selective-ui 1.4.0 → 1.4.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/selective-ui.css +0 -6
- package/dist/selective-ui.css.map +1 -1
- package/dist/selective-ui.esm.js +252 -553
- package/dist/selective-ui.esm.js.map +1 -1
- package/dist/selective-ui.esm.min.js +2 -2
- package/dist/selective-ui.esm.min.js.br +0 -0
- package/dist/selective-ui.min.css +1 -1
- package/dist/selective-ui.min.css.br +0 -0
- package/dist/selective-ui.min.js +2 -2
- package/dist/selective-ui.min.js.br +0 -0
- package/dist/selective-ui.umd.js +254 -555
- package/dist/selective-ui.umd.js.map +1 -1
- package/package.json +12 -12
- package/src/ts/adapter/mixed-adapter.ts +147 -68
- package/src/ts/components/accessorybox.ts +14 -11
- package/src/ts/components/directive.ts +1 -1
- package/src/ts/components/option-handle.ts +12 -9
- package/src/ts/components/placeholder.ts +5 -5
- package/src/ts/components/popup/empty-state.ts +5 -5
- package/src/ts/components/popup/loading-state.ts +5 -5
- package/src/ts/components/popup/popup.ts +138 -76
- package/src/ts/components/searchbox.ts +17 -13
- package/src/ts/components/selectbox.ts +242 -81
- package/src/ts/core/base/adapter.ts +39 -14
- package/src/ts/core/base/fenwick.ts +3 -2
- package/src/ts/core/base/lifecycle.ts +14 -4
- package/src/ts/core/base/model.ts +17 -15
- package/src/ts/core/base/recyclerview.ts +7 -5
- package/src/ts/core/base/view.ts +10 -5
- package/src/ts/core/base/virtual-recyclerview.ts +89 -37
- package/src/ts/core/model-manager.ts +48 -21
- package/src/ts/core/search-controller.ts +174 -56
- package/src/ts/global.ts +5 -8
- package/src/ts/index.ts +2 -2
- package/src/ts/models/group-model.ts +33 -8
- package/src/ts/models/option-model.ts +60 -19
- package/src/ts/services/dataset-observer.ts +6 -3
- package/src/ts/services/ea-observer.ts +1 -1
- package/src/ts/services/effector.ts +22 -12
- package/src/ts/services/refresher.ts +7 -3
- package/src/ts/services/resize-observer.ts +24 -11
- package/src/ts/services/select-observer.ts +2 -2
- package/src/ts/types/components/popup.type.ts +18 -1
- package/src/ts/types/components/searchbox.type.ts +43 -30
- package/src/ts/types/components/state.box.type.ts +1 -1
- package/src/ts/types/core/base/adapter.type.ts +13 -5
- package/src/ts/types/core/base/lifecycle.type.ts +1 -2
- package/src/ts/types/core/base/model.type.ts +3 -3
- package/src/ts/types/core/base/recyclerview.type.ts +7 -5
- package/src/ts/types/core/base/view.type.ts +6 -6
- package/src/ts/types/core/base/virtual-recyclerview.type.ts +45 -46
- package/src/ts/types/core/search-controller.type.ts +18 -2
- package/src/ts/types/css.d.ts +1 -0
- package/src/ts/types/plugins/plugin.type.ts +2 -2
- package/src/ts/types/services/effector.type.ts +25 -25
- package/src/ts/types/services/resize-observer.type.ts +23 -12
- package/src/ts/types/utils/callback-scheduler.type.ts +2 -2
- package/src/ts/types/utils/ievents.type.ts +1 -1
- package/src/ts/types/utils/istorage.type.ts +62 -60
- package/src/ts/types/utils/libs.type.ts +19 -17
- package/src/ts/types/utils/selective.type.ts +6 -3
- package/src/ts/types/views/view.group.type.ts +9 -5
- package/src/ts/types/views/view.option.type.ts +39 -17
- package/src/ts/utils/callback-scheduler.ts +12 -7
- package/src/ts/utils/ievents.ts +12 -5
- package/src/ts/utils/istorage.ts +5 -3
- package/src/ts/utils/libs.ts +122 -43
- package/src/ts/utils/selective.ts +15 -8
- package/src/ts/views/group-view.ts +11 -9
- package/src/ts/views/option-view.ts +37 -18
|
@@ -6,13 +6,13 @@ import { SelectiveOptions } from "./selective.type";
|
|
|
6
6
|
* Each event can have multiple callbacks.
|
|
7
7
|
*/
|
|
8
8
|
export type StorageEvents = {
|
|
9
|
-
load?: Array<(...args: any[]) => void>;
|
|
10
|
-
beforeShow?: Array<(...args: any[]) => void>;
|
|
11
|
-
show?: Array<(...args: any[]) => void>;
|
|
12
|
-
beforeChange?: Array<(...args: any[]) => void>;
|
|
13
|
-
change?: Array<(...args: any[]) => void>;
|
|
14
|
-
beforeClose?: Array<(...args: any[]) => void>;
|
|
15
|
-
close?: Array<(...args: any[]) => void>;
|
|
9
|
+
load?: Array<(...args: any[]) => void>; // Triggered when data or component is loaded
|
|
10
|
+
beforeShow?: Array<(...args: any[]) => void>; // Triggered before the panel is shown
|
|
11
|
+
show?: Array<(...args: any[]) => void>; // Triggered when the panel is displayed
|
|
12
|
+
beforeChange?: Array<(...args: any[]) => void>; // Triggered before a value change occurs
|
|
13
|
+
change?: Array<(...args: any[]) => void>; // Triggered after a value change occurs
|
|
14
|
+
beforeClose?: Array<(...args: any[]) => void>; // Triggered before the panel is closed
|
|
15
|
+
close?: Array<(...args: any[]) => void>; // Triggered when the panel is closed
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -20,51 +20,51 @@ export type StorageEvents = {
|
|
|
20
20
|
* Includes UI settings, behavior flags, and AJAX configuration.
|
|
21
21
|
*/
|
|
22
22
|
export interface DefaultConfig {
|
|
23
|
-
accessoryVisible?: boolean;
|
|
24
|
-
virtualScroll?: boolean;
|
|
25
|
-
accessoryStyle?: string;
|
|
26
|
-
multiple?: boolean;
|
|
27
|
-
minWidth?: string;
|
|
28
|
-
width?: string;
|
|
29
|
-
offsetWidth?: number
|
|
30
|
-
minHeight?: string;
|
|
31
|
-
height?: string;
|
|
32
|
-
panelHeight?: string;
|
|
33
|
-
panelMinHeight?: string;
|
|
34
|
-
disabled?: boolean;
|
|
35
|
-
readonly?: boolean;
|
|
36
|
-
selectall?: boolean;
|
|
37
|
-
keepSelected?: boolean;
|
|
38
|
-
placeholder?: string;
|
|
39
|
-
altMask?: string;
|
|
40
|
-
autoclose?: boolean;
|
|
41
|
-
autoscroll?: boolean;
|
|
42
|
-
autofocus?: boolean;
|
|
43
|
-
searchable?: boolean;
|
|
44
|
-
loadingfield?: boolean;
|
|
45
|
-
preload?: boolean;
|
|
46
|
-
visible?: boolean;
|
|
47
|
-
skipError?: boolean;
|
|
48
|
-
customDelimiter?: string;
|
|
49
|
-
textLoading?: string;
|
|
50
|
-
textNoData?: string;
|
|
51
|
-
textNotFound?: string;
|
|
52
|
-
textSelectAll?: string;
|
|
53
|
-
textDeselectAll?: string;
|
|
54
|
-
textAccessoryDeselect?: string;
|
|
55
|
-
animationtime?: number;
|
|
56
|
-
delaysearchtime?: number;
|
|
57
|
-
allowHtml?: boolean;
|
|
58
|
-
maxSelected?: number;
|
|
59
|
-
labelHalign?: string;
|
|
60
|
-
labelValign?: string;
|
|
61
|
-
imageMode?: boolean;
|
|
62
|
-
imageWidth?: string;
|
|
63
|
-
imageHeight?: string;
|
|
64
|
-
imageBorderRadius?: string;
|
|
65
|
-
imagePosition?: string;
|
|
66
|
-
ajax?: AjaxConfig
|
|
67
|
-
on?: StorageEvents;
|
|
23
|
+
accessoryVisible?: boolean; // Whether to show the accessory panel initially
|
|
24
|
+
virtualScroll?: boolean; // Enable virtual scroll
|
|
25
|
+
accessoryStyle?: string; // CSS style for accessory elements
|
|
26
|
+
multiple?: boolean; // Enable multiple selection
|
|
27
|
+
minWidth?: string; // Minimum width of the component
|
|
28
|
+
width?: string; // Fixed width of the component
|
|
29
|
+
offsetWidth?: number; // Offset width for positioning
|
|
30
|
+
minHeight?: string; // Minimum height of the component
|
|
31
|
+
height?: string; // Fixed height of the component
|
|
32
|
+
panelHeight?: string; // Height of the dropdown panel
|
|
33
|
+
panelMinHeight?: string; // Minimum height of the dropdown panel
|
|
34
|
+
disabled?: boolean; // Disable the component
|
|
35
|
+
readonly?: boolean; // Make the component read-only
|
|
36
|
+
selectall?: boolean; // Enable "Select All" functionality
|
|
37
|
+
keepSelected?: boolean; // Keep selected items after refresh
|
|
38
|
+
placeholder?: string; // Placeholder text
|
|
39
|
+
altMask?: string; // Alternative mask for display
|
|
40
|
+
autoclose?: boolean; // Close panel automatically after selection
|
|
41
|
+
autoscroll?: boolean; // Auto-scroll to selected item
|
|
42
|
+
autofocus?: boolean; // Focus on input automatically
|
|
43
|
+
searchable?: boolean; // Enable search functionality
|
|
44
|
+
loadingfield?: boolean; // Show loading indicator in the field
|
|
45
|
+
preload?: boolean; // Preload data on initialization
|
|
46
|
+
visible?: boolean; // Control visibility of the component
|
|
47
|
+
skipError?: boolean; // Skip error handling
|
|
48
|
+
customDelimiter?: string; // Custom delimiter for multiple values
|
|
49
|
+
textLoading?: string; // Text shown during loading
|
|
50
|
+
textNoData?: string; // Text shown when no data is available
|
|
51
|
+
textNotFound?: string; // Text shown when no search results are found
|
|
52
|
+
textSelectAll?: string; // Label for "Select All"
|
|
53
|
+
textDeselectAll?: string; // Label for "Deselect All"
|
|
54
|
+
textAccessoryDeselect?: string; // Label for accessory deselect button
|
|
55
|
+
animationtime?: number; // Animation duration in milliseconds
|
|
56
|
+
delaysearchtime?: number; // Delay before triggering search (ms)
|
|
57
|
+
allowHtml?: boolean; // Allow HTML in option labels
|
|
58
|
+
maxSelected?: number; // Maximum number of selections allowed
|
|
59
|
+
labelHalign?: string; // Horizontal alignment for labels
|
|
60
|
+
labelValign?: string; // Vertical alignment for labels
|
|
61
|
+
imageMode?: boolean; // Enable image display in options
|
|
62
|
+
imageWidth?: string; // Width for option images
|
|
63
|
+
imageHeight?: string; // Height for option images
|
|
64
|
+
imageBorderRadius?: string; // Border radius for option images
|
|
65
|
+
imagePosition?: string; // Position of images relative to text
|
|
66
|
+
ajax?: AjaxConfig; // AJAX configuration for dynamic data loading
|
|
67
|
+
on?: StorageEvents; // Event handlers for component lifecycle
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/**
|
|
@@ -72,13 +72,15 @@ export interface DefaultConfig {
|
|
|
72
72
|
* Includes options, container reference, and lifecycle actions.
|
|
73
73
|
*/
|
|
74
74
|
export type BinderMap<
|
|
75
|
-
TContainer extends any = any,
|
|
76
|
-
TAction extends Record<string, any> = Record<string, any>,
|
|
77
|
-
TSelf extends { deInit?: () => void } & Record<string, any> = {
|
|
75
|
+
TContainer extends any = any,
|
|
76
|
+
TAction extends Record<string, any> = Record<string, any>,
|
|
77
|
+
TSelf extends { deInit?: () => void } & Record<string, any> = {
|
|
78
|
+
deInit?: () => void;
|
|
79
|
+
} & Record<string, any>,
|
|
78
80
|
> = {
|
|
79
|
-
options: SelectiveOptions;
|
|
80
|
-
container?: TContainer;
|
|
81
|
-
action?: TAction;
|
|
81
|
+
options: SelectiveOptions; // Component options
|
|
82
|
+
container?: TContainer; // Reference to the container element
|
|
83
|
+
action?: TAction; // Action handlers or methods
|
|
82
84
|
self?: TSelf; // Self-reference with optional cleanup
|
|
83
85
|
};
|
|
84
86
|
|
|
@@ -87,5 +89,5 @@ export type BinderMap<
|
|
|
87
89
|
*/
|
|
88
90
|
export type PropertiesType = {
|
|
89
91
|
type: "variable" | "get-set" | "func"; // Property type (variable, getter/setter, or function)
|
|
90
|
-
name: string;
|
|
91
|
-
};
|
|
92
|
+
name: string; // Property name
|
|
93
|
+
};
|
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
* Includes attributes, styles, events, and accessibility properties.
|
|
4
4
|
*/
|
|
5
5
|
export type NodeSpec = {
|
|
6
|
-
node: string;
|
|
7
|
-
classList?: string | string[];
|
|
8
|
-
style?: Partial<CSSStyleDeclaration>;
|
|
9
|
-
dataset?: Record<string, string>;
|
|
10
|
-
role?: string;
|
|
11
|
-
ariaLive?: string;
|
|
12
|
-
ariaLabelledby?: string;
|
|
13
|
-
ariaControls?: string;
|
|
14
|
-
ariaHaspopup?: string;
|
|
15
|
-
ariaMultiselectable?: string;
|
|
16
|
-
ariaAutocomplete?: string;
|
|
17
|
-
event?: Record<string, EventListener>;
|
|
18
|
-
[key: string]: unknown;
|
|
6
|
+
node: string; // Tag name of the node (e.g., "div", "span")
|
|
7
|
+
classList?: string | string[]; // CSS classes to apply
|
|
8
|
+
style?: Partial<CSSStyleDeclaration>; // Inline styles for the node
|
|
9
|
+
dataset?: Record<string, string>; // Data attributes (e.g., data-* values)
|
|
10
|
+
role?: string; // ARIA role for accessibility
|
|
11
|
+
ariaLive?: string; // ARIA live region setting
|
|
12
|
+
ariaLabelledby?: string; // ARIA labelledby reference
|
|
13
|
+
ariaControls?: string; // ARIA controls reference
|
|
14
|
+
ariaHaspopup?: string; // ARIA haspopup attribute
|
|
15
|
+
ariaMultiselectable?: string; // ARIA multiselectable attribute
|
|
16
|
+
ariaAutocomplete?: string; // ARIA autocomplete attribute
|
|
17
|
+
event?: Record<string, EventListener>; // Event listeners mapped by event name
|
|
18
|
+
[key: string]: unknown; // Allow additional custom properties
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -24,7 +24,9 @@ export type NodeSpec = {
|
|
|
24
24
|
*
|
|
25
25
|
* @template TTags - A map of tag names to their corresponding HTMLElement instances.
|
|
26
26
|
*/
|
|
27
|
-
export type MountViewResult<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
export type MountViewResult<
|
|
28
|
+
TTags extends Record<string, HTMLElement> = Record<string, HTMLElement>,
|
|
29
|
+
> = {
|
|
30
|
+
view?: HTMLElement; // Root element of the mounted view
|
|
31
|
+
tags: TTags & { id: string }; // Tag map with an additional unique ID
|
|
32
|
+
};
|
|
@@ -7,9 +7,12 @@ import type { SelectivePlugin } from "../plugins/plugin.type";
|
|
|
7
7
|
* Extends DefaultConfig with additional internal identifiers.
|
|
8
8
|
*/
|
|
9
9
|
export type SelectiveOptions = DefaultConfig & {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/** Unique Selective Element ID */
|
|
11
|
+
SEID?: string;
|
|
12
|
+
/** ID for the list container */
|
|
13
|
+
SEID_LIST?: string;
|
|
14
|
+
/** ID for the holder element */
|
|
15
|
+
SEID_HOLDER?: string;
|
|
13
16
|
};
|
|
14
17
|
|
|
15
18
|
/**
|
|
@@ -5,9 +5,12 @@ import { MountViewResult } from "../utils/libs.type";
|
|
|
5
5
|
* These tags correspond to key sections of the group UI.
|
|
6
6
|
*/
|
|
7
7
|
export type GroupViewTags = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
/** Root container for the group view */
|
|
9
|
+
GroupView: HTMLDivElement;
|
|
10
|
+
/** Header section displaying the group title */
|
|
11
|
+
GroupHeader: HTMLDivElement;
|
|
12
|
+
/** Container for the group's items */
|
|
13
|
+
GroupItems: HTMLDivElement;
|
|
11
14
|
};
|
|
12
15
|
|
|
13
16
|
/**
|
|
@@ -15,5 +18,6 @@ export type GroupViewTags = {
|
|
|
15
18
|
* Extends MountViewResult with a guaranteed root element (`view`).
|
|
16
19
|
*/
|
|
17
20
|
export type GroupViewResult = MountViewResult<GroupViewTags> & {
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
/** The root element of the mounted group view */
|
|
22
|
+
view: Element;
|
|
23
|
+
};
|
|
@@ -5,11 +5,16 @@ import { MountViewResult } from "../utils/libs.type";
|
|
|
5
5
|
* These tags correspond to key elements of the option UI.
|
|
6
6
|
*/
|
|
7
7
|
export type OptionViewTags = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
/** Root container for the option view */
|
|
9
|
+
OptionView: HTMLDivElement;
|
|
10
|
+
/** Input element (checkbox or radio) */
|
|
11
|
+
OptionInput: HTMLInputElement;
|
|
12
|
+
/** Label element for the option */
|
|
13
|
+
OptionLabel: HTMLLabelElement;
|
|
14
|
+
/** Container for label text content */
|
|
15
|
+
LabelContent: HTMLDivElement;
|
|
16
|
+
/** Image element for options with images */
|
|
17
|
+
OptionImage: HTMLImageElement;
|
|
13
18
|
};
|
|
14
19
|
|
|
15
20
|
/**
|
|
@@ -17,7 +22,8 @@ export type OptionViewTags = {
|
|
|
17
22
|
* Extends MountViewResult with a guaranteed root element (`view`).
|
|
18
23
|
*/
|
|
19
24
|
export type OptionViewResult = MountViewResult<OptionViewTags> & {
|
|
20
|
-
|
|
25
|
+
/** The root element of the mounted option view */
|
|
26
|
+
view: Element;
|
|
21
27
|
};
|
|
22
28
|
|
|
23
29
|
/**
|
|
@@ -39,20 +45,36 @@ export type LabelHalign = "left" | "center" | "right";
|
|
|
39
45
|
* Configuration options for rendering an option.
|
|
40
46
|
*/
|
|
41
47
|
export type OptionConfig = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
/** Indicates if multiple selection is allowed */
|
|
49
|
+
isMultiple: boolean;
|
|
50
|
+
/** Indicates if the option includes an image */
|
|
51
|
+
hasImage: boolean;
|
|
52
|
+
/** Position of the image relative to the label */
|
|
53
|
+
imagePosition: ImagePosition;
|
|
54
|
+
/** Width of the image */
|
|
55
|
+
imageWidth: string;
|
|
56
|
+
/** Height of the image */
|
|
57
|
+
imageHeight: string;
|
|
58
|
+
/** Border radius for the image */
|
|
59
|
+
imageBorderRadius: string;
|
|
60
|
+
/** Vertical alignment of the label */
|
|
61
|
+
labelValign: LabelValign;
|
|
62
|
+
/** Horizontal alignment of the label */
|
|
63
|
+
labelHalign: LabelHalign;
|
|
50
64
|
};
|
|
51
65
|
|
|
52
66
|
/**
|
|
53
67
|
* Partial configuration patch for updating specific option properties.
|
|
54
68
|
* Includes only image and label alignment-related properties.
|
|
55
69
|
*/
|
|
56
|
-
export type OptionConfigPatch = Partial<
|
|
57
|
-
|
|
58
|
-
|
|
70
|
+
export type OptionConfigPatch = Partial<
|
|
71
|
+
Pick<
|
|
72
|
+
OptionConfig,
|
|
73
|
+
| "imageWidth"
|
|
74
|
+
| "imageHeight"
|
|
75
|
+
| "imageBorderRadius"
|
|
76
|
+
| "imagePosition"
|
|
77
|
+
| "labelValign"
|
|
78
|
+
| "labelHalign"
|
|
79
|
+
>
|
|
80
|
+
>;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
StoredEntry,
|
|
3
|
+
TimerKey,
|
|
4
|
+
TimerOptions,
|
|
5
|
+
} from "../types/utils/callback-scheduler.type";
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* CallbackScheduler
|
|
@@ -82,14 +86,14 @@ export class CallbackScheduler {
|
|
|
82
86
|
*
|
|
83
87
|
* @public
|
|
84
88
|
* @param {TimerKey} key - Group identifier for callbacks.
|
|
85
|
-
* @param {(payload
|
|
89
|
+
* @param {(payload?: any[]) => void} callback - Function to execute after debounce timeout.
|
|
86
90
|
* @param {TimerOptions} [options={}] - Scheduling options (`debounce`, `once`).
|
|
87
91
|
* @returns {void}
|
|
88
92
|
*/
|
|
89
93
|
public on(
|
|
90
94
|
key: TimerKey,
|
|
91
|
-
callback: (payload
|
|
92
|
-
options: TimerOptions = {}
|
|
95
|
+
callback: (payload?: any[]) => void,
|
|
96
|
+
options: TimerOptions = {},
|
|
93
97
|
): void {
|
|
94
98
|
const timeout = options.debounce ?? 50;
|
|
95
99
|
const once = options.once ?? false;
|
|
@@ -176,13 +180,14 @@ export class CallbackScheduler {
|
|
|
176
180
|
const timer = setTimeout(async () => {
|
|
177
181
|
try {
|
|
178
182
|
const resp = entry.callback(
|
|
179
|
-
params.length > 0 ? params : null
|
|
183
|
+
params.length > 0 ? params : null,
|
|
180
184
|
) as any;
|
|
181
185
|
|
|
182
186
|
if (resp instanceof Promise) {
|
|
183
187
|
await resp;
|
|
184
188
|
}
|
|
185
|
-
} catch {
|
|
189
|
+
} catch {
|
|
190
|
+
} finally {
|
|
186
191
|
if (entry.once) {
|
|
187
192
|
executes[i] = undefined;
|
|
188
193
|
|
|
@@ -230,4 +235,4 @@ export class CallbackScheduler {
|
|
|
230
235
|
this.off(k);
|
|
231
236
|
}
|
|
232
237
|
}
|
|
233
|
-
}
|
|
238
|
+
}
|
package/src/ts/utils/ievents.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
IEventCallback,
|
|
3
|
+
IEventHandler,
|
|
4
|
+
IEventToken,
|
|
5
|
+
} from "../types/utils/ievents.type";
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* iEvents
|
|
@@ -58,7 +62,10 @@ export class iEvents {
|
|
|
58
62
|
* - `token`: immutable view of the dispatch state.
|
|
59
63
|
* - `callback`: controller passed into handlers to modify dispatch flow.
|
|
60
64
|
*/
|
|
61
|
-
public static buildEventToken(): {
|
|
65
|
+
public static buildEventToken(): {
|
|
66
|
+
token: IEventToken;
|
|
67
|
+
callback: IEventCallback;
|
|
68
|
+
} {
|
|
62
69
|
const privToken = { isContinue: true, isCancel: false };
|
|
63
70
|
|
|
64
71
|
const token: IEventToken = {
|
|
@@ -104,7 +111,7 @@ export class iEvents {
|
|
|
104
111
|
* @returns The {@link IEventToken} describing the final dispatch state.
|
|
105
112
|
*/
|
|
106
113
|
public static callEvent<TParams extends unknown[]>(
|
|
107
|
-
params
|
|
114
|
+
params?: TParams,
|
|
108
115
|
...handles: Array<IEventHandler<TParams> | unknown>
|
|
109
116
|
): IEventToken {
|
|
110
117
|
const { token, callback } = this.buildEventToken();
|
|
@@ -139,7 +146,7 @@ export class iEvents {
|
|
|
139
146
|
public static trigger(
|
|
140
147
|
element: HTMLElement | Window | Document,
|
|
141
148
|
eventType: string,
|
|
142
|
-
opts: EventInit = { bubbles: true, cancelable: true }
|
|
149
|
+
opts: EventInit = { bubbles: true, cancelable: true },
|
|
143
150
|
): Event {
|
|
144
151
|
const evt = new Event(eventType, opts);
|
|
145
152
|
element.dispatchEvent(evt);
|
|
@@ -167,4 +174,4 @@ export class iEvents {
|
|
|
167
174
|
(fn as (...args: TParams) => unknown)(...params);
|
|
168
175
|
}
|
|
169
176
|
}
|
|
170
|
-
}
|
|
177
|
+
}
|
package/src/ts/utils/istorage.ts
CHANGED
|
@@ -61,11 +61,13 @@ export class iStorage {
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
/** Bound instance map (keyed by select element). */
|
|
64
|
-
public bindedMap: Map<HTMLSelectElement|HTMLElement, BinderMap> =
|
|
64
|
+
public bindedMap: Map<HTMLSelectElement | HTMLElement, BinderMap> =
|
|
65
|
+
new Map();
|
|
65
66
|
|
|
66
67
|
/** Unbind cache map (keyed by select element). */
|
|
67
|
-
public unbindedMap: Map<HTMLSelectElement|HTMLElement, BinderMap> =
|
|
68
|
+
public unbindedMap: Map<HTMLSelectElement | HTMLElement, BinderMap> =
|
|
69
|
+
new Map();
|
|
68
70
|
|
|
69
71
|
/** List of bound selectors/commands. */
|
|
70
72
|
public bindedCommand: string[] = [];
|
|
71
|
-
}
|
|
73
|
+
}
|