@casoon/opengrid 0.20.1 → 0.21.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 +185 -1
- package/README.md +10 -6
- package/collation/opengrid_collation_bg.wasm +0 -0
- package/engine/opengrid_wasm.d.ts +7 -0
- package/engine/opengrid_wasm.js +29 -2
- package/engine/opengrid_wasm_bg.wasm +0 -0
- package/engine/opengrid_wasm_bg.wasm.d.ts +1 -0
- package/loader.d.ts +228 -4
- package/loader.js +105 -2
- package/package.json +19 -3
- package/pkg/opengrid_web_components.d.ts +47 -10
- package/pkg/opengrid_web_components.js +185 -59
- package/pkg/opengrid_web_components_bg.wasm +0 -0
- package/pkg/opengrid_web_components_bg.wasm.d.ts +13 -10
- package/react/index.d.ts +6 -0
- package/react/index.js +10 -1
- package/solid/index.d.ts +149 -0
- package/solid/index.js +252 -0
- package/svelte/Opengrid.svelte +12 -0
- package/svelte/OpengridGrid.svelte +6 -0
- package/svelte/index.d.ts +13 -1
- package/texts/de.js +29 -0
- package/vue/index.d.ts +13 -1
- package/vue/index.js +20 -2
- package/worker.js +5 -0
- package/xlsx/opengrid_xlsx_bg.wasm +0 -0
- /package/pkg/snippets/{opengrid-web-components-75269052febb3de2 → opengrid-web-components-7b74e96872f41f92}/inline0.js +0 -0
- /package/pkg/snippets/{opengrid-web-components-75269052febb3de2 → opengrid-web-components-7b74e96872f41f92}/inline1.js +0 -0
- /package/pkg/snippets/{opengrid-web-core-d95b346530aeec64 → opengrid-web-core-2138c846fafc77c3}/inline0.js +0 -0
- /package/pkg/snippets/{opengrid-web-core-d95b346530aeec64 → opengrid-web-core-2138c846fafc77c3}/inline1.js +0 -0
- /package/pkg/snippets/{opengrid-web-core-d95b346530aeec64 → opengrid-web-core-2138c846fafc77c3}/inline2.js +0 -0
package/loader.d.ts
CHANGED
|
@@ -118,6 +118,22 @@ export interface OpengridModule {
|
|
|
118
118
|
* The label is the accessible name; group headers and the total have no button.
|
|
119
119
|
*/
|
|
120
120
|
set_actions(host: HTMLElement, actions: RowAction[]): void;
|
|
121
|
+
/**
|
|
122
|
+
* The page's own items in the cell menu (issue #524), after the grid's:
|
|
123
|
+
* a long-press, a right click, `Shift`+`F10` or the context-menu key opens
|
|
124
|
+
* it. `column` offers an item on that one column only. Choosing one fires
|
|
125
|
+
* `opengrid-cell-action`. The grid only.
|
|
126
|
+
*/
|
|
127
|
+
set_cell_actions(host: HTMLElement, actions: CellAction[]): void;
|
|
128
|
+
/**
|
|
129
|
+
* The page's own items in the toolbar (issue #531), after the grid's own
|
|
130
|
+
* controls and before the `toolbar-end` slot: a button, a menu button (with
|
|
131
|
+
* `items`) or an item that cannot act (`disabled` with its `reason`). Choosing
|
|
132
|
+
* one fires `opengrid-toolbar-action`. Checked like `set_columns`: a problem
|
|
133
|
+
* is said in the status line and none of the call is applied. Shown with the
|
|
134
|
+
* `toolbar` attribute. The grid only.
|
|
135
|
+
*/
|
|
136
|
+
set_toolbar(host: HTMLElement, items: ToolbarItem[]): void;
|
|
121
137
|
/**
|
|
122
138
|
* What became of a row the reader added (issue #183), by the `provisionalKey`
|
|
123
139
|
* `opengrid-row-add` gave. `saved` takes the record's `row-key` as `detail`
|
|
@@ -145,6 +161,17 @@ export interface OpengridModule {
|
|
|
145
161
|
* takes the panels away. Needs a `row-key`; not offered grouped or as a tree.
|
|
146
162
|
*/
|
|
147
163
|
set_detail_renderer(host: HTMLElement, renderer: DetailRenderer | null): void;
|
|
164
|
+
/**
|
|
165
|
+
* The page's presets (issue #532): named views the reader switches between in
|
|
166
|
+
* a segmented control in the toolbar — a `radiogroup`, one tab stop, the
|
|
167
|
+
* arrows choose. The first is the default; a preset without a `filter` shows
|
|
168
|
+
* every row. The chosen one is and-ed onto the page's `filter` and the
|
|
169
|
+
* reader's in every query, is the view's `preset`, and is not a chip. A list
|
|
170
|
+
* that is refused is applied not at all, and said in the status line.
|
|
171
|
+
* `{ counts: true }` puts each preset's rows in its label, one query per
|
|
172
|
+
* preset. The grid only.
|
|
173
|
+
*/
|
|
174
|
+
set_presets(host: HTMLElement, presets: Preset[], options?: PresetOptions): void;
|
|
148
175
|
/**
|
|
149
176
|
* Runs the grid's query again over a source that changed, keeping the view,
|
|
150
177
|
* the focus by record, the selection by key and the history (issue #328).
|
|
@@ -185,6 +212,14 @@ export interface ConnectOptions {
|
|
|
185
212
|
onCellChange?: (detail: CellChangeDetail) => void;
|
|
186
213
|
/** `set_actions`: compared by value. The grid only. */
|
|
187
214
|
actions?: RowAction[];
|
|
215
|
+
/** `set_cell_actions`: compared by value. The grid only. */
|
|
216
|
+
cellActions?: CellAction[];
|
|
217
|
+
/** `set_toolbar`: compared by value. The grid only. */
|
|
218
|
+
toolbarItems?: ToolbarItem[];
|
|
219
|
+
/** `set_presets`: compared by value. The grid only. */
|
|
220
|
+
presets?: Preset[];
|
|
221
|
+
/** The second argument of `set_presets`, with `presets`. The grid only. */
|
|
222
|
+
presetOptions?: PresetOptions;
|
|
188
223
|
/** `set_cell_templates`: functions compare by identity, as in `formats`. The grid only. */
|
|
189
224
|
cellTemplates?: Record<string, CellTemplate>;
|
|
190
225
|
/** `set_detail_renderer`: compared by identity. The grid only. */
|
|
@@ -202,6 +237,8 @@ export interface ConnectOptions {
|
|
|
202
237
|
onPaste?: (detail: PasteDetail) => void;
|
|
203
238
|
onBulkChange?: (detail: BulkChangeDetail) => void;
|
|
204
239
|
onRowAction?: (detail: RowActionDetail) => void;
|
|
240
|
+
onCellAction?: (detail: CellActionDetail) => void;
|
|
241
|
+
onToolbarAction?: (detail: ToolbarActionDetail) => void;
|
|
205
242
|
/** A value of a pivot with `drill-down` was pressed. The pivot only. */
|
|
206
243
|
onDrillDown?: (detail: DrillDownDetail) => void;
|
|
207
244
|
/** The provider loaded the grid's source again (`loadRows`); the grid asks anew. */
|
|
@@ -274,6 +311,33 @@ export function connect(
|
|
|
274
311
|
*/
|
|
275
312
|
export function inferSchema(rows: readonly Record<string, unknown>[]): string;
|
|
276
313
|
|
|
314
|
+
export interface SuggestColumnsOptions {
|
|
315
|
+
/** The field that names a row. It is read-only, monospaced, muted and narrow. */
|
|
316
|
+
rowKey?: string;
|
|
317
|
+
/**
|
|
318
|
+
* How many distinct values each field has, where the caller knows. The function never counts: a
|
|
319
|
+
* field with at most 12 values and a count here gets a `list` facet.
|
|
320
|
+
*/
|
|
321
|
+
distinct?: Record<string, number>;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/** What {@link suggestColumns} suggests: what `set_columns` and `set_formats` take. */
|
|
325
|
+
export interface ColumnSuggestions {
|
|
326
|
+
columns: Columns;
|
|
327
|
+
formats: Formats;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* What the schema suggests for how the columns look, in the two objects a page hands to
|
|
332
|
+
* `set_columns` and `set_formats` — to log, change and pass on. The key field: read-only, mono,
|
|
333
|
+
* muted, narrow. An integer or a decimal: `align: "end"` and `aggregate: "sum"`; a float: `align:
|
|
334
|
+
* "end"`. A date: a `date` format. A text or an integer with at most 12 distinct values (`distinct`
|
|
335
|
+
* says how many, it is never counted): `facet: "list"`. A field no rule fits is left out. Throws
|
|
336
|
+
* an `Error` for a schema that is not the JSON text of `{ fields }`, a `rowKey` or `distinct` name
|
|
337
|
+
* the schema does not have, and a count that is not a whole number.
|
|
338
|
+
*/
|
|
339
|
+
export function suggestColumns(schema: string, options?: SuggestColumnsOptions): ColumnSuggestions;
|
|
340
|
+
|
|
277
341
|
export interface FromRowsOptions {
|
|
278
342
|
/** The schema JSON; wins over inference. */
|
|
279
343
|
schema?: string;
|
|
@@ -332,6 +396,15 @@ export interface Provider {
|
|
|
332
396
|
* it. A provider without it is shown with the count alone.
|
|
333
397
|
*/
|
|
334
398
|
kind?: ProviderKind;
|
|
399
|
+
/**
|
|
400
|
+
* Optional: what the source `source` is (issue #528) — `{ name, schema }`, the
|
|
401
|
+
* schema being the source's own, with the `from` of a derived field. The grid
|
|
402
|
+
* asks it once per `datasource` (again when the source is replaced) to learn
|
|
403
|
+
* which fields are derived; they are read-only. Every built-in provider has
|
|
404
|
+
* it — the REST one for its one source — and a provider without it keeps every
|
|
405
|
+
* field as the result's schema says.
|
|
406
|
+
*/
|
|
407
|
+
describe?(source: string): Promise<SourceDescription>;
|
|
335
408
|
/**
|
|
336
409
|
* Optional: the whole export of `query` in one go. `exportRows` uses it when
|
|
337
410
|
* it is there instead of fetching pieces over `execute` —
|
|
@@ -386,6 +459,12 @@ export interface EngineProvider extends Provider {
|
|
|
386
459
|
* A grid on the name answers its next query with an unknown source.
|
|
387
460
|
*/
|
|
388
461
|
unload(name: string): Promise<boolean>;
|
|
462
|
+
/**
|
|
463
|
+
* What the source `name` is (issue #528): `{ name, schema }`, the schema as the
|
|
464
|
+
* source was loaded with it, with the `from` of a derived field. Rejects for a
|
|
465
|
+
* source that is not loaded.
|
|
466
|
+
*/
|
|
467
|
+
describe(name: string): Promise<SourceDescription>;
|
|
389
468
|
/** What the engine holds: its memory and each source's size (issue #70). */
|
|
390
469
|
stats(): Promise<EngineStats>;
|
|
391
470
|
/** Stops a worker; a no-op in the tab. */
|
|
@@ -425,6 +504,8 @@ export interface Engine {
|
|
|
425
504
|
set_collator(sortKeys: (locale: string, texts: Uint8Array, ends: Uint32Array) => Uint8Array): void;
|
|
426
505
|
/** Frees the source `name`; whether there was one (issue #459). */
|
|
427
506
|
unload(name: string): boolean;
|
|
507
|
+
/** The schema of the source `name`, as JSON, with the `from` of a derived field (issue #528). */
|
|
508
|
+
describe(name: string): string;
|
|
428
509
|
/** What it holds, as JSON (see `EngineStats`). */
|
|
429
510
|
stats(): string;
|
|
430
511
|
/** A pivot over the engine's sources, as JSON (issue #28). */
|
|
@@ -442,9 +523,12 @@ export interface Engine {
|
|
|
442
523
|
/** What a server says a source is. */
|
|
443
524
|
export interface SourceDescription {
|
|
444
525
|
name: string;
|
|
526
|
+
/** The source's schema, `{ fields: [{ name, type, nullable, from? }] }`. */
|
|
445
527
|
schema: unknown;
|
|
446
|
-
|
|
447
|
-
|
|
528
|
+
/** Only a server says it. */
|
|
529
|
+
capabilities?: unknown;
|
|
530
|
+
/** Only a server says it. */
|
|
531
|
+
pivot_limits?: unknown;
|
|
448
532
|
}
|
|
449
533
|
|
|
450
534
|
export interface RestProvider extends Provider {
|
|
@@ -784,6 +868,12 @@ export interface ColumnConfig {
|
|
|
784
868
|
* (`Alt`+`Shift`+`←`/`→` on the header, the column menu). The grid only.
|
|
785
869
|
*/
|
|
786
870
|
pin?: Pin;
|
|
871
|
+
/**
|
|
872
|
+
* Pins the column only while the grid is narrower than 560 px; `none` keeps
|
|
873
|
+
* the `row-key` column from being pinned there by default. `pin` leads: it
|
|
874
|
+
* pins at every width. The grid only.
|
|
875
|
+
*/
|
|
876
|
+
pinNarrow?: Pin | "none";
|
|
787
877
|
/**
|
|
788
878
|
* The band the column stands under: a header it shares with the other
|
|
789
879
|
* columns that name the same one. A band is always in one piece — its
|
|
@@ -798,10 +888,20 @@ export interface ColumnConfig {
|
|
|
798
888
|
aggregate?: Aggregate;
|
|
799
889
|
facet?: FacetKind;
|
|
800
890
|
/**
|
|
801
|
-
*
|
|
802
|
-
* its cells are announced as read-only.
|
|
891
|
+
* `true`: the page fills this column (`set_values`): it never opens an
|
|
892
|
+
* editor and its cells are announced as read-only. `false`: opens the
|
|
893
|
+
* `row-key` column, read-only by default, for editing. The grid only.
|
|
803
894
|
*/
|
|
804
895
|
readonly?: boolean;
|
|
896
|
+
/**
|
|
897
|
+
* The page means this column to be edited: its cells are tinted
|
|
898
|
+
* (`--og-editable`) and, on a touch screen, its header shows a pencil. As
|
|
899
|
+
* soon as one column is marked, **only the marked columns edit** — a column
|
|
900
|
+
* opened with `readonly: false` counts as marked; where none is marked,
|
|
901
|
+
* every column not read-only can be edited. Contradicts `readonly: true`
|
|
902
|
+
* and a derived field. The grid only.
|
|
903
|
+
*/
|
|
904
|
+
editable?: boolean;
|
|
805
905
|
/**
|
|
806
906
|
* The labels of the keys the column stores, key → label: the cell, the
|
|
807
907
|
* editor, the filter row and the facets show and choose by label. The value
|
|
@@ -810,6 +910,14 @@ export interface ColumnConfig {
|
|
|
810
910
|
* `int64` column. The grid only.
|
|
811
911
|
*/
|
|
812
912
|
lookup?: Record<string | number, string>;
|
|
913
|
+
/**
|
|
914
|
+
* The places of an `int64` column that stores its value × 10^scale — money as
|
|
915
|
+
* cents, `2`: a reader reads and types `6,12` where the column stores `612`.
|
|
916
|
+
* What the page and the wire see — the query, events, the view, exports — is
|
|
917
|
+
* the stored integer. A whole number from 0 to 18; for an `int64` column. A
|
|
918
|
+
* table shows it scaled too; the pivot ignores it.
|
|
919
|
+
*/
|
|
920
|
+
scale?: number;
|
|
813
921
|
}
|
|
814
922
|
|
|
815
923
|
/** What `set_cell_state` says became of an edit. */
|
|
@@ -908,6 +1016,11 @@ export interface View {
|
|
|
908
1016
|
* away. Leads over `set_columns`.
|
|
909
1017
|
*/
|
|
910
1018
|
pinned: Record<string, Pin | "none">;
|
|
1019
|
+
/**
|
|
1020
|
+
* The reader's pins for narrow grids (the column menu's *Only on narrow
|
|
1021
|
+
* screens*): `none` keeps a column from being pinned there.
|
|
1022
|
+
*/
|
|
1023
|
+
pinnedNarrow: Record<string, Pin | "none">;
|
|
911
1024
|
};
|
|
912
1025
|
density: Density;
|
|
913
1026
|
group: string[];
|
|
@@ -917,6 +1030,8 @@ export interface View {
|
|
|
917
1030
|
aggregates: Record<string, Aggregate>;
|
|
918
1031
|
/** Whether the filter row shows. */
|
|
919
1032
|
filterRow: boolean;
|
|
1033
|
+
/** The columns the reader locked against editing; never beyond what the page allows. */
|
|
1034
|
+
locked: string[];
|
|
920
1035
|
facets: Record<string, FacetSelection>;
|
|
921
1036
|
/**
|
|
922
1037
|
* The keys of the selected records, where the grid selects by key (`row-key`,
|
|
@@ -936,6 +1051,12 @@ export interface View {
|
|
|
936
1051
|
* there is none; a view without the field has none.
|
|
937
1052
|
*/
|
|
938
1053
|
where?: ViewFilter;
|
|
1054
|
+
/**
|
|
1055
|
+
* The id of the page's preset (`set_presets`) the reader chose. Left out
|
|
1056
|
+
* where the page has none; a view without the field has the first, the
|
|
1057
|
+
* default. `set_view` refuses an id the page has no preset of.
|
|
1058
|
+
*/
|
|
1059
|
+
preset?: string;
|
|
939
1060
|
}
|
|
940
1061
|
|
|
941
1062
|
/**
|
|
@@ -1064,6 +1185,14 @@ export type TextKey =
|
|
|
1064
1185
|
| "aggregateMax"
|
|
1065
1186
|
| "aggregateRange"
|
|
1066
1187
|
| "columnMenu"
|
|
1188
|
+
| "cellMenu"
|
|
1189
|
+
| "cellEdit"
|
|
1190
|
+
| "cellCopy"
|
|
1191
|
+
| "cellCopied"
|
|
1192
|
+
| "cellSelectRow"
|
|
1193
|
+
| "cellDeselectRow"
|
|
1194
|
+
| "cellOpenRecord"
|
|
1195
|
+
| "cellColumnMenu"
|
|
1067
1196
|
| "sortAscending"
|
|
1068
1197
|
| "sortDescending"
|
|
1069
1198
|
| "sortKey"
|
|
@@ -1080,7 +1209,9 @@ export type TextKey =
|
|
|
1080
1209
|
| "pinNone"
|
|
1081
1210
|
| "pinStart"
|
|
1082
1211
|
| "pinEnd"
|
|
1212
|
+
| "pinNarrow"
|
|
1083
1213
|
| "toolbarGroup"
|
|
1214
|
+
| "toolbarRefused"
|
|
1084
1215
|
| "filterRowToggle"
|
|
1085
1216
|
| "densityGroup"
|
|
1086
1217
|
| "densityCompact"
|
|
@@ -1131,6 +1262,7 @@ export type TextKey =
|
|
|
1131
1262
|
| "shareOfTotal"
|
|
1132
1263
|
| "runningTotal"
|
|
1133
1264
|
| "treeContext"
|
|
1265
|
+
| "rowMuted"
|
|
1134
1266
|
| "subtreeCell"
|
|
1135
1267
|
| "subtreeOnly"
|
|
1136
1268
|
| "treeOrphans"
|
|
@@ -1176,11 +1308,19 @@ export type TextKey =
|
|
|
1176
1308
|
| "filterBuilderAddGroup"
|
|
1177
1309
|
| "filterBuilderEdit"
|
|
1178
1310
|
| "filterApplied"
|
|
1311
|
+
| "presetsGroup"
|
|
1312
|
+
| "presetChosen"
|
|
1313
|
+
| "presetCount"
|
|
1179
1314
|
| "emptyFiltered"
|
|
1315
|
+
| "emptyPreset"
|
|
1180
1316
|
| "emptySource"
|
|
1181
1317
|
| "emptyReset"
|
|
1182
1318
|
| "filterInvalid"
|
|
1183
1319
|
| "cellRequired"
|
|
1320
|
+
| "numberInvalid"
|
|
1321
|
+
| "integerInvalid"
|
|
1322
|
+
| "numberDecimals"
|
|
1323
|
+
| "numberTooLarge"
|
|
1184
1324
|
| "selectionCleared"
|
|
1185
1325
|
| "selectionMissing"
|
|
1186
1326
|
| "columnWidth"
|
|
@@ -1189,6 +1329,7 @@ export type TextKey =
|
|
|
1189
1329
|
| "columnPinnedStart"
|
|
1190
1330
|
| "columnPinnedEnd"
|
|
1191
1331
|
| "columnUnpinned"
|
|
1332
|
+
| "columnPinnedNarrow"
|
|
1192
1333
|
| "pinsReleased"
|
|
1193
1334
|
| "columnHidden"
|
|
1194
1335
|
| "columnShown"
|
|
@@ -1219,6 +1360,14 @@ export type TextKey =
|
|
|
1219
1360
|
| "bulkMenu"
|
|
1220
1361
|
| "bulkReadonly"
|
|
1221
1362
|
| "editLocked"
|
|
1363
|
+
| "editUnlocked"
|
|
1364
|
+
| "editToggle"
|
|
1365
|
+
| "lockColumn"
|
|
1366
|
+
| "unlockColumn"
|
|
1367
|
+
| "columnLocked"
|
|
1368
|
+
| "columnUnlocked"
|
|
1369
|
+
| "editHint"
|
|
1370
|
+
| "editLockedHint"
|
|
1222
1371
|
| "bulkDone"
|
|
1223
1372
|
| "validationWarning"
|
|
1224
1373
|
| "validationError"
|
|
@@ -1241,6 +1390,7 @@ export type TextKey =
|
|
|
1241
1390
|
| "recordDone"
|
|
1242
1391
|
| "recordNothing"
|
|
1243
1392
|
| "rangeSize"
|
|
1393
|
+
| "positionCell"
|
|
1244
1394
|
| "rangeCopied"
|
|
1245
1395
|
| "rangeUnloaded"
|
|
1246
1396
|
| "sourceChanged"
|
|
@@ -1367,6 +1517,72 @@ export interface RowActionDetail {
|
|
|
1367
1517
|
key?: WireValue;
|
|
1368
1518
|
}
|
|
1369
1519
|
|
|
1520
|
+
/** One preset of `set_presets`: a named view the page defines. */
|
|
1521
|
+
export interface Preset {
|
|
1522
|
+
/** What the view's `preset` names it by; unique in the list. */
|
|
1523
|
+
id: string;
|
|
1524
|
+
/** What the reader sees, and a screen reader says. */
|
|
1525
|
+
label: string;
|
|
1526
|
+
/** In the wire's notation, as the `filter` attribute; none shows every row. */
|
|
1527
|
+
filter?: Record<string, unknown> | null;
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
/** The second argument of `set_presets`. */
|
|
1531
|
+
export interface PresetOptions {
|
|
1532
|
+
/** Count the rows of every preset into its label: one query per preset. */
|
|
1533
|
+
counts?: boolean;
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
/** One of the page's items in the cell menu (`set_cell_actions`). */
|
|
1537
|
+
export interface CellAction {
|
|
1538
|
+
id: string;
|
|
1539
|
+
label: string;
|
|
1540
|
+
/** Offered on this column only; on every column without. */
|
|
1541
|
+
column?: string;
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
/** `opengrid-cell-action`: one of the page's items in the cell menu was chosen (issue #524). */
|
|
1545
|
+
export interface CellActionDetail {
|
|
1546
|
+
id: string;
|
|
1547
|
+
/** The row's position — in a grouped grid a display position; use `key`. */
|
|
1548
|
+
row: number;
|
|
1549
|
+
/** The cell's column, by field name. */
|
|
1550
|
+
column: string;
|
|
1551
|
+
/** With `row-key` only: the record's value of that field. */
|
|
1552
|
+
key?: WireValue;
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
/** One entry of a toolbar menu (`set_toolbar`). */
|
|
1556
|
+
export interface ToolbarEntry {
|
|
1557
|
+
id: string;
|
|
1558
|
+
label: string;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
/** One of the page's items in the toolbar (`set_toolbar`). */
|
|
1562
|
+
export interface ToolbarItem {
|
|
1563
|
+
/** Unique within the call, entries included: it is what `opengrid-toolbar-action` names. */
|
|
1564
|
+
id: string;
|
|
1565
|
+
/** The visible text and the accessible name. */
|
|
1566
|
+
label: string;
|
|
1567
|
+
/** With entries it is a menu button; choosing an entry fires the event with the entry's `id`. */
|
|
1568
|
+
items?: ToolbarEntry[];
|
|
1569
|
+
/** The item cannot act; `reason` says why, on focus and on activation. */
|
|
1570
|
+
disabled?: boolean;
|
|
1571
|
+
/** Needed with `disabled: true`, and only then. */
|
|
1572
|
+
reason?: string;
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
/** `opengrid-toolbar-action`: one of the page's items in the toolbar was chosen (issue #531). */
|
|
1576
|
+
export interface ToolbarActionDetail {
|
|
1577
|
+
id: string;
|
|
1578
|
+
/**
|
|
1579
|
+
* The selection as `opengrid-selection-change` carries it now — by key
|
|
1580
|
+
* (`{ count, keys }`) in a grid with a `row-key` and in a tree, else by
|
|
1581
|
+
* position — so *Bulk change for the selected rows* needs no second call.
|
|
1582
|
+
*/
|
|
1583
|
+
selection: SelectionChangeDetail;
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1370
1586
|
/**
|
|
1371
1587
|
* `opengrid-drill-down`: a value of an `<opengrid-pivot>` with `drill-down`
|
|
1372
1588
|
* was pressed (issue #330). The page shows the rows.
|
|
@@ -1495,6 +1711,8 @@ export interface OpengridEventMap {
|
|
|
1495
1711
|
"opengrid-view-change": CustomEvent<ViewChangeDetail>;
|
|
1496
1712
|
"opengrid-query": CustomEvent<QueryDetail>;
|
|
1497
1713
|
"opengrid-row-action": CustomEvent<RowActionDetail>;
|
|
1714
|
+
"opengrid-cell-action": CustomEvent<CellActionDetail>;
|
|
1715
|
+
"opengrid-toolbar-action": CustomEvent<ToolbarActionDetail>;
|
|
1498
1716
|
"opengrid-row-add": CustomEvent<RowAddDetail>;
|
|
1499
1717
|
"opengrid-paste": CustomEvent<PasteDetail>;
|
|
1500
1718
|
"opengrid-bulk-change": CustomEvent<BulkChangeDetail>;
|
|
@@ -1543,6 +1761,8 @@ export interface OpengridGridAttributes {
|
|
|
1543
1761
|
"tree-key"?: string;
|
|
1544
1762
|
/** The field that names a record: `key` in `opengrid-cell-change`. */
|
|
1545
1763
|
"row-key"?: string;
|
|
1764
|
+
/** The boolean field that mutes a row: a row whose value is `true` is drawn in the muted ink, has the part `row-muted` and is described with the text `rowMuted`. */
|
|
1765
|
+
"row-muted"?: string;
|
|
1546
1766
|
search?: string;
|
|
1547
1767
|
facets?: string;
|
|
1548
1768
|
toolbar?: string;
|
|
@@ -1553,6 +1773,10 @@ export interface OpengridGridAttributes {
|
|
|
1553
1773
|
"add-row"?: string;
|
|
1554
1774
|
/** Locks editing for the whole grid: no editor, paste, bulk set, record form, new row or undo. Remove it to unlock. */
|
|
1555
1775
|
"edit-locked"?: string;
|
|
1776
|
+
/** An *Edit* switch in the toolbar that sets and removes `edit-locked`. Needs `toolbar`. */
|
|
1777
|
+
"edit-toggle"?: string;
|
|
1778
|
+
/** `down`: `Enter` that commits an editor moves the focus to the next data row (`Shift`+`Enter`: the previous one). A page setting, not part of the view. */
|
|
1779
|
+
"enter-moves"?: string;
|
|
1556
1780
|
selection?: string;
|
|
1557
1781
|
density?: Density;
|
|
1558
1782
|
/** One of the built-in looks; Base when absent. */
|
package/loader.js
CHANGED
|
@@ -295,6 +295,16 @@ export function createWorkerProvider({
|
|
|
295
295
|
return request({ type: "unload", name });
|
|
296
296
|
},
|
|
297
297
|
|
|
298
|
+
/**
|
|
299
|
+
* What the source `name` is (issue #528): `{ name, schema }`, the schema as the
|
|
300
|
+
* source has it, with the `from` of a derived field — a result never says. A
|
|
301
|
+
* grid asks it once per `datasource`. Rejects for a source that is not loaded.
|
|
302
|
+
*/
|
|
303
|
+
async describe(name) {
|
|
304
|
+
await start();
|
|
305
|
+
return { name, schema: JSON.parse(await request({ type: "describe", name })) };
|
|
306
|
+
},
|
|
307
|
+
|
|
298
308
|
/**
|
|
299
309
|
* What the engine in the worker holds (issue #70): its WASM memory and,
|
|
300
310
|
* per source, rows, columns and bytes.
|
|
@@ -817,6 +827,10 @@ export function createLocalProvider(engine) {
|
|
|
817
827
|
async unload(name) {
|
|
818
828
|
return engine.unload(name);
|
|
819
829
|
},
|
|
830
|
+
/** What the source `name` is (issue #528), as the worker provider says it. */
|
|
831
|
+
async describe(name) {
|
|
832
|
+
return { name, schema: JSON.parse(engine.describe(name)) };
|
|
833
|
+
},
|
|
820
834
|
/** What the engine holds (issue #70), as the worker provider says it. */
|
|
821
835
|
async stats() {
|
|
822
836
|
return { kind: "local", ...JSON.parse(engine.stats()) };
|
|
@@ -884,7 +898,9 @@ export function createRestProvider({ url, source, token, watch = false } = {}) {
|
|
|
884
898
|
/** Where the queries run; the grid names it in its footer (issue #33). */
|
|
885
899
|
kind: "remote",
|
|
886
900
|
/**
|
|
887
|
-
* What the server says this source is: `{ name, schema, capabilities }`.
|
|
901
|
+
* What the server says this source is: `{ name, schema, capabilities }`. A
|
|
902
|
+
* grid asks it for the derived fields of its source (issue #528); the
|
|
903
|
+
* provider is for one source, so an argument is ignored.
|
|
888
904
|
*
|
|
889
905
|
* A planner needs both halves before it can split anything — the
|
|
890
906
|
* schema to validate against, the capabilities to know what may be pushed.
|
|
@@ -1244,6 +1260,8 @@ export function createHybridProvider({ remote, planner, mode = "auto", onPlan }
|
|
|
1244
1260
|
return {
|
|
1245
1261
|
/** Where the queries run; the grid names it in its footer (issue #33). */
|
|
1246
1262
|
kind: "hybrid",
|
|
1263
|
+
// What the source is, where the remote half can say (issue #528).
|
|
1264
|
+
...(typeof remote?.describe === "function" ? { describe: (source) => remote.describe(source) } : {}),
|
|
1247
1265
|
async execute(queryJson, elementMode, { signal } = {}) {
|
|
1248
1266
|
// The element's attribute wins when it has one: the page sets the default,
|
|
1249
1267
|
// the markup can override it per grid.
|
|
@@ -1727,7 +1745,7 @@ function aborted() {
|
|
|
1727
1745
|
*
|
|
1728
1746
|
* `update` applies only what changed. A key left out of an update keeps its
|
|
1729
1747
|
* value; a key given as `undefined` resets it (texts to English, no formats, no
|
|
1730
|
-
* presentation, no choices, no actions, no validators) — except `provider`,
|
|
1748
|
+
* presentation, no choices, no actions, no presets, no validators) — except `provider`,
|
|
1731
1749
|
* which has no "none", and `view`, where `undefined` (or `null`) means the grid leads. Attributes
|
|
1732
1750
|
* (`label`, `columns`, `group-by`, …) are not options: the page or the
|
|
1733
1751
|
* framework sets them on the element as usual.
|
|
@@ -1788,6 +1806,8 @@ export function connect(host, options = {}) {
|
|
|
1788
1806
|
["opengrid-paste", (event) => current.onPaste?.(event.detail)],
|
|
1789
1807
|
["opengrid-bulk-change", (event) => current.onBulkChange?.(event.detail)],
|
|
1790
1808
|
["opengrid-row-action", (event) => current.onRowAction?.(event.detail)],
|
|
1809
|
+
["opengrid-cell-action", (event) => current.onCellAction?.(event.detail)],
|
|
1810
|
+
["opengrid-toolbar-action", (event) => current.onToolbarAction?.(event.detail)],
|
|
1791
1811
|
["opengrid-drill-down", (event) => current.onDrillDown?.(event.detail)],
|
|
1792
1812
|
["opengrid-source-replaced", (event) => current.onSourceReplaced?.(event.detail)],
|
|
1793
1813
|
];
|
|
@@ -1907,6 +1927,25 @@ export function connect(host, options = {}) {
|
|
|
1907
1927
|
const actions = changed.actions ?? [];
|
|
1908
1928
|
write("actions", actions, stableKey(actions), (value) => module.set_actions(host, value));
|
|
1909
1929
|
}
|
|
1930
|
+
if ("cellActions" in changed) {
|
|
1931
|
+
const cellActions = changed.cellActions ?? [];
|
|
1932
|
+
write("cellActions", cellActions, stableKey(cellActions), (value) =>
|
|
1933
|
+
module.set_cell_actions(host, value),
|
|
1934
|
+
);
|
|
1935
|
+
}
|
|
1936
|
+
if ("toolbarItems" in changed) {
|
|
1937
|
+
const toolbarItems = changed.toolbarItems ?? [];
|
|
1938
|
+
write("toolbarItems", toolbarItems, stableKey(toolbarItems), (value) =>
|
|
1939
|
+
module.set_toolbar(host, value),
|
|
1940
|
+
);
|
|
1941
|
+
}
|
|
1942
|
+
if ("presets" in changed || "presetOptions" in changed) {
|
|
1943
|
+
const presets = current.presets ?? [];
|
|
1944
|
+
const presetOptions = current.presetOptions ?? {};
|
|
1945
|
+
write("presets", presets, stableKey({ presets, presetOptions }), (value) =>
|
|
1946
|
+
module.set_presets(host, value, presetOptions),
|
|
1947
|
+
);
|
|
1948
|
+
}
|
|
1910
1949
|
if ("cellTemplates" in changed) {
|
|
1911
1950
|
const cellTemplates = changed.cellTemplates ?? {};
|
|
1912
1951
|
write("cellTemplates", cellTemplates, identityKey(cellTemplates), (value) =>
|
|
@@ -2104,6 +2143,70 @@ export function inferSchema(rows) {
|
|
|
2104
2143
|
return JSON.stringify({ fields: schema });
|
|
2105
2144
|
}
|
|
2106
2145
|
|
|
2146
|
+
/** Up to this many distinct values a column is offered as a list facet. */
|
|
2147
|
+
const FACET_LIST_MAX = 12;
|
|
2148
|
+
|
|
2149
|
+
/**
|
|
2150
|
+
* What the schema suggests for how the columns look, as the two objects a page hands to
|
|
2151
|
+
* `set_columns` and `set_formats` — a plain function, so the page can log the result, change it and
|
|
2152
|
+
* pass it on; the grid guesses nothing of its own. The rules, field by field:
|
|
2153
|
+
*
|
|
2154
|
+
* - the `rowKey` field: read-only, monospaced, muted and narrow; nothing else;
|
|
2155
|
+
* - an integer or a decimal: aligned at the end and summed in groups; a float: aligned at the end;
|
|
2156
|
+
* - a date: a `date` format, in the locale of the page;
|
|
2157
|
+
* - a text or an integer with at most 12 distinct values — `distinct` says how many each field has,
|
|
2158
|
+
* the function never counts — a `list` facet.
|
|
2159
|
+
*
|
|
2160
|
+
* A field no rule fits is left out. It throws a plain `Error` for what is wrong with the call: a
|
|
2161
|
+
* schema that is not the JSON text of `{ fields }`, a `rowKey` or a `distinct` name the schema does
|
|
2162
|
+
* not have, a count that is not a whole number.
|
|
2163
|
+
*
|
|
2164
|
+
* @param {string} schema the schema JSON, as `inferSchema` writes it and `loadRows` takes it.
|
|
2165
|
+
* @param {{ rowKey?: string, distinct?: Record<string, number> }} [options]
|
|
2166
|
+
* @returns {{ columns: Record<string, object>, formats: Record<string, object> }}
|
|
2167
|
+
*/
|
|
2168
|
+
export function suggestColumns(schema, options = {}) {
|
|
2169
|
+
let fields;
|
|
2170
|
+
try {
|
|
2171
|
+
fields = JSON.parse(schema)?.fields;
|
|
2172
|
+
} catch {
|
|
2173
|
+
fields = undefined;
|
|
2174
|
+
}
|
|
2175
|
+
if (!Array.isArray(fields)) {
|
|
2176
|
+
throw new Error("suggestColumns: the schema is not the JSON text of { fields: [...] }");
|
|
2177
|
+
}
|
|
2178
|
+
const { rowKey, distinct = {} } = options;
|
|
2179
|
+
const names = new Set(fields.map((field) => field?.name));
|
|
2180
|
+
if (rowKey !== undefined && !names.has(rowKey)) {
|
|
2181
|
+
throw new Error(`suggestColumns: rowKey ${rowKey} is not a field of the schema`);
|
|
2182
|
+
}
|
|
2183
|
+
for (const [name, count] of Object.entries(distinct)) {
|
|
2184
|
+
if (!names.has(name)) {
|
|
2185
|
+
throw new Error(`suggestColumns: distinct names ${name}, which is not a field of the schema`);
|
|
2186
|
+
}
|
|
2187
|
+
if (!Number.isInteger(count) || count < 0) {
|
|
2188
|
+
throw new Error(`suggestColumns: distinct ${name} is ${count}, not a count of values`);
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
const columns = {};
|
|
2192
|
+
const formats = {};
|
|
2193
|
+
for (const { name, type } of fields) {
|
|
2194
|
+
const few = distinct[name] <= FACET_LIST_MAX; // false where no count was handed in
|
|
2195
|
+
if (name === rowKey) {
|
|
2196
|
+
columns[name] = { readonly: true, mono: true, muted: true, width: 96 };
|
|
2197
|
+
} else if (type === "int64" || type?.decimal) {
|
|
2198
|
+
columns[name] = { align: "end", aggregate: "sum", ...(few && type === "int64" ? { facet: "list" } : {}) };
|
|
2199
|
+
} else if (type === "float64") {
|
|
2200
|
+
columns[name] = { align: "end" };
|
|
2201
|
+
} else if (type === "date") {
|
|
2202
|
+
formats[name] = { kind: "date" };
|
|
2203
|
+
} else if (type === "utf8" && few) {
|
|
2204
|
+
columns[name] = { facet: "list" };
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
return { columns, formats };
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2107
2210
|
/**
|
|
2108
2211
|
* Rows to a table in one call: the schema (`schema`, or `inferSchema(rows)`), a provider (the
|
|
2109
2212
|
* worker, unless `provider` is given), the rows loaded into it, and the element connected.
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@casoon/opengrid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Accessible data grid, table and pivot as web components, driven by a portable Rust/WASM query engine — with React, Vue and
|
|
5
|
+
"description": "Accessible data grid, table and pivot as web components, driven by a portable Rust/WASM query engine — with React, Vue, Svelte and Solid components.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"datagrid",
|
|
8
8
|
"pivot",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"wasm",
|
|
12
12
|
"react",
|
|
13
13
|
"vue",
|
|
14
|
-
"svelte"
|
|
14
|
+
"svelte",
|
|
15
|
+
"solid"
|
|
15
16
|
],
|
|
16
17
|
"license": "MIT OR Apache-2.0",
|
|
17
18
|
"repository": {
|
|
@@ -44,6 +45,10 @@
|
|
|
44
45
|
"svelte": "./svelte/index.js",
|
|
45
46
|
"default": "./svelte/index.js"
|
|
46
47
|
},
|
|
48
|
+
"./solid": {
|
|
49
|
+
"types": "./solid/index.d.ts",
|
|
50
|
+
"default": "./solid/index.js"
|
|
51
|
+
},
|
|
47
52
|
"./texts/de": {
|
|
48
53
|
"types": "./texts/de.d.ts",
|
|
49
54
|
"default": "./texts/de.js"
|
|
@@ -68,6 +73,7 @@
|
|
|
68
73
|
"react/",
|
|
69
74
|
"vue/",
|
|
70
75
|
"svelte/",
|
|
76
|
+
"solid/",
|
|
71
77
|
"texts/",
|
|
72
78
|
"pkg/",
|
|
73
79
|
"engine/",
|
|
@@ -79,18 +85,26 @@
|
|
|
79
85
|
"CHANGELOG.md"
|
|
80
86
|
],
|
|
81
87
|
"peerDependencies": {
|
|
88
|
+
"@solidjs/web": "^2.0.0",
|
|
82
89
|
"@types/react": ">=18.3.0",
|
|
83
90
|
"react": ">=18",
|
|
91
|
+
"solid-js": "^2.0.0",
|
|
84
92
|
"svelte": "^5.0.0",
|
|
85
93
|
"vue": ">=3.4.20"
|
|
86
94
|
},
|
|
87
95
|
"peerDependenciesMeta": {
|
|
96
|
+
"@solidjs/web": {
|
|
97
|
+
"optional": true
|
|
98
|
+
},
|
|
88
99
|
"@types/react": {
|
|
89
100
|
"optional": true
|
|
90
101
|
},
|
|
91
102
|
"react": {
|
|
92
103
|
"optional": true
|
|
93
104
|
},
|
|
105
|
+
"solid-js": {
|
|
106
|
+
"optional": true
|
|
107
|
+
},
|
|
94
108
|
"svelte": {
|
|
95
109
|
"optional": true
|
|
96
110
|
},
|
|
@@ -99,7 +113,9 @@
|
|
|
99
113
|
}
|
|
100
114
|
},
|
|
101
115
|
"devDependencies": {
|
|
116
|
+
"@solidjs/web": "2.0.4",
|
|
102
117
|
"@types/react": "19.3.0",
|
|
118
|
+
"solid-js": "2.0.4",
|
|
103
119
|
"svelte": "5.57.3",
|
|
104
120
|
"vue": "3.5.45"
|
|
105
121
|
},
|