pivotkit-react 0.6.1 → 0.8.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 (62) hide show
  1. package/CHANGELOG.md +212 -1
  2. package/README.md +33 -15
  3. package/dist/chunks/{chunk-JMRTIOX4.js → chunk-2N2UGSIG.js} +7 -0
  4. package/dist/chunks/{chunk-ZK5RVCHP.js → chunk-BHHIZHUE.js} +1 -1
  5. package/dist/chunks/{chunk-YXLANLGL.js → chunk-GUSQWPTH.js} +56 -3
  6. package/dist/chunks/{chunk-JOWAEZAD.js → chunk-JAOOFDNR.js} +21 -1
  7. package/dist/chunks/{chunk-E6M57YLL.js → chunk-MU5BTKSY.js} +7 -0
  8. package/dist/chunks/{chunk-TR2HROIK.js → chunk-RNQ32FCN.js} +66 -5
  9. package/dist/chunks/{chunk-XN5HNKJ2.js → chunk-SJCG4I57.js} +98 -33
  10. package/dist/chunks/{chunk-3LDE2GPG.js → chunk-VMJMDP7C.js} +372 -33
  11. package/dist/chunks/{report-run-BZBFOMPF.js → report-run-HU4WPOB7.js} +3 -1
  12. package/dist/chunks/{unused-texts-Y4R67XSN.js → unused-texts-LRYVWFFN.js} +1 -1
  13. package/dist/chunks/{unused-texts-de-6YVPTNVS.js → unused-texts-de-GB3IWWEM.js} +1 -1
  14. package/dist/echarts.js +426 -35
  15. package/dist/import-ui.js +3 -3
  16. package/dist/index.js +769 -435
  17. package/dist/labels.js +6 -6
  18. package/dist/menu-texts-de.js +1 -1
  19. package/dist/menus.js +1133 -542
  20. package/dist/styles.css +271 -158
  21. package/package.json +8 -4
  22. package/styles.css.d.ts +3 -0
  23. package/types/PivotReport.d.ts +6 -0
  24. package/types/add-menu.d.ts +48 -0
  25. package/types/chart-colors.d.ts +8 -0
  26. package/types/chart-decorate.d.ts +66 -3
  27. package/types/chart-legend.d.ts +176 -0
  28. package/types/chart-summary.d.ts +8 -3
  29. package/types/chart-tooltip.d.ts +159 -17
  30. package/types/chart.d.ts +21 -3
  31. package/types/date-context.d.ts +30 -0
  32. package/types/drill-panel.d.ts +4 -2
  33. package/types/echarts.d.ts +7 -3
  34. package/types/export-run.d.ts +19 -14
  35. package/types/export-scope.d.ts +13 -2
  36. package/types/field-info.d.ts +12 -0
  37. package/types/files.d.ts +14 -0
  38. package/types/filter.d.ts +18 -0
  39. package/types/group-context.d.ts +20 -0
  40. package/types/index.d.ts +35 -6
  41. package/types/label-room.d.ts +13 -0
  42. package/types/labels.d.ts +85 -16
  43. package/types/lazy-menus.d.ts +2 -2
  44. package/types/levels.d.ts +16 -7
  45. package/types/menu-labels.d.ts +67 -1
  46. package/types/menu-ops.d.ts +10 -0
  47. package/types/menu-topics.d.ts +110 -21
  48. package/types/menus.d.ts +3 -2
  49. package/types/names.d.ts +32 -3
  50. package/types/overflow.d.ts +18 -30
  51. package/types/print-frame.d.ts +32 -3
  52. package/types/report-run.d.ts +5 -0
  53. package/types/rove.d.ts +10 -0
  54. package/types/theme-tokens.d.ts +17 -0
  55. package/types/toolbar-panels.d.ts +43 -15
  56. package/types/unused-texts.d.ts +7 -0
  57. package/types/use-big-result.d.ts +24 -9
  58. package/types/use-export.d.ts +8 -4
  59. package/types/view-ops.d.ts +19 -8
  60. package/types/view-tabs.d.ts +12 -0
  61. package/types/zones.d.ts +41 -9
  62. package/types/light-tokens.d.ts +0 -16
@@ -1,30 +1,54 @@
1
1
  import React from "react";
2
- /** The chart type menu: the types (a pick closes it) and how the chart is drawn. */
3
- export declare function ChartTypePanel({ view, plan, labels, onChart, onDisplay, close }: {
2
+ /**
3
+ * Chart settings: the types (a pick closes it), then how the chart is drawn, in levels as the other
4
+ * menus (levels.jsx, menu-topics.js chartTopics): a row per topic with what is set, each opening its
5
+ * level (Value labels, Legend, Title, Axis, Tooltip, Reference lines with its Target, Series, Layout
6
+ * with the groups of Rows folded or not). Each choice applies at once and the menu stays open, so the
7
+ * chart behind it shows the change; folding the groups closes it.
8
+ */
9
+ export declare function ChartSettingsPanel({ view, plan, encoded, lineChecks, labels, locale, onChart, onDisplay, close, series, colors, folding, onExpand, onCollapse }: {
4
10
  close: any;
11
+ colors: any;
12
+ encoded: any;
13
+ folding: any;
5
14
  labels: any;
15
+ lineChecks: any;
16
+ locale: any;
6
17
  onChart: any;
18
+ onCollapse: any;
7
19
  onDisplay: any;
20
+ onExpand: any;
8
21
  plan: any;
22
+ series: any;
9
23
  view: any;
10
24
  }): React.JSX.Element;
11
25
  /**
12
- * The Options menu (topics in menu-topics.js): the totals, Expand all and Collapse all, help with the
13
- * keyboard shortcuts as a level. A switch or an action applies at once and the menu stays open (the
14
- * report behind it shows the change); Expand all and Collapse all close it.
26
+ * Table settings (topics in menu-topics.js): the totals, then Expand all and Collapse all. A switch
27
+ * applies at once and the menu stays open (the table behind it shows the change); Expand all and
28
+ * Collapse all close it.
15
29
  */
16
- export declare function OptionsPanel({ view, labels, onTotal, onExpand, onCollapse, close, tips, mod, folding, help }: {
30
+ export declare function TableSettingsPanel({ view, labels, onTotal, onExpand, onCollapse, close, folding }: {
17
31
  close: any;
18
32
  folding: any;
19
- help: any;
20
33
  labels: any;
21
- mod: any;
22
34
  onCollapse: any;
23
35
  onExpand: any;
24
36
  onTotal: any;
25
- tips: any;
26
37
  view: any;
27
38
  }): React.JSX.Element;
39
+ /**
40
+ * More (topics in menu-topics.js): Help first, a level with the tips' switches and the keyboard
41
+ * shortcuts, then the toolbar's buttons that do not fit (`foot`, drawn by the toolbar in the groups of
42
+ * MORE_GROUPS). A switch keeps Help open.
43
+ */
44
+ export declare function MorePanel({ labels, tips, mod, help, close, foot }: {
45
+ close: any;
46
+ foot: any;
47
+ help: any;
48
+ labels: any;
49
+ mod: any;
50
+ tips: any;
51
+ }): React.JSX.Element;
28
52
  /**
29
53
  * Before a view for other data is applied: what does not fit, and the choices (load it anyway, let
30
54
  * the host switch to its data and load it there, or cancel). Names from the file are text only. It
@@ -72,9 +96,11 @@ export declare function ViewsPanel({ templates, labels, onLoad, actions, close,
72
96
  }): React.JSX.Element;
73
97
  /**
74
98
  * One entry of an export menu: the option and, when it needs explaining, its "i".
75
- * @param {{ icon: string, text: string, info?: string, onSelect: () => void, testId: string, disabled?: boolean, reason?: string }} props
99
+ * @param {{ icon: string, text: string, info?: string, onSelect: () => void, testId: string, disabled?: boolean, reason?: string, onIntent?: () => void }} props
100
+ * `onIntent`: when the pointer comes to the entry, presses on it or the focus does (an entry with
101
+ * its "i")
76
102
  */
77
- export declare function ExportOption({ icon, text, info, onSelect, testId, disabled, reason }: {
103
+ export declare function ExportOption({ icon, text, info, onSelect, testId, disabled, reason, onIntent }: {
78
104
  icon: string;
79
105
  text: string;
80
106
  info?: string;
@@ -82,17 +108,19 @@ export declare function ExportOption({ icon, text, info, onSelect, testId, disab
82
108
  testId: string;
83
109
  disabled?: boolean;
84
110
  reason?: string;
111
+ onIntent?: () => void;
85
112
  }): React.JSX.Element;
86
113
  /**
87
114
  * The Export menu: the table as a file (Excel, CSV), the chart as an image (PNG, SVG), an HTML report,
88
115
  * printing (or saving as PDF from the print dialog), the table on the clipboard (as shown, or its data
89
116
  * as JSON), and last, when the host turns it on (exportData), the source data: every row as it is,
90
117
  * 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.
118
+ * the click; so does a print (the print frame is made ready when the menu opens, the report's modules
119
+ * load when Print is pointed at or focused: use-export.js). An empty report (no field placed) has no table to export: those entries are off, and say
120
+ * so; the source data is there all the same, while the data have rows (#585). The chart's images are off while the table is shown.
93
121
  * `dataExport`: the host's exportData with the data shown, read by export-scope.js (#259).
94
122
  * @param {{ labels: import("./labels.js").UiLabels, onExport: (kind: string) => void, chartReady: boolean, display: string, empty?: boolean,
95
- * dataExport?: { exportData: unknown, encoded: import("pivotkit-core").Encoded | null }, prepare: () => void, close: () => void }} props
123
+ * dataExport?: { exportData: unknown, encoded: import("pivotkit-core").Encoded | null }, prepare: (what: "menu" | "print") => (() => void) | undefined, close: () => void }} props
96
124
  */
97
125
  export declare function ExportPanel({ labels, onExport, chartReady, display, empty, dataExport, prepare, close }: {
98
126
  labels: import("./labels.js").UiLabels;
@@ -104,6 +132,6 @@ export declare function ExportPanel({ labels, onExport, chartReady, display, emp
104
132
  exportData: unknown;
105
133
  encoded: import("pivotkit-core").Encoded | null;
106
134
  };
107
- prepare: () => void;
135
+ prepare: (what: "menu" | "print") => (() => void) | undefined;
108
136
  close: () => void;
109
137
  }): React.JSX.Element;
@@ -22,6 +22,13 @@ export declare const en: {
22
22
  axisLabels: string;
23
23
  groupLabels: string;
24
24
  labelPosition: string;
25
+ tooltip: string;
26
+ zoom: string;
27
+ stackPercent: string;
28
+ hidden: string;
29
+ colors: string;
30
+ tooltipShare: string;
31
+ target: string;
25
32
  other: string;
26
33
  };
27
34
  dropped: {
@@ -10,20 +10,35 @@ export declare function useBigResult(root: React.RefObject<HTMLElement | null>):
10
10
  fullOk: boolean;
11
11
  toggleFull: () => void;
12
12
  };
13
+ export type FitState = {
14
+ need: number;
15
+ open: number;
16
+ grow: boolean;
17
+ folded: {
18
+ need: number;
19
+ open: number;
20
+ } | null;
21
+ size?: string | null;
22
+ };
23
+ /**
24
+ * @typedef {{ need: number, open: number, grow: boolean, folded: { need: number, open: number } | null, size?: string | null }} FitState
25
+ * `folded`: what the column and the open zones needed when the zones folded (null while open);
26
+ * `size`: the width class `open` was measured at
27
+ */
13
28
  /**
14
29
  * The least height of the report's root (its inline min-height): what its toolbar, zones,
15
30
  * tips, the result's own least height (CSS min-height) and the status line need. A host box that is
16
31
  * higher changes nothing; a lower one lets the report grow past it, so the page scrolls. Measured
17
- * after every render and when the report's size changes. The ref holds the last value (`need`, 0:
18
- * none) and what the report needs with its zones open (`open`), so a box too low for the open zones
19
- * folds them (PivotReport) instead of growing, and they stay folded until the box has room.
32
+ * after every render and when the report or a part of its column changes size. The ref holds the
33
+ * last value (`need`, 0: none) and what the report needs with its zones open (`open`), so a box too
34
+ * low for the open zones folds them (PivotReport) instead of growing, and they stay folded until the
35
+ * box has room. `onOpen` runs when `open` changed: the zones can need more while the report's box
36
+ * keeps its size (longer texts in another language, a font or stylesheet that loads late), and no
37
+ * resize of the report says so (#93).
20
38
  * @param {React.RefObject<HTMLElement | null>} root
21
39
  * @param {React.RefObject<HTMLElement | null>} main the column with the toolbar, the zones and the result
22
40
  * @param {boolean} grow the report may grow past its box (else only `open` is measured, for folding)
23
- * @returns {React.MutableRefObject<{ need: number, open: number, grow: boolean }>}
41
+ * @param {() => void} [onOpen]
42
+ * @returns {React.MutableRefObject<FitState>}
24
43
  */
25
- export declare function useFitHeight(root: React.RefObject<HTMLElement | null>, main: React.RefObject<HTMLElement | null>, grow: boolean): React.MutableRefObject<{
26
- need: number;
27
- open: number;
28
- grow: boolean;
29
- }>;
44
+ export declare function useFitHeight(root: React.RefObject<HTMLElement | null>, main: React.RefObject<HTMLElement | null>, grow: boolean, onOpen?: () => void): React.MutableRefObject<FitState>;
@@ -1,7 +1,11 @@
1
1
  /**
2
2
  * @param {import("./export-run.js").ExportContext} context
3
- * @returns {(kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json" | "data-csv" | "data-json") => Promise<void>}
3
+ * @returns {{ run: (kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json" | "copy-chart" | "data-csv" | "data-json") => Promise<void>,
4
+ * prepare: (what: "menu" | "print") => (() => void) | undefined }}
5
+ * `prepare`: the Export menu's, when it opens ("menu"; it returns what ends the menu's print frame)
6
+ * and when Print is pointed at or focused ("print"); one function for the report's lifetime
4
7
  */
5
- export declare function useExport(context: import("./export-run.js").ExportContext): (kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json" | "data-csv" | "data-json") => Promise<void>;
6
- /** Starts loading the export module when a menu that copies opens: a copy right in the click is allowed everywhere. */
7
- export declare const prepareExporters: () => undefined;
8
+ export declare function useExport(context: import("./export-run.js").ExportContext): {
9
+ run: (kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json" | "copy-chart" | "data-csv" | "data-json") => Promise<void>;
10
+ prepare: (what: "menu" | "print") => (() => void) | undefined;
11
+ };
@@ -125,6 +125,14 @@ export declare function zoneOverLimit(view: any, limits: Partial<import("pivotki
125
125
  zone: "rows" | "cols" | "values";
126
126
  max: number;
127
127
  } | null;
128
+ /**
129
+ * The most entries a zone holds (pivotkit-core's `axisFields` for Rows and Columns, `values` for
130
+ * Values), by the host's limits over the defaults; null for Filters, which has no such limit.
131
+ * @param {string} zone
132
+ * @param {Partial<import("pivotkit-core").Limits> | undefined} limits
133
+ * @returns {number | null}
134
+ */
135
+ export declare function zoneMax(zone: string, limits: Partial<import("pivotkit-core").Limits> | undefined): number | null;
128
136
  /**
129
137
  * Places a field in a zone at an index (default the end). On an axis the field leaves the other axis
130
138
  * (a field is on one axis only); in Values it is added as a new value, so a field can be summed and
@@ -347,17 +355,20 @@ export declare function setDisplay(view: any, display: any): any;
347
355
  /** Switches to the chart with a picker entry's settings (chart-types.js); its display settings stay. */
348
356
  export declare function setChart(view: any, name: any): any;
349
357
  /**
350
- * Changes how the chart is drawn: { valueLabels, legend, title, smooth } (pivotkit-core's chart
358
+ * Changes how the chart is drawn: { valueLabels, legend, title, smooth, ... } (pivotkit-core's chart
351
359
  * settings); the chart type stays.
352
360
  * @param {any} view
353
- * @param {{ valueLabels?: string, legend?: string, title?: string | null, smooth?: boolean }} patch
361
+ * @param {Partial<import("pivotkit-core").View["chart"]>} patch
362
+ */
363
+ export declare function setChartDisplay(view: any, patch: Partial<import("pivotkit-core").View["chart"]>): any;
364
+ /**
365
+ * The chart's hidden legend entries (chart.hidden) after `name` is shown or hidden: a click on the
366
+ * legend, or a checkbox of the Display settings.
367
+ * @param {readonly string[] | undefined} hidden
368
+ * @param {string} name
369
+ * @param {boolean} shown
354
370
  */
355
- export declare function setChartDisplay(view: any, patch: {
356
- valueLabels?: string;
357
- legend?: string;
358
- title?: string | null;
359
- smooth?: boolean;
360
- }): any;
371
+ export declare function hiddenAfter(hidden: readonly string[] | undefined, name: string, shown: boolean): string[];
361
372
  /** Rows and Columns swapped (pivotkit-core's swapAxes): the chart's swap, the zones' Swap button. */
362
373
  export { swapAxes };
363
374
  /** True when nothing is placed: the UI shows its first steps. */
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ /**
3
+ * The id of a tab, from the id of the panel it controls.
4
+ * @param {string} panelId
5
+ * @param {"table" | "chart"} display
6
+ */
7
+ export declare const tabId: (panelId: string, display: "table" | "chart") => string;
8
+ /**
9
+ * @param {any} props see PivotReport for what each one does. `panelId`: the result's id (the tab
10
+ * panel); `narrow`: icons only; `big`: use-big-result.js's Enlarge and Full screen
11
+ */
12
+ export declare function ViewTabs(props: any): React.JSX.Element;
package/types/zones.d.ts CHANGED
@@ -10,34 +10,66 @@ export declare function zoneEntries(view: any, types: any, labels: any): {
10
10
  }[];
11
11
  cols: any;
12
12
  rows: any;
13
- values: any;
13
+ values: {
14
+ id: string;
15
+ field: any;
16
+ text: string;
17
+ type: any;
18
+ index: number;
19
+ }[];
14
20
  };
15
21
  /**
16
22
  * @param {{ view: any, types: Map<string, string>, labels: import("./labels.js").UiLabels,
17
- * commit: (view: object, note?: any) => void, earlier?: () => any[],
23
+ * commit: (view: object, note?: any) => boolean, earlier?: () => any[],
18
24
  * encoded: import("pivotkit-core").Encoded, locale: string, onSwap: () => void,
19
- * id: string, folded: boolean, onShow: () => void, defaultsOf?: (field: string) => import("./index.js").FieldDefaults | undefined,
20
- * infoOf?: (field: string) => import("./field-info.js").FieldInfo | undefined, explain?: boolean, showInfo?: boolean }} props
25
+ * id: string, folded: boolean, onFold: () => void, narrow?: boolean, defaultsOf?: (field: string) => import("./index.js").FieldDefaults | undefined,
26
+ * infoOf?: (field: string) => import("./field-info.js").FieldInfo | undefined, titleOf?: (field: string) => string | undefined,
27
+ * explain?: boolean, showInfo?: boolean,
28
+ * adding?: { fields: Array<{ name: string, type: string }>, placed: Map<string, string[]>, nameOf: (field: string) => string,
29
+ * info: Map<string, import("./field-info.js").FieldInfo>, placeName: (field: string, zone: string) => string,
30
+ * onAdd: (field: string, zone: string) => boolean, filterDraft: (field: string) => { field: string, base: object | undefined },
31
+ * fullText: (zone: string, count: number) => string | null } }} props
21
32
  * `explain`: an "i" next to each zone's title that says what the zone does; `showInfo` false: no "i"
22
33
  * of a field description on the chips (Options → Help)
23
- * `folded`: the compact layout's one line; `defaultsOf`: the host's settings for a source field (fieldDefaults);
34
+ * `folded`: the section folded to its heading row; `onFold`: fold or open it; `defaultsOf`: the host's settings for a source field (fieldDefaults);
24
35
  * `infoOf`: the host's description of a field (its source field's for a grouping); `earlier`: the
25
- * history's views before this one (a value's own colours for its Highlight)
36
+ * history's views before this one (a value's own colours for its Highlight); `titleOf`: a
37
+ * field's name with the years its date grouping combines, the chip's tooltip (the chip shows the
38
+ * plain name); `adding`: what "+ Add"
39
+ * needs (the fields, where each is placed, how a pick is placed); without it there is no "+ Add"
26
40
  */
27
- export declare function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap, id, folded, onShow, defaultsOf, infoOf, explain, showInfo }: {
41
+ export declare function Zones({ view, types, labels, commit, earlier, encoded, locale, onSwap, id, folded, onFold, defaultsOf, infoOf, titleOf, explain, showInfo, adding }: {
28
42
  view: any;
29
43
  types: Map<string, string>;
30
44
  labels: import("./labels.js").UiLabels;
31
- commit: (view: object, note?: any) => void;
45
+ commit: (view: object, note?: any) => boolean;
32
46
  earlier?: () => any[];
33
47
  encoded: import("pivotkit-core").Encoded;
34
48
  locale: string;
35
49
  onSwap: () => void;
36
50
  id: string;
37
51
  folded: boolean;
38
- onShow: () => void;
52
+ onFold: () => void;
53
+ narrow?: boolean;
39
54
  defaultsOf?: (field: string) => import("./index.js").FieldDefaults | undefined;
40
55
  infoOf?: (field: string) => import("./field-info.js").FieldInfo | undefined;
56
+ titleOf?: (field: string) => string | undefined;
41
57
  explain?: boolean;
42
58
  showInfo?: boolean;
59
+ adding?: {
60
+ fields: Array<{
61
+ name: string;
62
+ type: string;
63
+ }>;
64
+ placed: Map<string, string[]>;
65
+ nameOf: (field: string) => string;
66
+ info: Map<string, import("./field-info.js").FieldInfo>;
67
+ placeName: (field: string, zone: string) => string;
68
+ onAdd: (field: string, zone: string) => boolean;
69
+ filterDraft: (field: string) => {
70
+ field: string;
71
+ base: object | undefined;
72
+ };
73
+ fullText: (zone: string, count: number) => string | null;
74
+ };
43
75
  }): React.JSX.Element;
@@ -1,16 +0,0 @@
1
- /**
2
- * Tokens as the report's light theme resolves them, in either theme: a workbook and an HTML report are
3
- * light (black text in Excel, paper), so a host's light colours go into them from a dark report too.
4
- * A dark report shows the light theme for the read, on its root and, inside pivotkit-element, on the
5
- * element whose :host rules declare the tokens, and the dark one again in the same task, so nothing is
6
- * drawn in between; --pk-duration is 0ms meanwhile (on the root, important), so no transition of the
7
- * report's starts on the way there or back. A host's dark rules on data-pk-theme="dark" are left out
8
- * that way; rules on something else (an html[data-theme] of the page) apply in both. Lengths are
9
- * resolved by the chart's module (chart-decorate.js, tokenLengths), passed in as `more`, read in the
10
- * light theme too.
11
- * @param {HTMLElement} root the report's root
12
- * @param {readonly string[]} names
13
- * @param {() => Record<string, string>} [more] further tokens read while the light theme shows
14
- * @returns {Record<string, string>} the tokens that are set
15
- */
16
- export declare function lightTokens(root: HTMLElement, names: readonly string[], more?: () => Record<string, string>): Record<string, string>;