@toolbox-web/grid-react 0.18.4 → 1.0.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/features/index.d.ts.map +1 -1
- package/features/index.js +2 -0
- package/index.d.ts +3 -12
- package/index.d.ts.map +1 -1
- package/index.js +398 -479
- package/lib/data-grid.d.ts +0 -2
- package/lib/data-grid.d.ts.map +1 -1
- package/lib/feature-props.d.ts +0 -16
- package/lib/feature-props.d.ts.map +1 -1
- package/lib/grid-type-registry.d.ts +0 -10
- package/lib/grid-type-registry.d.ts.map +1 -1
- package/lib/react-column-config.d.ts +0 -15
- package/lib/react-column-config.d.ts.map +1 -1
- package/lib/react-grid-adapter.d.ts +0 -5
- package/lib/react-grid-adapter.d.ts.map +1 -1
- package/lib/use-grid.d.ts +1 -82
- package/lib/use-grid.d.ts.map +1 -1
- package/package.json +1 -1
- package/features/reorder.d.ts +0 -6
- package/features/reorder.d.ts.map +0 -1
- package/features/reorder.js +0 -1
- package/features/row-reorder.d.ts +0 -6
- package/features/row-reorder.d.ts.map +0 -1
- package/features/row-reorder.js +0 -1
- package/features/sorting.d.ts +0 -1
- package/features/sorting.d.ts.map +0 -1
- package/features/sorting.js +0 -1
- package/lib/use-grid-event.d.ts +0 -77
- package/lib/use-grid-event.d.ts.map +0 -1
package/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { DataGridElement as
|
|
3
|
-
import { createContext as
|
|
1
|
+
import { jsx as b, Fragment as ye } from "react/jsx-runtime";
|
|
2
|
+
import { DataGridElement as he } from "@toolbox-web/grid";
|
|
3
|
+
import { createContext as fe, useContext as O, useRef as x, useCallback as P, useEffect as C, forwardRef as Re, useMemo as G, useImperativeHandle as we, Children as Ce, isValidElement as ve, useState as de } from "react";
|
|
4
4
|
import { flushSync as R } from "react-dom";
|
|
5
|
-
import { createRoot as
|
|
6
|
-
import { createPluginsFromFeatures as
|
|
7
|
-
import { G as
|
|
8
|
-
function
|
|
5
|
+
import { createRoot as v } from "react-dom/client";
|
|
6
|
+
import { createPluginsFromFeatures as be } from "@toolbox-web/grid/features/registry";
|
|
7
|
+
import { G as Ee } from "./chunks/grid-element-context-BU3WvNtM.js";
|
|
8
|
+
function Pe(n) {
|
|
9
9
|
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
10
10
|
}
|
|
11
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(
|
|
12
|
+
return n.toLowerCase() === "id" ? "ID" : n.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").split(" ").filter(Boolean).map(Pe).join(" ");
|
|
13
13
|
}
|
|
14
|
-
const
|
|
15
|
-
function
|
|
14
|
+
const Se = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime", "currency"]);
|
|
15
|
+
function De(n) {
|
|
16
16
|
const t = n.lastIndexOf(":");
|
|
17
17
|
if (t > 0) {
|
|
18
18
|
const e = n.slice(t + 1).toLowerCase();
|
|
19
|
-
if (
|
|
19
|
+
if (Se.has(e)) {
|
|
20
20
|
const r = n.slice(0, t);
|
|
21
21
|
return {
|
|
22
22
|
field: r,
|
|
@@ -30,10 +30,10 @@ function Ae(n) {
|
|
|
30
30
|
header: ue(n)
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
return n.map((t) => typeof t == "string" ?
|
|
33
|
+
function Ge(n) {
|
|
34
|
+
return n.map((t) => typeof t == "string" ? De(t) : t);
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const W = {
|
|
37
37
|
onCellClick: "cell-click",
|
|
38
38
|
onRowClick: "row-click",
|
|
39
39
|
onCellActivate: "cell-activate",
|
|
@@ -59,191 +59,191 @@ const U = {
|
|
|
59
59
|
onExportComplete: "export-complete",
|
|
60
60
|
onPrintStart: "print-start",
|
|
61
61
|
onPrintComplete: "print-complete"
|
|
62
|
-
},
|
|
63
|
-
function
|
|
64
|
-
return
|
|
62
|
+
}, te = fe(null), xe = ({ icons: n, children: t }) => /* @__PURE__ */ b(te.Provider, { value: n, children: t });
|
|
63
|
+
function st() {
|
|
64
|
+
return O(te);
|
|
65
65
|
}
|
|
66
|
-
const
|
|
67
|
-
function
|
|
66
|
+
const Ae = te, U = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new Map();
|
|
67
|
+
function ge(n) {
|
|
68
68
|
const t = n.querySelector("tbw-grid-responsive-card");
|
|
69
69
|
if (t) {
|
|
70
|
-
const r =
|
|
70
|
+
const r = U.get(t);
|
|
71
71
|
if (r) return r;
|
|
72
72
|
}
|
|
73
73
|
const e = n.id || n.getAttribute("data-grid-id");
|
|
74
74
|
if (e)
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
function
|
|
78
|
-
const { children: t, cardRowHeight: e = "auto" } = n, r =
|
|
79
|
-
(
|
|
80
|
-
if (r.current =
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
const
|
|
85
|
-
|
|
75
|
+
return J.get(e);
|
|
76
|
+
}
|
|
77
|
+
function Ve(n) {
|
|
78
|
+
const { children: t, cardRowHeight: e = "auto" } = n, r = x(null), o = P(
|
|
79
|
+
(c) => {
|
|
80
|
+
if (r.current = c, !c) return;
|
|
81
|
+
U.set(c, t);
|
|
82
|
+
const s = c.closest("tbw-grid");
|
|
83
|
+
if (s) {
|
|
84
|
+
const u = s.id || s.getAttribute("data-grid-id");
|
|
85
|
+
u && J.set(u, t);
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
[t]
|
|
89
89
|
);
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
const
|
|
97
|
-
|
|
90
|
+
C(() => () => {
|
|
91
|
+
const c = r.current;
|
|
92
|
+
if (c) {
|
|
93
|
+
U.delete(c);
|
|
94
|
+
const s = c.closest("tbw-grid");
|
|
95
|
+
if (s) {
|
|
96
|
+
const u = s.id || s.getAttribute("data-grid-id");
|
|
97
|
+
u && J.delete(u);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
}, []);
|
|
101
101
|
const a = e === "auto" ? "auto" : String(e);
|
|
102
|
-
return /* @__PURE__ */
|
|
102
|
+
return /* @__PURE__ */ b("tbw-grid-responsive-card", { ref: o, cardRowHeight: a });
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
function
|
|
107
|
-
return z
|
|
104
|
+
Ve.displayName = "GridResponsiveCard";
|
|
105
|
+
const z = fe(null), Ie = ({ defaults: n, children: t }) => /* @__PURE__ */ b(z.Provider, { value: n, children: t });
|
|
106
|
+
function ct() {
|
|
107
|
+
return O(z);
|
|
108
108
|
}
|
|
109
|
-
function
|
|
110
|
-
return z
|
|
109
|
+
function at(n) {
|
|
110
|
+
return O(z)?.[n];
|
|
111
111
|
}
|
|
112
|
-
const
|
|
113
|
-
function
|
|
114
|
-
for (let t =
|
|
115
|
-
const e =
|
|
112
|
+
const Ne = z, B = /* @__PURE__ */ Symbol("reactProcessed"), A = [];
|
|
113
|
+
function Le(n) {
|
|
114
|
+
for (let t = A.length - 1; t >= 0; t--) {
|
|
115
|
+
const e = A[t];
|
|
116
116
|
if (n.contains(e.container) && e.container.classList.contains("react-cell-editor")) {
|
|
117
117
|
try {
|
|
118
118
|
e.root.unmount();
|
|
119
119
|
} catch {
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
A.splice(t, 1);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function ke(n) {
|
|
126
126
|
const t = /* @__PURE__ */ new WeakMap();
|
|
127
127
|
return (e) => {
|
|
128
128
|
const r = e.cellEl;
|
|
129
129
|
if (r) {
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
130
|
+
const c = t.get(r);
|
|
131
|
+
if (c)
|
|
132
132
|
return R(() => {
|
|
133
|
-
|
|
134
|
-
}),
|
|
133
|
+
c.root.render(n(e));
|
|
134
|
+
}), c.container;
|
|
135
135
|
}
|
|
136
136
|
const o = document.createElement("div");
|
|
137
137
|
o.className = "react-cell-renderer", o.style.display = "contents";
|
|
138
|
-
const a =
|
|
138
|
+
const a = v(o);
|
|
139
139
|
return R(() => {
|
|
140
140
|
a.render(n(e));
|
|
141
|
-
}), r && t.set(r, { root: a, container: o }),
|
|
141
|
+
}), r && t.set(r, { root: a, container: o }), A.push({ root: a, container: o }), o;
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function Te(n) {
|
|
145
145
|
return (t) => {
|
|
146
146
|
const e = document.createElement("div");
|
|
147
147
|
e.className = "react-cell-editor", e.style.display = "contents";
|
|
148
|
-
const r =
|
|
148
|
+
const r = v(e);
|
|
149
149
|
return R(() => {
|
|
150
150
|
r.render(n(t));
|
|
151
|
-
}),
|
|
151
|
+
}), A.push({ root: r, container: e }), e;
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function Fe(n) {
|
|
155
155
|
return (t) => {
|
|
156
156
|
const e = document.createElement("div");
|
|
157
157
|
e.className = "react-header-renderer", e.style.display = "contents";
|
|
158
|
-
const r =
|
|
158
|
+
const r = v(e);
|
|
159
159
|
return R(() => {
|
|
160
160
|
r.render(n(t));
|
|
161
|
-
}),
|
|
161
|
+
}), A.push({ root: r, container: e }), e;
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function Me(n) {
|
|
165
165
|
return (t) => {
|
|
166
166
|
const e = document.createElement("div");
|
|
167
167
|
e.className = "react-header-label-renderer", e.style.display = "contents";
|
|
168
|
-
const r =
|
|
168
|
+
const r = v(e);
|
|
169
169
|
return R(() => {
|
|
170
170
|
r.render(n(t));
|
|
171
|
-
}),
|
|
171
|
+
}), A.push({ root: r, container: e }), e;
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
|
-
function
|
|
174
|
+
function He(n) {
|
|
175
175
|
return (t) => {
|
|
176
176
|
const e = n(t);
|
|
177
177
|
if (e instanceof HTMLElement || typeof e == "string")
|
|
178
178
|
return e;
|
|
179
179
|
const r = document.createElement("div");
|
|
180
180
|
r.className = "react-loading-renderer", r.style.display = "contents";
|
|
181
|
-
const o =
|
|
181
|
+
const o = v(r);
|
|
182
182
|
return R(() => {
|
|
183
183
|
o.render(e);
|
|
184
|
-
}),
|
|
184
|
+
}), A.push({ root: o, container: r }), r;
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function pe(n) {
|
|
188
188
|
if (!n) return;
|
|
189
|
-
if (n[
|
|
189
|
+
if (n[B]) return n;
|
|
190
190
|
if (n.loadingRenderer && typeof n.loadingRenderer == "function") {
|
|
191
191
|
const r = n.loadingRenderer;
|
|
192
192
|
n = {
|
|
193
193
|
...n,
|
|
194
|
-
loadingRenderer:
|
|
194
|
+
loadingRenderer: He(r)
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
197
|
if (!n.columns) {
|
|
198
198
|
const r = n;
|
|
199
|
-
return r[
|
|
199
|
+
return r[B] = !0, r;
|
|
200
200
|
}
|
|
201
201
|
const t = n.columns.map((r) => {
|
|
202
|
-
const { renderer: o, editor: a, headerRenderer:
|
|
203
|
-
return o && (
|
|
202
|
+
const { renderer: o, editor: a, headerRenderer: c, headerLabelRenderer: s, ...u } = r, l = { ...u };
|
|
203
|
+
return o && (l.renderer = ke(o)), a && (l.editor = Te(a)), c && (l.headerRenderer = Fe(c)), s && (l.headerLabelRenderer = Me(s)), l;
|
|
204
204
|
}), e = {
|
|
205
205
|
...n,
|
|
206
206
|
columns: t
|
|
207
207
|
};
|
|
208
|
-
return e[
|
|
208
|
+
return e[B] = !0, e;
|
|
209
209
|
}
|
|
210
|
-
const
|
|
211
|
-
function
|
|
210
|
+
const Y = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new Map();
|
|
211
|
+
function Oe(n) {
|
|
212
212
|
const t = n.querySelector("tbw-grid-detail");
|
|
213
213
|
if (t) {
|
|
214
|
-
const r =
|
|
214
|
+
const r = Y.get(t);
|
|
215
215
|
if (r) return r;
|
|
216
216
|
}
|
|
217
217
|
const e = n.id || n.getAttribute("data-grid-id");
|
|
218
218
|
if (e)
|
|
219
|
-
return
|
|
219
|
+
return Z.get(e);
|
|
220
220
|
}
|
|
221
|
-
function
|
|
222
|
-
const { children: t, showExpandColumn: e = !0, animation: r = "slide" } = n, o =
|
|
223
|
-
(
|
|
224
|
-
if (o.current =
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
if (
|
|
228
|
-
const
|
|
229
|
-
|
|
221
|
+
function je(n) {
|
|
222
|
+
const { children: t, showExpandColumn: e = !0, animation: r = "slide" } = n, o = x(null), a = P(
|
|
223
|
+
(s) => {
|
|
224
|
+
if (o.current = s, !s) return;
|
|
225
|
+
Y.set(s, t);
|
|
226
|
+
const u = s.closest("tbw-grid");
|
|
227
|
+
if (u) {
|
|
228
|
+
const l = u.id || u.getAttribute("data-grid-id");
|
|
229
|
+
l && Z.set(l, t);
|
|
230
230
|
}
|
|
231
231
|
},
|
|
232
232
|
[t]
|
|
233
233
|
);
|
|
234
|
-
return
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
|
|
238
|
-
const
|
|
239
|
-
if (
|
|
240
|
-
const
|
|
241
|
-
|
|
234
|
+
return C(() => () => {
|
|
235
|
+
const s = o.current;
|
|
236
|
+
if (s) {
|
|
237
|
+
Y.delete(s);
|
|
238
|
+
const u = s.closest("tbw-grid");
|
|
239
|
+
if (u) {
|
|
240
|
+
const w = u.id || u.getAttribute("data-grid-id");
|
|
241
|
+
w && Z.delete(w);
|
|
242
242
|
}
|
|
243
|
-
const
|
|
244
|
-
|
|
243
|
+
const l = s.parentNode;
|
|
244
|
+
l && l.contains(s);
|
|
245
245
|
}
|
|
246
|
-
}, []), /* @__PURE__ */
|
|
246
|
+
}, []), /* @__PURE__ */ b(
|
|
247
247
|
"tbw-grid-detail",
|
|
248
248
|
{
|
|
249
249
|
ref: a,
|
|
@@ -252,29 +252,29 @@ function _e(n) {
|
|
|
252
252
|
}
|
|
253
253
|
);
|
|
254
254
|
}
|
|
255
|
-
|
|
256
|
-
const
|
|
255
|
+
je.displayName = "GridDetailPanel";
|
|
256
|
+
const Q = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new Map();
|
|
257
257
|
function ze(n) {
|
|
258
|
-
const t =
|
|
258
|
+
const t = Q.get(n);
|
|
259
259
|
if (t) return t;
|
|
260
260
|
const e = n.id;
|
|
261
261
|
if (e)
|
|
262
|
-
return
|
|
262
|
+
return X.get(e);
|
|
263
263
|
}
|
|
264
|
-
function
|
|
265
|
-
const { id: t, title: e, icon: r, tooltip: o, order: a = 100, children:
|
|
266
|
-
(
|
|
267
|
-
|
|
264
|
+
function dt(n) {
|
|
265
|
+
const { id: t, title: e, icon: r, tooltip: o, order: a = 100, children: c } = n, s = x(null), u = P(
|
|
266
|
+
(l) => {
|
|
267
|
+
s.current = l, l && (Q.set(l, c), t && X.set(t, c));
|
|
268
268
|
},
|
|
269
|
-
[
|
|
269
|
+
[c, t]
|
|
270
270
|
);
|
|
271
|
-
return
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
}, [t]), /* @__PURE__ */
|
|
271
|
+
return C(() => () => {
|
|
272
|
+
const l = s.current;
|
|
273
|
+
l && (Q.delete(l), t && X.delete(t));
|
|
274
|
+
}, [t]), /* @__PURE__ */ b(
|
|
275
275
|
"tbw-grid-tool-panel",
|
|
276
276
|
{
|
|
277
|
-
ref:
|
|
277
|
+
ref: u,
|
|
278
278
|
id: t,
|
|
279
279
|
title: e,
|
|
280
280
|
icon: r,
|
|
@@ -283,38 +283,38 @@ function ut(n) {
|
|
|
283
283
|
}
|
|
284
284
|
);
|
|
285
285
|
}
|
|
286
|
-
const V = /* @__PURE__ */ new WeakMap(),
|
|
286
|
+
const V = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new Map();
|
|
287
287
|
function $e(n, t) {
|
|
288
288
|
const e = n.getAttribute("field"), r = V.get(n) ?? {};
|
|
289
289
|
if (r.renderer = t, V.set(n, r), e) {
|
|
290
|
-
const o =
|
|
291
|
-
o.renderer = t,
|
|
290
|
+
const o = I.get(e) ?? {};
|
|
291
|
+
o.renderer = t, I.set(e, o);
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
|
-
function
|
|
294
|
+
function _e(n, t) {
|
|
295
295
|
const e = n.getAttribute("field"), r = V.get(n) ?? {};
|
|
296
296
|
if (r.editor = t, V.set(n, r), e) {
|
|
297
|
-
const o =
|
|
298
|
-
o.editor = t,
|
|
297
|
+
const o = I.get(e) ?? {};
|
|
298
|
+
o.editor = t, I.set(e, o);
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
|
-
function
|
|
301
|
+
function qe(n) {
|
|
302
302
|
let t = V.get(n)?.renderer;
|
|
303
303
|
if (!t) {
|
|
304
304
|
const e = n.getAttribute("field");
|
|
305
|
-
e && (t =
|
|
305
|
+
e && (t = I.get(e)?.renderer);
|
|
306
306
|
}
|
|
307
307
|
return t;
|
|
308
308
|
}
|
|
309
|
-
function
|
|
309
|
+
function We(n) {
|
|
310
310
|
let t = V.get(n)?.editor;
|
|
311
311
|
if (!t) {
|
|
312
312
|
const e = n.getAttribute("field");
|
|
313
|
-
e && (t =
|
|
313
|
+
e && (t = I.get(e)?.editor);
|
|
314
314
|
}
|
|
315
315
|
return t;
|
|
316
316
|
}
|
|
317
|
-
class
|
|
317
|
+
class Be {
|
|
318
318
|
mountedViews = [];
|
|
319
319
|
/** Editor-specific views tracked separately for per-cell cleanup via releaseCell. */
|
|
320
320
|
editorViews = [];
|
|
@@ -334,7 +334,7 @@ class he {
|
|
|
334
334
|
* Converts React renderer/editor functions to DOM-returning functions.
|
|
335
335
|
*/
|
|
336
336
|
processConfig(t) {
|
|
337
|
-
return
|
|
337
|
+
return pe(t) ?? t;
|
|
338
338
|
}
|
|
339
339
|
/**
|
|
340
340
|
* Determines if this adapter can handle the given element.
|
|
@@ -344,8 +344,8 @@ class he {
|
|
|
344
344
|
const e = t.getAttribute("field");
|
|
345
345
|
let r = V.get(t);
|
|
346
346
|
if (!r && e) {
|
|
347
|
-
const
|
|
348
|
-
|
|
347
|
+
const c = I.get(e);
|
|
348
|
+
c && (c.renderer || c.editor) && (r = c, V.set(t, r));
|
|
349
349
|
}
|
|
350
350
|
const o = r?.renderer !== void 0, a = r?.editor !== void 0;
|
|
351
351
|
return r !== void 0 && (o || a);
|
|
@@ -362,31 +362,31 @@ class he {
|
|
|
362
362
|
* allowing the grid to use its default rendering.
|
|
363
363
|
*/
|
|
364
364
|
createRenderer(t) {
|
|
365
|
-
const e =
|
|
365
|
+
const e = qe(t);
|
|
366
366
|
if (!e)
|
|
367
367
|
return;
|
|
368
368
|
const r = /* @__PURE__ */ new WeakMap();
|
|
369
369
|
return (o) => {
|
|
370
370
|
const a = o.cellEl;
|
|
371
371
|
if (a) {
|
|
372
|
-
const
|
|
373
|
-
if (
|
|
372
|
+
const u = r.get(a);
|
|
373
|
+
if (u)
|
|
374
374
|
return R(() => {
|
|
375
|
-
|
|
376
|
-
}),
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
const
|
|
375
|
+
u.root.render(e(o));
|
|
376
|
+
}), u.container;
|
|
377
|
+
const l = document.createElement("div");
|
|
378
|
+
l.className = "react-cell-renderer", l.style.display = "contents";
|
|
379
|
+
const w = v(l);
|
|
380
380
|
return R(() => {
|
|
381
|
-
|
|
382
|
-
}), r.set(a, { root:
|
|
381
|
+
w.render(e(o));
|
|
382
|
+
}), r.set(a, { root: w, container: l, lastRowIndex: o.rowIndex ?? -1 }), this.mountedViews.push({ root: w, container: l }), l;
|
|
383
383
|
}
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
const
|
|
384
|
+
const c = document.createElement("div");
|
|
385
|
+
c.className = "react-cell-renderer", c.style.display = "contents";
|
|
386
|
+
const s = v(c);
|
|
387
387
|
return R(() => {
|
|
388
|
-
|
|
389
|
-
}), this.mountedViews.push({ root:
|
|
388
|
+
s.render(e(o));
|
|
389
|
+
}), this.mountedViews.push({ root: s, container: c }), c;
|
|
390
390
|
};
|
|
391
391
|
}
|
|
392
392
|
/**
|
|
@@ -394,11 +394,11 @@ class he {
|
|
|
394
394
|
* with commit/cancel callbacks passed as props.
|
|
395
395
|
*/
|
|
396
396
|
createEditor(t) {
|
|
397
|
-
const e =
|
|
397
|
+
const e = We(t);
|
|
398
398
|
return e ? (r) => {
|
|
399
399
|
const o = document.createElement("div");
|
|
400
400
|
o.className = "react-cell-editor", o.style.display = "contents";
|
|
401
|
-
const a =
|
|
401
|
+
const a = v(o);
|
|
402
402
|
return R(() => {
|
|
403
403
|
a.render(e(r));
|
|
404
404
|
}), this.editorViews.push({ root: a, container: o }), o;
|
|
@@ -409,15 +409,15 @@ class he {
|
|
|
409
409
|
* Renders React components for expandable detail rows.
|
|
410
410
|
*/
|
|
411
411
|
createDetailRenderer(t) {
|
|
412
|
-
const e =
|
|
412
|
+
const e = Oe(t);
|
|
413
413
|
if (e)
|
|
414
414
|
return (r, o) => {
|
|
415
415
|
const a = document.createElement("div");
|
|
416
416
|
a.className = "react-detail-panel";
|
|
417
|
-
const
|
|
417
|
+
const c = { row: r, rowIndex: o }, s = v(a);
|
|
418
418
|
return R(() => {
|
|
419
|
-
|
|
420
|
-
}), this.mountedViews.push({ root:
|
|
419
|
+
s.render(e(c));
|
|
420
|
+
}), this.mountedViews.push({ root: s, container: a }), a;
|
|
421
421
|
};
|
|
422
422
|
}
|
|
423
423
|
/**
|
|
@@ -434,15 +434,15 @@ class he {
|
|
|
434
434
|
* Renders React components for card layout in responsive mode.
|
|
435
435
|
*/
|
|
436
436
|
createResponsiveCardRenderer(t) {
|
|
437
|
-
const e =
|
|
437
|
+
const e = ge(t);
|
|
438
438
|
if (e)
|
|
439
439
|
return (r, o) => {
|
|
440
440
|
const a = document.createElement("div");
|
|
441
441
|
a.className = "react-responsive-card";
|
|
442
|
-
const
|
|
442
|
+
const c = { row: r, index: o }, s = v(a);
|
|
443
443
|
return R(() => {
|
|
444
|
-
|
|
445
|
-
}), this.mountedViews.push({ root:
|
|
444
|
+
s.render(e(c));
|
|
445
|
+
}), this.mountedViews.push({ root: s, container: a }), a;
|
|
446
446
|
};
|
|
447
447
|
}
|
|
448
448
|
/**
|
|
@@ -457,18 +457,18 @@ class he {
|
|
|
457
457
|
return (o) => {
|
|
458
458
|
const a = {
|
|
459
459
|
grid: r ?? o
|
|
460
|
-
},
|
|
460
|
+
}, c = v(o);
|
|
461
461
|
return R(() => {
|
|
462
|
-
|
|
463
|
-
}), this.mountedViews.push({ root:
|
|
464
|
-
const
|
|
465
|
-
if (
|
|
466
|
-
const { root:
|
|
462
|
+
c.render(e(a));
|
|
463
|
+
}), this.mountedViews.push({ root: c, container: o }), () => {
|
|
464
|
+
const s = this.mountedViews.findIndex((u) => u.container === o);
|
|
465
|
+
if (s !== -1) {
|
|
466
|
+
const { root: u } = this.mountedViews[s];
|
|
467
467
|
try {
|
|
468
|
-
|
|
468
|
+
u.unmount();
|
|
469
469
|
} catch {
|
|
470
470
|
}
|
|
471
|
-
this.mountedViews.splice(
|
|
471
|
+
this.mountedViews.splice(s, 1);
|
|
472
472
|
}
|
|
473
473
|
};
|
|
474
474
|
};
|
|
@@ -516,7 +516,7 @@ class he {
|
|
|
516
516
|
return (e) => {
|
|
517
517
|
const r = document.createElement("span");
|
|
518
518
|
r.style.display = "contents";
|
|
519
|
-
const o =
|
|
519
|
+
const o = v(r);
|
|
520
520
|
return this.mountedViews.push({ root: o, container: r }), R(() => {
|
|
521
521
|
o.render(t(e));
|
|
522
522
|
}), r;
|
|
@@ -530,7 +530,7 @@ class he {
|
|
|
530
530
|
return (e) => {
|
|
531
531
|
const r = document.createElement("span");
|
|
532
532
|
r.style.display = "contents";
|
|
533
|
-
const o =
|
|
533
|
+
const o = v(r);
|
|
534
534
|
return this.editorViews.push({ root: o, container: r }), R(() => {
|
|
535
535
|
o.render(t(e));
|
|
536
536
|
}), r;
|
|
@@ -544,7 +544,7 @@ class he {
|
|
|
544
544
|
return (e, r) => {
|
|
545
545
|
const o = document.createElement("div");
|
|
546
546
|
o.style.display = "contents";
|
|
547
|
-
const a =
|
|
547
|
+
const a = v(o);
|
|
548
548
|
this.mountedViews.push({ root: a, container: o }), R(() => {
|
|
549
549
|
a.render(t(r));
|
|
550
550
|
}), e.appendChild(o);
|
|
@@ -565,7 +565,7 @@ class he {
|
|
|
565
565
|
t.unmount();
|
|
566
566
|
} catch {
|
|
567
567
|
}
|
|
568
|
-
}), this.editorViews = [],
|
|
568
|
+
}), this.editorViews = [], I.clear();
|
|
569
569
|
}
|
|
570
570
|
/**
|
|
571
571
|
* Called when a cell's content is about to be wiped.
|
|
@@ -584,7 +584,7 @@ class he {
|
|
|
584
584
|
this.editorViews.splice(e, 1);
|
|
585
585
|
}
|
|
586
586
|
}
|
|
587
|
-
|
|
587
|
+
Le(t);
|
|
588
588
|
}
|
|
589
589
|
/**
|
|
590
590
|
* Unmount a specific container (called when cell is recycled).
|
|
@@ -601,11 +601,11 @@ class he {
|
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
|
-
const
|
|
604
|
+
const Ke = {
|
|
605
605
|
undoRedo: ["editing"],
|
|
606
606
|
clipboard: ["selection"]
|
|
607
607
|
};
|
|
608
|
-
function
|
|
608
|
+
function Ue(n) {
|
|
609
609
|
const t = new Set(n);
|
|
610
610
|
for (const e of n) {
|
|
611
611
|
const r = Ke[e];
|
|
@@ -616,34 +616,34 @@ function Ye(n) {
|
|
|
616
616
|
);
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
|
-
function
|
|
619
|
+
function Je(n) {
|
|
620
620
|
const t = [];
|
|
621
621
|
for (const [e, r] of Object.entries(n))
|
|
622
622
|
r === void 0 || r === !1 || t.push(e);
|
|
623
|
-
return
|
|
623
|
+
return Ue(t), be(n);
|
|
624
624
|
}
|
|
625
|
-
let
|
|
626
|
-
function
|
|
627
|
-
return
|
|
625
|
+
let le = !1, K = null;
|
|
626
|
+
function ee() {
|
|
627
|
+
return le || (K = new Be(), he.registerAdapter(K), le = !0), K;
|
|
628
628
|
}
|
|
629
|
-
|
|
630
|
-
function
|
|
629
|
+
ee();
|
|
630
|
+
function Ye(n) {
|
|
631
631
|
const e = n.getPluginByName?.("masterDetail");
|
|
632
632
|
e && typeof e.refreshDetailRenderer == "function" && e.refreshDetailRenderer();
|
|
633
633
|
}
|
|
634
|
-
function
|
|
634
|
+
function Ze(n, t) {
|
|
635
635
|
const e = n;
|
|
636
|
-
if (!n.querySelector("tbw-grid-responsive-card") || !
|
|
636
|
+
if (!n.querySelector("tbw-grid-responsive-card") || !ge(n)) return;
|
|
637
637
|
const a = e.getPluginByName?.("responsive");
|
|
638
638
|
if (a && typeof a.setCardRenderer == "function") {
|
|
639
|
-
const
|
|
640
|
-
|
|
639
|
+
const c = t.createResponsiveCardRenderer(n);
|
|
640
|
+
c && a.setCardRenderer(c);
|
|
641
641
|
}
|
|
642
642
|
}
|
|
643
|
-
function
|
|
643
|
+
function Qe(n) {
|
|
644
644
|
const t = {};
|
|
645
|
-
return
|
|
646
|
-
if (
|
|
645
|
+
return Ce.forEach(n, (e) => {
|
|
646
|
+
if (ve(e)) {
|
|
647
647
|
if (e.type && e.type.displayName === "GridDetailPanel") {
|
|
648
648
|
const r = e.props;
|
|
649
649
|
t.masterDetail = {
|
|
@@ -657,45 +657,38 @@ function et(n) {
|
|
|
657
657
|
}
|
|
658
658
|
}), t;
|
|
659
659
|
}
|
|
660
|
-
const
|
|
660
|
+
const ut = Re(function(t, e) {
|
|
661
661
|
const {
|
|
662
662
|
// Core props
|
|
663
663
|
rows: r,
|
|
664
664
|
gridConfig: o,
|
|
665
665
|
columns: a,
|
|
666
|
-
columnDefaults:
|
|
667
|
-
fitMode:
|
|
668
|
-
sortable:
|
|
669
|
-
filterable:
|
|
670
|
-
selectable:
|
|
671
|
-
loading:
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
children: L,
|
|
666
|
+
columnDefaults: c,
|
|
667
|
+
fitMode: s,
|
|
668
|
+
sortable: u,
|
|
669
|
+
filterable: l,
|
|
670
|
+
selectable: w,
|
|
671
|
+
loading: D,
|
|
672
|
+
customStyles: S,
|
|
673
|
+
className: L,
|
|
674
|
+
style: g,
|
|
675
|
+
children: h,
|
|
677
676
|
// Plugin props
|
|
678
|
-
plugins:
|
|
677
|
+
plugins: m,
|
|
679
678
|
// SSR mode
|
|
680
|
-
ssr:
|
|
679
|
+
ssr: E,
|
|
681
680
|
// Legacy event handlers
|
|
682
|
-
onRowsChange:
|
|
681
|
+
onRowsChange: N,
|
|
683
682
|
// Feature props and event props are in ...rest
|
|
684
|
-
...
|
|
685
|
-
} = t,
|
|
683
|
+
...y
|
|
684
|
+
} = t, f = x(null), j = x(null), re = O(Ne), $ = O(Ae), ne = [
|
|
686
685
|
"selection",
|
|
687
686
|
"editing",
|
|
688
687
|
"filtering",
|
|
689
688
|
"multiSort",
|
|
690
|
-
"sorting",
|
|
691
|
-
// deprecated alias for multiSort
|
|
692
689
|
"clipboard",
|
|
693
690
|
"contextMenu",
|
|
694
691
|
"reorderColumns",
|
|
695
|
-
"reorder",
|
|
696
|
-
// deprecated alias for reorderColumns
|
|
697
|
-
"rowReorder",
|
|
698
|
-
// deprecated alias for reorderRows
|
|
699
692
|
"reorderRows",
|
|
700
693
|
"visibility",
|
|
701
694
|
"undoRedo",
|
|
@@ -712,367 +705,293 @@ const gt = Ce(function(t, e) {
|
|
|
712
705
|
"pivot",
|
|
713
706
|
"serverSide",
|
|
714
707
|
"tooltip"
|
|
715
|
-
],
|
|
716
|
-
const
|
|
717
|
-
return
|
|
718
|
-
}).filter(Boolean).join("|"), [
|
|
719
|
-
const
|
|
720
|
-
for (const
|
|
721
|
-
|
|
722
|
-
return
|
|
723
|
-
}, [
|
|
724
|
-
if (
|
|
725
|
-
const
|
|
726
|
-
return [...
|
|
708
|
+
], me = G(() => ne.map((i) => {
|
|
709
|
+
const d = y[i];
|
|
710
|
+
return d !== void 0 ? `${i}:${JSON.stringify(d)}` : "";
|
|
711
|
+
}).filter(Boolean).join("|"), [y]), oe = G(() => {
|
|
712
|
+
const i = {};
|
|
713
|
+
for (const d of ne)
|
|
714
|
+
d in y && y[d] !== void 0 && (i[d] = y[d]);
|
|
715
|
+
return i;
|
|
716
|
+
}, [me]), ie = G(() => Qe(h), [h]), se = G(() => ({ ...ie, ...oe }), [oe, ie]), _ = G(() => m || E ? [] : Je(se), [se, m, E]), k = G(() => {
|
|
717
|
+
if (m) {
|
|
718
|
+
const i = new Set(m.map((p) => p.name)), d = _.filter((p) => !i.has(p.name));
|
|
719
|
+
return [...m, ...d];
|
|
727
720
|
}
|
|
728
|
-
return
|
|
729
|
-
}, [
|
|
721
|
+
return _;
|
|
722
|
+
}, [m, _]), T = G(() => {
|
|
730
723
|
if (!a) return a;
|
|
731
|
-
const
|
|
732
|
-
return
|
|
733
|
-
...
|
|
734
|
-
...
|
|
724
|
+
const i = Ge(a);
|
|
725
|
+
return c ? i.map((d) => ({
|
|
726
|
+
...c,
|
|
727
|
+
...d
|
|
735
728
|
// Individual column props override defaults
|
|
736
|
-
})) :
|
|
737
|
-
}, [a,
|
|
738
|
-
const
|
|
739
|
-
if (
|
|
740
|
-
const
|
|
741
|
-
|
|
729
|
+
})) : i;
|
|
730
|
+
}, [a, c]), F = G(() => {
|
|
731
|
+
const i = pe(o), d = {};
|
|
732
|
+
if (u !== void 0 && (d.sortable = u), l !== void 0 && (d.filterable = l), w !== void 0 && (d.selectable = w), $) {
|
|
733
|
+
const p = i?.icons || o?.icons || {};
|
|
734
|
+
d.icons = { ...$, ...p };
|
|
742
735
|
}
|
|
743
|
-
if (
|
|
744
|
-
const
|
|
736
|
+
if (k.length > 0 && i) {
|
|
737
|
+
const p = i.plugins || [], M = new Set(p.map((H) => H.name)), q = k.filter((H) => !M.has(H.name));
|
|
745
738
|
return {
|
|
746
|
-
...
|
|
747
|
-
...
|
|
748
|
-
plugins: [...
|
|
739
|
+
...i,
|
|
740
|
+
...d,
|
|
741
|
+
plugins: [...p, ...q]
|
|
749
742
|
};
|
|
750
743
|
}
|
|
751
|
-
return
|
|
752
|
-
}, [o,
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
}, [
|
|
756
|
-
|
|
757
|
-
}, [r]),
|
|
758
|
-
|
|
759
|
-
}, [
|
|
760
|
-
|
|
761
|
-
}, [
|
|
762
|
-
|
|
763
|
-
}, [
|
|
764
|
-
|
|
765
|
-
}, [D]),
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
const
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
const j = requestAnimationFrame(() => {
|
|
774
|
-
m || (typeof c.refreshColumns == "function" && c.refreshColumns(), typeof c.refreshShellHeader == "function" && c.refreshShellHeader());
|
|
744
|
+
return k.length > 0 && !i ? { ...d, plugins: k } : Object.keys(d).length > 0 ? { ...i, ...d } : i;
|
|
745
|
+
}, [o, k, u, l, w, $]);
|
|
746
|
+
C(() => {
|
|
747
|
+
ee().setTypeDefaults(re);
|
|
748
|
+
}, [re]), C(() => {
|
|
749
|
+
f.current && (f.current.rows = r);
|
|
750
|
+
}, [r]), C(() => {
|
|
751
|
+
f.current && F && (f.current.gridConfig = F);
|
|
752
|
+
}, [F]), C(() => {
|
|
753
|
+
f.current && T && (f.current.columns = T);
|
|
754
|
+
}, [T]), C(() => {
|
|
755
|
+
f.current && s !== void 0 && (f.current.fitMode = s);
|
|
756
|
+
}, [s]), C(() => {
|
|
757
|
+
f.current && D !== void 0 && (f.current.loading = D);
|
|
758
|
+
}, [D]), C(() => {
|
|
759
|
+
const i = f.current;
|
|
760
|
+
if (!i) return;
|
|
761
|
+
const d = ee();
|
|
762
|
+
i.__frameworkAdapter = d, Ye(i), Ze(i, d);
|
|
763
|
+
let p = !1;
|
|
764
|
+
const M = requestAnimationFrame(() => {
|
|
765
|
+
p || (typeof i.refreshColumns == "function" && i.refreshColumns(), typeof i.refreshShellHeader == "function" && i.refreshShellHeader());
|
|
775
766
|
});
|
|
776
767
|
return () => {
|
|
777
|
-
|
|
768
|
+
p = !0, cancelAnimationFrame(M);
|
|
778
769
|
};
|
|
779
|
-
}, []),
|
|
780
|
-
if (!
|
|
781
|
-
const
|
|
782
|
-
let
|
|
783
|
-
return
|
|
784
|
-
|
|
770
|
+
}, []), C(() => {
|
|
771
|
+
if (!f.current || !S) return;
|
|
772
|
+
const i = f.current, d = "react-custom-styles";
|
|
773
|
+
let p = !0;
|
|
774
|
+
return i.ready?.().then(() => {
|
|
775
|
+
p && S && (i.registerStyles?.(d, S), j.current = d);
|
|
785
776
|
}), () => {
|
|
786
|
-
|
|
777
|
+
p = !1, j.current && (i.unregisterStyles?.(j.current), j.current = null);
|
|
787
778
|
};
|
|
788
|
-
}, [
|
|
789
|
-
const
|
|
790
|
-
if (!
|
|
791
|
-
const
|
|
792
|
-
return
|
|
793
|
-
|
|
779
|
+
}, [S]), C(() => {
|
|
780
|
+
const i = f.current;
|
|
781
|
+
if (!i) return;
|
|
782
|
+
const d = [];
|
|
783
|
+
return N && d.push(i.on("rows-change", (p) => N(p.rows))), () => {
|
|
784
|
+
d.forEach((p) => p());
|
|
794
785
|
};
|
|
795
|
-
}, [
|
|
796
|
-
const
|
|
797
|
-
for (const
|
|
798
|
-
|
|
799
|
-
return
|
|
800
|
-
const
|
|
801
|
-
if (!
|
|
802
|
-
const
|
|
803
|
-
for (const [
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
786
|
+
}, [N]);
|
|
787
|
+
const ce = G(() => Object.keys(W).filter((i) => typeof y[i] == "function").sort().join("|"), [y]), ae = x({});
|
|
788
|
+
for (const i of Object.keys(W))
|
|
789
|
+
ae.current[i] = y[i];
|
|
790
|
+
return C(() => {
|
|
791
|
+
const i = f.current;
|
|
792
|
+
if (!i) return;
|
|
793
|
+
const d = [];
|
|
794
|
+
for (const [p, M] of Object.entries(W))
|
|
795
|
+
ce.includes(p) && d.push(
|
|
796
|
+
i.on(M, (q, H) => {
|
|
797
|
+
ae.current[p]?.(q, H);
|
|
807
798
|
})
|
|
808
799
|
);
|
|
809
800
|
return () => {
|
|
810
|
-
|
|
801
|
+
d.forEach((p) => p());
|
|
811
802
|
};
|
|
812
|
-
}, [
|
|
803
|
+
}, [ce]), we(
|
|
813
804
|
e,
|
|
814
805
|
() => ({
|
|
815
806
|
get element() {
|
|
816
|
-
return
|
|
807
|
+
return f.current;
|
|
817
808
|
},
|
|
818
809
|
async getConfig() {
|
|
819
|
-
return
|
|
810
|
+
return f.current?.getConfig?.() ?? {};
|
|
820
811
|
},
|
|
821
812
|
async ready() {
|
|
822
|
-
return
|
|
813
|
+
return f.current?.ready?.();
|
|
823
814
|
},
|
|
824
815
|
async forceLayout() {
|
|
825
|
-
return
|
|
816
|
+
return f.current?.forceLayout?.();
|
|
826
817
|
},
|
|
827
|
-
async toggleGroup(
|
|
828
|
-
return
|
|
818
|
+
async toggleGroup(i) {
|
|
819
|
+
return f.current?.toggleGroup?.(i);
|
|
829
820
|
},
|
|
830
|
-
registerStyles(
|
|
831
|
-
|
|
821
|
+
registerStyles(i, d) {
|
|
822
|
+
f.current?.registerStyles?.(i, d);
|
|
832
823
|
},
|
|
833
|
-
unregisterStyles(
|
|
834
|
-
|
|
824
|
+
unregisterStyles(i) {
|
|
825
|
+
f.current?.unregisterStyles?.(i);
|
|
835
826
|
},
|
|
836
|
-
setRowLoading(
|
|
837
|
-
|
|
827
|
+
setRowLoading(i, d) {
|
|
828
|
+
f.current?.setRowLoading?.(i, d);
|
|
838
829
|
},
|
|
839
|
-
setCellLoading(
|
|
840
|
-
|
|
830
|
+
setCellLoading(i, d, p) {
|
|
831
|
+
f.current?.setCellLoading?.(i, d, p);
|
|
841
832
|
},
|
|
842
|
-
isRowLoading(
|
|
843
|
-
return
|
|
833
|
+
isRowLoading(i) {
|
|
834
|
+
return f.current?.isRowLoading?.(i) ?? !1;
|
|
844
835
|
},
|
|
845
|
-
isCellLoading(
|
|
846
|
-
return
|
|
836
|
+
isCellLoading(i, d) {
|
|
837
|
+
return f.current?.isCellLoading?.(i, d) ?? !1;
|
|
847
838
|
},
|
|
848
839
|
clearAllLoading() {
|
|
849
|
-
|
|
840
|
+
f.current?.clearAllLoading?.();
|
|
850
841
|
}
|
|
851
842
|
}),
|
|
852
843
|
[]
|
|
853
|
-
), /* @__PURE__ */
|
|
844
|
+
), /* @__PURE__ */ b(
|
|
854
845
|
"tbw-grid",
|
|
855
846
|
{
|
|
856
|
-
ref: (
|
|
857
|
-
if (
|
|
858
|
-
const
|
|
859
|
-
|
|
847
|
+
ref: (i) => {
|
|
848
|
+
if (f.current = i, i) {
|
|
849
|
+
const d = i;
|
|
850
|
+
F && (d.gridConfig = F), r && (d.rows = r), T && (d.columns = T);
|
|
860
851
|
}
|
|
861
852
|
},
|
|
862
|
-
class:
|
|
863
|
-
style:
|
|
864
|
-
children: /* @__PURE__ */
|
|
853
|
+
class: L,
|
|
854
|
+
style: g,
|
|
855
|
+
children: /* @__PURE__ */ b(Ee.Provider, { value: f, children: h })
|
|
865
856
|
}
|
|
866
857
|
);
|
|
867
858
|
});
|
|
868
|
-
function
|
|
859
|
+
function lt(n) {
|
|
869
860
|
const {
|
|
870
861
|
field: t,
|
|
871
862
|
header: e,
|
|
872
863
|
type: r,
|
|
873
864
|
editable: o,
|
|
874
865
|
sortable: a,
|
|
875
|
-
resizable:
|
|
876
|
-
width:
|
|
877
|
-
minWidth:
|
|
878
|
-
hidden:
|
|
879
|
-
lockVisible:
|
|
880
|
-
children:
|
|
881
|
-
editor:
|
|
882
|
-
options:
|
|
883
|
-
multi:
|
|
884
|
-
format:
|
|
885
|
-
} = n,
|
|
886
|
-
(
|
|
887
|
-
|
|
866
|
+
resizable: c,
|
|
867
|
+
width: s,
|
|
868
|
+
minWidth: u,
|
|
869
|
+
hidden: l,
|
|
870
|
+
lockVisible: w,
|
|
871
|
+
children: D,
|
|
872
|
+
editor: S,
|
|
873
|
+
options: L,
|
|
874
|
+
multi: g,
|
|
875
|
+
format: h
|
|
876
|
+
} = n, m = x(null), E = P(
|
|
877
|
+
(f) => {
|
|
878
|
+
m.current = f, f && (D && $e(f, D), S && _e(f, S));
|
|
888
879
|
},
|
|
889
|
-
[
|
|
890
|
-
),
|
|
880
|
+
[D, S, t]
|
|
881
|
+
), N = typeof s == "number" ? `${s}px` : s, y = {
|
|
891
882
|
field: t,
|
|
892
|
-
ref:
|
|
883
|
+
ref: E
|
|
893
884
|
};
|
|
894
|
-
return e !== void 0 && (y.header = e), r !== void 0 && (y.type = r), o !== void 0 && (y.editable = o), a !== void 0 && (y.sortable = a),
|
|
885
|
+
return e !== void 0 && (y.header = e), r !== void 0 && (y.type = r), o !== void 0 && (y.editable = o), a !== void 0 && (y.sortable = a), c !== void 0 && (y.resizable = c), N !== void 0 && (y.width = N), u !== void 0 && (y["min-width"] = u), l !== void 0 && (y.hidden = l), w !== void 0 && (y["lock-visible"] = w), g !== void 0 && (y.multi = g), h && (y["data-has-format"] = "true"), L && (y["data-has-options"] = "true"), /* @__PURE__ */ b("tbw-grid-column", { ...y });
|
|
895
886
|
}
|
|
896
|
-
function
|
|
897
|
-
return /* @__PURE__ */
|
|
887
|
+
function ft({ children: n }) {
|
|
888
|
+
return /* @__PURE__ */ b("tbw-grid-tool-buttons", { children: n });
|
|
898
889
|
}
|
|
899
|
-
const
|
|
890
|
+
const gt = ({ icons: n, defaults: t, children: e }) => {
|
|
900
891
|
let r = e;
|
|
901
|
-
return t && (r = /* @__PURE__ */
|
|
892
|
+
return t && (r = /* @__PURE__ */ b(Ie, { defaults: t, children: r })), n && (r = /* @__PURE__ */ b(xe, { icons: n, children: r })), /* @__PURE__ */ b(ye, { children: r });
|
|
902
893
|
};
|
|
903
|
-
function
|
|
904
|
-
const t =
|
|
905
|
-
|
|
906
|
-
let
|
|
894
|
+
function pt(n) {
|
|
895
|
+
const t = x(null), [e, r] = de(!1), [o, a] = de(null), c = x(null), s = P(() => n ? (c.current ??= document.querySelector(n), c.current) : t.current?.element ?? null, [n]);
|
|
896
|
+
C(() => {
|
|
897
|
+
let g = !0;
|
|
907
898
|
return (async () => {
|
|
908
899
|
try {
|
|
909
900
|
if (n) {
|
|
910
|
-
const
|
|
911
|
-
if (!
|
|
912
|
-
if (
|
|
901
|
+
const m = document.querySelector(n);
|
|
902
|
+
if (!m) return;
|
|
903
|
+
if (c.current = m, await m.ready?.(), g) {
|
|
913
904
|
r(!0);
|
|
914
|
-
const
|
|
915
|
-
|
|
905
|
+
const E = await m.getConfig?.();
|
|
906
|
+
g && E && a(E);
|
|
916
907
|
}
|
|
917
908
|
} else {
|
|
918
|
-
const
|
|
919
|
-
if (!
|
|
920
|
-
if (await
|
|
909
|
+
const m = t.current;
|
|
910
|
+
if (!m) return;
|
|
911
|
+
if (await m.ready?.(), g) {
|
|
921
912
|
r(!0);
|
|
922
|
-
const
|
|
923
|
-
|
|
913
|
+
const E = await m.getConfig?.();
|
|
914
|
+
g && E && a(E);
|
|
924
915
|
}
|
|
925
916
|
}
|
|
926
917
|
} catch {
|
|
927
918
|
}
|
|
928
919
|
})(), () => {
|
|
929
|
-
|
|
920
|
+
g = !1;
|
|
930
921
|
};
|
|
931
922
|
}, [n]);
|
|
932
|
-
const
|
|
933
|
-
const
|
|
934
|
-
if (
|
|
935
|
-
return await
|
|
936
|
-
const
|
|
937
|
-
return
|
|
938
|
-
}, [
|
|
939
|
-
const
|
|
940
|
-
if (
|
|
941
|
-
await
|
|
923
|
+
const u = P(async () => {
|
|
924
|
+
const g = s();
|
|
925
|
+
if (g)
|
|
926
|
+
return await g.getConfig?.() ?? null;
|
|
927
|
+
const h = t.current;
|
|
928
|
+
return h ? await h.getConfig?.() ?? null : null;
|
|
929
|
+
}, [s]), l = P(async () => {
|
|
930
|
+
const g = s();
|
|
931
|
+
if (g) {
|
|
932
|
+
await g.forceLayout?.();
|
|
942
933
|
return;
|
|
943
934
|
}
|
|
944
|
-
const
|
|
945
|
-
|
|
946
|
-
}, [
|
|
947
|
-
async (
|
|
948
|
-
const
|
|
949
|
-
if (
|
|
950
|
-
await
|
|
935
|
+
const h = t.current;
|
|
936
|
+
h && await h.forceLayout?.();
|
|
937
|
+
}, [s]), w = P(
|
|
938
|
+
async (g) => {
|
|
939
|
+
const h = s();
|
|
940
|
+
if (h) {
|
|
941
|
+
await h.toggleGroup?.(g);
|
|
951
942
|
return;
|
|
952
943
|
}
|
|
953
|
-
const
|
|
954
|
-
|
|
944
|
+
const m = t.current;
|
|
945
|
+
m && await m.toggleGroup?.(g);
|
|
955
946
|
},
|
|
956
|
-
[
|
|
957
|
-
),
|
|
958
|
-
(
|
|
959
|
-
const
|
|
960
|
-
if (
|
|
961
|
-
|
|
947
|
+
[s]
|
|
948
|
+
), D = P(
|
|
949
|
+
(g, h) => {
|
|
950
|
+
const m = s();
|
|
951
|
+
if (m) {
|
|
952
|
+
m.registerStyles?.(g, h);
|
|
962
953
|
return;
|
|
963
954
|
}
|
|
964
|
-
t.current?.registerStyles?.(
|
|
955
|
+
t.current?.registerStyles?.(g, h);
|
|
965
956
|
},
|
|
966
|
-
[
|
|
967
|
-
),
|
|
968
|
-
(
|
|
969
|
-
const
|
|
970
|
-
if (
|
|
971
|
-
|
|
972
|
-
return;
|
|
973
|
-
}
|
|
974
|
-
t.current?.unregisterStyles?.(d);
|
|
975
|
-
},
|
|
976
|
-
[i]
|
|
977
|
-
), A = h(() => o?.columns ? o.columns.filter((d) => !d.hidden) : [], [o]), k = h(() => {
|
|
978
|
-
const d = i(), s = d?.getPluginByName?.("selection");
|
|
979
|
-
if (!s) {
|
|
980
|
-
console.warn("[useGrid] selectAll requires SelectionPlugin");
|
|
981
|
-
return;
|
|
982
|
-
}
|
|
983
|
-
if (s.config?.mode === "row") {
|
|
984
|
-
const p = d?.rows ?? [], b = new Set(p.map((H, F) => F));
|
|
985
|
-
s.selected = b, s.requestAfterRender?.();
|
|
986
|
-
}
|
|
987
|
-
}, [i]), M = h(() => {
|
|
988
|
-
const s = i()?.getPluginByName?.("selection");
|
|
989
|
-
s && s.clearSelection?.();
|
|
990
|
-
}, [i]), L = h(() => {
|
|
991
|
-
const s = i()?.getPluginByName?.("selection");
|
|
992
|
-
return s ? new Set(s.selected ?? []) : /* @__PURE__ */ new Set();
|
|
993
|
-
}, [i]), S = h(() => {
|
|
994
|
-
const d = i(), s = d?.getPluginByName?.("selection");
|
|
995
|
-
if (!s) return [];
|
|
996
|
-
const p = d?.rows ?? [], b = s.selected ?? /* @__PURE__ */ new Set();
|
|
997
|
-
return p.filter((H, F) => b.has(F));
|
|
998
|
-
}, [i]), T = h(
|
|
999
|
-
(d) => {
|
|
1000
|
-
const p = i()?.getPluginByName?.("export");
|
|
1001
|
-
if (!p) {
|
|
1002
|
-
console.warn("[useGrid] exportToCsv requires ExportPlugin (use export prop)");
|
|
1003
|
-
return;
|
|
1004
|
-
}
|
|
1005
|
-
p.exportCsv?.({ filename: d ?? "export.csv" });
|
|
1006
|
-
},
|
|
1007
|
-
[i]
|
|
1008
|
-
), y = h(
|
|
1009
|
-
(d) => {
|
|
1010
|
-
const p = i()?.getPluginByName?.("export");
|
|
1011
|
-
if (!p) {
|
|
1012
|
-
console.warn("[useGrid] exportToJson requires ExportPlugin (use export prop)");
|
|
957
|
+
[s]
|
|
958
|
+
), S = P(
|
|
959
|
+
(g) => {
|
|
960
|
+
const h = s();
|
|
961
|
+
if (h) {
|
|
962
|
+
h.unregisterStyles?.(g);
|
|
1013
963
|
return;
|
|
1014
964
|
}
|
|
1015
|
-
|
|
965
|
+
t.current?.unregisterStyles?.(g);
|
|
1016
966
|
},
|
|
1017
|
-
[
|
|
1018
|
-
);
|
|
967
|
+
[s]
|
|
968
|
+
), L = P(() => o?.columns ? o.columns.filter((g) => !g.hidden) : [], [o]);
|
|
1019
969
|
return {
|
|
1020
970
|
ref: t,
|
|
1021
|
-
element:
|
|
971
|
+
element: s(),
|
|
1022
972
|
isReady: e,
|
|
1023
973
|
config: o,
|
|
1024
|
-
getConfig:
|
|
1025
|
-
forceLayout:
|
|
1026
|
-
toggleGroup:
|
|
1027
|
-
registerStyles:
|
|
1028
|
-
unregisterStyles:
|
|
1029
|
-
getVisibleColumns:
|
|
1030
|
-
// Selection methods
|
|
1031
|
-
selectAll: k,
|
|
1032
|
-
clearSelection: M,
|
|
1033
|
-
getSelectedIndices: L,
|
|
1034
|
-
getSelectedRows: S,
|
|
1035
|
-
// Export methods
|
|
1036
|
-
exportToCsv: T,
|
|
1037
|
-
exportToJson: y
|
|
974
|
+
getConfig: u,
|
|
975
|
+
forceLayout: l,
|
|
976
|
+
toggleGroup: w,
|
|
977
|
+
registerStyles: D,
|
|
978
|
+
unregisterStyles: S,
|
|
979
|
+
getVisibleColumns: L
|
|
1038
980
|
};
|
|
1039
981
|
}
|
|
1040
|
-
let ge = !1;
|
|
1041
|
-
function wt(n, t, e, r = []) {
|
|
1042
|
-
!ge && typeof window < "u" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes(".local")) && (ge = !0, console.warn(
|
|
1043
|
-
`[useGridEvent] Deprecated: Use event props directly on DataGrid instead.
|
|
1044
|
-
Example: <DataGrid onSelectionChange={(e) => ...} />
|
|
1045
|
-
See migration guide: https://toolbox-web.dev/grid-react/migration`
|
|
1046
|
-
));
|
|
1047
|
-
const o = P(e);
|
|
1048
|
-
w(() => {
|
|
1049
|
-
o.current = e;
|
|
1050
|
-
}, [e, ...r]), w(() => {
|
|
1051
|
-
const a = n.current, l = a && "element" in a ? a.element : a;
|
|
1052
|
-
if (!l) return;
|
|
1053
|
-
const i = ((f) => {
|
|
1054
|
-
o.current(f);
|
|
1055
|
-
});
|
|
1056
|
-
return l.addEventListener(t, i), () => {
|
|
1057
|
-
l.removeEventListener(t, i);
|
|
1058
|
-
};
|
|
1059
|
-
}, [n, t]);
|
|
1060
|
-
}
|
|
1061
982
|
export {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
at as
|
|
1076
|
-
lt as useGridTypeDefaults,
|
|
1077
|
-
dt as useTypeDefault
|
|
983
|
+
ut as DataGrid,
|
|
984
|
+
Be as GridAdapter,
|
|
985
|
+
lt as GridColumn,
|
|
986
|
+
je as GridDetailPanel,
|
|
987
|
+
xe as GridIconProvider,
|
|
988
|
+
gt as GridProvider,
|
|
989
|
+
Ve as GridResponsiveCard,
|
|
990
|
+
ft as GridToolButtons,
|
|
991
|
+
dt as GridToolPanel,
|
|
992
|
+
Ie as GridTypeProvider,
|
|
993
|
+
pt as useGrid,
|
|
994
|
+
st as useGridIcons,
|
|
995
|
+
ct as useGridTypeDefaults,
|
|
996
|
+
at as useTypeDefault
|
|
1078
997
|
};
|