@casoon/opengrid 0.15.0 → 0.17.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 +282 -1
- package/README.md +6 -4
- package/collation/opengrid_collation.d.ts +47 -0
- package/collation/opengrid_collation.js +256 -0
- package/collation/opengrid_collation_bg.wasm +0 -0
- package/collation/opengrid_collation_bg.wasm.d.ts +10 -0
- package/collation.js +78 -0
- package/engine/opengrid_wasm.d.ts +18 -1
- package/engine/opengrid_wasm.js +76 -0
- package/engine/opengrid_wasm_bg.wasm +0 -0
- package/engine/opengrid_wasm_bg.wasm.d.ts +5 -1
- package/loader.d.ts +405 -18
- package/loader.js +485 -95
- package/package.json +11 -1
- package/pkg/opengrid_web_components.d.ts +76 -10
- package/pkg/opengrid_web_components.js +346 -60
- package/pkg/opengrid_web_components_bg.wasm +0 -0
- package/pkg/opengrid_web_components_bg.wasm.d.ts +18 -9
- package/react/index.d.ts +10 -2
- package/react/index.js +10 -3
- package/svelte/Opengrid.svelte +7 -1
- package/svelte/OpengridGrid.svelte +7 -1
- package/svelte/OpengridPivot.svelte +3 -3
- package/svelte/OpengridTable.svelte +1 -1
- package/svelte/index.d.ts +14 -2
- package/svelte/index.js +1 -1
- package/texts/de.d.ts +5 -0
- package/texts/de.js +245 -0
- package/vue/index.d.ts +14 -2
- package/vue/index.js +11 -6
- package/worker.js +7 -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-ef3def04de0cb619 → opengrid-web-components-ae047af7b34e4f04}/inline0.js +0 -0
- /package/pkg/snippets/{opengrid-web-components-ef3def04de0cb619 → opengrid-web-components-ae047af7b34e4f04}/inline1.js +0 -0
- /package/pkg/snippets/{opengrid-web-core-78fdded9b8a374ed → opengrid-web-core-b158b7dd980e3998}/inline0.js +0 -0
- /package/pkg/snippets/{opengrid-web-core-78fdded9b8a374ed → opengrid-web-core-b158b7dd980e3998}/inline1.js +0 -0
- /package/pkg/snippets/{opengrid-web-core-78fdded9b8a374ed → opengrid-web-core-b158b7dd980e3998}/inline2.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
|
|
@@ -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
|
}
|
|
@@ -153,6 +185,10 @@ export interface ConnectOptions {
|
|
|
153
185
|
onCellChange?: (detail: CellChangeDetail) => void;
|
|
154
186
|
/** `set_actions`: compared by value. The grid only. */
|
|
155
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;
|
|
156
192
|
/** `set_validators`: functions compare by identity, as in `formats`. The grid only. */
|
|
157
193
|
validators?: Record<string, Validator | ValidatorRule>;
|
|
158
194
|
/**
|
|
@@ -166,6 +202,8 @@ export interface ConnectOptions {
|
|
|
166
202
|
onPaste?: (detail: PasteDetail) => void;
|
|
167
203
|
onBulkChange?: (detail: BulkChangeDetail) => void;
|
|
168
204
|
onRowAction?: (detail: RowActionDetail) => void;
|
|
205
|
+
/** A value of a pivot with `drill-down` was pressed. The pivot only. */
|
|
206
|
+
onDrillDown?: (detail: DrillDownDetail) => void;
|
|
169
207
|
/** The provider loaded the grid's source again (`loadRows`); the grid asks anew. */
|
|
170
208
|
onSourceReplaced?: (detail: SourceReplacedDetail) => void;
|
|
171
209
|
}
|
|
@@ -308,6 +346,13 @@ export interface Engine {
|
|
|
308
346
|
execute(queryJson: string): string;
|
|
309
347
|
/** The result in the binary form — what the tab and worker providers answer. */
|
|
310
348
|
execute_columns(queryJson: string): Uint8Array;
|
|
349
|
+
/**
|
|
350
|
+
* Gives the engine its collator: `sort_keys` of the collation module
|
|
351
|
+
* (`collation/opengrid_collation.js`). A sort key that names a locale needs
|
|
352
|
+
* it; the providers of the package load the module and call this when a
|
|
353
|
+
* query first sorts by one.
|
|
354
|
+
*/
|
|
355
|
+
set_collator(sortKeys: (locale: string, texts: Uint8Array, ends: Uint32Array) => Uint8Array): void;
|
|
311
356
|
/** What it holds, as JSON (see `EngineStats`). */
|
|
312
357
|
stats(): string;
|
|
313
358
|
/** A pivot over the engine's sources, as JSON (issue #28). */
|
|
@@ -340,6 +385,20 @@ export interface RestProvider extends Provider {
|
|
|
340
385
|
* `onProgress` hears the end, `signal` aborts the download too.
|
|
341
386
|
*/
|
|
342
387
|
export(query: ViewQuery, options?: ProviderExportOptions): Promise<Blob>;
|
|
388
|
+
/** `POST /pivot/{source}?format=xlsx`: see {@link PivotProvider.exportPivot}. */
|
|
389
|
+
exportPivot(pivotQuery: PivotQuery, options: ProviderPivotExportOptions): Promise<Blob>;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/** What `createPivotProvider` answers. */
|
|
393
|
+
export interface PivotProvider extends Provider {
|
|
394
|
+
/**
|
|
395
|
+
* `POST /pivot/{source}?format=xlsx`: the pivot of `pivotQuery` as an XLSX
|
|
396
|
+
* file — one flat sheet, the table a pivot's CSV is, with numbers and dates
|
|
397
|
+
* as cells of their type. The server's rules are `/pivot`'s; its bounds are
|
|
398
|
+
* the pivot's limits and `max_xlsx_rows`. `exportPivot` builds the query
|
|
399
|
+
* from an element, and takes its words from it.
|
|
400
|
+
*/
|
|
401
|
+
exportPivot(pivotQuery: PivotQuery, options: ProviderPivotExportOptions): Promise<Blob>;
|
|
343
402
|
}
|
|
344
403
|
|
|
345
404
|
/** The `Planner` of the engine module, as `createHybridProvider` uses it. */
|
|
@@ -348,6 +407,8 @@ export interface PlannerLike {
|
|
|
348
407
|
plan(queryJson: string, mode: string): string;
|
|
349
408
|
/** Finishes the client half over the source's answer; the result as JSON. */
|
|
350
409
|
finish(clientQueryJson: string, resultJson: string): string;
|
|
410
|
+
/** The collator for the client half, as `Engine.set_collator`. */
|
|
411
|
+
set_collator(sortKeys: (locale: string, texts: Uint8Array, ends: Uint32Array) => Uint8Array): void;
|
|
351
412
|
/** The same over an answer in the binary form; the result as bytes. */
|
|
352
413
|
finish_columns(clientQueryJson: string, result: Uint8Array): Uint8Array;
|
|
353
414
|
}
|
|
@@ -370,6 +431,12 @@ export interface ServerOptions {
|
|
|
370
431
|
source: string;
|
|
371
432
|
/** Bearer token; the server refuses without one. */
|
|
372
433
|
token?: string;
|
|
434
|
+
/**
|
|
435
|
+
* Opens `GET /watch/{source}` and tells the grids on this provider with
|
|
436
|
+
* `opengrid-source-changed` when the server says the source changed (issue #328).
|
|
437
|
+
* Off by default; a server may not offer it.
|
|
438
|
+
*/
|
|
439
|
+
watch?: boolean;
|
|
373
440
|
}
|
|
374
441
|
|
|
375
442
|
/** The engine on the main thread. */
|
|
@@ -391,7 +458,7 @@ export function createWorkerProvider(options?: {
|
|
|
391
458
|
export function createRestProvider(options: ServerOptions): RestProvider;
|
|
392
459
|
|
|
393
460
|
/** `POST /pivot/{source}` — a whole pivot in one request. */
|
|
394
|
-
export function createPivotProvider(options: ServerOptions):
|
|
461
|
+
export function createPivotProvider(options: ServerOptions): PivotProvider;
|
|
395
462
|
|
|
396
463
|
/** Splits each query between a remote source and the engine in the tab. */
|
|
397
464
|
export function createHybridProvider(options: {
|
|
@@ -420,15 +487,30 @@ export interface ExportProgress {
|
|
|
420
487
|
*/
|
|
421
488
|
export interface ExportOptions extends CsvOptions {
|
|
422
489
|
/**
|
|
423
|
-
* `"csv"` (the default), `"json"` — an array of row objects — or `"xlsx"`,
|
|
424
|
-
*
|
|
425
|
-
*
|
|
490
|
+
* `"csv"` (the default), `"json"` — an array of row objects — or `"xlsx"`, a
|
|
491
|
+
* workbook: written by the server where the provider exports there
|
|
492
|
+
* (`createRestProvider`), and in the tab for any other provider by a module
|
|
493
|
+
* of its own that `exportRows` loads the first time (`@casoon/opengrid/xlsx/`,
|
|
494
|
+
* about 250 KB brotli). The tab holds the whole workbook in memory, so
|
|
495
|
+
* `maxRows` bounds it — 250 000 by default there — and more rows than an Excel
|
|
496
|
+
* sheet holds (1 048 575) is an error.
|
|
426
497
|
*/
|
|
427
498
|
format?: "csv" | "json" | "xlsx";
|
|
428
499
|
/** Rows per request; 10 000 by default, the server's `max_limit`. */
|
|
429
500
|
chunkSize?: number;
|
|
430
|
-
/**
|
|
501
|
+
/**
|
|
502
|
+
* More matches than this is an error, never a truncated file; 1 000 000 by
|
|
503
|
+
* default, and 250 000 for an XLSX written in the tab.
|
|
504
|
+
*/
|
|
431
505
|
maxRows?: number;
|
|
506
|
+
/**
|
|
507
|
+
* Header texts by field name for CSV and XLSX, `{ city: "Address · City" }`
|
|
508
|
+
* (issue #353); `get_export_headers(grid)` answers them for a grid with bands.
|
|
509
|
+
* A column without one keeps its field name. A JSON export has no header row
|
|
510
|
+
* and refuses the option. The server takes each as a parameter,
|
|
511
|
+
* `header.<column>`.
|
|
512
|
+
*/
|
|
513
|
+
headers?: Record<string, string>;
|
|
432
514
|
/** Called after each piece. */
|
|
433
515
|
onProgress?: (progress: ExportProgress) => void;
|
|
434
516
|
/** Aborts the export: it rejects with an `AbortError` and gives no `Blob`. */
|
|
@@ -452,6 +534,64 @@ export type ProviderExportOptions = Omit<ExportOptions, "chunkSize">;
|
|
|
452
534
|
*/
|
|
453
535
|
export function exportRows(provider: Provider, query: ViewQuery, options?: ExportOptions): Promise<Blob>;
|
|
454
536
|
|
|
537
|
+
/** A pivot query, as `POST /pivot/{source}` takes it. */
|
|
538
|
+
export interface PivotQuery {
|
|
539
|
+
source: string;
|
|
540
|
+
rows: string[];
|
|
541
|
+
columns: string[];
|
|
542
|
+
values: PivotMeasure[];
|
|
543
|
+
sort?: PivotSort[];
|
|
544
|
+
filter?: Record<string, unknown>;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/** How a pivot is exported as a workbook. Any other key is an error. */
|
|
548
|
+
export interface PivotExportOptions {
|
|
549
|
+
/** `"xlsx"`, the one format the server writes a pivot in; its CSV is `get_pivot`. */
|
|
550
|
+
format: "xlsx";
|
|
551
|
+
/** Aborts the request: it rejects with an `AbortError` and gives no `Blob`. */
|
|
552
|
+
signal?: AbortSignal;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* What a provider's `exportPivot` takes: {@link PivotExportOptions}, and the
|
|
557
|
+
* words the server writes where the data has none. The method has a query and
|
|
558
|
+
* no element, so they are handed to it; the function `exportPivot` reads them
|
|
559
|
+
* from the element.
|
|
560
|
+
*/
|
|
561
|
+
export interface ProviderPivotExportOptions extends PivotExportOptions {
|
|
562
|
+
/**
|
|
563
|
+
* `total`, `subtotal` (with `{value}`), `noValue` and `emptyValue`, and what
|
|
564
|
+
* a calculated measure is shown as — `shareOfRow`, `shareOfColumn`,
|
|
565
|
+
* `shareOfTotal`, `runningTotal`; any other key is ignored. Without them
|
|
566
|
+
* the server's English defaults.
|
|
567
|
+
*/
|
|
568
|
+
texts?: Pick<
|
|
569
|
+
Texts,
|
|
570
|
+
| "total"
|
|
571
|
+
| "subtotal"
|
|
572
|
+
| "noValue"
|
|
573
|
+
| "emptyValue"
|
|
574
|
+
| "shareOfRow"
|
|
575
|
+
| "shareOfColumn"
|
|
576
|
+
| "shareOfTotal"
|
|
577
|
+
| "runningTotal"
|
|
578
|
+
>;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* The pivot `host` shows as an XLSX file, written by the server: the
|
|
583
|
+
* element's view asked again through the provider's `exportPivot`, as one flat
|
|
584
|
+
* sheet — the header row and the rows of `get_pivot`'s CSV, numbers and dates
|
|
585
|
+
* typed, the totals and the NULL and empty groups in the element's own texts.
|
|
586
|
+
* A provider without `exportPivot` (the engine in the tab or a worker) is a
|
|
587
|
+
* `TypeError`.
|
|
588
|
+
*/
|
|
589
|
+
export function exportPivot(
|
|
590
|
+
provider: Pick<PivotProvider, "exportPivot">,
|
|
591
|
+
host: HTMLElement,
|
|
592
|
+
options: PivotExportOptions,
|
|
593
|
+
): Promise<Blob>;
|
|
594
|
+
|
|
455
595
|
// ---------------------------------------------------------------------------
|
|
456
596
|
// Errors
|
|
457
597
|
// ---------------------------------------------------------------------------
|
|
@@ -550,6 +690,12 @@ export type FacetKind = "list" | "pills" | "range" | "period";
|
|
|
550
690
|
/** A value as the wire format writes it: decimals and dates are strings. */
|
|
551
691
|
export type WireValue = string | number | boolean | null;
|
|
552
692
|
|
|
693
|
+
/**
|
|
694
|
+
* Where a column is kept in place while the others scroll sideways: at the
|
|
695
|
+
* start of the row or at its end, by reading direction.
|
|
696
|
+
*/
|
|
697
|
+
export type Pin = "start" | "end";
|
|
698
|
+
|
|
553
699
|
/** Per-column presentation for `set_columns` — `presentation` in `connect`. */
|
|
554
700
|
export interface ColumnConfig {
|
|
555
701
|
/**
|
|
@@ -560,6 +706,18 @@ export interface ColumnConfig {
|
|
|
560
706
|
title?: string;
|
|
561
707
|
/** The starting width in pixels; a reader's resize leads after that. */
|
|
562
708
|
width?: number;
|
|
709
|
+
/**
|
|
710
|
+
* Where the column starts pinned; the reader's own pin leads after that
|
|
711
|
+
* (`Alt`+`Shift`+`←`/`→` on the header, the column menu). The grid only.
|
|
712
|
+
*/
|
|
713
|
+
pin?: Pin;
|
|
714
|
+
/**
|
|
715
|
+
* The band the column stands under: a header it shares with the other
|
|
716
|
+
* columns that name the same one. A band is always in one piece — its
|
|
717
|
+
* columns stand together, move inside it, and are pinned with it. The grid
|
|
718
|
+
* only.
|
|
719
|
+
*/
|
|
720
|
+
band?: string;
|
|
563
721
|
align?: "start" | "end" | "center";
|
|
564
722
|
mono?: boolean;
|
|
565
723
|
emphasis?: boolean;
|
|
@@ -571,6 +729,14 @@ export interface ColumnConfig {
|
|
|
571
729
|
* its cells are announced as read-only. The grid only.
|
|
572
730
|
*/
|
|
573
731
|
readonly?: boolean;
|
|
732
|
+
/**
|
|
733
|
+
* The labels of the keys the column stores, key → label: the cell, the
|
|
734
|
+
* editor, the filter row and the facets show and choose by label. The value
|
|
735
|
+
* stays the key — in the query, the view, events and exports — and **the
|
|
736
|
+
* column sorts and groups by the key, not by the label**. For a `utf8` or
|
|
737
|
+
* `int64` column. The grid only.
|
|
738
|
+
*/
|
|
739
|
+
lookup?: Record<string | number, string>;
|
|
574
740
|
}
|
|
575
741
|
|
|
576
742
|
/** What `set_cell_state` says became of an edit. */
|
|
@@ -625,6 +791,23 @@ export interface FilterEntry {
|
|
|
625
791
|
value: string;
|
|
626
792
|
}
|
|
627
793
|
|
|
794
|
+
/**
|
|
795
|
+
* The nested filter of a view (`where`): conditions joined by `and` and `or`,
|
|
796
|
+
* in the wire form of a query's `filter` — values typed, so a number is a
|
|
797
|
+
* number and a decimal or a date a string. What the search expression and the
|
|
798
|
+
* builder dialog can write; `not` and the operator `in` are not part of it.
|
|
799
|
+
*/
|
|
800
|
+
export type ViewFilter =
|
|
801
|
+
| { and: ViewFilter[] }
|
|
802
|
+
| { or: ViewFilter[] }
|
|
803
|
+
| {
|
|
804
|
+
field: string;
|
|
805
|
+
op: Exclude<FilterOperator, "is_null" | "is_not_null" | "is_empty" | "has_all">;
|
|
806
|
+
value: string | number | boolean;
|
|
807
|
+
}
|
|
808
|
+
| { field: string; op: "has_all"; value: Array<string | number> }
|
|
809
|
+
| { field: string; op: "is_null" | "is_not_null" | "is_empty" };
|
|
810
|
+
|
|
628
811
|
/** A facet selection: values for `list`/`pills`, bounds for `range`/`period`. */
|
|
629
812
|
export type FacetSelection =
|
|
630
813
|
| { values: WireValue[] }
|
|
@@ -632,17 +815,27 @@ export type FacetSelection =
|
|
|
632
815
|
| { from: string; to: string };
|
|
633
816
|
|
|
634
817
|
/**
|
|
635
|
-
* Sort, filters, column layout, density, grouping,
|
|
636
|
-
* one value — as `get_view` writes it, every field present. `set_view` reads
|
|
818
|
+
* Sort, filters, the nested filter, column layout, density, grouping,
|
|
819
|
+
* aggregates and facets as one value — as `get_view` writes it, every field present. `set_view` reads
|
|
637
820
|
* some fields more leniently (a missing direction is `asc`, a missing operator
|
|
638
821
|
* `eq`); the types ask for the full form on purpose, so a saved view says what
|
|
639
|
-
* it means. A saved view is this value with a name on it.
|
|
640
|
-
*
|
|
822
|
+
* it means. A saved view is this value with a name on it. A selection by key
|
|
823
|
+
* is part of it (`selected`); a selection by position and the free-text
|
|
824
|
+
* search are deliberately not.
|
|
641
825
|
*/
|
|
642
826
|
export interface View {
|
|
643
827
|
sort: SortKey[];
|
|
644
828
|
filters: FilterEntry[];
|
|
645
|
-
columns: {
|
|
829
|
+
columns: {
|
|
830
|
+
order: string[];
|
|
831
|
+
hidden: string[];
|
|
832
|
+
widths: Record<string, number>;
|
|
833
|
+
/**
|
|
834
|
+
* The pins the reader changed: `none` is a pin of `set_columns` taken
|
|
835
|
+
* away. Leads over `set_columns`.
|
|
836
|
+
*/
|
|
837
|
+
pinned: Record<string, Pin | "none">;
|
|
838
|
+
};
|
|
646
839
|
density: Density;
|
|
647
840
|
group: string[];
|
|
648
841
|
/** The open groups, each as its path of keys. */
|
|
@@ -652,14 +845,46 @@ export interface View {
|
|
|
652
845
|
/** Whether the filter row shows. */
|
|
653
846
|
filterRow: boolean;
|
|
654
847
|
facets: Record<string, FacetSelection>;
|
|
848
|
+
/**
|
|
849
|
+
* The keys of the selected records, where the grid selects by key (`row-key`,
|
|
850
|
+
* or a tree's `tree-key`). Left out while nothing is selected, and always for
|
|
851
|
+
* a selection by position. `set_view` asks the source which of them name a
|
|
852
|
+
* record before it selects; a view without the field selects nothing.
|
|
853
|
+
*/
|
|
854
|
+
selected?: Array<string | number | boolean>;
|
|
855
|
+
/**
|
|
856
|
+
* The keys of the records whose detail panel is open (issue #318). Left out
|
|
857
|
+
* while none is. A restored view opens them as their rows load.
|
|
858
|
+
*/
|
|
859
|
+
detail?: Array<string | number | boolean>;
|
|
860
|
+
/**
|
|
861
|
+
* The nested filter: the one filter with `or` across columns, and-ed onto
|
|
862
|
+
* the filter row's (`filters`), the facets' and the page's. Left out while
|
|
863
|
+
* there is none; a view without the field has none.
|
|
864
|
+
*/
|
|
865
|
+
where?: ViewFilter;
|
|
655
866
|
}
|
|
656
867
|
|
|
868
|
+
/**
|
|
869
|
+
* What a calculated measure shows in place of its aggregate: the cell as a
|
|
870
|
+
* fraction of its row's total, of its column's total or of the grand total —
|
|
871
|
+
* a number between 0 and 1, NULL where that total is NULL or zero — or the
|
|
872
|
+
* running total along the columns, which starts again in every row.
|
|
873
|
+
*/
|
|
874
|
+
export type PivotCalc = "share_of_row" | "share_of_column" | "share_of_total" | "running_total";
|
|
875
|
+
|
|
657
876
|
/** A pivot measure, as the contract writes it: `{ field: "qty", fn: "sum", as: "total" }`. */
|
|
658
877
|
export interface PivotMeasure {
|
|
659
878
|
/** Absent for `count`. */
|
|
660
879
|
field?: string;
|
|
661
880
|
fn: string;
|
|
662
881
|
as: string;
|
|
882
|
+
/**
|
|
883
|
+
* Shows the measure as a calculation over the pivot's cells. A share is for
|
|
884
|
+
* `sum` and `count`; a running total also for `avg`, `min` and `max` over a
|
|
885
|
+
* number. The source refuses anything else.
|
|
886
|
+
*/
|
|
887
|
+
calc?: PivotCalc;
|
|
663
888
|
}
|
|
664
889
|
|
|
665
890
|
/**
|
|
@@ -776,6 +1001,12 @@ export type TextKey =
|
|
|
776
1001
|
| "groupSecondLevel"
|
|
777
1002
|
| "ungroupColumn"
|
|
778
1003
|
| "hideColumn"
|
|
1004
|
+
| "hideBand"
|
|
1005
|
+
| "bandKeep"
|
|
1006
|
+
| "pinGroup"
|
|
1007
|
+
| "pinNone"
|
|
1008
|
+
| "pinStart"
|
|
1009
|
+
| "pinEnd"
|
|
779
1010
|
| "toolbarGroup"
|
|
780
1011
|
| "filterRowToggle"
|
|
781
1012
|
| "densityGroup"
|
|
@@ -819,6 +1050,13 @@ export type TextKey =
|
|
|
819
1050
|
| "pivotFilters"
|
|
820
1051
|
| "pivotFilterLabel"
|
|
821
1052
|
| "pivotFilterHint"
|
|
1053
|
+
| "pivotDrillDown"
|
|
1054
|
+
| "pivotShowAs"
|
|
1055
|
+
| "calcValue"
|
|
1056
|
+
| "shareOfRow"
|
|
1057
|
+
| "shareOfColumn"
|
|
1058
|
+
| "shareOfTotal"
|
|
1059
|
+
| "runningTotal"
|
|
822
1060
|
| "treeContext"
|
|
823
1061
|
| "subtreeCell"
|
|
824
1062
|
| "subtreeOnly"
|
|
@@ -850,15 +1088,35 @@ export type TextKey =
|
|
|
850
1088
|
| "queryUnknownColumn"
|
|
851
1089
|
| "queryMissingValue"
|
|
852
1090
|
| "queryWrongOperator"
|
|
1091
|
+
| "queryOr"
|
|
1092
|
+
| "queryUnclosed"
|
|
1093
|
+
| "queryUnopened"
|
|
1094
|
+
| "queryMissingCondition"
|
|
1095
|
+
| "queryMissingJoin"
|
|
1096
|
+
| "filterBuilder"
|
|
1097
|
+
| "filterBuilderJoin"
|
|
1098
|
+
| "filterBuilderAll"
|
|
1099
|
+
| "filterBuilderAny"
|
|
1100
|
+
| "filterBuilderCondition"
|
|
1101
|
+
| "filterBuilderGroup"
|
|
1102
|
+
| "filterBuilderAddCondition"
|
|
1103
|
+
| "filterBuilderAddGroup"
|
|
1104
|
+
| "filterBuilderEdit"
|
|
1105
|
+
| "filterApplied"
|
|
853
1106
|
| "emptyFiltered"
|
|
854
1107
|
| "emptySource"
|
|
855
1108
|
| "emptyReset"
|
|
856
1109
|
| "filterInvalid"
|
|
857
1110
|
| "cellRequired"
|
|
858
1111
|
| "selectionCleared"
|
|
1112
|
+
| "selectionMissing"
|
|
859
1113
|
| "columnWidth"
|
|
860
1114
|
| "columnMoved"
|
|
861
1115
|
| "columnAtEdge"
|
|
1116
|
+
| "columnPinnedStart"
|
|
1117
|
+
| "columnPinnedEnd"
|
|
1118
|
+
| "columnUnpinned"
|
|
1119
|
+
| "pinsReleased"
|
|
862
1120
|
| "columnHidden"
|
|
863
1121
|
| "columnShown"
|
|
864
1122
|
| "columnsGroup"
|
|
@@ -902,6 +1160,22 @@ export type TextKey =
|
|
|
902
1160
|
| "undoAdded"
|
|
903
1161
|
| "redoAdded"
|
|
904
1162
|
| "undoPaste"
|
|
1163
|
+
| "undoRecord"
|
|
1164
|
+
| "redoRecord"
|
|
1165
|
+
| "recordTitle"
|
|
1166
|
+
| "recordSave"
|
|
1167
|
+
| "recordDone"
|
|
1168
|
+
| "recordNothing"
|
|
1169
|
+
| "rangeSize"
|
|
1170
|
+
| "rangeCopied"
|
|
1171
|
+
| "rangeUnloaded"
|
|
1172
|
+
| "sourceChanged"
|
|
1173
|
+
| "sourceRefresh"
|
|
1174
|
+
| "detailShow"
|
|
1175
|
+
| "detailHide"
|
|
1176
|
+
| "detailPanel"
|
|
1177
|
+
| "detailShown"
|
|
1178
|
+
| "detailHidden"
|
|
905
1179
|
| "redoPaste"
|
|
906
1180
|
| "undoNothing"
|
|
907
1181
|
| "redoNothing";
|
|
@@ -920,11 +1194,10 @@ export type Texts = Partial<Record<TextKey, string>> & {
|
|
|
920
1194
|
// ---------------------------------------------------------------------------
|
|
921
1195
|
|
|
922
1196
|
/**
|
|
923
|
-
* `opengrid-selection-change
|
|
924
|
-
*
|
|
925
|
-
* `keys` names every selected node by its key and `count` counts them.
|
|
1197
|
+
* `opengrid-selection-change` of a grid that selects **by position** — no
|
|
1198
|
+
* `row-key`, no tree: logical row numbers, ascending.
|
|
926
1199
|
*/
|
|
927
|
-
export interface
|
|
1200
|
+
export interface SelectionByPosition {
|
|
928
1201
|
rows: number[];
|
|
929
1202
|
/**
|
|
930
1203
|
* The same rows as runs of adjacent ones, ascending, both ends inclusive:
|
|
@@ -932,10 +1205,28 @@ export interface SelectionChangeDetail {
|
|
|
932
1205
|
*/
|
|
933
1206
|
ranges: Array<{ from: number; to: number }>;
|
|
934
1207
|
count: number;
|
|
935
|
-
|
|
936
|
-
|
|
1208
|
+
keys?: undefined;
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
/**
|
|
1212
|
+
* `opengrid-selection-change` of a grid that selects **by key** — with
|
|
1213
|
+
* `row-key` (grouped or not), or a tree: the keys of the selected records, in
|
|
1214
|
+
* no particular order (a tree's: the nodes shown first), and their number.
|
|
1215
|
+
* There are no positions: a key names a record wherever it sits, loaded or not.
|
|
1216
|
+
*/
|
|
1217
|
+
export interface SelectionByKey {
|
|
1218
|
+
count: number;
|
|
1219
|
+
keys: unknown[];
|
|
1220
|
+
rows?: undefined;
|
|
1221
|
+
ranges?: undefined;
|
|
937
1222
|
}
|
|
938
1223
|
|
|
1224
|
+
/**
|
|
1225
|
+
* `opengrid-selection-change`: one of the two, by what the grid's selection
|
|
1226
|
+
* names. `detail.keys` (or `"keys" in detail`) narrows it.
|
|
1227
|
+
*/
|
|
1228
|
+
export type SelectionChangeDetail = SelectionByPosition | SelectionByKey;
|
|
1229
|
+
|
|
939
1230
|
/** `opengrid-cell-change`: everything a page needs to persist an edit. */
|
|
940
1231
|
export interface CellChangeDetail {
|
|
941
1232
|
row: number;
|
|
@@ -955,6 +1246,31 @@ export interface CellChangeDetail {
|
|
|
955
1246
|
/** What a validator says about a value, or `null` for nothing. */
|
|
956
1247
|
export type Finding = { level: "warning" | "error"; message: string } | null | undefined;
|
|
957
1248
|
/** `value` is the text in the editor, `row` the record as loaded, by field name. */
|
|
1249
|
+
/** What `set_cell_templates` gives a function (issue #317). */
|
|
1250
|
+
export interface CellTemplateArgument {
|
|
1251
|
+
/** The cell's value as it is on the wire. */
|
|
1252
|
+
value: WireValue;
|
|
1253
|
+
/** The text the column's format makes of it. */
|
|
1254
|
+
text: string;
|
|
1255
|
+
/** The record as loaded, by field name. */
|
|
1256
|
+
row: Record<string, WireValue>;
|
|
1257
|
+
/** The record's `row-key` value; `undefined` without one. */
|
|
1258
|
+
key: WireValue | undefined;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
/**
|
|
1262
|
+
* The panel under an open row (issue #318): the record as the grid holds it and
|
|
1263
|
+
* its `row-key` value. A node, or a string shown as text; `null` or
|
|
1264
|
+
* `undefined`: this record has no panel.
|
|
1265
|
+
*/
|
|
1266
|
+
export type DetailRenderer = (
|
|
1267
|
+
record: Record<string, WireValue>,
|
|
1268
|
+
key: WireValue,
|
|
1269
|
+
) => Node | string | null | undefined;
|
|
1270
|
+
|
|
1271
|
+
/** A node, or a string shown as text; `null` or `undefined` leaves the cell's text. */
|
|
1272
|
+
export type CellTemplate = (cell: CellTemplateArgument) => Node | string | null | undefined;
|
|
1273
|
+
|
|
958
1274
|
export type Validator = (value: string, row: Record<string, WireValue>) => Finding;
|
|
959
1275
|
/** A validator that may block the commit on an `error`. */
|
|
960
1276
|
export interface ValidatorRule {
|
|
@@ -977,6 +1293,28 @@ export interface RowActionDetail {
|
|
|
977
1293
|
key?: WireValue;
|
|
978
1294
|
}
|
|
979
1295
|
|
|
1296
|
+
/**
|
|
1297
|
+
* `opengrid-drill-down`: a value of an `<opengrid-pivot>` with `drill-down`
|
|
1298
|
+
* was pressed (issue #330). The page shows the rows.
|
|
1299
|
+
*/
|
|
1300
|
+
export interface DrillDownDetail {
|
|
1301
|
+
/**
|
|
1302
|
+
* The rows behind the cell, as the wire writes a query. `filter` is the
|
|
1303
|
+
* pivot's own filter and-ed with one clause per dimension the cell lies in
|
|
1304
|
+
* — a NULL group as `is_null`, the empty string as `eq ""` — and absent
|
|
1305
|
+
* when nothing restricts the rows.
|
|
1306
|
+
*/
|
|
1307
|
+
query: { source: string; filter?: Record<string, unknown> };
|
|
1308
|
+
/** The row group's keys, down to the row's level; `[]` for the grand total. */
|
|
1309
|
+
row: WireValue[];
|
|
1310
|
+
/** The column group's keys, one per column dimension. */
|
|
1311
|
+
column: WireValue[];
|
|
1312
|
+
/** The measure's alias. */
|
|
1313
|
+
measure: string;
|
|
1314
|
+
/** The cell's value, as the answer carried it. */
|
|
1315
|
+
value: WireValue;
|
|
1316
|
+
}
|
|
1317
|
+
|
|
980
1318
|
/** `opengrid-row-add`: a record was typed into the new row (issue #183). */
|
|
981
1319
|
export interface RowAddDetail {
|
|
982
1320
|
/** The values by field name, in the wire notation of a result. */
|
|
@@ -996,6 +1334,27 @@ export interface SourceReplacedDetail {
|
|
|
996
1334
|
name: string;
|
|
997
1335
|
}
|
|
998
1336
|
|
|
1337
|
+
/**
|
|
1338
|
+
* `opengrid-source-changed`: the source behind the grid changed (issue #328).
|
|
1339
|
+
* **Cancelable**: `preventDefault()` keeps the grid's notice and "Refresh" button
|
|
1340
|
+
* from showing; call `refresh(grid)` when it suits. Fired on the grid only; it
|
|
1341
|
+
* does not bubble.
|
|
1342
|
+
*/
|
|
1343
|
+
export interface SourceChangedDetail {
|
|
1344
|
+
name: string | undefined;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
/**
|
|
1348
|
+
* `opengrid-detail-toggle`: a row's detail panel opened or closed (issue #318).
|
|
1349
|
+
*/
|
|
1350
|
+
export interface DetailToggleDetail {
|
|
1351
|
+
/** The record's `row-key` value. */
|
|
1352
|
+
key: WireValue;
|
|
1353
|
+
/** The row in the result. */
|
|
1354
|
+
row: number;
|
|
1355
|
+
open: boolean;
|
|
1356
|
+
}
|
|
1357
|
+
|
|
999
1358
|
/** `opengrid-bulk-change`: one value for the selected rows (issue #187). */
|
|
1000
1359
|
export interface BulkChangeDetail {
|
|
1001
1360
|
/** The `row-key` values of the selected records. */
|
|
@@ -1004,6 +1363,13 @@ export interface BulkChangeDetail {
|
|
|
1004
1363
|
value: string;
|
|
1005
1364
|
}
|
|
1006
1365
|
|
|
1366
|
+
/** `opengrid-record-open`: the reader asked for a record as a form (issue #325). Cancelable. */
|
|
1367
|
+
export interface RecordOpenDetail {
|
|
1368
|
+
/** The record's `row-key` value. */
|
|
1369
|
+
key: WireValue;
|
|
1370
|
+
row: number;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1007
1373
|
/** `opengrid-paste`: a pasted block was applied (issue #184). */
|
|
1008
1374
|
export interface PasteDetail {
|
|
1009
1375
|
/** One per cell of an existing row. */
|
|
@@ -1058,8 +1424,14 @@ export interface OpengridEventMap {
|
|
|
1058
1424
|
"opengrid-row-add": CustomEvent<RowAddDetail>;
|
|
1059
1425
|
"opengrid-paste": CustomEvent<PasteDetail>;
|
|
1060
1426
|
"opengrid-bulk-change": CustomEvent<BulkChangeDetail>;
|
|
1427
|
+
/** Cancelable: `preventDefault()` keeps the grid from opening its record form. */
|
|
1428
|
+
"opengrid-record-open": CustomEvent<RecordOpenDetail>;
|
|
1429
|
+
/** On `<opengrid-pivot>` with `drill-down`. */
|
|
1430
|
+
"opengrid-drill-down": CustomEvent<DrillDownDetail>;
|
|
1061
1431
|
/** Dispatched by `loader.js` on the grid; it does not bubble. */
|
|
1062
1432
|
"opengrid-source-replaced": CustomEvent<SourceReplacedDetail>;
|
|
1433
|
+
"opengrid-source-changed": CustomEvent<SourceChangedDetail>;
|
|
1434
|
+
"opengrid-detail-toggle": CustomEvent<DetailToggleDetail>;
|
|
1063
1435
|
}
|
|
1064
1436
|
|
|
1065
1437
|
// ---------------------------------------------------------------------------
|
|
@@ -1070,7 +1442,7 @@ export interface OpengridEventMap {
|
|
|
1070
1442
|
* The attributes of `<opengrid-grid>`, as strings the way HTML has them — for
|
|
1071
1443
|
* adapters and JSX typings to build on. For
|
|
1072
1444
|
* the boolean ones — `selection`, `toolbar`, `search`, `facets`,
|
|
1073
|
-
* `column-menu`, `add-row` — presence is what counts, whatever the value.
|
|
1445
|
+
* `column-menu`, `filter-builder`, `add-row` — presence is what counts, whatever the value.
|
|
1074
1446
|
*/
|
|
1075
1447
|
export interface OpengridGridAttributes {
|
|
1076
1448
|
label?: string;
|
|
@@ -1079,6 +1451,17 @@ export interface OpengridGridAttributes {
|
|
|
1079
1451
|
"window-size"?: string;
|
|
1080
1452
|
"page-size"?: string;
|
|
1081
1453
|
mode?: Mode;
|
|
1454
|
+
/**
|
|
1455
|
+
* The page's filter, as the wire's JSON — `{"field":"country","op":"eq","value":"DE"}` —
|
|
1456
|
+
* and-ed onto every query the grid sends. Not the reader's and not in the view.
|
|
1457
|
+
*/
|
|
1458
|
+
filter?: string;
|
|
1459
|
+
/**
|
|
1460
|
+
* The locale text columns sort by — `de`, `sv`, `sr-Latn`, `und` for the root
|
|
1461
|
+
* collation. Every sort key of the grid on a text column carries it; without
|
|
1462
|
+
* it text sorts by code point. Not in the view.
|
|
1463
|
+
*/
|
|
1464
|
+
collation?: string;
|
|
1082
1465
|
"group-by"?: string;
|
|
1083
1466
|
/** The field holding a row's parent key: the rows show as a tree. */
|
|
1084
1467
|
tree?: string;
|
|
@@ -1090,6 +1473,8 @@ export interface OpengridGridAttributes {
|
|
|
1090
1473
|
facets?: string;
|
|
1091
1474
|
toolbar?: string;
|
|
1092
1475
|
"column-menu"?: string;
|
|
1476
|
+
/** *Advanced filter* in the toolbar: the builder of the nested filter (`where` in the view). */
|
|
1477
|
+
"filter-builder"?: string;
|
|
1093
1478
|
/** An empty row after the last one to type a new record into (`opengrid-row-add`). */
|
|
1094
1479
|
"add-row"?: string;
|
|
1095
1480
|
selection?: string;
|
|
@@ -1126,6 +1511,8 @@ export interface OpengridPivotAttributes {
|
|
|
1126
1511
|
measures?: string;
|
|
1127
1512
|
/** The filter on the raw rows, as the wire's JSON: `{"field":"country","op":"eq","value":"DE"}`. */
|
|
1128
1513
|
filter?: string;
|
|
1514
|
+
/** Makes every value a button that fires `opengrid-drill-down`; presence is what counts. */
|
|
1515
|
+
"drill-down"?: string;
|
|
1129
1516
|
theme?: Theme;
|
|
1130
1517
|
}
|
|
1131
1518
|
|