@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.
Files changed (75) hide show
  1. package/dist/animated-number/index.d.ts.map +1 -1
  2. package/dist/animated-number/index.js +19 -18
  3. package/dist/breadcrumbs/index.d.ts +15 -0
  4. package/dist/breadcrumbs/index.d.ts.map +1 -0
  5. package/dist/breadcrumbs/index.js +39 -0
  6. package/dist/card/index.d.ts +3 -1
  7. package/dist/card/index.d.ts.map +1 -1
  8. package/dist/card/index.js +3 -2
  9. package/dist/chart/donut.d.ts.map +1 -1
  10. package/dist/chart/donut.js +72 -70
  11. package/dist/chart/index.d.ts.map +1 -1
  12. package/dist/chart/index.js +154 -152
  13. package/dist/code-block/index.js +1 -1
  14. package/dist/code-input/index.d.ts +20 -0
  15. package/dist/code-input/index.d.ts.map +1 -0
  16. package/dist/code-input/index.js +44 -0
  17. package/dist/command-palette/index.d.ts +37 -0
  18. package/dist/command-palette/index.d.ts.map +1 -0
  19. package/dist/command-palette/index.js +120 -0
  20. package/dist/dialog/index.d.ts +9 -1
  21. package/dist/dialog/index.d.ts.map +1 -1
  22. package/dist/dialog/index.js +116 -32
  23. package/dist/empty-state/index.d.ts +14 -0
  24. package/dist/empty-state/index.d.ts.map +1 -0
  25. package/dist/empty-state/index.js +31 -0
  26. package/dist/file-drop/index.d.ts +18 -0
  27. package/dist/file-drop/index.d.ts.map +1 -0
  28. package/dist/file-drop/index.js +49 -0
  29. package/dist/index.d.ts +13 -1
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/lib.js +75 -63
  32. package/dist/pagination/index.d.ts +26 -0
  33. package/dist/pagination/index.d.ts.map +1 -0
  34. package/dist/pagination/index.js +62 -0
  35. package/dist/skeleton/index.d.ts +12 -2
  36. package/dist/skeleton/index.d.ts.map +1 -1
  37. package/dist/skeleton/index.js +11 -5
  38. package/dist/sparkline/index.d.ts +15 -0
  39. package/dist/sparkline/index.d.ts.map +1 -0
  40. package/dist/sparkline/index.js +56 -0
  41. package/dist/stepper/index.d.ts +19 -0
  42. package/dist/stepper/index.d.ts.map +1 -0
  43. package/dist/stepper/index.js +53 -0
  44. package/dist/table/index.d.ts +6 -1
  45. package/dist/table/index.d.ts.map +1 -1
  46. package/dist/table/index.js +78 -46
  47. package/dist/table-of-contents/index.d.ts +1 -0
  48. package/dist/table-of-contents/index.d.ts.map +1 -1
  49. package/dist/table-of-contents/index.js +25 -23
  50. package/dist/tag-input/index.d.ts +19 -0
  51. package/dist/tag-input/index.d.ts.map +1 -0
  52. package/dist/tag-input/index.js +61 -0
  53. package/dist/theme.css +159 -0
  54. package/dist/timeline/index.d.ts +18 -0
  55. package/dist/timeline/index.d.ts.map +1 -0
  56. package/dist/timeline/index.js +45 -0
  57. package/dist/tree/index.d.ts.map +1 -1
  58. package/dist/tree/index.js +68 -67
  59. package/dist/utils/indicator.d.ts.map +1 -1
  60. package/dist/utils/indicator.js +1 -1
  61. package/dist/utils/motion.d.ts +3 -0
  62. package/dist/utils/motion.d.ts.map +1 -0
  63. package/dist/utils/motion.js +7 -0
  64. package/dist/utils/section-link.d.ts +9 -0
  65. package/dist/utils/section-link.d.ts.map +1 -0
  66. package/dist/utils/section-link.js +10 -0
  67. package/dist/utils/theme-wave.d.ts.map +1 -1
  68. package/dist/utils/theme-wave.js +84 -83
  69. package/dist/utils/useAnchoredPopup.d.ts.map +1 -1
  70. package/dist/utils/useAnchoredPopup.js +6 -1
  71. package/dist/utils/useSeen.d.ts +4 -0
  72. package/dist/utils/useSeen.d.ts.map +1 -0
  73. package/dist/utils/useSeen.js +17 -0
  74. package/dist/zen.css +1 -1
  75. package/package.json +1 -1
@@ -1,104 +1,105 @@
1
1
  "use client";
2
2
  import { cx as e } from "../utils/cx.js";
3
- import { paletteColor as t } from "./palette.js";
4
- import { ChartTooltipCard as n, Key as r } from "./tooltip.js";
5
- import i from "./donut.js";
6
- import { Children as a, isValidElement as o, useEffect as s, useId as c, useMemo as l, useRef as u, useState as d } from "react";
7
- import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
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 h = () => null, g = () => null, _ = () => null, v = () => null, ee = /* @__PURE__ */ new Map([
10
- [h, "area"],
11
- [g, "line"],
12
- [_, "bar"]
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: r, x: i, label: s, summary: h, height: g = 240, formatX: _ = String, formatY: x = O, formatTooltipX: D, renderTooltip: A, legend: j, palette: M = "chart", className: N, children: ie }) {
19
- let P = c().replace(/[^\w-]/g, ""), F = u(null), I = T(F), [L, R] = d(null), [z, B] = d(null), V = l(() => {
20
- let e = a.toArray(ie).filter(o), n = e.filter((e) => ee.has(e.type)).length, s = [], c = [];
21
- for (let r of e) {
22
- r.type === v && c.push(r.props);
23
- let e = ee.get(r.type);
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 i = r.props;
26
- s.push({
27
- ...i,
26
+ let a = i.props;
27
+ r.push({
28
+ ...a,
28
29
  kind: e,
29
- color: i.color ?? t(M, s.length, n)
30
+ color: a.color ?? n(ie, r.length, t)
30
31
  });
31
32
  }
32
- let l = r, u = s.flatMap((e) => l.map((t) => S(t, e.dataKey))).filter((e) => e !== null);
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
- s.some((e) => e.kind !== "line") && u.push(0);
35
- let d = E(u.length ? Math.min(...u) : 0, u.length ? Math.max(...u) : 1), [h, C] = [d[0], d[d.length - 1]], w = d.map((e) => x(e)), T = Math.ceil(Math.max(...w.map((e) => e.length)) * b * .62) + 10, D = Math.max(0, I - T - y.right), O = Math.max(0, g - y.top - y.bottom), k = l.length, A = s.filter((e) => e.kind === "bar"), j = A.length > 0 || k === 1, N = k ? j ? D / k : D / (k - 1) : 0, F = (e) => T + (j ? (e + .5) * N : e * N), L = (e) => y.top + (C === h ? O / 2 : (C - e) / (C - h) * O), R = L(Math.min(Math.max(0, h), C)), z = A.length ? Math.max(2, Math.min(24, N * .72 / A.length - 2)) : 0, B = (e, t) => F(e) - (A.length * (z + 2) - 2) / 2 + t * (z + 2), V = l.map((e) => _(e[i])), H = Math.max(1, ...V.map((e) => e.length)) * b * .6 + 12, U = N ? Math.max(1, Math.ceil(H / N)) : 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: s,
38
+ series: r,
38
39
  rows: l,
39
- n: k,
40
+ n: O,
40
41
  bars: A,
41
42
  banded: j,
42
- step: N,
43
- left: T,
44
- plotH: O,
45
- cx0: F,
46
- cy: L,
47
- base: R,
48
- barW: z,
49
- barX: B,
50
- back: /* @__PURE__ */ m(f, { children: [
51
- /* @__PURE__ */ p("defs", { children: s.map((e, t) => e.kind === "area" ? /* @__PURE__ */ m("linearGradient", {
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__ */ p("stop", {
58
+ children: [/* @__PURE__ */ m("stop", {
58
59
  offset: "0%",
59
60
  style: { stopColor: e.color },
60
61
  stopOpacity: e.dashed ? .16 : .32
61
- }), /* @__PURE__ */ p("stop", {
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__ */ m("g", { children: [/* @__PURE__ */ p("line", {
68
- x1: T,
69
- x2: T + D,
70
- y1: L(e),
71
- y2: L(e),
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__ */ p("text", {
75
- x: T - 8,
76
- y: L(e),
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: w[t]
82
+ children: C[t]
82
83
  })] }, e)),
83
- V.map((e, t) => t % U === 0 ? /* @__PURE__ */ p("text", {
84
- x: F(t),
85
- y: g - 8,
86
- textAnchor: !A.length && k > 1 && t === 0 ? "start" : !A.length && t === k - 1 ? "end" : "middle",
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__ */ m(f, { children: [s.map((e, t) => e.kind === "bar" ? null : te(l.map((t, n) => {
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 : [F(n), L(r)];
95
+ return r === null ? null : [N(n), F(r)];
95
96
  })).map((n, r) => {
96
- let i = (e.curve === "linear" ? ne : re)(n);
97
- return /* @__PURE__ */ m("g", { children: [e.kind === "area" && /* @__PURE__ */ p("path", {
98
- d: `${i}L${n[n.length - 1][0]},${R}L${n[0][0]},${R}Z`,
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__ */ p("path", {
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__ */ p("line", {
115
- x1: T,
116
- x2: T + D,
117
- y1: L(e.y),
118
- y2: L(e.y),
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[i] === e.x);
124
+ let r = l.findIndex((t) => t[a] === e.x);
124
125
  if (r < 0) return null;
125
- let a = !!e.label && F(r) - 6 - e.label.length * b * .6 < T;
126
- return /* @__PURE__ */ m("g", { children: [/* @__PURE__ */ p("line", {
127
- x1: F(r),
128
- x2: F(r),
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 + O,
131
+ y2: y.top + D,
131
132
  className: n,
132
133
  strokeDasharray: e.dashed === !1 ? void 0 : "3 4"
133
- }), e.label && /* @__PURE__ */ p("text", {
134
- x: F(r) + (a ? 6 : -6),
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: a ? "start" : "end",
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
- ie,
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
- M
154
- ]), { series: H, rows: U, n: W, bars: G, banded: ae, step: K, left: q, plotH: J, cx0: Y, cy: X, base: Z, barW: oe, barX: se } = V, ce = l(() => G.map((e, t) => U.map((n, r) => {
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__ */ p("path", {
159
- d: k(se(r, t), s ? Z : a, oe, o, s),
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) * (L !== null && L !== r ? .7 : 1),
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
- G,
170
- U,
170
+ K,
171
+ W,
171
172
  X,
172
173
  Z,
173
- se,
174
- oe,
175
- L
176
- ]), le = l(() => /* @__PURE__ */ p("div", {
174
+ le,
175
+ ce,
176
+ R
177
+ ]), de = u(() => /* @__PURE__ */ m("div", {
177
178
  className: "sr-only",
178
- children: /* @__PURE__ */ m("table", { children: [
179
- /* @__PURE__ */ p("caption", { children: s }),
180
- /* @__PURE__ */ p("thead", { children: /* @__PURE__ */ m("tr", { children: [/* @__PURE__ */ p("th", {
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(i)
183
- }), H.map((e) => /* @__PURE__ */ p("th", {
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__ */ p("tbody", { children: U.map((e, t) => /* @__PURE__ */ m("tr", { children: [/* @__PURE__ */ p("th", {
188
+ /* @__PURE__ */ m("tbody", { children: W.map((e, t) => /* @__PURE__ */ h("tr", { children: [/* @__PURE__ */ m("th", {
188
189
  scope: "row",
189
- children: (D ?? _)(e[i])
190
- }), H.map((t) => {
190
+ children: (D ?? v)(e[a])
191
+ }), U.map((t) => {
191
192
  let n = S(e, t.dataKey);
192
- return /* @__PURE__ */ p("td", { children: n === null ? "" : x(n) }, t.dataKey);
193
+ return /* @__PURE__ */ m("td", { children: n === null ? "" : x(n) }, t.dataKey);
193
194
  })] }, t)) })
194
195
  ] })
195
196
  }), [
196
- s,
197
- i,
198
- H,
197
+ c,
198
+ a,
199
199
  U,
200
+ W,
200
201
  D,
201
- _,
202
+ v,
202
203
  x
203
- ]), ue = (e) => {
204
- if (!W || !K) return null;
205
- let t = ae ? Math.floor((e - q) / K) : Math.round((e - q) / K);
206
- return Math.min(W - 1, Math.max(0, t));
207
- }, de = (e) => {
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
- R(ue(n)), B((e) => e?.y === r ? e : { y: r });
210
- }, fe = (e) => {
211
- if (!W) return;
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 R(null);
217
- if (e.key === "Home" || e.key === "End") return e.preventDefault(), B(null), R(e.key === "Home" ? 0 : W - 1);
218
- t && (e.preventDefault(), B(null), R((e) => e === null ? t > 0 ? 0 : W - 1 : Math.min(W - 1, Math.max(0, e + t))));
219
- }, pe = j ?? (H.length > 1 || H.some((e) => e.dimLabel)), Q = L === null ? null : U[L], $ = L === null ? 0 : Y(L), me = z?.y ?? y.top;
220
- return /* @__PURE__ */ m("figure", {
221
- "aria-label": s,
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
- pe && /* @__PURE__ */ p(C, { series: H }),
225
- /* @__PURE__ */ m("div", {
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": `${s}: use the arrow keys to read values`,
229
- onPointerMove: de,
230
+ "aria-label": `${c}: use the arrow keys to read values`,
231
+ onPointerMove: pe,
230
232
  onPointerLeave: () => {
231
- R(null), B(null);
233
+ z(null), V(null);
232
234
  },
233
- onKeyDown: fe,
234
- onBlur: () => R(null),
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: g },
237
- children: [I > 0 && /* @__PURE__ */ m("svg", {
238
+ style: { height: _ },
239
+ children: [I > 0 && /* @__PURE__ */ h("svg", {
238
240
  width: I,
239
- height: g,
241
+ height: _,
240
242
  "aria-hidden": !0,
241
243
  className: "block overflow-visible",
242
244
  children: [
243
- V.back,
244
- L !== null && (G.length ? /* @__PURE__ */ p("rect", {
245
- x: Y(L) - K / 2,
245
+ H.back,
246
+ R !== null && (K.length ? /* @__PURE__ */ m("rect", {
247
+ x: se(R) - q / 2,
246
248
  y: y.top,
247
- width: K,
248
- height: J,
249
+ width: q,
250
+ height: Y,
249
251
  className: "fill-tint/[0.04]"
250
- }) : /* @__PURE__ */ p("line", {
252
+ }) : /* @__PURE__ */ m("line", {
251
253
  x1: $,
252
254
  x2: $,
253
255
  y1: y.top,
254
- y2: y.top + J,
256
+ y2: y.top + Y,
255
257
  className: "stroke-glow/40"
256
258
  })),
257
- ce,
258
- V.front,
259
- L !== null && H.map((e, t) => {
259
+ ue,
260
+ H.front,
261
+ R !== null && U.map((e, t) => {
260
262
  if (e.kind === "bar") return null;
261
- let n = S(U[L], e.dataKey);
262
- return n === null ? null : /* @__PURE__ */ p("circle", {
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 && L !== null && /* @__PURE__ */ p("div", {
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($, me, I, g),
275
- children: A ? A(Q, L) : /* @__PURE__ */ p(n, {
276
- title: (D ?? _)(Q[i]),
277
- rows: H.map((e) => ({
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
- h && /* @__PURE__ */ p("figcaption", {
291
+ g && /* @__PURE__ */ m("figcaption", {
290
292
  className: "sr-only",
291
- children: h
293
+ children: g
292
294
  }),
293
- le
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__ */ m("ul", {
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__ */ m("li", {
308
+ children: [e.map((e) => /* @__PURE__ */ h("li", {
307
309
  className: "flex items-center gap-1.5",
308
- children: [/* @__PURE__ */ p(r, {
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__ */ m("li", {
315
+ }, e.dataKey)), t.map((e) => /* @__PURE__ */ h("li", {
314
316
  className: "flex items-center gap-1.5",
315
- children: [/* @__PURE__ */ p(r, {
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] = d(0);
335
- return s(() => {
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 te(e) {
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 ne(e) {
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 ne(e);
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 k(e, t, n, r, i) {
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 { h as ChartArea, _ as ChartBar, g as ChartLine, v as ChartReference, n as ChartTooltipCard, i as DonutChart, x as default, E as niceTicks, t as paletteColor };
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 };
@@ -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"}