pivotkit-react 0.7.0 → 0.8.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 +167 -1
- package/README.md +33 -15
- package/dist/chunks/{chunk-JMRTIOX4.js → chunk-2N2UGSIG.js} +7 -0
- package/dist/chunks/{chunk-ZK5RVCHP.js → chunk-BHHIZHUE.js} +1 -1
- package/dist/chunks/{chunk-YXLANLGL.js → chunk-GUSQWPTH.js} +56 -3
- package/dist/chunks/{chunk-E6M57YLL.js → chunk-MU5BTKSY.js} +7 -0
- package/dist/chunks/{chunk-TR2HROIK.js → chunk-RNQ32FCN.js} +66 -5
- package/dist/chunks/{chunk-XN5HNKJ2.js → chunk-SJCG4I57.js} +98 -33
- package/dist/chunks/{chunk-4WZ5F2TJ.js → chunk-VMJMDP7C.js} +371 -32
- package/dist/chunks/{unused-texts-Y4R67XSN.js → unused-texts-LRYVWFFN.js} +1 -1
- package/dist/chunks/{unused-texts-de-6YVPTNVS.js → unused-texts-de-GB3IWWEM.js} +1 -1
- package/dist/echarts.js +426 -35
- package/dist/import-ui.js +2 -2
- package/dist/index.js +723 -392
- package/dist/labels.js +6 -6
- package/dist/menu-texts-de.js +1 -1
- package/dist/menus.js +1534 -1020
- package/dist/styles.css +268 -158
- package/package.json +3 -3
- package/types/PivotReport.d.ts +6 -0
- package/types/add-menu.d.ts +48 -0
- package/types/chart-colors.d.ts +8 -0
- package/types/chart-decorate.d.ts +66 -3
- package/types/chart-legend.d.ts +176 -0
- package/types/chart-summary.d.ts +8 -3
- package/types/chart-tooltip.d.ts +159 -17
- package/types/chart.d.ts +21 -3
- package/types/date-context.d.ts +30 -0
- package/types/drill-panel.d.ts +4 -2
- package/types/echarts.d.ts +7 -3
- package/types/export-run.d.ts +7 -14
- package/types/export-scope.d.ts +13 -2
- package/types/field-info.d.ts +12 -0
- package/types/files.d.ts +14 -0
- package/types/filter.d.ts +18 -0
- package/types/group-context.d.ts +20 -0
- package/types/index.d.ts +35 -6
- package/types/label-room.d.ts +13 -0
- package/types/labels.d.ts +85 -16
- package/types/lazy-menus.d.ts +2 -2
- package/types/levels.d.ts +16 -7
- package/types/menu-labels.d.ts +67 -1
- package/types/menu-ops.d.ts +10 -0
- package/types/menu-topics.d.ts +110 -21
- package/types/menus.d.ts +2 -1
- package/types/names.d.ts +32 -3
- package/types/overflow.d.ts +18 -30
- package/types/rove.d.ts +10 -0
- package/types/toolbar-panels.d.ts +34 -10
- package/types/unused-texts.d.ts +7 -0
- package/types/use-big-result.d.ts +24 -9
- package/types/use-export.d.ts +2 -2
- package/types/view-ops.d.ts +19 -8
- package/types/view-tabs.d.ts +12 -0
- package/types/zones.d.ts +41 -9
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
InfoButton,
|
|
9
9
|
MAX_CATEGORIES,
|
|
10
10
|
NO_EXPLANATIONS,
|
|
11
|
+
SLICE_TYPES,
|
|
11
12
|
ZONES,
|
|
12
13
|
activeTips,
|
|
13
14
|
addField,
|
|
@@ -15,9 +16,15 @@ import {
|
|
|
15
16
|
chartPlan,
|
|
16
17
|
chartTypeOf,
|
|
17
18
|
cleanDismissed,
|
|
19
|
+
dateContext,
|
|
20
|
+
dateDisplayLocale,
|
|
21
|
+
dateRangeText,
|
|
18
22
|
dateSpan,
|
|
23
|
+
displayNames,
|
|
19
24
|
drillRows,
|
|
20
25
|
fieldAction,
|
|
26
|
+
fieldDefaultsFor,
|
|
27
|
+
fieldInfoOf,
|
|
21
28
|
fieldsCollapsed,
|
|
22
29
|
filterZoneFields,
|
|
23
30
|
filtersOf,
|
|
@@ -26,6 +33,7 @@ import {
|
|
|
26
33
|
headerSortState,
|
|
27
34
|
headerSortTarget,
|
|
28
35
|
helpSwitch,
|
|
36
|
+
hiddenAfter,
|
|
29
37
|
importNow,
|
|
30
38
|
isEmptyPick,
|
|
31
39
|
isEmptyView,
|
|
@@ -37,6 +45,7 @@ import {
|
|
|
37
45
|
loadImport,
|
|
38
46
|
loadLink,
|
|
39
47
|
localStore,
|
|
48
|
+
matchingFields,
|
|
40
49
|
moveField,
|
|
41
50
|
nextHeaderSort,
|
|
42
51
|
numberRange,
|
|
@@ -67,16 +76,19 @@ import {
|
|
|
67
76
|
tipContext,
|
|
68
77
|
tipText,
|
|
69
78
|
toggleCollapsed,
|
|
79
|
+
typesOf,
|
|
70
80
|
valueConditionText,
|
|
71
81
|
valueLabel,
|
|
82
|
+
valueLabels,
|
|
72
83
|
viewFromObject,
|
|
73
84
|
withHostOrders,
|
|
74
85
|
withoutFilters,
|
|
75
86
|
writeDismissed,
|
|
76
87
|
writeItem,
|
|
77
88
|
writeStoredView,
|
|
89
|
+
zoneMax,
|
|
78
90
|
zoneOverLimit
|
|
79
|
-
} from "./chunks/chunk-
|
|
91
|
+
} from "./chunks/chunk-VMJMDP7C.js";
|
|
80
92
|
import {
|
|
81
93
|
FormNameContext,
|
|
82
94
|
Group,
|
|
@@ -100,17 +112,19 @@ import {
|
|
|
100
112
|
mergeLabels,
|
|
101
113
|
messageOf,
|
|
102
114
|
plural,
|
|
103
|
-
|
|
104
|
-
|
|
115
|
+
removedLabels,
|
|
116
|
+
resolveLabels,
|
|
117
|
+
rowCount
|
|
118
|
+
} from "./chunks/chunk-SJCG4I57.js";
|
|
105
119
|
|
|
106
120
|
// src/PivotReport.jsx
|
|
107
|
-
import
|
|
121
|
+
import React13, { useCallback as useCallback10, useEffect as useEffect11, useId as useId5, useMemo as useMemo8, useRef as useRef12, useState as useState12, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
108
122
|
import { flushSync } from "react-dom";
|
|
109
123
|
import { computePivot, emptyView as emptyView2, encode, fieldLabel as fieldLabel5, normalize as normalize2, suggestDateUnit, toGrid, toSeries, viewFields } from "pivotkit-core";
|
|
110
124
|
|
|
111
125
|
// src/chart.jsx
|
|
112
126
|
import React, { useEffect, useId, useRef, useState } from "react";
|
|
113
|
-
import { fieldLabel
|
|
127
|
+
import { fieldLabel } from "pivotkit-core";
|
|
114
128
|
|
|
115
129
|
// src/chart-summary.js
|
|
116
130
|
import { formatter } from "pivotkit-core";
|
|
@@ -126,10 +140,11 @@ function counts(s, labels, locale) {
|
|
|
126
140
|
series: plural(labels.chartSeries, series, { lang: labels.lang, locale })
|
|
127
141
|
});
|
|
128
142
|
}
|
|
129
|
-
function chartSummary(s, { type, rows, valueNames, labels, locale }) {
|
|
143
|
+
function chartSummary(s, { type, rows, valueNames, labels, locale, shares = false, linesText = "" }) {
|
|
130
144
|
const parts = [
|
|
131
145
|
fill(labels.chartSummary, { type: labels.chartTypes[type] ?? type, values: valueNames.join(", "), categories: rows.length ? rows.join(" / ") : labels.categories }),
|
|
132
|
-
counts(s, labels, locale)
|
|
146
|
+
counts(s, labels, locale),
|
|
147
|
+
...shares ? [labels.chartShares] : []
|
|
133
148
|
];
|
|
134
149
|
let max = null;
|
|
135
150
|
let min = null;
|
|
@@ -151,6 +166,9 @@ function chartSummary(s, { type, rows, valueNames, labels, locale }) {
|
|
|
151
166
|
const text = (p) => formatter(s.series[p.si].format, { locale })(p.v);
|
|
152
167
|
parts.push(fill(labels.chartExtremes, { max: text(max), maxAt: where(max), min: text(min), minAt: where(min) }));
|
|
153
168
|
}
|
|
169
|
+
if (linesText) {
|
|
170
|
+
parts.push(linesText);
|
|
171
|
+
}
|
|
154
172
|
parts.push(labels.chartTableHint);
|
|
155
173
|
return parts.join(" ");
|
|
156
174
|
}
|
|
@@ -169,11 +187,12 @@ function resolveTheme(wanted, htmlTheme, prefersDark) {
|
|
|
169
187
|
|
|
170
188
|
// src/chart.jsx
|
|
171
189
|
var loading = null;
|
|
190
|
+
var TAP_WAIT = 1e4;
|
|
172
191
|
function loadECharts() {
|
|
173
192
|
loading ??= import("./echarts.js");
|
|
174
193
|
return loading;
|
|
175
194
|
}
|
|
176
|
-
function PivotChart({ result, series, labels, locale, themeName, root, onInstance, onPoint, valueNames, chartOptions, plan }) {
|
|
195
|
+
function PivotChart({ result, series, labels, locale, themeName, root, onInstance, onPoint, onLines, onLegend, valueNames, chartOptions, colorMap, plan }) {
|
|
177
196
|
const el = useRef(
|
|
178
197
|
/** @type {HTMLDivElement | null} */
|
|
179
198
|
null
|
|
@@ -189,10 +208,24 @@ function PivotChart({ result, series, labels, locale, themeName, root, onInstanc
|
|
|
189
208
|
);
|
|
190
209
|
const [box, setBox] = useState("");
|
|
191
210
|
const [every, setEvery] = useState(1);
|
|
211
|
+
const [linesText, setLinesText] = useState("");
|
|
192
212
|
const summaryId = useId();
|
|
193
213
|
const type = plan ? plan.name : chartTypeOf(result.view.chart);
|
|
194
214
|
const drawAs = plan ? plan.chart : null;
|
|
195
|
-
const latest = useRef({ series, onPoint, onInstance, type });
|
|
215
|
+
const latest = useRef({ series, onPoint, onInstance, onLines, onLegend, type });
|
|
216
|
+
const keeper = useRef(
|
|
217
|
+
/** @type {any} */
|
|
218
|
+
null
|
|
219
|
+
);
|
|
220
|
+
const [zoomed, setZoomed] = useState(0);
|
|
221
|
+
const [zoomKeys, setZoomKeys] = useState(
|
|
222
|
+
/** @type {any} */
|
|
223
|
+
null
|
|
224
|
+
);
|
|
225
|
+
const [shown, setShown] = useState(
|
|
226
|
+
/** @type {{ series: any, shares: boolean } | null} */
|
|
227
|
+
null
|
|
228
|
+
);
|
|
196
229
|
const lib = useRef(
|
|
197
230
|
/** @type {any} */
|
|
198
231
|
null
|
|
@@ -201,12 +234,23 @@ function PivotChart({ result, series, labels, locale, themeName, root, onInstanc
|
|
|
201
234
|
/** @type {unknown} */
|
|
202
235
|
void 0
|
|
203
236
|
);
|
|
237
|
+
const hover = useRef(
|
|
238
|
+
/** @type {{ seriesIndex: number, dataIndex: number } | null} */
|
|
239
|
+
null
|
|
240
|
+
);
|
|
241
|
+
const tapped = useRef(
|
|
242
|
+
/** @type {{ element: string, at: number } | null} */
|
|
243
|
+
null
|
|
244
|
+
);
|
|
245
|
+
const touched = useRef(false);
|
|
204
246
|
useEffect(() => {
|
|
205
|
-
latest.current = { series, onPoint, onInstance, type };
|
|
247
|
+
latest.current = { series, onPoint, onInstance, onLines, onLegend, type };
|
|
206
248
|
});
|
|
207
249
|
useEffect(() => {
|
|
208
250
|
let disposed = false;
|
|
209
251
|
let ro = null;
|
|
252
|
+
let onPress = null;
|
|
253
|
+
let doc = null;
|
|
210
254
|
loadECharts().then(
|
|
211
255
|
(echarts) => {
|
|
212
256
|
if (disposed || !el.current) {
|
|
@@ -224,8 +268,50 @@ function PivotChart({ result, series, labels, locale, themeName, root, onInstanc
|
|
|
224
268
|
}
|
|
225
269
|
const seriesEntry = kind === "heatmap" ? s.series.filter((x) => x.valueIndex === s.series[0]?.valueIndex)[p.value?.[0]] : s.series[p.seriesIndex];
|
|
226
270
|
const row = kind === "heatmap" ? p.value?.[1] : p.dataIndex;
|
|
227
|
-
if (seriesEntry
|
|
228
|
-
|
|
271
|
+
if (!seriesEntry || !s.categoryPaths[row]) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const element = `${p.seriesIndex}:${p.dataIndex}`;
|
|
275
|
+
const last = tapped.current;
|
|
276
|
+
if (touched.current && (last?.element !== element || Date.now() - last.at > TAP_WAIT)) {
|
|
277
|
+
tapped.current = { element, at: Date.now() };
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
tapped.current = null;
|
|
281
|
+
instance.dispatchAction({ type: "hideTip" });
|
|
282
|
+
const value = kind === "heatmap" ? p.value[2] : typeof p.data?.raw === "number" ? p.data.raw : p.value;
|
|
283
|
+
cb({ rowPath: s.categoryPaths[row], colPath: seriesEntry.colPath, valueIndex: seriesEntry.valueIndex, value });
|
|
284
|
+
});
|
|
285
|
+
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
|
+
const redraw = (e) => {
|
|
287
|
+
const at = e?.event;
|
|
288
|
+
if (at && typeof at.offsetX === "number") {
|
|
289
|
+
instance.dispatchAction({ type: "hideTip" });
|
|
290
|
+
instance.dispatchAction({ type: "showTip", x: at.offsetX, y: at.offsetY });
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
instance.on("mousemove", (e) => {
|
|
294
|
+
if (e.componentType === "series" && (e.seriesType === "bar" || e.seriesType === "line") && typeof e.dataIndex === "number") {
|
|
295
|
+
const last = hover.current;
|
|
296
|
+
if (last?.seriesIndex !== e.seriesIndex || last?.dataIndex !== e.dataIndex) {
|
|
297
|
+
hover.current = { seriesIndex: e.seriesIndex, dataIndex: e.dataIndex };
|
|
298
|
+
redraw(e);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
instance.on("mouseout", (e) => {
|
|
303
|
+
if (hover.current) {
|
|
304
|
+
hover.current = null;
|
|
305
|
+
redraw(e);
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
instance.on("globalout", () => {
|
|
309
|
+
hover.current = null;
|
|
310
|
+
tapped.current = null;
|
|
311
|
+
});
|
|
312
|
+
instance.getZr().on("click", (e) => {
|
|
313
|
+
if (!e.target) {
|
|
314
|
+
tapped.current = null;
|
|
229
315
|
}
|
|
230
316
|
});
|
|
231
317
|
ro = typeof ResizeObserver === "function" ? new ResizeObserver(() => {
|
|
@@ -233,36 +319,62 @@ function PivotChart({ result, series, labels, locale, themeName, root, onInstanc
|
|
|
233
319
|
setBox(`${instance.getWidth()}x${instance.getHeight()}`);
|
|
234
320
|
}) : null;
|
|
235
321
|
ro?.observe(el.current);
|
|
322
|
+
const box2 = el.current;
|
|
323
|
+
doc = box2.ownerDocument;
|
|
324
|
+
onPress = (e) => {
|
|
325
|
+
if (e.composedPath().includes(box2)) {
|
|
326
|
+
touched.current = e.pointerType === "touch";
|
|
327
|
+
} else {
|
|
328
|
+
tapped.current = null;
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
doc.addEventListener("pointerdown", onPress, true);
|
|
236
332
|
setReady(true);
|
|
237
333
|
},
|
|
238
334
|
(err) => setFailed(String(err && err.message ? err.message : err))
|
|
239
335
|
);
|
|
240
336
|
return () => {
|
|
241
337
|
disposed = true;
|
|
338
|
+
keeper.current?.dispose();
|
|
242
339
|
ro?.disconnect();
|
|
340
|
+
if (onPress) {
|
|
341
|
+
doc?.removeEventListener("pointerdown", onPress, true);
|
|
342
|
+
}
|
|
243
343
|
chart.current?.dispose();
|
|
244
344
|
chart.current = null;
|
|
245
345
|
latest.current.onInstance(null);
|
|
346
|
+
latest.current.onLines?.(null);
|
|
246
347
|
};
|
|
247
348
|
}, []);
|
|
248
349
|
useEffect(() => {
|
|
249
350
|
if (!ready || !chart.current || !root.current) {
|
|
250
351
|
return;
|
|
251
352
|
}
|
|
353
|
+
const { toEChartsOption } = lib.current;
|
|
252
354
|
const style = lib.current.chartStyle(root.current);
|
|
253
|
-
const
|
|
254
|
-
const
|
|
255
|
-
|
|
355
|
+
const colors = lib.current.colorMapFor(colorMap, themeName);
|
|
356
|
+
const option = toEChartsOption(result, { theme: chartThemeFrom(style), locale, labels: labels.core, maxCategories: MAX_CATEGORIES, ...series ? { series } : {}, ...drawAs ? { chart: drawAs } : {}, ...colors ? { colorMap: colors } : {} });
|
|
357
|
+
hover.current = null;
|
|
358
|
+
tapped.current = null;
|
|
359
|
+
const values = (series?.series ?? []).map((x) => result.view.values[x.valueIndex]);
|
|
360
|
+
const lines = series ? lib.current.chartLines(result, { series, chart: drawAs, labels, locale }) : null;
|
|
361
|
+
setLinesText(lines?.text ?? "");
|
|
362
|
+
latest.current.onLines?.(lines?.checks ?? null);
|
|
363
|
+
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
|
+
const doc = root.current.ownerDocument;
|
|
365
|
+
setShown(series ? lib.current.shownOf(series, option, result.view.chart.hidden, SLICE_TYPES.includes(type)) : null);
|
|
256
366
|
const clean = chartOptions ? lib.current.cleanChartOptions(chartOptions) : null;
|
|
257
367
|
if (clean?.problems.length && warned2.current !== chartOptions) {
|
|
258
368
|
warned2.current = chartOptions;
|
|
259
369
|
console.warn(`pivotkit: chartOptions entries left out (only plain JSON, and no markup, addresses or text templates): ${clean.problems.slice(0, 5).join("; ")}${clean.problems.length > 5 ? `; and ${clean.problems.length - 5} more` : ""}`);
|
|
260
370
|
}
|
|
261
|
-
|
|
262
|
-
|
|
371
|
+
const drawn = lib.current.drawOption(chart.current, option, style, doc, { categoryNames: series?.categories, axisLabels: result.view.chart.axisLabels, ...keeper.current.zoomOf(result, series?.categories ?? [], doc), tooltip, parseColor: lib.current.color.parse }, clean?.options);
|
|
372
|
+
keeper.current.drawn(drawn.dataZoom);
|
|
373
|
+
setEvery(drawn.axisEvery);
|
|
374
|
+
}, [ready, result, series, labels, locale, themeName, root, box, chartOptions, colorMap, drawAs, zoomed, type]);
|
|
263
375
|
const empty = result.view.values.length === 0;
|
|
264
|
-
const summary = series && !empty ? chartSummary(series, { type, rows: result.view.rows.map((f) => fieldLabel(f, labels.core)), valueNames, labels, locale }) : labels.noChartData;
|
|
265
|
-
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), !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);
|
|
376
|
+
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);
|
|
266
378
|
}
|
|
267
379
|
|
|
268
380
|
// src/dnd.jsx
|
|
@@ -358,11 +470,11 @@ function keyboardCoordinates(event, { context }) {
|
|
|
358
470
|
const over = context.over?.data?.current ?? null;
|
|
359
471
|
const id = nextTarget(event.code, targets, over, context.active?.data?.current ?? { kind: "field" });
|
|
360
472
|
const rect = id === null ? null : context.droppableRects.get(id);
|
|
361
|
-
const
|
|
362
|
-
if (!rect || !
|
|
473
|
+
const own = context.collisionRect;
|
|
474
|
+
if (!rect || !own) {
|
|
363
475
|
return void 0;
|
|
364
476
|
}
|
|
365
|
-
return { x: rect.left + rect.width / 2 -
|
|
477
|
+
return { x: rect.left + rect.width / 2 - own.width / 2, y: rect.top + rect.height / 2 - own.height / 2 };
|
|
366
478
|
}
|
|
367
479
|
function targetOf(source, over) {
|
|
368
480
|
const data = over?.data?.current;
|
|
@@ -433,8 +545,8 @@ function ownEventsOnly(listener) {
|
|
|
433
545
|
};
|
|
434
546
|
}
|
|
435
547
|
function split(listeners2) {
|
|
436
|
-
const
|
|
437
|
-
const { onKeyDown, ...pointer } =
|
|
548
|
+
const own = Object.fromEntries(Object.entries(listeners2 ?? {}).map(([name, listener]) => [name, ownEventsOnly(listener)]));
|
|
549
|
+
const { onKeyDown, ...pointer } = own;
|
|
438
550
|
return { pointer, keyboard: listeners2?.onKeyDown ? { onKeyDown } : {} };
|
|
439
551
|
}
|
|
440
552
|
function useDragSource(id, source, disabled = false) {
|
|
@@ -456,123 +568,6 @@ function ChipList({ ids, children }) {
|
|
|
456
568
|
return /* @__PURE__ */ React2.createElement(SortableContext, { items: ids, strategy: rectSortingStrategy }, children);
|
|
457
569
|
}
|
|
458
570
|
|
|
459
|
-
// src/field-info.js
|
|
460
|
-
import { fieldDefaultsFromSchema, isIdentifierName } from "pivotkit-core";
|
|
461
|
-
var isObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
462
|
-
var own = (o, k) => isObject(o) && Object.hasOwn(o, k) ? o[k] : void 0;
|
|
463
|
-
var TYPES = Object.freeze(["string", "number", "date", "boolean"]);
|
|
464
|
-
function fieldInfoOf(fieldDefaults) {
|
|
465
|
-
const map = /* @__PURE__ */ new Map();
|
|
466
|
-
if (!isObject(fieldDefaults)) {
|
|
467
|
-
return map;
|
|
468
|
-
}
|
|
469
|
-
const properties = {};
|
|
470
|
-
for (const name of Object.keys(
|
|
471
|
-
/** @type {object} */
|
|
472
|
-
fieldDefaults
|
|
473
|
-
)) {
|
|
474
|
-
const d = own(fieldDefaults, name);
|
|
475
|
-
const title = own(d, "label");
|
|
476
|
-
const description = own(d, "description");
|
|
477
|
-
const href = own(d, "href");
|
|
478
|
-
if (title !== void 0 || description !== void 0 || href !== void 0) {
|
|
479
|
-
Object.defineProperty(properties, name, { value: { title, description, externalDocs: { url: href } }, enumerable: true });
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
if (Object.keys(properties).length === 0) {
|
|
483
|
-
return map;
|
|
484
|
-
}
|
|
485
|
-
const clean = fieldDefaultsFromSchema({ properties }).defaults;
|
|
486
|
-
for (const name of Object.keys(clean)) {
|
|
487
|
-
const { label, description, href } = clean[name];
|
|
488
|
-
const info = {};
|
|
489
|
-
if (label) {
|
|
490
|
-
info.label = label;
|
|
491
|
-
}
|
|
492
|
-
if (description) {
|
|
493
|
-
info.description = description;
|
|
494
|
-
if (href) {
|
|
495
|
-
info.href = href;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
if (Object.keys(info).length) {
|
|
499
|
-
map.set(name.toLowerCase(), info);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
return map;
|
|
503
|
-
}
|
|
504
|
-
function displayNames(info, fieldNames = []) {
|
|
505
|
-
const spelling = new Map(fieldNames.map((n) => [String(n).toLowerCase(), String(n)]));
|
|
506
|
-
const uses = /* @__PURE__ */ new Map();
|
|
507
|
-
for (const entry of info.values()) {
|
|
508
|
-
if (entry.label) {
|
|
509
|
-
const l = entry.label.toLowerCase();
|
|
510
|
-
uses.set(l, (uses.get(l) ?? 0) + 1);
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
const out = {};
|
|
514
|
-
for (const [key, entry] of info) {
|
|
515
|
-
if (!entry.label) {
|
|
516
|
-
continue;
|
|
517
|
-
}
|
|
518
|
-
const l = entry.label.toLowerCase();
|
|
519
|
-
const clash = uses.get(l) > 1 || spelling.has(l) && l !== key;
|
|
520
|
-
const value = clash ? `${entry.label} (${spelling.get(key) ?? key})` : entry.label;
|
|
521
|
-
Object.defineProperty(out, key, { value, enumerable: true });
|
|
522
|
-
}
|
|
523
|
-
return Object.keys(out).length ? out : null;
|
|
524
|
-
}
|
|
525
|
-
function typesOf(fieldDefaults) {
|
|
526
|
-
if (!isObject(fieldDefaults)) {
|
|
527
|
-
return null;
|
|
528
|
-
}
|
|
529
|
-
const out = {};
|
|
530
|
-
for (const name of Object.keys(
|
|
531
|
-
/** @type {object} */
|
|
532
|
-
fieldDefaults
|
|
533
|
-
)) {
|
|
534
|
-
const type = own(own(fieldDefaults, name), "type");
|
|
535
|
-
if (typeof type === "string" && TYPES.includes(type)) {
|
|
536
|
-
Object.defineProperty(out, name, { value: type, enumerable: true });
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
return Object.keys(out).length ? out : null;
|
|
540
|
-
}
|
|
541
|
-
function fieldMatches(field, query, info) {
|
|
542
|
-
if (!query) {
|
|
543
|
-
return true;
|
|
544
|
-
}
|
|
545
|
-
return [field, info?.label, info?.description].some((t) => typeof t === "string" && t.toLowerCase().includes(query));
|
|
546
|
-
}
|
|
547
|
-
var identifierColumns = /* @__PURE__ */ new WeakMap();
|
|
548
|
-
function isIdentifier(column) {
|
|
549
|
-
if (!column || column.type !== "number" || column.derived || !isIdentifierName(column.name)) {
|
|
550
|
-
return false;
|
|
551
|
-
}
|
|
552
|
-
const known = identifierColumns.get(column);
|
|
553
|
-
if (known !== void 0) {
|
|
554
|
-
return known;
|
|
555
|
-
}
|
|
556
|
-
let whole = true;
|
|
557
|
-
for (let i = 0; i < column.dict.length && whole; i++) {
|
|
558
|
-
whole = Number.isInteger(column.dict[i]);
|
|
559
|
-
}
|
|
560
|
-
identifierColumns.set(column, whole);
|
|
561
|
-
return whole;
|
|
562
|
-
}
|
|
563
|
-
function fieldDefaultsFor(fieldDefaults, field, column) {
|
|
564
|
-
const key = isObject(fieldDefaults) ? Object.keys(
|
|
565
|
-
/** @type {object} */
|
|
566
|
-
fieldDefaults
|
|
567
|
-
).find((k) => k.toLowerCase() === String(field).toLowerCase()) : void 0;
|
|
568
|
-
const host = key === void 0 ? void 0 : own(fieldDefaults, key);
|
|
569
|
-
const set = ["agg", "format", "drillFormat"].some((k) => own(host, k) !== void 0);
|
|
570
|
-
if (set || !isIdentifier(column)) {
|
|
571
|
-
return isObject(host) ? host : void 0;
|
|
572
|
-
}
|
|
573
|
-
return { ...isObject(host) ? host : {}, agg: "count", drillFormat: "text" };
|
|
574
|
-
}
|
|
575
|
-
|
|
576
571
|
// src/fields.jsx
|
|
577
572
|
import React3, { useCallback, useEffect as useEffect2, useId as useId2, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
|
|
578
573
|
|
|
@@ -597,6 +592,23 @@ function roveTarget(key, at, rows, slotsOf) {
|
|
|
597
592
|
return null;
|
|
598
593
|
}
|
|
599
594
|
var opensMenu = (e) => e.key === "ContextMenu" || e.key === "F10" && e.shiftKey;
|
|
595
|
+
function tabStep(key, at, count) {
|
|
596
|
+
if (count <= 0) {
|
|
597
|
+
return null;
|
|
598
|
+
}
|
|
599
|
+
switch (key) {
|
|
600
|
+
case "ArrowRight":
|
|
601
|
+
return (at + 1) % count;
|
|
602
|
+
case "ArrowLeft":
|
|
603
|
+
return (at - 1 + count) % count;
|
|
604
|
+
case "Home":
|
|
605
|
+
return 0;
|
|
606
|
+
case "End":
|
|
607
|
+
return count - 1;
|
|
608
|
+
default:
|
|
609
|
+
return null;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
600
612
|
|
|
601
613
|
// src/fields.jsx
|
|
602
614
|
function FieldItem({ field, labels, zones, onAdd, onNote, onFilter, name, info, showInfo, stop }) {
|
|
@@ -617,8 +629,8 @@ function FieldItem({ field, labels, zones, onAdd, onNote, onFilter, name, info,
|
|
|
617
629
|
const action = fieldAction(name, field.type, zones, labels);
|
|
618
630
|
const describedBy = useId2();
|
|
619
631
|
const slots = SLOTS.filter((x) => x !== "info" || info && showInfo);
|
|
620
|
-
const
|
|
621
|
-
const tab = (slot) =>
|
|
632
|
+
const own = stop && slots.includes(stop) ? stop : stop ? "name" : null;
|
|
633
|
+
const tab = (slot) => own === slot ? 0 : -1;
|
|
622
634
|
return /* @__PURE__ */ React3.createElement("li", { className: `pk-field${isDragging ? " pk-dragging" : ""}${zones.length ? " pk-placed" : ""}`, ref, ...itemProps, "data-field": field.name }, /* @__PURE__ */ React3.createElement("span", { className: "pk-handle", ...handleProps, tabIndex: tab("handle"), "data-pk-slot": "handle", "aria-label": fill(labels.dragHandle, { field: name }), title: labels.dragIntoZone, onClick: () => menu.current?.click() }, /* @__PURE__ */ React3.createElement(Icon, { name: "grip", size: 18 })), /* @__PURE__ */ React3.createElement("span", { className: `pk-type pk-type-${field.type}`, title: typeLabel }, /* @__PURE__ */ React3.createElement(Icon, { name: (
|
|
623
635
|
/** @type {any} */
|
|
624
636
|
TYPE_ICON[field.type] ?? "text"
|
|
@@ -671,10 +683,7 @@ function FieldPanel({ fields, placed, labels, onAdd, onNote, onFilter, drawer, o
|
|
|
671
683
|
const [query, setQuery] = useState3("");
|
|
672
684
|
const active = useActiveDrag();
|
|
673
685
|
const { setNodeRef, isOver } = useDropTarget("panel", { kind: "panel" });
|
|
674
|
-
const shown = useMemo2(() =>
|
|
675
|
-
const q = query.trim().toLowerCase();
|
|
676
|
-
return q ? fields.filter((f) => fieldMatches(f.name, q, info.get(f.name.toLowerCase()))) : fields;
|
|
677
|
-
}, [fields, query, info]);
|
|
686
|
+
const shown = useMemo2(() => matchingFields(fields, query, info), [fields, query, info]);
|
|
678
687
|
const removing = active && active.kind !== "field";
|
|
679
688
|
const modal = drawer && open;
|
|
680
689
|
const el = useRef2(
|
|
@@ -1013,9 +1022,9 @@ function rowLabelOf(grid, r) {
|
|
|
1013
1022
|
const row = grid.headerRows + r;
|
|
1014
1023
|
const texts = [];
|
|
1015
1024
|
for (let c = 0; c < grid.rowHeaderColumns; c++) {
|
|
1016
|
-
const
|
|
1017
|
-
const merge =
|
|
1018
|
-
const cell =
|
|
1025
|
+
const own = grid.rows[row]?.[c];
|
|
1026
|
+
const merge = own ? null : grid.merges.find((m) => m.row <= row && row < m.row + m.rowSpan && m.col <= c && c < m.col + m.colSpan);
|
|
1027
|
+
const cell = own ?? (merge && merge.col === c ? grid.rows[merge.row][merge.col] : null);
|
|
1019
1028
|
if (cell && cell.text) {
|
|
1020
1029
|
texts.push(cell.text);
|
|
1021
1030
|
}
|
|
@@ -1048,6 +1057,23 @@ function longestLabels(grid, col, n) {
|
|
|
1048
1057
|
return out;
|
|
1049
1058
|
}
|
|
1050
1059
|
|
|
1060
|
+
// src/label-room.js
|
|
1061
|
+
function commonCap(widths, room) {
|
|
1062
|
+
if (room <= 0) {
|
|
1063
|
+
return 0;
|
|
1064
|
+
}
|
|
1065
|
+
const sorted = [...widths].sort((a, b) => a - b);
|
|
1066
|
+
let left = room;
|
|
1067
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
1068
|
+
const share = left / (sorted.length - i);
|
|
1069
|
+
if (sorted[i] > share) {
|
|
1070
|
+
return share;
|
|
1071
|
+
}
|
|
1072
|
+
left -= sorted[i];
|
|
1073
|
+
}
|
|
1074
|
+
return Infinity;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1051
1077
|
// src/table.jsx
|
|
1052
1078
|
var totalClass = (t) => t === 2 ? " pk-grand" : t === 1 ? " pk-sub" : "";
|
|
1053
1079
|
var MEASURED_LABELS = 50;
|
|
@@ -1065,7 +1091,7 @@ function labelWidths(grid, table) {
|
|
|
1065
1091
|
Object.assign(probe.style, { position: "absolute", visibility: "hidden", whiteSpace: "pre", width: "auto", minWidth: "0", maxWidth: "none", overflow: "visible" });
|
|
1066
1092
|
content.append(probe);
|
|
1067
1093
|
try {
|
|
1068
|
-
const
|
|
1094
|
+
const widthOf2 = (l) => {
|
|
1069
1095
|
probe.style.fontWeight = l.total ? "var(--pk-weight-bold)" : "";
|
|
1070
1096
|
probe.textContent = l.text;
|
|
1071
1097
|
return probe.getBoundingClientRect().width;
|
|
@@ -1076,7 +1102,7 @@ function labelWidths(grid, table) {
|
|
|
1076
1102
|
const toggleWidth = (toggle ? toggle.getBoundingClientRect().width : em * 1.7) + gap;
|
|
1077
1103
|
const widths = [];
|
|
1078
1104
|
for (let c = 0; c < grid.rowHeaderColumns; c++) {
|
|
1079
|
-
const most = Math.max(0, ...longestLabels(grid, c, MEASURED_LABELS).map((l) =>
|
|
1105
|
+
const most = Math.max(0, ...longestLabels(grid, c, MEASURED_LABELS).map((l) => widthOf2(l) + (l.toggle ? toggleWidth : 0)));
|
|
1080
1106
|
widths.push(Math.min(Math.ceil(most) + LABEL_SLACK, LABEL_MAX_EM * em));
|
|
1081
1107
|
}
|
|
1082
1108
|
return widths;
|
|
@@ -1084,6 +1110,40 @@ function labelWidths(grid, table) {
|
|
|
1084
1110
|
probe.remove();
|
|
1085
1111
|
}
|
|
1086
1112
|
}
|
|
1113
|
+
var widthOf = (el) => el.getBoundingClientRect().width;
|
|
1114
|
+
function fitLabels(table, box, columns) {
|
|
1115
|
+
if (box.clientWidth === 0) {
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
const over = () => box.scrollWidth - box.clientWidth;
|
|
1119
|
+
table.setAttribute("data-pk-labels", "natural");
|
|
1120
|
+
table.style.removeProperty("--pk-row-room");
|
|
1121
|
+
const head = table.tHead ? table.tHead.rows : [];
|
|
1122
|
+
const last = head[head.length - 1];
|
|
1123
|
+
const overflow = over();
|
|
1124
|
+
if (overflow <= 0 || !last) {
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1127
|
+
const cells = [...last.cells].slice(0, columns);
|
|
1128
|
+
const extras = cells.map((cell) => {
|
|
1129
|
+
const s = getComputedStyle(cell);
|
|
1130
|
+
const grip = cell.querySelector(":scope > .pk-th-grip");
|
|
1131
|
+
return parseFloat(s.paddingLeft) + parseFloat(s.paddingRight) + parseFloat(s.borderLeftWidth) + parseFloat(s.borderRightWidth) + (grip ? widthOf(grip) + parseFloat(getComputedStyle(grip).marginLeft) : 0);
|
|
1132
|
+
});
|
|
1133
|
+
const widths = cells.map((cell, c) => widthOf(cell) - extras[c]);
|
|
1134
|
+
const names = [...last.querySelectorAll("th.pk-colHeader .pk-th-content")].reduce((sum, el) => sum + widthOf(el), 0);
|
|
1135
|
+
const pliable = names + (table.classList.contains("pk-virtual") ? 0 : widths.reduce((a, b) => a + b, 0));
|
|
1136
|
+
if (overflow < pliable) {
|
|
1137
|
+
table.setAttribute("data-pk-labels", "share");
|
|
1138
|
+
if (over() <= 0) {
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
table.removeAttribute("data-pk-labels");
|
|
1143
|
+
const values = widthOf(table) - cells.reduce((sum, cell) => sum + widthOf(cell), 0);
|
|
1144
|
+
const room = commonCap(widths, box.clientWidth - values - extras.reduce((a, b) => a + b, 0));
|
|
1145
|
+
table.style.setProperty("--pk-row-room", `${Number.isFinite(room) ? Math.floor(room) : Math.max(0, ...widths)}px`);
|
|
1146
|
+
}
|
|
1087
1147
|
var fontOf = (table) => {
|
|
1088
1148
|
const s = getComputedStyle(table);
|
|
1089
1149
|
return `${s.fontFamily}|${s.fontSize}|${s.fontWeight}`;
|
|
@@ -1158,6 +1218,11 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1158
1218
|
null
|
|
1159
1219
|
);
|
|
1160
1220
|
const [fontsLoaded, setFontsLoaded] = useState5(0);
|
|
1221
|
+
const [font, setFont] = useState5("");
|
|
1222
|
+
const fitted = useRef4(
|
|
1223
|
+
/** @type {unknown[]} */
|
|
1224
|
+
[]
|
|
1225
|
+
);
|
|
1161
1226
|
const fixedWidths = virtual && labelsWide?.grid === grid ? labelsWide.widths : null;
|
|
1162
1227
|
const focusNext = useRef4(false);
|
|
1163
1228
|
const [sortNote, setSortNote] = useState5("");
|
|
@@ -1177,16 +1242,16 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1177
1242
|
if (!virtual || !t) {
|
|
1178
1243
|
return;
|
|
1179
1244
|
}
|
|
1180
|
-
const
|
|
1181
|
-
if (labelsWide?.grid !== grid || labelsWide.font !==
|
|
1245
|
+
const font2 = fontOf(t);
|
|
1246
|
+
if (labelsWide?.grid !== grid || labelsWide.font !== font2 || labelsWide.fonts !== fontsLoaded) {
|
|
1182
1247
|
const widths = labelWidths(grid, t);
|
|
1183
1248
|
if (widths) {
|
|
1184
|
-
setLabelsWide({ grid, font, fonts: fontsLoaded, widths });
|
|
1249
|
+
setLabelsWide({ grid, font: font2, fonts: fontsLoaded, widths });
|
|
1185
1250
|
}
|
|
1186
1251
|
}
|
|
1187
1252
|
});
|
|
1188
1253
|
useEffect4(() => {
|
|
1189
|
-
const fonts =
|
|
1254
|
+
const fonts = table.current?.ownerDocument.fonts;
|
|
1190
1255
|
if (!fonts) {
|
|
1191
1256
|
return void 0;
|
|
1192
1257
|
}
|
|
@@ -1200,12 +1265,17 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1200
1265
|
live = false;
|
|
1201
1266
|
fonts.removeEventListener?.("loadingdone", loaded3);
|
|
1202
1267
|
};
|
|
1203
|
-
}, [
|
|
1268
|
+
}, []);
|
|
1204
1269
|
useIsoLayoutEffect(() => {
|
|
1205
1270
|
const t = table.current;
|
|
1206
1271
|
if (!t) {
|
|
1207
1272
|
return;
|
|
1208
1273
|
}
|
|
1274
|
+
const key = [t, grid, width, font, fontsLoaded, fixedWidths];
|
|
1275
|
+
if (wrap.current && !key.every((v, i) => v === fitted.current[i])) {
|
|
1276
|
+
fitted.current = key;
|
|
1277
|
+
fitLabels(t, wrap.current, grid.rowHeaderColumns);
|
|
1278
|
+
}
|
|
1209
1279
|
const row = t.tBodies[0]?.querySelector("tr[data-r]");
|
|
1210
1280
|
if (row && row.getBoundingClientRect().height > 0) {
|
|
1211
1281
|
setRowHeight(row.getBoundingClientRect().height);
|
|
@@ -1225,7 +1295,7 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1225
1295
|
}
|
|
1226
1296
|
setLefts((old) => old.length === xs.length && old.every((v, i) => Math.abs(v - xs[i]) < 0.5) ? old : xs);
|
|
1227
1297
|
}
|
|
1228
|
-
}, [grid, version, width, fixedWidths]);
|
|
1298
|
+
}, [grid, version, width, font, fixedWidths, fontsLoaded]);
|
|
1229
1299
|
useEffect4(() => {
|
|
1230
1300
|
const el = wrap.current;
|
|
1231
1301
|
if (!el) {
|
|
@@ -1234,6 +1304,9 @@ function PivotTable({ grid, view, labels, onToggle: toggleGroup, onCell, version
|
|
|
1234
1304
|
const update = () => {
|
|
1235
1305
|
setScroll({ top: el.scrollTop, height: el.clientHeight });
|
|
1236
1306
|
setWidth(el.clientWidth);
|
|
1307
|
+
if (table.current) {
|
|
1308
|
+
setFont(fontOf(table.current));
|
|
1309
|
+
}
|
|
1237
1310
|
};
|
|
1238
1311
|
update();
|
|
1239
1312
|
const ro = typeof ResizeObserver === "function" ? new ResizeObserver(update) : null;
|
|
@@ -1497,12 +1570,12 @@ function Toasts({ toasts, dismiss, pause, closeLabel }) {
|
|
|
1497
1570
|
}
|
|
1498
1571
|
|
|
1499
1572
|
// src/templates.js
|
|
1500
|
-
import { fieldDefaultsFromSchema
|
|
1573
|
+
import { fieldDefaultsFromSchema, fromViewFile } from "pivotkit-core";
|
|
1501
1574
|
var warnedScope = false;
|
|
1502
1575
|
function plainNames(names) {
|
|
1503
1576
|
const properties = {};
|
|
1504
1577
|
names.forEach((title, i) => Object.defineProperty(properties, String(i), { value: { title }, enumerable: true }));
|
|
1505
|
-
const clean = names.length ?
|
|
1578
|
+
const clean = names.length ? fieldDefaultsFromSchema({ properties }).defaults : {};
|
|
1506
1579
|
return names.map((n, i) => Object.hasOwn(clean, String(i)) ? clean[String(i)].label : void 0);
|
|
1507
1580
|
}
|
|
1508
1581
|
var viewsName = (key) => key ? `pivotkit:views:${key}` : "pivotkit:views";
|
|
@@ -1591,15 +1664,15 @@ import React9, { useEffect as useEffect7, useMemo as useMemo4, useRef as useRef7
|
|
|
1591
1664
|
import { fieldLabel as fieldLabel3 } from "pivotkit-core";
|
|
1592
1665
|
|
|
1593
1666
|
// src/unused-load.js
|
|
1594
|
-
var UNUSED_TEXTS_OF = Object.freeze({ de: () => import("./chunks/unused-texts-de-
|
|
1667
|
+
var UNUSED_TEXTS_OF = Object.freeze({ de: () => import("./chunks/unused-texts-de-GB3IWWEM.js").then((m) => m.de) });
|
|
1595
1668
|
var pending2 = /* @__PURE__ */ new Map();
|
|
1596
1669
|
var loaded2 = /* @__PURE__ */ new Map();
|
|
1597
1670
|
var unusedNow = (lang) => loaded2.get(lang) ?? null;
|
|
1598
1671
|
function loadUnused(lang) {
|
|
1599
1672
|
let p = pending2.get(lang);
|
|
1600
1673
|
if (!p) {
|
|
1601
|
-
const
|
|
1602
|
-
p = Promise.all([import("./chunks/unused-texts-
|
|
1674
|
+
const own = Object.hasOwn(UNUSED_TEXTS_OF, lang) ? UNUSED_TEXTS_OF[lang]().catch(() => null) : null;
|
|
1675
|
+
p = Promise.all([import("./chunks/unused-texts-LRYVWFFN.js"), own]).then(
|
|
1603
1676
|
([mod, texts]) => {
|
|
1604
1677
|
const out = { mod, lang: texts };
|
|
1605
1678
|
loaded2.set(lang, out);
|
|
@@ -1695,7 +1768,7 @@ function Unused({ notes, notesKey, dismissed, onDismiss, labels, locale, narrow,
|
|
|
1695
1768
|
// src/unused-keep.js
|
|
1696
1769
|
var PATH = /^([A-Za-z]+)(?:\[(\d+)\])?(?:\.([A-Za-z]+))?/;
|
|
1697
1770
|
var lower = (v) => typeof v === "string" ? v.toLowerCase() : v;
|
|
1698
|
-
var
|
|
1771
|
+
var isObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
1699
1772
|
function partOf(path, raw, view) {
|
|
1700
1773
|
const m = PATH.exec(path ?? "");
|
|
1701
1774
|
if (!m) {
|
|
@@ -1704,19 +1777,19 @@ function partOf(path, raw, view) {
|
|
|
1704
1777
|
const [, key, index, sub] = m;
|
|
1705
1778
|
const section = Object.hasOwn(view, key) ? view[key] : void 0;
|
|
1706
1779
|
if (key === "values" && index !== void 0 && Array.isArray(section)) {
|
|
1707
|
-
const given =
|
|
1780
|
+
const given = isObject(raw) && Array.isArray(
|
|
1708
1781
|
/** @type {any} */
|
|
1709
1782
|
raw.values
|
|
1710
1783
|
) ? (
|
|
1711
1784
|
/** @type {any} */
|
|
1712
1785
|
raw.values[Number(index)]
|
|
1713
1786
|
) : void 0;
|
|
1714
|
-
const match =
|
|
1787
|
+
const match = isObject(given) ? section.find((v) => lower(v.field ?? null) === lower(given.field ?? null) && lower(v.agg) === lower(given.agg)) : void 0;
|
|
1715
1788
|
if (match) {
|
|
1716
1789
|
return JSON.stringify(match);
|
|
1717
1790
|
}
|
|
1718
1791
|
}
|
|
1719
|
-
if (sub !== void 0 &&
|
|
1792
|
+
if (sub !== void 0 && isObject(section)) {
|
|
1720
1793
|
return JSON.stringify(Object.hasOwn(section, sub) ? section[sub] : void 0);
|
|
1721
1794
|
}
|
|
1722
1795
|
return JSON.stringify(section);
|
|
@@ -1735,25 +1808,20 @@ function stillApplies(note, loaded3, shown) {
|
|
|
1735
1808
|
import React10, { useCallback as useCallback4, useEffect as useEffect8, useMemo as useMemo5, useRef as useRef8, useState as useState8 } from "react";
|
|
1736
1809
|
|
|
1737
1810
|
// src/overflow.js
|
|
1738
|
-
var OVERFLOW_ORDER = Object.freeze(["
|
|
1739
|
-
var MORE_GROUPS = Object.freeze([Object.freeze(["startOver"]), Object.freeze(["
|
|
1811
|
+
var OVERFLOW_ORDER = Object.freeze(["data", "startOver", "views"]);
|
|
1812
|
+
var MORE_GROUPS = Object.freeze([Object.freeze(["startOver"]), Object.freeze(["data"]), Object.freeze(["views"])]);
|
|
1740
1813
|
var TOOLBAR_ROOM = Object.freeze({
|
|
1741
1814
|
fields: 6.4,
|
|
1742
|
-
display: 15.3,
|
|
1743
|
-
chartType: 12.9,
|
|
1744
|
-
sep: 1,
|
|
1745
1815
|
undo: 8.75,
|
|
1746
1816
|
redo: 9.15,
|
|
1747
1817
|
startOver: 10.9,
|
|
1748
|
-
layout: 8.4,
|
|
1749
|
-
options: 8.75,
|
|
1750
1818
|
data: 7.4,
|
|
1751
1819
|
views: 9.1,
|
|
1752
1820
|
export: 7.5,
|
|
1753
1821
|
more: 7.2
|
|
1754
1822
|
});
|
|
1755
|
-
var TEXT_BUTTONS = Object.freeze(["fields", "undo", "redo"
|
|
1756
|
-
var MENU_BUTTONS = Object.freeze(["
|
|
1823
|
+
var TEXT_BUTTONS = Object.freeze(["fields", "undo", "redo"]);
|
|
1824
|
+
var MENU_BUTTONS = Object.freeze(["startOver", "data", "views", "export", "more"]);
|
|
1757
1825
|
function toolbarTexts(labels) {
|
|
1758
1826
|
const text = (v) => typeof v === "string" ? v : "";
|
|
1759
1827
|
return (
|
|
@@ -1763,22 +1831,18 @@ function toolbarTexts(labels) {
|
|
|
1763
1831
|
undo: [text(labels.undo)],
|
|
1764
1832
|
redo: [text(labels.redo)],
|
|
1765
1833
|
startOver: [text(labels.startOver)],
|
|
1766
|
-
layout: [text(labels.layout)],
|
|
1767
|
-
options: [text(labels.options)],
|
|
1768
1834
|
views: [text(labels.views)],
|
|
1769
1835
|
data: [text(labels.data)],
|
|
1770
1836
|
export: [text(labels.exportLabel)],
|
|
1771
|
-
more: [text(labels.more)]
|
|
1772
|
-
chartType: Object.values(labels.chartTypes ?? {}).map(text),
|
|
1773
|
-
display: [[text(labels.table), text(labels.chart)]]
|
|
1837
|
+
more: [text(labels.more)]
|
|
1774
1838
|
}
|
|
1775
1839
|
);
|
|
1776
1840
|
}
|
|
1777
1841
|
function toolbarRoom(texts, measure, chrome) {
|
|
1778
|
-
const widest = (list
|
|
1842
|
+
const widest = (list) => Math.max(0, ...list.map((t) => measure(t)));
|
|
1779
1843
|
const room = (
|
|
1780
1844
|
/** @type {Record<string, number>} */
|
|
1781
|
-
{
|
|
1845
|
+
{}
|
|
1782
1846
|
);
|
|
1783
1847
|
for (const id of TEXT_BUTTONS) {
|
|
1784
1848
|
room[id] = chrome.text + widest(texts[id]) + chrome.gap;
|
|
@@ -1786,13 +1850,12 @@ function toolbarRoom(texts, measure, chrome) {
|
|
|
1786
1850
|
for (const id of MENU_BUTTONS) {
|
|
1787
1851
|
room[id] = chrome.menu + widest(texts[id]) + chrome.gap;
|
|
1788
1852
|
}
|
|
1789
|
-
room.display = chrome.display + Math.max(0, ...texts.display.map(([a, b]) => measure(a, "display") + measure(b, "display"))) + chrome.gap;
|
|
1790
1853
|
return room;
|
|
1791
1854
|
}
|
|
1792
1855
|
function overflowHidden(width, narrow, present, room = TOOLBAR_ROOM) {
|
|
1793
|
-
const fixed = (narrow ? room.fields : 0) + room.
|
|
1856
|
+
const fixed = (narrow ? room.fields : 0) + room.undo + room.redo + room.export + room.more;
|
|
1794
1857
|
const order = OVERFLOW_ORDER.filter((id) => present.includes(id));
|
|
1795
|
-
const need = (shown2) => fixed + shown2.reduce((sum, id) => sum + (room[id] ?? 0), 0)
|
|
1858
|
+
const need = (shown2) => fixed + shown2.reduce((sum, id) => sum + (room[id] ?? 0), 0);
|
|
1796
1859
|
let shown = order;
|
|
1797
1860
|
while (shown.length && need(shown) > width) {
|
|
1798
1861
|
shown = shown.slice(1);
|
|
@@ -1824,37 +1887,28 @@ function measuredRoom(el, texts) {
|
|
|
1824
1887
|
}
|
|
1825
1888
|
const undo2 = el.querySelector("[data-testid='undo']");
|
|
1826
1889
|
const menu = el.querySelector("[data-testid='export']");
|
|
1827
|
-
const
|
|
1828
|
-
|
|
1829
|
-
const textOf = (node) => node?.querySelector(".pk-btn-text, span");
|
|
1830
|
-
if (!measuring || !undo2 || !menu || !display || !textOf(undo2) || !textOf(display)) {
|
|
1890
|
+
const textOf = (node) => node?.querySelector(".pk-btn-text");
|
|
1891
|
+
if (!measuring || !undo2 || !menu || !textOf(undo2) || !textOf(menu)) {
|
|
1831
1892
|
return null;
|
|
1832
1893
|
}
|
|
1833
1894
|
const view = doc.defaultView;
|
|
1834
1895
|
if (!view) {
|
|
1835
1896
|
return null;
|
|
1836
1897
|
}
|
|
1837
|
-
const
|
|
1898
|
+
const font = fontOf2(view.getComputedStyle(
|
|
1838
1899
|
/** @type {Element} */
|
|
1839
1900
|
textOf(undo2)
|
|
1840
|
-
))
|
|
1841
|
-
/** @type {Element} */
|
|
1842
|
-
textOf(display)
|
|
1843
|
-
)) };
|
|
1901
|
+
));
|
|
1844
1902
|
const ctx = measuring;
|
|
1845
|
-
const measure = (text
|
|
1846
|
-
ctx.font =
|
|
1903
|
+
const measure = (text) => {
|
|
1904
|
+
ctx.font = font;
|
|
1847
1905
|
return ctx.measureText(text).width;
|
|
1848
1906
|
};
|
|
1849
1907
|
const w = (node) => node.getBoundingClientRect().width;
|
|
1850
1908
|
const tw = (node) => node ? node.getBoundingClientRect().width : 0;
|
|
1851
|
-
const segTexts = [...display.querySelectorAll("button > span")];
|
|
1852
|
-
const sepStyle = sep ? view.getComputedStyle(sep) : null;
|
|
1853
1909
|
const chrome = {
|
|
1854
1910
|
text: w(undo2) - tw(textOf(undo2)),
|
|
1855
1911
|
menu: w(menu) - tw(textOf(menu)),
|
|
1856
|
-
display: w(display) - segTexts.reduce((n, s) => n + tw(s), 0),
|
|
1857
|
-
sep: sep && sepStyle ? w(sep) + parseFloat(sepStyle.marginLeft) + parseFloat(sepStyle.marginRight) : 0,
|
|
1858
1912
|
// one more px per part: text widths are fractional, the buttons round them
|
|
1859
1913
|
gap: (parseFloat(view.getComputedStyle(el).columnGap) || 0) + 1
|
|
1860
1914
|
};
|
|
@@ -1892,8 +1946,8 @@ function useOverflow(ref, key, narrow, present, texts) {
|
|
|
1892
1946
|
waiting.current = false;
|
|
1893
1947
|
const em = parseFloat(getComputedStyle(el).fontSize) || 14;
|
|
1894
1948
|
const room = measuredRoom(el, latest.current.texts);
|
|
1895
|
-
const
|
|
1896
|
-
setDecided(room ? overflowHidden(width, narrow,
|
|
1949
|
+
const own = latest.current.present;
|
|
1950
|
+
setDecided(room ? overflowHidden(width, narrow, own, room) : overflowHidden(width / em, narrow, own));
|
|
1897
1951
|
setExtra(0);
|
|
1898
1952
|
setMeasure((m) => m + 1);
|
|
1899
1953
|
};
|
|
@@ -1929,7 +1983,7 @@ function useOverflow(ref, key, narrow, present, texts) {
|
|
|
1929
1983
|
return order.filter((id) => decided.includes(id) || more.includes(id));
|
|
1930
1984
|
}
|
|
1931
1985
|
function Toolbar(props) {
|
|
1932
|
-
const { view, labels, size, canUndo, canRedo, canReset, startEmpty, canNew, onUndo, onRedo, onReset, onNew, loadedView, empty,
|
|
1986
|
+
const { view, labels, size, canUndo, canRedo, canReset, startEmpty, canNew, onUndo, onRedo, onReset, onNew, loadedView, empty, templates, onLoadTemplate, templateActions, onExport, chartReady, onShowFields, share } = props;
|
|
1933
1987
|
const tips = { controls: props.tipsControls, on: props.tipsOn, onOn: props.onTipsOn, canReset: props.canResetTips, onReset: props.onResetTips };
|
|
1934
1988
|
const bar = useRef8(
|
|
1935
1989
|
/** @type {HTMLDivElement | null} */
|
|
@@ -1944,21 +1998,15 @@ function Toolbar(props) {
|
|
|
1944
1998
|
null
|
|
1945
1999
|
);
|
|
1946
2000
|
const [panel, setPanel] = useState8(
|
|
1947
|
-
/** @type {"
|
|
2001
|
+
/** @type {"views" | "data" | null} */
|
|
1948
2002
|
null
|
|
1949
2003
|
);
|
|
1950
2004
|
const data = props.data;
|
|
1951
2005
|
const texts = useMemo5(() => toolbarTexts(labels), [labels]);
|
|
1952
|
-
const plan = props.chartPlan ?? { name: chartTypeOf(view.chart), auto: false };
|
|
1953
|
-
const preset = plan.auto ? "auto" : plan.name;
|
|
1954
|
-
const drawnIcon = CHART_TYPES[plan.name].icon;
|
|
1955
2006
|
const mod = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent) ? "\u2318" : "Ctrl+";
|
|
1956
|
-
const chartTypeText = fill(labels.chartTypeIs, { type: labels.chartTypes[preset] });
|
|
1957
2007
|
const panels = {
|
|
1958
2008
|
// the panels load with the chip menus (menus.js), on demand
|
|
1959
|
-
options: (close) => /* @__PURE__ */ React10.createElement(MenuPanel, { name: "OptionsPanel", loadingText: labels.loadingMenu, props: { view, labels, onTotal, onExpand, onCollapse, close, tips, mod, folding, help: props.help } }),
|
|
1960
2009
|
views: (close) => /* @__PURE__ */ React10.createElement(MenuPanel, { name: "ViewsPanel", loadingText: labels.loadingMenu, props: { templates, labels, onLoad: onLoadTemplate, actions: templateActions, close, share } }),
|
|
1961
|
-
chartType: (close) => /* @__PURE__ */ React10.createElement(MenuPanel, { name: "ChartTypePanel", loadingText: labels.loadingMenu, props: { view, plan, labels, onChart, onDisplay: onChartDisplay, close } }),
|
|
1962
2010
|
data: (close) => data?.panel(close)
|
|
1963
2011
|
};
|
|
1964
2012
|
const loadedMark = (testId) => data?.loaded ? dot(testId, labels.dataLoaded) : null;
|
|
@@ -1974,36 +2022,11 @@ function Toolbar(props) {
|
|
|
1974
2022
|
}, testId: `${prefix}new-report` }, labels.newEmpty)
|
|
1975
2023
|
];
|
|
1976
2024
|
const actions = {
|
|
1977
|
-
chartType: {
|
|
1978
|
-
place: "chart",
|
|
1979
|
-
button: () => /* @__PURE__ */ React10.createElement(MenuButton, { key: "chartType", label: chartTypeText, name: chartTypeText, title: chartTypeText, icon: drawnIcon, text: labels.chartTypes[preset], role: "dialog", testId: "chart-type", popoverClass: "pk-chart-menu" }, panels.chartType),
|
|
1980
|
-
entry: (close) => /* @__PURE__ */ React10.createElement(Option, { key: "chartType", inMenu: true, icon: drawnIcon, onSelect: () => {
|
|
1981
|
-
close();
|
|
1982
|
-
setPanel("chartType");
|
|
1983
|
-
}, testId: "more-chart-type" }, `${chartTypeText}\u2026`)
|
|
1984
|
-
},
|
|
1985
2025
|
startOver: {
|
|
1986
2026
|
place: "history",
|
|
1987
2027
|
button: () => /* @__PURE__ */ React10.createElement(MenuButton, { key: "startOver", label: labels.startOver, icon: "reset", text: labels.startOver, testId: "start-over", arrowOpens: true, off: resetWhy && !canNew ? labels.newAlready : void 0 }, (close) => startOverItems(close, "")),
|
|
1988
2028
|
entry: (close) => startOverItems(close, "more-")
|
|
1989
2029
|
},
|
|
1990
|
-
layout: {
|
|
1991
|
-
place: "end",
|
|
1992
|
-
// a toggle of the zones: the same text, open or folded; aria-pressed says which
|
|
1993
|
-
button: () => /* @__PURE__ */ React10.createElement("button", { key: "layout", type: "button", className: "pk-btn pk-pressable", onClick: onLayout, "aria-pressed": !layoutFolded, "aria-controls": zonesId, title: labels.showLayout, "data-testid": "layout" }, /* @__PURE__ */ React10.createElement(Icon, { name: "layout" }), /* @__PURE__ */ React10.createElement("span", { className: "pk-btn-text" }, labels.layout)),
|
|
1994
|
-
entry: (close) => /* @__PURE__ */ React10.createElement(Option, { key: "layout", inMenu: true, checkbox: true, icon: "layout", checked: !layoutFolded, onSelect: () => {
|
|
1995
|
-
close();
|
|
1996
|
-
onLayout();
|
|
1997
|
-
}, testId: "more-layout" }, labels.layout)
|
|
1998
|
-
},
|
|
1999
|
-
options: {
|
|
2000
|
-
place: "end",
|
|
2001
|
-
button: () => /* @__PURE__ */ React10.createElement(MenuButton, { key: "options", label: labels.options, icon: "sliders", text: labels.options, role: "dialog", align: "end", testId: "options" }, panels.options),
|
|
2002
|
-
entry: (close) => /* @__PURE__ */ React10.createElement(Option, { key: "options", inMenu: true, icon: "sliders", onSelect: () => {
|
|
2003
|
-
close();
|
|
2004
|
-
setPanel("options");
|
|
2005
|
-
}, testId: "more-options" }, `${labels.options}\u2026`)
|
|
2006
|
-
},
|
|
2007
2030
|
...data ? {
|
|
2008
2031
|
data: {
|
|
2009
2032
|
place: (
|
|
@@ -2028,7 +2051,7 @@ function Toolbar(props) {
|
|
|
2028
2051
|
};
|
|
2029
2052
|
const ORDER = Object.keys(actions);
|
|
2030
2053
|
const present = OVERFLOW_ORDER.filter((id) => ORDER.includes(id));
|
|
2031
|
-
const hiddenList = useOverflow(bar, `${labels.lang}:${labels.undo}:${size}:${present.join()}`, size === "narrow", present, texts);
|
|
2054
|
+
const hiddenList = useOverflow(bar, `${labels.lang}:${labels.undo}:${labels.more}:${size}:${present.join()}`, size === "narrow", present, texts);
|
|
2032
2055
|
const hidden = new Set(hiddenList);
|
|
2033
2056
|
if (panel && !hidden.has(panel)) {
|
|
2034
2057
|
setPanel(null);
|
|
@@ -2076,10 +2099,67 @@ function Toolbar(props) {
|
|
|
2076
2099
|
/* @__PURE__ */ React10.createElement(Group, { key: ids[0], menu: true, label: ids[0] === "startOver" ? labels.startOver : void 0 }, ids.map((id) => actions[id].entry(close)))
|
|
2077
2100
|
] : []
|
|
2078
2101
|
);
|
|
2079
|
-
return /* @__PURE__ */ React10.createElement("div", { className: `pk-toolbar${wrap ? " pk-wrap" : ""}`, role: "toolbar", "aria-label": labels.toolbar, ref: bar, "data-overflow": hidden.size }, size === "narrow" ? /* @__PURE__ */ React10.createElement("button", { type: "button", className: "pk-btn", onClick: onShowFields, "data-testid": "show-fields", "data-pk-opener": "fields" }, /* @__PURE__ */ React10.createElement(Icon, { name: "panel" }), /* @__PURE__ */ React10.createElement("span", { className: "pk-btn-text" }, labels.showFields)) : null, /* @__PURE__ */ React10.createElement("
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2102
|
+
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);
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2105
|
+
// src/view-tabs.jsx
|
|
2106
|
+
import React11, { useRef as useRef9 } from "react";
|
|
2107
|
+
var TABS = Object.freeze(
|
|
2108
|
+
/** @type {const} */
|
|
2109
|
+
["table", "chart"]
|
|
2110
|
+
);
|
|
2111
|
+
var tabId = (panelId, display) => `${panelId}-${display}`;
|
|
2112
|
+
function ViewTabs(props) {
|
|
2113
|
+
const { view, labels, panelId, narrow, onDisplay, plan, big } = props;
|
|
2114
|
+
const list = useRef9(
|
|
2115
|
+
/** @type {HTMLDivElement | null} */
|
|
2116
|
+
null
|
|
2117
|
+
);
|
|
2118
|
+
const chart = view.display === "chart";
|
|
2119
|
+
const settings = chart ? labels.chartSettings : labels.tableSettings;
|
|
2120
|
+
const onKeyDown = (e) => {
|
|
2121
|
+
const tabs = (
|
|
2122
|
+
/** @type {HTMLElement[]} */
|
|
2123
|
+
[...list.current?.querySelectorAll('[role="tab"]') ?? []]
|
|
2124
|
+
);
|
|
2125
|
+
const at = tabs.indexOf(
|
|
2126
|
+
/** @type {HTMLElement} */
|
|
2127
|
+
e.target
|
|
2128
|
+
);
|
|
2129
|
+
const next = at < 0 ? null : tabStep(e.key, at, tabs.length);
|
|
2130
|
+
if (next !== null) {
|
|
2131
|
+
e.preventDefault();
|
|
2132
|
+
tabs[next].focus();
|
|
2133
|
+
}
|
|
2134
|
+
};
|
|
2135
|
+
const iconOnly = (name) => narrow ? { "aria-label": name, title: name } : {};
|
|
2136
|
+
return /* @__PURE__ */ React11.createElement("div", { className: "pk-result-head", "data-testid": "view-tabs-row" }, /* @__PURE__ */ React11.createElement("div", { ref: list, className: "pk-tabs", role: "tablist", "aria-label": labels.view, onKeyDown }, TABS.map((d) => /* @__PURE__ */ React11.createElement(
|
|
2137
|
+
"button",
|
|
2138
|
+
{
|
|
2139
|
+
key: d,
|
|
2140
|
+
type: "button",
|
|
2141
|
+
role: "tab",
|
|
2142
|
+
id: tabId(panelId, d),
|
|
2143
|
+
"aria-selected": view.display === d,
|
|
2144
|
+
"aria-controls": panelId,
|
|
2145
|
+
tabIndex: view.display === d ? 0 : -1,
|
|
2146
|
+
className: "pk-tab",
|
|
2147
|
+
onClick: () => view.display === d ? void 0 : onDisplay(d),
|
|
2148
|
+
"data-testid": `show-${d}`
|
|
2149
|
+
},
|
|
2150
|
+
/* @__PURE__ */ React11.createElement(Icon, { name: (
|
|
2151
|
+
/** @type {any} */
|
|
2152
|
+
d === "table" ? "table" : CHART_TYPES[plan.name].icon
|
|
2153
|
+
) }),
|
|
2154
|
+
/* @__PURE__ */ React11.createElement("span", null, d === "table" ? labels.table : labels.chart)
|
|
2155
|
+
))), /* @__PURE__ */ React11.createElement("span", { className: "pk-grow" }), /* @__PURE__ */ React11.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: "view-settings", popoverClass: chart ? "pk-chart-menu" : void 0 }, (close) => chart ? /* @__PURE__ */ React11.createElement(
|
|
2156
|
+
MenuPanel,
|
|
2157
|
+
{
|
|
2158
|
+
name: "ChartSettingsPanel",
|
|
2159
|
+
loadingText: labels.loadingMenu,
|
|
2160
|
+
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 }
|
|
2161
|
+
}
|
|
2162
|
+
) : /* @__PURE__ */ React11.createElement(MenuPanel, { name: "TableSettingsPanel", loadingText: labels.loadingMenu, props: { view, labels, onTotal: props.onTotal, onExpand: props.onExpand, onCollapse: props.onCollapse, close, folding: props.folding } })), /* @__PURE__ */ React11.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", ...iconOnly(big.enlarged ? labels.reduce : labels.enlarge) }, /* @__PURE__ */ React11.createElement(Icon, { name: "enlarge", size: 14 }), narrow ? null : /* @__PURE__ */ React11.createElement("span", { className: "pk-btn-text" }, big.enlarged ? labels.reduce : labels.enlarge)), big.fullOk ? /* @__PURE__ */ React11.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__ */ React11.createElement(Icon, { name: "fullScreen", size: 14 }), narrow ? null : /* @__PURE__ */ React11.createElement("span", { className: "pk-btn-text" }, labels.fullScreen)) : null);
|
|
2083
2163
|
}
|
|
2084
2164
|
|
|
2085
2165
|
// src/use-export.js
|
|
@@ -2321,7 +2401,7 @@ function keptData(key, host) {
|
|
|
2321
2401
|
}
|
|
2322
2402
|
|
|
2323
2403
|
// src/use-big-result.js
|
|
2324
|
-
import { useCallback as useCallback8, useEffect as useEffect9, useRef as
|
|
2404
|
+
import { useCallback as useCallback8, useEffect as useEffect9, useRef as useRef10, useState as useState10, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
2325
2405
|
function fullScreenSupported() {
|
|
2326
2406
|
return typeof document !== "undefined" && Boolean(document.fullscreenEnabled) && typeof HTMLElement !== "undefined" && typeof HTMLElement.prototype.requestFullscreen === "function";
|
|
2327
2407
|
}
|
|
@@ -2361,11 +2441,23 @@ function useBigResult(root) {
|
|
|
2361
2441
|
};
|
|
2362
2442
|
return { enlarged, setEnlarged, toggleEnlarged, full, fullOk, toggleFull };
|
|
2363
2443
|
}
|
|
2364
|
-
function useFitHeight(root, main, grow) {
|
|
2365
|
-
const fit =
|
|
2444
|
+
function useFitHeight(root, main, grow, onOpen) {
|
|
2445
|
+
const fit = useRef10(
|
|
2446
|
+
/** @type {FitState} */
|
|
2447
|
+
{ need: 0, open: 0, grow, folded: null, size: null }
|
|
2448
|
+
);
|
|
2449
|
+
const opened = useRef10(onOpen);
|
|
2450
|
+
const watch = useRef10(
|
|
2451
|
+
/** @type {{ ro: ResizeObserver | null, parts: Set<Element> }} */
|
|
2452
|
+
{ ro: null, parts: /* @__PURE__ */ new Set() }
|
|
2453
|
+
);
|
|
2366
2454
|
useIsoLayoutEffect(() => {
|
|
2455
|
+
opened.current = onOpen;
|
|
2367
2456
|
fit.current.grow = grow;
|
|
2368
|
-
|
|
2457
|
+
watchParts(watch.current, main.current);
|
|
2458
|
+
if (measureFit(root.current, main.current, fit)) {
|
|
2459
|
+
opened.current?.();
|
|
2460
|
+
}
|
|
2369
2461
|
});
|
|
2370
2462
|
useIsoLayoutEffect(() => {
|
|
2371
2463
|
const el = root.current;
|
|
@@ -2375,26 +2467,72 @@ function useFitHeight(root, main, grow) {
|
|
|
2375
2467
|
let frame = 0;
|
|
2376
2468
|
const ro = new ResizeObserver(() => {
|
|
2377
2469
|
cancelAnimationFrame(frame);
|
|
2378
|
-
frame = requestAnimationFrame(() =>
|
|
2470
|
+
frame = requestAnimationFrame(() => {
|
|
2471
|
+
if (measureFit(root.current, main.current, fit)) {
|
|
2472
|
+
opened.current?.();
|
|
2473
|
+
}
|
|
2474
|
+
});
|
|
2379
2475
|
});
|
|
2380
2476
|
ro.observe(el);
|
|
2477
|
+
const w = watch.current;
|
|
2478
|
+
w.ro = ro;
|
|
2479
|
+
watchParts(w, main.current);
|
|
2381
2480
|
return () => {
|
|
2382
2481
|
cancelAnimationFrame(frame);
|
|
2383
2482
|
ro.disconnect();
|
|
2483
|
+
w.ro = null;
|
|
2484
|
+
w.parts = /* @__PURE__ */ new Set();
|
|
2384
2485
|
};
|
|
2385
2486
|
}, [root, main]);
|
|
2386
2487
|
return fit;
|
|
2387
2488
|
}
|
|
2489
|
+
function watchParts(w, m) {
|
|
2490
|
+
if (!w.ro || !m) {
|
|
2491
|
+
return;
|
|
2492
|
+
}
|
|
2493
|
+
const now = new Set(m.children);
|
|
2494
|
+
for (const part of w.parts) {
|
|
2495
|
+
if (!now.has(part)) {
|
|
2496
|
+
w.ro.unobserve(part);
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
for (const part of now) {
|
|
2500
|
+
if (!w.parts.has(part)) {
|
|
2501
|
+
w.ro.observe(part);
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
w.parts = now;
|
|
2505
|
+
}
|
|
2388
2506
|
function measureFit(el, m, fit) {
|
|
2389
2507
|
const result = m?.querySelector(":scope > .pk-result");
|
|
2390
2508
|
if (!el || !m || !(result instanceof HTMLElement)) {
|
|
2391
|
-
return;
|
|
2509
|
+
return false;
|
|
2392
2510
|
}
|
|
2393
2511
|
const least = parseFloat(el.ownerDocument.defaultView?.getComputedStyle(result).getPropertyValue("--pk-result-least") ?? "") || 0;
|
|
2394
2512
|
const needMain = m.scrollHeight - result.offsetHeight + least;
|
|
2395
2513
|
const need = Math.ceil(el.offsetHeight - m.clientHeight + needMain);
|
|
2396
|
-
|
|
2397
|
-
|
|
2514
|
+
const f = fit.current;
|
|
2515
|
+
const size = el.getAttribute("data-pk-size");
|
|
2516
|
+
let changed = false;
|
|
2517
|
+
if (size !== f.size) {
|
|
2518
|
+
changed = f.open > 0;
|
|
2519
|
+
f.size = size;
|
|
2520
|
+
f.folded = null;
|
|
2521
|
+
f.open = 0;
|
|
2522
|
+
}
|
|
2523
|
+
let open = f.open;
|
|
2524
|
+
if (el.hasAttribute("data-pk-enlarged")) {
|
|
2525
|
+
f.folded = null;
|
|
2526
|
+
} else if (!el.hasAttribute("data-pk-layout")) {
|
|
2527
|
+
f.folded = null;
|
|
2528
|
+
open = need;
|
|
2529
|
+
} else if (f.open > 0) {
|
|
2530
|
+
f.folded ??= { need, open: f.open };
|
|
2531
|
+
open = f.folded.open - (f.folded.need - need);
|
|
2532
|
+
}
|
|
2533
|
+
if (Math.abs(open - f.open) > 1) {
|
|
2534
|
+
f.open = open;
|
|
2535
|
+
changed = true;
|
|
2398
2536
|
}
|
|
2399
2537
|
if (!fit.current.grow) {
|
|
2400
2538
|
fit.current.need = 0;
|
|
@@ -2403,10 +2541,11 @@ function measureFit(el, m, fit) {
|
|
|
2403
2541
|
fit.current.need = need;
|
|
2404
2542
|
el.style.minHeight = `${need}px`;
|
|
2405
2543
|
}
|
|
2544
|
+
return changed;
|
|
2406
2545
|
}
|
|
2407
2546
|
|
|
2408
2547
|
// src/zones.jsx
|
|
2409
|
-
import
|
|
2548
|
+
import React12, { useCallback as useCallback9, useEffect as useEffect10, useId as useId4, useMemo as useMemo7, useRef as useRef11, useState as useState11 } from "react";
|
|
2410
2549
|
import { fieldItems, fieldLabel as fieldLabel4 } from "pivotkit-core";
|
|
2411
2550
|
function fieldState(view, field, encoded, locale, labels, sourceType) {
|
|
2412
2551
|
const items = filtersOf(view, field, ["in"]).filter((f) => !isEmptyPick(f));
|
|
@@ -2450,47 +2589,48 @@ function Badges({ state, view, labels, locale }) {
|
|
|
2450
2589
|
if (state.summary) {
|
|
2451
2590
|
const text = fill(labels.filterSummary, { shown: state.summary.shown.toLocaleString(locale), total: state.summary.total.toLocaleString(locale) });
|
|
2452
2591
|
parts.push(
|
|
2453
|
-
/* @__PURE__ */
|
|
2592
|
+
/* @__PURE__ */ React12.createElement("span", { key: "filter", className: "pk-chip-badge pk-badge-text", "aria-hidden": "true" }, /* @__PURE__ */ React12.createElement(Icon, { name: "filter", size: 12 }), text)
|
|
2454
2593
|
);
|
|
2455
2594
|
}
|
|
2456
2595
|
if (state.rules.length) {
|
|
2457
2596
|
const more = state.rules.length - 1;
|
|
2458
2597
|
parts.push(
|
|
2459
|
-
/* @__PURE__ */
|
|
2598
|
+
/* @__PURE__ */ React12.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__ */ React12.createElement(Icon, { name: "filter", size: 12 }), /* @__PURE__ */ React12.createElement("span", { className: "pk-badge-cut" }, state.rules[0]), more ? /* @__PURE__ */ React12.createElement("span", null, ` +${more.toLocaleString(locale)}`) : null)
|
|
2460
2599
|
);
|
|
2461
2600
|
}
|
|
2462
2601
|
if (state.top) {
|
|
2463
2602
|
const text = fill(state.top.bottom ? labels.bottomBadge : labels.topBadge, { count: state.top.count.toLocaleString(locale) });
|
|
2464
2603
|
parts.push(
|
|
2465
|
-
/* @__PURE__ */
|
|
2604
|
+
/* @__PURE__ */ React12.createElement("span", { key: "top", className: "pk-chip-badge pk-badge-text", "data-testid": "top-badge", "aria-hidden": "true" }, /* @__PURE__ */ React12.createElement(Icon, { name: "top", size: 12 }), text)
|
|
2466
2605
|
);
|
|
2467
2606
|
}
|
|
2468
2607
|
if (state.condition) {
|
|
2469
2608
|
const text = valueConditionText(view, state.condition, labels, locale);
|
|
2470
2609
|
parts.push(
|
|
2471
|
-
/* @__PURE__ */
|
|
2610
|
+
/* @__PURE__ */ React12.createElement("span", { key: "condition", className: "pk-chip-badge pk-badge-text pk-badge-condition", "data-testid": "condition-badge", "aria-hidden": "true" }, /* @__PURE__ */ React12.createElement(Icon, { name: "filter", size: 12 }), /* @__PURE__ */ React12.createElement("span", { className: "pk-badge-cut" }, text))
|
|
2472
2611
|
);
|
|
2473
2612
|
}
|
|
2474
2613
|
if (state.sort) {
|
|
2475
2614
|
const desc = state.sort.order === "desc";
|
|
2476
|
-
parts.push(/* @__PURE__ */
|
|
2615
|
+
parts.push(/* @__PURE__ */ React12.createElement(Icon, { key: "sort", name: desc ? "sortDesc" : "sortAsc", size: 12, className: "pk-chip-badge" }));
|
|
2477
2616
|
}
|
|
2478
|
-
return parts.length ? /* @__PURE__ */
|
|
2617
|
+
return parts.length ? /* @__PURE__ */ React12.createElement(React12.Fragment, null, parts) : null;
|
|
2479
2618
|
}
|
|
2480
|
-
function Chip({ id, zone, index, count, field, text, typeName, view, types, labels, commit, onRemove, state, locale, defaultsOf, earlier, rangeOf, info, showInfo, encoded }) {
|
|
2619
|
+
function Chip({ id, zone, index, count, field, text, title, typeName, view, types, labels, commit, onRemove, state, locale, defaultsOf, earlier, rangeOf, info, showInfo, encoded }) {
|
|
2481
2620
|
const { setNodeRef, isDragging, style, itemProps, handleProps } = useChip(id, { kind: "chip", zone, index, count, field, label: text, type: typeName });
|
|
2482
|
-
const badges = state ? /* @__PURE__ */
|
|
2621
|
+
const badges = state ? /* @__PURE__ */ React12.createElement(Badges, { state, view, labels, locale }) : null;
|
|
2483
2622
|
const words = stateWords(state, view, labels, locale);
|
|
2484
|
-
const
|
|
2623
|
+
const full = title ?? text;
|
|
2624
|
+
const name = words ? `${full}, ${words}` : title;
|
|
2485
2625
|
const remove = () => onRemove(zone, index, text);
|
|
2486
|
-
return /* @__PURE__ */
|
|
2626
|
+
return /* @__PURE__ */ React12.createElement("li", { ref: setNodeRef, style, className: `pk-chip pk-chip-${zone}${isDragging ? " pk-dragging" : ""}`, ...itemProps, "data-chip": text }, /* @__PURE__ */ React12.createElement("span", { className: "pk-handle", ...handleProps, "aria-label": fill(labels.dragHandle, { field: text }) }, /* @__PURE__ */ React12.createElement(Icon, { name: "grip", size: 16 })), /* @__PURE__ */ React12.createElement("span", { className: `pk-type pk-type-${typeName}`, "aria-hidden": "true" }, /* @__PURE__ */ React12.createElement(Icon, { name: (
|
|
2487
2627
|
/** @type {any} */
|
|
2488
2628
|
TYPE_ICON[typeName] ?? "text"
|
|
2489
|
-
), size: 13 })), /* @__PURE__ */
|
|
2629
|
+
), size: 13 })), /* @__PURE__ */ React12.createElement(
|
|
2490
2630
|
MenuButton,
|
|
2491
2631
|
{
|
|
2492
2632
|
label: fill(labels.fieldMenu, { field: text }),
|
|
2493
|
-
text: /* @__PURE__ */
|
|
2633
|
+
text: /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement("span", { className: "pk-chip-name" }, text), badges),
|
|
2494
2634
|
className: "pk-chip-label",
|
|
2495
2635
|
name,
|
|
2496
2636
|
title: name ?? text,
|
|
@@ -2499,10 +2639,14 @@ function Chip({ id, zone, index, count, field, text, typeName, view, types, labe
|
|
|
2499
2639
|
fill: true,
|
|
2500
2640
|
testId: `chip-menu-${text}`
|
|
2501
2641
|
},
|
|
2502
|
-
(close) => zone === "values" ? /* @__PURE__ */
|
|
2503
|
-
), info && showInfo ? /* @__PURE__ */
|
|
2642
|
+
(close) => zone === "values" ? /* @__PURE__ */ React12.createElement(MenuPanel, { name: "ValueMenu", loadingText: labels.loadingMenu, props: { view, index, types, labels, commit, close, onRemove: remove, defaultsOf, info, locale, earlier } }) : zone === "filters" ? /* @__PURE__ */ React12.createElement(MenuPanel, { name: "FilterMenu", loadingText: labels.loadingMenu, props: { view, index, field, types, labels, commit, close, onRemove: remove, locale, info, state, encoded } }) : /* @__PURE__ */ React12.createElement(MenuPanel, { name: "AxisMenu", loadingText: labels.loadingMenu, props: { view, zone, index, field, types, labels, commit, close, onRemove: remove, defaultsOf, rangeOf, locale, info, state, encoded } })
|
|
2643
|
+
), info && showInfo ? /* @__PURE__ */ React12.createElement(InfoButton, { info, name: fieldLabel4(sourceOf(view, field), labels.core), labels, className: "pk-chip-info" }) : null, /* @__PURE__ */ React12.createElement("button", { type: "button", className: "pk-chip-x", onClick: remove, "aria-label": fill(labels.removeField, { field: text }), title: fill(labels.removeField, { field: text }) }, /* @__PURE__ */ React12.createElement(Icon, { name: "x", size: 14 })));
|
|
2504
2644
|
}
|
|
2505
|
-
function
|
|
2645
|
+
function AddButton({ zone, labels, menu }) {
|
|
2646
|
+
const name = fill(labels.addFieldTo, { zone: labels.zones[zone] });
|
|
2647
|
+
return /* @__PURE__ */ React12.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__ */ React12.createElement(MenuPanel, { name: "AddMenu", loadingText: labels.loadingMenu, props: { ...menu, labels, zone, close } }));
|
|
2648
|
+
}
|
|
2649
|
+
function Zone({ zone, entries, labels, children, explain, add }) {
|
|
2506
2650
|
const count = entries.length;
|
|
2507
2651
|
const { setNodeRef, isOver } = useDropTarget(`zone:${zone}`, { kind: "zone", zone, count });
|
|
2508
2652
|
const active = useActiveDrag();
|
|
@@ -2522,11 +2666,13 @@ function Zone({ zone, entries, labels, children, action, explain }) {
|
|
|
2522
2666
|
const t = setTimeout(() => setFlash(false), 600);
|
|
2523
2667
|
return () => clearTimeout(t);
|
|
2524
2668
|
}, [flash]);
|
|
2525
|
-
return /* @__PURE__ */
|
|
2669
|
+
return /* @__PURE__ */ React12.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__ */ React12.createElement("div", { className: "pk-zone-head" }, /* @__PURE__ */ React12.createElement("h3", { className: "pk-zone-title" }, /* @__PURE__ */ React12.createElement(Icon, { name: (
|
|
2526
2670
|
/** @type {any} */
|
|
2527
2671
|
ZONE_ICON[zone]
|
|
2528
|
-
), size: 14 }), labels.zones[zone]), explain ? /* @__PURE__ */
|
|
2672
|
+
), size: 14 }), labels.zones[zone]), explain ? /* @__PURE__ */ React12.createElement(InfoButton, { info: { description: labels.zoneInfo[zone] }, name: labels.zones[zone], labels, className: "pk-zone-info", testId: `zone-info-${zone}` }) : null, add ? /* @__PURE__ */ React12.createElement(AddButton, { zone, labels, menu: add }) : null), /* @__PURE__ */ React12.createElement(ChipList, { ids: entries.map((e) => e.id) }, /* @__PURE__ */ React12.createElement("ul", { className: "pk-chips" }, children, count === 0 ? /* @__PURE__ */ React12.createElement("li", { className: "pk-zone-hint" }, labels.zoneHints[zone]) : null)));
|
|
2529
2673
|
}
|
|
2674
|
+
var SAY_AFTER = 100;
|
|
2675
|
+
var SAY_FOR = 8e3;
|
|
2530
2676
|
function zoneEntries(view, types, labels) {
|
|
2531
2677
|
const typeOf = (f) => types.get(String(sourceOf(view, f)).toLowerCase()) ?? "string";
|
|
2532
2678
|
const seen = /* @__PURE__ */ new Map();
|
|
@@ -2536,24 +2682,44 @@ function zoneEntries(view, types, labels) {
|
|
|
2536
2682
|
filters: filterZoneFields(view).map((f, i) => ({ id: `chip:filters:${f}`, field: f, text: text(f), type: typeOf(f), index: i })),
|
|
2537
2683
|
cols: axis("cols"),
|
|
2538
2684
|
rows: axis("rows"),
|
|
2539
|
-
values: view.values.map((
|
|
2685
|
+
values: valueLabels(view.values, labels).map((text2, i) => {
|
|
2686
|
+
const v = view.values[i];
|
|
2540
2687
|
const key = `${v.agg}:${v.field}`;
|
|
2541
2688
|
seen.set(key, (seen.get(key) ?? 0) + 1);
|
|
2542
|
-
return { id: `chip:values:${key}:${seen.get(key)}`, field: v.field, text:
|
|
2689
|
+
return { id: `chip:values:${key}:${seen.get(key)}`, field: v.field, text: text2, type: v.field ? typeOf(v.field) : "number", index: i };
|
|
2543
2690
|
})
|
|
2544
2691
|
};
|
|
2545
2692
|
}
|
|
2546
|
-
function
|
|
2693
|
+
function SectionHead({ entries, labels, id, open, onFold, onSwap, canSwap, buttonRef, explain }) {
|
|
2694
|
+
const own = useId4();
|
|
2547
2695
|
const parts = layoutSummary(entries, labels);
|
|
2548
2696
|
const text = parts.length ? parts.map((p) => `${p.title}: ${p.fields}`).join(" \xB7 ") : labels.layoutEmpty;
|
|
2549
|
-
return /* @__PURE__ */
|
|
2697
|
+
return /* @__PURE__ */ React12.createElement("div", { className: "pk-section-row" }, /* @__PURE__ */ React12.createElement(
|
|
2698
|
+
"button",
|
|
2699
|
+
{
|
|
2700
|
+
ref: buttonRef,
|
|
2701
|
+
type: "button",
|
|
2702
|
+
className: "pk-section-fold",
|
|
2703
|
+
"aria-expanded": open,
|
|
2704
|
+
"aria-controls": open ? id : void 0,
|
|
2705
|
+
"aria-labelledby": `${own}-t`,
|
|
2706
|
+
"aria-describedby": open ? void 0 : `${own}-s`,
|
|
2707
|
+
title: open ? void 0 : text,
|
|
2708
|
+
onClick: onFold,
|
|
2709
|
+
"data-testid": "layout-summary"
|
|
2710
|
+
},
|
|
2711
|
+
/* @__PURE__ */ React12.createElement(Icon, { name: "chevronRight", className: "pk-section-chevron" }),
|
|
2712
|
+
/* @__PURE__ */ React12.createElement("span", { id: `${own}-t`, className: "pk-section-heading" }, labels.zonesTitle)
|
|
2713
|
+
), explain ? /* @__PURE__ */ React12.createElement(InfoButton, { info: { description: labels.zonesHint }, name: labels.zonesTitle, labels, className: "pk-section-info", testId: "zones-info" }) : null, open ? /* @__PURE__ */ React12.createElement("span", { className: "pk-grow" }) : (
|
|
2714
|
+
// the button's description and a larger target for the pointer; the keys use the button
|
|
2715
|
+
/* @__PURE__ */ React12.createElement("span", { id: `${own}-s`, className: "pk-section-sub", onClick: onFold, "data-testid": "zones-sub" }, parts.length ? parts.map((p, i) => /* @__PURE__ */ React12.createElement(React12.Fragment, { key: p.zone }, i ? " \xB7 " : null, /* @__PURE__ */ React12.createElement("span", { className: "pk-zones-summary-zone" }, p.title, ":"), " ", p.fields)) : labels.layoutEmpty)
|
|
2716
|
+
), /* @__PURE__ */ React12.createElement("button", { type: "button", className: "pk-btn pk-small-btn pk-swap", onClick: onSwap, disabled: !canSwap, "data-testid": "swap", title: labels.swap }, /* @__PURE__ */ React12.createElement(Icon, { name: "swap", size: 14 }), /* @__PURE__ */ React12.createElement("span", { className: "pk-btn-text" }, labels.swap)));
|
|
2550
2717
|
}
|
|
2551
|
-
function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap, id, folded,
|
|
2718
|
+
function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap, id, folded, onFold, defaultsOf, infoOf, titleOf, explain = false, showInfo = true, adding }) {
|
|
2552
2719
|
const entries = useMemo7(() => zoneEntries(view, types, labels), [view, types, labels]);
|
|
2553
2720
|
const dragging = Boolean(useActiveDrag());
|
|
2554
|
-
const
|
|
2555
|
-
const
|
|
2556
|
-
const summary = useRef10(
|
|
2721
|
+
const focusInside = useRef11(false);
|
|
2722
|
+
const summary = useRef11(
|
|
2557
2723
|
/** @type {HTMLButtonElement | null} */
|
|
2558
2724
|
null
|
|
2559
2725
|
);
|
|
@@ -2567,11 +2733,11 @@ function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap,
|
|
|
2567
2733
|
return map;
|
|
2568
2734
|
}, [entries, view, encoded, locale, labels]);
|
|
2569
2735
|
const rangeOf = useCallback9((field) => numberRange(encoded, field), [encoded]);
|
|
2570
|
-
const root =
|
|
2736
|
+
const root = useRef11(
|
|
2571
2737
|
/** @type {HTMLDivElement | null} */
|
|
2572
2738
|
null
|
|
2573
2739
|
);
|
|
2574
|
-
const focusAfter =
|
|
2740
|
+
const focusAfter = useRef11(
|
|
2575
2741
|
/** @type {{ zone: string, index: number } | null} */
|
|
2576
2742
|
null
|
|
2577
2743
|
);
|
|
@@ -2593,32 +2759,57 @@ function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap,
|
|
|
2593
2759
|
);
|
|
2594
2760
|
target?.focus({ preventScroll: true });
|
|
2595
2761
|
});
|
|
2762
|
+
const added = useRef11(
|
|
2763
|
+
/** @type {{ zone: string, from: string | null, ids: Set<string> } | null} */
|
|
2764
|
+
null
|
|
2765
|
+
);
|
|
2766
|
+
const [said, setSaid] = useState11("");
|
|
2767
|
+
const sayTimers = useRef11(
|
|
2768
|
+
/** @type {ReturnType<typeof setTimeout>[]} */
|
|
2769
|
+
[]
|
|
2770
|
+
);
|
|
2771
|
+
useEffect10(() => () => sayTimers.current.forEach(clearTimeout), []);
|
|
2596
2772
|
useEffect10(() => {
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2773
|
+
const at = added.current;
|
|
2774
|
+
if (!at) {
|
|
2775
|
+
return;
|
|
2776
|
+
}
|
|
2777
|
+
added.current = null;
|
|
2778
|
+
const fresh = entries[at.zone].find((e) => !at.ids.has(e.id));
|
|
2779
|
+
if (!fresh) {
|
|
2780
|
+
return;
|
|
2600
2781
|
}
|
|
2782
|
+
const chip = root.current?.querySelectorAll(`[data-zone="${at.zone}"] .pk-chip`)[fresh.index];
|
|
2783
|
+
chip?.querySelector(".pk-chip-label")?.focus({ preventScroll: true });
|
|
2784
|
+
const text = fill(at.from ? labels.movedFrom : labels.steps.added, { field: fresh.text, zone: labels.zones[at.zone], from: at.from ? labels.zones[at.from] : "" });
|
|
2785
|
+
sayTimers.current.forEach(clearTimeout);
|
|
2786
|
+
setSaid("");
|
|
2787
|
+
sayTimers.current = [setTimeout(() => setSaid(text), SAY_AFTER), setTimeout(() => setSaid(""), SAY_FOR)];
|
|
2788
|
+
}, [entries, labels]);
|
|
2789
|
+
const addMenu = useMemo7(
|
|
2790
|
+
() => adding ? {
|
|
2791
|
+
...adding,
|
|
2792
|
+
view,
|
|
2793
|
+
commit,
|
|
2794
|
+
encoded,
|
|
2795
|
+
locale,
|
|
2796
|
+
onAdded: (zone) => (from, run) => {
|
|
2797
|
+
added.current = { zone, from, ids: new Set(entries[zone].map((e) => e.id)) };
|
|
2798
|
+
if (!run()) {
|
|
2799
|
+
added.current = null;
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
} : null,
|
|
2803
|
+
[adding, view, commit, encoded, locale, entries]
|
|
2804
|
+
);
|
|
2805
|
+
useEffect10(() => {
|
|
2601
2806
|
if (folded && focusInside.current) {
|
|
2602
2807
|
focusInside.current = false;
|
|
2603
2808
|
summary.current?.focus({ preventScroll: true });
|
|
2604
2809
|
}
|
|
2605
2810
|
}, [folded]);
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
ZoneSummary,
|
|
2609
|
-
{
|
|
2610
|
-
entries,
|
|
2611
|
-
labels,
|
|
2612
|
-
id,
|
|
2613
|
-
buttonRef: summary,
|
|
2614
|
-
onShow: () => {
|
|
2615
|
-
showing.current = true;
|
|
2616
|
-
onShow();
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
|
-
);
|
|
2620
|
-
}
|
|
2621
|
-
return /* @__PURE__ */ React11.createElement(
|
|
2811
|
+
const open = !folded || dragging;
|
|
2812
|
+
return /* @__PURE__ */ React12.createElement("div", { className: "pk-zone-section", "data-pk-open": open ? "" : void 0, "data-testid": "zone-section" }, /* @__PURE__ */ React12.createElement(SectionHead, { entries, labels, id, open, onFold, onSwap, canSwap: view.rows.length + view.cols.length > 0, buttonRef: summary, explain }), /* @__PURE__ */ React12.createElement("span", { className: "pk-sr", role: "status", "data-testid": "zones-status" }, said), open ? /* @__PURE__ */ React12.createElement(
|
|
2622
2813
|
"div",
|
|
2623
2814
|
{
|
|
2624
2815
|
className: "pk-zones",
|
|
@@ -2636,7 +2827,7 @@ function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap,
|
|
|
2636
2827
|
}
|
|
2637
2828
|
}
|
|
2638
2829
|
},
|
|
2639
|
-
ZONES.map((zone) => /* @__PURE__ */
|
|
2830
|
+
ZONES.map((zone) => /* @__PURE__ */ React12.createElement(
|
|
2640
2831
|
Zone,
|
|
2641
2832
|
{
|
|
2642
2833
|
key: zone,
|
|
@@ -2644,12 +2835,9 @@ function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap,
|
|
|
2644
2835
|
entries: entries[zone],
|
|
2645
2836
|
labels,
|
|
2646
2837
|
explain,
|
|
2647
|
-
|
|
2648
|
-
// the text goes when the zone is too narrow (styles.css): the title keeps it as a tooltip
|
|
2649
|
-
/* @__PURE__ */ React11.createElement("button", { type: "button", className: "pk-link pk-swap", onClick: onSwap, disabled: view.rows.length + view.cols.length === 0, "data-testid": "swap", title: labels.swap }, /* @__PURE__ */ React11.createElement(Icon, { name: "swap", size: 14 }), /* @__PURE__ */ React11.createElement("span", { className: "pk-btn-text" }, labels.swap))
|
|
2650
|
-
) : null
|
|
2838
|
+
add: addMenu ? { ...addMenu, onAdded: addMenu.onAdded(zone) } : null
|
|
2651
2839
|
},
|
|
2652
|
-
entries[zone].map((e) => /* @__PURE__ */
|
|
2840
|
+
entries[zone].map((e) => /* @__PURE__ */ React12.createElement(
|
|
2653
2841
|
Chip,
|
|
2654
2842
|
{
|
|
2655
2843
|
key: e.id,
|
|
@@ -2659,6 +2847,7 @@ function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap,
|
|
|
2659
2847
|
count: entries[zone].length,
|
|
2660
2848
|
field: e.field,
|
|
2661
2849
|
text: e.text,
|
|
2850
|
+
title: e.field ? titleOf?.(e.field) : void 0,
|
|
2662
2851
|
typeName: e.type,
|
|
2663
2852
|
view,
|
|
2664
2853
|
types,
|
|
@@ -2676,7 +2865,7 @@ function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap,
|
|
|
2676
2865
|
}
|
|
2677
2866
|
))
|
|
2678
2867
|
))
|
|
2679
|
-
);
|
|
2868
|
+
) : null);
|
|
2680
2869
|
}
|
|
2681
2870
|
|
|
2682
2871
|
// src/PivotReport.jsx
|
|
@@ -2687,6 +2876,7 @@ function sizeOf(width) {
|
|
|
2687
2876
|
var COMPACT_HEIGHT = 600;
|
|
2688
2877
|
var COMPACT_HEIGHT_NARROW = 820;
|
|
2689
2878
|
var compactAt = (size, height) => height < (size === "narrow" ? COMPACT_HEIGHT_NARROW : COMPACT_HEIGHT);
|
|
2879
|
+
var zonesStart = (zones) => zones === "folded" ? true : zones === "open" ? false : null;
|
|
2690
2880
|
var layerOpen = (layer) => Boolean(layer && [...layer.children].some((c) => !c.classList.contains("pk-origin")));
|
|
2691
2881
|
function measured(name, fn) {
|
|
2692
2882
|
const t0 = typeof performance !== "undefined" ? performance.now() : 0;
|
|
@@ -2764,19 +2954,19 @@ function PivotReport(props) {
|
|
|
2764
2954
|
setStarted(true);
|
|
2765
2955
|
}
|
|
2766
2956
|
if (waiting && !started) {
|
|
2767
|
-
return /* @__PURE__ */
|
|
2957
|
+
return /* @__PURE__ */ React13.createElement(WaitingReport, { ...props });
|
|
2768
2958
|
}
|
|
2769
|
-
return /* @__PURE__ */
|
|
2959
|
+
return /* @__PURE__ */ React13.createElement(Report, { ...props });
|
|
2770
2960
|
}
|
|
2771
2961
|
function WaitingReport({ locale = "en-US", labels: customLabels, theme = "auto", height = 640, className, label }) {
|
|
2772
|
-
const root =
|
|
2962
|
+
const root = useRef12(
|
|
2773
2963
|
/** @type {HTMLDivElement | null} */
|
|
2774
2964
|
null
|
|
2775
2965
|
);
|
|
2776
2966
|
const labelsKey = JSON.stringify(customLabels ?? null);
|
|
2777
2967
|
const labels = useMemo8(() => resolveLabels(locale, JSON.parse(labelsKey)), [locale, labelsKey]);
|
|
2778
2968
|
const themeName = useResolvedTheme(theme, root);
|
|
2779
|
-
return /* @__PURE__ */
|
|
2969
|
+
return /* @__PURE__ */ React13.createElement("div", { ref: root, className: `pk-root${className ? ` ${className}` : ""}`, "data-pk-theme": themeName, lang: labels.lang, role: "region", "aria-label": label || labels.report, style: { height } }, /* @__PURE__ */ React13.createElement(Skeleton, { full: true, text: labels.loadingReport }));
|
|
2780
2970
|
}
|
|
2781
2971
|
function keyOfHostView(view) {
|
|
2782
2972
|
try {
|
|
@@ -2787,7 +2977,7 @@ function keyOfHostView(view) {
|
|
|
2787
2977
|
}
|
|
2788
2978
|
var staysTheSame = () => () => void 0;
|
|
2789
2979
|
function EmptyState({ labels, templates, onTemplate, onLoad, noData }) {
|
|
2790
|
-
return /* @__PURE__ */
|
|
2980
|
+
return /* @__PURE__ */ React13.createElement("div", { className: "pk-empty", "data-testid": "empty-state" }, /* @__PURE__ */ React13.createElement("div", { className: "pk-empty-art", "aria-hidden": "true" }, /* @__PURE__ */ React13.createElement("span", { className: "pk-empty-chip pk-c1" }), /* @__PURE__ */ React13.createElement("span", { className: "pk-empty-chip pk-c2" }), /* @__PURE__ */ React13.createElement("span", { className: "pk-empty-chip pk-c3" })), /* @__PURE__ */ React13.createElement("h2", null, noData ? labels.emptyNoData : labels.emptyTitle), noData ? null : /* @__PURE__ */ React13.createElement("ol", { className: "pk-steps" }, labels.emptySteps.map((s, i) => /* @__PURE__ */ React13.createElement("li", { key: i }, /* @__PURE__ */ React13.createElement("span", { className: "pk-step-n", "aria-hidden": "true" }, i + 1), /* @__PURE__ */ React13.createElement("span", null, s)))), onLoad ? /* @__PURE__ */ React13.createElement("div", { className: "pk-drop-zone", "data-testid": "empty-drop" }, /* @__PURE__ */ React13.createElement("p", null, noData ? labels.emptyDrop : labels.emptyLoad), /* @__PURE__ */ React13.createElement("button", { type: "button", className: "pk-btn", onClick: onLoad, "data-testid": "empty-load" }, /* @__PURE__ */ React13.createElement(Icon, { name: "upload" }), /* @__PURE__ */ React13.createElement("span", { className: "pk-btn-text" }, labels.loadData))) : null, templates.length ? /* @__PURE__ */ React13.createElement("div", { className: "pk-empty-actions" }, templates.slice(0, 3).map((t, i) => /* @__PURE__ */ React13.createElement("button", { key: `${i}:${t.name}`, type: "button", className: "pk-btn", onClick: () => onTemplate(t) }, /* @__PURE__ */ React13.createElement(Icon, { name: "sparkle" }), /* @__PURE__ */ React13.createElement("span", { className: "pk-btn-text" }, fill(labels.tryView, { name: t.name }))))) : null);
|
|
2791
2981
|
}
|
|
2792
2982
|
function Report(props) {
|
|
2793
2983
|
const {
|
|
@@ -2818,12 +3008,14 @@ function Report(props) {
|
|
|
2818
3008
|
fieldDefaults,
|
|
2819
3009
|
onExport,
|
|
2820
3010
|
exportData = false,
|
|
3011
|
+
drillDownExport = false,
|
|
2821
3012
|
label,
|
|
2822
3013
|
tips: tipsProp = "on",
|
|
2823
3014
|
storageKey,
|
|
2824
3015
|
dismissedTips,
|
|
2825
3016
|
onTipDismiss,
|
|
2826
3017
|
chartOptions,
|
|
3018
|
+
colorMap,
|
|
2827
3019
|
shareLink,
|
|
2828
3020
|
persistView,
|
|
2829
3021
|
fieldInfo: fieldInfoProp,
|
|
@@ -2835,6 +3027,7 @@ function Report(props) {
|
|
|
2835
3027
|
schemaUrl,
|
|
2836
3028
|
grow: growProp,
|
|
2837
3029
|
fieldList,
|
|
3030
|
+
zones: zonesProp,
|
|
2838
3031
|
loading: loading2 = false,
|
|
2839
3032
|
allowImport = false,
|
|
2840
3033
|
plugins: pluginsProp,
|
|
@@ -2848,14 +3041,14 @@ function Report(props) {
|
|
|
2848
3041
|
/** @type {import("./import-host.jsx").ImportJob | null} */
|
|
2849
3042
|
null
|
|
2850
3043
|
);
|
|
2851
|
-
const afterSheet =
|
|
3044
|
+
const afterSheet = useRef12(
|
|
2852
3045
|
/** @type {(() => void) | null} */
|
|
2853
3046
|
null
|
|
2854
3047
|
);
|
|
2855
3048
|
const [dragging, setDragging] = useState12(false);
|
|
2856
|
-
const dragDepth =
|
|
3049
|
+
const dragDepth = useRef12(0);
|
|
2857
3050
|
const [importMod, setImportMod] = useState12(importNow);
|
|
2858
|
-
const fileInput =
|
|
3051
|
+
const fileInput = useRef12(
|
|
2859
3052
|
/** @type {HTMLInputElement | null} */
|
|
2860
3053
|
null
|
|
2861
3054
|
);
|
|
@@ -2869,7 +3062,7 @@ function Report(props) {
|
|
|
2869
3062
|
const hostLimits = useMemo8(() => JSON.parse(limitsKey) ?? void 0, [limitsKey]);
|
|
2870
3063
|
const importLimitsKey = JSON.stringify(importLimitsProp ?? null);
|
|
2871
3064
|
const fileLimits = useMemo8(() => importLimitsOf(hostLimits, JSON.parse(importLimitsKey)), [hostLimits, importLimitsKey]);
|
|
2872
|
-
const root =
|
|
3065
|
+
const root = useRef12(
|
|
2873
3066
|
/** @type {HTMLDivElement | null} */
|
|
2874
3067
|
null
|
|
2875
3068
|
);
|
|
@@ -2883,11 +3076,17 @@ function Report(props) {
|
|
|
2883
3076
|
const [short, setShort] = useState12(false);
|
|
2884
3077
|
const [folded, setFolded] = useState12(
|
|
2885
3078
|
/** @type {boolean | null} */
|
|
2886
|
-
|
|
3079
|
+
zonesStart(zonesProp)
|
|
2887
3080
|
);
|
|
2888
|
-
const
|
|
2889
|
-
const
|
|
2890
|
-
|
|
3081
|
+
const foldOpenWhileEmpty = useRef12(false);
|
|
3082
|
+
const [zonesSeen, setZonesSeen] = useState12(zonesProp);
|
|
3083
|
+
if (zonesProp !== zonesSeen) {
|
|
3084
|
+
setZonesSeen(zonesProp);
|
|
3085
|
+
setFolded(zonesStart(zonesProp));
|
|
3086
|
+
}
|
|
3087
|
+
const zonesId = useId5();
|
|
3088
|
+
const resultId = useId5();
|
|
3089
|
+
const ownPrefix = useRef12(
|
|
2891
3090
|
/** @type {string | null} */
|
|
2892
3091
|
null
|
|
2893
3092
|
);
|
|
@@ -2902,7 +3101,7 @@ function Report(props) {
|
|
|
2902
3101
|
null
|
|
2903
3102
|
);
|
|
2904
3103
|
const [hinted, setHinted] = useState12(false);
|
|
2905
|
-
const changesRef =
|
|
3104
|
+
const changesRef = useRef12(0);
|
|
2906
3105
|
const [changes, setChanges] = useState12(0);
|
|
2907
3106
|
const [dragAt, setDragAt] = useState12(
|
|
2908
3107
|
/** @type {number | null} */
|
|
@@ -2930,9 +3129,13 @@ function Report(props) {
|
|
|
2930
3129
|
/** @type {string | null} */
|
|
2931
3130
|
null
|
|
2932
3131
|
);
|
|
2933
|
-
const chartRef =
|
|
3132
|
+
const chartRef = useRef12(null);
|
|
2934
3133
|
const [chartReady, setChartReady] = useState12(false);
|
|
2935
|
-
const
|
|
3134
|
+
const [lineChecks, setLineChecks] = useState12(
|
|
3135
|
+
/** @type {any} */
|
|
3136
|
+
null
|
|
3137
|
+
);
|
|
3138
|
+
const hintId = useId5();
|
|
2936
3139
|
const closeFilter = useCallback10(() => setFilterTarget(null), []);
|
|
2937
3140
|
const { toasts, push, dismiss, pause } = useToasts();
|
|
2938
3141
|
const announce = useCallback10(
|
|
@@ -3010,8 +3213,8 @@ function Report(props) {
|
|
|
3010
3213
|
const loadedView = tagFor(history.tag, sourceId);
|
|
3011
3214
|
const viewName = loadedView?.name ?? null;
|
|
3012
3215
|
const unsaved = Boolean(loadedView) && savedKeys[savedKeyOf(loadedView)] !== history.viewKey;
|
|
3013
|
-
const
|
|
3014
|
-
const stableChartOptions = useMemo8(() => chartOptions, [
|
|
3216
|
+
const chartHostKey = optionsKey([chartOptions, colorMap]);
|
|
3217
|
+
const [stableChartOptions, stableColorMap] = useMemo8(() => [chartOptions, colorMap], [chartHostKey]);
|
|
3015
3218
|
const stepText = useCallback10(
|
|
3016
3219
|
(note) => {
|
|
3017
3220
|
const template = Object.hasOwn(labels.steps, note.step) ? labels.steps[note.step] : labels.steps.change;
|
|
@@ -3025,7 +3228,7 @@ function Report(props) {
|
|
|
3025
3228
|
},
|
|
3026
3229
|
[labels]
|
|
3027
3230
|
);
|
|
3028
|
-
const apiNow =
|
|
3231
|
+
const apiNow = useRef12(
|
|
3029
3232
|
/** @type {any} */
|
|
3030
3233
|
null
|
|
3031
3234
|
);
|
|
@@ -3042,7 +3245,7 @@ function Report(props) {
|
|
|
3042
3245
|
}
|
|
3043
3246
|
};
|
|
3044
3247
|
const newStep = useCallback10(() => setDataSteps((s) => s.future.length ? { past: s.past, future: [] } : s), []);
|
|
3045
|
-
const undoLater =
|
|
3248
|
+
const undoLater = useRef12(undo2);
|
|
3046
3249
|
useEffect11(() => {
|
|
3047
3250
|
undoLater.current = undo2;
|
|
3048
3251
|
});
|
|
@@ -3052,11 +3255,11 @@ function Report(props) {
|
|
|
3052
3255
|
announce(labels.toastReset, { action: { label: labels.undo, run: () => undoLater.current() } });
|
|
3053
3256
|
}, [history, labels, announce, newStep]);
|
|
3054
3257
|
const [opening, setOpening] = useState12(false);
|
|
3055
|
-
const appliedLink =
|
|
3258
|
+
const appliedLink = useRef12(
|
|
3056
3259
|
/** @type {string | null} */
|
|
3057
3260
|
null
|
|
3058
3261
|
);
|
|
3059
|
-
const latest =
|
|
3262
|
+
const latest = useRef12({ history, encoded, limits, labels, announce, commit: (
|
|
3060
3263
|
/** @type {any} */
|
|
3061
3264
|
null
|
|
3062
3265
|
), sourceId, loaded: (
|
|
@@ -3161,23 +3364,26 @@ function Report(props) {
|
|
|
3161
3364
|
}
|
|
3162
3365
|
}, [persistView, storageKey, history.viewKey]);
|
|
3163
3366
|
const commit = useCallback10(
|
|
3164
|
-
/** @param {object} next @param {{ step: string, removed?: boolean, field?: string, zone?: string, name?: string, display?: string, type?: string }} [note] @param {any} [tag] the saved view it is (history.tag) */
|
|
3367
|
+
/** @param {object} next @param {{ step: string, removed?: boolean, field?: string, zone?: string, name?: string, display?: string, type?: string }} [note] @param {any} [tag] the saved view it is (history.tag) @returns {boolean} whether the view changed */
|
|
3165
3368
|
(next, note = { step: "change" }, tag = void 0) => {
|
|
3166
3369
|
const over = note.step === "template" ? null : zoneOverLimit(next, limits);
|
|
3167
3370
|
if (over) {
|
|
3168
3371
|
announce(fill(labels.zoneFull, { zone: labels.zones[over.zone], max: over.max.toLocaleString(locale) }), { tone: "error" });
|
|
3169
|
-
return;
|
|
3372
|
+
return false;
|
|
3170
3373
|
}
|
|
3171
3374
|
const changed = history.commit(next, stepText(note), tag);
|
|
3375
|
+
if (changed && note.step === "added" && foldOpenWhileEmpty.current) {
|
|
3376
|
+
setFolded(false);
|
|
3377
|
+
}
|
|
3172
3378
|
if (changed) {
|
|
3173
3379
|
changesRef.current += 1;
|
|
3174
3380
|
setChanges(changesRef.current);
|
|
3175
3381
|
newStep();
|
|
3176
3382
|
}
|
|
3177
|
-
if (
|
|
3178
|
-
|
|
3383
|
+
if (changed && note.removed) {
|
|
3384
|
+
announce(fill(labels.toastRemoved, { field: note.field ?? "" }).trim(), { action: { label: labels.undo, run: () => undoLater.current() } });
|
|
3179
3385
|
}
|
|
3180
|
-
|
|
3386
|
+
return changed;
|
|
3181
3387
|
},
|
|
3182
3388
|
[history, stepText, labels, announce, limits, locale, newStep]
|
|
3183
3389
|
);
|
|
@@ -3217,7 +3423,8 @@ function Report(props) {
|
|
|
3217
3423
|
return { result: null, error: error2 };
|
|
3218
3424
|
}
|
|
3219
3425
|
}, [encoded, view, locale, limits]);
|
|
3220
|
-
const
|
|
3426
|
+
const context = useMemo8(() => dateContext(computed.result, labels), [computed.result, labels]);
|
|
3427
|
+
const result = context.result;
|
|
3221
3428
|
const unusedLocale = useMemo8(() => {
|
|
3222
3429
|
const requested = view.formatting?.locale || locale;
|
|
3223
3430
|
try {
|
|
@@ -3238,19 +3445,26 @@ function Report(props) {
|
|
|
3238
3445
|
return { result: null, error: error2 };
|
|
3239
3446
|
}
|
|
3240
3447
|
}, [plan.swap, view, encoded, locale, limits, computed, result]);
|
|
3241
|
-
const
|
|
3448
|
+
const titleOf = useCallback10((field) => context.titles.get(field), [context]);
|
|
3449
|
+
const chartContext = useMemo8(() => chartComputed.result === computed.result ? context : dateContext(chartComputed.result, labels), [chartComputed.result, computed.result, context, labels]);
|
|
3450
|
+
const chartResult = chartContext.result;
|
|
3242
3451
|
const empty = isEmptyView(view);
|
|
3452
|
+
const layoutFolded = folded ?? (short && !empty);
|
|
3453
|
+
useEffect11(() => {
|
|
3454
|
+
foldOpenWhileEmpty.current = empty && short && folded === null;
|
|
3455
|
+
});
|
|
3243
3456
|
const gridState = useMemo8(() => {
|
|
3244
3457
|
if (!result || view.display !== "table" || empty) {
|
|
3245
3458
|
return { grid: null, error: null };
|
|
3246
3459
|
}
|
|
3247
3460
|
try {
|
|
3248
|
-
return { grid: measured("toGrid", () => toGrid(result, { locale, labels: labels.core, limits })), error: null };
|
|
3461
|
+
return { grid: measured("toGrid", () => toGrid(result, { locale, labels: context.labels.core, limits })), error: null };
|
|
3249
3462
|
} catch (error2) {
|
|
3250
3463
|
return { grid: null, error: error2 };
|
|
3251
3464
|
}
|
|
3252
|
-
}, [result, view.display, empty, locale, labels, limits]);
|
|
3465
|
+
}, [result, view.display, empty, locale, context.labels, limits]);
|
|
3253
3466
|
const error = source.error ?? computed.error ?? gridState.error ?? (view.display === "chart" ? chartComputed.error : null);
|
|
3467
|
+
const dateLocale = useMemo8(() => dateDisplayLocale(view.formatting?.locale || locale), [view.formatting?.locale, locale]);
|
|
3254
3468
|
const fields = encoded.schema.fields;
|
|
3255
3469
|
const types = useMemo8(() => new Map(viewFields(view, encoded).map((f) => [f.name.toLowerCase(), f.type])), [view, encoded]);
|
|
3256
3470
|
const typeOf = useCallback10((field) => types.get(sourceOf(view, field ?? "").toLowerCase()) ?? "string", [types, view]);
|
|
@@ -3259,14 +3473,24 @@ function Report(props) {
|
|
|
3259
3473
|
const sortFromHeader = useCallback10((field, sort) => commit(setSort(view, field, sort), { step: "sort", field: nameOf(field) }), [view, commit, nameOf]);
|
|
3260
3474
|
const infoOf = useCallback10(
|
|
3261
3475
|
(field) => {
|
|
3262
|
-
if (!field
|
|
3476
|
+
if (!field) {
|
|
3263
3477
|
return void 0;
|
|
3264
3478
|
}
|
|
3265
3479
|
const entry = info.get(sourceOf(view, field).toLowerCase());
|
|
3266
|
-
|
|
3480
|
+
const range = dateRangeText(dateSpan(encoded, sourceOf(view, field)), dateLocale);
|
|
3481
|
+
const description = [entry?.description, range && fill(labels.dateRangeData, { range })].filter(Boolean).join(" \xB7 ");
|
|
3482
|
+
return description ? { ...entry, description } : void 0;
|
|
3267
3483
|
},
|
|
3268
|
-
[info, view]
|
|
3484
|
+
[info, view, encoded, dateLocale, labels]
|
|
3269
3485
|
);
|
|
3486
|
+
const fieldInfo = useMemo8(() => {
|
|
3487
|
+
const entries2 = new Map(info);
|
|
3488
|
+
for (const field of encoded.schema.fields) {
|
|
3489
|
+
const entry = infoOf(field.name);
|
|
3490
|
+
if (entry) entries2.set(field.name.toLowerCase(), entry);
|
|
3491
|
+
}
|
|
3492
|
+
return entries2;
|
|
3493
|
+
}, [info, infoOf, encoded]);
|
|
3270
3494
|
const placed = useMemo8(() => {
|
|
3271
3495
|
const map = /* @__PURE__ */ new Map();
|
|
3272
3496
|
const mark = (name, zone) => {
|
|
@@ -3298,11 +3522,13 @@ function Report(props) {
|
|
|
3298
3522
|
live = false;
|
|
3299
3523
|
};
|
|
3300
3524
|
}, [lang]);
|
|
3301
|
-
const mainRef =
|
|
3525
|
+
const mainRef = useRef12(
|
|
3302
3526
|
/** @type {HTMLDivElement | null} */
|
|
3303
3527
|
null
|
|
3304
3528
|
);
|
|
3305
|
-
const
|
|
3529
|
+
const checkLow = useRef12(() => {
|
|
3530
|
+
});
|
|
3531
|
+
const fit = useFitHeight(root, mainRef, grow, () => checkLow.current());
|
|
3306
3532
|
const big = useBigResult(root);
|
|
3307
3533
|
useIsoLayoutEffect(() => {
|
|
3308
3534
|
const el = root.current;
|
|
@@ -3314,17 +3540,78 @@ function Report(props) {
|
|
|
3314
3540
|
const first = compactAt(sizeOf(box.width), box.height);
|
|
3315
3541
|
setMeasuredShort(first);
|
|
3316
3542
|
setShort(first);
|
|
3543
|
+
const low = (width, height2) => compactAt(width, height2) || fit.current.open > 0 && height2 <= fit.current.open + 1;
|
|
3544
|
+
let waiting = false;
|
|
3545
|
+
let lastInArea = false;
|
|
3546
|
+
const inArea = (t) => t instanceof Node && Boolean(el.querySelector(".pk-zone-section")?.contains(t) || el.querySelector(".pk-layer")?.contains(t));
|
|
3547
|
+
const note = (e) => {
|
|
3548
|
+
lastInArea = inArea(e.composedPath()[0] ?? e.target);
|
|
3549
|
+
};
|
|
3550
|
+
el.addEventListener("pointerdown", note, true);
|
|
3551
|
+
el.addEventListener("focusin", note, true);
|
|
3552
|
+
const busy = () => {
|
|
3553
|
+
const section = el.querySelector(".pk-zone-section");
|
|
3554
|
+
if (!section) {
|
|
3555
|
+
return false;
|
|
3556
|
+
}
|
|
3557
|
+
const active = (
|
|
3558
|
+
/** @type {Document | ShadowRoot} */
|
|
3559
|
+
el.getRootNode().activeElement
|
|
3560
|
+
);
|
|
3561
|
+
const focusGone = !active || active === el.ownerDocument.body;
|
|
3562
|
+
return Boolean(layerOpen(el.querySelector(".pk-layer")) || section.matches(":hover") || section.matches(":focus-within") || section.querySelector(".pk-dropping") || lastInArea && focusGone);
|
|
3563
|
+
};
|
|
3564
|
+
const doc = el.ownerDocument;
|
|
3565
|
+
let again = 0;
|
|
3566
|
+
const retry = () => {
|
|
3567
|
+
clearTimeout(again);
|
|
3568
|
+
again = window.setTimeout(() => waiting && checkLow.current(), 0);
|
|
3569
|
+
};
|
|
3570
|
+
const watch = (on) => {
|
|
3571
|
+
const how = on ? "addEventListener" : "removeEventListener";
|
|
3572
|
+
el[how]("pointerout", retry);
|
|
3573
|
+
el[how]("focusout", retry);
|
|
3574
|
+
doc[how]("pointerup", retry);
|
|
3575
|
+
};
|
|
3576
|
+
checkLow.current = () => {
|
|
3577
|
+
if (busy()) {
|
|
3578
|
+
if (!waiting) {
|
|
3579
|
+
waiting = true;
|
|
3580
|
+
watch(true);
|
|
3581
|
+
}
|
|
3582
|
+
return;
|
|
3583
|
+
}
|
|
3584
|
+
if (waiting) {
|
|
3585
|
+
waiting = false;
|
|
3586
|
+
watch(false);
|
|
3587
|
+
}
|
|
3588
|
+
const now = el.getBoundingClientRect();
|
|
3589
|
+
setMeasuredShort(low(sizeOf(now.width), now.height));
|
|
3590
|
+
};
|
|
3591
|
+
const release = () => {
|
|
3592
|
+
el.removeEventListener("pointerdown", note, true);
|
|
3593
|
+
el.removeEventListener("focusin", note, true);
|
|
3594
|
+
clearTimeout(again);
|
|
3595
|
+
if (waiting) {
|
|
3596
|
+
waiting = false;
|
|
3597
|
+
watch(false);
|
|
3598
|
+
}
|
|
3599
|
+
};
|
|
3317
3600
|
if (typeof ResizeObserver !== "function") {
|
|
3318
|
-
return
|
|
3601
|
+
return release;
|
|
3319
3602
|
}
|
|
3320
3603
|
const ro = new ResizeObserver(([entry]) => {
|
|
3321
3604
|
const width = sizeOf(entry.contentRect.width);
|
|
3322
3605
|
setSize(width);
|
|
3323
|
-
|
|
3324
|
-
setMeasuredShort(compactAt(width, height2) || fit.current.open > 0 && height2 <= fit.current.open + 1);
|
|
3606
|
+
setMeasuredShort(low(width, entry.borderBoxSize?.[0]?.blockSize ?? el.getBoundingClientRect().height));
|
|
3325
3607
|
});
|
|
3326
3608
|
ro.observe(el);
|
|
3327
|
-
return () =>
|
|
3609
|
+
return () => {
|
|
3610
|
+
checkLow.current = () => {
|
|
3611
|
+
};
|
|
3612
|
+
release();
|
|
3613
|
+
ro.disconnect();
|
|
3614
|
+
};
|
|
3328
3615
|
}, []);
|
|
3329
3616
|
useEffect11(() => {
|
|
3330
3617
|
if (measuredShort === short) {
|
|
@@ -3344,7 +3631,7 @@ function Report(props) {
|
|
|
3344
3631
|
return () => mo.disconnect();
|
|
3345
3632
|
}, [measuredShort, short, layer]);
|
|
3346
3633
|
const drawerOpen = drawer && size === "narrow";
|
|
3347
|
-
const panelRef =
|
|
3634
|
+
const panelRef = useRef12(
|
|
3348
3635
|
/** @type {HTMLDivElement | null} */
|
|
3349
3636
|
null
|
|
3350
3637
|
);
|
|
@@ -3365,15 +3652,22 @@ function Report(props) {
|
|
|
3365
3652
|
const addTo = useCallback10(
|
|
3366
3653
|
(field, zone, index = void 0) => {
|
|
3367
3654
|
const options = placeOptions(field, zone, index);
|
|
3368
|
-
commit(addField(view, field, zone, options), { step: "added", field: options.groupName ?? nameOf(field), zone });
|
|
3655
|
+
return commit(addField(view, field, zone, options), { step: "added", field: options.groupName ?? nameOf(field), zone });
|
|
3369
3656
|
},
|
|
3370
3657
|
[view, placeOptions, commit, nameOf]
|
|
3371
3658
|
);
|
|
3372
|
-
const
|
|
3373
|
-
|
|
3659
|
+
const placeName = useCallback10((field, zone) => placeOptions(field, zone).groupName ?? field, [placeOptions]);
|
|
3660
|
+
const filterDraft = useCallback10(
|
|
3661
|
+
(field) => {
|
|
3374
3662
|
const options = placeOptions(field, "filters");
|
|
3375
3663
|
const name = options.groupName ?? field;
|
|
3376
|
-
|
|
3664
|
+
return { field: name, base: filterZoneFields(view).some((f) => same(f, name)) ? void 0 : addField(view, field, "filters", options) };
|
|
3665
|
+
},
|
|
3666
|
+
[placeOptions, view]
|
|
3667
|
+
);
|
|
3668
|
+
const filterField = useCallback10(
|
|
3669
|
+
(field, anchor) => {
|
|
3670
|
+
const draft = filterDraft(field);
|
|
3377
3671
|
const opener = size === "narrow" ? (
|
|
3378
3672
|
/** @type {HTMLElement | null} */
|
|
3379
3673
|
root.current?.querySelector("[data-pk-opener='fields']") ?? null
|
|
@@ -3383,11 +3677,19 @@ function Report(props) {
|
|
|
3383
3677
|
}
|
|
3384
3678
|
const target = opener ?? anchor;
|
|
3385
3679
|
if (target) {
|
|
3386
|
-
setFilterTarget({ field:
|
|
3680
|
+
setFilterTarget({ field: draft.field, anchor: target, base: draft.base });
|
|
3387
3681
|
}
|
|
3388
3682
|
},
|
|
3389
|
-
[
|
|
3683
|
+
[filterDraft, size]
|
|
3684
|
+
);
|
|
3685
|
+
const zoneFullText = useCallback10(
|
|
3686
|
+
(zone, count) => {
|
|
3687
|
+
const max = zoneMax(zone, limits);
|
|
3688
|
+
return max !== null && count >= max ? fill(labels.zoneFull, { zone: labels.zones[zone], max: max.toLocaleString(locale) }) : null;
|
|
3689
|
+
},
|
|
3690
|
+
[limits, labels, locale]
|
|
3390
3691
|
);
|
|
3692
|
+
const adding = useMemo8(() => ({ fields, placed, nameOf, info, placeName, onAdd: addTo, filterDraft, fullText: zoneFullText }), [fields, placed, nameOf, info, placeName, addTo, filterDraft, zoneFullText]);
|
|
3391
3693
|
const onDrop = useCallback10(
|
|
3392
3694
|
(src, target) => {
|
|
3393
3695
|
setDragAt((at) => at ?? changesRef.current + 1);
|
|
@@ -3429,7 +3731,7 @@ function Report(props) {
|
|
|
3429
3731
|
},
|
|
3430
3732
|
[result, encodedProp, imported, data, drillDownLimit, onCellClick, drillDown, defaultsOf, nameOf, infoOf]
|
|
3431
3733
|
);
|
|
3432
|
-
const { run: doExport, prepare: prepareExport } = useExport({ fileName, result, encoded, exportData, locale, labels, limits, root, chartRef, announce, onExport, title: viewName, source: sourceName, loadECharts });
|
|
3734
|
+
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 });
|
|
3433
3735
|
const requestImport = () => loadImport().then((m) => (flushSync(() => setImportMod(() => m)), m));
|
|
3434
3736
|
const api = {
|
|
3435
3737
|
imported,
|
|
@@ -3463,7 +3765,7 @@ function Report(props) {
|
|
|
3463
3765
|
useEffect11(() => {
|
|
3464
3766
|
apiNow.current = api;
|
|
3465
3767
|
});
|
|
3466
|
-
const restored =
|
|
3768
|
+
const restored = useRef12(false);
|
|
3467
3769
|
useIsoLayoutEffect(() => {
|
|
3468
3770
|
if (kept2 && !restored.current) {
|
|
3469
3771
|
restored.current = true;
|
|
@@ -3472,8 +3774,8 @@ function Report(props) {
|
|
|
3472
3774
|
}
|
|
3473
3775
|
}, []);
|
|
3474
3776
|
const snapshot = history.snapshot;
|
|
3475
|
-
const keptKey =
|
|
3476
|
-
const fileShown =
|
|
3777
|
+
const keptKey = useRef12(keepKey);
|
|
3778
|
+
const fileShown = useRef12(false);
|
|
3477
3779
|
const hostHasColumns = source.encoded.schema.fields.length > 0;
|
|
3478
3780
|
useIsoLayoutEffect(() => {
|
|
3479
3781
|
if (keepKey !== null && !kept2 && hostHasColumns) {
|
|
@@ -3554,7 +3856,7 @@ function Report(props) {
|
|
|
3554
3856
|
loadTemplate(how === "missing" ? { ...t, sheet: SHEET_GONE } : t);
|
|
3555
3857
|
}
|
|
3556
3858
|
};
|
|
3557
|
-
const loadLater =
|
|
3859
|
+
const loadLater = useRef12(
|
|
3558
3860
|
/** @type {((what: { template?: any, file?: object }) => void) | null} */
|
|
3559
3861
|
null
|
|
3560
3862
|
);
|
|
@@ -3656,10 +3958,10 @@ function Report(props) {
|
|
|
3656
3958
|
}
|
|
3657
3959
|
};
|
|
3658
3960
|
const layerValue = useMemo8(() => ({ layer, size }), [layer, size]);
|
|
3659
|
-
const renderOverlay = (src) => /* @__PURE__ */
|
|
3961
|
+
const renderOverlay = (src) => /* @__PURE__ */ React13.createElement("div", { className: "pk-chip pk-overlay" }, /* @__PURE__ */ React13.createElement(Icon, { name: "grip", size: 14 }), /* @__PURE__ */ React13.createElement("span", { className: `pk-type pk-type-${src.type ?? typeOf(src.field)}` }, /* @__PURE__ */ React13.createElement(Icon, { name: (
|
|
3660
3962
|
/** @type {any} */
|
|
3661
3963
|
TYPE_ICON[src.type ?? typeOf(src.field)] ?? "text"
|
|
3662
|
-
), size: 13 })), /* @__PURE__ */
|
|
3964
|
+
), size: 13 })), /* @__PURE__ */ React13.createElement("span", { className: "pk-chip-text" }, src.label ?? src.field));
|
|
3663
3965
|
const showTable = !error && !(empty && view.display === "table") && view.display !== "chart" && gridState.grid;
|
|
3664
3966
|
const outer = useMemo8(() => result ? outerPaths(result) : [], [result]);
|
|
3665
3967
|
const folding = rowFolding(view, outer);
|
|
@@ -3680,15 +3982,15 @@ function Report(props) {
|
|
|
3680
3982
|
return null;
|
|
3681
3983
|
}
|
|
3682
3984
|
try {
|
|
3683
|
-
return toSeries(chartResult, { labels: labels.core, maxCategories: MAX_CATEGORIES });
|
|
3985
|
+
return toSeries(chartResult, { labels: chartContext.labels.core, maxCategories: MAX_CATEGORIES });
|
|
3684
3986
|
} catch {
|
|
3685
3987
|
return null;
|
|
3686
3988
|
}
|
|
3687
|
-
}, [chartResult, view.display, view.values.length, labels]);
|
|
3989
|
+
}, [chartResult, view.display, view.values.length, chartContext.labels]);
|
|
3688
3990
|
const allowedKey = JSON.stringify(allowedTips(tipsProp));
|
|
3689
3991
|
const allowed = useMemo8(() => JSON.parse(allowedKey), [allowedKey]);
|
|
3690
3992
|
const dismissedKey = JSON.stringify(cleanDismissed(dismissedTips));
|
|
3691
|
-
const [
|
|
3993
|
+
const [own, setOwn] = useState12(() => cleanDismissed(JSON.parse(dismissedKey)));
|
|
3692
3994
|
const [lastDismissedKey, setLastDismissedKey] = useState12(dismissedKey);
|
|
3693
3995
|
if (dismissedKey !== lastDismissedKey) {
|
|
3694
3996
|
setLastDismissedKey(dismissedKey);
|
|
@@ -3696,7 +3998,7 @@ function Report(props) {
|
|
|
3696
3998
|
}
|
|
3697
3999
|
const subscribe = useCallback10((callback) => subscribeStored(storageKey, callback), [storageKey]);
|
|
3698
4000
|
const storedRaw = useSyncExternalStore3(subscribe, () => readStored(storageKey, localStore()), () => null);
|
|
3699
|
-
const dismissed = useMemo8(() => cleanDismissed([...
|
|
4001
|
+
const dismissed = useMemo8(() => cleanDismissed([...own, ...parseStored(storedRaw)]), [own, storedRaw]);
|
|
3700
4002
|
const changeDismissed = useCallback10(
|
|
3701
4003
|
(next, id) => {
|
|
3702
4004
|
setOwn(next);
|
|
@@ -3706,7 +4008,7 @@ function Report(props) {
|
|
|
3706
4008
|
[storageKey, onTipDismiss]
|
|
3707
4009
|
);
|
|
3708
4010
|
const tipsOn = allowed !== "off" && !dismissed.includes(ALL_TIPS);
|
|
3709
|
-
const describedFields = [...
|
|
4011
|
+
const describedFields = [...fieldInfo.values()].some((i) => i.description);
|
|
3710
4012
|
const fieldSwitch = helpSwitch(fieldInfoProp, dismissed);
|
|
3711
4013
|
const zoneSwitch = helpSwitch(zoneInfoProp, dismissed);
|
|
3712
4014
|
const settingSwitch = helpSwitch(settingInfoProp, dismissed);
|
|
@@ -3737,6 +4039,16 @@ function Report(props) {
|
|
|
3737
4039
|
warnOnce(`pivotkit: fieldList ${JSON.stringify(String(fieldList)).slice(0, 40)} is neither "open" nor "collapsed"; the user's choice decides`);
|
|
3738
4040
|
}
|
|
3739
4041
|
}, [fieldList]);
|
|
4042
|
+
useEffect11(() => {
|
|
4043
|
+
for (const [key, now] of removedLabels(JSON.parse(labelsKey))) {
|
|
4044
|
+
warnOnce(`pivotkit: labels.${key} is no longer shown and is ignored; set labels.${now} instead`);
|
|
4045
|
+
}
|
|
4046
|
+
}, [labelsKey]);
|
|
4047
|
+
useEffect11(() => {
|
|
4048
|
+
if (zonesProp !== void 0 && zonesStart(zonesProp) === null) {
|
|
4049
|
+
warnOnce(`pivotkit: zones ${JSON.stringify(String(zonesProp)).slice(0, 40)} is neither "open" nor "folded"; the report's height decides`);
|
|
4050
|
+
}
|
|
4051
|
+
}, [zonesProp]);
|
|
3740
4052
|
const railed = size !== "narrow" && fieldsCollapsed(fieldsSession, fieldList, dismissed);
|
|
3741
4053
|
const collapseFields = (next) => {
|
|
3742
4054
|
if (fieldList === "open" || fieldList === "collapsed") {
|
|
@@ -3788,9 +4100,9 @@ function Report(props) {
|
|
|
3788
4100
|
() => JSON.stringify([fromHost ? "host" : loads, ...given.notes.map((n) => "issue" in n ? [n.issue.path, n.issue.message] : n.text), ...result && !empty ? result.issues.slice(0, 20).map((i) => [i.path, i.message]) : []]),
|
|
3789
4101
|
[fromHost, given, loads, result, empty]
|
|
3790
4102
|
);
|
|
3791
|
-
const summaryParts = big.enlarged ? layoutSummary(zoneEntries(view, types, labels), labels) : [];
|
|
4103
|
+
const summaryParts = big.enlarged ? layoutSummary(zoneEntries(view, types, context.labels), context.labels) : [];
|
|
3792
4104
|
const summaryText = summaryParts.length ? summaryParts.map((p) => `${p.title}: ${p.fields}`).join(" \xB7 ") : labels.layoutEmpty;
|
|
3793
|
-
return /* @__PURE__ */
|
|
4105
|
+
return /* @__PURE__ */ React13.createElement(
|
|
3794
4106
|
"div",
|
|
3795
4107
|
{
|
|
3796
4108
|
ref: root,
|
|
@@ -3812,7 +4124,7 @@ function Report(props) {
|
|
|
3812
4124
|
onDragLeave: allowImport ? fileDrag : void 0,
|
|
3813
4125
|
onDrop: allowImport ? fileDrag : void 0
|
|
3814
4126
|
},
|
|
3815
|
-
/* @__PURE__ */
|
|
4127
|
+
/* @__PURE__ */ React13.createElement(LayerContext.Provider, { value: layerValue }, /* @__PURE__ */ React13.createElement(FormNameContext.Provider, { value: formPrefix }, /* @__PURE__ */ React13.createElement(HelpContext.Provider, { value: help }, /* @__PURE__ */ React13.createElement(
|
|
3816
4128
|
PivotDnd,
|
|
3817
4129
|
{
|
|
3818
4130
|
labels,
|
|
@@ -3824,7 +4136,7 @@ function Report(props) {
|
|
|
3824
4136
|
}
|
|
3825
4137
|
}
|
|
3826
4138
|
},
|
|
3827
|
-
/* @__PURE__ */
|
|
4139
|
+
/* @__PURE__ */ React13.createElement("div", { className: `pk-layout${drawerOpen ? " pk-drawer-open" : ""}` }, /* @__PURE__ */ React13.createElement("div", { className: "pk-panel-slot", ref: panelRef }, /* @__PURE__ */ React13.createElement(
|
|
3828
4140
|
FieldPanel,
|
|
3829
4141
|
{
|
|
3830
4142
|
fields,
|
|
@@ -3839,7 +4151,7 @@ function Report(props) {
|
|
|
3839
4151
|
onNote: (text) => announce(text),
|
|
3840
4152
|
onFilter: filterField,
|
|
3841
4153
|
nameOf,
|
|
3842
|
-
info,
|
|
4154
|
+
info: fieldInfo,
|
|
3843
4155
|
showInfo: fieldSwitch.on,
|
|
3844
4156
|
drawer: size === "narrow",
|
|
3845
4157
|
open: drawerOpen,
|
|
@@ -3851,11 +4163,10 @@ function Report(props) {
|
|
|
3851
4163
|
root.current?.querySelector(".pk-toolbar button:not([disabled])")?.focus()
|
|
3852
4164
|
)
|
|
3853
4165
|
}
|
|
3854
|
-
)), drawerOpen ? /* @__PURE__ */
|
|
4166
|
+
)), drawerOpen ? /* @__PURE__ */ React13.createElement("div", { className: "pk-scrim pk-drawer-scrim", onClick: () => setDrawer(false), "aria-hidden": "true" }) : null, /* @__PURE__ */ React13.createElement("div", { className: "pk-main", ref: mainRef }, /* @__PURE__ */ React13.createElement(
|
|
3855
4167
|
Toolbar,
|
|
3856
4168
|
{
|
|
3857
4169
|
view,
|
|
3858
|
-
chartPlan: plan,
|
|
3859
4170
|
labels,
|
|
3860
4171
|
size,
|
|
3861
4172
|
canUndo: history.canUndo || dataSteps.past.length > 0,
|
|
@@ -3868,13 +4179,6 @@ function Report(props) {
|
|
|
3868
4179
|
onReset: reset2,
|
|
3869
4180
|
onNew: newReport,
|
|
3870
4181
|
loadedView: loadedView ? { name: loadedView.name, changed: unsaved } : null,
|
|
3871
|
-
onDisplay: (d) => commit(setDisplay(view, d), { step: "display", display: d }),
|
|
3872
|
-
onChart: (p) => commit(setChart(view, p), { step: "chart", type: p }),
|
|
3873
|
-
onChartDisplay: (patch) => commit(setChartDisplay(view, patch), { step: "chartDisplay" }),
|
|
3874
|
-
onTotal: (key, on) => commit(setTotal(view, key, on), { step: "totals" }),
|
|
3875
|
-
onExpand: expandAll,
|
|
3876
|
-
onCollapse: collapseAll,
|
|
3877
|
-
folding,
|
|
3878
4182
|
share,
|
|
3879
4183
|
templates: entries,
|
|
3880
4184
|
onLoadTemplate: openTemplate,
|
|
@@ -3885,9 +4189,6 @@ function Report(props) {
|
|
|
3885
4189
|
chartReady: view.display === "chart" && chartReady,
|
|
3886
4190
|
empty,
|
|
3887
4191
|
onShowFields: () => setDrawer(true),
|
|
3888
|
-
layoutFolded,
|
|
3889
|
-
onLayout: () => setFolded(!layoutFolded),
|
|
3890
|
-
zonesId,
|
|
3891
4192
|
tipsControls: allowed !== "off",
|
|
3892
4193
|
tipsOn,
|
|
3893
4194
|
onTipsOn: (on) => changeDismissed(on ? dismissed.filter((id) => id !== ALL_TIPS) : [...dismissed, ALL_TIPS], on ? null : ALL_TIPS),
|
|
@@ -3897,9 +4198,9 @@ function Report(props) {
|
|
|
3897
4198
|
explanations: explainUser ? { on: !dismissed.includes(NO_EXPLANATIONS), set: (on) => toggle(NO_EXPLANATIONS, on) } : null
|
|
3898
4199
|
},
|
|
3899
4200
|
viewsRequest,
|
|
3900
|
-
data: allowImport ? { loaded: Boolean(imported), panel: (close) => /* @__PURE__ */
|
|
4201
|
+
data: allowImport ? { loaded: Boolean(imported), panel: (close) => /* @__PURE__ */ React13.createElement(MenuPanel, { name: "DataMenu", loadingText: labels.loadingMenu, props: { api, close, labels } }) } : null
|
|
3901
4202
|
}
|
|
3902
|
-
), /* @__PURE__ */
|
|
4203
|
+
), /* @__PURE__ */ React13.createElement(
|
|
3903
4204
|
Zones,
|
|
3904
4205
|
{
|
|
3905
4206
|
view,
|
|
@@ -3907,18 +4208,20 @@ function Report(props) {
|
|
|
3907
4208
|
labels,
|
|
3908
4209
|
commit,
|
|
3909
4210
|
encoded,
|
|
3910
|
-
locale,
|
|
4211
|
+
locale: dateLocale,
|
|
3911
4212
|
onSwap: () => commit(swapAxes(view), { step: "swap" }),
|
|
3912
4213
|
id: zonesId,
|
|
3913
4214
|
folded: layoutFolded,
|
|
3914
|
-
|
|
4215
|
+
onFold: () => setFolded(!layoutFolded),
|
|
3915
4216
|
defaultsOf,
|
|
3916
4217
|
infoOf,
|
|
4218
|
+
titleOf,
|
|
3917
4219
|
earlier: history.earlier,
|
|
3918
4220
|
explain: zoneSwitch.on,
|
|
3919
|
-
showInfo: fieldSwitch.on
|
|
4221
|
+
showInfo: fieldSwitch.on,
|
|
4222
|
+
adding
|
|
3920
4223
|
}
|
|
3921
|
-
), linkCheck ? /* @__PURE__ */
|
|
4224
|
+
), linkCheck ? /* @__PURE__ */ React13.createElement("div", { className: "pk-link-check", "data-testid": "link-check" }, /* @__PURE__ */ React13.createElement(MenuPanel, { name: "LoadCheck", props: { check: linkCheck, labels, title: labels.linkCheckTitle, quiet: linkCheck.quiet, close: () => setLinkCheck(null), onCancel: cancelLink } })) : null, /* @__PURE__ */ React13.createElement(
|
|
3922
4225
|
Unused,
|
|
3923
4226
|
{
|
|
3924
4227
|
notes,
|
|
@@ -3936,7 +4239,7 @@ function Report(props) {
|
|
|
3936
4239
|
narrow: size === "narrow",
|
|
3937
4240
|
quiet: unusedSaid && !fromHost
|
|
3938
4241
|
}
|
|
3939
|
-
), /* @__PURE__ */
|
|
4242
|
+
), /* @__PURE__ */ React13.createElement(
|
|
3940
4243
|
Tips,
|
|
3941
4244
|
{
|
|
3942
4245
|
tips: shownTips,
|
|
@@ -3945,27 +4248,55 @@ function Report(props) {
|
|
|
3945
4248
|
onAction: runTip,
|
|
3946
4249
|
focusFallback: () => root.current?.focus({ preventScroll: true })
|
|
3947
4250
|
}
|
|
3948
|
-
), showTable && view.values.length ? /* @__PURE__ */
|
|
4251
|
+
), showTable && view.values.length ? /* @__PURE__ */ React13.createElement("p", { id: hintId, className: "pk-sr", "data-testid": "cell-hint" }, labels.tips.cells) : null, big.enlarged ? /* @__PURE__ */ React13.createElement("p", { className: "pk-enlarged-fields", "data-testid": "enlarged-fields" }, summaryText) : null, /* @__PURE__ */ React13.createElement(
|
|
4252
|
+
ViewTabs,
|
|
4253
|
+
{
|
|
4254
|
+
view,
|
|
4255
|
+
labels,
|
|
4256
|
+
panelId: resultId,
|
|
4257
|
+
narrow: size === "narrow",
|
|
4258
|
+
big,
|
|
4259
|
+
plan,
|
|
4260
|
+
encoded,
|
|
4261
|
+
lineChecks: lineChecks?.view === view ? lineChecks.checks : null,
|
|
4262
|
+
locale,
|
|
4263
|
+
chartSeries: series,
|
|
4264
|
+
chartColors: { chart: chartRef },
|
|
4265
|
+
onDisplay: (d) => commit(setDisplay(view, d), { step: "display", display: d }),
|
|
4266
|
+
onChart: (p) => commit(setChart(view, p), { step: "chart", type: p }),
|
|
4267
|
+
onChartDisplay: (patch) => commit(setChartDisplay(view, patch), { step: "chartDisplay" }),
|
|
4268
|
+
onTotal: (key, on) => commit(setTotal(view, key, on), { step: "totals" }),
|
|
4269
|
+
onExpand: expandAll,
|
|
4270
|
+
onCollapse: collapseAll,
|
|
4271
|
+
folding
|
|
4272
|
+
}
|
|
4273
|
+
), /* @__PURE__ */ React13.createElement("section", { className: "pk-result", id: resultId, role: "tabpanel", "aria-labelledby": tabId(resultId, view.display === "chart" ? "chart" : "table") }, loading2 || opening ? /* @__PURE__ */ React13.createElement(Skeleton, { text: labels.loadingReport }) : error ? /* @__PURE__ */ React13.createElement("div", { className: "pk-message pk-error", role: "alert" }, /* @__PURE__ */ React13.createElement(Icon, { name: "info" }), /* @__PURE__ */ React13.createElement("p", null, errorText(error, labels, locale))) : empty && view.display === "table" ? /* @__PURE__ */ React13.createElement(EmptyState, { labels, templates: entries, onTemplate: openTemplate, onLoad: allowImport ? () => requestImport().then((m) => m.pickFile(fileInput.current), () => announce(labels.menuFailed, { tone: "error" })) : void 0, noData: allowImport && fields.length === 0 }) : view.display === "chart" && chartResult ? /* @__PURE__ */ React13.createElement(
|
|
3949
4274
|
PivotChart,
|
|
3950
4275
|
{
|
|
3951
4276
|
result: chartResult,
|
|
3952
4277
|
plan,
|
|
3953
4278
|
series,
|
|
3954
|
-
labels,
|
|
4279
|
+
labels: context.labels,
|
|
3955
4280
|
locale,
|
|
3956
4281
|
themeName,
|
|
3957
4282
|
root,
|
|
3958
|
-
valueNames: view.values
|
|
4283
|
+
valueNames: valueLabels(view.values, labels),
|
|
3959
4284
|
chartOptions: stableChartOptions,
|
|
4285
|
+
colorMap: stableColorMap,
|
|
4286
|
+
onLegend: ({ name, shown }) => {
|
|
4287
|
+
commit(setChartDisplay(view, { hidden: hiddenAfter(view.chart.hidden, name, shown) }), { step: "chartDisplay" });
|
|
4288
|
+
announce(fill(shown ? labels.chartShown : labels.chartHidden, { name }));
|
|
4289
|
+
},
|
|
3960
4290
|
onInstance: (c) => {
|
|
3961
4291
|
chartRef.current = c;
|
|
3962
4292
|
setChartReady(Boolean(c));
|
|
3963
4293
|
},
|
|
4294
|
+
onLines: (checks) => setLineChecks(checks && { checks, view }),
|
|
3964
4295
|
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 ?? "") })
|
|
3965
4296
|
}
|
|
3966
|
-
) : gridState.grid ? /* @__PURE__ */
|
|
3967
|
-
filterTarget ? /* @__PURE__ */
|
|
3968
|
-
), allowImport && importMod ? /* @__PURE__ */
|
|
4297
|
+
) : 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),
|
|
4298
|
+
filterTarget ? /* @__PURE__ */ React13.createElement(MenuPanel, { name: "FilterPopover", props: { target: filterTarget, onClose: closeFilter, view, encoded, locale, labels, commit } }) : null
|
|
4299
|
+
), 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" })))))
|
|
3969
4300
|
);
|
|
3970
4301
|
}
|
|
3971
4302
|
export {
|