pivotkit-react 0.8.2 → 0.9.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 +93 -1
- package/dist/chunks/chunk-24T2VRMU.js +1010 -0
- package/dist/chunks/chunk-6R7TJHS3.js +212 -0
- package/dist/chunks/{chunk-GUSQWPTH.js → chunk-EPGRJSPP.js} +20 -5
- package/dist/chunks/{chunk-JAOOFDNR.js → chunk-FAAQZSR4.js} +4 -1
- package/dist/chunks/{chunk-2N2UGSIG.js → chunk-FI22Z6CC.js} +5 -2
- package/dist/chunks/{chunk-ZM45YU3W.js → chunk-G3R5C3J7.js} +28 -6
- package/dist/chunks/{chunk-MU5BTKSY.js → chunk-QCBVEI23.js} +6 -2
- package/dist/chunks/{chunk-6OWC6X5W.js → chunk-QVE7JM4G.js} +1 -1
- package/dist/chunks/{chunk-3WWWKPB4.js → chunk-V233JHVY.js} +75 -336
- package/dist/chunks/chunk-W6BG3GGS.js +679 -0
- package/dist/chunks/chunk-YAT2TFMK.js +138 -0
- package/dist/chunks/chunk-ZQ2M3U74.js +341 -0
- package/dist/chunks/{unused-texts-de-GB3IWWEM.js → labels-de-ZC3CSQZR.js} +1 -1
- package/dist/chunks/tips-SYGQPI3Q.js +22 -0
- package/dist/chunks/{unused-texts-LRYVWFFN.js → unused-texts-ERQ6ACNX.js} +1 -1
- package/dist/chunks/unused-texts-de-AC5GS3FS.js +6 -0
- package/dist/deferred-late.js +13 -0
- package/dist/deferred.js +18 -0
- package/dist/echarts.js +30 -6
- package/dist/import-ui.js +3 -3
- package/dist/index.js +427 -202
- package/dist/labels.js +15 -12
- package/dist/menu-texts-de.js +1 -1
- package/dist/menus.js +518 -381
- package/dist/styles.css +128 -9
- package/package.json +5 -4
- package/types/PivotReport.d.ts +3 -1
- package/types/chart-tooltip.d.ts +18 -1
- package/types/chart-types.d.ts +7 -2
- package/types/chart.d.ts +10 -2
- package/types/chip-menus.d.ts +1 -1
- package/types/deferred-late.d.ts +2 -0
- package/types/deferred.d.ts +28 -0
- package/types/field-info.d.ts +6 -3
- package/types/fields.d.ts +3 -2
- package/types/icons.d.ts +2 -0
- package/types/index.d.ts +20 -10
- package/types/labels-de.d.ts +2 -0
- package/types/labels.d.ts +55 -459
- package/types/lazy-menus.d.ts +2 -2
- package/types/menu-labels.d.ts +20 -0
- package/types/menu-ops.d.ts +33 -0
- package/types/menu-topics.d.ts +6 -3
- package/types/menus.d.ts +1 -0
- package/types/names.d.ts +20 -2
- package/types/notices.d.ts +212 -0
- package/types/point-menu.d.ts +21 -0
- package/types/quick-choices.d.ts +28 -0
- package/types/side-by-side.d.ts +19 -0
- package/types/tip-state.d.ts +97 -0
- package/types/tips.d.ts +13 -250
- package/types/unused-texts.d.ts +3 -0
- package/types/view-ops.d.ts +27 -14
- package/types/view-tabs.d.ts +4 -3
- package/dist/chunks/chunk-W2SVDHGN.js +0 -1898
package/dist/index.js
CHANGED
|
@@ -1,30 +1,67 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ALL_TIPS,
|
|
3
|
-
CHART_TYPES,
|
|
4
2
|
ClearInput,
|
|
5
3
|
DRILL_LIMIT,
|
|
6
|
-
FIELDS_COLLAPSED,
|
|
7
4
|
HelpContext,
|
|
8
5
|
InfoButton,
|
|
6
|
+
dateContext,
|
|
7
|
+
dateDisplayLocale,
|
|
8
|
+
dateRangeText,
|
|
9
|
+
displayNames,
|
|
10
|
+
drillRows,
|
|
11
|
+
fieldDefaultsFor,
|
|
12
|
+
fieldInfoOf,
|
|
13
|
+
importNow,
|
|
14
|
+
linkNow,
|
|
15
|
+
loadCheck,
|
|
16
|
+
loadImport,
|
|
17
|
+
loadLink,
|
|
18
|
+
matchingFields,
|
|
19
|
+
readLinkParam,
|
|
20
|
+
readStoredView,
|
|
21
|
+
shareBase,
|
|
22
|
+
typesOf,
|
|
23
|
+
viewFromObject,
|
|
24
|
+
writeStoredView
|
|
25
|
+
} from "./chunks/chunk-W6BG3GGS.js";
|
|
26
|
+
import {
|
|
27
|
+
FormNameContext,
|
|
28
|
+
Group,
|
|
29
|
+
Icon,
|
|
30
|
+
LayerContext,
|
|
31
|
+
MenuButton,
|
|
32
|
+
Option,
|
|
33
|
+
Popover,
|
|
34
|
+
TYPE_ICON,
|
|
35
|
+
ZONE_ICON,
|
|
36
|
+
activeIn,
|
|
37
|
+
rootOf,
|
|
38
|
+
tabStops,
|
|
39
|
+
useIsoLayoutEffect,
|
|
40
|
+
useModal
|
|
41
|
+
} from "./chunks/chunk-FAAQZSR4.js";
|
|
42
|
+
import {
|
|
43
|
+
NOTICES,
|
|
44
|
+
activeEntries,
|
|
45
|
+
tipActionText,
|
|
46
|
+
tipContext,
|
|
47
|
+
tipText
|
|
48
|
+
} from "./chunks/chunk-YAT2TFMK.js";
|
|
49
|
+
import {
|
|
50
|
+
ALL_TIPS,
|
|
51
|
+
CHART_TYPES,
|
|
52
|
+
FIELDS_COLLAPSED,
|
|
53
|
+
ITEM_TYPES,
|
|
9
54
|
MAX_CATEGORIES,
|
|
10
55
|
NO_EXPLANATIONS,
|
|
11
|
-
SLICE_TYPES,
|
|
12
56
|
ZONES,
|
|
13
|
-
activeTips,
|
|
14
57
|
addField,
|
|
15
58
|
allowedTips,
|
|
16
59
|
chartPlan,
|
|
17
60
|
chartTypeOf,
|
|
18
61
|
cleanDismissed,
|
|
19
|
-
|
|
20
|
-
dateDisplayLocale,
|
|
21
|
-
dateRangeText,
|
|
62
|
+
columnText,
|
|
22
63
|
dateSpan,
|
|
23
|
-
displayNames,
|
|
24
|
-
drillRows,
|
|
25
64
|
fieldAction,
|
|
26
|
-
fieldDefaultsFor,
|
|
27
|
-
fieldInfoOf,
|
|
28
65
|
fieldsCollapsed,
|
|
29
66
|
filterZoneFields,
|
|
30
67
|
filtersOf,
|
|
@@ -34,26 +71,18 @@ import {
|
|
|
34
71
|
headerSortTarget,
|
|
35
72
|
helpSwitch,
|
|
36
73
|
hiddenAfter,
|
|
37
|
-
importNow,
|
|
38
74
|
isEmptyPick,
|
|
39
75
|
isEmptyView,
|
|
40
76
|
itemRuleText,
|
|
41
77
|
keptOnReset,
|
|
42
78
|
layoutSummary,
|
|
43
|
-
linkNow,
|
|
44
|
-
loadCheck,
|
|
45
|
-
loadImport,
|
|
46
|
-
loadLink,
|
|
47
79
|
localStore,
|
|
48
|
-
matchingFields,
|
|
49
80
|
moveField,
|
|
50
81
|
nextHeaderSort,
|
|
51
82
|
numberRange,
|
|
52
83
|
parseStored,
|
|
53
84
|
readItem,
|
|
54
|
-
readLinkParam,
|
|
55
85
|
readStored,
|
|
56
|
-
readStoredView,
|
|
57
86
|
refLabel,
|
|
58
87
|
removeAt,
|
|
59
88
|
rowFolding,
|
|
@@ -65,62 +94,45 @@ import {
|
|
|
65
94
|
setDisplay,
|
|
66
95
|
setSort,
|
|
67
96
|
setTotal,
|
|
68
|
-
shareBase,
|
|
69
97
|
sortOf,
|
|
70
98
|
sortText,
|
|
99
|
+
sourceFieldName,
|
|
71
100
|
sourceOf,
|
|
72
101
|
subscribeItem,
|
|
73
102
|
subscribeStored,
|
|
74
103
|
swapAxes,
|
|
75
|
-
tipActionText,
|
|
76
|
-
tipContext,
|
|
77
|
-
tipText,
|
|
78
104
|
toggleCollapsed,
|
|
79
|
-
typesOf,
|
|
80
105
|
valueConditionText,
|
|
81
106
|
valueLabel,
|
|
82
107
|
valueLabels,
|
|
83
|
-
viewFromObject,
|
|
84
108
|
withHostOrders,
|
|
85
109
|
withoutFilters,
|
|
86
110
|
writeDismissed,
|
|
87
111
|
writeItem,
|
|
88
|
-
writeStoredView,
|
|
89
112
|
zoneMax,
|
|
90
113
|
zoneOverLimit
|
|
91
|
-
} from "./chunks/chunk-
|
|
92
|
-
import {
|
|
93
|
-
FormNameContext,
|
|
94
|
-
Group,
|
|
95
|
-
Icon,
|
|
96
|
-
LayerContext,
|
|
97
|
-
MenuButton,
|
|
98
|
-
Option,
|
|
99
|
-
Popover,
|
|
100
|
-
TYPE_ICON,
|
|
101
|
-
ZONE_ICON,
|
|
102
|
-
activeIn,
|
|
103
|
-
rootOf,
|
|
104
|
-
tabStops,
|
|
105
|
-
useIsoLayoutEffect,
|
|
106
|
-
useModal
|
|
107
|
-
} from "./chunks/chunk-JAOOFDNR.js";
|
|
114
|
+
} from "./chunks/chunk-24T2VRMU.js";
|
|
108
115
|
import {
|
|
109
116
|
MENU_TEXTS,
|
|
110
117
|
errorText,
|
|
111
118
|
fill,
|
|
119
|
+
hasLabels,
|
|
120
|
+
labelsHere,
|
|
121
|
+
langOf,
|
|
112
122
|
mergeLabels,
|
|
113
123
|
messageOf,
|
|
124
|
+
onLabels,
|
|
114
125
|
plural,
|
|
115
126
|
removedLabels,
|
|
127
|
+
requestLabels,
|
|
116
128
|
resolveLabels,
|
|
117
129
|
rowCount
|
|
118
|
-
} from "./chunks/chunk-
|
|
130
|
+
} from "./chunks/chunk-V233JHVY.js";
|
|
119
131
|
|
|
120
132
|
// src/PivotReport.jsx
|
|
121
|
-
import
|
|
133
|
+
import React14, { useCallback as useCallback10, useEffect as useEffect11, useId as useId5, useMemo as useMemo8, useRef as useRef13, useState as useState12, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
122
134
|
import { flushSync } from "react-dom";
|
|
123
|
-
import { computePivot, emptyView as emptyView2, encode, fieldLabel as fieldLabel5, normalize as normalize2, suggestDateUnit, toGrid, toSeries, viewFields } from "pivotkit-core";
|
|
135
|
+
import { computePivot, emptyView as emptyView2, encode, fieldLabel as fieldLabel5, normalize as normalize2, suggestDateUnit, toGrid, toSeries, viewFields, withFieldLabels } from "pivotkit-core";
|
|
124
136
|
|
|
125
137
|
// src/chart.jsx
|
|
126
138
|
import React, { useEffect, useId, useRef, useState } from "react";
|
|
@@ -188,6 +200,7 @@ function resolveTheme(wanted, htmlTheme, prefersDark) {
|
|
|
188
200
|
// src/chart.jsx
|
|
189
201
|
var loading = null;
|
|
190
202
|
var TAP_WAIT = 1e4;
|
|
203
|
+
var DOUBLE_WAIT = 300;
|
|
191
204
|
function loadECharts() {
|
|
192
205
|
loading ??= import("./echarts.js");
|
|
193
206
|
return loading;
|
|
@@ -212,6 +225,14 @@ function PivotChart({ result, series, labels, locale, themeName, root, onInstanc
|
|
|
212
225
|
const summaryId = useId();
|
|
213
226
|
const type = plan ? plan.name : chartTypeOf(result.view.chart);
|
|
214
227
|
const drawAs = plan ? plan.chart : null;
|
|
228
|
+
const waiting = useRef(
|
|
229
|
+
/** @type {ReturnType<typeof setTimeout> | undefined} */
|
|
230
|
+
void 0
|
|
231
|
+
);
|
|
232
|
+
const anchor = useRef(
|
|
233
|
+
/** @type {HTMLSpanElement | null} */
|
|
234
|
+
null
|
|
235
|
+
);
|
|
215
236
|
const latest = useRef({ series, onPoint, onInstance, onLines, onLegend, type });
|
|
216
237
|
const keeper = useRef(
|
|
217
238
|
/** @type {any} */
|
|
@@ -260,15 +281,43 @@ function PivotChart({ result, series, labels, locale, themeName, root, onInstanc
|
|
|
260
281
|
const instance = echarts.init(el.current, null, { renderer: "canvas" });
|
|
261
282
|
chart.current = instance;
|
|
262
283
|
latest.current.onInstance(instance);
|
|
263
|
-
|
|
264
|
-
const
|
|
284
|
+
const pointOf = (p) => {
|
|
285
|
+
const s = latest.current.series;
|
|
265
286
|
const kind = p.seriesType;
|
|
266
|
-
if (!s || kind === "
|
|
267
|
-
return;
|
|
287
|
+
if (!s || kind === "treemap") {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
if (kind === "pie") {
|
|
291
|
+
const path = s.categoryPaths[p.dataIndex];
|
|
292
|
+
return path ? { rowPath: path, colPath: [], valueIndex: s.series[0]?.valueIndex ?? 0, value: p.value, slice: true, rowLabel: s.categories[p.dataIndex] } : null;
|
|
268
293
|
}
|
|
269
294
|
const seriesEntry = kind === "heatmap" ? s.series.filter((x) => x.valueIndex === s.series[0]?.valueIndex)[p.value?.[0]] : s.series[p.seriesIndex];
|
|
270
295
|
const row = kind === "heatmap" ? p.value?.[1] : p.dataIndex;
|
|
271
296
|
if (!seriesEntry || !s.categoryPaths[row]) {
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
const value = kind === "heatmap" ? p.value[2] : typeof p.data?.raw === "number" ? p.data.raw : p.value;
|
|
300
|
+
return { rowPath: s.categoryPaths[row], colPath: seriesEntry.colPath, valueIndex: seriesEntry.valueIndex, value, rowLabel: s.categories[row], colLabel: seriesEntry.colPath.length ? seriesEntry.name : void 0 };
|
|
301
|
+
};
|
|
302
|
+
const placeAnchor = (p) => {
|
|
303
|
+
const at = anchor.current;
|
|
304
|
+
if (at && typeof p.event?.offsetX === "number") {
|
|
305
|
+
at.style.left = `${p.event.offsetX}px`;
|
|
306
|
+
at.style.top = `${p.event.offsetY}px`;
|
|
307
|
+
}
|
|
308
|
+
return at;
|
|
309
|
+
};
|
|
310
|
+
instance.on("dblclick", (p) => {
|
|
311
|
+
clearTimeout(waiting.current);
|
|
312
|
+
const point = pointOf(p);
|
|
313
|
+
if (point && !point.slice) {
|
|
314
|
+
instance.dispatchAction({ type: "hideTip" });
|
|
315
|
+
latest.current.onPoint({ ...point, direct: true, anchor: placeAnchor(p) });
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
instance.on("click", (p) => {
|
|
319
|
+
const point = pointOf(p);
|
|
320
|
+
if (!point) {
|
|
272
321
|
return;
|
|
273
322
|
}
|
|
274
323
|
const element = `${p.seriesIndex}:${p.dataIndex}`;
|
|
@@ -278,9 +327,16 @@ function PivotChart({ result, series, labels, locale, themeName, root, onInstanc
|
|
|
278
327
|
return;
|
|
279
328
|
}
|
|
280
329
|
tapped.current = null;
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
330
|
+
const open = () => {
|
|
331
|
+
instance.dispatchAction({ type: "hideTip" });
|
|
332
|
+
latest.current.onPoint({ ...point, anchor: placeAnchor(p), home: el.current });
|
|
333
|
+
};
|
|
334
|
+
clearTimeout(waiting.current);
|
|
335
|
+
if (touched.current) {
|
|
336
|
+
open();
|
|
337
|
+
} else {
|
|
338
|
+
waiting.current = setTimeout(open, DOUBLE_WAIT);
|
|
339
|
+
}
|
|
284
340
|
});
|
|
285
341
|
keeper.current = echarts.chartKeeper(instance, { categories: () => latest.current.series?.categories, onLegend: (change) => latest.current.onLegend?.(change), redraw: () => setZoomed((n) => n + 1), onWindow: (control) => setZoomKeys(control ? { ...control, props: echarts.zoomKeyProps } : null) });
|
|
286
342
|
const redraw = (e) => {
|
|
@@ -335,6 +391,7 @@ function PivotChart({ result, series, labels, locale, themeName, root, onInstanc
|
|
|
335
391
|
);
|
|
336
392
|
return () => {
|
|
337
393
|
disposed = true;
|
|
394
|
+
clearTimeout(waiting.current);
|
|
338
395
|
keeper.current?.dispose();
|
|
339
396
|
ro?.disconnect();
|
|
340
397
|
if (onPress) {
|
|
@@ -362,7 +419,7 @@ function PivotChart({ result, series, labels, locale, themeName, root, onInstanc
|
|
|
362
419
|
latest.current.onLines?.(lines?.checks ?? null);
|
|
363
420
|
const tooltip = { mode: result.view.chart.tooltip, share: result.view.chart.tooltipShare, hover, totalLabel: labels.chartTotal, moreLabel: labels.chartMore, moreInTotalLabel: labels.chartMoreInTotal, values, lines: lines?.lines ?? [] };
|
|
364
421
|
const doc = root.current.ownerDocument;
|
|
365
|
-
setShown(series ? lib.current.shownOf(series, option, result.view.chart.hidden,
|
|
422
|
+
setShown(series ? lib.current.shownOf(series, option, result.view.chart.hidden, ITEM_TYPES.includes(type)) : null);
|
|
366
423
|
const clean = chartOptions ? lib.current.cleanChartOptions(chartOptions) : null;
|
|
367
424
|
if (clean?.problems.length && warned2.current !== chartOptions) {
|
|
368
425
|
warned2.current = chartOptions;
|
|
@@ -374,7 +431,7 @@ function PivotChart({ result, series, labels, locale, themeName, root, onInstanc
|
|
|
374
431
|
}, [ready, result, series, labels, locale, themeName, root, box, chartOptions, colorMap, drawAs, zoomed, type]);
|
|
375
432
|
const empty = result.view.values.length === 0;
|
|
376
433
|
const summary = series && !empty ? chartSummary(shown?.series ?? series, { type, rows: result.view.rows.map((f) => fieldLabel(f, labels.core)), valueNames, labels, locale, shares: shown?.shares, linesText }) : labels.noChartData;
|
|
377
|
-
return /* @__PURE__ */ React.createElement("div", { className: "pk-chart-wrap" }, /* @__PURE__ */ React.createElement("div", { className: "pk-chart-box" }, /* @__PURE__ */ React.createElement("div", { ref: el, className: "pk-chart", "data-testid": "pivot-chart", role: "img", "aria-label": result.view.chart.title ? `${labels.chart}: ${result.view.chart.title}` : labels.chart, "aria-describedby": summaryId }), /* @__PURE__ */ React.createElement("p", { id: summaryId, className: "pk-sr", "data-testid": "chart-summary" }, summary), zoomKeys ? /* @__PURE__ */ React.createElement("div", { ...zoomKeys.props(zoomKeys, labels, fill, locale) }) : null, !ready && !failed ? /* @__PURE__ */ React.createElement("div", { className: "pk-chart-note" }, labels.loadingChart) : null, failed ? /* @__PURE__ */ React.createElement("div", { className: "pk-chart-note pk-error" }, failed) : null, ready && empty ? /* @__PURE__ */ React.createElement("div", { className: "pk-chart-note" }, labels.noChartData) : null), ready && !empty && every > 1 ? /* @__PURE__ */ React.createElement("p", { className: "pk-axis-note", "data-testid": "axis-note" }, fill(labels.axisEvery, { n: every.toLocaleString(locale) })) : null);
|
|
434
|
+
return /* @__PURE__ */ React.createElement("div", { className: "pk-chart-wrap" }, /* @__PURE__ */ React.createElement("div", { className: "pk-chart-box" }, /* @__PURE__ */ React.createElement("div", { ref: el, className: "pk-chart", "data-testid": "pivot-chart", role: "img", tabIndex: -1, "aria-label": result.view.chart.title ? `${labels.chart}: ${result.view.chart.title}` : labels.chart, "aria-describedby": summaryId }), /* @__PURE__ */ React.createElement("span", { ref: anchor, className: "pk-point-anchor", "aria-hidden": "true" }), /* @__PURE__ */ React.createElement("p", { id: summaryId, className: "pk-sr", "data-testid": "chart-summary" }, summary), zoomKeys ? /* @__PURE__ */ React.createElement("div", { ...zoomKeys.props(zoomKeys, labels, fill, locale) }) : null, !ready && !failed ? /* @__PURE__ */ React.createElement("div", { className: "pk-chart-note" }, labels.loadingChart) : null, failed ? /* @__PURE__ */ React.createElement("div", { className: "pk-chart-note pk-error" }, failed) : null, ready && empty ? /* @__PURE__ */ React.createElement("div", { className: "pk-chart-note" }, labels.noChartData) : null), ready && !empty && every > 1 ? /* @__PURE__ */ React.createElement("p", { className: "pk-axis-note", "data-testid": "axis-note" }, fill(labels.axisEvery, { n: every.toLocaleString(locale) })) : null);
|
|
378
435
|
}
|
|
379
436
|
|
|
380
437
|
// src/dnd.jsx
|
|
@@ -615,7 +672,7 @@ function tabStep(key, at, count) {
|
|
|
615
672
|
}
|
|
616
673
|
|
|
617
674
|
// src/fields.jsx
|
|
618
|
-
function FieldItem({ field, labels, zones, onAdd, onNote, onFilter, name, info, showInfo, stop }) {
|
|
675
|
+
function FieldItem({ field, labels, zones, onAdd, onNote, onFilter, name, source, info, showInfo, stop }) {
|
|
619
676
|
const { setNodeRef, isDragging, itemProps, handleProps } = useDragSource(`field:${field.name}`, { kind: "field", field: field.name, type: field.type, label: name });
|
|
620
677
|
const item = useRef2(
|
|
621
678
|
/** @type {HTMLLIElement | null} */
|
|
@@ -657,7 +714,8 @@ function FieldItem({ field, labels, zones, onAdd, onNote, onFilter, name, info,
|
|
|
657
714
|
"aria-description": info ? void 0 : action.description || void 0,
|
|
658
715
|
"aria-describedby": info ? describedBy : void 0
|
|
659
716
|
},
|
|
660
|
-
/* @__PURE__ */ React3.createElement("span", { className: "pk-field-title", title: name }, wordsOf(name))
|
|
717
|
+
/* @__PURE__ */ React3.createElement("span", { className: "pk-field-title", title: source ? `${name} (${source})` : name }, wordsOf(name)),
|
|
718
|
+
source ? /* @__PURE__ */ React3.createElement("span", { className: "pk-field-source", title: source }, source) : null
|
|
661
719
|
), 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: (
|
|
662
720
|
/** @type {any} */
|
|
663
721
|
ZONE_ICON[z]
|
|
@@ -683,11 +741,11 @@ function FieldItem({ field, labels, zones, onAdd, onNote, onFilter, name, info,
|
|
|
683
741
|
function wordsOf(name) {
|
|
684
742
|
return name.split(/(\s+)/).map((part, i) => i % 2 === 1 ? " " : part ? /* @__PURE__ */ React3.createElement("span", { key: i, className: "pk-word" }, part) : null);
|
|
685
743
|
}
|
|
686
|
-
function FieldPanel({ fields, placed, labels, onAdd, onNote, onFilter, drawer, open, onClose, nameOf, info, showInfo = true, onSkip, collapsed = false, onCollapse }) {
|
|
744
|
+
function FieldPanel({ fields, placed, labels, onAdd, onNote, onFilter, drawer, open, onClose, nameOf, sourceNameOf, info, showInfo = true, onSkip, collapsed = false, onCollapse }) {
|
|
687
745
|
const [query, setQuery] = useState3("");
|
|
688
746
|
const active = useActiveDrag();
|
|
689
747
|
const { setNodeRef, isOver } = useDropTarget("panel", { kind: "panel" });
|
|
690
|
-
const shown = useMemo2(() => matchingFields(fields, query, info), [fields, query, info]);
|
|
748
|
+
const shown = useMemo2(() => matchingFields(fields, query, info, nameOf), [fields, query, info, nameOf]);
|
|
691
749
|
const removing = active && active.kind !== "field";
|
|
692
750
|
const modal = drawer && open;
|
|
693
751
|
const el = useRef2(
|
|
@@ -797,6 +855,7 @@ function FieldPanel({ fields, placed, labels, onAdd, onNote, onFilter, drawer, o
|
|
|
797
855
|
showInfo,
|
|
798
856
|
stop: current && current.field === f.name ? current.slot : null,
|
|
799
857
|
name: nameOf(f.name),
|
|
858
|
+
source: sourceNameOf && sourceNameOf(f.name) !== nameOf(f.name) ? sourceNameOf(f.name) : void 0,
|
|
800
859
|
info: info.get(f.name.toLowerCase())?.description ? info.get(f.name.toLowerCase()) : void 0
|
|
801
860
|
}
|
|
802
861
|
))),
|
|
@@ -806,6 +865,9 @@ function FieldPanel({ fields, placed, labels, onAdd, onNote, onFilter, drawer, o
|
|
|
806
865
|
);
|
|
807
866
|
}
|
|
808
867
|
|
|
868
|
+
// src/PivotReport.jsx
|
|
869
|
+
import { DEFERRED } from "./deferred.js";
|
|
870
|
+
|
|
809
871
|
// src/lazy-menus.jsx
|
|
810
872
|
import React4, { useEffect as useEffect3, useRef as useRef3, useState as useState4 } from "react";
|
|
811
873
|
|
|
@@ -1431,7 +1493,9 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1431
1493
|
const state = headerSortState(view, target);
|
|
1432
1494
|
const next = nextHeaderSort(view, target, hostOrdered(target.field));
|
|
1433
1495
|
const field = fieldLabel2(target.field, labels.core);
|
|
1434
|
-
const
|
|
1496
|
+
const column = target.column ? columnNames.get(JSON.stringify(target.column)) : void 0;
|
|
1497
|
+
const words = (s) => sortText(view, s ?? { by: hostOrdered(target.field) ? "custom" : "label", order: "asc" }, labels, s?.column ? columnNames.get(JSON.stringify(s.column)) : void 0);
|
|
1498
|
+
const aside = Boolean(target.column);
|
|
1435
1499
|
const down = state.chosen ? state.order === "descending" : next?.order === "desc";
|
|
1436
1500
|
const click = () => {
|
|
1437
1501
|
onSort?.(target.field, next);
|
|
@@ -1440,9 +1504,25 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1440
1504
|
return {
|
|
1441
1505
|
// aria-sort only on the header whose sort was chosen (a custom order too): one at a time (WAI-ARIA APG)
|
|
1442
1506
|
sort: state.chosen || state.order === "other" ? state.order : null,
|
|
1443
|
-
content: /* @__PURE__ */ React6.createElement("button", { type: "button", className: `pk-th-sort${state.chosen ? " pk-sorted" : ""}`, title: target.ref && next ? fill(next.order === "desc" ? labels.headerSortDesc : labels.headerSortAsc, { value: refLabel(view, target.ref, labels) }) : fill(labels.headerSort, { field, order: words(next) }), onClick: click }, /* @__PURE__ */ React6.createElement("span", { className: "pk-th-text" }, cell.text), /* @__PURE__ */ React6.createElement(Icon, { name: down ? "arrowDown" : "arrowUp", size: 14, className: "pk-th-arrow" }))
|
|
1507
|
+
content: /* @__PURE__ */ React6.createElement("button", { type: "button", className: `pk-th-sort${state.chosen ? " pk-sorted" : ""}${aside ? " pk-th-sort-aside" : ""}`, title: target.ref && next ? fill(next.order === "desc" ? labels.headerSortDesc : labels.headerSortAsc, { value: column ? fill(labels.valueInColumn, { value: refLabel(view, target.ref, labels), column }) : refLabel(view, target.ref, labels) }) : fill(labels.headerSort, { field, order: words(next) }), onClick: click }, /* @__PURE__ */ React6.createElement("span", { className: "pk-th-text" }, cell.text), /* @__PURE__ */ React6.createElement(Icon, { name: down ? "arrowDown" : "arrowUp", size: 14, className: "pk-th-arrow" }))
|
|
1444
1508
|
};
|
|
1445
1509
|
};
|
|
1510
|
+
const columnNames = (() => {
|
|
1511
|
+
const texts = /* @__PURE__ */ new Map();
|
|
1512
|
+
for (const row of grid.rows.slice(0, grid.headerRows)) {
|
|
1513
|
+
for (const cell of row) {
|
|
1514
|
+
if (cell?.kind === "colHeader" && cell.valueIndex === void 0 && !cell.total && cell.colPath?.length) {
|
|
1515
|
+
texts.set(JSON.stringify(cell.colPath), cell.text);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
const names = /* @__PURE__ */ new Map();
|
|
1520
|
+
for (const key of texts.keys()) {
|
|
1521
|
+
const path = JSON.parse(key);
|
|
1522
|
+
names.set(key, path.map((_, i) => texts.get(JSON.stringify(path.slice(0, i + 1))) ?? String(path[i])).join(" \u203A "));
|
|
1523
|
+
}
|
|
1524
|
+
return names;
|
|
1525
|
+
})();
|
|
1446
1526
|
const subStart = (col) => {
|
|
1447
1527
|
const data = grid.dataColumns[col - grid.rowHeaderColumns];
|
|
1448
1528
|
return data && data.total === 1 && data.valueIndex <= 0 ? " pk-sub-start" : "";
|
|
@@ -1452,7 +1532,7 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1452
1532
|
const top = { top: tops[r] ?? r * rowHeight };
|
|
1453
1533
|
const sticky = c < grid.rowHeaderColumns;
|
|
1454
1534
|
const className = `pk-th pk-${cell.kind}${totalClass(cell.total)}${subStart(c)}${sticky ? " pk-sticky" : ""}`;
|
|
1455
|
-
const target = onSort
|
|
1535
|
+
const target = onSort ? headerSortTarget(view, cell, typeOf) : null;
|
|
1456
1536
|
const sorting = target ? sortButton(cell, target) : null;
|
|
1457
1537
|
const content = /* @__PURE__ */ React6.createElement("span", { className: "pk-th-content" }, cell.toggle ? /* @__PURE__ */ React6.createElement(Toggle, { toggle: cell.toggle, text: cell.text, labels, onToggle }) : null, sorting ? sorting.content : /* @__PURE__ */ React6.createElement("span", { className: "pk-th-text" }, cell.text));
|
|
1458
1538
|
const props = { className, style: stickyStyle(c, top), colSpan: cell.colSpan, rowSpan: cell.rowSpan, scope: cell.kind === "colHeader" ? "col" : void 0 };
|
|
@@ -1468,7 +1548,7 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1468
1548
|
return /* @__PURE__ */ React6.createElement(DraggableHeader, { key: c, ...props, cell, source: { kind: "table", field: spec?.field ?? null, zone: "values", index: cell.valueIndex, label: cell.text }, description: spec?.field ? infoOf?.(spec.field)?.description : void 0, tooltip: showInfo, sort: sorting?.sort }, content);
|
|
1469
1549
|
}
|
|
1470
1550
|
const title = cell.kind === "colHeader" && cell.total === 1 && r < grid.headerRows - 1 ? labels.tips.colSubtotals : void 0;
|
|
1471
|
-
return /* @__PURE__ */ React6.createElement("th", { key: c, ...props, title }, content);
|
|
1551
|
+
return /* @__PURE__ */ React6.createElement("th", { key: c, ...props, title, "aria-sort": sorting?.sort ?? void 0 }, content);
|
|
1472
1552
|
};
|
|
1473
1553
|
const bodyCell = ({ cell, col, rowSpan, colSpan }, r) => {
|
|
1474
1554
|
if (cell.kind === "rowHeader") {
|
|
@@ -1677,7 +1757,7 @@ import React9, { useEffect as useEffect7, useMemo as useMemo4, useRef as useRef7
|
|
|
1677
1757
|
import { fieldLabel as fieldLabel3 } from "pivotkit-core";
|
|
1678
1758
|
|
|
1679
1759
|
// src/unused-load.js
|
|
1680
|
-
var UNUSED_TEXTS_OF = Object.freeze({ de: () => import("./chunks/unused-texts-de-
|
|
1760
|
+
var UNUSED_TEXTS_OF = Object.freeze({ de: () => import("./chunks/unused-texts-de-AC5GS3FS.js").then((m) => m.de) });
|
|
1681
1761
|
var pending2 = /* @__PURE__ */ new Map();
|
|
1682
1762
|
var loaded2 = /* @__PURE__ */ new Map();
|
|
1683
1763
|
var unusedNow = (lang) => loaded2.get(lang) ?? null;
|
|
@@ -1685,7 +1765,7 @@ function loadUnused(lang) {
|
|
|
1685
1765
|
let p = pending2.get(lang);
|
|
1686
1766
|
if (!p) {
|
|
1687
1767
|
const own = Object.hasOwn(UNUSED_TEXTS_OF, lang) ? UNUSED_TEXTS_OF[lang]().catch(() => null) : null;
|
|
1688
|
-
p = Promise.all([import("./chunks/unused-texts-
|
|
1768
|
+
p = Promise.all([import("./chunks/unused-texts-ERQ6ACNX.js"), own]).then(
|
|
1689
1769
|
([mod, texts]) => {
|
|
1690
1770
|
const out = { mod, lang: texts };
|
|
1691
1771
|
loaded2.set(lang, out);
|
|
@@ -2112,67 +2192,133 @@ function Toolbar(props) {
|
|
|
2112
2192
|
/* @__PURE__ */ React10.createElement(Group, { key: ids[0], menu: true, label: ids[0] === "startOver" ? labels.startOver : void 0 }, ids.map((id) => actions[id].entry(close)))
|
|
2113
2193
|
] : []
|
|
2114
2194
|
);
|
|
2115
|
-
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("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 } })), /* @__PURE__ */ React10.createElement(MenuButton, { label: labels.more, icon: "more", text: labels.more, role: "dialog", align: "end", testId: "more", buttonRef: more, arrowOpens: true, mark: hidden.has("views") && loadedView?.changed ? changedMark("more-changed") : hidden.has("data") ? loadedMark("more-loaded") : null }, (close) => /* @__PURE__ */ React10.createElement(MenuPanel, { name: "MorePanel", loadingText: labels.loadingMenu, props: { labels, tips, mod, help: props.help, close, foot: hidden.size > 0 ? moreGroups : void 0 } })), wrap ? name : null, panel ? /* @__PURE__ */ React10.createElement(Popover, { open: true, anchor: more, onClose: closePanel, label: panel === "views" ? labels.views : labels.data, role: "dialog", align: "end" }, panels[panel](closePanel)) : null);
|
|
2195
|
+
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("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: props.display ?? view.display, empty, dataExport: props.dataExport, prepare: props.prepareExport, close } })), /* @__PURE__ */ React10.createElement(MenuButton, { label: labels.more, icon: "more", text: labels.more, role: "dialog", align: "end", testId: "more", buttonRef: more, arrowOpens: true, mark: hidden.has("views") && loadedView?.changed ? changedMark("more-changed") : hidden.has("data") ? loadedMark("more-loaded") : null }, (close) => /* @__PURE__ */ React10.createElement(MenuPanel, { name: "MorePanel", loadingText: labels.loadingMenu, props: { labels, tips, mod, help: props.help, close, foot: hidden.size > 0 ? moreGroups : void 0 } })), wrap ? name : null, panel ? /* @__PURE__ */ React10.createElement(Popover, { open: true, anchor: more, onClose: closePanel, label: panel === "views" ? labels.views : labels.data, role: "dialog", align: "end" }, panels[panel](closePanel)) : null);
|
|
2116
2196
|
}
|
|
2117
2197
|
|
|
2118
|
-
// src/
|
|
2198
|
+
// src/side-by-side.jsx
|
|
2119
2199
|
import React11, { useRef as useRef9 } from "react";
|
|
2200
|
+
var SPLIT = Object.freeze({ start: 50, min: 25, max: 75, step: 5 });
|
|
2201
|
+
function SideBySide({ labels, split: split2, onSplit: setSplit, table, chart }) {
|
|
2202
|
+
const box = useRef9(
|
|
2203
|
+
/** @type {HTMLDivElement | null} */
|
|
2204
|
+
null
|
|
2205
|
+
);
|
|
2206
|
+
const clamp = (n) => Math.round(Math.min(SPLIT.max, Math.max(SPLIT.min, n)));
|
|
2207
|
+
const onPointerDown = (e) => {
|
|
2208
|
+
if (e.button !== 0) {
|
|
2209
|
+
return;
|
|
2210
|
+
}
|
|
2211
|
+
e.preventDefault();
|
|
2212
|
+
const bar = e.currentTarget;
|
|
2213
|
+
bar.setPointerCapture(e.pointerId);
|
|
2214
|
+
const move = (m) => {
|
|
2215
|
+
const rect = box.current?.getBoundingClientRect();
|
|
2216
|
+
if (rect && rect.width > 0) {
|
|
2217
|
+
setSplit(clamp((m.clientX - rect.left) / rect.width * 100));
|
|
2218
|
+
}
|
|
2219
|
+
};
|
|
2220
|
+
const up = () => {
|
|
2221
|
+
bar.removeEventListener("pointermove", move);
|
|
2222
|
+
bar.removeEventListener("pointerup", up);
|
|
2223
|
+
bar.removeEventListener("pointercancel", up);
|
|
2224
|
+
};
|
|
2225
|
+
bar.addEventListener("pointermove", move);
|
|
2226
|
+
bar.addEventListener("pointerup", up);
|
|
2227
|
+
bar.addEventListener("pointercancel", up);
|
|
2228
|
+
};
|
|
2229
|
+
const onKeyDown = (e) => {
|
|
2230
|
+
const next = e.key === "ArrowLeft" ? split2 - SPLIT.step : e.key === "ArrowRight" ? split2 + SPLIT.step : e.key === "Home" ? SPLIT.min : e.key === "End" ? SPLIT.max : null;
|
|
2231
|
+
if (next !== null) {
|
|
2232
|
+
e.preventDefault();
|
|
2233
|
+
setSplit(clamp(next));
|
|
2234
|
+
}
|
|
2235
|
+
};
|
|
2236
|
+
return /* @__PURE__ */ React11.createElement("div", { className: "pk-both", ref: box, style: (
|
|
2237
|
+
/** @type {any} */
|
|
2238
|
+
{ "--pk-split": `${split2}%` }
|
|
2239
|
+
), "data-testid": "side-by-side" }, /* @__PURE__ */ React11.createElement("div", { className: "pk-both-part pk-both-table" }, table), /* @__PURE__ */ React11.createElement(
|
|
2240
|
+
"div",
|
|
2241
|
+
{
|
|
2242
|
+
className: "pk-both-divider",
|
|
2243
|
+
role: "separator",
|
|
2244
|
+
"aria-orientation": "vertical",
|
|
2245
|
+
"aria-label": labels.splitDivider,
|
|
2246
|
+
"aria-valuemin": SPLIT.min,
|
|
2247
|
+
"aria-valuemax": SPLIT.max,
|
|
2248
|
+
"aria-valuenow": split2,
|
|
2249
|
+
"aria-valuetext": fill(labels.splitValue, { table: split2, chart: 100 - split2 }),
|
|
2250
|
+
tabIndex: 0,
|
|
2251
|
+
onPointerDown,
|
|
2252
|
+
onKeyDown,
|
|
2253
|
+
"data-testid": "split-divider"
|
|
2254
|
+
}
|
|
2255
|
+
), /* @__PURE__ */ React11.createElement("div", { className: "pk-both-part pk-both-chart" }, chart));
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
// src/view-tabs.jsx
|
|
2259
|
+
import React12, { useRef as useRef10 } from "react";
|
|
2120
2260
|
var TABS = Object.freeze(
|
|
2121
2261
|
/** @type {const} */
|
|
2122
|
-
["table", "chart"]
|
|
2262
|
+
["table", "chart", "both"]
|
|
2123
2263
|
);
|
|
2124
2264
|
var tabId = (panelId, display) => `${panelId}-${display}`;
|
|
2125
2265
|
function ViewTabs(props) {
|
|
2126
|
-
const { view, labels, panelId, narrow, onDisplay, plan, big } = props;
|
|
2127
|
-
const list =
|
|
2266
|
+
const { view, labels, panelId, narrow, shown = view.display, both = false, onDisplay, plan, big } = props;
|
|
2267
|
+
const list = useRef10(
|
|
2128
2268
|
/** @type {HTMLDivElement | null} */
|
|
2129
2269
|
null
|
|
2130
2270
|
);
|
|
2131
|
-
const
|
|
2132
|
-
const settings = chart ? labels.chartSettings : labels.tableSettings;
|
|
2271
|
+
const tabs = TABS.filter((d) => d !== "both" || both);
|
|
2133
2272
|
const onKeyDown = (e) => {
|
|
2134
|
-
const
|
|
2273
|
+
const buttons = (
|
|
2135
2274
|
/** @type {HTMLElement[]} */
|
|
2136
2275
|
[...list.current?.querySelectorAll('[role="tab"]') ?? []]
|
|
2137
2276
|
);
|
|
2138
|
-
const at =
|
|
2277
|
+
const at = buttons.indexOf(
|
|
2139
2278
|
/** @type {HTMLElement} */
|
|
2140
2279
|
e.target
|
|
2141
2280
|
);
|
|
2142
|
-
const next = at < 0 ? null : tabStep(e.key, at,
|
|
2281
|
+
const next = at < 0 ? null : tabStep(e.key, at, buttons.length);
|
|
2143
2282
|
if (next !== null) {
|
|
2144
2283
|
e.preventDefault();
|
|
2145
|
-
|
|
2284
|
+
buttons[next].focus();
|
|
2146
2285
|
}
|
|
2147
2286
|
};
|
|
2148
2287
|
const iconOnly = (name) => narrow ? { "aria-label": name, title: name } : {};
|
|
2149
|
-
|
|
2288
|
+
const enlargeTitle = shown === "both" && !big.enlarged ? { title: labels.enlargeBoth } : {};
|
|
2289
|
+
return /* @__PURE__ */ React12.createElement("div", { className: "pk-result-head", "data-testid": "view-tabs-row" }, /* @__PURE__ */ React12.createElement("div", { ref: list, className: "pk-tabs", role: "tablist", "aria-label": labels.view, onKeyDown }, tabs.map((d) => /* @__PURE__ */ React12.createElement(
|
|
2150
2290
|
"button",
|
|
2151
2291
|
{
|
|
2152
2292
|
key: d,
|
|
2153
2293
|
type: "button",
|
|
2154
2294
|
role: "tab",
|
|
2155
2295
|
id: tabId(panelId, d),
|
|
2156
|
-
"aria-selected":
|
|
2296
|
+
"aria-selected": shown === d,
|
|
2157
2297
|
"aria-controls": panelId,
|
|
2158
|
-
tabIndex:
|
|
2298
|
+
tabIndex: shown === d ? 0 : -1,
|
|
2159
2299
|
className: "pk-tab",
|
|
2160
|
-
onClick: () =>
|
|
2300
|
+
onClick: () => shown === d ? void 0 : onDisplay(d),
|
|
2161
2301
|
"data-testid": `show-${d}`
|
|
2162
2302
|
},
|
|
2163
|
-
/* @__PURE__ */
|
|
2303
|
+
/* @__PURE__ */ React12.createElement(Icon, { name: (
|
|
2164
2304
|
/** @type {any} */
|
|
2165
|
-
d === "table" ? "table" : CHART_TYPES[plan.name].icon
|
|
2305
|
+
d === "table" ? "table" : d === "both" ? "layout" : CHART_TYPES[plan.name].icon
|
|
2166
2306
|
) }),
|
|
2167
|
-
/* @__PURE__ */
|
|
2168
|
-
))), /* @__PURE__ */
|
|
2307
|
+
/* @__PURE__ */ React12.createElement("span", null, d === "table" ? labels.table : d === "both" ? labels.both : labels.chart)
|
|
2308
|
+
))), /* @__PURE__ */ React12.createElement("span", { className: "pk-grow" }), shown !== "chart" ? /* @__PURE__ */ React12.createElement(SettingsButton, { kind: "table", ...props }) : null, shown !== "table" ? /* @__PURE__ */ React12.createElement(SettingsButton, { kind: "chart", ...props }) : null, /* @__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", ...enlargeTitle, ...iconOnly(big.enlarged ? labels.reduce : labels.enlarge) }, /* @__PURE__ */ React12.createElement(Icon, { name: "enlarge", size: 14 }), narrow ? null : /* @__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", ...iconOnly(labels.fullScreen) }, /* @__PURE__ */ React12.createElement(Icon, { name: "fullScreen", size: 14 }), narrow ? null : /* @__PURE__ */ React12.createElement("span", { className: "pk-btn-text" }, labels.fullScreen)) : null);
|
|
2309
|
+
}
|
|
2310
|
+
function SettingsButton(props) {
|
|
2311
|
+
const { kind, view, labels, narrow, plan } = props;
|
|
2312
|
+
const chart = kind === "chart";
|
|
2313
|
+
const settings = chart ? labels.chartSettings : labels.tableSettings;
|
|
2314
|
+
return /* @__PURE__ */ React12.createElement(MenuButton, { label: settings, icon: "sliders", text: narrow ? labels.settingsShort : settings, name: narrow ? settings : void 0, title: narrow ? settings : void 0, className: "pk-btn pk-small-btn", role: "dialog", align: "end", testId: props.shown === "both" ? `${kind}-settings` : "view-settings", popoverClass: chart ? "pk-chart-menu" : void 0 }, (close) => chart ? /* @__PURE__ */ React12.createElement(
|
|
2169
2315
|
MenuPanel,
|
|
2170
2316
|
{
|
|
2171
2317
|
name: "ChartSettingsPanel",
|
|
2172
2318
|
loadingText: labels.loadingMenu,
|
|
2173
2319
|
props: { view, plan, encoded: props.encoded, lineChecks: props.lineChecks, labels, locale: props.locale, onChart: props.onChart, onDisplay: props.onChartDisplay, close, series: props.chartSeries, colors: props.chartColors, folding: props.folding, onExpand: props.onExpand, onCollapse: props.onCollapse }
|
|
2174
2320
|
}
|
|
2175
|
-
) : /* @__PURE__ */
|
|
2321
|
+
) : /* @__PURE__ */ React12.createElement(MenuPanel, { name: "TableSettingsPanel", loadingText: labels.loadingMenu, props: { view, labels, onTotal: props.onTotal, onExpand: props.onExpand, onCollapse: props.onCollapse, close, folding: props.folding } }));
|
|
2176
2322
|
}
|
|
2177
2323
|
|
|
2178
2324
|
// src/use-export.js
|
|
@@ -2414,7 +2560,7 @@ function keptData(key, host) {
|
|
|
2414
2560
|
}
|
|
2415
2561
|
|
|
2416
2562
|
// src/use-big-result.js
|
|
2417
|
-
import { useCallback as useCallback8, useEffect as useEffect9, useRef as
|
|
2563
|
+
import { useCallback as useCallback8, useEffect as useEffect9, useRef as useRef11, useState as useState10, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
2418
2564
|
function fullScreenSupported() {
|
|
2419
2565
|
return typeof document !== "undefined" && Boolean(document.fullscreenEnabled) && typeof HTMLElement !== "undefined" && typeof HTMLElement.prototype.requestFullscreen === "function";
|
|
2420
2566
|
}
|
|
@@ -2455,12 +2601,12 @@ function useBigResult(root) {
|
|
|
2455
2601
|
return { enlarged, setEnlarged, toggleEnlarged, full, fullOk, toggleFull };
|
|
2456
2602
|
}
|
|
2457
2603
|
function useFitHeight(root, main, grow, onOpen) {
|
|
2458
|
-
const fit =
|
|
2604
|
+
const fit = useRef11(
|
|
2459
2605
|
/** @type {FitState} */
|
|
2460
2606
|
{ need: 0, open: 0, grow, folded: null, size: null }
|
|
2461
2607
|
);
|
|
2462
|
-
const opened =
|
|
2463
|
-
const watch =
|
|
2608
|
+
const opened = useRef11(onOpen);
|
|
2609
|
+
const watch = useRef11(
|
|
2464
2610
|
/** @type {{ ro: ResizeObserver | null, parts: Set<Element> }} */
|
|
2465
2611
|
{ ro: null, parts: /* @__PURE__ */ new Set() }
|
|
2466
2612
|
);
|
|
@@ -2558,7 +2704,7 @@ function measureFit(el, m, fit) {
|
|
|
2558
2704
|
}
|
|
2559
2705
|
|
|
2560
2706
|
// src/zones.jsx
|
|
2561
|
-
import
|
|
2707
|
+
import React13, { useCallback as useCallback9, useEffect as useEffect10, useId as useId4, useMemo as useMemo7, useRef as useRef12, useState as useState11 } from "react";
|
|
2562
2708
|
import { fieldItems, fieldLabel as fieldLabel4 } from "pivotkit-core";
|
|
2563
2709
|
function fieldState(view, field, encoded, locale, labels, sourceType) {
|
|
2564
2710
|
const items = filtersOf(view, field, ["in"]).filter((f) => !isEmptyPick(f));
|
|
@@ -2575,7 +2721,9 @@ function fieldState(view, field, encoded, locale, labels, sourceType) {
|
|
|
2575
2721
|
const rules = filtersOf(view, field, ["relative", "compare", "text"]).map((f) => itemRuleText(f, labels, locale, { timeZone: encoded.timeZone, date, labelOf, span, weekStart: view.formatting?.weekStart }));
|
|
2576
2722
|
const top = filtersOf(view, field, ["top"])[0] ?? null;
|
|
2577
2723
|
const condition = filtersOf(view, field, ["value"])[0] ?? null;
|
|
2578
|
-
|
|
2724
|
+
const sort = sortOf(view, field);
|
|
2725
|
+
const sortColumn = sort?.column ? columnText(view, sort.column, encoded, labels, locale) : void 0;
|
|
2726
|
+
return { summary, rules, top, condition, sort, sortColumn };
|
|
2579
2727
|
}
|
|
2580
2728
|
function stateWords(state, view, labels, locale) {
|
|
2581
2729
|
if (!state) {
|
|
@@ -2593,7 +2741,7 @@ function stateWords(state, view, labels, locale) {
|
|
|
2593
2741
|
words.push(valueConditionText(view, state.condition, labels, locale));
|
|
2594
2742
|
}
|
|
2595
2743
|
if (state.sort) {
|
|
2596
|
-
words.push(fill(labels.stateSorted, { order: sortText(view, state.sort, labels) }));
|
|
2744
|
+
words.push(fill(labels.stateSorted, { order: sortText(view, state.sort, labels, state.sortColumn) }));
|
|
2597
2745
|
}
|
|
2598
2746
|
return words.join(", ");
|
|
2599
2747
|
}
|
|
@@ -2602,48 +2750,48 @@ function Badges({ state, view, labels, locale }) {
|
|
|
2602
2750
|
if (state.summary) {
|
|
2603
2751
|
const text = fill(labels.filterSummary, { shown: state.summary.shown.toLocaleString(locale), total: state.summary.total.toLocaleString(locale) });
|
|
2604
2752
|
parts.push(
|
|
2605
|
-
/* @__PURE__ */
|
|
2753
|
+
/* @__PURE__ */ React13.createElement("span", { key: "filter", className: "pk-chip-badge pk-badge-text", "aria-hidden": "true" }, /* @__PURE__ */ React13.createElement(Icon, { name: "filter", size: 12 }), text)
|
|
2606
2754
|
);
|
|
2607
2755
|
}
|
|
2608
2756
|
if (state.rules.length) {
|
|
2609
2757
|
const more = state.rules.length - 1;
|
|
2610
2758
|
parts.push(
|
|
2611
|
-
/* @__PURE__ */
|
|
2759
|
+
/* @__PURE__ */ React13.createElement("span", { key: "rules", className: "pk-chip-badge pk-badge-text pk-badge-condition", "data-testid": "rule-badge", "aria-hidden": "true" }, state.summary ? null : /* @__PURE__ */ React13.createElement(Icon, { name: "filter", size: 12 }), /* @__PURE__ */ React13.createElement("span", { className: "pk-badge-cut" }, state.rules[0]), more ? /* @__PURE__ */ React13.createElement("span", null, ` +${more.toLocaleString(locale)}`) : null)
|
|
2612
2760
|
);
|
|
2613
2761
|
}
|
|
2614
2762
|
if (state.top) {
|
|
2615
2763
|
const text = fill(state.top.bottom ? labels.bottomBadge : labels.topBadge, { count: state.top.count.toLocaleString(locale) });
|
|
2616
2764
|
parts.push(
|
|
2617
|
-
/* @__PURE__ */
|
|
2765
|
+
/* @__PURE__ */ React13.createElement("span", { key: "top", className: "pk-chip-badge pk-badge-text", "data-testid": "top-badge", "aria-hidden": "true" }, /* @__PURE__ */ React13.createElement(Icon, { name: "top", size: 12 }), text)
|
|
2618
2766
|
);
|
|
2619
2767
|
}
|
|
2620
2768
|
if (state.condition) {
|
|
2621
2769
|
const text = valueConditionText(view, state.condition, labels, locale);
|
|
2622
2770
|
parts.push(
|
|
2623
|
-
/* @__PURE__ */
|
|
2771
|
+
/* @__PURE__ */ React13.createElement("span", { key: "condition", className: "pk-chip-badge pk-badge-text pk-badge-condition", "data-testid": "condition-badge", "aria-hidden": "true" }, /* @__PURE__ */ React13.createElement(Icon, { name: "filter", size: 12 }), /* @__PURE__ */ React13.createElement("span", { className: "pk-badge-cut" }, text))
|
|
2624
2772
|
);
|
|
2625
2773
|
}
|
|
2626
2774
|
if (state.sort) {
|
|
2627
2775
|
const desc = state.sort.order === "desc";
|
|
2628
|
-
parts.push(/* @__PURE__ */
|
|
2776
|
+
parts.push(/* @__PURE__ */ React13.createElement(Icon, { key: "sort", name: desc ? "sortDesc" : "sortAsc", size: 12, className: "pk-chip-badge" }));
|
|
2629
2777
|
}
|
|
2630
|
-
return parts.length ? /* @__PURE__ */
|
|
2778
|
+
return parts.length ? /* @__PURE__ */ React13.createElement(React13.Fragment, null, parts) : null;
|
|
2631
2779
|
}
|
|
2632
2780
|
function Chip({ id, zone, index, count, field, text, title, typeName, view, types, labels, commit, onRemove, state, locale, defaultsOf, earlier, rangeOf, info, showInfo, encoded }) {
|
|
2633
2781
|
const { setNodeRef, isDragging, style, itemProps, handleProps } = useChip(id, { kind: "chip", zone, index, count, field, label: text, type: typeName });
|
|
2634
|
-
const badges = state ? /* @__PURE__ */
|
|
2782
|
+
const badges = state ? /* @__PURE__ */ React13.createElement(Badges, { state, view, labels, locale }) : null;
|
|
2635
2783
|
const words = stateWords(state, view, labels, locale);
|
|
2636
2784
|
const full = title ?? text;
|
|
2637
2785
|
const name = words ? `${full}, ${words}` : title;
|
|
2638
2786
|
const remove = () => onRemove(zone, index, text);
|
|
2639
|
-
return /* @__PURE__ */
|
|
2787
|
+
return /* @__PURE__ */ React13.createElement("li", { ref: setNodeRef, style, className: `pk-chip pk-chip-${zone}${isDragging ? " pk-dragging" : ""}`, ...itemProps, "data-chip": text }, /* @__PURE__ */ React13.createElement("span", { className: "pk-handle", ...handleProps, "aria-label": fill(labels.dragHandle, { field: text }) }, /* @__PURE__ */ React13.createElement(Icon, { name: "grip", size: 16 })), /* @__PURE__ */ React13.createElement("span", { className: `pk-type pk-type-${typeName}`, "aria-hidden": "true" }, /* @__PURE__ */ React13.createElement(Icon, { name: (
|
|
2640
2788
|
/** @type {any} */
|
|
2641
2789
|
TYPE_ICON[typeName] ?? "text"
|
|
2642
|
-
), size: 13 })), /* @__PURE__ */
|
|
2790
|
+
), size: 13 })), /* @__PURE__ */ React13.createElement(
|
|
2643
2791
|
MenuButton,
|
|
2644
2792
|
{
|
|
2645
2793
|
label: fill(labels.fieldMenu, { field: text }),
|
|
2646
|
-
text: /* @__PURE__ */
|
|
2794
|
+
text: /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement("span", { className: "pk-chip-name" }, text), badges),
|
|
2647
2795
|
className: "pk-chip-label",
|
|
2648
2796
|
name,
|
|
2649
2797
|
title: name ?? text,
|
|
@@ -2652,12 +2800,12 @@ function Chip({ id, zone, index, count, field, text, title, typeName, view, type
|
|
|
2652
2800
|
fill: true,
|
|
2653
2801
|
testId: `chip-menu-${text}`
|
|
2654
2802
|
},
|
|
2655
|
-
(close) => zone === "values" ? /* @__PURE__ */
|
|
2656
|
-
), info && showInfo ? /* @__PURE__ */
|
|
2803
|
+
(close) => zone === "values" ? /* @__PURE__ */ React13.createElement(MenuPanel, { name: "ValueMenu", loadingText: labels.loadingMenu, props: { view, index, types, labels, commit, close, onRemove: remove, defaultsOf, info, locale, earlier } }) : zone === "filters" ? /* @__PURE__ */ React13.createElement(MenuPanel, { name: "FilterMenu", loadingText: labels.loadingMenu, props: { view, index, field, types, labels, commit, close, onRemove: remove, locale, info, state, encoded } }) : /* @__PURE__ */ React13.createElement(MenuPanel, { name: "AxisMenu", loadingText: labels.loadingMenu, props: { view, zone, index, field, types, labels, commit, close, onRemove: remove, defaultsOf, rangeOf, locale, info, state, encoded } })
|
|
2804
|
+
), info && showInfo ? /* @__PURE__ */ React13.createElement(InfoButton, { info, name: fieldLabel4(sourceOf(view, field), labels.core), labels, className: "pk-chip-info" }) : null, /* @__PURE__ */ React13.createElement("button", { type: "button", className: "pk-chip-x", onClick: remove, "aria-label": fill(labels.removeField, { field: text }), title: fill(labels.removeField, { field: text }) }, /* @__PURE__ */ React13.createElement(Icon, { name: "x", size: 14 })));
|
|
2657
2805
|
}
|
|
2658
2806
|
function AddButton({ zone, labels, menu }) {
|
|
2659
2807
|
const name = fill(labels.addFieldTo, { zone: labels.zones[zone] });
|
|
2660
|
-
return /* @__PURE__ */
|
|
2808
|
+
return /* @__PURE__ */ React13.createElement(MenuButton, { label: name, name, title: name, icon: "plus", text: labels.addField, className: "pk-zone-add", role: "dialog", popoverClass: "pk-chip-menu", fill: true, testId: `add-field-${zone}` }, (close) => /* @__PURE__ */ React13.createElement(MenuPanel, { name: "AddMenu", loadingText: labels.loadingMenu, props: { ...menu, labels, zone, close } }));
|
|
2661
2809
|
}
|
|
2662
2810
|
function Zone({ zone, entries, labels, children, explain, add }) {
|
|
2663
2811
|
const count = entries.length;
|
|
@@ -2679,10 +2827,10 @@ function Zone({ zone, entries, labels, children, explain, add }) {
|
|
|
2679
2827
|
const t = setTimeout(() => setFlash(false), 600);
|
|
2680
2828
|
return () => clearTimeout(t);
|
|
2681
2829
|
}, [flash]);
|
|
2682
|
-
return /* @__PURE__ */
|
|
2830
|
+
return /* @__PURE__ */ React13.createElement("section", { ref: setNodeRef, tabIndex: -1, className: `pk-zone pk-zone-${zone}${isOver ? " pk-over" : ""}${dragging ? " pk-dropping" : ""}${flash ? " pk-flash" : ""}`, "aria-label": labels.zones[zone], "data-zone": zone }, /* @__PURE__ */ React13.createElement("div", { className: "pk-zone-head" }, /* @__PURE__ */ React13.createElement("h3", { className: "pk-zone-title" }, /* @__PURE__ */ React13.createElement(Icon, { name: (
|
|
2683
2831
|
/** @type {any} */
|
|
2684
2832
|
ZONE_ICON[zone]
|
|
2685
|
-
), size: 14 }), labels.zones[zone]), explain ? /* @__PURE__ */
|
|
2833
|
+
), size: 14 }), labels.zones[zone]), explain ? /* @__PURE__ */ React13.createElement(InfoButton, { info: { description: labels.zoneInfo[zone] }, name: labels.zones[zone], labels, className: "pk-zone-info", testId: `zone-info-${zone}` }) : null, add ? /* @__PURE__ */ React13.createElement(AddButton, { zone, labels, menu: add }) : null), /* @__PURE__ */ React13.createElement(ChipList, { ids: entries.map((e) => e.id) }, /* @__PURE__ */ React13.createElement("ul", { className: "pk-chips" }, children, count === 0 ? /* @__PURE__ */ React13.createElement("li", { className: "pk-zone-hint" }, labels.zoneHints[zone]) : null)));
|
|
2686
2834
|
}
|
|
2687
2835
|
var SAY_AFTER = 100;
|
|
2688
2836
|
var SAY_FOR = 8e3;
|
|
@@ -2707,7 +2855,7 @@ function SectionHead({ entries, labels, id, open, onFold, onSwap, canSwap, butto
|
|
|
2707
2855
|
const own = useId4();
|
|
2708
2856
|
const parts = layoutSummary(entries, labels);
|
|
2709
2857
|
const text = parts.length ? parts.map((p) => `${p.title}: ${p.fields}`).join(" \xB7 ") : labels.layoutEmpty;
|
|
2710
|
-
return /* @__PURE__ */
|
|
2858
|
+
return /* @__PURE__ */ React13.createElement("div", { className: "pk-section-row" }, /* @__PURE__ */ React13.createElement(
|
|
2711
2859
|
"button",
|
|
2712
2860
|
{
|
|
2713
2861
|
ref: buttonRef,
|
|
@@ -2721,18 +2869,18 @@ function SectionHead({ entries, labels, id, open, onFold, onSwap, canSwap, butto
|
|
|
2721
2869
|
onClick: onFold,
|
|
2722
2870
|
"data-testid": "layout-summary"
|
|
2723
2871
|
},
|
|
2724
|
-
/* @__PURE__ */
|
|
2725
|
-
/* @__PURE__ */
|
|
2726
|
-
), explain ? /* @__PURE__ */
|
|
2872
|
+
/* @__PURE__ */ React13.createElement(Icon, { name: "chevronRight", className: "pk-section-chevron" }),
|
|
2873
|
+
/* @__PURE__ */ React13.createElement("span", { id: `${own}-t`, className: "pk-section-heading" }, labels.zonesTitle)
|
|
2874
|
+
), explain ? /* @__PURE__ */ React13.createElement(InfoButton, { info: { description: labels.zonesHint }, name: labels.zonesTitle, labels, className: "pk-section-info", testId: "zones-info" }) : null, open ? /* @__PURE__ */ React13.createElement("span", { className: "pk-grow" }) : (
|
|
2727
2875
|
// the button's description and a larger target for the pointer; the keys use the button
|
|
2728
|
-
/* @__PURE__ */
|
|
2729
|
-
), /* @__PURE__ */
|
|
2876
|
+
/* @__PURE__ */ React13.createElement("span", { id: `${own}-s`, className: "pk-section-sub", onClick: onFold, "data-testid": "zones-sub" }, parts.length ? parts.map((p, i) => /* @__PURE__ */ React13.createElement(React13.Fragment, { key: p.zone }, i ? " \xB7 " : null, /* @__PURE__ */ React13.createElement("span", { className: "pk-zones-summary-zone" }, p.title, ":"), " ", p.fields)) : labels.layoutEmpty)
|
|
2877
|
+
), /* @__PURE__ */ React13.createElement("button", { type: "button", className: "pk-btn pk-small-btn pk-swap", onClick: onSwap, disabled: !canSwap, "data-testid": "swap", title: labels.swap }, /* @__PURE__ */ React13.createElement(Icon, { name: "swap", size: 14 }), /* @__PURE__ */ React13.createElement("span", { className: "pk-btn-text" }, labels.swap)));
|
|
2730
2878
|
}
|
|
2731
2879
|
function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap, id, folded, onFold, defaultsOf, infoOf, titleOf, explain = false, showInfo = true, adding }) {
|
|
2732
2880
|
const entries = useMemo7(() => zoneEntries(view, types, labels), [view, types, labels]);
|
|
2733
2881
|
const dragging = Boolean(useActiveDrag());
|
|
2734
|
-
const focusInside =
|
|
2735
|
-
const summary =
|
|
2882
|
+
const focusInside = useRef12(false);
|
|
2883
|
+
const summary = useRef12(
|
|
2736
2884
|
/** @type {HTMLButtonElement | null} */
|
|
2737
2885
|
null
|
|
2738
2886
|
);
|
|
@@ -2746,11 +2894,11 @@ function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap,
|
|
|
2746
2894
|
return map;
|
|
2747
2895
|
}, [entries, view, encoded, locale, labels]);
|
|
2748
2896
|
const rangeOf = useCallback9((field) => numberRange(encoded, field), [encoded]);
|
|
2749
|
-
const root =
|
|
2897
|
+
const root = useRef12(
|
|
2750
2898
|
/** @type {HTMLDivElement | null} */
|
|
2751
2899
|
null
|
|
2752
2900
|
);
|
|
2753
|
-
const focusAfter =
|
|
2901
|
+
const focusAfter = useRef12(
|
|
2754
2902
|
/** @type {{ zone: string, index: number } | null} */
|
|
2755
2903
|
null
|
|
2756
2904
|
);
|
|
@@ -2772,12 +2920,12 @@ function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap,
|
|
|
2772
2920
|
);
|
|
2773
2921
|
target?.focus({ preventScroll: true });
|
|
2774
2922
|
});
|
|
2775
|
-
const added =
|
|
2923
|
+
const added = useRef12(
|
|
2776
2924
|
/** @type {{ zone: string, from: string | null, ids: Set<string> } | null} */
|
|
2777
2925
|
null
|
|
2778
2926
|
);
|
|
2779
2927
|
const [said, setSaid] = useState11("");
|
|
2780
|
-
const sayTimers =
|
|
2928
|
+
const sayTimers = useRef12(
|
|
2781
2929
|
/** @type {ReturnType<typeof setTimeout>[]} */
|
|
2782
2930
|
[]
|
|
2783
2931
|
);
|
|
@@ -2822,7 +2970,7 @@ function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap,
|
|
|
2822
2970
|
}
|
|
2823
2971
|
}, [folded]);
|
|
2824
2972
|
const open = !folded || dragging;
|
|
2825
|
-
return /* @__PURE__ */
|
|
2973
|
+
return /* @__PURE__ */ React13.createElement("div", { className: "pk-zone-section", "data-pk-open": open ? "" : void 0, "data-testid": "zone-section" }, /* @__PURE__ */ React13.createElement(SectionHead, { entries, labels, id, open, onFold, onSwap, canSwap: view.rows.length + view.cols.length > 0, buttonRef: summary, explain }), /* @__PURE__ */ React13.createElement("span", { className: "pk-sr", role: "status", "data-testid": "zones-status" }, said), open ? /* @__PURE__ */ React13.createElement(
|
|
2826
2974
|
"div",
|
|
2827
2975
|
{
|
|
2828
2976
|
className: "pk-zones",
|
|
@@ -2840,7 +2988,7 @@ function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap,
|
|
|
2840
2988
|
}
|
|
2841
2989
|
}
|
|
2842
2990
|
},
|
|
2843
|
-
ZONES.map((zone) => /* @__PURE__ */
|
|
2991
|
+
ZONES.map((zone) => /* @__PURE__ */ React13.createElement(
|
|
2844
2992
|
Zone,
|
|
2845
2993
|
{
|
|
2846
2994
|
key: zone,
|
|
@@ -2850,7 +2998,7 @@ function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap,
|
|
|
2850
2998
|
explain,
|
|
2851
2999
|
add: addMenu ? { ...addMenu, onAdded: addMenu.onAdded(zone) } : null
|
|
2852
3000
|
},
|
|
2853
|
-
entries[zone].map((e) => /* @__PURE__ */
|
|
3001
|
+
entries[zone].map((e) => /* @__PURE__ */ React13.createElement(
|
|
2854
3002
|
Chip,
|
|
2855
3003
|
{
|
|
2856
3004
|
key: e.id,
|
|
@@ -2962,24 +3110,64 @@ function PivotReport(props) {
|
|
|
2962
3110
|
clearTimeout(timer);
|
|
2963
3111
|
};
|
|
2964
3112
|
}, [deferred]);
|
|
2965
|
-
const
|
|
3113
|
+
const texts = useLabelsOf(props.locale);
|
|
3114
|
+
const waiting = Boolean(loading2) || deferred || !texts.shown;
|
|
2966
3115
|
if (!waiting && !started) {
|
|
2967
3116
|
setStarted(true);
|
|
2968
3117
|
}
|
|
2969
3118
|
if (waiting && !started) {
|
|
2970
|
-
return /* @__PURE__ */
|
|
3119
|
+
return /* @__PURE__ */ React14.createElement(WaitingReport, { ...props, locale: texts.locale, silent: !texts.shown });
|
|
2971
3120
|
}
|
|
2972
|
-
return /* @__PURE__ */
|
|
3121
|
+
return /* @__PURE__ */ React14.createElement(Report, { ...props, locale: texts.locale });
|
|
2973
3122
|
}
|
|
2974
|
-
function
|
|
2975
|
-
const
|
|
3123
|
+
function useLabelsOf(locale) {
|
|
3124
|
+
const here2 = useSyncExternalStore3(onLabels, () => labelsHere(locale, DEFERRED.loadLabels), () => labelsHere(locale, DEFERRED.loadLabels));
|
|
3125
|
+
if (!here2) {
|
|
3126
|
+
requestLabels(locale, DEFERRED.loadLabels);
|
|
3127
|
+
}
|
|
3128
|
+
const lang = langOf(locale);
|
|
3129
|
+
useEffect11(() => requestLabels(lang, DEFERRED.loadLabels, { again: true }), [lang]);
|
|
3130
|
+
const [last, setLast] = useState12(() => here2 ? { locale } : null);
|
|
3131
|
+
if (here2 && (!last || last.locale !== locale)) {
|
|
3132
|
+
setLast({ locale });
|
|
3133
|
+
}
|
|
3134
|
+
return here2 ? { shown: true, locale } : { shown: last !== null, locale: last?.locale };
|
|
3135
|
+
}
|
|
3136
|
+
var tipsLoaded = DEFERRED.tips;
|
|
3137
|
+
var tipsPending = null;
|
|
3138
|
+
function useTipsTable() {
|
|
3139
|
+
const [mod, setMod] = useState12(() => tipsLoaded);
|
|
3140
|
+
useEffect11(() => {
|
|
3141
|
+
const load = DEFERRED.loadTips;
|
|
3142
|
+
if (mod || !load) {
|
|
3143
|
+
return void 0;
|
|
3144
|
+
}
|
|
3145
|
+
let live = true;
|
|
3146
|
+
tipsPending ??= load().then((m) => tipsLoaded = m, (error) => {
|
|
3147
|
+
tipsPending = null;
|
|
3148
|
+
warnOnce(`pivotkit: the tips did not load, the report shows none: ${error instanceof Error ? error.message : String(error)}`);
|
|
3149
|
+
throw error;
|
|
3150
|
+
});
|
|
3151
|
+
tipsPending.then(
|
|
3152
|
+
(m) => live && setMod(m),
|
|
3153
|
+
() => {
|
|
3154
|
+
}
|
|
3155
|
+
);
|
|
3156
|
+
return () => {
|
|
3157
|
+
live = false;
|
|
3158
|
+
};
|
|
3159
|
+
}, [mod]);
|
|
3160
|
+
return mod;
|
|
3161
|
+
}
|
|
3162
|
+
function WaitingReport({ locale = "en-US", labels: customLabels, theme = "auto", height = 640, className, label, silent = false }) {
|
|
3163
|
+
const root = useRef13(
|
|
2976
3164
|
/** @type {HTMLDivElement | null} */
|
|
2977
3165
|
null
|
|
2978
3166
|
);
|
|
2979
3167
|
const labelsKey = JSON.stringify(customLabels ?? null);
|
|
2980
3168
|
const labels = useMemo8(() => resolveLabels(locale, JSON.parse(labelsKey)), [locale, labelsKey]);
|
|
2981
3169
|
const themeName = useResolvedTheme(theme, root);
|
|
2982
|
-
return /* @__PURE__ */
|
|
3170
|
+
return /* @__PURE__ */ React14.createElement("div", { ref: root, className: `pk-root${className ? ` ${className}` : ""}`, "data-pk-theme": themeName, lang: silent ? void 0 : labels.lang, role: "region", "aria-label": label || (silent ? void 0 : labels.report), style: { height } }, /* @__PURE__ */ React14.createElement(Skeleton, { full: true, text: silent ? "" : labels.loadingReport }));
|
|
2983
3171
|
}
|
|
2984
3172
|
function keyOfHostView(view) {
|
|
2985
3173
|
try {
|
|
@@ -2990,7 +3178,7 @@ function keyOfHostView(view) {
|
|
|
2990
3178
|
}
|
|
2991
3179
|
var staysTheSame = () => () => void 0;
|
|
2992
3180
|
function EmptyState({ labels, templates, onTemplate, onLoad, noData }) {
|
|
2993
|
-
return /* @__PURE__ */
|
|
3181
|
+
return /* @__PURE__ */ React14.createElement("div", { className: "pk-empty", "data-testid": "empty-state" }, /* @__PURE__ */ React14.createElement("div", { className: "pk-empty-art", "aria-hidden": "true" }, /* @__PURE__ */ React14.createElement("span", { className: "pk-empty-chip pk-c1" }), /* @__PURE__ */ React14.createElement("span", { className: "pk-empty-chip pk-c2" }), /* @__PURE__ */ React14.createElement("span", { className: "pk-empty-chip pk-c3" })), /* @__PURE__ */ React14.createElement("h2", null, noData ? labels.emptyNoData : labels.emptyTitle), noData ? null : /* @__PURE__ */ React14.createElement("ol", { className: "pk-steps" }, labels.emptySteps.map((s, i) => /* @__PURE__ */ React14.createElement("li", { key: i }, /* @__PURE__ */ React14.createElement("span", { className: "pk-step-n", "aria-hidden": "true" }, i + 1), /* @__PURE__ */ React14.createElement("span", null, s)))), onLoad ? /* @__PURE__ */ React14.createElement("div", { className: "pk-drop-zone", "data-testid": "empty-drop" }, /* @__PURE__ */ React14.createElement("p", null, noData ? labels.emptyDrop : labels.emptyLoad), /* @__PURE__ */ React14.createElement("button", { type: "button", className: "pk-btn", onClick: onLoad, "data-testid": "empty-load" }, /* @__PURE__ */ React14.createElement(Icon, { name: "upload" }), /* @__PURE__ */ React14.createElement("span", { className: "pk-btn-text" }, labels.loadData))) : null, templates.length ? /* @__PURE__ */ React14.createElement("div", { className: "pk-empty-actions" }, templates.slice(0, 3).map((t, i) => /* @__PURE__ */ React14.createElement("button", { key: `${i}:${t.name}`, type: "button", className: "pk-btn", onClick: () => onTemplate(t) }, /* @__PURE__ */ React14.createElement(Icon, { name: "sparkle" }), /* @__PURE__ */ React14.createElement("span", { className: "pk-btn-text" }, fill(labels.tryView, { name: t.name }))))) : null);
|
|
2994
3182
|
}
|
|
2995
3183
|
function Report(props) {
|
|
2996
3184
|
const {
|
|
@@ -3054,14 +3242,14 @@ function Report(props) {
|
|
|
3054
3242
|
/** @type {import("./import-host.jsx").ImportJob | null} */
|
|
3055
3243
|
null
|
|
3056
3244
|
);
|
|
3057
|
-
const afterSheet =
|
|
3245
|
+
const afterSheet = useRef13(
|
|
3058
3246
|
/** @type {(() => void) | null} */
|
|
3059
3247
|
null
|
|
3060
3248
|
);
|
|
3061
3249
|
const [dragging, setDragging] = useState12(false);
|
|
3062
|
-
const dragDepth =
|
|
3250
|
+
const dragDepth = useRef13(0);
|
|
3063
3251
|
const [importMod, setImportMod] = useState12(importNow);
|
|
3064
|
-
const fileInput =
|
|
3252
|
+
const fileInput = useRef13(
|
|
3065
3253
|
/** @type {HTMLInputElement | null} */
|
|
3066
3254
|
null
|
|
3067
3255
|
);
|
|
@@ -3069,13 +3257,14 @@ function Report(props) {
|
|
|
3069
3257
|
const labelsKey = JSON.stringify(customLabels ?? null);
|
|
3070
3258
|
const defaultsKey = JSON.stringify(fieldDefaults ?? null);
|
|
3071
3259
|
const info = useMemo8(() => fieldInfoOf(JSON.parse(defaultsKey)), [defaultsKey]);
|
|
3072
|
-
const
|
|
3260
|
+
const textsHere = useSyncExternalStore3(onLabels, () => hasLabels(locale), () => hasLabels(locale));
|
|
3261
|
+
const baseLabels = useMemo8(() => resolveLabels(textsHere ? locale : "en", JSON.parse(labelsKey)), [textsHere, locale, labelsKey]);
|
|
3073
3262
|
const typesKey = JSON.stringify(typesOf(fieldDefaults));
|
|
3074
3263
|
const limitsKey = JSON.stringify(limitsProp ?? null);
|
|
3075
3264
|
const hostLimits = useMemo8(() => JSON.parse(limitsKey) ?? void 0, [limitsKey]);
|
|
3076
3265
|
const importLimitsKey = JSON.stringify(importLimitsProp ?? null);
|
|
3077
3266
|
const fileLimits = useMemo8(() => importLimitsOf(hostLimits, JSON.parse(importLimitsKey)), [hostLimits, importLimitsKey]);
|
|
3078
|
-
const root =
|
|
3267
|
+
const root = useRef13(
|
|
3079
3268
|
/** @type {HTMLDivElement | null} */
|
|
3080
3269
|
null
|
|
3081
3270
|
);
|
|
@@ -3091,7 +3280,7 @@ function Report(props) {
|
|
|
3091
3280
|
/** @type {boolean | null} */
|
|
3092
3281
|
zonesStart(zonesProp)
|
|
3093
3282
|
);
|
|
3094
|
-
const foldOpenWhileEmpty =
|
|
3283
|
+
const foldOpenWhileEmpty = useRef13(false);
|
|
3095
3284
|
const [zonesSeen, setZonesSeen] = useState12(zonesProp);
|
|
3096
3285
|
if (zonesProp !== zonesSeen) {
|
|
3097
3286
|
setZonesSeen(zonesProp);
|
|
@@ -3099,7 +3288,7 @@ function Report(props) {
|
|
|
3099
3288
|
}
|
|
3100
3289
|
const zonesId = useId5();
|
|
3101
3290
|
const resultId = useId5();
|
|
3102
|
-
const ownPrefix =
|
|
3291
|
+
const ownPrefix = useRef13(
|
|
3103
3292
|
/** @type {string | null} */
|
|
3104
3293
|
null
|
|
3105
3294
|
);
|
|
@@ -3114,7 +3303,7 @@ function Report(props) {
|
|
|
3114
3303
|
null
|
|
3115
3304
|
);
|
|
3116
3305
|
const [hinted, setHinted] = useState12(false);
|
|
3117
|
-
const changesRef =
|
|
3306
|
+
const changesRef = useRef13(0);
|
|
3118
3307
|
const [changes, setChanges] = useState12(0);
|
|
3119
3308
|
const [dragAt, setDragAt] = useState12(
|
|
3120
3309
|
/** @type {number | null} */
|
|
@@ -3142,7 +3331,7 @@ function Report(props) {
|
|
|
3142
3331
|
/** @type {string | null} */
|
|
3143
3332
|
null
|
|
3144
3333
|
);
|
|
3145
|
-
const chartRef =
|
|
3334
|
+
const chartRef = useRef13(null);
|
|
3146
3335
|
const [chartReady, setChartReady] = useState12(false);
|
|
3147
3336
|
const [lineChecks, setLineChecks] = useState12(
|
|
3148
3337
|
/** @type {any} */
|
|
@@ -3189,7 +3378,7 @@ function Report(props) {
|
|
|
3189
3378
|
const encoded = imported ? imported.encoded : source.encoded;
|
|
3190
3379
|
const limits = imported ? fileLimits : hostLimits;
|
|
3191
3380
|
const fieldNamesKey = encoded.schema.fields.map((f) => f.name).join("\0");
|
|
3192
|
-
const
|
|
3381
|
+
const hostLabels = useMemo8(() => {
|
|
3193
3382
|
const fields2 = displayNames(info, fieldNamesKey ? fieldNamesKey.split("\0") : []);
|
|
3194
3383
|
return fields2 ? { ...baseLabels, core: { ...baseLabels.core, fields: fields2 } } : baseLabels;
|
|
3195
3384
|
}, [baseLabels, info, fieldNamesKey]);
|
|
@@ -3206,8 +3395,22 @@ function Report(props) {
|
|
|
3206
3395
|
}
|
|
3207
3396
|
return (field) => orders.find(([name]) => name.toLowerCase() === field.toLowerCase())?.[1];
|
|
3208
3397
|
}, [ordersKey]);
|
|
3209
|
-
const history = useViewHistory({ encoded, view: viewProp, defaultView, onViewChange, limits, outsideNote:
|
|
3398
|
+
const history = useViewHistory({ encoded, view: viewProp, defaultView, onViewChange, limits, outsideNote: hostLabels.steps.outside, orderOf, dataKey: imported ? imported.key : 0, initial: kept2?.history });
|
|
3210
3399
|
const view = history.view;
|
|
3400
|
+
const fieldLabelsKey = view.fieldLabels ? JSON.stringify(view.fieldLabels) : "";
|
|
3401
|
+
const labels = useMemo8(() => {
|
|
3402
|
+
if (!fieldLabelsKey) {
|
|
3403
|
+
return hostLabels;
|
|
3404
|
+
}
|
|
3405
|
+
return { ...hostLabels, hostNames: hostLabels.core.fields ?? null, core: withFieldLabels(hostLabels.core, JSON.parse(fieldLabelsKey)) };
|
|
3406
|
+
}, [hostLabels, fieldLabelsKey]);
|
|
3407
|
+
const shown = view.display === "both" && size !== "wide" ? "table" : view.display;
|
|
3408
|
+
const tableShown = shown !== "chart";
|
|
3409
|
+
const [split2, setSplit] = useState12(
|
|
3410
|
+
/** @type {number} */
|
|
3411
|
+
SPLIT.start
|
|
3412
|
+
);
|
|
3413
|
+
const chartShown = shown !== "table";
|
|
3211
3414
|
const [startView] = useState12(() => defaultView);
|
|
3212
3415
|
const hostKey = keyOfHostView(viewProp !== void 0 ? viewProp : startView);
|
|
3213
3416
|
const keyOf = history.keyOf;
|
|
@@ -3235,13 +3438,13 @@ function Report(props) {
|
|
|
3235
3438
|
field: note.field ?? "",
|
|
3236
3439
|
name: note.name ?? "",
|
|
3237
3440
|
zone: labels.zones[note.zone] ?? note.zone ?? "",
|
|
3238
|
-
display: note.display ? labels[note.display] : "",
|
|
3441
|
+
display: note.display === "both" ? labels.bothShown : note.display ? labels[note.display] : "",
|
|
3239
3442
|
type: note.type ? labels.chartTypes[note.type] : ""
|
|
3240
3443
|
});
|
|
3241
3444
|
},
|
|
3242
3445
|
[labels]
|
|
3243
3446
|
);
|
|
3244
|
-
const apiNow =
|
|
3447
|
+
const apiNow = useRef13(
|
|
3245
3448
|
/** @type {any} */
|
|
3246
3449
|
null
|
|
3247
3450
|
);
|
|
@@ -3258,7 +3461,7 @@ function Report(props) {
|
|
|
3258
3461
|
}
|
|
3259
3462
|
};
|
|
3260
3463
|
const newStep = useCallback10(() => setDataSteps((s) => s.future.length ? { past: s.past, future: [] } : s), []);
|
|
3261
|
-
const undoLater =
|
|
3464
|
+
const undoLater = useRef13(undo2);
|
|
3262
3465
|
useEffect11(() => {
|
|
3263
3466
|
undoLater.current = undo2;
|
|
3264
3467
|
});
|
|
@@ -3268,11 +3471,11 @@ function Report(props) {
|
|
|
3268
3471
|
announce(labels.toastReset, { action: { label: labels.undo, run: () => undoLater.current() } });
|
|
3269
3472
|
}, [history, labels, announce, newStep]);
|
|
3270
3473
|
const [opening, setOpening] = useState12(false);
|
|
3271
|
-
const appliedLink =
|
|
3474
|
+
const appliedLink = useRef13(
|
|
3272
3475
|
/** @type {string | null} */
|
|
3273
3476
|
null
|
|
3274
3477
|
);
|
|
3275
|
-
const latest =
|
|
3478
|
+
const latest = useRef13({ history, encoded, limits, labels, announce, commit: (
|
|
3276
3479
|
/** @type {any} */
|
|
3277
3480
|
null
|
|
3278
3481
|
), sourceId, loaded: (
|
|
@@ -3449,7 +3652,7 @@ function Report(props) {
|
|
|
3449
3652
|
}, [view.formatting?.locale, locale]);
|
|
3450
3653
|
const plan = useMemo8(() => chartPlan(view, encoded), [view, encoded]);
|
|
3451
3654
|
const chartComputed = useMemo8(() => {
|
|
3452
|
-
if (!plan.swap ||
|
|
3655
|
+
if (!plan.swap || !chartShown || !result) {
|
|
3453
3656
|
return computed;
|
|
3454
3657
|
}
|
|
3455
3658
|
try {
|
|
@@ -3457,7 +3660,7 @@ function Report(props) {
|
|
|
3457
3660
|
} catch (error2) {
|
|
3458
3661
|
return { result: null, error: error2 };
|
|
3459
3662
|
}
|
|
3460
|
-
}, [plan.swap, view, encoded, locale, limits, computed, result]);
|
|
3663
|
+
}, [plan.swap, chartShown, view, encoded, locale, limits, computed, result]);
|
|
3461
3664
|
const titleOf = useCallback10((field) => context.titles.get(field), [context]);
|
|
3462
3665
|
const chartContext = useMemo8(() => chartComputed.result === computed.result ? context : dateContext(chartComputed.result, labels), [chartComputed.result, computed.result, context, labels]);
|
|
3463
3666
|
const chartResult = chartContext.result;
|
|
@@ -3467,7 +3670,7 @@ function Report(props) {
|
|
|
3467
3670
|
foldOpenWhileEmpty.current = empty && short && folded === null;
|
|
3468
3671
|
});
|
|
3469
3672
|
const gridState = useMemo8(() => {
|
|
3470
|
-
if (!result ||
|
|
3673
|
+
if (!result || !tableShown || empty) {
|
|
3471
3674
|
return { grid: null, error: null };
|
|
3472
3675
|
}
|
|
3473
3676
|
try {
|
|
@@ -3475,13 +3678,14 @@ function Report(props) {
|
|
|
3475
3678
|
} catch (error2) {
|
|
3476
3679
|
return { grid: null, error: error2 };
|
|
3477
3680
|
}
|
|
3478
|
-
}, [result,
|
|
3479
|
-
const error = source.error ?? computed.error ?? gridState.error ?? (
|
|
3681
|
+
}, [result, tableShown, empty, locale, context.labels, limits]);
|
|
3682
|
+
const error = source.error ?? computed.error ?? gridState.error ?? (chartShown ? chartComputed.error : null);
|
|
3480
3683
|
const dateLocale = useMemo8(() => dateDisplayLocale(view.formatting?.locale || locale), [view.formatting?.locale, locale]);
|
|
3481
3684
|
const fields = encoded.schema.fields;
|
|
3482
3685
|
const types = useMemo8(() => new Map(viewFields(view, encoded).map((f) => [f.name.toLowerCase(), f.type])), [view, encoded]);
|
|
3483
3686
|
const typeOf = useCallback10((field) => types.get(sourceOf(view, field ?? "").toLowerCase()) ?? "string", [types, view]);
|
|
3484
3687
|
const nameOf = useCallback10((field) => fieldLabel5(field, labels.core), [labels]);
|
|
3688
|
+
const sourceNameOf = useCallback10((field) => sourceFieldName(field, labels), [labels]);
|
|
3485
3689
|
const hostOrdered = useCallback10((field) => sourceOf(view, field) === field && (orderOf?.(field)?.length ?? 0) > 0, [view, orderOf]);
|
|
3486
3690
|
const sortFromHeader = useCallback10((field, sort) => commit(setSort(view, field, sort), { step: "sort", field: nameOf(field) }), [view, commit, nameOf]);
|
|
3487
3691
|
const infoOf = useCallback10(
|
|
@@ -3535,11 +3739,11 @@ function Report(props) {
|
|
|
3535
3739
|
live = false;
|
|
3536
3740
|
};
|
|
3537
3741
|
}, [lang]);
|
|
3538
|
-
const mainRef =
|
|
3742
|
+
const mainRef = useRef13(
|
|
3539
3743
|
/** @type {HTMLDivElement | null} */
|
|
3540
3744
|
null
|
|
3541
3745
|
);
|
|
3542
|
-
const checkLow =
|
|
3746
|
+
const checkLow = useRef13(() => {
|
|
3543
3747
|
});
|
|
3544
3748
|
const fit = useFitHeight(root, mainRef, grow, () => checkLow.current());
|
|
3545
3749
|
const big = useBigResult(root);
|
|
@@ -3644,7 +3848,7 @@ function Report(props) {
|
|
|
3644
3848
|
return () => mo.disconnect();
|
|
3645
3849
|
}, [measuredShort, short, layer]);
|
|
3646
3850
|
const drawerOpen = drawer && size === "narrow";
|
|
3647
|
-
const panelRef =
|
|
3851
|
+
const panelRef = useRef13(
|
|
3648
3852
|
/** @type {HTMLDivElement | null} */
|
|
3649
3853
|
null
|
|
3650
3854
|
);
|
|
@@ -3725,6 +3929,10 @@ function Report(props) {
|
|
|
3725
3929
|
},
|
|
3726
3930
|
[view, typeOf, commit, addTo, defaultsOf]
|
|
3727
3931
|
);
|
|
3932
|
+
const [pointTarget, setPointTarget] = useState12(
|
|
3933
|
+
/** @type {{ anchor: HTMLElement, home?: HTMLElement | null, point: any } | null} */
|
|
3934
|
+
null
|
|
3935
|
+
);
|
|
3728
3936
|
const openCell = useCallback10(
|
|
3729
3937
|
/** @param {any} cell */
|
|
3730
3938
|
({ rowPath = [], colPath = [], value, valueIndex, text }) => {
|
|
@@ -3744,6 +3952,7 @@ function Report(props) {
|
|
|
3744
3952
|
},
|
|
3745
3953
|
[result, encodedProp, imported, data, drillDownLimit, onCellClick, drillDown, defaultsOf, nameOf, infoOf]
|
|
3746
3954
|
);
|
|
3955
|
+
const openPoint = (p) => openCell({ rowPath: p.rowPath, colPath: p.colPath, value: p.value, valueIndex: p.valueIndex, text: String(p.value ?? "") });
|
|
3747
3956
|
const { run: doExport, prepare: prepareExport } = useExport({ fileName, result: computed.result, encoded, exportData, locale, labels, limits, root, chartRef, announce, onExport, title: viewName, source: sourceName, loadECharts, colorMap: stableColorMap });
|
|
3748
3957
|
const requestImport = () => loadImport().then((m) => (flushSync(() => setImportMod(() => m)), m));
|
|
3749
3958
|
const api = {
|
|
@@ -3778,7 +3987,7 @@ function Report(props) {
|
|
|
3778
3987
|
useEffect11(() => {
|
|
3779
3988
|
apiNow.current = api;
|
|
3780
3989
|
});
|
|
3781
|
-
const restored =
|
|
3990
|
+
const restored = useRef13(false);
|
|
3782
3991
|
useIsoLayoutEffect(() => {
|
|
3783
3992
|
if (kept2 && !restored.current) {
|
|
3784
3993
|
restored.current = true;
|
|
@@ -3787,8 +3996,8 @@ function Report(props) {
|
|
|
3787
3996
|
}
|
|
3788
3997
|
}, []);
|
|
3789
3998
|
const snapshot = history.snapshot;
|
|
3790
|
-
const keptKey =
|
|
3791
|
-
const fileShown =
|
|
3999
|
+
const keptKey = useRef13(keepKey);
|
|
4000
|
+
const fileShown = useRef13(false);
|
|
3792
4001
|
const hostHasColumns = source.encoded.schema.fields.length > 0;
|
|
3793
4002
|
useIsoLayoutEffect(() => {
|
|
3794
4003
|
if (keepKey !== null && !kept2 && hostHasColumns) {
|
|
@@ -3869,7 +4078,7 @@ function Report(props) {
|
|
|
3869
4078
|
loadTemplate(how === "missing" ? { ...t, sheet: SHEET_GONE } : t);
|
|
3870
4079
|
}
|
|
3871
4080
|
};
|
|
3872
|
-
const loadLater =
|
|
4081
|
+
const loadLater = useRef13(
|
|
3873
4082
|
/** @type {((what: { template?: any, file?: object }) => void) | null} */
|
|
3874
4083
|
null
|
|
3875
4084
|
);
|
|
@@ -3971,11 +4180,11 @@ function Report(props) {
|
|
|
3971
4180
|
}
|
|
3972
4181
|
};
|
|
3973
4182
|
const layerValue = useMemo8(() => ({ layer, size }), [layer, size]);
|
|
3974
|
-
const renderOverlay = (src) => /* @__PURE__ */
|
|
4183
|
+
const renderOverlay = (src) => /* @__PURE__ */ React14.createElement("div", { className: "pk-chip pk-overlay" }, /* @__PURE__ */ React14.createElement(Icon, { name: "grip", size: 14 }), /* @__PURE__ */ React14.createElement("span", { className: `pk-type pk-type-${src.type ?? typeOf(src.field)}` }, /* @__PURE__ */ React14.createElement(Icon, { name: (
|
|
3975
4184
|
/** @type {any} */
|
|
3976
4185
|
TYPE_ICON[src.type ?? typeOf(src.field)] ?? "text"
|
|
3977
|
-
), size: 13 })), /* @__PURE__ */
|
|
3978
|
-
const showTable = !error && !(empty &&
|
|
4186
|
+
), size: 13 })), /* @__PURE__ */ React14.createElement("span", { className: "pk-chip-text" }, src.label ?? src.field));
|
|
4187
|
+
const showTable = !error && !(empty && tableShown) && tableShown && gridState.grid;
|
|
3979
4188
|
const outer = useMemo8(() => result ? outerPaths(result) : [], [result]);
|
|
3980
4189
|
const folding = rowFolding(view, outer);
|
|
3981
4190
|
const expandAll = (texts) => {
|
|
@@ -3991,7 +4200,7 @@ function Report(props) {
|
|
|
3991
4200
|
announce(plural(texts.groupsCollapsed, folding.open, { lang: labels.lang, locale }));
|
|
3992
4201
|
};
|
|
3993
4202
|
const series = useMemo8(() => {
|
|
3994
|
-
if (!chartResult ||
|
|
4203
|
+
if (!chartResult || !chartShown || view.values.length === 0) {
|
|
3995
4204
|
return null;
|
|
3996
4205
|
}
|
|
3997
4206
|
try {
|
|
@@ -3999,7 +4208,7 @@ function Report(props) {
|
|
|
3999
4208
|
} catch {
|
|
4000
4209
|
return null;
|
|
4001
4210
|
}
|
|
4002
|
-
}, [chartResult,
|
|
4211
|
+
}, [chartResult, chartShown, view.values.length, chartContext.labels]);
|
|
4003
4212
|
const allowedKey = JSON.stringify(allowedTips(tipsProp));
|
|
4004
4213
|
const allowed = useMemo8(() => JSON.parse(allowedKey), [allowedKey]);
|
|
4005
4214
|
const dismissedKey = JSON.stringify(cleanDismissed(dismissedTips));
|
|
@@ -4071,8 +4280,9 @@ function Report(props) {
|
|
|
4071
4280
|
}
|
|
4072
4281
|
};
|
|
4073
4282
|
const toggle = (id, on) => changeDismissed(on ? dismissed.filter((d) => d !== id) : [...dismissed, id], on ? null : id);
|
|
4074
|
-
const
|
|
4075
|
-
const
|
|
4283
|
+
const tipsMod = useTipsTable();
|
|
4284
|
+
const ctx = tipContext({ view, display: shown, result, encoded, failed: Boolean(error), empty, typeOf, fields: labels.core.fields, series, tableShown: Boolean(showTable), drilled: hinted, changes, dragAt, canSave: Boolean(onSaveTemplate) || viewStore, savedAt, chartPlan: plan });
|
|
4285
|
+
const shownTips = activeEntries(tipsMod?.TIPS ?? NOTICES, ctx, { allowed, dismissed }).map((t) => ({
|
|
4076
4286
|
id: t.id,
|
|
4077
4287
|
params: t.params,
|
|
4078
4288
|
icon: t.entry.icon ?? "info",
|
|
@@ -4115,7 +4325,41 @@ function Report(props) {
|
|
|
4115
4325
|
);
|
|
4116
4326
|
const summaryParts = big.enlarged ? layoutSummary(zoneEntries(view, types, context.labels), context.labels) : [];
|
|
4117
4327
|
const summaryText = summaryParts.length ? summaryParts.map((p) => `${p.title}: ${p.fields}`).join(" \xB7 ") : labels.layoutEmpty;
|
|
4118
|
-
|
|
4328
|
+
const chartEl = chartResult ? /* @__PURE__ */ React14.createElement(
|
|
4329
|
+
PivotChart,
|
|
4330
|
+
{
|
|
4331
|
+
result: chartResult,
|
|
4332
|
+
plan,
|
|
4333
|
+
series,
|
|
4334
|
+
labels: context.labels,
|
|
4335
|
+
locale,
|
|
4336
|
+
themeName,
|
|
4337
|
+
root,
|
|
4338
|
+
valueNames: valueLabels(view.values, labels),
|
|
4339
|
+
chartOptions: stableChartOptions,
|
|
4340
|
+
colorMap: stableColorMap,
|
|
4341
|
+
onLegend: ({ name, shown: shown2 }) => {
|
|
4342
|
+
commit(setChartDisplay(view, { hidden: hiddenAfter(view.chart.hidden, name, shown2) }), { step: "chartDisplay" });
|
|
4343
|
+
announce(fill(shown2 ? labels.chartShown : labels.chartHidden, { name }));
|
|
4344
|
+
},
|
|
4345
|
+
onInstance: (c) => {
|
|
4346
|
+
chartRef.current = c;
|
|
4347
|
+
setChartReady(Boolean(c));
|
|
4348
|
+
},
|
|
4349
|
+
onLines: (checks) => setLineChecks(checks && { checks, view }),
|
|
4350
|
+
onPoint: (p) => {
|
|
4351
|
+
const point = { ...p, rowPath: plan.swap ? p.colPath : p.rowPath, colPath: plan.swap ? p.rowPath : p.colPath, anchor: void 0, home: void 0 };
|
|
4352
|
+
if (p.direct) {
|
|
4353
|
+
setPointTarget(null);
|
|
4354
|
+
openPoint(point);
|
|
4355
|
+
} else if (p.anchor) {
|
|
4356
|
+
setPointTarget({ anchor: p.anchor, home: p.home, point });
|
|
4357
|
+
}
|
|
4358
|
+
}
|
|
4359
|
+
}
|
|
4360
|
+
) : null;
|
|
4361
|
+
const tableEl = gridState.grid ? /* @__PURE__ */ React14.createElement(PivotTable, { grid: gridState.grid, view, labels: context.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;
|
|
4362
|
+
return /* @__PURE__ */ React14.createElement(
|
|
4119
4363
|
"div",
|
|
4120
4364
|
{
|
|
4121
4365
|
ref: root,
|
|
@@ -4137,7 +4381,7 @@ function Report(props) {
|
|
|
4137
4381
|
onDragLeave: allowImport ? fileDrag : void 0,
|
|
4138
4382
|
onDrop: allowImport ? fileDrag : void 0
|
|
4139
4383
|
},
|
|
4140
|
-
/* @__PURE__ */
|
|
4384
|
+
/* @__PURE__ */ React14.createElement(LayerContext.Provider, { value: layerValue }, /* @__PURE__ */ React14.createElement(FormNameContext.Provider, { value: formPrefix }, /* @__PURE__ */ React14.createElement(HelpContext.Provider, { value: help }, /* @__PURE__ */ React14.createElement(
|
|
4141
4385
|
PivotDnd,
|
|
4142
4386
|
{
|
|
4143
4387
|
labels,
|
|
@@ -4149,7 +4393,7 @@ function Report(props) {
|
|
|
4149
4393
|
}
|
|
4150
4394
|
}
|
|
4151
4395
|
},
|
|
4152
|
-
/* @__PURE__ */
|
|
4396
|
+
/* @__PURE__ */ React14.createElement("div", { className: `pk-layout${drawerOpen ? " pk-drawer-open" : ""}` }, /* @__PURE__ */ React14.createElement("div", { className: "pk-panel-slot", ref: panelRef }, /* @__PURE__ */ React14.createElement(
|
|
4153
4397
|
FieldPanel,
|
|
4154
4398
|
{
|
|
4155
4399
|
fields,
|
|
@@ -4164,6 +4408,7 @@ function Report(props) {
|
|
|
4164
4408
|
onNote: (text) => announce(text),
|
|
4165
4409
|
onFilter: filterField,
|
|
4166
4410
|
nameOf,
|
|
4411
|
+
sourceNameOf,
|
|
4167
4412
|
info: fieldInfo,
|
|
4168
4413
|
showInfo: fieldSwitch.on,
|
|
4169
4414
|
drawer: size === "narrow",
|
|
@@ -4176,7 +4421,7 @@ function Report(props) {
|
|
|
4176
4421
|
root.current?.querySelector(".pk-toolbar button:not([disabled])")?.focus()
|
|
4177
4422
|
)
|
|
4178
4423
|
}
|
|
4179
|
-
)), drawerOpen ? /* @__PURE__ */
|
|
4424
|
+
)), drawerOpen ? /* @__PURE__ */ React14.createElement("div", { className: "pk-scrim pk-drawer-scrim", onClick: () => setDrawer(false), "aria-hidden": "true" }) : null, /* @__PURE__ */ React14.createElement("div", { className: "pk-main", ref: mainRef }, /* @__PURE__ */ React14.createElement(
|
|
4180
4425
|
Toolbar,
|
|
4181
4426
|
{
|
|
4182
4427
|
view,
|
|
@@ -4199,7 +4444,8 @@ function Report(props) {
|
|
|
4199
4444
|
onExport: doExport,
|
|
4200
4445
|
prepareExport,
|
|
4201
4446
|
dataExport: { exportData, encoded },
|
|
4202
|
-
chartReady:
|
|
4447
|
+
chartReady: chartShown && chartReady,
|
|
4448
|
+
display: shown,
|
|
4203
4449
|
empty,
|
|
4204
4450
|
onShowFields: () => setDrawer(true),
|
|
4205
4451
|
tipsControls: allowed !== "off",
|
|
@@ -4211,9 +4457,9 @@ function Report(props) {
|
|
|
4211
4457
|
explanations: explainUser ? { on: !dismissed.includes(NO_EXPLANATIONS), set: (on) => toggle(NO_EXPLANATIONS, on) } : null
|
|
4212
4458
|
},
|
|
4213
4459
|
viewsRequest,
|
|
4214
|
-
data: allowImport ? { loaded: Boolean(imported), panel: (close) => /* @__PURE__ */
|
|
4460
|
+
data: allowImport ? { loaded: Boolean(imported), panel: (close) => /* @__PURE__ */ React14.createElement(MenuPanel, { name: "DataMenu", loadingText: labels.loadingMenu, props: { api, close, labels } }) } : null
|
|
4215
4461
|
}
|
|
4216
|
-
), /* @__PURE__ */
|
|
4462
|
+
), /* @__PURE__ */ React14.createElement(
|
|
4217
4463
|
Zones,
|
|
4218
4464
|
{
|
|
4219
4465
|
view,
|
|
@@ -4234,7 +4480,7 @@ function Report(props) {
|
|
|
4234
4480
|
showInfo: fieldSwitch.on,
|
|
4235
4481
|
adding
|
|
4236
4482
|
}
|
|
4237
|
-
), linkCheck ? /* @__PURE__ */
|
|
4483
|
+
), linkCheck ? /* @__PURE__ */ React14.createElement("div", { className: "pk-link-check", "data-testid": "link-check" }, /* @__PURE__ */ React14.createElement(MenuPanel, { name: "LoadCheck", props: { check: linkCheck, labels, title: labels.linkCheckTitle, quiet: linkCheck.quiet, close: () => setLinkCheck(null), onCancel: cancelLink } })) : null, /* @__PURE__ */ React14.createElement(
|
|
4238
4484
|
Unused,
|
|
4239
4485
|
{
|
|
4240
4486
|
notes,
|
|
@@ -4252,7 +4498,7 @@ function Report(props) {
|
|
|
4252
4498
|
narrow: size === "narrow",
|
|
4253
4499
|
quiet: unusedSaid && !fromHost
|
|
4254
4500
|
}
|
|
4255
|
-
), /* @__PURE__ */
|
|
4501
|
+
), /* @__PURE__ */ React14.createElement(
|
|
4256
4502
|
Tips,
|
|
4257
4503
|
{
|
|
4258
4504
|
tips: shownTips,
|
|
@@ -4261,13 +4507,15 @@ function Report(props) {
|
|
|
4261
4507
|
onAction: runTip,
|
|
4262
4508
|
focusFallback: () => root.current?.focus({ preventScroll: true })
|
|
4263
4509
|
}
|
|
4264
|
-
), showTable && view.values.length ? /* @__PURE__ */
|
|
4510
|
+
), showTable && view.values.length ? /* @__PURE__ */ React14.createElement("p", { id: hintId, className: "pk-sr", "data-testid": "cell-hint" }, labels.tips.cells) : null, big.enlarged ? /* @__PURE__ */ React14.createElement("p", { className: "pk-enlarged-fields", "data-testid": "enlarged-fields" }, summaryText) : null, /* @__PURE__ */ React14.createElement(
|
|
4265
4511
|
ViewTabs,
|
|
4266
4512
|
{
|
|
4267
4513
|
view,
|
|
4268
4514
|
labels,
|
|
4269
4515
|
panelId: resultId,
|
|
4270
4516
|
narrow: size === "narrow",
|
|
4517
|
+
shown,
|
|
4518
|
+
both: size === "wide",
|
|
4271
4519
|
big,
|
|
4272
4520
|
plan,
|
|
4273
4521
|
encoded,
|
|
@@ -4283,33 +4531,10 @@ function Report(props) {
|
|
|
4283
4531
|
onCollapse: collapseAll,
|
|
4284
4532
|
folding
|
|
4285
4533
|
}
|
|
4286
|
-
), /* @__PURE__ */
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
plan,
|
|
4291
|
-
series,
|
|
4292
|
-
labels: context.labels,
|
|
4293
|
-
locale,
|
|
4294
|
-
themeName,
|
|
4295
|
-
root,
|
|
4296
|
-
valueNames: valueLabels(view.values, labels),
|
|
4297
|
-
chartOptions: stableChartOptions,
|
|
4298
|
-
colorMap: stableColorMap,
|
|
4299
|
-
onLegend: ({ name, shown }) => {
|
|
4300
|
-
commit(setChartDisplay(view, { hidden: hiddenAfter(view.chart.hidden, name, shown) }), { step: "chartDisplay" });
|
|
4301
|
-
announce(fill(shown ? labels.chartShown : labels.chartHidden, { name }));
|
|
4302
|
-
},
|
|
4303
|
-
onInstance: (c) => {
|
|
4304
|
-
chartRef.current = c;
|
|
4305
|
-
setChartReady(Boolean(c));
|
|
4306
|
-
},
|
|
4307
|
-
onLines: (checks) => setLineChecks(checks && { checks, view }),
|
|
4308
|
-
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 ?? "") })
|
|
4309
|
-
}
|
|
4310
|
-
) : gridState.grid ? /* @__PURE__ */ React13.createElement(PivotTable, { grid: gridState.grid, view, labels: context.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__ */ React13.createElement("div", { className: "pk-status" }, /* @__PURE__ */ React13.createElement("span", { className: "pk-row-count", "data-testid": "row-count" }, result ? rowCount(result.rows.length, result.encoded.length, labels, locale) : ""), context.ranges.map(({ field, text }) => /* @__PURE__ */ React13.createElement("span", { key: field, "data-testid": "date-range", title: fill(labels.dateRangeTitle, { field: fieldLabel5(field, labels.core) }) }, context.ranges.length > 1 ? fill(labels.dateRangeField, { field: fieldLabel5(field, labels.core), range: text }) : fill(labels.dateRangeData, { range: text }))), importMod ? /* @__PURE__ */ React13.createElement(importMod.SourceLine, { api }) : null, rowLabel && showTable ? /* @__PURE__ */ React13.createElement("span", { className: "pk-row-label", "data-testid": "row-label" }, fill(labels.rowLabel, { label: rowLabel })) : null), /* @__PURE__ */ React13.createElement("div", { className: "pk-toast-dock" }, /* @__PURE__ */ React13.createElement(Toasts, { toasts, dismiss, pause, closeLabel: labels.close }))), drill ? /* @__PURE__ */ React13.createElement(MenuPanel, { name: "DrillPanel", props: { drill, onClose: () => setDrill(null), labels: context.labels, locale, exportContext: { encoded, onExport, announce, root, exportData, drillDownExport } } }) : null),
|
|
4311
|
-
filterTarget ? /* @__PURE__ */ React13.createElement(MenuPanel, { name: "FilterPopover", props: { target: filterTarget, onClose: closeFilter, view, encoded, locale, labels, commit } }) : null
|
|
4312
|
-
), allowImport && importMod ? /* @__PURE__ */ React13.createElement(importMod.ImportLayer, { api, input: fileInput }) : null, /* @__PURE__ */ React13.createElement("div", { className: "pk-layer", ref: setLayer }, /* @__PURE__ */ React13.createElement("span", { className: "pk-origin", "aria-hidden": "true" })))))
|
|
4534
|
+
), /* @__PURE__ */ React14.createElement("section", { className: "pk-result", id: resultId, role: "tabpanel", "aria-labelledby": tabId(resultId, shown) }, loading2 || opening ? /* @__PURE__ */ React14.createElement(Skeleton, { text: labels.loadingReport }) : error ? /* @__PURE__ */ React14.createElement("div", { className: "pk-message pk-error", role: "alert" }, /* @__PURE__ */ React14.createElement(Icon, { name: "info" }), /* @__PURE__ */ React14.createElement("p", null, errorText(error, labels, locale))) : empty && tableShown ? /* @__PURE__ */ React14.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 }) : shown === "both" ? /* @__PURE__ */ React14.createElement(SideBySide, { labels, split: split2, onSplit: setSplit, table: gridState.grid ? tableEl : null, chart: chartResult ? chartEl : null }) : shown === "chart" && chartResult ? chartEl : gridState.grid ? tableEl : null), /* @__PURE__ */ React14.createElement("div", { className: "pk-status" }, /* @__PURE__ */ React14.createElement("span", { className: "pk-row-count", "data-testid": "row-count" }, result ? rowCount(result.rows.length, result.encoded.length, labels, locale) : ""), context.ranges.map(({ field, text }) => /* @__PURE__ */ React14.createElement("span", { key: field, "data-testid": "date-range", title: fill(labels.dateRangeTitle, { field: fieldLabel5(field, labels.core) }) }, context.ranges.length > 1 ? fill(labels.dateRangeField, { field: fieldLabel5(field, labels.core), range: text }) : fill(labels.dateRangeData, { range: text }))), importMod ? /* @__PURE__ */ React14.createElement(importMod.SourceLine, { api }) : null, rowLabel && showTable ? /* @__PURE__ */ React14.createElement("span", { className: "pk-row-label", "data-testid": "row-label" }, fill(labels.rowLabel, { label: rowLabel })) : null), /* @__PURE__ */ React14.createElement("div", { className: "pk-toast-dock" }, /* @__PURE__ */ React14.createElement(Toasts, { toasts, dismiss, pause, closeLabel: labels.close }))), drill ? /* @__PURE__ */ React14.createElement(MenuPanel, { name: "DrillPanel", props: { drill, onClose: () => setDrill(null), labels: context.labels, locale, exportContext: { encoded, onExport, announce, root, exportData, drillDownExport } } }) : null),
|
|
4535
|
+
filterTarget ? /* @__PURE__ */ React14.createElement(MenuPanel, { name: "FilterPopover", props: { target: filterTarget, onClose: closeFilter, view, encoded, locale, labels, commit } }) : null,
|
|
4536
|
+
pointTarget ? /* @__PURE__ */ React14.createElement(MenuPanel, { name: "PointMenu", props: { target: pointTarget, onClose: () => setPointTarget(null), onRows: openPoint, view, encoded, locale, labels, commit, showRows: drillDown || Boolean(onCellClick) } }) : null
|
|
4537
|
+
), allowImport && importMod ? /* @__PURE__ */ React14.createElement(importMod.ImportLayer, { api, input: fileInput }) : null, /* @__PURE__ */ React14.createElement("div", { className: "pk-layer", ref: setLayer }, /* @__PURE__ */ React14.createElement("span", { className: "pk-origin", "aria-hidden": "true" })))))
|
|
4313
4538
|
);
|
|
4314
4539
|
}
|
|
4315
4540
|
export {
|