@toolbox-web/grid-react 0.18.1 → 0.18.2

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