@konstructio/ui 0.0.2 → 0.0.4

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 (118) hide show
  1. package/README.md +53 -4
  2. package/dist/{AlertDialogTrigger-BIbxXexQ.js → AlertDialogTrigger-lenvKoGF.js} +4 -4
  3. package/dist/Modal-Bg9UG35z.js +909 -0
  4. package/dist/{chevron-up-Cmu1oXfj.js → chevron-up-CvquEaNg.js} +1 -1
  5. package/dist/clsx-OuTLNxxd.js +16 -0
  6. package/dist/components/AlertDialog/AlertDialog.js +1 -1
  7. package/dist/components/AlertDialog/AlertDialog.variants.d.ts +1 -1
  8. package/dist/components/AlertDialog/AlertDialog.variants.js +4 -5
  9. package/dist/components/AlertDialog/components/AlertDialogTrigger.js +1 -1
  10. package/dist/components/AlertDialog/components/index.js +1 -1
  11. package/dist/components/Autocomplete/Autocomplete.variants.d.ts +2 -2
  12. package/dist/components/Autocomplete/Autocomplete.variants.js +8 -8
  13. package/dist/components/Autocomplete/components/List.types.d.ts +3 -3
  14. package/dist/components/Autocomplete/components/List.variants.d.ts +4 -4
  15. package/dist/components/Autocomplete/components/List.variants.js +13 -13
  16. package/dist/components/Autocomplete/hooks/useAutocomplete.d.ts +4 -4
  17. package/dist/components/Autocomplete/hooks/useNavigationList.d.ts +4 -4
  18. package/dist/components/Breadcrumb/Breadcrumb.js +57 -412
  19. package/dist/components/Breadcrumb/Breadcrumb.variants.d.ts +3 -3
  20. package/dist/components/Breadcrumb/Breadcrumb.variants.js +12 -12
  21. package/dist/components/Breadcrumb/hooks/useBreadcrumb.js +1 -1
  22. package/dist/components/Button/Button.js +23 -21
  23. package/dist/components/Button/Button.variants.d.ts +2 -1
  24. package/dist/components/Button/Button.variants.js +122 -23
  25. package/dist/components/Checkbox/Checkbox.js +4 -4
  26. package/dist/components/Checkbox/Checkbox.variants.d.ts +2 -2
  27. package/dist/components/Checkbox/Checkbox.variants.js +7 -16
  28. package/dist/components/Dropdown/Dropdown.js +5 -5
  29. package/dist/components/Dropdown/Dropdown.types.d.ts +1 -0
  30. package/dist/components/Dropdown/Dropdown.variants.d.ts +1 -1
  31. package/dist/components/Dropdown/Dropdown.variants.js +5 -9
  32. package/dist/components/Dropdown/components/List/List.d.ts +2 -2
  33. package/dist/components/Dropdown/components/List/List.types.d.ts +3 -3
  34. package/dist/components/Dropdown/components/List/List.variants.d.ts +1 -1
  35. package/dist/components/Dropdown/components/List/List.variants.js +3 -3
  36. package/dist/components/Dropdown/components/ListItem/ListItem.variants.d.ts +1 -1
  37. package/dist/components/Dropdown/components/ListItem/ListItem.variants.js +3 -3
  38. package/dist/components/Dropdown/components/Wrapper.d.ts +2 -2
  39. package/dist/components/Dropdown/components/Wrapper.js +1 -1
  40. package/dist/components/Dropdown/contexts/dropdown.provider.d.ts +4 -1
  41. package/dist/components/Dropdown/contexts/dropdown.provider.js +19 -8
  42. package/dist/components/Dropdown/hooks/useDropdown.d.ts +4 -4
  43. package/dist/components/Dropdown/hooks/useNavigationList.d.ts +4 -4
  44. package/dist/components/Input/Input.js +1 -1
  45. package/dist/components/Input/Input.variants.d.ts +1 -1
  46. package/dist/components/Input/Input.variants.js +3 -3
  47. package/dist/components/Modal/Modal.js +2 -2
  48. package/dist/components/Modal/components/Body/Body.js +1 -1
  49. package/dist/components/Modal/components/Footer/Footer.js +1 -1
  50. package/dist/components/Modal/components/Header/Header.js +1 -1
  51. package/dist/components/Modal/components/Wrapper/Wrapper.js +4 -3
  52. package/dist/components/Modal/components/Wrapper/Wrapper.variants.d.ts +2 -2
  53. package/dist/components/Modal/components/Wrapper/Wrapper.variants.js +10 -10
  54. package/dist/components/Modal/components/index.js +1 -1
  55. package/dist/components/Modal/hooks/useModal.d.ts +1 -1
  56. package/dist/components/NumberInput/NumberInput.js +96 -87
  57. package/dist/components/NumberInput/NumberInput.variants.d.ts +3 -3
  58. package/dist/components/NumberInput/NumberInput.variants.js +14 -21
  59. package/dist/components/ProgressBar/ProgressBar.variants.d.ts +2 -2
  60. package/dist/components/ProgressBar/ProgressBar.variants.js +7 -12
  61. package/dist/components/Radio/Radio.variants.d.ts +1 -1
  62. package/dist/components/Radio/Radio.variants.js +4 -7
  63. package/dist/components/RadioGroup/RadioGroup.js +1 -1
  64. package/dist/components/Range/Range.js +1 -1
  65. package/dist/components/Range/Range.variants.d.ts +4 -4
  66. package/dist/components/Range/Range.variants.js +18 -18
  67. package/dist/components/Slider/Slider.js +1 -1
  68. package/dist/components/Slider/Slider.variants.d.ts +3 -3
  69. package/dist/components/Slider/Slider.variants.js +12 -12
  70. package/dist/components/Switch/Switch.js +2 -2
  71. package/dist/components/Switch/Switch.variants.d.ts +2 -2
  72. package/dist/components/Switch/Switch.variants.js +6 -6
  73. package/dist/components/Tag/Tag.variants.js +1 -1
  74. package/dist/components/TagSelect/TagSelect.js +1 -1
  75. package/dist/components/TagSelect/TagSelect.variants.d.ts +3 -3
  76. package/dist/components/TagSelect/TagSelect.variants.js +11 -14
  77. package/dist/components/TagSelect/hooks/useTagSelect.d.ts +1 -1
  78. package/dist/components/TextArea/TextArea.variants.d.ts +1 -1
  79. package/dist/components/TextArea/TextArea.variants.js +5 -5
  80. package/dist/components/Toast/Toast.js +104 -101
  81. package/dist/components/Toast/Toast.variants.d.ts +3 -3
  82. package/dist/components/Toast/Toast.variants.js +12 -12
  83. package/dist/components/Tooltip/Tooltip.js +1 -1
  84. package/dist/components/Tooltip/Tooltip.variants.d.ts +2 -2
  85. package/dist/components/Tooltip/Tooltip.variants.js +9 -9
  86. package/dist/components/Tooltip/hooks/useTooltip.d.ts +1 -1
  87. package/dist/components/index.js +1 -1
  88. package/dist/contexts/theme.context.d.ts +1 -1
  89. package/dist/contexts/theme.hook.js +3 -6
  90. package/dist/contexts/theme.provider.d.ts +2 -3
  91. package/dist/contexts/theme.provider.js +4 -1
  92. package/dist/index-BBjak_0p.js +47 -0
  93. package/dist/index-BNmRGtA6.js +34 -0
  94. package/dist/{index-DFbnnPzA.js → index-Ci9Yg4G1.js} +5 -5
  95. package/dist/{index-B_GWswUP.js → index-D4Q2rMby.js} +1 -1
  96. package/dist/{index-DQMInta3.js → index-D68N8v8R.js} +214 -209
  97. package/dist/index-DoOsnuB6.js +72 -0
  98. package/dist/{index-2K8qjK4R.js → index-O3j1K921.js} +36 -37
  99. package/dist/index-OOfdXoxx.js +423 -0
  100. package/dist/index-ffjBR8Av.js +32 -0
  101. package/dist/index.js +1 -1
  102. package/dist/package.json +42 -38
  103. package/dist/plugins/konstruct.js +61 -50
  104. package/dist/plugins/utils/colors.d.ts +127 -10
  105. package/dist/plugins/utils/colors.js +210 -510
  106. package/dist/styles.css +1 -1
  107. package/dist/useBreadcrumb-tyxjV-a1.js +1398 -0
  108. package/dist/utils/index.js +150 -162
  109. package/dist/x-CRBgmX1Q.js +62 -0
  110. package/package.json +42 -38
  111. package/dist/Modal-CO0_SnXD.js +0 -909
  112. package/dist/index-2hJuj4UN.js +0 -19069
  113. package/dist/index-4qm4jAkj.js +0 -92
  114. package/dist/index-BJ7FQg17.js +0 -35
  115. package/dist/index-BqM_XclQ.js +0 -94
  116. package/dist/index-BwYCDOHZ.js +0 -44
  117. package/dist/index-CCavb-1K.js +0 -57
  118. package/dist/useBreadcrumb-BSMnc4Fu.js +0 -341
@@ -1,909 +0,0 @@
1
- import { jsx as D, jsxs as J } from "react/jsx-runtime";
2
- import { r as Tr } from "./index-2hJuj4UN.js";
3
- import { Body as Ar } from "./components/Modal/components/Body/Body.js";
4
- import { Footer as Cr } from "./components/Modal/components/Footer/Footer.js";
5
- import { Header as Rr } from "./components/Modal/components/Header/Header.js";
6
- import * as v from "react";
7
- import Dr, { createContext as kr, PureComponent as _r, Children as V, isValidElement as $ } from "react";
8
- import { P as ke, p as l } from "./index-DQMInta3.js";
9
- import { c as ie, a as Mr, u as Lr, R as Wr } from "./Combination-Cmu9JRkv.js";
10
- import { X as Br, R as Ur } from "./index-4qm4jAkj.js";
11
- import "./contexts/theme.context.js";
12
- import { useTheme as Gr } from "./contexts/theme.hook.js";
13
- import "./js.cookie-OLEfuq_g.js";
14
- import { useModal as _e } from "./components/Modal/hooks/useModal.js";
15
- import { modalVariants as Hr, buttonCloseVariants as jr } from "./components/Modal/components/Wrapper/Wrapper.variants.js";
16
- function Vr(e, r) {
17
- if (e == null) return {};
18
- var n = {};
19
- for (var t in e) if ({}.hasOwnProperty.call(e, t)) {
20
- if (r.includes(t)) continue;
21
- n[t] = e[t];
22
- }
23
- return n;
24
- }
25
- function W() {
26
- return W = Object.assign ? Object.assign.bind() : function(e) {
27
- for (var r = 1; r < arguments.length; r++) {
28
- var n = arguments[r];
29
- for (var t in n) ({}).hasOwnProperty.call(n, t) && (e[t] = n[t]);
30
- }
31
- return e;
32
- }, W.apply(null, arguments);
33
- }
34
- var ne = "data-focus-lock", Me = "data-focus-lock-disabled", $r = "data-no-focus-lock", qr = "data-autofocus-inside", Kr = "data-no-autofocus", Q = {
35
- width: "1px",
36
- height: "0px",
37
- padding: 0,
38
- overflow: "hidden",
39
- position: "fixed",
40
- top: "1px",
41
- left: "1px"
42
- };
43
- process.env.NODE_ENV !== "production" && ke.node;
44
- var Le = ie({}, function(e) {
45
- var r = e.target, n = e.currentTarget;
46
- return {
47
- target: r,
48
- currentTarget: n
49
- };
50
- }), We = ie(), Xr = ie(), Yr = Mr({
51
- async: !0,
52
- ssr: typeof document < "u"
53
- }), zr = /* @__PURE__ */ kr(void 0), Jr = [], ce = /* @__PURE__ */ v.forwardRef(function(r, n) {
54
- var t, o = v.useState(), u = o[0], i = o[1], c = v.useRef(), m = v.useRef(!1), f = v.useRef(null), y = v.useState({}), s = y[1], a = r.children, p = r.disabled, d = p === void 0 ? !1 : p, b = r.noFocusGuards, F = b === void 0 ? !1 : b, O = r.persistentFocus, h = O === void 0 ? !1 : O, g = r.crossFrame, w = g === void 0 ? !0 : g, I = r.autoFocus, K = I === void 0 ? !0 : I, fr = r.allowTextSelection, sr = r.group, dr = r.className, lr = r.whiteList, vr = r.hasPositiveIndices, Fe = r.shards, X = Fe === void 0 ? Jr : Fe, Ee = r.as, Oe = Ee === void 0 ? "div" : Ee, xe = r.lockProps, mr = xe === void 0 ? {} : xe, pr = r.sideCar, we = r.returnFocus, j = we === void 0 ? !1 : we, br = r.focusOptions, Y = r.onActivation, z = r.onDeactivation, yr = v.useState({}), hr = yr[0], gr = v.useCallback(function(N) {
55
- var C = N.captureFocusRestore;
56
- if (!f.current) {
57
- var R, P = (R = document) == null ? void 0 : R.activeElement;
58
- f.current = P, P !== document.body && (f.current = C(P));
59
- }
60
- c.current && Y && Y(c.current), m.current = !0, s();
61
- }, [Y]), Fr = v.useCallback(function() {
62
- m.current = !1, z && z(c.current), s();
63
- }, [z]), Er = v.useCallback(function(N) {
64
- var C = f.current;
65
- if (C) {
66
- var R = (typeof C == "function" ? C() : C) || document.body, P = typeof j == "function" ? j(R) : j;
67
- if (P) {
68
- var Se = typeof P == "object" ? P : void 0;
69
- f.current = null, N ? Promise.resolve().then(function() {
70
- return R.focus(Se);
71
- }) : R.focus(Se);
72
- }
73
- }
74
- }, [j]), Or = v.useCallback(function(N) {
75
- m.current && Le.useMedium(N);
76
- }, []), xr = We.useMedium, wr = v.useCallback(function(N) {
77
- c.current !== N && (c.current = N, i(N));
78
- }, []);
79
- process.env.NODE_ENV !== "production" && (typeof fr < "u" && console.warn("React-Focus-Lock: allowTextSelection is deprecated and enabled by default"), v.useEffect(function() {
80
- !c.current && typeof Oe != "string" && console.error("FocusLock: could not obtain ref to internal node");
81
- }, []));
82
- var Nr = W((t = {}, t[Me] = d && "disabled", t[ne] = sr, t), mr), Ne = F !== !0, Sr = Ne && F !== "tail", Ir = Lr([n, wr]), Pr = v.useMemo(function() {
83
- return {
84
- observed: c,
85
- shards: X,
86
- enabled: !d,
87
- active: m.current
88
- };
89
- }, [d, m.current, X, u]);
90
- return /* @__PURE__ */ v.createElement(v.Fragment, null, Ne && [
91
- /* @__PURE__ */ v.createElement("div", {
92
- key: "guard-first",
93
- "data-focus-guard": !0,
94
- tabIndex: d ? -1 : 0,
95
- style: Q
96
- }),
97
- vr ? /* @__PURE__ */ v.createElement("div", {
98
- key: "guard-nearest",
99
- "data-focus-guard": !0,
100
- tabIndex: d ? -1 : 1,
101
- style: Q
102
- }) : null
103
- ], !d && /* @__PURE__ */ v.createElement(pr, {
104
- id: hr,
105
- sideCar: Yr,
106
- observed: u,
107
- disabled: d,
108
- persistentFocus: h,
109
- crossFrame: w,
110
- autoFocus: K,
111
- whiteList: lr,
112
- shards: X,
113
- onActivation: gr,
114
- onDeactivation: Fr,
115
- returnFocus: Er,
116
- focusOptions: br,
117
- noFocusGuards: F
118
- }), /* @__PURE__ */ v.createElement(Oe, W({
119
- ref: Ir
120
- }, Nr, {
121
- className: dr,
122
- onBlur: xr,
123
- onFocus: Or
124
- }), /* @__PURE__ */ v.createElement(zr.Provider, {
125
- value: Pr
126
- }, a)), Sr && /* @__PURE__ */ v.createElement("div", {
127
- "data-focus-guard": !0,
128
- tabIndex: d ? -1 : 0,
129
- style: Q
130
- }));
131
- });
132
- ce.propTypes = process.env.NODE_ENV !== "production" ? {
133
- children: l.node,
134
- disabled: l.bool,
135
- returnFocus: l.oneOfType([l.bool, l.object, l.func]),
136
- focusOptions: l.object,
137
- noFocusGuards: l.bool,
138
- hasPositiveIndices: l.bool,
139
- allowTextSelection: l.bool,
140
- autoFocus: l.bool,
141
- persistentFocus: l.bool,
142
- crossFrame: l.bool,
143
- group: l.string,
144
- className: l.string,
145
- whiteList: l.func,
146
- shards: l.arrayOf(l.any),
147
- as: l.oneOfType([l.string, l.func, l.object]),
148
- lockProps: l.object,
149
- onActivation: l.func,
150
- onDeactivation: l.func,
151
- sideCar: l.any.isRequired
152
- } : {};
153
- function te(e, r) {
154
- return te = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(n, t) {
155
- return n.__proto__ = t, n;
156
- }, te(e, r);
157
- }
158
- function Qr(e, r) {
159
- e.prototype = Object.create(r.prototype), e.prototype.constructor = e, te(e, r);
160
- }
161
- function B(e) {
162
- "@babel/helpers - typeof";
163
- return B = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(r) {
164
- return typeof r;
165
- } : function(r) {
166
- return r && typeof Symbol == "function" && r.constructor === Symbol && r !== Symbol.prototype ? "symbol" : typeof r;
167
- }, B(e);
168
- }
169
- function Zr(e, r) {
170
- if (B(e) != "object" || !e) return e;
171
- var n = e[Symbol.toPrimitive];
172
- if (n !== void 0) {
173
- var t = n.call(e, r || "default");
174
- if (B(t) != "object") return t;
175
- throw new TypeError("@@toPrimitive must return a primitive value.");
176
- }
177
- return (r === "string" ? String : Number)(e);
178
- }
179
- function en(e) {
180
- var r = Zr(e, "string");
181
- return B(r) == "symbol" ? r : r + "";
182
- }
183
- function rn(e, r, n) {
184
- return (r = en(r)) in e ? Object.defineProperty(e, r, {
185
- value: n,
186
- enumerable: !0,
187
- configurable: !0,
188
- writable: !0
189
- }) : e[r] = n, e;
190
- }
191
- function nn(e, r) {
192
- if (process.env.NODE_ENV !== "production") {
193
- if (typeof e != "function")
194
- throw new Error("Expected reducePropsToState to be a function.");
195
- if (typeof r != "function")
196
- throw new Error("Expected handleStateChangeOnClient to be a function.");
197
- }
198
- function n(t) {
199
- return t.displayName || t.name || "Component";
200
- }
201
- return function(o) {
202
- if (process.env.NODE_ENV !== "production" && typeof o != "function")
203
- throw new Error("Expected WrappedComponent to be a React component.");
204
- var u = [], i;
205
- function c() {
206
- i = e(u.map(function(f) {
207
- return f.props;
208
- })), r(i);
209
- }
210
- var m = /* @__PURE__ */ function(f) {
211
- Qr(y, f);
212
- function y() {
213
- return f.apply(this, arguments) || this;
214
- }
215
- y.peek = function() {
216
- return i;
217
- };
218
- var s = y.prototype;
219
- return s.componentDidMount = function() {
220
- u.push(this), c();
221
- }, s.componentDidUpdate = function() {
222
- c();
223
- }, s.componentWillUnmount = function() {
224
- var p = u.indexOf(this);
225
- u.splice(p, 1), c();
226
- }, s.render = function() {
227
- return /* @__PURE__ */ Dr.createElement(o, this.props);
228
- }, y;
229
- }(_r);
230
- return rn(m, "displayName", "SideEffect(" + n(o) + ")"), m;
231
- };
232
- }
233
- var x = function(e) {
234
- for (var r = Array(e.length), n = 0; n < e.length; ++n)
235
- r[n] = e[n];
236
- return r;
237
- }, A = function(e) {
238
- return Array.isArray(e) ? e : [e];
239
- }, Be = function(e) {
240
- return Array.isArray(e) ? e[0] : e;
241
- }, tn = function(e) {
242
- if (e.nodeType !== Node.ELEMENT_NODE)
243
- return !1;
244
- var r = window.getComputedStyle(e, null);
245
- return !r || !r.getPropertyValue ? !1 : r.getPropertyValue("display") === "none" || r.getPropertyValue("visibility") === "hidden";
246
- }, Ue = function(e) {
247
- return e.parentNode && e.parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? (
248
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
249
- e.parentNode.host
250
- ) : e.parentNode;
251
- }, Ge = function(e) {
252
- return e === document || e && e.nodeType === Node.DOCUMENT_NODE;
253
- }, on = function(e) {
254
- return e.hasAttribute("inert");
255
- }, un = function(e, r) {
256
- return !e || Ge(e) || !tn(e) && !on(e) && r(Ue(e));
257
- }, He = function(e, r) {
258
- var n = e.get(r);
259
- if (n !== void 0)
260
- return n;
261
- var t = un(r, He.bind(void 0, e));
262
- return e.set(r, t), t;
263
- }, an = function(e, r) {
264
- return e && !Ge(e) ? sn(e) ? r(Ue(e)) : !1 : !0;
265
- }, je = function(e, r) {
266
- var n = e.get(r);
267
- if (n !== void 0)
268
- return n;
269
- var t = an(r, je.bind(void 0, e));
270
- return e.set(r, t), t;
271
- }, Ve = function(e) {
272
- return e.dataset;
273
- }, cn = function(e) {
274
- return e.tagName === "BUTTON";
275
- }, $e = function(e) {
276
- return e.tagName === "INPUT";
277
- }, qe = function(e) {
278
- return $e(e) && e.type === "radio";
279
- }, fn = function(e) {
280
- return !(($e(e) || cn(e)) && (e.type === "hidden" || e.disabled));
281
- }, sn = function(e) {
282
- var r = e.getAttribute(Kr);
283
- return ![!0, "true", ""].includes(r);
284
- }, fe = function(e) {
285
- var r;
286
- return !!(e && (!((r = Ve(e)) === null || r === void 0) && r.focusGuard));
287
- }, oe = function(e) {
288
- return !fe(e);
289
- }, dn = function(e) {
290
- return !!e;
291
- }, ln = function(e, r) {
292
- var n = Math.max(0, e.tabIndex), t = Math.max(0, r.tabIndex), o = n - t, u = e.index - r.index;
293
- if (o) {
294
- if (!n)
295
- return 1;
296
- if (!t)
297
- return -1;
298
- }
299
- return o || u;
300
- }, vn = function(e) {
301
- return e.tabIndex < 0 && !e.hasAttribute("tabindex") ? 0 : e.tabIndex;
302
- }, se = function(e, r, n) {
303
- return x(e).map(function(t, o) {
304
- var u = vn(t);
305
- return {
306
- node: t,
307
- index: o,
308
- tabIndex: n && u === -1 ? (t.dataset || {}).focusGuard ? 0 : -1 : u
309
- };
310
- }).filter(function(t) {
311
- return !r || t.tabIndex >= 0;
312
- }).sort(ln);
313
- }, mn = [
314
- "button:enabled",
315
- "select:enabled",
316
- "textarea:enabled",
317
- "input:enabled",
318
- // elements with explicit roles will also use explicit tabindex
319
- // '[role="button"]',
320
- "a[href]",
321
- "area[href]",
322
- "summary",
323
- "iframe",
324
- "object",
325
- "embed",
326
- "audio[controls]",
327
- "video[controls]",
328
- "[tabindex]",
329
- "[contenteditable]",
330
- "[autofocus]"
331
- ], de = mn.join(","), pn = "".concat(de, ", [data-focus-guard]"), Ke = function(e, r) {
332
- return x((e.shadowRoot || e).children).reduce(function(n, t) {
333
- return n.concat(t.matches(r ? pn : de) ? [t] : [], Ke(t));
334
- }, []);
335
- }, bn = function(e, r) {
336
- var n;
337
- return e instanceof HTMLIFrameElement && (!((n = e.contentDocument) === null || n === void 0) && n.body) ? M([e.contentDocument.body], r) : [e];
338
- }, M = function(e, r) {
339
- return e.reduce(function(n, t) {
340
- var o, u = Ke(t, r), i = (o = []).concat.apply(o, u.map(function(c) {
341
- return bn(c, r);
342
- }));
343
- return n.concat(
344
- // add all tabbables inside and within shadow DOMs in DOM order
345
- i,
346
- // add if node is tabbable itself
347
- t.parentNode ? x(t.parentNode.querySelectorAll(de)).filter(function(c) {
348
- return c === t;
349
- }) : []
350
- );
351
- }, []);
352
- }, yn = function(e) {
353
- var r = e.querySelectorAll("[".concat(qr, "]"));
354
- return x(r).map(function(n) {
355
- return M([n]);
356
- }).reduce(function(n, t) {
357
- return n.concat(t);
358
- }, []);
359
- }, le = function(e, r) {
360
- return x(e).filter(function(n) {
361
- return He(r, n);
362
- }).filter(function(n) {
363
- return fn(n);
364
- });
365
- }, Ie = function(e, r) {
366
- return r === void 0 && (r = /* @__PURE__ */ new Map()), x(e).filter(function(n) {
367
- return je(r, n);
368
- });
369
- }, ve = function(e, r, n) {
370
- return se(le(M(e, n), r), !0, n);
371
- }, U = function(e, r) {
372
- return se(le(M(e), r), !1);
373
- }, hn = function(e, r) {
374
- return le(yn(e), r);
375
- }, T = function(e, r) {
376
- return e.shadowRoot ? T(e.shadowRoot, r) : Object.getPrototypeOf(e).contains !== void 0 && Object.getPrototypeOf(e).contains.call(e, r) ? !0 : x(e.children).some(function(n) {
377
- var t;
378
- if (n instanceof HTMLIFrameElement) {
379
- var o = (t = n.contentDocument) === null || t === void 0 ? void 0 : t.body;
380
- return o ? T(o, r) : !1;
381
- }
382
- return T(n, r);
383
- });
384
- }, gn = function(e) {
385
- for (var r = /* @__PURE__ */ new Set(), n = e.length, t = 0; t < n; t += 1)
386
- for (var o = t + 1; o < n; o += 1) {
387
- var u = e[t].compareDocumentPosition(e[o]);
388
- (u & Node.DOCUMENT_POSITION_CONTAINED_BY) > 0 && r.add(o), (u & Node.DOCUMENT_POSITION_CONTAINS) > 0 && r.add(t);
389
- }
390
- return e.filter(function(i, c) {
391
- return !r.has(c);
392
- });
393
- }, Xe = function(e) {
394
- return e.parentNode ? Xe(e.parentNode) : e;
395
- }, me = function(e) {
396
- var r = A(e);
397
- return r.filter(Boolean).reduce(function(n, t) {
398
- var o = t.getAttribute(ne);
399
- return n.push.apply(n, o ? gn(x(Xe(t).querySelectorAll("[".concat(ne, '="').concat(o, '"]:not([').concat(Me, '="disabled"])')))) : [t]), n;
400
- }, []);
401
- }, Fn = function(e) {
402
- try {
403
- return e();
404
- } catch {
405
- return;
406
- }
407
- }, G = function(e) {
408
- if (e === void 0 && (e = document), !(!e || !e.activeElement)) {
409
- var r = e.activeElement;
410
- return r.shadowRoot ? G(r.shadowRoot) : r instanceof HTMLIFrameElement && Fn(function() {
411
- return r.contentWindow.document;
412
- }) ? G(r.contentWindow.document) : r;
413
- }
414
- }, En = function(e, r) {
415
- return e === r;
416
- }, On = function(e, r) {
417
- return !!x(e.querySelectorAll("iframe")).some(function(n) {
418
- return En(n, r);
419
- });
420
- }, Ye = function(e, r) {
421
- return r === void 0 && (r = G(Be(e).ownerDocument)), !r || r.dataset && r.dataset.focusGuard ? !1 : me(e).some(function(n) {
422
- return T(n, r) || On(n, r);
423
- });
424
- }, xn = function(e) {
425
- e === void 0 && (e = document);
426
- var r = G(e);
427
- return r ? x(e.querySelectorAll("[".concat($r, "]"))).some(function(n) {
428
- return T(n, r);
429
- }) : !1;
430
- }, wn = function(e, r) {
431
- return r.filter(qe).filter(function(n) {
432
- return n.name === e.name;
433
- }).filter(function(n) {
434
- return n.checked;
435
- })[0] || e;
436
- }, pe = function(e, r) {
437
- return qe(e) && e.name ? wn(e, r) : e;
438
- }, Nn = function(e) {
439
- var r = /* @__PURE__ */ new Set();
440
- return e.forEach(function(n) {
441
- return r.add(pe(n, e));
442
- }), e.filter(function(n) {
443
- return r.has(n);
444
- });
445
- }, Pe = function(e) {
446
- return e[0] && e.length > 1 ? pe(e[0], e) : e[0];
447
- }, Te = function(e, r) {
448
- return e.indexOf(pe(r, e));
449
- }, ue = "NEW_FOCUS", Sn = function(e, r, n, t, o) {
450
- var u = e.length, i = e[0], c = e[u - 1], m = fe(t);
451
- if (!(t && e.indexOf(t) >= 0)) {
452
- var f = t !== void 0 ? n.indexOf(t) : -1, y = o ? n.indexOf(o) : f, s = o ? e.indexOf(o) : -1;
453
- if (f === -1)
454
- return s !== -1 ? s : ue;
455
- if (s === -1)
456
- return ue;
457
- var a = f - y, p = n.indexOf(i), d = n.indexOf(c), b = Nn(n), F = t !== void 0 ? b.indexOf(t) : -1, O = F - (o ? b.indexOf(o) : f);
458
- if (!a && s >= 0 || r.length === 0)
459
- return s;
460
- var h = Te(e, r[0]), g = Te(e, r[r.length - 1]);
461
- if (f <= p && m && Math.abs(a) > 1)
462
- return g;
463
- if (f >= d && m && Math.abs(a) > 1)
464
- return h;
465
- if (a && Math.abs(O) > 1)
466
- return s;
467
- if (f <= p)
468
- return g;
469
- if (f > d)
470
- return h;
471
- if (a)
472
- return Math.abs(a) > 1 ? s : (u + s + a) % u;
473
- }
474
- }, In = function(e) {
475
- return function(r) {
476
- var n, t = (n = Ve(r)) === null || n === void 0 ? void 0 : n.autofocus;
477
- return (
478
- // @ts-expect-error
479
- r.autofocus || //
480
- t !== void 0 && t !== "false" || //
481
- e.indexOf(r) >= 0
482
- );
483
- };
484
- }, Ae = function(e, r, n) {
485
- var t = e.map(function(u) {
486
- var i = u.node;
487
- return i;
488
- }), o = Ie(t.filter(In(n)));
489
- return o && o.length ? Pe(o) : Pe(Ie(r));
490
- }, ae = function(e, r) {
491
- return r === void 0 && (r = []), r.push(e), e.parentNode && ae(e.parentNode.host || e.parentNode, r), r;
492
- }, Z = function(e, r) {
493
- for (var n = ae(e), t = ae(r), o = 0; o < n.length; o += 1) {
494
- var u = n[o];
495
- if (t.indexOf(u) >= 0)
496
- return u;
497
- }
498
- return !1;
499
- }, ze = function(e, r, n) {
500
- var t = A(e), o = A(r), u = t[0], i = !1;
501
- return o.filter(Boolean).forEach(function(c) {
502
- i = Z(i || c, c) || i, n.filter(Boolean).forEach(function(m) {
503
- var f = Z(u, m);
504
- f && (!i || T(f, i) ? i = f : i = Z(f, i));
505
- });
506
- }), i;
507
- }, Ce = function(e, r) {
508
- return e.reduce(function(n, t) {
509
- return n.concat(hn(t, r));
510
- }, []);
511
- }, Pn = function(e, r) {
512
- var n = /* @__PURE__ */ new Map();
513
- return r.forEach(function(t) {
514
- return n.set(t.node, t);
515
- }), e.map(function(t) {
516
- return n.get(t);
517
- }).filter(dn);
518
- }, Tn = function(e, r) {
519
- var n = G(A(e).length > 0 ? document : Be(e).ownerDocument), t = me(e).filter(oe), o = ze(n || e, e, t), u = /* @__PURE__ */ new Map(), i = U(t, u), c = i.filter(function(d) {
520
- var b = d.node;
521
- return oe(b);
522
- });
523
- if (c[0]) {
524
- var m = U([o], u).map(function(d) {
525
- var b = d.node;
526
- return b;
527
- }), f = Pn(m, c), y = f.map(function(d) {
528
- var b = d.node;
529
- return b;
530
- }), s = f.filter(function(d) {
531
- var b = d.tabIndex;
532
- return b >= 0;
533
- }).map(function(d) {
534
- var b = d.node;
535
- return b;
536
- }), a = Sn(y, s, m, n, r);
537
- if (a === ue) {
538
- var p = (
539
- // first try only tabbable, and the fallback to all focusable, as long as at least one element should be picked for focus
540
- Ae(i, s, Ce(t, u)) || Ae(i, y, Ce(t, u))
541
- );
542
- if (p)
543
- return { node: p };
544
- console.warn("focus-lock: cannot find any node to move focus into");
545
- return;
546
- }
547
- return a === void 0 ? a : f[a];
548
- }
549
- }, An = function(e) {
550
- var r = me(e).filter(oe), n = ze(e, e, r), t = se(M([n], !0), !0, !0), o = M(r, !1);
551
- return t.map(function(u) {
552
- var i = u.node, c = u.index;
553
- return {
554
- node: i,
555
- index: c,
556
- lockItem: o.indexOf(i) >= 0,
557
- guard: fe(i)
558
- };
559
- });
560
- }, be = function(e, r) {
561
- e && ("focus" in e && e.focus(r), "contentWindow" in e && e.contentWindow && e.contentWindow.focus());
562
- }, ee = 0, re = !1, Je = function(e, r, n) {
563
- n === void 0 && (n = {});
564
- var t = Tn(e, r);
565
- if (!re && t) {
566
- if (ee > 2) {
567
- console.error("FocusLock: focus-fighting detected. Only one focus management system could be active. See https://github.com/theKashey/focus-lock/#focus-fighting"), re = !0, setTimeout(function() {
568
- re = !1;
569
- }, 1);
570
- return;
571
- }
572
- ee++, be(t.node, n.focusOptions), ee--;
573
- }
574
- };
575
- function L(e) {
576
- if (!e)
577
- return null;
578
- if (typeof WeakRef > "u")
579
- return function() {
580
- return e || null;
581
- };
582
- var r = e ? new WeakRef(e) : null;
583
- return function() {
584
- return (r == null ? void 0 : r.deref()) || null;
585
- };
586
- }
587
- var Cn = function(e) {
588
- if (!e)
589
- return null;
590
- for (var r = [], n = e; n && n !== document.body; )
591
- r.push({
592
- current: L(n),
593
- parent: L(n.parentElement),
594
- left: L(n.previousElementSibling),
595
- right: L(n.nextElementSibling)
596
- }), n = n.parentElement;
597
- return {
598
- element: L(e),
599
- stack: r,
600
- ownerDocument: e.ownerDocument
601
- };
602
- }, Rn = function(e) {
603
- var r, n, t, o, u;
604
- if (e)
605
- for (var i = e.stack, c = e.ownerDocument, m = /* @__PURE__ */ new Map(), f = 0, y = i; f < y.length; f++) {
606
- var s = y[f], a = (r = s.parent) === null || r === void 0 ? void 0 : r.call(s);
607
- if (a && c.contains(a)) {
608
- for (var p = (n = s.left) === null || n === void 0 ? void 0 : n.call(s), d = s.current(), b = a.contains(d) ? d : void 0, F = (t = s.right) === null || t === void 0 ? void 0 : t.call(s), O = ve([a], m), h = (
609
- // that is element itself
610
- (u = (o = b ?? // or something in it's place
611
- (p == null ? void 0 : p.nextElementSibling)) !== null && o !== void 0 ? o : (
612
- // or somebody to the right, still close enough
613
- F
614
- )) !== null && u !== void 0 ? u : (
615
- // or somebody to the left, something?
616
- p
617
- )
618
- ); h; ) {
619
- for (var g = 0, w = O; g < w.length; g++) {
620
- var I = w[g];
621
- if (h != null && h.contains(I.node))
622
- return I.node;
623
- }
624
- h = h.nextElementSibling;
625
- }
626
- if (O.length)
627
- return O[0].node;
628
- }
629
- }
630
- }, Qe = function(e) {
631
- var r = Cn(e);
632
- return function() {
633
- return Rn(r);
634
- };
635
- }, Dn = function(e, r, n) {
636
- if (!e || !r)
637
- return console.error("no element or scope given"), {};
638
- var t = A(r);
639
- if (t.every(function(i) {
640
- return !T(i, e);
641
- }))
642
- return console.error("Active element is not contained in the scope"), {};
643
- var o = n ? ve(t, /* @__PURE__ */ new Map()) : U(t, /* @__PURE__ */ new Map()), u = o.findIndex(function(i) {
644
- var c = i.node;
645
- return c === e;
646
- });
647
- if (u !== -1)
648
- return {
649
- prev: o[u - 1],
650
- next: o[u + 1],
651
- first: o[0],
652
- last: o[o.length - 1]
653
- };
654
- }, kn = function(e, r) {
655
- var n = r ? ve(A(e), /* @__PURE__ */ new Map()) : U(A(e), /* @__PURE__ */ new Map());
656
- return {
657
- first: n[0],
658
- last: n[n.length - 1]
659
- };
660
- }, _n = function(e) {
661
- return Object.assign({
662
- scope: document.body,
663
- cycle: !0,
664
- onlyTabbable: !0
665
- }, e);
666
- }, Ze = function(e, r, n) {
667
- r === void 0 && (r = {});
668
- var t = _n(r), o = Dn(e, t.scope, t.onlyTabbable);
669
- if (o) {
670
- var u = n(o, t.cycle);
671
- u && be(u.node, t.focusOptions);
672
- }
673
- }, Mn = function(e, r) {
674
- r === void 0 && (r = {}), Ze(e, r, function(n, t) {
675
- var o = n.next, u = n.first;
676
- return o || t && u;
677
- });
678
- }, Ln = function(e, r) {
679
- r === void 0 && (r = {}), Ze(e, r, function(n, t) {
680
- var o = n.prev, u = n.last;
681
- return o || t && u;
682
- });
683
- }, er = function(e, r, n) {
684
- var t, o = kn(e, (t = r.onlyTabbable) !== null && t !== void 0 ? t : !0), u = o[n];
685
- u && be(u.node, r.focusOptions);
686
- }, Wn = function(e, r) {
687
- r === void 0 && (r = {}), er(e, r, "first");
688
- }, Bn = function(e, r) {
689
- r === void 0 && (r = {}), er(e, r, "last");
690
- };
691
- function ye(e) {
692
- setTimeout(e, 1);
693
- }
694
- var Un = function(r) {
695
- return r && "current" in r ? r.current : r;
696
- }, rr = function() {
697
- return document && document.activeElement === document.body;
698
- }, Gn = function() {
699
- return rr() || xn();
700
- }, k = null, E = null, Re = function() {
701
- return null;
702
- }, _ = null, H = !1, he = !1, Hn = function() {
703
- return !0;
704
- }, jn = function(r) {
705
- return (k.whiteList || Hn)(r);
706
- }, Vn = function(r, n) {
707
- _ = {
708
- observerNode: r,
709
- portaledElement: n
710
- };
711
- }, $n = function(r) {
712
- return _ && _.portaledElement === r;
713
- };
714
- function De(e, r, n, t) {
715
- var o = null, u = e;
716
- do {
717
- var i = t[u];
718
- if (i.guard)
719
- i.node.dataset.focusAutoGuard && (o = i);
720
- else if (i.lockItem) {
721
- if (u !== e)
722
- return;
723
- o = null;
724
- } else
725
- break;
726
- } while ((u += n) !== r);
727
- o && (o.node.tabIndex = 0);
728
- }
729
- var qn = function(r) {
730
- return r ? !!H : H === "meanwhile";
731
- }, Kn = function e(r, n, t) {
732
- return n && (n.host === r && (!n.activeElement || t.contains(n.activeElement)) || n.parentNode && e(r, n.parentNode, t));
733
- }, Xn = function(r, n) {
734
- return n.some(function(t) {
735
- return Kn(r, t, t);
736
- });
737
- }, nr = function(r) {
738
- return U(r, /* @__PURE__ */ new Map());
739
- }, Yn = function(r) {
740
- return !nr([r.parentNode]).some(function(n) {
741
- return n.node === r;
742
- });
743
- }, q = function() {
744
- var r = !1;
745
- if (k) {
746
- var n = k, t = n.observed, o = n.persistentFocus, u = n.autoFocus, i = n.shards, c = n.crossFrame, m = n.focusOptions, f = n.noFocusGuards, y = t || _ && _.portaledElement;
747
- if (rr() && E && (!document.body.contains(E) || Yn(E))) {
748
- E = null;
749
- var s = Re();
750
- s && s.focus();
751
- }
752
- var a = document && document.activeElement;
753
- if (y) {
754
- var p = [y].concat(i.map(Un).filter(Boolean)), d = function() {
755
- if (!qn(c) || !f || !E || he)
756
- return !1;
757
- var g = nr(p), w = g.findIndex(function(I) {
758
- var K = I.node;
759
- return K === E;
760
- });
761
- return w === 0 || w === g.length - 1;
762
- };
763
- if ((!a || jn(a)) && (o || d() || !Gn() || !E && u) && (y && !(Ye(p) || a && Xn(a, p) || $n(a)) && (document && !E && a && !u ? (a.blur && a.blur(), document.body.focus()) : (r = Je(p, E, {
764
- focusOptions: m
765
- }), _ = {})), H = !1, E = document && document.activeElement, Re = Qe(E)), document && a !== document.activeElement && document.querySelector("[data-focus-auto-guard]")) {
766
- var b = document && document.activeElement, F = An(p), O = F.map(function(h) {
767
- var g = h.node;
768
- return g;
769
- }).indexOf(b);
770
- O > -1 && (F.filter(function(h) {
771
- var g = h.guard, w = h.node;
772
- return g && w.dataset.focusAutoGuard;
773
- }).forEach(function(h) {
774
- var g = h.node;
775
- return g.removeAttribute("tabIndex");
776
- }), De(O, F.length, 1, F), De(O, -1, -1, F));
777
- }
778
- }
779
- }
780
- return r;
781
- }, tr = function(r) {
782
- q() && r && (r.stopPropagation(), r.preventDefault());
783
- }, ge = function() {
784
- return ye(q);
785
- }, zn = function(r) {
786
- var n = r.target, t = r.currentTarget;
787
- t.contains(n) || Vn(t, n);
788
- }, Jn = function() {
789
- return null;
790
- };
791
- process.env.NODE_ENV !== "production" && ke.node.isRequired;
792
- var or = function() {
793
- he = !0;
794
- }, ur = function() {
795
- he = !1, H = "just", ye(function() {
796
- H = "meanwhile";
797
- });
798
- }, Qn = function() {
799
- document.addEventListener("focusin", tr), document.addEventListener("focusout", ge), window.addEventListener("focus", or), window.addEventListener("blur", ur);
800
- }, Zn = function() {
801
- document.removeEventListener("focusin", tr), document.removeEventListener("focusout", ge), window.removeEventListener("focus", or), window.removeEventListener("blur", ur);
802
- };
803
- function et(e) {
804
- return e.filter(function(r) {
805
- var n = r.disabled;
806
- return !n;
807
- });
808
- }
809
- var ar = {
810
- moveFocusInside: Je,
811
- focusInside: Ye,
812
- focusNextElement: Mn,
813
- focusPrevElement: Ln,
814
- focusFirstElement: Wn,
815
- focusLastElement: Bn,
816
- captureFocusRestore: Qe
817
- };
818
- function rt(e) {
819
- var r = e.slice(-1)[0];
820
- r && !k && Qn();
821
- var n = k, t = n && r && r.id === n.id;
822
- k = r, n && !t && (n.onDeactivation(), e.filter(function(o) {
823
- var u = o.id;
824
- return u === n.id;
825
- }).length || n.returnFocus(!r)), r ? (E = null, (!t || n.observed !== r.observed) && r.onActivation(ar), q(), ye(q)) : (Zn(), E = null);
826
- }
827
- Le.assignSyncMedium(zn);
828
- We.assignMedium(ge);
829
- Xr.assignMedium(function(e) {
830
- return e(ar);
831
- });
832
- const nt = nn(et, rt)(Jn);
833
- var ir = /* @__PURE__ */ v.forwardRef(function(r, n) {
834
- return /* @__PURE__ */ v.createElement(ce, W({
835
- sideCar: nt,
836
- ref: n
837
- }, r));
838
- }), cr = ce.propTypes || {};
839
- cr.sideCar;
840
- var tt = Vr(cr, ["sideCar"]);
841
- ir.propTypes = process.env.NODE_ENV !== "production" ? tt : {};
842
- const ot = ({
843
- children: e,
844
- theme: r,
845
- className: n,
846
- buttonCloseClassName: t
847
- }) => {
848
- const { content: o, onClose: u, closeBtnRef: i } = _e(), { theme: c } = Gr(), m = V.toArray(e).find(
849
- (a) => $(a) && a.type === S.Header
850
- ), f = V.toArray(e).find(
851
- (a) => $(a) && a.type === S.Body
852
- ), y = V.toArray(e).find(
853
- (a) => $(a) && a.type === S.Footer
854
- ), s = V.toArray(e).filter(
855
- (a) => !$(a) || ![S.Header, S.Body, S.Footer].includes(
856
- a.type
857
- )
858
- );
859
- return /* @__PURE__ */ D(ir, { returnFocus: !0, children: /* @__PURE__ */ D(Wr, { children: /* @__PURE__ */ J("div", { className: "fixed inset-0 grid place-content-center", children: [
860
- /* @__PURE__ */ D(
861
- "div",
862
- {
863
- className: "absolute inset-0 bg-black opacity-75",
864
- onClick: u
865
- }
866
- ),
867
- /* @__PURE__ */ J(
868
- "div",
869
- {
870
- className: Hr({
871
- className: n,
872
- theme: r ?? c
873
- }),
874
- role: "dialog",
875
- "aria-modal": "true",
876
- children: [
877
- m,
878
- /* @__PURE__ */ J(
879
- "button",
880
- {
881
- ref: i,
882
- className: jr({
883
- className: t,
884
- theme: r ?? c
885
- }),
886
- onClick: u,
887
- children: [
888
- /* @__PURE__ */ D(Br, {}),
889
- /* @__PURE__ */ D(Ur, { children: "Dismiss modal" })
890
- ]
891
- }
892
- ),
893
- f ?? s ?? o,
894
- y
895
- ]
896
- }
897
- )
898
- ] }) }) });
899
- }, S = ({ ...e }) => {
900
- const { isOpen: r } = _e();
901
- return r ? Tr.createPortal(/* @__PURE__ */ D(ot, { ...e }), document.body) : null;
902
- };
903
- S.Header = Rr;
904
- S.Body = Ar;
905
- S.Footer = Cr;
906
- export {
907
- S as M,
908
- ot as W
909
- };