timepicker-ui 3.2.0 → 4.0.1

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.ts 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,30 +118,13 @@ 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
- */
125
+ /** Auto-switch to minutes @default true */
130
126
  autoSwitchToMinutes?: boolean;
131
- /**
132
- * @description Set theme to timepicker. Available options: `basic`, `crane`, `crane-straight`, `m3-green`, `m2`, `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
- */
127
+ /** Theme @default "basic" */
140
128
  theme?:
141
129
  | 'basic'
142
130
  | 'crane'
@@ -147,91 +135,245 @@ type OptionTypes = {
147
135
  | 'glassmorphic'
148
136
  | 'pastel'
149
137
  | 'ai'
150
- | 'cyberpunk'
151
- | '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 {
152
235
  /**
153
- * @description Set type of clock, it contains 2 versions: `12h` and `24h`.
236
+ * @description Set type of clock: `12h` or `24h`
237
+ * @default "12h"
238
+ */
239
+ type?: '12h' | '24h';
240
+
241
+ /**
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
154
255
  * @default false
155
256
  */
156
- clockType?: '12h' | '24h';
257
+ autoSwitchToMinutes?: boolean;
258
+
157
259
  /**
158
- * @description - The `hours` and `minutes` are arrays which accept strings and numbers to block select hours/minutes.
159
- * - The `interval` key can accept string or string[] to block select time intervals.
160
- * - If the interval key is set, the hours/minutes keys are `ignored`.
260
+ * @description Disable specific hours/minutes or time intervals
161
261
  * @example
162
- disabledTime: {
163
- minutes: [1,2,4,5,55,23,"22","38"],
164
- hours: [1,"3","5", 8],
165
- interval: "10:00 AM - 12:00 PM" | ["10:00 AM - 12:00 PM", "5:00 PM - 8:00 PM"],
166
- }
167
- * @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
+ * }
168
267
  */
169
268
  disabledTime?: {
170
269
  minutes?: Array<string | number>;
171
270
  hours?: Array<string | number>;
172
271
  interval?: string | string[];
173
272
  };
273
+
174
274
  /**
175
- * @description Set current time to the input and timepicker.\
176
- * If this options is set to `true` it's gonna update picker with toLocaleTimeString() and input with value based on your location.
177
- * This option also allows to put object with properties.
275
+ * @description Set current time to the input and timepicker
178
276
  * @example
179
- currentTime: {
180
- time: new Date(),
181
- updateInput: true,
182
- locales: "en-US",
183
- preventClockType: false
184
- };
277
+ * currentTime: {
278
+ * time: new Date(),
279
+ * updateInput: true,
280
+ * locales: "en-US",
281
+ * preventClockType: false
282
+ * }
185
283
  * @example currentTime: true
186
- * @default undefined
187
284
  */
188
285
  currentTime?:
189
286
  | {
190
- /**
191
- * The `time` key allows to put any valid date to update picker.
192
- * @requires
193
- * 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.
194
- *
195
- * If the `updateInput` is set to `false/undefined` but the default value from the input exist, the `time` key will be ignored.
196
- */
197
287
  time?: Date;
198
- /**
199
- * The `updateInput` key is set to `true` it's going update input value with set time key.
200
- */
201
288
  updateInput?: boolean;
202
- /**
203
- * The `locales` key can change language from `toLocaleTimeString()`.
204
- */
205
289
  locales?: string | string[];
206
- /**
207
- * The `preventClockType` key if is set to `true` it's `force` the clockType option to set value "12h" or "24h" based on your location
208
- * with current time and `locales` key value is ignored.
209
- */
210
290
  preventClockType?: boolean;
211
291
  }
212
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';
213
314
 
214
315
  /**
215
- * @description Set focus trap to the modal element to all elements with tabindex in the picker
316
+ * @description Enable/disable animations
216
317
  * @default true
217
318
  */
218
- focusTrap?: boolean;
319
+ animation?: boolean;
320
+
219
321
  /**
220
- * @description Set delay to clickable elements like button "OK", "Cancel" etc. The value has to be set in milliseconds.
221
- * @default 300
322
+ * @description Show backdrop when timepicker is open
323
+ * @default true
222
324
  */
223
- delayHandler?: number;
325
+ backdrop?: boolean;
326
+
224
327
  /**
225
- * @description Custom ID for the timepicker instance. Useful for identifying specific instances when using multiple timepickers.
226
- * If not provided, a random UUID will be generated.
227
- * @example id: "my-timepicker-1"
228
- * @default undefined
328
+ * @description Force mobile mode
329
+ * @default false
229
330
  */
230
- 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
+
231
351
  /**
232
- * @description Enable inline mode for always-visible timepicker
233
- * If enabled is true, containerId must be provided and the timepicker will be rendered inside the specified container instead of as a modal.
234
- * The timepicker will not open on input click and will be always visible.
352
+ * @description Additional CSS class for the wrapper
353
+ * @example cssClass: "my-custom-timepicker"
354
+ */
355
+ cssClass?: string;
356
+
357
+ /**
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
235
377
  * @example
236
378
  * inline: {
237
379
  * enabled: true,
@@ -239,481 +381,178 @@ type OptionTypes = {
239
381
  * showButtons: false,
240
382
  * autoUpdate: true
241
383
  * }
242
- * @default undefined
243
384
  */
244
385
  inline?: {
245
- /**
246
- * @description Enable or disable inline mode
247
- */
248
386
  enabled: boolean;
249
- /**
250
- * @description ID of the container element where the timepicker should be rendered (required when enabled is true)
251
- */
252
387
  containerId: string;
253
- /**
254
- * @description Show or hide OK/Cancel buttons in inline mode
255
- * @default false
256
- */
257
388
  showButtons?: boolean;
258
- /**
259
- * @description Automatically update input value when time changes (real-time updates)
260
- * @default true
261
- */
262
389
  autoUpdate?: boolean;
263
390
  };
391
+ }
392
+
393
+ /**
394
+ * Text labels configuration
395
+ */
396
+ interface LabelsOptions {
264
397
  /**
265
- * @description Add additional custom CSS class to the timepicker wrapper element. The default 'timepicker-ui' class is always added.
266
- * This allows multiple timepickers on the same page to have additional custom classes for styling or targeting.
267
- * @example cssClass: "my-custom-timepicker"
268
- * @default undefined
398
+ * @description "AM" label text
399
+ * @default "AM"
269
400
  */
270
- cssClass?: string;
401
+ am?: string;
402
+
271
403
  /**
272
- * @description Callback triggered when the timepicker opens
273
- * @example onOpen: (data) => console.log('Picker opened!', data)
404
+ * @description "PM" label text
405
+ * @default "PM"
274
406
  */
275
- onOpen?: TimepickerEventCallback;
407
+ pm?: string;
408
+
276
409
  /**
277
- * @description Callback triggered when user cancels the timepicker
278
- * @example onCancel: (data) => console.log('Cancelled', data)
410
+ * @description "OK" button text
411
+ * @default "OK"
279
412
  */
280
- onCancel?: TimepickerEventCallback;
413
+ ok?: string;
414
+
281
415
  /**
282
- * @description Callback triggered when user confirms the time selection (clicks OK)
283
- * @example onConfirm: (data) => console.log('Time confirmed', data)
416
+ * @description "Cancel" button text
417
+ * @default "Cancel"
284
418
  */
285
- onConfirm?: TimepickerEventCallback;
419
+ cancel?: string;
420
+
286
421
  /**
287
- * @description Callback triggered during interaction with the clock (real-time updates)
288
- * @example onUpdate: (data) => console.log('Time updated', data)
422
+ * @description Time label on desktop
423
+ * @default "Select time"
289
424
  */
290
- onUpdate?: TimepickerEventCallback;
425
+ time?: string;
426
+
291
427
  /**
292
- * @description Callback triggered when hour selection mode is activated
293
- * @example onSelectHour: (data) => console.log('Hour mode selected', data)
428
+ * @description Time label on mobile
429
+ * @default "Enter Time"
294
430
  */
295
- onSelectHour?: TimepickerEventCallback;
431
+ mobileTime?: string;
432
+
296
433
  /**
297
- * @description Callback triggered when minute selection mode is activated
298
- * @example onSelectMinute: (data) => console.log('Minute mode selected', data)
434
+ * @description Hour label on mobile
435
+ * @default "Hour"
299
436
  */
300
- onSelectMinute?: TimepickerEventCallback;
437
+ mobileHour?: string;
438
+
301
439
  /**
302
- * @description Callback triggered when AM is selected
303
- * @example onSelectAM: (data) => console.log('AM selected', data)
440
+ * @description Minute label on mobile
441
+ * @default "Minute"
304
442
  */
305
- onSelectAM?: TimepickerEventCallback;
443
+ mobileMinute?: string;
444
+ }
445
+
446
+ /**
447
+ * Behavior configuration
448
+ */
449
+ interface BehaviorOptions {
306
450
  /**
307
- * @description Callback triggered when PM is selected
308
- * @example onSelectPM: (data) => console.log('PM selected', data)
451
+ * @description Focus input after closing modal
452
+ * @default false
309
453
  */
310
- onSelectPM?: TimepickerEventCallback;
454
+ focusInputAfterClose?: boolean;
455
+
311
456
  /**
312
- * @description Callback triggered when invalid time format is detected in input
313
- * @example onError: (data) => console.log('Invalid format:', data.error)
457
+ * @description Enable focus trap in modal
458
+ * @default true
314
459
  */
315
- onError?: TimepickerEventCallback;
316
- };
317
-
318
- declare class DOMUpdateBatcher {
319
- private updates;
320
- private rafId;
321
- schedule(update: () => void): void;
322
- private flush;
323
- destroy(): void;
324
- }
325
-
326
- type InputValueResult = {
327
- hour: string;
328
- minutes: string;
329
- type?: string;
330
- error?: string;
331
- currentHour?: string | number;
332
- currentMin?: string | number;
333
- currentType?: string;
334
- currentLength?: number;
335
- };
336
-
337
- declare class ConfigManager {
338
- private timepicker;
339
- private debouncedHandler?;
340
- private timeoutManager;
341
- private viewSwitcher;
342
- private mobileToggler;
343
- private initManager;
344
- constructor(timepicker: ITimepickerUI);
345
- preventClockTypeByCurrentTime: () => void;
346
- updateInputValueWithCurrentTimeOnStart: () => void;
347
- checkMobileOption(): void;
348
- getDisableTime(): void;
349
- getInputValueOnOpenAndSet: () => void;
350
- toggleMobileClockFace: () => void;
351
- getInputValue: (el: HTMLInputElement, clockType?: string, currentTime?: OptionTypes["currentTime"], updateOptions?: boolean) => InputValueResult;
352
- destroy(): void;
353
- }
354
-
355
- declare class ThemeManager {
356
- private timepicker;
357
- constructor(timepicker: ITimepickerUI);
358
- /** @internal */
359
- setTheme: () => void;
360
- /** @internal */
361
- setInputClassToInputElement: () => void;
362
- /** @internal */
363
- setDataOpenToInputIfDoesntExistInWrapper: () => void;
364
- /** @internal */
365
- setClassTopOpenElement: () => void;
366
- /** @internal */
367
- setTimepickerClassToElement: () => void;
368
- destroy(): void;
369
- }
370
-
371
- declare class ValidationManager {
372
- private timepicker;
373
- constructor(timepicker: ITimepickerUI);
374
- /** @internal */
375
- setErrorHandler(): boolean | undefined;
376
- /** @internal */
377
- removeErrorHandler(): void;
378
- /** @internal */
379
- checkDisabledValuesOnStart(): void;
380
- destroy(): void;
381
- }
382
-
383
- declare class ClockManager {
384
- private timepicker;
385
- private clockSystem;
386
- constructor(timepicker: ITimepickerUI);
387
- initializeClockSystem(): void;
388
- private convertDisabledTime;
389
- private getAmPmValue;
390
- destroyClockSystem(): void;
391
- removeCircleClockClasses24h(): void;
392
- setCircleClockClasses24h(): void;
393
- setOnStartCSSClassesIfClockType24h(): void;
394
- setBgColorToCircleWithMinutesTips: () => void;
395
- removeBgColorToCirleWithMinutesTips: () => void;
396
- setClassActiveToHourOnOpen: () => void;
397
- setMinutesToClock: (value: string | null) => void;
398
- setHoursToClock: (value: string | null) => void;
399
- setTransformToCircleWithSwitchesHour: (val: string | null) => void;
400
- setTransformToCircleWithSwitchesMinutes: (val: string | null) => void;
401
- updateAmPm: () => void;
402
- toggleClassActiveToValueTips: (value: string | number | null) => void;
403
- }
404
-
405
- declare class AnimationManager {
406
- private timepicker;
407
- private timeouts;
408
- constructor(timepicker: ITimepickerUI);
409
- private runWithAnimation;
410
- private clearAllTimeouts;
411
- /** @internal */
412
- setAnimationToOpen(): void;
413
- /** @internal */
414
- removeAnimationToClose(): void;
415
- /** @internal */
416
- handleAnimationClock(): void;
417
- /** @internal */
418
- handleAnimationSwitchTipsMode(): void;
419
- /** @internal */
420
- destroy(): void;
421
- }
422
-
423
- declare class ModalManager {
424
- private timepicker;
425
- private timeouts;
426
- private originalOverflow?;
427
- private originalPaddingRight?;
428
- constructor(timepicker: ITimepickerUI);
429
- private runWithTimeout;
430
- private clearAllTimeouts;
431
- private clearExistingModal;
432
- /** @internal */
433
- setModalTemplate: () => void;
434
- /** @internal */
435
- setScrollbarOrNot: () => void;
436
- /** @internal */
437
- removeBackdrop: () => void;
438
- /** @internal */
439
- setNormalizeClass: () => void;
440
- /** @internal */
441
- setShowClassToBackdrop: () => void;
442
- /** @internal */
443
- setFlexEndToFooterIfNoKeyboardIcon: () => void;
444
- destroy(): void;
445
- }
446
-
447
- declare class EventManager {
448
- private _cleanupHandlers;
449
- private buttonHandlers;
450
- private typeModeHandlers;
451
- private inputHandlers;
452
- private miscHandlers;
453
- private inlineHandlers;
454
- constructor(timepicker: ITimepickerUI);
455
- destroy(): void;
456
- handleOpenOnClick: () => void;
457
- handleOpenOnEnterFocus: () => void;
458
- handleCancelButton: () => void;
459
- handleOkButton: () => void;
460
- handleBackdropClick: () => void;
461
- handleAmClick: () => void;
462
- handlePmClick: () => void;
463
- handleHourEvents: () => void;
464
- handleMinutesEvents: () => void;
465
- handleClickOnHourMobile: () => void;
466
- handlerClickHourMinutes: (event: Event) => Promise<void>;
467
- handleIconChangeView: () => Promise<void>;
468
- handleEscClick: () => void;
469
- focusTrapHandler: () => void;
470
- handleInlineAutoUpdate: () => void;
471
- handleMoveHand: () => void;
472
- handleEventToMoveHand: (event: TouchEvent) => void;
473
- get _isDragging(): boolean;
474
- get _animationFrameId(): number | null;
475
- _onDragStart: (event: MouseEvent | TouchEvent) => void;
476
- _onDragMove: (event: MouseEvent | TouchEvent) => void;
477
- _onDragEnd: (event: MouseEvent | TouchEvent) => void;
478
- }
479
-
480
- type EventHandler<T = CallbackData> = (data: T) => void;
481
- interface TimepickerEventMap {
482
- open: CallbackData;
483
- cancel: CallbackData;
484
- confirm: CallbackData;
485
- show: CallbackData;
486
- hide: CallbackData;
487
- update: CallbackData;
488
- 'select:hour': CallbackData;
489
- 'select:minute': CallbackData;
490
- 'select:am': CallbackData;
491
- 'select:pm': CallbackData;
492
- error: CallbackData;
493
- }
494
- declare class EventEmitter<EventMap extends Record<string, any> = TimepickerEventMap> {
495
- private events;
496
- on<K extends keyof EventMap>(event: K, handler: EventHandler<EventMap[K]>): void;
497
- once<K extends keyof EventMap>(event: K, handler: EventHandler<EventMap[K]>): void;
498
- off<K extends keyof EventMap>(event: K, handler?: EventHandler<EventMap[K]>): void;
499
- emit<K extends keyof EventMap>(event: K, data?: EventMap[K]): void;
500
- clear(): void;
501
- hasListeners<K extends keyof EventMap>(event: K): boolean;
502
- }
503
-
504
- interface ITimepickerUI {
505
- _degreesHours: number | null;
506
- _degreesMinutes: number | null;
507
- _eventsBundle: () => void;
508
- _options: OptionTypes;
509
- _eventsClickMobile: (event: Event) => Promise<void>;
510
- _eventsClickMobileHandler: EventListenerOrEventListenerObject;
511
- _mutliEventsMove: (event: Event) => void;
512
- _mutliEventsMoveHandler: EventListenerOrEventListenerObject;
513
- _clickTouchEvents: string[];
514
- _element: HTMLElement;
515
- _instanceId: string;
516
- _isMobileView: boolean | null;
517
- _isTouchMouseMove: boolean | null;
518
- _disabledTime: {
519
- value?: {
520
- isInterval?: boolean;
521
- intervals?: string[];
522
- clockType?: string;
523
- hours?: string[];
524
- minutes?: string[];
525
- };
526
- } | null;
527
- _cloned: Node | null;
528
- _inputEvents: string[];
529
- _isModalRemove?: boolean;
530
- _isInitialized: boolean;
531
- _customId?: string;
532
-
533
- readonly modalTemplate: string;
534
- readonly modalElement: HTMLDivElement;
535
- readonly clockFace: HTMLDivElement;
536
- readonly input: HTMLInputElement;
537
- readonly clockHand: HTMLDivElement;
538
- readonly circle: HTMLDivElement;
539
- readonly tipsWrapper: HTMLDivElement;
540
- readonly tipsWrapperFor24h: HTMLDivElement;
541
- readonly minutes: HTMLInputElement;
542
- readonly hour: HTMLInputElement;
543
- readonly AM: HTMLDivElement;
544
- readonly PM: HTMLDivElement;
545
- readonly hourText: HTMLDivElement;
546
- readonly minutesText: HTMLDivElement;
547
- readonly inputWrappers: NodeListOf<Element>;
548
- readonly dots: HTMLDivElement;
549
- readonly header: HTMLDivElement;
550
- readonly minutesTips: HTMLDivElement;
551
- readonly hourTips: HTMLDivElement;
552
- readonly allValueTips: readonly HTMLDivElement[];
553
- readonly openElementData: string[] | null;
554
- readonly openElement: NodeListOf<Element> | readonly [HTMLInputElement];
555
- readonly cancelButton: HTMLButtonElement;
556
- readonly okButton: HTMLButtonElement;
557
- readonly activeTypeMode: HTMLButtonElement;
558
- readonly keyboardClockIcon: HTMLButtonElement;
559
- readonly footer: HTMLDivElement;
560
- readonly wrapper: HTMLDivElement;
561
-
562
- create(): void;
563
- open(callback?: () => void): void;
564
- close(): (...args: (boolean | (() => void))[]) => void;
565
- destroy(options?: { keepInputValue?: boolean; callback?: () => void } | (() => void)): void;
566
- update(value: { options: OptionTypes; create?: boolean }, callback?: () => void): void;
567
- getElement(): HTMLElement;
568
- getValue(): {
569
- hour: string;
570
- minutes: string;
571
- type?: string;
572
- time: string;
573
- degreesHours: number | null;
574
- degreesMinutes: number | null;
575
- };
576
- setValue(time: string, updateInput?: boolean): void;
577
- setTheme(themeConfig: {
578
- primaryColor?: string;
579
- backgroundColor?: string;
580
- surfaceColor?: string;
581
- surfaceHoverColor?: string;
582
- textColor?: string;
583
- secondaryTextColor?: string;
584
- disabledTextColor?: string;
585
- onPrimaryColor?: string;
586
- borderColor?: string;
587
- shadow?: string;
588
- borderRadius?: string;
589
- fontFamily?: string;
590
- }): void;
591
-
592
- on<K extends keyof TimepickerEventMap>(event: K, handler: (data: TimepickerEventMap[K]) => void): void;
593
- once<K extends keyof TimepickerEventMap>(event: K, handler: (data: TimepickerEventMap[K]) => void): void;
594
- off<K extends keyof TimepickerEventMap>(event: K, handler?: (data: TimepickerEventMap[K]) => void): void;
595
-
596
- /** @internal */
597
- emit?<K extends keyof TimepickerEventMap>(event: K, data?: TimepickerEventMap[K]): void;
598
-
599
- eventManager?: EventManager;
600
- modalManager?: ModalManager;
601
- animationManager?: AnimationManager;
602
- clockManager?: ClockManager;
603
- validationManager?: ValidationManager;
604
- themeManager?: ThemeManager;
605
- configManager?: ConfigManager;
606
- domBatcher: DOMUpdateBatcher;
607
- }
608
-
609
- declare class TimepickerCore {
610
- _degreesHours: number | null;
611
- _degreesMinutes: number | null;
612
- _options: OptionTypes;
613
- _eventsClickMobile: (event: Event) => Promise<void>;
614
- _eventsClickMobileHandler: EventListenerOrEventListenerObject;
615
- _mutliEventsMove: (event: Event) => void;
616
- _mutliEventsMoveHandler: EventListenerOrEventListenerObject;
617
- _clickTouchEvents: string[];
618
- _element: HTMLElement;
619
- _instanceId: string;
620
- _isMobileView: boolean | null;
621
- _isTouchMouseMove: boolean | null;
622
- _disabledTime: {
623
- value?: {
624
- isInterval?: boolean;
625
- intervals?: string[];
626
- clockType?: string;
627
- hours?: string[];
628
- minutes?: string[];
629
- };
630
- } | null;
631
- _cloned: Node | null;
632
- _inputEvents: string[];
633
- _isModalRemove?: boolean;
634
- _isInitialized: boolean;
635
- _customId?: string;
636
- _eventHandlersRegistered: boolean;
637
- _isDestroyed: boolean;
638
- _pendingThemeConfig?: {
639
- primaryColor?: string;
640
- backgroundColor?: string;
641
- surfaceColor?: string;
642
- surfaceHoverColor?: string;
643
- textColor?: string;
644
- secondaryTextColor?: string;
645
- disabledTextColor?: string;
646
- onPrimaryColor?: string;
647
- borderColor?: string;
648
- shadow?: string;
649
- borderRadius?: string;
650
- fontFamily?: string;
651
- };
652
- eventManager: EventManager;
653
- modalManager: ModalManager;
654
- animationManager: AnimationManager;
655
- clockManager: ClockManager;
656
- validationManager: ValidationManager;
657
- themeManager: ThemeManager;
658
- configManager: ConfigManager;
659
- domBatcher: DOMUpdateBatcher;
660
- private _eventEmitter;
661
- constructor(selectorOrElement: string | HTMLElement, options?: OptionTypes);
662
- get modalTemplate(): string;
663
- get modalElement(): HTMLDivElement;
664
- get clockFace(): HTMLDivElement;
665
- get input(): HTMLInputElement;
666
- get clockHand(): HTMLDivElement;
667
- get circle(): HTMLDivElement;
668
- get tipsWrapper(): HTMLDivElement;
669
- get tipsWrapperFor24h(): HTMLDivElement;
670
- get minutes(): HTMLInputElement;
671
- get hour(): HTMLInputElement;
672
- get AM(): HTMLDivElement;
673
- get PM(): HTMLDivElement;
674
- get hourText(): HTMLDivElement;
675
- get minutesText(): HTMLDivElement;
676
- get header(): HTMLDivElement;
677
- get inputWrappers(): NodeListOf<Element>;
678
- get dots(): HTMLDivElement;
679
- get minutesTips(): HTMLDivElement;
680
- get hourTips(): HTMLDivElement;
681
- get allValueTips(): HTMLDivElement[];
682
- get openElementData(): string[] | null;
683
- get openElement(): NodeListOf<Element> | readonly [HTMLInputElement];
684
- get cancelButton(): HTMLButtonElement;
685
- get okButton(): HTMLButtonElement;
686
- get activeTypeMode(): HTMLButtonElement;
687
- get keyboardClockIcon(): HTMLButtonElement;
688
- get footer(): HTMLDivElement;
689
- get wrapper(): HTMLDivElement;
690
- getElement(): HTMLElement;
691
- on<K extends keyof TimepickerEventMap>(event: K, handler: (data: TimepickerEventMap[K]) => void): void;
692
- once<K extends keyof TimepickerEventMap>(event: K, handler: (data: TimepickerEventMap[K]) => void): void;
693
- off<K extends keyof TimepickerEventMap>(event: K, handler?: (data: TimepickerEventMap[K]) => void): void;
694
- /** @internal */
695
- emit<K extends keyof TimepickerEventMap>(event: K, data?: TimepickerEventMap[K]): void;
696
- protected _applyThemeToWrapper(wrapper: HTMLElement): void;
697
- private _resolveInputElement;
698
- private _createWrapperElement;
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 {
479
+ /**
480
+ * @description Triggered when timepicker opens
481
+ */
482
+ onOpen?: TimepickerEventCallback<OpenEventData>;
483
+
484
+ /**
485
+ * @description Triggered when user cancels
486
+ */
487
+ onCancel?: TimepickerEventCallback<CancelEventData>;
488
+
489
+ /**
490
+ * @description Triggered when user confirms time
491
+ */
492
+ onConfirm?: TimepickerEventCallback<ConfirmEventData>;
493
+
494
+ /**
495
+ * @description Triggered during interaction (real-time)
496
+ */
497
+ onUpdate?: TimepickerEventCallback<UpdateEventData>;
498
+
499
+ /**
500
+ * @description Triggered when hour mode is selected
501
+ */
502
+ onSelectHour?: TimepickerEventCallback<SelectHourEventData>;
503
+
504
+ /**
505
+ * @description Triggered when minute mode is selected
506
+ */
507
+ onSelectMinute?: TimepickerEventCallback<SelectMinuteEventData>;
508
+
509
+ /**
510
+ * @description Triggered when AM is selected
511
+ */
512
+ onSelectAM?: TimepickerEventCallback<SelectAMEventData>;
513
+
514
+ /**
515
+ * @description Triggered when PM is selected
516
+ */
517
+ onSelectPM?: TimepickerEventCallback<SelectPMEventData>;
518
+
519
+ /**
520
+ * @description Triggered on invalid time format
521
+ */
522
+ onError?: TimepickerEventCallback<ErrorEventData>;
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;
699
534
  }
700
535
 
701
- type TypeFunction$1 = () => void;
702
- declare class TimepickerLifecycle extends TimepickerCore {
703
- create: () => void;
704
- open: (callback?: () => void) => void;
705
- close: () => (...args: (boolean | TypeFunction$1)[]) => void;
706
- 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?: {
707
548
  keepInputValue?: boolean;
708
- callback?: TypeFunction$1;
709
- } | TypeFunction$1) => void;
710
- protected onDestroy?: () => void;
711
- _eventsBundle: () => void;
712
- }
713
-
714
- type TypeFunction = () => void;
715
- declare class TimepickerAPI extends TimepickerLifecycle {
716
- getValue: () => {
549
+ callback?: Callback;
550
+ } | Callback): void;
551
+ update(value: {
552
+ options: TimepickerOptions;
553
+ create?: boolean;
554
+ }, callback?: Callback): void;
555
+ getValue(): {
717
556
  hour: string;
718
557
  minutes: string;
719
558
  type?: string;
@@ -721,33 +560,26 @@ declare class TimepickerAPI extends TimepickerLifecycle {
721
560
  degreesHours: number | null;
722
561
  degreesMinutes: number | null;
723
562
  };
724
- setValue: (time: string, updateInput?: boolean) => void;
725
- update: (value: {
726
- options: OptionTypes;
727
- create?: boolean;
728
- }, callback?: TypeFunction) => void;
729
- setTheme(themeConfig: {
730
- primaryColor?: string;
731
- backgroundColor?: string;
732
- surfaceColor?: string;
733
- surfaceHoverColor?: string;
734
- textColor?: string;
735
- secondaryTextColor?: string;
736
- disabledTextColor?: string;
737
- onPrimaryColor?: string;
738
- borderColor?: string;
739
- shadow?: string;
740
- borderRadius?: string;
741
- fontFamily?: string;
742
- }): void;
743
- }
744
-
745
- declare class TimepickerUI extends TimepickerAPI implements ITimepickerUI {
746
- 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;
747
579
  static getById(id: string): TimepickerUI | undefined;
748
580
  static getAllInstances(): TimepickerUI[];
749
581
  static isAvailable(selectorOrElement: string | HTMLElement): boolean;
750
582
  static destroyAll(): void;
751
583
  }
752
584
 
753
- 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 };