seam-react 0.2.0 → 0.3.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/dist/index.js CHANGED
@@ -1,595 +1,602 @@
1
- import { jsxs as N, jsx as l } from "react/jsx-runtime";
2
- import { forwardRef as y, useId as L, useRef as M, useEffect as R, useMemo as F, createContext as j, useContext as B, isValidElement as se, cloneElement as K, useSyncExternalStore as ce, useState as $, useLayoutEffect as le } from "react";
3
- import { useReducedMotion as S, useMotionValue as ue, animate as V, motion as A, MotionConfig as de, AnimatePresence as fe, useIsPresent as pe } from "motion/react";
4
- import { createPortal as ge } from "react-dom";
5
- import { useControllableState as H, useEventCallback as be, useLockBodyScroll as he, useFocusTrap as me } from "seam-hooks";
6
- function h(...o) {
7
- return o.filter(Boolean).join(" ");
8
- }
9
- const Y = y(function({
10
- variant: e = "primary",
1
+ import { jsxs as N, jsx as h } from "react/jsx-runtime";
2
+ import { forwardRef as D, useId as z, useRef as _, useEffect as S, useMemo as X, createContext as j, useContext as Y, isValidElement as tt, cloneElement as J, useSyncExternalStore as et, useState as O, useLayoutEffect as nt, useCallback as B } from "react";
3
+ import { useReducedMotion as K, useMotionValue as Kt, animate as dt, motion as V, MotionConfig as ot, AnimatePresence as rt, useIsPresent as it } from "motion/react";
4
+ import { createPortal as st } from "react-dom";
5
+ import { useControllableState as Q, useEventCallback as P, useLockBodyScroll as Gt, useFocusTrap as qt } from "seam-hooks";
6
+ function v(...e) {
7
+ return e.filter(Boolean).join(" ");
8
+ }
9
+ const ht = D(function({
10
+ variant: t = "primary",
11
11
  size: n = "md",
12
- loading: r = !1,
13
- iconOnly: a = !1,
14
- type: s = "button",
15
- className: i,
16
- children: d,
17
- ...u
18
- }, c) {
12
+ loading: o = !1,
13
+ iconOnly: r = !1,
14
+ type: a = "button",
15
+ className: s,
16
+ children: l,
17
+ ...d
18
+ }, i) {
19
19
  return /* @__PURE__ */ N(
20
20
  "button",
21
21
  {
22
- ...u,
23
- ref: c,
24
- type: s,
25
- className: h("uk-button", i),
26
- "data-variant": e,
22
+ ...d,
23
+ ref: i,
24
+ type: a,
25
+ className: v("uk-button", s),
26
+ "data-variant": t,
27
27
  "data-size": n,
28
- "data-loading": r ? "true" : void 0,
29
- "data-icon-only": a ? "true" : void 0,
30
- disabled: u.disabled || r,
31
- "aria-busy": r || void 0,
28
+ "data-loading": o ? "true" : void 0,
29
+ "data-icon-only": r ? "true" : void 0,
30
+ disabled: d.disabled || o,
31
+ "aria-busy": o || void 0,
32
32
  children: [
33
- r ? /* @__PURE__ */ l("span", { className: "uk-button__spinner", "aria-hidden": "true" }) : null,
34
- d
33
+ o ? /* @__PURE__ */ h("span", { className: "uk-button__spinner", "aria-hidden": "true" }) : null,
34
+ l
35
35
  ]
36
36
  }
37
37
  );
38
- }), Ae = y(function({
39
- inputSize: e = "md",
38
+ }), Te = D(function({
39
+ inputSize: t = "md",
40
40
  invalid: n = !1,
41
- className: r,
42
- "aria-invalid": a,
43
- ...s
44
- }, i) {
45
- return /* @__PURE__ */ l(
41
+ className: o,
42
+ "aria-invalid": r,
43
+ ...a
44
+ }, s) {
45
+ return /* @__PURE__ */ h(
46
46
  "input",
47
47
  {
48
- ...s,
49
- ref: i,
50
- className: h("uk-input", r),
51
- "data-size": e,
52
- "aria-invalid": n ? !0 : a
48
+ ...a,
49
+ ref: s,
50
+ className: v("uk-input", o),
51
+ "data-size": t,
52
+ "aria-invalid": n ? !0 : r
53
53
  }
54
54
  );
55
- }), Ie = [0.23, 1, 0.32, 1], U = {
55
+ }), U = [0.23, 1, 0.32, 1], pt = {
56
56
  type: "spring",
57
57
  bounce: 0,
58
58
  duration: 0.3
59
- }, X = {
59
+ }, ft = {
60
60
  type: "spring",
61
61
  bounce: 0.04,
62
62
  duration: 0.38
63
- }, ye = {
63
+ }, Ut = {
64
64
  type: "spring",
65
65
  bounce: 0.08,
66
66
  duration: 0.34
67
- }, z = {
67
+ }, bt = {
68
+ duration: 0.12,
69
+ ease: U
70
+ }, Xt = {
71
+ layout: { type: "spring", bounce: 0, duration: 0.22 },
72
+ opacity: { duration: 0.12, ease: U },
73
+ scale: { duration: 0.12, ease: U }
74
+ }, H = {
68
75
  duration: 0.12,
69
- ease: Ie
70
- }, He = y(function({
71
- checked: e,
76
+ ease: U
77
+ }, we = D(function({
78
+ checked: t,
72
79
  defaultChecked: n,
73
- onCheckedChange: r,
74
- disabled: a,
75
- className: s,
76
- children: i,
77
- id: d,
78
- ...u
79
- }, c) {
80
- const p = L(), g = d ?? p, k = S() ?? !1, b = M(!1), m = M(null), [C, _] = H({
81
- value: e,
80
+ onCheckedChange: o,
81
+ disabled: r,
82
+ className: a,
83
+ children: s,
84
+ id: l,
85
+ ...d
86
+ }, i) {
87
+ const m = z(), b = l ?? m, u = K() ?? !1, f = _(!1), p = _(null), [g, y] = Q({
88
+ value: t,
82
89
  defaultValue: n ?? !1,
83
- onChange: r
84
- }), D = ue(C ? 16 : 0);
85
- R(() => {
86
- if (m.current)
90
+ onChange: o
91
+ }), T = Kt(g ? 16 : 0);
92
+ S(() => {
93
+ if (p.current)
87
94
  return;
88
- const t = V(
89
- D,
90
- C ? 16 : 0,
91
- k ? { duration: 0 } : U
95
+ const c = dt(
96
+ T,
97
+ g ? 16 : 0,
98
+ u ? { duration: 0 } : pt
92
99
  );
93
- return () => t.stop();
94
- }, [C, k, D]);
95
- const v = (t) => {
96
- const f = m.current;
97
- if (!(!f || f.pointerId !== t.pointerId)) {
98
- if (f.moved) {
99
- const T = f.samples[0], x = f.samples[f.samples.length - 1], E = T && x ? Math.max(x.time - T.time, 1) : 1, w = T && x ? (x.x - T.x) / E * 1e3 : 0, I = Math.abs(w) > 220 ? w > 0 : D.get() >= 8;
100
- b.current = !0, m.current = null, _(I), V(
101
- D,
102
- I ? 16 : 0,
103
- k ? { duration: 0 } : { ...U, velocity: w }
100
+ return () => c.stop();
101
+ }, [g, u, T]);
102
+ const C = (c) => {
103
+ const w = p.current;
104
+ if (!(!w || w.pointerId !== c.pointerId)) {
105
+ if (w.moved) {
106
+ const I = w.samples[0], k = w.samples[w.samples.length - 1], L = I && k ? Math.max(k.time - I.time, 1) : 1, R = I && k ? (k.x - I.x) / L * 1e3 : 0, x = Math.abs(R) > 220 ? R > 0 : T.get() >= 8;
107
+ f.current = !0, p.current = null, y(x), dt(
108
+ T,
109
+ x ? 16 : 0,
110
+ u ? { duration: 0 } : { ...pt, velocity: R }
104
111
  ), window.setTimeout(() => {
105
- b.current = !1;
112
+ f.current = !1;
106
113
  }, 0);
107
114
  } else
108
- m.current = null;
109
- t.currentTarget.hasPointerCapture(t.pointerId) && typeof t.currentTarget.releasePointerCapture == "function" && t.currentTarget.releasePointerCapture(t.pointerId);
115
+ p.current = null;
116
+ c.currentTarget.hasPointerCapture(c.pointerId) && typeof c.currentTarget.releasePointerCapture == "function" && c.currentTarget.releasePointerCapture(c.pointerId);
110
117
  }
111
118
  };
112
119
  return /* @__PURE__ */ N(
113
120
  "label",
114
121
  {
115
- className: h("uk-switch", s),
116
- "data-disabled": a ? "true" : void 0,
117
- htmlFor: g,
118
- onClickCapture: (t) => {
119
- b.current && (t.preventDefault(), t.stopPropagation());
122
+ className: v("uk-switch", a),
123
+ "data-disabled": r ? "true" : void 0,
124
+ htmlFor: b,
125
+ onClickCapture: (c) => {
126
+ f.current && (c.preventDefault(), c.stopPropagation());
120
127
  },
121
128
  children: [
122
- /* @__PURE__ */ l(
129
+ /* @__PURE__ */ h(
123
130
  "input",
124
131
  {
125
- ...u,
126
- ref: c,
127
- id: g,
132
+ ...d,
133
+ ref: i,
134
+ id: b,
128
135
  type: "checkbox",
129
136
  role: "switch",
130
137
  className: "uk-switch__input",
131
- checked: C,
132
- disabled: a,
133
- "aria-checked": C,
134
- onChange: (t) => _(t.target.checked)
138
+ checked: g,
139
+ disabled: r,
140
+ "aria-checked": g,
141
+ onChange: (c) => y(c.target.checked)
135
142
  }
136
143
  ),
137
- /* @__PURE__ */ l(
144
+ /* @__PURE__ */ h(
138
145
  "span",
139
146
  {
140
147
  className: "uk-switch__track",
141
148
  "aria-hidden": "true",
142
- onPointerDown: (t) => {
143
- a || (m.current = {
144
- pointerId: t.pointerId,
145
- startX: t.clientX,
146
- startValue: D.get(),
149
+ onPointerDown: (c) => {
150
+ r || (p.current = {
151
+ pointerId: c.pointerId,
152
+ startX: c.clientX,
153
+ startValue: T.get(),
147
154
  moved: !1,
148
- samples: [{ x: t.clientX, time: performance.now() }]
149
- }, typeof t.currentTarget.setPointerCapture == "function" && t.currentTarget.setPointerCapture(t.pointerId));
155
+ samples: [{ x: c.clientX, time: performance.now() }]
156
+ }, typeof c.currentTarget.setPointerCapture == "function" && c.currentTarget.setPointerCapture(c.pointerId));
150
157
  },
151
- onPointerMove: (t) => {
152
- const f = m.current;
153
- if (!f || f.pointerId !== t.pointerId)
158
+ onPointerMove: (c) => {
159
+ const w = p.current;
160
+ if (!w || w.pointerId !== c.pointerId)
154
161
  return;
155
- const T = t.clientX - f.startX;
156
- Math.abs(T) > 4 && (f.moved = !0), f.moved && (t.preventDefault(), D.set(Math.max(0, Math.min(16, f.startValue + T))), f.samples.push({ x: t.clientX, time: performance.now() }), f.samples = f.samples.filter(
157
- (x) => performance.now() - x.time < 120
162
+ const I = c.clientX - w.startX;
163
+ Math.abs(I) > 4 && (w.moved = !0), w.moved && (c.preventDefault(), T.set(Math.max(0, Math.min(16, w.startValue + I))), w.samples.push({ x: c.clientX, time: performance.now() }), w.samples = w.samples.filter(
164
+ (k) => performance.now() - k.time < 120
158
165
  ));
159
166
  },
160
- onPointerUp: v,
161
- onPointerCancel: v,
162
- children: /* @__PURE__ */ l(A.span, { className: "uk-switch__thumb", style: { x: D } })
167
+ onPointerUp: C,
168
+ onPointerCancel: C,
169
+ children: /* @__PURE__ */ h(V.span, { className: "uk-switch__thumb", style: { x: T } })
163
170
  }
164
171
  ),
165
- i ? /* @__PURE__ */ l("span", { className: "uk-switch__label", children: i }) : null
172
+ s ? /* @__PURE__ */ h("span", { className: "uk-switch__label", children: s }) : null
166
173
  ]
167
174
  }
168
175
  );
169
- }), G = j(null);
170
- function O(o) {
171
- const e = B(G);
172
- if (!e)
173
- throw new Error(`<${o}> must be rendered inside <Tabs>`);
174
- return e;
175
- }
176
- function W(o, e) {
177
- return `${o}-tab-${encodeURIComponent(e)}`;
178
- }
179
- function J(o, e) {
180
- return `${o}-panel-${encodeURIComponent(e)}`;
181
- }
182
- function ke({
183
- value: o,
184
- defaultValue: e,
176
+ }), gt = j(null);
177
+ function at(e) {
178
+ const t = Y(gt);
179
+ if (!t)
180
+ throw new Error(`<${e}> must be rendered inside <Tabs>`);
181
+ return t;
182
+ }
183
+ function yt(e, t) {
184
+ return `${e}-tab-${encodeURIComponent(t)}`;
185
+ }
186
+ function Tt(e, t) {
187
+ return `${e}-panel-${encodeURIComponent(t)}`;
188
+ }
189
+ function jt({
190
+ value: e,
191
+ defaultValue: t,
185
192
  onValueChange: n,
186
- orientation: r = "horizontal",
187
- className: a,
188
- children: s
193
+ orientation: o = "horizontal",
194
+ className: r,
195
+ children: a
189
196
  }) {
190
- const i = L(), [d, u] = H({
191
- value: o,
192
- defaultValue: e ?? "",
197
+ const s = z(), [l, d] = Q({
198
+ value: e,
199
+ defaultValue: t ?? "",
193
200
  onChange: n
194
- }), c = F(
201
+ }), i = X(
195
202
  () => ({
196
- baseId: i,
197
- value: d,
198
- setValue: u,
199
- orientation: r,
200
- indicatorId: `${i}-indicator`
203
+ baseId: s,
204
+ value: l,
205
+ setValue: d,
206
+ orientation: o,
207
+ indicatorId: `${s}-indicator`
201
208
  }),
202
- [i, d, r, u]
209
+ [s, l, o, d]
203
210
  );
204
- return /* @__PURE__ */ l(G.Provider, { value: c, children: /* @__PURE__ */ l("div", { className: h("uk-tabs", a), "data-orientation": r, children: s }) });
211
+ return /* @__PURE__ */ h(gt.Provider, { value: i, children: /* @__PURE__ */ h("div", { className: v("uk-tabs", r), "data-orientation": o, children: a }) });
205
212
  }
206
- const Ce = y(function({ className: e, onKeyDown: n, ...r }, a) {
207
- const { orientation: s } = O("Tabs.List");
208
- return /* @__PURE__ */ l(
213
+ const Yt = D(function({ className: t, onKeyDown: n, ...o }, r) {
214
+ const { orientation: a } = at("Tabs.List");
215
+ return /* @__PURE__ */ h(
209
216
  "div",
210
217
  {
211
- ...r,
212
- ref: a,
218
+ ...o,
219
+ ref: r,
213
220
  role: "tablist",
214
- "aria-orientation": s,
221
+ "aria-orientation": a,
215
222
  tabIndex: -1,
216
- className: h("uk-tabs__list", e),
217
- onKeyDown: (i) => {
218
- if (n?.(i), i.defaultPrevented)
223
+ className: v("uk-tabs__list", t),
224
+ onKeyDown: (s) => {
225
+ if (n?.(s), s.defaultPrevented)
219
226
  return;
220
- const u = i.target?.closest('[role="tab"]');
221
- if (!u || u.hasAttribute("disabled"))
227
+ const d = s.target?.closest('[role="tab"]');
228
+ if (!d || d.hasAttribute("disabled"))
222
229
  return;
223
- const c = Array.from(
224
- i.currentTarget.querySelectorAll(
230
+ const i = Array.from(
231
+ s.currentTarget.querySelectorAll(
225
232
  '[role="tab"]:not([disabled])'
226
233
  )
227
- ), p = c.indexOf(u);
228
- if (p === -1)
234
+ ), m = i.indexOf(d);
235
+ if (m === -1)
229
236
  return;
230
- const g = s === "horizontal" ? "ArrowRight" : "ArrowDown", k = s === "horizontal" ? "ArrowLeft" : "ArrowUp";
231
- let b = -1;
232
- switch (i.key) {
233
- case g:
234
- b = (p + 1) % c.length;
237
+ const b = a === "horizontal" ? "ArrowRight" : "ArrowDown", u = a === "horizontal" ? "ArrowLeft" : "ArrowUp";
238
+ let f = -1;
239
+ switch (s.key) {
240
+ case b:
241
+ f = (m + 1) % i.length;
235
242
  break;
236
- case k:
237
- b = (p - 1 + c.length) % c.length;
243
+ case u:
244
+ f = (m - 1 + i.length) % i.length;
238
245
  break;
239
246
  case "Home":
240
- b = 0;
247
+ f = 0;
241
248
  break;
242
249
  case "End":
243
- b = c.length - 1;
250
+ f = i.length - 1;
244
251
  break;
245
252
  default:
246
253
  return;
247
254
  }
248
- i.preventDefault();
249
- const m = c[b];
250
- m && (m.focus(), m.click());
255
+ s.preventDefault();
256
+ const p = i[f];
257
+ p && (p.focus(), p.click());
251
258
  }
252
259
  }
253
260
  );
254
- }), De = y(function({ value: e, type: n = "button", className: r, onClick: a, children: s, ...i }, d) {
255
- const u = O("Tabs.Trigger"), c = u.value === e, p = S() ?? !1;
261
+ }), Jt = D(function({ value: t, type: n = "button", className: o, onClick: r, children: a, ...s }, l) {
262
+ const d = at("Tabs.Trigger"), i = d.value === t, m = K() ?? !1;
256
263
  return /* @__PURE__ */ N(
257
264
  "button",
258
265
  {
259
- ...i,
260
- ref: d,
266
+ ...s,
267
+ ref: l,
261
268
  type: n,
262
269
  role: "tab",
263
- id: W(u.baseId, e),
264
- "aria-selected": c,
265
- "aria-controls": J(u.baseId, e),
266
- tabIndex: c ? 0 : -1,
267
- "data-state": c ? "active" : "inactive",
268
- className: h("uk-tabs__trigger", r),
269
- onClick: (g) => {
270
- a?.(g), g.defaultPrevented || u.setValue(e);
270
+ id: yt(d.baseId, t),
271
+ "aria-selected": i,
272
+ "aria-controls": Tt(d.baseId, t),
273
+ tabIndex: i ? 0 : -1,
274
+ "data-state": i ? "active" : "inactive",
275
+ className: v("uk-tabs__trigger", o),
276
+ onClick: (b) => {
277
+ r?.(b), b.defaultPrevented || d.setValue(t);
271
278
  },
272
279
  children: [
273
- s,
274
- c ? /* @__PURE__ */ l(
275
- A.span,
280
+ a,
281
+ i ? /* @__PURE__ */ h(
282
+ V.span,
276
283
  {
277
284
  className: "uk-tabs__indicator",
278
- layoutId: u.indicatorId,
285
+ layoutId: d.indicatorId,
279
286
  "aria-hidden": "true",
280
- transition: p ? { duration: 0 } : ye
287
+ transition: m ? { duration: 0 } : Ut
281
288
  }
282
289
  ) : null
283
290
  ]
284
291
  }
285
292
  );
286
- }), Te = y(function({ value: e, className: n, ...r }, a) {
287
- const s = O("Tabs.Content"), i = s.value === e;
288
- return /* @__PURE__ */ l(
293
+ }), Qt = D(function({ value: t, className: n, ...o }, r) {
294
+ const a = at("Tabs.Content"), s = a.value === t;
295
+ return /* @__PURE__ */ h(
289
296
  "div",
290
297
  {
291
- ...r,
292
- ref: a,
298
+ ...o,
299
+ ref: r,
293
300
  role: "tabpanel",
294
- id: J(s.baseId, e),
295
- "aria-labelledby": W(s.baseId, e),
296
- hidden: !i,
301
+ id: Tt(a.baseId, t),
302
+ "aria-labelledby": yt(a.baseId, t),
303
+ hidden: !s,
297
304
  tabIndex: 0,
298
- "data-state": i ? "active" : "inactive",
299
- className: h("uk-tabs__panel", n)
305
+ "data-state": s ? "active" : "inactive",
306
+ className: v("uk-tabs__panel", n)
300
307
  }
301
308
  );
302
- }), Oe = Object.assign(ke, {
303
- List: Ce,
304
- Trigger: De,
305
- Content: Te
306
- }), Q = j(null), xe = () => () => {
307
- }, _e = () => !0, ve = () => !1;
308
- function P(o) {
309
- const e = B(Q);
310
- if (!e)
311
- throw new Error(`<${o}> must be rendered inside <Dialog.Root>`);
312
- return e;
313
- }
314
- function Z(o, e) {
309
+ }), Ce = Object.assign(jt, {
310
+ List: Yt,
311
+ Trigger: Jt,
312
+ Content: Qt
313
+ }), wt = j(null), Wt = () => () => {
314
+ }, Zt = () => !0, te = () => !1;
315
+ function G(e) {
316
+ const t = Y(wt);
317
+ if (!t)
318
+ throw new Error(`<${e}> must be rendered inside <Dialog.Root>`);
319
+ return t;
320
+ }
321
+ function Ct(e, t) {
315
322
  return (n) => {
316
- o?.(n), n.defaultPrevented || e(n);
323
+ e?.(n), n.defaultPrevented || t(n);
317
324
  };
318
325
  }
319
- function q({
320
- children: o,
321
- open: e,
326
+ function vt({
327
+ children: e,
328
+ open: t,
322
329
  defaultOpen: n,
323
- onOpenChange: r
330
+ onOpenChange: o
324
331
  }) {
325
- const a = L(), [s, i] = $(!1), [d, u] = $(!1), [c, p] = H({
326
- value: e,
332
+ const r = z(), [a, s] = O(!1), [l, d] = O(!1), [i, m] = Q({
333
+ value: t,
327
334
  defaultValue: n ?? !1,
328
- onChange: r
329
- }), g = F(
335
+ onChange: o
336
+ }), b = X(
330
337
  () => ({
331
- open: c,
332
- setOpen: p,
333
- triggerId: `${a}-trigger`,
334
- contentId: `${a}-content`,
335
- titleId: `${a}-title`,
336
- descriptionId: `${a}-description`,
337
- hasTitle: s,
338
- setHasTitle: i,
339
- hasDescription: d,
340
- setHasDescription: u
338
+ open: i,
339
+ setOpen: m,
340
+ triggerId: `${r}-trigger`,
341
+ contentId: `${r}-content`,
342
+ titleId: `${r}-title`,
343
+ descriptionId: `${r}-description`,
344
+ hasTitle: a,
345
+ setHasTitle: s,
346
+ hasDescription: l,
347
+ setHasDescription: d
341
348
  }),
342
- [a, c, d, s, p]
349
+ [r, i, l, a, m]
343
350
  );
344
- return /* @__PURE__ */ l(Q.Provider, { value: g, children: o });
351
+ return /* @__PURE__ */ h(wt.Provider, { value: b, children: e });
345
352
  }
346
- function we({ children: o }) {
347
- const e = P("Dialog.Trigger"), n = o, r = n.props.onClick;
348
- return K(n, {
349
- id: e.triggerId,
353
+ function ee({ children: e }) {
354
+ const t = G("Dialog.Trigger"), n = e, o = n.props.onClick;
355
+ return J(n, {
356
+ id: t.triggerId,
350
357
  "aria-haspopup": "dialog",
351
- "aria-expanded": e.open,
352
- "aria-controls": e.open ? e.contentId : void 0,
353
- onClick: Z(r, () => {
354
- e.setOpen(!e.open);
358
+ "aria-expanded": t.open,
359
+ "aria-controls": t.open ? t.contentId : void 0,
360
+ onClick: Ct(o, () => {
361
+ t.setOpen(!t.open);
355
362
  })
356
363
  });
357
364
  }
358
- function ee({
359
- children: o,
360
- label: e = "Close"
365
+ function xt({
366
+ children: e,
367
+ label: t = "Close"
361
368
  }) {
362
- const n = P("Dialog.Close");
363
- if (se(o)) {
364
- const r = o, a = r.props.onClick;
365
- return K(r, {
366
- onClick: Z(a, () => {
369
+ const n = G("Dialog.Close");
370
+ if (tt(e)) {
371
+ const o = e, r = o.props.onClick;
372
+ return J(o, {
373
+ onClick: Ct(r, () => {
367
374
  n.setOpen(!1);
368
375
  })
369
376
  });
370
377
  }
371
- return /* @__PURE__ */ l(Y, { variant: "ghost", onClick: () => n.setOpen(!1), children: e });
378
+ return /* @__PURE__ */ h(ht, { variant: "ghost", onClick: () => n.setOpen(!1), children: t });
372
379
  }
373
- const te = y(function({ className: e, ...n }, r) {
374
- return /* @__PURE__ */ l(
380
+ const It = D(function({ className: t, ...n }, o) {
381
+ return /* @__PURE__ */ h(
375
382
  "header",
376
383
  {
377
384
  ...n,
378
- ref: r,
379
- className: h("uk-dialog__header", e)
385
+ ref: o,
386
+ className: v("uk-dialog__header", t)
380
387
  }
381
388
  );
382
- }), ne = y(function({ className: e, children: n, ...r }, a) {
383
- const s = P("Dialog.Title"), i = s.setHasTitle;
384
- return R(() => (i(!0), () => i(!1)), [i]), /* @__PURE__ */ l(
389
+ }), kt = D(function({ className: t, children: n, ...o }, r) {
390
+ const a = G("Dialog.Title"), s = a.setHasTitle;
391
+ return S(() => (s(!0), () => s(!1)), [s]), /* @__PURE__ */ h(
385
392
  "h2",
386
393
  {
387
- ...r,
388
- ref: a,
389
- id: s.titleId,
390
- className: h("uk-dialog__title", e),
394
+ ...o,
395
+ ref: r,
396
+ id: a.titleId,
397
+ className: v("uk-dialog__title", t),
391
398
  children: n
392
399
  }
393
400
  );
394
- }), re = y(
395
- function({ className: e, ...n }, r) {
396
- const a = P("Dialog.Description"), s = a.setHasDescription;
397
- return R(() => (s(!0), () => s(!1)), [s]), /* @__PURE__ */ l(
401
+ }), Dt = D(
402
+ function({ className: t, ...n }, o) {
403
+ const r = G("Dialog.Description"), a = r.setHasDescription;
404
+ return S(() => (a(!0), () => a(!1)), [a]), /* @__PURE__ */ h(
398
405
  "p",
399
406
  {
400
407
  ...n,
401
- ref: r,
402
- id: a.descriptionId,
403
- className: h("uk-dialog__description", e)
408
+ ref: o,
409
+ id: r.descriptionId,
410
+ className: v("uk-dialog__description", t)
404
411
  }
405
412
  );
406
413
  }
407
- ), oe = y(function({ className: e, ...n }, r) {
408
- return /* @__PURE__ */ l("div", { ...n, ref: r, className: h("uk-dialog__body", e) });
409
- }), ae = y(function({ className: e, ...n }, r) {
410
- return /* @__PURE__ */ l(
414
+ ), Et = D(function({ className: t, ...n }, o) {
415
+ return /* @__PURE__ */ h("div", { ...n, ref: o, className: v("uk-dialog__body", t) });
416
+ }), _t = D(function({ className: t, ...n }, o) {
417
+ return /* @__PURE__ */ h(
411
418
  "footer",
412
419
  {
413
420
  ...n,
414
- ref: r,
415
- className: h("uk-dialog__footer", e)
421
+ ref: o,
422
+ className: v("uk-dialog__footer", t)
416
423
  }
417
424
  );
418
425
  });
419
- function Ne({
420
- requestClose: o,
421
- contentId: e,
426
+ function ne({
427
+ requestClose: e,
428
+ contentId: t,
422
429
  titleId: n,
423
- descriptionId: r,
424
- hasTitle: a,
425
- hasDescription: s,
426
- children: i,
427
- closeOnBackdropClick: d = !0,
428
- closeOnEscape: u = !0,
429
- initialFocusRef: c,
430
- returnFocusRef: p,
431
- className: g,
432
- "aria-label": k,
433
- "aria-labelledby": b,
434
- "aria-describedby": m
430
+ descriptionId: o,
431
+ hasTitle: r,
432
+ hasDescription: a,
433
+ children: s,
434
+ closeOnBackdropClick: l = !0,
435
+ closeOnEscape: d = !0,
436
+ initialFocusRef: i,
437
+ returnFocusRef: m,
438
+ className: b,
439
+ "aria-label": u,
440
+ "aria-labelledby": f,
441
+ "aria-describedby": p
435
442
  }) {
436
- const C = M(null), _ = M(null), D = pe(), v = S() ?? !1;
437
- return he(!0), le(() => {
438
- const t = C.current;
439
- t && (_.current ?? (_.current = document.activeElement instanceof HTMLElement ? document.activeElement : null), !t.open && (typeof t.showModal == "function" ? t.showModal() : t.setAttribute("open", "")));
440
- }, []), me({
443
+ const g = _(null), y = _(null), T = it(), C = K() ?? !1;
444
+ return Gt(!0), nt(() => {
445
+ const c = g.current;
446
+ c && (y.current ?? (y.current = document.activeElement instanceof HTMLElement ? document.activeElement : null), !c.open && (typeof c.showModal == "function" ? c.showModal() : c.setAttribute("open", "")));
447
+ }, []), qt({
441
448
  active: !0,
442
- containerRef: C,
443
- initialFocusRef: c,
444
- returnFocusRef: p ?? _
445
- }), R(() => {
446
- const t = C.current;
447
- if (!t)
449
+ containerRef: g,
450
+ initialFocusRef: i,
451
+ returnFocusRef: m ?? y
452
+ }), S(() => {
453
+ const c = g.current;
454
+ if (!c)
448
455
  return;
449
- const f = () => {
450
- t.open || (typeof t.showModal == "function" ? t.showModal() : t.setAttribute("open", ""));
451
- }, T = () => {
452
- if (!u) {
453
- f();
456
+ const w = () => {
457
+ c.open || (typeof c.showModal == "function" ? c.showModal() : c.setAttribute("open", ""));
458
+ }, I = () => {
459
+ if (!d) {
460
+ w();
454
461
  return;
455
462
  }
456
- o();
457
- }, x = (I) => {
458
- I.preventDefault(), u && o();
459
- }, E = (I) => {
460
- u || I.key !== "Escape" || I.defaultPrevented || (I.preventDefault(), I.stopPropagation());
461
- }, w = (I) => {
462
- d && I.target === t && o();
463
+ e();
464
+ }, k = (x) => {
465
+ x.preventDefault(), d && e();
466
+ }, L = (x) => {
467
+ d || x.key !== "Escape" || x.defaultPrevented || (x.preventDefault(), x.stopPropagation());
468
+ }, R = (x) => {
469
+ l && x.target === c && e();
463
470
  };
464
- return t.addEventListener("close", T), t.addEventListener("cancel", x), t.addEventListener("keydown", E, !0), t.addEventListener("click", w), () => {
465
- t.removeEventListener("close", T), t.removeEventListener("cancel", x), t.removeEventListener("keydown", E, !0), t.removeEventListener("click", w);
471
+ return c.addEventListener("close", I), c.addEventListener("cancel", k), c.addEventListener("keydown", L, !0), c.addEventListener("click", R), () => {
472
+ c.removeEventListener("close", I), c.removeEventListener("cancel", k), c.removeEventListener("keydown", L, !0), c.removeEventListener("click", R);
466
473
  };
467
- }, [d, u, o]), /* @__PURE__ */ l(
474
+ }, [l, d, e]), /* @__PURE__ */ h(
468
475
  "dialog",
469
476
  {
470
- ref: C,
471
- id: e,
472
- className: h("uk-dialog", g),
473
- closedby: u || d ? "any" : "none",
474
- "data-state": D ? "open" : "closed",
475
- inert: !D,
476
- "aria-label": k,
477
- "aria-labelledby": b ?? (k ? void 0 : a ? n : void 0),
478
- "aria-describedby": m ?? (s ? r : void 0),
479
- children: /* @__PURE__ */ l(
480
- A.div,
477
+ ref: g,
478
+ id: t,
479
+ className: v("uk-dialog", b),
480
+ closedby: d || l ? "any" : "none",
481
+ "data-state": T ? "open" : "closed",
482
+ inert: !T,
483
+ "aria-label": u,
484
+ "aria-labelledby": f ?? (u ? void 0 : r ? n : void 0),
485
+ "aria-describedby": p ?? (a ? o : void 0),
486
+ children: /* @__PURE__ */ h(
487
+ V.div,
481
488
  {
482
489
  className: "uk-dialog__panel",
483
- initial: v ? { opacity: 0 } : {
490
+ initial: C ? { opacity: 0 } : {
484
491
  opacity: 0,
485
492
  transform: "translateY(12px) scale(0.96)"
486
493
  },
487
494
  animate: {
488
495
  opacity: 1,
489
496
  transform: "translateY(0px) scale(1)",
490
- transition: v ? z : { ...X, delay: 0.06 }
497
+ transition: C ? H : { ...ft, delay: 0.06 }
491
498
  },
492
- exit: v ? { opacity: 0, transition: z } : {
499
+ exit: C ? { opacity: 0, transition: H } : {
493
500
  opacity: 0,
494
501
  transform: "translateY(8px) scale(0.97)",
495
- transition: X
502
+ transition: ft
496
503
  },
497
- children: i
504
+ children: s
498
505
  }
499
506
  )
500
507
  }
501
508
  );
502
509
  }
503
- function ie({
504
- children: o,
505
- closeOnBackdropClick: e = !0,
510
+ function Rt({
511
+ children: e,
512
+ closeOnBackdropClick: t = !0,
506
513
  closeOnEscape: n = !0,
507
- initialFocusRef: r,
508
- returnFocusRef: a,
509
- className: s,
510
- "aria-label": i,
511
- "aria-labelledby": d,
512
- "aria-describedby": u
514
+ initialFocusRef: o,
515
+ returnFocusRef: r,
516
+ className: a,
517
+ "aria-label": s,
518
+ "aria-labelledby": l,
519
+ "aria-describedby": d
513
520
  }) {
514
- const c = P("Dialog.Content"), p = be(() => {
515
- c.setOpen(!1);
521
+ const i = G("Dialog.Content"), m = P(() => {
522
+ i.setOpen(!1);
516
523
  });
517
- return ce(
518
- xe,
519
- _e,
520
- ve
521
- ) ? ge(
522
- /* @__PURE__ */ l(de, { reducedMotion: "user", children: /* @__PURE__ */ l(fe, { children: c.open ? /* @__PURE__ */ l(
523
- Ne,
524
+ return et(
525
+ Wt,
526
+ Zt,
527
+ te
528
+ ) ? st(
529
+ /* @__PURE__ */ h(ot, { reducedMotion: "user", children: /* @__PURE__ */ h(rt, { children: i.open ? /* @__PURE__ */ h(
530
+ ne,
524
531
  {
525
- requestClose: p,
526
- contentId: c.contentId,
527
- titleId: c.titleId,
528
- descriptionId: c.descriptionId,
529
- hasTitle: c.hasTitle,
530
- hasDescription: c.hasDescription,
531
- closeOnBackdropClick: e,
532
+ requestClose: m,
533
+ contentId: i.contentId,
534
+ titleId: i.titleId,
535
+ descriptionId: i.descriptionId,
536
+ hasTitle: i.hasTitle,
537
+ hasDescription: i.hasDescription,
538
+ closeOnBackdropClick: t,
532
539
  closeOnEscape: n,
533
- initialFocusRef: r,
534
- returnFocusRef: a,
535
- className: s,
536
- "aria-label": i,
537
- "aria-labelledby": d,
538
- "aria-describedby": u,
539
- children: o
540
+ initialFocusRef: o,
541
+ returnFocusRef: r,
542
+ className: a,
543
+ "aria-label": s,
544
+ "aria-labelledby": l,
545
+ "aria-describedby": d,
546
+ children: e
540
547
  },
541
548
  "uk-dialog"
542
549
  ) : null }) }),
543
550
  document.body
544
551
  ) : null;
545
552
  }
546
- function Pe({
547
- open: o,
548
- onOpenChange: e,
553
+ function oe({
554
+ open: e,
555
+ onOpenChange: t,
549
556
  title: n,
550
- description: r,
551
- footer: a,
552
- children: s,
553
- closeLabel: i = "Close",
554
- showCloseButton: d = !0,
555
- closeOnBackdropClick: u = !0,
556
- closeOnEscape: c = !0,
557
- initialFocusRef: p,
558
- returnFocusRef: g,
559
- className: k,
560
- "aria-label": b
557
+ description: o,
558
+ footer: r,
559
+ children: a,
560
+ closeLabel: s = "Close",
561
+ showCloseButton: l = !0,
562
+ closeOnBackdropClick: d = !0,
563
+ closeOnEscape: i = !0,
564
+ initialFocusRef: m,
565
+ returnFocusRef: b,
566
+ className: u,
567
+ "aria-label": f
561
568
  }) {
562
- return /* @__PURE__ */ l(q, { open: o, onOpenChange: e, children: /* @__PURE__ */ N(
563
- ie,
569
+ return /* @__PURE__ */ h(vt, { open: e, onOpenChange: t, children: /* @__PURE__ */ N(
570
+ Rt,
564
571
  {
565
- className: k,
566
- closeOnBackdropClick: u,
567
- closeOnEscape: c,
568
- initialFocusRef: p,
569
- returnFocusRef: g,
570
- "aria-label": b,
572
+ className: u,
573
+ closeOnBackdropClick: d,
574
+ closeOnEscape: i,
575
+ initialFocusRef: m,
576
+ returnFocusRef: b,
577
+ "aria-label": f,
571
578
  children: [
572
- n || r || d ? /* @__PURE__ */ N(te, { children: [
579
+ n || o || l ? /* @__PURE__ */ N(It, { children: [
573
580
  /* @__PURE__ */ N("div", { className: "uk-dialog__heading", children: [
574
- n ? /* @__PURE__ */ l(ne, { children: n }) : null,
575
- r ? /* @__PURE__ */ l(re, { children: r }) : null
581
+ n ? /* @__PURE__ */ h(kt, { children: n }) : null,
582
+ o ? /* @__PURE__ */ h(Dt, { children: o }) : null
576
583
  ] }),
577
- d ? /* @__PURE__ */ l(ee, { children: /* @__PURE__ */ l(
578
- Y,
584
+ l ? /* @__PURE__ */ h(xt, { children: /* @__PURE__ */ h(
585
+ ht,
579
586
  {
580
587
  variant: "ghost",
581
588
  size: "sm",
582
589
  iconOnly: !0,
583
- "aria-label": i,
590
+ "aria-label": s,
584
591
  className: "uk-dialog__close",
585
- children: /* @__PURE__ */ l(
592
+ children: /* @__PURE__ */ h(
586
593
  "svg",
587
594
  {
588
595
  viewBox: "0 0 20 20",
589
596
  width: "16",
590
597
  height: "16",
591
598
  "aria-hidden": "true",
592
- children: /* @__PURE__ */ l(
599
+ children: /* @__PURE__ */ h(
593
600
  "path",
594
601
  {
595
602
  d: "M5 5l10 10M15 5L5 15",
@@ -603,28 +610,658 @@ function Pe({
603
610
  }
604
611
  ) }) : null
605
612
  ] }) : null,
606
- /* @__PURE__ */ l(oe, { children: s }),
607
- a ? /* @__PURE__ */ l(ae, { children: a }) : null
613
+ /* @__PURE__ */ h(Et, { children: a }),
614
+ r ? /* @__PURE__ */ h(_t, { children: r }) : null
608
615
  ]
609
616
  }
610
617
  ) });
611
618
  }
612
- const $e = Object.assign(Pe, {
613
- Root: q,
614
- Trigger: we,
615
- Content: ie,
616
- Header: te,
617
- Title: ne,
618
- Description: re,
619
- Body: oe,
620
- Footer: ae,
621
- Close: ee
622
- });
619
+ const ve = Object.assign(oe, {
620
+ Root: vt,
621
+ Trigger: ee,
622
+ Content: Rt,
623
+ Header: It,
624
+ Title: kt,
625
+ Description: Dt,
626
+ Body: Et,
627
+ Footer: _t,
628
+ Close: xt
629
+ }), Pt = j(null), Nt = () => () => {
630
+ }, Lt = () => !0, Mt = () => !1;
631
+ function Ot(e) {
632
+ const t = Y(Pt);
633
+ if (!t)
634
+ throw new Error(`<${e}> must be rendered inside <Tooltip.Root>`);
635
+ return t;
636
+ }
637
+ function St(e, t) {
638
+ typeof e == "function" ? e(t) : e && (e.current = t);
639
+ }
640
+ function $t(e, t) {
641
+ const n = typeof e == "string" ? e.split(/\s+/).filter(Boolean) : [];
642
+ return Array.from(/* @__PURE__ */ new Set([...n, t])).join(" ");
643
+ }
644
+ function E(e, t) {
645
+ return (n) => {
646
+ e?.(n), n.defaultPrevented || t(n);
647
+ };
648
+ }
649
+ function re({
650
+ children: e,
651
+ open: t,
652
+ defaultOpen: n,
653
+ onOpenChange: o,
654
+ delayDuration: r = 300,
655
+ closeDelay: a = 80
656
+ }) {
657
+ const s = z(), [l, d] = O(
658
+ null
659
+ ), i = _(null), m = _(null), [b, u] = Q({
660
+ value: t,
661
+ defaultValue: n ?? !1,
662
+ onChange: o
663
+ }), f = B(() => {
664
+ i.current !== null && (clearTimeout(i.current), i.current = null);
665
+ }, []), p = B(() => {
666
+ m.current !== null && (clearTimeout(m.current), m.current = null);
667
+ }, []), g = P((c = !1) => {
668
+ if (f(), p(), !b) {
669
+ if (c || r <= 0) {
670
+ u(!0);
671
+ return;
672
+ }
673
+ i.current = setTimeout(() => {
674
+ i.current = null, u(!0);
675
+ }, r);
676
+ }
677
+ }), y = P(() => {
678
+ if (f(), p(), !!b) {
679
+ if (a <= 0) {
680
+ u(!1);
681
+ return;
682
+ }
683
+ m.current = setTimeout(() => {
684
+ m.current = null, u(!1);
685
+ }, a);
686
+ }
687
+ }), T = P(() => {
688
+ f(), p(), u(!1);
689
+ });
690
+ S(() => {
691
+ b ? p() : f();
692
+ }, [p, f, b]), S(
693
+ () => () => {
694
+ f(), p();
695
+ },
696
+ [p, f]
697
+ );
698
+ const C = X(
699
+ () => ({
700
+ open: b,
701
+ triggerElement: l,
702
+ setTriggerElement: d,
703
+ contentId: s,
704
+ requestOpen: g,
705
+ requestClose: y,
706
+ dismiss: T
707
+ }),
708
+ [s, b, T, y, g, l]
709
+ );
710
+ return /* @__PURE__ */ h(Pt.Provider, { value: C, children: e });
711
+ }
712
+ function ie({ children: e }) {
713
+ const t = Ot("Tooltip.Trigger"), { setTriggerElement: n } = t;
714
+ if (!tt(e))
715
+ throw new Error("<Tooltip.Trigger> expects a single valid React element");
716
+ const o = e, r = o.props, a = r.ref ?? o.ref, s = r.onPointerEnter, l = r.onPointerLeave, d = r.onFocus, i = r.onBlur, m = r.onKeyDown, b = B(
717
+ (u) => {
718
+ St(a, u), n(u);
719
+ },
720
+ [a, n]
721
+ );
722
+ return J(o, {
723
+ ref: b,
724
+ "aria-describedby": t.open ? $t(r["aria-describedby"], t.contentId) : r["aria-describedby"],
725
+ onPointerEnter: E(s, (u) => {
726
+ t.requestOpen(u.pointerType === "touch");
727
+ }),
728
+ onPointerLeave: E(l, (u) => {
729
+ u.pointerType !== "touch" && t.requestClose();
730
+ }),
731
+ onFocus: E(d, () => {
732
+ t.requestOpen();
733
+ }),
734
+ onBlur: E(i, () => {
735
+ t.requestClose();
736
+ }),
737
+ onKeyDown: E(m, (u) => {
738
+ u.key === "Escape" && t.open && (u.preventDefault(), u.stopPropagation(), t.dismiss());
739
+ })
740
+ });
741
+ }
742
+ function q(e, t, n) {
743
+ return n < t ? t : Math.min(Math.max(e, t), n);
744
+ }
745
+ function se(e) {
746
+ switch (e) {
747
+ case "top":
748
+ return "bottom";
749
+ case "right":
750
+ return "left";
751
+ case "bottom":
752
+ return "top";
753
+ case "left":
754
+ return "right";
755
+ }
756
+ }
757
+ function Z(e, t, n, o, r) {
758
+ switch (t) {
759
+ case "top":
760
+ return e.top - r;
761
+ case "right":
762
+ return n - e.right - r;
763
+ case "bottom":
764
+ return o - e.bottom - r;
765
+ case "left":
766
+ return e.left - r;
767
+ }
768
+ }
769
+ function mt(e, t, n, o, r, a, s) {
770
+ return Z(
771
+ e,
772
+ n,
773
+ r,
774
+ a,
775
+ s
776
+ ) >= (n === "top" || n === "bottom" ? t.height : t.width) + o;
777
+ }
778
+ function ae({
779
+ trigger: e,
780
+ tooltip: t,
781
+ side: n,
782
+ align: o,
783
+ sideOffset: r,
784
+ collisionPadding: a,
785
+ avoidCollisions: s,
786
+ viewportWidth: l,
787
+ viewportHeight: d
788
+ }) {
789
+ let i = n;
790
+ if (s && !mt(
791
+ e,
792
+ t,
793
+ n,
794
+ r,
795
+ l,
796
+ d,
797
+ a
798
+ )) {
799
+ const y = se(n), T = mt(
800
+ e,
801
+ t,
802
+ y,
803
+ r,
804
+ l,
805
+ d,
806
+ a
807
+ ), C = Z(
808
+ e,
809
+ n,
810
+ l,
811
+ d,
812
+ a
813
+ ), c = Z(
814
+ e,
815
+ y,
816
+ l,
817
+ d,
818
+ a
819
+ );
820
+ (T || c > C) && (i = y);
821
+ }
822
+ const m = e.left + e.width / 2, b = e.top + e.height / 2;
823
+ let u = 0, f = 0;
824
+ switch (i) {
825
+ case "top":
826
+ case "bottom":
827
+ u = o === "start" ? e.left : o === "end" ? e.right - t.width : m - t.width / 2, f = i === "top" ? e.top - t.height - r : e.bottom + r;
828
+ break;
829
+ case "left":
830
+ case "right":
831
+ u = i === "left" ? e.left - t.width - r : e.right + r, f = o === "start" ? e.top : o === "end" ? e.bottom - t.height : b - t.height / 2;
832
+ break;
833
+ }
834
+ s && (u = q(
835
+ u,
836
+ a,
837
+ l - t.width - a
838
+ ), f = q(
839
+ f,
840
+ a,
841
+ d - t.height - a
842
+ ));
843
+ const p = 10, g = i === "top" || i === "bottom" ? q(
844
+ m - u,
845
+ p,
846
+ Math.max(p, t.width - p)
847
+ ) : q(
848
+ b - f,
849
+ p,
850
+ Math.max(p, t.height - p)
851
+ );
852
+ return { x: u, y: f, side: i, arrowOffset: g };
853
+ }
854
+ function At(e, t, {
855
+ side: n,
856
+ align: o,
857
+ sideOffset: r,
858
+ collisionPadding: a,
859
+ avoidCollisions: s
860
+ }) {
861
+ const [l, d] = O(null);
862
+ return nt(() => {
863
+ const i = t.current;
864
+ if (!i || !e)
865
+ return;
866
+ const m = () => {
867
+ const u = e.getBoundingClientRect(), f = i.getBoundingClientRect();
868
+ d(
869
+ ae({
870
+ trigger: u,
871
+ tooltip: f,
872
+ side: n,
873
+ align: o,
874
+ sideOffset: r,
875
+ collisionPadding: a,
876
+ avoidCollisions: s,
877
+ viewportWidth: window.innerWidth || document.documentElement.clientWidth,
878
+ viewportHeight: window.innerHeight || document.documentElement.clientHeight
879
+ })
880
+ );
881
+ };
882
+ m(), window.addEventListener("resize", m), window.addEventListener("scroll", m, !0);
883
+ const b = typeof ResizeObserver > "u" ? null : new ResizeObserver(m);
884
+ return b?.observe(e), b?.observe(i), () => {
885
+ window.removeEventListener("resize", m), window.removeEventListener("scroll", m, !0), b?.disconnect();
886
+ };
887
+ }, [
888
+ o,
889
+ s,
890
+ a,
891
+ t,
892
+ n,
893
+ r,
894
+ e
895
+ ]), l;
896
+ }
897
+ function Bt(e, t, n) {
898
+ S(() => {
899
+ const o = (s) => {
900
+ const l = s.target;
901
+ l instanceof Node && (e.contains(l) || t.current?.contains(l) || n());
902
+ }, r = () => {
903
+ document.visibilityState === "hidden" && n();
904
+ }, a = (s) => {
905
+ const l = s.target;
906
+ s.key !== "Escape" || l instanceof Node && e.contains(l) || n();
907
+ };
908
+ return document.addEventListener("pointerdown", o, !0), document.addEventListener("visibilitychange", r), document.addEventListener("keydown", a, !0), window.addEventListener("blur", n), () => {
909
+ document.removeEventListener("pointerdown", o, !0), document.removeEventListener("visibilitychange", r), document.removeEventListener("keydown", a, !0), window.removeEventListener("blur", n);
910
+ };
911
+ }, [n, t, e]);
912
+ }
913
+ function Vt(e) {
914
+ switch (e) {
915
+ case "top":
916
+ return "center bottom";
917
+ case "bottom":
918
+ return "center top";
919
+ case "left":
920
+ return "right center";
921
+ case "right":
922
+ return "left center";
923
+ default:
924
+ return "center";
925
+ }
926
+ }
927
+ function ce({
928
+ contentId: e,
929
+ triggerElement: t,
930
+ dismiss: n,
931
+ children: o,
932
+ className: r,
933
+ style: a,
934
+ side: s = "top",
935
+ align: l = "center",
936
+ sideOffset: d = 8,
937
+ collisionPadding: i = 8,
938
+ avoidCollisions: m = !0,
939
+ ...b
940
+ }) {
941
+ const u = _(null), f = K() ?? !1, p = it(), g = At(t, u, {
942
+ side: s,
943
+ align: l,
944
+ sideOffset: d,
945
+ collisionPadding: i,
946
+ avoidCollisions: m
947
+ });
948
+ Bt(t, u, n);
949
+ const y = Vt(g?.side ?? s), T = {
950
+ ...a,
951
+ left: g ? `${g.x}px` : 0,
952
+ top: g ? `${g.y}px` : 0,
953
+ visibility: g ? "visible" : "hidden"
954
+ };
955
+ return /* @__PURE__ */ h(
956
+ "div",
957
+ {
958
+ ...b,
959
+ ref: u,
960
+ id: e,
961
+ role: "tooltip",
962
+ "data-side": g?.side ?? s,
963
+ "data-align": l,
964
+ "data-state": p ? "open" : "closed",
965
+ "aria-hidden": p ? void 0 : !0,
966
+ className: v("uk-tooltip", r),
967
+ style: T,
968
+ children: /* @__PURE__ */ N(
969
+ V.div,
970
+ {
971
+ className: "uk-tooltip__surface",
972
+ style: { transformOrigin: y },
973
+ initial: f ? { opacity: 0 } : { opacity: 0, scale: 0.96 },
974
+ animate: { opacity: 1, scale: 1 },
975
+ exit: f ? { opacity: 0 } : { opacity: 0, scale: 0.96 },
976
+ transition: f ? H : bt,
977
+ children: [
978
+ /* @__PURE__ */ h(
979
+ "span",
980
+ {
981
+ className: "uk-tooltip__arrow",
982
+ "aria-hidden": "true",
983
+ style: {
984
+ "--uk-tooltip-arrow-offset": `${g?.arrowOffset ?? 0}px`
985
+ }
986
+ }
987
+ ),
988
+ o
989
+ ]
990
+ }
991
+ )
992
+ }
993
+ );
994
+ }
995
+ function le(e) {
996
+ const t = Ot("Tooltip.Content"), o = et(
997
+ Nt,
998
+ Lt,
999
+ Mt
1000
+ ) && t.triggerElement ? t.triggerElement.closest("dialog") ?? document.body : null;
1001
+ return !o || !t.triggerElement ? null : st(
1002
+ /* @__PURE__ */ h(ot, { reducedMotion: "user", children: /* @__PURE__ */ h(rt, { children: t.open ? /* @__PURE__ */ h(
1003
+ ce,
1004
+ {
1005
+ contentId: t.contentId,
1006
+ triggerElement: t.triggerElement,
1007
+ dismiss: t.dismiss,
1008
+ ...e
1009
+ },
1010
+ "uk-tooltip"
1011
+ ) : null }) }),
1012
+ o
1013
+ );
1014
+ }
1015
+ const Ft = j(
1016
+ null
1017
+ );
1018
+ function ue(e) {
1019
+ const t = Y(Ft);
1020
+ if (!t)
1021
+ throw new Error(`<${e}> must be rendered inside <Tooltip.Group>`);
1022
+ return t;
1023
+ }
1024
+ function de({
1025
+ activeValue: e,
1026
+ content: t,
1027
+ contentClassName: n,
1028
+ contentId: o,
1029
+ dismiss: r,
1030
+ triggerElement: a,
1031
+ side: s,
1032
+ align: l,
1033
+ sideOffset: d,
1034
+ collisionPadding: i,
1035
+ avoidCollisions: m
1036
+ }) {
1037
+ const b = _(null), u = K() ?? !1, f = it(), p = At(a, b, {
1038
+ side: s,
1039
+ align: l,
1040
+ sideOffset: d,
1041
+ collisionPadding: i,
1042
+ avoidCollisions: m
1043
+ });
1044
+ Bt(a, b, r);
1045
+ const g = {
1046
+ left: p ? `${p.x}px` : 0,
1047
+ top: p ? `${p.y}px` : 0,
1048
+ transformOrigin: Vt(p?.side ?? s),
1049
+ visibility: p ? "visible" : "hidden"
1050
+ };
1051
+ return /* @__PURE__ */ N(
1052
+ V.div,
1053
+ {
1054
+ ref: b,
1055
+ id: o,
1056
+ role: "tooltip",
1057
+ layout: !u,
1058
+ layoutDependency: e,
1059
+ "data-side": p?.side ?? s,
1060
+ "data-align": l,
1061
+ "data-state": f ? "open" : "closed",
1062
+ "aria-hidden": f ? void 0 : !0,
1063
+ className: v(
1064
+ "uk-tooltip",
1065
+ "uk-tooltip__surface",
1066
+ "uk-tooltip--group",
1067
+ n
1068
+ ),
1069
+ style: g,
1070
+ initial: u ? { opacity: 0 } : { opacity: 0, scale: 0.96 },
1071
+ animate: { opacity: 1, scale: 1 },
1072
+ exit: u ? { opacity: 0 } : { opacity: 0, scale: 0.96 },
1073
+ transition: u ? { ...H, layout: { duration: 0 } } : Xt,
1074
+ children: [
1075
+ /* @__PURE__ */ h(
1076
+ "span",
1077
+ {
1078
+ className: "uk-tooltip__arrow",
1079
+ "aria-hidden": "true",
1080
+ style: {
1081
+ "--uk-tooltip-arrow-offset": `${p?.arrowOffset ?? 0}px`
1082
+ }
1083
+ }
1084
+ ),
1085
+ /* @__PURE__ */ h(
1086
+ V.div,
1087
+ {
1088
+ className: "uk-tooltip__content",
1089
+ initial: { opacity: 0 },
1090
+ animate: { opacity: 1 },
1091
+ transition: u ? H : bt,
1092
+ children: t
1093
+ },
1094
+ e
1095
+ )
1096
+ ]
1097
+ }
1098
+ );
1099
+ }
1100
+ function pe({
1101
+ children: e,
1102
+ side: t = "top",
1103
+ align: n = "center",
1104
+ sideOffset: o = 8,
1105
+ collisionPadding: r = 8,
1106
+ avoidCollisions: a = !0,
1107
+ delayDuration: s = 180,
1108
+ closeDelay: l = 80,
1109
+ contentClassName: d
1110
+ }) {
1111
+ const i = z(), [m, b] = O(
1112
+ () => /* @__PURE__ */ new Map()
1113
+ ), [u, f] = O(!1), [p, g] = O(null), y = _(null), T = _(null), C = et(
1114
+ Nt,
1115
+ Lt,
1116
+ Mt
1117
+ ), c = B(() => {
1118
+ y.current !== null && (clearTimeout(y.current), y.current = null);
1119
+ }, []), w = B(() => {
1120
+ T.current !== null && (clearTimeout(T.current), T.current = null);
1121
+ }, []), I = P(($, M = !1) => {
1122
+ if (c(), w(), g($), !u) {
1123
+ if (M || s <= 0) {
1124
+ f(!0);
1125
+ return;
1126
+ }
1127
+ y.current = setTimeout(() => {
1128
+ y.current = null, f(!0);
1129
+ }, s);
1130
+ }
1131
+ }), k = P(() => {
1132
+ if (c(), w(), !!u) {
1133
+ if (l <= 0) {
1134
+ f(!1);
1135
+ return;
1136
+ }
1137
+ T.current = setTimeout(() => {
1138
+ T.current = null, f(!1);
1139
+ }, l);
1140
+ }
1141
+ }), L = P(() => {
1142
+ c(), w(), f(!1);
1143
+ }), R = P(
1144
+ ($, M, F) => {
1145
+ b((W) => {
1146
+ const lt = W.get($);
1147
+ if (lt?.triggerElement === M && Object.is(lt.content, F))
1148
+ return W;
1149
+ const ut = new Map(W);
1150
+ return ut.set($, { triggerElement: M, content: F }), ut;
1151
+ });
1152
+ }
1153
+ ), x = P(($) => {
1154
+ b((M) => {
1155
+ if (!M.has($))
1156
+ return M;
1157
+ const F = new Map(M);
1158
+ return F.delete($), F;
1159
+ });
1160
+ });
1161
+ S(
1162
+ () => () => {
1163
+ c(), w();
1164
+ },
1165
+ [w, c]
1166
+ );
1167
+ const Ht = X(
1168
+ () => ({
1169
+ open: u,
1170
+ activeValue: p,
1171
+ contentId: i,
1172
+ activate: I,
1173
+ requestClose: k,
1174
+ dismiss: L,
1175
+ register: R,
1176
+ unregister: x
1177
+ }),
1178
+ [
1179
+ I,
1180
+ p,
1181
+ i,
1182
+ L,
1183
+ u,
1184
+ R,
1185
+ k,
1186
+ x
1187
+ ]
1188
+ ), A = p ? m.get(p) : void 0, zt = u && !!A, ct = C && A ? A.triggerElement.closest("dialog") ?? document.body : null;
1189
+ return /* @__PURE__ */ N(Ft.Provider, { value: Ht, children: [
1190
+ e,
1191
+ ct && A ? st(
1192
+ /* @__PURE__ */ h(ot, { reducedMotion: "user", children: /* @__PURE__ */ h(rt, { children: zt ? /* @__PURE__ */ h(
1193
+ de,
1194
+ {
1195
+ activeValue: p ?? "",
1196
+ content: A.content,
1197
+ contentClassName: d,
1198
+ contentId: i,
1199
+ dismiss: L,
1200
+ triggerElement: A.triggerElement,
1201
+ side: t,
1202
+ align: n,
1203
+ sideOffset: o,
1204
+ collisionPadding: r,
1205
+ avoidCollisions: a
1206
+ },
1207
+ "uk-tooltip-group"
1208
+ ) : null }) }),
1209
+ ct
1210
+ ) : null
1211
+ ] });
1212
+ }
1213
+ function fe({
1214
+ value: e,
1215
+ content: t,
1216
+ children: n
1217
+ }) {
1218
+ const o = ue("Tooltip.Item"), { register: r, unregister: a } = o, [s, l] = O(
1219
+ null
1220
+ );
1221
+ if (!tt(n))
1222
+ throw new Error("<Tooltip.Item> expects a single valid React element");
1223
+ const d = n, i = d.props, m = i.ref ?? d.ref, b = i.onPointerEnter, u = i.onPointerLeave, f = i.onFocus, p = i.onBlur, g = i.onKeyDown, y = o.open && o.activeValue === e, T = B(
1224
+ (C) => {
1225
+ St(m, C), l(C);
1226
+ },
1227
+ [m, l]
1228
+ );
1229
+ return nt(() => {
1230
+ if (s)
1231
+ return r(e, s, t), () => a(e);
1232
+ }, [t, r, s, a, e]), J(d, {
1233
+ ref: T,
1234
+ "aria-describedby": y ? $t(i["aria-describedby"], o.contentId) : i["aria-describedby"],
1235
+ onPointerEnter: E(b, (C) => {
1236
+ o.activate(e, C.pointerType === "touch");
1237
+ }),
1238
+ onPointerLeave: E(u, (C) => {
1239
+ C.pointerType !== "touch" && o.requestClose();
1240
+ }),
1241
+ onFocus: E(f, () => {
1242
+ o.activate(e);
1243
+ }),
1244
+ onBlur: E(p, () => {
1245
+ o.requestClose();
1246
+ }),
1247
+ onKeyDown: E(g, (C) => {
1248
+ C.key === "Escape" && y && (C.preventDefault(), C.stopPropagation(), o.dismiss());
1249
+ })
1250
+ });
1251
+ }
1252
+ const xe = {
1253
+ Root: re,
1254
+ Trigger: ie,
1255
+ Content: le,
1256
+ Group: pe,
1257
+ Item: fe
1258
+ };
623
1259
  export {
624
- Y as Button,
625
- $e as Dialog,
626
- Ae as Input,
627
- He as Switch,
628
- Oe as Tabs
1260
+ ht as Button,
1261
+ ve as Dialog,
1262
+ Te as Input,
1263
+ we as Switch,
1264
+ Ce as Tabs,
1265
+ xe as Tooltip
629
1266
  };
630
1267
  //# sourceMappingURL=index.js.map