@guiexpert/preact-table 10.1.93 → 10.1.96

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, GeStateChangeEvent, SelectionModelIf, TableApi, TableModelIf, TableOptions } from '@guiexpert/table';
2
+ import { FocusModelIf, GeModelChangeEvent, GeBatchEditEvent, GeMouseEvent, GeRowDragEvent, 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;
@@ -9,6 +9,8 @@ export type GeSelectionChangeEventFn = (evt: SelectionModelIf) => void;
9
9
  export type GeFocusChangeEventFn = (evt: FocusModelIf) => void;
10
10
  export type GeScrollEventFn = (evt: GeScrollEvent) => void;
11
11
  export type GeStateChangeEventFn = (evt: GeStateChangeEvent) => void;
12
+ export type GeRowDragEventFn = (evt: GeRowDragEvent) => void;
13
+ export type GeBatchEditEventFn = (evt: GeBatchEditEvent) => void;
12
14
  export interface GuiexpertTableProps {
13
15
  tableModel: TableModelIf;
14
16
  tableOptions?: TableOptions;
@@ -30,6 +32,12 @@ export interface GuiexpertTableProps {
30
32
  * @since 1.1.92
31
33
  */
32
34
  stateChanged?: GeStateChangeEventFn;
35
+ /** Row drag (since 1.1.95, handles via `ColumnDef.rowDrag`): started / target changed / ended ("end" or "cancel"). */
36
+ rowDragStart?: GeRowDragEventFn;
37
+ rowDragMove?: GeRowDragEventFn;
38
+ rowDragEnd?: GeRowDragEventFn;
39
+ /** Batch edit: values marked, set back, written or discarded (since 1.1.96). */
40
+ batchEditChanged?: GeBatchEditEventFn;
33
41
  /**
34
42
  * `true` shows the loading overlay ("Loading…" with a CSS spinner) over the body, `false` hides it.
35
43
  * Changing it does **not** re-create the table. Texts: `tableOptions.overlayOptions`. @since 1.1.92
package/index.cjs CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";var b=Object.defineProperty;var u=(r,a,o)=>a in r?b(r,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[a]=o;var h=(r,a,o)=>u(r,typeof a!="symbol"?a+"":a,o);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(o){super(o);h(this,"ref",d.createRef());h(this,"tableScope");h(this,"shownByProp",!1)}componentDidMount(){const o=this.ref.current;o&&this.initTable(o,this.props)}componentDidUpdate(o){const s=this.ref.current;s&&(o.tableModel!==this.props.tableModel||o.tableOptions!==this.props.tableOptions)&&this.initTable(s,this.props),!!o.loading!=!!this.props.loading&&this.applyLoading(),this.props.licenseKey&&this.props.licenseKey!==o.licenseKey&&c.LicenseManager.getInstance().setLicenseKey(this.props.licenseKey)}componentWillUnmount(){this.destroyTable()}initTable(o,s){var p;this.destroyTable();const i=()=>this.props,g={onSelectionChanged:t=>{var e,n;return(n=(e=i()).selectionChanged)==null?void 0:n.call(e,t)},onFocusChanged:t=>{var e,n;return(n=(e=i()).focusChanged)==null?void 0:n.call(e,t)},onScroll:t=>{var e,n;return(n=(e=i()).scroll)==null?void 0:n.call(e,t)},onCheckboxChanged:t=>{var e,n;return(n=(e=i()).checkboxChanged)==null?void 0:n.call(e,t)},onContextmenu:t=>{var e,n;return(n=(e=i()).contextmenu)==null?void 0:n.call(e,t)},onModelChanged:t=>{var e,n;return(n=(e=i()).modelChanged)==null?void 0:n.call(e,t)},onMouseClicked:t=>{var e,n;return(n=(e=i()).mouseClicked)==null?void 0:n.call(e,t)},onMouseDragging:t=>{var e,n;return(n=(e=i()).mouseDragging)==null?void 0:n.call(e,t)},onMouseDraggingEnd:t=>{var e,n;return(n=(e=i()).mouseDraggingEnd)==null?void 0:n.call(e,t)},onMouseMoved:t=>{var e,n;return(n=(e=i()).mouseMoved)==null?void 0:n.call(e,t)},onStateChanged:t=>{var e,n;return(n=(e=i()).stateChanged)==null?void 0:n.call(e,t)},onRowDragStart:t=>{var e,n;return(n=(e=i()).rowDragStart)==null?void 0:n.call(e,t)},onRowDragMove:t=>{var e,n;return(n=(e=i()).rowDragMove)==null?void 0:n.call(e,t)},onRowDragEnd:t=>{var e,n;return(n=(e=i()).rowDragEnd)==null?void 0:n.call(e,t)},onBatchEditChanged:t=>{var e,n;return(n=(e=i()).batchEditChanged)==null?void 0:n.call(e,t)}},l=new c.TableScope(o,s.tableModel,new c.SimpleDomService,s.tableOptions??new c.TableOptions,g);this.tableScope=l,l.firstInit(),this.shownByProp=!1,this.applyLoading(),(p=s.tableReady)==null||p.call(s,l.getApi()),s.licenseKey&&c.LicenseManager.getInstance().setLicenseKey(s.licenseKey)}applyLoading(){var o,s;this.props.loading?((o=this.tableScope)==null||o.showLoadingOverlay(),this.shownByProp=!0):this.shownByProp&&((s=this.tableScope)==null||s.hideOverlay(),this.shownByProp=!1)}destroyTable(){var o;(o=this.tableScope)==null||o.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(a){this.Component=a}render(a,o,s,i,g,l,p){const t={cellDiv:a,rowIndex:o,columnIndex:s,areaIdent:i,areaModel:g,cellValue:l};return d.render(d.h(this.Component,t),a),()=>{d.render(null,a)}}}exports.ComponentRendererWrapper=C;exports.GuiexpertTable=m;
package/index.js CHANGED
@@ -1,24 +1,24 @@
1
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);
2
+ var b = (r, a, o) => a in r ? m(r, a, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[a] = o;
3
+ var h = (r, a, o) => b(r, typeof a != "symbol" ? a + "" : a, o);
4
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");
5
+ import { Component as u, createRef as C, render as g, h as f } from "preact";
6
+ import { LicenseManager as p, TableScope as w, SimpleDomService as S, TableOptions as M } from "@guiexpert/table";
7
+ class L extends u {
8
+ constructor(o) {
9
+ super(o);
10
+ h(this, "ref", C());
11
+ h(this, "tableScope");
12
12
  /** the overlay was shown by the loading prop: loading={false} hides only that one */
13
- c(this, "shownByProp", !1);
13
+ h(this, "shownByProp", !1);
14
14
  }
15
15
  componentDidMount() {
16
- const t = this.ref.current;
17
- t && this.initTable(t, this.props);
16
+ const o = this.ref.current;
17
+ o && this.initTable(o, this.props);
18
18
  }
19
- componentDidUpdate(t) {
19
+ componentDidUpdate(o) {
20
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);
21
+ s && (o.tableModel !== this.props.tableModel || o.tableOptions !== this.props.tableOptions) && this.initTable(s, this.props), !!o.loading != !!this.props.loading && this.applyLoading(), this.props.licenseKey && this.props.licenseKey !== o.licenseKey && p.getInstance().setLicenseKey(this.props.licenseKey);
22
22
  }
23
23
  componentWillUnmount() {
24
24
  this.destroyTable();
@@ -27,72 +27,88 @@ class O extends u {
27
27
  * Creates the table in `ele` (a table created before is destroyed first) and calls `tableReady`.
28
28
  * The event callbacks are always taken from the current props.
29
29
  */
30
- initTable(t, s) {
31
- var d;
30
+ initTable(o, s) {
31
+ var c;
32
32
  this.destroyTable();
33
- const a = () => this.props, h = {
34
- onSelectionChanged: (o) => {
33
+ const i = () => this.props, d = {
34
+ onSelectionChanged: (t) => {
35
35
  var e, n;
36
- return (n = (e = a()).selectionChanged) == null ? void 0 : n.call(e, o);
36
+ return (n = (e = i()).selectionChanged) == null ? void 0 : n.call(e, t);
37
37
  },
38
- onFocusChanged: (o) => {
38
+ onFocusChanged: (t) => {
39
39
  var e, n;
40
- return (n = (e = a()).focusChanged) == null ? void 0 : n.call(e, o);
40
+ return (n = (e = i()).focusChanged) == null ? void 0 : n.call(e, t);
41
41
  },
42
- onScroll: (o) => {
42
+ onScroll: (t) => {
43
43
  var e, n;
44
- return (n = (e = a()).scroll) == null ? void 0 : n.call(e, o);
44
+ return (n = (e = i()).scroll) == null ? void 0 : n.call(e, t);
45
45
  },
46
- onCheckboxChanged: (o) => {
46
+ onCheckboxChanged: (t) => {
47
47
  var e, n;
48
- return (n = (e = a()).checkboxChanged) == null ? void 0 : n.call(e, o);
48
+ return (n = (e = i()).checkboxChanged) == null ? void 0 : n.call(e, t);
49
49
  },
50
- onContextmenu: (o) => {
50
+ onContextmenu: (t) => {
51
51
  var e, n;
52
- return (n = (e = a()).contextmenu) == null ? void 0 : n.call(e, o);
52
+ return (n = (e = i()).contextmenu) == null ? void 0 : n.call(e, t);
53
53
  },
54
- onModelChanged: (o) => {
54
+ onModelChanged: (t) => {
55
55
  var e, n;
56
- return (n = (e = a()).modelChanged) == null ? void 0 : n.call(e, o);
56
+ return (n = (e = i()).modelChanged) == null ? void 0 : n.call(e, t);
57
57
  },
58
- onMouseClicked: (o) => {
58
+ onMouseClicked: (t) => {
59
59
  var e, n;
60
- return (n = (e = a()).mouseClicked) == null ? void 0 : n.call(e, o);
60
+ return (n = (e = i()).mouseClicked) == null ? void 0 : n.call(e, t);
61
61
  },
62
- onMouseDragging: (o) => {
62
+ onMouseDragging: (t) => {
63
63
  var e, n;
64
- return (n = (e = a()).mouseDragging) == null ? void 0 : n.call(e, o);
64
+ return (n = (e = i()).mouseDragging) == null ? void 0 : n.call(e, t);
65
65
  },
66
- onMouseDraggingEnd: (o) => {
66
+ onMouseDraggingEnd: (t) => {
67
67
  var e, n;
68
- return (n = (e = a()).mouseDraggingEnd) == null ? void 0 : n.call(e, o);
68
+ return (n = (e = i()).mouseDraggingEnd) == null ? void 0 : n.call(e, t);
69
69
  },
70
- onMouseMoved: (o) => {
70
+ onMouseMoved: (t) => {
71
71
  var e, n;
72
- return (n = (e = a()).mouseMoved) == null ? void 0 : n.call(e, o);
72
+ return (n = (e = i()).mouseMoved) == null ? void 0 : n.call(e, t);
73
73
  },
74
- onStateChanged: (o) => {
74
+ onStateChanged: (t) => {
75
75
  var e, n;
76
- return (n = (e = a()).stateChanged) == null ? void 0 : n.call(e, o);
76
+ return (n = (e = i()).stateChanged) == null ? void 0 : n.call(e, t);
77
+ },
78
+ onRowDragStart: (t) => {
79
+ var e, n;
80
+ return (n = (e = i()).rowDragStart) == null ? void 0 : n.call(e, t);
81
+ },
82
+ onRowDragMove: (t) => {
83
+ var e, n;
84
+ return (n = (e = i()).rowDragMove) == null ? void 0 : n.call(e, t);
85
+ },
86
+ onRowDragEnd: (t) => {
87
+ var e, n;
88
+ return (n = (e = i()).rowDragEnd) == null ? void 0 : n.call(e, t);
89
+ },
90
+ onBatchEditChanged: (t) => {
91
+ var e, n;
92
+ return (n = (e = i()).batchEditChanged) == null ? void 0 : n.call(e, t);
77
93
  }
78
- }, l = new S(
79
- t,
94
+ }, l = new w(
95
+ o,
80
96
  s.tableModel,
81
- new M(),
82
- s.tableOptions ?? new w(),
83
- h
97
+ new S(),
98
+ s.tableOptions ?? new M(),
99
+ d
84
100
  );
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);
101
+ this.tableScope = l, l.firstInit(), this.shownByProp = !1, this.applyLoading(), (c = s.tableReady) == null || c.call(s, l.getApi()), s.licenseKey && p.getInstance().setLicenseKey(s.licenseKey);
86
102
  }
87
103
  /** Shows or hides the loading overlay according to the `loading` prop. */
88
104
  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);
105
+ var o, s;
106
+ this.props.loading ? ((o = this.tableScope) == null || o.showLoadingOverlay(), this.shownByProp = !0) : this.shownByProp && ((s = this.tableScope) == null || s.hideOverlay(), this.shownByProp = !1);
91
107
  }
92
108
  /** Releases the table (listeners, resize observer, cell renderers). */
93
109
  destroyTable() {
94
- var t;
95
- (t = this.tableScope) == null || t.destroy(), this.tableScope = void 0;
110
+ var o;
111
+ (o = this.tableScope) == null || o.destroy(), this.tableScope = void 0;
96
112
  }
97
113
  render() {
98
114
  return /* @__PURE__ */ y(
@@ -111,21 +127,21 @@ class O extends u {
111
127
  );
112
128
  }
113
129
  }
114
- class k {
115
- constructor(i) {
116
- this.Component = i;
130
+ class v {
131
+ constructor(a) {
132
+ this.Component = a;
117
133
  }
118
- render(i, t, s, a, h, l, d) {
119
- const o = {
120
- cellDiv: i,
121
- rowIndex: t,
134
+ render(a, o, s, i, d, l, c) {
135
+ const t = {
136
+ cellDiv: a,
137
+ rowIndex: o,
122
138
  columnIndex: s,
123
- areaIdent: a,
124
- areaModel: h,
139
+ areaIdent: i,
140
+ areaModel: d,
125
141
  cellValue: l
126
142
  };
127
- return p(C(this.Component, o), i), () => {
128
- p(null, i);
143
+ return g(f(this.Component, t), a), () => {
144
+ g(null, a);
129
145
  };
130
146
  }
131
147
  // private mount(
@@ -149,6 +165,6 @@ class k {
149
165
  // }
150
166
  }
151
167
  export {
152
- k as ComponentRendererWrapper,
153
- O as GuiexpertTable
168
+ v as ComponentRendererWrapper,
169
+ L as GuiexpertTable
154
170
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guiexpert/preact-table",
3
- "version": "10.1.93",
3
+ "version": "10.1.96",
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.93"
34
+ "@guiexpert/table": "^1.1.96"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "preact": "^10.0.0"