UNPKG

4.92 kBTypeScriptView Raw
1import React from 'react';
2import { CalendarProps } from './Calendar';
3import { DatePickerInputProps } from './DatePickerInput';
4import { DateFormats } from './Localization';
5import { PopupProps } from './Popup';
6import { TimeInputProps } from './TimeInput';
7import { WidgetProps } from './Widget';
8import { TransitionProps } from 'react-transition-group/Transition';
9import { WidgetHTMLProps, InferFormat } from './shared';
10export interface DatePickerProps<TLocalizer = unknown> extends Omit<WidgetHTMLProps, 'onChange' | 'defaultValue'>, Omit<WidgetProps, 'onChange' | 'onSelect' | 'defaultValue'> {
11 /**
12 * @example ['valuePicker', [ ['new Date()', null] ]]
13 */
14 value?: Date | null;
15 defaultValue?: Date | null;
16 /**
17 * @example ['onChangePicker', [ ['new Date()', null] ]]
18 */
19 onChange?: (date: Date | null | undefined, rawValue: string) => void;
20 /**
21 * @example ['openDateTime']
22 */
23 open?: boolean;
24 onToggle?: (isOpen: boolean) => void;
25 /**
26 * Default current date at which the calendar opens. If none is provided, opens at today's date or the `value` date (if any).
27 */
28 currentDate?: Date;
29 /**
30 * Change event Handler that is called when the currentDate is changed. The handler is called with the currentDate object.
31 */
32 onCurrentDateChange?: () => void;
33 onSelect?: (date: Date | null, rawValue: string) => void;
34 /**
35 * The minimum Date that can be selected. Min only limits selection, it doesn't constrain the date values that
36 * can be typed or pasted into the widget. If you need this behavior you can constrain values via
37 * the `onChange` handler.
38 *
39 * @example ['prop', ['min', 'new Date()']]
40 */
41 min?: Date;
42 /**
43 * The maximum Date that can be selected. Max only limits selection, it doesn't constrain the date values that
44 * can be typed or pasted into the widget. If you need this behavior you can constrain values via
45 * the `onChange` handler.
46 *
47 * @example ['prop', ['max', 'new Date()']]
48 */
49 max?: Date;
50 /**
51 * The amount of minutes between each entry in the time list.
52 *
53 * @example ['prop', { step: 90 }]
54 */
55 step?: number;
56 /**
57 * Enable the time list component of the picker.
58 */
59 includeTime?: boolean;
60 timePrecision?: 'minutes' | 'seconds' | 'milliseconds';
61 timeInputProps?: Partial<TimeInputProps>;
62 /** Specify the element used to render the calendar dropdown icon. */
63 selectIcon?: React.ReactNode;
64 /**
65 * @example ['prop', { dropUp: true }]
66 */
67 dropUp?: boolean;
68 popupProps?: object;
69 popupTransition?: React.ComponentType<TransitionProps>;
70 popupComponent?: React.ComponentType<PopupProps>;
71 placeholder?: string;
72 name?: string;
73 autoFocus?: boolean;
74 /**
75 * @example ['disabled', ['new Date()']]
76 */
77 disabled?: boolean;
78 /**
79 * @example ['readOnly', ['new Date()']]
80 */
81 readOnly?: boolean;
82 /**
83 * Determines how the widget parses the typed date string into a Date object. You can provide a date format
84 * or a function that returns a date to handle parsing yourself. When `parse` is unspecified and
85 * the default `localizer.parse` is used and passed the string as well as `valueDisplayFormat` or `valueEditFormat`.
86 */
87 parse?: string | ((str: string, localizer?: TLocalizer) => Date | undefined);
88 onKeyDown?: (e: React.KeyboardEvent<HTMLDivElement>) => void;
89 onKeyPress?: (e: React.KeyboardEvent<HTMLDivElement>) => void;
90 onBlur?: () => void;
91 onFocus?: () => void;
92 /** Adds a css class to the input container element. */
93 containerClassName?: string;
94 calendarProps?: Partial<CalendarProps>;
95 inputProps?: Partial<DatePickerInputProps>;
96 valueFormat?: InferFormat<TLocalizer>;
97 valueDisplayFormat?: InferFormat<TLocalizer>;
98 valueEditFormat?: InferFormat<TLocalizer>;
99 formats?: DateFormats<InferFormat<TLocalizer>>;
100 messages?: CalendarProps['messages'] & {
101 dateButton?: string;
102 };
103}
104export interface DatePickerHandle {
105 focus(): void;
106}
107/**
108 * ---
109 * subtitle: DatePicker, TimePicker
110 * localized: true
111 * shortcuts:
112 * - { key: alt + down arrow, label: open calendar or time }
113 * - { key: alt + up arrow, label: close calendar or time }
114 * - { key: down arrow, label: move focus to next item }
115 * - { key: up arrow, label: move focus to previous item }
116 * - { key: home, label: move focus to first item }
117 * - { key: end, label: move focus to last item }
118 * - { key: enter, label: select focused item }
119 * - { key: any key, label: search list for item starting with key }
120 * ---
121 *
122 * @public
123 * @extends Calendar
124 */
125declare const DatePicker: React.ForwardRefExoticComponent<DatePickerProps<unknown> & React.RefAttributes<DatePickerHandle>>;
126export default DatePicker;
127//# sourceMappingURL=DatePicker.d.ts.map
\No newline at end of file