@guiexpert/preact-table 10.1.94 → 10.1.97
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/DetailComponentRendererWrapper.d.ts +27 -0
- package/GuiexpertTable.d.ts +12 -1
- package/index.cjs +1 -1
- package/index.d.ts +1 -0
- package/index.js +98 -68
- package/package.json +2 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DetailRenderContextIf, DetailRendererIf, TableApi } from '@guiexpert/table';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The props of a Preact component that renders a detail row (master/detail).
|
|
5
|
+
*
|
|
6
|
+
* @since 1.1.97
|
|
7
|
+
*/
|
|
8
|
+
export interface DetailComponentProps<T = any> {
|
|
9
|
+
row: T;
|
|
10
|
+
rowIndex: number;
|
|
11
|
+
tableApi: TableApi;
|
|
12
|
+
context: DetailRenderContextIf<T>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Renders a Preact component as the content of a detail row (master/detail, `tableOptions.masterDetail`). Mounted
|
|
16
|
+
* once when the detail row becomes visible, kept while scrolling, unmounted when it is collapsed.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* masterDetail: { detailHeight: 180, detailRenderer: new DetailComponentRendererWrapper(OrderItems) }
|
|
20
|
+
*
|
|
21
|
+
* @since 1.1.97
|
|
22
|
+
*/
|
|
23
|
+
export declare class DetailComponentRendererWrapper<T = any> implements DetailRendererIf<T> {
|
|
24
|
+
private readonly Component;
|
|
25
|
+
constructor(Component: any);
|
|
26
|
+
render(container: HTMLDivElement, row: T, context: DetailRenderContextIf<T>): () => void;
|
|
27
|
+
}
|
package/GuiexpertTable.d.ts
CHANGED
|
@@ -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, GeDetailEvent, 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,9 @@ 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;
|
|
14
|
+
export type GeDetailEventFn = (evt: GeDetailEvent) => void;
|
|
12
15
|
export interface GuiexpertTableProps {
|
|
13
16
|
tableModel: TableModelIf;
|
|
14
17
|
tableOptions?: TableOptions;
|
|
@@ -30,6 +33,14 @@ export interface GuiexpertTableProps {
|
|
|
30
33
|
* @since 1.1.92
|
|
31
34
|
*/
|
|
32
35
|
stateChanged?: GeStateChangeEventFn;
|
|
36
|
+
/** Row drag (since 1.1.95, handles via `ColumnDef.rowDrag`): started / target changed / ended ("end" or "cancel"). */
|
|
37
|
+
rowDragStart?: GeRowDragEventFn;
|
|
38
|
+
rowDragMove?: GeRowDragEventFn;
|
|
39
|
+
rowDragEnd?: GeRowDragEventFn;
|
|
40
|
+
/** Batch edit: values marked, set back, written or discarded (since 1.1.96). */
|
|
41
|
+
batchEditChanged?: GeBatchEditEventFn;
|
|
42
|
+
/** Master/detail: a detail row was expanded or collapsed (since 1.1.97). */
|
|
43
|
+
detailExpandedChanged?: GeDetailEventFn;
|
|
33
44
|
/**
|
|
34
45
|
* `true` shows the loading overlay ("Loading…" with a CSS spinner) over the body, `false` hides it.
|
|
35
46
|
* 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=(
|
|
1
|
+
"use strict";var u=Object.defineProperty;var b=(s,a,o)=>a in s?u(s,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):s[a]=o;var h=(s,a,o)=>b(s,typeof a!="symbol"?a+"":a,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("preact/jsx-runtime"),l=require("preact"),c=require("@guiexpert/table");class m extends l.Component{constructor(o){super(o);h(this,"ref",l.createRef());h(this,"tableScope");h(this,"shownByProp",!1)}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),!!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,i){var g;this.destroyTable();const r=()=>this.props,p={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)},onStateChanged:t=>{var e,n;return(n=(e=r()).stateChanged)==null?void 0:n.call(e,t)},onRowDragStart:t=>{var e,n;return(n=(e=r()).rowDragStart)==null?void 0:n.call(e,t)},onRowDragMove:t=>{var e,n;return(n=(e=r()).rowDragMove)==null?void 0:n.call(e,t)},onRowDragEnd:t=>{var e,n;return(n=(e=r()).rowDragEnd)==null?void 0:n.call(e,t)},onBatchEditChanged:t=>{var e,n;return(n=(e=r()).batchEditChanged)==null?void 0:n.call(e,t)},onDetailExpandedChanged:t=>{var e,n;return(n=(e=r()).detailExpandedChanged)==null?void 0:n.call(e,t)}},d=new c.TableScope(o,i.tableModel,new c.SimpleDomService,i.tableOptions??new c.TableOptions,p);this.tableScope=d,d.firstInit(),this.shownByProp=!1,this.applyLoading(),(g=i.tableReady)==null||g.call(i,d.getApi()),i.licenseKey&&c.LicenseManager.getInstance().setLicenseKey(i.licenseKey)}applyLoading(){var o,i;this.props.loading?((o=this.tableScope)==null||o.showLoadingOverlay(),this.shownByProp=!0):this.shownByProp&&((i=this.tableScope)==null||i.hideOverlay(),this.shownByProp=!1)}destroyTable(){var o;(o=this.tableScope)==null||o.destroy(),this.tableScope=void 0}render(){return C.jsx("div",{ref:this.ref,className:"container-div",style:{width:"100%",height:"100%",backgroundColor:"transparent",padding:"0",margin:"0"}})}}class y{constructor(a){this.Component=a}render(a,o,i,r,p,d,g){const t={cellDiv:a,rowIndex:o,columnIndex:i,areaIdent:r,areaModel:p,cellValue:d};return l.render(l.h(this.Component,t),a),()=>{l.render(null,a)}}}class f{constructor(a){this.Component=a}render(a,o,i){const r={row:o,rowIndex:i.rowIndex,tableApi:i.tableApi,context:i};return l.render(l.h(this.Component,r),a),()=>l.render(null,a)}}exports.ComponentRendererWrapper=y;exports.DetailComponentRendererWrapper=f;exports.GuiexpertTable=m;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { Component as
|
|
6
|
-
import { LicenseManager as g, TableScope as
|
|
7
|
-
class
|
|
8
|
-
constructor(
|
|
9
|
-
super(
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
var b = Object.defineProperty;
|
|
2
|
+
var C = (r, s, o) => s in r ? b(r, s, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[s] = o;
|
|
3
|
+
var d = (r, s, o) => C(r, typeof s != "symbol" ? s + "" : s, o);
|
|
4
|
+
import { jsx as u } from "preact/jsx-runtime";
|
|
5
|
+
import { Component as y, createRef as f, render as h, h as m } from "preact";
|
|
6
|
+
import { LicenseManager as g, TableScope as w, SimpleDomService as S, TableOptions as M } from "@guiexpert/table";
|
|
7
|
+
class K extends y {
|
|
8
|
+
constructor(o) {
|
|
9
|
+
super(o);
|
|
10
|
+
d(this, "ref", f());
|
|
11
|
+
d(this, "tableScope");
|
|
12
12
|
/** the overlay was shown by the loading prop: loading={false} hides only that one */
|
|
13
|
-
|
|
13
|
+
d(this, "shownByProp", !1);
|
|
14
14
|
}
|
|
15
15
|
componentDidMount() {
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
const o = this.ref.current;
|
|
17
|
+
o && this.initTable(o, this.props);
|
|
18
18
|
}
|
|
19
|
-
componentDidUpdate(
|
|
20
|
-
const
|
|
21
|
-
|
|
19
|
+
componentDidUpdate(o) {
|
|
20
|
+
const a = this.ref.current;
|
|
21
|
+
a && (o.tableModel !== this.props.tableModel || o.tableOptions !== this.props.tableOptions) && this.initTable(a, this.props), !!o.loading != !!this.props.loading && this.applyLoading(), this.props.licenseKey && this.props.licenseKey !== o.licenseKey && g.getInstance().setLicenseKey(this.props.licenseKey);
|
|
22
22
|
}
|
|
23
23
|
componentWillUnmount() {
|
|
24
24
|
this.destroyTable();
|
|
@@ -27,75 +27,95 @@ 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(
|
|
31
|
-
var
|
|
30
|
+
initTable(o, a) {
|
|
31
|
+
var p;
|
|
32
32
|
this.destroyTable();
|
|
33
|
-
const
|
|
34
|
-
onSelectionChanged: (
|
|
33
|
+
const i = () => this.props, c = {
|
|
34
|
+
onSelectionChanged: (t) => {
|
|
35
35
|
var e, n;
|
|
36
|
-
return (n = (e =
|
|
36
|
+
return (n = (e = i()).selectionChanged) == null ? void 0 : n.call(e, t);
|
|
37
37
|
},
|
|
38
|
-
onFocusChanged: (
|
|
38
|
+
onFocusChanged: (t) => {
|
|
39
39
|
var e, n;
|
|
40
|
-
return (n = (e =
|
|
40
|
+
return (n = (e = i()).focusChanged) == null ? void 0 : n.call(e, t);
|
|
41
41
|
},
|
|
42
|
-
onScroll: (
|
|
42
|
+
onScroll: (t) => {
|
|
43
43
|
var e, n;
|
|
44
|
-
return (n = (e =
|
|
44
|
+
return (n = (e = i()).scroll) == null ? void 0 : n.call(e, t);
|
|
45
45
|
},
|
|
46
|
-
onCheckboxChanged: (
|
|
46
|
+
onCheckboxChanged: (t) => {
|
|
47
47
|
var e, n;
|
|
48
|
-
return (n = (e =
|
|
48
|
+
return (n = (e = i()).checkboxChanged) == null ? void 0 : n.call(e, t);
|
|
49
49
|
},
|
|
50
|
-
onContextmenu: (
|
|
50
|
+
onContextmenu: (t) => {
|
|
51
51
|
var e, n;
|
|
52
|
-
return (n = (e =
|
|
52
|
+
return (n = (e = i()).contextmenu) == null ? void 0 : n.call(e, t);
|
|
53
53
|
},
|
|
54
|
-
onModelChanged: (
|
|
54
|
+
onModelChanged: (t) => {
|
|
55
55
|
var e, n;
|
|
56
|
-
return (n = (e =
|
|
56
|
+
return (n = (e = i()).modelChanged) == null ? void 0 : n.call(e, t);
|
|
57
57
|
},
|
|
58
|
-
onMouseClicked: (
|
|
58
|
+
onMouseClicked: (t) => {
|
|
59
59
|
var e, n;
|
|
60
|
-
return (n = (e =
|
|
60
|
+
return (n = (e = i()).mouseClicked) == null ? void 0 : n.call(e, t);
|
|
61
61
|
},
|
|
62
|
-
onMouseDragging: (
|
|
62
|
+
onMouseDragging: (t) => {
|
|
63
63
|
var e, n;
|
|
64
|
-
return (n = (e =
|
|
64
|
+
return (n = (e = i()).mouseDragging) == null ? void 0 : n.call(e, t);
|
|
65
65
|
},
|
|
66
|
-
onMouseDraggingEnd: (
|
|
66
|
+
onMouseDraggingEnd: (t) => {
|
|
67
67
|
var e, n;
|
|
68
|
-
return (n = (e =
|
|
68
|
+
return (n = (e = i()).mouseDraggingEnd) == null ? void 0 : n.call(e, t);
|
|
69
69
|
},
|
|
70
|
-
onMouseMoved: (
|
|
70
|
+
onMouseMoved: (t) => {
|
|
71
71
|
var e, n;
|
|
72
|
-
return (n = (e =
|
|
72
|
+
return (n = (e = i()).mouseMoved) == null ? void 0 : n.call(e, t);
|
|
73
73
|
},
|
|
74
|
-
onStateChanged: (
|
|
74
|
+
onStateChanged: (t) => {
|
|
75
75
|
var e, n;
|
|
76
|
-
return (n = (e =
|
|
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);
|
|
93
|
+
},
|
|
94
|
+
onDetailExpandedChanged: (t) => {
|
|
95
|
+
var e, n;
|
|
96
|
+
return (n = (e = i()).detailExpandedChanged) == null ? void 0 : n.call(e, t);
|
|
77
97
|
}
|
|
78
|
-
}, l = new
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
new
|
|
82
|
-
|
|
83
|
-
|
|
98
|
+
}, l = new w(
|
|
99
|
+
o,
|
|
100
|
+
a.tableModel,
|
|
101
|
+
new S(),
|
|
102
|
+
a.tableOptions ?? new M(),
|
|
103
|
+
c
|
|
84
104
|
);
|
|
85
|
-
this.tableScope = l, l.firstInit(), this.shownByProp = !1, this.applyLoading(), (
|
|
105
|
+
this.tableScope = l, l.firstInit(), this.shownByProp = !1, this.applyLoading(), (p = a.tableReady) == null || p.call(a, l.getApi()), a.licenseKey && g.getInstance().setLicenseKey(a.licenseKey);
|
|
86
106
|
}
|
|
87
107
|
/** Shows or hides the loading overlay according to the `loading` prop. */
|
|
88
108
|
applyLoading() {
|
|
89
|
-
var
|
|
90
|
-
this.props.loading ? ((
|
|
109
|
+
var o, a;
|
|
110
|
+
this.props.loading ? ((o = this.tableScope) == null || o.showLoadingOverlay(), this.shownByProp = !0) : this.shownByProp && ((a = this.tableScope) == null || a.hideOverlay(), this.shownByProp = !1);
|
|
91
111
|
}
|
|
92
112
|
/** Releases the table (listeners, resize observer, cell renderers). */
|
|
93
113
|
destroyTable() {
|
|
94
|
-
var
|
|
95
|
-
(
|
|
114
|
+
var o;
|
|
115
|
+
(o = this.tableScope) == null || o.destroy(), this.tableScope = void 0;
|
|
96
116
|
}
|
|
97
117
|
render() {
|
|
98
|
-
return /* @__PURE__ */
|
|
118
|
+
return /* @__PURE__ */ u(
|
|
99
119
|
"div",
|
|
100
120
|
{
|
|
101
121
|
ref: this.ref,
|
|
@@ -111,21 +131,21 @@ class O extends u {
|
|
|
111
131
|
);
|
|
112
132
|
}
|
|
113
133
|
}
|
|
114
|
-
class
|
|
115
|
-
constructor(
|
|
116
|
-
this.Component =
|
|
134
|
+
class L {
|
|
135
|
+
constructor(s) {
|
|
136
|
+
this.Component = s;
|
|
117
137
|
}
|
|
118
|
-
render(
|
|
119
|
-
const
|
|
120
|
-
cellDiv:
|
|
121
|
-
rowIndex:
|
|
122
|
-
columnIndex:
|
|
123
|
-
areaIdent:
|
|
124
|
-
areaModel:
|
|
138
|
+
render(s, o, a, i, c, l, p) {
|
|
139
|
+
const t = {
|
|
140
|
+
cellDiv: s,
|
|
141
|
+
rowIndex: o,
|
|
142
|
+
columnIndex: a,
|
|
143
|
+
areaIdent: i,
|
|
144
|
+
areaModel: c,
|
|
125
145
|
cellValue: l
|
|
126
146
|
};
|
|
127
|
-
return
|
|
128
|
-
|
|
147
|
+
return h(m(this.Component, t), s), () => {
|
|
148
|
+
h(null, s);
|
|
129
149
|
};
|
|
130
150
|
}
|
|
131
151
|
// private mount(
|
|
@@ -148,7 +168,17 @@ class k {
|
|
|
148
168
|
// return cleanupFn;
|
|
149
169
|
// }
|
|
150
170
|
}
|
|
171
|
+
class R {
|
|
172
|
+
constructor(s) {
|
|
173
|
+
this.Component = s;
|
|
174
|
+
}
|
|
175
|
+
render(s, o, a) {
|
|
176
|
+
const i = { row: o, rowIndex: a.rowIndex, tableApi: a.tableApi, context: a };
|
|
177
|
+
return h(m(this.Component, i), s), () => h(null, s);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
151
180
|
export {
|
|
152
|
-
|
|
153
|
-
|
|
181
|
+
L as ComponentRendererWrapper,
|
|
182
|
+
R as DetailComponentRendererWrapper,
|
|
183
|
+
K as GuiexpertTable
|
|
154
184
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guiexpert/preact-table",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.97",
|
|
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.
|
|
34
|
+
"@guiexpert/table": "^1.1.97"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"preact": "^10.0.0"
|