UNPKG

3.14 kBTypeScriptView Raw
1/// <reference types="react" />
2import type { Props } from "@blueprintjs/core";
3import type { TimePrecision } from "./timePrecision";
4import type { TimeUnit } from "./timeUnit";
5export interface TimePickerProps extends Props {
6 /**
7 * Whether to focus the first input when it opens initially.
8 *
9 * @default false
10 */
11 autoFocus?: boolean;
12 /**
13 * Initial time the `TimePicker` will display.
14 * This should not be set if `value` is set.
15 */
16 defaultValue?: Date;
17 /**
18 * Whether the time picker is non-interactive.
19 *
20 * @default false
21 */
22 disabled?: boolean;
23 /**
24 * Callback invoked on blur event emitted by specific time unit input
25 */
26 onBlur?: (event: React.FocusEvent<HTMLInputElement>, unit: TimeUnit) => void;
27 /**
28 * Callback invoked when the user changes the time.
29 */
30 onChange?: (newTime: Date) => void;
31 /**
32 * Callback invoked on focus event emitted by specific time unit input
33 */
34 onFocus?: (event: React.FocusEvent<HTMLInputElement>, unit: TimeUnit) => void;
35 /**
36 * Callback invoked on keydown event emitted by specific time unit input
37 */
38 onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>, unit: TimeUnit) => void;
39 /**
40 * Callback invoked on keyup event emitted by specific time unit input
41 */
42 onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>, unit: TimeUnit) => void;
43 /**
44 * The precision of time the user can set.
45 *
46 * @default TimePrecision.MINUTE
47 */
48 precision?: TimePrecision;
49 /**
50 * Whether all the text in each input should be selected on focus.
51 *
52 * @default false
53 */
54 selectAllOnFocus?: boolean;
55 /**
56 * Whether to show arrows buttons for changing the time.
57 *
58 * @default false
59 */
60 showArrowButtons?: boolean;
61 /**
62 * Whether to use a 12 hour format with an AM/PM dropdown.
63 *
64 * @default false
65 */
66 useAmPm?: boolean;
67 /**
68 * The latest time the user can select. The year, month, and day parts of the `Date` object are ignored.
69 * While the `maxTime` will be later than the `minTime` in the basic case,
70 * it is also allowed to be earlier than the `minTime`.
71 * This is useful, for example, to express a time range that extends before and after midnight.
72 * If the `maxTime` and `minTime` are equal, then the valid time range is constrained to only that one value.
73 */
74 maxTime?: Date;
75 /**
76 * The earliest time the user can select. The year, month, and day parts of the `Date` object are ignored.
77 * While the `minTime` will be earlier than the `maxTime` in the basic case,
78 * it is also allowed to be later than the `maxTime`.
79 * This is useful, for example, to express a time range that extends before and after midnight.
80 * If the `maxTime` and `minTime` are equal, then the valid time range is constrained to only that one value.
81 */
82 minTime?: Date;
83 /**
84 * The currently set time.
85 * If this prop is provided, the component acts in a controlled manner.
86 */
87 value?: Date | null;
88}