@casoon/opengrid 0.13.0 → 0.15.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 +491 -18
- package/README.md +17 -2
- package/engine/opengrid_wasm.d.ts +9 -0
- package/engine/opengrid_wasm.js +22 -0
- package/engine/opengrid_wasm_bg.wasm +0 -0
- package/engine/opengrid_wasm_bg.wasm.d.ts +1 -0
- package/loader.d.ts +215 -11
- package/loader.js +183 -43
- package/package.json +6 -6
- package/pkg/opengrid_web_components.d.ts +61 -26
- package/pkg/opengrid_web_components.js +250 -60
- package/pkg/opengrid_web_components_bg.wasm +0 -0
- package/pkg/opengrid_web_components_bg.wasm.d.ts +11 -8
- package/pkg/snippets/opengrid-web-components-ef3def04de0cb619/inline0.js +8 -0
- package/pkg/snippets/opengrid-web-components-ef3def04de0cb619/inline1.js +58 -0
- package/pkg/snippets/opengrid-web-core-78fdded9b8a374ed/inline2.js +89 -0
- package/react/index.d.ts +12 -0
- package/react/index.js +24 -4
- package/svelte/Opengrid.svelte +39 -10
- package/svelte/OpengridGrid.svelte +15 -0
- package/svelte/index.d.ts +45 -16
- package/vue/index.d.ts +37 -5
- package/vue/index.js +33 -7
- package/worker.js +11 -1
- package/pkg/snippets/opengrid-web-components-ad6dc2c80732d2d3/inline0.js +0 -17
- /package/pkg/snippets/{opengrid-web-core-19b41f3fd18cf51f → opengrid-web-core-78fdded9b8a374ed}/inline0.js +0 -0
- /package/pkg/snippets/{opengrid-web-core-19b41f3fd18cf51f → opengrid-web-core-78fdded9b8a374ed}/inline1.js +0 -0
package/README.md
CHANGED
|
@@ -50,6 +50,21 @@ The package holds the elements and the query engine. With a bundler, import from
|
|
|
50
50
|
`@casoon/opengrid`; without one, see
|
|
51
51
|
[Installation](https://github.com/casoon/opengrid/blob/main/docs/getting-started/installation.mdx).
|
|
52
52
|
|
|
53
|
+
### Rust crates
|
|
54
|
+
|
|
55
|
+
The engine and the server are on crates.io, one crate per layer. They carry the same version
|
|
56
|
+
as the npm package, so give every `opengrid-*` crate the same one:
|
|
57
|
+
|
|
58
|
+
```toml
|
|
59
|
+
[dependencies]
|
|
60
|
+
opengrid-server = "0.15" # the gateway, as a library
|
|
61
|
+
opengrid-connector-sqlite = "0.15" # or opengrid-datasource-postgres
|
|
62
|
+
opengrid-engine = "0.15" # the engine alone, native
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
While the version is 0.x, a minor bump may break the Rust API
|
|
66
|
+
([releasing](https://github.com/casoon/opengrid/blob/main/docs/releasing.md)).
|
|
67
|
+
|
|
53
68
|
## Data in the browser
|
|
54
69
|
|
|
55
70
|
The engine reads a CSV against a schema — it never guesses types.
|
|
@@ -101,7 +116,7 @@ connect(document.querySelector("opengrid-grid"), {
|
|
|
101
116
|
});
|
|
102
117
|
```
|
|
103
118
|
|
|
104
|
-
See [Where queries run](https://github.com/casoon/opengrid/blob/main/docs/guides/where-queries-run.
|
|
119
|
+
See [Where queries run](https://github.com/casoon/opengrid/blob/main/docs/guides/where-queries-run.mdx).
|
|
105
120
|
|
|
106
121
|
## React, Vue, Svelte
|
|
107
122
|
|
|
@@ -160,7 +175,7 @@ shown with `get_pivot`. See [Export](https://github.com/casoon/opengrid/blob/mai
|
|
|
160
175
|
- [Guides](https://github.com/casoon/opengrid/tree/main/docs/guides) and the
|
|
161
176
|
[project page](https://casoon.github.io/opengrid/)
|
|
162
177
|
- [In a chat client](https://github.com/casoon/opengrid/blob/main/docs/guides/mcp.md) —
|
|
163
|
-
the grid as an MCP App, `@casoon/opengrid-mcp`
|
|
178
|
+
the grid as an MCP App, [`@casoon/opengrid-mcp`](https://www.npmjs.com/package/@casoon/opengrid-mcp)
|
|
164
179
|
|
|
165
180
|
## Accessible and machine-readable: the aim
|
|
166
181
|
|
|
@@ -34,6 +34,14 @@ export class Engine {
|
|
|
34
34
|
* (plan/spezifikation/04-local-engine.md §Ingest).
|
|
35
35
|
*/
|
|
36
36
|
load_csv(name: string, bytes: Uint8Array, schema_json: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Registers a source from rows the page already holds (issue #182): a
|
|
39
|
+
* JSON array of objects keyed by field name, values in the wire notation
|
|
40
|
+
* of E13. The schema is required, as for CSV. A name that is already
|
|
41
|
+
* loaded is **replaced** — all or nothing: a row that does not fit is
|
|
42
|
+
* refused with its row and field named, and the old source stays.
|
|
43
|
+
*/
|
|
44
|
+
load_rows(name: string, rows_json: string, schema_json: string): void;
|
|
37
45
|
/**
|
|
38
46
|
* An engine without data. `load_csv` adds sources.
|
|
39
47
|
*/
|
|
@@ -136,6 +144,7 @@ export interface InitOutput {
|
|
|
136
144
|
readonly engine_execute: (a: number, b: number, c: number) => [number, number, number, number];
|
|
137
145
|
readonly engine_execute_columns: (a: number, b: number, c: number) => [number, number, number, number];
|
|
138
146
|
readonly engine_load_csv: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
147
|
+
readonly engine_load_rows: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
139
148
|
readonly engine_new: () => number;
|
|
140
149
|
readonly engine_pivot: (a: number, b: number, c: number) => [number, number, number, number];
|
|
141
150
|
readonly engine_pivot_columns: (a: number, b: number, c: number) => [number, number, number, number];
|
package/engine/opengrid_wasm.js
CHANGED
|
@@ -88,6 +88,28 @@ export class Engine {
|
|
|
88
88
|
throw takeFromExternrefTable0(ret[0]);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Registers a source from rows the page already holds (issue #182): a
|
|
93
|
+
* JSON array of objects keyed by field name, values in the wire notation
|
|
94
|
+
* of E13. The schema is required, as for CSV. A name that is already
|
|
95
|
+
* loaded is **replaced** — all or nothing: a row that does not fit is
|
|
96
|
+
* refused with its row and field named, and the old source stays.
|
|
97
|
+
* @param {string} name
|
|
98
|
+
* @param {string} rows_json
|
|
99
|
+
* @param {string} schema_json
|
|
100
|
+
*/
|
|
101
|
+
load_rows(name, rows_json, schema_json) {
|
|
102
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
103
|
+
const len0 = WASM_VECTOR_LEN;
|
|
104
|
+
const ptr1 = passStringToWasm0(rows_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
105
|
+
const len1 = WASM_VECTOR_LEN;
|
|
106
|
+
const ptr2 = passStringToWasm0(schema_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
107
|
+
const len2 = WASM_VECTOR_LEN;
|
|
108
|
+
const ret = wasm.engine_load_rows(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
109
|
+
if (ret[1]) {
|
|
110
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
91
113
|
/**
|
|
92
114
|
* An engine without data. `load_csv` adds sources.
|
|
93
115
|
*/
|
|
Binary file
|
|
@@ -6,6 +6,7 @@ export const __wbg_planner_free: (a: number, b: number) => void;
|
|
|
6
6
|
export const engine_execute: (a: number, b: number, c: number) => [number, number, number, number];
|
|
7
7
|
export const engine_execute_columns: (a: number, b: number, c: number) => [number, number, number, number];
|
|
8
8
|
export const engine_load_csv: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
9
|
+
export const engine_load_rows: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
9
10
|
export const engine_new: () => number;
|
|
10
11
|
export const engine_pivot: (a: number, b: number, c: number) => [number, number, number, number];
|
|
11
12
|
export const engine_pivot_columns: (a: number, b: number, c: number) => [number, number, number, number];
|
package/loader.d.ts
CHANGED
|
@@ -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"] }`. */
|
|
@@ -96,6 +96,28 @@ export interface OpengridModule {
|
|
|
96
96
|
* Requires `row-key`.
|
|
97
97
|
*/
|
|
98
98
|
set_values(host: HTMLElement, values: CellValue[]): void;
|
|
99
|
+
/**
|
|
100
|
+
* Gives every row actions (issue #189): one trailing column each, a button per
|
|
101
|
+
* row. Click, or `Enter`/`Space` on the cell, fires `opengrid-row-action`.
|
|
102
|
+
* The label is the accessible name; group headers and the total have no button.
|
|
103
|
+
*/
|
|
104
|
+
set_actions(host: HTMLElement, actions: RowAction[]): void;
|
|
105
|
+
/**
|
|
106
|
+
* What became of a row the reader added (issue #183), by the `provisionalKey`
|
|
107
|
+
* `opengrid-row-add` gave. `saved` takes the record's `row-key` as `detail`
|
|
108
|
+
* when it has one now; `error` takes the message, said in the live region.
|
|
109
|
+
*/
|
|
110
|
+
set_row_state(
|
|
111
|
+
host: HTMLElement,
|
|
112
|
+
provisionalKey: string,
|
|
113
|
+
state: "saving" | "saved" | "error",
|
|
114
|
+
detail?: WireValue | string,
|
|
115
|
+
): void;
|
|
116
|
+
/**
|
|
117
|
+
* Validators that run while the reader types (issue #188). A function never
|
|
118
|
+
* blocks the commit; `{ validate, block: true }` blocks on an `error`.
|
|
119
|
+
*/
|
|
120
|
+
set_validators(host: HTMLElement, validators: Record<string, Validator | ValidatorRule>): void;
|
|
99
121
|
/** Defines the three elements. `loadOpengrid()` calls it. */
|
|
100
122
|
register(): void;
|
|
101
123
|
}
|
|
@@ -107,7 +129,7 @@ export interface OpengridModule {
|
|
|
107
129
|
/**
|
|
108
130
|
* What `connect` supplies an element with. Each is one module function —
|
|
109
131
|
* `presentation` is `set_columns`, named apart from the `columns` attribute —
|
|
110
|
-
* and the
|
|
132
|
+
* and the callbacks receive the event's `detail`.
|
|
111
133
|
*/
|
|
112
134
|
export interface ConnectOptions {
|
|
113
135
|
provider?: Provider;
|
|
@@ -129,6 +151,40 @@ export interface ConnectOptions {
|
|
|
129
151
|
onViewChange?: (view: View) => void;
|
|
130
152
|
onSelectionChange?: (detail: SelectionChangeDetail) => void;
|
|
131
153
|
onCellChange?: (detail: CellChangeDetail) => void;
|
|
154
|
+
/** `set_actions`: compared by value. The grid only. */
|
|
155
|
+
actions?: RowAction[];
|
|
156
|
+
/** `set_validators`: functions compare by identity, as in `formats`. The grid only. */
|
|
157
|
+
validators?: Record<string, Validator | ValidatorRule>;
|
|
158
|
+
/**
|
|
159
|
+
* The reader added a row (`add-row`). The answer is the row's state
|
|
160
|
+
* (`set_row_state`): a promise shows `saving` until it settles — resolved
|
|
161
|
+
* with nothing, the row is saved — a rejection is an `error` with its
|
|
162
|
+
* message, and no answer at all leaves the row to the page. Not answered
|
|
163
|
+
* for an undone add.
|
|
164
|
+
*/
|
|
165
|
+
onRowAdd?: (detail: RowAddDetail) => RowAnswer | Promise<RowAnswer | void> | void;
|
|
166
|
+
onPaste?: (detail: PasteDetail) => void;
|
|
167
|
+
onBulkChange?: (detail: BulkChangeDetail) => void;
|
|
168
|
+
onRowAction?: (detail: RowActionDetail) => void;
|
|
169
|
+
/** The provider loaded the grid's source again (`loadRows`); the grid asks anew. */
|
|
170
|
+
onSourceReplaced?: (detail: SourceReplacedDetail) => void;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** What `onRowAdd` says became of the row; `key` is its `row-key` now. */
|
|
174
|
+
export type RowAnswer =
|
|
175
|
+
| { state: "saving" }
|
|
176
|
+
| { state: "saved"; key?: WireValue }
|
|
177
|
+
| { state: "error"; message: string };
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* What a page writes into the grid's cells, on a {@link Connection} and on each
|
|
181
|
+
* component's ref. Both wait for the module. The grid only; both need `row-key`.
|
|
182
|
+
*/
|
|
183
|
+
export interface CellWrites {
|
|
184
|
+
/** `set_cell_state`: what became of an edit the page saves. */
|
|
185
|
+
setCellState(key: WireValue, column: string, state: CellState, message?: string): void;
|
|
186
|
+
/** `set_values`: values the page computes, in a `readonly` column. */
|
|
187
|
+
setValues(values: CellValue[]): void;
|
|
132
188
|
}
|
|
133
189
|
|
|
134
190
|
/** `connect`'s options for `<opengrid-pivot>`: its view is a {@link PivotView}. */
|
|
@@ -138,7 +194,7 @@ export type PivotConnectOptions = Omit<ConnectOptions, "view" | "defaultView" |
|
|
|
138
194
|
onViewChange?: (view: PivotView) => void;
|
|
139
195
|
};
|
|
140
196
|
|
|
141
|
-
export interface Connection<O = ConnectOptions> {
|
|
197
|
+
export interface Connection<O = ConnectOptions> extends CellWrites {
|
|
142
198
|
/** Settles once the module is loaded and the options are applied. */
|
|
143
199
|
ready: Promise<LoadResult>;
|
|
144
200
|
/**
|
|
@@ -217,6 +273,17 @@ export interface ExecuteOptions {
|
|
|
217
273
|
export interface EngineProvider extends Provider {
|
|
218
274
|
/** Loads CSV bytes as the source `name`, against a schema (JSON). */
|
|
219
275
|
load(name: string, bytes: ArrayBuffer | Uint8Array, schema: string): Promise<void>;
|
|
276
|
+
/**
|
|
277
|
+
* Loads rows the page already holds as the source `name` (issue #182): an
|
|
278
|
+
* array of objects keyed by field name — or that array as JSON text — with
|
|
279
|
+
* values in the wire notation of the result (decimals as strings, dates as
|
|
280
|
+
* `YYYY-MM-DD`). The schema stays required. A name that is already loaded is
|
|
281
|
+
* replaced, all or nothing; a grid on it re-runs its query and keeps its view.
|
|
282
|
+
* A value that does not fit its field rejects with the row and field named.
|
|
283
|
+
*/
|
|
284
|
+
loadRows(name: string, rows: readonly Record<string, unknown>[] | string, schema: string): Promise<void>;
|
|
285
|
+
/** Called by `set_provider`; the grid is told when a source it shows is replaced. */
|
|
286
|
+
watch(host: HTMLElement): void;
|
|
220
287
|
/** What the engine holds: its memory and each source's size (issue #70). */
|
|
221
288
|
stats(): Promise<EngineStats>;
|
|
222
289
|
/** Stops a worker; a no-op in the tab. */
|
|
@@ -235,6 +302,8 @@ export interface EngineStats {
|
|
|
235
302
|
/** The engine of the engine module, as `createLocalProvider` uses it. */
|
|
236
303
|
export interface Engine {
|
|
237
304
|
load_csv(name: string, bytes: Uint8Array, schema: string): void;
|
|
305
|
+
/** Rows as JSON text (an array of objects); replaces a source of that name (issue #182). */
|
|
306
|
+
load_rows(name: string, rowsJson: string, schema: string): void;
|
|
238
307
|
/** The result as JSON. */
|
|
239
308
|
execute(queryJson: string): string;
|
|
240
309
|
/** The result in the binary form — what the tab and worker providers answer. */
|
|
@@ -388,7 +457,7 @@ export function exportRows(provider: Provider, query: ViewQuery, options?: Expor
|
|
|
388
457
|
// ---------------------------------------------------------------------------
|
|
389
458
|
|
|
390
459
|
/**
|
|
391
|
-
* What went wrong, as a closed list a page can switch on. The first
|
|
460
|
+
* What went wrong, as a closed list a page can switch on. The first eight are
|
|
392
461
|
* the server's, from its error form; the last three are `exportRows`' own.
|
|
393
462
|
*/
|
|
394
463
|
export type ErrorCode =
|
|
@@ -399,6 +468,7 @@ export type ErrorCode =
|
|
|
399
468
|
| "unauthorized"
|
|
400
469
|
| "backend"
|
|
401
470
|
| "malformed"
|
|
471
|
+
| "data"
|
|
402
472
|
| "too_many_rows"
|
|
403
473
|
| "source_changed"
|
|
404
474
|
| "module_not_loaded";
|
|
@@ -465,7 +535,11 @@ export type FilterOperator =
|
|
|
465
535
|
| "contains"
|
|
466
536
|
| "starts_with"
|
|
467
537
|
| "is_null"
|
|
468
|
-
| "is_not_null"
|
|
538
|
+
| "is_not_null"
|
|
539
|
+
/** A list column holds the value / every value / nothing (issue #185). */
|
|
540
|
+
| "has"
|
|
541
|
+
| "has_all"
|
|
542
|
+
| "is_empty";
|
|
469
543
|
|
|
470
544
|
/** An aggregate in group rows and the grand total. */
|
|
471
545
|
export type Aggregate = "sum" | "avg" | "count" | "min" | "max" | "range";
|
|
@@ -500,7 +574,8 @@ export interface ColumnConfig {
|
|
|
500
574
|
}
|
|
501
575
|
|
|
502
576
|
/** What `set_cell_state` says became of an edit. */
|
|
503
|
-
|
|
577
|
+
/** `invalid`: a finding the page computed elsewhere; `message` is its sentence. */
|
|
578
|
+
export type CellState = "saving" | "saved" | "error" | "invalid";
|
|
504
579
|
|
|
505
580
|
/** One value for `set_values`: the record by its `row-key`, the column, the value. */
|
|
506
581
|
export interface CellValue {
|
|
@@ -519,7 +594,11 @@ export type Format =
|
|
|
519
594
|
|
|
520
595
|
export type Formats = Record<string, Format>;
|
|
521
596
|
|
|
522
|
-
|
|
597
|
+
/** One choice: a value, or a `{ value, label }` pair — the label is shown, the value is stored. */
|
|
598
|
+
export type Choice = string | number | { value: string | number; label?: string };
|
|
599
|
+
|
|
600
|
+
/** The choices of each column; a list column is edited only with them (issue #185). */
|
|
601
|
+
export type Choices = Record<string, Choice[]>;
|
|
523
602
|
|
|
524
603
|
// ---------------------------------------------------------------------------
|
|
525
604
|
// The view
|
|
@@ -689,6 +768,7 @@ export type TextKey =
|
|
|
689
768
|
| "columnMenu"
|
|
690
769
|
| "sortAscending"
|
|
691
770
|
| "sortDescending"
|
|
771
|
+
| "sortKey"
|
|
692
772
|
| "filterColumn"
|
|
693
773
|
| "aggregateGroup"
|
|
694
774
|
| "aggregateNone"
|
|
@@ -790,7 +870,41 @@ export type TextKey =
|
|
|
790
870
|
| "total"
|
|
791
871
|
| "subtotal"
|
|
792
872
|
| "noValue"
|
|
793
|
-
| "emptyValue"
|
|
873
|
+
| "emptyValue"
|
|
874
|
+
| "newRow"
|
|
875
|
+
| "rowAdded"
|
|
876
|
+
| "pastePreview"
|
|
877
|
+
| "pasteApply"
|
|
878
|
+
| "pasteDiscard"
|
|
879
|
+
| "pasteUnreadable"
|
|
880
|
+
| "pasteBadOne"
|
|
881
|
+
| "pasteBadOther"
|
|
882
|
+
| "pasteCutOff"
|
|
883
|
+
| "pasteApplied"
|
|
884
|
+
| "pasteDiscarded"
|
|
885
|
+
| "pasteBlocked"
|
|
886
|
+
| "bulkCaption"
|
|
887
|
+
| "bulkApply"
|
|
888
|
+
| "bulkMenu"
|
|
889
|
+
| "bulkReadonly"
|
|
890
|
+
| "bulkDone"
|
|
891
|
+
| "validationWarning"
|
|
892
|
+
| "validationError"
|
|
893
|
+
| "typeList"
|
|
894
|
+
| "choicesOne"
|
|
895
|
+
| "choicesOther"
|
|
896
|
+
| "choiceRefused"
|
|
897
|
+
| "listItemAdded"
|
|
898
|
+
| "listItemRemoved"
|
|
899
|
+
| "listItemRemove"
|
|
900
|
+
| "undoCell"
|
|
901
|
+
| "redoCell"
|
|
902
|
+
| "undoAdded"
|
|
903
|
+
| "redoAdded"
|
|
904
|
+
| "undoPaste"
|
|
905
|
+
| "redoPaste"
|
|
906
|
+
| "undoNothing"
|
|
907
|
+
| "redoNothing";
|
|
794
908
|
|
|
795
909
|
/**
|
|
796
910
|
* Any subset of the texts; what is left out keeps its English default. `lang`
|
|
@@ -812,6 +926,11 @@ export type Texts = Partial<Record<TextKey, string>> & {
|
|
|
812
926
|
*/
|
|
813
927
|
export interface SelectionChangeDetail {
|
|
814
928
|
rows: number[];
|
|
929
|
+
/**
|
|
930
|
+
* The same rows as runs of adjacent ones, ascending, both ends inclusive:
|
|
931
|
+
* select-all over 100 000 rows is `[{ from: 0, to: 99999 }]`.
|
|
932
|
+
*/
|
|
933
|
+
ranges: Array<{ from: number; to: number }>;
|
|
815
934
|
count: number;
|
|
816
935
|
/** In a tree only: the selected nodes' keys, the shown ones first. */
|
|
817
936
|
keys?: unknown[];
|
|
@@ -828,6 +947,79 @@ export interface CellChangeDetail {
|
|
|
828
947
|
column: string;
|
|
829
948
|
value: string;
|
|
830
949
|
previous: string;
|
|
950
|
+
/** Set when this change is an undo or a redo (issue #186). */
|
|
951
|
+
undo?: true;
|
|
952
|
+
redo?: true;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
/** What a validator says about a value, or `null` for nothing. */
|
|
956
|
+
export type Finding = { level: "warning" | "error"; message: string } | null | undefined;
|
|
957
|
+
/** `value` is the text in the editor, `row` the record as loaded, by field name. */
|
|
958
|
+
export type Validator = (value: string, row: Record<string, WireValue>) => Finding;
|
|
959
|
+
/** A validator that may block the commit on an `error`. */
|
|
960
|
+
export interface ValidatorRule {
|
|
961
|
+
validate: Validator;
|
|
962
|
+
block?: boolean;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
/** One action of `set_actions`. */
|
|
966
|
+
export interface RowAction {
|
|
967
|
+
id: string;
|
|
968
|
+
label: string;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/** `opengrid-row-action`: an action was activated on a row (issue #189). */
|
|
972
|
+
export interface RowActionDetail {
|
|
973
|
+
id: string;
|
|
974
|
+
/** The row's position — in a grouped grid a display position; use `key`. */
|
|
975
|
+
row: number;
|
|
976
|
+
/** With `row-key` only: the record's value of that field. */
|
|
977
|
+
key?: WireValue;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/** `opengrid-row-add`: a record was typed into the new row (issue #183). */
|
|
981
|
+
export interface RowAddDetail {
|
|
982
|
+
/** The values by field name, in the wire notation of a result. */
|
|
983
|
+
values: Record<string, WireValue>;
|
|
984
|
+
/** What `set_row_state` names the row by until it has a key of its own. */
|
|
985
|
+
provisionalKey: string;
|
|
986
|
+
/** Set when this add is undone — delete the row — or redone (issue #186). */
|
|
987
|
+
undo?: true;
|
|
988
|
+
redo?: true;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* `opengrid-source-replaced`: the grid's source was loaded again (issue #182).
|
|
993
|
+
* Fired on the grid only; it does not bubble.
|
|
994
|
+
*/
|
|
995
|
+
export interface SourceReplacedDetail {
|
|
996
|
+
name: string;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
/** `opengrid-bulk-change`: one value for the selected rows (issue #187). */
|
|
1000
|
+
export interface BulkChangeDetail {
|
|
1001
|
+
/** The `row-key` values of the selected records. */
|
|
1002
|
+
keys: WireValue[];
|
|
1003
|
+
column: string;
|
|
1004
|
+
value: string;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
/** `opengrid-paste`: a pasted block was applied (issue #184). */
|
|
1008
|
+
export interface PasteDetail {
|
|
1009
|
+
/** One per cell of an existing row. */
|
|
1010
|
+
changes: {
|
|
1011
|
+
/** With `row-key` only: the record's value of that field. */
|
|
1012
|
+
key?: WireValue;
|
|
1013
|
+
row: number;
|
|
1014
|
+
column: string;
|
|
1015
|
+
value: string;
|
|
1016
|
+
previous: string;
|
|
1017
|
+
}[];
|
|
1018
|
+
/** The rows past the end, with `add-row`. */
|
|
1019
|
+
added: RowAddDetail[];
|
|
1020
|
+
/** Set when this paste is undone or redone (issue #186). */
|
|
1021
|
+
undo?: true;
|
|
1022
|
+
redo?: true;
|
|
831
1023
|
}
|
|
832
1024
|
|
|
833
1025
|
/** `opengrid-query`: one answer of the grid's provider (issue #70). */
|
|
@@ -852,12 +1044,22 @@ export interface ViewChangeDetail<V = View> {
|
|
|
852
1044
|
view: V;
|
|
853
1045
|
}
|
|
854
1046
|
|
|
855
|
-
/**
|
|
1047
|
+
/**
|
|
1048
|
+
* The events, by name. All bubble, all are composed, none is cancelable —
|
|
1049
|
+
* except `opengrid-source-replaced`, which `loader.js` dispatches on the grid
|
|
1050
|
+
* without bubbling.
|
|
1051
|
+
*/
|
|
856
1052
|
export interface OpengridEventMap {
|
|
857
1053
|
"opengrid-selection-change": CustomEvent<SelectionChangeDetail>;
|
|
858
1054
|
"opengrid-cell-change": CustomEvent<CellChangeDetail>;
|
|
859
1055
|
"opengrid-view-change": CustomEvent<ViewChangeDetail>;
|
|
860
1056
|
"opengrid-query": CustomEvent<QueryDetail>;
|
|
1057
|
+
"opengrid-row-action": CustomEvent<RowActionDetail>;
|
|
1058
|
+
"opengrid-row-add": CustomEvent<RowAddDetail>;
|
|
1059
|
+
"opengrid-paste": CustomEvent<PasteDetail>;
|
|
1060
|
+
"opengrid-bulk-change": CustomEvent<BulkChangeDetail>;
|
|
1061
|
+
/** Dispatched by `loader.js` on the grid; it does not bubble. */
|
|
1062
|
+
"opengrid-source-replaced": CustomEvent<SourceReplacedDetail>;
|
|
861
1063
|
}
|
|
862
1064
|
|
|
863
1065
|
// ---------------------------------------------------------------------------
|
|
@@ -868,7 +1070,7 @@ export interface OpengridEventMap {
|
|
|
868
1070
|
* The attributes of `<opengrid-grid>`, as strings the way HTML has them — for
|
|
869
1071
|
* adapters and JSX typings to build on. For
|
|
870
1072
|
* the boolean ones — `selection`, `toolbar`, `search`, `facets`,
|
|
871
|
-
* `column-menu` — presence is what counts, whatever the value.
|
|
1073
|
+
* `column-menu`, `add-row` — presence is what counts, whatever the value.
|
|
872
1074
|
*/
|
|
873
1075
|
export interface OpengridGridAttributes {
|
|
874
1076
|
label?: string;
|
|
@@ -888,6 +1090,8 @@ export interface OpengridGridAttributes {
|
|
|
888
1090
|
facets?: string;
|
|
889
1091
|
toolbar?: string;
|
|
890
1092
|
"column-menu"?: string;
|
|
1093
|
+
/** An empty row after the last one to type a new record into (`opengrid-row-add`). */
|
|
1094
|
+
"add-row"?: string;
|
|
891
1095
|
selection?: string;
|
|
892
1096
|
density?: Density;
|
|
893
1097
|
/** One of the built-in looks; Base when absent. */
|
|
@@ -925,7 +1129,7 @@ export interface OpengridPivotAttributes {
|
|
|
925
1129
|
theme?: Theme;
|
|
926
1130
|
}
|
|
927
1131
|
|
|
928
|
-
/** `<opengrid-grid>`; it fires the
|
|
1132
|
+
/** `<opengrid-grid>`; it fires the events of {@link OpengridEventMap}. */
|
|
929
1133
|
export interface OpengridGridElement extends HTMLElement {}
|
|
930
1134
|
/** `<opengrid-table>`. */
|
|
931
1135
|
export interface OpengridTableElement extends HTMLElement {}
|