@thednp/shorty 2.0.11 → 2.0.13
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/README.md +0 -3
- package/dist/chunk-CP6mxX4N.js +27 -0
- package/dist/index.d.ts +2232 -0
- package/dist/index.js +2382 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +4 -0
- package/dist/index.umd.js.map +1 -0
- package/package.json +31 -24
- package/dist/shorty.cjs +0 -2
- package/dist/shorty.cjs.map +0 -1
- package/dist/shorty.d.ts +0 -2145
- package/dist/shorty.js +0 -2
- package/dist/shorty.js.map +0 -1
- package/dist/shorty.mjs +0 -641
- package/dist/shorty.mjs.map +0 -1
package/dist/index.js
ADDED
|
@@ -0,0 +1,2382 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @thednp/shorty ESM v2.0.13 (https://github.com/thednp/shorty)
|
|
3
|
+
* Copyright 2026 © thednp
|
|
4
|
+
* Licensed under MIT (https://github.com/thednp/shorty/blob/master/LICENSE)
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
import "./chunk-CP6mxX4N.js";
|
|
9
|
+
//#region package.json
|
|
10
|
+
var version = "2.0.13";
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/strings/ariaChecked.ts
|
|
13
|
+
/**
|
|
14
|
+
* A global namespace for aria-checked.
|
|
15
|
+
*/
|
|
16
|
+
const ariaChecked = "aria-checked";
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/strings/ariaDescription.ts
|
|
19
|
+
/**
|
|
20
|
+
* A global namespace for aria-description.
|
|
21
|
+
*/
|
|
22
|
+
const ariaDescription = "aria-description";
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/strings/ariaDescribedBy.ts
|
|
25
|
+
/**
|
|
26
|
+
* A global namespace for aria-describedby.
|
|
27
|
+
*/
|
|
28
|
+
const ariaDescribedBy = "aria-describedby";
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/strings/ariaExpanded.ts
|
|
31
|
+
/**
|
|
32
|
+
* A global namespace for aria-expanded.
|
|
33
|
+
*/
|
|
34
|
+
const ariaExpanded = "aria-expanded";
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/strings/ariaHasPopup.ts
|
|
37
|
+
/**
|
|
38
|
+
* A global namespace for aria-haspopup.
|
|
39
|
+
*/
|
|
40
|
+
const ariaHasPopup = "aria-haspopup";
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/strings/ariaHidden.ts
|
|
43
|
+
/**
|
|
44
|
+
* A global namespace for aria-hidden.
|
|
45
|
+
*/
|
|
46
|
+
const ariaHidden = "aria-hidden";
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/strings/ariaLabel.ts
|
|
49
|
+
/**
|
|
50
|
+
* A global namespace for aria-label.
|
|
51
|
+
*/
|
|
52
|
+
const ariaLabel = "aria-label";
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/strings/ariaLabelledBy.ts
|
|
55
|
+
/**
|
|
56
|
+
* A global namespace for aria-labelledby.
|
|
57
|
+
*/
|
|
58
|
+
const ariaLabelledBy = "aria-labelledby";
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/strings/ariaModal.ts
|
|
61
|
+
/**
|
|
62
|
+
* A global namespace for aria-modal.
|
|
63
|
+
*/
|
|
64
|
+
const ariaModal = "aria-modal";
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/strings/ariaPressed.ts
|
|
67
|
+
/**
|
|
68
|
+
* A global namespace for aria-pressed.
|
|
69
|
+
*/
|
|
70
|
+
const ariaPressed = "aria-pressed";
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/strings/ariaSelected.ts
|
|
73
|
+
/**
|
|
74
|
+
* A global namespace for aria-selected.
|
|
75
|
+
*/
|
|
76
|
+
const ariaSelected = "aria-selected";
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/strings/ariaValueMin.ts
|
|
79
|
+
/**
|
|
80
|
+
* A global namespace for aria-valuemin.
|
|
81
|
+
*/
|
|
82
|
+
const ariaValueMin = "aria-valuemin";
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/strings/ariaValueMax.ts
|
|
85
|
+
/**
|
|
86
|
+
* A global namespace for aria-valuemax.
|
|
87
|
+
*/
|
|
88
|
+
const ariaValueMax = "aria-valuemax";
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/strings/ariaValueNow.ts
|
|
91
|
+
/**
|
|
92
|
+
* A global namespace for aria-valuenow.
|
|
93
|
+
*/
|
|
94
|
+
const ariaValueNow = "aria-valuenow";
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/strings/ariaValueText.ts
|
|
97
|
+
/**
|
|
98
|
+
* A global namespace for aria-valuetext.
|
|
99
|
+
*/
|
|
100
|
+
const ariaValueText = "aria-valuetext";
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/strings/abortEvent.ts
|
|
103
|
+
/**
|
|
104
|
+
* A global namespace for `abort` event.
|
|
105
|
+
*/
|
|
106
|
+
const abortEvent = "abort";
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/strings/beforeunloadEvent.ts
|
|
109
|
+
/**
|
|
110
|
+
* A global namespace for `beforeunload` event.
|
|
111
|
+
*/
|
|
112
|
+
const beforeunloadEvent = "beforeunload";
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/strings/blurEvent.ts
|
|
115
|
+
/**
|
|
116
|
+
* A global namespace for `blur` event.
|
|
117
|
+
*/
|
|
118
|
+
const blurEvent = "blur";
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/strings/changeEvent.ts
|
|
121
|
+
/**
|
|
122
|
+
* A global namespace for `change` event.
|
|
123
|
+
*/
|
|
124
|
+
const changeEvent = "change";
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/strings/contextmenuEvent.ts
|
|
127
|
+
/**
|
|
128
|
+
* A global namespace for `contextmenu` event.
|
|
129
|
+
*/
|
|
130
|
+
const contextmenuEvent = "contextmenu";
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/strings/DOMContentLoadedEvent.ts
|
|
133
|
+
/**
|
|
134
|
+
* A global namespace for `DOMContentLoaded` event.
|
|
135
|
+
*/
|
|
136
|
+
const DOMContentLoadedEvent = "DOMContentLoaded";
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/strings/DOMMouseScrollEvent.ts
|
|
139
|
+
/**
|
|
140
|
+
* A global namespace for `DOMMouseScroll` event.
|
|
141
|
+
*/
|
|
142
|
+
const DOMMouseScrollEvent = "DOMMouseScroll";
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/strings/errorEvent.ts
|
|
145
|
+
/**
|
|
146
|
+
* A global namespace for `error` event.
|
|
147
|
+
*/
|
|
148
|
+
const errorEvent = "error";
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/strings/focusEvent.ts
|
|
151
|
+
/**
|
|
152
|
+
* A global namespace for `focus` event.
|
|
153
|
+
*/
|
|
154
|
+
const focusEvent = "focus";
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/strings/focusinEvent.ts
|
|
157
|
+
/**
|
|
158
|
+
* A global namespace for `focusin` event.
|
|
159
|
+
*/
|
|
160
|
+
const focusinEvent = "focusin";
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/strings/focusoutEvent.ts
|
|
163
|
+
/**
|
|
164
|
+
* A global namespace for `focusout` event.
|
|
165
|
+
*/
|
|
166
|
+
const focusoutEvent = "focusout";
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/strings/gesturechangeEvent.ts
|
|
169
|
+
/**
|
|
170
|
+
* A global namespace for `gesturechange` event.
|
|
171
|
+
*/
|
|
172
|
+
const gesturechangeEvent = "gesturechange";
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/strings/gestureendEvent.ts
|
|
175
|
+
/**
|
|
176
|
+
* A global namespace for `gestureend` event.
|
|
177
|
+
*/
|
|
178
|
+
const gestureendEvent = "gestureend";
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/strings/gesturestartEvent.ts
|
|
181
|
+
/**
|
|
182
|
+
* A global namespace for `gesturestart` event.
|
|
183
|
+
*/
|
|
184
|
+
const gesturestartEvent = "gesturestart";
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/strings/keydownEvent.ts
|
|
187
|
+
/**
|
|
188
|
+
* A global namespace for `keydown` event.
|
|
189
|
+
*/
|
|
190
|
+
const keydownEvent = "keydown";
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/strings/keypressEvent.ts
|
|
193
|
+
/**
|
|
194
|
+
* A global namespace for `keypress` event.
|
|
195
|
+
*/
|
|
196
|
+
const keypressEvent = "keypress";
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region src/strings/keyupEvent.ts
|
|
199
|
+
/**
|
|
200
|
+
* A global namespace for `keyup` event.
|
|
201
|
+
*/
|
|
202
|
+
const keyupEvent = "keyup";
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/strings/loadEvent.ts
|
|
205
|
+
/**
|
|
206
|
+
* A global namespace for `load` event.
|
|
207
|
+
*/
|
|
208
|
+
const loadEvent = "load";
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/strings/mouseclickEvent.ts
|
|
211
|
+
/**
|
|
212
|
+
* A global namespace for `click` event.
|
|
213
|
+
*/
|
|
214
|
+
const mouseclickEvent = "click";
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region src/strings/mousedblclickEvent.ts
|
|
217
|
+
/**
|
|
218
|
+
* A global namespace for `dblclick` event.
|
|
219
|
+
*/
|
|
220
|
+
const mousedblclickEvent = "dblclick";
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/strings/mousedownEvent.ts
|
|
223
|
+
/**
|
|
224
|
+
* A global namespace for `mousedown` event.
|
|
225
|
+
*/
|
|
226
|
+
const mousedownEvent = "mousedown";
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/strings/mouseupEvent.ts
|
|
229
|
+
/**
|
|
230
|
+
* A global namespace for `mouseup` event.
|
|
231
|
+
*/
|
|
232
|
+
const mouseupEvent = "mouseup";
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/strings/mousehoverEvent.ts
|
|
235
|
+
/**
|
|
236
|
+
* A global namespace for `hover` event.
|
|
237
|
+
*/
|
|
238
|
+
const mousehoverEvent = "hover";
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/strings/mouseenterEvent.ts
|
|
241
|
+
/**
|
|
242
|
+
* A global namespace for `mouseenter` event.
|
|
243
|
+
*/
|
|
244
|
+
const mouseenterEvent = "mouseenter";
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/strings/mouseleaveEvent.ts
|
|
247
|
+
/**
|
|
248
|
+
* A global namespace for `mouseleave` event.
|
|
249
|
+
*/
|
|
250
|
+
const mouseleaveEvent = "mouseleave";
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region src/strings/mouseinEvent.ts
|
|
253
|
+
/**
|
|
254
|
+
* A global namespace for `mousein` event.
|
|
255
|
+
*/
|
|
256
|
+
const mouseinEvent = "mousein";
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/strings/mouseoutEvent.ts
|
|
259
|
+
/**
|
|
260
|
+
* A global namespace for `mouseout` event.
|
|
261
|
+
*/
|
|
262
|
+
const mouseoutEvent = "mouseout";
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/strings/mouseoverEvent.ts
|
|
265
|
+
/**
|
|
266
|
+
* A global namespace for `mouseover` event.
|
|
267
|
+
*/
|
|
268
|
+
const mouseoverEvent = "mouseover";
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region src/strings/mousemoveEvent.ts
|
|
271
|
+
/**
|
|
272
|
+
* A global namespace for `mousemove` event.
|
|
273
|
+
*/
|
|
274
|
+
const mousemoveEvent = "mousemove";
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region src/strings/mousewheelEvent.ts
|
|
277
|
+
/**
|
|
278
|
+
* A global namespace for `mousewheel` event.
|
|
279
|
+
*/
|
|
280
|
+
const mousewheelEvent = "mousewheel";
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src/strings/moveEvent.ts
|
|
283
|
+
/**
|
|
284
|
+
* A global namespace for `move` event.
|
|
285
|
+
*/
|
|
286
|
+
const moveEvent = "move";
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region src/strings/orientationchangeEvent.ts
|
|
289
|
+
/**
|
|
290
|
+
* A global namespace for `orientationchange` event.
|
|
291
|
+
*/
|
|
292
|
+
const orientationchangeEvent = "orientationchange";
|
|
293
|
+
//#endregion
|
|
294
|
+
//#region src/strings/pointercancelEvent.ts
|
|
295
|
+
/**
|
|
296
|
+
* A global namespace for `pointercancel` event.
|
|
297
|
+
*/
|
|
298
|
+
const pointercancelEvent = "pointercancel";
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region src/strings/pointerdownEvent.ts
|
|
301
|
+
/**
|
|
302
|
+
* A global namespace for `pointerdown` event.
|
|
303
|
+
*/
|
|
304
|
+
const pointerdownEvent = "pointerdown";
|
|
305
|
+
//#endregion
|
|
306
|
+
//#region src/strings/pointerleaveEvent.ts
|
|
307
|
+
/**
|
|
308
|
+
* A global namespace for `pointerleave` event.
|
|
309
|
+
*/
|
|
310
|
+
const pointerleaveEvent = "pointerleave";
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region src/strings/pointermoveEvent.ts
|
|
313
|
+
/**
|
|
314
|
+
* A global namespace for `pointermove` event.
|
|
315
|
+
*/
|
|
316
|
+
const pointermoveEvent = "pointermove";
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region src/strings/pointerupEvent.ts
|
|
319
|
+
/**
|
|
320
|
+
* A global namespace for `pointerup` event.
|
|
321
|
+
*/
|
|
322
|
+
const pointerupEvent = "pointerup";
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region src/strings/readystatechangeEvent.ts
|
|
325
|
+
/**
|
|
326
|
+
* A global namespace for `readystatechange` event.
|
|
327
|
+
*/
|
|
328
|
+
const readystatechangeEvent = "readystatechange";
|
|
329
|
+
//#endregion
|
|
330
|
+
//#region src/strings/resetEvent.ts
|
|
331
|
+
/**
|
|
332
|
+
* A global namespace for `reset` event.
|
|
333
|
+
*/
|
|
334
|
+
const resetEvent = "reset";
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region src/strings/resizeEvent.ts
|
|
337
|
+
/**
|
|
338
|
+
* A global namespace for `resize` event.
|
|
339
|
+
*/
|
|
340
|
+
const resizeEvent = "resize";
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region src/strings/selectEvent.ts
|
|
343
|
+
/**
|
|
344
|
+
* A global namespace for `select` event.
|
|
345
|
+
*/
|
|
346
|
+
const selectEvent = "select";
|
|
347
|
+
//#endregion
|
|
348
|
+
//#region src/strings/selectendEvent.ts
|
|
349
|
+
/**
|
|
350
|
+
* A global namespace for the `selectend` event.
|
|
351
|
+
*/
|
|
352
|
+
const selectendEvent = "selectend";
|
|
353
|
+
//#endregion
|
|
354
|
+
//#region src/strings/selectstartEvent.ts
|
|
355
|
+
/**
|
|
356
|
+
* A global namespace for the `selectstart` event.
|
|
357
|
+
*/
|
|
358
|
+
const selectstartEvent = "selectstart";
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region src/strings/scrollEvent.ts
|
|
361
|
+
/**
|
|
362
|
+
* A global namespace for `scroll` event.
|
|
363
|
+
*/
|
|
364
|
+
const scrollEvent = "scroll";
|
|
365
|
+
//#endregion
|
|
366
|
+
//#region src/strings/submitEvent.ts
|
|
367
|
+
/**
|
|
368
|
+
* A global namespace for `submit` event.
|
|
369
|
+
*/
|
|
370
|
+
const submitEvent = "submit";
|
|
371
|
+
//#endregion
|
|
372
|
+
//#region src/strings/touchstartEvent.ts
|
|
373
|
+
/**
|
|
374
|
+
* A global namespace for `touchstart` event.
|
|
375
|
+
*/
|
|
376
|
+
const touchstartEvent = "touchstart";
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region src/strings/touchmoveEvent.ts
|
|
379
|
+
/**
|
|
380
|
+
* A global namespace for `touchmove` event.
|
|
381
|
+
*/
|
|
382
|
+
const touchmoveEvent = "touchmove";
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region src/strings/touchcancelEvent.ts
|
|
385
|
+
/**
|
|
386
|
+
* A global namespace for `touchcancel` event.
|
|
387
|
+
*/
|
|
388
|
+
const touchcancelEvent = "touchcancel";
|
|
389
|
+
//#endregion
|
|
390
|
+
//#region src/strings/touchendEvent.ts
|
|
391
|
+
/**
|
|
392
|
+
* A global namespace for `touchend` event.
|
|
393
|
+
*/
|
|
394
|
+
const touchendEvent = "touchend";
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/strings/unloadEvent.ts
|
|
397
|
+
/**
|
|
398
|
+
* A global namespace for `unload` event.
|
|
399
|
+
*/
|
|
400
|
+
const unloadEvent = "unload";
|
|
401
|
+
//#endregion
|
|
402
|
+
//#region src/strings/nativeEvents.ts
|
|
403
|
+
/**
|
|
404
|
+
* A global namespace for all browser native events.
|
|
405
|
+
*/
|
|
406
|
+
const nativeEvents = {
|
|
407
|
+
DOMContentLoaded: DOMContentLoadedEvent,
|
|
408
|
+
DOMMouseScroll: DOMMouseScrollEvent,
|
|
409
|
+
abort: abortEvent,
|
|
410
|
+
beforeunload: beforeunloadEvent,
|
|
411
|
+
blur: blurEvent,
|
|
412
|
+
change: changeEvent,
|
|
413
|
+
click: mouseclickEvent,
|
|
414
|
+
contextmenu: contextmenuEvent,
|
|
415
|
+
dblclick: mousedblclickEvent,
|
|
416
|
+
error: errorEvent,
|
|
417
|
+
focus: focusEvent,
|
|
418
|
+
focusin: focusinEvent,
|
|
419
|
+
focusout: focusoutEvent,
|
|
420
|
+
gesturechange: gesturechangeEvent,
|
|
421
|
+
gestureend: gestureendEvent,
|
|
422
|
+
gesturestart: gesturestartEvent,
|
|
423
|
+
hover: mousehoverEvent,
|
|
424
|
+
keydown: keydownEvent,
|
|
425
|
+
keypress: keypressEvent,
|
|
426
|
+
keyup: keyupEvent,
|
|
427
|
+
load: loadEvent,
|
|
428
|
+
mousedown: mousedownEvent,
|
|
429
|
+
mousemove: mousemoveEvent,
|
|
430
|
+
mousein: mouseinEvent,
|
|
431
|
+
mouseout: mouseoutEvent,
|
|
432
|
+
mouseenter: mouseenterEvent,
|
|
433
|
+
mouseleave: mouseleaveEvent,
|
|
434
|
+
mouseover: mouseoverEvent,
|
|
435
|
+
mouseup: mouseupEvent,
|
|
436
|
+
mousewheel: mousewheelEvent,
|
|
437
|
+
move: moveEvent,
|
|
438
|
+
orientationchange: orientationchangeEvent,
|
|
439
|
+
pointercancel: pointercancelEvent,
|
|
440
|
+
pointerdown: pointerdownEvent,
|
|
441
|
+
pointerleave: pointerleaveEvent,
|
|
442
|
+
pointermove: pointermoveEvent,
|
|
443
|
+
pointerup: pointerupEvent,
|
|
444
|
+
readystatechange: readystatechangeEvent,
|
|
445
|
+
reset: resetEvent,
|
|
446
|
+
resize: resizeEvent,
|
|
447
|
+
scroll: scrollEvent,
|
|
448
|
+
select: selectEvent,
|
|
449
|
+
selectend: selectendEvent,
|
|
450
|
+
selectstart: selectstartEvent,
|
|
451
|
+
submit: submitEvent,
|
|
452
|
+
touchcancel: touchcancelEvent,
|
|
453
|
+
touchend: touchendEvent,
|
|
454
|
+
touchmove: touchmoveEvent,
|
|
455
|
+
touchstart: touchstartEvent,
|
|
456
|
+
unload: unloadEvent
|
|
457
|
+
};
|
|
458
|
+
//#endregion
|
|
459
|
+
//#region src/strings/dragEvent.ts
|
|
460
|
+
/**
|
|
461
|
+
* A global namespace for `drag` event.
|
|
462
|
+
*/
|
|
463
|
+
const dragEvent = "drag";
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region src/strings/dragstartEvent.ts
|
|
466
|
+
/**
|
|
467
|
+
* A global namespace for `dragstart` event.
|
|
468
|
+
*/
|
|
469
|
+
const dragstartEvent = "dragstart";
|
|
470
|
+
//#endregion
|
|
471
|
+
//#region src/strings/dragenterEvent.ts
|
|
472
|
+
/**
|
|
473
|
+
* A global namespace for `dragenter` event.
|
|
474
|
+
*/
|
|
475
|
+
const dragenterEvent = "dragenter";
|
|
476
|
+
//#endregion
|
|
477
|
+
//#region src/strings/dragleaveEvent.ts
|
|
478
|
+
/**
|
|
479
|
+
* A global namespace for `dragleave` event.
|
|
480
|
+
*/
|
|
481
|
+
const dragleaveEvent = "dragleave";
|
|
482
|
+
//#endregion
|
|
483
|
+
//#region src/strings/dragoverEvent.ts
|
|
484
|
+
/**
|
|
485
|
+
* A global namespace for `dragover` event.
|
|
486
|
+
*/
|
|
487
|
+
const dragoverEvent = "dragover";
|
|
488
|
+
//#endregion
|
|
489
|
+
//#region src/strings/dragendEvent.ts
|
|
490
|
+
/**
|
|
491
|
+
* A global namespace for `dragend` event.
|
|
492
|
+
*/
|
|
493
|
+
const dragendEvent = "dragend";
|
|
494
|
+
//#endregion
|
|
495
|
+
//#region src/strings/loadstartEvent.ts
|
|
496
|
+
/**
|
|
497
|
+
* A global namespace for `loadstart` event.
|
|
498
|
+
*/
|
|
499
|
+
const loadstartEvent = "loadstart";
|
|
500
|
+
//#endregion
|
|
501
|
+
//#region src/strings/mouseSwipeEvents.ts
|
|
502
|
+
/**
|
|
503
|
+
* A global namespace for mouse events equivalent to touch events.
|
|
504
|
+
*/
|
|
505
|
+
const mouseSwipeEvents = {
|
|
506
|
+
start: "mousedown",
|
|
507
|
+
end: "mouseup",
|
|
508
|
+
move: "mousemove",
|
|
509
|
+
cancel: "mouseleave"
|
|
510
|
+
};
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/strings/mouseClickEvents.ts
|
|
513
|
+
/**
|
|
514
|
+
* A global namespace for mouse click events.
|
|
515
|
+
*/
|
|
516
|
+
const mouseClickEvents = {
|
|
517
|
+
down: "mousedown",
|
|
518
|
+
up: "mouseup"
|
|
519
|
+
};
|
|
520
|
+
//#endregion
|
|
521
|
+
//#region src/strings/mouseHoverEvents.ts
|
|
522
|
+
/**
|
|
523
|
+
* A global namespace for mouse hover events.
|
|
524
|
+
*/
|
|
525
|
+
const mouseHoverEvents = "onmouseleave" in document ? ["mouseenter", "mouseleave"] : ["mouseover", "mouseout"];
|
|
526
|
+
//#endregion
|
|
527
|
+
//#region src/strings/touchEvents.ts
|
|
528
|
+
/**
|
|
529
|
+
* A global namespace for touch events.
|
|
530
|
+
*/
|
|
531
|
+
const touchEvents = {
|
|
532
|
+
start: "touchstart",
|
|
533
|
+
end: "touchend",
|
|
534
|
+
move: "touchmove",
|
|
535
|
+
cancel: "touchcancel"
|
|
536
|
+
};
|
|
537
|
+
//#endregion
|
|
538
|
+
//#region src/strings/focusEvents.ts
|
|
539
|
+
/**
|
|
540
|
+
* A global namespace for focus event names.
|
|
541
|
+
*/
|
|
542
|
+
const focusEvents = {
|
|
543
|
+
in: "focusin",
|
|
544
|
+
out: "focusout"
|
|
545
|
+
};
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/strings/focusableSelector.ts
|
|
548
|
+
const focusableSelector = "a[href], button, input, textarea, select, details, [tabindex]:not([tabindex=\"-1\"]";
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region src/strings/keyboardEventKeys.ts
|
|
551
|
+
/**
|
|
552
|
+
* A global namespace for keyboard event keys.
|
|
553
|
+
*/
|
|
554
|
+
const keyboardEventKeys = {
|
|
555
|
+
Backspace: "Backspace",
|
|
556
|
+
Tab: "Tab",
|
|
557
|
+
Enter: "Enter",
|
|
558
|
+
Shift: "Shift",
|
|
559
|
+
Control: "Control",
|
|
560
|
+
Alt: "Alt",
|
|
561
|
+
Pause: "Pause",
|
|
562
|
+
CapsLock: "CapsLock",
|
|
563
|
+
Escape: "Escape",
|
|
564
|
+
Scape: "Space",
|
|
565
|
+
ArrowLeft: "ArrowLeft",
|
|
566
|
+
ArrowUp: "ArrowUp",
|
|
567
|
+
ArrowRight: "ArrowRight",
|
|
568
|
+
ArrowDown: "ArrowDown",
|
|
569
|
+
Insert: "Insert",
|
|
570
|
+
Delete: "Delete",
|
|
571
|
+
Meta: "Meta",
|
|
572
|
+
ContextMenu: "ContextMenu",
|
|
573
|
+
ScrollLock: "ScrollLock"
|
|
574
|
+
};
|
|
575
|
+
//#endregion
|
|
576
|
+
//#region src/strings/keyAlt.ts
|
|
577
|
+
/**
|
|
578
|
+
* A global namespace for `Alt` key.
|
|
579
|
+
* e.which = 18
|
|
580
|
+
*/
|
|
581
|
+
const keyAlt = "Alt";
|
|
582
|
+
//#endregion
|
|
583
|
+
//#region src/strings/keyArrowDown.ts
|
|
584
|
+
/**
|
|
585
|
+
* A global namespace for `ArrowDown` key.
|
|
586
|
+
* e.which = 40 equivalent
|
|
587
|
+
*/
|
|
588
|
+
const keyArrowDown = "ArrowDown";
|
|
589
|
+
//#endregion
|
|
590
|
+
//#region src/strings/keyArrowUp.ts
|
|
591
|
+
/**
|
|
592
|
+
* A global namespace for `ArrowUp` key.
|
|
593
|
+
* e.which = 38 equivalent
|
|
594
|
+
*/
|
|
595
|
+
const keyArrowUp = "ArrowUp";
|
|
596
|
+
//#endregion
|
|
597
|
+
//#region src/strings/keyArrowLeft.ts
|
|
598
|
+
/**
|
|
599
|
+
* A global namespace for `ArrowLeft` key.
|
|
600
|
+
* e.which = 37 equivalent
|
|
601
|
+
*/
|
|
602
|
+
const keyArrowLeft = "ArrowLeft";
|
|
603
|
+
//#endregion
|
|
604
|
+
//#region src/strings/keyArrowRight.ts
|
|
605
|
+
/**
|
|
606
|
+
* A global namespace for `ArrowRight` key.
|
|
607
|
+
* e.which = 39 equivalent
|
|
608
|
+
*/
|
|
609
|
+
const keyArrowRight = "ArrowRight";
|
|
610
|
+
//#endregion
|
|
611
|
+
//#region src/strings/keyBackspace.ts
|
|
612
|
+
/**
|
|
613
|
+
* A global namespace for `Backspace` key.
|
|
614
|
+
* e.which === 8 equivalent
|
|
615
|
+
*/
|
|
616
|
+
const keyBackspace = "Backspace";
|
|
617
|
+
//#endregion
|
|
618
|
+
//#region src/strings/keyCapsLock.ts
|
|
619
|
+
/**
|
|
620
|
+
* A global namespace for `CapsLock` key.
|
|
621
|
+
* e.which = 20 equivalent
|
|
622
|
+
*/
|
|
623
|
+
const keyCapsLock = "CapsLock";
|
|
624
|
+
//#endregion
|
|
625
|
+
//#region src/strings/keyControl.ts
|
|
626
|
+
/**
|
|
627
|
+
* A global namespace for `Control` key.
|
|
628
|
+
* e.which = 17
|
|
629
|
+
*/
|
|
630
|
+
const keyControl = "Control";
|
|
631
|
+
//#endregion
|
|
632
|
+
//#region src/strings/keyDelete.ts
|
|
633
|
+
/**
|
|
634
|
+
* A global namespace for `Delete` key.
|
|
635
|
+
* e.which = 46 equivalent
|
|
636
|
+
*/
|
|
637
|
+
const keyDelete = "Delete";
|
|
638
|
+
//#endregion
|
|
639
|
+
//#region src/strings/keyEnter.ts
|
|
640
|
+
/**
|
|
641
|
+
* A global namespace for `Enter` key.
|
|
642
|
+
* e.which = 13 equivalent
|
|
643
|
+
*/
|
|
644
|
+
const keyEnter = "Enter";
|
|
645
|
+
//#endregion
|
|
646
|
+
//#region src/strings/keyNumpadEnter.ts
|
|
647
|
+
/**
|
|
648
|
+
* A global namespace for `Enter` key.
|
|
649
|
+
* e.which = 13 equivalent
|
|
650
|
+
*/
|
|
651
|
+
const keyNumpadEnter = "NumpadEnter";
|
|
652
|
+
//#endregion
|
|
653
|
+
//#region src/strings/keyEscape.ts
|
|
654
|
+
/**
|
|
655
|
+
* A global namespace for `Escape` key.
|
|
656
|
+
* e.which = 27 equivalent
|
|
657
|
+
*/
|
|
658
|
+
const keyEscape = "Escape";
|
|
659
|
+
//#endregion
|
|
660
|
+
//#region src/strings/keyInsert.ts
|
|
661
|
+
/**
|
|
662
|
+
* A global namespace for `Insert` key.
|
|
663
|
+
* e.which = 45 equivalent
|
|
664
|
+
*/
|
|
665
|
+
const keyInsert = "Insert";
|
|
666
|
+
//#endregion
|
|
667
|
+
//#region src/strings/keyMeta.ts
|
|
668
|
+
/**
|
|
669
|
+
* A global namespace for `Meta` key.
|
|
670
|
+
* e.which = 93 equivalent
|
|
671
|
+
*/
|
|
672
|
+
const keyMeta = "Meta";
|
|
673
|
+
//#endregion
|
|
674
|
+
//#region src/strings/keyPause.ts
|
|
675
|
+
/**
|
|
676
|
+
* A global namespace for `Pause` key.
|
|
677
|
+
* e.which = 19
|
|
678
|
+
*/
|
|
679
|
+
const keyPause = "Pause";
|
|
680
|
+
//#endregion
|
|
681
|
+
//#region src/strings/keyScrollLock.ts
|
|
682
|
+
/**
|
|
683
|
+
* A global namespace for `ScrollLock` key.
|
|
684
|
+
* e.which = 145 equivalent
|
|
685
|
+
*/
|
|
686
|
+
const keyScrollLock = "ScrollLock";
|
|
687
|
+
//#endregion
|
|
688
|
+
//#region src/strings/keyShift.ts
|
|
689
|
+
/**
|
|
690
|
+
* A global namespace for `Shift` key.
|
|
691
|
+
* e.which = 16
|
|
692
|
+
*/
|
|
693
|
+
const keyShift = "Shift";
|
|
694
|
+
//#endregion
|
|
695
|
+
//#region src/strings/keySpace.ts
|
|
696
|
+
/**
|
|
697
|
+
* A global namespace for `Space` key.
|
|
698
|
+
* e.which = 32 equivalent
|
|
699
|
+
*/
|
|
700
|
+
const keySpace = "Space";
|
|
701
|
+
//#endregion
|
|
702
|
+
//#region src/strings/keyTab.ts
|
|
703
|
+
/**
|
|
704
|
+
* A global namespace for `Tab` key.
|
|
705
|
+
* e.which = 9 equivalent
|
|
706
|
+
*/
|
|
707
|
+
const keyTab = "Tab";
|
|
708
|
+
//#endregion
|
|
709
|
+
//#region src/strings/animationDuration.ts
|
|
710
|
+
/**
|
|
711
|
+
* A global namespace for 'animationDuration' string.
|
|
712
|
+
*/
|
|
713
|
+
const animationDuration = "animationDuration";
|
|
714
|
+
//#endregion
|
|
715
|
+
//#region src/strings/animationDelay.ts
|
|
716
|
+
/**
|
|
717
|
+
* A global namespace for 'animationDelay' string.
|
|
718
|
+
*/
|
|
719
|
+
const animationDelay = "animationDelay";
|
|
720
|
+
//#endregion
|
|
721
|
+
//#region src/strings/animationName.ts
|
|
722
|
+
/**
|
|
723
|
+
* A global namespace for 'animationName' string.
|
|
724
|
+
*/
|
|
725
|
+
const animationName = "animationName";
|
|
726
|
+
//#endregion
|
|
727
|
+
//#region src/strings/animationEndEvent.ts
|
|
728
|
+
/**
|
|
729
|
+
* A global namespace for 'animationend' string.
|
|
730
|
+
*/
|
|
731
|
+
const animationEndEvent = "animationend";
|
|
732
|
+
//#endregion
|
|
733
|
+
//#region src/strings/transitionDuration.ts
|
|
734
|
+
/**
|
|
735
|
+
* A global namespace for 'transitionDuration' string.
|
|
736
|
+
*/
|
|
737
|
+
const transitionDuration = "transitionDuration";
|
|
738
|
+
//#endregion
|
|
739
|
+
//#region src/strings/transitionDelay.ts
|
|
740
|
+
/**
|
|
741
|
+
* A global namespace for 'transitionDelay' string.
|
|
742
|
+
*/
|
|
743
|
+
const transitionDelay = "transitionDelay";
|
|
744
|
+
//#endregion
|
|
745
|
+
//#region src/strings/transitionEndEvent.ts
|
|
746
|
+
/**
|
|
747
|
+
* A global namespace for 'transitionend' string.
|
|
748
|
+
*/
|
|
749
|
+
const transitionEndEvent = "transitionend";
|
|
750
|
+
//#endregion
|
|
751
|
+
//#region src/strings/transitionProperty.ts
|
|
752
|
+
/**
|
|
753
|
+
* A global namespace for `transitionProperty` string for modern browsers.
|
|
754
|
+
*/
|
|
755
|
+
const transitionProperty = "transitionProperty";
|
|
756
|
+
//#endregion
|
|
757
|
+
//#region src/strings/addEventListener.ts
|
|
758
|
+
/**
|
|
759
|
+
* A global namespace for 'addEventListener' string.
|
|
760
|
+
*/
|
|
761
|
+
const addEventListener = "addEventListener";
|
|
762
|
+
//#endregion
|
|
763
|
+
//#region src/strings/removeEventListener.ts
|
|
764
|
+
/**
|
|
765
|
+
* A global namespace for 'removeEventListener' string.
|
|
766
|
+
*/
|
|
767
|
+
const removeEventListener = "removeEventListener";
|
|
768
|
+
//#endregion
|
|
769
|
+
//#region src/strings/bezierEasings.ts
|
|
770
|
+
/**
|
|
771
|
+
* A global namespace for predefined
|
|
772
|
+
* CSS3 'cubic-bezier()' easing functions.
|
|
773
|
+
*/
|
|
774
|
+
const bezierEasings = {
|
|
775
|
+
linear: "linear",
|
|
776
|
+
easingSinusoidalIn: "cubic-bezier(0.47,0,0.745,0.715)",
|
|
777
|
+
easingSinusoidalOut: "cubic-bezier(0.39,0.575,0.565,1)",
|
|
778
|
+
easingSinusoidalInOut: "cubic-bezier(0.445,0.05,0.55,0.95)",
|
|
779
|
+
easingQuadraticIn: "cubic-bezier(0.550,0.085,0.680,0.530)",
|
|
780
|
+
easingQuadraticOut: "cubic-bezier(0.250,0.460,0.450,0.940)",
|
|
781
|
+
easingQuadraticInOut: "cubic-bezier(0.455,0.030,0.515,0.955)",
|
|
782
|
+
easingCubicIn: "cubic-bezier(0.55,0.055,0.675,0.19)",
|
|
783
|
+
easingCubicOut: "cubic-bezier(0.215,0.61,0.355,1)",
|
|
784
|
+
easingCubicInOut: "cubic-bezier(0.645,0.045,0.355,1)",
|
|
785
|
+
easingQuarticIn: "cubic-bezier(0.895,0.03,0.685,0.22)",
|
|
786
|
+
easingQuarticOut: "cubic-bezier(0.165,0.84,0.44,1)",
|
|
787
|
+
easingQuarticInOut: "cubic-bezier(0.77,0,0.175,1)",
|
|
788
|
+
easingQuinticIn: "cubic-bezier(0.755,0.05,0.855,0.06)",
|
|
789
|
+
easingQuinticOut: "cubic-bezier(0.23,1,0.32,1)",
|
|
790
|
+
easingQuinticInOut: "cubic-bezier(0.86,0,0.07,1)",
|
|
791
|
+
easingExponentialIn: "cubic-bezier(0.95,0.05,0.795,0.035)",
|
|
792
|
+
easingExponentialOut: "cubic-bezier(0.19,1,0.22,1)",
|
|
793
|
+
easingExponentialInOut: "cubic-bezier(1,0,0,1)",
|
|
794
|
+
easingCircularIn: "cubic-bezier(0.6,0.04,0.98,0.335)",
|
|
795
|
+
easingCircularOut: "cubic-bezier(0.075,0.82,0.165,1)",
|
|
796
|
+
easingCircularInOut: "cubic-bezier(0.785,0.135,0.15,0.86)",
|
|
797
|
+
easingBackIn: "cubic-bezier(0.6,-0.28,0.735,0.045)",
|
|
798
|
+
easingBackOut: "cubic-bezier(0.175,0.885,0.32,1.275)",
|
|
799
|
+
easingBackInOut: "cubic-bezier(0.68,-0.55,0.265,1.55)"
|
|
800
|
+
};
|
|
801
|
+
//#endregion
|
|
802
|
+
//#region src/strings/offsetHeight.ts
|
|
803
|
+
/**
|
|
804
|
+
* A global namespace for `offsetHeight` property.
|
|
805
|
+
*/
|
|
806
|
+
const offsetHeight = "offsetHeight";
|
|
807
|
+
//#endregion
|
|
808
|
+
//#region src/strings/offsetWidth.ts
|
|
809
|
+
/**
|
|
810
|
+
* A global namespace for `offsetWidth` property.
|
|
811
|
+
*/
|
|
812
|
+
const offsetWidth = "offsetWidth";
|
|
813
|
+
//#endregion
|
|
814
|
+
//#region src/strings/scrollHeight.ts
|
|
815
|
+
/**
|
|
816
|
+
* A global namespace for `scrollHeight` property.
|
|
817
|
+
*/
|
|
818
|
+
const scrollHeight = "scrollHeight";
|
|
819
|
+
//#endregion
|
|
820
|
+
//#region src/strings/scrollWidth.ts
|
|
821
|
+
/**
|
|
822
|
+
* A global namespace for `scrollWidth` property.
|
|
823
|
+
*/
|
|
824
|
+
const scrollWidth = "scrollWidth";
|
|
825
|
+
//#endregion
|
|
826
|
+
//#region src/strings/tabindex.ts
|
|
827
|
+
/**
|
|
828
|
+
* A global namespace for `touchcancel` event.
|
|
829
|
+
*/
|
|
830
|
+
const tabindex = "tabindex";
|
|
831
|
+
//#endregion
|
|
832
|
+
//#region src/strings/userAgentData.ts
|
|
833
|
+
/**
|
|
834
|
+
* A global namespace for `userAgentData` object.
|
|
835
|
+
*/
|
|
836
|
+
const userAgentData = navigator.userAgentData;
|
|
837
|
+
//#endregion
|
|
838
|
+
//#region src/strings/userAgent.ts
|
|
839
|
+
const { userAgent: userAgentString } = navigator;
|
|
840
|
+
/**
|
|
841
|
+
* A global namespace for `navigator.userAgent` string.
|
|
842
|
+
*/
|
|
843
|
+
const userAgent = userAgentString;
|
|
844
|
+
//#endregion
|
|
845
|
+
//#region src/boolean/isMobile.ts
|
|
846
|
+
/**
|
|
847
|
+
* An accessor that checks for mobile detection.
|
|
848
|
+
*/
|
|
849
|
+
const isMobile = () => {
|
|
850
|
+
const mobileBrands = /iPhone|iPad|iPod|Android/i;
|
|
851
|
+
return navigator?.userAgentData?.brands.some((x) => mobileBrands.test(x.brand)) || mobileBrands.test(navigator?.userAgent) || false;
|
|
852
|
+
};
|
|
853
|
+
//#endregion
|
|
854
|
+
//#region src/boolean/isApple.ts
|
|
855
|
+
/**
|
|
856
|
+
* An accessor that checks for Apple browsers.
|
|
857
|
+
*/
|
|
858
|
+
const isApple = () => {
|
|
859
|
+
const appleBrands = /(iPhone|iPod|iPad)/;
|
|
860
|
+
return navigator?.userAgentData?.brands.some((x) => appleBrands.test(x.brand)) || appleBrands.test(navigator?.userAgent) || false;
|
|
861
|
+
};
|
|
862
|
+
//#endregion
|
|
863
|
+
//#region src/boolean/isFirefox.ts
|
|
864
|
+
/**
|
|
865
|
+
* An accessor that checks for Gecko browsers. When writing this file,
|
|
866
|
+
* Gecko was not supporting `userAgentData`.
|
|
867
|
+
*/
|
|
868
|
+
const isFirefox = () => navigator?.userAgent?.includes("Firefox") || false;
|
|
869
|
+
//#endregion
|
|
870
|
+
//#region src/boolean/isWebKit.ts
|
|
871
|
+
const isWebKit = () => {
|
|
872
|
+
if (typeof CSS === "undefined" || !CSS.supports) return false;
|
|
873
|
+
return CSS.supports("-webkit-backdrop-filter", "none");
|
|
874
|
+
};
|
|
875
|
+
//#endregion
|
|
876
|
+
//#region src/boolean/support3DTransform.ts
|
|
877
|
+
/**
|
|
878
|
+
* An accessor that checks for CSS3 3D transform support.
|
|
879
|
+
*/
|
|
880
|
+
const support3DTransform = () => ["webkitPerspective", "perspective"].some((p) => p in document.head.style);
|
|
881
|
+
//#endregion
|
|
882
|
+
//#region src/misc/noop.ts
|
|
883
|
+
/** A generic function with empty body. */
|
|
884
|
+
const noop = () => {};
|
|
885
|
+
//#endregion
|
|
886
|
+
//#region src/event/on.ts
|
|
887
|
+
/**
|
|
888
|
+
* Add eventListener to an `EventTarget` object.
|
|
889
|
+
*/
|
|
890
|
+
const on = (element, eventName, listener, options) => {
|
|
891
|
+
const ops = options || false;
|
|
892
|
+
element.addEventListener(eventName, listener, ops);
|
|
893
|
+
};
|
|
894
|
+
//#endregion
|
|
895
|
+
//#region src/event/off.ts
|
|
896
|
+
/**
|
|
897
|
+
* Remove eventListener from an `EventTarget` object.
|
|
898
|
+
*/
|
|
899
|
+
const off = (element, eventName, listener, options) => {
|
|
900
|
+
const ops = options || false;
|
|
901
|
+
element.removeEventListener(eventName, listener, ops);
|
|
902
|
+
};
|
|
903
|
+
//#endregion
|
|
904
|
+
//#region src/event/one.ts
|
|
905
|
+
/**
|
|
906
|
+
* Add an `eventListener` to an `EventTarget`
|
|
907
|
+
* element and remove it once callback is called.
|
|
908
|
+
*/
|
|
909
|
+
const one = (element, eventName, listener, options) => {
|
|
910
|
+
/** Wrap the listener for easy on -> off */
|
|
911
|
+
const handlerWrapper = (e) => {
|
|
912
|
+
if (e.target === element || e.currentTarget === element) {
|
|
913
|
+
listener.apply(element, [e]);
|
|
914
|
+
off(element, eventName, handlerWrapper, options);
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
on(element, eventName, handlerWrapper, options);
|
|
918
|
+
};
|
|
919
|
+
//#endregion
|
|
920
|
+
//#region src/boolean/supportPassive.ts
|
|
921
|
+
/**
|
|
922
|
+
* An accessor that checks for passive events support,
|
|
923
|
+
* in general event options are not suited for scroll prevention.
|
|
924
|
+
*
|
|
925
|
+
* @see https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#feature-detection
|
|
926
|
+
*/
|
|
927
|
+
const supportPassive = () => {
|
|
928
|
+
let result = false;
|
|
929
|
+
try {
|
|
930
|
+
const opts = Object.defineProperty({}, "passive", { get: () => {
|
|
931
|
+
result = true;
|
|
932
|
+
return result;
|
|
933
|
+
} });
|
|
934
|
+
one(document, DOMContentLoadedEvent, noop, opts);
|
|
935
|
+
} catch (_e) {}
|
|
936
|
+
return result;
|
|
937
|
+
};
|
|
938
|
+
//#endregion
|
|
939
|
+
//#region src/boolean/supportTransform.ts
|
|
940
|
+
/**
|
|
941
|
+
* An accessor that checks for CSS3 transform support.
|
|
942
|
+
*/
|
|
943
|
+
const supportTransform = () => ["webkitTransform", "transform"].some((p) => p in document.head.style);
|
|
944
|
+
//#endregion
|
|
945
|
+
//#region src/boolean/supportTouch.ts
|
|
946
|
+
/**
|
|
947
|
+
* An accessor that checks for touch events support.
|
|
948
|
+
*/
|
|
949
|
+
const supportTouch = () => "ontouchstart" in window || "msMaxTouchPoints" in navigator;
|
|
950
|
+
//#endregion
|
|
951
|
+
//#region src/boolean/supportAnimation.ts
|
|
952
|
+
/**
|
|
953
|
+
* An accessor that checks for CSS3 animation support.
|
|
954
|
+
*/
|
|
955
|
+
const supportAnimation = () => ["webkitAnimation", "animation"].some((p) => p in document.head.style);
|
|
956
|
+
//#endregion
|
|
957
|
+
//#region src/boolean/supportTransition.ts
|
|
958
|
+
/**
|
|
959
|
+
* An accessor that checks for CSS3 transition support.
|
|
960
|
+
*/
|
|
961
|
+
const supportTransition = () => ["webkitTransition", "transition"].some((p) => p in document.head.style);
|
|
962
|
+
//#endregion
|
|
963
|
+
//#region src/attr/getAttribute.ts
|
|
964
|
+
/**
|
|
965
|
+
* Shortcut for `Element.getAttribute()` method.
|
|
966
|
+
*
|
|
967
|
+
* @param element target element
|
|
968
|
+
* @param att attribute name
|
|
969
|
+
* @returns attribute value
|
|
970
|
+
*/
|
|
971
|
+
const getAttribute = (element, att) => element.getAttribute(att);
|
|
972
|
+
//#endregion
|
|
973
|
+
//#region src/attr/getAttributeNS.ts
|
|
974
|
+
/**
|
|
975
|
+
* Shortcut for `Element.getAttributeNS()` method.
|
|
976
|
+
*
|
|
977
|
+
* @param ns attribute namespace
|
|
978
|
+
* @param element target element
|
|
979
|
+
* @param att attribute name
|
|
980
|
+
* @returns attribute value
|
|
981
|
+
*/
|
|
982
|
+
const getAttributeNS = (ns, element, att) => element.getAttributeNS(ns, att);
|
|
983
|
+
//#endregion
|
|
984
|
+
//#region src/attr/hasAttribute.ts
|
|
985
|
+
/**
|
|
986
|
+
* Shortcut for `Element.hasAttribute()` method.
|
|
987
|
+
*
|
|
988
|
+
* @param element target element
|
|
989
|
+
* @param att attribute name
|
|
990
|
+
* @returns the query result
|
|
991
|
+
*/
|
|
992
|
+
const hasAttribute = (element, att) => element.hasAttribute(att);
|
|
993
|
+
//#endregion
|
|
994
|
+
//#region src/attr/hasAttributeNS.ts
|
|
995
|
+
/**
|
|
996
|
+
* Shortcut for `Element.hasAttributeNS()` method.
|
|
997
|
+
*
|
|
998
|
+
* @param ns attribute namespace
|
|
999
|
+
* @param element target element
|
|
1000
|
+
* @param att attribute name
|
|
1001
|
+
* @returns the query result
|
|
1002
|
+
*/
|
|
1003
|
+
const hasAttributeNS = (ns, element, att) => element.hasAttributeNS(ns, att);
|
|
1004
|
+
//#endregion
|
|
1005
|
+
//#region src/attr/setAttribute.ts
|
|
1006
|
+
/**
|
|
1007
|
+
* Shortcut for `Element.setAttribute()` method.
|
|
1008
|
+
*
|
|
1009
|
+
* @param element target element
|
|
1010
|
+
* @param att attribute name
|
|
1011
|
+
* @param value attribute value
|
|
1012
|
+
*/
|
|
1013
|
+
const setAttribute = (element, att, value) => element.setAttribute(att, value);
|
|
1014
|
+
//#endregion
|
|
1015
|
+
//#region src/attr/setAttributeNS.ts
|
|
1016
|
+
/**
|
|
1017
|
+
* Shortcut for `Element.setAttributeNS()` method.
|
|
1018
|
+
*
|
|
1019
|
+
* @param ns attribute namespace
|
|
1020
|
+
* @param element target element
|
|
1021
|
+
* @param att attribute name
|
|
1022
|
+
* @param value attribute value
|
|
1023
|
+
*/
|
|
1024
|
+
const setAttributeNS = (ns, element, att, value) => element.setAttributeNS(ns, att, value);
|
|
1025
|
+
//#endregion
|
|
1026
|
+
//#region src/attr/removeAttribute.ts
|
|
1027
|
+
/**
|
|
1028
|
+
* Shortcut for `Element.removeAttribute()` method.
|
|
1029
|
+
*
|
|
1030
|
+
* @param element target element
|
|
1031
|
+
* @param att attribute name
|
|
1032
|
+
*/
|
|
1033
|
+
const removeAttribute = (element, att) => element.removeAttribute(att);
|
|
1034
|
+
//#endregion
|
|
1035
|
+
//#region src/attr/removeAttributeNS.ts
|
|
1036
|
+
/**
|
|
1037
|
+
* Shortcut for `Element.removeAttributeNS()` method.
|
|
1038
|
+
*
|
|
1039
|
+
* @param ns attribute namespace
|
|
1040
|
+
* @param element target element
|
|
1041
|
+
* @param att attribute name
|
|
1042
|
+
*/
|
|
1043
|
+
const removeAttributeNS = (ns, element, att) => element.removeAttributeNS(ns, att);
|
|
1044
|
+
//#endregion
|
|
1045
|
+
//#region src/class/addClass.ts
|
|
1046
|
+
/**
|
|
1047
|
+
* Add one or more CSS classes to `Element.classList`.
|
|
1048
|
+
*
|
|
1049
|
+
* @param element target
|
|
1050
|
+
* @param classNAME to add
|
|
1051
|
+
*/
|
|
1052
|
+
const addClass = (element, ...classNAME) => {
|
|
1053
|
+
element.classList.add(...classNAME);
|
|
1054
|
+
};
|
|
1055
|
+
//#endregion
|
|
1056
|
+
//#region src/class/removeClass.ts
|
|
1057
|
+
/**
|
|
1058
|
+
* Remove one or more classes from `Element.classList`.
|
|
1059
|
+
*
|
|
1060
|
+
* @param element target
|
|
1061
|
+
* @param classNAME to remove
|
|
1062
|
+
*/
|
|
1063
|
+
const removeClass = (element, ...classNAME) => {
|
|
1064
|
+
element.classList.remove(...classNAME);
|
|
1065
|
+
};
|
|
1066
|
+
//#endregion
|
|
1067
|
+
//#region src/class/hasClass.ts
|
|
1068
|
+
/**
|
|
1069
|
+
* Check class in `Element.classList`.
|
|
1070
|
+
*
|
|
1071
|
+
* @param element target
|
|
1072
|
+
* @param classNAME to check
|
|
1073
|
+
*/
|
|
1074
|
+
const hasClass = (element, classNAME) => {
|
|
1075
|
+
return element.classList.contains(classNAME);
|
|
1076
|
+
};
|
|
1077
|
+
//#endregion
|
|
1078
|
+
//#region src/blocks/documentBody.ts
|
|
1079
|
+
/**
|
|
1080
|
+
* A global namespace for `document.body`.
|
|
1081
|
+
*/
|
|
1082
|
+
const { body: documentBody } = document;
|
|
1083
|
+
//#endregion
|
|
1084
|
+
//#region src/blocks/documentElement.ts
|
|
1085
|
+
/**
|
|
1086
|
+
* A global namespace for `document.documentElement` or the `<HTML>`.
|
|
1087
|
+
*/
|
|
1088
|
+
const { documentElement } = document;
|
|
1089
|
+
//#endregion
|
|
1090
|
+
//#region src/blocks/documentHead.ts
|
|
1091
|
+
/**
|
|
1092
|
+
* A global namespace for `document.head`.
|
|
1093
|
+
*/
|
|
1094
|
+
const { head: documentHead } = document;
|
|
1095
|
+
//#endregion
|
|
1096
|
+
//#region src/misc/ArrayFrom.ts
|
|
1097
|
+
/**
|
|
1098
|
+
* Shortie for `Array.from()` static method.
|
|
1099
|
+
* The utility should also work with any typed arrays
|
|
1100
|
+
* like Float64Array or Int32Array.
|
|
1101
|
+
*
|
|
1102
|
+
* @param arr array-like iterable object
|
|
1103
|
+
* @returns a new array from iterable object
|
|
1104
|
+
*/
|
|
1105
|
+
const ArrayFrom = (arr) => Array.from(arr);
|
|
1106
|
+
//#endregion
|
|
1107
|
+
//#region src/is/isObject.ts
|
|
1108
|
+
/**
|
|
1109
|
+
* Checks if a value is an `Object`.
|
|
1110
|
+
*
|
|
1111
|
+
* @param obj the target object
|
|
1112
|
+
* @returns the query result
|
|
1113
|
+
*/
|
|
1114
|
+
const isObject = (obj) => obj !== null && obj !== void 0 && typeof obj === "object" || false;
|
|
1115
|
+
//#endregion
|
|
1116
|
+
//#region src/is/isNode.ts
|
|
1117
|
+
/**
|
|
1118
|
+
* Checks if an object is a `Node`.
|
|
1119
|
+
*
|
|
1120
|
+
* @param node the target object
|
|
1121
|
+
* @see https://dom.spec.whatwg.org/#node
|
|
1122
|
+
*
|
|
1123
|
+
* ```
|
|
1124
|
+
* ELEMENT_NODE = 1;
|
|
1125
|
+
* ATTRIBUTE_NODE = 2;
|
|
1126
|
+
* TEXT_NODE = 3;
|
|
1127
|
+
* CDATA_SECTION_NODE = 4;
|
|
1128
|
+
* ENTITY_REFERENCE_NODE = 5; // legacy
|
|
1129
|
+
* ENTITY_NODE = 6; // legacy
|
|
1130
|
+
* PROCESSING_INSTRUCTION_NODE = 7;
|
|
1131
|
+
* COMMENT_NODE = 8;
|
|
1132
|
+
* DOCUMENT_NODE = 9;
|
|
1133
|
+
* DOCUMENT_TYPE_NODE = 10;
|
|
1134
|
+
* DOCUMENT_FRAGMENT_NODE = 11;
|
|
1135
|
+
* @returns the query result
|
|
1136
|
+
*/
|
|
1137
|
+
const isNode = (node) => isObject(node) && typeof node.nodeType === "number" && [
|
|
1138
|
+
1,
|
|
1139
|
+
2,
|
|
1140
|
+
3,
|
|
1141
|
+
4,
|
|
1142
|
+
5,
|
|
1143
|
+
6,
|
|
1144
|
+
7,
|
|
1145
|
+
8,
|
|
1146
|
+
9,
|
|
1147
|
+
10,
|
|
1148
|
+
11
|
|
1149
|
+
].some((x) => node.nodeType === x) || false;
|
|
1150
|
+
//#endregion
|
|
1151
|
+
//#region src/is/isElement.ts
|
|
1152
|
+
/**
|
|
1153
|
+
* Checks if an object is an `Element`.
|
|
1154
|
+
*
|
|
1155
|
+
* @param element the target object
|
|
1156
|
+
* @returns the query result
|
|
1157
|
+
*/
|
|
1158
|
+
const isElement = (element) => isNode(element) && element.nodeType === 1 || false;
|
|
1159
|
+
//#endregion
|
|
1160
|
+
//#region src/misc/data.ts
|
|
1161
|
+
const componentData = /* @__PURE__ */ new Map();
|
|
1162
|
+
/**
|
|
1163
|
+
* An interface for web components background data.
|
|
1164
|
+
*
|
|
1165
|
+
* @see https://github.com/thednp/bootstrap.native/blob/master/src/components/base-component.js
|
|
1166
|
+
*/
|
|
1167
|
+
const Data = {
|
|
1168
|
+
data: componentData,
|
|
1169
|
+
set: (element, component, instance) => {
|
|
1170
|
+
if (!isElement(element)) return;
|
|
1171
|
+
if (!componentData.has(component)) componentData.set(component, /* @__PURE__ */ new Map());
|
|
1172
|
+
componentData.get(component).set(element, instance);
|
|
1173
|
+
},
|
|
1174
|
+
getAllFor: (component) => {
|
|
1175
|
+
return componentData.get(component) || null;
|
|
1176
|
+
},
|
|
1177
|
+
get: (element, component) => {
|
|
1178
|
+
if (!isElement(element) || !component) return null;
|
|
1179
|
+
const instanceMap = Data.getAllFor(component);
|
|
1180
|
+
return element && instanceMap && instanceMap.get(element) || null;
|
|
1181
|
+
},
|
|
1182
|
+
remove: (element, component) => {
|
|
1183
|
+
const instanceMap = Data.getAllFor(component);
|
|
1184
|
+
if (!instanceMap || !isElement(element)) return;
|
|
1185
|
+
instanceMap.delete(element);
|
|
1186
|
+
if (instanceMap.size === 0) componentData.delete(component);
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
//#endregion
|
|
1190
|
+
//#region src/misc/getInstance.ts
|
|
1191
|
+
/**
|
|
1192
|
+
* An alias for `Data.get()`.
|
|
1193
|
+
*/
|
|
1194
|
+
const getInstance = (target, component) => Data.get(target, component);
|
|
1195
|
+
//#endregion
|
|
1196
|
+
//#region src/misc/capitalize.ts
|
|
1197
|
+
/**
|
|
1198
|
+
* Capitalize first character in a string.
|
|
1199
|
+
* @param input source string
|
|
1200
|
+
*/
|
|
1201
|
+
const capitalize = (input) => input?.charAt(0).toUpperCase() + input?.slice(1);
|
|
1202
|
+
//#endregion
|
|
1203
|
+
//#region src/misc/camelCase.ts
|
|
1204
|
+
/**
|
|
1205
|
+
* Transform a string to camel case.
|
|
1206
|
+
* @param input source string
|
|
1207
|
+
*/
|
|
1208
|
+
const camelCase = (input) => input?.trim().replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) => index === 0 ? word.toLowerCase() : word.toUpperCase()).replace(/\s+/g, "");
|
|
1209
|
+
//#endregion
|
|
1210
|
+
//#region src/is/isString.ts
|
|
1211
|
+
/**
|
|
1212
|
+
* Shortie for `typeof SOMETHING === "string"`.
|
|
1213
|
+
*
|
|
1214
|
+
* @param str input value
|
|
1215
|
+
* @returns the query result
|
|
1216
|
+
*/
|
|
1217
|
+
const isString = (str) => typeof str === "string" || false;
|
|
1218
|
+
//#endregion
|
|
1219
|
+
//#region src/is/isWindow.ts
|
|
1220
|
+
/**
|
|
1221
|
+
* Check if a target object is `Window`.
|
|
1222
|
+
* => equivalent to `object instanceof Window`
|
|
1223
|
+
*
|
|
1224
|
+
* @param obj the target object
|
|
1225
|
+
* @returns the query result
|
|
1226
|
+
*/
|
|
1227
|
+
const isWindow = (obj) => isObject(obj) && obj.constructor.name === "Window" || false;
|
|
1228
|
+
//#endregion
|
|
1229
|
+
//#region src/is/isDocument.ts
|
|
1230
|
+
/**
|
|
1231
|
+
* Checks if an object is a `Document`.
|
|
1232
|
+
*
|
|
1233
|
+
* @see https://dom.spec.whatwg.org/#node
|
|
1234
|
+
*
|
|
1235
|
+
* @param obj the target object
|
|
1236
|
+
* @returns the query result
|
|
1237
|
+
*/
|
|
1238
|
+
const isDocument = (obj) => isNode(obj) && obj.nodeType === 9 || false;
|
|
1239
|
+
//#endregion
|
|
1240
|
+
//#region src/get/getDocument.ts
|
|
1241
|
+
/**
|
|
1242
|
+
* Returns the `document` or the `#document` element.
|
|
1243
|
+
*
|
|
1244
|
+
* @see https://github.com/floating-ui/floating-ui
|
|
1245
|
+
*
|
|
1246
|
+
* @param node the reference node
|
|
1247
|
+
* @returns the parent document of the given node
|
|
1248
|
+
*/
|
|
1249
|
+
const getDocument = (node) => {
|
|
1250
|
+
if (isDocument(node)) return node;
|
|
1251
|
+
if (isNode(node)) return node.ownerDocument;
|
|
1252
|
+
if (isWindow(node)) return node.document;
|
|
1253
|
+
return globalThis.document;
|
|
1254
|
+
};
|
|
1255
|
+
//#endregion
|
|
1256
|
+
//#region src/misc/ObjectAssign.ts
|
|
1257
|
+
/**
|
|
1258
|
+
* Shortcut for `Object.assign()` static method.
|
|
1259
|
+
*
|
|
1260
|
+
* @param obj a target object
|
|
1261
|
+
* @param source source object(s)
|
|
1262
|
+
* @see https://github.com/devinrhode2/ObjectTyped/blob/master/src/index.ts
|
|
1263
|
+
*/
|
|
1264
|
+
const ObjectAssign = (obj, ...source) => Object.assign(obj, ...source);
|
|
1265
|
+
//#endregion
|
|
1266
|
+
//#region src/misc/createElement.ts
|
|
1267
|
+
/**
|
|
1268
|
+
* Shortie for `document.createElement` method
|
|
1269
|
+
* which allows you to create a new `HTMLElement` for a given `tagName`
|
|
1270
|
+
* or based on an object with specific non-readonly attributes with string values:
|
|
1271
|
+
* `id`, `className`, `textContent`, `style`, etc.
|
|
1272
|
+
*
|
|
1273
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement
|
|
1274
|
+
*
|
|
1275
|
+
* @param param `tagName` or object
|
|
1276
|
+
* @return a new `HTMLElement`
|
|
1277
|
+
*/
|
|
1278
|
+
const createElement = (param) => {
|
|
1279
|
+
if (!param) return void 0;
|
|
1280
|
+
if (isString(param)) return getDocument().createElement(param);
|
|
1281
|
+
const { tagName } = param;
|
|
1282
|
+
const newElement = createElement(tagName);
|
|
1283
|
+
if (!newElement) return void 0;
|
|
1284
|
+
const attr = { ...param };
|
|
1285
|
+
delete attr.tagName;
|
|
1286
|
+
return ObjectAssign(newElement, attr);
|
|
1287
|
+
};
|
|
1288
|
+
//#endregion
|
|
1289
|
+
//#region src/misc/createElementNS.ts
|
|
1290
|
+
/**
|
|
1291
|
+
* Shortie for `document.createElementNS` method
|
|
1292
|
+
* which allows you to create a new `Element` for a given `tagName`
|
|
1293
|
+
* or based on an object with specific non-readonly attributes with string values:
|
|
1294
|
+
* `id`, `className`, `textContent`, `style`, etc.
|
|
1295
|
+
* Note: some elements resulted from this function call may not be compatible with
|
|
1296
|
+
* some attributes.
|
|
1297
|
+
*
|
|
1298
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createElementNS
|
|
1299
|
+
*
|
|
1300
|
+
* @param ns `namespaceURI` to associate with the new `Element`
|
|
1301
|
+
* @param param `tagName` or object
|
|
1302
|
+
* @return a new `Element`
|
|
1303
|
+
*/
|
|
1304
|
+
const createElementNS = (ns, param) => {
|
|
1305
|
+
if (!ns || !param) return void 0;
|
|
1306
|
+
if (isString(param)) return getDocument().createElementNS(ns, param);
|
|
1307
|
+
const { tagName } = param;
|
|
1308
|
+
const newElement = createElementNS(ns, tagName);
|
|
1309
|
+
if (!newElement) return void 0;
|
|
1310
|
+
const attr = { ...param };
|
|
1311
|
+
delete attr.tagName;
|
|
1312
|
+
return ObjectAssign(newElement, attr);
|
|
1313
|
+
};
|
|
1314
|
+
//#endregion
|
|
1315
|
+
//#region src/misc/dispatchEvent.ts
|
|
1316
|
+
/**
|
|
1317
|
+
* Shortcut for the `Element.dispatchEvent(Event)` method.
|
|
1318
|
+
*
|
|
1319
|
+
* @param element is the target
|
|
1320
|
+
* @param event is the `Event` object
|
|
1321
|
+
*/
|
|
1322
|
+
const dispatchEvent = (element, event) => element.dispatchEvent(event);
|
|
1323
|
+
//#endregion
|
|
1324
|
+
//#region src/misc/distinct.ts
|
|
1325
|
+
/**
|
|
1326
|
+
* JavaScript `Array` distinct.
|
|
1327
|
+
*
|
|
1328
|
+
* @see https://codeburst.io/javascript-array-distinct-5edc93501dc4
|
|
1329
|
+
*
|
|
1330
|
+
* @example
|
|
1331
|
+
* ```
|
|
1332
|
+
* [0,1,1,2].filter(distinct)
|
|
1333
|
+
* // => [0,1,2]
|
|
1334
|
+
* ```
|
|
1335
|
+
* @param value array item value
|
|
1336
|
+
* @param index array item index
|
|
1337
|
+
* @param arr a clone of the target array
|
|
1338
|
+
* @returns the query result
|
|
1339
|
+
*/
|
|
1340
|
+
const distinct = (value, index, arr) => arr.indexOf(value) === index;
|
|
1341
|
+
//#endregion
|
|
1342
|
+
//#region src/get/getElementStyle.ts
|
|
1343
|
+
/**
|
|
1344
|
+
* Shortcut for `window.getComputedStyle(element).propertyName`
|
|
1345
|
+
* static method.
|
|
1346
|
+
*
|
|
1347
|
+
* * If `element` parameter is not an `Element`, `getComputedStyle`
|
|
1348
|
+
* throws a `ReferenceError`.
|
|
1349
|
+
*
|
|
1350
|
+
* @param element target `Element`
|
|
1351
|
+
* @param property the css property
|
|
1352
|
+
* @param pseudoElt pseudo-elements
|
|
1353
|
+
* @return the css property value
|
|
1354
|
+
*/
|
|
1355
|
+
const getElementStyle = (element, property, pseudoElt) => {
|
|
1356
|
+
const computedStyle = getComputedStyle(element, pseudoElt);
|
|
1357
|
+
const prop = property.replace("webkit", "Webkit").replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
1358
|
+
return computedStyle.getPropertyValue(prop);
|
|
1359
|
+
};
|
|
1360
|
+
//#endregion
|
|
1361
|
+
//#region src/get/getElementAnimationDelay.ts
|
|
1362
|
+
/**
|
|
1363
|
+
* Utility to get the computed `animationDelay`
|
|
1364
|
+
* from Element in miliseconds.
|
|
1365
|
+
*
|
|
1366
|
+
* @param element target
|
|
1367
|
+
* @return the `animationDelay` value in miliseconds
|
|
1368
|
+
*/
|
|
1369
|
+
const getElementAnimationDelay = (element) => {
|
|
1370
|
+
const propertyValue = getElementStyle(element, animationName);
|
|
1371
|
+
const durationValue = getElementStyle(element, animationDelay);
|
|
1372
|
+
const durationScale = durationValue.includes("ms") ? 1 : 1e3;
|
|
1373
|
+
const duration = propertyValue && propertyValue !== "none" ? parseFloat(durationValue) * durationScale : 0;
|
|
1374
|
+
return !Number.isNaN(duration) ? duration : 0;
|
|
1375
|
+
};
|
|
1376
|
+
//#endregion
|
|
1377
|
+
//#region src/get/getElementAnimationDuration.ts
|
|
1378
|
+
/**
|
|
1379
|
+
* Utility to get the computed `animationDuration`
|
|
1380
|
+
* from `Element` in miliseconds.
|
|
1381
|
+
*
|
|
1382
|
+
* @param element target
|
|
1383
|
+
* @return the `animationDuration` value in miliseconds
|
|
1384
|
+
*/
|
|
1385
|
+
const getElementAnimationDuration = (element) => {
|
|
1386
|
+
const propertyValue = getElementStyle(element, animationName);
|
|
1387
|
+
const durationValue = getElementStyle(element, animationDuration);
|
|
1388
|
+
const durationScale = durationValue.includes("ms") ? 1 : 1e3;
|
|
1389
|
+
const duration = propertyValue && propertyValue !== "none" ? parseFloat(durationValue) * durationScale : 0;
|
|
1390
|
+
return !Number.isNaN(duration) ? duration : 0;
|
|
1391
|
+
};
|
|
1392
|
+
//#endregion
|
|
1393
|
+
//#region src/misc/emulateAnimationEnd.ts
|
|
1394
|
+
/**
|
|
1395
|
+
* Utility to make sure callbacks are consistently
|
|
1396
|
+
* called when animation ends.
|
|
1397
|
+
*
|
|
1398
|
+
* @param element target
|
|
1399
|
+
* @param handler `animationend` callback
|
|
1400
|
+
*/
|
|
1401
|
+
const emulateAnimationEnd = (element, handler) => {
|
|
1402
|
+
let called = 0;
|
|
1403
|
+
const endEvent = new Event(animationEndEvent);
|
|
1404
|
+
const duration = getElementAnimationDuration(element);
|
|
1405
|
+
const delay = getElementAnimationDelay(element);
|
|
1406
|
+
if (duration) {
|
|
1407
|
+
const animationEndWrapper = (e) => {
|
|
1408
|
+
if (e.target === element) {
|
|
1409
|
+
handler.apply(element, [e]);
|
|
1410
|
+
element.removeEventListener(animationEndEvent, animationEndWrapper);
|
|
1411
|
+
called = 1;
|
|
1412
|
+
}
|
|
1413
|
+
};
|
|
1414
|
+
element.addEventListener(animationEndEvent, animationEndWrapper);
|
|
1415
|
+
setTimeout(() => {
|
|
1416
|
+
if (!called) dispatchEvent(element, endEvent);
|
|
1417
|
+
}, duration + delay + 17);
|
|
1418
|
+
} else handler.apply(element, [endEvent]);
|
|
1419
|
+
};
|
|
1420
|
+
//#endregion
|
|
1421
|
+
//#region src/get/getElementTransitionDelay.ts
|
|
1422
|
+
/**
|
|
1423
|
+
* Utility to get the computed `transitionDelay`
|
|
1424
|
+
* from Element in miliseconds.
|
|
1425
|
+
*
|
|
1426
|
+
* @param element target
|
|
1427
|
+
* @return the `transitionDelay` value in miliseconds
|
|
1428
|
+
*/
|
|
1429
|
+
const getElementTransitionDelay = (element) => {
|
|
1430
|
+
const propertyValue = getElementStyle(element, transitionProperty);
|
|
1431
|
+
const delayValue = getElementStyle(element, transitionDelay);
|
|
1432
|
+
const delayScale = delayValue.includes("ms") ? 1 : 1e3;
|
|
1433
|
+
const duration = propertyValue && propertyValue !== "none" ? parseFloat(delayValue) * delayScale : 0;
|
|
1434
|
+
return !Number.isNaN(duration) ? duration : 0;
|
|
1435
|
+
};
|
|
1436
|
+
//#endregion
|
|
1437
|
+
//#region src/get/getElementTransitionDuration.ts
|
|
1438
|
+
/**
|
|
1439
|
+
* Utility to get the computed `transitionDuration`
|
|
1440
|
+
* from Element in miliseconds.
|
|
1441
|
+
*
|
|
1442
|
+
* @param element target
|
|
1443
|
+
* @return the `transitionDuration` value in miliseconds
|
|
1444
|
+
*/
|
|
1445
|
+
const getElementTransitionDuration = (element) => {
|
|
1446
|
+
const propertyValue = getElementStyle(element, transitionProperty);
|
|
1447
|
+
const durationValue = getElementStyle(element, transitionDuration);
|
|
1448
|
+
const durationScale = durationValue.includes("ms") ? 1 : 1e3;
|
|
1449
|
+
const duration = propertyValue && propertyValue !== "none" ? parseFloat(durationValue) * durationScale : 0;
|
|
1450
|
+
return !Number.isNaN(duration) ? duration : 0;
|
|
1451
|
+
};
|
|
1452
|
+
//#endregion
|
|
1453
|
+
//#region src/misc/emulateTransitionEnd.ts
|
|
1454
|
+
/**
|
|
1455
|
+
* Utility to make sure callbacks are consistently
|
|
1456
|
+
* called when transition ends.
|
|
1457
|
+
*
|
|
1458
|
+
* @param element element target
|
|
1459
|
+
* @param handler `transitionend` callback
|
|
1460
|
+
*/
|
|
1461
|
+
const emulateTransitionEnd = (element, handler) => {
|
|
1462
|
+
let called = 0;
|
|
1463
|
+
const endEvent = new Event(transitionEndEvent);
|
|
1464
|
+
const duration = getElementTransitionDuration(element);
|
|
1465
|
+
const delay = getElementTransitionDelay(element);
|
|
1466
|
+
if (duration) {
|
|
1467
|
+
const transitionEndWrapper = (e) => {
|
|
1468
|
+
if (e.target === element) {
|
|
1469
|
+
handler.apply(element, [e]);
|
|
1470
|
+
element.removeEventListener(transitionEndEvent, transitionEndWrapper);
|
|
1471
|
+
called = 1;
|
|
1472
|
+
}
|
|
1473
|
+
};
|
|
1474
|
+
element.addEventListener(transitionEndEvent, transitionEndWrapper);
|
|
1475
|
+
setTimeout(() => {
|
|
1476
|
+
if (!called) dispatchEvent(element, endEvent);
|
|
1477
|
+
}, duration + delay + 17);
|
|
1478
|
+
} else handler.apply(element, [endEvent]);
|
|
1479
|
+
};
|
|
1480
|
+
//#endregion
|
|
1481
|
+
//#region src/misc/Float32ArrayFrom.ts
|
|
1482
|
+
/**
|
|
1483
|
+
* Shortcut for `Float32Array.from()` static method.
|
|
1484
|
+
*
|
|
1485
|
+
* @param arr array-like iterable object
|
|
1486
|
+
* @returns a new Float32Array
|
|
1487
|
+
*/
|
|
1488
|
+
const Float32ArrayFrom = (arr) => Float32Array.from(Array.from(arr));
|
|
1489
|
+
//#endregion
|
|
1490
|
+
//#region src/misc/Float64ArrayFrom.ts
|
|
1491
|
+
/**
|
|
1492
|
+
* Shortcut for `Float64Array.from()` static method.
|
|
1493
|
+
*
|
|
1494
|
+
* @param arr array-like iterable object
|
|
1495
|
+
* @returns a new Float64Array
|
|
1496
|
+
*/
|
|
1497
|
+
const Float64ArrayFrom = (arr) => Float64Array.from(Array.from(arr));
|
|
1498
|
+
//#endregion
|
|
1499
|
+
//#region src/misc/focus.ts
|
|
1500
|
+
/**
|
|
1501
|
+
* Shortie for `HTMLOrSVGElement.focus()` method.
|
|
1502
|
+
*
|
|
1503
|
+
* @param element is the target
|
|
1504
|
+
* @param options allows to pass additional options such as `preventScroll: boolean`
|
|
1505
|
+
*/
|
|
1506
|
+
const focus = (element, options) => element.focus(options);
|
|
1507
|
+
//#endregion
|
|
1508
|
+
//#region src/misc/kebabCase.ts
|
|
1509
|
+
/**
|
|
1510
|
+
* Transform a string to kebab case.
|
|
1511
|
+
* @param input source string
|
|
1512
|
+
*/
|
|
1513
|
+
const kebabCase = (input) => input?.trim().replace(/([a-z])([A-Z])/g, "$1-$2").replace(/\s+/g, "-").toLowerCase();
|
|
1514
|
+
//#endregion
|
|
1515
|
+
//#region src/misc/normalizeValue.ts
|
|
1516
|
+
/**
|
|
1517
|
+
* Utility to normalize component options
|
|
1518
|
+
*
|
|
1519
|
+
* @param value the input value
|
|
1520
|
+
* @return the normalized value
|
|
1521
|
+
*/
|
|
1522
|
+
const normalizeValue = (value) => {
|
|
1523
|
+
if (["true", true].includes(value)) return true;
|
|
1524
|
+
if (["false", false].includes(value)) return false;
|
|
1525
|
+
if ([
|
|
1526
|
+
"null",
|
|
1527
|
+
"",
|
|
1528
|
+
null,
|
|
1529
|
+
void 0
|
|
1530
|
+
].includes(value)) return null;
|
|
1531
|
+
if (value !== "" && !Number.isNaN(+value)) return +value;
|
|
1532
|
+
return value;
|
|
1533
|
+
};
|
|
1534
|
+
//#endregion
|
|
1535
|
+
//#region src/misc/ObjectEntries.ts
|
|
1536
|
+
/**
|
|
1537
|
+
* Shortcut for `Object.entries()` static method.
|
|
1538
|
+
*
|
|
1539
|
+
* @param obj a target object
|
|
1540
|
+
* @returns the entries of an object in an array format [key, value][]
|
|
1541
|
+
* @see https://github.com/devinrhode2/ObjectTyped/blob/master/src/index.ts
|
|
1542
|
+
*/
|
|
1543
|
+
const ObjectEntries = (obj) => Object.entries(obj);
|
|
1544
|
+
//#endregion
|
|
1545
|
+
//#region src/misc/normalizeOptions.ts
|
|
1546
|
+
/**
|
|
1547
|
+
* Utility to normalize component options.
|
|
1548
|
+
*
|
|
1549
|
+
* @param element target
|
|
1550
|
+
* @param defaultOps component default options
|
|
1551
|
+
* @param inputOps component instance options
|
|
1552
|
+
* @param ns component namespace
|
|
1553
|
+
* @return normalized component options object
|
|
1554
|
+
*/
|
|
1555
|
+
const normalizeOptions = (element, defaultOps, inputOps, ns) => {
|
|
1556
|
+
if (!isElement(element)) return defaultOps;
|
|
1557
|
+
const INPUT = { ...inputOps };
|
|
1558
|
+
const data = { ...element.dataset };
|
|
1559
|
+
const normalOps = { ...defaultOps };
|
|
1560
|
+
const dataOps = {};
|
|
1561
|
+
const title = "title";
|
|
1562
|
+
ObjectEntries(data).forEach(([k, v]) => {
|
|
1563
|
+
const key = ns && typeof k === "string" && k.includes(ns) ? camelCase(k.replace(ns, "")) : camelCase(k);
|
|
1564
|
+
dataOps[key] = normalizeValue(v);
|
|
1565
|
+
});
|
|
1566
|
+
ObjectEntries(INPUT).forEach(([k, v]) => {
|
|
1567
|
+
INPUT[k] = normalizeValue(v);
|
|
1568
|
+
});
|
|
1569
|
+
ObjectEntries(defaultOps).forEach(([k, v]) => {
|
|
1570
|
+
if (k in INPUT) normalOps[k] = INPUT[k];
|
|
1571
|
+
else if (k in dataOps) normalOps[k] = dataOps[k];
|
|
1572
|
+
else normalOps[k] = k === title ? getAttribute(element, title) : v;
|
|
1573
|
+
});
|
|
1574
|
+
return normalOps;
|
|
1575
|
+
};
|
|
1576
|
+
//#endregion
|
|
1577
|
+
//#region src/misc/ObjectHasOwn.ts
|
|
1578
|
+
/**
|
|
1579
|
+
* A shortcut to `Object.hasOwn()` static method to work
|
|
1580
|
+
* with regular `Object` elements.
|
|
1581
|
+
*
|
|
1582
|
+
* @see https://fettblog.eu/typescript-hasownproperty/
|
|
1583
|
+
* @param obj the target object
|
|
1584
|
+
* @param prop the property to check
|
|
1585
|
+
* @returns the query result
|
|
1586
|
+
*/
|
|
1587
|
+
const ObjectHasOwn = (obj, prop) => isObject(obj) && (Object.hasOwn(obj, prop) || prop in obj);
|
|
1588
|
+
//#endregion
|
|
1589
|
+
//#region src/misc/ObjectKeys.ts
|
|
1590
|
+
/**
|
|
1591
|
+
* Shortcut for `Object.keys()` static method.
|
|
1592
|
+
*
|
|
1593
|
+
* @param obj a target object
|
|
1594
|
+
* @returns an array with object keys
|
|
1595
|
+
* @see https://github.com/devinrhode2/ObjectTyped/blob/master/src/index.ts
|
|
1596
|
+
*/
|
|
1597
|
+
const ObjectKeys = (obj) => Object.keys(obj);
|
|
1598
|
+
//#endregion
|
|
1599
|
+
//#region src/misc/ObjectValues.ts
|
|
1600
|
+
/**
|
|
1601
|
+
* Shortcut for `Object.values()` static method.
|
|
1602
|
+
*
|
|
1603
|
+
* @param obj a target object
|
|
1604
|
+
* @returns an array with the object values
|
|
1605
|
+
* @see https://github.com/devinrhode2/ObjectTyped/blob/master/src/index.ts
|
|
1606
|
+
*/
|
|
1607
|
+
const ObjectValues = (obj) => Object.values(obj);
|
|
1608
|
+
//#endregion
|
|
1609
|
+
//#region src/misc/ObjectFromEntries.ts
|
|
1610
|
+
/**
|
|
1611
|
+
* Shortcut for `Object.fromEntries()` static method.
|
|
1612
|
+
*
|
|
1613
|
+
* @param entries a target entries object
|
|
1614
|
+
* @returns a new Object created from the specified entries in array format [key, value][]
|
|
1615
|
+
* @see https://github.com/devinrhode2/ObjectTyped/blob/master/src/index.ts
|
|
1616
|
+
*/
|
|
1617
|
+
const ObjectFromEntries = (entries) => Object.fromEntries(entries);
|
|
1618
|
+
//#endregion
|
|
1619
|
+
//#region src/misc/createCustomEvent.ts
|
|
1620
|
+
/**
|
|
1621
|
+
* Returns a namespaced `CustomEvent` specific to each component.
|
|
1622
|
+
*
|
|
1623
|
+
* @param eventType Event.type
|
|
1624
|
+
* @param config Event.options | Event.properties
|
|
1625
|
+
* @returns a new namespaced event
|
|
1626
|
+
*/
|
|
1627
|
+
const createCustomEvent = (eventType, config) => {
|
|
1628
|
+
const OriginalCustomEvent = new CustomEvent(eventType, {
|
|
1629
|
+
cancelable: true,
|
|
1630
|
+
bubbles: true
|
|
1631
|
+
});
|
|
1632
|
+
if (isObject(config)) ObjectAssign(OriginalCustomEvent, config);
|
|
1633
|
+
return OriginalCustomEvent;
|
|
1634
|
+
};
|
|
1635
|
+
//#endregion
|
|
1636
|
+
//#region src/misc/passiveHandler.ts
|
|
1637
|
+
/**
|
|
1638
|
+
* A global namespace for most scroll event listeners.
|
|
1639
|
+
*/
|
|
1640
|
+
const passiveHandler = { passive: true };
|
|
1641
|
+
//#endregion
|
|
1642
|
+
//#region src/misc/reflow.ts
|
|
1643
|
+
/**
|
|
1644
|
+
* Utility to force re-paint of an `HTMLElement` target.
|
|
1645
|
+
*
|
|
1646
|
+
* @param element is the target
|
|
1647
|
+
* @return the `Element.offsetHeight` value
|
|
1648
|
+
*/
|
|
1649
|
+
const reflow = (element) => element.offsetHeight;
|
|
1650
|
+
//#endregion
|
|
1651
|
+
//#region src/misc/setElementStyle.ts
|
|
1652
|
+
/**
|
|
1653
|
+
* Shortcut for multiple uses of `HTMLElement.style.propertyName` method.
|
|
1654
|
+
*
|
|
1655
|
+
* @param element target element
|
|
1656
|
+
* @param styles attribute value
|
|
1657
|
+
*/
|
|
1658
|
+
const setElementStyle = (element, styles) => {
|
|
1659
|
+
ObjectEntries(styles).forEach(([key, value]) => {
|
|
1660
|
+
if (value && isString(key) && key.includes("--")) element.style.setProperty(key, value);
|
|
1661
|
+
else {
|
|
1662
|
+
const propObject = {};
|
|
1663
|
+
propObject[key] = value;
|
|
1664
|
+
ObjectAssign(element.style, propObject);
|
|
1665
|
+
}
|
|
1666
|
+
});
|
|
1667
|
+
};
|
|
1668
|
+
//#endregion
|
|
1669
|
+
//#region src/is/isMap.ts
|
|
1670
|
+
/**
|
|
1671
|
+
* Checks if an element is a `Map`.
|
|
1672
|
+
*
|
|
1673
|
+
* @param obj the target object
|
|
1674
|
+
* @returns the query result
|
|
1675
|
+
*/
|
|
1676
|
+
const isMap = (obj) => isObject(obj) && obj.constructor.name === "Map" || false;
|
|
1677
|
+
//#endregion
|
|
1678
|
+
//#region src/is/isNumber.ts
|
|
1679
|
+
/**
|
|
1680
|
+
* Shortie for `typeof SOMETHING === "number"`.
|
|
1681
|
+
*
|
|
1682
|
+
* @param num input value
|
|
1683
|
+
* @returns the query result
|
|
1684
|
+
*/
|
|
1685
|
+
const isNumber = (num) => typeof num === "number" || false;
|
|
1686
|
+
//#endregion
|
|
1687
|
+
//#region src/misc/timer.ts
|
|
1688
|
+
const TimeCache = /* @__PURE__ */ new Map();
|
|
1689
|
+
/**
|
|
1690
|
+
* An interface for one or more `TimerHandler`s per `Element`.
|
|
1691
|
+
*
|
|
1692
|
+
* @see https://github.com/thednp/navbar/
|
|
1693
|
+
*/
|
|
1694
|
+
const Timer = {
|
|
1695
|
+
set: (element, callback, delay, key) => {
|
|
1696
|
+
if (!isElement(element)) return;
|
|
1697
|
+
// @license test comment
|
|
1698
|
+
/* @license comment */
|
|
1699
|
+
/* test @license comment */
|
|
1700
|
+
if (key && key.length) {
|
|
1701
|
+
if (!TimeCache.has(element)) TimeCache.set(element, /* @__PURE__ */ new Map());
|
|
1702
|
+
TimeCache.get(element).set(key, setTimeout(callback, delay));
|
|
1703
|
+
} else TimeCache.set(element, setTimeout(callback, delay));
|
|
1704
|
+
},
|
|
1705
|
+
get: (element, key) => {
|
|
1706
|
+
if (!isElement(element)) return null;
|
|
1707
|
+
const keyTimers = TimeCache.get(element);
|
|
1708
|
+
if (key && keyTimers && isMap(keyTimers)) return keyTimers.get(key) || null;
|
|
1709
|
+
else if (isNumber(keyTimers)) return keyTimers;
|
|
1710
|
+
return null;
|
|
1711
|
+
},
|
|
1712
|
+
clear: (element, key) => {
|
|
1713
|
+
if (!isElement(element)) return;
|
|
1714
|
+
const keyTimers = TimeCache.get(element);
|
|
1715
|
+
if (key && key.length && isMap(keyTimers)) {
|
|
1716
|
+
clearTimeout(keyTimers.get(key));
|
|
1717
|
+
keyTimers.delete(key);
|
|
1718
|
+
if (keyTimers.size === 0) TimeCache.delete(element);
|
|
1719
|
+
} else {
|
|
1720
|
+
clearTimeout(keyTimers);
|
|
1721
|
+
TimeCache.delete(element);
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
};
|
|
1725
|
+
//#endregion
|
|
1726
|
+
//#region src/misc/toLowerCase.ts
|
|
1727
|
+
/**
|
|
1728
|
+
* Shortcut for `String.toLowerCase()`.
|
|
1729
|
+
*
|
|
1730
|
+
* @param source input string
|
|
1731
|
+
* @returns lowercase output string
|
|
1732
|
+
*/
|
|
1733
|
+
const toLowerCase = (source) => source.toLowerCase();
|
|
1734
|
+
//#endregion
|
|
1735
|
+
//#region src/misc/toUpperCase.ts
|
|
1736
|
+
/**
|
|
1737
|
+
* Shortcut for `String.toUpperCase()`.
|
|
1738
|
+
*
|
|
1739
|
+
* @param source input string
|
|
1740
|
+
* @returns uppercase output string
|
|
1741
|
+
*/
|
|
1742
|
+
const toUpperCase = (source) => source.toUpperCase();
|
|
1743
|
+
//#endregion
|
|
1744
|
+
//#region src/selectors/querySelectorAll.ts
|
|
1745
|
+
/**
|
|
1746
|
+
* A shortcut for `(document|Element).querySelectorAll`.
|
|
1747
|
+
*
|
|
1748
|
+
* @param selector the input selector
|
|
1749
|
+
* @param parent optional node to look into
|
|
1750
|
+
* @return the query result
|
|
1751
|
+
*/
|
|
1752
|
+
const querySelectorAll = (selector, parent) => {
|
|
1753
|
+
return (isNode(parent) ? parent : getDocument()).querySelectorAll(selector);
|
|
1754
|
+
};
|
|
1755
|
+
//#endregion
|
|
1756
|
+
//#region src/misc/focusTrap.ts
|
|
1757
|
+
const focusTrapMap = /* @__PURE__ */ new Map();
|
|
1758
|
+
function handleKeyboardNavigation(event) {
|
|
1759
|
+
const { shiftKey, code } = event;
|
|
1760
|
+
const doc = getDocument(this);
|
|
1761
|
+
const focusableElements = [...querySelectorAll(focusableSelector, this)].filter((el) => !hasAttribute(el, "disabled") && !getAttribute(el, "aria-hidden"));
|
|
1762
|
+
if (!focusableElements.length) return;
|
|
1763
|
+
const firstFocusable = focusableElements[0];
|
|
1764
|
+
const lastFocusable = focusableElements[focusableElements.length - 1];
|
|
1765
|
+
if (code === "Tab") {
|
|
1766
|
+
if (shiftKey && doc.activeElement === firstFocusable) {
|
|
1767
|
+
lastFocusable.focus();
|
|
1768
|
+
event.preventDefault();
|
|
1769
|
+
} else if (!shiftKey && doc.activeElement === lastFocusable) {
|
|
1770
|
+
firstFocusable.focus();
|
|
1771
|
+
event.preventDefault();
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
/**
|
|
1776
|
+
* Utility to check if a designated element is affected by focus trap;
|
|
1777
|
+
* @param target
|
|
1778
|
+
*/
|
|
1779
|
+
const hasFocusTrap = (target) => focusTrapMap.has(target) === true;
|
|
1780
|
+
/**
|
|
1781
|
+
* Utility to add focus trap inside a designated target element;
|
|
1782
|
+
* @param target
|
|
1783
|
+
*/
|
|
1784
|
+
const addFocusTrap = (target) => {
|
|
1785
|
+
if (hasFocusTrap(target)) return;
|
|
1786
|
+
on(target, "keydown", handleKeyboardNavigation);
|
|
1787
|
+
focusTrapMap.set(target, true);
|
|
1788
|
+
};
|
|
1789
|
+
/**
|
|
1790
|
+
* Utility to remove focus trap inside a designated target element;
|
|
1791
|
+
* @param target
|
|
1792
|
+
*/
|
|
1793
|
+
const removeFocusTrap = (target) => {
|
|
1794
|
+
if (!hasFocusTrap(target)) return;
|
|
1795
|
+
off(target, "keydown", handleKeyboardNavigation);
|
|
1796
|
+
focusTrapMap.delete(target);
|
|
1797
|
+
};
|
|
1798
|
+
/**
|
|
1799
|
+
* Utility to toggle focus trap inside a designated target element;
|
|
1800
|
+
* @param target
|
|
1801
|
+
*/
|
|
1802
|
+
const toggleFocusTrap = (target) => {
|
|
1803
|
+
if (hasFocusTrap(target)) removeFocusTrap(target);
|
|
1804
|
+
else addFocusTrap(target);
|
|
1805
|
+
};
|
|
1806
|
+
//#endregion
|
|
1807
|
+
//#region src/is/isHTMLElement.ts
|
|
1808
|
+
/**
|
|
1809
|
+
* Checks if an element is an `HTMLElement`.
|
|
1810
|
+
*
|
|
1811
|
+
* @see https://dom.spec.whatwg.org/#node
|
|
1812
|
+
*
|
|
1813
|
+
* @param element the target object
|
|
1814
|
+
* @returns the query result
|
|
1815
|
+
*/
|
|
1816
|
+
const isHTMLElement = (element) => isElement(element) && "offsetWidth" in element || false;
|
|
1817
|
+
//#endregion
|
|
1818
|
+
//#region src/get/getBoundingClientRect.ts
|
|
1819
|
+
/**
|
|
1820
|
+
* Returns the bounding client rect of a target `Element`.
|
|
1821
|
+
*
|
|
1822
|
+
* @see https://github.com/floating-ui/floating-ui
|
|
1823
|
+
*
|
|
1824
|
+
* @param element event.target
|
|
1825
|
+
* @param includeScale when *true*, the target scale is also computed
|
|
1826
|
+
* @returns the bounding client rect object
|
|
1827
|
+
*/
|
|
1828
|
+
const getBoundingClientRect = (element, includeScale) => {
|
|
1829
|
+
const { width, height, top, right, bottom, left } = element.getBoundingClientRect();
|
|
1830
|
+
let scaleX = 1;
|
|
1831
|
+
let scaleY = 1;
|
|
1832
|
+
if (includeScale && isHTMLElement(element)) {
|
|
1833
|
+
const { offsetWidth, offsetHeight } = element;
|
|
1834
|
+
scaleX = offsetWidth > 0 ? Math.round(width) / offsetWidth : 1;
|
|
1835
|
+
scaleY = offsetHeight > 0 ? Math.round(height) / offsetHeight : 1;
|
|
1836
|
+
}
|
|
1837
|
+
return {
|
|
1838
|
+
width: width / scaleX,
|
|
1839
|
+
height: height / scaleY,
|
|
1840
|
+
top: top / scaleY,
|
|
1841
|
+
right: right / scaleX,
|
|
1842
|
+
bottom: bottom / scaleY,
|
|
1843
|
+
left: left / scaleX,
|
|
1844
|
+
x: left / scaleX,
|
|
1845
|
+
y: top / scaleY
|
|
1846
|
+
};
|
|
1847
|
+
};
|
|
1848
|
+
//#endregion
|
|
1849
|
+
//#region src/get/getDocumentBody.ts
|
|
1850
|
+
/**
|
|
1851
|
+
* Returns the `document.body` or the `<body>` element.
|
|
1852
|
+
*
|
|
1853
|
+
* @param node the reference node
|
|
1854
|
+
* @returns the parent `<body>` of the specified node
|
|
1855
|
+
*/
|
|
1856
|
+
const getDocumentBody = (node) => {
|
|
1857
|
+
return getDocument(node).body;
|
|
1858
|
+
};
|
|
1859
|
+
//#endregion
|
|
1860
|
+
//#region src/get/getDocumentElement.ts
|
|
1861
|
+
/**
|
|
1862
|
+
* Returns the `document.documentElement` or the `<HTML>` element.
|
|
1863
|
+
*
|
|
1864
|
+
* @param node the reference node
|
|
1865
|
+
* @returns the parent `<HTML>` of the node's parent document
|
|
1866
|
+
*/
|
|
1867
|
+
const getDocumentElement = (node) => {
|
|
1868
|
+
return getDocument(node).documentElement;
|
|
1869
|
+
};
|
|
1870
|
+
//#endregion
|
|
1871
|
+
//#region src/get/getDocumentHead.ts
|
|
1872
|
+
/**
|
|
1873
|
+
* Returns the `document.head` or the `<head>` element.
|
|
1874
|
+
*
|
|
1875
|
+
* @param node the reference node
|
|
1876
|
+
* @returns the `<head>` of the node's parent document
|
|
1877
|
+
*/
|
|
1878
|
+
const getDocumentHead = (node) => {
|
|
1879
|
+
return getDocument(node).head;
|
|
1880
|
+
};
|
|
1881
|
+
//#endregion
|
|
1882
|
+
//#region src/get/getNodeName.ts
|
|
1883
|
+
/**
|
|
1884
|
+
* Returns the value of `node.nodeName` for the given node.
|
|
1885
|
+
* @param node target node
|
|
1886
|
+
* @returns the node name
|
|
1887
|
+
*/
|
|
1888
|
+
const getNodeName = (node) => {
|
|
1889
|
+
if (isNode(node)) return (node.nodeName || "").toLowerCase();
|
|
1890
|
+
return "#document";
|
|
1891
|
+
};
|
|
1892
|
+
//#endregion
|
|
1893
|
+
//#region src/get/getNodeScroll.ts
|
|
1894
|
+
/**
|
|
1895
|
+
* Returns an `{x, y}` object with the target
|
|
1896
|
+
* `Element` / `Node` scroll position.
|
|
1897
|
+
*
|
|
1898
|
+
* @see https://github.com/floating-ui/floating-ui
|
|
1899
|
+
*
|
|
1900
|
+
* @param element target node / element
|
|
1901
|
+
* @returns the scroll tuple
|
|
1902
|
+
*/
|
|
1903
|
+
const getNodeScroll = (element) => {
|
|
1904
|
+
const isWin = isWindow(element);
|
|
1905
|
+
return {
|
|
1906
|
+
x: isWin ? element.scrollX : element.scrollLeft,
|
|
1907
|
+
y: isWin ? element.scrollY : element.scrollTop
|
|
1908
|
+
};
|
|
1909
|
+
};
|
|
1910
|
+
//#endregion
|
|
1911
|
+
//#region src/is/isShadowRoot.ts
|
|
1912
|
+
/**
|
|
1913
|
+
* Check if target is a `ShadowRoot`.
|
|
1914
|
+
*
|
|
1915
|
+
* @param element target
|
|
1916
|
+
* @returns the query result
|
|
1917
|
+
*/
|
|
1918
|
+
const isShadowRoot = (element) => isNode(element) && element.constructor.name === "ShadowRoot" || false;
|
|
1919
|
+
//#endregion
|
|
1920
|
+
//#region src/get/getParentNode.ts
|
|
1921
|
+
/**
|
|
1922
|
+
* Returns the `parentNode` also going through `ShadowRoot`.
|
|
1923
|
+
*
|
|
1924
|
+
* @see https://github.com/floating-ui/floating-ui
|
|
1925
|
+
*
|
|
1926
|
+
* @param node the target node
|
|
1927
|
+
* @returns the apropriate parent node
|
|
1928
|
+
*/
|
|
1929
|
+
const getParentNode = (node) => {
|
|
1930
|
+
if (node.nodeName === "HTML") return node;
|
|
1931
|
+
return isElement(node) && node.assignedSlot || isNode(node) && node.parentNode || isShadowRoot(node) && node.host || getDocumentElement(node);
|
|
1932
|
+
};
|
|
1933
|
+
//#endregion
|
|
1934
|
+
//#region src/get/getWindow.ts
|
|
1935
|
+
/**
|
|
1936
|
+
* Returns the `Window` object of a target node.
|
|
1937
|
+
*
|
|
1938
|
+
* @see https://github.com/floating-ui/floating-ui
|
|
1939
|
+
*
|
|
1940
|
+
* @param node target node
|
|
1941
|
+
* @returns the `Window` object
|
|
1942
|
+
*/
|
|
1943
|
+
const getWindow = (node) => {
|
|
1944
|
+
if (!node) return window;
|
|
1945
|
+
if (isDocument(node)) return node.defaultView;
|
|
1946
|
+
if (isNode(node)) return node?.ownerDocument?.defaultView;
|
|
1947
|
+
return node;
|
|
1948
|
+
};
|
|
1949
|
+
//#endregion
|
|
1950
|
+
//#region src/is/isTableElement.ts
|
|
1951
|
+
/**
|
|
1952
|
+
* Check if a target element is a `<table>`, `<td>` or `<th>`.
|
|
1953
|
+
* This specific check is important for determining
|
|
1954
|
+
* the `offsetParent` of a given element.
|
|
1955
|
+
*
|
|
1956
|
+
* @param element the target element
|
|
1957
|
+
* @returns the query result
|
|
1958
|
+
*/
|
|
1959
|
+
const isTableElement = (element) => isNode(element) && [
|
|
1960
|
+
"TABLE",
|
|
1961
|
+
"TD",
|
|
1962
|
+
"TH"
|
|
1963
|
+
].includes(element.nodeName) || false;
|
|
1964
|
+
//#endregion
|
|
1965
|
+
//#region src/selectors/matches.ts
|
|
1966
|
+
/**
|
|
1967
|
+
* Check if element matches a CSS selector.
|
|
1968
|
+
*
|
|
1969
|
+
* @param target the target element
|
|
1970
|
+
* @param selector the selector to match
|
|
1971
|
+
* @returns the query result
|
|
1972
|
+
*/
|
|
1973
|
+
const matches = (target, selector) => target.matches(selector);
|
|
1974
|
+
//#endregion
|
|
1975
|
+
//#region src/get/getOffsetParent.ts
|
|
1976
|
+
const isStaticPositioned = (element) => {
|
|
1977
|
+
return getElementStyle(element, "position") === "static";
|
|
1978
|
+
};
|
|
1979
|
+
const isFixedPositioned = (element) => {
|
|
1980
|
+
return getElementStyle(element, "position") === "fixed";
|
|
1981
|
+
};
|
|
1982
|
+
const isTopLayer = (element) => {
|
|
1983
|
+
return [":popover-open", ":modal"].some((selector) => {
|
|
1984
|
+
try {
|
|
1985
|
+
return matches(element, selector);
|
|
1986
|
+
} catch (_) {
|
|
1987
|
+
return false;
|
|
1988
|
+
}
|
|
1989
|
+
});
|
|
1990
|
+
};
|
|
1991
|
+
const isContainingBlock = (elementOrCss) => {
|
|
1992
|
+
const webkit = isWebKit();
|
|
1993
|
+
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
|
1994
|
+
return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || [
|
|
1995
|
+
"transform",
|
|
1996
|
+
"perspective",
|
|
1997
|
+
"filter"
|
|
1998
|
+
].some((value) => (css.willChange || "").includes(value)) || [
|
|
1999
|
+
"paint",
|
|
2000
|
+
"layout",
|
|
2001
|
+
"strict",
|
|
2002
|
+
"content"
|
|
2003
|
+
].some((value) => (css.contain || "").includes(value));
|
|
2004
|
+
};
|
|
2005
|
+
const getContainingBlock = (element) => {
|
|
2006
|
+
let currentNode = getParentNode(element);
|
|
2007
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
2008
|
+
if (isContainingBlock(currentNode)) return currentNode;
|
|
2009
|
+
else if (isTopLayer(currentNode)) return null;
|
|
2010
|
+
currentNode = getParentNode(currentNode);
|
|
2011
|
+
}
|
|
2012
|
+
return null;
|
|
2013
|
+
};
|
|
2014
|
+
const isLastTraversableNode = (node) => {
|
|
2015
|
+
return [
|
|
2016
|
+
"html",
|
|
2017
|
+
"body",
|
|
2018
|
+
"#document"
|
|
2019
|
+
].includes(getNodeName(node));
|
|
2020
|
+
};
|
|
2021
|
+
const getTrueOffsetParent = (element) => {
|
|
2022
|
+
if (!isHTMLElement(element) || isFixedPositioned(element)) return null;
|
|
2023
|
+
let rawOffsetParent = element.offsetParent;
|
|
2024
|
+
if (getDocumentElement(element) === rawOffsetParent) rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
2025
|
+
return rawOffsetParent;
|
|
2026
|
+
};
|
|
2027
|
+
/**
|
|
2028
|
+
* Returns the `offsetParent` for a given target.
|
|
2029
|
+
*
|
|
2030
|
+
* @see https://github.com/floating-ui/floating-ui
|
|
2031
|
+
*
|
|
2032
|
+
* @param element the target node
|
|
2033
|
+
* @returns the offset parent node
|
|
2034
|
+
*/
|
|
2035
|
+
const getOffsetParent = (element) => {
|
|
2036
|
+
const win = getWindow(element);
|
|
2037
|
+
if (!isNode(element) || isTopLayer(element)) return win;
|
|
2038
|
+
if (!isHTMLElement(element)) {
|
|
2039
|
+
let svgOffsetParent = getParentNode(element);
|
|
2040
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
2041
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) return svgOffsetParent;
|
|
2042
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
2043
|
+
}
|
|
2044
|
+
return win;
|
|
2045
|
+
}
|
|
2046
|
+
let offsetParent = getTrueOffsetParent(element);
|
|
2047
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) offsetParent = getTrueOffsetParent(offsetParent);
|
|
2048
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) return win;
|
|
2049
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
2050
|
+
};
|
|
2051
|
+
//#endregion
|
|
2052
|
+
//#region src/is/isScaledElement.ts
|
|
2053
|
+
/**
|
|
2054
|
+
* Checks if a target `Element` is affected by scale.
|
|
2055
|
+
*
|
|
2056
|
+
* @see https://github.com/floating-ui/floating-ui
|
|
2057
|
+
*
|
|
2058
|
+
* @param element target
|
|
2059
|
+
* @returns the query result
|
|
2060
|
+
*/
|
|
2061
|
+
const isScaledElement = (element) => {
|
|
2062
|
+
if (!isHTMLElement(element)) return false;
|
|
2063
|
+
const { width, height } = getBoundingClientRect(element);
|
|
2064
|
+
const { offsetWidth, offsetHeight } = element;
|
|
2065
|
+
return Math.round(width) !== offsetWidth || Math.round(height) !== offsetHeight;
|
|
2066
|
+
};
|
|
2067
|
+
//#endregion
|
|
2068
|
+
//#region src/get/getRectRelativeToOffsetParent.ts
|
|
2069
|
+
/**
|
|
2070
|
+
* Returns the rect relative to a given offset parent and its scroll position.
|
|
2071
|
+
*
|
|
2072
|
+
* @see https://github.com/floating-ui/floating-ui
|
|
2073
|
+
*
|
|
2074
|
+
* @param element target
|
|
2075
|
+
* @param offsetParent the container / offset parent
|
|
2076
|
+
* @param scroll the offsetParent scroll position
|
|
2077
|
+
* @returns a DOMRect like object
|
|
2078
|
+
*/
|
|
2079
|
+
const getRectRelativeToOffsetParent = (element, offsetParent, scroll) => {
|
|
2080
|
+
const isParentAnElement = isHTMLElement(offsetParent);
|
|
2081
|
+
const rect = getBoundingClientRect(element, isParentAnElement && isScaledElement(offsetParent));
|
|
2082
|
+
const offsets = {
|
|
2083
|
+
x: 0,
|
|
2084
|
+
y: 0
|
|
2085
|
+
};
|
|
2086
|
+
if (isParentAnElement) {
|
|
2087
|
+
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
2088
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
2089
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2090
|
+
}
|
|
2091
|
+
return {
|
|
2092
|
+
x: rect.left + scroll.x - offsets.x,
|
|
2093
|
+
y: rect.top + scroll.y - offsets.y,
|
|
2094
|
+
width: rect.width,
|
|
2095
|
+
height: rect.height
|
|
2096
|
+
};
|
|
2097
|
+
};
|
|
2098
|
+
//#endregion
|
|
2099
|
+
//#region src/get/getUID.ts
|
|
2100
|
+
let elementUID = 0;
|
|
2101
|
+
let elementMapUID = 0;
|
|
2102
|
+
const elementIDMap = /* @__PURE__ */ new Map();
|
|
2103
|
+
/**
|
|
2104
|
+
* Returns a unique identifier for popover, tooltip, scrollspy.
|
|
2105
|
+
*
|
|
2106
|
+
* @param element target element
|
|
2107
|
+
* @param key optional identifier key
|
|
2108
|
+
* @returns an existing or new unique ID
|
|
2109
|
+
*/
|
|
2110
|
+
const getUID = (element, key) => {
|
|
2111
|
+
let result = key ? elementUID : elementMapUID;
|
|
2112
|
+
if (key) {
|
|
2113
|
+
const elID = getUID(element);
|
|
2114
|
+
const elMap = elementIDMap.get(elID) || /* @__PURE__ */ new Map();
|
|
2115
|
+
if (!elementIDMap.has(elID)) elementIDMap.set(elID, elMap);
|
|
2116
|
+
if (isMap(elMap) && !elMap.has(key)) {
|
|
2117
|
+
elMap.set(key, result);
|
|
2118
|
+
elementUID += 1;
|
|
2119
|
+
} else result = elMap.get(key);
|
|
2120
|
+
} else {
|
|
2121
|
+
const elkey = element.id || element;
|
|
2122
|
+
if (!elementIDMap.has(elkey)) {
|
|
2123
|
+
elementIDMap.set(elkey, result);
|
|
2124
|
+
elementMapUID += 1;
|
|
2125
|
+
} else result = elementIDMap.get(elkey);
|
|
2126
|
+
}
|
|
2127
|
+
return result;
|
|
2128
|
+
};
|
|
2129
|
+
//#endregion
|
|
2130
|
+
//#region src/is/isArray.ts
|
|
2131
|
+
/**
|
|
2132
|
+
* Shortie for the `Array.isArray()` static method.
|
|
2133
|
+
*
|
|
2134
|
+
* @param obj array-like iterable object
|
|
2135
|
+
* @returns the query result
|
|
2136
|
+
*/
|
|
2137
|
+
const isArray = (obj) => Array.isArray(obj) || false;
|
|
2138
|
+
//#endregion
|
|
2139
|
+
//#region src/is/isCanvas.ts
|
|
2140
|
+
/**
|
|
2141
|
+
* Checks if an element is an `HTMLCanvasElement` or `<canvas>`.
|
|
2142
|
+
*
|
|
2143
|
+
* @param element the target element
|
|
2144
|
+
* @returns the query result
|
|
2145
|
+
*/
|
|
2146
|
+
const isCanvas = (element) => isNode(element) && element.nodeName === "CANVAS" || false;
|
|
2147
|
+
//#endregion
|
|
2148
|
+
//#region src/is/isCustomElement.ts
|
|
2149
|
+
/**
|
|
2150
|
+
* Checks if an object is a `CustomElement`.
|
|
2151
|
+
*
|
|
2152
|
+
* @param element the target object
|
|
2153
|
+
* @returns the query result
|
|
2154
|
+
*/
|
|
2155
|
+
const isCustomElement = (element) => isHTMLElement(element) && !!element.shadowRoot || false;
|
|
2156
|
+
//#endregion
|
|
2157
|
+
//#region src/is/isElementInScrollRange.ts
|
|
2158
|
+
/**
|
|
2159
|
+
* Utility to determine if an `Element`
|
|
2160
|
+
* is partially visible in viewport.
|
|
2161
|
+
*
|
|
2162
|
+
* @param element target
|
|
2163
|
+
* @return the query result
|
|
2164
|
+
*/
|
|
2165
|
+
const isElementInScrollRange = (element) => {
|
|
2166
|
+
if (!isNode(element)) return false;
|
|
2167
|
+
const { top, bottom } = getBoundingClientRect(element);
|
|
2168
|
+
const { clientHeight } = getDocumentElement(element);
|
|
2169
|
+
return top <= clientHeight && bottom >= 0;
|
|
2170
|
+
};
|
|
2171
|
+
//#endregion
|
|
2172
|
+
//#region src/is/isElementInViewport.ts
|
|
2173
|
+
/**
|
|
2174
|
+
* Utility to determine if an `Element`
|
|
2175
|
+
* is fully visible in the viewport.
|
|
2176
|
+
*
|
|
2177
|
+
* @param element target
|
|
2178
|
+
* @return the query result
|
|
2179
|
+
*/
|
|
2180
|
+
const isElementInViewport = (element) => {
|
|
2181
|
+
if (!isElement(element)) return false;
|
|
2182
|
+
const { clientWidth, clientHeight } = getDocumentElement(element);
|
|
2183
|
+
const { top, left, bottom, right } = getBoundingClientRect(element, true);
|
|
2184
|
+
return top >= 0 && left >= 0 && bottom <= clientHeight && right <= clientWidth;
|
|
2185
|
+
};
|
|
2186
|
+
//#endregion
|
|
2187
|
+
//#region src/is/isElementsArray.ts
|
|
2188
|
+
/**
|
|
2189
|
+
* Checks if an object is an `Array` in which all items are `Element`.
|
|
2190
|
+
*
|
|
2191
|
+
* @param obj the target object
|
|
2192
|
+
* @returns the query result
|
|
2193
|
+
*/
|
|
2194
|
+
const isElementsArray = (obj) => isArray(obj) && obj.every(isElement) || false;
|
|
2195
|
+
//#endregion
|
|
2196
|
+
//#region src/is/isFunction.ts
|
|
2197
|
+
/**
|
|
2198
|
+
* Checks if an object is a `Function`.
|
|
2199
|
+
*
|
|
2200
|
+
* @param fn the target object
|
|
2201
|
+
* @returns the query result
|
|
2202
|
+
*/
|
|
2203
|
+
const isFunction = (fn) => typeof fn === "function" || false;
|
|
2204
|
+
//#endregion
|
|
2205
|
+
//#region src/is/isHTMLCollection.ts
|
|
2206
|
+
/**
|
|
2207
|
+
* Checks if an object is an `HTMLCollection`.
|
|
2208
|
+
*
|
|
2209
|
+
* @param obj the target object
|
|
2210
|
+
* @returns the query result
|
|
2211
|
+
*/
|
|
2212
|
+
const isHTMLCollection = (obj) => isObject(obj) && obj.constructor.name === "HTMLCollection" || false;
|
|
2213
|
+
//#endregion
|
|
2214
|
+
//#region src/is/isHTMLImageElement.ts
|
|
2215
|
+
/**
|
|
2216
|
+
* Check if a target element is an `<img>`.
|
|
2217
|
+
*
|
|
2218
|
+
* @param element the target element
|
|
2219
|
+
* @returns the query result
|
|
2220
|
+
*/
|
|
2221
|
+
const isHTMLImageElement = (element) => isHTMLElement(element) && element.tagName === "IMG" || false;
|
|
2222
|
+
//#endregion
|
|
2223
|
+
//#region src/is/isJSON.ts
|
|
2224
|
+
/**
|
|
2225
|
+
* Checks if a string is a `JSON` string.
|
|
2226
|
+
*
|
|
2227
|
+
* @param str the target string
|
|
2228
|
+
* @returns the query result
|
|
2229
|
+
*/
|
|
2230
|
+
const isJSON = (str) => {
|
|
2231
|
+
if (!isString(str)) return false;
|
|
2232
|
+
try {
|
|
2233
|
+
JSON.parse(str);
|
|
2234
|
+
} catch (_e) {
|
|
2235
|
+
return false;
|
|
2236
|
+
}
|
|
2237
|
+
return true;
|
|
2238
|
+
};
|
|
2239
|
+
//#endregion
|
|
2240
|
+
//#region src/is/isWeakMap.ts
|
|
2241
|
+
/**
|
|
2242
|
+
* Checks if an element is a `WeakMap`.
|
|
2243
|
+
*
|
|
2244
|
+
* @param obj the target object
|
|
2245
|
+
* @returns the query result
|
|
2246
|
+
*/
|
|
2247
|
+
const isWeakMap = (obj) => isObject(obj) && obj.constructor.name === "WeakMap" || false;
|
|
2248
|
+
//#endregion
|
|
2249
|
+
//#region src/is/isMedia.ts
|
|
2250
|
+
/**
|
|
2251
|
+
* Checks if an element is an `<svg>` (or any type of SVG element),
|
|
2252
|
+
* `<img>`, `<video>` or `<canvas>`.
|
|
2253
|
+
*
|
|
2254
|
+
* *Tooltip* / *Popover* works different with media elements.
|
|
2255
|
+
*
|
|
2256
|
+
* @param element the target element
|
|
2257
|
+
* @returns the query result
|
|
2258
|
+
*/
|
|
2259
|
+
const isMedia = (element) => isNode(element) && [
|
|
2260
|
+
"SVG",
|
|
2261
|
+
"Image",
|
|
2262
|
+
"Video",
|
|
2263
|
+
"Canvas"
|
|
2264
|
+
].some((s) => element.constructor.name.includes(s)) || false;
|
|
2265
|
+
//#endregion
|
|
2266
|
+
//#region src/is/isNodeList.ts
|
|
2267
|
+
/**
|
|
2268
|
+
* Checks if an object is a `NodeList`.
|
|
2269
|
+
* => equivalent to `object instanceof NodeList`
|
|
2270
|
+
*
|
|
2271
|
+
* @param obj the target object
|
|
2272
|
+
* @returns the query result
|
|
2273
|
+
*/
|
|
2274
|
+
const isNodeList = (obj) => isObject(obj) && obj.constructor.name === "NodeList" || false;
|
|
2275
|
+
//#endregion
|
|
2276
|
+
//#region src/is/isRTL.ts
|
|
2277
|
+
/**
|
|
2278
|
+
* Checks if a page is Right To Left.
|
|
2279
|
+
*
|
|
2280
|
+
* @param node the target
|
|
2281
|
+
* @returns the query result
|
|
2282
|
+
*/
|
|
2283
|
+
const isRTL = (node) => getDocumentElement(node).dir === "rtl";
|
|
2284
|
+
//#endregion
|
|
2285
|
+
//#region src/is/isSVGElement.ts
|
|
2286
|
+
/**
|
|
2287
|
+
* Check if an element is an `<svg>` or any other SVG element,
|
|
2288
|
+
* an equivalent to `SOMETHING instanceof SVGElement`.
|
|
2289
|
+
*
|
|
2290
|
+
* @param element the target element
|
|
2291
|
+
* @returns the query result
|
|
2292
|
+
*/
|
|
2293
|
+
const isSVGElement = (element) => isNode(element) && element.constructor.name.includes("SVG") || false;
|
|
2294
|
+
//#endregion
|
|
2295
|
+
//#region src/selectors/closest.ts
|
|
2296
|
+
/**
|
|
2297
|
+
* Shortcut for `HTMLElement.closest` method which also works
|
|
2298
|
+
* with children of `ShadowRoot`. The order of the parameters
|
|
2299
|
+
* is intentional since they're both required.
|
|
2300
|
+
*
|
|
2301
|
+
* @see https://stackoverflow.com/q/54520554/803358
|
|
2302
|
+
*
|
|
2303
|
+
* @param element target Element to check
|
|
2304
|
+
* @param selector the selector string
|
|
2305
|
+
* @return the query result
|
|
2306
|
+
*/
|
|
2307
|
+
const closest = (element, selector) => {
|
|
2308
|
+
if (!element || !selector) return null;
|
|
2309
|
+
return element.closest(selector) || closest(element.getRootNode().host, selector) || null;
|
|
2310
|
+
};
|
|
2311
|
+
//#endregion
|
|
2312
|
+
//#region src/selectors/querySelector.ts
|
|
2313
|
+
/**
|
|
2314
|
+
* Utility to check if target is typeof `Element`, `Node`
|
|
2315
|
+
* or find one that matches a selector.
|
|
2316
|
+
*
|
|
2317
|
+
* @param selector the input selector or target element
|
|
2318
|
+
* @param parent optional node to look into
|
|
2319
|
+
* @return the `Element` or null
|
|
2320
|
+
*/
|
|
2321
|
+
const querySelector = (selector, parent) => {
|
|
2322
|
+
if (isElement(selector)) return selector;
|
|
2323
|
+
return (isElement(parent) ? parent : getDocument()).querySelector(selector);
|
|
2324
|
+
};
|
|
2325
|
+
//#endregion
|
|
2326
|
+
//#region src/selectors/getElementsByTagName.ts
|
|
2327
|
+
/**
|
|
2328
|
+
* Shortcut for `Element.getElementsByTagName` method. Some `Node` elements
|
|
2329
|
+
* like `ShadowRoot` do not support `getElementsByTagName`.
|
|
2330
|
+
*
|
|
2331
|
+
* @param selector the tag name
|
|
2332
|
+
* @param parent optional Element to look into
|
|
2333
|
+
* @return the 'HTMLCollection'
|
|
2334
|
+
*/
|
|
2335
|
+
const getElementsByTagName = (selector, parent) => {
|
|
2336
|
+
return (isNode(parent) ? parent : getDocument()).getElementsByTagName(selector);
|
|
2337
|
+
};
|
|
2338
|
+
//#endregion
|
|
2339
|
+
//#region src/selectors/getCustomElements.ts
|
|
2340
|
+
/**
|
|
2341
|
+
* Returns an `Array` of `Node` elements that are registered as
|
|
2342
|
+
* `CustomElement`.
|
|
2343
|
+
*
|
|
2344
|
+
* @see https://stackoverflow.com/questions/27334365/how-to-get-list-of-registered-custom-elements
|
|
2345
|
+
*
|
|
2346
|
+
* @param parent parent to look into
|
|
2347
|
+
* @returns the query result
|
|
2348
|
+
*/
|
|
2349
|
+
const getCustomElements = (parent) => {
|
|
2350
|
+
return [...getElementsByTagName("*", parent)].filter(isCustomElement);
|
|
2351
|
+
};
|
|
2352
|
+
//#endregion
|
|
2353
|
+
//#region src/selectors/getElementById.ts
|
|
2354
|
+
/**
|
|
2355
|
+
* Returns an `HTMLElement` that matches the id in the document.
|
|
2356
|
+
* Within multiple <iframe> elements, a `parent` parameter
|
|
2357
|
+
* would decisively locate the correct element.
|
|
2358
|
+
*
|
|
2359
|
+
* @param id the ID selector
|
|
2360
|
+
* @param context an element in it's document or document
|
|
2361
|
+
* @returns the requested element
|
|
2362
|
+
*/
|
|
2363
|
+
const getElementById = (id, context) => {
|
|
2364
|
+
return getDocument(context).getElementById(id);
|
|
2365
|
+
};
|
|
2366
|
+
//#endregion
|
|
2367
|
+
//#region src/selectors/getElementsByClassName.ts
|
|
2368
|
+
/**
|
|
2369
|
+
* Shortcut for `Element.getElementsByClassName` method. Some `Node` elements
|
|
2370
|
+
* like `ShadowRoot` do not support `getElementsByClassName`.
|
|
2371
|
+
*
|
|
2372
|
+
* @param selector the class name
|
|
2373
|
+
* @param parent optional Element to look into
|
|
2374
|
+
* @return the 'HTMLCollection'
|
|
2375
|
+
*/
|
|
2376
|
+
const getElementsByClassName = (selector, parent) => {
|
|
2377
|
+
return (parent && isNode(parent) ? parent : getDocument()).getElementsByClassName(selector);
|
|
2378
|
+
};
|
|
2379
|
+
//#endregion
|
|
2380
|
+
export { ArrayFrom, DOMContentLoadedEvent, DOMMouseScrollEvent, Data, Float32ArrayFrom, Float64ArrayFrom, ObjectAssign, ObjectEntries, ObjectFromEntries, ObjectHasOwn, ObjectKeys, ObjectValues, Timer, abortEvent, addClass, addEventListener, addFocusTrap, animationDelay, animationDuration, animationEndEvent, animationName, ariaChecked, ariaDescribedBy, ariaDescription, ariaExpanded, ariaHasPopup, ariaHidden, ariaLabel, ariaLabelledBy, ariaModal, ariaPressed, ariaSelected, ariaValueMax, ariaValueMin, ariaValueNow, ariaValueText, beforeunloadEvent, bezierEasings, blurEvent, camelCase, capitalize, changeEvent, closest, contextmenuEvent, createCustomEvent, createElement, createElementNS, dispatchEvent, distinct, documentBody, documentElement, documentHead, dragEvent, dragendEvent, dragenterEvent, dragleaveEvent, dragoverEvent, dragstartEvent, emulateAnimationEnd, emulateTransitionEnd, errorEvent, focus, focusEvent, focusEvents, focusableSelector, focusinEvent, focusoutEvent, gesturechangeEvent, gestureendEvent, gesturestartEvent, getAttribute, getAttributeNS, getBoundingClientRect, getCustomElements, getDocument, getDocumentBody, getDocumentElement, getDocumentHead, getElementAnimationDelay, getElementAnimationDuration, getElementById, getElementStyle, getElementTransitionDelay, getElementTransitionDuration, getElementsByClassName, getElementsByTagName, getInstance, getNodeName, getNodeScroll, getOffsetParent, getParentNode, getRectRelativeToOffsetParent, getUID, getWindow, handleKeyboardNavigation, hasAttribute, hasAttributeNS, hasClass, hasFocusTrap, isApple, isArray, isCanvas, isCustomElement, isDocument, isElement, isElementInScrollRange, isElementInViewport, isElementsArray, isFirefox, isFunction, isHTMLCollection, isHTMLElement, isHTMLImageElement, isJSON, isMap, isMedia, isMobile, isNode, isNodeList, isNumber, isObject, isRTL, isSVGElement, isScaledElement, isShadowRoot, isString, isTableElement, isWeakMap, isWebKit, isWindow, kebabCase, keyAlt, keyArrowDown, keyArrowLeft, keyArrowRight, keyArrowUp, keyBackspace, keyCapsLock, keyControl, keyDelete, keyEnter, keyEscape, keyInsert, keyMeta, keyNumpadEnter, keyPause, keyScrollLock, keyShift, keySpace, keyTab, keyboardEventKeys, keydownEvent, keypressEvent, keyupEvent, loadEvent, loadstartEvent, matches, mouseClickEvents, mouseHoverEvents, mouseSwipeEvents, mouseclickEvent, mousedblclickEvent, mousedownEvent, mouseenterEvent, mousehoverEvent, mouseinEvent, mouseleaveEvent, mousemoveEvent, mouseoutEvent, mouseoverEvent, mouseupEvent, mousewheelEvent, moveEvent, nativeEvents, noop, normalizeOptions, normalizeValue, off, offsetHeight, offsetWidth, on, one, orientationchangeEvent, passiveHandler, pointercancelEvent, pointerdownEvent, pointerleaveEvent, pointermoveEvent, pointerupEvent, querySelector, querySelectorAll, readystatechangeEvent, reflow, removeAttribute, removeAttributeNS, removeClass, removeEventListener, removeFocusTrap, resetEvent, resizeEvent, scrollEvent, scrollHeight, scrollWidth, selectEvent, selectendEvent, selectstartEvent, setAttribute, setAttributeNS, setElementStyle, submitEvent, support3DTransform, supportAnimation, supportPassive, supportTouch, supportTransform, supportTransition, tabindex, toLowerCase, toUpperCase, toggleFocusTrap, touchEvents, touchcancelEvent, touchendEvent, touchmoveEvent, touchstartEvent, transitionDelay, transitionDuration, transitionEndEvent, transitionProperty, unloadEvent, userAgent, userAgentData, version };
|
|
2381
|
+
|
|
2382
|
+
//# sourceMappingURL=index.js.map
|