@stonecrop/utilities 0.2.11 → 0.2.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/package.json +1 -1
- package/src/composables/keyboard.ts +66 -36
- package/src/index.ts +2 -1
- package/dist/utilities.js +0 -333
- package/dist/utilities.js.map +0 -1
- package/dist/utilities.umd.cjs +0 -2
- package/dist/utilities.umd.cjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { type WatchStopHandle, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
2
|
+
import { useFocusWithin } from '@vueuse/core'
|
|
3
3
|
|
|
4
4
|
import type { KeyboardNavigationOptions, KeypressHandlers } from 'types'
|
|
5
|
+
import { useElementVisibility } from '@/composables/visibility'
|
|
5
6
|
|
|
6
7
|
// helper functions
|
|
7
8
|
const isVisible = (element: HTMLElement) => {
|
|
@@ -328,50 +329,67 @@ export const defaultKeypressHandlers: KeypressHandlers = {
|
|
|
328
329
|
}
|
|
329
330
|
|
|
330
331
|
export function useKeyboardNav(options: KeyboardNavigationOptions[]) {
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
let $parent: Element | null = null
|
|
332
|
+
const getParentElement = (option: KeyboardNavigationOptions) => {
|
|
333
|
+
let $parent: HTMLElement | null = null
|
|
334
334
|
if (option.parent) {
|
|
335
335
|
if (typeof option.parent === 'string') {
|
|
336
336
|
$parent = document.querySelector(option.parent)
|
|
337
|
-
} else if (option.parent instanceof
|
|
337
|
+
} else if (option.parent instanceof HTMLElement) {
|
|
338
338
|
$parent = option.parent
|
|
339
339
|
} else {
|
|
340
340
|
$parent = option.parent.value
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
+
return $parent
|
|
344
|
+
}
|
|
343
345
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
for (const element of option.selectors.value) {
|
|
357
|
-
if (element instanceof Element) {
|
|
358
|
-
selectors.push(element)
|
|
359
|
-
} else {
|
|
360
|
-
selectors.push(element.$el as Element)
|
|
361
|
-
}
|
|
362
|
-
}
|
|
346
|
+
const getSelectorsFromOption = (option: KeyboardNavigationOptions) => {
|
|
347
|
+
// assumes that option.selectors is provided
|
|
348
|
+
const $parent = getParentElement(option)
|
|
349
|
+
let selectors: HTMLElement[] = []
|
|
350
|
+
if (typeof option.selectors === 'string') {
|
|
351
|
+
selectors = $parent
|
|
352
|
+
? Array.from($parent.querySelectorAll(option.selectors))
|
|
353
|
+
: Array.from(document.querySelectorAll(option.selectors))
|
|
354
|
+
} else if (Array.isArray(option.selectors)) {
|
|
355
|
+
for (const element of option.selectors) {
|
|
356
|
+
if (element instanceof HTMLElement) {
|
|
357
|
+
selectors.push(element)
|
|
363
358
|
} else {
|
|
364
|
-
selectors.push(
|
|
359
|
+
selectors.push(element.$el as HTMLElement)
|
|
365
360
|
}
|
|
366
361
|
}
|
|
362
|
+
} else if (option.selectors instanceof HTMLElement) {
|
|
363
|
+
selectors.push(option.selectors)
|
|
367
364
|
} else {
|
|
368
|
-
|
|
369
|
-
|
|
365
|
+
if (Array.isArray(option.selectors.value)) {
|
|
366
|
+
for (const element of option.selectors.value) {
|
|
367
|
+
if (element instanceof HTMLElement) {
|
|
368
|
+
selectors.push(element)
|
|
369
|
+
} else {
|
|
370
|
+
selectors.push(element.$el as HTMLElement)
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
selectors.push(option.selectors.value)
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return selectors
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const getSelectors = (option: KeyboardNavigationOptions) => {
|
|
381
|
+
const $parent = getParentElement(option)
|
|
382
|
+
let selectors: HTMLElement[] = []
|
|
383
|
+
if (option.selectors) {
|
|
384
|
+
selectors = getSelectorsFromOption(option)
|
|
385
|
+
} else if ($parent) {
|
|
386
|
+
// TODO: what should happen if no parent or selectors are provided?
|
|
387
|
+
const $children = Array.from($parent.children) as HTMLElement[]
|
|
388
|
+
selectors = $children.filter(selector => {
|
|
370
389
|
// ignore elements not in the tab order or are not visible
|
|
371
390
|
return isFocusable(selector) && isVisible(selector)
|
|
372
391
|
})
|
|
373
392
|
}
|
|
374
|
-
|
|
375
393
|
return selectors
|
|
376
394
|
}
|
|
377
395
|
|
|
@@ -420,21 +438,33 @@ export function useKeyboardNav(options: KeyboardNavigationOptions[]) {
|
|
|
420
438
|
}
|
|
421
439
|
}
|
|
422
440
|
|
|
441
|
+
const watchStopHandlers: WatchStopHandle[] = []
|
|
423
442
|
onMounted(() => {
|
|
424
443
|
for (const option of options) {
|
|
444
|
+
const $parent = getParentElement(option)
|
|
425
445
|
const selectors = getSelectors(option)
|
|
426
|
-
|
|
427
|
-
|
|
446
|
+
const listener = getEventListener(option)
|
|
447
|
+
const listenerElements = $parent
|
|
448
|
+
? [$parent] // watch for focus recursively within the parent element
|
|
449
|
+
: selectors // watch for focus on each selector element TODO: too much JS?
|
|
450
|
+
|
|
451
|
+
for (const element of listenerElements) {
|
|
452
|
+
const { focused } = useFocusWithin(ref(element))
|
|
453
|
+
const stopHandler = watch(focused, value => {
|
|
454
|
+
if (value) {
|
|
455
|
+
element.addEventListener('keydown', listener)
|
|
456
|
+
} else {
|
|
457
|
+
element.removeEventListener('keydown', listener)
|
|
458
|
+
}
|
|
459
|
+
})
|
|
460
|
+
watchStopHandlers.push(stopHandler)
|
|
428
461
|
}
|
|
429
462
|
}
|
|
430
463
|
})
|
|
431
464
|
|
|
432
465
|
onBeforeUnmount(() => {
|
|
433
|
-
for (const
|
|
434
|
-
|
|
435
|
-
for (const selector of selectors) {
|
|
436
|
-
selector.removeEventListener('keydown', getEventListener(option))
|
|
437
|
-
}
|
|
466
|
+
for (const stopHandler of watchStopHandlers) {
|
|
467
|
+
stopHandler()
|
|
438
468
|
}
|
|
439
469
|
})
|
|
440
470
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { App } from 'vue'
|
|
2
2
|
|
|
3
3
|
import { defaultKeypressHandlers, useKeyboardNav } from './composables/keyboard'
|
|
4
|
+
import type { KeypressHandlers } from '../types'
|
|
4
5
|
|
|
5
6
|
function install(app: App /* options */) {}
|
|
6
7
|
|
|
7
|
-
export { defaultKeypressHandlers, install, useKeyboardNav }
|
|
8
|
+
export { KeypressHandlers, defaultKeypressHandlers, install, useKeyboardNav }
|
package/dist/utilities.js
DELETED
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
import { unref as Q, getCurrentScope as U, onScopeDispose as K, ref as B, watch as D, onMounted as W, onBeforeUnmount as V } from "vue";
|
|
2
|
-
var v;
|
|
3
|
-
const M = typeof window < "u", F = (e) => typeof e == "string", j = () => {
|
|
4
|
-
};
|
|
5
|
-
M && ((v = window == null ? void 0 : window.navigator) != null && v.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
|
|
6
|
-
function H(e) {
|
|
7
|
-
return typeof e == "function" ? e() : Q(e);
|
|
8
|
-
}
|
|
9
|
-
function q(e) {
|
|
10
|
-
return e;
|
|
11
|
-
}
|
|
12
|
-
function G(e) {
|
|
13
|
-
return U() ? (K(e), !0) : !1;
|
|
14
|
-
}
|
|
15
|
-
function y(e) {
|
|
16
|
-
var t;
|
|
17
|
-
const r = H(e);
|
|
18
|
-
return (t = r == null ? void 0 : r.$el) != null ? t : r;
|
|
19
|
-
}
|
|
20
|
-
const N = M ? window : void 0;
|
|
21
|
-
function z(...e) {
|
|
22
|
-
let t, r, n, o;
|
|
23
|
-
if (F(e[0]) || Array.isArray(e[0]) ? ([r, n, o] = e, t = N) : [t, r, n, o] = e, !t)
|
|
24
|
-
return j;
|
|
25
|
-
Array.isArray(r) || (r = [r]), Array.isArray(n) || (n = [n]);
|
|
26
|
-
const l = [], s = () => {
|
|
27
|
-
l.forEach((c) => c()), l.length = 0;
|
|
28
|
-
}, a = (c, g, p, i) => (c.addEventListener(g, p, i), () => c.removeEventListener(g, p, i)), C = D(() => [y(t), H(o)], ([c, g]) => {
|
|
29
|
-
s(), c && l.push(...r.flatMap((p) => n.map((i) => a(c, p, i, g))));
|
|
30
|
-
}, { immediate: !0, flush: "post" }), d = () => {
|
|
31
|
-
C(), s();
|
|
32
|
-
};
|
|
33
|
-
return G(d), d;
|
|
34
|
-
}
|
|
35
|
-
const O = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, T = "__vueuse_ssr_handlers__";
|
|
36
|
-
O[T] = O[T] || {};
|
|
37
|
-
function J(e, { window: t = N, scrollTarget: r } = {}) {
|
|
38
|
-
const n = B(!1), o = () => {
|
|
39
|
-
if (!t)
|
|
40
|
-
return;
|
|
41
|
-
const l = t.document, s = y(e);
|
|
42
|
-
if (!s)
|
|
43
|
-
n.value = !1;
|
|
44
|
-
else {
|
|
45
|
-
const a = s.getBoundingClientRect();
|
|
46
|
-
n.value = a.top <= (t.innerHeight || l.documentElement.clientHeight) && a.left <= (t.innerWidth || l.documentElement.clientWidth) && a.bottom >= 0 && a.right >= 0;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
return D(() => y(e), () => o(), { immediate: !0, flush: "post" }), t && z(r || t, "scroll", o, {
|
|
50
|
-
capture: !1,
|
|
51
|
-
passive: !0
|
|
52
|
-
}), n;
|
|
53
|
-
}
|
|
54
|
-
var P;
|
|
55
|
-
(function(e) {
|
|
56
|
-
e.UP = "UP", e.RIGHT = "RIGHT", e.DOWN = "DOWN", e.LEFT = "LEFT", e.NONE = "NONE";
|
|
57
|
-
})(P || (P = {}));
|
|
58
|
-
var X = Object.defineProperty, I = Object.getOwnPropertySymbols, Y = Object.prototype.hasOwnProperty, Z = Object.prototype.propertyIsEnumerable, _ = (e, t, r) => t in e ? X(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, ee = (e, t) => {
|
|
59
|
-
for (var r in t || (t = {}))
|
|
60
|
-
Y.call(t, r) && _(e, r, t[r]);
|
|
61
|
-
if (I)
|
|
62
|
-
for (var r of I(t))
|
|
63
|
-
Z.call(t, r) && _(e, r, t[r]);
|
|
64
|
-
return e;
|
|
65
|
-
};
|
|
66
|
-
const te = {
|
|
67
|
-
easeInSine: [0.12, 0, 0.39, 0],
|
|
68
|
-
easeOutSine: [0.61, 1, 0.88, 1],
|
|
69
|
-
easeInOutSine: [0.37, 0, 0.63, 1],
|
|
70
|
-
easeInQuad: [0.11, 0, 0.5, 0],
|
|
71
|
-
easeOutQuad: [0.5, 1, 0.89, 1],
|
|
72
|
-
easeInOutQuad: [0.45, 0, 0.55, 1],
|
|
73
|
-
easeInCubic: [0.32, 0, 0.67, 0],
|
|
74
|
-
easeOutCubic: [0.33, 1, 0.68, 1],
|
|
75
|
-
easeInOutCubic: [0.65, 0, 0.35, 1],
|
|
76
|
-
easeInQuart: [0.5, 0, 0.75, 0],
|
|
77
|
-
easeOutQuart: [0.25, 1, 0.5, 1],
|
|
78
|
-
easeInOutQuart: [0.76, 0, 0.24, 1],
|
|
79
|
-
easeInQuint: [0.64, 0, 0.78, 0],
|
|
80
|
-
easeOutQuint: [0.22, 1, 0.36, 1],
|
|
81
|
-
easeInOutQuint: [0.83, 0, 0.17, 1],
|
|
82
|
-
easeInExpo: [0.7, 0, 0.84, 0],
|
|
83
|
-
easeOutExpo: [0.16, 1, 0.3, 1],
|
|
84
|
-
easeInOutExpo: [0.87, 0, 0.13, 1],
|
|
85
|
-
easeInCirc: [0.55, 0, 1, 0.45],
|
|
86
|
-
easeOutCirc: [0, 0.55, 0.45, 1],
|
|
87
|
-
easeInOutCirc: [0.85, 0, 0.15, 1],
|
|
88
|
-
easeInBack: [0.36, 0, 0.66, -0.56],
|
|
89
|
-
easeOutBack: [0.34, 1.56, 0.64, 1],
|
|
90
|
-
easeInOutBack: [0.68, -0.6, 0.32, 1.6]
|
|
91
|
-
};
|
|
92
|
-
ee({
|
|
93
|
-
linear: q
|
|
94
|
-
}, te);
|
|
95
|
-
const f = (e) => {
|
|
96
|
-
let t = J(e).value;
|
|
97
|
-
return t = t && e.offsetHeight > 0, t;
|
|
98
|
-
}, u = (e) => e.tabIndex >= 0, A = (e) => {
|
|
99
|
-
const t = e.target;
|
|
100
|
-
return E(t);
|
|
101
|
-
}, E = (e) => {
|
|
102
|
-
var r;
|
|
103
|
-
let t;
|
|
104
|
-
if (e instanceof HTMLTableCellElement) {
|
|
105
|
-
const n = (r = e.parentElement) == null ? void 0 : r.previousElementSibling;
|
|
106
|
-
if (n) {
|
|
107
|
-
const l = Array.from(n.children)[e.cellIndex];
|
|
108
|
-
l && (t = l);
|
|
109
|
-
}
|
|
110
|
-
} else if (e instanceof HTMLTableRowElement) {
|
|
111
|
-
const n = e.previousElementSibling;
|
|
112
|
-
n && (t = n);
|
|
113
|
-
}
|
|
114
|
-
return t && (!u(t) || !f(t)) ? E(t) : t;
|
|
115
|
-
}, ne = (e) => {
|
|
116
|
-
var n;
|
|
117
|
-
const t = e.target;
|
|
118
|
-
let r;
|
|
119
|
-
if (t instanceof HTMLTableCellElement) {
|
|
120
|
-
const o = (n = t.parentElement) == null ? void 0 : n.parentElement;
|
|
121
|
-
if (o) {
|
|
122
|
-
const s = o.firstElementChild.children[t.cellIndex];
|
|
123
|
-
s && (r = s);
|
|
124
|
-
}
|
|
125
|
-
} else if (t instanceof HTMLTableRowElement) {
|
|
126
|
-
const o = t.parentElement;
|
|
127
|
-
if (o) {
|
|
128
|
-
const l = o.firstElementChild;
|
|
129
|
-
l && (r = l);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return r && (!u(r) || !f(r)) ? w(r) : r;
|
|
133
|
-
}, x = (e) => {
|
|
134
|
-
const t = e.target;
|
|
135
|
-
return w(t);
|
|
136
|
-
}, w = (e) => {
|
|
137
|
-
var r;
|
|
138
|
-
let t;
|
|
139
|
-
if (e instanceof HTMLTableCellElement) {
|
|
140
|
-
const n = (r = e.parentElement) == null ? void 0 : r.nextElementSibling;
|
|
141
|
-
if (n) {
|
|
142
|
-
const l = Array.from(n.children)[e.cellIndex];
|
|
143
|
-
l && (t = l);
|
|
144
|
-
}
|
|
145
|
-
} else if (e instanceof HTMLTableRowElement) {
|
|
146
|
-
const n = e.nextElementSibling;
|
|
147
|
-
n && (t = n);
|
|
148
|
-
}
|
|
149
|
-
return t && (!u(t) || !f(t)) ? w(t) : t;
|
|
150
|
-
}, re = (e) => {
|
|
151
|
-
var n;
|
|
152
|
-
const t = e.target;
|
|
153
|
-
let r;
|
|
154
|
-
if (t instanceof HTMLTableCellElement) {
|
|
155
|
-
const o = (n = t.parentElement) == null ? void 0 : n.parentElement;
|
|
156
|
-
if (o) {
|
|
157
|
-
const s = o.lastElementChild.children[t.cellIndex];
|
|
158
|
-
s && (r = s);
|
|
159
|
-
}
|
|
160
|
-
} else if (t instanceof HTMLTableRowElement) {
|
|
161
|
-
const o = t.parentElement;
|
|
162
|
-
if (o) {
|
|
163
|
-
const l = o.lastElementChild;
|
|
164
|
-
l && (r = l);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return r && (!u(r) || !f(r)) ? E(r) : r;
|
|
168
|
-
}, k = (e) => {
|
|
169
|
-
const t = e.target;
|
|
170
|
-
return h(t);
|
|
171
|
-
}, h = (e) => {
|
|
172
|
-
var r;
|
|
173
|
-
let t;
|
|
174
|
-
if (e.previousElementSibling)
|
|
175
|
-
t = e.previousElementSibling;
|
|
176
|
-
else {
|
|
177
|
-
const n = (r = e.parentElement) == null ? void 0 : r.previousElementSibling;
|
|
178
|
-
t = n == null ? void 0 : n.lastElementChild;
|
|
179
|
-
}
|
|
180
|
-
return t && (!u(t) || !f(t)) ? h(t) : t;
|
|
181
|
-
}, S = (e) => {
|
|
182
|
-
const t = e.target;
|
|
183
|
-
return b(t);
|
|
184
|
-
}, b = (e) => {
|
|
185
|
-
var r;
|
|
186
|
-
let t;
|
|
187
|
-
if (e.nextElementSibling)
|
|
188
|
-
t = e.nextElementSibling;
|
|
189
|
-
else {
|
|
190
|
-
const n = (r = e.parentElement) == null ? void 0 : r.nextElementSibling;
|
|
191
|
-
t = n == null ? void 0 : n.firstElementChild;
|
|
192
|
-
}
|
|
193
|
-
return t && (!u(t) || !f(t)) ? b(t) : t;
|
|
194
|
-
}, L = (e) => {
|
|
195
|
-
const n = e.target.parentElement.firstElementChild;
|
|
196
|
-
return n && (!u(n) || !f(n)) ? b(n) : n;
|
|
197
|
-
}, R = (e) => {
|
|
198
|
-
const n = e.target.parentElement.lastElementChild;
|
|
199
|
-
return n && (!u(n) || !f(n)) ? h(n) : n;
|
|
200
|
-
}, m = ["alt", "control", "shift", "meta"], oe = {
|
|
201
|
-
ArrowUp: "up",
|
|
202
|
-
ArrowDown: "down",
|
|
203
|
-
ArrowLeft: "left",
|
|
204
|
-
ArrowRight: "right"
|
|
205
|
-
}, le = {
|
|
206
|
-
"keydown.up": (e) => {
|
|
207
|
-
const t = A(e);
|
|
208
|
-
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
209
|
-
},
|
|
210
|
-
"keydown.down": (e) => {
|
|
211
|
-
const t = x(e);
|
|
212
|
-
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
213
|
-
},
|
|
214
|
-
"keydown.left": (e) => {
|
|
215
|
-
const t = k(e);
|
|
216
|
-
e.preventDefault(), e.stopPropagation(), t && t.focus();
|
|
217
|
-
},
|
|
218
|
-
"keydown.right": (e) => {
|
|
219
|
-
const t = S(e);
|
|
220
|
-
e.preventDefault(), e.stopPropagation(), t && t.focus();
|
|
221
|
-
},
|
|
222
|
-
"keydown.control.up": (e) => {
|
|
223
|
-
const t = ne(e);
|
|
224
|
-
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
225
|
-
},
|
|
226
|
-
"keydown.control.down": (e) => {
|
|
227
|
-
const t = re(e);
|
|
228
|
-
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
229
|
-
},
|
|
230
|
-
"keydown.control.left": (e) => {
|
|
231
|
-
const t = L(e);
|
|
232
|
-
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
233
|
-
},
|
|
234
|
-
"keydown.control.right": (e) => {
|
|
235
|
-
const t = R(e);
|
|
236
|
-
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
237
|
-
},
|
|
238
|
-
"keydown.end": (e) => {
|
|
239
|
-
const t = R(e);
|
|
240
|
-
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
241
|
-
},
|
|
242
|
-
"keydown.enter": (e) => {
|
|
243
|
-
if (e.target instanceof HTMLTableCellElement) {
|
|
244
|
-
e.preventDefault(), e.stopPropagation();
|
|
245
|
-
const r = x(e);
|
|
246
|
-
r && r.focus();
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
"keydown.shift.enter": (e) => {
|
|
250
|
-
if (e.target instanceof HTMLTableCellElement) {
|
|
251
|
-
e.preventDefault(), e.stopPropagation();
|
|
252
|
-
const r = A(e);
|
|
253
|
-
r && r.focus();
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
"keydown.home": (e) => {
|
|
257
|
-
const t = L(e);
|
|
258
|
-
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
259
|
-
},
|
|
260
|
-
"keydown.tab": (e) => {
|
|
261
|
-
const t = S(e);
|
|
262
|
-
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
263
|
-
},
|
|
264
|
-
"keydown.shift.tab": (e) => {
|
|
265
|
-
const t = k(e);
|
|
266
|
-
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
function ie(e) {
|
|
270
|
-
const t = (n) => {
|
|
271
|
-
let o = null;
|
|
272
|
-
n.parent && (typeof n.parent == "string" ? o = document.querySelector(n.parent) : n.parent instanceof Element ? o = n.parent : o = n.parent.value);
|
|
273
|
-
let l = [];
|
|
274
|
-
if (n.selectors)
|
|
275
|
-
if (typeof n.selectors == "string")
|
|
276
|
-
l = o ? Array.from(o.querySelectorAll(n.selectors)) : Array.from(document.querySelectorAll(n.selectors));
|
|
277
|
-
else if (n.selectors instanceof Element)
|
|
278
|
-
l.push(n.selectors);
|
|
279
|
-
else if (Array.isArray(n.selectors.value))
|
|
280
|
-
for (const s of n.selectors.value)
|
|
281
|
-
s instanceof Element ? l.push(s) : l.push(s.$el);
|
|
282
|
-
else
|
|
283
|
-
l.push(n.selectors.value);
|
|
284
|
-
else
|
|
285
|
-
l = Array.from(o.children).filter((a) => u(a) && f(a));
|
|
286
|
-
return l;
|
|
287
|
-
}, r = (n) => (o) => {
|
|
288
|
-
const l = oe[o.key] || o.key.toLowerCase();
|
|
289
|
-
if (m.includes(l))
|
|
290
|
-
return;
|
|
291
|
-
const s = n.handlers || le;
|
|
292
|
-
for (const a of Object.keys(s)) {
|
|
293
|
-
const [C, ...d] = a.split(".");
|
|
294
|
-
if (C === "keydown" && d.includes(l)) {
|
|
295
|
-
const c = s[a], g = d.filter((i) => m.includes(i)), p = m.some((i) => {
|
|
296
|
-
const $ = i.charAt(0).toUpperCase() + i.slice(1);
|
|
297
|
-
return o.getModifierState($);
|
|
298
|
-
});
|
|
299
|
-
if (g.length > 0) {
|
|
300
|
-
if (p) {
|
|
301
|
-
for (const i of m)
|
|
302
|
-
if (d.includes(i)) {
|
|
303
|
-
const $ = i.charAt(0).toUpperCase() + i.slice(1);
|
|
304
|
-
o.getModifierState($) && c(o);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
} else
|
|
308
|
-
p || c(o);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
W(() => {
|
|
313
|
-
for (const n of e) {
|
|
314
|
-
const o = t(n);
|
|
315
|
-
for (const l of o)
|
|
316
|
-
l.addEventListener("keydown", r(n));
|
|
317
|
-
}
|
|
318
|
-
}), V(() => {
|
|
319
|
-
for (const n of e) {
|
|
320
|
-
const o = t(n);
|
|
321
|
-
for (const l of o)
|
|
322
|
-
l.removeEventListener("keydown", r(n));
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
function ae(e) {
|
|
327
|
-
}
|
|
328
|
-
export {
|
|
329
|
-
le as defaultKeypressHandlers,
|
|
330
|
-
ae as install,
|
|
331
|
-
ie as useKeyboardNav
|
|
332
|
-
};
|
|
333
|
-
//# sourceMappingURL=utilities.js.map
|