selective-ui 1.0.2 → 1.0.3
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/LICENSE +21 -21
- package/README.md +7 -2
- package/dist/selective-ui.css +567 -567
- package/dist/selective-ui.css.map +1 -1
- package/dist/selective-ui.esm.js +6046 -6046
- package/dist/selective-ui.esm.js.map +1 -1
- package/dist/selective-ui.esm.min.js +1 -1
- package/dist/selective-ui.esm.min.js.br +0 -0
- package/dist/selective-ui.min.js +1 -1
- package/dist/selective-ui.min.js.br +0 -0
- package/dist/selective-ui.umd.js +6046 -6046
- package/dist/selective-ui.umd.js.map +1 -1
- package/package.json +68 -68
- package/src/css/components/accessorybox.css +63 -63
- package/src/css/components/directive.css +19 -19
- package/src/css/components/empty-state.css +25 -25
- package/src/css/components/loading-state.css +25 -25
- package/src/css/components/optgroup.css +61 -61
- package/src/css/components/option-handle.css +33 -33
- package/src/css/components/option.css +129 -129
- package/src/css/components/placeholder.css +14 -14
- package/src/css/components/popup.css +38 -38
- package/src/css/components/searchbox.css +28 -28
- package/src/css/components/selectbox.css +53 -53
- package/src/css/index.css +74 -74
- package/src/js/adapter/mixed-adapter.js +434 -434
- package/src/js/components/accessorybox.js +124 -124
- package/src/js/components/directive.js +37 -37
- package/src/js/components/empty-state.js +67 -67
- package/src/js/components/loading-state.js +59 -59
- package/src/js/components/option-handle.js +113 -113
- package/src/js/components/placeholder.js +56 -56
- package/src/js/components/popup.js +470 -470
- package/src/js/components/searchbox.js +167 -167
- package/src/js/components/selectbox.js +692 -692
- package/src/js/core/base/adapter.js +162 -162
- package/src/js/core/base/model.js +59 -59
- package/src/js/core/base/recyclerview.js +82 -82
- package/src/js/core/base/view.js +62 -62
- package/src/js/core/model-manager.js +286 -286
- package/src/js/core/search-controller.js +521 -521
- package/src/js/index.js +136 -136
- package/src/js/models/group-model.js +142 -142
- package/src/js/models/option-model.js +236 -236
- package/src/js/services/dataset-observer.js +73 -73
- package/src/js/services/ea-observer.js +87 -87
- package/src/js/services/effector.js +403 -403
- package/src/js/services/refresher.js +39 -39
- package/src/js/services/resize-observer.js +151 -151
- package/src/js/services/select-observer.js +60 -60
- package/src/js/types/adapter.type.js +32 -32
- package/src/js/types/effector.type.js +23 -23
- package/src/js/types/ievents.type.js +10 -10
- package/src/js/types/libs.type.js +27 -27
- package/src/js/types/model.type.js +11 -11
- package/src/js/types/recyclerview.type.js +11 -11
- package/src/js/types/resize-observer.type.js +18 -18
- package/src/js/types/view.group.type.js +12 -12
- package/src/js/types/view.option.type.js +14 -14
- package/src/js/types/view.type.js +10 -10
- package/src/js/utils/guard.js +46 -46
- package/src/js/utils/ievents.js +83 -83
- package/src/js/utils/istorage.js +60 -60
- package/src/js/utils/libs.js +618 -618
- package/src/js/utils/selective.js +385 -385
- package/src/js/views/group-view.js +102 -102
- package/src/js/views/option-view.js +152 -152
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @class
|
|
3
|
-
*/
|
|
4
|
-
export class ElementAdditionObserver {
|
|
5
|
-
#isActive = false;
|
|
6
|
-
/** @type {MutationObserver} */
|
|
7
|
-
#observer = null;
|
|
8
|
-
|
|
9
|
-
/** @type {Function[]} */
|
|
10
|
-
#actions = [];
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Registers a callback to be invoked whenever a matching element is detected being added to the DOM.
|
|
14
|
-
*
|
|
15
|
-
* @param {(el: HTMLSelectElement) => void} action - Function executed with the newly added element.
|
|
16
|
-
*/
|
|
17
|
-
onDetect(action) {
|
|
18
|
-
this.#actions.push(action);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Clears all previously registered detection callbacks.
|
|
23
|
-
*/
|
|
24
|
-
clearDetect() {
|
|
25
|
-
this.#actions = [];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Starts observing the document for additions of elements matching the given tag.
|
|
30
|
-
* Detects both direct additions and nested matches within added subtrees.
|
|
31
|
-
*
|
|
32
|
-
* @param {string} tag - The tag name to watch for (e.g., "select", "div").
|
|
33
|
-
*/
|
|
34
|
-
start(tag) {
|
|
35
|
-
if (this.#isActive) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
this.#isActive = true;
|
|
39
|
-
const upperTag = tag.toUpperCase();
|
|
40
|
-
const lowerTag = tag.toLowerCase();
|
|
41
|
-
this.#observer = new MutationObserver((mutations) => {
|
|
42
|
-
mutations.forEach((mutation) => {
|
|
43
|
-
mutation.addedNodes.forEach((node) => {
|
|
44
|
-
const subnode = /** @type {HTMLElement} */ (node);
|
|
45
|
-
if (subnode.nodeType === 1) {
|
|
46
|
-
if (subnode.tagName === upperTag) {
|
|
47
|
-
this.#handle(subnode);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const selects = subnode.querySelectorAll(lowerTag);
|
|
51
|
-
selects.forEach((select) => {
|
|
52
|
-
this.#handle(select);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
this.#observer.observe(document.body, {
|
|
60
|
-
childList: true,
|
|
61
|
-
subtree: true
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Stops observing for element additions and releases internal resources.
|
|
67
|
-
* No-ops if the observer is not active.
|
|
68
|
-
*/
|
|
69
|
-
stop() {
|
|
70
|
-
if (!this.#isActive) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
this.#isActive = false;
|
|
74
|
-
this.#observer.disconnect();
|
|
75
|
-
this.#observer = null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Internal handler that invokes all registered detection callbacks for the provided element.
|
|
80
|
-
*
|
|
81
|
-
* @param {Element} element - The element that was detected as added to the DOM.
|
|
82
|
-
*/
|
|
83
|
-
#handle(element) {
|
|
84
|
-
this.#actions.forEach(action => {
|
|
85
|
-
action(element);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @class
|
|
3
|
+
*/
|
|
4
|
+
export class ElementAdditionObserver {
|
|
5
|
+
#isActive = false;
|
|
6
|
+
/** @type {MutationObserver} */
|
|
7
|
+
#observer = null;
|
|
8
|
+
|
|
9
|
+
/** @type {Function[]} */
|
|
10
|
+
#actions = [];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Registers a callback to be invoked whenever a matching element is detected being added to the DOM.
|
|
14
|
+
*
|
|
15
|
+
* @param {(el: HTMLSelectElement) => void} action - Function executed with the newly added element.
|
|
16
|
+
*/
|
|
17
|
+
onDetect(action) {
|
|
18
|
+
this.#actions.push(action);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Clears all previously registered detection callbacks.
|
|
23
|
+
*/
|
|
24
|
+
clearDetect() {
|
|
25
|
+
this.#actions = [];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Starts observing the document for additions of elements matching the given tag.
|
|
30
|
+
* Detects both direct additions and nested matches within added subtrees.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} tag - The tag name to watch for (e.g., "select", "div").
|
|
33
|
+
*/
|
|
34
|
+
start(tag) {
|
|
35
|
+
if (this.#isActive) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this.#isActive = true;
|
|
39
|
+
const upperTag = tag.toUpperCase();
|
|
40
|
+
const lowerTag = tag.toLowerCase();
|
|
41
|
+
this.#observer = new MutationObserver((mutations) => {
|
|
42
|
+
mutations.forEach((mutation) => {
|
|
43
|
+
mutation.addedNodes.forEach((node) => {
|
|
44
|
+
const subnode = /** @type {HTMLElement} */ (node);
|
|
45
|
+
if (subnode.nodeType === 1) {
|
|
46
|
+
if (subnode.tagName === upperTag) {
|
|
47
|
+
this.#handle(subnode);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const selects = subnode.querySelectorAll(lowerTag);
|
|
51
|
+
selects.forEach((select) => {
|
|
52
|
+
this.#handle(select);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
this.#observer.observe(document.body, {
|
|
60
|
+
childList: true,
|
|
61
|
+
subtree: true
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Stops observing for element additions and releases internal resources.
|
|
67
|
+
* No-ops if the observer is not active.
|
|
68
|
+
*/
|
|
69
|
+
stop() {
|
|
70
|
+
if (!this.#isActive) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.#isActive = false;
|
|
74
|
+
this.#observer.disconnect();
|
|
75
|
+
this.#observer = null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Internal handler that invokes all registered detection callbacks for the provided element.
|
|
80
|
+
*
|
|
81
|
+
* @param {Element} element - The element that was detected as added to the DOM.
|
|
82
|
+
*/
|
|
83
|
+
#handle(element) {
|
|
84
|
+
this.#actions.forEach(action => {
|
|
85
|
+
action(element);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
88
|
}
|