@ohseungik/maru-ui 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +52 -2
  3. package/dist/components/Button/Button.d.ts +16 -0
  4. package/dist/components/Button/index.d.ts +2 -0
  5. package/dist/components/Checkbox/Checkbox.d.ts +17 -0
  6. package/dist/components/Checkbox/index.d.ts +2 -0
  7. package/dist/components/Dialog/Dialog.d.ts +29 -0
  8. package/dist/components/Dialog/index.d.ts +2 -0
  9. package/dist/components/Field/Field.d.ts +14 -0
  10. package/dist/components/Field/FieldContext.d.ts +12 -0
  11. package/dist/components/Field/index.d.ts +2 -0
  12. package/dist/components/Heading/Heading.d.ts +12 -0
  13. package/dist/components/Heading/index.d.ts +2 -0
  14. package/dist/components/Input/Input.d.ts +16 -0
  15. package/dist/components/Input/index.d.ts +2 -0
  16. package/dist/components/Select/Select.d.ts +23 -0
  17. package/dist/components/Select/index.d.ts +2 -0
  18. package/dist/components/Stack/Stack.d.ts +16 -0
  19. package/dist/components/Stack/index.d.ts +2 -0
  20. package/dist/components/Switch/Switch.d.ts +13 -0
  21. package/dist/components/Switch/index.d.ts +2 -0
  22. package/dist/components/Tabs/Tab.d.ts +10 -0
  23. package/dist/components/Tabs/TabList.d.ts +8 -0
  24. package/dist/components/Tabs/TabPanel.d.ts +11 -0
  25. package/dist/components/Tabs/Tabs.d.ts +25 -0
  26. package/dist/components/Tabs/TabsContext.d.ts +16 -0
  27. package/dist/components/Tabs/index.d.ts +9 -0
  28. package/dist/components/Text/Text.d.ts +13 -0
  29. package/dist/components/Text/index.d.ts +2 -0
  30. package/dist/components/Tooltip/Tooltip.d.ts +37 -0
  31. package/dist/components/Tooltip/index.d.ts +3 -0
  32. package/dist/components/Tooltip/position.d.ts +28 -0
  33. package/dist/index.d.ts +24 -0
  34. package/dist/index.js +663 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/styles.css +1 -0
  37. package/dist/utils/cx.d.ts +4 -0
  38. package/package.json +62 -3
package/dist/index.js ADDED
@@ -0,0 +1,663 @@
1
+ "use client";
2
+ import { jsxs as g, jsx as l, Fragment as W } from "react/jsx-runtime";
3
+ import { forwardRef as $, useRef as L, useCallback as j, useEffect as D, useId as A, createContext as Q, useContext as X, useState as G, useMemo as ce, Children as ie, isValidElement as le, cloneElement as de, useLayoutEffect as ue } from "react";
4
+ function N(...r) {
5
+ return r.filter(Boolean).join(" ");
6
+ }
7
+ const me = "maru-Button-module__root__Q2R8-", fe = "maru-Button-module__spinner__ZExvW", Y = {
8
+ root: me,
9
+ spinner: fe
10
+ }, at = $(function({
11
+ variant: e = "primary",
12
+ size: o = "md",
13
+ loading: n = !1,
14
+ type: t = "button",
15
+ disabled: s = !1,
16
+ className: m,
17
+ children: c,
18
+ ...i
19
+ }, d) {
20
+ return /* @__PURE__ */ g(
21
+ "button",
22
+ {
23
+ ...i,
24
+ ref: d,
25
+ type: t,
26
+ className: N(Y.root, m),
27
+ "data-variant": e,
28
+ "data-size": o,
29
+ "data-loading": n ? "" : void 0,
30
+ disabled: s || n,
31
+ "aria-busy": n ? !0 : void 0,
32
+ children: [
33
+ n ? /* @__PURE__ */ l("span", { className: Y.spinner, "aria-hidden": "true" }) : null,
34
+ c
35
+ ]
36
+ }
37
+ );
38
+ }), he = "maru-Checkbox-module__root__mY3qk", _e = "maru-Checkbox-module__control__PxoNk", be = "maru-Checkbox-module__input__2kt-h", pe = "maru-Checkbox-module__box__OCPee", M = {
39
+ root: he,
40
+ control: _e,
41
+ input: be,
42
+ box: pe
43
+ }, ct = $(function({ size: e = "md", indeterminate: o = !1, invalid: n = !1, disabled: t, className: s, children: m, ...c }, i) {
44
+ const d = L(null), _ = j(
45
+ (h) => {
46
+ d.current = h, typeof i == "function" ? i(h) : i && (i.current = h);
47
+ },
48
+ [i]
49
+ );
50
+ return D(() => {
51
+ d.current && (d.current.indeterminate = o);
52
+ }), /* @__PURE__ */ g(
53
+ "label",
54
+ {
55
+ className: N(M.root, s),
56
+ "data-size": e,
57
+ "data-disabled": t ? "" : void 0,
58
+ children: [
59
+ /* @__PURE__ */ g("span", { className: M.control, children: [
60
+ /* @__PURE__ */ l(
61
+ "input",
62
+ {
63
+ ...c,
64
+ ref: _,
65
+ type: "checkbox",
66
+ className: M.input,
67
+ disabled: t,
68
+ "data-invalid": n ? "" : void 0,
69
+ "aria-invalid": n ? !0 : void 0
70
+ }
71
+ ),
72
+ /* @__PURE__ */ l("span", { className: M.box, "aria-hidden": "true" })
73
+ ] }),
74
+ m ? /* @__PURE__ */ l("span", { className: M.label, children: m }) : null
75
+ ]
76
+ }
77
+ );
78
+ }), ve = "maru-Heading-module__root__-To4U", ye = {
79
+ root: ve
80
+ }, we = {
81
+ 1: "4xl",
82
+ 2: "3xl",
83
+ 3: "2xl",
84
+ 4: "xl",
85
+ 5: "lg",
86
+ 6: "md"
87
+ }, xe = $(function({ level: e, size: o, tone: n = "default", className: t, ...s }, m) {
88
+ const c = `h${e}`;
89
+ return /* @__PURE__ */ l(
90
+ c,
91
+ {
92
+ ...s,
93
+ ref: m,
94
+ className: N(ye.root, t),
95
+ "data-size": o ?? we[e],
96
+ "data-tone": n
97
+ }
98
+ );
99
+ }), ke = "maru-Dialog-module__root__tvkOF", Ne = "maru-Dialog-module__panel__b2y0S", $e = "maru-Dialog-module__header__bdJRp", ge = "maru-Dialog-module__title__glVA6", Te = "maru-Dialog-module__description__6Bsa9", Ee = "maru-Dialog-module__body__1ZbVo", Ce = "maru-Dialog-module__actions__JRD2K", Le = "maru-Dialog-module__close__Zz2uv", C = {
100
+ root: ke,
101
+ panel: Ne,
102
+ header: $e,
103
+ title: ge,
104
+ description: Te,
105
+ body: Ee,
106
+ actions: Ce,
107
+ close: Le
108
+ };
109
+ let q = 0, ee = "";
110
+ function Ie() {
111
+ q === 0 && (ee = document.body.style.overflow, document.body.style.overflow = "hidden"), q += 1;
112
+ }
113
+ function Be() {
114
+ q = Math.max(0, q - 1), q === 0 && (document.body.style.overflow = ee);
115
+ }
116
+ const it = $(function({
117
+ open: e,
118
+ onClose: o,
119
+ title: n,
120
+ description: t,
121
+ actions: s,
122
+ size: m = "md",
123
+ closeOnBackdropClick: c = !0,
124
+ closeLabel: i = "Close",
125
+ initialFocusRef: d,
126
+ keepMounted: _ = !1,
127
+ className: h,
128
+ children: v,
129
+ ...b
130
+ }, p) {
131
+ const y = A(), x = `${y}-title`, f = `${y}-description`, T = L(null), k = L(o), u = L(e), w = L(c);
132
+ D(() => {
133
+ k.current = o, u.current = e, w.current = c;
134
+ });
135
+ const P = j(
136
+ (a) => {
137
+ T.current = a, typeof p == "function" ? p(a) : p && (p.current = a);
138
+ },
139
+ [p]
140
+ ), I = e || _;
141
+ return D(() => {
142
+ const a = T.current;
143
+ if (!a || !e) return;
144
+ const B = document.activeElement instanceof HTMLElement ? document.activeElement : null;
145
+ return a.open || a.showModal(), Ie(), d?.current && d.current.focus(), () => {
146
+ Be(), a.open && a.close();
147
+ const E = document.activeElement, S = !E || E === document.body || a.contains(E);
148
+ B?.isConnected && S && B.focus();
149
+ };
150
+ }, [e]), D(() => {
151
+ const a = T.current;
152
+ if (!a) return;
153
+ const B = (F) => {
154
+ F.preventDefault(), k.current();
155
+ }, E = () => {
156
+ u.current && !a.open && k.current();
157
+ };
158
+ let S = !1;
159
+ const H = (F) => {
160
+ S = F.target === a;
161
+ }, U = (F) => {
162
+ const ae = S && F.target === a && w.current;
163
+ S = !1, ae && k.current();
164
+ };
165
+ return a.addEventListener("cancel", B), a.addEventListener("close", E), a.addEventListener("mousedown", H), a.addEventListener("click", U), () => {
166
+ a.removeEventListener("cancel", B), a.removeEventListener("close", E), a.removeEventListener("mousedown", H), a.removeEventListener("click", U);
167
+ };
168
+ }, [I]), I ? /* @__PURE__ */ l(
169
+ "dialog",
170
+ {
171
+ ...b,
172
+ ref: P,
173
+ className: N(C.root, h),
174
+ "data-size": m,
175
+ "aria-labelledby": x,
176
+ "aria-describedby": t ? f : void 0,
177
+ children: /* @__PURE__ */ g("div", { className: C.panel, children: [
178
+ /* @__PURE__ */ g("header", { className: C.header, children: [
179
+ /* @__PURE__ */ l(xe, { level: 2, size: "lg", id: x, className: C.title, children: n }),
180
+ t ? /* @__PURE__ */ l("p", { id: f, className: C.description, children: t }) : null
181
+ ] }),
182
+ /* @__PURE__ */ l("div", { className: C.body, children: v }),
183
+ s ? /* @__PURE__ */ l("footer", { className: C.actions, children: s }) : null,
184
+ /* @__PURE__ */ l("button", { type: "button", className: C.close, "aria-label": i, onClick: o, children: /* @__PURE__ */ l("svg", { viewBox: "0 0 16 16", width: "16", height: "16", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ l(
185
+ "path",
186
+ {
187
+ d: "M3 3l10 10M13 3L3 13",
188
+ fill: "none",
189
+ stroke: "currentColor",
190
+ strokeWidth: "1.5",
191
+ strokeLinecap: "round"
192
+ }
193
+ ) }) })
194
+ ] })
195
+ }
196
+ ) : null;
197
+ }), te = Q(null);
198
+ function oe() {
199
+ return X(te);
200
+ }
201
+ const Se = "maru-Field-module__root__OOI9-", De = "maru-Field-module__label__LAQio", Pe = "maru-Field-module__required__8HCWC", Fe = "maru-Field-module__description__yqljW", Me = "maru-Field-module__error__m0uol", R = {
202
+ root: Se,
203
+ label: De,
204
+ required: Pe,
205
+ description: Fe,
206
+ error: Me
207
+ };
208
+ function Z(r) {
209
+ return r != null && r !== !1 && r !== "";
210
+ }
211
+ const lt = $(function({ label: e, description: o, error: n, required: t = !1, disabled: s = !1, className: m, children: c, ...i }, d) {
212
+ const _ = A(), h = `${_}-control`, v = `${_}-description`, b = `${_}-error`, p = Z(o), y = Z(n), x = [p ? v : null, y ? b : null].filter(Boolean).join(" ") || void 0;
213
+ return /* @__PURE__ */ g(
214
+ "div",
215
+ {
216
+ ...i,
217
+ ref: d,
218
+ className: N(R.root, m),
219
+ "data-invalid": y ? "" : void 0,
220
+ children: [
221
+ /* @__PURE__ */ g("label", { htmlFor: h, className: R.label, children: [
222
+ e,
223
+ t ? /* @__PURE__ */ l("span", { "aria-hidden": "true", className: R.required, children: " *" }) : null
224
+ ] }),
225
+ p ? /* @__PURE__ */ l("p", { id: v, className: R.description, children: o }) : null,
226
+ /* @__PURE__ */ l(
227
+ te.Provider,
228
+ {
229
+ value: { controlId: h, describedBy: x, invalid: y, required: t, disabled: s },
230
+ children: c
231
+ }
232
+ ),
233
+ /* @__PURE__ */ l("div", { "aria-live": "polite", children: y ? /* @__PURE__ */ l("p", { id: b, className: R.error, children: n }) : null })
234
+ ]
235
+ }
236
+ );
237
+ }), Re = "maru-Input-module__root__KgYPo", ze = {
238
+ root: Re
239
+ }, dt = $(function({
240
+ size: e = "md",
241
+ type: o = "text",
242
+ invalid: n,
243
+ id: t,
244
+ disabled: s,
245
+ required: m,
246
+ className: c,
247
+ "aria-describedby": i,
248
+ ...d
249
+ }, _) {
250
+ const h = oe(), v = n ?? h?.invalid ?? !1, b = [i, h?.describedBy].filter(Boolean).join(" ") || void 0;
251
+ return /* @__PURE__ */ l(
252
+ "input",
253
+ {
254
+ ...d,
255
+ ref: _,
256
+ id: h?.controlId ?? t,
257
+ type: o,
258
+ className: N(ze.root, c),
259
+ "data-size": e,
260
+ "data-invalid": v ? "" : void 0,
261
+ "aria-invalid": v ? !0 : void 0,
262
+ "aria-describedby": b,
263
+ disabled: s ?? h?.disabled,
264
+ required: m ?? h?.required
265
+ }
266
+ );
267
+ }), qe = "maru-Select-module__wrapper__KS2K3", Ae = "maru-Select-module__root__y0u6b", Oe = "maru-Select-module__chevron__PLUsh", V = {
268
+ wrapper: qe,
269
+ root: Ae,
270
+ chevron: Oe
271
+ }, ut = $(function({
272
+ size: e = "md",
273
+ invalid: o,
274
+ placeholder: n,
275
+ id: t,
276
+ disabled: s,
277
+ required: m,
278
+ value: c,
279
+ defaultValue: i,
280
+ className: d,
281
+ children: _,
282
+ "aria-describedby": h,
283
+ ...v
284
+ }, b) {
285
+ const p = oe(), y = o ?? p?.invalid ?? !1, x = s ?? p?.disabled ?? !1, f = [h, p?.describedBy].filter(Boolean).join(" ") || void 0, T = c !== void 0 ? { value: c } : { defaultValue: i ?? (n !== void 0 ? "" : void 0) };
286
+ return /* @__PURE__ */ g("span", { className: V.wrapper, "data-size": e, "data-disabled": x ? "" : void 0, children: [
287
+ /* @__PURE__ */ g(
288
+ "select",
289
+ {
290
+ ...v,
291
+ ...T,
292
+ ref: b,
293
+ id: p?.controlId ?? t,
294
+ className: N(V.root, d),
295
+ "data-invalid": y ? "" : void 0,
296
+ "aria-invalid": y ? !0 : void 0,
297
+ "aria-describedby": f,
298
+ disabled: x,
299
+ required: m ?? p?.required,
300
+ children: [
301
+ n !== void 0 ? /* @__PURE__ */ l("option", { value: "", disabled: !0, hidden: !0, children: n }) : null,
302
+ _
303
+ ]
304
+ }
305
+ ),
306
+ /* @__PURE__ */ l("svg", { className: V.chevron, viewBox: "0 0 16 16", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ l(
307
+ "path",
308
+ {
309
+ d: "M4 6l4 4 4-4",
310
+ fill: "none",
311
+ stroke: "currentColor",
312
+ strokeWidth: "1.5",
313
+ strokeLinecap: "round",
314
+ strokeLinejoin: "round"
315
+ }
316
+ ) })
317
+ ] });
318
+ }), Ve = "maru-Stack-module__root__NUN-x", je = {
319
+ root: Ve
320
+ }, mt = $(function({
321
+ as: e = "div",
322
+ direction: o = "vertical",
323
+ gap: n = 4,
324
+ align: t,
325
+ justify: s,
326
+ wrap: m = !1,
327
+ className: c,
328
+ style: i,
329
+ ...d
330
+ }, _) {
331
+ const h = e, v = {
332
+ "--maru-stack-gap": `var(--maru-space-${n})`,
333
+ ...i
334
+ };
335
+ return /* @__PURE__ */ l(
336
+ h,
337
+ {
338
+ ...d,
339
+ ref: _,
340
+ className: N(je.root, c),
341
+ style: v,
342
+ "data-direction": o,
343
+ "data-align": t,
344
+ "data-justify": s,
345
+ "data-wrap": m ? "" : void 0
346
+ }
347
+ );
348
+ }), Ke = "maru-Switch-module__root__Y5Ydi", He = "maru-Switch-module__control__HV3vX", Ue = "maru-Switch-module__input__5BPNu", We = "maru-Switch-module__track__7ObdZ", z = {
349
+ root: Ke,
350
+ control: He,
351
+ input: Ue,
352
+ track: We
353
+ }, ft = $(function({ size: e = "md", disabled: o, className: n, children: t, ...s }, m) {
354
+ return /* @__PURE__ */ g(
355
+ "label",
356
+ {
357
+ className: N(z.root, n),
358
+ "data-size": e,
359
+ "data-disabled": o ? "" : void 0,
360
+ children: [
361
+ /* @__PURE__ */ g("span", { className: z.control, children: [
362
+ /* @__PURE__ */ l(
363
+ "input",
364
+ {
365
+ ...s,
366
+ ref: m,
367
+ type: "checkbox",
368
+ role: "switch",
369
+ className: z.input,
370
+ disabled: o
371
+ }
372
+ ),
373
+ /* @__PURE__ */ l("span", { className: z.track, "aria-hidden": "true" })
374
+ ] }),
375
+ t ? /* @__PURE__ */ l("span", { className: z.label, children: t }) : null
376
+ ]
377
+ }
378
+ );
379
+ }), ne = Q(null);
380
+ function K(r) {
381
+ const e = X(ne);
382
+ if (!e)
383
+ throw new Error(`<${r}> must be rendered inside <Tabs>.`);
384
+ return e;
385
+ }
386
+ function re(r, e) {
387
+ return `${r}-tab-${encodeURIComponent(e)}`;
388
+ }
389
+ function se(r, e) {
390
+ return `${r}-panel-${encodeURIComponent(e)}`;
391
+ }
392
+ const Ye = "maru-Tabs-module__root__-VKVI", Ze = "maru-Tabs-module__list__qRVME", Je = "maru-Tabs-module__tab__IdDYc", Qe = "maru-Tabs-module__panel__08i9c", O = {
393
+ root: Ye,
394
+ list: Ze,
395
+ tab: Je,
396
+ panel: Qe
397
+ }, ht = $(function({ value: e, className: o, onClick: n, onFocus: t, onKeyDown: s, ...m }, c) {
398
+ const { baseId: i, value: d, select: _, orientation: h, activation: v } = K("Tab"), b = e === d;
399
+ function p(f) {
400
+ n?.(f), f.defaultPrevented || _(e);
401
+ }
402
+ function y(f) {
403
+ t?.(f), !f.defaultPrevented && v === "automatic" && _(e);
404
+ }
405
+ function x(f) {
406
+ if (s?.(f), f.defaultPrevented) return;
407
+ const T = f.currentTarget.closest('[role="tablist"]');
408
+ if (!T) return;
409
+ const k = Array.from(T.querySelectorAll('[role="tab"]:not(:disabled)')), u = k.indexOf(f.currentTarget);
410
+ if (u === -1) return;
411
+ const w = getComputedStyle(T).direction === "rtl", P = h === "vertical" ? "ArrowUp" : w ? "ArrowRight" : "ArrowLeft", I = h === "vertical" ? "ArrowDown" : w ? "ArrowLeft" : "ArrowRight";
412
+ let a;
413
+ if (f.key === I)
414
+ a = k[(u + 1) % k.length];
415
+ else if (f.key === P)
416
+ a = k[(u - 1 + k.length) % k.length];
417
+ else if (f.key === "Home")
418
+ a = k[0];
419
+ else if (f.key === "End")
420
+ a = k[k.length - 1];
421
+ else
422
+ return;
423
+ f.preventDefault(), a?.focus();
424
+ }
425
+ return /* @__PURE__ */ l(
426
+ "button",
427
+ {
428
+ ...m,
429
+ ref: c,
430
+ type: "button",
431
+ role: "tab",
432
+ id: re(i, e),
433
+ "aria-selected": b,
434
+ "aria-controls": se(i, e),
435
+ tabIndex: b ? 0 : -1,
436
+ className: N(O.tab, o),
437
+ "data-selected": b ? "" : void 0,
438
+ "data-orientation": h,
439
+ onClick: p,
440
+ onFocus: y,
441
+ onKeyDown: x
442
+ }
443
+ );
444
+ }), _t = $(function({ className: e, ...o }, n) {
445
+ const { orientation: t } = K("TabList");
446
+ return /* @__PURE__ */ l(
447
+ "div",
448
+ {
449
+ ...o,
450
+ ref: n,
451
+ role: "tablist",
452
+ "aria-orientation": t,
453
+ className: N(O.list, e),
454
+ "data-orientation": t
455
+ }
456
+ );
457
+ }), bt = $(function({ value: e, keepMounted: o = !1, className: n, children: t, ...s }, m) {
458
+ const { baseId: c, value: i } = K("TabPanel"), d = e === i;
459
+ return /* @__PURE__ */ l(
460
+ "div",
461
+ {
462
+ ...s,
463
+ ref: m,
464
+ role: "tabpanel",
465
+ id: se(c, e),
466
+ "aria-labelledby": re(c, e),
467
+ tabIndex: 0,
468
+ hidden: !d,
469
+ className: N(O.panel, n),
470
+ children: d || o ? t : null
471
+ }
472
+ );
473
+ }), pt = $(function({
474
+ value: e,
475
+ defaultValue: o,
476
+ onValueChange: n,
477
+ orientation: t = "horizontal",
478
+ activation: s = "automatic",
479
+ className: m,
480
+ children: c,
481
+ ...i
482
+ }, d) {
483
+ const _ = A(), [h, v] = G(o ?? ""), b = e !== void 0, p = b ? e : h, y = j(
484
+ (f) => {
485
+ f !== p && (b || v(f), n?.(f));
486
+ },
487
+ [p, b, n]
488
+ ), x = ce(
489
+ () => ({ baseId: _, value: p, select: y, orientation: t, activation: s }),
490
+ [_, p, y, t, s]
491
+ );
492
+ return /* @__PURE__ */ l(ne.Provider, { value: x, children: /* @__PURE__ */ l(
493
+ "div",
494
+ {
495
+ ...i,
496
+ ref: d,
497
+ className: N(O.root, m),
498
+ "data-orientation": t,
499
+ children: c
500
+ }
501
+ ) });
502
+ }), Xe = "maru-Text-module__root__rsBo7", Ge = {
503
+ root: Xe
504
+ }, vt = $(function({ as: e = "p", size: o = "md", tone: n = "default", weight: t = "regular", className: s, ...m }, c) {
505
+ return /* @__PURE__ */ l(
506
+ e,
507
+ {
508
+ ...m,
509
+ ref: c,
510
+ className: N(Ge.root, s),
511
+ "data-size": o,
512
+ "data-tone": n,
513
+ "data-weight": t
514
+ }
515
+ );
516
+ }), J = {
517
+ top: "bottom",
518
+ bottom: "top",
519
+ left: "right",
520
+ right: "left"
521
+ };
522
+ function et(r, e, o, n, t = 8, s = 8) {
523
+ const m = {
524
+ top: r.top - t - e.height >= s,
525
+ bottom: r.bottom + t + e.height <= o.height - s,
526
+ left: r.left - t - e.width >= s,
527
+ right: r.right + t + e.width <= o.width - s
528
+ }, c = !m[n] && m[J[n]] ? J[n] : n, i = (h, v, b) => Math.max(s, Math.min(h, b - s - v)), d = (r.left + r.right) / 2 - e.width / 2, _ = (r.top + r.bottom) / 2 - e.height / 2;
529
+ switch (c) {
530
+ case "top":
531
+ return {
532
+ side: c,
533
+ x: i(d, e.width, o.width),
534
+ y: r.top - t - e.height
535
+ };
536
+ case "bottom":
537
+ return {
538
+ side: c,
539
+ x: i(d, e.width, o.width),
540
+ y: r.bottom + t
541
+ };
542
+ case "left":
543
+ return {
544
+ side: c,
545
+ x: r.left - t - e.width,
546
+ y: i(_, e.height, o.height)
547
+ };
548
+ case "right":
549
+ return {
550
+ side: c,
551
+ x: r.right + t,
552
+ y: i(_, e.height, o.height)
553
+ };
554
+ }
555
+ }
556
+ const tt = "maru-Tooltip-module__root__U84l8", ot = {
557
+ root: tt
558
+ }, nt = typeof document > "u" ? D : ue;
559
+ function yt({
560
+ content: r,
561
+ children: e,
562
+ placement: o = "top",
563
+ openDelay: n = 300,
564
+ closeDelay: t = 100,
565
+ disabled: s = !1,
566
+ className: m
567
+ }) {
568
+ const c = A(), [i, d] = G(!1), _ = L(null), h = L(null), v = L(void 0), b = () => {
569
+ clearTimeout(v.current), v.current = void 0;
570
+ }, p = (u, w) => {
571
+ _.current = u, b(), w > 0 ? v.current = setTimeout(() => d(!0), w) : d(!0);
572
+ }, y = (u) => {
573
+ b(), u > 0 ? v.current = setTimeout(() => d(!1), u) : d(!1);
574
+ };
575
+ D(() => b, []), D(() => {
576
+ s && (b(), d(!1));
577
+ }, [s]), nt(() => {
578
+ const u = h.current;
579
+ if (!u || !i) return;
580
+ const w = () => {
581
+ const a = _.current;
582
+ if (!a) return;
583
+ const { x: B, y: E, side: S } = et(
584
+ a.getBoundingClientRect(),
585
+ { width: u.offsetWidth, height: u.offsetHeight },
586
+ {
587
+ width: document.documentElement.clientWidth,
588
+ height: document.documentElement.clientHeight
589
+ },
590
+ o
591
+ );
592
+ u.style.left = `${B}px`, u.style.top = `${E}px`, u.dataset.placement = S;
593
+ };
594
+ let P = !1;
595
+ typeof u.showPopover == "function" && (u.showPopover(), P = !0), w();
596
+ const I = (a) => {
597
+ a.key === "Escape" && (a.preventDefault(), a.stopPropagation(), d(!1));
598
+ };
599
+ return window.addEventListener("scroll", w, !0), window.addEventListener("resize", w), document.addEventListener("keydown", I, !0), () => {
600
+ window.removeEventListener("scroll", w, !0), window.removeEventListener("resize", w), document.removeEventListener("keydown", I, !0), P && u.hidePopover();
601
+ };
602
+ }, [i, o]);
603
+ const x = ie.only(e);
604
+ if (!le(x)) return /* @__PURE__ */ l(W, { children: e });
605
+ if (s) return x;
606
+ const f = x.props, T = [f["aria-describedby"], c].filter(Boolean).join(" "), k = de(x, {
607
+ "aria-describedby": T,
608
+ onMouseEnter: (u) => {
609
+ f.onMouseEnter?.(u), p(u.currentTarget, n);
610
+ },
611
+ onMouseLeave: (u) => {
612
+ f.onMouseLeave?.(u), y(t);
613
+ },
614
+ onFocus: (u) => {
615
+ f.onFocus?.(u);
616
+ let w = !0;
617
+ try {
618
+ w = u.currentTarget.matches(":focus-visible");
619
+ } catch {
620
+ }
621
+ w && p(u.currentTarget, 0);
622
+ },
623
+ onBlur: (u) => {
624
+ f.onBlur?.(u), y(0);
625
+ }
626
+ });
627
+ return /* @__PURE__ */ g(W, { children: [
628
+ k,
629
+ /* @__PURE__ */ l(
630
+ "span",
631
+ {
632
+ ref: h,
633
+ id: c,
634
+ role: "tooltip",
635
+ popover: "manual",
636
+ className: N(ot.root, m),
637
+ "data-open": i ? "" : void 0,
638
+ "data-placement": o,
639
+ onMouseEnter: b,
640
+ onMouseLeave: () => y(t),
641
+ children: r
642
+ }
643
+ )
644
+ ] });
645
+ }
646
+ export {
647
+ at as Button,
648
+ ct as Checkbox,
649
+ it as Dialog,
650
+ lt as Field,
651
+ xe as Heading,
652
+ dt as Input,
653
+ ut as Select,
654
+ mt as Stack,
655
+ ft as Switch,
656
+ ht as Tab,
657
+ _t as TabList,
658
+ bt as TabPanel,
659
+ pt as Tabs,
660
+ vt as Text,
661
+ yt as Tooltip
662
+ };
663
+ //# sourceMappingURL=index.js.map