@canvas-components/react-pivot-table 0.2.2 → 0.2.4
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/dist/index.cjs +45 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +46 -16
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -370,7 +370,7 @@ function PivotFieldPanel(props) {
|
|
|
370
370
|
}
|
|
371
371
|
)
|
|
372
372
|
] }),
|
|
373
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "react-pivot-field-panel__field-list", children: [
|
|
373
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "react-pivot-field-panel__field-list canvas-react-scrollbar", children: [
|
|
374
374
|
visibleFields.map((field) => {
|
|
375
375
|
const fieldKey = pivotTable.resolvePivotDimensionKey(field);
|
|
376
376
|
const area = pivotTable.findPivotFieldArea(props.layout, fieldKey);
|
|
@@ -497,7 +497,7 @@ function FieldArea(props) {
|
|
|
497
497
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
498
498
|
"div",
|
|
499
499
|
{
|
|
500
|
-
className: "react-pivot-field-panel__area",
|
|
500
|
+
className: "react-pivot-field-panel__area canvas-react-scrollbar",
|
|
501
501
|
"data-dragging": props.dragging || void 0,
|
|
502
502
|
onDragOver: (event) => event.preventDefault(),
|
|
503
503
|
onDragEnter: props.onDragEnter,
|
|
@@ -1177,19 +1177,26 @@ function SettingsIcon() {
|
|
|
1177
1177
|
// src/features/chart/pivot-chart-panel.css
|
|
1178
1178
|
styleInject('.react-pivot-chart-panel {\n display: flex;\n width: 100%;\n min-width: 0;\n height: 100%;\n min-height: 0;\n flex-direction: column;\n gap: 8px;\n padding: 0;\n overflow: auto;\n background: #fff;\n box-sizing: border-box;\n}\n.react-pivot-chart-card {\n display: flex;\n min-width: 0;\n min-height: 240px;\n flex: 0 0 260px;\n flex-direction: column;\n overflow: hidden;\n border-radius: 0;\n background: #fff;\n box-sizing: border-box;\n}\n.react-pivot-chart-card:only-child {\n min-height: 240px;\n flex: 1 1 auto;\n}\n.react-pivot-chart-card__header {\n display: flex;\n height: 42px;\n flex: 0 0 42px;\n align-items: center;\n justify-content: space-between;\n padding: 0 10px 0 14px;\n border-bottom: 1px solid #edf0f2;\n color: #1f2329;\n font-size: 13px;\n box-sizing: border-box;\n}\n.react-pivot-chart-card__remove {\n display: inline-flex;\n width: 24px;\n height: 24px;\n align-items: center;\n justify-content: center;\n padding: 0;\n border: 0;\n background: transparent;\n color: #646a73;\n cursor: pointer;\n font: 18px/24px "Segoe UI", sans-serif;\n}\n.react-pivot-chart-card__remove:hover {\n background: #f2f3f5;\n color: #d14343;\n}\n.react-pivot-chart-card__canvas {\n min-width: 0;\n min-height: 0;\n flex: 1 1 auto;\n}\n.react-pivot-chart-card__empty {\n display: grid;\n min-height: 0;\n flex: 1 1 auto;\n place-items: center;\n color: #8f959e;\n font-size: 12px;\n}\n');
|
|
1179
1179
|
function PivotChartPanel(props) {
|
|
1180
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1181
|
-
|
|
1180
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1181
|
+
"section",
|
|
1182
1182
|
{
|
|
1183
|
-
chart,
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1183
|
+
className: "react-pivot-chart-panel canvas-react-scrollbar",
|
|
1184
|
+
"aria-label": "\u900F\u89C6\u56FE\u8868",
|
|
1185
|
+
children: props.charts.map((chart, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1186
|
+
PivotChartCard,
|
|
1187
|
+
{
|
|
1188
|
+
chart,
|
|
1189
|
+
index,
|
|
1190
|
+
model: props.model,
|
|
1191
|
+
rows: props.rows,
|
|
1192
|
+
columns: props.columns,
|
|
1193
|
+
indicators: props.indicators,
|
|
1194
|
+
onRemove: props.onRemove
|
|
1195
|
+
},
|
|
1196
|
+
chart.id
|
|
1197
|
+
))
|
|
1198
|
+
}
|
|
1199
|
+
);
|
|
1193
1200
|
}
|
|
1194
1201
|
function PivotChartCard(props) {
|
|
1195
1202
|
const option = react.useMemo(
|
|
@@ -1261,6 +1268,7 @@ function ReactPivotTableInner(props, ref) {
|
|
|
1261
1268
|
null
|
|
1262
1269
|
);
|
|
1263
1270
|
const chartIdRef = react.useRef(0);
|
|
1271
|
+
const layoutRevisionRef = react.useRef(0);
|
|
1264
1272
|
const [internalLayout, setInternalLayout] = react.useState(
|
|
1265
1273
|
() => customizationOptions?.defaultLayout ?? pivotTable.createEmptyPivotFieldLayout()
|
|
1266
1274
|
);
|
|
@@ -1366,7 +1374,13 @@ function ReactPivotTableInner(props, ref) {
|
|
|
1366
1374
|
setCharts((current) => current.filter((chart) => chart.id !== chartId));
|
|
1367
1375
|
};
|
|
1368
1376
|
const applyLayout = (next) => {
|
|
1369
|
-
if (customizationOptions?.layout === void 0)
|
|
1377
|
+
if (customizationOptions?.layout === void 0) {
|
|
1378
|
+
layoutRevisionRef.current += 1;
|
|
1379
|
+
setInternalLayout(next);
|
|
1380
|
+
if (customizationOptions?.storageKey) {
|
|
1381
|
+
void pivotTable.savePivotFieldLayout(customizationOptions.storageKey, next);
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1370
1384
|
customizationOptions?.onLayoutChange?.(next);
|
|
1371
1385
|
};
|
|
1372
1386
|
const moveField = (fieldKey, area, index, sourceArea) => {
|
|
@@ -1414,6 +1428,22 @@ function ReactPivotTableInner(props, ref) {
|
|
|
1414
1428
|
table.updateOptions(options);
|
|
1415
1429
|
refreshChartModel();
|
|
1416
1430
|
}, [options]);
|
|
1431
|
+
react.useEffect(() => {
|
|
1432
|
+
const storageKey = customizationOptions?.storageKey;
|
|
1433
|
+
if (!storageKey || customizationOptions?.layout !== void 0) return;
|
|
1434
|
+
let active = true;
|
|
1435
|
+
const revision = layoutRevisionRef.current;
|
|
1436
|
+
void pivotTable.loadPivotFieldLayout(storageKey).then((storedLayout) => {
|
|
1437
|
+
if (!active || !storedLayout || layoutRevisionRef.current !== revision) {
|
|
1438
|
+
return;
|
|
1439
|
+
}
|
|
1440
|
+
setInternalLayout(storedLayout);
|
|
1441
|
+
customizationOptions?.onLayoutChange?.(storedLayout);
|
|
1442
|
+
});
|
|
1443
|
+
return () => {
|
|
1444
|
+
active = false;
|
|
1445
|
+
};
|
|
1446
|
+
}, [customizationOptions?.layout, customizationOptions?.storageKey]);
|
|
1417
1447
|
react.useEffect(() => {
|
|
1418
1448
|
if (customizationOptions?.panelWidth != null) {
|
|
1419
1449
|
setFieldPanelWidth(customizationOptions.panelWidth);
|