@guiexpert/preact-table 10.1.91 → 10.1.93

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.
@@ -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,6 +24,17 @@ 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
40
  * GuiexpertTable is a Preact component that wraps the GuiExpert Table (`@guiexpert/table`).
@@ -36,6 +48,8 @@ export interface GuiexpertTableProps {
36
48
  export declare class GuiexpertTable extends Component<GuiexpertTableProps> {
37
49
  ref: import('preact').RefObject<HTMLDivElement>;
38
50
  private tableScope?;
51
+ /** the overlay was shown by the loading prop: loading={false} hides only that one */
52
+ private shownByProp;
39
53
  constructor(props: GuiexpertTableProps);
40
54
  componentDidMount(): void;
41
55
  componentDidUpdate(previousProps: Readonly<GuiexpertTableProps>): void;
@@ -45,6 +59,8 @@ export declare class GuiexpertTable extends Component<GuiexpertTableProps> {
45
59
  * The event callbacks are always taken from the current props.
46
60
  */
47
61
  initTable(ele: HTMLDivElement, props: GuiexpertTableProps): void;
62
+ /** Shows or hides the loading overlay according to the `loading` prop. */
63
+ private applyLoading;
48
64
  /** Releases the table (listeners, resize observer, cell renderers). */
49
65
  private destroyTable;
50
66
  render(): import("preact").JSX.Element;
package/index.cjs CHANGED
@@ -1 +1 @@
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;
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.js CHANGED
@@ -1,22 +1,24 @@
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
- constructor(o) {
9
- super(o);
10
- h(this, "ref", y());
11
- h(this, "tableScope");
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);
12
14
  }
13
15
  componentDidMount() {
14
- const o = this.ref.current;
15
- o && this.initTable(o, this.props);
16
+ const t = this.ref.current;
17
+ t && this.initTable(t, this.props);
16
18
  }
17
- componentDidUpdate(o) {
19
+ componentDidUpdate(t) {
18
20
  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);
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);
20
22
  }
21
23
  componentWillUnmount() {
22
24
  this.destroyTable();
@@ -25,66 +27,75 @@ class w extends C {
25
27
  * Creates the table in `ele` (a table created before is destroyed first) and calls `tableReady`.
26
28
  * The event callbacks are always taken from the current props.
27
29
  */
28
- initTable(o, s) {
30
+ initTable(t, s) {
29
31
  var d;
30
32
  this.destroyTable();
31
- const r = () => this.props, l = {
32
- onSelectionChanged: (t) => {
33
+ const a = () => this.props, h = {
34
+ onSelectionChanged: (o) => {
33
35
  var e, n;
34
- return (n = (e = r()).selectionChanged) == null ? void 0 : n.call(e, t);
36
+ return (n = (e = a()).selectionChanged) == null ? void 0 : n.call(e, o);
35
37
  },
36
- onFocusChanged: (t) => {
38
+ onFocusChanged: (o) => {
37
39
  var e, n;
38
- return (n = (e = r()).focusChanged) == null ? void 0 : n.call(e, t);
40
+ return (n = (e = a()).focusChanged) == null ? void 0 : n.call(e, o);
39
41
  },
40
- onScroll: (t) => {
42
+ onScroll: (o) => {
41
43
  var e, n;
42
- return (n = (e = r()).scroll) == null ? void 0 : n.call(e, t);
44
+ return (n = (e = a()).scroll) == null ? void 0 : n.call(e, o);
43
45
  },
44
- onCheckboxChanged: (t) => {
46
+ onCheckboxChanged: (o) => {
45
47
  var e, n;
46
- return (n = (e = r()).checkboxChanged) == null ? void 0 : n.call(e, t);
48
+ return (n = (e = a()).checkboxChanged) == null ? void 0 : n.call(e, o);
47
49
  },
48
- onContextmenu: (t) => {
50
+ onContextmenu: (o) => {
49
51
  var e, n;
50
- return (n = (e = r()).contextmenu) == null ? void 0 : n.call(e, t);
52
+ return (n = (e = a()).contextmenu) == null ? void 0 : n.call(e, o);
51
53
  },
52
- onModelChanged: (t) => {
54
+ onModelChanged: (o) => {
53
55
  var e, n;
54
- return (n = (e = r()).modelChanged) == null ? void 0 : n.call(e, t);
56
+ return (n = (e = a()).modelChanged) == null ? void 0 : n.call(e, o);
55
57
  },
56
- onMouseClicked: (t) => {
58
+ onMouseClicked: (o) => {
57
59
  var e, n;
58
- return (n = (e = r()).mouseClicked) == null ? void 0 : n.call(e, t);
60
+ return (n = (e = a()).mouseClicked) == null ? void 0 : n.call(e, o);
59
61
  },
60
- onMouseDragging: (t) => {
62
+ onMouseDragging: (o) => {
61
63
  var e, n;
62
- return (n = (e = r()).mouseDragging) == null ? void 0 : n.call(e, t);
64
+ return (n = (e = a()).mouseDragging) == null ? void 0 : n.call(e, o);
63
65
  },
64
- onMouseDraggingEnd: (t) => {
66
+ onMouseDraggingEnd: (o) => {
65
67
  var e, n;
66
- return (n = (e = r()).mouseDraggingEnd) == null ? void 0 : n.call(e, t);
68
+ return (n = (e = a()).mouseDraggingEnd) == null ? void 0 : n.call(e, o);
67
69
  },
68
- onMouseMoved: (t) => {
70
+ onMouseMoved: (o) => {
69
71
  var e, n;
70
- return (n = (e = r()).mouseMoved) == null ? void 0 : n.call(e, t);
72
+ return (n = (e = a()).mouseMoved) == null ? void 0 : n.call(e, o);
73
+ },
74
+ onStateChanged: (o) => {
75
+ var e, n;
76
+ return (n = (e = a()).stateChanged) == null ? void 0 : n.call(e, o);
71
77
  }
72
- }, c = new M(
73
- o,
78
+ }, l = new S(
79
+ t,
74
80
  s.tableModel,
75
- new S(),
76
- s.tableOptions ?? new T(),
77
- l
81
+ new M(),
82
+ s.tableOptions ?? new w(),
83
+ h
78
84
  );
79
- this.tableScope = c, c.firstInit(), (d = s.tableReady) == null || d.call(s, c.getApi()), s.licenseKey && m.getInstance().setLicenseKey(s.licenseKey);
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);
80
91
  }
81
92
  /** Releases the table (listeners, resize observer, cell renderers). */
82
93
  destroyTable() {
83
- var o;
84
- (o = this.tableScope) == null || o.destroy(), this.tableScope = void 0;
94
+ var t;
95
+ (t = this.tableScope) == null || t.destroy(), this.tableScope = void 0;
85
96
  }
86
97
  render() {
87
- return /* @__PURE__ */ u(
98
+ return /* @__PURE__ */ y(
88
99
  "div",
89
100
  {
90
101
  ref: this.ref,
@@ -100,21 +111,21 @@ class w extends C {
100
111
  );
101
112
  }
102
113
  }
103
- class O {
114
+ class k {
104
115
  constructor(i) {
105
116
  this.Component = i;
106
117
  }
107
- render(i, o, s, r, l, c, d) {
108
- const t = {
118
+ render(i, t, s, a, h, l, d) {
119
+ const o = {
109
120
  cellDiv: i,
110
- rowIndex: o,
121
+ rowIndex: t,
111
122
  columnIndex: s,
112
- areaIdent: r,
113
- areaModel: l,
114
- cellValue: c
123
+ areaIdent: a,
124
+ areaModel: h,
125
+ cellValue: l
115
126
  };
116
- return g(f(this.Component, t), i), () => {
117
- g(null, i);
127
+ return p(C(this.Component, o), i), () => {
128
+ p(null, i);
118
129
  };
119
130
  }
120
131
  // private mount(
@@ -138,6 +149,6 @@ class O {
138
149
  // }
139
150
  }
140
151
  export {
141
- O as ComponentRendererWrapper,
142
- w as GuiexpertTable
152
+ k as ComponentRendererWrapper,
153
+ O as GuiexpertTable
143
154
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guiexpert/preact-table",
3
- "version": "10.1.91",
3
+ "version": "10.1.93",
4
4
  "license": "MIT",
5
5
  "author": "Dr. Marc Kronberg <info@gui.expert> (https://gui.expert)",
6
6
  "repository": {
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "tslib": "^2.3.0",
34
- "@guiexpert/table": "^1.1.91"
34
+ "@guiexpert/table": "^1.1.93"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "preact": "^10.0.0"