cleaned up time trigger
This commit is contained in:
1 parent
ef02abe0cb
commit
3a44057a40
14 files changed
+536
-167
No files matched your search
@@ -10,6 +10,8 @@ export type InputEntityProps = InputAutoCompletePropsBase & {
|
||||
restrictToDomain?: string[];
|
||||
restrictedIntegrations?: string[];
|
||||
preSelectedEntityIds?: string[];
|
||||
restrictedDeviceClass?: string[];
|
||||
restrictMode?: "and" | "or";
|
||||
};
|
||||
|
||||
export const InputEntity: FC<InputEntityProps> = (props) => {
|
||||
@@ -17,7 +19,9 @@ export const InputEntity: FC<InputEntityProps> = (props) => {
|
||||
const entities = useHAEntities();
|
||||
let options = entities.getOptions(
|
||||
props.restrictToDomain,
|
||||
props.restrictedIntegrations
|
||||
props.restrictedIntegrations,
|
||||
props.restrictedDeviceClass,
|
||||
props.restrictMode ?? "and"
|
||||
);
|
||||
if (props.preSelectedEntityIds) {
|
||||
options = options.filter((opt) =>
|
||||
|
||||
@@ -6,29 +6,35 @@ import { AutomationTime } from "types/automations/common";
|
||||
import { InputTime } from "./InputTime";
|
||||
|
||||
export default {
|
||||
title: 'Inputs/InputTime',
|
||||
title: "Inputs/InputTime",
|
||||
component: InputTime,
|
||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||
parameters: { actions: { argTypesRegex: "^on.*" } },
|
||||
} as ComponentMeta<typeof InputTime>;
|
||||
|
||||
|
||||
const Template: ComponentStory<typeof InputTime> = args => {
|
||||
|
||||
const Template: ComponentStory<typeof InputTime> = (args) => {
|
||||
const [value, setValue] = useState<AutomationTime | undefined>(undefined);
|
||||
return <Page>
|
||||
<div style={{
|
||||
padding: '1em'
|
||||
}}>
|
||||
<InputTime {...args} value={value} onChange={t => {
|
||||
setValue(t)
|
||||
args.onChange(t)
|
||||
}} />
|
||||
</div>
|
||||
</Page>
|
||||
}
|
||||
return (
|
||||
<Page>
|
||||
<div
|
||||
style={{
|
||||
padding: "1em",
|
||||
}}
|
||||
>
|
||||
<InputTime
|
||||
{...args}
|
||||
value={args.restrictEmpty ? "00:00:00" : value}
|
||||
onChange={(t) => {
|
||||
setValue(t);
|
||||
args.onChange(t);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</Page>
|
||||
);
|
||||
};
|
||||
|
||||
export const SimpleText = Template.bind({})
|
||||
export const SimpleText = Template.bind({});
|
||||
SimpleText.args = {
|
||||
label: "Time Stamp",
|
||||
value: "10"
|
||||
}
|
||||
value: "10",
|
||||
};
|
||||
@@ -19,13 +19,14 @@ const fields: Array<keyof AutomationTimeObject> = [
|
||||
"seconds",
|
||||
"milliseconds",
|
||||
];
|
||||
export interface Props {
|
||||
export type InputTimeProps = {
|
||||
label: string;
|
||||
value?: AutomationTime;
|
||||
onChange: (v?: AutomationTimeObject) => void;
|
||||
className?: string;
|
||||
}
|
||||
export const InputTime: FC<Props> = (props) => {
|
||||
value?: AutomationTime;
|
||||
restrictEmpty?: boolean;
|
||||
};
|
||||
export const InputTime: FC<InputTimeProps> = (props) => {
|
||||
// state
|
||||
const [disabled, setDisabled] = useState(!props.value);
|
||||
const [displayValue, setDisplayValue] = useState(
|
||||
@@ -140,10 +141,12 @@ export const InputTime: FC<Props> = (props) => {
|
||||
onChange={(e) => updateOne(name)(e.target.value)}
|
||||
/>
|
||||
))}
|
||||
<ButtonIcon
|
||||
onClick={() => setDisabled(!disabled)}
|
||||
icon={disabled ? <EditIcon /> : <CloseIcon />}
|
||||
/>
|
||||
{!props.restrictEmpty && (
|
||||
<ButtonIcon
|
||||
onClick={() => setDisabled(!disabled)}
|
||||
icon={disabled ? <EditIcon /> : <CloseIcon />}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user