timepicker-ui 4.1.6 → 4.2.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/README.md +100 -15
- package/dist/css/index.css +1 -1
- package/dist/css/main.css +1 -1
- package/dist/css/themes/theme-ai.css +1 -1
- package/dist/css/themes/theme-crane-straight.css +1 -1
- package/dist/css/themes/theme-crane.css +1 -1
- package/dist/css/themes/theme-cyberpunk.css +1 -1
- package/dist/css/themes/theme-dark.css +1 -1
- package/dist/css/themes/theme-glassmorphic.css +1 -1
- package/dist/css/themes/theme-m2.css +1 -1
- package/dist/css/themes/theme-m3-green.css +1 -1
- package/dist/css/themes/theme-pastel.css +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.d.ts +124 -10
- package/dist/index.js +6 -6
- package/dist/index.umd.js +1 -1
- package/dist/plugins/range.cjs +1 -1
- package/dist/plugins/range.js +1 -1
- package/dist/plugins/range.umd.js +1 -1
- package/dist/plugins/timezone.cjs +1 -1
- package/dist/plugins/timezone.js +1 -1
- package/dist/plugins/timezone.umd.js +1 -1
- package/dist/plugins/wheel.cjs +1 -0
- package/dist/plugins/wheel.d.ts +21 -0
- package/dist/plugins/wheel.js +1 -0
- package/dist/plugins/wheel.umd.js +1 -0
- package/package.json +6 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,13 @@ type ConfirmEventData = {
|
|
|
15
15
|
hour?: string;
|
|
16
16
|
minutes?: string;
|
|
17
17
|
type?: string;
|
|
18
|
+
/** When true, this confirm was triggered by commitOnScroll (auto-commit) */
|
|
19
|
+
autoCommit?: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** Payload when user clears time */
|
|
23
|
+
type ClearEventData = {
|
|
24
|
+
previousValue: string | null;
|
|
18
25
|
};
|
|
19
26
|
|
|
20
27
|
/** Payload when modal shows */
|
|
@@ -87,6 +94,18 @@ type RangeGetDisabledTimeEventData = Record<string, never>;
|
|
|
87
94
|
|
|
88
95
|
type RangeUpdateDisabledEventData = Record<string, never>;
|
|
89
96
|
|
|
97
|
+
/** Payload when wheel scroll starts on a column */
|
|
98
|
+
type WheelScrollStartEventData = {
|
|
99
|
+
column: 'hours' | 'minutes' | 'ampm';
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/** Payload when wheel scroll ends and snaps to a value */
|
|
103
|
+
type WheelScrollEndEventData = {
|
|
104
|
+
column: 'hours' | 'minutes' | 'ampm';
|
|
105
|
+
value: string;
|
|
106
|
+
previousValue: string | null;
|
|
107
|
+
};
|
|
108
|
+
|
|
90
109
|
/** Payload when validation error occurs */
|
|
91
110
|
type ErrorEventData = {
|
|
92
111
|
error: string;
|
|
@@ -102,6 +121,8 @@ type ErrorEventData = {
|
|
|
102
121
|
type TimepickerEventCallback<T = unknown> = (eventData: T) => void;
|
|
103
122
|
|
|
104
123
|
type OptionTypes = {
|
|
124
|
+
/** Picker mode: clock, wheel, or compact-wheel @default "clock" */
|
|
125
|
+
mode?: 'clock' | 'wheel' | 'compact-wheel';
|
|
105
126
|
/** AM label text @default "AM" */
|
|
106
127
|
amLabel?: string;
|
|
107
128
|
/** Enable animations @default true */
|
|
@@ -235,6 +256,7 @@ interface TimepickerEventMap {
|
|
|
235
256
|
open: OpenEventData;
|
|
236
257
|
cancel: CancelEventData;
|
|
237
258
|
confirm: ConfirmEventData;
|
|
259
|
+
clear: ClearEventData;
|
|
238
260
|
show: ShowEventData;
|
|
239
261
|
hide: HideEventData;
|
|
240
262
|
update: UpdateEventData;
|
|
@@ -250,6 +272,8 @@ interface TimepickerEventMap {
|
|
|
250
272
|
'range:minute:commit': RangeMinuteCommitEventData;
|
|
251
273
|
'range:get-disabled-time': RangeGetDisabledTimeEventData;
|
|
252
274
|
'range:update-disabled': RangeUpdateDisabledEventData;
|
|
275
|
+
'wheel:scroll:start': WheelScrollStartEventData;
|
|
276
|
+
'wheel:scroll:end': WheelScrollEndEventData;
|
|
253
277
|
'animation:clock': Record<string, never>;
|
|
254
278
|
'animation:start': Record<string, never>;
|
|
255
279
|
'animation:end': Record<string, never>;
|
|
@@ -350,6 +374,12 @@ interface ClockOptions {
|
|
|
350
374
|
* UI appearance and behavior configuration
|
|
351
375
|
*/
|
|
352
376
|
interface UIOptions {
|
|
377
|
+
/**
|
|
378
|
+
* @description Picker mode: analog clock face, scroll wheel spinner, or compact wheel (no header)
|
|
379
|
+
* @default "clock"
|
|
380
|
+
*/
|
|
381
|
+
mode?: 'clock' | 'wheel' | 'compact-wheel';
|
|
382
|
+
|
|
353
383
|
/**
|
|
354
384
|
* @description Theme for the timepicker
|
|
355
385
|
* @default "basic"
|
|
@@ -408,6 +438,12 @@ interface UIOptions {
|
|
|
408
438
|
*/
|
|
409
439
|
cssClass?: string;
|
|
410
440
|
|
|
441
|
+
/**
|
|
442
|
+
* @description Show clear button to reset time selection
|
|
443
|
+
* @default false
|
|
444
|
+
*/
|
|
445
|
+
clearButton?: boolean;
|
|
446
|
+
|
|
411
447
|
/**
|
|
412
448
|
* @description Selector where to append modal (default: body)
|
|
413
449
|
* @default ""
|
|
@@ -495,6 +531,12 @@ interface LabelsOptions {
|
|
|
495
531
|
* @default "Minute"
|
|
496
532
|
*/
|
|
497
533
|
mobileMinute?: string;
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* @description "Clear" button text
|
|
537
|
+
* @default "Clear"
|
|
538
|
+
*/
|
|
539
|
+
clear?: string;
|
|
498
540
|
}
|
|
499
541
|
|
|
500
542
|
/**
|
|
@@ -558,6 +600,58 @@ interface TimezoneOptions {
|
|
|
558
600
|
label?: string;
|
|
559
601
|
}
|
|
560
602
|
|
|
603
|
+
/**
|
|
604
|
+
* Wheel / compact-wheel mode configuration
|
|
605
|
+
* @example
|
|
606
|
+
* wheel: {
|
|
607
|
+
* placement: 'auto',
|
|
608
|
+
* hideFooter: true,
|
|
609
|
+
* commitOnScroll: true
|
|
610
|
+
* }
|
|
611
|
+
*/
|
|
612
|
+
interface WheelOptions {
|
|
613
|
+
/**
|
|
614
|
+
* @description Popover placement relative to input in compact-wheel mode.
|
|
615
|
+
* 'auto' opens below if space allows, otherwise above.
|
|
616
|
+
* Defaults to 'auto' in compact-wheel mode.
|
|
617
|
+
* Can be overridden to 'top' or 'bottom' for fixed positioning.
|
|
618
|
+
* @default 'auto' (compact-wheel) | undefined (wheel)
|
|
619
|
+
*/
|
|
620
|
+
placement?: 'auto' | 'top' | 'bottom';
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* @description When true, the footer (OK/Cancel/Clear buttons + switch icon)
|
|
624
|
+
* is not rendered in the DOM at all. Only works in compact-wheel mode.
|
|
625
|
+
* Useful when commitOnScroll is enabled and buttons are unnecessary.
|
|
626
|
+
* @default false
|
|
627
|
+
*/
|
|
628
|
+
hideFooter?: boolean;
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* @description When enabled, the timepicker automatically commits the selected time
|
|
632
|
+
* at the end of wheel scrolling, updating the input value and emitting a change event
|
|
633
|
+
* without requiring the user to press OK. Only applies to wheel and compact-wheel modes.
|
|
634
|
+
* @default false
|
|
635
|
+
*/
|
|
636
|
+
commitOnScroll?: boolean;
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* @description When true, disabled hours/minutes are completely removed from the wheel list
|
|
640
|
+
* instead of being dimmed. Only applies to wheel and compact-wheel modes.
|
|
641
|
+
* Useful when many values are disabled (e.g., business hours only).
|
|
642
|
+
* @default false
|
|
643
|
+
*/
|
|
644
|
+
hideDisabled?: boolean;
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* @description When true, clicking outside the picker area does not close it.
|
|
648
|
+
* Only applies to wheel and compact-wheel modes (popover and modal).
|
|
649
|
+
* The user must explicitly press OK or Cancel to close the picker.
|
|
650
|
+
* @default false
|
|
651
|
+
*/
|
|
652
|
+
ignoreOutsideClick?: boolean;
|
|
653
|
+
}
|
|
654
|
+
|
|
561
655
|
/**
|
|
562
656
|
* Range mode configuration (opt-in)
|
|
563
657
|
*/
|
|
@@ -659,6 +753,22 @@ interface CallbacksOptions {
|
|
|
659
753
|
* @description Triggered on range validation (range mode only)
|
|
660
754
|
*/
|
|
661
755
|
onRangeValidation?: TimepickerEventCallback<RangeValidationEventData>;
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* @description Triggered when clear button is clicked
|
|
759
|
+
*/
|
|
760
|
+
onClear?: TimepickerEventCallback<ClearEventData>;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Clear button behavior configuration
|
|
765
|
+
*/
|
|
766
|
+
interface ClearBehaviorOptions {
|
|
767
|
+
/**
|
|
768
|
+
* @description Whether clicking clear also empties the input field value
|
|
769
|
+
* @default true
|
|
770
|
+
*/
|
|
771
|
+
clearInput?: boolean;
|
|
662
772
|
}
|
|
663
773
|
|
|
664
774
|
/**
|
|
@@ -672,6 +782,8 @@ interface TimepickerOptions {
|
|
|
672
782
|
callbacks?: CallbacksOptions;
|
|
673
783
|
timezone?: TimezoneOptions;
|
|
674
784
|
range?: RangeOptions;
|
|
785
|
+
wheel?: WheelOptions;
|
|
786
|
+
clearBehavior?: ClearBehaviorOptions;
|
|
675
787
|
}
|
|
676
788
|
|
|
677
789
|
type Callback = () => void;
|
|
@@ -736,6 +848,10 @@ declare class TimepickerUI {
|
|
|
736
848
|
* @param updateInput - If true, the input field will be updated with the new time value. Default is true.
|
|
737
849
|
*/
|
|
738
850
|
setValue(time: string, updateInput?: boolean): void;
|
|
851
|
+
private parseTimeString;
|
|
852
|
+
private applyParsedTime;
|
|
853
|
+
private syncPeriodIndicator;
|
|
854
|
+
private syncClockVisual;
|
|
739
855
|
/**
|
|
740
856
|
* Get the root element of the timepicker instance.
|
|
741
857
|
* @returns - The HTMLElement that serves as the root of the timepicker instance.
|
|
@@ -792,21 +908,21 @@ declare class TimepickerUI {
|
|
|
792
908
|
* @param handler - The function to handle the event.
|
|
793
909
|
* @returns - void
|
|
794
910
|
*/
|
|
795
|
-
on<K extends keyof TimepickerEventMap>(event: K, handler: (
|
|
911
|
+
on<K extends keyof TimepickerEventMap>(event: K, handler: () => void): void;
|
|
796
912
|
/**
|
|
797
913
|
* Subscribe to a timepicker event with a handler function that will be called only once.
|
|
798
914
|
* @param event - The name of the event to subscribe to.
|
|
799
915
|
* @param handler - The function to handle the event.
|
|
800
916
|
* @returns - void
|
|
801
917
|
*/
|
|
802
|
-
once<K extends keyof TimepickerEventMap>(event: K, handler: (
|
|
918
|
+
once<K extends keyof TimepickerEventMap>(event: K, handler: () => void): void;
|
|
803
919
|
/**
|
|
804
920
|
* Unsubscribe from a timepicker event. If a handler is provided, only that handler will be removed. If no handler is provided, all handlers for the event will be removed.
|
|
805
921
|
* @param event - The name of the event to unsubscribe from.
|
|
806
922
|
* @param handler - The function to handle the event.
|
|
807
923
|
* @returns - void
|
|
808
924
|
*/
|
|
809
|
-
off<K extends keyof TimepickerEventMap>(event: K, handler?: (
|
|
925
|
+
off<K extends keyof TimepickerEventMap>(event: K, handler?: () => void): void;
|
|
810
926
|
private resolveInputElement;
|
|
811
927
|
private createWrapperElement;
|
|
812
928
|
/**
|
|
@@ -851,6 +967,7 @@ interface CoreStateData {
|
|
|
851
967
|
} | null;
|
|
852
968
|
readonly cloned: Node | null;
|
|
853
969
|
readonly isModalRemove: boolean;
|
|
970
|
+
readonly isOpen: boolean;
|
|
854
971
|
readonly isInitialized: boolean;
|
|
855
972
|
readonly customId?: string;
|
|
856
973
|
readonly eventHandlersRegistered: boolean;
|
|
@@ -869,6 +986,7 @@ declare class CoreState {
|
|
|
869
986
|
get disabledTime(): CoreStateData['disabledTime'];
|
|
870
987
|
get cloned(): Node | null;
|
|
871
988
|
get isModalRemove(): boolean;
|
|
989
|
+
get isOpen(): boolean;
|
|
872
990
|
get isInitialized(): boolean;
|
|
873
991
|
get customId(): string | undefined;
|
|
874
992
|
get eventHandlersRegistered(): boolean;
|
|
@@ -881,6 +999,7 @@ declare class CoreState {
|
|
|
881
999
|
setDisabledTime(value: CoreStateData['disabledTime']): void;
|
|
882
1000
|
setCloned(value: Node | null): void;
|
|
883
1001
|
setIsModalRemove(value: boolean): void;
|
|
1002
|
+
setIsOpen(value: boolean): void;
|
|
884
1003
|
setIsInitialized(value: boolean): void;
|
|
885
1004
|
setEventHandlersRegistered(value: boolean): void;
|
|
886
1005
|
setIsDestroyed(value: boolean): void;
|
|
@@ -925,14 +1044,9 @@ interface Plugin {
|
|
|
925
1044
|
factory: PluginFactory;
|
|
926
1045
|
optionsExtender?: (options: Record<string, unknown>) => void;
|
|
927
1046
|
}
|
|
928
|
-
interface PluginInput {
|
|
929
|
-
name: string;
|
|
930
|
-
factory: (core: never, emitter: never) => PluginManager;
|
|
931
|
-
optionsExtender?: (options: Record<string, unknown>) => void;
|
|
932
|
-
}
|
|
933
1047
|
declare class PluginRegistryClass {
|
|
934
1048
|
private plugins;
|
|
935
|
-
register(plugin: Plugin
|
|
1049
|
+
register(plugin: Plugin): void;
|
|
936
1050
|
getAll(): Plugin[];
|
|
937
1051
|
has(name: string): boolean;
|
|
938
1052
|
get(name: string): Plugin | undefined;
|
|
@@ -940,4 +1054,4 @@ declare class PluginRegistryClass {
|
|
|
940
1054
|
declare const PluginRegistry: PluginRegistryClass;
|
|
941
1055
|
|
|
942
1056
|
export { CoreState, EventEmitter, PluginRegistry, TimepickerUI, TimepickerUI as default };
|
|
943
|
-
export type { BehaviorOptions, CallbacksOptions, CancelEventData, ClockOptions, ConfirmEventData, ErrorEventData, HideEventData, LabelsOptions, OpenEventData, OptionTypes, Plugin, PluginFactory, PluginManager, RangeConfirmEventData, RangeOptions, RangeSwitchEventData, RangeValidationEventData, SelectAMEventData, SelectHourEventData, SelectMinuteEventData, SelectPMEventData, ShowEventData, SwitchViewEventData, TimepickerEventMap, TimepickerOptions, TimezoneChangeEventData, TimezoneOptions, UIOptions, UpdateEventData };
|
|
1057
|
+
export type { BehaviorOptions, CallbacksOptions, CancelEventData, ClearBehaviorOptions, ClearEventData, ClockOptions, ConfirmEventData, ErrorEventData, HideEventData, LabelsOptions, OpenEventData, OptionTypes, Plugin, PluginFactory, PluginManager, RangeConfirmEventData, RangeOptions, RangeSwitchEventData, RangeValidationEventData, SelectAMEventData, SelectHourEventData, SelectMinuteEventData, SelectPMEventData, ShowEventData, SwitchViewEventData, TimepickerEventMap, TimepickerOptions, TimezoneChangeEventData, TimezoneOptions, UIOptions, UpdateEventData, WheelScrollEndEventData, WheelScrollStartEventData };
|