@ogcio/design-system-react 1.26.0 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +27 -11
  2. package/dist/autocomplete/use-autocomplete-controller.js +1 -1
  3. package/dist/browser-support/browser-support.js +1 -1
  4. package/dist/character-count/character-count.d.ts +6 -0
  5. package/dist/character-count/character-count.js +23 -0
  6. package/dist/character-count/types.d.ts +10 -0
  7. package/dist/character-count/types.js +1 -0
  8. package/dist/data-table/editable-table-cell.js +1 -1
  9. package/dist/forms/form-field/form-field.js +1 -1
  10. package/dist/forms/form-field-with-tag/form-field-with-tag.js +1 -1
  11. package/dist/header/header-next/components/menu/components/header-menu-item-button.js +1 -1
  12. package/dist/header/header-next/components/menu/components/header-menu-item-link.js +1 -1
  13. package/dist/hooks/use-focus-trap.js +574 -416
  14. package/dist/i18n/config.js +2 -2
  15. package/dist/i18n/utility.js +1 -1
  16. package/dist/{i18nInstance-D_96ADqd.js → i18nInstance-AYICsHJu.js} +8 -6
  17. package/dist/{i18next-B_GQfCrJ.js → i18next-Bfi2-LyH.js} +125 -117
  18. package/dist/index-D_wwt4P0.js +87 -0
  19. package/dist/index.d.ts +7 -1
  20. package/dist/index.js +232 -229
  21. package/dist/link/link.js +33 -33
  22. package/dist/load-symbols/load-symbols.d.ts +7 -0
  23. package/dist/{load-fonts/load-fonts.js → load-symbols/load-symbols.js} +7 -13
  24. package/dist/{lodash-LsP9-6SV.js → lodash-82PmXrjJ.js} +16 -16
  25. package/dist/pagination/pagination.js +249 -221
  26. package/dist/primitives/anchor.js +1 -1
  27. package/dist/styles.css +1 -1
  28. package/dist/textarea/textarea.d.ts +6 -0
  29. package/dist/textarea/textarea.js +33 -33
  30. package/dist/useTranslation-DiBQuy8S.js +268 -0
  31. package/package.json +2 -2
  32. package/dist/index-2sRBqKFV.js +0 -78
  33. package/dist/load-fonts/load-fonts.d.ts +0 -40
  34. package/dist/useTranslation-BmIU4GBA.js +0 -272
@@ -1,329 +1,409 @@
1
- import { useLayoutEffect as he } from "react";
1
+ import { useLayoutEffect as ge } from "react";
2
2
  /*!
3
- * tabbable 6.2.0
3
+ * tabbable 6.4.0
4
4
  * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
5
5
  */
6
- var oe = ["input:not([inert])", "select:not([inert])", "textarea:not([inert])", "a[href]:not([inert])", "button:not([inert])", "[tabindex]:not(slot):not([inert])", "audio[controls]:not([inert])", "video[controls]:not([inert])", '[contenteditable]:not([contenteditable="false"]):not([inert])', "details>summary:first-of-type:not([inert])", "details:not([inert])"], K = /* @__PURE__ */ oe.join(","), ce = typeof Element > "u", R = ce ? function() {
7
- } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, j = !ce && Element.prototype.getRootNode ? function(r) {
6
+ var se = ["input:not([inert]):not([inert] *)", "select:not([inert]):not([inert] *)", "textarea:not([inert]):not([inert] *)", "a[href]:not([inert]):not([inert] *)", "button:not([inert]):not([inert] *)", "[tabindex]:not(slot):not([inert]):not([inert] *)", "audio[controls]:not([inert]):not([inert] *)", "video[controls]:not([inert]):not([inert] *)", '[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)', "details>summary:first-of-type:not([inert]):not([inert] *)", "details:not([inert]):not([inert] *)"], M = /* @__PURE__ */ se.join(","), ce = typeof Element > "u", O = ce ? function() {
7
+ } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, _ = !ce && Element.prototype.getRootNode ? function(r) {
8
8
  var e;
9
9
  return r == null || (e = r.getRootNode) === null || e === void 0 ? void 0 : e.call(r);
10
10
  } : function(r) {
11
11
  return r == null ? void 0 : r.ownerDocument;
12
- }, M = function r(e, t) {
13
- var a;
12
+ }, G = function(e, t) {
13
+ var n;
14
14
  t === void 0 && (t = !0);
15
- var o = e == null || (a = e.getAttribute) === null || a === void 0 ? void 0 : a.call(e, "inert"), c = o === "" || o === "true", i = c || t && e && r(e.parentNode);
16
- return i;
17
- }, ye = function(e) {
18
- var t, a = e == null || (t = e.getAttribute) === null || t === void 0 ? void 0 : t.call(e, "contenteditable");
19
- return a === "" || a === "true";
20
- }, le = function(e, t, a) {
21
- if (M(e))
15
+ var u = e == null || (n = e.getAttribute) === null || n === void 0 ? void 0 : n.call(e, "inert"), l = u === "" || u === "true", a = l || t && e && // closest does not exist on shadow roots, so we fall back to a manual
16
+ // lookup upward, in case it is not defined.
17
+ (typeof e.closest == "function" ? e.closest("[inert]") : G(e.parentNode));
18
+ return a;
19
+ }, we = function(e) {
20
+ var t, n = e == null || (t = e.getAttribute) === null || t === void 0 ? void 0 : t.call(e, "contenteditable");
21
+ return n === "" || n === "true";
22
+ }, fe = function(e, t, n) {
23
+ if (G(e))
22
24
  return [];
23
- var o = Array.prototype.slice.apply(e.querySelectorAll(K));
24
- return t && R.call(e, K) && o.unshift(e), o = o.filter(a), o;
25
- }, se = function r(e, t, a) {
26
- for (var o = [], c = Array.from(e); c.length; ) {
27
- var i = c.shift();
28
- if (!M(i, !1))
29
- if (i.tagName === "SLOT") {
30
- var b = i.assignedElements(), v = b.length ? b : i.children, p = r(v, !0, a);
31
- a.flatten ? o.push.apply(o, p) : o.push({
32
- scopeParent: i,
33
- candidates: p
25
+ var u = Array.prototype.slice.apply(e.querySelectorAll(M));
26
+ return t && O.call(e, M) && u.unshift(e), u = u.filter(n), u;
27
+ }, V = function(e, t, n) {
28
+ for (var u = [], l = Array.from(e); l.length; ) {
29
+ var a = l.shift();
30
+ if (!G(a, !1))
31
+ if (a.tagName === "SLOT") {
32
+ var v = a.assignedElements(), y = v.length ? v : a.children, g = V(y, !0, n);
33
+ n.flatten ? u.push.apply(u, g) : u.push({
34
+ scopeParent: a,
35
+ candidates: g
34
36
  });
35
37
  } else {
36
- var T = R.call(i, K);
37
- T && a.filter(i) && (t || !e.includes(i)) && o.push(i);
38
- var w = i.shadowRoot || // check for an undisclosed shadow
39
- typeof a.getShadowRoot == "function" && a.getShadowRoot(i), E = !M(w, !1) && (!a.shadowRootFilter || a.shadowRootFilter(i));
40
- if (w && E) {
41
- var D = r(w === !0 ? i.children : w.children, !0, a);
42
- a.flatten ? o.push.apply(o, D) : o.push({
43
- scopeParent: i,
44
- candidates: D
38
+ var w = O.call(a, M);
39
+ w && n.filter(a) && (t || !e.includes(a)) && u.push(a);
40
+ var T = a.shadowRoot || // check for an undisclosed shadow
41
+ typeof n.getShadowRoot == "function" && n.getShadowRoot(a), I = !G(T, !1) && (!n.shadowRootFilter || n.shadowRootFilter(a));
42
+ if (T && I) {
43
+ var P = V(T === !0 ? a.children : T.children, !0, n);
44
+ n.flatten ? u.push.apply(u, P) : u.push({
45
+ scopeParent: a,
46
+ candidates: P
45
47
  });
46
48
  } else
47
- c.unshift.apply(c, i.children);
49
+ l.unshift.apply(l, a.children);
48
50
  }
49
51
  }
50
- return o;
51
- }, fe = function(e) {
52
+ return u;
53
+ }, de = function(e) {
52
54
  return !isNaN(parseInt(e.getAttribute("tabindex"), 10));
53
- }, k = function(e) {
55
+ }, D = function(e) {
54
56
  if (!e)
55
57
  throw new Error("No node provided");
56
- return e.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName) || ye(e)) && !fe(e) ? 0 : e.tabIndex;
57
- }, pe = function(e, t) {
58
- var a = k(e);
59
- return a < 0 && t && !fe(e) ? 0 : a;
60
- }, ge = function(e, t) {
58
+ return e.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName) || we(e)) && !de(e) ? 0 : e.tabIndex;
59
+ }, Te = function(e, t) {
60
+ var n = D(e);
61
+ return n < 0 && t && !de(e) ? 0 : n;
62
+ }, Se = function(e, t) {
61
63
  return e.tabIndex === t.tabIndex ? e.documentOrder - t.documentOrder : e.tabIndex - t.tabIndex;
62
- }, de = function(e) {
64
+ }, ve = function(e) {
63
65
  return e.tagName === "INPUT";
64
- }, me = function(e) {
65
- return de(e) && e.type === "hidden";
66
- }, we = function(e) {
67
- var t = e.tagName === "DETAILS" && Array.prototype.slice.apply(e.children).some(function(a) {
68
- return a.tagName === "SUMMARY";
66
+ }, Ne = function(e) {
67
+ return ve(e) && e.type === "hidden";
68
+ }, Ee = function(e) {
69
+ var t = e.tagName === "DETAILS" && Array.prototype.slice.apply(e.children).some(function(n) {
70
+ return n.tagName === "SUMMARY";
69
71
  });
70
72
  return t;
71
- }, Te = function(e, t) {
72
- for (var a = 0; a < e.length; a++)
73
- if (e[a].checked && e[a].form === t)
74
- return e[a];
75
- }, Ne = function(e) {
73
+ }, Fe = function(e, t) {
74
+ for (var n = 0; n < e.length; n++)
75
+ if (e[n].checked && e[n].form === t)
76
+ return e[n];
77
+ }, ke = function(e) {
76
78
  if (!e.name)
77
79
  return !0;
78
- var t = e.form || j(e), a = function(b) {
79
- return t.querySelectorAll('input[type="radio"][name="' + b + '"]');
80
- }, o;
80
+ var t = e.form || _(e), n = function(v) {
81
+ return t.querySelectorAll('input[type="radio"][name="' + v + '"]');
82
+ }, u;
81
83
  if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
82
- o = a(window.CSS.escape(e.name));
84
+ u = n(window.CSS.escape(e.name));
83
85
  else
84
86
  try {
85
- o = a(e.name);
86
- } catch (i) {
87
- return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", i.message), !1;
87
+ u = n(e.name);
88
+ } catch (a) {
89
+ return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", a.message), !1;
88
90
  }
89
- var c = Te(o, e.form);
90
- return !c || c === e;
91
- }, Fe = function(e) {
92
- return de(e) && e.type === "radio";
93
- }, Ee = function(e) {
94
- return Fe(e) && !Ne(e);
95
- }, Se = function(e) {
96
- var t, a = e && j(e), o = (t = a) === null || t === void 0 ? void 0 : t.host, c = !1;
97
- if (a && a !== e) {
98
- var i, b, v;
99
- for (c = !!((i = o) !== null && i !== void 0 && (b = i.ownerDocument) !== null && b !== void 0 && b.contains(o) || e != null && (v = e.ownerDocument) !== null && v !== void 0 && v.contains(e)); !c && o; ) {
100
- var p, T, w;
101
- a = j(o), o = (p = a) === null || p === void 0 ? void 0 : p.host, c = !!((T = o) !== null && T !== void 0 && (w = T.ownerDocument) !== null && w !== void 0 && w.contains(o));
91
+ var l = Fe(u, e.form);
92
+ return !l || l === e;
93
+ }, Ae = function(e) {
94
+ return ve(e) && e.type === "radio";
95
+ }, Ie = function(e) {
96
+ return Ae(e) && !ke(e);
97
+ }, Re = function(e) {
98
+ var t, n = e && _(e), u = (t = n) === null || t === void 0 ? void 0 : t.host, l = !1;
99
+ if (n && n !== e) {
100
+ var a, v, y;
101
+ for (l = !!((a = u) !== null && a !== void 0 && (v = a.ownerDocument) !== null && v !== void 0 && v.contains(u) || e != null && (y = e.ownerDocument) !== null && y !== void 0 && y.contains(e)); !l && u; ) {
102
+ var g, w, T;
103
+ n = _(u), u = (g = n) === null || g === void 0 ? void 0 : g.host, l = !!((w = u) !== null && w !== void 0 && (T = w.ownerDocument) !== null && T !== void 0 && T.contains(u));
102
104
  }
103
105
  }
104
- return c;
105
- }, ae = function(e) {
106
- var t = e.getBoundingClientRect(), a = t.width, o = t.height;
107
- return a === 0 && o === 0;
108
- }, ke = function(e, t) {
109
- var a = t.displayCheck, o = t.getShadowRoot;
106
+ return l;
107
+ }, ne = function(e) {
108
+ var t = e.getBoundingClientRect(), n = t.width, u = t.height;
109
+ return n === 0 && u === 0;
110
+ }, De = function(e, t) {
111
+ var n = t.displayCheck, u = t.getShadowRoot;
112
+ if (n === "full-native" && "checkVisibility" in e) {
113
+ var l = e.checkVisibility({
114
+ // Checking opacity might be desirable for some use cases, but natively,
115
+ // opacity zero elements _are_ focusable and tabbable.
116
+ checkOpacity: !1,
117
+ opacityProperty: !1,
118
+ contentVisibilityAuto: !0,
119
+ visibilityProperty: !0,
120
+ // This is an alias for `visibilityProperty`. Contemporary browsers
121
+ // support both. However, this alias has wider browser support (Chrome
122
+ // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
123
+ // we include it anyway.
124
+ checkVisibilityCSS: !0
125
+ });
126
+ return !l;
127
+ }
110
128
  if (getComputedStyle(e).visibility === "hidden")
111
129
  return !0;
112
- var c = R.call(e, "details>summary:first-of-type"), i = c ? e.parentElement : e;
113
- if (R.call(i, "details:not([open]) *"))
130
+ var a = O.call(e, "details>summary:first-of-type"), v = a ? e.parentElement : e;
131
+ if (O.call(v, "details:not([open]) *"))
114
132
  return !0;
115
- if (!a || a === "full" || a === "legacy-full") {
116
- if (typeof o == "function") {
117
- for (var b = e; e; ) {
118
- var v = e.parentElement, p = j(e);
119
- if (v && !v.shadowRoot && o(v) === !0)
120
- return ae(e);
121
- e.assignedSlot ? e = e.assignedSlot : !v && p !== e.ownerDocument ? e = p.host : e = v;
133
+ if (!n || n === "full" || // full-native can run this branch when it falls through in case
134
+ // Element#checkVisibility is unsupported
135
+ n === "full-native" || n === "legacy-full") {
136
+ if (typeof u == "function") {
137
+ for (var y = e; e; ) {
138
+ var g = e.parentElement, w = _(e);
139
+ if (g && !g.shadowRoot && u(g) === !0)
140
+ return ne(e);
141
+ e.assignedSlot ? e = e.assignedSlot : !g && w !== e.ownerDocument ? e = w.host : e = g;
122
142
  }
123
- e = b;
143
+ e = y;
124
144
  }
125
- if (Se(e))
145
+ if (Re(e))
126
146
  return !e.getClientRects().length;
127
- if (a !== "legacy-full")
147
+ if (n !== "legacy-full")
128
148
  return !0;
129
- } else if (a === "non-zero-area")
130
- return ae(e);
149
+ } else if (n === "non-zero-area")
150
+ return ne(e);
131
151
  return !1;
132
- }, Re = function(e) {
152
+ }, Oe = function(e) {
133
153
  if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))
134
154
  for (var t = e.parentElement; t; ) {
135
155
  if (t.tagName === "FIELDSET" && t.disabled) {
136
- for (var a = 0; a < t.children.length; a++) {
137
- var o = t.children.item(a);
138
- if (o.tagName === "LEGEND")
139
- return R.call(t, "fieldset[disabled] *") ? !0 : !o.contains(e);
156
+ for (var n = 0; n < t.children.length; n++) {
157
+ var u = t.children.item(n);
158
+ if (u.tagName === "LEGEND")
159
+ return O.call(t, "fieldset[disabled] *") ? !0 : !u.contains(e);
140
160
  }
141
161
  return !0;
142
162
  }
143
163
  t = t.parentElement;
144
164
  }
145
165
  return !1;
146
- }, G = function(e, t) {
147
- return !(t.disabled || // we must do an inert look up to filter out any elements inside an inert ancestor
148
- // because we're limited in the type of selectors we can use in JSDom (see related
149
- // note related to `candidateSelectors`)
150
- M(t) || me(t) || ke(t, e) || // For a details element with a summary, the summary element gets the focus
151
- we(t) || Re(t));
152
- }, U = function(e, t) {
153
- return !(Ee(t) || k(t) < 0 || !G(e, t));
154
- }, De = function(e) {
166
+ }, q = function(e, t) {
167
+ return !(t.disabled || Ne(t) || De(t, e) || // For a details element with a summary, the summary element gets the focus
168
+ Ee(t) || Oe(t));
169
+ }, Z = function(e, t) {
170
+ return !(Ie(t) || D(t) < 0 || !q(e, t));
171
+ }, Pe = function(e) {
155
172
  var t = parseInt(e.getAttribute("tabindex"), 10);
156
173
  return !!(isNaN(t) || t >= 0);
157
- }, Ie = function r(e) {
158
- var t = [], a = [];
159
- return e.forEach(function(o, c) {
160
- var i = !!o.scopeParent, b = i ? o.scopeParent : o, v = pe(b, i), p = i ? r(o.candidates) : b;
161
- v === 0 ? i ? t.push.apply(t, p) : t.push(b) : a.push({
162
- documentOrder: c,
163
- tabIndex: v,
164
- item: o,
165
- isScope: i,
166
- content: p
174
+ }, be = function(e) {
175
+ var t = [], n = [];
176
+ return e.forEach(function(u, l) {
177
+ var a = !!u.scopeParent, v = a ? u.scopeParent : u, y = Te(v, a), g = a ? be(u.candidates) : v;
178
+ y === 0 ? a ? t.push.apply(t, g) : t.push(v) : n.push({
179
+ documentOrder: l,
180
+ tabIndex: y,
181
+ item: u,
182
+ isScope: a,
183
+ content: g
167
184
  });
168
- }), a.sort(ge).reduce(function(o, c) {
169
- return c.isScope ? o.push.apply(o, c.content) : o.push(c.content), o;
185
+ }), n.sort(Se).reduce(function(u, l) {
186
+ return l.isScope ? u.push.apply(u, l.content) : u.push(l.content), u;
170
187
  }, []).concat(t);
171
- }, Ae = function(e, t) {
188
+ }, Ce = function(e, t) {
172
189
  t = t || {};
173
- var a;
174
- return t.getShadowRoot ? a = se([e], t.includeContainer, {
175
- filter: U.bind(null, t),
190
+ var n;
191
+ return t.getShadowRoot ? n = V([e], t.includeContainer, {
192
+ filter: Z.bind(null, t),
176
193
  flatten: !1,
177
194
  getShadowRoot: t.getShadowRoot,
178
- shadowRootFilter: De
179
- }) : a = le(e, t.includeContainer, U.bind(null, t)), Ie(a);
180
- }, Oe = function(e, t) {
195
+ shadowRootFilter: Pe
196
+ }) : n = fe(e, t.includeContainer, Z.bind(null, t)), be(n);
197
+ }, je = function(e, t) {
181
198
  t = t || {};
182
- var a;
183
- return t.getShadowRoot ? a = se([e], t.includeContainer, {
184
- filter: G.bind(null, t),
199
+ var n;
200
+ return t.getShadowRoot ? n = V([e], t.includeContainer, {
201
+ filter: q.bind(null, t),
185
202
  flatten: !0,
186
203
  getShadowRoot: t.getShadowRoot
187
- }) : a = le(e, t.includeContainer, G.bind(null, t)), a;
188
- }, I = function(e, t) {
204
+ }) : n = fe(e, t.includeContainer, q.bind(null, t)), n;
205
+ }, C = function(e, t) {
189
206
  if (t = t || {}, !e)
190
207
  throw new Error("No node provided");
191
- return R.call(e, K) === !1 ? !1 : U(t, e);
192
- }, Pe = /* @__PURE__ */ oe.concat("iframe").join(","), $ = function(e, t) {
208
+ return O.call(e, M) === !1 ? !1 : Z(t, e);
209
+ }, Le = /* @__PURE__ */ se.concat("iframe:not([inert]):not([inert] *)").join(","), H = function(e, t) {
193
210
  if (t = t || {}, !e)
194
211
  throw new Error("No node provided");
195
- return R.call(e, Pe) === !1 ? !1 : G(t, e);
212
+ return O.call(e, Le) === !1 ? !1 : q(t, e);
196
213
  };
197
214
  /*!
198
- * focus-trap 7.6.5
215
+ * focus-trap 7.8.0
199
216
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
200
217
  */
201
- function W(r, e) {
218
+ function z(r, e) {
202
219
  (e == null || e > r.length) && (e = r.length);
203
- for (var t = 0, a = Array(e); t < e; t++) a[t] = r[t];
204
- return a;
220
+ for (var t = 0, n = Array(e); t < e; t++) n[t] = r[t];
221
+ return n;
205
222
  }
206
- function Ce(r) {
207
- if (Array.isArray(r)) return W(r);
223
+ function xe(r) {
224
+ if (Array.isArray(r)) return z(r);
225
+ }
226
+ function ie(r, e) {
227
+ var t = typeof Symbol < "u" && r[Symbol.iterator] || r["@@iterator"];
228
+ if (!t) {
229
+ if (Array.isArray(r) || (t = he(r)) || e) {
230
+ t && (r = t);
231
+ var n = 0, u = function() {
232
+ };
233
+ return {
234
+ s: u,
235
+ n: function() {
236
+ return n >= r.length ? {
237
+ done: !0
238
+ } : {
239
+ done: !1,
240
+ value: r[n++]
241
+ };
242
+ },
243
+ e: function(y) {
244
+ throw y;
245
+ },
246
+ f: u
247
+ };
248
+ }
249
+ throw new TypeError(`Invalid attempt to iterate non-iterable instance.
250
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
251
+ }
252
+ var l, a = !0, v = !1;
253
+ return {
254
+ s: function() {
255
+ t = t.call(r);
256
+ },
257
+ n: function() {
258
+ var y = t.next();
259
+ return a = y.done, y;
260
+ },
261
+ e: function(y) {
262
+ v = !0, l = y;
263
+ },
264
+ f: function() {
265
+ try {
266
+ a || t.return == null || t.return();
267
+ } finally {
268
+ if (v) throw l;
269
+ }
270
+ }
271
+ };
208
272
  }
209
- function xe(r, e, t) {
210
- return (e = Me(e)) in r ? Object.defineProperty(r, e, {
273
+ function Be(r, e, t) {
274
+ return (e = Ve(e)) in r ? Object.defineProperty(r, e, {
211
275
  value: t,
212
276
  enumerable: !0,
213
277
  configurable: !0,
214
278
  writable: !0
215
279
  }) : r[e] = t, r;
216
280
  }
217
- function Le(r) {
281
+ function Ke(r) {
218
282
  if (typeof Symbol < "u" && r[Symbol.iterator] != null || r["@@iterator"] != null) return Array.from(r);
219
283
  }
220
- function Be() {
284
+ function Me() {
221
285
  throw new TypeError(`Invalid attempt to spread non-iterable instance.
222
286
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
223
287
  }
224
- function re(r, e) {
288
+ function oe(r, e) {
225
289
  var t = Object.keys(r);
226
290
  if (Object.getOwnPropertySymbols) {
227
- var a = Object.getOwnPropertySymbols(r);
228
- e && (a = a.filter(function(o) {
229
- return Object.getOwnPropertyDescriptor(r, o).enumerable;
230
- })), t.push.apply(t, a);
291
+ var n = Object.getOwnPropertySymbols(r);
292
+ e && (n = n.filter(function(u) {
293
+ return Object.getOwnPropertyDescriptor(r, u).enumerable;
294
+ })), t.push.apply(t, n);
231
295
  }
232
296
  return t;
233
297
  }
234
- function ne(r) {
298
+ function ue(r) {
235
299
  for (var e = 1; e < arguments.length; e++) {
236
300
  var t = arguments[e] != null ? arguments[e] : {};
237
- e % 2 ? re(Object(t), !0).forEach(function(a) {
238
- xe(r, a, t[a]);
239
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(t)) : re(Object(t)).forEach(function(a) {
240
- Object.defineProperty(r, a, Object.getOwnPropertyDescriptor(t, a));
301
+ e % 2 ? oe(Object(t), !0).forEach(function(n) {
302
+ Be(r, n, t[n]);
303
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(t)) : oe(Object(t)).forEach(function(n) {
304
+ Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(t, n));
241
305
  });
242
306
  }
243
307
  return r;
244
308
  }
245
- function Ke(r) {
246
- return Ce(r) || Le(r) || Ge(r) || Be();
309
+ function _e(r) {
310
+ return xe(r) || Ke(r) || he(r) || Me();
247
311
  }
248
- function je(r, e) {
312
+ function Ge(r, e) {
249
313
  if (typeof r != "object" || !r) return r;
250
314
  var t = r[Symbol.toPrimitive];
251
315
  if (t !== void 0) {
252
- var a = t.call(r, e);
253
- if (typeof a != "object") return a;
316
+ var n = t.call(r, e);
317
+ if (typeof n != "object") return n;
254
318
  throw new TypeError("@@toPrimitive must return a primitive value.");
255
319
  }
256
320
  return (e === "string" ? String : Number)(r);
257
321
  }
258
- function Me(r) {
259
- var e = je(r, "string");
322
+ function Ve(r) {
323
+ var e = Ge(r, "string");
260
324
  return typeof e == "symbol" ? e : e + "";
261
325
  }
262
- function Ge(r, e) {
326
+ function he(r, e) {
263
327
  if (r) {
264
- if (typeof r == "string") return W(r, e);
328
+ if (typeof r == "string") return z(r, e);
265
329
  var t = {}.toString.call(r).slice(8, -1);
266
- return t === "Object" && r.constructor && (t = r.constructor.name), t === "Map" || t === "Set" ? Array.from(r) : t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? W(r, e) : void 0;
330
+ return t === "Object" && r.constructor && (t = r.constructor.name), t === "Map" || t === "Set" ? Array.from(r) : t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? z(r, e) : void 0;
267
331
  }
268
332
  }
269
- var ie = {
333
+ var F = {
334
+ // Returns the trap from the top of the stack.
335
+ getActiveTrap: function(e) {
336
+ return (e == null ? void 0 : e.length) > 0 ? e[e.length - 1] : null;
337
+ },
338
+ // Pauses the currently active trap, then adds a new trap to the stack.
270
339
  activateTrap: function(e, t) {
271
- if (e.length > 0) {
272
- var a = e[e.length - 1];
273
- a !== t && a._setPausedState(!0);
274
- }
275
- var o = e.indexOf(t);
276
- o === -1 || e.splice(o, 1), e.push(t);
340
+ var n = F.getActiveTrap(e);
341
+ t !== n && F.pauseTrap(e);
342
+ var u = e.indexOf(t);
343
+ u === -1 || e.splice(u, 1), e.push(t);
277
344
  },
345
+ // Removes the trap from the top of the stack, then unpauses the next trap down.
278
346
  deactivateTrap: function(e, t) {
279
- var a = e.indexOf(t);
280
- a !== -1 && e.splice(a, 1), e.length > 0 && !e[e.length - 1]._isManuallyPaused() && e[e.length - 1]._setPausedState(!1);
347
+ var n = e.indexOf(t);
348
+ n !== -1 && e.splice(n, 1), F.unpauseTrap(e);
349
+ },
350
+ // Pauses the trap at the top of the stack.
351
+ pauseTrap: function(e) {
352
+ var t = F.getActiveTrap(e);
353
+ t == null || t._setPausedState(!0);
354
+ },
355
+ // Unpauses the trap at the top of the stack.
356
+ unpauseTrap: function(e) {
357
+ var t = F.getActiveTrap(e);
358
+ t && !t._isManuallyPaused() && t._setPausedState(!1);
281
359
  }
282
360
  }, qe = function(e) {
283
361
  return e.tagName && e.tagName.toLowerCase() === "input" && typeof e.select == "function";
284
- }, Ve = function(e) {
362
+ }, Ue = function(e) {
285
363
  return (e == null ? void 0 : e.key) === "Escape" || (e == null ? void 0 : e.key) === "Esc" || (e == null ? void 0 : e.keyCode) === 27;
286
364
  }, x = function(e) {
287
365
  return (e == null ? void 0 : e.key) === "Tab" || (e == null ? void 0 : e.keyCode) === 9;
288
- }, _e = function(e) {
366
+ }, We = function(e) {
289
367
  return x(e) && !e.shiftKey;
290
- }, $e = function(e) {
368
+ }, Ye = function(e) {
291
369
  return x(e) && e.shiftKey;
292
- }, ue = function(e) {
370
+ }, le = function(e) {
293
371
  return setTimeout(e, 0);
294
- }, C = function(e) {
295
- for (var t = arguments.length, a = new Array(t > 1 ? t - 1 : 0), o = 1; o < t; o++)
296
- a[o - 1] = arguments[o];
297
- return typeof e == "function" ? e.apply(void 0, a) : e;
298
- }, B = function(e) {
372
+ }, L = function(e) {
373
+ for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), u = 1; u < t; u++)
374
+ n[u - 1] = arguments[u];
375
+ return typeof e == "function" ? e.apply(void 0, n) : e;
376
+ }, K = function(e) {
299
377
  return e.target.shadowRoot && typeof e.composedPath == "function" ? e.composedPath()[0] : e.target;
300
- }, Ue = [], We = function(e, t) {
301
- var a = (t == null ? void 0 : t.document) || document, o = (t == null ? void 0 : t.trapStack) || Ue, c = ne({
378
+ }, He = [], Ze = function(e, t) {
379
+ var n = (t == null ? void 0 : t.document) || document, u = (t == null ? void 0 : t.trapStack) || He, l = ue({
302
380
  returnFocusOnDeactivate: !0,
303
381
  escapeDeactivates: !0,
304
382
  delayInitialFocus: !0,
305
- isKeyForward: _e,
306
- isKeyBackward: $e
307
- }, t), i = {
383
+ isolateSubtrees: !1,
384
+ isKeyForward: We,
385
+ isKeyBackward: Ye
386
+ }, t), a = {
308
387
  // containers given to createFocusTrap()
309
- // @type {Array<HTMLElement>}
388
+ /** @type {Array<HTMLElement>} */
310
389
  containers: [],
311
390
  // list of objects identifying tabbable nodes in `containers` in the trap
312
391
  // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
313
392
  // is active, but the trap should never get to a state where there isn't at least one group
314
393
  // with at least one tabbable node in it (that would lead to an error condition that would
315
394
  // result in an error being thrown)
316
- // @type {Array<{
317
- // container: HTMLElement,
318
- // tabbableNodes: Array<HTMLElement>, // empty if none
319
- // focusableNodes: Array<HTMLElement>, // empty if none
320
- // posTabIndexesFound: boolean,
321
- // firstTabbableNode: HTMLElement|undefined,
322
- // lastTabbableNode: HTMLElement|undefined,
323
- // firstDomTabbableNode: HTMLElement|undefined,
324
- // lastDomTabbableNode: HTMLElement|undefined,
325
- // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
326
- // }>}
395
+ /** @type {Array<{
396
+ * container: HTMLElement,
397
+ * tabbableNodes: Array<HTMLElement>, // empty if none
398
+ * focusableNodes: Array<HTMLElement>, // empty if none
399
+ * posTabIndexesFound: boolean,
400
+ * firstTabbableNode: HTMLElement|undefined,
401
+ * lastTabbableNode: HTMLElement|undefined,
402
+ * firstDomTabbableNode: HTMLElement|undefined,
403
+ * lastDomTabbableNode: HTMLElement|undefined,
404
+ * nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
405
+ * }>}
406
+ */
327
407
  containerGroups: [],
328
408
  // same order/length as `containers` list
329
409
  // references to objects in `containerGroups`, but only those that actually have
@@ -331,6 +411,12 @@ var ie = {
331
411
  // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
332
412
  // the same length
333
413
  tabbableGroups: [],
414
+ // references to nodes that are siblings to the ancestors of this trap's containers.
415
+ /** @type {Set<HTMLElement>} */
416
+ adjacentElements: /* @__PURE__ */ new Set(),
417
+ // references to nodes that were inert or aria-hidden before the trap was activated.
418
+ /** @type {Set<HTMLElement>} */
419
+ alreadySilent: /* @__PURE__ */ new Set(),
334
420
  nodeFocusedBeforeActivation: null,
335
421
  mostRecentlyFocusedNode: null,
336
422
  active: !1,
@@ -341,74 +427,74 @@ var ie = {
341
427
  delayInitialFocusTimer: void 0,
342
428
  // the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any
343
429
  recentNavEvent: void 0
344
- }, b, v = function(n, u, l) {
345
- return n && n[u] !== void 0 ? n[u] : c[l || u];
346
- }, p = function(n, u) {
347
- var l = typeof (u == null ? void 0 : u.composedPath) == "function" ? u.composedPath() : void 0;
348
- return i.containerGroups.findIndex(function(f) {
349
- var d = f.container, y = f.tabbableNodes;
350
- return d.contains(n) || // fall back to explicit tabbable search which will take into consideration any
430
+ }, v, y = function(i, o, s) {
431
+ return i && i[o] !== void 0 ? i[o] : l[s || o];
432
+ }, g = function(i, o) {
433
+ var s = typeof (o == null ? void 0 : o.composedPath) == "function" ? o.composedPath() : void 0;
434
+ return a.containerGroups.findIndex(function(d) {
435
+ var f = d.container, b = d.tabbableNodes;
436
+ return f.contains(i) || // fall back to explicit tabbable search which will take into consideration any
351
437
  // web components if the `tabbableOptions.getShadowRoot` option was used for
352
438
  // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
353
439
  // look inside web components even if open)
354
- (l == null ? void 0 : l.includes(d)) || y.find(function(s) {
355
- return s === n;
440
+ (s == null ? void 0 : s.includes(f)) || b.find(function(c) {
441
+ return c === i;
356
442
  });
357
443
  });
358
- }, T = function(n) {
359
- var u = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, l = u.hasFallback, f = l === void 0 ? !1 : l, d = u.params, y = d === void 0 ? [] : d, s = c[n];
360
- if (typeof s == "function" && (s = s.apply(void 0, Ke(y))), s === !0 && (s = void 0), !s) {
361
- if (s === void 0 || s === !1)
362
- return s;
363
- throw new Error("`".concat(n, "` was specified but was not a node, or did not return a node"));
444
+ }, w = function(i) {
445
+ var o = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, s = o.hasFallback, d = s === void 0 ? !1 : s, f = o.params, b = f === void 0 ? [] : f, c = l[i];
446
+ if (typeof c == "function" && (c = c.apply(void 0, _e(b))), c === !0 && (c = void 0), !c) {
447
+ if (c === void 0 || c === !1)
448
+ return c;
449
+ throw new Error("`".concat(i, "` was specified but was not a node, or did not return a node"));
364
450
  }
365
- var g = s;
366
- if (typeof s == "string") {
451
+ var h = c;
452
+ if (typeof c == "string") {
367
453
  try {
368
- g = a.querySelector(s);
369
- } catch (m) {
370
- throw new Error("`".concat(n, '` appears to be an invalid selector; error="').concat(m.message, '"'));
454
+ h = n.querySelector(c);
455
+ } catch (p) {
456
+ throw new Error("`".concat(i, '` appears to be an invalid selector; error="').concat(p.message, '"'));
371
457
  }
372
- if (!g && !f)
373
- throw new Error("`".concat(n, "` as selector refers to no known node"));
458
+ if (!h && !d)
459
+ throw new Error("`".concat(i, "` as selector refers to no known node"));
374
460
  }
375
- return g;
376
- }, w = function() {
377
- var n = T("initialFocus", {
461
+ return h;
462
+ }, T = function() {
463
+ var i = w("initialFocus", {
378
464
  hasFallback: !0
379
465
  });
380
- if (n === !1)
466
+ if (i === !1)
381
467
  return !1;
382
- if (n === void 0 || n && !$(n, c.tabbableOptions))
383
- if (p(a.activeElement) >= 0)
384
- n = a.activeElement;
468
+ if (i === void 0 || i && !H(i, l.tabbableOptions))
469
+ if (g(n.activeElement) >= 0)
470
+ i = n.activeElement;
385
471
  else {
386
- var u = i.tabbableGroups[0], l = u && u.firstTabbableNode;
387
- n = l || T("fallbackFocus");
472
+ var o = a.tabbableGroups[0], s = o && o.firstTabbableNode;
473
+ i = s || w("fallbackFocus");
388
474
  }
389
- else n === null && (n = T("fallbackFocus"));
390
- if (!n)
475
+ else i === null && (i = w("fallbackFocus"));
476
+ if (!i)
391
477
  throw new Error("Your focus-trap needs to have at least one focusable element");
392
- return n;
393
- }, E = function() {
394
- if (i.containerGroups = i.containers.map(function(n) {
395
- var u = Ae(n, c.tabbableOptions), l = Oe(n, c.tabbableOptions), f = u.length > 0 ? u[0] : void 0, d = u.length > 0 ? u[u.length - 1] : void 0, y = l.find(function(m) {
396
- return I(m);
397
- }), s = l.slice().reverse().find(function(m) {
398
- return I(m);
399
- }), g = !!u.find(function(m) {
400
- return k(m) > 0;
478
+ return i;
479
+ }, I = function() {
480
+ if (a.containerGroups = a.containers.map(function(i) {
481
+ var o = Ce(i, l.tabbableOptions), s = je(i, l.tabbableOptions), d = o.length > 0 ? o[0] : void 0, f = o.length > 0 ? o[o.length - 1] : void 0, b = s.find(function(p) {
482
+ return C(p);
483
+ }), c = s.slice().reverse().find(function(p) {
484
+ return C(p);
485
+ }), h = !!o.find(function(p) {
486
+ return D(p) > 0;
401
487
  });
402
488
  return {
403
- container: n,
404
- tabbableNodes: u,
405
- focusableNodes: l,
489
+ container: i,
490
+ tabbableNodes: o,
491
+ focusableNodes: s,
406
492
  /** True if at least one node with positive `tabindex` was found in this container. */
407
- posTabIndexesFound: g,
493
+ posTabIndexesFound: h,
408
494
  /** First tabbable node in container, __tabindex__ order; `undefined` if none. */
409
- firstTabbableNode: f,
495
+ firstTabbableNode: d,
410
496
  /** Last tabbable node in container, __tabindex__ order; `undefined` if none. */
411
- lastTabbableNode: d,
497
+ lastTabbableNode: f,
412
498
  // NOTE: DOM order is NOT NECESSARILY "document position" order, but figuring that out
413
499
  // would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
414
500
  // because that API doesn't work with Shadow DOM as well as it should (@see
@@ -417,9 +503,9 @@ var ie = {
417
503
  // "close enough most of the time" alternative for positive tabindexes which should generally
418
504
  // be avoided anyway...
419
505
  /** First tabbable node in container, __DOM__ order; `undefined` if none. */
420
- firstDomTabbableNode: y,
506
+ firstDomTabbableNode: b,
421
507
  /** Last tabbable node in container, __DOM__ order; `undefined` if none. */
422
- lastDomTabbableNode: s,
508
+ lastDomTabbableNode: c,
423
509
  /**
424
510
  * Finds the __tabbable__ node that follows the given node in the specified direction,
425
511
  * in this container, if any.
@@ -429,255 +515,327 @@ var ie = {
429
515
  * @returns {HTMLElement|undefined} The next tabbable node, if any.
430
516
  */
431
517
  nextTabbableNode: function(S) {
432
- var O = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, F = u.indexOf(S);
433
- return F < 0 ? O ? l.slice(l.indexOf(S) + 1).find(function(P) {
434
- return I(P);
435
- }) : l.slice(0, l.indexOf(S)).reverse().find(function(P) {
436
- return I(P);
437
- }) : u[F + (O ? 1 : -1)];
518
+ var E = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, N = o.indexOf(S);
519
+ return N < 0 ? E ? s.slice(s.indexOf(S) + 1).find(function(R) {
520
+ return C(R);
521
+ }) : s.slice(0, s.indexOf(S)).reverse().find(function(R) {
522
+ return C(R);
523
+ }) : o[N + (E ? 1 : -1)];
438
524
  }
439
525
  };
440
- }), i.tabbableGroups = i.containerGroups.filter(function(n) {
441
- return n.tabbableNodes.length > 0;
442
- }), i.tabbableGroups.length <= 0 && !T("fallbackFocus"))
526
+ }), a.tabbableGroups = a.containerGroups.filter(function(i) {
527
+ return i.tabbableNodes.length > 0;
528
+ }), a.tabbableGroups.length <= 0 && !w("fallbackFocus"))
443
529
  throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");
444
- if (i.containerGroups.find(function(n) {
445
- return n.posTabIndexesFound;
446
- }) && i.containerGroups.length > 1)
530
+ if (a.containerGroups.find(function(i) {
531
+ return i.posTabIndexesFound;
532
+ }) && a.containerGroups.length > 1)
447
533
  throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.");
448
- }, D = function(n) {
449
- var u = n.activeElement;
450
- if (u)
451
- return u.shadowRoot && u.shadowRoot.activeElement !== null ? D(u.shadowRoot) : u;
452
- }, N = function(n) {
453
- if (n !== !1 && n !== D(document)) {
454
- if (!n || !n.focus) {
455
- N(w());
534
+ }, P = function(i) {
535
+ var o = i.activeElement;
536
+ if (o)
537
+ return o.shadowRoot && o.shadowRoot.activeElement !== null ? P(o.shadowRoot) : o;
538
+ }, k = function(i) {
539
+ if (i !== !1 && i !== P(document)) {
540
+ if (!i || !i.focus) {
541
+ k(T());
456
542
  return;
457
543
  }
458
- n.focus({
459
- preventScroll: !!c.preventScroll
460
- }), i.mostRecentlyFocusedNode = n, qe(n) && n.select();
544
+ i.focus({
545
+ preventScroll: !!l.preventScroll
546
+ }), a.mostRecentlyFocusedNode = i, qe(i) && i.select();
461
547
  }
462
- }, Y = function(n) {
463
- var u = T("setReturnFocus", {
464
- params: [n]
548
+ }, X = function(i) {
549
+ var o = w("setReturnFocus", {
550
+ params: [i]
465
551
  });
466
- return u || (u === !1 ? !1 : n);
467
- }, Z = function(n) {
468
- var u = n.target, l = n.event, f = n.isBackward, d = f === void 0 ? !1 : f;
469
- u = u || B(l), E();
470
- var y = null;
471
- if (i.tabbableGroups.length > 0) {
472
- var s = p(u, l), g = s >= 0 ? i.containerGroups[s] : void 0;
473
- if (s < 0)
474
- d ? y = i.tabbableGroups[i.tabbableGroups.length - 1].lastTabbableNode : y = i.tabbableGroups[0].firstTabbableNode;
475
- else if (d) {
476
- var m = i.tabbableGroups.findIndex(function(V) {
477
- var _ = V.firstTabbableNode;
478
- return u === _;
552
+ return o || (o === !1 ? !1 : i);
553
+ }, $ = function(i) {
554
+ var o = i.target, s = i.event, d = i.isBackward, f = d === void 0 ? !1 : d;
555
+ o = o || K(s), I();
556
+ var b = null;
557
+ if (a.tabbableGroups.length > 0) {
558
+ var c = g(o, s), h = c >= 0 ? a.containerGroups[c] : void 0;
559
+ if (c < 0)
560
+ f ? b = a.tabbableGroups[a.tabbableGroups.length - 1].lastTabbableNode : b = a.tabbableGroups[0].firstTabbableNode;
561
+ else if (f) {
562
+ var p = a.tabbableGroups.findIndex(function(W) {
563
+ var Y = W.firstTabbableNode;
564
+ return o === Y;
479
565
  });
480
- if (m < 0 && (g.container === u || $(u, c.tabbableOptions) && !I(u, c.tabbableOptions) && !g.nextTabbableNode(u, !1)) && (m = s), m >= 0) {
481
- var S = m === 0 ? i.tabbableGroups.length - 1 : m - 1, O = i.tabbableGroups[S];
482
- y = k(u) >= 0 ? O.lastTabbableNode : O.lastDomTabbableNode;
483
- } else x(l) || (y = g.nextTabbableNode(u, !1));
566
+ if (p < 0 && (h.container === o || H(o, l.tabbableOptions) && !C(o, l.tabbableOptions) && !h.nextTabbableNode(o, !1)) && (p = c), p >= 0) {
567
+ var S = p === 0 ? a.tabbableGroups.length - 1 : p - 1, E = a.tabbableGroups[S];
568
+ b = D(o) >= 0 ? E.lastTabbableNode : E.lastDomTabbableNode;
569
+ } else x(s) || (b = h.nextTabbableNode(o, !1));
484
570
  } else {
485
- var F = i.tabbableGroups.findIndex(function(V) {
486
- var _ = V.lastTabbableNode;
487
- return u === _;
571
+ var N = a.tabbableGroups.findIndex(function(W) {
572
+ var Y = W.lastTabbableNode;
573
+ return o === Y;
488
574
  });
489
- if (F < 0 && (g.container === u || $(u, c.tabbableOptions) && !I(u, c.tabbableOptions) && !g.nextTabbableNode(u)) && (F = s), F >= 0) {
490
- var P = F === i.tabbableGroups.length - 1 ? 0 : F + 1, te = i.tabbableGroups[P];
491
- y = k(u) >= 0 ? te.firstTabbableNode : te.firstDomTabbableNode;
492
- } else x(l) || (y = g.nextTabbableNode(u));
575
+ if (N < 0 && (h.container === o || H(o, l.tabbableOptions) && !C(o, l.tabbableOptions) && !h.nextTabbableNode(o)) && (N = c), N >= 0) {
576
+ var R = N === a.tabbableGroups.length - 1 ? 0 : N + 1, A = a.tabbableGroups[R];
577
+ b = D(o) >= 0 ? A.firstTabbableNode : A.firstDomTabbableNode;
578
+ } else x(s) || (b = h.nextTabbableNode(o));
493
579
  }
494
580
  } else
495
- y = T("fallbackFocus");
496
- return y;
497
- }, L = function(n) {
498
- var u = B(n);
499
- if (!(p(u, n) >= 0)) {
500
- if (C(c.clickOutsideDeactivates, n)) {
501
- b.deactivate({
581
+ b = w("fallbackFocus");
582
+ return b;
583
+ }, B = function(i) {
584
+ var o = K(i);
585
+ if (!(g(o, i) >= 0)) {
586
+ if (L(l.clickOutsideDeactivates, i)) {
587
+ v.deactivate({
502
588
  // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
503
589
  // which will result in the outside click setting focus to the node
504
590
  // that was clicked (and if not focusable, to "nothing"); by setting
505
591
  // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
506
592
  // on activation (or the configured `setReturnFocus` node), whether the
507
593
  // outside click was on a focusable node or not
508
- returnFocus: c.returnFocusOnDeactivate
594
+ returnFocus: l.returnFocusOnDeactivate
509
595
  });
510
596
  return;
511
597
  }
512
- C(c.allowOutsideClick, n) || n.preventDefault();
598
+ L(l.allowOutsideClick, i) || i.preventDefault();
513
599
  }
514
- }, z = function(n) {
515
- var u = B(n), l = p(u, n) >= 0;
516
- if (l || u instanceof Document)
517
- l && (i.mostRecentlyFocusedNode = u);
600
+ }, J = function(i) {
601
+ var o = K(i), s = g(o, i) >= 0;
602
+ if (s || o instanceof Document)
603
+ s && (a.mostRecentlyFocusedNode = o);
518
604
  else {
519
- n.stopImmediatePropagation();
520
- var f, d = !0;
521
- if (i.mostRecentlyFocusedNode)
522
- if (k(i.mostRecentlyFocusedNode) > 0) {
523
- var y = p(i.mostRecentlyFocusedNode), s = i.containerGroups[y].tabbableNodes;
524
- if (s.length > 0) {
525
- var g = s.findIndex(function(m) {
526
- return m === i.mostRecentlyFocusedNode;
605
+ i.stopImmediatePropagation();
606
+ var d, f = !0;
607
+ if (a.mostRecentlyFocusedNode)
608
+ if (D(a.mostRecentlyFocusedNode) > 0) {
609
+ var b = g(a.mostRecentlyFocusedNode), c = a.containerGroups[b].tabbableNodes;
610
+ if (c.length > 0) {
611
+ var h = c.findIndex(function(p) {
612
+ return p === a.mostRecentlyFocusedNode;
527
613
  });
528
- g >= 0 && (c.isKeyForward(i.recentNavEvent) ? g + 1 < s.length && (f = s[g + 1], d = !1) : g - 1 >= 0 && (f = s[g - 1], d = !1));
614
+ h >= 0 && (l.isKeyForward(a.recentNavEvent) ? h + 1 < c.length && (d = c[h + 1], f = !1) : h - 1 >= 0 && (d = c[h - 1], f = !1));
529
615
  }
530
616
  } else
531
- i.containerGroups.some(function(m) {
532
- return m.tabbableNodes.some(function(S) {
533
- return k(S) > 0;
617
+ a.containerGroups.some(function(p) {
618
+ return p.tabbableNodes.some(function(S) {
619
+ return D(S) > 0;
534
620
  });
535
- }) || (d = !1);
621
+ }) || (f = !1);
536
622
  else
537
- d = !1;
538
- d && (f = Z({
623
+ f = !1;
624
+ f && (d = $({
539
625
  // move FROM the MRU node, not event-related node (which will be the node that is
540
626
  // outside the trap causing the focus escape we're trying to fix)
541
- target: i.mostRecentlyFocusedNode,
542
- isBackward: c.isKeyBackward(i.recentNavEvent)
543
- })), N(f || i.mostRecentlyFocusedNode || w());
627
+ target: a.mostRecentlyFocusedNode,
628
+ isBackward: l.isKeyBackward(a.recentNavEvent)
629
+ })), k(d || a.mostRecentlyFocusedNode || T());
544
630
  }
545
- i.recentNavEvent = void 0;
546
- }, ve = function(n) {
547
- var u = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
548
- i.recentNavEvent = n;
549
- var l = Z({
550
- event: n,
551
- isBackward: u
631
+ a.recentNavEvent = void 0;
632
+ }, ye = function(i) {
633
+ var o = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
634
+ a.recentNavEvent = i;
635
+ var s = $({
636
+ event: i,
637
+ isBackward: o
552
638
  });
553
- l && (x(n) && n.preventDefault(), N(l));
554
- }, X = function(n) {
555
- (c.isKeyForward(n) || c.isKeyBackward(n)) && ve(n, c.isKeyBackward(n));
556
- }, H = function(n) {
557
- Ve(n) && C(c.escapeDeactivates, n) !== !1 && (n.preventDefault(), b.deactivate());
558
- }, J = function(n) {
559
- var u = B(n);
560
- p(u, n) >= 0 || C(c.clickOutsideDeactivates, n) || C(c.allowOutsideClick, n) || (n.preventDefault(), n.stopImmediatePropagation());
561
- }, Q = function() {
562
- if (i.active)
563
- return ie.activateTrap(o, b), i.delayInitialFocusTimer = c.delayInitialFocus ? ue(function() {
564
- N(w());
565
- }) : N(w()), a.addEventListener("focusin", z, !0), a.addEventListener("mousedown", L, {
639
+ s && (x(i) && i.preventDefault(), k(s));
640
+ }, Q = function(i) {
641
+ (l.isKeyForward(i) || l.isKeyBackward(i)) && ye(i, l.isKeyBackward(i));
642
+ }, ee = function(i) {
643
+ Ue(i) && L(l.escapeDeactivates, i) !== !1 && (i.preventDefault(), v.deactivate());
644
+ }, te = function(i) {
645
+ var o = K(i);
646
+ g(o, i) >= 0 || L(l.clickOutsideDeactivates, i) || L(l.allowOutsideClick, i) || (i.preventDefault(), i.stopImmediatePropagation());
647
+ }, ae = function() {
648
+ if (a.active)
649
+ return F.activateTrap(u, v), a.delayInitialFocusTimer = l.delayInitialFocus ? le(function() {
650
+ k(T());
651
+ }) : k(T()), n.addEventListener("focusin", J, !0), n.addEventListener("mousedown", B, {
566
652
  capture: !0,
567
653
  passive: !1
568
- }), a.addEventListener("touchstart", L, {
654
+ }), n.addEventListener("touchstart", B, {
569
655
  capture: !0,
570
656
  passive: !1
571
- }), a.addEventListener("click", J, {
657
+ }), n.addEventListener("click", te, {
572
658
  capture: !0,
573
659
  passive: !1
574
- }), a.addEventListener("keydown", X, {
660
+ }), n.addEventListener("keydown", Q, {
575
661
  capture: !0,
576
662
  passive: !1
577
- }), a.addEventListener("keydown", H), b;
578
- }, ee = function() {
579
- if (i.active)
580
- return a.removeEventListener("focusin", z, !0), a.removeEventListener("mousedown", L, !0), a.removeEventListener("touchstart", L, !0), a.removeEventListener("click", J, !0), a.removeEventListener("keydown", X, !0), a.removeEventListener("keydown", H), b;
581
- }, be = function(n) {
582
- var u = n.some(function(l) {
583
- var f = Array.from(l.removedNodes);
584
- return f.some(function(d) {
585
- return d === i.mostRecentlyFocusedNode;
663
+ }), n.addEventListener("keydown", ee), v;
664
+ }, pe = function(i) {
665
+ a.active && !a.paused && v._setSubtreeIsolation(!1), a.adjacentElements.clear(), a.alreadySilent.clear();
666
+ var o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), d = ie(i), f;
667
+ try {
668
+ for (d.s(); !(f = d.n()).done; ) {
669
+ var b = f.value;
670
+ o.add(b);
671
+ for (var c = typeof ShadowRoot < "u" && b.getRootNode() instanceof ShadowRoot, h = b; h; ) {
672
+ o.add(h);
673
+ var p = h.parentElement, S = [];
674
+ p ? S = p.children : !p && c && (S = h.getRootNode().children, p = h.getRootNode().host, c = typeof ShadowRoot < "u" && p.getRootNode() instanceof ShadowRoot);
675
+ var E = ie(S), N;
676
+ try {
677
+ for (E.s(); !(N = E.n()).done; ) {
678
+ var R = N.value;
679
+ s.add(R);
680
+ }
681
+ } catch (A) {
682
+ E.e(A);
683
+ } finally {
684
+ E.f();
685
+ }
686
+ h = p;
687
+ }
688
+ }
689
+ } catch (A) {
690
+ d.e(A);
691
+ } finally {
692
+ d.f();
693
+ }
694
+ o.forEach(function(A) {
695
+ s.delete(A);
696
+ }), a.adjacentElements = s;
697
+ }, re = function() {
698
+ if (a.active)
699
+ return n.removeEventListener("focusin", J, !0), n.removeEventListener("mousedown", B, !0), n.removeEventListener("touchstart", B, !0), n.removeEventListener("click", te, !0), n.removeEventListener("keydown", Q, !0), n.removeEventListener("keydown", ee), v;
700
+ }, me = function(i) {
701
+ var o = i.some(function(s) {
702
+ var d = Array.from(s.removedNodes);
703
+ return d.some(function(f) {
704
+ return f === a.mostRecentlyFocusedNode;
586
705
  });
587
706
  });
588
- u && N(w());
589
- }, q = typeof window < "u" && "MutationObserver" in window ? new MutationObserver(be) : void 0, A = function() {
590
- q && (q.disconnect(), i.active && !i.paused && i.containers.map(function(n) {
591
- q.observe(n, {
707
+ o && k(T());
708
+ }, U = typeof window < "u" && "MutationObserver" in window ? new MutationObserver(me) : void 0, j = function() {
709
+ U && (U.disconnect(), a.active && !a.paused && a.containers.map(function(i) {
710
+ U.observe(i, {
592
711
  subtree: !0,
593
712
  childList: !0
594
713
  });
595
714
  }));
596
715
  };
597
- return b = {
716
+ return v = {
598
717
  get active() {
599
- return i.active;
718
+ return a.active;
600
719
  },
601
720
  get paused() {
602
- return i.paused;
721
+ return a.paused;
603
722
  },
604
- activate: function(n) {
605
- if (i.active)
723
+ activate: function(i) {
724
+ if (a.active)
606
725
  return this;
607
- var u = v(n, "onActivate"), l = v(n, "onPostActivate"), f = v(n, "checkCanFocusTrap");
608
- f || E(), i.active = !0, i.paused = !1, i.nodeFocusedBeforeActivation = D(a), u == null || u();
609
- var d = function() {
610
- f && E(), Q(), A(), l == null || l();
611
- };
612
- return f ? (f(i.containers.concat()).then(d, d), this) : (d(), this);
726
+ var o = y(i, "onActivate"), s = y(i, "onPostActivate"), d = y(i, "checkCanFocusTrap"), f = F.getActiveTrap(u), b = !1;
727
+ if (f && !f.paused) {
728
+ var c;
729
+ (c = f._setSubtreeIsolation) === null || c === void 0 || c.call(f, !1), b = !0;
730
+ }
731
+ try {
732
+ d || I(), a.active = !0, a.paused = !1, a.nodeFocusedBeforeActivation = P(n), o == null || o();
733
+ var h = function() {
734
+ d && I(), ae(), j(), l.isolateSubtrees && v._setSubtreeIsolation(!0), s == null || s();
735
+ };
736
+ if (d)
737
+ return d(a.containers.concat()).then(h, h), this;
738
+ h();
739
+ } catch (S) {
740
+ if (f === F.getActiveTrap(u) && b) {
741
+ var p;
742
+ (p = f._setSubtreeIsolation) === null || p === void 0 || p.call(f, !0);
743
+ }
744
+ throw S;
745
+ }
746
+ return this;
613
747
  },
614
- deactivate: function(n) {
615
- if (!i.active)
748
+ deactivate: function(i) {
749
+ if (!a.active)
616
750
  return this;
617
- var u = ne({
618
- onDeactivate: c.onDeactivate,
619
- onPostDeactivate: c.onPostDeactivate,
620
- checkCanReturnFocus: c.checkCanReturnFocus
621
- }, n);
622
- clearTimeout(i.delayInitialFocusTimer), i.delayInitialFocusTimer = void 0, ee(), i.active = !1, i.paused = !1, A(), ie.deactivateTrap(o, b);
623
- var l = v(u, "onDeactivate"), f = v(u, "onPostDeactivate"), d = v(u, "checkCanReturnFocus"), y = v(u, "returnFocus", "returnFocusOnDeactivate");
624
- l == null || l();
625
- var s = function() {
626
- ue(function() {
627
- y && N(Y(i.nodeFocusedBeforeActivation)), f == null || f();
751
+ var o = ue({
752
+ onDeactivate: l.onDeactivate,
753
+ onPostDeactivate: l.onPostDeactivate,
754
+ checkCanReturnFocus: l.checkCanReturnFocus
755
+ }, i);
756
+ clearTimeout(a.delayInitialFocusTimer), a.delayInitialFocusTimer = void 0, a.paused || v._setSubtreeIsolation(!1), a.alreadySilent.clear(), re(), a.active = !1, a.paused = !1, j(), F.deactivateTrap(u, v);
757
+ var s = y(o, "onDeactivate"), d = y(o, "onPostDeactivate"), f = y(o, "checkCanReturnFocus"), b = y(o, "returnFocus", "returnFocusOnDeactivate");
758
+ s == null || s();
759
+ var c = function() {
760
+ le(function() {
761
+ b && k(X(a.nodeFocusedBeforeActivation)), d == null || d();
628
762
  });
629
763
  };
630
- return y && d ? (d(Y(i.nodeFocusedBeforeActivation)).then(s, s), this) : (s(), this);
764
+ return b && f ? (f(X(a.nodeFocusedBeforeActivation)).then(c, c), this) : (c(), this);
631
765
  },
632
- pause: function(n) {
633
- return i.active ? (i.manuallyPaused = !0, this._setPausedState(!0, n)) : this;
766
+ pause: function(i) {
767
+ return a.active ? (a.manuallyPaused = !0, this._setPausedState(!0, i)) : this;
634
768
  },
635
- unpause: function(n) {
636
- return i.active ? (i.manuallyPaused = !1, o[o.length - 1] !== this ? this : this._setPausedState(!1, n)) : this;
769
+ unpause: function(i) {
770
+ return a.active ? (a.manuallyPaused = !1, u[u.length - 1] !== this ? this : this._setPausedState(!1, i)) : this;
637
771
  },
638
- updateContainerElements: function(n) {
639
- var u = [].concat(n).filter(Boolean);
640
- return i.containers = u.map(function(l) {
641
- return typeof l == "string" ? a.querySelector(l) : l;
642
- }), i.active && E(), A(), this;
772
+ updateContainerElements: function(i) {
773
+ var o = [].concat(i).filter(Boolean);
774
+ return a.containers = o.map(function(s) {
775
+ return typeof s == "string" ? n.querySelector(s) : s;
776
+ }), l.isolateSubtrees && pe(a.containers), a.active && (I(), l.isolateSubtrees && !a.paused && v._setSubtreeIsolation(!0)), j(), this;
643
777
  }
644
- }, Object.defineProperties(b, {
778
+ }, Object.defineProperties(v, {
645
779
  _isManuallyPaused: {
646
780
  value: function() {
647
- return i.manuallyPaused;
781
+ return a.manuallyPaused;
648
782
  }
649
783
  },
650
784
  _setPausedState: {
651
- value: function(n, u) {
652
- if (i.paused === n)
785
+ value: function(i, o) {
786
+ if (a.paused === i)
653
787
  return this;
654
- if (i.paused = n, n) {
655
- var l = v(u, "onPause"), f = v(u, "onPostPause");
656
- l == null || l(), ee(), A(), f == null || f();
788
+ if (a.paused = i, i) {
789
+ var s = y(o, "onPause"), d = y(o, "onPostPause");
790
+ s == null || s(), re(), j(), v._setSubtreeIsolation(!1), d == null || d();
657
791
  } else {
658
- var d = v(u, "onUnpause"), y = v(u, "onPostUnpause");
659
- d == null || d(), E(), Q(), A(), y == null || y();
792
+ var f = y(o, "onUnpause"), b = y(o, "onPostUnpause");
793
+ f == null || f(), v._setSubtreeIsolation(!0), I(), ae(), j(), b == null || b();
660
794
  }
661
795
  return this;
662
796
  }
797
+ },
798
+ _setSubtreeIsolation: {
799
+ value: function(i) {
800
+ l.isolateSubtrees && a.adjacentElements.forEach(function(o) {
801
+ var s;
802
+ if (i)
803
+ switch (l.isolateSubtrees) {
804
+ case "aria-hidden":
805
+ (o.ariaHidden === "true" || ((s = o.getAttribute("aria-hidden")) === null || s === void 0 ? void 0 : s.toLowerCase()) === "true") && a.alreadySilent.add(o), o.setAttribute("aria-hidden", "true");
806
+ break;
807
+ default:
808
+ (o.inert || o.hasAttribute("inert")) && a.alreadySilent.add(o), o.setAttribute("inert", !0);
809
+ break;
810
+ }
811
+ else if (!a.alreadySilent.has(o)) switch (l.isolateSubtrees) {
812
+ case "aria-hidden":
813
+ o.removeAttribute("aria-hidden");
814
+ break;
815
+ default:
816
+ o.removeAttribute("inert");
817
+ break;
818
+ }
819
+ });
820
+ }
663
821
  }
664
- }), b.updateContainerElements(e), b;
822
+ }), v.updateContainerElements(e), v;
665
823
  };
666
- const Ze = (r, e, t) => {
667
- he(() => {
824
+ const Xe = (r, e, t) => {
825
+ ge(() => {
668
826
  if (!r || !e)
669
827
  return;
670
- const a = We(r, {
828
+ const n = Ze(r, {
671
829
  ...t,
672
830
  initialFocus: (t == null ? void 0 : t.initialFocus) ?? r,
673
831
  fallbackFocus: (t == null ? void 0 : t.fallbackFocus) ?? r,
674
832
  returnFocusOnDeactivate: !1
675
833
  });
676
- return a.activate(), () => {
677
- a.deactivate();
834
+ return n.activate(), () => {
835
+ n.deactivate();
678
836
  };
679
837
  }, [r, e]);
680
838
  };
681
839
  export {
682
- Ze as useFocusTrap
840
+ Xe as useFocusTrap
683
841
  };