@momentum-design/components 0.130.8 → 0.131.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ import '../button';
2
+ import '../icon';
3
+ import '../option';
4
+ import '../popover';
5
+ import '../text';
6
+ import '../toggletip';
7
+ import TimePicker from './timepicker.component';
8
+ declare global {
9
+ interface HTMLElementTagNameMap {
10
+ ['mdc-timepicker']: TimePicker;
11
+ }
12
+ }
13
+ export default TimePicker;
@@ -0,0 +1,10 @@
1
+ import '../button';
2
+ import '../icon';
3
+ import '../option';
4
+ import '../popover';
5
+ import '../text';
6
+ import '../toggletip';
7
+ import TimePicker from './timepicker.component';
8
+ import { TAG_NAME } from './timepicker.constants';
9
+ TimePicker.register(TAG_NAME);
10
+ export default TimePicker;
@@ -0,0 +1,328 @@
1
+ import type { PropertyValueMap } from 'lit';
2
+ import { CSSResult } from 'lit';
3
+ import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
4
+ import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
5
+ import type { PopoverStrategy } from '../popover/popover.types';
6
+ import type { Placement, TimeFormat } from './timepicker.types';
7
+ declare const TimePicker_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
8
+ /**
9
+ * mdc-timepicker is a component that allows users to select a specific time
10
+ * or enter a time manually. It supports both 12-hour and 24-hour formats.
11
+ *
12
+ * The component consists of:
13
+ * - label - describes the time picker field
14
+ * - input field - made up of 2-3 spinbuttons (hours, minutes, optional AM/PM period)
15
+ * - dropdown arrow button - opens a flyout menu with predefined time intervals
16
+ * - helper text - displayed below the input field
17
+ *
18
+ * Users can input values by:
19
+ * - Manually entering numbers/characters in spinbuttons
20
+ * - Navigating using arrow keys to increment/decrement values
21
+ * - Selecting a predefined time from the dropdown menu
22
+ *
23
+ * @tagname mdc-timepicker
24
+ *
25
+ * @dependency mdc-button
26
+ * @dependency mdc-icon
27
+ * @dependency mdc-option
28
+ * @dependency mdc-popover
29
+ * @dependency mdc-text
30
+ * @dependency mdc-toggletip
31
+ *
32
+ * @event input - (React: onInput) This event is dispatched when the time value changes.
33
+ * @event change - (React: onChange) This event is dispatched when the time value is committed.
34
+ * @event focus - (React: onFocus) This event is dispatched when the timepicker receives focus.
35
+ * @event blur - (React: onBlur) This event is dispatched when the timepicker loses focus.
36
+ *
37
+ * @slot label - Slot for the label element.
38
+ * @slot toggletip - Slot for the toggletip info icon button.
39
+ * @slot help-icon - Slot for the helper/validation icon.
40
+ * @slot help-text - Slot for the helper/validation text.
41
+ *
42
+ * @cssproperty --mdc-timepicker-background-color - Background color of the timepicker input.
43
+ * @cssproperty --mdc-timepicker-border-color - Border color of the timepicker input.
44
+ * @cssproperty --mdc-timepicker-text-color - Text color of the timepicker input.
45
+ * @cssproperty --mdc-timepicker-width - Width of the timepicker component.
46
+ *
47
+ * @csspart label - The label element.
48
+ * @csspart label-text - The container for the label and required indicator elements.
49
+ * @csspart required-indicator - The required indicator element.
50
+ * @csspart info-icon-btn - The info icon button element.
51
+ * @csspart label-toggletip - The toggletip element.
52
+ * @csspart help-text - The helper/validation text element.
53
+ * @csspart helper-icon - The helper/validation icon element.
54
+ * @csspart help-text-container - The container for helper/validation elements.
55
+ * @csspart container - The outer container for the input and popover.
56
+ * @csspart base-container - The input container with border and background.
57
+ * @csspart spinbutton-group - The container for spinbutton elements.
58
+ * @csspart spinbutton - A spinbutton input element.
59
+ * @csspart separator - The colon separator between spinbuttons.
60
+ * @csspart period - The AM/PM period spinbutton.
61
+ * @csspart icon-container - The dropdown arrow button container.
62
+ * @csspart native-input - The hidden native input for form participation.
63
+ * @csspart listbox - The dropdown list container.
64
+ */
65
+ declare class TimePicker extends TimePicker_base implements AssociatedFormControl {
66
+ /**
67
+ * The time format to use for display.
68
+ * - `'12h'`: 12-hour format with AM/PM period
69
+ * - `'24h'`: 24-hour format without period
70
+ * @default '12h'
71
+ */
72
+ timeFormat: TimeFormat;
73
+ /**
74
+ * The interval in minutes between time options in the dropdown menu.
75
+ * @default 30
76
+ */
77
+ interval: number;
78
+ /**
79
+ * The placement of the popover dropdown.
80
+ * @default 'bottom-start'
81
+ */
82
+ placement: Placement;
83
+ /**
84
+ * The strategy for positioning the popover.
85
+ * @default 'absolute'
86
+ */
87
+ strategy: PopoverStrategy;
88
+ /**
89
+ * Determines whether the dropdown should flip its position when it hits the boundary.
90
+ * @default false
91
+ */
92
+ disableFlip: boolean;
93
+ /**
94
+ * Element ID that the popover will be appended to.
95
+ * This is useful when the timepicker is inside a scrollable container
96
+ * and the popover needs to be portalled to avoid clipping.
97
+ */
98
+ appendTo?: string;
99
+ /**
100
+ * Element ID the backdrop will be appended to (if backdrop is enabled).
101
+ * This is useful to ensure that the backdrop is appended to the correct element in the DOM.
102
+ * If not set, the backdrop will be appended to the parent element of the timepicker.
103
+ */
104
+ backdropAppendTo?: string;
105
+ /**
106
+ * The minimum allowed time value in 24-hour format (HH:MM).
107
+ */
108
+ min?: string;
109
+ /**
110
+ * The maximum allowed time value in 24-hour format (HH:MM).
111
+ */
112
+ max?: string;
113
+ /**
114
+ * Accessible label for the hours spinbutton.
115
+ * Consumers must provide a translated string.
116
+ */
117
+ localeHoursLabel: string;
118
+ /**
119
+ * Accessible label for the minutes spinbutton.
120
+ * Consumers must provide a translated string.
121
+ */
122
+ localeMinutesLabel: string;
123
+ /**
124
+ * Accessible label for the period (AM/PM) spinbutton.
125
+ * Consumers must provide a translated string.
126
+ */
127
+ localePeriodLabel: string;
128
+ /**
129
+ * Placeholder text for the hours spinbutton.
130
+ * Consumers must provide a translated string.
131
+ */
132
+ localeHoursPlaceholder: string;
133
+ /**
134
+ * Placeholder text for the minutes spinbutton.
135
+ * Consumers must provide a translated string.
136
+ */
137
+ localeMinutesPlaceholder: string;
138
+ /**
139
+ * Placeholder text for the period spinbutton.
140
+ * Consumers must provide a translated string.
141
+ */
142
+ localePeriodPlaceholder: string;
143
+ /**
144
+ * Label for the AM period.
145
+ * Consumers must provide a translated string.
146
+ */
147
+ localeAmLabel: string;
148
+ /**
149
+ * Label for the PM period.
150
+ * Consumers must provide a translated string.
151
+ */
152
+ localePmLabel: string;
153
+ /**
154
+ * Accessible label for the dropdown toggle button.
155
+ * Consumers must provide a translated string.
156
+ */
157
+ localeShowTimePickerLabel: string;
158
+ /**
159
+ * Accessible label for the time options listbox.
160
+ * Consumers must provide a translated string.
161
+ */
162
+ localeTimeOptionsLabel: string;
163
+ /**
164
+ * Accessible description for spinbutton inputs (instruction text).
165
+ * Consumers must provide a translated string.
166
+ */
167
+ localeSpinbuttonDescription: string;
168
+ /** @internal */
169
+ private dropdownButton;
170
+ /** @internal */
171
+ private hoursInput;
172
+ /** @internal */
173
+ private minutesInput;
174
+ /** @internal */
175
+ private periodInput;
176
+ /** @internal */
177
+ private displayPopover;
178
+ /** @internal */
179
+ private internalHours;
180
+ /** @internal */
181
+ private internalMinutes;
182
+ /** @internal */
183
+ private internalPeriod;
184
+ /** @internal */
185
+ private focusedOptionIndex;
186
+ /** @internal */
187
+ private pendingDigits;
188
+ /** @internal */
189
+ private pendingDigitTimeout?;
190
+ connectedCallback(): void;
191
+ disconnectedCallback(): void;
192
+ protected willUpdate(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
193
+ protected updated(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
194
+ /**
195
+ * When the menu opens, focus the selected item or the first item.
196
+ * @internal
197
+ */
198
+ private focusMenuItemOnOpen;
199
+ /**
200
+ * Focuses the menu item at the current focusedOptionIndex.
201
+ * @internal
202
+ */
203
+ private focusCurrentMenuItem;
204
+ /** @internal */
205
+ formResetCallback(): void;
206
+ /** @internal */
207
+ formStateRestoreCallback(state: string): void;
208
+ /**
209
+ * Parses the value (24h HH:MM) into internal hours, minutes, and period.
210
+ * @internal
211
+ */
212
+ private parseValueToInternal;
213
+ /**
214
+ * Converts internal hours, minutes, and period to 24h HH:MM value.
215
+ * @internal
216
+ */
217
+ private internalToValue;
218
+ /**
219
+ * Syncs the form value with the current internal state.
220
+ * @internal
221
+ */
222
+ private syncFormValue;
223
+ /**
224
+ * Updates the value from internal state and fires events.
225
+ * @internal
226
+ */
227
+ private commitValue;
228
+ /**
229
+ * Generates time interval options for the dropdown.
230
+ * @internal
231
+ */
232
+ private getTimeOptions;
233
+ /**
234
+ * Handles clicking on a time option in the dropdown.
235
+ * @internal
236
+ */
237
+ private handleOptionClick;
238
+ /**
239
+ * Handles clicking the dropdown arrow button.
240
+ * @internal
241
+ */
242
+ private handleDropdownClick;
243
+ /**
244
+ * Handles clicking on the spinbutton area (not the dropdown button).
245
+ * Focuses the nearest spinbutton.
246
+ * @internal
247
+ */
248
+ private handleSpinbuttonAreaClick;
249
+ /**
250
+ * Handles keydown on the base container (when popover is closed).
251
+ * @internal
252
+ */
253
+ private handleBaseKeydown;
254
+ /**
255
+ * Handles keydown on the popover/listbox (when open).
256
+ * Supports ArrowDown/ArrowUp to navigate, Enter to select, Escape to close.
257
+ * @internal
258
+ */
259
+ private handleListboxKeydown;
260
+ /**
261
+ * Handles keydown on the hours spinbutton.
262
+ * @internal
263
+ */
264
+ private handleHoursKeydown;
265
+ /**
266
+ * Handles keydown on the minutes spinbutton.
267
+ * @internal
268
+ */
269
+ private handleMinutesKeydown;
270
+ /**
271
+ * Handles keydown on the period spinbutton.
272
+ * @internal
273
+ */
274
+ private handlePeriodKeydown;
275
+ /**
276
+ * Generic spinbutton keydown handler for hours and minutes.
277
+ * @internal
278
+ */
279
+ private handleSpinbuttonKeydown;
280
+ /**
281
+ * Handles digit input for spinbuttons with auto-advance logic.
282
+ * @internal
283
+ */
284
+ private handleDigitInput;
285
+ /**
286
+ * Sets the value of a spinbutton field.
287
+ * @internal
288
+ */
289
+ private setSpinbuttonValue;
290
+ /**
291
+ * Advances focus to the next spinbutton field.
292
+ * @internal
293
+ */
294
+ private advanceToNextField;
295
+ /**
296
+ * Handles focus on a spinbutton - selects all text.
297
+ * @internal
298
+ */
299
+ private handleSpinbuttonFocus;
300
+ /**
301
+ * Gets the display text for the current period using locale labels.
302
+ * @internal
303
+ */
304
+ private get displayPeriod();
305
+ /**
306
+ * Gets the placeholder text for the hours spinbutton.
307
+ * @internal
308
+ */
309
+ private get hoursPlaceholder();
310
+ /**
311
+ * Gets the placeholder text for the minutes spinbutton.
312
+ * @internal
313
+ */
314
+ private get minutesPlaceholder();
315
+ /**
316
+ * Gets the placeholder text for the period spinbutton.
317
+ * @internal
318
+ */
319
+ private get periodPlaceholder();
320
+ /**
321
+ * Renders the dropdown time options list using mdc-option components.
322
+ * @internal
323
+ */
324
+ private renderTimeOptions;
325
+ render(): import("lit-html").TemplateResult<1>;
326
+ static styles: Array<CSSResult>;
327
+ }
328
+ export default TimePicker;