@toolbox-web/grid-react 0.18.1 → 0.18.3
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/README.md +12 -11
- package/features/export.d.ts +4 -1
- package/features/export.d.ts.map +1 -1
- package/features/export.js +12 -12
- package/features/filtering.d.ts +4 -1
- package/features/filtering.d.ts.map +1 -1
- package/features/filtering.js +34 -34
- package/features/print.d.ts +4 -1
- package/features/print.d.ts.map +1 -1
- package/features/print.js +10 -10
- package/features/selection.d.ts +4 -1
- package/features/selection.d.ts.map +1 -1
- package/features/selection.js +23 -23
- package/features/undo-redo.d.ts +4 -1
- package/features/undo-redo.d.ts.map +1 -1
- package/features/undo-redo.js +23 -23
- package/index.js +429 -380
- package/lib/data-grid.d.ts +1 -1
- package/lib/data-grid.d.ts.map +1 -1
- package/lib/event-props.d.ts +12 -1
- package/lib/event-props.d.ts.map +1 -1
- package/lib/use-grid.d.ts +5 -1
- package/lib/use-grid.d.ts.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as E, Fragment as Re } from "react/jsx-runtime";
|
|
2
2
|
import { DataGridElement as ve } from "@toolbox-web/grid";
|
|
3
|
-
import { createContext as pe, useContext as
|
|
4
|
-
import { flushSync as
|
|
5
|
-
import { createRoot as
|
|
6
|
-
import { createPluginsFromFeatures as
|
|
3
|
+
import { createContext as pe, useContext as z, useRef as P, useCallback as h, useEffect as w, forwardRef as Ce, useMemo as G, useImperativeHandle as be, Children as Ee, isValidElement as Se, useState as de } from "react";
|
|
4
|
+
import { flushSync as R } from "react-dom";
|
|
5
|
+
import { createRoot as C } from "react-dom/client";
|
|
6
|
+
import { createPluginsFromFeatures as Pe } from "@toolbox-web/grid/features/registry";
|
|
7
7
|
import { G as xe } from "./chunks/grid-element-context-BU3WvNtM.js";
|
|
8
8
|
function De(n) {
|
|
9
9
|
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
@@ -33,13 +33,14 @@ function Ae(n) {
|
|
|
33
33
|
function Ie(n) {
|
|
34
34
|
return n.map((t) => typeof t == "string" ? Ae(t) : t);
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const U = {
|
|
37
37
|
onCellClick: "cell-click",
|
|
38
38
|
onRowClick: "row-click",
|
|
39
39
|
onCellActivate: "cell-activate",
|
|
40
40
|
onCellChange: "cell-change",
|
|
41
41
|
onCellCommit: "cell-commit",
|
|
42
42
|
onRowCommit: "row-commit",
|
|
43
|
+
onChangedRowsReset: "changed-rows-reset",
|
|
43
44
|
onSortChange: "sort-change",
|
|
44
45
|
onFilterChange: "filter-change",
|
|
45
46
|
onColumnResize: "column-resize",
|
|
@@ -58,57 +59,57 @@ const W = {
|
|
|
58
59
|
onExportComplete: "export-complete",
|
|
59
60
|
onPrintStart: "print-start",
|
|
60
61
|
onPrintComplete: "print-complete"
|
|
61
|
-
},
|
|
62
|
+
}, oe = pe(null), Ve = ({ icons: n, children: t }) => /* @__PURE__ */ E(oe.Provider, { value: n, children: t });
|
|
62
63
|
function at() {
|
|
63
|
-
return
|
|
64
|
+
return z(oe);
|
|
64
65
|
}
|
|
65
|
-
const Ne =
|
|
66
|
+
const Ne = oe, Z = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new Map();
|
|
66
67
|
function me(n) {
|
|
67
68
|
const t = n.querySelector("tbw-grid-responsive-card");
|
|
68
69
|
if (t) {
|
|
69
|
-
const r =
|
|
70
|
+
const r = Z.get(t);
|
|
70
71
|
if (r) return r;
|
|
71
72
|
}
|
|
72
73
|
const e = n.id || n.getAttribute("data-grid-id");
|
|
73
74
|
if (e)
|
|
74
|
-
return
|
|
75
|
+
return Q.get(e);
|
|
75
76
|
}
|
|
76
|
-
function
|
|
77
|
-
const { children: t, cardRowHeight: e = "auto" } = n, r =
|
|
78
|
-
(
|
|
79
|
-
if (r.current =
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
const
|
|
84
|
-
|
|
77
|
+
function Le(n) {
|
|
78
|
+
const { children: t, cardRowHeight: e = "auto" } = n, r = P(null), o = h(
|
|
79
|
+
(l) => {
|
|
80
|
+
if (r.current = l, !l) return;
|
|
81
|
+
Z.set(l, t);
|
|
82
|
+
const i = l.closest("tbw-grid");
|
|
83
|
+
if (i) {
|
|
84
|
+
const f = i.id || i.getAttribute("data-grid-id");
|
|
85
|
+
f && Q.set(f, t);
|
|
85
86
|
}
|
|
86
87
|
},
|
|
87
88
|
[t]
|
|
88
89
|
);
|
|
89
90
|
w(() => () => {
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
const
|
|
96
|
-
|
|
91
|
+
const l = r.current;
|
|
92
|
+
if (l) {
|
|
93
|
+
Z.delete(l);
|
|
94
|
+
const i = l.closest("tbw-grid");
|
|
95
|
+
if (i) {
|
|
96
|
+
const f = i.id || i.getAttribute("data-grid-id");
|
|
97
|
+
f && Q.delete(f);
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
}, []);
|
|
100
|
-
const
|
|
101
|
-
return /* @__PURE__ */ E("tbw-grid-responsive-card", { ref: o, cardRowHeight:
|
|
101
|
+
const a = e === "auto" ? "auto" : String(e);
|
|
102
|
+
return /* @__PURE__ */ E("tbw-grid-responsive-card", { ref: o, cardRowHeight: a });
|
|
102
103
|
}
|
|
103
|
-
|
|
104
|
-
const
|
|
104
|
+
Le.displayName = "GridResponsiveCard";
|
|
105
|
+
const $ = pe(null), Te = ({ defaults: n, children: t }) => /* @__PURE__ */ E($.Provider, { value: n, children: t });
|
|
105
106
|
function lt() {
|
|
106
|
-
return
|
|
107
|
+
return z($);
|
|
107
108
|
}
|
|
108
109
|
function dt(n) {
|
|
109
|
-
return
|
|
110
|
+
return z($)?.[n];
|
|
110
111
|
}
|
|
111
|
-
const ke =
|
|
112
|
+
const ke = $, K = /* @__PURE__ */ Symbol("reactProcessed"), I = [];
|
|
112
113
|
function Fe(n) {
|
|
113
114
|
for (let t = I.length - 1; t >= 0; t--) {
|
|
114
115
|
const e = I[t];
|
|
@@ -126,26 +127,26 @@ function Me(n) {
|
|
|
126
127
|
return (e) => {
|
|
127
128
|
const r = e.cellEl;
|
|
128
129
|
if (r) {
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
return
|
|
132
|
-
|
|
133
|
-
}),
|
|
130
|
+
const l = t.get(r);
|
|
131
|
+
if (l)
|
|
132
|
+
return R(() => {
|
|
133
|
+
l.root.render(n(e));
|
|
134
|
+
}), l.container;
|
|
134
135
|
}
|
|
135
136
|
const o = document.createElement("div");
|
|
136
137
|
o.className = "react-cell-renderer", o.style.display = "contents";
|
|
137
|
-
const
|
|
138
|
-
return
|
|
139
|
-
|
|
140
|
-
}), r && t.set(r, { root:
|
|
138
|
+
const a = C(o);
|
|
139
|
+
return R(() => {
|
|
140
|
+
a.render(n(e));
|
|
141
|
+
}), r && t.set(r, { root: a, container: o }), I.push({ root: a, container: o }), o;
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
144
|
function He(n) {
|
|
144
145
|
return (t) => {
|
|
145
146
|
const e = document.createElement("div");
|
|
146
147
|
e.className = "react-cell-editor", e.style.display = "contents";
|
|
147
|
-
const r =
|
|
148
|
-
return
|
|
148
|
+
const r = C(e);
|
|
149
|
+
return R(() => {
|
|
149
150
|
r.render(n(t));
|
|
150
151
|
}), I.push({ root: r, container: e }), e;
|
|
151
152
|
};
|
|
@@ -154,131 +155,131 @@ function Oe(n) {
|
|
|
154
155
|
return (t) => {
|
|
155
156
|
const e = document.createElement("div");
|
|
156
157
|
e.className = "react-header-renderer", e.style.display = "contents";
|
|
157
|
-
const r =
|
|
158
|
-
return
|
|
158
|
+
const r = C(e);
|
|
159
|
+
return R(() => {
|
|
159
160
|
r.render(n(t));
|
|
160
161
|
}), I.push({ root: r, container: e }), e;
|
|
161
162
|
};
|
|
162
163
|
}
|
|
163
|
-
function
|
|
164
|
+
function qe(n) {
|
|
164
165
|
return (t) => {
|
|
165
166
|
const e = document.createElement("div");
|
|
166
167
|
e.className = "react-header-label-renderer", e.style.display = "contents";
|
|
167
|
-
const r =
|
|
168
|
-
return
|
|
168
|
+
const r = C(e);
|
|
169
|
+
return R(() => {
|
|
169
170
|
r.render(n(t));
|
|
170
171
|
}), I.push({ root: r, container: e }), e;
|
|
171
172
|
};
|
|
172
173
|
}
|
|
173
|
-
function
|
|
174
|
+
function Be(n) {
|
|
174
175
|
return (t) => {
|
|
175
176
|
const e = n(t);
|
|
176
177
|
if (e instanceof HTMLElement || typeof e == "string")
|
|
177
178
|
return e;
|
|
178
179
|
const r = document.createElement("div");
|
|
179
180
|
r.className = "react-loading-renderer", r.style.display = "contents";
|
|
180
|
-
const o =
|
|
181
|
-
return
|
|
181
|
+
const o = C(r);
|
|
182
|
+
return R(() => {
|
|
182
183
|
o.render(e);
|
|
183
184
|
}), I.push({ root: o, container: r }), r;
|
|
184
185
|
};
|
|
185
186
|
}
|
|
186
187
|
function ye(n) {
|
|
187
188
|
if (!n) return;
|
|
188
|
-
if (n[
|
|
189
|
+
if (n[K]) return n;
|
|
189
190
|
if (n.loadingRenderer && typeof n.loadingRenderer == "function") {
|
|
190
191
|
const r = n.loadingRenderer;
|
|
191
192
|
n = {
|
|
192
193
|
...n,
|
|
193
|
-
loadingRenderer:
|
|
194
|
+
loadingRenderer: Be(r)
|
|
194
195
|
};
|
|
195
196
|
}
|
|
196
197
|
if (!n.columns) {
|
|
197
198
|
const r = n;
|
|
198
|
-
return r[
|
|
199
|
+
return r[K] = !0, r;
|
|
199
200
|
}
|
|
200
201
|
const t = n.columns.map((r) => {
|
|
201
|
-
const { renderer: o, editor:
|
|
202
|
-
return o && (
|
|
202
|
+
const { renderer: o, editor: a, headerRenderer: l, headerLabelRenderer: i, ...f } = r, g = { ...f };
|
|
203
|
+
return o && (g.renderer = Me(o)), a && (g.editor = He(a)), l && (g.headerRenderer = Oe(l)), i && (g.headerLabelRenderer = qe(i)), g;
|
|
203
204
|
}), e = {
|
|
204
205
|
...n,
|
|
205
206
|
columns: t
|
|
206
207
|
};
|
|
207
|
-
return e[
|
|
208
|
+
return e[K] = !0, e;
|
|
208
209
|
}
|
|
209
|
-
const
|
|
210
|
-
function
|
|
210
|
+
const X = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new Map();
|
|
211
|
+
function je(n) {
|
|
211
212
|
const t = n.querySelector("tbw-grid-detail");
|
|
212
213
|
if (t) {
|
|
213
|
-
const r =
|
|
214
|
+
const r = X.get(t);
|
|
214
215
|
if (r) return r;
|
|
215
216
|
}
|
|
216
217
|
const e = n.id || n.getAttribute("data-grid-id");
|
|
217
218
|
if (e)
|
|
218
|
-
return
|
|
219
|
+
return ee.get(e);
|
|
219
220
|
}
|
|
220
|
-
function
|
|
221
|
-
const { children: t, showExpandColumn: e = !0, animation: r = "slide" } = n, o =
|
|
222
|
-
(
|
|
223
|
-
if (o.current =
|
|
224
|
-
|
|
225
|
-
const
|
|
226
|
-
if (
|
|
227
|
-
const
|
|
228
|
-
|
|
221
|
+
function _e(n) {
|
|
222
|
+
const { children: t, showExpandColumn: e = !0, animation: r = "slide" } = n, o = P(null), a = h(
|
|
223
|
+
(i) => {
|
|
224
|
+
if (o.current = i, !i) return;
|
|
225
|
+
X.set(i, t);
|
|
226
|
+
const f = i.closest("tbw-grid");
|
|
227
|
+
if (f) {
|
|
228
|
+
const g = f.id || f.getAttribute("data-grid-id");
|
|
229
|
+
g && ee.set(g, t);
|
|
229
230
|
}
|
|
230
231
|
},
|
|
231
232
|
[t]
|
|
232
233
|
);
|
|
233
234
|
return w(() => () => {
|
|
234
|
-
const
|
|
235
|
-
if (
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
if (
|
|
239
|
-
const
|
|
240
|
-
|
|
235
|
+
const i = o.current;
|
|
236
|
+
if (i) {
|
|
237
|
+
X.delete(i);
|
|
238
|
+
const f = i.closest("tbw-grid");
|
|
239
|
+
if (f) {
|
|
240
|
+
const v = f.id || f.getAttribute("data-grid-id");
|
|
241
|
+
v && ee.delete(v);
|
|
241
242
|
}
|
|
242
|
-
const
|
|
243
|
-
|
|
243
|
+
const g = i.parentNode;
|
|
244
|
+
g && g.contains(i);
|
|
244
245
|
}
|
|
245
246
|
}, []), /* @__PURE__ */ E(
|
|
246
247
|
"tbw-grid-detail",
|
|
247
248
|
{
|
|
248
|
-
ref:
|
|
249
|
+
ref: a,
|
|
249
250
|
showExpandColumn: e ? void 0 : "false",
|
|
250
251
|
animation: r === !1 ? "false" : r
|
|
251
252
|
}
|
|
252
253
|
);
|
|
253
254
|
}
|
|
254
|
-
|
|
255
|
-
const
|
|
255
|
+
_e.displayName = "GridDetailPanel";
|
|
256
|
+
const te = /* @__PURE__ */ new WeakMap(), re = /* @__PURE__ */ new Map();
|
|
256
257
|
function ze(n) {
|
|
257
|
-
const t =
|
|
258
|
+
const t = te.get(n);
|
|
258
259
|
if (t) return t;
|
|
259
260
|
const e = n.id;
|
|
260
261
|
if (e)
|
|
261
|
-
return
|
|
262
|
+
return re.get(e);
|
|
262
263
|
}
|
|
263
264
|
function ut(n) {
|
|
264
|
-
const { id: t, title: e, icon: r, tooltip: o, order:
|
|
265
|
-
(
|
|
266
|
-
|
|
265
|
+
const { id: t, title: e, icon: r, tooltip: o, order: a = 100, children: l } = n, i = P(null), f = h(
|
|
266
|
+
(g) => {
|
|
267
|
+
i.current = g, g && (te.set(g, l), t && re.set(t, l));
|
|
267
268
|
},
|
|
268
|
-
[
|
|
269
|
+
[l, t]
|
|
269
270
|
);
|
|
270
271
|
return w(() => () => {
|
|
271
|
-
const
|
|
272
|
-
|
|
272
|
+
const g = i.current;
|
|
273
|
+
g && (te.delete(g), t && re.delete(t));
|
|
273
274
|
}, [t]), /* @__PURE__ */ E(
|
|
274
275
|
"tbw-grid-tool-panel",
|
|
275
276
|
{
|
|
276
|
-
ref:
|
|
277
|
+
ref: f,
|
|
277
278
|
id: t,
|
|
278
279
|
title: e,
|
|
279
280
|
icon: r,
|
|
280
281
|
tooltip: o,
|
|
281
|
-
order:
|
|
282
|
+
order: a?.toString()
|
|
282
283
|
}
|
|
283
284
|
);
|
|
284
285
|
}
|
|
@@ -343,11 +344,11 @@ class he {
|
|
|
343
344
|
const e = t.getAttribute("field");
|
|
344
345
|
let r = V.get(t);
|
|
345
346
|
if (!r && e) {
|
|
346
|
-
const
|
|
347
|
-
|
|
347
|
+
const l = N.get(e);
|
|
348
|
+
l && (l.renderer || l.editor) && (r = l, V.set(t, r));
|
|
348
349
|
}
|
|
349
|
-
const o = r?.renderer !== void 0,
|
|
350
|
-
return r !== void 0 && (o ||
|
|
350
|
+
const o = r?.renderer !== void 0, a = r?.editor !== void 0;
|
|
351
|
+
return r !== void 0 && (o || a);
|
|
351
352
|
}
|
|
352
353
|
/**
|
|
353
354
|
* Creates a view renderer function that renders a React component
|
|
@@ -366,26 +367,26 @@ class he {
|
|
|
366
367
|
return;
|
|
367
368
|
const r = /* @__PURE__ */ new WeakMap();
|
|
368
369
|
return (o) => {
|
|
369
|
-
const
|
|
370
|
-
if (
|
|
371
|
-
const
|
|
372
|
-
if (
|
|
373
|
-
return
|
|
374
|
-
|
|
375
|
-
}),
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
const
|
|
379
|
-
return
|
|
380
|
-
|
|
381
|
-
}), r.set(
|
|
370
|
+
const a = o.cellEl;
|
|
371
|
+
if (a) {
|
|
372
|
+
const f = r.get(a);
|
|
373
|
+
if (f)
|
|
374
|
+
return R(() => {
|
|
375
|
+
f.root.render(e(o));
|
|
376
|
+
}), f.container;
|
|
377
|
+
const g = document.createElement("div");
|
|
378
|
+
g.className = "react-cell-renderer", g.style.display = "contents";
|
|
379
|
+
const v = C(g);
|
|
380
|
+
return R(() => {
|
|
381
|
+
v.render(e(o));
|
|
382
|
+
}), r.set(a, { root: v, container: g, lastRowIndex: o.rowIndex ?? -1 }), this.mountedViews.push({ root: v, container: g }), g;
|
|
382
383
|
}
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
const
|
|
386
|
-
return
|
|
387
|
-
|
|
388
|
-
}), this.mountedViews.push({ root:
|
|
384
|
+
const l = document.createElement("div");
|
|
385
|
+
l.className = "react-cell-renderer", l.style.display = "contents";
|
|
386
|
+
const i = C(l);
|
|
387
|
+
return R(() => {
|
|
388
|
+
i.render(e(o));
|
|
389
|
+
}), this.mountedViews.push({ root: i, container: l }), l;
|
|
389
390
|
};
|
|
390
391
|
}
|
|
391
392
|
/**
|
|
@@ -397,10 +398,10 @@ class he {
|
|
|
397
398
|
return e ? (r) => {
|
|
398
399
|
const o = document.createElement("div");
|
|
399
400
|
o.className = "react-cell-editor", o.style.display = "contents";
|
|
400
|
-
const
|
|
401
|
-
return
|
|
402
|
-
|
|
403
|
-
}), this.editorViews.push({ root:
|
|
401
|
+
const a = C(o);
|
|
402
|
+
return R(() => {
|
|
403
|
+
a.render(e(r));
|
|
404
|
+
}), this.editorViews.push({ root: a, container: o }), o;
|
|
404
405
|
} : () => document.createElement("div");
|
|
405
406
|
}
|
|
406
407
|
/**
|
|
@@ -408,15 +409,15 @@ class he {
|
|
|
408
409
|
* Renders React components for expandable detail rows.
|
|
409
410
|
*/
|
|
410
411
|
createDetailRenderer(t) {
|
|
411
|
-
const e =
|
|
412
|
+
const e = je(t);
|
|
412
413
|
if (e)
|
|
413
414
|
return (r, o) => {
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
const
|
|
417
|
-
return
|
|
418
|
-
|
|
419
|
-
}), this.mountedViews.push({ root:
|
|
415
|
+
const a = document.createElement("div");
|
|
416
|
+
a.className = "react-detail-panel";
|
|
417
|
+
const l = { row: r, rowIndex: o }, i = C(a);
|
|
418
|
+
return R(() => {
|
|
419
|
+
i.render(e(l));
|
|
420
|
+
}), this.mountedViews.push({ root: i, container: a }), a;
|
|
420
421
|
};
|
|
421
422
|
}
|
|
422
423
|
/**
|
|
@@ -436,12 +437,12 @@ class he {
|
|
|
436
437
|
const e = me(t);
|
|
437
438
|
if (e)
|
|
438
439
|
return (r, o) => {
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
const
|
|
442
|
-
return
|
|
443
|
-
|
|
444
|
-
}), this.mountedViews.push({ root:
|
|
440
|
+
const a = document.createElement("div");
|
|
441
|
+
a.className = "react-responsive-card";
|
|
442
|
+
const l = { row: r, index: o }, i = C(a);
|
|
443
|
+
return R(() => {
|
|
444
|
+
i.render(e(l));
|
|
445
|
+
}), this.mountedViews.push({ root: i, container: a }), a;
|
|
445
446
|
};
|
|
446
447
|
}
|
|
447
448
|
/**
|
|
@@ -454,20 +455,20 @@ class he {
|
|
|
454
455
|
return;
|
|
455
456
|
const r = t.closest("tbw-grid");
|
|
456
457
|
return (o) => {
|
|
457
|
-
const
|
|
458
|
+
const a = {
|
|
458
459
|
grid: r ?? o
|
|
459
|
-
},
|
|
460
|
-
return
|
|
461
|
-
|
|
462
|
-
}), this.mountedViews.push({ root:
|
|
463
|
-
const
|
|
464
|
-
if (
|
|
465
|
-
const { root:
|
|
460
|
+
}, l = C(o);
|
|
461
|
+
return R(() => {
|
|
462
|
+
l.render(e(a));
|
|
463
|
+
}), this.mountedViews.push({ root: l, container: o }), () => {
|
|
464
|
+
const i = this.mountedViews.findIndex((f) => f.container === o);
|
|
465
|
+
if (i !== -1) {
|
|
466
|
+
const { root: f } = this.mountedViews[i];
|
|
466
467
|
try {
|
|
467
|
-
|
|
468
|
+
f.unmount();
|
|
468
469
|
} catch {
|
|
469
470
|
}
|
|
470
|
-
this.mountedViews.splice(
|
|
471
|
+
this.mountedViews.splice(i, 1);
|
|
471
472
|
}
|
|
472
473
|
};
|
|
473
474
|
};
|
|
@@ -515,8 +516,8 @@ class he {
|
|
|
515
516
|
return (e) => {
|
|
516
517
|
const r = document.createElement("span");
|
|
517
518
|
r.style.display = "contents";
|
|
518
|
-
const o =
|
|
519
|
-
return this.mountedViews.push({ root: o, container: r }),
|
|
519
|
+
const o = C(r);
|
|
520
|
+
return this.mountedViews.push({ root: o, container: r }), R(() => {
|
|
520
521
|
o.render(t(e));
|
|
521
522
|
}), r;
|
|
522
523
|
};
|
|
@@ -529,8 +530,8 @@ class he {
|
|
|
529
530
|
return (e) => {
|
|
530
531
|
const r = document.createElement("span");
|
|
531
532
|
r.style.display = "contents";
|
|
532
|
-
const o =
|
|
533
|
-
return this.editorViews.push({ root: o, container: r }),
|
|
533
|
+
const o = C(r);
|
|
534
|
+
return this.editorViews.push({ root: o, container: r }), R(() => {
|
|
534
535
|
o.render(t(e));
|
|
535
536
|
}), r;
|
|
536
537
|
};
|
|
@@ -543,9 +544,9 @@ class he {
|
|
|
543
544
|
return (e, r) => {
|
|
544
545
|
const o = document.createElement("div");
|
|
545
546
|
o.style.display = "contents";
|
|
546
|
-
const
|
|
547
|
-
this.mountedViews.push({ root:
|
|
548
|
-
|
|
547
|
+
const a = C(o);
|
|
548
|
+
this.mountedViews.push({ root: a, container: o }), R(() => {
|
|
549
|
+
a.render(t(r));
|
|
549
550
|
}), e.appendChild(o);
|
|
550
551
|
};
|
|
551
552
|
}
|
|
@@ -619,13 +620,13 @@ function Ze(n) {
|
|
|
619
620
|
const t = [];
|
|
620
621
|
for (const [e, r] of Object.entries(n))
|
|
621
622
|
r === void 0 || r === !1 || t.push(e);
|
|
622
|
-
return Ye(t),
|
|
623
|
+
return Ye(t), Pe(n);
|
|
623
624
|
}
|
|
624
|
-
let fe = !1,
|
|
625
|
-
function
|
|
626
|
-
return fe || (
|
|
625
|
+
let fe = !1, Y = null;
|
|
626
|
+
function ne() {
|
|
627
|
+
return fe || (Y = new he(), ve.registerAdapter(Y), fe = !0), Y;
|
|
627
628
|
}
|
|
628
|
-
|
|
629
|
+
ne();
|
|
629
630
|
function Qe(n) {
|
|
630
631
|
const e = n.getPluginByName?.("masterDetail");
|
|
631
632
|
e && typeof e.refreshDetailRenderer == "function" && e.refreshDetailRenderer();
|
|
@@ -633,16 +634,16 @@ function Qe(n) {
|
|
|
633
634
|
function Xe(n, t) {
|
|
634
635
|
const e = n;
|
|
635
636
|
if (!n.querySelector("tbw-grid-responsive-card") || !me(n)) return;
|
|
636
|
-
const
|
|
637
|
-
if (
|
|
638
|
-
const
|
|
639
|
-
|
|
637
|
+
const a = e.getPluginByName?.("responsive");
|
|
638
|
+
if (a && typeof a.setCardRenderer == "function") {
|
|
639
|
+
const l = t.createResponsiveCardRenderer(n);
|
|
640
|
+
l && a.setCardRenderer(l);
|
|
640
641
|
}
|
|
641
642
|
}
|
|
642
643
|
function et(n) {
|
|
643
644
|
const t = {};
|
|
644
645
|
return Ee.forEach(n, (e) => {
|
|
645
|
-
if (
|
|
646
|
+
if (Se(e)) {
|
|
646
647
|
if (e.type && e.type.displayName === "GridDetailPanel") {
|
|
647
648
|
const r = e.props;
|
|
648
649
|
t.masterDetail = {
|
|
@@ -661,27 +662,27 @@ const gt = Ce(function(t, e) {
|
|
|
661
662
|
// Core props
|
|
662
663
|
rows: r,
|
|
663
664
|
gridConfig: o,
|
|
664
|
-
columns:
|
|
665
|
-
columnDefaults:
|
|
666
|
-
fitMode:
|
|
667
|
-
sortable:
|
|
668
|
-
filterable:
|
|
669
|
-
selectable:
|
|
670
|
-
loading:
|
|
671
|
-
editOn:
|
|
672
|
-
customStyles:
|
|
673
|
-
className:
|
|
674
|
-
style:
|
|
675
|
-
children:
|
|
665
|
+
columns: a,
|
|
666
|
+
columnDefaults: l,
|
|
667
|
+
fitMode: i,
|
|
668
|
+
sortable: f,
|
|
669
|
+
filterable: g,
|
|
670
|
+
selectable: v,
|
|
671
|
+
loading: x,
|
|
672
|
+
editOn: D,
|
|
673
|
+
customStyles: A,
|
|
674
|
+
className: k,
|
|
675
|
+
style: M,
|
|
676
|
+
children: L,
|
|
676
677
|
// Plugin props
|
|
677
|
-
plugins:
|
|
678
|
+
plugins: S,
|
|
678
679
|
// SSR mode
|
|
679
|
-
ssr:
|
|
680
|
+
ssr: T,
|
|
680
681
|
// Legacy event handlers
|
|
681
|
-
onRowsChange:
|
|
682
|
+
onRowsChange: y,
|
|
682
683
|
// Feature props and event props are in ...rest
|
|
683
|
-
...
|
|
684
|
-
} = t,
|
|
684
|
+
...d
|
|
685
|
+
} = t, s = P(null), p = P(null), b = z(ke), H = z(Ne), F = [
|
|
685
686
|
"selection",
|
|
686
687
|
"editing",
|
|
687
688
|
"filtering",
|
|
@@ -711,156 +712,156 @@ const gt = Ce(function(t, e) {
|
|
|
711
712
|
"pivot",
|
|
712
713
|
"serverSide",
|
|
713
714
|
"tooltip"
|
|
714
|
-
], we =
|
|
715
|
-
const
|
|
716
|
-
return
|
|
717
|
-
}).filter(Boolean).join("|"), [
|
|
718
|
-
const
|
|
719
|
-
for (const
|
|
720
|
-
|
|
721
|
-
return
|
|
722
|
-
}, [we]), se =
|
|
723
|
-
if (
|
|
724
|
-
const
|
|
725
|
-
return [...
|
|
715
|
+
], we = G(() => F.map((c) => {
|
|
716
|
+
const u = d[c];
|
|
717
|
+
return u !== void 0 ? `${c}:${JSON.stringify(u)}` : "";
|
|
718
|
+
}).filter(Boolean).join("|"), [d]), ie = G(() => {
|
|
719
|
+
const c = {};
|
|
720
|
+
for (const u of F)
|
|
721
|
+
u in d && d[u] !== void 0 && (c[u] = d[u]);
|
|
722
|
+
return c;
|
|
723
|
+
}, [we]), se = G(() => et(L), [L]), ce = G(() => ({ ...se, ...ie }), [ie, se]), W = G(() => S || T ? [] : Ze(ce), [ce, S, T]), O = G(() => {
|
|
724
|
+
if (S) {
|
|
725
|
+
const c = new Set(S.map((m) => m.name)), u = W.filter((m) => !c.has(m.name));
|
|
726
|
+
return [...S, ...u];
|
|
726
727
|
}
|
|
727
|
-
return
|
|
728
|
-
}, [
|
|
729
|
-
if (!
|
|
730
|
-
const
|
|
731
|
-
return
|
|
732
|
-
...
|
|
733
|
-
...
|
|
728
|
+
return W;
|
|
729
|
+
}, [S, W]), q = G(() => {
|
|
730
|
+
if (!a) return a;
|
|
731
|
+
const c = Ie(a);
|
|
732
|
+
return l ? c.map((u) => ({
|
|
733
|
+
...l,
|
|
734
|
+
...u
|
|
734
735
|
// Individual column props override defaults
|
|
735
|
-
})) :
|
|
736
|
-
}, [
|
|
737
|
-
const
|
|
738
|
-
if (
|
|
739
|
-
const
|
|
740
|
-
|
|
736
|
+
})) : c;
|
|
737
|
+
}, [a, l]), B = G(() => {
|
|
738
|
+
const c = ye(o), u = {};
|
|
739
|
+
if (f !== void 0 && (u.sortable = f), g !== void 0 && (u.filterable = g), v !== void 0 && (u.selectable = v), H) {
|
|
740
|
+
const m = c?.icons || o?.icons || {};
|
|
741
|
+
u.icons = { ...H, ...m };
|
|
741
742
|
}
|
|
742
|
-
if (
|
|
743
|
-
const
|
|
743
|
+
if (O.length > 0 && c) {
|
|
744
|
+
const m = c.plugins || [], j = new Set(m.map((_) => _.name)), J = O.filter((_) => !j.has(_.name));
|
|
744
745
|
return {
|
|
745
|
-
...
|
|
746
|
-
...
|
|
747
|
-
plugins: [...
|
|
746
|
+
...c,
|
|
747
|
+
...u,
|
|
748
|
+
plugins: [...m, ...J]
|
|
748
749
|
};
|
|
749
750
|
}
|
|
750
|
-
return
|
|
751
|
-
}, [o,
|
|
751
|
+
return O.length > 0 && !c ? { ...u, plugins: O } : Object.keys(u).length > 0 ? { ...c, ...u } : c;
|
|
752
|
+
}, [o, O, f, g, v, H]);
|
|
752
753
|
w(() => {
|
|
753
|
-
|
|
754
|
-
}, [
|
|
755
|
-
|
|
754
|
+
ne().setTypeDefaults(b);
|
|
755
|
+
}, [b]), w(() => {
|
|
756
|
+
s.current && (s.current.rows = r);
|
|
756
757
|
}, [r]), w(() => {
|
|
757
|
-
|
|
758
|
-
}, [
|
|
759
|
-
|
|
760
|
-
}, [
|
|
761
|
-
|
|
762
|
-
}, [
|
|
763
|
-
|
|
764
|
-
}, [
|
|
765
|
-
|
|
766
|
-
}, [
|
|
767
|
-
const
|
|
768
|
-
if (!
|
|
769
|
-
const
|
|
770
|
-
|
|
771
|
-
let
|
|
772
|
-
const
|
|
773
|
-
|
|
758
|
+
s.current && B && (s.current.gridConfig = B);
|
|
759
|
+
}, [B]), w(() => {
|
|
760
|
+
s.current && q && (s.current.columns = q);
|
|
761
|
+
}, [q]), w(() => {
|
|
762
|
+
s.current && i !== void 0 && (s.current.fitMode = i);
|
|
763
|
+
}, [i]), w(() => {
|
|
764
|
+
s.current && D !== void 0 && (s.current.editOn = D);
|
|
765
|
+
}, [D]), w(() => {
|
|
766
|
+
s.current && x !== void 0 && (s.current.loading = x);
|
|
767
|
+
}, [x]), w(() => {
|
|
768
|
+
const c = s.current;
|
|
769
|
+
if (!c) return;
|
|
770
|
+
const u = ne();
|
|
771
|
+
c.__frameworkAdapter = u, Qe(c), Xe(c, u);
|
|
772
|
+
let m = !1;
|
|
773
|
+
const j = requestAnimationFrame(() => {
|
|
774
|
+
m || (typeof c.refreshColumns == "function" && c.refreshColumns(), typeof c.refreshShellHeader == "function" && c.refreshShellHeader());
|
|
774
775
|
});
|
|
775
776
|
return () => {
|
|
776
|
-
|
|
777
|
+
m = !0, cancelAnimationFrame(j);
|
|
777
778
|
};
|
|
778
779
|
}, []), w(() => {
|
|
779
|
-
if (!
|
|
780
|
-
const
|
|
781
|
-
let
|
|
782
|
-
return
|
|
783
|
-
|
|
780
|
+
if (!s.current || !A) return;
|
|
781
|
+
const c = s.current, u = "react-custom-styles";
|
|
782
|
+
let m = !0;
|
|
783
|
+
return c.ready?.().then(() => {
|
|
784
|
+
m && A && (c.registerStyles?.(u, A), p.current = u);
|
|
784
785
|
}), () => {
|
|
785
|
-
|
|
786
|
+
m = !1, p.current && (c.unregisterStyles?.(p.current), p.current = null);
|
|
786
787
|
};
|
|
787
|
-
}, [
|
|
788
|
-
const
|
|
789
|
-
if (!
|
|
790
|
-
const
|
|
791
|
-
return
|
|
792
|
-
|
|
788
|
+
}, [A]), w(() => {
|
|
789
|
+
const c = s.current;
|
|
790
|
+
if (!c) return;
|
|
791
|
+
const u = [];
|
|
792
|
+
return y && u.push(c.on("rows-change", (m) => y(m.rows))), () => {
|
|
793
|
+
u.forEach((m) => m());
|
|
793
794
|
};
|
|
794
|
-
}, [
|
|
795
|
-
const ae =
|
|
796
|
-
for (const
|
|
797
|
-
le.current[
|
|
795
|
+
}, [y]);
|
|
796
|
+
const ae = G(() => Object.keys(U).filter((c) => typeof d[c] == "function").sort().join("|"), [d]), le = P({});
|
|
797
|
+
for (const c of Object.keys(U))
|
|
798
|
+
le.current[c] = d[c];
|
|
798
799
|
return w(() => {
|
|
799
|
-
const
|
|
800
|
-
if (!
|
|
801
|
-
const
|
|
802
|
-
for (const [
|
|
803
|
-
ae.includes(
|
|
804
|
-
|
|
805
|
-
le.current[
|
|
800
|
+
const c = s.current;
|
|
801
|
+
if (!c) return;
|
|
802
|
+
const u = [];
|
|
803
|
+
for (const [m, j] of Object.entries(U))
|
|
804
|
+
ae.includes(m) && u.push(
|
|
805
|
+
c.on(j, (J, _) => {
|
|
806
|
+
le.current[m]?.(J, _);
|
|
806
807
|
})
|
|
807
808
|
);
|
|
808
809
|
return () => {
|
|
809
|
-
|
|
810
|
+
u.forEach((m) => m());
|
|
810
811
|
};
|
|
811
812
|
}, [ae]), be(
|
|
812
813
|
e,
|
|
813
814
|
() => ({
|
|
814
815
|
get element() {
|
|
815
|
-
return
|
|
816
|
+
return s.current;
|
|
816
817
|
},
|
|
817
818
|
async getConfig() {
|
|
818
|
-
return
|
|
819
|
+
return s.current?.getConfig?.() ?? {};
|
|
819
820
|
},
|
|
820
821
|
async ready() {
|
|
821
|
-
return
|
|
822
|
+
return s.current?.ready?.();
|
|
822
823
|
},
|
|
823
824
|
async forceLayout() {
|
|
824
|
-
return
|
|
825
|
+
return s.current?.forceLayout?.();
|
|
825
826
|
},
|
|
826
|
-
async toggleGroup(
|
|
827
|
-
return
|
|
827
|
+
async toggleGroup(c) {
|
|
828
|
+
return s.current?.toggleGroup?.(c);
|
|
828
829
|
},
|
|
829
|
-
registerStyles(
|
|
830
|
-
|
|
830
|
+
registerStyles(c, u) {
|
|
831
|
+
s.current?.registerStyles?.(c, u);
|
|
831
832
|
},
|
|
832
|
-
unregisterStyles(
|
|
833
|
-
|
|
833
|
+
unregisterStyles(c) {
|
|
834
|
+
s.current?.unregisterStyles?.(c);
|
|
834
835
|
},
|
|
835
|
-
setRowLoading(
|
|
836
|
-
|
|
836
|
+
setRowLoading(c, u) {
|
|
837
|
+
s.current?.setRowLoading?.(c, u);
|
|
837
838
|
},
|
|
838
|
-
setCellLoading(
|
|
839
|
-
|
|
839
|
+
setCellLoading(c, u, m) {
|
|
840
|
+
s.current?.setCellLoading?.(c, u, m);
|
|
840
841
|
},
|
|
841
|
-
isRowLoading(
|
|
842
|
-
return
|
|
842
|
+
isRowLoading(c) {
|
|
843
|
+
return s.current?.isRowLoading?.(c) ?? !1;
|
|
843
844
|
},
|
|
844
|
-
isCellLoading(
|
|
845
|
-
return
|
|
845
|
+
isCellLoading(c, u) {
|
|
846
|
+
return s.current?.isCellLoading?.(c, u) ?? !1;
|
|
846
847
|
},
|
|
847
848
|
clearAllLoading() {
|
|
848
|
-
|
|
849
|
+
s.current?.clearAllLoading?.();
|
|
849
850
|
}
|
|
850
851
|
}),
|
|
851
852
|
[]
|
|
852
853
|
), /* @__PURE__ */ E(
|
|
853
854
|
"tbw-grid",
|
|
854
855
|
{
|
|
855
|
-
ref: (
|
|
856
|
-
if (
|
|
857
|
-
const
|
|
858
|
-
|
|
856
|
+
ref: (c) => {
|
|
857
|
+
if (s.current = c, c) {
|
|
858
|
+
const u = c;
|
|
859
|
+
B && (u.gridConfig = B), r && (u.rows = r), q && (u.columns = q);
|
|
859
860
|
}
|
|
860
861
|
},
|
|
861
|
-
class:
|
|
862
|
-
style:
|
|
863
|
-
children: /* @__PURE__ */ E(xe.Provider, { value:
|
|
862
|
+
class: k,
|
|
863
|
+
style: M,
|
|
864
|
+
children: /* @__PURE__ */ E(xe.Provider, { value: s, children: L })
|
|
864
865
|
}
|
|
865
866
|
);
|
|
866
867
|
});
|
|
@@ -870,122 +871,170 @@ function pt(n) {
|
|
|
870
871
|
header: e,
|
|
871
872
|
type: r,
|
|
872
873
|
editable: o,
|
|
873
|
-
sortable:
|
|
874
|
-
resizable:
|
|
875
|
-
width:
|
|
876
|
-
minWidth:
|
|
877
|
-
hidden:
|
|
878
|
-
lockVisible:
|
|
879
|
-
children:
|
|
880
|
-
editor:
|
|
881
|
-
options:
|
|
882
|
-
multi:
|
|
883
|
-
format:
|
|
884
|
-
} = n,
|
|
885
|
-
(
|
|
886
|
-
|
|
874
|
+
sortable: a,
|
|
875
|
+
resizable: l,
|
|
876
|
+
width: i,
|
|
877
|
+
minWidth: f,
|
|
878
|
+
hidden: g,
|
|
879
|
+
lockVisible: v,
|
|
880
|
+
children: x,
|
|
881
|
+
editor: D,
|
|
882
|
+
options: A,
|
|
883
|
+
multi: k,
|
|
884
|
+
format: M
|
|
885
|
+
} = n, L = P(null), S = h(
|
|
886
|
+
(d) => {
|
|
887
|
+
L.current = d, d && (x && $e(d, x), D && We(d, D));
|
|
887
888
|
},
|
|
888
|
-
[
|
|
889
|
-
),
|
|
889
|
+
[x, D, t]
|
|
890
|
+
), T = typeof i == "number" ? `${i}px` : i, y = {
|
|
890
891
|
field: t,
|
|
891
|
-
ref:
|
|
892
|
+
ref: S
|
|
892
893
|
};
|
|
893
|
-
return e !== void 0 && (
|
|
894
|
+
return e !== void 0 && (y.header = e), r !== void 0 && (y.type = r), o !== void 0 && (y.editable = o), a !== void 0 && (y.sortable = a), l !== void 0 && (y.resizable = l), T !== void 0 && (y.width = T), f !== void 0 && (y["min-width"] = f), g !== void 0 && (y.hidden = g), v !== void 0 && (y["lock-visible"] = v), k !== void 0 && (y.multi = k), M && (y["data-has-format"] = "true"), A && (y["data-has-options"] = "true"), /* @__PURE__ */ E("tbw-grid-column", { ...y });
|
|
894
895
|
}
|
|
895
896
|
function mt({ children: n }) {
|
|
896
897
|
return /* @__PURE__ */ E("tbw-grid-tool-buttons", { children: n });
|
|
897
898
|
}
|
|
898
899
|
const yt = ({ icons: n, defaults: t, children: e }) => {
|
|
899
900
|
let r = e;
|
|
900
|
-
return t && (r = /* @__PURE__ */ E(
|
|
901
|
+
return t && (r = /* @__PURE__ */ E(Te, { defaults: t, children: r })), n && (r = /* @__PURE__ */ E(Ve, { icons: n, children: r })), /* @__PURE__ */ E(Re, { children: r });
|
|
901
902
|
};
|
|
902
|
-
function ht() {
|
|
903
|
-
const
|
|
903
|
+
function ht(n) {
|
|
904
|
+
const t = P(null), [e, r] = de(!1), [o, a] = de(null), l = P(null), i = h(() => n ? (l.current ??= document.querySelector(n), l.current) : t.current?.element ?? null, [n]);
|
|
904
905
|
w(() => {
|
|
905
|
-
|
|
906
|
-
if (!d) return;
|
|
907
|
-
let p = !0;
|
|
906
|
+
let d = !0;
|
|
908
907
|
return (async () => {
|
|
909
908
|
try {
|
|
910
|
-
if (
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
909
|
+
if (n) {
|
|
910
|
+
const p = document.querySelector(n);
|
|
911
|
+
if (!p) return;
|
|
912
|
+
if (l.current = p, await p.ready?.(), d) {
|
|
913
|
+
r(!0);
|
|
914
|
+
const b = await p.getConfig?.();
|
|
915
|
+
d && b && a(b);
|
|
916
|
+
}
|
|
917
|
+
} else {
|
|
918
|
+
const p = t.current;
|
|
919
|
+
if (!p) return;
|
|
920
|
+
if (await p.ready?.(), d) {
|
|
921
|
+
r(!0);
|
|
922
|
+
const b = await p.getConfig?.();
|
|
923
|
+
d && b && a(b);
|
|
924
|
+
}
|
|
914
925
|
}
|
|
915
926
|
} catch {
|
|
916
927
|
}
|
|
917
928
|
})(), () => {
|
|
918
|
-
|
|
929
|
+
d = !1;
|
|
919
930
|
};
|
|
920
|
-
}, []);
|
|
921
|
-
const
|
|
922
|
-
const d =
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
const
|
|
926
|
-
|
|
927
|
-
}, []),
|
|
928
|
-
const
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
n.current?.registerStyles?.(d, p);
|
|
932
|
-
}, []), f = R((d) => {
|
|
933
|
-
n.current?.unregisterStyles?.(d);
|
|
934
|
-
}, []), C = R(() => r?.columns ? r.columns.filter((d) => !d.hidden) : [], [r]), P = R(() => {
|
|
935
|
-
const d = n.current?.element, p = d?.getPluginByName?.("selection");
|
|
936
|
-
if (!p) {
|
|
937
|
-
console.warn("[useGrid] selectAll requires SelectionPlugin");
|
|
931
|
+
}, [n]);
|
|
932
|
+
const f = h(async () => {
|
|
933
|
+
const d = i();
|
|
934
|
+
if (d)
|
|
935
|
+
return await d.getConfig?.() ?? null;
|
|
936
|
+
const s = t.current;
|
|
937
|
+
return s ? await s.getConfig?.() ?? null : null;
|
|
938
|
+
}, [i]), g = h(async () => {
|
|
939
|
+
const d = i();
|
|
940
|
+
if (d) {
|
|
941
|
+
await d.forceLayout?.();
|
|
938
942
|
return;
|
|
939
943
|
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
944
|
+
const s = t.current;
|
|
945
|
+
s && await s.forceLayout?.();
|
|
946
|
+
}, [i]), v = h(
|
|
947
|
+
async (d) => {
|
|
948
|
+
const s = i();
|
|
949
|
+
if (s) {
|
|
950
|
+
await s.toggleGroup?.(d);
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
const p = t.current;
|
|
954
|
+
p && await p.toggleGroup?.(d);
|
|
955
|
+
},
|
|
956
|
+
[i]
|
|
957
|
+
), x = h(
|
|
958
|
+
(d, s) => {
|
|
959
|
+
const p = i();
|
|
960
|
+
if (p) {
|
|
961
|
+
p.registerStyles?.(d, s);
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
964
|
+
t.current?.registerStyles?.(d, s);
|
|
965
|
+
},
|
|
966
|
+
[i]
|
|
967
|
+
), D = h(
|
|
968
|
+
(d) => {
|
|
969
|
+
const s = i();
|
|
970
|
+
if (s) {
|
|
971
|
+
s.unregisterStyles?.(d);
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
t.current?.unregisterStyles?.(d);
|
|
975
|
+
},
|
|
976
|
+
[i]
|
|
977
|
+
), A = h(() => o?.columns ? o.columns.filter((d) => !d.hidden) : [], [o]), k = h(() => {
|
|
978
|
+
const d = i(), s = d?.getPluginByName?.("selection");
|
|
979
|
+
if (!s) {
|
|
980
|
+
console.warn("[useGrid] selectAll requires SelectionPlugin");
|
|
959
981
|
return;
|
|
960
982
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
if (!m) {
|
|
965
|
-
console.warn("[useGrid] exportToJson requires ExportPlugin (use export prop)");
|
|
966
|
-
return;
|
|
983
|
+
if (s.config?.mode === "row") {
|
|
984
|
+
const p = d?.rows ?? [], b = new Set(p.map((H, F) => F));
|
|
985
|
+
s.selected = b, s.requestAfterRender?.();
|
|
967
986
|
}
|
|
968
|
-
|
|
969
|
-
|
|
987
|
+
}, [i]), M = h(() => {
|
|
988
|
+
const s = i()?.getPluginByName?.("selection");
|
|
989
|
+
s && s.clearSelection?.();
|
|
990
|
+
}, [i]), L = h(() => {
|
|
991
|
+
const s = i()?.getPluginByName?.("selection");
|
|
992
|
+
return s ? new Set(s.selected ?? []) : /* @__PURE__ */ new Set();
|
|
993
|
+
}, [i]), S = h(() => {
|
|
994
|
+
const d = i(), s = d?.getPluginByName?.("selection");
|
|
995
|
+
if (!s) return [];
|
|
996
|
+
const p = d?.rows ?? [], b = s.selected ?? /* @__PURE__ */ new Set();
|
|
997
|
+
return p.filter((H, F) => b.has(F));
|
|
998
|
+
}, [i]), T = h(
|
|
999
|
+
(d) => {
|
|
1000
|
+
const p = i()?.getPluginByName?.("export");
|
|
1001
|
+
if (!p) {
|
|
1002
|
+
console.warn("[useGrid] exportToCsv requires ExportPlugin (use export prop)");
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
p.exportCsv?.({ filename: d ?? "export.csv" });
|
|
1006
|
+
},
|
|
1007
|
+
[i]
|
|
1008
|
+
), y = h(
|
|
1009
|
+
(d) => {
|
|
1010
|
+
const p = i()?.getPluginByName?.("export");
|
|
1011
|
+
if (!p) {
|
|
1012
|
+
console.warn("[useGrid] exportToJson requires ExportPlugin (use export prop)");
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
p.exportJson?.({ filename: d ?? "export.json" });
|
|
1016
|
+
},
|
|
1017
|
+
[i]
|
|
1018
|
+
);
|
|
970
1019
|
return {
|
|
971
|
-
ref:
|
|
972
|
-
element:
|
|
973
|
-
isReady:
|
|
974
|
-
config:
|
|
975
|
-
getConfig:
|
|
976
|
-
forceLayout:
|
|
977
|
-
toggleGroup:
|
|
978
|
-
registerStyles:
|
|
979
|
-
unregisterStyles:
|
|
980
|
-
getVisibleColumns:
|
|
1020
|
+
ref: t,
|
|
1021
|
+
element: i(),
|
|
1022
|
+
isReady: e,
|
|
1023
|
+
config: o,
|
|
1024
|
+
getConfig: f,
|
|
1025
|
+
forceLayout: g,
|
|
1026
|
+
toggleGroup: v,
|
|
1027
|
+
registerStyles: x,
|
|
1028
|
+
unregisterStyles: D,
|
|
1029
|
+
getVisibleColumns: A,
|
|
981
1030
|
// Selection methods
|
|
982
|
-
selectAll:
|
|
983
|
-
clearSelection:
|
|
984
|
-
getSelectedIndices:
|
|
985
|
-
getSelectedRows:
|
|
1031
|
+
selectAll: k,
|
|
1032
|
+
clearSelection: M,
|
|
1033
|
+
getSelectedIndices: L,
|
|
1034
|
+
getSelectedRows: S,
|
|
986
1035
|
// Export methods
|
|
987
|
-
exportToCsv:
|
|
988
|
-
exportToJson:
|
|
1036
|
+
exportToCsv: T,
|
|
1037
|
+
exportToJson: y
|
|
989
1038
|
};
|
|
990
1039
|
}
|
|
991
1040
|
let ge = !1;
|
|
@@ -995,17 +1044,17 @@ function wt(n, t, e, r = []) {
|
|
|
995
1044
|
Example: <DataGrid onSelectionChange={(e) => ...} />
|
|
996
1045
|
See migration guide: https://toolbox-web.dev/grid-react/migration`
|
|
997
1046
|
));
|
|
998
|
-
const o =
|
|
1047
|
+
const o = P(e);
|
|
999
1048
|
w(() => {
|
|
1000
1049
|
o.current = e;
|
|
1001
1050
|
}, [e, ...r]), w(() => {
|
|
1002
|
-
const
|
|
1003
|
-
if (!
|
|
1004
|
-
const
|
|
1005
|
-
o.current(
|
|
1051
|
+
const a = n.current, l = a && "element" in a ? a.element : a;
|
|
1052
|
+
if (!l) return;
|
|
1053
|
+
const i = ((f) => {
|
|
1054
|
+
o.current(f);
|
|
1006
1055
|
});
|
|
1007
|
-
return
|
|
1008
|
-
|
|
1056
|
+
return l.addEventListener(t, i), () => {
|
|
1057
|
+
l.removeEventListener(t, i);
|
|
1009
1058
|
};
|
|
1010
1059
|
}, [n, t]);
|
|
1011
1060
|
}
|
|
@@ -1013,13 +1062,13 @@ export {
|
|
|
1013
1062
|
gt as DataGrid,
|
|
1014
1063
|
he as GridAdapter,
|
|
1015
1064
|
pt as GridColumn,
|
|
1016
|
-
|
|
1065
|
+
_e as GridDetailPanel,
|
|
1017
1066
|
Ve as GridIconProvider,
|
|
1018
1067
|
yt as GridProvider,
|
|
1019
|
-
|
|
1068
|
+
Le as GridResponsiveCard,
|
|
1020
1069
|
mt as GridToolButtons,
|
|
1021
1070
|
ut as GridToolPanel,
|
|
1022
|
-
|
|
1071
|
+
Te as GridTypeProvider,
|
|
1023
1072
|
ft as ReactGridAdapter,
|
|
1024
1073
|
ht as useGrid,
|
|
1025
1074
|
wt as useGridEvent,
|