pivotkit-react 0.3.0 → 0.4.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 +121 -1
- package/README.md +1 -1
- package/dist/chunks/{chunk-32Z33U6S.js → chunk-6MDAL3IO.js} +28 -3
- package/dist/chunks/{chunk-APB4NW4O.js → chunk-LEN5RPBM.js} +3 -6
- package/dist/chunks/{chunk-7CC4JHDY.js → chunk-WB4GKWFQ.js} +1 -4
- package/dist/chunks/chunk-XN55BQ4M.js +618 -0
- package/dist/chunks/{chunk-IOPAM4JD.js → chunk-YITKWZ4L.js} +48 -492
- package/dist/chunks/chunk-ZYEYZSYL.js +187 -0
- package/dist/import-ui.js +769 -0
- package/dist/import-worker.js +20 -0
- package/dist/index.js +599 -175
- package/dist/labels.js +14 -10
- package/dist/menu-texts-de.js +1 -1
- package/dist/menus.js +132 -68
- package/dist/styles.css +116 -8
- package/package.json +3 -2
- package/types/data-history.d.ts +85 -0
- package/types/data-keep.d.ts +51 -0
- package/types/data-menu.d.ts +11 -0
- package/types/dom.d.ts +40 -7
- package/types/field-info.d.ts +32 -0
- package/types/import-host.d.ts +53 -0
- package/types/import-labels.d.ts +360 -0
- package/types/import-module.d.ts +2 -0
- package/types/import-run.d.ts +73 -0
- package/types/import-source.d.ts +32 -0
- package/types/import-steps.d.ts +121 -0
- package/types/import-ui.d.ts +108 -0
- package/types/import-worker.d.ts +1 -0
- package/types/index.d.ts +56 -4
- package/types/labels.d.ts +26 -2
- package/types/lazy-import.d.ts +4 -0
- package/types/lazy-menus.d.ts +2 -2
- package/types/levels.d.ts +3 -2
- package/types/menu-labels.d.ts +0 -3
- package/types/menu-topics.d.ts +2 -4
- package/types/menus.d.ts +1 -0
- package/types/overflow.d.ts +29 -17
- package/types/popover.d.ts +47 -5
- package/types/section.d.ts +2 -2
- package/types/toasts.d.ts +1 -1
- package/types/toolbar-panels.d.ts +6 -5
- package/types/unused-keep.d.ts +20 -0
- package/types/unused.d.ts +1 -0
- package/types/use-view-history.d.ts +12 -4
- package/types/virtual.d.ts +15 -0
package/dist/index.js
CHANGED
|
@@ -5,18 +5,10 @@ import {
|
|
|
5
5
|
DRILL_LIMIT,
|
|
6
6
|
FIELDS_COLLAPSED,
|
|
7
7
|
HelpContext,
|
|
8
|
-
Icon,
|
|
9
8
|
InfoButton,
|
|
10
|
-
LayerContext,
|
|
11
9
|
MAX_CATEGORIES,
|
|
12
|
-
MenuButton,
|
|
13
10
|
NO_EXPLANATIONS,
|
|
14
|
-
Option,
|
|
15
|
-
Popover,
|
|
16
|
-
TYPE_ICON,
|
|
17
11
|
ZONES,
|
|
18
|
-
ZONE_ICON,
|
|
19
|
-
activeIn,
|
|
20
12
|
activeTips,
|
|
21
13
|
addField,
|
|
22
14
|
allowedTips,
|
|
@@ -34,6 +26,7 @@ import {
|
|
|
34
26
|
headerSortState,
|
|
35
27
|
headerSortTarget,
|
|
36
28
|
helpSwitch,
|
|
29
|
+
importNow,
|
|
37
30
|
isEmptyView,
|
|
38
31
|
itemRuleText,
|
|
39
32
|
keptOnReset,
|
|
@@ -41,6 +34,7 @@ import {
|
|
|
41
34
|
linkNow,
|
|
42
35
|
linkParam,
|
|
43
36
|
loadCheck,
|
|
37
|
+
loadImport,
|
|
44
38
|
loadLink,
|
|
45
39
|
localStore,
|
|
46
40
|
moveField,
|
|
@@ -53,7 +47,6 @@ import {
|
|
|
53
47
|
readStoredView,
|
|
54
48
|
refLabel,
|
|
55
49
|
removeAt,
|
|
56
|
-
rootOf,
|
|
57
50
|
rowFolding,
|
|
58
51
|
selectedItems,
|
|
59
52
|
setChart,
|
|
@@ -73,8 +66,6 @@ import {
|
|
|
73
66
|
tipContext,
|
|
74
67
|
tipText,
|
|
75
68
|
toggleCollapsed,
|
|
76
|
-
useIsoLayoutEffect,
|
|
77
|
-
useModal,
|
|
78
69
|
valueConditionText,
|
|
79
70
|
valueLabel,
|
|
80
71
|
viewFromObject,
|
|
@@ -84,9 +75,24 @@ import {
|
|
|
84
75
|
writeItem,
|
|
85
76
|
writeStoredView,
|
|
86
77
|
zoneOverLimit
|
|
87
|
-
} from "./chunks/chunk-
|
|
78
|
+
} from "./chunks/chunk-YITKWZ4L.js";
|
|
79
|
+
import {
|
|
80
|
+
FormNameContext,
|
|
81
|
+
Group,
|
|
82
|
+
Icon,
|
|
83
|
+
LayerContext,
|
|
84
|
+
MenuButton,
|
|
85
|
+
Option,
|
|
86
|
+
Popover,
|
|
87
|
+
TYPE_ICON,
|
|
88
|
+
ZONE_ICON,
|
|
89
|
+
activeIn,
|
|
90
|
+
rootOf,
|
|
91
|
+
tabStops,
|
|
92
|
+
useIsoLayoutEffect,
|
|
93
|
+
useModal
|
|
94
|
+
} from "./chunks/chunk-XN55BQ4M.js";
|
|
88
95
|
import {
|
|
89
|
-
LABELS,
|
|
90
96
|
MENU_TEXTS,
|
|
91
97
|
errorText,
|
|
92
98
|
fill,
|
|
@@ -94,10 +100,11 @@ import {
|
|
|
94
100
|
messageOf,
|
|
95
101
|
plural,
|
|
96
102
|
resolveLabels
|
|
97
|
-
} from "./chunks/chunk-
|
|
103
|
+
} from "./chunks/chunk-6MDAL3IO.js";
|
|
98
104
|
|
|
99
105
|
// src/PivotReport.jsx
|
|
100
106
|
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";
|
|
107
|
+
import { flushSync } from "react-dom";
|
|
101
108
|
import { computePivot, emptyView as emptyView2, encode, fieldLabel as fieldLabel5, normalize as normalize2, suggestDateUnit, toGrid, toSeries, viewFields } from "pivotkit-core";
|
|
102
109
|
|
|
103
110
|
// src/chart.jsx
|
|
@@ -560,6 +567,43 @@ function fieldMatches(field, query, info) {
|
|
|
560
567
|
}
|
|
561
568
|
return [field, info?.label, info?.description].some((t) => typeof t === "string" && t.toLowerCase().includes(query));
|
|
562
569
|
}
|
|
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
|
+
var identifierColumns = /* @__PURE__ */ new WeakMap();
|
|
580
|
+
function isIdentifier(column) {
|
|
581
|
+
if (!column || column.type !== "number" || column.derived || !isIdentifierName(column.name)) {
|
|
582
|
+
return false;
|
|
583
|
+
}
|
|
584
|
+
const known = identifierColumns.get(column);
|
|
585
|
+
if (known !== void 0) {
|
|
586
|
+
return known;
|
|
587
|
+
}
|
|
588
|
+
let whole = true;
|
|
589
|
+
for (let i = 0; i < column.dict.length && whole; i++) {
|
|
590
|
+
whole = Number.isInteger(column.dict[i]);
|
|
591
|
+
}
|
|
592
|
+
identifierColumns.set(column, whole);
|
|
593
|
+
return whole;
|
|
594
|
+
}
|
|
595
|
+
function fieldDefaultsFor(fieldDefaults, field, column) {
|
|
596
|
+
const key = isObject(fieldDefaults) ? Object.keys(
|
|
597
|
+
/** @type {object} */
|
|
598
|
+
fieldDefaults
|
|
599
|
+
).find((k) => k.toLowerCase() === String(field).toLowerCase()) : void 0;
|
|
600
|
+
const host = key === void 0 ? void 0 : own(fieldDefaults, key);
|
|
601
|
+
const set = ["agg", "format", "drillFormat"].some((k) => own(host, k) !== void 0);
|
|
602
|
+
if (set || !isIdentifier(column)) {
|
|
603
|
+
return isObject(host) ? host : void 0;
|
|
604
|
+
}
|
|
605
|
+
return { ...isObject(host) ? host : {}, agg: "count", drillFormat: "text" };
|
|
606
|
+
}
|
|
563
607
|
|
|
564
608
|
// src/fields.jsx
|
|
565
609
|
import React3, { useCallback, useEffect as useEffect2, useId as useId2, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
|
|
@@ -629,7 +673,7 @@ function FieldItem({ field, labels, zones, onAdd, onNote, onFilter, name, info,
|
|
|
629
673
|
"aria-description": info ? void 0 : action.description || void 0,
|
|
630
674
|
"aria-describedby": info ? describedBy : void 0
|
|
631
675
|
},
|
|
632
|
-
/* @__PURE__ */ React3.createElement("span", { className: "pk-field-title", title: name }, name)
|
|
676
|
+
/* @__PURE__ */ React3.createElement("span", { className: "pk-field-title", title: name }, wordsOf(name))
|
|
633
677
|
), info ? /* @__PURE__ */ React3.createElement("span", { id: describedBy, className: "pk-sr" }, [action.description, info.description].filter(Boolean).join(". ")) : null, zones.length ? /* @__PURE__ */ React3.createElement("span", { className: "pk-badges", "aria-hidden": "true" }, zones.map((z) => /* @__PURE__ */ React3.createElement("span", { key: z, className: `pk-badge pk-badge-${z}`, "aria-hidden": "true", title: fill(labels.inZone, { zone: labels.zones[z] }) }, /* @__PURE__ */ React3.createElement(Icon, { name: (
|
|
634
678
|
/** @type {any} */
|
|
635
679
|
ZONE_ICON[z]
|
|
@@ -659,6 +703,9 @@ function FieldItem({ field, labels, zones, onAdd, onNote, onFilter, name, info,
|
|
|
659
703
|
labels.filter
|
|
660
704
|
) : null)));
|
|
661
705
|
}
|
|
706
|
+
function wordsOf(name) {
|
|
707
|
+
return name.split(/(\s+)/).map((part, i) => i % 2 === 1 ? " " : part ? /* @__PURE__ */ React3.createElement("span", { key: i, className: "pk-word" }, part) : null);
|
|
708
|
+
}
|
|
662
709
|
function FieldPanel({ fields, placed, labels, onAdd, onNote, onFilter, drawer, open, onClose, nameOf, info, showInfo = true, onSkip, collapsed = false, onCollapse }) {
|
|
663
710
|
const [query, setQuery] = useState3("");
|
|
664
711
|
const active = useActiveDrag();
|
|
@@ -863,11 +910,11 @@ function MenuPanel({ name, loadingText, props }) {
|
|
|
863
910
|
useEffect3(() => onMenuTexts(() => setLoads((n) => n + 1)), []);
|
|
864
911
|
const mod = menusNow(lang);
|
|
865
912
|
const current = mod && labels ? mod.menuLabels(labels) : null;
|
|
866
|
-
const [
|
|
913
|
+
const [kept2, setKept] = useState4(
|
|
867
914
|
/** @type {any} */
|
|
868
915
|
null
|
|
869
916
|
);
|
|
870
|
-
if (current && current !==
|
|
917
|
+
if (current && current !== kept2) {
|
|
871
918
|
setKept(current);
|
|
872
919
|
}
|
|
873
920
|
const [failed, setFailed] = useState4(false);
|
|
@@ -910,14 +957,14 @@ function MenuPanel({ name, loadingText, props }) {
|
|
|
910
957
|
focusFirst(box.current);
|
|
911
958
|
}
|
|
912
959
|
}, [mod, failed]);
|
|
913
|
-
const shown = mod ?? (
|
|
960
|
+
const shown = mod ?? (kept2 ? menusNow() : null);
|
|
914
961
|
const Panel = shown ? (
|
|
915
962
|
/** @type {any} */
|
|
916
963
|
shown[name]
|
|
917
964
|
) : null;
|
|
918
965
|
return /* @__PURE__ */ React4.createElement("div", { className: "pk-menu-panel", ref: box }, Panel ? (
|
|
919
966
|
// the menus' own texts (menu-labels.js) come with them, under the report's labels
|
|
920
|
-
/* @__PURE__ */ React4.createElement(Panel, { ...props, labels: current ??
|
|
967
|
+
/* @__PURE__ */ React4.createElement(Panel, { ...props, labels: current ?? kept2 ?? labels })
|
|
921
968
|
) : failed && labels ? /* @__PURE__ */ React4.createElement("div", { className: "pk-menu-failed", role: "alert", "data-testid": "menu-failed" }, /* @__PURE__ */ React4.createElement("p", null, labels.menuFailed), /* @__PURE__ */ React4.createElement(
|
|
922
969
|
"button",
|
|
923
970
|
{
|
|
@@ -994,9 +1041,72 @@ function rowLabelOf(grid, r) {
|
|
|
994
1041
|
}
|
|
995
1042
|
return texts.join(" / ");
|
|
996
1043
|
}
|
|
1044
|
+
function longestLabels(grid, col, n) {
|
|
1045
|
+
const out = [];
|
|
1046
|
+
if (n < 1) {
|
|
1047
|
+
return out;
|
|
1048
|
+
}
|
|
1049
|
+
for (let r = grid.headerRows; r < grid.rows.length; r++) {
|
|
1050
|
+
const cell = grid.rows[r][col];
|
|
1051
|
+
if (!cell || cell.kind !== "rowHeader" || !cell.text || (cell.colSpan ?? 1) > 1) {
|
|
1052
|
+
continue;
|
|
1053
|
+
}
|
|
1054
|
+
if (out.length === n && cell.text.length <= out[n - 1].text.length) {
|
|
1055
|
+
continue;
|
|
1056
|
+
}
|
|
1057
|
+
const entry = { text: cell.text, toggle: Boolean(cell.toggle), total: Boolean(cell.total) };
|
|
1058
|
+
let at = out.length;
|
|
1059
|
+
while (at > 0 && out[at - 1].text.length < entry.text.length) {
|
|
1060
|
+
at--;
|
|
1061
|
+
}
|
|
1062
|
+
out.splice(at, 0, entry);
|
|
1063
|
+
if (out.length > n) {
|
|
1064
|
+
out.pop();
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
return out;
|
|
1068
|
+
}
|
|
997
1069
|
|
|
998
1070
|
// src/table.jsx
|
|
999
1071
|
var totalClass = (t) => t === 2 ? " pk-grand" : t === 1 ? " pk-sub" : "";
|
|
1072
|
+
var MEASURED_LABELS = 50;
|
|
1073
|
+
var LABEL_MAX_EM = 28;
|
|
1074
|
+
var LABEL_SLACK = 2;
|
|
1075
|
+
function labelWidths(grid, table) {
|
|
1076
|
+
const text = table.querySelector("tbody th.pk-rowHeader .pk-th-text");
|
|
1077
|
+
const content = text?.parentElement;
|
|
1078
|
+
if (!text || !content) {
|
|
1079
|
+
return null;
|
|
1080
|
+
}
|
|
1081
|
+
const probe = table.ownerDocument.createElement("span");
|
|
1082
|
+
probe.className = "pk-th-text";
|
|
1083
|
+
probe.setAttribute("aria-hidden", "true");
|
|
1084
|
+
Object.assign(probe.style, { position: "absolute", visibility: "hidden", whiteSpace: "pre", width: "auto", minWidth: "0", maxWidth: "none", overflow: "visible" });
|
|
1085
|
+
content.append(probe);
|
|
1086
|
+
try {
|
|
1087
|
+
const widthOf = (l) => {
|
|
1088
|
+
probe.style.fontWeight = l.total ? "700" : "";
|
|
1089
|
+
probe.textContent = l.text;
|
|
1090
|
+
return probe.getBoundingClientRect().width;
|
|
1091
|
+
};
|
|
1092
|
+
const em = parseFloat(getComputedStyle(text).fontSize) || 14;
|
|
1093
|
+
const toggle = table.querySelector(".pk-toggle");
|
|
1094
|
+
const gap = parseFloat(getComputedStyle(content).columnGap) || 0;
|
|
1095
|
+
const toggleWidth = (toggle ? toggle.getBoundingClientRect().width : em * 1.7) + gap;
|
|
1096
|
+
const widths = [];
|
|
1097
|
+
for (let c = 0; c < grid.rowHeaderColumns; c++) {
|
|
1098
|
+
const most = Math.max(0, ...longestLabels(grid, c, MEASURED_LABELS).map((l) => widthOf(l) + (l.toggle ? toggleWidth : 0)));
|
|
1099
|
+
widths.push(Math.min(Math.ceil(most) + LABEL_SLACK, LABEL_MAX_EM * em));
|
|
1100
|
+
}
|
|
1101
|
+
return widths;
|
|
1102
|
+
} finally {
|
|
1103
|
+
probe.remove();
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
var fontOf = (table) => {
|
|
1107
|
+
const s = getComputedStyle(table);
|
|
1108
|
+
return `${s.fontFamily}|${s.fontSize}|${s.fontWeight}`;
|
|
1109
|
+
};
|
|
1000
1110
|
function conditionalStyle(cell) {
|
|
1001
1111
|
const s = cell.style;
|
|
1002
1112
|
if (!s) {
|
|
@@ -1061,6 +1171,12 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1061
1171
|
/** @type {{ r: number, c: number } | null} */
|
|
1062
1172
|
null
|
|
1063
1173
|
);
|
|
1174
|
+
const [labelsWide, setLabelsWide] = useState5(
|
|
1175
|
+
/** @type {{ grid: unknown, font: string, fonts: number, widths: number[] } | null} */
|
|
1176
|
+
null
|
|
1177
|
+
);
|
|
1178
|
+
const [fontsLoaded, setFontsLoaded] = useState5(0);
|
|
1179
|
+
const fixedWidths = virtual && labelsWide?.grid === grid ? labelsWide.widths : null;
|
|
1064
1180
|
const focusNext = useRef4(false);
|
|
1065
1181
|
const [sortNote, setSortNote] = useState5("");
|
|
1066
1182
|
const focusToggle = useRef4(
|
|
@@ -1074,6 +1190,35 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1074
1190
|
},
|
|
1075
1191
|
[toggleGroup]
|
|
1076
1192
|
);
|
|
1193
|
+
useIsoLayoutEffect(() => {
|
|
1194
|
+
const t = table.current;
|
|
1195
|
+
if (!virtual || !t) {
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
const font = fontOf(t);
|
|
1199
|
+
if (labelsWide?.grid !== grid || labelsWide.font !== font || labelsWide.fonts !== fontsLoaded) {
|
|
1200
|
+
const widths = labelWidths(grid, t);
|
|
1201
|
+
if (widths) {
|
|
1202
|
+
setLabelsWide({ grid, font, fonts: fontsLoaded, widths });
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
useEffect4(() => {
|
|
1207
|
+
const fonts = virtual ? table.current?.ownerDocument.fonts : void 0;
|
|
1208
|
+
if (!fonts) {
|
|
1209
|
+
return void 0;
|
|
1210
|
+
}
|
|
1211
|
+
let live = true;
|
|
1212
|
+
const loaded3 = () => live && setFontsLoaded((n) => n + 1);
|
|
1213
|
+
fonts.addEventListener?.("loadingdone", loaded3);
|
|
1214
|
+
if (fonts.status === "loading") {
|
|
1215
|
+
fonts.ready.then(loaded3, () => void 0);
|
|
1216
|
+
}
|
|
1217
|
+
return () => {
|
|
1218
|
+
live = false;
|
|
1219
|
+
fonts.removeEventListener?.("loadingdone", loaded3);
|
|
1220
|
+
};
|
|
1221
|
+
}, [virtual]);
|
|
1077
1222
|
useIsoLayoutEffect(() => {
|
|
1078
1223
|
const t = table.current;
|
|
1079
1224
|
if (!t) {
|
|
@@ -1098,7 +1243,7 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1098
1243
|
}
|
|
1099
1244
|
setLefts((old) => old.length === xs.length && old.every((v, i) => Math.abs(v - xs[i]) < 0.5) ? old : xs);
|
|
1100
1245
|
}
|
|
1101
|
-
}, [grid, version, width]);
|
|
1246
|
+
}, [grid, version, width, fixedWidths]);
|
|
1102
1247
|
useEffect4(() => {
|
|
1103
1248
|
const el = wrap.current;
|
|
1104
1249
|
if (!el) {
|
|
@@ -1111,6 +1256,9 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1111
1256
|
update();
|
|
1112
1257
|
const ro = typeof ResizeObserver === "function" ? new ResizeObserver(update) : null;
|
|
1113
1258
|
ro?.observe(el);
|
|
1259
|
+
if (table.current) {
|
|
1260
|
+
ro?.observe(table.current);
|
|
1261
|
+
}
|
|
1114
1262
|
return () => ro?.disconnect();
|
|
1115
1263
|
}, []);
|
|
1116
1264
|
const head = headHeight || rowHeight * grid.headerRows;
|
|
@@ -1251,7 +1399,7 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1251
1399
|
};
|
|
1252
1400
|
const bodyCell = ({ cell, col, rowSpan, colSpan }, r) => {
|
|
1253
1401
|
if (cell.kind === "rowHeader") {
|
|
1254
|
-
return /* @__PURE__ */ React6.createElement("th", { key: col, scope: "row", className: `pk-th pk-rowHeader pk-sticky${totalClass(cell.total)}${rowSpan > 1 ? " pk-span" : ""}`, style: stickyStyle(col), rowSpan: rowSpan > 1 ? rowSpan : void 0, colSpan: colSpan > 1 ? colSpan : void 0, title: virtual ? cell.text : void 0, onClick: showRowLabel ? () => showRowLabel(r, rowSpan) : void 0 }, /* @__PURE__ */ React6.createElement("span", { className: "pk-th-content" }, cell.toggle ? /* @__PURE__ */ React6.createElement(Toggle, { toggle: cell.toggle, text: cell.text, labels, onToggle }) : null, /* @__PURE__ */ React6.createElement("span", { className: "pk-th-text" }, cell.text)));
|
|
1402
|
+
return /* @__PURE__ */ React6.createElement("th", { key: col, scope: "row", className: `pk-th pk-rowHeader pk-sticky${totalClass(cell.total)}${rowSpan > 1 ? " pk-span" : ""}`, style: stickyStyle(col), rowSpan: rowSpan > 1 ? rowSpan : void 0, colSpan: colSpan > 1 ? colSpan : void 0, title: virtual ? cell.text : void 0, onClick: showRowLabel ? () => showRowLabel(r, rowSpan) : void 0 }, /* @__PURE__ */ React6.createElement("span", { className: "pk-th-content", style: fixedWidths && colSpan <= 1 && fixedWidths[col] !== void 0 ? { width: fixedWidths[col] } : void 0 }, cell.toggle ? /* @__PURE__ */ React6.createElement(Toggle, { toggle: cell.toggle, text: cell.text, labels, onToggle }) : null, /* @__PURE__ */ React6.createElement("span", { className: "pk-th-text" }, cell.text)));
|
|
1255
1403
|
}
|
|
1256
1404
|
const isValue = cell.valueIndex !== void 0;
|
|
1257
1405
|
const clickable = isValue && drillable(cell);
|
|
@@ -1314,6 +1462,7 @@ function useToasts() {
|
|
|
1314
1462
|
if (toast.tone !== "error" && !paused.current) {
|
|
1315
1463
|
arm(id);
|
|
1316
1464
|
}
|
|
1465
|
+
return id;
|
|
1317
1466
|
},
|
|
1318
1467
|
[arm]
|
|
1319
1468
|
);
|
|
@@ -1485,7 +1634,6 @@ function unusedTexts(loaded3, labels) {
|
|
|
1485
1634
|
|
|
1486
1635
|
// src/unused.jsx
|
|
1487
1636
|
var FIRST = { narrow: 2, wide: 3 };
|
|
1488
|
-
var FOCUSABLE = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
1489
1637
|
function Unused({ notes, notesKey, dismissed, onDismiss, labels, locale, narrow, quiet }) {
|
|
1490
1638
|
const lang = labels.lang;
|
|
1491
1639
|
const show = notes.length > 0 && !dismissed;
|
|
@@ -1538,7 +1686,7 @@ function Unused({ notes, notesKey, dismissed, onDismiss, labels, locale, narrow,
|
|
|
1538
1686
|
const dismiss = () => {
|
|
1539
1687
|
const el = box.current;
|
|
1540
1688
|
const root = el?.closest(".pk-root");
|
|
1541
|
-
const next = el && root ?
|
|
1689
|
+
const next = el && root ? tabStops(root).find((c) => !el.contains(c) && el.compareDocumentPosition(c) & Node.DOCUMENT_POSITION_FOLLOWING) : null;
|
|
1542
1690
|
onDismiss(
|
|
1543
1691
|
/** @type {HTMLElement | null} */
|
|
1544
1692
|
next ?? null
|
|
@@ -1554,49 +1702,87 @@ function Unused({ notes, notesKey, dismissed, onDismiss, labels, locale, narrow,
|
|
|
1554
1702
|
})), notes.length > first + 1 ? /* @__PURE__ */ React9.createElement("button", { type: "button", className: "pk-btn pk-small-btn pk-issues-more", onClick: () => setAll(all === notesKey ? null : notesKey), "data-testid": "unused-more" }, cut < notes.length ? plural(labels.unusedMore, notes.length - cut, { lang, locale }) : labels.unusedFewer) : null), /* @__PURE__ */ React9.createElement("button", { type: "button", className: "pk-icon-btn pk-issues-x", "aria-label": labels.dismissIssues, title: labels.dismissIssues, onClick: dismiss, "data-testid": "dismiss-issues" }, /* @__PURE__ */ React9.createElement(Icon, { name: "x", size: 14 }))) : null, /* @__PURE__ */ React9.createElement("div", { className: "pk-sr", "aria-live": "polite", "data-testid": "unused-live" }, show && !quiet ? title : null));
|
|
1555
1703
|
}
|
|
1556
1704
|
|
|
1705
|
+
// src/unused-keep.js
|
|
1706
|
+
var PATH = /^([A-Za-z]+)(?:\[(\d+)\])?(?:\.([A-Za-z]+))?/;
|
|
1707
|
+
var lower = (v) => typeof v === "string" ? v.toLowerCase() : v;
|
|
1708
|
+
var isObject2 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
1709
|
+
function partOf(path, raw, view) {
|
|
1710
|
+
const m = PATH.exec(path ?? "");
|
|
1711
|
+
if (!m) {
|
|
1712
|
+
return JSON.stringify(view);
|
|
1713
|
+
}
|
|
1714
|
+
const [, key, index, sub] = m;
|
|
1715
|
+
const section = Object.hasOwn(view, key) ? view[key] : void 0;
|
|
1716
|
+
if (key === "values" && index !== void 0 && Array.isArray(section)) {
|
|
1717
|
+
const given = isObject2(raw) && Array.isArray(
|
|
1718
|
+
/** @type {any} */
|
|
1719
|
+
raw.values
|
|
1720
|
+
) ? (
|
|
1721
|
+
/** @type {any} */
|
|
1722
|
+
raw.values[Number(index)]
|
|
1723
|
+
) : void 0;
|
|
1724
|
+
const match = isObject2(given) ? section.find((v) => lower(v.field ?? null) === lower(given.field ?? null) && lower(v.agg) === lower(given.agg)) : void 0;
|
|
1725
|
+
if (match) {
|
|
1726
|
+
return JSON.stringify(match);
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
if (sub !== void 0 && isObject2(section)) {
|
|
1730
|
+
return JSON.stringify(Object.hasOwn(section, sub) ? section[sub] : void 0);
|
|
1731
|
+
}
|
|
1732
|
+
return JSON.stringify(section);
|
|
1733
|
+
}
|
|
1734
|
+
function stillApplies(note, loaded3, shown) {
|
|
1735
|
+
if (!loaded3) {
|
|
1736
|
+
return true;
|
|
1737
|
+
}
|
|
1738
|
+
if ("issue" in note) {
|
|
1739
|
+
return partOf(note.issue.path, note.raw, loaded3) === partOf(note.issue.path, note.raw, shown);
|
|
1740
|
+
}
|
|
1741
|
+
return note.path === void 0 || partOf(note.path, null, loaded3) === partOf(note.path, null, shown);
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1557
1744
|
// src/toolbar.jsx
|
|
1558
1745
|
import React10, { useCallback as useCallback4, useEffect as useEffect8, useMemo as useMemo5, useRef as useRef8, useState as useState8 } from "react";
|
|
1559
1746
|
|
|
1560
1747
|
// src/overflow.js
|
|
1561
|
-
var OVERFLOW_ORDER = Object.freeze(["
|
|
1748
|
+
var OVERFLOW_ORDER = Object.freeze(["layout", "options", "chartType", "data", "startOver", "views"]);
|
|
1749
|
+
var MORE_GROUPS = Object.freeze([Object.freeze(["startOver"]), Object.freeze(["layout", "chartType", "options"]), Object.freeze(["data"]), Object.freeze(["views"])]);
|
|
1562
1750
|
var TOOLBAR_ROOM = Object.freeze({
|
|
1563
|
-
// measured in Chromium at the playground's font: the longer of English and German with the gap
|
|
1564
|
-
// after it, plus 2 %; a wider font still fits, as useOverflow measures as well
|
|
1565
1751
|
fields: 6.4,
|
|
1566
1752
|
display: 15.3,
|
|
1567
1753
|
chartType: 12.9,
|
|
1568
1754
|
sep: 1,
|
|
1569
1755
|
undo: 8.75,
|
|
1570
1756
|
redo: 9.15,
|
|
1571
|
-
|
|
1757
|
+
startOver: 10.9,
|
|
1572
1758
|
layout: 8.4,
|
|
1573
1759
|
options: 8.75,
|
|
1760
|
+
data: 7.4,
|
|
1574
1761
|
views: 9.1,
|
|
1575
1762
|
export: 7.5,
|
|
1576
1763
|
more: 7.2
|
|
1577
1764
|
});
|
|
1578
|
-
var TEXT_BUTTONS = Object.freeze(["fields", "undo", "redo", "
|
|
1579
|
-
var MENU_BUTTONS = Object.freeze(["chartType", "options", "views", "export", "more"]);
|
|
1580
|
-
function toolbarTexts(
|
|
1581
|
-
const
|
|
1765
|
+
var TEXT_BUTTONS = Object.freeze(["fields", "undo", "redo", "layout"]);
|
|
1766
|
+
var MENU_BUTTONS = Object.freeze(["chartType", "startOver", "options", "data", "views", "export", "more"]);
|
|
1767
|
+
function toolbarTexts(labels) {
|
|
1768
|
+
const text = (v) => typeof v === "string" ? v : "";
|
|
1769
|
+
return (
|
|
1582
1770
|
/** @type {any} */
|
|
1583
|
-
{
|
|
1771
|
+
{
|
|
1772
|
+
fields: [text(labels.showFields)],
|
|
1773
|
+
undo: [text(labels.undo)],
|
|
1774
|
+
redo: [text(labels.redo)],
|
|
1775
|
+
startOver: [text(labels.startOver)],
|
|
1776
|
+
layout: [text(labels.layout)],
|
|
1777
|
+
options: [text(labels.options)],
|
|
1778
|
+
views: [text(labels.views)],
|
|
1779
|
+
data: [text(labels.data)],
|
|
1780
|
+
export: [text(labels.exportLabel)],
|
|
1781
|
+
more: [text(labels.more)],
|
|
1782
|
+
chartType: Object.values(labels.chartTypes ?? {}).map(text),
|
|
1783
|
+
display: [[text(labels.table), text(labels.chart)]]
|
|
1784
|
+
}
|
|
1584
1785
|
);
|
|
1585
|
-
const text = (v) => typeof v === "string" ? v : "";
|
|
1586
|
-
for (const l of sets) {
|
|
1587
|
-
out.fields.push(text(l.showFields));
|
|
1588
|
-
out.undo.push(text(l.undo));
|
|
1589
|
-
out.redo.push(text(l.redo));
|
|
1590
|
-
out.reset.push(text(l.reset));
|
|
1591
|
-
out.layout.push(text(l.layout));
|
|
1592
|
-
out.options.push(text(l.options));
|
|
1593
|
-
out.views.push(text(l.views));
|
|
1594
|
-
out.export.push(text(l.exportLabel));
|
|
1595
|
-
out.more.push(text(l.more));
|
|
1596
|
-
out.chartType.push(...Object.values(l.chartTypes ?? {}).map(text));
|
|
1597
|
-
out.display.push([text(l.table), text(l.chart)]);
|
|
1598
|
-
}
|
|
1599
|
-
return out;
|
|
1600
1786
|
}
|
|
1601
1787
|
function toolbarRoom(texts, measure, chrome) {
|
|
1602
1788
|
const widest = (list, kind = "button") => Math.max(0, ...list.map((t) => measure(t, kind)));
|
|
@@ -1613,14 +1799,22 @@ function toolbarRoom(texts, measure, chrome) {
|
|
|
1613
1799
|
room.display = chrome.display + Math.max(0, ...texts.display.map(([a, b]) => measure(a, "display") + measure(b, "display"))) + chrome.gap;
|
|
1614
1800
|
return room;
|
|
1615
1801
|
}
|
|
1616
|
-
function
|
|
1802
|
+
function overflowHidden(width, narrow, present, room = TOOLBAR_ROOM) {
|
|
1617
1803
|
const fixed = (narrow ? room.fields : 0) + room.display + room.sep + room.undo + room.redo + room.export;
|
|
1618
|
-
|
|
1619
|
-
const need = (
|
|
1620
|
-
|
|
1621
|
-
|
|
1804
|
+
const order = OVERFLOW_ORDER.filter((id) => present.includes(id));
|
|
1805
|
+
const need = (shown2) => fixed + shown2.reduce((sum, id) => sum + (room[id] ?? 0), 0) + (shown2.length < order.length ? room.more : 0);
|
|
1806
|
+
let shown = order;
|
|
1807
|
+
while (shown.length && need(shown) > width) {
|
|
1808
|
+
shown = shown.slice(1);
|
|
1809
|
+
}
|
|
1810
|
+
const gone = order.filter((id) => !shown.includes(id));
|
|
1811
|
+
for (const id of gone.reverse()) {
|
|
1812
|
+
const next = order.filter((o) => o === id || shown.includes(o));
|
|
1813
|
+
if (need(next) <= width) {
|
|
1814
|
+
shown = next;
|
|
1815
|
+
}
|
|
1622
1816
|
}
|
|
1623
|
-
return
|
|
1817
|
+
return order.filter((id) => !shown.includes(id));
|
|
1624
1818
|
}
|
|
1625
1819
|
|
|
1626
1820
|
// src/toolbar.jsx
|
|
@@ -1628,7 +1822,7 @@ function TextButton({ icon, label, onClick, disabled, testId, shortcut }) {
|
|
|
1628
1822
|
return /* @__PURE__ */ React10.createElement("button", { type: "button", className: "pk-btn", onClick, disabled, title: shortcut ? `${label} (${shortcut})` : void 0, "aria-keyshortcuts": shortcut ? shortcut.replace("\u2318", "Meta+").replace("\u21E7", "Shift+") : void 0, "data-testid": testId }, /* @__PURE__ */ React10.createElement(Icon, { name: icon }), /* @__PURE__ */ React10.createElement("span", { className: "pk-btn-text" }, label));
|
|
1629
1823
|
}
|
|
1630
1824
|
var measuring;
|
|
1631
|
-
var
|
|
1825
|
+
var fontOf2 = (style) => `${style.fontStyle} ${style.fontWeight} ${style.fontSize} ${style.fontFamily}`;
|
|
1632
1826
|
function measuredRoom(el, texts) {
|
|
1633
1827
|
const doc = el.ownerDocument;
|
|
1634
1828
|
if (measuring === void 0) {
|
|
@@ -1650,10 +1844,10 @@ function measuredRoom(el, texts) {
|
|
|
1650
1844
|
if (!view) {
|
|
1651
1845
|
return null;
|
|
1652
1846
|
}
|
|
1653
|
-
const fonts = { button:
|
|
1847
|
+
const fonts = { button: fontOf2(view.getComputedStyle(
|
|
1654
1848
|
/** @type {Element} */
|
|
1655
1849
|
textOf(undo2)
|
|
1656
|
-
)), display:
|
|
1850
|
+
)), display: fontOf2(view.getComputedStyle(
|
|
1657
1851
|
/** @type {Element} */
|
|
1658
1852
|
textOf(display)
|
|
1659
1853
|
)) };
|
|
@@ -1676,14 +1870,20 @@ function measuredRoom(el, texts) {
|
|
|
1676
1870
|
};
|
|
1677
1871
|
return toolbarRoom(texts, measure, chrome);
|
|
1678
1872
|
}
|
|
1679
|
-
function useOverflow(ref, key, narrow,
|
|
1680
|
-
const [
|
|
1873
|
+
function useOverflow(ref, key, narrow, present, texts) {
|
|
1874
|
+
const [decided, setDecided] = useState8(
|
|
1875
|
+
/** @type {string[]} */
|
|
1876
|
+
[]
|
|
1877
|
+
);
|
|
1878
|
+
const [extra, setExtra] = useState8(0);
|
|
1681
1879
|
const [measure, setMeasure] = useState8(0);
|
|
1682
1880
|
const [lastKey, setLastKey] = useState8(key);
|
|
1683
|
-
const latest = useRef8(texts);
|
|
1881
|
+
const latest = useRef8({ texts, present });
|
|
1882
|
+
const waiting = useRef8(false);
|
|
1684
1883
|
useIsoLayoutEffect(() => {
|
|
1685
|
-
latest.current = texts;
|
|
1884
|
+
latest.current = { texts, present };
|
|
1686
1885
|
});
|
|
1886
|
+
const isOpen = (el) => Boolean(el.querySelector('[aria-expanded="true"]'));
|
|
1687
1887
|
if (key !== lastKey) {
|
|
1688
1888
|
setLastKey(key);
|
|
1689
1889
|
setMeasure((m) => m + 1);
|
|
@@ -1695,9 +1895,16 @@ function useOverflow(ref, key, narrow, max, texts) {
|
|
|
1695
1895
|
}
|
|
1696
1896
|
let width = -1;
|
|
1697
1897
|
const decide = () => {
|
|
1898
|
+
if (isOpen(el)) {
|
|
1899
|
+
waiting.current = true;
|
|
1900
|
+
return;
|
|
1901
|
+
}
|
|
1902
|
+
waiting.current = false;
|
|
1698
1903
|
const em = parseFloat(getComputedStyle(el).fontSize) || 14;
|
|
1699
|
-
const room = measuredRoom(el, latest.current);
|
|
1700
|
-
|
|
1904
|
+
const room = measuredRoom(el, latest.current.texts);
|
|
1905
|
+
const own2 = latest.current.present;
|
|
1906
|
+
setDecided(room ? overflowHidden(width, narrow, own2, room) : overflowHidden(width / em, narrow, own2));
|
|
1907
|
+
setExtra(0);
|
|
1701
1908
|
setMeasure((m) => m + 1);
|
|
1702
1909
|
};
|
|
1703
1910
|
const ro = new ResizeObserver(([entry]) => {
|
|
@@ -1710,23 +1917,29 @@ function useOverflow(ref, key, narrow, max, texts) {
|
|
|
1710
1917
|
width = Math.round(el.getBoundingClientRect().width);
|
|
1711
1918
|
decide();
|
|
1712
1919
|
ro.observe(el);
|
|
1920
|
+
const mo = typeof MutationObserver === "function" ? new MutationObserver(() => waiting.current && decide()) : null;
|
|
1921
|
+
mo?.observe(el, { subtree: true, attributes: true, attributeFilter: ["aria-expanded"] });
|
|
1713
1922
|
let live = true;
|
|
1714
1923
|
el.ownerDocument.fonts?.ready.then(() => live && width >= 0 && decide(), () => void 0);
|
|
1715
1924
|
return () => {
|
|
1716
1925
|
live = false;
|
|
1717
1926
|
ro.disconnect();
|
|
1927
|
+
mo?.disconnect();
|
|
1718
1928
|
};
|
|
1719
1929
|
}, [ref, narrow, key]);
|
|
1930
|
+
const order = OVERFLOW_ORDER.filter((id) => present.includes(id));
|
|
1931
|
+
const shown = order.filter((id) => !decided.includes(id));
|
|
1932
|
+
const more = shown.slice(0, extra);
|
|
1720
1933
|
useIsoLayoutEffect(() => {
|
|
1721
1934
|
const el = ref.current;
|
|
1722
|
-
if (el && el.scrollWidth > el.clientWidth + 1 &&
|
|
1723
|
-
|
|
1935
|
+
if (el && !isOpen(el) && el.scrollWidth > el.clientWidth + 1 && extra < shown.length) {
|
|
1936
|
+
setExtra(extra + 1);
|
|
1724
1937
|
}
|
|
1725
|
-
}, [ref,
|
|
1726
|
-
return
|
|
1938
|
+
}, [ref, extra, measure, key, shown.length]);
|
|
1939
|
+
return order.filter((id) => decided.includes(id) || more.includes(id));
|
|
1727
1940
|
}
|
|
1728
1941
|
function Toolbar(props) {
|
|
1729
|
-
const { view, labels, size, canUndo, canRedo, canReset, onUndo, onRedo, onReset, loadedView, empty, onDisplay, onChart, onChartDisplay, onTotal, onExpand, onCollapse, folding, templates, onLoadTemplate, templateActions, onExport, chartReady, onShowFields, layoutFolded, onLayout, zonesId, share } = props;
|
|
1942
|
+
const { view, labels, size, canUndo, canRedo, canReset, startEmpty, canNew, onUndo, onRedo, onReset, onNew, loadedView, empty, onDisplay, onChart, onChartDisplay, onTotal, onExpand, onCollapse, folding, templates, onLoadTemplate, templateActions, onExport, chartReady, onShowFields, layoutFolded, onLayout, zonesId, share } = props;
|
|
1730
1943
|
const tips = { controls: props.tipsControls, on: props.tipsOn, onOn: props.onTipsOn, canReset: props.canResetTips, onReset: props.onResetTips };
|
|
1731
1944
|
const bar = useRef8(
|
|
1732
1945
|
/** @type {HTMLDivElement | null} */
|
|
@@ -1741,34 +1954,11 @@ function Toolbar(props) {
|
|
|
1741
1954
|
null
|
|
1742
1955
|
);
|
|
1743
1956
|
const [panel, setPanel] = useState8(
|
|
1744
|
-
/** @type {"options" | "views" | "chartType" | null} */
|
|
1957
|
+
/** @type {"options" | "views" | "chartType" | "data" | null} */
|
|
1745
1958
|
null
|
|
1746
1959
|
);
|
|
1747
|
-
const
|
|
1748
|
-
const texts = useMemo5(() => toolbarTexts(
|
|
1749
|
-
const level = useOverflow(bar, `${labels.lang}:${labels.undo}:${size}`, size === "narrow", order.length, texts);
|
|
1750
|
-
const hidden = new Set(order.slice(0, level));
|
|
1751
|
-
if (panel && !hidden.has(panel)) {
|
|
1752
|
-
setPanel(null);
|
|
1753
|
-
}
|
|
1754
|
-
const closePanel = useCallback4(() => setPanel(null), []);
|
|
1755
|
-
const request = props.viewsRequest ?? 0;
|
|
1756
|
-
const [seenRequest, setSeenRequest] = useState8(request);
|
|
1757
|
-
const [clickFor, setClickFor] = useState8(0);
|
|
1758
|
-
if (request !== seenRequest) {
|
|
1759
|
-
setSeenRequest(request);
|
|
1760
|
-
if (hidden.has("views")) {
|
|
1761
|
-
setPanel("views");
|
|
1762
|
-
} else {
|
|
1763
|
-
setClickFor(request);
|
|
1764
|
-
}
|
|
1765
|
-
}
|
|
1766
|
-
useEffect8(() => {
|
|
1767
|
-
const button = viewsButton.current;
|
|
1768
|
-
if (clickFor > 0 && button && button.getAttribute("aria-expanded") !== "true") {
|
|
1769
|
-
button.click();
|
|
1770
|
-
}
|
|
1771
|
-
}, [clickFor]);
|
|
1960
|
+
const data = props.data;
|
|
1961
|
+
const texts = useMemo5(() => toolbarTexts(labels), [labels]);
|
|
1772
1962
|
const plan = props.chartPlan ?? { name: chartTypeOf(view.chart), auto: false };
|
|
1773
1963
|
const preset = plan.auto ? "auto" : plan.name;
|
|
1774
1964
|
const drawnIcon = CHART_TYPES[plan.name].icon;
|
|
@@ -1778,8 +1968,21 @@ function Toolbar(props) {
|
|
|
1778
1968
|
// the panels load with the chip menus (menus.js), on demand
|
|
1779
1969
|
options: (close) => /* @__PURE__ */ React10.createElement(MenuPanel, { name: "OptionsPanel", loadingText: labels.loadingMenu, props: { view, labels, onTotal, onExpand, onCollapse, close, tips, mod, folding, help: props.help } }),
|
|
1780
1970
|
views: (close) => /* @__PURE__ */ React10.createElement(MenuPanel, { name: "ViewsPanel", loadingText: labels.loadingMenu, props: { templates, labels, onLoad: onLoadTemplate, actions: templateActions, close, share } }),
|
|
1781
|
-
chartType: (close) => /* @__PURE__ */ React10.createElement(MenuPanel, { name: "ChartTypePanel", loadingText: labels.loadingMenu, props: { view, plan, labels, onChart, onDisplay: onChartDisplay, close } })
|
|
1971
|
+
chartType: (close) => /* @__PURE__ */ React10.createElement(MenuPanel, { name: "ChartTypePanel", loadingText: labels.loadingMenu, props: { view, plan, labels, onChart, onDisplay: onChartDisplay, close } }),
|
|
1972
|
+
data: (close) => data?.panel(close)
|
|
1782
1973
|
};
|
|
1974
|
+
const loadedMark = (testId) => data?.loaded ? dot(testId, labels.dataLoaded) : null;
|
|
1975
|
+
const resetWhy = !canReset ? labels.resetAlready : startEmpty ? labels.resetStartEmpty : void 0;
|
|
1976
|
+
const startOverItems = (close, prefix) => [
|
|
1977
|
+
/* @__PURE__ */ React10.createElement(Option, { key: "reset", inMenu: true, icon: "reset", hint: labels.resetHint, disabled: Boolean(resetWhy), reason: resetWhy, onSelect: () => {
|
|
1978
|
+
close();
|
|
1979
|
+
onReset();
|
|
1980
|
+
}, testId: `${prefix}reset` }, labels.reset),
|
|
1981
|
+
/* @__PURE__ */ React10.createElement(Option, { key: "new", inMenu: true, icon: "newFile", hint: labels.newHint, disabled: !canNew, reason: labels.newAlready, onSelect: () => {
|
|
1982
|
+
close();
|
|
1983
|
+
onNew();
|
|
1984
|
+
}, testId: `${prefix}new-report` }, labels.newEmpty)
|
|
1985
|
+
];
|
|
1783
1986
|
const actions = {
|
|
1784
1987
|
chartType: {
|
|
1785
1988
|
place: "chart",
|
|
@@ -1789,19 +1992,16 @@ function Toolbar(props) {
|
|
|
1789
1992
|
setPanel("chartType");
|
|
1790
1993
|
}, testId: "more-chart-type" }, `${chartTypeText}\u2026`)
|
|
1791
1994
|
},
|
|
1792
|
-
|
|
1995
|
+
startOver: {
|
|
1793
1996
|
place: "history",
|
|
1794
|
-
button: () => /* @__PURE__ */ React10.createElement(
|
|
1795
|
-
entry: (close) =>
|
|
1796
|
-
close();
|
|
1797
|
-
onReset();
|
|
1798
|
-
}, testId: "more-reset" }, labels.reset)
|
|
1997
|
+
button: () => /* @__PURE__ */ React10.createElement(MenuButton, { key: "startOver", label: labels.startOver, icon: "reset", text: labels.startOver, testId: "start-over", arrowOpens: true, off: resetWhy && !canNew ? labels.newAlready : void 0 }, (close) => startOverItems(close, "")),
|
|
1998
|
+
entry: (close) => startOverItems(close, "more-")
|
|
1799
1999
|
},
|
|
1800
2000
|
layout: {
|
|
1801
2001
|
place: "end",
|
|
1802
2002
|
// a toggle of the zones: the same text, open or folded; aria-pressed says which
|
|
1803
2003
|
button: () => /* @__PURE__ */ React10.createElement("button", { key: "layout", type: "button", className: "pk-btn pk-pressable", onClick: onLayout, "aria-pressed": !layoutFolded, "aria-controls": zonesId, title: labels.showLayout, "data-testid": "layout" }, /* @__PURE__ */ React10.createElement(Icon, { name: "layout" }), /* @__PURE__ */ React10.createElement("span", { className: "pk-btn-text" }, labels.layout)),
|
|
1804
|
-
entry: (close) => /* @__PURE__ */ React10.createElement(Option, { key: "layout", inMenu: true, icon: "layout", checked: !layoutFolded, onSelect: () => {
|
|
2004
|
+
entry: (close) => /* @__PURE__ */ React10.createElement(Option, { key: "layout", inMenu: true, checkbox: true, icon: "layout", checked: !layoutFolded, onSelect: () => {
|
|
1805
2005
|
close();
|
|
1806
2006
|
onLayout();
|
|
1807
2007
|
}, testId: "more-layout" }, labels.layout)
|
|
@@ -1814,6 +2014,19 @@ function Toolbar(props) {
|
|
|
1814
2014
|
setPanel("options");
|
|
1815
2015
|
}, testId: "more-options" }, `${labels.options}\u2026`)
|
|
1816
2016
|
},
|
|
2017
|
+
...data ? {
|
|
2018
|
+
data: {
|
|
2019
|
+
place: (
|
|
2020
|
+
/** @type {const} */
|
|
2021
|
+
"end"
|
|
2022
|
+
),
|
|
2023
|
+
button: () => /* @__PURE__ */ React10.createElement(MenuButton, { key: "data", label: labels.data, icon: "file", text: labels.data, role: "dialog", align: "end", testId: "data", mark: loadedMark("data-loaded") }, panels.data),
|
|
2024
|
+
entry: (close) => /* @__PURE__ */ React10.createElement(Option, { key: "data", inMenu: true, icon: "file", onSelect: () => {
|
|
2025
|
+
close();
|
|
2026
|
+
setPanel("data");
|
|
2027
|
+
}, testId: "more-data" }, `${labels.data}\u2026`, loadedMark("more-data-loaded"))
|
|
2028
|
+
}
|
|
2029
|
+
} : {},
|
|
1817
2030
|
views: {
|
|
1818
2031
|
place: "end",
|
|
1819
2032
|
button: () => /* @__PURE__ */ React10.createElement(MenuButton, { key: "views", label: labels.views, icon: "bookmark", text: labels.views, role: "dialog", align: "end", testId: "views", buttonRef: viewsButton }, panels.views),
|
|
@@ -1824,8 +2037,33 @@ function Toolbar(props) {
|
|
|
1824
2037
|
}
|
|
1825
2038
|
};
|
|
1826
2039
|
const ORDER = Object.keys(actions);
|
|
2040
|
+
const present = OVERFLOW_ORDER.filter((id) => ORDER.includes(id));
|
|
2041
|
+
const hiddenList = useOverflow(bar, `${labels.lang}:${labels.undo}:${size}:${present.join()}`, size === "narrow", present, texts);
|
|
2042
|
+
const hidden = new Set(hiddenList);
|
|
2043
|
+
if (panel && !hidden.has(panel)) {
|
|
2044
|
+
setPanel(null);
|
|
2045
|
+
}
|
|
2046
|
+
const closePanel = useCallback4(() => setPanel(null), []);
|
|
2047
|
+
const request = props.viewsRequest ?? 0;
|
|
2048
|
+
const [seenRequest, setSeenRequest] = useState8(request);
|
|
2049
|
+
const [clickFor, setClickFor] = useState8(0);
|
|
2050
|
+
if (request !== seenRequest) {
|
|
2051
|
+
setSeenRequest(request);
|
|
2052
|
+
if (hidden.has("views")) {
|
|
2053
|
+
setPanel("views");
|
|
2054
|
+
} else {
|
|
2055
|
+
setClickFor(request);
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
useEffect8(() => {
|
|
2059
|
+
const button = viewsButton.current;
|
|
2060
|
+
if (clickFor > 0 && button && button.getAttribute("aria-expanded") !== "true") {
|
|
2061
|
+
button.click();
|
|
2062
|
+
}
|
|
2063
|
+
}, [clickFor]);
|
|
1827
2064
|
const buttons = (place) => ORDER.filter((id) => actions[id].place === place && !hidden.has(id)).map((id) => actions[id].button());
|
|
1828
|
-
const
|
|
2065
|
+
const dot = (testId, text) => /* @__PURE__ */ React10.createElement("span", { className: "pk-view-changed", "data-testid": testId }, /* @__PURE__ */ React10.createElement("span", { className: "pk-sr" }, text));
|
|
2066
|
+
const changedMark = (testId) => dot(testId, labels.unsavedChanges);
|
|
1829
2067
|
const name = loadedView ? /* @__PURE__ */ React10.createElement(
|
|
1830
2068
|
"button",
|
|
1831
2069
|
{
|
|
@@ -1842,11 +2080,16 @@ function Toolbar(props) {
|
|
|
1842
2080
|
) : null;
|
|
1843
2081
|
const end = buttons("end");
|
|
1844
2082
|
const at = hidden.has("views") ? end.length : end.length - 1;
|
|
1845
|
-
const wrap =
|
|
1846
|
-
|
|
2083
|
+
const wrap = hidden.size > 0 && hidden.size >= present.length;
|
|
2084
|
+
const moreGroups = (close) => MORE_GROUPS.map((group) => group.filter((id) => hidden.has(id))).flatMap(
|
|
2085
|
+
(ids) => ids.length ? [
|
|
2086
|
+
/* @__PURE__ */ React10.createElement(Group, { key: ids[0], menu: true, label: ids[0] === "startOver" ? labels.startOver : void 0 }, ids.map((id) => actions[id].entry(close)))
|
|
2087
|
+
] : []
|
|
2088
|
+
);
|
|
2089
|
+
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: (
|
|
1847
2090
|
/** @type {any} */
|
|
1848
2091
|
drawnIcon
|
|
1849
|
-
) }), /* @__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 } })),
|
|
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);
|
|
1850
2093
|
}
|
|
1851
2094
|
|
|
1852
2095
|
// src/use-export.js
|
|
@@ -1960,9 +2203,9 @@ function reset(state, note) {
|
|
|
1960
2203
|
function schemaKeyOf(encoded) {
|
|
1961
2204
|
return JSON.stringify(encoded.schema.fields.map((f) => [f.name, f.type]));
|
|
1962
2205
|
}
|
|
1963
|
-
function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outsideNote, orderOf }) {
|
|
2206
|
+
function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outsideNote, orderOf, dataKey = 0, initial: initialState = null }) {
|
|
1964
2207
|
const controlled = view !== void 0;
|
|
1965
|
-
const schema = useMemo6(() => schemaKeyOf(encoded)
|
|
2208
|
+
const schema = useMemo6(() => `${dataKey}|${schemaKeyOf(encoded)}`, [encoded, dataKey]);
|
|
1966
2209
|
const json = useCallback6(
|
|
1967
2210
|
(v) => {
|
|
1968
2211
|
const normalized = normalize(v ?? emptyView(), encoded, { limits }).view;
|
|
@@ -1973,8 +2216,12 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
1973
2216
|
);
|
|
1974
2217
|
const [initial] = useState9(() => (controlled ? view : defaultView) ?? null);
|
|
1975
2218
|
const start = useMemo6(() => json(initial), [json, initial]);
|
|
1976
|
-
const [state, setState] = useState9(() => createState(schema, start));
|
|
2219
|
+
const [state, setState] = useState9(() => initialState ?? createState(schema, start));
|
|
1977
2220
|
const viewKey = controlled ? JSON.stringify(view) : null;
|
|
2221
|
+
const [toldOver, setToldOver] = useState9(() => initialState ? viewKey : null);
|
|
2222
|
+
if (toldOver !== null && toldOver !== viewKey) {
|
|
2223
|
+
setToldOver(null);
|
|
2224
|
+
}
|
|
1978
2225
|
const shown = useMemo6(() => {
|
|
1979
2226
|
if (viewKey !== null) {
|
|
1980
2227
|
return json(JSON.parse(viewKey));
|
|
@@ -1989,9 +2236,10 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
1989
2236
|
const apply = useCallback6(
|
|
1990
2237
|
(next) => {
|
|
1991
2238
|
setState(next);
|
|
2239
|
+
setToldOver(viewKey);
|
|
1992
2240
|
onViewChange?.(JSON.parse(next.present));
|
|
1993
2241
|
},
|
|
1994
|
-
[onViewChange]
|
|
2242
|
+
[onViewChange, viewKey]
|
|
1995
2243
|
);
|
|
1996
2244
|
const commit = useCallback6(
|
|
1997
2245
|
(next, note, tag) => {
|
|
@@ -2034,16 +2282,43 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2034
2282
|
[live, apply]
|
|
2035
2283
|
);
|
|
2036
2284
|
const restore = useCallback6((next, tag = null) => apply(createState(schema, start, json(next), tag)), [schema, start, json, apply]);
|
|
2285
|
+
const waiting = viewKey !== null && viewKey === toldOver && state.schema === schema;
|
|
2286
|
+
const made = waiting ? state : live;
|
|
2287
|
+
const snapshot = useCallback6(() => made, [made]);
|
|
2037
2288
|
const earlier = useCallback6(() => live.past.map((p) => JSON.parse(p.view)), [live.past]);
|
|
2038
2289
|
const canUndo = live.past.length > 0;
|
|
2039
2290
|
const canRedo = live.future.length > 0;
|
|
2040
2291
|
const canReset = live.present !== live.start;
|
|
2292
|
+
const emptyKey = useMemo6(() => json(null), [json]);
|
|
2293
|
+
const startEmpty = live.start === emptyKey;
|
|
2041
2294
|
return useMemo6(
|
|
2042
|
-
() => ({ view: current, viewKey: shown, tag: live.tag, setTag, commit, undo: undo2, redo: redo2, reset: reset2, restore, keyOf: json, earlier, canUndo, canRedo, canReset }),
|
|
2043
|
-
[current, shown, live.tag, setTag, commit, undo2, redo2, reset2, restore, json, earlier, canUndo, canRedo, canReset]
|
|
2295
|
+
() => ({ view: current, viewKey: shown, tag: live.tag, setTag, commit, undo: undo2, redo: redo2, reset: reset2, restore, keyOf: json, earlier, canUndo, canRedo, canReset, startEmpty, snapshot, replace: apply }),
|
|
2296
|
+
[current, shown, live.tag, setTag, commit, undo2, redo2, reset2, restore, json, earlier, canUndo, canRedo, canReset, startEmpty, snapshot, apply]
|
|
2044
2297
|
);
|
|
2045
2298
|
}
|
|
2046
2299
|
|
|
2300
|
+
// src/data-keep.js
|
|
2301
|
+
var KEPT_REPORTS = 4;
|
|
2302
|
+
var kept = /* @__PURE__ */ new Map();
|
|
2303
|
+
var hostIdentity = ({ dataKey, sourceId, schemaKey }) => JSON.stringify([sourceId ?? null, dataKey !== void 0 ? ["key", String(dataKey)] : ["columns", schemaKey]]);
|
|
2304
|
+
function keepData(key, entry) {
|
|
2305
|
+
kept.delete(key);
|
|
2306
|
+
kept.set(key, entry);
|
|
2307
|
+
while (kept.size > KEPT_REPORTS) {
|
|
2308
|
+
kept.delete(
|
|
2309
|
+
/** @type {string} */
|
|
2310
|
+
kept.keys().next().value
|
|
2311
|
+
);
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
function forgetData(key) {
|
|
2315
|
+
kept.delete(key);
|
|
2316
|
+
}
|
|
2317
|
+
function keptData(key, host) {
|
|
2318
|
+
const entry = kept.get(key);
|
|
2319
|
+
return entry && entry.host === host ? entry : null;
|
|
2320
|
+
}
|
|
2321
|
+
|
|
2047
2322
|
// src/use-big-result.js
|
|
2048
2323
|
import { useCallback as useCallback7, useEffect as useEffect9, useRef as useRef9, useState as useState10, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
2049
2324
|
function fullScreenSupported() {
|
|
@@ -2460,10 +2735,13 @@ function optionsKey(options) {
|
|
|
2460
2735
|
}
|
|
2461
2736
|
var here = () => typeof location !== "undefined" ? { href: location.href, hash: location.hash } : void 0;
|
|
2462
2737
|
var DEFER_ROWS = 1e4;
|
|
2738
|
+
var dataOf = (d) => Array.isArray(d) || Array.isArray(d?.columns) ? d : [];
|
|
2739
|
+
var rowsOf = (d) => Array.isArray(d) ? d.length : d?.data?.[0]?.length ?? 0;
|
|
2740
|
+
var NO_STEPS = Object.freeze({ past: [], future: [] });
|
|
2463
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 }));
|
|
2464
2742
|
function PivotReport(props) {
|
|
2465
2743
|
const { loading: loading2 = false, data, encoded } = props;
|
|
2466
|
-
const [deferred, setDeferred] = useState12(() => !encoded &&
|
|
2744
|
+
const [deferred, setDeferred] = useState12(() => !encoded && rowsOf(data) > DEFER_ROWS);
|
|
2467
2745
|
const [started, setStarted] = useState12(false);
|
|
2468
2746
|
useEffect11(() => {
|
|
2469
2747
|
if (!deferred) {
|
|
@@ -2497,15 +2775,16 @@ function WaitingReport({ locale = "en-US", labels: customLabels, theme = "auto",
|
|
|
2497
2775
|
const themeName = useResolvedTheme(theme, root);
|
|
2498
2776
|
return /* @__PURE__ */ React12.createElement("div", { ref: root, className: `pk-root${className ? ` ${className}` : ""}`, "data-pk-theme": themeName, lang: labels.lang, role: "region", "aria-label": label || labels.report, style: { height } }, /* @__PURE__ */ React12.createElement(Skeleton, { full: true, text: labels.loadingReport }));
|
|
2499
2777
|
}
|
|
2500
|
-
function
|
|
2501
|
-
|
|
2502
|
-
return
|
|
2778
|
+
function keyOfHostView(view) {
|
|
2779
|
+
try {
|
|
2780
|
+
return JSON.stringify(view ?? null) ?? "null";
|
|
2781
|
+
} catch {
|
|
2782
|
+
return "null";
|
|
2503
2783
|
}
|
|
2504
|
-
const key = Object.keys(fieldDefaults).find((k) => k.toLowerCase() === String(field).toLowerCase());
|
|
2505
|
-
return key === void 0 ? void 0 : fieldDefaults[key];
|
|
2506
2784
|
}
|
|
2507
|
-
|
|
2508
|
-
|
|
2785
|
+
var staysTheSame = () => () => void 0;
|
|
2786
|
+
function EmptyState({ labels, templates, onTemplate, onLoad, noData }) {
|
|
2787
|
+
return /* @__PURE__ */ React12.createElement("div", { className: "pk-empty", "data-testid": "empty-state" }, /* @__PURE__ */ React12.createElement("div", { className: "pk-empty-art", "aria-hidden": "true" }, /* @__PURE__ */ React12.createElement("span", { className: "pk-empty-chip pk-c1" }), /* @__PURE__ */ React12.createElement("span", { className: "pk-empty-chip pk-c2" }), /* @__PURE__ */ React12.createElement("span", { className: "pk-empty-chip pk-c3" })), /* @__PURE__ */ React12.createElement("h2", null, noData ? labels.emptyNoData : labels.emptyTitle), noData ? null : /* @__PURE__ */ React12.createElement("ol", { className: "pk-steps" }, labels.emptySteps.map((s, i) => /* @__PURE__ */ React12.createElement("li", { key: i }, /* @__PURE__ */ React12.createElement("span", { className: "pk-step-n", "aria-hidden": "true" }, i + 1), /* @__PURE__ */ React12.createElement("span", null, s)))), onLoad ? /* @__PURE__ */ React12.createElement("div", { className: "pk-drop-zone", "data-testid": "empty-drop" }, /* @__PURE__ */ React12.createElement("p", null, noData ? labels.emptyDrop : labels.emptyLoad), /* @__PURE__ */ React12.createElement("button", { type: "button", className: "pk-btn", onClick: onLoad, "data-testid": "empty-load" }, /* @__PURE__ */ React12.createElement(Icon, { name: "upload" }), /* @__PURE__ */ React12.createElement("span", { className: "pk-btn-text" }, labels.loadData))) : null, templates.length ? /* @__PURE__ */ React12.createElement("div", { className: "pk-empty-actions" }, templates.slice(0, 3).map((t, i) => /* @__PURE__ */ React12.createElement("button", { key: `${i}:${t.name}`, type: "button", className: "pk-btn", onClick: () => onTemplate(t) }, /* @__PURE__ */ React12.createElement(Icon, { name: "sparkle" }), /* @__PURE__ */ React12.createElement("span", { className: "pk-btn-text" }, fill(labels.tryView, { name: t.name }))))) : null);
|
|
2509
2788
|
}
|
|
2510
2789
|
function Report(props) {
|
|
2511
2790
|
const {
|
|
@@ -2551,11 +2830,27 @@ function Report(props) {
|
|
|
2551
2830
|
schemaUrl,
|
|
2552
2831
|
grow: growProp,
|
|
2553
2832
|
fieldList,
|
|
2554
|
-
loading: loading2 = false
|
|
2833
|
+
loading: loading2 = false,
|
|
2834
|
+
allowImport = false,
|
|
2835
|
+
plugins: pluginsProp,
|
|
2836
|
+
onDataLoad,
|
|
2837
|
+
importWorker
|
|
2555
2838
|
} = props;
|
|
2556
2839
|
const grow = growProp === "on" || growProp !== "off" && props.height === void 0;
|
|
2557
|
-
const
|
|
2558
|
-
const
|
|
2840
|
+
const hostSourceId = typeof sourceProp?.id === "string" && sourceProp.id ? sourceProp.id : void 0;
|
|
2841
|
+
const hostSourceName = typeof sourceProp?.name === "string" && sourceProp.name ? sourceProp.name : void 0;
|
|
2842
|
+
const [job, setJob] = useState12(
|
|
2843
|
+
/** @type {{ file: File, n: number } | null} */
|
|
2844
|
+
null
|
|
2845
|
+
);
|
|
2846
|
+
const [dragging, setDragging] = useState12(false);
|
|
2847
|
+
const dragDepth = useRef11(0);
|
|
2848
|
+
const [importMod, setImportMod] = useState12(importNow);
|
|
2849
|
+
const fileInput = useRef11(
|
|
2850
|
+
/** @type {HTMLInputElement | null} */
|
|
2851
|
+
null
|
|
2852
|
+
);
|
|
2853
|
+
const plugins = Array.isArray(pluginsProp) ? pluginsProp : [];
|
|
2559
2854
|
const labelsKey = JSON.stringify(customLabels ?? null);
|
|
2560
2855
|
const defaultsKey = JSON.stringify(fieldDefaults ?? null);
|
|
2561
2856
|
const info = useMemo8(() => fieldInfoOf(JSON.parse(defaultsKey)), [defaultsKey]);
|
|
@@ -2581,6 +2876,11 @@ function Report(props) {
|
|
|
2581
2876
|
);
|
|
2582
2877
|
const layoutFolded = folded ?? short;
|
|
2583
2878
|
const zonesId = useId4();
|
|
2879
|
+
const ownPrefix = useRef11(
|
|
2880
|
+
/** @type {string | null} */
|
|
2881
|
+
null
|
|
2882
|
+
);
|
|
2883
|
+
const formPrefix = useSyncExternalStore3(staysTheSame, () => ownPrefix.current ??= `pk-${Math.random().toString(36).slice(2, 8)}`, () => "pk");
|
|
2584
2884
|
const [drawer, setDrawer] = useState12(false);
|
|
2585
2885
|
const [filterTarget, setFilterTarget] = useState12(
|
|
2586
2886
|
/** @type {{ field: string, anchor: HTMLElement, base?: object } | null} */
|
|
@@ -2606,8 +2906,8 @@ function Report(props) {
|
|
|
2606
2906
|
useEffect11(() => onMenuTexts(() => setTexts((n) => n + 1)), []);
|
|
2607
2907
|
const [viewsRequest, setViewsRequest] = useState12(0);
|
|
2608
2908
|
const [leftOut, setLeftOut] = useState12(
|
|
2609
|
-
/** @type {import("./unused.jsx").UnusedNote[]} */
|
|
2610
|
-
[]
|
|
2909
|
+
/** @type {{ notes: import("./unused.jsx").UnusedNote[], loaded: any, after: string | null }} */
|
|
2910
|
+
{ notes: [], loaded: null, after: null }
|
|
2611
2911
|
);
|
|
2612
2912
|
const [issuesDismissed, setIssuesDismissed] = useState12(
|
|
2613
2913
|
/** @type {string | null} */
|
|
@@ -2615,10 +2915,6 @@ function Report(props) {
|
|
|
2615
2915
|
);
|
|
2616
2916
|
const [loads, setLoads] = useState12(0);
|
|
2617
2917
|
const [unusedSaid, setUnusedSaid] = useState12(false);
|
|
2618
|
-
const [savedKeys, setSavedKeys] = useState12(
|
|
2619
|
-
/** @type {Record<string, string>} */
|
|
2620
|
-
{}
|
|
2621
|
-
);
|
|
2622
2918
|
const [rowLabel, setRowLabel] = useState12(
|
|
2623
2919
|
/** @type {string | null} */
|
|
2624
2920
|
null
|
|
@@ -2637,17 +2933,30 @@ function Report(props) {
|
|
|
2637
2933
|
const source = useMemo8(() => {
|
|
2638
2934
|
try {
|
|
2639
2935
|
const types2 = JSON.parse(typesKey);
|
|
2640
|
-
const enc = encodedProp ?? measured("encode", () => encode(
|
|
2641
|
-
/** @type {any[]} */
|
|
2642
|
-
Array.isArray(data) ? data : [],
|
|
2643
|
-
{ timeZone: timeZone ?? "UTC", limits, ...types2 ? { types: types2 } : {} }
|
|
2644
|
-
));
|
|
2936
|
+
const enc = encodedProp ?? measured("encode", () => encode(dataOf(data), { timeZone: timeZone ?? "UTC", limits, ...types2 ? { types: types2 } : {} }));
|
|
2645
2937
|
return { encoded: enc, error: null };
|
|
2646
2938
|
} catch (error2) {
|
|
2647
2939
|
return { encoded: encode([]), error: error2 };
|
|
2648
2940
|
}
|
|
2649
2941
|
}, [encodedProp, dataIdentity, timeZone, limits, typesKey]);
|
|
2650
|
-
const
|
|
2942
|
+
const keepKey = allowImport && typeof storageKey === "string" && storageKey ? storageKey : null;
|
|
2943
|
+
const hostData = hostIdentity({ dataKey, sourceId: hostSourceId, schemaKey: schemaKeyOf(source.encoded) });
|
|
2944
|
+
const [kept2] = useState12(() => keepKey ? keptData(keepKey, hostData) : null);
|
|
2945
|
+
const [imported, setImported] = useState12(
|
|
2946
|
+
/** @type {import("./import-steps.js").ShownData | null} */
|
|
2947
|
+
kept2?.imported ?? null
|
|
2948
|
+
);
|
|
2949
|
+
const [dataSteps, setDataSteps] = useState12(
|
|
2950
|
+
/** @type {import("./data-history.js").DataSteps} */
|
|
2951
|
+
kept2?.steps ?? NO_STEPS
|
|
2952
|
+
);
|
|
2953
|
+
const [savedKeys, setSavedKeys] = useState12(
|
|
2954
|
+
/** @type {Record<string, string>} */
|
|
2955
|
+
kept2?.savedKeys ?? {}
|
|
2956
|
+
);
|
|
2957
|
+
const sourceId = imported ? imported.source.id : hostSourceId;
|
|
2958
|
+
const sourceName = imported ? imported.source.name : hostSourceName;
|
|
2959
|
+
const encoded = imported ? imported.encoded : source.encoded;
|
|
2651
2960
|
const fieldNamesKey = encoded.schema.fields.map((f) => f.name).join("\0");
|
|
2652
2961
|
const labels = useMemo8(() => {
|
|
2653
2962
|
const fields2 = displayNames(info, fieldNamesKey ? fieldNamesKey.split("\0") : []);
|
|
@@ -2666,8 +2975,23 @@ function Report(props) {
|
|
|
2666
2975
|
}
|
|
2667
2976
|
return (field) => orders.find(([name]) => name.toLowerCase() === field.toLowerCase())?.[1];
|
|
2668
2977
|
}, [ordersKey]);
|
|
2669
|
-
const history = useViewHistory({ encoded, view: viewProp, defaultView, onViewChange, limits, outsideNote: labels.steps.outside, orderOf });
|
|
2978
|
+
const history = useViewHistory({ encoded, view: viewProp, defaultView, onViewChange, limits, outsideNote: labels.steps.outside, orderOf, dataKey: imported ? imported.key : 0, initial: kept2?.history });
|
|
2670
2979
|
const view = history.view;
|
|
2980
|
+
const [startView] = useState12(() => defaultView);
|
|
2981
|
+
const hostKey = keyOfHostView(viewProp !== void 0 ? viewProp : startView);
|
|
2982
|
+
const keyOf = history.keyOf;
|
|
2983
|
+
const hostNotes = useMemo8(() => {
|
|
2984
|
+
if (hostKey === "null" || loading2 || imported || encoded.schema.fields.length === 0) {
|
|
2985
|
+
return null;
|
|
2986
|
+
}
|
|
2987
|
+
const raw = JSON.parse(hostKey);
|
|
2988
|
+
if (raw === null) {
|
|
2989
|
+
return null;
|
|
2990
|
+
}
|
|
2991
|
+
const notes2 = unusedNotes(normalize2(raw, encoded, { limits }).issues, raw);
|
|
2992
|
+
return notes2.length ? { notes: notes2, loaded: JSON.parse(keyOf(raw)) } : null;
|
|
2993
|
+
}, [hostKey, loading2, imported, encoded, limits, keyOf]);
|
|
2994
|
+
const leaveOut = useCallback9((notes2, given2) => setLeftOut({ notes: notes2, loaded: given2 ? JSON.parse(keyOf(given2)) : null, after: hostKey }), [keyOf, hostKey]);
|
|
2671
2995
|
const loadedView = tagFor(history.tag, sourceId);
|
|
2672
2996
|
const viewName = loadedView?.name ?? null;
|
|
2673
2997
|
const unsaved = Boolean(loadedView) && savedKeys[savedKeyOf(loadedView)] !== history.viewKey;
|
|
@@ -2686,26 +3010,32 @@ function Report(props) {
|
|
|
2686
3010
|
},
|
|
2687
3011
|
[labels]
|
|
2688
3012
|
);
|
|
2689
|
-
const
|
|
2690
|
-
|
|
3013
|
+
const apiNow = useRef11(
|
|
3014
|
+
/** @type {any} */
|
|
3015
|
+
null
|
|
3016
|
+
);
|
|
3017
|
+
const undo2 = () => {
|
|
3018
|
+
const note = history.canUndo || !importMod ? history.undo() : importMod.moveData(apiNow.current, true);
|
|
2691
3019
|
if (note !== null) {
|
|
2692
3020
|
announce(fill(labels.toastUndone, { step: note }));
|
|
2693
3021
|
}
|
|
2694
|
-
}
|
|
2695
|
-
const redo2 =
|
|
2696
|
-
const note = history.redo();
|
|
3022
|
+
};
|
|
3023
|
+
const redo2 = () => {
|
|
3024
|
+
const note = history.canRedo || !importMod ? history.redo() : importMod.moveData(apiNow.current, false);
|
|
2697
3025
|
if (note !== null) {
|
|
2698
3026
|
announce(fill(labels.toastRedone, { step: note }));
|
|
2699
3027
|
}
|
|
2700
|
-
}
|
|
3028
|
+
};
|
|
3029
|
+
const newStep = useCallback9(() => setDataSteps((s) => s.future.length ? { past: s.past, future: [] } : s), []);
|
|
2701
3030
|
const undoLater = useRef11(undo2);
|
|
2702
3031
|
useEffect11(() => {
|
|
2703
3032
|
undoLater.current = undo2;
|
|
2704
3033
|
});
|
|
2705
3034
|
const reset2 = useCallback9(() => {
|
|
2706
3035
|
history.reset(labels.steps.reset);
|
|
2707
|
-
|
|
2708
|
-
|
|
3036
|
+
newStep();
|
|
3037
|
+
announce(labels.toastReset, { action: { label: labels.undo, run: () => undoLater.current() } });
|
|
3038
|
+
}, [history, labels, announce, newStep]);
|
|
2709
3039
|
const param = linkParam(storageKey);
|
|
2710
3040
|
const [opening, setOpening] = useState12(false);
|
|
2711
3041
|
const appliedLink = useRef11(
|
|
@@ -2778,6 +3108,9 @@ function Report(props) {
|
|
|
2778
3108
|
);
|
|
2779
3109
|
}, []);
|
|
2780
3110
|
useIsoLayoutEffect(() => {
|
|
3111
|
+
if (kept2) {
|
|
3112
|
+
return;
|
|
3113
|
+
}
|
|
2781
3114
|
const page = here();
|
|
2782
3115
|
const link = shareLink ? readLinkParam(page?.hash ?? "", param) : null;
|
|
2783
3116
|
if (link) {
|
|
@@ -2825,18 +3158,19 @@ function Report(props) {
|
|
|
2825
3158
|
if (changed) {
|
|
2826
3159
|
changesRef.current += 1;
|
|
2827
3160
|
setChanges(changesRef.current);
|
|
3161
|
+
newStep();
|
|
2828
3162
|
}
|
|
2829
3163
|
if (!changed || !note.removed) {
|
|
2830
3164
|
return;
|
|
2831
3165
|
}
|
|
2832
3166
|
announce(fill(labels.toastRemoved, { field: note.field ?? "" }).trim(), { action: { label: labels.undo, run: () => undoLater.current() } });
|
|
2833
3167
|
},
|
|
2834
|
-
[history, stepText, labels, announce, limits, locale]
|
|
3168
|
+
[history, stepText, labels, announce, limits, locale, newStep]
|
|
2835
3169
|
);
|
|
2836
3170
|
const remember = useCallback9((tag, key) => setSavedKeys((all) => ({ ...all, [savedKeyOf(tag)]: key })), []);
|
|
2837
3171
|
const applyLoaded = useCallback9(
|
|
2838
3172
|
/** @param {import("./share.js").LoadedView} loaded @param {{ link?: boolean, restored?: boolean }} [how] */
|
|
2839
|
-
(loaded3, { link = false, restored = false } = {}) => {
|
|
3173
|
+
(loaded3, { link = false, restored: restored2 = false } = {}) => {
|
|
2840
3174
|
if (!loaded3.view) {
|
|
2841
3175
|
return;
|
|
2842
3176
|
}
|
|
@@ -2844,20 +3178,20 @@ function Report(props) {
|
|
|
2844
3178
|
if (tag) {
|
|
2845
3179
|
remember(tag, latest.current.history.keyOf(loaded3.view));
|
|
2846
3180
|
}
|
|
2847
|
-
if (
|
|
3181
|
+
if (restored2) {
|
|
2848
3182
|
latest.current.history.setTag(tag);
|
|
2849
3183
|
} else {
|
|
2850
3184
|
commit(loaded3.view, { step: "viewLoaded" }, tag);
|
|
2851
3185
|
}
|
|
2852
3186
|
const notes2 = unusedNotes(loaded3.issues, loaded3.file?.view);
|
|
2853
|
-
|
|
3187
|
+
leaveOut(notes2, loaded3.view);
|
|
2854
3188
|
setIssuesDismissed(null);
|
|
2855
3189
|
setLoads((x) => x + 1);
|
|
2856
3190
|
setUnusedSaid(notes2.length > 0);
|
|
2857
3191
|
const text = link ? notes2.length ? labels.toastLinkOpenedPartly : labels.toastLinkOpened : notes2.length ? labels.toastViewLoadedPartly : labels.toastViewLoaded;
|
|
2858
|
-
announce(text,
|
|
3192
|
+
announce(text, restored2 ? void 0 : { action: { label: labels.undo, run: () => undoLater.current() } });
|
|
2859
3193
|
},
|
|
2860
|
-
[commit, labels, announce, remember]
|
|
3194
|
+
[commit, labels, announce, remember, leaveOut]
|
|
2861
3195
|
);
|
|
2862
3196
|
useEffect11(() => {
|
|
2863
3197
|
latest.current = { history, encoded, limits, labels, announce, commit, sourceId, loaded: applyLoaded, sources, onSourceSwitch };
|
|
@@ -2996,15 +3330,15 @@ function Report(props) {
|
|
|
2996
3330
|
panelRef.current.inert = size === "narrow" && !drawerOpen;
|
|
2997
3331
|
}
|
|
2998
3332
|
}, [size, drawerOpen]);
|
|
3333
|
+
const defaultsOf = useCallback9((field) => fieldDefaultsFor(fieldDefaults, field, encoded.column(field)), [fieldDefaults, encoded]);
|
|
2999
3334
|
const placeOptions = useCallback9(
|
|
3000
3335
|
(field, zone, index = void 0) => {
|
|
3001
3336
|
const column = encoded.column(field);
|
|
3002
3337
|
const unit = zone !== "values" && column && column.type === "date" && !column.derived ? suggestDateUnit(encoded, field) : null;
|
|
3003
|
-
return { index, type: typeOf(field), defaults:
|
|
3338
|
+
return { index, type: typeOf(field), defaults: defaultsOf(field), dateUnit: unit, groupName: unit ? groupingName(nameOf(column.name), unit, labels) : void 0 };
|
|
3004
3339
|
},
|
|
3005
|
-
[encoded, typeOf,
|
|
3340
|
+
[encoded, typeOf, defaultsOf, labels, nameOf]
|
|
3006
3341
|
);
|
|
3007
|
-
const defaultsOf = useCallback9((field) => defaultsFor(fieldDefaults, field), [fieldDefaults]);
|
|
3008
3342
|
const addTo = useCallback9(
|
|
3009
3343
|
(field, zone, index = void 0) => {
|
|
3010
3344
|
const options = placeOptions(field, zone, index);
|
|
@@ -3047,10 +3381,10 @@ function Report(props) {
|
|
|
3047
3381
|
target.zone
|
|
3048
3382
|
);
|
|
3049
3383
|
const note = src.zone !== zone ? { step: "moved", field: src.label ?? src.field, zone } : { step: "reordered", zone };
|
|
3050
|
-
commit(moveField(view, src.zone, src.index, zone, target.index, { type: typeOf(src.field) }), note);
|
|
3384
|
+
commit(moveField(view, src.zone, src.index, zone, target.index, { type: typeOf(src.field), defaults: zone === "values" && src.field ? defaultsOf(src.field) : void 0 }), note);
|
|
3051
3385
|
}
|
|
3052
3386
|
},
|
|
3053
|
-
[view, typeOf, commit, addTo]
|
|
3387
|
+
[view, typeOf, commit, addTo, defaultsOf]
|
|
3054
3388
|
);
|
|
3055
3389
|
const openCell = useCallback9(
|
|
3056
3390
|
/** @param {any} cell */
|
|
@@ -3059,19 +3393,95 @@ function Report(props) {
|
|
|
3059
3393
|
return;
|
|
3060
3394
|
}
|
|
3061
3395
|
setHinted(true);
|
|
3062
|
-
const { count, rows, indices } = drillRows(result, { rowPath, colPath, data: encodedProp ? null : data, limit: drillDownLimit });
|
|
3396
|
+
const { count, rows, indices } = drillRows(result, { rowPath, colPath, data: encodedProp || imported || !Array.isArray(data) ? null : data, limit: drillDownLimit });
|
|
3063
3397
|
onCellClick?.({ row: rowPath, col: colPath, value, valueIndex, text, count, rows });
|
|
3064
3398
|
if (drillDown) {
|
|
3065
3399
|
const formatOf = (name) => {
|
|
3066
|
-
const d =
|
|
3400
|
+
const d = defaultsOf(name);
|
|
3067
3401
|
return d ? d.drillFormat ?? d.format : void 0;
|
|
3068
3402
|
};
|
|
3069
3403
|
setDrill({ result, rowPath, colPath, count, indices, formatOf, nameOf, infoOf });
|
|
3070
3404
|
}
|
|
3071
3405
|
},
|
|
3072
|
-
[result, encodedProp, data, drillDownLimit, onCellClick, drillDown,
|
|
3406
|
+
[result, encodedProp, imported, data, drillDownLimit, onCellClick, drillDown, defaultsOf, nameOf, infoOf]
|
|
3073
3407
|
);
|
|
3074
3408
|
const doExport = useExport({ fileName, result, locale, labels, limits, root, chartRef, announce, onExport });
|
|
3409
|
+
const requestImport = () => loadImport().then((m) => (flushSync(() => setImportMod(() => m)), m));
|
|
3410
|
+
const api = {
|
|
3411
|
+
imported,
|
|
3412
|
+
setImported,
|
|
3413
|
+
steps: dataSteps,
|
|
3414
|
+
setSteps: setDataSteps,
|
|
3415
|
+
job,
|
|
3416
|
+
setJob,
|
|
3417
|
+
dragging,
|
|
3418
|
+
history,
|
|
3419
|
+
encoded,
|
|
3420
|
+
hostEncoded: source.encoded,
|
|
3421
|
+
hostSource: sourceProp,
|
|
3422
|
+
sourceName,
|
|
3423
|
+
labels,
|
|
3424
|
+
locale,
|
|
3425
|
+
plugins,
|
|
3426
|
+
worker: importWorker,
|
|
3427
|
+
limits,
|
|
3428
|
+
timeZone,
|
|
3429
|
+
onDataLoad,
|
|
3430
|
+
announce,
|
|
3431
|
+
dismiss,
|
|
3432
|
+
undo: () => undoLater.current(),
|
|
3433
|
+
box: () => root.current?.getBoundingClientRect(),
|
|
3434
|
+
pick: () => importMod?.pickFile(fileInput.current),
|
|
3435
|
+
load: requestImport
|
|
3436
|
+
};
|
|
3437
|
+
useEffect11(() => {
|
|
3438
|
+
apiNow.current = api;
|
|
3439
|
+
});
|
|
3440
|
+
const restored = useRef11(false);
|
|
3441
|
+
useIsoLayoutEffect(() => {
|
|
3442
|
+
if (kept2 && !restored.current) {
|
|
3443
|
+
restored.current = true;
|
|
3444
|
+
importMod?.restoreData(api);
|
|
3445
|
+
history.replace(kept2.history);
|
|
3446
|
+
}
|
|
3447
|
+
}, []);
|
|
3448
|
+
const snapshot = history.snapshot;
|
|
3449
|
+
const keptKey = useRef11(keepKey);
|
|
3450
|
+
const fileShown = useRef11(false);
|
|
3451
|
+
const hostHasColumns = source.encoded.schema.fields.length > 0;
|
|
3452
|
+
useIsoLayoutEffect(() => {
|
|
3453
|
+
if (keepKey !== null && !kept2 && hostHasColumns) {
|
|
3454
|
+
forgetData(keepKey);
|
|
3455
|
+
}
|
|
3456
|
+
}, []);
|
|
3457
|
+
useEffect11(() => {
|
|
3458
|
+
if (keptKey.current !== keepKey && keptKey.current !== null) {
|
|
3459
|
+
forgetData(keptKey.current);
|
|
3460
|
+
}
|
|
3461
|
+
keptKey.current = keepKey;
|
|
3462
|
+
if (keepKey === null) {
|
|
3463
|
+
return;
|
|
3464
|
+
}
|
|
3465
|
+
if (imported) {
|
|
3466
|
+
fileShown.current = true;
|
|
3467
|
+
keepData(keepKey, { host: hostData, imported, steps: dataSteps, history: snapshot(), savedKeys });
|
|
3468
|
+
} else if (fileShown.current) {
|
|
3469
|
+
fileShown.current = false;
|
|
3470
|
+
forgetData(keepKey);
|
|
3471
|
+
}
|
|
3472
|
+
}, [keepKey, hostData, imported, dataSteps, snapshot, savedKeys]);
|
|
3473
|
+
const fileDrag = (e) => {
|
|
3474
|
+
if (!Array.prototype.includes.call(e.dataTransfer?.types ?? [], "Files")) {
|
|
3475
|
+
return;
|
|
3476
|
+
}
|
|
3477
|
+
e.preventDefault();
|
|
3478
|
+
const files = e.type === "drop" ? [...e.dataTransfer.files] : null;
|
|
3479
|
+
dragDepth.current = files ? 0 : Math.max(0, dragDepth.current + (e.type === "dragenter" ? 1 : e.type === "dragleave" ? -1 : 0));
|
|
3480
|
+
setDragging(dragDepth.current > 0);
|
|
3481
|
+
if (e.type !== "dragover") {
|
|
3482
|
+
requestImport().then((m) => files && m.startFiles(apiNow.current, files), () => void 0);
|
|
3483
|
+
}
|
|
3484
|
+
};
|
|
3075
3485
|
const base = shareBase(shareLink, here()?.href);
|
|
3076
3486
|
const share = {
|
|
3077
3487
|
canLink: base !== null,
|
|
@@ -3100,20 +3510,20 @@ function Report(props) {
|
|
|
3100
3510
|
commit(t.view, { step: "template", name: t.name }, tag);
|
|
3101
3511
|
const over = zoneOverLimit(t.view, limits);
|
|
3102
3512
|
const issues = normalize2(t.view, encoded, { limits }).issues.filter((i) => !over || i.code !== "tooMany");
|
|
3103
|
-
|
|
3513
|
+
leaveOut([...over ? [{ text: fill(labels.viewTrimmed, { name: t.name, zone: labels.zones[over.zone], max: over.max.toLocaleString(locale) }), path: over.zone }] : [], ...unusedNotes(issues, t.view)], t.view);
|
|
3104
3514
|
setIssuesDismissed(null);
|
|
3105
3515
|
setLoads((x) => x + 1);
|
|
3106
3516
|
setUnusedSaid(false);
|
|
3107
3517
|
announce(fill(labels.toastLoaded, { name: t.name }));
|
|
3108
3518
|
},
|
|
3109
|
-
[commit, labels, announce, limits, locale, history, remember, sourceId, encoded]
|
|
3519
|
+
[commit, labels, announce, limits, locale, history, remember, sourceId, encoded, leaveOut]
|
|
3110
3520
|
);
|
|
3111
3521
|
const newReport = () => {
|
|
3112
3522
|
if (empty) {
|
|
3113
3523
|
return;
|
|
3114
3524
|
}
|
|
3115
3525
|
commit(emptyView2(), { step: "new" }, null);
|
|
3116
|
-
|
|
3526
|
+
leaveOut([], null);
|
|
3117
3527
|
setLoads((x) => x + 1);
|
|
3118
3528
|
setUnusedSaid(false);
|
|
3119
3529
|
announce(labels.newEmpty, { action: { label: labels.undo, run: () => undoLater.current() } });
|
|
@@ -3155,9 +3565,7 @@ function Report(props) {
|
|
|
3155
3565
|
now.setTag(tag);
|
|
3156
3566
|
}
|
|
3157
3567
|
},
|
|
3158
|
-
viewKey: history.viewKey
|
|
3159
|
-
onNew: newReport,
|
|
3160
|
-
canNew: !empty
|
|
3568
|
+
viewKey: history.viewKey
|
|
3161
3569
|
};
|
|
3162
3570
|
const onKeyDown = (e) => {
|
|
3163
3571
|
const target = (
|
|
@@ -3169,7 +3577,7 @@ function Report(props) {
|
|
|
3169
3577
|
big.setEnlarged(false);
|
|
3170
3578
|
return;
|
|
3171
3579
|
}
|
|
3172
|
-
if (target.closest("input, textarea, select, [contenteditable]")) {
|
|
3580
|
+
if (target.closest("input, textarea, select, [contenteditable], [aria-modal='true']")) {
|
|
3173
3581
|
return;
|
|
3174
3582
|
}
|
|
3175
3583
|
const mod = e.ctrlKey || e.metaKey;
|
|
@@ -3306,8 +3714,16 @@ function Report(props) {
|
|
|
3306
3714
|
appliedLink.current = null;
|
|
3307
3715
|
setLinkCheck(null);
|
|
3308
3716
|
};
|
|
3309
|
-
const
|
|
3310
|
-
const
|
|
3717
|
+
const fromHost = hostNotes !== null && leftOut.after !== hostKey;
|
|
3718
|
+
const given = fromHost ? hostNotes : leftOut;
|
|
3719
|
+
const notes = useMemo8(
|
|
3720
|
+
() => [...given.notes.filter((n) => stillApplies(n, given.loaded, view)), ...result && !empty ? result.issues.slice(0, 20).map((issue) => ({ issue, raw: view })) : []],
|
|
3721
|
+
[given, result, empty, view]
|
|
3722
|
+
);
|
|
3723
|
+
const notesKey = useMemo8(
|
|
3724
|
+
() => JSON.stringify([fromHost ? "host" : loads, ...given.notes.map((n) => "issue" in n ? [n.issue.path, n.issue.message] : n.text), ...result && !empty ? result.issues.slice(0, 20).map((i) => [i.path, i.message]) : []]),
|
|
3725
|
+
[fromHost, given, loads, result, empty]
|
|
3726
|
+
);
|
|
3311
3727
|
const summaryParts = big.enlarged ? layoutSummary(zoneEntries(view, types, labels), labels) : [];
|
|
3312
3728
|
const summaryText = summaryParts.length ? summaryParts.map((p) => `${p.title}: ${p.fields}`).join(" \xB7 ") : labels.layoutEmpty;
|
|
3313
3729
|
return /* @__PURE__ */ React12.createElement(
|
|
@@ -3326,9 +3742,13 @@ function Report(props) {
|
|
|
3326
3742
|
"aria-label": label || labels.report,
|
|
3327
3743
|
style: { height },
|
|
3328
3744
|
tabIndex: -1,
|
|
3329
|
-
onKeyDown
|
|
3745
|
+
onKeyDown,
|
|
3746
|
+
onDragEnter: allowImport ? fileDrag : void 0,
|
|
3747
|
+
onDragOver: allowImport ? fileDrag : void 0,
|
|
3748
|
+
onDragLeave: allowImport ? fileDrag : void 0,
|
|
3749
|
+
onDrop: allowImport ? fileDrag : void 0
|
|
3330
3750
|
},
|
|
3331
|
-
/* @__PURE__ */ React12.createElement(LayerContext.Provider, { value: layerValue }, /* @__PURE__ */ React12.createElement(HelpContext.Provider, { value: help }, /* @__PURE__ */ React12.createElement(
|
|
3751
|
+
/* @__PURE__ */ React12.createElement(LayerContext.Provider, { value: layerValue }, /* @__PURE__ */ React12.createElement(FormNameContext.Provider, { value: formPrefix }, /* @__PURE__ */ React12.createElement(HelpContext.Provider, { value: help }, /* @__PURE__ */ React12.createElement(
|
|
3332
3752
|
PivotDnd,
|
|
3333
3753
|
{
|
|
3334
3754
|
labels,
|
|
@@ -3374,12 +3794,15 @@ function Report(props) {
|
|
|
3374
3794
|
chartPlan: plan,
|
|
3375
3795
|
labels,
|
|
3376
3796
|
size,
|
|
3377
|
-
canUndo: history.canUndo,
|
|
3378
|
-
canRedo: history.canRedo,
|
|
3797
|
+
canUndo: history.canUndo || dataSteps.past.length > 0,
|
|
3798
|
+
canRedo: history.canRedo || dataSteps.future.length > 0,
|
|
3379
3799
|
canReset: history.canReset,
|
|
3800
|
+
startEmpty: history.startEmpty,
|
|
3801
|
+
canNew: !empty,
|
|
3380
3802
|
onUndo: undo2,
|
|
3381
3803
|
onRedo: redo2,
|
|
3382
3804
|
onReset: reset2,
|
|
3805
|
+
onNew: newReport,
|
|
3383
3806
|
loadedView: loadedView ? { name: loadedView.name, changed: unsaved } : null,
|
|
3384
3807
|
onDisplay: (d) => commit(setDisplay(view, d), { step: "display", display: d }),
|
|
3385
3808
|
onChart: (p) => commit(setChart(view, p), { step: "chart", type: p }),
|
|
@@ -3408,7 +3831,8 @@ function Report(props) {
|
|
|
3408
3831
|
help: {
|
|
3409
3832
|
explanations: explainUser ? { on: !dismissed.includes(NO_EXPLANATIONS), set: (on) => toggle(NO_EXPLANATIONS, on) } : null
|
|
3410
3833
|
},
|
|
3411
|
-
viewsRequest
|
|
3834
|
+
viewsRequest,
|
|
3835
|
+
data: allowImport ? { loaded: Boolean(imported), panel: (close) => /* @__PURE__ */ React12.createElement(MenuPanel, { name: "DataMenu", loadingText: labels.loadingMenu, props: { api, close, labels } }) } : null
|
|
3412
3836
|
}
|
|
3413
3837
|
), /* @__PURE__ */ React12.createElement(
|
|
3414
3838
|
Zones,
|
|
@@ -3445,7 +3869,7 @@ function Report(props) {
|
|
|
3445
3869
|
labels,
|
|
3446
3870
|
locale,
|
|
3447
3871
|
narrow: size === "narrow",
|
|
3448
|
-
quiet: unusedSaid
|
|
3872
|
+
quiet: unusedSaid && !fromHost
|
|
3449
3873
|
}
|
|
3450
3874
|
), /* @__PURE__ */ React12.createElement(
|
|
3451
3875
|
Tips,
|
|
@@ -3456,7 +3880,7 @@ function Report(props) {
|
|
|
3456
3880
|
onAction: runTip,
|
|
3457
3881
|
focusFallback: () => root.current?.focus({ preventScroll: true })
|
|
3458
3882
|
}
|
|
3459
|
-
), 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: loadTemplate }) : view.display === "chart" && chartResult ? /* @__PURE__ */ React12.createElement(
|
|
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: loadTemplate, 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(
|
|
3460
3884
|
PivotChart,
|
|
3461
3885
|
{
|
|
3462
3886
|
result: chartResult,
|
|
@@ -3474,9 +3898,9 @@ function Report(props) {
|
|
|
3474
3898
|
},
|
|
3475
3899
|
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 ?? "") })
|
|
3476
3900
|
}
|
|
3477
|
-
) : 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 }) : ""), 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),
|
|
3901
|
+
) : 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),
|
|
3478
3902
|
filterTarget ? /* @__PURE__ */ React12.createElement(MenuPanel, { name: "FilterPopover", props: { target: filterTarget, onClose: closeFilter, view, encoded, locale, labels, commit } }) : null
|
|
3479
|
-
), /* @__PURE__ */ React12.createElement("div", { className: "pk-layer", ref: setLayer }, /* @__PURE__ */ React12.createElement("span", { className: "pk-origin", "aria-hidden": "true" }))))
|
|
3903
|
+
), 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" })))))
|
|
3480
3904
|
);
|
|
3481
3905
|
}
|
|
3482
3906
|
export {
|