UNPKG

2.17 kBTypeScriptView Raw
1import * as React from "react";
2import { type DateRange, type TimePrecision } from "../../common";
3export interface DateShortcutBase {
4 /** Shortcut label that appears in the list. */
5 label: string;
6 /**
7 * Set this prop to `true` to allow this shortcut to change the selected
8 * times as well as the dates. By default, time components of a shortcut are
9 * ignored; clicking a shortcut takes the date components of the `dateRange`
10 * and combines them with the currently selected time.
11 *
12 * @default false
13 */
14 includeTime?: boolean;
15}
16export interface DateRangeShortcut extends DateShortcutBase {
17 /**
18 * Date range represented by this shortcut. Note that time components of a
19 * shortcut are ignored by default; set `includeTime: true` to respect them.
20 */
21 dateRange: DateRange;
22}
23export interface DatePickerShortcut extends DateShortcutBase {
24 /**
25 * Date represented by this shortcut. Note that time components of a
26 * shortcut are ignored by default; set `includeTime: true` to respect them.
27 */
28 date: Date;
29}
30export interface DatePickerShortcutMenuProps {
31 allowSingleDayRange: boolean;
32 minDate: Date;
33 maxDate: Date;
34 shortcuts: DateRangeShortcut[] | true;
35 timePrecision: TimePrecision;
36 selectedShortcutIndex?: number;
37 onShortcutClick: (shortcut: DateRangeShortcut, index: number) => void;
38 /**
39 * The DatePicker component reuses this component for a single date.
40 * This changes the default shortcut labels and affects which shortcuts are used.
41 *
42 * @default false
43 */
44 useSingleDateShortcuts?: boolean;
45}
46/**
47 * Menu of {@link DateRangeShortcut} items, typically displayed in the UI to the left of a day picker calendar.
48 *
49 * This component may be used for single date pickers as well as range pickers by toggling the
50 * `useSingleDateShortcuts` option.
51 */
52export declare class DatePickerShortcutMenu extends React.PureComponent<DatePickerShortcutMenuProps> {
53 static defaultProps: Partial<DatePickerShortcutMenuProps>;
54 render(): React.JSX.Element;
55 private getShorcutClickHandler;
56 private isShortcutInRange;
57}