@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/index.js CHANGED
@@ -1,22 +1,22 @@
1
- import { jsx as b, Fragment as ne, jsxs as Pe } from "react/jsx-runtime";
2
- import { DataGridElement as be } from "@toolbox-web/grid";
3
- import { createContext as ye, useContext as O, useRef as k, useCallback as E, useEffect as P, forwardRef as he, useReducer as Ee, useImperativeHandle as ve, useMemo as S, useLayoutEffect as ke, Children as Se, isValidElement as De, useState as fe } from "react";
4
- import { a as w, r as H, s as ge } from "./chunks/portal-bridge-DZ4yQkmm.js";
5
- import { flushSync as V, createPortal as Ge } from "react-dom";
6
- import { createPluginsFromFeatures as Ae } from "@toolbox-web/grid/features/registry";
7
- import { G as Te } from "./chunks/grid-element-context-BU3WvNtM.js";
8
- function xe(n) {
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(xe).join(" ");
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 Ke = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime", "currency"]);
15
- function Ne(n) {
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 (Ke.has(t)) {
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" ? Ne(e) : e);
34
+ return n.map((e) => typeof e == "string" ? Le(e) : e);
35
35
  }
36
- const W = {
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
- }, oe = ye(null), Ie = ({ icons: n, children: e }) => /* @__PURE__ */ b(oe.Provider, { value: n, children: e });
64
- function pt() {
65
- return O(oe);
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 Le = oe, Y = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new Map();
68
- function Ce(n) {
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 = Y.get(e);
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 Z.get(t);
80
+ return Y.get(t);
77
81
  }
78
- function Me(n) {
79
- const { children: e, cardRowHeight: t = "auto" } = n, r = k(null), o = E(
80
- (a) => {
81
- if (r.current = a, !a) return;
82
- Y.set(a, e);
83
- const s = a.closest("tbw-grid");
84
- if (s) {
85
- const g = s.id || s.getAttribute("data-grid-id");
86
- g && Z.set(g, e);
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 a = r.current;
93
- if (a) {
94
- Y.delete(a);
95
- const s = a.closest("tbw-grid");
96
- if (s) {
97
- const g = s.id || s.getAttribute("data-grid-id");
98
- g && Z.delete(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 c = t === "auto" ? "auto" : String(t);
103
- return /* @__PURE__ */ b("tbw-grid-responsive-card", { ref: o, cardRowHeight: c });
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
- Me.displayName = "GridResponsiveCard";
106
- const z = ye(null), He = ({ defaults: n, children: e }) => /* @__PURE__ */ b(z.Provider, { value: n, children: e });
107
- function mt() {
108
- return O(z);
114
+ function vt(n) {
115
+ return L(O)?.[n];
109
116
  }
110
- function yt(n) {
111
- return O(z)?.[n];
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 Oe = z, je = he(function(e, t) {
114
- const r = k(/* @__PURE__ */ new Map()), [, o] = Ee((p) => p + 1, 0), c = k(!1), a = k(0), s = () => {
115
- c.current || (c.current = !0, queueMicrotask(() => {
116
- c.current = !1, V(o), g();
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
- a.current || (a.current = requestAnimationFrame(() => {
120
- a.current = 0;
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(p, C, R) {
131
- r.current.set(p, { container: C, element: R }), s();
145
+ renderPortal(m, w, D) {
146
+ r.current.set(m, { container: w, element: D }), c();
132
147
  },
133
- removePortal(p, C) {
134
- r.current.delete(p) && (C ? V(o) : s());
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(), a.current && (cancelAnimationFrame(a.current), a.current = 0), s());
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 d = [];
145
- for (const [p, { container: C, element: R }] of r.current)
146
- d.push(Ge(R, C, p));
147
- return /* @__PURE__ */ b(ne, { children: d });
148
- }), U = /* @__PURE__ */ Symbol("reactProcessed"), D = [];
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
- for (let e = D.length - 1; e >= 0; e--) {
151
- const t = D[e];
152
- n.contains(t.container) && t.container.classList.contains("react-cell-editor") && (H(t.key), D.splice(e, 1));
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 qe(n) {
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 a = e.get(r);
161
- if (a)
162
- return w(a.container, n(t), a.portalKey), a.container;
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 c = w(o, n(t));
167
- return r && e.set(r, { portalKey: c, container: o }), D.push({ key: c, container: o }), o;
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 _e(n) {
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 r = w(t, n(e));
175
- return D.push({ key: r, container: t }), t;
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 $e(n) {
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 = w(t, n(e));
183
- return D.push({ key: r, container: t }), t;
229
+ const r = b(t, n(e));
230
+ return M.set(t, { key: r }), t;
184
231
  };
185
232
  }
186
- function Be(n) {
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 = w(t, n(e));
191
- return D.push({ key: r, container: t }), t;
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 = w(r, t);
202
- return D.push({ key: o, container: r }), r;
248
+ const o = b(r, t);
249
+ return M.set(r, { key: o }), r;
203
250
  };
204
251
  }
205
- function Re(n) {
252
+ function we(n) {
206
253
  if (!n) return;
207
- if (n[U]) return 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[U] = !0, r;
264
+ return r[W] = !0, r;
218
265
  }
219
266
  const e = n.columns.map((r) => {
220
- const { renderer: o, editor: c, headerRenderer: a, headerLabelRenderer: s, ...g } = r, d = { ...g };
221
- return o && (d.renderer = qe(o)), c && (d.editor = _e(c)), a && (d.headerRenderer = $e(a)), s && (d.headerLabelRenderer = Be(s)), d;
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[U] = !0, t;
273
+ return t[W] = !0, t;
227
274
  }
228
- const Q = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new Map();
229
- function We(n) {
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 = Q.get(e);
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 X.get(t);
284
+ return Q.get(t);
238
285
  }
239
- function Ue(n) {
240
- const { children: e, showExpandColumn: t = !0, animation: r = "slide" } = n, o = k(null), c = E(
241
- (s) => {
242
- if (o.current = s, !s) return;
243
- Q.set(s, e);
244
- const g = s.closest("tbw-grid");
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 d = g.id || g.getAttribute("data-grid-id");
247
- d && X.set(d, e);
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 s = o.current;
254
- if (s) {
255
- Q.delete(s);
256
- const g = s.closest("tbw-grid");
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 p = g.id || g.getAttribute("data-grid-id");
259
- p && X.delete(p);
305
+ const C = g.id || g.getAttribute("data-grid-id");
306
+ C && Q.delete(C);
260
307
  }
261
- const d = s.parentNode;
262
- d && d.contains(s);
308
+ const l = c.parentNode;
309
+ l && l.contains(c);
263
310
  }
264
- }, []), /* @__PURE__ */ b(
311
+ }, []), /* @__PURE__ */ E(
265
312
  "tbw-grid-detail",
266
313
  {
267
- ref: c,
314
+ ref: s,
268
315
  showExpandColumn: t ? void 0 : "false",
269
316
  animation: r === !1 ? "false" : r
270
317
  }
271
318
  );
272
319
  }
273
- Ue.displayName = "GridDetailPanel";
274
- const ee = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new Map();
275
- function Je(n) {
276
- const e = ee.get(n);
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 te.get(t);
327
+ return ee.get(t);
281
328
  }
282
- function ht(n) {
283
- const { id: e, title: t, icon: r, tooltip: o, order: c = 100, children: a } = n, s = k(null), g = E(
284
- (d) => {
285
- s.current = d, d && (ee.set(d, a), e && te.set(e, a));
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
- [a, e]
334
+ [i, e]
288
335
  );
289
336
  return P(() => () => {
290
- const d = s.current;
291
- d && (ee.delete(d), e && te.delete(e));
292
- }, [e]), /* @__PURE__ */ b(
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: c?.toString()
347
+ order: s?.toString()
301
348
  }
302
349
  );
303
350
  }
304
- const G = /* @__PURE__ */ new WeakMap(), A = /* @__PURE__ */ new Map();
305
- function Ye(n, e) {
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 = A.get(t) ?? {};
309
- o.renderer = e, A.set(t, o);
355
+ const o = K.get(t) ?? {};
356
+ o.renderer = e, K.set(t, o);
310
357
  }
311
358
  }
312
- function Ze(n, e) {
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 = A.get(t) ?? {};
316
- o.editor = e, A.set(t, o);
362
+ const o = K.get(t) ?? {};
363
+ o.editor = e, K.set(t, o);
317
364
  }
318
365
  }
319
- function Qe(n) {
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 = A.get(t)?.renderer);
370
+ t && (e = K.get(t)?.renderer);
324
371
  }
325
372
  return e;
326
373
  }
327
- function Xe(n) {
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 = A.get(t)?.editor);
378
+ t && (e = K.get(t)?.editor);
332
379
  }
333
380
  return e;
334
381
  }
335
- class et {
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 Re(e) ?? e;
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 a = A.get(t);
369
- a && (a.renderer || a.editor) && (r = a, G.set(e, r));
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, c = r?.editor !== void 0;
372
- return r !== void 0 && (o || c);
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 = Qe(e);
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 (c) => {
391
- const a = c.cellEl;
392
- if (a) {
393
- const d = o.get(a);
394
- if (d)
395
- return w(d.container, t(c), d.portalKey), d.container;
396
- const p = document.createElement("div");
397
- p.className = "react-cell-renderer", p.style.display = "contents";
398
- const C = w(
399
- p,
400
- t(c),
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(a, { portalKey: C, container: p }), this.trackPortal(C, p, !1), p;
486
+ return o.set(i, { portalKey: R, container: C }), this.trackPortal(R, C, !1), C;
405
487
  }
406
- const s = document.createElement("div");
407
- s.className = "react-cell-renderer", s.style.display = "contents";
408
- const g = w(
409
- s,
410
- t(c),
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, s, !1), s;
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 = Xe(e);
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 c = document.createElement("div");
428
- c.className = "react-cell-editor", c.style.display = "contents";
429
- const a = w(
430
- c,
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
- return this.trackPortal(a, c, !0), c;
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 = We(e);
534
+ const t = Je(e);
444
535
  if (t)
445
536
  return (r, o) => {
446
- const c = document.createElement("div");
447
- c.className = "react-detail-panel";
448
- const s = w(
449
- c,
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(s, c, !1), c;
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 = Ce(e);
562
+ const t = Re(e);
472
563
  if (t)
473
564
  return (r, o) => {
474
- const c = document.createElement("div");
475
- c.className = "react-responsive-card";
476
- const s = w(
477
- c,
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(s, c, !1), c;
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 = Je(e);
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 a = w(o, t({
599
+ const i = b(o, t({
509
600
  grid: r ?? o
510
601
  }), void 0, r ?? void 0);
511
- return this.trackPortal(a, o, !1), () => {
512
- H(a, { sync: !0 }), this.untrackPortal(a);
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 c = r.cellEl?.closest("tbw-grid") ?? t, a = w(o, e(r), void 0, c);
560
- return this.trackPortal(a, o, !1), o;
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 c = w(o, e(r), void 0, t);
572
- return this.trackPortal(c, o, !0), o;
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 c = document.createElement("div");
582
- c.style.display = "contents";
583
- const a = r.closest("tbw-grid") ?? t, s = w(c, e(o), void 0, a);
584
- this.trackPortal(s, c, !1), r.appendChild(c);
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), this.keyToContainer.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
- H(e);
604
- this.allPortalKeys.clear(), this.editorPortalKeys.clear(), this.keyToContainer.clear(), A.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
- * Destroys editor portals whose container is inside the cell.
609
- * Also cleans up config-based editor roots (from processGridConfig/wrapReactEditor)
610
- * that bypass the adapter's tracking.
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
- for (const t of this.editorPortalKeys) {
614
- const r = this.keyToContainer.get(t);
615
- r && e.contains(r) && (H(t), this.untrackPortal(t));
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
- for (const [t, r] of this.keyToContainer)
624
- if (r === e) {
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 tt = {
741
+ const nt = {
631
742
  undoRedo: ["editing"],
632
743
  clipboard: ["selection"]
633
744
  };
634
- function rt(n) {
745
+ function ot(n) {
635
746
  const e = new Set(n);
636
747
  for (const t of n) {
637
- const r = tt[t];
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 nt(n) {
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 rt(e), Ae(n);
760
+ return ot(e), xe(n);
650
761
  }
651
- let me = !1, J = null;
652
- function re() {
653
- return me || (J = new et(), be.registerAdapter(J), me = !0), J;
762
+ let me = !1, V = null;
763
+ function te() {
764
+ return me || (V = new rt(), Ee.registerAdapter(V), me = !0), V;
654
765
  }
655
- re();
656
- function ot(n) {
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 it(n, e) {
771
+ function ct(n, e) {
661
772
  const t = n;
662
- if (!n.querySelector("tbw-grid-responsive-card") || !Ce(n)) return;
663
- const c = t.getPluginByName?.("responsive");
664
- if (c && typeof c.setCardRenderer == "function") {
665
- const a = e.createResponsiveCardRenderer(n);
666
- a && c.setCardRenderer(a);
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 st(n) {
780
+ function at(n) {
670
781
  const e = {};
671
- return Se.forEach(n, (t) => {
672
- if (De(t)) {
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 vt = he(function(e, t) {
797
+ const Rt = he(function(e, t) {
687
798
  const {
688
799
  // Core props
689
800
  rows: r,
690
801
  gridConfig: o,
691
- columns: c,
692
- columnDefaults: a,
693
- fitMode: s,
802
+ columns: s,
803
+ columnDefaults: i,
804
+ fitMode: c,
694
805
  sortable: g,
695
- filterable: d,
696
- selectable: p,
697
- loading: C,
698
- customStyles: R,
699
- className: K,
700
- style: x,
701
- children: T,
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
- ...m
710
- } = e, f = k(null), j = k(null), ie = O(Oe), q = O(Le), se = [
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
- ], we = S(() => se.map((i) => {
735
- const l = m[i];
736
- return l !== void 0 ? `${i}:${JSON.stringify(l)}` : "";
737
- }).filter(Boolean).join("|"), [m]), ce = S(() => {
738
- const i = {};
739
- for (const l of se)
740
- l in m && m[l] !== void 0 && (i[l] = m[l]);
741
- return i;
742
- }, [we]), ae = S(() => st(T), [T]), le = S(() => ({ ...ae, ...ce }), [ce, ae]), _ = S(() => u || h ? [] : nt(le), [le, u, h]), N = S(() => {
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 i = new Set(u.map((y) => y.name)), l = _.filter((y) => !i.has(y.name));
745
- return [...u, ...l];
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, _]), F = S(() => {
749
- if (!c) return c;
750
- const i = Fe(c);
751
- return a ? i.map((l) => ({
752
- ...a,
753
- ...l
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
- })) : i;
756
- }, [c, a]), I = S(() => {
757
- const i = Re(o), l = {};
758
- if (g !== void 0 && (l.sortable = g), d !== void 0 && (l.filterable = d), p !== void 0 && (l.selectable = p), q) {
759
- const y = i?.icons || o?.icons || {};
760
- l.icons = { ...q, ...y };
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 (N.length > 0 && i) {
763
- const y = i.plugins || [], L = new Set(y.map((M) => M.name)), B = N.filter((M) => !L.has(M.name));
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
- ...i,
766
- ...l,
767
- plugins: [...y, ...B]
877
+ ...a,
878
+ ...d,
879
+ plugins: [...y, ...U]
768
880
  };
769
881
  }
770
- return N.length > 0 && !i ? { ...l, plugins: N } : Object.keys(l).length > 0 ? { ...i, ...l } : i;
771
- }, [o, N, g, d, p, q]);
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
- re().setTypeDefaults(ie);
774
- }, [ie]), P(() => {
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 && F && (f.current.columns = F);
780
- }, [F]), P(() => {
781
- f.current && s !== void 0 && (f.current.fitMode = s);
782
- }, [s]), P(() => {
783
- f.current && C !== void 0 && (f.current.loading = C);
784
- }, [C]), P(() => {
785
- const i = f.current;
786
- if (!i) return;
787
- const l = re();
788
- i.__frameworkAdapter = l, ot(i), it(i, l);
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 L = requestAnimationFrame(() => {
791
- y || (typeof i.refreshColumns == "function" && i.refreshColumns(), typeof i.refreshShellHeader == "function" && i.refreshShellHeader());
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(L);
906
+ y = !0, cancelAnimationFrame(H);
795
907
  };
796
908
  }, []), P(() => {
797
- if (!f.current || !R) return;
798
- const i = f.current, l = "react-custom-styles";
909
+ if (!f.current || !m) return;
910
+ const a = f.current, d = "react-custom-styles";
799
911
  let y = !0;
800
- return i.ready?.().then(() => {
801
- y && R && (i.registerStyles?.(l, R), j.current = l);
912
+ return a.ready?.().then(() => {
913
+ y && m && (a.registerStyles?.(d, m), q.current = d);
802
914
  }), () => {
803
- y = !1, j.current && (i.unregisterStyles?.(j.current), j.current = null);
915
+ y = !1, q.current && (a.unregisterStyles?.(q.current), q.current = null);
804
916
  };
805
- }, [R]), P(() => {
806
- const i = f.current;
807
- if (!i) return;
808
- const l = [];
809
- return v && l.push(i.on("rows-change", (y) => v(y.rows))), () => {
810
- l.forEach((y) => y());
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 de = S(() => Object.keys(W).filter((i) => typeof m[i] == "function").sort().join("|"), [m]), ue = k({});
814
- for (const i of Object.keys(W))
815
- ue.current[i] = m[i];
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 i = f.current;
818
- if (!i) return;
819
- const l = [];
820
- for (const [y, L] of Object.entries(W))
821
- de.includes(y) && l.push(
822
- i.on(L, (B, M) => {
823
- ue.current[y]?.(B, M);
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
- l.forEach((y) => y());
939
+ d.forEach((y) => y());
828
940
  };
829
- }, [de]), ve(
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(i) {
845
- return f.current?.toggleGroup?.(i);
956
+ async toggleGroup(a) {
957
+ return f.current?.toggleGroup?.(a);
846
958
  },
847
- registerStyles(i, l) {
848
- f.current?.registerStyles?.(i, l);
959
+ registerStyles(a, d) {
960
+ f.current?.registerStyles?.(a, d);
849
961
  },
850
- unregisterStyles(i) {
851
- f.current?.unregisterStyles?.(i);
962
+ unregisterStyles(a) {
963
+ f.current?.unregisterStyles?.(a);
852
964
  },
853
- setRowLoading(i, l) {
854
- f.current?.setRowLoading?.(i, l);
965
+ setRowLoading(a, d) {
966
+ f.current?.setRowLoading?.(a, d);
855
967
  },
856
- setCellLoading(i, l, y) {
857
- f.current?.setCellLoading?.(i, l, y);
968
+ setCellLoading(a, d, y) {
969
+ f.current?.setCellLoading?.(a, d, y);
858
970
  },
859
- isRowLoading(i) {
860
- return f.current?.isRowLoading?.(i) ?? !1;
971
+ isRowLoading(a) {
972
+ return f.current?.isRowLoading?.(a) ?? !1;
861
973
  },
862
- isCellLoading(i, l) {
863
- return f.current?.isCellLoading?.(i, l) ?? !1;
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 ke(() => {
873
- const i = f.current;
874
- return i && $.current && ge(i, $.current), () => {
875
- i && ge(i, null);
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(ne, { children: [
878
- /* @__PURE__ */ b(je, { ref: $ }),
879
- /* @__PURE__ */ b(
989
+ }, []), /* @__PURE__ */ Pe(re, { children: [
990
+ /* @__PURE__ */ E(je, { ref: $ }),
991
+ /* @__PURE__ */ E(
880
992
  "tbw-grid",
881
993
  {
882
- ref: (i) => {
883
- if (f.current = i, i) {
884
- const l = i;
885
- I && (l.gridConfig = I), r && (l.rows = r), F && (l.columns = F);
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: K,
889
- style: x,
890
- children: /* @__PURE__ */ b(Te.Provider, { value: f, children: T })
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 Ct(n) {
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: c,
902
- resizable: a,
903
- width: s,
1013
+ sortable: s,
1014
+ resizable: i,
1015
+ width: c,
904
1016
  minWidth: g,
905
- hidden: d,
906
- lockVisible: p,
907
- children: C,
908
- editor: R,
909
- options: K,
910
- multi: x,
911
- format: T
912
- } = n, u = k(null), h = E(
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 && (C && Ye(f, C), R && Ze(f, R));
1026
+ u.current = f, f && (R && Qe(f, R), m && Xe(f, m));
915
1027
  },
916
- [C, R, e]
917
- ), v = typeof s == "number" ? `${s}px` : s, m = {
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 && (m.header = t), r !== void 0 && (m.type = r), o !== void 0 && (m.editable = o), c !== void 0 && (m.sortable = c), a !== void 0 && (m.resizable = a), v !== void 0 && (m.width = v), g !== void 0 && (m["min-width"] = g), d !== void 0 && (m.hidden = d), p !== void 0 && (m["lock-visible"] = p), x !== void 0 && (m.multi = x), T && (m["data-has-format"] = "true"), K && (m["data-has-options"] = "true"), /* @__PURE__ */ b("tbw-grid-column", { ...m });
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 Rt({ children: n }) {
924
- return /* @__PURE__ */ b("tbw-grid-tool-buttons", { children: n });
1035
+ function bt({ children: n }) {
1036
+ return /* @__PURE__ */ E("tbw-grid-tool-buttons", { children: n });
925
1037
  }
926
- const wt = ({ icons: n, defaults: e, children: t }) => {
1038
+ const Pt = ({ icons: n, defaults: e, children: t }) => {
927
1039
  let r = t;
928
- return e && (r = /* @__PURE__ */ b(He, { defaults: e, children: r })), n && (r = /* @__PURE__ */ b(Ie, { icons: n, children: r })), /* @__PURE__ */ b(ne, { children: r });
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 Pt(n) {
931
- const e = k(null), [t, r] = fe(!1), [o, c] = fe(null), a = k(null), s = E(() => n ? (a.current ??= document.querySelector(n), a.current) : e.current?.element ?? null, [n]);
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 (a.current = v, await v.ready?.(), u) {
1051
+ if (i.current = v, await v.ready?.(), u) {
940
1052
  r(!0);
941
- const m = await v.getConfig?.();
942
- u && m && c(m);
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 m = await v.getConfig?.();
950
- u && m && c(m);
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 = E(async () => {
960
- const u = s();
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
- }, [s]), d = E(async () => {
966
- const u = s();
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
- }, [s]), p = E(
1085
+ }, [c]), C = S(
974
1086
  async (u) => {
975
- const h = s();
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
- [s]
984
- ), C = E(
985
- (u) => s()?.getPlugin?.(u),
986
- [s]
987
- ), R = E(
988
- ((u) => s()?.getPluginByName?.(u)),
989
- [s]
990
- ), K = E(
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 = s();
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
- [s]
1000
- ), x = E(
1111
+ [c]
1112
+ ), D = S(
1001
1113
  (u) => {
1002
- const h = s();
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
- [s]
1010
- ), T = E(() => o?.columns ? o.columns.filter((u) => !u.hidden) : [], [o]);
1121
+ [c]
1122
+ ), x = S(() => o?.columns ? o.columns.filter((u) => !u.hidden) : [], [o]);
1011
1123
  return {
1012
1124
  ref: e,
1013
- element: s(),
1125
+ element: c(),
1014
1126
  isReady: t,
1015
1127
  config: o,
1016
1128
  getConfig: g,
1017
- forceLayout: d,
1018
- toggleGroup: p,
1019
- getPlugin: C,
1020
- getPluginByName: R,
1021
- registerStyles: K,
1022
- unregisterStyles: x,
1023
- getVisibleColumns: T
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
- vt as DataGrid,
1028
- et as GridAdapter,
1029
- Ct as GridColumn,
1030
- Ue as GridDetailPanel,
1031
- Ie as GridIconProvider,
1032
- wt as GridProvider,
1033
- Me as GridResponsiveCard,
1034
- Rt as GridToolButtons,
1035
- ht as GridToolPanel,
1036
- He as GridTypeProvider,
1037
- Pt as useGrid,
1038
- pt as useGridIcons,
1039
- mt as useGridTypeDefaults,
1040
- yt as useTypeDefault
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
  };