@toolbox-web/grid-react 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +537 -416
- package/lib/portal-manager.d.ts.map +1 -1
- package/lib/react-column-config.d.ts +26 -5
- package/lib/react-column-config.d.ts.map +1 -1
- package/lib/react-grid-adapter.d.ts +51 -3
- package/lib/react-grid-adapter.d.ts.map +1 -1
- package/lib/use-grid-overlay.d.ts +74 -0
- package/lib/use-grid-overlay.d.ts.map +1 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { DataGridElement as
|
|
3
|
-
import { createContext as ye, useContext as
|
|
4
|
-
import { a as
|
|
5
|
-
import { flushSync as
|
|
6
|
-
import { createPluginsFromFeatures as
|
|
7
|
-
import { G as
|
|
8
|
-
function
|
|
1
|
+
import { jsx as E, Fragment as re, jsxs as Pe } from "react/jsx-runtime";
|
|
2
|
+
import { DataGridElement as Ee } from "@toolbox-web/grid";
|
|
3
|
+
import { createContext as ye, useContext as L, useRef as k, useCallback as S, useEffect as P, forwardRef as he, useReducer as Se, useImperativeHandle as ve, Component as ke, useMemo as T, useLayoutEffect as De, Children as Te, isValidElement as Ge, useState as ue } from "react";
|
|
4
|
+
import { a as b, r as A, s as fe } from "./chunks/portal-bridge-DZ4yQkmm.js";
|
|
5
|
+
import { flushSync as ge, createPortal as Ke } from "react-dom";
|
|
6
|
+
import { createPluginsFromFeatures as xe } from "@toolbox-web/grid/features/registry";
|
|
7
|
+
import { G as Ce } from "./chunks/grid-element-context-BU3WvNtM.js";
|
|
8
|
+
function Ae(n) {
|
|
9
9
|
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
10
10
|
}
|
|
11
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(
|
|
12
|
+
return n.toLowerCase() === "id" ? "ID" : n.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").split(" ").filter(Boolean).map(Ae).join(" ");
|
|
13
13
|
}
|
|
14
|
-
const
|
|
15
|
-
function
|
|
14
|
+
const Me = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime", "currency"]);
|
|
15
|
+
function Le(n) {
|
|
16
16
|
const e = n.lastIndexOf(":");
|
|
17
17
|
if (e > 0) {
|
|
18
18
|
const t = n.slice(e + 1).toLowerCase();
|
|
19
|
-
if (
|
|
19
|
+
if (Me.has(t)) {
|
|
20
20
|
const r = n.slice(0, e);
|
|
21
21
|
return {
|
|
22
22
|
field: r,
|
|
@@ -31,9 +31,9 @@ function Ne(n) {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
function Fe(n) {
|
|
34
|
-
return n.map((e) => typeof e == "string" ?
|
|
34
|
+
return n.map((e) => typeof e == "string" ? Le(e) : e);
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const _ = {
|
|
37
37
|
onCellClick: "cell-click",
|
|
38
38
|
onRowClick: "row-click",
|
|
39
39
|
onCellActivate: "cell-activate",
|
|
@@ -64,135 +64,178 @@ const W = {
|
|
|
64
64
|
onPrintStart: "print-start",
|
|
65
65
|
onPrintComplete: "print-complete",
|
|
66
66
|
onTbwScroll: "tbw-scroll"
|
|
67
|
-
},
|
|
68
|
-
function
|
|
69
|
-
return
|
|
67
|
+
}, ne = ye(null), Ne = ({ icons: n, children: e }) => /* @__PURE__ */ E(ne.Provider, { value: n, children: e });
|
|
68
|
+
function yt() {
|
|
69
|
+
return L(ne);
|
|
70
70
|
}
|
|
71
|
-
const
|
|
72
|
-
function
|
|
71
|
+
const Ie = ne, J = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new Map();
|
|
72
|
+
function Re(n) {
|
|
73
73
|
const e = n.querySelector("tbw-grid-responsive-card");
|
|
74
74
|
if (e) {
|
|
75
|
-
const r =
|
|
75
|
+
const r = J.get(e);
|
|
76
76
|
if (r) return r;
|
|
77
77
|
}
|
|
78
78
|
const t = n.id || n.getAttribute("data-grid-id");
|
|
79
79
|
if (t)
|
|
80
|
-
return
|
|
80
|
+
return Y.get(t);
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
const { children: e, cardRowHeight: t = "auto" } = n, r = k(null), o =
|
|
84
|
-
(
|
|
85
|
-
if (r.current =
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
89
|
-
const g =
|
|
90
|
-
g &&
|
|
82
|
+
function He(n) {
|
|
83
|
+
const { children: e, cardRowHeight: t = "auto" } = n, r = k(null), o = S(
|
|
84
|
+
(i) => {
|
|
85
|
+
if (r.current = i, !i) return;
|
|
86
|
+
J.set(i, e);
|
|
87
|
+
const c = i.closest("tbw-grid");
|
|
88
|
+
if (c) {
|
|
89
|
+
const g = c.id || c.getAttribute("data-grid-id");
|
|
90
|
+
g && Y.set(g, e);
|
|
91
91
|
}
|
|
92
92
|
},
|
|
93
93
|
[e]
|
|
94
94
|
);
|
|
95
95
|
P(() => () => {
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
101
|
-
const g =
|
|
102
|
-
g &&
|
|
96
|
+
const i = r.current;
|
|
97
|
+
if (i) {
|
|
98
|
+
J.delete(i);
|
|
99
|
+
const c = i.closest("tbw-grid");
|
|
100
|
+
if (c) {
|
|
101
|
+
const g = c.id || c.getAttribute("data-grid-id");
|
|
102
|
+
g && Y.delete(g);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
}, []);
|
|
106
|
-
const
|
|
107
|
-
return /* @__PURE__ */
|
|
106
|
+
const s = t === "auto" ? "auto" : String(t);
|
|
107
|
+
return /* @__PURE__ */ E("tbw-grid-responsive-card", { ref: o, cardRowHeight: s });
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
function
|
|
112
|
-
return O
|
|
109
|
+
He.displayName = "GridResponsiveCard";
|
|
110
|
+
const O = ye(null), Be = ({ defaults: n, children: e }) => /* @__PURE__ */ E(O.Provider, { value: n, children: e });
|
|
111
|
+
function ht() {
|
|
112
|
+
return L(O);
|
|
113
113
|
}
|
|
114
|
-
function
|
|
115
|
-
return O
|
|
114
|
+
function vt(n) {
|
|
115
|
+
return L(O)?.[n];
|
|
116
116
|
}
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
const qe = O;
|
|
118
|
+
class Oe extends ke {
|
|
119
|
+
state = { failed: !1 };
|
|
120
|
+
static getDerivedStateFromError() {
|
|
121
|
+
return { failed: !0 };
|
|
122
|
+
}
|
|
123
|
+
componentDidCatch(e) {
|
|
124
|
+
this.props.onError(this.props.portalKey, e);
|
|
125
|
+
}
|
|
126
|
+
render() {
|
|
127
|
+
return this.state.failed ? null : this.props.children;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const je = he(function(e, t) {
|
|
131
|
+
const r = k(/* @__PURE__ */ new Map()), [, o] = Se((m) => m + 1, 0), s = k(!1), i = k(0), c = () => {
|
|
132
|
+
s.current || (s.current = !0, queueMicrotask(() => {
|
|
133
|
+
s.current = !1, ge(o), g();
|
|
121
134
|
}));
|
|
122
135
|
}, g = () => {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
let p = !1;
|
|
126
|
-
for (const [v, C] of r.current)
|
|
127
|
-
C.container.isConnected || (r.current.delete(v), p = !0);
|
|
128
|
-
p && V(o);
|
|
136
|
+
i.current || (i.current = requestAnimationFrame(() => {
|
|
137
|
+
i.current = 0, o();
|
|
129
138
|
}));
|
|
139
|
+
}, l = (m, w) => {
|
|
140
|
+
console.error(`[grid-react] Portal "${m}" crashed; dropping.`, w), r.current.delete(m), g();
|
|
130
141
|
};
|
|
131
|
-
|
|
142
|
+
ve(
|
|
132
143
|
t,
|
|
133
144
|
() => ({
|
|
134
|
-
renderPortal(
|
|
135
|
-
r.current.set(
|
|
145
|
+
renderPortal(m, w, D) {
|
|
146
|
+
r.current.set(m, { container: w, element: D }), c();
|
|
136
147
|
},
|
|
137
|
-
removePortal(
|
|
138
|
-
r.current.delete(
|
|
148
|
+
removePortal(m, w) {
|
|
149
|
+
r.current.delete(m) && (w ? ge(o) : c());
|
|
139
150
|
},
|
|
140
151
|
clear() {
|
|
141
|
-
r.current.size > 0 && (r.current.clear(),
|
|
152
|
+
r.current.size > 0 && (r.current.clear(), i.current && (cancelAnimationFrame(i.current), i.current = 0), c());
|
|
142
153
|
}
|
|
143
154
|
}),
|
|
144
155
|
// forceRender is stable (useReducer dispatch), refs are stable
|
|
145
156
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
146
157
|
[]
|
|
147
158
|
);
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
159
|
+
const C = [];
|
|
160
|
+
let R = null;
|
|
161
|
+
for (const [m, { container: w, element: D }] of r.current) {
|
|
162
|
+
if (!w.isConnected) {
|
|
163
|
+
(R ??= []).push(m);
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
C.push(
|
|
167
|
+
Ke(
|
|
168
|
+
/* @__PURE__ */ E(Oe, { portalKey: m, onError: l, children: D }),
|
|
169
|
+
w,
|
|
170
|
+
m
|
|
171
|
+
)
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
if (R) {
|
|
175
|
+
const m = R;
|
|
176
|
+
queueMicrotask(() => {
|
|
177
|
+
for (const w of m) r.current.delete(w);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return /* @__PURE__ */ E(re, { children: C });
|
|
181
|
+
}), W = /* @__PURE__ */ Symbol("reactProcessed"), M = /* @__PURE__ */ new Map();
|
|
153
182
|
function ze(n) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
183
|
+
const e = n.querySelectorAll(".react-cell-editor, .react-cell-renderer");
|
|
184
|
+
for (const t of e) {
|
|
185
|
+
const r = M.get(t);
|
|
186
|
+
r && (r.unsub?.(), A(r.key, { sync: !0 }), M.delete(t));
|
|
157
187
|
}
|
|
158
188
|
}
|
|
159
|
-
function
|
|
189
|
+
function $e(n) {
|
|
160
190
|
const e = /* @__PURE__ */ new WeakMap();
|
|
161
191
|
return (t) => {
|
|
162
192
|
const r = t.cellEl;
|
|
163
193
|
if (r) {
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
166
|
-
|
|
194
|
+
const i = e.get(r);
|
|
195
|
+
if (i) {
|
|
196
|
+
if (r.contains(i.container))
|
|
197
|
+
return b(i.container, n(t), i.portalKey), i.container;
|
|
198
|
+
A(i.portalKey, { sync: !0 }), e.delete(r);
|
|
199
|
+
}
|
|
167
200
|
}
|
|
168
201
|
const o = document.createElement("div");
|
|
169
202
|
o.className = "react-cell-renderer", o.style.display = "contents";
|
|
170
|
-
const
|
|
171
|
-
return r && e.set(r, { portalKey:
|
|
203
|
+
const s = b(o, n(t));
|
|
204
|
+
return r && e.set(r, { portalKey: s, container: o }), M.set(o, { key: s }), o;
|
|
172
205
|
};
|
|
173
206
|
}
|
|
174
|
-
function
|
|
207
|
+
function Ue(n) {
|
|
175
208
|
return (e) => {
|
|
176
209
|
const t = document.createElement("div");
|
|
177
210
|
t.className = "react-cell-editor", t.style.display = "contents";
|
|
178
|
-
const
|
|
179
|
-
return
|
|
211
|
+
const o = { key: b(t, n(e)) };
|
|
212
|
+
return M.set(t, o), queueMicrotask(() => {
|
|
213
|
+
const s = t.closest("tbw-grid");
|
|
214
|
+
if (!s) return;
|
|
215
|
+
const i = () => {
|
|
216
|
+
const c = t.ownerDocument.activeElement;
|
|
217
|
+
c && t.contains(c) && (c instanceof HTMLInputElement || c instanceof HTMLTextAreaElement || c instanceof HTMLSelectElement) && c.blur();
|
|
218
|
+
};
|
|
219
|
+
s.addEventListener("before-edit-close", i), o.unsub = () => {
|
|
220
|
+
s.removeEventListener("before-edit-close", i);
|
|
221
|
+
};
|
|
222
|
+
}), t;
|
|
180
223
|
};
|
|
181
224
|
}
|
|
182
|
-
function
|
|
225
|
+
function _e(n) {
|
|
183
226
|
return (e) => {
|
|
184
227
|
const t = document.createElement("div");
|
|
185
228
|
t.className = "react-header-renderer", t.style.display = "contents";
|
|
186
|
-
const r =
|
|
187
|
-
return
|
|
229
|
+
const r = b(t, n(e));
|
|
230
|
+
return M.set(t, { key: r }), t;
|
|
188
231
|
};
|
|
189
232
|
}
|
|
190
|
-
function
|
|
233
|
+
function We(n) {
|
|
191
234
|
return (e) => {
|
|
192
235
|
const t = document.createElement("div");
|
|
193
236
|
t.className = "react-header-label-renderer", t.style.display = "contents";
|
|
194
|
-
const r =
|
|
195
|
-
return
|
|
237
|
+
const r = b(t, n(e));
|
|
238
|
+
return M.set(t, { key: r }), t;
|
|
196
239
|
};
|
|
197
240
|
}
|
|
198
241
|
function Ve(n) {
|
|
@@ -202,13 +245,13 @@ function Ve(n) {
|
|
|
202
245
|
return t;
|
|
203
246
|
const r = document.createElement("div");
|
|
204
247
|
r.className = "react-loading-renderer", r.style.display = "contents";
|
|
205
|
-
const o =
|
|
206
|
-
return
|
|
248
|
+
const o = b(r, t);
|
|
249
|
+
return M.set(r, { key: o }), r;
|
|
207
250
|
};
|
|
208
251
|
}
|
|
209
|
-
function
|
|
252
|
+
function we(n) {
|
|
210
253
|
if (!n) return;
|
|
211
|
-
if (n[
|
|
254
|
+
if (n[W]) return n;
|
|
212
255
|
if (n.loadingRenderer && typeof n.loadingRenderer == "function") {
|
|
213
256
|
const r = n.loadingRenderer;
|
|
214
257
|
n = {
|
|
@@ -218,82 +261,82 @@ function Ce(n) {
|
|
|
218
261
|
}
|
|
219
262
|
if (!n.columns) {
|
|
220
263
|
const r = n;
|
|
221
|
-
return r[
|
|
264
|
+
return r[W] = !0, r;
|
|
222
265
|
}
|
|
223
266
|
const e = n.columns.map((r) => {
|
|
224
|
-
const { renderer: o, editor:
|
|
225
|
-
return o && (
|
|
267
|
+
const { renderer: o, editor: s, headerRenderer: i, headerLabelRenderer: c, ...g } = r, l = { ...g };
|
|
268
|
+
return o && (l.renderer = $e(o)), s && (l.editor = Ue(s)), i && (l.headerRenderer = _e(i)), c && (l.headerLabelRenderer = We(c)), l;
|
|
226
269
|
}), t = {
|
|
227
270
|
...n,
|
|
228
271
|
columns: e
|
|
229
272
|
};
|
|
230
|
-
return t[
|
|
273
|
+
return t[W] = !0, t;
|
|
231
274
|
}
|
|
232
|
-
const
|
|
233
|
-
function
|
|
275
|
+
const Z = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new Map();
|
|
276
|
+
function Je(n) {
|
|
234
277
|
const e = n.querySelector("tbw-grid-detail");
|
|
235
278
|
if (e) {
|
|
236
|
-
const r =
|
|
279
|
+
const r = Z.get(e);
|
|
237
280
|
if (r) return r;
|
|
238
281
|
}
|
|
239
282
|
const t = n.id || n.getAttribute("data-grid-id");
|
|
240
283
|
if (t)
|
|
241
|
-
return
|
|
284
|
+
return Q.get(t);
|
|
242
285
|
}
|
|
243
|
-
function
|
|
244
|
-
const { children: e, showExpandColumn: t = !0, animation: r = "slide" } = n, o = k(null),
|
|
245
|
-
(
|
|
246
|
-
if (o.current =
|
|
247
|
-
|
|
248
|
-
const g =
|
|
286
|
+
function Ye(n) {
|
|
287
|
+
const { children: e, showExpandColumn: t = !0, animation: r = "slide" } = n, o = k(null), s = S(
|
|
288
|
+
(c) => {
|
|
289
|
+
if (o.current = c, !c) return;
|
|
290
|
+
Z.set(c, e);
|
|
291
|
+
const g = c.closest("tbw-grid");
|
|
249
292
|
if (g) {
|
|
250
|
-
const
|
|
251
|
-
|
|
293
|
+
const l = g.id || g.getAttribute("data-grid-id");
|
|
294
|
+
l && Q.set(l, e);
|
|
252
295
|
}
|
|
253
296
|
},
|
|
254
297
|
[e]
|
|
255
298
|
);
|
|
256
299
|
return P(() => () => {
|
|
257
|
-
const
|
|
258
|
-
if (
|
|
259
|
-
|
|
260
|
-
const g =
|
|
300
|
+
const c = o.current;
|
|
301
|
+
if (c) {
|
|
302
|
+
Z.delete(c);
|
|
303
|
+
const g = c.closest("tbw-grid");
|
|
261
304
|
if (g) {
|
|
262
|
-
const
|
|
263
|
-
|
|
305
|
+
const C = g.id || g.getAttribute("data-grid-id");
|
|
306
|
+
C && Q.delete(C);
|
|
264
307
|
}
|
|
265
|
-
const
|
|
266
|
-
|
|
308
|
+
const l = c.parentNode;
|
|
309
|
+
l && l.contains(c);
|
|
267
310
|
}
|
|
268
|
-
}, []), /* @__PURE__ */
|
|
311
|
+
}, []), /* @__PURE__ */ E(
|
|
269
312
|
"tbw-grid-detail",
|
|
270
313
|
{
|
|
271
|
-
ref:
|
|
314
|
+
ref: s,
|
|
272
315
|
showExpandColumn: t ? void 0 : "false",
|
|
273
316
|
animation: r === !1 ? "false" : r
|
|
274
317
|
}
|
|
275
318
|
);
|
|
276
319
|
}
|
|
277
|
-
|
|
278
|
-
const
|
|
279
|
-
function
|
|
280
|
-
const e =
|
|
320
|
+
Ye.displayName = "GridDetailPanel";
|
|
321
|
+
const X = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new Map();
|
|
322
|
+
function Ze(n) {
|
|
323
|
+
const e = X.get(n);
|
|
281
324
|
if (e) return e;
|
|
282
325
|
const t = n.id;
|
|
283
326
|
if (t)
|
|
284
|
-
return
|
|
327
|
+
return ee.get(t);
|
|
285
328
|
}
|
|
286
|
-
function
|
|
287
|
-
const { id: e, title: t, icon: r, tooltip: o, order:
|
|
288
|
-
(
|
|
289
|
-
|
|
329
|
+
function Ct(n) {
|
|
330
|
+
const { id: e, title: t, icon: r, tooltip: o, order: s = 100, children: i } = n, c = k(null), g = S(
|
|
331
|
+
(l) => {
|
|
332
|
+
c.current = l, l && (X.set(l, i), e && ee.set(e, i));
|
|
290
333
|
},
|
|
291
|
-
[
|
|
334
|
+
[i, e]
|
|
292
335
|
);
|
|
293
336
|
return P(() => () => {
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
}, [e]), /* @__PURE__ */
|
|
337
|
+
const l = c.current;
|
|
338
|
+
l && (X.delete(l), e && ee.delete(e));
|
|
339
|
+
}, [e]), /* @__PURE__ */ E(
|
|
297
340
|
"tbw-grid-tool-panel",
|
|
298
341
|
{
|
|
299
342
|
ref: g,
|
|
@@ -301,48 +344,80 @@ function ht(n) {
|
|
|
301
344
|
title: t,
|
|
302
345
|
icon: r,
|
|
303
346
|
tooltip: o,
|
|
304
|
-
order:
|
|
347
|
+
order: s?.toString()
|
|
305
348
|
}
|
|
306
349
|
);
|
|
307
350
|
}
|
|
308
|
-
const G = /* @__PURE__ */ new WeakMap(),
|
|
309
|
-
function
|
|
351
|
+
const G = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new Map();
|
|
352
|
+
function Qe(n, e) {
|
|
310
353
|
const t = n.getAttribute("field"), r = G.get(n) ?? {};
|
|
311
354
|
if (r.renderer = e, G.set(n, r), t) {
|
|
312
|
-
const o =
|
|
313
|
-
o.renderer = e,
|
|
355
|
+
const o = K.get(t) ?? {};
|
|
356
|
+
o.renderer = e, K.set(t, o);
|
|
314
357
|
}
|
|
315
358
|
}
|
|
316
|
-
function
|
|
359
|
+
function Xe(n, e) {
|
|
317
360
|
const t = n.getAttribute("field"), r = G.get(n) ?? {};
|
|
318
361
|
if (r.editor = e, G.set(n, r), t) {
|
|
319
|
-
const o =
|
|
320
|
-
o.editor = e,
|
|
362
|
+
const o = K.get(t) ?? {};
|
|
363
|
+
o.editor = e, K.set(t, o);
|
|
321
364
|
}
|
|
322
365
|
}
|
|
323
|
-
function
|
|
366
|
+
function et(n) {
|
|
324
367
|
let e = G.get(n)?.renderer;
|
|
325
368
|
if (!e) {
|
|
326
369
|
const t = n.getAttribute("field");
|
|
327
|
-
t && (e =
|
|
370
|
+
t && (e = K.get(t)?.renderer);
|
|
328
371
|
}
|
|
329
372
|
return e;
|
|
330
373
|
}
|
|
331
|
-
function
|
|
374
|
+
function tt(n) {
|
|
332
375
|
let e = G.get(n)?.editor;
|
|
333
376
|
if (!e) {
|
|
334
377
|
const t = n.getAttribute("field");
|
|
335
|
-
t && (e =
|
|
378
|
+
t && (e = K.get(t)?.editor);
|
|
336
379
|
}
|
|
337
380
|
return e;
|
|
338
381
|
}
|
|
339
|
-
class
|
|
382
|
+
class rt {
|
|
340
383
|
/** Portal keys for all managed portals (for cleanup on destroy). */
|
|
341
384
|
allPortalKeys = /* @__PURE__ */ new Set();
|
|
342
385
|
/** Portal keys for editor-specific portals (for per-cell cleanup via releaseCell). */
|
|
343
386
|
editorPortalKeys = /* @__PURE__ */ new Set();
|
|
344
387
|
/** Maps portal keys to their containers (for container-based lookups in releaseCell/unmount). */
|
|
345
388
|
keyToContainer = /* @__PURE__ */ new Map();
|
|
389
|
+
/**
|
|
390
|
+
* Reverse index: container element → portal key. Maintained alongside
|
|
391
|
+
* `keyToContainer` so `releaseCell` can resolve only the containers
|
|
392
|
+
* actually inside the released cell (via `cellEl.querySelectorAll`)
|
|
393
|
+
* instead of scanning every tracked portal — important for grids with
|
|
394
|
+
* many cells, where `releaseCell` runs on every cell teardown.
|
|
395
|
+
*/
|
|
396
|
+
containerToKey = /* @__PURE__ */ new WeakMap();
|
|
397
|
+
/**
|
|
398
|
+
* Per-editor `before-edit-close` listener teardown functions, keyed by portal key.
|
|
399
|
+
*
|
|
400
|
+
* The grid's editing plugin emits `before-edit-close` on the host `<tbw-grid>`
|
|
401
|
+
* before tearing down a row's managed editors. React editors commonly write
|
|
402
|
+
* `onBlur={commit}` to flush local state on click-away, but Tab / programmatic
|
|
403
|
+
* row exit rebuilds the cell DOM synchronously without giving the focused
|
|
404
|
+
* input a chance to fire `blur` first.
|
|
405
|
+
*
|
|
406
|
+
* To bridge that gap we call `.blur()` on the focused input inside the editor
|
|
407
|
+
* container as soon as `before-edit-close` fires. The native `.blur()` method
|
|
408
|
+
* is what React's event system actually observes — React 17+ delegates focus
|
|
409
|
+
* events at the root by listening to `focusout` (bubbling) and mapping it to
|
|
410
|
+
* `onBlur`. A bare `dispatchEvent(new FocusEvent('blur'))` would be ignored
|
|
411
|
+
* by React because `blur` does not bubble. Calling the native `.blur()`
|
|
412
|
+
* dispatches the full focus-loss chain (`blur` + `focusout`) and also moves
|
|
413
|
+
* focus off the input — both desirable here since the editor DOM is about to
|
|
414
|
+
* be torn down anyway.
|
|
415
|
+
*
|
|
416
|
+
* Mirrors the Angular adapter's `BaseGridEditor.onBeforeEditClose()` hook.
|
|
417
|
+
* Requires zero per-editor code: any editor with `onBlur={commit}` is
|
|
418
|
+
* automatically covered for Tab commits and programmatic row exit.
|
|
419
|
+
*/
|
|
420
|
+
editorBeforeCloseUnsubs = /* @__PURE__ */ new Map();
|
|
346
421
|
typeDefaults = null;
|
|
347
422
|
/**
|
|
348
423
|
* Sets the type defaults map for this adapter.
|
|
@@ -359,7 +434,7 @@ class et {
|
|
|
359
434
|
* Converts React renderer/editor functions to DOM-returning functions.
|
|
360
435
|
*/
|
|
361
436
|
processConfig(e) {
|
|
362
|
-
return
|
|
437
|
+
return we(e) ?? e;
|
|
363
438
|
}
|
|
364
439
|
/**
|
|
365
440
|
* Determines if this adapter can handle the given element.
|
|
@@ -369,11 +444,11 @@ class et {
|
|
|
369
444
|
const t = e.getAttribute("field");
|
|
370
445
|
let r = G.get(e);
|
|
371
446
|
if (!r && t) {
|
|
372
|
-
const
|
|
373
|
-
|
|
447
|
+
const i = K.get(t);
|
|
448
|
+
i && (i.renderer || i.editor) && (r = i, G.set(e, r));
|
|
374
449
|
}
|
|
375
|
-
const o = r?.renderer !== void 0,
|
|
376
|
-
return r !== void 0 && (o ||
|
|
450
|
+
const o = r?.renderer !== void 0, s = r?.editor !== void 0;
|
|
451
|
+
return r !== void 0 && (o || s);
|
|
377
452
|
}
|
|
378
453
|
/**
|
|
379
454
|
* Creates a view renderer function that renders a React component
|
|
@@ -387,35 +462,38 @@ class et {
|
|
|
387
462
|
* allowing the grid to use its default rendering.
|
|
388
463
|
*/
|
|
389
464
|
createRenderer(e) {
|
|
390
|
-
const t =
|
|
465
|
+
const t = et(e);
|
|
391
466
|
if (!t)
|
|
392
467
|
return;
|
|
393
468
|
const r = e.closest("tbw-grid"), o = /* @__PURE__ */ new WeakMap();
|
|
394
|
-
return (
|
|
395
|
-
const
|
|
396
|
-
if (
|
|
397
|
-
const
|
|
398
|
-
if (
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
469
|
+
return (s) => {
|
|
470
|
+
const i = s.cellEl;
|
|
471
|
+
if (i) {
|
|
472
|
+
const l = o.get(i);
|
|
473
|
+
if (l) {
|
|
474
|
+
if (i.contains(l.container))
|
|
475
|
+
return b(l.container, t(s), l.portalKey), l.container;
|
|
476
|
+
A(l.portalKey, { sync: !0 }), this.untrackPortal(l.portalKey), o.delete(i);
|
|
477
|
+
}
|
|
478
|
+
const C = document.createElement("div");
|
|
479
|
+
C.className = "react-cell-renderer", C.style.display = "contents";
|
|
480
|
+
const R = b(
|
|
481
|
+
C,
|
|
482
|
+
t(s),
|
|
405
483
|
void 0,
|
|
406
484
|
r ?? void 0
|
|
407
485
|
);
|
|
408
|
-
return o.set(
|
|
486
|
+
return o.set(i, { portalKey: R, container: C }), this.trackPortal(R, C, !1), C;
|
|
409
487
|
}
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
const g =
|
|
413
|
-
|
|
414
|
-
t(
|
|
488
|
+
const c = document.createElement("div");
|
|
489
|
+
c.className = "react-cell-renderer", c.style.display = "contents";
|
|
490
|
+
const g = b(
|
|
491
|
+
c,
|
|
492
|
+
t(s),
|
|
415
493
|
void 0,
|
|
416
494
|
r ?? void 0
|
|
417
495
|
);
|
|
418
|
-
return this.trackPortal(g,
|
|
496
|
+
return this.trackPortal(g, c, !1), c;
|
|
419
497
|
};
|
|
420
498
|
}
|
|
421
499
|
/**
|
|
@@ -423,20 +501,29 @@ class et {
|
|
|
423
501
|
* with commit/cancel callbacks passed as props.
|
|
424
502
|
*/
|
|
425
503
|
createEditor(e) {
|
|
426
|
-
const t =
|
|
504
|
+
const t = tt(e);
|
|
427
505
|
if (!t)
|
|
428
506
|
return () => document.createElement("div");
|
|
429
507
|
const r = e.closest("tbw-grid") ?? void 0;
|
|
430
508
|
return (o) => {
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
const
|
|
434
|
-
|
|
509
|
+
const s = document.createElement("div");
|
|
510
|
+
s.className = "react-cell-editor", s.style.display = "contents";
|
|
511
|
+
const i = b(
|
|
512
|
+
s,
|
|
435
513
|
t(o),
|
|
436
514
|
void 0,
|
|
437
515
|
r
|
|
438
516
|
);
|
|
439
|
-
|
|
517
|
+
if (this.trackPortal(i, s, !0), r) {
|
|
518
|
+
const c = () => {
|
|
519
|
+
const l = s.ownerDocument.activeElement;
|
|
520
|
+
l && s.contains(l) && (l instanceof HTMLInputElement || l instanceof HTMLTextAreaElement || l instanceof HTMLSelectElement) && l.blur();
|
|
521
|
+
};
|
|
522
|
+
r.addEventListener("before-edit-close", c), this.editorBeforeCloseUnsubs.set(i, () => {
|
|
523
|
+
r.removeEventListener("before-edit-close", c);
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
return s;
|
|
440
527
|
};
|
|
441
528
|
}
|
|
442
529
|
/**
|
|
@@ -444,18 +531,18 @@ class et {
|
|
|
444
531
|
* Renders React components for expandable detail rows.
|
|
445
532
|
*/
|
|
446
533
|
createDetailRenderer(e) {
|
|
447
|
-
const t =
|
|
534
|
+
const t = Je(e);
|
|
448
535
|
if (t)
|
|
449
536
|
return (r, o) => {
|
|
450
|
-
const
|
|
451
|
-
|
|
452
|
-
const
|
|
453
|
-
|
|
537
|
+
const s = document.createElement("div");
|
|
538
|
+
s.className = "react-detail-panel";
|
|
539
|
+
const c = b(
|
|
540
|
+
s,
|
|
454
541
|
t({ row: r, rowIndex: o }),
|
|
455
542
|
void 0,
|
|
456
543
|
e
|
|
457
544
|
);
|
|
458
|
-
return this.trackPortal(
|
|
545
|
+
return this.trackPortal(c, s, !1), s;
|
|
459
546
|
};
|
|
460
547
|
}
|
|
461
548
|
/**
|
|
@@ -472,18 +559,18 @@ class et {
|
|
|
472
559
|
* Renders React components for card layout in responsive mode.
|
|
473
560
|
*/
|
|
474
561
|
createResponsiveCardRenderer(e) {
|
|
475
|
-
const t =
|
|
562
|
+
const t = Re(e);
|
|
476
563
|
if (t)
|
|
477
564
|
return (r, o) => {
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
const
|
|
481
|
-
|
|
565
|
+
const s = document.createElement("div");
|
|
566
|
+
s.className = "react-responsive-card";
|
|
567
|
+
const c = b(
|
|
568
|
+
s,
|
|
482
569
|
t({ row: r, index: o }),
|
|
483
570
|
void 0,
|
|
484
571
|
e
|
|
485
572
|
);
|
|
486
|
-
return this.trackPortal(
|
|
573
|
+
return this.trackPortal(c, s, !1), s;
|
|
487
574
|
};
|
|
488
575
|
}
|
|
489
576
|
/**
|
|
@@ -504,16 +591,16 @@ class et {
|
|
|
504
591
|
* Renders React components into tool panel containers.
|
|
505
592
|
*/
|
|
506
593
|
createToolPanelRenderer(e) {
|
|
507
|
-
const t =
|
|
594
|
+
const t = Ze(e);
|
|
508
595
|
if (!t)
|
|
509
596
|
return;
|
|
510
597
|
const r = e.closest("tbw-grid");
|
|
511
598
|
return (o) => {
|
|
512
|
-
const
|
|
599
|
+
const i = b(o, t({
|
|
513
600
|
grid: r ?? o
|
|
514
601
|
}), void 0, r ?? void 0);
|
|
515
|
-
return this.trackPortal(
|
|
516
|
-
|
|
602
|
+
return this.trackPortal(i, o, !1), () => {
|
|
603
|
+
A(i, { sync: !0 }), this.untrackPortal(i);
|
|
517
604
|
};
|
|
518
605
|
};
|
|
519
606
|
}
|
|
@@ -560,8 +647,8 @@ class et {
|
|
|
560
647
|
return (r) => {
|
|
561
648
|
const o = document.createElement("span");
|
|
562
649
|
o.style.display = "contents";
|
|
563
|
-
const
|
|
564
|
-
return this.trackPortal(
|
|
650
|
+
const s = r.cellEl?.closest("tbw-grid") ?? t, i = b(o, e(r), void 0, s);
|
|
651
|
+
return this.trackPortal(i, o, !1), o;
|
|
565
652
|
};
|
|
566
653
|
}
|
|
567
654
|
/**
|
|
@@ -572,8 +659,8 @@ class et {
|
|
|
572
659
|
return (r) => {
|
|
573
660
|
const o = document.createElement("span");
|
|
574
661
|
o.style.display = "contents";
|
|
575
|
-
const
|
|
576
|
-
return this.trackPortal(
|
|
662
|
+
const s = b(o, e(r), void 0, t);
|
|
663
|
+
return this.trackPortal(s, o, !0), o;
|
|
577
664
|
};
|
|
578
665
|
}
|
|
579
666
|
/**
|
|
@@ -582,20 +669,24 @@ class et {
|
|
|
582
669
|
*/
|
|
583
670
|
createFilterPanelRenderer(e, t) {
|
|
584
671
|
return (r, o) => {
|
|
585
|
-
const
|
|
586
|
-
|
|
587
|
-
const
|
|
588
|
-
this.trackPortal(
|
|
672
|
+
const s = document.createElement("div");
|
|
673
|
+
s.style.display = "contents";
|
|
674
|
+
const i = r.closest("tbw-grid") ?? t, c = b(s, e(o), void 0, i);
|
|
675
|
+
this.trackPortal(c, s, !1), r.appendChild(s);
|
|
589
676
|
};
|
|
590
677
|
}
|
|
591
678
|
// #region Portal tracking helpers
|
|
592
679
|
/** Register a portal key for lifecycle tracking. */
|
|
593
680
|
trackPortal(e, t, r) {
|
|
594
|
-
this.allPortalKeys.add(e), this.keyToContainer.set(e, t), r && this.editorPortalKeys.add(e);
|
|
681
|
+
this.allPortalKeys.add(e), this.keyToContainer.set(e, t), this.containerToKey.set(t, e), r && this.editorPortalKeys.add(e);
|
|
595
682
|
}
|
|
596
683
|
/** Unregister a portal key from all tracking sets. */
|
|
597
684
|
untrackPortal(e) {
|
|
598
|
-
this.allPortalKeys.delete(e), this.editorPortalKeys.delete(e)
|
|
685
|
+
this.allPortalKeys.delete(e), this.editorPortalKeys.delete(e);
|
|
686
|
+
const t = this.keyToContainer.get(e);
|
|
687
|
+
this.keyToContainer.delete(e), t && this.containerToKey.delete(t);
|
|
688
|
+
const r = this.editorBeforeCloseUnsubs.get(e);
|
|
689
|
+
r && (r(), this.editorBeforeCloseUnsubs.delete(e));
|
|
599
690
|
}
|
|
600
691
|
// #endregion
|
|
601
692
|
/**
|
|
@@ -604,19 +695,38 @@ class et {
|
|
|
604
695
|
*/
|
|
605
696
|
destroy() {
|
|
606
697
|
for (const e of this.allPortalKeys)
|
|
607
|
-
|
|
608
|
-
this.allPortalKeys.clear(), this.editorPortalKeys.clear(), this.keyToContainer.clear()
|
|
698
|
+
A(e);
|
|
699
|
+
this.allPortalKeys.clear(), this.editorPortalKeys.clear(), this.keyToContainer.clear();
|
|
700
|
+
for (const e of this.editorBeforeCloseUnsubs.values()) e();
|
|
701
|
+
this.editorBeforeCloseUnsubs.clear(), K.clear();
|
|
609
702
|
}
|
|
610
703
|
/**
|
|
611
704
|
* Called when a cell's content is about to be wiped.
|
|
612
|
-
*
|
|
613
|
-
*
|
|
614
|
-
*
|
|
705
|
+
*
|
|
706
|
+
* Destroys editor portals AND renderer portals whose container is inside
|
|
707
|
+
* the cell. Releasing renderers here is critical: the editing pipeline
|
|
708
|
+
* runs `cell.innerHTML = ''` immediately after this returns, which
|
|
709
|
+
* silently detaches React-managed renderer containers from the DOM.
|
|
710
|
+
* If we leave the React root mounted, its fiber tree still believes
|
|
711
|
+
* the now-orphaned children are present — a subsequent React commit
|
|
712
|
+
* (e.g. the user's `onCellCommit` → `setRows`) tries to `removeChild`
|
|
713
|
+
* those gone nodes and throws `NotFoundError` (issue #250).
|
|
714
|
+
*
|
|
715
|
+
* Calling this BEFORE the wipe lets React unmount cleanly while DOM
|
|
716
|
+
* still matches its fiber tree. The `wrapReactRenderer` cache will
|
|
717
|
+
* detect the missing entry on the next render and create a fresh
|
|
718
|
+
* container — see the cache-validation defense in `createRenderer`
|
|
719
|
+
* and `wrapReactRenderer` (`react-column-config.ts`).
|
|
720
|
+
*
|
|
721
|
+
* Also cleans up config-based editor and renderer roots
|
|
722
|
+
* (from processGridConfig/wrapReactEditor/wrapReactRenderer) that
|
|
723
|
+
* bypass the adapter's own portal tracking.
|
|
615
724
|
*/
|
|
616
725
|
releaseCell(e) {
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
726
|
+
const t = e.querySelectorAll(".react-cell-renderer, .react-cell-editor");
|
|
727
|
+
for (const r of t) {
|
|
728
|
+
const o = this.containerToKey.get(r);
|
|
729
|
+
o && (A(o, { sync: !0 }), this.untrackPortal(o));
|
|
620
730
|
}
|
|
621
731
|
ze(e);
|
|
622
732
|
}
|
|
@@ -624,21 +734,18 @@ class et {
|
|
|
624
734
|
* Unmount a specific container (called when cell is recycled).
|
|
625
735
|
*/
|
|
626
736
|
unmount(e) {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
H(t), this.untrackPortal(t);
|
|
630
|
-
return;
|
|
631
|
-
}
|
|
737
|
+
const t = this.containerToKey.get(e);
|
|
738
|
+
t && (A(t), this.untrackPortal(t));
|
|
632
739
|
}
|
|
633
740
|
}
|
|
634
|
-
const
|
|
741
|
+
const nt = {
|
|
635
742
|
undoRedo: ["editing"],
|
|
636
743
|
clipboard: ["selection"]
|
|
637
744
|
};
|
|
638
|
-
function
|
|
745
|
+
function ot(n) {
|
|
639
746
|
const e = new Set(n);
|
|
640
747
|
for (const t of n) {
|
|
641
|
-
const r =
|
|
748
|
+
const r = nt[t];
|
|
642
749
|
if (r)
|
|
643
750
|
for (const o of r)
|
|
644
751
|
e.has(o) || console.warn(
|
|
@@ -646,34 +753,34 @@ function rt(n) {
|
|
|
646
753
|
);
|
|
647
754
|
}
|
|
648
755
|
}
|
|
649
|
-
function
|
|
756
|
+
function it(n) {
|
|
650
757
|
const e = [];
|
|
651
758
|
for (const [t, r] of Object.entries(n))
|
|
652
759
|
r === void 0 || r === !1 || e.push(t);
|
|
653
|
-
return
|
|
760
|
+
return ot(e), xe(n);
|
|
654
761
|
}
|
|
655
|
-
let me = !1,
|
|
656
|
-
function
|
|
657
|
-
return me || (
|
|
762
|
+
let me = !1, V = null;
|
|
763
|
+
function te() {
|
|
764
|
+
return me || (V = new rt(), Ee.registerAdapter(V), me = !0), V;
|
|
658
765
|
}
|
|
659
|
-
|
|
660
|
-
function
|
|
766
|
+
te();
|
|
767
|
+
function st(n) {
|
|
661
768
|
const t = n.getPluginByName?.("masterDetail");
|
|
662
769
|
t && typeof t.refreshDetailRenderer == "function" && t.refreshDetailRenderer();
|
|
663
770
|
}
|
|
664
|
-
function
|
|
771
|
+
function ct(n, e) {
|
|
665
772
|
const t = n;
|
|
666
|
-
if (!n.querySelector("tbw-grid-responsive-card") || !
|
|
667
|
-
const
|
|
668
|
-
if (
|
|
669
|
-
const
|
|
670
|
-
|
|
773
|
+
if (!n.querySelector("tbw-grid-responsive-card") || !Re(n)) return;
|
|
774
|
+
const s = t.getPluginByName?.("responsive");
|
|
775
|
+
if (s && typeof s.setCardRenderer == "function") {
|
|
776
|
+
const i = e.createResponsiveCardRenderer(n);
|
|
777
|
+
i && s.setCardRenderer(i);
|
|
671
778
|
}
|
|
672
779
|
}
|
|
673
|
-
function
|
|
780
|
+
function at(n) {
|
|
674
781
|
const e = {};
|
|
675
|
-
return
|
|
676
|
-
if (
|
|
782
|
+
return Te.forEach(n, (t) => {
|
|
783
|
+
if (Ge(t)) {
|
|
677
784
|
if (t.type && t.type.displayName === "GridDetailPanel") {
|
|
678
785
|
const r = t.props;
|
|
679
786
|
e.masterDetail = {
|
|
@@ -692,26 +799,26 @@ const Rt = he(function(e, t) {
|
|
|
692
799
|
// Core props
|
|
693
800
|
rows: r,
|
|
694
801
|
gridConfig: o,
|
|
695
|
-
columns:
|
|
696
|
-
columnDefaults:
|
|
697
|
-
fitMode:
|
|
802
|
+
columns: s,
|
|
803
|
+
columnDefaults: i,
|
|
804
|
+
fitMode: c,
|
|
698
805
|
sortable: g,
|
|
699
|
-
filterable:
|
|
700
|
-
selectable:
|
|
701
|
-
loading:
|
|
702
|
-
customStyles:
|
|
703
|
-
className:
|
|
704
|
-
style:
|
|
705
|
-
children:
|
|
806
|
+
filterable: l,
|
|
807
|
+
selectable: C,
|
|
808
|
+
loading: R,
|
|
809
|
+
customStyles: m,
|
|
810
|
+
className: w,
|
|
811
|
+
style: D,
|
|
812
|
+
children: x,
|
|
706
813
|
// Plugin props
|
|
707
814
|
plugins: u,
|
|
708
815
|
// SSR mode
|
|
709
816
|
ssr: h,
|
|
710
817
|
// Legacy event handlers
|
|
711
|
-
onRowsChange:
|
|
818
|
+
onRowsChange: v,
|
|
712
819
|
// Feature props and event props are in ...rest
|
|
713
|
-
...
|
|
714
|
-
} = e, f = k(null),
|
|
820
|
+
...p
|
|
821
|
+
} = e, f = k(null), q = k(null), oe = L(qe), j = L(Ie), ie = [
|
|
715
822
|
"selection",
|
|
716
823
|
"editing",
|
|
717
824
|
"filtering",
|
|
@@ -736,102 +843,102 @@ const Rt = he(function(e, t) {
|
|
|
736
843
|
"pivot",
|
|
737
844
|
"serverSide",
|
|
738
845
|
"tooltip"
|
|
739
|
-
],
|
|
740
|
-
const
|
|
741
|
-
return
|
|
742
|
-
}).filter(Boolean).join("|"), [
|
|
743
|
-
const
|
|
744
|
-
for (const
|
|
745
|
-
|
|
746
|
-
return
|
|
747
|
-
}, [
|
|
846
|
+
], be = T(() => ie.map((a) => {
|
|
847
|
+
const d = p[a];
|
|
848
|
+
return d !== void 0 ? `${a}:${JSON.stringify(d)}` : "";
|
|
849
|
+
}).filter(Boolean).join("|"), [p]), se = T(() => {
|
|
850
|
+
const a = {};
|
|
851
|
+
for (const d of ie)
|
|
852
|
+
d in p && p[d] !== void 0 && (a[d] = p[d]);
|
|
853
|
+
return a;
|
|
854
|
+
}, [be]), ce = T(() => at(x), [x]), ae = T(() => ({ ...ce, ...se }), [se, ce]), z = T(() => u || h ? [] : it(ae), [ae, u, h]), F = T(() => {
|
|
748
855
|
if (u) {
|
|
749
|
-
const
|
|
750
|
-
return [...u, ...
|
|
856
|
+
const a = new Set(u.map((y) => y.name)), d = z.filter((y) => !a.has(y.name));
|
|
857
|
+
return [...u, ...d];
|
|
751
858
|
}
|
|
752
|
-
return
|
|
753
|
-
}, [u,
|
|
754
|
-
if (!
|
|
755
|
-
const
|
|
756
|
-
return
|
|
757
|
-
...
|
|
758
|
-
...
|
|
859
|
+
return z;
|
|
860
|
+
}, [u, z]), N = T(() => {
|
|
861
|
+
if (!s) return s;
|
|
862
|
+
const a = Fe(s);
|
|
863
|
+
return i ? a.map((d) => ({
|
|
864
|
+
...i,
|
|
865
|
+
...d
|
|
759
866
|
// Individual column props override defaults
|
|
760
|
-
})) :
|
|
761
|
-
}, [
|
|
762
|
-
const
|
|
763
|
-
if (g !== void 0 && (
|
|
764
|
-
const y =
|
|
765
|
-
|
|
867
|
+
})) : a;
|
|
868
|
+
}, [s, i]), I = T(() => {
|
|
869
|
+
const a = we(o), d = {};
|
|
870
|
+
if (g !== void 0 && (d.sortable = g), l !== void 0 && (d.filterable = l), C !== void 0 && (d.selectable = C), j) {
|
|
871
|
+
const y = a?.icons || o?.icons || {};
|
|
872
|
+
d.icons = { ...j, ...y };
|
|
766
873
|
}
|
|
767
|
-
if (
|
|
768
|
-
const y =
|
|
874
|
+
if (F.length > 0 && a) {
|
|
875
|
+
const y = a.plugins || [], H = new Set(y.map((B) => B.name)), U = F.filter((B) => !H.has(B.name));
|
|
769
876
|
return {
|
|
770
|
-
...
|
|
771
|
-
...
|
|
772
|
-
plugins: [...y, ...
|
|
877
|
+
...a,
|
|
878
|
+
...d,
|
|
879
|
+
plugins: [...y, ...U]
|
|
773
880
|
};
|
|
774
881
|
}
|
|
775
|
-
return
|
|
776
|
-
}, [o,
|
|
882
|
+
return F.length > 0 && !a ? { ...d, plugins: F } : Object.keys(d).length > 0 ? { ...a, ...d } : a;
|
|
883
|
+
}, [o, F, g, l, C, j]);
|
|
777
884
|
P(() => {
|
|
778
|
-
|
|
779
|
-
}, [
|
|
885
|
+
te().setTypeDefaults(oe);
|
|
886
|
+
}, [oe]), P(() => {
|
|
780
887
|
f.current && (f.current.rows = r);
|
|
781
888
|
}, [r]), P(() => {
|
|
782
889
|
f.current && I && (f.current.gridConfig = I);
|
|
783
890
|
}, [I]), P(() => {
|
|
784
|
-
f.current &&
|
|
785
|
-
}, [
|
|
786
|
-
f.current &&
|
|
787
|
-
}, [
|
|
788
|
-
f.current &&
|
|
789
|
-
}, [
|
|
790
|
-
const
|
|
791
|
-
if (!
|
|
792
|
-
const
|
|
793
|
-
|
|
891
|
+
f.current && N && (f.current.columns = N);
|
|
892
|
+
}, [N]), P(() => {
|
|
893
|
+
f.current && c !== void 0 && (f.current.fitMode = c);
|
|
894
|
+
}, [c]), P(() => {
|
|
895
|
+
f.current && R !== void 0 && (f.current.loading = R);
|
|
896
|
+
}, [R]), P(() => {
|
|
897
|
+
const a = f.current;
|
|
898
|
+
if (!a) return;
|
|
899
|
+
const d = te();
|
|
900
|
+
a.__frameworkAdapter = d, st(a), ct(a, d);
|
|
794
901
|
let y = !1;
|
|
795
|
-
const
|
|
796
|
-
y || (typeof
|
|
902
|
+
const H = requestAnimationFrame(() => {
|
|
903
|
+
y || (typeof a.refreshColumns == "function" && a.refreshColumns(), typeof a.refreshShellHeader == "function" && a.refreshShellHeader());
|
|
797
904
|
});
|
|
798
905
|
return () => {
|
|
799
|
-
y = !0, cancelAnimationFrame(
|
|
906
|
+
y = !0, cancelAnimationFrame(H);
|
|
800
907
|
};
|
|
801
908
|
}, []), P(() => {
|
|
802
|
-
if (!f.current || !
|
|
803
|
-
const
|
|
909
|
+
if (!f.current || !m) return;
|
|
910
|
+
const a = f.current, d = "react-custom-styles";
|
|
804
911
|
let y = !0;
|
|
805
|
-
return
|
|
806
|
-
y &&
|
|
912
|
+
return a.ready?.().then(() => {
|
|
913
|
+
y && m && (a.registerStyles?.(d, m), q.current = d);
|
|
807
914
|
}), () => {
|
|
808
|
-
y = !1,
|
|
915
|
+
y = !1, q.current && (a.unregisterStyles?.(q.current), q.current = null);
|
|
809
916
|
};
|
|
810
|
-
}, [
|
|
811
|
-
const
|
|
812
|
-
if (!
|
|
813
|
-
const
|
|
814
|
-
return
|
|
815
|
-
|
|
917
|
+
}, [m]), P(() => {
|
|
918
|
+
const a = f.current;
|
|
919
|
+
if (!a) return;
|
|
920
|
+
const d = [];
|
|
921
|
+
return v && d.push(a.on("rows-change", (y) => v(y.rows))), () => {
|
|
922
|
+
d.forEach((y) => y());
|
|
816
923
|
};
|
|
817
|
-
}, [
|
|
818
|
-
const
|
|
819
|
-
for (const
|
|
820
|
-
|
|
924
|
+
}, [v]);
|
|
925
|
+
const le = T(() => Object.keys(_).filter((a) => typeof p[a] == "function").sort().join("|"), [p]), de = k({});
|
|
926
|
+
for (const a of Object.keys(_))
|
|
927
|
+
de.current[a] = p[a];
|
|
821
928
|
P(() => {
|
|
822
|
-
const
|
|
823
|
-
if (!
|
|
824
|
-
const
|
|
825
|
-
for (const [y,
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
929
|
+
const a = f.current;
|
|
930
|
+
if (!a) return;
|
|
931
|
+
const d = [];
|
|
932
|
+
for (const [y, H] of Object.entries(_))
|
|
933
|
+
le.includes(y) && d.push(
|
|
934
|
+
a.on(H, (U, B) => {
|
|
935
|
+
de.current[y]?.(U, B);
|
|
829
936
|
})
|
|
830
937
|
);
|
|
831
938
|
return () => {
|
|
832
|
-
|
|
939
|
+
d.forEach((y) => y());
|
|
833
940
|
};
|
|
834
|
-
}, [
|
|
941
|
+
}, [le]), ve(
|
|
835
942
|
t,
|
|
836
943
|
() => ({
|
|
837
944
|
get element() {
|
|
@@ -846,26 +953,26 @@ const Rt = he(function(e, t) {
|
|
|
846
953
|
async forceLayout() {
|
|
847
954
|
return f.current?.forceLayout?.();
|
|
848
955
|
},
|
|
849
|
-
async toggleGroup(
|
|
850
|
-
return f.current?.toggleGroup?.(
|
|
956
|
+
async toggleGroup(a) {
|
|
957
|
+
return f.current?.toggleGroup?.(a);
|
|
851
958
|
},
|
|
852
|
-
registerStyles(
|
|
853
|
-
f.current?.registerStyles?.(
|
|
959
|
+
registerStyles(a, d) {
|
|
960
|
+
f.current?.registerStyles?.(a, d);
|
|
854
961
|
},
|
|
855
|
-
unregisterStyles(
|
|
856
|
-
f.current?.unregisterStyles?.(
|
|
962
|
+
unregisterStyles(a) {
|
|
963
|
+
f.current?.unregisterStyles?.(a);
|
|
857
964
|
},
|
|
858
|
-
setRowLoading(
|
|
859
|
-
f.current?.setRowLoading?.(
|
|
965
|
+
setRowLoading(a, d) {
|
|
966
|
+
f.current?.setRowLoading?.(a, d);
|
|
860
967
|
},
|
|
861
|
-
setCellLoading(
|
|
862
|
-
f.current?.setCellLoading?.(
|
|
968
|
+
setCellLoading(a, d, y) {
|
|
969
|
+
f.current?.setCellLoading?.(a, d, y);
|
|
863
970
|
},
|
|
864
|
-
isRowLoading(
|
|
865
|
-
return f.current?.isRowLoading?.(
|
|
971
|
+
isRowLoading(a) {
|
|
972
|
+
return f.current?.isRowLoading?.(a) ?? !1;
|
|
866
973
|
},
|
|
867
|
-
isCellLoading(
|
|
868
|
-
return f.current?.isCellLoading?.(
|
|
974
|
+
isCellLoading(a, d) {
|
|
975
|
+
return f.current?.isCellLoading?.(a, d) ?? !1;
|
|
869
976
|
},
|
|
870
977
|
clearAllLoading() {
|
|
871
978
|
f.current?.clearAllLoading?.();
|
|
@@ -874,85 +981,85 @@ const Rt = he(function(e, t) {
|
|
|
874
981
|
[]
|
|
875
982
|
);
|
|
876
983
|
const $ = k(null);
|
|
877
|
-
return
|
|
878
|
-
const
|
|
879
|
-
return
|
|
880
|
-
|
|
984
|
+
return De(() => {
|
|
985
|
+
const a = f.current;
|
|
986
|
+
return a && $.current && fe(a, $.current), () => {
|
|
987
|
+
a && fe(a, null);
|
|
881
988
|
};
|
|
882
|
-
}, []), /* @__PURE__ */ Pe(
|
|
883
|
-
/* @__PURE__ */
|
|
884
|
-
/* @__PURE__ */
|
|
989
|
+
}, []), /* @__PURE__ */ Pe(re, { children: [
|
|
990
|
+
/* @__PURE__ */ E(je, { ref: $ }),
|
|
991
|
+
/* @__PURE__ */ E(
|
|
885
992
|
"tbw-grid",
|
|
886
993
|
{
|
|
887
|
-
ref: (
|
|
888
|
-
if (f.current =
|
|
889
|
-
const
|
|
890
|
-
I && (
|
|
994
|
+
ref: (a) => {
|
|
995
|
+
if (f.current = a, a) {
|
|
996
|
+
const d = a;
|
|
997
|
+
I && (d.gridConfig = I), r && (d.rows = r), N && (d.columns = N);
|
|
891
998
|
}
|
|
892
999
|
},
|
|
893
|
-
class:
|
|
894
|
-
style:
|
|
895
|
-
children: /* @__PURE__ */
|
|
1000
|
+
class: w,
|
|
1001
|
+
style: D,
|
|
1002
|
+
children: /* @__PURE__ */ E(Ce.Provider, { value: f, children: x })
|
|
896
1003
|
}
|
|
897
1004
|
)
|
|
898
1005
|
] });
|
|
899
1006
|
});
|
|
900
|
-
function
|
|
1007
|
+
function wt(n) {
|
|
901
1008
|
const {
|
|
902
1009
|
field: e,
|
|
903
1010
|
header: t,
|
|
904
1011
|
type: r,
|
|
905
1012
|
editable: o,
|
|
906
|
-
sortable:
|
|
907
|
-
resizable:
|
|
908
|
-
width:
|
|
1013
|
+
sortable: s,
|
|
1014
|
+
resizable: i,
|
|
1015
|
+
width: c,
|
|
909
1016
|
minWidth: g,
|
|
910
|
-
hidden:
|
|
911
|
-
lockVisible:
|
|
912
|
-
children:
|
|
913
|
-
editor:
|
|
914
|
-
options:
|
|
915
|
-
multi:
|
|
916
|
-
format:
|
|
917
|
-
} = n, u = k(null), h =
|
|
1017
|
+
hidden: l,
|
|
1018
|
+
lockVisible: C,
|
|
1019
|
+
children: R,
|
|
1020
|
+
editor: m,
|
|
1021
|
+
options: w,
|
|
1022
|
+
multi: D,
|
|
1023
|
+
format: x
|
|
1024
|
+
} = n, u = k(null), h = S(
|
|
918
1025
|
(f) => {
|
|
919
|
-
u.current = f, f && (
|
|
1026
|
+
u.current = f, f && (R && Qe(f, R), m && Xe(f, m));
|
|
920
1027
|
},
|
|
921
|
-
[
|
|
922
|
-
),
|
|
1028
|
+
[R, m, e]
|
|
1029
|
+
), v = typeof c == "number" ? `${c}px` : c, p = {
|
|
923
1030
|
field: e,
|
|
924
1031
|
ref: h
|
|
925
1032
|
};
|
|
926
|
-
return t !== void 0 && (
|
|
1033
|
+
return t !== void 0 && (p.header = t), r !== void 0 && (p.type = r), o !== void 0 && (p.editable = o), s !== void 0 && (p.sortable = s), i !== void 0 && (p.resizable = i), v !== void 0 && (p.width = v), g !== void 0 && (p["min-width"] = g), l !== void 0 && (p.hidden = l), C !== void 0 && (p["lock-visible"] = C), D !== void 0 && (p.multi = D), x && (p["data-has-format"] = "true"), w && (p["data-has-options"] = "true"), /* @__PURE__ */ E("tbw-grid-column", { ...p });
|
|
927
1034
|
}
|
|
928
|
-
function
|
|
929
|
-
return /* @__PURE__ */
|
|
1035
|
+
function bt({ children: n }) {
|
|
1036
|
+
return /* @__PURE__ */ E("tbw-grid-tool-buttons", { children: n });
|
|
930
1037
|
}
|
|
931
|
-
const
|
|
1038
|
+
const Pt = ({ icons: n, defaults: e, children: t }) => {
|
|
932
1039
|
let r = t;
|
|
933
|
-
return e && (r = /* @__PURE__ */
|
|
1040
|
+
return e && (r = /* @__PURE__ */ E(Be, { defaults: e, children: r })), n && (r = /* @__PURE__ */ E(Ne, { icons: n, children: r })), /* @__PURE__ */ E(re, { children: r });
|
|
934
1041
|
};
|
|
935
|
-
function
|
|
936
|
-
const e = k(null), [t, r] =
|
|
1042
|
+
function Et(n) {
|
|
1043
|
+
const e = k(null), [t, r] = ue(!1), [o, s] = ue(null), i = k(null), c = S(() => n ? (i.current ??= document.querySelector(n), i.current) : e.current?.element ?? null, [n]);
|
|
937
1044
|
P(() => {
|
|
938
1045
|
let u = !0;
|
|
939
1046
|
return (async () => {
|
|
940
1047
|
try {
|
|
941
1048
|
if (n) {
|
|
942
|
-
const
|
|
943
|
-
if (!
|
|
944
|
-
if (
|
|
1049
|
+
const v = document.querySelector(n);
|
|
1050
|
+
if (!v) return;
|
|
1051
|
+
if (i.current = v, await v.ready?.(), u) {
|
|
945
1052
|
r(!0);
|
|
946
|
-
const
|
|
947
|
-
u &&
|
|
1053
|
+
const p = await v.getConfig?.();
|
|
1054
|
+
u && p && s(p);
|
|
948
1055
|
}
|
|
949
1056
|
} else {
|
|
950
|
-
const
|
|
951
|
-
if (!
|
|
952
|
-
if (await
|
|
1057
|
+
const v = e.current;
|
|
1058
|
+
if (!v) return;
|
|
1059
|
+
if (await v.ready?.(), u) {
|
|
953
1060
|
r(!0);
|
|
954
|
-
const
|
|
955
|
-
u &&
|
|
1061
|
+
const p = await v.getConfig?.();
|
|
1062
|
+
u && p && s(p);
|
|
956
1063
|
}
|
|
957
1064
|
}
|
|
958
1065
|
} catch {
|
|
@@ -961,86 +1068,100 @@ function Pt(n) {
|
|
|
961
1068
|
u = !1;
|
|
962
1069
|
};
|
|
963
1070
|
}, [n]);
|
|
964
|
-
const g =
|
|
965
|
-
const u =
|
|
1071
|
+
const g = S(async () => {
|
|
1072
|
+
const u = c();
|
|
966
1073
|
if (u)
|
|
967
1074
|
return await u.getConfig?.() ?? null;
|
|
968
1075
|
const h = e.current;
|
|
969
1076
|
return h ? await h.getConfig?.() ?? null : null;
|
|
970
|
-
}, [
|
|
971
|
-
const u =
|
|
1077
|
+
}, [c]), l = S(async () => {
|
|
1078
|
+
const u = c();
|
|
972
1079
|
if (u) {
|
|
973
1080
|
await u.forceLayout?.();
|
|
974
1081
|
return;
|
|
975
1082
|
}
|
|
976
1083
|
const h = e.current;
|
|
977
1084
|
h && await h.forceLayout?.();
|
|
978
|
-
}, [
|
|
1085
|
+
}, [c]), C = S(
|
|
979
1086
|
async (u) => {
|
|
980
|
-
const h =
|
|
1087
|
+
const h = c();
|
|
981
1088
|
if (h) {
|
|
982
1089
|
await h.toggleGroup?.(u);
|
|
983
1090
|
return;
|
|
984
1091
|
}
|
|
985
|
-
const
|
|
986
|
-
|
|
1092
|
+
const v = e.current;
|
|
1093
|
+
v && await v.toggleGroup?.(u);
|
|
987
1094
|
},
|
|
988
|
-
[
|
|
989
|
-
),
|
|
990
|
-
(u) =>
|
|
991
|
-
[
|
|
992
|
-
),
|
|
993
|
-
((u) =>
|
|
994
|
-
[
|
|
995
|
-
),
|
|
1095
|
+
[c]
|
|
1096
|
+
), R = S(
|
|
1097
|
+
(u) => c()?.getPlugin?.(u),
|
|
1098
|
+
[c]
|
|
1099
|
+
), m = S(
|
|
1100
|
+
((u) => c()?.getPluginByName?.(u)),
|
|
1101
|
+
[c]
|
|
1102
|
+
), w = S(
|
|
996
1103
|
(u, h) => {
|
|
997
|
-
const
|
|
998
|
-
if (
|
|
999
|
-
|
|
1104
|
+
const v = c();
|
|
1105
|
+
if (v) {
|
|
1106
|
+
v.registerStyles?.(u, h);
|
|
1000
1107
|
return;
|
|
1001
1108
|
}
|
|
1002
1109
|
e.current?.registerStyles?.(u, h);
|
|
1003
1110
|
},
|
|
1004
|
-
[
|
|
1005
|
-
),
|
|
1111
|
+
[c]
|
|
1112
|
+
), D = S(
|
|
1006
1113
|
(u) => {
|
|
1007
|
-
const h =
|
|
1114
|
+
const h = c();
|
|
1008
1115
|
if (h) {
|
|
1009
1116
|
h.unregisterStyles?.(u);
|
|
1010
1117
|
return;
|
|
1011
1118
|
}
|
|
1012
1119
|
e.current?.unregisterStyles?.(u);
|
|
1013
1120
|
},
|
|
1014
|
-
[
|
|
1015
|
-
),
|
|
1121
|
+
[c]
|
|
1122
|
+
), x = S(() => o?.columns ? o.columns.filter((u) => !u.hidden) : [], [o]);
|
|
1016
1123
|
return {
|
|
1017
1124
|
ref: e,
|
|
1018
|
-
element:
|
|
1125
|
+
element: c(),
|
|
1019
1126
|
isReady: t,
|
|
1020
1127
|
config: o,
|
|
1021
1128
|
getConfig: g,
|
|
1022
|
-
forceLayout:
|
|
1023
|
-
toggleGroup:
|
|
1024
|
-
getPlugin:
|
|
1025
|
-
getPluginByName:
|
|
1026
|
-
registerStyles:
|
|
1027
|
-
unregisterStyles:
|
|
1028
|
-
getVisibleColumns:
|
|
1129
|
+
forceLayout: l,
|
|
1130
|
+
toggleGroup: C,
|
|
1131
|
+
getPlugin: R,
|
|
1132
|
+
getPluginByName: m,
|
|
1133
|
+
registerStyles: w,
|
|
1134
|
+
unregisterStyles: D,
|
|
1135
|
+
getVisibleColumns: x
|
|
1029
1136
|
};
|
|
1030
1137
|
}
|
|
1138
|
+
function St(n, e = {}) {
|
|
1139
|
+
const { open: t = !0, gridElement: r } = e, o = L(Ce);
|
|
1140
|
+
P(() => {
|
|
1141
|
+
if (!t) return;
|
|
1142
|
+
const s = n.current;
|
|
1143
|
+
if (!s) return;
|
|
1144
|
+
const i = r ?? s.closest("tbw-grid") ?? o?.current ?? null;
|
|
1145
|
+
if (i)
|
|
1146
|
+
return i.registerExternalFocusContainer?.(s), () => {
|
|
1147
|
+
i.unregisterExternalFocusContainer?.(s);
|
|
1148
|
+
};
|
|
1149
|
+
}, [t, r, o, n]);
|
|
1150
|
+
}
|
|
1031
1151
|
export {
|
|
1032
1152
|
Rt as DataGrid,
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1153
|
+
rt as GridAdapter,
|
|
1154
|
+
wt as GridColumn,
|
|
1155
|
+
Ye as GridDetailPanel,
|
|
1156
|
+
Ne as GridIconProvider,
|
|
1157
|
+
Pt as GridProvider,
|
|
1158
|
+
He as GridResponsiveCard,
|
|
1159
|
+
bt as GridToolButtons,
|
|
1160
|
+
Ct as GridToolPanel,
|
|
1161
|
+
Be as GridTypeProvider,
|
|
1162
|
+
Et as useGrid,
|
|
1163
|
+
yt as useGridIcons,
|
|
1164
|
+
St as useGridOverlay,
|
|
1165
|
+
ht as useGridTypeDefaults,
|
|
1166
|
+
vt as useTypeDefault
|
|
1046
1167
|
};
|