@iamproperty/components 7.8.1 → 7.8.2--beta2

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 (164) hide show
  1. package/assets/css/components/card.component.css +1 -1
  2. package/assets/css/components/card.component.css.map +1 -1
  3. package/assets/css/components/card.module.css +1 -1
  4. package/assets/css/components/card.module.css.map +1 -1
  5. package/assets/css/components/filter-card.component.css +1 -1
  6. package/assets/css/components/filter-card.component.css.map +1 -1
  7. package/assets/css/components/modal.component.css +1 -1
  8. package/assets/css/components/modal.component.css.map +1 -1
  9. package/assets/css/components/record-card.component.css +1 -1
  10. package/assets/css/components/record-card.component.css.map +1 -1
  11. package/assets/css/components/video-card.component.css +1 -1
  12. package/assets/css/components/video-card.component.css.map +1 -1
  13. package/assets/css/components/video-modal.component.css +1 -1
  14. package/assets/css/components/video-modal.component.css.map +1 -1
  15. package/assets/js/components/accordion/accordion.component.min.js +1 -1
  16. package/assets/js/components/actionbar/actionbar.component.min.js +1 -1
  17. package/assets/js/components/address-lookup/address-lookup.component.min.js +3 -3
  18. package/assets/js/components/address-lookup/address-lookup.component.min.js.map +1 -1
  19. package/assets/js/components/advanced-select/advanced-select.component.min.js +3 -3
  20. package/assets/js/components/advanced-select/advanced-select.component.min.js.map +1 -1
  21. package/assets/js/components/applied-filters/applied-filters.component.min.js +1 -1
  22. package/assets/js/components/banner/banner.component.min.js +1 -1
  23. package/assets/js/components/barchart/barchart.component.min.js +1 -1
  24. package/assets/js/components/bento-grid/bento-grid.component.min.js +1 -1
  25. package/assets/js/components/bone/bone.component.min.js +1 -1
  26. package/assets/js/components/button/button.component.min.js +1 -1
  27. package/assets/js/components/calendar/calendar.component.min.js +1 -1
  28. package/assets/js/components/card/card.component.min.js +7 -7
  29. package/assets/js/components/card/card.component.min.js.map +1 -1
  30. package/assets/js/components/carousel/carousel.component.min.js +1 -1
  31. package/assets/js/components/collapsible-side/collapsible-side.component.min.js +1 -1
  32. package/assets/js/components/config/config.component.min.js +1 -1
  33. package/assets/js/components/content/content.component.min.js +1 -1
  34. package/assets/js/components/darkmode/darkmode.component.min.js +1 -1
  35. package/assets/js/components/doughnutchart/doughnutchart.component.min.js +1 -1
  36. package/assets/js/components/fileupload/fileupload.component.min.js +1 -1
  37. package/assets/js/components/filter-card/filter-card.component.min.js +5 -5
  38. package/assets/js/components/filter-card/filter-card.component.min.js.map +1 -1
  39. package/assets/js/components/filterlist/filterlist.component.min.js +1 -1
  40. package/assets/js/components/form/form.component.min.js +1 -1
  41. package/assets/js/components/header/header.component.min.js +1 -1
  42. package/assets/js/components/inline-edit/inline-edit.component.min.js +1 -1
  43. package/assets/js/components/input/input.component.min.js +1 -1
  44. package/assets/js/components/input-range/input-range.component.min.js +1 -1
  45. package/assets/js/components/marketing/marketing.component.min.js +1 -1
  46. package/assets/js/components/menu/menu.component.min.js +1 -1
  47. package/assets/js/components/milestone/milestone.component.min.js +1 -1
  48. package/assets/js/components/milestone-group/milestone-group.component.min.js +1 -1
  49. package/assets/js/components/modal/modal.component.min.js +2 -2
  50. package/assets/js/components/multi-step/multi-step.component.min.js +1 -1
  51. package/assets/js/components/multi-step-modal/multi-step-modal.component.min.js +1 -1
  52. package/assets/js/components/multiselect/multiselect.component.js +17 -5
  53. package/assets/js/components/multiselect/multiselect.component.min.js +3 -3
  54. package/assets/js/components/multiselect/multiselect.component.min.js.map +1 -1
  55. package/assets/js/components/nav/nav.component.min.js +1 -1
  56. package/assets/js/components/notification/notification.component.min.js +1 -1
  57. package/assets/js/components/pagination/pagination.component.min.js +1 -1
  58. package/assets/js/components/password/password.component.min.js +1 -1
  59. package/assets/js/components/popover/popover.component.min.js +1 -1
  60. package/assets/js/components/rank/rank.component.min.js +1 -1
  61. package/assets/js/components/rankings/rankings.component.min.js +1 -1
  62. package/assets/js/components/rating/rating.component.min.js +1 -1
  63. package/assets/js/components/record-card/record-card.component.min.js +5 -5
  64. package/assets/js/components/record-card/record-card.component.min.js.map +1 -1
  65. package/assets/js/components/search/search.component.js +2 -2
  66. package/assets/js/components/search/search.component.min.js +5 -5
  67. package/assets/js/components/search/search.component.min.js.map +1 -1
  68. package/assets/js/components/skeleton/skeleton.component.min.js +1 -1
  69. package/assets/js/components/slider/slider.component.min.js +1 -1
  70. package/assets/js/components/split-button/split-button.component.min.js +1 -1
  71. package/assets/js/components/std-address-lookup/std-address-lookup.component.min.js +4 -4
  72. package/assets/js/components/std-address-lookup/std-address-lookup.component.min.js.map +1 -1
  73. package/assets/js/components/std-nav/std-nav.component.min.js +1 -1
  74. package/assets/js/components/std-nav-standalone/std-nav-standalone.component.min.js +1 -1
  75. package/assets/js/components/table/table.component.min.js +1 -1
  76. package/assets/js/components/table-ajax/table-ajax.component.min.js +1 -1
  77. package/assets/js/components/table-basic/table-basic.component.min.js +1 -1
  78. package/assets/js/components/table-no-submit/table-no-submit.component.min.js +1 -1
  79. package/assets/js/components/table-submit/table-submit.component.min.js +1 -1
  80. package/assets/js/components/tabs/tabs.component.min.js +1 -1
  81. package/assets/js/components/tag/tag.component.min.js +1 -1
  82. package/assets/js/components/tooltip/tooltip.component.min.js +1 -1
  83. package/assets/js/components/video/video.component.min.js +1 -1
  84. package/assets/js/components/video-card/video-card.component.min.js +6 -6
  85. package/assets/js/components/video-card/video-card.component.min.js.map +1 -1
  86. package/assets/js/components/video-modal/video-modal.component.min.js +2 -2
  87. package/assets/js/components/word-count/word-count.component.min.js +1 -1
  88. package/assets/js/modules/advanced-select.js +6 -3
  89. package/assets/js/modules/advanced-select.test.js +28 -0
  90. package/assets/js/modules/applied-filters.test.js +21 -0
  91. package/assets/js/modules/card.module.js +3 -2
  92. package/assets/js/modules/card.module.test.js +20 -0
  93. package/assets/js/modules/carousel.test.js +18 -0
  94. package/assets/js/modules/chart.module.test.js +22 -0
  95. package/assets/js/modules/chart.test.js +15 -0
  96. package/assets/js/modules/content.test.js +20 -0
  97. package/assets/js/modules/data-layer.test.js +12 -0
  98. package/assets/js/modules/dialogs.test.js +13 -0
  99. package/assets/js/modules/drawer.test.js +16 -0
  100. package/assets/js/modules/dropdown.test.js +31 -0
  101. package/assets/js/modules/dynamicEvents.test.js +19 -0
  102. package/assets/js/modules/fileupload.test.js +17 -0
  103. package/assets/js/modules/filterlist.test.js +18 -0
  104. package/assets/js/modules/{helper.test.js → helpers.test.js} +42 -2
  105. package/assets/js/modules/integration-tests.test.js +12 -0
  106. package/assets/js/modules/milestone-group.test.js +18 -0
  107. package/assets/js/modules/milestone.test.js +31 -0
  108. package/assets/js/modules/modal.test.js +18 -0
  109. package/assets/js/modules/nav.test.js +37 -0
  110. package/assets/js/modules/notification.test.js +11 -0
  111. package/assets/js/modules/orderablelist.test.js +15 -0
  112. package/assets/js/modules/pagination.test.js +21 -0
  113. package/assets/js/modules/password.test.js +33 -0
  114. package/assets/js/modules/table.test.js +42 -0
  115. package/assets/js/modules/tabs.test.js +23 -0
  116. package/assets/js/modules/test-dom.js +725 -0
  117. package/assets/js/modules/test-globals.js +7 -0
  118. package/assets/js/modules/test-utils.js +26 -0
  119. package/assets/js/modules/test.js +20 -1
  120. package/assets/js/modules/testimonial.test.js +14 -0
  121. package/assets/js/modules/videos.test.js +37 -0
  122. package/assets/js/scripts.bundle.js +1 -1
  123. package/assets/js/scripts.bundle.min.js +1 -1
  124. package/assets/sass/components/card.module.scss +2 -0
  125. package/assets/sass/components/modal.component.scss +1 -2
  126. package/assets/ts/components/multiselect/multiselect.component.ts +25 -5
  127. package/assets/ts/components/search/search.component.ts +2 -2
  128. package/assets/ts/modules/advanced-select.test.ts +33 -0
  129. package/assets/ts/modules/advanced-select.ts +6 -2
  130. package/assets/ts/modules/applied-filters.test.ts +25 -0
  131. package/assets/ts/modules/card.module.test.ts +24 -0
  132. package/assets/ts/modules/card.module.ts +2 -1
  133. package/assets/ts/modules/carousel.test.ts +27 -0
  134. package/assets/ts/modules/chart.module.test.ts +26 -0
  135. package/assets/ts/modules/chart.test.ts +19 -0
  136. package/assets/ts/modules/content.test.ts +24 -0
  137. package/assets/ts/modules/data-layer.test.ts +15 -0
  138. package/assets/ts/modules/dialogs.test.ts +17 -0
  139. package/assets/ts/modules/drawer.test.ts +20 -0
  140. package/assets/ts/modules/dropdown.test.ts +38 -0
  141. package/assets/ts/modules/dynamicEvents.test.ts +23 -0
  142. package/assets/ts/modules/fileupload.test.ts +21 -0
  143. package/assets/ts/modules/filterlist.test.ts +22 -0
  144. package/assets/ts/modules/{helper.test.ts → helpers.test.ts} +63 -2
  145. package/assets/ts/modules/integration-tests.test.ts +15 -0
  146. package/assets/ts/modules/milestone-group.test.ts +22 -0
  147. package/assets/ts/modules/milestone.test.ts +35 -0
  148. package/assets/ts/modules/modal.test.ts +22 -0
  149. package/assets/ts/modules/nav.test.ts +41 -0
  150. package/assets/ts/modules/notification.test.ts +15 -0
  151. package/assets/ts/modules/orderablelist.test.ts +19 -0
  152. package/assets/ts/modules/pagination.test.ts +25 -0
  153. package/assets/ts/modules/password.test.ts +40 -0
  154. package/assets/ts/modules/table.test.ts +57 -0
  155. package/assets/ts/modules/tabs.test.ts +27 -0
  156. package/assets/ts/modules/test-dom.ts +798 -0
  157. package/assets/ts/modules/test-globals.ts +7 -0
  158. package/assets/ts/modules/test-utils.ts +29 -0
  159. package/assets/ts/modules/test.ts +28 -1
  160. package/assets/ts/modules/testimonial.test.ts +17 -0
  161. package/assets/ts/modules/videos.test.ts +33 -0
  162. package/dist/components.es.js +24 -24
  163. package/dist/components.umd.js +111 -111
  164. package/package.json +1 -1
@@ -0,0 +1,725 @@
1
+ /* eslint-disable */
2
+ const toKebab = (value) => value.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
3
+ const toDatasetKey = (value) => value.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
4
+ const splitSelector = (selector, separator = ',') => {
5
+ const parts = [];
6
+ let current = '';
7
+ let depth = 0;
8
+ let quote = '';
9
+ for (const char of selector) {
10
+ if (quote) {
11
+ current += char;
12
+ if (char === quote)
13
+ quote = '';
14
+ continue;
15
+ }
16
+ if (char === '"' || char === "'") {
17
+ quote = char;
18
+ current += char;
19
+ continue;
20
+ }
21
+ if (char === '(' || char === '[')
22
+ depth++;
23
+ if (char === ')' || char === ']')
24
+ depth--;
25
+ if (char === separator && depth === 0) {
26
+ parts.push(current.trim());
27
+ current = '';
28
+ continue;
29
+ }
30
+ current += char;
31
+ }
32
+ if (current.trim())
33
+ parts.push(current.trim());
34
+ return parts;
35
+ };
36
+ const splitTokens = (selector) => {
37
+ const tokens = [];
38
+ let current = '';
39
+ let depth = 0;
40
+ let quote = '';
41
+ for (const char of selector.trim()) {
42
+ if (quote) {
43
+ current += char;
44
+ if (char === quote)
45
+ quote = '';
46
+ continue;
47
+ }
48
+ if (char === '"' || char === "'") {
49
+ quote = char;
50
+ current += char;
51
+ continue;
52
+ }
53
+ if (char === '(' || char === '[')
54
+ depth++;
55
+ if (char === ')' || char === ']')
56
+ depth--;
57
+ if (depth === 0 && (char === ' ' || char === '>')) {
58
+ if (current.trim())
59
+ tokens.push(current.trim());
60
+ if (char === '>')
61
+ tokens.push('>');
62
+ current = '';
63
+ continue;
64
+ }
65
+ current += char;
66
+ }
67
+ if (current.trim())
68
+ tokens.push(current.trim());
69
+ return tokens;
70
+ };
71
+ const stripQuotes = (value) => value.replace(/^["']|["']$/g, '');
72
+ class TestClassList {
73
+ constructor(element) {
74
+ this.element = element;
75
+ this.items = new Set();
76
+ }
77
+ add(...classes) {
78
+ classes.filter(Boolean).forEach((className) => this.items.add(className));
79
+ this.sync();
80
+ }
81
+ remove(...classes) {
82
+ classes.forEach((className) => this.items.delete(className));
83
+ this.sync();
84
+ }
85
+ contains(className) {
86
+ return this.items.has(className);
87
+ }
88
+ toggle(className, force) {
89
+ if (force === true) {
90
+ this.add(className);
91
+ return true;
92
+ }
93
+ if (force === false) {
94
+ this.remove(className);
95
+ return false;
96
+ }
97
+ if (this.contains(className)) {
98
+ this.remove(className);
99
+ return false;
100
+ }
101
+ this.add(className);
102
+ return true;
103
+ }
104
+ setFromString(value) {
105
+ this.items = new Set(String(value || '').split(/\s+/).filter(Boolean));
106
+ this.sync();
107
+ }
108
+ toString() {
109
+ return Array.from(this.items).join(' ');
110
+ }
111
+ sync() {
112
+ this.element.attributes.class = this.toString();
113
+ }
114
+ }
115
+ class TestStyle {
116
+ constructor() {
117
+ this.properties = {};
118
+ }
119
+ setProperty(name, value) {
120
+ this.properties[name] = String(value);
121
+ }
122
+ getPropertyValue(name) {
123
+ return this.properties[name] || '';
124
+ }
125
+ toString() {
126
+ return Object.entries(this.properties)
127
+ .map(([name, value]) => `${name}: ${value};`)
128
+ .join(' ');
129
+ }
130
+ }
131
+ export class TestElement extends EventTarget {
132
+ constructor(tagName = 'div') {
133
+ super();
134
+ this.tagName = tagName.toUpperCase();
135
+ this.nodeName = this.tagName;
136
+ this.localName = tagName.toLowerCase();
137
+ this.attributes = {};
138
+ this.dataset = {};
139
+ this.children = [];
140
+ this.parentNode = null;
141
+ this.parentElement = null;
142
+ this.classList = new TestClassList(this);
143
+ this.style = new TestStyle();
144
+ this.shadowRoot = null;
145
+ this._innerHTML = '';
146
+ this._textContent = '';
147
+ this.value = '';
148
+ this.checked = false;
149
+ this.disabled = false;
150
+ this.open = false;
151
+ this.selectedIndex = 0;
152
+ this.scrollLeft = 0;
153
+ this.scrollTop = 0;
154
+ this.scrollWidth = 0;
155
+ this.scrollHeight = 0;
156
+ this.clientWidth = 0;
157
+ this.clientHeight = 0;
158
+ this.offsetWidth = 0;
159
+ this.offsetHeight = 0;
160
+ this.offsetLeft = 0;
161
+ this.files = [];
162
+ this._rect = { left: 0, right: 0, top: 0, bottom: 0, width: 0, height: 0 };
163
+ }
164
+ get id() {
165
+ return this.getAttribute('id') || '';
166
+ }
167
+ set id(value) {
168
+ this.setAttribute('id', value);
169
+ }
170
+ get className() {
171
+ return this.classList.toString();
172
+ }
173
+ set className(value) {
174
+ this.classList.setFromString(value);
175
+ }
176
+ get textContent() {
177
+ if (this._textContent)
178
+ return this._textContent;
179
+ if (this.children.length)
180
+ return this.children.map((child) => child.textContent).join('');
181
+ return this._innerHTML.replace(/<[^>]+>/g, '');
182
+ }
183
+ set textContent(value) {
184
+ this._textContent = String(value);
185
+ this._innerHTML = String(value);
186
+ }
187
+ get innerText() {
188
+ return this.textContent;
189
+ }
190
+ set innerText(value) {
191
+ this.textContent = value;
192
+ }
193
+ get innerHTML() {
194
+ if (this._innerHTML)
195
+ return this._innerHTML;
196
+ return this.children.map((child) => child.outerHTML).join('');
197
+ }
198
+ set innerHTML(value) {
199
+ this._innerHTML = String(value);
200
+ this._textContent = '';
201
+ this.children = [];
202
+ }
203
+ get outerHTML() {
204
+ const attributes = Object.entries(this.attributes)
205
+ .filter(([, value]) => value !== null && typeof value !== 'undefined' && value !== '')
206
+ .map(([name, value]) => ` ${name}="${String(value)}"`)
207
+ .join('');
208
+ return `<${this.localName}${attributes}>${this.innerHTML || this.textContent}</${this.localName}>`;
209
+ }
210
+ get firstChild() {
211
+ return this.children[0] || null;
212
+ }
213
+ get firstElementChild() {
214
+ return this.firstChild;
215
+ }
216
+ get nextSibling() {
217
+ if (!this.parentNode)
218
+ return null;
219
+ const index = this.parentNode.children.indexOf(this);
220
+ return this.parentNode.children[index + 1] || null;
221
+ }
222
+ get nextElementSibling() {
223
+ return this.nextSibling;
224
+ }
225
+ get previousSibling() {
226
+ if (!this.parentNode)
227
+ return null;
228
+ const index = this.parentNode.children.indexOf(this);
229
+ return this.parentNode.children[index - 1] || null;
230
+ }
231
+ get previousElementSibling() {
232
+ return this.previousSibling;
233
+ }
234
+ get options() {
235
+ return this.children.filter((child) => child.matches('option'));
236
+ }
237
+ setAttribute(name, value = '') {
238
+ const stringValue = String(value);
239
+ this.attributes[name] = stringValue;
240
+ if (name === 'class')
241
+ this.classList.setFromString(stringValue);
242
+ if (name === 'value')
243
+ this.value = stringValue;
244
+ if (name === 'type')
245
+ this.type = stringValue;
246
+ if (name === 'checked')
247
+ this.checked = true;
248
+ if (name === 'disabled')
249
+ this.disabled = true;
250
+ if (name === 'open')
251
+ this.open = true;
252
+ if (name === 'style') {
253
+ stringValue
254
+ .split(';')
255
+ .map((part) => part.trim())
256
+ .filter(Boolean)
257
+ .forEach((part) => {
258
+ const [property, ...rest] = part.split(':');
259
+ this.style.setProperty(property.trim(), rest.join(':').trim());
260
+ });
261
+ }
262
+ if (name.startsWith('data-'))
263
+ this.dataset[toDatasetKey(name.slice(5))] = stringValue;
264
+ }
265
+ getAttribute(name) {
266
+ if (name in this.attributes)
267
+ return this.attributes[name];
268
+ return null;
269
+ }
270
+ hasAttribute(name) {
271
+ return name in this.attributes;
272
+ }
273
+ removeAttribute(name) {
274
+ delete this.attributes[name];
275
+ if (name === 'class')
276
+ this.classList.setFromString('');
277
+ if (name === 'checked')
278
+ this.checked = false;
279
+ if (name === 'disabled')
280
+ this.disabled = false;
281
+ if (name === 'open')
282
+ this.open = false;
283
+ if (name.startsWith('data-'))
284
+ delete this.dataset[toDatasetKey(name.slice(5))];
285
+ }
286
+ toggleAttribute(name, force) {
287
+ if (force === true || (force !== false && !this.hasAttribute(name))) {
288
+ this.setAttribute(name, '');
289
+ return true;
290
+ }
291
+ this.removeAttribute(name);
292
+ return false;
293
+ }
294
+ appendChild(child) {
295
+ if (!child)
296
+ return child;
297
+ child.parentNode = this;
298
+ child.parentElement = this;
299
+ this.children.push(child);
300
+ this._innerHTML = '';
301
+ return child;
302
+ }
303
+ append(...items) {
304
+ items.forEach((item) => {
305
+ if (typeof item === 'string')
306
+ this._innerHTML += item;
307
+ else
308
+ this.appendChild(item);
309
+ });
310
+ }
311
+ prepend(...items) {
312
+ items
313
+ .slice()
314
+ .reverse()
315
+ .forEach((item) => {
316
+ if (typeof item === 'string') {
317
+ this._innerHTML = item + this._innerHTML;
318
+ }
319
+ else {
320
+ item.parentNode = this;
321
+ item.parentElement = this;
322
+ this.children.unshift(item);
323
+ this._innerHTML = '';
324
+ }
325
+ });
326
+ }
327
+ before(element) {
328
+ if (!this.parentNode)
329
+ return;
330
+ this.parentNode.insertBefore(element, this);
331
+ }
332
+ insertBefore(child, reference) {
333
+ child.parentNode = this;
334
+ child.parentElement = this;
335
+ const index = reference ? this.children.indexOf(reference) : -1;
336
+ if (index === -1)
337
+ this.children.push(child);
338
+ else
339
+ this.children.splice(index, 0, child);
340
+ this._innerHTML = '';
341
+ return child;
342
+ }
343
+ removeChild(child) {
344
+ const index = this.children.indexOf(child);
345
+ if (index !== -1)
346
+ this.children.splice(index, 1);
347
+ child.parentNode = null;
348
+ child.parentElement = null;
349
+ return child;
350
+ }
351
+ remove() {
352
+ if (this.parentNode)
353
+ this.parentNode.removeChild(this);
354
+ }
355
+ replaceChild(newChild, oldChild) {
356
+ const index = this.children.indexOf(oldChild);
357
+ if (index === -1)
358
+ return oldChild;
359
+ newChild.parentNode = this;
360
+ newChild.parentElement = this;
361
+ oldChild.parentNode = null;
362
+ oldChild.parentElement = null;
363
+ this.children[index] = newChild;
364
+ return oldChild;
365
+ }
366
+ cloneNode(deep = false) {
367
+ const clone = new TestElement(this.localName);
368
+ Object.entries(this.attributes).forEach(([name, value]) => clone.setAttribute(name, value));
369
+ clone.value = this.value;
370
+ clone.checked = this.checked;
371
+ clone.innerHTML = this.innerHTML;
372
+ clone.textContent = this._textContent;
373
+ clone.files = Array.from(this.files || []);
374
+ if (deep)
375
+ this.children.forEach((child) => clone.appendChild(child.cloneNode(true)));
376
+ return clone;
377
+ }
378
+ insertAdjacentHTML(position, html) {
379
+ if (position === 'afterbegin')
380
+ this._innerHTML = String(html) + this._innerHTML;
381
+ else
382
+ this._innerHTML += String(html);
383
+ }
384
+ insertAdjacentElement(position, element) {
385
+ if (position === 'afterbegin')
386
+ this.prepend(element);
387
+ else
388
+ this.appendChild(element);
389
+ return element;
390
+ }
391
+ querySelector(selector) {
392
+ return this.querySelectorAll(selector)[0] || null;
393
+ }
394
+ querySelectorAll(selector) {
395
+ return selectAll(this, selector);
396
+ }
397
+ getElementsByTagName(tagName) {
398
+ return this.querySelectorAll(tagName);
399
+ }
400
+ closest(selector) {
401
+ let current = this;
402
+ while (current) {
403
+ if (current.matches && current.matches(selector))
404
+ return current;
405
+ current = current.parentNode;
406
+ }
407
+ return null;
408
+ }
409
+ matches(selector) {
410
+ return matchesSelector(this, selector);
411
+ }
412
+ click() {
413
+ this.dispatchEvent(new Event('click', { bubbles: true, cancelable: true }));
414
+ }
415
+ focus() {
416
+ globalThis.document.activeElement = this;
417
+ }
418
+ blur() {
419
+ if (globalThis.document.activeElement === this)
420
+ globalThis.document.activeElement = null;
421
+ }
422
+ scroll(options = {}) {
423
+ if ('left' in options)
424
+ this.scrollLeft = options.left;
425
+ if ('top' in options)
426
+ this.scrollTop = options.top;
427
+ this.dispatchEvent(new Event('scroll'));
428
+ }
429
+ scrollIntoView() { }
430
+ showModal() {
431
+ this.setAttribute('open', '');
432
+ this.open = true;
433
+ }
434
+ show() {
435
+ this.showModal();
436
+ }
437
+ close() {
438
+ this.removeAttribute('open');
439
+ this.open = false;
440
+ this.dispatchEvent(new Event('close'));
441
+ }
442
+ submit() {
443
+ this.dispatchEvent(new Event('submit'));
444
+ }
445
+ getBoundingClientRect() {
446
+ return this._rect;
447
+ }
448
+ setRect(rect) {
449
+ this._rect = Object.assign(Object.assign({}, this._rect), rect);
450
+ }
451
+ }
452
+ export class TestDocument extends TestElement {
453
+ constructor() {
454
+ super('#document');
455
+ this.title = 'Test page';
456
+ this.documentElement = new TestElement('html');
457
+ this.body = new TestElement('body');
458
+ this.documentElement.appendChild(this.body);
459
+ this.appendChild(this.documentElement);
460
+ this.activeElement = null;
461
+ }
462
+ createElement(tagName) {
463
+ return new TestElement(tagName);
464
+ }
465
+ createDocumentFragment() {
466
+ return new TestElement('fragment');
467
+ }
468
+ getElementById(id) {
469
+ return this.querySelector(`#${id}`);
470
+ }
471
+ querySelector(selector) {
472
+ if (selector === 'body')
473
+ return this.body;
474
+ if (selector === 'html')
475
+ return this.documentElement;
476
+ return super.querySelector(selector);
477
+ }
478
+ }
479
+ class TestStorage {
480
+ constructor() {
481
+ this.items = {};
482
+ }
483
+ getItem(key) {
484
+ return this.items[key] || null;
485
+ }
486
+ setItem(key, value) {
487
+ this.items[key] = String(value);
488
+ }
489
+ removeItem(key) {
490
+ delete this.items[key];
491
+ }
492
+ clear() {
493
+ this.items = {};
494
+ }
495
+ }
496
+ const getDescendants = (root) => {
497
+ const descendants = [];
498
+ root.children.forEach((child) => {
499
+ descendants.push(child);
500
+ descendants.push(...getDescendants(child));
501
+ });
502
+ if (root.shadowRoot) {
503
+ descendants.push(root.shadowRoot);
504
+ descendants.push(...getDescendants(root.shadowRoot));
505
+ }
506
+ return descendants;
507
+ };
508
+ const unique = (items) => Array.from(new Set(items));
509
+ const selectAll = (root, selector) => {
510
+ if (!selector)
511
+ return [];
512
+ const selectors = splitSelector(selector);
513
+ if (selectors.length > 1)
514
+ return unique(selectors.flatMap((part) => selectAll(root, part)));
515
+ const normalized = selector.trim();
516
+ if (normalized.startsWith(':scope > ')) {
517
+ const childSelector = normalized.replace(':scope > ', '').trim();
518
+ return root.children.filter((child) => child.matches(childSelector));
519
+ }
520
+ const tokens = splitTokens(normalized);
521
+ if (tokens.length > 1) {
522
+ let current = [root];
523
+ let direct = false;
524
+ tokens.forEach((token) => {
525
+ if (token === '>') {
526
+ direct = true;
527
+ return;
528
+ }
529
+ current = current.flatMap((element) => {
530
+ const candidates = direct ? element.children : getDescendants(element);
531
+ return candidates.filter((candidate) => candidate.matches(token));
532
+ });
533
+ direct = false;
534
+ });
535
+ return unique(current);
536
+ }
537
+ return getDescendants(root).filter((element) => element.matches(normalized));
538
+ };
539
+ const matchesSelector = (element, selector) => {
540
+ if (!selector)
541
+ return false;
542
+ const selectors = splitSelector(selector);
543
+ if (selectors.length > 1)
544
+ return selectors.some((part) => matchesSelector(element, part));
545
+ let current = selector.trim();
546
+ if (current === '*')
547
+ return true;
548
+ if (current.startsWith(':scope'))
549
+ current = current.replace(':scope', '').trim();
550
+ if (!current)
551
+ return true;
552
+ const notMatches = current.match(/:not\((.+)\)$/);
553
+ if (notMatches) {
554
+ current = current.slice(0, notMatches.index);
555
+ if (matchesSelector(element, notMatches[1]))
556
+ return false;
557
+ }
558
+ const isMatches = current.match(/:is\((.+)\)/);
559
+ if (isMatches) {
560
+ const before = current.slice(0, isMatches.index);
561
+ const after = current.slice(isMatches.index + isMatches[0].length);
562
+ return splitSelector(isMatches[1]).some((part) => matchesSelector(element, `${before}${part}${after}`));
563
+ }
564
+ if (current.endsWith(':first-child')) {
565
+ current = current.replace(':first-child', '');
566
+ if (!element.parentNode || element.parentNode.children[0] !== element)
567
+ return false;
568
+ }
569
+ if (current.endsWith(':last-child')) {
570
+ current = current.replace(':last-child', '');
571
+ if (!element.parentNode || element.parentNode.children[element.parentNode.children.length - 1] !== element) {
572
+ return false;
573
+ }
574
+ }
575
+ if (current.endsWith(':checked')) {
576
+ current = current.replace(':checked', '');
577
+ if (!element.checked)
578
+ return false;
579
+ }
580
+ current = current.trim();
581
+ const attributeMatches = Array.from(current.matchAll(/\[([^\]=~*]+)([*]?=)?(?:"([^"]*)"|'([^']*)'|([^\]]+))?\]/g));
582
+ for (const attributeMatch of attributeMatches) {
583
+ const name = attributeMatch[1].trim();
584
+ const operator = attributeMatch[2];
585
+ const expected = stripQuotes(attributeMatch[3] || attributeMatch[4] || attributeMatch[5] || '');
586
+ const actual = name === 'class' ? element.className : element.getAttribute(name);
587
+ if (!operator && actual === null)
588
+ return false;
589
+ if (operator === '=' && String(actual) !== expected)
590
+ return false;
591
+ if (operator === '*=' && !String(actual || '').includes(expected))
592
+ return false;
593
+ }
594
+ current = current.replace(/\[[^\]]+\]/g, '');
595
+ const idMatch = current.match(/#([A-Za-z0-9_-]+)/);
596
+ if (idMatch && element.getAttribute('id') !== idMatch[1])
597
+ return false;
598
+ current = current.replace(/#[A-Za-z0-9_-]+/g, '');
599
+ const classMatches = Array.from(current.matchAll(/\.([A-Za-z0-9_-]+)/g)).map((match) => match[1]);
600
+ if (classMatches.some((className) => !element.classList.contains(className)))
601
+ return false;
602
+ current = current.replace(/\.[A-Za-z0-9_-]+/g, '').trim();
603
+ if (current && current !== '*' && element.localName !== current.toLowerCase())
604
+ return false;
605
+ return true;
606
+ };
607
+ class TestDataTransfer {
608
+ constructor() {
609
+ this.items = {
610
+ files: [],
611
+ add: (file) => this.items.files.push(file),
612
+ };
613
+ }
614
+ get files() {
615
+ return this.items.files;
616
+ }
617
+ }
618
+ export const installTestDom = () => {
619
+ const document = new TestDocument();
620
+ const localStorage = new TestStorage();
621
+ const window = globalThis.window || new EventTarget();
622
+ window.document = document;
623
+ window.dataLayer = [];
624
+ window.controller = [];
625
+ window.innerWidth = 1024;
626
+ window.innerHeight = 768;
627
+ window.scrollY = 0;
628
+ window.pageYOffset = 0;
629
+ window.location = { href: 'http://localhost/', hash: '' };
630
+ window.history = { pushState: () => { } };
631
+ window.matchMedia = () => ({ matches: true });
632
+ window.getComputedStyle = (element) => ({
633
+ display: element.style.getPropertyValue('display') || element.getAttribute('data-display') || 'block',
634
+ fontSize: '16px',
635
+ getPropertyValue: (name) => {
636
+ if (name === 'line-height')
637
+ return element.getAttribute('data-line-height') || '16px';
638
+ if (name === 'display')
639
+ return element.style.getPropertyValue('display') || 'block';
640
+ if (name === 'font-size')
641
+ return '16px';
642
+ return element.style.getPropertyValue(name);
643
+ },
644
+ });
645
+ window.URL = {
646
+ createObjectURL: () => 'blob:test',
647
+ };
648
+ window.setTimeout = globalThis.setTimeout.bind(globalThis);
649
+ window.clearTimeout = globalThis.clearTimeout.bind(globalThis);
650
+ window.setInterval = globalThis.setInterval.bind(globalThis);
651
+ window.clearInterval = globalThis.clearInterval.bind(globalThis);
652
+ window.localStorage = localStorage;
653
+ Object.defineProperty(globalThis, 'window', { value: window, writable: true, configurable: true });
654
+ Object.defineProperty(globalThis, 'document', { value: document, writable: true, configurable: true });
655
+ Object.defineProperty(globalThis, 'navigator', {
656
+ value: { userAgent: '', appVersion: '' },
657
+ writable: true,
658
+ configurable: true,
659
+ });
660
+ globalThis.location = window.location;
661
+ globalThis.history = window.history;
662
+ globalThis.localStorage = localStorage;
663
+ globalThis.HTMLElement = TestElement;
664
+ globalThis.Element = TestElement;
665
+ globalThis.HTMLInputElement = TestElement;
666
+ globalThis.getComputedStyle = window.getComputedStyle;
667
+ globalThis.addEventListener = window.addEventListener.bind(window);
668
+ globalThis.IntersectionObserver = class {
669
+ constructor(callback) {
670
+ this.callback = callback;
671
+ this.observed = [];
672
+ }
673
+ observe(element) {
674
+ this.observed.push(element);
675
+ this.callback([{ target: element, intersectionRatio: 1 }]);
676
+ }
677
+ disconnect() { }
678
+ };
679
+ globalThis.ResizeObserver = class {
680
+ constructor(callback) {
681
+ this.callback = callback;
682
+ }
683
+ observe(element) {
684
+ this.callback([{ target: element }]);
685
+ }
686
+ };
687
+ globalThis.MutationObserver = class {
688
+ constructor(callback) {
689
+ this.callback = callback;
690
+ }
691
+ observe() { }
692
+ disconnect() { }
693
+ };
694
+ globalThis.DataTransfer = TestDataTransfer;
695
+ globalThis.Image = class {
696
+ set src(value) {
697
+ this._src = value;
698
+ setTimeout(() => this.onload && this.onload(), 0);
699
+ }
700
+ get src() {
701
+ return this._src;
702
+ }
703
+ };
704
+ return { document, window, localStorage };
705
+ };
706
+ export const createElement = (tagName, attributes = {}, text = '') => {
707
+ const element = new TestElement(tagName);
708
+ Object.entries(attributes).forEach(([name, value]) => {
709
+ if (name === 'textContent')
710
+ element.textContent = value;
711
+ else if (name === 'innerHTML')
712
+ element.innerHTML = value;
713
+ else if (name === 'checked')
714
+ element.checked = Boolean(value);
715
+ else if (name === 'value') {
716
+ element.value = value;
717
+ element.setAttribute('value', value);
718
+ }
719
+ else
720
+ element.setAttribute(toKebab(name), value);
721
+ });
722
+ if (text)
723
+ element.textContent = text;
724
+ return element;
725
+ };