@dreamtree-org/twreact-ui 1.3.1 → 1.3.2

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 (60) hide show
  1. package/DESIGN.md +2 -2
  2. package/README.md +80 -1
  3. package/ai-skills/dreamtree-ui.md +40 -3
  4. package/charts/package.json +5 -0
  5. package/dist/_shared/cn-DPPQUJu1.js +138 -0
  6. package/dist/ai-schema.json +638 -0
  7. package/dist/charts/index.d.ts +9 -0
  8. package/dist/charts/index.d.ts.map +1 -0
  9. package/dist/charts/index.js +769 -0
  10. package/dist/components/charts/AreaChart.d.ts +4 -0
  11. package/dist/components/charts/AreaChart.d.ts.map +1 -0
  12. package/dist/components/charts/BarChart.d.ts +4 -0
  13. package/dist/components/charts/BarChart.d.ts.map +1 -0
  14. package/dist/components/charts/CartesianChart.d.ts +5 -0
  15. package/dist/components/charts/CartesianChart.d.ts.map +1 -0
  16. package/dist/components/charts/ChartFrame.d.ts +18 -0
  17. package/dist/components/charts/ChartFrame.d.ts.map +1 -0
  18. package/dist/components/charts/DonutChart.d.ts +4 -0
  19. package/dist/components/charts/DonutChart.d.ts.map +1 -0
  20. package/dist/components/charts/LineChart.d.ts +4 -0
  21. package/dist/components/charts/LineChart.d.ts.map +1 -0
  22. package/dist/components/charts/Sparkline.d.ts +5 -0
  23. package/dist/components/charts/Sparkline.d.ts.map +1 -0
  24. package/dist/components/charts/chartTheme.d.ts +26 -0
  25. package/dist/components/charts/chartTheme.d.ts.map +1 -0
  26. package/dist/components/rich-text/RichTextEditor.d.ts +4 -0
  27. package/dist/components/rich-text/RichTextEditor.d.ts.map +1 -0
  28. package/dist/components/rich-text/RichTextToolbar.d.ts +219 -0
  29. package/dist/components/rich-text/RichTextToolbar.d.ts.map +1 -0
  30. package/dist/esm/charts/index.js +5 -0
  31. package/dist/esm/components/charts/AreaChart.js +16 -0
  32. package/dist/esm/components/charts/BarChart.js +16 -0
  33. package/dist/esm/components/charts/CartesianChart.js +250 -0
  34. package/dist/esm/components/charts/ChartFrame.js +170 -0
  35. package/dist/esm/components/charts/DonutChart.js +119 -0
  36. package/dist/esm/components/charts/LineChart.js +16 -0
  37. package/dist/esm/components/charts/Sparkline.js +110 -0
  38. package/dist/esm/components/charts/chartTheme.js +109 -0
  39. package/dist/esm/components/rich-text/RichTextEditor.js +244 -0
  40. package/dist/esm/components/rich-text/RichTextToolbar.js +397 -0
  41. package/dist/esm/rich-text/index.js +1 -0
  42. package/dist/index.css +1 -1
  43. package/dist/index.esm.css +1 -1
  44. package/dist/index.esm.js +17 -4
  45. package/dist/index.js +17 -4
  46. package/dist/rich-text/index.d.ts +5 -0
  47. package/dist/rich-text/index.d.ts.map +1 -0
  48. package/dist/rich-text/index.js +654 -0
  49. package/dist/tokens/brands/studio.css +14 -0
  50. package/dist/tokens/brands/studio.json +20 -0
  51. package/dist/types/charts.d.ts +97 -0
  52. package/dist/types/charts.d.ts.map +1 -0
  53. package/dist/types/rich-text.d.ts +50 -0
  54. package/dist/types/rich-text.d.ts.map +1 -0
  55. package/doc/README.md +13 -0
  56. package/mcp/catalog.snapshot.json +1009 -3
  57. package/mcp/server-core.mjs +30 -1
  58. package/package.json +38 -2
  59. package/rich-text/package.json +5 -0
  60. package/tokens/brands/studio.json +20 -0
@@ -0,0 +1,769 @@
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.
204
+ function resolveVar(name) {
205
+ var value = readVar(name);
206
+ return value ? "rgb(".concat(value.split(/[\s,]+/).join(" "), ")") : "rgb(var(".concat(name, "))");
207
+ }
208
+ /**
209
+ * A series colour: a palette token (`primary`, `success-600`, …) resolves to the
210
+ * matching `--dt-*` variable; any other string is treated as a CSS colour supplied
211
+ * by the consumer (e.g. a colour stored with the data).
212
+ */
213
+ function resolveColor(color) {
214
+ var name = tokenVar(color);
215
+ return name ? resolveVar(name) : color;
216
+ }
217
+ function seriesColors(categories, colors) {
218
+ var palette = colors && colors.length ? colors : DEFAULT_CHART_COLORS;
219
+ return categories.map(function (_, i) {
220
+ return resolveColor(palette[i % palette.length]);
221
+ });
222
+ }
223
+ function readChrome() {
224
+ return Object.fromEntries(Object.entries(CHROME_VARS).map(function (_ref) {
225
+ var _ref2 = cn._slicedToArray(_ref, 2),
226
+ k = _ref2[0],
227
+ v = _ref2[1];
228
+ return [k, resolveVar(v)];
229
+ }));
230
+ }
231
+ /**
232
+ * Chart chrome + series colours, re-read whenever the theme flips (the `dark`
233
+ * class or `data-theme` on <html>) so axes and series follow dark mode without
234
+ * a remount.
235
+ */
236
+ function useChartTheme(categories, colors) {
237
+ var _useState = React.useState(0),
238
+ _useState2 = cn._slicedToArray(_useState, 2);
239
+ _useState2[0];
240
+ var setVersion = _useState2[1];
241
+ React.useEffect(function () {
242
+ if (typeof MutationObserver !== "function") return undefined;
243
+ var observer = new MutationObserver(function () {
244
+ return setVersion(function (v) {
245
+ return v + 1;
246
+ });
247
+ });
248
+ observer.observe(document.documentElement, {
249
+ attributes: true,
250
+ attributeFilter: ["class", "data-theme", "style"]
251
+ });
252
+ return function () {
253
+ return observer.disconnect();
254
+ };
255
+ }, []);
256
+ return {
257
+ chrome: readChrome(),
258
+ series: seriesColors(categories, colors)
259
+ };
260
+ }
261
+ /** `true` while the user asks the OS for reduced motion; follows changes live. */
262
+ function useReducedMotion() {
263
+ var _useState3 = React.useState(prefersReducedMotion),
264
+ _useState4 = cn._slicedToArray(_useState3, 2),
265
+ reduced = _useState4[0],
266
+ setReduced = _useState4[1];
267
+ React.useEffect(function () {
268
+ var _query$addEventListen;
269
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return undefined;
270
+ var query = window.matchMedia("(prefers-reduced-motion: reduce)");
271
+ var update = function update() {
272
+ return setReduced(query.matches);
273
+ };
274
+ (_query$addEventListen = query.addEventListener) === null || _query$addEventListen === void 0 || _query$addEventListen.call(query, "change", update);
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", update);
278
+ };
279
+ }, []);
280
+ return reduced;
281
+ }
282
+ var defaultValueFormatter = function defaultValueFormatter(value) {
283
+ return typeof value === "number" ? value.toLocaleString() : value == null ? "" : String(value);
284
+ };
285
+
286
+ 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"];
287
+ var ROOTS = {
288
+ line: recharts.LineChart,
289
+ bar: recharts.BarChart,
290
+ area: recharts.AreaChart
291
+ };
292
+ var TITLES = {
293
+ line: "Line chart",
294
+ bar: "Bar chart",
295
+ area: "Area chart"
296
+ };
297
+ var CURVES = {
298
+ linear: "linear",
299
+ monotone: "monotone",
300
+ step: "step",
301
+ natural: "natural"
302
+ };
303
+ function renderSeries(kind, _ref) {
304
+ var category = _ref.category,
305
+ color = _ref.color,
306
+ curve = _ref.curve,
307
+ stacked = _ref.stacked,
308
+ showDots = _ref.showDots,
309
+ connectNulls = _ref.connectNulls,
310
+ animate = _ref.animate,
311
+ horizontal = _ref.horizontal,
312
+ barRadius = _ref.barRadius;
313
+ var common = {
314
+ dataKey: category,
315
+ name: category,
316
+ isAnimationActive: animate
317
+ };
318
+ if (kind === "bar") {
319
+ var radius = horizontal ? [0, barRadius, barRadius, 0] : [barRadius, barRadius, 0, 0];
320
+ return jsxRuntime.jsx(recharts.Bar, cn._objectSpread2(cn._objectSpread2({}, common), {}, {
321
+ fill: color,
322
+ stackId: stacked ? "stack" : undefined,
323
+ radius: stacked ? 0 : radius,
324
+ maxBarSize: 48
325
+ }), category);
326
+ }
327
+ if (kind === "area") {
328
+ return jsxRuntime.jsx(recharts.Area, cn._objectSpread2(cn._objectSpread2({}, common), {}, {
329
+ type: curve,
330
+ stroke: color,
331
+ fill: color,
332
+ fillOpacity: stacked ? 0.4 : 0.15,
333
+ strokeWidth: 2,
334
+ stackId: stacked ? "stack" : undefined,
335
+ dot: showDots ? {
336
+ r: 3,
337
+ fill: color,
338
+ strokeWidth: 0
339
+ } : false,
340
+ activeDot: {
341
+ r: 4,
342
+ strokeWidth: 0,
343
+ fill: color
344
+ },
345
+ connectNulls: connectNulls
346
+ }), category);
347
+ }
348
+ return jsxRuntime.jsx(recharts.Line, cn._objectSpread2(cn._objectSpread2({}, common), {}, {
349
+ type: curve,
350
+ stroke: color,
351
+ strokeWidth: 2,
352
+ dot: showDots ? {
353
+ r: 3,
354
+ fill: color,
355
+ strokeWidth: 0
356
+ } : false,
357
+ activeDot: {
358
+ r: 4,
359
+ strokeWidth: 0,
360
+ fill: color
361
+ },
362
+ connectNulls: connectNulls
363
+ }), category);
364
+ }
365
+ /** Shared implementation of LineChart / BarChart / AreaChart. */
366
+ var CartesianChart = /*#__PURE__*/React__default.default.forwardRef(function CartesianChart(_ref2, ref) {
367
+ var kind = _ref2.kind,
368
+ data = _ref2.data,
369
+ index = _ref2.index,
370
+ _ref2$categories = _ref2.categories,
371
+ categories = _ref2$categories === void 0 ? [] : _ref2$categories,
372
+ colors = _ref2.colors,
373
+ _ref2$valueFormatter = _ref2.valueFormatter,
374
+ valueFormatter = _ref2$valueFormatter === void 0 ? defaultValueFormatter : _ref2$valueFormatter,
375
+ xAxisFormatter = _ref2.xAxisFormatter,
376
+ _ref2$height = _ref2.height,
377
+ height = _ref2$height === void 0 ? 300 : _ref2$height,
378
+ _ref2$showLegend = _ref2.showLegend,
379
+ showLegend = _ref2$showLegend === void 0 ? true : _ref2$showLegend,
380
+ _ref2$showTooltip = _ref2.showTooltip,
381
+ showTooltip = _ref2$showTooltip === void 0 ? true : _ref2$showTooltip,
382
+ _ref2$showXAxis = _ref2.showXAxis,
383
+ showXAxis = _ref2$showXAxis === void 0 ? true : _ref2$showXAxis,
384
+ _ref2$showYAxis = _ref2.showYAxis,
385
+ showYAxis = _ref2$showYAxis === void 0 ? true : _ref2$showYAxis,
386
+ _ref2$showGrid = _ref2.showGrid,
387
+ showGrid = _ref2$showGrid === void 0 ? true : _ref2$showGrid,
388
+ _ref2$yAxisWidth = _ref2.yAxisWidth,
389
+ yAxisWidth = _ref2$yAxisWidth === void 0 ? 48 : _ref2$yAxisWidth,
390
+ _ref2$curveType = _ref2.curveType,
391
+ curveType = _ref2$curveType === void 0 ? "monotone" : _ref2$curveType,
392
+ _ref2$stacked = _ref2.stacked,
393
+ stacked = _ref2$stacked === void 0 ? false : _ref2$stacked,
394
+ _ref2$horizontal = _ref2.horizontal,
395
+ horizontal = _ref2$horizontal === void 0 ? false : _ref2$horizontal,
396
+ _ref2$showDots = _ref2.showDots,
397
+ showDots = _ref2$showDots === void 0 ? false : _ref2$showDots,
398
+ _ref2$connectNulls = _ref2.connectNulls,
399
+ connectNulls = _ref2$connectNulls === void 0 ? false : _ref2$connectNulls,
400
+ _ref2$animate = _ref2.animate,
401
+ animate = _ref2$animate === void 0 ? true : _ref2$animate,
402
+ title = _ref2.title,
403
+ description = _ref2.description,
404
+ emptyState = _ref2.emptyState,
405
+ _ref2$accessibleTable = _ref2.accessibleTable,
406
+ accessibleTable = _ref2$accessibleTable === void 0 ? true : _ref2$accessibleTable,
407
+ className = _ref2.className,
408
+ rest = cn._objectWithoutProperties(_ref2, _excluded$2);
409
+ var _useChartTheme = useChartTheme(categories, colors),
410
+ chrome = _useChartTheme.chrome,
411
+ series = _useChartTheme.series;
412
+ var reducedMotion = useReducedMotion();
413
+ var Root = ROOTS[kind];
414
+ var isHorizontalBars = kind === "bar" && horizontal;
415
+ var curve = CURVES[curveType] || "monotone";
416
+ var tick = {
417
+ fill: chrome.axis,
418
+ fontSize: 12
419
+ };
420
+ var formatIndex = xAxisFormatter || function (v) {
421
+ return v == null ? "" : String(v);
422
+ };
423
+ var categoryAxis = {
424
+ dataKey: index,
425
+ tick: tick,
426
+ tickLine: false,
427
+ axisLine: false,
428
+ tickFormatter: xAxisFormatter,
429
+ hide: !showXAxis,
430
+ minTickGap: 8
431
+ };
432
+ var valueAxis = {
433
+ tick: tick,
434
+ tickLine: false,
435
+ axisLine: false,
436
+ tickFormatter: valueFormatter,
437
+ hide: !showYAxis,
438
+ width: yAxisWidth
439
+ };
440
+ return jsxRuntime.jsx(ChartFrame, cn._objectSpread2(cn._objectSpread2({
441
+ ref: ref,
442
+ className: className,
443
+ title: title,
444
+ description: description,
445
+ defaultTitle: TITLES[kind],
446
+ data: data,
447
+ height: height,
448
+ emptyState: emptyState,
449
+ accessibleTable: accessibleTable,
450
+ legend: showLegend ? categories.map(function (c, i) {
451
+ return {
452
+ name: c,
453
+ color: series[i]
454
+ };
455
+ }) : null,
456
+ tableColumns: [{
457
+ key: index,
458
+ label: index,
459
+ format: formatIndex
460
+ }].concat(cn._toConsumableArray(categories.map(function (c) {
461
+ return {
462
+ key: c,
463
+ label: c,
464
+ format: valueFormatter
465
+ };
466
+ })))
467
+ }, rest), {}, {
468
+ children: jsxRuntime.jsx(recharts.ResponsiveContainer, {
469
+ width: "100%",
470
+ height: "100%",
471
+ minWidth: 0,
472
+ children: jsxRuntime.jsxs(Root, {
473
+ data: data,
474
+ layout: isHorizontalBars ? "vertical" : "horizontal",
475
+ margin: {
476
+ top: 8,
477
+ right: 8,
478
+ bottom: 0,
479
+ left: 0
480
+ },
481
+ accessibilityLayer: false,
482
+ children: [showGrid && jsxRuntime.jsx(recharts.CartesianGrid, {
483
+ stroke: chrome.grid,
484
+ strokeDasharray: "3 3",
485
+ vertical: isHorizontalBars,
486
+ horizontal: !isHorizontalBars
487
+ }), isHorizontalBars ? jsxRuntime.jsx(recharts.XAxis, cn._objectSpread2(cn._objectSpread2({
488
+ type: "number"
489
+ }, valueAxis), {}, {
490
+ hide: !showXAxis,
491
+ width: undefined
492
+ })) : jsxRuntime.jsx(recharts.XAxis, cn._objectSpread2({}, categoryAxis)), isHorizontalBars ? jsxRuntime.jsx(recharts.YAxis, cn._objectSpread2(cn._objectSpread2({
493
+ type: "category"
494
+ }, categoryAxis), {}, {
495
+ hide: !showYAxis,
496
+ width: yAxisWidth,
497
+ interval: 0
498
+ })) : jsxRuntime.jsx(recharts.YAxis, cn._objectSpread2({}, valueAxis)), showTooltip && jsxRuntime.jsx(recharts.Tooltip, {
499
+ cursor: kind === "bar" ? {
500
+ fill: chrome.grid,
501
+ fillOpacity: 0.4
502
+ } : {
503
+ stroke: chrome.grid
504
+ },
505
+ isAnimationActive: false,
506
+ content: jsxRuntime.jsx(ChartTooltipContent, {
507
+ valueFormatter: valueFormatter
508
+ })
509
+ }), categories.map(function (category, i) {
510
+ return renderSeries(kind, {
511
+ category: category,
512
+ color: series[i],
513
+ curve: curve,
514
+ stacked: stacked,
515
+ showDots: showDots,
516
+ connectNulls: connectNulls,
517
+ animate: animate && !reducedMotion,
518
+ horizontal: isHorizontalBars,
519
+ barRadius: 4
520
+ });
521
+ })]
522
+ })
523
+ })
524
+ }));
525
+ });
526
+
527
+ var LineChart = /*#__PURE__*/React__default.default.forwardRef(function (props, ref) {
528
+ return jsxRuntime.jsx(CartesianChart, cn._objectSpread2(cn._objectSpread2({
529
+ ref: ref
530
+ }, props), {}, {
531
+ kind: "line"
532
+ }));
533
+ });
534
+ LineChart.displayName = "LineChart";
535
+
536
+ var BarChart = /*#__PURE__*/React__default.default.forwardRef(function (props, ref) {
537
+ return jsxRuntime.jsx(CartesianChart, cn._objectSpread2(cn._objectSpread2({
538
+ ref: ref
539
+ }, props), {}, {
540
+ kind: "bar"
541
+ }));
542
+ });
543
+ BarChart.displayName = "BarChart";
544
+
545
+ var AreaChart = /*#__PURE__*/React__default.default.forwardRef(function (props, ref) {
546
+ return jsxRuntime.jsx(CartesianChart, cn._objectSpread2(cn._objectSpread2({
547
+ ref: ref
548
+ }, props), {}, {
549
+ kind: "area"
550
+ }));
551
+ });
552
+ AreaChart.displayName = "AreaChart";
553
+
554
+ var _excluded$1 = ["data", "index", "category", "colors", "valueFormatter", "variant", "innerRadius", "outerRadius", "centerLabel", "height", "showLegend", "showTooltip", "animate", "title", "description", "emptyState", "accessibleTable", "className"];
555
+ var DonutChart = /*#__PURE__*/React__default.default.forwardRef(function (_ref, ref) {
556
+ var data = _ref.data,
557
+ _ref$index = _ref.index,
558
+ index = _ref$index === void 0 ? "name" : _ref$index,
559
+ _ref$category = _ref.category,
560
+ category = _ref$category === void 0 ? "value" : _ref$category,
561
+ colors = _ref.colors,
562
+ _ref$valueFormatter = _ref.valueFormatter,
563
+ valueFormatter = _ref$valueFormatter === void 0 ? defaultValueFormatter : _ref$valueFormatter,
564
+ _ref$variant = _ref.variant,
565
+ variant = _ref$variant === void 0 ? "donut" : _ref$variant,
566
+ _ref$innerRadius = _ref.innerRadius,
567
+ innerRadius = _ref$innerRadius === void 0 ? "60%" : _ref$innerRadius,
568
+ _ref$outerRadius = _ref.outerRadius,
569
+ outerRadius = _ref$outerRadius === void 0 ? "90%" : _ref$outerRadius,
570
+ centerLabel = _ref.centerLabel,
571
+ _ref$height = _ref.height,
572
+ height = _ref$height === void 0 ? 240 : _ref$height,
573
+ _ref$showLegend = _ref.showLegend,
574
+ showLegend = _ref$showLegend === void 0 ? true : _ref$showLegend,
575
+ _ref$showTooltip = _ref.showTooltip,
576
+ showTooltip = _ref$showTooltip === void 0 ? true : _ref$showTooltip,
577
+ _ref$animate = _ref.animate,
578
+ animate = _ref$animate === void 0 ? true : _ref$animate,
579
+ title = _ref.title,
580
+ description = _ref.description,
581
+ emptyState = _ref.emptyState,
582
+ _ref$accessibleTable = _ref.accessibleTable,
583
+ accessibleTable = _ref$accessibleTable === void 0 ? true : _ref$accessibleTable,
584
+ className = _ref.className,
585
+ rest = cn._objectWithoutProperties(_ref, _excluded$1);
586
+ var rows = Array.isArray(data) ? data : [];
587
+ var names = rows.map(function (row) {
588
+ return String(row[index]);
589
+ });
590
+ var _useChartTheme = useChartTheme(names, colors),
591
+ chrome = _useChartTheme.chrome,
592
+ series = _useChartTheme.series;
593
+ var reducedMotion = useReducedMotion();
594
+ var slices = rows.map(function (row, i) {
595
+ return cn._objectSpread2(cn._objectSpread2({}, row), {}, {
596
+ fill: series[i]
597
+ });
598
+ });
599
+ var isDonut = variant !== "pie";
600
+ return jsxRuntime.jsx(ChartFrame, cn._objectSpread2(cn._objectSpread2({
601
+ ref: ref,
602
+ className: className,
603
+ title: title,
604
+ description: description,
605
+ defaultTitle: isDonut ? "Donut chart" : "Pie chart",
606
+ data: data,
607
+ height: height,
608
+ emptyState: emptyState,
609
+ accessibleTable: accessibleTable,
610
+ legend: showLegend ? names.map(function (name, i) {
611
+ return {
612
+ name: name,
613
+ color: series[i]
614
+ };
615
+ }) : null,
616
+ tableColumns: [{
617
+ key: index,
618
+ label: index,
619
+ format: function format(v) {
620
+ return v == null ? "" : String(v);
621
+ }
622
+ }, {
623
+ key: category,
624
+ label: category,
625
+ format: valueFormatter
626
+ }]
627
+ }, rest), {}, {
628
+ children: jsxRuntime.jsxs("div", {
629
+ className: "relative h-full w-full",
630
+ children: [jsxRuntime.jsx(recharts.ResponsiveContainer, {
631
+ width: "100%",
632
+ height: "100%",
633
+ minWidth: 0,
634
+ children: jsxRuntime.jsxs(recharts.PieChart, {
635
+ accessibilityLayer: false,
636
+ children: [showTooltip && jsxRuntime.jsx(recharts.Tooltip, {
637
+ isAnimationActive: false,
638
+ content: jsxRuntime.jsx(ChartTooltipContent, {
639
+ valueFormatter: valueFormatter,
640
+ hideLabel: true
641
+ })
642
+ }), jsxRuntime.jsx(recharts.Pie, {
643
+ data: slices,
644
+ dataKey: category,
645
+ nameKey: index,
646
+ innerRadius: isDonut ? innerRadius : 0,
647
+ outerRadius: outerRadius,
648
+ paddingAngle: isDonut && rows.length > 1 ? 1 : 0,
649
+ stroke: chrome.surface,
650
+ strokeWidth: 2,
651
+ isAnimationActive: animate && !reducedMotion
652
+ })]
653
+ })
654
+ }), isDonut && centerLabel != null && jsxRuntime.jsx("div", {
655
+ 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",
656
+ "aria-hidden": "true",
657
+ children: centerLabel
658
+ })]
659
+ })
660
+ }));
661
+ });
662
+ DonutChart.displayName = "DonutChart";
663
+
664
+ var _excluded = ["data", "category", "index", "color", "type", "valueFormatter", "height", "showTooltip", "animate", "title", "description", "emptyState", "accessibleTable", "className"];
665
+ /** A word-sized trend line: no axes, grid or legend — just the shape of the data. */
666
+ var Sparkline = /*#__PURE__*/React__default.default.forwardRef(function (_ref, ref) {
667
+ var data = _ref.data,
668
+ _ref$category = _ref.category,
669
+ category = _ref$category === void 0 ? "value" : _ref$category,
670
+ index = _ref.index,
671
+ _ref$color = _ref.color,
672
+ color = _ref$color === void 0 ? "primary" : _ref$color,
673
+ _ref$type = _ref.type,
674
+ type = _ref$type === void 0 ? "line" : _ref$type,
675
+ _ref$valueFormatter = _ref.valueFormatter,
676
+ valueFormatter = _ref$valueFormatter === void 0 ? defaultValueFormatter : _ref$valueFormatter,
677
+ _ref$height = _ref.height,
678
+ height = _ref$height === void 0 ? 40 : _ref$height,
679
+ _ref$showTooltip = _ref.showTooltip,
680
+ showTooltip = _ref$showTooltip === void 0 ? false : _ref$showTooltip,
681
+ _ref$animate = _ref.animate,
682
+ animate = _ref$animate === void 0 ? false : _ref$animate,
683
+ title = _ref.title,
684
+ description = _ref.description,
685
+ _ref$emptyState = _ref.emptyState,
686
+ emptyState = _ref$emptyState === void 0 ? "No data" : _ref$emptyState,
687
+ _ref$accessibleTable = _ref.accessibleTable,
688
+ accessibleTable = _ref$accessibleTable === void 0 ? true : _ref$accessibleTable,
689
+ className = _ref.className,
690
+ rest = cn._objectWithoutProperties(_ref, _excluded);
691
+ var _useChartTheme = useChartTheme([category], [color]),
692
+ series = _useChartTheme.series;
693
+ var reducedMotion = useReducedMotion();
694
+ var stroke = series[0];
695
+ var Root = type === "area" ? recharts.AreaChart : recharts.LineChart;
696
+ var common = {
697
+ dataKey: category,
698
+ name: category,
699
+ type: "monotone",
700
+ stroke: stroke,
701
+ strokeWidth: 2,
702
+ dot: false,
703
+ activeDot: showTooltip ? {
704
+ r: 3,
705
+ strokeWidth: 0,
706
+ fill: stroke
707
+ } : false,
708
+ isAnimationActive: animate && !reducedMotion
709
+ };
710
+ return jsxRuntime.jsx(ChartFrame, cn._objectSpread2(cn._objectSpread2({
711
+ ref: ref,
712
+ className: className,
713
+ title: title,
714
+ description: description,
715
+ defaultTitle: "Sparkline",
716
+ data: data,
717
+ height: height,
718
+ emptyState: emptyState,
719
+ accessibleTable: accessibleTable,
720
+ tableColumns: [].concat(cn._toConsumableArray(index ? [{
721
+ key: index,
722
+ label: index,
723
+ format: function format(v) {
724
+ return v == null ? "" : String(v);
725
+ }
726
+ }] : []), [{
727
+ key: category,
728
+ label: category,
729
+ format: valueFormatter
730
+ }])
731
+ }, rest), {}, {
732
+ children: jsxRuntime.jsx(recharts.ResponsiveContainer, {
733
+ width: "100%",
734
+ height: "100%",
735
+ minWidth: 0,
736
+ children: jsxRuntime.jsxs(Root, {
737
+ data: data,
738
+ margin: {
739
+ top: 2,
740
+ right: 2,
741
+ bottom: 2,
742
+ left: 2
743
+ },
744
+ accessibilityLayer: false,
745
+ children: [jsxRuntime.jsx(recharts.YAxis, {
746
+ hide: true,
747
+ domain: ["dataMin", "dataMax"]
748
+ }), showTooltip && jsxRuntime.jsx(recharts.Tooltip, {
749
+ isAnimationActive: false,
750
+ cursor: false,
751
+ content: jsxRuntime.jsx(ChartTooltipContent, {
752
+ valueFormatter: valueFormatter,
753
+ hideLabel: !index
754
+ })
755
+ }), type === "area" ? jsxRuntime.jsx(recharts.Area, cn._objectSpread2(cn._objectSpread2({}, common), {}, {
756
+ fill: stroke,
757
+ fillOpacity: 0.15
758
+ })) : jsxRuntime.jsx(recharts.Line, cn._objectSpread2({}, common))]
759
+ })
760
+ })
761
+ }));
762
+ });
763
+ Sparkline.displayName = "Sparkline";
764
+
765
+ exports.AreaChart = AreaChart;
766
+ exports.BarChart = BarChart;
767
+ exports.DonutChart = DonutChart;
768
+ exports.LineChart = LineChart;
769
+ exports.Sparkline = Sparkline;