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