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