@kolking/react-ui 1.0.0 → 1.2.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 (36) hide show
  1. package/dist/{Input-Lz3ft8Tp.js → Input-DE1QkW7S.js} +1 -1
  2. package/dist/components/Badge/Badge.d.ts +9 -0
  3. package/dist/components/Badge/Badge.js +56 -0
  4. package/dist/components/Badge/index.d.ts +1 -0
  5. package/dist/components/Badge/index.js +4 -0
  6. package/dist/components/Button/Button.d.ts +1 -1
  7. package/dist/components/Button/Button.js +5 -5
  8. package/dist/components/Dialog/Dialog.js +1 -1
  9. package/dist/components/Dialog/DialogFocusTrap.js +9 -757
  10. package/dist/components/Fields/Checkbox.js +7 -7
  11. package/dist/components/Fields/Field.js +10 -10
  12. package/dist/components/Fields/Input.js +2 -2
  13. package/dist/components/Fields/Quantity.js +18 -18
  14. package/dist/components/Fields/Radio.js +5 -5
  15. package/dist/components/Fields/Select.js +6 -6
  16. package/dist/components/Fields/Textarea.js +18 -177
  17. package/dist/components/Fields/index.js +1 -1
  18. package/dist/components/Flex/Flex.js +7 -7
  19. package/dist/components/Heading/Heading.js +1 -1
  20. package/dist/components/Icon/Icon.js +1 -1
  21. package/dist/components/Menu/Menu.js +41 -40
  22. package/dist/components/Menu/MenuItem.js +10 -10
  23. package/dist/components/Notice/Notice.js +1 -1
  24. package/dist/components/Progress/ProgressBar.js +5 -5
  25. package/dist/components/Progress/ProgressCircular.js +1 -1
  26. package/dist/components/Segmented/Segmented.js +10 -10
  27. package/dist/components/Spinner/Spinner.js +4 -4
  28. package/dist/components/Tooltip/Tooltip.js +37 -37
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.js +54 -52
  31. package/dist/styles/style.css +1 -1
  32. package/package.json +1 -1
  33. package/dist/_commonjsHelpers-B52_cu2H.js +0 -26
  34. package/dist/floating-ui.react-KLg1MUz0.js +0 -22334
  35. package/dist/index-DyIdU--j.js +0 -45
  36. package/dist/index.esm-Dkuk1b-q.js +0 -211
@@ -1,765 +1,17 @@
1
- import { jsx as ie } from "react/jsx-runtime";
2
- import oe from "react";
3
- import { a as ae } from "../../_commonjsHelpers-B52_cu2H.js";
4
- import { t as ue, f as se, i as A, g as B, a as J, b as ce } from "../../index.esm-Dkuk1b-q.js";
5
- var U = { exports: {} };
6
- /*!
7
- * focus-trap 7.6.4
8
- * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
9
- */
10
- function Q(i, t) {
11
- (t == null || t > i.length) && (t = i.length);
12
- for (var s = 0, l = Array(t); s < t; s++) l[s] = i[s];
13
- return l;
14
- }
15
- function le(i) {
16
- if (Array.isArray(i)) return Q(i);
17
- }
18
- function fe(i, t, s) {
19
- return (t = he(t)) in i ? Object.defineProperty(i, t, {
20
- value: s,
21
- enumerable: !0,
22
- configurable: !0,
23
- writable: !0
24
- }) : i[t] = s, i;
25
- }
26
- function de(i) {
27
- if (typeof Symbol < "u" && i[Symbol.iterator] != null || i["@@iterator"] != null) return Array.from(i);
28
- }
29
- function ve() {
30
- throw new TypeError(`Invalid attempt to spread non-iterable instance.
31
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
32
- }
33
- function Z(i, t) {
34
- var s = Object.keys(i);
35
- if (Object.getOwnPropertySymbols) {
36
- var l = Object.getOwnPropertySymbols(i);
37
- t && (l = l.filter(function(F) {
38
- return Object.getOwnPropertyDescriptor(i, F).enumerable;
39
- })), s.push.apply(s, l);
40
- }
41
- return s;
42
- }
43
- function ee(i) {
44
- for (var t = 1; t < arguments.length; t++) {
45
- var s = arguments[t] != null ? arguments[t] : {};
46
- t % 2 ? Z(Object(s), !0).forEach(function(l) {
47
- fe(i, l, s[l]);
48
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(i, Object.getOwnPropertyDescriptors(s)) : Z(Object(s)).forEach(function(l) {
49
- Object.defineProperty(i, l, Object.getOwnPropertyDescriptor(s, l));
50
- });
51
- }
52
- return i;
53
- }
54
- function pe(i) {
55
- return le(i) || de(i) || ye(i) || ve();
56
- }
57
- function be(i, t) {
58
- if (typeof i != "object" || !i) return i;
59
- var s = i[Symbol.toPrimitive];
60
- if (s !== void 0) {
61
- var l = s.call(i, t);
62
- if (typeof l != "object") return l;
63
- throw new TypeError("@@toPrimitive must return a primitive value.");
64
- }
65
- return (t === "string" ? String : Number)(i);
66
- }
67
- function he(i) {
68
- var t = be(i, "string");
69
- return typeof t == "symbol" ? t : t + "";
70
- }
71
- function ye(i, t) {
72
- if (i) {
73
- if (typeof i == "string") return Q(i, t);
74
- var s = {}.toString.call(i).slice(8, -1);
75
- return s === "Object" && i.constructor && (s = i.constructor.name), s === "Map" || s === "Set" ? Array.from(i) : s === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s) ? Q(i, t) : void 0;
76
- }
77
- }
78
- var te = {
79
- activateTrap: function(t, s) {
80
- if (t.length > 0) {
81
- var l = t[t.length - 1];
82
- l !== s && l._setPausedState(!0);
83
- }
84
- var F = t.indexOf(s);
85
- F === -1 || t.splice(F, 1), t.push(s);
86
- },
87
- deactivateTrap: function(t, s) {
88
- var l = t.indexOf(s);
89
- l !== -1 && t.splice(l, 1), t.length > 0 && !t[t.length - 1]._isManuallyPaused() && t[t.length - 1]._setPausedState(!1);
90
- }
91
- }, me = function(t) {
92
- return t.tagName && t.tagName.toLowerCase() === "input" && typeof t.select == "function";
93
- }, ge = function(t) {
94
- return (t == null ? void 0 : t.key) === "Escape" || (t == null ? void 0 : t.key) === "Esc" || (t == null ? void 0 : t.keyCode) === 27;
95
- }, L = function(t) {
96
- return (t == null ? void 0 : t.key) === "Tab" || (t == null ? void 0 : t.keyCode) === 9;
97
- }, Te = function(t) {
98
- return L(t) && !t.shiftKey;
99
- }, Fe = function(t) {
100
- return L(t) && t.shiftKey;
101
- }, ne = function(t) {
102
- return setTimeout(t, 0);
103
- }, I = function(t) {
104
- for (var s = arguments.length, l = new Array(s > 1 ? s - 1 : 0), F = 1; F < s; F++)
105
- l[F - 1] = arguments[F];
106
- return typeof t == "function" ? t.apply(void 0, l) : t;
107
- }, V = function(t) {
108
- return t.target.shadowRoot && typeof t.composedPath == "function" ? t.composedPath()[0] : t.target;
109
- }, we = [], Oe = function(t, s) {
110
- var l = (s == null ? void 0 : s.document) || document, F = (s == null ? void 0 : s.trapStack) || we, m = ee({
111
- returnFocusOnDeactivate: !0,
112
- escapeDeactivates: !0,
113
- delayInitialFocus: !0,
114
- isKeyForward: Te,
115
- isKeyBackward: Fe
116
- }, s), o = {
117
- // containers given to createFocusTrap()
118
- // @type {Array<HTMLElement>}
119
- containers: [],
120
- // list of objects identifying tabbable nodes in `containers` in the trap
121
- // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
122
- // is active, but the trap should never get to a state where there isn't at least one group
123
- // with at least one tabbable node in it (that would lead to an error condition that would
124
- // result in an error being thrown)
125
- // @type {Array<{
126
- // container: HTMLElement,
127
- // tabbableNodes: Array<HTMLElement>, // empty if none
128
- // focusableNodes: Array<HTMLElement>, // empty if none
129
- // posTabIndexesFound: boolean,
130
- // firstTabbableNode: HTMLElement|undefined,
131
- // lastTabbableNode: HTMLElement|undefined,
132
- // firstDomTabbableNode: HTMLElement|undefined,
133
- // lastDomTabbableNode: HTMLElement|undefined,
134
- // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
135
- // }>}
136
- containerGroups: [],
137
- // same order/length as `containers` list
138
- // references to objects in `containerGroups`, but only those that actually have
139
- // tabbable nodes in them
140
- // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
141
- // the same length
142
- tabbableGroups: [],
143
- nodeFocusedBeforeActivation: null,
144
- mostRecentlyFocusedNode: null,
145
- active: !1,
146
- paused: !1,
147
- manuallyPaused: !1,
148
- // timer ID for when delayInitialFocus is true and initial focus in this trap
149
- // has been delayed during activation
150
- delayInitialFocusTimer: void 0,
151
- // the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any
152
- recentNavEvent: void 0
153
- }, O, w = function(e, n, a) {
154
- return e && e[n] !== void 0 ? e[n] : m[a || n];
155
- }, E = function(e, n) {
156
- var a = typeof (n == null ? void 0 : n.composedPath) == "function" ? n.composedPath() : void 0;
157
- return o.containerGroups.findIndex(function(d) {
158
- var h = d.container, y = d.tabbableNodes;
159
- return h.contains(e) || // fall back to explicit tabbable search which will take into consideration any
160
- // web components if the `tabbableOptions.getShadowRoot` option was used for
161
- // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
162
- // look inside web components even if open)
163
- (a == null ? void 0 : a.includes(h)) || y.find(function(v) {
164
- return v === e;
165
- });
166
- });
167
- }, D = function(e) {
168
- var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, a = n.hasFallback, d = a === void 0 ? !1 : a, h = n.params, y = h === void 0 ? [] : h, v = m[e];
169
- if (typeof v == "function" && (v = v.apply(void 0, pe(y))), v === !0 && (v = void 0), !v) {
170
- if (v === void 0 || v === !1)
171
- return v;
172
- throw new Error("`".concat(e, "` was specified but was not a node, or did not return a node"));
173
- }
174
- var g = v;
175
- if (typeof v == "string") {
176
- try {
177
- g = l.querySelector(v);
178
- } catch (T) {
179
- throw new Error("`".concat(e, '` appears to be an invalid selector; error="').concat(T.message, '"'));
180
- }
181
- if (!g && !d)
182
- throw new Error("`".concat(e, "` as selector refers to no known node"));
183
- }
184
- return g;
185
- }, _ = function() {
186
- var e = D("initialFocus", {
187
- hasFallback: !0
188
- });
189
- if (e === !1)
190
- return !1;
191
- if (e === void 0 || e && !J(e, m.tabbableOptions))
192
- if (E(l.activeElement) >= 0)
193
- e = l.activeElement;
194
- else {
195
- var n = o.tabbableGroups[0], a = n && n.firstTabbableNode;
196
- e = a || D("fallbackFocus");
197
- }
198
- else e === null && (e = D("fallbackFocus"));
199
- if (!e)
200
- throw new Error("Your focus-trap needs to have at least one focusable element");
201
- return e;
202
- }, P = function() {
203
- if (o.containerGroups = o.containers.map(function(e) {
204
- var n = ue(e, m.tabbableOptions), a = se(e, m.tabbableOptions), d = n.length > 0 ? n[0] : void 0, h = n.length > 0 ? n[n.length - 1] : void 0, y = a.find(function(T) {
205
- return A(T);
206
- }), v = a.slice().reverse().find(function(T) {
207
- return A(T);
208
- }), g = !!n.find(function(T) {
209
- return B(T) > 0;
210
- });
211
- return {
212
- container: e,
213
- tabbableNodes: n,
214
- focusableNodes: a,
215
- /** True if at least one node with positive `tabindex` was found in this container. */
216
- posTabIndexesFound: g,
217
- /** First tabbable node in container, __tabindex__ order; `undefined` if none. */
218
- firstTabbableNode: d,
219
- /** Last tabbable node in container, __tabindex__ order; `undefined` if none. */
220
- lastTabbableNode: h,
221
- // NOTE: DOM order is NOT NECESSARILY "document position" order, but figuring that out
222
- // would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
223
- // because that API doesn't work with Shadow DOM as well as it should (@see
224
- // https://github.com/whatwg/dom/issues/320) and since this first/last is only needed, so far,
225
- // to address an edge case related to positive tabindex support, this seems like a much easier,
226
- // "close enough most of the time" alternative for positive tabindexes which should generally
227
- // be avoided anyway...
228
- /** First tabbable node in container, __DOM__ order; `undefined` if none. */
229
- firstDomTabbableNode: y,
230
- /** Last tabbable node in container, __DOM__ order; `undefined` if none. */
231
- lastDomTabbableNode: v,
232
- /**
233
- * Finds the __tabbable__ node that follows the given node in the specified direction,
234
- * in this container, if any.
235
- * @param {HTMLElement} node
236
- * @param {boolean} [forward] True if going in forward tab order; false if going
237
- * in reverse.
238
- * @returns {HTMLElement|undefined} The next tabbable node, if any.
239
- */
240
- nextTabbableNode: function(C) {
241
- var K = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, R = n.indexOf(C);
242
- return R < 0 ? K ? a.slice(a.indexOf(C) + 1).find(function(x) {
243
- return A(x);
244
- }) : a.slice(0, a.indexOf(C)).reverse().find(function(x) {
245
- return A(x);
246
- }) : n[R + (K ? 1 : -1)];
247
- }
248
- };
249
- }), o.tabbableGroups = o.containerGroups.filter(function(e) {
250
- return e.tabbableNodes.length > 0;
251
- }), o.tabbableGroups.length <= 0 && !D("fallbackFocus"))
252
- throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");
253
- if (o.containerGroups.find(function(e) {
254
- return e.posTabIndexesFound;
255
- }) && o.containerGroups.length > 1)
256
- 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.");
257
- }, q = function(e) {
258
- var n = e.activeElement;
259
- if (n)
260
- return n.shadowRoot && n.shadowRoot.activeElement !== null ? q(n.shadowRoot) : n;
261
- }, k = function(e) {
262
- if (e !== !1 && e !== q(document)) {
263
- if (!e || !e.focus) {
264
- k(_());
265
- return;
266
- }
267
- e.focus({
268
- preventScroll: !!m.preventScroll
269
- }), o.mostRecentlyFocusedNode = e, me(e) && e.select();
270
- }
271
- }, M = function(e) {
272
- var n = D("setReturnFocus", {
273
- params: [e]
274
- });
275
- return n || (n === !1 ? !1 : e);
276
- }, N = function(e) {
277
- var n = e.target, a = e.event, d = e.isBackward, h = d === void 0 ? !1 : d;
278
- n = n || V(a), P();
279
- var y = null;
280
- if (o.tabbableGroups.length > 0) {
281
- var v = E(n, a), g = v >= 0 ? o.containerGroups[v] : void 0;
282
- if (v < 0)
283
- h ? y = o.tabbableGroups[o.tabbableGroups.length - 1].lastTabbableNode : y = o.tabbableGroups[0].firstTabbableNode;
284
- else if (h) {
285
- var T = o.tabbableGroups.findIndex(function(z) {
286
- var Y = z.firstTabbableNode;
287
- return n === Y;
288
- });
289
- if (T < 0 && (g.container === n || J(n, m.tabbableOptions) && !A(n, m.tabbableOptions) && !g.nextTabbableNode(n, !1)) && (T = v), T >= 0) {
290
- var C = T === 0 ? o.tabbableGroups.length - 1 : T - 1, K = o.tabbableGroups[C];
291
- y = B(n) >= 0 ? K.lastTabbableNode : K.lastDomTabbableNode;
292
- } else L(a) || (y = g.nextTabbableNode(n, !1));
293
- } else {
294
- var R = o.tabbableGroups.findIndex(function(z) {
295
- var Y = z.lastTabbableNode;
296
- return n === Y;
297
- });
298
- if (R < 0 && (g.container === n || J(n, m.tabbableOptions) && !A(n, m.tabbableOptions) && !g.nextTabbableNode(n)) && (R = v), R >= 0) {
299
- var x = R === o.tabbableGroups.length - 1 ? 0 : R + 1, X = o.tabbableGroups[x];
300
- y = B(n) >= 0 ? X.firstTabbableNode : X.firstDomTabbableNode;
301
- } else L(a) || (y = g.nextTabbableNode(n));
302
- }
303
- } else
304
- y = D("fallbackFocus");
305
- return y;
306
- }, j = function(e) {
307
- var n = V(e);
308
- if (!(E(n, e) >= 0)) {
309
- if (I(m.clickOutsideDeactivates, e)) {
310
- O.deactivate({
311
- // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
312
- // which will result in the outside click setting focus to the node
313
- // that was clicked (and if not focusable, to "nothing"); by setting
314
- // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
315
- // on activation (or the configured `setReturnFocus` node), whether the
316
- // outside click was on a focusable node or not
317
- returnFocus: m.returnFocusOnDeactivate
318
- });
319
- return;
320
- }
321
- I(m.allowOutsideClick, e) || e.preventDefault();
322
- }
323
- }, $ = function(e) {
324
- var n = V(e), a = E(n, e) >= 0;
325
- if (a || n instanceof Document)
326
- a && (o.mostRecentlyFocusedNode = n);
327
- else {
328
- e.stopImmediatePropagation();
329
- var d, h = !0;
330
- if (o.mostRecentlyFocusedNode)
331
- if (B(o.mostRecentlyFocusedNode) > 0) {
332
- var y = E(o.mostRecentlyFocusedNode), v = o.containerGroups[y].tabbableNodes;
333
- if (v.length > 0) {
334
- var g = v.findIndex(function(T) {
335
- return T === o.mostRecentlyFocusedNode;
336
- });
337
- g >= 0 && (m.isKeyForward(o.recentNavEvent) ? g + 1 < v.length && (d = v[g + 1], h = !1) : g - 1 >= 0 && (d = v[g - 1], h = !1));
338
- }
339
- } else
340
- o.containerGroups.some(function(T) {
341
- return T.tabbableNodes.some(function(C) {
342
- return B(C) > 0;
343
- });
344
- }) || (h = !1);
345
- else
346
- h = !1;
347
- h && (d = N({
348
- // move FROM the MRU node, not event-related node (which will be the node that is
349
- // outside the trap causing the focus escape we're trying to fix)
350
- target: o.mostRecentlyFocusedNode,
351
- isBackward: m.isKeyBackward(o.recentNavEvent)
352
- })), k(d || o.mostRecentlyFocusedNode || _());
353
- }
354
- o.recentNavEvent = void 0;
355
- }, W = function(e) {
356
- var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
357
- o.recentNavEvent = e;
358
- var a = N({
359
- event: e,
360
- isBackward: n
361
- });
362
- a && (L(e) && e.preventDefault(), k(a));
363
- }, G = function(e) {
364
- (m.isKeyForward(e) || m.isKeyBackward(e)) && W(e, m.isKeyBackward(e));
365
- }, H = function(e) {
366
- ge(e) && I(m.escapeDeactivates, e) !== !1 && (e.preventDefault(), O.deactivate());
367
- }, S = function(e) {
368
- var n = V(e);
369
- E(n, e) >= 0 || I(m.clickOutsideDeactivates, e) || I(m.allowOutsideClick, e) || (e.preventDefault(), e.stopImmediatePropagation());
370
- }, c = function() {
371
- if (o.active)
372
- return te.activateTrap(F, O), o.delayInitialFocusTimer = m.delayInitialFocus ? ne(function() {
373
- k(_());
374
- }) : k(_()), l.addEventListener("focusin", $, !0), l.addEventListener("mousedown", j, {
375
- capture: !0,
376
- passive: !1
377
- }), l.addEventListener("touchstart", j, {
378
- capture: !0,
379
- passive: !1
380
- }), l.addEventListener("click", S, {
381
- capture: !0,
382
- passive: !1
383
- }), l.addEventListener("keydown", G, {
384
- capture: !0,
385
- passive: !1
386
- }), l.addEventListener("keydown", H), O;
387
- }, u = function() {
388
- if (o.active)
389
- return l.removeEventListener("focusin", $, !0), l.removeEventListener("mousedown", j, !0), l.removeEventListener("touchstart", j, !0), l.removeEventListener("click", S, !0), l.removeEventListener("keydown", G, !0), l.removeEventListener("keydown", H), O;
390
- }, p = function(e) {
391
- var n = e.some(function(a) {
392
- var d = Array.from(a.removedNodes);
393
- return d.some(function(h) {
394
- return h === o.mostRecentlyFocusedNode;
395
- });
396
- });
397
- n && k(_());
398
- }, r = typeof window < "u" && "MutationObserver" in window ? new MutationObserver(p) : void 0, b = function() {
399
- r && (r.disconnect(), o.active && !o.paused && o.containers.map(function(e) {
400
- r.observe(e, {
401
- subtree: !0,
402
- childList: !0
403
- });
404
- }));
405
- };
406
- return O = {
407
- get active() {
408
- return o.active;
409
- },
410
- get paused() {
411
- return o.paused;
412
- },
413
- activate: function(e) {
414
- if (o.active)
415
- return this;
416
- var n = w(e, "onActivate"), a = w(e, "onPostActivate"), d = w(e, "checkCanFocusTrap");
417
- d || P(), o.active = !0, o.paused = !1, o.nodeFocusedBeforeActivation = l.activeElement, n == null || n();
418
- var h = function() {
419
- d && P(), c(), b(), a == null || a();
420
- };
421
- return d ? (d(o.containers.concat()).then(h, h), this) : (h(), this);
422
- },
423
- deactivate: function(e) {
424
- if (!o.active)
425
- return this;
426
- var n = ee({
427
- onDeactivate: m.onDeactivate,
428
- onPostDeactivate: m.onPostDeactivate,
429
- checkCanReturnFocus: m.checkCanReturnFocus
430
- }, e);
431
- clearTimeout(o.delayInitialFocusTimer), o.delayInitialFocusTimer = void 0, u(), o.active = !1, o.paused = !1, b(), te.deactivateTrap(F, O);
432
- var a = w(n, "onDeactivate"), d = w(n, "onPostDeactivate"), h = w(n, "checkCanReturnFocus"), y = w(n, "returnFocus", "returnFocusOnDeactivate");
433
- a == null || a();
434
- var v = function() {
435
- ne(function() {
436
- y && k(M(o.nodeFocusedBeforeActivation)), d == null || d();
437
- });
438
- };
439
- return y && h ? (h(M(o.nodeFocusedBeforeActivation)).then(v, v), this) : (v(), this);
440
- },
441
- pause: function(e) {
442
- return o.active ? (o.manuallyPaused = !0, this._setPausedState(!0, e)) : this;
443
- },
444
- unpause: function(e) {
445
- return o.active ? (o.manuallyPaused = !1, F[F.length - 1] !== this ? this : this._setPausedState(!1, e)) : this;
446
- },
447
- updateContainerElements: function(e) {
448
- var n = [].concat(e).filter(Boolean);
449
- return o.containers = n.map(function(a) {
450
- return typeof a == "string" ? l.querySelector(a) : a;
451
- }), o.active && P(), b(), this;
452
- }
453
- }, Object.defineProperties(O, {
454
- _isManuallyPaused: {
455
- value: function() {
456
- return o.manuallyPaused;
457
- }
458
- },
459
- _setPausedState: {
460
- value: function(e, n) {
461
- if (o.paused === e)
462
- return this;
463
- if (o.paused = e, e) {
464
- var a = w(n, "onPause"), d = w(n, "onPostPause");
465
- a == null || a(), u(), b(), d == null || d();
466
- } else {
467
- var h = w(n, "onUnpause"), y = w(n, "onPostUnpause");
468
- h == null || h(), P(), c(), b(), y == null || y();
469
- }
470
- return this;
471
- }
472
- }
473
- }), O.updateContainerElements(t), O;
474
- };
475
- const De = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
476
- __proto__: null,
477
- createFocusTrap: Oe
478
- }, Symbol.toStringTag, { value: "Module" })), ke = /* @__PURE__ */ ae(De), Ee = /* @__PURE__ */ ae(ce);
479
- var re;
480
- function Pe() {
481
- if (re) return U.exports;
482
- re = 1;
483
- function i(c) {
484
- "@babel/helpers - typeof";
485
- return i = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(u) {
486
- return typeof u;
487
- } : function(u) {
488
- return u && typeof Symbol == "function" && u.constructor === Symbol && u !== Symbol.prototype ? "symbol" : typeof u;
489
- }, i(c);
490
- }
491
- var t, s;
492
- function l(c, u) {
493
- if (!(c instanceof u)) throw new TypeError("Cannot call a class as a function");
494
- }
495
- function F(c, u) {
496
- for (var p = 0; p < u.length; p++) {
497
- var r = u[p];
498
- r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(c, k(r.key), r);
499
- }
500
- }
501
- function m(c, u, p) {
502
- return u && F(c.prototype, u), Object.defineProperty(c, "prototype", { writable: !1 }), c;
503
- }
504
- function o(c, u, p) {
505
- return u = D(u), O(c, E() ? Reflect.construct(u, p || [], D(c).constructor) : u.apply(c, p));
506
- }
507
- function O(c, u) {
508
- if (u && (i(u) == "object" || typeof u == "function")) return u;
509
- if (u !== void 0) throw new TypeError("Derived constructors may only return object or undefined");
510
- return w(c);
511
- }
512
- function w(c) {
513
- if (c === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
514
- return c;
515
- }
516
- function E() {
517
- try {
518
- var c = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
519
- }));
520
- } catch {
521
- }
522
- return (E = function() {
523
- return !!c;
524
- })();
525
- }
526
- function D(c) {
527
- return D = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(u) {
528
- return u.__proto__ || Object.getPrototypeOf(u);
529
- }, D(c);
530
- }
531
- function _(c, u) {
532
- if (typeof u != "function" && u !== null) throw new TypeError("Super expression must either be null or a function");
533
- c.prototype = Object.create(u && u.prototype, { constructor: { value: c, writable: !0, configurable: !0 } }), Object.defineProperty(c, "prototype", { writable: !1 }), u && P(c, u);
534
- }
535
- function P(c, u) {
536
- return P = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(p, r) {
537
- return p.__proto__ = r, p;
538
- }, P(c, u);
539
- }
540
- function q(c, u, p) {
541
- return (u = k(u)) in c ? Object.defineProperty(c, u, { value: p, enumerable: !0, configurable: !0, writable: !0 }) : c[u] = p, c;
542
- }
543
- function k(c) {
544
- var u = M(c, "string");
545
- return i(u) == "symbol" ? u : u + "";
546
- }
547
- function M(c, u) {
548
- if (i(c) != "object" || !c) return c;
549
- var p = c[Symbol.toPrimitive];
550
- if (p !== void 0) {
551
- var r = p.call(c, u);
552
- if (i(r) != "object") return r;
553
- throw new TypeError("@@toPrimitive must return a primitive value.");
554
- }
555
- return (u === "string" ? String : Number)(c);
556
- }
557
- var N = oe, j = ke, $ = j.createFocusTrap, W = Ee, G = W.isFocusable, H = parseInt((t = (s = /^(\d+)\./.exec(N.version)) === null || s === void 0 ? void 0 : s[1]) !== null && t !== void 0 ? t : 0, 10), S = /* @__PURE__ */ function(c) {
558
- function u(p) {
559
- var r;
560
- l(this, u), r = o(this, u, [p]), q(r, "getNodeForOption", function(e) {
561
- var n, a = (n = this.internalOptions[e]) !== null && n !== void 0 ? n : this.originalOptions[e];
562
- if (typeof a == "function") {
563
- for (var d = arguments.length, h = new Array(d > 1 ? d - 1 : 0), y = 1; y < d; y++)
564
- h[y - 1] = arguments[y];
565
- a = a.apply(void 0, h);
566
- }
567
- if (a === !0 && (a = void 0), !a) {
568
- if (a === void 0 || a === !1)
569
- return a;
570
- throw new Error("`".concat(e, "` was specified but was not a node, or did not return a node"));
571
- }
572
- var v = a;
573
- if (typeof a == "string") {
574
- var g;
575
- if (v = (g = this.getDocument()) === null || g === void 0 ? void 0 : g.querySelector(a), !v)
576
- throw new Error("`".concat(e, "` as selector refers to no known node"));
577
- }
578
- return v;
579
- }), r.handleDeactivate = r.handleDeactivate.bind(r), r.handlePostDeactivate = r.handlePostDeactivate.bind(r), r.handleClickOutsideDeactivates = r.handleClickOutsideDeactivates.bind(r), r.internalOptions = {
580
- // We need to hijack the returnFocusOnDeactivate option,
581
- // because React can move focus into the element before we arrived at
582
- // this lifecycle hook (e.g. with autoFocus inputs). So the component
583
- // captures the previouslyFocusedElement in componentWillMount,
584
- // then (optionally) returns focus to it in componentWillUnmount.
585
- returnFocusOnDeactivate: !1,
586
- // the rest of these are also related to deactivation of the trap, and we
587
- // need to use them and control them as well
588
- checkCanReturnFocus: null,
589
- onDeactivate: r.handleDeactivate,
590
- onPostDeactivate: r.handlePostDeactivate,
591
- // we need to special-case this setting as well so that we can know if we should
592
- // NOT return focus if the trap gets auto-deactivated as the result of an
593
- // outside click (otherwise, we'll always think we should return focus because
594
- // of how we manage that flag internally here)
595
- clickOutsideDeactivates: r.handleClickOutsideDeactivates
596
- }, r.originalOptions = {
597
- // because of the above `internalOptions`, we maintain our own flag for
598
- // this option, and default it to `true` because that's focus-trap's default
599
- returnFocusOnDeactivate: !0,
600
- // because of the above `internalOptions`, we keep these separate since
601
- // they're part of the deactivation process which we configure (internally) to
602
- // be shared between focus-trap and focus-trap-react
603
- onDeactivate: null,
604
- onPostDeactivate: null,
605
- checkCanReturnFocus: null,
606
- // the user's setting, defaulted to false since focus-trap defaults this to false
607
- clickOutsideDeactivates: !1
608
- };
609
- var b = p.focusTrapOptions;
610
- for (var f in b)
611
- if (Object.prototype.hasOwnProperty.call(b, f)) {
612
- if (f === "returnFocusOnDeactivate" || f === "onDeactivate" || f === "onPostDeactivate" || f === "checkCanReturnFocus" || f === "clickOutsideDeactivates") {
613
- r.originalOptions[f] = b[f];
614
- continue;
615
- }
616
- r.internalOptions[f] = b[f];
617
- }
618
- return r.outsideClick = null, r.focusTrapElements = p.containerElements || [], r.updatePreviousElement(), r;
619
- }
620
- return _(u, c), m(u, [{
621
- key: "getDocument",
622
- value: function() {
623
- return this.props.focusTrapOptions.document || (typeof document < "u" ? document : void 0);
624
- }
625
- }, {
626
- key: "getReturnFocusNode",
627
- value: function() {
628
- var r = this.getNodeForOption("setReturnFocus", this.previouslyFocusedElement);
629
- return r || (r === !1 ? !1 : this.previouslyFocusedElement);
630
- }
631
- /** Update the previously focused element with the currently focused element. */
632
- }, {
633
- key: "updatePreviousElement",
634
- value: function() {
635
- var r = this.getDocument();
636
- r && (this.previouslyFocusedElement = r.activeElement);
637
- }
638
- }, {
639
- key: "deactivateTrap",
640
- value: function() {
641
- !this.focusTrap || !this.focusTrap.active || this.focusTrap.deactivate({
642
- // NOTE: we never let the trap return the focus since we do that ourselves
643
- returnFocus: !1,
644
- // we'll call this in our own post deactivate handler so make sure the trap doesn't
645
- // do it prematurely
646
- checkCanReturnFocus: null,
647
- // let it call the user's original deactivate handler, if any, instead of
648
- // our own which calls back into this function
649
- onDeactivate: this.originalOptions.onDeactivate
650
- // NOTE: for post deactivate, don't specify anything so that it calls the
651
- // onPostDeactivate handler specified on `this.internalOptions`
652
- // which will always be our own `handlePostDeactivate()` handler, which
653
- // will finish things off by calling the user's provided onPostDeactivate
654
- // handler, if any, at the right time
655
- // onPostDeactivate: NOTHING
656
- });
657
- }
658
- }, {
659
- key: "handleClickOutsideDeactivates",
660
- value: function(r) {
661
- var b = typeof this.originalOptions.clickOutsideDeactivates == "function" ? this.originalOptions.clickOutsideDeactivates.call(null, r) : this.originalOptions.clickOutsideDeactivates;
662
- return b && (this.outsideClick = {
663
- target: r.target,
664
- allowDeactivation: b
665
- }), b;
666
- }
667
- }, {
668
- key: "handleDeactivate",
669
- value: function() {
670
- this.originalOptions.onDeactivate && this.originalOptions.onDeactivate.call(null), this.deactivateTrap();
671
- }
672
- }, {
673
- key: "handlePostDeactivate",
674
- value: function() {
675
- var r = this, b = function() {
676
- var e = r.getReturnFocusNode(), n = !!// did the consumer allow it?
677
- (r.originalOptions.returnFocusOnDeactivate && // can we actually focus the node?
678
- e !== null && e !== void 0 && e.focus && // was there an outside click that allowed deactivation?
679
- (!r.outsideClick || // did the consumer allow deactivation when the outside node was clicked?
680
- r.outsideClick.allowDeactivation && // is the outside node NOT focusable (implying that it did NOT receive focus
681
- // as a result of the click-through) -- in which case do NOT restore focus
682
- // to `returnFocusNode` because focus should remain on the outside node
683
- !G(r.outsideClick.target, r.internalOptions.tabbableOptions))), a = r.internalOptions.preventScroll, d = a === void 0 ? !1 : a;
684
- n && e.focus({
685
- preventScroll: d
686
- }), r.originalOptions.onPostDeactivate && r.originalOptions.onPostDeactivate.call(null), r.outsideClick = null;
687
- };
688
- this.originalOptions.checkCanReturnFocus ? this.originalOptions.checkCanReturnFocus.call(null, this.getReturnFocusNode()).then(b, b) : b();
689
- }
690
- }, {
691
- key: "setupFocusTrap",
692
- value: function() {
693
- if (this.focusTrap)
694
- this.props.active && !this.focusTrap.active && (this.focusTrap.activate(), this.props.paused && this.focusTrap.pause());
695
- else {
696
- var r = this.focusTrapElements.some(Boolean);
697
- r && (this.focusTrap = this.props._createFocusTrap(this.focusTrapElements, this.internalOptions), this.props.active && this.focusTrap.activate(), this.props.paused && this.focusTrap.pause());
698
- }
699
- }
700
- }, {
701
- key: "componentDidMount",
702
- value: function() {
703
- this.props.active && this.setupFocusTrap();
704
- }
705
- }, {
706
- key: "componentDidUpdate",
707
- value: function(r) {
708
- if (this.focusTrap) {
709
- r.containerElements !== this.props.containerElements && this.focusTrap.updateContainerElements(this.props.containerElements);
710
- var b = !r.active && this.props.active, f = r.active && !this.props.active, e = !r.paused && this.props.paused, n = r.paused && !this.props.paused;
711
- if (b && (this.updatePreviousElement(), this.focusTrap.activate()), f) {
712
- this.deactivateTrap();
713
- return;
714
- }
715
- e && this.focusTrap.pause(), n && this.focusTrap.unpause();
716
- } else
717
- r.containerElements !== this.props.containerElements && (this.focusTrapElements = this.props.containerElements), this.props.active && (this.updatePreviousElement(), this.setupFocusTrap());
718
- }
719
- }, {
720
- key: "componentWillUnmount",
721
- value: function() {
722
- this.deactivateTrap();
723
- }
724
- }, {
725
- key: "render",
726
- value: function() {
727
- var r = this, b = this.props.children ? N.Children.only(this.props.children) : void 0;
728
- if (b) {
729
- if (b.type && b.type === N.Fragment)
730
- throw new Error("A focus-trap cannot use a Fragment as its child container. Try replacing it with a <div> element.");
731
- var f = function(a) {
732
- var d = r.props.containerElements;
733
- b && (H >= 19 ? typeof b.props.ref == "function" ? b.props.ref(a) : b.props.ref && (b.props.ref.current = a) : typeof b.ref == "function" ? b.ref(a) : b.ref && (b.ref.current = a)), r.focusTrapElements = d || [a];
734
- }, e = N.cloneElement(b, {
735
- ref: f
736
- });
737
- return e;
738
- }
739
- return null;
740
- }
741
- }]);
742
- }(N.Component);
743
- return S.defaultProps = {
744
- active: !0,
745
- paused: !1,
746
- focusTrapOptions: {},
747
- _createFocusTrap: $
748
- }, U.exports = S, U.exports.FocusTrap = S, U.exports;
749
- }
750
- var Ne = Pe();
751
- const Re = {
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { FocusTrap as s } from "focus-trap-react";
3
+ const i = {
752
4
  escapeDeactivates: !1,
753
- checkCanFocusTrap: async (i) => {
5
+ checkCanFocusTrap: async (e) => {
754
6
  await Promise.all(
755
- i.map((t) => new Promise((s) => {
756
- const l = setInterval(() => {
757
- getComputedStyle(t).visibility !== "hidden" && (s(), clearInterval(l));
7
+ e.map((a) => new Promise((t) => {
8
+ const o = setInterval(() => {
9
+ getComputedStyle(a).visibility !== "hidden" && (t(), clearInterval(o));
758
10
  }, 5);
759
11
  }))
760
12
  );
761
13
  }
762
- }, Ae = (i) => /* @__PURE__ */ ie(Ne.FocusTrap, { ...i, focusTrapOptions: Re });
14
+ }, p = (e) => /* @__PURE__ */ r(s, { ...e, focusTrapOptions: i });
763
15
  export {
764
- Ae as DialogFocusTrap
16
+ p as DialogFocusTrap
765
17
  };