@guiexpert/preact-table 10.1.96 → 10.1.98
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 +4 -1
- package/index.cjs +1 -1
- package/index.d.ts +1 -0
- package/index.js +47 -33
- 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, GeBatchEditEvent, GeMouseEvent, GeRowDragEvent, 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;
|
|
@@ -11,6 +11,7 @@ export type GeScrollEventFn = (evt: GeScrollEvent) => void;
|
|
|
11
11
|
export type GeStateChangeEventFn = (evt: GeStateChangeEvent) => void;
|
|
12
12
|
export type GeRowDragEventFn = (evt: GeRowDragEvent) => void;
|
|
13
13
|
export type GeBatchEditEventFn = (evt: GeBatchEditEvent) => void;
|
|
14
|
+
export type GeDetailEventFn = (evt: GeDetailEvent) => void;
|
|
14
15
|
export interface GuiexpertTableProps {
|
|
15
16
|
tableModel: TableModelIf;
|
|
16
17
|
tableOptions?: TableOptions;
|
|
@@ -38,6 +39,8 @@ export interface GuiexpertTableProps {
|
|
|
38
39
|
rowDragEnd?: GeRowDragEventFn;
|
|
39
40
|
/** Batch edit: values marked, set back, written or discarded (since 1.1.96). */
|
|
40
41
|
batchEditChanged?: GeBatchEditEventFn;
|
|
42
|
+
/** Master/detail: a detail row was expanded or collapsed (since 1.1.97). */
|
|
43
|
+
detailExpandedChanged?: GeDetailEventFn;
|
|
41
44
|
/**
|
|
42
45
|
* `true` shows the loading overlay ("Loading…" with a CSS spinner) over the body, `false` hides it.
|
|
43
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
|
|
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
|
|
7
|
-
class
|
|
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
8
|
constructor(o) {
|
|
9
9
|
super(o);
|
|
10
|
-
|
|
11
|
-
|
|
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
16
|
const o = this.ref.current;
|
|
17
17
|
o && this.initTable(o, this.props);
|
|
18
18
|
}
|
|
19
19
|
componentDidUpdate(o) {
|
|
20
|
-
const
|
|
21
|
-
|
|
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,10 +27,10 @@ class L 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(o,
|
|
31
|
-
var
|
|
30
|
+
initTable(o, a) {
|
|
31
|
+
var p;
|
|
32
32
|
this.destroyTable();
|
|
33
|
-
const i = () => this.props,
|
|
33
|
+
const i = () => this.props, c = {
|
|
34
34
|
onSelectionChanged: (t) => {
|
|
35
35
|
var e, n;
|
|
36
36
|
return (n = (e = i()).selectionChanged) == null ? void 0 : n.call(e, t);
|
|
@@ -90,20 +90,24 @@ class L extends u {
|
|
|
90
90
|
onBatchEditChanged: (t) => {
|
|
91
91
|
var e, n;
|
|
92
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);
|
|
93
97
|
}
|
|
94
98
|
}, l = new w(
|
|
95
99
|
o,
|
|
96
|
-
|
|
100
|
+
a.tableModel,
|
|
97
101
|
new S(),
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
a.tableOptions ?? new M(),
|
|
103
|
+
c
|
|
100
104
|
);
|
|
101
|
-
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);
|
|
102
106
|
}
|
|
103
107
|
/** Shows or hides the loading overlay according to the `loading` prop. */
|
|
104
108
|
applyLoading() {
|
|
105
|
-
var o,
|
|
106
|
-
this.props.loading ? ((o = this.tableScope) == null || o.showLoadingOverlay(), this.shownByProp = !0) : this.shownByProp && ((
|
|
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);
|
|
107
111
|
}
|
|
108
112
|
/** Releases the table (listeners, resize observer, cell renderers). */
|
|
109
113
|
destroyTable() {
|
|
@@ -111,7 +115,7 @@ class L extends u {
|
|
|
111
115
|
(o = this.tableScope) == null || o.destroy(), this.tableScope = void 0;
|
|
112
116
|
}
|
|
113
117
|
render() {
|
|
114
|
-
return /* @__PURE__ */
|
|
118
|
+
return /* @__PURE__ */ u(
|
|
115
119
|
"div",
|
|
116
120
|
{
|
|
117
121
|
ref: this.ref,
|
|
@@ -127,21 +131,21 @@ class L extends u {
|
|
|
127
131
|
);
|
|
128
132
|
}
|
|
129
133
|
}
|
|
130
|
-
class
|
|
131
|
-
constructor(
|
|
132
|
-
this.Component =
|
|
134
|
+
class L {
|
|
135
|
+
constructor(s) {
|
|
136
|
+
this.Component = s;
|
|
133
137
|
}
|
|
134
|
-
render(
|
|
138
|
+
render(s, o, a, i, c, l, p) {
|
|
135
139
|
const t = {
|
|
136
|
-
cellDiv:
|
|
140
|
+
cellDiv: s,
|
|
137
141
|
rowIndex: o,
|
|
138
|
-
columnIndex:
|
|
142
|
+
columnIndex: a,
|
|
139
143
|
areaIdent: i,
|
|
140
|
-
areaModel:
|
|
144
|
+
areaModel: c,
|
|
141
145
|
cellValue: l
|
|
142
146
|
};
|
|
143
|
-
return
|
|
144
|
-
|
|
147
|
+
return h(m(this.Component, t), s), () => {
|
|
148
|
+
h(null, s);
|
|
145
149
|
};
|
|
146
150
|
}
|
|
147
151
|
// private mount(
|
|
@@ -164,7 +168,17 @@ class v {
|
|
|
164
168
|
// return cleanupFn;
|
|
165
169
|
// }
|
|
166
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
|
+
}
|
|
167
180
|
export {
|
|
168
|
-
|
|
169
|
-
|
|
181
|
+
L as ComponentRendererWrapper,
|
|
182
|
+
R as DetailComponentRendererWrapper,
|
|
183
|
+
K as GuiexpertTable
|
|
170
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.98",
|
|
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.98"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"preact": "^10.0.0"
|