@dreamtree-org/twreact-ui 1.3.1 → 1.3.3

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/DESIGN.md +2 -2
  2. package/README.md +90 -5
  3. package/ai-skills/dreamtree-ui.md +43 -4
  4. package/bin/cli.mjs +72 -4
  5. package/charts/package.json +5 -0
  6. package/dist/_shared/cn-DPPQUJu1.js +138 -0
  7. package/dist/ai-schema.json +639 -1
  8. package/dist/charts/index.d.ts +9 -0
  9. package/dist/charts/index.d.ts.map +1 -0
  10. package/dist/charts/index.js +797 -0
  11. package/dist/components/charts/AreaChart.d.ts +4 -0
  12. package/dist/components/charts/AreaChart.d.ts.map +1 -0
  13. package/dist/components/charts/BarChart.d.ts +4 -0
  14. package/dist/components/charts/BarChart.d.ts.map +1 -0
  15. package/dist/components/charts/CartesianChart.d.ts +5 -0
  16. package/dist/components/charts/CartesianChart.d.ts.map +1 -0
  17. package/dist/components/charts/ChartFrame.d.ts +18 -0
  18. package/dist/components/charts/ChartFrame.d.ts.map +1 -0
  19. package/dist/components/charts/DonutChart.d.ts +4 -0
  20. package/dist/components/charts/DonutChart.d.ts.map +1 -0
  21. package/dist/components/charts/LineChart.d.ts +4 -0
  22. package/dist/components/charts/LineChart.d.ts.map +1 -0
  23. package/dist/components/charts/Sparkline.d.ts +5 -0
  24. package/dist/components/charts/Sparkline.d.ts.map +1 -0
  25. package/dist/components/charts/chartTheme.d.ts +36 -0
  26. package/dist/components/charts/chartTheme.d.ts.map +1 -0
  27. package/dist/components/core/Table/MobileCard.d.ts.map +1 -1
  28. package/dist/components/core/Table/MobileFilters.d.ts.map +1 -1
  29. package/dist/components/core/Table/Table.d.ts.map +1 -1
  30. package/dist/components/rich-text/RichTextEditor.d.ts +4 -0
  31. package/dist/components/rich-text/RichTextEditor.d.ts.map +1 -0
  32. package/dist/components/rich-text/RichTextToolbar.d.ts +219 -0
  33. package/dist/components/rich-text/RichTextToolbar.d.ts.map +1 -0
  34. package/dist/components/utility/Stepper.d.ts.map +1 -1
  35. package/dist/esm/charts/index.js +5 -0
  36. package/dist/esm/components/blocks/StatCard.js +1 -1
  37. package/dist/esm/components/charts/AreaChart.js +16 -0
  38. package/dist/esm/components/charts/BarChart.js +16 -0
  39. package/dist/esm/components/charts/CartesianChart.js +255 -0
  40. package/dist/esm/components/charts/ChartFrame.js +170 -0
  41. package/dist/esm/components/charts/DonutChart.js +122 -0
  42. package/dist/esm/components/charts/LineChart.js +16 -0
  43. package/dist/esm/components/charts/Sparkline.js +113 -0
  44. package/dist/esm/components/charts/chartTheme.js +126 -0
  45. package/dist/esm/components/core/Select.js +2 -2
  46. package/dist/esm/components/core/Table/MobileCard.js +5 -2
  47. package/dist/esm/components/core/Table/MobileFilters.js +10 -3
  48. package/dist/esm/components/core/Table/Table.js +10 -7
  49. package/dist/esm/components/rich-text/RichTextEditor.js +244 -0
  50. package/dist/esm/components/rich-text/RichTextToolbar.js +397 -0
  51. package/dist/esm/components/utility/Stepper.js +6 -4
  52. package/dist/esm/rich-text/index.js +1 -0
  53. package/dist/index.css +1 -1
  54. package/dist/index.esm.css +1 -1
  55. package/dist/index.esm.js +50 -22
  56. package/dist/index.js +50 -22
  57. package/dist/rich-text/index.d.ts +5 -0
  58. package/dist/rich-text/index.d.ts.map +1 -0
  59. package/dist/rich-text/index.js +654 -0
  60. package/dist/tokens/brands/practicepro.json +1 -0
  61. package/dist/tokens/brands/studio.css +14 -0
  62. package/dist/tokens/brands/studio.json +21 -0
  63. package/dist/types/charts.d.ts +97 -0
  64. package/dist/types/charts.d.ts.map +1 -0
  65. package/dist/types/rich-text.d.ts +50 -0
  66. package/dist/types/rich-text.d.ts.map +1 -0
  67. package/doc/README.md +13 -0
  68. package/mcp/catalog.snapshot.json +1016 -10
  69. package/mcp/server-core.mjs +30 -1
  70. package/package.json +39 -2
  71. package/rich-text/package.json +5 -0
  72. package/tokens/brand.schema.json +612 -0
  73. package/tokens/brands/practicepro.json +1 -0
  74. package/tokens/brands/studio.json +21 -0
  75. package/tokens/lib.cjs +131 -7
@@ -0,0 +1,797 @@
1
+ 'use strict';
2
+
3
+ var cn = require('../_shared/cn-DPPQUJu1.js');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var React = require('react');
6
+ var recharts = require('recharts');
7
+ require('clsx');
8
+ require('tailwind-merge');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ var React__default = /*#__PURE__*/_interopDefault(React);
13
+
14
+ var _excluded$3 = ["className", "title", "description", "defaultTitle", "data", "height", "emptyState", "legend", "accessibleTable", "tableColumns", "children", "aria-label"];
15
+ // The swatch colour arrives as a custom property so a token (`rgb(var(--dt-*))`)
16
+ // and a resolved rgb() string both work.
17
+ var swatch = function swatch(size) {
18
+ return cn.cn("inline-block shrink-0 rounded-full bg-[color:var(--dt-chart-color)]", size);
19
+ };
20
+ var sizeStyle = function sizeStyle(height) {
21
+ return {
22
+ height: typeof height === "number" ? "".concat(height, "px") : height
23
+ };
24
+ };
25
+ function ChartLegend(_ref) {
26
+ var items = _ref.items;
27
+ return jsxRuntime.jsx("ul", {
28
+ className: "mt-3 flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-xs text-gray-600 dark:text-gray-300",
29
+ "data-testid": "chart-legend",
30
+ children: items.map(function (item) {
31
+ return jsxRuntime.jsxs("li", {
32
+ className: "inline-flex items-center gap-1.5",
33
+ children: [jsxRuntime.jsx("span", {
34
+ className: swatch("h-2.5 w-2.5"),
35
+ style: {
36
+ "--dt-chart-color": item.color
37
+ },
38
+ "aria-hidden": "true"
39
+ }), jsxRuntime.jsx("span", {
40
+ children: item.name
41
+ })]
42
+ }, item.name);
43
+ })
44
+ });
45
+ }
46
+ function ChartTooltipContent(_ref2) {
47
+ var active = _ref2.active,
48
+ payload = _ref2.payload,
49
+ label = _ref2.label,
50
+ valueFormatter = _ref2.valueFormatter,
51
+ _ref2$hideLabel = _ref2.hideLabel,
52
+ hideLabel = _ref2$hideLabel === void 0 ? false : _ref2$hideLabel;
53
+ if (!active || !payload || !payload.length) return null;
54
+ return jsxRuntime.jsxs("div", {
55
+ className: "rounded-md border border-gray-200 bg-white px-3 py-2 text-xs text-gray-900 shadow-md dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100",
56
+ children: [!hideLabel && label != null && label !== "" && jsxRuntime.jsx("p", {
57
+ className: "mb-1 font-medium",
58
+ children: label
59
+ }), jsxRuntime.jsx("ul", {
60
+ className: "space-y-0.5",
61
+ children: payload.map(function (entry) {
62
+ var _entry$payload;
63
+ return jsxRuntime.jsxs("li", {
64
+ className: "flex items-center gap-2",
65
+ children: [jsxRuntime.jsx("span", {
66
+ className: swatch("h-2 w-2"),
67
+ style: {
68
+ "--dt-chart-color": entry.color || ((_entry$payload = entry.payload) === null || _entry$payload === void 0 ? void 0 : _entry$payload.fill)
69
+ },
70
+ "aria-hidden": "true"
71
+ }), jsxRuntime.jsx("span", {
72
+ className: "text-gray-600 dark:text-gray-300",
73
+ children: entry.name
74
+ }), jsxRuntime.jsx("span", {
75
+ className: "ml-auto pl-3 font-medium tabular-nums",
76
+ children: valueFormatter(entry.value)
77
+ })]
78
+ }, "".concat(entry.dataKey, "-").concat(entry.name));
79
+ })
80
+ })]
81
+ });
82
+ }
83
+ function ChartDataTable(_ref3) {
84
+ var caption = _ref3.caption,
85
+ columns = _ref3.columns,
86
+ rows = _ref3.rows;
87
+ return jsxRuntime.jsxs("table", {
88
+ className: "sr-only",
89
+ "data-testid": "chart-data-table",
90
+ children: [caption && jsxRuntime.jsx("caption", {
91
+ children: caption
92
+ }), jsxRuntime.jsx("thead", {
93
+ children: jsxRuntime.jsx("tr", {
94
+ children: columns.map(function (c) {
95
+ return jsxRuntime.jsx("th", {
96
+ scope: "col",
97
+ children: c.label
98
+ }, c.key);
99
+ })
100
+ })
101
+ }), jsxRuntime.jsx("tbody", {
102
+ children: rows.map(function (row, r) {
103
+ return jsxRuntime.jsx("tr", {
104
+ children: columns.map(function (c, i) {
105
+ return i === 0 ? jsxRuntime.jsx("th", {
106
+ scope: "row",
107
+ children: c.format(row[c.key])
108
+ }, c.key) : jsxRuntime.jsx("td", {
109
+ children: c.format(row[c.key])
110
+ }, c.key);
111
+ })
112
+ }, r);
113
+ })
114
+ })]
115
+ });
116
+ }
117
+ /**
118
+ * The accessible shell every chart renders: the SVG lives in a `role="img"`
119
+ * region named by `title` and described by `description`; the numbers are
120
+ * repeated in a visually-hidden table (recharts' SVG has no accessible content).
121
+ */
122
+ var ChartFrame = /*#__PURE__*/React__default.default.forwardRef(function ChartFrame(_ref4, ref) {
123
+ var className = _ref4.className,
124
+ title = _ref4.title,
125
+ description = _ref4.description,
126
+ defaultTitle = _ref4.defaultTitle,
127
+ data = _ref4.data,
128
+ height = _ref4.height,
129
+ _ref4$emptyState = _ref4.emptyState,
130
+ emptyState = _ref4$emptyState === void 0 ? "No data to display" : _ref4$emptyState,
131
+ legend = _ref4.legend,
132
+ _ref4$accessibleTable = _ref4.accessibleTable,
133
+ accessibleTable = _ref4$accessibleTable === void 0 ? true : _ref4$accessibleTable,
134
+ tableColumns = _ref4.tableColumns,
135
+ children = _ref4.children,
136
+ ariaLabel = _ref4["aria-label"],
137
+ rest = cn._objectWithoutProperties(_ref4, _excluded$3);
138
+ var descriptionId = React.useId();
139
+ var name = title || ariaLabel || defaultTitle;
140
+ if (!Array.isArray(data) || data.length === 0) {
141
+ return jsxRuntime.jsx("div", cn._objectSpread2(cn._objectSpread2({
142
+ ref: ref,
143
+ className: cn.cn("flex w-full items-center justify-center rounded-md border border-dashed border-gray-300 text-sm text-gray-500 dark:border-gray-700 dark:text-gray-400", className),
144
+ style: sizeStyle(height),
145
+ role: "status",
146
+ "aria-label": name,
147
+ "data-empty": "true"
148
+ }, rest), {}, {
149
+ children: emptyState
150
+ }));
151
+ }
152
+ return jsxRuntime.jsxs("div", cn._objectSpread2(cn._objectSpread2({
153
+ ref: ref,
154
+ className: cn.cn("w-full", className)
155
+ }, rest), {}, {
156
+ children: [jsxRuntime.jsx("div", {
157
+ role: "img",
158
+ "aria-label": name,
159
+ "aria-describedby": description ? descriptionId : undefined,
160
+ className: "w-full text-gray-500 dark:text-gray-400",
161
+ style: sizeStyle(height),
162
+ children: children
163
+ }), description && jsxRuntime.jsx("p", {
164
+ id: descriptionId,
165
+ className: "sr-only",
166
+ children: description
167
+ }), legend && legend.length > 0 && jsxRuntime.jsx(ChartLegend, {
168
+ items: legend
169
+ }), accessibleTable && jsxRuntime.jsx(ChartDataTable, {
170
+ caption: name,
171
+ columns: tableColumns,
172
+ rows: data
173
+ })]
174
+ }));
175
+ });
176
+
177
+ /** `true` when the user asked the OS for reduced motion. */
178
+ function prefersReducedMotion() {
179
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return false;
180
+ return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
181
+ }
182
+
183
+ var CHART_PALETTES = ["primary", "secondary", "success", "warning", "error", "info", "gray"];
184
+ var DEFAULT_CHART_COLORS = ["primary", "success", "warning", "error", "info", "secondary", "gray"];
185
+ var TOKEN_RE = new RegExp("^(".concat(CHART_PALETTES.join("|"), ")(?:-(50|[1-9]00|950))?$"));
186
+ var CHROME_VARS = {
187
+ grid: "--dt-line",
188
+ axis: "--dt-muted",
189
+ surface: "--dt-surface",
190
+ text: "--dt-foreground"
191
+ };
192
+ /** `"primary"` → `"--dt-primary-500"`, `"error-300"` → `"--dt-error-300"`; null for anything else. */
193
+ function tokenVar(color) {
194
+ var m = TOKEN_RE.exec(String(color || ""));
195
+ return m ? "--dt-".concat(m[1], "-").concat(m[2] || "500") : null;
196
+ }
197
+ function readVar(name) {
198
+ if (typeof window === "undefined" || typeof window.getComputedStyle !== "function") return "";
199
+ return window.getComputedStyle(document.documentElement).getPropertyValue(name).trim();
200
+ }
201
+ // SVG presentation attributes do not resolve var() in every engine, so a token is
202
+ // turned into a concrete rgb() string when the browser can tell us its value. The
203
+ // var() form is the SSR / jsdom fallback, and what the first (hydrating) client
204
+ // render uses so it matches the server's HTML (`live` = false).
205
+ function resolveVar(name) {
206
+ var live = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
207
+ var value = live ? readVar(name) : "";
208
+ return value ? "rgb(".concat(value.split(/[\s,]+/).join(" "), ")") : "rgb(var(".concat(name, "))");
209
+ }
210
+ /**
211
+ * A series colour: a palette token (`primary`, `success-600`, …) resolves to the
212
+ * matching `--dt-*` variable; any other string is treated as a CSS colour supplied
213
+ * by the consumer (e.g. a colour stored with the data).
214
+ */
215
+ function resolveColor(color) {
216
+ var live = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
217
+ var name = tokenVar(color);
218
+ return name ? resolveVar(name, live) : color;
219
+ }
220
+ function seriesColors(categories, colors) {
221
+ var live = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
222
+ var palette = colors && colors.length ? colors : DEFAULT_CHART_COLORS;
223
+ return categories.map(function (_, i) {
224
+ return resolveColor(palette[i % palette.length], live);
225
+ });
226
+ }
227
+ function readChrome(live) {
228
+ return Object.fromEntries(Object.entries(CHROME_VARS).map(function (_ref) {
229
+ var _ref2 = cn._slicedToArray(_ref, 2),
230
+ k = _ref2[0],
231
+ v = _ref2[1];
232
+ return [k, resolveVar(v, live)];
233
+ }));
234
+ }
235
+ // The theme is an external store: the attributes on <html> that flip it. The
236
+ // server snapshot is null, so a hydrating render keeps the var() fallback the
237
+ // server rendered and React re-renders with live colours right after (#130).
238
+ function subscribeTheme(onChange) {
239
+ if (typeof document === "undefined" || typeof MutationObserver !== "function") return function () {};
240
+ var observer = new MutationObserver(onChange);
241
+ observer.observe(document.documentElement, {
242
+ attributes: true,
243
+ attributeFilter: ["class", "data-theme", "style"]
244
+ });
245
+ return function () {
246
+ return observer.disconnect();
247
+ };
248
+ }
249
+ function themeSnapshot() {
250
+ if (typeof document === "undefined") return null;
251
+ var el = document.documentElement;
252
+ return "".concat(el.className, "|").concat(el.getAttribute("data-theme") || "", "|").concat(el.getAttribute("style") || "");
253
+ }
254
+ var serverThemeSnapshot = function serverThemeSnapshot() {
255
+ return null;
256
+ };
257
+ /**
258
+ * Chart chrome + series colours, re-read whenever the theme flips (the `dark`
259
+ * class or `data-theme` on <html>) so axes and series follow dark mode without
260
+ * a remount.
261
+ */
262
+ function useChartTheme(categories, colors) {
263
+ // The snapshot only signals a change; the values come from the live document.
264
+ var live = React.useSyncExternalStore(subscribeTheme, themeSnapshot, serverThemeSnapshot) !== null;
265
+ return {
266
+ chrome: readChrome(live),
267
+ series: seriesColors(categories, colors, live)
268
+ };
269
+ }
270
+ function subscribeReducedMotion(onChange) {
271
+ var _query$addEventListen;
272
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return function () {};
273
+ var query = window.matchMedia("(prefers-reduced-motion: reduce)");
274
+ (_query$addEventListen = query.addEventListener) === null || _query$addEventListen === void 0 || _query$addEventListen.call(query, "change", onChange);
275
+ return function () {
276
+ var _query$removeEventLis;
277
+ return (_query$removeEventLis = query.removeEventListener) === null || _query$removeEventLis === void 0 ? void 0 : _query$removeEventLis.call(query, "change", onChange);
278
+ };
279
+ }
280
+ var serverReducedMotion = function serverReducedMotion() {
281
+ return false;
282
+ };
283
+ /**
284
+ * `true` while the user asks the OS for reduced motion; follows changes live.
285
+ * `false` on the server and while hydrating, so the first render matches.
286
+ */
287
+ function useReducedMotion() {
288
+ return React.useSyncExternalStore(subscribeReducedMotion, prefersReducedMotion, serverReducedMotion);
289
+ }
290
+ var defaultValueFormatter = function defaultValueFormatter(value) {
291
+ return typeof value === "number" ? value.toLocaleString() : value == null ? "" : String(value);
292
+ };
293
+ /**
294
+ * A per-instance id for the SVG defs recharts draws (clip paths). recharts 2
295
+ * falls back to a module-level counter, which differs between the server and the
296
+ * client; an id from React.useId() is the same on both. Only [A-Za-z0-9_-] so it
297
+ * is safe inside `url(#…)`.
298
+ */
299
+ function useChartId() {
300
+ return "dt-chart-".concat(React.useId().replace(/[^A-Za-z0-9_-]/g, ""));
301
+ }
302
+
303
+ var _excluded$2 = ["kind", "data", "index", "categories", "colors", "valueFormatter", "xAxisFormatter", "height", "showLegend", "showTooltip", "showXAxis", "showYAxis", "showGrid", "yAxisWidth", "curveType", "stacked", "horizontal", "showDots", "connectNulls", "animate", "title", "description", "emptyState", "accessibleTable", "className"];
304
+ var ROOTS = {
305
+ line: recharts.LineChart,
306
+ bar: recharts.BarChart,
307
+ area: recharts.AreaChart
308
+ };
309
+ var TITLES = {
310
+ line: "Line chart",
311
+ bar: "Bar chart",
312
+ area: "Area chart"
313
+ };
314
+ var CURVES = {
315
+ linear: "linear",
316
+ monotone: "monotone",
317
+ step: "step",
318
+ natural: "natural"
319
+ };
320
+ function renderSeries(kind, _ref) {
321
+ var id = _ref.id,
322
+ category = _ref.category,
323
+ color = _ref.color,
324
+ curve = _ref.curve,
325
+ stacked = _ref.stacked,
326
+ showDots = _ref.showDots,
327
+ connectNulls = _ref.connectNulls,
328
+ animate = _ref.animate,
329
+ horizontal = _ref.horizontal,
330
+ barRadius = _ref.barRadius;
331
+ var common = {
332
+ id: id,
333
+ dataKey: category,
334
+ name: category,
335
+ isAnimationActive: animate
336
+ };
337
+ if (kind === "bar") {
338
+ var radius = horizontal ? [0, barRadius, barRadius, 0] : [barRadius, barRadius, 0, 0];
339
+ return jsxRuntime.jsx(recharts.Bar, cn._objectSpread2(cn._objectSpread2({}, common), {}, {
340
+ fill: color,
341
+ stackId: stacked ? "stack" : undefined,
342
+ radius: stacked ? 0 : radius,
343
+ maxBarSize: 48
344
+ }), category);
345
+ }
346
+ if (kind === "area") {
347
+ return jsxRuntime.jsx(recharts.Area, cn._objectSpread2(cn._objectSpread2({}, common), {}, {
348
+ type: curve,
349
+ stroke: color,
350
+ fill: color,
351
+ fillOpacity: stacked ? 0.4 : 0.15,
352
+ strokeWidth: 2,
353
+ stackId: stacked ? "stack" : undefined,
354
+ dot: showDots ? {
355
+ r: 3,
356
+ fill: color,
357
+ strokeWidth: 0
358
+ } : false,
359
+ activeDot: {
360
+ r: 4,
361
+ strokeWidth: 0,
362
+ fill: color
363
+ },
364
+ connectNulls: connectNulls
365
+ }), category);
366
+ }
367
+ return jsxRuntime.jsx(recharts.Line, cn._objectSpread2(cn._objectSpread2({}, common), {}, {
368
+ type: curve,
369
+ stroke: color,
370
+ strokeWidth: 2,
371
+ dot: showDots ? {
372
+ r: 3,
373
+ fill: color,
374
+ strokeWidth: 0
375
+ } : false,
376
+ activeDot: {
377
+ r: 4,
378
+ strokeWidth: 0,
379
+ fill: color
380
+ },
381
+ connectNulls: connectNulls
382
+ }), category);
383
+ }
384
+ /** Shared implementation of LineChart / BarChart / AreaChart. */
385
+ var CartesianChart = /*#__PURE__*/React__default.default.forwardRef(function CartesianChart(_ref2, ref) {
386
+ var kind = _ref2.kind,
387
+ data = _ref2.data,
388
+ index = _ref2.index,
389
+ _ref2$categories = _ref2.categories,
390
+ categories = _ref2$categories === void 0 ? [] : _ref2$categories,
391
+ colors = _ref2.colors,
392
+ _ref2$valueFormatter = _ref2.valueFormatter,
393
+ valueFormatter = _ref2$valueFormatter === void 0 ? defaultValueFormatter : _ref2$valueFormatter,
394
+ xAxisFormatter = _ref2.xAxisFormatter,
395
+ _ref2$height = _ref2.height,
396
+ height = _ref2$height === void 0 ? 300 : _ref2$height,
397
+ _ref2$showLegend = _ref2.showLegend,
398
+ showLegend = _ref2$showLegend === void 0 ? true : _ref2$showLegend,
399
+ _ref2$showTooltip = _ref2.showTooltip,
400
+ showTooltip = _ref2$showTooltip === void 0 ? true : _ref2$showTooltip,
401
+ _ref2$showXAxis = _ref2.showXAxis,
402
+ showXAxis = _ref2$showXAxis === void 0 ? true : _ref2$showXAxis,
403
+ _ref2$showYAxis = _ref2.showYAxis,
404
+ showYAxis = _ref2$showYAxis === void 0 ? true : _ref2$showYAxis,
405
+ _ref2$showGrid = _ref2.showGrid,
406
+ showGrid = _ref2$showGrid === void 0 ? true : _ref2$showGrid,
407
+ _ref2$yAxisWidth = _ref2.yAxisWidth,
408
+ yAxisWidth = _ref2$yAxisWidth === void 0 ? 48 : _ref2$yAxisWidth,
409
+ _ref2$curveType = _ref2.curveType,
410
+ curveType = _ref2$curveType === void 0 ? "monotone" : _ref2$curveType,
411
+ _ref2$stacked = _ref2.stacked,
412
+ stacked = _ref2$stacked === void 0 ? false : _ref2$stacked,
413
+ _ref2$horizontal = _ref2.horizontal,
414
+ horizontal = _ref2$horizontal === void 0 ? false : _ref2$horizontal,
415
+ _ref2$showDots = _ref2.showDots,
416
+ showDots = _ref2$showDots === void 0 ? false : _ref2$showDots,
417
+ _ref2$connectNulls = _ref2.connectNulls,
418
+ connectNulls = _ref2$connectNulls === void 0 ? false : _ref2$connectNulls,
419
+ _ref2$animate = _ref2.animate,
420
+ animate = _ref2$animate === void 0 ? true : _ref2$animate,
421
+ title = _ref2.title,
422
+ description = _ref2.description,
423
+ emptyState = _ref2.emptyState,
424
+ _ref2$accessibleTable = _ref2.accessibleTable,
425
+ accessibleTable = _ref2$accessibleTable === void 0 ? true : _ref2$accessibleTable,
426
+ className = _ref2.className,
427
+ rest = cn._objectWithoutProperties(_ref2, _excluded$2);
428
+ var _useChartTheme = useChartTheme(categories, colors),
429
+ chrome = _useChartTheme.chrome,
430
+ series = _useChartTheme.series;
431
+ var reducedMotion = useReducedMotion();
432
+ var chartId = useChartId();
433
+ var Root = ROOTS[kind];
434
+ var isHorizontalBars = kind === "bar" && horizontal;
435
+ var curve = CURVES[curveType] || "monotone";
436
+ var tick = {
437
+ fill: chrome.axis,
438
+ fontSize: 12
439
+ };
440
+ var formatIndex = xAxisFormatter || function (v) {
441
+ return v == null ? "" : String(v);
442
+ };
443
+ var categoryAxis = {
444
+ dataKey: index,
445
+ tick: tick,
446
+ tickLine: false,
447
+ axisLine: false,
448
+ tickFormatter: xAxisFormatter,
449
+ hide: !showXAxis,
450
+ minTickGap: 8
451
+ };
452
+ var valueAxis = {
453
+ tick: tick,
454
+ tickLine: false,
455
+ axisLine: false,
456
+ tickFormatter: valueFormatter,
457
+ hide: !showYAxis,
458
+ width: yAxisWidth
459
+ };
460
+ return jsxRuntime.jsx(ChartFrame, cn._objectSpread2(cn._objectSpread2({
461
+ ref: ref,
462
+ className: className,
463
+ title: title,
464
+ description: description,
465
+ defaultTitle: TITLES[kind],
466
+ data: data,
467
+ height: height,
468
+ emptyState: emptyState,
469
+ accessibleTable: accessibleTable,
470
+ legend: showLegend ? categories.map(function (c, i) {
471
+ return {
472
+ name: c,
473
+ color: series[i]
474
+ };
475
+ }) : null,
476
+ tableColumns: [{
477
+ key: index,
478
+ label: index,
479
+ format: formatIndex
480
+ }].concat(cn._toConsumableArray(categories.map(function (c) {
481
+ return {
482
+ key: c,
483
+ label: c,
484
+ format: valueFormatter
485
+ };
486
+ })))
487
+ }, rest), {}, {
488
+ children: jsxRuntime.jsx(recharts.ResponsiveContainer, {
489
+ width: "100%",
490
+ height: "100%",
491
+ minWidth: 0,
492
+ children: jsxRuntime.jsxs(Root, {
493
+ id: chartId,
494
+ data: data,
495
+ layout: isHorizontalBars ? "vertical" : "horizontal",
496
+ margin: {
497
+ top: 8,
498
+ right: 8,
499
+ bottom: 0,
500
+ left: 0
501
+ },
502
+ accessibilityLayer: false,
503
+ children: [showGrid && jsxRuntime.jsx(recharts.CartesianGrid, {
504
+ stroke: chrome.grid,
505
+ strokeDasharray: "3 3",
506
+ vertical: isHorizontalBars,
507
+ horizontal: !isHorizontalBars
508
+ }), isHorizontalBars ? jsxRuntime.jsx(recharts.XAxis, cn._objectSpread2(cn._objectSpread2({
509
+ type: "number"
510
+ }, valueAxis), {}, {
511
+ hide: !showXAxis,
512
+ width: undefined
513
+ })) : jsxRuntime.jsx(recharts.XAxis, cn._objectSpread2({}, categoryAxis)), isHorizontalBars ? jsxRuntime.jsx(recharts.YAxis, cn._objectSpread2(cn._objectSpread2({
514
+ type: "category"
515
+ }, categoryAxis), {}, {
516
+ hide: !showYAxis,
517
+ width: yAxisWidth,
518
+ interval: 0
519
+ })) : jsxRuntime.jsx(recharts.YAxis, cn._objectSpread2({}, valueAxis)), showTooltip && jsxRuntime.jsx(recharts.Tooltip, {
520
+ cursor: kind === "bar" ? {
521
+ fill: chrome.grid,
522
+ fillOpacity: 0.4
523
+ } : {
524
+ stroke: chrome.grid
525
+ },
526
+ isAnimationActive: false,
527
+ content: jsxRuntime.jsx(ChartTooltipContent, {
528
+ valueFormatter: valueFormatter
529
+ })
530
+ }), categories.map(function (category, i) {
531
+ return renderSeries(kind, {
532
+ id: "".concat(chartId, "-").concat(i),
533
+ category: category,
534
+ color: series[i],
535
+ curve: curve,
536
+ stacked: stacked,
537
+ showDots: showDots,
538
+ connectNulls: connectNulls,
539
+ animate: animate && !reducedMotion,
540
+ horizontal: isHorizontalBars,
541
+ barRadius: 4
542
+ });
543
+ })]
544
+ })
545
+ })
546
+ }));
547
+ });
548
+
549
+ var LineChart = /*#__PURE__*/React__default.default.forwardRef(function (props, ref) {
550
+ return jsxRuntime.jsx(CartesianChart, cn._objectSpread2(cn._objectSpread2({
551
+ ref: ref
552
+ }, props), {}, {
553
+ kind: "line"
554
+ }));
555
+ });
556
+ LineChart.displayName = "LineChart";
557
+
558
+ var BarChart = /*#__PURE__*/React__default.default.forwardRef(function (props, ref) {
559
+ return jsxRuntime.jsx(CartesianChart, cn._objectSpread2(cn._objectSpread2({
560
+ ref: ref
561
+ }, props), {}, {
562
+ kind: "bar"
563
+ }));
564
+ });
565
+ BarChart.displayName = "BarChart";
566
+
567
+ var AreaChart = /*#__PURE__*/React__default.default.forwardRef(function (props, ref) {
568
+ return jsxRuntime.jsx(CartesianChart, cn._objectSpread2(cn._objectSpread2({
569
+ ref: ref
570
+ }, props), {}, {
571
+ kind: "area"
572
+ }));
573
+ });
574
+ AreaChart.displayName = "AreaChart";
575
+
576
+ var _excluded$1 = ["data", "index", "category", "colors", "valueFormatter", "variant", "innerRadius", "outerRadius", "centerLabel", "height", "showLegend", "showTooltip", "animate", "title", "description", "emptyState", "accessibleTable", "className"];
577
+ var DonutChart = /*#__PURE__*/React__default.default.forwardRef(function (_ref, ref) {
578
+ var data = _ref.data,
579
+ _ref$index = _ref.index,
580
+ index = _ref$index === void 0 ? "name" : _ref$index,
581
+ _ref$category = _ref.category,
582
+ category = _ref$category === void 0 ? "value" : _ref$category,
583
+ colors = _ref.colors,
584
+ _ref$valueFormatter = _ref.valueFormatter,
585
+ valueFormatter = _ref$valueFormatter === void 0 ? defaultValueFormatter : _ref$valueFormatter,
586
+ _ref$variant = _ref.variant,
587
+ variant = _ref$variant === void 0 ? "donut" : _ref$variant,
588
+ _ref$innerRadius = _ref.innerRadius,
589
+ innerRadius = _ref$innerRadius === void 0 ? "60%" : _ref$innerRadius,
590
+ _ref$outerRadius = _ref.outerRadius,
591
+ outerRadius = _ref$outerRadius === void 0 ? "90%" : _ref$outerRadius,
592
+ centerLabel = _ref.centerLabel,
593
+ _ref$height = _ref.height,
594
+ height = _ref$height === void 0 ? 240 : _ref$height,
595
+ _ref$showLegend = _ref.showLegend,
596
+ showLegend = _ref$showLegend === void 0 ? true : _ref$showLegend,
597
+ _ref$showTooltip = _ref.showTooltip,
598
+ showTooltip = _ref$showTooltip === void 0 ? true : _ref$showTooltip,
599
+ _ref$animate = _ref.animate,
600
+ animate = _ref$animate === void 0 ? true : _ref$animate,
601
+ title = _ref.title,
602
+ description = _ref.description,
603
+ emptyState = _ref.emptyState,
604
+ _ref$accessibleTable = _ref.accessibleTable,
605
+ accessibleTable = _ref$accessibleTable === void 0 ? true : _ref$accessibleTable,
606
+ className = _ref.className,
607
+ rest = cn._objectWithoutProperties(_ref, _excluded$1);
608
+ var rows = Array.isArray(data) ? data : [];
609
+ var names = rows.map(function (row) {
610
+ return String(row[index]);
611
+ });
612
+ var _useChartTheme = useChartTheme(names, colors),
613
+ chrome = _useChartTheme.chrome,
614
+ series = _useChartTheme.series;
615
+ var reducedMotion = useReducedMotion();
616
+ var chartId = useChartId();
617
+ var slices = rows.map(function (row, i) {
618
+ return cn._objectSpread2(cn._objectSpread2({}, row), {}, {
619
+ fill: series[i]
620
+ });
621
+ });
622
+ var isDonut = variant !== "pie";
623
+ return jsxRuntime.jsx(ChartFrame, cn._objectSpread2(cn._objectSpread2({
624
+ ref: ref,
625
+ className: className,
626
+ title: title,
627
+ description: description,
628
+ defaultTitle: isDonut ? "Donut chart" : "Pie chart",
629
+ data: data,
630
+ height: height,
631
+ emptyState: emptyState,
632
+ accessibleTable: accessibleTable,
633
+ legend: showLegend ? names.map(function (name, i) {
634
+ return {
635
+ name: name,
636
+ color: series[i]
637
+ };
638
+ }) : null,
639
+ tableColumns: [{
640
+ key: index,
641
+ label: index,
642
+ format: function format(v) {
643
+ return v == null ? "" : String(v);
644
+ }
645
+ }, {
646
+ key: category,
647
+ label: category,
648
+ format: valueFormatter
649
+ }]
650
+ }, rest), {}, {
651
+ children: jsxRuntime.jsxs("div", {
652
+ className: "relative h-full w-full",
653
+ children: [jsxRuntime.jsx(recharts.ResponsiveContainer, {
654
+ width: "100%",
655
+ height: "100%",
656
+ minWidth: 0,
657
+ children: jsxRuntime.jsxs(recharts.PieChart, {
658
+ id: chartId,
659
+ accessibilityLayer: false,
660
+ children: [showTooltip && jsxRuntime.jsx(recharts.Tooltip, {
661
+ isAnimationActive: false,
662
+ content: jsxRuntime.jsx(ChartTooltipContent, {
663
+ valueFormatter: valueFormatter,
664
+ hideLabel: true
665
+ })
666
+ }), jsxRuntime.jsx(recharts.Pie, {
667
+ id: "".concat(chartId, "-0"),
668
+ data: slices,
669
+ dataKey: category,
670
+ nameKey: index,
671
+ innerRadius: isDonut ? innerRadius : 0,
672
+ outerRadius: outerRadius,
673
+ paddingAngle: isDonut && rows.length > 1 ? 1 : 0,
674
+ stroke: chrome.surface,
675
+ strokeWidth: 2,
676
+ isAnimationActive: animate && !reducedMotion
677
+ })]
678
+ })
679
+ }), isDonut && centerLabel != null && jsxRuntime.jsx("div", {
680
+ className: "pointer-events-none absolute inset-0 flex items-center justify-center text-center text-sm font-semibold text-gray-900 dark:text-gray-100",
681
+ "aria-hidden": "true",
682
+ children: centerLabel
683
+ })]
684
+ })
685
+ }));
686
+ });
687
+ DonutChart.displayName = "DonutChart";
688
+
689
+ var _excluded = ["data", "category", "index", "color", "type", "valueFormatter", "height", "showTooltip", "animate", "title", "description", "emptyState", "accessibleTable", "className"];
690
+ /** A word-sized trend line: no axes, grid or legend — just the shape of the data. */
691
+ var Sparkline = /*#__PURE__*/React__default.default.forwardRef(function (_ref, ref) {
692
+ var data = _ref.data,
693
+ _ref$category = _ref.category,
694
+ category = _ref$category === void 0 ? "value" : _ref$category,
695
+ index = _ref.index,
696
+ _ref$color = _ref.color,
697
+ color = _ref$color === void 0 ? "primary" : _ref$color,
698
+ _ref$type = _ref.type,
699
+ type = _ref$type === void 0 ? "line" : _ref$type,
700
+ _ref$valueFormatter = _ref.valueFormatter,
701
+ valueFormatter = _ref$valueFormatter === void 0 ? defaultValueFormatter : _ref$valueFormatter,
702
+ _ref$height = _ref.height,
703
+ height = _ref$height === void 0 ? 40 : _ref$height,
704
+ _ref$showTooltip = _ref.showTooltip,
705
+ showTooltip = _ref$showTooltip === void 0 ? false : _ref$showTooltip,
706
+ _ref$animate = _ref.animate,
707
+ animate = _ref$animate === void 0 ? false : _ref$animate,
708
+ title = _ref.title,
709
+ description = _ref.description,
710
+ _ref$emptyState = _ref.emptyState,
711
+ emptyState = _ref$emptyState === void 0 ? "No data" : _ref$emptyState,
712
+ _ref$accessibleTable = _ref.accessibleTable,
713
+ accessibleTable = _ref$accessibleTable === void 0 ? true : _ref$accessibleTable,
714
+ className = _ref.className,
715
+ rest = cn._objectWithoutProperties(_ref, _excluded);
716
+ var _useChartTheme = useChartTheme([category], [color]),
717
+ series = _useChartTheme.series;
718
+ var reducedMotion = useReducedMotion();
719
+ var chartId = useChartId();
720
+ var stroke = series[0];
721
+ var Root = type === "area" ? recharts.AreaChart : recharts.LineChart;
722
+ var common = {
723
+ id: "".concat(chartId, "-0"),
724
+ dataKey: category,
725
+ name: category,
726
+ type: "monotone",
727
+ stroke: stroke,
728
+ strokeWidth: 2,
729
+ dot: false,
730
+ activeDot: showTooltip ? {
731
+ r: 3,
732
+ strokeWidth: 0,
733
+ fill: stroke
734
+ } : false,
735
+ isAnimationActive: animate && !reducedMotion
736
+ };
737
+ return jsxRuntime.jsx(ChartFrame, cn._objectSpread2(cn._objectSpread2({
738
+ ref: ref,
739
+ className: className,
740
+ title: title,
741
+ description: description,
742
+ defaultTitle: "Sparkline",
743
+ data: data,
744
+ height: height,
745
+ emptyState: emptyState,
746
+ accessibleTable: accessibleTable,
747
+ tableColumns: [].concat(cn._toConsumableArray(index ? [{
748
+ key: index,
749
+ label: index,
750
+ format: function format(v) {
751
+ return v == null ? "" : String(v);
752
+ }
753
+ }] : []), [{
754
+ key: category,
755
+ label: category,
756
+ format: valueFormatter
757
+ }])
758
+ }, rest), {}, {
759
+ children: jsxRuntime.jsx(recharts.ResponsiveContainer, {
760
+ width: "100%",
761
+ height: "100%",
762
+ minWidth: 0,
763
+ children: jsxRuntime.jsxs(Root, {
764
+ id: chartId,
765
+ data: data,
766
+ margin: {
767
+ top: 2,
768
+ right: 2,
769
+ bottom: 2,
770
+ left: 2
771
+ },
772
+ accessibilityLayer: false,
773
+ children: [jsxRuntime.jsx(recharts.YAxis, {
774
+ hide: true,
775
+ domain: ["dataMin", "dataMax"]
776
+ }), showTooltip && jsxRuntime.jsx(recharts.Tooltip, {
777
+ isAnimationActive: false,
778
+ cursor: false,
779
+ content: jsxRuntime.jsx(ChartTooltipContent, {
780
+ valueFormatter: valueFormatter,
781
+ hideLabel: !index
782
+ })
783
+ }), type === "area" ? jsxRuntime.jsx(recharts.Area, cn._objectSpread2(cn._objectSpread2({}, common), {}, {
784
+ fill: stroke,
785
+ fillOpacity: 0.15
786
+ })) : jsxRuntime.jsx(recharts.Line, cn._objectSpread2({}, common))]
787
+ })
788
+ })
789
+ }));
790
+ });
791
+ Sparkline.displayName = "Sparkline";
792
+
793
+ exports.AreaChart = AreaChart;
794
+ exports.BarChart = BarChart;
795
+ exports.DonutChart = DonutChart;
796
+ exports.LineChart = LineChart;
797
+ exports.Sparkline = Sparkline;