@rinzai/zen 0.8.6 → 0.9.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/animated-number/index.d.ts.map +1 -1
- package/dist/animated-number/index.js +19 -18
- package/dist/breadcrumbs/index.d.ts +15 -0
- package/dist/breadcrumbs/index.d.ts.map +1 -0
- package/dist/breadcrumbs/index.js +39 -0
- package/dist/card/index.d.ts +3 -1
- package/dist/card/index.d.ts.map +1 -1
- package/dist/card/index.js +3 -2
- package/dist/chart/donut.d.ts.map +1 -1
- package/dist/chart/donut.js +72 -70
- package/dist/chart/index.d.ts.map +1 -1
- package/dist/chart/index.js +154 -152
- package/dist/code-block/index.js +1 -1
- package/dist/code-input/index.d.ts +20 -0
- package/dist/code-input/index.d.ts.map +1 -0
- package/dist/code-input/index.js +44 -0
- package/dist/command-palette/index.d.ts +37 -0
- package/dist/command-palette/index.d.ts.map +1 -0
- package/dist/command-palette/index.js +120 -0
- package/dist/dialog/index.d.ts +9 -1
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +116 -32
- package/dist/empty-state/index.d.ts +14 -0
- package/dist/empty-state/index.d.ts.map +1 -0
- package/dist/empty-state/index.js +31 -0
- package/dist/file-drop/index.d.ts +18 -0
- package/dist/file-drop/index.d.ts.map +1 -0
- package/dist/file-drop/index.js +49 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib.js +75 -63
- package/dist/pagination/index.d.ts +26 -0
- package/dist/pagination/index.d.ts.map +1 -0
- package/dist/pagination/index.js +62 -0
- package/dist/skeleton/index.d.ts +12 -2
- package/dist/skeleton/index.d.ts.map +1 -1
- package/dist/skeleton/index.js +11 -5
- package/dist/sparkline/index.d.ts +15 -0
- package/dist/sparkline/index.d.ts.map +1 -0
- package/dist/sparkline/index.js +56 -0
- package/dist/stepper/index.d.ts +19 -0
- package/dist/stepper/index.d.ts.map +1 -0
- package/dist/stepper/index.js +53 -0
- package/dist/table/index.d.ts +6 -1
- package/dist/table/index.d.ts.map +1 -1
- package/dist/table/index.js +78 -46
- package/dist/table-of-contents/index.d.ts +1 -0
- package/dist/table-of-contents/index.d.ts.map +1 -1
- package/dist/table-of-contents/index.js +25 -23
- package/dist/tag-input/index.d.ts +19 -0
- package/dist/tag-input/index.d.ts.map +1 -0
- package/dist/tag-input/index.js +61 -0
- package/dist/theme.css +159 -0
- package/dist/timeline/index.d.ts +18 -0
- package/dist/timeline/index.d.ts.map +1 -0
- package/dist/timeline/index.js +45 -0
- package/dist/tree/index.d.ts.map +1 -1
- package/dist/tree/index.js +68 -67
- package/dist/utils/indicator.d.ts.map +1 -1
- package/dist/utils/indicator.js +1 -1
- package/dist/utils/motion.d.ts +3 -0
- package/dist/utils/motion.d.ts.map +1 -0
- package/dist/utils/motion.js +7 -0
- package/dist/utils/section-link.d.ts +9 -0
- package/dist/utils/section-link.d.ts.map +1 -0
- package/dist/utils/section-link.js +10 -0
- package/dist/utils/theme-wave.d.ts.map +1 -1
- package/dist/utils/theme-wave.js +72 -71
- package/dist/utils/useAnchoredPopup.d.ts.map +1 -1
- package/dist/utils/useAnchoredPopup.js +6 -1
- package/dist/utils/useSeen.d.ts +4 -0
- package/dist/utils/useSeen.d.ts.map +1 -0
- package/dist/utils/useSeen.js +17 -0
- package/dist/zen.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/animated-number/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/animated-number/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAO3D;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACnC,KAAK,EACL,MAAe,EACf,QAAc,EACd,QAAe,EACf,SAAS,GACZ,EAAE,mBAAmB,+BAuBrB;AAED,sEAAsE;AACtE,wBAAgB,aAAa,CAAC,EAC1B,KAAK,EACL,QAAQ,EACR,MAAM,EACN,YAAoB,EACpB,GAAG,IAAI,EACV,EAAE,IAAI,CAAC,mBAAmB,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG;IAC/C,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B,+BAIA;AAED,MAAM,WAAW,mBAAmB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cx as e } from "../utils/cx.js";
|
|
3
3
|
import { formatMoney as t } from "../utils/money.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { reducedMotion as n } from "../utils/motion.js";
|
|
5
|
+
import { useEffect as r, useLayoutEffect as i, useRef as a, useState as o } from "react";
|
|
6
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
6
7
|
//#region packages/animated-number/index.tsx
|
|
7
|
-
var
|
|
8
|
-
function
|
|
9
|
-
let [
|
|
10
|
-
return
|
|
11
|
-
if (
|
|
12
|
-
|
|
8
|
+
var c = typeof window > "u" ? r : i, l = (e) => 1 - (1 - e) ** 3;
|
|
9
|
+
function u({ value: t, format: r = String, duration: i = 650, fromZero: u = !0, className: d }) {
|
|
10
|
+
let [f, p] = o(u ? 0 : t), m = a(u ? 0 : t);
|
|
11
|
+
return c(() => {
|
|
12
|
+
if (n() || i <= 0) {
|
|
13
|
+
m.current = t, p(t);
|
|
13
14
|
return;
|
|
14
15
|
}
|
|
15
|
-
let e =
|
|
16
|
-
let s = Math.min(1, (o -
|
|
17
|
-
|
|
16
|
+
let e = m.current, r = performance.now(), a = requestAnimationFrame(function n(o) {
|
|
17
|
+
let s = Math.min(1, (o - r) / i), c = Math.round(e + (t - e) * l(s));
|
|
18
|
+
m.current = c, p(c), s < 1 && (a = requestAnimationFrame(n));
|
|
18
19
|
});
|
|
19
|
-
return () => cancelAnimationFrame(
|
|
20
|
-
}, [t,
|
|
21
|
-
className: e("zen__animated-number tabular-nums",
|
|
22
|
-
children:
|
|
20
|
+
return () => cancelAnimationFrame(a);
|
|
21
|
+
}, [t, i]), /* @__PURE__ */ s("span", {
|
|
22
|
+
className: e("zen__animated-number tabular-nums", d),
|
|
23
|
+
children: r(f)
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
-
return /* @__PURE__ */
|
|
26
|
+
function d({ value: e, currency: n, locale: r, showDecimals: i = !1, ...a }) {
|
|
27
|
+
return /* @__PURE__ */ s(u, {
|
|
27
28
|
value: e,
|
|
28
29
|
format: (e) => t(e, n, r, { showDecimals: i }),
|
|
29
30
|
...a
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
//#endregion
|
|
33
|
-
export {
|
|
34
|
+
export { d as AnimatedMoney, u as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
/** Where a page sits: its parents as links, then the page itself. Give the last crumb `current`. */
|
|
3
|
+
export default function Breadcrumbs({ className, children, 'aria-label': label, ...rest }: ComponentProps<'nav'>): import('react').JSX.Element;
|
|
4
|
+
/**
|
|
5
|
+
* One crumb: a link, or with `current`, the page you're on (not a link). With
|
|
6
|
+
* `asChild`, the styles go onto your own link element (a router's Link).
|
|
7
|
+
*/
|
|
8
|
+
export declare function Breadcrumb({ current, asChild, className, ...rest }: BreadcrumbProps): import('react').JSX.Element;
|
|
9
|
+
export interface BreadcrumbProps extends ComponentProps<'a'> {
|
|
10
|
+
/** The page you're on: the last crumb. */
|
|
11
|
+
current?: boolean;
|
|
12
|
+
/** Style the single child element (e.g. a router link) instead of rendering an <a>. */
|
|
13
|
+
asChild?: boolean;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/breadcrumbs/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAY,cAAc,EAA4B,MAAM,OAAO,CAAC;AAE3E,oGAAoG;AACpG,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAChC,SAAS,EACT,QAAQ,EACR,YAAY,EAAE,KAAoB,EAClC,GAAG,IAAI,EACV,EAAE,cAAc,CAAC,KAAK,CAAC,+BAkBvB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,eAAe,+BAQnF;AAED,MAAM,WAAW,eAAgB,SAAQ,cAAc,CAAC,GAAG,CAAC;IACxD,0CAA0C;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uFAAuF;IACvF,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx as e } from "../utils/cx.js";
|
|
3
|
+
import { Slot as t } from "../utils/slot.js";
|
|
4
|
+
import n from "../icons/micro/chevron-right.js";
|
|
5
|
+
import { Children as r, Fragment as i, isValidElement as a } from "react";
|
|
6
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
|
+
//#region packages/breadcrumbs/index.tsx
|
|
8
|
+
function c({ className: t, children: c, "aria-label": l = "Breadcrumb", ...u }) {
|
|
9
|
+
let d = r.toArray(c).filter(a);
|
|
10
|
+
return /* @__PURE__ */ o("nav", {
|
|
11
|
+
"aria-label": l,
|
|
12
|
+
className: e("zen__breadcrumbs", t),
|
|
13
|
+
...u,
|
|
14
|
+
children: /* @__PURE__ */ o("ol", {
|
|
15
|
+
className: "text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm",
|
|
16
|
+
children: d.map((e, t) => /* @__PURE__ */ s(i, { children: [t > 0 && /* @__PURE__ */ o("li", {
|
|
17
|
+
"aria-hidden": !0,
|
|
18
|
+
className: "text-muted-foreground/60 flex",
|
|
19
|
+
children: /* @__PURE__ */ o(n, { className: "size-3.5" })
|
|
20
|
+
}), /* @__PURE__ */ o("li", {
|
|
21
|
+
className: "flex min-w-0",
|
|
22
|
+
children: e
|
|
23
|
+
})] }, e.key ?? t))
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function l({ current: n, asChild: r, className: i, ...a }) {
|
|
28
|
+
let s = e("truncate rounded-sm outline-hidden transition-colors focus-visible:ring-2 focus-visible:ring-ring/50", n ? "text-foreground font-medium" : "hover:text-foreground touch-target", i);
|
|
29
|
+
return n ? /* @__PURE__ */ o("span", {
|
|
30
|
+
"aria-current": "page",
|
|
31
|
+
className: s,
|
|
32
|
+
...a
|
|
33
|
+
}) : o(r ? t : "a", {
|
|
34
|
+
className: s,
|
|
35
|
+
...a
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { l as Breadcrumb, c as default };
|
package/dist/card/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare function CardDescription({ className, ...rest }: ComponentProps<'
|
|
|
11
11
|
/** The card's title: an h4 by default; with `asChild`, your own heading (an h2, say) gets its look. */
|
|
12
12
|
export declare function CardTitle({ asChild, className, children, ...rest }: CardTitleProps): import('react').JSX.Element;
|
|
13
13
|
/** A single figure with a label, e.g. "Revenue $12,400". */
|
|
14
|
-
export declare function Stat({ label, value, hint, tone, className }: StatProps): import('react').JSX.Element;
|
|
14
|
+
export declare function Stat({ label, value, hint, tone, className, children }: StatProps): import('react').JSX.Element;
|
|
15
15
|
/** Row of stats: two columns on phones (an odd last one spans both), three from `sm` up. */
|
|
16
16
|
export declare function StatRow({ children, className }: {
|
|
17
17
|
children: ReactNode;
|
|
@@ -28,5 +28,7 @@ export interface StatProps {
|
|
|
28
28
|
hint?: ReactNode;
|
|
29
29
|
tone?: 'default' | 'positive' | 'negative';
|
|
30
30
|
className?: string;
|
|
31
|
+
/** Under the figure: how it got there, like a Sparkline. */
|
|
32
|
+
children?: ReactNode;
|
|
31
33
|
}
|
|
32
34
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/card/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/card/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,SAAS,+BAO7D;AAED,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC,+BAE1E;AAED,6GAA6G;AAC7G,wBAAgB,eAAe,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,cAAc,CAAC,GAAG,CAAC,+BAE1E;AAED,uGAAuG;AACvG,wBAAgB,SAAS,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,cAAc,+BAIlF;AAED,6DAA6D;AAC7D,wBAAgB,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAgB,EAAE,SAAS,EAAE,EAAE,SAAS,+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot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C,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB"}
|
package/dist/card/index.js
CHANGED
|
@@ -31,7 +31,7 @@ function s({ asChild: r, className: i, children: a, ...o }) {
|
|
|
31
31
|
children: a
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
function c({ label: t, value: i, hint: a, tone: o = "default", className: s }) {
|
|
34
|
+
function c({ label: t, value: i, hint: a, tone: o = "default", className: s, children: c }) {
|
|
35
35
|
return /* @__PURE__ */ r("div", {
|
|
36
36
|
className: e("zen__stat glass glow-edge flex flex-col gap-1 rounded-xl p-3.5 md:p-4", s),
|
|
37
37
|
children: [
|
|
@@ -46,7 +46,8 @@ function c({ label: t, value: i, hint: a, tone: o = "default", className: s }) {
|
|
|
46
46
|
a && /* @__PURE__ */ n("span", {
|
|
47
47
|
className: "text-muted-foreground text-xs",
|
|
48
48
|
children: a
|
|
49
|
-
})
|
|
49
|
+
}),
|
|
50
|
+
c
|
|
50
51
|
]
|
|
51
52
|
});
|
|
52
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"donut.d.ts","sourceRoot":"","sources":["../../packages/chart/donut.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"donut.d.ts","sourceRoot":"","sources":["../../packages/chart/donut.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAqC,MAAM,OAAO,CAAC;AAErE,OAAO,EAAE,KAAK,YAAY,EAAgB,MAAM,WAAW,CAAC;AAG5D;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAC/B,KAAK,EACL,KAAK,EACL,IAAU,EACV,SAAgB,EAChB,OAAiB,EACjB,WAAoB,EACpB,QAAQ,EACR,SAAS,GACZ,EAAE,eAAe,+BAuIjB;AA+FD,MAAM,WAAW,eAAe;IAC5B,0DAA0D;IAC1D,KAAK,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvE,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACxC,qHAAqH;IACrH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
package/dist/chart/donut.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cx as e } from "../utils/cx.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { useSeen as t } from "../utils/useSeen.js";
|
|
4
|
+
import { paletteColor as n } from "./palette.js";
|
|
5
|
+
import { ChartTooltipCard as r } from "./tooltip.js";
|
|
6
|
+
import { useLayoutEffect as i, useRef as a, useState as o } from "react";
|
|
7
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
8
|
//#region packages/chart/donut.tsx
|
|
8
|
-
function
|
|
9
|
-
let [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
],
|
|
14
|
-
for (let e = 0,
|
|
15
|
-
start:
|
|
16
|
-
end:
|
|
17
|
-
color:
|
|
9
|
+
function l({ items: l, label: f, size: p = 200, thickness: m = .32, palette: h = "chart", formatValue: g = String, children: b, className: x }) {
|
|
10
|
+
let [S, C] = o(null), w = l.reduce((e, t) => e + Math.max(0, t.value), 0), T = p / 2, E = T * (1 - m), D = Math.min(4, (T - E) / 4), O = l.filter((e) => e.value > 0).length > 1 ? 1.5 : 0, [k, A, j] = [
|
|
11
|
+
E + D,
|
|
12
|
+
T - D,
|
|
13
|
+
O + D
|
|
14
|
+
], M = d(l, 2 * _(j, A)), N = [];
|
|
15
|
+
for (let e = 0, t = -Math.PI / 2; e < l.length; t += M[e++]) N.push({
|
|
16
|
+
start: t,
|
|
17
|
+
end: t + M[e],
|
|
18
|
+
color: l[e].color ?? n(h, e, l.length)
|
|
18
19
|
});
|
|
19
|
-
let
|
|
20
|
-
return
|
|
21
|
-
let e =
|
|
22
|
-
if (
|
|
20
|
+
let P = S === null ? null : l[S], F = S === null ? null : (N[S].start + N[S].end) / 2, I = a(null), L = a(null), R = t(I);
|
|
21
|
+
return i(() => {
|
|
22
|
+
let e = L.current;
|
|
23
|
+
if (F === null || !e || !I.current) return;
|
|
23
24
|
try {
|
|
24
25
|
e.showPopover?.();
|
|
25
26
|
} catch {}
|
|
26
27
|
let t = () => {
|
|
27
|
-
let t =
|
|
28
|
-
e.style.left = `${o(Math.cos(
|
|
28
|
+
let t = I.current.getBoundingClientRect(), n = t.left + T + Math.cos(F) * (T + 10), r = t.top + T + Math.sin(F) * (T + 10), i = e.offsetWidth, a = e.offsetHeight, o = (e, t) => Math.max(u, Math.min(e, t - u));
|
|
29
|
+
e.style.left = `${o(Math.cos(F) >= 0 ? n : n - i, document.documentElement.clientWidth - i)}px`, e.style.top = `${o(r - a / 2, window.innerHeight - a)}px`;
|
|
29
30
|
};
|
|
30
31
|
return t(), window.addEventListener("scroll", t, {
|
|
31
32
|
passive: !0,
|
|
@@ -33,105 +34,106 @@ function c({ items: c, label: d, size: f = 200, thickness: p = .32, palette: m =
|
|
|
33
34
|
}), window.addEventListener("resize", t, { passive: !0 }), () => {
|
|
34
35
|
window.removeEventListener("scroll", t, { capture: !0 }), window.removeEventListener("resize", t);
|
|
35
36
|
};
|
|
36
|
-
}, [
|
|
37
|
-
ref:
|
|
38
|
-
|
|
37
|
+
}, [F, T]), /* @__PURE__ */ c("div", {
|
|
38
|
+
ref: I,
|
|
39
|
+
"data-zen-unseen": R ? void 0 : "",
|
|
40
|
+
className: e("zen__donut relative shrink-0", x),
|
|
39
41
|
style: {
|
|
40
|
-
width:
|
|
41
|
-
height:
|
|
42
|
+
width: p,
|
|
43
|
+
height: p
|
|
42
44
|
},
|
|
43
45
|
children: [
|
|
44
|
-
/* @__PURE__ */
|
|
45
|
-
width:
|
|
46
|
-
height:
|
|
47
|
-
viewBox: `${-
|
|
46
|
+
/* @__PURE__ */ s("svg", {
|
|
47
|
+
width: p,
|
|
48
|
+
height: p,
|
|
49
|
+
viewBox: `${-T} ${-T} ${p} ${p}`,
|
|
48
50
|
role: "list",
|
|
49
|
-
"aria-label":
|
|
51
|
+
"aria-label": f,
|
|
50
52
|
className: "overflow-visible",
|
|
51
|
-
children:
|
|
53
|
+
children: N.map((e, t) => {
|
|
52
54
|
if (e.end === e.start) return null;
|
|
53
|
-
let n = e.end - e.start >= Math.PI * 2 - 1e-6, r = n ?
|
|
54
|
-
return /* @__PURE__ */
|
|
55
|
+
let n = e.end - e.start >= Math.PI * 2 - 1e-6, r = n ? y(E, T, e.start, e.end) : v(k, A, e.start, e.end, j, D), i = (e.start + e.end) / 2, a = S === t && !n ? 4 : 0, o = w ? Math.round(l[t].value / w * 100) : 0;
|
|
56
|
+
return /* @__PURE__ */ s("path", {
|
|
55
57
|
role: "listitem",
|
|
56
58
|
tabIndex: 0,
|
|
57
|
-
"aria-label": `${
|
|
59
|
+
"aria-label": `${l[t].label}: ${g(l[t].value)} (${o}%)`,
|
|
58
60
|
d: r,
|
|
59
|
-
onPointerEnter: () =>
|
|
60
|
-
onPointerLeave: () =>
|
|
61
|
-
onFocus: () =>
|
|
62
|
-
onBlur: () =>
|
|
61
|
+
onPointerEnter: () => C(t),
|
|
62
|
+
onPointerLeave: () => C(null),
|
|
63
|
+
onFocus: () => C(t),
|
|
64
|
+
onBlur: () => C(null),
|
|
63
65
|
className: "zen__chart-fade focus-visible:outline-hidden",
|
|
64
66
|
style: {
|
|
65
67
|
fill: e.color,
|
|
66
|
-
opacity:
|
|
68
|
+
opacity: S !== null && S !== t ? .55 : 1,
|
|
67
69
|
transform: `translate(${Math.cos(i) * a}px, ${Math.sin(i) * a}px)`,
|
|
68
70
|
transition: "transform 200ms ease-out, opacity 200ms",
|
|
69
71
|
animationDelay: `${t * 60}ms`,
|
|
70
|
-
filter:
|
|
72
|
+
filter: S === t ? `drop-shadow(0 0 10px ${e.color})` : void 0
|
|
71
73
|
}
|
|
72
|
-
},
|
|
74
|
+
}, l[t].key);
|
|
73
75
|
})
|
|
74
76
|
}),
|
|
75
|
-
|
|
77
|
+
b && /* @__PURE__ */ s("div", {
|
|
76
78
|
className: "pointer-events-none absolute inset-0 flex flex-col items-center justify-center text-center",
|
|
77
|
-
children:
|
|
79
|
+
children: b
|
|
78
80
|
}),
|
|
79
|
-
|
|
80
|
-
ref:
|
|
81
|
+
P && S !== null && /* @__PURE__ */ s("div", {
|
|
82
|
+
ref: L,
|
|
81
83
|
popover: "manual",
|
|
82
84
|
className: "pointer-events-none fixed inset-auto m-0 overflow-visible border-0 bg-transparent p-0",
|
|
83
|
-
children: /* @__PURE__ */
|
|
84
|
-
title:
|
|
85
|
+
children: /* @__PURE__ */ s(r, {
|
|
86
|
+
title: P.label,
|
|
85
87
|
rows: [{
|
|
86
|
-
label: `${
|
|
87
|
-
value:
|
|
88
|
-
color:
|
|
88
|
+
label: `${w ? Math.round(P.value / w * 100) : 0}%`,
|
|
89
|
+
value: g(P.value),
|
|
90
|
+
color: N[S].color
|
|
89
91
|
}]
|
|
90
92
|
})
|
|
91
93
|
})
|
|
92
94
|
]
|
|
93
95
|
});
|
|
94
96
|
}
|
|
95
|
-
var
|
|
96
|
-
function
|
|
97
|
+
var u = 8;
|
|
98
|
+
function d(e, t) {
|
|
97
99
|
let n = Math.PI * 2, r = e.map((e) => e.value).filter((e) => e > 0), i = [...r].sort((e, t) => e - t), a = Math.min(t, n / r.length), o = r.reduce((e, t) => e + t, 0), s = 0, c = (e) => e / o * (n - s * a);
|
|
98
100
|
for (; s < i.length - 1 && c(i[s]) < a;) o -= i[s++];
|
|
99
101
|
return e.map((e) => e.value > 0 ? Math.max(a, c(e.value)) : 0);
|
|
100
102
|
}
|
|
101
|
-
function
|
|
102
|
-
return
|
|
103
|
+
function f(e, t) {
|
|
104
|
+
return p([e * Math.cos(t), e * Math.sin(t)]);
|
|
103
105
|
}
|
|
104
|
-
function
|
|
106
|
+
function p([e, t]) {
|
|
105
107
|
let n = (e) => Math.round(e * 1e3) / 1e3;
|
|
106
108
|
return `${n(e)},${n(t)}`;
|
|
107
109
|
}
|
|
108
|
-
var
|
|
110
|
+
var m = (e, t) => [e * Math.cos(t), e * Math.sin(t)], h = ([e, t], [n, r], i) => [e + n * i, t + r * i], g = ([e, t], [n, r]) => {
|
|
109
111
|
let i = Math.hypot(n - e, r - t);
|
|
110
112
|
return [(r - t) / i, (e - n) / i];
|
|
111
113
|
};
|
|
112
|
-
function
|
|
114
|
+
function _(e, t) {
|
|
113
115
|
return t > e ? Math.asin(e / t) : Math.PI / 2;
|
|
114
116
|
}
|
|
115
|
-
function
|
|
117
|
+
function v(e, t, n, r, i, a) {
|
|
116
118
|
let o = (e) => {
|
|
117
|
-
let [t, a] = [n +
|
|
119
|
+
let [t, a] = [n + _(i, e), r - _(i, e)];
|
|
118
120
|
return a < t ? [(n + r) / 2, (n + r) / 2] : [t, a];
|
|
119
|
-
}, [s, c] = o(t), [l, u] = o(e), [
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
], [x, S] = [
|
|
125
|
-
return `M${
|
|
121
|
+
}, [s, c] = o(t), [l, u] = o(e), [d, v, y, b] = [
|
|
122
|
+
m(t, s),
|
|
123
|
+
m(t, c),
|
|
124
|
+
m(e, u),
|
|
125
|
+
m(e, l)
|
|
126
|
+
], [x, S] = [g(v, y), g(b, d)], C = (e, t, n, r) => t === n ? "" : `A${e},${e} 0 ${+(Math.abs(n - t) > Math.PI)} ${r} ${f(e, n)}`, w = (e) => `A${a},${a} 0 0 1 ${p(e)}`;
|
|
127
|
+
return `M${f(t + a, s)}${C(t + a, s, c, 1)}${w(h(v, x, a))}L${p(h(y, x, a))}${w(m(e - a, u))}${C(e - a, u, l, 0)}${w(h(b, S, a))}L${p(h(d, S, a))}${w(m(t + a, s))}Z`;
|
|
126
128
|
}
|
|
127
|
-
function
|
|
129
|
+
function y(e, t, n, r) {
|
|
128
130
|
if (r <= n) return "";
|
|
129
131
|
let i = +(r - n > Math.PI);
|
|
130
132
|
if (r - n >= Math.PI * 2 - 1e-6) {
|
|
131
133
|
let r = n + Math.PI;
|
|
132
|
-
return `M${
|
|
134
|
+
return `M${f(t, n)}A${t},${t} 0 1 1 ${f(t, r)}A${t},${t} 0 1 1 ${f(t, n)}M${f(e, n)}A${e},${e} 0 1 0 ${f(e, r)}A${e},${e} 0 1 0 ${f(e, n)}Z`;
|
|
133
135
|
}
|
|
134
|
-
return `M${
|
|
136
|
+
return `M${f(t, n)}A${t},${t} 0 ${i} 1 ${f(t, r)}L${f(e, r)}A${e},${e} 0 ${i} 0 ${f(e, n)}Z`;
|
|
135
137
|
}
|
|
136
138
|
//#endregion
|
|
137
|
-
export {
|
|
139
|
+
export { l as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/chart/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/chart/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,YAAY,EAAgB,MAAM,WAAW,CAAC;AAE5D,OAAO,EAQH,SAAS,EAMZ,MAAM,OAAO,CAAC;AAEf,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAQnC,oDAAoD;AACpD,eAAO,MAAM,SAAS,EAAE,CAAC,KAAK,EAAE,cAAc,K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