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