pivotkit-react 0.6.0 → 0.7.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 +114 -1
- package/dist/chunks/{chunk-2RAVX4DO.js → chunk-4WZ5F2TJ.js} +57 -33
- package/dist/chunks/{chunk-RIOSIYGC.js → chunk-JAOOFDNR.js} +27 -5
- package/dist/chunks/{chunk-7LERNGUW.js → chunk-ZK5RVCHP.js} +14 -2
- package/dist/chunks/{report-run-BZBFOMPF.js → report-run-HU4WPOB7.js} +3 -1
- package/dist/import-ui.js +13 -24
- package/dist/index.js +61 -54
- package/dist/labels.js +1 -1
- package/dist/menus.js +388 -151
- package/dist/styles.css +4 -1
- package/package.json +8 -4
- package/styles.css.d.ts +3 -0
- package/types/drill-export.d.ts +3 -2
- package/types/drill-panel.d.ts +4 -2
- package/types/export-run.d.ts +16 -3
- package/types/export-scope.d.ts +47 -0
- package/types/import-host.d.ts +8 -5
- package/types/import-labels.d.ts +14 -3
- package/types/import-run.d.ts +0 -8
- package/types/import-ui.d.ts +5 -2
- package/types/index.d.ts +14 -8
- package/types/menu-fields.d.ts +9 -0
- package/types/menu-ops.d.ts +23 -0
- package/types/menus.d.ts +1 -1
- package/types/names.d.ts +22 -8
- package/types/print-frame.d.ts +32 -3
- package/types/report-run.d.ts +5 -0
- package/types/theme-tokens.d.ts +17 -0
- package/types/toolbar-panels.d.ts +15 -6
- package/types/use-export.d.ts +8 -4
- package/types/view-history.d.ts +15 -0
- package/types/light-tokens.d.ts +0 -16
package/dist/index.js
CHANGED
|
@@ -76,7 +76,7 @@ import {
|
|
|
76
76
|
writeItem,
|
|
77
77
|
writeStoredView,
|
|
78
78
|
zoneOverLimit
|
|
79
|
-
} from "./chunks/chunk-
|
|
79
|
+
} from "./chunks/chunk-4WZ5F2TJ.js";
|
|
80
80
|
import {
|
|
81
81
|
FormNameContext,
|
|
82
82
|
Group,
|
|
@@ -92,7 +92,7 @@ import {
|
|
|
92
92
|
tabStops,
|
|
93
93
|
useIsoLayoutEffect,
|
|
94
94
|
useModal
|
|
95
|
-
} from "./chunks/chunk-
|
|
95
|
+
} from "./chunks/chunk-JAOOFDNR.js";
|
|
96
96
|
import {
|
|
97
97
|
MENU_TEXTS,
|
|
98
98
|
errorText,
|
|
@@ -104,7 +104,7 @@ import {
|
|
|
104
104
|
} from "./chunks/chunk-XN5HNKJ2.js";
|
|
105
105
|
|
|
106
106
|
// src/PivotReport.jsx
|
|
107
|
-
import React12, { useCallback as
|
|
107
|
+
import React12, { useCallback as useCallback10, useEffect as useEffect11, useId as useId4, useMemo as useMemo8, useRef as useRef11, useState as useState12, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
108
108
|
import { flushSync } from "react-dom";
|
|
109
109
|
import { computePivot, emptyView as emptyView2, encode, fieldLabel as fieldLabel5, normalize as normalize2, suggestDateUnit, toGrid, toSeries, viewFields } from "pivotkit-core";
|
|
110
110
|
|
|
@@ -2083,8 +2083,11 @@ function Toolbar(props) {
|
|
|
2083
2083
|
}
|
|
2084
2084
|
|
|
2085
2085
|
// src/use-export.js
|
|
2086
|
+
import { useCallback as useCallback5 } from "react";
|
|
2086
2087
|
function useExport(context) {
|
|
2087
|
-
|
|
2088
|
+
const { root, loadECharts: loadECharts2 } = context;
|
|
2089
|
+
const prepare = useCallback5((what) => menusNow()?.prepareExport(what, root, loadECharts2), [root, loadECharts2]);
|
|
2090
|
+
const run = async (kind) => {
|
|
2088
2091
|
try {
|
|
2089
2092
|
const lang = context.labels.lang;
|
|
2090
2093
|
const menus = menusNow(lang) ?? await loadMenus(lang);
|
|
@@ -2093,11 +2096,11 @@ function useExport(context) {
|
|
|
2093
2096
|
context.announce(fill(context.labels.toastExportFailed, { message: messageOf(e) }), { tone: "error" });
|
|
2094
2097
|
}
|
|
2095
2098
|
};
|
|
2099
|
+
return { run, prepare };
|
|
2096
2100
|
}
|
|
2097
|
-
var prepareExporters = () => void loadMenus().then((m) => m.prepareExporters(), () => void 0);
|
|
2098
2101
|
|
|
2099
2102
|
// src/use-theme.js
|
|
2100
|
-
import { useCallback as
|
|
2103
|
+
import { useCallback as useCallback6, useSyncExternalStore } from "react";
|
|
2101
2104
|
function hostTheme(el) {
|
|
2102
2105
|
let node = el;
|
|
2103
2106
|
while (node) {
|
|
@@ -2115,7 +2118,7 @@ function hostTheme(el) {
|
|
|
2115
2118
|
}
|
|
2116
2119
|
var darkQuery = () => typeof matchMedia === "function" ? matchMedia("(prefers-color-scheme: dark)") : null;
|
|
2117
2120
|
function useResolvedTheme(wanted, ref) {
|
|
2118
|
-
const subscribe =
|
|
2121
|
+
const subscribe = useCallback6(
|
|
2119
2122
|
(onChange) => {
|
|
2120
2123
|
if (wanted === "light" || wanted === "dark" || typeof document === "undefined") {
|
|
2121
2124
|
return () => {
|
|
@@ -2142,12 +2145,17 @@ function useResolvedTheme(wanted, ref) {
|
|
|
2142
2145
|
}
|
|
2143
2146
|
|
|
2144
2147
|
// src/use-view-history.js
|
|
2145
|
-
import { useCallback as
|
|
2148
|
+
import { useCallback as useCallback7, useMemo as useMemo6, useState as useState9 } from "react";
|
|
2146
2149
|
import { emptyView, normalize } from "pivotkit-core";
|
|
2147
2150
|
|
|
2148
2151
|
// src/view-history.js
|
|
2149
2152
|
var tagFor = (tag, sourceId) => tag && tag.sourceId === sourceId ? tag : null;
|
|
2150
2153
|
var HISTORY_LIMIT = 100;
|
|
2154
|
+
var told = (pending3, view) => [...pending3, view].slice(-HISTORY_LIMIT);
|
|
2155
|
+
function answered(pending3, view) {
|
|
2156
|
+
const index = pending3.indexOf(view);
|
|
2157
|
+
return index < 0 ? [] : pending3.slice(index + 1);
|
|
2158
|
+
}
|
|
2151
2159
|
function createState(schema, start, current = start, tag = null) {
|
|
2152
2160
|
return { schema, start, present: current, past: [], future: [], tag };
|
|
2153
2161
|
}
|
|
@@ -2196,7 +2204,7 @@ function schemaKeyOf(encoded) {
|
|
|
2196
2204
|
function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outsideNote, orderOf, dataKey = 0, initial: initialState = null }) {
|
|
2197
2205
|
const controlled = view !== void 0;
|
|
2198
2206
|
const schema = useMemo6(() => `${dataKey}|${schemaKeyOf(encoded)}`, [encoded, dataKey]);
|
|
2199
|
-
const json =
|
|
2207
|
+
const json = useCallback7(
|
|
2200
2208
|
(v) => {
|
|
2201
2209
|
const normalized = normalize(v ?? emptyView(), encoded, { limits }).view;
|
|
2202
2210
|
const ordered = orderOf ? withHostOrders(normalized, orderOf) : normalized;
|
|
@@ -2211,8 +2219,7 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2211
2219
|
const [echo, setEcho] = useState9(() => ({ over: viewKey, pending: initialState ? [initialState.present] : [] }));
|
|
2212
2220
|
let pending3 = echo.pending;
|
|
2213
2221
|
if (viewKey !== echo.over) {
|
|
2214
|
-
|
|
2215
|
-
pending3 = index < 0 ? [] : pending3.slice(index + 1);
|
|
2222
|
+
pending3 = viewKey === null ? [] : answered(pending3, json(JSON.parse(viewKey)));
|
|
2216
2223
|
setEcho({ over: viewKey, pending: pending3 });
|
|
2217
2224
|
}
|
|
2218
2225
|
const shown = useMemo6(() => {
|
|
@@ -2227,17 +2234,17 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2227
2234
|
), [shown]);
|
|
2228
2235
|
const waiting = viewKey !== null && pending3.length > 0 && state.schema === schema;
|
|
2229
2236
|
const live = useMemo6(() => waiting ? state : settle(state, { schema, start, shown, outside: outsideNote }), [waiting, state, schema, start, shown, outsideNote]);
|
|
2230
|
-
const apply =
|
|
2237
|
+
const apply = useCallback7(
|
|
2231
2238
|
(next) => {
|
|
2232
2239
|
setState(next);
|
|
2233
2240
|
if (viewKey !== null) {
|
|
2234
|
-
setEcho((previous) => ({ over: viewKey, pending:
|
|
2241
|
+
setEcho((previous) => ({ over: viewKey, pending: told(previous.over === viewKey ? previous.pending : pending3, next.present) }));
|
|
2235
2242
|
}
|
|
2236
2243
|
onViewChange?.(JSON.parse(next.present));
|
|
2237
2244
|
},
|
|
2238
2245
|
[onViewChange, viewKey, pending3]
|
|
2239
2246
|
);
|
|
2240
|
-
const commit =
|
|
2247
|
+
const commit = useCallback7(
|
|
2241
2248
|
(next, note, tag) => {
|
|
2242
2249
|
const s = record(live, json(next), note, tag === void 0 ? live.tag : tag);
|
|
2243
2250
|
if (s.present === live.present) {
|
|
@@ -2251,22 +2258,22 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2251
2258
|
},
|
|
2252
2259
|
[live, json, apply]
|
|
2253
2260
|
);
|
|
2254
|
-
const setTag =
|
|
2255
|
-
const undo2 =
|
|
2261
|
+
const setTag = useCallback7((tag) => setState((s) => ({ ...s, tag })), []);
|
|
2262
|
+
const undo2 = useCallback7(() => {
|
|
2256
2263
|
const { state: s, note } = undo(live);
|
|
2257
2264
|
if (note !== null) {
|
|
2258
2265
|
apply(s);
|
|
2259
2266
|
}
|
|
2260
2267
|
return note;
|
|
2261
2268
|
}, [live, apply]);
|
|
2262
|
-
const redo2 =
|
|
2269
|
+
const redo2 = useCallback7(() => {
|
|
2263
2270
|
const { state: s, note } = redo(live);
|
|
2264
2271
|
if (note !== null) {
|
|
2265
2272
|
apply(s);
|
|
2266
2273
|
}
|
|
2267
2274
|
return note;
|
|
2268
2275
|
}, [live, apply]);
|
|
2269
|
-
const reset2 =
|
|
2276
|
+
const reset2 = useCallback7(
|
|
2270
2277
|
(note) => {
|
|
2271
2278
|
const s = reset(live, note);
|
|
2272
2279
|
if (s.present !== live.present) {
|
|
@@ -2277,9 +2284,9 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2277
2284
|
},
|
|
2278
2285
|
[live, apply]
|
|
2279
2286
|
);
|
|
2280
|
-
const restore =
|
|
2281
|
-
const snapshot =
|
|
2282
|
-
const earlier =
|
|
2287
|
+
const restore = useCallback7((next, tag = null) => apply(createState(schema, start, json(next), tag)), [schema, start, json, apply]);
|
|
2288
|
+
const snapshot = useCallback7(() => live, [live]);
|
|
2289
|
+
const earlier = useCallback7(() => live.past.map((p) => JSON.parse(p.view)), [live.past]);
|
|
2283
2290
|
const canUndo = live.past.length > 0;
|
|
2284
2291
|
const canRedo = live.future.length > 0;
|
|
2285
2292
|
const canReset = live.present !== live.start;
|
|
@@ -2314,7 +2321,7 @@ function keptData(key, host) {
|
|
|
2314
2321
|
}
|
|
2315
2322
|
|
|
2316
2323
|
// src/use-big-result.js
|
|
2317
|
-
import { useCallback as
|
|
2324
|
+
import { useCallback as useCallback8, useEffect as useEffect9, useRef as useRef9, useState as useState10, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
2318
2325
|
function fullScreenSupported() {
|
|
2319
2326
|
return typeof document !== "undefined" && Boolean(document.fullscreenEnabled) && typeof HTMLElement !== "undefined" && typeof HTMLElement.prototype.requestFullscreen === "function";
|
|
2320
2327
|
}
|
|
@@ -2337,7 +2344,7 @@ function useBigResult(root) {
|
|
|
2337
2344
|
doc.addEventListener("fullscreenchange", sync);
|
|
2338
2345
|
return () => doc.removeEventListener("fullscreenchange", sync);
|
|
2339
2346
|
}, [root]);
|
|
2340
|
-
const toggleEnlarged =
|
|
2347
|
+
const toggleEnlarged = useCallback8(() => setEnlarged((on) => !on), []);
|
|
2341
2348
|
const toggleFull = () => {
|
|
2342
2349
|
const el = root.current;
|
|
2343
2350
|
if (!el) {
|
|
@@ -2399,7 +2406,7 @@ function measureFit(el, m, fit) {
|
|
|
2399
2406
|
}
|
|
2400
2407
|
|
|
2401
2408
|
// src/zones.jsx
|
|
2402
|
-
import React11, { useCallback as
|
|
2409
|
+
import React11, { useCallback as useCallback9, useEffect as useEffect10, useMemo as useMemo7, useRef as useRef10, useState as useState11 } from "react";
|
|
2403
2410
|
import { fieldItems, fieldLabel as fieldLabel4 } from "pivotkit-core";
|
|
2404
2411
|
function fieldState(view, field, encoded, locale, labels, sourceType) {
|
|
2405
2412
|
const items = filtersOf(view, field, ["in"]).filter((f) => !isEmptyPick(f));
|
|
@@ -2559,7 +2566,7 @@ function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap,
|
|
|
2559
2566
|
}
|
|
2560
2567
|
return map;
|
|
2561
2568
|
}, [entries, view, encoded, locale, labels]);
|
|
2562
|
-
const rangeOf =
|
|
2569
|
+
const rangeOf = useCallback9((field) => numberRange(encoded, field), [encoded]);
|
|
2563
2570
|
const root = useRef10(
|
|
2564
2571
|
/** @type {HTMLDivElement | null} */
|
|
2565
2572
|
null
|
|
@@ -2926,9 +2933,9 @@ function Report(props) {
|
|
|
2926
2933
|
const chartRef = useRef11(null);
|
|
2927
2934
|
const [chartReady, setChartReady] = useState12(false);
|
|
2928
2935
|
const hintId = useId4();
|
|
2929
|
-
const closeFilter =
|
|
2936
|
+
const closeFilter = useCallback10(() => setFilterTarget(null), []);
|
|
2930
2937
|
const { toasts, push, dismiss, pause } = useToasts();
|
|
2931
|
-
const announce =
|
|
2938
|
+
const announce = useCallback10(
|
|
2932
2939
|
/** @param {string} text @param {{ action?: { label: string, run: () => void }, tone?: "error" }} [extra] */
|
|
2933
2940
|
(text, extra) => push({ text, ...extra }),
|
|
2934
2941
|
[push]
|
|
@@ -2999,13 +3006,13 @@ function Report(props) {
|
|
|
2999
3006
|
const notes2 = unusedNotes(normalize2(raw, encoded, { limits }).issues, raw);
|
|
3000
3007
|
return notes2.length ? { notes: notes2, loaded: JSON.parse(keyOf(raw)) } : null;
|
|
3001
3008
|
}, [hostKey, loading2, imported, encoded, limits, keyOf]);
|
|
3002
|
-
const leaveOut =
|
|
3009
|
+
const leaveOut = useCallback10((notes2, given2) => setLeftOut({ notes: notes2, loaded: given2 ? JSON.parse(keyOf(given2)) : null, after: hostKey }), [keyOf, hostKey]);
|
|
3003
3010
|
const loadedView = tagFor(history.tag, sourceId);
|
|
3004
3011
|
const viewName = loadedView?.name ?? null;
|
|
3005
3012
|
const unsaved = Boolean(loadedView) && savedKeys[savedKeyOf(loadedView)] !== history.viewKey;
|
|
3006
3013
|
const chartOptionsKey = optionsKey(chartOptions);
|
|
3007
3014
|
const stableChartOptions = useMemo8(() => chartOptions, [chartOptionsKey]);
|
|
3008
|
-
const stepText =
|
|
3015
|
+
const stepText = useCallback10(
|
|
3009
3016
|
(note) => {
|
|
3010
3017
|
const template = Object.hasOwn(labels.steps, note.step) ? labels.steps[note.step] : labels.steps.change;
|
|
3011
3018
|
return fill(template, {
|
|
@@ -3034,12 +3041,12 @@ function Report(props) {
|
|
|
3034
3041
|
announce(fill(labels.toastRedone, { step: note }));
|
|
3035
3042
|
}
|
|
3036
3043
|
};
|
|
3037
|
-
const newStep =
|
|
3044
|
+
const newStep = useCallback10(() => setDataSteps((s) => s.future.length ? { past: s.past, future: [] } : s), []);
|
|
3038
3045
|
const undoLater = useRef11(undo2);
|
|
3039
3046
|
useEffect11(() => {
|
|
3040
3047
|
undoLater.current = undo2;
|
|
3041
3048
|
});
|
|
3042
|
-
const reset2 =
|
|
3049
|
+
const reset2 = useCallback10(() => {
|
|
3043
3050
|
history.reset(labels.steps.reset);
|
|
3044
3051
|
newStep();
|
|
3045
3052
|
announce(labels.toastReset, { action: { label: labels.undo, run: () => undoLater.current() } });
|
|
@@ -3060,7 +3067,7 @@ function Report(props) {
|
|
|
3060
3067
|
/** @type {null | { lines: string[], quiet: boolean, load: () => void, switchTo?: { name: string, run: () => void } }} */
|
|
3061
3068
|
null
|
|
3062
3069
|
);
|
|
3063
|
-
const openLink =
|
|
3070
|
+
const openLink = useCallback10((text, asStep = false) => {
|
|
3064
3071
|
appliedLink.current = text;
|
|
3065
3072
|
const now = linkNow();
|
|
3066
3073
|
const apply = (m) => {
|
|
@@ -3153,7 +3160,7 @@ function Report(props) {
|
|
|
3153
3160
|
writeStoredView(storageKey, sessionStore(), JSON.parse(history.viewKey));
|
|
3154
3161
|
}
|
|
3155
3162
|
}, [persistView, storageKey, history.viewKey]);
|
|
3156
|
-
const commit =
|
|
3163
|
+
const commit = useCallback10(
|
|
3157
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) */
|
|
3158
3165
|
(next, note = { step: "change" }, tag = void 0) => {
|
|
3159
3166
|
const over = note.step === "template" ? null : zoneOverLimit(next, limits);
|
|
@@ -3174,8 +3181,8 @@ function Report(props) {
|
|
|
3174
3181
|
},
|
|
3175
3182
|
[history, stepText, labels, announce, limits, locale, newStep]
|
|
3176
3183
|
);
|
|
3177
|
-
const remember =
|
|
3178
|
-
const applyLoaded =
|
|
3184
|
+
const remember = useCallback10((tag, key) => setSavedKeys((all) => ({ ...all, [savedKeyOf(tag)]: key })), []);
|
|
3185
|
+
const applyLoaded = useCallback10(
|
|
3179
3186
|
/** @param {import("./share.js").LoadedView} loaded @param {{ link?: boolean, restored?: boolean }} [how] */
|
|
3180
3187
|
(loaded3, { link = false, restored: restored2 = false } = {}) => {
|
|
3181
3188
|
if (!loaded3.view) {
|
|
@@ -3246,11 +3253,11 @@ function Report(props) {
|
|
|
3246
3253
|
const error = source.error ?? computed.error ?? gridState.error ?? (view.display === "chart" ? chartComputed.error : null);
|
|
3247
3254
|
const fields = encoded.schema.fields;
|
|
3248
3255
|
const types = useMemo8(() => new Map(viewFields(view, encoded).map((f) => [f.name.toLowerCase(), f.type])), [view, encoded]);
|
|
3249
|
-
const typeOf =
|
|
3250
|
-
const nameOf =
|
|
3251
|
-
const hostOrdered =
|
|
3252
|
-
const sortFromHeader =
|
|
3253
|
-
const infoOf =
|
|
3256
|
+
const typeOf = useCallback10((field) => types.get(sourceOf(view, field ?? "").toLowerCase()) ?? "string", [types, view]);
|
|
3257
|
+
const nameOf = useCallback10((field) => fieldLabel5(field, labels.core), [labels]);
|
|
3258
|
+
const hostOrdered = useCallback10((field) => sourceOf(view, field) === field && (orderOf?.(field)?.length ?? 0) > 0, [view, orderOf]);
|
|
3259
|
+
const sortFromHeader = useCallback10((field, sort) => commit(setSort(view, field, sort), { step: "sort", field: nameOf(field) }), [view, commit, nameOf]);
|
|
3260
|
+
const infoOf = useCallback10(
|
|
3254
3261
|
(field) => {
|
|
3255
3262
|
if (!field || info.size === 0) {
|
|
3256
3263
|
return void 0;
|
|
@@ -3346,8 +3353,8 @@ function Report(props) {
|
|
|
3346
3353
|
panelRef.current.inert = size === "narrow" && !drawerOpen;
|
|
3347
3354
|
}
|
|
3348
3355
|
}, [size, drawerOpen]);
|
|
3349
|
-
const defaultsOf =
|
|
3350
|
-
const placeOptions =
|
|
3356
|
+
const defaultsOf = useCallback10((field) => fieldDefaultsFor(fieldDefaults, field, encoded.column(field)), [fieldDefaults, encoded]);
|
|
3357
|
+
const placeOptions = useCallback10(
|
|
3351
3358
|
(field, zone, index = void 0) => {
|
|
3352
3359
|
const column = encoded.column(field);
|
|
3353
3360
|
const unit = zone !== "values" && column && column.type === "date" && !column.derived ? suggestDateUnit(encoded, field) : null;
|
|
@@ -3355,14 +3362,14 @@ function Report(props) {
|
|
|
3355
3362
|
},
|
|
3356
3363
|
[encoded, typeOf, defaultsOf, labels, nameOf]
|
|
3357
3364
|
);
|
|
3358
|
-
const addTo =
|
|
3365
|
+
const addTo = useCallback10(
|
|
3359
3366
|
(field, zone, index = void 0) => {
|
|
3360
3367
|
const options = placeOptions(field, zone, index);
|
|
3361
3368
|
commit(addField(view, field, zone, options), { step: "added", field: options.groupName ?? nameOf(field), zone });
|
|
3362
3369
|
},
|
|
3363
3370
|
[view, placeOptions, commit, nameOf]
|
|
3364
3371
|
);
|
|
3365
|
-
const filterField =
|
|
3372
|
+
const filterField = useCallback10(
|
|
3366
3373
|
(field, anchor) => {
|
|
3367
3374
|
const options = placeOptions(field, "filters");
|
|
3368
3375
|
const name = options.groupName ?? field;
|
|
@@ -3381,7 +3388,7 @@ function Report(props) {
|
|
|
3381
3388
|
},
|
|
3382
3389
|
[placeOptions, view, size]
|
|
3383
3390
|
);
|
|
3384
|
-
const onDrop =
|
|
3391
|
+
const onDrop = useCallback10(
|
|
3385
3392
|
(src, target) => {
|
|
3386
3393
|
setDragAt((at) => at ?? changesRef.current + 1);
|
|
3387
3394
|
if (target.zone === "panel") {
|
|
@@ -3403,7 +3410,7 @@ function Report(props) {
|
|
|
3403
3410
|
},
|
|
3404
3411
|
[view, typeOf, commit, addTo, defaultsOf]
|
|
3405
3412
|
);
|
|
3406
|
-
const openCell =
|
|
3413
|
+
const openCell = useCallback10(
|
|
3407
3414
|
/** @param {any} cell */
|
|
3408
3415
|
({ rowPath = [], colPath = [], value, valueIndex, text }) => {
|
|
3409
3416
|
if (!result) {
|
|
@@ -3422,7 +3429,7 @@ function Report(props) {
|
|
|
3422
3429
|
},
|
|
3423
3430
|
[result, encodedProp, imported, data, drillDownLimit, onCellClick, drillDown, defaultsOf, nameOf, infoOf]
|
|
3424
3431
|
);
|
|
3425
|
-
const doExport = useExport({ fileName, result, encoded, exportData, locale, labels, limits, root, chartRef, announce, onExport, title: viewName, source: sourceName, loadECharts });
|
|
3432
|
+
const { run: doExport, prepare: prepareExport } = useExport({ fileName, result, encoded, exportData, locale, labels, limits, root, chartRef, announce, onExport, title: viewName, source: sourceName, loadECharts });
|
|
3426
3433
|
const requestImport = () => loadImport().then((m) => (flushSync(() => setImportMod(() => m)), m));
|
|
3427
3434
|
const api = {
|
|
3428
3435
|
imported,
|
|
@@ -3526,7 +3533,7 @@ function Report(props) {
|
|
|
3526
3533
|
applyLoaded
|
|
3527
3534
|
};
|
|
3528
3535
|
const viaSheet = (made, name, then) => imported && importMod ? importMod.openOnSheet(apiNow.current, made, name, then) : "none";
|
|
3529
|
-
const loadTemplate =
|
|
3536
|
+
const loadTemplate = useCallback10(
|
|
3530
3537
|
(t) => {
|
|
3531
3538
|
const tag = { name: t.name, scope: t.scope === "user" ? "user" : "shared", store: t.at !== void 0, storeSource: t.sourceId ?? null, storeSheet: t.sheet ?? null, sourceId };
|
|
3532
3539
|
remember(tag, history.keyOf(t.view));
|
|
@@ -3578,7 +3585,7 @@ function Report(props) {
|
|
|
3578
3585
|
};
|
|
3579
3586
|
const viewStore = templateStore === "browser";
|
|
3580
3587
|
const storeName = viewsName(storageKey);
|
|
3581
|
-
const subscribeViews =
|
|
3588
|
+
const subscribeViews = useCallback10((callback) => viewStore ? subscribeItem(storeName, callback) : () => {
|
|
3582
3589
|
}, [viewStore, storeName]);
|
|
3583
3590
|
const viewsText = useSyncExternalStore3(subscribeViews, () => viewStore ? readItem(storeName, localStore()) : null, () => null);
|
|
3584
3591
|
const entries = useMemo8(
|
|
@@ -3687,10 +3694,10 @@ function Report(props) {
|
|
|
3687
3694
|
setLastDismissedKey(dismissedKey);
|
|
3688
3695
|
setOwn(JSON.parse(dismissedKey));
|
|
3689
3696
|
}
|
|
3690
|
-
const subscribe =
|
|
3697
|
+
const subscribe = useCallback10((callback) => subscribeStored(storageKey, callback), [storageKey]);
|
|
3691
3698
|
const storedRaw = useSyncExternalStore3(subscribe, () => readStored(storageKey, localStore()), () => null);
|
|
3692
3699
|
const dismissed = useMemo8(() => cleanDismissed([...own2, ...parseStored(storedRaw)]), [own2, storedRaw]);
|
|
3693
|
-
const changeDismissed =
|
|
3700
|
+
const changeDismissed = useCallback10(
|
|
3694
3701
|
(next, id) => {
|
|
3695
3702
|
setOwn(next);
|
|
3696
3703
|
writeDismissed(storageKey, localStore(), next);
|
|
@@ -3873,8 +3880,8 @@ function Report(props) {
|
|
|
3873
3880
|
onLoadTemplate: openTemplate,
|
|
3874
3881
|
templateActions,
|
|
3875
3882
|
onExport: doExport,
|
|
3876
|
-
prepareExport
|
|
3877
|
-
dataExport: exportData,
|
|
3883
|
+
prepareExport,
|
|
3884
|
+
dataExport: { exportData, encoded },
|
|
3878
3885
|
chartReady: view.display === "chart" && chartReady,
|
|
3879
3886
|
empty,
|
|
3880
3887
|
onShowFields: () => setDrawer(true),
|
|
@@ -3956,7 +3963,7 @@ function Report(props) {
|
|
|
3956
3963
|
},
|
|
3957
3964
|
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 ?? "") })
|
|
3958
3965
|
}
|
|
3959
|
-
) : gridState.grid ? /* @__PURE__ */ React12.createElement(PivotTable, { grid: gridState.grid, view, labels, version: history.viewKey, hintId: view.values.length ? hintId : void 0, onRowLabel: setRowLabel, infoOf, showInfo: fieldSwitch.on, typeOf, hostOrdered, onSort: sortFromHeader, onToggle: (axis, path) => commit(toggleCollapsed(view, axis, path), { step: "collapse" }), onCell: (cell) => openCell(cell) }) : null), /* @__PURE__ */ React12.createElement("div", { className: "pk-status" }, /* @__PURE__ */ React12.createElement("span", { "data-testid": "row-count" }, result ? plural(labels.rowsCount, result.rows.length, { lang: labels.lang, locale }) : ""), importMod ? /* @__PURE__ */ React12.createElement(importMod.SourceLine, { api }) : null, rowLabel && showTable ? /* @__PURE__ */ React12.createElement("span", { className: "pk-row-label", "data-testid": "row-label" }, fill(labels.rowLabel, { label: rowLabel })) : null), /* @__PURE__ */ React12.createElement("div", { className: "pk-toast-dock" }, /* @__PURE__ */ React12.createElement(Toasts, { toasts, dismiss, pause, closeLabel: labels.close }))), drill ? /* @__PURE__ */ React12.createElement(MenuPanel, { name: "DrillPanel", props: { drill, onClose: () => setDrill(null), labels, locale, exportContext: { encoded, onExport, announce, root } } }) : null),
|
|
3966
|
+
) : gridState.grid ? /* @__PURE__ */ React12.createElement(PivotTable, { grid: gridState.grid, view, labels, version: history.viewKey, hintId: view.values.length ? hintId : void 0, onRowLabel: setRowLabel, infoOf, showInfo: fieldSwitch.on, typeOf, hostOrdered, onSort: sortFromHeader, onToggle: (axis, path) => commit(toggleCollapsed(view, axis, path), { step: "collapse" }), onCell: (cell) => openCell(cell) }) : null), /* @__PURE__ */ React12.createElement("div", { className: "pk-status" }, /* @__PURE__ */ React12.createElement("span", { "data-testid": "row-count" }, result ? plural(labels.rowsCount, result.rows.length, { lang: labels.lang, locale }) : ""), importMod ? /* @__PURE__ */ React12.createElement(importMod.SourceLine, { api }) : null, rowLabel && showTable ? /* @__PURE__ */ React12.createElement("span", { className: "pk-row-label", "data-testid": "row-label" }, fill(labels.rowLabel, { label: rowLabel })) : null), /* @__PURE__ */ React12.createElement("div", { className: "pk-toast-dock" }, /* @__PURE__ */ React12.createElement(Toasts, { toasts, dismiss, pause, closeLabel: labels.close }))), drill ? /* @__PURE__ */ React12.createElement(MenuPanel, { name: "DrillPanel", props: { drill, onClose: () => setDrill(null), labels, locale, exportContext: { encoded, onExport, announce, root, exportData } } }) : null),
|
|
3960
3967
|
filterTarget ? /* @__PURE__ */ React12.createElement(MenuPanel, { name: "FilterPopover", props: { target: filterTarget, onClose: closeFilter, view, encoded, locale, labels, commit } }) : null
|
|
3961
3968
|
), allowImport && importMod ? /* @__PURE__ */ React12.createElement(importMod.ImportLayer, { api, input: fileInput }) : null, /* @__PURE__ */ React12.createElement("div", { className: "pk-layer", ref: setLayer }, /* @__PURE__ */ React12.createElement("span", { className: "pk-origin", "aria-hidden": "true" })))))
|
|
3962
3969
|
);
|