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