seam-react 0.1.1 → 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,501 +1,1267 @@
1
- import { jsxs as N, jsx as a } from "react/jsx-runtime";
2
- import { forwardRef as L, useId as S, useMemo as j, createContext as F, useContext as U, useRef as x, useSyncExternalStore as K, useEffect as z, useState as Q, useCallback as C } from "react";
3
- import { createPortal as q } from "react-dom";
4
- import { useControllableState as H, useEventCallback as Y, useLockBodyScroll as Z, useFocusTrap as ee } from "seam-hooks";
5
- function y(...t) {
6
- return t.filter(Boolean).join(" ");
7
- }
8
- const te = L(function({
9
- variant: n = "primary",
10
- size: i = "md",
11
- loading: r = !1,
12
- iconOnly: l = !1,
13
- type: u = "button",
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
+ size: n = "md",
12
+ loading: o = !1,
13
+ iconOnly: r = !1,
14
+ type: a = "button",
14
15
  className: s,
15
- children: h,
16
- ...o
17
- }, c) {
16
+ children: l,
17
+ ...d
18
+ }, i) {
18
19
  return /* @__PURE__ */ N(
19
20
  "button",
20
21
  {
21
- ...o,
22
- ref: c,
23
- type: u,
24
- className: y("uk-button", s),
25
- "data-variant": n,
26
- "data-size": i,
27
- "data-loading": r ? "true" : void 0,
28
- "data-icon-only": l ? "true" : void 0,
29
- disabled: o.disabled || r,
30
- "aria-busy": r || void 0,
22
+ ...d,
23
+ ref: i,
24
+ type: a,
25
+ className: v("uk-button", s),
26
+ "data-variant": t,
27
+ "data-size": n,
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,
31
32
  children: [
32
- r ? /* @__PURE__ */ a("span", { className: "uk-button__spinner", "aria-hidden": "true" }) : null,
33
- h
33
+ o ? /* @__PURE__ */ h("span", { className: "uk-button__spinner", "aria-hidden": "true" }) : null,
34
+ l
34
35
  ]
35
36
  }
36
37
  );
37
- }), ke = L(function({
38
- inputSize: n = "md",
39
- invalid: i = !1,
40
- className: r,
41
- "aria-invalid": l,
42
- ...u
38
+ }), Te = D(function({
39
+ inputSize: t = "md",
40
+ invalid: n = !1,
41
+ className: o,
42
+ "aria-invalid": r,
43
+ ...a
43
44
  }, s) {
44
- return /* @__PURE__ */ a(
45
+ return /* @__PURE__ */ h(
45
46
  "input",
46
47
  {
47
- ...u,
48
+ ...a,
48
49
  ref: s,
49
- className: y("uk-input", r),
50
- "data-size": n,
51
- "aria-invalid": i ? !0 : l
50
+ className: v("uk-input", o),
51
+ "data-size": t,
52
+ "aria-invalid": n ? !0 : r
52
53
  }
53
54
  );
54
- }), Te = L(function({
55
- checked: n,
56
- defaultChecked: i,
57
- onCheckedChange: r,
58
- disabled: l,
59
- className: u,
55
+ }), U = [0.23, 1, 0.32, 1], pt = {
56
+ type: "spring",
57
+ bounce: 0,
58
+ duration: 0.3
59
+ }, ft = {
60
+ type: "spring",
61
+ bounce: 0.04,
62
+ duration: 0.38
63
+ }, Ut = {
64
+ type: "spring",
65
+ bounce: 0.08,
66
+ duration: 0.34
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 = {
75
+ duration: 0.12,
76
+ ease: U
77
+ }, we = D(function({
78
+ checked: t,
79
+ defaultChecked: n,
80
+ onCheckedChange: o,
81
+ disabled: r,
82
+ className: a,
60
83
  children: s,
61
- id: h,
62
- ...o
63
- }, c) {
64
- const m = S(), g = h ?? m, [_, v] = H({
65
- value: n,
66
- defaultValue: i ?? !1,
67
- onChange: r
68
- });
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,
89
+ defaultValue: n ?? !1,
90
+ onChange: o
91
+ }), T = Kt(g ? 16 : 0);
92
+ S(() => {
93
+ if (p.current)
94
+ return;
95
+ const c = dt(
96
+ T,
97
+ g ? 16 : 0,
98
+ u ? { duration: 0 } : pt
99
+ );
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 }
111
+ ), window.setTimeout(() => {
112
+ f.current = !1;
113
+ }, 0);
114
+ } else
115
+ p.current = null;
116
+ c.currentTarget.hasPointerCapture(c.pointerId) && typeof c.currentTarget.releasePointerCapture == "function" && c.currentTarget.releasePointerCapture(c.pointerId);
117
+ }
118
+ };
69
119
  return /* @__PURE__ */ N(
70
120
  "label",
71
121
  {
72
- className: y("uk-switch", u),
73
- "data-disabled": l ? "true" : void 0,
74
- htmlFor: g,
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());
127
+ },
75
128
  children: [
76
- /* @__PURE__ */ a(
129
+ /* @__PURE__ */ h(
77
130
  "input",
78
131
  {
79
- ...o,
80
- ref: c,
81
- id: g,
132
+ ...d,
133
+ ref: i,
134
+ id: b,
82
135
  type: "checkbox",
83
136
  role: "switch",
84
137
  className: "uk-switch__input",
85
- checked: _,
86
- disabled: l,
87
- "aria-checked": _,
88
- onChange: (p) => v(p.target.checked)
138
+ checked: g,
139
+ disabled: r,
140
+ "aria-checked": g,
141
+ onChange: (c) => y(c.target.checked)
89
142
  }
90
143
  ),
91
- /* @__PURE__ */ a("span", { className: "uk-switch__track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { className: "uk-switch__thumb" }) }),
92
- s ? /* @__PURE__ */ a("span", { className: "uk-switch__label", children: s }) : null
144
+ /* @__PURE__ */ h(
145
+ "span",
146
+ {
147
+ className: "uk-switch__track",
148
+ "aria-hidden": "true",
149
+ onPointerDown: (c) => {
150
+ r || (p.current = {
151
+ pointerId: c.pointerId,
152
+ startX: c.clientX,
153
+ startValue: T.get(),
154
+ moved: !1,
155
+ samples: [{ x: c.clientX, time: performance.now() }]
156
+ }, typeof c.currentTarget.setPointerCapture == "function" && c.currentTarget.setPointerCapture(c.pointerId));
157
+ },
158
+ onPointerMove: (c) => {
159
+ const w = p.current;
160
+ if (!w || w.pointerId !== c.pointerId)
161
+ return;
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
165
+ ));
166
+ },
167
+ onPointerUp: C,
168
+ onPointerCancel: C,
169
+ children: /* @__PURE__ */ h(V.span, { className: "uk-switch__thumb", style: { x: T } })
170
+ }
171
+ ),
172
+ s ? /* @__PURE__ */ h("span", { className: "uk-switch__label", children: s }) : null
93
173
  ]
94
174
  }
95
175
  );
96
- }), O = F(null);
97
- function V(t) {
98
- const n = U(O);
99
- if (!n)
100
- throw new Error(`<${t}> must be rendered inside <Tabs>`);
101
- return n;
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;
102
182
  }
103
- function W(t, n) {
104
- return `${t}-tab-${encodeURIComponent(n)}`;
183
+ function yt(e, t) {
184
+ return `${e}-tab-${encodeURIComponent(t)}`;
105
185
  }
106
- function X(t, n) {
107
- return `${t}-panel-${encodeURIComponent(n)}`;
186
+ function Tt(e, t) {
187
+ return `${e}-panel-${encodeURIComponent(t)}`;
108
188
  }
109
- function ne({
110
- value: t,
111
- defaultValue: n,
112
- onValueChange: i,
113
- orientation: r = "horizontal",
114
- className: l,
115
- children: u
189
+ function jt({
190
+ value: e,
191
+ defaultValue: t,
192
+ onValueChange: n,
193
+ orientation: o = "horizontal",
194
+ className: r,
195
+ children: a
116
196
  }) {
117
- const s = S(), [h, o] = H({
118
- value: t,
119
- defaultValue: n ?? "",
120
- onChange: i
121
- }), c = j(
122
- () => ({ baseId: s, value: h, setValue: o, orientation: r }),
123
- [s, h, r, o]
197
+ const s = z(), [l, d] = Q({
198
+ value: e,
199
+ defaultValue: t ?? "",
200
+ onChange: n
201
+ }), i = X(
202
+ () => ({
203
+ baseId: s,
204
+ value: l,
205
+ setValue: d,
206
+ orientation: o,
207
+ indicatorId: `${s}-indicator`
208
+ }),
209
+ [s, l, o, d]
124
210
  );
125
- return /* @__PURE__ */ a(O.Provider, { value: c, children: /* @__PURE__ */ a("div", { className: y("uk-tabs", l), "data-orientation": r, children: u }) });
211
+ return /* @__PURE__ */ h(gt.Provider, { value: i, children: /* @__PURE__ */ h("div", { className: v("uk-tabs", r), "data-orientation": o, children: a }) });
126
212
  }
127
- const re = L(function({ className: n, onKeyDown: i, ...r }, l) {
128
- const { orientation: u } = V("Tabs.List");
129
- return /* @__PURE__ */ a(
213
+ const Yt = D(function({ className: t, onKeyDown: n, ...o }, r) {
214
+ const { orientation: a } = at("Tabs.List");
215
+ return /* @__PURE__ */ h(
130
216
  "div",
131
217
  {
132
- ...r,
133
- ref: l,
218
+ ...o,
219
+ ref: r,
134
220
  role: "tablist",
135
- "aria-orientation": u,
221
+ "aria-orientation": a,
136
222
  tabIndex: -1,
137
- className: y("uk-tabs__list", n),
223
+ className: v("uk-tabs__list", t),
138
224
  onKeyDown: (s) => {
139
- if (i?.(s), s.defaultPrevented)
225
+ if (n?.(s), s.defaultPrevented)
140
226
  return;
141
- const o = s.target?.closest('[role="tab"]');
142
- if (!o || o.hasAttribute("disabled"))
227
+ const d = s.target?.closest('[role="tab"]');
228
+ if (!d || d.hasAttribute("disabled"))
143
229
  return;
144
- const c = Array.from(
230
+ const i = Array.from(
145
231
  s.currentTarget.querySelectorAll(
146
232
  '[role="tab"]:not([disabled])'
147
233
  )
148
- ), m = c.indexOf(o);
234
+ ), m = i.indexOf(d);
149
235
  if (m === -1)
150
236
  return;
151
- const g = u === "horizontal" ? "ArrowRight" : "ArrowDown", _ = u === "horizontal" ? "ArrowLeft" : "ArrowUp";
152
- let v = -1;
237
+ const b = a === "horizontal" ? "ArrowRight" : "ArrowDown", u = a === "horizontal" ? "ArrowLeft" : "ArrowUp";
238
+ let f = -1;
153
239
  switch (s.key) {
154
- case g:
155
- v = (m + 1) % c.length;
240
+ case b:
241
+ f = (m + 1) % i.length;
156
242
  break;
157
- case _:
158
- v = (m - 1 + c.length) % c.length;
243
+ case u:
244
+ f = (m - 1 + i.length) % i.length;
159
245
  break;
160
246
  case "Home":
161
- v = 0;
247
+ f = 0;
162
248
  break;
163
249
  case "End":
164
- v = c.length - 1;
250
+ f = i.length - 1;
165
251
  break;
166
252
  default:
167
253
  return;
168
254
  }
169
255
  s.preventDefault();
170
- const p = c[v];
256
+ const p = i[f];
171
257
  p && (p.focus(), p.click());
172
258
  }
173
259
  }
174
260
  );
175
- }), ae = L(function({ value: n, type: i = "button", className: r, onClick: l, ...u }, s) {
176
- const h = V("Tabs.Trigger"), o = h.value === n;
177
- return /* @__PURE__ */ a(
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;
263
+ return /* @__PURE__ */ N(
178
264
  "button",
179
265
  {
180
- ...u,
181
- ref: s,
182
- type: i,
266
+ ...s,
267
+ ref: l,
268
+ type: n,
183
269
  role: "tab",
184
- id: W(h.baseId, n),
185
- "aria-selected": o,
186
- "aria-controls": X(h.baseId, n),
187
- tabIndex: o ? 0 : -1,
188
- "data-state": o ? "active" : "inactive",
189
- className: y("uk-tabs__trigger", r),
190
- onClick: (c) => {
191
- l?.(c), c.defaultPrevented || h.setValue(n);
192
- }
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);
278
+ },
279
+ children: [
280
+ a,
281
+ i ? /* @__PURE__ */ h(
282
+ V.span,
283
+ {
284
+ className: "uk-tabs__indicator",
285
+ layoutId: d.indicatorId,
286
+ "aria-hidden": "true",
287
+ transition: m ? { duration: 0 } : Ut
288
+ }
289
+ ) : null
290
+ ]
193
291
  }
194
292
  );
195
- }), se = L(function({ value: n, className: i, ...r }, l) {
196
- const u = V("Tabs.Content"), s = u.value === n;
197
- return /* @__PURE__ */ a(
293
+ }), Qt = D(function({ value: t, className: n, ...o }, r) {
294
+ const a = at("Tabs.Content"), s = a.value === t;
295
+ return /* @__PURE__ */ h(
198
296
  "div",
199
297
  {
200
- ...r,
201
- ref: l,
298
+ ...o,
299
+ ref: r,
202
300
  role: "tabpanel",
203
- id: X(u.baseId, n),
204
- "aria-labelledby": W(u.baseId, n),
301
+ id: Tt(a.baseId, t),
302
+ "aria-labelledby": yt(a.baseId, t),
205
303
  hidden: !s,
206
304
  tabIndex: 0,
207
305
  "data-state": s ? "active" : "inactive",
208
- className: y("uk-tabs__panel", i)
306
+ className: v("uk-tabs__panel", n)
209
307
  }
210
308
  );
211
- }), _e = Object.assign(ne, {
212
- List: re,
213
- Trigger: ae,
214
- Content: se
215
- }), oe = () => () => {
216
- }, ie = () => !0, ce = () => !1;
217
- function Ce({
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) {
322
+ return (n) => {
323
+ e?.(n), n.defaultPrevented || t(n);
324
+ };
325
+ }
326
+ function vt({
327
+ children: e,
218
328
  open: t,
219
- onOpenChange: n,
220
- title: i,
221
- description: r,
222
- footer: l,
223
- children: u,
329
+ defaultOpen: n,
330
+ onOpenChange: o
331
+ }) {
332
+ const r = z(), [a, s] = O(!1), [l, d] = O(!1), [i, m] = Q({
333
+ value: t,
334
+ defaultValue: n ?? !1,
335
+ onChange: o
336
+ }), b = X(
337
+ () => ({
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
348
+ }),
349
+ [r, i, l, a, m]
350
+ );
351
+ return /* @__PURE__ */ h(wt.Provider, { value: b, children: e });
352
+ }
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,
357
+ "aria-haspopup": "dialog",
358
+ "aria-expanded": t.open,
359
+ "aria-controls": t.open ? t.contentId : void 0,
360
+ onClick: Ct(o, () => {
361
+ t.setOpen(!t.open);
362
+ })
363
+ });
364
+ }
365
+ function xt({
366
+ children: e,
367
+ label: t = "Close"
368
+ }) {
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, () => {
374
+ n.setOpen(!1);
375
+ })
376
+ });
377
+ }
378
+ return /* @__PURE__ */ h(ht, { variant: "ghost", onClick: () => n.setOpen(!1), children: t });
379
+ }
380
+ const It = D(function({ className: t, ...n }, o) {
381
+ return /* @__PURE__ */ h(
382
+ "header",
383
+ {
384
+ ...n,
385
+ ref: o,
386
+ className: v("uk-dialog__header", t)
387
+ }
388
+ );
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(
392
+ "h2",
393
+ {
394
+ ...o,
395
+ ref: r,
396
+ id: a.titleId,
397
+ className: v("uk-dialog__title", t),
398
+ children: n
399
+ }
400
+ );
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(
405
+ "p",
406
+ {
407
+ ...n,
408
+ ref: o,
409
+ id: r.descriptionId,
410
+ className: v("uk-dialog__description", t)
411
+ }
412
+ );
413
+ }
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(
418
+ "footer",
419
+ {
420
+ ...n,
421
+ ref: o,
422
+ className: v("uk-dialog__footer", t)
423
+ }
424
+ );
425
+ });
426
+ function ne({
427
+ requestClose: e,
428
+ contentId: t,
429
+ titleId: n,
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
442
+ }) {
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({
448
+ active: !0,
449
+ containerRef: g,
450
+ initialFocusRef: i,
451
+ returnFocusRef: m ?? y
452
+ }), S(() => {
453
+ const c = g.current;
454
+ if (!c)
455
+ return;
456
+ const w = () => {
457
+ c.open || (typeof c.showModal == "function" ? c.showModal() : c.setAttribute("open", ""));
458
+ }, I = () => {
459
+ if (!d) {
460
+ w();
461
+ return;
462
+ }
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();
470
+ };
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);
473
+ };
474
+ }, [l, d, e]), /* @__PURE__ */ h(
475
+ "dialog",
476
+ {
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,
488
+ {
489
+ className: "uk-dialog__panel",
490
+ initial: C ? { opacity: 0 } : {
491
+ opacity: 0,
492
+ transform: "translateY(12px) scale(0.96)"
493
+ },
494
+ animate: {
495
+ opacity: 1,
496
+ transform: "translateY(0px) scale(1)",
497
+ transition: C ? H : { ...ft, delay: 0.06 }
498
+ },
499
+ exit: C ? { opacity: 0, transition: H } : {
500
+ opacity: 0,
501
+ transform: "translateY(8px) scale(0.97)",
502
+ transition: ft
503
+ },
504
+ children: s
505
+ }
506
+ )
507
+ }
508
+ );
509
+ }
510
+ function Rt({
511
+ children: e,
512
+ closeOnBackdropClick: t = !0,
513
+ closeOnEscape: n = !0,
514
+ initialFocusRef: o,
515
+ returnFocusRef: r,
516
+ className: a,
517
+ "aria-label": s,
518
+ "aria-labelledby": l,
519
+ "aria-describedby": d
520
+ }) {
521
+ const i = G("Dialog.Content"), m = P(() => {
522
+ i.setOpen(!1);
523
+ });
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,
531
+ {
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,
539
+ closeOnEscape: n,
540
+ initialFocusRef: o,
541
+ returnFocusRef: r,
542
+ className: a,
543
+ "aria-label": s,
544
+ "aria-labelledby": l,
545
+ "aria-describedby": d,
546
+ children: e
547
+ },
548
+ "uk-dialog"
549
+ ) : null }) }),
550
+ document.body
551
+ ) : null;
552
+ }
553
+ function oe({
554
+ open: e,
555
+ onOpenChange: t,
556
+ title: n,
557
+ description: o,
558
+ footer: r,
559
+ children: a,
224
560
  closeLabel: s = "Close",
225
- showCloseButton: h = !0,
226
- closeOnBackdropClick: o = !0,
227
- closeOnEscape: c = !0,
561
+ showCloseButton: l = !0,
562
+ closeOnBackdropClick: d = !0,
563
+ closeOnEscape: i = !0,
228
564
  initialFocusRef: m,
229
- returnFocusRef: g,
230
- className: _,
231
- "aria-label": v
565
+ returnFocusRef: b,
566
+ className: u,
567
+ "aria-label": f
568
+ }) {
569
+ return /* @__PURE__ */ h(vt, { open: e, onOpenChange: t, children: /* @__PURE__ */ N(
570
+ Rt,
571
+ {
572
+ className: u,
573
+ closeOnBackdropClick: d,
574
+ closeOnEscape: i,
575
+ initialFocusRef: m,
576
+ returnFocusRef: b,
577
+ "aria-label": f,
578
+ children: [
579
+ n || o || l ? /* @__PURE__ */ N(It, { children: [
580
+ /* @__PURE__ */ N("div", { className: "uk-dialog__heading", children: [
581
+ n ? /* @__PURE__ */ h(kt, { children: n }) : null,
582
+ o ? /* @__PURE__ */ h(Dt, { children: o }) : null
583
+ ] }),
584
+ l ? /* @__PURE__ */ h(xt, { children: /* @__PURE__ */ h(
585
+ ht,
586
+ {
587
+ variant: "ghost",
588
+ size: "sm",
589
+ iconOnly: !0,
590
+ "aria-label": s,
591
+ className: "uk-dialog__close",
592
+ children: /* @__PURE__ */ h(
593
+ "svg",
594
+ {
595
+ viewBox: "0 0 20 20",
596
+ width: "16",
597
+ height: "16",
598
+ "aria-hidden": "true",
599
+ children: /* @__PURE__ */ h(
600
+ "path",
601
+ {
602
+ d: "M5 5l10 10M15 5L5 15",
603
+ stroke: "currentColor",
604
+ strokeWidth: "1.8",
605
+ strokeLinecap: "round"
606
+ }
607
+ )
608
+ }
609
+ )
610
+ }
611
+ ) }) : null
612
+ ] }) : null,
613
+ /* @__PURE__ */ h(Et, { children: a }),
614
+ r ? /* @__PURE__ */ h(_t, { children: r }) : null
615
+ ]
616
+ }
617
+ ) });
618
+ }
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
232
656
  }) {
233
- const p = x(null), w = x(null), k = x(t), R = S(), T = S(), E = K(
234
- oe,
235
- ie,
236
- ce
237
- ), I = Y(() => {
238
- k.current && n(!1);
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
+ })
239
740
  });
240
- return Z(t), z(() => {
241
- k.current = t;
242
- }, [t]), z(() => {
243
- const d = p.current;
244
- d && (t && !d.open ? (w.current = document.activeElement instanceof HTMLElement ? document.activeElement : null, typeof d.showModal == "function" ? d.showModal() : d.setAttribute("open", "")) : !t && d.open && (typeof d.close == "function" ? d.close() : d.removeAttribute("open")));
245
- }, [t]), ee({
246
- active: t,
247
- containerRef: p,
248
- initialFocusRef: m,
249
- returnFocusRef: g ?? w
250
- }), z(() => {
251
- const d = p.current;
252
- if (!d)
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)
253
865
  return;
254
- const A = () => I(), M = (e) => {
255
- c || e.preventDefault();
256
- }, $ = (e) => {
257
- o && e.target === d && I();
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
+ );
258
881
  };
259
- return d.addEventListener("close", A), d.addEventListener("cancel", M), d.addEventListener("click", $), () => {
260
- d.removeEventListener("close", A), d.removeEventListener("cancel", M), d.removeEventListener("click", $);
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();
261
886
  };
262
- }, [o, c, I]), E ? q(
263
- /* @__PURE__ */ a(
264
- "dialog",
265
- {
266
- ref: p,
267
- className: y("uk-dialog", _),
268
- "aria-label": v,
269
- "aria-labelledby": i ? R : void 0,
270
- "aria-describedby": r ? T : void 0,
271
- children: /* @__PURE__ */ N("div", { className: "uk-dialog__panel", children: [
272
- i || r || h ? /* @__PURE__ */ N("header", { className: "uk-dialog__header", children: [
273
- /* @__PURE__ */ N("div", { className: "uk-dialog__heading", children: [
274
- i ? /* @__PURE__ */ a("h2", { id: R, className: "uk-dialog__title", children: i }) : null,
275
- r ? /* @__PURE__ */ a("p", { id: T, className: "uk-dialog__description", children: r }) : null
276
- ] }),
277
- h ? /* @__PURE__ */ a(
278
- te,
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",
279
980
  {
280
- variant: "ghost",
281
- size: "sm",
282
- iconOnly: !0,
283
- "aria-label": s,
284
- className: "uk-dialog__close",
285
- onClick: I,
286
- children: /* @__PURE__ */ a(
287
- "svg",
288
- {
289
- viewBox: "0 0 20 20",
290
- width: "16",
291
- height: "16",
292
- "aria-hidden": "true",
293
- children: /* @__PURE__ */ a(
294
- "path",
295
- {
296
- d: "M5 5l10 10M15 5L5 15",
297
- stroke: "currentColor",
298
- strokeWidth: "1.8",
299
- strokeLinecap: "round"
300
- }
301
- )
302
- }
303
- )
981
+ className: "uk-tooltip__arrow",
982
+ "aria-hidden": "true",
983
+ style: {
984
+ "--uk-tooltip-arrow-offset": `${g?.arrowOffset ?? 0}px`
985
+ }
304
986
  }
305
- ) : null
306
- ] }) : null,
307
- /* @__PURE__ */ a("div", { className: "uk-dialog__body", children: u }),
308
- l ? /* @__PURE__ */ a("footer", { className: "uk-dialog__footer", children: l }) : null
309
- ] })
310
- }
311
- ),
312
- document.body
313
- ) : null;
987
+ ),
988
+ o
989
+ ]
990
+ }
991
+ )
992
+ }
993
+ );
314
994
  }
315
- const G = F(null), le = 200, ue = () => () => {
316
- }, de = () => !0, fe = () => !1;
317
- function he({
318
- record: t,
319
- closeLabel: n,
320
- onDismiss: i,
321
- onPause: r,
322
- onResume: l
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
323
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
+ };
324
1051
  return /* @__PURE__ */ N(
325
- "div",
1052
+ V.div,
326
1053
  {
327
- className: "uk-toast",
328
- "data-variant": t.variant,
329
- "data-state": t.leaving ? "closed" : "open",
330
- onMouseEnter: () => r(t.id),
331
- onMouseLeave: () => l(t.id),
332
- onFocusCapture: () => r(t.id),
333
- onBlurCapture: () => l(t.id),
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,
334
1074
  children: [
335
- /* @__PURE__ */ N("div", { className: "uk-toast__body", children: [
336
- t.title ? /* @__PURE__ */ a("div", { className: "uk-toast__title", children: t.title }) : null,
337
- t.description ? /* @__PURE__ */ a("div", { className: "uk-toast__description", children: t.description }) : null
338
- ] }),
339
- /* @__PURE__ */ a(
340
- "button",
1075
+ /* @__PURE__ */ h(
1076
+ "span",
341
1077
  {
342
- type: "button",
343
- className: "uk-toast__close",
344
- "aria-label": n,
345
- onClick: () => i(t.id),
346
- children: /* @__PURE__ */ a("svg", { viewBox: "0 0 20 20", width: "14", height: "14", "aria-hidden": "true", children: /* @__PURE__ */ a(
347
- "path",
348
- {
349
- d: "M5 5l10 10M15 5L5 15",
350
- stroke: "currentColor",
351
- strokeWidth: "1.8",
352
- strokeLinecap: "round"
353
- }
354
- ) })
1078
+ className: "uk-tooltip__arrow",
1079
+ "aria-hidden": "true",
1080
+ style: {
1081
+ "--uk-tooltip-arrow-offset": `${p?.arrowOffset ?? 0}px`
1082
+ }
355
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
356
1095
  )
357
1096
  ]
358
1097
  }
359
1098
  );
360
1099
  }
361
- function we({
362
- children: t,
363
- placement: n = "top-right",
364
- duration: i = 4e3,
365
- maxToasts: r = 4,
366
- label: l = "Notifications",
367
- closeLabel: u = "Close"
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
368
1110
  }) {
369
- const [s, h] = Q([]), o = x([]), c = x(/* @__PURE__ */ new Map()), m = x(
370
- /* @__PURE__ */ new Map()
371
- ), g = x(
372
- /* @__PURE__ */ new Map()
373
- ), _ = x(0), v = S(), p = K(
374
- ue,
375
- de,
376
- fe
377
- ), w = C((e) => {
378
- o.current = e, h(e);
379
- }, []), k = C((e) => {
380
- const f = m.current.get(e);
381
- f !== void 0 && (clearTimeout(f), m.current.delete(e));
382
- }, []), R = C((e) => {
383
- const f = g.current.get(e);
384
- f !== void 0 && (clearTimeout(f), g.current.delete(e));
385
- }, []), T = C(
386
- (e) => {
387
- k(e), !(g.current.has(e) || !o.current.some((b) => b.id === e)) && (w(
388
- o.current.map(
389
- (b) => b.id === e ? { ...b, leaving: !0 } : b
390
- )
391
- ), g.current.set(
392
- e,
393
- setTimeout(() => {
394
- g.current.delete(e), c.current.delete(e), w(o.current.filter((b) => b.id !== e));
395
- }, le)
396
- ));
397
- },
398
- [k, w]
399
- ), E = C(
400
- (e, f) => {
401
- k(e), !(f <= 0) && m.current.set(
402
- e,
403
- setTimeout(() => {
404
- m.current.delete(e), T(e);
405
- }, f)
406
- );
407
- },
408
- [k, T]
409
- ), I = C(
410
- (e) => {
411
- const f = `${v}-${_.current}`;
412
- _.current += 1;
413
- const b = {
414
- id: f,
415
- title: e.title,
416
- description: e.description,
417
- variant: e.variant ?? "info",
418
- duration: e.duration ?? i,
419
- leaving: !1
420
- }, D = [...o.current, b], P = Math.max(0, D.length - r);
421
- (P > 0 ? D.slice(0, P) : []).forEach((B) => {
422
- k(B.id), R(B.id), c.current.delete(B.id);
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;
423
1151
  });
424
- const J = P > 0 ? D.slice(P) : D;
425
- return c.current.set(f, b.duration), w(J), E(f, b.duration), f;
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();
426
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
+ }),
427
1178
  [
428
- v,
429
- k,
430
- R,
431
- w,
1179
+ I,
1180
+ p,
432
1181
  i,
433
- r,
434
- E
1182
+ L,
1183
+ u,
1184
+ R,
1185
+ k,
1186
+ x
435
1187
  ]
436
- ), d = C(
437
- (e) => {
438
- k(e);
439
- },
440
- [k]
441
- ), A = C(
442
- (e) => {
443
- const f = c.current.get(e);
444
- f !== void 0 && E(e, f);
445
- },
446
- [E]
447
- ), M = C(() => {
448
- o.current.forEach((e) => T(e.id));
449
- }, [T]), $ = j(
450
- () => ({ toast: I, dismiss: T, dismissAll: M }),
451
- [T, M, I]
452
- );
453
- return z(() => {
454
- const e = m.current, f = g.current;
455
- return () => {
456
- e.forEach((b) => clearTimeout(b)), f.forEach((b) => clearTimeout(b)), e.clear(), f.clear();
457
- };
458
- }, []), /* @__PURE__ */ N(G.Provider, { value: $, children: [
459
- t,
460
- p ? q(
461
- /* @__PURE__ */ a(
462
- "section",
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,
463
1194
  {
464
- className: "uk-toast-viewport",
465
- "data-placement": n,
466
- "aria-label": l,
467
- "aria-live": "polite",
468
- "aria-atomic": "false",
469
- children: s.map((e) => /* @__PURE__ */ a(
470
- he,
471
- {
472
- record: e,
473
- closeLabel: u,
474
- onDismiss: T,
475
- onPause: d,
476
- onResume: A
477
- },
478
- e.id
479
- ))
480
- }
481
- ),
482
- document.body
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
483
1210
  ) : null
484
1211
  ] });
485
1212
  }
486
- function xe() {
487
- const t = U(G);
488
- if (!t)
489
- throw new Error("useToast must be used within <ToastProvider>");
490
- return t;
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
+ });
491
1251
  }
1252
+ const xe = {
1253
+ Root: re,
1254
+ Trigger: ie,
1255
+ Content: le,
1256
+ Group: pe,
1257
+ Item: fe
1258
+ };
492
1259
  export {
493
- te as Button,
494
- Ce as Dialog,
495
- ke as Input,
496
- Te as Switch,
497
- _e as Tabs,
498
- we as ToastProvider,
499
- xe as useToast
1260
+ ht as Button,
1261
+ ve as Dialog,
1262
+ Te as Input,
1263
+ we as Switch,
1264
+ Ce as Tabs,
1265
+ xe as Tooltip
500
1266
  };
501
1267
  //# sourceMappingURL=index.js.map