UNPKG

3.56 kBTypeScriptView Raw
1import * as React from "react";
2import { AbstractPureComponent, type ButtonProps, type InputGroupProps, type Props } from "@blueprintjs/core";
3import { type SelectPopoverProps } from "@blueprintjs/select";
4import { TimezoneDisplayFormat } from "../../common/timezoneDisplayFormat";
5export interface TimezoneSelectProps extends Props {
6 /**
7 * Element which triggers the timezone select popover. If this is undefined,
8 * by default the component will render a `<Button>` which shows the currently
9 * selected timezone.
10 */
11 children?: React.ReactNode;
12 /**
13 * The currently selected timezone UTC identifier, e.g. "Pacific/Honolulu".
14 *
15 * @see https://www.iana.org/time-zones
16 */
17 value: string | undefined;
18 /**
19 * Callback invoked when the user selects a timezone.
20 *
21 * @param timezone the new timezone's IANA code
22 */
23 onChange: (timezone: string) => void;
24 /**
25 * The date to use when formatting timezone offsets.
26 * An offset date is necessary to account for DST, but typically the default value of `now` will be sufficient.
27 *
28 * @default now
29 */
30 date?: Date;
31 /**
32 * Whether the component should take up the full width of its container.
33 * This overrides `popoverProps.fill` and `buttonProps.fill`.
34 *
35 * @default false
36 */
37 fill?: boolean;
38 /**
39 * Whether this component is non-interactive.
40 * This prop will be ignored if `children` is provided.
41 *
42 * @default false
43 */
44 disabled?: boolean;
45 /**
46 * Whether to show the local timezone at the top of the list of initial timezone suggestions.
47 *
48 * @default false
49 */
50 showLocalTimezone?: boolean;
51 /**
52 * Text to show when no timezone has been selected (`value === undefined`).
53 * This prop will be ignored if `children` is provided.
54 *
55 * @default "Select timezone..."
56 */
57 placeholder?: string;
58 /**
59 * Props to spread to the target `Button`.
60 * This prop will be ignored if `children` is provided.
61 */
62 buttonProps?: Partial<ButtonProps>;
63 /**
64 * Props to spread to the filter `InputGroup`.
65 * All props are supported except `ref` (use `inputRef` instead).
66 * If you want to control the filter input, you can pass `value` and `onChange` here
67 * to override `Select`'s own behavior.
68 */
69 inputProps?: InputGroupProps;
70 /** Props to spread to the popover. Note that `content` cannot be changed. */
71 popoverProps?: SelectPopoverProps["popoverProps"];
72 /**
73 * Format to use when displaying the selected (or default) timezone within the target element.
74 * This prop will be ignored if `children` is provided.
75 *
76 * @default TimezoneDisplayFormat.COMPOSITE
77 */
78 valueDisplayFormat?: TimezoneDisplayFormat;
79}
80export interface TimezoneSelectState {
81 query: string;
82}
83/**
84 * Timezone select component.
85 *
86 * @see https://blueprintjs.com/docs/#datetime/timezone-select
87 */
88export declare class TimezoneSelect extends AbstractPureComponent<TimezoneSelectProps, TimezoneSelectState> {
89 static displayName: string;
90 static defaultProps: Partial<TimezoneSelectProps>;
91 private timezoneItems;
92 private initialTimezoneItems;
93 constructor(props: TimezoneSelectProps);
94 render(): React.JSX.Element;
95 componentDidUpdate(prevProps: TimezoneSelectProps, prevState: TimezoneSelectState): void;
96 private renderButton;
97 private filterItems;
98 private renderItem;
99 private handleItemSelect;
100 private handleQueryChange;
101}