@toolbox-web/grid-react 1.4.0 → 1.5.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,49 +1,68 @@
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
- return n.charAt(0).toUpperCase() + n.slice(1);
10
- }
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(Ae).join(" ");
13
- }
14
- const Me = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime", "currency"]);
15
- function Le(n) {
16
- const e = n.lastIndexOf(":");
17
- if (e > 0) {
18
- const t = n.slice(e + 1).toLowerCase();
19
- if (Me.has(t)) {
20
- const r = n.slice(0, e);
1
+ import { jsx as w, Fragment as V, jsxs as le } from "react/jsx-runtime";
2
+ import { DataGridElement as fe } from "@toolbox-web/grid";
3
+ import { createContext as ie, useContext as F, forwardRef as se, useRef as b, useReducer as de, useImperativeHandle as ce, Component as ge, useMemo as E, useEffect as v, useLayoutEffect as pe, Children as me, isValidElement as Ce, useCallback as x, useState as X } from "react";
4
+ import { g as ye } from "./chunks/grid-responsive-card-BB28Zl2O.js";
5
+ import { G as ur } from "./chunks/grid-responsive-card-BB28Zl2O.js";
6
+ import { s as ee } from "./chunks/portal-bridge-DLA6Zs11.js";
7
+ import { flushSync as re, createPortal as he } from "react-dom";
8
+ import { p as ve } from "./chunks/react-column-config-Sb-U7Bq3.js";
9
+ import { G as we, c as Re, d as Pe } from "./chunks/react-grid-adapter-CzByOnua.js";
10
+ import { e as fr } from "./chunks/react-grid-adapter-CzByOnua.js";
11
+ import { createPluginsFromFeatures as be } from "@toolbox-web/grid/features/registry";
12
+ import { G as ae } from "./chunks/grid-element-context-BU3WvNtM.js";
13
+ import { G as gr } from "./chunks/grid-detail-panel-CR7YUhdN.js";
14
+ function Se(r) {
15
+ return r.charAt(0).toUpperCase() + r.slice(1);
16
+ }
17
+ function te(r) {
18
+ return r.toLowerCase() === "id" ? "ID" : r.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").split(" ").filter(Boolean).map(Se).join(" ");
19
+ }
20
+ const Ge = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime", "currency"]);
21
+ function xe(r) {
22
+ const t = r.lastIndexOf(":");
23
+ if (t > 0) {
24
+ const i = r.slice(t + 1).toLowerCase();
25
+ if (Ge.has(i)) {
26
+ const o = r.slice(0, t);
21
27
  return {
22
- field: r,
23
- header: pe(r),
24
- type: t
28
+ field: o,
29
+ header: te(o),
30
+ type: i
25
31
  };
26
32
  }
27
33
  }
28
34
  return {
29
- field: n,
30
- header: pe(n)
35
+ field: r,
36
+ header: te(r)
31
37
  };
32
38
  }
33
- function Fe(n) {
34
- return n.map((e) => typeof e == "string" ? Le(e) : e);
39
+ function Ee(r) {
40
+ return r.map((t) => typeof t == "string" ? xe(t) : t);
41
+ }
42
+ function De(r, t) {
43
+ return t ? r.map((i) => ({ ...t, ...i })) : r;
44
+ }
45
+ function Ze(r) {
46
+ return r.some((t) => typeof t == "string");
35
47
  }
36
- const _ = {
48
+ const B = {
37
49
  onCellClick: "cell-click",
38
50
  onRowClick: "row-click",
39
51
  onCellActivate: "cell-activate",
40
52
  onCellChange: "cell-change",
41
53
  onCellCommit: "cell-commit",
54
+ onCellCancel: "cell-cancel",
42
55
  onRowCommit: "row-commit",
43
56
  onChangedRowsReset: "changed-rows-reset",
57
+ onEditOpen: "edit-open",
58
+ onBeforeEditClose: "before-edit-close",
59
+ onEditClose: "edit-close",
60
+ onDirtyChange: "dirty-change",
61
+ onDataChange: "data-change",
44
62
  onSortChange: "sort-change",
45
63
  onFilterChange: "filter-change",
46
64
  onColumnResize: "column-resize",
65
+ onColumnResizeReset: "column-resize-reset",
47
66
  onColumnMove: "column-move",
48
67
  onColumnVisibility: "column-visibility",
49
68
  onColumnStateChange: "column-state-change",
@@ -54,1114 +73,517 @@ const _ = {
54
73
  onRowDrop: "row-drop",
55
74
  onRowTransfer: "row-transfer",
56
75
  onGroupToggle: "group-toggle",
76
+ onGroupExpand: "group-expand",
77
+ onGroupCollapse: "group-collapse",
57
78
  onTreeExpand: "tree-expand",
58
79
  onDetailExpand: "detail-expand",
59
80
  onResponsiveChange: "responsive-change",
81
+ onContextMenuOpen: "context-menu-open",
60
82
  onCopy: "copy",
61
83
  onPaste: "paste",
62
- onUndoRedo: "undo-redo",
84
+ onUndo: "undo",
85
+ onRedo: "redo",
63
86
  onExportComplete: "export-complete",
64
87
  onPrintStart: "print-start",
65
88
  onPrintComplete: "print-complete",
66
89
  onTbwScroll: "tbw-scroll"
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
- }
71
- const Ie = ne, J = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new Map();
72
- function Re(n) {
73
- const e = n.querySelector("tbw-grid-responsive-card");
74
- if (e) {
75
- const r = J.get(e);
76
- if (r) return r;
77
- }
78
- const t = n.id || n.getAttribute("data-grid-id");
79
- if (t)
80
- return Y.get(t);
81
- }
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
- }
92
- },
93
- [e]
94
- );
95
- P(() => () => {
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
- }
104
- }
105
- }, []);
106
- const s = t === "auto" ? "auto" : String(t);
107
- return /* @__PURE__ */ E("tbw-grid-responsive-card", { ref: o, cardRowHeight: s });
90
+ }, H = ie(null), Fe = ({ icons: r, children: t }) => /* @__PURE__ */ w(H.Provider, { value: r, children: t });
91
+ function Qe() {
92
+ return F(H);
108
93
  }
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);
94
+ const Le = H, N = ie(null), Ae = ({ defaults: r, children: t }) => /* @__PURE__ */ w(N.Provider, { value: r, children: t });
95
+ function Xe() {
96
+ return F(N);
113
97
  }
114
- function vt(n) {
115
- return L(O)?.[n];
98
+ function er(r) {
99
+ return F(N)?.[r];
116
100
  }
117
- const qe = O;
118
- class Oe extends ke {
101
+ const ke = N;
102
+ class Ie extends ge {
119
103
  state = { failed: !1 };
120
104
  static getDerivedStateFromError() {
121
105
  return { failed: !0 };
122
106
  }
123
- componentDidCatch(e) {
124
- this.props.onError(this.props.portalKey, e);
107
+ componentDidCatch(t) {
108
+ this.props.onError(this.props.portalKey, t);
125
109
  }
126
110
  render() {
127
111
  return this.state.failed ? null : this.props.children;
128
112
  }
129
113
  }
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();
114
+ const Te = se(function(t, i) {
115
+ const o = b(/* @__PURE__ */ new Map()), [, d] = de((l) => l + 1, 0), g = b(!1), p = b(0), u = () => {
116
+ g.current || (g.current = !0, queueMicrotask(() => {
117
+ g.current = !1, re(d), R();
134
118
  }));
135
- }, g = () => {
136
- i.current || (i.current = requestAnimationFrame(() => {
137
- i.current = 0, o();
119
+ }, R = () => {
120
+ p.current || (p.current = requestAnimationFrame(() => {
121
+ p.current = 0, d();
138
122
  }));
139
- }, l = (m, w) => {
140
- console.error(`[grid-react] Portal "${m}" crashed; dropping.`, w), r.current.delete(m), g();
123
+ }, S = (l, y) => {
124
+ console.error(`[grid-react] Portal "${l}" crashed; dropping.`, y), o.current.delete(l), R();
141
125
  };
142
- ve(
143
- t,
126
+ ce(
127
+ i,
144
128
  () => ({
145
- renderPortal(m, w, D) {
146
- r.current.set(m, { container: w, element: D }), c();
129
+ renderPortal(l, y, G) {
130
+ o.current.set(l, { container: y, element: G }), u();
147
131
  },
148
- removePortal(m, w) {
149
- r.current.delete(m) && (w ? ge(o) : c());
132
+ removePortal(l, y) {
133
+ o.current.delete(l) && (y ? re(d) : u());
150
134
  },
151
135
  clear() {
152
- r.current.size > 0 && (r.current.clear(), i.current && (cancelAnimationFrame(i.current), i.current = 0), c());
136
+ o.current.size > 0 && (o.current.clear(), p.current && (cancelAnimationFrame(p.current), p.current = 0), u());
153
137
  }
154
138
  }),
155
139
  // forceRender is stable (useReducer dispatch), refs are stable
156
140
  // eslint-disable-next-line react-hooks/exhaustive-deps
157
141
  []
158
142
  );
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);
143
+ const P = [];
144
+ let h = null;
145
+ for (const [l, { container: y, element: G }] of o.current) {
146
+ if (!y.isConnected) {
147
+ (h ??= []).push(l);
164
148
  continue;
165
149
  }
166
- C.push(
167
- Ke(
168
- /* @__PURE__ */ E(Oe, { portalKey: m, onError: l, children: D }),
169
- w,
170
- m
150
+ P.push(
151
+ he(
152
+ /* @__PURE__ */ w(Ie, { portalKey: l, onError: S, children: G }),
153
+ y,
154
+ l
171
155
  )
172
156
  );
173
157
  }
174
- if (R) {
175
- const m = R;
158
+ if (h) {
159
+ const l = h;
176
160
  queueMicrotask(() => {
177
- for (const w of m) r.current.delete(w);
161
+ for (const y of l) o.current.delete(y);
178
162
  });
179
163
  }
180
- return /* @__PURE__ */ E(re, { children: C });
181
- }), W = /* @__PURE__ */ Symbol("reactProcessed"), M = /* @__PURE__ */ new Map();
182
- function ze(n) {
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));
187
- }
188
- }
189
- function $e(n) {
190
- const e = /* @__PURE__ */ new WeakMap();
191
- return (t) => {
192
- const r = t.cellEl;
193
- if (r) {
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
- }
200
- }
201
- const o = document.createElement("div");
202
- o.className = "react-cell-renderer", o.style.display = "contents";
203
- const s = b(o, n(t));
204
- return r && e.set(r, { portalKey: s, container: o }), M.set(o, { key: s }), o;
205
- };
206
- }
207
- function Ue(n) {
208
- return (e) => {
209
- const t = document.createElement("div");
210
- t.className = "react-cell-editor", t.style.display = "contents";
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;
223
- };
224
- }
225
- function _e(n) {
226
- return (e) => {
227
- const t = document.createElement("div");
228
- t.className = "react-header-renderer", t.style.display = "contents";
229
- const r = b(t, n(e));
230
- return M.set(t, { key: r }), t;
231
- };
232
- }
233
- function We(n) {
234
- return (e) => {
235
- const t = document.createElement("div");
236
- t.className = "react-header-label-renderer", t.style.display = "contents";
237
- const r = b(t, n(e));
238
- return M.set(t, { key: r }), t;
239
- };
240
- }
241
- function Ve(n) {
242
- return (e) => {
243
- const t = n(e);
244
- if (t instanceof HTMLElement || typeof t == "string")
245
- return t;
246
- const r = document.createElement("div");
247
- r.className = "react-loading-renderer", r.style.display = "contents";
248
- const o = b(r, t);
249
- return M.set(r, { key: o }), r;
250
- };
251
- }
252
- function we(n) {
253
- if (!n) return;
254
- if (n[W]) return n;
255
- if (n.loadingRenderer && typeof n.loadingRenderer == "function") {
256
- const r = n.loadingRenderer;
257
- n = {
258
- ...n,
259
- loadingRenderer: Ve(r)
260
- };
261
- }
262
- if (!n.columns) {
263
- const r = n;
264
- return r[W] = !0, r;
265
- }
266
- const e = n.columns.map((r) => {
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;
269
- }), t = {
270
- ...n,
271
- columns: e
272
- };
273
- return t[W] = !0, t;
274
- }
275
- const Z = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new Map();
276
- function Je(n) {
277
- const e = n.querySelector("tbw-grid-detail");
278
- if (e) {
279
- const r = Z.get(e);
280
- if (r) return r;
281
- }
282
- const t = n.id || n.getAttribute("data-grid-id");
283
- if (t)
284
- return Q.get(t);
285
- }
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");
292
- if (g) {
293
- const l = g.id || g.getAttribute("data-grid-id");
294
- l && Q.set(l, e);
295
- }
296
- },
297
- [e]
298
- );
299
- return P(() => () => {
300
- const c = o.current;
301
- if (c) {
302
- Z.delete(c);
303
- const g = c.closest("tbw-grid");
304
- if (g) {
305
- const C = g.id || g.getAttribute("data-grid-id");
306
- C && Q.delete(C);
307
- }
308
- const l = c.parentNode;
309
- l && l.contains(c);
310
- }
311
- }, []), /* @__PURE__ */ E(
312
- "tbw-grid-detail",
313
- {
314
- ref: s,
315
- showExpandColumn: t ? void 0 : "false",
316
- animation: r === !1 ? "false" : r
317
- }
318
- );
319
- }
320
- Ye.displayName = "GridDetailPanel";
321
- const X = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new Map();
322
- function Ze(n) {
323
- const e = X.get(n);
324
- if (e) return e;
325
- const t = n.id;
326
- if (t)
327
- return ee.get(t);
328
- }
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));
333
- },
334
- [i, e]
335
- );
336
- return P(() => () => {
337
- const l = c.current;
338
- l && (X.delete(l), e && ee.delete(e));
339
- }, [e]), /* @__PURE__ */ E(
340
- "tbw-grid-tool-panel",
341
- {
342
- ref: g,
343
- id: e,
344
- title: t,
345
- icon: r,
346
- tooltip: o,
347
- order: s?.toString()
348
- }
349
- );
350
- }
351
- const G = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new Map();
352
- function Qe(n, e) {
353
- const t = n.getAttribute("field"), r = G.get(n) ?? {};
354
- if (r.renderer = e, G.set(n, r), t) {
355
- const o = K.get(t) ?? {};
356
- o.renderer = e, K.set(t, o);
357
- }
358
- }
359
- function Xe(n, e) {
360
- const t = n.getAttribute("field"), r = G.get(n) ?? {};
361
- if (r.editor = e, G.set(n, r), t) {
362
- const o = K.get(t) ?? {};
363
- o.editor = e, K.set(t, o);
364
- }
365
- }
366
- function et(n) {
367
- let e = G.get(n)?.renderer;
368
- if (!e) {
369
- const t = n.getAttribute("field");
370
- t && (e = K.get(t)?.renderer);
371
- }
372
- return e;
373
- }
374
- function tt(n) {
375
- let e = G.get(n)?.editor;
376
- if (!e) {
377
- const t = n.getAttribute("field");
378
- t && (e = K.get(t)?.editor);
379
- }
380
- return e;
381
- }
382
- class rt {
383
- /** Portal keys for all managed portals (for cleanup on destroy). */
384
- allPortalKeys = /* @__PURE__ */ new Set();
385
- /** Portal keys for editor-specific portals (for per-cell cleanup via releaseCell). */
386
- editorPortalKeys = /* @__PURE__ */ new Set();
387
- /** Maps portal keys to their containers (for container-based lookups in releaseCell/unmount). */
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();
421
- typeDefaults = null;
422
- /**
423
- * Sets the type defaults map for this adapter.
424
- * Called by DataGrid when it receives type defaults from context.
425
- *
426
- * @internal
427
- */
428
- setTypeDefaults(e) {
429
- this.typeDefaults = e;
430
- }
431
- /**
432
- * FrameworkAdapter.processConfig implementation.
433
- * Called automatically by the grid's `set gridConfig` setter.
434
- * Converts React renderer/editor functions to DOM-returning functions.
435
- */
436
- processConfig(e) {
437
- return we(e) ?? e;
438
- }
439
- /**
440
- * Determines if this adapter can handle the given element.
441
- * Checks if a renderer or editor is registered for this element.
442
- */
443
- canHandle(e) {
444
- const t = e.getAttribute("field");
445
- let r = G.get(e);
446
- if (!r && t) {
447
- const i = K.get(t);
448
- i && (i.renderer || i.editor) && (r = i, G.set(e, r));
449
- }
450
- const o = r?.renderer !== void 0, s = r?.editor !== void 0;
451
- return r !== void 0 && (o || s);
452
- }
453
- /**
454
- * Creates a view renderer function that renders a React component
455
- * and returns its container DOM element.
456
- *
457
- * Uses a cell cache to reuse portals for performance - instead of
458
- * creating new portals on each render, we reuse existing ones and
459
- * update their content.
460
- *
461
- * Returns undefined if no renderer is registered for this element,
462
- * allowing the grid to use its default rendering.
463
- */
464
- createRenderer(e) {
465
- const t = et(e);
466
- if (!t)
467
- return;
468
- const r = e.closest("tbw-grid"), o = /* @__PURE__ */ new WeakMap();
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),
483
- void 0,
484
- r ?? void 0
485
- );
486
- return o.set(i, { portalKey: R, container: C }), this.trackPortal(R, C, !1), C;
487
- }
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),
493
- void 0,
494
- r ?? void 0
495
- );
496
- return this.trackPortal(g, c, !1), c;
497
- };
498
- }
499
- /**
500
- * Creates an editor spec that renders a React component
501
- * with commit/cancel callbacks passed as props.
502
- */
503
- createEditor(e) {
504
- const t = tt(e);
505
- if (!t)
506
- return () => document.createElement("div");
507
- const r = e.closest("tbw-grid") ?? void 0;
508
- return (o) => {
509
- const s = document.createElement("div");
510
- s.className = "react-cell-editor", s.style.display = "contents";
511
- const i = b(
512
- s,
513
- t(o),
514
- void 0,
515
- r
516
- );
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;
527
- };
528
- }
529
- /**
530
- * Creates a detail renderer function for MasterDetailPlugin.
531
- * Renders React components for expandable detail rows.
532
- */
533
- createDetailRenderer(e) {
534
- const t = Je(e);
535
- if (t)
536
- return (r, o) => {
537
- const s = document.createElement("div");
538
- s.className = "react-detail-panel";
539
- const c = b(
540
- s,
541
- t({ row: r, rowIndex: o }),
542
- void 0,
543
- e
544
- );
545
- return this.trackPortal(c, s, !1), s;
546
- };
547
- }
548
- /**
549
- * Framework adapter hook called by MasterDetailPlugin during attach().
550
- * Parses the <tbw-grid-detail> element and returns a React-based renderer.
551
- */
552
- parseDetailElement(e) {
553
- const t = e.closest("tbw-grid");
554
- if (t)
555
- return this.createDetailRenderer(t);
556
- }
557
- /**
558
- * Creates a responsive card renderer function for ResponsivePlugin.
559
- * Renders React components for card layout in responsive mode.
560
- */
561
- createResponsiveCardRenderer(e) {
562
- const t = Re(e);
563
- if (t)
564
- return (r, o) => {
565
- const s = document.createElement("div");
566
- s.className = "react-responsive-card";
567
- const c = b(
568
- s,
569
- t({ row: r, index: o }),
570
- void 0,
571
- e
572
- );
573
- return this.trackPortal(c, s, !1), s;
574
- };
575
- }
576
- /**
577
- * FrameworkAdapter hook called by ResponsivePlugin during attach().
578
- * Parses the `<tbw-grid-responsive-card>` element and delegates to
579
- * {@link createResponsiveCardRenderer}. Needed for parity with the Vue
580
- * and Angular adapters so ResponsivePlugin's standard lookup path works
581
- * for React users as well, not just via the imperative
582
- * `refreshResponsiveCardRenderer` hook in DataGrid.
583
- */
584
- parseResponsiveCardElement(e) {
585
- const t = e.closest("tbw-grid");
586
- if (t)
587
- return this.createResponsiveCardRenderer(t);
588
- }
589
- /**
590
- * Creates a tool panel renderer from a light DOM element.
591
- * Renders React components into tool panel containers.
592
- */
593
- createToolPanelRenderer(e) {
594
- const t = Ze(e);
595
- if (!t)
596
- return;
597
- const r = e.closest("tbw-grid");
598
- return (o) => {
599
- const i = b(o, t({
600
- grid: r ?? o
601
- }), void 0, r ?? void 0);
602
- return this.trackPortal(i, o, !1), () => {
603
- A(i, { sync: !0 }), this.untrackPortal(i);
604
- };
605
- };
606
- }
607
- /**
608
- * Gets type-level defaults from the type defaults map.
609
- *
610
- * This enables application-wide type defaults configured via GridTypeProvider.
611
- * The returned TypeDefault contains renderer/editor functions that render
612
- * React components into the grid's cells.
613
- *
614
- * @example
615
- * ```tsx
616
- * // App.tsx
617
- * const typeDefaults = {
618
- * country: {
619
- * renderer: (ctx) => <CountryBadge code={ctx.value} />,
620
- * editor: (ctx) => <CountrySelect value={ctx.value} onCommit={ctx.commit} />
621
- * }
622
- * };
623
- *
624
- * <GridTypeProvider defaults={typeDefaults}>
625
- * <App />
626
- * </GridTypeProvider>
627
- *
628
- * // Any grid with type: 'country' columns will use these components
629
- * ```
630
- */
631
- getTypeDefault(e, t) {
632
- if (!this.typeDefaults)
633
- return;
634
- const r = this.typeDefaults[e];
635
- if (!r)
636
- return;
637
- const o = {
638
- editorParams: r.editorParams
639
- };
640
- return r.renderer && (o.renderer = this.createTypeRenderer(r.renderer, t)), r.editor && (o.editor = this.createTypeEditor(r.editor, t)), r.filterPanelRenderer && (o.filterPanelRenderer = this.createFilterPanelRenderer(r.filterPanelRenderer, t)), o;
641
- }
642
- /**
643
- * Creates a renderer function from a React render function for type defaults.
644
- * @internal
645
- */
646
- createTypeRenderer(e, t) {
647
- return (r) => {
648
- const o = document.createElement("span");
649
- o.style.display = "contents";
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;
652
- };
653
- }
654
- /**
655
- * Creates an editor function from a React render function for type defaults.
656
- * @internal
657
- */
658
- createTypeEditor(e, t) {
659
- return (r) => {
660
- const o = document.createElement("span");
661
- o.style.display = "contents";
662
- const s = b(o, e(r), void 0, t);
663
- return this.trackPortal(s, o, !0), o;
664
- };
665
- }
666
- /**
667
- * Creates a filter panel renderer that mounts React content into the filter panel container.
668
- * @internal
669
- */
670
- createFilterPanelRenderer(e, t) {
671
- return (r, o) => {
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);
676
- };
677
- }
678
- // #region Portal tracking helpers
679
- /** Register a portal key for lifecycle tracking. */
680
- trackPortal(e, t, r) {
681
- this.allPortalKeys.add(e), this.keyToContainer.set(e, t), this.containerToKey.set(t, e), r && this.editorPortalKeys.add(e);
682
- }
683
- /** Unregister a portal key from all tracking sets. */
684
- untrackPortal(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));
690
- }
691
- // #endregion
692
- /**
693
- * Clean up all mounted portals.
694
- * Call this when the grid is unmounted.
695
- */
696
- destroy() {
697
- for (const e of this.allPortalKeys)
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();
702
- }
703
- /**
704
- * Called when a cell's content is about to be wiped.
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.
724
- */
725
- releaseCell(e) {
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));
730
- }
731
- ze(e);
732
- }
733
- /**
734
- * Unmount a specific container (called when cell is recycled).
735
- */
736
- unmount(e) {
737
- const t = this.containerToKey.get(e);
738
- t && (A(t), this.untrackPortal(t));
739
- }
740
- }
741
- const nt = {
164
+ return /* @__PURE__ */ w(V, { children: P });
165
+ }), Me = {
742
166
  undoRedo: ["editing"],
743
167
  clipboard: ["selection"]
744
168
  };
745
- function ot(n) {
746
- const e = new Set(n);
747
- for (const t of n) {
748
- const r = nt[t];
749
- if (r)
750
- for (const o of r)
751
- e.has(o) || console.warn(
752
- `[DataGrid] Feature "${t}" requires "${o}" to be enabled. Add the "${o}" prop to your DataGrid.`
169
+ function Ne(r) {
170
+ const t = new Set(r);
171
+ for (const i of r) {
172
+ const o = Me[i];
173
+ if (o)
174
+ for (const d of o)
175
+ t.has(d) || console.warn(
176
+ `[DataGrid] Feature "${i}" requires "${d}" to be enabled. Add the "${d}" prop to your DataGrid.`
753
177
  );
754
178
  }
755
179
  }
756
- function it(n) {
757
- const e = [];
758
- for (const [t, r] of Object.entries(n))
759
- r === void 0 || r === !1 || e.push(t);
760
- return ot(e), xe(n);
761
- }
762
- let me = !1, V = null;
763
- function te() {
764
- return me || (V = new rt(), Ee.registerAdapter(V), me = !0), V;
765
- }
766
- te();
767
- function st(n) {
768
- const t = n.getPluginByName?.("masterDetail");
769
- t && typeof t.refreshDetailRenderer == "function" && t.refreshDetailRenderer();
770
- }
771
- function ct(n, e) {
772
- const t = n;
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);
778
- }
779
- }
780
- function at(n) {
781
- const e = {};
782
- return Te.forEach(n, (t) => {
783
- if (Ge(t)) {
784
- if (t.type && t.type.displayName === "GridDetailPanel") {
785
- const r = t.props;
786
- e.masterDetail = {
180
+ function Oe(r) {
181
+ const t = [];
182
+ for (const [i, o] of Object.entries(r))
183
+ o === void 0 || o === !1 || t.push(i);
184
+ return Ne(t), be(r);
185
+ }
186
+ let ne = !1, _ = null;
187
+ const oe = [
188
+ "selection",
189
+ "editing",
190
+ "filtering",
191
+ "multiSort",
192
+ "clipboard",
193
+ "contextMenu",
194
+ "reorderColumns",
195
+ "reorderRows",
196
+ "rowDragDrop",
197
+ "visibility",
198
+ "undoRedo",
199
+ "tree",
200
+ "groupingRows",
201
+ "groupingColumns",
202
+ "pinnedColumns",
203
+ "pinnedRows",
204
+ "masterDetail",
205
+ "responsive",
206
+ "columnVirtualization",
207
+ "export",
208
+ "print",
209
+ "pivot",
210
+ "serverSide",
211
+ "tooltip"
212
+ ];
213
+ function q() {
214
+ return ne || (_ = new we(), fe.registerAdapter(_), ne = !0), _;
215
+ }
216
+ q();
217
+ function ze(r) {
218
+ const i = r.getPluginByName?.("masterDetail");
219
+ i && typeof i.refreshDetailRenderer == "function" && i.refreshDetailRenderer();
220
+ }
221
+ function je(r, t) {
222
+ const i = r;
223
+ if (!r.querySelector("tbw-grid-responsive-card") || !ye(r)) return;
224
+ const g = i.getPluginByName?.("responsive");
225
+ if (g && typeof g.setCardRenderer == "function") {
226
+ const p = t.createResponsiveCardRenderer(r);
227
+ p && g.setCardRenderer(p);
228
+ }
229
+ }
230
+ function $e(r) {
231
+ const t = {};
232
+ return me.forEach(r, (i) => {
233
+ if (Ce(i)) {
234
+ if (i.type && i.type.displayName === "GridDetailPanel") {
235
+ const o = i.props;
236
+ t.masterDetail = {
787
237
  // Use props from the child component for configuration
788
- showExpandColumn: r.showExpandColumn ?? !0,
789
- animation: r.animation ?? "slide"
238
+ showExpandColumn: o.showExpandColumn ?? !0,
239
+ animation: o.animation ?? "slide"
790
240
  // detailRenderer will be wired up by refreshMasterDetailRenderer after mount
791
241
  };
792
242
  }
793
- t.type && t.type.displayName === "GridResponsiveCard" && (e.responsive = !0);
243
+ i.type && i.type.displayName === "GridResponsiveCard" && (t.responsive = !0);
794
244
  }
795
- }), e;
245
+ }), t;
796
246
  }
797
- const Rt = he(function(e, t) {
247
+ const rr = se(function(t, i) {
798
248
  const {
799
249
  // Core props
800
- rows: r,
801
- gridConfig: o,
802
- columns: s,
803
- columnDefaults: i,
804
- fitMode: c,
805
- sortable: g,
806
- filterable: l,
807
- selectable: C,
808
- loading: R,
809
- customStyles: m,
810
- className: w,
811
- style: D,
812
- children: x,
250
+ rows: o,
251
+ gridConfig: d,
252
+ columns: g,
253
+ columnDefaults: p,
254
+ fitMode: u,
255
+ sortable: R,
256
+ filterable: S,
257
+ selectable: P,
258
+ loading: h,
259
+ customStyles: l,
260
+ className: y,
261
+ style: G,
262
+ children: D,
813
263
  // Plugin props
814
- plugins: u,
815
- // SSR mode
816
- ssr: h,
264
+ plugins: s,
265
+ // SSR mode (deprecated - see SSRProps)
266
+ ssr: m,
817
267
  // Legacy event handlers
818
- onRowsChange: v,
268
+ onRowsChange: C,
819
269
  // Feature props and event props are in ...rest
820
- ...p
821
- } = e, f = k(null), q = k(null), oe = L(qe), j = L(Ie), ie = [
822
- "selection",
823
- "editing",
824
- "filtering",
825
- "multiSort",
826
- "clipboard",
827
- "contextMenu",
828
- "reorderColumns",
829
- "reorderRows",
830
- "rowDragDrop",
831
- "visibility",
832
- "undoRedo",
833
- "tree",
834
- "groupingRows",
835
- "groupingColumns",
836
- "pinnedColumns",
837
- "pinnedRows",
838
- "masterDetail",
839
- "responsive",
840
- "columnVirtualization",
841
- "export",
842
- "print",
843
- "pivot",
844
- "serverSide",
845
- "tooltip"
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(() => {
855
- if (u) {
856
- const a = new Set(u.map((y) => y.name)), d = z.filter((y) => !a.has(y.name));
857
- return [...u, ...d];
270
+ ...a
271
+ } = t, c = b(null), M = b(null), K = b(!1), U = F(ke), O = F(Le), ue = E(() => oe.map((e) => {
272
+ const n = a[e];
273
+ return n !== void 0 ? `${e}:${JSON.stringify(n)}` : "";
274
+ }).filter(Boolean).join("|"), [a]), Y = E(() => {
275
+ const e = {};
276
+ for (const n of oe)
277
+ n in a && a[n] !== void 0 && (e[n] = a[n]);
278
+ return e;
279
+ }, [ue]), J = E(() => $e(D), [D]), W = E(() => ({ ...J, ...Y }), [Y, J]), z = E(() => s || m ? [] : Oe(W), [W, s, m]), L = E(() => {
280
+ if (s) {
281
+ const e = new Set(s.map((f) => f.name)), n = z.filter((f) => !e.has(f.name));
282
+ return [...s, ...n];
858
283
  }
859
284
  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
866
- // Individual column props override defaults
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 };
285
+ }, [s, z]), A = E(() => g && De(Ee(g), p), [g, p]), k = E(() => {
286
+ const e = ve(d), n = {};
287
+ if (R !== void 0 && (n.sortable = R), S !== void 0 && (n.filterable = S), P !== void 0 && (n.selectable = P), O) {
288
+ const f = e?.icons || d?.icons || {};
289
+ n.icons = { ...O, ...f };
873
290
  }
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));
291
+ if (L.length > 0 && e) {
292
+ const f = e.plugins || [], I = new Set(f.map((T) => T.name)), $ = L.filter((T) => !I.has(T.name));
876
293
  return {
877
- ...a,
878
- ...d,
879
- plugins: [...y, ...U]
294
+ ...e,
295
+ ...n,
296
+ plugins: [...f, ...$]
880
297
  };
881
298
  }
882
- return F.length > 0 && !a ? { ...d, plugins: F } : Object.keys(d).length > 0 ? { ...a, ...d } : a;
883
- }, [o, F, g, l, C, j]);
884
- P(() => {
885
- te().setTypeDefaults(oe);
886
- }, [oe]), P(() => {
887
- f.current && (f.current.rows = r);
888
- }, [r]), P(() => {
889
- f.current && I && (f.current.gridConfig = I);
890
- }, [I]), P(() => {
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);
901
- let y = !1;
902
- const H = requestAnimationFrame(() => {
903
- y || (typeof a.refreshColumns == "function" && a.refreshColumns(), typeof a.refreshShellHeader == "function" && a.refreshShellHeader());
299
+ return L.length > 0 && !e ? { ...n, plugins: L } : Object.keys(n).length > 0 ? { ...e, ...n } : e;
300
+ }, [d, L, R, S, P, O]);
301
+ v(() => {
302
+ q().setTypeDefaults(U);
303
+ }, [U]), v(() => {
304
+ c.current && (c.current.rows = o);
305
+ }, [o]), v(() => {
306
+ c.current && k && (c.current.gridConfig = k);
307
+ }, [k]), v(() => {
308
+ c.current && A && (c.current.columns = A);
309
+ }, [A]), v(() => {
310
+ c.current && u !== void 0 && (c.current.fitMode = u);
311
+ }, [u]), v(() => {
312
+ c.current && h !== void 0 && (c.current.loading = h);
313
+ }, [h]), v(() => {
314
+ const e = c.current;
315
+ if (!e) return;
316
+ const n = q();
317
+ e.__frameworkAdapter = n, ze(e), je(e, n);
318
+ let f = !1;
319
+ const I = requestAnimationFrame(() => {
320
+ f || (typeof e.refreshColumns == "function" && e.refreshColumns(), typeof e.refreshShellHeader == "function" && e.refreshShellHeader());
904
321
  });
905
322
  return () => {
906
- y = !0, cancelAnimationFrame(H);
323
+ f = !0, cancelAnimationFrame(I);
907
324
  };
908
- }, []), P(() => {
909
- if (!f.current || !m) return;
910
- const a = f.current, d = "react-custom-styles";
911
- let y = !0;
912
- return a.ready?.().then(() => {
913
- y && m && (a.registerStyles?.(d, m), q.current = d);
325
+ }, []), v(() => {
326
+ if (!c.current || !l) return;
327
+ const e = c.current, n = "react-custom-styles";
328
+ let f = !0;
329
+ return e.ready?.().then(() => {
330
+ f && l && (e.registerStyles?.(n, l), M.current = n);
914
331
  }), () => {
915
- y = !1, q.current && (a.unregisterStyles?.(q.current), q.current = null);
332
+ f = !1, M.current && (e.unregisterStyles?.(M.current), M.current = null);
916
333
  };
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());
334
+ }, [l]), v(() => {
335
+ const e = c.current;
336
+ if (!e) return;
337
+ const n = [];
338
+ return C && n.push(e.on("rows-change", (f) => C(f.rows))), () => {
339
+ n.forEach((f) => f());
923
340
  };
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];
928
- P(() => {
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);
341
+ }, [C]);
342
+ const Z = E(() => Object.keys(B).filter((e) => typeof a[e] == "function").sort().join("|"), [a]), Q = b({});
343
+ for (const e of Object.keys(B))
344
+ Q.current[e] = a[e];
345
+ v(() => {
346
+ const e = c.current;
347
+ if (!e) return;
348
+ const n = [];
349
+ for (const [f, I] of Object.entries(B))
350
+ Z.includes(f) && n.push(
351
+ e.on(I, ($, T) => {
352
+ Q.current[f]?.($, T);
936
353
  })
937
354
  );
938
355
  return () => {
939
- d.forEach((y) => y());
356
+ n.forEach((f) => f());
940
357
  };
941
- }, [le]), ve(
942
- t,
358
+ }, [Z]), ce(
359
+ i,
943
360
  () => ({
944
361
  get element() {
945
- return f.current;
362
+ return c.current;
946
363
  },
947
364
  async getConfig() {
948
- return f.current?.getConfig?.() ?? {};
365
+ return c.current?.getConfig?.() ?? {};
949
366
  },
950
367
  async ready() {
951
- return f.current?.ready?.();
368
+ return c.current?.ready?.();
952
369
  },
953
370
  async forceLayout() {
954
- return f.current?.forceLayout?.();
371
+ return c.current?.forceLayout?.();
955
372
  },
956
- async toggleGroup(a) {
957
- return f.current?.toggleGroup?.(a);
373
+ async toggleGroup(e) {
374
+ return c.current?.toggleGroup?.(e);
958
375
  },
959
- registerStyles(a, d) {
960
- f.current?.registerStyles?.(a, d);
376
+ registerStyles(e, n) {
377
+ c.current?.registerStyles?.(e, n);
961
378
  },
962
- unregisterStyles(a) {
963
- f.current?.unregisterStyles?.(a);
379
+ unregisterStyles(e) {
380
+ c.current?.unregisterStyles?.(e);
964
381
  },
965
- setRowLoading(a, d) {
966
- f.current?.setRowLoading?.(a, d);
382
+ setRowLoading(e, n) {
383
+ c.current?.setRowLoading?.(e, n);
967
384
  },
968
- setCellLoading(a, d, y) {
969
- f.current?.setCellLoading?.(a, d, y);
385
+ setCellLoading(e, n, f) {
386
+ c.current?.setCellLoading?.(e, n, f);
970
387
  },
971
- isRowLoading(a) {
972
- return f.current?.isRowLoading?.(a) ?? !1;
388
+ isRowLoading(e) {
389
+ return c.current?.isRowLoading?.(e) ?? !1;
973
390
  },
974
- isCellLoading(a, d) {
975
- return f.current?.isCellLoading?.(a, d) ?? !1;
391
+ isCellLoading(e, n) {
392
+ return c.current?.isCellLoading?.(e, n) ?? !1;
976
393
  },
977
394
  clearAllLoading() {
978
- f.current?.clearAllLoading?.();
395
+ c.current?.clearAllLoading?.();
979
396
  }
980
397
  }),
981
398
  []
982
399
  );
983
- const $ = k(null);
984
- return De(() => {
985
- const a = f.current;
986
- return a && $.current && fe(a, $.current), () => {
987
- a && fe(a, null);
400
+ const j = b(null);
401
+ return pe(() => {
402
+ const e = c.current;
403
+ return e && j.current && ee(e, j.current), () => {
404
+ e && ee(e, null);
988
405
  };
989
- }, []), /* @__PURE__ */ Pe(re, { children: [
990
- /* @__PURE__ */ E(je, { ref: $ }),
991
- /* @__PURE__ */ E(
406
+ }, []), /* @__PURE__ */ le(V, { children: [
407
+ /* @__PURE__ */ w(Te, { ref: j }),
408
+ /* @__PURE__ */ w(
992
409
  "tbw-grid",
993
410
  {
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);
411
+ ref: (e) => {
412
+ if (c.current = e, e && !K.current) {
413
+ K.current = !0;
414
+ const n = e;
415
+ k && (n.gridConfig = k), o && (n.rows = o), A && (n.columns = A);
998
416
  }
999
417
  },
1000
- class: w,
1001
- style: D,
1002
- children: /* @__PURE__ */ E(Ce.Provider, { value: f, children: x })
418
+ class: y,
419
+ style: G,
420
+ children: /* @__PURE__ */ w(ae.Provider, { value: c, children: D })
1003
421
  }
1004
422
  )
1005
423
  ] });
1006
424
  });
1007
- function wt(n) {
425
+ function tr(r) {
1008
426
  const {
1009
- field: e,
1010
- header: t,
1011
- type: r,
1012
- editable: o,
1013
- sortable: s,
1014
- resizable: i,
1015
- width: c,
1016
- minWidth: g,
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(
1025
- (f) => {
1026
- u.current = f, f && (R && Qe(f, R), m && Xe(f, m));
427
+ field: t,
428
+ header: i,
429
+ type: o,
430
+ editable: d,
431
+ sortable: g,
432
+ resizable: p,
433
+ width: u,
434
+ minWidth: R,
435
+ hidden: S,
436
+ lockVisible: P,
437
+ children: h,
438
+ editor: l,
439
+ options: y,
440
+ multi: G,
441
+ format: D
442
+ } = r, s = b(null), m = x(
443
+ (c) => {
444
+ s.current = c, c && (h && Re(c, h), l && Pe(c, l));
1027
445
  },
1028
- [R, m, e]
1029
- ), v = typeof c == "number" ? `${c}px` : c, p = {
1030
- field: e,
1031
- ref: h
446
+ [h, l, t]
447
+ ), C = typeof u == "number" ? `${u}px` : u, a = {
448
+ field: t,
449
+ ref: m
1032
450
  };
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 });
451
+ return i !== void 0 && (a.header = i), o !== void 0 && (a.type = o), d !== void 0 && (a.editable = d), g !== void 0 && (a.sortable = g), p !== void 0 && (a.resizable = p), C !== void 0 && (a.width = C), R !== void 0 && (a["min-width"] = R), S !== void 0 && (a.hidden = S), P !== void 0 && (a["lock-visible"] = P), G !== void 0 && (a.multi = G), D && (a["data-has-format"] = "true"), y && (a["data-has-options"] = "true"), /* @__PURE__ */ w("tbw-grid-column", { ...a });
1034
452
  }
1035
- function bt({ children: n }) {
1036
- return /* @__PURE__ */ E("tbw-grid-tool-buttons", { children: n });
453
+ function nr({ children: r }) {
454
+ return /* @__PURE__ */ w("tbw-grid-tool-buttons", { children: r });
1037
455
  }
1038
- const Pt = ({ icons: n, defaults: e, children: t }) => {
1039
- let r = t;
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 });
456
+ const or = ({ icons: r, defaults: t, children: i }) => {
457
+ let o = i;
458
+ return t && (o = /* @__PURE__ */ w(Ae, { defaults: t, children: o })), r && (o = /* @__PURE__ */ w(Fe, { icons: r, children: o })), /* @__PURE__ */ w(V, { children: o });
1041
459
  };
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]);
1044
- P(() => {
1045
- let u = !0;
460
+ function ir(r) {
461
+ const t = b(null), [i, o] = X(!1), [d, g] = X(null), p = b(null), u = x(() => r ? (p.current ??= document.querySelector(r), p.current) : t.current?.element ?? null, [r]);
462
+ v(() => {
463
+ let s = !0;
1046
464
  return (async () => {
1047
465
  try {
1048
- if (n) {
1049
- const v = document.querySelector(n);
1050
- if (!v) return;
1051
- if (i.current = v, await v.ready?.(), u) {
1052
- r(!0);
1053
- const p = await v.getConfig?.();
1054
- u && p && s(p);
466
+ if (r) {
467
+ const C = document.querySelector(r);
468
+ if (!C) return;
469
+ if (p.current = C, await C.ready?.(), s) {
470
+ o(!0);
471
+ const a = await C.getConfig?.();
472
+ s && a && g(a);
1055
473
  }
1056
474
  } else {
1057
- const v = e.current;
1058
- if (!v) return;
1059
- if (await v.ready?.(), u) {
1060
- r(!0);
1061
- const p = await v.getConfig?.();
1062
- u && p && s(p);
475
+ const C = t.current;
476
+ if (!C) return;
477
+ if (await C.ready?.(), s) {
478
+ o(!0);
479
+ const a = await C.getConfig?.();
480
+ s && a && g(a);
1063
481
  }
1064
482
  }
1065
483
  } catch {
1066
484
  }
1067
485
  })(), () => {
1068
- u = !1;
486
+ s = !1;
1069
487
  };
1070
- }, [n]);
1071
- const g = S(async () => {
1072
- const u = c();
1073
- if (u)
1074
- return await u.getConfig?.() ?? null;
1075
- const h = e.current;
1076
- return h ? await h.getConfig?.() ?? null : null;
1077
- }, [c]), l = S(async () => {
1078
- const u = c();
1079
- if (u) {
1080
- await u.forceLayout?.();
488
+ }, [r]);
489
+ const R = x(async () => {
490
+ const s = u();
491
+ if (s)
492
+ return await s.getConfig?.() ?? null;
493
+ const m = t.current;
494
+ return m ? await m.getConfig?.() ?? null : null;
495
+ }, [u]), S = x(async () => {
496
+ const s = u();
497
+ if (s) {
498
+ await s.forceLayout?.();
1081
499
  return;
1082
500
  }
1083
- const h = e.current;
1084
- h && await h.forceLayout?.();
1085
- }, [c]), C = S(
1086
- async (u) => {
1087
- const h = c();
1088
- if (h) {
1089
- await h.toggleGroup?.(u);
501
+ const m = t.current;
502
+ m && await m.forceLayout?.();
503
+ }, [u]), P = x(
504
+ async (s) => {
505
+ const m = u();
506
+ if (m) {
507
+ await m.toggleGroup?.(s);
1090
508
  return;
1091
509
  }
1092
- const v = e.current;
1093
- v && await v.toggleGroup?.(u);
510
+ const C = t.current;
511
+ C && await C.toggleGroup?.(s);
1094
512
  },
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(
1103
- (u, h) => {
1104
- const v = c();
1105
- if (v) {
1106
- v.registerStyles?.(u, h);
513
+ [u]
514
+ ), h = x(
515
+ (s) => u()?.getPlugin?.(s),
516
+ [u]
517
+ ), l = x(
518
+ ((s) => u()?.getPluginByName?.(s)),
519
+ [u]
520
+ ), y = x(
521
+ (s, m) => {
522
+ const C = u();
523
+ if (C) {
524
+ C.registerStyles?.(s, m);
1107
525
  return;
1108
526
  }
1109
- e.current?.registerStyles?.(u, h);
527
+ t.current?.registerStyles?.(s, m);
1110
528
  },
1111
- [c]
1112
- ), D = S(
1113
- (u) => {
1114
- const h = c();
1115
- if (h) {
1116
- h.unregisterStyles?.(u);
529
+ [u]
530
+ ), G = x(
531
+ (s) => {
532
+ const m = u();
533
+ if (m) {
534
+ m.unregisterStyles?.(s);
1117
535
  return;
1118
536
  }
1119
- e.current?.unregisterStyles?.(u);
537
+ t.current?.unregisterStyles?.(s);
1120
538
  },
1121
- [c]
1122
- ), x = S(() => o?.columns ? o.columns.filter((u) => !u.hidden) : [], [o]);
539
+ [u]
540
+ ), D = x(() => d?.columns ? d.columns.filter((s) => !s.hidden) : [], [d]);
1123
541
  return {
1124
- ref: e,
1125
- element: c(),
1126
- isReady: t,
1127
- config: o,
1128
- getConfig: g,
1129
- forceLayout: l,
1130
- toggleGroup: C,
1131
- getPlugin: R,
1132
- getPluginByName: m,
1133
- registerStyles: w,
1134
- unregisterStyles: D,
1135
- getVisibleColumns: x
542
+ ref: t,
543
+ element: u(),
544
+ isReady: i,
545
+ config: d,
546
+ getConfig: R,
547
+ forceLayout: S,
548
+ toggleGroup: P,
549
+ getPlugin: h,
550
+ getPluginByName: l,
551
+ registerStyles: y,
552
+ unregisterStyles: G,
553
+ getVisibleColumns: D
1136
554
  };
1137
555
  }
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);
556
+ function sr(r, t = {}) {
557
+ const { open: i = !0, gridElement: o } = t, d = F(ae);
558
+ v(() => {
559
+ if (!i) return;
560
+ const g = r.current;
561
+ if (!g) return;
562
+ const p = o ?? g.closest("tbw-grid") ?? d?.current ?? null;
563
+ if (p)
564
+ return p.registerExternalFocusContainer?.(g), () => {
565
+ p.unregisterExternalFocusContainer?.(g);
1148
566
  };
1149
- }, [t, r, o, n]);
567
+ }, [i, o, d, r]);
1150
568
  }
1151
569
  export {
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
570
+ rr as DataGrid,
571
+ we as GridAdapter,
572
+ tr as GridColumn,
573
+ gr as GridDetailPanel,
574
+ Fe as GridIconProvider,
575
+ or as GridProvider,
576
+ ur as GridResponsiveCard,
577
+ nr as GridToolButtons,
578
+ fr as GridToolPanel,
579
+ Ae as GridTypeProvider,
580
+ De as applyColumnDefaults,
581
+ Ze as hasColumnShorthands,
582
+ Ee as normalizeColumns,
583
+ xe as parseColumnShorthand,
584
+ ir as useGrid,
585
+ Qe as useGridIcons,
586
+ sr as useGridOverlay,
587
+ Xe as useGridTypeDefaults,
588
+ er as useTypeDefault
1167
589
  };