1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

datepicker

This commit is contained in:
Jernej Pregelj 2019-04-05 16:14:26 +02:00
parent a1ab653ffb
commit 2dedbc19e0

View File

@ -23,6 +23,7 @@ interface InputProps {
value?: string value?: string
onChange?( onChange?(
event: event:
| any
| FormEvent<HTMLInputElement> | FormEvent<HTMLInputElement>
| ChangeEvent<HTMLInputElement> | ChangeEvent<HTMLInputElement>
| ChangeEvent<HTMLSelectElement> | ChangeEvent<HTMLSelectElement>
@ -39,6 +40,7 @@ interface InputState {
} }
export default class Input extends PureComponent<InputProps, InputState> { export default class Input extends PureComponent<InputProps, InputState> {
hiddenDate: any
public state: InputState = { public state: InputState = {
isFocused: false, isFocused: false,
startDate: new Date() startDate: new Date()
@ -64,6 +66,13 @@ export default class Input extends PureComponent<InputProps, InputState> {
this.setState({ this.setState({
startDate: date startDate: date
}) })
const event = {
currentTarget: {
name: 'startDate',
value: date
}
}
this.props.onChange!(event as any)
} }
public InputComponent = () => { public InputComponent = () => {
@ -157,7 +166,6 @@ export default class Input extends PureComponent<InputProps, InputState> {
<div className={wrapClass}> <div className={wrapClass}>
<DatePicker <DatePicker
selected={this.state.startDate} selected={this.state.startDate}
// TODO: this needs to be able to receive this.props.onChange too
onChange={this.handleDateChange} onChange={this.handleDateChange}
className={styles.input} className={styles.input}
onFocus={this.toggleFocus} onFocus={this.toggleFocus}