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