@guiexpert/preact-table 10.1.90 → 10.1.91

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.
@@ -25,15 +25,28 @@ export interface GuiexpertTableProps {
25
25
  focusChanged?: GeFocusChangeEventFn;
26
26
  }
27
27
  /**
28
- * GuiexpertTable is a React component that wraps the ExpertTable library.
28
+ * GuiexpertTable is a Preact component that wraps the GuiExpert Table (`@guiexpert/table`).
29
29
  * It displays a table with various event listeners and callback functions.
30
+ *
31
+ * A new `tableModel` or `tableOptions` object (new reference) re-creates the table; the previous
32
+ * table is released with `TableScope.destroy()`, as on unmount. Keep both objects stable
33
+ * (create them once, not in `render`), otherwise the table is re-created on every render.
34
+ * Callback props may change freely – the current one is called.
30
35
  */
31
36
  export declare class GuiexpertTable extends Component<GuiexpertTableProps> {
32
- ref: import('preact').RefObject<any>;
37
+ ref: import('preact').RefObject<HTMLDivElement>;
38
+ private tableScope?;
33
39
  constructor(props: GuiexpertTableProps);
34
40
  componentDidMount(): void;
41
+ componentDidUpdate(previousProps: Readonly<GuiexpertTableProps>): void;
35
42
  componentWillUnmount(): void;
43
+ /**
44
+ * Creates the table in `ele` (a table created before is destroyed first) and calls `tableReady`.
45
+ * The event callbacks are always taken from the current props.
46
+ */
36
47
  initTable(ele: HTMLDivElement, props: GuiexpertTableProps): void;
48
+ /** Releases the table (listeners, resize observer, cell renderers). */
49
+ private destroyTable;
37
50
  render(): import("preact").JSX.Element;
38
51
  }
39
52
  export default GuiexpertTable;
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var s=Object.defineProperty;var u=(o,t,i)=>t in o?s(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i;var l=(o,t,i)=>u(o,typeof t!="symbol"?t+"":t,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("preact/jsx-runtime"),a=require("preact"),r=require("@guiexpert/table");class h extends a.Component{constructor(i){super(i);l(this,"ref",a.createRef())}componentDidMount(){const i=this.ref.current;this.initTable(i,this.props)}componentWillUnmount(){}initTable(i,e){const d={onSelectionChanged(n){e.selectionChanged&&e.selectionChanged(n)},onScroll(n){e.scroll&&e.scroll(n)},onFocusChanged(n){e.focusChanged&&e.focusChanged(n)},onCheckboxChanged:n=>{e.checkboxChanged&&e.checkboxChanged(n)},onContextmenu:n=>{e.contextmenu&&e.contextmenu(n)},onModelChanged:n=>{e.modelChanged&&e.modelChanged(n)},onMouseClicked:n=>{e.mouseClicked&&e.mouseClicked(n)},onMouseDragging:n=>{e.mouseDragging&&e.mouseDragging(n)},onMouseDraggingEnd:n=>{e.mouseDraggingEnd&&e.mouseDraggingEnd(n)},onMouseMoved:n=>{}},c=new r.TableScope(i,e.tableModel,new r.SimpleDomService,e.tableOptions??new r.TableOptions,d);c.firstInit(),e.tableReady&&e.tableReady(c.getApi()),e.licenseKey&&r.LicenseManager.getInstance().setLicenseKey(e.licenseKey)}render(){return m.jsx("div",{ref:this.ref,className:"container-div",style:{width:"100%",height:"100%",backgroundColor:"transparent",padding:"0",margin:"0"}})}}class C{constructor(t){this.Component=t}render(t,i,e,d,c,n,f){const g={cellDiv:t,rowIndex:i,columnIndex:e,areaIdent:d,areaModel:c,cellValue:n};return a.render(a.h(this.Component,g),t),()=>{a.render(null,t)}}}exports.ComponentRendererWrapper=C;exports.GuiexpertTable=h;
1
+ "use strict";var p=Object.defineProperty;var b=(a,s,o)=>s in a?p(a,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[s]=o;var u=(a,s,o)=>b(a,typeof s!="symbol"?s+"":s,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("preact/jsx-runtime"),d=require("preact"),l=require("@guiexpert/table");class C extends d.Component{constructor(o){super(o);u(this,"ref",d.createRef());u(this,"tableScope")}componentDidMount(){const o=this.ref.current;o&&this.initTable(o,this.props)}componentDidUpdate(o){const i=this.ref.current;i&&(o.tableModel!==this.props.tableModel||o.tableOptions!==this.props.tableOptions)&&this.initTable(i,this.props),this.props.licenseKey&&this.props.licenseKey!==o.licenseKey&&l.LicenseManager.getInstance().setLicenseKey(this.props.licenseKey)}componentWillUnmount(){this.destroyTable()}initTable(o,i){var g;this.destroyTable();const r=()=>this.props,h={onSelectionChanged:t=>{var e,n;return(n=(e=r()).selectionChanged)==null?void 0:n.call(e,t)},onFocusChanged:t=>{var e,n;return(n=(e=r()).focusChanged)==null?void 0:n.call(e,t)},onScroll:t=>{var e,n;return(n=(e=r()).scroll)==null?void 0:n.call(e,t)},onCheckboxChanged:t=>{var e,n;return(n=(e=r()).checkboxChanged)==null?void 0:n.call(e,t)},onContextmenu:t=>{var e,n;return(n=(e=r()).contextmenu)==null?void 0:n.call(e,t)},onModelChanged:t=>{var e,n;return(n=(e=r()).modelChanged)==null?void 0:n.call(e,t)},onMouseClicked:t=>{var e,n;return(n=(e=r()).mouseClicked)==null?void 0:n.call(e,t)},onMouseDragging:t=>{var e,n;return(n=(e=r()).mouseDragging)==null?void 0:n.call(e,t)},onMouseDraggingEnd:t=>{var e,n;return(n=(e=r()).mouseDraggingEnd)==null?void 0:n.call(e,t)},onMouseMoved:t=>{var e,n;return(n=(e=r()).mouseMoved)==null?void 0:n.call(e,t)}},c=new l.TableScope(o,i.tableModel,new l.SimpleDomService,i.tableOptions??new l.TableOptions,h);this.tableScope=c,c.firstInit(),(g=i.tableReady)==null||g.call(i,c.getApi()),i.licenseKey&&l.LicenseManager.getInstance().setLicenseKey(i.licenseKey)}destroyTable(){var o;(o=this.tableScope)==null||o.destroy(),this.tableScope=void 0}render(){return m.jsx("div",{ref:this.ref,className:"container-div",style:{width:"100%",height:"100%",backgroundColor:"transparent",padding:"0",margin:"0"}})}}class y{constructor(s){this.Component=s}render(s,o,i,r,h,c,g){const t={cellDiv:s,rowIndex:o,columnIndex:i,areaIdent:r,areaModel:h,cellValue:c};return d.render(d.h(this.Component,t),s),()=>{d.render(null,s)}}}exports.ComponentRendererWrapper=y;exports.GuiexpertTable=C;
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,90 @@
1
- var r = Object.defineProperty;
2
- var m = (i, t, o) => t in i ? r(i, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : i[t] = o;
3
- var d = (i, t, o) => m(i, typeof t != "symbol" ? t + "" : t, o);
4
- import { jsx as s } from "preact/jsx-runtime";
5
- import { Component as u, createRef as h, render as g, h as C } from "preact";
6
- import { TableScope as f, SimpleDomService as b, TableOptions as x, LicenseManager as M } from "@guiexpert/table";
7
- class v extends u {
1
+ var p = Object.defineProperty;
2
+ var b = (a, i, o) => i in a ? p(a, i, { enumerable: !0, configurable: !0, writable: !0, value: o }) : a[i] = o;
3
+ var h = (a, i, o) => b(a, typeof i != "symbol" ? i + "" : i, o);
4
+ import { jsx as u } from "preact/jsx-runtime";
5
+ import { Component as C, createRef as y, render as g, h as f } from "preact";
6
+ import { LicenseManager as m, TableScope as M, SimpleDomService as S, TableOptions as T } from "@guiexpert/table";
7
+ class w extends C {
8
8
  constructor(o) {
9
9
  super(o);
10
- d(this, "ref", h());
10
+ h(this, "ref", y());
11
+ h(this, "tableScope");
11
12
  }
12
13
  componentDidMount() {
13
14
  const o = this.ref.current;
14
- this.initTable(o, this.props);
15
+ o && this.initTable(o, this.props);
16
+ }
17
+ componentDidUpdate(o) {
18
+ const s = this.ref.current;
19
+ s && (o.tableModel !== this.props.tableModel || o.tableOptions !== this.props.tableOptions) && this.initTable(s, this.props), this.props.licenseKey && this.props.licenseKey !== o.licenseKey && m.getInstance().setLicenseKey(this.props.licenseKey);
15
20
  }
16
21
  componentWillUnmount() {
22
+ this.destroyTable();
17
23
  }
18
- initTable(o, e) {
19
- const c = {
20
- onSelectionChanged(n) {
21
- e.selectionChanged && e.selectionChanged(n);
24
+ /**
25
+ * Creates the table in `ele` (a table created before is destroyed first) and calls `tableReady`.
26
+ * The event callbacks are always taken from the current props.
27
+ */
28
+ initTable(o, s) {
29
+ var d;
30
+ this.destroyTable();
31
+ const r = () => this.props, l = {
32
+ onSelectionChanged: (t) => {
33
+ var e, n;
34
+ return (n = (e = r()).selectionChanged) == null ? void 0 : n.call(e, t);
22
35
  },
23
- onScroll(n) {
24
- e.scroll && e.scroll(n);
36
+ onFocusChanged: (t) => {
37
+ var e, n;
38
+ return (n = (e = r()).focusChanged) == null ? void 0 : n.call(e, t);
25
39
  },
26
- onFocusChanged(n) {
27
- e.focusChanged && e.focusChanged(n);
40
+ onScroll: (t) => {
41
+ var e, n;
42
+ return (n = (e = r()).scroll) == null ? void 0 : n.call(e, t);
28
43
  },
29
- onCheckboxChanged: (n) => {
30
- e.checkboxChanged && e.checkboxChanged(n);
44
+ onCheckboxChanged: (t) => {
45
+ var e, n;
46
+ return (n = (e = r()).checkboxChanged) == null ? void 0 : n.call(e, t);
31
47
  },
32
- onContextmenu: (n) => {
33
- e.contextmenu && e.contextmenu(n);
48
+ onContextmenu: (t) => {
49
+ var e, n;
50
+ return (n = (e = r()).contextmenu) == null ? void 0 : n.call(e, t);
34
51
  },
35
- onModelChanged: (n) => {
36
- e.modelChanged && e.modelChanged(n);
52
+ onModelChanged: (t) => {
53
+ var e, n;
54
+ return (n = (e = r()).modelChanged) == null ? void 0 : n.call(e, t);
37
55
  },
38
- onMouseClicked: (n) => {
39
- e.mouseClicked && e.mouseClicked(n);
56
+ onMouseClicked: (t) => {
57
+ var e, n;
58
+ return (n = (e = r()).mouseClicked) == null ? void 0 : n.call(e, t);
40
59
  },
41
- onMouseDragging: (n) => {
42
- e.mouseDragging && e.mouseDragging(n);
60
+ onMouseDragging: (t) => {
61
+ var e, n;
62
+ return (n = (e = r()).mouseDragging) == null ? void 0 : n.call(e, t);
43
63
  },
44
- onMouseDraggingEnd: (n) => {
45
- e.mouseDraggingEnd && e.mouseDraggingEnd(n);
64
+ onMouseDraggingEnd: (t) => {
65
+ var e, n;
66
+ return (n = (e = r()).mouseDraggingEnd) == null ? void 0 : n.call(e, t);
46
67
  },
47
- onMouseMoved: (n) => {
68
+ onMouseMoved: (t) => {
69
+ var e, n;
70
+ return (n = (e = r()).mouseMoved) == null ? void 0 : n.call(e, t);
48
71
  }
49
- }, a = new f(
72
+ }, c = new M(
50
73
  o,
51
- e.tableModel,
52
- new b(),
53
- e.tableOptions ?? new x(),
54
- c
74
+ s.tableModel,
75
+ new S(),
76
+ s.tableOptions ?? new T(),
77
+ l
55
78
  );
56
- a.firstInit(), e.tableReady && e.tableReady(a.getApi()), e.licenseKey && M.getInstance().setLicenseKey(e.licenseKey);
79
+ this.tableScope = c, c.firstInit(), (d = s.tableReady) == null || d.call(s, c.getApi()), s.licenseKey && m.getInstance().setLicenseKey(s.licenseKey);
80
+ }
81
+ /** Releases the table (listeners, resize observer, cell renderers). */
82
+ destroyTable() {
83
+ var o;
84
+ (o = this.tableScope) == null || o.destroy(), this.tableScope = void 0;
57
85
  }
58
86
  render() {
59
- return /* @__PURE__ */ s(
87
+ return /* @__PURE__ */ u(
60
88
  "div",
61
89
  {
62
90
  ref: this.ref,
@@ -72,21 +100,21 @@ class v extends u {
72
100
  );
73
101
  }
74
102
  }
75
- class w {
76
- constructor(t) {
77
- this.Component = t;
103
+ class O {
104
+ constructor(i) {
105
+ this.Component = i;
78
106
  }
79
- render(t, o, e, c, a, n, k) {
80
- const l = {
81
- cellDiv: t,
107
+ render(i, o, s, r, l, c, d) {
108
+ const t = {
109
+ cellDiv: i,
82
110
  rowIndex: o,
83
- columnIndex: e,
84
- areaIdent: c,
85
- areaModel: a,
86
- cellValue: n
111
+ columnIndex: s,
112
+ areaIdent: r,
113
+ areaModel: l,
114
+ cellValue: c
87
115
  };
88
- return g(C(this.Component, l), t), () => {
89
- g(null, t);
116
+ return g(f(this.Component, t), i), () => {
117
+ g(null, i);
90
118
  };
91
119
  }
92
120
  // private mount(
@@ -110,6 +138,6 @@ class w {
110
138
  // }
111
139
  }
112
140
  export {
113
- w as ComponentRendererWrapper,
114
- v as GuiexpertTable
141
+ O as ComponentRendererWrapper,
142
+ w as GuiexpertTable
115
143
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guiexpert/preact-table",
3
- "version": "10.1.90",
3
+ "version": "10.1.91",
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": "./index.js",
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.90"
34
+ "@guiexpert/table": "^1.1.91"
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.3.4",
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
  }