pivotkit-react 0.4.0 → 0.5.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/CHANGELOG.md +219 -1
- package/README.md +2 -2
- package/dist/chunks/{chunk-YITKWZ4L.js → chunk-2AT72SLA.js} +604 -505
- package/dist/chunks/{chunk-ZYEYZSYL.js → chunk-3E4NB5RZ.js} +30 -2
- package/dist/chunks/{chunk-6MDAL3IO.js → chunk-3WUGQPWV.js} +78 -6
- package/dist/chunks/{chunk-WB4GKWFQ.js → chunk-4RS72AAA.js} +26 -4
- package/dist/chunks/{chunk-EM23V5GH.js → chunk-E6M57YLL.js} +19 -8
- package/dist/chunks/{chunk-RWYHJRQO.js → chunk-JMRTIOX4.js} +17 -7
- package/dist/chunks/{chunk-XN55BQ4M.js → chunk-RIOSIYGC.js} +54 -7
- package/dist/chunks/{chunk-LEN5RPBM.js → chunk-U5Q5I2D5.js} +34 -5
- package/dist/chunks/report-run-BZBFOMPF.js +12 -0
- package/dist/chunks/{unused-texts-K3VFH65P.js → unused-texts-Y4R67XSN.js} +1 -1
- package/dist/chunks/{unused-texts-de-OW4TGIVX.js → unused-texts-de-6YVPTNVS.js} +1 -1
- package/dist/echarts.js +38 -156
- package/dist/import-ui.js +8 -12
- package/dist/index.js +97 -82
- package/dist/labels.js +6 -6
- package/dist/menu-texts-de.js +1 -1
- package/dist/menus.js +650 -245
- package/dist/styles.css +207 -93
- package/package.json +8 -4
- package/types/chart-decorate.d.ts +28 -4
- package/types/chart-types.d.ts +2 -4
- package/types/echarts.d.ts +1 -1
- package/types/export-run.d.ts +37 -3
- package/types/filter.d.ts +1 -1
- package/types/icons.d.ts +1 -0
- package/types/import-labels.d.ts +41 -0
- package/types/import-limits.d.ts +6 -0
- package/types/index.d.ts +25 -7
- package/types/labels.d.ts +198 -2
- package/types/light-tokens.d.ts +16 -0
- package/types/menu-labels.d.ts +37 -14
- package/types/menu-ops.d.ts +161 -40
- package/types/menu-topics.d.ts +7 -4
- package/types/names.d.ts +47 -19
- package/types/place.d.ts +24 -0
- package/types/print-frame.d.ts +24 -0
- package/types/report-run.d.ts +14 -0
- package/types/share-actions.d.ts +3 -3
- package/types/share.d.ts +13 -17
- package/types/theme.d.ts +2 -16
- package/types/tips.d.ts +5 -0
- package/types/toolbar-panels.d.ts +5 -4
- package/types/unused-texts.d.ts +13 -3
- package/types/use-export.d.ts +2 -2
- package/types/view-ops.d.ts +65 -6
- package/types/chart-layout.d.ts +0 -111
package/dist/index.js
CHANGED
|
@@ -27,12 +27,12 @@ import {
|
|
|
27
27
|
headerSortTarget,
|
|
28
28
|
helpSwitch,
|
|
29
29
|
importNow,
|
|
30
|
+
isEmptyPick,
|
|
30
31
|
isEmptyView,
|
|
31
32
|
itemRuleText,
|
|
32
33
|
keptOnReset,
|
|
33
34
|
layoutSummary,
|
|
34
35
|
linkNow,
|
|
35
|
-
linkParam,
|
|
36
36
|
loadCheck,
|
|
37
37
|
loadImport,
|
|
38
38
|
loadLink,
|
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
refLabel,
|
|
49
49
|
removeAt,
|
|
50
50
|
rowFolding,
|
|
51
|
+
same,
|
|
51
52
|
selectedItems,
|
|
52
53
|
setChart,
|
|
53
54
|
setChartDisplay,
|
|
@@ -75,7 +76,7 @@ import {
|
|
|
75
76
|
writeItem,
|
|
76
77
|
writeStoredView,
|
|
77
78
|
zoneOverLimit
|
|
78
|
-
} from "./chunks/chunk-
|
|
79
|
+
} from "./chunks/chunk-2AT72SLA.js";
|
|
79
80
|
import {
|
|
80
81
|
FormNameContext,
|
|
81
82
|
Group,
|
|
@@ -91,7 +92,7 @@ import {
|
|
|
91
92
|
tabStops,
|
|
92
93
|
useIsoLayoutEffect,
|
|
93
94
|
useModal
|
|
94
|
-
} from "./chunks/chunk-
|
|
95
|
+
} from "./chunks/chunk-RIOSIYGC.js";
|
|
95
96
|
import {
|
|
96
97
|
MENU_TEXTS,
|
|
97
98
|
errorText,
|
|
@@ -100,7 +101,7 @@ import {
|
|
|
100
101
|
messageOf,
|
|
101
102
|
plural,
|
|
102
103
|
resolveLabels
|
|
103
|
-
} from "./chunks/chunk-
|
|
104
|
+
} from "./chunks/chunk-3WUGQPWV.js";
|
|
104
105
|
|
|
105
106
|
// src/PivotReport.jsx
|
|
106
107
|
import React12, { useCallback as useCallback9, useEffect as useEffect11, useId as useId4, useMemo as useMemo8, useRef as useRef11, useState as useState12, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
@@ -155,6 +156,7 @@ function chartSummary(s, { type, rows, valueNames, labels, locale }) {
|
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
// src/theme.js
|
|
159
|
+
import { CHART_COLORS, chartThemeFrom } from "pivotkit-core";
|
|
158
160
|
function resolveTheme(wanted, htmlTheme, prefersDark) {
|
|
159
161
|
if (wanted === "light" || wanted === "dark") {
|
|
160
162
|
return wanted;
|
|
@@ -164,31 +166,6 @@ function resolveTheme(wanted, htmlTheme, prefersDark) {
|
|
|
164
166
|
}
|
|
165
167
|
return prefersDark ? "dark" : "light";
|
|
166
168
|
}
|
|
167
|
-
var CHART_COLORS = 8;
|
|
168
|
-
function chartThemeFrom(style) {
|
|
169
|
-
const v = (name) => style.getPropertyValue(name).trim();
|
|
170
|
-
const colors = [];
|
|
171
|
-
for (let i = 1; i <= CHART_COLORS; i++) {
|
|
172
|
-
const c = v(`--pk-chart-${i}`);
|
|
173
|
-
if (c) {
|
|
174
|
-
colors.push(c);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
const theme = {
|
|
178
|
-
colors,
|
|
179
|
-
textColor: v("--pk-muted") || void 0,
|
|
180
|
-
axisColor: v("--pk-border") || void 0,
|
|
181
|
-
gridColor: v("--pk-grid") || v("--pk-border") || void 0,
|
|
182
|
-
fontFamily: v("font-family") || void 0,
|
|
183
|
-
backgroundColor: "transparent"
|
|
184
|
-
};
|
|
185
|
-
const low = v("--pk-heat-low");
|
|
186
|
-
const high = v("--pk-heat-high");
|
|
187
|
-
if (low && high) {
|
|
188
|
-
theme.heatmapColors = [low, high];
|
|
189
|
-
}
|
|
190
|
-
return theme;
|
|
191
|
-
}
|
|
192
169
|
|
|
193
170
|
// src/chart.jsx
|
|
194
171
|
var loading = null;
|
|
@@ -272,7 +249,7 @@ function PivotChart({ result, series, labels, locale, themeName, root, onInstanc
|
|
|
272
249
|
if (!ready || !chart.current || !root.current) {
|
|
273
250
|
return;
|
|
274
251
|
}
|
|
275
|
-
const style =
|
|
252
|
+
const style = lib.current.chartStyle(root.current);
|
|
276
253
|
const option = toEChartsOption(result, { theme: chartThemeFrom(style), locale, labels: labels.core, maxCategories: MAX_CATEGORIES, ...series ? { series } : {}, ...drawAs ? { chart: drawAs } : {} });
|
|
277
254
|
const { axisEvery, ...drawn } = lib.current.decorate(option, style, chart.current.getHeight(), root.current.ownerDocument, chart.current.getWidth(), { categoryNames: series?.categories, axisLabels: result.view.chart.axisLabels });
|
|
278
255
|
setEvery(axisEvery);
|
|
@@ -341,8 +318,8 @@ function announcementsOf(labels) {
|
|
|
341
318
|
}
|
|
342
319
|
const zone = labels.zones[d.zone] ?? d.zone;
|
|
343
320
|
if (d.kind === "chip") {
|
|
344
|
-
const
|
|
345
|
-
const count = (d.count ?? d.index + 1) + (
|
|
321
|
+
const same2 = a?.data?.current?.kind === "chip" && a.data.current.zone === d.zone;
|
|
322
|
+
const count = (d.count ?? d.index + 1) + (same2 ? 0 : 1);
|
|
346
323
|
return fill(at, { field, zone, position: d.index + 1, count });
|
|
347
324
|
}
|
|
348
325
|
return fill(end, { field, zone });
|
|
@@ -685,23 +662,16 @@ function FieldItem({ field, labels, zones, onAdd, onNote, onFilter, name, info,
|
|
|
685
662
|
icon: zone === "values" ? "sigma" : zone === "filters" ? "filter" : zone,
|
|
686
663
|
onSelect: () => {
|
|
687
664
|
close();
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
Option,
|
|
694
|
-
{
|
|
695
|
-
inMenu: true,
|
|
696
|
-
icon: "filter",
|
|
697
|
-
onSelect: () => {
|
|
698
|
-
close();
|
|
699
|
-
onFilter(field.name, item.current);
|
|
665
|
+
if (zone === "filters" && onFilter) {
|
|
666
|
+
onFilter(field.name, item.current);
|
|
667
|
+
} else {
|
|
668
|
+
onAdd(field.name, zone);
|
|
669
|
+
}
|
|
700
670
|
},
|
|
701
|
-
testId: `field-filter-${field.name}`
|
|
671
|
+
testId: zone === "filters" ? `field-filter-${field.name}` : void 0
|
|
702
672
|
},
|
|
703
|
-
labels.
|
|
704
|
-
)
|
|
673
|
+
fill(zone === "values" && zones.includes("values") ? labels.addAgain : labels.addTo, { zone: labels.zones[zone] })
|
|
674
|
+
)))));
|
|
705
675
|
}
|
|
706
676
|
function wordsOf(name) {
|
|
707
677
|
return name.split(/(\s+)/).map((part, i) => i % 2 === 1 ? " " : part ? /* @__PURE__ */ React3.createElement("span", { key: i, className: "pk-word" }, part) : null);
|
|
@@ -981,6 +951,26 @@ function MenuPanel({ name, loadingText, props }) {
|
|
|
981
951
|
)) : loadingText ? /* @__PURE__ */ React4.createElement(Loading, { text: loadingText }) : null);
|
|
982
952
|
}
|
|
983
953
|
|
|
954
|
+
// src/import-limits.js
|
|
955
|
+
function importLimitsOf(limits, importLimits) {
|
|
956
|
+
if (importLimits === null || importLimits === void 0) {
|
|
957
|
+
return (
|
|
958
|
+
/** @type {any} */
|
|
959
|
+
limits ?? void 0
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
if (!isRecord(importLimits) || !isRecord(limits)) {
|
|
963
|
+
return (
|
|
964
|
+
/** @type {any} */
|
|
965
|
+
importLimits
|
|
966
|
+
);
|
|
967
|
+
}
|
|
968
|
+
return { ...limits, ...importLimits };
|
|
969
|
+
}
|
|
970
|
+
function isRecord(value) {
|
|
971
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
972
|
+
}
|
|
973
|
+
|
|
984
974
|
// src/skeleton.jsx
|
|
985
975
|
import React5 from "react";
|
|
986
976
|
var ROWS = 6;
|
|
@@ -1085,7 +1075,7 @@ function labelWidths(grid, table) {
|
|
|
1085
1075
|
content.append(probe);
|
|
1086
1076
|
try {
|
|
1087
1077
|
const widthOf = (l) => {
|
|
1088
|
-
probe.style.fontWeight = l.total ? "
|
|
1078
|
+
probe.style.fontWeight = l.total ? "var(--pk-weight-bold)" : "";
|
|
1089
1079
|
probe.textContent = l.text;
|
|
1090
1080
|
return probe.getBoundingClientRect().width;
|
|
1091
1081
|
};
|
|
@@ -1107,6 +1097,7 @@ var fontOf = (table) => {
|
|
|
1107
1097
|
const s = getComputedStyle(table);
|
|
1108
1098
|
return `${s.fontFamily}|${s.fontSize}|${s.fontWeight}`;
|
|
1109
1099
|
};
|
|
1100
|
+
var SCALE_MID = "var(--pk-scale-mid, color-mix(in srgb, var(--pk-scale-low), var(--pk-scale-high)))";
|
|
1110
1101
|
function conditionalStyle(cell) {
|
|
1111
1102
|
const s = cell.style;
|
|
1112
1103
|
if (!s) {
|
|
@@ -1117,8 +1108,8 @@ function conditionalStyle(cell) {
|
|
|
1117
1108
|
}
|
|
1118
1109
|
if (s.scale !== void 0) {
|
|
1119
1110
|
const t = Math.max(0, Math.min(1, s.scale));
|
|
1120
|
-
const [from, to, part] = t < 0.5 ? ["--pk-scale-low",
|
|
1121
|
-
return { "--pk-cell-bg": `color-mix(in srgb,
|
|
1111
|
+
const [from, to, part] = t < 0.5 ? ["var(--pk-scale-low)", SCALE_MID, t * 2] : [SCALE_MID, "var(--pk-scale-high)", (t - 0.5) * 2];
|
|
1112
|
+
return { "--pk-cell-bg": `color-mix(in srgb, ${to} ${Math.round(part * 100)}%, ${from})` };
|
|
1122
1113
|
}
|
|
1123
1114
|
if (s.bar !== void 0) {
|
|
1124
1115
|
return { "--pk-bar": `${Math.round(s.bar * 1e3) / 10}%`, ...s.color ? { "--pk-bar-color": s.color } : {} };
|
|
@@ -1375,11 +1366,15 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1375
1366
|
content: /* @__PURE__ */ React6.createElement("button", { type: "button", className: `pk-th-sort${state.chosen ? " pk-sorted" : ""}`, title: target.ref && next ? fill(next.order === "desc" ? labels.headerSortDesc : labels.headerSortAsc, { value: refLabel(view, target.ref, labels) }) : fill(labels.headerSort, { field, order: words(next) }), onClick: click }, /* @__PURE__ */ React6.createElement("span", { className: "pk-th-text" }, cell.text), /* @__PURE__ */ React6.createElement(Icon, { name: down ? "arrowDown" : "arrowUp", size: 14, className: "pk-th-arrow" }))
|
|
1376
1367
|
};
|
|
1377
1368
|
};
|
|
1369
|
+
const subStart = (col) => {
|
|
1370
|
+
const data = grid.dataColumns[col - grid.rowHeaderColumns];
|
|
1371
|
+
return data && data.total === 1 && data.valueIndex <= 0 ? " pk-sub-start" : "";
|
|
1372
|
+
};
|
|
1378
1373
|
const stickyStyle = (col, extra) => col < grid.rowHeaderColumns && lefts[col] !== void 0 ? { left: lefts[col], ...extra } : extra;
|
|
1379
1374
|
const headerCell = (cell, r, c) => {
|
|
1380
1375
|
const top = { top: tops[r] ?? r * rowHeight };
|
|
1381
1376
|
const sticky = c < grid.rowHeaderColumns;
|
|
1382
|
-
const className = `pk-th pk-${cell.kind}${totalClass(cell.total)}${sticky ? " pk-sticky" : ""}`;
|
|
1377
|
+
const className = `pk-th pk-${cell.kind}${totalClass(cell.total)}${subStart(c)}${sticky ? " pk-sticky" : ""}`;
|
|
1383
1378
|
const target = onSort && r === grid.headerRows - 1 ? headerSortTarget(view, cell, typeOf) : null;
|
|
1384
1379
|
const sorting = target ? sortButton(cell, target) : null;
|
|
1385
1380
|
const content = /* @__PURE__ */ React6.createElement("span", { className: "pk-th-content" }, cell.toggle ? /* @__PURE__ */ React6.createElement(Toggle, { toggle: cell.toggle, text: cell.text, labels, onToggle }) : null, sorting ? sorting.content : /* @__PURE__ */ React6.createElement("span", { className: "pk-th-text" }, cell.text));
|
|
@@ -1395,7 +1390,8 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1395
1390
|
const spec = view.values[cell.valueIndex];
|
|
1396
1391
|
return /* @__PURE__ */ React6.createElement(DraggableHeader, { key: c, ...props, cell, source: { kind: "table", field: spec?.field ?? null, zone: "values", index: cell.valueIndex, label: cell.text }, description: spec?.field ? infoOf?.(spec.field)?.description : void 0, tooltip: showInfo, sort: sorting?.sort }, content);
|
|
1397
1392
|
}
|
|
1398
|
-
|
|
1393
|
+
const title = cell.kind === "colHeader" && cell.total === 1 && r < grid.headerRows - 1 ? labels.tips.colSubtotals : void 0;
|
|
1394
|
+
return /* @__PURE__ */ React6.createElement("th", { key: c, ...props, title }, content);
|
|
1399
1395
|
};
|
|
1400
1396
|
const bodyCell = ({ cell, col, rowSpan, colSpan }, r) => {
|
|
1401
1397
|
if (cell.kind === "rowHeader") {
|
|
@@ -1409,7 +1405,7 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1409
1405
|
"td",
|
|
1410
1406
|
{
|
|
1411
1407
|
key: col,
|
|
1412
|
-
className: `pk-td${totalClass(cell.total)}${clickable ? " pk-clickable" : ""}${cell.valueType === "text" ? " pk-text" : ""}${cond ? cell.style.bar !== void 0 ? " pk-has-bar" : " pk-has-scale" : ""}`,
|
|
1408
|
+
className: `pk-td${totalClass(cell.total)}${subStart(col)}${clickable ? " pk-clickable" : ""}${cell.valueType === "text" ? " pk-text" : ""}${cond ? cell.style.bar !== void 0 ? " pk-has-bar" : " pk-has-scale" : ""}`,
|
|
1413
1409
|
style: cond,
|
|
1414
1410
|
"data-r": r,
|
|
1415
1411
|
"data-c": col,
|
|
@@ -1425,7 +1421,7 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1425
1421
|
);
|
|
1426
1422
|
};
|
|
1427
1423
|
const columns = grid.columnCount;
|
|
1428
|
-
return /* @__PURE__ */ React6.createElement("div", { className: "pk-table-wrap", ref: wrap, onScroll: virtual ? onScroll : void 0, onBlur: virtual ? onBlur : void 0, "data-testid": "pivot-table" }, onSort ? /* @__PURE__ */ React6.createElement("span", { className: "pk-sr", role: "status", "data-testid": "sort-status" }, sortNote) : null, /* @__PURE__ */ React6.createElement("table", { ref: table, className: `pk-table${virtual ? " pk-virtual" : ""}`, style: (
|
|
1424
|
+
return /* @__PURE__ */ React6.createElement("div", { className: "pk-table-wrap", ref: wrap, onScroll: virtual ? onScroll : void 0, onBlur: virtual ? onBlur : void 0, "data-testid": "pivot-table" }, onSort ? /* @__PURE__ */ React6.createElement("span", { className: "pk-sr", role: "status", "data-testid": "sort-status" }, sortNote) : null, /* @__PURE__ */ React6.createElement("table", { ref: table, className: `pk-table${virtual ? " pk-virtual" : ""}${grid.columnCount === grid.rowHeaderColumns ? " pk-labels-only" : ""}`, style: (
|
|
1429
1425
|
/** @type {any} */
|
|
1430
1426
|
{ "--pk-row-cols": grid.rowHeaderColumns }
|
|
1431
1427
|
), onKeyDown, "aria-rowcount": grid.rows.length, "aria-label": labels.tableName, "aria-describedby": hintId }, /* @__PURE__ */ React6.createElement("thead", null, grid.rows.slice(0, grid.headerRows).map((row, r) => /* @__PURE__ */ React6.createElement("tr", { key: r }, row.map((cell, c) => cell ? headerCell(cell, r, c) : null)))), /* @__PURE__ */ React6.createElement("tbody", null, win.padTop > 0 ? /* @__PURE__ */ React6.createElement("tr", { className: "pk-spacer", "aria-hidden": "true", style: { height: win.padTop } }, /* @__PURE__ */ React6.createElement("td", { colSpan: columns })) : null, rows.map(({ index, cells }) => /* @__PURE__ */ React6.createElement("tr", { key: index, "data-r": index, "aria-rowindex": grid.headerRows + index + 1, className: totalClass(grid.bodyRows[index]?.total).trim() || void 0 }, cells.map((c) => bodyCell(c, index)))), win.padBottom > 0 ? /* @__PURE__ */ React6.createElement("tr", { className: "pk-spacer", "aria-hidden": "true", style: { height: win.padBottom } }, /* @__PURE__ */ React6.createElement("td", { colSpan: columns })) : null)));
|
|
@@ -1601,7 +1597,7 @@ import React9, { useEffect as useEffect7, useMemo as useMemo4, useRef as useRef7
|
|
|
1601
1597
|
import { fieldLabel as fieldLabel3 } from "pivotkit-core";
|
|
1602
1598
|
|
|
1603
1599
|
// src/unused-load.js
|
|
1604
|
-
var UNUSED_TEXTS_OF = Object.freeze({ de: () => import("./chunks/unused-texts-de-
|
|
1600
|
+
var UNUSED_TEXTS_OF = Object.freeze({ de: () => import("./chunks/unused-texts-de-6YVPTNVS.js").then((m) => m.de) });
|
|
1605
1601
|
var pending2 = /* @__PURE__ */ new Map();
|
|
1606
1602
|
var loaded2 = /* @__PURE__ */ new Map();
|
|
1607
1603
|
var unusedNow = (lang) => loaded2.get(lang) ?? null;
|
|
@@ -1609,7 +1605,7 @@ function loadUnused(lang) {
|
|
|
1609
1605
|
let p = pending2.get(lang);
|
|
1610
1606
|
if (!p) {
|
|
1611
1607
|
const own2 = Object.hasOwn(UNUSED_TEXTS_OF, lang) ? UNUSED_TEXTS_OF[lang]().catch(() => null) : null;
|
|
1612
|
-
p = Promise.all([import("./chunks/unused-texts-
|
|
1608
|
+
p = Promise.all([import("./chunks/unused-texts-Y4R67XSN.js"), own2]).then(
|
|
1613
1609
|
([mod, texts]) => {
|
|
1614
1610
|
const out = { mod, lang: texts };
|
|
1615
1611
|
loaded2.set(lang, out);
|
|
@@ -2218,9 +2214,12 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2218
2214
|
const start = useMemo6(() => json(initial), [json, initial]);
|
|
2219
2215
|
const [state, setState] = useState9(() => initialState ?? createState(schema, start));
|
|
2220
2216
|
const viewKey = controlled ? JSON.stringify(view) : null;
|
|
2221
|
-
const [
|
|
2222
|
-
|
|
2223
|
-
|
|
2217
|
+
const [echo, setEcho] = useState9(() => ({ over: viewKey, pending: initialState ? [initialState.present] : [] }));
|
|
2218
|
+
let pending3 = echo.pending;
|
|
2219
|
+
if (viewKey !== echo.over) {
|
|
2220
|
+
const index = viewKey === null ? -1 : pending3.indexOf(json(JSON.parse(viewKey)));
|
|
2221
|
+
pending3 = index < 0 ? [] : pending3.slice(index + 1);
|
|
2222
|
+
setEcho({ over: viewKey, pending: pending3 });
|
|
2224
2223
|
}
|
|
2225
2224
|
const shown = useMemo6(() => {
|
|
2226
2225
|
if (viewKey !== null) {
|
|
@@ -2232,14 +2231,17 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2232
2231
|
/** @type {import("pivotkit-core").View} */
|
|
2233
2232
|
JSON.parse(shown)
|
|
2234
2233
|
), [shown]);
|
|
2235
|
-
const
|
|
2234
|
+
const waiting = viewKey !== null && pending3.length > 0 && state.schema === schema;
|
|
2235
|
+
const live = useMemo6(() => waiting ? state : settle(state, { schema, start, shown, outside: outsideNote }), [waiting, state, schema, start, shown, outsideNote]);
|
|
2236
2236
|
const apply = useCallback6(
|
|
2237
2237
|
(next) => {
|
|
2238
2238
|
setState(next);
|
|
2239
|
-
|
|
2239
|
+
if (viewKey !== null) {
|
|
2240
|
+
setEcho((previous) => ({ over: viewKey, pending: [...previous.over === viewKey ? previous.pending : pending3, next.present] }));
|
|
2241
|
+
}
|
|
2240
2242
|
onViewChange?.(JSON.parse(next.present));
|
|
2241
2243
|
},
|
|
2242
|
-
[onViewChange, viewKey]
|
|
2244
|
+
[onViewChange, viewKey, pending3]
|
|
2243
2245
|
);
|
|
2244
2246
|
const commit = useCallback6(
|
|
2245
2247
|
(next, note, tag) => {
|
|
@@ -2282,9 +2284,7 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2282
2284
|
[live, apply]
|
|
2283
2285
|
);
|
|
2284
2286
|
const restore = useCallback6((next, tag = null) => apply(createState(schema, start, json(next), tag)), [schema, start, json, apply]);
|
|
2285
|
-
const
|
|
2286
|
-
const made = waiting ? state : live;
|
|
2287
|
-
const snapshot = useCallback6(() => made, [made]);
|
|
2287
|
+
const snapshot = useCallback6(() => live, [live]);
|
|
2288
2288
|
const earlier = useCallback6(() => live.past.map((p) => JSON.parse(p.view)), [live.past]);
|
|
2289
2289
|
const canUndo = live.past.length > 0;
|
|
2290
2290
|
const canRedo = live.future.length > 0;
|
|
@@ -2408,7 +2408,7 @@ function measureFit(el, m, fit) {
|
|
|
2408
2408
|
import React11, { useCallback as useCallback8, useEffect as useEffect10, useMemo as useMemo7, useRef as useRef10, useState as useState11 } from "react";
|
|
2409
2409
|
import { fieldItems, fieldLabel as fieldLabel4 } from "pivotkit-core";
|
|
2410
2410
|
function fieldState(view, field, encoded, locale, labels, sourceType) {
|
|
2411
|
-
const items = filtersOf(view, field, ["
|
|
2411
|
+
const items = filtersOf(view, field, ["in"]).filter((f) => !isEmptyPick(f));
|
|
2412
2412
|
const compared = filtersOf(view, field, ["compare"]);
|
|
2413
2413
|
const info = items.length || compared.length ? fieldItems(encoded, field, { view, locale }) : null;
|
|
2414
2414
|
let summary = null;
|
|
@@ -2419,7 +2419,7 @@ function fieldState(view, field, encoded, locale, labels, sourceType) {
|
|
|
2419
2419
|
const labelOf = (v) => info?.items.find((i) => i.value === v)?.label;
|
|
2420
2420
|
const date = sourceType === "date";
|
|
2421
2421
|
const span = date ? dateSpan(encoded, sourceOf(view, field)) : null;
|
|
2422
|
-
const rules = filtersOf(view, field, ["relative", "compare", "
|
|
2422
|
+
const rules = filtersOf(view, field, ["relative", "compare", "text"]).map((f) => itemRuleText(f, labels, locale, { timeZone: encoded.timeZone, date, labelOf, span, weekStart: view.formatting?.weekStart }));
|
|
2423
2423
|
const top = filtersOf(view, field, ["top"])[0] ?? null;
|
|
2424
2424
|
const condition = filtersOf(view, field, ["value"])[0] ?? null;
|
|
2425
2425
|
return { summary, rules, top, condition, sort: sortOf(view, field) };
|
|
@@ -2809,6 +2809,7 @@ function Report(props) {
|
|
|
2809
2809
|
theme = "auto",
|
|
2810
2810
|
height = 640,
|
|
2811
2811
|
limits: limitsProp,
|
|
2812
|
+
importLimits: importLimitsProp,
|
|
2812
2813
|
className,
|
|
2813
2814
|
fileName = "pivot",
|
|
2814
2815
|
fieldDefaults,
|
|
@@ -2857,7 +2858,9 @@ function Report(props) {
|
|
|
2857
2858
|
const baseLabels = useMemo8(() => resolveLabels(locale, JSON.parse(labelsKey)), [locale, labelsKey]);
|
|
2858
2859
|
const typesKey = JSON.stringify(typesOf(fieldDefaults));
|
|
2859
2860
|
const limitsKey = JSON.stringify(limitsProp ?? null);
|
|
2860
|
-
const
|
|
2861
|
+
const hostLimits = useMemo8(() => JSON.parse(limitsKey) ?? void 0, [limitsKey]);
|
|
2862
|
+
const importLimitsKey = JSON.stringify(importLimitsProp ?? null);
|
|
2863
|
+
const fileLimits = useMemo8(() => importLimitsOf(hostLimits, JSON.parse(importLimitsKey)), [hostLimits, importLimitsKey]);
|
|
2861
2864
|
const root = useRef11(
|
|
2862
2865
|
/** @type {HTMLDivElement | null} */
|
|
2863
2866
|
null
|
|
@@ -2933,12 +2936,12 @@ function Report(props) {
|
|
|
2933
2936
|
const source = useMemo8(() => {
|
|
2934
2937
|
try {
|
|
2935
2938
|
const types2 = JSON.parse(typesKey);
|
|
2936
|
-
const enc = encodedProp ?? measured("encode", () => encode(dataOf(data), { timeZone: timeZone ?? "UTC", limits, ...types2 ? { types: types2 } : {} }));
|
|
2939
|
+
const enc = encodedProp ?? measured("encode", () => encode(dataOf(data), { timeZone: timeZone ?? "UTC", limits: hostLimits, ...types2 ? { types: types2 } : {} }));
|
|
2937
2940
|
return { encoded: enc, error: null };
|
|
2938
2941
|
} catch (error2) {
|
|
2939
2942
|
return { encoded: encode([]), error: error2 };
|
|
2940
2943
|
}
|
|
2941
|
-
}, [encodedProp, dataIdentity, timeZone,
|
|
2944
|
+
}, [encodedProp, dataIdentity, timeZone, hostLimits, typesKey]);
|
|
2942
2945
|
const keepKey = allowImport && typeof storageKey === "string" && storageKey ? storageKey : null;
|
|
2943
2946
|
const hostData = hostIdentity({ dataKey, sourceId: hostSourceId, schemaKey: schemaKeyOf(source.encoded) });
|
|
2944
2947
|
const [kept2] = useState12(() => keepKey ? keptData(keepKey, hostData) : null);
|
|
@@ -2957,6 +2960,7 @@ function Report(props) {
|
|
|
2957
2960
|
const sourceId = imported ? imported.source.id : hostSourceId;
|
|
2958
2961
|
const sourceName = imported ? imported.source.name : hostSourceName;
|
|
2959
2962
|
const encoded = imported ? imported.encoded : source.encoded;
|
|
2963
|
+
const limits = imported ? fileLimits : hostLimits;
|
|
2960
2964
|
const fieldNamesKey = encoded.schema.fields.map((f) => f.name).join("\0");
|
|
2961
2965
|
const labels = useMemo8(() => {
|
|
2962
2966
|
const fields2 = displayNames(info, fieldNamesKey ? fieldNamesKey.split("\0") : []);
|
|
@@ -3036,7 +3040,6 @@ function Report(props) {
|
|
|
3036
3040
|
newStep();
|
|
3037
3041
|
announce(labels.toastReset, { action: { label: labels.undo, run: () => undoLater.current() } });
|
|
3038
3042
|
}, [history, labels, announce, newStep]);
|
|
3039
|
-
const param = linkParam(storageKey);
|
|
3040
3043
|
const [opening, setOpening] = useState12(false);
|
|
3041
3044
|
const appliedLink = useRef11(
|
|
3042
3045
|
/** @type {string | null} */
|
|
@@ -3112,7 +3115,7 @@ function Report(props) {
|
|
|
3112
3115
|
return;
|
|
3113
3116
|
}
|
|
3114
3117
|
const page = here();
|
|
3115
|
-
const link = shareLink ? readLinkParam(page?.hash ?? "",
|
|
3118
|
+
const link = shareLink ? readLinkParam(page?.hash ?? "", storageKey) : null;
|
|
3116
3119
|
if (link) {
|
|
3117
3120
|
openLink(link);
|
|
3118
3121
|
} else if (persistView === "session") {
|
|
@@ -3133,14 +3136,14 @@ function Report(props) {
|
|
|
3133
3136
|
return void 0;
|
|
3134
3137
|
}
|
|
3135
3138
|
const onHash = () => {
|
|
3136
|
-
const link = readLinkParam(here()?.hash ?? "",
|
|
3139
|
+
const link = readLinkParam(here()?.hash ?? "", storageKey);
|
|
3137
3140
|
if (link && link !== appliedLink.current) {
|
|
3138
3141
|
openLink(link, true);
|
|
3139
3142
|
}
|
|
3140
3143
|
};
|
|
3141
3144
|
window.addEventListener("hashchange", onHash);
|
|
3142
3145
|
return () => window.removeEventListener("hashchange", onHash);
|
|
3143
|
-
}, [shareLink,
|
|
3146
|
+
}, [shareLink, storageKey, openLink]);
|
|
3144
3147
|
useEffect11(() => {
|
|
3145
3148
|
if (persistView === "session") {
|
|
3146
3149
|
writeStoredView(storageKey, sessionStore(), JSON.parse(history.viewKey));
|
|
@@ -3204,6 +3207,15 @@ function Report(props) {
|
|
|
3204
3207
|
}
|
|
3205
3208
|
}, [encoded, view, locale, limits]);
|
|
3206
3209
|
const result = computed.result;
|
|
3210
|
+
const unusedLocale = useMemo8(() => {
|
|
3211
|
+
const requested = view.formatting?.locale || locale;
|
|
3212
|
+
try {
|
|
3213
|
+
new Intl.NumberFormat(requested);
|
|
3214
|
+
return requested;
|
|
3215
|
+
} catch {
|
|
3216
|
+
return "en-US";
|
|
3217
|
+
}
|
|
3218
|
+
}, [view.formatting?.locale, locale]);
|
|
3207
3219
|
const plan = useMemo8(() => chartPlan(view, encoded), [view, encoded]);
|
|
3208
3220
|
const chartComputed = useMemo8(() => {
|
|
3209
3221
|
if (!plan.swap || view.display !== "chart" || !result) {
|
|
@@ -3346,10 +3358,11 @@ function Report(props) {
|
|
|
3346
3358
|
},
|
|
3347
3359
|
[view, placeOptions, commit, nameOf]
|
|
3348
3360
|
);
|
|
3349
|
-
const
|
|
3361
|
+
const filterField = useCallback9(
|
|
3350
3362
|
(field, anchor) => {
|
|
3351
3363
|
const options = placeOptions(field, "filters");
|
|
3352
|
-
const
|
|
3364
|
+
const name = options.groupName ?? field;
|
|
3365
|
+
const draft = filterZoneFields(view).some((f) => same(f, name)) ? void 0 : addField(view, field, "filters", options);
|
|
3353
3366
|
const opener = size === "narrow" ? (
|
|
3354
3367
|
/** @type {HTMLElement | null} */
|
|
3355
3368
|
root.current?.querySelector("[data-pk-opener='fields']") ?? null
|
|
@@ -3359,7 +3372,7 @@ function Report(props) {
|
|
|
3359
3372
|
}
|
|
3360
3373
|
const target = opener ?? anchor;
|
|
3361
3374
|
if (target) {
|
|
3362
|
-
setFilterTarget({ field:
|
|
3375
|
+
setFilterTarget({ field: name, anchor: target, base: draft });
|
|
3363
3376
|
}
|
|
3364
3377
|
},
|
|
3365
3378
|
[placeOptions, view, size]
|
|
@@ -3405,7 +3418,7 @@ function Report(props) {
|
|
|
3405
3418
|
},
|
|
3406
3419
|
[result, encodedProp, imported, data, drillDownLimit, onCellClick, drillDown, defaultsOf, nameOf, infoOf]
|
|
3407
3420
|
);
|
|
3408
|
-
const doExport = useExport({ fileName, result, locale, labels, limits, root, chartRef, announce, onExport });
|
|
3421
|
+
const doExport = useExport({ fileName, result, locale, labels, limits, root, chartRef, announce, onExport, title: viewName, source: sourceName, loadECharts });
|
|
3409
3422
|
const requestImport = () => loadImport().then((m) => (flushSync(() => setImportMod(() => m)), m));
|
|
3410
3423
|
const api = {
|
|
3411
3424
|
imported,
|
|
@@ -3424,7 +3437,7 @@ function Report(props) {
|
|
|
3424
3437
|
locale,
|
|
3425
3438
|
plugins,
|
|
3426
3439
|
worker: importWorker,
|
|
3427
|
-
limits,
|
|
3440
|
+
limits: fileLimits,
|
|
3428
3441
|
timeZone,
|
|
3429
3442
|
onDataLoad,
|
|
3430
3443
|
announce,
|
|
@@ -3493,7 +3506,7 @@ function Report(props) {
|
|
|
3493
3506
|
schemaUrl,
|
|
3494
3507
|
encoded,
|
|
3495
3508
|
shareLink,
|
|
3496
|
-
|
|
3509
|
+
linkKey: storageKey,
|
|
3497
3510
|
root,
|
|
3498
3511
|
fileName,
|
|
3499
3512
|
onExport,
|
|
@@ -3708,6 +3721,8 @@ function Report(props) {
|
|
|
3708
3721
|
commit(setChart(view, "auto"), { step: "chart", type: "auto" });
|
|
3709
3722
|
} else if (action === "saveTemplate") {
|
|
3710
3723
|
setViewsRequest((n) => n + 1);
|
|
3724
|
+
} else if (action === "colSubtotalsOff") {
|
|
3725
|
+
commit(setTotal(view, "colSubtotals", false), { step: "totals" });
|
|
3711
3726
|
}
|
|
3712
3727
|
};
|
|
3713
3728
|
const cancelLink = () => {
|
|
@@ -3773,7 +3788,7 @@ function Report(props) {
|
|
|
3773
3788
|
}
|
|
3774
3789
|
},
|
|
3775
3790
|
onNote: (text) => announce(text),
|
|
3776
|
-
onFilter:
|
|
3791
|
+
onFilter: filterField,
|
|
3777
3792
|
nameOf,
|
|
3778
3793
|
info,
|
|
3779
3794
|
showInfo: fieldSwitch.on,
|
|
@@ -3867,7 +3882,7 @@ function Report(props) {
|
|
|
3867
3882
|
}
|
|
3868
3883
|
},
|
|
3869
3884
|
labels,
|
|
3870
|
-
locale,
|
|
3885
|
+
locale: result?.locale ?? unusedLocale,
|
|
3871
3886
|
narrow: size === "narrow",
|
|
3872
3887
|
quiet: unusedSaid && !fromHost
|
|
3873
3888
|
}
|
package/dist/labels.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
de as de3
|
|
3
|
-
} from "./chunks/chunk-
|
|
3
|
+
} from "./chunks/chunk-JMRTIOX4.js";
|
|
4
4
|
import {
|
|
5
5
|
en as en3
|
|
6
|
-
} from "./chunks/chunk-
|
|
6
|
+
} from "./chunks/chunk-E6M57YLL.js";
|
|
7
7
|
import {
|
|
8
8
|
en
|
|
9
|
-
} from "./chunks/chunk-
|
|
9
|
+
} from "./chunks/chunk-U5Q5I2D5.js";
|
|
10
10
|
import {
|
|
11
11
|
de
|
|
12
|
-
} from "./chunks/chunk-
|
|
12
|
+
} from "./chunks/chunk-4RS72AAA.js";
|
|
13
13
|
import {
|
|
14
14
|
de as de2,
|
|
15
15
|
en as en2
|
|
16
|
-
} from "./chunks/chunk-
|
|
16
|
+
} from "./chunks/chunk-3E4NB5RZ.js";
|
|
17
17
|
import {
|
|
18
18
|
LABELS
|
|
19
|
-
} from "./chunks/chunk-
|
|
19
|
+
} from "./chunks/chunk-3WUGQPWV.js";
|
|
20
20
|
|
|
21
21
|
// src/all-labels.js
|
|
22
22
|
var LABELS2 = Object.freeze({ en: { ...LABELS.en, ...en, unused: en3, dataImport: en2 }, de: { ...LABELS.de, ...de, unused: de3, dataImport: de2 } });
|