pivotkit-react 0.5.0 → 0.6.1
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 +118 -2
- package/README.md +4 -1
- package/dist/chunks/{chunk-2AT72SLA.js → chunk-3LDE2GPG.js} +58 -34
- package/dist/chunks/{chunk-RIOSIYGC.js → chunk-JOWAEZAD.js} +6 -4
- package/dist/chunks/{chunk-U5Q5I2D5.js → chunk-TR2HROIK.js} +10 -3
- package/dist/chunks/chunk-W2KIPREL.js +36 -0
- package/dist/chunks/{chunk-3WUGQPWV.js → chunk-XN5HNKJ2.js} +10 -95
- package/dist/chunks/{chunk-4RS72AAA.js → chunk-YXLANLGL.js} +8 -2
- package/dist/chunks/{chunk-3E4NB5RZ.js → chunk-ZK5RVCHP.js} +21 -3
- package/dist/import-ui.js +68 -174
- package/dist/index.js +75 -28
- package/dist/labels.js +4 -4
- package/dist/menu-texts-de.js +1 -1
- package/dist/menus.js +338 -82
- package/dist/styles.css +1 -1
- package/package.json +3 -3
- package/types/drill-export.d.ts +3 -2
- package/types/drill-panel.d.ts +4 -2
- package/types/export-run.d.ts +8 -3
- package/types/export-scope.d.ts +47 -0
- package/types/field-info.d.ts +3 -10
- package/types/import-host.d.ts +37 -8
- package/types/import-labels.d.ts +20 -3
- package/types/import-module.d.ts +1 -1
- package/types/import-run.d.ts +0 -8
- package/types/import-steps.d.ts +8 -0
- package/types/import-ui.d.ts +21 -4
- package/types/index.d.ts +59 -12
- package/types/labels.d.ts +2 -22
- package/types/menu-fields.d.ts +9 -0
- package/types/menu-labels.d.ts +6 -0
- package/types/menu-ops.d.ts +28 -3
- package/types/names.d.ts +22 -8
- package/types/share-actions.d.ts +14 -0
- package/types/sheet-views.d.ts +60 -0
- package/types/templates.d.ts +21 -1
- package/types/toolbar-panels.d.ts +13 -6
- package/types/use-export.d.ts +2 -2
- package/types/view-history.d.ts +15 -0
- package/types/view-save.d.ts +10 -6
- package/types/view-store.d.ts +21 -11
- package/types/import-source.d.ts +0 -32
package/dist/index.js
CHANGED
|
@@ -76,7 +76,7 @@ import {
|
|
|
76
76
|
writeItem,
|
|
77
77
|
writeStoredView,
|
|
78
78
|
zoneOverLimit
|
|
79
|
-
} from "./chunks/chunk-
|
|
79
|
+
} from "./chunks/chunk-3LDE2GPG.js";
|
|
80
80
|
import {
|
|
81
81
|
FormNameContext,
|
|
82
82
|
Group,
|
|
@@ -92,7 +92,7 @@ import {
|
|
|
92
92
|
tabStops,
|
|
93
93
|
useIsoLayoutEffect,
|
|
94
94
|
useModal
|
|
95
|
-
} from "./chunks/chunk-
|
|
95
|
+
} from "./chunks/chunk-JOWAEZAD.js";
|
|
96
96
|
import {
|
|
97
97
|
MENU_TEXTS,
|
|
98
98
|
errorText,
|
|
@@ -101,7 +101,7 @@ import {
|
|
|
101
101
|
messageOf,
|
|
102
102
|
plural,
|
|
103
103
|
resolveLabels
|
|
104
|
-
} from "./chunks/chunk-
|
|
104
|
+
} from "./chunks/chunk-XN5HNKJ2.js";
|
|
105
105
|
|
|
106
106
|
// src/PivotReport.jsx
|
|
107
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";
|
|
@@ -457,7 +457,7 @@ function ChipList({ ids, children }) {
|
|
|
457
457
|
}
|
|
458
458
|
|
|
459
459
|
// src/field-info.js
|
|
460
|
-
import { fieldDefaultsFromSchema } from "pivotkit-core";
|
|
460
|
+
import { fieldDefaultsFromSchema, isIdentifierName } from "pivotkit-core";
|
|
461
461
|
var isObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
462
462
|
var own = (o, k) => isObject(o) && Object.hasOwn(o, k) ? o[k] : void 0;
|
|
463
463
|
var TYPES = Object.freeze(["string", "number", "date", "boolean"]);
|
|
@@ -544,15 +544,6 @@ function fieldMatches(field, query, info) {
|
|
|
544
544
|
}
|
|
545
545
|
return [field, info?.label, info?.description].some((t) => typeof t === "string" && t.toLowerCase().includes(query));
|
|
546
546
|
}
|
|
547
|
-
var IDENTIFIER_WORDS = Object.freeze(["id", "nr", "no", "number", "key", "#"]);
|
|
548
|
-
function isIdentifierName(name) {
|
|
549
|
-
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);
|
|
550
|
-
while (words.length > 1 && /^\d+$/.test(words[words.length - 1])) {
|
|
551
|
-
words.pop();
|
|
552
|
-
}
|
|
553
|
-
const last = words[words.length - 1];
|
|
554
|
-
return last !== void 0 && IDENTIFIER_WORDS.includes(last.toLowerCase());
|
|
555
|
-
}
|
|
556
547
|
var identifierColumns = /* @__PURE__ */ new WeakMap();
|
|
557
548
|
function isIdentifier(column) {
|
|
558
549
|
if (!column || column.type !== "number" || column.derived || !isIdentifierName(column.name)) {
|
|
@@ -1522,10 +1513,13 @@ function templateEntries(templates, stored, hostDeletes) {
|
|
|
1522
1513
|
continue;
|
|
1523
1514
|
}
|
|
1524
1515
|
let { name, view } = t;
|
|
1516
|
+
let made = {};
|
|
1525
1517
|
if (t.file !== void 0 && t.file !== null) {
|
|
1526
1518
|
const read = fromViewFile(t.file);
|
|
1527
1519
|
view = read.view;
|
|
1528
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 } : {} };
|
|
1529
1523
|
}
|
|
1530
1524
|
if (typeof name === "string" && name && view && typeof view === "object") {
|
|
1531
1525
|
const deletable = t.deletable === true;
|
|
@@ -1534,13 +1528,13 @@ function templateEntries(templates, stored, hostDeletes) {
|
|
|
1534
1528
|
warnedScope = true;
|
|
1535
1529
|
console.warn('pivotkit: a template marked deletable without a scope is listed under "My views"; give shared views scope: "shared"');
|
|
1536
1530
|
}
|
|
1537
|
-
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 });
|
|
1538
1532
|
}
|
|
1539
1533
|
}
|
|
1540
1534
|
const all = [...out, ...stored.map((t) => ({ name: t.name, view: t.view, scope: (
|
|
1541
1535
|
/** @type {const} */
|
|
1542
1536
|
"user"
|
|
1543
|
-
), 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 } : {} }))];
|
|
1544
1538
|
const names = plainNames(all.map((t) => t.name));
|
|
1545
1539
|
return all.flatMap((t, i) => names[i] ? [{ ...t, name: (
|
|
1546
1540
|
/** @type {string} */
|
|
@@ -2085,7 +2079,7 @@ function Toolbar(props) {
|
|
|
2085
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: (
|
|
2086
2080
|
/** @type {any} */
|
|
2087
2081
|
drawnIcon
|
|
2088
|
-
) }), /* @__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);
|
|
2089
2083
|
}
|
|
2090
2084
|
|
|
2091
2085
|
// src/use-export.js
|
|
@@ -2154,6 +2148,11 @@ import { emptyView, normalize } from "pivotkit-core";
|
|
|
2154
2148
|
// src/view-history.js
|
|
2155
2149
|
var tagFor = (tag, sourceId) => tag && tag.sourceId === sourceId ? tag : null;
|
|
2156
2150
|
var HISTORY_LIMIT = 100;
|
|
2151
|
+
var told = (pending3, view) => [...pending3, view].slice(-HISTORY_LIMIT);
|
|
2152
|
+
function answered(pending3, view) {
|
|
2153
|
+
const index = pending3.indexOf(view);
|
|
2154
|
+
return index < 0 ? [] : pending3.slice(index + 1);
|
|
2155
|
+
}
|
|
2157
2156
|
function createState(schema, start, current = start, tag = null) {
|
|
2158
2157
|
return { schema, start, present: current, past: [], future: [], tag };
|
|
2159
2158
|
}
|
|
@@ -2217,8 +2216,7 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2217
2216
|
const [echo, setEcho] = useState9(() => ({ over: viewKey, pending: initialState ? [initialState.present] : [] }));
|
|
2218
2217
|
let pending3 = echo.pending;
|
|
2219
2218
|
if (viewKey !== echo.over) {
|
|
2220
|
-
|
|
2221
|
-
pending3 = index < 0 ? [] : pending3.slice(index + 1);
|
|
2219
|
+
pending3 = viewKey === null ? [] : answered(pending3, json(JSON.parse(viewKey)));
|
|
2222
2220
|
setEcho({ over: viewKey, pending: pending3 });
|
|
2223
2221
|
}
|
|
2224
2222
|
const shown = useMemo6(() => {
|
|
@@ -2237,7 +2235,7 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2237
2235
|
(next) => {
|
|
2238
2236
|
setState(next);
|
|
2239
2237
|
if (viewKey !== null) {
|
|
2240
|
-
setEcho((previous) => ({ over: viewKey, pending:
|
|
2238
|
+
setEcho((previous) => ({ over: viewKey, pending: told(previous.over === viewKey ? previous.pending : pending3, next.present) }));
|
|
2241
2239
|
}
|
|
2242
2240
|
onViewChange?.(JSON.parse(next.present));
|
|
2243
2241
|
},
|
|
@@ -2679,7 +2677,7 @@ function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap,
|
|
|
2679
2677
|
}
|
|
2680
2678
|
|
|
2681
2679
|
// src/PivotReport.jsx
|
|
2682
|
-
var savedKeyOf = (t) => JSON.stringify([t.scope, t.store, t.storeSource ?? null, t.sourceId ?? null, t.name]);
|
|
2680
|
+
var savedKeyOf = (t) => JSON.stringify([t.scope, t.store, t.storeSource ?? null, t.storeSheet ?? null, t.sourceId ?? null, t.name]);
|
|
2683
2681
|
function sizeOf(width) {
|
|
2684
2682
|
return width < 640 ? "narrow" : width < 1024 ? "medium" : "wide";
|
|
2685
2683
|
}
|
|
@@ -2738,6 +2736,8 @@ var DEFER_ROWS = 1e4;
|
|
|
2738
2736
|
var dataOf = (d) => Array.isArray(d) || Array.isArray(d?.columns) ? d : [];
|
|
2739
2737
|
var rowsOf = (d) => Array.isArray(d) ? d.length : d?.data?.[0]?.length ?? 0;
|
|
2740
2738
|
var NO_STEPS = Object.freeze({ past: [], future: [] });
|
|
2739
|
+
var NO_SHEETS = Object.freeze([]);
|
|
2740
|
+
var SHEET_GONE = "\0";
|
|
2741
2741
|
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
2742
|
function PivotReport(props) {
|
|
2743
2743
|
const { loading: loading2 = false, data, encoded } = props;
|
|
@@ -2814,6 +2814,7 @@ function Report(props) {
|
|
|
2814
2814
|
fileName = "pivot",
|
|
2815
2815
|
fieldDefaults,
|
|
2816
2816
|
onExport,
|
|
2817
|
+
exportData = false,
|
|
2817
2818
|
label,
|
|
2818
2819
|
tips: tipsProp = "on",
|
|
2819
2820
|
storageKey,
|
|
@@ -2841,7 +2842,11 @@ function Report(props) {
|
|
|
2841
2842
|
const hostSourceId = typeof sourceProp?.id === "string" && sourceProp.id ? sourceProp.id : void 0;
|
|
2842
2843
|
const hostSourceName = typeof sourceProp?.name === "string" && sourceProp.name ? sourceProp.name : void 0;
|
|
2843
2844
|
const [job, setJob] = useState12(
|
|
2844
|
-
/** @type {
|
|
2845
|
+
/** @type {import("./import-host.jsx").ImportJob | null} */
|
|
2846
|
+
null
|
|
2847
|
+
);
|
|
2848
|
+
const afterSheet = useRef11(
|
|
2849
|
+
/** @type {(() => void) | null} */
|
|
2845
2850
|
null
|
|
2846
2851
|
);
|
|
2847
2852
|
const [dragging, setDragging] = useState12(false);
|
|
@@ -2959,6 +2964,9 @@ function Report(props) {
|
|
|
2959
2964
|
);
|
|
2960
2965
|
const sourceId = imported ? imported.source.id : hostSourceId;
|
|
2961
2966
|
const sourceName = imported ? imported.source.name : hostSourceName;
|
|
2967
|
+
const shownSheet = imported?.sheet ?? null;
|
|
2968
|
+
const shownSheets = imported?.sheets ?? NO_SHEETS;
|
|
2969
|
+
const sourceParams = shownSheet ? { sheet: shownSheet } : void 0;
|
|
2962
2970
|
const encoded = imported ? imported.encoded : source.encoded;
|
|
2963
2971
|
const limits = imported ? fileLimits : hostLimits;
|
|
2964
2972
|
const fieldNamesKey = encoded.schema.fields.map((f) => f.name).join("\0");
|
|
@@ -3418,7 +3426,7 @@ function Report(props) {
|
|
|
3418
3426
|
},
|
|
3419
3427
|
[result, encodedProp, imported, data, drillDownLimit, onCellClick, drillDown, defaultsOf, nameOf, infoOf]
|
|
3420
3428
|
);
|
|
3421
|
-
const doExport = useExport({ fileName, result, locale, labels, limits, root, chartRef, announce, onExport, title: viewName, source: sourceName, loadECharts });
|
|
3429
|
+
const doExport = useExport({ fileName, result, encoded, exportData, locale, labels, limits, root, chartRef, announce, onExport, title: viewName, source: sourceName, loadECharts });
|
|
3422
3430
|
const requestImport = () => loadImport().then((m) => (flushSync(() => setImportMod(() => m)), m));
|
|
3423
3431
|
const api = {
|
|
3424
3432
|
imported,
|
|
@@ -3445,7 +3453,9 @@ function Report(props) {
|
|
|
3445
3453
|
undo: () => undoLater.current(),
|
|
3446
3454
|
box: () => root.current?.getBoundingClientRect(),
|
|
3447
3455
|
pick: () => importMod?.pickFile(fileInput.current),
|
|
3448
|
-
load: requestImport
|
|
3456
|
+
load: requestImport,
|
|
3457
|
+
// what waits for another sheet of the file to be read (openOnSheet): it runs once that data is shown
|
|
3458
|
+
afterData: (run) => void (afterSheet.current = run)
|
|
3449
3459
|
};
|
|
3450
3460
|
useEffect11(() => {
|
|
3451
3461
|
apiNow.current = api;
|
|
@@ -3503,6 +3513,9 @@ function Report(props) {
|
|
|
3503
3513
|
viewName,
|
|
3504
3514
|
sourceId,
|
|
3505
3515
|
sourceName,
|
|
3516
|
+
sourceParams,
|
|
3517
|
+
// a view file that names another sheet of the workbook shown reads that sheet first
|
|
3518
|
+
viaSheet: (made, name, file) => viaSheet(made, name, () => loadLater.current?.({ file })),
|
|
3506
3519
|
schemaUrl,
|
|
3507
3520
|
encoded,
|
|
3508
3521
|
shareLink,
|
|
@@ -3516,9 +3529,10 @@ function Report(props) {
|
|
|
3516
3529
|
onSourceSwitch,
|
|
3517
3530
|
applyLoaded
|
|
3518
3531
|
};
|
|
3532
|
+
const viaSheet = (made, name, then) => imported && importMod ? importMod.openOnSheet(apiNow.current, made, name, then) : "none";
|
|
3519
3533
|
const loadTemplate = useCallback9(
|
|
3520
3534
|
(t) => {
|
|
3521
|
-
const tag = { name: t.name, scope: t.scope === "user" ? "user" : "shared", store: t.at !== void 0, storeSource: t.sourceId ?? null, sourceId };
|
|
3535
|
+
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 };
|
|
3522
3536
|
remember(tag, history.keyOf(t.view));
|
|
3523
3537
|
commit(t.view, { step: "template", name: t.name }, tag);
|
|
3524
3538
|
const over = zoneOverLimit(t.view, limits);
|
|
@@ -3531,6 +3545,31 @@ function Report(props) {
|
|
|
3531
3545
|
},
|
|
3532
3546
|
[commit, labels, announce, limits, locale, history, remember, sourceId, encoded, leaveOut]
|
|
3533
3547
|
);
|
|
3548
|
+
const openTemplate = (t) => {
|
|
3549
|
+
const how = viaSheet({ id: t.sourceId ?? t.sheetOf, sheet: t.sheet }, t.name, () => loadLater.current?.({ template: t }));
|
|
3550
|
+
if (how !== "switch") {
|
|
3551
|
+
loadTemplate(how === "missing" ? { ...t, sheet: SHEET_GONE } : t);
|
|
3552
|
+
}
|
|
3553
|
+
};
|
|
3554
|
+
const loadLater = useRef11(
|
|
3555
|
+
/** @type {((what: { template?: any, file?: object }) => void) | null} */
|
|
3556
|
+
null
|
|
3557
|
+
);
|
|
3558
|
+
useEffect11(() => {
|
|
3559
|
+
loadLater.current = ({ template, file }) => {
|
|
3560
|
+
if (template) {
|
|
3561
|
+
loadTemplate(template);
|
|
3562
|
+
} else if (file) {
|
|
3563
|
+
const loaded3 = viewFromObject(file, encoded, { limits, sourceId });
|
|
3564
|
+
applyLoaded(loaded3);
|
|
3565
|
+
}
|
|
3566
|
+
};
|
|
3567
|
+
const run = afterSheet.current;
|
|
3568
|
+
if (run && imported) {
|
|
3569
|
+
afterSheet.current = null;
|
|
3570
|
+
run();
|
|
3571
|
+
}
|
|
3572
|
+
}, [imported, loadTemplate, encoded, limits, sourceId, applyLoaded]);
|
|
3534
3573
|
const newReport = () => {
|
|
3535
3574
|
if (empty) {
|
|
3536
3575
|
return;
|
|
@@ -3546,12 +3585,19 @@ function Report(props) {
|
|
|
3546
3585
|
const subscribeViews = useCallback9((callback) => viewStore ? subscribeItem(storeName, callback) : () => {
|
|
3547
3586
|
}, [viewStore, storeName]);
|
|
3548
3587
|
const viewsText = useSyncExternalStore3(subscribeViews, () => viewStore ? readItem(storeName, localStore()) : null, () => null);
|
|
3549
|
-
const entries = useMemo8(
|
|
3588
|
+
const entries = useMemo8(
|
|
3589
|
+
() => templateEntries(templates, viewStore && menus ? menus.storedViews(viewsText, sourceId, { sheet: shownSheet, sheets: shownSheets }) : [], Boolean(onDeleteTemplate)),
|
|
3590
|
+
[templates, viewStore, menus, viewsText, sourceId, shownSheet, shownSheets, onDeleteTemplate]
|
|
3591
|
+
);
|
|
3550
3592
|
const templateActions = {
|
|
3551
3593
|
view,
|
|
3552
3594
|
announce,
|
|
3553
3595
|
locale,
|
|
3554
3596
|
sourceId,
|
|
3597
|
+
// the sheet of a workbook shown, which a view saved into the browser store names, and the data
|
|
3598
|
+
// shown as the host's callbacks get it
|
|
3599
|
+
sheet: shownSheet,
|
|
3600
|
+
source: sourceId ? { id: sourceId, ...sourceName ? { name: sourceName } : {}, ...sourceParams ? { params: sourceParams } : {} } : null,
|
|
3555
3601
|
viewsText,
|
|
3556
3602
|
store: viewStore,
|
|
3557
3603
|
keep: (text) => writeItem(storeName, localStore(), text),
|
|
@@ -3828,10 +3874,11 @@ function Report(props) {
|
|
|
3828
3874
|
folding,
|
|
3829
3875
|
share,
|
|
3830
3876
|
templates: entries,
|
|
3831
|
-
onLoadTemplate:
|
|
3877
|
+
onLoadTemplate: openTemplate,
|
|
3832
3878
|
templateActions,
|
|
3833
3879
|
onExport: doExport,
|
|
3834
3880
|
prepareExport: prepareExporters,
|
|
3881
|
+
dataExport: { exportData, encoded },
|
|
3835
3882
|
chartReady: view.display === "chart" && chartReady,
|
|
3836
3883
|
empty,
|
|
3837
3884
|
onShowFields: () => setDrawer(true),
|
|
@@ -3895,7 +3942,7 @@ function Report(props) {
|
|
|
3895
3942
|
onAction: runTip,
|
|
3896
3943
|
focusFallback: () => root.current?.focus({ preventScroll: true })
|
|
3897
3944
|
}
|
|
3898
|
-
), 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:
|
|
3945
|
+
), 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(
|
|
3899
3946
|
PivotChart,
|
|
3900
3947
|
{
|
|
3901
3948
|
result: chartResult,
|
|
@@ -3913,7 +3960,7 @@ function Report(props) {
|
|
|
3913
3960
|
},
|
|
3914
3961
|
onPoint: (p) => openCell({ rowPath: plan.swap ? p.colPath : p.rowPath, colPath: plan.swap ? p.rowPath : p.colPath, value: p.value, valueIndex: p.valueIndex, text: String(p.value ?? "") })
|
|
3915
3962
|
}
|
|
3916
|
-
) : gridState.grid ? /* @__PURE__ */ React12.createElement(PivotTable, { grid: gridState.grid, view, labels, version: history.viewKey, hintId: view.values.length ? hintId : void 0, onRowLabel: setRowLabel, infoOf, showInfo: fieldSwitch.on, typeOf, hostOrdered, onSort: sortFromHeader, onToggle: (axis, path) => commit(toggleCollapsed(view, axis, path), { step: "collapse" }), onCell: (cell) => openCell(cell) }) : null), /* @__PURE__ */ React12.createElement("div", { className: "pk-status" }, /* @__PURE__ */ React12.createElement("span", { "data-testid": "row-count" }, result ? plural(labels.rowsCount, result.rows.length, { lang: labels.lang, locale }) : ""), importMod ? /* @__PURE__ */ React12.createElement(importMod.SourceLine, { api }) : null, rowLabel && showTable ? /* @__PURE__ */ React12.createElement("span", { className: "pk-row-label", "data-testid": "row-label" }, fill(labels.rowLabel, { label: rowLabel })) : null), /* @__PURE__ */ React12.createElement("div", { className: "pk-toast-dock" }, /* @__PURE__ */ React12.createElement(Toasts, { toasts, dismiss, pause, closeLabel: labels.close }))), drill ? /* @__PURE__ */ React12.createElement(MenuPanel, { name: "DrillPanel", props: { drill, onClose: () => setDrill(null), labels, locale, exportContext: { encoded, onExport, announce, root } } }) : null),
|
|
3963
|
+
) : gridState.grid ? /* @__PURE__ */ React12.createElement(PivotTable, { grid: gridState.grid, view, labels, version: history.viewKey, hintId: view.values.length ? hintId : void 0, onRowLabel: setRowLabel, infoOf, showInfo: fieldSwitch.on, typeOf, hostOrdered, onSort: sortFromHeader, onToggle: (axis, path) => commit(toggleCollapsed(view, axis, path), { step: "collapse" }), onCell: (cell) => openCell(cell) }) : null), /* @__PURE__ */ React12.createElement("div", { className: "pk-status" }, /* @__PURE__ */ React12.createElement("span", { "data-testid": "row-count" }, result ? plural(labels.rowsCount, result.rows.length, { lang: labels.lang, locale }) : ""), importMod ? /* @__PURE__ */ React12.createElement(importMod.SourceLine, { api }) : null, rowLabel && showTable ? /* @__PURE__ */ React12.createElement("span", { className: "pk-row-label", "data-testid": "row-label" }, fill(labels.rowLabel, { label: rowLabel })) : null), /* @__PURE__ */ React12.createElement("div", { className: "pk-toast-dock" }, /* @__PURE__ */ React12.createElement(Toasts, { toasts, dismiss, pause, closeLabel: labels.close }))), drill ? /* @__PURE__ */ React12.createElement(MenuPanel, { name: "DrillPanel", props: { drill, onClose: () => setDrill(null), labels, locale, exportContext: { encoded, onExport, announce, root, exportData } } }) : null),
|
|
3917
3964
|
filterTarget ? /* @__PURE__ */ React12.createElement(MenuPanel, { name: "FilterPopover", props: { target: filterTarget, onClose: closeFilter, view, encoded, locale, labels, commit } }) : null
|
|
3918
3965
|
), allowImport && importMod ? /* @__PURE__ */ React12.createElement(importMod.ImportLayer, { api, input: fileInput }) : null, /* @__PURE__ */ React12.createElement("div", { className: "pk-layer", ref: setLayer }, /* @__PURE__ */ React12.createElement("span", { className: "pk-origin", "aria-hidden": "true" })))))
|
|
3919
3966
|
);
|
package/dist/labels.js
CHANGED
|
@@ -6,17 +6,17 @@ import {
|
|
|
6
6
|
} from "./chunks/chunk-E6M57YLL.js";
|
|
7
7
|
import {
|
|
8
8
|
en
|
|
9
|
-
} from "./chunks/chunk-
|
|
9
|
+
} from "./chunks/chunk-TR2HROIK.js";
|
|
10
10
|
import {
|
|
11
11
|
de
|
|
12
|
-
} from "./chunks/chunk-
|
|
12
|
+
} from "./chunks/chunk-YXLANLGL.js";
|
|
13
13
|
import {
|
|
14
14
|
de as de2,
|
|
15
15
|
en as en2
|
|
16
|
-
} from "./chunks/chunk-
|
|
16
|
+
} from "./chunks/chunk-ZK5RVCHP.js";
|
|
17
17
|
import {
|
|
18
18
|
LABELS
|
|
19
|
-
} from "./chunks/chunk-
|
|
19
|
+
} from "./chunks/chunk-XN5HNKJ2.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 } });
|