pivotkit-react 0.8.2 → 0.9.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 (56) hide show
  1. package/CHANGELOG.md +93 -1
  2. package/dist/chunks/chunk-24T2VRMU.js +1010 -0
  3. package/dist/chunks/chunk-6R7TJHS3.js +212 -0
  4. package/dist/chunks/{chunk-GUSQWPTH.js → chunk-EPGRJSPP.js} +20 -5
  5. package/dist/chunks/{chunk-JAOOFDNR.js → chunk-FAAQZSR4.js} +4 -1
  6. package/dist/chunks/{chunk-2N2UGSIG.js → chunk-FI22Z6CC.js} +5 -2
  7. package/dist/chunks/{chunk-ZM45YU3W.js → chunk-G3R5C3J7.js} +28 -6
  8. package/dist/chunks/{chunk-MU5BTKSY.js → chunk-QCBVEI23.js} +6 -2
  9. package/dist/chunks/{chunk-6OWC6X5W.js → chunk-QVE7JM4G.js} +1 -1
  10. package/dist/chunks/{chunk-3WWWKPB4.js → chunk-V233JHVY.js} +75 -336
  11. package/dist/chunks/chunk-W6BG3GGS.js +679 -0
  12. package/dist/chunks/chunk-YAT2TFMK.js +138 -0
  13. package/dist/chunks/chunk-ZQ2M3U74.js +341 -0
  14. package/dist/chunks/{unused-texts-de-GB3IWWEM.js → labels-de-ZC3CSQZR.js} +1 -1
  15. package/dist/chunks/tips-SYGQPI3Q.js +22 -0
  16. package/dist/chunks/{unused-texts-LRYVWFFN.js → unused-texts-ERQ6ACNX.js} +1 -1
  17. package/dist/chunks/unused-texts-de-AC5GS3FS.js +6 -0
  18. package/dist/deferred-late.js +13 -0
  19. package/dist/deferred.js +18 -0
  20. package/dist/echarts.js +30 -6
  21. package/dist/import-ui.js +3 -3
  22. package/dist/index.js +427 -202
  23. package/dist/labels.js +15 -12
  24. package/dist/menu-texts-de.js +1 -1
  25. package/dist/menus.js +518 -381
  26. package/dist/styles.css +128 -9
  27. package/package.json +5 -4
  28. package/types/PivotReport.d.ts +3 -1
  29. package/types/chart-tooltip.d.ts +18 -1
  30. package/types/chart-types.d.ts +7 -2
  31. package/types/chart.d.ts +10 -2
  32. package/types/chip-menus.d.ts +1 -1
  33. package/types/deferred-late.d.ts +2 -0
  34. package/types/deferred.d.ts +28 -0
  35. package/types/field-info.d.ts +6 -3
  36. package/types/fields.d.ts +3 -2
  37. package/types/icons.d.ts +2 -0
  38. package/types/index.d.ts +20 -10
  39. package/types/labels-de.d.ts +2 -0
  40. package/types/labels.d.ts +55 -459
  41. package/types/lazy-menus.d.ts +2 -2
  42. package/types/menu-labels.d.ts +20 -0
  43. package/types/menu-ops.d.ts +33 -0
  44. package/types/menu-topics.d.ts +6 -3
  45. package/types/menus.d.ts +1 -0
  46. package/types/names.d.ts +20 -2
  47. package/types/notices.d.ts +212 -0
  48. package/types/point-menu.d.ts +21 -0
  49. package/types/quick-choices.d.ts +28 -0
  50. package/types/side-by-side.d.ts +19 -0
  51. package/types/tip-state.d.ts +97 -0
  52. package/types/tips.d.ts +13 -250
  53. package/types/unused-texts.d.ts +3 -0
  54. package/types/view-ops.d.ts +27 -14
  55. package/types/view-tabs.d.ts +4 -3
  56. package/dist/chunks/chunk-W2SVDHGN.js +0 -1898
package/types/tips.d.ts CHANGED
@@ -1,5 +1,8 @@
1
- /** Tips shown at a time: one, the most important; the next waits until it is followed or dismissed. */
2
- export declare const TIP_LIMIT = 1;
1
+ import { activeEntries } from "./notices.js";
2
+ export { TIP_LIMIT, tipActionText, tipContext, tipText } from "./notices.js";
3
+ export type TipEntry = import("./notices.js").TipEntry;
4
+ export type TipContext = import("./notices.js").TipContext;
5
+ /** @typedef {import("./notices.js").TipEntry} TipEntry @typedef {import("./notices.js").TipContext} TipContext */
3
6
  /** When the tips show; each number is documented in the React reference (tips). */
4
7
  export declare const TIP_THRESHOLDS: Readonly<{
5
8
  /** columns of an ungrouped date on Columns from which grouping it is suggested */
@@ -15,256 +18,16 @@ export declare const TIP_THRESHOLDS: Readonly<{
15
18
  /** slices from which a pie or a donut suggests bars: a circle reads well up to about 7 parts */
16
19
  pieSlices: 7;
17
20
  }>;
18
- export type TipContext = {
19
- /**
20
- * the normalized view
21
- */
22
- view: any;
23
- /**
24
- * nothing placed
25
- */
26
- empty: boolean;
27
- /**
28
- * the result cannot be shown (an error is shown instead)
29
- */
30
- failed: boolean;
31
- /**
32
- * the type of a field's source column
33
- */
34
- typeOf: (field: string) => string;
35
- encoded: import("pivotkit-core").Encoded;
36
- /**
37
- * display names (labels.core.fields)
38
- */
39
- fields?: Record<string, string>;
40
- /**
41
- * rows of the innermost row field (1 without row fields)
42
- */
43
- rowLeaves: number;
44
- /**
45
- * columns of the innermost column field (1 without column fields)
46
- */
47
- colLeaves: number;
48
- /**
49
- * a column group with more than one child is expanded, so a
50
- * column subtotal shows when column subtotals are on (core's layout.js draws none for one child)
51
- */
52
- colSubtotalShown: boolean;
53
- /**
54
- * source rows left after the filters
55
- */
56
- matched: number;
57
- /**
58
- * source rows of the data
59
- */
60
- dataRows: number;
61
- /**
62
- * the chart's series, when the chart shows
63
- */
64
- series: {
65
- series: any[];
66
- categories: any[];
67
- categoryCount: number;
68
- } | null;
69
- /**
70
- * the table (with cells) is on screen
71
- */
72
- tableShown: boolean;
73
- /**
74
- * a value was opened once
75
- */
76
- drilled: boolean;
77
- /**
78
- * changes of the view in this session
79
- */
80
- changes: number;
81
- /**
82
- * `changes` when the first drag ended, null before
83
- */
84
- dragAt: number | null;
85
- /**
86
- * the host lets the user save templates
87
- */
88
- canSave: boolean;
89
- /**
90
- * `changes` when the view was last saved (0: not saved in this session)
91
- */
92
- savedAt: number;
93
- /**
94
- * what the chart draws
95
- * (chart-types.js chartPlan): the type, whether the data chose it, rows and columns swapped for it
96
- */
97
- chartPlan: {
98
- name: string;
99
- auto: boolean;
100
- swap: boolean;
101
- };
102
- };
103
- export type TipEntry = {
104
- id: string;
105
- /**
106
- * null: not now; else the
107
- * placeholders of its text (and `action` data)
108
- */
109
- when: (ctx: TipContext) => Record<string, any> | null;
110
- /**
111
- * the action of its button: a key of labels.tipActions and of PivotReport's actions
112
- */
113
- action?: string;
114
- /**
115
- * a notice: always shown, not dismissible, outside the tips' limit
116
- */
117
- kind?: "notice";
118
- icon?: string;
119
- };
120
- /** @type {readonly TipEntry[]} the tips, most important first: that is the order they show in */
21
+ /** @type {readonly TipEntry[]} the notices (notices.js) and the tips, most important first: that is the order they show in */
121
22
  export declare const TIPS: readonly TipEntry[];
122
- /** Every tip id, for a host's `tips` list and for stored dismissals. */
123
- export declare const TIP_IDS: readonly string[];
124
- /** The notices: shown whenever they hold, whatever the tips settings are. */
125
- export declare const NOTICE_IDS: readonly string[];
126
- /** The dismissal that switches every tip off ("Show tips" in Options). */
127
- export declare const ALL_TIPS = "*";
128
- /**
129
- * The other switch of Options → Help, "Show explanations", kept in the same list (and storage) as the
130
- * tips: off, it hides every "i" - of the settings, of the zones and of the field descriptions -
131
- * except those a host forces on (the props settingInfo, zoneInfo and fieldInfo).
132
- */
133
- export declare const NO_EXPLANATIONS = "-explanations";
134
- /** The field list collapsed to a rail by the user (a wide or medium report), kept in the same list. */
135
- export declare const FIELDS_COLLAPSED = "-fields";
136
- /** Entries of the list that are switches, not dismissed tips: "Show dismissed tips again" keeps them. */
137
- export declare const SWITCHES: readonly string[];
138
- /**
139
- * Whether the field list is collapsed: the user's choice in this session, else the host's
140
- * `fieldList` ("open" or "collapsed"), else what the user chose before (the list).
141
- * @param {boolean | null} session
142
- * @param {unknown} forced
143
- * @param {readonly string[]} dismissed
144
- */
145
- export declare function fieldsCollapsed(session: boolean | null, forced: unknown, dismissed: readonly string[]): boolean;
146
- /** Entries "Show dismissed tips again" keeps: the switches. */
147
- export declare const keptOnReset: (id: any) => boolean;
148
- /**
149
- * Whether one kind of "i" shows: the host's "on" or "off" forces it (and the user's switch leaves it
150
- * alone), else the user's "Show explanations" in the list, on by default.
151
- * @param {unknown} forced the host's prop (settingInfo, zoneInfo or fieldInfo)
152
- * @param {readonly string[]} dismissed
153
- * @param {string} [off] the switch's entry, NO_EXPLANATIONS
154
- * @returns {{ on: boolean, user: boolean }} `user`: the user's switch decides
155
- */
156
- export declare function helpSwitch(forced: unknown, dismissed: readonly string[], off?: string): {
157
- on: boolean;
158
- user: boolean;
159
- };
160
23
  /**
161
- * The keyboard shortcuts of the help section in Options: the keys (with "Mod" for Ctrl or ⌘) and
162
- * the key of their text in labels.shortcuts.
24
+ * What to show now from every row: the notices whose condition holds, then the tips allowed and not
25
+ * dismissed, at most `limit` of them (notices.js activeEntries).
26
+ * @param {import("./notices.js").TipContext} ctx
27
+ * @param {Parameters<typeof activeEntries>[2]} options
163
28
  */
164
- export declare const SHORTCUTS: readonly {
165
- keys: string[];
166
- text: string;
167
- }[];
168
- /**
169
- * What the conditions read, from the report's state. Pure.
170
- * @param {{ view: any, result: import("pivotkit-core").PivotResult | null, encoded: import("pivotkit-core").Encoded,
171
- * failed: boolean, empty: boolean, typeOf: (field: string) => string, fields?: Record<string, string>,
172
- * series?: TipContext["series"], tableShown?: boolean, drilled?: boolean, changes?: number, dragAt?: number | null, canSave?: boolean,
173
- * savedAt?: number, chartPlan?: TipContext["chartPlan"] }} state
174
- * @returns {TipContext}
175
- */
176
- export declare function tipContext({ view, result, encoded, failed, empty, typeOf, fields, series, tableShown, drilled, changes, dragAt, canSave, savedAt, chartPlan }: {
177
- view: any;
178
- result: import("pivotkit-core").PivotResult | null;
179
- encoded: import("pivotkit-core").Encoded;
180
- failed: boolean;
181
- empty: boolean;
182
- typeOf: (field: string) => string;
183
- fields?: Record<string, string>;
184
- series?: TipContext["series"];
185
- tableShown?: boolean;
186
- drilled?: boolean;
187
- changes?: number;
188
- dragAt?: number | null;
189
- canSave?: boolean;
190
- savedAt?: number;
191
- chartPlan?: TipContext["chartPlan"];
192
- }): TipContext;
193
- /**
194
- * What to show now, the most important first: every notice whose condition holds, then the tips
195
- * whose condition holds, allowed by the host and not dismissed, at most `limit` of them.
196
- * @param {TipContext} ctx
197
- * @param {{ allowed: "on" | "off" | readonly string[], dismissed: ReadonlySet<string> | readonly string[], limit?: number }} options
198
- * @returns {Array<{ id: string, params: Record<string, any>, entry: TipEntry }>}
199
- */
200
- export declare function activeTips(ctx: TipContext, { allowed, dismissed, limit }: {
201
- allowed: "on" | "off" | readonly string[];
202
- dismissed: ReadonlySet<string> | readonly string[];
203
- limit?: number;
204
- }): Array<{
29
+ export declare const activeTips: (ctx: import("./notices.js").TipContext, options: Parameters<typeof activeEntries>[2]) => {
205
30
  id: string;
206
31
  params: Record<string, any>;
207
- entry: TipEntry;
208
- }>;
209
- /**
210
- * The text of a tip in the labels' language; numbers in the locale.
211
- * @param {string} id
212
- * @param {Record<string, any>} params
213
- * @param {import("./labels.js").UiLabels} labels
214
- * @param {string} locale
215
- */
216
- export declare function tipText(id: string, params: Record<string, any>, labels: import("./labels.js").UiLabels, locale: string): any;
217
- /**
218
- * The text of a tip's button.
219
- * @param {TipEntry} entry
220
- * @param {Record<string, any>} params
221
- * @param {import("./labels.js").UiLabels} labels
222
- */
223
- export declare function tipActionText(entry: TipEntry, params: Record<string, any>, labels: import("./labels.js").UiLabels): string;
224
- /**
225
- * A host's `tips` prop or attribute: "on" (default), "off", or the ids it allows (an array, or a
226
- * comma-separated text); unknown ids are left out.
227
- * @param {unknown} value
228
- * @returns {"on" | "off" | string[]}
229
- */
230
- export declare function allowedTips(value: unknown): "on" | "off" | string[];
231
- /** Dismissed ids from anywhere (storage, a host): known ids and the switches only, once each. */
232
- export declare function cleanDismissed(value: any): any[];
233
- /** The localStorage key of a report's tips: one per `storageKey`, so two reports never share one. */
234
- export declare const storageName: (key: any) => string;
235
- /**
236
- * The stored text of a report's dismissed tips, or null (no key, no storage, blocked). A text, so a
237
- * React store snapshot of it compares by value.
238
- * @param {string | undefined} key
239
- * @param {Pick<Storage, "getItem"> | null | undefined} storage
240
- * @returns {string | null}
241
- */
242
- export declare function readStored(key: string | undefined, storage: Pick<Storage, "getItem"> | null | undefined): string | null;
243
- /** The dismissed ids of a stored text: [] for nothing or broken JSON. @param {string | null} raw */
244
- export declare function parseStored(raw: string | null): any[];
245
- /**
246
- * The dismissed tips stored for a report, or [] (no key, no storage, blocked, broken JSON).
247
- * @param {string | undefined} key
248
- * @param {Pick<Storage, "getItem"> | null | undefined} storage
249
- */
250
- export declare function readDismissed(key: string | undefined, storage: Pick<Storage, "getItem"> | null | undefined): any[];
251
- /**
252
- * Listens to the stored tips of a key: a write in this page (writeDismissed) or in another tab of
253
- * the same site. For useSyncExternalStore, so the report reads the storage only after hydration (its
254
- * server snapshot is "nothing stored").
255
- * @param {string | undefined} key
256
- * @param {() => void} callback
257
- * @returns {() => void} stops listening
258
- */
259
- export declare function subscribeStored(key: string | undefined, callback: () => void): () => void;
260
- /**
261
- * Stores the dismissed tips of a report and tells the reports of the page that use the key; nothing
262
- * without a key or storage, and quietly when the browser refuses (private mode, quota): the tips stay
263
- * dismissed until the page is loaded again.
264
- * @param {string | undefined} key
265
- * @param {Pick<Storage, "setItem" | "removeItem"> | null | undefined} storage
266
- * @param {readonly string[]} dismissed
267
- */
268
- export declare function writeDismissed(key: string | undefined, storage: Pick<Storage, "setItem" | "removeItem"> | null | undefined, dismissed: readonly string[]): void;
269
- /** The Filters zone fields, kept with empty filters, and every other filter gone: "Remove filter". */
270
- export declare function withoutFilters(view: any): any;
32
+ entry: import("./notices.js").TipEntry;
33
+ }[];
@@ -70,6 +70,8 @@ export declare const en: {
70
70
  aggregatorType: string;
71
71
  unknownFormat: string;
72
72
  badLabel: string;
73
+ labelTwice: string;
74
+ labelTaken: string;
73
75
  unknownShowAs: string;
74
76
  showAsNotAdditive: string;
75
77
  showAsNotNumber: string;
@@ -100,6 +102,7 @@ export declare const en: {
100
102
  filterRelativeAnchor: string;
101
103
  sortNoItems: string;
102
104
  sortedTwice: string;
105
+ sortColumn: string;
103
106
  badTotals: string;
104
107
  collapsedPath: string;
105
108
  unknownSetting: string;
@@ -210,6 +210,14 @@ export declare function groupField(view: any, field: string, unit: string | null
210
210
  export declare function groupingOf(view: any, field: any): any;
211
211
  /** The source field of a field: itself, or the field a derived field groups. */
212
212
  export declare function sourceOf(view: any, field: any): any;
213
+ /**
214
+ * A field's own name in the report (#158): the table, the chart and the exports show it instead of the
215
+ * field's name. An empty name or null takes it away; none left, the view has no fieldLabels.
216
+ * @param {any} view
217
+ * @param {string} field
218
+ * @param {string | null} name
219
+ */
220
+ export declare function setFieldLabel(view: any, field: string, name: string | null): any;
213
221
  /**
214
222
  * Sort of a field: { by: "label" | "value" | "custom", order, value?, items? }; null removes the field's sort entry
215
223
  * (natural label order).
@@ -241,34 +249,38 @@ export declare function sortEntry(spec: {
241
249
  order: string;
242
250
  } | null;
243
251
  /**
244
- * What a click on a header of the table sorts: a row field's name sorts that field by label; a value's
245
- * name sorts the innermost row field by that value. Only a value's header that stands for the whole
246
- * row does (its column path is empty: the one value header over all columns, the values without
247
- * column fields, the grand total column), and only a value that gives a number (numericResult). Null
248
- * for every other header.
252
+ * What a click on a header of the table sorts: a field's name in the corner sorts that field by label
253
+ * (a row field or a column field); a value's name sorts the innermost row field by that value, over
254
+ * the whole row (an empty column path: the one value header over all columns, the values without
255
+ * column fields, the grand total column) or in its column (#70: the column's path; with several values a
256
+ * subtotal column's too). With one value, the innermost column's own label stands for its column; a
257
+ * subtotal column's has no value name to click and does not sort. Only a value that gives
258
+ * a number (numericResult). Null for every other header.
249
259
  * @param {any} view
250
- * @param {{ kind: string, field?: string, valueIndex?: number, colPath?: any[] }} cell a header cell of the grid
260
+ * @param {{ kind: string, field?: string, valueIndex?: number, colPath?: any[], total?: number }} cell a header cell of the grid
251
261
  * @param {(field: string) => string | undefined} typeOf the column type of a field
252
- * @returns {{ field: string, ref?: { field: string | null, agg: string } } | null}
262
+ * @returns {{ field: string, ref?: { field: string | null, agg: string }, column?: any[] } | null}
253
263
  */
254
264
  export declare function headerSortTarget(view: any, cell: {
255
265
  kind: string;
256
266
  field?: string;
257
267
  valueIndex?: number;
258
268
  colPath?: any[];
269
+ total?: number;
259
270
  }, typeOf: (field: string) => string | undefined): {
260
271
  field: string;
261
272
  ref?: {
262
273
  field: string | null;
263
274
  agg: string;
264
275
  };
276
+ column?: any[];
265
277
  } | null;
266
278
  /**
267
279
  * The sort a header shows (aria-sort): "ascending", "descending", "other" (a custom order), or null
268
280
  * when the rows are not in its order; `chosen` when a sort entry of the view puts them in it (the
269
281
  * default A to Z of a field without an entry is not chosen).
270
282
  * @param {any} view
271
- * @param {{ field: string, ref?: { field: string | null, agg: string } }} target headerSortTarget's
283
+ * @param {{ field: string, ref?: { field: string | null, agg: string }, column?: any[] }} target headerSortTarget's
272
284
  * @returns {{ order: "ascending" | "descending" | "other" | null, chosen: boolean }}
273
285
  */
274
286
  export declare function headerSortState(view: any, target: {
@@ -277,6 +289,7 @@ export declare function headerSortState(view: any, target: {
277
289
  field: string | null;
278
290
  agg: string;
279
291
  };
292
+ column?: any[];
280
293
  }): {
281
294
  order: "ascending" | "descending" | "other" | null;
282
295
  chosen: boolean;
@@ -286,7 +299,7 @@ export declare function headerSortState(view: any, target: {
286
299
  * largest first to smallest first to no sort by it (the field's default order); a row field's name
287
300
  * from A to Z to Z to A and back, and to A to Z from a sort by a value or a custom order.
288
301
  * @param {any} view
289
- * @param {{ field: string, ref?: { field: string | null, agg: string } }} target headerSortTarget's
302
+ * @param {{ field: string, ref?: { field: string | null, agg: string }, column?: any[] }} target headerSortTarget's
290
303
  * @param {boolean} [hostOrdered] the field has the host's order (fieldDefaults.order)
291
304
  */
292
305
  export declare function nextHeaderSort(view: any, target: {
@@ -295,13 +308,10 @@ export declare function nextHeaderSort(view: any, target: {
295
308
  field: string | null;
296
309
  agg: string;
297
310
  };
311
+ column?: any[];
298
312
  }, hostOrdered?: boolean): {
299
313
  by: string;
300
314
  order: string;
301
- } | {
302
- by: string;
303
- order: string;
304
- value: any;
305
315
  } | null;
306
316
  /** Filters of one type of a field. */
307
317
  export declare function filtersOf(view: any, field: any, types: any): any;
@@ -352,7 +362,10 @@ export declare function setCollapsed(view: any, axis: "rows" | "cols", paths: Ar
352
362
  export declare function setTotal(view: any, key: any, on: any): any;
353
363
  /** Table or chart. */
354
364
  export declare function setDisplay(view: any, display: any): any;
355
- /** Switches to the chart with a picker entry's settings (chart-types.js); its display settings stay. */
365
+ /**
366
+ * Switches to the chart with a picker entry's settings (chart-types.js); its display settings stay.
367
+ * The table and the chart side by side (#51) stay side by side.
368
+ */
356
369
  export declare function setChart(view: any, name: any): any;
357
370
  /**
358
371
  * Changes how the chart is drawn: { valueLabels, legend, title, smooth, ... } (pivotkit-core's chart
@@ -2,11 +2,12 @@ import React from "react";
2
2
  /**
3
3
  * The id of a tab, from the id of the panel it controls.
4
4
  * @param {string} panelId
5
- * @param {"table" | "chart"} display
5
+ * @param {"table" | "chart" | "both"} display
6
6
  */
7
- export declare const tabId: (panelId: string, display: "table" | "chart") => string;
7
+ export declare const tabId: (panelId: string, display: "table" | "chart" | "both") => string;
8
8
  /**
9
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
10
+ * panel); `narrow`: icons only; `shown`: what the result shows ("both" only on a wide report);
11
+ * `both`: whether the tab Both is offered; `big`: use-big-result.js's Enlarge and Full screen
11
12
  */
12
13
  export declare function ViewTabs(props: any): React.JSX.Element;