@twobirds/microcomponents 0.0.82 → 0.0.84
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/assets/documentation/MC.md +0 -1
- package/assets/test/test.html +1 -1
- package/dist/MC.d.ts +11 -10
- package/dist/MC.d.ts.map +1 -1
- package/dist/MC.js +137 -200
- package/dist/MC.min.js +157 -296
- package/dist/MC.ts +202 -337
- package/dist/elements.d.ts +1 -1
- package/dist/elements.d.ts.map +1 -1
- package/dist/elements.js +26 -6
- package/dist/elements.min.js +1 -1
- package/dist/elements.ts +50 -7
- package/dist/formValues.js +2 -2
- package/dist/formValues.min.js +1 -1
- package/dist/formValues.ts +3 -3
- package/dist/microcomponents.d.ts +0 -1
- package/dist/microcomponents.d.ts.map +1 -1
- package/dist/microcomponents.js +0 -1
- package/dist/microcomponents.min.js +1 -1
- package/dist/microcomponents.ts +1 -1
- package/dist/observables.d.ts.map +1 -1
- package/dist/observables.js +52 -57
- package/dist/observables.min.js +1 -1
- package/dist/observables.ts +68 -73
- package/package.json +6 -5
- package/public/MC.d.ts +11 -10
- package/public/MC.d.ts.map +1 -1
- package/public/MC.js +137 -200
- package/public/MC.js.map +1 -1
- package/public/MC.min.js +157 -296
- package/public/MC.ts +202 -337
- package/public/documentation/MC.md +0 -1
- package/public/elements.d.ts +1 -1
- package/public/elements.d.ts.map +1 -1
- package/public/elements.js +26 -6
- package/public/elements.js.map +1 -1
- package/public/elements.min.js +1 -1
- package/public/elements.ts +50 -7
- package/public/formValues.js +2 -2
- package/public/formValues.js.map +1 -1
- package/public/formValues.min.js +1 -1
- package/public/formValues.ts +3 -3
- package/public/microcomponents.d.ts +0 -1
- package/public/microcomponents.d.ts.map +1 -1
- package/public/microcomponents.js +0 -1
- package/public/microcomponents.js.map +1 -1
- package/public/microcomponents.min.js +1 -1
- package/public/microcomponents.ts +1 -1
- package/public/observables.d.ts.map +1 -1
- package/public/observables.js +52 -57
- package/public/observables.js.map +1 -1
- package/public/observables.min.js +1 -1
- package/public/observables.ts +68 -73
- package/public/{test/selectors.ts → selectors._ts} +2 -367
- package/public/src/MC.d.ts +37 -0
- package/public/src/MC.d.ts.map +1 -0
- package/public/src/MC.js +316 -0
- package/public/src/MC.js.map +1 -0
- package/public/src/MC.ts +202 -337
- package/public/src/elements.d.ts +5 -0
- package/public/src/elements.d.ts.map +1 -0
- package/public/src/elements.js +68 -0
- package/public/src/elements.js.map +1 -0
- package/public/src/elements.ts +50 -7
- package/public/src/formValues.d.ts +3 -0
- package/public/src/formValues.d.ts.map +1 -0
- package/public/src/formValues.js +162 -0
- package/public/src/formValues.js.map +1 -0
- package/public/src/formValues.ts +3 -3
- package/public/src/helpers.d.ts +14 -0
- package/public/src/helpers.d.ts.map +1 -0
- package/public/src/helpers.js +113 -0
- package/public/src/microcomponents.d.ts +6 -0
- package/public/src/microcomponents.d.ts.map +1 -0
- package/public/src/microcomponents.js +7 -0
- package/public/src/microcomponents.js.map +1 -0
- package/public/src/microcomponents.ts +1 -1
- package/public/src/observables.d.ts +11 -0
- package/public/src/observables.d.ts.map +1 -0
- package/public/src/observables.js +244 -0
- package/public/src/observables.js.map +1 -0
- package/public/src/observables.ts +68 -73
- package/public/{selectors.ts → src/selectors._ts} +2 -367
- package/public/src/test/grandparent.css +11 -0
- package/public/src/test/test/child.d.ts +2 -0
- package/public/src/test/test/child.d.ts.map +1 -0
- package/public/src/test/test/child.js +15 -0
- package/public/src/test/test/child.js.map +1 -0
- package/public/src/test/test/child.ts +21 -0
- package/public/src/test/test/grandchild.d.ts +2 -0
- package/public/src/test/test/grandchild.d.ts.map +1 -0
- package/public/src/test/test/grandchild.js +15 -0
- package/public/src/test/test/grandchild.js.map +1 -0
- package/public/src/test/test/grandchild.ts +21 -0
- package/public/src/test/test/grandparent.d.ts +2 -0
- package/public/src/test/test/grandparent.d.ts.map +1 -0
- package/public/src/test/test/grandparent.js +1 -0
- package/public/src/test/test/grandparent.js.map +1 -0
- package/public/src/test/test/grandparent.ts +29 -0
- package/public/src/test/test/greatgrandchild.d.ts +2 -0
- package/public/src/test/test/greatgrandchild.d.ts.map +1 -0
- package/public/src/test/test/greatgrandchild.js +29 -0
- package/public/src/test/test/greatgrandchild.js.map +1 -0
- package/public/src/test/test/greatgrandchild.ts +42 -0
- package/public/src/test/test/parent.d.ts +2 -0
- package/public/src/test/test/parent.d.ts.map +1 -0
- package/public/src/test/test/parent.js +15 -0
- package/public/src/test/test/parent.js.map +1 -0
- package/public/src/test/test/parent.ts +21 -0
- package/public/src/test/test/testform.d.ts +2 -0
- package/public/src/test/test/testform.d.ts.map +1 -0
- package/public/src/test/test/testform.js +1 -0
- package/public/src/test/test/testform.js.map +1 -0
- package/public/src/test/test/testform.ts +153 -0
- package/public/src/test/test/testfunction.d.ts +3 -0
- package/public/src/test/test/testfunction.d.ts.map +1 -0
- package/public/src/test/test/testfunction.js +7 -0
- package/public/src/test/test/testfunction.js.map +1 -0
- package/public/src/test/test/testfunction.ts +12 -0
- package/public/src/test/test/testmc.d.ts +3 -0
- package/public/src/test/test/testmc.d.ts.map +1 -0
- package/public/src/test/test/testmc.js +10 -0
- package/public/src/test/test/testmc.js.map +1 -0
- package/public/src/test/test/testmc.ts +16 -0
- package/public/src/test/test/testsimpleclass.d.ts +3 -0
- package/public/src/test/test/testsimpleclass.d.ts.map +1 -0
- package/public/src/test/test/testsimpleclass.js +9 -0
- package/public/src/test/test/testsimpleclass.js.map +1 -0
- package/public/src/test/test/testsimpleclass.ts +15 -0
- package/public/src/test/test.d.ts +2 -0
- package/public/src/test/test.d.ts.map +1 -0
- package/public/src/test/test.js +80 -0
- package/public/src/test/test.js.map +1 -0
- package/public/src/test/test.ts +188 -0
- package/public/src/test/testform.css +47 -0
- package/public/src/test/testform.html +56 -0
- package/public/src/test/testform.json +27 -0
- package/public/test/MC.d.ts +11 -10
- package/public/test/MC.d.ts.map +1 -1
- package/public/test/MC.js +137 -200
- package/public/test/MC.min.js +377 -0
- package/public/test/MC.ts +202 -337
- package/public/test/elements.d.ts +1 -1
- package/public/test/elements.d.ts.map +1 -1
- package/public/test/elements.js +26 -6
- package/public/test/elements.min.js +1 -0
- package/public/test/elements.ts +50 -7
- package/public/test/formValues.js +2 -2
- package/public/test/formValues.min.js +1 -0
- package/public/test/formValues.ts +3 -3
- package/public/test/grandparent.css +1 -3
- package/public/test/microcomponents.d.ts +0 -1
- package/public/test/microcomponents.d.ts.map +1 -1
- package/public/test/microcomponents.js +0 -1
- package/public/test/microcomponents.min.js +1 -1
- package/public/test/microcomponents.ts +1 -1
- package/public/test/observables.d.ts.map +1 -1
- package/public/test/observables.js +52 -57
- package/public/test/observables.min.js +1 -0
- package/public/test/observables.ts +68 -73
- package/public/test/test/child.ts +21 -0
- package/public/test/test/grandchild.ts +21 -0
- package/public/test/test/grandparent.d.ts.map +1 -1
- package/public/test/test/grandparent.js +1 -1
- package/public/test/test/grandparent.js.map +1 -1
- package/public/test/test/grandparent.ts +29 -0
- package/public/test/test/greatgrandchild.ts +42 -0
- package/public/test/test/parent.ts +21 -0
- package/public/test/test/testform.js +1 -1
- package/public/test/test/testform.js.map +1 -1
- package/public/test/test/testform.ts +153 -0
- package/public/test/test/testfunction.d.ts +3 -0
- package/public/test/test/testfunction.d.ts.map +1 -0
- package/public/test/test/testfunction.js +7 -0
- package/public/test/test/testfunction.js.map +1 -0
- package/public/test/test/testfunction.ts +12 -0
- package/public/test/test/testmc.d.ts +2 -5
- package/public/test/test/testmc.d.ts.map +1 -1
- package/public/test/test/testmc.js +4 -4
- package/public/test/test/testmc.js.map +1 -1
- package/public/test/test/testmc.ts +16 -0
- package/public/test/test/testsimpleclass.d.ts +3 -0
- package/public/test/test/testsimpleclass.d.ts.map +1 -0
- package/public/test/test/testsimpleclass.js +9 -0
- package/public/test/test/testsimpleclass.js.map +1 -0
- package/public/test/test/testsimpleclass.ts +15 -0
- package/public/test/test.html +1 -1
- package/public/test/test.js +5 -6
- package/public/test/test.js.map +1 -1
- package/public/test/test.ts +188 -0
- package/public/test/testform.css +47 -0
- package/public/test/testform.html +56 -0
- package/public/test/testform.json +3 -3
- package/public/typedoc/assets/navigation.js +1 -1
- package/public/typedoc/assets/search.js +1 -1
- package/public/typedoc/classes/MC.DC.html +6 -4
- package/public/typedoc/classes/MC.MC.html +3 -4
- package/public/typedoc/classes/MC.McBase.html +2 -2
- package/public/typedoc/functions/MC.autoload.html +1 -1
- package/public/typedoc/functions/MC.off.html +1 -0
- package/public/typedoc/functions/MC.on.html +1 -0
- package/public/typedoc/functions/MC.one.html +1 -0
- package/public/typedoc/functions/elements.defineCE.html +1 -1
- package/public/typedoc/functions/elements.getCE.html +1 -1
- package/public/typedoc/functions/formValues.formValues.html +1 -1
- package/public/typedoc/functions/observables.observe.html +1 -1
- package/public/typedoc/interfaces/MC.HTMLMcElement.html +2 -2
- package/public/typedoc/modules/MC.html +7 -6
- package/public/typedoc/modules/elements.html +1 -1
- package/public/typedoc/modules/formValues.html +1 -1
- package/public/typedoc/modules/observables.html +1 -1
- package/public/typedoc/types/observables.Observable.html +1 -1
- package/src/MC.ts +202 -337
- package/src/elements.ts +50 -7
- package/src/formValues.ts +3 -3
- package/src/microcomponents.ts +1 -1
- package/src/observables.ts +68 -73
- package/{dist/selectors.ts → src/selectors._ts} +2 -367
- package/src/test/test/grandparent.ts +12 -4
- package/src/test/test/testform.ts +13 -11
- package/src/test/test/testfunction.ts +12 -0
- package/src/test/test/testmc.ts +13 -9
- package/src/test/test/testsimpleclass.ts +15 -0
- package/src/test/test.ts +8 -20
- package/tasks.md +36 -0
- package/tsconfig.json +2 -2
- package/typedoc.json +1 -1
- package/webpack.config.js +2 -2
- package/dist/McEvent.d.ts +0 -15
- package/dist/McEvent.d.ts.map +0 -1
- package/dist/McEvent.js +0 -71
- package/dist/selectors.d.ts +0 -108
- package/dist/selectors.d.ts.map +0 -1
- package/dist/selectors.js +0 -971
- package/dist/selectors.min.js +0 -1
- package/public/McEvent.d.ts +0 -15
- package/public/McEvent.d.ts.map +0 -1
- package/public/McEvent.js +0 -71
- package/public/McEvent.js.map +0 -1
- package/public/selectors.d.ts +0 -108
- package/public/selectors.d.ts.map +0 -1
- package/public/selectors.js +0 -971
- package/public/selectors.js.map +0 -1
- package/public/selectors.min.js +0 -1
- package/public/src/selectors.ts +0 -1634
- package/public/test/MC.js.map +0 -1
- package/public/test/McEvent.d.ts +0 -15
- package/public/test/McEvent.d.ts.map +0 -1
- package/public/test/McEvent.js +0 -71
- package/public/test/McEvent.js.map +0 -1
- package/public/test/McEvent.ts +0 -96
- package/public/test/elements.js.map +0 -1
- package/public/test/formValues.js.map +0 -1
- package/public/test/microcomponents.js.map +0 -1
- package/public/test/observables.js.map +0 -1
- package/public/test/selectors.d.ts +0 -108
- package/public/test/selectors.d.ts.map +0 -1
- package/public/test/selectors.js +0 -971
- package/public/test/selectors.js.map +0 -1
- package/public/typedoc/classes/MC.McEvent.html +0 -9
- package/public/typedoc/functions/MC.addListener.html +0 -1
- package/public/typedoc/functions/MC.removeListener.html +0 -1
- package/src/McEvent.ts +0 -96
- package/src/selectors.ts +0 -1634
- /package/{dist/McEvent.ts → public/McEvent._ts} +0 -0
- /package/public/{McEvent.ts → src/McEvent._ts} +0 -0
- /package/public/{test → src}/helpers.js.map +0 -0
- /package/{public/src/McEvent.ts → src/McEvent._ts} +0 -0
package/public/selectors.js
DELETED
|
@@ -1,971 +0,0 @@
|
|
|
1
|
-
import { addListener, removeListener } from './MC.js';
|
|
2
|
-
const isObject = (value) => {
|
|
3
|
-
return value != null && typeof value === 'object';
|
|
4
|
-
};
|
|
5
|
-
const words = (classes) => {
|
|
6
|
-
let classSet = new Set();
|
|
7
|
-
classes.forEach(c => {
|
|
8
|
-
c = c.trim();
|
|
9
|
-
c.split(' ').forEach(e => {
|
|
10
|
-
if (e !== '') {
|
|
11
|
-
classSet.add(e);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
classes = Array.from(classSet);
|
|
16
|
-
return classes;
|
|
17
|
-
};
|
|
18
|
-
const getInputName = (e) => {
|
|
19
|
-
let ret = e instanceof HTMLInputElement
|
|
20
|
-
? 'input'
|
|
21
|
-
: e instanceof HTMLSelectElement
|
|
22
|
-
? 'select'
|
|
23
|
-
: e instanceof HTMLTextAreaElement
|
|
24
|
-
? 'textarea'
|
|
25
|
-
: '';
|
|
26
|
-
return ret;
|
|
27
|
-
};
|
|
28
|
-
const getInputHandlers = (e) => {
|
|
29
|
-
let inputList = $d('input,select,textarea', e).array, handlers = {};
|
|
30
|
-
inputList.forEach((i) => {
|
|
31
|
-
const name = i.getAttribute('name') || 'undefined';
|
|
32
|
-
if (name) {
|
|
33
|
-
let h;
|
|
34
|
-
switch (getInputName(i)) {
|
|
35
|
-
case 'input':
|
|
36
|
-
h = new InputHandler(i, e);
|
|
37
|
-
Object.defineProperty(handlers, name, {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
configurable: true,
|
|
40
|
-
get: () => { return h.val; },
|
|
41
|
-
set: (value) => { h.val = value; }
|
|
42
|
-
});
|
|
43
|
-
break;
|
|
44
|
-
case 'select':
|
|
45
|
-
h = new SelectHandler(i);
|
|
46
|
-
Object.defineProperty(handlers, name, {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
configurable: true,
|
|
49
|
-
get: () => { return h.val; },
|
|
50
|
-
set: (value) => { h.val = value; }
|
|
51
|
-
});
|
|
52
|
-
break;
|
|
53
|
-
case 'textarea':
|
|
54
|
-
h = new TextAreaHandler(i);
|
|
55
|
-
Object.defineProperty(handlers, name, {
|
|
56
|
-
enumerable: true,
|
|
57
|
-
configurable: true,
|
|
58
|
-
get: () => { return h.val; },
|
|
59
|
-
set: (value) => { h.val = value; }
|
|
60
|
-
});
|
|
61
|
-
break;
|
|
62
|
-
default:
|
|
63
|
-
console.warn('handler missing:', name, 'for', i);
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
return handlers;
|
|
69
|
-
};
|
|
70
|
-
class InputBase {
|
|
71
|
-
constructor(e) {
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
class InputHandler extends InputBase {
|
|
75
|
-
#e;
|
|
76
|
-
#type;
|
|
77
|
-
#radioBase;
|
|
78
|
-
constructor(e, radioBase) {
|
|
79
|
-
super(e);
|
|
80
|
-
this.#e = e;
|
|
81
|
-
this.#type = e.type;
|
|
82
|
-
this.#radioBase = radioBase;
|
|
83
|
-
}
|
|
84
|
-
get val() {
|
|
85
|
-
let that = this, type = that.#type, ret;
|
|
86
|
-
switch (type) {
|
|
87
|
-
case 'radio':
|
|
88
|
-
const check = $d(`input[type="radio"][name="${this.#e.getAttribute('name')}"]`, this.#radioBase)
|
|
89
|
-
.filter(e => e.checked);
|
|
90
|
-
if (!check.length)
|
|
91
|
-
return '';
|
|
92
|
-
ret = check.array[0];
|
|
93
|
-
return ret.value;
|
|
94
|
-
case 'checkbox':
|
|
95
|
-
return that.#e.checked;
|
|
96
|
-
default:
|
|
97
|
-
return that.#e.value;
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
return '';
|
|
101
|
-
}
|
|
102
|
-
set val(value) {
|
|
103
|
-
let that = this, type = that.#type, ret;
|
|
104
|
-
switch (type) {
|
|
105
|
-
case 'radio':
|
|
106
|
-
const selection = `input[type="radio"][name="${this.#e.getAttribute('name')}"]`, radios = $d(selection, this.#radioBase);
|
|
107
|
-
if (!radios.length)
|
|
108
|
-
return;
|
|
109
|
-
if (value === '') {
|
|
110
|
-
radios.forEach(r => { if (r.checked)
|
|
111
|
-
r.checked = false; });
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const setRadioElement = radios.filter(r => r.getAttribute('value') === value);
|
|
115
|
-
if (!setRadioElement.length)
|
|
116
|
-
return;
|
|
117
|
-
setRadioElement.array[0].checked = true;
|
|
118
|
-
return;
|
|
119
|
-
break;
|
|
120
|
-
case 'checkbox':
|
|
121
|
-
that.#e.checked = value;
|
|
122
|
-
break;
|
|
123
|
-
default:
|
|
124
|
-
that.#e.value = value;
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
class SelectHandler extends InputBase {
|
|
131
|
-
#e;
|
|
132
|
-
#multi = false;
|
|
133
|
-
constructor(e) {
|
|
134
|
-
super(e);
|
|
135
|
-
this.#e = e;
|
|
136
|
-
this.#multi = e.type === 'select-multiple';
|
|
137
|
-
}
|
|
138
|
-
get val() {
|
|
139
|
-
const that = this, ret = [];
|
|
140
|
-
const options = $d(that.#e.querySelectorAll('option'))
|
|
141
|
-
.filter(o => o.selected)
|
|
142
|
-
.forEach(o => { if (o.selected)
|
|
143
|
-
ret.push(o.value); });
|
|
144
|
-
if (this.#multi)
|
|
145
|
-
return ret;
|
|
146
|
-
return ret.length ? ret[0] : '';
|
|
147
|
-
}
|
|
148
|
-
set val(value) {
|
|
149
|
-
const that = this;
|
|
150
|
-
value = typeof value === 'string' ? [value] : value;
|
|
151
|
-
const options = $d(that.#e.querySelectorAll('option'))
|
|
152
|
-
.forEach(o => {
|
|
153
|
-
if (value.indexOf(o.value) > -1) {
|
|
154
|
-
o.setAttribute('selected', true);
|
|
155
|
-
o.selected = true;
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
o.removeAttribute('selected');
|
|
159
|
-
o.selected = false;
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
class TextAreaHandler extends InputBase {
|
|
166
|
-
#e;
|
|
167
|
-
constructor(e) {
|
|
168
|
-
super(e);
|
|
169
|
-
this.#e = e;
|
|
170
|
-
}
|
|
171
|
-
get val() {
|
|
172
|
-
return this.#e.value;
|
|
173
|
-
}
|
|
174
|
-
set val(value) {
|
|
175
|
-
this.#e.value = value;
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
class DomSelector {
|
|
180
|
-
#set = new Set();
|
|
181
|
-
get set() {
|
|
182
|
-
return this.#set;
|
|
183
|
-
}
|
|
184
|
-
get array() {
|
|
185
|
-
return Array.from(this.#set);
|
|
186
|
-
}
|
|
187
|
-
set set(set) {
|
|
188
|
-
this.#set = set;
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
get length() {
|
|
192
|
-
return this.#set.size;
|
|
193
|
-
}
|
|
194
|
-
constructor(selection, element = document.body) {
|
|
195
|
-
let that = this, undefinedTags = new Set();
|
|
196
|
-
if (!selection) {
|
|
197
|
-
return that;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
$t(nameSpace) {
|
|
201
|
-
let result = new TbSelector();
|
|
202
|
-
this.#set.forEach((e) => {
|
|
203
|
-
if (e._mc) {
|
|
204
|
-
Object.values(e._mc).forEach((mc) => {
|
|
205
|
-
result.set.add(mc);
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
if (nameSpace) {
|
|
210
|
-
result.filter(mc => mc.nameSpace === nameSpace);
|
|
211
|
-
}
|
|
212
|
-
return result;
|
|
213
|
-
}
|
|
214
|
-
add(selection, target) {
|
|
215
|
-
let that = this;
|
|
216
|
-
$d(selection, target).forEach(element => {
|
|
217
|
-
that.#set.add(element);
|
|
218
|
-
});
|
|
219
|
-
return that;
|
|
220
|
-
}
|
|
221
|
-
addClass(...classes) {
|
|
222
|
-
classes = words(classes);
|
|
223
|
-
this.forEach(element => {
|
|
224
|
-
element.classList.add(...classes);
|
|
225
|
-
});
|
|
226
|
-
return this;
|
|
227
|
-
}
|
|
228
|
-
after(selection, target) {
|
|
229
|
-
let that = this, after = $d(selection, target);
|
|
230
|
-
;
|
|
231
|
-
if (!after.length)
|
|
232
|
-
return that;
|
|
233
|
-
after
|
|
234
|
-
.first()
|
|
235
|
-
.forEach(element => {
|
|
236
|
-
that.array.reverse().forEach((e) => {
|
|
237
|
-
e.after(element);
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
return that;
|
|
241
|
-
}
|
|
242
|
-
append(selection, target) {
|
|
243
|
-
let that = this, addTo = that.array['0'], append = $d(selection, target);
|
|
244
|
-
if (addTo) {
|
|
245
|
-
append.forEach((e) => {
|
|
246
|
-
addTo.append(e);
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
return that;
|
|
250
|
-
}
|
|
251
|
-
appendTo(selection, target) {
|
|
252
|
-
let that = this, appendTo = $d(selection, target).array['0'];
|
|
253
|
-
if (appendTo) {
|
|
254
|
-
that.forEach((e) => {
|
|
255
|
-
appendTo.append(e);
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
return that;
|
|
259
|
-
}
|
|
260
|
-
attr(first, second) {
|
|
261
|
-
let that = this, attributes = {};
|
|
262
|
-
if (!that.length)
|
|
263
|
-
return that;
|
|
264
|
-
if (!arguments.length) {
|
|
265
|
-
Array.from([...that.set][0].attributes).forEach((attribute) => {
|
|
266
|
-
attributes[attribute.name] = attribute.value;
|
|
267
|
-
});
|
|
268
|
-
return attributes;
|
|
269
|
-
}
|
|
270
|
-
if (typeof first === 'string') {
|
|
271
|
-
if (second === undefined) {
|
|
272
|
-
return [...that.set][0].getAttribute(first);
|
|
273
|
-
}
|
|
274
|
-
if (second === null) {
|
|
275
|
-
[...that.set].forEach((e) => {
|
|
276
|
-
e.removeAttribute(first);
|
|
277
|
-
});
|
|
278
|
-
return that;
|
|
279
|
-
}
|
|
280
|
-
if (typeof second === 'object') {
|
|
281
|
-
second = JSON.stringify(second);
|
|
282
|
-
}
|
|
283
|
-
[...that.set].forEach((e) => {
|
|
284
|
-
e.setAttribute(first, second);
|
|
285
|
-
});
|
|
286
|
-
return that;
|
|
287
|
-
}
|
|
288
|
-
if (typeof first === 'object') {
|
|
289
|
-
[...that.set].forEach((e) => {
|
|
290
|
-
Object.keys(first).forEach((key) => {
|
|
291
|
-
$d(e).attr(key, first.key);
|
|
292
|
-
});
|
|
293
|
-
});
|
|
294
|
-
return that;
|
|
295
|
-
}
|
|
296
|
-
return that;
|
|
297
|
-
}
|
|
298
|
-
before(selection, target) {
|
|
299
|
-
let that = this, before = $d(selection, target);
|
|
300
|
-
;
|
|
301
|
-
if (!before.length)
|
|
302
|
-
return that;
|
|
303
|
-
before
|
|
304
|
-
.first()
|
|
305
|
-
.forEach(element => {
|
|
306
|
-
that.forEach((e) => {
|
|
307
|
-
e.before(element);
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
return that;
|
|
311
|
-
}
|
|
312
|
-
children(selection, rootNode) {
|
|
313
|
-
let that = this, set = new Set();
|
|
314
|
-
that.#set.forEach((e) => {
|
|
315
|
-
Array.from(e.children).forEach((c) => {
|
|
316
|
-
set.add(c);
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
that = $d([...set]);
|
|
320
|
-
if (selection) {
|
|
321
|
-
let compare = $d(selection, rootNode);
|
|
322
|
-
that.filter((e) => compare.has(e));
|
|
323
|
-
}
|
|
324
|
-
return that;
|
|
325
|
-
}
|
|
326
|
-
descendants(selection, rootNode) {
|
|
327
|
-
let that = this, set = new Set();
|
|
328
|
-
that.#set.forEach((e) => {
|
|
329
|
-
e.querySelectorAll('*').forEach((h) => {
|
|
330
|
-
set.add(h);
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
that = $d([...set]);
|
|
334
|
-
if (selection) {
|
|
335
|
-
let compare = $d(selection, rootNode);
|
|
336
|
-
that.filter((e) => compare.has(e));
|
|
337
|
-
}
|
|
338
|
-
return that;
|
|
339
|
-
}
|
|
340
|
-
empty() {
|
|
341
|
-
return this.filter((e) => false);
|
|
342
|
-
}
|
|
343
|
-
first(selection, rootNode) {
|
|
344
|
-
let that = this, set = new Set(), compare = false;
|
|
345
|
-
;
|
|
346
|
-
if (selection) {
|
|
347
|
-
compare = $d(selection, rootNode);
|
|
348
|
-
}
|
|
349
|
-
that.#set.forEach((e) => {
|
|
350
|
-
if (e.parentNode) {
|
|
351
|
-
set.add(e.parentNode.children[0]);
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
that = $d([...set]);
|
|
355
|
-
if (selection) {
|
|
356
|
-
that.filter((e) => compare.has(e));
|
|
357
|
-
}
|
|
358
|
-
return that;
|
|
359
|
-
}
|
|
360
|
-
has(element) {
|
|
361
|
-
return this.#set.has(element);
|
|
362
|
-
}
|
|
363
|
-
hasClass(...classes) {
|
|
364
|
-
classes = words(classes);
|
|
365
|
-
return this.every(e => {
|
|
366
|
-
return Array.from(e.classList).every(c => e.contains(c));
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
html(html) {
|
|
370
|
-
let that = this;
|
|
371
|
-
if (html) {
|
|
372
|
-
that.forEach((e) => {
|
|
373
|
-
!e.parentNode
|
|
374
|
-
? (() => {
|
|
375
|
-
console.warn('Cannot access the .innerHTML of a HTMLElement that hasnt been inserted yet', e);
|
|
376
|
-
console.trace(e, this);
|
|
377
|
-
console.info('If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!', 'color: blue;');
|
|
378
|
-
})()
|
|
379
|
-
: e.innerHTML = html;
|
|
380
|
-
});
|
|
381
|
-
return that;
|
|
382
|
-
}
|
|
383
|
-
return that.array[0].innerHTML;
|
|
384
|
-
}
|
|
385
|
-
last(selection, rootNode) {
|
|
386
|
-
let that = this, set = new Set();
|
|
387
|
-
that.#set.forEach((e) => {
|
|
388
|
-
let siblings = e.parentNode?.children;
|
|
389
|
-
if (siblings) {
|
|
390
|
-
set.add(Array.from(siblings).at(-1));
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
that = $d([...set]);
|
|
394
|
-
if (selection) {
|
|
395
|
-
let compare = $d(selection, rootNode);
|
|
396
|
-
that.filter((e) => compare.has(e));
|
|
397
|
-
}
|
|
398
|
-
return that;
|
|
399
|
-
}
|
|
400
|
-
next(selection, rootNode) {
|
|
401
|
-
let that = this, set = new Set();
|
|
402
|
-
that.#set.forEach((e) => {
|
|
403
|
-
let siblings = e.parentNode?.children;
|
|
404
|
-
if (siblings) {
|
|
405
|
-
let arr = Array.from(siblings), pos = arr.indexOf(e) + 1;
|
|
406
|
-
if (pos < arr.length) {
|
|
407
|
-
set.add(arr.at(pos));
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
});
|
|
411
|
-
that = $d([...set]);
|
|
412
|
-
if (selection) {
|
|
413
|
-
let compare = $d(selection, rootNode);
|
|
414
|
-
that.filter((e) => compare.has(e));
|
|
415
|
-
}
|
|
416
|
-
return that;
|
|
417
|
-
}
|
|
418
|
-
normalize() {
|
|
419
|
-
let that = this;
|
|
420
|
-
that.#set.forEach((e) => { e.normalize(); });
|
|
421
|
-
return that;
|
|
422
|
-
}
|
|
423
|
-
off(eventName, cb) {
|
|
424
|
-
let that = this, eventNames = eventName.indexOf(' ') > -1
|
|
425
|
-
? eventName.split(' ')
|
|
426
|
-
: [eventName];
|
|
427
|
-
that.array.forEach((e) => {
|
|
428
|
-
eventNames.forEach(function (n) {
|
|
429
|
-
removeListener(e, n, cb);
|
|
430
|
-
});
|
|
431
|
-
});
|
|
432
|
-
return that;
|
|
433
|
-
}
|
|
434
|
-
on(eventName, cb, capture = false, once = false) {
|
|
435
|
-
let that = this, eventNames = eventName.indexOf(' ') > -1
|
|
436
|
-
? eventName.split(' ').filter((s) => s !== '')
|
|
437
|
-
: [eventName];
|
|
438
|
-
function wrapper() { wrapper.cb.apply(that, Array.from(arguments)); }
|
|
439
|
-
;
|
|
440
|
-
wrapper.cb = cb;
|
|
441
|
-
that.forEach((e) => {
|
|
442
|
-
eventNames.forEach(function (n) {
|
|
443
|
-
addListener(e, n, wrapper, capture, once);
|
|
444
|
-
});
|
|
445
|
-
});
|
|
446
|
-
return wrapper;
|
|
447
|
-
}
|
|
448
|
-
one(eventName, cb, capture = false) {
|
|
449
|
-
let that = this, eventNames = eventName.indexOf(' ') > -1
|
|
450
|
-
? eventName.split(' ').filter((s) => s !== '')
|
|
451
|
-
: [eventName];
|
|
452
|
-
function wrapper() { wrapper.cb.apply(that, Array.from(arguments)); }
|
|
453
|
-
;
|
|
454
|
-
wrapper.cb = cb;
|
|
455
|
-
that.forEach((e) => {
|
|
456
|
-
eventNames.forEach(function (n) {
|
|
457
|
-
addListener(e, n, wrapper, capture, true);
|
|
458
|
-
});
|
|
459
|
-
});
|
|
460
|
-
return wrapper;
|
|
461
|
-
}
|
|
462
|
-
parent(selection, rootNode) {
|
|
463
|
-
let that = this, set = new Set();
|
|
464
|
-
that.#set.forEach((e) => {
|
|
465
|
-
if (e.parentNode && e.parentNode.tagName !== 'HTML') {
|
|
466
|
-
set.add(e.parentNode);
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
that = $d([...set]);
|
|
470
|
-
if (selection) {
|
|
471
|
-
let compare = $d(selection, rootNode);
|
|
472
|
-
that.filter((e) => compare.has(e));
|
|
473
|
-
}
|
|
474
|
-
return that;
|
|
475
|
-
}
|
|
476
|
-
parents(selection, rootNode) {
|
|
477
|
-
let that = this, set = new Set();
|
|
478
|
-
that.#set.forEach((e) => {
|
|
479
|
-
let current = e;
|
|
480
|
-
while (current.parentNode && current.parentNode.tagName !== 'HTML') {
|
|
481
|
-
current = current.parentNode;
|
|
482
|
-
set.add(current);
|
|
483
|
-
}
|
|
484
|
-
});
|
|
485
|
-
that = $d([...set]);
|
|
486
|
-
if (selection) {
|
|
487
|
-
let compare = $d(selection, rootNode);
|
|
488
|
-
that.filter((e) => compare.has(e));
|
|
489
|
-
}
|
|
490
|
-
return that;
|
|
491
|
-
}
|
|
492
|
-
prepend(selection, target) {
|
|
493
|
-
let that = this, addTo = that.array['0'], prepend = $d(selection, target);
|
|
494
|
-
if (addTo) {
|
|
495
|
-
prepend.forEach((e) => {
|
|
496
|
-
addTo.prepend(e);
|
|
497
|
-
});
|
|
498
|
-
}
|
|
499
|
-
return that;
|
|
500
|
-
}
|
|
501
|
-
prev(selection, rootNode) {
|
|
502
|
-
let that = this, set = new Set();
|
|
503
|
-
that.#set.forEach((e) => {
|
|
504
|
-
let siblings = e.parentNode?.children;
|
|
505
|
-
if (siblings) {
|
|
506
|
-
let arr = Array.from(siblings), pos = arr.indexOf(e) - 1;
|
|
507
|
-
if (pos > -1) {
|
|
508
|
-
set.add(arr.at(pos));
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
that = $d([...set]);
|
|
513
|
-
if (selection) {
|
|
514
|
-
let compare = $d(selection, rootNode);
|
|
515
|
-
that.filter((e) => compare.has(e));
|
|
516
|
-
}
|
|
517
|
-
return that;
|
|
518
|
-
}
|
|
519
|
-
removeClass(...classes) {
|
|
520
|
-
classes = words(classes);
|
|
521
|
-
this.forEach(element => {
|
|
522
|
-
element.classList.remove(...classes);
|
|
523
|
-
});
|
|
524
|
-
return this;
|
|
525
|
-
}
|
|
526
|
-
text(text) {
|
|
527
|
-
let that = this;
|
|
528
|
-
if (text) {
|
|
529
|
-
that.forEach((e) => {
|
|
530
|
-
!e.parentNode
|
|
531
|
-
? (() => {
|
|
532
|
-
console.warn('Cannot access the .textContent of a HTMLElement that hasnt been inserted yet', e);
|
|
533
|
-
console.trace(e, this);
|
|
534
|
-
console.info('If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!', 'color: blue;');
|
|
535
|
-
})()
|
|
536
|
-
: e.innerText = text;
|
|
537
|
-
});
|
|
538
|
-
return that;
|
|
539
|
-
}
|
|
540
|
-
let t = that.array[0].innerText;
|
|
541
|
-
return t ?? '';
|
|
542
|
-
}
|
|
543
|
-
toggleClass(...classes) {
|
|
544
|
-
classes = words(classes);
|
|
545
|
-
this.forEach(element => {
|
|
546
|
-
element.classList.toggle(...classes);
|
|
547
|
-
});
|
|
548
|
-
return this;
|
|
549
|
-
}
|
|
550
|
-
trigger(eventName, data = {}, bubbles = false, cancelable = false, composed = false) {
|
|
551
|
-
let that = this, ev, options = { bubbles, cancelable, composed }, eventNames = eventName.indexOf(' ') > -1
|
|
552
|
-
? eventName.split(' ')
|
|
553
|
-
: [eventName];
|
|
554
|
-
that.#set.forEach((e) => {
|
|
555
|
-
eventNames.forEach(function (n) {
|
|
556
|
-
ev = new Event(n, options);
|
|
557
|
-
ev.data = data;
|
|
558
|
-
e.dispatchEvent(ev);
|
|
559
|
-
});
|
|
560
|
-
});
|
|
561
|
-
return that;
|
|
562
|
-
}
|
|
563
|
-
val(p1, p2) {
|
|
564
|
-
if (!this.length)
|
|
565
|
-
return this;
|
|
566
|
-
const that = this;
|
|
567
|
-
let result, handlers = getInputHandlers(that.array[0]);
|
|
568
|
-
if (!p1) {
|
|
569
|
-
result = Object.assign({}, handlers);
|
|
570
|
-
}
|
|
571
|
-
else {
|
|
572
|
-
if (isObject(p1)) {
|
|
573
|
-
Object.assign(handlers, p1);
|
|
574
|
-
result = that;
|
|
575
|
-
}
|
|
576
|
-
else if (typeof p1 === 'string') {
|
|
577
|
-
if (p2 === undefined) {
|
|
578
|
-
result = handlers[p1];
|
|
579
|
-
}
|
|
580
|
-
else {
|
|
581
|
-
handlers[p1] = p2;
|
|
582
|
-
result = that;
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
return result;
|
|
587
|
-
}
|
|
588
|
-
values(values) {
|
|
589
|
-
const that = this, holder = {};
|
|
590
|
-
let data = {};
|
|
591
|
-
if (!that.length) {
|
|
592
|
-
console.warn('no dom selection to search inputs in');
|
|
593
|
-
return {};
|
|
594
|
-
}
|
|
595
|
-
let handlers = getInputHandlers(that.array[0]);
|
|
596
|
-
Object.keys(handlers).forEach((key) => {
|
|
597
|
-
data[key] = handlers[key];
|
|
598
|
-
});
|
|
599
|
-
if (Object.keys(data).length === 0) {
|
|
600
|
-
console.warn('no inputs in this dom selection', that.array[0], data);
|
|
601
|
-
}
|
|
602
|
-
if (values) {
|
|
603
|
-
Object
|
|
604
|
-
.keys(values)
|
|
605
|
-
.forEach(key => {
|
|
606
|
-
if (handlers.hasOwnProperty(key)) {
|
|
607
|
-
console.log('key found', key);
|
|
608
|
-
handlers[key] = values[key];
|
|
609
|
-
}
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
return structuredClone(Object.assign(handlers));
|
|
613
|
-
}
|
|
614
|
-
at(index) {
|
|
615
|
-
return $d(this.array.at(index));
|
|
616
|
-
}
|
|
617
|
-
concat(items) {
|
|
618
|
-
let that = this, arr = items instanceof DomSelector
|
|
619
|
-
? items.array
|
|
620
|
-
: items;
|
|
621
|
-
arr.forEach((e) => {
|
|
622
|
-
that.#set.add(e);
|
|
623
|
-
});
|
|
624
|
-
return that;
|
|
625
|
-
}
|
|
626
|
-
entries() {
|
|
627
|
-
return this.array.entries();
|
|
628
|
-
}
|
|
629
|
-
every(predicate, thisArg) {
|
|
630
|
-
return this.array.every(predicate, thisArg);
|
|
631
|
-
}
|
|
632
|
-
filter(predicate, thisArg) {
|
|
633
|
-
this.#set = new Set(this.array.filter(predicate, thisArg));
|
|
634
|
-
return this;
|
|
635
|
-
}
|
|
636
|
-
forEach(predicate, thisArg) {
|
|
637
|
-
this.array.forEach(predicate, thisArg);
|
|
638
|
-
return this;
|
|
639
|
-
}
|
|
640
|
-
includes(item) {
|
|
641
|
-
return this.array.indexOf(item, 0) !== -1;
|
|
642
|
-
}
|
|
643
|
-
indexOf(item, start) {
|
|
644
|
-
return this.array.indexOf(item, start);
|
|
645
|
-
}
|
|
646
|
-
map(predicate, thisArg) {
|
|
647
|
-
return this.array.map(predicate, thisArg);
|
|
648
|
-
}
|
|
649
|
-
pop() {
|
|
650
|
-
return this.array.pop();
|
|
651
|
-
}
|
|
652
|
-
push(...items) {
|
|
653
|
-
items.forEach((item) => {
|
|
654
|
-
this.#set.add(item);
|
|
655
|
-
});
|
|
656
|
-
return this;
|
|
657
|
-
}
|
|
658
|
-
shift() {
|
|
659
|
-
let that = this, element = that.#set.size ? that.array[0] : undefined;
|
|
660
|
-
if (element) {
|
|
661
|
-
that.#set.delete(element);
|
|
662
|
-
}
|
|
663
|
-
return element;
|
|
664
|
-
}
|
|
665
|
-
slice(start, end) {
|
|
666
|
-
return $d(this.array.slice(start, end));
|
|
667
|
-
}
|
|
668
|
-
some(predicate, thisArg) {
|
|
669
|
-
return this.array.some(predicate, thisArg);
|
|
670
|
-
}
|
|
671
|
-
splice(start, deleteCount, ...items) {
|
|
672
|
-
let that = this, arr = that.array;
|
|
673
|
-
arr.splice(start, deleteCount, ...items);
|
|
674
|
-
return $d(arr);
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
;
|
|
678
|
-
class TbSelector {
|
|
679
|
-
#set = new Set();
|
|
680
|
-
get set() {
|
|
681
|
-
return this.#set;
|
|
682
|
-
}
|
|
683
|
-
get array() {
|
|
684
|
-
return Array.from(this.#set);
|
|
685
|
-
}
|
|
686
|
-
set set(set) {
|
|
687
|
-
this.#set = set;
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
get length() {
|
|
691
|
-
return this.#set.size;
|
|
692
|
-
}
|
|
693
|
-
set length(value) {
|
|
694
|
-
}
|
|
695
|
-
constructor(selection, element = document.body) {
|
|
696
|
-
if (!selection) {
|
|
697
|
-
return this;
|
|
698
|
-
}
|
|
699
|
-
$d(selection, element).forEach((e) => {
|
|
700
|
-
$t(e).forEach((t) => {
|
|
701
|
-
this.#set.add(t);
|
|
702
|
-
});
|
|
703
|
-
});
|
|
704
|
-
}
|
|
705
|
-
$d(selection, element = document.body) {
|
|
706
|
-
let result = new DomSelector(), set = new Set(), compare = !!selection || false, compareSelection = new Set();
|
|
707
|
-
if (compare) {
|
|
708
|
-
compareSelection = $d(selection, element).set;
|
|
709
|
-
}
|
|
710
|
-
this.#set.forEach((e) => {
|
|
711
|
-
if (!compare || compareSelection.has(e._tg)) {
|
|
712
|
-
set.add(e._tg);
|
|
713
|
-
}
|
|
714
|
-
});
|
|
715
|
-
result.set = set;
|
|
716
|
-
return result;
|
|
717
|
-
}
|
|
718
|
-
children(nameSpace) {
|
|
719
|
-
let that = this, set = new Set();
|
|
720
|
-
that.#set.forEach((e) => {
|
|
721
|
-
e.children(nameSpace).forEach((tb) => {
|
|
722
|
-
set.add(tb);
|
|
723
|
-
});
|
|
724
|
-
});
|
|
725
|
-
that.#set = set;
|
|
726
|
-
return that;
|
|
727
|
-
}
|
|
728
|
-
descendants(nameSpace) {
|
|
729
|
-
let that = this, set = new Set();
|
|
730
|
-
that.#set.forEach((e) => {
|
|
731
|
-
e.descendants(nameSpace).forEach((tb) => {
|
|
732
|
-
set.add(tb);
|
|
733
|
-
});
|
|
734
|
-
});
|
|
735
|
-
that.#set = set;
|
|
736
|
-
return that;
|
|
737
|
-
}
|
|
738
|
-
first(nameSpace) {
|
|
739
|
-
let that = this, set = new Set();
|
|
740
|
-
that.#set.forEach((e) => {
|
|
741
|
-
e
|
|
742
|
-
.parent()
|
|
743
|
-
.children()
|
|
744
|
-
.$d()
|
|
745
|
-
.first()
|
|
746
|
-
.$t()
|
|
747
|
-
.forEach((tb) => {
|
|
748
|
-
set.add(tb);
|
|
749
|
-
});
|
|
750
|
-
});
|
|
751
|
-
that.#set = set;
|
|
752
|
-
if (nameSpace) {
|
|
753
|
-
that.filter((tb) => tb.nameSpace = nameSpace);
|
|
754
|
-
}
|
|
755
|
-
return that;
|
|
756
|
-
}
|
|
757
|
-
has(element) {
|
|
758
|
-
return this.#set.has(element);
|
|
759
|
-
}
|
|
760
|
-
last(nameSpace) {
|
|
761
|
-
let that = this, set = new Set();
|
|
762
|
-
that.#set.forEach((e) => {
|
|
763
|
-
e
|
|
764
|
-
.parent()
|
|
765
|
-
.children()
|
|
766
|
-
.$d()
|
|
767
|
-
.last()
|
|
768
|
-
.$t()
|
|
769
|
-
.forEach((tb) => {
|
|
770
|
-
set.add(tb);
|
|
771
|
-
});
|
|
772
|
-
});
|
|
773
|
-
that.#set = set;
|
|
774
|
-
if (nameSpace) {
|
|
775
|
-
that.filter((e) => e.nameSpace = nameSpace);
|
|
776
|
-
}
|
|
777
|
-
return that;
|
|
778
|
-
}
|
|
779
|
-
next(nameSpace) {
|
|
780
|
-
let that = this, set = new Set();
|
|
781
|
-
that.#set.forEach((e) => {
|
|
782
|
-
let elements = new Set(), element;
|
|
783
|
-
element = e._tg;
|
|
784
|
-
while (element.nextElementSibling !== null) {
|
|
785
|
-
element = element.nextElementSibling;
|
|
786
|
-
elements.add(element);
|
|
787
|
-
}
|
|
788
|
-
$t([...elements])
|
|
789
|
-
.$d()
|
|
790
|
-
.first()
|
|
791
|
-
.$t()
|
|
792
|
-
.forEach((tb) => {
|
|
793
|
-
set.add(tb);
|
|
794
|
-
});
|
|
795
|
-
});
|
|
796
|
-
that.#set = set;
|
|
797
|
-
if (nameSpace) {
|
|
798
|
-
that.filter((e) => e.nameSpace = nameSpace);
|
|
799
|
-
}
|
|
800
|
-
return that;
|
|
801
|
-
}
|
|
802
|
-
ns(nameSpace) {
|
|
803
|
-
return this.filter((tb) => tb.nameSpace === nameSpace);
|
|
804
|
-
}
|
|
805
|
-
off(name, cb) {
|
|
806
|
-
let that = this, eventNames = name.indexOf(' ') > -1
|
|
807
|
-
? name.split(' ').filter((s) => s !== '')
|
|
808
|
-
: [name];
|
|
809
|
-
that.$d().array.forEach((e) => {
|
|
810
|
-
eventNames.forEach(function (n) {
|
|
811
|
-
removeListener(e, `[TB]${n}`, cb);
|
|
812
|
-
});
|
|
813
|
-
});
|
|
814
|
-
return that;
|
|
815
|
-
}
|
|
816
|
-
on(name, cb, once = false) {
|
|
817
|
-
let that = this, eventNames = name.indexOf(' ') > -1
|
|
818
|
-
? name.split(' ').filter((s) => s !== '')
|
|
819
|
-
: [name];
|
|
820
|
-
function wrapper() { wrapper.cb.apply(that, Array.from(arguments)); }
|
|
821
|
-
;
|
|
822
|
-
wrapper.cb = cb;
|
|
823
|
-
that.forEach((tb) => {
|
|
824
|
-
eventNames.forEach(function (n) {
|
|
825
|
-
addListener(tb._tg, `[TB]${n}`, wrapper, false, once);
|
|
826
|
-
});
|
|
827
|
-
});
|
|
828
|
-
return wrapper;
|
|
829
|
-
}
|
|
830
|
-
one(name, cb) {
|
|
831
|
-
let that = this, eventNames = name.indexOf(' ') > -1
|
|
832
|
-
? name.split(' ').filter((s) => s !== '')
|
|
833
|
-
: [name];
|
|
834
|
-
function wrapper() { wrapper.cb.apply(that, Array.from(arguments)); }
|
|
835
|
-
;
|
|
836
|
-
wrapper.cb = cb;
|
|
837
|
-
that.forEach((tb) => {
|
|
838
|
-
eventNames.forEach(function (n) {
|
|
839
|
-
addListener(tb._tg, `[TB]${n}`, wrapper, false, true);
|
|
840
|
-
});
|
|
841
|
-
});
|
|
842
|
-
return wrapper;
|
|
843
|
-
}
|
|
844
|
-
parent(nameSpace) {
|
|
845
|
-
let that = this, set = new Set();
|
|
846
|
-
that.#set.forEach((e) => {
|
|
847
|
-
e.parent(nameSpace).forEach((tb) => {
|
|
848
|
-
set.add(tb);
|
|
849
|
-
});
|
|
850
|
-
});
|
|
851
|
-
that.#set = set;
|
|
852
|
-
return that;
|
|
853
|
-
}
|
|
854
|
-
parents(nameSpace) {
|
|
855
|
-
let that = this, set = new Set();
|
|
856
|
-
that.#set.forEach((e) => {
|
|
857
|
-
e.parents(nameSpace).forEach((tb) => {
|
|
858
|
-
set.add(tb);
|
|
859
|
-
});
|
|
860
|
-
});
|
|
861
|
-
that.#set = set;
|
|
862
|
-
return that;
|
|
863
|
-
}
|
|
864
|
-
prev(nameSpace) {
|
|
865
|
-
let that = this, set = new Set();
|
|
866
|
-
that.#set.forEach((e) => {
|
|
867
|
-
let elements = new Set(), element;
|
|
868
|
-
element = e._tg;
|
|
869
|
-
while (element.previousElementSibling !== null) {
|
|
870
|
-
element = element.previousElementSibling;
|
|
871
|
-
elements.add(element);
|
|
872
|
-
}
|
|
873
|
-
$t([...elements])
|
|
874
|
-
.$d()
|
|
875
|
-
.last()
|
|
876
|
-
.$t()
|
|
877
|
-
.forEach((tb) => {
|
|
878
|
-
set.add(tb);
|
|
879
|
-
});
|
|
880
|
-
});
|
|
881
|
-
that.#set = set;
|
|
882
|
-
if (nameSpace) {
|
|
883
|
-
that.filter((e) => e.nameSpace = nameSpace);
|
|
884
|
-
}
|
|
885
|
-
return that;
|
|
886
|
-
}
|
|
887
|
-
trigger(ev, data = {}, bubble = 'l') {
|
|
888
|
-
let that = this;
|
|
889
|
-
that.forEach((tb) => {
|
|
890
|
-
tb.trigger(ev, data, bubble);
|
|
891
|
-
});
|
|
892
|
-
return that;
|
|
893
|
-
}
|
|
894
|
-
at(index) {
|
|
895
|
-
return $t(this.array.at(index));
|
|
896
|
-
}
|
|
897
|
-
concat(items) {
|
|
898
|
-
let that = this;
|
|
899
|
-
items.forEach((tb) => {
|
|
900
|
-
that.#set.add(tb);
|
|
901
|
-
});
|
|
902
|
-
return that;
|
|
903
|
-
}
|
|
904
|
-
entries() {
|
|
905
|
-
return this.array.entries();
|
|
906
|
-
}
|
|
907
|
-
every(predicate, thisArg) {
|
|
908
|
-
return this.array.every(predicate, thisArg);
|
|
909
|
-
}
|
|
910
|
-
filter(predicate, thisArg) {
|
|
911
|
-
return $t(this.array.filter(predicate, thisArg));
|
|
912
|
-
}
|
|
913
|
-
forEach(predicate, thisArg) {
|
|
914
|
-
let that = this;
|
|
915
|
-
that.array.forEach(predicate, thisArg);
|
|
916
|
-
return that;
|
|
917
|
-
}
|
|
918
|
-
includes(item) {
|
|
919
|
-
return this.array.indexOf(item) !== -1;
|
|
920
|
-
}
|
|
921
|
-
indexOf(item, start) {
|
|
922
|
-
return this.array.indexOf(item, start);
|
|
923
|
-
}
|
|
924
|
-
map(predicate, thisArg) {
|
|
925
|
-
return this.array.map(predicate, thisArg);
|
|
926
|
-
}
|
|
927
|
-
pop() {
|
|
928
|
-
let that = this, arr = that.array, result = arr.pop();
|
|
929
|
-
that.#set = new Set(arr);
|
|
930
|
-
return result;
|
|
931
|
-
}
|
|
932
|
-
push(item) {
|
|
933
|
-
let that = this;
|
|
934
|
-
that.#set.add(item);
|
|
935
|
-
return that;
|
|
936
|
-
}
|
|
937
|
-
shift() {
|
|
938
|
-
let that = this, first = this.array.shift();
|
|
939
|
-
that.#set.delete(first);
|
|
940
|
-
return first;
|
|
941
|
-
}
|
|
942
|
-
slice(start, end) {
|
|
943
|
-
return $t(this.array.slice(start, end));
|
|
944
|
-
}
|
|
945
|
-
some(predicate, thisArg) {
|
|
946
|
-
return this.array.some(predicate, thisArg);
|
|
947
|
-
}
|
|
948
|
-
splice(start, deleteCount, ...items) {
|
|
949
|
-
let that = this, arr = that.array, result = arr.splice(start, deleteCount, ...items);
|
|
950
|
-
return $t(result);
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
;
|
|
954
|
-
export const $d = (selection, element = document) => {
|
|
955
|
-
let set = new Set();
|
|
956
|
-
if (selection instanceof Array) {
|
|
957
|
-
selection.forEach(value => {
|
|
958
|
-
$d(value, element).forEach(n => {
|
|
959
|
-
set.add(n);
|
|
960
|
-
});
|
|
961
|
-
});
|
|
962
|
-
return new DomSelector([...set]);
|
|
963
|
-
}
|
|
964
|
-
else {
|
|
965
|
-
return new DomSelector(selection, element);
|
|
966
|
-
}
|
|
967
|
-
};
|
|
968
|
-
export const $t = (selection, element = document) => {
|
|
969
|
-
return $d(selection, element).$t();
|
|
970
|
-
};
|
|
971
|
-
//# sourceMappingURL=selectors.js.map
|