UNPKG

3.98 kBTypeScriptView Raw
1/// <reference types="react" />
2import { AbstractPureComponent2, Props } from "@blueprintjs/core";
3import { DatePickerBaseProps } from "./datePickerCore";
4import { DatePickerShortcut } from "./shortcuts";
5export declare type DatePickerProps = IDatePickerProps;
6/** @deprecated use DatePickerProps */
7export interface IDatePickerProps extends DatePickerBaseProps, Props {
8 /**
9 * Allows the user to clear the selection by clicking the currently selected day.
10 * If disabled, the "Clear" Button in the Actions Bar will also be disabled.
11 *
12 * @default true
13 */
14 canClearSelection?: boolean;
15 /**
16 * Initial day the calendar will display as selected.
17 * This should not be set if `value` is set.
18 */
19 defaultValue?: Date;
20 /**
21 * Called when the user selects a day.
22 * If being used in an uncontrolled manner, `selectedDate` will be `null` if the user clicks the currently selected
23 * day. If being used in a controlled manner, `selectedDate` will contain the day clicked no matter what.
24 * `isUserChange` is true if the user selected a day, and false if the date was automatically changed
25 * by the user navigating to a new month or year rather than explicitly clicking on a date in the calendar.
26 */
27 onChange?: (selectedDate: Date, isUserChange: boolean) => void;
28 /**
29 * Called when the `shortcuts` props is enabled and the user changes the shortcut.
30 */
31 onShortcutChange?: (shortcut: DatePickerShortcut, index: number) => void;
32 /**
33 * Whether the bottom bar displaying "Today" and "Clear" buttons should be shown.
34 *
35 * @default false
36 */
37 showActionsBar?: boolean;
38 /**
39 * Whether shortcuts to quickly select a date are displayed or not.
40 * If `true`, preset shortcuts will be displayed.
41 * If `false`, no shortcuts will be displayed.
42 * If an array is provided, the custom shortcuts will be displayed.
43 */
44 shortcuts?: boolean | DatePickerShortcut[];
45 /**
46 * The currently selected shortcut.
47 * If this prop is provided, the component acts in a controlled manner.
48 */
49 selectedShortcutIndex?: number;
50 /**
51 * Text for the today button in the action bar.
52 *
53 * @default "Today"
54 */
55 todayButtonText?: string;
56 /**
57 * Text for the reset button in the action bar.
58 *
59 * @default "Clear"
60 */
61 clearButtonText?: string;
62 /**
63 * The currently selected day. If this prop is provided, the component acts in a controlled manner.
64 */
65 value?: Date | null;
66}
67export interface IDatePickerState {
68 displayMonth: number;
69 displayYear: number;
70 selectedDay: number | null;
71 value: Date | null;
72 selectedShortcutIndex?: number;
73}
74/**
75 * Date picker component.
76 *
77 * @see https://blueprintjs.com/docs/#datetime/datepicker
78 */
79export declare class DatePicker extends AbstractPureComponent2<DatePickerProps, IDatePickerState> {
80 static defaultProps: DatePickerProps;
81 static displayName: string;
82 private ignoreNextMonthChange;
83 constructor(props: DatePickerProps, context?: any);
84 render(): JSX.Element;
85 componentDidUpdate(prevProps: DatePickerProps, prevState: IDatePickerState): void;
86 protected validateProps(props: DatePickerProps): void;
87 private shouldHighlightCurrentDay;
88 private getDatePickerModifiers;
89 private renderDay;
90 private disabledDays;
91 private getDisabledDaysModifier;
92 private renderCaption;
93 private renderNavbar;
94 private renderOptionsBar;
95 private maybeRenderTimePicker;
96 private maybeRenderShortcuts;
97 private handleDayClick;
98 private handleShortcutClick;
99 private updateDay;
100 private computeValidDateInSpecifiedMonthYear;
101 private handleClearClick;
102 private handleMonthChange;
103 private handleTodayClick;
104 private handleTimeChange;
105 /**
106 * Update `value` by invoking `onChange` (always) and setting state (if uncontrolled).
107 */
108 private updateValue;
109}