@casoon/opengrid 0.1.0 → 0.2.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 +19 -0
- package/README.md +4 -2
- package/engine/opengrid_wasm_bg.wasm +0 -0
- package/package.json +47 -3
- package/pkg/opengrid_web_components.js +8 -8
- package/pkg/opengrid_web_components_bg.wasm +0 -0
- package/react/index.d.ts +84 -0
- package/react/index.js +174 -0
- package/svelte/Opengrid.svelte +106 -0
- package/svelte/OpengridGrid.svelte +49 -0
- package/svelte/OpengridPivot.svelte +14 -0
- package/svelte/OpengridTable.svelte +8 -0
- package/svelte/index.d.ts +81 -0
- package/svelte/index.js +11 -0
- package/vue/index.d.ts +72 -0
- package/vue/index.js +166 -0
- /package/pkg/snippets/{opengrid-web-core-e0ef3c8948ce8a1e → opengrid-web-core-13b0d2b2f5d74a24}/inline0.js +0 -0
- /package/pkg/snippets/{opengrid-web-core-e0ef3c8948ce8a1e → opengrid-web-core-13b0d2b2f5d74a24}/inline1.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,25 @@ Two things belong in every release entry and are easy to leave out:
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [0.2.0] — 2026-09-27
|
|
22
|
+
|
|
23
|
+
**Screen-reader pairings tested: none yet** — unchanged since 0.1.0
|
|
24
|
+
([issue #5](https://github.com/casoon/opengrid/issues/5)). **Browsers:** as in 0.1.0.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- **One package instead of four** ([#27](https://github.com/casoon/opengrid/issues/27)).
|
|
29
|
+
The React, Vue and Svelte components are subpaths of `@casoon/opengrid`:
|
|
30
|
+
`@casoon/opengrid/react`, `@casoon/opengrid/vue`, `@casoon/opengrid/svelte`. `react`,
|
|
31
|
+
`vue` and `svelte` are optional peer dependencies — a page without a framework installs
|
|
32
|
+
none of them.
|
|
33
|
+
|
|
34
|
+
**What breaks:** `@casoon/opengrid-react`, `@casoon/opengrid-vue` and
|
|
35
|
+
`@casoon/opengrid-svelte` are gone (unpublished from npm within 72 hours of 0.1.0).
|
|
36
|
+
Replace the import — `from "@casoon/opengrid-react"` becomes
|
|
37
|
+
`from "@casoon/opengrid/react"` — and drop the package from `dependencies`. The
|
|
38
|
+
components, their props and their events are unchanged.
|
|
39
|
+
|
|
21
40
|
## [0.1.0] — 2026-09-26
|
|
22
41
|
|
|
23
42
|
The first release: `@casoon/opengrid`, `@casoon/opengrid-react`,
|
package/README.md
CHANGED
|
@@ -73,12 +73,14 @@ See [Where queries run](https://github.com/casoon/opengrid/blob/main/docs/guides
|
|
|
73
73
|
|
|
74
74
|
## React, Vue, Svelte
|
|
75
75
|
|
|
76
|
+
One package: the components are its subpaths, and the framework is an optional peer.
|
|
77
|
+
|
|
76
78
|
```sh
|
|
77
|
-
npm install @casoon/opengrid
|
|
79
|
+
npm install @casoon/opengrid react # or vue, svelte
|
|
78
80
|
```
|
|
79
81
|
|
|
80
82
|
```jsx
|
|
81
|
-
import { OpengridGrid } from "@casoon/opengrid
|
|
83
|
+
import { OpengridGrid } from "@casoon/opengrid/react"; // or /vue, /svelte
|
|
82
84
|
|
|
83
85
|
<OpengridGrid label="Orders" datasource="orders" columns="id,customer,amount"
|
|
84
86
|
provider={provider} view={view} onViewChange={setView} />
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@casoon/opengrid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Accessible data grid, table and pivot as web components, driven by a portable Rust/WASM query engine.",
|
|
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": [
|
|
7
7
|
"datagrid",
|
|
8
8
|
"pivot",
|
|
9
9
|
"web-components",
|
|
10
10
|
"accessibility",
|
|
11
|
-
"wasm"
|
|
11
|
+
"wasm",
|
|
12
|
+
"react",
|
|
13
|
+
"vue",
|
|
14
|
+
"svelte"
|
|
12
15
|
],
|
|
13
16
|
"license": "MIT OR Apache-2.0",
|
|
14
17
|
"repository": {
|
|
@@ -28,6 +31,19 @@
|
|
|
28
31
|
"types": "./loader.d.ts",
|
|
29
32
|
"default": "./loader.js"
|
|
30
33
|
},
|
|
34
|
+
"./react": {
|
|
35
|
+
"types": "./react/index.d.ts",
|
|
36
|
+
"default": "./react/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./vue": {
|
|
39
|
+
"types": "./vue/index.d.ts",
|
|
40
|
+
"default": "./vue/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./svelte": {
|
|
43
|
+
"types": "./svelte/index.d.ts",
|
|
44
|
+
"svelte": "./svelte/index.js",
|
|
45
|
+
"default": "./svelte/index.js"
|
|
46
|
+
},
|
|
31
47
|
"./worker.js": "./worker.js",
|
|
32
48
|
"./pkg/*": "./pkg/*",
|
|
33
49
|
"./engine/*": "./engine/*",
|
|
@@ -42,6 +58,9 @@
|
|
|
42
58
|
"loader.js",
|
|
43
59
|
"loader.d.ts",
|
|
44
60
|
"worker.js",
|
|
61
|
+
"react/",
|
|
62
|
+
"vue/",
|
|
63
|
+
"svelte/",
|
|
45
64
|
"pkg/",
|
|
46
65
|
"engine/",
|
|
47
66
|
"LICENSE-MIT",
|
|
@@ -49,6 +68,31 @@
|
|
|
49
68
|
"README.md",
|
|
50
69
|
"CHANGELOG.md"
|
|
51
70
|
],
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"@types/react": ">=18",
|
|
73
|
+
"react": ">=18",
|
|
74
|
+
"svelte": "^5.0.0",
|
|
75
|
+
"vue": ">=3.3"
|
|
76
|
+
},
|
|
77
|
+
"peerDependenciesMeta": {
|
|
78
|
+
"@types/react": {
|
|
79
|
+
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"react": {
|
|
82
|
+
"optional": true
|
|
83
|
+
},
|
|
84
|
+
"svelte": {
|
|
85
|
+
"optional": true
|
|
86
|
+
},
|
|
87
|
+
"vue": {
|
|
88
|
+
"optional": true
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"devDependencies": {
|
|
92
|
+
"@types/react": "19.3.0",
|
|
93
|
+
"svelte": "5.57.1",
|
|
94
|
+
"vue": "3.5.43"
|
|
95
|
+
},
|
|
52
96
|
"engines": {
|
|
53
97
|
"node": ">=18"
|
|
54
98
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* @ts-self-types="./opengrid_web_components.d.ts" */
|
|
2
|
-
import { __opengrid_define_element } from './snippets/opengrid-web-core-
|
|
3
|
-
import * as import1 from "./snippets/opengrid-web-core-
|
|
4
|
-
import * as import2 from "./snippets/opengrid-web-core-
|
|
5
|
-
import * as import3 from "./snippets/opengrid-web-core-
|
|
2
|
+
import { __opengrid_define_element } from './snippets/opengrid-web-core-13b0d2b2f5d74a24/inline1.js';
|
|
3
|
+
import * as import1 from "./snippets/opengrid-web-core-13b0d2b2f5d74a24/inline0.js"
|
|
4
|
+
import * as import2 from "./snippets/opengrid-web-core-13b0d2b2f5d74a24/inline0.js"
|
|
5
|
+
import * as import3 from "./snippets/opengrid-web-core-13b0d2b2f5d74a24/inline0.js"
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -270,7 +270,7 @@ function __wbg_get_imports() {
|
|
|
270
270
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
271
271
|
return ret;
|
|
272
272
|
},
|
|
273
|
-
|
|
273
|
+
__wbg___opengrid_define_element_2b856416c859acf2: function(arg0, arg1, arg2, arg3, arg4, arg5) {
|
|
274
274
|
__opengrid_define_element(getStringFromWasm0(arg0, arg1), arg2, arg3, arg4, arg5);
|
|
275
275
|
},
|
|
276
276
|
__wbg___wbindgen_boolean_get_fa956cfa2d1bd751: function(arg0) {
|
|
@@ -896,9 +896,9 @@ function __wbg_get_imports() {
|
|
|
896
896
|
return {
|
|
897
897
|
__proto__: null,
|
|
898
898
|
"./opengrid_web_components_bg.js": import0,
|
|
899
|
-
"./snippets/opengrid-web-core-
|
|
900
|
-
"./snippets/opengrid-web-core-
|
|
901
|
-
"./snippets/opengrid-web-core-
|
|
899
|
+
"./snippets/opengrid-web-core-13b0d2b2f5d74a24/inline0.js": import1,
|
|
900
|
+
"./snippets/opengrid-web-core-13b0d2b2f5d74a24/inline0.js": import2,
|
|
901
|
+
"./snippets/opengrid-web-core-13b0d2b2f5d74a24/inline0.js": import3,
|
|
902
902
|
};
|
|
903
903
|
}
|
|
904
904
|
|
|
Binary file
|
package/react/index.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for `@casoon/opengrid/react` (plan point 77).
|
|
3
|
+
*
|
|
4
|
+
* The props are the element's attributes in camelCase plus the options of
|
|
5
|
+
* `connect` from `@casoon/opengrid` — no names of their own. Everything else
|
|
6
|
+
* (`id`, `className`, `style`, `aria-*`, `data-*`) goes to the element.
|
|
7
|
+
*
|
|
8
|
+
* Three things to know, from `connect`:
|
|
9
|
+
*
|
|
10
|
+
* - `provider` and format functions compare by **identity**. An inline
|
|
11
|
+
* `provider={createRestProvider(…)}` is a new provider on every render, and
|
|
12
|
+
* each one asks the source again — create it once (`useMemo`, or outside the
|
|
13
|
+
* component).
|
|
14
|
+
* - `view` is controlled at **render**: a view the page does not take back
|
|
15
|
+
* from `onViewChange` is written again the next time the component renders.
|
|
16
|
+
* - `density` and `groupBy` are attributes the reader can change too (they are
|
|
17
|
+
* part of the view). As props they set the start; with a controlled `view`,
|
|
18
|
+
* leave them out and let the view carry them.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import type { ForwardRefExoticComponent, HTMLAttributes, RefAttributes } from "react";
|
|
22
|
+
import type {
|
|
23
|
+
ConnectOptions,
|
|
24
|
+
Density,
|
|
25
|
+
Mode,
|
|
26
|
+
OpengridGridElement,
|
|
27
|
+
OpengridPivotElement,
|
|
28
|
+
OpengridTableElement,
|
|
29
|
+
} from "../loader.js";
|
|
30
|
+
|
|
31
|
+
/** What the element itself takes from React, minus what the component owns. */
|
|
32
|
+
type ElementProps = Omit<
|
|
33
|
+
HTMLAttributes<HTMLElement>,
|
|
34
|
+
"children" | keyof ConnectOptions
|
|
35
|
+
>;
|
|
36
|
+
|
|
37
|
+
export interface OpengridGridProps extends ConnectOptions, ElementProps {
|
|
38
|
+
/** The accessible name of the table. */
|
|
39
|
+
label?: string;
|
|
40
|
+
/** The source; becomes the query's `source`. */
|
|
41
|
+
datasource?: string;
|
|
42
|
+
/** Comma-separated output fields, in order. */
|
|
43
|
+
columns?: string;
|
|
44
|
+
/** Rows rendered and fetched at once while scrolling. Default 40. */
|
|
45
|
+
windowSize?: number;
|
|
46
|
+
/** Switches from scrolling to paging. */
|
|
47
|
+
pageSize?: number;
|
|
48
|
+
mode?: Mode;
|
|
49
|
+
/** Up to two columns, outermost first: `"country,customer"`. */
|
|
50
|
+
groupBy?: string;
|
|
51
|
+
search?: boolean;
|
|
52
|
+
facets?: boolean;
|
|
53
|
+
toolbar?: boolean;
|
|
54
|
+
columnMenu?: boolean;
|
|
55
|
+
selection?: boolean;
|
|
56
|
+
density?: Density;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface OpengridTableProps extends ConnectOptions, ElementProps {
|
|
60
|
+
label?: string;
|
|
61
|
+
datasource?: string;
|
|
62
|
+
columns?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface OpengridPivotProps extends ConnectOptions, ElementProps {
|
|
66
|
+
label?: string;
|
|
67
|
+
datasource?: string;
|
|
68
|
+
/** Comma-separated row dimensions, outermost first. */
|
|
69
|
+
rows?: string;
|
|
70
|
+
/** Comma-separated column dimensions; V1 allows one. */
|
|
71
|
+
columns?: string;
|
|
72
|
+
/** The measures as the contract's JSON. */
|
|
73
|
+
values?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const OpengridGrid: ForwardRefExoticComponent<
|
|
77
|
+
OpengridGridProps & RefAttributes<OpengridGridElement>
|
|
78
|
+
>;
|
|
79
|
+
export const OpengridTable: ForwardRefExoticComponent<
|
|
80
|
+
OpengridTableProps & RefAttributes<OpengridTableElement>
|
|
81
|
+
>;
|
|
82
|
+
export const OpengridPivot: ForwardRefExoticComponent<
|
|
83
|
+
OpengridPivotProps & RefAttributes<OpengridPivotElement>
|
|
84
|
+
>;
|
package/react/index.js
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* React components for `@casoon/opengrid` (plan point 77, E32).
|
|
5
|
+
*
|
|
6
|
+
* A thin shell around `connect`: the component renders the custom element with
|
|
7
|
+
* its attributes, and hands everything else — provider, texts, formats,
|
|
8
|
+
* presentation, choices, the view and the three event callbacks — to one
|
|
9
|
+
* connection. The rules of the module functions live in `connect`, not here.
|
|
10
|
+
*
|
|
11
|
+
* Three things only a React shell has to know:
|
|
12
|
+
*
|
|
13
|
+
* - **Attributes are rendered, not set later.** So they are in the server
|
|
14
|
+
* HTML too. A boolean attribute (`selection`, `toolbar`, …) is present or
|
|
15
|
+
* absent: React 18 would write `selection="false"` for `false`, and for a
|
|
16
|
+
* boolean attribute presence is what counts, so `true` becomes `""` and
|
|
17
|
+
* `false` leaves it out — the same in React 18 and 19. (`""` is safe only
|
|
18
|
+
* because the element has no JS property of those names: React 19 sets a
|
|
19
|
+
* property where one exists, and `""` is falsy.) The HTML booleans a page
|
|
20
|
+
* passes through — `hidden`, `inert`, `autoFocus` — *are* properties of
|
|
21
|
+
* every element, so they go on as `true`, which React 19 sets as the
|
|
22
|
+
* property and React 18 writes as a present attribute; `false` leaves them
|
|
23
|
+
* out, where React 18 would write `hidden="false"` and hide the grid.
|
|
24
|
+
* - **`"use client"`:** hooks and refs, so a Server Component imports it as a
|
|
25
|
+
* client boundary.
|
|
26
|
+
* - **StrictMode mounts twice in development**, and that costs nothing:
|
|
27
|
+
* `connect` applies only once the module has loaded, a microtask later at
|
|
28
|
+
* the earliest, so the first connection is disconnected before it has
|
|
29
|
+
* written anything, and only the second one asks the source.
|
|
30
|
+
* - **An option is passed when it is set, or was set last time** — so a prop
|
|
31
|
+
* that goes away is reset (`connect`'s `undefined`), and one that was never
|
|
32
|
+
* there is not reset on every render.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
import { createElement, forwardRef, useEffect, useImperativeHandle, useRef } from "react";
|
|
36
|
+
import { connect } from "../loader.js";
|
|
37
|
+
|
|
38
|
+
/** The HTML boolean attributes a page may pass through, by prop name. */
|
|
39
|
+
const HTML_BOOLEANS = { hidden: "hidden", inert: "inert", autoFocus: "autofocus" };
|
|
40
|
+
|
|
41
|
+
/** What `connect` takes, by prop name. */
|
|
42
|
+
const OPTIONS = [
|
|
43
|
+
"provider",
|
|
44
|
+
"texts",
|
|
45
|
+
"formats",
|
|
46
|
+
"presentation",
|
|
47
|
+
"choices",
|
|
48
|
+
"view",
|
|
49
|
+
"defaultView",
|
|
50
|
+
"onViewChange",
|
|
51
|
+
"onSelectionChange",
|
|
52
|
+
"onCellChange",
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Builds one component.
|
|
57
|
+
*
|
|
58
|
+
* @param {string} tag the custom element.
|
|
59
|
+
* @param {string} displayName the component's name in the React tools.
|
|
60
|
+
* @param {Record<string, string>} attributes prop name → attribute name.
|
|
61
|
+
* @param {string[]} booleans the props that are boolean attributes.
|
|
62
|
+
*/
|
|
63
|
+
function component(tag, displayName, attributes, booleans) {
|
|
64
|
+
const Component = forwardRef(function OpengridComponent(props, ref) {
|
|
65
|
+
const element = useRef(null);
|
|
66
|
+
const connection = useRef(null);
|
|
67
|
+
/** The options of the last render, to tell a removed prop from an absent one. */
|
|
68
|
+
const previous = useRef({});
|
|
69
|
+
useImperativeHandle(ref, () => element.current, []);
|
|
70
|
+
|
|
71
|
+
const rendered = { ref: element };
|
|
72
|
+
const options = {};
|
|
73
|
+
for (const [name, value] of Object.entries(props)) {
|
|
74
|
+
if (OPTIONS.includes(name)) {
|
|
75
|
+
options[name] = value;
|
|
76
|
+
} else if (name in HTML_BOOLEANS) {
|
|
77
|
+
rendered[HTML_BOOLEANS[name]] = value ? true : undefined;
|
|
78
|
+
} else if (name in attributes) {
|
|
79
|
+
if (booleans.includes(name)) {
|
|
80
|
+
rendered[attributes[name]] = value ? "" : undefined;
|
|
81
|
+
} else {
|
|
82
|
+
rendered[attributes[name]] = value == null ? undefined : String(value);
|
|
83
|
+
}
|
|
84
|
+
} else if (name === "className") {
|
|
85
|
+
// `class` on a custom element: React 18 would write `classname`.
|
|
86
|
+
rendered.class = value;
|
|
87
|
+
} else {
|
|
88
|
+
rendered[name] = value;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Unmount: the listeners go; the element keeps its state for as long as
|
|
93
|
+
// it lives (docs/api.md §Connecting).
|
|
94
|
+
useEffect(
|
|
95
|
+
() => () => {
|
|
96
|
+
connection.current?.disconnect();
|
|
97
|
+
connection.current = null;
|
|
98
|
+
},
|
|
99
|
+
[],
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// Every render: connect once, then update — `connect` writes only what
|
|
103
|
+
// changed, so passing everything each time costs nothing.
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
const last = previous.current;
|
|
106
|
+
previous.current = options;
|
|
107
|
+
if (connection.current) {
|
|
108
|
+
const changed = {};
|
|
109
|
+
for (const name of OPTIONS) {
|
|
110
|
+
if (options[name] !== undefined || last[name] !== undefined) {
|
|
111
|
+
changed[name] = options[name];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
connection.current.update(changed);
|
|
115
|
+
} else {
|
|
116
|
+
if (props.view != null && props.defaultView != null) {
|
|
117
|
+
console.warn(
|
|
118
|
+
`[opengrid] <${displayName}> has both view and defaultView; the view is controlled and leads`,
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
// Only what is set: `texts={undefined}` is no texts, not a reset.
|
|
122
|
+
connection.current = connect(
|
|
123
|
+
element.current,
|
|
124
|
+
Object.fromEntries(Object.entries(options).filter(([, value]) => value !== undefined)),
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
return createElement(tag, rendered);
|
|
130
|
+
});
|
|
131
|
+
Component.displayName = displayName;
|
|
132
|
+
return Component;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export const OpengridGrid = component(
|
|
136
|
+
"opengrid-grid",
|
|
137
|
+
"OpengridGrid",
|
|
138
|
+
{
|
|
139
|
+
label: "label",
|
|
140
|
+
datasource: "datasource",
|
|
141
|
+
columns: "columns",
|
|
142
|
+
windowSize: "window-size",
|
|
143
|
+
pageSize: "page-size",
|
|
144
|
+
mode: "mode",
|
|
145
|
+
groupBy: "group-by",
|
|
146
|
+
search: "search",
|
|
147
|
+
facets: "facets",
|
|
148
|
+
toolbar: "toolbar",
|
|
149
|
+
columnMenu: "column-menu",
|
|
150
|
+
selection: "selection",
|
|
151
|
+
density: "density",
|
|
152
|
+
},
|
|
153
|
+
["search", "facets", "toolbar", "columnMenu", "selection"],
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
export const OpengridTable = component(
|
|
157
|
+
"opengrid-table",
|
|
158
|
+
"OpengridTable",
|
|
159
|
+
{ label: "label", datasource: "datasource", columns: "columns" },
|
|
160
|
+
[],
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
export const OpengridPivot = component(
|
|
164
|
+
"opengrid-pivot",
|
|
165
|
+
"OpengridPivot",
|
|
166
|
+
{
|
|
167
|
+
label: "label",
|
|
168
|
+
datasource: "datasource",
|
|
169
|
+
rows: "rows",
|
|
170
|
+
columns: "columns",
|
|
171
|
+
values: "values",
|
|
172
|
+
},
|
|
173
|
+
[],
|
|
174
|
+
);
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The element and its connection (plan point 79) — internal; the page uses
|
|
3
|
+
OpengridGrid, OpengridTable and OpengridPivot.
|
|
4
|
+
|
|
5
|
+
The element is rendered with its attributes, so they are in the server HTML
|
|
6
|
+
too; everything else goes to one `connect` from `@casoon/opengrid`:
|
|
7
|
+
|
|
8
|
+
- One effect reads every option — objects through `$state.snapshot`, so a
|
|
9
|
+
change inside a `$state` object counts (for `formats`, the functions in it
|
|
10
|
+
keep their identity) — and passes on what is set now or was set last time:
|
|
11
|
+
a prop taken away is reset, one never given is left alone (the same rule
|
|
12
|
+
as the React adapter).
|
|
13
|
+
- `bind:view`: the view the reader changed is written into the bound prop;
|
|
14
|
+
the effect then hands it back, and `connect` knows that is no change. A
|
|
15
|
+
binding that refuses it (`bind:view={get, set}` whose setter keeps the old
|
|
16
|
+
view) gets its own view written back after the tick — controlled, as in
|
|
17
|
+
React and Vue. A `view={…}` without `bind:` follows Svelte's rule for
|
|
18
|
+
bindable props: the reader's change becomes the component's own value,
|
|
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.
|
|
21
|
+
- The connection is made once the element exists and closed when the
|
|
22
|
+
component is destroyed. The element keeps its own state for as long as it
|
|
23
|
+
lives (docs/api.md §Connecting).
|
|
24
|
+
-->
|
|
25
|
+
<script>
|
|
26
|
+
import { tick, untrack } from "svelte";
|
|
27
|
+
import { connect } from "../loader.js";
|
|
28
|
+
|
|
29
|
+
let {
|
|
30
|
+
tag,
|
|
31
|
+
attributes,
|
|
32
|
+
view = $bindable(),
|
|
33
|
+
element = $bindable(),
|
|
34
|
+
defaultView,
|
|
35
|
+
provider,
|
|
36
|
+
texts,
|
|
37
|
+
formats,
|
|
38
|
+
presentation,
|
|
39
|
+
choices,
|
|
40
|
+
onviewchange,
|
|
41
|
+
onselectionchange,
|
|
42
|
+
oncellchange,
|
|
43
|
+
...rest
|
|
44
|
+
} = $props();
|
|
45
|
+
|
|
46
|
+
let connection = null;
|
|
47
|
+
let previous = {};
|
|
48
|
+
|
|
49
|
+
$effect(() => {
|
|
50
|
+
const options = {
|
|
51
|
+
provider,
|
|
52
|
+
texts: $state.snapshot(texts),
|
|
53
|
+
formats: formats && snapshotFormats(formats),
|
|
54
|
+
presentation: $state.snapshot(presentation),
|
|
55
|
+
choices: $state.snapshot(choices),
|
|
56
|
+
view: $state.snapshot(view),
|
|
57
|
+
defaultView: $state.snapshot(defaultView),
|
|
58
|
+
};
|
|
59
|
+
untrack(() => {
|
|
60
|
+
const callbacks = {
|
|
61
|
+
onViewChange: (next) => {
|
|
62
|
+
view = next;
|
|
63
|
+
onviewchange?.(next);
|
|
64
|
+
tick().then(() => {
|
|
65
|
+
if (view != null) connection?.update({ view: $state.snapshot(view) });
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
onSelectionChange: (detail) => onselectionchange?.(detail),
|
|
69
|
+
onCellChange: (detail) => oncellchange?.(detail),
|
|
70
|
+
};
|
|
71
|
+
if (!connection) {
|
|
72
|
+
if (options.view != null && options.defaultView != null) {
|
|
73
|
+
console.warn(`[opengrid] <${tag}> has both view and defaultView; the view is controlled and leads`);
|
|
74
|
+
}
|
|
75
|
+
const set = Object.entries(options).filter(([, value]) => value !== undefined);
|
|
76
|
+
connection = connect(element, { ...Object.fromEntries(set), ...callbacks });
|
|
77
|
+
} else {
|
|
78
|
+
const changed = { ...callbacks };
|
|
79
|
+
for (const [name, value] of Object.entries(options)) {
|
|
80
|
+
if (value !== undefined || previous[name] !== undefined) {
|
|
81
|
+
changed[name] = value;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
connection.update(changed);
|
|
85
|
+
}
|
|
86
|
+
previous = options;
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
/** The formats as plain values, their functions kept as they are. */
|
|
91
|
+
function snapshotFormats(value) {
|
|
92
|
+
return Object.fromEntries(
|
|
93
|
+
Object.entries(value).map(([column, format]) => [
|
|
94
|
+
column,
|
|
95
|
+
typeof format === "function" ? format : $state.snapshot(format),
|
|
96
|
+
]),
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
$effect(() => () => {
|
|
101
|
+
connection?.disconnect();
|
|
102
|
+
connection = null;
|
|
103
|
+
});
|
|
104
|
+
</script>
|
|
105
|
+
|
|
106
|
+
<svelte:element this={tag} bind:this={element} {...attributes} {...rest}></svelte:element>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<!-- `<opengrid-grid>` for Svelte 5 (plan point 79). See Opengrid.svelte. -->
|
|
2
|
+
<script>
|
|
3
|
+
import Opengrid from "./Opengrid.svelte";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
label,
|
|
7
|
+
datasource,
|
|
8
|
+
columns,
|
|
9
|
+
windowSize,
|
|
10
|
+
pageSize,
|
|
11
|
+
mode,
|
|
12
|
+
groupBy,
|
|
13
|
+
search = false,
|
|
14
|
+
facets = false,
|
|
15
|
+
toolbar = false,
|
|
16
|
+
columnMenu = false,
|
|
17
|
+
selection = false,
|
|
18
|
+
density,
|
|
19
|
+
view = $bindable(),
|
|
20
|
+
element = $bindable(),
|
|
21
|
+
...rest
|
|
22
|
+
} = $props();
|
|
23
|
+
|
|
24
|
+
/** A boolean attribute is present or absent; `false` is absent. */
|
|
25
|
+
const flag = (on) => (on ? "" : undefined);
|
|
26
|
+
const text = (value) => (value == null ? undefined : String(value));
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<Opengrid
|
|
30
|
+
tag="opengrid-grid"
|
|
31
|
+
attributes={{
|
|
32
|
+
label,
|
|
33
|
+
datasource,
|
|
34
|
+
columns,
|
|
35
|
+
"window-size": text(windowSize),
|
|
36
|
+
"page-size": text(pageSize),
|
|
37
|
+
mode,
|
|
38
|
+
"group-by": groupBy,
|
|
39
|
+
search: flag(search),
|
|
40
|
+
facets: flag(facets),
|
|
41
|
+
toolbar: flag(toolbar),
|
|
42
|
+
"column-menu": flag(columnMenu),
|
|
43
|
+
selection: flag(selection),
|
|
44
|
+
density,
|
|
45
|
+
}}
|
|
46
|
+
bind:view
|
|
47
|
+
bind:element
|
|
48
|
+
{...rest}
|
|
49
|
+
/>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!-- `<opengrid-pivot>` for Svelte 5 (plan point 79). See Opengrid.svelte. -->
|
|
2
|
+
<script>
|
|
3
|
+
import Opengrid from "./Opengrid.svelte";
|
|
4
|
+
|
|
5
|
+
let { label, datasource, rows, columns, values, view = $bindable(), element = $bindable(), ...rest } = $props();
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<Opengrid
|
|
9
|
+
tag="opengrid-pivot"
|
|
10
|
+
attributes={{ label, datasource, rows, columns, values }}
|
|
11
|
+
bind:view
|
|
12
|
+
bind:element
|
|
13
|
+
{...rest}
|
|
14
|
+
/>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<!-- `<opengrid-table>` for Svelte 5 (plan point 79). See Opengrid.svelte. -->
|
|
2
|
+
<script>
|
|
3
|
+
import Opengrid from "./Opengrid.svelte";
|
|
4
|
+
|
|
5
|
+
let { label, datasource, columns, view = $bindable(), element = $bindable(), ...rest } = $props();
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<Opengrid tag="opengrid-table" attributes={{ label, datasource, columns }} bind:view bind:element {...rest} />
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for `@casoon/opengrid/svelte` (plan point 79).
|
|
3
|
+
*
|
|
4
|
+
* The props are the element's attributes in camelCase plus the options of
|
|
5
|
+
* `connect` from `@casoon/opengrid`, with the callbacks in Svelte's own
|
|
6
|
+
* spelling — `onviewchange`, `onselectionchange`, `oncellchange` — `view`
|
|
7
|
+
* bindable (`bind:view`), and the element itself through `bind:element`.
|
|
8
|
+
* Everything else (`id`, `class`, `style`, `aria-*`) goes to the element.
|
|
9
|
+
*
|
|
10
|
+
* `view` is controlled through `bind:view`: a binding whose setter refuses the
|
|
11
|
+
* reader's change gets its view written back. A `view={…}` without `bind:`
|
|
12
|
+
* follows Svelte's rule for bindable props — the reader's change becomes the
|
|
13
|
+
* component's own value, as on an `<input>` without `bind:`.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { Component } from "svelte";
|
|
17
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
18
|
+
import type {
|
|
19
|
+
CellChangeDetail,
|
|
20
|
+
ConnectOptions,
|
|
21
|
+
Density,
|
|
22
|
+
Mode,
|
|
23
|
+
SelectionChangeDetail,
|
|
24
|
+
View,
|
|
25
|
+
} from "../loader.js";
|
|
26
|
+
|
|
27
|
+
/** `connect`'s options, the callbacks in Svelte's spelling. */
|
|
28
|
+
type Options = Omit<ConnectOptions, "onViewChange" | "onSelectionChange" | "onCellChange"> & {
|
|
29
|
+
/** The element, for `bind:element`. */
|
|
30
|
+
element?: HTMLElement;
|
|
31
|
+
/** The reader changed the view; `bind:view` has it already. */
|
|
32
|
+
onviewchange?: (view: View) => void;
|
|
33
|
+
onselectionchange?: (detail: SelectionChangeDetail) => void;
|
|
34
|
+
oncellchange?: (detail: CellChangeDetail) => void;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** What the element itself takes, minus what the component owns. */
|
|
38
|
+
type ElementProps = Omit<HTMLAttributes<HTMLElement>, "children" | keyof Options>;
|
|
39
|
+
|
|
40
|
+
export interface OpengridGridProps extends Options, ElementProps {
|
|
41
|
+
/** The accessible name of the table. */
|
|
42
|
+
label?: string;
|
|
43
|
+
/** The source; becomes the query's `source`. */
|
|
44
|
+
datasource?: string;
|
|
45
|
+
/** Comma-separated output fields, in order. */
|
|
46
|
+
columns?: string;
|
|
47
|
+
/** Rows rendered and fetched at once while scrolling. Default 40. */
|
|
48
|
+
windowSize?: number;
|
|
49
|
+
/** Switches from scrolling to paging. */
|
|
50
|
+
pageSize?: number;
|
|
51
|
+
mode?: Mode;
|
|
52
|
+
/** Up to two columns, outermost first: `"country,customer"`. */
|
|
53
|
+
groupBy?: string;
|
|
54
|
+
search?: boolean;
|
|
55
|
+
facets?: boolean;
|
|
56
|
+
toolbar?: boolean;
|
|
57
|
+
columnMenu?: boolean;
|
|
58
|
+
selection?: boolean;
|
|
59
|
+
density?: Density;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface OpengridTableProps extends Options, ElementProps {
|
|
63
|
+
label?: string;
|
|
64
|
+
datasource?: string;
|
|
65
|
+
columns?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface OpengridPivotProps extends Options, ElementProps {
|
|
69
|
+
label?: string;
|
|
70
|
+
datasource?: string;
|
|
71
|
+
/** Comma-separated row dimensions, outermost first. */
|
|
72
|
+
rows?: string;
|
|
73
|
+
/** Comma-separated column dimensions; V1 allows one. */
|
|
74
|
+
columns?: string;
|
|
75
|
+
/** The measures as the contract's JSON. */
|
|
76
|
+
values?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const OpengridGrid: Component<OpengridGridProps, {}, "view" | "element">;
|
|
80
|
+
export const OpengridTable: Component<OpengridTableProps, {}, "view" | "element">;
|
|
81
|
+
export const OpengridPivot: Component<OpengridPivotProps, {}, "view" | "element">;
|
package/svelte/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte 5 components for `@casoon/opengrid` (plan point 79, E32).
|
|
3
|
+
*
|
|
4
|
+
* Shipped as `.svelte` sources, the Svelte convention: the page's bundler
|
|
5
|
+
* compiles them with the page's Svelte. The three components are thin: each
|
|
6
|
+
* maps its props onto its element's attributes and hands the rest to
|
|
7
|
+
* `Opengrid.svelte`, which renders the element and keeps one `connect`.
|
|
8
|
+
*/
|
|
9
|
+
export { default as OpengridGrid } from "./OpengridGrid.svelte";
|
|
10
|
+
export { default as OpengridTable } from "./OpengridTable.svelte";
|
|
11
|
+
export { default as OpengridPivot } from "./OpengridPivot.svelte";
|
package/vue/index.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for `@casoon/opengrid/vue` (plan point 78).
|
|
3
|
+
*
|
|
4
|
+
* The props are the element's attributes in camelCase plus the options of
|
|
5
|
+
* `connect` from `@casoon/opengrid`; the callbacks are Vue events instead:
|
|
6
|
+
* `update:view` (so `v-model:view` works), `selectionChange` and `cellChange`
|
|
7
|
+
* — `@selection-change` and `@cell-change` in a template.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { DefineSetupFnComponent } from "vue";
|
|
11
|
+
import type {
|
|
12
|
+
CellChangeDetail,
|
|
13
|
+
ConnectOptions,
|
|
14
|
+
Density,
|
|
15
|
+
Mode,
|
|
16
|
+
SelectionChangeDetail,
|
|
17
|
+
View,
|
|
18
|
+
} from "../loader.js";
|
|
19
|
+
|
|
20
|
+
/** `connect`'s options, less the callbacks — those are events here. */
|
|
21
|
+
type Options = Omit<ConnectOptions, "onViewChange" | "onSelectionChange" | "onCellChange">;
|
|
22
|
+
|
|
23
|
+
/** A type, not an interface: Vue's `EmitsOptions` wants an index signature. */
|
|
24
|
+
export type OpengridEmits = {
|
|
25
|
+
/** The reader changed the view; `v-model:view` writes it back. */
|
|
26
|
+
"update:view": (view: View) => void;
|
|
27
|
+
selectionChange: (detail: SelectionChangeDetail) => void;
|
|
28
|
+
cellChange: (detail: CellChangeDetail) => void;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export interface OpengridGridProps extends Options {
|
|
32
|
+
/** The accessible name of the table. */
|
|
33
|
+
label?: string;
|
|
34
|
+
/** The source; becomes the query's `source`. */
|
|
35
|
+
datasource?: string;
|
|
36
|
+
/** Comma-separated output fields, in order. */
|
|
37
|
+
columns?: string;
|
|
38
|
+
/** Rows rendered and fetched at once while scrolling. Default 40. */
|
|
39
|
+
windowSize?: number;
|
|
40
|
+
/** Switches from scrolling to paging. */
|
|
41
|
+
pageSize?: number;
|
|
42
|
+
mode?: Mode;
|
|
43
|
+
/** Up to two columns, outermost first: `"country,customer"`. */
|
|
44
|
+
groupBy?: string;
|
|
45
|
+
search?: boolean;
|
|
46
|
+
facets?: boolean;
|
|
47
|
+
toolbar?: boolean;
|
|
48
|
+
columnMenu?: boolean;
|
|
49
|
+
selection?: boolean;
|
|
50
|
+
density?: Density;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface OpengridTableProps extends Options {
|
|
54
|
+
label?: string;
|
|
55
|
+
datasource?: string;
|
|
56
|
+
columns?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface OpengridPivotProps extends Options {
|
|
60
|
+
label?: string;
|
|
61
|
+
datasource?: string;
|
|
62
|
+
/** Comma-separated row dimensions, outermost first. */
|
|
63
|
+
rows?: string;
|
|
64
|
+
/** Comma-separated column dimensions; V1 allows one. */
|
|
65
|
+
columns?: string;
|
|
66
|
+
/** The measures as the contract's JSON. */
|
|
67
|
+
values?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const OpengridGrid: DefineSetupFnComponent<OpengridGridProps, OpengridEmits>;
|
|
71
|
+
export const OpengridTable: DefineSetupFnComponent<OpengridTableProps, OpengridEmits>;
|
|
72
|
+
export const OpengridPivot: DefineSetupFnComponent<OpengridPivotProps, OpengridEmits>;
|
package/vue/index.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue components for `@casoon/opengrid` (plan point 78, E32).
|
|
3
|
+
*
|
|
4
|
+
* The same thin shell as the React adapter: the component renders the custom
|
|
5
|
+
* element with its attributes, and hands everything else — provider, texts,
|
|
6
|
+
* formats, presentation, choices, the view and the events — to one `connect`.
|
|
7
|
+
*
|
|
8
|
+
* What only a Vue shell has to know:
|
|
9
|
+
*
|
|
10
|
+
* - **The element is rendered with `h()`,** so Vue never tries to resolve
|
|
11
|
+
* `opengrid-grid` as a component — no `compilerOptions.isCustomElement` for
|
|
12
|
+
* the page. (A page that writes the bare element in a template needs it.)
|
|
13
|
+
* `class`, `style`, `id` and `aria-*` fall through to it, as Vue does for a
|
|
14
|
+
* component's root.
|
|
15
|
+
* - **Events in camelCase** (`selectionChange`, `cellChange`), which a
|
|
16
|
+
* template writes as `@selection-change` — Vue normalizes the two, and only
|
|
17
|
+
* the camelCase form gives typed `onSelectionChange` props.
|
|
18
|
+
* - **`v-model:view`:** the view comes in as a prop and goes out as
|
|
19
|
+
* `update:view`, which is the reader's change `connect` reports. Writing it
|
|
20
|
+
* back is no change, so the loop ends there.
|
|
21
|
+
* - **`<KeepAlive>` detaches, it does not unmount:** the connection stays, and
|
|
22
|
+
* the element brings back its own view and selection when it returns
|
|
23
|
+
* (docs/api.md §Connecting, plan point 74). Only an unmount disconnects. A
|
|
24
|
+
* view that changed while the grid was away waited in `connect` (there is no
|
|
25
|
+
* view to set on a detached element); reactivation hands it over.
|
|
26
|
+
* - **Watchers run after the render** (`flush: "post"`), so the element has
|
|
27
|
+
* its new attributes before an option follows: a new `datasource` and a new
|
|
28
|
+
* `provider` together ask once, a view naming a new column finds it.
|
|
29
|
+
* - **The view is controlled like in React:** a view the page does not take
|
|
30
|
+
* back from `update:view` is written again — on the next tick, once Vue has
|
|
31
|
+
* had its chance to pass the new one down.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import { defineComponent, h, nextTick, onActivated, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
|
35
|
+
import { connect } from "../loader.js";
|
|
36
|
+
|
|
37
|
+
/** The options of `connect` that are props; deep ones compare by value. */
|
|
38
|
+
const SHALLOW = ["provider"];
|
|
39
|
+
const DEEP = ["texts", "formats", "presentation", "choices", "view"];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Builds one component.
|
|
43
|
+
*
|
|
44
|
+
* @param {string} tag the custom element.
|
|
45
|
+
* @param {string} name the component's name in the Vue tools.
|
|
46
|
+
* @param {Record<string, string>} attributes prop name → attribute name.
|
|
47
|
+
* @param {string[]} booleans the props that are boolean attributes.
|
|
48
|
+
*/
|
|
49
|
+
function component(tag, name, attributes, booleans) {
|
|
50
|
+
const props = {};
|
|
51
|
+
for (const prop of Object.keys(attributes)) {
|
|
52
|
+
props[prop] = booleans.includes(prop) ? { type: Boolean, default: false } : null;
|
|
53
|
+
}
|
|
54
|
+
for (const option of [...SHALLOW, ...DEEP, "defaultView"]) {
|
|
55
|
+
props[option] = { type: null, default: undefined };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return defineComponent({
|
|
59
|
+
name,
|
|
60
|
+
props,
|
|
61
|
+
emits: ["update:view", "selectionChange", "cellChange"],
|
|
62
|
+
setup(props, { emit }) {
|
|
63
|
+
const element = ref(null);
|
|
64
|
+
let connection = null;
|
|
65
|
+
|
|
66
|
+
onMounted(() => {
|
|
67
|
+
if (props.view != null && props.defaultView != null) {
|
|
68
|
+
console.warn(`[opengrid] <${name}> has both view and defaultView; the view is controlled and leads`);
|
|
69
|
+
}
|
|
70
|
+
const options = {
|
|
71
|
+
onViewChange: (view) => {
|
|
72
|
+
emit("update:view", view);
|
|
73
|
+
nextTick(() => {
|
|
74
|
+
if (props.view != null) connection?.update({ view: props.view });
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
onSelectionChange: (detail) => emit("selectionChange", detail),
|
|
78
|
+
onCellChange: (detail) => emit("cellChange", detail),
|
|
79
|
+
};
|
|
80
|
+
for (const option of [...SHALLOW, ...DEEP, "defaultView"]) {
|
|
81
|
+
if (props[option] !== undefined) {
|
|
82
|
+
options[option] = props[option];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
connection = connect(element.value, options);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// A changed option is passed on, and one that went away is passed as
|
|
89
|
+
// `undefined`, which resets it (`connect`).
|
|
90
|
+
for (const option of SHALLOW) {
|
|
91
|
+
watch(
|
|
92
|
+
() => props[option],
|
|
93
|
+
(value) => connection?.update({ [option]: value }),
|
|
94
|
+
{ flush: "post" },
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
for (const option of DEEP) {
|
|
98
|
+
watch(
|
|
99
|
+
() => props[option],
|
|
100
|
+
(value) => connection?.update({ [option]: value }),
|
|
101
|
+
{ deep: true, flush: "post" },
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
onActivated(() => connection?.update({}));
|
|
105
|
+
|
|
106
|
+
onBeforeUnmount(() => {
|
|
107
|
+
connection?.disconnect();
|
|
108
|
+
connection = null;
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
return () => {
|
|
112
|
+
const rendered = { ref: element };
|
|
113
|
+
for (const [prop, attribute] of Object.entries(attributes)) {
|
|
114
|
+
const value = props[prop];
|
|
115
|
+
if (booleans.includes(prop)) {
|
|
116
|
+
rendered[attribute] = value ? "" : undefined;
|
|
117
|
+
} else {
|
|
118
|
+
rendered[attribute] = value == null ? undefined : String(value);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return h(tag, rendered);
|
|
122
|
+
};
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export const OpengridGrid = component(
|
|
128
|
+
"opengrid-grid",
|
|
129
|
+
"OpengridGrid",
|
|
130
|
+
{
|
|
131
|
+
label: "label",
|
|
132
|
+
datasource: "datasource",
|
|
133
|
+
columns: "columns",
|
|
134
|
+
windowSize: "window-size",
|
|
135
|
+
pageSize: "page-size",
|
|
136
|
+
mode: "mode",
|
|
137
|
+
groupBy: "group-by",
|
|
138
|
+
search: "search",
|
|
139
|
+
facets: "facets",
|
|
140
|
+
toolbar: "toolbar",
|
|
141
|
+
columnMenu: "column-menu",
|
|
142
|
+
selection: "selection",
|
|
143
|
+
density: "density",
|
|
144
|
+
},
|
|
145
|
+
["search", "facets", "toolbar", "columnMenu", "selection"],
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
export const OpengridTable = component(
|
|
149
|
+
"opengrid-table",
|
|
150
|
+
"OpengridTable",
|
|
151
|
+
{ label: "label", datasource: "datasource", columns: "columns" },
|
|
152
|
+
[],
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
export const OpengridPivot = component(
|
|
156
|
+
"opengrid-pivot",
|
|
157
|
+
"OpengridPivot",
|
|
158
|
+
{
|
|
159
|
+
label: "label",
|
|
160
|
+
datasource: "datasource",
|
|
161
|
+
rows: "rows",
|
|
162
|
+
columns: "columns",
|
|
163
|
+
values: "values",
|
|
164
|
+
},
|
|
165
|
+
[],
|
|
166
|
+
);
|
|
File without changes
|
|
File without changes
|