@toolbox-web/grid-react 1.3.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.
Files changed (39) hide show
  1. package/README.md +1 -1
  2. package/chunks/grid-detail-panel-CR7YUhdN.js +52 -0
  3. package/chunks/grid-responsive-card-BB28Zl2O.js +45 -0
  4. package/chunks/portal-bridge-DLA6Zs11.js +51 -0
  5. package/chunks/react-column-config-Sb-U7Bq3.js +109 -0
  6. package/chunks/react-grid-adapter-CzByOnua.js +416 -0
  7. package/features/editing.js +5 -0
  8. package/features/filtering.d.ts.map +1 -1
  9. package/features/filtering.js +55 -45
  10. package/features/grouping-columns.js +18 -23
  11. package/features/grouping-rows.js +11 -16
  12. package/features/index.js +3 -3
  13. package/features/master-detail.js +18 -0
  14. package/features/pinned-rows.d.ts.map +1 -1
  15. package/features/pinned-rows.js +24 -17
  16. package/features/responsive.js +18 -0
  17. package/index.d.ts +2 -0
  18. package/index.d.ts.map +1 -1
  19. package/index.js +438 -895
  20. package/lib/column-shorthand.d.ts +22 -1
  21. package/lib/column-shorthand.d.ts.map +1 -1
  22. package/lib/data-grid.d.ts.map +1 -1
  23. package/lib/editor-mount-hooks.d.ts +39 -0
  24. package/lib/editor-mount-hooks.d.ts.map +1 -0
  25. package/lib/event-props.d.ts +132 -6
  26. package/lib/event-props.d.ts.map +1 -1
  27. package/lib/feature-props.d.ts +17 -2
  28. package/lib/feature-props.d.ts.map +1 -1
  29. package/lib/portal-bridge.d.ts +11 -0
  30. package/lib/portal-bridge.d.ts.map +1 -1
  31. package/lib/portal-manager.d.ts.map +1 -1
  32. package/lib/react-column-config.d.ts +36 -5
  33. package/lib/react-column-config.d.ts.map +1 -1
  34. package/lib/react-grid-adapter.d.ts +111 -14
  35. package/lib/react-grid-adapter.d.ts.map +1 -1
  36. package/lib/use-grid-overlay.d.ts +74 -0
  37. package/lib/use-grid-overlay.d.ts.map +1 -0
  38. package/package.json +1 -1
  39. package/chunks/portal-bridge-DZ4yQkmm.js +0 -42
package/index.js CHANGED
@@ -1,49 +1,68 @@
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) {
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(xe).join(" ");
13
- }
14
- const Ke = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime", "currency"]);
15
- function Ne(n) {
16
- const e = n.lastIndexOf(":");
17
- if (e > 0) {
18
- const t = n.slice(e + 1).toLowerCase();
19
- if (Ke.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" ? Ne(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 W = {
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,993 +73,517 @@ const W = {
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
- }, oe = ye(null), Ie = ({ icons: n, children: e }) => /* @__PURE__ */ b(oe.Provider, { value: n, children: e });
68
- function pt() {
69
- return O(oe);
70
- }
71
- const Le = oe, Y = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new Map();
72
- function ve(n) {
73
- const e = n.querySelector("tbw-grid-responsive-card");
74
- if (e) {
75
- const r = Y.get(e);
76
- if (r) return r;
90
+ }, H = ie(null), Fe = ({ icons: r, children: t }) => /* @__PURE__ */ w(H.Provider, { value: r, children: t });
91
+ function Qe() {
92
+ return F(H);
93
+ }
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);
97
+ }
98
+ function er(r) {
99
+ return F(N)?.[r];
100
+ }
101
+ const ke = N;
102
+ class Ie extends ge {
103
+ state = { failed: !1 };
104
+ static getDerivedStateFromError() {
105
+ return { failed: !0 };
106
+ }
107
+ componentDidCatch(t) {
108
+ this.props.onError(this.props.portalKey, t);
109
+ }
110
+ render() {
111
+ return this.state.failed ? null : this.props.children;
77
112
  }
78
- const t = n.id || n.getAttribute("data-grid-id");
79
- if (t)
80
- return Z.get(t);
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);
91
- }
92
- },
93
- [e]
94
- );
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);
103
- }
104
- }
105
- }, []);
106
- const a = t === "auto" ? "auto" : String(t);
107
- return /* @__PURE__ */ b("tbw-grid-responsive-card", { ref: o, cardRowHeight: a });
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);
113
- }
114
- function yt(n) {
115
- return O(z)?.[n];
116
113
  }
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();
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();
121
118
  }));
122
- }, 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);
119
+ }, R = () => {
120
+ p.current || (p.current = requestAnimationFrame(() => {
121
+ p.current = 0, d();
129
122
  }));
123
+ }, S = (l, y) => {
124
+ console.error(`[grid-react] Portal "${l}" crashed; dropping.`, y), o.current.delete(l), R();
130
125
  };
131
- Re(
132
- t,
126
+ ce(
127
+ i,
133
128
  () => ({
134
- renderPortal(p, v, C) {
135
- r.current.set(p, { container: v, element: C }), s();
129
+ renderPortal(l, y, G) {
130
+ o.current.set(l, { container: y, element: G }), u();
136
131
  },
137
- removePortal(p, v) {
138
- r.current.delete(p) && (v ? V(o) : s());
132
+ removePortal(l, y) {
133
+ o.current.delete(l) && (y ? re(d) : u());
139
134
  },
140
135
  clear() {
141
- r.current.size > 0 && (r.current.clear(), c.current && (cancelAnimationFrame(c.current), c.current = 0), s());
136
+ o.current.size > 0 && (o.current.clear(), p.current && (cancelAnimationFrame(p.current), p.current = 0), u());
142
137
  }
143
138
  }),
144
139
  // forceRender is stable (useReducer dispatch), refs are stable
145
140
  // eslint-disable-next-line react-hooks/exhaustive-deps
146
141
  []
147
142
  );
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 = [];
153
- 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));
157
- }
158
- }
159
- function qe(n) {
160
- const e = /* @__PURE__ */ new WeakMap();
161
- return (t) => {
162
- const r = t.cellEl;
163
- if (r) {
164
- const c = e.get(r);
165
- if (c)
166
- return w(c.container, n(t), c.portalKey), c.container;
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);
148
+ continue;
167
149
  }
168
- const o = document.createElement("div");
169
- 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;
172
- };
173
- }
174
- function _e(n) {
175
- return (e) => {
176
- const t = document.createElement("div");
177
- 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;
180
- };
181
- }
182
- function $e(n) {
183
- return (e) => {
184
- const t = document.createElement("div");
185
- 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;
188
- };
189
- }
190
- function Be(n) {
191
- return (e) => {
192
- const t = document.createElement("div");
193
- 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;
196
- };
197
- }
198
- function Ve(n) {
199
- return (e) => {
200
- const t = n(e);
201
- if (t instanceof HTMLElement || typeof t == "string")
202
- return t;
203
- const r = document.createElement("div");
204
- r.className = "react-loading-renderer", r.style.display = "contents";
205
- const o = w(r, t);
206
- return D.push({ key: o, container: r }), r;
207
- };
208
- }
209
- function Ce(n) {
210
- if (!n) return;
211
- if (n[U]) return n;
212
- if (n.loadingRenderer && typeof n.loadingRenderer == "function") {
213
- const r = n.loadingRenderer;
214
- n = {
215
- ...n,
216
- loadingRenderer: Ve(r)
217
- };
218
- }
219
- if (!n.columns) {
220
- const r = n;
221
- return r[U] = !0, r;
222
- }
223
- 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;
226
- }), t = {
227
- ...n,
228
- columns: e
229
- };
230
- return t[U] = !0, t;
231
- }
232
- const Q = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new Map();
233
- function We(n) {
234
- const e = n.querySelector("tbw-grid-detail");
235
- if (e) {
236
- const r = Q.get(e);
237
- if (r) return r;
238
- }
239
- const t = n.id || n.getAttribute("data-grid-id");
240
- if (t)
241
- return X.get(t);
242
- }
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");
249
- if (g) {
250
- const d = g.id || g.getAttribute("data-grid-id");
251
- d && X.set(d, e);
252
- }
253
- },
254
- [e]
255
- );
256
- return P(() => () => {
257
- const s = o.current;
258
- if (s) {
259
- Q.delete(s);
260
- const g = s.closest("tbw-grid");
261
- if (g) {
262
- const p = g.id || g.getAttribute("data-grid-id");
263
- p && X.delete(p);
264
- }
265
- const d = s.parentNode;
266
- d && d.contains(s);
267
- }
268
- }, []), /* @__PURE__ */ b(
269
- "tbw-grid-detail",
270
- {
271
- ref: a,
272
- showExpandColumn: t ? void 0 : "false",
273
- animation: r === !1 ? "false" : r
274
- }
275
- );
276
- }
277
- Ue.displayName = "GridDetailPanel";
278
- const ee = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new Map();
279
- function Je(n) {
280
- const e = ee.get(n);
281
- if (e) return e;
282
- const t = n.id;
283
- if (t)
284
- return te.get(t);
285
- }
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));
290
- },
291
- [c, e]
292
- );
293
- return P(() => () => {
294
- const d = s.current;
295
- d && (ee.delete(d), e && te.delete(e));
296
- }, [e]), /* @__PURE__ */ b(
297
- "tbw-grid-tool-panel",
298
- {
299
- ref: g,
300
- id: e,
301
- title: t,
302
- icon: r,
303
- tooltip: o,
304
- order: a?.toString()
305
- }
306
- );
307
- }
308
- const G = /* @__PURE__ */ new WeakMap(), A = /* @__PURE__ */ new Map();
309
- function Ye(n, e) {
310
- const t = n.getAttribute("field"), r = G.get(n) ?? {};
311
- if (r.renderer = e, G.set(n, r), t) {
312
- const o = A.get(t) ?? {};
313
- o.renderer = e, A.set(t, o);
314
- }
315
- }
316
- function Ze(n, e) {
317
- const t = n.getAttribute("field"), r = G.get(n) ?? {};
318
- if (r.editor = e, G.set(n, r), t) {
319
- const o = A.get(t) ?? {};
320
- o.editor = e, A.set(t, o);
321
- }
322
- }
323
- function Qe(n) {
324
- let e = G.get(n)?.renderer;
325
- if (!e) {
326
- const t = n.getAttribute("field");
327
- t && (e = A.get(t)?.renderer);
328
- }
329
- return e;
330
- }
331
- function Xe(n) {
332
- let e = G.get(n)?.editor;
333
- if (!e) {
334
- const t = n.getAttribute("field");
335
- t && (e = A.get(t)?.editor);
336
- }
337
- return e;
338
- }
339
- class et {
340
- /** Portal keys for all managed portals (for cleanup on destroy). */
341
- allPortalKeys = /* @__PURE__ */ new Set();
342
- /** Portal keys for editor-specific portals (for per-cell cleanup via releaseCell). */
343
- editorPortalKeys = /* @__PURE__ */ new Set();
344
- /** Maps portal keys to their containers (for container-based lookups in releaseCell/unmount). */
345
- keyToContainer = /* @__PURE__ */ new Map();
346
- typeDefaults = null;
347
- /**
348
- * Sets the type defaults map for this adapter.
349
- * Called by DataGrid when it receives type defaults from context.
350
- *
351
- * @internal
352
- */
353
- setTypeDefaults(e) {
354
- this.typeDefaults = e;
150
+ P.push(
151
+ he(
152
+ /* @__PURE__ */ w(Ie, { portalKey: l, onError: S, children: G }),
153
+ y,
154
+ l
155
+ )
156
+ );
355
157
  }
356
- /**
357
- * FrameworkAdapter.processConfig implementation.
358
- * Called automatically by the grid's `set gridConfig` setter.
359
- * Converts React renderer/editor functions to DOM-returning functions.
360
- */
361
- processConfig(e) {
362
- return Ce(e) ?? e;
363
- }
364
- /**
365
- * Determines if this adapter can handle the given element.
366
- * Checks if a renderer or editor is registered for this element.
367
- */
368
- canHandle(e) {
369
- const t = e.getAttribute("field");
370
- let r = G.get(e);
371
- if (!r && t) {
372
- const c = A.get(t);
373
- c && (c.renderer || c.editor) && (r = c, G.set(e, r));
374
- }
375
- const o = r?.renderer !== void 0, a = r?.editor !== void 0;
376
- return r !== void 0 && (o || a);
377
- }
378
- /**
379
- * Creates a view renderer function that renders a React component
380
- * and returns its container DOM element.
381
- *
382
- * Uses a cell cache to reuse portals for performance - instead of
383
- * creating new portals on each render, we reuse existing ones and
384
- * update their content.
385
- *
386
- * Returns undefined if no renderer is registered for this element,
387
- * allowing the grid to use its default rendering.
388
- */
389
- createRenderer(e) {
390
- const t = Qe(e);
391
- if (!t)
392
- return;
393
- 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),
405
- void 0,
406
- r ?? void 0
407
- );
408
- return o.set(c, { portalKey: v, container: p }), this.trackPortal(v, p, !1), p;
409
- }
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),
415
- void 0,
416
- r ?? void 0
417
- );
418
- return this.trackPortal(g, s, !1), s;
419
- };
420
- }
421
- /**
422
- * Creates an editor spec that renders a React component
423
- * with commit/cancel callbacks passed as props.
424
- */
425
- createEditor(e) {
426
- const t = Xe(e);
427
- if (!t)
428
- return () => document.createElement("div");
429
- const r = e.closest("tbw-grid") ?? void 0;
430
- return (o) => {
431
- const a = document.createElement("div");
432
- a.className = "react-cell-editor", a.style.display = "contents";
433
- const c = w(
434
- a,
435
- t(o),
436
- void 0,
437
- r
438
- );
439
- return this.trackPortal(c, a, !0), a;
440
- };
441
- }
442
- /**
443
- * Creates a detail renderer function for MasterDetailPlugin.
444
- * Renders React components for expandable detail rows.
445
- */
446
- createDetailRenderer(e) {
447
- const t = We(e);
448
- if (t)
449
- return (r, o) => {
450
- const a = document.createElement("div");
451
- a.className = "react-detail-panel";
452
- const s = w(
453
- a,
454
- t({ row: r, rowIndex: o }),
455
- void 0,
456
- e
457
- );
458
- return this.trackPortal(s, a, !1), a;
459
- };
460
- }
461
- /**
462
- * Framework adapter hook called by MasterDetailPlugin during attach().
463
- * Parses the <tbw-grid-detail> element and returns a React-based renderer.
464
- */
465
- parseDetailElement(e) {
466
- const t = e.closest("tbw-grid");
467
- if (t)
468
- return this.createDetailRenderer(t);
469
- }
470
- /**
471
- * Creates a responsive card renderer function for ResponsivePlugin.
472
- * Renders React components for card layout in responsive mode.
473
- */
474
- createResponsiveCardRenderer(e) {
475
- const t = ve(e);
476
- if (t)
477
- return (r, o) => {
478
- const a = document.createElement("div");
479
- a.className = "react-responsive-card";
480
- const s = w(
481
- a,
482
- t({ row: r, index: o }),
483
- void 0,
484
- e
485
- );
486
- return this.trackPortal(s, a, !1), a;
487
- };
488
- }
489
- /**
490
- * FrameworkAdapter hook called by ResponsivePlugin during attach().
491
- * Parses the `<tbw-grid-responsive-card>` element and delegates to
492
- * {@link createResponsiveCardRenderer}. Needed for parity with the Vue
493
- * and Angular adapters so ResponsivePlugin's standard lookup path works
494
- * for React users as well, not just via the imperative
495
- * `refreshResponsiveCardRenderer` hook in DataGrid.
496
- */
497
- parseResponsiveCardElement(e) {
498
- const t = e.closest("tbw-grid");
499
- if (t)
500
- return this.createResponsiveCardRenderer(t);
501
- }
502
- /**
503
- * Creates a tool panel renderer from a light DOM element.
504
- * Renders React components into tool panel containers.
505
- */
506
- createToolPanelRenderer(e) {
507
- const t = Je(e);
508
- if (!t)
509
- return;
510
- const r = e.closest("tbw-grid");
511
- return (o) => {
512
- const c = w(o, t({
513
- grid: r ?? o
514
- }), void 0, r ?? void 0);
515
- return this.trackPortal(c, o, !1), () => {
516
- H(c, { sync: !0 }), this.untrackPortal(c);
517
- };
518
- };
519
- }
520
- /**
521
- * Gets type-level defaults from the type defaults map.
522
- *
523
- * This enables application-wide type defaults configured via GridTypeProvider.
524
- * The returned TypeDefault contains renderer/editor functions that render
525
- * React components into the grid's cells.
526
- *
527
- * @example
528
- * ```tsx
529
- * // App.tsx
530
- * const typeDefaults = {
531
- * country: {
532
- * renderer: (ctx) => <CountryBadge code={ctx.value} />,
533
- * editor: (ctx) => <CountrySelect value={ctx.value} onCommit={ctx.commit} />
534
- * }
535
- * };
536
- *
537
- * <GridTypeProvider defaults={typeDefaults}>
538
- * <App />
539
- * </GridTypeProvider>
540
- *
541
- * // Any grid with type: 'country' columns will use these components
542
- * ```
543
- */
544
- getTypeDefault(e, t) {
545
- if (!this.typeDefaults)
546
- return;
547
- const r = this.typeDefaults[e];
548
- if (!r)
549
- return;
550
- const o = {
551
- editorParams: r.editorParams
552
- };
553
- 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;
554
- }
555
- /**
556
- * Creates a renderer function from a React render function for type defaults.
557
- * @internal
558
- */
559
- createTypeRenderer(e, t) {
560
- return (r) => {
561
- const o = document.createElement("span");
562
- 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;
565
- };
566
- }
567
- /**
568
- * Creates an editor function from a React render function for type defaults.
569
- * @internal
570
- */
571
- createTypeEditor(e, t) {
572
- return (r) => {
573
- const o = document.createElement("span");
574
- o.style.display = "contents";
575
- const a = w(o, e(r), void 0, t);
576
- return this.trackPortal(a, o, !0), o;
577
- };
578
- }
579
- /**
580
- * Creates a filter panel renderer that mounts React content into the filter panel container.
581
- * @internal
582
- */
583
- createFilterPanelRenderer(e, t) {
584
- 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);
589
- };
590
- }
591
- // #region Portal tracking helpers
592
- /** Register a portal key for lifecycle tracking. */
593
- trackPortal(e, t, r) {
594
- this.allPortalKeys.add(e), this.keyToContainer.set(e, t), r && this.editorPortalKeys.add(e);
595
- }
596
- /** Unregister a portal key from all tracking sets. */
597
- untrackPortal(e) {
598
- this.allPortalKeys.delete(e), this.editorPortalKeys.delete(e), this.keyToContainer.delete(e);
599
- }
600
- // #endregion
601
- /**
602
- * Clean up all mounted portals.
603
- * Call this when the grid is unmounted.
604
- */
605
- destroy() {
606
- for (const e of this.allPortalKeys)
607
- H(e);
608
- this.allPortalKeys.clear(), this.editorPortalKeys.clear(), this.keyToContainer.clear(), A.clear();
609
- }
610
- /**
611
- * 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.
615
- */
616
- 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));
620
- }
621
- ze(e);
622
- }
623
- /**
624
- * Unmount a specific container (called when cell is recycled).
625
- */
626
- unmount(e) {
627
- for (const [t, r] of this.keyToContainer)
628
- if (r === e) {
629
- H(t), this.untrackPortal(t);
630
- return;
631
- }
158
+ if (h) {
159
+ const l = h;
160
+ queueMicrotask(() => {
161
+ for (const y of l) o.current.delete(y);
162
+ });
632
163
  }
633
- }
634
- const tt = {
164
+ return /* @__PURE__ */ w(V, { children: P });
165
+ }), Me = {
635
166
  undoRedo: ["editing"],
636
167
  clipboard: ["selection"]
637
168
  };
638
- function rt(n) {
639
- const e = new Set(n);
640
- for (const t of n) {
641
- const r = tt[t];
642
- if (r)
643
- for (const o of r)
644
- e.has(o) || console.warn(
645
- `[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.`
646
177
  );
647
178
  }
648
179
  }
649
- function nt(n) {
650
- const e = [];
651
- for (const [t, r] of Object.entries(n))
652
- r === void 0 || r === !1 || e.push(t);
653
- return rt(e), Ae(n);
654
- }
655
- let me = !1, J = null;
656
- function re() {
657
- return me || (J = new et(), be.registerAdapter(J), me = !0), J;
658
- }
659
- re();
660
- function ot(n) {
661
- const t = n.getPluginByName?.("masterDetail");
662
- t && typeof t.refreshDetailRenderer == "function" && t.refreshDetailRenderer();
663
- }
664
- function it(n, e) {
665
- 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);
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);
671
228
  }
672
229
  }
673
- function st(n) {
674
- const e = {};
675
- return Se.forEach(n, (t) => {
676
- if (De(t)) {
677
- if (t.type && t.type.displayName === "GridDetailPanel") {
678
- const r = t.props;
679
- e.masterDetail = {
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 = {
680
237
  // Use props from the child component for configuration
681
- showExpandColumn: r.showExpandColumn ?? !0,
682
- animation: r.animation ?? "slide"
238
+ showExpandColumn: o.showExpandColumn ?? !0,
239
+ animation: o.animation ?? "slide"
683
240
  // detailRenderer will be wired up by refreshMasterDetailRenderer after mount
684
241
  };
685
242
  }
686
- t.type && t.type.displayName === "GridResponsiveCard" && (e.responsive = !0);
243
+ i.type && i.type.displayName === "GridResponsiveCard" && (t.responsive = !0);
687
244
  }
688
- }), e;
245
+ }), t;
689
246
  }
690
- const Rt = he(function(e, t) {
247
+ const rr = se(function(t, i) {
691
248
  const {
692
249
  // Core props
693
- rows: r,
694
- gridConfig: o,
695
- columns: a,
696
- columnDefaults: c,
697
- fitMode: s,
698
- sortable: g,
699
- filterable: d,
700
- selectable: p,
701
- loading: v,
702
- customStyles: C,
703
- className: K,
704
- style: x,
705
- children: T,
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,
706
263
  // Plugin props
707
- plugins: u,
708
- // SSR mode
709
- ssr: h,
264
+ plugins: s,
265
+ // SSR mode (deprecated - see SSRProps)
266
+ ssr: m,
710
267
  // Legacy event handlers
711
- onRowsChange: R,
268
+ onRowsChange: C,
712
269
  // 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 = [
715
- "selection",
716
- "editing",
717
- "filtering",
718
- "multiSort",
719
- "clipboard",
720
- "contextMenu",
721
- "reorderColumns",
722
- "reorderRows",
723
- "rowDragDrop",
724
- "visibility",
725
- "undoRedo",
726
- "tree",
727
- "groupingRows",
728
- "groupingColumns",
729
- "pinnedColumns",
730
- "pinnedRows",
731
- "masterDetail",
732
- "responsive",
733
- "columnVirtualization",
734
- "export",
735
- "print",
736
- "pivot",
737
- "serverSide",
738
- "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(() => {
748
- if (u) {
749
- const i = new Set(u.map((y) => y.name)), l = _.filter((y) => !i.has(y.name));
750
- return [...u, ...l];
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];
751
283
  }
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
759
- // 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 };
284
+ return z;
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 };
766
290
  }
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));
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));
769
293
  return {
770
- ...i,
771
- ...l,
772
- plugins: [...y, ...B]
294
+ ...e,
295
+ ...n,
296
+ plugins: [...f, ...$]
773
297
  };
774
298
  }
775
- return N.length > 0 && !i ? { ...l, plugins: N } : Object.keys(l).length > 0 ? { ...i, ...l } : i;
776
- }, [o, N, g, d, p, q]);
777
- P(() => {
778
- re().setTypeDefaults(ie);
779
- }, [ie]), P(() => {
780
- f.current && (f.current.rows = r);
781
- }, [r]), P(() => {
782
- f.current && I && (f.current.gridConfig = I);
783
- }, [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);
794
- let y = !1;
795
- const L = requestAnimationFrame(() => {
796
- y || (typeof i.refreshColumns == "function" && i.refreshColumns(), typeof i.refreshShellHeader == "function" && i.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());
797
321
  });
798
322
  return () => {
799
- y = !0, cancelAnimationFrame(L);
323
+ f = !0, cancelAnimationFrame(I);
800
324
  };
801
- }, []), P(() => {
802
- if (!f.current || !C) return;
803
- const i = f.current, l = "react-custom-styles";
804
- let y = !0;
805
- return i.ready?.().then(() => {
806
- y && C && (i.registerStyles?.(l, C), j.current = l);
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);
807
331
  }), () => {
808
- y = !1, j.current && (i.unregisterStyles?.(j.current), j.current = null);
332
+ f = !1, M.current && (e.unregisterStyles?.(M.current), M.current = null);
809
333
  };
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());
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());
816
340
  };
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];
821
- 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);
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);
829
353
  })
830
354
  );
831
355
  return () => {
832
- l.forEach((y) => y());
356
+ n.forEach((f) => f());
833
357
  };
834
- }, [de]), Re(
835
- t,
358
+ }, [Z]), ce(
359
+ i,
836
360
  () => ({
837
361
  get element() {
838
- return f.current;
362
+ return c.current;
839
363
  },
840
364
  async getConfig() {
841
- return f.current?.getConfig?.() ?? {};
365
+ return c.current?.getConfig?.() ?? {};
842
366
  },
843
367
  async ready() {
844
- return f.current?.ready?.();
368
+ return c.current?.ready?.();
845
369
  },
846
370
  async forceLayout() {
847
- return f.current?.forceLayout?.();
371
+ return c.current?.forceLayout?.();
848
372
  },
849
- async toggleGroup(i) {
850
- return f.current?.toggleGroup?.(i);
373
+ async toggleGroup(e) {
374
+ return c.current?.toggleGroup?.(e);
851
375
  },
852
- registerStyles(i, l) {
853
- f.current?.registerStyles?.(i, l);
376
+ registerStyles(e, n) {
377
+ c.current?.registerStyles?.(e, n);
854
378
  },
855
- unregisterStyles(i) {
856
- f.current?.unregisterStyles?.(i);
379
+ unregisterStyles(e) {
380
+ c.current?.unregisterStyles?.(e);
857
381
  },
858
- setRowLoading(i, l) {
859
- f.current?.setRowLoading?.(i, l);
382
+ setRowLoading(e, n) {
383
+ c.current?.setRowLoading?.(e, n);
860
384
  },
861
- setCellLoading(i, l, y) {
862
- f.current?.setCellLoading?.(i, l, y);
385
+ setCellLoading(e, n, f) {
386
+ c.current?.setCellLoading?.(e, n, f);
863
387
  },
864
- isRowLoading(i) {
865
- return f.current?.isRowLoading?.(i) ?? !1;
388
+ isRowLoading(e) {
389
+ return c.current?.isRowLoading?.(e) ?? !1;
866
390
  },
867
- isCellLoading(i, l) {
868
- return f.current?.isCellLoading?.(i, l) ?? !1;
391
+ isCellLoading(e, n) {
392
+ return c.current?.isCellLoading?.(e, n) ?? !1;
869
393
  },
870
394
  clearAllLoading() {
871
- f.current?.clearAllLoading?.();
395
+ c.current?.clearAllLoading?.();
872
396
  }
873
397
  }),
874
398
  []
875
399
  );
876
- const $ = k(null);
877
- return ke(() => {
878
- const i = f.current;
879
- return i && $.current && ge(i, $.current), () => {
880
- i && ge(i, 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);
881
405
  };
882
- }, []), /* @__PURE__ */ Pe(ne, { children: [
883
- /* @__PURE__ */ b(je, { ref: $ }),
884
- /* @__PURE__ */ b(
406
+ }, []), /* @__PURE__ */ le(V, { children: [
407
+ /* @__PURE__ */ w(Te, { ref: j }),
408
+ /* @__PURE__ */ w(
885
409
  "tbw-grid",
886
410
  {
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);
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);
891
416
  }
892
417
  },
893
- class: K,
894
- style: x,
895
- children: /* @__PURE__ */ b(Te.Provider, { value: f, children: T })
418
+ class: y,
419
+ style: G,
420
+ children: /* @__PURE__ */ w(ae.Provider, { value: c, children: D })
896
421
  }
897
422
  )
898
423
  ] });
899
424
  });
900
- function vt(n) {
425
+ function tr(r) {
901
426
  const {
902
- field: e,
903
- header: t,
904
- type: r,
905
- editable: o,
906
- sortable: a,
907
- resizable: c,
908
- width: s,
909
- 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(
918
- (f) => {
919
- u.current = f, f && (v && Ye(f, v), C && Ze(f, C));
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));
920
445
  },
921
- [v, C, e]
922
- ), R = typeof s == "number" ? `${s}px` : s, m = {
923
- field: e,
924
- ref: h
446
+ [h, l, t]
447
+ ), C = typeof u == "number" ? `${u}px` : u, a = {
448
+ field: t,
449
+ ref: m
925
450
  };
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 });
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 });
927
452
  }
928
- function Ct({ children: n }) {
929
- return /* @__PURE__ */ b("tbw-grid-tool-buttons", { children: n });
453
+ function nr({ children: r }) {
454
+ return /* @__PURE__ */ w("tbw-grid-tool-buttons", { children: r });
930
455
  }
931
- const wt = ({ icons: n, defaults: e, children: t }) => {
932
- 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 });
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 });
934
459
  };
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]);
937
- P(() => {
938
- 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;
939
464
  return (async () => {
940
465
  try {
941
- if (n) {
942
- const R = document.querySelector(n);
943
- if (!R) return;
944
- if (c.current = R, await R.ready?.(), u) {
945
- r(!0);
946
- const m = await R.getConfig?.();
947
- u && m && a(m);
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);
948
473
  }
949
474
  } else {
950
- const R = e.current;
951
- if (!R) return;
952
- if (await R.ready?.(), u) {
953
- r(!0);
954
- const m = await R.getConfig?.();
955
- u && m && a(m);
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);
956
481
  }
957
482
  }
958
483
  } catch {
959
484
  }
960
485
  })(), () => {
961
- u = !1;
486
+ s = !1;
962
487
  };
963
- }, [n]);
964
- const g = E(async () => {
965
- const u = s();
966
- if (u)
967
- return await u.getConfig?.() ?? null;
968
- const h = e.current;
969
- return h ? await h.getConfig?.() ?? null : null;
970
- }, [s]), d = E(async () => {
971
- const u = s();
972
- if (u) {
973
- 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?.();
974
499
  return;
975
500
  }
976
- const h = e.current;
977
- h && await h.forceLayout?.();
978
- }, [s]), p = E(
979
- async (u) => {
980
- const h = s();
981
- if (h) {
982
- 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);
983
508
  return;
984
509
  }
985
- const R = e.current;
986
- R && await R.toggleGroup?.(u);
510
+ const C = t.current;
511
+ C && await C.toggleGroup?.(s);
987
512
  },
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(
996
- (u, h) => {
997
- const R = s();
998
- if (R) {
999
- R.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);
1000
525
  return;
1001
526
  }
1002
- e.current?.registerStyles?.(u, h);
527
+ t.current?.registerStyles?.(s, m);
1003
528
  },
1004
- [s]
1005
- ), x = E(
1006
- (u) => {
1007
- const h = s();
1008
- if (h) {
1009
- h.unregisterStyles?.(u);
529
+ [u]
530
+ ), G = x(
531
+ (s) => {
532
+ const m = u();
533
+ if (m) {
534
+ m.unregisterStyles?.(s);
1010
535
  return;
1011
536
  }
1012
- e.current?.unregisterStyles?.(u);
537
+ t.current?.unregisterStyles?.(s);
1013
538
  },
1014
- [s]
1015
- ), T = E(() => o?.columns ? o.columns.filter((u) => !u.hidden) : [], [o]);
539
+ [u]
540
+ ), D = x(() => d?.columns ? d.columns.filter((s) => !s.hidden) : [], [d]);
1016
541
  return {
1017
- ref: e,
1018
- element: s(),
1019
- isReady: t,
1020
- config: o,
1021
- getConfig: g,
1022
- forceLayout: d,
1023
- toggleGroup: p,
1024
- getPlugin: v,
1025
- getPluginByName: C,
1026
- registerStyles: K,
1027
- unregisterStyles: x,
1028
- getVisibleColumns: T
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
1029
554
  };
1030
555
  }
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);
566
+ };
567
+ }, [i, o, d, r]);
568
+ }
1031
569
  export {
1032
- 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
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
1046
589
  };