timepicker-ui 4.0.2 → 4.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "timepicker-ui",
3
- "version": "4.0.2",
3
+ "version": "4.1.0",
4
4
  "description": "timepicker-ui is a customizable time picker library built with TypeScript, inspired by Google's Material Design. Lightweight, themeable, and easy to integrate.",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -17,9 +17,25 @@
17
17
  ],
18
18
  "exports": {
19
19
  ".": {
20
+ "types": "./dist/index.d.ts",
20
21
  "import": "./dist/index.js",
21
22
  "require": "./dist/index.cjs"
22
23
  },
24
+ "./plugins/range": {
25
+ "types": "./dist/plugins/range.d.ts",
26
+ "import": "./dist/plugins/range.js",
27
+ "require": "./dist/plugins/range.cjs"
28
+ },
29
+ "./plugins/timezone": {
30
+ "types": "./dist/plugins/timezone.d.ts",
31
+ "import": "./dist/plugins/timezone.js",
32
+ "require": "./dist/plugins/timezone.cjs"
33
+ },
34
+ "./plugins/*": {
35
+ "types": "./dist/plugins/*.d.ts",
36
+ "import": "./dist/plugins/*.js",
37
+ "require": "./dist/plugins/*.cjs"
38
+ },
23
39
  "./main.css": "./dist/css/main.css",
24
40
  "./index.css": "./dist/css/index.css",
25
41
  "./theme-crane.css": "./dist/css/themes/theme-crane.css",
@@ -32,18 +48,31 @@
32
48
  "./theme-cyberpunk.css": "./dist/css/themes/theme-cyberpunk.css"
33
49
  },
34
50
  "keywords": [
51
+ "angular",
52
+ "css",
53
+ "customizable",
54
+ "design",
55
+ "javascript",
56
+ "lightweight",
35
57
  "material-design",
36
58
  "material",
37
- "design",
59
+ "react",
60
+ "svelte",
61
+ "themeable",
62
+ "time-picker",
38
63
  "timepicker",
64
+ "typescript",
39
65
  "ui",
40
- "css",
41
- "javascript",
42
66
  "vanillajs",
43
- "typescript"
67
+ "vue"
44
68
  ],
45
69
  "author": "Piotr Glejzer (@pglejzer)",
46
70
  "license": "MIT",
71
+ "sideEffects": [
72
+ "./dist/plugins/*.js",
73
+ "./dist/plugins/*.cjs",
74
+ "./dist/css/**/*.css"
75
+ ],
47
76
  "bugs": {
48
77
  "url": "https://github.com/pglejzer/timepicker-ui/issues"
49
78
  },
package/dist/index.d.cts DELETED
@@ -1,585 +0,0 @@
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;
8
- };
9
-
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;
65
-
66
- type OptionTypes = {
67
- /** AM label text @default "AM" */
68
- amLabel?: string;
69
- /** Enable animations @default true */
70
- animation?: boolean;
71
- /**
72
- * @description Set default selector to append timepicker inside it. Timepicker default append to `body`
73
- * @default ""
74
- */
75
- appendModalSelector?: string;
76
- /** Enable backdrop @default true */
77
- backdrop?: boolean;
78
- /** Cancel button text @default "Cancel" */
79
- cancelLabel?: string;
80
- /** Edit hour/minutes in web mode @default false */
81
- editable?: boolean;
82
- /** Enable scroll when open @default false */
83
- enableScrollbar?: boolean;
84
- /** Icon to switch desktop/mobile @default false */
85
- enableSwitchIcon?: boolean;
86
- /** Mobile time label @default "Enter Time" */
87
- mobileTimeLabel?: string;
88
- /** Focus input after close @default false */
89
- focusInputAfterCloseModal?: boolean;
90
- /** Mobile hour label @default "Hour" */
91
- hourMobileLabel?: string;
92
- /** Desktop icon template */
93
- iconTemplate?: string;
94
- /** Mobile icon template */
95
- iconTemplateMobile?: string;
96
- /**
97
- * @description Set increment hour by `1`, `2`, `3` hour
98
- * @default 1
99
- */
100
- incrementHours?: number;
101
- /**
102
- * @description Set increment minutes by `1`, `5`, `10`, `15` minutes
103
- * @default 1
104
- */
105
- incrementMinutes?: number;
106
- /**
107
- * @description set custom text to minute label on mobile version
108
- * @default "Minute"
109
- */
110
- minuteMobileLabel?: string;
111
- /**
112
- * @description Turn on/off mobile version
113
- * @default false
114
- */
115
- mobile?: boolean;
116
- /**
117
- * @description Set custom text to ok label
118
- * @default "OK"
119
- */
120
- okLabel?: string;
121
- /** PM label @default "PM" */
122
- pmLabel?: string;
123
- /** Time label (desktop) @default "Select time" */
124
- timeLabel?: string;
125
- /** Auto-switch to minutes @default true */
126
- autoSwitchToMinutes?: boolean;
127
- /** Theme @default "basic" */
128
- theme?:
129
- | 'basic'
130
- | 'crane'
131
- | 'crane-straight'
132
- | 'm2'
133
- | 'm3-green'
134
- | 'dark'
135
- | 'glassmorphic'
136
- | 'pastel'
137
- | 'ai'
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
-
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
255
- * @default false
256
- */
257
- autoSwitchToMinutes?: boolean;
258
-
259
- /**
260
- * @description Disable specific hours/minutes or time intervals
261
- * @example
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
- * }
267
- */
268
- disabledTime?: {
269
- minutes?: Array<string | number>;
270
- hours?: Array<string | number>;
271
- interval?: string | string[];
272
- };
273
-
274
- /**
275
- * @description Set current time to the input and timepicker
276
- * @example
277
- * currentTime: {
278
- * time: new Date(),
279
- * updateInput: true,
280
- * locales: "en-US",
281
- * preventClockType: false
282
- * }
283
- * @example currentTime: true
284
- */
285
- currentTime?:
286
- | {
287
- time?: Date;
288
- updateInput?: boolean;
289
- locales?: string | string[];
290
- preventClockType?: boolean;
291
- }
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';
314
-
315
- /**
316
- * @description Enable/disable animations
317
- * @default true
318
- */
319
- animation?: boolean;
320
-
321
- /**
322
- * @description Show backdrop when timepicker is open
323
- * @default true
324
- */
325
- backdrop?: boolean;
326
-
327
- /**
328
- * @description Force mobile mode
329
- * @default false
330
- */
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
-
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
377
- * @example
378
- * inline: {
379
- * enabled: true,
380
- * containerId: "timepicker-container",
381
- * showButtons: false,
382
- * autoUpdate: true
383
- * }
384
- */
385
- inline?: {
386
- enabled: boolean;
387
- containerId: string;
388
- showButtons?: boolean;
389
- autoUpdate?: boolean;
390
- };
391
- }
392
-
393
- /**
394
- * Text labels configuration
395
- */
396
- interface LabelsOptions {
397
- /**
398
- * @description "AM" label text
399
- * @default "AM"
400
- */
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 {
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;
534
- }
535
-
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?: {
548
- keepInputValue?: boolean;
549
- callback?: Callback;
550
- } | Callback): void;
551
- update(value: {
552
- options: TimepickerOptions;
553
- create?: boolean;
554
- }, callback?: Callback): void;
555
- getValue(): {
556
- hour: string;
557
- minutes: string;
558
- type?: string;
559
- time: string;
560
- degreesHours: number | null;
561
- degreesMinutes: number | null;
562
- };
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;
579
- static getById(id: string): TimepickerUI | undefined;
580
- static getAllInstances(): TimepickerUI[];
581
- static isAvailable(selectorOrElement: string | HTMLElement): boolean;
582
- static destroyAll(): void;
583
- }
584
-
585
- export { type BehaviorOptions, type CallbacksOptions, type CancelEventData, type ClockOptions, type ConfirmEventData, type ErrorEventData, EventEmitter, type HideEventData, type LabelsOptions, type OpenEventData, type OptionTypes, type SelectAMEventData, type SelectHourEventData, type SelectMinuteEventData, type SelectPMEventData, type ShowEventData, type SwitchViewEventData, type TimepickerOptions, TimepickerUI, type UIOptions, type UpdateEventData, TimepickerUI as default };