pivotkit-react 0.0.0-stage → 0.1.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 (71) hide show
  1. package/CHANGELOG.md +300 -0
  2. package/LICENSE +21 -0
  3. package/README.md +327 -2
  4. package/dist/chunks/chunk-C32TYSHG.js +441 -0
  5. package/dist/chunks/chunk-ILHFIV2P.js +784 -0
  6. package/dist/chunks/chunk-KKJO36W5.js +1833 -0
  7. package/dist/chunks/chunk-XYP47DJ3.js +123 -0
  8. package/dist/echarts.js +262 -0
  9. package/dist/index.js +3390 -0
  10. package/dist/labels.js +12 -0
  11. package/dist/menus.js +1085 -0
  12. package/dist/styles.css +2447 -0
  13. package/package.json +70 -4
  14. package/types/PivotReport.d.ts +20 -0
  15. package/types/all-labels.d.ts +5 -0
  16. package/types/chart-decorate.d.ts +16 -0
  17. package/types/chart-options.d.ts +23 -0
  18. package/types/chart-summary.d.ts +12 -0
  19. package/types/chart-tooltip.d.ts +38 -0
  20. package/types/chart-types.d.ts +152 -0
  21. package/types/chart.d.ts +39 -0
  22. package/types/chip-menus.d.ts +32 -0
  23. package/types/clear-input.d.ts +20 -0
  24. package/types/dnd-moves.d.ts +45 -0
  25. package/types/dnd.d.ts +101 -0
  26. package/types/dom.d.ts +52 -0
  27. package/types/drill-export.d.ts +42 -0
  28. package/types/drill-panel.d.ts +39 -0
  29. package/types/drill.d.ts +62 -0
  30. package/types/echarts.d.ts +4 -0
  31. package/types/export-run.d.ts +59 -0
  32. package/types/field-info.d.ts +34 -0
  33. package/types/fields.d.ts +32 -0
  34. package/types/files.d.ts +27 -0
  35. package/types/filter.d.ts +21 -0
  36. package/types/icons.d.ts +76 -0
  37. package/types/index.d.ts +536 -0
  38. package/types/info.d.ts +34 -0
  39. package/types/iso.d.ts +2 -0
  40. package/types/labels.d.ts +721 -0
  41. package/types/lazy-menus.d.ts +16 -0
  42. package/types/menu-labels.d.ts +255 -0
  43. package/types/menus.d.ts +7 -0
  44. package/types/names.d.ts +80 -0
  45. package/types/numbers.d.ts +13 -0
  46. package/types/overflow.d.ts +59 -0
  47. package/types/place.d.ts +43 -0
  48. package/types/popover.d.ts +89 -0
  49. package/types/rove.d.ts +20 -0
  50. package/types/section.d.ts +42 -0
  51. package/types/share.d.ts +123 -0
  52. package/types/skeleton.d.ts +9 -0
  53. package/types/storage.d.ts +24 -0
  54. package/types/table.d.ts +23 -0
  55. package/types/templates.d.ts +40 -0
  56. package/types/theme.d.ts +24 -0
  57. package/types/tip-list.d.ts +20 -0
  58. package/types/tips.d.ts +298 -0
  59. package/types/toasts.d.ts +26 -0
  60. package/types/toolbar-panels.d.ts +90 -0
  61. package/types/toolbar.d.ts +5 -0
  62. package/types/use-big-result.d.ts +29 -0
  63. package/types/use-export.d.ts +7 -0
  64. package/types/use-theme.d.ts +11 -0
  65. package/types/use-view-history.d.ts +34 -0
  66. package/types/version.d.ts +2 -0
  67. package/types/view-history.d.ts +89 -0
  68. package/types/view-ops.d.ts +344 -0
  69. package/types/view-store.d.ts +52 -0
  70. package/types/virtual.d.ts +44 -0
  71. package/types/zones.d.ts +42 -0
@@ -0,0 +1,90 @@
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 }: {
4
+ close: any;
5
+ labels: any;
6
+ onChart: any;
7
+ onDisplay: any;
8
+ plan: any;
9
+ view: any;
10
+ }): React.JSX.Element;
11
+ export declare function OptionsPanel({ view, labels, onTotal, onExpand, onCollapse, close, tips, mod, folding, help }: {
12
+ close: any;
13
+ folding: any;
14
+ help: any;
15
+ labels: any;
16
+ mod: any;
17
+ onCollapse: any;
18
+ onExpand: any;
19
+ onTotal: any;
20
+ tips: any;
21
+ view: any;
22
+ }): React.JSX.Element;
23
+ /**
24
+ * Before a view for other data is applied: what does not fit, and the choices (load it anyway, let
25
+ * the host switch to its data and load it there, or cancel). Names from the file are text only. It
26
+ * takes the focus when it appears (it replaces the form the focus was in), unless `quiet` (a link at
27
+ * the page's load: the focus stays where the page put it).
28
+ * @param {{ check: { lines: string[], load: () => void, switchTo?: { name: string, run: () => void } }, labels: any, onCancel: () => void, close: () => void, title?: string, quiet?: boolean }} props
29
+ */
30
+ export declare function LoadCheck({ check, labels, onCancel, close, title, quiet }: {
31
+ check: {
32
+ lines: string[];
33
+ load: () => void;
34
+ switchTo?: {
35
+ name: string;
36
+ run: () => void;
37
+ };
38
+ };
39
+ labels: any;
40
+ onCancel: () => void;
41
+ close: () => void;
42
+ title?: string;
43
+ quiet?: boolean;
44
+ }): React.JSX.Element;
45
+ /**
46
+ * The Views menu: the templates in two groups, "Shared views" (the host's, for everyone) and "My
47
+ * views" (the user's own: the host's or the browser store's), each shown only when it has entries
48
+ * ("My views" also with "Save current view"), then sharing. An entry loads its view; a deletable one
49
+ * has a delete button, a shared one that is not has the "i" that says who changes shared views, and
50
+ * a user's view offers "Publish as shared view" when the host allows it. Delete and publish ask
51
+ * first, in place; the entry changes only when the host's callback (or the browser store) has
52
+ * finished, and the focus goes back to the entry in that place. Names need not be unique: every
53
+ * entry is shown, keyed and confirmed by its place in the list.
54
+ * @param {{ templates: import("./templates.js").TemplateEntry[], labels: any, onLoad: (t: any) => void, actions: any, close: () => void, share?: any }} props
55
+ */
56
+ export declare function ViewsPanel({ templates, labels, onLoad, actions, close, share }: {
57
+ templates: import("./templates.js").TemplateEntry[];
58
+ labels: any;
59
+ onLoad: (t: any) => void;
60
+ actions: any;
61
+ close: () => void;
62
+ share?: any;
63
+ }): React.JSX.Element;
64
+ /**
65
+ * One entry of an export menu: the option and, when it needs explaining, its "i".
66
+ * @param {{ icon: string, text: string, info?: string, onSelect: () => void, testId: string, disabled?: boolean, reason?: string }} props
67
+ */
68
+ export declare function ExportOption({ icon, text, info, onSelect, testId, disabled, reason }: {
69
+ icon: string;
70
+ text: string;
71
+ info?: string;
72
+ onSelect: () => void;
73
+ testId: string;
74
+ disabled?: boolean;
75
+ reason?: string;
76
+ }): React.JSX.Element;
77
+ /**
78
+ * The Export menu: the table as a file (Excel, CSV), the chart as an image, and the table on the
79
+ * clipboard (as shown, or its data as JSON). The export module loads when the menu opens, so a copy
80
+ * happens right in the click.
81
+ * @param {{ labels: import("./labels.js").UiLabels, onExport: (kind: string) => void, chartReady: boolean, display: string, prepare: () => void, close: () => void }} props
82
+ */
83
+ export declare function ExportPanel({ labels, onExport, chartReady, display, prepare, close }: {
84
+ labels: import("./labels.js").UiLabels;
85
+ onExport: (kind: string) => void;
86
+ chartReady: boolean;
87
+ display: string;
88
+ prepare: () => void;
89
+ close: () => void;
90
+ }): React.JSX.Element;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ /**
3
+ * @param {any} props see PivotReport for what each one does
4
+ */
5
+ export declare function Toolbar(props: any): React.JSX.Element;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The report's Enlarge and Full screen states and their toggles.
3
+ * @param {React.RefObject<HTMLElement | null>} root
4
+ */
5
+ export declare function useBigResult(root: React.RefObject<HTMLElement | null>): {
6
+ enlarged: boolean;
7
+ setEnlarged: import("react").Dispatch<import("react").SetStateAction<boolean>>;
8
+ toggleEnlarged: () => void;
9
+ full: boolean;
10
+ fullOk: boolean;
11
+ toggleFull: () => void;
12
+ };
13
+ /**
14
+ * The least height of the report's root (its inline min-height): what its toolbar, zones,
15
+ * tips, the result's own least height (CSS min-height) and the status line need. A host box that is
16
+ * 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.
20
+ * @param {React.RefObject<HTMLElement | null>} root
21
+ * @param {React.RefObject<HTMLElement | null>} main the column with the toolbar, the zones and the result
22
+ * @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 }>}
24
+ */
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
+ }>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @param {import("./export-run.js").ExportContext} context
3
+ * @returns {(kind: "xlsx" | "csv" | "png" | "copy-table" | "copy-json") => Promise<void>}
4
+ */
5
+ export declare function useExport(context: import("./export-run.js").ExportContext): (kind: "xlsx" | "csv" | "png" | "copy-table" | "copy-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;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The data-theme of the nearest element above `el` that has one, crossing shadow roots.
3
+ * @param {Element | null} el
4
+ */
5
+ export declare function hostTheme(el: Element | null): string | null;
6
+ /**
7
+ * @param {"auto" | "light" | "dark" | undefined} wanted
8
+ * @param {React.RefObject<HTMLElement | null>} ref the report's root element
9
+ * @returns {"light" | "dark"}
10
+ */
11
+ export declare function useResolvedTheme(wanted: "auto" | "light" | "dark" | undefined, ref: React.RefObject<HTMLElement | null>): "light" | "dark";
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The identity of a data set's columns: names and types.
3
+ * @param {import("pivotkit-core").Encoded} encoded
4
+ */
5
+ export declare function schemaKeyOf(encoded: import("pivotkit-core").Encoded): string;
6
+ /**
7
+ * @param {{ encoded: import("pivotkit-core").Encoded, view: object | undefined, defaultView: object | undefined,
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
11
+ * @returns {{ view: import("pivotkit-core").View, viewKey: string, commit: (next: object, note: string) => boolean,
12
+ * undo: () => string | null, redo: () => string | null, reset: (note: string) => void,
13
+ * restore: (view: object) => void, canUndo: boolean, canRedo: boolean, canReset: boolean }}
14
+ */
15
+ export declare function useViewHistory({ encoded, view, defaultView, onViewChange, limits, outsideNote, orderOf }: {
16
+ encoded: import("pivotkit-core").Encoded;
17
+ view: object | undefined;
18
+ defaultView: object | undefined;
19
+ onViewChange?: (view: import("pivotkit-core").View) => void;
20
+ limits: object | undefined;
21
+ outsideNote: string;
22
+ orderOf?: (field: string) => unknown[] | undefined;
23
+ }): {
24
+ view: import("pivotkit-core").View;
25
+ viewKey: string;
26
+ commit: (next: object, note: string) => boolean;
27
+ undo: () => string | null;
28
+ redo: () => string | null;
29
+ reset: (note: string) => void;
30
+ restore: (view: object) => void;
31
+ canUndo: boolean;
32
+ canRedo: boolean;
33
+ canReset: boolean;
34
+ };
@@ -0,0 +1,2 @@
1
+ /** @type {string} */
2
+ export declare const VERSION: string;
@@ -0,0 +1,89 @@
1
+ /** Steps kept for undo. */
2
+ export declare const HISTORY_LIMIT = 100;
3
+ export type HistoryState = {
4
+ /**
5
+ * the schema the views were normalized against
6
+ */
7
+ schema: string;
8
+ /**
9
+ * the start view, the target of reset
10
+ */
11
+ start: string;
12
+ /**
13
+ * the view the history is at
14
+ */
15
+ present: string;
16
+ /**
17
+ * older views, each with the note of the step that left it
18
+ */
19
+ past: Array<{
20
+ view: string;
21
+ note: string;
22
+ }>;
23
+ /**
24
+ * views undone, newest undo last
25
+ */
26
+ future: Array<{
27
+ view: string;
28
+ note: string;
29
+ }>;
30
+ };
31
+ /**
32
+ * @typedef {object} HistoryState
33
+ * @property {string} schema the schema the views were normalized against
34
+ * @property {string} start the start view, the target of reset
35
+ * @property {string} present the view the history is at
36
+ * @property {Array<{ view: string, note: string }>} past older views, each with the note of the step that left it
37
+ * @property {Array<{ view: string, note: string }>} future views undone, newest undo last
38
+ */
39
+ /**
40
+ * @param {string} schema
41
+ * @param {string} start JSON of the start view
42
+ * @param {string} [current] JSON of the view shown now, default the start
43
+ * @returns {HistoryState}
44
+ */
45
+ export declare function createState(schema: string, start: string, current?: string): HistoryState;
46
+ /**
47
+ * The state a step works on: a new history when the schema changed, and the view the report shows
48
+ * recorded first when it differs from the history (a controlled host passed another view).
49
+ * @param {HistoryState} state
50
+ * @param {{ schema: string, start: string, shown: string, outside: string }} at
51
+ */
52
+ export declare function settle(state: HistoryState, at: {
53
+ schema: string;
54
+ start: string;
55
+ shown: string;
56
+ outside: string;
57
+ }): HistoryState;
58
+ /**
59
+ * A new step; an unchanged view is none. Clears the steps that were undone.
60
+ * @param {HistoryState} state
61
+ * @param {string} view JSON
62
+ * @param {string} note
63
+ * @returns {HistoryState}
64
+ */
65
+ export declare function record(state: HistoryState, view: string, note: string): HistoryState;
66
+ /**
67
+ * One step back; `note` says what was undone (null when there was nothing to undo).
68
+ * @param {HistoryState} state
69
+ * @returns {{ state: HistoryState, note: string | null }}
70
+ */
71
+ export declare function undo(state: HistoryState): {
72
+ state: HistoryState;
73
+ note: string | null;
74
+ };
75
+ /**
76
+ * One undone step again.
77
+ * @param {HistoryState} state
78
+ * @returns {{ state: HistoryState, note: string | null }}
79
+ */
80
+ export declare function redo(state: HistoryState): {
81
+ state: HistoryState;
82
+ note: string | null;
83
+ };
84
+ /**
85
+ * Back to the start view, as one step that can be undone.
86
+ * @param {HistoryState} state
87
+ * @param {string} note
88
+ */
89
+ export declare function reset(state: HistoryState, note: string): HistoryState;
@@ -0,0 +1,344 @@
1
+ export type Zone = "rows" | "cols" | "values" | "filters";
2
+ /** @typedef {"rows" | "cols" | "values" | "filters"} Zone */
3
+ export declare const ZONES: readonly Zone[];
4
+ /** The fields shown in the Filters zone: filtered fields that are on no axis, once each. */
5
+ export declare function filterZoneFields(view: any): any[];
6
+ /** The axis a field is on, or null. */
7
+ export declare function axisOf(view: any, field: any): "cols" | "rows" | null;
8
+ /**
9
+ * The aggregator a new value of a field gets: the host's choice for the field when it fits the type
10
+ * (fieldDefaults), else sum for numbers and count for anything else.
11
+ * @param {string | undefined} type
12
+ * @param {string} [wanted]
13
+ */
14
+ export declare function defaultAgg(type: string | undefined, wanted?: string): string;
15
+ export type AddOptions = {
16
+ /**
17
+ * position in the zone, default the end
18
+ */
19
+ index?: number;
20
+ /**
21
+ * the field's column type, for the aggregator
22
+ */
23
+ type?: string;
24
+ /**
25
+ * the host's settings for
26
+ * the field: a new value's aggregator and format, the custom order of its items on an axis
27
+ */
28
+ defaults?: {
29
+ agg?: string;
30
+ format?: string;
31
+ order?: unknown[];
32
+ };
33
+ /**
34
+ * a date grouping to place instead of the raw date (rows, columns, filters)
35
+ */
36
+ dateUnit?: string | null;
37
+ /**
38
+ * the name of that grouping's derived field
39
+ */
40
+ groupName?: string;
41
+ };
42
+ /**
43
+ * @typedef {object} AddOptions
44
+ * @property {number} [index] position in the zone, default the end
45
+ * @property {string} [type] the field's column type, for the aggregator
46
+ * @property {{ agg?: string, format?: string, order?: unknown[] }} [defaults] the host's settings for
47
+ * the field: a new value's aggregator and format, the custom order of its items on an axis
48
+ * @property {string | null} [dateUnit] a date grouping to place instead of the raw date (rows, columns, filters)
49
+ * @property {string} [groupName] the name of that grouping's derived field
50
+ */
51
+ /**
52
+ * The first zone of a view with more entries than pivotkit-core keeps (Rows and Columns:
53
+ * `limits.axisFields`, Values: `limits.values`), with that maximum; null when every zone fits.
54
+ * normalize() would drop the rest without a word, so the UI refuses such a step or says what it left
55
+ * out.
56
+ * @param {any} view
57
+ * @param {Partial<import("pivotkit-core").Limits> | undefined} limits the host's, over LIMITS
58
+ * @returns {{ zone: "rows" | "cols" | "values", max: number } | null}
59
+ */
60
+ export declare function zoneOverLimit(view: any, limits: Partial<import("pivotkit-core").Limits> | undefined): {
61
+ zone: "rows" | "cols" | "values";
62
+ max: number;
63
+ } | null;
64
+ /**
65
+ * Places a field in a zone at an index (default the end). On an axis the field leaves the other axis
66
+ * (a field is on one axis only); in Values it is added as a new value, so a field can be summed and
67
+ * averaged at once; in Filters it gets an empty filter unless it has one. With `dateUnit` a date is
68
+ * placed grouped (by month, say), as its derived field.
69
+ * @param {any} view
70
+ * @param {string} field
71
+ * @param {Zone} zone
72
+ * @param {AddOptions} [options]
73
+ */
74
+ export declare function addField(view: any, field: string, zone: Zone, options?: AddOptions): any;
75
+ /**
76
+ * Removes the entry at `index` of a zone. A field leaving an axis or the Filters zone takes its
77
+ * filters and its sort with it, as in Excel; a value leaves only that value.
78
+ */
79
+ export declare function removeAt(view: any, zone: any, index: any): any;
80
+ /** The field name of the entry at `index` of a zone. */
81
+ export declare function fieldAt(view: any, zone: any, index: any): any;
82
+ /**
83
+ * Moves an entry from one zone to another (or within one zone) to an index of the target zone. A value
84
+ * moved to an axis or Filters places its field there; an axis field moved to Values adds a value and
85
+ * leaves the axis.
86
+ */
87
+ /**
88
+ * @param {any} view
89
+ * @param {Zone} from
90
+ * @param {number} fromIndex
91
+ * @param {Zone} to
92
+ * @param {number | undefined} toIndex
93
+ * @param {AddOptions} [options]
94
+ */
95
+ export declare function moveField(view: any, from: Zone, fromIndex: number, to: Zone, toIndex: number | undefined, options?: AddOptions): any;
96
+ /** Moves an entry within a zone. */
97
+ export declare function reorder(view: any, zone: any, from: any, to: any): any;
98
+ /**
99
+ * Changes properties of the value at `index` (agg, format, label, showAs, conditional). A new
100
+ * aggregator drops the "show values as" calculation (a running total does not fit an average) and
101
+ * picks the format: one the patch names; else the user's own format (one that is not the host's
102
+ * default) while the result keeps its unit (average to median: still years); else the host's format
103
+ * for the field (fieldDefaults) when its aggregator has that unit; else none, the automatic one.
104
+ * @param {any} view
105
+ * @param {number} index
106
+ * @param {{ agg?: string, format?: string | null, label?: string | null, showAs?: object | null, conditional?: object | null }} patch
107
+ * @param {{ defaults?: { agg?: string, format?: string } }} [options] `defaults`: the host's
108
+ * settings for the value's field
109
+ */
110
+ export declare function updateValue(view: any, index: number, patch: {
111
+ agg?: string;
112
+ format?: string | null;
113
+ label?: string | null;
114
+ showAs?: object | null;
115
+ conditional?: object | null;
116
+ }, options?: {
117
+ defaults?: {
118
+ agg?: string;
119
+ format?: string;
120
+ };
121
+ }): any;
122
+ /**
123
+ * The smallest and the largest number of a number column, for the range form; null without numbers.
124
+ * @param {import("pivotkit-core").Encoded} encoded
125
+ * @param {string} field
126
+ * @returns {{ min: number, max: number } | null}
127
+ */
128
+ export declare function numberRange(encoded: import("pivotkit-core").Encoded, field: string): {
129
+ min: number;
130
+ max: number;
131
+ } | null;
132
+ /**
133
+ * Why ranges of `size` from `start` cannot hold the numbers of `range`, or null when they can. A start
134
+ * so far from the values that a range's bounds can no longer be told apart in a double (1e17 for
135
+ * magnitudes of 2 to 9 in ranges of 0.5) would put every row into "(blank)": "far".
136
+ * @param {number} size
137
+ * @param {number} start
138
+ * @param {{ min: number, max: number } | null} range
139
+ * @returns {"far" | null}
140
+ */
141
+ export declare function binProblem(size: number, start: number, range: {
142
+ min: number;
143
+ max: number;
144
+ } | null): "far" | null;
145
+ /**
146
+ * The derived field a grouping makes of a field on an axis: replaces it in place. `unit` null removes
147
+ * the grouping (back to the source field). Returns the view and the new field's name.
148
+ * @param {any} view
149
+ * @param {string} field the field on the axis (a source field or a derived one)
150
+ * @param {string | null} unit a DERIVED unit of pivotkit-core ("year", "month", "bin", ...)
151
+ * @param {{ size?: number, origin?: number, name?: string }} [options] bins: size and origin (the
152
+ * start of the ranges; without one a range field keeps its own, else 0); name: the derived field's name
153
+ */
154
+ export declare function groupField(view: any, field: string, unit: string | null, options?: {
155
+ size?: number;
156
+ origin?: number;
157
+ name?: string;
158
+ }): {
159
+ view: any;
160
+ field: any;
161
+ };
162
+ /** The grouping of a field: its derived spec, or null for a plain field. */
163
+ export declare function groupingOf(view: any, field: any): any;
164
+ /** The source field of a field: itself, or the field a derived field groups. */
165
+ export declare function sourceOf(view: any, field: any): any;
166
+ /**
167
+ * Sort of a field: { by: "label" | "value" | "custom", order, value?, items? }; null removes the field's sort entry
168
+ * (natural label order).
169
+ */
170
+ export declare function setSort(view: any, field: any, sort: any): any;
171
+ /**
172
+ * The view with the host's custom order (fieldDefaults.order) for every field on Rows or Columns that
173
+ * has no sort entry: a saved or default view sorts such a field as placing it in the UI does
174
+ * (addField). A field with an entry keeps it, "A to Z" included; a grouping has items of its own.
175
+ * Returns the same view when there is nothing to add.
176
+ * @param {any} view normalized
177
+ * @param {(field: string) => unknown[] | undefined} orderOf the host's order of a source field
178
+ */
179
+ export declare function withHostOrders(view: any, orderOf: (field: string) => unknown[] | undefined): any;
180
+ /** The sort entry of a field, or null. */
181
+ export declare function sortOf(view: any, field: any): any;
182
+ /** Filters of one type of a field. */
183
+ export declare function filtersOf(view: any, field: any, types: any): any;
184
+ /**
185
+ * The item filter of a field from the selected values: everything selected removes it; otherwise the
186
+ * values not selected are excluded, so values that appear in newer data are shown, as in Excel.
187
+ * @param {any} view
188
+ * @param {string} field
189
+ * @param {Array<unknown>} selected values (null is blank)
190
+ * @param {Array<unknown>} all every value of the field
191
+ */
192
+ export declare function setItemFilter(view: any, field: string, selected: Array<unknown>, all: Array<unknown>): any;
193
+ /** The values an item filter lets through, from the field's values; all of them without a filter. */
194
+ export declare function selectedItems(view: any, field: any, all: any): any;
195
+ /** The label condition of a field ({ op, value }) or null to remove it. */
196
+ export declare function setLabelFilter(view: any, field: any, condition: any): any;
197
+ /**
198
+ * Top or bottom N items of a field by a value ({ count, bottom, by }), or null to remove it. `previous`
199
+ * is the top filter being edited (the view's own entry); without it the field's top filters are
200
+ * replaced. Another top filter of the field (a view may hold two) stays.
201
+ */
202
+ export declare function setTopFilter(view: any, field: any, top: any, previous: any): any;
203
+ /**
204
+ * A value condition on a field ({ by, op, value, value2 }, pivotkit-core's `value` filter: "Sum of
205
+ * Revenue greater than 1000"), or null to remove it. `previous` is the condition being edited (the
206
+ * view's own entry): only that one is replaced or removed; without it every value condition of the
207
+ * field is. The field keeps its other filters.
208
+ * @param {any} view
209
+ * @param {string} field
210
+ * @param {{ by: { field: string | null, agg: string }, op: string, value: number, value2?: number } | null} condition
211
+ * @param {object} [previous]
212
+ */
213
+ export declare function setValueFilter(view: any, field: string, condition: {
214
+ by: {
215
+ field: string | null;
216
+ agg: string;
217
+ };
218
+ op: string;
219
+ value: number;
220
+ value2?: number;
221
+ } | null, previous?: object): any;
222
+ /**
223
+ * True when a value gives a number for each cell, so it can be shown as a share, formatted, highlighted,
224
+ * sorted by and filtered by: not a list of distinct values, not the first or last entry of a text,
225
+ * not an average, median, minimum or maximum of dates.
226
+ * @param {{ agg: string }} spec
227
+ * @param {string} type the column type of the value's field ("number" for a row count)
228
+ */
229
+ export declare function numericResult(spec: {
230
+ agg: string;
231
+ }, type: string): boolean;
232
+ /**
233
+ * The measures to choose from with `ref` among them: a sort, a top N or a condition may go by a
234
+ * measure the view no longer shows (its value was removed); it stays a choice, so applying the form
235
+ * again keeps it.
236
+ * @param {Array<{ field: string | null, agg: string }>} choices
237
+ * @param {{ field: string | null, agg: string } | null | undefined} ref
238
+ */
239
+ export declare function withMeasure(choices: Array<{
240
+ field: string | null;
241
+ agg: string;
242
+ }>, ref: {
243
+ field: string | null;
244
+ agg: string;
245
+ } | null | undefined): {
246
+ field: string | null;
247
+ agg: string;
248
+ }[];
249
+ /** True when two value references ({ field, agg }) name the same measure. */
250
+ export declare function sameRef(a: any, b: any): boolean;
251
+ /**
252
+ * The measures a field on an axis can be sorted, ranked and filtered by: each value of the view that
253
+ * gives a number, once per field and aggregator, in the view's order; the row count without one. The
254
+ * first one is the default, as pivotkit-core's.
255
+ * @param {any} view
256
+ * @param {(field: string) => string | undefined} typeOf the column type of a field
257
+ * @returns {Array<{ field: string | null, agg: string }>}
258
+ */
259
+ export declare function measureChoices(view: any, typeOf: (field: string) => string | undefined): Array<{
260
+ field: string | null;
261
+ agg: string;
262
+ }>;
263
+ /**
264
+ * Removes what the filter of a field keeps out: its item list, its text condition and a value
265
+ * condition; Top N has its own control and stays. A field in the Filters zone stays there, unfiltered.
266
+ */
267
+ export declare function removeFilters(view: any, field: any): any;
268
+ /** True when a field has an item, text or value filter that removes something (Top N is not counted). */
269
+ export declare function hasFilter(view: any, field: any): any;
270
+ /** True when a field has a filter that removes something. */
271
+ export declare function isFiltered(view: any, field: any): any;
272
+ /** Collapses or expands one group of an axis. */
273
+ export declare function toggleCollapsed(view: any, axis: any, path: any): any;
274
+ /**
275
+ * What "Expand all" and "Collapse all" would do for the rows: each is offered only when it changes
276
+ * something. `outer` are the groups that can collapse (every level but the last, from the pivot's
277
+ * tree); `why` names the reason when one of them would change nothing.
278
+ * @param {any} view
279
+ * @param {Array<Array<unknown>>} outer
280
+ * @returns {{ canExpand: boolean, canCollapse: boolean, collapsed: number, open: number, why: { expand: string | null, collapse: string | null } }}
281
+ */
282
+ export declare function rowFolding(view: any, outer: Array<Array<unknown>>): {
283
+ canExpand: boolean;
284
+ canCollapse: boolean;
285
+ collapsed: number;
286
+ open: number;
287
+ why: {
288
+ expand: string | null;
289
+ collapse: string | null;
290
+ };
291
+ };
292
+ /**
293
+ * Collapses every group of the outer levels of an axis (paths from the pivot's tree), or expands all.
294
+ * @param {any} view
295
+ * @param {"rows" | "cols"} axis
296
+ * @param {Array<Array<unknown>> | null} paths the paths to collapse; null expands everything
297
+ */
298
+ export declare function setCollapsed(view: any, axis: "rows" | "cols", paths: Array<Array<unknown>> | null): any;
299
+ /** The four totals of Options, in their order. */
300
+ export declare const TOTALS: readonly string[];
301
+ /**
302
+ * Why a total of Options would change nothing in this view, or null when it changes something: a
303
+ * grand total row needs a field in Rows (without one the only row is the total), a grand total column
304
+ * one in Columns, subtotals two or more fields on their axis. The key names the text (labels).
305
+ * @param {any} view
306
+ * @param {string} key one of TOTALS
307
+ * @returns {string | null}
308
+ */
309
+ export declare function totalNoEffect(view: any, key: string): string | null;
310
+ /** Turns one of the totals on or off. */
311
+ export declare function setTotal(view: any, key: any, on: any): any;
312
+ /** Table or chart. */
313
+ export declare function setDisplay(view: any, display: any): any;
314
+ /** Switches to the chart with a picker entry's settings (chart-types.js); its display settings stay. */
315
+ export declare function setChart(view: any, name: any): any;
316
+ /**
317
+ * Changes how the chart is drawn: { valueLabels, legend, title, smooth } (pivotkit-core's chart
318
+ * settings); the chart type stays.
319
+ * @param {any} view
320
+ * @param {{ valueLabels?: string, legend?: string, title?: string | null, smooth?: boolean }} patch
321
+ */
322
+ export declare function setChartDisplay(view: any, patch: {
323
+ valueLabels?: string;
324
+ legend?: string;
325
+ title?: string | null;
326
+ smooth?: boolean;
327
+ }): any;
328
+ /**
329
+ * Swaps the fields of Rows and Columns, with their collapsed groups; a calculation along an axis
330
+ * ("running total along Rows") goes along the other one, so it still runs along the same fields.
331
+ */
332
+ export declare function swapAxes(view: any): any;
333
+ /** True when nothing is placed: the UI shows its first steps. */
334
+ export declare function isEmptyView(view: any): boolean;
335
+ /**
336
+ * The condition on a field's labels its type offers: "text" for text, "number" for a number (on the
337
+ * label as shown), none for a date (or a grouping of one) and a yes/no field, whose items the list
338
+ * above chooses.
339
+ * @param {import("pivotkit-core").Encoded} encoded
340
+ * @param {any} view
341
+ * @param {string} field
342
+ * @returns {"text" | "number" | null}
343
+ */
344
+ export declare function conditionKind(encoded: import("pivotkit-core").Encoded, view: any, field: string): "text" | "number" | null;
@@ -0,0 +1,52 @@
1
+ /** The most the browser store keeps per storageKey: views, and characters of their JSON. */
2
+ export declare const VIEW_STORE_LIMITS: Readonly<{
3
+ count: 100;
4
+ text: 500000;
5
+ }>;
6
+ /**
7
+ * The browser store's views from its text, those for the data shown: made for `sourceId` or for no
8
+ * named data.
9
+ * @param {string | null} raw
10
+ * @param {string | undefined} sourceId
11
+ * @returns {Array<{ name: string, view: Record<string, unknown>, at: number }>}
12
+ */
13
+ export declare function storedViews(raw: string | null, sourceId: string | undefined): Array<{
14
+ name: string;
15
+ view: Record<string, unknown>;
16
+ at: number;
17
+ }>;
18
+ /**
19
+ * The browser store's text after a change: `name` saved for `sourceId` (replacing a view of the same
20
+ * name for the same data), or the view at `remove` taken out. A delete checks that the view there is
21
+ * still the one named `removeName` (another tab may have changed the store since the menu was drawn)
22
+ * and throws "changed" when it is not, so the wrong view is never deleted. The caps apply to a save
23
+ * only: a store over them (older caps, changed by hand) can always shrink.
24
+ * @param {string | null} raw
25
+ * @param {{ name?: string, view?: object, sourceId?: string, remove?: number, removeName?: string }} change
26
+ * @param {(kind: "count" | "text" | "changed", max: number) => string} message the Error's message
27
+ * @returns {string | null} null when nothing is left
28
+ */
29
+ export declare function changedViews(raw: string | null, change: {
30
+ name?: string;
31
+ view?: object;
32
+ sourceId?: string;
33
+ remove?: number;
34
+ removeName?: string;
35
+ }, message: (kind: "count" | "text" | "changed", max: number) => string): string | null;
36
+ /**
37
+ * Saves or deletes a view in the browser store (see changedViews). Throws an Error with the reason in
38
+ * the labels' words when the store would hold too much, changed since the menu was drawn, or the
39
+ * browser refused to keep it.
40
+ * @param {string | null} raw the store's text now
41
+ * @param {{ name?: string, view?: object, sourceId?: string, remove?: number, removeName?: string }} change
42
+ * @param {any} labels with the menus' texts
43
+ * @param {string} locale for the numbers
44
+ * @param {(text: string | null) => boolean} keep writes the text (storage.js: writeItem), false when the browser refused
45
+ */
46
+ export declare function storeViews(raw: string | null, change: {
47
+ name?: string;
48
+ view?: object;
49
+ sourceId?: string;
50
+ remove?: number;
51
+ removeName?: string;
52
+ }, labels: any, locale: string, keep: (text: string | null) => boolean): void;