pivotkit-react 0.3.0 → 0.4.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 (46) hide show
  1. package/CHANGELOG.md +121 -1
  2. package/README.md +1 -1
  3. package/dist/chunks/{chunk-32Z33U6S.js → chunk-6MDAL3IO.js} +28 -3
  4. package/dist/chunks/{chunk-APB4NW4O.js → chunk-LEN5RPBM.js} +3 -6
  5. package/dist/chunks/{chunk-7CC4JHDY.js → chunk-WB4GKWFQ.js} +1 -4
  6. package/dist/chunks/chunk-XN55BQ4M.js +618 -0
  7. package/dist/chunks/{chunk-IOPAM4JD.js → chunk-YITKWZ4L.js} +48 -492
  8. package/dist/chunks/chunk-ZYEYZSYL.js +187 -0
  9. package/dist/import-ui.js +769 -0
  10. package/dist/import-worker.js +20 -0
  11. package/dist/index.js +599 -175
  12. package/dist/labels.js +14 -10
  13. package/dist/menu-texts-de.js +1 -1
  14. package/dist/menus.js +132 -68
  15. package/dist/styles.css +116 -8
  16. package/package.json +3 -2
  17. package/types/data-history.d.ts +85 -0
  18. package/types/data-keep.d.ts +51 -0
  19. package/types/data-menu.d.ts +11 -0
  20. package/types/dom.d.ts +40 -7
  21. package/types/field-info.d.ts +32 -0
  22. package/types/import-host.d.ts +53 -0
  23. package/types/import-labels.d.ts +360 -0
  24. package/types/import-module.d.ts +2 -0
  25. package/types/import-run.d.ts +73 -0
  26. package/types/import-source.d.ts +32 -0
  27. package/types/import-steps.d.ts +121 -0
  28. package/types/import-ui.d.ts +108 -0
  29. package/types/import-worker.d.ts +1 -0
  30. package/types/index.d.ts +56 -4
  31. package/types/labels.d.ts +26 -2
  32. package/types/lazy-import.d.ts +4 -0
  33. package/types/lazy-menus.d.ts +2 -2
  34. package/types/levels.d.ts +3 -2
  35. package/types/menu-labels.d.ts +0 -3
  36. package/types/menu-topics.d.ts +2 -4
  37. package/types/menus.d.ts +1 -0
  38. package/types/overflow.d.ts +29 -17
  39. package/types/popover.d.ts +47 -5
  40. package/types/section.d.ts +2 -2
  41. package/types/toasts.d.ts +1 -1
  42. package/types/toolbar-panels.d.ts +6 -5
  43. package/types/unused-keep.d.ts +20 -0
  44. package/types/unused.d.ts +1 -0
  45. package/types/use-view-history.d.ts +12 -4
  46. package/types/virtual.d.ts +15 -0
package/types/index.d.ts CHANGED
@@ -125,9 +125,11 @@ export type ExportFile = {
125
125
  };
126
126
  export type PivotReportProps = {
127
127
  /**
128
- * the rows; encoded once per array, or once per `dataKey`
128
+ * the rows, or columnar data
129
+ * (`{ columns, types, data }`, one array per column, as pivotkit-core's encode takes it); encoded once
130
+ * per array or object, or once per `dataKey`
129
131
  */
130
- data?: object[];
132
+ data?: object[] | import("pivotkit-core").ColumnarData;
131
133
  /**
132
134
  * identity of `data`: a new array with the same key is not encoded again
133
135
  */
@@ -328,7 +330,35 @@ export type PivotReportProps = {
328
330
  * the first data) or covers its result (later loads)
329
331
  */
330
332
  loading?: boolean;
333
+ /**
334
+ * people may load a file into the report in the browser: a Data
335
+ * button with "Load data…", a file dropped onto the report, a preview before it replaces the data
336
+ * (nothing is uploaded; Undo and "Back to original data" bring the host's data back). With a
337
+ * `storageKey` a report mounted again over the same host data shows the file again (memory only).
338
+ * Default false
339
+ */
340
+ allowImport?: boolean;
341
+ /**
342
+ * reader plugins (contract v1,
343
+ * pivotkit-core/import's validatePlugin) for more formats, such as pivotkit-xlsx; CSV, TSV, text and
344
+ * JSON are built in
345
+ */
346
+ plugins?: import("pivotkit-core/import").ReaderPlugin[];
347
+ /**
348
+ * the data shown changed: a file is loaded
349
+ * (`cause` "load"; returning false refuses it, the data stays), the host's data shown again
350
+ * ("original"), one of those undone or redone ("undo", "redo"), or the file shown again by a report
351
+ * mounted again with its storageKey ("restore")
352
+ */
353
+ onDataLoad?: (load: DataLoad) => unknown;
354
+ /**
355
+ * starts a module worker that runs pivotkit-react's
356
+ * `import-worker` entry, so CSV and JSON files are read off the page; without it they are read on
357
+ * the page (pivotkit-element brings its own)
358
+ */
359
+ importWorker?: () => Worker;
331
360
  };
361
+ export type DataLoad = import("./import-steps.js").DataLoad;
332
362
  export type ViewSource = {
333
363
  /**
334
364
  * stable, as the host names the data ("sales", a table's or an endpoint's name)
@@ -387,7 +417,9 @@ export type TipDismiss = {
387
417
  * @property {"shared" | "user"} scope
388
418
  */
389
419
  /**
390
- * @typedef {object} FieldDefaults the host's settings for a field
420
+ * @typedef {object} FieldDefaults the host's settings for a field. A number field of whole numbers
421
+ * named ID, …Id, …_id, Nr, No, Number, Key or # without `agg`, `format` and `drillFormat` is an
422
+ * identifier: `{ agg: "count", drillFormat: "text" }` (field-info.js fieldDefaultsFor)
391
423
  * @property {string} [agg] aggregator of a new value, when it fits the field's type ("average" for durations)
392
424
  * @property {string} [format] a format of pivotkit-core ("duration:h", "currency:EUR") for a new value,
393
425
  * and for the field's own numbers in the drill-down unless `drillFormat` is set
@@ -431,7 +463,9 @@ export type TipDismiss = {
431
463
  */
432
464
  /**
433
465
  * @typedef {object} PivotReportProps
434
- * @property {object[]} [data] the rows; encoded once per array, or once per `dataKey`
466
+ * @property {object[] | import("pivotkit-core").ColumnarData} [data] the rows, or columnar data
467
+ * (`{ columns, types, data }`, one array per column, as pivotkit-core's encode takes it); encoded once
468
+ * per array or object, or once per `dataKey`
435
469
  * @property {string | number} [dataKey] identity of `data`: a new array with the same key is not encoded again
436
470
  * @property {import("pivotkit-core").Encoded} [encoded] already encoded data, instead of `data`
437
471
  * @property {ViewInput} [view] controlled: the view to show; pass back what onViewChange gives
@@ -515,6 +549,24 @@ export type TipDismiss = {
515
549
  * decides. With it the user can still change it until the page is loaded again
516
550
  * @property {boolean} [loading] the host is loading the data: the report shows its skeleton (before
517
551
  * the first data) or covers its result (later loads)
552
+ * @property {boolean} [allowImport] people may load a file into the report in the browser: a Data
553
+ * button with "Load data…", a file dropped onto the report, a preview before it replaces the data
554
+ * (nothing is uploaded; Undo and "Back to original data" bring the host's data back). With a
555
+ * `storageKey` a report mounted again over the same host data shows the file again (memory only).
556
+ * Default false
557
+ * @property {import("pivotkit-core/import").ReaderPlugin[]} [plugins] reader plugins (contract v1,
558
+ * pivotkit-core/import's validatePlugin) for more formats, such as pivotkit-xlsx; CSV, TSV, text and
559
+ * JSON are built in
560
+ * @property {(load: DataLoad) => unknown} [onDataLoad] the data shown changed: a file is loaded
561
+ * (`cause` "load"; returning false refuses it, the data stays), the host's data shown again
562
+ * ("original"), one of those undone or redone ("undo", "redo"), or the file shown again by a report
563
+ * mounted again with its storageKey ("restore")
564
+ * @property {() => Worker} [importWorker] starts a module worker that runs pivotkit-react's
565
+ * `import-worker` entry, so CSV and JSON files are read off the page; without it they are read on
566
+ * the page (pivotkit-element brings its own)
567
+ */
568
+ /**
569
+ * @typedef {import("./import-steps.js").DataLoad} DataLoad
518
570
  */
519
571
  /**
520
572
  * @typedef {object} ViewSource the data a view is made for
package/types/labels.d.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  export type UiLabels = typeof en & import("./menu-labels.js").MenuTexts & {
2
2
  unused?: import("./unused-texts.js").UnusedTexts;
3
+ dataImport?: import("./import-labels.js").ImportTexts;
3
4
  };
4
5
  /**
5
6
  * Every text of the UI: these and the menus' (menu-labels.js, loaded with the menus; a type import
6
7
  * only, so they stay out of the first load).
7
- * @typedef {typeof en & import("./menu-labels.js").MenuTexts & { unused?: import("./unused-texts.js").UnusedTexts }} UiLabels
8
+ * @typedef {typeof en & import("./menu-labels.js").MenuTexts & { unused?: import("./unused-texts.js").UnusedTexts, dataImport?: import("./import-labels.js").ImportTexts }} UiLabels
8
9
  * `unused`: the texts of a view's unused parts (unused-texts.js), loaded when a view has such parts;
9
- * a host's are kept aside as the menus' are
10
+ * `dataImport`: those of loading data (import-labels.js), loaded with the import UI; a host's of
11
+ * both are kept aside as the menus' are
10
12
  */
11
13
  export declare const en: {
12
14
  /** the language of the texts, for the report's lang attribute */
@@ -69,8 +71,13 @@ export declare const en: {
69
71
  };
70
72
  undo: string;
71
73
  redo: string;
74
+ startOver: string;
72
75
  reset: string;
73
76
  resetHint: string;
77
+ resetAlready: string;
78
+ resetStartEmpty: string;
79
+ newHint: string;
80
+ newAlready: string;
74
81
  unsavedChanges: string;
75
82
  swap: string;
76
83
  layout: string;
@@ -78,6 +85,12 @@ export declare const en: {
78
85
  layoutEmpty: string;
79
86
  more: string;
80
87
  views: string;
88
+ data: string;
89
+ dataLoaded: string;
90
+ loadData: string;
91
+ emptyLoad: string;
92
+ emptyDrop: string;
93
+ emptyNoData: string;
81
94
  exportLabel: string;
82
95
  options: string;
83
96
  expand: string;
@@ -401,8 +414,13 @@ export declare const de: {
401
414
  };
402
415
  undo: string;
403
416
  redo: string;
417
+ startOver: string;
404
418
  reset: string;
405
419
  resetHint: string;
420
+ resetAlready: string;
421
+ resetStartEmpty: string;
422
+ newHint: string;
423
+ newAlready: string;
406
424
  unsavedChanges: string;
407
425
  swap: string;
408
426
  layout: string;
@@ -410,6 +428,12 @@ export declare const de: {
410
428
  layoutEmpty: string;
411
429
  more: string;
412
430
  views: string;
431
+ data: string;
432
+ dataLoaded: string;
433
+ loadData: string;
434
+ emptyLoad: string;
435
+ emptyDrop: string;
436
+ emptyNoData: string;
413
437
  exportLabel: string;
414
438
  options: string;
415
439
  expand: string;
@@ -0,0 +1,4 @@
1
+ /** The import UI, imported once; a failed import is forgotten, so the next call tries again. */
2
+ export declare function loadImport(): Promise<typeof import("./import-module.js")>;
3
+ /** The import UI when it is loaded, else null. */
4
+ export declare const importNow: () => typeof import("./import-module.js") | null;
@@ -17,12 +17,12 @@ export declare function loadMenus(lang?: string): Promise<typeof import("./menus
17
17
  export declare const menusNow: (lang?: string) => typeof import("./menus.js") | null;
18
18
  /**
19
19
  * One panel of menus.js with its props.
20
- * @param {{ name: "AxisMenu" | "FilterMenu" | "ValueMenu" | "ChartTypePanel" | "OptionsPanel" | "ViewsPanel" | "ExportPanel" | "LoadCheck" | "FilterPopover" | "DrillPanel", loadingText?: string, props: Record<string, any> }} props
20
+ * @param {{ name: "AxisMenu" | "FilterMenu" | "ValueMenu" | "ChartTypePanel" | "OptionsPanel" | "ViewsPanel" | "ExportPanel" | "LoadCheck" | "FilterPopover" | "DrillPanel" | "DataMenu", loadingText?: string, props: Record<string, any> }} props
21
21
  * `loadingText`: shown while loading; without it nothing is (a popover or panel of its own).
22
22
  * `props.labels` gives the texts of a failed load
23
23
  */
24
24
  export declare function MenuPanel({ name, loadingText, props }: {
25
- name: "AxisMenu" | "FilterMenu" | "ValueMenu" | "ChartTypePanel" | "OptionsPanel" | "ViewsPanel" | "ExportPanel" | "LoadCheck" | "FilterPopover" | "DrillPanel";
25
+ name: "AxisMenu" | "FilterMenu" | "ValueMenu" | "ChartTypePanel" | "OptionsPanel" | "ViewsPanel" | "ExportPanel" | "LoadCheck" | "FilterPopover" | "DrillPanel" | "DataMenu";
26
26
  loadingText?: string;
27
27
  props: Record<string, any>;
28
28
  }): React.JSX.Element;
package/types/levels.d.ts CHANGED
@@ -2,8 +2,9 @@ import React from "react";
2
2
  /** The button that opened the popover around `el` (MenuButton's aria-controls names it). */
3
3
  export declare function openerOf(el: any): HTMLElement | null;
4
4
  /**
5
- * Tab in a menu leaves it: the focus goes to its button first, so the browser's Tab moves on from
6
- * there to what follows it, and the menu closes.
5
+ * Tab in a menu leaves it: the focus goes to what follows its button, else (at the end of the page)
6
+ * to the button; the menu closes. The Tab is taken (preventDefault), so the popover or sheet around
7
+ * the menu leaves it alone (dom.js: who takes Tab).
7
8
  * @param {KeyboardEvent | React.KeyboardEvent} e
8
9
  * @param {() => void} close
9
10
  */
@@ -18,7 +18,6 @@ export declare const en: {
18
18
  groupLabels: string;
19
19
  labelPosition: string;
20
20
  sharedView: string;
21
- newReport: string;
22
21
  valuesFilter: string;
23
22
  };
24
23
  back: string;
@@ -271,7 +270,6 @@ export declare const en: {
271
270
  replaceConfirm: string;
272
271
  replaceAction: string;
273
272
  replaceSharedConfirm: string;
274
- newAlready: string;
275
273
  save: string;
276
274
  cancel: string;
277
275
  expandAll: string;
@@ -439,7 +437,6 @@ export declare const en: {
439
437
  };
440
438
  defaultName: string;
441
439
  shareThisView: string;
442
- share: string;
443
440
  copyLink: string;
444
441
  copyJson: string;
445
442
  downloadView: string;
@@ -36,7 +36,6 @@ export type Topic = {
36
36
  changed?: boolean;
37
37
  icon?: string;
38
38
  titled?: boolean;
39
- heading?: string;
40
39
  info?: string;
41
40
  hidden?: boolean;
42
41
  levelTitle?: string;
@@ -73,11 +72,10 @@ export type Topic = {
73
72
  * "panel" a row that opens a level with a form (the menu's component draws it, by the topic's id).
74
73
  * `state` is what is set, in short, on the row's right; `changed` marks a setting that is not the
75
74
  * default; `info` the id of an explanation next to the level's title. `hidden`: a level a choice
76
- * opens, with no row of its own (`levelTitle` its title); `note`: a line under its choices;
77
- * `heading`: a group heading above a "menu" or "panel" row on the first level, as an inline topic's title.
75
+ * opens, with no row of its own (`levelTitle` its title); `note`: a line under its choices.
78
76
  * @typedef {{ id: string, title: string, kind: "segmented" | "inline" | "menu" | "panel",
79
77
  * groups?: Array<{ title?: string, choices: Choice[] }>, state?: string | null, changed?: boolean,
80
- * icon?: string, titled?: boolean, heading?: string, info?: string, hidden?: boolean, levelTitle?: string, note?: string | null, noteId?: string,
78
+ * icon?: string, titled?: boolean, info?: string, hidden?: boolean, levelTitle?: string, note?: string | null, noteId?: string,
81
79
  * keywords?: string, searchExtra?: Array<{ id: string, text: string, focus?: string, choice?: Choice }>,
82
80
  * searchFor?: (query: string) => Array<{ id: string, text: string, focus?: string, choice: Choice }> }} Topic
83
81
  * `keywords`: more words the search finds the topic's entries by (a choice's own `keywords` put it
package/types/menus.d.ts CHANGED
@@ -2,6 +2,7 @@ export { AxisMenu, FilterMenu, ValueMenu } from "./chip-menus.jsx";
2
2
  export { ChartTypePanel, ExportPanel, LoadCheck, OptionsPanel, ViewsPanel } from "./toolbar-panels.jsx";
3
3
  export { FilterPopover } from "./filter.jsx";
4
4
  export { DrillPanel } from "./drill-panel.jsx";
5
+ export { DataMenu } from "./data-menu.jsx";
5
6
  export { addMenuTexts, hasMenuTexts, menuLabels } from "./menu-labels.js";
6
7
  export { storedViews } from "./view-store.js";
7
8
  export { prepareExporters, runExport } from "./export-run.js";
@@ -1,17 +1,23 @@
1
1
  /**
2
2
  * The buttons that move into "More" when the toolbar is too narrow, first to go first: a fixed
3
- * priority. The order never depends on a button's own state (Layout open or folded), so a click never
4
- * moves it. Reset goes first: it is wider than "More", which takes its place. Views goes last: it is
5
- * where a user saves the report, so it stays wherever one button besides Undo, Redo and Export fits
6
- * (a report with its field list in a window 1280 px wide). Redo is not in the list: it stays next
7
- * to Undo, which always stays. (New is in the Views menu, not in the toolbar.)
3
+ * priority. The order never depends on a button's own state (Layout open or folded, the chart type
4
+ * picked: its room is its longest type's), so a click never moves it. Layout goes first. Start over
5
+ * and Views go last: Start over holds New, which must be as easy to find as Reset, and Views is where
6
+ * a user saves the report. "data" is the place of a Data button (loading data):
7
+ * a toolbar without one leaves it out and pays nothing for it. Redo is not in the list: it stays next
8
+ * to Undo, which always stays, as do Table | Chart and Export.
8
9
  */
9
10
  export declare const OVERFLOW_ORDER: readonly string[];
10
11
  /**
11
- * The room (em of the toolbar's font) each part of the toolbar takes with the longest text of the
12
- * built-in languages, the gap after it included. How many buttons move into "More" follows from the
13
- * toolbar's width and these numbers, not from the texts shown: at the same width the same buttons
14
- * show in every language. (A host's own longer labels still fit: useOverflow measures as well.)
12
+ * The groups of "More", in order, each with a rule between it and the one before: starting over (its
13
+ * two actions as entries of their own), the report's layout and settings, data, the saved views. A
14
+ * group without an entry in More is not shown.
15
+ */
16
+ export declare const MORE_GROUPS: readonly (readonly string[])[];
17
+ /**
18
+ * The room (em of the toolbar's font) each part of the toolbar takes, the gap after it included: the
19
+ * estimate where the browser cannot measure (a server render, no canvas), with the longer of the
20
+ * built-in languages' texts. The browser measures (toolbarRoom).
15
21
  */
16
22
  export declare const TOOLBAR_ROOM: Readonly<{
17
23
  fields: 6.4;
@@ -20,20 +26,22 @@ export declare const TOOLBAR_ROOM: Readonly<{
20
26
  sep: 1;
21
27
  undo: 8.75;
22
28
  redo: 9.15;
23
- reset: 9.65;
29
+ startOver: 10.9;
24
30
  layout: 8.4;
25
31
  options: 8.75;
32
+ data: 7.4;
26
33
  views: 9.1;
27
34
  export: 7.5;
28
35
  more: 7.2;
29
36
  }>;
30
37
  /**
31
- * Every text each part of the toolbar can show, from several label sets (the built-in languages and
32
- * the report's own): a list of texts per part; for `display` (Table | Chart) the pairs.
33
- * @param {ReadonlyArray<any>} sets labels objects
38
+ * Every text each part of the toolbar can show with the report's labels: a list of texts per part
39
+ * (the chart type: every type's name, so picking one never moves a button); for `display`
40
+ * (Table | Chart) the pair.
41
+ * @param {any} labels
34
42
  * @returns {Record<string, string[]> & { display: string[][] }}
35
43
  */
36
- export declare function toolbarTexts(sets: ReadonlyArray<any>): Record<string, string[]> & {
44
+ export declare function toolbarTexts(labels: any): Record<string, string[]> & {
37
45
  display: string[][];
38
46
  };
39
47
  /**
@@ -53,10 +61,14 @@ export declare function toolbarRoom(texts: ReturnType<typeof toolbarTexts>, meas
53
61
  gap: number;
54
62
  }): Record<string, number>;
55
63
  /**
56
- * How many entries of OVERFLOW_ORDER go into "More" in a toolbar `width` wide: the fewest with
57
- * which the rest fits.
64
+ * The entries of OVERFLOW_ORDER that go into "More" in a toolbar `width` wide: first as few as the
65
+ * order allows (the first ones go until the rest fits, with "More"), then every one of them that the
66
+ * room left still holds comes back, the last in the order first. A button moves only when the room
67
+ * left really cannot hold it.
58
68
  * @param {number} width in the unit of `room` (em for TOOLBAR_ROOM, px for toolbarRoom)
59
69
  * @param {boolean} narrow the report is narrow: the Fields button is there too
70
+ * @param {ReadonlyArray<string>} present the entries of OVERFLOW_ORDER this toolbar has
60
71
  * @param {Readonly<Record<string, number>>} [room]
72
+ * @returns {string[]} in the order of OVERFLOW_ORDER
61
73
  */
62
- export declare function overflowLevel(width: number, narrow: boolean, room?: Readonly<Record<string, number>>): number;
74
+ export declare function overflowHidden(width: number, narrow: boolean, present: ReadonlyArray<string>, room?: Readonly<Record<string, number>>): string[];
@@ -4,6 +4,21 @@ export declare const LayerContext: React.Context<{
4
4
  layer: HTMLElement | null;
5
5
  size: string;
6
6
  }>;
7
+ /**
8
+ * Whether the browser has the Popover API, so a popover goes into the top layer. Read when a popover
9
+ * opens (a page may load a polyfill or lack the API; a server has no HTMLElement).
10
+ */
11
+ export declare const hasTopLayer: () => boolean;
12
+ /**
13
+ * Shows elements in the top layer while a popover is open, in order (the scrim, then the sheet above
14
+ * it); a popover opened later from this one is shown later, so it is above. Hidden again when it
15
+ * closes (an element removed from the page has left the top layer by itself).
16
+ * @param {boolean} open
17
+ * @param {Array<React.RefObject<HTMLElement | null>>} refs
18
+ * @param {unknown} key what re-shows them (the sheet's scrim coming or going)
19
+ * @param {unknown} layer the report's layer: the elements are there only once it is
20
+ */
21
+ export declare function useTopLayer(open: boolean, refs: Array<React.RefObject<HTMLElement | null>>, key: unknown, layer: unknown): void;
7
22
  /**
8
23
  * Whether a wheel turn inside a popover may scroll something there: an element on its way from the
9
24
  * target up to the popover that scrolls in that direction and is not at its end. Else the popover
@@ -44,11 +59,13 @@ export declare function Popover({ open, anchor, onClose, label, role, align, cla
44
59
  * @param {{ label: string, icon?: string, text?: React.ReactNode, showText?: boolean, className?: string,
45
60
  * role?: "menu" | "dialog", align?: "start" | "end", popoverClass?: string, disabled?: boolean,
46
61
  * title?: string, children: (close: () => void) => React.ReactNode, testId?: string, name?: string,
47
- * buttonRef?: React.RefObject<HTMLButtonElement>, tabIndex?: number, slot?: string, fill?: boolean, mark?: React.ReactNode }} props
62
+ * buttonRef?: React.RefObject<HTMLButtonElement>, tabIndex?: number, slot?: string, fill?: boolean, mark?: React.ReactNode, arrowOpens?: boolean, off?: string }} props
48
63
  * `tabIndex`: -1 where a list moves the focus itself (the field list); `mark`: after the text (the
49
- * dot for unsaved changes on "More")
64
+ * dot for unsaved changes on "More"); `arrowOpens`: the down arrow opens it (a toolbar's menu);
65
+ * `off`: why it opens nothing now (every entry of its menu is off): it stays focusable
66
+ * (aria-disabled) with the reason as its description and tooltip
50
67
  */
51
- export declare function MenuButton({ label, icon, text, showText, className, role, align, popoverClass, disabled, title, children, testId, buttonRef, name, tabIndex, slot, fill, mark }: {
68
+ export declare function MenuButton({ label, icon, text, showText, className, role, align, popoverClass, disabled, title, children, testId, buttonRef, name, tabIndex, slot, fill, mark, arrowOpens, off }: {
52
69
  label: string;
53
70
  icon?: string;
54
71
  text?: React.ReactNode;
@@ -67,20 +84,45 @@ export declare function MenuButton({ label, icon, text, showText, className, rol
67
84
  slot?: string;
68
85
  fill?: boolean;
69
86
  mark?: React.ReactNode;
87
+ arrowOpens?: boolean;
88
+ off?: string;
89
+ }): React.JSX.Element;
90
+ /**
91
+ * A group of a menu's entries, the one way every menu draws its groups (the toolbar's menus, More,
92
+ * a chip menu's levels; section.jsx's Section adds the "i"): its title in bold above it, a rule
93
+ * between it and what comes before (styles.css: .pk-section), none above the first. In a dialog the
94
+ * group is the whole block, named by its title. In an ARIA menu (`menu`) the block is presentational
95
+ * and the group holds only the items, as a menu may own groups of items but no other text; a group
96
+ * without a title (More) is named by `label`.
97
+ * @param {{ title?: React.ReactNode, label?: string, menu?: boolean, head?: React.ReactNode, after?: React.ReactNode, children: React.ReactNode, testId?: string, titleTestId?: string }} props
98
+ * `head`: next to the title (an "i"); `after`: under the entries, inside the block (a note);
99
+ * `testId`: the group's, `titleTestId`: the title's
100
+ */
101
+ export declare function Group({ title, label, menu, head, after, children, testId, titleTestId }: {
102
+ title?: React.ReactNode;
103
+ label?: string;
104
+ menu?: boolean;
105
+ head?: React.ReactNode;
106
+ after?: React.ReactNode;
107
+ children: React.ReactNode;
108
+ testId?: string;
109
+ titleTestId?: string;
70
110
  }): React.JSX.Element;
71
111
  /**
72
112
  * One option of a menu or of a chip's settings: one line. `hint` is a short second line that belongs
73
113
  * to the option (a date unit's example); `reason` says why a disabled option does nothing and shows
74
114
  * only while it is disabled (it is state, not an explanation: those go into an "i").
75
- * @param {{ onSelect: () => void, icon?: string, checked?: boolean, children: React.ReactNode, hint?: React.ReactNode,
115
+ * @param {{ onSelect: () => void, icon?: string, checked?: boolean, checkbox?: boolean, children: React.ReactNode, hint?: React.ReactNode,
76
116
  * reason?: React.ReactNode, inMenu?: boolean, disabled?: boolean, danger?: boolean, tone?: "accent", testId?: string, current?: boolean }} props
117
+ * `checkbox`: a toggle of its own in a menu (menuitemcheckbox), not one of a set of choices;
77
118
  * `tone`: "accent" for an option that says what is set (a filter); `current`: the entry shown now
78
119
  * (the view loaded), with a check and aria-current
79
120
  */
80
- export declare function Option({ onSelect, icon, checked, children, hint, reason, inMenu, disabled, danger, tone, testId, current }: {
121
+ export declare function Option({ onSelect, icon, checked, checkbox, children, hint, reason, inMenu, disabled, danger, tone, testId, current }: {
81
122
  onSelect: () => void;
82
123
  icon?: string;
83
124
  checked?: boolean;
125
+ checkbox?: boolean;
84
126
  children: React.ReactNode;
85
127
  hint?: React.ReactNode;
86
128
  reason?: React.ReactNode;
@@ -11,8 +11,8 @@ export declare function SettingInfo({ id, name, tabIndex }: {
11
11
  tabIndex?: number;
12
12
  }): React.JSX.Element | null;
13
13
  /**
14
- * A titled group of a menu's entries (the Export menus, the chart type), with `info`, the id of an
15
- * explanation shown as an "i" next to the title.
14
+ * A titled group of a menu's entries (the Export menus, the chart type): popover.jsx's Group, with
15
+ * `info`, the id of an explanation shown as an "i" next to the title.
16
16
  * @param {{ title: React.ReactNode, children: React.ReactNode, info?: string }} props
17
17
  */
18
18
  export declare function Section({ title, children, info }: {
package/types/toasts.d.ts CHANGED
@@ -13,7 +13,7 @@ export type Toast = {
13
13
  /** @typedef {{ id: number, text: string, action?: { label: string, run: () => void }, tone?: "error" }} Toast */
14
14
  export declare function useToasts(): {
15
15
  toasts: Toast[];
16
- push: (toast: Omit<Toast, "id">) => void;
16
+ push: (toast: Omit<Toast, "id">) => number;
17
17
  dismiss: (id: any) => void;
18
18
  pause: (on: any, list: any) => void;
19
19
  };
@@ -48,11 +48,12 @@ export declare function LoadCheck({ check, labels, onCancel, close, title, quiet
48
48
  quiet?: boolean;
49
49
  }): React.JSX.Element;
50
50
  /**
51
- * The Views menu in levels: its first level is the list to scan - "This view" (Save the loaded view
52
- * under its name, or why not; Save as…; New, an empty report), "Shared views" (the host's, for
53
- * everyone) and "My views" (the user's own: the host's or the browser store's), each shown only when
54
- * it has entries ("My views" also when the user can save), then Share. Save as…, Share (copy a link
55
- * or the JSON, download, load a view) and the questions before a change open levels of their own. An
51
+ * The Views menu in levels: what persists, as one list to scan in groups - "This view" (Save the
52
+ * loaded view under its name, or why not; Save as…), "Shared views" (the host's, for everyone) and
53
+ * "My views" (the user's own: the host's or the browser store's), each shown only when it has entries
54
+ * ("My views" also when the user can save), then "Share this view" (copy a link or the JSON, download
55
+ * the view file, open one). Save as…, Open view file… and the questions before a change open levels
56
+ * of their own. (Starting over, New and Reset, is the toolbar's Start over.) An
56
57
  * entry loads its view; a deletable one has Delete next to it, a user's view Publish when the host
57
58
  * allows it, a shared one that is not deletable the "i" that says who changes shared views. Delete,
58
59
  * publish and Save over a shared view ask first, in a level; the entry changes only when the host's
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The part of a view a path names, as JSON: a value of Values by its field and aggregator (its
3
+ * place may differ from the place in the view as given, which may have had entries that were
4
+ * dropped), a setting of an object section (chart.legend), else the whole section (rows, filters), or
5
+ * the whole view for a path that names none ("" for a view that could not be read at all).
6
+ * @param {string | undefined} path an issue's path in the view as given
7
+ * @param {unknown} raw the view as given (a file's, a link's, the host's), before normalize()
8
+ * @param {Record<string, any>} view a normalized view
9
+ * @returns {string | undefined}
10
+ */
11
+ export declare function partOf(path: string | undefined, raw: unknown, view: Record<string, any>): string | undefined;
12
+ /**
13
+ * Whether a line of the warning still applies to the view shown: the part of the view it names is
14
+ * as it was in the view loaded (both normalized). A line without a path (a text) names its zone in
15
+ * `path`, or nothing (it stays).
16
+ * @param {import("./unused.jsx").UnusedNote} note
17
+ * @param {Record<string, any> | null} loaded the view as loaded, normalized; null: every line stays
18
+ * @param {Record<string, any>} shown the view shown, normalized
19
+ */
20
+ export declare function stillApplies(note: import("./unused.jsx").UnusedNote, loaded: Record<string, any> | null, shown: Record<string, any>): boolean;
package/types/unused.d.ts CHANGED
@@ -4,6 +4,7 @@ export type UnusedNote = {
4
4
  raw: unknown;
5
5
  } | {
6
6
  text: string;
7
+ path?: string;
7
8
  };
8
9
  /**
9
10
  * @param {{ notes: UnusedNote[], notesKey: string, dismissed: boolean, onDismiss: (next: HTMLElement | null) => void,
@@ -6,13 +6,16 @@ export declare function schemaKeyOf(encoded: import("pivotkit-core").Encoded): s
6
6
  /**
7
7
  * @param {{ encoded: import("pivotkit-core").Encoded, view: object | undefined, defaultView: object | undefined,
8
8
  * onViewChange?: (view: import("pivotkit-core").View) => void, limits: object | undefined, outsideNote: string,
9
- * orderOf?: (field: string) => unknown[] | undefined }} options `orderOf`: the host's custom order of a
10
- * field (fieldDefaults.order), applied to every view shown (withHostOrders); keep it stable
9
+ * orderOf?: (field: string) => unknown[] | undefined, dataKey?: string | number,
10
+ * initial?: import("./view-history.js").HistoryState | null }} options `orderOf`: the host's custom order of a
11
+ * field (fieldDefaults.order), applied to every view shown (withHostOrders); keep it stable. `initial`:
12
+ * the history to start on (read on the first render only)
11
13
  * @returns {{ view: import("pivotkit-core").View, viewKey: string, tag: any, setTag: (tag: any) => void, commit: (next: object, note: string, tag?: any) => boolean,
12
14
  * undo: () => string | null, redo: () => string | null, reset: (note: string) => void,
13
- * restore: (view: object, tag?: any) => void, keyOf: (view: object) => string, earlier: () => any[], canUndo: boolean, canRedo: boolean, canReset: boolean }}
15
+ * restore: (view: object, tag?: any) => void, keyOf: (view: object) => string, earlier: () => any[], canUndo: boolean, canRedo: boolean, canReset: boolean, startEmpty: boolean,
16
+ * snapshot: () => import("./view-history.js").HistoryState, replace: (state: import("./view-history.js").HistoryState) => void }}
14
17
  */
15
- export declare function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outsideNote, orderOf }: {
18
+ export declare function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outsideNote, orderOf, dataKey, initial: initialState }: {
16
19
  encoded: import("pivotkit-core").Encoded;
17
20
  view: object | undefined;
18
21
  defaultView: object | undefined;
@@ -20,6 +23,8 @@ export declare function useViewHistory({ encoded, view, defaultView, onViewChang
20
23
  limits: object | undefined;
21
24
  outsideNote: string;
22
25
  orderOf?: (field: string) => unknown[] | undefined;
26
+ dataKey?: string | number;
27
+ initial?: import("./view-history.js").HistoryState | null;
23
28
  }): {
24
29
  view: import("pivotkit-core").View;
25
30
  viewKey: string;
@@ -35,4 +40,7 @@ export declare function useViewHistory({ encoded, view, defaultView, onViewChang
35
40
  canUndo: boolean;
36
41
  canRedo: boolean;
37
42
  canReset: boolean;
43
+ startEmpty: boolean;
44
+ snapshot: () => import("./view-history.js").HistoryState;
45
+ replace: (state: import("./view-history.js").HistoryState) => void;
38
46
  };
@@ -42,3 +42,18 @@ export declare function sliceRows(grid: import("pivotkit-core").Grid, start: num
42
42
  * @param {number} r body row index
43
43
  */
44
44
  export declare function rowLabelOf(grid: import("pivotkit-core").Grid, r: number): string;
45
+ /**
46
+ * The longest row labels of a column by their number of characters, at most `n`: what a virtual table
47
+ * measures for the column's width once, instead of the rows it happens to show (they change as it
48
+ * scrolls). With each label whether it has a group's toggle in front of it and whether it is a total's
49
+ * (drawn bolder). A label spanning several columns (a total) is left out: it widens no single column.
50
+ * @param {import("pivotkit-core").Grid} grid
51
+ * @param {number} col a row label column (below grid.rowHeaderColumns)
52
+ * @param {number} n
53
+ * @returns {Array<{ text: string, toggle: boolean, total: boolean }>}
54
+ */
55
+ export declare function longestLabels(grid: import("pivotkit-core").Grid, col: number, n: number): Array<{
56
+ text: string;
57
+ toggle: boolean;
58
+ total: boolean;
59
+ }>;