@toolbox-web/grid-react 0.0.3 → 0.0.5
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/index.js +140 -141
- package/lib/data-grid.d.ts.map +1 -1
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as L } from "react/jsx-runtime";
|
|
2
|
-
import { DataGridElement as
|
|
3
|
-
import { useRef as G, useCallback as C, forwardRef as
|
|
2
|
+
import { DataGridElement as z } from "@toolbox-web/grid";
|
|
3
|
+
import { useRef as G, useCallback as C, forwardRef as B, useMemo as O, useEffect as R, useImperativeHandle as _, useState as x } from "react";
|
|
4
4
|
import { flushSync as b } from "react-dom";
|
|
5
5
|
import { createRoot as V } from "react-dom/client";
|
|
6
|
-
const F = /* @__PURE__ */ new WeakMap(),
|
|
7
|
-
function
|
|
6
|
+
const F = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new Map();
|
|
7
|
+
function W(n) {
|
|
8
8
|
const t = n.querySelector("tbw-grid-detail");
|
|
9
9
|
if (t) {
|
|
10
10
|
const r = F.get(t);
|
|
@@ -12,17 +12,17 @@ function H(n) {
|
|
|
12
12
|
}
|
|
13
13
|
const e = n.id || n.getAttribute("data-grid-id");
|
|
14
14
|
if (e)
|
|
15
|
-
return
|
|
15
|
+
return N.get(e);
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
const { children: t, showExpandColumn: e = !0, animation: r = "slide" } = n, i = G(null),
|
|
17
|
+
function se(n) {
|
|
18
|
+
const { children: t, showExpandColumn: e = !0, animation: r = "slide" } = n, i = G(null), s = C(
|
|
19
19
|
(d) => {
|
|
20
20
|
if (i.current = d, !d) return;
|
|
21
21
|
F.set(d, t);
|
|
22
22
|
const u = d.closest("tbw-grid");
|
|
23
23
|
if (u) {
|
|
24
24
|
const l = u.id || u.getAttribute("data-grid-id");
|
|
25
|
-
l &&
|
|
25
|
+
l && N.set(l, t);
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
[t]
|
|
@@ -30,32 +30,32 @@ function ce(n) {
|
|
|
30
30
|
return /* @__PURE__ */ L(
|
|
31
31
|
"tbw-grid-detail",
|
|
32
32
|
{
|
|
33
|
-
ref:
|
|
33
|
+
ref: s,
|
|
34
34
|
showExpandColumn: e ? void 0 : "false",
|
|
35
35
|
animation: r === !1 ? "false" : r
|
|
36
36
|
}
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function j(n) {
|
|
40
40
|
const t = /* @__PURE__ */ new WeakMap();
|
|
41
41
|
return (e) => {
|
|
42
42
|
const r = e.cellEl;
|
|
43
43
|
if (r) {
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
44
|
+
const o = t.get(r);
|
|
45
|
+
if (o)
|
|
46
46
|
return b(() => {
|
|
47
|
-
|
|
48
|
-
}),
|
|
47
|
+
o.root.render(n(e));
|
|
48
|
+
}), o.container;
|
|
49
49
|
}
|
|
50
50
|
const i = document.createElement("div");
|
|
51
51
|
i.className = "react-cell-renderer", i.style.display = "contents";
|
|
52
|
-
const
|
|
52
|
+
const s = V(i);
|
|
53
53
|
return b(() => {
|
|
54
|
-
|
|
55
|
-
}), r && t.set(r, { root:
|
|
54
|
+
s.render(n(e));
|
|
55
|
+
}), r && t.set(r, { root: s, container: i }), i;
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function $(n) {
|
|
59
59
|
return (t) => {
|
|
60
60
|
const e = document.createElement("div");
|
|
61
61
|
e.className = "react-cell-editor", e.style.display = "contents";
|
|
@@ -65,32 +65,32 @@ function J(n) {
|
|
|
65
65
|
}), e;
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function J(n) {
|
|
69
69
|
if (!n) return;
|
|
70
70
|
if (!n.columns) return n;
|
|
71
71
|
const t = n.columns.map((e) => {
|
|
72
|
-
const { renderer: r, editor: i, ...
|
|
73
|
-
return r && (
|
|
72
|
+
const { renderer: r, editor: i, ...s } = e, o = { ...s };
|
|
73
|
+
return r && (o.renderer = j(r)), i && (o.editor = $(i)), o;
|
|
74
74
|
});
|
|
75
75
|
return {
|
|
76
76
|
...n,
|
|
77
77
|
columns: t
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
const
|
|
81
|
-
function
|
|
82
|
-
const t =
|
|
80
|
+
const H = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new Map();
|
|
81
|
+
function K(n) {
|
|
82
|
+
const t = H.get(n);
|
|
83
83
|
if (t) return t;
|
|
84
84
|
const e = n.id;
|
|
85
85
|
if (e)
|
|
86
86
|
return T.get(e);
|
|
87
87
|
}
|
|
88
|
-
function
|
|
89
|
-
const { id: t, title: e, icon: r, tooltip: i, order:
|
|
88
|
+
function ce(n) {
|
|
89
|
+
const { id: t, title: e, icon: r, tooltip: i, order: s = 100, children: o } = n, d = G(null), u = C(
|
|
90
90
|
(l) => {
|
|
91
|
-
d.current = l, l && (
|
|
91
|
+
d.current = l, l && (H.set(l, o), t && T.set(t, o));
|
|
92
92
|
},
|
|
93
|
-
[
|
|
93
|
+
[o, t]
|
|
94
94
|
);
|
|
95
95
|
return /* @__PURE__ */ L(
|
|
96
96
|
"tbw-grid-tool-panel",
|
|
@@ -100,26 +100,26 @@ function de(n) {
|
|
|
100
100
|
title: e,
|
|
101
101
|
icon: r,
|
|
102
102
|
tooltip: i,
|
|
103
|
-
order:
|
|
103
|
+
order: s?.toString()
|
|
104
104
|
}
|
|
105
105
|
);
|
|
106
106
|
}
|
|
107
107
|
const S = /* @__PURE__ */ new WeakMap(), A = /* @__PURE__ */ new Map();
|
|
108
|
-
function
|
|
108
|
+
function Q(n, t) {
|
|
109
109
|
const e = n.getAttribute("field"), r = S.get(n) ?? {};
|
|
110
110
|
if (r.renderer = t, S.set(n, r), e) {
|
|
111
111
|
const i = A.get(e) ?? {};
|
|
112
112
|
i.renderer = t, A.set(e, i);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function U(n, t) {
|
|
116
116
|
const e = n.getAttribute("field"), r = S.get(n) ?? {};
|
|
117
117
|
if (r.editor = t, S.set(n, r), e) {
|
|
118
118
|
const i = A.get(e) ?? {};
|
|
119
119
|
i.editor = t, A.set(e, i);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function X(n) {
|
|
123
123
|
let t = S.get(n)?.renderer;
|
|
124
124
|
if (!t) {
|
|
125
125
|
const e = n.getAttribute("field");
|
|
@@ -127,7 +127,7 @@ function Y(n) {
|
|
|
127
127
|
}
|
|
128
128
|
return t;
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function Y(n) {
|
|
131
131
|
let t = S.get(n)?.editor;
|
|
132
132
|
if (!t) {
|
|
133
133
|
const e = n.getAttribute("field");
|
|
@@ -135,10 +135,10 @@ function Z(n) {
|
|
|
135
135
|
}
|
|
136
136
|
return t;
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function de() {
|
|
139
139
|
return Array.from(A.keys());
|
|
140
140
|
}
|
|
141
|
-
class
|
|
141
|
+
class Z {
|
|
142
142
|
mountedViews = [];
|
|
143
143
|
/**
|
|
144
144
|
* Determines if this adapter can handle the given element.
|
|
@@ -148,11 +148,11 @@ class ee {
|
|
|
148
148
|
const e = t.getAttribute("field");
|
|
149
149
|
let r = S.get(t);
|
|
150
150
|
if (!r && e) {
|
|
151
|
-
const
|
|
152
|
-
|
|
151
|
+
const o = A.get(e);
|
|
152
|
+
o && (o.renderer || o.editor) && (r = o, S.set(t, r));
|
|
153
153
|
}
|
|
154
|
-
const i = r?.renderer !== void 0,
|
|
155
|
-
return r !== void 0 && (i ||
|
|
154
|
+
const i = r?.renderer !== void 0, s = r?.editor !== void 0;
|
|
155
|
+
return r !== void 0 && (i || s);
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* Creates a view renderer function that renders a React component
|
|
@@ -166,14 +166,14 @@ class ee {
|
|
|
166
166
|
* allowing the grid to use its default rendering.
|
|
167
167
|
*/
|
|
168
168
|
createRenderer(t) {
|
|
169
|
-
const e =
|
|
169
|
+
const e = X(t);
|
|
170
170
|
if (!e)
|
|
171
171
|
return;
|
|
172
172
|
const r = /* @__PURE__ */ new WeakMap();
|
|
173
173
|
return (i) => {
|
|
174
|
-
const
|
|
175
|
-
if (
|
|
176
|
-
const u = r.get(
|
|
174
|
+
const s = i.cellEl;
|
|
175
|
+
if (s) {
|
|
176
|
+
const u = r.get(s);
|
|
177
177
|
if (u)
|
|
178
178
|
return b(() => {
|
|
179
179
|
u.root.render(e(i));
|
|
@@ -183,14 +183,14 @@ class ee {
|
|
|
183
183
|
const w = V(l);
|
|
184
184
|
return b(() => {
|
|
185
185
|
w.render(e(i));
|
|
186
|
-
}), r.set(
|
|
186
|
+
}), r.set(s, { root: w, container: l, lastRowIndex: i.rowIndex ?? -1 }), this.mountedViews.push({ root: w, container: l }), l;
|
|
187
187
|
}
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
const d = V(
|
|
188
|
+
const o = document.createElement("div");
|
|
189
|
+
o.className = "react-cell-renderer", o.style.display = "contents";
|
|
190
|
+
const d = V(o);
|
|
191
191
|
return b(() => {
|
|
192
192
|
d.render(e(i));
|
|
193
|
-
}), this.mountedViews.push({ root: d, container:
|
|
193
|
+
}), this.mountedViews.push({ root: d, container: o }), o;
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
196
|
/**
|
|
@@ -198,14 +198,14 @@ class ee {
|
|
|
198
198
|
* with commit/cancel callbacks passed as props.
|
|
199
199
|
*/
|
|
200
200
|
createEditor(t) {
|
|
201
|
-
const e =
|
|
201
|
+
const e = Y(t);
|
|
202
202
|
return e ? (r) => {
|
|
203
203
|
const i = document.createElement("div");
|
|
204
204
|
i.className = "react-cell-editor", i.style.display = "contents";
|
|
205
|
-
const
|
|
205
|
+
const s = V(i);
|
|
206
206
|
return b(() => {
|
|
207
|
-
|
|
208
|
-
}), this.mountedViews.push({ root:
|
|
207
|
+
s.render(e(r));
|
|
208
|
+
}), this.mountedViews.push({ root: s, container: i }), i;
|
|
209
209
|
} : () => document.createElement("div");
|
|
210
210
|
}
|
|
211
211
|
/**
|
|
@@ -213,15 +213,15 @@ class ee {
|
|
|
213
213
|
* Renders React components for expandable detail rows.
|
|
214
214
|
*/
|
|
215
215
|
createDetailRenderer(t) {
|
|
216
|
-
const e =
|
|
216
|
+
const e = W(t);
|
|
217
217
|
if (e)
|
|
218
218
|
return (r, i) => {
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
const
|
|
219
|
+
const s = document.createElement("div");
|
|
220
|
+
s.className = "react-detail-panel";
|
|
221
|
+
const o = { row: r, rowIndex: i }, d = V(s);
|
|
222
222
|
return b(() => {
|
|
223
|
-
d.render(e(
|
|
224
|
-
}), this.mountedViews.push({ root: d, container:
|
|
223
|
+
d.render(e(o));
|
|
224
|
+
}), this.mountedViews.push({ root: d, container: s }), s;
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
227
|
/**
|
|
@@ -238,17 +238,17 @@ class ee {
|
|
|
238
238
|
* Renders React components into tool panel containers.
|
|
239
239
|
*/
|
|
240
240
|
createToolPanelRenderer(t) {
|
|
241
|
-
const e =
|
|
241
|
+
const e = K(t);
|
|
242
242
|
if (!e)
|
|
243
243
|
return;
|
|
244
244
|
const r = t.closest("tbw-grid");
|
|
245
245
|
return (i) => {
|
|
246
|
-
const
|
|
246
|
+
const s = {
|
|
247
247
|
grid: r ?? i
|
|
248
|
-
},
|
|
248
|
+
}, o = V(i);
|
|
249
249
|
return b(() => {
|
|
250
|
-
|
|
251
|
-
}), this.mountedViews.push({ root:
|
|
250
|
+
o.render(e(s));
|
|
251
|
+
}), this.mountedViews.push({ root: o, container: i }), () => {
|
|
252
252
|
const d = this.mountedViews.findIndex((u) => u.container === i);
|
|
253
253
|
if (d !== -1) {
|
|
254
254
|
const { root: u } = this.mountedViews[d];
|
|
@@ -288,40 +288,42 @@ class ee {
|
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
|
-
let P = !1,
|
|
291
|
+
let P = !1, M = null;
|
|
292
292
|
function q() {
|
|
293
|
-
return P || (
|
|
293
|
+
return P || (M = new Z(), z.registerAdapter(M), P = !0), M;
|
|
294
294
|
}
|
|
295
295
|
q();
|
|
296
|
-
function
|
|
297
|
-
const
|
|
298
|
-
if (
|
|
299
|
-
|
|
296
|
+
function ee(n, t) {
|
|
297
|
+
const e = n, r = e.getPluginByName?.("masterDetail");
|
|
298
|
+
if (r && typeof r.refreshDetailRenderer == "function") {
|
|
299
|
+
r.refreshDetailRenderer();
|
|
300
300
|
return;
|
|
301
301
|
}
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
302
|
+
const i = n.querySelector("tbw-grid-detail");
|
|
303
|
+
!i || !W(n) || import("@toolbox-web/grid/all").then(({ MasterDetailPlugin: o }) => {
|
|
304
|
+
const d = t.createDetailRenderer(n);
|
|
305
|
+
if (!d) return;
|
|
306
|
+
const u = i.getAttribute("animation");
|
|
307
|
+
let l = "slide";
|
|
308
|
+
u === "false" ? l = !1 : u === "fade" && (l = "fade");
|
|
309
|
+
const w = i.getAttribute("showExpandColumn") !== "false", a = new o({
|
|
310
|
+
detailRenderer: d,
|
|
311
|
+
showExpandColumn: w,
|
|
312
|
+
animation: l
|
|
313
|
+
}), m = e.gridConfig || {}, E = m.plugins || [];
|
|
314
|
+
e.gridConfig = {
|
|
315
|
+
...m,
|
|
316
|
+
plugins: [...E, a]
|
|
317
|
+
};
|
|
318
|
+
}).catch(() => {
|
|
319
|
+
});
|
|
318
320
|
}
|
|
319
|
-
const
|
|
321
|
+
const ue = B(function(t, e) {
|
|
320
322
|
const {
|
|
321
323
|
rows: r,
|
|
322
324
|
gridConfig: i,
|
|
323
|
-
columns:
|
|
324
|
-
fitMode:
|
|
325
|
+
columns: s,
|
|
326
|
+
fitMode: o,
|
|
325
327
|
editOn: d,
|
|
326
328
|
customStyles: u,
|
|
327
329
|
className: l,
|
|
@@ -332,71 +334,68 @@ const ae = _(function(t, e) {
|
|
|
332
334
|
onRowClick: v,
|
|
333
335
|
onColumnStateChange: D,
|
|
334
336
|
onSortChange: I
|
|
335
|
-
} = t, f = G(null), k = G(null),
|
|
337
|
+
} = t, f = G(null), k = G(null), h = O(() => J(i), [i]);
|
|
336
338
|
return R(() => {
|
|
337
339
|
f.current && (f.current.rows = r);
|
|
338
340
|
}, [r]), R(() => {
|
|
339
|
-
f.current &&
|
|
340
|
-
}, [
|
|
341
|
-
f.current &&
|
|
342
|
-
}, [o]), R(() => {
|
|
343
|
-
f.current && s !== void 0 && (f.current.fitMode = s);
|
|
341
|
+
f.current && h && (f.current.gridConfig = h);
|
|
342
|
+
}, [h]), R(() => {
|
|
343
|
+
f.current && s && (f.current.columns = s);
|
|
344
344
|
}, [s]), R(() => {
|
|
345
|
+
f.current && o !== void 0 && (f.current.fitMode = o);
|
|
346
|
+
}, [o]), R(() => {
|
|
345
347
|
f.current && d !== void 0 && (f.current.editOn = d);
|
|
346
348
|
}, [d]), R(() => {
|
|
347
349
|
const c = f.current;
|
|
348
350
|
if (!c) return;
|
|
349
|
-
const
|
|
350
|
-
c.__frameworkAdapter =
|
|
351
|
+
const p = q();
|
|
352
|
+
c.__frameworkAdapter = p, ee(c, p);
|
|
351
353
|
let g = !1;
|
|
352
354
|
const y = requestAnimationFrame(() => {
|
|
353
|
-
g || (typeof c.refreshColumns == "function" && c.refreshColumns(),
|
|
354
|
-
g || te(c, z, h);
|
|
355
|
-
}).catch(() => {
|
|
356
|
-
}), typeof c.refreshShellHeader == "function" && c.refreshShellHeader());
|
|
355
|
+
g || (typeof c.refreshColumns == "function" && c.refreshColumns(), typeof c.refreshShellHeader == "function" && c.refreshShellHeader());
|
|
357
356
|
});
|
|
358
357
|
return () => {
|
|
359
358
|
g = !0, cancelAnimationFrame(y);
|
|
360
359
|
};
|
|
361
360
|
}, []), R(() => {
|
|
362
361
|
if (!f.current || !u) return;
|
|
363
|
-
const c = f.current,
|
|
362
|
+
const c = f.current, p = "react-custom-styles";
|
|
364
363
|
let g = !0;
|
|
365
364
|
return c.ready?.().then(() => {
|
|
366
|
-
g && u && (c.registerStyles?.(
|
|
365
|
+
g && u && (c.registerStyles?.(p, u), k.current = p);
|
|
367
366
|
}), () => {
|
|
368
367
|
g = !1, k.current && (c.unregisterStyles?.(k.current), k.current = null);
|
|
369
368
|
};
|
|
370
369
|
}, [u]), R(() => {
|
|
371
370
|
const c = f.current;
|
|
372
371
|
if (!c) return;
|
|
373
|
-
const
|
|
372
|
+
const p = [];
|
|
374
373
|
if (m) {
|
|
375
374
|
const g = ((y) => m(y.detail.rows));
|
|
376
|
-
c.addEventListener("rows-change", g),
|
|
375
|
+
c.addEventListener("rows-change", g), p.push(["rows-change", g]);
|
|
377
376
|
}
|
|
378
377
|
if (E) {
|
|
379
378
|
const g = ((y) => E(y));
|
|
380
|
-
c.addEventListener("cell-edit", g),
|
|
379
|
+
c.addEventListener("cell-edit", g), p.push(["cell-edit", g]);
|
|
381
380
|
}
|
|
382
381
|
if (v) {
|
|
383
382
|
const g = ((y) => v(y));
|
|
384
|
-
c.addEventListener("row-click", g),
|
|
383
|
+
c.addEventListener("row-click", g), p.push(["row-click", g]);
|
|
385
384
|
}
|
|
386
385
|
if (D) {
|
|
387
386
|
const g = ((y) => D(y));
|
|
388
|
-
c.addEventListener("column-state-change", g),
|
|
387
|
+
c.addEventListener("column-state-change", g), p.push(["column-state-change", g]);
|
|
389
388
|
}
|
|
390
389
|
if (I) {
|
|
391
390
|
const g = ((y) => I(y));
|
|
392
|
-
c.addEventListener("sort-change", g),
|
|
391
|
+
c.addEventListener("sort-change", g), p.push(["sort-change", g]);
|
|
393
392
|
}
|
|
394
393
|
return () => {
|
|
395
|
-
|
|
394
|
+
p.forEach(([g, y]) => {
|
|
396
395
|
c.removeEventListener(g, y);
|
|
397
396
|
});
|
|
398
397
|
};
|
|
399
|
-
}, [m, E, v, D, I]),
|
|
398
|
+
}, [m, E, v, D, I]), _(
|
|
400
399
|
e,
|
|
401
400
|
() => ({
|
|
402
401
|
get element() {
|
|
@@ -414,8 +413,8 @@ const ae = _(function(t, e) {
|
|
|
414
413
|
async toggleGroup(c) {
|
|
415
414
|
return f.current?.toggleGroup?.(c);
|
|
416
415
|
},
|
|
417
|
-
registerStyles(c,
|
|
418
|
-
f.current?.registerStyles?.(c,
|
|
416
|
+
registerStyles(c, p) {
|
|
417
|
+
f.current?.registerStyles?.(c, p);
|
|
419
418
|
},
|
|
420
419
|
unregisterStyles(c) {
|
|
421
420
|
f.current?.unregisterStyles?.(c);
|
|
@@ -427,8 +426,8 @@ const ae = _(function(t, e) {
|
|
|
427
426
|
{
|
|
428
427
|
ref: (c) => {
|
|
429
428
|
if (f.current = c, c) {
|
|
430
|
-
const
|
|
431
|
-
|
|
429
|
+
const p = c;
|
|
430
|
+
h && (p.gridConfig = h), r && (p.rows = r), s && (p.columns = s);
|
|
432
431
|
}
|
|
433
432
|
},
|
|
434
433
|
class: l,
|
|
@@ -437,14 +436,14 @@ const ae = _(function(t, e) {
|
|
|
437
436
|
}
|
|
438
437
|
);
|
|
439
438
|
});
|
|
440
|
-
function
|
|
439
|
+
function ae(n) {
|
|
441
440
|
const {
|
|
442
441
|
field: t,
|
|
443
442
|
header: e,
|
|
444
443
|
type: r,
|
|
445
444
|
editable: i,
|
|
446
|
-
sortable:
|
|
447
|
-
resizable:
|
|
445
|
+
sortable: s,
|
|
446
|
+
resizable: o,
|
|
448
447
|
width: d,
|
|
449
448
|
minWidth: u,
|
|
450
449
|
hidden: l,
|
|
@@ -456,20 +455,20 @@ function le(n) {
|
|
|
456
455
|
format: D
|
|
457
456
|
} = n, I = G(null), f = C(
|
|
458
457
|
(c) => {
|
|
459
|
-
I.current = c, c && (a &&
|
|
458
|
+
I.current = c, c && (a && Q(c, a), m && U(c, m));
|
|
460
459
|
},
|
|
461
460
|
[a, m, t]
|
|
462
|
-
), k = typeof d == "number" ? `${d}px` : d,
|
|
461
|
+
), k = typeof d == "number" ? `${d}px` : d, h = {
|
|
463
462
|
field: t,
|
|
464
463
|
ref: f
|
|
465
464
|
};
|
|
466
|
-
return e !== void 0 && (
|
|
465
|
+
return e !== void 0 && (h.header = e), r !== void 0 && (h.type = r), i !== void 0 && (h.editable = i), s !== void 0 && (h.sortable = s), o !== void 0 && (h.resizable = o), k !== void 0 && (h.width = k), u !== void 0 && (h["min-width"] = u), l !== void 0 && (h.hidden = l), w !== void 0 && (h["lock-visible"] = w), v !== void 0 && (h.multi = v), D && (h["data-has-format"] = "true"), E && (h["data-has-options"] = "true"), /* @__PURE__ */ L("tbw-grid-column", { ...h });
|
|
467
466
|
}
|
|
468
|
-
function
|
|
467
|
+
function le({ children: n }) {
|
|
469
468
|
return /* @__PURE__ */ L("tbw-grid-tool-buttons", { children: n });
|
|
470
469
|
}
|
|
471
|
-
function
|
|
472
|
-
const n = G(null), [t, e] =
|
|
470
|
+
function fe() {
|
|
471
|
+
const n = G(null), [t, e] = x(!1), [r, i] = x(null);
|
|
473
472
|
R(() => {
|
|
474
473
|
const a = n.current;
|
|
475
474
|
if (!a) return;
|
|
@@ -487,10 +486,10 @@ function ge() {
|
|
|
487
486
|
m = !1;
|
|
488
487
|
};
|
|
489
488
|
}, []);
|
|
490
|
-
const
|
|
489
|
+
const s = C(async () => {
|
|
491
490
|
const a = n.current;
|
|
492
491
|
return a ? await a.getConfig?.() ?? null : null;
|
|
493
|
-
}, []),
|
|
492
|
+
}, []), o = C(async () => {
|
|
494
493
|
const a = n.current;
|
|
495
494
|
a && await a.forceLayout?.();
|
|
496
495
|
}, []), d = C(async (a) => {
|
|
@@ -505,37 +504,37 @@ function ge() {
|
|
|
505
504
|
ref: n,
|
|
506
505
|
isReady: t,
|
|
507
506
|
config: r,
|
|
508
|
-
getConfig:
|
|
509
|
-
forceLayout:
|
|
507
|
+
getConfig: s,
|
|
508
|
+
forceLayout: o,
|
|
510
509
|
toggleGroup: d,
|
|
511
510
|
registerStyles: u,
|
|
512
511
|
unregisterStyles: l,
|
|
513
512
|
getVisibleColumns: w
|
|
514
513
|
};
|
|
515
514
|
}
|
|
516
|
-
function
|
|
515
|
+
function ge(n, t, e, r = []) {
|
|
517
516
|
const i = G(e);
|
|
518
517
|
R(() => {
|
|
519
518
|
i.current = e;
|
|
520
519
|
}, [e, ...r]), R(() => {
|
|
521
|
-
const
|
|
522
|
-
if (!
|
|
520
|
+
const s = n.current, o = s && "element" in s ? s.element : s;
|
|
521
|
+
if (!o) return;
|
|
523
522
|
const d = ((u) => {
|
|
524
523
|
i.current(u);
|
|
525
524
|
});
|
|
526
|
-
return
|
|
527
|
-
|
|
525
|
+
return o.addEventListener(t, d), () => {
|
|
526
|
+
o.removeEventListener(t, d);
|
|
528
527
|
};
|
|
529
528
|
}, [n, t]);
|
|
530
529
|
}
|
|
531
530
|
export {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
531
|
+
ue as DataGrid,
|
|
532
|
+
ae as GridColumn,
|
|
533
|
+
se as GridDetailPanel,
|
|
534
|
+
le as GridToolButtons,
|
|
535
|
+
ce as GridToolPanel,
|
|
536
|
+
Z as ReactGridAdapter,
|
|
537
|
+
de as getRegisteredFields,
|
|
538
|
+
fe as useGrid,
|
|
539
|
+
ge as useGridEvent
|
|
541
540
|
};
|
package/lib/data-grid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-grid.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/data-grid.tsx"],"names":[],"mappings":"AAAA,OAA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AAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,+BAA+B;IAC/B,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,eAAO,MAAM,QAAQ,EAuOf,CAAC,IAAI,GAAG,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAA;CAAE,KAAK,KAAK,CAAC,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toolbox-web/grid-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "React adapter for @toolbox-web/grid data grid component",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"react-dom": "^19.0.0",
|
|
41
41
|
"@types/react": "^19.0.0",
|
|
42
42
|
"@types/react-dom": "^19.0.0",
|
|
43
|
-
"@toolbox-web/grid": ">=0.
|
|
43
|
+
"@toolbox-web/grid": ">=0.4.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": ">=18.0.0",
|
|
47
47
|
"react-dom": ">=18.0.0",
|
|
48
|
-
"@toolbox-web/grid": ">=0.
|
|
48
|
+
"@toolbox-web/grid": ">=0.4.0"
|
|
49
49
|
}
|
|
50
50
|
}
|