-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enables typing for ReactDatePicker usage
- Loading branch information
1 parent
a5e12fa
commit 11193d6
Showing
2 changed files
with
13 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import React, { Component, MouseEventHandler } from 'react'; | ||
import React, { Component, MouseEventHandler, Ref } from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
import { Moment } from 'moment'; // eslint-disable-line import/named | ||
import { ReactDatePicker as DatePicker } from '../../../packages'; | ||
// @ts-ignore the type is provided by | ||
import { ReactDatePicker as _ReactDatePicker } from '../../../packages'; | ||
|
||
import { EuiFormControlLayout, EuiValidatableControl } from '../form'; | ||
|
||
|
@@ -17,6 +18,8 @@ import { EuiFormControlLayoutIconsProps } from '../form/form_control_layout/form | |
export const euiDatePickerDefaultDateFormat = 'MM/DD/YYYY'; | ||
export const euiDatePickerDefaultTimeFormat = 'hh:mm A'; | ||
|
||
const DatePicker = _ReactDatePicker as typeof ReactDatePicker; | ||
|
||
interface EuiExtendedDatePickerProps extends ReactDatePickerProps { | ||
/** | ||
* Applies classes to the numbered days provided. Check docs for example. | ||
|
@@ -28,15 +31,10 @@ interface EuiExtendedDatePickerProps extends ReactDatePickerProps { | |
*/ | ||
fullWidth?: boolean; | ||
|
||
/** | ||
* Adds additional times to the time selector other then :30 increments | ||
*/ | ||
injectTimes?: Moment[]; // added here because the type is missing in @types/[email protected] | ||
|
||
/** | ||
* Applies ref to the input | ||
*/ | ||
inputRef?: React.Ref<typeof ReactDatePicker>; | ||
inputRef: Ref<typeof ReactDatePicker>; | ||
|
||
/** | ||
* Provides styling to the input when invalid | ||
|
@@ -81,6 +79,7 @@ export class EuiDatePicker extends Component<EuiDatePickerProps> { | |
adjustDateOnChange: true, | ||
dateFormat: euiDatePickerDefaultDateFormat, | ||
fullWidth: false, | ||
inputRef: () => {}, | ||
isLoading: false, | ||
shadow: true, | ||
shouldCloseOnSelect: true, | ||
|
@@ -229,6 +228,7 @@ export class EuiDatePicker extends Component<EuiDatePickerProps> { | |
openToDate={openToDate} | ||
placeholderText={placeholder} | ||
popperClassName={popperClassName} | ||
// @ts-ignore this is due to `react-datepicker` (i.e. `ReactDatePicker`, this component) being a `React.ClassicComponentClass` rather than a `React.Component`. | ||
ref={inputRef} | ||
selected={selected} | ||
shouldCloseOnSelect={shouldCloseOnSelect} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,11 @@ export interface ReactDatePickerProps { | |
includeDates?: moment.Moment[]; | ||
includeTimes?: moment.Moment[]; | ||
inline?: boolean; | ||
|
||
/** | ||
* Adds additional times to the time selector other then :30 increments | ||
*/ | ||
injectTimes?: moment.Moment[]; // added here because the type is missing in @types/[email protected] | ||
isClearable?: boolean; | ||
|
||
/** | ||
|