@toolbox-web/grid-react 0.18.4 → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,22 +1,22 @@
1
- import { jsx as E, Fragment as Re } from "react/jsx-runtime";
2
- import { DataGridElement as ve } from "@toolbox-web/grid";
3
- import { createContext as pe, useContext as z, useRef as P, useCallback as h, useEffect as w, forwardRef as Ce, useMemo as G, useImperativeHandle as be, Children as Ee, isValidElement as Se, useState as de } from "react";
1
+ import { jsx as b, Fragment as ye } from "react/jsx-runtime";
2
+ import { DataGridElement as he } from "@toolbox-web/grid";
3
+ import { createContext as fe, useContext as O, useRef as x, useCallback as P, useEffect as C, forwardRef as Re, useMemo as G, useImperativeHandle as we, Children as Ce, isValidElement as ve, useState as de } from "react";
4
4
  import { flushSync as R } from "react-dom";
5
- import { createRoot as C } from "react-dom/client";
6
- import { createPluginsFromFeatures as Pe } from "@toolbox-web/grid/features/registry";
7
- import { G as xe } from "./chunks/grid-element-context-BU3WvNtM.js";
8
- function De(n) {
5
+ import { createRoot as v } from "react-dom/client";
6
+ import { createPluginsFromFeatures as be } from "@toolbox-web/grid/features/registry";
7
+ import { G as Ee } from "./chunks/grid-element-context-BU3WvNtM.js";
8
+ function Pe(n) {
9
9
  return n.charAt(0).toUpperCase() + n.slice(1);
10
10
  }
11
11
  function ue(n) {
12
- return n.toLowerCase() === "id" ? "ID" : n.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").split(" ").filter(Boolean).map(De).join(" ");
12
+ return n.toLowerCase() === "id" ? "ID" : n.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").split(" ").filter(Boolean).map(Pe).join(" ");
13
13
  }
14
- const Ge = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime", "currency"]);
15
- function Ae(n) {
14
+ const Se = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime", "currency"]);
15
+ function De(n) {
16
16
  const t = n.lastIndexOf(":");
17
17
  if (t > 0) {
18
18
  const e = n.slice(t + 1).toLowerCase();
19
- if (Ge.has(e)) {
19
+ if (Se.has(e)) {
20
20
  const r = n.slice(0, t);
21
21
  return {
22
22
  field: r,
@@ -30,10 +30,10 @@ function Ae(n) {
30
30
  header: ue(n)
31
31
  };
32
32
  }
33
- function Ie(n) {
34
- return n.map((t) => typeof t == "string" ? Ae(t) : t);
33
+ function Ge(n) {
34
+ return n.map((t) => typeof t == "string" ? De(t) : t);
35
35
  }
36
- const U = {
36
+ const W = {
37
37
  onCellClick: "cell-click",
38
38
  onRowClick: "row-click",
39
39
  onCellActivate: "cell-activate",
@@ -59,191 +59,191 @@ const U = {
59
59
  onExportComplete: "export-complete",
60
60
  onPrintStart: "print-start",
61
61
  onPrintComplete: "print-complete"
62
- }, oe = pe(null), Ve = ({ icons: n, children: t }) => /* @__PURE__ */ E(oe.Provider, { value: n, children: t });
63
- function at() {
64
- return z(oe);
62
+ }, te = fe(null), xe = ({ icons: n, children: t }) => /* @__PURE__ */ b(te.Provider, { value: n, children: t });
63
+ function st() {
64
+ return O(te);
65
65
  }
66
- const Ne = oe, Z = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new Map();
67
- function me(n) {
66
+ const Ae = te, U = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new Map();
67
+ function ge(n) {
68
68
  const t = n.querySelector("tbw-grid-responsive-card");
69
69
  if (t) {
70
- const r = Z.get(t);
70
+ const r = U.get(t);
71
71
  if (r) return r;
72
72
  }
73
73
  const e = n.id || n.getAttribute("data-grid-id");
74
74
  if (e)
75
- return Q.get(e);
76
- }
77
- function Le(n) {
78
- const { children: t, cardRowHeight: e = "auto" } = n, r = P(null), o = h(
79
- (l) => {
80
- if (r.current = l, !l) return;
81
- Z.set(l, t);
82
- const i = l.closest("tbw-grid");
83
- if (i) {
84
- const f = i.id || i.getAttribute("data-grid-id");
85
- f && Q.set(f, t);
75
+ return J.get(e);
76
+ }
77
+ function Ve(n) {
78
+ const { children: t, cardRowHeight: e = "auto" } = n, r = x(null), o = P(
79
+ (c) => {
80
+ if (r.current = c, !c) return;
81
+ U.set(c, t);
82
+ const s = c.closest("tbw-grid");
83
+ if (s) {
84
+ const u = s.id || s.getAttribute("data-grid-id");
85
+ u && J.set(u, t);
86
86
  }
87
87
  },
88
88
  [t]
89
89
  );
90
- w(() => () => {
91
- const l = r.current;
92
- if (l) {
93
- Z.delete(l);
94
- const i = l.closest("tbw-grid");
95
- if (i) {
96
- const f = i.id || i.getAttribute("data-grid-id");
97
- f && Q.delete(f);
90
+ C(() => () => {
91
+ const c = r.current;
92
+ if (c) {
93
+ U.delete(c);
94
+ const s = c.closest("tbw-grid");
95
+ if (s) {
96
+ const u = s.id || s.getAttribute("data-grid-id");
97
+ u && J.delete(u);
98
98
  }
99
99
  }
100
100
  }, []);
101
101
  const a = e === "auto" ? "auto" : String(e);
102
- return /* @__PURE__ */ E("tbw-grid-responsive-card", { ref: o, cardRowHeight: a });
102
+ return /* @__PURE__ */ b("tbw-grid-responsive-card", { ref: o, cardRowHeight: a });
103
103
  }
104
- Le.displayName = "GridResponsiveCard";
105
- const $ = pe(null), Te = ({ defaults: n, children: t }) => /* @__PURE__ */ E($.Provider, { value: n, children: t });
106
- function lt() {
107
- return z($);
104
+ Ve.displayName = "GridResponsiveCard";
105
+ const z = fe(null), Ie = ({ defaults: n, children: t }) => /* @__PURE__ */ b(z.Provider, { value: n, children: t });
106
+ function ct() {
107
+ return O(z);
108
108
  }
109
- function dt(n) {
110
- return z($)?.[n];
109
+ function at(n) {
110
+ return O(z)?.[n];
111
111
  }
112
- const ke = $, K = /* @__PURE__ */ Symbol("reactProcessed"), I = [];
113
- function Fe(n) {
114
- for (let t = I.length - 1; t >= 0; t--) {
115
- const e = I[t];
112
+ const Ne = z, B = /* @__PURE__ */ Symbol("reactProcessed"), A = [];
113
+ function Le(n) {
114
+ for (let t = A.length - 1; t >= 0; t--) {
115
+ const e = A[t];
116
116
  if (n.contains(e.container) && e.container.classList.contains("react-cell-editor")) {
117
117
  try {
118
118
  e.root.unmount();
119
119
  } catch {
120
120
  }
121
- I.splice(t, 1);
121
+ A.splice(t, 1);
122
122
  }
123
123
  }
124
124
  }
125
- function Me(n) {
125
+ function ke(n) {
126
126
  const t = /* @__PURE__ */ new WeakMap();
127
127
  return (e) => {
128
128
  const r = e.cellEl;
129
129
  if (r) {
130
- const l = t.get(r);
131
- if (l)
130
+ const c = t.get(r);
131
+ if (c)
132
132
  return R(() => {
133
- l.root.render(n(e));
134
- }), l.container;
133
+ c.root.render(n(e));
134
+ }), c.container;
135
135
  }
136
136
  const o = document.createElement("div");
137
137
  o.className = "react-cell-renderer", o.style.display = "contents";
138
- const a = C(o);
138
+ const a = v(o);
139
139
  return R(() => {
140
140
  a.render(n(e));
141
- }), r && t.set(r, { root: a, container: o }), I.push({ root: a, container: o }), o;
141
+ }), r && t.set(r, { root: a, container: o }), A.push({ root: a, container: o }), o;
142
142
  };
143
143
  }
144
- function He(n) {
144
+ function Te(n) {
145
145
  return (t) => {
146
146
  const e = document.createElement("div");
147
147
  e.className = "react-cell-editor", e.style.display = "contents";
148
- const r = C(e);
148
+ const r = v(e);
149
149
  return R(() => {
150
150
  r.render(n(t));
151
- }), I.push({ root: r, container: e }), e;
151
+ }), A.push({ root: r, container: e }), e;
152
152
  };
153
153
  }
154
- function Oe(n) {
154
+ function Fe(n) {
155
155
  return (t) => {
156
156
  const e = document.createElement("div");
157
157
  e.className = "react-header-renderer", e.style.display = "contents";
158
- const r = C(e);
158
+ const r = v(e);
159
159
  return R(() => {
160
160
  r.render(n(t));
161
- }), I.push({ root: r, container: e }), e;
161
+ }), A.push({ root: r, container: e }), e;
162
162
  };
163
163
  }
164
- function qe(n) {
164
+ function Me(n) {
165
165
  return (t) => {
166
166
  const e = document.createElement("div");
167
167
  e.className = "react-header-label-renderer", e.style.display = "contents";
168
- const r = C(e);
168
+ const r = v(e);
169
169
  return R(() => {
170
170
  r.render(n(t));
171
- }), I.push({ root: r, container: e }), e;
171
+ }), A.push({ root: r, container: e }), e;
172
172
  };
173
173
  }
174
- function Be(n) {
174
+ function He(n) {
175
175
  return (t) => {
176
176
  const e = n(t);
177
177
  if (e instanceof HTMLElement || typeof e == "string")
178
178
  return e;
179
179
  const r = document.createElement("div");
180
180
  r.className = "react-loading-renderer", r.style.display = "contents";
181
- const o = C(r);
181
+ const o = v(r);
182
182
  return R(() => {
183
183
  o.render(e);
184
- }), I.push({ root: o, container: r }), r;
184
+ }), A.push({ root: o, container: r }), r;
185
185
  };
186
186
  }
187
- function ye(n) {
187
+ function pe(n) {
188
188
  if (!n) return;
189
- if (n[K]) return n;
189
+ if (n[B]) return n;
190
190
  if (n.loadingRenderer && typeof n.loadingRenderer == "function") {
191
191
  const r = n.loadingRenderer;
192
192
  n = {
193
193
  ...n,
194
- loadingRenderer: Be(r)
194
+ loadingRenderer: He(r)
195
195
  };
196
196
  }
197
197
  if (!n.columns) {
198
198
  const r = n;
199
- return r[K] = !0, r;
199
+ return r[B] = !0, r;
200
200
  }
201
201
  const t = n.columns.map((r) => {
202
- const { renderer: o, editor: a, headerRenderer: l, headerLabelRenderer: i, ...f } = r, g = { ...f };
203
- return o && (g.renderer = Me(o)), a && (g.editor = He(a)), l && (g.headerRenderer = Oe(l)), i && (g.headerLabelRenderer = qe(i)), g;
202
+ const { renderer: o, editor: a, headerRenderer: c, headerLabelRenderer: s, ...u } = r, l = { ...u };
203
+ return o && (l.renderer = ke(o)), a && (l.editor = Te(a)), c && (l.headerRenderer = Fe(c)), s && (l.headerLabelRenderer = Me(s)), l;
204
204
  }), e = {
205
205
  ...n,
206
206
  columns: t
207
207
  };
208
- return e[K] = !0, e;
208
+ return e[B] = !0, e;
209
209
  }
210
- const X = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new Map();
211
- function je(n) {
210
+ const Y = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new Map();
211
+ function Oe(n) {
212
212
  const t = n.querySelector("tbw-grid-detail");
213
213
  if (t) {
214
- const r = X.get(t);
214
+ const r = Y.get(t);
215
215
  if (r) return r;
216
216
  }
217
217
  const e = n.id || n.getAttribute("data-grid-id");
218
218
  if (e)
219
- return ee.get(e);
219
+ return Z.get(e);
220
220
  }
221
- function _e(n) {
222
- const { children: t, showExpandColumn: e = !0, animation: r = "slide" } = n, o = P(null), a = h(
223
- (i) => {
224
- if (o.current = i, !i) return;
225
- X.set(i, t);
226
- const f = i.closest("tbw-grid");
227
- if (f) {
228
- const g = f.id || f.getAttribute("data-grid-id");
229
- g && ee.set(g, t);
221
+ function je(n) {
222
+ const { children: t, showExpandColumn: e = !0, animation: r = "slide" } = n, o = x(null), a = P(
223
+ (s) => {
224
+ if (o.current = s, !s) return;
225
+ Y.set(s, t);
226
+ const u = s.closest("tbw-grid");
227
+ if (u) {
228
+ const l = u.id || u.getAttribute("data-grid-id");
229
+ l && Z.set(l, t);
230
230
  }
231
231
  },
232
232
  [t]
233
233
  );
234
- return w(() => () => {
235
- const i = o.current;
236
- if (i) {
237
- X.delete(i);
238
- const f = i.closest("tbw-grid");
239
- if (f) {
240
- const v = f.id || f.getAttribute("data-grid-id");
241
- v && ee.delete(v);
234
+ return C(() => () => {
235
+ const s = o.current;
236
+ if (s) {
237
+ Y.delete(s);
238
+ const u = s.closest("tbw-grid");
239
+ if (u) {
240
+ const w = u.id || u.getAttribute("data-grid-id");
241
+ w && Z.delete(w);
242
242
  }
243
- const g = i.parentNode;
244
- g && g.contains(i);
243
+ const l = s.parentNode;
244
+ l && l.contains(s);
245
245
  }
246
- }, []), /* @__PURE__ */ E(
246
+ }, []), /* @__PURE__ */ b(
247
247
  "tbw-grid-detail",
248
248
  {
249
249
  ref: a,
@@ -252,29 +252,29 @@ function _e(n) {
252
252
  }
253
253
  );
254
254
  }
255
- _e.displayName = "GridDetailPanel";
256
- const te = /* @__PURE__ */ new WeakMap(), re = /* @__PURE__ */ new Map();
255
+ je.displayName = "GridDetailPanel";
256
+ const Q = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new Map();
257
257
  function ze(n) {
258
- const t = te.get(n);
258
+ const t = Q.get(n);
259
259
  if (t) return t;
260
260
  const e = n.id;
261
261
  if (e)
262
- return re.get(e);
262
+ return X.get(e);
263
263
  }
264
- function ut(n) {
265
- const { id: t, title: e, icon: r, tooltip: o, order: a = 100, children: l } = n, i = P(null), f = h(
266
- (g) => {
267
- i.current = g, g && (te.set(g, l), t && re.set(t, l));
264
+ function dt(n) {
265
+ const { id: t, title: e, icon: r, tooltip: o, order: a = 100, children: c } = n, s = x(null), u = P(
266
+ (l) => {
267
+ s.current = l, l && (Q.set(l, c), t && X.set(t, c));
268
268
  },
269
- [l, t]
269
+ [c, t]
270
270
  );
271
- return w(() => () => {
272
- const g = i.current;
273
- g && (te.delete(g), t && re.delete(t));
274
- }, [t]), /* @__PURE__ */ E(
271
+ return C(() => () => {
272
+ const l = s.current;
273
+ l && (Q.delete(l), t && X.delete(t));
274
+ }, [t]), /* @__PURE__ */ b(
275
275
  "tbw-grid-tool-panel",
276
276
  {
277
- ref: f,
277
+ ref: u,
278
278
  id: t,
279
279
  title: e,
280
280
  icon: r,
@@ -283,38 +283,38 @@ function ut(n) {
283
283
  }
284
284
  );
285
285
  }
286
- const V = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new Map();
286
+ const V = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new Map();
287
287
  function $e(n, t) {
288
288
  const e = n.getAttribute("field"), r = V.get(n) ?? {};
289
289
  if (r.renderer = t, V.set(n, r), e) {
290
- const o = N.get(e) ?? {};
291
- o.renderer = t, N.set(e, o);
290
+ const o = I.get(e) ?? {};
291
+ o.renderer = t, I.set(e, o);
292
292
  }
293
293
  }
294
- function We(n, t) {
294
+ function _e(n, t) {
295
295
  const e = n.getAttribute("field"), r = V.get(n) ?? {};
296
296
  if (r.editor = t, V.set(n, r), e) {
297
- const o = N.get(e) ?? {};
298
- o.editor = t, N.set(e, o);
297
+ const o = I.get(e) ?? {};
298
+ o.editor = t, I.set(e, o);
299
299
  }
300
300
  }
301
- function Je(n) {
301
+ function qe(n) {
302
302
  let t = V.get(n)?.renderer;
303
303
  if (!t) {
304
304
  const e = n.getAttribute("field");
305
- e && (t = N.get(e)?.renderer);
305
+ e && (t = I.get(e)?.renderer);
306
306
  }
307
307
  return t;
308
308
  }
309
- function Ue(n) {
309
+ function We(n) {
310
310
  let t = V.get(n)?.editor;
311
311
  if (!t) {
312
312
  const e = n.getAttribute("field");
313
- e && (t = N.get(e)?.editor);
313
+ e && (t = I.get(e)?.editor);
314
314
  }
315
315
  return t;
316
316
  }
317
- class he {
317
+ class Be {
318
318
  mountedViews = [];
319
319
  /** Editor-specific views tracked separately for per-cell cleanup via releaseCell. */
320
320
  editorViews = [];
@@ -334,7 +334,7 @@ class he {
334
334
  * Converts React renderer/editor functions to DOM-returning functions.
335
335
  */
336
336
  processConfig(t) {
337
- return ye(t) ?? t;
337
+ return pe(t) ?? t;
338
338
  }
339
339
  /**
340
340
  * Determines if this adapter can handle the given element.
@@ -344,8 +344,8 @@ class he {
344
344
  const e = t.getAttribute("field");
345
345
  let r = V.get(t);
346
346
  if (!r && e) {
347
- const l = N.get(e);
348
- l && (l.renderer || l.editor) && (r = l, V.set(t, r));
347
+ const c = I.get(e);
348
+ c && (c.renderer || c.editor) && (r = c, V.set(t, r));
349
349
  }
350
350
  const o = r?.renderer !== void 0, a = r?.editor !== void 0;
351
351
  return r !== void 0 && (o || a);
@@ -362,31 +362,31 @@ class he {
362
362
  * allowing the grid to use its default rendering.
363
363
  */
364
364
  createRenderer(t) {
365
- const e = Je(t);
365
+ const e = qe(t);
366
366
  if (!e)
367
367
  return;
368
368
  const r = /* @__PURE__ */ new WeakMap();
369
369
  return (o) => {
370
370
  const a = o.cellEl;
371
371
  if (a) {
372
- const f = r.get(a);
373
- if (f)
372
+ const u = r.get(a);
373
+ if (u)
374
374
  return R(() => {
375
- f.root.render(e(o));
376
- }), f.container;
377
- const g = document.createElement("div");
378
- g.className = "react-cell-renderer", g.style.display = "contents";
379
- const v = C(g);
375
+ u.root.render(e(o));
376
+ }), u.container;
377
+ const l = document.createElement("div");
378
+ l.className = "react-cell-renderer", l.style.display = "contents";
379
+ const w = v(l);
380
380
  return R(() => {
381
- v.render(e(o));
382
- }), r.set(a, { root: v, container: g, lastRowIndex: o.rowIndex ?? -1 }), this.mountedViews.push({ root: v, container: g }), g;
381
+ w.render(e(o));
382
+ }), r.set(a, { root: w, container: l, lastRowIndex: o.rowIndex ?? -1 }), this.mountedViews.push({ root: w, container: l }), l;
383
383
  }
384
- const l = document.createElement("div");
385
- l.className = "react-cell-renderer", l.style.display = "contents";
386
- const i = C(l);
384
+ const c = document.createElement("div");
385
+ c.className = "react-cell-renderer", c.style.display = "contents";
386
+ const s = v(c);
387
387
  return R(() => {
388
- i.render(e(o));
389
- }), this.mountedViews.push({ root: i, container: l }), l;
388
+ s.render(e(o));
389
+ }), this.mountedViews.push({ root: s, container: c }), c;
390
390
  };
391
391
  }
392
392
  /**
@@ -394,11 +394,11 @@ class he {
394
394
  * with commit/cancel callbacks passed as props.
395
395
  */
396
396
  createEditor(t) {
397
- const e = Ue(t);
397
+ const e = We(t);
398
398
  return e ? (r) => {
399
399
  const o = document.createElement("div");
400
400
  o.className = "react-cell-editor", o.style.display = "contents";
401
- const a = C(o);
401
+ const a = v(o);
402
402
  return R(() => {
403
403
  a.render(e(r));
404
404
  }), this.editorViews.push({ root: a, container: o }), o;
@@ -409,15 +409,15 @@ class he {
409
409
  * Renders React components for expandable detail rows.
410
410
  */
411
411
  createDetailRenderer(t) {
412
- const e = je(t);
412
+ const e = Oe(t);
413
413
  if (e)
414
414
  return (r, o) => {
415
415
  const a = document.createElement("div");
416
416
  a.className = "react-detail-panel";
417
- const l = { row: r, rowIndex: o }, i = C(a);
417
+ const c = { row: r, rowIndex: o }, s = v(a);
418
418
  return R(() => {
419
- i.render(e(l));
420
- }), this.mountedViews.push({ root: i, container: a }), a;
419
+ s.render(e(c));
420
+ }), this.mountedViews.push({ root: s, container: a }), a;
421
421
  };
422
422
  }
423
423
  /**
@@ -434,15 +434,15 @@ class he {
434
434
  * Renders React components for card layout in responsive mode.
435
435
  */
436
436
  createResponsiveCardRenderer(t) {
437
- const e = me(t);
437
+ const e = ge(t);
438
438
  if (e)
439
439
  return (r, o) => {
440
440
  const a = document.createElement("div");
441
441
  a.className = "react-responsive-card";
442
- const l = { row: r, index: o }, i = C(a);
442
+ const c = { row: r, index: o }, s = v(a);
443
443
  return R(() => {
444
- i.render(e(l));
445
- }), this.mountedViews.push({ root: i, container: a }), a;
444
+ s.render(e(c));
445
+ }), this.mountedViews.push({ root: s, container: a }), a;
446
446
  };
447
447
  }
448
448
  /**
@@ -457,18 +457,18 @@ class he {
457
457
  return (o) => {
458
458
  const a = {
459
459
  grid: r ?? o
460
- }, l = C(o);
460
+ }, c = v(o);
461
461
  return R(() => {
462
- l.render(e(a));
463
- }), this.mountedViews.push({ root: l, container: o }), () => {
464
- const i = this.mountedViews.findIndex((f) => f.container === o);
465
- if (i !== -1) {
466
- const { root: f } = this.mountedViews[i];
462
+ c.render(e(a));
463
+ }), this.mountedViews.push({ root: c, container: o }), () => {
464
+ const s = this.mountedViews.findIndex((u) => u.container === o);
465
+ if (s !== -1) {
466
+ const { root: u } = this.mountedViews[s];
467
467
  try {
468
- f.unmount();
468
+ u.unmount();
469
469
  } catch {
470
470
  }
471
- this.mountedViews.splice(i, 1);
471
+ this.mountedViews.splice(s, 1);
472
472
  }
473
473
  };
474
474
  };
@@ -516,7 +516,7 @@ class he {
516
516
  return (e) => {
517
517
  const r = document.createElement("span");
518
518
  r.style.display = "contents";
519
- const o = C(r);
519
+ const o = v(r);
520
520
  return this.mountedViews.push({ root: o, container: r }), R(() => {
521
521
  o.render(t(e));
522
522
  }), r;
@@ -530,7 +530,7 @@ class he {
530
530
  return (e) => {
531
531
  const r = document.createElement("span");
532
532
  r.style.display = "contents";
533
- const o = C(r);
533
+ const o = v(r);
534
534
  return this.editorViews.push({ root: o, container: r }), R(() => {
535
535
  o.render(t(e));
536
536
  }), r;
@@ -544,7 +544,7 @@ class he {
544
544
  return (e, r) => {
545
545
  const o = document.createElement("div");
546
546
  o.style.display = "contents";
547
- const a = C(o);
547
+ const a = v(o);
548
548
  this.mountedViews.push({ root: a, container: o }), R(() => {
549
549
  a.render(t(r));
550
550
  }), e.appendChild(o);
@@ -565,7 +565,7 @@ class he {
565
565
  t.unmount();
566
566
  } catch {
567
567
  }
568
- }), this.editorViews = [], N.clear();
568
+ }), this.editorViews = [], I.clear();
569
569
  }
570
570
  /**
571
571
  * Called when a cell's content is about to be wiped.
@@ -584,7 +584,7 @@ class he {
584
584
  this.editorViews.splice(e, 1);
585
585
  }
586
586
  }
587
- Fe(t);
587
+ Le(t);
588
588
  }
589
589
  /**
590
590
  * Unmount a specific container (called when cell is recycled).
@@ -601,11 +601,11 @@ class he {
601
601
  }
602
602
  }
603
603
  }
604
- const ft = he, Ke = {
604
+ const Ke = {
605
605
  undoRedo: ["editing"],
606
606
  clipboard: ["selection"]
607
607
  };
608
- function Ye(n) {
608
+ function Ue(n) {
609
609
  const t = new Set(n);
610
610
  for (const e of n) {
611
611
  const r = Ke[e];
@@ -616,34 +616,34 @@ function Ye(n) {
616
616
  );
617
617
  }
618
618
  }
619
- function Ze(n) {
619
+ function Je(n) {
620
620
  const t = [];
621
621
  for (const [e, r] of Object.entries(n))
622
622
  r === void 0 || r === !1 || t.push(e);
623
- return Ye(t), Pe(n);
623
+ return Ue(t), be(n);
624
624
  }
625
- let fe = !1, Y = null;
626
- function ne() {
627
- return fe || (Y = new he(), ve.registerAdapter(Y), fe = !0), Y;
625
+ let le = !1, K = null;
626
+ function ee() {
627
+ return le || (K = new Be(), he.registerAdapter(K), le = !0), K;
628
628
  }
629
- ne();
630
- function Qe(n) {
629
+ ee();
630
+ function Ye(n) {
631
631
  const e = n.getPluginByName?.("masterDetail");
632
632
  e && typeof e.refreshDetailRenderer == "function" && e.refreshDetailRenderer();
633
633
  }
634
- function Xe(n, t) {
634
+ function Ze(n, t) {
635
635
  const e = n;
636
- if (!n.querySelector("tbw-grid-responsive-card") || !me(n)) return;
636
+ if (!n.querySelector("tbw-grid-responsive-card") || !ge(n)) return;
637
637
  const a = e.getPluginByName?.("responsive");
638
638
  if (a && typeof a.setCardRenderer == "function") {
639
- const l = t.createResponsiveCardRenderer(n);
640
- l && a.setCardRenderer(l);
639
+ const c = t.createResponsiveCardRenderer(n);
640
+ c && a.setCardRenderer(c);
641
641
  }
642
642
  }
643
- function et(n) {
643
+ function Qe(n) {
644
644
  const t = {};
645
- return Ee.forEach(n, (e) => {
646
- if (Se(e)) {
645
+ return Ce.forEach(n, (e) => {
646
+ if (ve(e)) {
647
647
  if (e.type && e.type.displayName === "GridDetailPanel") {
648
648
  const r = e.props;
649
649
  t.masterDetail = {
@@ -657,45 +657,38 @@ function et(n) {
657
657
  }
658
658
  }), t;
659
659
  }
660
- const gt = Ce(function(t, e) {
660
+ const ut = Re(function(t, e) {
661
661
  const {
662
662
  // Core props
663
663
  rows: r,
664
664
  gridConfig: o,
665
665
  columns: a,
666
- columnDefaults: l,
667
- fitMode: i,
668
- sortable: f,
669
- filterable: g,
670
- selectable: v,
671
- loading: x,
672
- editOn: D,
673
- customStyles: A,
674
- className: k,
675
- style: M,
676
- children: L,
666
+ columnDefaults: c,
667
+ fitMode: s,
668
+ sortable: u,
669
+ filterable: l,
670
+ selectable: w,
671
+ loading: D,
672
+ customStyles: S,
673
+ className: L,
674
+ style: g,
675
+ children: h,
677
676
  // Plugin props
678
- plugins: S,
677
+ plugins: m,
679
678
  // SSR mode
680
- ssr: T,
679
+ ssr: E,
681
680
  // Legacy event handlers
682
- onRowsChange: y,
681
+ onRowsChange: N,
683
682
  // Feature props and event props are in ...rest
684
- ...d
685
- } = t, s = P(null), p = P(null), b = z(ke), H = z(Ne), F = [
683
+ ...y
684
+ } = t, f = x(null), j = x(null), re = O(Ne), $ = O(Ae), ne = [
686
685
  "selection",
687
686
  "editing",
688
687
  "filtering",
689
688
  "multiSort",
690
- "sorting",
691
- // deprecated alias for multiSort
692
689
  "clipboard",
693
690
  "contextMenu",
694
691
  "reorderColumns",
695
- "reorder",
696
- // deprecated alias for reorderColumns
697
- "rowReorder",
698
- // deprecated alias for reorderRows
699
692
  "reorderRows",
700
693
  "visibility",
701
694
  "undoRedo",
@@ -712,367 +705,293 @@ const gt = Ce(function(t, e) {
712
705
  "pivot",
713
706
  "serverSide",
714
707
  "tooltip"
715
- ], we = G(() => F.map((c) => {
716
- const u = d[c];
717
- return u !== void 0 ? `${c}:${JSON.stringify(u)}` : "";
718
- }).filter(Boolean).join("|"), [d]), ie = G(() => {
719
- const c = {};
720
- for (const u of F)
721
- u in d && d[u] !== void 0 && (c[u] = d[u]);
722
- return c;
723
- }, [we]), se = G(() => et(L), [L]), ce = G(() => ({ ...se, ...ie }), [ie, se]), W = G(() => S || T ? [] : Ze(ce), [ce, S, T]), O = G(() => {
724
- if (S) {
725
- const c = new Set(S.map((m) => m.name)), u = W.filter((m) => !c.has(m.name));
726
- return [...S, ...u];
708
+ ], me = G(() => ne.map((i) => {
709
+ const d = y[i];
710
+ return d !== void 0 ? `${i}:${JSON.stringify(d)}` : "";
711
+ }).filter(Boolean).join("|"), [y]), oe = G(() => {
712
+ const i = {};
713
+ for (const d of ne)
714
+ d in y && y[d] !== void 0 && (i[d] = y[d]);
715
+ return i;
716
+ }, [me]), ie = G(() => Qe(h), [h]), se = G(() => ({ ...ie, ...oe }), [oe, ie]), _ = G(() => m || E ? [] : Je(se), [se, m, E]), k = G(() => {
717
+ if (m) {
718
+ const i = new Set(m.map((p) => p.name)), d = _.filter((p) => !i.has(p.name));
719
+ return [...m, ...d];
727
720
  }
728
- return W;
729
- }, [S, W]), q = G(() => {
721
+ return _;
722
+ }, [m, _]), T = G(() => {
730
723
  if (!a) return a;
731
- const c = Ie(a);
732
- return l ? c.map((u) => ({
733
- ...l,
734
- ...u
724
+ const i = Ge(a);
725
+ return c ? i.map((d) => ({
726
+ ...c,
727
+ ...d
735
728
  // Individual column props override defaults
736
- })) : c;
737
- }, [a, l]), B = G(() => {
738
- const c = ye(o), u = {};
739
- if (f !== void 0 && (u.sortable = f), g !== void 0 && (u.filterable = g), v !== void 0 && (u.selectable = v), H) {
740
- const m = c?.icons || o?.icons || {};
741
- u.icons = { ...H, ...m };
729
+ })) : i;
730
+ }, [a, c]), F = G(() => {
731
+ const i = pe(o), d = {};
732
+ if (u !== void 0 && (d.sortable = u), l !== void 0 && (d.filterable = l), w !== void 0 && (d.selectable = w), $) {
733
+ const p = i?.icons || o?.icons || {};
734
+ d.icons = { ...$, ...p };
742
735
  }
743
- if (O.length > 0 && c) {
744
- const m = c.plugins || [], j = new Set(m.map((_) => _.name)), J = O.filter((_) => !j.has(_.name));
736
+ if (k.length > 0 && i) {
737
+ const p = i.plugins || [], M = new Set(p.map((H) => H.name)), q = k.filter((H) => !M.has(H.name));
745
738
  return {
746
- ...c,
747
- ...u,
748
- plugins: [...m, ...J]
739
+ ...i,
740
+ ...d,
741
+ plugins: [...p, ...q]
749
742
  };
750
743
  }
751
- return O.length > 0 && !c ? { ...u, plugins: O } : Object.keys(u).length > 0 ? { ...c, ...u } : c;
752
- }, [o, O, f, g, v, H]);
753
- w(() => {
754
- ne().setTypeDefaults(b);
755
- }, [b]), w(() => {
756
- s.current && (s.current.rows = r);
757
- }, [r]), w(() => {
758
- s.current && B && (s.current.gridConfig = B);
759
- }, [B]), w(() => {
760
- s.current && q && (s.current.columns = q);
761
- }, [q]), w(() => {
762
- s.current && i !== void 0 && (s.current.fitMode = i);
763
- }, [i]), w(() => {
764
- s.current && D !== void 0 && (s.current.editOn = D);
765
- }, [D]), w(() => {
766
- s.current && x !== void 0 && (s.current.loading = x);
767
- }, [x]), w(() => {
768
- const c = s.current;
769
- if (!c) return;
770
- const u = ne();
771
- c.__frameworkAdapter = u, Qe(c), Xe(c, u);
772
- let m = !1;
773
- const j = requestAnimationFrame(() => {
774
- m || (typeof c.refreshColumns == "function" && c.refreshColumns(), typeof c.refreshShellHeader == "function" && c.refreshShellHeader());
744
+ return k.length > 0 && !i ? { ...d, plugins: k } : Object.keys(d).length > 0 ? { ...i, ...d } : i;
745
+ }, [o, k, u, l, w, $]);
746
+ C(() => {
747
+ ee().setTypeDefaults(re);
748
+ }, [re]), C(() => {
749
+ f.current && (f.current.rows = r);
750
+ }, [r]), C(() => {
751
+ f.current && F && (f.current.gridConfig = F);
752
+ }, [F]), C(() => {
753
+ f.current && T && (f.current.columns = T);
754
+ }, [T]), C(() => {
755
+ f.current && s !== void 0 && (f.current.fitMode = s);
756
+ }, [s]), C(() => {
757
+ f.current && D !== void 0 && (f.current.loading = D);
758
+ }, [D]), C(() => {
759
+ const i = f.current;
760
+ if (!i) return;
761
+ const d = ee();
762
+ i.__frameworkAdapter = d, Ye(i), Ze(i, d);
763
+ let p = !1;
764
+ const M = requestAnimationFrame(() => {
765
+ p || (typeof i.refreshColumns == "function" && i.refreshColumns(), typeof i.refreshShellHeader == "function" && i.refreshShellHeader());
775
766
  });
776
767
  return () => {
777
- m = !0, cancelAnimationFrame(j);
768
+ p = !0, cancelAnimationFrame(M);
778
769
  };
779
- }, []), w(() => {
780
- if (!s.current || !A) return;
781
- const c = s.current, u = "react-custom-styles";
782
- let m = !0;
783
- return c.ready?.().then(() => {
784
- m && A && (c.registerStyles?.(u, A), p.current = u);
770
+ }, []), C(() => {
771
+ if (!f.current || !S) return;
772
+ const i = f.current, d = "react-custom-styles";
773
+ let p = !0;
774
+ return i.ready?.().then(() => {
775
+ p && S && (i.registerStyles?.(d, S), j.current = d);
785
776
  }), () => {
786
- m = !1, p.current && (c.unregisterStyles?.(p.current), p.current = null);
777
+ p = !1, j.current && (i.unregisterStyles?.(j.current), j.current = null);
787
778
  };
788
- }, [A]), w(() => {
789
- const c = s.current;
790
- if (!c) return;
791
- const u = [];
792
- return y && u.push(c.on("rows-change", (m) => y(m.rows))), () => {
793
- u.forEach((m) => m());
779
+ }, [S]), C(() => {
780
+ const i = f.current;
781
+ if (!i) return;
782
+ const d = [];
783
+ return N && d.push(i.on("rows-change", (p) => N(p.rows))), () => {
784
+ d.forEach((p) => p());
794
785
  };
795
- }, [y]);
796
- const ae = G(() => Object.keys(U).filter((c) => typeof d[c] == "function").sort().join("|"), [d]), le = P({});
797
- for (const c of Object.keys(U))
798
- le.current[c] = d[c];
799
- return w(() => {
800
- const c = s.current;
801
- if (!c) return;
802
- const u = [];
803
- for (const [m, j] of Object.entries(U))
804
- ae.includes(m) && u.push(
805
- c.on(j, (J, _) => {
806
- le.current[m]?.(J, _);
786
+ }, [N]);
787
+ const ce = G(() => Object.keys(W).filter((i) => typeof y[i] == "function").sort().join("|"), [y]), ae = x({});
788
+ for (const i of Object.keys(W))
789
+ ae.current[i] = y[i];
790
+ return C(() => {
791
+ const i = f.current;
792
+ if (!i) return;
793
+ const d = [];
794
+ for (const [p, M] of Object.entries(W))
795
+ ce.includes(p) && d.push(
796
+ i.on(M, (q, H) => {
797
+ ae.current[p]?.(q, H);
807
798
  })
808
799
  );
809
800
  return () => {
810
- u.forEach((m) => m());
801
+ d.forEach((p) => p());
811
802
  };
812
- }, [ae]), be(
803
+ }, [ce]), we(
813
804
  e,
814
805
  () => ({
815
806
  get element() {
816
- return s.current;
807
+ return f.current;
817
808
  },
818
809
  async getConfig() {
819
- return s.current?.getConfig?.() ?? {};
810
+ return f.current?.getConfig?.() ?? {};
820
811
  },
821
812
  async ready() {
822
- return s.current?.ready?.();
813
+ return f.current?.ready?.();
823
814
  },
824
815
  async forceLayout() {
825
- return s.current?.forceLayout?.();
816
+ return f.current?.forceLayout?.();
826
817
  },
827
- async toggleGroup(c) {
828
- return s.current?.toggleGroup?.(c);
818
+ async toggleGroup(i) {
819
+ return f.current?.toggleGroup?.(i);
829
820
  },
830
- registerStyles(c, u) {
831
- s.current?.registerStyles?.(c, u);
821
+ registerStyles(i, d) {
822
+ f.current?.registerStyles?.(i, d);
832
823
  },
833
- unregisterStyles(c) {
834
- s.current?.unregisterStyles?.(c);
824
+ unregisterStyles(i) {
825
+ f.current?.unregisterStyles?.(i);
835
826
  },
836
- setRowLoading(c, u) {
837
- s.current?.setRowLoading?.(c, u);
827
+ setRowLoading(i, d) {
828
+ f.current?.setRowLoading?.(i, d);
838
829
  },
839
- setCellLoading(c, u, m) {
840
- s.current?.setCellLoading?.(c, u, m);
830
+ setCellLoading(i, d, p) {
831
+ f.current?.setCellLoading?.(i, d, p);
841
832
  },
842
- isRowLoading(c) {
843
- return s.current?.isRowLoading?.(c) ?? !1;
833
+ isRowLoading(i) {
834
+ return f.current?.isRowLoading?.(i) ?? !1;
844
835
  },
845
- isCellLoading(c, u) {
846
- return s.current?.isCellLoading?.(c, u) ?? !1;
836
+ isCellLoading(i, d) {
837
+ return f.current?.isCellLoading?.(i, d) ?? !1;
847
838
  },
848
839
  clearAllLoading() {
849
- s.current?.clearAllLoading?.();
840
+ f.current?.clearAllLoading?.();
850
841
  }
851
842
  }),
852
843
  []
853
- ), /* @__PURE__ */ E(
844
+ ), /* @__PURE__ */ b(
854
845
  "tbw-grid",
855
846
  {
856
- ref: (c) => {
857
- if (s.current = c, c) {
858
- const u = c;
859
- B && (u.gridConfig = B), r && (u.rows = r), q && (u.columns = q);
847
+ ref: (i) => {
848
+ if (f.current = i, i) {
849
+ const d = i;
850
+ F && (d.gridConfig = F), r && (d.rows = r), T && (d.columns = T);
860
851
  }
861
852
  },
862
- class: k,
863
- style: M,
864
- children: /* @__PURE__ */ E(xe.Provider, { value: s, children: L })
853
+ class: L,
854
+ style: g,
855
+ children: /* @__PURE__ */ b(Ee.Provider, { value: f, children: h })
865
856
  }
866
857
  );
867
858
  });
868
- function pt(n) {
859
+ function lt(n) {
869
860
  const {
870
861
  field: t,
871
862
  header: e,
872
863
  type: r,
873
864
  editable: o,
874
865
  sortable: a,
875
- resizable: l,
876
- width: i,
877
- minWidth: f,
878
- hidden: g,
879
- lockVisible: v,
880
- children: x,
881
- editor: D,
882
- options: A,
883
- multi: k,
884
- format: M
885
- } = n, L = P(null), S = h(
886
- (d) => {
887
- L.current = d, d && (x && $e(d, x), D && We(d, D));
866
+ resizable: c,
867
+ width: s,
868
+ minWidth: u,
869
+ hidden: l,
870
+ lockVisible: w,
871
+ children: D,
872
+ editor: S,
873
+ options: L,
874
+ multi: g,
875
+ format: h
876
+ } = n, m = x(null), E = P(
877
+ (f) => {
878
+ m.current = f, f && (D && $e(f, D), S && _e(f, S));
888
879
  },
889
- [x, D, t]
890
- ), T = typeof i == "number" ? `${i}px` : i, y = {
880
+ [D, S, t]
881
+ ), N = typeof s == "number" ? `${s}px` : s, y = {
891
882
  field: t,
892
- ref: S
883
+ ref: E
893
884
  };
894
- return e !== void 0 && (y.header = e), r !== void 0 && (y.type = r), o !== void 0 && (y.editable = o), a !== void 0 && (y.sortable = a), l !== void 0 && (y.resizable = l), T !== void 0 && (y.width = T), f !== void 0 && (y["min-width"] = f), g !== void 0 && (y.hidden = g), v !== void 0 && (y["lock-visible"] = v), k !== void 0 && (y.multi = k), M && (y["data-has-format"] = "true"), A && (y["data-has-options"] = "true"), /* @__PURE__ */ E("tbw-grid-column", { ...y });
885
+ return e !== void 0 && (y.header = e), r !== void 0 && (y.type = r), o !== void 0 && (y.editable = o), a !== void 0 && (y.sortable = a), c !== void 0 && (y.resizable = c), N !== void 0 && (y.width = N), u !== void 0 && (y["min-width"] = u), l !== void 0 && (y.hidden = l), w !== void 0 && (y["lock-visible"] = w), g !== void 0 && (y.multi = g), h && (y["data-has-format"] = "true"), L && (y["data-has-options"] = "true"), /* @__PURE__ */ b("tbw-grid-column", { ...y });
895
886
  }
896
- function mt({ children: n }) {
897
- return /* @__PURE__ */ E("tbw-grid-tool-buttons", { children: n });
887
+ function ft({ children: n }) {
888
+ return /* @__PURE__ */ b("tbw-grid-tool-buttons", { children: n });
898
889
  }
899
- const yt = ({ icons: n, defaults: t, children: e }) => {
890
+ const gt = ({ icons: n, defaults: t, children: e }) => {
900
891
  let r = e;
901
- return t && (r = /* @__PURE__ */ E(Te, { defaults: t, children: r })), n && (r = /* @__PURE__ */ E(Ve, { icons: n, children: r })), /* @__PURE__ */ E(Re, { children: r });
892
+ return t && (r = /* @__PURE__ */ b(Ie, { defaults: t, children: r })), n && (r = /* @__PURE__ */ b(xe, { icons: n, children: r })), /* @__PURE__ */ b(ye, { children: r });
902
893
  };
903
- function ht(n) {
904
- const t = P(null), [e, r] = de(!1), [o, a] = de(null), l = P(null), i = h(() => n ? (l.current ??= document.querySelector(n), l.current) : t.current?.element ?? null, [n]);
905
- w(() => {
906
- let d = !0;
894
+ function pt(n) {
895
+ const t = x(null), [e, r] = de(!1), [o, a] = de(null), c = x(null), s = P(() => n ? (c.current ??= document.querySelector(n), c.current) : t.current?.element ?? null, [n]);
896
+ C(() => {
897
+ let g = !0;
907
898
  return (async () => {
908
899
  try {
909
900
  if (n) {
910
- const p = document.querySelector(n);
911
- if (!p) return;
912
- if (l.current = p, await p.ready?.(), d) {
901
+ const m = document.querySelector(n);
902
+ if (!m) return;
903
+ if (c.current = m, await m.ready?.(), g) {
913
904
  r(!0);
914
- const b = await p.getConfig?.();
915
- d && b && a(b);
905
+ const E = await m.getConfig?.();
906
+ g && E && a(E);
916
907
  }
917
908
  } else {
918
- const p = t.current;
919
- if (!p) return;
920
- if (await p.ready?.(), d) {
909
+ const m = t.current;
910
+ if (!m) return;
911
+ if (await m.ready?.(), g) {
921
912
  r(!0);
922
- const b = await p.getConfig?.();
923
- d && b && a(b);
913
+ const E = await m.getConfig?.();
914
+ g && E && a(E);
924
915
  }
925
916
  }
926
917
  } catch {
927
918
  }
928
919
  })(), () => {
929
- d = !1;
920
+ g = !1;
930
921
  };
931
922
  }, [n]);
932
- const f = h(async () => {
933
- const d = i();
934
- if (d)
935
- return await d.getConfig?.() ?? null;
936
- const s = t.current;
937
- return s ? await s.getConfig?.() ?? null : null;
938
- }, [i]), g = h(async () => {
939
- const d = i();
940
- if (d) {
941
- await d.forceLayout?.();
923
+ const u = P(async () => {
924
+ const g = s();
925
+ if (g)
926
+ return await g.getConfig?.() ?? null;
927
+ const h = t.current;
928
+ return h ? await h.getConfig?.() ?? null : null;
929
+ }, [s]), l = P(async () => {
930
+ const g = s();
931
+ if (g) {
932
+ await g.forceLayout?.();
942
933
  return;
943
934
  }
944
- const s = t.current;
945
- s && await s.forceLayout?.();
946
- }, [i]), v = h(
947
- async (d) => {
948
- const s = i();
949
- if (s) {
950
- await s.toggleGroup?.(d);
935
+ const h = t.current;
936
+ h && await h.forceLayout?.();
937
+ }, [s]), w = P(
938
+ async (g) => {
939
+ const h = s();
940
+ if (h) {
941
+ await h.toggleGroup?.(g);
951
942
  return;
952
943
  }
953
- const p = t.current;
954
- p && await p.toggleGroup?.(d);
944
+ const m = t.current;
945
+ m && await m.toggleGroup?.(g);
955
946
  },
956
- [i]
957
- ), x = h(
958
- (d, s) => {
959
- const p = i();
960
- if (p) {
961
- p.registerStyles?.(d, s);
947
+ [s]
948
+ ), D = P(
949
+ (g, h) => {
950
+ const m = s();
951
+ if (m) {
952
+ m.registerStyles?.(g, h);
962
953
  return;
963
954
  }
964
- t.current?.registerStyles?.(d, s);
955
+ t.current?.registerStyles?.(g, h);
965
956
  },
966
- [i]
967
- ), D = h(
968
- (d) => {
969
- const s = i();
970
- if (s) {
971
- s.unregisterStyles?.(d);
972
- return;
973
- }
974
- t.current?.unregisterStyles?.(d);
975
- },
976
- [i]
977
- ), A = h(() => o?.columns ? o.columns.filter((d) => !d.hidden) : [], [o]), k = h(() => {
978
- const d = i(), s = d?.getPluginByName?.("selection");
979
- if (!s) {
980
- console.warn("[useGrid] selectAll requires SelectionPlugin");
981
- return;
982
- }
983
- if (s.config?.mode === "row") {
984
- const p = d?.rows ?? [], b = new Set(p.map((H, F) => F));
985
- s.selected = b, s.requestAfterRender?.();
986
- }
987
- }, [i]), M = h(() => {
988
- const s = i()?.getPluginByName?.("selection");
989
- s && s.clearSelection?.();
990
- }, [i]), L = h(() => {
991
- const s = i()?.getPluginByName?.("selection");
992
- return s ? new Set(s.selected ?? []) : /* @__PURE__ */ new Set();
993
- }, [i]), S = h(() => {
994
- const d = i(), s = d?.getPluginByName?.("selection");
995
- if (!s) return [];
996
- const p = d?.rows ?? [], b = s.selected ?? /* @__PURE__ */ new Set();
997
- return p.filter((H, F) => b.has(F));
998
- }, [i]), T = h(
999
- (d) => {
1000
- const p = i()?.getPluginByName?.("export");
1001
- if (!p) {
1002
- console.warn("[useGrid] exportToCsv requires ExportPlugin (use export prop)");
1003
- return;
1004
- }
1005
- p.exportCsv?.({ filename: d ?? "export.csv" });
1006
- },
1007
- [i]
1008
- ), y = h(
1009
- (d) => {
1010
- const p = i()?.getPluginByName?.("export");
1011
- if (!p) {
1012
- console.warn("[useGrid] exportToJson requires ExportPlugin (use export prop)");
957
+ [s]
958
+ ), S = P(
959
+ (g) => {
960
+ const h = s();
961
+ if (h) {
962
+ h.unregisterStyles?.(g);
1013
963
  return;
1014
964
  }
1015
- p.exportJson?.({ filename: d ?? "export.json" });
965
+ t.current?.unregisterStyles?.(g);
1016
966
  },
1017
- [i]
1018
- );
967
+ [s]
968
+ ), L = P(() => o?.columns ? o.columns.filter((g) => !g.hidden) : [], [o]);
1019
969
  return {
1020
970
  ref: t,
1021
- element: i(),
971
+ element: s(),
1022
972
  isReady: e,
1023
973
  config: o,
1024
- getConfig: f,
1025
- forceLayout: g,
1026
- toggleGroup: v,
1027
- registerStyles: x,
1028
- unregisterStyles: D,
1029
- getVisibleColumns: A,
1030
- // Selection methods
1031
- selectAll: k,
1032
- clearSelection: M,
1033
- getSelectedIndices: L,
1034
- getSelectedRows: S,
1035
- // Export methods
1036
- exportToCsv: T,
1037
- exportToJson: y
974
+ getConfig: u,
975
+ forceLayout: l,
976
+ toggleGroup: w,
977
+ registerStyles: D,
978
+ unregisterStyles: S,
979
+ getVisibleColumns: L
1038
980
  };
1039
981
  }
1040
- let ge = !1;
1041
- function wt(n, t, e, r = []) {
1042
- !ge && typeof window < "u" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes(".local")) && (ge = !0, console.warn(
1043
- `[useGridEvent] Deprecated: Use event props directly on DataGrid instead.
1044
- Example: <DataGrid onSelectionChange={(e) => ...} />
1045
- See migration guide: https://toolbox-web.dev/grid-react/migration`
1046
- ));
1047
- const o = P(e);
1048
- w(() => {
1049
- o.current = e;
1050
- }, [e, ...r]), w(() => {
1051
- const a = n.current, l = a && "element" in a ? a.element : a;
1052
- if (!l) return;
1053
- const i = ((f) => {
1054
- o.current(f);
1055
- });
1056
- return l.addEventListener(t, i), () => {
1057
- l.removeEventListener(t, i);
1058
- };
1059
- }, [n, t]);
1060
- }
1061
982
  export {
1062
- gt as DataGrid,
1063
- he as GridAdapter,
1064
- pt as GridColumn,
1065
- _e as GridDetailPanel,
1066
- Ve as GridIconProvider,
1067
- yt as GridProvider,
1068
- Le as GridResponsiveCard,
1069
- mt as GridToolButtons,
1070
- ut as GridToolPanel,
1071
- Te as GridTypeProvider,
1072
- ft as ReactGridAdapter,
1073
- ht as useGrid,
1074
- wt as useGridEvent,
1075
- at as useGridIcons,
1076
- lt as useGridTypeDefaults,
1077
- dt as useTypeDefault
983
+ ut as DataGrid,
984
+ Be as GridAdapter,
985
+ lt as GridColumn,
986
+ je as GridDetailPanel,
987
+ xe as GridIconProvider,
988
+ gt as GridProvider,
989
+ Ve as GridResponsiveCard,
990
+ ft as GridToolButtons,
991
+ dt as GridToolPanel,
992
+ Ie as GridTypeProvider,
993
+ pt as useGrid,
994
+ st as useGridIcons,
995
+ ct as useGridTypeDefaults,
996
+ at as useTypeDefault
1078
997
  };