pivotkit-react 0.5.0 → 0.6.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.
@@ -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-source.js), the name shown
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-source.js), the name shown
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,10 @@ 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
- * @param {{ job: { file: File, n: number }, labels: any, locale: string, plugins: any[], worker?: () => Worker,
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
+ * @param {{ job: { file: File, n: number, sheet?: string, auto?: boolean }, labels: any, locale: string, plugins: any[], worker?: () => Worker,
89
101
  * limits?: object, timeZone?: string, onApply: (data: LoadedData) => void, onClose: () => void,
90
102
  * announce: (text: string, extra?: { tone?: "error" }) => void }} props
91
103
  */
@@ -93,6 +105,8 @@ export declare function ImportDialog({ job, labels, locale, plugins, worker, lim
93
105
  job: {
94
106
  file: File;
95
107
  n: number;
108
+ sheet?: string;
109
+ auto?: boolean;
96
110
  };
97
111
  labels: any;
98
112
  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"); "copy-table", "copy-json": Export → Copy table,
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"); "saved" is shown when it returns or the promise it
162
- * returns resolves, an error when it throws or rejects. It wins over `templateStore`
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) => unknown;
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,12 @@ 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 and every column of the
278
+ * data shown, as a CSV or JSON file, for the user's own analysis or the command line. Default false:
279
+ * the rows may hold more than the report shows (docs/security.md)
280
+ */
281
+ exportData?: boolean;
255
282
  /**
256
283
  * the tips above the result: "on" (default), "off"
257
284
  * (none, and no switch in Options), or the ids of the tips allowed (an array, or a comma-separated text)
@@ -427,6 +454,13 @@ export type TipDismiss = {
427
454
  /**
428
455
  * @typedef {object} TemplateScope where a template is or goes
429
456
  * @property {"shared" | "user"} scope
457
+ * @property {TemplateSource | null} [source] for a save: the data shown
458
+ */
459
+ /**
460
+ * @typedef {object} TemplateSource the data a view is saved or published from, as a view file names it
461
+ * @property {string} id the source's id (the host's `source.id`, a loaded file's name and hash)
462
+ * @property {string} [name]
463
+ * @property {Record<string, string>} [params] a loaded workbook's sheet: `{ sheet }`
430
464
  */
431
465
  /**
432
466
  * @typedef {object} FieldDefaults the host's settings for a field. A number field of whole numbers
@@ -462,10 +496,11 @@ export type TipDismiss = {
462
496
  /**
463
497
  * @typedef {object} ExportFile a file the report made, before it is downloaded, or a text before it
464
498
  * 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
499
+ * @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
500
  * "html": the HTML report; "svg": the chart as SVG; "print": the HTML report before it is printed
467
501
  * (returning false prints nothing: the host prints it, e.g. as a PDF of its own);
468
- * "json": the view file (Views, "Download view"); "copy-table", "copy-json": Export → Copy table,
502
+ * "json": the view file (Views, "Download view"); "data-csv", "data-json": Export → Source data, every
503
+ * row of the data shown as it is (`<fileName>-data.csv`, `<fileName>-data.json`); "copy-table", "copy-json": Export → Copy table,
469
504
  * Copy data as JSON; "drill-*": the drill-down panel's Export menu (Copy, Copy as JSON, Download
470
505
  * CSV, Download Excel)
471
506
  * @property {string} fileName with the extension ("pivot.xlsx"), made safe; for a copy the name it
@@ -487,13 +522,16 @@ export type TipDismiss = {
487
522
  * @property {(view: View) => void} [onViewChange] every change, normalized
488
523
  * @property {Template[]} [templates] the entries of the Views menu, in two groups by `scope`
489
524
  * @property {(name: string, view: View, where: TemplateScope) => unknown} [onSaveTemplate] shows
490
- * "Save" when set (`where.scope` is "user"); "saved" is shown when it returns or the promise it
491
- * returns resolves, an error when it throws or rejects. It wins over `templateStore`
525
+ * "Save" when set (`where.scope` is "user", `where.source` the data shown, null without a source id);
526
+ * "saved" is shown when it returns or the promise it returns resolves, an error when it throws or
527
+ * rejects. It wins over `templateStore`
492
528
  * @property {(name: string, where: TemplateScope) => unknown} [onDeleteTemplate] deletes a template
493
529
  * 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`:
530
+ * @property {(name: string, view: ViewInput, where: { source: TemplateSource | null }) => unknown} [onPublishTemplate] with `canPublish`:
495
531
  * "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
532
+ * `templates`; "published" is shown when it returns or its promise resolves; `where.source` the data the
533
+ * view was made for: the data shown (null without a source id), or the data a view file or a view of
534
+ * the browser store names (its id and sheet; its name when that is the data shown)
497
535
  * @property {boolean} [canPublish] the user may publish views for everyone (an admin); default false
498
536
  * @property {"browser"} [templateStore] "browser": the user's own views are kept in this browser's
499
537
  * localStorage under `storageKey` (only this browser and device, lost when the site's data is
@@ -525,6 +563,9 @@ export type TipDismiss = {
525
563
  * @property {(file: ExportFile) => unknown} [onExport] every exported file before its download, and
526
564
  * every copy before it goes on the clipboard; returning false skips the download or the copy (the
527
565
  * host keeps the file or the text, for example to upload it)
566
+ * @property {boolean} [exportData] the Export menu's "Source data": every row and every column of the
567
+ * data shown, as a CSV or JSON file, for the user's own analysis or the command line. Default false:
568
+ * the rows may hold more than the report shows (docs/security.md)
528
569
  * @property {"on" | "off" | string | string[]} [tips] the tips above the result: "on" (default), "off"
529
570
  * (none, and no switch in Options), or the ids of the tips allowed (an array, or a comma-separated text)
530
571
  * @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
- year: string;
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
- year: string;
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;
@@ -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;
@@ -121,14 +121,16 @@ export declare const RULE_TYPES: readonly string[];
121
121
  export declare const RULES_MAX = 10;
122
122
  /**
123
123
  * Replaces one rule of a field, `previous` (the view's own entry, matched by its content), with
124
- * `entry` (a filter of RULE_TYPES), removes it when `entry` is null, or adds `entry` after the field's
125
- * other filters without `previous`.
124
+ * `entry` (a filter of RULE_TYPES), removes it when `entry` is null, or adds `entry` without
125
+ * `previous`: before the rule `before` (a rule emptied and typed again keeps its place among the
126
+ * others), else after the field's other filters.
126
127
  * @param {any} view
127
128
  * @param {string} field
128
129
  * @param {object | null} previous
129
130
  * @param {object | null} entry
131
+ * @param {object | null} [before]
130
132
  */
131
- export declare const setRule: (view: any, field: string, previous: object | null, entry: object | null) => any;
133
+ export declare const setRule: (view: any, field: string, previous: object | null, entry: object | null, before?: object | null) => any;
132
134
  /** The units of a date's quick choices, finest first (hours are left to a view's own filters). */
133
135
  export declare const QUICK_UNITS: readonly string[];
134
136
  /**
@@ -17,6 +17,17 @@ export type ShareContext = {
17
17
  viewName: string | null;
18
18
  sourceId: string | undefined;
19
19
  sourceName: string | undefined;
20
+ /**
21
+ * the source's params the files and links carry (a loaded workbook's sheet)
22
+ */
23
+ sourceParams: Record<string, string> | undefined;
24
+ /**
25
+ * a view file made on another sheet of the workbook shown: reads that sheet, then loads `file` on it ("switch" when that started)
26
+ */
27
+ viaSheet: ((made: {
28
+ id?: string | null;
29
+ sheet?: string | null;
30
+ }, name: string, file: object) => "switch" | "missing" | "none") | undefined;
20
31
  /**
21
32
  * the `$schema` of the view files (the prop)
22
33
  */
@@ -61,6 +72,9 @@ export type ShareContext = {
61
72
  * @property {string | null} viewName the loaded view's name
62
73
  * @property {string | undefined} sourceId
63
74
  * @property {string | undefined} sourceName
75
+ * @property {Record<string, string> | undefined} sourceParams the source's params the files and links carry (a loaded workbook's sheet)
76
+ * @property {((made: { id?: string | null, sheet?: string | null }, name: string, file: object) => "switch" | "missing" | "none") | undefined} viaSheet
77
+ * a view file made on another sheet of the workbook shown: reads that sheet, then loads `file` on it ("switch" when that started)
64
78
  * @property {string | null | undefined} schemaUrl the `$schema` of the view files (the prop)
65
79
  * @property {import("pivotkit-core").Encoded} encoded
66
80
  * @property {boolean | string | undefined} shareLink the prop: the base of the link
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The file name part of a loaded file's source id, or null for another id (a host's data).
3
+ * @param {string | null | undefined} id
4
+ */
5
+ export declare function fileOfId(id: string | null | undefined): string | null;
6
+ /**
7
+ * The sheet a view's source names, or null.
8
+ * @param {unknown} source a view file's source ({ id, params })
9
+ * @returns {string | null}
10
+ */
11
+ export declare function sheetOfSource(source: unknown): string | null;
12
+ export type ShownSheet = {
13
+ /**
14
+ * its source id
15
+ */
16
+ id: string | undefined;
17
+ /**
18
+ * the sheet of a workbook shown, else null
19
+ */
20
+ sheet: string | null;
21
+ /**
22
+ * the sheets of that workbook (names)
23
+ */
24
+ sheets: readonly string[];
25
+ };
26
+ /**
27
+ * @typedef {object} ShownSheet the data shown, for these rules
28
+ * @property {string | undefined} id its source id
29
+ * @property {string | null} sheet the sheet of a workbook shown, else null
30
+ * @property {readonly string[]} sheets the sheets of that workbook (names)
31
+ */
32
+ /**
33
+ * Whether a view of the browser store is listed for the data shown: made for this data (its id), for
34
+ * no named data, while no data is named, or for a sheet of a file of the same name while a workbook's
35
+ * sheet is shown (the same workbook's other sheets have other columns, so another id; opening it
36
+ * reads that sheet, sheetPlan).
37
+ * @param {{ sourceId?: string, sheet?: string | null }} entry
38
+ * @param {ShownSheet} shown
39
+ */
40
+ export declare function listedFor(entry: {
41
+ sourceId?: string;
42
+ sheet?: string | null;
43
+ }, shown: ShownSheet): boolean;
44
+ /**
45
+ * What opening a view that names a sheet does with the data shown: nothing ("none": it names no
46
+ * sheet, the sheet shown, or other data than this file), read that sheet of the file again first
47
+ * ("switch"), or say that the workbook has no such sheet ("missing": the view loads on the data shown).
48
+ * @param {{ id?: string | null, sheet?: string | null }} view the source the view names
49
+ * @param {ShownSheet} shown
50
+ * @returns {{ kind: "none" } | { kind: "switch" | "missing", sheet: string }}
51
+ */
52
+ export declare function sheetPlan(view: {
53
+ id?: string | null;
54
+ sheet?: string | null;
55
+ }, shown: ShownSheet): {
56
+ kind: "none";
57
+ } | {
58
+ kind: "switch" | "missing";
59
+ sheet: string;
60
+ };
@@ -16,6 +16,20 @@ export type TemplateEntry = {
16
16
  * the data a view of the browser store names, when it names one
17
17
  */
18
18
  sourceId?: string;
19
+ /**
20
+ * the sheet of a workbook the view was made on (its source.params.sheet)
21
+ */
22
+ sheet?: string;
23
+ /**
24
+ * the source id of that workbook's sheet (a host's view file; the
25
+ * browser store's entries have it as `sourceId`)
26
+ */
27
+ sheetOf?: string;
28
+ /**
29
+ * the source id a host's view file names (with or without a sheet): the data it
30
+ * was made for, which Publish hands on
31
+ */
32
+ fileSource?: string;
19
33
  };
20
34
  /**
21
35
  * @typedef {object} TemplateEntry an entry of the Views menu
@@ -25,6 +39,11 @@ export type TemplateEntry = {
25
39
  * @property {boolean} deletable
26
40
  * @property {number} [at] its place in the browser store; only for the store's own entries
27
41
  * @property {string} [sourceId] the data a view of the browser store names, when it names one
42
+ * @property {string} [sheet] the sheet of a workbook the view was made on (its source.params.sheet)
43
+ * @property {string} [sheetOf] the source id of that workbook's sheet (a host's view file; the
44
+ * browser store's entries have it as `sourceId`)
45
+ * @property {string} [fileSource] the source id a host's view file names (with or without a sheet): the data it
46
+ * was made for, which Publish hands on
28
47
  */
29
48
  /**
30
49
  * The entries of the Views menu: the host's templates (an entry with `file` is read as a view file;
@@ -34,7 +53,7 @@ export type TemplateEntry = {
34
53
  * marked `deletable` and the host takes the delete (`hostDeletes`). Every name is plain text
35
54
  * (plainNames), as a name from a file or the store is.
36
55
  * @param {unknown} templates the host's
37
- * @param {Array<{ name: string, view: Record<string, unknown>, at: number, sourceId?: string }>} stored
56
+ * @param {Array<{ name: string, view: Record<string, unknown>, at: number, sourceId?: string, sheet?: string }>} stored
38
57
  * @param {boolean} hostDeletes
39
58
  * @returns {TemplateEntry[]}
40
59
  */
@@ -43,4 +62,5 @@ export declare function templateEntries(templates: unknown, stored: Array<{
43
62
  view: Record<string, unknown>;
44
63
  at: number;
45
64
  sourceId?: string;
65
+ sheet?: string;
46
66
  }>, hostDeletes: boolean): TemplateEntry[];
@@ -85,18 +85,20 @@ export declare function ExportOption({ icon, text, info, onSelect, testId, disab
85
85
  }): React.JSX.Element;
86
86
  /**
87
87
  * The Export menu: the table as a file (Excel, CSV), the chart as an image (PNG, SVG), an HTML report,
88
- * printing (or saving as PDF from the print dialog), and the table on the clipboard (as shown, or its
89
- * data as JSON). The export module loads when the menu opens, so a copy happens right in the click.
90
- * An empty report (no field placed) has nothing to export: every entry is off, and says so; the chart's
91
- * images are off while the table is shown.
92
- * @param {{ labels: import("./labels.js").UiLabels, onExport: (kind: string) => void, chartReady: boolean, display: string, empty?: boolean, prepare: () => void, close: () => void }} props
88
+ * printing (or saving as PDF from the print dialog), the table on the clipboard (as shown, or its data
89
+ * as JSON), and last, when the host turns it on (exportData), the source data: every row as it is,
90
+ * 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. An empty report (no field placed) has no table to export: those entries are off, and say
92
+ * so; the source data is there all the same. The chart's images are off while the table is shown.
93
+ * @param {{ labels: import("./labels.js").UiLabels, onExport: (kind: string) => void, chartReady: boolean, display: string, empty?: boolean, dataExport?: boolean, prepare: () => void, close: () => void }} props
93
94
  */
94
- export declare function ExportPanel({ labels, onExport, chartReady, display, empty, prepare, close }: {
95
+ export declare function ExportPanel({ labels, onExport, chartReady, display, empty, dataExport, prepare, close }: {
95
96
  labels: import("./labels.js").UiLabels;
96
97
  onExport: (kind: string) => void;
97
98
  chartReady: boolean;
98
99
  display: string;
99
100
  empty?: boolean;
101
+ dataExport?: boolean;
100
102
  prepare: () => void;
101
103
  close: () => void;
102
104
  }): React.JSX.Element;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @param {import("./export-run.js").ExportContext} context
3
- * @returns {(kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json") => Promise<void>}
3
+ * @returns {(kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json" | "data-csv" | "data-json") => Promise<void>}
4
4
  */
5
- export declare function useExport(context: import("./export-run.js").ExportContext): (kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json") => Promise<void>;
5
+ export declare function useExport(context: import("./export-run.js").ExportContext): (kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json" | "data-csv" | "data-json") => Promise<void>;
6
6
  /** Starts loading the export module when a menu that copies opens: a copy right in the click is allowed everywhere. */
7
7
  export declare const prepareExporters: () => undefined;
@@ -3,17 +3,20 @@ export type LoadedView = {
3
3
  scope: "user" | "shared" | null;
4
4
  store: boolean;
5
5
  storeSource?: string | null;
6
+ storeSheet?: string | null;
6
7
  };
7
8
  export type SaveRights = {
8
9
  host: boolean;
9
10
  store: boolean;
10
11
  publish: boolean;
11
12
  sourceId?: string;
13
+ sheet?: string | null;
12
14
  };
13
15
  export type SaveWrite = {
14
16
  kind: "store";
15
17
  at?: number;
16
18
  storeSource: string | null;
19
+ storeSheet?: string | null;
17
20
  } | {
18
21
  kind: "host";
19
22
  } | {
@@ -28,19 +31,20 @@ export type Entry = {
28
31
  scope: string;
29
32
  at?: number;
30
33
  sourceId?: string;
34
+ sheet?: string;
31
35
  };
32
36
  /**
33
- * @typedef {{ name: string, scope: "user" | "shared" | null, store: boolean, storeSource?: string | null }} LoadedView
37
+ * @typedef {{ name: string, scope: "user" | "shared" | null, store: boolean, storeSource?: string | null, storeSheet?: string | null }} LoadedView
34
38
  * the view loaded: its name, its group (null: a file or a link), whether the browser store keeps it
35
- * and, there, the data it names
36
- * @typedef {{ host: boolean, store: boolean, publish: boolean, sourceId?: string }} SaveRights
39
+ * and, there, the data and the sheet it names
40
+ * @typedef {{ host: boolean, store: boolean, publish: boolean, sourceId?: string, sheet?: string | null }} SaveRights
37
41
  * onSaveTemplate is set, the browser store is on, the user may publish (canPublish with
38
- * onPublishTemplate); the data shown
39
- * @typedef {{ kind: "store", at?: number, storeSource: string | null } | { kind: "host" } | { kind: "publish" }} SaveWrite
42
+ * onPublishTemplate); the data shown and its sheet of a workbook
43
+ * @typedef {{ kind: "store", at?: number, storeSource: string | null, storeSheet?: string | null } | { kind: "host" } | { kind: "publish" }} SaveWrite
40
44
  * where a save goes; `at`: the browser store's view it writes over (none: a view added)
41
45
  * @typedef {SaveWrite | { kind: null, why: "saveSharedLocked" | "saveNotInViews" | "exportNeedsField" }} SaveTarget
42
46
  * `why`: the label that says why Save is off
43
- * @typedef {{ name: string, scope: string, at?: number, sourceId?: string }} Entry an entry of the Views menu
47
+ * @typedef {{ name: string, scope: string, at?: number, sourceId?: string, sheet?: string }} Entry an entry of the Views menu
44
48
  */
45
49
  /** Whether Save as can write anywhere. @param {SaveRights} can */
46
50
  export declare const canSaveAs: (can: SaveRights) => boolean;
@@ -4,30 +4,38 @@ export declare const VIEW_STORE_LIMITS: Readonly<{
4
4
  text: 500000;
5
5
  }>;
6
6
  /**
7
- * The browser store's views from its text, those for the data shown: made for `sourceId` or for no
8
- * named data.
7
+ * The browser store's views from its text, those for the data shown: made for `sourceId`, for no
8
+ * named data, or for another sheet of the workbook shown (sheet-views.js: listedFor).
9
9
  * @param {string | null} raw
10
10
  * @param {string | undefined} sourceId
11
- * `sourceId` of an entry: the data it names (none for a view saved without), which tells two views
12
- * of the same name apart (one for no named data, one for this data).
13
- * @returns {Array<{ name: string, view: Record<string, unknown>, at: number, sourceId?: string }>}
11
+ * @param {{ sheet: string | null, sheets: readonly string[] }} [shown] the workbook's sheet shown
12
+ * `sourceId` and `sheet` of an entry: the data it names (none for a view saved without) and the sheet
13
+ * of a workbook it was made on, which tell two views of the same name apart (one for no named data,
14
+ * one per data and sheet).
15
+ * @returns {Array<{ name: string, view: Record<string, unknown>, at: number, sourceId?: string, sheet?: string }>}
14
16
  */
15
- export declare function storedViews(raw: string | null, sourceId: string | undefined): Array<{
17
+ export declare function storedViews(raw: string | null, sourceId: string | undefined, shown?: {
18
+ sheet: string | null;
19
+ sheets: readonly string[];
20
+ }): Array<{
16
21
  name: string;
17
22
  view: Record<string, unknown>;
18
23
  at: number;
19
24
  sourceId?: string;
25
+ sheet?: string;
20
26
  }>;
21
27
  /**
22
- * The browser store's text after a change: `name` saved for `sourceId` (replacing a view of the same
23
- * name for the same data), the view at `replace` written over in its place (Save, and Save as onto a
24
- * name that exists: its data and its place in the list stay), or the view at `remove` taken out. A
28
+ * The browser store's text after a change: `name` saved for `sourceId` and `sheet` (replacing a view of
29
+ * the same name for the same data and sheet), the view at `replace` written over in its place (Save,
30
+ * and Save as onto a name that exists: its place in the list stays, and its data, which takes the sheet
31
+ * shown when it is the data shown: a view saved before views named their sheet gets it), or the view
32
+ * at `remove` taken out. A
25
33
  * delete and a replace check that the view there is still the one named `removeName` or `name`
26
34
  * (another tab may have changed the store since the menu was drawn) and throw "changed" when it is
27
35
  * not, so the wrong view is never deleted or overwritten. The caps apply to a save
28
36
  * only: a store over them (older caps, changed by hand) can always shrink.
29
37
  * @param {string | null} raw
30
- * @param {{ name?: string, view?: object, sourceId?: string, remove?: number, removeName?: string, replace?: number }} change
38
+ * @param {{ name?: string, view?: object, sourceId?: string, sheet?: string | null, remove?: number, removeName?: string, replace?: number }} change
31
39
  * @param {(kind: "count" | "text" | "changed", max: number) => string} message the Error's message
32
40
  * @returns {string | null} null when nothing is left
33
41
  */
@@ -35,6 +43,7 @@ export declare function changedViews(raw: string | null, change: {
35
43
  name?: string;
36
44
  view?: object;
37
45
  sourceId?: string;
46
+ sheet?: string | null;
38
47
  remove?: number;
39
48
  removeName?: string;
40
49
  replace?: number;
@@ -44,7 +53,7 @@ export declare function changedViews(raw: string | null, change: {
44
53
  * the labels' words when the store would hold too much, changed since the menu was drawn, or the
45
54
  * browser refused to keep it.
46
55
  * @param {string | null} raw the store's text now
47
- * @param {{ name?: string, view?: object, sourceId?: string, remove?: number, removeName?: string, replace?: number }} change
56
+ * @param {{ name?: string, view?: object, sourceId?: string, sheet?: string | null, remove?: number, removeName?: string, replace?: number }} change
48
57
  * @param {any} labels with the menus' texts
49
58
  * @param {string} locale for the numbers
50
59
  * @param {(text: string | null) => boolean} keep writes the text (storage.js: writeItem), false when the browser refused
@@ -53,6 +62,7 @@ export declare function storeViews(raw: string | null, change: {
53
62
  name?: string;
54
63
  view?: object;
55
64
  sourceId?: string;
65
+ sheet?: string | null;
56
66
  remove?: number;
57
67
  removeName?: string;
58
68
  replace?: number;
@@ -1,32 +0,0 @@
1
- /** Characters of a file name in the source id and the report's source line. */
2
- export declare const SHOWN_MAX = 120;
3
- /**
4
- * The name as the report shows it: at most SHOWN_MAX characters, cut with "...".
5
- * @param {string} name
6
- */
7
- export declare function shownName(name: string): string;
8
- /**
9
- * SHA-256 of bytes, in JavaScript (where crypto.subtle is missing).
10
- * @param {Uint8Array} bytes
11
- * @returns {Uint8Array}
12
- */
13
- export declare function sha256Bytes(bytes: Uint8Array): Uint8Array;
14
- /**
15
- * SHA-256 of a text (UTF-8) as lower-case hex: the browser's crypto.subtle where there is one.
16
- * @param {string} text
17
- * @param {{ subtle?: SubtleCrypto | null }} [options] `subtle: null` uses the own implementation (tests)
18
- * @returns {Promise<string>}
19
- */
20
- export declare function sha256Hex(text: string, options?: {
21
- subtle?: SubtleCrypto | null;
22
- }): Promise<string>;
23
- /**
24
- * The source id of a loaded file: its shown name, "#" and 16 hex digits of the SHA-256 of its whole
25
- * name and its column names in their order, joined with U+0000.
26
- * @param {string} name
27
- * @param {readonly string[]} columns
28
- * @param {{ subtle?: SubtleCrypto | null }} [options]
29
- */
30
- export declare function sourceIdOf(name: string, columns: readonly string[], options?: {
31
- subtle?: SubtleCrypto | null;
32
- }): Promise<string>;