@rinzai/zen 0.5.0 → 0.6.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/README.md +2 -2
- package/dist/animated-number/index.js +33 -0
- package/dist/avatar/index.js +38 -0
- package/dist/backdrop/index.d.ts +7 -3
- package/dist/backdrop/index.d.ts.map +1 -1
- package/dist/backdrop/index.js +98 -0
- package/dist/badge/index.d.ts +1 -1
- package/dist/badge/index.js +24 -0
- package/dist/button/index.d.ts +10 -3
- package/dist/button/index.d.ts.map +1 -1
- package/dist/button/index.js +54 -0
- package/dist/calendar/index.d.ts +44 -0
- package/dist/calendar/index.d.ts.map +1 -0
- package/dist/calendar/index.js +161 -0
- package/dist/card/index.d.ts +15 -6
- package/dist/card/index.d.ts.map +1 -1
- package/dist/card/index.js +60 -0
- package/dist/chart/donut.d.ts +30 -0
- package/dist/chart/donut.d.ts.map +1 -0
- package/dist/chart/donut.js +96 -0
- package/dist/chart/index.d.ts +81 -0
- package/dist/chart/index.d.ts.map +1 -0
- package/dist/chart/index.js +362 -0
- package/dist/chart/tooltip.d.ts +25 -0
- package/dist/chart/tooltip.d.ts.map +1 -0
- package/dist/chart/tooltip.js +51 -0
- package/dist/checkbox/index.d.ts +20 -0
- package/dist/checkbox/index.d.ts.map +1 -0
- package/dist/checkbox/index.js +61 -0
- package/dist/chip/index.d.ts +12 -0
- package/dist/chip/index.d.ts.map +1 -0
- package/dist/chip/index.js +14 -0
- package/dist/code-block/index.js +36 -0
- package/dist/collapse/index.d.ts +17 -7
- package/dist/collapse/index.d.ts.map +1 -1
- package/dist/collapse/index.js +82 -0
- package/dist/combobox/index.d.ts +89 -0
- package/dist/combobox/index.d.ts.map +1 -0
- package/dist/combobox/index.js +262 -0
- package/dist/confirm-dialog/index.d.ts.map +1 -1
- package/dist/confirm-dialog/index.js +25 -0
- package/dist/date-picker/index.d.ts +48 -0
- package/dist/date-picker/index.d.ts.map +1 -0
- package/dist/date-picker/index.js +112 -0
- package/dist/dialog/index.d.ts +14 -2
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +77 -0
- package/dist/disclosure/index.d.ts +25 -0
- package/dist/disclosure/index.d.ts.map +1 -0
- package/dist/disclosure/index.js +66 -0
- package/dist/editable-cell/index.js +24 -0
- package/dist/field/index.d.ts +42 -3
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +66 -0
- package/dist/header/index.js +17 -0
- package/dist/icons/chevron-down.js +21 -0
- package/dist/icons/chevron-left.js +21 -0
- package/dist/icons/chevron-right.js +21 -0
- package/dist/icons/chevron-up.js +21 -0
- package/dist/icons/ellipsis.d.ts +4 -0
- package/dist/icons/ellipsis.d.ts.map +1 -0
- package/dist/icons/ellipsis.js +31 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.d.ts.map +1 -1
- package/dist/icons/search.js +21 -0
- package/dist/icons/x-mark.js +21 -0
- package/dist/index.d.ts +22 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/input/index.d.ts.map +1 -1
- package/dist/input/index.js +16 -0
- package/dist/input-group/index.d.ts.map +1 -1
- package/dist/input-group/index.js +36 -0
- package/dist/inset/index.d.ts +16 -0
- package/dist/inset/index.d.ts.map +1 -0
- package/dist/inset/index.js +23 -0
- package/dist/lib.js +74 -0
- package/dist/menu/index.d.ts +55 -0
- package/dist/menu/index.d.ts.map +1 -0
- package/dist/menu/index.js +118 -0
- package/dist/meter/index.js +41 -0
- package/dist/money-input/index.d.ts +77 -7
- package/dist/money-input/index.d.ts.map +1 -1
- package/dist/money-input/index.js +304 -0
- package/dist/month-picker/index.d.ts +4 -3
- package/dist/month-picker/index.d.ts.map +1 -1
- package/dist/month-picker/index.js +93 -0
- package/dist/page-header/index.js +26 -0
- package/dist/pills/index.d.ts +35 -0
- package/dist/pills/index.d.ts.map +1 -0
- package/dist/pills/index.js +50 -0
- package/dist/popover/index.d.ts +41 -22
- package/dist/popover/index.d.ts.map +1 -1
- package/dist/popover/index.js +75 -0
- package/dist/progress-ring/index.js +49 -0
- package/dist/radio-cards/index.d.ts +34 -0
- package/dist/radio-cards/index.d.ts.map +1 -0
- package/dist/radio-cards/index.js +48 -0
- package/dist/radio-group/index.d.ts +39 -0
- package/dist/radio-group/index.d.ts.map +1 -0
- package/dist/radio-group/index.js +63 -0
- package/dist/segmented/index.d.ts +16 -6
- package/dist/segmented/index.d.ts.map +1 -1
- package/dist/segmented/index.js +58 -0
- package/dist/select/index.d.ts +28 -14
- package/dist/select/index.d.ts.map +1 -1
- package/dist/select/index.js +187 -0
- package/dist/side-nav/index.js +37 -0
- package/dist/skeleton/index.js +12 -0
- package/dist/slider/index.js +34 -0
- package/dist/spinner/index.js +14 -0
- package/dist/tab-bar/index.d.ts +3 -0
- package/dist/tab-bar/index.d.ts.map +1 -1
- package/dist/tab-bar/index.js +34 -0
- package/dist/table/index.js +148 -0
- package/dist/table-of-contents/index.js +37 -0
- package/dist/tabs/index.d.ts +3 -2
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +114 -0
- package/dist/tailwind.css +1 -1
- package/dist/textarea/index.d.ts.map +1 -1
- package/dist/textarea/index.js +16 -0
- package/dist/theme-toggle/index.js +43 -0
- package/dist/theme.css +178 -13
- package/dist/toast/index.d.ts +6 -1
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/index.js +248 -0
- package/dist/toggle/index.d.ts.map +1 -1
- package/dist/toggle/index.js +26 -0
- package/dist/tooltip/index.d.ts +25 -0
- package/dist/tooltip/index.d.ts.map +1 -0
- package/dist/tooltip/index.js +108 -0
- package/dist/tree/index.d.ts.map +1 -1
- package/dist/tree/index.js +135 -0
- package/dist/utils/cva.js +25 -0
- package/dist/utils/cx.js +6 -0
- package/dist/utils/date.d.ts +37 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +68 -0
- package/dist/utils/field-chevron.js +19 -0
- package/dist/utils/fx.d.ts +30 -0
- package/dist/utils/fx.d.ts.map +1 -0
- package/dist/utils/fx.js +21 -0
- package/dist/utils/graphics.js +33 -0
- package/dist/utils/indicator.d.ts +24 -0
- package/dist/utils/indicator.d.ts.map +1 -0
- package/dist/utils/indicator.js +37 -0
- package/dist/utils/merge.js +305 -0
- package/dist/utils/money.js +73 -0
- package/dist/utils/month.js +46 -0
- package/dist/utils/slot.d.ts +9 -5
- package/dist/utils/slot.d.ts.map +1 -1
- package/dist/utils/slot.js +25 -0
- package/dist/utils/status-icons.js +48 -0
- package/dist/utils/styles.d.ts +6 -6
- package/dist/utils/styles.d.ts.map +1 -1
- package/dist/utils/styles.js +6 -0
- package/dist/utils/theme.js +200 -0
- package/dist/utils/useAnchoredPopup.d.ts +8 -2
- package/dist/utils/useAnchoredPopup.d.ts.map +1 -1
- package/dist/utils/useAnchoredPopup.js +63 -0
- package/dist/utils/useHydrated.js +9 -0
- package/dist/utils/useVirtualList.js +45 -0
- package/dist/variables.css +22 -0
- package/dist/zen.css +1 -1
- package/package.json +9 -4
- package/dist/actions-menu/index.d.ts +0 -18
- package/dist/actions-menu/index.d.ts.map +0 -1
- package/dist/dropdown/index.d.ts +0 -28
- package/dist/dropdown/index.d.ts.map +0 -1
- package/dist/nav-pills/index.d.ts +0 -31
- package/dist/nav-pills/index.d.ts.map +0 -1
- package/dist/zen.js +0 -2970
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/tooltip/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EACH,cAAc,EAGd,SAAS,EAQZ,MAAM,OAAO,CAAC;AAmBf;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,+BA8BrE;AAED,2GAA2G;AAC3G,wBAAgB,cAAc,CAAC,EAC3B,OAAO,EACP,KAAK,EACL,cAAc,EACd,cAAc,EACd,OAAO,EACP,MAAM,EACN,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACV,EAAE,mBAAmB,+BAkCrB;AAED,kGAAkG;AAClG,wBAAgB,cAAc,CAAC,EAC3B,KAAgB,EAChB,MAAU,EACV,SAAS,EACT,KAAK,EACL,cAAc,EACd,cAAc,EACd,QAAQ,EACR,GAAG,IAAI,EACV,EAAE,mBAAmB,+BA4BrB;AAED,MAAM,WAAW,mBAAoB,SAAQ,cAAc,CAAC,QAAQ,CAAC;IACjE,2FAA2F;IAC3F,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,mBAAoB,SAAQ,cAAc,CAAC,KAAK,CAAC;IAC9D,gFAAgF;IAChF,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;IACnC,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx as e } from "../utils/cx.js";
|
|
3
|
+
import { useGraphicsMode as t } from "../utils/graphics.js";
|
|
4
|
+
import { Slot as n } from "../utils/slot.js";
|
|
5
|
+
import { anchoredStyle as r } from "../utils/useAnchoredPopup.js";
|
|
6
|
+
import { POPUP as i } from "../utils/styles.js";
|
|
7
|
+
import { createContext as a, useCallback as o, useContext as s, useEffect as c, useId as l, useMemo as u, useRef as d } from "react";
|
|
8
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
9
|
+
//#region packages/tooltip/index.tsx
|
|
10
|
+
var p = a(null);
|
|
11
|
+
function m(e) {
|
|
12
|
+
let t = s(p);
|
|
13
|
+
if (!t) throw Error(`<${e}> must be inside <Tooltip>`);
|
|
14
|
+
return t;
|
|
15
|
+
}
|
|
16
|
+
function h({ children: e }) {
|
|
17
|
+
t();
|
|
18
|
+
let n = `zen__tooltip-${l().replace(/[^\w-]/g, "")}`, r = d(null), i = d(0), a = o(() => {
|
|
19
|
+
clearTimeout(i.current);
|
|
20
|
+
try {
|
|
21
|
+
r.current?.showPopover?.();
|
|
22
|
+
} catch {}
|
|
23
|
+
}, []), s = o(() => {
|
|
24
|
+
clearTimeout(i.current);
|
|
25
|
+
try {
|
|
26
|
+
r.current?.hidePopover?.();
|
|
27
|
+
} catch {}
|
|
28
|
+
}, []), m = o(() => {
|
|
29
|
+
clearTimeout(i.current), i.current = window.setTimeout(s, 100);
|
|
30
|
+
}, [s]);
|
|
31
|
+
c(() => () => clearTimeout(i.current), []);
|
|
32
|
+
let h = u(() => ({
|
|
33
|
+
id: n,
|
|
34
|
+
ref: r,
|
|
35
|
+
show: a,
|
|
36
|
+
hide: s,
|
|
37
|
+
hideSoon: m
|
|
38
|
+
}), [
|
|
39
|
+
n,
|
|
40
|
+
a,
|
|
41
|
+
s,
|
|
42
|
+
m
|
|
43
|
+
]);
|
|
44
|
+
return /* @__PURE__ */ f(p.Provider, {
|
|
45
|
+
value: h,
|
|
46
|
+
children: e
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function g({ asChild: e, style: t, onPointerEnter: r, onPointerLeave: i, onFocus: a, onBlur: o, onKeyDown: s, children: c, ...l }) {
|
|
50
|
+
let u = m("TooltipTrigger"), d = {
|
|
51
|
+
"aria-describedby": u.id,
|
|
52
|
+
...l,
|
|
53
|
+
style: {
|
|
54
|
+
anchorName: `--${u.id}`,
|
|
55
|
+
...t
|
|
56
|
+
},
|
|
57
|
+
onPointerEnter: (e) => {
|
|
58
|
+
r?.(e), e.pointerType === "mouse" && u.show();
|
|
59
|
+
},
|
|
60
|
+
onPointerLeave: (e) => {
|
|
61
|
+
i?.(e), u.hideSoon();
|
|
62
|
+
},
|
|
63
|
+
onFocus: (e) => {
|
|
64
|
+
a?.(e), e.currentTarget.matches(":focus-visible") && u.show();
|
|
65
|
+
},
|
|
66
|
+
onBlur: (e) => {
|
|
67
|
+
o?.(e), u.hide();
|
|
68
|
+
},
|
|
69
|
+
onKeyDown: (e) => {
|
|
70
|
+
s?.(e), e.key === "Escape" && u.hide();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
return e ? /* @__PURE__ */ f(n, {
|
|
74
|
+
...d,
|
|
75
|
+
children: c
|
|
76
|
+
}) : /* @__PURE__ */ f("button", {
|
|
77
|
+
type: "button",
|
|
78
|
+
...d,
|
|
79
|
+
children: c
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function _({ align: t = "center", offset: n = 5, className: a, style: o, onPointerEnter: s, onPointerLeave: c, children: l, ...u }) {
|
|
83
|
+
let d = m("TooltipContent");
|
|
84
|
+
return /* @__PURE__ */ f("div", {
|
|
85
|
+
...u,
|
|
86
|
+
ref: d.ref,
|
|
87
|
+
id: d.id,
|
|
88
|
+
role: "tooltip",
|
|
89
|
+
popover: "manual",
|
|
90
|
+
onPointerEnter: (e) => {
|
|
91
|
+
s?.(e), d.show();
|
|
92
|
+
},
|
|
93
|
+
onPointerLeave: (e) => {
|
|
94
|
+
c?.(e), d.hideSoon();
|
|
95
|
+
},
|
|
96
|
+
style: {
|
|
97
|
+
...r(d.id, {
|
|
98
|
+
align: t,
|
|
99
|
+
offset: n
|
|
100
|
+
}),
|
|
101
|
+
...o
|
|
102
|
+
},
|
|
103
|
+
className: e("zen__popover fixed z-50 w-[anchor-size(width)] min-w-max overflow-visible p-0", i, a),
|
|
104
|
+
children: l
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
export { _ as TooltipContent, g as TooltipTrigger, h as default };
|
package/dist/tree/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/tree/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,cAAc,EAAY,MAAM,YAAY,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAA0C,MAAM,OAAO,CAAC;AAEzG,iCAAiC;AACjC,MAAM,WAAW,WAAW,CAAC,CAAC;IAC1B,IAAI,EAAE,CA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AE,WAAW,CAAC,CAAC,CAAC,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACd,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;IAC/E,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACxB"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx as e } from "../utils/cx.js";
|
|
3
|
+
import { TableCell as t, TableRow as n } from "../table/index.js";
|
|
4
|
+
import { useCallback as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
5
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
|
+
//#region packages/tree/index.tsx
|
|
7
|
+
function l({ items: t, getKey: n, getChildren: s, defaultExpanded: c = !0, rowHeight: l = 36 }) {
|
|
8
|
+
let [u, d] = o(() => /* @__PURE__ */ new Set()), [f, p] = o(null), [m, h] = o(null), g = a(null), _ = r((e) => u.has(e) !== c, [u, c]), v = i(() => {
|
|
9
|
+
let e = [], r = (t, i, a) => {
|
|
10
|
+
for (let o of t) {
|
|
11
|
+
let t = n(o), c = s(o), l = !!c?.length, u = l && _(t);
|
|
12
|
+
e.push({
|
|
13
|
+
item: o,
|
|
14
|
+
key: t,
|
|
15
|
+
depth: i,
|
|
16
|
+
parentKey: a,
|
|
17
|
+
hasChildren: l,
|
|
18
|
+
expanded: u
|
|
19
|
+
}), u && r(c, i + 1, t);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return r(t, 0, null), e;
|
|
23
|
+
}, [
|
|
24
|
+
t,
|
|
25
|
+
n,
|
|
26
|
+
s,
|
|
27
|
+
_
|
|
28
|
+
]), y = () => {
|
|
29
|
+
let e = [], r = (t) => {
|
|
30
|
+
for (let i of t) {
|
|
31
|
+
let t = s(i);
|
|
32
|
+
t?.length && (e.push(n(i)), r(t));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return r(t), e;
|
|
36
|
+
}, b = r((e, t) => d((n) => {
|
|
37
|
+
let r = new Set(n);
|
|
38
|
+
return t === c ? r.delete(e) : r.add(e), r;
|
|
39
|
+
}), [c]), x = () => typeof window < "u" && (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches || document.documentElement.classList.contains("reduce-motion")), S = (e) => {
|
|
40
|
+
let t = () => {
|
|
41
|
+
let t = Date.now();
|
|
42
|
+
p({
|
|
43
|
+
key: e,
|
|
44
|
+
at: t
|
|
45
|
+
}), setTimeout(() => p((e) => e?.at === t ? null : e), 320);
|
|
46
|
+
};
|
|
47
|
+
if (m === e) g.current = null, h(null), t();
|
|
48
|
+
else if (!_(e)) t(), b(e, !0);
|
|
49
|
+
else if (x()) b(e, !1);
|
|
50
|
+
else {
|
|
51
|
+
h(e);
|
|
52
|
+
let t = () => {
|
|
53
|
+
g.current === t && (b(e, !1), h((t) => t === e ? null : t), g.current = null);
|
|
54
|
+
};
|
|
55
|
+
g.current = t, setTimeout(t, 500);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
rows: v,
|
|
60
|
+
toggle: S,
|
|
61
|
+
isExpanded: _,
|
|
62
|
+
expand: (e) => b(e, !0),
|
|
63
|
+
collapse: (e) => b(e, !1),
|
|
64
|
+
expandAll: () => d(c ? /* @__PURE__ */ new Set() : new Set(y())),
|
|
65
|
+
collapseAll: () => d(c ? new Set(y()) : /* @__PURE__ */ new Set()),
|
|
66
|
+
rowProps: (t) => ({
|
|
67
|
+
"aria-level": t.depth + 1,
|
|
68
|
+
"aria-expanded": t.hasChildren ? t.expanded : void 0,
|
|
69
|
+
"data-depth": t.depth,
|
|
70
|
+
className: e(f && t.parentKey === f.key && "zen__tree-row-enter", m && t.parentKey === m && "zen__tree-row-exit"),
|
|
71
|
+
style: { "--row-h": `${l - 1}px` },
|
|
72
|
+
onAnimationEnd: (e) => {
|
|
73
|
+
e.animationName === "zen-row-close" && m && t.parentKey === m && g.current?.();
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
toggleProps: (e) => ({
|
|
77
|
+
expanded: e.expanded && m !== e.key,
|
|
78
|
+
onToggle: () => S(e.key)
|
|
79
|
+
}),
|
|
80
|
+
rowHeight: l
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function u({ row: t, tree: r, className: i, style: a, ...o }) {
|
|
84
|
+
let c = r.rowProps(t);
|
|
85
|
+
return /* @__PURE__ */ s(n, {
|
|
86
|
+
...o,
|
|
87
|
+
...c,
|
|
88
|
+
className: e(c.className, i),
|
|
89
|
+
style: {
|
|
90
|
+
...c.style,
|
|
91
|
+
...a
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function d({ numeric: n, className: r, children: i, ...a }) {
|
|
96
|
+
return /* @__PURE__ */ s(t, {
|
|
97
|
+
numeric: n,
|
|
98
|
+
className: e("py-0 whitespace-nowrap", r),
|
|
99
|
+
...a,
|
|
100
|
+
children: /* @__PURE__ */ s("div", {
|
|
101
|
+
className: e("zen__tree-cell flex h-[var(--row-h)] items-center", n && "justify-end"),
|
|
102
|
+
children: i
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function f({ row: t, tree: n, indent: r = 20, children: i, className: a }) {
|
|
107
|
+
return /* @__PURE__ */ c("div", {
|
|
108
|
+
className: e("flex min-w-0 flex-1 items-center gap-1", a),
|
|
109
|
+
style: { paddingLeft: t.depth * r },
|
|
110
|
+
children: [t.hasChildren ? /* @__PURE__ */ s(p, { ...n.toggleProps(t) }) : /* @__PURE__ */ s("span", { className: "-ml-1 w-6 shrink-0" }), i]
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function p({ expanded: t, onToggle: n, className: r, ...i }) {
|
|
114
|
+
return /* @__PURE__ */ s("button", {
|
|
115
|
+
type: "button",
|
|
116
|
+
onClick: n,
|
|
117
|
+
"aria-label": t ? "Collapse" : "Expand",
|
|
118
|
+
"aria-expanded": t,
|
|
119
|
+
className: e("text-muted-foreground hover:bg-tint/[0.08] hover:text-foreground focus-visible:ring-ring/50 -ml-1 grid size-6 shrink-0 place-items-center rounded-md outline-hidden transition-colors focus-visible:ring-2", r),
|
|
120
|
+
...i,
|
|
121
|
+
children: /* @__PURE__ */ s("svg", {
|
|
122
|
+
viewBox: "0 0 16 16",
|
|
123
|
+
fill: "none",
|
|
124
|
+
stroke: "currentColor",
|
|
125
|
+
strokeWidth: "2",
|
|
126
|
+
strokeLinecap: "round",
|
|
127
|
+
strokeLinejoin: "round",
|
|
128
|
+
"aria-hidden": !0,
|
|
129
|
+
className: e("size-4 transition-transform duration-200 ease-out", t && "rotate-90"),
|
|
130
|
+
children: /* @__PURE__ */ s("path", { d: "m6 3.5 4.5 4.5L6 12.5" })
|
|
131
|
+
})
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
export { d as TreeCell, f as TreeLabel, u as TreeRow, p as TreeToggle, l as useTree };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx as e } from "./cx.js";
|
|
3
|
+
//#region packages/utils/cva.ts
|
|
4
|
+
var t = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, n = (n, r) => (i) => {
|
|
5
|
+
if (r?.variants == null) return e(n, i?.class, i?.className);
|
|
6
|
+
let { variants: a, defaultVariants: o } = r, s = Object.keys(a).map((e) => {
|
|
7
|
+
let n = i?.[e], r = o?.[e];
|
|
8
|
+
if (n === null) return null;
|
|
9
|
+
let s = t(n) || t(r);
|
|
10
|
+
return a[e][s];
|
|
11
|
+
}), c = i && Object.entries(i).reduce((e, [t, n]) => (n === void 0 || (e[t] = n), e), {}), l = r?.compoundVariants?.reduce((e, { class: t, className: n, ...r }) => Object.entries(r).every(([e, t]) => Array.isArray(t) ? t.includes({
|
|
12
|
+
...o,
|
|
13
|
+
...c
|
|
14
|
+
}[e]) : {
|
|
15
|
+
...o,
|
|
16
|
+
...c
|
|
17
|
+
}[e] === t) ? [
|
|
18
|
+
...e,
|
|
19
|
+
t,
|
|
20
|
+
n
|
|
21
|
+
] : e, []);
|
|
22
|
+
return e(n, s, l, i?.class, i?.className);
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { n as cva };
|
package/dist/utils/cx.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { mergeClasses as e } from "./merge.js";
|
|
3
|
+
//#region packages/utils/cx.ts
|
|
4
|
+
var t = (...t) => e(n(t)), n = (e) => e.reduce((e, t) => t == null || t === !1 ? e : typeof t == "string" || typeof t == "number" ? e + " " + t : Array.isArray(t) ? e + " " + n(t) : typeof t == "object" ? e + " " + Object.entries(t).reduce((e, [t, n]) => n == null || n === !1 ? e : typeof n == "string" || typeof n == "number" ? e + " " + t + "-" + n : typeof n == "boolean" && n ? e + " " + t : e, "") : e, "");
|
|
5
|
+
//#endregion
|
|
6
|
+
export { t as cx };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Month } from './month';
|
|
2
|
+
/**
|
|
3
|
+
* Calendar date as "YYYY-MM-DD": no time and no time zone, so it never shifts
|
|
4
|
+
* a day. Compares correctly as a string.
|
|
5
|
+
*/
|
|
6
|
+
export type DateString = string;
|
|
7
|
+
/** A start and an end date; `end` is null while only the start is picked. */
|
|
8
|
+
export interface DateRange {
|
|
9
|
+
start: DateString;
|
|
10
|
+
end: DateString | null;
|
|
11
|
+
}
|
|
12
|
+
export declare function isDate(value: unknown): value is DateString;
|
|
13
|
+
/** Days since 1970-01-01; lets date arithmetic be plain integer maths. */
|
|
14
|
+
export declare function dayIndex(date: DateString): number;
|
|
15
|
+
export declare function fromDayIndex(index: number): DateString;
|
|
16
|
+
export declare function addDays(date: DateString, n: number): DateString;
|
|
17
|
+
/** The same day n months later, kept within the month (Jan 31 + 1 month is Feb 28 or 29). */
|
|
18
|
+
export declare function addMonthsToDate(date: DateString, n: number): DateString;
|
|
19
|
+
export declare function daysInMonth(month: Month): number;
|
|
20
|
+
/** 0 for Sunday … 6 for Saturday. */
|
|
21
|
+
export declare function dayOfWeek(date: DateString): number;
|
|
22
|
+
/** Today in the user's time zone. */
|
|
23
|
+
export declare function today(now?: Date): DateString;
|
|
24
|
+
/** Days from `from` to `to` (negative if `to` is earlier). */
|
|
25
|
+
export declare function daysBetween(from: DateString, to: DateString): number;
|
|
26
|
+
/**
|
|
27
|
+
* "Sep 30, 2026" (or the locale's equivalent) by default; `short` is
|
|
28
|
+
* "9/30/26", `long` "September 30, 2026", `full` adds the weekday.
|
|
29
|
+
*/
|
|
30
|
+
export declare function formatDate(date: DateString, locale: string, style?: 'short' | 'medium' | 'long' | 'full'): string;
|
|
31
|
+
/** Short weekday names for a locale, Sunday first. */
|
|
32
|
+
export declare function weekdayNames(locale: string, style?: 'narrow' | 'short' | 'long'): string[];
|
|
33
|
+
/** The first day of the week for a locale: 0 for Sunday, 1 for Monday, 6 for Saturday. */
|
|
34
|
+
export declare function weekStart(locale: string): number;
|
|
35
|
+
/** "Sep 3 – 10, 2026" (or the locale's equivalent), sharing what the two dates have in common. */
|
|
36
|
+
export declare function formatDateRange(start: DateString, end: DateString, locale: string, style?: 'short' | 'medium' | 'long'): string;
|
|
37
|
+
//# sourceMappingURL=date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../packages/utils/date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,6EAA6E;AAC7E,MAAM,WAAW,S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UAAU,EACjB,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,OAAO,GAAG,QAAQ,GAAG,MAAiB,GAC9C,MAAM,CAGR"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region packages/utils/date.ts
|
|
3
|
+
var e = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
|
|
4
|
+
function t(t) {
|
|
5
|
+
if (typeof t != "string") return !1;
|
|
6
|
+
let n = e.exec(t);
|
|
7
|
+
return !!n && Number(n[3]) <= o(`${n[1]}-${n[2]}`);
|
|
8
|
+
}
|
|
9
|
+
function n(e) {
|
|
10
|
+
let [t, n, r] = e.split("-").map(Number);
|
|
11
|
+
return Date.UTC(t, n - 1, r) / 864e5;
|
|
12
|
+
}
|
|
13
|
+
function r(e) {
|
|
14
|
+
return (/* @__PURE__ */ new Date(e * 864e5)).toISOString().slice(0, 10);
|
|
15
|
+
}
|
|
16
|
+
function i(e, t) {
|
|
17
|
+
return r(n(e) + t);
|
|
18
|
+
}
|
|
19
|
+
function a(e, t) {
|
|
20
|
+
let [n, r, i] = e.split("-").map(Number), a = n * 12 + r - 1 + t, s = `${String(Math.floor(a / 12)).padStart(4, "0")}-${String(a % 12 + 1).padStart(2, "0")}`;
|
|
21
|
+
return `${s}-${String(Math.min(i, o(s))).padStart(2, "0")}`;
|
|
22
|
+
}
|
|
23
|
+
function o(e) {
|
|
24
|
+
let [t, n] = e.split("-").map(Number);
|
|
25
|
+
return new Date(Date.UTC(t, n, 0)).getUTCDate();
|
|
26
|
+
}
|
|
27
|
+
function s(e) {
|
|
28
|
+
return (n(e) + 4) % 7;
|
|
29
|
+
}
|
|
30
|
+
function c(e = /* @__PURE__ */ new Date()) {
|
|
31
|
+
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
32
|
+
}
|
|
33
|
+
function l(e, t) {
|
|
34
|
+
return n(t) - n(e);
|
|
35
|
+
}
|
|
36
|
+
function u(e, t, r = "medium") {
|
|
37
|
+
return g(new Intl.DateTimeFormat(t, {
|
|
38
|
+
dateStyle: r,
|
|
39
|
+
timeZone: "UTC"
|
|
40
|
+
}).format(n(e) * 864e5));
|
|
41
|
+
}
|
|
42
|
+
function d(e, t = "short") {
|
|
43
|
+
let n = new Intl.DateTimeFormat(e, {
|
|
44
|
+
weekday: t,
|
|
45
|
+
timeZone: "UTC"
|
|
46
|
+
});
|
|
47
|
+
return Array.from({ length: 7 }, (e, t) => n.format(Date.UTC(2023, 0, 1 + t)));
|
|
48
|
+
}
|
|
49
|
+
var f = new Set("AG AS BD BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW".split(" ")), p = new Set("AE AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY".split(" "));
|
|
50
|
+
function m(e) {
|
|
51
|
+
try {
|
|
52
|
+
let t = new Intl.Locale(e), n = t.getWeekInfo?.() ?? t.weekInfo;
|
|
53
|
+
if (n) return n.firstDay % 7;
|
|
54
|
+
let r = t.maximize().region ?? "";
|
|
55
|
+
return f.has(r) ? 0 : p.has(r) ? 6 : 1;
|
|
56
|
+
} catch {
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function h(e, t, r, i = "medium") {
|
|
61
|
+
return g(new Intl.DateTimeFormat(r, {
|
|
62
|
+
dateStyle: i,
|
|
63
|
+
timeZone: "UTC"
|
|
64
|
+
}).formatRange(n(e) * 864e5, n(t) * 864e5));
|
|
65
|
+
}
|
|
66
|
+
var g = (e) => e.replace(/[\u2009\u202f]/g, " ");
|
|
67
|
+
//#endregion
|
|
68
|
+
export { i as addDays, a as addMonthsToDate, n as dayIndex, s as dayOfWeek, l as daysBetween, o as daysInMonth, u as formatDate, h as formatDateRange, r as fromDayIndex, t as isDate, c as today, m as weekStart, d as weekdayNames };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx as e } from "./cx.js";
|
|
3
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
4
|
+
//#region packages/utils/field-chevron.tsx
|
|
5
|
+
function n({ open: n, className: r }) {
|
|
6
|
+
return /* @__PURE__ */ t("svg", {
|
|
7
|
+
viewBox: "0 0 16 16",
|
|
8
|
+
fill: "none",
|
|
9
|
+
stroke: "currentColor",
|
|
10
|
+
strokeWidth: "1.6",
|
|
11
|
+
strokeLinecap: "round",
|
|
12
|
+
strokeLinejoin: "round",
|
|
13
|
+
"aria-hidden": !0,
|
|
14
|
+
className: e("text-muted-foreground size-4 shrink-0 transition-transform duration-300", n && "rotate-180", r),
|
|
15
|
+
children: /* @__PURE__ */ t("path", { d: "m4 6 4 4 4-4" })
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { n as FieldChevron };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Money } from './money';
|
|
2
|
+
/** Exchange rates: units of each currency per 1 unit of `base` (e.g. as the ECB publishes them). */
|
|
3
|
+
export interface RateTable {
|
|
4
|
+
base: string;
|
|
5
|
+
/** Day the rates are for, "YYYY-MM-DD". */
|
|
6
|
+
date: string;
|
|
7
|
+
rates: Record<string, number>;
|
|
8
|
+
}
|
|
9
|
+
/** A converted amount's original, kept so it's never lost. */
|
|
10
|
+
export interface ForeignAmount {
|
|
11
|
+
currency: string;
|
|
12
|
+
/** Minor units of `currency`. */
|
|
13
|
+
amount: Money;
|
|
14
|
+
/** Units of the home currency per 1 unit of `currency`. */
|
|
15
|
+
rate: number;
|
|
16
|
+
/** Day of the rate used, "YYYY-MM-DD". */
|
|
17
|
+
date: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class RateUnavailableError extends Error {
|
|
20
|
+
}
|
|
21
|
+
/** How many `to` per 1 `from`, via the table's base. Throws RateUnavailableError for a currency it lacks. */
|
|
22
|
+
export declare function rateBetween(table: RateTable, from: string, to: string): number;
|
|
23
|
+
/**
|
|
24
|
+
* Converts minor units between currencies (with different decimal places,
|
|
25
|
+
* e.g. JPY has none). Rounded once, to the nearest minor unit of `to`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function convertMinor(amount: Money, rate: number, from: string, to: string): Money;
|
|
28
|
+
/** Whether a value (e.g. a fetched response) is a well-formed RateTable. */
|
|
29
|
+
export declare function isRateTable(value: unknown): value is RateTable;
|
|
30
|
+
//# sourceMappingURL=fx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fx.d.ts","sourceRoot":"","sources":["../../packages/utils/fx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAElD,oGAAoG;AACpG,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,8DAA8D;AAC9D,MAAM,WAAW,aAAa;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,MAAM,EAAE,KAAK,CAAC;IACd,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,oBAAqB,SAAQ,KAAK;CAAG;AAElD,6GAA6G;AAC7G,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAO9E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,KAAK,CAGzF;AAED,4EAA4E;AAC5E,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAc9D"}
|
package/dist/utils/fx.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { minorDigits as e } from "./money.js";
|
|
3
|
+
//#region packages/utils/fx.ts
|
|
4
|
+
var t = class extends Error {};
|
|
5
|
+
function n(e, n, r) {
|
|
6
|
+
if (n === r) return 1;
|
|
7
|
+
let i = (t) => t === e.base ? 1 : e.rates[t], a = i(n), o = i(r);
|
|
8
|
+
if (!a || !o) throw new t(`No rate for ${a ? r : n}`);
|
|
9
|
+
return o / a;
|
|
10
|
+
}
|
|
11
|
+
function r(t, n, r, i) {
|
|
12
|
+
let a = e(i) - e(r);
|
|
13
|
+
return Math.round(t * n * 10 ** a);
|
|
14
|
+
}
|
|
15
|
+
function i(e) {
|
|
16
|
+
if (typeof e != "object" || !e) return !1;
|
|
17
|
+
let t = e;
|
|
18
|
+
return typeof t.base == "string" && /^[A-Z]{3}$/.test(t.base) && typeof t.date == "string" && /^\d{4}-\d{2}-\d{2}$/.test(t.date) && typeof t.rates == "object" && t.rates !== null && Object.entries(t.rates).every(([e, t]) => /^[A-Z]{3}$/.test(e) && typeof t == "number" && Number.isFinite(t) && t > 0);
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { t as RateUnavailableError, r as convertMinor, i as isRateTable, n as rateBetween };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect as e } from "react";
|
|
3
|
+
//#region packages/utils/graphics.ts
|
|
4
|
+
var t = "data-zen-graphics", n = /swiftshader|llvmpipe|softpipe|software|basic render driver|mesa offscreen/i, r;
|
|
5
|
+
function i() {
|
|
6
|
+
if (r) return r;
|
|
7
|
+
if (typeof document > "u") return "full";
|
|
8
|
+
try {
|
|
9
|
+
let e = document.createElement("canvas"), t = e.getContext("webgl", { failIfMajorPerformanceCaveat: !0 }) ?? e.getContext("experimental-webgl", { failIfMajorPerformanceCaveat: !0 });
|
|
10
|
+
if (!t) r = "lite";
|
|
11
|
+
else {
|
|
12
|
+
let e = t.getExtension("WEBGL_debug_renderer_info"), i = String(t.getParameter(e ? e.UNMASKED_RENDERER_WEBGL : t.RENDERER) ?? "");
|
|
13
|
+
r = n.test(i) ? "lite" : "full", t.getExtension("WEBGL_lose_context")?.loseContext();
|
|
14
|
+
}
|
|
15
|
+
} catch {
|
|
16
|
+
r = "lite";
|
|
17
|
+
}
|
|
18
|
+
return r;
|
|
19
|
+
}
|
|
20
|
+
function a() {
|
|
21
|
+
if (typeof document > "u") return "full";
|
|
22
|
+
let e = document.documentElement, n = e.getAttribute(t);
|
|
23
|
+
if (n === "full" || n === "lite") return n;
|
|
24
|
+
let r = i();
|
|
25
|
+
return e.setAttribute(t, r), r;
|
|
26
|
+
}
|
|
27
|
+
function o() {
|
|
28
|
+
e(() => {
|
|
29
|
+
a();
|
|
30
|
+
}, []);
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { a as applyGraphicsMode, i as detectGraphicsMode, o as useGraphicsMode };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DependencyList, RefObject } from 'react';
|
|
2
|
+
/** Where an item sits in its track, in the track's own coordinates. */
|
|
3
|
+
export interface IndicatorBox {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
w: number;
|
|
7
|
+
h: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Where the active item of a track is, for an indicator that slides to it
|
|
11
|
+
* (Pills, Tabs, Segmented). `selector` finds the active item inside the track;
|
|
12
|
+
* null while none matches, and until measured (e.g. in server HTML).
|
|
13
|
+
*
|
|
14
|
+
* Measures again when the track resizes (labels change width as fonts load; a
|
|
15
|
+
* row can wrap), when items are added or removed or their aria-current or
|
|
16
|
+
* aria-selected changes (a router marking the current link itself), and when
|
|
17
|
+
* `deps` change (state the DOM doesn't show as an attribute, like a checked radio).
|
|
18
|
+
*
|
|
19
|
+
* Call it in the component that renders the track element: React attaches a
|
|
20
|
+
* parent's refs after its children's effects run, so a child measuring a
|
|
21
|
+
* parent's track would find nothing.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useIndicator(trackRef: RefObject<HTMLElement | null>, selector: string, deps?: DependencyList): IndicatorBox | null;
|
|
24
|
+
//# sourceMappingURL=indicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indicator.d.ts","sourceRoot":"","sources":["../../packages/utils/indicator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAA6B,MAAM,OAAO,CAAC;AAE7E,uEAAuE;AACvE,MAAM,WAAW,YAAY;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CACxB,QAAQ,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACvC,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,cAAmB,GAC1B,YAAY,GAAG,IAAI,CAiCrB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useLayoutEffect as e, useState as t } from "react";
|
|
3
|
+
//#region packages/utils/indicator.ts
|
|
4
|
+
function n(n, r, i = []) {
|
|
5
|
+
let [a, o] = t(null);
|
|
6
|
+
return e(() => {
|
|
7
|
+
let e = n.current;
|
|
8
|
+
if (!e) return;
|
|
9
|
+
let t = () => {
|
|
10
|
+
let t = e.querySelector(r), n = t && {
|
|
11
|
+
x: t.offsetLeft,
|
|
12
|
+
y: t.offsetTop,
|
|
13
|
+
w: t.offsetWidth,
|
|
14
|
+
h: t.offsetHeight
|
|
15
|
+
};
|
|
16
|
+
o((e) => e && n && e.x === n.x && e.y === n.y && e.w === n.w && e.h === n.h ? e : n);
|
|
17
|
+
};
|
|
18
|
+
t();
|
|
19
|
+
let i = typeof MutationObserver > "u" ? null : new MutationObserver(t);
|
|
20
|
+
i?.observe(e, {
|
|
21
|
+
subtree: !0,
|
|
22
|
+
childList: !0,
|
|
23
|
+
attributes: !0,
|
|
24
|
+
attributeFilter: ["aria-current", "aria-selected"]
|
|
25
|
+
});
|
|
26
|
+
let a = typeof ResizeObserver > "u" ? null : new ResizeObserver(t);
|
|
27
|
+
return a?.observe(e), () => {
|
|
28
|
+
i?.disconnect(), a?.disconnect();
|
|
29
|
+
};
|
|
30
|
+
}, [
|
|
31
|
+
n,
|
|
32
|
+
r,
|
|
33
|
+
...i
|
|
34
|
+
]), a;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { n as useIndicator };
|