@rinzai/zen 0.8.5 → 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 +84 -83
- 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
package/dist/chart/index.js
CHANGED
|
@@ -1,104 +1,105 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cx as e } from "../utils/cx.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import i from "./
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
3
|
+
import { useSeen as t } from "../utils/useSeen.js";
|
|
4
|
+
import { paletteColor as n } from "./palette.js";
|
|
5
|
+
import { ChartTooltipCard as r, Key as i } from "./tooltip.js";
|
|
6
|
+
import a from "./donut.js";
|
|
7
|
+
import { Children as o, isValidElement as s, useEffect as c, useId as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
8
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
8
9
|
//#region packages/chart/index.tsx
|
|
9
|
-
var
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
10
|
+
var g = () => null, _ = () => null, v = () => null, ee = () => null, te = /* @__PURE__ */ new Map([
|
|
11
|
+
[g, "area"],
|
|
12
|
+
[_, "line"],
|
|
13
|
+
[v, "bar"]
|
|
13
14
|
]), y = {
|
|
14
15
|
top: 12,
|
|
15
16
|
right: 8,
|
|
16
17
|
bottom: 26
|
|
17
18
|
}, b = 11;
|
|
18
|
-
function x({ data:
|
|
19
|
-
let P =
|
|
20
|
-
let e =
|
|
21
|
-
for (let
|
|
22
|
-
|
|
23
|
-
let e =
|
|
19
|
+
function x({ data: i, x: a, label: c, summary: g, height: _ = 240, formatX: v = String, formatY: x = O, formatTooltipX: D, renderTooltip: j, legend: M, palette: ie = "chart", className: N, children: ae }) {
|
|
20
|
+
let P = l().replace(/[^\w-]/g, ""), F = d(null), I = T(F), L = t(F), [R, z] = f(null), [B, V] = f(null), H = u(() => {
|
|
21
|
+
let e = o.toArray(ae).filter(s), t = e.filter((e) => te.has(e.type)).length, r = [], c = [];
|
|
22
|
+
for (let i of e) {
|
|
23
|
+
i.type === ee && c.push(i.props);
|
|
24
|
+
let e = te.get(i.type);
|
|
24
25
|
if (!e) continue;
|
|
25
|
-
let
|
|
26
|
-
|
|
27
|
-
...
|
|
26
|
+
let a = i.props;
|
|
27
|
+
r.push({
|
|
28
|
+
...a,
|
|
28
29
|
kind: e,
|
|
29
|
-
color:
|
|
30
|
+
color: a.color ?? n(ie, r.length, t)
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
|
-
let l =
|
|
33
|
+
let l = i, u = r.flatMap((e) => l.map((t) => S(t, e.dataKey))).filter((e) => e !== null);
|
|
33
34
|
for (let e of c) e.y !== void 0 && u.push(e.y);
|
|
34
|
-
|
|
35
|
-
let d = E(u.length ? Math.min(...u) : 0, u.length ? Math.max(...u) : 1), [
|
|
35
|
+
r.some((e) => e.kind !== "line") && u.push(0);
|
|
36
|
+
let d = E(u.length ? Math.min(...u) : 0, u.length ? Math.max(...u) : 1), [f, g] = [d[0], d[d.length - 1]], C = d.map((e) => x(e)), w = Math.ceil(Math.max(...C.map((e) => e.length)) * b * .62) + 10, T = Math.max(0, I - w - y.right), D = Math.max(0, _ - y.top - y.bottom), O = l.length, A = r.filter((e) => e.kind === "bar"), j = A.length > 0 || O === 1, M = O ? j ? T / O : T / (O - 1) : 0, N = (e) => w + (j ? (e + .5) * M : e * M), F = (e) => y.top + (g === f ? D / 2 : (g - e) / (g - f) * D), L = F(Math.min(Math.max(0, f), g)), R = A.length ? Math.max(2, Math.min(24, M * .72 / A.length - 2)) : 0, z = (e, t) => N(e) - (A.length * (R + 2) - 2) / 2 + t * (R + 2), B = l.map((e) => v(e[a])), V = Math.max(1, ...B.map((e) => e.length)) * b * .6 + 12, H = M ? Math.max(1, Math.ceil(V / M)) : 1;
|
|
36
37
|
return {
|
|
37
|
-
series:
|
|
38
|
+
series: r,
|
|
38
39
|
rows: l,
|
|
39
|
-
n:
|
|
40
|
+
n: O,
|
|
40
41
|
bars: A,
|
|
41
42
|
banded: j,
|
|
42
|
-
step:
|
|
43
|
-
left:
|
|
44
|
-
plotH:
|
|
45
|
-
cx0:
|
|
46
|
-
cy:
|
|
47
|
-
base:
|
|
48
|
-
barW:
|
|
49
|
-
barX:
|
|
50
|
-
back: /* @__PURE__ */
|
|
51
|
-
/* @__PURE__ */
|
|
43
|
+
step: M,
|
|
44
|
+
left: w,
|
|
45
|
+
plotH: D,
|
|
46
|
+
cx0: N,
|
|
47
|
+
cy: F,
|
|
48
|
+
base: L,
|
|
49
|
+
barW: R,
|
|
50
|
+
barX: z,
|
|
51
|
+
back: /* @__PURE__ */ h(p, { children: [
|
|
52
|
+
/* @__PURE__ */ m("defs", { children: r.map((e, t) => e.kind === "area" ? /* @__PURE__ */ h("linearGradient", {
|
|
52
53
|
id: `${P}-fill-${t}`,
|
|
53
54
|
x1: "0",
|
|
54
55
|
y1: "0",
|
|
55
56
|
x2: "0",
|
|
56
57
|
y2: "1",
|
|
57
|
-
children: [/* @__PURE__ */
|
|
58
|
+
children: [/* @__PURE__ */ m("stop", {
|
|
58
59
|
offset: "0%",
|
|
59
60
|
style: { stopColor: e.color },
|
|
60
61
|
stopOpacity: e.dashed ? .16 : .32
|
|
61
|
-
}), /* @__PURE__ */
|
|
62
|
+
}), /* @__PURE__ */ m("stop", {
|
|
62
63
|
offset: "100%",
|
|
63
64
|
style: { stopColor: e.color },
|
|
64
65
|
stopOpacity: 0
|
|
65
66
|
})]
|
|
66
67
|
}, t) : null) }),
|
|
67
|
-
d.map((e, t) => /* @__PURE__ */
|
|
68
|
-
x1:
|
|
69
|
-
x2:
|
|
70
|
-
y1:
|
|
71
|
-
y2:
|
|
68
|
+
d.map((e, t) => /* @__PURE__ */ h("g", { children: [/* @__PURE__ */ m("line", {
|
|
69
|
+
x1: w,
|
|
70
|
+
x2: w + T,
|
|
71
|
+
y1: F(e),
|
|
72
|
+
y2: F(e),
|
|
72
73
|
className: "stroke-tint/[0.07]",
|
|
73
74
|
shapeRendering: "crispEdges"
|
|
74
|
-
}), /* @__PURE__ */
|
|
75
|
-
x:
|
|
76
|
-
y:
|
|
75
|
+
}), /* @__PURE__ */ m("text", {
|
|
76
|
+
x: w - 8,
|
|
77
|
+
y: F(e),
|
|
77
78
|
dy: "0.32em",
|
|
78
79
|
textAnchor: "end",
|
|
79
80
|
className: "fill-muted-foreground tabular-nums",
|
|
80
81
|
style: { fontSize: b },
|
|
81
|
-
children:
|
|
82
|
+
children: C[t]
|
|
82
83
|
})] }, e)),
|
|
83
|
-
|
|
84
|
-
x:
|
|
85
|
-
y:
|
|
86
|
-
textAnchor: !A.length &&
|
|
84
|
+
B.map((e, t) => t % H === 0 ? /* @__PURE__ */ m("text", {
|
|
85
|
+
x: N(t),
|
|
86
|
+
y: _ - 8,
|
|
87
|
+
textAnchor: !A.length && O > 1 && t === 0 ? "start" : !A.length && t === O - 1 ? "end" : "middle",
|
|
87
88
|
className: "fill-muted-foreground",
|
|
88
89
|
style: { fontSize: b },
|
|
89
90
|
children: e
|
|
90
91
|
}, t) : null)
|
|
91
92
|
] }),
|
|
92
|
-
front: /* @__PURE__ */
|
|
93
|
+
front: /* @__PURE__ */ h(p, { children: [r.map((e, t) => e.kind === "bar" ? null : ne(l.map((t, n) => {
|
|
93
94
|
let r = S(t, e.dataKey);
|
|
94
|
-
return r === null ? null : [
|
|
95
|
+
return r === null ? null : [N(n), F(r)];
|
|
95
96
|
})).map((n, r) => {
|
|
96
|
-
let i = (e.curve === "linear" ?
|
|
97
|
-
return /* @__PURE__ */
|
|
98
|
-
d: `${i}L${n[n.length - 1][0]},${
|
|
97
|
+
let i = (e.curve === "linear" ? k : re)(n);
|
|
98
|
+
return /* @__PURE__ */ h("g", { children: [e.kind === "area" && /* @__PURE__ */ m("path", {
|
|
99
|
+
d: `${i}L${n[n.length - 1][0]},${L}L${n[0][0]},${L}Z`,
|
|
99
100
|
fill: `url(#${P}-fill-${t})`,
|
|
100
101
|
className: "zen__chart-fade"
|
|
101
|
-
}), /* @__PURE__ */
|
|
102
|
+
}), /* @__PURE__ */ m("path", {
|
|
102
103
|
d: i,
|
|
103
104
|
fill: "none",
|
|
104
105
|
strokeWidth: e.kind === "area" && !e.dashed ? 2.5 : 2,
|
|
@@ -111,30 +112,30 @@ function x({ data: r, x: i, label: s, summary: h, height: g = 240, formatX: _ =
|
|
|
111
112
|
})] }, `${t}-${r}`);
|
|
112
113
|
})), c.map((e, t) => {
|
|
113
114
|
let n = e.tone === "destructive" ? "stroke-destructive/45" : "stroke-muted-foreground/60";
|
|
114
|
-
if (e.y !== void 0) return /* @__PURE__ */
|
|
115
|
-
x1:
|
|
116
|
-
x2:
|
|
117
|
-
y1:
|
|
118
|
-
y2:
|
|
115
|
+
if (e.y !== void 0) return /* @__PURE__ */ m("line", {
|
|
116
|
+
x1: w,
|
|
117
|
+
x2: w + T,
|
|
118
|
+
y1: F(e.y),
|
|
119
|
+
y2: F(e.y),
|
|
119
120
|
className: n,
|
|
120
121
|
strokeDasharray: e.dashed ? "3 4" : void 0,
|
|
121
122
|
shapeRendering: "crispEdges"
|
|
122
123
|
}, t);
|
|
123
|
-
let r = l.findIndex((t) => t[
|
|
124
|
+
let r = l.findIndex((t) => t[a] === e.x);
|
|
124
125
|
if (r < 0) return null;
|
|
125
|
-
let
|
|
126
|
-
return /* @__PURE__ */
|
|
127
|
-
x1:
|
|
128
|
-
x2:
|
|
126
|
+
let i = !!e.label && N(r) - 6 - e.label.length * b * .6 < w;
|
|
127
|
+
return /* @__PURE__ */ h("g", { children: [/* @__PURE__ */ m("line", {
|
|
128
|
+
x1: N(r),
|
|
129
|
+
x2: N(r),
|
|
129
130
|
y1: y.top,
|
|
130
|
-
y2: y.top +
|
|
131
|
+
y2: y.top + D,
|
|
131
132
|
className: n,
|
|
132
133
|
strokeDasharray: e.dashed === !1 ? void 0 : "3 4"
|
|
133
|
-
}), e.label && /* @__PURE__ */
|
|
134
|
-
x:
|
|
134
|
+
}), e.label && /* @__PURE__ */ m("text", {
|
|
135
|
+
x: N(r) + (i ? 6 : -6),
|
|
135
136
|
y: y.top + 4,
|
|
136
137
|
dy: "0.7em",
|
|
137
|
-
textAnchor:
|
|
138
|
+
textAnchor: i ? "start" : "end",
|
|
138
139
|
className: "fill-muted-foreground",
|
|
139
140
|
style: { fontSize: b },
|
|
140
141
|
children: e.label
|
|
@@ -142,124 +143,125 @@ function x({ data: r, x: i, label: s, summary: h, height: g = 240, formatX: _ =
|
|
|
142
143
|
})] })
|
|
143
144
|
};
|
|
144
145
|
}, [
|
|
145
|
-
|
|
146
|
-
r,
|
|
146
|
+
ae,
|
|
147
147
|
i,
|
|
148
|
+
a,
|
|
148
149
|
I,
|
|
149
|
-
g,
|
|
150
150
|
_,
|
|
151
|
+
v,
|
|
151
152
|
x,
|
|
152
153
|
P,
|
|
153
|
-
|
|
154
|
-
]), { series:
|
|
154
|
+
ie
|
|
155
|
+
]), { series: U, rows: W, n: G, bars: K, banded: oe, step: q, left: J, plotH: Y, cx0: se, cy: X, base: Z, barW: ce, barX: le } = H, ue = u(() => K.map((e, t) => W.map((n, r) => {
|
|
155
156
|
let i = S(n, e.dataKey);
|
|
156
157
|
if (i === null) return null;
|
|
157
158
|
let a = X(i), o = Math.abs(Z - a), s = i < 0;
|
|
158
|
-
return /* @__PURE__ */
|
|
159
|
-
d:
|
|
159
|
+
return /* @__PURE__ */ m("path", {
|
|
160
|
+
d: A(le(r, t), s ? Z : a, ce, o, s),
|
|
160
161
|
"data-negative": s || void 0,
|
|
161
162
|
className: "zen__chart-grow transition-opacity duration-200",
|
|
162
163
|
style: {
|
|
163
164
|
fill: e.color,
|
|
164
|
-
opacity: (e.dim?.(n, r) ? .35 : .9) * (
|
|
165
|
+
opacity: (e.dim?.(n, r) ? .35 : .9) * (R !== null && R !== r ? .7 : 1),
|
|
165
166
|
animationDelay: `${Math.min(r * 25, 400)}ms`
|
|
166
167
|
}
|
|
167
168
|
}, `${t}-${r}`);
|
|
168
169
|
})), [
|
|
169
|
-
|
|
170
|
-
|
|
170
|
+
K,
|
|
171
|
+
W,
|
|
171
172
|
X,
|
|
172
173
|
Z,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
]),
|
|
174
|
+
le,
|
|
175
|
+
ce,
|
|
176
|
+
R
|
|
177
|
+
]), de = u(() => /* @__PURE__ */ m("div", {
|
|
177
178
|
className: "sr-only",
|
|
178
|
-
children: /* @__PURE__ */
|
|
179
|
-
/* @__PURE__ */
|
|
180
|
-
/* @__PURE__ */
|
|
179
|
+
children: /* @__PURE__ */ h("table", { children: [
|
|
180
|
+
/* @__PURE__ */ m("caption", { children: c }),
|
|
181
|
+
/* @__PURE__ */ m("thead", { children: /* @__PURE__ */ h("tr", { children: [/* @__PURE__ */ m("th", {
|
|
181
182
|
scope: "col",
|
|
182
|
-
children: String(
|
|
183
|
-
}),
|
|
183
|
+
children: String(a)
|
|
184
|
+
}), U.map((e) => /* @__PURE__ */ m("th", {
|
|
184
185
|
scope: "col",
|
|
185
186
|
children: e.label
|
|
186
187
|
}, e.dataKey))] }) }),
|
|
187
|
-
/* @__PURE__ */
|
|
188
|
+
/* @__PURE__ */ m("tbody", { children: W.map((e, t) => /* @__PURE__ */ h("tr", { children: [/* @__PURE__ */ m("th", {
|
|
188
189
|
scope: "row",
|
|
189
|
-
children: (D ??
|
|
190
|
-
}),
|
|
190
|
+
children: (D ?? v)(e[a])
|
|
191
|
+
}), U.map((t) => {
|
|
191
192
|
let n = S(e, t.dataKey);
|
|
192
|
-
return /* @__PURE__ */
|
|
193
|
+
return /* @__PURE__ */ m("td", { children: n === null ? "" : x(n) }, t.dataKey);
|
|
193
194
|
})] }, t)) })
|
|
194
195
|
] })
|
|
195
196
|
}), [
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
H,
|
|
197
|
+
c,
|
|
198
|
+
a,
|
|
199
199
|
U,
|
|
200
|
+
W,
|
|
200
201
|
D,
|
|
201
|
-
|
|
202
|
+
v,
|
|
202
203
|
x
|
|
203
|
-
]),
|
|
204
|
-
if (!
|
|
205
|
-
let t =
|
|
206
|
-
return Math.min(
|
|
207
|
-
},
|
|
204
|
+
]), fe = (e) => {
|
|
205
|
+
if (!G || !q) return null;
|
|
206
|
+
let t = oe ? Math.floor((e - J) / q) : Math.round((e - J) / q);
|
|
207
|
+
return Math.min(G - 1, Math.max(0, t));
|
|
208
|
+
}, pe = (e) => {
|
|
208
209
|
let t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left, r = Math.round(e.clientY - t.top);
|
|
209
|
-
|
|
210
|
-
},
|
|
211
|
-
if (!
|
|
210
|
+
z(fe(n)), V((e) => e?.y === r ? e : { y: r });
|
|
211
|
+
}, me = (e) => {
|
|
212
|
+
if (!G) return;
|
|
212
213
|
let t = {
|
|
213
214
|
ArrowRight: 1,
|
|
214
215
|
ArrowLeft: -1
|
|
215
216
|
}[e.key];
|
|
216
|
-
if (e.key === "Escape") return
|
|
217
|
-
if (e.key === "Home" || e.key === "End") return e.preventDefault(),
|
|
218
|
-
t && (e.preventDefault(),
|
|
219
|
-
},
|
|
220
|
-
return /* @__PURE__ */
|
|
221
|
-
"aria-label":
|
|
217
|
+
if (e.key === "Escape") return z(null);
|
|
218
|
+
if (e.key === "Home" || e.key === "End") return e.preventDefault(), V(null), z(e.key === "Home" ? 0 : G - 1);
|
|
219
|
+
t && (e.preventDefault(), V(null), z((e) => e === null ? t > 0 ? 0 : G - 1 : Math.min(G - 1, Math.max(0, e + t))));
|
|
220
|
+
}, he = M ?? (U.length > 1 || U.some((e) => e.dimLabel)), Q = R === null ? null : W[R], $ = R === null ? 0 : se(R), ge = B?.y ?? y.top;
|
|
221
|
+
return /* @__PURE__ */ h("figure", {
|
|
222
|
+
"aria-label": c,
|
|
222
223
|
className: e("zen__chart m-0 flex flex-col gap-3", N),
|
|
223
224
|
children: [
|
|
224
|
-
|
|
225
|
-
/* @__PURE__ */
|
|
225
|
+
he && /* @__PURE__ */ m(C, { series: U }),
|
|
226
|
+
/* @__PURE__ */ h("div", {
|
|
226
227
|
ref: F,
|
|
228
|
+
"data-zen-unseen": L ? void 0 : "",
|
|
227
229
|
tabIndex: 0,
|
|
228
|
-
"aria-label": `${
|
|
229
|
-
onPointerMove:
|
|
230
|
+
"aria-label": `${c}: use the arrow keys to read values`,
|
|
231
|
+
onPointerMove: pe,
|
|
230
232
|
onPointerLeave: () => {
|
|
231
|
-
|
|
233
|
+
z(null), V(null);
|
|
232
234
|
},
|
|
233
|
-
onKeyDown:
|
|
234
|
-
onBlur: () =>
|
|
235
|
+
onKeyDown: me,
|
|
236
|
+
onBlur: () => z(null),
|
|
235
237
|
className: "focus-visible:ring-ring/50 relative rounded-lg outline-hidden focus-visible:ring-2",
|
|
236
|
-
style: { height:
|
|
237
|
-
children: [I > 0 && /* @__PURE__ */
|
|
238
|
+
style: { height: _ },
|
|
239
|
+
children: [I > 0 && /* @__PURE__ */ h("svg", {
|
|
238
240
|
width: I,
|
|
239
|
-
height:
|
|
241
|
+
height: _,
|
|
240
242
|
"aria-hidden": !0,
|
|
241
243
|
className: "block overflow-visible",
|
|
242
244
|
children: [
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
x:
|
|
245
|
+
H.back,
|
|
246
|
+
R !== null && (K.length ? /* @__PURE__ */ m("rect", {
|
|
247
|
+
x: se(R) - q / 2,
|
|
246
248
|
y: y.top,
|
|
247
|
-
width:
|
|
248
|
-
height:
|
|
249
|
+
width: q,
|
|
250
|
+
height: Y,
|
|
249
251
|
className: "fill-tint/[0.04]"
|
|
250
|
-
}) : /* @__PURE__ */
|
|
252
|
+
}) : /* @__PURE__ */ m("line", {
|
|
251
253
|
x1: $,
|
|
252
254
|
x2: $,
|
|
253
255
|
y1: y.top,
|
|
254
|
-
y2: y.top +
|
|
256
|
+
y2: y.top + Y,
|
|
255
257
|
className: "stroke-glow/40"
|
|
256
258
|
})),
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
259
|
+
ue,
|
|
260
|
+
H.front,
|
|
261
|
+
R !== null && U.map((e, t) => {
|
|
260
262
|
if (e.kind === "bar") return null;
|
|
261
|
-
let n = S(
|
|
262
|
-
return n === null ? null : /* @__PURE__ */
|
|
263
|
+
let n = S(W[R], e.dataKey);
|
|
264
|
+
return n === null ? null : /* @__PURE__ */ m("circle", {
|
|
263
265
|
cx: $,
|
|
264
266
|
cy: X(n),
|
|
265
267
|
r: 4,
|
|
@@ -269,12 +271,12 @@ function x({ data: r, x: i, label: s, summary: h, height: g = 240, formatX: _ =
|
|
|
269
271
|
}, t);
|
|
270
272
|
})
|
|
271
273
|
]
|
|
272
|
-
}), Q &&
|
|
274
|
+
}), Q && R !== null && /* @__PURE__ */ m("div", {
|
|
273
275
|
className: "zen__chart-tooltip pointer-events-none absolute top-0 z-10 transition-[translate] duration-75",
|
|
274
|
-
style: w($,
|
|
275
|
-
children:
|
|
276
|
-
title: (D ??
|
|
277
|
-
rows:
|
|
276
|
+
style: w($, ge, I, _),
|
|
277
|
+
children: j ? j(Q, R) : /* @__PURE__ */ m(r, {
|
|
278
|
+
title: (D ?? v)(Q[a]),
|
|
279
|
+
rows: U.map((e) => ({
|
|
278
280
|
s: e,
|
|
279
281
|
v: S(Q, e.dataKey)
|
|
280
282
|
})).filter(({ v: e }) => e !== null).map(({ s: e, v: t }) => ({
|
|
@@ -286,11 +288,11 @@ function x({ data: r, x: i, label: s, summary: h, height: g = 240, formatX: _ =
|
|
|
286
288
|
})
|
|
287
289
|
})]
|
|
288
290
|
}),
|
|
289
|
-
|
|
291
|
+
g && /* @__PURE__ */ m("figcaption", {
|
|
290
292
|
className: "sr-only",
|
|
291
|
-
children:
|
|
293
|
+
children: g
|
|
292
294
|
}),
|
|
293
|
-
|
|
295
|
+
de
|
|
294
296
|
]
|
|
295
297
|
});
|
|
296
298
|
}
|
|
@@ -300,19 +302,19 @@ function S(e, t) {
|
|
|
300
302
|
}
|
|
301
303
|
function C({ series: e }) {
|
|
302
304
|
let t = e.filter((t, n) => t.dimLabel && e.findIndex((e) => e.dimLabel === t.dimLabel) === n);
|
|
303
|
-
return /* @__PURE__ */
|
|
305
|
+
return /* @__PURE__ */ h("ul", {
|
|
304
306
|
className: "text-muted-foreground flex flex-wrap gap-x-4 gap-y-1 text-xs",
|
|
305
307
|
"aria-label": "Legend",
|
|
306
|
-
children: [e.map((e) => /* @__PURE__ */
|
|
308
|
+
children: [e.map((e) => /* @__PURE__ */ h("li", {
|
|
307
309
|
className: "flex items-center gap-1.5",
|
|
308
|
-
children: [/* @__PURE__ */
|
|
310
|
+
children: [/* @__PURE__ */ m(i, {
|
|
309
311
|
color: e.color,
|
|
310
312
|
dashed: e.dashed,
|
|
311
313
|
kind: e.kind
|
|
312
314
|
}), e.label]
|
|
313
|
-
}, e.dataKey)), t.map((e) => /* @__PURE__ */
|
|
315
|
+
}, e.dataKey)), t.map((e) => /* @__PURE__ */ h("li", {
|
|
314
316
|
className: "flex items-center gap-1.5",
|
|
315
|
-
children: [/* @__PURE__ */
|
|
317
|
+
children: [/* @__PURE__ */ m(i, {
|
|
316
318
|
color: e.color,
|
|
317
319
|
kind: "bar",
|
|
318
320
|
faded: !0
|
|
@@ -331,8 +333,8 @@ function w(e, t, n, r) {
|
|
|
331
333
|
};
|
|
332
334
|
}
|
|
333
335
|
function T(e) {
|
|
334
|
-
let [t, n] =
|
|
335
|
-
return
|
|
336
|
+
let [t, n] = f(0);
|
|
337
|
+
return c(() => {
|
|
336
338
|
let t = e.current;
|
|
337
339
|
if (!t || (n(t.clientWidth), typeof ResizeObserver > "u")) return;
|
|
338
340
|
let r = new ResizeObserver(() => n(t.clientWidth));
|
|
@@ -348,17 +350,17 @@ var D = new Intl.NumberFormat("en", {
|
|
|
348
350
|
notation: "compact",
|
|
349
351
|
maximumFractionDigits: 1
|
|
350
352
|
}), O = (e) => D.format(e);
|
|
351
|
-
function
|
|
353
|
+
function ne(e) {
|
|
352
354
|
let t = [], n = [];
|
|
353
355
|
for (let r of e) r ? n.push(r) : n.length && (t.push(n), n = []);
|
|
354
356
|
return n.length && t.push(n), t;
|
|
355
357
|
}
|
|
356
|
-
function
|
|
358
|
+
function k(e) {
|
|
357
359
|
return e.map(([e, t], n) => `${n ? "L" : "M"}${e},${t}`).join("");
|
|
358
360
|
}
|
|
359
361
|
function re(e) {
|
|
360
362
|
let t = e.length;
|
|
361
|
-
if (t < 3) return
|
|
363
|
+
if (t < 3) return k(e);
|
|
362
364
|
let n = e.slice(1).map((t, n) => t[0] - e[n][0]), r = e.slice(1).map((t, r) => (t[1] - e[r][1]) / n[r]), i = e.map((e, i) => i === 0 ? r[0] : i === t - 1 ? r[t - 2] : r[i - 1] * r[i] <= 0 ? 0 : 3 * (n[i - 1] + n[i]) / ((2 * n[i] + n[i - 1]) / r[i - 1] + (n[i] + 2 * n[i - 1]) / r[i])), a = `M${e[0][0]},${e[0][1]}`;
|
|
363
365
|
for (let r = 0; r < t - 1; r++) {
|
|
364
366
|
let t = n[r] / 3;
|
|
@@ -366,9 +368,9 @@ function re(e) {
|
|
|
366
368
|
}
|
|
367
369
|
return a;
|
|
368
370
|
}
|
|
369
|
-
function
|
|
371
|
+
function A(e, t, n, r, i) {
|
|
370
372
|
let a = Math.min(4, n / 2, r);
|
|
371
373
|
return i ? `M${e},${t}V${t + r - a}Q${e},${t + r} ${e + a},${t + r}H${e + n - a}Q${e + n},${t + r} ${e + n},${t + r - a}V${t}Z` : `M${e},${t + r}V${t + a}Q${e},${t} ${e + a},${t}H${e + n - a}Q${e + n},${t} ${e + n},${t + a}V${t + r}Z`;
|
|
372
374
|
}
|
|
373
375
|
//#endregion
|
|
374
|
-
export {
|
|
376
|
+
export { g as ChartArea, v as ChartBar, _ as ChartLine, ee as ChartReference, r as ChartTooltipCard, a as DonutChart, x as default, E as niceTicks, n as paletteColor };
|
package/dist/code-block/index.js
CHANGED
|
@@ -27,7 +27,7 @@ function a({ code: a, language: o, highlight: s, copyable: c = !0, variant: l =
|
|
|
27
27
|
onClick: async () => {
|
|
28
28
|
await navigator.clipboard?.writeText(f), m(!0);
|
|
29
29
|
},
|
|
30
|
-
className: e("zen__code-copy text-muted-foreground hover:bg-tint/[0.07] hover:text-foreground focus-visible:ring-ring/50 absolute top-2.5 right-2.5 cursor-pointer rounded-lg px-2.5 py-1 text-xs font-medium outline-hidden transition-[opacity,background-color,color] focus-visible:ring-2", "opacity-0 group-hover:opacity-100 focus-visible:opacity-100", p && "text-primary opacity-100"),
|
|
30
|
+
className: e("zen__code-copy inline-flex items-center justify-center text-muted-foreground hover:bg-tint/[0.07] hover:text-foreground focus-visible:ring-ring/50 absolute top-2.5 right-2.5 cursor-pointer rounded-lg px-2.5 py-1 text-xs font-medium outline-hidden transition-[opacity,background-color,color] focus-visible:ring-2", "opacity-0 group-hover:opacity-100 focus-visible:opacity-100 pointer-coarse:min-h-11 pointer-coarse:min-w-11 [@media(hover:none)]:bg-card/90 [@media(hover:none)]:opacity-100", p && "text-primary opacity-100"),
|
|
31
31
|
children: p ? "Copied" : "Copy"
|
|
32
32
|
})]
|
|
33
33
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A one-time code (sign-in, verification): a box per character. It's one real
|
|
4
|
+
* field under the boxes, so typing, pasting, deleting and the phone's
|
|
5
|
+
* autofill from a text message all work as in any field. `onComplete` gets the
|
|
6
|
+
* code once every box is filled.
|
|
7
|
+
*/
|
|
8
|
+
export default function CodeInput({ length, value: controlled, defaultValue, onValueChange, onComplete, allowed, className, disabled, ...rest }: CodeInputProps): import('react').JSX.Element;
|
|
9
|
+
export interface CodeInputProps extends Omit<ComponentProps<'input'>, 'value' | 'defaultValue' | 'maxLength'> {
|
|
10
|
+
/** How many characters (boxes). */
|
|
11
|
+
length?: number;
|
|
12
|
+
value?: string;
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
onValueChange?: (value: string) => void;
|
|
15
|
+
/** Called with the code when the last box is filled. */
|
|
16
|
+
onComplete?: (code: string) => void;
|
|
17
|
+
/** Which characters count (one at a time); digits by default. Others typed or pasted are dropped. */
|
|
18
|
+
allowed?: RegExp;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/code-input/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAY,MAAM,OAAO,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAC9B,MAAU,EACV,KAAK,EAAE,UAAU,EACjB,YAAiB,EACjB,aAAa,EACb,UAAU,EACV,OAAc,EACd,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACV,EAAE,cAAc,+BAgEhB;AAED,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,GAAG,WAAW,CAAC;IACzG,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,wDAAwD;IACxD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,qGAAqG;IACrG,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx as e } from "../utils/cx.js";
|
|
3
|
+
import { useFieldProps as t } from "../field/index.js";
|
|
4
|
+
import { useState as n } from "react";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
|
+
//#region packages/code-input/index.tsx
|
|
7
|
+
function a({ length: a = 6, value: o, defaultValue: s = "", onValueChange: c, onComplete: l, allowed: u = /\d/, className: d, disabled: f, ...p }) {
|
|
8
|
+
let [m, h] = n(s), g = o ?? m, [_, v] = n(!1), y = t(p), b = u.source === "\\d";
|
|
9
|
+
return /* @__PURE__ */ i("div", {
|
|
10
|
+
className: e("zen__code-input relative inline-flex gap-2", f && "opacity-50", d),
|
|
11
|
+
children: [/* @__PURE__ */ r("input", {
|
|
12
|
+
autoComplete: "one-time-code",
|
|
13
|
+
inputMode: b ? "numeric" : "text",
|
|
14
|
+
spellCheck: !1,
|
|
15
|
+
maxLength: a,
|
|
16
|
+
...p,
|
|
17
|
+
...y,
|
|
18
|
+
disabled: f,
|
|
19
|
+
value: g,
|
|
20
|
+
onChange: (e) => {
|
|
21
|
+
let t = e.target.value.split("").filter((e) => u.test(e)).join("").slice(0, a);
|
|
22
|
+
o === void 0 && h(t), c?.(t), t.length === a && g.length !== a && l?.(t);
|
|
23
|
+
},
|
|
24
|
+
onFocus: (e) => {
|
|
25
|
+
p.onFocus?.(e), v(!0);
|
|
26
|
+
let t = e.target.value.length;
|
|
27
|
+
e.target.setSelectionRange(t, t);
|
|
28
|
+
},
|
|
29
|
+
onBlur: (e) => {
|
|
30
|
+
p.onBlur?.(e), v(!1);
|
|
31
|
+
},
|
|
32
|
+
className: "absolute inset-0 z-10 cursor-text font-mono text-transparent caret-transparent opacity-0 outline-hidden selection:bg-transparent disabled:cursor-not-allowed"
|
|
33
|
+
}), Array.from({ length: a }, (t, n) => {
|
|
34
|
+
let o = _ && (n === g.length || n === a - 1 && g.length === a);
|
|
35
|
+
return /* @__PURE__ */ i("span", {
|
|
36
|
+
"aria-hidden": !0,
|
|
37
|
+
className: e("glow-border bg-tint/[0.035] relative grid h-12 w-10 place-items-center rounded-lg border font-mono text-lg tabular-nums [--glow-border-color:oklch(var(--glow)/0.22)]", "transition-[border-color,box-shadow,background-color] duration-200", o && "border-glow/60 bg-tint/[0.05] shadow-glow-focus [--glow-border-color:transparent]", y["aria-invalid"] && "border-destructive/60"),
|
|
38
|
+
children: [g[n], o && n === g.length && /* @__PURE__ */ r("span", { className: "zen__code-caret bg-foreground absolute h-5 w-px" })]
|
|
39
|
+
}, n);
|
|
40
|
+
})]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { a as default };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Search everything and act on it (pages, commands, records): a field over a
|
|
4
|
+
* list that narrows as you type. Arrow keys move, Enter runs the item and
|
|
5
|
+
* closes. Open it from a button, or anywhere with ⌘K / Ctrl+K
|
|
6
|
+
* (useCommandPaletteShortcut).
|
|
7
|
+
*/
|
|
8
|
+
export default function CommandPalette({ open, onOpenChange, items, placeholder, empty, label, className, }: CommandPaletteProps): import('react').JSX.Element;
|
|
9
|
+
/** The items matching `query`: each of its words is in the label or keywords. Labels starting with it come first. */
|
|
10
|
+
export declare function search(items: CommandItem[], query: string): CommandItem[];
|
|
11
|
+
/** Calls `open` on ⌘K (Mac) or Ctrl+K, anywhere on the page. */
|
|
12
|
+
export declare function useCommandPaletteShortcut(open: () => void, key?: string): void;
|
|
13
|
+
export interface CommandItem {
|
|
14
|
+
/** Unique among the items; the label by default. */
|
|
15
|
+
id?: string;
|
|
16
|
+
label: string;
|
|
17
|
+
/** Items with the same group are listed together, under it. */
|
|
18
|
+
group?: string;
|
|
19
|
+
/** More words it's found by. */
|
|
20
|
+
keywords?: string[];
|
|
21
|
+
icon?: ReactNode;
|
|
22
|
+
/** Shown at the end, e.g. a shortcut or where it goes. */
|
|
23
|
+
hint?: ReactNode;
|
|
24
|
+
onSelect: () => void;
|
|
25
|
+
}
|
|
26
|
+
export interface CommandPaletteProps {
|
|
27
|
+
open: boolean;
|
|
28
|
+
onOpenChange: (open: boolean) => void;
|
|
29
|
+
items: CommandItem[];
|
|
30
|
+
placeholder?: string;
|
|
31
|
+
/** Shown when nothing matches. */
|
|
32
|
+
empty?: ReactNode;
|
|
33
|
+
/** Names the palette and its list, for screen readers. */
|
|
34
|
+
label?: string;
|
|
35
|
+
className?: string;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/command-palette/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,SAAS,EAA+C,MAAM,OAAO,CAAC;AAE9F;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACnC,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,WAAuB,EACvB,KAAoB,EACpB,KAAkB,EAClB,SAAS,GACZ,EAAE,mBAAmB,+BAoIrB;AAED,qHAAqH;AACrH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAUzE;AAED,gEAAgE;AAChE,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,GAAG,SAAM,GAAG,IAAI,CAc3E;AAED,MAAM,WAAW,WAAW;IACxB,oDAAoD;IACpD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,0DAA0D;IAC1D,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kCAAkC;IAClC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB"}
|