@canvas-components/react-pivot-table 0.2.3 → 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 +24 -1
- 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 +25 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1268,6 +1268,7 @@ function ReactPivotTableInner(props, ref) {
|
|
|
1268
1268
|
null
|
|
1269
1269
|
);
|
|
1270
1270
|
const chartIdRef = react.useRef(0);
|
|
1271
|
+
const layoutRevisionRef = react.useRef(0);
|
|
1271
1272
|
const [internalLayout, setInternalLayout] = react.useState(
|
|
1272
1273
|
() => customizationOptions?.defaultLayout ?? pivotTable.createEmptyPivotFieldLayout()
|
|
1273
1274
|
);
|
|
@@ -1373,7 +1374,13 @@ function ReactPivotTableInner(props, ref) {
|
|
|
1373
1374
|
setCharts((current) => current.filter((chart) => chart.id !== chartId));
|
|
1374
1375
|
};
|
|
1375
1376
|
const applyLayout = (next) => {
|
|
1376
|
-
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
|
+
}
|
|
1377
1384
|
customizationOptions?.onLayoutChange?.(next);
|
|
1378
1385
|
};
|
|
1379
1386
|
const moveField = (fieldKey, area, index, sourceArea) => {
|
|
@@ -1421,6 +1428,22 @@ function ReactPivotTableInner(props, ref) {
|
|
|
1421
1428
|
table.updateOptions(options);
|
|
1422
1429
|
refreshChartModel();
|
|
1423
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]);
|
|
1424
1447
|
react.useEffect(() => {
|
|
1425
1448
|
if (customizationOptions?.panelWidth != null) {
|
|
1426
1449
|
setFieldPanelWidth(customizationOptions.panelWidth);
|