diff --git a/webapp/src/components/AutomationEditor/index.tsx b/webapp/src/components/AutomationEditor/index.tsx index 5d846cc..4160f99 100644 --- a/webapp/src/components/AutomationEditor/index.tsx +++ b/webapp/src/components/AutomationEditor/index.tsx @@ -14,7 +14,7 @@ import ModeEditOutlineTwoToneIcon from "@mui/icons-material/ModeEditOutlineTwoTo import { CheckMarkIcon } from "components/Icons"; import { Modal } from "components/Modal"; -import { Button } from "components/Inputs/Button"; +import { Button } from "components/Inputs/Buttons/Button"; import InputYaml from "components/Inputs/InputYaml"; import { TagDB } from "components/AutomationManager/TagDB"; import { DAGDims } from "components/DAGGraph/elements/types"; diff --git a/webapp/src/components/AutomationManager/MetadataBox/Tags.tsx b/webapp/src/components/AutomationManager/MetadataBox/Tags.tsx index c5a8a3c..6dddc70 100644 --- a/webapp/src/components/AutomationManager/MetadataBox/Tags.tsx +++ b/webapp/src/components/AutomationManager/MetadataBox/Tags.tsx @@ -8,7 +8,7 @@ import SaveIcon from "@mui/icons-material/SaveOutlined"; import { cleanUpUndefined } from "utils/helpers"; import { Modal } from "components/Modal"; -import { Button } from "components/Inputs/Button"; +import { Button } from "components/Inputs/Buttons/Button"; import InputAutoText from "components/Inputs/InputAutoText"; import { TagDB } from "../TagDB"; diff --git a/webapp/src/components/AutomationManager/Sidebar/index.tsx b/webapp/src/components/AutomationManager/Sidebar/index.tsx index 87aa03b..b94785a 100644 --- a/webapp/src/components/AutomationManager/Sidebar/index.tsx +++ b/webapp/src/components/AutomationManager/Sidebar/index.tsx @@ -16,7 +16,7 @@ import { AutomationManagerAuto, AutomationManagerAutoUpdatable, } from "../types"; -import { Button } from "components/Inputs/Button"; +import { Button } from "components/Inputs/Buttons/Button"; import { ButtonIcon } from "components/Icons/ButtonIcons"; export type AutomationManagerSidebarProps = { diff --git a/webapp/src/components/ConditionEditor/editorRender.tsx b/webapp/src/components/ConditionEditor/editorRender.tsx index dc38208..1b3989d 100644 --- a/webapp/src/components/ConditionEditor/editorRender.tsx +++ b/webapp/src/components/ConditionEditor/editorRender.tsx @@ -12,7 +12,7 @@ import { } from "types/automations/conditions"; import InputNumber from "components/Inputs/InputNumber"; import InputText from "components/Inputs/InputText"; -import { InputEntity } from "components/Inputs/InputEntities"; +import { InputEntity } from "components/Inputs/AutoComplete/InputEntities"; import { ConditionNodeBase, ConditionNodeBaseViewMode, @@ -25,11 +25,11 @@ import { DeviceEditor } from "components/DeviceEditor"; import { ButtonIcon } from "components/Icons/ButtonIcons"; import AddIcon from "@mui/icons-material/Add"; import { getEntityDomains } from "utils/automations"; -import { InputAutoComplete } from "components/Inputs/InputAutoComplete"; -import { InputTimeEntity } from "components/Inputs/InputTimeEntity"; +import { InputAutoComplete } from "components/Inputs/AutoComplete/InputAutoComplete"; +import { InputTimeEntity } from "components/Inputs/AutoComplete/InputTimeEntity"; import { prettyName } from "utils/formatting"; import { InputList } from "components/Inputs/InputList"; -import { Button } from "components/Inputs/Button"; +import { Button } from "components/Inputs/Buttons/Button"; import { RemoveCircle } from "@mui/icons-material"; interface Editor diff --git a/webapp/src/components/DAGGraph/elements/index.stories.tsx b/webapp/src/components/DAGGraph/elements/index.stories.tsx index 1a504bd..84bfcf3 100644 --- a/webapp/src/components/DAGGraph/elements/index.stories.tsx +++ b/webapp/src/components/DAGGraph/elements/index.stories.tsx @@ -8,67 +8,61 @@ import { AutomationActionData } from "types/automations"; import { createUpdaterFromAutomationData } from "../updater"; import { ModalState } from "../board/types"; import { DEFAULT_DIMS } from "./constants"; +import { makeStory } from "devUtils"; -const Demo: FC<{ - automation: AutomationActionData; - flipped: boolean; -}> = (props) => { - const { namer } = useHA(); - const [state, setState] = useState(props.automation); - const [modalState, setModalState] = - useState(undefined); - const updater = createUpdaterFromAutomationData( - setModalState, - state, - setState - ); - const elementData = useAutomationNodes(state, { - dims: { - ...DEFAULT_DIMS, - flipped: props.flipped, - }, - namer, - openModal: setModalState, - stateUpdater: updater, - }); - return ( - setModalState(undefined)} - state={{ - ready: true, - data: { - elements: elementData, - }, - }} - /> - ); -}; - -export default { - title: "DAGGraph/Elements", - component: Demo, - parameters: { actions: { argTypesRegex: "^on.*" } }, - args: { - flipped: true, - automation: { - trigger: [], - condition: [], - sequence: [], +const { make, componentMeta } = makeStory({ + Component: (props: { + automation: AutomationActionData; + flipped: boolean; + }) => { + const { namer } = useHA(); + const [state, setState] = useState(props.automation); + const [modalState, setModalState] = + useState(undefined); + const updater = createUpdaterFromAutomationData( + setModalState, + state, + setState + ); + const elementData = useAutomationNodes(state, { + dims: { + ...DEFAULT_DIMS, + flipped: props.flipped, + }, + namer, + openModal: setModalState, + stateUpdater: updater, + }); + return ( + setModalState(undefined)} + state={{ + ready: true, + data: { + elements: elementData, + }, + }} + /> + ); + }, + meta: { + title: "DAGGraph/Elements", + args: { + flipped: true, + automation: { + trigger: [], + condition: [], + sequence: [], + }, }, }, -} as ComponentMeta; +}); -const Template: ComponentStory = (args) => ( - - - -); +export default componentMeta; -export const Empty = Template.bind({}); -export const Trigger = Template.bind({}); -Trigger.args = { - ...Trigger.args, +export const Empty = make({}); +export const Trigger = make({ automation: { trigger: [ { platform: "homeassistant", event: "up" }, @@ -82,10 +76,9 @@ Trigger.args = { condition: [], sequence: [], }, -}; -export const Conditions = Template.bind({}); -Conditions.args = { - ...Conditions.args, +}); + +export const Conditions = make({ automation: { trigger: [ { @@ -119,11 +112,9 @@ Conditions.args = { ], sequence: [], }, -}; +}); -export const FullAuto = Template.bind({}); -FullAuto.args = { - ...FullAuto.args, +export const FullAuto = make({ automation: { condition: [ { @@ -272,11 +263,9 @@ FullAuto.args = { }, ], }, -}; +}); -export const ChooseAuto = Template.bind({}); -ChooseAuto.args = { - ...ChooseAuto.args, +export const ChooseAuto = make({ automation: { condition: [], trigger: [], @@ -370,12 +359,9 @@ ChooseAuto.args = { }, ], }, -}; +}); -export const EmptyChooseAuto = Template.bind({}); - -EmptyChooseAuto.args = { - ...EmptyChooseAuto.args, +export const EmptyChooseAuto = make({ automation: { condition: [], trigger: [], @@ -386,11 +372,9 @@ EmptyChooseAuto.args = { }, ], }, -}; +}); -export const RepeatAuto = Template.bind({}); -RepeatAuto.args = { - ...RepeatAuto.args, +export const RepeatAuto = make({ automation: { condition: [], trigger: [], @@ -437,11 +421,9 @@ RepeatAuto.args = { }, ], }, -}; +}); -export const ParallelAuto = Template.bind({}); -ParallelAuto.args = { - ...ParallelAuto.args, +export const ParallelAuto = make({ automation: { condition: [], trigger: [], @@ -467,11 +449,9 @@ ParallelAuto.args = { }, ], }, -}; +}); -export const BadNodes = Template.bind({}); -BadNodes.args = { - ...BadNodes.args, +export const BadNodes = make({ automation: { condition: [ { @@ -500,11 +480,9 @@ BadNodes.args = { }, ] as any, }, -}; +}); -export const IfElseNode = Template.bind({}); -IfElseNode.args = { - ...IfElseNode.args, +export const IfElseNode = make({ automation: { condition: [], trigger: [], @@ -516,4 +494,24 @@ IfElseNode.args = { }, ], }, -}; +}); + +export const TimeNodes = make({ + automation: { + condition: [], + trigger: [ + { + platform: "time", + at: "", + }, + { + platform: "time_pattern", + }, + ], + sequence: [ + { + condition: "time", + }, + ], + }, +}); diff --git a/webapp/src/components/DAGGraph/nodes/ButtonNode/ButtonNode.tsx b/webapp/src/components/DAGGraph/nodes/ButtonNode/ButtonNode.tsx index 8d820fa..be51b68 100644 --- a/webapp/src/components/DAGGraph/nodes/ButtonNode/ButtonNode.tsx +++ b/webapp/src/components/DAGGraph/nodes/ButtonNode/ButtonNode.tsx @@ -4,7 +4,7 @@ import { ButtonIcon } from "components/Icons/ButtonIcons"; import { FC } from "react"; import { ButtonNodeProps } from "./types"; import { Handle, Position } from "react-flow-renderer"; -import { Button } from "components/Inputs/Button"; +import { Button } from "components/Inputs/Buttons/Button"; export const ButtonNode: FC = ({ height, diff --git a/webapp/src/components/DeviceEditor/index.tsx b/webapp/src/components/DeviceEditor/index.tsx index 594ab63..fff7ba8 100644 --- a/webapp/src/components/DeviceEditor/index.tsx +++ b/webapp/src/components/DeviceEditor/index.tsx @@ -1,10 +1,10 @@ import { BaseOption, InputAutoComplete, -} from "components/Inputs/InputAutoComplete"; -import { InputDevice } from "components/Inputs/InputDevice"; -import { InputDeviceCapabilties } from "components/Inputs/InputDeviceCapabilties"; -import { InputEntity } from "components/Inputs/InputEntities"; +} from "components/Inputs/AutoComplete/InputAutoComplete"; +import { InputDevice } from "components/Inputs/AutoComplete/InputDevice"; +import { InputDeviceCapabilties } from "components/Inputs/AutoComplete/InputDeviceCapabilties"; +import { InputEntity } from "components/Inputs/AutoComplete/InputEntities"; import { cleanUpUndefined } from "utils/helpers"; import { DeviceBaseType, DeviceTypeCapability } from "haService/types"; import { AutomationDeviceState } from "types/automations/common"; diff --git a/webapp/src/components/Inputs/InputArea.tsx b/webapp/src/components/Inputs/AutoComplete/InputArea.tsx similarity index 100% rename from webapp/src/components/Inputs/InputArea.tsx rename to webapp/src/components/Inputs/AutoComplete/InputArea.tsx diff --git a/webapp/src/components/Inputs/InputAutoComplete.css b/webapp/src/components/Inputs/AutoComplete/InputAutoComplete.css similarity index 100% rename from webapp/src/components/Inputs/InputAutoComplete.css rename to webapp/src/components/Inputs/AutoComplete/InputAutoComplete.css diff --git a/webapp/src/components/Inputs/InputAutoComplete.test.ts b/webapp/src/components/Inputs/AutoComplete/InputAutoComplete.test.ts similarity index 100% rename from webapp/src/components/Inputs/InputAutoComplete.test.ts rename to webapp/src/components/Inputs/AutoComplete/InputAutoComplete.test.ts diff --git a/webapp/src/components/Inputs/InputAutoComplete.tsx b/webapp/src/components/Inputs/AutoComplete/InputAutoComplete.tsx similarity index 100% rename from webapp/src/components/Inputs/InputAutoComplete.tsx rename to webapp/src/components/Inputs/AutoComplete/InputAutoComplete.tsx diff --git a/webapp/src/components/Inputs/InputDevice.stories.tsx b/webapp/src/components/Inputs/AutoComplete/InputDevice.stories.tsx similarity index 100% rename from webapp/src/components/Inputs/InputDevice.stories.tsx rename to webapp/src/components/Inputs/AutoComplete/InputDevice.stories.tsx diff --git a/webapp/src/components/Inputs/InputDevice.tsx b/webapp/src/components/Inputs/AutoComplete/InputDevice.tsx similarity index 100% rename from webapp/src/components/Inputs/InputDevice.tsx rename to webapp/src/components/Inputs/AutoComplete/InputDevice.tsx diff --git a/webapp/src/components/Inputs/InputDeviceCapabilties.css b/webapp/src/components/Inputs/AutoComplete/InputDeviceCapabilties.css similarity index 100% rename from webapp/src/components/Inputs/InputDeviceCapabilties.css rename to webapp/src/components/Inputs/AutoComplete/InputDeviceCapabilties.css diff --git a/webapp/src/components/Inputs/InputDeviceCapabilties.tsx b/webapp/src/components/Inputs/AutoComplete/InputDeviceCapabilties.tsx similarity index 95% rename from webapp/src/components/Inputs/InputDeviceCapabilties.tsx rename to webapp/src/components/Inputs/AutoComplete/InputDeviceCapabilties.tsx index 6121fd8..daf7caa 100644 --- a/webapp/src/components/Inputs/InputDeviceCapabilties.tsx +++ b/webapp/src/components/Inputs/AutoComplete/InputDeviceCapabilties.tsx @@ -4,10 +4,10 @@ import { useSnackbar } from "notistack"; import { useRef } from "react"; import { prettyName } from "utils/formatting"; import { InputAutoComplete, Option } from "./InputAutoComplete"; -import InputBoolean from "./InputBoolean"; -import { InputTime } from "./InputDayTime"; -import InputNumber from "./InputNumber"; -import InputText from "./InputText"; +import InputBoolean from "../InputBoolean"; +import { InputTime } from "../InputDayTime"; +import InputNumber from "../InputNumber"; +import InputText from "../InputText"; export type InputDeviceCapabiltiesProps> = { defn: HaFormSchema[]; diff --git a/webapp/src/components/Inputs/InputEntities.tsx b/webapp/src/components/Inputs/AutoComplete/InputEntities.tsx similarity index 100% rename from webapp/src/components/Inputs/InputEntities.tsx rename to webapp/src/components/Inputs/AutoComplete/InputEntities.tsx diff --git a/webapp/src/components/Inputs/InputEntityID.stories.tsx b/webapp/src/components/Inputs/AutoComplete/InputEntityID.stories.tsx similarity index 100% rename from webapp/src/components/Inputs/InputEntityID.stories.tsx rename to webapp/src/components/Inputs/AutoComplete/InputEntityID.stories.tsx diff --git a/webapp/src/components/Inputs/InputService.stories.tsx b/webapp/src/components/Inputs/AutoComplete/InputService.stories.tsx similarity index 100% rename from webapp/src/components/Inputs/InputService.stories.tsx rename to webapp/src/components/Inputs/AutoComplete/InputService.stories.tsx diff --git a/webapp/src/components/Inputs/InputService.tsx b/webapp/src/components/Inputs/AutoComplete/InputService.tsx similarity index 100% rename from webapp/src/components/Inputs/InputService.tsx rename to webapp/src/components/Inputs/AutoComplete/InputService.tsx diff --git a/webapp/src/components/Inputs/InputTimeEntity.css b/webapp/src/components/Inputs/AutoComplete/InputTimeEntity.css similarity index 100% rename from webapp/src/components/Inputs/InputTimeEntity.css rename to webapp/src/components/Inputs/AutoComplete/InputTimeEntity.css diff --git a/webapp/src/components/Inputs/InputTimeEntity.stories.tsx b/webapp/src/components/Inputs/AutoComplete/InputTimeEntity.stories.tsx similarity index 100% rename from webapp/src/components/Inputs/InputTimeEntity.stories.tsx rename to webapp/src/components/Inputs/AutoComplete/InputTimeEntity.stories.tsx diff --git a/webapp/src/components/Inputs/InputTimeEntity.tsx b/webapp/src/components/Inputs/AutoComplete/InputTimeEntity.tsx similarity index 97% rename from webapp/src/components/Inputs/InputTimeEntity.tsx rename to webapp/src/components/Inputs/AutoComplete/InputTimeEntity.tsx index 39c15b0..12053fc 100644 --- a/webapp/src/components/Inputs/InputTimeEntity.tsx +++ b/webapp/src/components/Inputs/AutoComplete/InputTimeEntity.tsx @@ -11,7 +11,7 @@ import { isAutomationTimeString24Hours, } from "utils/time"; import { InputEntity } from "./InputEntities"; -import { InputTime } from "./InputTime"; +import { InputTime } from "../InputTime"; export type InputTimeEntityProps = { value: string; diff --git a/webapp/src/components/Inputs/extras-SearchItem.stories.tsx b/webapp/src/components/Inputs/AutoComplete/extras-SearchItem.stories.tsx similarity index 100% rename from webapp/src/components/Inputs/extras-SearchItem.stories.tsx rename to webapp/src/components/Inputs/AutoComplete/extras-SearchItem.stories.tsx diff --git a/webapp/src/components/Inputs/extras.css b/webapp/src/components/Inputs/AutoComplete/extras.css similarity index 100% rename from webapp/src/components/Inputs/extras.css rename to webapp/src/components/Inputs/AutoComplete/extras.css diff --git a/webapp/src/components/Inputs/extras.tsx b/webapp/src/components/Inputs/AutoComplete/extras.tsx similarity index 100% rename from webapp/src/components/Inputs/extras.tsx rename to webapp/src/components/Inputs/AutoComplete/extras.tsx diff --git a/webapp/src/components/Inputs/Button.tsx b/webapp/src/components/Inputs/Buttons/Button.tsx similarity index 100% rename from webapp/src/components/Inputs/Button.tsx rename to webapp/src/components/Inputs/Buttons/Button.tsx diff --git a/webapp/src/components/Modal/index.stories.tsx b/webapp/src/components/Modal/index.stories.tsx index 5d23799..7fbda0f 100644 --- a/webapp/src/components/Modal/index.stories.tsx +++ b/webapp/src/components/Modal/index.stories.tsx @@ -1,33 +1,36 @@ import React from "react"; -import { ComponentMeta, ComponentStory } from '@storybook/react'; +import { ComponentMeta, ComponentStory } from "@storybook/react"; import { Modal } from "."; -import { useState } from 'react'; -import { Button } from "components/Inputs/Button"; - +import { useState } from "react"; +import { Button } from "components/Inputs/Buttons/Button"; export default { - title: 'Modal', + title: "Modal", component: Modal, - parameters: { actions: { argTypesRegex: '^on.*' } }, + parameters: { actions: { argTypesRegex: "^on.*" } }, args: { - open: true - } -} as ComponentMeta + open: true, + }, +} as ComponentMeta; -export const Simple: ComponentStory = args => { - return <> - -
Hello World!
-
- -} -export const WithButtons: ComponentStory = args => { +export const Simple: ComponentStory = (args) => { + return ( + <> + +
Hello World!
+
+ + ); +}; +export const WithButtons: ComponentStory = (args) => { const [open, setOpen] = useState(false); - return <> - - -
Hello World!
- -
- -} + return ( + <> + + +
Hello World!
+ +
+ + ); +}; diff --git a/webapp/src/components/NodeEditor/OptionManager/ActionRepeat.tsx b/webapp/src/components/NodeEditor/OptionManager/ActionRepeat.tsx index 713b0fc..461ff9f 100644 --- a/webapp/src/components/NodeEditor/OptionManager/ActionRepeat.tsx +++ b/webapp/src/components/NodeEditor/OptionManager/ActionRepeat.tsx @@ -1,7 +1,7 @@ import InputNumber from "components/Inputs/InputNumber"; import { RepeatAction } from "types/automations/actions"; import { OptionManager } from "./OptionManager"; -import { InputAutoComplete } from "components/Inputs/InputAutoComplete"; +import { InputAutoComplete } from "components/Inputs/AutoComplete/InputAutoComplete"; const determineType = (repeatNode: RepeatAction["repeat"]) => "count" in repeatNode ? "count" : "until" in repeatNode ? "until" : "while"; diff --git a/webapp/src/components/NodeEditor/OptionManager/ActionService.tsx b/webapp/src/components/NodeEditor/OptionManager/ActionService.tsx index c28a7dc..641c4f6 100644 --- a/webapp/src/components/NodeEditor/OptionManager/ActionService.tsx +++ b/webapp/src/components/NodeEditor/OptionManager/ActionService.tsx @@ -1,4 +1,4 @@ -import { InputService } from "components/Inputs/InputService"; +import { InputService } from "components/Inputs/AutoComplete/InputService"; import { ServiceEditor } from "components/ServiceEditor"; import { ServiceAction } from "types/automations/actions"; import { OptionManager, updateActionData } from "./OptionManager"; diff --git a/webapp/src/components/NodeEditor/OptionManager/TriggerNumericState.tsx b/webapp/src/components/NodeEditor/OptionManager/TriggerNumericState.tsx index 28f8f5e..963ec11 100644 --- a/webapp/src/components/NodeEditor/OptionManager/TriggerNumericState.tsx +++ b/webapp/src/components/NodeEditor/OptionManager/TriggerNumericState.tsx @@ -1,63 +1,82 @@ -import { OptionManager } from './OptionManager'; -import { AutomationTriggerNumericState } from 'types/automations/triggers'; -import InputText from 'components/Inputs/InputText'; -import { InputEntity } from 'components/Inputs/InputEntities'; -import InputNumber from 'components/Inputs/InputNumber'; -import { InputTime } from 'components/Inputs/InputTime'; import InputYaml from 'components/Inputs/InputYaml'; +import { OptionManager } from "./OptionManager"; +import { AutomationTriggerNumericState } from "types/automations/triggers"; +import InputText from "components/Inputs/InputText"; +import { InputEntity } from "components/Inputs/AutoComplete/InputEntities"; +import InputNumber from "components/Inputs/InputNumber"; +import { InputTime } from "components/Inputs/InputTime"; +import InputYaml from "components/Inputs/InputYaml"; - -export const TriggerNumericState: OptionManager = { - defaultState: () => ({ - "platform": 'numeric_state', - "entity_id": "", - }), - isReady: () => true, - renderOptionList: (state, setState) => { - return <> - setState({ - ...state, - entity_id - })} - /> - setState({ - ...state, - attribute - })} /> - setState({ - ...state, - above: above ? String(above) : undefined, - })} - /> - setState({ - ...state, - below: below ? String(below) : undefined, - })} - /> - setState({ - ...state, - value_template - })} - /> - setState({ - ...state, - for: _for, - })} - /> - - } -} +export const TriggerNumericState: OptionManager = + { + defaultState: () => ({ + platform: "numeric_state", + entity_id: "", + }), + isReady: () => true, + renderOptionList: (state, setState) => { + return ( + <> + + setState({ + ...state, + entity_id, + }) + } + /> + + setState({ + ...state, + attribute, + }) + } + /> + + setState({ + ...state, + above: above ? String(above) : undefined, + }) + } + /> + + setState({ + ...state, + below: below ? String(below) : undefined, + }) + } + /> + + setState({ + ...state, + value_template, + }) + } + /> + + setState({ + ...state, + for: _for, + }) + } + /> + + ); + }, + }; diff --git a/webapp/src/components/NodeEditor/OptionManager/TriggerState.tsx b/webapp/src/components/NodeEditor/OptionManager/TriggerState.tsx index d5c5833..18440d8 100644 --- a/webapp/src/components/NodeEditor/OptionManager/TriggerState.tsx +++ b/webapp/src/components/NodeEditor/OptionManager/TriggerState.tsx @@ -1,9 +1,9 @@ import { OptionManager } from "./OptionManager"; import { AutomationTriggerState } from "types/automations/triggers"; import InputText from "components/Inputs/InputText"; -import { InputEntity } from "components/Inputs/InputEntities"; +import { InputEntity } from "components/Inputs/AutoComplete/InputEntities"; import { InputTime } from "components/Inputs/InputTime"; -import { InputAutoComplete } from "components/Inputs/InputAutoComplete"; +import { InputAutoComplete } from "components/Inputs/AutoComplete/InputAutoComplete"; import { FC } from "react"; import { getEntityDomains } from "utils/automations"; import { InputList } from "components/Inputs/InputList"; diff --git a/webapp/src/components/NodeEditor/OptionManager/TriggerTime.tsx b/webapp/src/components/NodeEditor/OptionManager/TriggerTime.tsx index 874da55..5025017 100644 --- a/webapp/src/components/NodeEditor/OptionManager/TriggerTime.tsx +++ b/webapp/src/components/NodeEditor/OptionManager/TriggerTime.tsx @@ -11,10 +11,10 @@ import { import InputText from "components/Inputs/InputText"; import { FC } from "react"; import { InputList } from "components/Inputs/InputList"; -import { Button } from "components/Inputs/Button"; +import { Button } from "components/Inputs/Buttons/Button"; import { useState } from "react"; import AddIcon from "@mui/icons-material/Add"; -import { InputTimeEntity } from "components/Inputs/InputTimeEntity"; +import { InputTimeEntity } from "components/Inputs/AutoComplete/InputTimeEntity"; export const TriggerTime: OptionManager = { defaultState: () => ({ @@ -59,7 +59,8 @@ export const TriggerTime: OptionManager = { divisible by that number. You can specify "*" to match any value.{" "} More Info. diff --git a/webapp/src/components/NodeEditor/OptionManager/TriggerZone.tsx b/webapp/src/components/NodeEditor/OptionManager/TriggerZone.tsx index fd8390a..4921e69 100644 --- a/webapp/src/components/NodeEditor/OptionManager/TriggerZone.tsx +++ b/webapp/src/components/NodeEditor/OptionManager/TriggerZone.tsx @@ -1,40 +1,53 @@ -import { OptionManager } from './OptionManager'; -import { AutomationTriggerZone } from 'types/automations/triggers'; -import { InputList } from 'components/Inputs/InputList'; -import { InputEntity } from 'components/Inputs/InputEntities'; - +import { OptionManager } from "./OptionManager"; +import { AutomationTriggerZone } from "types/automations/triggers"; +import { InputList } from "components/Inputs/InputList"; +import { InputEntity } from "components/Inputs/AutoComplete/InputEntities"; export const TriggerZone: OptionManager = { defaultState: () => ({ - "platform": 'zone', - "zone": "", - "event": "enter", - "entity_id": "", + platform: "zone", + zone: "", + event: "enter", + entity_id: "", }), isReady: () => true, renderOptionList: (state, setState) => { - return <> - setState({ - ...state, - zone: zone ?? "" - })} /> - setState({ - ...state, event, - })} - /> - setState({ - ...state, - entity_id - })} - /> - - } -} + return ( + <> + + setState({ + ...state, + zone: zone ?? "", + }) + } + /> + + setState({ + ...state, + event, + }) + } + /> + + setState({ + ...state, + entity_id, + }) + } + /> + + ); + }, +}; diff --git a/webapp/src/components/NodeEditor/index.stories.tsx b/webapp/src/components/NodeEditor/index.stories.tsx index 01e9241..b4c2a50 100644 --- a/webapp/src/components/NodeEditor/index.stories.tsx +++ b/webapp/src/components/NodeEditor/index.stories.tsx @@ -3,7 +3,7 @@ import { ComponentMeta, ComponentStory } from "@storybook/react"; import { NodeEditor } from "."; import { AutomationCondition } from "types/automations/conditions"; -import { Button } from "components/Inputs/Button"; +import { Button } from "components/Inputs/Buttons/Button"; import { useState } from "react"; import { Modal } from "components/Modal"; import { Page } from "components/Page"; diff --git a/webapp/src/components/NodeEditor/index.tsx b/webapp/src/components/NodeEditor/index.tsx index b4db582..1a96e89 100644 --- a/webapp/src/components/NodeEditor/index.tsx +++ b/webapp/src/components/NodeEditor/index.tsx @@ -4,7 +4,7 @@ import { FC, ReactNode } from "react"; import { AutomationNode, AutomationNodeMapping } from "types/automations/index"; import { useEditorNodeState } from "./OptionManager"; import { InputList } from "components/Inputs/InputList"; -import { Button } from "components/Inputs/Button"; +import { Button } from "components/Inputs/Buttons/Button"; import InputBoolean from "components/Inputs/InputBoolean"; import { useConfirm } from "material-ui-confirm"; import { getNodeSubTypeDescription } from "./utils"; diff --git a/webapp/src/components/ServiceEditor/ServiceEditorField.tsx b/webapp/src/components/ServiceEditor/ServiceEditorField.tsx index 732e9fc..b8f601f 100644 --- a/webapp/src/components/ServiceEditor/ServiceEditorField.tsx +++ b/webapp/src/components/ServiceEditor/ServiceEditorField.tsx @@ -4,13 +4,16 @@ import { ServiceEditorOption } from "./options"; import InputText from "components/Inputs/InputText"; import InputNumber from "components/Inputs/InputNumber"; import { RemoveCircle } from "@mui/icons-material"; -import { InputAutoComplete, Option } from "components/Inputs/InputAutoComplete"; +import { + InputAutoComplete, + Option, +} from "components/Inputs/AutoComplete/InputAutoComplete"; import { prettyName } from "utils/formatting"; import InputBoolean from "components/Inputs/InputBoolean"; import { SelectorNumber, SelectorText } from "haService/fieldTypes"; import InputYaml from "components/Inputs/InputYaml"; import { useSnackbar } from "notistack"; -import { InputEntity } from "components/Inputs/InputEntities"; +import { InputEntity } from "components/Inputs/AutoComplete/InputEntities"; import { ButtonIcon } from "components/Icons/ButtonIcons"; export type ServiceEditorFieldProps = { diff --git a/webapp/src/components/ServiceEditor/ServiceEditorTarget.tsx b/webapp/src/components/ServiceEditor/ServiceEditorTarget.tsx index 260ac1f..1cc8b41 100644 --- a/webapp/src/components/ServiceEditor/ServiceEditorTarget.tsx +++ b/webapp/src/components/ServiceEditor/ServiceEditorTarget.tsx @@ -1,9 +1,9 @@ import "./ServiceEditorTarget.css"; -import { InputDevice } from "components/Inputs/InputDevice"; -import { InputEntity } from "components/Inputs/InputEntities"; +import { InputDevice } from "components/Inputs/AutoComplete/InputDevice"; +import { InputEntity } from "components/Inputs/AutoComplete/InputEntities"; import { Targets } from "haService/fieldTypes"; import { FC } from "react"; -import { InputArea } from "components/Inputs/InputArea"; +import { InputArea } from "components/Inputs/AutoComplete/InputArea"; type RawTargetData = { entity_id?: string[] | string; diff --git a/webapp/src/components/ServiceEditor/index.tsx b/webapp/src/components/ServiceEditor/index.tsx index 5d4bfdf..bf2ae40 100644 --- a/webapp/src/components/ServiceEditor/index.tsx +++ b/webapp/src/components/ServiceEditor/index.tsx @@ -10,7 +10,7 @@ import { ServiceEditorData, } from "./options"; import { ServiceEditorField } from "./ServiceEditorField"; -import { InputAutoComplete } from "components/Inputs/InputAutoComplete"; +import { InputAutoComplete } from "components/Inputs/AutoComplete/InputAutoComplete"; import { ServiceEditorTarget } from "./ServiceEditorTarget"; export type ServiceEditorProps = { diff --git a/webapp/src/components/ServiceEditor/options.ts b/webapp/src/components/ServiceEditor/options.ts index da2236e..c11181d 100644 --- a/webapp/src/components/ServiceEditor/options.ts +++ b/webapp/src/components/ServiceEditor/options.ts @@ -1,4 +1,4 @@ -import { BaseOption } from "components/Inputs/InputAutoComplete"; +import { BaseOption } from "components/Inputs/AutoComplete/InputAutoComplete"; import { FieldData, TypedHassService } from "haService/fieldTypes"; import { prettyName } from "utils/formatting"; @@ -7,17 +7,22 @@ export type ServiceEditorData = { target: Record; }; export type ServiceEditorOption = BaseOption<{ - data: FieldData + data: FieldData; }>; -export const convertFieldToOption = (id: string, data: FieldData): ServiceEditorOption => ({ +export const convertFieldToOption = ( + id: string, + data: FieldData +): ServiceEditorOption => ({ id, label: data.name ?? prettyName(id), data, -}) +}); - -export const splitUpOptions = (service: TypedHassService, data: ServiceEditorData) => { +export const splitUpOptions = ( + service: TypedHassService, + data: ServiceEditorData +) => { const required: ServiceEditorOption[] = []; const additional: ServiceEditorOption[] = []; const incmFields: string[] = []; @@ -28,7 +33,7 @@ export const splitUpOptions = (service: TypedHassService, data: ServiceEditorDat required.push(opt); } else { if (data.field[opt.id]) { - incmFields.push(opt.id) + incmFields.push(opt.id); } else { additional.push(opt); } diff --git a/webapp/src/haService/AreaRegistry.ts b/webapp/src/haService/AreaRegistry.ts index 7a80763..09aba63 100644 --- a/webapp/src/haService/AreaRegistry.ts +++ b/webapp/src/haService/AreaRegistry.ts @@ -1,6 +1,9 @@ import { Connection, getCollection } from "home-assistant-js-websocket"; import { useHassCollection } from "./useHassCollection"; -import { Option, BaseOption } from "components/Inputs/InputAutoComplete"; +import { + Option, + BaseOption, +} from "components/Inputs/AutoComplete/InputAutoComplete"; import { EntityRegisteryItem, HassEntitiesRegistry } from "./types"; import { prettyName } from "utils/formatting"; diff --git a/webapp/src/haService/HAEntities.ts b/webapp/src/haService/HAEntities.ts index a1400f3..343484f 100644 --- a/webapp/src/haService/HAEntities.ts +++ b/webapp/src/haService/HAEntities.ts @@ -1,4 +1,4 @@ -import { Option } from "components/Inputs/InputAutoComplete"; +import { Option } from "components/Inputs/AutoComplete/InputAutoComplete"; import { HACollectionState, useHassCollection } from "./useHassCollection"; import { entitiesColl, HassEntities } from "home-assistant-js-websocket"; import { entitySourceColl } from "./additionalCollections"; diff --git a/webapp/src/haService/automation.stories.tsx b/webapp/src/haService/automation.stories.tsx index 0230279..9d052bb 100644 --- a/webapp/src/haService/automation.stories.tsx +++ b/webapp/src/haService/automation.stories.tsx @@ -4,7 +4,7 @@ import { Page } from "components/Page"; import { useHA } from "haService"; import InputYaml from "components/Inputs/InputYaml"; import { InputList } from "components/Inputs/InputList"; -import { Button } from "components/Inputs/Button"; +import { Button } from "components/Inputs/Buttons/Button"; import { ServiceEditor } from "components/ServiceEditor"; const Test: FC = () => { diff --git a/webapp/src/haService/extras.ts b/webapp/src/haService/extras.ts index 96651aa..602b593 100644 --- a/webapp/src/haService/extras.ts +++ b/webapp/src/haService/extras.ts @@ -1,4 +1,4 @@ -import { BaseOption } from "components/Inputs/InputAutoComplete"; +import { BaseOption } from "components/Inputs/AutoComplete/InputAutoComplete"; import { MessageBase } from "home-assistant-js-websocket"; import { useEffect, useRef, useState } from "react"; import { prettyName } from "utils/formatting"; diff --git a/webapp/src/haService/index.ts b/webapp/src/haService/index.ts index fd76185..0547ca0 100644 --- a/webapp/src/haService/index.ts +++ b/webapp/src/haService/index.ts @@ -9,7 +9,7 @@ import { useHassCollection } from "./useHassCollection"; import { useHAConnection } from "./connection"; import { useSnackbar } from "notistack"; import { TypedHassService } from "./fieldTypes"; -import { Option } from "components/Inputs/InputAutoComplete"; +import { Option } from "components/Inputs/AutoComplete/InputAutoComplete"; import { getDeviceExtraWsCalls } from "./extras"; import { useHAEntities } from "./HAEntities"; diff --git a/webapp/src/haService/services.stories.tsx b/webapp/src/haService/services.stories.tsx index 7705437..6b4def1 100644 --- a/webapp/src/haService/services.stories.tsx +++ b/webapp/src/haService/services.stories.tsx @@ -4,7 +4,7 @@ import { Page } from "components/Page"; import { useHA } from "haService"; import InputYaml from "components/Inputs/InputYaml"; import { InputList } from "components/Inputs/InputList"; -import { Button } from "components/Inputs/Button"; +import { Button } from "components/Inputs/Buttons/Button"; import { ServiceEditor } from "components/ServiceEditor"; const Test: FC = () => {