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.
- package/CHANGELOG.md +284 -1
- package/README.md +1 -1
- package/dist/chunks/{chunk-F6MVUAQD.js → chunk-6MDAL3IO.js} +51 -3
- package/dist/chunks/{chunk-53ZMK4BH.js → chunk-EM23V5GH.js} +6 -0
- package/dist/chunks/{chunk-LQCWFJBS.js → chunk-LEN5RPBM.js} +147 -26
- package/dist/chunks/{chunk-OYY4BKIL.js → chunk-RWYHJRQO.js} +6 -0
- package/dist/chunks/{chunk-QBD4FOBB.js → chunk-WB4GKWFQ.js} +124 -18
- package/dist/chunks/chunk-XN55BQ4M.js +618 -0
- package/dist/chunks/{chunk-X7H7BAVT.js → chunk-YITKWZ4L.js} +312 -628
- package/dist/chunks/chunk-ZYEYZSYL.js +187 -0
- package/dist/chunks/{unused-texts-YTNJCFFC.js → unused-texts-K3VFH65P.js} +1 -1
- package/dist/chunks/{unused-texts-de-SGOHV4N7.js → unused-texts-de-OW4TGIVX.js} +1 -1
- package/dist/import-ui.js +769 -0
- package/dist/import-worker.js +20 -0
- package/dist/index.js +653 -227
- package/dist/labels.js +14 -10
- package/dist/menu-texts-de.js +1 -1
- package/dist/menus.js +2499 -676
- package/dist/styles.css +673 -125
- package/package.json +3 -2
- package/types/chip-menus.d.ts +20 -4
- package/types/data-history.d.ts +85 -0
- package/types/data-keep.d.ts +51 -0
- package/types/data-menu.d.ts +11 -0
- package/types/dnd.d.ts +8 -4
- package/types/dom.d.ts +40 -7
- package/types/field-info.d.ts +32 -0
- package/types/filter-level.d.ts +16 -0
- package/types/filter.d.ts +31 -0
- package/types/help.d.ts +0 -7
- package/types/import-host.d.ts +53 -0
- package/types/import-labels.d.ts +360 -0
- package/types/import-module.d.ts +2 -0
- package/types/import-run.d.ts +73 -0
- package/types/import-source.d.ts +32 -0
- package/types/import-steps.d.ts +121 -0
- package/types/import-ui.d.ts +108 -0
- package/types/import-worker.d.ts +1 -0
- package/types/index.d.ts +56 -4
- package/types/labels.d.ts +97 -2
- package/types/lazy-import.d.ts +4 -0
- package/types/lazy-menus.d.ts +2 -2
- package/types/levels.d.ts +106 -0
- package/types/menu-fields.d.ts +80 -0
- package/types/menu-labels.d.ts +214 -22
- package/types/menu-ops.d.ts +150 -9
- package/types/menu-topics.d.ts +291 -0
- package/types/menus.d.ts +2 -1
- package/types/names.d.ts +141 -1
- package/types/overflow.d.ts +29 -17
- package/types/place.d.ts +44 -0
- package/types/popover.d.ts +47 -5
- package/types/section.d.ts +8 -11
- package/types/tips.d.ts +1 -36
- package/types/toasts.d.ts +1 -1
- package/types/toolbar-panels.d.ts +17 -9
- package/types/unused-keep.d.ts +20 -0
- package/types/unused-texts.d.ts +6 -0
- package/types/unused.d.ts +1 -0
- package/types/use-view-history.d.ts +13 -4
- package/types/view-ops.d.ts +12 -0
- package/types/virtual.d.ts +15 -0
- package/types/zones.d.ts +5 -4
- package/types/sections.d.ts +0 -2
package/types/index.d.ts
CHANGED
|
@@ -125,9 +125,11 @@ export type ExportFile = {
|
|
|
125
125
|
};
|
|
126
126
|
export type PivotReportProps = {
|
|
127
127
|
/**
|
|
128
|
-
* the rows
|
|
128
|
+
* the rows, or columnar data
|
|
129
|
+
* (`{ columns, types, data }`, one array per column, as pivotkit-core's encode takes it); encoded once
|
|
130
|
+
* per array or object, or once per `dataKey`
|
|
129
131
|
*/
|
|
130
|
-
data?: object[];
|
|
132
|
+
data?: object[] | import("pivotkit-core").ColumnarData;
|
|
131
133
|
/**
|
|
132
134
|
* identity of `data`: a new array with the same key is not encoded again
|
|
133
135
|
*/
|
|
@@ -328,7 +330,35 @@ export type PivotReportProps = {
|
|
|
328
330
|
* the first data) or covers its result (later loads)
|
|
329
331
|
*/
|
|
330
332
|
loading?: boolean;
|
|
333
|
+
/**
|
|
334
|
+
* people may load a file into the report in the browser: a Data
|
|
335
|
+
* button with "Load data…", a file dropped onto the report, a preview before it replaces the data
|
|
336
|
+
* (nothing is uploaded; Undo and "Back to original data" bring the host's data back). With a
|
|
337
|
+
* `storageKey` a report mounted again over the same host data shows the file again (memory only).
|
|
338
|
+
* Default false
|
|
339
|
+
*/
|
|
340
|
+
allowImport?: boolean;
|
|
341
|
+
/**
|
|
342
|
+
* reader plugins (contract v1,
|
|
343
|
+
* pivotkit-core/import's validatePlugin) for more formats, such as pivotkit-xlsx; CSV, TSV, text and
|
|
344
|
+
* JSON are built in
|
|
345
|
+
*/
|
|
346
|
+
plugins?: import("pivotkit-core/import").ReaderPlugin[];
|
|
347
|
+
/**
|
|
348
|
+
* the data shown changed: a file is loaded
|
|
349
|
+
* (`cause` "load"; returning false refuses it, the data stays), the host's data shown again
|
|
350
|
+
* ("original"), one of those undone or redone ("undo", "redo"), or the file shown again by a report
|
|
351
|
+
* mounted again with its storageKey ("restore")
|
|
352
|
+
*/
|
|
353
|
+
onDataLoad?: (load: DataLoad) => unknown;
|
|
354
|
+
/**
|
|
355
|
+
* starts a module worker that runs pivotkit-react's
|
|
356
|
+
* `import-worker` entry, so CSV and JSON files are read off the page; without it they are read on
|
|
357
|
+
* the page (pivotkit-element brings its own)
|
|
358
|
+
*/
|
|
359
|
+
importWorker?: () => Worker;
|
|
331
360
|
};
|
|
361
|
+
export type DataLoad = import("./import-steps.js").DataLoad;
|
|
332
362
|
export type ViewSource = {
|
|
333
363
|
/**
|
|
334
364
|
* stable, as the host names the data ("sales", a table's or an endpoint's name)
|
|
@@ -387,7 +417,9 @@ export type TipDismiss = {
|
|
|
387
417
|
* @property {"shared" | "user"} scope
|
|
388
418
|
*/
|
|
389
419
|
/**
|
|
390
|
-
* @typedef {object} FieldDefaults the host's settings for a field
|
|
420
|
+
* @typedef {object} FieldDefaults the host's settings for a field. A number field of whole numbers
|
|
421
|
+
* named ID, …Id, …_id, Nr, No, Number, Key or # without `agg`, `format` and `drillFormat` is an
|
|
422
|
+
* identifier: `{ agg: "count", drillFormat: "text" }` (field-info.js fieldDefaultsFor)
|
|
391
423
|
* @property {string} [agg] aggregator of a new value, when it fits the field's type ("average" for durations)
|
|
392
424
|
* @property {string} [format] a format of pivotkit-core ("duration:h", "currency:EUR") for a new value,
|
|
393
425
|
* and for the field's own numbers in the drill-down unless `drillFormat` is set
|
|
@@ -431,7 +463,9 @@ export type TipDismiss = {
|
|
|
431
463
|
*/
|
|
432
464
|
/**
|
|
433
465
|
* @typedef {object} PivotReportProps
|
|
434
|
-
* @property {object[]} [data] the rows
|
|
466
|
+
* @property {object[] | import("pivotkit-core").ColumnarData} [data] the rows, or columnar data
|
|
467
|
+
* (`{ columns, types, data }`, one array per column, as pivotkit-core's encode takes it); encoded once
|
|
468
|
+
* per array or object, or once per `dataKey`
|
|
435
469
|
* @property {string | number} [dataKey] identity of `data`: a new array with the same key is not encoded again
|
|
436
470
|
* @property {import("pivotkit-core").Encoded} [encoded] already encoded data, instead of `data`
|
|
437
471
|
* @property {ViewInput} [view] controlled: the view to show; pass back what onViewChange gives
|
|
@@ -515,6 +549,24 @@ export type TipDismiss = {
|
|
|
515
549
|
* decides. With it the user can still change it until the page is loaded again
|
|
516
550
|
* @property {boolean} [loading] the host is loading the data: the report shows its skeleton (before
|
|
517
551
|
* the first data) or covers its result (later loads)
|
|
552
|
+
* @property {boolean} [allowImport] people may load a file into the report in the browser: a Data
|
|
553
|
+
* button with "Load data…", a file dropped onto the report, a preview before it replaces the data
|
|
554
|
+
* (nothing is uploaded; Undo and "Back to original data" bring the host's data back). With a
|
|
555
|
+
* `storageKey` a report mounted again over the same host data shows the file again (memory only).
|
|
556
|
+
* Default false
|
|
557
|
+
* @property {import("pivotkit-core/import").ReaderPlugin[]} [plugins] reader plugins (contract v1,
|
|
558
|
+
* pivotkit-core/import's validatePlugin) for more formats, such as pivotkit-xlsx; CSV, TSV, text and
|
|
559
|
+
* JSON are built in
|
|
560
|
+
* @property {(load: DataLoad) => unknown} [onDataLoad] the data shown changed: a file is loaded
|
|
561
|
+
* (`cause` "load"; returning false refuses it, the data stays), the host's data shown again
|
|
562
|
+
* ("original"), one of those undone or redone ("undo", "redo"), or the file shown again by a report
|
|
563
|
+
* mounted again with its storageKey ("restore")
|
|
564
|
+
* @property {() => Worker} [importWorker] starts a module worker that runs pivotkit-react's
|
|
565
|
+
* `import-worker` entry, so CSV and JSON files are read off the page; without it they are read on
|
|
566
|
+
* the page (pivotkit-element brings its own)
|
|
567
|
+
*/
|
|
568
|
+
/**
|
|
569
|
+
* @typedef {import("./import-steps.js").DataLoad} DataLoad
|
|
518
570
|
*/
|
|
519
571
|
/**
|
|
520
572
|
* @typedef {object} ViewSource the data a view is made for
|
package/types/labels.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export type UiLabels = typeof en & import("./menu-labels.js").MenuTexts & {
|
|
2
2
|
unused?: import("./unused-texts.js").UnusedTexts;
|
|
3
|
+
dataImport?: import("./import-labels.js").ImportTexts;
|
|
3
4
|
};
|
|
4
5
|
/**
|
|
5
6
|
* Every text of the UI: these and the menus' (menu-labels.js, loaded with the menus; a type import
|
|
6
7
|
* only, so they stay out of the first load).
|
|
7
|
-
* @typedef {typeof en & import("./menu-labels.js").MenuTexts & { unused?: import("./unused-texts.js").UnusedTexts }} UiLabels
|
|
8
|
+
* @typedef {typeof en & import("./menu-labels.js").MenuTexts & { unused?: import("./unused-texts.js").UnusedTexts, dataImport?: import("./import-labels.js").ImportTexts }} UiLabels
|
|
8
9
|
* `unused`: the texts of a view's unused parts (unused-texts.js), loaded when a view has such parts;
|
|
9
|
-
*
|
|
10
|
+
* `dataImport`: those of loading data (import-labels.js), loaded with the import UI; a host's of
|
|
11
|
+
* both are kept aside as the menus' are
|
|
10
12
|
*/
|
|
11
13
|
export declare const en: {
|
|
12
14
|
/** the language of the texts, for the report's lang attribute */
|
|
@@ -69,8 +71,13 @@ export declare const en: {
|
|
|
69
71
|
};
|
|
70
72
|
undo: string;
|
|
71
73
|
redo: string;
|
|
74
|
+
startOver: string;
|
|
72
75
|
reset: string;
|
|
73
76
|
resetHint: string;
|
|
77
|
+
resetAlready: string;
|
|
78
|
+
resetStartEmpty: string;
|
|
79
|
+
newHint: string;
|
|
80
|
+
newAlready: string;
|
|
74
81
|
unsavedChanges: string;
|
|
75
82
|
swap: string;
|
|
76
83
|
layout: string;
|
|
@@ -78,6 +85,12 @@ export declare const en: {
|
|
|
78
85
|
layoutEmpty: string;
|
|
79
86
|
more: string;
|
|
80
87
|
views: string;
|
|
88
|
+
data: string;
|
|
89
|
+
dataLoaded: string;
|
|
90
|
+
loadData: string;
|
|
91
|
+
emptyLoad: string;
|
|
92
|
+
emptyDrop: string;
|
|
93
|
+
emptyNoData: string;
|
|
81
94
|
exportLabel: string;
|
|
82
95
|
options: string;
|
|
83
96
|
expand: string;
|
|
@@ -129,6 +142,8 @@ export declare const en: {
|
|
|
129
142
|
filter: string;
|
|
130
143
|
filtered: string;
|
|
131
144
|
filterSummary: string;
|
|
145
|
+
/** a text the user typed or a name, quoted as the language quotes: a text condition, field names */
|
|
146
|
+
quote: string;
|
|
132
147
|
filterTitle: string;
|
|
133
148
|
condition: string;
|
|
134
149
|
emptyTitle: string;
|
|
@@ -296,6 +311,40 @@ export declare const en: {
|
|
|
296
311
|
between: string;
|
|
297
312
|
notBetween: string;
|
|
298
313
|
};
|
|
314
|
+
countOfRows: string;
|
|
315
|
+
labelOps: {
|
|
316
|
+
equals: string;
|
|
317
|
+
notEquals: string;
|
|
318
|
+
contains: string;
|
|
319
|
+
notContains: string;
|
|
320
|
+
beginsWith: string;
|
|
321
|
+
endsWith: string;
|
|
322
|
+
};
|
|
323
|
+
relative: {
|
|
324
|
+
year: string;
|
|
325
|
+
years: string;
|
|
326
|
+
month: string;
|
|
327
|
+
months: string;
|
|
328
|
+
day: string;
|
|
329
|
+
days: string;
|
|
330
|
+
};
|
|
331
|
+
withRange: string;
|
|
332
|
+
relativeTo: string;
|
|
333
|
+
withShare: string;
|
|
334
|
+
noData: {
|
|
335
|
+
one: string;
|
|
336
|
+
other: string;
|
|
337
|
+
};
|
|
338
|
+
compareShort: {
|
|
339
|
+
"=": string;
|
|
340
|
+
"!=": string;
|
|
341
|
+
">": string;
|
|
342
|
+
">=": string;
|
|
343
|
+
"<": string;
|
|
344
|
+
"<=": string;
|
|
345
|
+
between: string;
|
|
346
|
+
notBetween: string;
|
|
347
|
+
};
|
|
299
348
|
zoneInfo: {
|
|
300
349
|
rows: string;
|
|
301
350
|
cols: string;
|
|
@@ -365,8 +414,13 @@ export declare const de: {
|
|
|
365
414
|
};
|
|
366
415
|
undo: string;
|
|
367
416
|
redo: string;
|
|
417
|
+
startOver: string;
|
|
368
418
|
reset: string;
|
|
369
419
|
resetHint: string;
|
|
420
|
+
resetAlready: string;
|
|
421
|
+
resetStartEmpty: string;
|
|
422
|
+
newHint: string;
|
|
423
|
+
newAlready: string;
|
|
370
424
|
unsavedChanges: string;
|
|
371
425
|
swap: string;
|
|
372
426
|
layout: string;
|
|
@@ -374,6 +428,12 @@ export declare const de: {
|
|
|
374
428
|
layoutEmpty: string;
|
|
375
429
|
more: string;
|
|
376
430
|
views: string;
|
|
431
|
+
data: string;
|
|
432
|
+
dataLoaded: string;
|
|
433
|
+
loadData: string;
|
|
434
|
+
emptyLoad: string;
|
|
435
|
+
emptyDrop: string;
|
|
436
|
+
emptyNoData: string;
|
|
377
437
|
exportLabel: string;
|
|
378
438
|
options: string;
|
|
379
439
|
expand: string;
|
|
@@ -425,6 +485,7 @@ export declare const de: {
|
|
|
425
485
|
filter: string;
|
|
426
486
|
filtered: string;
|
|
427
487
|
filterSummary: string;
|
|
488
|
+
quote: string;
|
|
428
489
|
filterTitle: string;
|
|
429
490
|
condition: string;
|
|
430
491
|
emptyTitle: string;
|
|
@@ -592,6 +653,40 @@ export declare const de: {
|
|
|
592
653
|
between: string;
|
|
593
654
|
notBetween: string;
|
|
594
655
|
};
|
|
656
|
+
countOfRows: string;
|
|
657
|
+
labelOps: {
|
|
658
|
+
equals: string;
|
|
659
|
+
notEquals: string;
|
|
660
|
+
contains: string;
|
|
661
|
+
notContains: string;
|
|
662
|
+
beginsWith: string;
|
|
663
|
+
endsWith: string;
|
|
664
|
+
};
|
|
665
|
+
relative: {
|
|
666
|
+
year: string;
|
|
667
|
+
years: string;
|
|
668
|
+
month: string;
|
|
669
|
+
months: string;
|
|
670
|
+
day: string;
|
|
671
|
+
days: string;
|
|
672
|
+
};
|
|
673
|
+
withRange: string;
|
|
674
|
+
relativeTo: string;
|
|
675
|
+
withShare: string;
|
|
676
|
+
noData: {
|
|
677
|
+
one: string;
|
|
678
|
+
other: string;
|
|
679
|
+
};
|
|
680
|
+
compareShort: {
|
|
681
|
+
"=": string;
|
|
682
|
+
"!=": string;
|
|
683
|
+
">": string;
|
|
684
|
+
">=": string;
|
|
685
|
+
"<": string;
|
|
686
|
+
"<=": string;
|
|
687
|
+
between: string;
|
|
688
|
+
notBetween: string;
|
|
689
|
+
};
|
|
595
690
|
zoneInfo: {
|
|
596
691
|
rows: string;
|
|
597
692
|
cols: string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** The import UI, imported once; a failed import is forgotten, so the next call tries again. */
|
|
2
|
+
export declare function loadImport(): Promise<typeof import("./import-module.js")>;
|
|
3
|
+
/** The import UI when it is loaded, else null. */
|
|
4
|
+
export declare const importNow: () => typeof import("./import-module.js") | null;
|
package/types/lazy-menus.d.ts
CHANGED
|
@@ -17,12 +17,12 @@ export declare function loadMenus(lang?: string): Promise<typeof import("./menus
|
|
|
17
17
|
export declare const menusNow: (lang?: string) => typeof import("./menus.js") | null;
|
|
18
18
|
/**
|
|
19
19
|
* One panel of menus.js with its props.
|
|
20
|
-
* @param {{ name: "AxisMenu" | "ValueMenu" | "ChartTypePanel" | "OptionsPanel" | "ViewsPanel" | "ExportPanel" | "LoadCheck" | "FilterPopover" | "DrillPanel", loadingText?: string, props: Record<string, any> }} props
|
|
20
|
+
* @param {{ name: "AxisMenu" | "FilterMenu" | "ValueMenu" | "ChartTypePanel" | "OptionsPanel" | "ViewsPanel" | "ExportPanel" | "LoadCheck" | "FilterPopover" | "DrillPanel" | "DataMenu", loadingText?: string, props: Record<string, any> }} props
|
|
21
21
|
* `loadingText`: shown while loading; without it nothing is (a popover or panel of its own).
|
|
22
22
|
* `props.labels` gives the texts of a failed load
|
|
23
23
|
*/
|
|
24
24
|
export declare function MenuPanel({ name, loadingText, props }: {
|
|
25
|
-
name: "AxisMenu" | "ValueMenu" | "ChartTypePanel" | "OptionsPanel" | "ViewsPanel" | "ExportPanel" | "LoadCheck" | "FilterPopover" | "DrillPanel";
|
|
25
|
+
name: "AxisMenu" | "FilterMenu" | "ValueMenu" | "ChartTypePanel" | "OptionsPanel" | "ViewsPanel" | "ExportPanel" | "LoadCheck" | "FilterPopover" | "DrillPanel" | "DataMenu";
|
|
26
26
|
loadingText?: string;
|
|
27
27
|
props: Record<string, any>;
|
|
28
28
|
}): React.JSX.Element;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/** The button that opened the popover around `el` (MenuButton's aria-controls names it). */
|
|
3
|
+
export declare function openerOf(el: any): HTMLElement | null;
|
|
4
|
+
/**
|
|
5
|
+
* Tab in a menu leaves it: the focus goes to what follows its button, else (at the end of the page)
|
|
6
|
+
* to the button; the menu closes. The Tab is taken (preventDefault), so the popover or sheet around
|
|
7
|
+
* the menu leaves it alone (dom.js: who takes Tab).
|
|
8
|
+
* @param {KeyboardEvent | React.KeyboardEvent} e
|
|
9
|
+
* @param {() => void} close
|
|
10
|
+
*/
|
|
11
|
+
export declare function tabLeaves(e: KeyboardEvent | React.KeyboardEvent, close: () => void): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* An ARIA menu: one Tab stop (the item focused last, else the one marked `data-pk-start`, else the
|
|
14
|
+
* first), the arrow keys, Home and End, type-ahead; left and right move inside a group of choices
|
|
15
|
+
* side by side (`data-pk-seg`). `onKey` runs first and may take a key (return true).
|
|
16
|
+
* @param {{ label?: string, labelledBy?: string, className?: string, close: () => void, children: React.ReactNode, testId?: string }} props
|
|
17
|
+
*/
|
|
18
|
+
export declare function MenuList({ label, labelledBy, className, close, children, testId }: {
|
|
19
|
+
label?: string;
|
|
20
|
+
labelledBy?: string;
|
|
21
|
+
className?: string;
|
|
22
|
+
close: () => void;
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
testId?: string;
|
|
25
|
+
}): React.JSX.Element;
|
|
26
|
+
/**
|
|
27
|
+
* One item of a menu: a choice (`checked` set: menuitemradio, or menuitemcheckbox with `checkbox`)
|
|
28
|
+
* or an action. `hint` stands on its right (a format's example, a date unit's).
|
|
29
|
+
* @param {{ id: string, text: React.ReactNode, onSelect: () => void, checked?: boolean, checkbox?: boolean,
|
|
30
|
+
* hint?: string, icon?: string, danger?: boolean, testId?: string, start?: boolean, plain?: string,
|
|
31
|
+
* label?: string, className?: string, disabled?: boolean, reason?: string, haspopup?: "menu" | "dialog", level?: string,
|
|
32
|
+
* description?: string | null, current?: boolean, children?: React.ReactNode }} props
|
|
33
|
+
* `plain`: the text type-ahead matches; `start`: takes Tab first; `level`: the topic it opens;
|
|
34
|
+
* `description`: an explanation a screen reader reads with it (the "i" next to it shows it);
|
|
35
|
+
* `current`: the entry shown now (the view loaded), with a check and aria-current
|
|
36
|
+
*/
|
|
37
|
+
export declare function MenuItem({ id, text, onSelect, checked, checkbox, hint, icon, danger, testId, start, plain, label, className, disabled, reason, haspopup, level, description, current, children }: {
|
|
38
|
+
id: string;
|
|
39
|
+
text: React.ReactNode;
|
|
40
|
+
onSelect: () => void;
|
|
41
|
+
checked?: boolean;
|
|
42
|
+
checkbox?: boolean;
|
|
43
|
+
hint?: string;
|
|
44
|
+
icon?: string;
|
|
45
|
+
danger?: boolean;
|
|
46
|
+
testId?: string;
|
|
47
|
+
start?: boolean;
|
|
48
|
+
plain?: string;
|
|
49
|
+
label?: string;
|
|
50
|
+
className?: string;
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
reason?: string;
|
|
53
|
+
haspopup?: "menu" | "dialog";
|
|
54
|
+
level?: string;
|
|
55
|
+
description?: string | null;
|
|
56
|
+
current?: boolean;
|
|
57
|
+
children?: React.ReactNode;
|
|
58
|
+
}): React.JSX.Element;
|
|
59
|
+
/**
|
|
60
|
+
* A menu in levels.
|
|
61
|
+
* @param {{ name: string, labels: any, topics: import("./menu-topics.js").Topic[], close: () => void,
|
|
62
|
+
* onPick: (choice: import("./menu-topics.js").Choice) => void, panel: (id: string, back: (focus?: string) => void, hint?: string) => React.ReactNode,
|
|
63
|
+
* head?: React.ReactNode, foot?: React.ReactNode, search?: boolean, locale?: string, focusAgain?: unknown }} props
|
|
64
|
+
* `onPick`: applies a choice (the menu then goes back to its first level, unless the choice closes
|
|
65
|
+
* it); `panel`: the form of a "panel" topic, with `back` (one level back, the focus where the level
|
|
66
|
+
* was opened from, or `focus`); `foot`: items after the topics (Remove field); `focusAgain`: when it
|
|
67
|
+
* changes, the focus goes once more where the last step sent it (that element may come later)
|
|
68
|
+
*/
|
|
69
|
+
export declare function LevelMenu({ name, labels, topics, close, onPick, panel, head, foot, search, locale, focusAgain }: {
|
|
70
|
+
name: string;
|
|
71
|
+
labels: any;
|
|
72
|
+
topics: import("./menu-topics.js").Topic[];
|
|
73
|
+
close: () => void;
|
|
74
|
+
onPick: (choice: import("./menu-topics.js").Choice) => void;
|
|
75
|
+
panel: (id: string, back: (focus?: string) => void, hint?: string) => React.ReactNode;
|
|
76
|
+
head?: React.ReactNode;
|
|
77
|
+
foot?: React.ReactNode;
|
|
78
|
+
search?: boolean;
|
|
79
|
+
locale?: string;
|
|
80
|
+
focusAgain?: unknown;
|
|
81
|
+
}): React.JSX.Element;
|
|
82
|
+
/**
|
|
83
|
+
* Runs the last function handed to `later` a moment after the last call (the typing stopped); `now`
|
|
84
|
+
* runs it at once, `cancel` drops it.
|
|
85
|
+
* @param {number} [wait] ms
|
|
86
|
+
*/
|
|
87
|
+
export declare function useLater(wait?: number): {
|
|
88
|
+
later: (/** @type {() => void} */ fn: () => void) => void;
|
|
89
|
+
now: () => void;
|
|
90
|
+
cancel: () => void;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* A value the user types that applies a moment after the typing stops (`apply` with the text), at
|
|
94
|
+
* once on Enter or when the field is left; Escape gives the text it had back. Returns the text and
|
|
95
|
+
* what the field's handlers call.
|
|
96
|
+
* @param {string} applied the text that applies now
|
|
97
|
+
* @param {(text: string) => void} apply
|
|
98
|
+
* @param {number} [wait] ms; 0: only on Enter and when the field is left (a name)
|
|
99
|
+
*/
|
|
100
|
+
export declare function useAppliedText(applied: string, apply: (text: string) => void, wait?: number): {
|
|
101
|
+
text: string;
|
|
102
|
+
set: (/** @type {string} */ value: string) => void;
|
|
103
|
+
flush: () => void;
|
|
104
|
+
/** Escape: back to the text that applies; true when there was something to give back. */
|
|
105
|
+
restore: () => boolean;
|
|
106
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A number typed into a menu, read in the report's locale (numbers.js). `kind` says what it must be:
|
|
4
|
+
* "number" any number, "size" above 0, "count" a whole number of 1 or more. The problem shows while
|
|
5
|
+
* the text is not such a number, and for an empty required field once Apply was pressed; `max`: the
|
|
6
|
+
* largest count, a larger one says so.
|
|
7
|
+
* @param {string} text
|
|
8
|
+
* @param {{ kind?: "number" | "size" | "count", required?: boolean, tried?: boolean, max?: number, labels: any, locale: string }} options
|
|
9
|
+
* @returns {{ value: number | null, problem: string | null }}
|
|
10
|
+
*/
|
|
11
|
+
export declare function readNumber(text: string, { kind, required, tried, max, labels, locale }: {
|
|
12
|
+
kind?: "number" | "size" | "count";
|
|
13
|
+
required?: boolean;
|
|
14
|
+
tried?: boolean;
|
|
15
|
+
max?: number;
|
|
16
|
+
labels: any;
|
|
17
|
+
locale: string;
|
|
18
|
+
}): {
|
|
19
|
+
value: number | null;
|
|
20
|
+
problem: string | null;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The text field of a number: a text input for the locale's own way of writing numbers (a number
|
|
24
|
+
* input would read "1.000,5" by the browser's rules, not the report's), its problem under it.
|
|
25
|
+
* @param {{ value: string, onChange: (text: string) => void, problem: string | null, label: string,
|
|
26
|
+
* testId: string, className?: string, shown?: string, shownClass?: string, onKeyDown?: (e: React.KeyboardEvent) => void,
|
|
27
|
+
* onBlur?: () => void, onFocus?: () => void, autoFocus?: boolean }} props
|
|
28
|
+
*/
|
|
29
|
+
export declare function NumberField({ value, onChange, problem, label, testId, className, shown, shownClass, onKeyDown, onBlur, onFocus, autoFocus }: {
|
|
30
|
+
value: string;
|
|
31
|
+
onChange: (text: string) => void;
|
|
32
|
+
problem: string | null;
|
|
33
|
+
label: string;
|
|
34
|
+
testId: string;
|
|
35
|
+
className?: string;
|
|
36
|
+
shown?: string;
|
|
37
|
+
shownClass?: string;
|
|
38
|
+
onKeyDown?: (e: React.KeyboardEvent) => void;
|
|
39
|
+
onBlur?: () => void;
|
|
40
|
+
onFocus?: () => void;
|
|
41
|
+
autoFocus?: boolean;
|
|
42
|
+
}): React.JSX.Element;
|
|
43
|
+
/**
|
|
44
|
+
* The keys of a field that applies what is typed: Enter applies now; Escape gives back what applies,
|
|
45
|
+
* or, when nothing was changed, goes back a level.
|
|
46
|
+
* @param {{ now: () => void, restore: () => boolean, back: () => void }} actions
|
|
47
|
+
*/
|
|
48
|
+
export declare const fieldKeys: ({ now, restore, back }: {
|
|
49
|
+
now: () => void;
|
|
50
|
+
restore: () => boolean;
|
|
51
|
+
back: () => void;
|
|
52
|
+
}) => (/** @type {React.KeyboardEvent} */ e: React.KeyboardEvent) => void;
|
|
53
|
+
/**
|
|
54
|
+
* The measure a top N or a value condition goes by: a select when the view has several values that
|
|
55
|
+
* give numbers, else the one name. `index` is the position in `choices`.
|
|
56
|
+
* @param {{ choices: Array<{ field: string | null, agg: string }>, names: string[], index: number,
|
|
57
|
+
* onChange: (index: number) => void, label: string, prefix?: string, testId: string }} props
|
|
58
|
+
*/
|
|
59
|
+
export declare function MeasurePick({ choices, names, index, onChange, label, prefix, testId }: {
|
|
60
|
+
choices: Array<{
|
|
61
|
+
field: string | null;
|
|
62
|
+
agg: string;
|
|
63
|
+
}>;
|
|
64
|
+
names: string[];
|
|
65
|
+
index: number;
|
|
66
|
+
onChange: (index: number) => void;
|
|
67
|
+
label: string;
|
|
68
|
+
prefix?: string;
|
|
69
|
+
testId: string;
|
|
70
|
+
}): React.JSX.Element;
|
|
71
|
+
/** The index of a reference in the choices; the first (the default) when it is not there. */
|
|
72
|
+
export declare const choiceIndex: (choices: any, ref: any) => number;
|
|
73
|
+
/** The measures a filter of a field can go by, with the one it goes by now, and their names. */
|
|
74
|
+
export declare function measuresOf(view: any, types: any, labels: any, ref: any): {
|
|
75
|
+
choices: {
|
|
76
|
+
field: string | null;
|
|
77
|
+
agg: string;
|
|
78
|
+
}[];
|
|
79
|
+
names: any[];
|
|
80
|
+
};
|