@rinzai/zen 0.6.1 → 0.7.1

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 (161) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +3 -3
  3. package/dist/alert/index.d.ts +21 -0
  4. package/dist/alert/index.d.ts.map +1 -0
  5. package/dist/alert/index.js +49 -0
  6. package/dist/avatar/index.d.ts.map +1 -1
  7. package/dist/avatar/index.js +25 -22
  8. package/dist/button/index.d.ts +2 -1
  9. package/dist/button/index.d.ts.map +1 -1
  10. package/dist/button/index.js +43 -12
  11. package/dist/calendar/index.d.ts.map +1 -1
  12. package/dist/calendar/index.js +86 -85
  13. package/dist/chart/donut.d.ts +4 -1
  14. package/dist/chart/donut.d.ts.map +1 -1
  15. package/dist/chart/donut.js +76 -66
  16. package/dist/chart/index.d.ts +8 -2
  17. package/dist/chart/index.d.ts.map +1 -1
  18. package/dist/chart/index.js +192 -182
  19. package/dist/chart/palette.d.ts +14 -0
  20. package/dist/chart/palette.d.ts.map +1 -0
  21. package/dist/chart/palette.js +9 -0
  22. package/dist/chart/tooltip.d.ts +6 -2
  23. package/dist/chart/tooltip.d.ts.map +1 -1
  24. package/dist/chart/tooltip.js +6 -6
  25. package/dist/checkbox/index.d.ts.map +1 -1
  26. package/dist/checkbox/index.js +28 -44
  27. package/dist/chip/index.js +1 -1
  28. package/dist/code-block/index.js +1 -1
  29. package/dist/date-picker/index.d.ts.map +1 -1
  30. package/dist/date-picker/index.js +24 -38
  31. package/dist/disclosure/index.js +1 -1
  32. package/dist/editable-cell/index.js +1 -1
  33. package/dist/field/index.d.ts +1 -1
  34. package/dist/field/index.d.ts.map +1 -1
  35. package/dist/field/index.js +33 -32
  36. package/dist/header/index.d.ts +9 -1
  37. package/dist/header/index.d.ts.map +1 -1
  38. package/dist/header/index.js +17 -9
  39. package/dist/icons/arrow-left.d.ts +3 -0
  40. package/dist/icons/arrow-left.d.ts.map +1 -0
  41. package/dist/icons/arrow-right.d.ts +3 -0
  42. package/dist/icons/arrow-right.d.ts.map +1 -0
  43. package/dist/icons/bars.d.ts +3 -0
  44. package/dist/icons/bars.d.ts.map +1 -0
  45. package/dist/icons/calendar.d.ts +3 -0
  46. package/dist/icons/calendar.d.ts.map +1 -0
  47. package/dist/icons/chart-bar.d.ts +3 -0
  48. package/dist/icons/chart-bar.d.ts.map +1 -0
  49. package/dist/icons/chevron-down.d.ts.map +1 -1
  50. package/dist/icons/chevron-down.js +4 -2
  51. package/dist/icons/chevron-left.d.ts.map +1 -1
  52. package/dist/icons/chevron-left.js +4 -2
  53. package/dist/icons/chevron-right.d.ts.map +1 -1
  54. package/dist/icons/chevron-right.js +4 -2
  55. package/dist/icons/chevron-up.d.ts.map +1 -1
  56. package/dist/icons/chevron-up.js +4 -2
  57. package/dist/icons/ellipsis.d.ts +0 -1
  58. package/dist/icons/ellipsis.d.ts.map +1 -1
  59. package/dist/icons/flag.d.ts +3 -0
  60. package/dist/icons/flag.d.ts.map +1 -0
  61. package/dist/icons/list-bullet.d.ts +3 -0
  62. package/dist/icons/list-bullet.d.ts.map +1 -0
  63. package/dist/icons/lock.d.ts +3 -0
  64. package/dist/icons/lock.d.ts.map +1 -0
  65. package/dist/icons/logout.d.ts +3 -0
  66. package/dist/icons/logout.d.ts.map +1 -0
  67. package/dist/icons/micro/calendar.d.ts +3 -0
  68. package/dist/icons/micro/calendar.d.ts.map +1 -0
  69. package/dist/icons/micro/calendar.js +21 -0
  70. package/dist/icons/micro/check.d.ts +3 -0
  71. package/dist/icons/micro/check.d.ts.map +1 -0
  72. package/dist/icons/micro/check.js +21 -0
  73. package/dist/icons/micro/chevron-down.d.ts +3 -0
  74. package/dist/icons/micro/chevron-down.d.ts.map +1 -0
  75. package/dist/icons/micro/chevron-down.js +21 -0
  76. package/dist/icons/micro/chevron-right.d.ts +3 -0
  77. package/dist/icons/micro/chevron-right.d.ts.map +1 -0
  78. package/dist/icons/micro/chevron-right.js +21 -0
  79. package/dist/icons/micro/exclamation-triangle.d.ts +3 -0
  80. package/dist/icons/micro/exclamation-triangle.d.ts.map +1 -0
  81. package/dist/icons/micro/exclamation-triangle.js +21 -0
  82. package/dist/icons/micro/information-circle.d.ts +3 -0
  83. package/dist/icons/micro/information-circle.d.ts.map +1 -0
  84. package/dist/icons/micro/information-circle.js +21 -0
  85. package/dist/icons/micro/minus.d.ts +3 -0
  86. package/dist/icons/micro/minus.d.ts.map +1 -0
  87. package/dist/icons/micro/minus.js +17 -0
  88. package/dist/icons/micro/moon.d.ts +3 -0
  89. package/dist/icons/micro/moon.d.ts.map +1 -0
  90. package/dist/icons/micro/moon.js +17 -0
  91. package/dist/icons/micro/sun.d.ts +3 -0
  92. package/dist/icons/micro/sun.d.ts.map +1 -0
  93. package/dist/icons/micro/sun.js +17 -0
  94. package/dist/icons/micro/x-mark.d.ts +3 -0
  95. package/dist/icons/micro/x-mark.d.ts.map +1 -0
  96. package/dist/icons/micro/x-mark.js +17 -0
  97. package/dist/icons/search.d.ts.map +1 -1
  98. package/dist/icons/search.js +4 -2
  99. package/dist/icons/settings.d.ts +3 -0
  100. package/dist/icons/settings.d.ts.map +1 -0
  101. package/dist/icons/squares.d.ts +3 -0
  102. package/dist/icons/squares.d.ts.map +1 -0
  103. package/dist/icons/table.d.ts +3 -0
  104. package/dist/icons/table.d.ts.map +1 -0
  105. package/dist/icons/x-mark.d.ts.map +1 -1
  106. package/dist/icons/x-mark.js +4 -2
  107. package/dist/index.d.ts +7 -5
  108. package/dist/index.d.ts.map +1 -1
  109. package/dist/lib.js +57 -61
  110. package/dist/menu/index.d.ts.map +1 -1
  111. package/dist/menu/index.js +67 -60
  112. package/dist/month-picker/index.d.ts.map +1 -1
  113. package/dist/month-picker/index.js +55 -55
  114. package/dist/pills/index.d.ts +1 -1
  115. package/dist/pills/index.d.ts.map +1 -1
  116. package/dist/pills/index.js +6 -2
  117. package/dist/popover/index.js +12 -11
  118. package/dist/select/index.d.ts.map +1 -1
  119. package/dist/select/index.js +96 -102
  120. package/dist/slider/index.d.ts.map +1 -1
  121. package/dist/slider/index.js +1 -1
  122. package/dist/status-pill/index.d.ts +18 -0
  123. package/dist/status-pill/index.d.ts.map +1 -0
  124. package/dist/status-pill/index.js +25 -0
  125. package/dist/tab-bar/index.js +1 -1
  126. package/dist/table/index.js +1 -1
  127. package/dist/tabs/index.d.ts.map +1 -1
  128. package/dist/tabs/index.js +9 -5
  129. package/dist/theme-toggle/index.d.ts +26 -4
  130. package/dist/theme-toggle/index.d.ts.map +1 -1
  131. package/dist/theme-toggle/index.js +42 -35
  132. package/dist/theme.css +67 -1
  133. package/dist/toast/index.d.ts.map +1 -1
  134. package/dist/toast/index.js +119 -106
  135. package/dist/tree/index.d.ts +22 -3
  136. package/dist/tree/index.d.ts.map +1 -1
  137. package/dist/tree/index.js +76 -56
  138. package/dist/utils/date.d.ts +6 -4
  139. package/dist/utils/date.d.ts.map +1 -1
  140. package/dist/utils/date.js +18 -16
  141. package/dist/utils/field-chevron.d.ts.map +1 -1
  142. package/dist/utils/field-chevron.js +5 -14
  143. package/dist/utils/status-icons.d.ts +1 -1
  144. package/dist/utils/status-icons.d.ts.map +1 -1
  145. package/dist/utils/status-icons.js +11 -41
  146. package/dist/utils/styles.d.ts +9 -3
  147. package/dist/utils/styles.d.ts.map +1 -1
  148. package/dist/utils/styles.js +2 -2
  149. package/dist/utils/theme-wave.d.ts +26 -0
  150. package/dist/utils/theme-wave.d.ts.map +1 -0
  151. package/dist/utils/theme-wave.js +239 -0
  152. package/dist/utils/typeahead.d.ts +12 -0
  153. package/dist/utils/typeahead.d.ts.map +1 -0
  154. package/dist/utils/typeahead.js +19 -0
  155. package/dist/zen.css +1 -1
  156. package/package.json +2 -1
  157. package/dist/icons/ellipsis.js +0 -31
  158. package/dist/icons/index.d.ts +0 -9
  159. package/dist/icons/index.d.ts.map +0 -1
  160. package/dist/icons/status.d.ts +0 -2
  161. package/dist/icons/status.d.ts.map +0 -1
@@ -1,103 +1,104 @@
1
1
  "use client";
2
2
  import { cx as e } from "../utils/cx.js";
3
- import { ChartTooltipCard as t, Key as n } from "./tooltip.js";
4
- import r from "./donut.js";
5
- import { Children as i, isValidElement as a, useEffect as o, useId as s, useMemo as c, useRef as l, useState as u } from "react";
6
- import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
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";
7
8
  //#region packages/chart/index.tsx
8
- var m = () => null, h = () => null, g = () => null, _ = () => null, ee = /* @__PURE__ */ new Map([
9
- [m, "area"],
10
- [h, "line"],
11
- [g, "bar"]
12
- ]), v = {
9
+ var h = () => null, g = () => null, _ = () => null, v = () => null, ee = /* @__PURE__ */ new Map([
10
+ [h, "area"],
11
+ [g, "line"],
12
+ [_, "bar"]
13
+ ]), y = {
13
14
  top: 12,
14
15
  right: 8,
15
16
  bottom: 26
16
- }, y = 11;
17
- function b({ data: n, x: r, label: o, summary: m, height: h = 240, formatX: g = String, formatY: b = D, formatTooltipX: E, renderTooltip: k, legend: A, className: j, children: M }) {
18
- let N = s().replace(/[^\w-]/g, ""), P = l(null), F = w(P), [I, L] = u(null), [R, z] = u(null), B = c(() => {
19
- let e = i.toArray(M).filter(a), t = 0, o = [], s = [];
20
- for (let n of e) {
21
- n.type === _ && s.push(n.props);
22
- let e = ee.get(n.type);
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);
23
24
  if (!e) continue;
24
- let r = n.props;
25
- t++, o.push({
26
- ...r,
25
+ let i = r.props;
26
+ s.push({
27
+ ...i,
27
28
  kind: e,
28
- color: r.color ?? `var(--chart-${Math.min(t, 8)})`
29
+ color: i.color ?? t(M, s.length, n)
29
30
  });
30
31
  }
31
- let c = n, l = o.flatMap((e) => c.map((t) => x(t, e.dataKey))).filter((e) => e !== null);
32
- for (let e of s) e.y !== void 0 && l.push(e.y);
33
- o.some((e) => e.kind !== "line") && l.push(0);
34
- let u = T(l.length ? Math.min(...l) : 0, l.length ? Math.max(...l) : 1), [m, S] = [u[0], u[u.length - 1]], C = u.map((e) => b(e)), w = Math.ceil(Math.max(...C.map((e) => e.length)) * y * .62) + 10, E = Math.max(0, F - w - v.right), D = Math.max(0, h - v.top - v.bottom), O = c.length, k = o.filter((e) => e.kind === "bar"), A = k.length > 0 || O === 1, j = O ? A ? E / O : E / (O - 1) : 0, P = (e) => w + (A ? (e + .5) * j : e * j), I = (e) => v.top + (S === m ? D / 2 : (S - e) / (S - m) * D), L = I(Math.min(Math.max(0, m), S)), R = k.length ? Math.max(2, Math.min(24, j * .72 / k.length - 2)) : 0, z = (e, t) => P(e) - (k.length * (R + 2) - 2) / 2 + t * (R + 2), B = c.map((e) => g(e[r])), V = Math.max(1, ...B.map((e) => e.length)) * y * .6 + 12, H = j ? Math.max(1, Math.ceil(V / j)) : 1;
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;
35
36
  return {
36
- series: o,
37
- rows: c,
38
- n: O,
39
- bars: k,
40
- banded: A,
41
- step: j,
42
- left: w,
43
- plotH: D,
44
- cx0: P,
45
- cy: I,
46
- base: L,
47
- barW: R,
48
- barX: z,
49
- back: /* @__PURE__ */ p(d, { children: [
50
- /* @__PURE__ */ f("defs", { children: o.map((e, t) => e.kind === "area" ? /* @__PURE__ */ p("linearGradient", {
51
- id: `${N}-fill-${t}`,
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", {
52
+ id: `${P}-fill-${t}`,
52
53
  x1: "0",
53
54
  y1: "0",
54
55
  x2: "0",
55
56
  y2: "1",
56
- children: [/* @__PURE__ */ f("stop", {
57
+ children: [/* @__PURE__ */ p("stop", {
57
58
  offset: "0%",
58
59
  style: { stopColor: e.color },
59
60
  stopOpacity: e.dashed ? .16 : .32
60
- }), /* @__PURE__ */ f("stop", {
61
+ }), /* @__PURE__ */ p("stop", {
61
62
  offset: "100%",
62
63
  style: { stopColor: e.color },
63
64
  stopOpacity: 0
64
65
  })]
65
66
  }, t) : null) }),
66
- u.map((e, t) => /* @__PURE__ */ p("g", { children: [/* @__PURE__ */ f("line", {
67
- x1: w,
68
- x2: w + E,
69
- y1: I(e),
70
- y2: I(e),
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),
71
72
  className: "stroke-tint/[0.07]",
72
73
  shapeRendering: "crispEdges"
73
- }), /* @__PURE__ */ f("text", {
74
- x: w - 8,
75
- y: I(e),
74
+ }), /* @__PURE__ */ p("text", {
75
+ x: T - 8,
76
+ y: L(e),
76
77
  dy: "0.32em",
77
78
  textAnchor: "end",
78
79
  className: "fill-muted-foreground tabular-nums",
79
- style: { fontSize: y },
80
- children: C[t]
80
+ style: { fontSize: b },
81
+ children: w[t]
81
82
  })] }, e)),
82
- B.map((e, t) => t % H === 0 ? /* @__PURE__ */ f("text", {
83
- x: P(t),
84
- y: h - 8,
85
- textAnchor: !k.length && O > 1 && t === 0 ? "start" : !k.length && t === O - 1 ? "end" : "middle",
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",
86
87
  className: "fill-muted-foreground",
87
- style: { fontSize: y },
88
+ style: { fontSize: b },
88
89
  children: e
89
90
  }, t) : null)
90
91
  ] }),
91
- front: /* @__PURE__ */ p(d, { children: [o.map((e, t) => e.kind === "bar" ? null : te(c.map((t, n) => {
92
- let r = x(t, e.dataKey);
93
- return r === null ? null : [P(n), I(r)];
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
95
  })).map((n, r) => {
95
96
  let i = (e.curve === "linear" ? ne : re)(n);
96
- return /* @__PURE__ */ p("g", { children: [e.kind === "area" && /* @__PURE__ */ f("path", {
97
- d: `${i}L${n[n.length - 1][0]},${L}L${n[0][0]},${L}Z`,
98
- fill: `url(#${N}-fill-${t})`,
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`,
99
+ fill: `url(#${P}-fill-${t})`,
99
100
  className: "zen__chart-fade"
100
- }), /* @__PURE__ */ f("path", {
101
+ }), /* @__PURE__ */ p("path", {
101
102
  d: i,
102
103
  fill: "none",
103
104
  strokeWidth: e.kind === "area" && !e.dashed ? 2.5 : 2,
@@ -108,158 +109,159 @@ function b({ data: n, x: r, label: o, summary: m, height: h = 240, formatX: g =
108
109
  className: e.dashed ? "zen__chart-fade" : "zen__chart-draw",
109
110
  style: { stroke: e.color }
110
111
  })] }, `${t}-${r}`);
111
- })), s.map((e, t) => {
112
+ })), c.map((e, t) => {
112
113
  let n = e.tone === "destructive" ? "stroke-destructive/45" : "stroke-muted-foreground/60";
113
- if (e.y !== void 0) return /* @__PURE__ */ f("line", {
114
- x1: w,
115
- x2: w + E,
116
- y1: I(e.y),
117
- y2: I(e.y),
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),
118
119
  className: n,
119
120
  strokeDasharray: e.dashed ? "3 4" : void 0,
120
121
  shapeRendering: "crispEdges"
121
122
  }, t);
122
- let i = c.findIndex((t) => t[r] === e.x);
123
- if (i < 0) return null;
124
- let a = !!e.label && P(i) - 6 - e.label.length * y * .6 < w;
125
- return /* @__PURE__ */ p("g", { children: [/* @__PURE__ */ f("line", {
126
- x1: P(i),
127
- x2: P(i),
128
- y1: v.top,
129
- y2: v.top + D,
123
+ let r = l.findIndex((t) => t[i] === e.x);
124
+ 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,
130
131
  className: n,
131
132
  strokeDasharray: e.dashed === !1 ? void 0 : "3 4"
132
- }), e.label && /* @__PURE__ */ f("text", {
133
- x: P(i) + (a ? 6 : -6),
134
- y: v.top + 4,
133
+ }), e.label && /* @__PURE__ */ p("text", {
134
+ x: F(r) + (a ? 6 : -6),
135
+ y: y.top + 4,
135
136
  dy: "0.7em",
136
137
  textAnchor: a ? "start" : "end",
137
138
  className: "fill-muted-foreground",
138
- style: { fontSize: y },
139
+ style: { fontSize: b },
139
140
  children: e.label
140
141
  })] }, t);
141
142
  })] })
142
143
  };
143
144
  }, [
144
- M,
145
- n,
145
+ ie,
146
146
  r,
147
- F,
148
- h,
147
+ i,
148
+ I,
149
149
  g,
150
- b,
151
- N
152
- ]), { series: V, rows: H, n: U, bars: W, banded: ie, step: G, left: K, plotH: q, cx0: J, cy: Y, base: X, barW: Z, barX: ae } = B, oe = c(() => W.map((e, t) => H.map((n, r) => {
153
- let i = x(n, e.dataKey);
150
+ _,
151
+ x,
152
+ 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);
154
156
  if (i === null) return null;
155
- let a = Y(i), o = Math.abs(X - a), s = i < 0;
156
- return /* @__PURE__ */ f("path", {
157
- d: O(ae(r, t), s ? X : a, Z, o, s),
157
+ 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),
158
160
  "data-negative": s || void 0,
159
161
  className: "zen__chart-grow transition-opacity duration-200",
160
162
  style: {
161
163
  fill: e.color,
162
- opacity: (e.dim?.(n, r) ? .35 : .9) * (I !== null && I !== r ? .7 : 1),
164
+ opacity: (e.dim?.(n, r) ? .35 : .9) * (L !== null && L !== r ? .7 : 1),
163
165
  animationDelay: `${Math.min(r * 25, 400)}ms`
164
166
  }
165
167
  }, `${t}-${r}`);
166
168
  })), [
167
- W,
168
- H,
169
- Y,
169
+ G,
170
+ U,
170
171
  X,
171
- ae,
172
172
  Z,
173
- I
174
- ]), se = c(() => /* @__PURE__ */ p("table", {
173
+ se,
174
+ oe,
175
+ L
176
+ ]), le = l(() => /* @__PURE__ */ m("table", {
175
177
  className: "sr-only",
176
178
  children: [
177
- /* @__PURE__ */ f("caption", { children: o }),
178
- /* @__PURE__ */ f("thead", { children: /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("th", {
179
+ /* @__PURE__ */ p("caption", { children: s }),
180
+ /* @__PURE__ */ p("thead", { children: /* @__PURE__ */ m("tr", { children: [/* @__PURE__ */ p("th", {
179
181
  scope: "col",
180
- children: String(r)
181
- }), V.map((e) => /* @__PURE__ */ f("th", {
182
+ children: String(i)
183
+ }), H.map((e) => /* @__PURE__ */ p("th", {
182
184
  scope: "col",
183
185
  children: e.label
184
186
  }, e.dataKey))] }) }),
185
- /* @__PURE__ */ f("tbody", { children: H.map((e, t) => /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("th", {
187
+ /* @__PURE__ */ p("tbody", { children: U.map((e, t) => /* @__PURE__ */ m("tr", { children: [/* @__PURE__ */ p("th", {
186
188
  scope: "row",
187
- children: (E ?? g)(e[r])
188
- }), V.map((t) => {
189
- let n = x(e, t.dataKey);
190
- return /* @__PURE__ */ f("td", { children: n === null ? "" : b(n) }, t.dataKey);
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
193
  })] }, t)) })
192
194
  ]
193
195
  }), [
194
- o,
195
- r,
196
- V,
196
+ s,
197
+ i,
197
198
  H,
198
- E,
199
- g,
200
- b
201
- ]), ce = (e) => {
202
- if (!U || !G) return null;
203
- let t = ie ? Math.floor((e - K) / G) : Math.round((e - K) / G);
204
- return Math.min(U - 1, Math.max(0, t));
205
- }, le = (e) => {
199
+ U,
200
+ D,
201
+ _,
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) => {
206
208
  let t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left, r = Math.round(e.clientY - t.top);
207
- L(ce(n)), z((e) => e?.y === r ? e : { y: r });
208
- }, ue = (e) => {
209
- if (!U) return;
209
+ R(ue(n)), B((e) => e?.y === r ? e : { y: r });
210
+ }, fe = (e) => {
211
+ if (!W) return;
210
212
  let t = {
211
213
  ArrowRight: 1,
212
214
  ArrowLeft: -1
213
215
  }[e.key];
214
- if (e.key === "Escape") return L(null);
215
- if (e.key === "Home" || e.key === "End") return e.preventDefault(), z(null), L(e.key === "Home" ? 0 : U - 1);
216
- t && (e.preventDefault(), z(null), L((e) => e === null ? t > 0 ? 0 : U - 1 : Math.min(U - 1, Math.max(0, e + t))));
217
- }, de = A ?? V.length > 1, Q = I === null ? null : H[I], $ = I === null ? 0 : J(I), fe = R?.y ?? v.top;
218
- return /* @__PURE__ */ p("figure", {
219
- "aria-label": o,
220
- className: e("zen__chart m-0 flex flex-col gap-3", j),
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),
221
223
  children: [
222
- de && /* @__PURE__ */ f(S, { series: V }),
223
- /* @__PURE__ */ p("div", {
224
- ref: P,
224
+ pe && /* @__PURE__ */ p(C, { series: H }),
225
+ /* @__PURE__ */ m("div", {
226
+ ref: F,
225
227
  tabIndex: 0,
226
- "aria-label": `${o}: use the arrow keys to read values`,
227
- onPointerMove: le,
228
+ "aria-label": `${s}: use the arrow keys to read values`,
229
+ onPointerMove: de,
228
230
  onPointerLeave: () => {
229
- L(null), z(null);
231
+ R(null), B(null);
230
232
  },
231
- onKeyDown: ue,
232
- onBlur: () => L(null),
233
+ onKeyDown: fe,
234
+ onBlur: () => R(null),
233
235
  className: "focus-visible:ring-ring/50 relative rounded-lg outline-hidden focus-visible:ring-2",
234
- style: { height: h },
235
- children: [F > 0 && /* @__PURE__ */ p("svg", {
236
- width: F,
237
- height: h,
236
+ style: { height: g },
237
+ children: [I > 0 && /* @__PURE__ */ m("svg", {
238
+ width: I,
239
+ height: g,
238
240
  "aria-hidden": !0,
239
241
  className: "block overflow-visible",
240
242
  children: [
241
- B.back,
242
- I !== null && (W.length ? /* @__PURE__ */ f("rect", {
243
- x: J(I) - G / 2,
244
- y: v.top,
245
- width: G,
246
- height: q,
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
249
  className: "fill-tint/[0.04]"
248
- }) : /* @__PURE__ */ f("line", {
250
+ }) : /* @__PURE__ */ p("line", {
249
251
  x1: $,
250
252
  x2: $,
251
- y1: v.top,
252
- y2: v.top + q,
253
+ y1: y.top,
254
+ y2: y.top + J,
253
255
  className: "stroke-glow/40"
254
256
  })),
255
- oe,
256
- B.front,
257
- I !== null && V.map((e, t) => {
257
+ ce,
258
+ V.front,
259
+ L !== null && H.map((e, t) => {
258
260
  if (e.kind === "bar") return null;
259
- let n = x(H[I], e.dataKey);
260
- return n === null ? null : /* @__PURE__ */ f("circle", {
261
+ let n = S(U[L], e.dataKey);
262
+ return n === null ? null : /* @__PURE__ */ p("circle", {
261
263
  cx: $,
262
- cy: Y(n),
264
+ cy: X(n),
263
265
  r: 4,
264
266
  strokeWidth: 2,
265
267
  className: "stroke-card",
@@ -267,50 +269,58 @@ function b({ data: n, x: r, label: o, summary: m, height: h = 240, formatX: g =
267
269
  }, t);
268
270
  })
269
271
  ]
270
- }), Q && I !== null && /* @__PURE__ */ f("div", {
272
+ }), Q && L !== null && /* @__PURE__ */ p("div", {
271
273
  className: "pointer-events-none absolute top-0 z-10 transition-[translate] duration-75",
272
- style: C($, fe, F, h),
273
- children: k ? k(Q, I) : /* @__PURE__ */ f(t, {
274
- title: (E ?? g)(Q[r]),
275
- rows: V.map((e) => ({
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
278
  s: e,
277
- v: x(Q, e.dataKey)
279
+ v: S(Q, e.dataKey)
278
280
  })).filter(({ v: e }) => e !== null).map(({ s: e, v: t }) => ({
279
281
  label: e.label,
280
- value: b(t),
282
+ value: x(t),
281
283
  color: e.color,
282
284
  dashed: e.dashed
283
285
  }))
284
286
  })
285
287
  })]
286
288
  }),
287
- m && /* @__PURE__ */ f("figcaption", {
289
+ h && /* @__PURE__ */ p("figcaption", {
288
290
  className: "sr-only",
289
- children: m
291
+ children: h
290
292
  }),
291
- se
293
+ le
292
294
  ]
293
295
  });
294
296
  }
295
- function x(e, t) {
297
+ function S(e, t) {
296
298
  let n = e[t];
297
299
  return typeof n == "number" && Number.isFinite(n) ? n : null;
298
300
  }
299
- function S({ series: e }) {
300
- return /* @__PURE__ */ f("ul", {
301
+ function C({ series: e }) {
302
+ let t = e.filter((t, n) => t.dimLabel && e.findIndex((e) => e.dimLabel === t.dimLabel) === n);
303
+ return /* @__PURE__ */ m("ul", {
301
304
  className: "text-muted-foreground flex flex-wrap gap-x-4 gap-y-1 text-xs",
302
305
  "aria-label": "Legend",
303
- children: e.map((e) => /* @__PURE__ */ p("li", {
306
+ children: [e.map((e) => /* @__PURE__ */ m("li", {
304
307
  className: "flex items-center gap-1.5",
305
- children: [/* @__PURE__ */ f(n, {
308
+ children: [/* @__PURE__ */ p(r, {
306
309
  color: e.color,
307
310
  dashed: e.dashed,
308
311
  kind: e.kind
309
312
  }), e.label]
310
- }, e.dataKey))
313
+ }, e.dataKey)), t.map((e) => /* @__PURE__ */ m("li", {
314
+ className: "flex items-center gap-1.5",
315
+ children: [/* @__PURE__ */ p(r, {
316
+ color: e.color,
317
+ kind: "bar",
318
+ faded: !0
319
+ }), e.dimLabel]
320
+ }, `faded-${e.dimLabel}`))]
311
321
  });
312
322
  }
313
- function C(e, t, n, r) {
323
+ function w(e, t, n, r) {
314
324
  let i = e > n / 2, a = Math.round(Math.min(Math.max(0, t - 20), r - 80));
315
325
  return i ? {
316
326
  right: 0,
@@ -320,24 +330,24 @@ function C(e, t, n, r) {
320
330
  translate: `${Math.round(e + 12)}px ${a}px`
321
331
  };
322
332
  }
323
- function w(e) {
324
- let [t, n] = u(0);
325
- return o(() => {
333
+ function T(e) {
334
+ let [t, n] = d(0);
335
+ return s(() => {
326
336
  let t = e.current;
327
337
  if (!t || (n(t.clientWidth), typeof ResizeObserver > "u")) return;
328
338
  let r = new ResizeObserver(() => n(t.clientWidth));
329
339
  return r.observe(t), () => r.disconnect();
330
340
  }, [e]), t;
331
341
  }
332
- function T(e, t, n = 5) {
342
+ function E(e, t, n = 5) {
333
343
  e === t && ([e, t] = e === 0 ? [0, 1] : [Math.min(0, e), Math.max(0, t)]);
334
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);
335
345
  return Array.from({ length: c - s + 1 }, (e, t) => Number(((s + t) * o).toPrecision(12)));
336
346
  }
337
- var E = new Intl.NumberFormat("en", {
347
+ var D = new Intl.NumberFormat("en", {
338
348
  notation: "compact",
339
349
  maximumFractionDigits: 1
340
- }), D = (e) => E.format(e);
350
+ }), O = (e) => D.format(e);
341
351
  function te(e) {
342
352
  let t = [], n = [];
343
353
  for (let r of e) r ? n.push(r) : n.length && (t.push(n), n = []);
@@ -356,9 +366,9 @@ function re(e) {
356
366
  }
357
367
  return a;
358
368
  }
359
- function O(e, t, n, r, i) {
369
+ function k(e, t, n, r, i) {
360
370
  let a = Math.min(4, n / 2, r);
361
371
  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`;
362
372
  }
363
373
  //#endregion
364
- export { m as ChartArea, g as ChartBar, h as ChartLine, _ as ChartReference, t as ChartTooltipCard, r as DonutChart, b as default, T as niceTicks };
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 };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Where a chart's colours come from when a series or item doesn't give its own:
3
+ * `chart`, the categorical palette (--chart-1…8, distinct hues); `glow`, shades
4
+ * of the theme's two glow colours, from the first to the second and deepening
5
+ * towards the background, for a chart in the theme's own colours (e.g. parts
6
+ * of one whole).
7
+ */
8
+ export type ChartPalette = 'chart' | 'glow';
9
+ /**
10
+ * The i-th (0-based) of n colours in the palette: what a chart draws its i-th
11
+ * series or item in, for a legend of your own beside it.
12
+ */
13
+ export declare function paletteColor(palette: ChartPalette, i: number, n: number): string;
14
+ //# sourceMappingURL=palette.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../packages/chart/palette.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAKhF"}
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ //#region packages/chart/palette.ts
3
+ function e(e, t, n) {
4
+ if (e === "chart") return `var(--chart-${Math.min(t + 1, 8)})`;
5
+ let r = n <= 1 ? 0 : t / (n - 1);
6
+ return `color-mix(in oklch, ${`color-mix(in oklch, oklch(var(--glow)), oklch(var(--glow-2)) ${Math.round(r * 100)}%)`}, oklch(var(--background)) ${Math.round(r * 45)}%)`;
7
+ }
8
+ //#endregion
9
+ export { e as paletteColor };
@@ -6,11 +6,15 @@ export type Kind = 'area' | 'line' | 'bar';
6
6
  * show your own rows.
7
7
  */
8
8
  export declare function ChartTooltipCard({ title, rows, className }: ChartTooltipCardProps): import('react').JSX.Element;
9
- /** A series' key: a short line for lines (dashed if the series is), a rounded swatch for bars and areas. */
10
- export declare function Key({ color, dashed, kind }: {
9
+ /**
10
+ * A series' key: a short line for lines (dashed if the series is), a rounded swatch for
11
+ * bars and areas; `faded` as a bar's dimmed rows are drawn.
12
+ */
13
+ export declare function Key({ color, dashed, kind, faded, }: {
11
14
  color: string;
12
15
  dashed?: boolean;
13
16
  kind?: Kind;
17
+ faded?: boolean;
14
18
  }): import('react').JSX.Element;
15
19
  export interface ChartTooltipCardProps {
16
20
  title: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../packages/chart/tooltip.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAE3C;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,qBAAqB,+BAiBjF;AAED,4GAA4G;AAC5G,wBAAgB,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAa,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,IAAI,CAAA;CAAE,+BAiBrG;AAED,MAAM,WAAW,qBAAqB;IAClC,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB"}
1
+ {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../packages/chart/tooltip.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAE3C;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,qBAAqB,+BAiBjF;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,EAChB,KAAK,EACL,MAAM,EACN,IAAa,EACb,KAAK,GACR,EAAE;IACC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB,+BAuBA;AAED,MAAM,WAAW,qBAAqB;IAClC,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB"}
@@ -26,8 +26,8 @@ function r({ title: r, rows: a, className: o }) {
26
26
  })]
27
27
  });
28
28
  }
29
- function i({ color: e, dashed: n, kind: r = "line" }) {
30
- return r === "line" || n ? /* @__PURE__ */ t("svg", {
29
+ function i({ color: n, dashed: r, kind: i = "line", faded: a }) {
30
+ return i === "line" || r ? /* @__PURE__ */ t("svg", {
31
31
  viewBox: "0 0 12 4",
32
32
  "aria-hidden": !0,
33
33
  className: "h-1 w-3 shrink-0 overflow-visible",
@@ -38,13 +38,13 @@ function i({ color: e, dashed: n, kind: r = "line" }) {
38
38
  y2: "2",
39
39
  strokeWidth: "2",
40
40
  strokeLinecap: "round",
41
- strokeDasharray: n ? "3 3" : void 0,
42
- style: { stroke: e }
41
+ strokeDasharray: r ? "3 3" : void 0,
42
+ style: { stroke: n }
43
43
  })
44
44
  }) : /* @__PURE__ */ t("span", {
45
45
  "aria-hidden": !0,
46
- className: "size-2.5 shrink-0 rounded-[3px]",
47
- style: { background: e }
46
+ className: e("size-2.5 shrink-0 rounded-[3px]", a && "opacity-40"),
47
+ style: { background: n }
48
48
  });
49
49
  }
50
50
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/checkbox/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAqB,MAAM,OAAO,CAAC;AAErE;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC7B,QAAQ,EACR,WAAW,EACX,aAAqB,EACrB,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACV,EAAE,aAAa,+BAqEf;AAED,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,UAAU,CAAC;IAClG,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,+EAA+E;IAC/E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,oCAAoC;IACpC,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/checkbox/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAqB,MAAM,OAAO,CAAC;AAErE;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC7B,QAAQ,EACR,WAAW,EACX,aAAqB,EACrB,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACV,EAAE,aAAa,+BAkDf;AAED,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,UAAU,CAAC;IAClG,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,+EAA+E;IAC/E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,oCAAoC;IACpC,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB"}