diff --git a/package.json b/package.json index a9cae36..213448e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "timeinput", "widgetName": "TimeInput", - "version": "1.0.0", + "version": "1.1.0", "description": "Input field/dropdown for time", "copyright": "Jelte Lagendijk 2020", "author": "Jelte Lagendijk", diff --git a/src/components/TimeSelector.tsx b/src/components/TimeSelector.tsx index daf5439..6d56e2c 100644 --- a/src/components/TimeSelector.tsx +++ b/src/components/TimeSelector.tsx @@ -8,7 +8,22 @@ export interface TimeSelectorProps extends TimePickerProps { containerClassName?: string; } -export class TimeSelector extends Component { +interface TimeSelectorState { + focus: boolean; +} + +export class TimeSelector extends Component { + onOpen = this.openHandler.bind(this); + onClose = this.closeHandler.bind(this); + + constructor(props: TimeSelectorProps) { + super(props); + + this.state = { + focus: false + }; + } + render(): ReactNode { return ( { )} > { const { label } = this.props; return label === null ? null : ; } + + openHandler(): void { + this.setState({ focus: true }); + if (this.props.onOpen) { + this.props.onOpen({ open: true }); + } + } + + closeHandler(): void { + this.setState({ focus: false }); + if (this.props.onClose) { + this.props.onClose({ open: false }); + } + } } diff --git a/src/package.xml b/src/package.xml index 6081d5a..3fae44d 100644 --- a/src/package.xml +++ b/src/package.xml @@ -1,6 +1,6 @@ - +