@vectara/vectara-ui 18.4.0 → 19.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/lib/components/card/SimpleCard.d.ts +1 -1
  2. package/lib/components/card/_index.scss +5 -30
  3. package/lib/components/chart/BarChart.d.ts +20 -0
  4. package/lib/components/chart/BarChart.js +28 -0
  5. package/lib/components/chart/ComposedChart.d.ts +21 -0
  6. package/lib/components/chart/ComposedChart.js +29 -0
  7. package/lib/components/chart/LineChart.d.ts +22 -0
  8. package/lib/components/chart/LineChart.js +42 -0
  9. package/lib/components/chart/PieChart.d.ts +15 -0
  10. package/lib/components/chart/PieChart.js +36 -0
  11. package/lib/components/chart/ScatterChart.d.ts +18 -0
  12. package/lib/components/chart/ScatterChart.js +34 -0
  13. package/lib/components/chart/Sparkline.d.ts +13 -0
  14. package/lib/components/chart/Sparkline.js +23 -0
  15. package/lib/components/chart/TreeMap.d.ts +13 -0
  16. package/lib/components/chart/TreeMap.js +51 -0
  17. package/lib/components/chart/_index.scss +19 -0
  18. package/lib/components/chart/chartTheme.d.ts +21 -0
  19. package/lib/components/chart/chartTheme.js +13 -0
  20. package/lib/components/chart/palette.d.ts +5 -0
  21. package/lib/components/chart/palette.js +29 -0
  22. package/lib/components/composer/Composer.d.ts +41 -0
  23. package/lib/components/composer/Composer.js +148 -0
  24. package/lib/components/composer/_index.scss +4 -0
  25. package/lib/components/composer/useComposerHistory.d.ts +34 -0
  26. package/lib/components/composer/useComposerHistory.js +127 -0
  27. package/lib/components/context/Theme.d.ts +32 -0
  28. package/lib/components/context/Theme.js +116 -3
  29. package/lib/components/fileDropTarget/FileDropTarget.d.ts +8 -0
  30. package/lib/components/fileDropTarget/FileDropTarget.js +69 -0
  31. package/lib/components/fileDropTarget/_index.scss +34 -0
  32. package/lib/components/index.d.ts +13 -2
  33. package/lib/components/index.js +12 -1
  34. package/lib/components/patch/VuiPatch.d.ts +10 -0
  35. package/lib/components/patch/VuiPatch.js +32 -0
  36. package/lib/components/patch/_index.scss +30 -0
  37. package/lib/styles/index.css +143 -27
  38. package/package.json +4 -3
  39. package/src/docs/Docs.tsx +10 -0
  40. package/src/docs/pages/barChart/Basic.tsx +21 -0
  41. package/src/docs/pages/barChart/Horizontal.tsx +20 -0
  42. package/src/docs/pages/barChart/Stacked.tsx +23 -0
  43. package/src/docs/pages/barChart/index.tsx +29 -0
  44. package/src/docs/pages/card/SimpleCard.tsx +72 -6
  45. package/src/docs/pages/colorPalette/CategoricalColors.tsx +89 -0
  46. package/src/docs/pages/colorPalette/ChartColors.tsx +68 -0
  47. package/src/docs/pages/colorPalette/NeutralColors.tsx +42 -0
  48. package/src/docs/pages/colorPalette/SemanticColors.tsx +64 -0
  49. package/src/docs/pages/colorPalette/Swatch.tsx +59 -0
  50. package/src/docs/pages/colorPalette/TextAndBorderColors.tsx +37 -0
  51. package/src/docs/pages/colorPalette/Usage.tsx +72 -0
  52. package/src/docs/pages/colorPalette/index.tsx +50 -0
  53. package/src/docs/pages/composedChart/Basic.tsx +25 -0
  54. package/src/docs/pages/composedChart/index.tsx +15 -0
  55. package/src/docs/pages/composer/Composer.tsx +130 -0
  56. package/src/docs/pages/composer/index.tsx +11 -0
  57. package/src/docs/pages/fileDropTarget/FileDropTarget.tsx +80 -0
  58. package/src/docs/pages/fileDropTarget/index.tsx +11 -0
  59. package/src/docs/pages/lineChart/Area.tsx +25 -0
  60. package/src/docs/pages/lineChart/Basic.tsx +23 -0
  61. package/src/docs/pages/lineChart/Curved.tsx +25 -0
  62. package/src/docs/pages/lineChart/StackedArea.tsx +27 -0
  63. package/src/docs/pages/lineChart/index.tsx +36 -0
  64. package/src/docs/pages/patch/Icons.tsx +16 -0
  65. package/src/docs/pages/patch/Sizes.tsx +20 -0
  66. package/src/docs/pages/patch/index.tsx +22 -0
  67. package/src/docs/pages/pieChart/Basic.tsx +13 -0
  68. package/src/docs/pages/pieChart/Donut.tsx +12 -0
  69. package/src/docs/pages/pieChart/ManyValues.tsx +51 -0
  70. package/src/docs/pages/pieChart/Unlabeled.tsx +15 -0
  71. package/src/docs/pages/pieChart/index.tsx +36 -0
  72. package/src/docs/pages/scatterChart/Basic.tsx +31 -0
  73. package/src/docs/pages/scatterChart/Dense.tsx +144 -0
  74. package/src/docs/pages/scatterChart/index.tsx +22 -0
  75. package/src/docs/pages/sparkline/Basic.tsx +7 -0
  76. package/src/docs/pages/sparkline/Inline.tsx +21 -0
  77. package/src/docs/pages/sparkline/index.tsx +22 -0
  78. package/src/docs/pages/treeMap/Basic.tsx +14 -0
  79. package/src/docs/pages/treeMap/Nested.tsx +88 -0
  80. package/src/docs/pages/treeMap/index.tsx +22 -0
  81. package/src/docs/pages.tsx +20 -3
@@ -4,7 +4,7 @@ type Props = {
4
4
  fullHeight?: boolean;
5
5
  href?: string;
6
6
  onClick?: (e: MouseEvent) => void;
7
- padding?: "xxs" | "xs" | "s" | "m" | "l";
7
+ padding?: "s" | "m" | "l";
8
8
  children?: React.ReactNode;
9
9
  error?: string | ReactNode;
10
10
  warning?: string | ReactNode;
@@ -179,28 +179,11 @@
179
179
  }
180
180
 
181
181
  .vuiSimpleCard--interactive {
182
- border: 1px solid var(--vui-color-primary-highlight-shade);
183
182
  transition: box-shadow $transitionSpeed, border-color $transitionSpeed;
184
183
 
185
184
  &:hover {
186
- border-color: var(--vui-color-primary-shade);
187
- box-shadow: $shadowLargeEnd;
188
- }
189
- }
190
-
191
- .vuiSimpleCard--danger {
192
- border-color: var(--vui-color-danger-shade);
193
-
194
- &.vuiSimpleCard--interactive:hover {
195
- border-color: var(--vui-color-danger-shade);
196
- }
197
- }
198
-
199
- .vuiSimpleCard--warning {
200
- border-color: var(--vui-color-warning-shade);
201
-
202
- &.vuiSimpleCard--interactive:hover {
203
- border-color: var(--vui-color-warning-shade);
185
+ border-color: var(--vui-color-primary-highlight-shade);
186
+ box-shadow: rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 2px 6px 2px;
204
187
  }
205
188
  }
206
189
 
@@ -208,22 +191,14 @@
208
191
  height: 100%;
209
192
  }
210
193
 
211
- .vuiSimpleCard--xxs {
212
- padding: $sizeXs $sizeS;
213
- }
214
-
215
- .vuiSimpleCard--xs {
216
- padding: $sizeS $sizeM;
217
- }
218
-
219
194
  .vuiSimpleCard--s {
220
- padding: $sizeM $sizeL;
195
+ padding: $sizeS;
221
196
  }
222
197
 
223
198
  .vuiSimpleCard--m {
224
- padding: $sizeL $sizeXl;
199
+ padding: $sizeM;
225
200
  }
226
201
 
227
202
  .vuiSimpleCard--l {
228
- padding: $sizeXl $sizeXxl;
203
+ padding: $sizeL;
229
204
  }
@@ -0,0 +1,20 @@
1
+ import { PatchColor } from "../patch/VuiPatch";
2
+ export type BarChartSeries = {
3
+ dataKey: string;
4
+ name?: string;
5
+ color?: PatchColor;
6
+ };
7
+ type Props = {
8
+ data: Array<Record<string, string | number>>;
9
+ categoryKey: string;
10
+ series: BarChartSeries[];
11
+ orientation?: "columns" | "bars";
12
+ stacked?: boolean;
13
+ height?: number;
14
+ showLegend?: boolean;
15
+ showGrid?: boolean;
16
+ showTooltip?: boolean;
17
+ "data-testid"?: string;
18
+ };
19
+ export declare const VuiBarChart: ({ data, categoryKey, series, orientation, stacked, height, showLegend, showGrid, showTooltip, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
20
+ export {};
@@ -0,0 +1,28 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Bar, CartesianGrid, BarChart as RechartsBarChart, Legend, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
14
+ import { getChartColor, getChartColorByIndex } from "./palette";
15
+ import { chartAxisLineStyle, chartLegendProps, chartTickStyle, chartTooltipProps } from "./chartTheme";
16
+ export const VuiBarChart = (_a) => {
17
+ var { data, categoryKey, series, orientation = "columns", stacked = false, height = 320, showLegend = series.length > 1, showGrid = true, showTooltip = true } = _a, rest = __rest(_a, ["data", "categoryKey", "series", "orientation", "stacked", "height", "showLegend", "showGrid", "showTooltip"]);
18
+ const isHorizontal = orientation === "bars";
19
+ const categoryAxis = (_jsx(_Fragment, { children: isHorizontal ? (_jsx(YAxis, { type: "category", dataKey: categoryKey, tick: chartTickStyle, axisLine: chartAxisLineStyle, tickLine: false })) : (_jsx(XAxis, { type: "category", dataKey: categoryKey, tick: chartTickStyle, axisLine: chartAxisLineStyle, tickLine: false })) }));
20
+ const valueAxis = isHorizontal ? (_jsx(XAxis, { type: "number", tick: chartTickStyle, axisLine: chartAxisLineStyle, tickLine: false })) : (_jsx(YAxis, { type: "number", tick: chartTickStyle, axisLine: chartAxisLineStyle, tickLine: false }));
21
+ return (_jsx("div", Object.assign({ className: "vuiBarChart" }, rest, { children: _jsx(ResponsiveContainer, Object.assign({ width: "100%", height: height }, { children: _jsxs(RechartsBarChart, Object.assign({ data: data, layout: isHorizontal ? "vertical" : "horizontal" }, { children: [showGrid && (_jsx(CartesianGrid, { stroke: "var(--vui-color-border-light)", vertical: isHorizontal, horizontal: !isHorizontal })), categoryAxis, valueAxis, showTooltip && _jsx(Tooltip, Object.assign({ cursor: { fill: "var(--vui-color-light-shade)" } }, chartTooltipProps)), showLegend && _jsx(Legend, Object.assign({}, chartLegendProps)), series.map((s, index) => {
22
+ var _a;
23
+ return (_jsx(Bar, { dataKey: s.dataKey, name: (_a = s.name) !== null && _a !== void 0 ? _a : s.dataKey, fill: s.color ? getChartColor(s.color) : getChartColorByIndex(index), stackId: stacked ? "stack" : undefined, radius: isHorizontal ? [0, 4, 4, 0] : [4, 4, 0, 0],
24
+ // A thin stroke separates touching segments regardless of fill,
25
+ // a redundant cue that aids color-blind readers.
26
+ stroke: "var(--vui-color-empty-shade)", strokeWidth: 1 }, s.dataKey));
27
+ })] })) })) })));
28
+ };
@@ -0,0 +1,21 @@
1
+ import { PatchColor } from "../patch/VuiPatch";
2
+ export type ComposedSeries = {
3
+ dataKey: string;
4
+ type: "bar" | "line";
5
+ name?: string;
6
+ color?: PatchColor;
7
+ axis?: "left" | "right";
8
+ curved?: boolean;
9
+ };
10
+ type Props = {
11
+ data: Array<Record<string, string | number>>;
12
+ categoryKey: string;
13
+ series: ComposedSeries[];
14
+ height?: number;
15
+ showLegend?: boolean;
16
+ showGrid?: boolean;
17
+ showTooltip?: boolean;
18
+ "data-testid"?: string;
19
+ };
20
+ export declare const VuiComposedChart: ({ data, categoryKey, series, height, showLegend, showGrid, showTooltip, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
21
+ export {};
@@ -0,0 +1,29 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Bar, CartesianGrid, ComposedChart as RechartsComposedChart, Legend, Line, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
14
+ import { getChartColor, getChartColorByIndex } from "./palette";
15
+ import { chartAxisLineStyle, chartLegendProps, chartTickStyle, chartTooltipProps } from "./chartTheme";
16
+ export const VuiComposedChart = (_a) => {
17
+ var { data, categoryKey, series, height = 320, showLegend = series.length > 1, showGrid = true, showTooltip = true } = _a, rest = __rest(_a, ["data", "categoryKey", "series", "height", "showLegend", "showGrid", "showTooltip"]);
18
+ const hasRightAxis = series.some((s) => s.axis === "right");
19
+ return (_jsx("div", Object.assign({ className: "vuiComposedChart" }, rest, { children: _jsx(ResponsiveContainer, Object.assign({ width: "100%", height: height }, { children: _jsxs(RechartsComposedChart, Object.assign({ data: data }, { children: [showGrid && _jsx(CartesianGrid, { stroke: "var(--vui-color-border-light)", vertical: false }), _jsx(XAxis, { dataKey: categoryKey, tick: chartTickStyle, axisLine: chartAxisLineStyle, tickLine: false }), _jsx(YAxis, { yAxisId: "left", tick: chartTickStyle, axisLine: chartAxisLineStyle, tickLine: false }), hasRightAxis && (_jsx(YAxis, { yAxisId: "right", orientation: "right", tick: chartTickStyle, axisLine: chartAxisLineStyle, tickLine: false })), showTooltip && _jsx(Tooltip, Object.assign({ cursor: { fill: "var(--vui-color-light-shade)" } }, chartTooltipProps)), showLegend && _jsx(Legend, Object.assign({}, chartLegendProps)), series.map((s, index) => {
20
+ var _a, _b;
21
+ const color = s.color ? getChartColor(s.color) : getChartColorByIndex(index);
22
+ const yAxisId = (_a = s.axis) !== null && _a !== void 0 ? _a : "left";
23
+ const name = (_b = s.name) !== null && _b !== void 0 ? _b : s.dataKey;
24
+ if (s.type === "bar") {
25
+ return (_jsx(Bar, { yAxisId: yAxisId, dataKey: s.dataKey, name: name, fill: color, radius: [4, 4, 0, 0], stroke: "var(--vui-color-empty-shade)", strokeWidth: 1 }, s.dataKey));
26
+ }
27
+ return (_jsx(Line, { yAxisId: yAxisId, type: s.curved ? "monotone" : "linear", dataKey: s.dataKey, name: name, stroke: color, strokeWidth: 2, dot: { r: 3, strokeWidth: 0, fill: color }, activeDot: { r: 5 } }, s.dataKey));
28
+ })] })) })) })));
29
+ };
@@ -0,0 +1,22 @@
1
+ import { PatchColor } from "../patch/VuiPatch";
2
+ export type LineChartSeries = {
3
+ dataKey: string;
4
+ name?: string;
5
+ color?: PatchColor;
6
+ };
7
+ export type LineChartVariant = "line" | "area" | "stacked-area";
8
+ type Props = {
9
+ data: Array<Record<string, string | number>>;
10
+ categoryKey: string;
11
+ series: LineChartSeries[];
12
+ variant?: LineChartVariant;
13
+ curved?: boolean;
14
+ showPoints?: boolean;
15
+ height?: number;
16
+ showLegend?: boolean;
17
+ showGrid?: boolean;
18
+ showTooltip?: boolean;
19
+ "data-testid"?: string;
20
+ };
21
+ export declare const VuiLineChart: ({ data, categoryKey, series, variant, curved, showPoints, height, showLegend, showGrid, showTooltip, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
22
+ export {};
@@ -0,0 +1,42 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Area, AreaChart as RechartsAreaChart, CartesianGrid, Line, LineChart as RechartsLineChart, Legend, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
14
+ import { getChartColor, getChartColorByIndex } from "./palette";
15
+ import { chartAxisLineStyle, chartLegendProps, chartTickStyle, chartTooltipProps } from "./chartTheme";
16
+ export const VuiLineChart = (_a) => {
17
+ var { data, categoryKey, series, variant = "line", curved = false, showPoints = true, height = 320, showLegend = series.length > 1, showGrid = true, showTooltip = true } = _a, rest = __rest(_a, ["data", "categoryKey", "series", "variant", "curved", "showPoints", "height", "showLegend", "showGrid", "showTooltip"]);
18
+ const isArea = variant === "area" || variant === "stacked-area";
19
+ const isStacked = variant === "stacked-area";
20
+ const axes = (_jsxs(_Fragment, { children: [showGrid && _jsx(CartesianGrid, { stroke: "var(--vui-color-border-light)", vertical: false }), _jsx(XAxis, { dataKey: categoryKey, tick: chartTickStyle, axisLine: chartAxisLineStyle, tickLine: false }), _jsx(YAxis, { tick: chartTickStyle, axisLine: chartAxisLineStyle, tickLine: false }), showTooltip && _jsx(Tooltip, Object.assign({ cursor: { stroke: "var(--vui-color-border-medium)" } }, chartTooltipProps)), showLegend && _jsx(Legend, Object.assign({}, chartLegendProps))] }));
21
+ // Shared marker props keep lines and areas visually identical apart from the fill.
22
+ const markProps = (s, index) => {
23
+ var _a;
24
+ const color = s.color ? getChartColor(s.color) : getChartColorByIndex(index);
25
+ return {
26
+ key: s.dataKey,
27
+ type: curved ? "monotone" : "linear",
28
+ dataKey: s.dataKey,
29
+ name: (_a = s.name) !== null && _a !== void 0 ? _a : s.dataKey,
30
+ stroke: color,
31
+ strokeWidth: 2,
32
+ dot: showPoints ? { r: 3, strokeWidth: 0, fill: color } : false,
33
+ activeDot: { r: 5 }
34
+ };
35
+ };
36
+ return (_jsx("div", Object.assign({ className: "vuiLineChart" }, rest, { children: _jsx(ResponsiveContainer, Object.assign({ width: "100%", height: height }, { children: isArea ? (_jsxs(RechartsAreaChart, Object.assign({ data: data }, { children: [axes, series.map((s, index) => {
37
+ const props = markProps(s, index);
38
+ // Stacked areas tile rather than overlap, so they take a more solid
39
+ // fill; overlapping areas stay translucent to remain readable.
40
+ return (_jsx(Area, Object.assign({}, props, { fill: props.stroke, fillOpacity: isStacked ? 0.85 : 0.2, stackId: isStacked ? "stack" : undefined })));
41
+ })] }))) : (_jsxs(RechartsLineChart, Object.assign({ data: data }, { children: [axes, series.map((s, index) => (_jsx(Line, Object.assign({}, markProps(s, index)))))] }))) })) })));
42
+ };
@@ -0,0 +1,15 @@
1
+ import { PatchColor } from "../patch/VuiPatch";
2
+ type Props = {
3
+ data: Array<Record<string, string | number>>;
4
+ categoryKey: string;
5
+ valueKey: string;
6
+ donut?: boolean;
7
+ colors?: PatchColor[];
8
+ showLabels?: boolean;
9
+ height?: number;
10
+ showLegend?: boolean;
11
+ showTooltip?: boolean;
12
+ "data-testid"?: string;
13
+ };
14
+ export declare const VuiPieChart: ({ data, categoryKey, valueKey, donut, colors, showLabels, height, showLegend, showTooltip, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -0,0 +1,36 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Cell, Legend, Pie, PieChart as RechartsPieChart, ResponsiveContainer, Tooltip } from "recharts";
14
+ import { getChartColor, getChartColorByIndex } from "./palette";
15
+ import { chartLegendProps, chartTooltipProps } from "./chartTheme";
16
+ const RADIAN = Math.PI / 180;
17
+ // Render a slice's name and percentage just outside its arc, anchored so the
18
+ // text reads away from the center.
19
+ const renderSliceLabel = ({ cx, cy, midAngle, outerRadius, percent, name }) => {
20
+ const centerX = Number(cx);
21
+ const centerY = Number(cy);
22
+ const angle = Number(midAngle);
23
+ const radius = Number(outerRadius) + 18;
24
+ const x = centerX + radius * Math.cos(-angle * RADIAN);
25
+ const y = centerY + radius * Math.sin(-angle * RADIAN);
26
+ return (_jsx("text", Object.assign({ x: x, y: y, fill: "var(--vui-color-text)", fontSize: 12, textAnchor: x > centerX ? "start" : "end", dominantBaseline: "central" }, { children: `${name} (${Math.round(Number(percent) * 100)}%)` })));
27
+ };
28
+ export const VuiPieChart = (_a) => {
29
+ var { data, categoryKey, valueKey, donut = false, colors, showLabels = true, height = 320, showLegend = true, showTooltip = true } = _a, rest = __rest(_a, ["data", "categoryKey", "valueKey", "donut", "colors", "showLabels", "height", "showLegend", "showTooltip"]);
30
+ return (_jsx("div", Object.assign({ className: "vuiPieChart" }, rest, { children: _jsx(ResponsiveContainer, Object.assign({ width: "100%", height: height }, { children: _jsxs(RechartsPieChart, { children: [_jsx(Pie, Object.assign({ data: data, dataKey: valueKey, nameKey: categoryKey, innerRadius: donut ? "55%" : 0,
31
+ // Leave room outside the arc for labels when they're shown.
32
+ outerRadius: showLabels ? "70%" : "80%", paddingAngle: 1, label: showLabels ? renderSliceLabel : undefined, labelLine: showLabels ? { stroke: "var(--vui-color-border-medium)" } : false,
33
+ // A stroke between slices separates adjacent colors, a redundant cue
34
+ // that aids color-blind readers.
35
+ stroke: "var(--vui-color-empty-shade)", strokeWidth: 2 }, { children: data.map((datum, index) => (_jsx(Cell, { fill: (colors === null || colors === void 0 ? void 0 : colors[index]) ? getChartColor(colors[index]) : getChartColorByIndex(index) }, String(datum[categoryKey])))) })), showTooltip && _jsx(Tooltip, Object.assign({}, chartTooltipProps)), showLegend && _jsx(Legend, Object.assign({}, chartLegendProps))] }) })) })));
36
+ };
@@ -0,0 +1,18 @@
1
+ import { PatchColor } from "../patch/VuiPatch";
2
+ export type ScatterSeries = {
3
+ data: Array<Record<string, number>>;
4
+ name?: string;
5
+ color?: PatchColor;
6
+ };
7
+ type Props = {
8
+ series: ScatterSeries[];
9
+ xKey?: string;
10
+ yKey?: string;
11
+ height?: number;
12
+ showLegend?: boolean;
13
+ showGrid?: boolean;
14
+ showTooltip?: boolean;
15
+ "data-testid"?: string;
16
+ };
17
+ export declare const VuiScatterChart: ({ series, xKey, yKey, height, showLegend, showGrid, showTooltip, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
18
+ export {};
@@ -0,0 +1,34 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { useState } from "react";
14
+ import { CartesianGrid, Legend, ResponsiveContainer, Scatter, ScatterChart as RechartsScatterChart, Tooltip, XAxis, YAxis } from "recharts";
15
+ import { getChartColor, getChartColorByIndex } from "./palette";
16
+ import { chartAxisLineStyle, chartLegendProps, chartTickStyle, chartTooltipProps } from "./chartTheme";
17
+ const DEFAULT_RADIUS = 4;
18
+ const ACTIVE_RADIUS = 7;
19
+ export const VuiScatterChart = (_a) => {
20
+ var { series, xKey = "x", yKey = "y", height = 320, showLegend = series.length > 1, showGrid = true, showTooltip = true } = _a, rest = __rest(_a, ["series", "xKey", "yKey", "height", "showLegend", "showGrid", "showTooltip"]);
21
+ // Recharts fires activeShape for the active point of every series at the
22
+ // shared hover index, which would light up points across colors at once.
23
+ // Tracking the hovered series lets only that series emphasize its point;
24
+ // the others render an ordinary dot.
25
+ const [hoveredSeries, setHoveredSeries] = useState(null);
26
+ return (_jsx("div", Object.assign({ className: "vuiScatterChart" }, rest, { children: _jsx(ResponsiveContainer, Object.assign({ width: "100%", height: height }, { children: _jsxs(RechartsScatterChart, { children: [showGrid && _jsx(CartesianGrid, { stroke: "var(--vui-color-border-light)" }), _jsx(XAxis, { type: "number", dataKey: xKey, tick: chartTickStyle, axisLine: chartAxisLineStyle, tickLine: false }), _jsx(YAxis, { type: "number", dataKey: yKey, tick: chartTickStyle, axisLine: chartAxisLineStyle, tickLine: false }), showTooltip && (_jsx(Tooltip, Object.assign({ cursor: { strokeDasharray: "3 3", stroke: "var(--vui-color-border-medium)" } }, chartTooltipProps))), showLegend && _jsx(Legend, Object.assign({}, chartLegendProps)), series.map((s, index) => {
27
+ var _a;
28
+ const color = s.color ? getChartColor(s.color) : getChartColorByIndex(index);
29
+ // Only the hovered series rings its active point; ring it with the
30
+ // surface color so it lifts above the points it overlaps.
31
+ const renderActivePoint = ({ cx, cy }) => hoveredSeries === index ? (_jsx("circle", { cx: cx, cy: cy, r: ACTIVE_RADIUS, fill: color, stroke: "var(--vui-color-empty-shade)", strokeWidth: 2 })) : (_jsx("circle", { cx: cx, cy: cy, r: DEFAULT_RADIUS, fill: color }));
32
+ return (_jsx(Scatter, { name: s.name, data: s.data, fill: color, activeShape: renderActivePoint, onMouseEnter: () => setHoveredSeries(index), onMouseLeave: () => setHoveredSeries(null) }, (_a = s.name) !== null && _a !== void 0 ? _a : index));
33
+ })] }) })) })));
34
+ };
@@ -0,0 +1,13 @@
1
+ import { PatchColor } from "../patch/VuiPatch";
2
+ type Props = {
3
+ data: Array<Record<string, string | number>>;
4
+ dataKey: string;
5
+ variant?: "line" | "bar";
6
+ color?: PatchColor;
7
+ curved?: boolean;
8
+ width?: number;
9
+ height?: number;
10
+ "data-testid"?: string;
11
+ };
12
+ export declare const VuiSparkline: ({ data, dataKey, variant, color, curved, width, height, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1,23 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { Bar, BarChart, Line, LineChart } from "recharts";
14
+ import { getChartColor, getChartColorByIndex } from "./palette";
15
+ // A compact, axis-free trend meant to sit inline beside a number or in a table
16
+ // cell. It renders at a fixed size rather than filling its container.
17
+ export const VuiSparkline = (_a) => {
18
+ var { data, dataKey, variant = "line", color, curved = true, width = 120, height = 32 } = _a, rest = __rest(_a, ["data", "dataKey", "variant", "color", "curved", "width", "height"]);
19
+ const fill = color ? getChartColor(color) : getChartColorByIndex(0);
20
+ return (_jsx("div", Object.assign({ className: "vuiSparkline" }, rest, { children: variant === "bar" ? (_jsx(BarChart, Object.assign({ width: width, height: height, data: data, margin: { top: 1, right: 0, bottom: 1, left: 0 } }, { children: _jsx(Bar, { dataKey: dataKey, fill: fill, radius: 1, isAnimationActive: false }) }))) : (_jsx(LineChart, Object.assign({ width: width, height: height, data: data, margin: { top: 2, right: 2, bottom: 2, left: 2 } }, { children: _jsx(Line, { type: curved ? "monotone" : "linear", dataKey: dataKey, stroke: fill, strokeWidth: 1.5, dot: false,
21
+ // No axes or tooltip means a hover dot conveys nothing, so suppress it.
22
+ activeDot: false, isAnimationActive: false }) }))) })));
23
+ };
@@ -0,0 +1,13 @@
1
+ import { PatchColor } from "../patch/VuiPatch";
2
+ type Props = {
3
+ data: Array<Record<string, unknown>>;
4
+ categoryKey: string;
5
+ valueKey: string;
6
+ childrenKey?: string;
7
+ colors?: PatchColor[];
8
+ height?: number;
9
+ showTooltip?: boolean;
10
+ "data-testid"?: string;
11
+ };
12
+ export declare const VuiTreeMap: ({ data, categoryKey, valueKey, childrenKey, colors, height, showTooltip, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1,51 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { ResponsiveContainer, Tooltip, Treemap } from "recharts";
14
+ import { getChartColor, getChartColorByIndex } from "./palette";
15
+ import { chartTooltipProps } from "./chartTheme";
16
+ // Leaves render as palette-colored cells separated by a stroke; parent blocks
17
+ // render as an outline that delineates the group its children fill.
18
+ const TreeMapCell = ({ x = 0, y = 0, width = 0, height = 0, depth = 0, name = "", fill = "", leafDepth = 1 }) => {
19
+ if (depth === leafDepth) {
20
+ return (_jsxs("g", { children: [_jsx("rect", { x: x, y: y, width: width, height: height, fill: fill, stroke: "var(--vui-color-empty-shade)", strokeWidth: 1.5 }), width > 50 && height > 22 && (_jsx("text", Object.assign({ x: x + 6, y: y + 16, fill: "var(--vui-color-empty-shade)", fontSize: 11, fontWeight: 600 }, { children: name })))] }));
21
+ }
22
+ if (depth >= 1) {
23
+ return _jsx("rect", { x: x, y: y, width: width, height: height, fill: "none", stroke: "var(--vui-color-dark-shade)", strokeWidth: 2 });
24
+ }
25
+ return null;
26
+ };
27
+ export const VuiTreeMap = (_a) => {
28
+ var { data, categoryKey, valueKey, childrenKey, colors, height = 320, showTooltip = true } = _a, rest = __rest(_a, ["data", "categoryKey", "valueKey", "childrenKey", "colors", "height", "showTooltip"]);
29
+ const colorFor = (index) => ((colors === null || colors === void 0 ? void 0 : colors[index]) ? getChartColor(colors[index]) : getChartColorByIndex(index));
30
+ // Build the shape Recharts expects, embedding each node's fill so the content
31
+ // element can color it. Children of a block share the block's hue.
32
+ const treeData = data.map((datum, index) => {
33
+ const color = colorFor(index);
34
+ const name = String(datum[categoryKey]);
35
+ const children = childrenKey ? datum[childrenKey] : undefined;
36
+ if (children) {
37
+ return {
38
+ name,
39
+ fill: color,
40
+ children: children.map((child) => ({
41
+ name: String(child[categoryKey]),
42
+ value: Number(child[valueKey]),
43
+ fill: color
44
+ }))
45
+ };
46
+ }
47
+ return { name, value: Number(datum[valueKey]), fill: color };
48
+ });
49
+ const leafDepth = childrenKey ? 2 : 1;
50
+ return (_jsx("div", Object.assign({ className: "vuiTreeMap" }, rest, { children: _jsx(ResponsiveContainer, Object.assign({ width: "100%", height: height }, { children: _jsx(Treemap, Object.assign({ data: treeData, dataKey: "value", isAnimationActive: false, content: _jsx(TreeMapCell, { leafDepth: leafDepth }) }, { children: showTooltip && _jsx(Tooltip, Object.assign({}, chartTooltipProps)) })) })) })));
51
+ };
@@ -0,0 +1,19 @@
1
+ .vuiBarChart,
2
+ .vuiLineChart,
3
+ .vuiPieChart,
4
+ .vuiScatterChart,
5
+ .vuiComposedChart,
6
+ .vuiTreeMap {
7
+ width: 100%;
8
+
9
+ // Soften Recharts' default legend spacing to match the design system rhythm.
10
+ .recharts-legend-item {
11
+ margin-right: $sizeM !important;
12
+ }
13
+ }
14
+
15
+ // Sparklines render at a fixed size and sit inline beside other content.
16
+ .vuiSparkline {
17
+ display: inline-block;
18
+ line-height: 0;
19
+ }
@@ -0,0 +1,21 @@
1
+ export declare const chartTickStyle: {
2
+ fill: string;
3
+ fontSize: number;
4
+ };
5
+ export declare const chartAxisLineStyle: {
6
+ stroke: string;
7
+ };
8
+ export declare const chartTooltipProps: {
9
+ contentStyle: {
10
+ backgroundColor: string;
11
+ border: string;
12
+ borderRadius: number;
13
+ color: string;
14
+ };
15
+ };
16
+ export declare const chartLegendProps: {
17
+ wrapperStyle: {
18
+ fontSize: number;
19
+ color: string;
20
+ };
21
+ };
@@ -0,0 +1,13 @@
1
+ // Shared styling for chart primitives, wired to theme variables so every chart
2
+ // type renders with the same axes, tooltip, and legend treatment.
3
+ export const chartTickStyle = { fill: "var(--vui-color-label)", fontSize: 12 };
4
+ export const chartAxisLineStyle = { stroke: "var(--vui-color-border-medium)" };
5
+ export const chartTooltipProps = {
6
+ contentStyle: {
7
+ backgroundColor: "var(--vui-color-empty-shade)",
8
+ border: "1px solid var(--vui-color-border-light)",
9
+ borderRadius: 6,
10
+ color: "var(--vui-color-text)"
11
+ }
12
+ };
13
+ export const chartLegendProps = { wrapperStyle: { fontSize: 12, color: "var(--vui-color-label)" } };
@@ -0,0 +1,5 @@
1
+ import { PatchColor } from "../patch/VuiPatch";
2
+ export declare const CHART_COLOR_COUNT = 8;
3
+ export declare const CHART_PALETTE: string[];
4
+ export declare const getChartColorByIndex: (index: number) => string;
5
+ export declare const getChartColor: (color: PatchColor) => string;
@@ -0,0 +1,29 @@
1
+ // The number of distinct colors in the chart palette. Past this many series,
2
+ // no palette stays reliably distinguishable, so callers should group or facet.
3
+ export const CHART_COLOR_COUNT = 8;
4
+ // The ordered chart palette as CSS variable references, so series colors stay
5
+ // reactive to the active theme. These are tuned for series discrimination
6
+ // (hue + luminance contrast, colorblind-safe), distinct from the categorical
7
+ // chip hues. See the chart color tokens in Theme.ts.
8
+ export const CHART_PALETTE = Array.from({ length: CHART_COLOR_COUNT }, (_, index) => `var(--vui-chart-${index + 1})`);
9
+ // When the series count exceeds the palette, each wrap shifts lightness rather
10
+ // than repeating the same color. Lightness is a partially colorblind-safe
11
+ // channel, so a base hue and its darker/lighter variants stay distinguishable.
12
+ // This lets charts degrade gracefully past eight series — though it does not
13
+ // make a chart with that many categories genuinely readable; prefer grouping or
14
+ // a bar chart instead.
15
+ const tierTransforms = [
16
+ (color) => color,
17
+ (color) => `color-mix(in srgb, ${color}, black 22%)`,
18
+ (color) => `color-mix(in srgb, ${color}, white 32%)`
19
+ ];
20
+ // Pick a series color by index. The base hue cycles every CHART_COLOR_COUNT
21
+ // entries; the lightness tier advances on each cycle.
22
+ export const getChartColorByIndex = (index) => {
23
+ const base = CHART_PALETTE[index % CHART_COLOR_COUNT];
24
+ const tier = Math.floor(index / CHART_COLOR_COUNT) % tierTransforms.length;
25
+ return tierTransforms[tier](base);
26
+ };
27
+ // Resolve a categorical hue to its saturated foreground — an escape hatch for
28
+ // series that need a specific brand color rather than the default palette.
29
+ export const getChartColor = (color) => `var(--vui-color-${color}-text)`;
@@ -0,0 +1,41 @@
1
+ export type ComposerSubmission = {
2
+ text: string;
3
+ files: File[];
4
+ };
5
+ export type ComposerFileError = {
6
+ file: File;
7
+ message: string;
8
+ };
9
+ export type ComposerShortcutApi = {
10
+ value: string;
11
+ setValue: (value: string) => void;
12
+ clear: () => void;
13
+ };
14
+ export type ComposerShortcutHandler = (event: React.KeyboardEvent<HTMLTextAreaElement>, composer: ComposerShortcutApi) => void;
15
+ type Props = {
16
+ onSubmit: (submission: ComposerSubmission) => void;
17
+ isRunning?: boolean;
18
+ onCancel?: () => void;
19
+ isSendDisabled?: boolean;
20
+ sendLabel?: string;
21
+ cancelLabel?: string;
22
+ placeholder?: string;
23
+ autoFocus?: boolean;
24
+ onChange?: (value: string) => void;
25
+ value?: string;
26
+ enableHistory?: boolean;
27
+ historyKey?: string;
28
+ canUploadFiles?: boolean;
29
+ accept?: string;
30
+ validateFile?: (file: File) => string | null;
31
+ onFilesRejected?: (errors: ComposerFileError[]) => void;
32
+ fileDropScope?: "document" | "composer";
33
+ fileDropMessage?: React.ReactNode;
34
+ onShortcutKeys?: Record<string, ComposerShortcutHandler>;
35
+ leadingActions?: React.ReactNode;
36
+ footer?: React.ReactNode;
37
+ className?: string;
38
+ "data-testid"?: string;
39
+ };
40
+ export declare const VuiComposer: ({ onSubmit, isRunning, onCancel, isSendDisabled, sendLabel, cancelLabel, placeholder, autoFocus, onChange, value, enableHistory, historyKey, canUploadFiles, accept, validateFile, onFilesRejected, fileDropScope, fileDropMessage, onShortcutKeys, leadingActions, footer, className, "data-testid": dataTestId }: Props) => import("react/jsx-runtime").JSX.Element;
41
+ export {};