timepicker-ui 3.1.3 → 4.0.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.
package/dist/index.d.cts CHANGED
@@ -1,92 +1,97 @@
1
- /**
2
- * @description Callback data type for timepicker events
3
- */
4
- type CallbackData = {
5
- hour?: string | null;
6
- minutes?: string | null;
7
- type?: string | null;
8
- degreesHours?: number | null;
9
- degreesMinutes?: number | null;
10
- hourNotAccepted?: string | null;
11
- minutesNotAccepted?: string | null;
12
- eventType?: 'accept' | 'cancel' | 'click' | 'change' | null;
13
- error?: string;
14
- currentHour?: string | number;
15
- currentMin?: string | number;
16
- currentType?: string;
17
- currentLength?: string | number;
1
+ /** Payload when timepicker opens */
2
+ type OpenEventData = {
3
+ hour: string;
4
+ minutes: string;
5
+ type?: string;
6
+ degreesHours: number | null;
7
+ degreesMinutes: number | null;
18
8
  };
19
9
 
20
- /**
21
- * @description Callback function type for timepicker events
22
- */
23
- type TimepickerEventCallback = (eventData: CallbackData) => void;
10
+ /** Payload when user cancels */
11
+ type CancelEventData = Record<string, never>;
12
+
13
+ /** Payload when user confirms time */
14
+ type ConfirmEventData = {
15
+ hour?: string;
16
+ minutes?: string;
17
+ type?: string;
18
+ };
19
+
20
+ /** Payload when modal shows */
21
+ type ShowEventData = Record<string, never>;
22
+
23
+ /** Payload when modal hides */
24
+ type HideEventData = Record<string, never>;
25
+
26
+ /** Payload for real-time updates */
27
+ type UpdateEventData = {
28
+ hour: string;
29
+ minutes: string;
30
+ type?: string;
31
+ };
32
+
33
+ /** Payload when hour mode activated */
34
+ type SelectHourEventData = {
35
+ hour: string;
36
+ };
37
+
38
+ /** Payload when minute mode activated */
39
+ type SelectMinuteEventData = {
40
+ minutes: string;
41
+ };
42
+
43
+ /** Payload when AM selected */
44
+ type SelectAMEventData = Record<string, never>;
45
+
46
+ /** Payload when PM selected */
47
+ type SelectPMEventData = Record<string, never>;
48
+
49
+ /** Payload when switching view */
50
+ type SwitchViewEventData = Record<string, never>;
51
+
52
+ /** Payload when validation error occurs */
53
+ type ErrorEventData = {
54
+ error: string;
55
+ rejectedHour?: string;
56
+ rejectedMinute?: string;
57
+ inputHour?: string | number;
58
+ inputMinute?: string | number;
59
+ inputType?: string;
60
+ inputLength?: string | number;
61
+ };
62
+
63
+ /** Callback function for timepicker events */
64
+ type TimepickerEventCallback<T = unknown> = (eventData: T) => void;
24
65
 
25
66
  type OptionTypes = {
26
- /**
27
- * @description Set custom text to AM label
28
- * @default "AM"
29
- */
67
+ /** AM label text @default "AM" */
30
68
  amLabel?: string;
31
- /**
32
- * @description Turn on/off animations on picker on start/close
33
- * @default true
34
- */
69
+ /** Enable animations @default true */
35
70
  animation?: boolean;
36
71
  /**
37
72
  * @description Set default selector to append timepicker inside it. Timepicker default append to `body`
38
73
  * @default ""
39
74
  */
40
75
  appendModalSelector?: string;
41
- /**
42
- * @description Turn on/off backdrop
43
- * @default true
44
- */
76
+ /** Enable backdrop @default true */
45
77
  backdrop?: boolean;
46
- /**
47
- * @description Set custom text to cancel button
48
- * @default "CANCEL"
49
- */
78
+ /** Cancel button text @default "Cancel" */
50
79
  cancelLabel?: string;
51
- /**
52
- * @description Edit hour/minutes on the web mode.
53
- * @default false
54
- */
80
+ /** Edit hour/minutes in web mode @default false */
55
81
  editable?: boolean;
56
- /**
57
- * @description Turn on/off scroll if timepicker is open
58
- * @default false
59
- */
82
+ /** Enable scroll when open @default false */
60
83
  enableScrollbar?: boolean;
61
- /**
62
- * @description Turn on/off icon to switch desktop/mobile
63
- * @default false
64
- */
84
+ /** Icon to switch desktop/mobile @default false */
65
85
  enableSwitchIcon?: boolean;
66
- /**
67
- * @description Set custom text to time label on mobile version
68
- * @default "Enter Time"
69
- */
86
+ /** Mobile time label @default "Enter Time" */
70
87
  mobileTimeLabel?: string;
71
- /**
72
- * @description Turn on/off focus to input after close modal
73
- * @default false
74
- */
88
+ /** Focus input after close @default false */
75
89
  focusInputAfterCloseModal?: boolean;
76
- /**
77
- * @description Set custom text to hour label on mobile version
78
- * @default "Hour"
79
- */
90
+ /** Mobile hour label @default "Hour" */
80
91
  hourMobileLabel?: string;
81
- /**
82
- * @description Set default template to switch desktop.This options is using by default material design icon
83
- * @default "<i class='material-icons timepicker-ui-keyboard-icon'> keyboard </i>"
84
- */
92
+ /** Desktop icon template */
85
93
  iconTemplate?: string;
86
- /**
87
- * @description Set default template to switch mobile. This options is using by default material design icon
88
- * @default "<i class='material-icons timepicker-ui-keyboard-icon'> schedule </i>"
89
- */
94
+ /** Mobile icon template */
90
95
  iconTemplateMobile?: string;
91
96
  /**
92
97
  * @description Set increment hour by `1`, `2`, `3` hour
@@ -113,124 +118,262 @@ type OptionTypes = {
113
118
  * @default "OK"
114
119
  */
115
120
  okLabel?: string;
116
- /**
117
- * @description Set custom text to pm label
118
- * @default "PM"
119
- */
121
+ /** PM label @default "PM" */
120
122
  pmLabel?: string;
121
- /**
122
- * @description Set custom text to time label on desktop version
123
- * @default "Select Time"
124
- */
123
+ /** Time label (desktop) @default "Select time" */
125
124
  timeLabel?: string;
126
- /**
127
- * @description Turn on/off switch to minutes by select hour
128
- * @default true
129
- */
130
- switchToMinutesAfterSelectHour?: boolean;
131
- /**
132
- * @description Set theme to timepicker. Available options: `basic`, `crane-straight`, `crane-radius`, `m3`, `dark`, `glassmorphic`, `pastel`, `ai`, `cyberpunk`, `custom`.
133
- *
134
- * The `custom` theme allows you to create your own styling by overriding CSS variables.
135
- * The offical version of Material Design 3 is still not avaialbe for the WEB version.Theme `m3` has been added
136
- * based on the design what you can find [here](https://m3.material.io/components/time-pickers/overview).
137
- * If new version M3 will be released this design will get improve.
138
- * @default "basic"
139
- */
125
+ /** Auto-switch to minutes @default true */
126
+ autoSwitchToMinutes?: boolean;
127
+ /** Theme @default "basic" */
140
128
  theme?:
141
129
  | 'basic'
130
+ | 'crane'
142
131
  | 'crane-straight'
143
- | 'crane-radius'
144
- | 'm3'
132
+ | 'm2'
133
+ | 'm3-green'
145
134
  | 'dark'
146
135
  | 'glassmorphic'
147
136
  | 'pastel'
148
137
  | 'ai'
149
- | 'cyberpunk'
150
- | 'custom';
138
+ | 'cyberpunk';
139
+ /** Clock type: 12h or 24h @default "12h" */
140
+ clockType?: '12h' | '24h';
141
+ /** Disable specific times (hours/minutes/intervals) */
142
+ disabledTime?: {
143
+ minutes?: Array<string | number>;
144
+ hours?: Array<string | number>;
145
+ interval?: string | string[];
146
+ };
147
+ /** Current time config */
148
+ /** Current time config */
149
+ currentTime?:
150
+ | {
151
+ time?: Date;
152
+ updateInput?: boolean;
153
+ locales?: string | string[];
154
+ preventClockType?: boolean;
155
+ }
156
+ | boolean;
157
+
158
+ /** Focus trap on modal @default true */
159
+ focusTrap?: boolean;
160
+ /** Delay for clickable elements (ms) @default 300 */
161
+ delayHandler?: number;
162
+ /** Custom ID for instance */
163
+ id?: string;
164
+ /** Inline mode config */
165
+ inline?: {
166
+ enabled: boolean;
167
+ containerId: string;
168
+ /** @default false */
169
+ showButtons?: boolean;
170
+ /** @default true */
171
+ autoUpdate?: boolean;
172
+ };
173
+ /** Additional CSS class */
174
+ cssClass?: string;
175
+ /** Callback when picker opens */
176
+ onOpen?: TimepickerEventCallback<OpenEventData>;
177
+ /** Callback when user cancels */
178
+ onCancel?: TimepickerEventCallback<CancelEventData>;
179
+ /** Callback when user confirms */
180
+ onConfirm?: TimepickerEventCallback<ConfirmEventData>;
181
+ /** Callback during interaction */
182
+ onUpdate?: TimepickerEventCallback<UpdateEventData>;
183
+ /** Callback when hour mode activated */
184
+ onSelectHour?: TimepickerEventCallback<SelectHourEventData>;
185
+ /** Callback when minute mode activated */
186
+ onSelectMinute?: TimepickerEventCallback<SelectMinuteEventData>;
187
+ /** Callback when AM selected */
188
+ onSelectAM?: TimepickerEventCallback<SelectAMEventData>;
189
+ /** Callback when PM selected */
190
+ onSelectPM?: TimepickerEventCallback<SelectPMEventData>;
191
+ /** Callback on validation error */
192
+ onError?: TimepickerEventCallback<ErrorEventData>;
193
+ };
194
+
195
+ type EventHandler<T = unknown> = (data: T) => void;
196
+ interface TimepickerEventMap {
197
+ open: OpenEventData;
198
+ cancel: CancelEventData;
199
+ confirm: ConfirmEventData;
200
+ show: ShowEventData;
201
+ hide: HideEventData;
202
+ update: UpdateEventData;
203
+ 'select:hour': SelectHourEventData;
204
+ 'select:minute': SelectMinuteEventData;
205
+ 'select:am': SelectAMEventData;
206
+ 'select:pm': SelectPMEventData;
207
+ 'switch:view': SwitchViewEventData;
208
+ 'animation:clock': Record<string, never>;
209
+ error: ErrorEventData;
210
+ [key: string]: unknown;
211
+ }
212
+ declare class EventEmitter<EventMap extends Record<string, unknown> = TimepickerEventMap> {
213
+ private events;
214
+ on<K extends keyof EventMap>(event: K, handler: EventHandler<EventMap[K]>): void;
215
+ once<K extends keyof EventMap>(event: K, handler: EventHandler<EventMap[K]>): void;
216
+ off<K extends keyof EventMap>(event: K, handler?: EventHandler<EventMap[K]>): void;
217
+ emit<K extends keyof EventMap>(event: K, data?: EventMap[K]): void;
218
+ clear(): void;
219
+ hasListeners<K extends keyof EventMap>(event: K): boolean;
220
+ }
221
+
222
+ /**
223
+ * Grouped options structure for Timepicker UI v4.0.0
224
+ *
225
+ * BREAKING CHANGE from v3.x:
226
+ * Options are now organized into logical groups for better clarity and maintainability.
227
+ */
228
+
229
+
230
+
231
+ /**
232
+ * Clock behavior configuration
233
+ */
234
+ interface ClockOptions {
235
+ /**
236
+ * @description Set type of clock: `12h` or `24h`
237
+ * @default "12h"
238
+ */
239
+ type?: '12h' | '24h';
240
+
151
241
  /**
152
- * @description Set type of clock, it contains 2 versions: `12h` and `24h`.
242
+ * @description Set increment for hours (1, 2, 3, etc.)
243
+ * @default 1
244
+ */
245
+ incrementHours?: number;
246
+
247
+ /**
248
+ * @description Set increment for minutes (1, 5, 10, 15, etc.)
249
+ * @default 1
250
+ */
251
+ incrementMinutes?: number;
252
+
253
+ /**
254
+ * @description Automatically switch to minutes after selecting hour
153
255
  * @default false
154
256
  */
155
- clockType?: '12h' | '24h';
257
+ autoSwitchToMinutes?: boolean;
258
+
156
259
  /**
157
- * @description - The `hours` and `minutes` are arrays which accept strings and numbers to block select hours/minutes.
158
- * - The `interval` key can accept string or string[] to block select time intervals.
159
- * - If the interval key is set, the hours/minutes keys are `ignored`.
260
+ * @description Disable specific hours/minutes or time intervals
160
261
  * @example
161
- disabledTime: {
162
- minutes: [1,2,4,5,55,23,"22","38"],
163
- hours: [1,"3","5", 8],
164
- interval: "10:00 AM - 12:00 PM" | ["10:00 AM - 12:00 PM", "5:00 PM - 8:00 PM"],
165
- }
166
- * @default undefined
262
+ * disabledTime: {
263
+ * minutes: [1, 2, 4, 5, 55, 23, "22", "38"],
264
+ * hours: [1, "3", "5", 8],
265
+ * interval: "10:00 AM - 12:00 PM" | ["10:00 AM - 12:00 PM", "5:00 PM - 8:00 PM"]
266
+ * }
167
267
  */
168
268
  disabledTime?: {
169
269
  minutes?: Array<string | number>;
170
270
  hours?: Array<string | number>;
171
271
  interval?: string | string[];
172
272
  };
273
+
173
274
  /**
174
- * @description Set current time to the input and timepicker.\
175
- * If this options is set to `true` it's gonna update picker with toLocaleTimeString() and input with value based on your location.
176
- * This option also allows to put object with properties.
275
+ * @description Set current time to the input and timepicker
177
276
  * @example
178
- currentTime: {
179
- time: new Date(),
180
- updateInput: true,
181
- locales: "en-US",
182
- preventClockType: false
183
- };
277
+ * currentTime: {
278
+ * time: new Date(),
279
+ * updateInput: true,
280
+ * locales: "en-US",
281
+ * preventClockType: false
282
+ * }
184
283
  * @example currentTime: true
185
- * @default undefined
186
284
  */
187
285
  currentTime?:
188
286
  | {
189
- /**
190
- * The `time` key allows to put any valid date to update picker.
191
- * @requires
192
- * If the `updateInput` is set to `false/undefined` and the default value from the input not exist, the `time` key value will be displayed in the picker.
193
- *
194
- * If the `updateInput` is set to `false/undefined` but the default value from the input exist, the `time` key will be ignored.
195
- */
196
287
  time?: Date;
197
- /**
198
- * The `updateInput` key is set to `true` it's going update input value with set time key.
199
- */
200
288
  updateInput?: boolean;
201
- /**
202
- * The `locales` key can change language from `toLocaleTimeString()`.
203
- */
204
289
  locales?: string | string[];
205
- /**
206
- * The `preventClockType` key if is set to `true` it's `force` the clockType option to set value "12h" or "24h" based on your location
207
- * with current time and `locales` key value is ignored.
208
- */
209
290
  preventClockType?: boolean;
210
291
  }
211
292
  | boolean;
293
+ }
294
+
295
+ /**
296
+ * UI appearance and behavior configuration
297
+ */
298
+ interface UIOptions {
299
+ /**
300
+ * @description Theme for the timepicker
301
+ * @default "basic"
302
+ */
303
+ theme?:
304
+ | 'basic'
305
+ | 'crane'
306
+ | 'crane-straight'
307
+ | 'm2'
308
+ | 'm3-green'
309
+ | 'dark'
310
+ | 'glassmorphic'
311
+ | 'pastel'
312
+ | 'ai'
313
+ | 'cyberpunk';
212
314
 
213
315
  /**
214
- * @description Set focus trap to the modal element to all elements with tabindex in the picker
316
+ * @description Enable/disable animations
215
317
  * @default true
216
318
  */
217
- focusTrap?: boolean;
319
+ animation?: boolean;
320
+
218
321
  /**
219
- * @description Set delay to clickable elements like button "OK", "CANCEL" etc. The value has to be set in milliseconds.
220
- * @default 300
322
+ * @description Show backdrop when timepicker is open
323
+ * @default true
221
324
  */
222
- delayHandler?: number;
325
+ backdrop?: boolean;
326
+
223
327
  /**
224
- * @description Custom ID for the timepicker instance. Useful for identifying specific instances when using multiple timepickers.
225
- * If not provided, a random UUID will be generated.
226
- * @example id: "my-timepicker-1"
227
- * @default undefined
328
+ * @description Force mobile mode
329
+ * @default false
228
330
  */
229
- id?: string;
331
+ mobile?: boolean;
332
+
333
+ /**
334
+ * @description Enable switch icon (mobile ↔ desktop)
335
+ * @default false
336
+ */
337
+ enableSwitchIcon?: boolean;
338
+
339
+ /**
340
+ * @description Allow editing hour/minutes directly
341
+ * @default false
342
+ */
343
+ editable?: boolean;
344
+
345
+ /**
346
+ * @description Enable scrollbar when timepicker is open
347
+ * @default false
348
+ */
349
+ enableScrollbar?: boolean;
350
+
351
+ /**
352
+ * @description Additional CSS class for the wrapper
353
+ * @example cssClass: "my-custom-timepicker"
354
+ */
355
+ cssClass?: string;
356
+
230
357
  /**
231
- * @description Enable inline mode for always-visible timepicker
232
- * If enabled is true, containerId must be provided and the timepicker will be rendered inside the specified container instead of as a modal.
233
- * The timepicker will not open on input click and will be always visible.
358
+ * @description Selector where to append modal (default: body)
359
+ * @default ""
360
+ */
361
+ appendModalSelector?: string;
362
+
363
+ /**
364
+ * @description Custom keyboard icon template (desktop → mobile)
365
+ * @default Material Icons template
366
+ */
367
+ iconTemplate?: string;
368
+
369
+ /**
370
+ * @description Custom schedule icon template (mobile → desktop)
371
+ * @default Material Icons template
372
+ */
373
+ iconTemplateMobile?: string;
374
+
375
+ /**
376
+ * @description Inline mode configuration
234
377
  * @example
235
378
  * inline: {
236
379
  * enabled: true,
@@ -238,543 +381,178 @@ type OptionTypes = {
238
381
  * showButtons: false,
239
382
  * autoUpdate: true
240
383
  * }
241
- * @default undefined
242
384
  */
243
385
  inline?: {
244
- /**
245
- * @description Enable or disable inline mode
246
- */
247
386
  enabled: boolean;
248
- /**
249
- * @description ID of the container element where the timepicker should be rendered (required when enabled is true)
250
- */
251
387
  containerId: string;
252
- /**
253
- * @description Show or hide OK/CANCEL buttons in inline mode
254
- * @default false
255
- */
256
388
  showButtons?: boolean;
257
- /**
258
- * @description Automatically update input value when time changes (real-time updates)
259
- * @default true
260
- */
261
389
  autoUpdate?: boolean;
262
390
  };
391
+ }
392
+
393
+ /**
394
+ * Text labels configuration
395
+ */
396
+ interface LabelsOptions {
263
397
  /**
264
- * @description Add additional custom CSS class to the timepicker wrapper element. The default 'timepicker-ui' class is always added.
265
- * This allows multiple timepickers on the same page to have additional custom classes for styling or targeting.
266
- * @example cssClass: "my-custom-timepicker"
267
- * @default undefined
398
+ * @description "AM" label text
399
+ * @default "AM"
268
400
  */
269
- cssClass?: string;
401
+ am?: string;
402
+
403
+ /**
404
+ * @description "PM" label text
405
+ * @default "PM"
406
+ */
407
+ pm?: string;
408
+
409
+ /**
410
+ * @description "OK" button text
411
+ * @default "OK"
412
+ */
413
+ ok?: string;
414
+
415
+ /**
416
+ * @description "Cancel" button text
417
+ * @default "Cancel"
418
+ */
419
+ cancel?: string;
420
+
421
+ /**
422
+ * @description Time label on desktop
423
+ * @default "Select time"
424
+ */
425
+ time?: string;
426
+
427
+ /**
428
+ * @description Time label on mobile
429
+ * @default "Enter Time"
430
+ */
431
+ mobileTime?: string;
432
+
433
+ /**
434
+ * @description Hour label on mobile
435
+ * @default "Hour"
436
+ */
437
+ mobileHour?: string;
438
+
439
+ /**
440
+ * @description Minute label on mobile
441
+ * @default "Minute"
442
+ */
443
+ mobileMinute?: string;
444
+ }
445
+
446
+ /**
447
+ * Behavior configuration
448
+ */
449
+ interface BehaviorOptions {
450
+ /**
451
+ * @description Focus input after closing modal
452
+ * @default false
453
+ */
454
+ focusInputAfterClose?: boolean;
455
+
456
+ /**
457
+ * @description Enable focus trap in modal
458
+ * @default true
459
+ */
460
+ focusTrap?: boolean;
461
+
462
+ /**
463
+ * @description Delay for clickable elements (ms)
464
+ * @default 300
465
+ */
466
+ delayHandler?: number;
467
+
468
+ /**
469
+ * @description Custom ID for the timepicker instance
470
+ * @example id: "my-timepicker-1"
471
+ */
472
+ id?: string;
473
+ }
474
+
475
+ /**
476
+ * Event callbacks configuration
477
+ */
478
+ interface CallbacksOptions {
270
479
  /**
271
- * @description Callback triggered when the timepicker opens
272
- * @example onOpen: (data) => console.log('Picker opened!', data)
480
+ * @description Triggered when timepicker opens
273
481
  */
274
482
  onOpen?: TimepickerEventCallback;
483
+
275
484
  /**
276
- * @description Callback triggered when user cancels the timepicker
277
- * @example onCancel: (data) => console.log('Cancelled', data)
485
+ * @description Triggered when user cancels
278
486
  */
279
487
  onCancel?: TimepickerEventCallback;
488
+
280
489
  /**
281
- * @description Callback triggered when user confirms the time selection (clicks OK)
282
- * @example onConfirm: (data) => console.log('Time confirmed', data)
490
+ * @description Triggered when user confirms time
283
491
  */
284
492
  onConfirm?: TimepickerEventCallback;
493
+
285
494
  /**
286
- * @description Callback triggered during interaction with the clock (real-time updates)
287
- * @example onUpdate: (data) => console.log('Time updated', data)
495
+ * @description Triggered during interaction (real-time)
288
496
  */
289
497
  onUpdate?: TimepickerEventCallback;
498
+
290
499
  /**
291
- * @description Callback triggered when hour selection mode is activated
292
- * @example onSelectHour: (data) => console.log('Hour mode selected', data)
500
+ * @description Triggered when hour mode is selected
293
501
  */
294
502
  onSelectHour?: TimepickerEventCallback;
503
+
295
504
  /**
296
- * @description Callback triggered when minute selection mode is activated
297
- * @example onSelectMinute: (data) => console.log('Minute mode selected', data)
505
+ * @description Triggered when minute mode is selected
298
506
  */
299
507
  onSelectMinute?: TimepickerEventCallback;
508
+
300
509
  /**
301
- * @description Callback triggered when AM is selected
302
- * @example onSelectAM: (data) => console.log('AM selected', data)
510
+ * @description Triggered when AM is selected
303
511
  */
304
512
  onSelectAM?: TimepickerEventCallback;
513
+
305
514
  /**
306
- * @description Callback triggered when PM is selected
307
- * @example onSelectPM: (data) => console.log('PM selected', data)
515
+ * @description Triggered when PM is selected
308
516
  */
309
517
  onSelectPM?: TimepickerEventCallback;
518
+
310
519
  /**
311
- * @description Callback triggered when invalid time format is detected in input
312
- * @example onError: (data) => console.log('Invalid format:', data.error)
520
+ * @description Triggered on invalid time format
313
521
  */
314
522
  onError?: TimepickerEventCallback;
315
- };
316
-
317
- declare class DOMUpdateBatcher {
318
- private updates;
319
- private rafId;
320
- schedule(update: () => void): void;
321
- private flush;
322
- destroy(): void;
323
- }
324
-
325
- type InputValueResult = {
326
- hour: string;
327
- minutes: string;
328
- type?: string;
329
- error?: string;
330
- currentHour?: string | number;
331
- currentMin?: string | number;
332
- currentType?: string;
333
- currentLength?: number;
334
- };
335
-
336
- declare class ConfigManager {
337
- private timepicker;
338
- private timeouts;
339
- private debouncedHandler?;
340
- constructor(timepicker: ITimepickerUI);
341
- private clearAllTimeouts;
342
- private runWithTimeout;
343
- private isCurrentTimeEnabled;
344
- /** @internal */
345
- preventClockTypeByCurrentTime: () => void;
346
- /** @internal */
347
- updateInputValueWithCurrentTimeOnStart: () => void;
348
- /** @internal */
349
- checkMobileOption(): void;
350
- /** @internal */
351
- getDisableTime(): void;
352
- /** @internal */
353
- getInputValueOnOpenAndSet: () => void;
354
- private handleModeSwitch;
355
- /** @internal */
356
- handlerViewChange: () => (...args: any[]) => void;
357
- /** @internal */
358
- getInputValue: (el: HTMLInputElement, clockType?: string, currentTime?: OptionTypes["currentTime"], updateOptions?: boolean) => InputValueResult;
359
- destroy(): void;
360
- }
361
-
362
- declare class ThemeManager {
363
- private timepicker;
364
- constructor(timepicker: ITimepickerUI);
365
- /** @internal */
366
- setTheme: () => void;
367
- /** @internal */
368
- setInputClassToInputElement: () => void;
369
- /** @internal */
370
- setDataOpenToInputIfDoesntExistInWrapper: () => void;
371
- /** @internal */
372
- setClassTopOpenElement: () => void;
373
- /** @internal */
374
- setTimepickerClassToElement: () => void;
375
- destroy(): void;
376
- }
377
-
378
- declare class ValidationManager {
379
- private timepicker;
380
- constructor(timepicker: ITimepickerUI);
381
- /** @internal */
382
- setErrorHandler(): boolean | undefined;
383
- /** @internal */
384
- removeErrorHandler(): void;
385
- /** @internal */
386
- checkDisabledValuesOnStart(): void;
387
- destroy(): void;
388
- }
389
-
390
- declare class ClockManager {
391
- private timepicker;
392
- constructor(timepicker: ITimepickerUI);
393
- /** @internal */
394
- removeCircleClockClasses24h(): void;
395
- /** @internal */
396
- setCircleClockClasses24h(): void;
397
- /** @internal */
398
- setOnStartCSSClassesIfClockType24h(): void;
399
- /** @internal */
400
- setBgColorToCircleWithMinutesTips: () => void;
401
- /** @internal */
402
- removeBgColorToCirleWithMinutesTips: () => void;
403
- /** @internal */
404
- setClassActiveToHourOnOpen: () => void;
405
- /** @internal */
406
- setMinutesToClock: (value: string | null) => void;
407
- /** @internal */
408
- setHoursToClock: (value: string | null) => void;
409
- /** @internal */
410
- setTransformToCircleWithSwitchesHour: (val: string | null) => void;
411
- /** @internal */
412
- setTransformToCircleWithSwitchesMinutes: (val: string | null) => void;
413
- /** @internal */
414
- toggleClassActiveToValueTips: (value: string | number | null) => void;
415
- }
416
-
417
- declare class AnimationManager {
418
- private timepicker;
419
- private timeouts;
420
- constructor(timepicker: ITimepickerUI);
421
- private runWithAnimation;
422
- private clearAllTimeouts;
423
- /** @internal */
424
- setAnimationToOpen(): void;
425
- /** @internal */
426
- removeAnimationToClose(): void;
427
- /** @internal */
428
- handleAnimationClock(): void;
429
- /** @internal */
430
- handleAnimationSwitchTipsMode(): void;
431
- /** @internal */
432
- destroy(): void;
433
- }
434
-
435
- declare class ModalManager {
436
- private timepicker;
437
- private timeouts;
438
- private originalOverflow?;
439
- private originalPaddingRight?;
440
- constructor(timepicker: ITimepickerUI);
441
- private runWithTimeout;
442
- private clearAllTimeouts;
443
- private clearExistingModal;
444
- /** @internal */
445
- setModalTemplate: () => void;
446
- /** @internal */
447
- setScrollbarOrNot: () => void;
448
- /** @internal */
449
- removeBackdrop: () => void;
450
- /** @internal */
451
- setNormalizeClass: () => void;
452
- /** @internal */
453
- setShowClassToBackdrop: () => void;
454
- /** @internal */
455
- setFlexEndToFooterIfNoKeyboardIcon: () => void;
456
- /** Cleanup to avoid leaks */
457
- destroy(): void;
458
- }
459
-
460
- declare class EventManager {
461
- private _cleanupHandlers;
462
- private buttonHandlers;
463
- private dragHandlers;
464
- private typeModeHandlers;
465
- private inputHandlers;
466
- private clockHandPositionUpdater;
467
- private miscHandlers;
468
- private inlineHandlers;
469
- constructor(timepicker: ITimepickerUI);
470
- destroy(): void;
471
- handleOpenOnClick: () => void;
472
- handleOpenOnEnterFocus: () => void;
473
- handleCancelButton: () => void;
474
- handleOkButton: () => void;
475
- handleBackdropClick: () => void;
476
- handleAmClick: () => void;
477
- handlePmClick: () => void;
478
- handleHourEvents: () => void;
479
- handleMinutesEvents: () => void;
480
- handleEventToMoveHand: (event: TouchEvent) => void;
481
- handleMoveHand: () => void;
482
- handleClickOnHourMobile: () => void;
483
- handlerClickHourMinutes: (event: Event) => Promise<void>;
484
- handleIconChangeView: () => Promise<void>;
485
- handleEscClick: () => void;
486
- focusTrapHandler: () => void;
487
- handleInlineAutoUpdate: () => void;
488
- get _isDragging(): boolean;
489
- get _animationFrameId(): number | null;
490
- _onDragStart: (event: MouseEvent | TouchEvent) => void;
491
- _onDragMove: (event: MouseEvent | TouchEvent) => void;
492
- _onDragEnd: (event: MouseEvent | TouchEvent) => void;
493
- }
494
-
495
- declare class ClockFaceManager {
496
- private array?;
497
- private classToAdd?;
498
- private clockFace?;
499
- private tipsWrapper?;
500
- private theme?;
501
- private clockType?;
502
- private disabledTime?;
503
- private hour?;
504
- private activeTypeMode?;
505
- private _tipsCache;
506
- constructor(obj?: {
507
- array?: string[];
508
- classToAdd?: string;
509
- clockFace?: HTMLElement;
510
- tipsWrapper?: HTMLElement;
511
- theme?: string;
512
- clockType?: string;
513
- disabledTime?: any;
514
- hour?: any;
515
- activeTypeMode?: string;
516
- });
517
- /** @internal */
518
- clean: () => void;
519
- /** @internal */
520
- create: () => void;
521
- private _createTip;
522
- private _updateTipState;
523
- /** @internal */
524
- updateDisable: (hour?: string, activeTypeMode?: string) => void;
525
- /** @internal */
526
- private _removeClasses;
527
- /** Cleanup */
528
- destroy(): void;
529
- }
530
-
531
- interface ClockFaceConfig {
532
- array?: string[];
533
- classToAdd?: string;
534
- clockFace?: HTMLElement;
535
- tipsWrapper?: HTMLElement;
536
- theme?: string;
537
- clockType?: string;
538
- disabledTime?: {
539
- isInterval?: boolean;
540
- intervals?: string[];
541
- clockType?: string;
542
- } | string[] | null;
543
- hour?: string;
544
- activeTypeMode?: string;
545
- }
546
- declare class ClockFaceManagerPool {
547
- private pool;
548
- private maxSize;
549
- acquire(config: ClockFaceConfig): ClockFaceManager;
550
- release(instance: ClockFaceManager): void;
551
- clear(): void;
552
- }
553
-
554
- type EventHandler<T = CallbackData> = (data: T) => void;
555
- interface TimepickerEventMap {
556
- open: CallbackData;
557
- cancel: CallbackData;
558
- confirm: CallbackData;
559
- show: CallbackData;
560
- hide: CallbackData;
561
- update: CallbackData;
562
- 'select:hour': CallbackData;
563
- 'select:minute': CallbackData;
564
- 'select:am': CallbackData;
565
- 'select:pm': CallbackData;
566
- error: CallbackData;
567
- }
568
- declare class EventEmitter<EventMap extends Record<string, any> = TimepickerEventMap> {
569
- private events;
570
- on<K extends keyof EventMap>(event: K, handler: EventHandler<EventMap[K]>): void;
571
- once<K extends keyof EventMap>(event: K, handler: EventHandler<EventMap[K]>): void;
572
- off<K extends keyof EventMap>(event: K, handler?: EventHandler<EventMap[K]>): void;
573
- emit<K extends keyof EventMap>(event: K, data?: EventMap[K]): void;
574
- clear(): void;
575
- hasListeners<K extends keyof EventMap>(event: K): boolean;
576
- }
577
-
578
- interface ITimepickerUI {
579
- _degreesHours: number | null;
580
- _degreesMinutes: number | null;
581
- _eventsBundle: () => void;
582
- _options: OptionTypes;
583
- _eventsClickMobile: (event: Event) => Promise<void>;
584
- _eventsClickMobileHandler: EventListenerOrEventListenerObject;
585
- _mutliEventsMove: (event: Event) => void;
586
- _mutliEventsMoveHandler: EventListenerOrEventListenerObject;
587
- _clickTouchEvents: string[];
588
- _element: HTMLElement;
589
- _instanceId: string;
590
- _isMobileView: boolean | null;
591
- _isTouchMouseMove: boolean | null;
592
- _disabledTime: {
593
- value?: {
594
- isInterval?: boolean;
595
- intervals?: string[];
596
- clockType?: string;
597
- hours?: string[];
598
- minutes?: string[];
599
- };
600
- } | null;
601
- _cloned: Node | null;
602
- _inputEvents: string[];
603
- _isModalRemove?: boolean;
604
- _isInitialized: boolean;
605
- _customId?: string;
606
-
607
- clockFacePool: ClockFaceManagerPool;
608
-
609
- readonly modalTemplate: string;
610
- readonly modalElement: HTMLDivElement;
611
- readonly clockFace: HTMLDivElement;
612
- readonly input: HTMLInputElement;
613
- readonly clockHand: HTMLDivElement;
614
- readonly circle: HTMLDivElement;
615
- readonly tipsWrapper: HTMLDivElement;
616
- readonly tipsWrapperFor24h: HTMLDivElement;
617
- readonly minutes: HTMLInputElement;
618
- readonly hour: HTMLInputElement;
619
- readonly AM: HTMLDivElement;
620
- readonly PM: HTMLDivElement;
621
- readonly minutesTips: HTMLDivElement;
622
- readonly hourTips: HTMLDivElement;
623
- readonly allValueTips: readonly HTMLDivElement[];
624
- readonly openElementData: string[] | null;
625
- readonly openElement: NodeListOf<Element> | readonly [HTMLInputElement];
626
- readonly cancelButton: HTMLButtonElement;
627
- readonly okButton: HTMLButtonElement;
628
- readonly activeTypeMode: HTMLButtonElement;
629
- readonly keyboardClockIcon: HTMLButtonElement;
630
- readonly footer: HTMLDivElement;
631
- readonly wrapper: HTMLDivElement;
632
-
633
- create(): void;
634
- open(callback?: () => void): void;
635
- close(): (...args: (boolean | (() => void))[]) => void;
636
- destroy(options?: { keepInputValue?: boolean; callback?: () => void } | (() => void)): void;
637
- update(value: { options: OptionTypes; create?: boolean }, callback?: () => void): void;
638
- getElement(): HTMLElement;
639
- getValue(): {
640
- hour: string;
641
- minutes: string;
642
- type?: string;
643
- time: string;
644
- degreesHours: number | null;
645
- degreesMinutes: number | null;
646
- };
647
- setValue(time: string, updateInput?: boolean): void;
648
- setTheme(themeConfig: {
649
- primaryColor?: string;
650
- backgroundColor?: string;
651
- surfaceColor?: string;
652
- surfaceHoverColor?: string;
653
- textColor?: string;
654
- secondaryTextColor?: string;
655
- disabledTextColor?: string;
656
- onPrimaryColor?: string;
657
- borderColor?: string;
658
- shadow?: string;
659
- borderRadius?: string;
660
- fontFamily?: string;
661
- }): void;
662
-
663
- on<K extends keyof TimepickerEventMap>(event: K, handler: (data: TimepickerEventMap[K]) => void): void;
664
- once<K extends keyof TimepickerEventMap>(event: K, handler: (data: TimepickerEventMap[K]) => void): void;
665
- off<K extends keyof TimepickerEventMap>(event: K, handler?: (data: TimepickerEventMap[K]) => void): void;
666
-
667
- eventManager?: EventManager;
668
- modalManager?: ModalManager;
669
- animationManager?: AnimationManager;
670
- clockManager?: ClockManager;
671
- validationManager?: ValidationManager;
672
- themeManager?: ThemeManager;
673
- configManager?: ConfigManager;
674
- domBatcher: DOMUpdateBatcher;
675
- }
676
-
677
- declare class TimepickerCore {
678
- _degreesHours: number | null;
679
- _degreesMinutes: number | null;
680
- _options: OptionTypes;
681
- _eventsClickMobile: (event: Event) => Promise<void>;
682
- _eventsClickMobileHandler: EventListenerOrEventListenerObject;
683
- _mutliEventsMove: (event: Event) => void;
684
- _mutliEventsMoveHandler: EventListenerOrEventListenerObject;
685
- _clickTouchEvents: string[];
686
- _element: HTMLElement;
687
- _instanceId: string;
688
- _isMobileView: boolean | null;
689
- _isTouchMouseMove: boolean | null;
690
- _disabledTime: {
691
- value?: {
692
- isInterval?: boolean;
693
- intervals?: string[];
694
- clockType?: string;
695
- hours?: string[];
696
- minutes?: string[];
697
- };
698
- } | null;
699
- _cloned: Node | null;
700
- _inputEvents: string[];
701
- _isModalRemove?: boolean;
702
- _isInitialized: boolean;
703
- _customId?: string;
704
- _eventHandlersRegistered: boolean;
705
- _isDestroyed: boolean;
706
- _pendingThemeConfig?: {
707
- primaryColor?: string;
708
- backgroundColor?: string;
709
- surfaceColor?: string;
710
- surfaceHoverColor?: string;
711
- textColor?: string;
712
- secondaryTextColor?: string;
713
- disabledTextColor?: string;
714
- onPrimaryColor?: string;
715
- borderColor?: string;
716
- shadow?: string;
717
- borderRadius?: string;
718
- fontFamily?: string;
719
- };
720
- clockFacePool: ClockFaceManagerPool;
721
- eventManager: EventManager;
722
- modalManager: ModalManager;
723
- animationManager: AnimationManager;
724
- clockManager: ClockManager;
725
- validationManager: ValidationManager;
726
- themeManager: ThemeManager;
727
- configManager: ConfigManager;
728
- domBatcher: DOMUpdateBatcher;
729
- private _eventEmitter;
730
- constructor(selectorOrElement: string | HTMLElement, options?: OptionTypes);
731
- get modalTemplate(): any;
732
- get modalElement(): HTMLDivElement;
733
- get clockFace(): HTMLDivElement;
734
- get input(): HTMLInputElement;
735
- get clockHand(): HTMLDivElement;
736
- get circle(): HTMLDivElement;
737
- get tipsWrapper(): HTMLDivElement;
738
- get tipsWrapperFor24h(): HTMLDivElement;
739
- get minutes(): HTMLInputElement;
740
- get hour(): HTMLInputElement;
741
- get AM(): HTMLDivElement;
742
- get PM(): HTMLDivElement;
743
- get minutesTips(): HTMLDivElement;
744
- get hourTips(): HTMLDivElement;
745
- get allValueTips(): HTMLDivElement[];
746
- get openElementData(): string[] | null;
747
- get openElement(): NodeListOf<Element> | readonly [HTMLInputElement];
748
- get cancelButton(): HTMLButtonElement;
749
- get okButton(): HTMLButtonElement;
750
- get activeTypeMode(): HTMLButtonElement;
751
- get keyboardClockIcon(): HTMLButtonElement;
752
- get footer(): HTMLDivElement;
753
- get wrapper(): HTMLDivElement;
754
- getElement(): HTMLElement;
755
- on<K extends keyof TimepickerEventMap>(event: K, handler: (data: TimepickerEventMap[K]) => void): void;
756
- once<K extends keyof TimepickerEventMap>(event: K, handler: (data: TimepickerEventMap[K]) => void): void;
757
- off<K extends keyof TimepickerEventMap>(event: K, handler?: (data: TimepickerEventMap[K]) => void): void;
758
- protected emit<K extends keyof TimepickerEventMap>(event: K, data?: TimepickerEventMap[K]): void;
759
- protected _applyThemeToWrapper(wrapper: HTMLElement): void;
523
+ }
524
+
525
+ /**
526
+ * Main options type with grouped structure (v4.0.0)
527
+ */
528
+ interface TimepickerOptions {
529
+ clock?: ClockOptions;
530
+ ui?: UIOptions;
531
+ labels?: LabelsOptions;
532
+ behavior?: BehaviorOptions;
533
+ callbacks?: CallbacksOptions;
760
534
  }
761
535
 
762
- type TypeFunction$1 = () => void;
763
- declare class TimepickerLifecycle extends TimepickerCore {
764
- create: () => void;
765
- open: (callback?: () => void) => void;
766
- close: () => (...args: (boolean | TypeFunction$1)[]) => void;
767
- destroy: (options?: {
536
+ type Callback = () => void;
537
+ declare class TimepickerUI {
538
+ private readonly core;
539
+ private readonly managers;
540
+ private readonly lifecycle;
541
+ private readonly emitter;
542
+ constructor(selectorOrElement: string | HTMLElement, options?: TimepickerOptions);
543
+ private setupInternalEventListeners;
544
+ create(): void;
545
+ open(callback?: Callback): void;
546
+ close(update?: boolean, callback?: Callback): void;
547
+ destroy(options?: {
768
548
  keepInputValue?: boolean;
769
- callback?: TypeFunction$1;
770
- } | TypeFunction$1) => void;
771
- protected onDestroy?: () => void;
772
- _eventsBundle: () => void;
773
- }
774
-
775
- type TypeFunction = () => void;
776
- declare class TimepickerAPI extends TimepickerLifecycle {
777
- getValue: () => {
549
+ callback?: Callback;
550
+ } | Callback): void;
551
+ update(value: {
552
+ options: TimepickerOptions;
553
+ create?: boolean;
554
+ }, callback?: Callback): void;
555
+ getValue(): {
778
556
  hour: string;
779
557
  minutes: string;
780
558
  type?: string;
@@ -782,33 +560,26 @@ declare class TimepickerAPI extends TimepickerLifecycle {
782
560
  degreesHours: number | null;
783
561
  degreesMinutes: number | null;
784
562
  };
785
- setValue: (time: string, updateInput?: boolean) => void;
786
- update: (value: {
787
- options: OptionTypes;
788
- create?: boolean;
789
- }, callback?: TypeFunction) => void;
790
- setTheme(themeConfig: {
791
- primaryColor?: string;
792
- backgroundColor?: string;
793
- surfaceColor?: string;
794
- surfaceHoverColor?: string;
795
- textColor?: string;
796
- secondaryTextColor?: string;
797
- disabledTextColor?: string;
798
- onPrimaryColor?: string;
799
- borderColor?: string;
800
- shadow?: string;
801
- borderRadius?: string;
802
- fontFamily?: string;
803
- }): void;
804
- }
805
-
806
- declare class TimepickerUI extends TimepickerAPI implements ITimepickerUI {
807
- constructor(selectorOrElement: string | HTMLElement, options?: OptionTypes);
563
+ setValue(time: string, updateInput?: boolean): void;
564
+ getElement(): HTMLElement;
565
+ get instanceId(): string;
566
+ get options(): Required<TimepickerOptions>;
567
+ get isInitialized(): boolean;
568
+ get isDestroyed(): boolean;
569
+ get hour(): HTMLInputElement | null;
570
+ get minutes(): HTMLInputElement | null;
571
+ get okButton(): HTMLButtonElement | null;
572
+ get cancelButton(): HTMLButtonElement | null;
573
+ get clockHand(): HTMLDivElement | null;
574
+ on<K extends keyof TimepickerEventMap>(event: K, handler: (data: TimepickerEventMap[K]) => void): void;
575
+ once<K extends keyof TimepickerEventMap>(event: K, handler: (data: TimepickerEventMap[K]) => void): void;
576
+ off<K extends keyof TimepickerEventMap>(event: K, handler?: (data: TimepickerEventMap[K]) => void): void;
577
+ private resolveInputElement;
578
+ private createWrapperElement;
808
579
  static getById(id: string): TimepickerUI | undefined;
809
580
  static getAllInstances(): TimepickerUI[];
810
581
  static isAvailable(selectorOrElement: string | HTMLElement): boolean;
811
582
  static destroyAll(): void;
812
583
  }
813
584
 
814
- export { type CallbackData, EventEmitter, type OptionTypes, TimepickerUI, TimepickerUI as default };
585
+ export { type CancelEventData, type ConfirmEventData, type ErrorEventData, EventEmitter, type HideEventData, type OpenEventData, type OptionTypes, type SelectAMEventData, type SelectHourEventData, type SelectMinuteEventData, type SelectPMEventData, type ShowEventData, type SwitchViewEventData, TimepickerUI, type UpdateEventData, TimepickerUI as default };