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