@twobirds/microcomponents 0.0.83 → 0.0.85

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.
Files changed (202) hide show
  1. package/README.md +22 -6
  2. package/assets/documentation/MC.md +60 -81
  3. package/assets/documentation/elements.md +6 -9
  4. package/assets/documentation/observables.md +97 -11
  5. package/assets/test/test.html +1 -1
  6. package/dist/MC.d.ts +14 -16
  7. package/dist/MC.d.ts.map +1 -1
  8. package/dist/MC.js +150 -218
  9. package/dist/MC.min.js +164 -308
  10. package/dist/MC.ts +213 -319
  11. package/dist/elements.d.ts.map +1 -1
  12. package/dist/elements.js +10 -4
  13. package/dist/elements.min.js +1 -1
  14. package/dist/elements.ts +17 -4
  15. package/dist/formValues.js +2 -2
  16. package/dist/formValues.min.js +1 -1
  17. package/dist/formValues.ts +3 -3
  18. package/dist/microcomponents.d.ts +0 -1
  19. package/dist/microcomponents.d.ts.map +1 -1
  20. package/dist/microcomponents.js +0 -1
  21. package/dist/microcomponents.min.js +1 -1
  22. package/dist/microcomponents.ts +1 -1
  23. package/dist/observables.d.ts.map +1 -1
  24. package/dist/observables.js +14 -12
  25. package/dist/observables.min.js +1 -1
  26. package/dist/observables.ts +32 -32
  27. package/package.json +1 -1
  28. package/public/MC.d.ts +14 -16
  29. package/public/MC.d.ts.map +1 -1
  30. package/public/MC.js +150 -218
  31. package/public/MC.js.map +1 -1
  32. package/public/MC.min.js +164 -308
  33. package/public/MC.ts +213 -319
  34. package/public/documentation/MC.md +60 -81
  35. package/public/documentation/elements.md +6 -9
  36. package/public/documentation/observables.md +97 -11
  37. package/public/elements.d.ts.map +1 -1
  38. package/public/elements.js +10 -4
  39. package/public/elements.js.map +1 -1
  40. package/public/elements.min.js +1 -1
  41. package/public/elements.ts +17 -4
  42. package/public/formValues.js +2 -2
  43. package/public/formValues.js.map +1 -1
  44. package/public/formValues.min.js +1 -1
  45. package/public/formValues.ts +3 -3
  46. package/public/microcomponents.d.ts +0 -1
  47. package/public/microcomponents.d.ts.map +1 -1
  48. package/public/microcomponents.js +0 -1
  49. package/public/microcomponents.js.map +1 -1
  50. package/public/microcomponents.min.js +1 -1
  51. package/public/microcomponents.ts +1 -1
  52. package/public/observables.d.ts.map +1 -1
  53. package/public/observables.js +14 -12
  54. package/public/observables.js.map +1 -1
  55. package/public/observables.min.js +1 -1
  56. package/public/observables.ts +32 -32
  57. package/public/src/MC.d.ts +14 -16
  58. package/public/src/MC.d.ts.map +1 -1
  59. package/public/src/MC.js +150 -218
  60. package/public/src/MC.js.map +1 -1
  61. package/public/src/MC.ts +213 -319
  62. package/public/src/elements.d.ts.map +1 -1
  63. package/public/src/elements.js +10 -4
  64. package/public/src/elements.js.map +1 -1
  65. package/public/src/elements.ts +17 -4
  66. package/public/src/formValues.js +2 -2
  67. package/public/src/formValues.js.map +1 -1
  68. package/public/src/formValues.ts +3 -3
  69. package/public/src/microcomponents.d.ts +0 -1
  70. package/public/src/microcomponents.d.ts.map +1 -1
  71. package/public/src/microcomponents.js +0 -1
  72. package/public/src/microcomponents.js.map +1 -1
  73. package/public/src/microcomponents.ts +1 -1
  74. package/public/src/observables.d.ts.map +1 -1
  75. package/public/src/observables.js +14 -12
  76. package/public/src/observables.js.map +1 -1
  77. package/public/src/observables.ts +32 -32
  78. package/public/src/test/test/grandparent.d.ts.map +1 -1
  79. package/public/src/test/test/grandparent.js +1 -1
  80. package/public/src/test/test/grandparent.js.map +1 -1
  81. package/public/src/test/test/grandparent.ts +12 -4
  82. package/public/src/test/test/testform.js +1 -1
  83. package/public/src/test/test/testform.js.map +1 -1
  84. package/public/src/test/test/testform.ts +6 -8
  85. package/public/src/test/test.js +6 -5
  86. package/public/src/test/test.js.map +1 -1
  87. package/public/src/test/test.ts +10 -9
  88. package/public/test/MC.d.ts +14 -16
  89. package/public/test/MC.d.ts.map +1 -1
  90. package/public/test/MC.js +150 -218
  91. package/public/test/MC.min.js +164 -308
  92. package/public/test/MC.ts +213 -319
  93. package/public/test/elements.d.ts.map +1 -1
  94. package/public/test/elements.js +10 -4
  95. package/public/test/elements.min.js +1 -1
  96. package/public/test/elements.ts +17 -4
  97. package/public/test/formValues.js +2 -2
  98. package/public/test/formValues.min.js +1 -1
  99. package/public/test/formValues.ts +3 -3
  100. package/public/test/microcomponents.d.ts +0 -1
  101. package/public/test/microcomponents.d.ts.map +1 -1
  102. package/public/test/microcomponents.js +0 -1
  103. package/public/test/microcomponents.min.js +1 -1
  104. package/public/test/microcomponents.ts +1 -1
  105. package/public/test/observables.d.ts.map +1 -1
  106. package/public/test/observables.js +14 -12
  107. package/public/test/observables.min.js +1 -1
  108. package/public/test/observables.ts +32 -32
  109. package/public/test/test/grandparent.d.ts.map +1 -1
  110. package/public/test/test/grandparent.js +1 -1
  111. package/public/test/test/grandparent.js.map +1 -1
  112. package/public/test/test/grandparent.ts +12 -4
  113. package/public/test/test/testform.js +1 -1
  114. package/public/test/test/testform.js.map +1 -1
  115. package/public/test/test/testform.ts +6 -8
  116. package/public/test/test.html +1 -1
  117. package/public/test/test.js +6 -5
  118. package/public/test/test.js.map +1 -1
  119. package/public/test/test.ts +10 -9
  120. package/public/typedoc/assets/navigation.js +1 -1
  121. package/public/typedoc/assets/search.js +1 -1
  122. package/public/typedoc/classes/MC.DC.html +7 -6
  123. package/public/typedoc/classes/MC.MC.html +3 -6
  124. package/public/typedoc/classes/MC.McBase.html +3 -4
  125. package/public/typedoc/functions/MC.autoload.html +1 -1
  126. package/public/typedoc/functions/MC.off.html +1 -0
  127. package/public/typedoc/functions/{selectors._d.html → MC.on.html} +1 -1
  128. package/public/typedoc/functions/MC.one.html +1 -0
  129. package/public/typedoc/functions/MC.trigger.html +1 -0
  130. package/public/typedoc/functions/elements.defineCE.html +1 -1
  131. package/public/typedoc/functions/elements.getCE.html +1 -1
  132. package/public/typedoc/functions/formValues.formValues.html +1 -1
  133. package/public/typedoc/functions/observables.observe.html +1 -1
  134. package/public/typedoc/index.html +21 -10
  135. package/public/typedoc/interfaces/MC.HTMLMcElement.html +2 -2
  136. package/public/typedoc/modules/MC.html +6 -5
  137. package/public/typedoc/modules/elements.html +1 -1
  138. package/public/typedoc/modules/formValues.html +1 -1
  139. package/public/typedoc/modules/observables.html +1 -1
  140. package/public/typedoc/modules.html +0 -1
  141. package/public/typedoc/types/observables.Observable.html +1 -1
  142. package/src/MC.ts +213 -319
  143. package/src/elements.ts +17 -4
  144. package/src/formValues.ts +3 -3
  145. package/src/microcomponents.ts +1 -1
  146. package/src/observables.ts +32 -32
  147. package/src/test/test/grandparent.ts +12 -4
  148. package/src/test/test/testform.ts +6 -8
  149. package/src/test/test.ts +10 -9
  150. package/tsconfig.json +2 -2
  151. package/typedoc.json +1 -1
  152. package/webpack.config.js +2 -2
  153. package/dist/McEvent.d.ts +0 -15
  154. package/dist/McEvent.d.ts.map +0 -1
  155. package/dist/McEvent.js +0 -71
  156. package/dist/selectors.d.ts +0 -106
  157. package/dist/selectors.d.ts.map +0 -1
  158. package/dist/selectors.js +0 -759
  159. package/dist/selectors.min.js +0 -1
  160. package/public/McEvent.d.ts +0 -15
  161. package/public/McEvent.d.ts.map +0 -1
  162. package/public/McEvent.js +0 -71
  163. package/public/McEvent.js.map +0 -1
  164. package/public/selectors.d.ts +0 -106
  165. package/public/selectors.d.ts.map +0 -1
  166. package/public/selectors.js +0 -759
  167. package/public/selectors.js.map +0 -1
  168. package/public/selectors.min.js +0 -1
  169. package/public/src/McEvent.d.ts +0 -15
  170. package/public/src/McEvent.d.ts.map +0 -1
  171. package/public/src/McEvent.js +0 -71
  172. package/public/src/McEvent.js.map +0 -1
  173. package/public/src/selectors.d.ts +0 -106
  174. package/public/src/selectors.d.ts.map +0 -1
  175. package/public/src/selectors.js +0 -759
  176. package/public/src/selectors.js.map +0 -1
  177. package/public/test/McEvent.d.ts +0 -15
  178. package/public/test/McEvent.d.ts.map +0 -1
  179. package/public/test/McEvent.js +0 -71
  180. package/public/test/McEvent.ts +0 -96
  181. package/public/test/selectors.d.ts +0 -106
  182. package/public/test/selectors.d.ts.map +0 -1
  183. package/public/test/selectors.js +0 -759
  184. package/public/test/selectors.min.js +0 -1
  185. package/public/test/selectors.ts +0 -1269
  186. package/public/typedoc/classes/MC.McEvent.html +0 -9
  187. package/public/typedoc/functions/MC.addListener.html +0 -1
  188. package/public/typedoc/functions/MC.removeListener.html +0 -1
  189. package/public/typedoc/functions/selectors._t.html +0 -1
  190. package/public/typedoc/interfaces/selectors.DSelector.html +0 -48
  191. package/public/typedoc/interfaces/selectors.TSelector.html +0 -34
  192. package/public/typedoc/modules/selectors.html +0 -7
  193. package/public/typedoc/types/selectors.selection.html +0 -1
  194. package/public/typedoc/types/selectors.singleSelector.html +0 -1
  195. package/src/McEvent.ts +0 -96
  196. package/src/selectors.ts +0 -1269
  197. /package/{dist/McEvent.ts → public/McEvent._ts} +0 -0
  198. /package/{dist/selectors.ts → public/selectors._ts} +0 -0
  199. /package/public/{McEvent.ts → src/McEvent._ts} +0 -0
  200. /package/public/{selectors.ts → src/selectors._ts} +0 -0
  201. /package/{public/src/McEvent.ts → src/McEvent._ts} +0 -0
  202. /package/{public/src/selectors.ts → src/selectors._ts} +0 -0
package/dist/selectors.js DELETED
@@ -1,759 +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
- class DomSelector {
19
- #set = new Set();
20
- get set() {
21
- return this.#set;
22
- }
23
- get array() {
24
- return Array.from(this.#set);
25
- }
26
- set set(set) {
27
- this.#set = set;
28
- return;
29
- }
30
- get length() {
31
- return this.#set.size;
32
- }
33
- constructor(selection, element = document.body) {
34
- let that = this, undefinedTags = new Set();
35
- if (!selection) {
36
- return that;
37
- }
38
- }
39
- $t(nameSpace) {
40
- let result = new TbSelector();
41
- this.#set.forEach((e) => {
42
- if (e._mc) {
43
- Object.values(e._mc).forEach((mc) => {
44
- result.set.add(mc);
45
- });
46
- }
47
- });
48
- if (nameSpace) {
49
- result.filter(mc => mc.nameSpace === nameSpace);
50
- }
51
- return result;
52
- }
53
- add(selection, target) {
54
- let that = this;
55
- $d(selection, target).forEach(element => {
56
- that.#set.add(element);
57
- });
58
- return that;
59
- }
60
- addClass(...classes) {
61
- classes = words(classes);
62
- this.forEach(element => {
63
- element.classList.add(...classes);
64
- });
65
- return this;
66
- }
67
- after(selection, target) {
68
- let that = this, after = $d(selection, target);
69
- ;
70
- if (!after.length)
71
- return that;
72
- after
73
- .first()
74
- .forEach(element => {
75
- that.array.reverse().forEach((e) => {
76
- e.after(element);
77
- });
78
- });
79
- return that;
80
- }
81
- append(selection, target) {
82
- let that = this, addTo = that.array['0'], append = $d(selection, target);
83
- if (addTo) {
84
- append.forEach((e) => {
85
- addTo.append(e);
86
- });
87
- }
88
- return that;
89
- }
90
- appendTo(selection, target) {
91
- let that = this, appendTo = $d(selection, target).array['0'];
92
- if (appendTo) {
93
- that.forEach((e) => {
94
- appendTo.append(e);
95
- });
96
- }
97
- return that;
98
- }
99
- attr(first, second) {
100
- let that = this, attributes = {};
101
- if (!that.length)
102
- return that;
103
- if (!arguments.length) {
104
- Array.from([...that.set][0].attributes).forEach((attribute) => {
105
- attributes[attribute.name] = attribute.value;
106
- });
107
- return attributes;
108
- }
109
- if (typeof first === 'string') {
110
- if (second === undefined) {
111
- return [...that.set][0].getAttribute(first);
112
- }
113
- if (second === null) {
114
- [...that.set].forEach((e) => {
115
- e.removeAttribute(first);
116
- });
117
- return that;
118
- }
119
- if (typeof second === 'object') {
120
- second = JSON.stringify(second);
121
- }
122
- [...that.set].forEach((e) => {
123
- e.setAttribute(first, second);
124
- });
125
- return that;
126
- }
127
- if (typeof first === 'object') {
128
- [...that.set].forEach((e) => {
129
- Object.keys(first).forEach((key) => {
130
- $d(e).attr(key, first.key);
131
- });
132
- });
133
- return that;
134
- }
135
- return that;
136
- }
137
- before(selection, target) {
138
- let that = this, before = $d(selection, target);
139
- ;
140
- if (!before.length)
141
- return that;
142
- before
143
- .first()
144
- .forEach(element => {
145
- that.forEach((e) => {
146
- e.before(element);
147
- });
148
- });
149
- return that;
150
- }
151
- children(selection, rootNode) {
152
- let that = this, set = new Set();
153
- that.#set.forEach((e) => {
154
- Array.from(e.children).forEach((c) => {
155
- set.add(c);
156
- });
157
- });
158
- that = $d([...set]);
159
- if (selection) {
160
- let compare = $d(selection, rootNode);
161
- that.filter((e) => compare.has(e));
162
- }
163
- return that;
164
- }
165
- descendants(selection, rootNode) {
166
- let that = this, set = new Set();
167
- that.#set.forEach((e) => {
168
- e.querySelectorAll('*').forEach((h) => {
169
- set.add(h);
170
- });
171
- });
172
- that = $d([...set]);
173
- if (selection) {
174
- let compare = $d(selection, rootNode);
175
- that.filter((e) => compare.has(e));
176
- }
177
- return that;
178
- }
179
- empty() {
180
- return this.filter((e) => false);
181
- }
182
- first(selection, rootNode) {
183
- let that = this, set = new Set(), compare = false;
184
- ;
185
- if (selection) {
186
- compare = $d(selection, rootNode);
187
- }
188
- that.#set.forEach((e) => {
189
- if (e.parentNode) {
190
- set.add(e.parentNode.children[0]);
191
- }
192
- });
193
- that = $d([...set]);
194
- if (selection) {
195
- that.filter((e) => compare.has(e));
196
- }
197
- return that;
198
- }
199
- has(element) {
200
- return this.#set.has(element);
201
- }
202
- hasClass(...classes) {
203
- classes = words(classes);
204
- return this.every(e => {
205
- return Array.from(e.classList).every(c => e.contains(c));
206
- });
207
- }
208
- html(html) {
209
- let that = this;
210
- if (html) {
211
- that.forEach((e) => {
212
- !e.parentNode
213
- ? (() => {
214
- console.warn('Cannot access the .innerHTML of a HTMLElement that hasnt been inserted yet', e);
215
- console.trace(e, this);
216
- console.info('If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!', 'color: blue;');
217
- })()
218
- : e.innerHTML = html;
219
- });
220
- return that;
221
- }
222
- return that.array[0].innerHTML;
223
- }
224
- last(selection, rootNode) {
225
- let that = this, set = new Set();
226
- that.#set.forEach((e) => {
227
- let siblings = e.parentNode?.children;
228
- if (siblings) {
229
- set.add(Array.from(siblings).at(-1));
230
- }
231
- });
232
- that = $d([...set]);
233
- if (selection) {
234
- let compare = $d(selection, rootNode);
235
- that.filter((e) => compare.has(e));
236
- }
237
- return that;
238
- }
239
- next(selection, rootNode) {
240
- let that = this, set = new Set();
241
- that.#set.forEach((e) => {
242
- let siblings = e.parentNode?.children;
243
- if (siblings) {
244
- let arr = Array.from(siblings), pos = arr.indexOf(e) + 1;
245
- if (pos < arr.length) {
246
- set.add(arr.at(pos));
247
- }
248
- }
249
- });
250
- that = $d([...set]);
251
- if (selection) {
252
- let compare = $d(selection, rootNode);
253
- that.filter((e) => compare.has(e));
254
- }
255
- return that;
256
- }
257
- normalize() {
258
- let that = this;
259
- that.#set.forEach((e) => { e.normalize(); });
260
- return that;
261
- }
262
- off(eventName, cb) {
263
- let that = this, eventNames = eventName.indexOf(' ') > -1
264
- ? eventName.split(' ')
265
- : [eventName];
266
- that.array.forEach((e) => {
267
- eventNames.forEach(function (n) {
268
- removeListener(e, n, cb);
269
- });
270
- });
271
- return that;
272
- }
273
- on(eventName, cb, capture = false, once = false) {
274
- let that = this, eventNames = eventName.indexOf(' ') > -1
275
- ? eventName.split(' ').filter((s) => s !== '')
276
- : [eventName];
277
- function wrapper() { wrapper.cb.apply(that, Array.from(arguments)); }
278
- ;
279
- wrapper.cb = cb;
280
- that.forEach((e) => {
281
- eventNames.forEach(function (n) {
282
- addListener(e, n, wrapper, capture, once);
283
- });
284
- });
285
- return wrapper;
286
- }
287
- one(eventName, cb, capture = false) {
288
- let that = this, eventNames = eventName.indexOf(' ') > -1
289
- ? eventName.split(' ').filter((s) => s !== '')
290
- : [eventName];
291
- function wrapper() { wrapper.cb.apply(that, Array.from(arguments)); }
292
- ;
293
- wrapper.cb = cb;
294
- that.forEach((e) => {
295
- eventNames.forEach(function (n) {
296
- addListener(e, n, wrapper, capture, true);
297
- });
298
- });
299
- return wrapper;
300
- }
301
- parent(selection, rootNode) {
302
- let that = this, set = new Set();
303
- that.#set.forEach((e) => {
304
- if (e.parentNode && e.parentNode.tagName !== 'HTML') {
305
- set.add(e.parentNode);
306
- }
307
- });
308
- that = $d([...set]);
309
- if (selection) {
310
- let compare = $d(selection, rootNode);
311
- that.filter((e) => compare.has(e));
312
- }
313
- return that;
314
- }
315
- ancestors(selection, rootNode) {
316
- let that = this, set = new Set();
317
- that.#set.forEach((e) => {
318
- let current = e;
319
- while (current.parentNode && current.parentNode.tagName !== 'HTML') {
320
- current = current.parentNode;
321
- set.add(current);
322
- }
323
- });
324
- that = $d([...set]);
325
- if (selection) {
326
- let compare = $d(selection, rootNode);
327
- that.filter((e) => compare.has(e));
328
- }
329
- return that;
330
- }
331
- prepend(selection, target) {
332
- let that = this, addTo = that.array['0'], prepend = $d(selection, target);
333
- if (addTo) {
334
- prepend.forEach((e) => {
335
- addTo.prepend(e);
336
- });
337
- }
338
- return that;
339
- }
340
- prev(selection, rootNode) {
341
- let that = this, set = new Set();
342
- that.#set.forEach((e) => {
343
- let siblings = e.parentNode?.children;
344
- if (siblings) {
345
- let arr = Array.from(siblings), pos = arr.indexOf(e) - 1;
346
- if (pos > -1) {
347
- set.add(arr.at(pos));
348
- }
349
- }
350
- });
351
- that = $d([...set]);
352
- if (selection) {
353
- let compare = $d(selection, rootNode);
354
- that.filter((e) => compare.has(e));
355
- }
356
- return that;
357
- }
358
- removeClass(...classes) {
359
- classes = words(classes);
360
- this.forEach(element => {
361
- element.classList.remove(...classes);
362
- });
363
- return this;
364
- }
365
- text(text) {
366
- let that = this;
367
- if (text) {
368
- that.forEach((e) => {
369
- !e.parentNode
370
- ? (() => {
371
- console.warn('Cannot access the .textContent of a HTMLElement that hasnt been inserted yet', e);
372
- console.trace(e, this);
373
- console.info('If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!', 'color: blue;');
374
- })()
375
- : e.innerText = text;
376
- });
377
- return that;
378
- }
379
- let t = that.array[0].innerText;
380
- return t ?? '';
381
- }
382
- toggleClass(...classes) {
383
- classes = words(classes);
384
- this.forEach(element => {
385
- element.classList.toggle(...classes);
386
- });
387
- return this;
388
- }
389
- trigger(eventName, data = {}, bubbles = false, cancelable = false, composed = false) {
390
- let that = this, ev, options = { bubbles, cancelable, composed }, eventNames = eventName.indexOf(' ') > -1
391
- ? eventName.split(' ')
392
- : [eventName];
393
- that.#set.forEach((e) => {
394
- eventNames.forEach(function (n) {
395
- ev = new Event(n, options);
396
- ev.data = data;
397
- e.dispatchEvent(ev);
398
- });
399
- });
400
- return that;
401
- }
402
- at(index) {
403
- return $d(this.array.at(index));
404
- }
405
- concat(items) {
406
- let that = this, arr = items instanceof DomSelector
407
- ? items.array
408
- : items;
409
- arr.forEach((e) => {
410
- that.#set.add(e);
411
- });
412
- return that;
413
- }
414
- entries() {
415
- return this.array.entries();
416
- }
417
- every(predicate, thisArg) {
418
- return this.array.every(predicate, thisArg);
419
- }
420
- filter(predicate, thisArg) {
421
- this.#set = new Set(this.array.filter(predicate, thisArg));
422
- return this;
423
- }
424
- forEach(predicate, thisArg) {
425
- this.array.forEach(predicate, thisArg);
426
- return this;
427
- }
428
- includes(item) {
429
- return this.array.indexOf(item, 0) !== -1;
430
- }
431
- indexOf(item, start) {
432
- return this.array.indexOf(item, start);
433
- }
434
- map(predicate, thisArg) {
435
- return this.array.map(predicate, thisArg);
436
- }
437
- pop() {
438
- return this.array.pop();
439
- }
440
- push(...items) {
441
- items.forEach((item) => {
442
- this.#set.add(item);
443
- });
444
- return this;
445
- }
446
- shift() {
447
- let that = this, element = that.#set.size ? that.array[0] : undefined;
448
- if (element) {
449
- that.#set.delete(element);
450
- }
451
- return element;
452
- }
453
- slice(start, end) {
454
- return $d(this.array.slice(start, end));
455
- }
456
- some(predicate, thisArg) {
457
- return this.array.some(predicate, thisArg);
458
- }
459
- splice(start, deleteCount, ...items) {
460
- let that = this, arr = that.array;
461
- arr.splice(start, deleteCount, ...items);
462
- return $d(arr);
463
- }
464
- }
465
- ;
466
- class TbSelector {
467
- #set = new Set();
468
- get set() {
469
- return this.#set;
470
- }
471
- get array() {
472
- return Array.from(this.#set);
473
- }
474
- set set(set) {
475
- this.#set = set;
476
- return;
477
- }
478
- get length() {
479
- return this.#set.size;
480
- }
481
- set length(value) {
482
- }
483
- constructor(selection, element = document.body) {
484
- if (!selection) {
485
- return this;
486
- }
487
- $d(selection, element).forEach((e) => {
488
- $t(e).forEach((t) => {
489
- this.#set.add(t);
490
- });
491
- });
492
- }
493
- $d(selection, element = document.body) {
494
- let result = new DomSelector(), set = new Set(), compare = !!selection || false, compareSelection = new Set();
495
- if (compare) {
496
- compareSelection = $d(selection, element).set;
497
- }
498
- this.#set.forEach((e) => {
499
- if (!compare || compareSelection.has(e._tg)) {
500
- set.add(e._tg);
501
- }
502
- });
503
- result.set = set;
504
- return result;
505
- }
506
- children(nameSpace) {
507
- let that = this, set = new Set();
508
- that.#set.forEach((e) => {
509
- e.children(nameSpace).forEach((tb) => {
510
- set.add(tb);
511
- });
512
- });
513
- that.#set = set;
514
- return that;
515
- }
516
- descendants(nameSpace) {
517
- let that = this, set = new Set();
518
- that.#set.forEach((e) => {
519
- e.descendants(nameSpace).forEach((tb) => {
520
- set.add(tb);
521
- });
522
- });
523
- that.#set = set;
524
- return that;
525
- }
526
- first(nameSpace) {
527
- let that = this, set = new Set();
528
- that.#set.forEach((e) => {
529
- e
530
- .parent()
531
- .children()
532
- .$d()
533
- .first()
534
- .$t()
535
- .forEach((tb) => {
536
- set.add(tb);
537
- });
538
- });
539
- that.#set = set;
540
- if (nameSpace) {
541
- that.filter((tb) => tb.nameSpace = nameSpace);
542
- }
543
- return that;
544
- }
545
- has(element) {
546
- return this.#set.has(element);
547
- }
548
- last(nameSpace) {
549
- let that = this, set = new Set();
550
- that.#set.forEach((e) => {
551
- e
552
- .parent()
553
- .children()
554
- .$d()
555
- .last()
556
- .$t()
557
- .forEach((tb) => {
558
- set.add(tb);
559
- });
560
- });
561
- that.#set = set;
562
- if (nameSpace) {
563
- that.filter((e) => e.nameSpace = nameSpace);
564
- }
565
- return that;
566
- }
567
- next(nameSpace) {
568
- let that = this, set = new Set();
569
- that.#set.forEach((e) => {
570
- let elements = new Set(), element;
571
- element = e._tg;
572
- while (element.nextElementSibling !== null) {
573
- element = element.nextElementSibling;
574
- elements.add(element);
575
- }
576
- $t([...elements])
577
- .$d()
578
- .first()
579
- .$t()
580
- .forEach((tb) => {
581
- set.add(tb);
582
- });
583
- });
584
- that.#set = set;
585
- if (nameSpace) {
586
- that.filter((e) => e.nameSpace = nameSpace);
587
- }
588
- return that;
589
- }
590
- ns(nameSpace) {
591
- return this.filter((tb) => tb.nameSpace === nameSpace);
592
- }
593
- off(name, cb) {
594
- let that = this, eventNames = name.indexOf(' ') > -1
595
- ? name.split(' ').filter((s) => s !== '')
596
- : [name];
597
- that.$d().array.forEach((e) => {
598
- eventNames.forEach(function (n) {
599
- removeListener(e, `[TB]${n}`, cb);
600
- });
601
- });
602
- return that;
603
- }
604
- on(name, cb, once = false) {
605
- let that = this, eventNames = name.indexOf(' ') > -1
606
- ? name.split(' ').filter((s) => s !== '')
607
- : [name];
608
- function wrapper() { wrapper.cb.apply(that, Array.from(arguments)); }
609
- ;
610
- wrapper.cb = cb;
611
- that.forEach((tb) => {
612
- eventNames.forEach(function (n) {
613
- addListener(tb._tg, `[TB]${n}`, wrapper, false, once);
614
- });
615
- });
616
- return wrapper;
617
- }
618
- one(name, cb) {
619
- let that = this, eventNames = name.indexOf(' ') > -1
620
- ? name.split(' ').filter((s) => s !== '')
621
- : [name];
622
- function wrapper() { wrapper.cb.apply(that, Array.from(arguments)); }
623
- ;
624
- wrapper.cb = cb;
625
- that.forEach((tb) => {
626
- eventNames.forEach(function (n) {
627
- addListener(tb._tg, `[TB]${n}`, wrapper, false, true);
628
- });
629
- });
630
- return wrapper;
631
- }
632
- parent(nameSpace) {
633
- let that = this, set = new Set();
634
- that.#set.forEach((e) => {
635
- e.parent(nameSpace).forEach((tb) => {
636
- set.add(tb);
637
- });
638
- });
639
- that.#set = set;
640
- return that;
641
- }
642
- ancestors(nameSpace) {
643
- let that = this, set = new Set();
644
- that.#set.forEach((e) => {
645
- e.parents(nameSpace).forEach((tb) => {
646
- set.add(tb);
647
- });
648
- });
649
- that.#set = set;
650
- return that;
651
- }
652
- prev(nameSpace) {
653
- let that = this, set = new Set();
654
- that.#set.forEach((e) => {
655
- let elements = new Set(), element;
656
- element = e._tg;
657
- while (element.previousElementSibling !== null) {
658
- element = element.previousElementSibling;
659
- elements.add(element);
660
- }
661
- $t([...elements])
662
- .$d()
663
- .last()
664
- .$t()
665
- .forEach((tb) => {
666
- set.add(tb);
667
- });
668
- });
669
- that.#set = set;
670
- if (nameSpace) {
671
- that.filter((e) => e.nameSpace = nameSpace);
672
- }
673
- return that;
674
- }
675
- trigger(ev, data = {}, bubble = 'l') {
676
- let that = this;
677
- that.forEach((tb) => {
678
- tb.trigger(ev, data, bubble);
679
- });
680
- return that;
681
- }
682
- at(index) {
683
- return $t(this.array.at(index));
684
- }
685
- concat(items) {
686
- let that = this;
687
- items.forEach((tb) => {
688
- that.#set.add(tb);
689
- });
690
- return that;
691
- }
692
- entries() {
693
- return this.array.entries();
694
- }
695
- every(predicate, thisArg) {
696
- return this.array.every(predicate, thisArg);
697
- }
698
- filter(predicate, thisArg) {
699
- return $t(this.array.filter(predicate, thisArg));
700
- }
701
- forEach(predicate, thisArg) {
702
- let that = this;
703
- that.array.forEach(predicate, thisArg);
704
- return that;
705
- }
706
- includes(item) {
707
- return this.array.indexOf(item) !== -1;
708
- }
709
- indexOf(item, start) {
710
- return this.array.indexOf(item, start);
711
- }
712
- map(predicate, thisArg) {
713
- return this.array.map(predicate, thisArg);
714
- }
715
- pop() {
716
- let that = this, arr = that.array, result = arr.pop();
717
- that.#set = new Set(arr);
718
- return result;
719
- }
720
- push(item) {
721
- let that = this;
722
- that.#set.add(item);
723
- return that;
724
- }
725
- shift() {
726
- let that = this, first = this.array.shift();
727
- that.#set.delete(first);
728
- return first;
729
- }
730
- slice(start, end) {
731
- return $t(this.array.slice(start, end));
732
- }
733
- some(predicate, thisArg) {
734
- return this.array.some(predicate, thisArg);
735
- }
736
- splice(start, deleteCount, ...items) {
737
- let that = this, arr = that.array, result = arr.splice(start, deleteCount, ...items);
738
- return $t(result);
739
- }
740
- }
741
- ;
742
- export const $d = (selection, element = document) => {
743
- let set = new Set();
744
- if (selection instanceof Array) {
745
- selection.forEach(value => {
746
- $d(value, element).forEach(n => {
747
- set.add(n);
748
- });
749
- });
750
- return new DomSelector([...set]);
751
- }
752
- else {
753
- return new DomSelector(selection, element);
754
- }
755
- };
756
- export const $t = (selection, element = document) => {
757
- return $d(selection, element).$t();
758
- };
759
- //# sourceMappingURL=selectors.js.map