@toolbox-web/grid-react 0.10.0 → 0.11.0
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 +17 -9
- package/chunks/data-grid-GKyKxE6c.js +799 -0
- package/features/export.d.ts +50 -7
- package/features/export.d.ts.map +1 -1
- package/features/export.js +65 -5
- package/features/filtering.d.ts +62 -7
- package/features/filtering.d.ts.map +1 -1
- package/features/filtering.js +81 -5
- package/features/print.d.ts +34 -7
- package/features/print.d.ts.map +1 -1
- package/features/print.js +27 -3
- package/features/selection.d.ts +47 -7
- package/features/selection.d.ts.map +1 -1
- package/features/selection.js +48 -3
- package/features/undo-redo.d.ts +51 -9
- package/features/undo-redo.d.ts.map +1 -1
- package/features/undo-redo.js +42 -5
- package/index.d.ts +10 -2
- package/index.d.ts.map +1 -1
- package/index.js +127 -904
- package/lib/data-grid.d.ts +10 -4
- package/lib/data-grid.d.ts.map +1 -1
- package/lib/grid-type-registry.d.ts +32 -8
- package/lib/grid-type-registry.d.ts.map +1 -1
- package/lib/react-column-config.d.ts +59 -29
- package/lib/react-column-config.d.ts.map +1 -1
- package/lib/react-grid-adapter.d.ts +8 -3
- package/lib/react-grid-adapter.d.ts.map +1 -1
- package/lib/use-grid.d.ts +37 -0
- package/lib/use-grid.d.ts.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,944 +1,167 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { c as Re } from "./chunks/feature-registry-Y3KvnN54.js";
|
|
7
|
-
function be(n) {
|
|
8
|
-
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
9
|
-
}
|
|
10
|
-
function le(n) {
|
|
11
|
-
return n.toLowerCase() === "id" ? "ID" : n.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").split(" ").filter(Boolean).map(be).join(" ");
|
|
12
|
-
}
|
|
13
|
-
const Ee = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime", "currency"]);
|
|
14
|
-
function Se(n) {
|
|
15
|
-
const t = n.lastIndexOf(":");
|
|
16
|
-
if (t > 0) {
|
|
17
|
-
const e = n.slice(t + 1).toLowerCase();
|
|
18
|
-
if (Ee.has(e)) {
|
|
19
|
-
const r = n.slice(0, t);
|
|
20
|
-
return {
|
|
21
|
-
field: r,
|
|
22
|
-
header: le(r),
|
|
23
|
-
type: e
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
field: n,
|
|
29
|
-
header: le(n)
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function xe(n) {
|
|
33
|
-
return n.map((t) => typeof t == "string" ? Se(t) : t);
|
|
34
|
-
}
|
|
35
|
-
const W = {
|
|
36
|
-
onCellClick: "cell-click",
|
|
37
|
-
onRowClick: "row-click",
|
|
38
|
-
onCellActivate: "cell-activate",
|
|
39
|
-
onCellChange: "cell-change",
|
|
40
|
-
onCellCommit: "cell-commit",
|
|
41
|
-
onRowCommit: "row-commit",
|
|
42
|
-
onSortChange: "sort-change",
|
|
43
|
-
onFilterChange: "filter-change",
|
|
44
|
-
onColumnResize: "column-resize",
|
|
45
|
-
onColumnMove: "column-move",
|
|
46
|
-
onColumnVisibility: "column-visibility",
|
|
47
|
-
onColumnStateChange: "column-state-change",
|
|
48
|
-
onSelectionChange: "selection-change",
|
|
49
|
-
onRowMove: "row-move",
|
|
50
|
-
onGroupToggle: "group-toggle",
|
|
51
|
-
onTreeExpand: "tree-expand",
|
|
52
|
-
onDetailExpand: "detail-expand",
|
|
53
|
-
onResponsiveChange: "responsive-change",
|
|
54
|
-
onCopy: "copy",
|
|
55
|
-
onPaste: "paste",
|
|
56
|
-
onUndoRedo: "undo-redo",
|
|
57
|
-
onExportComplete: "export-complete",
|
|
58
|
-
onPrintStart: "print-start",
|
|
59
|
-
onPrintComplete: "print-complete"
|
|
60
|
-
}, ee = fe(null), Pe = ({ icons: n, children: t }) => /* @__PURE__ */ E(ee.Provider, { value: n, children: t });
|
|
61
|
-
function et() {
|
|
62
|
-
return j(ee);
|
|
63
|
-
}
|
|
64
|
-
const De = ee, J = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new Map();
|
|
65
|
-
function ge(n) {
|
|
66
|
-
const t = n.querySelector("tbw-grid-responsive-card");
|
|
67
|
-
if (t) {
|
|
68
|
-
const r = J.get(t);
|
|
69
|
-
if (r) return r;
|
|
70
|
-
}
|
|
71
|
-
const e = n.id || n.getAttribute("data-grid-id");
|
|
72
|
-
if (e)
|
|
73
|
-
return U.get(e);
|
|
74
|
-
}
|
|
75
|
-
function Ge(n) {
|
|
76
|
-
const { children: t, cardRowHeight: e = "auto" } = n, r = G(null), o = v(
|
|
77
|
-
(i) => {
|
|
78
|
-
if (r.current = i, !i) return;
|
|
79
|
-
J.set(i, t);
|
|
80
|
-
const c = i.closest("tbw-grid");
|
|
81
|
-
if (c) {
|
|
82
|
-
const d = c.id || c.getAttribute("data-grid-id");
|
|
83
|
-
d && U.set(d, t);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
[t]
|
|
87
|
-
);
|
|
88
|
-
w(() => () => {
|
|
89
|
-
const i = r.current;
|
|
90
|
-
if (i) {
|
|
91
|
-
J.delete(i);
|
|
92
|
-
const c = i.closest("tbw-grid");
|
|
93
|
-
if (c) {
|
|
94
|
-
const d = c.id || c.getAttribute("data-grid-id");
|
|
95
|
-
d && U.delete(d);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}, []);
|
|
99
|
-
const a = e === "auto" ? "auto" : String(e);
|
|
100
|
-
return /* @__PURE__ */ E("tbw-grid-responsive-card", { ref: o, cardRowHeight: a });
|
|
101
|
-
}
|
|
102
|
-
Ge.displayName = "GridResponsiveCard";
|
|
103
|
-
const q = fe(null), Ae = ({ defaults: n, children: t }) => /* @__PURE__ */ E(q.Provider, { value: n, children: t });
|
|
104
|
-
function tt() {
|
|
105
|
-
return j(q);
|
|
106
|
-
}
|
|
107
|
-
function rt(n) {
|
|
108
|
-
return j(q)?.[n];
|
|
109
|
-
}
|
|
110
|
-
const Ie = q;
|
|
111
|
-
function Ne(n) {
|
|
112
|
-
const t = /* @__PURE__ */ new WeakMap();
|
|
113
|
-
return (e) => {
|
|
114
|
-
const r = e.cellEl;
|
|
115
|
-
if (r) {
|
|
116
|
-
const i = t.get(r);
|
|
117
|
-
if (i)
|
|
118
|
-
return b(() => {
|
|
119
|
-
i.root.render(n(e));
|
|
120
|
-
}), i.container;
|
|
121
|
-
}
|
|
122
|
-
const o = document.createElement("div");
|
|
123
|
-
o.className = "react-cell-renderer", o.style.display = "contents";
|
|
124
|
-
const a = S(o);
|
|
125
|
-
return b(() => {
|
|
126
|
-
a.render(n(e));
|
|
127
|
-
}), r && t.set(r, { root: a, container: o }), o;
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
function Te(n) {
|
|
131
|
-
return (t) => {
|
|
132
|
-
const e = document.createElement("div");
|
|
133
|
-
e.className = "react-cell-editor", e.style.display = "contents";
|
|
134
|
-
const r = S(e);
|
|
135
|
-
return b(() => {
|
|
136
|
-
r.render(n(t));
|
|
137
|
-
}), e;
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
function Ve(n) {
|
|
141
|
-
if (!n) return;
|
|
142
|
-
if (!n.columns) return n;
|
|
143
|
-
const t = n.columns.map((e) => {
|
|
144
|
-
const { renderer: r, editor: o, ...a } = e, i = { ...a };
|
|
145
|
-
return r && (i.renderer = Ne(r)), o && (i.editor = Te(o)), i;
|
|
146
|
-
});
|
|
147
|
-
return {
|
|
148
|
-
...n,
|
|
149
|
-
columns: t
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
const K = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new Map();
|
|
153
|
-
function ke(n) {
|
|
154
|
-
const t = n.querySelector("tbw-grid-detail");
|
|
155
|
-
if (t) {
|
|
156
|
-
const r = K.get(t);
|
|
157
|
-
if (r) return r;
|
|
158
|
-
}
|
|
159
|
-
const e = n.id || n.getAttribute("data-grid-id");
|
|
160
|
-
if (e)
|
|
161
|
-
return Y.get(e);
|
|
162
|
-
}
|
|
163
|
-
function Le(n) {
|
|
164
|
-
const { children: t, showExpandColumn: e = !0, animation: r = "slide" } = n, o = G(null), a = v(
|
|
165
|
-
(c) => {
|
|
166
|
-
if (o.current = c, !c) return;
|
|
167
|
-
K.set(c, t);
|
|
168
|
-
const d = c.closest("tbw-grid");
|
|
169
|
-
if (d) {
|
|
170
|
-
const p = d.id || d.getAttribute("data-grid-id");
|
|
171
|
-
p && Y.set(p, t);
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
[t]
|
|
175
|
-
);
|
|
176
|
-
return w(() => () => {
|
|
177
|
-
const c = o.current;
|
|
178
|
-
if (c) {
|
|
179
|
-
K.delete(c);
|
|
180
|
-
const d = c.closest("tbw-grid");
|
|
181
|
-
if (d) {
|
|
182
|
-
const C = d.id || d.getAttribute("data-grid-id");
|
|
183
|
-
C && Y.delete(C);
|
|
184
|
-
}
|
|
185
|
-
const p = c.parentNode;
|
|
186
|
-
p && p.contains(c);
|
|
187
|
-
}
|
|
188
|
-
}, []), /* @__PURE__ */ E(
|
|
189
|
-
"tbw-grid-detail",
|
|
190
|
-
{
|
|
191
|
-
ref: a,
|
|
192
|
-
showExpandColumn: e ? void 0 : "false",
|
|
193
|
-
animation: r === !1 ? "false" : r
|
|
194
|
-
}
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
Le.displayName = "GridDetailPanel";
|
|
198
|
-
const Z = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new Map();
|
|
199
|
-
function Fe(n) {
|
|
200
|
-
const t = Z.get(n);
|
|
201
|
-
if (t) return t;
|
|
202
|
-
const e = n.id;
|
|
203
|
-
if (e)
|
|
204
|
-
return Q.get(e);
|
|
205
|
-
}
|
|
206
|
-
function nt(n) {
|
|
207
|
-
const { id: t, title: e, icon: r, tooltip: o, order: a = 100, children: i } = n, c = G(null), d = v(
|
|
208
|
-
(p) => {
|
|
209
|
-
c.current = p, p && (Z.set(p, i), t && Q.set(t, i));
|
|
210
|
-
},
|
|
211
|
-
[i, t]
|
|
212
|
-
);
|
|
213
|
-
return w(() => () => {
|
|
214
|
-
const p = c.current;
|
|
215
|
-
p && (Z.delete(p), t && Q.delete(t));
|
|
216
|
-
}, [t]), /* @__PURE__ */ E(
|
|
217
|
-
"tbw-grid-tool-panel",
|
|
218
|
-
{
|
|
219
|
-
ref: d,
|
|
220
|
-
id: t,
|
|
221
|
-
title: e,
|
|
222
|
-
icon: r,
|
|
223
|
-
tooltip: o,
|
|
224
|
-
order: a?.toString()
|
|
225
|
-
}
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
const N = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new Map();
|
|
229
|
-
function Me(n, t) {
|
|
230
|
-
const e = n.getAttribute("field"), r = N.get(n) ?? {};
|
|
231
|
-
if (r.renderer = t, N.set(n, r), e) {
|
|
232
|
-
const o = V.get(e) ?? {};
|
|
233
|
-
o.renderer = t, V.set(e, o);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
function Oe(n, t) {
|
|
237
|
-
const e = n.getAttribute("field"), r = N.get(n) ?? {};
|
|
238
|
-
if (r.editor = t, N.set(n, r), e) {
|
|
239
|
-
const o = V.get(e) ?? {};
|
|
240
|
-
o.editor = t, V.set(e, o);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
function Be(n) {
|
|
244
|
-
let t = N.get(n)?.renderer;
|
|
245
|
-
if (!t) {
|
|
246
|
-
const e = n.getAttribute("field");
|
|
247
|
-
e && (t = V.get(e)?.renderer);
|
|
248
|
-
}
|
|
249
|
-
return t;
|
|
250
|
-
}
|
|
251
|
-
function je(n) {
|
|
252
|
-
let t = N.get(n)?.editor;
|
|
253
|
-
if (!t) {
|
|
254
|
-
const e = n.getAttribute("field");
|
|
255
|
-
e && (t = V.get(e)?.editor);
|
|
256
|
-
}
|
|
257
|
-
return t;
|
|
258
|
-
}
|
|
259
|
-
class He {
|
|
260
|
-
mountedViews = [];
|
|
261
|
-
typeDefaults = null;
|
|
262
|
-
/**
|
|
263
|
-
* Sets the type defaults map for this adapter.
|
|
264
|
-
* Called by DataGrid when it receives type defaults from context.
|
|
265
|
-
*
|
|
266
|
-
* @internal
|
|
267
|
-
*/
|
|
268
|
-
setTypeDefaults(t) {
|
|
269
|
-
this.typeDefaults = t;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Determines if this adapter can handle the given element.
|
|
273
|
-
* Checks if a renderer or editor is registered for this element.
|
|
274
|
-
*/
|
|
275
|
-
canHandle(t) {
|
|
276
|
-
const e = t.getAttribute("field");
|
|
277
|
-
let r = N.get(t);
|
|
278
|
-
if (!r && e) {
|
|
279
|
-
const i = V.get(e);
|
|
280
|
-
i && (i.renderer || i.editor) && (r = i, N.set(t, r));
|
|
281
|
-
}
|
|
282
|
-
const o = r?.renderer !== void 0, a = r?.editor !== void 0;
|
|
283
|
-
return r !== void 0 && (o || a);
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Creates a view renderer function that renders a React component
|
|
287
|
-
* and returns its container DOM element.
|
|
288
|
-
*
|
|
289
|
-
* Uses a cell cache to reuse React roots for performance - instead of
|
|
290
|
-
* creating new roots on each render, we reuse existing ones and just
|
|
291
|
-
* call root.render() with new data.
|
|
292
|
-
*
|
|
293
|
-
* Returns undefined if no renderer is registered for this element,
|
|
294
|
-
* allowing the grid to use its default rendering.
|
|
295
|
-
*/
|
|
296
|
-
createRenderer(t) {
|
|
297
|
-
const e = Be(t);
|
|
298
|
-
if (!e)
|
|
299
|
-
return;
|
|
300
|
-
const r = /* @__PURE__ */ new WeakMap();
|
|
301
|
-
return (o) => {
|
|
302
|
-
const a = o.cellEl;
|
|
303
|
-
if (a) {
|
|
304
|
-
const d = r.get(a);
|
|
305
|
-
if (d)
|
|
306
|
-
return b(() => {
|
|
307
|
-
d.root.render(e(o));
|
|
308
|
-
}), d.container;
|
|
309
|
-
const p = document.createElement("div");
|
|
310
|
-
p.className = "react-cell-renderer", p.style.display = "contents";
|
|
311
|
-
const C = S(p);
|
|
312
|
-
return b(() => {
|
|
313
|
-
C.render(e(o));
|
|
314
|
-
}), r.set(a, { root: C, container: p, lastRowIndex: o.rowIndex ?? -1 }), this.mountedViews.push({ root: C, container: p }), p;
|
|
315
|
-
}
|
|
316
|
-
const i = document.createElement("div");
|
|
317
|
-
i.className = "react-cell-renderer", i.style.display = "contents";
|
|
318
|
-
const c = S(i);
|
|
319
|
-
return b(() => {
|
|
320
|
-
c.render(e(o));
|
|
321
|
-
}), this.mountedViews.push({ root: c, container: i }), i;
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Creates an editor spec that renders a React component
|
|
326
|
-
* with commit/cancel callbacks passed as props.
|
|
327
|
-
*/
|
|
328
|
-
createEditor(t) {
|
|
329
|
-
const e = je(t);
|
|
330
|
-
return e ? (r) => {
|
|
331
|
-
const o = document.createElement("div");
|
|
332
|
-
o.className = "react-cell-editor", o.style.display = "contents";
|
|
333
|
-
const a = S(o);
|
|
334
|
-
return b(() => {
|
|
335
|
-
a.render(e(r));
|
|
336
|
-
}), this.mountedViews.push({ root: a, container: o }), o;
|
|
337
|
-
} : () => document.createElement("div");
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Creates a detail renderer function for MasterDetailPlugin.
|
|
341
|
-
* Renders React components for expandable detail rows.
|
|
342
|
-
*/
|
|
343
|
-
createDetailRenderer(t) {
|
|
344
|
-
const e = ke(t);
|
|
345
|
-
if (e)
|
|
346
|
-
return (r, o) => {
|
|
347
|
-
const a = document.createElement("div");
|
|
348
|
-
a.className = "react-detail-panel";
|
|
349
|
-
const i = { row: r, rowIndex: o }, c = S(a);
|
|
350
|
-
return b(() => {
|
|
351
|
-
c.render(e(i));
|
|
352
|
-
}), this.mountedViews.push({ root: c, container: a }), a;
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Framework adapter hook called by MasterDetailPlugin during attach().
|
|
357
|
-
* Parses the <tbw-grid-detail> element and returns a React-based renderer.
|
|
358
|
-
*/
|
|
359
|
-
parseDetailElement(t) {
|
|
360
|
-
const e = t.closest("tbw-grid");
|
|
361
|
-
if (e)
|
|
362
|
-
return this.createDetailRenderer(e);
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Creates a responsive card renderer function for ResponsivePlugin.
|
|
366
|
-
* Renders React components for card layout in responsive mode.
|
|
367
|
-
*/
|
|
368
|
-
createResponsiveCardRenderer(t) {
|
|
369
|
-
const e = ge(t);
|
|
370
|
-
if (e)
|
|
371
|
-
return (r, o) => {
|
|
372
|
-
const a = document.createElement("div");
|
|
373
|
-
a.className = "react-responsive-card";
|
|
374
|
-
const i = { row: r, index: o }, c = S(a);
|
|
375
|
-
return b(() => {
|
|
376
|
-
c.render(e(i));
|
|
377
|
-
}), this.mountedViews.push({ root: c, container: a }), a;
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Creates a tool panel renderer from a light DOM element.
|
|
382
|
-
* Renders React components into tool panel containers.
|
|
383
|
-
*/
|
|
384
|
-
createToolPanelRenderer(t) {
|
|
385
|
-
const e = Fe(t);
|
|
386
|
-
if (!e)
|
|
387
|
-
return;
|
|
388
|
-
const r = t.closest("tbw-grid");
|
|
389
|
-
return (o) => {
|
|
390
|
-
const a = {
|
|
391
|
-
grid: r ?? o
|
|
392
|
-
}, i = S(o);
|
|
393
|
-
return b(() => {
|
|
394
|
-
i.render(e(a));
|
|
395
|
-
}), this.mountedViews.push({ root: i, container: o }), () => {
|
|
396
|
-
const c = this.mountedViews.findIndex((d) => d.container === o);
|
|
397
|
-
if (c !== -1) {
|
|
398
|
-
const { root: d } = this.mountedViews[c];
|
|
399
|
-
try {
|
|
400
|
-
d.unmount();
|
|
401
|
-
} catch {
|
|
402
|
-
}
|
|
403
|
-
this.mountedViews.splice(c, 1);
|
|
404
|
-
}
|
|
405
|
-
};
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* Gets type-level defaults from the type defaults map.
|
|
410
|
-
*
|
|
411
|
-
* This enables application-wide type defaults configured via GridTypeProvider.
|
|
412
|
-
* The returned TypeDefault contains renderer/editor functions that render
|
|
413
|
-
* React components into the grid's cells.
|
|
414
|
-
*
|
|
415
|
-
* @example
|
|
416
|
-
* ```tsx
|
|
417
|
-
* // App.tsx
|
|
418
|
-
* const typeDefaults = {
|
|
419
|
-
* country: {
|
|
420
|
-
* renderer: (ctx) => <CountryBadge code={ctx.value} />,
|
|
421
|
-
* editor: (ctx) => <CountrySelect value={ctx.value} onCommit={ctx.commit} />
|
|
422
|
-
* }
|
|
423
|
-
* };
|
|
424
|
-
*
|
|
425
|
-
* <GridTypeProvider defaults={typeDefaults}>
|
|
426
|
-
* <App />
|
|
427
|
-
* </GridTypeProvider>
|
|
428
|
-
*
|
|
429
|
-
* // Any grid with type: 'country' columns will use these components
|
|
430
|
-
* ```
|
|
431
|
-
*/
|
|
432
|
-
getTypeDefault(t) {
|
|
433
|
-
if (!this.typeDefaults)
|
|
434
|
-
return;
|
|
435
|
-
const e = this.typeDefaults[t];
|
|
436
|
-
if (!e)
|
|
437
|
-
return;
|
|
438
|
-
const r = {
|
|
439
|
-
editorParams: e.editorParams
|
|
440
|
-
};
|
|
441
|
-
return e.renderer && (r.renderer = this.createTypeRenderer(e.renderer)), e.editor && (r.editor = this.createTypeEditor(e.editor)), r;
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* Creates a renderer function from a React render function for type defaults.
|
|
445
|
-
* @internal
|
|
446
|
-
*/
|
|
447
|
-
createTypeRenderer(t) {
|
|
448
|
-
return (e) => {
|
|
449
|
-
const r = document.createElement("span");
|
|
450
|
-
r.style.display = "contents";
|
|
451
|
-
const o = S(r);
|
|
452
|
-
return this.mountedViews.push({ root: o, container: r }), b(() => {
|
|
453
|
-
o.render(t(e));
|
|
454
|
-
}), r;
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
/**
|
|
458
|
-
* Creates an editor function from a React render function for type defaults.
|
|
459
|
-
* @internal
|
|
460
|
-
*/
|
|
461
|
-
createTypeEditor(t) {
|
|
462
|
-
return (e) => {
|
|
463
|
-
const r = document.createElement("span");
|
|
464
|
-
r.style.display = "contents";
|
|
465
|
-
const o = S(r);
|
|
466
|
-
return this.mountedViews.push({ root: o, container: r }), b(() => {
|
|
467
|
-
o.render(t(e));
|
|
468
|
-
}), r;
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
/**
|
|
472
|
-
* Clean up all mounted React roots.
|
|
473
|
-
* Call this when the grid is unmounted.
|
|
474
|
-
*/
|
|
475
|
-
destroy() {
|
|
476
|
-
this.mountedViews.forEach(({ root: t }) => {
|
|
477
|
-
try {
|
|
478
|
-
t.unmount();
|
|
479
|
-
} catch {
|
|
480
|
-
}
|
|
481
|
-
}), this.mountedViews = [];
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Unmount a specific container (called when cell is recycled).
|
|
485
|
-
*/
|
|
486
|
-
unmount(t) {
|
|
487
|
-
const e = this.mountedViews.findIndex((r) => r.container === t);
|
|
488
|
-
if (e !== -1) {
|
|
489
|
-
const { root: r } = this.mountedViews[e];
|
|
490
|
-
try {
|
|
491
|
-
r.unmount();
|
|
492
|
-
} catch {
|
|
493
|
-
}
|
|
494
|
-
this.mountedViews.splice(e, 1);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
const qe = {
|
|
499
|
-
undoRedo: ["editing"],
|
|
500
|
-
clipboard: ["selection"]
|
|
501
|
-
};
|
|
502
|
-
function ze(n) {
|
|
503
|
-
const t = new Set(n);
|
|
504
|
-
for (const e of n) {
|
|
505
|
-
const r = qe[e];
|
|
506
|
-
if (r)
|
|
507
|
-
for (const o of r)
|
|
508
|
-
t.has(o) || console.warn(
|
|
509
|
-
`[DataGrid] Feature "${e}" requires "${o}" to be enabled. Add the "${o}" prop to your DataGrid.`
|
|
510
|
-
);
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
function _e(n) {
|
|
514
|
-
const t = [], e = [], r = { ...n };
|
|
515
|
-
r.multiSort !== void 0 ? delete r.sorting : r.sorting !== void 0 && (r.multiSort = r.sorting, delete r.sorting);
|
|
516
|
-
for (const [i, c] of Object.entries(r)) {
|
|
517
|
-
if (c === void 0 || c === !1) continue;
|
|
518
|
-
const d = i;
|
|
519
|
-
e.push(d);
|
|
520
|
-
}
|
|
521
|
-
ze(e);
|
|
522
|
-
const o = [
|
|
523
|
-
"selection",
|
|
524
|
-
"editing",
|
|
525
|
-
// Then everything else in the order they were specified
|
|
526
|
-
...e.filter((i) => i !== "selection" && i !== "editing")
|
|
527
|
-
], a = [...new Set(o)].filter((i) => e.includes(i));
|
|
528
|
-
for (const i of a) {
|
|
529
|
-
const c = n[i];
|
|
530
|
-
if (c === void 0 || c === !1) continue;
|
|
531
|
-
const d = Re(i, c);
|
|
532
|
-
d && t.push(d);
|
|
533
|
-
}
|
|
534
|
-
return t;
|
|
535
|
-
}
|
|
536
|
-
let de = !1, $ = null;
|
|
537
|
-
function X() {
|
|
538
|
-
return de || ($ = new He(), ye.registerAdapter($), de = !0), $;
|
|
539
|
-
}
|
|
540
|
-
X();
|
|
541
|
-
function We(n) {
|
|
542
|
-
const e = n.getPluginByName?.("masterDetail");
|
|
543
|
-
e && typeof e.refreshDetailRenderer == "function" && e.refreshDetailRenderer();
|
|
544
|
-
}
|
|
545
|
-
function $e(n, t) {
|
|
546
|
-
const e = n;
|
|
547
|
-
if (!n.querySelector("tbw-grid-responsive-card") || !ge(n)) return;
|
|
548
|
-
const a = e.getPluginByName?.("responsive");
|
|
549
|
-
if (a && typeof a.setCardRenderer == "function") {
|
|
550
|
-
const i = t.createResponsiveCardRenderer(n);
|
|
551
|
-
i && a.setCardRenderer(i);
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
function Je(n) {
|
|
555
|
-
const t = {};
|
|
556
|
-
return ve.forEach(n, (e) => {
|
|
557
|
-
if (Ce(e)) {
|
|
558
|
-
if (e.type && e.type.displayName === "GridDetailPanel") {
|
|
559
|
-
const r = e.props;
|
|
560
|
-
t.masterDetail = {
|
|
561
|
-
// Use props from the child component for configuration
|
|
562
|
-
showExpandColumn: r.showExpandColumn ?? !0,
|
|
563
|
-
animation: r.animation ?? "slide"
|
|
564
|
-
// detailRenderer will be wired up by refreshMasterDetailRenderer after mount
|
|
565
|
-
};
|
|
566
|
-
}
|
|
567
|
-
e.type && e.type.displayName === "GridResponsiveCard" && (t.responsive = !0);
|
|
568
|
-
}
|
|
569
|
-
}), t;
|
|
570
|
-
}
|
|
571
|
-
const ot = he(function(t, e) {
|
|
1
|
+
import { r as T, a as B, b as k, c as A } from "./chunks/data-grid-GKyKxE6c.js";
|
|
2
|
+
import { D as H, i as U, d as $, e as K, f as M, R as O, h as Q, u as X, g as Y } from "./chunks/data-grid-GKyKxE6c.js";
|
|
3
|
+
import { jsx as w, Fragment as I } from "react/jsx-runtime";
|
|
4
|
+
import { useRef as R, useCallback as i, useState as P, useEffect as S } from "react";
|
|
5
|
+
function J(n) {
|
|
572
6
|
const {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
ssr: g,
|
|
592
|
-
// Legacy event handlers
|
|
593
|
-
onRowsChange: m,
|
|
594
|
-
// Feature props and event props are in ...rest
|
|
595
|
-
...h
|
|
596
|
-
} = t, f = G(null), I = G(null), te = j(Ie), z = j(De), re = [
|
|
597
|
-
"selection",
|
|
598
|
-
"editing",
|
|
599
|
-
"filtering",
|
|
600
|
-
"multiSort",
|
|
601
|
-
"sorting",
|
|
602
|
-
// deprecated alias for multiSort
|
|
603
|
-
"clipboard",
|
|
604
|
-
"contextMenu",
|
|
605
|
-
"reorder",
|
|
606
|
-
"rowReorder",
|
|
607
|
-
"visibility",
|
|
608
|
-
"undoRedo",
|
|
609
|
-
"tree",
|
|
610
|
-
"groupingRows",
|
|
611
|
-
"groupingColumns",
|
|
612
|
-
"pinnedColumns",
|
|
613
|
-
"pinnedRows",
|
|
614
|
-
"masterDetail",
|
|
615
|
-
"responsive",
|
|
616
|
-
"columnVirtualization",
|
|
617
|
-
"export",
|
|
618
|
-
"print",
|
|
619
|
-
"pivot",
|
|
620
|
-
"serverSide"
|
|
621
|
-
], pe = D(() => re.map((s) => {
|
|
622
|
-
const l = h[s];
|
|
623
|
-
return l !== void 0 ? `${s}:${JSON.stringify(l)}` : "";
|
|
624
|
-
}).filter(Boolean).join("|"), [h]), ne = D(() => {
|
|
625
|
-
const s = {};
|
|
626
|
-
for (const l of re)
|
|
627
|
-
l in h && h[l] !== void 0 && (s[l] = h[l]);
|
|
628
|
-
return s;
|
|
629
|
-
}, [pe]), oe = D(() => Je(T), [T]), ie = D(() => ({ ...oe, ...ne }), [ne, oe]), _ = D(() => u || g ? [] : _e(ie), [ie, u, g]), M = D(() => {
|
|
630
|
-
if (u) {
|
|
631
|
-
const s = new Set(u.map((y) => y.name)), l = _.filter((y) => !s.has(y.name));
|
|
632
|
-
return [...u, ...l];
|
|
633
|
-
}
|
|
634
|
-
return _;
|
|
635
|
-
}, [u, _]), O = D(() => {
|
|
636
|
-
if (!a) return a;
|
|
637
|
-
const s = xe(a);
|
|
638
|
-
return i ? s.map((l) => ({
|
|
639
|
-
...i,
|
|
640
|
-
...l
|
|
641
|
-
// Individual column props override defaults
|
|
642
|
-
})) : s;
|
|
643
|
-
}, [a, i]), B = D(() => {
|
|
644
|
-
const s = Ve(o), l = {};
|
|
645
|
-
if (d !== void 0 && (l.sortable = d), p !== void 0 && (l.filterable = p), C !== void 0 && (l.selectable = C), z) {
|
|
646
|
-
const y = s?.icons || o?.icons || {};
|
|
647
|
-
l.icons = { ...z, ...y };
|
|
648
|
-
}
|
|
649
|
-
if (M.length > 0 && s) {
|
|
650
|
-
const y = s.plugins || [], R = new Set(y.map((L) => L.name)), H = M.filter((L) => !R.has(L.name));
|
|
651
|
-
return {
|
|
652
|
-
...s,
|
|
653
|
-
...l,
|
|
654
|
-
plugins: [...y, ...H]
|
|
655
|
-
};
|
|
656
|
-
}
|
|
657
|
-
return M.length > 0 && !s ? { ...l, plugins: M } : Object.keys(l).length > 0 ? { ...s, ...l } : s;
|
|
658
|
-
}, [o, M, d, p, C, z]);
|
|
659
|
-
w(() => {
|
|
660
|
-
X().setTypeDefaults(te);
|
|
661
|
-
}, [te]), w(() => {
|
|
662
|
-
f.current && (f.current.rows = r);
|
|
663
|
-
}, [r]), w(() => {
|
|
664
|
-
f.current && B && (f.current.gridConfig = B);
|
|
665
|
-
}, [B]), w(() => {
|
|
666
|
-
f.current && O && (f.current.columns = O);
|
|
667
|
-
}, [O]), w(() => {
|
|
668
|
-
f.current && c !== void 0 && (f.current.fitMode = c);
|
|
669
|
-
}, [c]), w(() => {
|
|
670
|
-
f.current && P !== void 0 && (f.current.editOn = P);
|
|
671
|
-
}, [P]), w(() => {
|
|
672
|
-
f.current && x !== void 0 && (f.current.loading = x);
|
|
673
|
-
}, [x]), w(() => {
|
|
674
|
-
const s = f.current;
|
|
675
|
-
if (!s) return;
|
|
676
|
-
const l = X();
|
|
677
|
-
s.__frameworkAdapter = l, We(s), $e(s, l);
|
|
678
|
-
let y = !1;
|
|
679
|
-
const R = requestAnimationFrame(() => {
|
|
680
|
-
y || (typeof s.refreshColumns == "function" && s.refreshColumns(), typeof s.refreshShellHeader == "function" && s.refreshShellHeader());
|
|
681
|
-
});
|
|
682
|
-
return () => {
|
|
683
|
-
y = !0, cancelAnimationFrame(R);
|
|
684
|
-
};
|
|
685
|
-
}, []), w(() => {
|
|
686
|
-
if (!f.current || !A) return;
|
|
687
|
-
const s = f.current, l = "react-custom-styles";
|
|
688
|
-
let y = !0;
|
|
689
|
-
return s.ready?.().then(() => {
|
|
690
|
-
y && A && (s.registerStyles?.(l, A), I.current = l);
|
|
691
|
-
}), () => {
|
|
692
|
-
y = !1, I.current && (s.unregisterStyles?.(I.current), I.current = null);
|
|
693
|
-
};
|
|
694
|
-
}, [A]), w(() => {
|
|
695
|
-
const s = f.current;
|
|
696
|
-
if (!s) return;
|
|
697
|
-
const l = [];
|
|
698
|
-
if (m) {
|
|
699
|
-
const y = ((R) => m(R.detail.rows));
|
|
700
|
-
s.addEventListener("rows-change", y), l.push(["rows-change", y]);
|
|
701
|
-
}
|
|
702
|
-
return () => {
|
|
703
|
-
l.forEach(([y, R]) => {
|
|
704
|
-
s.removeEventListener(y, R);
|
|
705
|
-
});
|
|
706
|
-
};
|
|
707
|
-
}, [m]);
|
|
708
|
-
const se = D(() => Object.keys(W).filter((s) => typeof h[s] == "function").sort().join("|"), [h]), ce = G({});
|
|
709
|
-
for (const s of Object.keys(W))
|
|
710
|
-
ce.current[s] = h[s];
|
|
711
|
-
return w(() => {
|
|
712
|
-
const s = f.current;
|
|
713
|
-
if (!s) return;
|
|
714
|
-
const l = [];
|
|
715
|
-
for (const [y, R] of Object.entries(W))
|
|
716
|
-
if (se.includes(y)) {
|
|
717
|
-
const H = ((L) => {
|
|
718
|
-
ce.current[y]?.(L.detail, L);
|
|
719
|
-
});
|
|
720
|
-
s.addEventListener(R, H), l.push([R, H]);
|
|
721
|
-
}
|
|
722
|
-
return () => {
|
|
723
|
-
l.forEach(([y, R]) => {
|
|
724
|
-
s.removeEventListener(y, R);
|
|
725
|
-
});
|
|
726
|
-
};
|
|
727
|
-
}, [se]), we(
|
|
728
|
-
e,
|
|
729
|
-
() => ({
|
|
730
|
-
get element() {
|
|
731
|
-
return f.current;
|
|
732
|
-
},
|
|
733
|
-
async getConfig() {
|
|
734
|
-
return f.current?.getConfig?.() ?? {};
|
|
735
|
-
},
|
|
736
|
-
async ready() {
|
|
737
|
-
return f.current?.ready?.();
|
|
738
|
-
},
|
|
739
|
-
async forceLayout() {
|
|
740
|
-
return f.current?.forceLayout?.();
|
|
741
|
-
},
|
|
742
|
-
async toggleGroup(s) {
|
|
743
|
-
return f.current?.toggleGroup?.(s);
|
|
744
|
-
},
|
|
745
|
-
registerStyles(s, l) {
|
|
746
|
-
f.current?.registerStyles?.(s, l);
|
|
747
|
-
},
|
|
748
|
-
unregisterStyles(s) {
|
|
749
|
-
f.current?.unregisterStyles?.(s);
|
|
750
|
-
},
|
|
751
|
-
setRowLoading(s, l) {
|
|
752
|
-
f.current?.setRowLoading?.(s, l);
|
|
753
|
-
},
|
|
754
|
-
setCellLoading(s, l, y) {
|
|
755
|
-
f.current?.setCellLoading?.(s, l, y);
|
|
756
|
-
},
|
|
757
|
-
isRowLoading(s) {
|
|
758
|
-
return f.current?.isRowLoading?.(s) ?? !1;
|
|
759
|
-
},
|
|
760
|
-
isCellLoading(s, l) {
|
|
761
|
-
return f.current?.isCellLoading?.(s, l) ?? !1;
|
|
762
|
-
},
|
|
763
|
-
clearAllLoading() {
|
|
764
|
-
f.current?.clearAllLoading?.();
|
|
765
|
-
}
|
|
766
|
-
}),
|
|
767
|
-
[]
|
|
768
|
-
), /* @__PURE__ */ E(
|
|
769
|
-
"tbw-grid",
|
|
770
|
-
{
|
|
771
|
-
ref: (s) => {
|
|
772
|
-
if (f.current = s, s) {
|
|
773
|
-
const l = s;
|
|
774
|
-
B && (l.gridConfig = B), r && (l.rows = r), O && (l.columns = O);
|
|
775
|
-
}
|
|
776
|
-
},
|
|
777
|
-
class: k,
|
|
778
|
-
style: F,
|
|
779
|
-
children: T
|
|
780
|
-
}
|
|
781
|
-
);
|
|
782
|
-
});
|
|
783
|
-
function it(n) {
|
|
784
|
-
const {
|
|
785
|
-
field: t,
|
|
786
|
-
header: e,
|
|
787
|
-
type: r,
|
|
788
|
-
editable: o,
|
|
789
|
-
sortable: a,
|
|
790
|
-
resizable: i,
|
|
791
|
-
width: c,
|
|
792
|
-
minWidth: d,
|
|
793
|
-
hidden: p,
|
|
794
|
-
lockVisible: C,
|
|
795
|
-
children: x,
|
|
796
|
-
editor: P,
|
|
797
|
-
options: A,
|
|
798
|
-
multi: k,
|
|
799
|
-
format: F
|
|
800
|
-
} = n, T = G(null), u = v(
|
|
801
|
-
(h) => {
|
|
802
|
-
T.current = h, h && (x && Me(h, x), P && Oe(h, P));
|
|
7
|
+
field: s,
|
|
8
|
+
header: l,
|
|
9
|
+
type: o,
|
|
10
|
+
editable: f,
|
|
11
|
+
sortable: u,
|
|
12
|
+
resizable: a,
|
|
13
|
+
width: d,
|
|
14
|
+
minWidth: g,
|
|
15
|
+
hidden: v,
|
|
16
|
+
lockVisible: y,
|
|
17
|
+
children: m,
|
|
18
|
+
editor: p,
|
|
19
|
+
options: G,
|
|
20
|
+
multi: h,
|
|
21
|
+
format: x
|
|
22
|
+
} = n, b = R(null), e = i(
|
|
23
|
+
(c) => {
|
|
24
|
+
b.current = c, c && (m && T(c, m), p && B(c, p));
|
|
803
25
|
},
|
|
804
|
-
[
|
|
805
|
-
),
|
|
806
|
-
field:
|
|
807
|
-
ref:
|
|
26
|
+
[m, p, s]
|
|
27
|
+
), t = typeof d == "number" ? `${d}px` : d, r = {
|
|
28
|
+
field: s,
|
|
29
|
+
ref: e
|
|
808
30
|
};
|
|
809
|
-
return
|
|
31
|
+
return l !== void 0 && (r.header = l), o !== void 0 && (r.type = o), f !== void 0 && (r.editable = f), u !== void 0 && (r.sortable = u), a !== void 0 && (r.resizable = a), t !== void 0 && (r.width = t), g !== void 0 && (r["min-width"] = g), v !== void 0 && (r.hidden = v), y !== void 0 && (r["lock-visible"] = y), h !== void 0 && (r.multi = h), x && (r["data-has-format"] = "true"), G && (r["data-has-options"] = "true"), /* @__PURE__ */ w("tbw-grid-column", { ...r });
|
|
810
32
|
}
|
|
811
|
-
function
|
|
812
|
-
return /* @__PURE__ */
|
|
33
|
+
function V({ children: n }) {
|
|
34
|
+
return /* @__PURE__ */ w("tbw-grid-tool-buttons", { children: n });
|
|
813
35
|
}
|
|
814
|
-
const
|
|
815
|
-
let
|
|
816
|
-
return
|
|
36
|
+
const j = ({ icons: n, defaults: s, children: l }) => {
|
|
37
|
+
let o = l;
|
|
38
|
+
return s && (o = /* @__PURE__ */ w(k, { defaults: s, children: o })), n && (o = /* @__PURE__ */ w(A, { icons: n, children: o })), /* @__PURE__ */ w(I, { children: o });
|
|
817
39
|
};
|
|
818
|
-
function
|
|
819
|
-
const n =
|
|
820
|
-
|
|
821
|
-
const
|
|
822
|
-
if (!
|
|
823
|
-
let
|
|
40
|
+
function z() {
|
|
41
|
+
const n = R(null), [s, l] = P(!1), [o, f] = P(null);
|
|
42
|
+
S(() => {
|
|
43
|
+
const e = n.current;
|
|
44
|
+
if (!e) return;
|
|
45
|
+
let t = !0;
|
|
824
46
|
return (async () => {
|
|
825
47
|
try {
|
|
826
|
-
if (await
|
|
827
|
-
|
|
828
|
-
const
|
|
829
|
-
|
|
48
|
+
if (await e.ready?.(), t) {
|
|
49
|
+
l(!0);
|
|
50
|
+
const c = await e.getConfig?.();
|
|
51
|
+
t && c && f(c);
|
|
830
52
|
}
|
|
831
53
|
} catch {
|
|
832
54
|
}
|
|
833
55
|
})(), () => {
|
|
834
|
-
|
|
56
|
+
t = !1;
|
|
835
57
|
};
|
|
836
58
|
}, []);
|
|
837
|
-
const
|
|
838
|
-
const
|
|
839
|
-
return
|
|
840
|
-
}, []),
|
|
841
|
-
const
|
|
842
|
-
|
|
843
|
-
}, []),
|
|
844
|
-
const
|
|
845
|
-
|
|
846
|
-
}, []),
|
|
847
|
-
n.current?.registerStyles?.(
|
|
848
|
-
}, []),
|
|
849
|
-
n.current?.unregisterStyles?.(
|
|
850
|
-
}, []),
|
|
851
|
-
const
|
|
852
|
-
if (!
|
|
59
|
+
const u = i(async () => {
|
|
60
|
+
const e = n.current;
|
|
61
|
+
return e ? await e.getConfig?.() ?? null : null;
|
|
62
|
+
}, []), a = i(async () => {
|
|
63
|
+
const e = n.current;
|
|
64
|
+
e && await e.forceLayout?.();
|
|
65
|
+
}, []), d = i(async (e) => {
|
|
66
|
+
const t = n.current;
|
|
67
|
+
t && await t.toggleGroup?.(e);
|
|
68
|
+
}, []), g = i((e, t) => {
|
|
69
|
+
n.current?.registerStyles?.(e, t);
|
|
70
|
+
}, []), v = i((e) => {
|
|
71
|
+
n.current?.unregisterStyles?.(e);
|
|
72
|
+
}, []), y = i(() => o?.columns ? o.columns.filter((e) => !e.hidden) : [], [o]), m = i(() => {
|
|
73
|
+
const e = n.current?.element, t = e?.getPluginByName?.("selection");
|
|
74
|
+
if (!t) {
|
|
853
75
|
console.warn("[useGrid] selectAll requires SelectionPlugin");
|
|
854
76
|
return;
|
|
855
77
|
}
|
|
856
|
-
if (
|
|
857
|
-
const
|
|
858
|
-
|
|
859
|
-
}
|
|
860
|
-
}, []),
|
|
861
|
-
const
|
|
862
|
-
|
|
863
|
-
}, []),
|
|
864
|
-
const
|
|
865
|
-
return
|
|
866
|
-
}, []),
|
|
867
|
-
const
|
|
868
|
-
if (!
|
|
869
|
-
const
|
|
870
|
-
return
|
|
871
|
-
}, []),
|
|
872
|
-
const
|
|
873
|
-
if (!
|
|
78
|
+
if (t.config?.mode === "row") {
|
|
79
|
+
const r = e?.rows ?? [], c = new Set(r.map((E, C) => C));
|
|
80
|
+
t.selected = c, t.requestAfterRender?.();
|
|
81
|
+
}
|
|
82
|
+
}, []), p = i(() => {
|
|
83
|
+
const t = n.current?.element?.getPluginByName?.("selection");
|
|
84
|
+
t && t.clearSelection?.();
|
|
85
|
+
}, []), G = i(() => {
|
|
86
|
+
const t = n.current?.element?.getPluginByName?.("selection");
|
|
87
|
+
return t ? new Set(t.selected ?? []) : /* @__PURE__ */ new Set();
|
|
88
|
+
}, []), h = i(() => {
|
|
89
|
+
const e = n.current?.element, t = e?.getPluginByName?.("selection");
|
|
90
|
+
if (!t) return [];
|
|
91
|
+
const r = e?.rows ?? [], c = t.selected ?? /* @__PURE__ */ new Set();
|
|
92
|
+
return r.filter((E, C) => c.has(C));
|
|
93
|
+
}, []), x = i((e) => {
|
|
94
|
+
const r = n.current?.element?.getPluginByName?.("export");
|
|
95
|
+
if (!r) {
|
|
874
96
|
console.warn("[useGrid] exportToCsv requires ExportPlugin (use export prop)");
|
|
875
97
|
return;
|
|
876
98
|
}
|
|
877
|
-
|
|
878
|
-
}, []),
|
|
879
|
-
const
|
|
880
|
-
if (!
|
|
99
|
+
r.exportCsv?.({ filename: e ?? "export.csv" });
|
|
100
|
+
}, []), b = i((e) => {
|
|
101
|
+
const r = n.current?.element?.getPluginByName?.("export");
|
|
102
|
+
if (!r) {
|
|
881
103
|
console.warn("[useGrid] exportToJson requires ExportPlugin (use export prop)");
|
|
882
104
|
return;
|
|
883
105
|
}
|
|
884
|
-
|
|
106
|
+
r.exportJson?.({ filename: e ?? "export.json" });
|
|
885
107
|
}, []);
|
|
886
108
|
return {
|
|
887
109
|
ref: n,
|
|
888
110
|
element: n.current?.element ?? null,
|
|
889
|
-
isReady:
|
|
890
|
-
config:
|
|
891
|
-
getConfig:
|
|
892
|
-
forceLayout:
|
|
893
|
-
toggleGroup:
|
|
894
|
-
registerStyles:
|
|
895
|
-
unregisterStyles:
|
|
896
|
-
getVisibleColumns:
|
|
111
|
+
isReady: s,
|
|
112
|
+
config: o,
|
|
113
|
+
getConfig: u,
|
|
114
|
+
forceLayout: a,
|
|
115
|
+
toggleGroup: d,
|
|
116
|
+
registerStyles: g,
|
|
117
|
+
unregisterStyles: v,
|
|
118
|
+
getVisibleColumns: y,
|
|
897
119
|
// Selection methods
|
|
898
|
-
selectAll:
|
|
899
|
-
clearSelection:
|
|
900
|
-
getSelectedIndices:
|
|
901
|
-
getSelectedRows:
|
|
120
|
+
selectAll: m,
|
|
121
|
+
clearSelection: p,
|
|
122
|
+
getSelectedIndices: G,
|
|
123
|
+
getSelectedRows: h,
|
|
902
124
|
// Export methods
|
|
903
|
-
exportToCsv:
|
|
904
|
-
exportToJson:
|
|
125
|
+
exportToCsv: x,
|
|
126
|
+
exportToJson: b
|
|
905
127
|
};
|
|
906
128
|
}
|
|
907
|
-
let
|
|
908
|
-
function
|
|
909
|
-
!
|
|
129
|
+
let D = !1;
|
|
130
|
+
function W(n, s, l, o = []) {
|
|
131
|
+
!D && typeof window < "u" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes(".local")) && (D = !0, console.warn(
|
|
910
132
|
`[useGridEvent] Deprecated: Use event props directly on DataGrid instead.
|
|
911
133
|
Example: <DataGrid onSelectionChange={(e) => ...} />
|
|
912
134
|
See migration guide: https://toolbox-web.dev/grid-react/migration`
|
|
913
135
|
));
|
|
914
|
-
const
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
}, [
|
|
918
|
-
const
|
|
919
|
-
if (!
|
|
920
|
-
const
|
|
921
|
-
|
|
136
|
+
const f = R(l);
|
|
137
|
+
S(() => {
|
|
138
|
+
f.current = l;
|
|
139
|
+
}, [l, ...o]), S(() => {
|
|
140
|
+
const u = n.current, a = u && "element" in u ? u.element : u;
|
|
141
|
+
if (!a) return;
|
|
142
|
+
const d = ((g) => {
|
|
143
|
+
f.current(g);
|
|
922
144
|
});
|
|
923
|
-
return
|
|
924
|
-
|
|
145
|
+
return a.addEventListener(s, d), () => {
|
|
146
|
+
a.removeEventListener(s, d);
|
|
925
147
|
};
|
|
926
|
-
}, [n,
|
|
148
|
+
}, [n, s]);
|
|
927
149
|
}
|
|
928
150
|
export {
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
151
|
+
H as DataGrid,
|
|
152
|
+
U as GridAdapter,
|
|
153
|
+
J as GridColumn,
|
|
154
|
+
$ as GridDetailPanel,
|
|
155
|
+
A as GridIconProvider,
|
|
156
|
+
j as GridProvider,
|
|
157
|
+
K as GridResponsiveCard,
|
|
158
|
+
V as GridToolButtons,
|
|
159
|
+
M as GridToolPanel,
|
|
160
|
+
k as GridTypeProvider,
|
|
161
|
+
O as ReactGridAdapter,
|
|
162
|
+
z as useGrid,
|
|
163
|
+
W as useGridEvent,
|
|
164
|
+
Q as useGridIcons,
|
|
165
|
+
X as useGridTypeDefaults,
|
|
166
|
+
Y as useTypeDefault
|
|
944
167
|
};
|