pivotkit-react 0.2.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 (64) hide show
  1. package/CHANGELOG.md +284 -1
  2. package/README.md +1 -1
  3. package/dist/chunks/{chunk-F6MVUAQD.js → chunk-6MDAL3IO.js} +51 -3
  4. package/dist/chunks/{chunk-53ZMK4BH.js → chunk-EM23V5GH.js} +6 -0
  5. package/dist/chunks/{chunk-LQCWFJBS.js → chunk-LEN5RPBM.js} +147 -26
  6. package/dist/chunks/{chunk-OYY4BKIL.js → chunk-RWYHJRQO.js} +6 -0
  7. package/dist/chunks/{chunk-QBD4FOBB.js → chunk-WB4GKWFQ.js} +124 -18
  8. package/dist/chunks/chunk-XN55BQ4M.js +618 -0
  9. package/dist/chunks/{chunk-X7H7BAVT.js → chunk-YITKWZ4L.js} +312 -628
  10. package/dist/chunks/chunk-ZYEYZSYL.js +187 -0
  11. package/dist/chunks/{unused-texts-YTNJCFFC.js → unused-texts-K3VFH65P.js} +1 -1
  12. package/dist/chunks/{unused-texts-de-SGOHV4N7.js → unused-texts-de-OW4TGIVX.js} +1 -1
  13. package/dist/import-ui.js +769 -0
  14. package/dist/import-worker.js +20 -0
  15. package/dist/index.js +653 -227
  16. package/dist/labels.js +14 -10
  17. package/dist/menu-texts-de.js +1 -1
  18. package/dist/menus.js +2499 -676
  19. package/dist/styles.css +673 -125
  20. package/package.json +3 -2
  21. package/types/chip-menus.d.ts +20 -4
  22. package/types/data-history.d.ts +85 -0
  23. package/types/data-keep.d.ts +51 -0
  24. package/types/data-menu.d.ts +11 -0
  25. package/types/dnd.d.ts +8 -4
  26. package/types/dom.d.ts +40 -7
  27. package/types/field-info.d.ts +32 -0
  28. package/types/filter-level.d.ts +16 -0
  29. package/types/filter.d.ts +31 -0
  30. package/types/help.d.ts +0 -7
  31. package/types/import-host.d.ts +53 -0
  32. package/types/import-labels.d.ts +360 -0
  33. package/types/import-module.d.ts +2 -0
  34. package/types/import-run.d.ts +73 -0
  35. package/types/import-source.d.ts +32 -0
  36. package/types/import-steps.d.ts +121 -0
  37. package/types/import-ui.d.ts +108 -0
  38. package/types/import-worker.d.ts +1 -0
  39. package/types/index.d.ts +56 -4
  40. package/types/labels.d.ts +97 -2
  41. package/types/lazy-import.d.ts +4 -0
  42. package/types/lazy-menus.d.ts +2 -2
  43. package/types/levels.d.ts +106 -0
  44. package/types/menu-fields.d.ts +80 -0
  45. package/types/menu-labels.d.ts +214 -22
  46. package/types/menu-ops.d.ts +150 -9
  47. package/types/menu-topics.d.ts +291 -0
  48. package/types/menus.d.ts +2 -1
  49. package/types/names.d.ts +141 -1
  50. package/types/overflow.d.ts +29 -17
  51. package/types/place.d.ts +44 -0
  52. package/types/popover.d.ts +47 -5
  53. package/types/section.d.ts +8 -11
  54. package/types/tips.d.ts +1 -36
  55. package/types/toasts.d.ts +1 -1
  56. package/types/toolbar-panels.d.ts +17 -9
  57. package/types/unused-keep.d.ts +20 -0
  58. package/types/unused-texts.d.ts +6 -0
  59. package/types/unused.d.ts +1 -0
  60. package/types/use-view-history.d.ts +13 -4
  61. package/types/view-ops.d.ts +12 -0
  62. package/types/virtual.d.ts +15 -0
  63. package/types/zones.d.ts +5 -4
  64. package/types/sections.d.ts +0 -2
@@ -0,0 +1,291 @@
1
+ export type Choice = {
2
+ id: string;
3
+ text: string;
4
+ change?: () => {
5
+ view: any;
6
+ note: any;
7
+ } | null;
8
+ run?: () => void;
9
+ checked?: boolean;
10
+ hint?: string;
11
+ icon?: string;
12
+ closes?: boolean;
13
+ checkbox?: boolean;
14
+ disabled?: boolean;
15
+ reason?: string;
16
+ info?: string;
17
+ keywords?: string;
18
+ open?: string;
19
+ backTo?: string;
20
+ actions?: Array<Choice & {
21
+ label: string;
22
+ }>;
23
+ current?: boolean;
24
+ testId?: string;
25
+ label?: string;
26
+ };
27
+ export type Topic = {
28
+ id: string;
29
+ title: string;
30
+ kind: "segmented" | "inline" | "menu" | "panel";
31
+ groups?: Array<{
32
+ title?: string;
33
+ choices: Choice[];
34
+ }>;
35
+ state?: string | null;
36
+ changed?: boolean;
37
+ icon?: string;
38
+ titled?: boolean;
39
+ info?: string;
40
+ hidden?: boolean;
41
+ levelTitle?: string;
42
+ note?: string | null;
43
+ noteId?: string;
44
+ keywords?: string;
45
+ searchExtra?: Array<{
46
+ id: string;
47
+ text: string;
48
+ focus?: string;
49
+ choice?: Choice;
50
+ }>;
51
+ searchFor?: (query: string) => Array<{
52
+ id: string;
53
+ text: string;
54
+ focus?: string;
55
+ choice: Choice;
56
+ }>;
57
+ };
58
+ /**
59
+ * One choice of a topic: a menu item. `change` gives the next view and the history's note, or `run`
60
+ * does what it does; `closes`: the menu closes after it (the chip it belongs to is replaced, or moves
61
+ * away). `checkbox`: a switch (`checked` on or off) instead of one of several; `disabled` with the
62
+ * `reason`; `info`: the id of its explanation (labels.settingInfo). `open`: the id of a topic whose
63
+ * level it opens (after `run`; Back puts the focus on `backTo`, else on the choice), instead of applying; `actions`: an entry's own actions next to it
64
+ * (choices themselves, drawn as icon buttons with `label`); `current`: the entry shown now.
65
+ * @typedef {{ id: string, text: string, change?: () => { view: any, note: any } | null, run?: () => void, checked?: boolean,
66
+ * hint?: string, icon?: string, closes?: boolean, checkbox?: boolean, disabled?: boolean, reason?: string, info?: string,
67
+ * keywords?: string, open?: string, backTo?: string, actions?: Array<Choice & { label: string }>, current?: boolean, testId?: string, label?: string }} Choice
68
+ */
69
+ /**
70
+ * One topic of a menu. `kind`: "segmented" its choices on the first level side by side, "inline" one
71
+ * below the other (`titled`: under its title), "menu" a row that opens a level with its choices,
72
+ * "panel" a row that opens a level with a form (the menu's component draws it, by the topic's id).
73
+ * `state` is what is set, in short, on the row's right; `changed` marks a setting that is not the
74
+ * default; `info` the id of an explanation next to the level's title. `hidden`: a level a choice
75
+ * opens, with no row of its own (`levelTitle` its title); `note`: a line under its choices.
76
+ * @typedef {{ id: string, title: string, kind: "segmented" | "inline" | "menu" | "panel",
77
+ * groups?: Array<{ title?: string, choices: Choice[] }>, state?: string | null, changed?: boolean,
78
+ * icon?: string, titled?: boolean, info?: string, hidden?: boolean, levelTitle?: string, note?: string | null, noteId?: string,
79
+ * keywords?: string, searchExtra?: Array<{ id: string, text: string, focus?: string, choice?: Choice }>,
80
+ * searchFor?: (query: string) => Array<{ id: string, text: string, focus?: string, choice: Choice }> }} Topic
81
+ * `keywords`: more words the search finds the topic's entries by (a choice's own `keywords` put it
82
+ * first among the hits for them); `searchExtra`: more entries of a panel topic (a part of its level,
83
+ * or a quick choice of it); `searchFor`: entries made from what is typed ("last 3 years", "from 2022").
84
+ */
85
+ /** The formats the value menu offers first, and those under "More formats"; any other format of a view still works. */
86
+ export declare const FORMAT_CHOICES: readonly string[];
87
+ export declare const MORE_FORMATS: readonly string[];
88
+ /** The quick choices of Top items, besides Off and a count of one's own. */
89
+ export declare const TOP_COUNTS: readonly number[];
90
+ /**
91
+ * The topics of a field's menu on Rows or Columns: sort by label (side by side), sort by a value,
92
+ * Filter, the grouping of a date or a number, Top items, Move to.
93
+ * @param {{ view: any, zone: string, index: number, field: string, types: Map<string, string>,
94
+ * labels: any, locale: string, state?: any, defaultsOf?: (field: string) => any, encoded?: any }} input
95
+ * `state`: the chip's state (zones.jsx), for the filter's "3 of 12"; `encoded`: the data, for the
96
+ * search's quick choices of a date field
97
+ * @returns {Topic[]}
98
+ */
99
+ export declare function axisTopics({ view, zone, index, field, types, labels, locale, state, defaultsOf, encoded }: {
100
+ view: any;
101
+ zone: string;
102
+ index: number;
103
+ field: string;
104
+ types: Map<string, string>;
105
+ labels: any;
106
+ locale: string;
107
+ state?: any;
108
+ defaultsOf?: (field: string) => any;
109
+ encoded?: any;
110
+ }): Topic[];
111
+ /**
112
+ * The Filter topic of a field's menu: its state in words ("last 5 years (2022–2026)", "3 of 12"), the
113
+ * rules found by their names (they open the level on them), and from what is typed in the search,
114
+ * for a date field: the quick choices with that count ("Last 3 years (2024–2026)") and, for a grouping
115
+ * by year, a year compared ("From 2022"), applied at once.
116
+ * @param {{ view: any, field: string, labels: any, locale: string, state?: any, encoded?: any }} input
117
+ * @returns {Topic}
118
+ */
119
+ export declare function filterTopic({ view, field, labels, locale, state, encoded }: {
120
+ view: any;
121
+ field: string;
122
+ labels: any;
123
+ locale: string;
124
+ state?: any;
125
+ encoded?: any;
126
+ }): Topic;
127
+ /**
128
+ * The topics of a field's menu in Filters (the whole report): Filter, Move to.
129
+ * @param {{ view: any, index: number, field: string, types: Map<string, string>, labels: any, locale: string, state?: any, encoded?: any }} input
130
+ * @returns {Topic[]}
131
+ */
132
+ export declare function filterZoneTopics({ view, index, field, types, labels, locale, state, encoded }: {
133
+ view: any;
134
+ index: number;
135
+ field: string;
136
+ types: Map<string, string>;
137
+ labels: any;
138
+ locale: string;
139
+ state?: any;
140
+ encoded?: any;
141
+ }): Topic[];
142
+ /**
143
+ * A Top items filter in words: "Top 10 by Sum of Revenue", "Bottom 3 by Count".
144
+ * @param {any} view
145
+ * @param {{ count: number, bottom?: boolean, by?: { field: string | null, agg: string } }} top
146
+ */
147
+ export declare function topText(view: any, top: {
148
+ count: number;
149
+ bottom?: boolean;
150
+ by?: {
151
+ field: string | null;
152
+ agg: string;
153
+ };
154
+ }, labels: any, locale: any): string;
155
+ /**
156
+ * A format in words: its own label, a number with other decimals ("Number, 1 decimal"), else the
157
+ * label of its kind ("Currency" for currency:USD), else its name.
158
+ * @param {string} format
159
+ */
160
+ export declare function formatLabel(format: string, labels: any, locale: any): any;
161
+ /**
162
+ * The topics of a value's menu: Summarize by, Show as, Number format (each a level), Highlight (side
163
+ * by side), Name, Move to. A value whose result is no number has no Show as, format or highlight.
164
+ * @param {{ view: any, index: number, types: Map<string, string>, labels: any, locale: string, defaultsOf?: (field: string) => any,
165
+ * earlier?: () => any[] }} input `earlier`: the history's views before this one, oldest first
166
+ * @returns {Topic[]}
167
+ */
168
+ export declare function valueTopics({ view, index, types, labels, locale, defaultsOf, earlier }: {
169
+ view: any;
170
+ index: number;
171
+ types: Map<string, string>;
172
+ labels: any;
173
+ locale: string;
174
+ defaultsOf?: (field: string) => any;
175
+ earlier?: () => any[];
176
+ }): Topic[];
177
+ /**
178
+ * The topics of the Options menu: the totals (each a switch; one that would change nothing in this
179
+ * view is off, with the reason), Expand all and Collapse all (each only when it changes something,
180
+ * else with the reason), and help: Show tips, Show explanations, Show dismissed tips again, and the
181
+ * keyboard shortcuts (a level). What each does is the report's (`act`).
182
+ * @param {{ view: any, labels: any, folding: { canExpand: boolean, canCollapse: boolean, why: { expand?: string | null, collapse?: string | null } },
183
+ * tips: { controls: boolean, on: boolean, canReset: boolean }, explanations?: { on: boolean } | null,
184
+ * act: { total: (key: string, on: boolean) => void, expand: () => void, collapse: () => void, tipsOn: (on: boolean) => void,
185
+ * resetTips: () => void, explain: (on: boolean) => void } }} input
186
+ * @returns {Topic[]}
187
+ */
188
+ export declare function optionTopics({ view, labels, folding, tips, explanations, act }: {
189
+ view: any;
190
+ labels: any;
191
+ folding: {
192
+ canExpand: boolean;
193
+ canCollapse: boolean;
194
+ why: {
195
+ expand?: string | null;
196
+ collapse?: string | null;
197
+ };
198
+ };
199
+ tips: {
200
+ controls: boolean;
201
+ on: boolean;
202
+ canReset: boolean;
203
+ };
204
+ explanations?: {
205
+ on: boolean;
206
+ } | null;
207
+ act: {
208
+ total: (key: string, on: boolean) => void;
209
+ expand: () => void;
210
+ collapse: () => void;
211
+ tipsOn: (on: boolean) => void;
212
+ resetTips: () => void;
213
+ explain: (on: boolean) => void;
214
+ };
215
+ }): Topic[];
216
+ /**
217
+ * The ids of the Views menu's entries: by their group, their name and how often the name came
218
+ * before in that group, so an entry keeps its id when one before it is deleted, and two entries of
219
+ * one name are told apart.
220
+ * @param {Array<{ scope: string, name: string }>} templates
221
+ */
222
+ export declare function entryIds(templates: Array<{
223
+ scope: string;
224
+ name: string;
225
+ }>): string[];
226
+ /**
227
+ * The entry the focus goes to once the entry at `place` of a group is deleted: the next one, else
228
+ * the one before it; undefined when it was the only one.
229
+ * @template T
230
+ * @param {T[]} list
231
+ * @param {number} place
232
+ */
233
+ export declare const afterDelete: <T>(list: T[], place: number) => T;
234
+ export type SearchEntry = {
235
+ id: string;
236
+ text: string;
237
+ path: string;
238
+ topic: Topic;
239
+ choice?: Choice;
240
+ focus?: string;
241
+ };
242
+ /**
243
+ * One entry of a menu's search: a choice of a topic (with the path to it), or a topic's level
244
+ * (`focus`: the part of it to show and focus).
245
+ * @typedef {{ id: string, text: string, path: string, topic: Topic, choice?: Choice, focus?: string }} SearchEntry
246
+ */
247
+ /**
248
+ * Every entry of a menu, for its search: each choice with the titles above it as its path ("Number
249
+ * format › More formats"), each panel as an entry that opens it, and the entries a topic makes from
250
+ * what is typed (`query`).
251
+ * @param {Topic[]} topics
252
+ * @param {string} [query]
253
+ * @returns {SearchEntry[]}
254
+ */
255
+ export declare function searchEntries(topics: Topic[], query?: string): SearchEntry[];
256
+ /** At most this many hits show. */
257
+ export declare const SEARCH_HITS = 8;
258
+ /**
259
+ * The entries every word of `query` is found in (its text or its path), at most SEARCH_HITS; those
260
+ * whose text starts with the query first.
261
+ * @param {SearchEntry[]} entries
262
+ * @param {string} query
263
+ * @param {string} [locale]
264
+ * @returns {SearchEntry[]}
265
+ */
266
+ export declare function searchHits(entries: SearchEntry[], query: string, locale?: string): SearchEntry[];
267
+ /**
268
+ * A row's accessible name: "Filter, 3 of 12, changed" (`changedWord`: ", changed").
269
+ * @param {string} title
270
+ * @param {string | null | undefined} state
271
+ * @param {boolean | undefined} changed
272
+ * @param {string} changedWord
273
+ */
274
+ export declare const rowName: (title: string, state: string | null | undefined, changed: boolean | undefined, changedWord: string) => string;
275
+ /**
276
+ * Where the focus goes in a list of `count` items from `at` for a key (ArrowDown, ArrowUp, Home,
277
+ * End), around the ends; null for another key.
278
+ * @param {string} key
279
+ * @param {number} at -1 when no item has the focus
280
+ * @param {number} count
281
+ */
282
+ export declare function stepIndex(key: string, at: number, count: number): number | null;
283
+ /**
284
+ * Type-ahead: the next item after `at` whose text starts with `typed` (the letters typed in a short
285
+ * while), around the end; null when none does.
286
+ * @param {string[]} texts
287
+ * @param {number} at
288
+ * @param {string} typed
289
+ * @param {string} [locale]
290
+ */
291
+ export declare function typeAheadIndex(texts: string[], at: number, typed: string, locale?: string): number | null;
package/types/menus.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- export { AxisMenu, ValueMenu } from "./chip-menus.jsx";
1
+ 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";
package/types/names.d.ts CHANGED
@@ -3,7 +3,8 @@ export declare function valueLabel(spec: any, labels: any): any;
3
3
  /**
4
4
  * The name of a measure a sort, a top N or a value condition goes by ({ field, agg }): the name of the
5
5
  * view's value for it ("Sum of Revenue", or the name the user gave it), without a "show as"
6
- * calculation, since the raw result is what is compared.
6
+ * calculation, since the raw result is what is compared; the row count the view does not show is
7
+ * "Count of rows".
7
8
  * @param {any} view
8
9
  * @param {{ field: string | null, agg: string } | null | undefined} ref
9
10
  * @param {import("./labels.js").UiLabels} labels
@@ -42,6 +43,145 @@ export declare function valueConditionText(view: any, f: {
42
43
  value: number;
43
44
  value2?: number;
44
45
  }, labels: import("./labels.js").UiLabels, locale: string): string;
46
+ /** A calendar day ("2022-03-01") as the locale writes a date. */
47
+ export declare const dayText: (iso: any, locale: any) => string;
48
+ /** A calendar day of wall-clock ms ("2022-03-01"), as a date column holds dates. */
49
+ export declare const isoDay: (ms: any) => string;
50
+ /**
51
+ * The days a relative filter keeps, both included (pivotkit-core's relativeDateRange): counted back
52
+ * from today (`now`, default the current time) or, with `anchor: "latest"`, from the data's latest
53
+ * date (`latest`, wall-clock ms); null without one then, or for a range that leaves what a Date holds.
54
+ * @param {{ unit: string, count: number, anchor?: string }} f a `relative` filter
55
+ * @param {string} timeZone the data's
56
+ * @param {Date | number | string} [now]
57
+ * @param {number | null} [latest]
58
+ * @returns {{ from: string, to: string } | null}
59
+ */
60
+ export declare const relativeDays: (f: {
61
+ unit: string;
62
+ count: number;
63
+ anchor?: string;
64
+ }, timeZone: string, now?: Date | number | string, latest?: number | null) => {
65
+ from: string;
66
+ to: string;
67
+ } | null;
68
+ /**
69
+ * A range of days as the unit writes it: "2022–2026" for years, "Dec 2025–Nov 2026" for months, dates
70
+ * for days; one period alone ("2026").
71
+ * @param {{ from: string, to: string }} range ISO days, both included
72
+ * @param {string} unit
73
+ * @param {string} locale
74
+ */
75
+ export declare function periodText(range: {
76
+ from: string;
77
+ to: string;
78
+ }, unit: string, locale: string): any;
79
+ /**
80
+ * The days a relative date range keeps, as the unit writes them: "2022–2026" for years, "Dec
81
+ * 2025–Nov 2026" for months, dates for days; one period alone ("2026"); "" for no range.
82
+ * @param {{ unit: string, count: number, anchor?: string }} f a `relative` filter
83
+ * @param {string} locale
84
+ * @param {string} timeZone the data's
85
+ * @param {Date | number | string} [now] today, default the current time
86
+ * @param {number | null} [latest] the data's latest date (wall-clock ms), for anchor "latest"
87
+ */
88
+ export declare function rangeText(f: {
89
+ unit: string;
90
+ count: number;
91
+ anchor?: string;
92
+ }, locale: string, timeZone: string, now?: Date | number | string, latest?: number | null): any;
93
+ /**
94
+ * The data's share of a range: which of its days have data and which have none. Null when the data
95
+ * cover the whole range; `none` when they cover none of it; else the days with data (`data`) and
96
+ * the parts without, as years when whole years have no data ("2026"), else as the unit writes them.
97
+ * @param {{ from: string, to: string }} range ISO days
98
+ * @param {string} unit
99
+ * @param {{ min: number, max: number }} span the data's first and last date (wall-clock ms)
100
+ * @param {string} locale
101
+ * @returns {{ none: true } | { none: false, data: string, missing: string[], count: number } | null} `count`: how many
102
+ * periods have no data, for the words ("2026 has no data", "2021–2022 have no data")
103
+ */
104
+ export declare function rangeShare(range: {
105
+ from: string;
106
+ to: string;
107
+ }, unit: string, span: {
108
+ min: number;
109
+ max: number;
110
+ }, locale: string): {
111
+ none: true;
112
+ } | {
113
+ none: false;
114
+ data: string;
115
+ missing: string[];
116
+ count: number;
117
+ } | null;
118
+ /**
119
+ * A relative date range in short, with the days it keeps: "last 5 years (2022–2026)", "this year
120
+ * (2026)". With the data's span, the data's share of them: "last 2 years (2025; 2026 has no data)",
121
+ * "this year (2026 has no data)". Anchored at the data's latest date: "last 12 months to Dec 2025",
122
+ * its days only when the data do not cover them all.
123
+ * @param {{ unit: string, count: number, anchor?: string }} f a `relative` filter
124
+ * @param {import("./labels.js").UiLabels} labels
125
+ * @param {string} locale
126
+ * @param {string} timeZone the data's
127
+ * @param {Date | number | string} [now] today, default the current time
128
+ * @param {{ min: number, max: number } | null} [span] the data's first and last date (wall-clock ms)
129
+ */
130
+ export declare function relativeText(f: {
131
+ unit: string;
132
+ count: number;
133
+ anchor?: string;
134
+ }, labels: import("./labels.js").UiLabels, locale: string, timeZone: string, now?: Date | number | string, span?: {
135
+ min: number;
136
+ max: number;
137
+ } | null): string;
138
+ /**
139
+ * The years two calendar days bound as whole years (Jan 1 to Dec 31), or null: the days a comparison
140
+ * on a date grouping's source dates gets from Years combined.
141
+ * @returns {[string, string] | null}
142
+ */
143
+ export declare function wholeYears(from: any, to: any): [string, string] | null;
144
+ /**
145
+ * A comparison of the item itself in short: "from 2022", "2022 to 2024" for a date or a date
146
+ * grouping, "≥ 10" for a number. `labelOf` gives an item's label (a grouping's "Mar 2025").
147
+ * @param {{ op: string, value: number | string, value2?: number | string }} f a `compare` filter
148
+ * @param {import("./labels.js").UiLabels} labels
149
+ * @param {string} locale
150
+ * @param {{ date: boolean, labelOf?: (value: number) => string | undefined }} kind
151
+ */
152
+ export declare function compareText(f: {
153
+ op: string;
154
+ value: number | string;
155
+ value2?: number | string;
156
+ }, labels: import("./labels.js").UiLabels, locale: string, { date, labelOf }: {
157
+ date: boolean;
158
+ labelOf?: (value: number) => string | undefined;
159
+ }): string;
160
+ /**
161
+ * A rule on a field's items in short, as its chip and its menu say it: "last 5 years (2022–2026)",
162
+ * "from 2022", "contains “an”".
163
+ * @param {{ type: string, op?: string, value?: any, value2?: any, unit?: string, count?: number }} f a `relative`, `compare` or `label` filter
164
+ * @param {import("./labels.js").UiLabels} labels
165
+ * @param {string} locale
166
+ * @param {{ timeZone: string, date: boolean, labelOf?: (value: number) => string | undefined, span?: { min: number, max: number } | null }} kind
167
+ * `span`: the data's first and last date, for the data's share of a relative range
168
+ */
169
+ export declare function itemRuleText(f: {
170
+ type: string;
171
+ op?: string;
172
+ value?: any;
173
+ value2?: any;
174
+ unit?: string;
175
+ count?: number;
176
+ }, labels: import("./labels.js").UiLabels, locale: string, { timeZone, date, labelOf, span }: {
177
+ timeZone: string;
178
+ date: boolean;
179
+ labelOf?: (value: number) => string | undefined;
180
+ span?: {
181
+ min: number;
182
+ max: number;
183
+ } | null;
184
+ }): string;
45
185
  /** The name of a derived field for a grouping, in the labels' language: "Date by month", "Amount (by 100)". */
46
186
  export declare function groupingName(source: any, unit: any, labels: any, size: any): string;
47
187
  /** The zone a click on a field of the field list puts it in: numbers to Values, the rest to Rows. */
@@ -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[];
package/types/place.d.ts CHANGED
@@ -1,3 +1,14 @@
1
+ /**
2
+ * The room a fixed popover has: the window without its scroll bars (the root's client box). A classic
3
+ * scroll bar (Windows, 17 px) is part of innerWidth but not of the area fixed elements are laid out
4
+ * in; placed against innerWidth, a popover at the right edge would reach under the scroll bar.
5
+ * @param {Document} doc
6
+ * @returns {{ width: number, height: number }}
7
+ */
8
+ export declare function viewportOf(doc: Document): {
9
+ width: number;
10
+ height: number;
11
+ };
1
12
  /**
2
13
  * @param {{ top: number, bottom: number, left: number, right: number }} anchor getBoundingClientRect()
3
14
  * @param {{ width: number, height: number }} size the popover's size
@@ -25,6 +36,39 @@ export declare function placePopover(anchor: {
25
36
  maxHeight: number;
26
37
  side: "below" | "above";
27
38
  };
39
+ /**
40
+ * A popover whose content changes while it is open (a menu's level in place of its first level) stays
41
+ * where it was: on its side, with its top below the anchor, its new content scrolling inside, instead
42
+ * of jumping above the anchor or over it. Only while the anchor has not moved, and only when that side
43
+ * has room enough (KEEP_ROOM, or the content's height); else `next`, placed anew.
44
+ * @param {{ top: number, side: "below" | "above", anchorTop: number } | null} last the last place, with the anchor's top then
45
+ * @param {{ top: number, left: number, maxHeight: number, side: "below" | "above" }} next placePopover's
46
+ * @param {{ top: number, bottom: number }} anchor
47
+ * @param {{ height: number }} size
48
+ * @param {{ height: number }} viewport
49
+ */
50
+ export declare function keepPlace(last: {
51
+ top: number;
52
+ side: "below" | "above";
53
+ anchorTop: number;
54
+ } | null, next: {
55
+ top: number;
56
+ left: number;
57
+ maxHeight: number;
58
+ side: "below" | "above";
59
+ }, anchor: {
60
+ top: number;
61
+ bottom: number;
62
+ }, size: {
63
+ height: number;
64
+ }, viewport: {
65
+ height: number;
66
+ }): {
67
+ top: number;
68
+ left: number;
69
+ maxHeight: number;
70
+ side: "below" | "above";
71
+ };
28
72
  /**
29
73
  * A place in viewport coordinates as the top and left of a fixed element whose containing block
30
74
  * starts at `origin` (the viewport rect of a fixed probe at 0, 0: { top: 0, left: 0 } without a