pivotkit-react 0.5.0 → 0.6.1
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 +118 -2
- package/README.md +4 -1
- package/dist/chunks/{chunk-2AT72SLA.js → chunk-3LDE2GPG.js} +58 -34
- package/dist/chunks/{chunk-RIOSIYGC.js → chunk-JOWAEZAD.js} +6 -4
- package/dist/chunks/{chunk-U5Q5I2D5.js → chunk-TR2HROIK.js} +10 -3
- package/dist/chunks/chunk-W2KIPREL.js +36 -0
- package/dist/chunks/{chunk-3WUGQPWV.js → chunk-XN5HNKJ2.js} +10 -95
- package/dist/chunks/{chunk-4RS72AAA.js → chunk-YXLANLGL.js} +8 -2
- package/dist/chunks/{chunk-3E4NB5RZ.js → chunk-ZK5RVCHP.js} +21 -3
- package/dist/import-ui.js +68 -174
- package/dist/index.js +75 -28
- package/dist/labels.js +4 -4
- package/dist/menu-texts-de.js +1 -1
- package/dist/menus.js +338 -82
- package/dist/styles.css +1 -1
- package/package.json +3 -3
- package/types/drill-export.d.ts +3 -2
- package/types/drill-panel.d.ts +4 -2
- package/types/export-run.d.ts +8 -3
- package/types/export-scope.d.ts +47 -0
- package/types/field-info.d.ts +3 -10
- package/types/import-host.d.ts +37 -8
- package/types/import-labels.d.ts +20 -3
- package/types/import-module.d.ts +1 -1
- package/types/import-run.d.ts +0 -8
- package/types/import-steps.d.ts +8 -0
- package/types/import-ui.d.ts +21 -4
- package/types/index.d.ts +59 -12
- package/types/labels.d.ts +2 -22
- package/types/menu-fields.d.ts +9 -0
- package/types/menu-labels.d.ts +6 -0
- package/types/menu-ops.d.ts +28 -3
- package/types/names.d.ts +22 -8
- package/types/share-actions.d.ts +14 -0
- package/types/sheet-views.d.ts +60 -0
- package/types/templates.d.ts +21 -1
- package/types/toolbar-panels.d.ts +13 -6
- package/types/use-export.d.ts +2 -2
- package/types/view-history.d.ts +15 -0
- package/types/view-save.d.ts +10 -6
- package/types/view-store.d.ts +21 -11
- package/types/import-source.d.ts +0 -32
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.6.1",
|
|
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>",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@dnd-kit/core": "6.3.1",
|
|
66
66
|
"@dnd-kit/sortable": "10.0.0",
|
|
67
|
-
"pivotkit-core": "^0.
|
|
68
|
-
"pivotkit-report": "^0.1
|
|
67
|
+
"pivotkit-core": "^0.6.1",
|
|
68
|
+
"pivotkit-report": "^0.2.1"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"echarts": "6.1.0"
|
package/types/drill-export.d.ts
CHANGED
|
@@ -15,11 +15,11 @@ export declare function rowsText({ shown, count }: {
|
|
|
15
15
|
* @param {DrillExportKind} kind
|
|
16
16
|
* @param {{ drill: { name: string, count: number, locale: string, indices: ArrayLike<number>, formats: Record<string, string>,
|
|
17
17
|
* columns: Array<{ name: string, label?: string }>, rows: string[][] },
|
|
18
|
-
* encoded: import("pivotkit-core").Encoded, labels: import("./labels.js").UiLabels,
|
|
18
|
+
* encoded: import("pivotkit-core").Encoded, labels: import("./labels.js").UiLabels, columns?: string[],
|
|
19
19
|
* onExport?: (file: import("./export-run.js").ExportFile) => unknown,
|
|
20
20
|
* announce: (text: string, extra?: { tone?: "error" }) => void, root: HTMLElement | null }} context
|
|
21
21
|
*/
|
|
22
|
-
export declare function exportDrill(kind: DrillExportKind, { drill, encoded, labels, onExport, announce, root }: {
|
|
22
|
+
export declare function exportDrill(kind: DrillExportKind, { drill, encoded, labels, columns, onExport, announce, root }: {
|
|
23
23
|
drill: {
|
|
24
24
|
name: string;
|
|
25
25
|
count: number;
|
|
@@ -34,6 +34,7 @@ export declare function exportDrill(kind: DrillExportKind, { drill, encoded, lab
|
|
|
34
34
|
};
|
|
35
35
|
encoded: import("pivotkit-core").Encoded;
|
|
36
36
|
labels: import("./labels.js").UiLabels;
|
|
37
|
+
columns?: string[];
|
|
37
38
|
onExport?: (file: import("./export-run.js").ExportFile) => unknown;
|
|
38
39
|
announce: (text: string, extra?: {
|
|
39
40
|
tone?: "error";
|
package/types/drill-panel.d.ts
CHANGED
|
@@ -4,9 +4,10 @@ export type Drill = import("./drill-table.js").Drill;
|
|
|
4
4
|
/**
|
|
5
5
|
* @param {{ drill: import("./drill-table.js").DrillSource | null, onClose: () => void, labels: import("./labels.js").UiLabels, locale: string,
|
|
6
6
|
* exportContext?: { encoded: import("pivotkit-core").Encoded, onExport?: (file: import("./export-run.js").ExportFile) => unknown,
|
|
7
|
-
* announce: (text: string, extra?: { tone?: "error" }) => void, root: React.RefObject<HTMLElement | null
|
|
7
|
+
* announce: (text: string, extra?: { tone?: "error" }) => void, root: React.RefObject<HTMLElement | null>, exportData?: unknown } }} props
|
|
8
|
+
* `exportContext`: the panel's exports; the host's exportData `{ columns }` keeps them to those (#259)
|
|
8
9
|
*/
|
|
9
|
-
export declare function DrillPanel({ drill: source, onClose, labels, locale, exportContext }: {
|
|
10
|
+
export declare function DrillPanel({ drill: source, onClose, labels, locale, exportContext: context }: {
|
|
10
11
|
drill: import("./drill-table.js").DrillSource | null;
|
|
11
12
|
onClose: () => void;
|
|
12
13
|
labels: import("./labels.js").UiLabels;
|
|
@@ -18,5 +19,6 @@ export declare function DrillPanel({ drill: source, onClose, labels, locale, exp
|
|
|
18
19
|
tone?: "error";
|
|
19
20
|
}) => void;
|
|
20
21
|
root: React.RefObject<HTMLElement | null>;
|
|
22
|
+
exportData?: unknown;
|
|
21
23
|
};
|
|
22
24
|
}): React.JSX.Element | null;
|
package/types/export-run.d.ts
CHANGED
|
@@ -63,6 +63,8 @@ export declare function xlsxThemeOf(style: {
|
|
|
63
63
|
export type ExportContext = {
|
|
64
64
|
fileName: string;
|
|
65
65
|
result: import("pivotkit-core").PivotResult | null;
|
|
66
|
+
encoded?: import("pivotkit-core").Encoded | null;
|
|
67
|
+
exportData?: unknown;
|
|
66
68
|
locale: string;
|
|
67
69
|
labels: import("./labels.js").UiLabels;
|
|
68
70
|
limits: object | undefined;
|
|
@@ -77,17 +79,20 @@ export type ExportContext = {
|
|
|
77
79
|
loadECharts?: () => Promise<any>;
|
|
78
80
|
};
|
|
79
81
|
/**
|
|
80
|
-
* @typedef {{ fileName: string, result: import("pivotkit-core").PivotResult | null, locale: string,
|
|
82
|
+
* @typedef {{ fileName: string, result: import("pivotkit-core").PivotResult | null, encoded?: import("pivotkit-core").Encoded | null, exportData?: unknown, locale: string,
|
|
81
83
|
* labels: import("./labels.js").UiLabels, limits: object | undefined, root: React.RefObject<HTMLElement | null>,
|
|
82
84
|
* chartRef: React.RefObject<any>, announce: (text: string, extra?: { tone?: "error" }) => void,
|
|
83
85
|
* onExport?: (file: ExportFile) => unknown, title?: string | null, source?: string | null, loadECharts?: () => Promise<any> }} ExportContext
|
|
84
86
|
* `title`: the report's title in an HTML report (the loaded view's name); `source`: the data's name;
|
|
87
|
+
* `encoded`: the data shown (the host's or a loaded file's), which the source data exports, only
|
|
88
|
+
* with the host's `exportData` (read by export-scope.js: the menu hides it otherwise, and no other
|
|
89
|
+
* way reaches it; `{ columns }`: only those);
|
|
85
90
|
* `loadECharts`: chart.jsx's loader of dist/echarts.js (passed in: a module of the menus that
|
|
86
91
|
* imported chart.jsx would move it out of the first load into a shared chunk)
|
|
87
92
|
*/
|
|
88
93
|
/**
|
|
89
94
|
* One export of the Export menu.
|
|
90
|
-
* @param {"xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json"} kind
|
|
95
|
+
* @param {"xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json" | "data-csv" | "data-json"} kind
|
|
91
96
|
* @param {ExportContext} context
|
|
92
97
|
*/
|
|
93
|
-
export declare function runExport(kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json", { fileName, result, locale, labels, limits, root, chartRef, announce, onExport, title, source, loadECharts }: ExportContext): Promise<void>;
|
|
98
|
+
export declare function runExport(kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json" | "data-csv" | "data-json", { fileName, result, encoded, exportData, locale, labels, limits, root, chartRef, announce, onExport, title, source, loadECharts }: ExportContext): Promise<void>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export type ExportDataOption = boolean | {
|
|
2
|
+
columns?: string[];
|
|
3
|
+
};
|
|
4
|
+
export type DataExport = {
|
|
5
|
+
source: boolean;
|
|
6
|
+
columns?: string[];
|
|
7
|
+
unknown: string[];
|
|
8
|
+
notList?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {boolean | { columns?: string[] }} ExportDataOption
|
|
12
|
+
* @typedef {{ source: boolean, columns?: string[], unknown: string[], notList?: boolean }} DataExport
|
|
13
|
+
* `source`: Source data is offered; `columns`: the host's columns as the data names them (only
|
|
14
|
+
* these, in this order, in Source data and in the drill-down's exports); `unknown`: names the host
|
|
15
|
+
* gave that no column of the data has; `notList`: `columns` was given but is no list
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The host's `exportData` against the data's own columns (not the derived fields a view adds):
|
|
19
|
+
* - off (false, absent, or a shape it does not know): no Source data; the drill-down's exports as
|
|
20
|
+
* they are, every column;
|
|
21
|
+
* - `{ columns }` that is no list (`"Region"`, a function): both off, as an empty list, so a mistake
|
|
22
|
+
* hands out nothing;
|
|
23
|
+
* - true or `{}`: Source data with every column;
|
|
24
|
+
* - `{ columns }`: Source data and the drill-down's exports with those columns only, matched
|
|
25
|
+
* case-insensitively, each once; none that matches (or an empty list): no Source data, and the
|
|
26
|
+
* drill-down's exports go too, since they would hold no column.
|
|
27
|
+
* @param {unknown} exportData
|
|
28
|
+
* @param {string[]} names the data's columns, without derived fields
|
|
29
|
+
* @returns {DataExport}
|
|
30
|
+
*/
|
|
31
|
+
export declare function dataExportOf(exportData: unknown, names: string[]): DataExport;
|
|
32
|
+
/**
|
|
33
|
+
* The places of the wanted columns among `names`, in the wanted order, matched case-insensitively as
|
|
34
|
+
* pivotkit-core's exporters match them; a name not there is left out, each column once.
|
|
35
|
+
* @param {string[]} names
|
|
36
|
+
* @param {string[] | undefined} wanted undefined: every column, in its order
|
|
37
|
+
* @returns {number[]}
|
|
38
|
+
*/
|
|
39
|
+
export declare function pickColumns(names: string[], wanted: string[] | undefined): number[];
|
|
40
|
+
/**
|
|
41
|
+
* dataExportOf against the data shown (its columns without derived fields), with the host's names
|
|
42
|
+
* that match nothing said once in the console.
|
|
43
|
+
* @param {unknown} exportData
|
|
44
|
+
* @param {import("pivotkit-core").Encoded | null | undefined} encoded
|
|
45
|
+
* @returns {DataExport}
|
|
46
|
+
*/
|
|
47
|
+
export declare function dataExportFor(exportData: unknown, encoded: import("pivotkit-core").Encoded | null | undefined): DataExport;
|
package/types/field-info.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isIdentifierName } from "pivotkit-core";
|
|
1
2
|
export type FieldInfo = {
|
|
2
3
|
label?: string;
|
|
3
4
|
description?: string;
|
|
@@ -32,16 +33,8 @@ export declare function typesOf(fieldDefaults: unknown): Record<string, string>
|
|
|
32
33
|
* @param {FieldInfo | undefined} info
|
|
33
34
|
*/
|
|
34
35
|
export declare function fieldMatches(field: string, query: string, info: FieldInfo | undefined): boolean;
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
* in any case. Words are split at a space, "_", "-", ".", "/", ":", a change from a small letter to
|
|
38
|
-
* a capital ("CustomerId", "CustomerID") and from a letter to a digit; a "#" is a word of its own
|
|
39
|
-
* ("Serial#" as "Serial #"). Before the last word is read, a part in parentheses at the end ("ID
|
|
40
|
-
* (Asset)") and digits at the end ("userID2") are left out. "Paid", "PAID" and "UUID" are one word,
|
|
41
|
-
* not one ending in "id"; "Number of items" ends in "items".
|
|
42
|
-
* @param {string} name
|
|
43
|
-
*/
|
|
44
|
-
export declare function isIdentifierName(name: string): boolean;
|
|
36
|
+
/** Whether a field's name says it is an identifier: pivotkit-core's rule, which its suggestions share. */
|
|
37
|
+
export { isIdentifierName };
|
|
45
38
|
/**
|
|
46
39
|
* Whether a column is an identifier: a number column of whole numbers whose name says so
|
|
47
40
|
* (isIdentifierName). That every value is another is no sign: a count per row is too.
|
package/types/import-host.d.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export type ImportApi = import("./import-steps.js").ImportContext & {
|
|
3
|
-
job:
|
|
4
|
-
|
|
5
|
-
n: number;
|
|
6
|
-
} | null;
|
|
7
|
-
setJob: React.Dispatch<React.SetStateAction<{
|
|
8
|
-
file: File;
|
|
9
|
-
n: number;
|
|
10
|
-
} | null>>;
|
|
3
|
+
job: ImportJob | null;
|
|
4
|
+
setJob: React.Dispatch<React.SetStateAction<ImportJob | null>>;
|
|
11
5
|
dismiss?: (id: number) => void;
|
|
12
6
|
dragging: boolean;
|
|
13
7
|
encoded: import("pivotkit-core").Encoded;
|
|
@@ -18,6 +12,15 @@ export type ImportApi = import("./import-steps.js").ImportContext & {
|
|
|
18
12
|
timeZone?: string;
|
|
19
13
|
box: () => DOMRect | undefined;
|
|
20
14
|
pick: () => void;
|
|
15
|
+
afterData: (run: (() => void) | null) => void;
|
|
16
|
+
};
|
|
17
|
+
export type ImportJob = {
|
|
18
|
+
file: File;
|
|
19
|
+
n: number;
|
|
20
|
+
sheet?: string;
|
|
21
|
+
auto?: boolean;
|
|
22
|
+
view?: string;
|
|
23
|
+
done?: (loaded: boolean, refused?: boolean, other?: boolean) => void;
|
|
21
24
|
};
|
|
22
25
|
/**
|
|
23
26
|
* Files picked or dropped: one opens its preview, more than one is said to be too many. The error
|
|
@@ -26,6 +29,32 @@ export type ImportApi = import("./import-steps.js").ImportContext & {
|
|
|
26
29
|
* @param {File[]} files
|
|
27
30
|
*/
|
|
28
31
|
export declare function startFiles(api: ImportApi, files: File[]): void;
|
|
32
|
+
/**
|
|
33
|
+
* Reads another sheet of the file shown and loads it at once (a saved view made on that sheet was
|
|
34
|
+
* opened, sheet-views.js): the dialog shows the progress and has Cancel, a sheet that cannot be read
|
|
35
|
+
* says why there. `done` is told whether the sheet was loaded (Cancel, a failure, a host's refusal and
|
|
36
|
+
* another sheet picked in the preview are not).
|
|
37
|
+
* @param {ImportApi} api
|
|
38
|
+
* @param {string} sheet
|
|
39
|
+
* @param {string} view the name of the view that needs the sheet, for the dialog
|
|
40
|
+
* @param {(loaded: boolean, refused?: boolean, other?: boolean) => void} done `refused`: the host
|
|
41
|
+
* refused it (onDataLoad); `other`: another sheet was picked in the preview and loaded
|
|
42
|
+
*/
|
|
43
|
+
export declare function loadSheet(api: ImportApi, sheet: string, view: string, done: (loaded: boolean, refused?: boolean, other?: boolean) => void): void;
|
|
44
|
+
/**
|
|
45
|
+
* A view that names a sheet (sheet-views.js: sheetPlan): another sheet of the workbook shown is read
|
|
46
|
+
* first (loadSheet), and `then` runs once its data is shown (the report's `afterData`); a sheet the
|
|
47
|
+
* workbook does not have is said, and the view loads on the sheet shown. A sheet the host refuses
|
|
48
|
+
* (onDataLoad) is said too; Cancel is not. Returns what the plan was.
|
|
49
|
+
* @param {ImportApi} api
|
|
50
|
+
* @param {{ id?: string | null, sheet?: string | null }} made the data and sheet the view names
|
|
51
|
+
* @param {string} name the view's name
|
|
52
|
+
* @param {() => void} then
|
|
53
|
+
*/
|
|
54
|
+
export declare function openOnSheet(api: ImportApi, made: {
|
|
55
|
+
id?: string | null;
|
|
56
|
+
sheet?: string | null;
|
|
57
|
+
}, name: string, then: () => void): "missing" | "none" | "switch";
|
|
29
58
|
/**
|
|
30
59
|
* Opens the browser's file picker: the report's hidden file input.
|
|
31
60
|
* @param {HTMLInputElement | null} input
|
package/types/import-labels.d.ts
CHANGED
|
@@ -65,8 +65,13 @@ export declare const en: {
|
|
|
65
65
|
archiveEntries: string;
|
|
66
66
|
unpackedBytes: string;
|
|
67
67
|
};
|
|
68
|
+
workbookCells: string;
|
|
68
69
|
sourceLine: string;
|
|
69
70
|
sourceSheet: string;
|
|
71
|
+
sheetMissing: string;
|
|
72
|
+
sheetRefused: string;
|
|
73
|
+
sheetForView: string;
|
|
74
|
+
sheetOther: string;
|
|
70
75
|
notes: {
|
|
71
76
|
ENCODING: string;
|
|
72
77
|
SEPARATOR: string;
|
|
@@ -190,8 +195,13 @@ export declare const IMPORT_TEXTS: Readonly<{
|
|
|
190
195
|
archiveEntries: string;
|
|
191
196
|
unpackedBytes: string;
|
|
192
197
|
};
|
|
198
|
+
workbookCells: string;
|
|
193
199
|
sourceLine: string;
|
|
194
200
|
sourceSheet: string;
|
|
201
|
+
sheetMissing: string;
|
|
202
|
+
sheetRefused: string;
|
|
203
|
+
sheetForView: string;
|
|
204
|
+
sheetOther: string;
|
|
195
205
|
notes: {
|
|
196
206
|
ENCODING: string;
|
|
197
207
|
SEPARATOR: string;
|
|
@@ -309,8 +319,13 @@ export declare const IMPORT_TEXTS: Readonly<{
|
|
|
309
319
|
archiveEntries: string;
|
|
310
320
|
unpackedBytes: string;
|
|
311
321
|
};
|
|
322
|
+
workbookCells: string;
|
|
312
323
|
sourceLine: string;
|
|
313
324
|
sourceSheet: string;
|
|
325
|
+
sheetMissing: string;
|
|
326
|
+
sheetRefused: string;
|
|
327
|
+
sheetForView: string;
|
|
328
|
+
sheetOther: string;
|
|
314
329
|
notes: {
|
|
315
330
|
ENCODING: string;
|
|
316
331
|
SEPARATOR: string;
|
|
@@ -387,9 +402,11 @@ export declare function noteText(note: {
|
|
|
387
402
|
}): string;
|
|
388
403
|
/**
|
|
389
404
|
* Why a file could not be read, after "{name} could not be loaded:", which names the file: a limit of
|
|
390
|
-
* pivotkit-core (`LIMIT_EXCEEDED` with a limit this version has words for
|
|
391
|
-
*
|
|
392
|
-
*
|
|
405
|
+
* pivotkit-core (`LIMIT_EXCEEDED` with a limit this version has words for; `importCells` reached
|
|
406
|
+
* by a workbook's shared strings and formats, as `details.what` says, in the words of
|
|
407
|
+
* `workbookCells`) in the report's language with its key (`limits.rows`, whose words fit
|
|
408
|
+
* `importLimits` too), else the reader's own English message without the file's name in front
|
|
409
|
+
* (`"name": ` of `fileError`, `"name" ` of `limitError`).
|
|
393
410
|
* @param {unknown} error
|
|
394
411
|
* @param {string} name the file's name
|
|
395
412
|
* @param {ImportTexts} texts
|
package/types/import-module.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { DataMenuPanel, ImportLayer, SourceLine, pickFile, startFiles } from "./import-host.jsx";
|
|
1
|
+
export { DataMenuPanel, ImportLayer, SourceLine, loadSheet, openOnSheet, pickFile, startFiles } from "./import-host.jsx";
|
|
2
2
|
export { moveData, restoreData } from "./import-steps.js";
|
package/types/import-run.d.ts
CHANGED
|
@@ -14,14 +14,6 @@ export declare function acceptOf(plugins: readonly any[]): string;
|
|
|
14
14
|
export declare const formatsOf: (plugins: readonly any[], names?: Record<string, string>) => any[];
|
|
15
15
|
/** How long a worker may take to say it is ready before the page reads the file itself (ms). */
|
|
16
16
|
export declare const WORKER_READY_MS = 10000;
|
|
17
|
-
/**
|
|
18
|
-
* A reader's table as the import UI uses it: what checkTable of pivotkit-core does not ask for, but
|
|
19
|
-
* retype and the preview need, filled in from what is there (a plugin may return the minimal shape),
|
|
20
|
-
* and notes that are no `{ code, params }` left out.
|
|
21
|
-
* @param {any} table
|
|
22
|
-
* @returns {import("pivotkit-core/import").ImportTable}
|
|
23
|
-
*/
|
|
24
|
-
export declare function completeTable(table: any): import("pivotkit-core/import").ImportTable;
|
|
25
17
|
export type ImportRead = {
|
|
26
18
|
/**
|
|
27
19
|
* the host's reader plugins
|
package/types/import-steps.d.ts
CHANGED
|
@@ -9,6 +9,14 @@ export type ShownData = {
|
|
|
9
9
|
name: string;
|
|
10
10
|
};
|
|
11
11
|
sheet: string | null;
|
|
12
|
+
/**
|
|
13
|
+
* the workbook's sheets (names)
|
|
14
|
+
*/
|
|
15
|
+
sheets?: readonly string[];
|
|
16
|
+
/**
|
|
17
|
+
* the file, to read another of its sheets
|
|
18
|
+
*/
|
|
19
|
+
blob?: File;
|
|
12
20
|
file: {
|
|
13
21
|
name: string;
|
|
14
22
|
size: number;
|
package/types/import-ui.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export declare function SourceLine({ labels, source }: {
|
|
|
47
47
|
export type LoadedData = {
|
|
48
48
|
encoded: import("pivotkit-core").Encoded;
|
|
49
49
|
/**
|
|
50
|
-
* the id for the saved views (import
|
|
50
|
+
* the id for the saved views (pivotkit-core/import's sourceIdOf), the name shown
|
|
51
51
|
*/
|
|
52
52
|
source: {
|
|
53
53
|
id: string;
|
|
@@ -59,6 +59,14 @@ export type LoadedData = {
|
|
|
59
59
|
type: string;
|
|
60
60
|
};
|
|
61
61
|
sheet: string | null;
|
|
62
|
+
/**
|
|
63
|
+
* the names of the workbook's sheets ([] for a file with one table)
|
|
64
|
+
*/
|
|
65
|
+
sheets: readonly string[];
|
|
66
|
+
/**
|
|
67
|
+
* the file itself, to read another of its sheets (a view made on it, sheet-views.js)
|
|
68
|
+
*/
|
|
69
|
+
blob: File;
|
|
62
70
|
rows: number;
|
|
63
71
|
columns: Array<{
|
|
64
72
|
name: string;
|
|
@@ -73,9 +81,11 @@ export type LoadedData = {
|
|
|
73
81
|
/**
|
|
74
82
|
* @typedef {object} LoadedData what "Load data" hands the report
|
|
75
83
|
* @property {import("pivotkit-core").Encoded} encoded
|
|
76
|
-
* @property {{ id: string, name: string }} source the id for the saved views (import
|
|
84
|
+
* @property {{ id: string, name: string }} source the id for the saved views (pivotkit-core/import's sourceIdOf), the name shown
|
|
77
85
|
* @property {{ name: string, size: number, type: string }} file
|
|
78
86
|
* @property {string | null} sheet
|
|
87
|
+
* @property {readonly string[]} sheets the names of the workbook's sheets ([] for a file with one table)
|
|
88
|
+
* @property {File} blob the file itself, to read another of its sheets (a view made on it, sheet-views.js)
|
|
79
89
|
* @property {number} rows
|
|
80
90
|
* @property {Array<{ name: string, type: string }>} columns
|
|
81
91
|
* @property {Array<{ code: string, params: Record<string, unknown>, message: string }>} notes
|
|
@@ -84,8 +94,12 @@ export type LoadedData = {
|
|
|
84
94
|
* Reads a file (progress, Cancel) and shows it before it replaces the data: the sheet, the first
|
|
85
95
|
* rows with a type per column, the readers' notes; "Load data" or Cancel. Modal, in the top layer:
|
|
86
96
|
* the focus moves in, Tab stays inside, Escape cancels, the focus goes back to where it was. A file
|
|
87
|
-
* that cannot be read closes it with a note; the report's data stays.
|
|
88
|
-
*
|
|
97
|
+
* that cannot be read closes it with a note; the report's data stays. A job with `sheet` starts on that
|
|
98
|
+
* sheet (a name); with `auto` it loads as soon as the sheet is read, without waiting for "Load data"
|
|
99
|
+
* (a saved view opened on another sheet of the file shown: the person asked for that sheet already),
|
|
100
|
+
* unless the reader has notes about it or it has no rows: then the preview stays, as for a file, and
|
|
101
|
+
* says which view needs that sheet (`view`); another sheet picked there never loads by itself.
|
|
102
|
+
* @param {{ job: { file: File, n: number, sheet?: string, auto?: boolean, view?: string }, labels: any, locale: string, plugins: any[], worker?: () => Worker,
|
|
89
103
|
* limits?: object, timeZone?: string, onApply: (data: LoadedData) => void, onClose: () => void,
|
|
90
104
|
* announce: (text: string, extra?: { tone?: "error" }) => void }} props
|
|
91
105
|
*/
|
|
@@ -93,6 +107,9 @@ export declare function ImportDialog({ job, labels, locale, plugins, worker, lim
|
|
|
93
107
|
job: {
|
|
94
108
|
file: File;
|
|
95
109
|
n: number;
|
|
110
|
+
sheet?: string;
|
|
111
|
+
auto?: boolean;
|
|
112
|
+
view?: string;
|
|
96
113
|
};
|
|
97
114
|
labels: any;
|
|
98
115
|
locale: string;
|
package/types/index.d.ts
CHANGED
|
@@ -27,6 +27,21 @@ export type Template = {
|
|
|
27
27
|
};
|
|
28
28
|
export type TemplateScope = {
|
|
29
29
|
scope: "shared" | "user";
|
|
30
|
+
/**
|
|
31
|
+
* for a save: the data shown
|
|
32
|
+
*/
|
|
33
|
+
source?: TemplateSource | null;
|
|
34
|
+
};
|
|
35
|
+
export type TemplateSource = {
|
|
36
|
+
/**
|
|
37
|
+
* the source's id (the host's `source.id`, a loaded file's name and hash)
|
|
38
|
+
*/
|
|
39
|
+
id: string;
|
|
40
|
+
name?: string;
|
|
41
|
+
/**
|
|
42
|
+
* a loaded workbook's sheet: `{ sheet }`
|
|
43
|
+
*/
|
|
44
|
+
params?: Record<string, string>;
|
|
30
45
|
};
|
|
31
46
|
export type FieldDefaults = {
|
|
32
47
|
/**
|
|
@@ -101,11 +116,12 @@ export type ExportFile = {
|
|
|
101
116
|
/**
|
|
102
117
|
* "html": the HTML report; "svg": the chart as SVG; "print": the HTML report before it is printed
|
|
103
118
|
* (returning false prints nothing: the host prints it, e.g. as a PDF of its own);
|
|
104
|
-
* "json": the view file (Views, "Download view"); "
|
|
119
|
+
* "json": the view file (Views, "Download view"); "data-csv", "data-json": Export → Source data, every
|
|
120
|
+
* row of the data shown as it is (`<fileName>-data.csv`, `<fileName>-data.json`); "copy-table", "copy-json": Export → Copy table,
|
|
105
121
|
* Copy data as JSON; "drill-*": the drill-down panel's Export menu (Copy, Copy as JSON, Download
|
|
106
122
|
* CSV, Download Excel)
|
|
107
123
|
*/
|
|
108
|
-
kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "json" | "copy-table" | "copy-json" | "drill-copy" | "drill-json" | "drill-csv" | "drill-xlsx";
|
|
124
|
+
kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "json" | "data-csv" | "data-json" | "copy-table" | "copy-json" | "drill-copy" | "drill-json" | "drill-csv" | "drill-xlsx";
|
|
109
125
|
/**
|
|
110
126
|
* with the extension ("pivot.xlsx"), made safe; for a copy the name it
|
|
111
127
|
* would have as a file ("pivot.tsv", "Central – Jul 2026.json")
|
|
@@ -158,8 +174,9 @@ export type PivotReportProps = {
|
|
|
158
174
|
templates?: Template[];
|
|
159
175
|
/**
|
|
160
176
|
* shows
|
|
161
|
-
* "Save" when set (`where.scope` is "user"
|
|
162
|
-
* returns resolves, an error when it throws or
|
|
177
|
+
* "Save" when set (`where.scope` is "user", `where.source` the data shown, null without a source id);
|
|
178
|
+
* "saved" is shown when it returns or the promise it returns resolves, an error when it throws or
|
|
179
|
+
* rejects. It wins over `templateStore`
|
|
163
180
|
*/
|
|
164
181
|
onSaveTemplate?: (name: string, view: View, where: TemplateScope) => unknown;
|
|
165
182
|
/**
|
|
@@ -170,9 +187,13 @@ export type PivotReportProps = {
|
|
|
170
187
|
/**
|
|
171
188
|
* with `canPublish`:
|
|
172
189
|
* "Publish as shared view" on each of the user's views; the host makes it a shared entry of
|
|
173
|
-
* `templates`; "published" is shown when it returns or its promise resolves
|
|
190
|
+
* `templates`; "published" is shown when it returns or its promise resolves; `where.source` the data the
|
|
191
|
+
* view was made for: the data shown (null without a source id), or the data a view file or a view of
|
|
192
|
+
* the browser store names (its id and sheet; its name when that is the data shown)
|
|
174
193
|
*/
|
|
175
|
-
onPublishTemplate?: (name: string, view: ViewInput
|
|
194
|
+
onPublishTemplate?: (name: string, view: ViewInput, where: {
|
|
195
|
+
source: TemplateSource | null;
|
|
196
|
+
}) => unknown;
|
|
176
197
|
/**
|
|
177
198
|
* the user may publish views for everyone (an admin); default false
|
|
178
199
|
*/
|
|
@@ -252,6 +273,16 @@ export type PivotReportProps = {
|
|
|
252
273
|
* host keeps the file or the text, for example to upload it)
|
|
253
274
|
*/
|
|
254
275
|
onExport?: (file: ExportFile) => unknown;
|
|
276
|
+
/**
|
|
277
|
+
* the Export menu's "Source data": every row
|
|
278
|
+
* of the data shown, as a CSV or JSON file, for the user's own analysis or the command line.
|
|
279
|
+
* `true`: every column; `{ columns }`: only these, in this order, which the drill-down panel's
|
|
280
|
+
* copies and files keep to as well (none left: both off). Default false: the rows may hold more
|
|
281
|
+
* than the report shows (docs/security.md)
|
|
282
|
+
*/
|
|
283
|
+
exportData?: boolean | {
|
|
284
|
+
columns?: string[];
|
|
285
|
+
};
|
|
255
286
|
/**
|
|
256
287
|
* the tips above the result: "on" (default), "off"
|
|
257
288
|
* (none, and no switch in Options), or the ids of the tips allowed (an array, or a comma-separated text)
|
|
@@ -427,6 +458,13 @@ export type TipDismiss = {
|
|
|
427
458
|
/**
|
|
428
459
|
* @typedef {object} TemplateScope where a template is or goes
|
|
429
460
|
* @property {"shared" | "user"} scope
|
|
461
|
+
* @property {TemplateSource | null} [source] for a save: the data shown
|
|
462
|
+
*/
|
|
463
|
+
/**
|
|
464
|
+
* @typedef {object} TemplateSource the data a view is saved or published from, as a view file names it
|
|
465
|
+
* @property {string} id the source's id (the host's `source.id`, a loaded file's name and hash)
|
|
466
|
+
* @property {string} [name]
|
|
467
|
+
* @property {Record<string, string>} [params] a loaded workbook's sheet: `{ sheet }`
|
|
430
468
|
*/
|
|
431
469
|
/**
|
|
432
470
|
* @typedef {object} FieldDefaults the host's settings for a field. A number field of whole numbers
|
|
@@ -462,10 +500,11 @@ export type TipDismiss = {
|
|
|
462
500
|
/**
|
|
463
501
|
* @typedef {object} ExportFile a file the report made, before it is downloaded, or a text before it
|
|
464
502
|
* goes on the clipboard
|
|
465
|
-
* @property {"xlsx" | "csv" | "png" | "html" | "svg" | "print" | "json" | "copy-table" | "copy-json" | "drill-copy" | "drill-json" | "drill-csv" | "drill-xlsx"} kind
|
|
503
|
+
* @property {"xlsx" | "csv" | "png" | "html" | "svg" | "print" | "json" | "data-csv" | "data-json" | "copy-table" | "copy-json" | "drill-copy" | "drill-json" | "drill-csv" | "drill-xlsx"} kind
|
|
466
504
|
* "html": the HTML report; "svg": the chart as SVG; "print": the HTML report before it is printed
|
|
467
505
|
* (returning false prints nothing: the host prints it, e.g. as a PDF of its own);
|
|
468
|
-
* "json": the view file (Views, "Download view"); "
|
|
506
|
+
* "json": the view file (Views, "Download view"); "data-csv", "data-json": Export → Source data, every
|
|
507
|
+
* row of the data shown as it is (`<fileName>-data.csv`, `<fileName>-data.json`); "copy-table", "copy-json": Export → Copy table,
|
|
469
508
|
* Copy data as JSON; "drill-*": the drill-down panel's Export menu (Copy, Copy as JSON, Download
|
|
470
509
|
* CSV, Download Excel)
|
|
471
510
|
* @property {string} fileName with the extension ("pivot.xlsx"), made safe; for a copy the name it
|
|
@@ -487,13 +526,16 @@ export type TipDismiss = {
|
|
|
487
526
|
* @property {(view: View) => void} [onViewChange] every change, normalized
|
|
488
527
|
* @property {Template[]} [templates] the entries of the Views menu, in two groups by `scope`
|
|
489
528
|
* @property {(name: string, view: View, where: TemplateScope) => unknown} [onSaveTemplate] shows
|
|
490
|
-
* "Save" when set (`where.scope` is "user"
|
|
491
|
-
* returns resolves, an error when it throws or
|
|
529
|
+
* "Save" when set (`where.scope` is "user", `where.source` the data shown, null without a source id);
|
|
530
|
+
* "saved" is shown when it returns or the promise it returns resolves, an error when it throws or
|
|
531
|
+
* rejects. It wins over `templateStore`
|
|
492
532
|
* @property {(name: string, where: TemplateScope) => unknown} [onDeleteTemplate] deletes a template
|
|
493
533
|
* marked `deletable` (`where.scope`: its group); the entry goes when it returns (or its promise resolves)
|
|
494
|
-
* @property {(name: string, view: ViewInput) => unknown} [onPublishTemplate] with `canPublish`:
|
|
534
|
+
* @property {(name: string, view: ViewInput, where: { source: TemplateSource | null }) => unknown} [onPublishTemplate] with `canPublish`:
|
|
495
535
|
* "Publish as shared view" on each of the user's views; the host makes it a shared entry of
|
|
496
|
-
* `templates`; "published" is shown when it returns or its promise resolves
|
|
536
|
+
* `templates`; "published" is shown when it returns or its promise resolves; `where.source` the data the
|
|
537
|
+
* view was made for: the data shown (null without a source id), or the data a view file or a view of
|
|
538
|
+
* the browser store names (its id and sheet; its name when that is the data shown)
|
|
497
539
|
* @property {boolean} [canPublish] the user may publish views for everyone (an admin); default false
|
|
498
540
|
* @property {"browser"} [templateStore] "browser": the user's own views are kept in this browser's
|
|
499
541
|
* localStorage under `storageKey` (only this browser and device, lost when the site's data is
|
|
@@ -525,6 +567,11 @@ export type TipDismiss = {
|
|
|
525
567
|
* @property {(file: ExportFile) => unknown} [onExport] every exported file before its download, and
|
|
526
568
|
* every copy before it goes on the clipboard; returning false skips the download or the copy (the
|
|
527
569
|
* host keeps the file or the text, for example to upload it)
|
|
570
|
+
* @property {boolean | { columns?: string[] }} [exportData] the Export menu's "Source data": every row
|
|
571
|
+
* of the data shown, as a CSV or JSON file, for the user's own analysis or the command line.
|
|
572
|
+
* `true`: every column; `{ columns }`: only these, in this order, which the drill-down panel's
|
|
573
|
+
* copies and files keep to as well (none left: both off). Default false: the rows may hold more
|
|
574
|
+
* than the report shows (docs/security.md)
|
|
528
575
|
* @property {"on" | "off" | string | string[]} [tips] the tips above the result: "on" (default), "off"
|
|
529
576
|
* (none, and no switch in Options), or the ids of the tips allowed (an array, or a comma-separated text)
|
|
530
577
|
* @property {string} [storageKey] remembers dismissed tips in localStorage under this key (one per
|
package/types/labels.d.ts
CHANGED
|
@@ -122,17 +122,7 @@ export declare const en: {
|
|
|
122
122
|
};
|
|
123
123
|
derivedName: string;
|
|
124
124
|
unitInName: {
|
|
125
|
-
|
|
126
|
-
yearQuarter: string;
|
|
127
|
-
yearMonth: string;
|
|
128
|
-
yearWeek: string;
|
|
129
|
-
day: string;
|
|
130
|
-
quarter: string;
|
|
131
|
-
month: string;
|
|
132
|
-
week: string;
|
|
133
|
-
weekday: string;
|
|
134
|
-
hour: string;
|
|
135
|
-
bin: string;
|
|
125
|
+
[x: string]: string;
|
|
136
126
|
};
|
|
137
127
|
binsName: string;
|
|
138
128
|
top: string;
|
|
@@ -563,17 +553,7 @@ export declare const de: {
|
|
|
563
553
|
};
|
|
564
554
|
derivedName: string;
|
|
565
555
|
unitInName: {
|
|
566
|
-
|
|
567
|
-
yearQuarter: string;
|
|
568
|
-
yearMonth: string;
|
|
569
|
-
yearWeek: string;
|
|
570
|
-
day: string;
|
|
571
|
-
quarter: string;
|
|
572
|
-
month: string;
|
|
573
|
-
week: string;
|
|
574
|
-
weekday: string;
|
|
575
|
-
hour: string;
|
|
576
|
-
bin: string;
|
|
556
|
+
[x: string]: string;
|
|
577
557
|
};
|
|
578
558
|
binsName: string;
|
|
579
559
|
top: string;
|
package/types/menu-fields.d.ts
CHANGED
|
@@ -40,6 +40,15 @@ export declare function NumberField({ value, onChange, problem, label, testId, c
|
|
|
40
40
|
onFocus?: () => void;
|
|
41
41
|
autoFocus?: boolean;
|
|
42
42
|
}): React.JSX.Element;
|
|
43
|
+
/**
|
|
44
|
+
* A menu's radio button, focused by a click: WebKit on macOS picks a radio on a click without focusing
|
|
45
|
+
* it, so the focus would land elsewhere after a pick (#148, #203).
|
|
46
|
+
* @param {React.InputHTMLAttributes<HTMLInputElement> & { "data-testid"?: string, "data-autofocus"?: string }} props
|
|
47
|
+
*/
|
|
48
|
+
export declare function Radio(props: React.InputHTMLAttributes<HTMLInputElement> & {
|
|
49
|
+
"data-testid"?: string;
|
|
50
|
+
"data-autofocus"?: string;
|
|
51
|
+
}): React.JSX.Element;
|
|
43
52
|
/**
|
|
44
53
|
* The keys of a field that applies what is typed: Enter applies now; Escape gives back what applies,
|
|
45
54
|
* or, when nothing was changed, goes back a level.
|
package/types/menu-labels.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export declare const en: {
|
|
|
13
13
|
exportCsv: string;
|
|
14
14
|
exportHtml: string;
|
|
15
15
|
exportPrint: string;
|
|
16
|
+
exportDataCsv: string;
|
|
17
|
+
exportDataJson: string;
|
|
16
18
|
copyTable: string;
|
|
17
19
|
copyDataJson: string;
|
|
18
20
|
drillCopy: string;
|
|
@@ -259,6 +261,7 @@ export declare const en: {
|
|
|
259
261
|
storeTooLarge: string;
|
|
260
262
|
storeRefused: string;
|
|
261
263
|
storeChanged: string;
|
|
264
|
+
viewSheet: string;
|
|
262
265
|
toastSaved: string;
|
|
263
266
|
toastDeleted: string;
|
|
264
267
|
toastPublished: string;
|
|
@@ -376,6 +379,9 @@ export declare const en: {
|
|
|
376
379
|
exportPrint: string;
|
|
377
380
|
exportPngNeedsChart: string;
|
|
378
381
|
exportNeedsField: string;
|
|
382
|
+
exportDataGroup: string;
|
|
383
|
+
exportDataCsv: string;
|
|
384
|
+
exportDataJson: string;
|
|
379
385
|
copyTable: string;
|
|
380
386
|
copyDataJson: string;
|
|
381
387
|
toastTableCopied: string;
|