@targoninc/jess-components 0.0.29 → 0.0.31
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.js +16 -10
- package/dist/src/Components.d.ts +3 -3
- package/dist/src/Debounce.d.ts +1 -0
- package/dist/src/Types.d.ts +6 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -746,6 +746,18 @@ var InputType;
|
|
|
746
746
|
InputType2["week"] = "week";
|
|
747
747
|
})(InputType ||= {});
|
|
748
748
|
|
|
749
|
+
// src/src/Debounce.ts
|
|
750
|
+
var debounceMap = {};
|
|
751
|
+
function debounce(identifier, func, delay = 500) {
|
|
752
|
+
if (debounceMap[identifier]) {
|
|
753
|
+
clearTimeout(debounceMap[identifier]);
|
|
754
|
+
}
|
|
755
|
+
debounceMap[identifier] = setTimeout(() => {
|
|
756
|
+
func();
|
|
757
|
+
delete debounceMap[identifier];
|
|
758
|
+
}, delay);
|
|
759
|
+
}
|
|
760
|
+
|
|
749
761
|
// src/src/Components.ts
|
|
750
762
|
function getDisabledClass(config) {
|
|
751
763
|
let disabledClass;
|
|
@@ -772,19 +784,13 @@ function input(config) {
|
|
|
772
784
|
const toggleState = signal(false);
|
|
773
785
|
const configTypeSignal = config.type.constructor === Signal ? config.type : signal(config.type);
|
|
774
786
|
const actualType = compute((t) => t ? InputType.text : configTypeSignal.value, toggleState);
|
|
787
|
+
const inputId = v4_default();
|
|
775
788
|
let lastChange = 0;
|
|
776
|
-
let debounceTimeout;
|
|
777
789
|
function validate(newValue) {
|
|
778
790
|
errors.value = [];
|
|
779
791
|
if (config.debounce) {
|
|
780
792
|
if (Date.now() - lastChange < config.debounce) {
|
|
781
|
-
|
|
782
|
-
clearTimeout(debounceTimeout);
|
|
783
|
-
}
|
|
784
|
-
debounceTimeout = setTimeout(() => {
|
|
785
|
-
debounceTimeout = undefined;
|
|
786
|
-
validate(newValue);
|
|
787
|
-
}, config.debounce);
|
|
793
|
+
debounce(inputId, () => validate(newValue), config.debounce);
|
|
788
794
|
return;
|
|
789
795
|
}
|
|
790
796
|
}
|
|
@@ -813,7 +819,7 @@ function input(config) {
|
|
|
813
819
|
validate(e.target.value);
|
|
814
820
|
}
|
|
815
821
|
if (config.onchange) {
|
|
816
|
-
config.onchange(e.target.value);
|
|
822
|
+
debounce(inputId, () => config.onchange(e.target.value), config.debounce);
|
|
817
823
|
}
|
|
818
824
|
value.value = e.target.value;
|
|
819
825
|
}).onchange((e) => {
|
|
@@ -823,7 +829,7 @@ function input(config) {
|
|
|
823
829
|
validate(e.target.value);
|
|
824
830
|
}
|
|
825
831
|
if (config.onchange) {
|
|
826
|
-
config.onchange(e.target.value);
|
|
832
|
+
debounce(inputId, () => config.onchange(e.target.value), config.debounce);
|
|
827
833
|
}
|
|
828
834
|
value.value = e.target.value;
|
|
829
835
|
}).onkeydown(config.onkeydown ?? (() => {})).name(config.name).build(), when(isPassword, eyeButton(toggleState, () => {
|
package/dist/src/Components.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ export declare function container(config: ContainerConfig): AnyElement;
|
|
|
11
11
|
export declare function text(config: TextConfig): AnyElement;
|
|
12
12
|
export declare function heading(config: HeadingConfig): AnyElement;
|
|
13
13
|
export declare function icon(config: IconConfig): Signal<AnyElement>;
|
|
14
|
-
export declare function select(config: SelectConfig): AnyElement;
|
|
15
|
-
export declare function searchableSelect(config: SearchableSelectConfig): AnyElement;
|
|
16
|
-
export declare function searchSelectOption(config: SelectOptionConfig): any;
|
|
14
|
+
export declare function select<T = any>(config: SelectConfig<T>): AnyElement;
|
|
15
|
+
export declare function searchableSelect<T = any>(config: SearchableSelectConfig<T>): AnyElement;
|
|
16
|
+
export declare function searchSelectOption<T = any>(config: SelectOptionConfig<T>): any;
|
|
17
17
|
export declare function checkbox(config: BooleanConfig): AnyElement;
|
|
18
18
|
export declare function toggle(config: BooleanConfig): AnyElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function debounce(identifier: any, func: () => void, delay?: number): void;
|
package/dist/src/Types.d.ts
CHANGED
|
@@ -57,24 +57,24 @@ export interface IconConfig extends BaseComponentConfig {
|
|
|
57
57
|
isUrl?: TypeOrSignal<boolean>;
|
|
58
58
|
onclick?: Function;
|
|
59
59
|
}
|
|
60
|
-
export interface SelectOption extends BaseComponentConfig {
|
|
60
|
+
export interface SelectOption<T> extends BaseComponentConfig {
|
|
61
61
|
image?: string;
|
|
62
62
|
imageIsUrl?: boolean;
|
|
63
63
|
name: any;
|
|
64
|
-
id: any;
|
|
64
|
+
id: any | T;
|
|
65
65
|
}
|
|
66
|
-
export interface SelectOptionConfig extends BaseComponentConfig {
|
|
67
|
-
option: SelectOption
|
|
66
|
+
export interface SelectOptionConfig<T> extends BaseComponentConfig {
|
|
67
|
+
option: SelectOption<T>;
|
|
68
68
|
value: Signal<any>;
|
|
69
69
|
search: Signal<string>;
|
|
70
70
|
optionsVisible: Signal<boolean>;
|
|
71
71
|
selectedId: Signal<any>;
|
|
72
72
|
}
|
|
73
73
|
export interface SearchableSelectConfig<T = string> extends ChangeableConfig<T> {
|
|
74
|
-
options: Signal<SelectOption[]>;
|
|
74
|
+
options: Signal<SelectOption<T>[]>;
|
|
75
75
|
value: Signal<T>;
|
|
76
76
|
}
|
|
77
|
-
export type SelectConfig = SearchableSelectConfig
|
|
77
|
+
export type SelectConfig<T> = SearchableSelectConfig<T>;
|
|
78
78
|
export interface HeadingConfig extends BaseComponentConfig {
|
|
79
79
|
level?: IntRange<1, 6>;
|
|
80
80
|
text: StringOrSignal;
|