pivotkit-react 0.6.1 → 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 +46 -1
- package/dist/chunks/{chunk-3LDE2GPG.js → chunk-4WZ5F2TJ.js} +1 -1
- package/dist/chunks/{chunk-JOWAEZAD.js → chunk-JAOOFDNR.js} +21 -1
- package/dist/chunks/{report-run-BZBFOMPF.js → report-run-HU4WPOB7.js} +3 -1
- package/dist/import-ui.js +1 -1
- package/dist/index.js +52 -49
- package/dist/menus.js +176 -99
- package/dist/styles.css +3 -0
- package/package.json +8 -4
- package/styles.css.d.ts +3 -0
- package/types/export-run.d.ts +12 -0
- package/types/menus.d.ts +1 -1
- 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 +9 -5
- package/types/use-export.d.ts +8 -4
- package/types/light-tokens.d.ts +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,50 @@ All notable changes to `pivotkit-react` are documented in this file. The format
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.7.0] - 2026-11-16
|
|
10
|
+
|
|
11
|
+
### Upgrading from 0.6
|
|
12
|
+
|
|
13
|
+
What a host checks; the [upgrade page](https://pivotkit.eize.dev/getting-started/upgrading/#from-0-6-1) has the details.
|
|
14
|
+
|
|
15
|
+
- Export → HTML report carries the host's dark colours too. On a dark screen a colour scale's middle
|
|
16
|
+
colour (`--pk-scale-mid`) is the one your dark theme sets, not the light one; without it the cells
|
|
17
|
+
run halfway between the dark low and high colours ([upgrading](https://pivotkit.eize.dev/getting-started/upgrading/#dark-mid-colour)).
|
|
18
|
+
- A field's Filter level shows its rules in a single column as wide as the menu, in every browser.
|
|
19
|
+
Tests or screenshots of that form take the new layout.
|
|
20
|
+
- pivotkit-core moves to `^0.7.0` and pivotkit-report to `^0.3.0` with it.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- Depends on `pivotkit-core` `^0.7.0` (was `^0.6.1`) and `pivotkit-report` `^0.3.0` (was `^0.2.1`): a host
|
|
25
|
+
that also lists pivotkit-core updates both together, or it gets two copies.
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- The rules in a field's Filter level show in the WebKit of Playwright 1.65 (build 2388): the rule
|
|
30
|
+
list stacked in a wrapping column got no size there, so a new rule's row and its value field could
|
|
31
|
+
not be seen or used. The rules form is a single column as wide as the menu, each row with room for
|
|
32
|
+
its value, in every browser. Whether a Safari release shows the same fault was not checked
|
|
33
|
+
([#474](https://github.com/eizedev/pivotkit/issues/474)).
|
|
34
|
+
- Export → HTML report carries the host's dark colours too (pivotkit-report's `darkTokens`), read
|
|
35
|
+
from the report's dark theme whichever theme it shows: a reader on a dark screen sees the host's
|
|
36
|
+
dark design, not pivotkit's default dark colours. Paper and a print stay light. The report's
|
|
37
|
+
`--pk-scale-mid` on a dark screen is the one your dark theme resolves (pivotkit-report no longer
|
|
38
|
+
takes the light one there) ([#385](https://github.com/eizedev/pivotkit/issues/385)).
|
|
39
|
+
- Print or save as PDF opens the print dialog in the click itself: the Export menu makes the print
|
|
40
|
+
frame ready when it opens, and the report's modules load when Print is pointed at or focused. A
|
|
41
|
+
page hidden while it printed (it gets no animation frame) did not print at all. Safari still asks
|
|
42
|
+
"This webpage is trying to print" after a cancelled print dialog: that is Safari's own rule
|
|
43
|
+
([print or save as PDF](https://pivotkit.eize.dev/use/export/)) ([#210](https://github.com/eizedev/pivotkit/issues/210)).
|
|
44
|
+
- A second click on a menu's button closes the menu in Safari and other WebKit browsers, as in the
|
|
45
|
+
others: the toolbar's menus (Export, Views, Data, Start over, More) and a field's chip menu. WebKit
|
|
46
|
+
does not focus a clicked button, so the press moved the focus out of the menu, which closed it,
|
|
47
|
+
and the click opened it again ([#393](https://github.com/eizedev/pivotkit/issues/393)).
|
|
48
|
+
- `import "pivotkit-react/styles.css"` compiles in a strict TypeScript project without a bundler's
|
|
49
|
+
CSS types: the stylesheet ships its own declaration (`styles.css.d.ts`, the `types` condition of
|
|
50
|
+
its export); TypeScript answered TS2882 before
|
|
51
|
+
([#165](https://github.com/eizedev/pivotkit/issues/165)).
|
|
52
|
+
|
|
9
53
|
## [0.6.1] - 2026-11-14
|
|
10
54
|
|
|
11
55
|
### Added
|
|
@@ -1049,7 +1093,8 @@ First release.
|
|
|
1049
1093
|
weather (Open-Meteo), countries (World Bank), earthquakes (USGS), Nobel laureates and the release
|
|
1050
1094
|
cycles of software products (endoflife.date).
|
|
1051
1095
|
|
|
1052
|
-
[Unreleased]: https://github.com/eizedev/pivotkit/compare/pivotkit-react@0.
|
|
1096
|
+
[Unreleased]: https://github.com/eizedev/pivotkit/compare/pivotkit-react@0.7.0...HEAD
|
|
1097
|
+
[0.7.0]: https://github.com/eizedev/pivotkit/compare/pivotkit-react@0.6.1...pivotkit-react@0.7.0
|
|
1053
1098
|
[0.6.1]: https://github.com/eizedev/pivotkit/compare/pivotkit-react@0.6.0...pivotkit-react@0.6.1
|
|
1054
1099
|
[0.6.0]: https://github.com/eizedev/pivotkit/compare/pivotkit-react@0.5.0...pivotkit-react@0.6.0
|
|
1055
1100
|
[0.5.0]: https://github.com/eizedev/pivotkit/compare/pivotkit-react@0.4.0...pivotkit-react@0.5.0
|
|
@@ -302,6 +302,7 @@ function onTheWay(anchor, popover, point) {
|
|
|
302
302
|
}
|
|
303
303
|
|
|
304
304
|
// src/popover.jsx
|
|
305
|
+
var PRESS_MS = 1e3;
|
|
305
306
|
var LayerContext = createContext2({ layer: (
|
|
306
307
|
/** @type {HTMLElement | null} */
|
|
307
308
|
null
|
|
@@ -428,6 +429,8 @@ function Popover({ open, anchor, onClose, label, role = "dialog", align = "start
|
|
|
428
429
|
};
|
|
429
430
|
}, [open, anchor, align, sheet, layer, fill]);
|
|
430
431
|
useEscapeLayer(open, onClose);
|
|
432
|
+
const pressedAt = useRef2(0);
|
|
433
|
+
const pressedAway = (to) => pressedAt.current > 0 && performance.now() - pressedAt.current < PRESS_MS && Boolean(anchor.current && to.contains(anchor.current));
|
|
431
434
|
const closeRef = useRef2(onClose);
|
|
432
435
|
useEffect3(() => {
|
|
433
436
|
closeRef.current = onClose;
|
|
@@ -446,12 +449,24 @@ function Popover({ open, anchor, onClose, label, role = "dialog", align = "start
|
|
|
446
449
|
first?.focus({ preventScroll: true });
|
|
447
450
|
});
|
|
448
451
|
const onDown = (e) => {
|
|
452
|
+
pressedAt.current = eventWithin(e, [anchor.current]) ? performance.now() : 0;
|
|
449
453
|
if (!eventWithin(e, [el, anchor.current]) && !e.composedPath().some((n) => n instanceof Element && n !== el && n.getAttribute("data-pk-parent") === elId)) {
|
|
450
454
|
closeRef.current();
|
|
451
455
|
}
|
|
452
456
|
};
|
|
457
|
+
const onUp = () => {
|
|
458
|
+
if (pressedAt.current) pressedAt.current = performance.now();
|
|
459
|
+
};
|
|
460
|
+
const onPressEnd = () => {
|
|
461
|
+
pressedAt.current = 0;
|
|
462
|
+
};
|
|
453
463
|
const doc = el?.ownerDocument ?? document;
|
|
464
|
+
const win = doc.defaultView;
|
|
454
465
|
doc.addEventListener("pointerdown", onDown, true);
|
|
466
|
+
doc.addEventListener("pointerup", onUp, true);
|
|
467
|
+
doc.addEventListener("click", onPressEnd, true);
|
|
468
|
+
doc.addEventListener("pointercancel", onPressEnd, true);
|
|
469
|
+
win?.addEventListener("blur", onPressEnd);
|
|
455
470
|
const onWheel = (e) => {
|
|
456
471
|
if (el && !e.ctrlKey && !wheelScrollsInside(e.composedPath(), el, e.deltaX, e.deltaY)) {
|
|
457
472
|
e.preventDefault();
|
|
@@ -462,6 +477,11 @@ function Popover({ open, anchor, onClose, label, role = "dialog", align = "start
|
|
|
462
477
|
return () => {
|
|
463
478
|
cancelAnimationFrame(t);
|
|
464
479
|
doc.removeEventListener("pointerdown", onDown, true);
|
|
480
|
+
doc.removeEventListener("pointerup", onUp, true);
|
|
481
|
+
doc.removeEventListener("click", onPressEnd, true);
|
|
482
|
+
doc.removeEventListener("pointercancel", onPressEnd, true);
|
|
483
|
+
win?.removeEventListener("blur", onPressEnd);
|
|
484
|
+
pressedAt.current = 0;
|
|
465
485
|
el?.removeEventListener("wheel", onWheel);
|
|
466
486
|
const now = activeIn(button);
|
|
467
487
|
if (button && button.isConnected && (!now || now === doc.body || el?.contains(now) || !now.isConnected)) {
|
|
@@ -528,7 +548,7 @@ function Popover({ open, anchor, onClose, label, role = "dialog", align = "start
|
|
|
528
548
|
/** @type {Node | null} */
|
|
529
549
|
e.relatedTarget
|
|
530
550
|
);
|
|
531
|
-
if (to && !ref.current?.contains(to) && !anchor.current?.contains(to) && !(to instanceof Element && [...to.ownerDocument.querySelectorAll(".pk-popover")].some((p) => p.contains(to) && within(p)))) {
|
|
551
|
+
if (to && !pressedAway(to) && !ref.current?.contains(to) && !anchor.current?.contains(to) && !(to instanceof Element && [...to.ownerDocument.querySelectorAll(".pk-popover")].some((p) => p.contains(to) && within(p)))) {
|
|
532
552
|
onClose();
|
|
533
553
|
}
|
|
534
554
|
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// src/report-run.js
|
|
2
2
|
import { use as register } from "echarts/core";
|
|
3
3
|
import { SVGRenderer } from "echarts/renderers";
|
|
4
|
-
import { LIGHT_TOKENS, SHAPE_TOKENS, SIZE_TOKENS, WEIGHT_TOKENS, render } from "pivotkit-report";
|
|
4
|
+
import { DARK_TOKENS, LIGHT_TOKENS, SHAPE_TOKENS, SIZE_TOKENS, WEIGHT_TOKENS, render } from "pivotkit-report";
|
|
5
5
|
register([SVGRenderer]);
|
|
6
6
|
var REPORT_TOKENS = Object.freeze([...Object.keys(WEIGHT_TOKENS), ...Object.keys(SHAPE_TOKENS), ...Object.keys(LIGHT_TOKENS), "--pk-scale-mid"]);
|
|
7
|
+
var REPORT_DARK_TOKENS = Object.freeze([...Object.keys(DARK_TOKENS), "--pk-scale-mid"]);
|
|
7
8
|
var REPORT_LENGTHS = Object.freeze(Object.keys(SIZE_TOKENS));
|
|
8
9
|
export {
|
|
10
|
+
REPORT_DARK_TOKENS,
|
|
9
11
|
REPORT_LENGTHS,
|
|
10
12
|
REPORT_TOKENS,
|
|
11
13
|
render
|
package/dist/import-ui.js
CHANGED
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,7 +2145,7 @@ 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
|
|
@@ -2201,7 +2204,7 @@ function schemaKeyOf(encoded) {
|
|
|
2201
2204
|
function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outsideNote, orderOf, dataKey = 0, initial: initialState = null }) {
|
|
2202
2205
|
const controlled = view !== void 0;
|
|
2203
2206
|
const schema = useMemo6(() => `${dataKey}|${schemaKeyOf(encoded)}`, [encoded, dataKey]);
|
|
2204
|
-
const json =
|
|
2207
|
+
const json = useCallback7(
|
|
2205
2208
|
(v) => {
|
|
2206
2209
|
const normalized = normalize(v ?? emptyView(), encoded, { limits }).view;
|
|
2207
2210
|
const ordered = orderOf ? withHostOrders(normalized, orderOf) : normalized;
|
|
@@ -2231,7 +2234,7 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2231
2234
|
), [shown]);
|
|
2232
2235
|
const waiting = viewKey !== null && pending3.length > 0 && state.schema === schema;
|
|
2233
2236
|
const live = useMemo6(() => waiting ? state : settle(state, { schema, start, shown, outside: outsideNote }), [waiting, state, schema, start, shown, outsideNote]);
|
|
2234
|
-
const apply =
|
|
2237
|
+
const apply = useCallback7(
|
|
2235
2238
|
(next) => {
|
|
2236
2239
|
setState(next);
|
|
2237
2240
|
if (viewKey !== null) {
|
|
@@ -2241,7 +2244,7 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2241
2244
|
},
|
|
2242
2245
|
[onViewChange, viewKey, pending3]
|
|
2243
2246
|
);
|
|
2244
|
-
const commit =
|
|
2247
|
+
const commit = useCallback7(
|
|
2245
2248
|
(next, note, tag) => {
|
|
2246
2249
|
const s = record(live, json(next), note, tag === void 0 ? live.tag : tag);
|
|
2247
2250
|
if (s.present === live.present) {
|
|
@@ -2255,22 +2258,22 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2255
2258
|
},
|
|
2256
2259
|
[live, json, apply]
|
|
2257
2260
|
);
|
|
2258
|
-
const setTag =
|
|
2259
|
-
const undo2 =
|
|
2261
|
+
const setTag = useCallback7((tag) => setState((s) => ({ ...s, tag })), []);
|
|
2262
|
+
const undo2 = useCallback7(() => {
|
|
2260
2263
|
const { state: s, note } = undo(live);
|
|
2261
2264
|
if (note !== null) {
|
|
2262
2265
|
apply(s);
|
|
2263
2266
|
}
|
|
2264
2267
|
return note;
|
|
2265
2268
|
}, [live, apply]);
|
|
2266
|
-
const redo2 =
|
|
2269
|
+
const redo2 = useCallback7(() => {
|
|
2267
2270
|
const { state: s, note } = redo(live);
|
|
2268
2271
|
if (note !== null) {
|
|
2269
2272
|
apply(s);
|
|
2270
2273
|
}
|
|
2271
2274
|
return note;
|
|
2272
2275
|
}, [live, apply]);
|
|
2273
|
-
const reset2 =
|
|
2276
|
+
const reset2 = useCallback7(
|
|
2274
2277
|
(note) => {
|
|
2275
2278
|
const s = reset(live, note);
|
|
2276
2279
|
if (s.present !== live.present) {
|
|
@@ -2281,9 +2284,9 @@ function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outs
|
|
|
2281
2284
|
},
|
|
2282
2285
|
[live, apply]
|
|
2283
2286
|
);
|
|
2284
|
-
const restore =
|
|
2285
|
-
const snapshot =
|
|
2286
|
-
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]);
|
|
2287
2290
|
const canUndo = live.past.length > 0;
|
|
2288
2291
|
const canRedo = live.future.length > 0;
|
|
2289
2292
|
const canReset = live.present !== live.start;
|
|
@@ -2318,7 +2321,7 @@ function keptData(key, host) {
|
|
|
2318
2321
|
}
|
|
2319
2322
|
|
|
2320
2323
|
// src/use-big-result.js
|
|
2321
|
-
import { useCallback as
|
|
2324
|
+
import { useCallback as useCallback8, useEffect as useEffect9, useRef as useRef9, useState as useState10, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
2322
2325
|
function fullScreenSupported() {
|
|
2323
2326
|
return typeof document !== "undefined" && Boolean(document.fullscreenEnabled) && typeof HTMLElement !== "undefined" && typeof HTMLElement.prototype.requestFullscreen === "function";
|
|
2324
2327
|
}
|
|
@@ -2341,7 +2344,7 @@ function useBigResult(root) {
|
|
|
2341
2344
|
doc.addEventListener("fullscreenchange", sync);
|
|
2342
2345
|
return () => doc.removeEventListener("fullscreenchange", sync);
|
|
2343
2346
|
}, [root]);
|
|
2344
|
-
const toggleEnlarged =
|
|
2347
|
+
const toggleEnlarged = useCallback8(() => setEnlarged((on) => !on), []);
|
|
2345
2348
|
const toggleFull = () => {
|
|
2346
2349
|
const el = root.current;
|
|
2347
2350
|
if (!el) {
|
|
@@ -2403,7 +2406,7 @@ function measureFit(el, m, fit) {
|
|
|
2403
2406
|
}
|
|
2404
2407
|
|
|
2405
2408
|
// src/zones.jsx
|
|
2406
|
-
import React11, { useCallback as
|
|
2409
|
+
import React11, { useCallback as useCallback9, useEffect as useEffect10, useMemo as useMemo7, useRef as useRef10, useState as useState11 } from "react";
|
|
2407
2410
|
import { fieldItems, fieldLabel as fieldLabel4 } from "pivotkit-core";
|
|
2408
2411
|
function fieldState(view, field, encoded, locale, labels, sourceType) {
|
|
2409
2412
|
const items = filtersOf(view, field, ["in"]).filter((f) => !isEmptyPick(f));
|
|
@@ -2563,7 +2566,7 @@ function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap,
|
|
|
2563
2566
|
}
|
|
2564
2567
|
return map;
|
|
2565
2568
|
}, [entries, view, encoded, locale, labels]);
|
|
2566
|
-
const rangeOf =
|
|
2569
|
+
const rangeOf = useCallback9((field) => numberRange(encoded, field), [encoded]);
|
|
2567
2570
|
const root = useRef10(
|
|
2568
2571
|
/** @type {HTMLDivElement | null} */
|
|
2569
2572
|
null
|
|
@@ -2930,9 +2933,9 @@ function Report(props) {
|
|
|
2930
2933
|
const chartRef = useRef11(null);
|
|
2931
2934
|
const [chartReady, setChartReady] = useState12(false);
|
|
2932
2935
|
const hintId = useId4();
|
|
2933
|
-
const closeFilter =
|
|
2936
|
+
const closeFilter = useCallback10(() => setFilterTarget(null), []);
|
|
2934
2937
|
const { toasts, push, dismiss, pause } = useToasts();
|
|
2935
|
-
const announce =
|
|
2938
|
+
const announce = useCallback10(
|
|
2936
2939
|
/** @param {string} text @param {{ action?: { label: string, run: () => void }, tone?: "error" }} [extra] */
|
|
2937
2940
|
(text, extra) => push({ text, ...extra }),
|
|
2938
2941
|
[push]
|
|
@@ -3003,13 +3006,13 @@ function Report(props) {
|
|
|
3003
3006
|
const notes2 = unusedNotes(normalize2(raw, encoded, { limits }).issues, raw);
|
|
3004
3007
|
return notes2.length ? { notes: notes2, loaded: JSON.parse(keyOf(raw)) } : null;
|
|
3005
3008
|
}, [hostKey, loading2, imported, encoded, limits, keyOf]);
|
|
3006
|
-
const leaveOut =
|
|
3009
|
+
const leaveOut = useCallback10((notes2, given2) => setLeftOut({ notes: notes2, loaded: given2 ? JSON.parse(keyOf(given2)) : null, after: hostKey }), [keyOf, hostKey]);
|
|
3007
3010
|
const loadedView = tagFor(history.tag, sourceId);
|
|
3008
3011
|
const viewName = loadedView?.name ?? null;
|
|
3009
3012
|
const unsaved = Boolean(loadedView) && savedKeys[savedKeyOf(loadedView)] !== history.viewKey;
|
|
3010
3013
|
const chartOptionsKey = optionsKey(chartOptions);
|
|
3011
3014
|
const stableChartOptions = useMemo8(() => chartOptions, [chartOptionsKey]);
|
|
3012
|
-
const stepText =
|
|
3015
|
+
const stepText = useCallback10(
|
|
3013
3016
|
(note) => {
|
|
3014
3017
|
const template = Object.hasOwn(labels.steps, note.step) ? labels.steps[note.step] : labels.steps.change;
|
|
3015
3018
|
return fill(template, {
|
|
@@ -3038,12 +3041,12 @@ function Report(props) {
|
|
|
3038
3041
|
announce(fill(labels.toastRedone, { step: note }));
|
|
3039
3042
|
}
|
|
3040
3043
|
};
|
|
3041
|
-
const newStep =
|
|
3044
|
+
const newStep = useCallback10(() => setDataSteps((s) => s.future.length ? { past: s.past, future: [] } : s), []);
|
|
3042
3045
|
const undoLater = useRef11(undo2);
|
|
3043
3046
|
useEffect11(() => {
|
|
3044
3047
|
undoLater.current = undo2;
|
|
3045
3048
|
});
|
|
3046
|
-
const reset2 =
|
|
3049
|
+
const reset2 = useCallback10(() => {
|
|
3047
3050
|
history.reset(labels.steps.reset);
|
|
3048
3051
|
newStep();
|
|
3049
3052
|
announce(labels.toastReset, { action: { label: labels.undo, run: () => undoLater.current() } });
|
|
@@ -3064,7 +3067,7 @@ function Report(props) {
|
|
|
3064
3067
|
/** @type {null | { lines: string[], quiet: boolean, load: () => void, switchTo?: { name: string, run: () => void } }} */
|
|
3065
3068
|
null
|
|
3066
3069
|
);
|
|
3067
|
-
const openLink =
|
|
3070
|
+
const openLink = useCallback10((text, asStep = false) => {
|
|
3068
3071
|
appliedLink.current = text;
|
|
3069
3072
|
const now = linkNow();
|
|
3070
3073
|
const apply = (m) => {
|
|
@@ -3157,7 +3160,7 @@ function Report(props) {
|
|
|
3157
3160
|
writeStoredView(storageKey, sessionStore(), JSON.parse(history.viewKey));
|
|
3158
3161
|
}
|
|
3159
3162
|
}, [persistView, storageKey, history.viewKey]);
|
|
3160
|
-
const commit =
|
|
3163
|
+
const commit = useCallback10(
|
|
3161
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) */
|
|
3162
3165
|
(next, note = { step: "change" }, tag = void 0) => {
|
|
3163
3166
|
const over = note.step === "template" ? null : zoneOverLimit(next, limits);
|
|
@@ -3178,8 +3181,8 @@ function Report(props) {
|
|
|
3178
3181
|
},
|
|
3179
3182
|
[history, stepText, labels, announce, limits, locale, newStep]
|
|
3180
3183
|
);
|
|
3181
|
-
const remember =
|
|
3182
|
-
const applyLoaded =
|
|
3184
|
+
const remember = useCallback10((tag, key) => setSavedKeys((all) => ({ ...all, [savedKeyOf(tag)]: key })), []);
|
|
3185
|
+
const applyLoaded = useCallback10(
|
|
3183
3186
|
/** @param {import("./share.js").LoadedView} loaded @param {{ link?: boolean, restored?: boolean }} [how] */
|
|
3184
3187
|
(loaded3, { link = false, restored: restored2 = false } = {}) => {
|
|
3185
3188
|
if (!loaded3.view) {
|
|
@@ -3250,11 +3253,11 @@ function Report(props) {
|
|
|
3250
3253
|
const error = source.error ?? computed.error ?? gridState.error ?? (view.display === "chart" ? chartComputed.error : null);
|
|
3251
3254
|
const fields = encoded.schema.fields;
|
|
3252
3255
|
const types = useMemo8(() => new Map(viewFields(view, encoded).map((f) => [f.name.toLowerCase(), f.type])), [view, encoded]);
|
|
3253
|
-
const typeOf =
|
|
3254
|
-
const nameOf =
|
|
3255
|
-
const hostOrdered =
|
|
3256
|
-
const sortFromHeader =
|
|
3257
|
-
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(
|
|
3258
3261
|
(field) => {
|
|
3259
3262
|
if (!field || info.size === 0) {
|
|
3260
3263
|
return void 0;
|
|
@@ -3350,8 +3353,8 @@ function Report(props) {
|
|
|
3350
3353
|
panelRef.current.inert = size === "narrow" && !drawerOpen;
|
|
3351
3354
|
}
|
|
3352
3355
|
}, [size, drawerOpen]);
|
|
3353
|
-
const defaultsOf =
|
|
3354
|
-
const placeOptions =
|
|
3356
|
+
const defaultsOf = useCallback10((field) => fieldDefaultsFor(fieldDefaults, field, encoded.column(field)), [fieldDefaults, encoded]);
|
|
3357
|
+
const placeOptions = useCallback10(
|
|
3355
3358
|
(field, zone, index = void 0) => {
|
|
3356
3359
|
const column = encoded.column(field);
|
|
3357
3360
|
const unit = zone !== "values" && column && column.type === "date" && !column.derived ? suggestDateUnit(encoded, field) : null;
|
|
@@ -3359,14 +3362,14 @@ function Report(props) {
|
|
|
3359
3362
|
},
|
|
3360
3363
|
[encoded, typeOf, defaultsOf, labels, nameOf]
|
|
3361
3364
|
);
|
|
3362
|
-
const addTo =
|
|
3365
|
+
const addTo = useCallback10(
|
|
3363
3366
|
(field, zone, index = void 0) => {
|
|
3364
3367
|
const options = placeOptions(field, zone, index);
|
|
3365
3368
|
commit(addField(view, field, zone, options), { step: "added", field: options.groupName ?? nameOf(field), zone });
|
|
3366
3369
|
},
|
|
3367
3370
|
[view, placeOptions, commit, nameOf]
|
|
3368
3371
|
);
|
|
3369
|
-
const filterField =
|
|
3372
|
+
const filterField = useCallback10(
|
|
3370
3373
|
(field, anchor) => {
|
|
3371
3374
|
const options = placeOptions(field, "filters");
|
|
3372
3375
|
const name = options.groupName ?? field;
|
|
@@ -3385,7 +3388,7 @@ function Report(props) {
|
|
|
3385
3388
|
},
|
|
3386
3389
|
[placeOptions, view, size]
|
|
3387
3390
|
);
|
|
3388
|
-
const onDrop =
|
|
3391
|
+
const onDrop = useCallback10(
|
|
3389
3392
|
(src, target) => {
|
|
3390
3393
|
setDragAt((at) => at ?? changesRef.current + 1);
|
|
3391
3394
|
if (target.zone === "panel") {
|
|
@@ -3407,7 +3410,7 @@ function Report(props) {
|
|
|
3407
3410
|
},
|
|
3408
3411
|
[view, typeOf, commit, addTo, defaultsOf]
|
|
3409
3412
|
);
|
|
3410
|
-
const openCell =
|
|
3413
|
+
const openCell = useCallback10(
|
|
3411
3414
|
/** @param {any} cell */
|
|
3412
3415
|
({ rowPath = [], colPath = [], value, valueIndex, text }) => {
|
|
3413
3416
|
if (!result) {
|
|
@@ -3426,7 +3429,7 @@ function Report(props) {
|
|
|
3426
3429
|
},
|
|
3427
3430
|
[result, encodedProp, imported, data, drillDownLimit, onCellClick, drillDown, defaultsOf, nameOf, infoOf]
|
|
3428
3431
|
);
|
|
3429
|
-
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 });
|
|
3430
3433
|
const requestImport = () => loadImport().then((m) => (flushSync(() => setImportMod(() => m)), m));
|
|
3431
3434
|
const api = {
|
|
3432
3435
|
imported,
|
|
@@ -3530,7 +3533,7 @@ function Report(props) {
|
|
|
3530
3533
|
applyLoaded
|
|
3531
3534
|
};
|
|
3532
3535
|
const viaSheet = (made, name, then) => imported && importMod ? importMod.openOnSheet(apiNow.current, made, name, then) : "none";
|
|
3533
|
-
const loadTemplate =
|
|
3536
|
+
const loadTemplate = useCallback10(
|
|
3534
3537
|
(t) => {
|
|
3535
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 };
|
|
3536
3539
|
remember(tag, history.keyOf(t.view));
|
|
@@ -3582,7 +3585,7 @@ function Report(props) {
|
|
|
3582
3585
|
};
|
|
3583
3586
|
const viewStore = templateStore === "browser";
|
|
3584
3587
|
const storeName = viewsName(storageKey);
|
|
3585
|
-
const subscribeViews =
|
|
3588
|
+
const subscribeViews = useCallback10((callback) => viewStore ? subscribeItem(storeName, callback) : () => {
|
|
3586
3589
|
}, [viewStore, storeName]);
|
|
3587
3590
|
const viewsText = useSyncExternalStore3(subscribeViews, () => viewStore ? readItem(storeName, localStore()) : null, () => null);
|
|
3588
3591
|
const entries = useMemo8(
|
|
@@ -3691,10 +3694,10 @@ function Report(props) {
|
|
|
3691
3694
|
setLastDismissedKey(dismissedKey);
|
|
3692
3695
|
setOwn(JSON.parse(dismissedKey));
|
|
3693
3696
|
}
|
|
3694
|
-
const subscribe =
|
|
3697
|
+
const subscribe = useCallback10((callback) => subscribeStored(storageKey, callback), [storageKey]);
|
|
3695
3698
|
const storedRaw = useSyncExternalStore3(subscribe, () => readStored(storageKey, localStore()), () => null);
|
|
3696
3699
|
const dismissed = useMemo8(() => cleanDismissed([...own2, ...parseStored(storedRaw)]), [own2, storedRaw]);
|
|
3697
|
-
const changeDismissed =
|
|
3700
|
+
const changeDismissed = useCallback10(
|
|
3698
3701
|
(next, id) => {
|
|
3699
3702
|
setOwn(next);
|
|
3700
3703
|
writeDismissed(storageKey, localStore(), next);
|
|
@@ -3877,7 +3880,7 @@ function Report(props) {
|
|
|
3877
3880
|
onLoadTemplate: openTemplate,
|
|
3878
3881
|
templateActions,
|
|
3879
3882
|
onExport: doExport,
|
|
3880
|
-
prepareExport
|
|
3883
|
+
prepareExport,
|
|
3881
3884
|
dataExport: { exportData, encoded },
|
|
3882
3885
|
chartReady: view.display === "chart" && chartReady,
|
|
3883
3886
|
empty,
|
package/dist/menus.js
CHANGED
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
withLinkParam,
|
|
61
61
|
yearOf,
|
|
62
62
|
yearText
|
|
63
|
-
} from "./chunks/chunk-
|
|
63
|
+
} from "./chunks/chunk-4WZ5F2TJ.js";
|
|
64
64
|
import {
|
|
65
65
|
addMenuTexts,
|
|
66
66
|
hasMenuTexts,
|
|
@@ -83,7 +83,7 @@ import {
|
|
|
83
83
|
useFormName,
|
|
84
84
|
useIsoLayoutEffect,
|
|
85
85
|
useModal
|
|
86
|
-
} from "./chunks/chunk-
|
|
86
|
+
} from "./chunks/chunk-JAOOFDNR.js";
|
|
87
87
|
import {
|
|
88
88
|
fill,
|
|
89
89
|
hostFailure,
|
|
@@ -2931,7 +2931,7 @@ async function copyText(text, container) {
|
|
|
2931
2931
|
}
|
|
2932
2932
|
|
|
2933
2933
|
// src/version.js
|
|
2934
|
-
var VERSION = true ? "0.
|
|
2934
|
+
var VERSION = true ? "0.7.0" : "0.0.0-source";
|
|
2935
2935
|
|
|
2936
2936
|
// src/share-actions.js
|
|
2937
2937
|
var here = () => typeof location !== "undefined" ? location.href : void 0;
|
|
@@ -2993,28 +2993,28 @@ function shareActions(ctx, labels) {
|
|
|
2993
2993
|
if (!loaded.view) {
|
|
2994
2994
|
return labels.viewFailed[loaded.failed ?? "notView"] ?? labels.viewFailed.notView;
|
|
2995
2995
|
}
|
|
2996
|
-
const
|
|
2996
|
+
const ready2 = (
|
|
2997
2997
|
/** @type {import("./share.js").LoadedView} */
|
|
2998
2998
|
loaded
|
|
2999
2999
|
);
|
|
3000
|
-
const made =
|
|
3001
|
-
if (made &&
|
|
3000
|
+
const made = ready2.file?.source;
|
|
3001
|
+
if (made && ready2.file?.view && ctx.viaSheet?.({ id: made.id, sheet: sheetOfSource(made) }, ready2.file.name || viewName || "", toViewFile(ready2.file.view, { name: ready2.file.name, source: made })) === "switch") {
|
|
3002
3002
|
return null;
|
|
3003
3003
|
}
|
|
3004
|
-
const check = loadCheck(
|
|
3004
|
+
const check = loadCheck(ready2, labels, Array.isArray(ctx.sources) ? ctx.sources : []);
|
|
3005
3005
|
if (!check) {
|
|
3006
|
-
ctx.applyLoaded(
|
|
3006
|
+
ctx.applyLoaded(ready2);
|
|
3007
3007
|
return null;
|
|
3008
3008
|
}
|
|
3009
3009
|
const target = check.switchTo;
|
|
3010
3010
|
const switchTo = ctx.onSourceSwitch;
|
|
3011
3011
|
return {
|
|
3012
3012
|
lines: check.lines,
|
|
3013
|
-
load: () => ctx.applyLoaded(
|
|
3013
|
+
load: () => ctx.applyLoaded(ready2),
|
|
3014
3014
|
switchTo: target && typeof switchTo === "function" ? { name: target.name, run: () => switchTo({ source: { id: target.id, name: target.name }, view: (
|
|
3015
3015
|
/** @type {Record<string, unknown>} */
|
|
3016
|
-
|
|
3017
|
-
), name:
|
|
3016
|
+
ready2.file?.view ?? ready2.view
|
|
3017
|
+
), name: ready2.file?.name || void 0 }) } : void 0
|
|
3018
3018
|
};
|
|
3019
3019
|
}
|
|
3020
3020
|
};
|
|
@@ -3621,24 +3621,22 @@ function ViewsPanel({ templates, labels, onLoad, actions, close, share }) {
|
|
|
3621
3621
|
};
|
|
3622
3622
|
return /* @__PURE__ */ React7.createElement(LevelMenu, { name: labels.views, labels, topics, close, onPick: runChoice(close), panel, focusAgain: templates.length });
|
|
3623
3623
|
}
|
|
3624
|
-
function ExportOption({ icon, text, info, onSelect, testId, disabled, reason }) {
|
|
3624
|
+
function ExportOption({ icon, text, info, onSelect, testId, disabled, reason, onIntent }) {
|
|
3625
3625
|
const option = /* @__PURE__ */ React7.createElement(Option, { icon, onSelect, disabled, reason, testId }, text);
|
|
3626
|
-
return info ? /* @__PURE__ */ React7.createElement("div", { className: "pk-setting-row" }, option, /* @__PURE__ */ React7.createElement(SettingInfo, { id: (
|
|
3626
|
+
return info ? /* @__PURE__ */ React7.createElement("div", { className: "pk-setting-row", onPointerEnter: onIntent, onPointerDown: onIntent, onFocus: onIntent }, option, /* @__PURE__ */ React7.createElement(SettingInfo, { id: (
|
|
3627
3627
|
/** @type {any} */
|
|
3628
3628
|
info
|
|
3629
3629
|
), name: text })) : option;
|
|
3630
3630
|
}
|
|
3631
3631
|
function ExportPanel({ labels, onExport, chartReady, display, empty = false, dataExport, prepare, close }) {
|
|
3632
3632
|
const source = dataExport ? dataExportFor(dataExport.exportData, dataExport.encoded).source : false;
|
|
3633
|
-
useEffect3(() =>
|
|
3634
|
-
prepare();
|
|
3635
|
-
}, [prepare]);
|
|
3633
|
+
useEffect3(() => prepare("menu"), [prepare]);
|
|
3636
3634
|
const run = (kind) => () => {
|
|
3637
3635
|
close();
|
|
3638
3636
|
onExport(kind);
|
|
3639
3637
|
};
|
|
3640
3638
|
const off = empty ? { disabled: true, reason: labels.exportNeedsField } : {};
|
|
3641
|
-
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(Section, { title: labels.exportDownload }, /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportXlsx, info: "exportXlsx", onSelect: run("xlsx"), ...off, testId: "export-xlsx" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportCsv, info: "exportCsv", onSelect: run("csv"), ...off, testId: "export-csv" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportHtml, info: "exportHtml", onSelect: run("html"), ...off, testId: "export-html" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "image", text: labels.exportPng, disabled: empty || !chartReady, reason: empty ? off.reason : display !== "chart" ? labels.exportPngNeedsChart : void 0, onSelect: run("png"), testId: "export-png" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "image", text: labels.exportSvg, disabled: empty || display !== "chart", reason: empty ? off.reason : display !== "chart" ? labels.exportPngNeedsChart : void 0, onSelect: run("svg"), testId: "export-svg" })), /* @__PURE__ */ React7.createElement(Section, { title: labels.exportPrintGroup }, /* @__PURE__ */ React7.createElement(ExportOption, { icon: "print", text: labels.exportPrint, info: "exportPrint", onSelect: run("print"), ...off, testId: "export-print" })), /* @__PURE__ */ React7.createElement(Section, { title: labels.exportCopy }, /* @__PURE__ */ React7.createElement(ExportOption, { icon: "copy", text: labels.copyTable, info: "copyTable", onSelect: run("copy-table"), ...off, testId: "export-copy-table" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "copy", text: labels.copyDataJson, info: "copyDataJson", onSelect: run("copy-json"), ...off, testId: "export-copy-json" })), source ? /* @__PURE__ */ React7.createElement(Section, { title: labels.exportDataGroup }, /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportDataCsv, info: "exportDataCsv", onSelect: run("data-csv"), testId: "export-data-csv" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportDataJson, info: "exportDataJson", onSelect: run("data-json"), testId: "export-data-json" })) : null);
|
|
3639
|
+
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(Section, { title: labels.exportDownload }, /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportXlsx, info: "exportXlsx", onSelect: run("xlsx"), ...off, testId: "export-xlsx" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportCsv, info: "exportCsv", onSelect: run("csv"), ...off, testId: "export-csv" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportHtml, info: "exportHtml", onSelect: run("html"), ...off, testId: "export-html" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "image", text: labels.exportPng, disabled: empty || !chartReady, reason: empty ? off.reason : display !== "chart" ? labels.exportPngNeedsChart : void 0, onSelect: run("png"), testId: "export-png" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "image", text: labels.exportSvg, disabled: empty || display !== "chart", reason: empty ? off.reason : display !== "chart" ? labels.exportPngNeedsChart : void 0, onSelect: run("svg"), testId: "export-svg" })), /* @__PURE__ */ React7.createElement(Section, { title: labels.exportPrintGroup }, /* @__PURE__ */ React7.createElement(ExportOption, { icon: "print", text: labels.exportPrint, info: "exportPrint", onSelect: run("print"), ...off, testId: "export-print", onIntent: () => prepare("print") })), /* @__PURE__ */ React7.createElement(Section, { title: labels.exportCopy }, /* @__PURE__ */ React7.createElement(ExportOption, { icon: "copy", text: labels.copyTable, info: "copyTable", onSelect: run("copy-table"), ...off, testId: "export-copy-table" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "copy", text: labels.copyDataJson, info: "copyDataJson", onSelect: run("copy-json"), ...off, testId: "export-copy-json" })), source ? /* @__PURE__ */ React7.createElement(Section, { title: labels.exportDataGroup }, /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportDataCsv, info: "exportDataCsv", onSelect: run("data-csv"), testId: "export-data-csv" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportDataJson, info: "exportDataJson", onSelect: run("data-json"), testId: "export-data-json" })) : null);
|
|
3642
3640
|
}
|
|
3643
3641
|
|
|
3644
3642
|
// src/drill-panel.jsx
|
|
@@ -3664,45 +3662,97 @@ function printParts(html, parser) {
|
|
|
3664
3662
|
}
|
|
3665
3663
|
return { css: styles.join("\n"), lang: parsed.documentElement.getAttribute("lang") ?? "", dir: parsed.documentElement.getAttribute("dir") ?? "", title: parsed.title, body: parsed.body };
|
|
3666
3664
|
}
|
|
3667
|
-
|
|
3665
|
+
var ready = /* @__PURE__ */ new WeakMap();
|
|
3666
|
+
function newSlot(container) {
|
|
3668
3667
|
const doc = container.ownerDocument;
|
|
3669
|
-
const view = doc.defaultView;
|
|
3670
|
-
if (!view) {
|
|
3671
|
-
return false;
|
|
3672
|
-
}
|
|
3673
|
-
for (const old of container.querySelectorAll(`iframe.${FRAME_CLASS}`)) {
|
|
3674
|
-
removeFrame(
|
|
3675
|
-
/** @type {HTMLIFrameElement} */
|
|
3676
|
-
old
|
|
3677
|
-
);
|
|
3678
|
-
}
|
|
3679
|
-
const parts = printParts(html, new view.DOMParser());
|
|
3680
3668
|
const frame = doc.createElement("iframe");
|
|
3681
3669
|
frame.className = FRAME_CLASS;
|
|
3682
3670
|
frame.setAttribute("sandbox", "allow-same-origin allow-modals");
|
|
3683
3671
|
frame.setAttribute("aria-hidden", "true");
|
|
3684
3672
|
frame.setAttribute("tabindex", "-1");
|
|
3685
|
-
frame.title = parts.title;
|
|
3686
3673
|
frame.hidden = true;
|
|
3687
|
-
const
|
|
3674
|
+
const slot = { frame, isLoaded: false, loaded: Promise.resolve(false) };
|
|
3675
|
+
const loading = new AbortController();
|
|
3676
|
+
listeners.set(frame, loading);
|
|
3677
|
+
slot.loaded = new Promise((resolve) => {
|
|
3688
3678
|
const timer = setTimeout(() => resolve(false), PRINT_LOAD_TIMEOUT);
|
|
3679
|
+
loading.signal.addEventListener("abort", () => {
|
|
3680
|
+
clearTimeout(timer);
|
|
3681
|
+
resolve(false);
|
|
3682
|
+
});
|
|
3689
3683
|
const done = () => {
|
|
3690
3684
|
if (frame.contentDocument?.URL === "about:srcdoc" && frame.contentDocument.readyState === "complete") {
|
|
3691
|
-
|
|
3692
|
-
|
|
3685
|
+
frame.hidden = false;
|
|
3686
|
+
slot.isLoaded = true;
|
|
3693
3687
|
resolve(true);
|
|
3688
|
+
loading.abort();
|
|
3694
3689
|
}
|
|
3695
3690
|
};
|
|
3696
|
-
frame.addEventListener("load", done);
|
|
3691
|
+
frame.addEventListener("load", done, { signal: loading.signal });
|
|
3697
3692
|
});
|
|
3698
3693
|
frame.srcdoc = '<!doctype html><html><head><meta charset="utf-8"><title></title></head><body></body></html>';
|
|
3699
3694
|
container.append(frame);
|
|
3700
|
-
|
|
3695
|
+
return slot;
|
|
3696
|
+
}
|
|
3697
|
+
function preparePrintFrame(container) {
|
|
3698
|
+
if (!ready.get(container)?.frame.isConnected) {
|
|
3699
|
+
ready.set(container, newSlot(container));
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3702
|
+
function releasePrintFrame(container) {
|
|
3703
|
+
const slot = ready.get(container);
|
|
3704
|
+
if (slot) {
|
|
3705
|
+
ready.delete(container);
|
|
3706
|
+
removeFrame(slot.frame);
|
|
3707
|
+
}
|
|
3708
|
+
}
|
|
3709
|
+
function takePrintFrame(container) {
|
|
3710
|
+
const kept = ready.get(container);
|
|
3711
|
+
const slot = kept?.frame.isConnected ? kept : newSlot(container);
|
|
3712
|
+
ready.delete(container);
|
|
3713
|
+
for (const old of container.querySelectorAll(`iframe.${FRAME_CLASS}`)) {
|
|
3714
|
+
if (old !== slot.frame) {
|
|
3715
|
+
removeFrame(
|
|
3716
|
+
/** @type {HTMLIFrameElement} */
|
|
3717
|
+
old
|
|
3718
|
+
);
|
|
3719
|
+
}
|
|
3720
|
+
}
|
|
3721
|
+
return slot;
|
|
3722
|
+
}
|
|
3723
|
+
var dropPrintFrame = (slot) => removeFrame(slot.frame);
|
|
3724
|
+
function printHtml(html, slot) {
|
|
3725
|
+
if (slot.isLoaded) {
|
|
3726
|
+
return Promise.resolve(fillAndPrint(html, slot.frame));
|
|
3727
|
+
}
|
|
3728
|
+
return slot.loaded.then((ok) => {
|
|
3729
|
+
if (!ok) {
|
|
3730
|
+
removeFrame(slot.frame);
|
|
3731
|
+
}
|
|
3732
|
+
return ok && fillAndPrint(html, slot.frame);
|
|
3733
|
+
});
|
|
3734
|
+
}
|
|
3735
|
+
function fillAndPrint(html, frame) {
|
|
3736
|
+
try {
|
|
3737
|
+
return fillAndPrintIn(html, frame);
|
|
3738
|
+
} catch (error) {
|
|
3739
|
+
removeFrame(frame);
|
|
3740
|
+
throw error;
|
|
3741
|
+
}
|
|
3742
|
+
}
|
|
3743
|
+
function fillAndPrintIn(html, frame) {
|
|
3744
|
+
const win = frame.contentWindow;
|
|
3701
3745
|
const fdoc = frame.contentDocument;
|
|
3746
|
+
if (!frame.isConnected) {
|
|
3747
|
+
return true;
|
|
3748
|
+
}
|
|
3702
3749
|
if (!win || !fdoc || !fdoc.body) {
|
|
3703
|
-
frame
|
|
3750
|
+
removeFrame(frame);
|
|
3704
3751
|
return false;
|
|
3705
3752
|
}
|
|
3753
|
+
const parts = printParts(html, new /** @type {any} */
|
|
3754
|
+
frame.ownerDocument.defaultView.DOMParser());
|
|
3755
|
+
frame.title = parts.title;
|
|
3706
3756
|
fdoc.documentElement.lang = parts.lang;
|
|
3707
3757
|
fdoc.documentElement.dir = parts.dir;
|
|
3708
3758
|
fdoc.title = parts.title;
|
|
@@ -3720,45 +3770,43 @@ async function printHtml(html, container) {
|
|
|
3720
3770
|
fdoc.head.append(style);
|
|
3721
3771
|
}
|
|
3722
3772
|
fdoc.body.replaceChildren(...[...parts.body.childNodes].map((node) => fdoc.importNode(node, true)));
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
if (!frame.isConnected) {
|
|
3726
|
-
return true;
|
|
3727
|
-
}
|
|
3773
|
+
void fdoc.documentElement.getBoundingClientRect();
|
|
3774
|
+
const view = frame.ownerDocument.defaultView;
|
|
3728
3775
|
const ended = new AbortController();
|
|
3729
3776
|
listeners.set(frame, ended);
|
|
3730
3777
|
const after = () => setTimeout(() => removeFrame(frame), 0);
|
|
3731
3778
|
win.addEventListener("afterprint", after, { once: true, signal: ended.signal });
|
|
3732
|
-
view
|
|
3779
|
+
view?.addEventListener("afterprint", after, { once: true, signal: ended.signal });
|
|
3733
3780
|
win.print();
|
|
3734
3781
|
return true;
|
|
3735
3782
|
}
|
|
3736
3783
|
|
|
3737
|
-
// src/
|
|
3738
|
-
function
|
|
3784
|
+
// src/theme-tokens.js
|
|
3785
|
+
function themeTokens(root, theme, names, more = () => ({})) {
|
|
3739
3786
|
const host = (
|
|
3740
3787
|
/** @type {{ host?: Element }} */
|
|
3741
3788
|
root.getRootNode().host
|
|
3742
3789
|
);
|
|
3743
|
-
const
|
|
3790
|
+
const other = theme === "light" ? "dark" : "light";
|
|
3791
|
+
const shown = [root, ...host ? [host] : []].filter((el) => el.getAttribute("data-pk-theme") === other);
|
|
3744
3792
|
const read = () => {
|
|
3745
3793
|
const style = getComputedStyle(root);
|
|
3746
3794
|
return { ...Object.fromEntries(names.map((name) => [name, style.getPropertyValue(name).trim()]).filter(([, value]) => value)), ...more() };
|
|
3747
3795
|
};
|
|
3748
|
-
if (!
|
|
3796
|
+
if (!shown.length) {
|
|
3749
3797
|
return read();
|
|
3750
3798
|
}
|
|
3751
3799
|
const kept = [root.style.getPropertyValue("--pk-duration"), root.style.getPropertyPriority("--pk-duration")];
|
|
3752
3800
|
root.style.setProperty("--pk-duration", "0ms", "important");
|
|
3753
3801
|
try {
|
|
3754
|
-
for (const el of
|
|
3755
|
-
el.setAttribute("data-pk-theme",
|
|
3802
|
+
for (const el of shown) {
|
|
3803
|
+
el.setAttribute("data-pk-theme", theme);
|
|
3756
3804
|
}
|
|
3757
3805
|
try {
|
|
3758
3806
|
return read();
|
|
3759
3807
|
} finally {
|
|
3760
|
-
for (const el of
|
|
3761
|
-
el.setAttribute("data-pk-theme",
|
|
3808
|
+
for (const el of shown) {
|
|
3809
|
+
el.setAttribute("data-pk-theme", other);
|
|
3762
3810
|
}
|
|
3763
3811
|
getComputedStyle(root).getPropertyValue("--pk-duration");
|
|
3764
3812
|
}
|
|
@@ -3789,15 +3837,34 @@ function loadExporters() {
|
|
|
3789
3837
|
return pending;
|
|
3790
3838
|
}
|
|
3791
3839
|
var reportPending = null;
|
|
3840
|
+
var reportModules = null;
|
|
3792
3841
|
function loadReport(loadECharts) {
|
|
3793
|
-
reportPending ??= Promise.all([import("./chunks/report-run-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3842
|
+
reportPending ??= Promise.all([import("./chunks/report-run-HU4WPOB7.js"), loadECharts()]).then(
|
|
3843
|
+
(modules) => reportModules = modules,
|
|
3844
|
+
(error) => {
|
|
3845
|
+
reportPending = null;
|
|
3846
|
+
throw error;
|
|
3847
|
+
}
|
|
3848
|
+
);
|
|
3797
3849
|
return reportPending;
|
|
3798
3850
|
}
|
|
3799
3851
|
var exportersNow = () => exporters;
|
|
3800
3852
|
var prepareExporters = () => void loadExporters().catch(() => void 0);
|
|
3853
|
+
function prepareExport(what, root, loadECharts) {
|
|
3854
|
+
if (what === "print") {
|
|
3855
|
+
if (loadECharts) {
|
|
3856
|
+
void loadReport(loadECharts).catch(() => void 0);
|
|
3857
|
+
}
|
|
3858
|
+
return void 0;
|
|
3859
|
+
}
|
|
3860
|
+
prepareExporters();
|
|
3861
|
+
const container = root.current;
|
|
3862
|
+
if (!container) {
|
|
3863
|
+
return void 0;
|
|
3864
|
+
}
|
|
3865
|
+
preparePrintFrame(container);
|
|
3866
|
+
return () => releasePrintFrame(container);
|
|
3867
|
+
}
|
|
3801
3868
|
function deliver(blob, { doc, onExport, ...file }) {
|
|
3802
3869
|
if (onExport?.({ ...file, blob }) === false) {
|
|
3803
3870
|
return false;
|
|
@@ -3835,16 +3902,17 @@ function xlsxTheme(root) {
|
|
|
3835
3902
|
if (!root) {
|
|
3836
3903
|
return void 0;
|
|
3837
3904
|
}
|
|
3838
|
-
const tokens =
|
|
3905
|
+
const tokens = themeTokens(root, "light", XLSX_TOKENS);
|
|
3839
3906
|
const ctx = root.ownerDocument.createElement("canvas").getContext("2d");
|
|
3840
3907
|
return xlsxThemeOf({ getPropertyValue: (name) => tokens[name] ?? "" }, (text) => hexColor(text, ctx));
|
|
3841
3908
|
}
|
|
3842
|
-
function reportTokens(root, report, chart) {
|
|
3909
|
+
function reportTokens(root, report, chart, dark) {
|
|
3843
3910
|
if (!root) {
|
|
3844
|
-
return
|
|
3911
|
+
return {};
|
|
3845
3912
|
}
|
|
3846
|
-
const tokens =
|
|
3847
|
-
|
|
3913
|
+
const tokens = themeTokens(root, "light", report.REPORT_TOKENS, () => chart.tokenLengths(root, [...chart.LENGTH_TOKENS, ...report.REPORT_LENGTHS]));
|
|
3914
|
+
const darkTokens = dark ? themeTokens(root, "dark", report.REPORT_DARK_TOKENS) : {};
|
|
3915
|
+
return { ...Object.keys(tokens).length ? { tokens } : {}, ...Object.keys(darkTokens).length ? { darkTokens } : {} };
|
|
3848
3916
|
}
|
|
3849
3917
|
async function runExport(kind, { fileName, result, encoded, exportData, locale, labels, limits, root, chartRef, announce, onExport, title, source, loadECharts }) {
|
|
3850
3918
|
labels = menuLabels(labels);
|
|
@@ -3887,48 +3955,57 @@ async function runExport(kind, { fileName, result, encoded, exportData, locale,
|
|
|
3887
3955
|
return;
|
|
3888
3956
|
}
|
|
3889
3957
|
if (kind === "html" || kind === "svg" || kind === "print") {
|
|
3890
|
-
const
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3958
|
+
const slot = kind === "print" && root.current ? takePrintFrame(root.current) : null;
|
|
3959
|
+
let printing = false;
|
|
3960
|
+
try {
|
|
3961
|
+
const [report, echarts] = reportModules ?? await loadReport(
|
|
3962
|
+
/** @type {() => Promise<any>} */
|
|
3963
|
+
loadECharts
|
|
3964
|
+
);
|
|
3965
|
+
const chart = chartRef.current;
|
|
3966
|
+
const size = chart ? { width: clampSize(chart.getWidth()), height: clampSize(chart.getHeight()) } : void 0;
|
|
3967
|
+
const rendered = await report.render(result.view, result.encoded, {
|
|
3968
|
+
format: kind === "svg" ? "svg" : "html",
|
|
3969
|
+
echarts,
|
|
3970
|
+
locale,
|
|
3971
|
+
trusted: true,
|
|
3972
|
+
labels: labels.core,
|
|
3973
|
+
...limits ? { limits } : {},
|
|
3974
|
+
timeZone: result.timeZone,
|
|
3975
|
+
...title ? { title } : {},
|
|
3976
|
+
...source ? { source } : {},
|
|
3977
|
+
...size ? { size } : {},
|
|
3978
|
+
...reportTokens(root.current, report, echarts, kind === "html"),
|
|
3979
|
+
chartEmbed: kind === "print" ? "inline" : "image"
|
|
3980
|
+
});
|
|
3981
|
+
const file2 = `${base}.${kind === "svg" ? "svg" : "html"}`;
|
|
3982
|
+
const blob = new Blob([
|
|
3983
|
+
/** @type {BlobPart} */
|
|
3984
|
+
rendered.body
|
|
3985
|
+
], { type: rendered.mediaType });
|
|
3986
|
+
if (kind !== "print") {
|
|
3987
|
+
if (deliver(blob, { kind, fileName: file2, doc, onExport })) {
|
|
3988
|
+
announce(fill(labels.toastExported, { file: file2 }));
|
|
3989
|
+
}
|
|
3990
|
+
return;
|
|
3991
|
+
}
|
|
3992
|
+
if (onExport?.({ kind, fileName: file2, blob }) === false) {
|
|
3993
|
+
return;
|
|
3994
|
+
}
|
|
3995
|
+
printing = true;
|
|
3996
|
+
if (!slot || !await printHtml(
|
|
3997
|
+
/** @type {string} */
|
|
3998
|
+
rendered.text,
|
|
3999
|
+
slot
|
|
4000
|
+
)) {
|
|
4001
|
+
announce(labels.toastPrintBlocked, { tone: "error" });
|
|
3918
4002
|
}
|
|
3919
4003
|
return;
|
|
4004
|
+
} finally {
|
|
4005
|
+
if (slot && !printing) {
|
|
4006
|
+
dropPrintFrame(slot);
|
|
4007
|
+
}
|
|
3920
4008
|
}
|
|
3921
|
-
if (onExport?.({ kind, fileName: file2, blob }) === false) {
|
|
3922
|
-
return;
|
|
3923
|
-
}
|
|
3924
|
-
if (!root.current || !await printHtml(
|
|
3925
|
-
/** @type {string} */
|
|
3926
|
-
rendered.text,
|
|
3927
|
-
root.current
|
|
3928
|
-
)) {
|
|
3929
|
-
announce(labels.toastPrintBlocked, { tone: "error" });
|
|
3930
|
-
}
|
|
3931
|
-
return;
|
|
3932
4009
|
}
|
|
3933
4010
|
const m = exporters ?? await loadExporters();
|
|
3934
4011
|
const grid = toGrid(result, { locale, labels: labels.core, limits });
|
|
@@ -4159,7 +4236,7 @@ export {
|
|
|
4159
4236
|
addMenuTexts,
|
|
4160
4237
|
hasMenuTexts,
|
|
4161
4238
|
menuLabels,
|
|
4162
|
-
|
|
4239
|
+
prepareExport,
|
|
4163
4240
|
runExport,
|
|
4164
4241
|
storedViews
|
|
4165
4242
|
};
|
package/dist/styles.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pivotkit-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "React 18/19 pivot report builder on pivotkit-core: drag-and-drop fields, table and Apache ECharts chart, filters, views as JSON files, undo, Excel and CSV export.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "eizedev <oss@eize.dev>",
|
|
@@ -38,12 +38,16 @@
|
|
|
38
38
|
"default": "./dist/labels.js"
|
|
39
39
|
},
|
|
40
40
|
"./import-worker": "./dist/import-worker.js",
|
|
41
|
-
"./styles.css":
|
|
41
|
+
"./styles.css": {
|
|
42
|
+
"types": "./styles.css.d.ts",
|
|
43
|
+
"default": "./dist/styles.css"
|
|
44
|
+
},
|
|
42
45
|
"./package.json": "./package.json"
|
|
43
46
|
},
|
|
44
47
|
"files": [
|
|
45
48
|
"dist",
|
|
46
49
|
"types",
|
|
50
|
+
"styles.css.d.ts",
|
|
47
51
|
"README.md",
|
|
48
52
|
"CHANGELOG.md",
|
|
49
53
|
"LICENSE"
|
|
@@ -64,8 +68,8 @@
|
|
|
64
68
|
"dependencies": {
|
|
65
69
|
"@dnd-kit/core": "6.3.1",
|
|
66
70
|
"@dnd-kit/sortable": "10.0.0",
|
|
67
|
-
"pivotkit-core": "^0.
|
|
68
|
-
"pivotkit-report": "^0.
|
|
71
|
+
"pivotkit-core": "^0.7.0",
|
|
72
|
+
"pivotkit-report": "^0.3.0"
|
|
69
73
|
},
|
|
70
74
|
"devDependencies": {
|
|
71
75
|
"echarts": "6.1.0"
|
package/styles.css.d.ts
ADDED
package/types/export-run.d.ts
CHANGED
|
@@ -10,6 +10,18 @@ export declare function loadExporters(): Promise<typeof import("pivotkit-core/ex
|
|
|
10
10
|
export declare const exportersNow: () => typeof import("pivotkit-core/export") | null;
|
|
11
11
|
/** Starts loading the export module (a menu that copies, when it opens); a failure waits for the click. */
|
|
12
12
|
export declare const prepareExporters: () => undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Makes the Export menu's exports ready to happen in the click (use-export.js). When the menu opens
|
|
15
|
+
* ("menu"): the export module (a copy) and an empty print frame (print-frame.js); the function it
|
|
16
|
+
* returns removes the frame when the menu closes without a print. When Print is pointed at or focused
|
|
17
|
+
* ("print"): the report's modules, ECharts with them (a chunk too large to load whenever the menu
|
|
18
|
+
* opens). A failure waits for the click.
|
|
19
|
+
* @param {"menu" | "print"} what
|
|
20
|
+
* @param {React.RefObject<HTMLElement | null>} root the report's root
|
|
21
|
+
* @param {(() => Promise<any>) | undefined} loadECharts chart.jsx's
|
|
22
|
+
* @returns {(() => void) | undefined}
|
|
23
|
+
*/
|
|
24
|
+
export declare function prepareExport(what: "menu" | "print", root: React.RefObject<HTMLElement | null>, loadECharts: (() => Promise<any>) | undefined): (() => void) | undefined;
|
|
13
25
|
/**
|
|
14
26
|
* Hands the file to the host's onExport, then downloads it unless onExport returned false.
|
|
15
27
|
* @returns {boolean} whether the report downloaded it
|
package/types/menus.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export { DrillPanel } from "./drill-panel.jsx";
|
|
|
5
5
|
export { DataMenu } from "./data-menu.jsx";
|
|
6
6
|
export { addMenuTexts, hasMenuTexts, menuLabels } from "./menu-labels.js";
|
|
7
7
|
export { storedViews } from "./view-store.js";
|
|
8
|
-
export {
|
|
8
|
+
export { prepareExport, runExport } from "./export-run.js";
|
package/types/print-frame.d.ts
CHANGED
|
@@ -15,10 +15,39 @@ export declare function printParts(html: string, parser: DOMParser): {
|
|
|
15
15
|
title: string;
|
|
16
16
|
body: HTMLElement;
|
|
17
17
|
};
|
|
18
|
+
export type PrintSlot = {
|
|
19
|
+
frame: HTMLIFrameElement;
|
|
20
|
+
loaded: Promise<boolean>;
|
|
21
|
+
isLoaded: boolean;
|
|
22
|
+
};
|
|
18
23
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
24
|
+
* Makes an empty frame ready in `container` for the next print, unless one is (the Export menu, when
|
|
25
|
+
* it opens).
|
|
26
|
+
* @param {HTMLElement} container the report's root
|
|
27
|
+
*/
|
|
28
|
+
export declare function preparePrintFrame(container: HTMLElement): void;
|
|
29
|
+
/**
|
|
30
|
+
* Removes the ready frame no print took (the Export menu, when it closes).
|
|
31
|
+
* @param {HTMLElement} container
|
|
32
|
+
*/
|
|
33
|
+
export declare function releasePrintFrame(container: HTMLElement): void;
|
|
34
|
+
/**
|
|
35
|
+
* Takes the frame for a print, in the click before anything is awaited (so the menu, closing, leaves
|
|
36
|
+
* it): the ready one, or a new one when none is. Every other print frame in `container` goes.
|
|
21
37
|
* @param {HTMLElement} container the report's root
|
|
38
|
+
* @returns {PrintSlot}
|
|
39
|
+
*/
|
|
40
|
+
export declare function takePrintFrame(container: HTMLElement): PrintSlot;
|
|
41
|
+
/**
|
|
42
|
+
* Removes a frame takePrintFrame gave that will not print (the host took the report, or it failed).
|
|
43
|
+
* @param {PrintSlot} slot
|
|
44
|
+
*/
|
|
45
|
+
export declare const dropPrintFrame: (slot: PrintSlot) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Prints the report's HTML from a frame takePrintFrame gave: at once when the frame has loaded (in
|
|
48
|
+
* the click), else once it has.
|
|
49
|
+
* @param {string} html pivotkit-report's HTML (format "html", chartEmbed "inline")
|
|
50
|
+
* @param {PrintSlot} slot
|
|
22
51
|
* @returns {Promise<boolean>} false when the frame could not be used (blocked by the page)
|
|
23
52
|
*/
|
|
24
|
-
export declare function printHtml(html: string,
|
|
53
|
+
export declare function printHtml(html: string, slot: PrintSlot): Promise<boolean>;
|
package/types/report-run.d.ts
CHANGED
|
@@ -6,6 +6,11 @@ export { render };
|
|
|
6
6
|
* The chart's lengths in px come from the chart's module (LENGTH_TOKENS).
|
|
7
7
|
*/
|
|
8
8
|
export declare const REPORT_TOKENS: readonly string[];
|
|
9
|
+
/**
|
|
10
|
+
* The colours of an HTML report on a dark screen, as the report's dark theme resolves them
|
|
11
|
+
* (export-run.js): pivotkit-report's dark colours and a host's middle colour of a colour scale.
|
|
12
|
+
*/
|
|
13
|
+
export declare const REPORT_DARK_TOKENS: readonly string[];
|
|
9
14
|
/**
|
|
10
15
|
* The HTML report's font sizes, in px as the report resolves them (export-run.js): its text and
|
|
11
16
|
* secondary text, so the file's text is the size the screen's is, and a host's title and print sizes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tokens as the report's `theme` resolves them, in either theme the report shows: the light ones for
|
|
3
|
+
* a workbook and an HTML report (so a host's light colours go into them from a dark report too), the
|
|
4
|
+
* dark ones for the HTML report on a dark screen. A report showing the other theme shows this one for
|
|
5
|
+
* the read, on its root and, inside pivotkit-element, on the element whose :host rules declare the
|
|
6
|
+
* tokens, and its own again in the same task, so nothing is drawn in between; --pk-duration is 0ms
|
|
7
|
+
* meanwhile (on the root, important), so no transition of the report's starts on the way there or
|
|
8
|
+
* back. A host's rules on data-pk-theme="dark" (or "light") are read that way; rules on something
|
|
9
|
+
* else (an html[data-theme] of the page) apply in both. Lengths are resolved by the chart's module
|
|
10
|
+
* (chart-decorate.js, tokenLengths), passed in as `more`, read in that theme too.
|
|
11
|
+
* @param {HTMLElement} root the report's root
|
|
12
|
+
* @param {"light" | "dark"} theme
|
|
13
|
+
* @param {readonly string[]} names
|
|
14
|
+
* @param {() => Record<string, string>} [more] further tokens read while that theme shows
|
|
15
|
+
* @returns {Record<string, string>} the tokens that are set
|
|
16
|
+
*/
|
|
17
|
+
export declare function themeTokens(root: HTMLElement, theme: "light" | "dark", names: readonly string[], more?: () => Record<string, string>): Record<string, string>;
|
|
@@ -72,9 +72,11 @@ export declare function ViewsPanel({ templates, labels, onLoad, actions, close,
|
|
|
72
72
|
}): React.JSX.Element;
|
|
73
73
|
/**
|
|
74
74
|
* One entry of an export menu: the option and, when it needs explaining, its "i".
|
|
75
|
-
* @param {{ icon: string, text: string, info?: string, onSelect: () => void, testId: string, disabled?: boolean, reason?: string }} props
|
|
75
|
+
* @param {{ icon: string, text: string, info?: string, onSelect: () => void, testId: string, disabled?: boolean, reason?: string, onIntent?: () => void }} props
|
|
76
|
+
* `onIntent`: when the pointer comes to the entry, presses on it or the focus does (an entry with
|
|
77
|
+
* its "i")
|
|
76
78
|
*/
|
|
77
|
-
export declare function ExportOption({ icon, text, info, onSelect, testId, disabled, reason }: {
|
|
79
|
+
export declare function ExportOption({ icon, text, info, onSelect, testId, disabled, reason, onIntent }: {
|
|
78
80
|
icon: string;
|
|
79
81
|
text: string;
|
|
80
82
|
info?: string;
|
|
@@ -82,17 +84,19 @@ export declare function ExportOption({ icon, text, info, onSelect, testId, disab
|
|
|
82
84
|
testId: string;
|
|
83
85
|
disabled?: boolean;
|
|
84
86
|
reason?: string;
|
|
87
|
+
onIntent?: () => void;
|
|
85
88
|
}): React.JSX.Element;
|
|
86
89
|
/**
|
|
87
90
|
* The Export menu: the table as a file (Excel, CSV), the chart as an image (PNG, SVG), an HTML report,
|
|
88
91
|
* printing (or saving as PDF from the print dialog), the table on the clipboard (as shown, or its data
|
|
89
92
|
* as JSON), and last, when the host turns it on (exportData), the source data: every row as it is,
|
|
90
93
|
* CSV or JSON, apart from the table's exports so the two are not taken for each other. The export module loads when the menu opens, so a copy happens right in
|
|
91
|
-
* the click
|
|
94
|
+
* the click; so does a print (the print frame is made ready when the menu opens, the report's modules
|
|
95
|
+
* load when Print is pointed at or focused: use-export.js). An empty report (no field placed) has no table to export: those entries are off, and say
|
|
92
96
|
* so; the source data is there all the same. The chart's images are off while the table is shown.
|
|
93
97
|
* `dataExport`: the host's exportData with the data shown, read by export-scope.js (#259).
|
|
94
98
|
* @param {{ labels: import("./labels.js").UiLabels, onExport: (kind: string) => void, chartReady: boolean, display: string, empty?: boolean,
|
|
95
|
-
* dataExport?: { exportData: unknown, encoded: import("pivotkit-core").Encoded | null }, prepare: () => void, close: () => void }} props
|
|
99
|
+
* dataExport?: { exportData: unknown, encoded: import("pivotkit-core").Encoded | null }, prepare: (what: "menu" | "print") => (() => void) | undefined, close: () => void }} props
|
|
96
100
|
*/
|
|
97
101
|
export declare function ExportPanel({ labels, onExport, chartReady, display, empty, dataExport, prepare, close }: {
|
|
98
102
|
labels: import("./labels.js").UiLabels;
|
|
@@ -104,6 +108,6 @@ export declare function ExportPanel({ labels, onExport, chartReady, display, emp
|
|
|
104
108
|
exportData: unknown;
|
|
105
109
|
encoded: import("pivotkit-core").Encoded | null;
|
|
106
110
|
};
|
|
107
|
-
prepare: () => void;
|
|
111
|
+
prepare: (what: "menu" | "print") => (() => void) | undefined;
|
|
108
112
|
close: () => void;
|
|
109
113
|
}): React.JSX.Element;
|
package/types/use-export.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @param {import("./export-run.js").ExportContext} context
|
|
3
|
-
* @returns {(kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json" | "data-csv" | "data-json") => Promise<void
|
|
3
|
+
* @returns {{ run: (kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json" | "data-csv" | "data-json") => Promise<void>,
|
|
4
|
+
* prepare: (what: "menu" | "print") => (() => void) | undefined }}
|
|
5
|
+
* `prepare`: the Export menu's, when it opens ("menu"; it returns what ends the menu's print frame)
|
|
6
|
+
* and when Print is pointed at or focused ("print"); one function for the report's lifetime
|
|
4
7
|
*/
|
|
5
|
-
export declare function useExport(context: import("./export-run.js").ExportContext):
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
export declare function useExport(context: import("./export-run.js").ExportContext): {
|
|
9
|
+
run: (kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json" | "data-csv" | "data-json") => Promise<void>;
|
|
10
|
+
prepare: (what: "menu" | "print") => (() => void) | undefined;
|
|
11
|
+
};
|
package/types/light-tokens.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tokens as the report's light theme resolves them, in either theme: a workbook and an HTML report are
|
|
3
|
-
* light (black text in Excel, paper), so a host's light colours go into them from a dark report too.
|
|
4
|
-
* A dark report shows the light theme for the read, on its root and, inside pivotkit-element, on the
|
|
5
|
-
* element whose :host rules declare the tokens, and the dark one again in the same task, so nothing is
|
|
6
|
-
* drawn in between; --pk-duration is 0ms meanwhile (on the root, important), so no transition of the
|
|
7
|
-
* report's starts on the way there or back. A host's dark rules on data-pk-theme="dark" are left out
|
|
8
|
-
* that way; rules on something else (an html[data-theme] of the page) apply in both. Lengths are
|
|
9
|
-
* resolved by the chart's module (chart-decorate.js, tokenLengths), passed in as `more`, read in the
|
|
10
|
-
* light theme too.
|
|
11
|
-
* @param {HTMLElement} root the report's root
|
|
12
|
-
* @param {readonly string[]} names
|
|
13
|
-
* @param {() => Record<string, string>} [more] further tokens read while the light theme shows
|
|
14
|
-
* @returns {Record<string, string>} the tokens that are set
|
|
15
|
-
*/
|
|
16
|
-
export declare function lightTokens(root: HTMLElement, names: readonly string[], more?: () => Record<string, string>): Record<string, string>;
|