pivotkit-react 0.4.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +267 -1
  2. package/README.md +5 -2
  3. package/dist/chunks/{chunk-YITKWZ4L.js → chunk-2RAVX4DO.js} +604 -505
  4. package/dist/chunks/{chunk-ZYEYZSYL.js → chunk-7LERNGUW.js} +36 -2
  5. package/dist/chunks/{chunk-EM23V5GH.js → chunk-E6M57YLL.js} +19 -8
  6. package/dist/chunks/{chunk-RWYHJRQO.js → chunk-JMRTIOX4.js} +17 -7
  7. package/dist/chunks/{chunk-XN55BQ4M.js → chunk-RIOSIYGC.js} +54 -7
  8. package/dist/chunks/{chunk-LEN5RPBM.js → chunk-TR2HROIK.js} +43 -7
  9. package/dist/chunks/chunk-W2KIPREL.js +36 -0
  10. package/dist/chunks/{chunk-6MDAL3IO.js → chunk-XN5HNKJ2.js} +88 -101
  11. package/dist/chunks/{chunk-WB4GKWFQ.js → chunk-YXLANLGL.js} +34 -6
  12. package/dist/chunks/report-run-BZBFOMPF.js +12 -0
  13. package/dist/chunks/{unused-texts-K3VFH65P.js → unused-texts-Y4R67XSN.js} +1 -1
  14. package/dist/chunks/{unused-texts-de-OW4TGIVX.js → unused-texts-de-6YVPTNVS.js} +1 -1
  15. package/dist/echarts.js +38 -156
  16. package/dist/import-ui.js +69 -168
  17. package/dist/index.js +160 -102
  18. package/dist/labels.js +6 -6
  19. package/dist/menu-texts-de.js +1 -1
  20. package/dist/menus.js +778 -277
  21. package/dist/styles.css +207 -93
  22. package/package.json +8 -4
  23. package/types/chart-decorate.d.ts +28 -4
  24. package/types/chart-types.d.ts +2 -4
  25. package/types/echarts.d.ts +1 -1
  26. package/types/export-run.d.ts +42 -4
  27. package/types/field-info.d.ts +3 -10
  28. package/types/filter.d.ts +1 -1
  29. package/types/icons.d.ts +1 -0
  30. package/types/import-host.d.ts +34 -8
  31. package/types/import-labels.d.ts +47 -0
  32. package/types/import-limits.d.ts +6 -0
  33. package/types/import-module.d.ts +1 -1
  34. package/types/import-steps.d.ts +8 -0
  35. package/types/import-ui.d.ts +18 -4
  36. package/types/index.d.ts +76 -17
  37. package/types/labels.d.ts +200 -24
  38. package/types/light-tokens.d.ts +16 -0
  39. package/types/menu-labels.d.ts +43 -14
  40. package/types/menu-ops.d.ts +166 -43
  41. package/types/menu-topics.d.ts +7 -4
  42. package/types/names.d.ts +47 -19
  43. package/types/place.d.ts +24 -0
  44. package/types/print-frame.d.ts +24 -0
  45. package/types/report-run.d.ts +14 -0
  46. package/types/share-actions.d.ts +17 -3
  47. package/types/share.d.ts +13 -17
  48. package/types/sheet-views.d.ts +60 -0
  49. package/types/templates.d.ts +21 -1
  50. package/types/theme.d.ts +2 -16
  51. package/types/tips.d.ts +5 -0
  52. package/types/toolbar-panels.d.ts +9 -6
  53. package/types/unused-texts.d.ts +13 -3
  54. package/types/use-export.d.ts +2 -2
  55. package/types/view-ops.d.ts +65 -6
  56. package/types/view-save.d.ts +10 -6
  57. package/types/view-store.d.ts +21 -11
  58. package/types/chart-layout.d.ts +0 -111
  59. package/types/import-source.d.ts +0 -32
package/types/share.d.ts CHANGED
@@ -3,28 +3,21 @@ export declare function loadLink(): Promise<typeof import("pivotkit-core/link")>
3
3
  /** The link module when it is loaded already, else null (see loadLink). */
4
4
  export declare const linkNow: () => typeof import("pivotkit-core/link") | null;
5
5
  /**
6
- * The name of a report's view in the URL fragment: "pivot", or "pivot-<storageKey>" so several reports
7
- * on one page each have their own.
8
- * @param {string | undefined} storageKey
9
- */
10
- export declare function linkParam(storageKey: string | undefined): string;
11
- /**
12
- * The encoded view of a fragment ("#pivot=1.abc&pivot-sales=1.def") under a name, or null. The
13
- * fragment is read as it is, not as form data, so a hash route next to it ("#/reports/a?tab=2&pivot=...")
14
- * does not matter.
6
+ * The link text of a report's entry in a fragment ("#pivot=1.abc&pivot-sales=1.def"), or null:
7
+ * pivotkit-core's linkFragment. `key` is the report's storageKey: its entry is "pivot-<key>", else
8
+ * "pivot". The fragment is read as it is, so a hash route next to it does not matter.
15
9
  * @param {string} hash location.hash, with or without "#"
16
- * @param {string} param
10
+ * @param {string | undefined} key
17
11
  */
18
- export declare function readLinkParam(hash: string, param: string): any;
12
+ export declare const readLinkParam: (hash: string, key: string | undefined) => string | null;
19
13
  /**
20
- * A URL with the encoded view under `param` in its fragment. Only that entry is added, replaced or
21
- * removed; the rest of the fragment (another report's entry, a hash route such as "#/reports/a?tab=2",
22
- * an anchor) stays byte for byte.
14
+ * A URL with the report's link text in its fragment (pivotkit-core's withLinkFragment): only that
15
+ * entry is added, replaced or removed (null), the rest of the fragment stays byte for byte.
23
16
  * @param {string} url
24
- * @param {string} param
25
- * @param {string | null} encoded null removes the entry
17
+ * @param {string | undefined} key the report's storageKey
18
+ * @param {string | null} encoded
26
19
  */
27
- export declare function withLinkParam(url: string, param: string, encoded: string | null): string;
20
+ export declare const withLinkParam: (url: string, key: string | undefined, encoded: string | null) => string;
28
21
  /**
29
22
  * The address a shared link points to: the host's base URL as given, or for `true` the page's own
30
23
  * address without its query (it may hold tokens or ids the host did not mean to share) and with its
@@ -84,6 +77,9 @@ export declare function viewFromText(text: string, encoded: import("pivotkit-cor
84
77
  /**
85
78
  * A view from a parsed object (a link's) or a text, read as a view file and normalized against the
86
79
  * data; `file.compatible` says how it fits (the same source by `options.sourceId`, its fields there).
80
+ * Every view that comes in this way (a link, a file, pasted JSON, the tab's stored view) comes from
81
+ * outside the host's code: it is normalized with pivotkit-core's outsideLimits() over the host's
82
+ * `options.limits` (at most 50 filters, or the host's lower value).
87
83
  * @param {unknown} input
88
84
  * @param {import("pivotkit-core").Encoded} encoded
89
85
  * @param {{ limits?: object, sourceId?: string }} [options]
@@ -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[];
package/types/theme.d.ts CHANGED
@@ -6,19 +6,5 @@
6
6
  * @returns {"light" | "dark"}
7
7
  */
8
8
  export declare function resolveTheme(wanted: "auto" | "light" | "dark" | undefined, htmlTheme: string | null | undefined, prefersDark: boolean): "light" | "dark";
9
- /** Number of categorical chart colours (--pk-chart-1 ... --pk-chart-8). */
10
- export declare const CHART_COLORS = 8;
11
- /**
12
- * The ECharts theme of pivotkit-core's toEChartsOption from the computed style of the report's root.
13
- * @param {{ getPropertyValue(name: string): string }} style getComputedStyle(root)
14
- */
15
- export declare function chartThemeFrom(style: {
16
- getPropertyValue(name: string): string;
17
- }): {
18
- colors: any[];
19
- textColor: string | undefined;
20
- axisColor: string | undefined;
21
- gridColor: string | undefined;
22
- fontFamily: string | undefined;
23
- backgroundColor: string;
24
- };
9
+ /** The chart's colours from the --pk-* tokens: pivotkit-core's, the same for an SVG and a printed report. */
10
+ export { CHART_COLORS, chartThemeFrom } from "pivotkit-core";
package/types/tips.d.ts CHANGED
@@ -45,6 +45,11 @@ export type TipContext = {
45
45
  * columns of the innermost column field (1 without column fields)
46
46
  */
47
47
  colLeaves: number;
48
+ /**
49
+ * a column group with more than one child is expanded, so a
50
+ * column subtotal shows when column subtotals are on (core's layout.js draws none for one child)
51
+ */
52
+ colSubtotalShown: boolean;
48
53
  /**
49
54
  * source rows left after the filters
50
55
  */
@@ -84,18 +84,21 @@ export declare function ExportOption({ icon, text, info, onSelect, testId, disab
84
84
  reason?: string;
85
85
  }): React.JSX.Element;
86
86
  /**
87
- * The Export menu: the table as a file (Excel, CSV), the chart as an image, and the table on the
88
- * clipboard (as shown, or its data as JSON). The export module loads when the menu opens, so a copy
89
- * happens right in the click.
90
- * An empty report (no field placed) has nothing to export: every entry is off, and says so.
91
- * @param {{ labels: import("./labels.js").UiLabels, onExport: (kind: string) => void, chartReady: boolean, display: string, empty?: boolean, prepare: () => void, close: () => void }} props
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), 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
92
94
  */
93
- export declare function ExportPanel({ labels, onExport, chartReady, display, empty, prepare, close }: {
95
+ export declare function ExportPanel({ labels, onExport, chartReady, display, empty, dataExport, prepare, close }: {
94
96
  labels: import("./labels.js").UiLabels;
95
97
  onExport: (kind: string) => void;
96
98
  chartReady: boolean;
97
99
  display: string;
98
100
  empty?: boolean;
101
+ dataExport?: boolean;
99
102
  prepare: () => void;
100
103
  close: () => void;
101
104
  }): React.JSX.Element;
@@ -45,6 +45,8 @@ export declare const en: {
45
45
  tooMany: string;
46
46
  tooManyItems: string;
47
47
  itemType: string;
48
+ itemTooLong: string;
49
+ itemCase: string;
48
50
  unknownField: string;
49
51
  unknownFieldHere: string;
50
52
  placedTwice: string;
@@ -70,15 +72,22 @@ export declare const en: {
70
72
  dataBarColor: string;
71
73
  unknownFilterType: string;
72
74
  filterNoItems: string;
73
- filterLabelOp: string;
75
+ filterFieldType: string;
76
+ filterTextOp: string;
77
+ filterMatch: string;
78
+ filterNot: string;
79
+ filterBlanks: string;
80
+ blanksUnspecified: string;
81
+ filterEmpty: string;
74
82
  filterText: string;
75
83
  filterNotNumber: string;
84
+ filterTies: string;
85
+ filterPrecision: string;
76
86
  filterCount: string;
77
87
  filterValue: string;
78
88
  filterValue2: string;
79
- filterCompareField: string;
80
89
  filterCompareValue: string;
81
- filterRelativeField: string;
90
+ filterRelativeDirection: string;
82
91
  filterRelativeUnit: string;
83
92
  filterRelativeCount: string;
84
93
  filterRelativeAnchor: string;
@@ -91,6 +100,7 @@ export declare const en: {
91
100
  unknownLocale: string;
92
101
  unknownTimeZone: string;
93
102
  timeZoneMismatch: string;
103
+ tooManyIssues: string;
94
104
  };
95
105
  other: string;
96
106
  };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @param {import("./export-run.js").ExportContext} context
3
- * @returns {(kind: "xlsx" | "csv" | "png" | "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" | "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;
@@ -1,8 +1,70 @@
1
+ import { swapAxes } from "pivotkit-core";
1
2
  export type Zone = "rows" | "cols" | "values" | "filters";
2
3
  /** @typedef {"rows" | "cols" | "values" | "filters"} Zone */
3
4
  export declare const ZONES: readonly Zone[];
4
5
  export declare const clone: (view: any) => any;
6
+ /** The operators of the menus' rules: on an item's name, on an item or its total. */
7
+ export declare const RULE_OPS: Readonly<{
8
+ text: readonly string[];
9
+ compare: readonly string[];
10
+ }>;
11
+ /**
12
+ * A filter's operator as the menus name it: its own, or with `not` its negation ("!=", "notBetween",
13
+ * "notContains", "notBeginsWith"). A `not` the menus have no word for (a loaded view's "not greater
14
+ * than") is hiddenNot().
15
+ * @param {{ op?: string, not?: boolean }} f
16
+ */
17
+ export declare const ruleOp: (f: {
18
+ op?: string;
19
+ not?: boolean;
20
+ }) => any;
21
+ /** Whether a filter's `not` has no word in the menus (ruleOp gives the operator without it). */
22
+ export declare const hiddenNot: (f: any) => boolean;
23
+ /**
24
+ * A menu's operator as version 2 writes it: `{ op, not }` ("notBetween" is between with not).
25
+ * @param {string} menuOp
26
+ */
27
+ export declare function opOf(menuOp: string): {
28
+ op: string;
29
+ not: boolean;
30
+ };
31
+ /**
32
+ * The pick of a field: the values not ticked dropped (null is the blank), so values that appear in
33
+ * newer data are shown, as in Excel.
34
+ * @param {string} field
35
+ * @param {unknown[]} excluded
36
+ */
37
+ export declare const pickFilter: (field: string, excluded: unknown[]) => {
38
+ field: string;
39
+ type: string;
40
+ items: ({} | undefined)[];
41
+ not: boolean;
42
+ blanks: string;
43
+ };
44
+ /** The pick of a field that drops nothing: a field in the Filters zone without a filter holds it. */
45
+ export declare const emptyPick: (field: any) => {
46
+ field: string;
47
+ type: string;
48
+ items: ({} | undefined)[];
49
+ not: boolean;
50
+ blanks: string;
51
+ };
52
+ /** Whether a filter is a field's pick (an item list, ticked in the menus). */
53
+ export declare const isPick: (f: any) => boolean;
54
+ /** Whether a pick drops nothing (emptyPick). */
55
+ export declare const isEmptyPick: (f: any) => boolean;
5
56
  export declare const same: (a: any, b: any) => boolean;
57
+ /**
58
+ * The items of a picker whose label holds what was typed: as text filters compare (pivotkit-core's
59
+ * foldText), so case and runs of whitespace, a no-break space among them, do not matter.
60
+ * @param {Array<{ label: string } & Record<string, any>>} items
61
+ * @param {string} query
62
+ */
63
+ export declare function searchItems(items: Array<{
64
+ label: string;
65
+ } & Record<string, any>>, query: string): ({
66
+ label: string;
67
+ } & Record<string, any>)[];
6
68
  /** The fields shown in the Filters zone: filtered fields that are on no axis, once each. */
7
69
  export declare function filterZoneFields(view: any): any[];
8
70
  /** The axis a field is on, or null. */
@@ -235,7 +297,7 @@ export declare function nextHeaderSort(view: any, target: {
235
297
  } | null;
236
298
  /** Filters of one type of a field. */
237
299
  export declare function filtersOf(view: any, field: any, types: any): any;
238
- /** The values an item filter lets through, from the field's values; all of them without a filter. */
300
+ /** The values a field's picks let through, from the field's values (null is the blank); all of them without a pick. */
239
301
  export declare function selectedItems(view: any, field: any, all: any): any;
240
302
  /**
241
303
  * True when a value gives a number for each cell, so it can be shown as a share, formatted, highlighted,
@@ -296,10 +358,7 @@ export declare function setChartDisplay(view: any, patch: {
296
358
  title?: string | null;
297
359
  smooth?: boolean;
298
360
  }): any;
299
- /**
300
- * Swaps the fields of Rows and Columns, with their collapsed groups; a calculation along an axis
301
- * ("running total along Rows") goes along the other one, so it still runs along the same fields.
302
- */
303
- export declare function swapAxes(view: any): any;
361
+ /** Rows and Columns swapped (pivotkit-core's swapAxes): the chart's swap, the zones' Swap button. */
362
+ export { swapAxes };
304
363
  /** True when nothing is placed: the UI shows its first steps. */
305
364
  export declare function isEmptyView(view: any): boolean;
@@ -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,111 +0,0 @@
1
- /**
2
- * Room (px) above and below a pie for the labels outside it, for a chart `height` px high: 5 % of the
3
- * height, at most 24 px. The pie's radius is a share of its box, so in a low box the top and bottom
4
- * labels would reach past the canvas; a tall box keeps nearly all of its pie.
5
- * @param {number} height
6
- */
7
- export declare function pieLabelRoom(height: number): number;
8
- /**
9
- * The least width (px) of a chart that keeps a legend on its right: the legend's column takes 160 px
10
- * (pivotkit-core), so a narrower chart (a phone) would squeeze the pie or the plot into a sliver. Below
11
- * it the legend is drawn at the bottom instead, with the room pivotkit-core gives a bottom legend.
12
- */
13
- export declare const RIGHT_LEGEND_MIN_WIDTH = 480;
14
- /** Room (px) pivotkit-core gives a legend at the bottom of a chart. */
15
- export declare const BOTTOM_LEGEND_ROOM = 32;
16
- /**
17
- * Whether the numbers written inside a donut's ring fit across it: the ring is the outer less the
18
- * inner radius, both a share (ECharts' "70%") of half the smaller side of the pie's box. A pie (no
19
- * inner radius) has room from its centre and always fits.
20
- * @param {[string | number, string | number]} radius the series' radius, inner and outer
21
- * @param {{ width: number, height: number }} box the pie's box: the chart less the room around it
22
- * @param {string[]} texts the labels written on the slices
23
- */
24
- export declare function ringLabelsFit(radius: [string | number, string | number], box: {
25
- width: number;
26
- height: number;
27
- }, texts: string[]): boolean;
28
- /** Width (px) a slanted column name of a heatmap takes at most; a longer one ends in "…". */
29
- export declare const SLANTED_LABEL_WIDTH = 120;
30
- /**
31
- * How a heatmap writes its column names along the x axis of a chart `width` px wide: straight when
32
- * the longest fits its column, else slanted by 45 degrees and cut at SLANTED_LABEL_WIDTH. Every name is
33
- * shown (the core sets interval 0); the width of a character is estimated as 0.55 of the font size.
34
- * @param {string[]} names
35
- * @param {number} width the chart's width in px
36
- * @param {number} [fontSize] px, ECharts' default for axis labels
37
- * @returns {{ rotate: number, width?: number, overflow?: "truncate" }}
38
- */
39
- export declare function columnLabelLayout(names: string[], width: number, fontSize?: number): {
40
- rotate: number;
41
- width?: number;
42
- overflow?: "truncate";
43
- };
44
- /**
45
- * True when the cells of a heatmap of `columns` x `rows` in a chart of `width` x `height` px hold their
46
- * numbers as the chart writes them (`texts`, formatted: "1,234.5", "-12.3%"): the longest, estimated at
47
- * 0.55 of the font size per character, fits a cell's width with room on both sides, and a line its height.
48
- * @param {number} columns
49
- * @param {number} rows
50
- * @param {number} width
51
- * @param {number} height
52
- * @param {string[]} texts
53
- * @param {number} [fontSize] px, ECharts' default for labels
54
- */
55
- export declare function heatmapCellLabels(columns: number, rows: number, width: number, height: number, texts: string[], fontSize?: number): boolean;
56
- /**
57
- * Which row names of a heatmap the y axis writes in a chart `height` px high: every one (0) when a line
58
- * fits each row, else every n-th (ECharts' interval: n - 1 names left out between two shown), so the
59
- * names never overlap and the first one is always there.
60
- * @param {number} rows
61
- * @param {number} height
62
- */
63
- export declare function rowLabelInterval(rows: number, height: number): number;
64
- /** Width (px) a category label of bars, lines and areas takes at most: a longer one ends in "…" (the tooltip has it whole). */
65
- export declare const CATEGORY_LABEL_WIDTH = 120;
66
- /**
67
- * How the category axis of bars, lines and areas writes its labels (`chart.axisLabels`):
68
- * - "auto": every label straight when the longest fits its slot, else slanted by 45 degrees while a
69
- * line fits each slot, else every n-th slanted (`every` > 1, the chart says so in a note);
70
- * - "all": every label, slanted when they do not fit straight;
71
- * - "nth": straight, every n-th so they never overlap.
72
- * Along a vertical axis (horizontal bars) the labels stay straight: every one while a line fits each
73
- * row, else every n-th. A label is cut at CATEGORY_LABEL_WIDTH; character width estimated at 0.55 of the font size.
74
- * @param {string[]} names
75
- * @param {{ width: number, height: number, horizontal?: boolean, mode?: string, fontSize?: number }} box
76
- * @returns {{ rotate: number, interval: number, every: number, width: number, overflow: "truncate" }}
77
- */
78
- export declare function categoryLabelLayout(names: string[], { width, height, horizontal, mode, fontSize }: {
79
- width: number;
80
- height: number;
81
- horizontal?: boolean;
82
- mode?: string;
83
- fontSize?: number;
84
- }): {
85
- rotate: number;
86
- interval: number;
87
- every: number;
88
- width: number;
89
- overflow: "truncate";
90
- };
91
- /** The least room (px) a group label needs along the axis, and the least size of a chart with group labels. */
92
- export declare const GROUP_LABEL_ROOM: Readonly<{
93
- along: 56;
94
- across: 28;
95
- width: 420;
96
- height: 260;
97
- }>;
98
- /**
99
- * Whether "auto" group labels fit a chart of `width` x `height` px with `count` categories whose
100
- * smallest group has `groupSize` of them: each group's name needs GROUP_LABEL_ROOM.along px under the
101
- * axis (across: a line per group beside a vertical axis), and the chart itself a least size, or the
102
- * plot area left over is too small to read.
103
- * @param {number} count
104
- * @param {number} groupSize
105
- * @param {{ width: number, height: number, horizontal?: boolean }} box
106
- */
107
- export declare function groupLabelsFit(count: number, groupSize: number, { width, height, horizontal }: {
108
- width: number;
109
- height: number;
110
- horizontal?: boolean;
111
- }): boolean;
@@ -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>;