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