welcome-ui 9.0.0-alpha.4 → 9.0.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 (111) hide show
  1. package/README.md +47 -3
  2. package/dist/2W3RN7C5-bkX-rIa3.js +61 -0
  3. package/dist/4I4MLMKD-BLxAidnq.js +43 -0
  4. package/dist/Accordion.js +6 -6
  5. package/dist/Alert.js +1 -1
  6. package/dist/AspectRatio.js +1 -1
  7. package/dist/Avatar.js +1 -1
  8. package/dist/{4CMBR7SL-Dhp8uJop.js → B7UTNDHN-BlIblHCu.js} +59 -59
  9. package/dist/Badge.js +1 -1
  10. package/dist/Breadcrumb.css +1 -1
  11. package/dist/Breadcrumb.js +27 -27
  12. package/dist/Button.js +2 -2
  13. package/dist/ButtonGroup.js +1 -1
  14. package/dist/Card.js +1 -1
  15. package/dist/Checkbox.css +1 -1
  16. package/dist/Checkbox.js +22 -22
  17. package/dist/CloseButton.js +3 -3
  18. package/dist/{SYRFVSLH-CHNUB1rW.js → DSAASPLT-BaaCUKsb.js} +7 -7
  19. package/dist/DatePicker.js +5 -5
  20. package/dist/DateTimePicker.js +2 -2
  21. package/dist/Drawer.css +1 -1
  22. package/dist/Drawer.js +67 -67
  23. package/dist/DropdownMenu.js +261 -259
  24. package/dist/Field.js +1 -1
  25. package/dist/FieldGroup.js +1 -1
  26. package/dist/FileDrop.js +194 -221
  27. package/dist/FileUpload.js +2 -2
  28. package/dist/GVVKDT6A-bET6V7Py.js +724 -0
  29. package/dist/Hint.js +1 -1
  30. package/dist/{Icon-BisRi8B3.js → Icon-EG7O4YwD.js} +1 -1
  31. package/dist/Icon.js +12 -12
  32. package/dist/InputText.js +1 -1
  33. package/dist/{ASMQKSDT-SH1qSiMi.js → KPUWHTQJ-D2TPji47.js} +30 -30
  34. package/dist/Label.js +3 -3
  35. package/dist/Link.css +1 -1
  36. package/dist/Link.js +27 -27
  37. package/dist/Loader.js +1 -1
  38. package/dist/Logo.js +1 -1
  39. package/dist/Modal.js +10 -10
  40. package/dist/{JC64G2H7-DPy9R0De.js → NI3IVY7K-Ztb3-XAv.js} +571 -571
  41. package/dist/{P4IRICAX-7kH4HzWI.js → NMGNQVTG-C6TqBngP.js} +5 -5
  42. package/dist/{LVA2YJMS-NUHCRwFZ.js → OE2EFRVA-C3721cM3.js} +316 -315
  43. package/dist/{ITI7HKP4-C5xLpoVY.js → OLVWQA7U-DysaSaZj.js} +59 -59
  44. package/dist/Pagination.css +1 -1
  45. package/dist/Pagination.js +81 -73
  46. package/dist/PasswordInput.js +17 -18
  47. package/dist/Popover.js +14 -14
  48. package/dist/{YV4JVR4I-CVFstk2K.js → RTNCFSKZ-qpPg689E.js} +75 -73
  49. package/dist/Radio.css +1 -1
  50. package/dist/Radio.js +29 -29
  51. package/dist/RadioGroup.js +21 -21
  52. package/dist/RadioTab.js +2 -2
  53. package/dist/{P2CTZE2T-D1TepwxQ.js → SBSPVDDI-DJKkC1eb.js} +43 -43
  54. package/dist/{NLEBE274-B4zy25kL.js → SQZLCNLX-CHDXnZ16.js} +16 -16
  55. package/dist/Search.js +2 -2
  56. package/dist/Select.js +170 -181
  57. package/dist/Slider.js +1 -1
  58. package/dist/Swiper.css +1 -1
  59. package/dist/Swiper.js +151 -151
  60. package/dist/{VGCJ63VH-CVhs4PYt.js → T22PY7TE-C1N0q8Kn.js} +109 -109
  61. package/dist/Table.js +1 -1
  62. package/dist/Tabs.js +303 -308
  63. package/dist/Tag.js +3 -3
  64. package/dist/Text.js +1 -1
  65. package/dist/Textarea.js +1 -1
  66. package/dist/TimePicker.js +2 -2
  67. package/dist/Toast.js +1 -1
  68. package/dist/Toggle.js +2 -2
  69. package/dist/Tooltip.js +72 -72
  70. package/dist/VariantIcon.js +3 -3
  71. package/dist/WelcomeLoader.js +1 -1
  72. package/dist/XCKGTAUF-DkxWCbaW.js +25 -0
  73. package/dist/Y67KZUMI-DFEgrUv2.js +15 -0
  74. package/dist/{AXB53BZF-BHeessqV.js → ZTXFEM5L-CkrIQCN1.js} +7 -7
  75. package/dist/{field-icon-size-Du58qHNC.js → field-icon-size-Z5NulTSk.js} +216 -224
  76. package/dist/{index-5rXezknO.js → index-BC2bF45u.js} +1 -1
  77. package/dist/{index-C8GsqBDe.js → index-BeetbagJ.js} +1 -1
  78. package/dist/{index-BJLXLdM3.js → index-Bt79XJ8R.js} +1 -1
  79. package/dist/{index-Dcq5gh3E.js → index-BtwrJ6N4.js} +1 -1
  80. package/dist/{index-DL4-ut3P.js → index-CCASZBtz.js} +1 -1
  81. package/dist/{index-lbUBMgHp.js → index-CPqDZeah.js} +2 -2
  82. package/dist/{index-CTgip19b.js → index-CQEPCbEE.js} +1 -1
  83. package/dist/{index-CnxSNAPH.js → index-Crpe9CvH.js} +1 -1
  84. package/dist/{index-CWVOLBDY.js → index-D5a8Oe6k.js} +1 -1
  85. package/dist/{index-C1jjVTAc.js → index-D8dq-I5s.js} +1 -1
  86. package/dist/{index-Cvtm6uuS.js → index-DkwTwo3z.js} +1 -1
  87. package/dist/{index-BG2aV9o8.js → index-DnO8yBVT.js} +1 -1
  88. package/dist/index.css +0 -0
  89. package/dist/tslib.es6-DpB4Y59c.js +683 -0
  90. package/dist/types/components/Pagination/index.d.ts +1 -2
  91. package/dist/types/components/Pagination/types.d.ts +5 -2
  92. package/dist/types/components/PasswordInput/ToggleButton.d.ts +1 -1
  93. package/dist/types/components/PasswordInput/types.d.ts +1 -1
  94. package/dist/types/components/Tabs/components/TabList/index.d.ts +1 -1
  95. package/dist/types/components/Tabs/index.d.ts +1 -1
  96. package/dist/types/components/Tabs/types.d.ts +1 -2
  97. package/dist/types/components/Tabs/utils.d.ts +1 -2
  98. package/dist/types/utils/index.d.ts +1 -0
  99. package/dist/types/utils/theme/index.d.ts +0 -0
  100. package/dist/types/utils/useForkRef.d.ts +7 -1
  101. package/dist/useForkRef-D807AV7D.js +22 -0
  102. package/dist/{utils-BNMgUIHQ.js → utils-BpbIqM56.js} +1 -1
  103. package/dist/utils.js +2 -2
  104. package/package.json +5 -5
  105. package/dist/BYC7LY2E-DbSoi9cN.js +0 -673
  106. package/dist/KUU7WJ55-CsIy9XMu.js +0 -61
  107. package/dist/MTZPJQMC-D_TnSwZf.js +0 -15
  108. package/dist/QYJ6MIDR-Dm7lYMh6.js +0 -43
  109. package/dist/X5NMLKT6-PeY306ft.js +0 -25
  110. package/dist/index--0U5Rubs.js +0 -644
  111. /package/dist/{index-PAaZGbyz.js → index-CdiHdiVB.js} +0 -0
@@ -1,673 +0,0 @@
1
- "use client";
2
- import { u as Re, P as Fe, a as Xe, b as Ye } from "./MTZPJQMC-D_TnSwZf.js";
3
- import { w as Ge, x as U, z as T, y as M, B as Je, c as ae, _ as Z, i as K, ae as Te, b as J, M as ue, D as ve, e as $, g as x, l as ce, n as le, f as we, r as Ze, a1 as Ke, v as Qe, u as _e, a as he, S as Oe, a4 as q, V as et, F as tt, j as Pe, h as ot, G as rt, W as nt } from "./LVA2YJMS-NUHCRwFZ.js";
4
- import { useRef as X, useState as de, useMemo as st, useEffect as _, useContext as it, createContext as ut, useCallback as De } from "react";
5
- import { jsx as V, jsxs as at } from "react/jsx-runtime";
6
- import { a as ct, b as lt, d as dt, c as Ne } from "./JC64G2H7-DPy9R0De.js";
7
- import { m as ft, o as pt, t as mt, c as Ve, b as ie, u as ke, a as vt } from "./YV4JVR4I-CVFstk2K.js";
8
- import { B as ht, N as Pt, L as gt, A as wt, O as St, g as Et, C as xt, a as yt } from "./floating-ui.dom.browser.min-Bza9K_UR.js";
9
- function ze(t = {}) {
10
- var r = t, {
11
- popover: o
12
- } = r, e = Ge(r, [
13
- "popover"
14
- ]);
15
- const n = ft(
16
- e.store,
17
- pt(o, [
18
- "arrowElement",
19
- "anchorElement",
20
- "contentElement",
21
- "popoverElement",
22
- "disclosureElement"
23
- ])
24
- );
25
- mt(e, n);
26
- const s = n == null ? void 0 : n.getState(), a = ct(U(T({}, e), { store: n })), c = M(
27
- e.placement,
28
- s == null ? void 0 : s.placement,
29
- "bottom"
30
- ), u = U(T({}, a.getState()), {
31
- placement: c,
32
- currentPlacement: c,
33
- anchorElement: M(s == null ? void 0 : s.anchorElement, null),
34
- popoverElement: M(s == null ? void 0 : s.popoverElement, null),
35
- arrowElement: M(s == null ? void 0 : s.arrowElement, null),
36
- rendered: Symbol("rendered")
37
- }), i = Ve(u, a, n);
38
- return U(T(T({}, a), i), {
39
- setAnchorElement: (l) => i.setState("anchorElement", l),
40
- setPopoverElement: (l) => i.setState("popoverElement", l),
41
- setArrowElement: (l) => i.setState("arrowElement", l),
42
- render: () => i.setState("rendered", Symbol("rendered"))
43
- });
44
- }
45
- function je(t, r, o) {
46
- return Je(r, [o.popover]), ie(t, o, "placement"), lt(t, r, o);
47
- }
48
- function eo(t = {}) {
49
- const [r, o] = ke(ze, t);
50
- return je(r, o, t);
51
- }
52
- var Ot = "div";
53
- function be(t = 0, r = 0, o = 0, e = 0) {
54
- if (typeof DOMRect == "function")
55
- return new DOMRect(t, r, o, e);
56
- const n = {
57
- x: t,
58
- y: r,
59
- width: o,
60
- height: e,
61
- top: r,
62
- right: t + o,
63
- bottom: r + e,
64
- left: t
65
- };
66
- return $(x({}, n), { toJSON: () => n });
67
- }
68
- function bt(t) {
69
- if (!t) return be();
70
- const { x: r, y: o, width: e, height: n } = t;
71
- return be(r, o, e, n);
72
- }
73
- function At(t, r) {
74
- return {
75
- contextElement: t || void 0,
76
- getBoundingClientRect: () => {
77
- const e = t, n = r == null ? void 0 : r(e);
78
- return n || !e ? bt(n) : e.getBoundingClientRect();
79
- }
80
- };
81
- }
82
- function Ht(t) {
83
- return /^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(t);
84
- }
85
- function Ae(t) {
86
- const r = window.devicePixelRatio || 1;
87
- return Math.round(t * r) / r;
88
- }
89
- function Mt(t, r) {
90
- return gt(({ placement: o }) => {
91
- var e;
92
- const n = ((t == null ? void 0 : t.clientHeight) || 0) / 2, s = typeof r.gutter == "number" ? r.gutter + n : (e = r.gutter) != null ? e : n;
93
- return {
94
- crossAxis: !!o.split("-")[1] ? void 0 : r.shift,
95
- mainAxis: s,
96
- alignmentAxis: r.shift
97
- };
98
- });
99
- }
100
- function $t(t) {
101
- if (t.flip === !1) return;
102
- const r = typeof t.flip == "string" ? t.flip.split(" ") : void 0;
103
- return K(
104
- !r || r.every(Ht),
105
- process.env.NODE_ENV !== "production" && "`flip` expects a spaced-delimited list of placements"
106
- ), wt({
107
- padding: t.overflowPadding,
108
- fallbackPlacements: r
109
- });
110
- }
111
- function Ct(t) {
112
- if (!(!t.slide && !t.overlap))
113
- return St({
114
- mainAxis: t.slide,
115
- crossAxis: t.overlap,
116
- padding: t.overflowPadding,
117
- limiter: yt()
118
- });
119
- }
120
- function Rt(t) {
121
- return xt({
122
- padding: t.overflowPadding,
123
- apply({ elements: r, availableWidth: o, availableHeight: e, rects: n }) {
124
- const s = r.floating, a = Math.round(n.reference.width);
125
- o = Math.floor(o), e = Math.floor(e), s.style.setProperty(
126
- "--popover-anchor-width",
127
- `${a}px`
128
- ), s.style.setProperty(
129
- "--popover-available-width",
130
- `${o}px`
131
- ), s.style.setProperty(
132
- "--popover-available-height",
133
- `${e}px`
134
- ), t.sameWidth && (s.style.width = `${a}px`), t.fitViewport && (s.style.maxWidth = `${o}px`, s.style.maxHeight = `${e}px`);
135
- }
136
- });
137
- }
138
- function Ft(t, r) {
139
- if (t)
140
- return Et({
141
- element: t,
142
- padding: r.arrowPadding
143
- });
144
- }
145
- var Be = ae(
146
- function(r) {
147
- var o = r, {
148
- store: e,
149
- modal: n = !1,
150
- portal: s = !!n,
151
- preserveTabOrder: a = !0,
152
- autoFocusOnShow: c = !0,
153
- wrapperProps: u,
154
- fixed: i = !1,
155
- flip: l = !0,
156
- shift: g = 0,
157
- slide: P = !0,
158
- overlap: w = !1,
159
- sameWidth: v = !1,
160
- fitViewport: y = !1,
161
- gutter: S,
162
- arrowPadding: f = 4,
163
- overflowPadding: E = 8,
164
- getAnchorRect: k,
165
- updatePosition: C
166
- } = o, p = Z(o, [
167
- "store",
168
- "modal",
169
- "portal",
170
- "preserveTabOrder",
171
- "autoFocusOnShow",
172
- "wrapperProps",
173
- "fixed",
174
- "flip",
175
- "shift",
176
- "slide",
177
- "overlap",
178
- "sameWidth",
179
- "fitViewport",
180
- "gutter",
181
- "arrowPadding",
182
- "overflowPadding",
183
- "getAnchorRect",
184
- "updatePosition"
185
- ]);
186
- const z = Re();
187
- e = e || z, K(
188
- e,
189
- process.env.NODE_ENV !== "production" && "Popover must receive a `store` prop or be wrapped in a PopoverProvider component."
190
- );
191
- const D = e.useState("arrowElement"), O = e.useState("anchorElement"), fe = e.useState("disclosureElement"), m = e.useState("popoverElement"), N = e.useState("contentElement"), ee = e.useState("placement"), d = e.useState("mounted"), b = e.useState("rendered"), h = X(null), [A, R] = de(!1), { portalRef: pe, domReady: j } = Te(s, p.portalRef), B = J(k), W = J(C), Y = !!C;
192
- ue(() => {
193
- if (!(m != null && m.isConnected)) return;
194
- m.style.setProperty(
195
- "--popover-overflow-padding",
196
- `${E}px`
197
- );
198
- const H = At(O, B), G = async () => {
199
- if (!d) return;
200
- D || (h.current = h.current || document.createElement("div"));
201
- const L = D || h.current, Ie = [
202
- Mt(L, { gutter: S, shift: g }),
203
- $t({ flip: l, overflowPadding: E }),
204
- Ct({ slide: P, overlap: w, overflowPadding: E }),
205
- Ft(L, { arrowPadding: f }),
206
- Rt({
207
- sameWidth: v,
208
- fitViewport: y,
209
- overflowPadding: E
210
- })
211
- ], I = await Pt(H, m, {
212
- placement: ee,
213
- strategy: i ? "fixed" : "absolute",
214
- middleware: Ie
215
- });
216
- e == null || e.setState("currentPlacement", I.placement), R(!0);
217
- const qe = Ae(I.x), Ue = Ae(I.y);
218
- if (Object.assign(m.style, {
219
- top: "0",
220
- left: "0",
221
- transform: `translate3d(${qe}px,${Ue}px,0)`
222
- }), L && I.middlewareData.arrow) {
223
- const { x: oe, y: re } = I.middlewareData.arrow, Ee = I.placement.split("-")[0], ne = L.clientWidth / 2, se = L.clientHeight / 2, xe = oe != null ? oe + ne : -ne, ye = re != null ? re + se : -se;
224
- m.style.setProperty(
225
- "--popover-transform-origin",
226
- {
227
- top: `${xe}px calc(100% + ${se}px)`,
228
- bottom: `${xe}px ${-se}px`,
229
- left: `calc(100% + ${ne}px) ${ye}px`,
230
- right: `${-ne}px ${ye}px`
231
- }[Ee]
232
- ), Object.assign(L.style, {
233
- left: oe != null ? `${oe}px` : "",
234
- top: re != null ? `${re}px` : "",
235
- [Ee]: "100%"
236
- });
237
- }
238
- }, Le = ht(H, m, async () => {
239
- Y ? (await W({ updatePosition: G }), R(!0)) : await G();
240
- }, {
241
- // JSDOM doesn't support ResizeObserver
242
- elementResize: typeof ResizeObserver == "function"
243
- });
244
- return () => {
245
- R(!1), Le();
246
- };
247
- }, [
248
- e,
249
- b,
250
- m,
251
- D,
252
- O,
253
- m,
254
- ee,
255
- d,
256
- j,
257
- i,
258
- l,
259
- g,
260
- P,
261
- w,
262
- v,
263
- y,
264
- S,
265
- f,
266
- E,
267
- B,
268
- Y,
269
- W
270
- ]), ue(() => {
271
- if (!d || !j || !(m != null && m.isConnected) || !(N != null && N.isConnected)) return;
272
- const H = () => {
273
- m.style.zIndex = getComputedStyle(N).zIndex;
274
- };
275
- H();
276
- let G = requestAnimationFrame(() => {
277
- G = requestAnimationFrame(H);
278
- });
279
- return () => cancelAnimationFrame(G);
280
- }, [d, j, m, N]);
281
- const te = i ? "fixed" : "absolute";
282
- return p = ve(
283
- p,
284
- (H) => /* @__PURE__ */ V(
285
- "div",
286
- $(x({}, u), {
287
- style: x({
288
- // https://floating-ui.com/docs/computeposition#initial-layout
289
- position: te,
290
- top: 0,
291
- left: 0,
292
- width: "max-content"
293
- }, u == null ? void 0 : u.style),
294
- ref: e == null ? void 0 : e.setPopoverElement,
295
- children: H
296
- })
297
- ),
298
- [e, te, u]
299
- ), p = ve(
300
- p,
301
- (H) => /* @__PURE__ */ V(Fe, { value: e, children: H }),
302
- [e]
303
- ), p = $(x({
304
- // data-placing is not part of the public API. We're setting this here so
305
- // we can wait for the popover to be positioned before other components
306
- // move focus into it. For example, this attribute is observed by the
307
- // Combobox component with the autoSelect behavior.
308
- "data-placing": !A || void 0
309
- }, p), {
310
- style: x({
311
- position: "relative"
312
- }, p.style)
313
- }), p = dt($(x({
314
- store: e,
315
- modal: n,
316
- portal: s,
317
- preserveTabOrder: a,
318
- preserveTabOrderAnchor: fe || O,
319
- autoFocusOnShow: A && c
320
- }, p), {
321
- portalRef: pe
322
- })), p;
323
- }
324
- ), to = Ne(
325
- ce(function(r) {
326
- const o = Be(r);
327
- return le(Ot, o);
328
- }),
329
- Re
330
- ), He = "M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z", Tt = "div", ge = 30, F = ge / 2, _t = {
331
- top: `rotate(180 ${F} ${F})`,
332
- right: `rotate(-90 ${F} ${F})`,
333
- bottom: `rotate(0 ${F} ${F})`,
334
- left: `rotate(90 ${F} ${F})`
335
- };
336
- function Dt(t) {
337
- const [r, o] = de(), e = t.useState("contentElement");
338
- return ue(() => {
339
- if (!e) return;
340
- const s = Ke(e).getComputedStyle(e);
341
- o(s);
342
- }, [e]), r;
343
- }
344
- var Nt = ae(
345
- function(r) {
346
- var o = r, { store: e, size: n = ge } = o, s = Z(o, ["store", "size"]);
347
- const a = Xe();
348
- e = e || a, K(
349
- e,
350
- process.env.NODE_ENV !== "production" && "PopoverArrow must be wrapped in a Popover component."
351
- );
352
- const c = e.useState(
353
- (y) => y.currentPlacement.split("-")[0]
354
- ), u = Dt(e), i = (u == null ? void 0 : u.getPropertyValue("background-color")) || "none", l = (u == null ? void 0 : u.getPropertyValue(`border-${c}-color`)) || "none", g = (u == null ? void 0 : u.getPropertyValue(`border-${c}-width`)) || "0px", P = Number.parseInt(g) * 2 * (ge / n), w = _t[c], v = st(
355
- () => /* @__PURE__ */ V("svg", { display: "block", viewBox: "0 0 30 30", children: /* @__PURE__ */ at("g", { transform: w, children: [
356
- /* @__PURE__ */ V("path", { fill: "none", d: He }),
357
- /* @__PURE__ */ V("path", { stroke: "none", d: He })
358
- ] }) }),
359
- [w]
360
- );
361
- return s = $(x({
362
- children: v,
363
- "aria-hidden": !0
364
- }, s), {
365
- ref: we(e.setArrowElement, s.ref),
366
- style: x({
367
- // server side rendering
368
- position: "absolute",
369
- fontSize: n,
370
- width: "1em",
371
- height: "1em",
372
- pointerEvents: "none",
373
- fill: i,
374
- stroke: l,
375
- strokeWidth: P
376
- }, s.style)
377
- }), Ze(s);
378
- }
379
- ), oo = ce(function(r) {
380
- const o = Nt(r);
381
- return le(Tt, o);
382
- }), Q = Qe(
383
- [Ye],
384
- [Fe]
385
- );
386
- Q.useContext;
387
- Q.useScopedContext;
388
- var Se = Q.useProviderContext, ro = Q.ContextProvider, Vt = Q.ScopedContextProvider;
389
- function kt(t = {}) {
390
- var r;
391
- const o = (r = t.store) == null ? void 0 : r.getState(), e = ze(U(T({}, t), {
392
- placement: M(
393
- t.placement,
394
- o == null ? void 0 : o.placement,
395
- "bottom"
396
- )
397
- })), n = M(t.timeout, o == null ? void 0 : o.timeout, 500), s = U(T({}, e.getState()), {
398
- timeout: n,
399
- showTimeout: M(t.showTimeout, o == null ? void 0 : o.showTimeout),
400
- hideTimeout: M(t.hideTimeout, o == null ? void 0 : o.hideTimeout),
401
- autoFocusOnShow: M(o == null ? void 0 : o.autoFocusOnShow, !1)
402
- }), a = Ve(s, e, t.store);
403
- return U(T(T({}, e), a), {
404
- setAutoFocusOnShow: (c) => a.setState("autoFocusOnShow", c)
405
- });
406
- }
407
- function zt(t, r, o) {
408
- return ie(t, o, "timeout"), ie(t, o, "showTimeout"), ie(t, o, "hideTimeout"), je(t, r, o);
409
- }
410
- function no(t = {}) {
411
- const [r, o] = ke(kt, t);
412
- return zt(r, o, t);
413
- }
414
- function me(t) {
415
- return [t.clientX, t.clientY];
416
- }
417
- function Me(t, r) {
418
- const [o, e] = t;
419
- let n = !1;
420
- const s = r.length;
421
- for (let a = s, c = 0, u = a - 1; c < a; u = c++) {
422
- const [i, l] = r[c], [g, P] = r[u], [, w] = r[u === 0 ? a - 1 : u - 1] || [0, 0], v = (l - P) * (o - i) - (i - g) * (e - l);
423
- if (P < l) {
424
- if (e >= P && e < l) {
425
- if (v === 0) return !0;
426
- v > 0 && (e === P ? e > w && (n = !n) : n = !n);
427
- }
428
- } else if (l < P) {
429
- if (e > l && e <= P) {
430
- if (v === 0) return !0;
431
- v < 0 && (e === P ? e < w && (n = !n) : n = !n);
432
- }
433
- } else if (e === l && (o >= g && o <= i || o >= i && o <= g))
434
- return !0;
435
- }
436
- return n;
437
- }
438
- function jt(t, r) {
439
- const { top: o, right: e, bottom: n, left: s } = r, [a, c] = t, u = a < s ? "left" : a > e ? "right" : null, i = c < o ? "top" : c > n ? "bottom" : null;
440
- return [u, i];
441
- }
442
- function $e(t, r) {
443
- const o = t.getBoundingClientRect(), { top: e, right: n, bottom: s, left: a } = o, [c, u] = jt(r, o), i = [r];
444
- return c ? (u !== "top" && i.push([c === "left" ? a : n, e]), i.push([c === "left" ? n : a, e]), i.push([c === "left" ? n : a, s]), u !== "bottom" && i.push([c === "left" ? a : n, s])) : u === "top" ? (i.push([a, e]), i.push([a, s]), i.push([n, s]), i.push([n, e])) : (i.push([a, s]), i.push([a, e]), i.push([n, e]), i.push([n, s])), i;
445
- }
446
- var Bt = "div";
447
- function We(t, r, o, e) {
448
- return ot(r) ? !0 : t ? !!(Pe(r, t) || o && Pe(o, t) || e != null && e.some((n) => We(t, n, o))) : !1;
449
- }
450
- function Wt(t) {
451
- var r = t, {
452
- store: o
453
- } = r, e = Z(r, [
454
- "store"
455
- ]);
456
- const [n, s] = de(!1), a = o.useState("mounted");
457
- _(() => {
458
- a || s(!1);
459
- }, [a]);
460
- const c = e.onFocus, u = J((l) => {
461
- c == null || c(l), !l.defaultPrevented && s(!0);
462
- }), i = X(null);
463
- return _(() => vt(o, ["anchorElement"], (l) => {
464
- i.current = l.anchorElement;
465
- }), []), e = $(x({
466
- autoFocusOnHide: n,
467
- finalFocus: i
468
- }, e), {
469
- onFocus: u
470
- }), e;
471
- }
472
- var Ce = ut(null), Lt = ae(
473
- function(r) {
474
- var o = r, {
475
- store: e,
476
- modal: n = !1,
477
- portal: s = !!n,
478
- hideOnEscape: a = !0,
479
- hideOnHoverOutside: c = !0,
480
- disablePointerEventsOnApproach: u = !!c
481
- } = o, i = Z(o, [
482
- "store",
483
- "modal",
484
- "portal",
485
- "hideOnEscape",
486
- "hideOnHoverOutside",
487
- "disablePointerEventsOnApproach"
488
- ]);
489
- const l = Se();
490
- e = e || l, K(
491
- e,
492
- process.env.NODE_ENV !== "production" && "Hovercard must receive a `store` prop or be wrapped in a HovercardProvider component."
493
- );
494
- const g = X(null), [P, w] = de([]), v = X(0), y = X(null), { portalRef: S, domReady: f } = Te(s, i.portalRef), E = _e(), k = !!c, C = he(c), p = !!u, z = he(
495
- u
496
- ), D = e.useState("open"), O = e.useState("mounted");
497
- _(() => {
498
- if (!f || !O || !k && !p) return;
499
- const d = g.current;
500
- return d ? Oe(
501
- q("mousemove", (h) => {
502
- if (!e || !E()) return;
503
- const { anchorElement: A, hideTimeout: R, timeout: pe } = e.getState(), j = y.current, [B] = h.composedPath(), W = A;
504
- if (We(B, d, W, P)) {
505
- y.current = B && W && Pe(W, B) ? me(h) : null, window.clearTimeout(v.current), v.current = 0;
506
- return;
507
- }
508
- if (!v.current) {
509
- if (j) {
510
- const Y = me(h), te = $e(d, j);
511
- if (Me(Y, te)) {
512
- if (y.current = Y, !z(h)) return;
513
- h.preventDefault(), h.stopPropagation();
514
- return;
515
- }
516
- }
517
- C(h) && (v.current = window.setTimeout(() => {
518
- v.current = 0, e == null || e.hide();
519
- }, R ?? pe));
520
- }
521
- }, !0),
522
- () => clearTimeout(v.current)
523
- ) : void 0;
524
- }, [
525
- e,
526
- E,
527
- f,
528
- O,
529
- k,
530
- p,
531
- P,
532
- z,
533
- C
534
- ]), _(() => {
535
- if (!f || !O || !p) return;
536
- const d = (b) => {
537
- const h = g.current;
538
- if (!h) return;
539
- const A = y.current;
540
- if (!A) return;
541
- const R = $e(h, A);
542
- if (Me(me(b), R)) {
543
- if (!z(b)) return;
544
- b.preventDefault(), b.stopPropagation();
545
- }
546
- };
547
- return Oe(
548
- // Note: we may need to add pointer events here in the future.
549
- q("mouseenter", d, !0),
550
- q("mouseover", d, !0),
551
- q("mouseout", d, !0),
552
- q("mouseleave", d, !0)
553
- );
554
- }, [f, O, p, z]), _(() => {
555
- f && (D || e == null || e.setAutoFocusOnShow(!1));
556
- }, [e, f, D]);
557
- const fe = et(D);
558
- _(() => {
559
- if (f)
560
- return () => {
561
- fe.current || e == null || e.setAutoFocusOnShow(!1);
562
- };
563
- }, [e, f]);
564
- const m = it(Ce);
565
- ue(() => {
566
- if (n || !s || !O || !f) return;
567
- const d = g.current;
568
- if (d)
569
- return m == null ? void 0 : m(d);
570
- }, [n, s, O, f]);
571
- const N = De(
572
- (d) => {
573
- w((h) => [...h, d]);
574
- const b = m == null ? void 0 : m(d);
575
- return () => {
576
- w(
577
- (h) => h.filter((A) => A !== d)
578
- ), b == null || b();
579
- };
580
- },
581
- [m]
582
- );
583
- i = ve(
584
- i,
585
- (d) => /* @__PURE__ */ V(Vt, { value: e, children: /* @__PURE__ */ V(Ce.Provider, { value: N, children: d }) }),
586
- [e, N]
587
- ), i = $(x({}, i), {
588
- ref: we(g, i.ref)
589
- }), i = Wt(x({ store: e }, i));
590
- const ee = e.useState(
591
- (d) => n || d.autoFocusOnShow
592
- );
593
- return i = Be($(x({
594
- store: e,
595
- modal: n,
596
- portal: s,
597
- autoFocusOnShow: ee
598
- }, i), {
599
- portalRef: S,
600
- hideOnEscape(d) {
601
- return tt(a, d) ? !1 : (requestAnimationFrame(() => {
602
- requestAnimationFrame(() => {
603
- e == null || e.hide();
604
- });
605
- }), !0);
606
- }
607
- })), i;
608
- }
609
- ), so = Ne(
610
- ce(function(r) {
611
- const o = Lt(r);
612
- return le(Bt, o);
613
- }),
614
- Se
615
- ), It = "a", qt = ae(
616
- function(r) {
617
- var o = r, { store: e, showOnHover: n = !0 } = o, s = Z(o, ["store", "showOnHover"]);
618
- const a = Se();
619
- e = e || a, K(
620
- e,
621
- process.env.NODE_ENV !== "production" && "HovercardAnchor must receive a `store` prop or be wrapped in a HovercardProvider component."
622
- );
623
- const c = rt(s), u = X(0);
624
- _(() => () => window.clearTimeout(u.current), []), _(() => q("mouseleave", (f) => {
625
- if (!e) return;
626
- const { anchorElement: E } = e.getState();
627
- E && f.target === E && (window.clearTimeout(u.current), u.current = 0);
628
- }, !0), [e]);
629
- const i = s.onMouseMove, l = he(n), g = _e(), P = J((S) => {
630
- if (i == null || i(S), c || !e || S.defaultPrevented || u.current || !g() || !l(S)) return;
631
- const f = S.currentTarget;
632
- e.setAnchorElement(f), e.setDisclosureElement(f);
633
- const { showTimeout: E, timeout: k } = e.getState(), C = () => {
634
- u.current = 0, g() && (e == null || e.setAnchorElement(f), e == null || e.show(), queueMicrotask(() => {
635
- e == null || e.setDisclosureElement(f);
636
- }));
637
- }, p = E ?? k;
638
- p === 0 ? C() : u.current = window.setTimeout(C, p);
639
- }), w = s.onClick, v = J((S) => {
640
- w == null || w(S), e && (window.clearTimeout(u.current), u.current = 0);
641
- }), y = De(
642
- (S) => {
643
- if (!e) return;
644
- const { anchorElement: f } = e.getState();
645
- f != null && f.isConnected || e.setAnchorElement(S);
646
- },
647
- [e]
648
- );
649
- return s = $(x({}, s), {
650
- ref: we(y, s.ref),
651
- onMouseMove: P,
652
- onClick: v
653
- }), s = nt(s), s;
654
- }
655
- ), io = ce(function(r) {
656
- const o = qt(r);
657
- return le(It, o);
658
- });
659
- export {
660
- Vt as H,
661
- oo as P,
662
- ro as a,
663
- Lt as b,
664
- kt as c,
665
- Nt as d,
666
- qt as e,
667
- io as f,
668
- so as g,
669
- eo as h,
670
- no as i,
671
- to as j,
672
- zt as u
673
- };