@toolbox-web/grid-react 0.18.1 → 0.18.3

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,13 +33,14 @@ 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",
40
40
  onCellChange: "cell-change",
41
41
  onCellCommit: "cell-commit",
42
42
  onRowCommit: "row-commit",
43
+ onChangedRowsReset: "changed-rows-reset",
43
44
  onSortChange: "sort-change",
44
45
  onFilterChange: "filter-change",
45
46
  onColumnResize: "column-resize",
@@ -58,57 +59,57 @@ const W = {
58
59
  onExportComplete: "export-complete",
59
60
  onPrintStart: "print-start",
60
61
  onPrintComplete: "print-complete"
61
- }, re = pe(null), Ve = ({ icons: n, children: t }) => /* @__PURE__ */ E(re.Provider, { value: n, children: t });
62
+ }, oe = pe(null), Ve = ({ icons: n, children: t }) => /* @__PURE__ */ E(oe.Provider, { value: n, children: t });
62
63
  function at() {
63
- return j(re);
64
+ return z(oe);
64
65
  }
65
- const Ne = re, K = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new Map();
66
+ const Ne = oe, Z = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new Map();
66
67
  function me(n) {
67
68
  const t = n.querySelector("tbw-grid-responsive-card");
68
69
  if (t) {
69
- const r = K.get(t);
70
+ const r = Z.get(t);
70
71
  if (r) return r;
71
72
  }
72
73
  const e = n.id || n.getAttribute("data-grid-id");
73
74
  if (e)
74
- return Y.get(e);
75
+ return Q.get(e);
75
76
  }
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);
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);
85
86
  }
86
87
  },
87
88
  [t]
88
89
  );
89
90
  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);
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);
97
98
  }
98
99
  }
99
100
  }, []);
100
- const s = e === "auto" ? "auto" : String(e);
101
- return /* @__PURE__ */ E("tbw-grid-responsive-card", { ref: o, cardRowHeight: s });
101
+ const a = e === "auto" ? "auto" : String(e);
102
+ return /* @__PURE__ */ E("tbw-grid-responsive-card", { ref: o, cardRowHeight: a });
102
103
  }
103
- Te.displayName = "GridResponsiveCard";
104
- const _ = pe(null), Le = ({ defaults: n, children: t }) => /* @__PURE__ */ E(_.Provider, { value: n, children: t });
104
+ Le.displayName = "GridResponsiveCard";
105
+ const $ = pe(null), Te = ({ defaults: n, children: t }) => /* @__PURE__ */ E($.Provider, { value: n, children: t });
105
106
  function lt() {
106
- return j(_);
107
+ return z($);
107
108
  }
108
109
  function dt(n) {
109
- return j(_)?.[n];
110
+ return z($)?.[n];
110
111
  }
111
- const ke = _, J = /* @__PURE__ */ Symbol("reactProcessed"), I = [];
112
+ const ke = $, K = /* @__PURE__ */ Symbol("reactProcessed"), I = [];
112
113
  function Fe(n) {
113
114
  for (let t = I.length - 1; t >= 0; t--) {
114
115
  const e = I[t];
@@ -126,26 +127,26 @@ function Me(n) {
126
127
  return (e) => {
127
128
  const r = e.cellEl;
128
129
  if (r) {
129
- const c = t.get(r);
130
- if (c)
131
- return v(() => {
132
- c.root.render(n(e));
133
- }), c.container;
130
+ const l = t.get(r);
131
+ if (l)
132
+ return R(() => {
133
+ l.root.render(n(e));
134
+ }), l.container;
134
135
  }
135
136
  const o = document.createElement("div");
136
137
  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;
138
+ const a = C(o);
139
+ return R(() => {
140
+ a.render(n(e));
141
+ }), r && t.set(r, { root: a, container: o }), I.push({ root: a, container: o }), o;
141
142
  };
142
143
  }
143
144
  function He(n) {
144
145
  return (t) => {
145
146
  const e = document.createElement("div");
146
147
  e.className = "react-cell-editor", e.style.display = "contents";
147
- const r = b(e);
148
- return v(() => {
148
+ const r = C(e);
149
+ return R(() => {
149
150
  r.render(n(t));
150
151
  }), I.push({ root: r, container: e }), e;
151
152
  };
@@ -154,131 +155,131 @@ function Oe(n) {
154
155
  return (t) => {
155
156
  const e = document.createElement("div");
156
157
  e.className = "react-header-renderer", e.style.display = "contents";
157
- const r = b(e);
158
- return v(() => {
158
+ const r = C(e);
159
+ return R(() => {
159
160
  r.render(n(t));
160
161
  }), I.push({ root: r, container: e }), e;
161
162
  };
162
163
  }
163
- function Be(n) {
164
+ function qe(n) {
164
165
  return (t) => {
165
166
  const e = document.createElement("div");
166
167
  e.className = "react-header-label-renderer", e.style.display = "contents";
167
- const r = b(e);
168
- return v(() => {
168
+ const r = C(e);
169
+ return R(() => {
169
170
  r.render(n(t));
170
171
  }), I.push({ root: r, container: e }), e;
171
172
  };
172
173
  }
173
- function je(n) {
174
+ function Be(n) {
174
175
  return (t) => {
175
176
  const e = n(t);
176
177
  if (e instanceof HTMLElement || typeof e == "string")
177
178
  return e;
178
179
  const r = document.createElement("div");
179
180
  r.className = "react-loading-renderer", r.style.display = "contents";
180
- const o = b(r);
181
- return v(() => {
181
+ const o = C(r);
182
+ return R(() => {
182
183
  o.render(e);
183
184
  }), I.push({ root: o, container: r }), r;
184
185
  };
185
186
  }
186
187
  function ye(n) {
187
188
  if (!n) return;
188
- if (n[J]) return n;
189
+ if (n[K]) return n;
189
190
  if (n.loadingRenderer && typeof n.loadingRenderer == "function") {
190
191
  const r = n.loadingRenderer;
191
192
  n = {
192
193
  ...n,
193
- loadingRenderer: je(r)
194
+ loadingRenderer: Be(r)
194
195
  };
195
196
  }
196
197
  if (!n.columns) {
197
198
  const r = n;
198
- return r[J] = !0, r;
199
+ return r[K] = !0, r;
199
200
  }
200
201
  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;
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;
203
204
  }), e = {
204
205
  ...n,
205
206
  columns: t
206
207
  };
207
- return e[J] = !0, e;
208
+ return e[K] = !0, e;
208
209
  }
209
- const Z = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new Map();
210
- function _e(n) {
210
+ const X = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new Map();
211
+ function je(n) {
211
212
  const t = n.querySelector("tbw-grid-detail");
212
213
  if (t) {
213
- const r = Z.get(t);
214
+ const r = X.get(t);
214
215
  if (r) return r;
215
216
  }
216
217
  const e = n.id || n.getAttribute("data-grid-id");
217
218
  if (e)
218
- return Q.get(e);
219
+ return ee.get(e);
219
220
  }
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);
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);
229
230
  }
230
231
  },
231
232
  [t]
232
233
  );
233
234
  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);
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);
241
242
  }
242
- const f = a.parentNode;
243
- f && f.contains(a);
243
+ const g = i.parentNode;
244
+ g && g.contains(i);
244
245
  }
245
246
  }, []), /* @__PURE__ */ E(
246
247
  "tbw-grid-detail",
247
248
  {
248
- ref: s,
249
+ ref: a,
249
250
  showExpandColumn: e ? void 0 : "false",
250
251
  animation: r === !1 ? "false" : r
251
252
  }
252
253
  );
253
254
  }
254
- qe.displayName = "GridDetailPanel";
255
- const X = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new Map();
255
+ _e.displayName = "GridDetailPanel";
256
+ const te = /* @__PURE__ */ new WeakMap(), re = /* @__PURE__ */ new Map();
256
257
  function ze(n) {
257
- const t = X.get(n);
258
+ const t = te.get(n);
258
259
  if (t) return t;
259
260
  const e = n.id;
260
261
  if (e)
261
- return ee.get(e);
262
+ return re.get(e);
262
263
  }
263
264
  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));
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));
267
268
  },
268
- [c, t]
269
+ [l, t]
269
270
  );
270
271
  return w(() => () => {
271
- const f = a.current;
272
- f && (X.delete(f), t && ee.delete(t));
272
+ const g = i.current;
273
+ g && (te.delete(g), t && re.delete(t));
273
274
  }, [t]), /* @__PURE__ */ E(
274
275
  "tbw-grid-tool-panel",
275
276
  {
276
- ref: u,
277
+ ref: f,
277
278
  id: t,
278
279
  title: e,
279
280
  icon: r,
280
281
  tooltip: o,
281
- order: s?.toString()
282
+ order: a?.toString()
282
283
  }
283
284
  );
284
285
  }
@@ -343,11 +344,11 @@ class he {
343
344
  const e = t.getAttribute("field");
344
345
  let r = V.get(t);
345
346
  if (!r && e) {
346
- const c = N.get(e);
347
- c && (c.renderer || c.editor) && (r = c, V.set(t, r));
347
+ const l = N.get(e);
348
+ l && (l.renderer || l.editor) && (r = l, V.set(t, r));
348
349
  }
349
- const o = r?.renderer !== void 0, s = r?.editor !== void 0;
350
- return r !== void 0 && (o || s);
350
+ const o = r?.renderer !== void 0, a = r?.editor !== void 0;
351
+ return r !== void 0 && (o || a);
351
352
  }
352
353
  /**
353
354
  * Creates a view renderer function that renders a React component
@@ -366,26 +367,26 @@ class he {
366
367
  return;
367
368
  const r = /* @__PURE__ */ new WeakMap();
368
369
  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;
370
+ const a = o.cellEl;
371
+ if (a) {
372
+ const f = r.get(a);
373
+ if (f)
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);
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;
382
383
  }
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;
384
+ const l = document.createElement("div");
385
+ l.className = "react-cell-renderer", l.style.display = "contents";
386
+ const i = C(l);
387
+ return R(() => {
388
+ i.render(e(o));
389
+ }), this.mountedViews.push({ root: i, container: l }), l;
389
390
  };
390
391
  }
391
392
  /**
@@ -397,10 +398,10 @@ class he {
397
398
  return e ? (r) => {
398
399
  const o = document.createElement("div");
399
400
  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;
401
+ const a = C(o);
402
+ return R(() => {
403
+ a.render(e(r));
404
+ }), this.editorViews.push({ root: a, container: o }), o;
404
405
  } : () => document.createElement("div");
405
406
  }
406
407
  /**
@@ -408,15 +409,15 @@ class he {
408
409
  * Renders React components for expandable detail rows.
409
410
  */
410
411
  createDetailRenderer(t) {
411
- const e = _e(t);
412
+ const e = je(t);
412
413
  if (e)
413
414
  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;
415
+ const a = document.createElement("div");
416
+ a.className = "react-detail-panel";
417
+ const l = { row: r, rowIndex: o }, i = C(a);
418
+ return R(() => {
419
+ i.render(e(l));
420
+ }), this.mountedViews.push({ root: i, container: a }), a;
420
421
  };
421
422
  }
422
423
  /**
@@ -436,12 +437,12 @@ class he {
436
437
  const e = me(t);
437
438
  if (e)
438
439
  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;
440
+ const a = document.createElement("div");
441
+ a.className = "react-responsive-card";
442
+ const l = { row: r, index: o }, i = C(a);
443
+ return R(() => {
444
+ i.render(e(l));
445
+ }), this.mountedViews.push({ root: i, container: a }), a;
445
446
  };
446
447
  }
447
448
  /**
@@ -454,20 +455,20 @@ class he {
454
455
  return;
455
456
  const r = t.closest("tbw-grid");
456
457
  return (o) => {
457
- const s = {
458
+ const a = {
458
459
  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];
460
+ }, l = C(o);
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];
466
467
  try {
467
- u.unmount();
468
+ f.unmount();
468
469
  } catch {
469
470
  }
470
- this.mountedViews.splice(a, 1);
471
+ this.mountedViews.splice(i, 1);
471
472
  }
472
473
  };
473
474
  };
@@ -515,8 +516,8 @@ class he {
515
516
  return (e) => {
516
517
  const r = document.createElement("span");
517
518
  r.style.display = "contents";
518
- const o = b(r);
519
- return this.mountedViews.push({ root: o, container: r }), v(() => {
519
+ const o = C(r);
520
+ return this.mountedViews.push({ root: o, container: r }), R(() => {
520
521
  o.render(t(e));
521
522
  }), r;
522
523
  };
@@ -529,8 +530,8 @@ class he {
529
530
  return (e) => {
530
531
  const r = document.createElement("span");
531
532
  r.style.display = "contents";
532
- const o = b(r);
533
- return this.editorViews.push({ root: o, container: r }), v(() => {
533
+ const o = C(r);
534
+ return this.editorViews.push({ root: o, container: r }), R(() => {
534
535
  o.render(t(e));
535
536
  }), r;
536
537
  };
@@ -543,9 +544,9 @@ class he {
543
544
  return (e, r) => {
544
545
  const o = document.createElement("div");
545
546
  o.style.display = "contents";
546
- const s = b(o);
547
- this.mountedViews.push({ root: s, container: o }), v(() => {
548
- s.render(t(r));
547
+ const a = C(o);
548
+ this.mountedViews.push({ root: a, container: o }), R(() => {
549
+ a.render(t(r));
549
550
  }), e.appendChild(o);
550
551
  };
551
552
  }
@@ -619,13 +620,13 @@ function Ze(n) {
619
620
  const t = [];
620
621
  for (const [e, r] of Object.entries(n))
621
622
  r === void 0 || r === !1 || t.push(e);
622
- return Ye(t), Se(n);
623
+ return Ye(t), Pe(n);
623
624
  }
624
- let fe = !1, U = null;
625
- function te() {
626
- return fe || (U = new he(), ve.registerAdapter(U), fe = !0), U;
625
+ let fe = !1, Y = null;
626
+ function ne() {
627
+ return fe || (Y = new he(), ve.registerAdapter(Y), fe = !0), Y;
627
628
  }
628
- te();
629
+ ne();
629
630
  function Qe(n) {
630
631
  const e = n.getPluginByName?.("masterDetail");
631
632
  e && typeof e.refreshDetailRenderer == "function" && e.refreshDetailRenderer();
@@ -633,16 +634,16 @@ function Qe(n) {
633
634
  function Xe(n, t) {
634
635
  const e = n;
635
636
  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);
637
+ const a = e.getPluginByName?.("responsive");
638
+ if (a && typeof a.setCardRenderer == "function") {
639
+ const l = t.createResponsiveCardRenderer(n);
640
+ l && a.setCardRenderer(l);
640
641
  }
641
642
  }
642
643
  function et(n) {
643
644
  const t = {};
644
645
  return Ee.forEach(n, (e) => {
645
- if (Pe(e)) {
646
+ if (Se(e)) {
646
647
  if (e.type && e.type.displayName === "GridDetailPanel") {
647
648
  const r = e.props;
648
649
  t.masterDetail = {
@@ -661,27 +662,27 @@ const gt = Ce(function(t, e) {
661
662
  // Core props
662
663
  rows: r,
663
664
  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,
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,
676
677
  // Plugin props
677
- plugins: d,
678
+ plugins: S,
678
679
  // SSR mode
679
- ssr: p,
680
+ ssr: T,
680
681
  // Legacy event handlers
681
- onRowsChange: m,
682
+ onRowsChange: y,
682
683
  // 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 = [
684
+ ...d
685
+ } = t, s = P(null), p = P(null), b = z(ke), H = z(Ne), F = [
685
686
  "selection",
686
687
  "editing",
687
688
  "filtering",
@@ -711,156 +712,156 @@ const gt = Ce(function(t, e) {
711
712
  "pivot",
712
713
  "serverSide",
713
714
  "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];
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];
726
727
  }
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
728
+ return W;
729
+ }, [S, W]), q = G(() => {
730
+ if (!a) return a;
731
+ const c = Ie(a);
732
+ return l ? c.map((u) => ({
733
+ ...l,
734
+ ...u
734
735
  // 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 };
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 };
741
742
  }
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));
743
+ if (O.length > 0 && c) {
744
+ const m = c.plugins || [], j = new Set(m.map((_) => _.name)), J = O.filter((_) => !j.has(_.name));
744
745
  return {
745
- ...i,
746
- ...l,
747
- plugins: [...y, ...$]
746
+ ...c,
747
+ ...u,
748
+ plugins: [...m, ...J]
748
749
  };
749
750
  }
750
- return F.length > 0 && !i ? { ...l, plugins: F } : Object.keys(l).length > 0 ? { ...i, ...l } : i;
751
- }, [o, F, u, f, C, q]);
751
+ return O.length > 0 && !c ? { ...u, plugins: O } : Object.keys(u).length > 0 ? { ...c, ...u } : c;
752
+ }, [o, O, f, g, v, H]);
752
753
  w(() => {
753
- te().setTypeDefaults(ne);
754
- }, [ne]), w(() => {
755
- g.current && (g.current.rows = r);
754
+ ne().setTypeDefaults(b);
755
+ }, [b]), w(() => {
756
+ s.current && (s.current.rows = r);
756
757
  }, [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());
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());
774
775
  });
775
776
  return () => {
776
- y = !0, cancelAnimationFrame(O);
777
+ m = !0, cancelAnimationFrame(j);
777
778
  };
778
779
  }, []), 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);
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);
784
785
  }), () => {
785
- y = !1, A.current && (i.unregisterStyles?.(A.current), A.current = null);
786
+ m = !1, p.current && (c.unregisterStyles?.(p.current), p.current = null);
786
787
  };
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());
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());
793
794
  };
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];
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];
798
799
  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);
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, _);
806
807
  })
807
808
  );
808
809
  return () => {
809
- l.forEach((y) => y());
810
+ u.forEach((m) => m());
810
811
  };
811
812
  }, [ae]), be(
812
813
  e,
813
814
  () => ({
814
815
  get element() {
815
- return g.current;
816
+ return s.current;
816
817
  },
817
818
  async getConfig() {
818
- return g.current?.getConfig?.() ?? {};
819
+ return s.current?.getConfig?.() ?? {};
819
820
  },
820
821
  async ready() {
821
- return g.current?.ready?.();
822
+ return s.current?.ready?.();
822
823
  },
823
824
  async forceLayout() {
824
- return g.current?.forceLayout?.();
825
+ return s.current?.forceLayout?.();
825
826
  },
826
- async toggleGroup(i) {
827
- return g.current?.toggleGroup?.(i);
827
+ async toggleGroup(c) {
828
+ return s.current?.toggleGroup?.(c);
828
829
  },
829
- registerStyles(i, l) {
830
- g.current?.registerStyles?.(i, l);
830
+ registerStyles(c, u) {
831
+ s.current?.registerStyles?.(c, u);
831
832
  },
832
- unregisterStyles(i) {
833
- g.current?.unregisterStyles?.(i);
833
+ unregisterStyles(c) {
834
+ s.current?.unregisterStyles?.(c);
834
835
  },
835
- setRowLoading(i, l) {
836
- g.current?.setRowLoading?.(i, l);
836
+ setRowLoading(c, u) {
837
+ s.current?.setRowLoading?.(c, u);
837
838
  },
838
- setCellLoading(i, l, y) {
839
- g.current?.setCellLoading?.(i, l, y);
839
+ setCellLoading(c, u, m) {
840
+ s.current?.setCellLoading?.(c, u, m);
840
841
  },
841
- isRowLoading(i) {
842
- return g.current?.isRowLoading?.(i) ?? !1;
842
+ isRowLoading(c) {
843
+ return s.current?.isRowLoading?.(c) ?? !1;
843
844
  },
844
- isCellLoading(i, l) {
845
- return g.current?.isCellLoading?.(i, l) ?? !1;
845
+ isCellLoading(c, u) {
846
+ return s.current?.isCellLoading?.(c, u) ?? !1;
846
847
  },
847
848
  clearAllLoading() {
848
- g.current?.clearAllLoading?.();
849
+ s.current?.clearAllLoading?.();
849
850
  }
850
851
  }),
851
852
  []
852
853
  ), /* @__PURE__ */ E(
853
854
  "tbw-grid",
854
855
  {
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);
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);
859
860
  }
860
861
  },
861
- class: L,
862
- style: k,
863
- children: /* @__PURE__ */ E(xe.Provider, { value: g, children: T })
862
+ class: k,
863
+ style: M,
864
+ children: /* @__PURE__ */ E(xe.Provider, { value: s, children: L })
864
865
  }
865
866
  );
866
867
  });
@@ -870,122 +871,170 @@ function pt(n) {
870
871
  header: e,
871
872
  type: r,
872
873
  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));
874
+ 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));
887
888
  },
888
- [P, S, t]
889
- ), p = typeof a == "number" ? `${a}px` : a, m = {
889
+ [x, D, t]
890
+ ), T = typeof i == "number" ? `${i}px` : i, y = {
890
891
  field: t,
891
- ref: d
892
+ ref: S
892
893
  };
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 });
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 });
894
895
  }
895
896
  function mt({ children: n }) {
896
897
  return /* @__PURE__ */ E("tbw-grid-tool-buttons", { children: n });
897
898
  }
898
899
  const yt = ({ icons: n, defaults: t, children: e }) => {
899
900
  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 });
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 });
901
902
  };
902
- function ht() {
903
- const n = D(null), [t, e] = de(!1), [r, o] = de(null);
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]);
904
905
  w(() => {
905
- const d = n.current;
906
- if (!d) return;
907
- let p = !0;
906
+ let d = !0;
908
907
  return (async () => {
909
908
  try {
910
- if (await d.ready?.(), p) {
911
- e(!0);
912
- const h = await d.getConfig?.();
913
- p && h && o(h);
909
+ if (n) {
910
+ const p = document.querySelector(n);
911
+ if (!p) return;
912
+ if (l.current = p, await p.ready?.(), d) {
913
+ r(!0);
914
+ const b = await p.getConfig?.();
915
+ d && b && a(b);
916
+ }
917
+ } else {
918
+ const p = t.current;
919
+ if (!p) return;
920
+ if (await p.ready?.(), d) {
921
+ r(!0);
922
+ const b = await p.getConfig?.();
923
+ d && b && a(b);
924
+ }
914
925
  }
915
926
  } catch {
916
927
  }
917
928
  })(), () => {
918
- p = !1;
929
+ d = !1;
919
930
  };
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");
931
+ }, [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?.();
938
942
  return;
939
943
  }
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)");
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);
951
+ return;
952
+ }
953
+ const p = t.current;
954
+ p && await p.toggleGroup?.(d);
955
+ },
956
+ [i]
957
+ ), x = h(
958
+ (d, s) => {
959
+ const p = i();
960
+ if (p) {
961
+ p.registerStyles?.(d, s);
962
+ return;
963
+ }
964
+ t.current?.registerStyles?.(d, s);
965
+ },
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");
959
981
  return;
960
982
  }
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;
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?.();
967
986
  }
968
- m.exportJson?.({ filename: d ?? "export.json" });
969
- }, []);
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)");
1013
+ return;
1014
+ }
1015
+ p.exportJson?.({ filename: d ?? "export.json" });
1016
+ },
1017
+ [i]
1018
+ );
970
1019
  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,
1020
+ ref: t,
1021
+ element: i(),
1022
+ isReady: e,
1023
+ config: o,
1024
+ getConfig: f,
1025
+ forceLayout: g,
1026
+ toggleGroup: v,
1027
+ registerStyles: x,
1028
+ unregisterStyles: D,
1029
+ getVisibleColumns: A,
981
1030
  // Selection methods
982
- selectAll: P,
983
- clearSelection: S,
984
- getSelectedIndices: G,
985
- getSelectedRows: L,
1031
+ selectAll: k,
1032
+ clearSelection: M,
1033
+ getSelectedIndices: L,
1034
+ getSelectedRows: S,
986
1035
  // Export methods
987
- exportToCsv: k,
988
- exportToJson: T
1036
+ exportToCsv: T,
1037
+ exportToJson: y
989
1038
  };
990
1039
  }
991
1040
  let ge = !1;
@@ -995,17 +1044,17 @@ function wt(n, t, e, r = []) {
995
1044
  Example: <DataGrid onSelectionChange={(e) => ...} />
996
1045
  See migration guide: https://toolbox-web.dev/grid-react/migration`
997
1046
  ));
998
- const o = D(e);
1047
+ const o = P(e);
999
1048
  w(() => {
1000
1049
  o.current = e;
1001
1050
  }, [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);
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);
1006
1055
  });
1007
- return c.addEventListener(t, a), () => {
1008
- c.removeEventListener(t, a);
1056
+ return l.addEventListener(t, i), () => {
1057
+ l.removeEventListener(t, i);
1009
1058
  };
1010
1059
  }, [n, t]);
1011
1060
  }
@@ -1013,13 +1062,13 @@ export {
1013
1062
  gt as DataGrid,
1014
1063
  he as GridAdapter,
1015
1064
  pt as GridColumn,
1016
- qe as GridDetailPanel,
1065
+ _e as GridDetailPanel,
1017
1066
  Ve as GridIconProvider,
1018
1067
  yt as GridProvider,
1019
- Te as GridResponsiveCard,
1068
+ Le as GridResponsiveCard,
1020
1069
  mt as GridToolButtons,
1021
1070
  ut as GridToolPanel,
1022
- Le as GridTypeProvider,
1071
+ Te as GridTypeProvider,
1023
1072
  ft as ReactGridAdapter,
1024
1073
  ht as useGrid,
1025
1074
  wt as useGridEvent,