@toolbox-web/grid-react 0.9.0 → 0.11.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.
@@ -0,0 +1,799 @@
1
+ import { jsx as b } from "react/jsx-runtime";
2
+ import { DataGridElement as pe } from "@toolbox-web/grid";
3
+ import { createContext as Y, useContext as I, useRef as S, useCallback as Z, useEffect as p, forwardRef as me, useMemo as w, useImperativeHandle as ye, Children as he, isValidElement as ve } from "react";
4
+ import { flushSync as y } from "react-dom";
5
+ import { createRoot as v } from "react-dom/client";
6
+ import { c as we } from "./feature-registry-Y3KvnN54.js";
7
+ function Ce(n) {
8
+ return n.charAt(0).toUpperCase() + n.slice(1);
9
+ }
10
+ function ce(n) {
11
+ return n.toLowerCase() === "id" ? "ID" : n.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").split(" ").filter(Boolean).map(Ce).join(" ");
12
+ }
13
+ const Re = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime", "currency"]);
14
+ function be(n) {
15
+ const t = n.lastIndexOf(":");
16
+ if (t > 0) {
17
+ const e = n.slice(t + 1).toLowerCase();
18
+ if (Re.has(e)) {
19
+ const r = n.slice(0, t);
20
+ return {
21
+ field: r,
22
+ header: ce(r),
23
+ type: e
24
+ };
25
+ }
26
+ }
27
+ return {
28
+ field: n,
29
+ header: ce(n)
30
+ };
31
+ }
32
+ function Ee(n) {
33
+ return n.map((t) => typeof t == "string" ? be(t) : t);
34
+ }
35
+ const z = {
36
+ onCellClick: "cell-click",
37
+ onRowClick: "row-click",
38
+ onCellActivate: "cell-activate",
39
+ onCellChange: "cell-change",
40
+ onCellCommit: "cell-commit",
41
+ onRowCommit: "row-commit",
42
+ onSortChange: "sort-change",
43
+ onFilterChange: "filter-change",
44
+ onColumnResize: "column-resize",
45
+ onColumnMove: "column-move",
46
+ onColumnVisibility: "column-visibility",
47
+ onColumnStateChange: "column-state-change",
48
+ onSelectionChange: "selection-change",
49
+ onRowMove: "row-move",
50
+ onGroupToggle: "group-toggle",
51
+ onTreeExpand: "tree-expand",
52
+ onDetailExpand: "detail-expand",
53
+ onResponsiveChange: "responsive-change",
54
+ onCopy: "copy",
55
+ onPaste: "paste",
56
+ onUndoRedo: "undo-redo",
57
+ onExportComplete: "export-complete",
58
+ onPrintStart: "print-start",
59
+ onPrintComplete: "print-complete"
60
+ }, Q = Y(null), Ue = ({ icons: n, children: t }) => /* @__PURE__ */ b(Q.Provider, { value: n, children: t });
61
+ function Je() {
62
+ return I(Q);
63
+ }
64
+ const De = Q, $ = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new Map();
65
+ function de(n) {
66
+ const t = n.querySelector("tbw-grid-responsive-card");
67
+ if (t) {
68
+ const r = $.get(t);
69
+ if (r) return r;
70
+ }
71
+ const e = n.id || n.getAttribute("data-grid-id");
72
+ if (e)
73
+ return W.get(e);
74
+ }
75
+ function Pe(n) {
76
+ const { children: t, cardRowHeight: e = "auto" } = n, r = S(null), i = Z(
77
+ (s) => {
78
+ if (r.current = s, !s) return;
79
+ $.set(s, t);
80
+ const c = s.closest("tbw-grid");
81
+ if (c) {
82
+ const u = c.id || c.getAttribute("data-grid-id");
83
+ u && W.set(u, t);
84
+ }
85
+ },
86
+ [t]
87
+ );
88
+ p(() => () => {
89
+ const s = r.current;
90
+ if (s) {
91
+ $.delete(s);
92
+ const c = s.closest("tbw-grid");
93
+ if (c) {
94
+ const u = c.id || c.getAttribute("data-grid-id");
95
+ u && W.delete(u);
96
+ }
97
+ }
98
+ }, []);
99
+ const d = e === "auto" ? "auto" : String(e);
100
+ return /* @__PURE__ */ b("tbw-grid-responsive-card", { ref: i, cardRowHeight: d });
101
+ }
102
+ Pe.displayName = "GridResponsiveCard";
103
+ const T = Y(null), Ye = ({ defaults: n, children: t }) => /* @__PURE__ */ b(T.Provider, { value: n, children: t });
104
+ function Ze() {
105
+ return I(T);
106
+ }
107
+ function Qe(n) {
108
+ return I(T)?.[n];
109
+ }
110
+ const Se = T;
111
+ function xe(n) {
112
+ const t = /* @__PURE__ */ new WeakMap();
113
+ return (e) => {
114
+ const r = e.cellEl;
115
+ if (r) {
116
+ const s = t.get(r);
117
+ if (s)
118
+ return y(() => {
119
+ s.root.render(n(e));
120
+ }), s.container;
121
+ }
122
+ const i = document.createElement("div");
123
+ i.className = "react-cell-renderer", i.style.display = "contents";
124
+ const d = v(i);
125
+ return y(() => {
126
+ d.render(n(e));
127
+ }), r && t.set(r, { root: d, container: i }), i;
128
+ };
129
+ }
130
+ function Ae(n) {
131
+ return (t) => {
132
+ const e = document.createElement("div");
133
+ e.className = "react-cell-editor", e.style.display = "contents";
134
+ const r = v(e);
135
+ return y(() => {
136
+ r.render(n(t));
137
+ }), e;
138
+ };
139
+ }
140
+ function Ge(n) {
141
+ if (!n) return;
142
+ if (!n.columns) return n;
143
+ const t = n.columns.map((e) => {
144
+ const { renderer: r, editor: i, ...d } = e, s = { ...d };
145
+ return r && (s.renderer = xe(r)), i && (s.editor = Ae(i)), s;
146
+ });
147
+ return {
148
+ ...n,
149
+ columns: t
150
+ };
151
+ }
152
+ const q = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new Map();
153
+ function Ie(n) {
154
+ const t = n.querySelector("tbw-grid-detail");
155
+ if (t) {
156
+ const r = q.get(t);
157
+ if (r) return r;
158
+ }
159
+ const e = n.id || n.getAttribute("data-grid-id");
160
+ if (e)
161
+ return B.get(e);
162
+ }
163
+ function Ne(n) {
164
+ const { children: t, showExpandColumn: e = !0, animation: r = "slide" } = n, i = S(null), d = Z(
165
+ (c) => {
166
+ if (i.current = c, !c) return;
167
+ q.set(c, t);
168
+ const u = c.closest("tbw-grid");
169
+ if (u) {
170
+ const g = u.id || u.getAttribute("data-grid-id");
171
+ g && B.set(g, t);
172
+ }
173
+ },
174
+ [t]
175
+ );
176
+ return p(() => () => {
177
+ const c = i.current;
178
+ if (c) {
179
+ q.delete(c);
180
+ const u = c.closest("tbw-grid");
181
+ if (u) {
182
+ const h = u.id || u.getAttribute("data-grid-id");
183
+ h && B.delete(h);
184
+ }
185
+ const g = c.parentNode;
186
+ g && g.contains(c);
187
+ }
188
+ }, []), /* @__PURE__ */ b(
189
+ "tbw-grid-detail",
190
+ {
191
+ ref: d,
192
+ showExpandColumn: e ? void 0 : "false",
193
+ animation: r === !1 ? "false" : r
194
+ }
195
+ );
196
+ }
197
+ Ne.displayName = "GridDetailPanel";
198
+ const K = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new Map();
199
+ function Ve(n) {
200
+ const t = K.get(n);
201
+ if (t) return t;
202
+ const e = n.id;
203
+ if (e)
204
+ return U.get(e);
205
+ }
206
+ function Xe(n) {
207
+ const { id: t, title: e, icon: r, tooltip: i, order: d = 100, children: s } = n, c = S(null), u = Z(
208
+ (g) => {
209
+ c.current = g, g && (K.set(g, s), t && U.set(t, s));
210
+ },
211
+ [s, t]
212
+ );
213
+ return p(() => () => {
214
+ const g = c.current;
215
+ g && (K.delete(g), t && U.delete(t));
216
+ }, [t]), /* @__PURE__ */ b(
217
+ "tbw-grid-tool-panel",
218
+ {
219
+ ref: u,
220
+ id: t,
221
+ title: e,
222
+ icon: r,
223
+ tooltip: i,
224
+ order: d?.toString()
225
+ }
226
+ );
227
+ }
228
+ const R = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new Map();
229
+ function et(n, t) {
230
+ const e = n.getAttribute("field"), r = R.get(n) ?? {};
231
+ if (r.renderer = t, R.set(n, r), e) {
232
+ const i = E.get(e) ?? {};
233
+ i.renderer = t, E.set(e, i);
234
+ }
235
+ }
236
+ function tt(n, t) {
237
+ const e = n.getAttribute("field"), r = R.get(n) ?? {};
238
+ if (r.editor = t, R.set(n, r), e) {
239
+ const i = E.get(e) ?? {};
240
+ i.editor = t, E.set(e, i);
241
+ }
242
+ }
243
+ function Le(n) {
244
+ let t = R.get(n)?.renderer;
245
+ if (!t) {
246
+ const e = n.getAttribute("field");
247
+ e && (t = E.get(e)?.renderer);
248
+ }
249
+ return t;
250
+ }
251
+ function Te(n) {
252
+ let t = R.get(n)?.editor;
253
+ if (!t) {
254
+ const e = n.getAttribute("field");
255
+ e && (t = E.get(e)?.editor);
256
+ }
257
+ return t;
258
+ }
259
+ class ue {
260
+ mountedViews = [];
261
+ typeDefaults = null;
262
+ /**
263
+ * Sets the type defaults map for this adapter.
264
+ * Called by DataGrid when it receives type defaults from context.
265
+ *
266
+ * @internal
267
+ */
268
+ setTypeDefaults(t) {
269
+ this.typeDefaults = t;
270
+ }
271
+ /**
272
+ * Determines if this adapter can handle the given element.
273
+ * Checks if a renderer or editor is registered for this element.
274
+ */
275
+ canHandle(t) {
276
+ const e = t.getAttribute("field");
277
+ let r = R.get(t);
278
+ if (!r && e) {
279
+ const s = E.get(e);
280
+ s && (s.renderer || s.editor) && (r = s, R.set(t, r));
281
+ }
282
+ const i = r?.renderer !== void 0, d = r?.editor !== void 0;
283
+ return r !== void 0 && (i || d);
284
+ }
285
+ /**
286
+ * Creates a view renderer function that renders a React component
287
+ * and returns its container DOM element.
288
+ *
289
+ * Uses a cell cache to reuse React roots for performance - instead of
290
+ * creating new roots on each render, we reuse existing ones and just
291
+ * call root.render() with new data.
292
+ *
293
+ * Returns undefined if no renderer is registered for this element,
294
+ * allowing the grid to use its default rendering.
295
+ */
296
+ createRenderer(t) {
297
+ const e = Le(t);
298
+ if (!e)
299
+ return;
300
+ const r = /* @__PURE__ */ new WeakMap();
301
+ return (i) => {
302
+ const d = i.cellEl;
303
+ if (d) {
304
+ const u = r.get(d);
305
+ if (u)
306
+ return y(() => {
307
+ u.root.render(e(i));
308
+ }), u.container;
309
+ const g = document.createElement("div");
310
+ g.className = "react-cell-renderer", g.style.display = "contents";
311
+ const h = v(g);
312
+ return y(() => {
313
+ h.render(e(i));
314
+ }), r.set(d, { root: h, container: g, lastRowIndex: i.rowIndex ?? -1 }), this.mountedViews.push({ root: h, container: g }), g;
315
+ }
316
+ const s = document.createElement("div");
317
+ s.className = "react-cell-renderer", s.style.display = "contents";
318
+ const c = v(s);
319
+ return y(() => {
320
+ c.render(e(i));
321
+ }), this.mountedViews.push({ root: c, container: s }), s;
322
+ };
323
+ }
324
+ /**
325
+ * Creates an editor spec that renders a React component
326
+ * with commit/cancel callbacks passed as props.
327
+ */
328
+ createEditor(t) {
329
+ const e = Te(t);
330
+ return e ? (r) => {
331
+ const i = document.createElement("div");
332
+ i.className = "react-cell-editor", i.style.display = "contents";
333
+ const d = v(i);
334
+ return y(() => {
335
+ d.render(e(r));
336
+ }), this.mountedViews.push({ root: d, container: i }), i;
337
+ } : () => document.createElement("div");
338
+ }
339
+ /**
340
+ * Creates a detail renderer function for MasterDetailPlugin.
341
+ * Renders React components for expandable detail rows.
342
+ */
343
+ createDetailRenderer(t) {
344
+ const e = Ie(t);
345
+ if (e)
346
+ return (r, i) => {
347
+ const d = document.createElement("div");
348
+ d.className = "react-detail-panel";
349
+ const s = { row: r, rowIndex: i }, c = v(d);
350
+ return y(() => {
351
+ c.render(e(s));
352
+ }), this.mountedViews.push({ root: c, container: d }), d;
353
+ };
354
+ }
355
+ /**
356
+ * Framework adapter hook called by MasterDetailPlugin during attach().
357
+ * Parses the <tbw-grid-detail> element and returns a React-based renderer.
358
+ */
359
+ parseDetailElement(t) {
360
+ const e = t.closest("tbw-grid");
361
+ if (e)
362
+ return this.createDetailRenderer(e);
363
+ }
364
+ /**
365
+ * Creates a responsive card renderer function for ResponsivePlugin.
366
+ * Renders React components for card layout in responsive mode.
367
+ */
368
+ createResponsiveCardRenderer(t) {
369
+ const e = de(t);
370
+ if (e)
371
+ return (r, i) => {
372
+ const d = document.createElement("div");
373
+ d.className = "react-responsive-card";
374
+ const s = { row: r, index: i }, c = v(d);
375
+ return y(() => {
376
+ c.render(e(s));
377
+ }), this.mountedViews.push({ root: c, container: d }), d;
378
+ };
379
+ }
380
+ /**
381
+ * Creates a tool panel renderer from a light DOM element.
382
+ * Renders React components into tool panel containers.
383
+ */
384
+ createToolPanelRenderer(t) {
385
+ const e = Ve(t);
386
+ if (!e)
387
+ return;
388
+ const r = t.closest("tbw-grid");
389
+ return (i) => {
390
+ const d = {
391
+ grid: r ?? i
392
+ }, s = v(i);
393
+ return y(() => {
394
+ s.render(e(d));
395
+ }), this.mountedViews.push({ root: s, container: i }), () => {
396
+ const c = this.mountedViews.findIndex((u) => u.container === i);
397
+ if (c !== -1) {
398
+ const { root: u } = this.mountedViews[c];
399
+ try {
400
+ u.unmount();
401
+ } catch {
402
+ }
403
+ this.mountedViews.splice(c, 1);
404
+ }
405
+ };
406
+ };
407
+ }
408
+ /**
409
+ * Gets type-level defaults from the type defaults map.
410
+ *
411
+ * This enables application-wide type defaults configured via GridTypeProvider.
412
+ * The returned TypeDefault contains renderer/editor functions that render
413
+ * React components into the grid's cells.
414
+ *
415
+ * @example
416
+ * ```tsx
417
+ * // App.tsx
418
+ * const typeDefaults = {
419
+ * country: {
420
+ * renderer: (ctx) => <CountryBadge code={ctx.value} />,
421
+ * editor: (ctx) => <CountrySelect value={ctx.value} onCommit={ctx.commit} />
422
+ * }
423
+ * };
424
+ *
425
+ * <GridTypeProvider defaults={typeDefaults}>
426
+ * <App />
427
+ * </GridTypeProvider>
428
+ *
429
+ * // Any grid with type: 'country' columns will use these components
430
+ * ```
431
+ */
432
+ getTypeDefault(t) {
433
+ if (!this.typeDefaults)
434
+ return;
435
+ const e = this.typeDefaults[t];
436
+ if (!e)
437
+ return;
438
+ const r = {
439
+ editorParams: e.editorParams
440
+ };
441
+ return e.renderer && (r.renderer = this.createTypeRenderer(e.renderer)), e.editor && (r.editor = this.createTypeEditor(e.editor)), r;
442
+ }
443
+ /**
444
+ * Creates a renderer function from a React render function for type defaults.
445
+ * @internal
446
+ */
447
+ createTypeRenderer(t) {
448
+ return (e) => {
449
+ const r = document.createElement("span");
450
+ r.style.display = "contents";
451
+ const i = v(r);
452
+ return this.mountedViews.push({ root: i, container: r }), y(() => {
453
+ i.render(t(e));
454
+ }), r;
455
+ };
456
+ }
457
+ /**
458
+ * Creates an editor function from a React render function for type defaults.
459
+ * @internal
460
+ */
461
+ createTypeEditor(t) {
462
+ return (e) => {
463
+ const r = document.createElement("span");
464
+ r.style.display = "contents";
465
+ const i = v(r);
466
+ return this.mountedViews.push({ root: i, container: r }), y(() => {
467
+ i.render(t(e));
468
+ }), r;
469
+ };
470
+ }
471
+ /**
472
+ * Clean up all mounted React roots.
473
+ * Call this when the grid is unmounted.
474
+ */
475
+ destroy() {
476
+ this.mountedViews.forEach(({ root: t }) => {
477
+ try {
478
+ t.unmount();
479
+ } catch {
480
+ }
481
+ }), this.mountedViews = [];
482
+ }
483
+ /**
484
+ * Unmount a specific container (called when cell is recycled).
485
+ */
486
+ unmount(t) {
487
+ const e = this.mountedViews.findIndex((r) => r.container === t);
488
+ if (e !== -1) {
489
+ const { root: r } = this.mountedViews[e];
490
+ try {
491
+ r.unmount();
492
+ } catch {
493
+ }
494
+ this.mountedViews.splice(e, 1);
495
+ }
496
+ }
497
+ }
498
+ const rt = ue, ke = {
499
+ undoRedo: ["editing"],
500
+ clipboard: ["selection"]
501
+ };
502
+ function Fe(n) {
503
+ const t = new Set(n);
504
+ for (const e of n) {
505
+ const r = ke[e];
506
+ if (r)
507
+ for (const i of r)
508
+ t.has(i) || console.warn(
509
+ `[DataGrid] Feature "${e}" requires "${i}" to be enabled. Add the "${i}" prop to your DataGrid.`
510
+ );
511
+ }
512
+ }
513
+ function Me(n) {
514
+ const t = [], e = [], r = { ...n };
515
+ r.multiSort !== void 0 ? delete r.sorting : r.sorting !== void 0 && (r.multiSort = r.sorting, delete r.sorting);
516
+ for (const [s, c] of Object.entries(r)) {
517
+ if (c === void 0 || c === !1) continue;
518
+ const u = s;
519
+ e.push(u);
520
+ }
521
+ Fe(e);
522
+ const i = [
523
+ "selection",
524
+ "editing",
525
+ // Then everything else in the order they were specified
526
+ ...e.filter((s) => s !== "selection" && s !== "editing")
527
+ ], d = [...new Set(i)].filter((s) => e.includes(s));
528
+ for (const s of d) {
529
+ const c = n[s];
530
+ if (c === void 0 || c === !1) continue;
531
+ const u = we(s, c);
532
+ u && t.push(u);
533
+ }
534
+ return t;
535
+ }
536
+ let ae = !1, _ = null;
537
+ function J() {
538
+ return ae || (_ = new ue(), pe.registerAdapter(_), ae = !0), _;
539
+ }
540
+ J();
541
+ const Oe = Y(null);
542
+ function je(n) {
543
+ const e = n.getPluginByName?.("masterDetail");
544
+ e && typeof e.refreshDetailRenderer == "function" && e.refreshDetailRenderer();
545
+ }
546
+ function He(n, t) {
547
+ const e = n;
548
+ if (!n.querySelector("tbw-grid-responsive-card") || !de(n)) return;
549
+ const d = e.getPluginByName?.("responsive");
550
+ if (d && typeof d.setCardRenderer == "function") {
551
+ const s = t.createResponsiveCardRenderer(n);
552
+ s && d.setCardRenderer(s);
553
+ }
554
+ }
555
+ function ze(n) {
556
+ const t = {};
557
+ return he.forEach(n, (e) => {
558
+ if (ve(e)) {
559
+ if (e.type && e.type.displayName === "GridDetailPanel") {
560
+ const r = e.props;
561
+ t.masterDetail = {
562
+ // Use props from the child component for configuration
563
+ showExpandColumn: r.showExpandColumn ?? !0,
564
+ animation: r.animation ?? "slide"
565
+ // detailRenderer will be wired up by refreshMasterDetailRenderer after mount
566
+ };
567
+ }
568
+ e.type && e.type.displayName === "GridResponsiveCard" && (t.responsive = !0);
569
+ }
570
+ }), t;
571
+ }
572
+ const nt = me(function(t, e) {
573
+ const {
574
+ // Core props
575
+ rows: r,
576
+ gridConfig: i,
577
+ columns: d,
578
+ columnDefaults: s,
579
+ fitMode: c,
580
+ sortable: u,
581
+ filterable: g,
582
+ selectable: h,
583
+ loading: k,
584
+ editOn: F,
585
+ customStyles: N,
586
+ className: le,
587
+ style: fe,
588
+ children: M,
589
+ // Plugin props
590
+ plugins: D,
591
+ // SSR mode
592
+ ssr: X,
593
+ // Legacy event handlers
594
+ onRowsChange: O,
595
+ // Feature props and event props are in ...rest
596
+ ...C
597
+ } = t, l = S(null), V = S(null), ee = I(Se), j = I(De), te = [
598
+ "selection",
599
+ "editing",
600
+ "filtering",
601
+ "multiSort",
602
+ "sorting",
603
+ // deprecated alias for multiSort
604
+ "clipboard",
605
+ "contextMenu",
606
+ "reorder",
607
+ "rowReorder",
608
+ "visibility",
609
+ "undoRedo",
610
+ "tree",
611
+ "groupingRows",
612
+ "groupingColumns",
613
+ "pinnedColumns",
614
+ "pinnedRows",
615
+ "masterDetail",
616
+ "responsive",
617
+ "columnVirtualization",
618
+ "export",
619
+ "print",
620
+ "pivot",
621
+ "serverSide"
622
+ ], ge = w(() => te.map((o) => {
623
+ const a = C[o];
624
+ return a !== void 0 ? `${o}:${JSON.stringify(a)}` : "";
625
+ }).filter(Boolean).join("|"), [C]), re = w(() => {
626
+ const o = {};
627
+ for (const a of te)
628
+ a in C && C[a] !== void 0 && (o[a] = C[a]);
629
+ return o;
630
+ }, [ge]), ne = w(() => ze(M), [M]), oe = w(() => ({ ...ne, ...re }), [re, ne]), H = w(() => D || X ? [] : Me(oe), [oe, D, X]), x = w(() => {
631
+ if (D) {
632
+ const o = new Set(D.map((f) => f.name)), a = H.filter((f) => !o.has(f.name));
633
+ return [...D, ...a];
634
+ }
635
+ return H;
636
+ }, [D, H]), A = w(() => {
637
+ if (!d) return d;
638
+ const o = Ee(d);
639
+ return s ? o.map((a) => ({
640
+ ...s,
641
+ ...a
642
+ // Individual column props override defaults
643
+ })) : o;
644
+ }, [d, s]), G = w(() => {
645
+ const o = Ge(i), a = {};
646
+ if (u !== void 0 && (a.sortable = u), g !== void 0 && (a.filterable = g), h !== void 0 && (a.selectable = h), j) {
647
+ const f = o?.icons || i?.icons || {};
648
+ a.icons = { ...j, ...f };
649
+ }
650
+ if (x.length > 0 && o) {
651
+ const f = o.plugins || [], m = new Set(f.map((P) => P.name)), L = x.filter((P) => !m.has(P.name));
652
+ return {
653
+ ...o,
654
+ ...a,
655
+ plugins: [...f, ...L]
656
+ };
657
+ }
658
+ return x.length > 0 && !o ? { ...a, plugins: x } : Object.keys(a).length > 0 ? { ...o, ...a } : o;
659
+ }, [i, x, u, g, h, j]);
660
+ p(() => {
661
+ J().setTypeDefaults(ee);
662
+ }, [ee]), p(() => {
663
+ l.current && (l.current.rows = r);
664
+ }, [r]), p(() => {
665
+ l.current && G && (l.current.gridConfig = G);
666
+ }, [G]), p(() => {
667
+ l.current && A && (l.current.columns = A);
668
+ }, [A]), p(() => {
669
+ l.current && c !== void 0 && (l.current.fitMode = c);
670
+ }, [c]), p(() => {
671
+ l.current && F !== void 0 && (l.current.editOn = F);
672
+ }, [F]), p(() => {
673
+ l.current && k !== void 0 && (l.current.loading = k);
674
+ }, [k]), p(() => {
675
+ const o = l.current;
676
+ if (!o) return;
677
+ const a = J();
678
+ o.__frameworkAdapter = a, je(o), He(o, a);
679
+ let f = !1;
680
+ const m = requestAnimationFrame(() => {
681
+ f || (typeof o.refreshColumns == "function" && o.refreshColumns(), typeof o.refreshShellHeader == "function" && o.refreshShellHeader());
682
+ });
683
+ return () => {
684
+ f = !0, cancelAnimationFrame(m);
685
+ };
686
+ }, []), p(() => {
687
+ if (!l.current || !N) return;
688
+ const o = l.current, a = "react-custom-styles";
689
+ let f = !0;
690
+ return o.ready?.().then(() => {
691
+ f && N && (o.registerStyles?.(a, N), V.current = a);
692
+ }), () => {
693
+ f = !1, V.current && (o.unregisterStyles?.(V.current), V.current = null);
694
+ };
695
+ }, [N]), p(() => {
696
+ const o = l.current;
697
+ if (!o) return;
698
+ const a = [];
699
+ if (O) {
700
+ const f = ((m) => O(m.detail.rows));
701
+ o.addEventListener("rows-change", f), a.push(["rows-change", f]);
702
+ }
703
+ return () => {
704
+ a.forEach(([f, m]) => {
705
+ o.removeEventListener(f, m);
706
+ });
707
+ };
708
+ }, [O]);
709
+ const ie = w(() => Object.keys(z).filter((o) => typeof C[o] == "function").sort().join("|"), [C]), se = S({});
710
+ for (const o of Object.keys(z))
711
+ se.current[o] = C[o];
712
+ return p(() => {
713
+ const o = l.current;
714
+ if (!o) return;
715
+ const a = [];
716
+ for (const [f, m] of Object.entries(z))
717
+ if (ie.includes(f)) {
718
+ const L = ((P) => {
719
+ se.current[f]?.(P.detail, P);
720
+ });
721
+ o.addEventListener(m, L), a.push([m, L]);
722
+ }
723
+ return () => {
724
+ a.forEach(([f, m]) => {
725
+ o.removeEventListener(f, m);
726
+ });
727
+ };
728
+ }, [ie]), ye(
729
+ e,
730
+ () => ({
731
+ get element() {
732
+ return l.current;
733
+ },
734
+ async getConfig() {
735
+ return l.current?.getConfig?.() ?? {};
736
+ },
737
+ async ready() {
738
+ return l.current?.ready?.();
739
+ },
740
+ async forceLayout() {
741
+ return l.current?.forceLayout?.();
742
+ },
743
+ async toggleGroup(o) {
744
+ return l.current?.toggleGroup?.(o);
745
+ },
746
+ registerStyles(o, a) {
747
+ l.current?.registerStyles?.(o, a);
748
+ },
749
+ unregisterStyles(o) {
750
+ l.current?.unregisterStyles?.(o);
751
+ },
752
+ setRowLoading(o, a) {
753
+ l.current?.setRowLoading?.(o, a);
754
+ },
755
+ setCellLoading(o, a, f) {
756
+ l.current?.setCellLoading?.(o, a, f);
757
+ },
758
+ isRowLoading(o) {
759
+ return l.current?.isRowLoading?.(o) ?? !1;
760
+ },
761
+ isCellLoading(o, a) {
762
+ return l.current?.isCellLoading?.(o, a) ?? !1;
763
+ },
764
+ clearAllLoading() {
765
+ l.current?.clearAllLoading?.();
766
+ }
767
+ }),
768
+ []
769
+ ), /* @__PURE__ */ b(
770
+ "tbw-grid",
771
+ {
772
+ ref: (o) => {
773
+ if (l.current = o, o) {
774
+ const a = o;
775
+ G && (a.gridConfig = G), r && (a.rows = r), A && (a.columns = A);
776
+ }
777
+ },
778
+ class: le,
779
+ style: fe,
780
+ children: /* @__PURE__ */ b(Oe.Provider, { value: l, children: M })
781
+ }
782
+ );
783
+ });
784
+ export {
785
+ nt as D,
786
+ Oe as G,
787
+ rt as R,
788
+ tt as a,
789
+ Ye as b,
790
+ Ue as c,
791
+ Ne as d,
792
+ Pe as e,
793
+ Xe as f,
794
+ Qe as g,
795
+ Je as h,
796
+ ue as i,
797
+ et as r,
798
+ Ze as u
799
+ };