@toolbox-web/grid-react 1.3.0 → 1.4.0

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