@toolbox-web/grid-react 1.2.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/README.md +7 -31
- package/features/index.d.ts.map +1 -1
- package/features/index.js +1 -0
- package/features/row-drag-drop.d.ts +1 -0
- package/features/row-drag-drop.d.ts.map +1 -0
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +532 -406
- package/lib/data-grid.d.ts.map +1 -1
- package/lib/event-props.d.ts +27 -1
- package/lib/event-props.d.ts.map +1 -1
- package/lib/feature-props.d.ts +19 -1
- package/lib/feature-props.d.ts.map +1 -1
- 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",
|
|
@@ -49,6 +49,10 @@ const W = {
|
|
|
49
49
|
onColumnStateChange: "column-state-change",
|
|
50
50
|
onSelectionChange: "selection-change",
|
|
51
51
|
onRowMove: "row-move",
|
|
52
|
+
onRowDragStart: "row-drag-start",
|
|
53
|
+
onRowDragEnd: "row-drag-end",
|
|
54
|
+
onRowDrop: "row-drop",
|
|
55
|
+
onRowTransfer: "row-transfer",
|
|
52
56
|
onGroupToggle: "group-toggle",
|
|
53
57
|
onTreeExpand: "tree-expand",
|
|
54
58
|
onDetailExpand: "detail-expand",
|
|
@@ -60,135 +64,178 @@ const W = {
|
|
|
60
64
|
onPrintStart: "print-start",
|
|
61
65
|
onPrintComplete: "print-complete",
|
|
62
66
|
onTbwScroll: "tbw-scroll"
|
|
63
|
-
},
|
|
64
|
-
function
|
|
65
|
-
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);
|
|
66
70
|
}
|
|
67
|
-
const
|
|
68
|
-
function
|
|
71
|
+
const Ie = ne, J = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new Map();
|
|
72
|
+
function Re(n) {
|
|
69
73
|
const e = n.querySelector("tbw-grid-responsive-card");
|
|
70
74
|
if (e) {
|
|
71
|
-
const r =
|
|
75
|
+
const r = J.get(e);
|
|
72
76
|
if (r) return r;
|
|
73
77
|
}
|
|
74
78
|
const t = n.id || n.getAttribute("data-grid-id");
|
|
75
79
|
if (t)
|
|
76
|
-
return
|
|
80
|
+
return Y.get(t);
|
|
77
81
|
}
|
|
78
|
-
function
|
|
79
|
-
const { children: e, cardRowHeight: t = "auto" } = n, r = k(null), o =
|
|
80
|
-
(
|
|
81
|
-
if (r.current =
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
const g =
|
|
86
|
-
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);
|
|
87
91
|
}
|
|
88
92
|
},
|
|
89
93
|
[e]
|
|
90
94
|
);
|
|
91
95
|
P(() => () => {
|
|
92
|
-
const
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
const g =
|
|
98
|
-
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);
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
105
|
}, []);
|
|
102
|
-
const
|
|
103
|
-
return /* @__PURE__ */
|
|
106
|
+
const s = t === "auto" ? "auto" : String(t);
|
|
107
|
+
return /* @__PURE__ */ E("tbw-grid-responsive-card", { ref: o, cardRowHeight: s });
|
|
108
|
+
}
|
|
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);
|
|
104
113
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
function mt() {
|
|
108
|
-
return O(z);
|
|
114
|
+
function vt(n) {
|
|
115
|
+
return L(O)?.[n];
|
|
109
116
|
}
|
|
110
|
-
|
|
111
|
-
|
|
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
|
+
}
|
|
112
129
|
}
|
|
113
|
-
const
|
|
114
|
-
const r = k(/* @__PURE__ */ new Map()), [, o] =
|
|
115
|
-
|
|
116
|
-
|
|
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();
|
|
117
134
|
}));
|
|
118
135
|
}, g = () => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
let p = !1;
|
|
122
|
-
for (const [C, R] of r.current)
|
|
123
|
-
R.container.isConnected || (r.current.delete(C), p = !0);
|
|
124
|
-
p && V(o);
|
|
136
|
+
i.current || (i.current = requestAnimationFrame(() => {
|
|
137
|
+
i.current = 0, o();
|
|
125
138
|
}));
|
|
139
|
+
}, l = (m, w) => {
|
|
140
|
+
console.error(`[grid-react] Portal "${m}" crashed; dropping.`, w), r.current.delete(m), g();
|
|
126
141
|
};
|
|
127
142
|
ve(
|
|
128
143
|
t,
|
|
129
144
|
() => ({
|
|
130
|
-
renderPortal(
|
|
131
|
-
r.current.set(
|
|
145
|
+
renderPortal(m, w, D) {
|
|
146
|
+
r.current.set(m, { container: w, element: D }), c();
|
|
132
147
|
},
|
|
133
|
-
removePortal(
|
|
134
|
-
r.current.delete(
|
|
148
|
+
removePortal(m, w) {
|
|
149
|
+
r.current.delete(m) && (w ? ge(o) : c());
|
|
135
150
|
},
|
|
136
151
|
clear() {
|
|
137
|
-
r.current.size > 0 && (r.current.clear(),
|
|
152
|
+
r.current.size > 0 && (r.current.clear(), i.current && (cancelAnimationFrame(i.current), i.current = 0), c());
|
|
138
153
|
}
|
|
139
154
|
}),
|
|
140
155
|
// forceRender is stable (useReducer dispatch), refs are stable
|
|
141
156
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
142
157
|
[]
|
|
143
158
|
);
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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();
|
|
149
182
|
function ze(n) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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));
|
|
153
187
|
}
|
|
154
188
|
}
|
|
155
|
-
function
|
|
189
|
+
function $e(n) {
|
|
156
190
|
const e = /* @__PURE__ */ new WeakMap();
|
|
157
191
|
return (t) => {
|
|
158
192
|
const r = t.cellEl;
|
|
159
193
|
if (r) {
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
162
|
-
|
|
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
|
+
}
|
|
163
200
|
}
|
|
164
201
|
const o = document.createElement("div");
|
|
165
202
|
o.className = "react-cell-renderer", o.style.display = "contents";
|
|
166
|
-
const
|
|
167
|
-
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;
|
|
168
205
|
};
|
|
169
206
|
}
|
|
170
|
-
function
|
|
207
|
+
function Ue(n) {
|
|
171
208
|
return (e) => {
|
|
172
209
|
const t = document.createElement("div");
|
|
173
210
|
t.className = "react-cell-editor", t.style.display = "contents";
|
|
174
|
-
const
|
|
175
|
-
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;
|
|
176
223
|
};
|
|
177
224
|
}
|
|
178
|
-
function
|
|
225
|
+
function _e(n) {
|
|
179
226
|
return (e) => {
|
|
180
227
|
const t = document.createElement("div");
|
|
181
228
|
t.className = "react-header-renderer", t.style.display = "contents";
|
|
182
|
-
const r =
|
|
183
|
-
return
|
|
229
|
+
const r = b(t, n(e));
|
|
230
|
+
return M.set(t, { key: r }), t;
|
|
184
231
|
};
|
|
185
232
|
}
|
|
186
|
-
function
|
|
233
|
+
function We(n) {
|
|
187
234
|
return (e) => {
|
|
188
235
|
const t = document.createElement("div");
|
|
189
236
|
t.className = "react-header-label-renderer", t.style.display = "contents";
|
|
190
|
-
const r =
|
|
191
|
-
return
|
|
237
|
+
const r = b(t, n(e));
|
|
238
|
+
return M.set(t, { key: r }), t;
|
|
192
239
|
};
|
|
193
240
|
}
|
|
194
241
|
function Ve(n) {
|
|
@@ -198,13 +245,13 @@ function Ve(n) {
|
|
|
198
245
|
return t;
|
|
199
246
|
const r = document.createElement("div");
|
|
200
247
|
r.className = "react-loading-renderer", r.style.display = "contents";
|
|
201
|
-
const o =
|
|
202
|
-
return
|
|
248
|
+
const o = b(r, t);
|
|
249
|
+
return M.set(r, { key: o }), r;
|
|
203
250
|
};
|
|
204
251
|
}
|
|
205
|
-
function
|
|
252
|
+
function we(n) {
|
|
206
253
|
if (!n) return;
|
|
207
|
-
if (n[
|
|
254
|
+
if (n[W]) return n;
|
|
208
255
|
if (n.loadingRenderer && typeof n.loadingRenderer == "function") {
|
|
209
256
|
const r = n.loadingRenderer;
|
|
210
257
|
n = {
|
|
@@ -214,82 +261,82 @@ function Re(n) {
|
|
|
214
261
|
}
|
|
215
262
|
if (!n.columns) {
|
|
216
263
|
const r = n;
|
|
217
|
-
return r[
|
|
264
|
+
return r[W] = !0, r;
|
|
218
265
|
}
|
|
219
266
|
const e = n.columns.map((r) => {
|
|
220
|
-
const { renderer: o, editor:
|
|
221
|
-
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;
|
|
222
269
|
}), t = {
|
|
223
270
|
...n,
|
|
224
271
|
columns: e
|
|
225
272
|
};
|
|
226
|
-
return t[
|
|
273
|
+
return t[W] = !0, t;
|
|
227
274
|
}
|
|
228
|
-
const
|
|
229
|
-
function
|
|
275
|
+
const Z = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new Map();
|
|
276
|
+
function Je(n) {
|
|
230
277
|
const e = n.querySelector("tbw-grid-detail");
|
|
231
278
|
if (e) {
|
|
232
|
-
const r =
|
|
279
|
+
const r = Z.get(e);
|
|
233
280
|
if (r) return r;
|
|
234
281
|
}
|
|
235
282
|
const t = n.id || n.getAttribute("data-grid-id");
|
|
236
283
|
if (t)
|
|
237
|
-
return
|
|
284
|
+
return Q.get(t);
|
|
238
285
|
}
|
|
239
|
-
function
|
|
240
|
-
const { children: e, showExpandColumn: t = !0, animation: r = "slide" } = n, o = k(null),
|
|
241
|
-
(
|
|
242
|
-
if (o.current =
|
|
243
|
-
|
|
244
|
-
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");
|
|
245
292
|
if (g) {
|
|
246
|
-
const
|
|
247
|
-
|
|
293
|
+
const l = g.id || g.getAttribute("data-grid-id");
|
|
294
|
+
l && Q.set(l, e);
|
|
248
295
|
}
|
|
249
296
|
},
|
|
250
297
|
[e]
|
|
251
298
|
);
|
|
252
299
|
return P(() => () => {
|
|
253
|
-
const
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
const g =
|
|
300
|
+
const c = o.current;
|
|
301
|
+
if (c) {
|
|
302
|
+
Z.delete(c);
|
|
303
|
+
const g = c.closest("tbw-grid");
|
|
257
304
|
if (g) {
|
|
258
|
-
const
|
|
259
|
-
|
|
305
|
+
const C = g.id || g.getAttribute("data-grid-id");
|
|
306
|
+
C && Q.delete(C);
|
|
260
307
|
}
|
|
261
|
-
const
|
|
262
|
-
|
|
308
|
+
const l = c.parentNode;
|
|
309
|
+
l && l.contains(c);
|
|
263
310
|
}
|
|
264
|
-
}, []), /* @__PURE__ */
|
|
311
|
+
}, []), /* @__PURE__ */ E(
|
|
265
312
|
"tbw-grid-detail",
|
|
266
313
|
{
|
|
267
|
-
ref:
|
|
314
|
+
ref: s,
|
|
268
315
|
showExpandColumn: t ? void 0 : "false",
|
|
269
316
|
animation: r === !1 ? "false" : r
|
|
270
317
|
}
|
|
271
318
|
);
|
|
272
319
|
}
|
|
273
|
-
|
|
274
|
-
const
|
|
275
|
-
function
|
|
276
|
-
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);
|
|
277
324
|
if (e) return e;
|
|
278
325
|
const t = n.id;
|
|
279
326
|
if (t)
|
|
280
|
-
return
|
|
327
|
+
return ee.get(t);
|
|
281
328
|
}
|
|
282
|
-
function
|
|
283
|
-
const { id: e, title: t, icon: r, tooltip: o, order:
|
|
284
|
-
(
|
|
285
|
-
|
|
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));
|
|
286
333
|
},
|
|
287
|
-
[
|
|
334
|
+
[i, e]
|
|
288
335
|
);
|
|
289
336
|
return P(() => () => {
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
}, [e]), /* @__PURE__ */
|
|
337
|
+
const l = c.current;
|
|
338
|
+
l && (X.delete(l), e && ee.delete(e));
|
|
339
|
+
}, [e]), /* @__PURE__ */ E(
|
|
293
340
|
"tbw-grid-tool-panel",
|
|
294
341
|
{
|
|
295
342
|
ref: g,
|
|
@@ -297,48 +344,80 @@ function ht(n) {
|
|
|
297
344
|
title: t,
|
|
298
345
|
icon: r,
|
|
299
346
|
tooltip: o,
|
|
300
|
-
order:
|
|
347
|
+
order: s?.toString()
|
|
301
348
|
}
|
|
302
349
|
);
|
|
303
350
|
}
|
|
304
|
-
const G = /* @__PURE__ */ new WeakMap(),
|
|
305
|
-
function
|
|
351
|
+
const G = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new Map();
|
|
352
|
+
function Qe(n, e) {
|
|
306
353
|
const t = n.getAttribute("field"), r = G.get(n) ?? {};
|
|
307
354
|
if (r.renderer = e, G.set(n, r), t) {
|
|
308
|
-
const o =
|
|
309
|
-
o.renderer = e,
|
|
355
|
+
const o = K.get(t) ?? {};
|
|
356
|
+
o.renderer = e, K.set(t, o);
|
|
310
357
|
}
|
|
311
358
|
}
|
|
312
|
-
function
|
|
359
|
+
function Xe(n, e) {
|
|
313
360
|
const t = n.getAttribute("field"), r = G.get(n) ?? {};
|
|
314
361
|
if (r.editor = e, G.set(n, r), t) {
|
|
315
|
-
const o =
|
|
316
|
-
o.editor = e,
|
|
362
|
+
const o = K.get(t) ?? {};
|
|
363
|
+
o.editor = e, K.set(t, o);
|
|
317
364
|
}
|
|
318
365
|
}
|
|
319
|
-
function
|
|
366
|
+
function et(n) {
|
|
320
367
|
let e = G.get(n)?.renderer;
|
|
321
368
|
if (!e) {
|
|
322
369
|
const t = n.getAttribute("field");
|
|
323
|
-
t && (e =
|
|
370
|
+
t && (e = K.get(t)?.renderer);
|
|
324
371
|
}
|
|
325
372
|
return e;
|
|
326
373
|
}
|
|
327
|
-
function
|
|
374
|
+
function tt(n) {
|
|
328
375
|
let e = G.get(n)?.editor;
|
|
329
376
|
if (!e) {
|
|
330
377
|
const t = n.getAttribute("field");
|
|
331
|
-
t && (e =
|
|
378
|
+
t && (e = K.get(t)?.editor);
|
|
332
379
|
}
|
|
333
380
|
return e;
|
|
334
381
|
}
|
|
335
|
-
class
|
|
382
|
+
class rt {
|
|
336
383
|
/** Portal keys for all managed portals (for cleanup on destroy). */
|
|
337
384
|
allPortalKeys = /* @__PURE__ */ new Set();
|
|
338
385
|
/** Portal keys for editor-specific portals (for per-cell cleanup via releaseCell). */
|
|
339
386
|
editorPortalKeys = /* @__PURE__ */ new Set();
|
|
340
387
|
/** Maps portal keys to their containers (for container-based lookups in releaseCell/unmount). */
|
|
341
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();
|
|
342
421
|
typeDefaults = null;
|
|
343
422
|
/**
|
|
344
423
|
* Sets the type defaults map for this adapter.
|
|
@@ -355,7 +434,7 @@ class et {
|
|
|
355
434
|
* Converts React renderer/editor functions to DOM-returning functions.
|
|
356
435
|
*/
|
|
357
436
|
processConfig(e) {
|
|
358
|
-
return
|
|
437
|
+
return we(e) ?? e;
|
|
359
438
|
}
|
|
360
439
|
/**
|
|
361
440
|
* Determines if this adapter can handle the given element.
|
|
@@ -365,11 +444,11 @@ class et {
|
|
|
365
444
|
const t = e.getAttribute("field");
|
|
366
445
|
let r = G.get(e);
|
|
367
446
|
if (!r && t) {
|
|
368
|
-
const
|
|
369
|
-
|
|
447
|
+
const i = K.get(t);
|
|
448
|
+
i && (i.renderer || i.editor) && (r = i, G.set(e, r));
|
|
370
449
|
}
|
|
371
|
-
const o = r?.renderer !== void 0,
|
|
372
|
-
return r !== void 0 && (o ||
|
|
450
|
+
const o = r?.renderer !== void 0, s = r?.editor !== void 0;
|
|
451
|
+
return r !== void 0 && (o || s);
|
|
373
452
|
}
|
|
374
453
|
/**
|
|
375
454
|
* Creates a view renderer function that renders a React component
|
|
@@ -383,35 +462,38 @@ class et {
|
|
|
383
462
|
* allowing the grid to use its default rendering.
|
|
384
463
|
*/
|
|
385
464
|
createRenderer(e) {
|
|
386
|
-
const t =
|
|
465
|
+
const t = et(e);
|
|
387
466
|
if (!t)
|
|
388
467
|
return;
|
|
389
468
|
const r = e.closest("tbw-grid"), o = /* @__PURE__ */ new WeakMap();
|
|
390
|
-
return (
|
|
391
|
-
const
|
|
392
|
-
if (
|
|
393
|
-
const
|
|
394
|
-
if (
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
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),
|
|
401
483
|
void 0,
|
|
402
484
|
r ?? void 0
|
|
403
485
|
);
|
|
404
|
-
return o.set(
|
|
486
|
+
return o.set(i, { portalKey: R, container: C }), this.trackPortal(R, C, !1), C;
|
|
405
487
|
}
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
const g =
|
|
409
|
-
|
|
410
|
-
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),
|
|
411
493
|
void 0,
|
|
412
494
|
r ?? void 0
|
|
413
495
|
);
|
|
414
|
-
return this.trackPortal(g,
|
|
496
|
+
return this.trackPortal(g, c, !1), c;
|
|
415
497
|
};
|
|
416
498
|
}
|
|
417
499
|
/**
|
|
@@ -419,20 +501,29 @@ class et {
|
|
|
419
501
|
* with commit/cancel callbacks passed as props.
|
|
420
502
|
*/
|
|
421
503
|
createEditor(e) {
|
|
422
|
-
const t =
|
|
504
|
+
const t = tt(e);
|
|
423
505
|
if (!t)
|
|
424
506
|
return () => document.createElement("div");
|
|
425
507
|
const r = e.closest("tbw-grid") ?? void 0;
|
|
426
508
|
return (o) => {
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
const
|
|
430
|
-
|
|
509
|
+
const s = document.createElement("div");
|
|
510
|
+
s.className = "react-cell-editor", s.style.display = "contents";
|
|
511
|
+
const i = b(
|
|
512
|
+
s,
|
|
431
513
|
t(o),
|
|
432
514
|
void 0,
|
|
433
515
|
r
|
|
434
516
|
);
|
|
435
|
-
|
|
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;
|
|
436
527
|
};
|
|
437
528
|
}
|
|
438
529
|
/**
|
|
@@ -440,18 +531,18 @@ class et {
|
|
|
440
531
|
* Renders React components for expandable detail rows.
|
|
441
532
|
*/
|
|
442
533
|
createDetailRenderer(e) {
|
|
443
|
-
const t =
|
|
534
|
+
const t = Je(e);
|
|
444
535
|
if (t)
|
|
445
536
|
return (r, o) => {
|
|
446
|
-
const
|
|
447
|
-
|
|
448
|
-
const
|
|
449
|
-
|
|
537
|
+
const s = document.createElement("div");
|
|
538
|
+
s.className = "react-detail-panel";
|
|
539
|
+
const c = b(
|
|
540
|
+
s,
|
|
450
541
|
t({ row: r, rowIndex: o }),
|
|
451
542
|
void 0,
|
|
452
543
|
e
|
|
453
544
|
);
|
|
454
|
-
return this.trackPortal(
|
|
545
|
+
return this.trackPortal(c, s, !1), s;
|
|
455
546
|
};
|
|
456
547
|
}
|
|
457
548
|
/**
|
|
@@ -468,18 +559,18 @@ class et {
|
|
|
468
559
|
* Renders React components for card layout in responsive mode.
|
|
469
560
|
*/
|
|
470
561
|
createResponsiveCardRenderer(e) {
|
|
471
|
-
const t =
|
|
562
|
+
const t = Re(e);
|
|
472
563
|
if (t)
|
|
473
564
|
return (r, o) => {
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
const
|
|
477
|
-
|
|
565
|
+
const s = document.createElement("div");
|
|
566
|
+
s.className = "react-responsive-card";
|
|
567
|
+
const c = b(
|
|
568
|
+
s,
|
|
478
569
|
t({ row: r, index: o }),
|
|
479
570
|
void 0,
|
|
480
571
|
e
|
|
481
572
|
);
|
|
482
|
-
return this.trackPortal(
|
|
573
|
+
return this.trackPortal(c, s, !1), s;
|
|
483
574
|
};
|
|
484
575
|
}
|
|
485
576
|
/**
|
|
@@ -500,16 +591,16 @@ class et {
|
|
|
500
591
|
* Renders React components into tool panel containers.
|
|
501
592
|
*/
|
|
502
593
|
createToolPanelRenderer(e) {
|
|
503
|
-
const t =
|
|
594
|
+
const t = Ze(e);
|
|
504
595
|
if (!t)
|
|
505
596
|
return;
|
|
506
597
|
const r = e.closest("tbw-grid");
|
|
507
598
|
return (o) => {
|
|
508
|
-
const
|
|
599
|
+
const i = b(o, t({
|
|
509
600
|
grid: r ?? o
|
|
510
601
|
}), void 0, r ?? void 0);
|
|
511
|
-
return this.trackPortal(
|
|
512
|
-
|
|
602
|
+
return this.trackPortal(i, o, !1), () => {
|
|
603
|
+
A(i, { sync: !0 }), this.untrackPortal(i);
|
|
513
604
|
};
|
|
514
605
|
};
|
|
515
606
|
}
|
|
@@ -556,8 +647,8 @@ class et {
|
|
|
556
647
|
return (r) => {
|
|
557
648
|
const o = document.createElement("span");
|
|
558
649
|
o.style.display = "contents";
|
|
559
|
-
const
|
|
560
|
-
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;
|
|
561
652
|
};
|
|
562
653
|
}
|
|
563
654
|
/**
|
|
@@ -568,8 +659,8 @@ class et {
|
|
|
568
659
|
return (r) => {
|
|
569
660
|
const o = document.createElement("span");
|
|
570
661
|
o.style.display = "contents";
|
|
571
|
-
const
|
|
572
|
-
return this.trackPortal(
|
|
662
|
+
const s = b(o, e(r), void 0, t);
|
|
663
|
+
return this.trackPortal(s, o, !0), o;
|
|
573
664
|
};
|
|
574
665
|
}
|
|
575
666
|
/**
|
|
@@ -578,20 +669,24 @@ class et {
|
|
|
578
669
|
*/
|
|
579
670
|
createFilterPanelRenderer(e, t) {
|
|
580
671
|
return (r, o) => {
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
const
|
|
584
|
-
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);
|
|
585
676
|
};
|
|
586
677
|
}
|
|
587
678
|
// #region Portal tracking helpers
|
|
588
679
|
/** Register a portal key for lifecycle tracking. */
|
|
589
680
|
trackPortal(e, t, r) {
|
|
590
|
-
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);
|
|
591
682
|
}
|
|
592
683
|
/** Unregister a portal key from all tracking sets. */
|
|
593
684
|
untrackPortal(e) {
|
|
594
|
-
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));
|
|
595
690
|
}
|
|
596
691
|
// #endregion
|
|
597
692
|
/**
|
|
@@ -600,19 +695,38 @@ class et {
|
|
|
600
695
|
*/
|
|
601
696
|
destroy() {
|
|
602
697
|
for (const e of this.allPortalKeys)
|
|
603
|
-
|
|
604
|
-
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();
|
|
605
702
|
}
|
|
606
703
|
/**
|
|
607
704
|
* Called when a cell's content is about to be wiped.
|
|
608
|
-
*
|
|
609
|
-
*
|
|
610
|
-
*
|
|
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.
|
|
611
724
|
*/
|
|
612
725
|
releaseCell(e) {
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
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));
|
|
616
730
|
}
|
|
617
731
|
ze(e);
|
|
618
732
|
}
|
|
@@ -620,21 +734,18 @@ class et {
|
|
|
620
734
|
* Unmount a specific container (called when cell is recycled).
|
|
621
735
|
*/
|
|
622
736
|
unmount(e) {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
H(t), this.untrackPortal(t);
|
|
626
|
-
return;
|
|
627
|
-
}
|
|
737
|
+
const t = this.containerToKey.get(e);
|
|
738
|
+
t && (A(t), this.untrackPortal(t));
|
|
628
739
|
}
|
|
629
740
|
}
|
|
630
|
-
const
|
|
741
|
+
const nt = {
|
|
631
742
|
undoRedo: ["editing"],
|
|
632
743
|
clipboard: ["selection"]
|
|
633
744
|
};
|
|
634
|
-
function
|
|
745
|
+
function ot(n) {
|
|
635
746
|
const e = new Set(n);
|
|
636
747
|
for (const t of n) {
|
|
637
|
-
const r =
|
|
748
|
+
const r = nt[t];
|
|
638
749
|
if (r)
|
|
639
750
|
for (const o of r)
|
|
640
751
|
e.has(o) || console.warn(
|
|
@@ -642,34 +753,34 @@ function rt(n) {
|
|
|
642
753
|
);
|
|
643
754
|
}
|
|
644
755
|
}
|
|
645
|
-
function
|
|
756
|
+
function it(n) {
|
|
646
757
|
const e = [];
|
|
647
758
|
for (const [t, r] of Object.entries(n))
|
|
648
759
|
r === void 0 || r === !1 || e.push(t);
|
|
649
|
-
return
|
|
760
|
+
return ot(e), xe(n);
|
|
650
761
|
}
|
|
651
|
-
let me = !1,
|
|
652
|
-
function
|
|
653
|
-
return me || (
|
|
762
|
+
let me = !1, V = null;
|
|
763
|
+
function te() {
|
|
764
|
+
return me || (V = new rt(), Ee.registerAdapter(V), me = !0), V;
|
|
654
765
|
}
|
|
655
|
-
|
|
656
|
-
function
|
|
766
|
+
te();
|
|
767
|
+
function st(n) {
|
|
657
768
|
const t = n.getPluginByName?.("masterDetail");
|
|
658
769
|
t && typeof t.refreshDetailRenderer == "function" && t.refreshDetailRenderer();
|
|
659
770
|
}
|
|
660
|
-
function
|
|
771
|
+
function ct(n, e) {
|
|
661
772
|
const t = n;
|
|
662
|
-
if (!n.querySelector("tbw-grid-responsive-card") || !
|
|
663
|
-
const
|
|
664
|
-
if (
|
|
665
|
-
const
|
|
666
|
-
|
|
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);
|
|
667
778
|
}
|
|
668
779
|
}
|
|
669
|
-
function
|
|
780
|
+
function at(n) {
|
|
670
781
|
const e = {};
|
|
671
|
-
return
|
|
672
|
-
if (
|
|
782
|
+
return Te.forEach(n, (t) => {
|
|
783
|
+
if (Ge(t)) {
|
|
673
784
|
if (t.type && t.type.displayName === "GridDetailPanel") {
|
|
674
785
|
const r = t.props;
|
|
675
786
|
e.masterDetail = {
|
|
@@ -683,22 +794,22 @@ function st(n) {
|
|
|
683
794
|
}
|
|
684
795
|
}), e;
|
|
685
796
|
}
|
|
686
|
-
const
|
|
797
|
+
const Rt = he(function(e, t) {
|
|
687
798
|
const {
|
|
688
799
|
// Core props
|
|
689
800
|
rows: r,
|
|
690
801
|
gridConfig: o,
|
|
691
|
-
columns:
|
|
692
|
-
columnDefaults:
|
|
693
|
-
fitMode:
|
|
802
|
+
columns: s,
|
|
803
|
+
columnDefaults: i,
|
|
804
|
+
fitMode: c,
|
|
694
805
|
sortable: g,
|
|
695
|
-
filterable:
|
|
696
|
-
selectable:
|
|
697
|
-
loading:
|
|
698
|
-
customStyles:
|
|
699
|
-
className:
|
|
700
|
-
style:
|
|
701
|
-
children:
|
|
806
|
+
filterable: l,
|
|
807
|
+
selectable: C,
|
|
808
|
+
loading: R,
|
|
809
|
+
customStyles: m,
|
|
810
|
+
className: w,
|
|
811
|
+
style: D,
|
|
812
|
+
children: x,
|
|
702
813
|
// Plugin props
|
|
703
814
|
plugins: u,
|
|
704
815
|
// SSR mode
|
|
@@ -706,8 +817,8 @@ const vt = he(function(e, t) {
|
|
|
706
817
|
// Legacy event handlers
|
|
707
818
|
onRowsChange: v,
|
|
708
819
|
// Feature props and event props are in ...rest
|
|
709
|
-
...
|
|
710
|
-
} = e, f = k(null),
|
|
820
|
+
...p
|
|
821
|
+
} = e, f = k(null), q = k(null), oe = L(qe), j = L(Ie), ie = [
|
|
711
822
|
"selection",
|
|
712
823
|
"editing",
|
|
713
824
|
"filtering",
|
|
@@ -716,6 +827,7 @@ const vt = he(function(e, t) {
|
|
|
716
827
|
"contextMenu",
|
|
717
828
|
"reorderColumns",
|
|
718
829
|
"reorderRows",
|
|
830
|
+
"rowDragDrop",
|
|
719
831
|
"visibility",
|
|
720
832
|
"undoRedo",
|
|
721
833
|
"tree",
|
|
@@ -731,102 +843,102 @@ const vt = he(function(e, t) {
|
|
|
731
843
|
"pivot",
|
|
732
844
|
"serverSide",
|
|
733
845
|
"tooltip"
|
|
734
|
-
],
|
|
735
|
-
const
|
|
736
|
-
return
|
|
737
|
-
}).filter(Boolean).join("|"), [
|
|
738
|
-
const
|
|
739
|
-
for (const
|
|
740
|
-
|
|
741
|
-
return
|
|
742
|
-
}, [
|
|
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(() => {
|
|
743
855
|
if (u) {
|
|
744
|
-
const
|
|
745
|
-
return [...u, ...
|
|
856
|
+
const a = new Set(u.map((y) => y.name)), d = z.filter((y) => !a.has(y.name));
|
|
857
|
+
return [...u, ...d];
|
|
746
858
|
}
|
|
747
|
-
return
|
|
748
|
-
}, [u,
|
|
749
|
-
if (!
|
|
750
|
-
const
|
|
751
|
-
return
|
|
752
|
-
...
|
|
753
|
-
...
|
|
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
|
|
754
866
|
// Individual column props override defaults
|
|
755
|
-
})) :
|
|
756
|
-
}, [
|
|
757
|
-
const
|
|
758
|
-
if (g !== void 0 && (
|
|
759
|
-
const y =
|
|
760
|
-
|
|
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 };
|
|
761
873
|
}
|
|
762
|
-
if (
|
|
763
|
-
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));
|
|
764
876
|
return {
|
|
765
|
-
...
|
|
766
|
-
...
|
|
767
|
-
plugins: [...y, ...
|
|
877
|
+
...a,
|
|
878
|
+
...d,
|
|
879
|
+
plugins: [...y, ...U]
|
|
768
880
|
};
|
|
769
881
|
}
|
|
770
|
-
return
|
|
771
|
-
}, [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]);
|
|
772
884
|
P(() => {
|
|
773
|
-
|
|
774
|
-
}, [
|
|
885
|
+
te().setTypeDefaults(oe);
|
|
886
|
+
}, [oe]), P(() => {
|
|
775
887
|
f.current && (f.current.rows = r);
|
|
776
888
|
}, [r]), P(() => {
|
|
777
889
|
f.current && I && (f.current.gridConfig = I);
|
|
778
890
|
}, [I]), P(() => {
|
|
779
|
-
f.current &&
|
|
780
|
-
}, [
|
|
781
|
-
f.current &&
|
|
782
|
-
}, [
|
|
783
|
-
f.current &&
|
|
784
|
-
}, [
|
|
785
|
-
const
|
|
786
|
-
if (!
|
|
787
|
-
const
|
|
788
|
-
|
|
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);
|
|
789
901
|
let y = !1;
|
|
790
|
-
const
|
|
791
|
-
y || (typeof
|
|
902
|
+
const H = requestAnimationFrame(() => {
|
|
903
|
+
y || (typeof a.refreshColumns == "function" && a.refreshColumns(), typeof a.refreshShellHeader == "function" && a.refreshShellHeader());
|
|
792
904
|
});
|
|
793
905
|
return () => {
|
|
794
|
-
y = !0, cancelAnimationFrame(
|
|
906
|
+
y = !0, cancelAnimationFrame(H);
|
|
795
907
|
};
|
|
796
908
|
}, []), P(() => {
|
|
797
|
-
if (!f.current || !
|
|
798
|
-
const
|
|
909
|
+
if (!f.current || !m) return;
|
|
910
|
+
const a = f.current, d = "react-custom-styles";
|
|
799
911
|
let y = !0;
|
|
800
|
-
return
|
|
801
|
-
y &&
|
|
912
|
+
return a.ready?.().then(() => {
|
|
913
|
+
y && m && (a.registerStyles?.(d, m), q.current = d);
|
|
802
914
|
}), () => {
|
|
803
|
-
y = !1,
|
|
915
|
+
y = !1, q.current && (a.unregisterStyles?.(q.current), q.current = null);
|
|
804
916
|
};
|
|
805
|
-
}, [
|
|
806
|
-
const
|
|
807
|
-
if (!
|
|
808
|
-
const
|
|
809
|
-
return v &&
|
|
810
|
-
|
|
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());
|
|
811
923
|
};
|
|
812
924
|
}, [v]);
|
|
813
|
-
const
|
|
814
|
-
for (const
|
|
815
|
-
|
|
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];
|
|
816
928
|
P(() => {
|
|
817
|
-
const
|
|
818
|
-
if (!
|
|
819
|
-
const
|
|
820
|
-
for (const [y,
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
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);
|
|
824
936
|
})
|
|
825
937
|
);
|
|
826
938
|
return () => {
|
|
827
|
-
|
|
939
|
+
d.forEach((y) => y());
|
|
828
940
|
};
|
|
829
|
-
}, [
|
|
941
|
+
}, [le]), ve(
|
|
830
942
|
t,
|
|
831
943
|
() => ({
|
|
832
944
|
get element() {
|
|
@@ -841,26 +953,26 @@ const vt = he(function(e, t) {
|
|
|
841
953
|
async forceLayout() {
|
|
842
954
|
return f.current?.forceLayout?.();
|
|
843
955
|
},
|
|
844
|
-
async toggleGroup(
|
|
845
|
-
return f.current?.toggleGroup?.(
|
|
956
|
+
async toggleGroup(a) {
|
|
957
|
+
return f.current?.toggleGroup?.(a);
|
|
846
958
|
},
|
|
847
|
-
registerStyles(
|
|
848
|
-
f.current?.registerStyles?.(
|
|
959
|
+
registerStyles(a, d) {
|
|
960
|
+
f.current?.registerStyles?.(a, d);
|
|
849
961
|
},
|
|
850
|
-
unregisterStyles(
|
|
851
|
-
f.current?.unregisterStyles?.(
|
|
962
|
+
unregisterStyles(a) {
|
|
963
|
+
f.current?.unregisterStyles?.(a);
|
|
852
964
|
},
|
|
853
|
-
setRowLoading(
|
|
854
|
-
f.current?.setRowLoading?.(
|
|
965
|
+
setRowLoading(a, d) {
|
|
966
|
+
f.current?.setRowLoading?.(a, d);
|
|
855
967
|
},
|
|
856
|
-
setCellLoading(
|
|
857
|
-
f.current?.setCellLoading?.(
|
|
968
|
+
setCellLoading(a, d, y) {
|
|
969
|
+
f.current?.setCellLoading?.(a, d, y);
|
|
858
970
|
},
|
|
859
|
-
isRowLoading(
|
|
860
|
-
return f.current?.isRowLoading?.(
|
|
971
|
+
isRowLoading(a) {
|
|
972
|
+
return f.current?.isRowLoading?.(a) ?? !1;
|
|
861
973
|
},
|
|
862
|
-
isCellLoading(
|
|
863
|
-
return f.current?.isCellLoading?.(
|
|
974
|
+
isCellLoading(a, d) {
|
|
975
|
+
return f.current?.isCellLoading?.(a, d) ?? !1;
|
|
864
976
|
},
|
|
865
977
|
clearAllLoading() {
|
|
866
978
|
f.current?.clearAllLoading?.();
|
|
@@ -869,66 +981,66 @@ const vt = he(function(e, t) {
|
|
|
869
981
|
[]
|
|
870
982
|
);
|
|
871
983
|
const $ = k(null);
|
|
872
|
-
return
|
|
873
|
-
const
|
|
874
|
-
return
|
|
875
|
-
|
|
984
|
+
return De(() => {
|
|
985
|
+
const a = f.current;
|
|
986
|
+
return a && $.current && fe(a, $.current), () => {
|
|
987
|
+
a && fe(a, null);
|
|
876
988
|
};
|
|
877
|
-
}, []), /* @__PURE__ */ Pe(
|
|
878
|
-
/* @__PURE__ */
|
|
879
|
-
/* @__PURE__ */
|
|
989
|
+
}, []), /* @__PURE__ */ Pe(re, { children: [
|
|
990
|
+
/* @__PURE__ */ E(je, { ref: $ }),
|
|
991
|
+
/* @__PURE__ */ E(
|
|
880
992
|
"tbw-grid",
|
|
881
993
|
{
|
|
882
|
-
ref: (
|
|
883
|
-
if (f.current =
|
|
884
|
-
const
|
|
885
|
-
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);
|
|
886
998
|
}
|
|
887
999
|
},
|
|
888
|
-
class:
|
|
889
|
-
style:
|
|
890
|
-
children: /* @__PURE__ */
|
|
1000
|
+
class: w,
|
|
1001
|
+
style: D,
|
|
1002
|
+
children: /* @__PURE__ */ E(Ce.Provider, { value: f, children: x })
|
|
891
1003
|
}
|
|
892
1004
|
)
|
|
893
1005
|
] });
|
|
894
1006
|
});
|
|
895
|
-
function
|
|
1007
|
+
function wt(n) {
|
|
896
1008
|
const {
|
|
897
1009
|
field: e,
|
|
898
1010
|
header: t,
|
|
899
1011
|
type: r,
|
|
900
1012
|
editable: o,
|
|
901
|
-
sortable:
|
|
902
|
-
resizable:
|
|
903
|
-
width:
|
|
1013
|
+
sortable: s,
|
|
1014
|
+
resizable: i,
|
|
1015
|
+
width: c,
|
|
904
1016
|
minWidth: g,
|
|
905
|
-
hidden:
|
|
906
|
-
lockVisible:
|
|
907
|
-
children:
|
|
908
|
-
editor:
|
|
909
|
-
options:
|
|
910
|
-
multi:
|
|
911
|
-
format:
|
|
912
|
-
} = 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(
|
|
913
1025
|
(f) => {
|
|
914
|
-
u.current = f, f && (
|
|
1026
|
+
u.current = f, f && (R && Qe(f, R), m && Xe(f, m));
|
|
915
1027
|
},
|
|
916
|
-
[
|
|
917
|
-
), v = typeof
|
|
1028
|
+
[R, m, e]
|
|
1029
|
+
), v = typeof c == "number" ? `${c}px` : c, p = {
|
|
918
1030
|
field: e,
|
|
919
1031
|
ref: h
|
|
920
1032
|
};
|
|
921
|
-
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 });
|
|
922
1034
|
}
|
|
923
|
-
function
|
|
924
|
-
return /* @__PURE__ */
|
|
1035
|
+
function bt({ children: n }) {
|
|
1036
|
+
return /* @__PURE__ */ E("tbw-grid-tool-buttons", { children: n });
|
|
925
1037
|
}
|
|
926
|
-
const
|
|
1038
|
+
const Pt = ({ icons: n, defaults: e, children: t }) => {
|
|
927
1039
|
let r = t;
|
|
928
|
-
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 });
|
|
929
1041
|
};
|
|
930
|
-
function
|
|
931
|
-
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]);
|
|
932
1044
|
P(() => {
|
|
933
1045
|
let u = !0;
|
|
934
1046
|
return (async () => {
|
|
@@ -936,18 +1048,18 @@ function Pt(n) {
|
|
|
936
1048
|
if (n) {
|
|
937
1049
|
const v = document.querySelector(n);
|
|
938
1050
|
if (!v) return;
|
|
939
|
-
if (
|
|
1051
|
+
if (i.current = v, await v.ready?.(), u) {
|
|
940
1052
|
r(!0);
|
|
941
|
-
const
|
|
942
|
-
u &&
|
|
1053
|
+
const p = await v.getConfig?.();
|
|
1054
|
+
u && p && s(p);
|
|
943
1055
|
}
|
|
944
1056
|
} else {
|
|
945
1057
|
const v = e.current;
|
|
946
1058
|
if (!v) return;
|
|
947
1059
|
if (await v.ready?.(), u) {
|
|
948
1060
|
r(!0);
|
|
949
|
-
const
|
|
950
|
-
u &&
|
|
1061
|
+
const p = await v.getConfig?.();
|
|
1062
|
+
u && p && s(p);
|
|
951
1063
|
}
|
|
952
1064
|
}
|
|
953
1065
|
} catch {
|
|
@@ -956,23 +1068,23 @@ function Pt(n) {
|
|
|
956
1068
|
u = !1;
|
|
957
1069
|
};
|
|
958
1070
|
}, [n]);
|
|
959
|
-
const g =
|
|
960
|
-
const u =
|
|
1071
|
+
const g = S(async () => {
|
|
1072
|
+
const u = c();
|
|
961
1073
|
if (u)
|
|
962
1074
|
return await u.getConfig?.() ?? null;
|
|
963
1075
|
const h = e.current;
|
|
964
1076
|
return h ? await h.getConfig?.() ?? null : null;
|
|
965
|
-
}, [
|
|
966
|
-
const u =
|
|
1077
|
+
}, [c]), l = S(async () => {
|
|
1078
|
+
const u = c();
|
|
967
1079
|
if (u) {
|
|
968
1080
|
await u.forceLayout?.();
|
|
969
1081
|
return;
|
|
970
1082
|
}
|
|
971
1083
|
const h = e.current;
|
|
972
1084
|
h && await h.forceLayout?.();
|
|
973
|
-
}, [
|
|
1085
|
+
}, [c]), C = S(
|
|
974
1086
|
async (u) => {
|
|
975
|
-
const h =
|
|
1087
|
+
const h = c();
|
|
976
1088
|
if (h) {
|
|
977
1089
|
await h.toggleGroup?.(u);
|
|
978
1090
|
return;
|
|
@@ -980,62 +1092,76 @@ function Pt(n) {
|
|
|
980
1092
|
const v = e.current;
|
|
981
1093
|
v && await v.toggleGroup?.(u);
|
|
982
1094
|
},
|
|
983
|
-
[
|
|
984
|
-
),
|
|
985
|
-
(u) =>
|
|
986
|
-
[
|
|
987
|
-
),
|
|
988
|
-
((u) =>
|
|
989
|
-
[
|
|
990
|
-
),
|
|
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(
|
|
991
1103
|
(u, h) => {
|
|
992
|
-
const v =
|
|
1104
|
+
const v = c();
|
|
993
1105
|
if (v) {
|
|
994
1106
|
v.registerStyles?.(u, h);
|
|
995
1107
|
return;
|
|
996
1108
|
}
|
|
997
1109
|
e.current?.registerStyles?.(u, h);
|
|
998
1110
|
},
|
|
999
|
-
[
|
|
1000
|
-
),
|
|
1111
|
+
[c]
|
|
1112
|
+
), D = S(
|
|
1001
1113
|
(u) => {
|
|
1002
|
-
const h =
|
|
1114
|
+
const h = c();
|
|
1003
1115
|
if (h) {
|
|
1004
1116
|
h.unregisterStyles?.(u);
|
|
1005
1117
|
return;
|
|
1006
1118
|
}
|
|
1007
1119
|
e.current?.unregisterStyles?.(u);
|
|
1008
1120
|
},
|
|
1009
|
-
[
|
|
1010
|
-
),
|
|
1121
|
+
[c]
|
|
1122
|
+
), x = S(() => o?.columns ? o.columns.filter((u) => !u.hidden) : [], [o]);
|
|
1011
1123
|
return {
|
|
1012
1124
|
ref: e,
|
|
1013
|
-
element:
|
|
1125
|
+
element: c(),
|
|
1014
1126
|
isReady: t,
|
|
1015
1127
|
config: o,
|
|
1016
1128
|
getConfig: g,
|
|
1017
|
-
forceLayout:
|
|
1018
|
-
toggleGroup:
|
|
1019
|
-
getPlugin:
|
|
1020
|
-
getPluginByName:
|
|
1021
|
-
registerStyles:
|
|
1022
|
-
unregisterStyles:
|
|
1023
|
-
getVisibleColumns:
|
|
1129
|
+
forceLayout: l,
|
|
1130
|
+
toggleGroup: C,
|
|
1131
|
+
getPlugin: R,
|
|
1132
|
+
getPluginByName: m,
|
|
1133
|
+
registerStyles: w,
|
|
1134
|
+
unregisterStyles: D,
|
|
1135
|
+
getVisibleColumns: x
|
|
1024
1136
|
};
|
|
1025
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
|
+
}
|
|
1026
1151
|
export {
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1152
|
+
Rt as DataGrid,
|
|
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
|
|
1041
1167
|
};
|