@casoon/opengrid 0.14.0 → 0.16.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 +621 -19
- package/README.md +19 -2
- package/engine/opengrid_wasm_bg.wasm +0 -0
- package/loader.d.ts +451 -24
- package/loader.js +584 -132
- package/package.json +13 -6
- package/pkg/opengrid_web_components.d.ts +94 -23
- package/pkg/opengrid_web_components.js +451 -59
- package/pkg/opengrid_web_components_bg.wasm +0 -0
- package/pkg/opengrid_web_components_bg.wasm.d.ts +15 -6
- package/pkg/snippets/opengrid-web-components-35ed06b453a9b215/inline0.js +8 -0
- package/pkg/snippets/opengrid-web-components-35ed06b453a9b215/inline1.js +58 -0
- package/pkg/snippets/opengrid-web-core-b41714d4e7311909/inline2.js +89 -0
- package/react/index.d.ts +20 -2
- package/react/index.js +32 -6
- package/svelte/Opengrid.svelte +46 -11
- package/svelte/OpengridGrid.svelte +20 -1
- package/svelte/OpengridPivot.svelte +3 -3
- package/svelte/OpengridTable.svelte +1 -1
- package/svelte/index.d.ts +57 -18
- package/svelte/index.js +1 -1
- package/texts/de.d.ts +5 -0
- package/texts/de.js +245 -0
- package/vue/index.d.ts +49 -7
- package/vue/index.js +41 -11
- package/worker.js +6 -3
- package/xlsx/opengrid_xlsx.d.ts +69 -0
- package/xlsx/opengrid_xlsx.js +375 -0
- package/xlsx/opengrid_xlsx_bg.wasm +0 -0
- package/xlsx/opengrid_xlsx_bg.wasm.d.ts +16 -0
- package/pkg/snippets/opengrid-web-components-56667a20e9158a6a/inline0.js +0 -17
- /package/pkg/snippets/{opengrid-web-core-a3505e32fee0c1ed → opengrid-web-core-b41714d4e7311909}/inline0.js +0 -0
- /package/pkg/snippets/{opengrid-web-core-a3505e32fee0c1ed → opengrid-web-core-b41714d4e7311909}/inline1.js +0 -0
package/loader.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference lib="dom" />
|
|
2
2
|
/**
|
|
3
|
-
* Types for `@casoon/opengrid
|
|
3
|
+
* Types for `@casoon/opengrid`.
|
|
4
4
|
*
|
|
5
5
|
* Written by hand after `docs/api.md`, which is the source: everything a page
|
|
6
6
|
* can rely on is typed here, and nothing else. The freeze test in
|
|
@@ -39,7 +39,7 @@ export interface OpengridModule {
|
|
|
39
39
|
/** Attaches the data source. Call {@link OpengridModule.set_texts} first. */
|
|
40
40
|
set_provider(host: HTMLElement, provider: Provider): void;
|
|
41
41
|
/** Overrides any subset of the texts; call it before `set_provider`. */
|
|
42
|
-
set_texts(host: HTMLElement, texts: Texts): void;
|
|
42
|
+
set_texts(host: HTMLElement, texts: Texts | null): void;
|
|
43
43
|
/** Per-column display formatting. Never reaches a query. */
|
|
44
44
|
set_formats(host: HTMLElement, formats: Formats): void;
|
|
45
45
|
/** Per-column editor choices: `{ customer: ["Alpha", "Beta"] }`. */
|
|
@@ -66,6 +66,13 @@ export interface OpengridModule {
|
|
|
66
66
|
* table and the pivot.
|
|
67
67
|
*/
|
|
68
68
|
get_query(host: HTMLElement): ViewQuery | null;
|
|
69
|
+
/**
|
|
70
|
+
* The header texts of the columns shown that stand under a band, by field name:
|
|
71
|
+
* `{ city: "Address · City" }` (issue #353). Pass it to `exportRows` as
|
|
72
|
+
* `headers`; the print table uses the same texts. Columns without a band are
|
|
73
|
+
* not in it.
|
|
74
|
+
*/
|
|
75
|
+
get_export_headers(host: HTMLElement): Record<string, string>;
|
|
69
76
|
/**
|
|
70
77
|
* The pivot as it is shown, as CSV text: one header line (`2025 · total`),
|
|
71
78
|
* every row including subtotals and the grand total, the element's labels.
|
|
@@ -75,6 +82,15 @@ export interface OpengridModule {
|
|
|
75
82
|
* Values are in the canonical wire notation: a float `2` reads `2.0`.
|
|
76
83
|
*/
|
|
77
84
|
get_pivot(host: HTMLElement, options?: CsvOptions): string | null;
|
|
85
|
+
/**
|
|
86
|
+
* Builds the grid's print table (issue #334): every match of the view as a
|
|
87
|
+
* native table that only `@media print` shows, in place of the grid, until
|
|
88
|
+
* `afterprint`. Await it, then call `window.print()`. Resolves with the
|
|
89
|
+
* number of rows; with `null` where `get_query` answers `null`, and for the
|
|
90
|
+
* table and the pivot, which print as they are. Rejects with the provider's
|
|
91
|
+
* error, and with the code `too_many_rows` for more than 10 000 matches.
|
|
92
|
+
*/
|
|
93
|
+
prepare_print(host: HTMLElement): Promise<number | null>;
|
|
78
94
|
/**
|
|
79
95
|
* What became of an edit the page saves (issue #153). `key` is the record's
|
|
80
96
|
* `row-key` value as `opengrid-cell-change` gave it. `saved` clears the
|
|
@@ -118,6 +134,22 @@ export interface OpengridModule {
|
|
|
118
134
|
* blocks the commit; `{ validate, block: true }` blocks on an `error`.
|
|
119
135
|
*/
|
|
120
136
|
set_validators(host: HTMLElement, validators: Record<string, Validator | ValidatorRule>): void;
|
|
137
|
+
/**
|
|
138
|
+
* The DOM node a cell shows instead of its text (issue #317). A function per
|
|
139
|
+
* column; never an HTML string. The source's value stays what search, export
|
|
140
|
+
* and events read. The grid only.
|
|
141
|
+
*/
|
|
142
|
+
set_cell_templates(host: HTMLElement, templates: Record<string, CellTemplate>): void;
|
|
143
|
+
/**
|
|
144
|
+
* The function that builds the panel under an open row (issue #318); `null`
|
|
145
|
+
* takes the panels away. Needs a `row-key`; not offered grouped or as a tree.
|
|
146
|
+
*/
|
|
147
|
+
set_detail_renderer(host: HTMLElement, renderer: DetailRenderer | null): void;
|
|
148
|
+
/**
|
|
149
|
+
* Runs the grid's query again over a source that changed, keeping the view,
|
|
150
|
+
* the focus by record, the selection by key and the history (issue #328).
|
|
151
|
+
*/
|
|
152
|
+
refresh(host: HTMLElement): void;
|
|
121
153
|
/** Defines the three elements. `loadOpengrid()` calls it. */
|
|
122
154
|
register(): void;
|
|
123
155
|
}
|
|
@@ -129,7 +161,7 @@ export interface OpengridModule {
|
|
|
129
161
|
/**
|
|
130
162
|
* What `connect` supplies an element with. Each is one module function —
|
|
131
163
|
* `presentation` is `set_columns`, named apart from the `columns` attribute —
|
|
132
|
-
* and the
|
|
164
|
+
* and the callbacks receive the event's `detail`.
|
|
133
165
|
*/
|
|
134
166
|
export interface ConnectOptions {
|
|
135
167
|
provider?: Provider;
|
|
@@ -151,6 +183,46 @@ export interface ConnectOptions {
|
|
|
151
183
|
onViewChange?: (view: View) => void;
|
|
152
184
|
onSelectionChange?: (detail: SelectionChangeDetail) => void;
|
|
153
185
|
onCellChange?: (detail: CellChangeDetail) => void;
|
|
186
|
+
/** `set_actions`: compared by value. The grid only. */
|
|
187
|
+
actions?: RowAction[];
|
|
188
|
+
/** `set_cell_templates`: functions compare by identity, as in `formats`. The grid only. */
|
|
189
|
+
cellTemplates?: Record<string, CellTemplate>;
|
|
190
|
+
/** `set_detail_renderer`: compared by identity. The grid only. */
|
|
191
|
+
detailRenderer?: DetailRenderer | null;
|
|
192
|
+
/** `set_validators`: functions compare by identity, as in `formats`. The grid only. */
|
|
193
|
+
validators?: Record<string, Validator | ValidatorRule>;
|
|
194
|
+
/**
|
|
195
|
+
* The reader added a row (`add-row`). The answer is the row's state
|
|
196
|
+
* (`set_row_state`): a promise shows `saving` until it settles — resolved
|
|
197
|
+
* with nothing, the row is saved — a rejection is an `error` with its
|
|
198
|
+
* message, and no answer at all leaves the row to the page. Not answered
|
|
199
|
+
* for an undone add.
|
|
200
|
+
*/
|
|
201
|
+
onRowAdd?: (detail: RowAddDetail) => RowAnswer | Promise<RowAnswer | void> | void;
|
|
202
|
+
onPaste?: (detail: PasteDetail) => void;
|
|
203
|
+
onBulkChange?: (detail: BulkChangeDetail) => void;
|
|
204
|
+
onRowAction?: (detail: RowActionDetail) => void;
|
|
205
|
+
/** A value of a pivot with `drill-down` was pressed. The pivot only. */
|
|
206
|
+
onDrillDown?: (detail: DrillDownDetail) => void;
|
|
207
|
+
/** The provider loaded the grid's source again (`loadRows`); the grid asks anew. */
|
|
208
|
+
onSourceReplaced?: (detail: SourceReplacedDetail) => void;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** What `onRowAdd` says became of the row; `key` is its `row-key` now. */
|
|
212
|
+
export type RowAnswer =
|
|
213
|
+
| { state: "saving" }
|
|
214
|
+
| { state: "saved"; key?: WireValue }
|
|
215
|
+
| { state: "error"; message: string };
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* What a page writes into the grid's cells, on a {@link Connection} and on each
|
|
219
|
+
* component's ref. Both wait for the module. The grid only; both need `row-key`.
|
|
220
|
+
*/
|
|
221
|
+
export interface CellWrites {
|
|
222
|
+
/** `set_cell_state`: what became of an edit the page saves. */
|
|
223
|
+
setCellState(key: WireValue, column: string, state: CellState, message?: string): void;
|
|
224
|
+
/** `set_values`: values the page computes, in a `readonly` column. */
|
|
225
|
+
setValues(values: CellValue[]): void;
|
|
154
226
|
}
|
|
155
227
|
|
|
156
228
|
/** `connect`'s options for `<opengrid-pivot>`: its view is a {@link PivotView}. */
|
|
@@ -160,7 +232,7 @@ export type PivotConnectOptions = Omit<ConnectOptions, "view" | "defaultView" |
|
|
|
160
232
|
onViewChange?: (view: PivotView) => void;
|
|
161
233
|
};
|
|
162
234
|
|
|
163
|
-
export interface Connection<O = ConnectOptions> {
|
|
235
|
+
export interface Connection<O = ConnectOptions> extends CellWrites {
|
|
164
236
|
/** Settles once the module is loaded and the options are applied. */
|
|
165
237
|
ready: Promise<LoadResult>;
|
|
166
238
|
/**
|
|
@@ -306,6 +378,20 @@ export interface RestProvider extends Provider {
|
|
|
306
378
|
* `onProgress` hears the end, `signal` aborts the download too.
|
|
307
379
|
*/
|
|
308
380
|
export(query: ViewQuery, options?: ProviderExportOptions): Promise<Blob>;
|
|
381
|
+
/** `POST /pivot/{source}?format=xlsx`: see {@link PivotProvider.exportPivot}. */
|
|
382
|
+
exportPivot(pivotQuery: PivotQuery, options: ProviderPivotExportOptions): Promise<Blob>;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/** What `createPivotProvider` answers. */
|
|
386
|
+
export interface PivotProvider extends Provider {
|
|
387
|
+
/**
|
|
388
|
+
* `POST /pivot/{source}?format=xlsx`: the pivot of `pivotQuery` as an XLSX
|
|
389
|
+
* file — one flat sheet, the table a pivot's CSV is, with numbers and dates
|
|
390
|
+
* as cells of their type. The server's rules are `/pivot`'s; its bounds are
|
|
391
|
+
* the pivot's limits and `max_xlsx_rows`. `exportPivot` builds the query
|
|
392
|
+
* from an element, and takes its words from it.
|
|
393
|
+
*/
|
|
394
|
+
exportPivot(pivotQuery: PivotQuery, options: ProviderPivotExportOptions): Promise<Blob>;
|
|
309
395
|
}
|
|
310
396
|
|
|
311
397
|
/** The `Planner` of the engine module, as `createHybridProvider` uses it. */
|
|
@@ -336,6 +422,12 @@ export interface ServerOptions {
|
|
|
336
422
|
source: string;
|
|
337
423
|
/** Bearer token; the server refuses without one. */
|
|
338
424
|
token?: string;
|
|
425
|
+
/**
|
|
426
|
+
* Opens `GET /watch/{source}` and tells the grids on this provider with
|
|
427
|
+
* `opengrid-source-changed` when the server says the source changed (issue #328).
|
|
428
|
+
* Off by default; a server may not offer it.
|
|
429
|
+
*/
|
|
430
|
+
watch?: boolean;
|
|
339
431
|
}
|
|
340
432
|
|
|
341
433
|
/** The engine on the main thread. */
|
|
@@ -357,7 +449,7 @@ export function createWorkerProvider(options?: {
|
|
|
357
449
|
export function createRestProvider(options: ServerOptions): RestProvider;
|
|
358
450
|
|
|
359
451
|
/** `POST /pivot/{source}` — a whole pivot in one request. */
|
|
360
|
-
export function createPivotProvider(options: ServerOptions):
|
|
452
|
+
export function createPivotProvider(options: ServerOptions): PivotProvider;
|
|
361
453
|
|
|
362
454
|
/** Splits each query between a remote source and the engine in the tab. */
|
|
363
455
|
export function createHybridProvider(options: {
|
|
@@ -386,15 +478,30 @@ export interface ExportProgress {
|
|
|
386
478
|
*/
|
|
387
479
|
export interface ExportOptions extends CsvOptions {
|
|
388
480
|
/**
|
|
389
|
-
* `"csv"` (the default), `"json"` — an array of row objects — or `"xlsx"`,
|
|
390
|
-
*
|
|
391
|
-
*
|
|
481
|
+
* `"csv"` (the default), `"json"` — an array of row objects — or `"xlsx"`, a
|
|
482
|
+
* workbook: written by the server where the provider exports there
|
|
483
|
+
* (`createRestProvider`), and in the tab for any other provider by a module
|
|
484
|
+
* of its own that `exportRows` loads the first time (`@casoon/opengrid/xlsx/`,
|
|
485
|
+
* about 250 KB brotli). The tab holds the whole workbook in memory, so
|
|
486
|
+
* `maxRows` bounds it — 250 000 by default there — and more rows than an Excel
|
|
487
|
+
* sheet holds (1 048 575) is an error.
|
|
392
488
|
*/
|
|
393
489
|
format?: "csv" | "json" | "xlsx";
|
|
394
490
|
/** Rows per request; 10 000 by default, the server's `max_limit`. */
|
|
395
491
|
chunkSize?: number;
|
|
396
|
-
/**
|
|
492
|
+
/**
|
|
493
|
+
* More matches than this is an error, never a truncated file; 1 000 000 by
|
|
494
|
+
* default, and 250 000 for an XLSX written in the tab.
|
|
495
|
+
*/
|
|
397
496
|
maxRows?: number;
|
|
497
|
+
/**
|
|
498
|
+
* Header texts by field name for CSV and XLSX, `{ city: "Address · City" }`
|
|
499
|
+
* (issue #353); `get_export_headers(grid)` answers them for a grid with bands.
|
|
500
|
+
* A column without one keeps its field name. A JSON export has no header row
|
|
501
|
+
* and refuses the option. The server takes each as a parameter,
|
|
502
|
+
* `header.<column>`.
|
|
503
|
+
*/
|
|
504
|
+
headers?: Record<string, string>;
|
|
398
505
|
/** Called after each piece. */
|
|
399
506
|
onProgress?: (progress: ExportProgress) => void;
|
|
400
507
|
/** Aborts the export: it rejects with an `AbortError` and gives no `Blob`. */
|
|
@@ -418,12 +525,70 @@ export type ProviderExportOptions = Omit<ExportOptions, "chunkSize">;
|
|
|
418
525
|
*/
|
|
419
526
|
export function exportRows(provider: Provider, query: ViewQuery, options?: ExportOptions): Promise<Blob>;
|
|
420
527
|
|
|
528
|
+
/** A pivot query, as `POST /pivot/{source}` takes it. */
|
|
529
|
+
export interface PivotQuery {
|
|
530
|
+
source: string;
|
|
531
|
+
rows: string[];
|
|
532
|
+
columns: string[];
|
|
533
|
+
values: PivotMeasure[];
|
|
534
|
+
sort?: PivotSort[];
|
|
535
|
+
filter?: Record<string, unknown>;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/** How a pivot is exported as a workbook. Any other key is an error. */
|
|
539
|
+
export interface PivotExportOptions {
|
|
540
|
+
/** `"xlsx"`, the one format the server writes a pivot in; its CSV is `get_pivot`. */
|
|
541
|
+
format: "xlsx";
|
|
542
|
+
/** Aborts the request: it rejects with an `AbortError` and gives no `Blob`. */
|
|
543
|
+
signal?: AbortSignal;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* What a provider's `exportPivot` takes: {@link PivotExportOptions}, and the
|
|
548
|
+
* words the server writes where the data has none. The method has a query and
|
|
549
|
+
* no element, so they are handed to it; the function `exportPivot` reads them
|
|
550
|
+
* from the element.
|
|
551
|
+
*/
|
|
552
|
+
export interface ProviderPivotExportOptions extends PivotExportOptions {
|
|
553
|
+
/**
|
|
554
|
+
* `total`, `subtotal` (with `{value}`), `noValue` and `emptyValue`, and what
|
|
555
|
+
* a calculated measure is shown as — `shareOfRow`, `shareOfColumn`,
|
|
556
|
+
* `shareOfTotal`, `runningTotal`; any other key is ignored. Without them
|
|
557
|
+
* the server's English defaults.
|
|
558
|
+
*/
|
|
559
|
+
texts?: Pick<
|
|
560
|
+
Texts,
|
|
561
|
+
| "total"
|
|
562
|
+
| "subtotal"
|
|
563
|
+
| "noValue"
|
|
564
|
+
| "emptyValue"
|
|
565
|
+
| "shareOfRow"
|
|
566
|
+
| "shareOfColumn"
|
|
567
|
+
| "shareOfTotal"
|
|
568
|
+
| "runningTotal"
|
|
569
|
+
>;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* The pivot `host` shows as an XLSX file, written by the server: the
|
|
574
|
+
* element's view asked again through the provider's `exportPivot`, as one flat
|
|
575
|
+
* sheet — the header row and the rows of `get_pivot`'s CSV, numbers and dates
|
|
576
|
+
* typed, the totals and the NULL and empty groups in the element's own texts.
|
|
577
|
+
* A provider without `exportPivot` (the engine in the tab or a worker) is a
|
|
578
|
+
* `TypeError`.
|
|
579
|
+
*/
|
|
580
|
+
export function exportPivot(
|
|
581
|
+
provider: Pick<PivotProvider, "exportPivot">,
|
|
582
|
+
host: HTMLElement,
|
|
583
|
+
options: PivotExportOptions,
|
|
584
|
+
): Promise<Blob>;
|
|
585
|
+
|
|
421
586
|
// ---------------------------------------------------------------------------
|
|
422
587
|
// Errors
|
|
423
588
|
// ---------------------------------------------------------------------------
|
|
424
589
|
|
|
425
590
|
/**
|
|
426
|
-
* What went wrong, as a closed list a page can switch on. The first
|
|
591
|
+
* What went wrong, as a closed list a page can switch on. The first eight are
|
|
427
592
|
* the server's, from its error form; the last three are `exportRows`' own.
|
|
428
593
|
*/
|
|
429
594
|
export type ErrorCode =
|
|
@@ -434,6 +599,7 @@ export type ErrorCode =
|
|
|
434
599
|
| "unauthorized"
|
|
435
600
|
| "backend"
|
|
436
601
|
| "malformed"
|
|
602
|
+
| "data"
|
|
437
603
|
| "too_many_rows"
|
|
438
604
|
| "source_changed"
|
|
439
605
|
| "module_not_loaded";
|
|
@@ -515,6 +681,12 @@ export type FacetKind = "list" | "pills" | "range" | "period";
|
|
|
515
681
|
/** A value as the wire format writes it: decimals and dates are strings. */
|
|
516
682
|
export type WireValue = string | number | boolean | null;
|
|
517
683
|
|
|
684
|
+
/**
|
|
685
|
+
* Where a column is kept in place while the others scroll sideways: at the
|
|
686
|
+
* start of the row or at its end, by reading direction.
|
|
687
|
+
*/
|
|
688
|
+
export type Pin = "start" | "end";
|
|
689
|
+
|
|
518
690
|
/** Per-column presentation for `set_columns` — `presentation` in `connect`. */
|
|
519
691
|
export interface ColumnConfig {
|
|
520
692
|
/**
|
|
@@ -525,6 +697,18 @@ export interface ColumnConfig {
|
|
|
525
697
|
title?: string;
|
|
526
698
|
/** The starting width in pixels; a reader's resize leads after that. */
|
|
527
699
|
width?: number;
|
|
700
|
+
/**
|
|
701
|
+
* Where the column starts pinned; the reader's own pin leads after that
|
|
702
|
+
* (`Alt`+`Shift`+`←`/`→` on the header, the column menu). The grid only.
|
|
703
|
+
*/
|
|
704
|
+
pin?: Pin;
|
|
705
|
+
/**
|
|
706
|
+
* The band the column stands under: a header it shares with the other
|
|
707
|
+
* columns that name the same one. A band is always in one piece — its
|
|
708
|
+
* columns stand together, move inside it, and are pinned with it. The grid
|
|
709
|
+
* only.
|
|
710
|
+
*/
|
|
711
|
+
band?: string;
|
|
528
712
|
align?: "start" | "end" | "center";
|
|
529
713
|
mono?: boolean;
|
|
530
714
|
emphasis?: boolean;
|
|
@@ -536,6 +720,14 @@ export interface ColumnConfig {
|
|
|
536
720
|
* its cells are announced as read-only. The grid only.
|
|
537
721
|
*/
|
|
538
722
|
readonly?: boolean;
|
|
723
|
+
/**
|
|
724
|
+
* The labels of the keys the column stores, key → label: the cell, the
|
|
725
|
+
* editor, the filter row and the facets show and choose by label. The value
|
|
726
|
+
* stays the key — in the query, the view, events and exports — and **the
|
|
727
|
+
* column sorts and groups by the key, not by the label**. For a `utf8` or
|
|
728
|
+
* `int64` column. The grid only.
|
|
729
|
+
*/
|
|
730
|
+
lookup?: Record<string | number, string>;
|
|
539
731
|
}
|
|
540
732
|
|
|
541
733
|
/** What `set_cell_state` says became of an edit. */
|
|
@@ -590,6 +782,23 @@ export interface FilterEntry {
|
|
|
590
782
|
value: string;
|
|
591
783
|
}
|
|
592
784
|
|
|
785
|
+
/**
|
|
786
|
+
* The nested filter of a view (`where`): conditions joined by `and` and `or`,
|
|
787
|
+
* in the wire form of a query's `filter` — values typed, so a number is a
|
|
788
|
+
* number and a decimal or a date a string. What the search expression and the
|
|
789
|
+
* builder dialog can write; `not` and the operator `in` are not part of it.
|
|
790
|
+
*/
|
|
791
|
+
export type ViewFilter =
|
|
792
|
+
| { and: ViewFilter[] }
|
|
793
|
+
| { or: ViewFilter[] }
|
|
794
|
+
| {
|
|
795
|
+
field: string;
|
|
796
|
+
op: Exclude<FilterOperator, "is_null" | "is_not_null" | "is_empty" | "has_all">;
|
|
797
|
+
value: string | number | boolean;
|
|
798
|
+
}
|
|
799
|
+
| { field: string; op: "has_all"; value: Array<string | number> }
|
|
800
|
+
| { field: string; op: "is_null" | "is_not_null" | "is_empty" };
|
|
801
|
+
|
|
593
802
|
/** A facet selection: values for `list`/`pills`, bounds for `range`/`period`. */
|
|
594
803
|
export type FacetSelection =
|
|
595
804
|
| { values: WireValue[] }
|
|
@@ -597,17 +806,27 @@ export type FacetSelection =
|
|
|
597
806
|
| { from: string; to: string };
|
|
598
807
|
|
|
599
808
|
/**
|
|
600
|
-
* Sort, filters, column layout, density, grouping,
|
|
601
|
-
* one value — as `get_view` writes it, every field present. `set_view` reads
|
|
809
|
+
* Sort, filters, the nested filter, column layout, density, grouping,
|
|
810
|
+
* aggregates and facets as one value — as `get_view` writes it, every field present. `set_view` reads
|
|
602
811
|
* some fields more leniently (a missing direction is `asc`, a missing operator
|
|
603
812
|
* `eq`); the types ask for the full form on purpose, so a saved view says what
|
|
604
|
-
* it means. A saved view is this value with a name on it.
|
|
605
|
-
*
|
|
813
|
+
* it means. A saved view is this value with a name on it. A selection by key
|
|
814
|
+
* is part of it (`selected`); a selection by position and the free-text
|
|
815
|
+
* search are deliberately not.
|
|
606
816
|
*/
|
|
607
817
|
export interface View {
|
|
608
818
|
sort: SortKey[];
|
|
609
819
|
filters: FilterEntry[];
|
|
610
|
-
columns: {
|
|
820
|
+
columns: {
|
|
821
|
+
order: string[];
|
|
822
|
+
hidden: string[];
|
|
823
|
+
widths: Record<string, number>;
|
|
824
|
+
/**
|
|
825
|
+
* The pins the reader changed: `none` is a pin of `set_columns` taken
|
|
826
|
+
* away. Leads over `set_columns`.
|
|
827
|
+
*/
|
|
828
|
+
pinned: Record<string, Pin | "none">;
|
|
829
|
+
};
|
|
611
830
|
density: Density;
|
|
612
831
|
group: string[];
|
|
613
832
|
/** The open groups, each as its path of keys. */
|
|
@@ -617,14 +836,46 @@ export interface View {
|
|
|
617
836
|
/** Whether the filter row shows. */
|
|
618
837
|
filterRow: boolean;
|
|
619
838
|
facets: Record<string, FacetSelection>;
|
|
839
|
+
/**
|
|
840
|
+
* The keys of the selected records, where the grid selects by key (`row-key`,
|
|
841
|
+
* or a tree's `tree-key`). Left out while nothing is selected, and always for
|
|
842
|
+
* a selection by position. `set_view` asks the source which of them name a
|
|
843
|
+
* record before it selects; a view without the field selects nothing.
|
|
844
|
+
*/
|
|
845
|
+
selected?: Array<string | number | boolean>;
|
|
846
|
+
/**
|
|
847
|
+
* The keys of the records whose detail panel is open (issue #318). Left out
|
|
848
|
+
* while none is. A restored view opens them as their rows load.
|
|
849
|
+
*/
|
|
850
|
+
detail?: Array<string | number | boolean>;
|
|
851
|
+
/**
|
|
852
|
+
* The nested filter: the one filter with `or` across columns, and-ed onto
|
|
853
|
+
* the filter row's (`filters`), the facets' and the page's. Left out while
|
|
854
|
+
* there is none; a view without the field has none.
|
|
855
|
+
*/
|
|
856
|
+
where?: ViewFilter;
|
|
620
857
|
}
|
|
621
858
|
|
|
859
|
+
/**
|
|
860
|
+
* What a calculated measure shows in place of its aggregate: the cell as a
|
|
861
|
+
* fraction of its row's total, of its column's total or of the grand total —
|
|
862
|
+
* a number between 0 and 1, NULL where that total is NULL or zero — or the
|
|
863
|
+
* running total along the columns, which starts again in every row.
|
|
864
|
+
*/
|
|
865
|
+
export type PivotCalc = "share_of_row" | "share_of_column" | "share_of_total" | "running_total";
|
|
866
|
+
|
|
622
867
|
/** A pivot measure, as the contract writes it: `{ field: "qty", fn: "sum", as: "total" }`. */
|
|
623
868
|
export interface PivotMeasure {
|
|
624
869
|
/** Absent for `count`. */
|
|
625
870
|
field?: string;
|
|
626
871
|
fn: string;
|
|
627
872
|
as: string;
|
|
873
|
+
/**
|
|
874
|
+
* Shows the measure as a calculation over the pivot's cells. A share is for
|
|
875
|
+
* `sum` and `count`; a running total also for `avg`, `min` and `max` over a
|
|
876
|
+
* number. The source refuses anything else.
|
|
877
|
+
*/
|
|
878
|
+
calc?: PivotCalc;
|
|
628
879
|
}
|
|
629
880
|
|
|
630
881
|
/**
|
|
@@ -733,6 +984,7 @@ export type TextKey =
|
|
|
733
984
|
| "columnMenu"
|
|
734
985
|
| "sortAscending"
|
|
735
986
|
| "sortDescending"
|
|
987
|
+
| "sortKey"
|
|
736
988
|
| "filterColumn"
|
|
737
989
|
| "aggregateGroup"
|
|
738
990
|
| "aggregateNone"
|
|
@@ -740,6 +992,12 @@ export type TextKey =
|
|
|
740
992
|
| "groupSecondLevel"
|
|
741
993
|
| "ungroupColumn"
|
|
742
994
|
| "hideColumn"
|
|
995
|
+
| "hideBand"
|
|
996
|
+
| "bandKeep"
|
|
997
|
+
| "pinGroup"
|
|
998
|
+
| "pinNone"
|
|
999
|
+
| "pinStart"
|
|
1000
|
+
| "pinEnd"
|
|
743
1001
|
| "toolbarGroup"
|
|
744
1002
|
| "filterRowToggle"
|
|
745
1003
|
| "densityGroup"
|
|
@@ -783,6 +1041,13 @@ export type TextKey =
|
|
|
783
1041
|
| "pivotFilters"
|
|
784
1042
|
| "pivotFilterLabel"
|
|
785
1043
|
| "pivotFilterHint"
|
|
1044
|
+
| "pivotDrillDown"
|
|
1045
|
+
| "pivotShowAs"
|
|
1046
|
+
| "calcValue"
|
|
1047
|
+
| "shareOfRow"
|
|
1048
|
+
| "shareOfColumn"
|
|
1049
|
+
| "shareOfTotal"
|
|
1050
|
+
| "runningTotal"
|
|
786
1051
|
| "treeContext"
|
|
787
1052
|
| "subtreeCell"
|
|
788
1053
|
| "subtreeOnly"
|
|
@@ -814,15 +1079,35 @@ export type TextKey =
|
|
|
814
1079
|
| "queryUnknownColumn"
|
|
815
1080
|
| "queryMissingValue"
|
|
816
1081
|
| "queryWrongOperator"
|
|
1082
|
+
| "queryOr"
|
|
1083
|
+
| "queryUnclosed"
|
|
1084
|
+
| "queryUnopened"
|
|
1085
|
+
| "queryMissingCondition"
|
|
1086
|
+
| "queryMissingJoin"
|
|
1087
|
+
| "filterBuilder"
|
|
1088
|
+
| "filterBuilderJoin"
|
|
1089
|
+
| "filterBuilderAll"
|
|
1090
|
+
| "filterBuilderAny"
|
|
1091
|
+
| "filterBuilderCondition"
|
|
1092
|
+
| "filterBuilderGroup"
|
|
1093
|
+
| "filterBuilderAddCondition"
|
|
1094
|
+
| "filterBuilderAddGroup"
|
|
1095
|
+
| "filterBuilderEdit"
|
|
1096
|
+
| "filterApplied"
|
|
817
1097
|
| "emptyFiltered"
|
|
818
1098
|
| "emptySource"
|
|
819
1099
|
| "emptyReset"
|
|
820
1100
|
| "filterInvalid"
|
|
821
1101
|
| "cellRequired"
|
|
822
1102
|
| "selectionCleared"
|
|
1103
|
+
| "selectionMissing"
|
|
823
1104
|
| "columnWidth"
|
|
824
1105
|
| "columnMoved"
|
|
825
1106
|
| "columnAtEdge"
|
|
1107
|
+
| "columnPinnedStart"
|
|
1108
|
+
| "columnPinnedEnd"
|
|
1109
|
+
| "columnUnpinned"
|
|
1110
|
+
| "pinsReleased"
|
|
826
1111
|
| "columnHidden"
|
|
827
1112
|
| "columnShown"
|
|
828
1113
|
| "columnsGroup"
|
|
@@ -866,6 +1151,22 @@ export type TextKey =
|
|
|
866
1151
|
| "undoAdded"
|
|
867
1152
|
| "redoAdded"
|
|
868
1153
|
| "undoPaste"
|
|
1154
|
+
| "undoRecord"
|
|
1155
|
+
| "redoRecord"
|
|
1156
|
+
| "recordTitle"
|
|
1157
|
+
| "recordSave"
|
|
1158
|
+
| "recordDone"
|
|
1159
|
+
| "recordNothing"
|
|
1160
|
+
| "rangeSize"
|
|
1161
|
+
| "rangeCopied"
|
|
1162
|
+
| "rangeUnloaded"
|
|
1163
|
+
| "sourceChanged"
|
|
1164
|
+
| "sourceRefresh"
|
|
1165
|
+
| "detailShow"
|
|
1166
|
+
| "detailHide"
|
|
1167
|
+
| "detailPanel"
|
|
1168
|
+
| "detailShown"
|
|
1169
|
+
| "detailHidden"
|
|
869
1170
|
| "redoPaste"
|
|
870
1171
|
| "undoNothing"
|
|
871
1172
|
| "redoNothing";
|
|
@@ -884,17 +1185,39 @@ export type Texts = Partial<Record<TextKey, string>> & {
|
|
|
884
1185
|
// ---------------------------------------------------------------------------
|
|
885
1186
|
|
|
886
1187
|
/**
|
|
887
|
-
* `opengrid-selection-change
|
|
888
|
-
*
|
|
889
|
-
* `keys` names every selected node by its key and `count` counts them.
|
|
1188
|
+
* `opengrid-selection-change` of a grid that selects **by position** — no
|
|
1189
|
+
* `row-key`, no tree: logical row numbers, ascending.
|
|
890
1190
|
*/
|
|
891
|
-
export interface
|
|
1191
|
+
export interface SelectionByPosition {
|
|
892
1192
|
rows: number[];
|
|
1193
|
+
/**
|
|
1194
|
+
* The same rows as runs of adjacent ones, ascending, both ends inclusive:
|
|
1195
|
+
* select-all over 100 000 rows is `[{ from: 0, to: 99999 }]`.
|
|
1196
|
+
*/
|
|
1197
|
+
ranges: Array<{ from: number; to: number }>;
|
|
893
1198
|
count: number;
|
|
894
|
-
|
|
895
|
-
keys?: unknown[];
|
|
1199
|
+
keys?: undefined;
|
|
896
1200
|
}
|
|
897
1201
|
|
|
1202
|
+
/**
|
|
1203
|
+
* `opengrid-selection-change` of a grid that selects **by key** — with
|
|
1204
|
+
* `row-key` (grouped or not), or a tree: the keys of the selected records, in
|
|
1205
|
+
* no particular order (a tree's: the nodes shown first), and their number.
|
|
1206
|
+
* There are no positions: a key names a record wherever it sits, loaded or not.
|
|
1207
|
+
*/
|
|
1208
|
+
export interface SelectionByKey {
|
|
1209
|
+
count: number;
|
|
1210
|
+
keys: unknown[];
|
|
1211
|
+
rows?: undefined;
|
|
1212
|
+
ranges?: undefined;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* `opengrid-selection-change`: one of the two, by what the grid's selection
|
|
1217
|
+
* names. `detail.keys` (or `"keys" in detail`) narrows it.
|
|
1218
|
+
*/
|
|
1219
|
+
export type SelectionChangeDetail = SelectionByPosition | SelectionByKey;
|
|
1220
|
+
|
|
898
1221
|
/** `opengrid-cell-change`: everything a page needs to persist an edit. */
|
|
899
1222
|
export interface CellChangeDetail {
|
|
900
1223
|
row: number;
|
|
@@ -914,6 +1237,31 @@ export interface CellChangeDetail {
|
|
|
914
1237
|
/** What a validator says about a value, or `null` for nothing. */
|
|
915
1238
|
export type Finding = { level: "warning" | "error"; message: string } | null | undefined;
|
|
916
1239
|
/** `value` is the text in the editor, `row` the record as loaded, by field name. */
|
|
1240
|
+
/** What `set_cell_templates` gives a function (issue #317). */
|
|
1241
|
+
export interface CellTemplateArgument {
|
|
1242
|
+
/** The cell's value as it is on the wire. */
|
|
1243
|
+
value: WireValue;
|
|
1244
|
+
/** The text the column's format makes of it. */
|
|
1245
|
+
text: string;
|
|
1246
|
+
/** The record as loaded, by field name. */
|
|
1247
|
+
row: Record<string, WireValue>;
|
|
1248
|
+
/** The record's `row-key` value; `undefined` without one. */
|
|
1249
|
+
key: WireValue | undefined;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
/**
|
|
1253
|
+
* The panel under an open row (issue #318): the record as the grid holds it and
|
|
1254
|
+
* its `row-key` value. A node, or a string shown as text; `null` or
|
|
1255
|
+
* `undefined`: this record has no panel.
|
|
1256
|
+
*/
|
|
1257
|
+
export type DetailRenderer = (
|
|
1258
|
+
record: Record<string, WireValue>,
|
|
1259
|
+
key: WireValue,
|
|
1260
|
+
) => Node | string | null | undefined;
|
|
1261
|
+
|
|
1262
|
+
/** A node, or a string shown as text; `null` or `undefined` leaves the cell's text. */
|
|
1263
|
+
export type CellTemplate = (cell: CellTemplateArgument) => Node | string | null | undefined;
|
|
1264
|
+
|
|
917
1265
|
export type Validator = (value: string, row: Record<string, WireValue>) => Finding;
|
|
918
1266
|
/** A validator that may block the commit on an `error`. */
|
|
919
1267
|
export interface ValidatorRule {
|
|
@@ -936,6 +1284,28 @@ export interface RowActionDetail {
|
|
|
936
1284
|
key?: WireValue;
|
|
937
1285
|
}
|
|
938
1286
|
|
|
1287
|
+
/**
|
|
1288
|
+
* `opengrid-drill-down`: a value of an `<opengrid-pivot>` with `drill-down`
|
|
1289
|
+
* was pressed (issue #330). The page shows the rows.
|
|
1290
|
+
*/
|
|
1291
|
+
export interface DrillDownDetail {
|
|
1292
|
+
/**
|
|
1293
|
+
* The rows behind the cell, as the wire writes a query. `filter` is the
|
|
1294
|
+
* pivot's own filter and-ed with one clause per dimension the cell lies in
|
|
1295
|
+
* — a NULL group as `is_null`, the empty string as `eq ""` — and absent
|
|
1296
|
+
* when nothing restricts the rows.
|
|
1297
|
+
*/
|
|
1298
|
+
query: { source: string; filter?: Record<string, unknown> };
|
|
1299
|
+
/** The row group's keys, down to the row's level; `[]` for the grand total. */
|
|
1300
|
+
row: WireValue[];
|
|
1301
|
+
/** The column group's keys, one per column dimension. */
|
|
1302
|
+
column: WireValue[];
|
|
1303
|
+
/** The measure's alias. */
|
|
1304
|
+
measure: string;
|
|
1305
|
+
/** The cell's value, as the answer carried it. */
|
|
1306
|
+
value: WireValue;
|
|
1307
|
+
}
|
|
1308
|
+
|
|
939
1309
|
/** `opengrid-row-add`: a record was typed into the new row (issue #183). */
|
|
940
1310
|
export interface RowAddDetail {
|
|
941
1311
|
/** The values by field name, in the wire notation of a result. */
|
|
@@ -947,6 +1317,35 @@ export interface RowAddDetail {
|
|
|
947
1317
|
redo?: true;
|
|
948
1318
|
}
|
|
949
1319
|
|
|
1320
|
+
/**
|
|
1321
|
+
* `opengrid-source-replaced`: the grid's source was loaded again (issue #182).
|
|
1322
|
+
* Fired on the grid only; it does not bubble.
|
|
1323
|
+
*/
|
|
1324
|
+
export interface SourceReplacedDetail {
|
|
1325
|
+
name: string;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
/**
|
|
1329
|
+
* `opengrid-source-changed`: the source behind the grid changed (issue #328).
|
|
1330
|
+
* **Cancelable**: `preventDefault()` keeps the grid's notice and "Refresh" button
|
|
1331
|
+
* from showing; call `refresh(grid)` when it suits. Fired on the grid only; it
|
|
1332
|
+
* does not bubble.
|
|
1333
|
+
*/
|
|
1334
|
+
export interface SourceChangedDetail {
|
|
1335
|
+
name: string | undefined;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
/**
|
|
1339
|
+
* `opengrid-detail-toggle`: a row's detail panel opened or closed (issue #318).
|
|
1340
|
+
*/
|
|
1341
|
+
export interface DetailToggleDetail {
|
|
1342
|
+
/** The record's `row-key` value. */
|
|
1343
|
+
key: WireValue;
|
|
1344
|
+
/** The row in the result. */
|
|
1345
|
+
row: number;
|
|
1346
|
+
open: boolean;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
950
1349
|
/** `opengrid-bulk-change`: one value for the selected rows (issue #187). */
|
|
951
1350
|
export interface BulkChangeDetail {
|
|
952
1351
|
/** The `row-key` values of the selected records. */
|
|
@@ -955,6 +1354,13 @@ export interface BulkChangeDetail {
|
|
|
955
1354
|
value: string;
|
|
956
1355
|
}
|
|
957
1356
|
|
|
1357
|
+
/** `opengrid-record-open`: the reader asked for a record as a form (issue #325). Cancelable. */
|
|
1358
|
+
export interface RecordOpenDetail {
|
|
1359
|
+
/** The record's `row-key` value. */
|
|
1360
|
+
key: WireValue;
|
|
1361
|
+
row: number;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
958
1364
|
/** `opengrid-paste`: a pasted block was applied (issue #184). */
|
|
959
1365
|
export interface PasteDetail {
|
|
960
1366
|
/** One per cell of an existing row. */
|
|
@@ -995,7 +1401,11 @@ export interface ViewChangeDetail<V = View> {
|
|
|
995
1401
|
view: V;
|
|
996
1402
|
}
|
|
997
1403
|
|
|
998
|
-
/**
|
|
1404
|
+
/**
|
|
1405
|
+
* The events, by name. All bubble, all are composed, none is cancelable —
|
|
1406
|
+
* except `opengrid-source-replaced`, which `loader.js` dispatches on the grid
|
|
1407
|
+
* without bubbling.
|
|
1408
|
+
*/
|
|
999
1409
|
export interface OpengridEventMap {
|
|
1000
1410
|
"opengrid-selection-change": CustomEvent<SelectionChangeDetail>;
|
|
1001
1411
|
"opengrid-cell-change": CustomEvent<CellChangeDetail>;
|
|
@@ -1005,6 +1415,14 @@ export interface OpengridEventMap {
|
|
|
1005
1415
|
"opengrid-row-add": CustomEvent<RowAddDetail>;
|
|
1006
1416
|
"opengrid-paste": CustomEvent<PasteDetail>;
|
|
1007
1417
|
"opengrid-bulk-change": CustomEvent<BulkChangeDetail>;
|
|
1418
|
+
/** Cancelable: `preventDefault()` keeps the grid from opening its record form. */
|
|
1419
|
+
"opengrid-record-open": CustomEvent<RecordOpenDetail>;
|
|
1420
|
+
/** On `<opengrid-pivot>` with `drill-down`. */
|
|
1421
|
+
"opengrid-drill-down": CustomEvent<DrillDownDetail>;
|
|
1422
|
+
/** Dispatched by `loader.js` on the grid; it does not bubble. */
|
|
1423
|
+
"opengrid-source-replaced": CustomEvent<SourceReplacedDetail>;
|
|
1424
|
+
"opengrid-source-changed": CustomEvent<SourceChangedDetail>;
|
|
1425
|
+
"opengrid-detail-toggle": CustomEvent<DetailToggleDetail>;
|
|
1008
1426
|
}
|
|
1009
1427
|
|
|
1010
1428
|
// ---------------------------------------------------------------------------
|
|
@@ -1015,7 +1433,7 @@ export interface OpengridEventMap {
|
|
|
1015
1433
|
* The attributes of `<opengrid-grid>`, as strings the way HTML has them — for
|
|
1016
1434
|
* adapters and JSX typings to build on. For
|
|
1017
1435
|
* the boolean ones — `selection`, `toolbar`, `search`, `facets`,
|
|
1018
|
-
* `column-menu` — presence is what counts, whatever the value.
|
|
1436
|
+
* `column-menu`, `filter-builder`, `add-row` — presence is what counts, whatever the value.
|
|
1019
1437
|
*/
|
|
1020
1438
|
export interface OpengridGridAttributes {
|
|
1021
1439
|
label?: string;
|
|
@@ -1024,6 +1442,11 @@ export interface OpengridGridAttributes {
|
|
|
1024
1442
|
"window-size"?: string;
|
|
1025
1443
|
"page-size"?: string;
|
|
1026
1444
|
mode?: Mode;
|
|
1445
|
+
/**
|
|
1446
|
+
* The page's filter, as the wire's JSON — `{"field":"country","op":"eq","value":"DE"}` —
|
|
1447
|
+
* and-ed onto every query the grid sends. Not the reader's and not in the view.
|
|
1448
|
+
*/
|
|
1449
|
+
filter?: string;
|
|
1027
1450
|
"group-by"?: string;
|
|
1028
1451
|
/** The field holding a row's parent key: the rows show as a tree. */
|
|
1029
1452
|
tree?: string;
|
|
@@ -1035,6 +1458,8 @@ export interface OpengridGridAttributes {
|
|
|
1035
1458
|
facets?: string;
|
|
1036
1459
|
toolbar?: string;
|
|
1037
1460
|
"column-menu"?: string;
|
|
1461
|
+
/** *Advanced filter* in the toolbar: the builder of the nested filter (`where` in the view). */
|
|
1462
|
+
"filter-builder"?: string;
|
|
1038
1463
|
/** An empty row after the last one to type a new record into (`opengrid-row-add`). */
|
|
1039
1464
|
"add-row"?: string;
|
|
1040
1465
|
selection?: string;
|
|
@@ -1071,10 +1496,12 @@ export interface OpengridPivotAttributes {
|
|
|
1071
1496
|
measures?: string;
|
|
1072
1497
|
/** The filter on the raw rows, as the wire's JSON: `{"field":"country","op":"eq","value":"DE"}`. */
|
|
1073
1498
|
filter?: string;
|
|
1499
|
+
/** Makes every value a button that fires `opengrid-drill-down`; presence is what counts. */
|
|
1500
|
+
"drill-down"?: string;
|
|
1074
1501
|
theme?: Theme;
|
|
1075
1502
|
}
|
|
1076
1503
|
|
|
1077
|
-
/** `<opengrid-grid>`; it fires the
|
|
1504
|
+
/** `<opengrid-grid>`; it fires the events of {@link OpengridEventMap}. */
|
|
1078
1505
|
export interface OpengridGridElement extends HTMLElement {}
|
|
1079
1506
|
/** `<opengrid-table>`. */
|
|
1080
1507
|
export interface OpengridTableElement extends HTMLElement {}
|