@tensor_1/react 2.10.0 → 2.12.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.
- package/README.md +10 -1
- package/dist/ChartCore-Bt1C84ty.d.cts +22 -0
- package/dist/chart-preset.cjs +168 -0
- package/dist/chart-preset.d.cts +9 -0
- package/dist/chart-preset.d.ts +9 -0
- package/dist/chart-preset.js +35 -0
- package/dist/chart.cjs +58 -41
- package/dist/chart.d.cts +6 -21
- package/dist/chart.d.ts +2 -1
- package/dist/components/Alert.js +7 -15
- package/dist/components/AppShell.d.ts +1 -3
- package/dist/components/AppShell.js +1 -3
- package/dist/components/Avatar.js +1 -2
- package/dist/components/Button.js +16 -32
- package/dist/components/Card.d.ts +1 -3
- package/dist/components/Card.js +2 -2
- package/dist/components/Chart.d.ts +6 -21
- package/dist/components/Chart.js +5 -85
- package/dist/components/ChartCore.d.ts +33 -0
- package/dist/components/ChartCore.js +100 -0
- package/dist/components/CommandPalette.d.ts +2 -4
- package/dist/components/CommandPalette.js +13 -66
- package/dist/components/Comments.d.ts +1 -5
- package/dist/components/Comments.js +1 -1
- package/dist/components/Composer.d.ts +1 -8
- package/dist/components/Composer.js +2 -7
- package/dist/components/DetailLayout.js +1 -1
- package/dist/components/Drawer.d.ts +4 -3
- package/dist/components/Drawer.js +4 -6
- package/dist/components/Field.js +3 -6
- package/dist/components/Inbox.d.ts +3 -13
- package/dist/components/Inbox.js +3 -62
- package/dist/components/Input.d.ts +2 -13
- package/dist/components/Input.js +5 -20
- package/dist/components/Kanban.d.ts +3 -15
- package/dist/components/Kanban.js +10 -42
- package/dist/components/Meter.d.ts +1 -3
- package/dist/components/Meter.js +1 -10
- package/dist/components/Modal.d.ts +5 -3
- package/dist/components/Modal.js +4 -6
- package/dist/components/NavFavourites.js +35 -119
- package/dist/components/PageHeader.d.ts +1 -3
- package/dist/components/PageHeader.js +2 -2
- package/dist/components/Peek.d.ts +4 -3
- package/dist/components/Peek.js +6 -9
- package/dist/components/Progress.d.ts +1 -3
- package/dist/components/Progress.js +3 -5
- package/dist/components/Radio.d.ts +1 -3
- package/dist/components/Radio.js +2 -6
- package/dist/components/Segmented.js +3 -2
- package/dist/components/Sidebar.js +2 -4
- package/dist/components/Spinner.d.ts +1 -3
- package/dist/components/Spinner.js +3 -3
- package/dist/components/Stat.js +1 -5
- package/dist/components/States.d.ts +1 -3
- package/dist/components/States.js +2 -8
- package/dist/components/Table.d.ts +2 -9
- package/dist/components/Table.js +8 -11
- package/dist/components/Tabs.d.ts +1 -13
- package/dist/components/Tabs.js +4 -78
- package/dist/components/Timeline.d.ts +3 -3
- package/dist/components/Timeline.js +3 -3
- package/dist/components/Toast.js +5 -42
- package/dist/components/Tooltip.d.ts +1 -3
- package/dist/components/Tooltip.js +5 -44
- package/dist/components/Tree.d.ts +0 -2
- package/dist/components/Tree.js +4 -26
- package/dist/hooks/useDialog.d.ts +1 -1
- package/dist/hooks/useDialog.js +2 -17
- package/dist/hooks/useTable.d.ts +0 -5
- package/dist/hooks/useTable.js +12 -27
- package/dist/hooks/useVirtualRows.d.ts +27 -0
- package/dist/hooks/useVirtualRows.js +50 -0
- package/dist/index.cjs +291 -760
- package/dist/index.d.cts +61 -127
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -3
- package/dist/table-engine.js +8 -6
- package/dist/tree-model.d.ts +0 -4
- package/dist/tree-model.js +0 -8
- package/package.json +16 -2
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Thin React wrappers over the UIx v2 CSS component library — every component is
|
|
|
7
7
|
```sh
|
|
8
8
|
npm i @tensor_1/react @tensor_1/tokens
|
|
9
9
|
```
|
|
10
|
-
Peer deps: `react` / `react-dom` (`^18` or `^19`).
|
|
10
|
+
Peer deps: `react` / `react-dom` (`^18` or `^19`). Install `echarts` only when using a chart entry.
|
|
11
11
|
|
|
12
12
|
## Use
|
|
13
13
|
|
|
@@ -31,4 +31,13 @@ Charts (ECharts) live behind a separate entry so they stay out of the main bundl
|
|
|
31
31
|
import { Chart } from "@tensor_1/react/chart";
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
For common line, bar, and pie charts, the tree-shaken preset avoids shipping the complete ECharts build:
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { Chart } from "@tensor_1/react/chart/preset";
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Large fixed-height tables can use `useVirtualRows(rows, { rowHeight })`; attach its `containerRef` to
|
|
41
|
+
`TableWrap` and render the returned row window between spacer rows.
|
|
42
|
+
|
|
34
43
|
Ships **ESM + CJS + types**, with per-file `"use client"` so it's safe under React Server Components. Part of the **[UIx v2 styleguide](https://github.com/COx-ORG-H/UIx)**.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { EChartsOption, ECharts } from 'echarts';
|
|
3
|
+
|
|
4
|
+
declare function uixChartPalette(): string[];
|
|
5
|
+
interface ChartTableRow {
|
|
6
|
+
[key: string]: string | number;
|
|
7
|
+
}
|
|
8
|
+
interface ChartProps {
|
|
9
|
+
option: EChartsOption;
|
|
10
|
+
title?: string;
|
|
11
|
+
subtitle?: string;
|
|
12
|
+
height?: string | number;
|
|
13
|
+
className?: string;
|
|
14
|
+
style?: CSSProperties;
|
|
15
|
+
ariaLabel?: string;
|
|
16
|
+
tableData?: ChartTableRow[];
|
|
17
|
+
tableHeaders?: string[];
|
|
18
|
+
onReady?: (chart: ECharts) => void;
|
|
19
|
+
header?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { type ChartProps as C, type ChartTableRow as a, uixChartPalette as u };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/chart-preset.tsx
|
|
32
|
+
var chart_preset_exports = {};
|
|
33
|
+
__export(chart_preset_exports, {
|
|
34
|
+
Chart: () => Chart,
|
|
35
|
+
uixChartPalette: () => uixChartPalette
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(chart_preset_exports);
|
|
38
|
+
var echarts = __toESM(require("echarts/core"), 1);
|
|
39
|
+
var import_charts = require("echarts/charts");
|
|
40
|
+
var import_components = require("echarts/components");
|
|
41
|
+
var import_renderers = require("echarts/renderers");
|
|
42
|
+
|
|
43
|
+
// src/components/ChartCore.tsx
|
|
44
|
+
var import_react = require("react");
|
|
45
|
+
|
|
46
|
+
// src/cx.ts
|
|
47
|
+
function cx(...args) {
|
|
48
|
+
return args.filter(Boolean).join(" ");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/components/ChartCore.tsx
|
|
52
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
53
|
+
function readToken(name) {
|
|
54
|
+
if (typeof getComputedStyle === "undefined") return "";
|
|
55
|
+
return getComputedStyle(document.documentElement).getPropertyValue(name).trim();
|
|
56
|
+
}
|
|
57
|
+
function uixChartPalette() {
|
|
58
|
+
return [1, 2, 3, 4, 5, 6, 7, 8].map((i) => readToken(`--uix-chart-${i}`));
|
|
59
|
+
}
|
|
60
|
+
function ChartCore({
|
|
61
|
+
engine,
|
|
62
|
+
option,
|
|
63
|
+
title,
|
|
64
|
+
subtitle,
|
|
65
|
+
height = 280,
|
|
66
|
+
className,
|
|
67
|
+
style,
|
|
68
|
+
ariaLabel,
|
|
69
|
+
tableData,
|
|
70
|
+
tableHeaders,
|
|
71
|
+
onReady,
|
|
72
|
+
header
|
|
73
|
+
}) {
|
|
74
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
75
|
+
const chartRef = (0, import_react.useRef)(null);
|
|
76
|
+
const appliedOptionRef = (0, import_react.useRef)(null);
|
|
77
|
+
const latestOptionRef = (0, import_react.useRef)(option);
|
|
78
|
+
const onReadyRef = (0, import_react.useRef)(onReady);
|
|
79
|
+
const tableId = (0, import_react.useId)();
|
|
80
|
+
latestOptionRef.current = option;
|
|
81
|
+
onReadyRef.current = onReady;
|
|
82
|
+
(0, import_react.useEffect)(() => {
|
|
83
|
+
const element = containerRef.current;
|
|
84
|
+
if (!element) return;
|
|
85
|
+
const chart = engine.init(element, null, { renderer: "svg" });
|
|
86
|
+
chartRef.current = chart;
|
|
87
|
+
chart.setOption(latestOptionRef.current);
|
|
88
|
+
appliedOptionRef.current = latestOptionRef.current;
|
|
89
|
+
onReadyRef.current?.(chart);
|
|
90
|
+
let frame = 0;
|
|
91
|
+
let width = element.clientWidth;
|
|
92
|
+
let height2 = element.clientHeight;
|
|
93
|
+
const observer = new ResizeObserver(() => {
|
|
94
|
+
const nextWidth = element.clientWidth;
|
|
95
|
+
const nextHeight = element.clientHeight;
|
|
96
|
+
if (nextWidth === width && nextHeight === height2) return;
|
|
97
|
+
width = nextWidth;
|
|
98
|
+
height2 = nextHeight;
|
|
99
|
+
if (frame) return;
|
|
100
|
+
frame = requestAnimationFrame(() => {
|
|
101
|
+
frame = 0;
|
|
102
|
+
chart.resize();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
observer.observe(element);
|
|
106
|
+
return () => {
|
|
107
|
+
observer.disconnect();
|
|
108
|
+
if (frame) cancelAnimationFrame(frame);
|
|
109
|
+
chart.dispose();
|
|
110
|
+
chartRef.current = null;
|
|
111
|
+
appliedOptionRef.current = null;
|
|
112
|
+
};
|
|
113
|
+
}, [engine]);
|
|
114
|
+
(0, import_react.useEffect)(() => {
|
|
115
|
+
const chart = chartRef.current;
|
|
116
|
+
if (!chart || appliedOptionRef.current === option) return;
|
|
117
|
+
chart.setOption(option, { notMerge: false });
|
|
118
|
+
appliedOptionRef.current = option;
|
|
119
|
+
}, [option]);
|
|
120
|
+
const heightValue = typeof height === "number" ? `${height}px` : height;
|
|
121
|
+
const effectiveAriaLabel = ariaLabel ?? title ?? "Chart";
|
|
122
|
+
const hasTable = Boolean(tableData?.length && tableHeaders?.length);
|
|
123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: cx("uix-chart", className), style, children: [
|
|
124
|
+
title != null || subtitle != null || header != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
125
|
+
header,
|
|
126
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "uix-chart__title", children: title }) : null,
|
|
127
|
+
subtitle ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "uix-chart__subtitle", children: subtitle }) : null
|
|
128
|
+
] }) : null,
|
|
129
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
130
|
+
"div",
|
|
131
|
+
{
|
|
132
|
+
ref: containerRef,
|
|
133
|
+
style: { height: heightValue },
|
|
134
|
+
role: "img",
|
|
135
|
+
"aria-label": effectiveAriaLabel,
|
|
136
|
+
"aria-describedby": hasTable ? tableId : void 0
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
hasTable ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { id: tableId, className: "sr-only", "aria-label": `${effectiveAriaLabel} \u2014 data table`, children: [
|
|
140
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: tableHeaders.map((label) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { scope: "col", children: label }, label)) }) }),
|
|
141
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: tableData.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: tableHeaders.map((label) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: row[label] }, label)) }, index)) })
|
|
142
|
+
] }) : null
|
|
143
|
+
] });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// src/chart-preset.tsx
|
|
147
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
148
|
+
echarts.use([
|
|
149
|
+
import_charts.BarChart,
|
|
150
|
+
import_charts.LineChart,
|
|
151
|
+
import_charts.PieChart,
|
|
152
|
+
import_components.DatasetComponent,
|
|
153
|
+
import_components.GridComponent,
|
|
154
|
+
import_components.LegendComponent,
|
|
155
|
+
import_components.TitleComponent,
|
|
156
|
+
import_components.TooltipComponent,
|
|
157
|
+
import_components.TransformComponent,
|
|
158
|
+
import_renderers.SVGRenderer
|
|
159
|
+
]);
|
|
160
|
+
var presetEngine = echarts;
|
|
161
|
+
function Chart(props) {
|
|
162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ChartCore, { ...props, engine: presetEngine });
|
|
163
|
+
}
|
|
164
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
165
|
+
0 && (module.exports = {
|
|
166
|
+
Chart,
|
|
167
|
+
uixChartPalette
|
|
168
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { C as ChartProps } from './ChartCore-Bt1C84ty.cjs';
|
|
3
|
+
export { a as ChartTableRow, u as uixChartPalette } from './ChartCore-Bt1C84ty.cjs';
|
|
4
|
+
import 'echarts';
|
|
5
|
+
|
|
6
|
+
/** Lean SVG adapter: line, bar, pie, dataset, grid, legend, title, and tooltip. */
|
|
7
|
+
declare function Chart(props: ChartProps): react.JSX.Element;
|
|
8
|
+
|
|
9
|
+
export { Chart, ChartProps };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ChartProps } from './components/ChartCore.js';
|
|
3
|
+
export { ChartTableRow, uixChartPalette } from './components/ChartCore.js';
|
|
4
|
+
import 'echarts';
|
|
5
|
+
|
|
6
|
+
/** Lean SVG adapter: line, bar, pie, dataset, grid, legend, title, and tooltip. */
|
|
7
|
+
declare function Chart(props: ChartProps): react.JSX.Element;
|
|
8
|
+
|
|
9
|
+
export { Chart, ChartProps };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as echarts from "echarts/core";
|
|
4
|
+
import { BarChart, LineChart, PieChart } from "echarts/charts";
|
|
5
|
+
import {
|
|
6
|
+
DatasetComponent,
|
|
7
|
+
GridComponent,
|
|
8
|
+
LegendComponent,
|
|
9
|
+
TitleComponent,
|
|
10
|
+
TooltipComponent,
|
|
11
|
+
TransformComponent
|
|
12
|
+
} from "echarts/components";
|
|
13
|
+
import { SVGRenderer } from "echarts/renderers";
|
|
14
|
+
import { ChartCore } from "./components/ChartCore.js";
|
|
15
|
+
echarts.use([
|
|
16
|
+
BarChart,
|
|
17
|
+
LineChart,
|
|
18
|
+
PieChart,
|
|
19
|
+
DatasetComponent,
|
|
20
|
+
GridComponent,
|
|
21
|
+
LegendComponent,
|
|
22
|
+
TitleComponent,
|
|
23
|
+
TooltipComponent,
|
|
24
|
+
TransformComponent,
|
|
25
|
+
SVGRenderer
|
|
26
|
+
]);
|
|
27
|
+
const presetEngine = echarts;
|
|
28
|
+
function Chart(props) {
|
|
29
|
+
return /* @__PURE__ */ jsx(ChartCore, { ...props, engine: presetEngine });
|
|
30
|
+
}
|
|
31
|
+
import { uixChartPalette } from "./components/ChartCore.js";
|
|
32
|
+
export {
|
|
33
|
+
Chart,
|
|
34
|
+
uixChartPalette
|
|
35
|
+
};
|
package/dist/chart.cjs
CHANGED
|
@@ -36,15 +36,17 @@ __export(chart_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(chart_exports);
|
|
37
37
|
|
|
38
38
|
// src/components/Chart.tsx
|
|
39
|
-
var import_react = require("react");
|
|
40
39
|
var echarts = __toESM(require("echarts"), 1);
|
|
41
40
|
|
|
41
|
+
// src/components/ChartCore.tsx
|
|
42
|
+
var import_react = require("react");
|
|
43
|
+
|
|
42
44
|
// src/cx.ts
|
|
43
45
|
function cx(...args) {
|
|
44
46
|
return args.filter(Boolean).join(" ");
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
// src/components/
|
|
49
|
+
// src/components/ChartCore.tsx
|
|
48
50
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
49
51
|
function readToken(name) {
|
|
50
52
|
if (typeof getComputedStyle === "undefined") return "";
|
|
@@ -53,13 +55,8 @@ function readToken(name) {
|
|
|
53
55
|
function uixChartPalette() {
|
|
54
56
|
return [1, 2, 3, 4, 5, 6, 7, 8].map((i) => readToken(`--uix-chart-${i}`));
|
|
55
57
|
}
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
return { ...option, animation: false };
|
|
59
|
-
}
|
|
60
|
-
return option;
|
|
61
|
-
}
|
|
62
|
-
function Chart({
|
|
58
|
+
function ChartCore({
|
|
59
|
+
engine,
|
|
63
60
|
option,
|
|
64
61
|
title,
|
|
65
62
|
subtitle,
|
|
@@ -74,61 +71,81 @@ function Chart({
|
|
|
74
71
|
}) {
|
|
75
72
|
const containerRef = (0, import_react.useRef)(null);
|
|
76
73
|
const chartRef = (0, import_react.useRef)(null);
|
|
74
|
+
const appliedOptionRef = (0, import_react.useRef)(null);
|
|
75
|
+
const latestOptionRef = (0, import_react.useRef)(option);
|
|
76
|
+
const onReadyRef = (0, import_react.useRef)(onReady);
|
|
77
77
|
const tableId = (0, import_react.useId)();
|
|
78
|
+
latestOptionRef.current = option;
|
|
79
|
+
onReadyRef.current = onReady;
|
|
78
80
|
(0, import_react.useEffect)(() => {
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
const chart =
|
|
81
|
+
const element = containerRef.current;
|
|
82
|
+
if (!element) return;
|
|
83
|
+
const chart = engine.init(element, null, { renderer: "svg" });
|
|
82
84
|
chartRef.current = chart;
|
|
83
|
-
chart.setOption(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
chart.setOption(latestOptionRef.current);
|
|
86
|
+
appliedOptionRef.current = latestOptionRef.current;
|
|
87
|
+
onReadyRef.current?.(chart);
|
|
88
|
+
let frame = 0;
|
|
89
|
+
let width = element.clientWidth;
|
|
90
|
+
let height2 = element.clientHeight;
|
|
91
|
+
const observer = new ResizeObserver(() => {
|
|
92
|
+
const nextWidth = element.clientWidth;
|
|
93
|
+
const nextHeight = element.clientHeight;
|
|
94
|
+
if (nextWidth === width && nextHeight === height2) return;
|
|
95
|
+
width = nextWidth;
|
|
96
|
+
height2 = nextHeight;
|
|
97
|
+
if (frame) return;
|
|
98
|
+
frame = requestAnimationFrame(() => {
|
|
99
|
+
frame = 0;
|
|
100
|
+
chart.resize();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
observer.observe(element);
|
|
90
104
|
return () => {
|
|
91
|
-
|
|
105
|
+
observer.disconnect();
|
|
106
|
+
if (frame) cancelAnimationFrame(frame);
|
|
92
107
|
chart.dispose();
|
|
93
108
|
chartRef.current = null;
|
|
109
|
+
appliedOptionRef.current = null;
|
|
94
110
|
};
|
|
95
|
-
}, []);
|
|
111
|
+
}, [engine]);
|
|
96
112
|
(0, import_react.useEffect)(() => {
|
|
97
|
-
chartRef.current
|
|
113
|
+
const chart = chartRef.current;
|
|
114
|
+
if (!chart || appliedOptionRef.current === option) return;
|
|
115
|
+
chart.setOption(option, { notMerge: false });
|
|
116
|
+
appliedOptionRef.current = option;
|
|
98
117
|
}, [option]);
|
|
99
|
-
const
|
|
118
|
+
const heightValue = typeof height === "number" ? `${height}px` : height;
|
|
100
119
|
const effectiveAriaLabel = ariaLabel ?? title ?? "Chart";
|
|
101
|
-
const hasTable = tableData
|
|
120
|
+
const hasTable = Boolean(tableData?.length && tableHeaders?.length);
|
|
102
121
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: cx("uix-chart", className), style, children: [
|
|
103
|
-
|
|
122
|
+
title != null || subtitle != null || header != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
104
123
|
header,
|
|
105
|
-
title
|
|
106
|
-
subtitle
|
|
107
|
-
] }),
|
|
124
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "uix-chart__title", children: title }) : null,
|
|
125
|
+
subtitle ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "uix-chart__subtitle", children: subtitle }) : null
|
|
126
|
+
] }) : null,
|
|
108
127
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
109
128
|
"div",
|
|
110
129
|
{
|
|
111
130
|
ref: containerRef,
|
|
112
|
-
style: { height:
|
|
131
|
+
style: { height: heightValue },
|
|
113
132
|
role: "img",
|
|
114
133
|
"aria-label": effectiveAriaLabel,
|
|
115
134
|
"aria-describedby": hasTable ? tableId : void 0
|
|
116
135
|
}
|
|
117
136
|
),
|
|
118
|
-
hasTable
|
|
119
|
-
"
|
|
120
|
-
{
|
|
121
|
-
|
|
122
|
-
className: "uix-visually-hidden",
|
|
123
|
-
"aria-label": `${effectiveAriaLabel} \u2014 data table`,
|
|
124
|
-
children: [
|
|
125
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: tableHeaders.map((h) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { scope: "col", children: h }, h)) }) }),
|
|
126
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: tableData.map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: tableHeaders.map((h) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: row[h] }, h)) }, i)) })
|
|
127
|
-
]
|
|
128
|
-
}
|
|
129
|
-
)
|
|
137
|
+
hasTable ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { id: tableId, className: "sr-only", "aria-label": `${effectiveAriaLabel} \u2014 data table`, children: [
|
|
138
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: tableHeaders.map((label) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { scope: "col", children: label }, label)) }) }),
|
|
139
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: tableData.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: tableHeaders.map((label) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: row[label] }, label)) }, index)) })
|
|
140
|
+
] }) : null
|
|
130
141
|
] });
|
|
131
142
|
}
|
|
143
|
+
|
|
144
|
+
// src/components/Chart.tsx
|
|
145
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
146
|
+
function Chart(props) {
|
|
147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ChartCore, { ...props, engine: echarts });
|
|
148
|
+
}
|
|
132
149
|
// Annotate the CommonJS export names for ESM import in node:
|
|
133
150
|
0 && (module.exports = {
|
|
134
151
|
Chart,
|
package/dist/chart.d.cts
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { C as ChartProps } from './ChartCore-Bt1C84ty.cjs';
|
|
3
|
+
export { a as ChartTableRow, u as uixChartPalette } from './ChartCore-Bt1C84ty.cjs';
|
|
4
|
+
import 'echarts';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[key: string]: string | number;
|
|
8
|
-
}
|
|
9
|
-
interface ChartProps {
|
|
10
|
-
option: EChartsOption;
|
|
11
|
-
title?: string;
|
|
12
|
-
subtitle?: string;
|
|
13
|
-
height?: string | number;
|
|
14
|
-
className?: string;
|
|
15
|
-
style?: CSSProperties;
|
|
16
|
-
ariaLabel?: string;
|
|
17
|
-
tableData?: ChartTableRow[];
|
|
18
|
-
tableHeaders?: string[];
|
|
19
|
-
onReady?: (chart: ECharts) => void;
|
|
20
|
-
header?: ReactNode;
|
|
21
|
-
}
|
|
22
|
-
declare function Chart({ option, title, subtitle, height, className, style, ariaLabel, tableData, tableHeaders, onReady, header, }: ChartProps): react.JSX.Element;
|
|
6
|
+
/** Full-compatibility adapter. Use `@tensor_1/react/chart/preset` for the lean preset. */
|
|
7
|
+
declare function Chart(props: ChartProps): react.JSX.Element;
|
|
23
8
|
|
|
24
|
-
export { Chart,
|
|
9
|
+
export { Chart, ChartProps };
|
package/dist/chart.d.ts
CHANGED
package/dist/components/Alert.js
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cx } from "../cx.js";
|
|
3
3
|
function Alert({ tone, title, icon, children, className, ...props }) {
|
|
4
|
-
return /* @__PURE__ */ jsxs(
|
|
5
|
-
"div",
|
|
6
|
-
{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
icon && /* @__PURE__ */ jsx("div", { className: "uix-alert__icon", children: icon }),
|
|
12
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
13
|
-
title && /* @__PURE__ */ jsx("div", { className: "uix-alert__title", children: title }),
|
|
14
|
-
children && /* @__PURE__ */ jsx("div", { className: "uix-alert__body", children })
|
|
15
|
-
] })
|
|
16
|
-
]
|
|
17
|
-
}
|
|
18
|
-
);
|
|
4
|
+
return /* @__PURE__ */ jsxs("div", { className: cx("uix-alert", tone && tone !== "neutral" && `uix-alert--${tone}`, className), ...props, children: [
|
|
5
|
+
icon && /* @__PURE__ */ jsx("div", { className: "uix-alert__icon", children: icon }),
|
|
6
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
7
|
+
title && /* @__PURE__ */ jsx("div", { className: "uix-alert__title", children: title }),
|
|
8
|
+
children && /* @__PURE__ */ jsx("div", { className: "uix-alert__body", children })
|
|
9
|
+
] })
|
|
10
|
+
] });
|
|
19
11
|
}
|
|
20
12
|
export {
|
|
21
13
|
Alert
|
|
@@ -17,12 +17,10 @@ interface AppShellProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
17
17
|
onExitFocus?: () => void;
|
|
18
18
|
/** Drop the content gutter so a genuinely wide table runs edge-to-edge. */
|
|
19
19
|
mainBleed?: boolean;
|
|
20
|
-
/** id given to `<main>` and targeted by the skip link. Override on collision (UIX-A11Y-2). */
|
|
21
|
-
mainId?: string;
|
|
22
20
|
sidebar?: ReactNode;
|
|
23
21
|
topbar?: ReactNode;
|
|
24
22
|
children?: ReactNode;
|
|
25
23
|
}
|
|
26
|
-
declare function AppShell({ nav, collapsed, focus, onExitFocus, mainBleed,
|
|
24
|
+
declare function AppShell({ nav, collapsed, focus, onExitFocus, mainBleed, sidebar, topbar, children, className, ...props }: AppShellProps): react.JSX.Element;
|
|
27
25
|
|
|
28
26
|
export { AppShell, type AppShellProps, type ShellNav };
|
|
@@ -8,7 +8,6 @@ function AppShell({
|
|
|
8
8
|
focus,
|
|
9
9
|
onExitFocus,
|
|
10
10
|
mainBleed,
|
|
11
|
-
mainId = "uix-main",
|
|
12
11
|
sidebar,
|
|
13
12
|
topbar,
|
|
14
13
|
children,
|
|
@@ -33,10 +32,9 @@ function AppShell({
|
|
|
33
32
|
"data-focus": focus || void 0,
|
|
34
33
|
...props,
|
|
35
34
|
children: [
|
|
36
|
-
/* @__PURE__ */ jsx("a", { className: "uix-skiplink", href: `#${mainId}`, children: "Skip to content" }),
|
|
37
35
|
sidebar && /* @__PURE__ */ jsx("div", { className: "uix-shell__sidebar", children: sidebar }),
|
|
38
36
|
topbar && /* @__PURE__ */ jsx("div", { className: "uix-shell__topbar", children: topbar }),
|
|
39
|
-
/* @__PURE__ */ jsx("main", {
|
|
37
|
+
/* @__PURE__ */ jsx("main", { className: cx("uix-shell__main", mainBleed && "uix-shell__main--bleed"), children }),
|
|
40
38
|
focus && onExitFocus && /* @__PURE__ */ jsx("div", { className: "uix-shell__focus-exit", children: /* @__PURE__ */ jsx("button", { type: "button", className: "uix-btn uix-btn--secondary uix-btn--sm", onClick: onExitFocus, children: "Esc \xB7 Exit focus" }) })
|
|
41
39
|
]
|
|
42
40
|
}
|
|
@@ -3,8 +3,7 @@ import { cx } from "../cx.js";
|
|
|
3
3
|
function Avatar({ size = "md", src, alt, children, status, className, ...props }) {
|
|
4
4
|
return /* @__PURE__ */ jsxs("span", { className: cx("uix-avatar", size !== "md" && `uix-avatar--${size}`, className), ...props, children: [
|
|
5
5
|
src ? /* @__PURE__ */ jsx("img", { src, alt: alt ?? "" }) : children,
|
|
6
|
-
status && /* @__PURE__ */ jsx("span", { className: "uix-avatar__status"
|
|
7
|
-
status && /* @__PURE__ */ jsx("span", { className: "uix-visually-hidden", children: "online" })
|
|
6
|
+
status && /* @__PURE__ */ jsx("span", { className: "uix-avatar__status" })
|
|
8
7
|
] });
|
|
9
8
|
}
|
|
10
9
|
function AvatarGroup({ children, className, ...props }) {
|
|
@@ -1,40 +1,24 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { cx } from "../cx.js";
|
|
4
|
-
let warnedIconButton = false;
|
|
5
4
|
const Button = forwardRef(
|
|
6
|
-
({ variant = "secondary", size = "md", icon = false, loading = false, className, children, disabled,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
({ variant = "secondary", size = "md", icon = false, loading = false, className, children, disabled, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
6
|
+
"button",
|
|
7
|
+
{
|
|
8
|
+
ref,
|
|
9
|
+
className: cx(
|
|
10
|
+
"uix-btn",
|
|
11
|
+
`uix-btn--${variant}`,
|
|
12
|
+
size !== "md" && `uix-btn--${size}`,
|
|
13
|
+
icon && "uix-btn--icon",
|
|
14
|
+
className
|
|
15
|
+
),
|
|
16
|
+
disabled: disabled || loading,
|
|
17
|
+
"data-loading": loading || void 0,
|
|
18
|
+
...props,
|
|
19
|
+
children
|
|
10
20
|
}
|
|
11
|
-
|
|
12
|
-
"button",
|
|
13
|
-
{
|
|
14
|
-
ref,
|
|
15
|
-
className: cx(
|
|
16
|
-
"uix-btn",
|
|
17
|
-
`uix-btn--${variant}`,
|
|
18
|
-
size !== "md" && `uix-btn--${size}`,
|
|
19
|
-
icon && "uix-btn--icon",
|
|
20
|
-
className
|
|
21
|
-
),
|
|
22
|
-
disabled,
|
|
23
|
-
"aria-disabled": loading || void 0,
|
|
24
|
-
"aria-busy": loading || void 0,
|
|
25
|
-
"data-loading": loading || void 0,
|
|
26
|
-
onClick: loading || onClick ? (e) => {
|
|
27
|
-
if (loading) {
|
|
28
|
-
e.preventDefault();
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
onClick?.(e);
|
|
32
|
-
} : void 0,
|
|
33
|
-
...props,
|
|
34
|
-
children
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
}
|
|
21
|
+
)
|
|
38
22
|
);
|
|
39
23
|
Button.displayName = "Button";
|
|
40
24
|
function ButtonGroup({ children, className }) {
|
|
@@ -3,13 +3,11 @@ import { HTMLAttributes, ReactNode } from 'react';
|
|
|
3
3
|
|
|
4
4
|
interface CardProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
5
5
|
title?: ReactNode;
|
|
6
|
-
/** Element for the title — pick a real heading to slot the card into the page outline (UIX-A11Y-4). Default `div` keeps legacy rendering. */
|
|
7
|
-
titleAs?: 'h2' | 'h3' | 'h4' | 'div';
|
|
8
6
|
subtitle?: ReactNode;
|
|
9
7
|
headerAction?: ReactNode;
|
|
10
8
|
footer?: ReactNode;
|
|
11
9
|
children?: ReactNode;
|
|
12
10
|
}
|
|
13
|
-
declare function Card({ title,
|
|
11
|
+
declare function Card({ title, subtitle, headerAction, footer, children, className, ...props }: CardProps): react.JSX.Element;
|
|
14
12
|
|
|
15
13
|
export { Card, type CardProps };
|
package/dist/components/Card.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cx } from "../cx.js";
|
|
3
|
-
function Card({ title,
|
|
3
|
+
function Card({ title, subtitle, headerAction, footer, children, className, ...props }) {
|
|
4
4
|
const hasHeader = title != null || subtitle != null || headerAction != null;
|
|
5
5
|
return /* @__PURE__ */ jsxs("div", { className: cx("uix-card", className), ...props, children: [
|
|
6
6
|
hasHeader && /* @__PURE__ */ jsxs("div", { className: "uix-card__header", children: [
|
|
7
7
|
/* @__PURE__ */ jsxs("div", { style: { flex: 1 }, children: [
|
|
8
|
-
title && /* @__PURE__ */ jsx(
|
|
8
|
+
title && /* @__PURE__ */ jsx("div", { className: "uix-card__title", children: title }),
|
|
9
9
|
subtitle && /* @__PURE__ */ jsx("div", { className: "uix-card__subtitle", children: subtitle })
|
|
10
10
|
] }),
|
|
11
11
|
headerAction
|
|
@@ -1,24 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { ChartProps } from './ChartCore.js';
|
|
3
|
+
export { ChartTableRow, uixChartPalette } from './ChartCore.js';
|
|
4
|
+
import 'echarts';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[key: string]: string | number;
|
|
8
|
-
}
|
|
9
|
-
interface ChartProps {
|
|
10
|
-
option: EChartsOption;
|
|
11
|
-
title?: string;
|
|
12
|
-
subtitle?: string;
|
|
13
|
-
height?: string | number;
|
|
14
|
-
className?: string;
|
|
15
|
-
style?: CSSProperties;
|
|
16
|
-
ariaLabel?: string;
|
|
17
|
-
tableData?: ChartTableRow[];
|
|
18
|
-
tableHeaders?: string[];
|
|
19
|
-
onReady?: (chart: ECharts) => void;
|
|
20
|
-
header?: ReactNode;
|
|
21
|
-
}
|
|
22
|
-
declare function Chart({ option, title, subtitle, height, className, style, ariaLabel, tableData, tableHeaders, onReady, header, }: ChartProps): react.JSX.Element;
|
|
6
|
+
/** Full-compatibility adapter. Use `@tensor_1/react/chart/preset` for the lean preset. */
|
|
7
|
+
declare function Chart(props: ChartProps): react.JSX.Element;
|
|
23
8
|
|
|
24
|
-
export { Chart,
|
|
9
|
+
export { Chart, ChartProps };
|