@guiexpert/preact-table 10.1.90 → 10.1.92
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/GuiexpertTable.d.ts +32 -3
- package/index.cjs +1 -1
- package/index.d.ts +2 -2
- package/index.js +95 -56
- package/package.json +13 -5
package/GuiexpertTable.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from 'preact';
|
|
2
|
-
import { FocusModelIf, GeModelChangeEvent, GeMouseEvent, GeScrollEvent, SelectionModelIf, TableApi, TableModelIf, TableOptions } from '@guiexpert/table';
|
|
2
|
+
import { FocusModelIf, GeModelChangeEvent, GeMouseEvent, GeScrollEvent, GeStateChangeEvent, SelectionModelIf, TableApi, TableModelIf, TableOptions } from '@guiexpert/table';
|
|
3
3
|
|
|
4
4
|
export type GeMouseEventFn = (evt: GeMouseEvent) => void;
|
|
5
5
|
export type GeCheckboxEventFn = (evt: any[]) => void;
|
|
@@ -8,6 +8,7 @@ export type GeModelChangeEventFn = (evt: GeModelChangeEvent) => void;
|
|
|
8
8
|
export type GeSelectionChangeEventFn = (evt: SelectionModelIf) => void;
|
|
9
9
|
export type GeFocusChangeEventFn = (evt: FocusModelIf) => void;
|
|
10
10
|
export type GeScrollEventFn = (evt: GeScrollEvent) => void;
|
|
11
|
+
export type GeStateChangeEventFn = (evt: GeStateChangeEvent) => void;
|
|
11
12
|
export interface GuiexpertTableProps {
|
|
12
13
|
tableModel: TableModelIf;
|
|
13
14
|
tableOptions?: TableOptions;
|
|
@@ -23,17 +24,45 @@ export interface GuiexpertTableProps {
|
|
|
23
24
|
licenseKey?: string;
|
|
24
25
|
selectionChanged?: GeSelectionChangeEventFn;
|
|
25
26
|
focusChanged?: GeFocusChangeEventFn;
|
|
27
|
+
/**
|
|
28
|
+
* The state changed (column layout, sorting, scroll position, tree, checked/selected rows …) – once after the
|
|
29
|
+
* changes settled. Save `evt.state` (e.g. on your server) and pass it back as `tableOptions.initialState`.
|
|
30
|
+
* @since 1.1.92
|
|
31
|
+
*/
|
|
32
|
+
stateChanged?: GeStateChangeEventFn;
|
|
33
|
+
/**
|
|
34
|
+
* `true` shows the loading overlay ("Loading…" with a CSS spinner) over the body, `false` hides it.
|
|
35
|
+
* Changing it does **not** re-create the table. Texts: `tableOptions.overlayOptions`. @since 1.1.92
|
|
36
|
+
*/
|
|
37
|
+
loading?: boolean;
|
|
26
38
|
}
|
|
27
39
|
/**
|
|
28
|
-
* GuiexpertTable is a
|
|
40
|
+
* GuiexpertTable is a Preact component that wraps the GuiExpert Table (`@guiexpert/table`).
|
|
29
41
|
* It displays a table with various event listeners and callback functions.
|
|
42
|
+
*
|
|
43
|
+
* A new `tableModel` or `tableOptions` object (new reference) re-creates the table; the previous
|
|
44
|
+
* table is released with `TableScope.destroy()`, as on unmount. Keep both objects stable
|
|
45
|
+
* (create them once, not in `render`), otherwise the table is re-created on every render.
|
|
46
|
+
* Callback props may change freely – the current one is called.
|
|
30
47
|
*/
|
|
31
48
|
export declare class GuiexpertTable extends Component<GuiexpertTableProps> {
|
|
32
|
-
ref: import('preact').RefObject<
|
|
49
|
+
ref: import('preact').RefObject<HTMLDivElement>;
|
|
50
|
+
private tableScope?;
|
|
51
|
+
/** the overlay was shown by the loading prop: loading={false} hides only that one */
|
|
52
|
+
private shownByProp;
|
|
33
53
|
constructor(props: GuiexpertTableProps);
|
|
34
54
|
componentDidMount(): void;
|
|
55
|
+
componentDidUpdate(previousProps: Readonly<GuiexpertTableProps>): void;
|
|
35
56
|
componentWillUnmount(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Creates the table in `ele` (a table created before is destroyed first) and calls `tableReady`.
|
|
59
|
+
* The event callbacks are always taken from the current props.
|
|
60
|
+
*/
|
|
36
61
|
initTable(ele: HTMLDivElement, props: GuiexpertTableProps): void;
|
|
62
|
+
/** Shows or hides the loading overlay according to the `loading` prop. */
|
|
63
|
+
private applyLoading;
|
|
64
|
+
/** Releases the table (listeners, resize observer, cell renderers). */
|
|
65
|
+
private destroyTable;
|
|
37
66
|
render(): import("preact").JSX.Element;
|
|
38
67
|
}
|
|
39
68
|
export default GuiexpertTable;
|
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var u=Object.defineProperty;var b=(r,i,t)=>i in r?u(r,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[i]=t;var h=(r,i,t)=>b(r,typeof i!="symbol"?i+"":i,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("preact/jsx-runtime"),d=require("preact"),c=require("@guiexpert/table");class m extends d.Component{constructor(t){super(t);h(this,"ref",d.createRef());h(this,"tableScope");h(this,"shownByProp",!1)}componentDidMount(){const t=this.ref.current;t&&this.initTable(t,this.props)}componentDidUpdate(t){const s=this.ref.current;s&&(t.tableModel!==this.props.tableModel||t.tableOptions!==this.props.tableOptions)&&this.initTable(s,this.props),!!t.loading!=!!this.props.loading&&this.applyLoading(),this.props.licenseKey&&this.props.licenseKey!==t.licenseKey&&c.LicenseManager.getInstance().setLicenseKey(this.props.licenseKey)}componentWillUnmount(){this.destroyTable()}initTable(t,s){var g;this.destroyTable();const a=()=>this.props,p={onSelectionChanged:o=>{var e,n;return(n=(e=a()).selectionChanged)==null?void 0:n.call(e,o)},onFocusChanged:o=>{var e,n;return(n=(e=a()).focusChanged)==null?void 0:n.call(e,o)},onScroll:o=>{var e,n;return(n=(e=a()).scroll)==null?void 0:n.call(e,o)},onCheckboxChanged:o=>{var e,n;return(n=(e=a()).checkboxChanged)==null?void 0:n.call(e,o)},onContextmenu:o=>{var e,n;return(n=(e=a()).contextmenu)==null?void 0:n.call(e,o)},onModelChanged:o=>{var e,n;return(n=(e=a()).modelChanged)==null?void 0:n.call(e,o)},onMouseClicked:o=>{var e,n;return(n=(e=a()).mouseClicked)==null?void 0:n.call(e,o)},onMouseDragging:o=>{var e,n;return(n=(e=a()).mouseDragging)==null?void 0:n.call(e,o)},onMouseDraggingEnd:o=>{var e,n;return(n=(e=a()).mouseDraggingEnd)==null?void 0:n.call(e,o)},onMouseMoved:o=>{var e,n;return(n=(e=a()).mouseMoved)==null?void 0:n.call(e,o)},onStateChanged:o=>{var e,n;return(n=(e=a()).stateChanged)==null?void 0:n.call(e,o)}},l=new c.TableScope(t,s.tableModel,new c.SimpleDomService,s.tableOptions??new c.TableOptions,p);this.tableScope=l,l.firstInit(),this.shownByProp=!1,this.applyLoading(),(g=s.tableReady)==null||g.call(s,l.getApi()),s.licenseKey&&c.LicenseManager.getInstance().setLicenseKey(s.licenseKey)}applyLoading(){var t,s;this.props.loading?((t=this.tableScope)==null||t.showLoadingOverlay(),this.shownByProp=!0):this.shownByProp&&((s=this.tableScope)==null||s.hideOverlay(),this.shownByProp=!1)}destroyTable(){var t;(t=this.tableScope)==null||t.destroy(),this.tableScope=void 0}render(){return y.jsx("div",{ref:this.ref,className:"container-div",style:{width:"100%",height:"100%",backgroundColor:"transparent",padding:"0",margin:"0"}})}}class C{constructor(i){this.Component=i}render(i,t,s,a,p,l,g){const o={cellDiv:i,rowIndex:t,columnIndex:s,areaIdent:a,areaModel:p,cellValue:l};return d.render(d.h(this.Component,o),i),()=>{d.render(null,i)}}}exports.ComponentRendererWrapper=C;exports.GuiexpertTable=m;
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './GuiexpertTable';
|
|
2
|
-
export * from './ComponentRendererWrapper';
|
|
1
|
+
export * from './GuiexpertTable.js';
|
|
2
|
+
export * from './ComponentRendererWrapper.js';
|
package/index.js
CHANGED
|
@@ -1,62 +1,101 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { Component as u, createRef as
|
|
6
|
-
import {
|
|
7
|
-
class
|
|
8
|
-
constructor(
|
|
9
|
-
super(
|
|
10
|
-
|
|
1
|
+
var m = Object.defineProperty;
|
|
2
|
+
var b = (r, i, t) => i in r ? m(r, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[i] = t;
|
|
3
|
+
var c = (r, i, t) => b(r, typeof i != "symbol" ? i + "" : i, t);
|
|
4
|
+
import { jsx as y } from "preact/jsx-runtime";
|
|
5
|
+
import { Component as u, createRef as f, render as p, h as C } from "preact";
|
|
6
|
+
import { LicenseManager as g, TableScope as S, SimpleDomService as M, TableOptions as w } from "@guiexpert/table";
|
|
7
|
+
class O extends u {
|
|
8
|
+
constructor(t) {
|
|
9
|
+
super(t);
|
|
10
|
+
c(this, "ref", f());
|
|
11
|
+
c(this, "tableScope");
|
|
12
|
+
/** the overlay was shown by the loading prop: loading={false} hides only that one */
|
|
13
|
+
c(this, "shownByProp", !1);
|
|
11
14
|
}
|
|
12
15
|
componentDidMount() {
|
|
13
|
-
const
|
|
14
|
-
this.initTable(
|
|
16
|
+
const t = this.ref.current;
|
|
17
|
+
t && this.initTable(t, this.props);
|
|
18
|
+
}
|
|
19
|
+
componentDidUpdate(t) {
|
|
20
|
+
const s = this.ref.current;
|
|
21
|
+
s && (t.tableModel !== this.props.tableModel || t.tableOptions !== this.props.tableOptions) && this.initTable(s, this.props), !!t.loading != !!this.props.loading && this.applyLoading(), this.props.licenseKey && this.props.licenseKey !== t.licenseKey && g.getInstance().setLicenseKey(this.props.licenseKey);
|
|
15
22
|
}
|
|
16
23
|
componentWillUnmount() {
|
|
24
|
+
this.destroyTable();
|
|
17
25
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Creates the table in `ele` (a table created before is destroyed first) and calls `tableReady`.
|
|
28
|
+
* The event callbacks are always taken from the current props.
|
|
29
|
+
*/
|
|
30
|
+
initTable(t, s) {
|
|
31
|
+
var d;
|
|
32
|
+
this.destroyTable();
|
|
33
|
+
const a = () => this.props, h = {
|
|
34
|
+
onSelectionChanged: (o) => {
|
|
35
|
+
var e, n;
|
|
36
|
+
return (n = (e = a()).selectionChanged) == null ? void 0 : n.call(e, o);
|
|
37
|
+
},
|
|
38
|
+
onFocusChanged: (o) => {
|
|
39
|
+
var e, n;
|
|
40
|
+
return (n = (e = a()).focusChanged) == null ? void 0 : n.call(e, o);
|
|
22
41
|
},
|
|
23
|
-
onScroll(
|
|
24
|
-
e
|
|
42
|
+
onScroll: (o) => {
|
|
43
|
+
var e, n;
|
|
44
|
+
return (n = (e = a()).scroll) == null ? void 0 : n.call(e, o);
|
|
25
45
|
},
|
|
26
|
-
|
|
27
|
-
e
|
|
46
|
+
onCheckboxChanged: (o) => {
|
|
47
|
+
var e, n;
|
|
48
|
+
return (n = (e = a()).checkboxChanged) == null ? void 0 : n.call(e, o);
|
|
28
49
|
},
|
|
29
|
-
|
|
30
|
-
e
|
|
50
|
+
onContextmenu: (o) => {
|
|
51
|
+
var e, n;
|
|
52
|
+
return (n = (e = a()).contextmenu) == null ? void 0 : n.call(e, o);
|
|
31
53
|
},
|
|
32
|
-
|
|
33
|
-
e
|
|
54
|
+
onModelChanged: (o) => {
|
|
55
|
+
var e, n;
|
|
56
|
+
return (n = (e = a()).modelChanged) == null ? void 0 : n.call(e, o);
|
|
34
57
|
},
|
|
35
|
-
|
|
36
|
-
e
|
|
58
|
+
onMouseClicked: (o) => {
|
|
59
|
+
var e, n;
|
|
60
|
+
return (n = (e = a()).mouseClicked) == null ? void 0 : n.call(e, o);
|
|
37
61
|
},
|
|
38
|
-
|
|
39
|
-
e
|
|
62
|
+
onMouseDragging: (o) => {
|
|
63
|
+
var e, n;
|
|
64
|
+
return (n = (e = a()).mouseDragging) == null ? void 0 : n.call(e, o);
|
|
40
65
|
},
|
|
41
|
-
|
|
42
|
-
e
|
|
66
|
+
onMouseDraggingEnd: (o) => {
|
|
67
|
+
var e, n;
|
|
68
|
+
return (n = (e = a()).mouseDraggingEnd) == null ? void 0 : n.call(e, o);
|
|
43
69
|
},
|
|
44
|
-
|
|
45
|
-
e
|
|
70
|
+
onMouseMoved: (o) => {
|
|
71
|
+
var e, n;
|
|
72
|
+
return (n = (e = a()).mouseMoved) == null ? void 0 : n.call(e, o);
|
|
46
73
|
},
|
|
47
|
-
|
|
74
|
+
onStateChanged: (o) => {
|
|
75
|
+
var e, n;
|
|
76
|
+
return (n = (e = a()).stateChanged) == null ? void 0 : n.call(e, o);
|
|
48
77
|
}
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
new
|
|
53
|
-
|
|
54
|
-
|
|
78
|
+
}, l = new S(
|
|
79
|
+
t,
|
|
80
|
+
s.tableModel,
|
|
81
|
+
new M(),
|
|
82
|
+
s.tableOptions ?? new w(),
|
|
83
|
+
h
|
|
55
84
|
);
|
|
56
|
-
|
|
85
|
+
this.tableScope = l, l.firstInit(), this.shownByProp = !1, this.applyLoading(), (d = s.tableReady) == null || d.call(s, l.getApi()), s.licenseKey && g.getInstance().setLicenseKey(s.licenseKey);
|
|
86
|
+
}
|
|
87
|
+
/** Shows or hides the loading overlay according to the `loading` prop. */
|
|
88
|
+
applyLoading() {
|
|
89
|
+
var t, s;
|
|
90
|
+
this.props.loading ? ((t = this.tableScope) == null || t.showLoadingOverlay(), this.shownByProp = !0) : this.shownByProp && ((s = this.tableScope) == null || s.hideOverlay(), this.shownByProp = !1);
|
|
91
|
+
}
|
|
92
|
+
/** Releases the table (listeners, resize observer, cell renderers). */
|
|
93
|
+
destroyTable() {
|
|
94
|
+
var t;
|
|
95
|
+
(t = this.tableScope) == null || t.destroy(), this.tableScope = void 0;
|
|
57
96
|
}
|
|
58
97
|
render() {
|
|
59
|
-
return /* @__PURE__ */
|
|
98
|
+
return /* @__PURE__ */ y(
|
|
60
99
|
"div",
|
|
61
100
|
{
|
|
62
101
|
ref: this.ref,
|
|
@@ -72,21 +111,21 @@ class v extends u {
|
|
|
72
111
|
);
|
|
73
112
|
}
|
|
74
113
|
}
|
|
75
|
-
class
|
|
76
|
-
constructor(
|
|
77
|
-
this.Component =
|
|
114
|
+
class k {
|
|
115
|
+
constructor(i) {
|
|
116
|
+
this.Component = i;
|
|
78
117
|
}
|
|
79
|
-
render(
|
|
80
|
-
const
|
|
81
|
-
cellDiv:
|
|
82
|
-
rowIndex:
|
|
83
|
-
columnIndex:
|
|
84
|
-
areaIdent:
|
|
85
|
-
areaModel:
|
|
86
|
-
cellValue:
|
|
118
|
+
render(i, t, s, a, h, l, d) {
|
|
119
|
+
const o = {
|
|
120
|
+
cellDiv: i,
|
|
121
|
+
rowIndex: t,
|
|
122
|
+
columnIndex: s,
|
|
123
|
+
areaIdent: a,
|
|
124
|
+
areaModel: h,
|
|
125
|
+
cellValue: l
|
|
87
126
|
};
|
|
88
|
-
return
|
|
89
|
-
|
|
127
|
+
return p(C(this.Component, o), i), () => {
|
|
128
|
+
p(null, i);
|
|
90
129
|
};
|
|
91
130
|
}
|
|
92
131
|
// private mount(
|
|
@@ -110,6 +149,6 @@ class w {
|
|
|
110
149
|
// }
|
|
111
150
|
}
|
|
112
151
|
export {
|
|
113
|
-
|
|
114
|
-
|
|
152
|
+
k as ComponentRendererWrapper,
|
|
153
|
+
O as GuiexpertTable
|
|
115
154
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guiexpert/preact-table",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.92",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dr. Marc Kronberg <info@gui.expert> (https://gui.expert)",
|
|
6
6
|
"repository": {
|
|
@@ -22,13 +22,16 @@
|
|
|
22
22
|
},
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
-
"import":
|
|
25
|
+
"import": {
|
|
26
|
+
"types": "./index.d.ts",
|
|
27
|
+
"default": "./index.js"
|
|
28
|
+
},
|
|
26
29
|
"require": "./index.cjs"
|
|
27
30
|
}
|
|
28
31
|
},
|
|
29
32
|
"dependencies": {
|
|
30
33
|
"tslib": "^2.3.0",
|
|
31
|
-
"@guiexpert/table": "^1.1.
|
|
34
|
+
"@guiexpert/table": "^1.1.92"
|
|
32
35
|
},
|
|
33
36
|
"peerDependencies": {
|
|
34
37
|
"preact": "^10.0.0"
|
|
@@ -40,7 +43,7 @@
|
|
|
40
43
|
"@types/react": "^18.2.37 || ^19.0.0",
|
|
41
44
|
"@types/react-dom": "^18.2.15 || ^19.0.0",
|
|
42
45
|
"@types/node": "^20.11.17",
|
|
43
|
-
"vite": "6.
|
|
46
|
+
"vite": "6.4.4",
|
|
44
47
|
"vite-plugin-dts": "^3.7.2",
|
|
45
48
|
"vite-plugin-eslint": "^1.8.1",
|
|
46
49
|
"vite-plugin-static-copy": "^0.17.0",
|
|
@@ -50,12 +53,17 @@
|
|
|
50
53
|
"ts-node": "10.9.1",
|
|
51
54
|
"tsconfig": "^7.0.0",
|
|
52
55
|
"typescript": "5.2.2",
|
|
53
|
-
"@babel/core": "~7.28.6"
|
|
56
|
+
"@babel/core": "~7.28.6",
|
|
57
|
+
"vitest": "5.0.4",
|
|
58
|
+
"@vitest/browser-playwright": "5.0.4",
|
|
59
|
+
"playwright": "1.64.0"
|
|
54
60
|
},
|
|
55
61
|
"scripts": {
|
|
56
62
|
"i": "pnpm i",
|
|
57
63
|
"patch-version": "node patch.js",
|
|
58
64
|
"build": "vite build",
|
|
65
|
+
"test": "vitest run",
|
|
66
|
+
"test:watch": "vitest",
|
|
59
67
|
"npm-pub": "pnpm publish --no-git-checks --access public"
|
|
60
68
|
}
|
|
61
69
|
}
|