UNPKG

2.25 kBTypeScriptView Raw
1import * as React from 'react';
2import { TextInputProps } from '../TextInput/TextInput';
3import { PopoverProps } from '../Popover/Popover';
4import { CalendarFormat } from '../CalendarMonth';
5export interface DatePickerProps extends CalendarFormat, Omit<React.HTMLProps<HTMLInputElement>, 'onChange' | 'onFocus' | 'onBlur' | 'disabled' | 'ref'> {
6 /** Additional classes added to the date time picker. */
7 className?: string;
8 /** Accessible label for the date picker */
9 'aria-label'?: string;
10 /** How to format the date in the TextInput */
11 dateFormat?: (date: Date) => string;
12 /** How to format the date in the TextInput */
13 dateParse?: (value: string) => Date;
14 /** Flag indicating the date picker is disabled*/
15 isDisabled?: boolean;
16 /** String to display in the empty date picker field as a hint for the expected date format */
17 placeholder?: string;
18 /** Value of TextInput */
19 value?: string;
20 /** Error message to display when the TextInput cannot be parsed. */
21 invalidFormatText?: string;
22 /** Callback called every time the input value changes */
23 onChange?: (value: string, date?: Date) => void;
24 /** Callback called every time the input loses focus */
25 onBlur?: (value: string, date?: Date) => void;
26 /** Text for label */
27 helperText?: React.ReactNode;
28 /** Aria label for the button to open the date picker */
29 buttonAriaLabel?: string;
30 /** The element to append the popover to */
31 appendTo?: HTMLElement | ((ref?: HTMLElement) => HTMLElement);
32 /** Props to pass to the Popover */
33 popoverProps?: Omit<PopoverProps, 'appendTo'>;
34 /** Functions that returns an error message if a date is invalid */
35 validators?: ((date: Date) => string)[];
36 /** Additional props for input field */
37 inputProps?: TextInputProps;
38}
39export interface DatePickerRef {
40 /** Sets the calendar open status */
41 setCalendarOpen: (isOpen: boolean) => void;
42 /** Toggles the calendar open status */
43 toggleCalendar: () => void;
44}
45export declare const yyyyMMddFormat: (date: Date) => string;
46export declare const DatePicker: React.ForwardRefExoticComponent<DatePickerProps & React.RefAttributes<DatePickerRef>>;
47//# sourceMappingURL=DatePicker.d.ts.map
\No newline at end of file