@casoon/opengrid 0.14.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 +375 -19
- package/README.md +16 -1
- package/engine/opengrid_wasm_bg.wasm +0 -0
- package/loader.d.ts +62 -7
- package/loader.js +112 -43
- package/package.json +6 -6
- package/pkg/opengrid_web_components.d.ts +21 -16
- package/pkg/opengrid_web_components.js +134 -28
- package/pkg/opengrid_web_components_bg.wasm +0 -0
- 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 +5 -1
- package/pkg/snippets/opengrid-web-components-56667a20e9158a6a/inline0.js +0 -17
- /package/pkg/snippets/{opengrid-web-core-a3505e32fee0c1ed → opengrid-web-core-78fdded9b8a374ed}/inline0.js +0 -0
- /package/pkg/snippets/{opengrid-web-core-a3505e32fee0c1ed → opengrid-web-core-78fdded9b8a374ed}/inline1.js +0 -0
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"] }`. */
|
|
@@ -129,7 +129,7 @@ export interface OpengridModule {
|
|
|
129
129
|
/**
|
|
130
130
|
* What `connect` supplies an element with. Each is one module function —
|
|
131
131
|
* `presentation` is `set_columns`, named apart from the `columns` attribute —
|
|
132
|
-
* and the
|
|
132
|
+
* and the callbacks receive the event's `detail`.
|
|
133
133
|
*/
|
|
134
134
|
export interface ConnectOptions {
|
|
135
135
|
provider?: Provider;
|
|
@@ -151,6 +151,40 @@ export interface ConnectOptions {
|
|
|
151
151
|
onViewChange?: (view: View) => void;
|
|
152
152
|
onSelectionChange?: (detail: SelectionChangeDetail) => void;
|
|
153
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;
|
|
154
188
|
}
|
|
155
189
|
|
|
156
190
|
/** `connect`'s options for `<opengrid-pivot>`: its view is a {@link PivotView}. */
|
|
@@ -160,7 +194,7 @@ export type PivotConnectOptions = Omit<ConnectOptions, "view" | "defaultView" |
|
|
|
160
194
|
onViewChange?: (view: PivotView) => void;
|
|
161
195
|
};
|
|
162
196
|
|
|
163
|
-
export interface Connection<O = ConnectOptions> {
|
|
197
|
+
export interface Connection<O = ConnectOptions> extends CellWrites {
|
|
164
198
|
/** Settles once the module is loaded and the options are applied. */
|
|
165
199
|
ready: Promise<LoadResult>;
|
|
166
200
|
/**
|
|
@@ -423,7 +457,7 @@ export function exportRows(provider: Provider, query: ViewQuery, options?: Expor
|
|
|
423
457
|
// ---------------------------------------------------------------------------
|
|
424
458
|
|
|
425
459
|
/**
|
|
426
|
-
* 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
|
|
427
461
|
* the server's, from its error form; the last three are `exportRows`' own.
|
|
428
462
|
*/
|
|
429
463
|
export type ErrorCode =
|
|
@@ -434,6 +468,7 @@ export type ErrorCode =
|
|
|
434
468
|
| "unauthorized"
|
|
435
469
|
| "backend"
|
|
436
470
|
| "malformed"
|
|
471
|
+
| "data"
|
|
437
472
|
| "too_many_rows"
|
|
438
473
|
| "source_changed"
|
|
439
474
|
| "module_not_loaded";
|
|
@@ -733,6 +768,7 @@ export type TextKey =
|
|
|
733
768
|
| "columnMenu"
|
|
734
769
|
| "sortAscending"
|
|
735
770
|
| "sortDescending"
|
|
771
|
+
| "sortKey"
|
|
736
772
|
| "filterColumn"
|
|
737
773
|
| "aggregateGroup"
|
|
738
774
|
| "aggregateNone"
|
|
@@ -890,6 +926,11 @@ export type Texts = Partial<Record<TextKey, string>> & {
|
|
|
890
926
|
*/
|
|
891
927
|
export interface SelectionChangeDetail {
|
|
892
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 }>;
|
|
893
934
|
count: number;
|
|
894
935
|
/** In a tree only: the selected nodes' keys, the shown ones first. */
|
|
895
936
|
keys?: unknown[];
|
|
@@ -947,6 +988,14 @@ export interface RowAddDetail {
|
|
|
947
988
|
redo?: true;
|
|
948
989
|
}
|
|
949
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
|
+
|
|
950
999
|
/** `opengrid-bulk-change`: one value for the selected rows (issue #187). */
|
|
951
1000
|
export interface BulkChangeDetail {
|
|
952
1001
|
/** The `row-key` values of the selected records. */
|
|
@@ -995,7 +1044,11 @@ export interface ViewChangeDetail<V = View> {
|
|
|
995
1044
|
view: V;
|
|
996
1045
|
}
|
|
997
1046
|
|
|
998
|
-
/**
|
|
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
|
+
*/
|
|
999
1052
|
export interface OpengridEventMap {
|
|
1000
1053
|
"opengrid-selection-change": CustomEvent<SelectionChangeDetail>;
|
|
1001
1054
|
"opengrid-cell-change": CustomEvent<CellChangeDetail>;
|
|
@@ -1005,6 +1058,8 @@ export interface OpengridEventMap {
|
|
|
1005
1058
|
"opengrid-row-add": CustomEvent<RowAddDetail>;
|
|
1006
1059
|
"opengrid-paste": CustomEvent<PasteDetail>;
|
|
1007
1060
|
"opengrid-bulk-change": CustomEvent<BulkChangeDetail>;
|
|
1061
|
+
/** Dispatched by `loader.js` on the grid; it does not bubble. */
|
|
1062
|
+
"opengrid-source-replaced": CustomEvent<SourceReplacedDetail>;
|
|
1008
1063
|
}
|
|
1009
1064
|
|
|
1010
1065
|
// ---------------------------------------------------------------------------
|
|
@@ -1015,7 +1070,7 @@ export interface OpengridEventMap {
|
|
|
1015
1070
|
* The attributes of `<opengrid-grid>`, as strings the way HTML has them — for
|
|
1016
1071
|
* adapters and JSX typings to build on. For
|
|
1017
1072
|
* the boolean ones — `selection`, `toolbar`, `search`, `facets`,
|
|
1018
|
-
* `column-menu` — presence is what counts, whatever the value.
|
|
1073
|
+
* `column-menu`, `add-row` — presence is what counts, whatever the value.
|
|
1019
1074
|
*/
|
|
1020
1075
|
export interface OpengridGridAttributes {
|
|
1021
1076
|
label?: string;
|
|
@@ -1074,7 +1129,7 @@ export interface OpengridPivotAttributes {
|
|
|
1074
1129
|
theme?: Theme;
|
|
1075
1130
|
}
|
|
1076
1131
|
|
|
1077
|
-
/** `<opengrid-grid>`; it fires the
|
|
1132
|
+
/** `<opengrid-grid>`; it fires the events of {@link OpengridEventMap}. */
|
|
1078
1133
|
export interface OpengridGridElement extends HTMLElement {}
|
|
1079
1134
|
/** `<opengrid-table>`. */
|
|
1080
1135
|
export interface OpengridTableElement extends HTMLElement {}
|
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;
|
|
@@ -202,7 +197,11 @@ export function createWorkerProvider({
|
|
|
202
197
|
|
|
203
198
|
function start() {
|
|
204
199
|
if (!worker) {
|
|
205
|
-
|
|
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" });
|
|
206
205
|
worker.onmessage = ({ data }) => onMessage(data);
|
|
207
206
|
ready = request({ type: "init", moduleUrl, wasmUrl });
|
|
208
207
|
}
|
|
@@ -959,8 +958,8 @@ function aborted() {
|
|
|
959
958
|
*
|
|
960
959
|
* `update` applies only what changed. A key left out of an update keeps its
|
|
961
960
|
* value; a key given as `undefined` resets it (texts to English, no formats, no
|
|
962
|
-
* presentation, no choices) — except `provider`,
|
|
963
|
-
* `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
|
|
964
963
|
* (`label`, `columns`, `group-by`, …) are not options: the page or the
|
|
965
964
|
* framework sets them on the element as usual.
|
|
966
965
|
*
|
|
@@ -973,12 +972,17 @@ function aborted() {
|
|
|
973
972
|
* set). On an element that is not, the view **and the provider** wait for the
|
|
974
973
|
* next `update` — together, so the first query still asks for the view.
|
|
975
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
|
+
*
|
|
976
980
|
* `connect` loads the module with `loadOpengrid()`, whose first call decides
|
|
977
981
|
* the URLs: a page that needs its own calls `loadOpengrid(options)` first.
|
|
978
982
|
*
|
|
979
983
|
* @param {HTMLElement} host an `<opengrid-grid>`, `-table` or `-pivot`.
|
|
980
984
|
* @param {object} options see `ConnectOptions` in `loader.d.ts`.
|
|
981
|
-
* @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}}
|
|
982
986
|
*/
|
|
983
987
|
export function connect(host, options = {}) {
|
|
984
988
|
let current = { ...options };
|
|
@@ -1011,11 +1015,53 @@ export function connect(host, options = {}) {
|
|
|
1011
1015
|
],
|
|
1012
1016
|
["opengrid-selection-change", (event) => current.onSelectionChange?.(event.detail)],
|
|
1013
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)],
|
|
1014
1023
|
];
|
|
1015
1024
|
for (const [type, listener] of listeners) {
|
|
1016
1025
|
host.addEventListener(type, listener);
|
|
1017
1026
|
}
|
|
1018
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
|
+
|
|
1019
1065
|
/** Writes one option if it differs from what the element has. */
|
|
1020
1066
|
function write(name, value, key, apply) {
|
|
1021
1067
|
if (applied.has(name) && applied.get(name) === key) {
|
|
@@ -1064,11 +1110,18 @@ export function connect(host, options = {}) {
|
|
|
1064
1110
|
// first query is the only one and asks for the right thing.
|
|
1065
1111
|
if ("texts" in changed) {
|
|
1066
1112
|
const texts = changed.texts ?? {};
|
|
1067
|
-
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
|
+
});
|
|
1068
1121
|
}
|
|
1069
1122
|
if ("formats" in changed) {
|
|
1070
1123
|
const formats = changed.formats ?? {};
|
|
1071
|
-
write("formats", formats,
|
|
1124
|
+
write("formats", formats, identityKey(formats), (value) => module.set_formats(host, value));
|
|
1072
1125
|
}
|
|
1073
1126
|
if ("presentation" in changed) {
|
|
1074
1127
|
const presentation = changed.presentation ?? {};
|
|
@@ -1080,6 +1133,16 @@ export function connect(host, options = {}) {
|
|
|
1080
1133
|
const choices = changed.choices ?? {};
|
|
1081
1134
|
write("choices", choices, stableKey(choices), (value) => module.set_choices(host, value));
|
|
1082
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
|
+
}
|
|
1083
1146
|
|
|
1084
1147
|
const wantsView =
|
|
1085
1148
|
current.view != null ? "view" in changed || deferred : !defaultApplied && current.defaultView != null;
|
|
@@ -1128,6 +1191,12 @@ export function connect(host, options = {}) {
|
|
|
1128
1191
|
current = { ...current, ...next };
|
|
1129
1192
|
apply(next);
|
|
1130
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
|
+
},
|
|
1131
1200
|
disconnect() {
|
|
1132
1201
|
connected = false;
|
|
1133
1202
|
for (const [type, listener] of listeners) {
|
|
@@ -1137,36 +1206,36 @@ export function connect(host, options = {}) {
|
|
|
1137
1206
|
};
|
|
1138
1207
|
}
|
|
1139
1208
|
|
|
1140
|
-
/**
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
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)
|
|
1144
1217
|
? Object.fromEntries(Object.entries(inner).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)))
|
|
1145
|
-
: inner
|
|
1146
|
-
);
|
|
1218
|
+
: inner;
|
|
1219
|
+
});
|
|
1147
1220
|
}
|
|
1148
1221
|
|
|
1149
1222
|
/**
|
|
1150
|
-
* Formats compare by identity where they are functions and by
|
|
1151
|
-
*
|
|
1152
|
-
* 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.
|
|
1153
1226
|
*/
|
|
1154
1227
|
const functionIds = new WeakMap();
|
|
1155
1228
|
let nextFunctionId = 1;
|
|
1156
|
-
function
|
|
1157
|
-
return stableKey(
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
return [column, { function: functionIds.get(format) }];
|
|
1167
|
-
}),
|
|
1168
|
-
),
|
|
1169
|
-
);
|
|
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
|
+
});
|
|
1170
1239
|
}
|
|
1171
1240
|
|
|
1172
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"
|
|
@@ -135,22 +135,6 @@ export function set_choices(host: HTMLElement, choices: any): void;
|
|
|
135
135
|
export function set_columns(host: HTMLElement, columns: any): void;
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
|
-
* Overrides the texts a component writes itself (point 48).
|
|
139
|
-
*
|
|
140
|
-
* `texts` is a plain JS object with any subset of the keys `lang`, `loading`,
|
|
141
|
-
* `matchesOne`, `matchesOther`, `empty`, `error`, `errorUnknown`,
|
|
142
|
-
* `filterGroup`, `operatorLabel`, `valueLabel`, `clear` and `operators`; every
|
|
143
|
-
* key left out keeps its English default. `{count}`, `{column}` and `{cause}`
|
|
144
|
-
* are the placeholders. A `lang` is written onto the elements that carry these
|
|
145
|
-
* texts — the grid's filter row and status line, the table's error paragraph —
|
|
146
|
-
* so they are announced in the language they are written in. Never onto the
|
|
147
|
-
* data: the cells are the page's, in the page's language.
|
|
148
|
-
*
|
|
149
|
-
* Exported as `set_texts` beside `set_provider`, and like it, it takes effect
|
|
150
|
-
* immediately: the grid rebuilds, because its labels are part of the one-time
|
|
151
|
-
* skeleton (the filter row, the scroll offset and the focus are carried
|
|
152
|
-
* across). Call it **before** wiring the provider and the component renders the
|
|
153
|
-
* right words from its first paint.
|
|
154
138
|
* Sets the per-column display formats (plan point 42).
|
|
155
139
|
*
|
|
156
140
|
* `formats` is a plain JS object keyed by column name. A value is either a
|
|
@@ -183,6 +167,27 @@ export function set_provider(host: HTMLElement, provider: any): void;
|
|
|
183
167
|
*/
|
|
184
168
|
export function set_row_state(host: HTMLElement, provisional_key: string, state: string, detail: any): void;
|
|
185
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
|
+
*/
|
|
186
191
|
export function set_texts(host: HTMLElement, values: any): void;
|
|
187
192
|
|
|
188
193
|
/**
|