@rinzai/zen 0.8.6 → 0.10.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 (168) hide show
  1. package/dist/animated-number/index.d.ts +6 -2
  2. package/dist/animated-number/index.d.ts.map +1 -1
  3. package/dist/animated-number/index.js +69 -17
  4. package/dist/breadcrumbs/index.d.ts +15 -0
  5. package/dist/breadcrumbs/index.d.ts.map +1 -0
  6. package/dist/breadcrumbs/index.js +39 -0
  7. package/dist/calendar-heatmap/index.d.ts +25 -0
  8. package/dist/calendar-heatmap/index.d.ts.map +1 -0
  9. package/dist/calendar-heatmap/index.js +48 -0
  10. package/dist/card/index.d.ts +3 -1
  11. package/dist/card/index.d.ts.map +1 -1
  12. package/dist/card/index.js +3 -2
  13. package/dist/chart/allocation.d.ts +30 -0
  14. package/dist/chart/allocation.d.ts.map +1 -0
  15. package/dist/chart/allocation.js +69 -0
  16. package/dist/chart/donut.d.ts.map +1 -1
  17. package/dist/chart/donut.js +72 -70
  18. package/dist/chart/index.d.ts +1 -0
  19. package/dist/chart/index.d.ts.map +1 -1
  20. package/dist/chart/index.js +182 -178
  21. package/dist/code-block/index.d.ts +1 -1
  22. package/dist/code-block/index.d.ts.map +1 -1
  23. package/dist/code-block/index.js +31 -22
  24. package/dist/code-input/index.d.ts +20 -0
  25. package/dist/code-input/index.d.ts.map +1 -0
  26. package/dist/code-input/index.js +44 -0
  27. package/dist/collapse/index.d.ts +3 -2
  28. package/dist/collapse/index.d.ts.map +1 -1
  29. package/dist/collapse/index.js +1 -1
  30. package/dist/command-palette/index.d.ts +37 -0
  31. package/dist/command-palette/index.d.ts.map +1 -0
  32. package/dist/command-palette/index.js +120 -0
  33. package/dist/date-picker/index.d.ts +10 -2
  34. package/dist/date-picker/index.d.ts.map +1 -1
  35. package/dist/date-picker/index.js +43 -21
  36. package/dist/dialog/index.d.ts +13 -3
  37. package/dist/dialog/index.d.ts.map +1 -1
  38. package/dist/dialog/index.js +84 -44
  39. package/dist/editable-cell/index.d.ts +2 -1
  40. package/dist/editable-cell/index.d.ts.map +1 -1
  41. package/dist/editable-cell/index.js +24 -17
  42. package/dist/empty-state/index.d.ts +14 -0
  43. package/dist/empty-state/index.d.ts.map +1 -0
  44. package/dist/empty-state/index.js +31 -0
  45. package/dist/file-drop/index.d.ts +18 -0
  46. package/dist/file-drop/index.d.ts.map +1 -0
  47. package/dist/file-drop/index.js +49 -0
  48. package/dist/filter-bar/index.d.ts +21 -0
  49. package/dist/filter-bar/index.d.ts.map +1 -0
  50. package/dist/filter-bar/index.js +90 -0
  51. package/dist/icon-picker/index.d.ts +38 -0
  52. package/dist/icon-picker/index.d.ts.map +1 -0
  53. package/dist/icon-picker/index.js +112 -0
  54. package/dist/icons/arrow-left.js +23 -0
  55. package/dist/icons/micro/arrow-trending-down.d.ts +3 -0
  56. package/dist/icons/micro/arrow-trending-down.d.ts.map +1 -0
  57. package/dist/icons/micro/arrow-trending-down.js +21 -0
  58. package/dist/icons/micro/arrow-trending-up.d.ts +3 -0
  59. package/dist/icons/micro/arrow-trending-up.d.ts.map +1 -0
  60. package/dist/icons/micro/arrow-trending-up.js +21 -0
  61. package/dist/index.d.ts +30 -6
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/kbd/index.d.ts +4 -0
  64. package/dist/kbd/index.d.ts.map +1 -0
  65. package/dist/kbd/index.js +12 -0
  66. package/dist/keypad/index.d.ts +20 -0
  67. package/dist/keypad/index.d.ts.map +1 -0
  68. package/dist/keypad/index.js +42 -0
  69. package/dist/lib.js +92 -65
  70. package/dist/load-more/index.d.ts +19 -0
  71. package/dist/load-more/index.d.ts.map +1 -0
  72. package/dist/load-more/index.js +37 -0
  73. package/dist/menu/index.d.ts +22 -3
  74. package/dist/menu/index.d.ts.map +1 -1
  75. package/dist/menu/index.js +132 -45
  76. package/dist/meter/index.d.ts +3 -1
  77. package/dist/meter/index.d.ts.map +1 -1
  78. package/dist/meter/index.js +19 -14
  79. package/dist/money-input/index.d.ts +3 -3
  80. package/dist/page-transition/index.d.ts +10 -0
  81. package/dist/page-transition/index.d.ts.map +1 -0
  82. package/dist/page-transition/index.js +16 -0
  83. package/dist/pagination/index.d.ts +26 -0
  84. package/dist/pagination/index.d.ts.map +1 -0
  85. package/dist/pagination/index.js +62 -0
  86. package/dist/progress-ring/index.d.ts +4 -1
  87. package/dist/progress-ring/index.d.ts.map +1 -1
  88. package/dist/progress-ring/index.js +47 -38
  89. package/dist/range-slider/index.d.ts +26 -0
  90. package/dist/range-slider/index.d.ts.map +1 -0
  91. package/dist/range-slider/index.js +44 -0
  92. package/dist/repeat-picker/index.d.ts +22 -0
  93. package/dist/repeat-picker/index.d.ts.map +1 -0
  94. package/dist/repeat-picker/index.js +115 -0
  95. package/dist/skeleton/index.d.ts +12 -2
  96. package/dist/skeleton/index.d.ts.map +1 -1
  97. package/dist/skeleton/index.js +11 -5
  98. package/dist/slider/index.d.ts +2 -0
  99. package/dist/slider/index.d.ts.map +1 -1
  100. package/dist/slider/index.js +19 -18
  101. package/dist/sortable/index.d.ts +33 -0
  102. package/dist/sortable/index.d.ts.map +1 -0
  103. package/dist/sortable/index.js +147 -0
  104. package/dist/sparkline/index.d.ts +15 -0
  105. package/dist/sparkline/index.d.ts.map +1 -0
  106. package/dist/sparkline/index.js +56 -0
  107. package/dist/stepper/index.d.ts +19 -0
  108. package/dist/stepper/index.d.ts.map +1 -0
  109. package/dist/stepper/index.js +53 -0
  110. package/dist/table/index.d.ts +11 -2
  111. package/dist/table/index.d.ts.map +1 -1
  112. package/dist/table/index.js +117 -53
  113. package/dist/table/selection.d.ts +55 -0
  114. package/dist/table/selection.d.ts.map +1 -0
  115. package/dist/table/selection.js +83 -0
  116. package/dist/table/swipe.d.ts +18 -0
  117. package/dist/table/swipe.d.ts.map +1 -0
  118. package/dist/table/swipe.js +53 -0
  119. package/dist/table-of-contents/index.d.ts +1 -0
  120. package/dist/table-of-contents/index.d.ts.map +1 -1
  121. package/dist/table-of-contents/index.js +25 -23
  122. package/dist/tabs/index.d.ts.map +1 -1
  123. package/dist/tabs/index.js +101 -51
  124. package/dist/tag-input/index.d.ts +19 -0
  125. package/dist/tag-input/index.d.ts.map +1 -0
  126. package/dist/tag-input/index.js +61 -0
  127. package/dist/theme-toggle/index.js +6 -6
  128. package/dist/theme.css +340 -8
  129. package/dist/timeline/index.d.ts +18 -0
  130. package/dist/timeline/index.d.ts.map +1 -0
  131. package/dist/timeline/index.js +45 -0
  132. package/dist/toast/index.js +25 -25
  133. package/dist/toggle/index.d.ts.map +1 -1
  134. package/dist/toggle/index.js +1 -1
  135. package/dist/tree/index.d.ts.map +1 -1
  136. package/dist/tree/index.js +68 -67
  137. package/dist/trend/index.d.ts +19 -0
  138. package/dist/trend/index.d.ts.map +1 -0
  139. package/dist/trend/index.js +27 -0
  140. package/dist/utils/date.d.ts +34 -0
  141. package/dist/utils/date.d.ts.map +1 -1
  142. package/dist/utils/date.js +45 -12
  143. package/dist/utils/indicator.d.ts.map +1 -1
  144. package/dist/utils/indicator.js +1 -1
  145. package/dist/utils/money.d.ts +3 -1
  146. package/dist/utils/money.d.ts.map +1 -1
  147. package/dist/utils/money.js +24 -1
  148. package/dist/utils/motion.d.ts +3 -0
  149. package/dist/utils/motion.d.ts.map +1 -0
  150. package/dist/utils/motion.js +7 -0
  151. package/dist/utils/repeat.d.ts +17 -0
  152. package/dist/utils/repeat.d.ts.map +1 -0
  153. package/dist/utils/repeat.js +38 -0
  154. package/dist/utils/section-link.d.ts +9 -0
  155. package/dist/utils/section-link.d.ts.map +1 -0
  156. package/dist/utils/section-link.js +10 -0
  157. package/dist/utils/swipe.d.ts +29 -0
  158. package/dist/utils/swipe.d.ts.map +1 -0
  159. package/dist/utils/swipe.js +85 -0
  160. package/dist/utils/theme-wave.d.ts.map +1 -1
  161. package/dist/utils/theme-wave.js +72 -71
  162. package/dist/utils/useAnchoredPopup.d.ts.map +1 -1
  163. package/dist/utils/useAnchoredPopup.js +3 -4
  164. package/dist/utils/useSeen.d.ts +4 -0
  165. package/dist/utils/useSeen.d.ts.map +1 -0
  166. package/dist/utils/useSeen.js +17 -0
  167. package/dist/zen.css +1 -1
  168. package/package.json +3 -1
@@ -1,104 +1,106 @@
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 "./allocation.js";
7
+ import o from "./donut.js";
8
+ import { Children as s, isValidElement as ee, useEffect as c, useId as l, useMemo as u, useRef as d, useState as f } from "react";
9
+ import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
8
10
  //#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"]
13
- ]), y = {
11
+ var g = () => null, _ = () => null, v = () => null, te = () => null, y = /* @__PURE__ */ new Map([
12
+ [g, "area"],
13
+ [_, "line"],
14
+ [v, "bar"]
15
+ ]), b = {
14
16
  top: 12,
15
17
  right: 8,
16
18
  bottom: 26
17
- }, 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
+ }, x = 11;
20
+ function S({ data: i, x: a, label: o, summary: c, height: g = 240, formatX: _ = String, formatY: v = O, formatTooltipX: S, renderTooltip: D, legend: j, palette: ae = "chart", className: M, children: N }) {
21
+ let P = l().replace(/[^\w-]/g, ""), F = d(null), I = E(F), L = t(F), [R, z] = f(null), [B, V] = f(null), H = u(() => {
22
+ let e = s.toArray(N).filter(ee), t = e.filter((e) => y.has(e.type)).length, r = [], o = [];
23
+ for (let i of e) {
24
+ i.type === te && o.push(i.props);
25
+ let e = y.get(i.type);
24
26
  if (!e) continue;
25
- let i = r.props;
26
- s.push({
27
- ...i,
27
+ let a = i.props;
28
+ r.push({
29
+ ...a,
28
30
  kind: e,
29
- color: i.color ?? t(M, s.length, n)
31
+ color: a.color ?? n(ae, r.length, t)
30
32
  });
31
33
  }
32
- let l = r, u = s.flatMap((e) => l.map((t) => S(t, e.dataKey))).filter((e) => e !== null);
33
- 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;
34
+ let c = i, l = r.flatMap((e) => c.map((t) => C(t, e.dataKey))).filter((e) => e !== null);
35
+ for (let e of o) e.y !== void 0 && l.push(e.y);
36
+ r.some((e) => e.kind !== "line") && l.push(0);
37
+ let u = ne(l.length ? Math.min(...l) : 0, l.length ? Math.max(...l) : 1), [d, f] = [u[0], u[u.length - 1]], S = u.map((e) => v(e)), w = Math.ceil(Math.max(...S.map((e) => e.length)) * x * .62) + 10, T = Math.max(0, I - w - b.right), E = Math.max(0, g - b.top - b.bottom), D = c.length, O = r.filter((e) => e.kind === "bar"), A = O.length > 0 || D === 1, j = D ? A ? T / D : T / (D - 1) : 0, M = (e) => w + (A ? (e + .5) * j : e * j), F = (e) => b.top + (f === d ? E / 2 : (f - e) / (f - d) * E), L = F(Math.min(Math.max(0, d), f)), R = O.length ? Math.max(2, Math.min(24, j * .72 / O.length - 2)) : 0, z = (e, t) => M(e) - (O.length * (R + 2) - 2) / 2 + t * (R + 2), B = c.map((e) => _(e[a])), V = Math.max(1, ...B.map((e) => e.length)) * x * .6 + 12, H = j ? Math.max(1, Math.ceil(V / j)) : 1;
36
38
  return {
37
- series: s,
38
- rows: l,
39
- n: k,
40
- bars: A,
41
- 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", {
39
+ series: r,
40
+ rows: c,
41
+ n: D,
42
+ bars: O,
43
+ banded: A,
44
+ step: j,
45
+ left: w,
46
+ plotH: E,
47
+ cx0: M,
48
+ cy: F,
49
+ base: L,
50
+ barW: R,
51
+ barX: z,
52
+ back: /* @__PURE__ */ h(p, { children: [
53
+ /* @__PURE__ */ m("defs", { children: r.map((e, t) => e.kind === "area" ? /* @__PURE__ */ h("linearGradient", {
52
54
  id: `${P}-fill-${t}`,
53
55
  x1: "0",
54
56
  y1: "0",
55
57
  x2: "0",
56
58
  y2: "1",
57
- children: [/* @__PURE__ */ p("stop", {
59
+ children: [/* @__PURE__ */ m("stop", {
58
60
  offset: "0%",
59
61
  style: { stopColor: e.color },
60
62
  stopOpacity: e.dashed ? .16 : .32
61
- }), /* @__PURE__ */ p("stop", {
63
+ }), /* @__PURE__ */ m("stop", {
62
64
  offset: "100%",
63
65
  style: { stopColor: e.color },
64
66
  stopOpacity: 0
65
67
  })]
66
68
  }, 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),
69
+ u.map((e, t) => /* @__PURE__ */ h("g", { children: [/* @__PURE__ */ m("line", {
70
+ x1: w,
71
+ x2: w + T,
72
+ y1: F(e),
73
+ y2: F(e),
72
74
  className: "stroke-tint/[0.07]",
73
75
  shapeRendering: "crispEdges"
74
- }), /* @__PURE__ */ p("text", {
75
- x: T - 8,
76
- y: L(e),
76
+ }), /* @__PURE__ */ m("text", {
77
+ x: w - 8,
78
+ y: F(e),
77
79
  dy: "0.32em",
78
80
  textAnchor: "end",
79
81
  className: "fill-muted-foreground tabular-nums",
80
- style: { fontSize: b },
81
- children: w[t]
82
+ style: { fontSize: x },
83
+ children: S[t]
82
84
  })] }, e)),
83
- V.map((e, t) => t % U === 0 ? /* @__PURE__ */ p("text", {
84
- x: F(t),
85
+ B.map((e, t) => t % H === 0 ? /* @__PURE__ */ m("text", {
86
+ x: M(t),
85
87
  y: g - 8,
86
- textAnchor: !A.length && k > 1 && t === 0 ? "start" : !A.length && t === k - 1 ? "end" : "middle",
88
+ textAnchor: !O.length && D > 1 && t === 0 ? "start" : !O.length && t === D - 1 ? "end" : "middle",
87
89
  className: "fill-muted-foreground",
88
- style: { fontSize: b },
90
+ style: { fontSize: x },
89
91
  children: e
90
92
  }, t) : null)
91
93
  ] }),
92
- front: /* @__PURE__ */ m(f, { children: [s.map((e, t) => e.kind === "bar" ? null : te(l.map((t, n) => {
93
- let r = S(t, e.dataKey);
94
- return r === null ? null : [F(n), L(r)];
94
+ front: /* @__PURE__ */ h(p, { children: [r.map((e, t) => e.kind === "bar" ? null : re(c.map((t, n) => {
95
+ let r = C(t, e.dataKey);
96
+ return r === null ? null : [M(n), F(r)];
95
97
  })).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`,
98
+ let i = (e.curve === "linear" ? k : ie)(n);
99
+ return /* @__PURE__ */ h("g", { children: [e.kind === "area" && /* @__PURE__ */ m("path", {
100
+ d: `${i}L${n[n.length - 1][0]},${L}L${n[0][0]},${L}Z`,
99
101
  fill: `url(#${P}-fill-${t})`,
100
102
  className: "zen__chart-fade"
101
- }), /* @__PURE__ */ p("path", {
103
+ }), /* @__PURE__ */ m("path", {
102
104
  d: i,
103
105
  fill: "none",
104
106
  strokeWidth: e.kind === "area" && !e.dashed ? 2.5 : 2,
@@ -109,157 +111,159 @@ function x({ data: r, x: i, label: s, summary: h, height: g = 240, formatX: _ =
109
111
  className: e.dashed ? "zen__chart-fade" : "zen__chart-draw",
110
112
  style: { stroke: e.color }
111
113
  })] }, `${t}-${r}`);
112
- })), c.map((e, t) => {
114
+ })), o.map((e, t) => {
113
115
  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),
116
+ if (e.y !== void 0) return /* @__PURE__ */ m("line", {
117
+ x1: w,
118
+ x2: w + T,
119
+ y1: F(e.y),
120
+ y2: F(e.y),
119
121
  className: n,
120
122
  strokeDasharray: e.dashed ? "3 4" : void 0,
121
123
  shapeRendering: "crispEdges"
122
124
  }, t);
123
- let r = l.findIndex((t) => t[i] === e.x);
125
+ let r = c.findIndex((t) => t[a] === e.x);
124
126
  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),
129
- y1: y.top,
130
- y2: y.top + O,
127
+ let i = !!e.label && M(r) - 6 - e.label.length * x * .6 < w;
128
+ return /* @__PURE__ */ h("g", { children: [/* @__PURE__ */ m("line", {
129
+ x1: M(r),
130
+ x2: M(r),
131
+ y1: b.top,
132
+ y2: b.top + E,
131
133
  className: n,
132
134
  strokeDasharray: e.dashed === !1 ? void 0 : "3 4"
133
- }), e.label && /* @__PURE__ */ p("text", {
134
- x: F(r) + (a ? 6 : -6),
135
- y: y.top + 4,
135
+ }), e.label && /* @__PURE__ */ m("text", {
136
+ x: M(r) + (i ? 6 : -6),
137
+ y: b.top + 4,
136
138
  dy: "0.7em",
137
- textAnchor: a ? "start" : "end",
139
+ textAnchor: i ? "start" : "end",
138
140
  className: "fill-muted-foreground",
139
- style: { fontSize: b },
141
+ style: { fontSize: x },
140
142
  children: e.label
141
143
  })] }, t);
142
144
  })] })
143
145
  };
144
146
  }, [
145
- ie,
146
- r,
147
+ N,
147
148
  i,
149
+ a,
148
150
  I,
149
151
  g,
150
152
  _,
151
- x,
153
+ v,
152
154
  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) => {
155
- let i = S(n, e.dataKey);
155
+ ae
156
+ ]), { 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) => {
157
+ let i = C(n, e.dataKey);
156
158
  if (i === null) return null;
157
159
  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),
160
+ return /* @__PURE__ */ m("path", {
161
+ d: A(le(r, t), s ? Z : a, ce, o, s),
160
162
  "data-negative": s || void 0,
161
163
  className: "zen__chart-grow transition-opacity duration-200",
162
164
  style: {
163
165
  fill: e.color,
164
- opacity: (e.dim?.(n, r) ? .35 : .9) * (L !== null && L !== r ? .7 : 1),
166
+ opacity: (e.dim?.(n, r) ? .35 : .9) * (R !== null && R !== r ? .7 : 1),
165
167
  animationDelay: `${Math.min(r * 25, 400)}ms`
166
168
  }
167
169
  }, `${t}-${r}`);
168
170
  })), [
169
- G,
170
- U,
171
+ K,
172
+ W,
171
173
  X,
172
174
  Z,
173
- se,
174
- oe,
175
- L
176
- ]), le = l(() => /* @__PURE__ */ p("div", {
175
+ le,
176
+ ce,
177
+ R
178
+ ]), de = u(() => /* @__PURE__ */ m("div", {
177
179
  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", {
180
+ children: /* @__PURE__ */ h("table", { children: [
181
+ /* @__PURE__ */ m("caption", { children: o }),
182
+ /* @__PURE__ */ m("thead", { children: /* @__PURE__ */ h("tr", { children: [/* @__PURE__ */ m("th", {
181
183
  scope: "col",
182
- children: String(i)
183
- }), H.map((e) => /* @__PURE__ */ p("th", {
184
+ children: String(a)
185
+ }), U.map((e) => /* @__PURE__ */ m("th", {
184
186
  scope: "col",
185
187
  children: e.label
186
188
  }, e.dataKey))] }) }),
187
- /* @__PURE__ */ p("tbody", { children: U.map((e, t) => /* @__PURE__ */ m("tr", { children: [/* @__PURE__ */ p("th", {
189
+ /* @__PURE__ */ m("tbody", { children: W.map((e, t) => /* @__PURE__ */ h("tr", { children: [/* @__PURE__ */ m("th", {
188
190
  scope: "row",
189
- children: (D ?? _)(e[i])
190
- }), H.map((t) => {
191
- let n = S(e, t.dataKey);
192
- return /* @__PURE__ */ p("td", { children: n === null ? "" : x(n) }, t.dataKey);
191
+ children: (S ?? _)(e[a])
192
+ }), U.map((t) => {
193
+ let n = C(e, t.dataKey);
194
+ return /* @__PURE__ */ m("td", { children: n === null ? "" : v(n) }, t.dataKey);
193
195
  })] }, t)) })
194
196
  ] })
195
197
  }), [
196
- s,
197
- i,
198
- H,
198
+ o,
199
+ a,
199
200
  U,
200
- D,
201
+ W,
202
+ S,
201
203
  _,
202
- 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
+ v
205
+ ]), fe = (e) => {
206
+ if (!G || !q) return null;
207
+ let t = oe ? Math.floor((e - J) / q) : Math.round((e - J) / q);
208
+ return Math.min(G - 1, Math.max(0, t));
209
+ }, pe = (e) => {
208
210
  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;
211
+ z(fe(n)), V((e) => e?.y === r ? e : { y: r });
212
+ }, me = (e) => {
213
+ if (!G) return;
212
214
  let t = {
213
215
  ArrowRight: 1,
214
216
  ArrowLeft: -1
215
217
  }[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,
222
- className: e("zen__chart m-0 flex flex-col gap-3", N),
218
+ if (e.key === "Escape") return z(null);
219
+ if (e.key === "Home" || e.key === "End") return e.preventDefault(), V(null), z(e.key === "Home" ? 0 : G - 1);
220
+ t && (e.preventDefault(), V(null), z((e) => e === null ? t > 0 ? 0 : G - 1 : Math.min(G - 1, Math.max(0, e + t))));
221
+ }, he = j ?? (U.length > 1 || U.some((e) => e.dimLabel)), Q = R === null ? null : W[R], $ = R === null ? 0 : se(R), ge = B?.y ?? b.top;
222
+ return /* @__PURE__ */ h("figure", {
223
+ "aria-label": o,
224
+ className: e("zen__chart m-0 flex flex-col gap-3", M),
223
225
  children: [
224
- pe && /* @__PURE__ */ p(C, { series: H }),
225
- /* @__PURE__ */ m("div", {
226
+ he && /* @__PURE__ */ m(w, { series: U }),
227
+ /* @__PURE__ */ h("div", {
226
228
  ref: F,
229
+ "data-zen-unseen": L ? void 0 : "",
227
230
  tabIndex: 0,
228
- "aria-label": `${s}: use the arrow keys to read values`,
229
- onPointerMove: de,
231
+ role: "group",
232
+ "aria-label": `${o}: use the arrow keys to read values`,
233
+ onPointerMove: pe,
230
234
  onPointerLeave: () => {
231
- R(null), B(null);
235
+ z(null), V(null);
232
236
  },
233
- onKeyDown: fe,
234
- onBlur: () => R(null),
237
+ onKeyDown: me,
238
+ onBlur: () => z(null),
235
239
  className: "focus-visible:ring-ring/50 relative rounded-lg outline-hidden focus-visible:ring-2",
236
240
  style: { height: g },
237
- children: [I > 0 && /* @__PURE__ */ m("svg", {
241
+ children: [I > 0 && /* @__PURE__ */ h("svg", {
238
242
  width: I,
239
243
  height: g,
240
244
  "aria-hidden": !0,
241
245
  className: "block overflow-visible",
242
246
  children: [
243
- V.back,
244
- L !== null && (G.length ? /* @__PURE__ */ p("rect", {
245
- x: Y(L) - K / 2,
246
- y: y.top,
247
- width: K,
248
- height: J,
247
+ H.back,
248
+ R !== null && (K.length ? /* @__PURE__ */ m("rect", {
249
+ x: se(R) - q / 2,
250
+ y: b.top,
251
+ width: q,
252
+ height: Y,
249
253
  className: "fill-tint/[0.04]"
250
- }) : /* @__PURE__ */ p("line", {
254
+ }) : /* @__PURE__ */ m("line", {
251
255
  x1: $,
252
256
  x2: $,
253
- y1: y.top,
254
- y2: y.top + J,
257
+ y1: b.top,
258
+ y2: b.top + Y,
255
259
  className: "stroke-glow/40"
256
260
  })),
257
- ce,
258
- V.front,
259
- L !== null && H.map((e, t) => {
261
+ ue,
262
+ H.front,
263
+ R !== null && U.map((e, t) => {
260
264
  if (e.kind === "bar") return null;
261
- let n = S(U[L], e.dataKey);
262
- return n === null ? null : /* @__PURE__ */ p("circle", {
265
+ let n = C(W[R], e.dataKey);
266
+ return n === null ? null : /* @__PURE__ */ m("circle", {
263
267
  cx: $,
264
268
  cy: X(n),
265
269
  r: 4,
@@ -269,50 +273,50 @@ function x({ data: r, x: i, label: s, summary: h, height: g = 240, formatX: _ =
269
273
  }, t);
270
274
  })
271
275
  ]
272
- }), Q && L !== null && /* @__PURE__ */ p("div", {
276
+ }), Q && R !== null && /* @__PURE__ */ m("div", {
273
277
  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) => ({
278
+ style: T($, ge, I, g),
279
+ children: D ? D(Q, R) : /* @__PURE__ */ m(r, {
280
+ title: (S ?? _)(Q[a]),
281
+ rows: U.map((e) => ({
278
282
  s: e,
279
- v: S(Q, e.dataKey)
283
+ v: C(Q, e.dataKey)
280
284
  })).filter(({ v: e }) => e !== null).map(({ s: e, v: t }) => ({
281
285
  label: e.label,
282
- value: x(t),
286
+ value: v(t),
283
287
  color: e.color,
284
288
  dashed: e.dashed
285
289
  }))
286
290
  })
287
291
  })]
288
292
  }),
289
- h && /* @__PURE__ */ p("figcaption", {
293
+ c && /* @__PURE__ */ m("figcaption", {
290
294
  className: "sr-only",
291
- children: h
295
+ children: c
292
296
  }),
293
- le
297
+ de
294
298
  ]
295
299
  });
296
300
  }
297
- function S(e, t) {
301
+ function C(e, t) {
298
302
  let n = e[t];
299
303
  return typeof n == "number" && Number.isFinite(n) ? n : null;
300
304
  }
301
- function C({ series: e }) {
305
+ function w({ series: e }) {
302
306
  let t = e.filter((t, n) => t.dimLabel && e.findIndex((e) => e.dimLabel === t.dimLabel) === n);
303
- return /* @__PURE__ */ m("ul", {
307
+ return /* @__PURE__ */ h("ul", {
304
308
  className: "text-muted-foreground flex flex-wrap gap-x-4 gap-y-1 text-xs",
305
309
  "aria-label": "Legend",
306
- children: [e.map((e) => /* @__PURE__ */ m("li", {
310
+ children: [e.map((e) => /* @__PURE__ */ h("li", {
307
311
  className: "flex items-center gap-1.5",
308
- children: [/* @__PURE__ */ p(r, {
312
+ children: [/* @__PURE__ */ m(i, {
309
313
  color: e.color,
310
314
  dashed: e.dashed,
311
315
  kind: e.kind
312
316
  }), e.label]
313
- }, e.dataKey)), t.map((e) => /* @__PURE__ */ m("li", {
317
+ }, e.dataKey)), t.map((e) => /* @__PURE__ */ h("li", {
314
318
  className: "flex items-center gap-1.5",
315
- children: [/* @__PURE__ */ p(r, {
319
+ children: [/* @__PURE__ */ m(i, {
316
320
  color: e.color,
317
321
  kind: "bar",
318
322
  faded: !0
@@ -320,7 +324,7 @@ function C({ series: e }) {
320
324
  }, `faded-${e.dimLabel}`))]
321
325
  });
322
326
  }
323
- function w(e, t, n, r) {
327
+ function T(e, t, n, r) {
324
328
  let i = e > n / 2, a = Math.round(Math.min(Math.max(0, t - 20), r - 80));
325
329
  return i ? {
326
330
  right: 0,
@@ -330,35 +334,35 @@ function w(e, t, n, r) {
330
334
  translate: `${Math.round(e + 12)}px ${a}px`
331
335
  };
332
336
  }
333
- function T(e) {
334
- let [t, n] = d(0);
335
- return s(() => {
337
+ function E(e) {
338
+ let [t, n] = f(0);
339
+ return c(() => {
336
340
  let t = e.current;
337
341
  if (!t || (n(t.clientWidth), typeof ResizeObserver > "u")) return;
338
342
  let r = new ResizeObserver(() => n(t.clientWidth));
339
343
  return r.observe(t), () => r.disconnect();
340
344
  }, [e]), t;
341
345
  }
342
- function E(e, t, n = 5) {
346
+ function ne(e, t, n = 5) {
343
347
  e === t && ([e, t] = e === 0 ? [0, 1] : [Math.min(0, e), Math.max(0, t)]);
344
- let r = (t - e) / n, i = 10 ** Math.floor(Math.log10(r)), a = r / i, o = i * (a >= 7.5 ? 10 : a >= 3.5 ? 5 : a >= 1.5 ? 2 : 1), s = Math.floor(e / o), c = Math.ceil(t / o);
345
- return Array.from({ length: c - s + 1 }, (e, t) => Number(((s + t) * o).toPrecision(12)));
348
+ let r = (t - e) / n, i = 10 ** Math.floor(Math.log10(r)), a = r / i, o = i * (a >= 7.5 ? 10 : a >= 3.5 ? 5 : a >= 1.5 ? 2 : 1), s = Math.floor(e / o), ee = Math.ceil(t / o);
349
+ return Array.from({ length: ee - s + 1 }, (e, t) => Number(((s + t) * o).toPrecision(12)));
346
350
  }
347
351
  var D = new Intl.NumberFormat("en", {
348
352
  notation: "compact",
349
353
  maximumFractionDigits: 1
350
354
  }), O = (e) => D.format(e);
351
- function te(e) {
355
+ function re(e) {
352
356
  let t = [], n = [];
353
357
  for (let r of e) r ? n.push(r) : n.length && (t.push(n), n = []);
354
358
  return n.length && t.push(n), t;
355
359
  }
356
- function ne(e) {
360
+ function k(e) {
357
361
  return e.map(([e, t], n) => `${n ? "L" : "M"}${e},${t}`).join("");
358
362
  }
359
- function re(e) {
363
+ function ie(e) {
360
364
  let t = e.length;
361
- if (t < 3) return ne(e);
365
+ if (t < 3) return k(e);
362
366
  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
367
  for (let r = 0; r < t - 1; r++) {
364
368
  let t = n[r] / 3;
@@ -366,9 +370,9 @@ function re(e) {
366
370
  }
367
371
  return a;
368
372
  }
369
- function k(e, t, n, r, i) {
373
+ function A(e, t, n, r, i) {
370
374
  let a = Math.min(4, n / 2, r);
371
375
  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
376
  }
373
377
  //#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 };
378
+ export { a as AllocationBar, g as ChartArea, v as ChartBar, _ as ChartLine, te as ChartReference, r as ChartTooltipCard, o as DonutChart, S as default, ne as niceTicks, n as paletteColor };
@@ -1,7 +1,7 @@
1
1
  import { ComponentProps } from 'react';
2
2
  /**
3
3
  * Code on a glass panel whose edge catches the pointer light, with a copy
4
- * button. Zen ships no highlighter: pass `highlight` (code → HTML string, e.g.
4
+ * button. Give it a max height (className) and the code scrolls inside. Zen ships no highlighter: pass `highlight` (code → HTML string, e.g.
5
5
  * sugar-high's `highlight`) for colours.
6
6
  */
7
7
  export default function CodeBlock({ code, language, highlight, copyable, variant, className, ...rest }: CodeBlockProps): import('react').JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/code-block/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAuB,MAAM,OAAO,CAAC;AAE5D;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAC9B,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,QAAe,EACf,OAAiB,EACjB,SAAS,EACT,GAAG,IAAI,EACV,EAAE,cAAc,+BA+ChB;AAED,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACxD,iDAAiD;IACjD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wGAAwG;IACxG,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAC/B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/code-block/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAA+B,MAAM,OAAO,CAAC;AAEpE;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAC9B,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,QAAe,EACf,OAAiB,EACjB,SAAS,EACT,GAAG,IAAI,EACV,EAAE,cAAc,+BA8DhB;AAED,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACxD,iDAAiD;IACjD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wGAAwG;IACxG,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAC/B"}
@@ -1,36 +1,45 @@
1
1
  "use client";
2
2
  import { cx as e } from "../utils/cx.js";
3
- import { useEffect as t, useState as n } from "react";
4
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
3
+ import { useEffect as t, useRef as n, useState as r } from "react";
4
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
5
5
  //#region packages/code-block/index.tsx
6
- function a({ code: a, language: o, highlight: s, copyable: c = !0, variant: l = "glass", className: u, ...d }) {
7
- let f = a.trim(), [p, m] = n(!1);
8
- return t(() => {
9
- if (!p) return;
10
- let e = setTimeout(() => m(!1), 1500);
6
+ function o({ code: o, language: s, highlight: c, copyable: l = !0, variant: u = "glass", className: d, ...f }) {
7
+ let p = o.trim(), [m, h] = r(!1);
8
+ t(() => {
9
+ if (!m) return;
10
+ let e = setTimeout(() => h(!1), 1500);
11
11
  return () => clearTimeout(e);
12
- }, [p]), /* @__PURE__ */ i("div", {
13
- className: e("zen__code-block group relative", l === "glass" && "glass glow-edge overflow-hidden rounded-xl", u),
14
- "data-language": o,
15
- ...d,
16
- children: [/* @__PURE__ */ r("pre", {
17
- className: "text-foreground m-0! overflow-x-auto rounded-none! bg-transparent! p-5! font-mono text-[13px]! leading-6 font-normal!",
18
- children: s ? /* @__PURE__ */ r("code", {
12
+ }, [m]);
13
+ let g = n(null), [_, v] = r(!1);
14
+ return t(() => {
15
+ let e = g.current;
16
+ if (!e || typeof ResizeObserver > "u") return;
17
+ let t = new ResizeObserver(() => v(e.scrollWidth > e.clientWidth || e.scrollHeight > e.clientHeight));
18
+ return t.observe(e), () => t.disconnect();
19
+ }, []), /* @__PURE__ */ a("div", {
20
+ className: e("zen__code-block group relative flex flex-col", u === "glass" && "glass glow-edge overflow-hidden rounded-xl", d),
21
+ "data-language": s,
22
+ ...f,
23
+ children: [/* @__PURE__ */ i("pre", {
24
+ ref: g,
25
+ tabIndex: _ ? 0 : void 0,
26
+ className: "text-foreground focus-visible:ring-ring/50 m-0! min-h-0 overflow-auto rounded-none! bg-transparent! p-5! font-mono text-[13px]! leading-6 font-normal! outline-hidden focus-visible:ring-2 focus-visible:ring-inset",
27
+ children: c ? /* @__PURE__ */ i("code", {
19
28
  className: "bg-transparent! p-0! text-inherit!",
20
- dangerouslySetInnerHTML: { __html: s(f, o) }
21
- }) : /* @__PURE__ */ r("code", {
29
+ dangerouslySetInnerHTML: { __html: c(p, s) }
30
+ }) : /* @__PURE__ */ i("code", {
22
31
  className: "bg-transparent! p-0! text-inherit!",
23
- children: f
32
+ children: p
24
33
  })
25
- }), c && /* @__PURE__ */ r("button", {
34
+ }), l && /* @__PURE__ */ i("button", {
26
35
  type: "button",
27
36
  onClick: async () => {
28
- await navigator.clipboard?.writeText(f), m(!0);
37
+ await navigator.clipboard?.writeText(p), h(!0);
29
38
  },
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"),
31
- children: p ? "Copied" : "Copy"
39
+ 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", m && "text-primary opacity-100"),
40
+ children: m ? "Copied" : "Copy"
32
41
  })]
33
42
  });
34
43
  }
35
44
  //#endregion
36
- export { a as default };
45
+ export { o as default };