@indielayer/ui 1.14.1 → 1.14.3

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.
@@ -1,52 +1,50 @@
1
- import { ref as F, onUnmounted as h, unref as w, nextTick as x, watch as E } from "vue";
2
- const T = 'button:not([tabindex="-1"]), [href], input, select, textarea, li, a, [tabindex]:not([tabindex="-1"])';
3
- function p() {
4
- const l = F([]);
5
- let r = null, a = null, f = null, s = null, o = null;
6
- function d(e) {
1
+ import { ref as b, onUnmounted as F, unref as w, nextTick as x } from "vue";
2
+ const h = 'button:not([tabindex="-1"]), [href], input, select, textarea, li, a, [tabindex]:not([tabindex="-1"])';
3
+ function T() {
4
+ const l = b([]);
5
+ let t = null, a = null, s = null, i = null, o = null;
6
+ function m(e) {
7
7
  return e ? e.$el ? e.$el : e : null;
8
8
  }
9
- function m(e) {
10
- const n = d(e);
11
- if (!n)
9
+ function v(e) {
10
+ const u = m(e);
11
+ if (!u)
12
12
  return;
13
- const t = n.querySelectorAll(T);
14
- l.value = Array.from(t), a = l.value[0] || null, f = l.value[l.value.length - 1] || null;
13
+ const c = u.querySelectorAll(h);
14
+ l.value = Array.from(c), a = l.value[0] || null, s = l.value[l.value.length - 1] || null;
15
15
  }
16
- const v = (e) => {
16
+ const f = (e) => {
17
17
  if (e.key !== "Tab" || l.value.length === 0)
18
18
  return;
19
- const n = e.shiftKey, t = document.activeElement, u = a, c = f;
20
- if (!t) {
21
- e.preventDefault(), u == null || u.focus();
19
+ const u = e.shiftKey, c = document.activeElement, n = a, r = s;
20
+ if (!c) {
21
+ e.preventDefault(), n == null || n.focus();
22
22
  return;
23
23
  }
24
- !n && t === c ? (e.preventDefault(), u == null || u.focus()) : n && t === u && (e.preventDefault(), c == null || c.focus());
24
+ !u && c === r ? (e.preventDefault(), n == null || n.focus()) : u && c === n && (e.preventDefault(), r == null || r.focus());
25
25
  };
26
- async function b(e, n) {
27
- var c;
28
- if (typeof window > "u" || (i(), s = document.activeElement, o = w(e), !o))
26
+ async function y(e, u) {
27
+ var r;
28
+ if (typeof window > "u" || (d(), i = document.activeElement, o = w(e), !o))
29
29
  return;
30
- await x(), m(o);
31
- const t = (n == null ? void 0 : n.initialFocusIndex) ?? 0;
32
- (c = l.value[t]) == null || c.focus(), document.addEventListener("keydown", v), r = new MutationObserver(() => m(o));
33
- const u = d(o);
34
- u && r.observe(u, { childList: !0, subtree: !0 }), typeof e == "object" && e !== null && "value" in e && E(e, (y) => {
35
- i(), y !== null && b(e, n);
36
- });
30
+ await x(), v(o);
31
+ const c = (u == null ? void 0 : u.initialFocusIndex) ?? 0;
32
+ (r = l.value[c]) == null || r.focus(), document.removeEventListener("keydown", f), t == null || t.disconnect(), document.addEventListener("keydown", f);
33
+ const n = m(o);
34
+ n && (t = new MutationObserver(() => v(o)), t.observe(n, { childList: !0, subtree: !0 }));
37
35
  }
38
- function i(e) {
39
- document.removeEventListener("keydown", v), r == null || r.disconnect(), r = null, e != null && e.returnFocus && s && s.focus(), o = null;
36
+ function d(e) {
37
+ document.removeEventListener("keydown", f), t == null || t.disconnect(), t = null, e != null && e.returnFocus && i && i.focus(), o = null, l.value = [], a = null, s = null, i = null;
40
38
  }
41
- return h(() => {
42
- i({ returnFocus: !0 });
39
+ return F(() => {
40
+ d({ returnFocus: !0 });
43
41
  }), {
44
- initFocusTrap: b,
45
- clearFocusTrap: i,
42
+ initFocusTrap: y,
43
+ clearFocusTrap: d,
46
44
  focusable: l
47
45
  // expose for advanced use
48
46
  };
49
47
  }
50
48
  export {
51
- p as useFocusTrap
49
+ T as useFocusTrap
52
50
  };