@lazar-ui/kit 0.1.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.
- package/README.md +182 -0
- package/dist/Overlay-RmiBtqDR.mjs +1011 -0
- package/dist/accordion.css +1 -0
- package/dist/accordion.d.ts +53 -0
- package/dist/accordion.js +48 -0
- package/dist/alert.css +1 -0
- package/dist/alert.d.ts +33 -0
- package/dist/alert.js +20 -0
- package/dist/avatar.css +1 -0
- package/dist/avatar.d.ts +34 -0
- package/dist/avatar.js +41 -0
- package/dist/badge.css +1 -0
- package/dist/badge.d.ts +33 -0
- package/dist/badge.js +23 -0
- package/dist/breadcrumbs.css +1 -0
- package/dist/breadcrumbs.d.ts +80 -0
- package/dist/breadcrumbs.js +63 -0
- package/dist/button.css +1 -0
- package/dist/button.d.ts +66 -0
- package/dist/button.js +46 -0
- package/dist/camelCase-PtIYufW8.mjs +528 -0
- package/dist/card.css +1 -0
- package/dist/card.d.ts +42 -0
- package/dist/card.js +24 -0
- package/dist/checkbox.css +1 -0
- package/dist/checkbox.d.ts +41 -0
- package/dist/checkbox.js +42 -0
- package/dist/clsx-OuTLNxxd.mjs +16 -0
- package/dist/config-provider.d.ts +78 -0
- package/dist/config-provider.js +14 -0
- package/dist/css/palettes/indigo.css +104 -0
- package/dist/css/palettes/monochrome.css +104 -0
- package/dist/css/semantic.css +113 -0
- package/dist/dialog.css +1 -0
- package/dist/dialog.d.ts +91 -0
- package/dist/dialog.js +75 -0
- package/dist/drawer.css +1 -0
- package/dist/drawer.d.ts +128 -0
- package/dist/drawer.js +106 -0
- package/dist/empty-state.css +1 -0
- package/dist/empty-state.d.ts +33 -0
- package/dist/empty-state.js +52 -0
- package/dist/error-boundary.css +1 -0
- package/dist/error-boundary.d.ts +55 -0
- package/dist/error-boundary.js +37 -0
- package/dist/flex.css +1 -0
- package/dist/flex.d.ts +68 -0
- package/dist/flex.js +73 -0
- package/dist/form-field.css +1 -0
- package/dist/form-field.d.ts +27 -0
- package/dist/form-field.js +22 -0
- package/dist/getComponentSlots-DwAYUFNk.mjs +16 -0
- package/dist/getVariantClassName-D7Nhpuec.mjs +8 -0
- package/dist/input.css +1 -0
- package/dist/input.d.ts +39 -0
- package/dist/input.js +146 -0
- package/dist/isValidReactNode-CmYwTWCE.mjs +18 -0
- package/dist/menu.css +1 -0
- package/dist/menu.d.ts +94 -0
- package/dist/menu.js +135 -0
- package/dist/pagination.css +1 -0
- package/dist/pagination.d.ts +40 -0
- package/dist/pagination.js +74 -0
- package/dist/popover.css +1 -0
- package/dist/popover.d.ts +54 -0
- package/dist/popover.js +65 -0
- package/dist/select.css +1 -0
- package/dist/select.d.ts +64 -0
- package/dist/select.js +170 -0
- package/dist/separator.css +1 -0
- package/dist/separator.d.ts +25 -0
- package/dist/separator.js +24 -0
- package/dist/skeleton.css +1 -0
- package/dist/skeleton.d.ts +38 -0
- package/dist/skeleton.js +27 -0
- package/dist/spinner.css +1 -0
- package/dist/spinner.d.ts +31 -0
- package/dist/spinner.js +29 -0
- package/dist/switch.css +1 -0
- package/dist/switch.d.ts +44 -0
- package/dist/switch.js +37 -0
- package/dist/table.css +1 -0
- package/dist/table.d.ts +60 -0
- package/dist/table.js +40 -0
- package/dist/tabs.css +1 -0
- package/dist/tabs.d.ts +69 -0
- package/dist/tabs.js +79 -0
- package/dist/textarea.css +1 -0
- package/dist/textarea.d.ts +53 -0
- package/dist/textarea.js +46 -0
- package/dist/tooltip.css +1 -0
- package/dist/tooltip.d.ts +38 -0
- package/dist/tooltip.js +99 -0
- package/dist/useLocale-D2Z0JH0l.mjs +70 -0
- package/dist/useModalOverlay-D5Bs9FCB.mjs +486 -0
- package/dist/useOverlayPosition-DVu1Qziq.mjs +451 -0
- package/dist/useOverlayTriggerState-BIo1Jcba.mjs +221 -0
- package/dist/utils.d.ts +58 -0
- package/dist/utils.js +18 -0
- package/package.json +76 -0
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
import { l as N, n as ee, p as J, h as g, $ as P, g as te, o as ne, a as oe, s as D, b as k, q as K, e as re, c as F } from "./Overlay-RmiBtqDR.mjs";
|
|
2
|
+
import { useState as X, useRef as E, useCallback as Y, useEffect as C } from "react";
|
|
3
|
+
import { $ as le } from "./useOverlayTriggerState-BIo1Jcba.mjs";
|
|
4
|
+
import { c as ae } from "./clsx-OuTLNxxd.mjs";
|
|
5
|
+
function _(...t) {
|
|
6
|
+
return (...e) => {
|
|
7
|
+
for (let n of t) typeof n == "function" && n(...e);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function ie(t) {
|
|
11
|
+
let [e, n] = X(t), r = E(e), o = E(null), a = E(() => {
|
|
12
|
+
if (!o.current) return;
|
|
13
|
+
let u = o.current.next();
|
|
14
|
+
if (u.done) {
|
|
15
|
+
o.current = null;
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
r.current === u.value ? a.current() : n(u.value);
|
|
19
|
+
});
|
|
20
|
+
N(() => {
|
|
21
|
+
r.current = e, o.current && a.current();
|
|
22
|
+
});
|
|
23
|
+
let l = Y((u) => {
|
|
24
|
+
o.current = u(r.current), a.current();
|
|
25
|
+
}, [
|
|
26
|
+
a
|
|
27
|
+
]);
|
|
28
|
+
return [
|
|
29
|
+
e,
|
|
30
|
+
l
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
let ce = !!(typeof window < "u" && window.document && window.document.createElement), w = /* @__PURE__ */ new Map(), x;
|
|
34
|
+
typeof FinalizationRegistry < "u" && (x = new FinalizationRegistry((t) => {
|
|
35
|
+
w.delete(t);
|
|
36
|
+
}));
|
|
37
|
+
function fe(t) {
|
|
38
|
+
let [e, n] = X(t), r = E(null), o = ee(e), a = E(null);
|
|
39
|
+
if (x && x.register(a, o), ce) {
|
|
40
|
+
const l = w.get(o);
|
|
41
|
+
l && !l.includes(r) ? l.push(r) : w.set(o, [
|
|
42
|
+
r
|
|
43
|
+
]);
|
|
44
|
+
}
|
|
45
|
+
return N(() => {
|
|
46
|
+
let l = o;
|
|
47
|
+
return () => {
|
|
48
|
+
x && x.unregister(a), w.delete(l);
|
|
49
|
+
};
|
|
50
|
+
}, [
|
|
51
|
+
o
|
|
52
|
+
]), C(() => {
|
|
53
|
+
let l = r.current;
|
|
54
|
+
return l && n(l), () => {
|
|
55
|
+
l && (r.current = null);
|
|
56
|
+
};
|
|
57
|
+
}), o;
|
|
58
|
+
}
|
|
59
|
+
function ue(t, e) {
|
|
60
|
+
if (t === e) return t;
|
|
61
|
+
let n = w.get(t);
|
|
62
|
+
if (n)
|
|
63
|
+
return n.forEach((o) => o.current = e), e;
|
|
64
|
+
let r = w.get(e);
|
|
65
|
+
return r ? (r.forEach((o) => o.current = t), t) : e;
|
|
66
|
+
}
|
|
67
|
+
function se(t = []) {
|
|
68
|
+
let e = fe(), [n, r] = ie(e), o = Y(() => {
|
|
69
|
+
r(function* () {
|
|
70
|
+
yield e, yield document.getElementById(e) ? e : void 0;
|
|
71
|
+
});
|
|
72
|
+
}, [
|
|
73
|
+
e,
|
|
74
|
+
r
|
|
75
|
+
]);
|
|
76
|
+
return N(o, [
|
|
77
|
+
e,
|
|
78
|
+
o,
|
|
79
|
+
...t
|
|
80
|
+
]), n;
|
|
81
|
+
}
|
|
82
|
+
function de(...t) {
|
|
83
|
+
return t.length === 1 && t[0] ? t[0] : (e) => {
|
|
84
|
+
let n = !1;
|
|
85
|
+
const r = t.map((o) => {
|
|
86
|
+
const a = U(o, e);
|
|
87
|
+
return n ||= typeof a == "function", a;
|
|
88
|
+
});
|
|
89
|
+
if (n) return () => {
|
|
90
|
+
r.forEach((o, a) => {
|
|
91
|
+
typeof o == "function" ? o() : U(t[a], null);
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function U(t, e) {
|
|
97
|
+
if (typeof t == "function") return t(e);
|
|
98
|
+
t != null && (t.current = e);
|
|
99
|
+
}
|
|
100
|
+
function be(...t) {
|
|
101
|
+
let e = {
|
|
102
|
+
...t[0]
|
|
103
|
+
};
|
|
104
|
+
for (let n = 1; n < t.length; n++) {
|
|
105
|
+
let r = t[n];
|
|
106
|
+
for (let o in r) {
|
|
107
|
+
let a = e[o], l = r[o];
|
|
108
|
+
typeof a == "function" && typeof l == "function" && // This is a lot faster than a regex.
|
|
109
|
+
o[0] === "o" && o[1] === "n" && o.charCodeAt(2) >= /* 'A' */
|
|
110
|
+
65 && o.charCodeAt(2) <= /* 'Z' */
|
|
111
|
+
90 ? e[o] = _(a, l) : (o === "className" || o === "UNSAFE_className") && typeof a == "string" && typeof l == "string" ? e[o] = ae(a, l) : o === "id" && a && l ? e.id = ue(a, l) : o === "ref" && a && l ? e.ref = de(a, l) : e[o] = l !== void 0 ? l : a;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return e;
|
|
115
|
+
}
|
|
116
|
+
const $e = /* @__PURE__ */ new Set([
|
|
117
|
+
"checkbox",
|
|
118
|
+
"radio",
|
|
119
|
+
"range",
|
|
120
|
+
"color",
|
|
121
|
+
"file",
|
|
122
|
+
"image",
|
|
123
|
+
"button",
|
|
124
|
+
"submit",
|
|
125
|
+
"reset"
|
|
126
|
+
]);
|
|
127
|
+
function I(t) {
|
|
128
|
+
return t instanceof HTMLInputElement && !$e.has(t.type) || t instanceof HTMLTextAreaElement || t instanceof HTMLElement && t.isContentEditable;
|
|
129
|
+
}
|
|
130
|
+
const pe = /* @__PURE__ */ new Set([
|
|
131
|
+
"id"
|
|
132
|
+
]), me = /* @__PURE__ */ new Set([
|
|
133
|
+
"aria-label",
|
|
134
|
+
"aria-labelledby",
|
|
135
|
+
"aria-describedby",
|
|
136
|
+
"aria-details"
|
|
137
|
+
]), he = /* @__PURE__ */ new Set([
|
|
138
|
+
"href",
|
|
139
|
+
"hrefLang",
|
|
140
|
+
"target",
|
|
141
|
+
"rel",
|
|
142
|
+
"download",
|
|
143
|
+
"ping",
|
|
144
|
+
"referrerPolicy"
|
|
145
|
+
]), ve = /* @__PURE__ */ new Set([
|
|
146
|
+
"dir",
|
|
147
|
+
"lang",
|
|
148
|
+
"hidden",
|
|
149
|
+
"inert",
|
|
150
|
+
"translate"
|
|
151
|
+
]), G = /* @__PURE__ */ new Set([
|
|
152
|
+
"onClick",
|
|
153
|
+
"onAuxClick",
|
|
154
|
+
"onContextMenu",
|
|
155
|
+
"onDoubleClick",
|
|
156
|
+
"onMouseDown",
|
|
157
|
+
"onMouseEnter",
|
|
158
|
+
"onMouseLeave",
|
|
159
|
+
"onMouseMove",
|
|
160
|
+
"onMouseOut",
|
|
161
|
+
"onMouseOver",
|
|
162
|
+
"onMouseUp",
|
|
163
|
+
"onTouchCancel",
|
|
164
|
+
"onTouchEnd",
|
|
165
|
+
"onTouchMove",
|
|
166
|
+
"onTouchStart",
|
|
167
|
+
"onPointerDown",
|
|
168
|
+
"onPointerMove",
|
|
169
|
+
"onPointerUp",
|
|
170
|
+
"onPointerCancel",
|
|
171
|
+
"onPointerEnter",
|
|
172
|
+
"onPointerLeave",
|
|
173
|
+
"onPointerOver",
|
|
174
|
+
"onPointerOut",
|
|
175
|
+
"onGotPointerCapture",
|
|
176
|
+
"onLostPointerCapture",
|
|
177
|
+
"onScroll",
|
|
178
|
+
"onWheel",
|
|
179
|
+
"onAnimationStart",
|
|
180
|
+
"onAnimationEnd",
|
|
181
|
+
"onAnimationIteration",
|
|
182
|
+
"onTransitionCancel",
|
|
183
|
+
"onTransitionEnd",
|
|
184
|
+
"onTransitionRun",
|
|
185
|
+
"onTransitionStart"
|
|
186
|
+
]), Ee = /^(data-.*)$/;
|
|
187
|
+
function we(t, e = {}) {
|
|
188
|
+
let { labelable: n, isLink: r, global: o, events: a = o, propNames: l } = e, u = {};
|
|
189
|
+
for (const d in t) Object.prototype.hasOwnProperty.call(t, d) && (pe.has(d) || n && me.has(d) || r && he.has(d) || o && ve.has(d) || a && (G.has(d) || d.endsWith("Capture") && G.has(d.slice(0, -7))) || l?.has(d) || Ee.test(d)) && (u[d] = t[d]);
|
|
190
|
+
return u;
|
|
191
|
+
}
|
|
192
|
+
function q(t) {
|
|
193
|
+
return t?.defaultView?.__webpack_nonce__ || globalThis.__webpack_nonce__ || void 0;
|
|
194
|
+
}
|
|
195
|
+
let H = /* @__PURE__ */ new WeakMap();
|
|
196
|
+
function ge(t) {
|
|
197
|
+
let e = t ?? (typeof document < "u" ? document : void 0);
|
|
198
|
+
if (!e) return q(e);
|
|
199
|
+
if (H.has(e)) return H.get(e);
|
|
200
|
+
let n = e.querySelector('meta[property="csp-nonce"]'), r = n && n instanceof J(n).HTMLMetaElement && (n.nonce || n.content) || q(e) || void 0;
|
|
201
|
+
return r !== void 0 && H.set(e, r), r;
|
|
202
|
+
}
|
|
203
|
+
function W(t, e) {
|
|
204
|
+
if (!t) return !1;
|
|
205
|
+
let n = window.getComputedStyle(t), r = document.scrollingElement || document.documentElement, o = /(auto|scroll)/.test(n.overflow + n.overflowX + n.overflowY);
|
|
206
|
+
return t === r && n.overflow !== "hidden" && (o = !0), o && e && (o = t.scrollHeight !== t.clientHeight || t.scrollWidth !== t.clientWidth), o;
|
|
207
|
+
}
|
|
208
|
+
function Q(t, e) {
|
|
209
|
+
let n = t;
|
|
210
|
+
for (W(n, e) && (n = n.parentElement); n && !W(n, e); ) n = n.parentElement;
|
|
211
|
+
return n || document.scrollingElement || document.documentElement;
|
|
212
|
+
}
|
|
213
|
+
const ye = typeof HTMLElement < "u" && "inert" in HTMLElement.prototype;
|
|
214
|
+
function j(t) {
|
|
215
|
+
return t.dataset.liveAnnouncer === "true" || t.dataset.reactAriaTopLayer !== void 0;
|
|
216
|
+
}
|
|
217
|
+
let y = /* @__PURE__ */ new WeakMap(), m = [];
|
|
218
|
+
function xe(t, e) {
|
|
219
|
+
let n = J(t?.[0]), r = e instanceof n.Element ? {
|
|
220
|
+
root: e
|
|
221
|
+
} : e, o = r?.root ?? document.body, a = r?.shouldUseInert && ye, l = new Set(t), u = /* @__PURE__ */ new Set(), d = (i) => a && i instanceof n.HTMLElement ? i.inert : i.getAttribute("aria-hidden") === "true", M = (i, c) => {
|
|
222
|
+
a && i instanceof n.HTMLElement ? i.inert = c : c ? i.setAttribute("aria-hidden", "true") : (i.removeAttribute("aria-hidden"), i instanceof n.HTMLElement && (i.inert = !1));
|
|
223
|
+
}, $ = /* @__PURE__ */ new Set();
|
|
224
|
+
if (g())
|
|
225
|
+
for (let i of t) {
|
|
226
|
+
let c = i;
|
|
227
|
+
for (; c && c !== o; ) {
|
|
228
|
+
let b = c.getRootNode();
|
|
229
|
+
"shadowRoot" in b && $.add(b.shadowRoot), c = b.parentNode;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
let s = (i) => {
|
|
233
|
+
for (let f of i.querySelectorAll("[data-live-announcer], [data-react-aria-top-layer]")) l.add(f);
|
|
234
|
+
let c = (f) => {
|
|
235
|
+
if (u.has(f) || l.has(f) || f.parentElement && u.has(f.parentElement) && f.parentElement.getAttribute("role") !== "row") return NodeFilter.FILTER_REJECT;
|
|
236
|
+
for (let Z of l)
|
|
237
|
+
if (P(f, Z)) return NodeFilter.FILTER_SKIP;
|
|
238
|
+
return NodeFilter.FILTER_ACCEPT;
|
|
239
|
+
}, b = te(ne(i), i, NodeFilter.SHOW_ELEMENT, {
|
|
240
|
+
acceptNode: c
|
|
241
|
+
}), v = c(i);
|
|
242
|
+
if (v === NodeFilter.FILTER_ACCEPT && p(i), v !== NodeFilter.FILTER_REJECT) {
|
|
243
|
+
let f = b.nextNode();
|
|
244
|
+
for (; f != null; )
|
|
245
|
+
p(f), f = b.nextNode();
|
|
246
|
+
}
|
|
247
|
+
}, p = (i) => {
|
|
248
|
+
let c = y.get(i) ?? 0;
|
|
249
|
+
d(i) && c === 0 || (c === 0 && M(i, !0), u.add(i), y.set(i, c + 1));
|
|
250
|
+
};
|
|
251
|
+
m.length && m[m.length - 1].disconnect(), s(o);
|
|
252
|
+
let h = new MutationObserver((i) => {
|
|
253
|
+
for (let c of i)
|
|
254
|
+
if (c.type === "childList") {
|
|
255
|
+
if (c.target.isConnected && ![
|
|
256
|
+
...l,
|
|
257
|
+
...u
|
|
258
|
+
].some((b) => P(b, c.target))) for (let b of c.addedNodes)
|
|
259
|
+
(b instanceof HTMLElement || b instanceof SVGElement) && j(b) ? l.add(b) : b instanceof Element && s(b);
|
|
260
|
+
if (g()) {
|
|
261
|
+
for (let b of $) if (!b.isConnected) {
|
|
262
|
+
h.disconnect();
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
h.observe(o, {
|
|
269
|
+
childList: !0,
|
|
270
|
+
subtree: !0
|
|
271
|
+
});
|
|
272
|
+
let V = /* @__PURE__ */ new Set();
|
|
273
|
+
if (g()) for (let i of $) {
|
|
274
|
+
let c = new MutationObserver((b) => {
|
|
275
|
+
for (let v of b)
|
|
276
|
+
if (v.type === "childList") {
|
|
277
|
+
if (v.target.isConnected && ![
|
|
278
|
+
...l,
|
|
279
|
+
...u
|
|
280
|
+
].some((f) => P(f, v.target))) for (let f of v.addedNodes)
|
|
281
|
+
(f instanceof HTMLElement || f instanceof SVGElement) && j(f) ? l.add(f) : f instanceof Element && s(f);
|
|
282
|
+
if (g()) {
|
|
283
|
+
for (let f of $) if (!f.isConnected) {
|
|
284
|
+
h.disconnect();
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
c.observe(i, {
|
|
291
|
+
childList: !0,
|
|
292
|
+
subtree: !0
|
|
293
|
+
}), V.add(c);
|
|
294
|
+
}
|
|
295
|
+
let R = {
|
|
296
|
+
visibleNodes: l,
|
|
297
|
+
hiddenNodes: u,
|
|
298
|
+
observe() {
|
|
299
|
+
h.observe(o, {
|
|
300
|
+
childList: !0,
|
|
301
|
+
subtree: !0
|
|
302
|
+
});
|
|
303
|
+
},
|
|
304
|
+
disconnect() {
|
|
305
|
+
h.disconnect();
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
return m.push(R), () => {
|
|
309
|
+
if (h.disconnect(), g()) for (let i of V) i.disconnect();
|
|
310
|
+
for (let i of u) {
|
|
311
|
+
let c = y.get(i);
|
|
312
|
+
c != null && (c === 1 ? (M(i, !1), y.delete(i)) : y.set(i, c - 1));
|
|
313
|
+
}
|
|
314
|
+
R === m[m.length - 1] ? (m.pop(), m.length && m[m.length - 1].observe()) : m.splice(m.indexOf(R), 1);
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function Pe(t, e) {
|
|
318
|
+
let { role: n = "dialog" } = t, r = se();
|
|
319
|
+
r = t["aria-label"] ? void 0 : r;
|
|
320
|
+
let o = E(!1);
|
|
321
|
+
C(() => {
|
|
322
|
+
if (e.current && !oe(e.current)) {
|
|
323
|
+
D(e.current);
|
|
324
|
+
let l = setTimeout(() => {
|
|
325
|
+
(k() === e.current || k() === document.body) && (o.current = !0, e.current && (e.current.blur(), D(e.current)), o.current = !1);
|
|
326
|
+
}, 500);
|
|
327
|
+
return () => {
|
|
328
|
+
clearTimeout(l);
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
}, [
|
|
332
|
+
e
|
|
333
|
+
]), K();
|
|
334
|
+
let a = E(!1);
|
|
335
|
+
return C(() => {
|
|
336
|
+
if (process.env.NODE_ENV !== "production" && !a.current && e.current) {
|
|
337
|
+
let l = e.current, u = l.hasAttribute("aria-label"), d = l.hasAttribute("aria-labelledby");
|
|
338
|
+
!u && !d && (console.warn("A dialog must have a title for accessibility. Either provide an aria-label or aria-labelledby prop, or render a heading element inside the dialog."), a.current = !0);
|
|
339
|
+
}
|
|
340
|
+
}), {
|
|
341
|
+
dialogProps: {
|
|
342
|
+
...we(t, {
|
|
343
|
+
labelable: !0
|
|
344
|
+
}),
|
|
345
|
+
role: n,
|
|
346
|
+
tabIndex: -1,
|
|
347
|
+
"aria-labelledby": t["aria-labelledby"] || r,
|
|
348
|
+
// Prevent blur events from reaching useOverlay, which may cause
|
|
349
|
+
// popovers to close. Since focus is contained within the dialog,
|
|
350
|
+
// we don't want this to occur due to the above useEffect.
|
|
351
|
+
onBlur: (l) => {
|
|
352
|
+
o.current && l.stopPropagation();
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
titleProps: {
|
|
356
|
+
id: r
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
const T = typeof document < "u" && window.visualViewport;
|
|
361
|
+
let S = 0, O;
|
|
362
|
+
function Te(t = {}) {
|
|
363
|
+
let { isDisabled: e } = t;
|
|
364
|
+
N(() => {
|
|
365
|
+
if (!e)
|
|
366
|
+
return S++, S === 1 && (re() ? O = Se() : O = Me()), () => {
|
|
367
|
+
S--, S === 0 && O();
|
|
368
|
+
};
|
|
369
|
+
}, [
|
|
370
|
+
e
|
|
371
|
+
]);
|
|
372
|
+
}
|
|
373
|
+
function Me() {
|
|
374
|
+
let t = window.innerWidth - document.documentElement.clientWidth;
|
|
375
|
+
return _(t > 0 && // Use scrollbar-gutter when supported because it also works for fixed positioned elements.
|
|
376
|
+
("scrollbarGutter" in document.documentElement.style ? L(document.documentElement, "scrollbarGutter", "stable") : L(document.documentElement, "paddingRight", `${t}px`)), L(document.documentElement, "overflow", "hidden"));
|
|
377
|
+
}
|
|
378
|
+
function Se() {
|
|
379
|
+
let t = L(document.documentElement, "overflow", "hidden"), e, n = !1, r = ($) => {
|
|
380
|
+
let s = F($);
|
|
381
|
+
e = W(s) ? s : Q(s, !0), n = !1;
|
|
382
|
+
let p = s.ownerDocument.defaultView.getSelection();
|
|
383
|
+
p && !p.isCollapsed && p.containsNode(s, !0) && (n = !0), $.composedPath().some((h) => h instanceof HTMLInputElement && h.type === "range") && (n = !0), "selectionStart" in s && "selectionEnd" in s && s.selectionStart < s.selectionEnd && s.ownerDocument.activeElement === s && (n = !0);
|
|
384
|
+
}, o = document.createElement("style"), a = ge();
|
|
385
|
+
a && (o.nonce = a), o.textContent = `
|
|
386
|
+
@layer {
|
|
387
|
+
* {
|
|
388
|
+
overscroll-behavior: contain;
|
|
389
|
+
}
|
|
390
|
+
}`.trim(), document.head.prepend(o);
|
|
391
|
+
let l = ($) => {
|
|
392
|
+
if (!($.touches.length === 2 || n)) {
|
|
393
|
+
if (!e || e === document.documentElement || e === document.body) {
|
|
394
|
+
$.preventDefault();
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
e.scrollHeight === e.clientHeight && e.scrollWidth === e.clientWidth && $.preventDefault();
|
|
398
|
+
}
|
|
399
|
+
}, u = ($) => {
|
|
400
|
+
let s = F($), p = $.relatedTarget;
|
|
401
|
+
p && I(p) ? (p.focus({
|
|
402
|
+
preventScroll: !0
|
|
403
|
+
}), z(p, I(s))) : p || s.parentElement?.closest("[tabindex]")?.focus({
|
|
404
|
+
preventScroll: !0
|
|
405
|
+
});
|
|
406
|
+
}, d = HTMLElement.prototype.focus;
|
|
407
|
+
HTMLElement.prototype.focus = function($) {
|
|
408
|
+
let s = k(), p = s != null && I(s);
|
|
409
|
+
d.call(this, {
|
|
410
|
+
...$,
|
|
411
|
+
preventScroll: !0
|
|
412
|
+
}), (!$ || !$.preventScroll) && z(this, p);
|
|
413
|
+
};
|
|
414
|
+
let M = _(A(document, "touchstart", r, {
|
|
415
|
+
passive: !1,
|
|
416
|
+
capture: !0
|
|
417
|
+
}), A(document, "touchmove", l, {
|
|
418
|
+
passive: !1,
|
|
419
|
+
capture: !0
|
|
420
|
+
}), A(document, "blur", u, !0));
|
|
421
|
+
return () => {
|
|
422
|
+
t(), M(), o.remove(), HTMLElement.prototype.focus = d;
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
function L(t, e, n) {
|
|
426
|
+
let r = t.style[e];
|
|
427
|
+
return t.style[e] = n, () => {
|
|
428
|
+
t.style[e] = r;
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
function A(t, e, n, r) {
|
|
432
|
+
return t.addEventListener(e, n, r), () => {
|
|
433
|
+
t.removeEventListener(e, n, r);
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
function z(t, e) {
|
|
437
|
+
e || !T ? B(t) : T.addEventListener("resize", () => B(t), {
|
|
438
|
+
once: !0
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
function B(t) {
|
|
442
|
+
let e = document.scrollingElement || document.documentElement, n = t;
|
|
443
|
+
for (; n && n !== e; ) {
|
|
444
|
+
let r = Q(n);
|
|
445
|
+
if (r !== document.documentElement && r !== document.body && r !== n) {
|
|
446
|
+
let o = r.getBoundingClientRect(), a = n.getBoundingClientRect();
|
|
447
|
+
if (a.top < o.top || a.bottom > o.top + n.clientHeight) {
|
|
448
|
+
let l = o.bottom;
|
|
449
|
+
T && (l = Math.min(l, T.offsetTop + T.height));
|
|
450
|
+
let u = a.top - o.top - ((l - o.top) / 2 - a.height / 2);
|
|
451
|
+
r.scrollTo({
|
|
452
|
+
// Clamp to the valid range to prevent over-scrolling.
|
|
453
|
+
top: Math.max(0, Math.min(r.scrollHeight - r.clientHeight, r.scrollTop + u)),
|
|
454
|
+
behavior: "smooth"
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
n = r.parentElement;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
function Ie(t, e, n) {
|
|
462
|
+
let { overlayProps: r, underlayProps: o } = le({
|
|
463
|
+
...t,
|
|
464
|
+
isOpen: e.isOpen,
|
|
465
|
+
onClose: e.close
|
|
466
|
+
}, n);
|
|
467
|
+
return Te({
|
|
468
|
+
isDisabled: !e.isOpen
|
|
469
|
+
}), K(), C(() => {
|
|
470
|
+
if (e.isOpen && n.current) return xe([
|
|
471
|
+
n.current
|
|
472
|
+
], {
|
|
473
|
+
shouldUseInert: !0
|
|
474
|
+
});
|
|
475
|
+
}, [
|
|
476
|
+
e.isOpen,
|
|
477
|
+
n
|
|
478
|
+
]), {
|
|
479
|
+
modalProps: be(r),
|
|
480
|
+
underlayProps: o
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
export {
|
|
484
|
+
Pe as $,
|
|
485
|
+
Ie as a
|
|
486
|
+
};
|