@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/loader.js
CHANGED
|
@@ -37,14 +37,10 @@
|
|
|
37
37
|
* single worker of V1 (no pool, no SharedArrayBuffer).
|
|
38
38
|
*/
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
* Default location of the engine module's glue, shipped under `engine/`. A
|
|
45
|
-
* string, not a `URL`: it travels to the worker by `postMessage`.
|
|
46
|
-
*/
|
|
47
|
-
const DEFAULT_ENGINE_URL = new URL("./engine/opengrid_wasm.js", import.meta.url).href;
|
|
40
|
+
// The packaged glue (point 40 pins the path), imported statically: a bundler
|
|
41
|
+
// follows the import, and the `new URL("…_bg.wasm", import.meta.url)` inside the
|
|
42
|
+
// glue, so the `.wasm` ends up in its output. `moduleUrl` replaces it.
|
|
43
|
+
import * as packaged from "./pkg/opengrid_web_components.js";
|
|
48
44
|
|
|
49
45
|
/** Set once the first `loadOpengrid` call has run. */
|
|
50
46
|
let loading;
|
|
@@ -67,9 +63,9 @@ export function loadOpengrid(options = {}) {
|
|
|
67
63
|
return loading;
|
|
68
64
|
}
|
|
69
65
|
|
|
70
|
-
async function start({ moduleUrl
|
|
66
|
+
async function start({ moduleUrl, wasmUrl } = {}) {
|
|
71
67
|
try {
|
|
72
|
-
const module = await import(moduleUrl);
|
|
68
|
+
const module = moduleUrl ? await import(/* @vite-ignore */ moduleUrl) : packaged;
|
|
73
69
|
// wasm-bindgen `--target web` exports the initialiser as the default.
|
|
74
70
|
await module.default(wasmUrl);
|
|
75
71
|
module.register();
|
|
@@ -157,18 +153,17 @@ function installFallback(name = "opengrid-table") {
|
|
|
157
153
|
*
|
|
158
154
|
* @param {object} [options]
|
|
159
155
|
* @param {string} [options.moduleUrl] wasm-bindgen glue of the engine module;
|
|
160
|
-
* defaults to the packaged one under `engine
|
|
161
|
-
* travels to the worker by `postMessage`.
|
|
156
|
+
* defaults to the packaged one under `engine/`, which `worker.js` imports
|
|
157
|
+
* itself. A string, not a `URL`: it travels to the worker by `postMessage`.
|
|
162
158
|
* @param {string} [options.wasmUrl] explicit `.wasm` URL, if it is not next to the glue.
|
|
163
159
|
* @param {URL|string} [options.workerUrl] the worker entry; defaults to `worker.js` next to this file.
|
|
164
160
|
* @returns {{load: Function, execute: Function, terminate: Function, worker?: Worker}}
|
|
165
161
|
*/
|
|
166
162
|
export function createWorkerProvider({
|
|
167
|
-
moduleUrl
|
|
163
|
+
moduleUrl,
|
|
168
164
|
wasmUrl,
|
|
169
165
|
workerUrl,
|
|
170
166
|
} = {}) {
|
|
171
|
-
const workerScript = workerUrl ?? new URL("./worker.js", import.meta.url);
|
|
172
167
|
let worker;
|
|
173
168
|
let ready;
|
|
174
169
|
let nextId = 1;
|
|
@@ -198,9 +193,15 @@ export function createWorkerProvider({
|
|
|
198
193
|
});
|
|
199
194
|
}
|
|
200
195
|
|
|
196
|
+
const watchers = createWatchers();
|
|
197
|
+
|
|
201
198
|
function start() {
|
|
202
199
|
if (!worker) {
|
|
203
|
-
|
|
200
|
+
// Written out in full: the `new Worker(new URL(…, import.meta.url), …)` form
|
|
201
|
+
// is what bundlers recognise and bundle.
|
|
202
|
+
worker = workerUrl
|
|
203
|
+
? new Worker(workerUrl, { type: "module" })
|
|
204
|
+
: new Worker(new URL("./worker.js", import.meta.url), { type: "module" });
|
|
204
205
|
worker.onmessage = ({ data }) => onMessage(data);
|
|
205
206
|
ready = request({ type: "init", moduleUrl, wasmUrl });
|
|
206
207
|
}
|
|
@@ -215,6 +216,23 @@ export function createWorkerProvider({
|
|
|
215
216
|
await start();
|
|
216
217
|
const buffer = toTransferable(bytes);
|
|
217
218
|
await request({ type: "load", name, bytes: buffer, schema }, [buffer]);
|
|
219
|
+
watchers.loaded(name);
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Loads rows the page already holds — an array of objects keyed by field
|
|
224
|
+
* name (or that array as JSON text) — against a schema (issue #182). A
|
|
225
|
+
* name already loaded is replaced, all or nothing.
|
|
226
|
+
*/
|
|
227
|
+
async loadRows(name, rows, schema) {
|
|
228
|
+
await start();
|
|
229
|
+
await request({ type: "rows", name, rows: rowsJson(rows), schema });
|
|
230
|
+
watchers.loaded(name);
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
/** Called by `set_provider`: the grids to tell when a source is replaced. */
|
|
234
|
+
watch(host) {
|
|
235
|
+
watchers.watch(host);
|
|
218
236
|
},
|
|
219
237
|
|
|
220
238
|
/** Runs a query JSON and resolves with the result in the binary form. */
|
|
@@ -255,6 +273,49 @@ export function createWorkerProvider({
|
|
|
255
273
|
};
|
|
256
274
|
}
|
|
257
275
|
|
|
276
|
+
/**
|
|
277
|
+
* The grids on an engine provider's sources (issue #182).
|
|
278
|
+
*
|
|
279
|
+
* `watch(host)` is called by `set_provider`; the host is held weakly, so a
|
|
280
|
+
* removed grid is still collected (point 74). Loading a source — under a new
|
|
281
|
+
* name or over a loaded one, which replaces it — tells every watching grid on
|
|
282
|
+
* that name with an `opengrid-source-replaced` event — it re-runs its query and
|
|
283
|
+
* keeps its view.
|
|
284
|
+
*/
|
|
285
|
+
function createWatchers() {
|
|
286
|
+
const hosts = new Set();
|
|
287
|
+
return {
|
|
288
|
+
watch(host) {
|
|
289
|
+
for (const ref of hosts) {
|
|
290
|
+
if (ref.deref() === host) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
hosts.add(new WeakRef(host));
|
|
295
|
+
},
|
|
296
|
+
/**
|
|
297
|
+
* Tells the grids on `name` that it was loaded. A first load counts too: the
|
|
298
|
+
* engine may hold the source from before this provider (a grid that asked
|
|
299
|
+
* early shows its error until the rows arrive).
|
|
300
|
+
*/
|
|
301
|
+
loaded(name) {
|
|
302
|
+
for (const ref of [...hosts]) {
|
|
303
|
+
const host = ref.deref();
|
|
304
|
+
if (!host) {
|
|
305
|
+
hosts.delete(ref);
|
|
306
|
+
} else if (host.getAttribute("datasource") === name) {
|
|
307
|
+
host.dispatchEvent(new CustomEvent("opengrid-source-replaced", { detail: { name } }));
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** Rows as the engine reads them: a JSON array of objects, as text. */
|
|
315
|
+
function rowsJson(rows) {
|
|
316
|
+
return typeof rows === "string" ? rows : JSON.stringify(rows);
|
|
317
|
+
}
|
|
318
|
+
|
|
258
319
|
/**
|
|
259
320
|
* A provider over an engine that is already initialised on the main thread.
|
|
260
321
|
*
|
|
@@ -265,6 +326,7 @@ export function createWorkerProvider({
|
|
|
265
326
|
* @returns {{load: Function, execute: Function, terminate: Function}}
|
|
266
327
|
*/
|
|
267
328
|
export function createLocalProvider(engine) {
|
|
329
|
+
const watchers = createWatchers();
|
|
268
330
|
return {
|
|
269
331
|
/** Where the queries run; the grid names it in its footer (issue #33). */
|
|
270
332
|
kind: "local",
|
|
@@ -274,6 +336,14 @@ export function createLocalProvider(engine) {
|
|
|
274
336
|
bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes),
|
|
275
337
|
schema,
|
|
276
338
|
);
|
|
339
|
+
watchers.loaded(name);
|
|
340
|
+
},
|
|
341
|
+
async loadRows(name, rows, schema) {
|
|
342
|
+
engine.load_rows(name, rowsJson(rows), schema);
|
|
343
|
+
watchers.loaded(name);
|
|
344
|
+
},
|
|
345
|
+
watch(host) {
|
|
346
|
+
watchers.watch(host);
|
|
277
347
|
},
|
|
278
348
|
execute(queryJson) {
|
|
279
349
|
return engine.execute_columns(queryJson);
|
|
@@ -888,8 +958,8 @@ function aborted() {
|
|
|
888
958
|
*
|
|
889
959
|
* `update` applies only what changed. A key left out of an update keeps its
|
|
890
960
|
* value; a key given as `undefined` resets it (texts to English, no formats, no
|
|
891
|
-
* presentation, no choices) — except `provider`,
|
|
892
|
-
* `view`, where `undefined` (or `null`) means the grid leads. Attributes
|
|
961
|
+
* presentation, no choices, no actions, no validators) — except `provider`,
|
|
962
|
+
* which has no "none", and `view`, where `undefined` (or `null`) means the grid leads. Attributes
|
|
893
963
|
* (`label`, `columns`, `group-by`, …) are not options: the page or the
|
|
894
964
|
* framework sets them on the element as usual.
|
|
895
965
|
*
|
|
@@ -902,12 +972,17 @@ function aborted() {
|
|
|
902
972
|
* set). On an element that is not, the view **and the provider** wait for the
|
|
903
973
|
* next `update` — together, so the first query still asks for the view.
|
|
904
974
|
*
|
|
975
|
+
* **Editing** (issue #206): `onRowAdd` answers with the new row's state — or a
|
|
976
|
+
* promise of it — which is `set_row_state`; `setCellState` and `setValues` on
|
|
977
|
+
* the connection are `set_cell_state` and `set_values`, and wait for the
|
|
978
|
+
* module like every option does.
|
|
979
|
+
*
|
|
905
980
|
* `connect` loads the module with `loadOpengrid()`, whose first call decides
|
|
906
981
|
* the URLs: a page that needs its own calls `loadOpengrid(options)` first.
|
|
907
982
|
*
|
|
908
983
|
* @param {HTMLElement} host an `<opengrid-grid>`, `-table` or `-pivot`.
|
|
909
984
|
* @param {object} options see `ConnectOptions` in `loader.d.ts`.
|
|
910
|
-
* @returns {{ready: Promise<{fallback: boolean, module?: object}>, update: Function, disconnect: Function}}
|
|
985
|
+
* @returns {{ready: Promise<{fallback: boolean, module?: object}>, update: Function, setCellState: Function, setValues: Function, disconnect: Function}}
|
|
911
986
|
*/
|
|
912
987
|
export function connect(host, options = {}) {
|
|
913
988
|
let current = { ...options };
|
|
@@ -940,11 +1015,53 @@ export function connect(host, options = {}) {
|
|
|
940
1015
|
],
|
|
941
1016
|
["opengrid-selection-change", (event) => current.onSelectionChange?.(event.detail)],
|
|
942
1017
|
["opengrid-cell-change", (event) => current.onCellChange?.(event.detail)],
|
|
1018
|
+
["opengrid-row-add", (event) => answerRowAdd(event.detail)],
|
|
1019
|
+
["opengrid-paste", (event) => current.onPaste?.(event.detail)],
|
|
1020
|
+
["opengrid-bulk-change", (event) => current.onBulkChange?.(event.detail)],
|
|
1021
|
+
["opengrid-row-action", (event) => current.onRowAction?.(event.detail)],
|
|
1022
|
+
["opengrid-source-replaced", (event) => current.onSourceReplaced?.(event.detail)],
|
|
943
1023
|
];
|
|
944
1024
|
for (const [type, listener] of listeners) {
|
|
945
1025
|
host.addEventListener(type, listener);
|
|
946
1026
|
}
|
|
947
1027
|
|
|
1028
|
+
/**
|
|
1029
|
+
* `onRowAdd`'s answer becomes the row's state: a promise shows `saving` until
|
|
1030
|
+
* it settles — resolved with nothing, the row is saved — and a rejection is
|
|
1031
|
+
* an `error` with its message. An undone add has no row left to answer for.
|
|
1032
|
+
*/
|
|
1033
|
+
function answerRowAdd(detail) {
|
|
1034
|
+
const answer = current.onRowAdd?.(detail);
|
|
1035
|
+
if (answer == null || detail.undo) {
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
const key = detail.provisionalKey;
|
|
1039
|
+
if (typeof answer.then !== "function") {
|
|
1040
|
+
setRowState(key, answer);
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
1043
|
+
setRowState(key, { state: "saving" });
|
|
1044
|
+
answer.then(
|
|
1045
|
+
(state) => setRowState(key, state ?? { state: "saved" }),
|
|
1046
|
+
(error) => setRowState(key, { state: "error", message: String(error?.message ?? error) }),
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
function setRowState(key, { state, key: saved, message }) {
|
|
1051
|
+
if (module && connected) {
|
|
1052
|
+
module.set_row_state(host, key, state, state === "saved" ? saved : message);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
/** Runs `call` with the module — now, or once it has loaded. */
|
|
1057
|
+
function withModule(call) {
|
|
1058
|
+
if (module) {
|
|
1059
|
+
call(module);
|
|
1060
|
+
} else {
|
|
1061
|
+
ready.then(() => module && connected && call(module));
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
|
|
948
1065
|
/** Writes one option if it differs from what the element has. */
|
|
949
1066
|
function write(name, value, key, apply) {
|
|
950
1067
|
if (applied.has(name) && applied.get(name) === key) {
|
|
@@ -993,11 +1110,18 @@ export function connect(host, options = {}) {
|
|
|
993
1110
|
// first query is the only one and asks for the right thing.
|
|
994
1111
|
if ("texts" in changed) {
|
|
995
1112
|
const texts = changed.texts ?? {};
|
|
996
|
-
write("texts", texts, stableKey(texts), (value) =>
|
|
1113
|
+
write("texts", texts, stableKey(texts), (value) => {
|
|
1114
|
+
// `set_texts` adds to the texts the element has; this option is all of
|
|
1115
|
+
// them, so what an earlier value set and this one leaves out goes first.
|
|
1116
|
+
module.set_texts(host, null);
|
|
1117
|
+
if (Object.keys(value).length > 0) {
|
|
1118
|
+
module.set_texts(host, value);
|
|
1119
|
+
}
|
|
1120
|
+
});
|
|
997
1121
|
}
|
|
998
1122
|
if ("formats" in changed) {
|
|
999
1123
|
const formats = changed.formats ?? {};
|
|
1000
|
-
write("formats", formats,
|
|
1124
|
+
write("formats", formats, identityKey(formats), (value) => module.set_formats(host, value));
|
|
1001
1125
|
}
|
|
1002
1126
|
if ("presentation" in changed) {
|
|
1003
1127
|
const presentation = changed.presentation ?? {};
|
|
@@ -1009,6 +1133,16 @@ export function connect(host, options = {}) {
|
|
|
1009
1133
|
const choices = changed.choices ?? {};
|
|
1010
1134
|
write("choices", choices, stableKey(choices), (value) => module.set_choices(host, value));
|
|
1011
1135
|
}
|
|
1136
|
+
if ("actions" in changed) {
|
|
1137
|
+
const actions = changed.actions ?? [];
|
|
1138
|
+
write("actions", actions, stableKey(actions), (value) => module.set_actions(host, value));
|
|
1139
|
+
}
|
|
1140
|
+
if ("validators" in changed) {
|
|
1141
|
+
const validators = changed.validators ?? {};
|
|
1142
|
+
write("validators", validators, identityKey(validators), (value) =>
|
|
1143
|
+
module.set_validators(host, value),
|
|
1144
|
+
);
|
|
1145
|
+
}
|
|
1012
1146
|
|
|
1013
1147
|
const wantsView =
|
|
1014
1148
|
current.view != null ? "view" in changed || deferred : !defaultApplied && current.defaultView != null;
|
|
@@ -1057,6 +1191,12 @@ export function connect(host, options = {}) {
|
|
|
1057
1191
|
current = { ...current, ...next };
|
|
1058
1192
|
apply(next);
|
|
1059
1193
|
},
|
|
1194
|
+
setCellState(key, column, state, message) {
|
|
1195
|
+
withModule((loaded) => loaded.set_cell_state(host, key, column, state, message));
|
|
1196
|
+
},
|
|
1197
|
+
setValues(values) {
|
|
1198
|
+
withModule((loaded) => loaded.set_values(host, values));
|
|
1199
|
+
},
|
|
1060
1200
|
disconnect() {
|
|
1061
1201
|
connected = false;
|
|
1062
1202
|
for (const [type, listener] of listeners) {
|
|
@@ -1066,36 +1206,36 @@ export function connect(host, options = {}) {
|
|
|
1066
1206
|
};
|
|
1067
1207
|
}
|
|
1068
1208
|
|
|
1069
|
-
/**
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1209
|
+
/**
|
|
1210
|
+
* A JSON key that does not depend on the order an object's keys were written
|
|
1211
|
+
* in; `each` may stand in for a value first.
|
|
1212
|
+
*/
|
|
1213
|
+
function stableKey(value, each = (inner) => inner) {
|
|
1214
|
+
return JSON.stringify(value, (_, raw) => {
|
|
1215
|
+
const inner = each(raw);
|
|
1216
|
+
return inner && typeof inner === "object" && !Array.isArray(inner)
|
|
1073
1217
|
? Object.fromEntries(Object.entries(inner).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)))
|
|
1074
|
-
: inner
|
|
1075
|
-
);
|
|
1218
|
+
: inner;
|
|
1219
|
+
});
|
|
1076
1220
|
}
|
|
1077
1221
|
|
|
1078
1222
|
/**
|
|
1079
|
-
* Formats compare by identity where they are functions and by
|
|
1080
|
-
*
|
|
1081
|
-
* two different functions never compare equal.
|
|
1223
|
+
* Formats and validators compare by identity where they are functions and by
|
|
1224
|
+
* value elsewhere (`Intl` options, `block`). Function identities are numbered
|
|
1225
|
+
* per call site so two different functions never compare equal.
|
|
1082
1226
|
*/
|
|
1083
1227
|
const functionIds = new WeakMap();
|
|
1084
1228
|
let nextFunctionId = 1;
|
|
1085
|
-
function
|
|
1086
|
-
return stableKey(
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
return [column, { function: functionIds.get(format) }];
|
|
1096
|
-
}),
|
|
1097
|
-
),
|
|
1098
|
-
);
|
|
1229
|
+
function identityKey(value) {
|
|
1230
|
+
return stableKey(value, (inner) => {
|
|
1231
|
+
if (typeof inner !== "function") {
|
|
1232
|
+
return inner;
|
|
1233
|
+
}
|
|
1234
|
+
if (!functionIds.has(inner)) {
|
|
1235
|
+
functionIds.set(inner, nextFunctionId++);
|
|
1236
|
+
}
|
|
1237
|
+
return { function: functionIds.get(inner) };
|
|
1238
|
+
});
|
|
1099
1239
|
}
|
|
1100
1240
|
|
|
1101
1241
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@casoon/opengrid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Accessible data grid, table and pivot as web components, driven by a portable Rust/WASM query engine — with React, Vue and Svelte components.",
|
|
6
6
|
"keywords": [
|
|
@@ -69,10 +69,10 @@
|
|
|
69
69
|
"CHANGELOG.md"
|
|
70
70
|
],
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@types/react": ">=18",
|
|
72
|
+
"@types/react": ">=18.3.0",
|
|
73
73
|
"react": ">=18",
|
|
74
74
|
"svelte": "^5.0.0",
|
|
75
|
-
"vue": ">=3.
|
|
75
|
+
"vue": ">=3.4.20"
|
|
76
76
|
},
|
|
77
77
|
"peerDependenciesMeta": {
|
|
78
78
|
"@types/react": {
|
|
@@ -90,11 +90,11 @@
|
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@types/react": "19.3.0",
|
|
93
|
-
"svelte": "5.57.
|
|
94
|
-
"vue": "3.5.
|
|
93
|
+
"svelte": "5.57.3",
|
|
94
|
+
"vue": "3.5.45"
|
|
95
95
|
},
|
|
96
96
|
"engines": {
|
|
97
|
-
"node": ">=
|
|
97
|
+
"node": ">=22.12.0"
|
|
98
98
|
},
|
|
99
99
|
"publishConfig": {
|
|
100
100
|
"access": "public"
|
|
@@ -80,6 +80,15 @@ export function get_view(host: HTMLElement): any;
|
|
|
80
80
|
*/
|
|
81
81
|
export function register(): void;
|
|
82
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Gives every row of a grid actions (issue #189): `[{ id, label }]`, one
|
|
85
|
+
* trailing column each, with a button per row. Activating one — click, or
|
|
86
|
+
* `Enter` and `Space` on its cell — fires `opengrid-row-action` with
|
|
87
|
+
* `{ id, key, row }`; `key` is the `row-key` value, and group headers and the
|
|
88
|
+
* total have no button. The label is the accessible name.
|
|
89
|
+
*/
|
|
90
|
+
export function set_actions(host: HTMLElement, actions: any): void;
|
|
91
|
+
|
|
83
92
|
/**
|
|
84
93
|
* Says what became of an edit the page saves (issue #153).
|
|
85
94
|
*
|
|
@@ -96,8 +105,10 @@ export function set_cell_state(host: HTMLElement, key: any, column: string, stat
|
|
|
96
105
|
* Sets the choices a column's editor offers (plan point 37).
|
|
97
106
|
*
|
|
98
107
|
* `choices` is a plain JS object keyed by column name, each value a list of
|
|
99
|
-
* strings. A column with choices gets a
|
|
100
|
-
*
|
|
108
|
+
* strings, numbers or `{ value, label }` pairs. A column with choices gets a
|
|
109
|
+
* type-ahead combobox instead of a typed input (issue #185), and a list column
|
|
110
|
+
* is edited with one only. V1 has no enum type, so the page is the only honest
|
|
111
|
+
* source of the options.
|
|
101
112
|
*/
|
|
102
113
|
export function set_choices(host: HTMLElement, choices: any): void;
|
|
103
114
|
|
|
@@ -124,22 +135,6 @@ export function set_choices(host: HTMLElement, choices: any): void;
|
|
|
124
135
|
export function set_columns(host: HTMLElement, columns: any): void;
|
|
125
136
|
|
|
126
137
|
/**
|
|
127
|
-
* Overrides the texts a component writes itself (point 48).
|
|
128
|
-
*
|
|
129
|
-
* `texts` is a plain JS object with any subset of the keys `lang`, `loading`,
|
|
130
|
-
* `matchesOne`, `matchesOther`, `empty`, `error`, `errorUnknown`,
|
|
131
|
-
* `filterGroup`, `operatorLabel`, `valueLabel`, `clear` and `operators`; every
|
|
132
|
-
* key left out keeps its English default. `{count}`, `{column}` and `{cause}`
|
|
133
|
-
* are the placeholders. A `lang` is written onto the elements that carry these
|
|
134
|
-
* texts — the grid's filter row and status line, the table's error paragraph —
|
|
135
|
-
* so they are announced in the language they are written in. Never onto the
|
|
136
|
-
* data: the cells are the page's, in the page's language.
|
|
137
|
-
*
|
|
138
|
-
* Exported as `set_texts` beside `set_provider`, and like it, it takes effect
|
|
139
|
-
* immediately: the grid rebuilds, because its labels are part of the one-time
|
|
140
|
-
* skeleton (the filter row, the scroll offset and the focus are carried
|
|
141
|
-
* across). Call it **before** wiring the provider and the component renders the
|
|
142
|
-
* right words from its first paint.
|
|
143
138
|
* Sets the per-column display formats (plan point 42).
|
|
144
139
|
*
|
|
145
140
|
* `formats` is a plain JS object keyed by column name. A value is either a
|
|
@@ -165,8 +160,45 @@ export function set_formats(host: HTMLElement, formats: any): void;
|
|
|
165
160
|
*/
|
|
166
161
|
export function set_provider(host: HTMLElement, provider: any): void;
|
|
167
162
|
|
|
163
|
+
/**
|
|
164
|
+
* What became of a row the reader added (issue #183): `state` is `saving`,
|
|
165
|
+
* `saved` or `error`. `detail` is the record's `row-key` for `saved`, the
|
|
166
|
+
* message for `error` — said in the status line, as `set_cell_state` says one.
|
|
167
|
+
*/
|
|
168
|
+
export function set_row_state(host: HTMLElement, provisional_key: string, state: string, detail: any): void;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Overrides the texts a component writes itself (point 48).
|
|
172
|
+
*
|
|
173
|
+
* `texts` is a plain JS object with any subset of the keys `lang`, `loading`,
|
|
174
|
+
* `matchesOne`, `matchesOther`, `empty`, `error`, `errorUnknown`,
|
|
175
|
+
* `filterGroup`, `operatorLabel`, `valueLabel`, `clear` and `operators`; every
|
|
176
|
+
* key left out keeps its English default. `{count}`, `{column}` and `{cause}`
|
|
177
|
+
* are the placeholders. A `lang` is written onto the elements that carry these
|
|
178
|
+
* texts — the grid's filter row and status line, the table's error paragraph —
|
|
179
|
+
* so they are announced in the language they are written in. Never onto the
|
|
180
|
+
* data: the cells are the page's, in the page's language.
|
|
181
|
+
*
|
|
182
|
+
* A call adds to the texts an earlier one set; a key left out keeps what it was.
|
|
183
|
+
* `set_texts(host, null)` takes them all back to the English defaults.
|
|
184
|
+
*
|
|
185
|
+
* Exported as `set_texts` beside `set_provider`, and like it, it takes effect
|
|
186
|
+
* immediately: the grid rebuilds, because its labels are part of the one-time
|
|
187
|
+
* skeleton (the filter row, the scroll offset and the focus are carried
|
|
188
|
+
* across). Call it **before** wiring the provider and the component renders the
|
|
189
|
+
* right words from its first paint.
|
|
190
|
+
*/
|
|
168
191
|
export function set_texts(host: HTMLElement, values: any): void;
|
|
169
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Gives columns a validator that runs while the reader types (issue #188):
|
|
195
|
+
* `{ column: (value, row) => null | { level: "warning" | "error", message } }`,
|
|
196
|
+
* or `{ column: { validate, block: true } }` to make an `error` block the
|
|
197
|
+
* commit. The answer is shown under the editor and stays on the cell; it blocks
|
|
198
|
+
* only where the column asks for it (what the schema refuses always does).
|
|
199
|
+
*/
|
|
200
|
+
export function set_validators(host: HTMLElement, validators: any): void;
|
|
201
|
+
|
|
170
202
|
/**
|
|
171
203
|
* Shows values the page computes (issue #153): `[{ key, column, value }]`.
|
|
172
204
|
*
|
|
@@ -207,22 +239,25 @@ export interface InitOutput {
|
|
|
207
239
|
readonly get_query: (a: any) => any;
|
|
208
240
|
readonly get_view: (a: any) => any;
|
|
209
241
|
readonly register: () => [number, number];
|
|
242
|
+
readonly set_actions: (a: any, b: any) => void;
|
|
210
243
|
readonly set_cell_state: (a: any, b: any, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
211
244
|
readonly set_choices: (a: any, b: any) => void;
|
|
212
245
|
readonly set_columns: (a: any, b: any) => void;
|
|
213
246
|
readonly set_formats: (a: any, b: any) => void;
|
|
214
247
|
readonly set_provider: (a: any, b: any) => void;
|
|
248
|
+
readonly set_row_state: (a: any, b: number, c: number, d: number, e: number, f: any) => void;
|
|
215
249
|
readonly set_texts: (a: any, b: any) => void;
|
|
250
|
+
readonly set_validators: (a: any, b: any) => void;
|
|
216
251
|
readonly set_values: (a: any, b: any) => void;
|
|
217
252
|
readonly set_view: (a: any, b: any, c: any) => void;
|
|
218
|
-
readonly
|
|
219
|
-
readonly
|
|
220
|
-
readonly
|
|
221
|
-
readonly
|
|
222
|
-
readonly
|
|
223
|
-
readonly
|
|
224
|
-
readonly
|
|
225
|
-
readonly
|
|
253
|
+
readonly wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke___web_sys_b5c30633085262f3___features__gen_HtmlElement__HtmlElement__alloc_42d2b33bd937efdb___string__String__core_37ee0ce0c4cd57d5___option__Option_alloc_42d2b33bd937efdb___string__String___core_37ee0ce0c4cd57d5___option__Option_alloc_42d2b33bd937efdb___string__String_______true_: (a: number, b: number, c: any, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
254
|
+
readonly wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke___wasm_bindgen_4cfd459b66780f67___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_4cfd459b66780f67___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
255
|
+
readonly wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke___js_sys_167d7a02263935a1___Array______true_: (a: number, b: number, c: any) => void;
|
|
256
|
+
readonly wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke___js_sys_167d7a02263935a1___Array______true__2: (a: number, b: number, c: any) => void;
|
|
257
|
+
readonly wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke___js_sys_167d7a02263935a1___Array______true__4: (a: number, b: number, c: any) => void;
|
|
258
|
+
readonly wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke___js_sys_167d7a02263935a1___Array______true__5: (a: number, b: number, c: any) => void;
|
|
259
|
+
readonly wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke___u32______true_: (a: number, b: number, c: number) => void;
|
|
260
|
+
readonly wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke_______true_: (a: number, b: number) => void;
|
|
226
261
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
227
262
|
readonly __externref_table_alloc: () => number;
|
|
228
263
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|