pivotkit-react 0.4.0 → 0.6.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 +267 -1
- package/README.md +5 -2
- package/dist/chunks/{chunk-YITKWZ4L.js → chunk-2RAVX4DO.js} +604 -505
- package/dist/chunks/{chunk-ZYEYZSYL.js → chunk-7LERNGUW.js} +36 -2
- 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-TR2HROIK.js} +43 -7
- package/dist/chunks/chunk-W2KIPREL.js +36 -0
- package/dist/chunks/{chunk-6MDAL3IO.js → chunk-XN5HNKJ2.js} +88 -101
- package/dist/chunks/{chunk-WB4GKWFQ.js → chunk-YXLANLGL.js} +34 -6
- 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 +69 -168
- package/dist/index.js +160 -102
- package/dist/labels.js +6 -6
- package/dist/menu-texts-de.js +1 -1
- package/dist/menus.js +778 -277
- 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 +42 -4
- package/types/field-info.d.ts +3 -10
- package/types/filter.d.ts +1 -1
- package/types/icons.d.ts +1 -0
- package/types/import-host.d.ts +34 -8
- package/types/import-labels.d.ts +47 -0
- package/types/import-limits.d.ts +6 -0
- package/types/import-module.d.ts +1 -1
- package/types/import-steps.d.ts +8 -0
- package/types/import-ui.d.ts +18 -4
- package/types/index.d.ts +76 -17
- package/types/labels.d.ts +200 -24
- package/types/light-tokens.d.ts +16 -0
- package/types/menu-labels.d.ts +43 -14
- package/types/menu-ops.d.ts +166 -43
- 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 +17 -3
- package/types/share.d.ts +13 -17
- package/types/sheet-views.d.ts +60 -0
- package/types/templates.d.ts +21 -1
- package/types/theme.d.ts +2 -16
- package/types/tips.d.ts +5 -0
- package/types/toolbar-panels.d.ts +9 -6
- 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/view-save.d.ts +10 -6
- package/types/view-store.d.ts +21 -11
- package/types/chart-layout.d.ts +0 -111
- package/types/import-source.d.ts +0 -32
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-2RAVX4DO.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-XN5HNKJ2.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 });
|
|
@@ -480,7 +457,7 @@ function ChipList({ ids, children }) {
|
|
|
480
457
|
}
|
|
481
458
|
|
|
482
459
|
// src/field-info.js
|
|
483
|
-
import { fieldDefaultsFromSchema } from "pivotkit-core";
|
|
460
|
+
import { fieldDefaultsFromSchema, isIdentifierName } from "pivotkit-core";
|
|
484
461
|
var isObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
485
462
|
var own = (o, k) => isObject(o) && Object.hasOwn(o, k) ? o[k] : void 0;
|
|
486
463
|
var TYPES = Object.freeze(["string", "number", "date", "boolean"]);
|
|
@@ -567,15 +544,6 @@ function fieldMatches(field, query, info) {
|
|
|
567
544
|
}
|
|
568
545
|
return [field, info?.label, info?.description].some((t) => typeof t === "string" && t.toLowerCase().includes(query));
|
|
569
546
|
}
|
|
570
|
-
var IDENTIFIER_WORDS = Object.freeze(["id", "nr", "no", "number", "key", "#"]);
|
|
571
|
-
function isIdentifierName(name) {
|
|
572
|
-
const words = String(name).replace(/(\s*\([^()]*\))+\s*$/, "").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Za-z])(\d)/g, "$1 $2").replace(/#/g, " # ").split(/[\s_.\-/:()]+/).filter(Boolean);
|
|
573
|
-
while (words.length > 1 && /^\d+$/.test(words[words.length - 1])) {
|
|
574
|
-
words.pop();
|
|
575
|
-
}
|
|
576
|
-
const last = words[words.length - 1];
|
|
577
|
-
return last !== void 0 && IDENTIFIER_WORDS.includes(last.toLowerCase());
|
|
578
|
-
}
|
|
579
547
|
var identifierColumns = /* @__PURE__ */ new WeakMap();
|
|
580
548
|
function isIdentifier(column) {
|
|
581
549
|
if (!column || column.type !== "number" || column.derived || !isIdentifierName(column.name)) {
|
|
@@ -685,23 +653,16 @@ function FieldItem({ field, labels, zones, onAdd, onNote, onFilter, name, info,
|
|
|
685
653
|
icon: zone === "values" ? "sigma" : zone === "filters" ? "filter" : zone,
|
|
686
654
|
onSelect: () => {
|
|
687
655
|
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);
|
|
656
|
+
if (zone === "filters" && onFilter) {
|
|
657
|
+
onFilter(field.name, item.current);
|
|
658
|
+
} else {
|
|
659
|
+
onAdd(field.name, zone);
|
|
660
|
+
}
|
|
700
661
|
},
|
|
701
|
-
testId: `field-filter-${field.name}`
|
|
662
|
+
testId: zone === "filters" ? `field-filter-${field.name}` : void 0
|
|
702
663
|
},
|
|
703
|
-
labels.
|
|
704
|
-
)
|
|
664
|
+
fill(zone === "values" && zones.includes("values") ? labels.addAgain : labels.addTo, { zone: labels.zones[zone] })
|
|
665
|
+
)))));
|
|
705
666
|
}
|
|
706
667
|
function wordsOf(name) {
|
|
707
668
|
return name.split(/(\s+)/).map((part, i) => i % 2 === 1 ? " " : part ? /* @__PURE__ */ React3.createElement("span", { key: i, className: "pk-word" }, part) : null);
|
|
@@ -981,6 +942,26 @@ function MenuPanel({ name, loadingText, props }) {
|
|
|
981
942
|
)) : loadingText ? /* @__PURE__ */ React4.createElement(Loading, { text: loadingText }) : null);
|
|
982
943
|
}
|
|
983
944
|
|
|
945
|
+
// src/import-limits.js
|
|
946
|
+
function importLimitsOf(limits, importLimits) {
|
|
947
|
+
if (importLimits === null || importLimits === void 0) {
|
|
948
|
+
return (
|
|
949
|
+
/** @type {any} */
|
|
950
|
+
limits ?? void 0
|
|
951
|
+
);
|
|
952
|
+
}
|
|
953
|
+
if (!isRecord(importLimits) || !isRecord(limits)) {
|
|
954
|
+
return (
|
|
955
|
+
/** @type {any} */
|
|
956
|
+
importLimits
|
|
957
|
+
);
|
|
958
|
+
}
|
|
959
|
+
return { ...limits, ...importLimits };
|
|
960
|
+
}
|
|
961
|
+
function isRecord(value) {
|
|
962
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
963
|
+
}
|
|
964
|
+
|
|
984
965
|
// src/skeleton.jsx
|
|
985
966
|
import React5 from "react";
|
|
986
967
|
var ROWS = 6;
|
|
@@ -1085,7 +1066,7 @@ function labelWidths(grid, table) {
|
|
|
1085
1066
|
content.append(probe);
|
|
1086
1067
|
try {
|
|
1087
1068
|
const widthOf = (l) => {
|
|
1088
|
-
probe.style.fontWeight = l.total ? "
|
|
1069
|
+
probe.style.fontWeight = l.total ? "var(--pk-weight-bold)" : "";
|
|
1089
1070
|
probe.textContent = l.text;
|
|
1090
1071
|
return probe.getBoundingClientRect().width;
|
|
1091
1072
|
};
|
|
@@ -1107,6 +1088,7 @@ var fontOf = (table) => {
|
|
|
1107
1088
|
const s = getComputedStyle(table);
|
|
1108
1089
|
return `${s.fontFamily}|${s.fontSize}|${s.fontWeight}`;
|
|
1109
1090
|
};
|
|
1091
|
+
var SCALE_MID = "var(--pk-scale-mid, color-mix(in srgb, var(--pk-scale-low), var(--pk-scale-high)))";
|
|
1110
1092
|
function conditionalStyle(cell) {
|
|
1111
1093
|
const s = cell.style;
|
|
1112
1094
|
if (!s) {
|
|
@@ -1117,8 +1099,8 @@ function conditionalStyle(cell) {
|
|
|
1117
1099
|
}
|
|
1118
1100
|
if (s.scale !== void 0) {
|
|
1119
1101
|
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,
|
|
1102
|
+
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];
|
|
1103
|
+
return { "--pk-cell-bg": `color-mix(in srgb, ${to} ${Math.round(part * 100)}%, ${from})` };
|
|
1122
1104
|
}
|
|
1123
1105
|
if (s.bar !== void 0) {
|
|
1124
1106
|
return { "--pk-bar": `${Math.round(s.bar * 1e3) / 10}%`, ...s.color ? { "--pk-bar-color": s.color } : {} };
|
|
@@ -1375,11 +1357,15 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1375
1357
|
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
1358
|
};
|
|
1377
1359
|
};
|
|
1360
|
+
const subStart = (col) => {
|
|
1361
|
+
const data = grid.dataColumns[col - grid.rowHeaderColumns];
|
|
1362
|
+
return data && data.total === 1 && data.valueIndex <= 0 ? " pk-sub-start" : "";
|
|
1363
|
+
};
|
|
1378
1364
|
const stickyStyle = (col, extra) => col < grid.rowHeaderColumns && lefts[col] !== void 0 ? { left: lefts[col], ...extra } : extra;
|
|
1379
1365
|
const headerCell = (cell, r, c) => {
|
|
1380
1366
|
const top = { top: tops[r] ?? r * rowHeight };
|
|
1381
1367
|
const sticky = c < grid.rowHeaderColumns;
|
|
1382
|
-
const className = `pk-th pk-${cell.kind}${totalClass(cell.total)}${sticky ? " pk-sticky" : ""}`;
|
|
1368
|
+
const className = `pk-th pk-${cell.kind}${totalClass(cell.total)}${subStart(c)}${sticky ? " pk-sticky" : ""}`;
|
|
1383
1369
|
const target = onSort && r === grid.headerRows - 1 ? headerSortTarget(view, cell, typeOf) : null;
|
|
1384
1370
|
const sorting = target ? sortButton(cell, target) : null;
|
|
1385
1371
|
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 +1381,8 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1395
1381
|
const spec = view.values[cell.valueIndex];
|
|
1396
1382
|
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
1383
|
}
|
|
1398
|
-
|
|
1384
|
+
const title = cell.kind === "colHeader" && cell.total === 1 && r < grid.headerRows - 1 ? labels.tips.colSubtotals : void 0;
|
|
1385
|
+
return /* @__PURE__ */ React6.createElement("th", { key: c, ...props, title }, content);
|
|
1399
1386
|
};
|
|
1400
1387
|
const bodyCell = ({ cell, col, rowSpan, colSpan }, r) => {
|
|
1401
1388
|
if (cell.kind === "rowHeader") {
|
|
@@ -1409,7 +1396,7 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1409
1396
|
"td",
|
|
1410
1397
|
{
|
|
1411
1398
|
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" : ""}`,
|
|
1399
|
+
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
1400
|
style: cond,
|
|
1414
1401
|
"data-r": r,
|
|
1415
1402
|
"data-c": col,
|
|
@@ -1425,7 +1412,7 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1425
1412
|
);
|
|
1426
1413
|
};
|
|
1427
1414
|
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: (
|
|
1415
|
+
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
1416
|
/** @type {any} */
|
|
1430
1417
|
{ "--pk-row-cols": grid.rowHeaderColumns }
|
|
1431
1418
|
), 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)));
|
|
@@ -1526,10 +1513,13 @@ function templateEntries(templates, stored, hostDeletes) {
|
|
|
1526
1513
|
continue;
|
|
1527
1514
|
}
|
|
1528
1515
|
let { name, view } = t;
|
|
1516
|
+
let made = {};
|
|
1529
1517
|
if (t.file !== void 0 && t.file !== null) {
|
|
1530
1518
|
const read = fromViewFile(t.file);
|
|
1531
1519
|
view = read.view;
|
|
1532
1520
|
name = typeof name === "string" && name ? name : read.name;
|
|
1521
|
+
const sheet = read.source?.params?.sheet;
|
|
1522
|
+
made = { ...read.source?.id ? { fileSource: read.source.id } : {}, ...sheet && read.source?.id ? { sheet, sheetOf: read.source.id } : {} };
|
|
1533
1523
|
}
|
|
1534
1524
|
if (typeof name === "string" && name && view && typeof view === "object") {
|
|
1535
1525
|
const deletable = t.deletable === true;
|
|
@@ -1538,13 +1528,13 @@ function templateEntries(templates, stored, hostDeletes) {
|
|
|
1538
1528
|
warnedScope = true;
|
|
1539
1529
|
console.warn('pivotkit: a template marked deletable without a scope is listed under "My views"; give shared views scope: "shared"');
|
|
1540
1530
|
}
|
|
1541
|
-
out.push({ name, view, deletable: deletable && hostDeletes, scope: scoped ? t.scope : deletable ? "user" : "shared" });
|
|
1531
|
+
out.push({ name, view, deletable: deletable && hostDeletes, scope: scoped ? t.scope : deletable ? "user" : "shared", ...made });
|
|
1542
1532
|
}
|
|
1543
1533
|
}
|
|
1544
1534
|
const all = [...out, ...stored.map((t) => ({ name: t.name, view: t.view, scope: (
|
|
1545
1535
|
/** @type {const} */
|
|
1546
1536
|
"user"
|
|
1547
|
-
), deletable: true, at: t.at, ...t.sourceId ? { sourceId: t.sourceId } : {} }))];
|
|
1537
|
+
), deletable: true, at: t.at, ...t.sourceId ? { sourceId: t.sourceId } : {}, ...t.sheet ? { sheet: t.sheet } : {} }))];
|
|
1548
1538
|
const names = plainNames(all.map((t) => t.name));
|
|
1549
1539
|
return all.flatMap((t, i) => names[i] ? [{ ...t, name: (
|
|
1550
1540
|
/** @type {string} */
|
|
@@ -1601,7 +1591,7 @@ import React9, { useEffect as useEffect7, useMemo as useMemo4, useRef as useRef7
|
|
|
1601
1591
|
import { fieldLabel as fieldLabel3 } from "pivotkit-core";
|
|
1602
1592
|
|
|
1603
1593
|
// src/unused-load.js
|
|
1604
|
-
var UNUSED_TEXTS_OF = Object.freeze({ de: () => import("./chunks/unused-texts-de-
|
|
1594
|
+
var UNUSED_TEXTS_OF = Object.freeze({ de: () => import("./chunks/unused-texts-de-6YVPTNVS.js").then((m) => m.de) });
|
|
1605
1595
|
var pending2 = /* @__PURE__ */ new Map();
|
|
1606
1596
|
var loaded2 = /* @__PURE__ */ new Map();
|
|
1607
1597
|
var unusedNow = (lang) => loaded2.get(lang) ?? null;
|
|
@@ -1609,7 +1599,7 @@ function loadUnused(lang) {
|
|
|
1609
1599
|
let p = pending2.get(lang);
|
|
1610
1600
|
if (!p) {
|
|
1611
1601
|
const own2 = Object.hasOwn(UNUSED_TEXTS_OF, lang) ? UNUSED_TEXTS_OF[lang]().catch(() => null) : null;
|
|
1612
|
-
p = Promise.all([import("./chunks/unused-texts-
|
|
1602
|
+
p = Promise.all([import("./chunks/unused-texts-Y4R67XSN.js"), own2]).then(
|
|
1613
1603
|
([mod, texts]) => {
|
|
1614
1604
|
const out = { mod, lang: texts };
|
|
1615
1605
|
loaded2.set(lang, out);
|
|
@@ -2089,7 +2079,7 @@ function Toolbar(props) {
|
|
|
2089
2079
|
return /* @__PURE__ */ React10.createElement("div", { className: `pk-toolbar${wrap ? " pk-wrap" : ""}`, role: "toolbar", "aria-label": labels.toolbar, ref: bar, "data-overflow": hidden.size }, size === "narrow" ? /* @__PURE__ */ React10.createElement("button", { type: "button", className: "pk-btn", onClick: onShowFields, "data-testid": "show-fields", "data-pk-opener": "fields" }, /* @__PURE__ */ React10.createElement(Icon, { name: "panel" }), /* @__PURE__ */ React10.createElement("span", { className: "pk-btn-text" }, labels.showFields)) : null, /* @__PURE__ */ React10.createElement("div", { className: "pk-segmented", role: "group", "aria-label": labels.view }, /* @__PURE__ */ React10.createElement("button", { type: "button", "aria-pressed": view.display === "table", onClick: () => onDisplay("table"), "data-testid": "show-table" }, /* @__PURE__ */ React10.createElement(Icon, { name: "table" }), /* @__PURE__ */ React10.createElement("span", null, labels.table)), /* @__PURE__ */ React10.createElement("button", { type: "button", "aria-pressed": view.display === "chart", onClick: () => onDisplay("chart"), "data-testid": "show-chart" }, /* @__PURE__ */ React10.createElement(Icon, { name: (
|
|
2090
2080
|
/** @type {any} */
|
|
2091
2081
|
drawnIcon
|
|
2092
|
-
) }), /* @__PURE__ */ React10.createElement("span", null, labels.chart))), buttons("chart"), /* @__PURE__ */ React10.createElement("span", { className: "pk-sep", "aria-hidden": "true" }), /* @__PURE__ */ React10.createElement("span", { className: "pk-toolbar-pair" }, /* @__PURE__ */ React10.createElement(TextButton, { icon: "undo", label: labels.undo, onClick: onUndo, disabled: !canUndo, testId: "undo", shortcut: `${mod}Z` }), /* @__PURE__ */ React10.createElement(TextButton, { icon: "redo", label: labels.redo, onClick: onRedo, disabled: !canRedo, testId: "redo", shortcut: `${mod}\u21E7Z` })), buttons("history"), /* @__PURE__ */ React10.createElement("span", { className: "pk-grow" }), end.slice(0, at), wrap ? null : name, end.slice(at), /* @__PURE__ */ React10.createElement(MenuButton, { label: labels.exportLabel, icon: "download", text: labels.exportLabel, role: "dialog", align: "end", testId: "export" }, (close) => /* @__PURE__ */ React10.createElement(MenuPanel, { name: "ExportPanel", loadingText: labels.loadingMenu, props: { labels, onExport, chartReady, display: view.display, empty, prepare: props.prepareExport, close } })), hidden.size > 0 ? /* @__PURE__ */ React10.createElement(MenuButton, { label: labels.more, icon: "more", text: labels.more, align: "end", testId: "more", buttonRef: more, arrowOpens: true, mark: hidden.has("views") && loadedView?.changed ? changedMark("more-changed") : hidden.has("data") ? loadedMark("more-loaded") : null }, moreGroups) : null, wrap ? name : null, panel ? /* @__PURE__ */ React10.createElement(Popover, { open: true, anchor: more, onClose: closePanel, label: panel === "chartType" ? chartTypeText : panel === "views" ? labels.views : panel === "data" ? labels.data : labels.options, role: "dialog", align: "end", className: panel === "chartType" ? "pk-chart-menu" : void 0 }, panels[panel](closePanel)) : null);
|
|
2082
|
+
) }), /* @__PURE__ */ React10.createElement("span", null, labels.chart))), buttons("chart"), /* @__PURE__ */ React10.createElement("span", { className: "pk-sep", "aria-hidden": "true" }), /* @__PURE__ */ React10.createElement("span", { className: "pk-toolbar-pair" }, /* @__PURE__ */ React10.createElement(TextButton, { icon: "undo", label: labels.undo, onClick: onUndo, disabled: !canUndo, testId: "undo", shortcut: `${mod}Z` }), /* @__PURE__ */ React10.createElement(TextButton, { icon: "redo", label: labels.redo, onClick: onRedo, disabled: !canRedo, testId: "redo", shortcut: `${mod}\u21E7Z` })), buttons("history"), /* @__PURE__ */ React10.createElement("span", { className: "pk-grow" }), end.slice(0, at), wrap ? null : name, end.slice(at), /* @__PURE__ */ React10.createElement(MenuButton, { label: labels.exportLabel, icon: "download", text: labels.exportLabel, role: "dialog", align: "end", testId: "export" }, (close) => /* @__PURE__ */ React10.createElement(MenuPanel, { name: "ExportPanel", loadingText: labels.loadingMenu, props: { labels, onExport, chartReady, display: view.display, empty, dataExport: props.dataExport, prepare: props.prepareExport, close } })), hidden.size > 0 ? /* @__PURE__ */ React10.createElement(MenuButton, { label: labels.more, icon: "more", text: labels.more, align: "end", testId: "more", buttonRef: more, arrowOpens: true, mark: hidden.has("views") && loadedView?.changed ? changedMark("more-changed") : hidden.has("data") ? loadedMark("more-loaded") : null }, moreGroups) : null, wrap ? name : null, panel ? /* @__PURE__ */ React10.createElement(Popover, { open: true, anchor: more, onClose: closePanel, label: panel === "chartType" ? chartTypeText : panel === "views" ? labels.views : panel === "data" ? labels.data : labels.options, role: "dialog", align: "end", className: panel === "chartType" ? "pk-chart-menu" : void 0 }, panels[panel](closePanel)) : null);
|
|
2093
2083
|
}
|
|
2094
2084
|
|
|
2095
2085
|
// src/use-export.js
|
|
@@ -2218,9 +2208,12 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2218
2208
|
const start = useMemo6(() => json(initial), [json, initial]);
|
|
2219
2209
|
const [state, setState] = useState9(() => initialState ?? createState(schema, start));
|
|
2220
2210
|
const viewKey = controlled ? JSON.stringify(view) : null;
|
|
2221
|
-
const [
|
|
2222
|
-
|
|
2223
|
-
|
|
2211
|
+
const [echo, setEcho] = useState9(() => ({ over: viewKey, pending: initialState ? [initialState.present] : [] }));
|
|
2212
|
+
let pending3 = echo.pending;
|
|
2213
|
+
if (viewKey !== echo.over) {
|
|
2214
|
+
const index = viewKey === null ? -1 : pending3.indexOf(json(JSON.parse(viewKey)));
|
|
2215
|
+
pending3 = index < 0 ? [] : pending3.slice(index + 1);
|
|
2216
|
+
setEcho({ over: viewKey, pending: pending3 });
|
|
2224
2217
|
}
|
|
2225
2218
|
const shown = useMemo6(() => {
|
|
2226
2219
|
if (viewKey !== null) {
|
|
@@ -2232,14 +2225,17 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2232
2225
|
/** @type {import("pivotkit-core").View} */
|
|
2233
2226
|
JSON.parse(shown)
|
|
2234
2227
|
), [shown]);
|
|
2235
|
-
const
|
|
2228
|
+
const waiting = viewKey !== null && pending3.length > 0 && state.schema === schema;
|
|
2229
|
+
const live = useMemo6(() => waiting ? state : settle(state, { schema, start, shown, outside: outsideNote }), [waiting, state, schema, start, shown, outsideNote]);
|
|
2236
2230
|
const apply = useCallback6(
|
|
2237
2231
|
(next) => {
|
|
2238
2232
|
setState(next);
|
|
2239
|
-
|
|
2233
|
+
if (viewKey !== null) {
|
|
2234
|
+
setEcho((previous) => ({ over: viewKey, pending: [...previous.over === viewKey ? previous.pending : pending3, next.present] }));
|
|
2235
|
+
}
|
|
2240
2236
|
onViewChange?.(JSON.parse(next.present));
|
|
2241
2237
|
},
|
|
2242
|
-
[onViewChange, viewKey]
|
|
2238
|
+
[onViewChange, viewKey, pending3]
|
|
2243
2239
|
);
|
|
2244
2240
|
const commit = useCallback6(
|
|
2245
2241
|
(next, note, tag) => {
|
|
@@ -2282,9 +2278,7 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2282
2278
|
[live, apply]
|
|
2283
2279
|
);
|
|
2284
2280
|
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]);
|
|
2281
|
+
const snapshot = useCallback6(() => live, [live]);
|
|
2288
2282
|
const earlier = useCallback6(() => live.past.map((p) => JSON.parse(p.view)), [live.past]);
|
|
2289
2283
|
const canUndo = live.past.length > 0;
|
|
2290
2284
|
const canRedo = live.future.length > 0;
|
|
@@ -2408,7 +2402,7 @@ function measureFit(el, m, fit) {
|
|
|
2408
2402
|
import React11, { useCallback as useCallback8, useEffect as useEffect10, useMemo as useMemo7, useRef as useRef10, useState as useState11 } from "react";
|
|
2409
2403
|
import { fieldItems, fieldLabel as fieldLabel4 } from "pivotkit-core";
|
|
2410
2404
|
function fieldState(view, field, encoded, locale, labels, sourceType) {
|
|
2411
|
-
const items = filtersOf(view, field, ["
|
|
2405
|
+
const items = filtersOf(view, field, ["in"]).filter((f) => !isEmptyPick(f));
|
|
2412
2406
|
const compared = filtersOf(view, field, ["compare"]);
|
|
2413
2407
|
const info = items.length || compared.length ? fieldItems(encoded, field, { view, locale }) : null;
|
|
2414
2408
|
let summary = null;
|
|
@@ -2419,7 +2413,7 @@ function fieldState(view, field, encoded, locale, labels, sourceType) {
|
|
|
2419
2413
|
const labelOf = (v) => info?.items.find((i) => i.value === v)?.label;
|
|
2420
2414
|
const date = sourceType === "date";
|
|
2421
2415
|
const span = date ? dateSpan(encoded, sourceOf(view, field)) : null;
|
|
2422
|
-
const rules = filtersOf(view, field, ["relative", "compare", "
|
|
2416
|
+
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
2417
|
const top = filtersOf(view, field, ["top"])[0] ?? null;
|
|
2424
2418
|
const condition = filtersOf(view, field, ["value"])[0] ?? null;
|
|
2425
2419
|
return { summary, rules, top, condition, sort: sortOf(view, field) };
|
|
@@ -2679,7 +2673,7 @@ function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap,
|
|
|
2679
2673
|
}
|
|
2680
2674
|
|
|
2681
2675
|
// src/PivotReport.jsx
|
|
2682
|
-
var savedKeyOf = (t) => JSON.stringify([t.scope, t.store, t.storeSource ?? null, t.sourceId ?? null, t.name]);
|
|
2676
|
+
var savedKeyOf = (t) => JSON.stringify([t.scope, t.store, t.storeSource ?? null, t.storeSheet ?? null, t.sourceId ?? null, t.name]);
|
|
2683
2677
|
function sizeOf(width) {
|
|
2684
2678
|
return width < 640 ? "narrow" : width < 1024 ? "medium" : "wide";
|
|
2685
2679
|
}
|
|
@@ -2738,6 +2732,8 @@ var DEFER_ROWS = 1e4;
|
|
|
2738
2732
|
var dataOf = (d) => Array.isArray(d) || Array.isArray(d?.columns) ? d : [];
|
|
2739
2733
|
var rowsOf = (d) => Array.isArray(d) ? d.length : d?.data?.[0]?.length ?? 0;
|
|
2740
2734
|
var NO_STEPS = Object.freeze({ past: [], future: [] });
|
|
2735
|
+
var NO_SHEETS = Object.freeze([]);
|
|
2736
|
+
var SHEET_GONE = "\0";
|
|
2741
2737
|
var unusedNotes = (issues, raw) => issues.filter((i) => (i.code ?? (i.message === "unknown key" ? "unknownKey" : "")) !== "unknownKey" || !["name", "description"].includes(i.path)).map((issue) => ({ issue, raw }));
|
|
2742
2738
|
function PivotReport(props) {
|
|
2743
2739
|
const { loading: loading2 = false, data, encoded } = props;
|
|
@@ -2809,10 +2805,12 @@ function Report(props) {
|
|
|
2809
2805
|
theme = "auto",
|
|
2810
2806
|
height = 640,
|
|
2811
2807
|
limits: limitsProp,
|
|
2808
|
+
importLimits: importLimitsProp,
|
|
2812
2809
|
className,
|
|
2813
2810
|
fileName = "pivot",
|
|
2814
2811
|
fieldDefaults,
|
|
2815
2812
|
onExport,
|
|
2813
|
+
exportData = false,
|
|
2816
2814
|
label,
|
|
2817
2815
|
tips: tipsProp = "on",
|
|
2818
2816
|
storageKey,
|
|
@@ -2840,7 +2838,11 @@ function Report(props) {
|
|
|
2840
2838
|
const hostSourceId = typeof sourceProp?.id === "string" && sourceProp.id ? sourceProp.id : void 0;
|
|
2841
2839
|
const hostSourceName = typeof sourceProp?.name === "string" && sourceProp.name ? sourceProp.name : void 0;
|
|
2842
2840
|
const [job, setJob] = useState12(
|
|
2843
|
-
/** @type {
|
|
2841
|
+
/** @type {import("./import-host.jsx").ImportJob | null} */
|
|
2842
|
+
null
|
|
2843
|
+
);
|
|
2844
|
+
const afterSheet = useRef11(
|
|
2845
|
+
/** @type {(() => void) | null} */
|
|
2844
2846
|
null
|
|
2845
2847
|
);
|
|
2846
2848
|
const [dragging, setDragging] = useState12(false);
|
|
@@ -2857,7 +2859,9 @@ function Report(props) {
|
|
|
2857
2859
|
const baseLabels = useMemo8(() => resolveLabels(locale, JSON.parse(labelsKey)), [locale, labelsKey]);
|
|
2858
2860
|
const typesKey = JSON.stringify(typesOf(fieldDefaults));
|
|
2859
2861
|
const limitsKey = JSON.stringify(limitsProp ?? null);
|
|
2860
|
-
const
|
|
2862
|
+
const hostLimits = useMemo8(() => JSON.parse(limitsKey) ?? void 0, [limitsKey]);
|
|
2863
|
+
const importLimitsKey = JSON.stringify(importLimitsProp ?? null);
|
|
2864
|
+
const fileLimits = useMemo8(() => importLimitsOf(hostLimits, JSON.parse(importLimitsKey)), [hostLimits, importLimitsKey]);
|
|
2861
2865
|
const root = useRef11(
|
|
2862
2866
|
/** @type {HTMLDivElement | null} */
|
|
2863
2867
|
null
|
|
@@ -2933,12 +2937,12 @@ function Report(props) {
|
|
|
2933
2937
|
const source = useMemo8(() => {
|
|
2934
2938
|
try {
|
|
2935
2939
|
const types2 = JSON.parse(typesKey);
|
|
2936
|
-
const enc = encodedProp ?? measured("encode", () => encode(dataOf(data), { timeZone: timeZone ?? "UTC", limits, ...types2 ? { types: types2 } : {} }));
|
|
2940
|
+
const enc = encodedProp ?? measured("encode", () => encode(dataOf(data), { timeZone: timeZone ?? "UTC", limits: hostLimits, ...types2 ? { types: types2 } : {} }));
|
|
2937
2941
|
return { encoded: enc, error: null };
|
|
2938
2942
|
} catch (error2) {
|
|
2939
2943
|
return { encoded: encode([]), error: error2 };
|
|
2940
2944
|
}
|
|
2941
|
-
}, [encodedProp, dataIdentity, timeZone,
|
|
2945
|
+
}, [encodedProp, dataIdentity, timeZone, hostLimits, typesKey]);
|
|
2942
2946
|
const keepKey = allowImport && typeof storageKey === "string" && storageKey ? storageKey : null;
|
|
2943
2947
|
const hostData = hostIdentity({ dataKey, sourceId: hostSourceId, schemaKey: schemaKeyOf(source.encoded) });
|
|
2944
2948
|
const [kept2] = useState12(() => keepKey ? keptData(keepKey, hostData) : null);
|
|
@@ -2956,7 +2960,11 @@ function Report(props) {
|
|
|
2956
2960
|
);
|
|
2957
2961
|
const sourceId = imported ? imported.source.id : hostSourceId;
|
|
2958
2962
|
const sourceName = imported ? imported.source.name : hostSourceName;
|
|
2963
|
+
const shownSheet = imported?.sheet ?? null;
|
|
2964
|
+
const shownSheets = imported?.sheets ?? NO_SHEETS;
|
|
2965
|
+
const sourceParams = shownSheet ? { sheet: shownSheet } : void 0;
|
|
2959
2966
|
const encoded = imported ? imported.encoded : source.encoded;
|
|
2967
|
+
const limits = imported ? fileLimits : hostLimits;
|
|
2960
2968
|
const fieldNamesKey = encoded.schema.fields.map((f) => f.name).join("\0");
|
|
2961
2969
|
const labels = useMemo8(() => {
|
|
2962
2970
|
const fields2 = displayNames(info, fieldNamesKey ? fieldNamesKey.split("\0") : []);
|
|
@@ -3036,7 +3044,6 @@ function Report(props) {
|
|
|
3036
3044
|
newStep();
|
|
3037
3045
|
announce(labels.toastReset, { action: { label: labels.undo, run: () => undoLater.current() } });
|
|
3038
3046
|
}, [history, labels, announce, newStep]);
|
|
3039
|
-
const param = linkParam(storageKey);
|
|
3040
3047
|
const [opening, setOpening] = useState12(false);
|
|
3041
3048
|
const appliedLink = useRef11(
|
|
3042
3049
|
/** @type {string | null} */
|
|
@@ -3112,7 +3119,7 @@ function Report(props) {
|
|
|
3112
3119
|
return;
|
|
3113
3120
|
}
|
|
3114
3121
|
const page = here();
|
|
3115
|
-
const link = shareLink ? readLinkParam(page?.hash ?? "",
|
|
3122
|
+
const link = shareLink ? readLinkParam(page?.hash ?? "", storageKey) : null;
|
|
3116
3123
|
if (link) {
|
|
3117
3124
|
openLink(link);
|
|
3118
3125
|
} else if (persistView === "session") {
|
|
@@ -3133,14 +3140,14 @@ function Report(props) {
|
|
|
3133
3140
|
return void 0;
|
|
3134
3141
|
}
|
|
3135
3142
|
const onHash = () => {
|
|
3136
|
-
const link = readLinkParam(here()?.hash ?? "",
|
|
3143
|
+
const link = readLinkParam(here()?.hash ?? "", storageKey);
|
|
3137
3144
|
if (link && link !== appliedLink.current) {
|
|
3138
3145
|
openLink(link, true);
|
|
3139
3146
|
}
|
|
3140
3147
|
};
|
|
3141
3148
|
window.addEventListener("hashchange", onHash);
|
|
3142
3149
|
return () => window.removeEventListener("hashchange", onHash);
|
|
3143
|
-
}, [shareLink,
|
|
3150
|
+
}, [shareLink, storageKey, openLink]);
|
|
3144
3151
|
useEffect11(() => {
|
|
3145
3152
|
if (persistView === "session") {
|
|
3146
3153
|
writeStoredView(storageKey, sessionStore(), JSON.parse(history.viewKey));
|
|
@@ -3204,6 +3211,15 @@ function Report(props) {
|
|
|
3204
3211
|
}
|
|
3205
3212
|
}, [encoded, view, locale, limits]);
|
|
3206
3213
|
const result = computed.result;
|
|
3214
|
+
const unusedLocale = useMemo8(() => {
|
|
3215
|
+
const requested = view.formatting?.locale || locale;
|
|
3216
|
+
try {
|
|
3217
|
+
new Intl.NumberFormat(requested);
|
|
3218
|
+
return requested;
|
|
3219
|
+
} catch {
|
|
3220
|
+
return "en-US";
|
|
3221
|
+
}
|
|
3222
|
+
}, [view.formatting?.locale, locale]);
|
|
3207
3223
|
const plan = useMemo8(() => chartPlan(view, encoded), [view, encoded]);
|
|
3208
3224
|
const chartComputed = useMemo8(() => {
|
|
3209
3225
|
if (!plan.swap || view.display !== "chart" || !result) {
|
|
@@ -3346,10 +3362,11 @@ function Report(props) {
|
|
|
3346
3362
|
},
|
|
3347
3363
|
[view, placeOptions, commit, nameOf]
|
|
3348
3364
|
);
|
|
3349
|
-
const
|
|
3365
|
+
const filterField = useCallback9(
|
|
3350
3366
|
(field, anchor) => {
|
|
3351
3367
|
const options = placeOptions(field, "filters");
|
|
3352
|
-
const
|
|
3368
|
+
const name = options.groupName ?? field;
|
|
3369
|
+
const draft = filterZoneFields(view).some((f) => same(f, name)) ? void 0 : addField(view, field, "filters", options);
|
|
3353
3370
|
const opener = size === "narrow" ? (
|
|
3354
3371
|
/** @type {HTMLElement | null} */
|
|
3355
3372
|
root.current?.querySelector("[data-pk-opener='fields']") ?? null
|
|
@@ -3359,7 +3376,7 @@ function Report(props) {
|
|
|
3359
3376
|
}
|
|
3360
3377
|
const target = opener ?? anchor;
|
|
3361
3378
|
if (target) {
|
|
3362
|
-
setFilterTarget({ field:
|
|
3379
|
+
setFilterTarget({ field: name, anchor: target, base: draft });
|
|
3363
3380
|
}
|
|
3364
3381
|
},
|
|
3365
3382
|
[placeOptions, view, size]
|
|
@@ -3405,7 +3422,7 @@ function Report(props) {
|
|
|
3405
3422
|
},
|
|
3406
3423
|
[result, encodedProp, imported, data, drillDownLimit, onCellClick, drillDown, defaultsOf, nameOf, infoOf]
|
|
3407
3424
|
);
|
|
3408
|
-
const doExport = useExport({ fileName, result, locale, labels, limits, root, chartRef, announce, onExport });
|
|
3425
|
+
const doExport = useExport({ fileName, result, encoded, exportData, locale, labels, limits, root, chartRef, announce, onExport, title: viewName, source: sourceName, loadECharts });
|
|
3409
3426
|
const requestImport = () => loadImport().then((m) => (flushSync(() => setImportMod(() => m)), m));
|
|
3410
3427
|
const api = {
|
|
3411
3428
|
imported,
|
|
@@ -3424,7 +3441,7 @@ function Report(props) {
|
|
|
3424
3441
|
locale,
|
|
3425
3442
|
plugins,
|
|
3426
3443
|
worker: importWorker,
|
|
3427
|
-
limits,
|
|
3444
|
+
limits: fileLimits,
|
|
3428
3445
|
timeZone,
|
|
3429
3446
|
onDataLoad,
|
|
3430
3447
|
announce,
|
|
@@ -3432,7 +3449,9 @@ function Report(props) {
|
|
|
3432
3449
|
undo: () => undoLater.current(),
|
|
3433
3450
|
box: () => root.current?.getBoundingClientRect(),
|
|
3434
3451
|
pick: () => importMod?.pickFile(fileInput.current),
|
|
3435
|
-
load: requestImport
|
|
3452
|
+
load: requestImport,
|
|
3453
|
+
// what waits for another sheet of the file to be read (openOnSheet): it runs once that data is shown
|
|
3454
|
+
afterData: (run) => void (afterSheet.current = run)
|
|
3436
3455
|
};
|
|
3437
3456
|
useEffect11(() => {
|
|
3438
3457
|
apiNow.current = api;
|
|
@@ -3490,10 +3509,13 @@ function Report(props) {
|
|
|
3490
3509
|
viewName,
|
|
3491
3510
|
sourceId,
|
|
3492
3511
|
sourceName,
|
|
3512
|
+
sourceParams,
|
|
3513
|
+
// a view file that names another sheet of the workbook shown reads that sheet first
|
|
3514
|
+
viaSheet: (made, name, file) => viaSheet(made, name, () => loadLater.current?.({ file })),
|
|
3493
3515
|
schemaUrl,
|
|
3494
3516
|
encoded,
|
|
3495
3517
|
shareLink,
|
|
3496
|
-
|
|
3518
|
+
linkKey: storageKey,
|
|
3497
3519
|
root,
|
|
3498
3520
|
fileName,
|
|
3499
3521
|
onExport,
|
|
@@ -3503,9 +3525,10 @@ function Report(props) {
|
|
|
3503
3525
|
onSourceSwitch,
|
|
3504
3526
|
applyLoaded
|
|
3505
3527
|
};
|
|
3528
|
+
const viaSheet = (made, name, then) => imported && importMod ? importMod.openOnSheet(apiNow.current, made, name, then) : "none";
|
|
3506
3529
|
const loadTemplate = useCallback9(
|
|
3507
3530
|
(t) => {
|
|
3508
|
-
const tag = { name: t.name, scope: t.scope === "user" ? "user" : "shared", store: t.at !== void 0, storeSource: t.sourceId ?? null, sourceId };
|
|
3531
|
+
const tag = { name: t.name, scope: t.scope === "user" ? "user" : "shared", store: t.at !== void 0, storeSource: t.sourceId ?? null, storeSheet: t.sheet ?? null, sourceId };
|
|
3509
3532
|
remember(tag, history.keyOf(t.view));
|
|
3510
3533
|
commit(t.view, { step: "template", name: t.name }, tag);
|
|
3511
3534
|
const over = zoneOverLimit(t.view, limits);
|
|
@@ -3518,6 +3541,31 @@ function Report(props) {
|
|
|
3518
3541
|
},
|
|
3519
3542
|
[commit, labels, announce, limits, locale, history, remember, sourceId, encoded, leaveOut]
|
|
3520
3543
|
);
|
|
3544
|
+
const openTemplate = (t) => {
|
|
3545
|
+
const how = viaSheet({ id: t.sourceId ?? t.sheetOf, sheet: t.sheet }, t.name, () => loadLater.current?.({ template: t }));
|
|
3546
|
+
if (how !== "switch") {
|
|
3547
|
+
loadTemplate(how === "missing" ? { ...t, sheet: SHEET_GONE } : t);
|
|
3548
|
+
}
|
|
3549
|
+
};
|
|
3550
|
+
const loadLater = useRef11(
|
|
3551
|
+
/** @type {((what: { template?: any, file?: object }) => void) | null} */
|
|
3552
|
+
null
|
|
3553
|
+
);
|
|
3554
|
+
useEffect11(() => {
|
|
3555
|
+
loadLater.current = ({ template, file }) => {
|
|
3556
|
+
if (template) {
|
|
3557
|
+
loadTemplate(template);
|
|
3558
|
+
} else if (file) {
|
|
3559
|
+
const loaded3 = viewFromObject(file, encoded, { limits, sourceId });
|
|
3560
|
+
applyLoaded(loaded3);
|
|
3561
|
+
}
|
|
3562
|
+
};
|
|
3563
|
+
const run = afterSheet.current;
|
|
3564
|
+
if (run && imported) {
|
|
3565
|
+
afterSheet.current = null;
|
|
3566
|
+
run();
|
|
3567
|
+
}
|
|
3568
|
+
}, [imported, loadTemplate, encoded, limits, sourceId, applyLoaded]);
|
|
3521
3569
|
const newReport = () => {
|
|
3522
3570
|
if (empty) {
|
|
3523
3571
|
return;
|
|
@@ -3533,12 +3581,19 @@ function Report(props) {
|
|
|
3533
3581
|
const subscribeViews = useCallback9((callback) => viewStore ? subscribeItem(storeName, callback) : () => {
|
|
3534
3582
|
}, [viewStore, storeName]);
|
|
3535
3583
|
const viewsText = useSyncExternalStore3(subscribeViews, () => viewStore ? readItem(storeName, localStore()) : null, () => null);
|
|
3536
|
-
const entries = useMemo8(
|
|
3584
|
+
const entries = useMemo8(
|
|
3585
|
+
() => templateEntries(templates, viewStore && menus ? menus.storedViews(viewsText, sourceId, { sheet: shownSheet, sheets: shownSheets }) : [], Boolean(onDeleteTemplate)),
|
|
3586
|
+
[templates, viewStore, menus, viewsText, sourceId, shownSheet, shownSheets, onDeleteTemplate]
|
|
3587
|
+
);
|
|
3537
3588
|
const templateActions = {
|
|
3538
3589
|
view,
|
|
3539
3590
|
announce,
|
|
3540
3591
|
locale,
|
|
3541
3592
|
sourceId,
|
|
3593
|
+
// the sheet of a workbook shown, which a view saved into the browser store names, and the data
|
|
3594
|
+
// shown as the host's callbacks get it
|
|
3595
|
+
sheet: shownSheet,
|
|
3596
|
+
source: sourceId ? { id: sourceId, ...sourceName ? { name: sourceName } : {}, ...sourceParams ? { params: sourceParams } : {} } : null,
|
|
3542
3597
|
viewsText,
|
|
3543
3598
|
store: viewStore,
|
|
3544
3599
|
keep: (text) => writeItem(storeName, localStore(), text),
|
|
@@ -3708,6 +3763,8 @@ function Report(props) {
|
|
|
3708
3763
|
commit(setChart(view, "auto"), { step: "chart", type: "auto" });
|
|
3709
3764
|
} else if (action === "saveTemplate") {
|
|
3710
3765
|
setViewsRequest((n) => n + 1);
|
|
3766
|
+
} else if (action === "colSubtotalsOff") {
|
|
3767
|
+
commit(setTotal(view, "colSubtotals", false), { step: "totals" });
|
|
3711
3768
|
}
|
|
3712
3769
|
};
|
|
3713
3770
|
const cancelLink = () => {
|
|
@@ -3773,7 +3830,7 @@ function Report(props) {
|
|
|
3773
3830
|
}
|
|
3774
3831
|
},
|
|
3775
3832
|
onNote: (text) => announce(text),
|
|
3776
|
-
onFilter:
|
|
3833
|
+
onFilter: filterField,
|
|
3777
3834
|
nameOf,
|
|
3778
3835
|
info,
|
|
3779
3836
|
showInfo: fieldSwitch.on,
|
|
@@ -3813,10 +3870,11 @@ function Report(props) {
|
|
|
3813
3870
|
folding,
|
|
3814
3871
|
share,
|
|
3815
3872
|
templates: entries,
|
|
3816
|
-
onLoadTemplate:
|
|
3873
|
+
onLoadTemplate: openTemplate,
|
|
3817
3874
|
templateActions,
|
|
3818
3875
|
onExport: doExport,
|
|
3819
3876
|
prepareExport: prepareExporters,
|
|
3877
|
+
dataExport: exportData,
|
|
3820
3878
|
chartReady: view.display === "chart" && chartReady,
|
|
3821
3879
|
empty,
|
|
3822
3880
|
onShowFields: () => setDrawer(true),
|
|
@@ -3867,7 +3925,7 @@ function Report(props) {
|
|
|
3867
3925
|
}
|
|
3868
3926
|
},
|
|
3869
3927
|
labels,
|
|
3870
|
-
locale,
|
|
3928
|
+
locale: result?.locale ?? unusedLocale,
|
|
3871
3929
|
narrow: size === "narrow",
|
|
3872
3930
|
quiet: unusedSaid && !fromHost
|
|
3873
3931
|
}
|
|
@@ -3880,7 +3938,7 @@ function Report(props) {
|
|
|
3880
3938
|
onAction: runTip,
|
|
3881
3939
|
focusFallback: () => root.current?.focus({ preventScroll: true })
|
|
3882
3940
|
}
|
|
3883
|
-
), showTable && view.values.length ? /* @__PURE__ */ React12.createElement("p", { id: hintId, className: "pk-sr", "data-testid": "cell-hint" }, labels.tips.cells) : null, /* @__PURE__ */ React12.createElement("div", { className: "pk-result-head" }, big.enlarged ? /* @__PURE__ */ React12.createElement("p", { className: "pk-enlarged-fields", "data-testid": "enlarged-fields" }, summaryText) : null, /* @__PURE__ */ React12.createElement("span", { className: "pk-grow" }), /* @__PURE__ */ React12.createElement("button", { type: "button", className: "pk-btn pk-pressable pk-small-btn", "data-pk-on": big.enlarged ? "" : void 0, onClick: big.toggleEnlarged, "data-testid": "enlarge" }, /* @__PURE__ */ React12.createElement(Icon, { name: "enlarge", size: 14 }), /* @__PURE__ */ React12.createElement("span", { className: "pk-btn-text" }, big.enlarged ? labels.reduce : labels.enlarge)), big.fullOk ? /* @__PURE__ */ React12.createElement("button", { type: "button", className: "pk-btn pk-pressable pk-small-btn", "aria-pressed": big.full, onClick: big.toggleFull, "data-testid": "full-screen" }, /* @__PURE__ */ React12.createElement(Icon, { name: "fullScreen", size: 14 }), /* @__PURE__ */ React12.createElement("span", { className: "pk-btn-text" }, labels.fullScreen)) : null), /* @__PURE__ */ React12.createElement("section", { className: "pk-result", "aria-label": view.display === "chart" ? labels.chart : labels.table }, loading2 || opening ? /* @__PURE__ */ React12.createElement(Skeleton, { text: labels.loadingReport }) : error ? /* @__PURE__ */ React12.createElement("div", { className: "pk-message pk-error", role: "alert" }, /* @__PURE__ */ React12.createElement(Icon, { name: "info" }), /* @__PURE__ */ React12.createElement("p", null, errorText(error, labels, locale))) : empty && view.display === "table" ? /* @__PURE__ */ React12.createElement(EmptyState, { labels, templates: entries, onTemplate:
|
|
3941
|
+
), showTable && view.values.length ? /* @__PURE__ */ React12.createElement("p", { id: hintId, className: "pk-sr", "data-testid": "cell-hint" }, labels.tips.cells) : null, /* @__PURE__ */ React12.createElement("div", { className: "pk-result-head" }, big.enlarged ? /* @__PURE__ */ React12.createElement("p", { className: "pk-enlarged-fields", "data-testid": "enlarged-fields" }, summaryText) : null, /* @__PURE__ */ React12.createElement("span", { className: "pk-grow" }), /* @__PURE__ */ React12.createElement("button", { type: "button", className: "pk-btn pk-pressable pk-small-btn", "data-pk-on": big.enlarged ? "" : void 0, onClick: big.toggleEnlarged, "data-testid": "enlarge" }, /* @__PURE__ */ React12.createElement(Icon, { name: "enlarge", size: 14 }), /* @__PURE__ */ React12.createElement("span", { className: "pk-btn-text" }, big.enlarged ? labels.reduce : labels.enlarge)), big.fullOk ? /* @__PURE__ */ React12.createElement("button", { type: "button", className: "pk-btn pk-pressable pk-small-btn", "aria-pressed": big.full, onClick: big.toggleFull, "data-testid": "full-screen" }, /* @__PURE__ */ React12.createElement(Icon, { name: "fullScreen", size: 14 }), /* @__PURE__ */ React12.createElement("span", { className: "pk-btn-text" }, labels.fullScreen)) : null), /* @__PURE__ */ React12.createElement("section", { className: "pk-result", "aria-label": view.display === "chart" ? labels.chart : labels.table }, loading2 || opening ? /* @__PURE__ */ React12.createElement(Skeleton, { text: labels.loadingReport }) : error ? /* @__PURE__ */ React12.createElement("div", { className: "pk-message pk-error", role: "alert" }, /* @__PURE__ */ React12.createElement(Icon, { name: "info" }), /* @__PURE__ */ React12.createElement("p", null, errorText(error, labels, locale))) : empty && view.display === "table" ? /* @__PURE__ */ React12.createElement(EmptyState, { labels, templates: entries, onTemplate: openTemplate, onLoad: allowImport ? () => requestImport().then((m) => m.pickFile(fileInput.current), () => announce(labels.menuFailed, { tone: "error" })) : void 0, noData: allowImport && fields.length === 0 }) : view.display === "chart" && chartResult ? /* @__PURE__ */ React12.createElement(
|
|
3884
3942
|
PivotChart,
|
|
3885
3943
|
{
|
|
3886
3944
|
result: chartResult,
|