@casoon/opengrid 0.14.0 → 0.16.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 +621 -19
- package/README.md +19 -2
- package/engine/opengrid_wasm_bg.wasm +0 -0
- package/loader.d.ts +451 -24
- package/loader.js +584 -132
- package/package.json +13 -6
- package/pkg/opengrid_web_components.d.ts +94 -23
- package/pkg/opengrid_web_components.js +451 -59
- package/pkg/opengrid_web_components_bg.wasm +0 -0
- package/pkg/opengrid_web_components_bg.wasm.d.ts +15 -6
- package/pkg/snippets/opengrid-web-components-35ed06b453a9b215/inline0.js +8 -0
- package/pkg/snippets/opengrid-web-components-35ed06b453a9b215/inline1.js +58 -0
- package/pkg/snippets/opengrid-web-core-b41714d4e7311909/inline2.js +89 -0
- package/react/index.d.ts +20 -2
- package/react/index.js +32 -6
- package/svelte/Opengrid.svelte +46 -11
- package/svelte/OpengridGrid.svelte +20 -1
- package/svelte/OpengridPivot.svelte +3 -3
- package/svelte/OpengridTable.svelte +1 -1
- package/svelte/index.d.ts +57 -18
- package/svelte/index.js +1 -1
- package/texts/de.d.ts +5 -0
- package/texts/de.js +245 -0
- package/vue/index.d.ts +49 -7
- package/vue/index.js +41 -11
- package/worker.js +6 -3
- package/xlsx/opengrid_xlsx.d.ts +69 -0
- package/xlsx/opengrid_xlsx.js +375 -0
- package/xlsx/opengrid_xlsx_bg.wasm +0 -0
- package/xlsx/opengrid_xlsx_bg.wasm.d.ts +16 -0
- package/pkg/snippets/opengrid-web-components-56667a20e9158a6a/inline0.js +0 -17
- /package/pkg/snippets/{opengrid-web-core-a3505e32fee0c1ed → opengrid-web-core-b41714d4e7311909}/inline0.js +0 -0
- /package/pkg/snippets/{opengrid-web-core-a3505e32fee0c1ed → opengrid-web-core-b41714d4e7311909}/inline1.js +0 -0
|
Binary file
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const export_csv: (a: any, b: any, c: number) => [number, number, number, number];
|
|
4
|
+
export const export_csv: (a: any, b: any, c: number, d: any) => [number, number, number, number];
|
|
5
5
|
export const export_json: (a: any, b: number) => [number, number, number, number];
|
|
6
|
+
export const get_export_headers: (a: any) => any;
|
|
6
7
|
export const get_pivot: (a: any, b: any) => [number, number, number];
|
|
7
8
|
export const get_query: (a: any) => any;
|
|
8
9
|
export const get_view: (a: any) => any;
|
|
10
|
+
export const pivot_words: (a: any) => [number, number];
|
|
11
|
+
export const prepare_print: (a: any) => any;
|
|
12
|
+
export const refresh: (a: any) => void;
|
|
9
13
|
export const register: () => [number, number];
|
|
10
14
|
export const set_actions: (a: any, b: any) => void;
|
|
11
15
|
export const set_cell_state: (a: any, b: any, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
16
|
+
export const set_cell_templates: (a: any, b: any) => void;
|
|
12
17
|
export const set_choices: (a: any, b: any) => void;
|
|
13
18
|
export const set_columns: (a: any, b: any) => void;
|
|
19
|
+
export const set_detail_renderer: (a: any, b: any) => void;
|
|
14
20
|
export const set_formats: (a: any, b: any) => void;
|
|
15
21
|
export const set_provider: (a: any, b: any) => void;
|
|
16
22
|
export const set_row_state: (a: any, b: number, c: number, d: number, e: number, f: any) => void;
|
|
@@ -18,12 +24,14 @@ export const set_texts: (a: any, b: any) => void;
|
|
|
18
24
|
export const set_validators: (a: any, b: any) => void;
|
|
19
25
|
export const set_values: (a: any, b: any) => void;
|
|
20
26
|
export const set_view: (a: any, b: any, c: any) => void;
|
|
21
|
-
export const
|
|
27
|
+
export const wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke___web_sys_a82a67fb9e0c1518___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;
|
|
22
28
|
export const 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];
|
|
23
|
-
export const
|
|
24
|
-
export const
|
|
25
|
-
export const
|
|
26
|
-
export const
|
|
29
|
+
export const wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke___js_sys_167d7a02263935a1___Function_fn_wasm_bindgen_4cfd459b66780f67___JsValue_____wasm_bindgen_4cfd459b66780f67___sys__Undefined___js_sys_167d7a02263935a1___Function_fn_wasm_bindgen_4cfd459b66780f67___JsValue_____wasm_bindgen_4cfd459b66780f67___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
30
|
+
export const wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke___wasm_bindgen_4cfd459b66780f67___JsValue______true_: (a: number, b: number, c: any) => void;
|
|
31
|
+
export const wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke___wasm_bindgen_4cfd459b66780f67___JsValue______true__2: (a: number, b: number, c: any) => void;
|
|
32
|
+
export const wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke___wasm_bindgen_4cfd459b66780f67___JsValue______true__3: (a: number, b: number, c: any) => void;
|
|
33
|
+
export const wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke___wasm_bindgen_4cfd459b66780f67___JsValue______true__5: (a: number, b: number, c: any) => void;
|
|
34
|
+
export const wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke___wasm_bindgen_4cfd459b66780f67___JsValue______true__6: (a: number, b: number, c: any) => void;
|
|
27
35
|
export const wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke___u32______true_: (a: number, b: number, c: number) => void;
|
|
28
36
|
export const wasm_bindgen_4cfd459b66780f67___convert__closures_____invoke_______true_: (a: number, b: number) => void;
|
|
29
37
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
@@ -34,4 +42,5 @@ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) =>
|
|
|
34
42
|
export const __wbindgen_destroy_closure: (a: number, b: number) => void;
|
|
35
43
|
export const __externref_table_dealloc: (a: number) => void;
|
|
36
44
|
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
45
|
+
export const __externref_drop_slice: (a: number, b: number) => void;
|
|
37
46
|
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
|
|
2
|
+
// The language of the page at `host`: the nearest `lang` attribute, through
|
|
3
|
+
// shadow roots as well; empty when there is none or it is empty.
|
|
4
|
+
export function __opengrid_page_lang(host) {
|
|
5
|
+
for (let node = host; node; node = node.parentElement || (node.getRootNode && node.getRootNode().host) || null) {
|
|
6
|
+
const lang = node.getAttribute && node.getAttribute('lang');
|
|
7
|
+
if (lang !== null && lang !== undefined) return lang.trim();
|
|
8
|
+
}
|
|
9
|
+
return '';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// One observer for every host whose formats follow the page's language. It
|
|
13
|
+
// holds the hosts weakly, so a removed grid is still collected.
|
|
14
|
+
const followers = new Set();
|
|
15
|
+
const known = new WeakSet();
|
|
16
|
+
const roots = new WeakSet();
|
|
17
|
+
let observer = null;
|
|
18
|
+
export function __opengrid_follow_lang(host, relocalize) {
|
|
19
|
+
if (!known.has(host)) {
|
|
20
|
+
known.add(host);
|
|
21
|
+
followers.add(new WeakRef(host));
|
|
22
|
+
}
|
|
23
|
+
if (!observer) {
|
|
24
|
+
observer = new MutationObserver(() => {
|
|
25
|
+
for (const ref of [...followers]) {
|
|
26
|
+
const host = ref.deref();
|
|
27
|
+
if (!host) followers.delete(ref);
|
|
28
|
+
else if (host.isConnected) relocalize(host);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const watch = (node) => {
|
|
33
|
+
if (node && !roots.has(node)) {
|
|
34
|
+
roots.add(node);
|
|
35
|
+
observer.observe(node, { attributes: true, attributeFilter: ['lang'], subtree: true });
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
watch(host.ownerDocument.documentElement);
|
|
39
|
+
const root = host.getRootNode();
|
|
40
|
+
if (root !== host.ownerDocument) watch(root);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function __opengrid_intl_formatter(kind, locale, options) {
|
|
44
|
+
const loc = locale || undefined;
|
|
45
|
+
const format = kind === 'date'
|
|
46
|
+
? new Intl.DateTimeFormat(loc, options)
|
|
47
|
+
: new Intl.NumberFormat(loc, options);
|
|
48
|
+
return (text, value) => {
|
|
49
|
+
if (value === null || value === undefined) return '';
|
|
50
|
+
if (kind === 'date') {
|
|
51
|
+
const at = Date.parse(typeof value === 'string' && value.length === 10
|
|
52
|
+
? value + 'T00:00:00Z' : value);
|
|
53
|
+
return Number.isNaN(at) ? text : format.format(new Date(at));
|
|
54
|
+
}
|
|
55
|
+
const number = Number(value);
|
|
56
|
+
return Number.isFinite(number) ? format.format(number) : text;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
|
|
2
|
+
// Writes nothing when the node already shows exactly this text: one Text node
|
|
3
|
+
// with these characters, or no child for the empty string. A recycled cell
|
|
4
|
+
// that shows the same value again, and the status line on every scroll frame,
|
|
5
|
+
// then neither lose their Text node nor queue a mutation (a live region may
|
|
6
|
+
// announce a replaced node again). Whatever else the node holds, such as the
|
|
7
|
+
// chips drawn over a cell, is not equal and is replaced as before.
|
|
8
|
+
function setText(node, text) {
|
|
9
|
+
const first = node.firstChild;
|
|
10
|
+
if (first === null ? text === "" : first.nodeType === 3 && first.nextSibling === null && first.data === text) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
node.textContent = text;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// The same for attributes: a recycled slot is patched with the whole set of
|
|
17
|
+
// attributes a row has, nearly all of them already as they should be, and most
|
|
18
|
+
// of the removals name an attribute that is not there. Each is one comparison
|
|
19
|
+
// against the element instead of a write the browser has to record.
|
|
20
|
+
// `style` goes through the CSSOM (`style.cssText`), not `setAttribute`: a page
|
|
21
|
+
// whose policy has `style-src` without 'unsafe-inline' refuses a style
|
|
22
|
+
// attribute set from script, and the grid positions its rows with one. The
|
|
23
|
+
// CSSOM is not governed by `style-src`; the attribute reads back the same
|
|
24
|
+
// either way.
|
|
25
|
+
function setAttribute(node, name, value) {
|
|
26
|
+
if (name === "style" && node instanceof HTMLElement) {
|
|
27
|
+
if (node.style.cssText !== value) {
|
|
28
|
+
node.style.cssText = value;
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (node.nodeType === 1 && node.getAttribute(name) !== value) {
|
|
33
|
+
node.setAttribute(name, value);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function removeAttribute(node, name) {
|
|
38
|
+
if (node.nodeType === 1 && node.hasAttribute(name)) {
|
|
39
|
+
node.removeAttribute(name);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function __opengrid_set_text(node, text) {
|
|
44
|
+
setText(node, text);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function __opengrid_set_attribute(node, name, value) {
|
|
48
|
+
setAttribute(node, name, value);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function __opengrid_remove_attribute(node, name) {
|
|
52
|
+
removeAttribute(node, name);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// A whole frame in one call. `ops` holds six numbers per patch: its kind, the
|
|
56
|
+
// node it is about, and two (offset, length) pairs into `text`, in UTF-16 units
|
|
57
|
+
// (a create: the tag; an attribute: name and value; a removal: the name; a
|
|
58
|
+
// text: the text; an append: the child's index in the first offset). Names,
|
|
59
|
+
// values and texts are cut from one string instead of crossing one by one.
|
|
60
|
+
function piece(text, ops, at) {
|
|
61
|
+
return text.substring(ops[at], ops[at] + ops[at + 1]);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function __opengrid_apply_frame(document, table, ops, text) {
|
|
65
|
+
for (let at = 0; at < ops.length; at += 6) {
|
|
66
|
+
const node = table[ops[at + 1]];
|
|
67
|
+
switch (ops[at]) {
|
|
68
|
+
case 0:
|
|
69
|
+
table[ops[at + 1]] = document.createElement(piece(text, ops, at + 2));
|
|
70
|
+
break;
|
|
71
|
+
case 1:
|
|
72
|
+
setAttribute(
|
|
73
|
+
node,
|
|
74
|
+
piece(text, ops, at + 2),
|
|
75
|
+
piece(text, ops, at + 4),
|
|
76
|
+
);
|
|
77
|
+
break;
|
|
78
|
+
case 2:
|
|
79
|
+
removeAttribute(node, piece(text, ops, at + 2));
|
|
80
|
+
break;
|
|
81
|
+
case 3:
|
|
82
|
+
setText(node, piece(text, ops, at + 2));
|
|
83
|
+
break;
|
|
84
|
+
case 4:
|
|
85
|
+
node.appendChild(table[ops[at + 2]]);
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
package/react/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Types for `@casoon/opengrid/react
|
|
2
|
+
* Types for `@casoon/opengrid/react`.
|
|
3
3
|
*
|
|
4
4
|
* The props are the element's attributes in camelCase plus the options of
|
|
5
5
|
* `connect` from `@casoon/opengrid` — no names of their own. Everything else
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
import type { ForwardRefExoticComponent, HTMLAttributes, RefAttributes } from "react";
|
|
22
22
|
import type {
|
|
23
|
+
CellWrites,
|
|
23
24
|
ConnectOptions,
|
|
24
25
|
Density,
|
|
25
26
|
Theme,
|
|
@@ -48,16 +49,24 @@ export interface OpengridGridProps extends ConnectOptions, ElementProps {
|
|
|
48
49
|
/** Switches from scrolling to paging. */
|
|
49
50
|
pageSize?: number;
|
|
50
51
|
mode?: Mode;
|
|
51
|
-
/** Up to
|
|
52
|
+
/** Up to three columns, outermost first: `"country,customer"`. */
|
|
52
53
|
groupBy?: string;
|
|
53
54
|
/** The field holding a row's parent key: the rows show as a tree. */
|
|
54
55
|
tree?: string;
|
|
55
56
|
/** The field the parent key refers to; `id` when absent. */
|
|
56
57
|
treeKey?: string;
|
|
58
|
+
/** The field that names a record: `key` in the editing events. */
|
|
59
|
+
rowKey?: string;
|
|
60
|
+
/** The page's filter, as the wire's JSON; and-ed onto every query, not in the view. */
|
|
61
|
+
filter?: string;
|
|
62
|
+
/** An empty row after the last one to type a new record into (`onRowAdd`). */
|
|
63
|
+
addRow?: boolean;
|
|
57
64
|
search?: boolean;
|
|
58
65
|
facets?: boolean;
|
|
59
66
|
toolbar?: boolean;
|
|
60
67
|
columnMenu?: boolean;
|
|
68
|
+
/** *Advanced filter* in the toolbar: the builder of the nested filter. */
|
|
69
|
+
filterBuilder?: boolean;
|
|
61
70
|
selection?: boolean;
|
|
62
71
|
density?: Density;
|
|
63
72
|
/** One of the built-in looks; Base when absent. */
|
|
@@ -93,9 +102,18 @@ export interface OpengridPivotProps extends PivotConnectOptions, ElementProps {
|
|
|
93
102
|
measures?: string;
|
|
94
103
|
/** The filter on the raw rows, as the wire's JSON; part of the view. */
|
|
95
104
|
filter?: string;
|
|
105
|
+
/** Makes every value a button that calls `onDrillDown`. */
|
|
106
|
+
drillDown?: boolean;
|
|
96
107
|
theme?: Theme;
|
|
97
108
|
}
|
|
98
109
|
|
|
110
|
+
/**
|
|
111
|
+
* What the ref holds: the element, carrying the connection's `setCellState`
|
|
112
|
+
* and `setValues` — `useRef<OpengridGridRef>(null)`. The prop takes a ref to
|
|
113
|
+
* the plain element too.
|
|
114
|
+
*/
|
|
115
|
+
export type OpengridGridRef = OpengridGridElement & CellWrites;
|
|
116
|
+
|
|
99
117
|
export const OpengridGrid: ForwardRefExoticComponent<
|
|
100
118
|
OpengridGridProps & RefAttributes<OpengridGridElement>
|
|
101
119
|
>;
|
package/react/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* React components for `@casoon/opengrid
|
|
4
|
+
* React components for `@casoon/opengrid`.
|
|
5
5
|
*
|
|
6
6
|
* A thin shell around `connect`: the component renders the custom element with
|
|
7
7
|
* its attributes, and hands everything else — provider, texts, formats,
|
|
8
|
-
* presentation, choices, the view and the
|
|
9
|
-
* connection. The rules of the module functions live in `connect`, not here.
|
|
8
|
+
* presentation, choices, actions, validators, the view and the event
|
|
9
|
+
* callbacks — to one connection. The rules of the module functions live in `connect`, not here.
|
|
10
10
|
*
|
|
11
11
|
* Three things only a React shell has to know:
|
|
12
12
|
*
|
|
@@ -30,6 +30,9 @@
|
|
|
30
30
|
* - **An option is passed when it is set, or was set last time** — so a prop
|
|
31
31
|
* that goes away is reset (`connect`'s `undefined`), and one that was never
|
|
32
32
|
* there is not reset on every render.
|
|
33
|
+
* - **The ref is the element,** and the element behind it carries the
|
|
34
|
+
* connection's `setCellState` and `setValues` — there is no other object a
|
|
35
|
+
* React ref could be without ceasing to be the element.
|
|
33
36
|
*/
|
|
34
37
|
|
|
35
38
|
import { createElement, forwardRef, useEffect, useImperativeHandle, useRef } from "react";
|
|
@@ -50,6 +53,16 @@ const OPTIONS = [
|
|
|
50
53
|
"onViewChange",
|
|
51
54
|
"onSelectionChange",
|
|
52
55
|
"onCellChange",
|
|
56
|
+
"actions",
|
|
57
|
+
"validators",
|
|
58
|
+
"cellTemplates",
|
|
59
|
+
"detailRenderer",
|
|
60
|
+
"onRowAdd",
|
|
61
|
+
"onPaste",
|
|
62
|
+
"onBulkChange",
|
|
63
|
+
"onRowAction",
|
|
64
|
+
"onDrillDown",
|
|
65
|
+
"onSourceReplaced",
|
|
53
66
|
];
|
|
54
67
|
|
|
55
68
|
/**
|
|
@@ -66,7 +79,15 @@ function component(tag, displayName, attributes, booleans) {
|
|
|
66
79
|
const connection = useRef(null);
|
|
67
80
|
/** The options of the last render, to tell a removed prop from an absent one. */
|
|
68
81
|
const previous = useRef({});
|
|
69
|
-
useImperativeHandle(
|
|
82
|
+
useImperativeHandle(
|
|
83
|
+
ref,
|
|
84
|
+
() =>
|
|
85
|
+
Object.assign(element.current, {
|
|
86
|
+
setCellState: (...args) => connection.current?.setCellState(...args),
|
|
87
|
+
setValues: (values) => connection.current?.setValues(values),
|
|
88
|
+
}),
|
|
89
|
+
[],
|
|
90
|
+
);
|
|
70
91
|
|
|
71
92
|
const rendered = { ref: element };
|
|
72
93
|
const options = {};
|
|
@@ -145,15 +166,19 @@ export const OpengridGrid = component(
|
|
|
145
166
|
groupBy: "group-by",
|
|
146
167
|
tree: "tree",
|
|
147
168
|
treeKey: "tree-key",
|
|
169
|
+
rowKey: "row-key",
|
|
170
|
+
filter: "filter",
|
|
171
|
+
addRow: "add-row",
|
|
148
172
|
search: "search",
|
|
149
173
|
facets: "facets",
|
|
150
174
|
toolbar: "toolbar",
|
|
151
175
|
columnMenu: "column-menu",
|
|
176
|
+
filterBuilder: "filter-builder",
|
|
152
177
|
selection: "selection",
|
|
153
178
|
density: "density",
|
|
154
179
|
theme: "theme",
|
|
155
180
|
},
|
|
156
|
-
["search", "facets", "toolbar", "columnMenu", "selection"],
|
|
181
|
+
["search", "facets", "toolbar", "columnMenu", "filterBuilder", "selection", "addRow"],
|
|
157
182
|
);
|
|
158
183
|
|
|
159
184
|
export const OpengridTable = component(
|
|
@@ -178,7 +203,8 @@ export const OpengridPivot = component(
|
|
|
178
203
|
fields: "fields",
|
|
179
204
|
measures: "measures",
|
|
180
205
|
filter: "filter",
|
|
206
|
+
drillDown: "drill-down",
|
|
181
207
|
theme: "theme",
|
|
182
208
|
},
|
|
183
|
-
["toolbar"],
|
|
209
|
+
["toolbar", "drillDown"],
|
|
184
210
|
);
|
package/svelte/Opengrid.svelte
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
The element and its connection
|
|
2
|
+
The element and its connection — internal; the page uses
|
|
3
3
|
OpengridGrid, OpengridTable and OpengridPivot.
|
|
4
4
|
|
|
5
5
|
The element is rendered with its attributes, so they are in the server HTML
|
|
6
6
|
too; everything else goes to one `connect` from `@casoon/opengrid`:
|
|
7
7
|
|
|
8
8
|
- One effect reads every option — objects through `$state.snapshot`, so a
|
|
9
|
-
change inside a `$state` object counts (for `formats
|
|
10
|
-
keep their identity) — and passes on what is set now or was set last time:
|
|
9
|
+
change inside a `$state` object counts (for `formats` and `validators`,
|
|
10
|
+
the functions in them keep their identity) — and passes on what is set now or was set last time:
|
|
11
11
|
a prop taken away is reset, one never given is left alone (the same rule
|
|
12
12
|
as the React adapter).
|
|
13
13
|
- `bind:view`: the view the reader changed is written into the bound prop;
|
|
@@ -17,7 +17,11 @@
|
|
|
17
17
|
React and Vue. A `view={…}` without `bind:` follows Svelte's rule for
|
|
18
18
|
bindable props: the reader's change becomes the component's own value,
|
|
19
19
|
as a typed-in `value` does on an `<input>` without `bind:`.
|
|
20
|
-
- `bind:element` gives the page the element, as `ref` does in React
|
|
20
|
+
- `bind:element` gives the page the element, as `ref` does in React;
|
|
21
|
+
`bind:this` the component, with the connection's `setCellState` and
|
|
22
|
+
`setValues`.
|
|
23
|
+
- `onrowadd` answers with the new row's state, as `onRowAdd` does in
|
|
24
|
+
`connect`.
|
|
21
25
|
- The connection is made once the element exists and closed when the
|
|
22
26
|
component is destroyed. The element keeps its own state for as long as it
|
|
23
27
|
lives (docs/api.md §Connecting).
|
|
@@ -37,9 +41,19 @@
|
|
|
37
41
|
formats,
|
|
38
42
|
presentation,
|
|
39
43
|
choices,
|
|
44
|
+
actions,
|
|
45
|
+
validators,
|
|
46
|
+
cellTemplates,
|
|
47
|
+
detailRenderer,
|
|
40
48
|
onviewchange,
|
|
41
49
|
onselectionchange,
|
|
42
50
|
oncellchange,
|
|
51
|
+
onrowadd,
|
|
52
|
+
onpaste,
|
|
53
|
+
onbulkchange,
|
|
54
|
+
onrowaction,
|
|
55
|
+
ondrilldown,
|
|
56
|
+
onsourcereplaced,
|
|
43
57
|
...rest
|
|
44
58
|
} = $props();
|
|
45
59
|
|
|
@@ -50,9 +64,13 @@
|
|
|
50
64
|
const options = {
|
|
51
65
|
provider,
|
|
52
66
|
texts: $state.snapshot(texts),
|
|
53
|
-
formats: formats &&
|
|
67
|
+
formats: formats && snapshotKeepingFunctions(formats),
|
|
54
68
|
presentation: $state.snapshot(presentation),
|
|
55
69
|
choices: $state.snapshot(choices),
|
|
70
|
+
actions: $state.snapshot(actions),
|
|
71
|
+
validators: validators && snapshotKeepingFunctions(validators),
|
|
72
|
+
cellTemplates: cellTemplates && snapshotKeepingFunctions(cellTemplates),
|
|
73
|
+
detailRenderer,
|
|
56
74
|
view: $state.snapshot(view),
|
|
57
75
|
defaultView: $state.snapshot(defaultView),
|
|
58
76
|
};
|
|
@@ -67,6 +85,12 @@
|
|
|
67
85
|
},
|
|
68
86
|
onSelectionChange: (detail) => onselectionchange?.(detail),
|
|
69
87
|
onCellChange: (detail) => oncellchange?.(detail),
|
|
88
|
+
onRowAdd: (detail) => onrowadd?.(detail),
|
|
89
|
+
onPaste: (detail) => onpaste?.(detail),
|
|
90
|
+
onBulkChange: (detail) => onbulkchange?.(detail),
|
|
91
|
+
onRowAction: (detail) => onrowaction?.(detail),
|
|
92
|
+
onDrillDown: (detail) => ondrilldown?.(detail),
|
|
93
|
+
onSourceReplaced: (detail) => onsourcereplaced?.(detail),
|
|
70
94
|
};
|
|
71
95
|
if (!connection) {
|
|
72
96
|
if (options.view != null && options.defaultView != null) {
|
|
@@ -87,16 +111,27 @@
|
|
|
87
111
|
});
|
|
88
112
|
});
|
|
89
113
|
|
|
90
|
-
/**
|
|
91
|
-
function
|
|
114
|
+
/** Plain values all the way down, the functions kept as they are. */
|
|
115
|
+
function snapshotKeepingFunctions(value) {
|
|
116
|
+
if (typeof value === "function" || value === null || typeof value !== "object") {
|
|
117
|
+
return value;
|
|
118
|
+
}
|
|
119
|
+
if (Array.isArray(value)) {
|
|
120
|
+
return value.map(snapshotKeepingFunctions);
|
|
121
|
+
}
|
|
92
122
|
return Object.fromEntries(
|
|
93
|
-
Object.entries(value).map(([
|
|
94
|
-
column,
|
|
95
|
-
typeof format === "function" ? format : $state.snapshot(format),
|
|
96
|
-
]),
|
|
123
|
+
Object.entries(value).map(([name, inner]) => [name, snapshotKeepingFunctions(inner)]),
|
|
97
124
|
);
|
|
98
125
|
}
|
|
99
126
|
|
|
127
|
+
export function setCellState(key, column, state, message) {
|
|
128
|
+
connection?.setCellState(key, column, state, message);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function setValues(values) {
|
|
132
|
+
connection?.setValues(values);
|
|
133
|
+
}
|
|
134
|
+
|
|
100
135
|
$effect(() => () => {
|
|
101
136
|
connection?.disconnect();
|
|
102
137
|
connection = null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- `<opengrid-grid>` for Svelte 5
|
|
1
|
+
<!-- `<opengrid-grid>` for Svelte 5. See Opengrid.svelte. -->
|
|
2
2
|
<script>
|
|
3
3
|
import Opengrid from "./Opengrid.svelte";
|
|
4
4
|
|
|
@@ -12,10 +12,14 @@
|
|
|
12
12
|
groupBy,
|
|
13
13
|
tree,
|
|
14
14
|
treeKey,
|
|
15
|
+
rowKey,
|
|
16
|
+
filter,
|
|
17
|
+
addRow = false,
|
|
15
18
|
search = false,
|
|
16
19
|
facets = false,
|
|
17
20
|
toolbar = false,
|
|
18
21
|
columnMenu = false,
|
|
22
|
+
filterBuilder = false,
|
|
19
23
|
selection = false,
|
|
20
24
|
density,
|
|
21
25
|
theme,
|
|
@@ -27,9 +31,20 @@
|
|
|
27
31
|
/** A boolean attribute is present or absent; `false` is absent. */
|
|
28
32
|
const flag = (on) => (on ? "" : undefined);
|
|
29
33
|
const text = (value) => (value == null ? undefined : String(value));
|
|
34
|
+
|
|
35
|
+
let inner;
|
|
36
|
+
|
|
37
|
+
export function setCellState(key, column, state, message) {
|
|
38
|
+
inner.setCellState(key, column, state, message);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function setValues(values) {
|
|
42
|
+
inner.setValues(values);
|
|
43
|
+
}
|
|
30
44
|
</script>
|
|
31
45
|
|
|
32
46
|
<Opengrid
|
|
47
|
+
bind:this={inner}
|
|
33
48
|
tag="opengrid-grid"
|
|
34
49
|
attributes={{
|
|
35
50
|
label,
|
|
@@ -41,10 +56,14 @@
|
|
|
41
56
|
"group-by": groupBy,
|
|
42
57
|
tree,
|
|
43
58
|
"tree-key": treeKey,
|
|
59
|
+
"row-key": rowKey,
|
|
60
|
+
filter,
|
|
61
|
+
"add-row": flag(addRow),
|
|
44
62
|
search: flag(search),
|
|
45
63
|
facets: flag(facets),
|
|
46
64
|
toolbar: flag(toolbar),
|
|
47
65
|
"column-menu": flag(columnMenu),
|
|
66
|
+
"filter-builder": flag(filterBuilder),
|
|
48
67
|
selection: flag(selection),
|
|
49
68
|
density,
|
|
50
69
|
theme,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<!-- `<opengrid-pivot>` for Svelte 5
|
|
1
|
+
<!-- `<opengrid-pivot>` for Svelte 5. See Opengrid.svelte. -->
|
|
2
2
|
<script>
|
|
3
3
|
import Opengrid from "./Opengrid.svelte";
|
|
4
4
|
|
|
5
|
-
let { label, datasource, rows, columns, values, sort, collapsed, toolbar = false, fields, measures, filter, theme, view = $bindable(), element = $bindable(), ...rest } = $props();
|
|
5
|
+
let { label, datasource, rows, columns, values, sort, collapsed, toolbar = false, fields, measures, filter, drillDown = false, theme, view = $bindable(), element = $bindable(), ...rest } = $props();
|
|
6
6
|
|
|
7
7
|
/** A boolean attribute is present or absent; `false` is absent. */
|
|
8
8
|
const flag = (on) => (on ? "" : undefined);
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
<Opengrid
|
|
12
12
|
tag="opengrid-pivot"
|
|
13
|
-
attributes={{ label, datasource, rows, columns, values, sort, collapsed, toolbar: flag(toolbar), fields, measures, filter, theme }}
|
|
13
|
+
attributes={{ label, datasource, rows, columns, values, sort, collapsed, toolbar: flag(toolbar), fields, measures, filter, "drill-down": flag(drillDown), theme }}
|
|
14
14
|
bind:view
|
|
15
15
|
bind:element
|
|
16
16
|
{...rest}
|