@toolbox-web/grid-react 0.7.0 → 0.8.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,38 +1,38 @@
1
- import { jsx as V } from "react/jsx-runtime";
2
- import { DataGridElement as ae } from "@toolbox-web/grid";
3
- import { useRef as P, useCallback as y, useEffect as h, createContext as de, useContext as Z, forwardRef as ue, useMemo as D, useImperativeHandle as le, Children as fe, isValidElement as ge, useState as ne } from "react";
4
- import { flushSync as b } from "react-dom";
1
+ import { jsx as I } from "react/jsx-runtime";
2
+ import { DataGridElement as ue } from "@toolbox-web/grid";
3
+ import { useRef as P, useCallback as h, useEffect as w, createContext as fe, useContext as Q, forwardRef as ge, useMemo as D, useImperativeHandle as pe, Children as me, isValidElement as ye, useState as ie } from "react";
4
+ import { flushSync as R } from "react-dom";
5
5
  import { createRoot as S } from "react-dom/client";
6
- import { c as pe } from "./chunks/feature-registry-Y3KvnN54.js";
7
- function me(r) {
6
+ import { c as he } from "./chunks/feature-registry-Y3KvnN54.js";
7
+ function we(r) {
8
8
  return r.charAt(0).toUpperCase() + r.slice(1);
9
9
  }
10
- function oe(r) {
11
- return r.toLowerCase() === "id" ? "ID" : r.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").split(" ").filter(Boolean).map(me).join(" ");
10
+ function se(r) {
11
+ return r.toLowerCase() === "id" ? "ID" : r.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").split(" ").filter(Boolean).map(we).join(" ");
12
12
  }
13
- const ye = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime", "currency"]);
14
- function he(r) {
13
+ const ve = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime", "currency"]);
14
+ function Ce(r) {
15
15
  const t = r.lastIndexOf(":");
16
16
  if (t > 0) {
17
17
  const e = r.slice(t + 1).toLowerCase();
18
- if (ye.has(e)) {
18
+ if (ve.has(e)) {
19
19
  const n = r.slice(0, t);
20
20
  return {
21
21
  field: n,
22
- header: oe(n),
22
+ header: se(n),
23
23
  type: e
24
24
  };
25
25
  }
26
26
  }
27
27
  return {
28
28
  field: r,
29
- header: oe(r)
29
+ header: se(r)
30
30
  };
31
31
  }
32
- function we(r) {
33
- return r.map((t) => typeof t == "string" ? he(t) : t);
32
+ function Re(r) {
33
+ return r.map((t) => typeof t == "string" ? Ce(t) : t);
34
34
  }
35
- const q = {
35
+ const z = {
36
36
  onCellClick: "cell-click",
37
37
  onRowClick: "row-click",
38
38
  onCellActivate: "cell-activate",
@@ -57,202 +57,202 @@ const q = {
57
57
  onExportComplete: "export-complete",
58
58
  onPrintStart: "print-start",
59
59
  onPrintComplete: "print-complete"
60
- }, _ = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new Map();
61
- function ce(r) {
60
+ }, W = /* @__PURE__ */ new WeakMap(), $ = /* @__PURE__ */ new Map();
61
+ function le(r) {
62
62
  const t = r.querySelector("tbw-grid-responsive-card");
63
63
  if (t) {
64
- const n = _.get(t);
64
+ const n = W.get(t);
65
65
  if (n) return n;
66
66
  }
67
67
  const e = r.id || r.getAttribute("data-grid-id");
68
68
  if (e)
69
- return W.get(e);
69
+ return $.get(e);
70
70
  }
71
- function ve(r) {
72
- const { children: t, cardRowHeight: e = "auto" } = r, n = P(null), o = y(
71
+ function be(r) {
72
+ const { children: t, cardRowHeight: e = "auto" } = r, n = P(null), o = h(
73
73
  (i) => {
74
74
  if (n.current = i, !i) return;
75
- _.set(i, t);
76
- const d = i.closest("tbw-grid");
77
- if (d) {
78
- const u = d.id || d.getAttribute("data-grid-id");
79
- u && W.set(u, t);
75
+ W.set(i, t);
76
+ const s = i.closest("tbw-grid");
77
+ if (s) {
78
+ const l = s.id || s.getAttribute("data-grid-id");
79
+ l && $.set(l, t);
80
80
  }
81
81
  },
82
82
  [t]
83
83
  );
84
- h(() => () => {
84
+ w(() => () => {
85
85
  const i = n.current;
86
86
  if (i) {
87
- _.delete(i);
88
- const d = i.closest("tbw-grid");
89
- if (d) {
90
- const u = d.id || d.getAttribute("data-grid-id");
91
- u && W.delete(u);
87
+ W.delete(i);
88
+ const s = i.closest("tbw-grid");
89
+ if (s) {
90
+ const l = s.id || s.getAttribute("data-grid-id");
91
+ l && $.delete(l);
92
92
  }
93
93
  }
94
94
  }, []);
95
- const s = e === "auto" ? "auto" : String(e);
96
- return /* @__PURE__ */ V("tbw-grid-responsive-card", { ref: o, cardRowHeight: s });
95
+ const a = e === "auto" ? "auto" : String(e);
96
+ return /* @__PURE__ */ I("tbw-grid-responsive-card", { ref: o, cardRowHeight: a });
97
97
  }
98
- ve.displayName = "GridResponsiveCard";
99
- const H = de(null), _e = ({ defaults: r, children: t }) => /* @__PURE__ */ V(H.Provider, { value: r, children: t });
100
- function We() {
101
- return Z(H);
98
+ be.displayName = "GridResponsiveCard";
99
+ const H = fe(null), Je = ({ defaults: r, children: t }) => /* @__PURE__ */ I(H.Provider, { value: r, children: t });
100
+ function Ue() {
101
+ return Q(H);
102
102
  }
103
- function $e(r) {
104
- return Z(H)?.[r];
103
+ function Ke(r) {
104
+ return Q(H)?.[r];
105
105
  }
106
- const Ce = H;
107
- function Re(r) {
106
+ const Ee = H;
107
+ function Se(r) {
108
108
  const t = /* @__PURE__ */ new WeakMap();
109
109
  return (e) => {
110
110
  const n = e.cellEl;
111
111
  if (n) {
112
112
  const i = t.get(n);
113
113
  if (i)
114
- return b(() => {
114
+ return R(() => {
115
115
  i.root.render(r(e));
116
116
  }), i.container;
117
117
  }
118
118
  const o = document.createElement("div");
119
119
  o.className = "react-cell-renderer", o.style.display = "contents";
120
- const s = S(o);
121
- return b(() => {
122
- s.render(r(e));
123
- }), n && t.set(n, { root: s, container: o }), o;
120
+ const a = S(o);
121
+ return R(() => {
122
+ a.render(r(e));
123
+ }), n && t.set(n, { root: a, container: o }), o;
124
124
  };
125
125
  }
126
- function be(r) {
126
+ function xe(r) {
127
127
  return (t) => {
128
128
  const e = document.createElement("div");
129
129
  e.className = "react-cell-editor", e.style.display = "contents";
130
130
  const n = S(e);
131
- return b(() => {
131
+ return R(() => {
132
132
  n.render(r(t));
133
133
  }), e;
134
134
  };
135
135
  }
136
- function Ee(r) {
136
+ function De(r) {
137
137
  if (!r) return;
138
138
  if (!r.columns) return r;
139
139
  const t = r.columns.map((e) => {
140
- const { renderer: n, editor: o, ...s } = e, i = { ...s };
141
- return n && (i.renderer = Re(n)), o && (i.editor = be(o)), i;
140
+ const { renderer: n, editor: o, ...a } = e, i = { ...a };
141
+ return n && (i.renderer = Se(n)), o && (i.editor = xe(o)), i;
142
142
  });
143
143
  return {
144
144
  ...r,
145
145
  columns: t
146
146
  };
147
147
  }
148
- const $ = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new Map();
149
- function Se(r) {
148
+ const J = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new Map();
149
+ function Pe(r) {
150
150
  const t = r.querySelector("tbw-grid-detail");
151
151
  if (t) {
152
- const n = $.get(t);
152
+ const n = J.get(t);
153
153
  if (n) return n;
154
154
  }
155
155
  const e = r.id || r.getAttribute("data-grid-id");
156
156
  if (e)
157
- return J.get(e);
157
+ return U.get(e);
158
158
  }
159
- function xe(r) {
160
- const { children: t, showExpandColumn: e = !0, animation: n = "slide" } = r, o = P(null), s = y(
161
- (d) => {
162
- if (o.current = d, !d) return;
163
- $.set(d, t);
164
- const u = d.closest("tbw-grid");
165
- if (u) {
166
- const g = u.id || u.getAttribute("data-grid-id");
167
- g && J.set(g, t);
159
+ function Ge(r) {
160
+ const { children: t, showExpandColumn: e = !0, animation: n = "slide" } = r, o = P(null), a = h(
161
+ (s) => {
162
+ if (o.current = s, !s) return;
163
+ J.set(s, t);
164
+ const l = s.closest("tbw-grid");
165
+ if (l) {
166
+ const m = l.id || l.getAttribute("data-grid-id");
167
+ m && U.set(m, t);
168
168
  }
169
169
  },
170
170
  [t]
171
171
  );
172
- return h(() => () => {
173
- const d = o.current;
174
- if (d) {
175
- $.delete(d);
176
- const u = d.closest("tbw-grid");
177
- if (u) {
178
- const v = u.id || u.getAttribute("data-grid-id");
179
- v && J.delete(v);
172
+ return w(() => () => {
173
+ const s = o.current;
174
+ if (s) {
175
+ J.delete(s);
176
+ const l = s.closest("tbw-grid");
177
+ if (l) {
178
+ const v = l.id || l.getAttribute("data-grid-id");
179
+ v && U.delete(v);
180
180
  }
181
- const g = d.parentNode;
182
- g && g.contains(d);
181
+ const m = s.parentNode;
182
+ m && m.contains(s);
183
183
  }
184
- }, []), /* @__PURE__ */ V(
184
+ }, []), /* @__PURE__ */ I(
185
185
  "tbw-grid-detail",
186
186
  {
187
- ref: s,
187
+ ref: a,
188
188
  showExpandColumn: e ? void 0 : "false",
189
189
  animation: n === !1 ? "false" : n
190
190
  }
191
191
  );
192
192
  }
193
- xe.displayName = "GridDetailPanel";
194
- const U = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new Map();
195
- function De(r) {
196
- const t = U.get(r);
193
+ Ge.displayName = "GridDetailPanel";
194
+ const K = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new Map();
195
+ function Ae(r) {
196
+ const t = K.get(r);
197
197
  if (t) return t;
198
198
  const e = r.id;
199
199
  if (e)
200
- return K.get(e);
200
+ return Y.get(e);
201
201
  }
202
- function Je(r) {
203
- const { id: t, title: e, icon: n, tooltip: o, order: s = 100, children: i } = r, d = P(null), u = y(
204
- (g) => {
205
- d.current = g, g && (U.set(g, i), t && K.set(t, i));
202
+ function Ye(r) {
203
+ const { id: t, title: e, icon: n, tooltip: o, order: a = 100, children: i } = r, s = P(null), l = h(
204
+ (m) => {
205
+ s.current = m, m && (K.set(m, i), t && Y.set(t, i));
206
206
  },
207
207
  [i, t]
208
208
  );
209
- return h(() => () => {
210
- const g = d.current;
211
- g && (U.delete(g), t && K.delete(t));
212
- }, [t]), /* @__PURE__ */ V(
209
+ return w(() => () => {
210
+ const m = s.current;
211
+ m && (K.delete(m), t && Y.delete(t));
212
+ }, [t]), /* @__PURE__ */ I(
213
213
  "tbw-grid-tool-panel",
214
214
  {
215
- ref: u,
215
+ ref: l,
216
216
  id: t,
217
217
  title: e,
218
218
  icon: n,
219
219
  tooltip: o,
220
- order: s?.toString()
220
+ order: a?.toString()
221
221
  }
222
222
  );
223
223
  }
224
- const G = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new Map();
225
- function Pe(r, t) {
224
+ const G = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new Map();
225
+ function Ne(r, t) {
226
226
  const e = r.getAttribute("field"), n = G.get(r) ?? {};
227
227
  if (n.renderer = t, G.set(r, n), e) {
228
- const o = T.get(e) ?? {};
229
- o.renderer = t, T.set(e, o);
228
+ const o = N.get(e) ?? {};
229
+ o.renderer = t, N.set(e, o);
230
230
  }
231
231
  }
232
- function Ge(r, t) {
232
+ function Ie(r, t) {
233
233
  const e = r.getAttribute("field"), n = G.get(r) ?? {};
234
234
  if (n.editor = t, G.set(r, n), e) {
235
- const o = T.get(e) ?? {};
236
- o.editor = t, T.set(e, o);
235
+ const o = N.get(e) ?? {};
236
+ o.editor = t, N.set(e, o);
237
237
  }
238
238
  }
239
- function Ae(r) {
239
+ function Te(r) {
240
240
  let t = G.get(r)?.renderer;
241
241
  if (!t) {
242
242
  const e = r.getAttribute("field");
243
- e && (t = T.get(e)?.renderer);
243
+ e && (t = N.get(e)?.renderer);
244
244
  }
245
245
  return t;
246
246
  }
247
- function Ne(r) {
247
+ function Ve(r) {
248
248
  let t = G.get(r)?.editor;
249
249
  if (!t) {
250
250
  const e = r.getAttribute("field");
251
- e && (t = T.get(e)?.editor);
251
+ e && (t = N.get(e)?.editor);
252
252
  }
253
253
  return t;
254
254
  }
255
- class Ie {
255
+ class ke {
256
256
  mountedViews = [];
257
257
  typeDefaults = null;
258
258
  /**
@@ -272,11 +272,11 @@ class Ie {
272
272
  const e = t.getAttribute("field");
273
273
  let n = G.get(t);
274
274
  if (!n && e) {
275
- const i = T.get(e);
275
+ const i = N.get(e);
276
276
  i && (i.renderer || i.editor) && (n = i, G.set(t, n));
277
277
  }
278
- const o = n?.renderer !== void 0, s = n?.editor !== void 0;
279
- return n !== void 0 && (o || s);
278
+ const o = n?.renderer !== void 0, a = n?.editor !== void 0;
279
+ return n !== void 0 && (o || a);
280
280
  }
281
281
  /**
282
282
  * Creates a view renderer function that renders a React component
@@ -290,31 +290,31 @@ class Ie {
290
290
  * allowing the grid to use its default rendering.
291
291
  */
292
292
  createRenderer(t) {
293
- const e = Ae(t);
293
+ const e = Te(t);
294
294
  if (!e)
295
295
  return;
296
296
  const n = /* @__PURE__ */ new WeakMap();
297
297
  return (o) => {
298
- const s = o.cellEl;
299
- if (s) {
300
- const u = n.get(s);
301
- if (u)
302
- return b(() => {
303
- u.root.render(e(o));
304
- }), u.container;
305
- const g = document.createElement("div");
306
- g.className = "react-cell-renderer", g.style.display = "contents";
307
- const v = S(g);
308
- return b(() => {
298
+ const a = o.cellEl;
299
+ if (a) {
300
+ const l = n.get(a);
301
+ if (l)
302
+ return R(() => {
303
+ l.root.render(e(o));
304
+ }), l.container;
305
+ const m = document.createElement("div");
306
+ m.className = "react-cell-renderer", m.style.display = "contents";
307
+ const v = S(m);
308
+ return R(() => {
309
309
  v.render(e(o));
310
- }), n.set(s, { root: v, container: g, lastRowIndex: o.rowIndex ?? -1 }), this.mountedViews.push({ root: v, container: g }), g;
310
+ }), n.set(a, { root: v, container: m, lastRowIndex: o.rowIndex ?? -1 }), this.mountedViews.push({ root: v, container: m }), m;
311
311
  }
312
312
  const i = document.createElement("div");
313
313
  i.className = "react-cell-renderer", i.style.display = "contents";
314
- const d = S(i);
315
- return b(() => {
316
- d.render(e(o));
317
- }), this.mountedViews.push({ root: d, container: i }), i;
314
+ const s = S(i);
315
+ return R(() => {
316
+ s.render(e(o));
317
+ }), this.mountedViews.push({ root: s, container: i }), i;
318
318
  };
319
319
  }
320
320
  /**
@@ -322,14 +322,14 @@ class Ie {
322
322
  * with commit/cancel callbacks passed as props.
323
323
  */
324
324
  createEditor(t) {
325
- const e = Ne(t);
325
+ const e = Ve(t);
326
326
  return e ? (n) => {
327
327
  const o = document.createElement("div");
328
328
  o.className = "react-cell-editor", o.style.display = "contents";
329
- const s = S(o);
330
- return b(() => {
331
- s.render(e(n));
332
- }), this.mountedViews.push({ root: s, container: o }), o;
329
+ const a = S(o);
330
+ return R(() => {
331
+ a.render(e(n));
332
+ }), this.mountedViews.push({ root: a, container: o }), o;
333
333
  } : () => document.createElement("div");
334
334
  }
335
335
  /**
@@ -337,15 +337,15 @@ class Ie {
337
337
  * Renders React components for expandable detail rows.
338
338
  */
339
339
  createDetailRenderer(t) {
340
- const e = Se(t);
340
+ const e = Pe(t);
341
341
  if (e)
342
342
  return (n, o) => {
343
- const s = document.createElement("div");
344
- s.className = "react-detail-panel";
345
- const i = { row: n, rowIndex: o }, d = S(s);
346
- return b(() => {
347
- d.render(e(i));
348
- }), this.mountedViews.push({ root: d, container: s }), s;
343
+ const a = document.createElement("div");
344
+ a.className = "react-detail-panel";
345
+ const i = { row: n, rowIndex: o }, s = S(a);
346
+ return R(() => {
347
+ s.render(e(i));
348
+ }), this.mountedViews.push({ root: s, container: a }), a;
349
349
  };
350
350
  }
351
351
  /**
@@ -362,15 +362,15 @@ class Ie {
362
362
  * Renders React components for card layout in responsive mode.
363
363
  */
364
364
  createResponsiveCardRenderer(t) {
365
- const e = ce(t);
365
+ const e = le(t);
366
366
  if (e)
367
367
  return (n, o) => {
368
- const s = document.createElement("div");
369
- s.className = "react-responsive-card";
370
- const i = { row: n, index: o }, d = S(s);
371
- return b(() => {
372
- d.render(e(i));
373
- }), this.mountedViews.push({ root: d, container: s }), s;
368
+ const a = document.createElement("div");
369
+ a.className = "react-responsive-card";
370
+ const i = { row: n, index: o }, s = S(a);
371
+ return R(() => {
372
+ s.render(e(i));
373
+ }), this.mountedViews.push({ root: s, container: a }), a;
374
374
  };
375
375
  }
376
376
  /**
@@ -378,25 +378,25 @@ class Ie {
378
378
  * Renders React components into tool panel containers.
379
379
  */
380
380
  createToolPanelRenderer(t) {
381
- const e = De(t);
381
+ const e = Ae(t);
382
382
  if (!e)
383
383
  return;
384
384
  const n = t.closest("tbw-grid");
385
385
  return (o) => {
386
- const s = {
386
+ const a = {
387
387
  grid: n ?? o
388
388
  }, i = S(o);
389
- return b(() => {
390
- i.render(e(s));
389
+ return R(() => {
390
+ i.render(e(a));
391
391
  }), this.mountedViews.push({ root: i, container: o }), () => {
392
- const d = this.mountedViews.findIndex((u) => u.container === o);
393
- if (d !== -1) {
394
- const { root: u } = this.mountedViews[d];
392
+ const s = this.mountedViews.findIndex((l) => l.container === o);
393
+ if (s !== -1) {
394
+ const { root: l } = this.mountedViews[s];
395
395
  try {
396
- u.unmount();
396
+ l.unmount();
397
397
  } catch {
398
398
  }
399
- this.mountedViews.splice(d, 1);
399
+ this.mountedViews.splice(s, 1);
400
400
  }
401
401
  };
402
402
  };
@@ -445,7 +445,7 @@ class Ie {
445
445
  const n = document.createElement("span");
446
446
  n.style.display = "contents";
447
447
  const o = S(n);
448
- return this.mountedViews.push({ root: o, container: n }), b(() => {
448
+ return this.mountedViews.push({ root: o, container: n }), R(() => {
449
449
  o.render(t(e));
450
450
  }), n;
451
451
  };
@@ -459,7 +459,7 @@ class Ie {
459
459
  const n = document.createElement("span");
460
460
  n.style.display = "contents";
461
461
  const o = S(n);
462
- return this.mountedViews.push({ root: o, container: n }), b(() => {
462
+ return this.mountedViews.push({ root: o, container: n }), R(() => {
463
463
  o.render(t(e));
464
464
  }), n;
465
465
  };
@@ -491,14 +491,14 @@ class Ie {
491
491
  }
492
492
  }
493
493
  }
494
- const Te = {
494
+ const Fe = {
495
495
  undoRedo: ["editing"],
496
496
  clipboard: ["selection"]
497
497
  };
498
- function Ve(r) {
498
+ function Me(r) {
499
499
  const t = new Set(r);
500
500
  for (const e of r) {
501
- const n = Te[e];
501
+ const n = Fe[e];
502
502
  if (n)
503
503
  for (const o of n)
504
504
  t.has(o) || console.warn(
@@ -506,50 +506,51 @@ function Ve(r) {
506
506
  );
507
507
  }
508
508
  }
509
- function ke(r) {
510
- const t = [], e = [];
511
- for (const [s, i] of Object.entries(r)) {
512
- if (i === void 0 || i === !1) continue;
513
- const d = s;
514
- e.push(d);
509
+ function Le(r) {
510
+ const t = [], e = [], n = { ...r };
511
+ n.multiSort !== void 0 ? delete n.sorting : n.sorting !== void 0 && (n.multiSort = n.sorting, delete n.sorting);
512
+ for (const [i, s] of Object.entries(n)) {
513
+ if (s === void 0 || s === !1) continue;
514
+ const l = i;
515
+ e.push(l);
515
516
  }
516
- Ve(e);
517
- const n = [
517
+ Me(e);
518
+ const o = [
518
519
  "selection",
519
520
  "editing",
520
521
  // Then everything else in the order they were specified
521
- ...e.filter((s) => s !== "selection" && s !== "editing")
522
- ], o = [...new Set(n)].filter((s) => e.includes(s));
523
- for (const s of o) {
524
- const i = r[s];
525
- if (i === void 0 || i === !1) continue;
526
- const d = pe(s, i);
527
- d && t.push(d);
522
+ ...e.filter((i) => i !== "selection" && i !== "editing")
523
+ ], a = [...new Set(o)].filter((i) => e.includes(i));
524
+ for (const i of a) {
525
+ const s = r[i];
526
+ if (s === void 0 || s === !1) continue;
527
+ const l = he(i, s);
528
+ l && t.push(l);
528
529
  }
529
530
  return t;
530
531
  }
531
- let ie = !1, z = null;
532
- function Y() {
533
- return ie || (z = new Ie(), ae.registerAdapter(z), ie = !0), z;
532
+ let ce = !1, _ = null;
533
+ function Z() {
534
+ return ce || (_ = new ke(), ue.registerAdapter(_), ce = !0), _;
534
535
  }
535
- Y();
536
- function Fe(r) {
536
+ Z();
537
+ function Oe(r) {
537
538
  const e = r.getPluginByName?.("masterDetail");
538
539
  e && typeof e.refreshDetailRenderer == "function" && e.refreshDetailRenderer();
539
540
  }
540
- function Me(r, t) {
541
+ function Be(r, t) {
541
542
  const e = r;
542
- if (!r.querySelector("tbw-grid-responsive-card") || !ce(r)) return;
543
- const s = e.getPluginByName?.("responsive");
544
- if (s && typeof s.setCardRenderer == "function") {
543
+ if (!r.querySelector("tbw-grid-responsive-card") || !le(r)) return;
544
+ const a = e.getPluginByName?.("responsive");
545
+ if (a && typeof a.setCardRenderer == "function") {
545
546
  const i = t.createResponsiveCardRenderer(r);
546
- i && s.setCardRenderer(i);
547
+ i && a.setCardRenderer(i);
547
548
  }
548
549
  }
549
- function Le(r) {
550
+ function je(r) {
550
551
  const t = {};
551
- return fe.forEach(r, (e) => {
552
- if (ge(e)) {
552
+ return me.forEach(r, (e) => {
553
+ if (ye(e)) {
553
554
  if (e.type && e.type.displayName === "GridDetailPanel") {
554
555
  const n = e.props;
555
556
  t.masterDetail = {
@@ -563,32 +564,37 @@ function Le(r) {
563
564
  }
564
565
  }), t;
565
566
  }
566
- const Ue = ue(function(t, e) {
567
+ const Ze = ge(function(t, e) {
567
568
  const {
568
569
  // Core props
569
570
  rows: n,
570
571
  gridConfig: o,
571
- columns: s,
572
+ columns: a,
572
573
  columnDefaults: i,
573
- fitMode: d,
574
- editOn: u,
575
- customStyles: g,
576
- className: v,
577
- style: A,
578
- children: x,
574
+ fitMode: s,
575
+ sortable: l,
576
+ filterable: m,
577
+ selectable: v,
578
+ editOn: x,
579
+ customStyles: b,
580
+ className: M,
581
+ style: T,
582
+ children: A,
579
583
  // Plugin props
580
584
  plugins: E,
581
585
  // SSR mode
582
- ssr: N,
586
+ ssr: f,
583
587
  // Legacy event handlers
584
- onRowsChange: I,
588
+ onRowsChange: p,
585
589
  // Feature props and event props are in ...rest
586
- ...C
587
- } = t, c = P(null), l = P(null), p = Z(Ce), w = [
590
+ ...g
591
+ } = t, u = P(null), V = P(null), k = Q(Ee), X = [
588
592
  "selection",
589
593
  "editing",
590
594
  "filtering",
595
+ "multiSort",
591
596
  "sorting",
597
+ // deprecated alias for multiSort
592
598
  "clipboard",
593
599
  "contextMenu",
594
600
  "reorder",
@@ -607,298 +613,299 @@ const Ue = ue(function(t, e) {
607
613
  "print",
608
614
  "pivot",
609
615
  "serverSide"
610
- ], O = D(() => w.map((a) => {
611
- const f = C[a];
612
- return f !== void 0 ? `${a}:${JSON.stringify(f)}` : "";
613
- }).filter(Boolean).join("|"), [C]), k = D(() => {
614
- const a = {};
615
- for (const f of w)
616
- f in C && C[f] !== void 0 && (a[f] = C[f]);
617
- return a;
618
- }, [O]), Q = D(() => Le(x), [x]), X = D(() => ({ ...Q, ...k }), [k, Q]), j = D(() => E || N ? [] : ke(X), [X, E, N]), M = D(() => {
616
+ ], de = D(() => X.map((c) => {
617
+ const d = g[c];
618
+ return d !== void 0 ? `${c}:${JSON.stringify(d)}` : "";
619
+ }).filter(Boolean).join("|"), [g]), ee = D(() => {
620
+ const c = {};
621
+ for (const d of X)
622
+ d in g && g[d] !== void 0 && (c[d] = g[d]);
623
+ return c;
624
+ }, [de]), te = D(() => je(A), [A]), re = D(() => ({ ...te, ...ee }), [ee, te]), q = D(() => E || f ? [] : Le(re), [re, E, f]), L = D(() => {
619
625
  if (E) {
620
- const a = new Set(E.map((m) => m.name)), f = j.filter((m) => !a.has(m.name));
621
- return [...E, ...f];
626
+ const c = new Set(E.map((y) => y.name)), d = q.filter((y) => !c.has(y.name));
627
+ return [...E, ...d];
622
628
  }
623
- return j;
624
- }, [E, j]), L = D(() => {
625
- if (!s) return s;
626
- const a = we(s);
627
- return i ? a.map((f) => ({
629
+ return q;
630
+ }, [E, q]), O = D(() => {
631
+ if (!a) return a;
632
+ const c = Re(a);
633
+ return i ? c.map((d) => ({
628
634
  ...i,
629
- ...f
635
+ ...d
630
636
  // Individual column props override defaults
631
- })) : a;
632
- }, [s, i]), B = D(() => {
633
- const a = Ee(o);
634
- if (M.length > 0 && a) {
635
- const f = a.plugins || [], m = new Set(f.map((F) => F.name)), R = M.filter((F) => !m.has(F.name));
637
+ })) : c;
638
+ }, [a, i]), B = D(() => {
639
+ const c = De(o), d = {};
640
+ if (l !== void 0 && (d.sortable = l), m !== void 0 && (d.filterable = m), v !== void 0 && (d.selectable = v), L.length > 0 && c) {
641
+ const y = c.plugins || [], C = new Set(y.map((F) => F.name)), j = L.filter((F) => !C.has(F.name));
636
642
  return {
637
- ...a,
638
- plugins: [...f, ...R]
643
+ ...c,
644
+ ...d,
645
+ plugins: [...y, ...j]
639
646
  };
640
647
  }
641
- return M.length > 0 && !a ? { plugins: M } : a;
642
- }, [o, M]);
643
- h(() => {
644
- Y().setTypeDefaults(p);
645
- }, [p]), h(() => {
646
- c.current && (c.current.rows = n);
647
- }, [n]), h(() => {
648
- c.current && B && (c.current.gridConfig = B);
649
- }, [B]), h(() => {
650
- c.current && L && (c.current.columns = L);
651
- }, [L]), h(() => {
652
- c.current && d !== void 0 && (c.current.fitMode = d);
653
- }, [d]), h(() => {
654
- c.current && u !== void 0 && (c.current.editOn = u);
655
- }, [u]), h(() => {
656
- const a = c.current;
657
- if (!a) return;
658
- const f = Y();
659
- a.__frameworkAdapter = f, Fe(a), Me(a, f);
660
- let m = !1;
661
- const R = requestAnimationFrame(() => {
662
- m || (typeof a.refreshColumns == "function" && a.refreshColumns(), typeof a.refreshShellHeader == "function" && a.refreshShellHeader());
648
+ return L.length > 0 && !c ? { ...d, plugins: L } : Object.keys(d).length > 0 ? { ...c, ...d } : c;
649
+ }, [o, L, l, m, v]);
650
+ w(() => {
651
+ Z().setTypeDefaults(k);
652
+ }, [k]), w(() => {
653
+ u.current && (u.current.rows = n);
654
+ }, [n]), w(() => {
655
+ u.current && B && (u.current.gridConfig = B);
656
+ }, [B]), w(() => {
657
+ u.current && O && (u.current.columns = O);
658
+ }, [O]), w(() => {
659
+ u.current && s !== void 0 && (u.current.fitMode = s);
660
+ }, [s]), w(() => {
661
+ u.current && x !== void 0 && (u.current.editOn = x);
662
+ }, [x]), w(() => {
663
+ const c = u.current;
664
+ if (!c) return;
665
+ const d = Z();
666
+ c.__frameworkAdapter = d, Oe(c), Be(c, d);
667
+ let y = !1;
668
+ const C = requestAnimationFrame(() => {
669
+ y || (typeof c.refreshColumns == "function" && c.refreshColumns(), typeof c.refreshShellHeader == "function" && c.refreshShellHeader());
663
670
  });
664
671
  return () => {
665
- m = !0, cancelAnimationFrame(R);
672
+ y = !0, cancelAnimationFrame(C);
666
673
  };
667
- }, []), h(() => {
668
- if (!c.current || !g) return;
669
- const a = c.current, f = "react-custom-styles";
670
- let m = !0;
671
- return a.ready?.().then(() => {
672
- m && g && (a.registerStyles?.(f, g), l.current = f);
674
+ }, []), w(() => {
675
+ if (!u.current || !b) return;
676
+ const c = u.current, d = "react-custom-styles";
677
+ let y = !0;
678
+ return c.ready?.().then(() => {
679
+ y && b && (c.registerStyles?.(d, b), V.current = d);
673
680
  }), () => {
674
- m = !1, l.current && (a.unregisterStyles?.(l.current), l.current = null);
681
+ y = !1, V.current && (c.unregisterStyles?.(V.current), V.current = null);
675
682
  };
676
- }, [g]), h(() => {
677
- const a = c.current;
678
- if (!a) return;
679
- const f = [];
680
- if (I) {
681
- const m = ((R) => I(R.detail.rows));
682
- a.addEventListener("rows-change", m), f.push(["rows-change", m]);
683
+ }, [b]), w(() => {
684
+ const c = u.current;
685
+ if (!c) return;
686
+ const d = [];
687
+ if (p) {
688
+ const y = ((C) => p(C.detail.rows));
689
+ c.addEventListener("rows-change", y), d.push(["rows-change", y]);
683
690
  }
684
691
  return () => {
685
- f.forEach(([m, R]) => {
686
- a.removeEventListener(m, R);
692
+ d.forEach(([y, C]) => {
693
+ c.removeEventListener(y, C);
687
694
  });
688
695
  };
689
- }, [I]);
690
- const ee = D(() => Object.keys(q).filter((a) => typeof C[a] == "function").sort().join("|"), [C]), te = P({});
691
- for (const a of Object.keys(q))
692
- te.current[a] = C[a];
693
- return h(() => {
694
- const a = c.current;
695
- if (!a) return;
696
- const f = [];
697
- for (const [m, R] of Object.entries(q))
698
- if (ee.includes(m)) {
699
- const F = ((re) => {
700
- te.current[m]?.(re.detail, re);
696
+ }, [p]);
697
+ const ne = D(() => Object.keys(z).filter((c) => typeof g[c] == "function").sort().join("|"), [g]), oe = P({});
698
+ for (const c of Object.keys(z))
699
+ oe.current[c] = g[c];
700
+ return w(() => {
701
+ const c = u.current;
702
+ if (!c) return;
703
+ const d = [];
704
+ for (const [y, C] of Object.entries(z))
705
+ if (ne.includes(y)) {
706
+ const j = ((F) => {
707
+ oe.current[y]?.(F.detail, F);
701
708
  });
702
- a.addEventListener(R, F), f.push([R, F]);
709
+ c.addEventListener(C, j), d.push([C, j]);
703
710
  }
704
711
  return () => {
705
- f.forEach(([m, R]) => {
706
- a.removeEventListener(m, R);
712
+ d.forEach(([y, C]) => {
713
+ c.removeEventListener(y, C);
707
714
  });
708
715
  };
709
- }, [ee]), le(
716
+ }, [ne]), pe(
710
717
  e,
711
718
  () => ({
712
719
  get element() {
713
- return c.current;
720
+ return u.current;
714
721
  },
715
722
  async getConfig() {
716
- return c.current?.getConfig?.() ?? {};
723
+ return u.current?.getConfig?.() ?? {};
717
724
  },
718
725
  async ready() {
719
- return c.current?.ready?.();
726
+ return u.current?.ready?.();
720
727
  },
721
728
  async forceLayout() {
722
- return c.current?.forceLayout?.();
729
+ return u.current?.forceLayout?.();
723
730
  },
724
- async toggleGroup(a) {
725
- return c.current?.toggleGroup?.(a);
731
+ async toggleGroup(c) {
732
+ return u.current?.toggleGroup?.(c);
726
733
  },
727
- registerStyles(a, f) {
728
- c.current?.registerStyles?.(a, f);
734
+ registerStyles(c, d) {
735
+ u.current?.registerStyles?.(c, d);
729
736
  },
730
- unregisterStyles(a) {
731
- c.current?.unregisterStyles?.(a);
737
+ unregisterStyles(c) {
738
+ u.current?.unregisterStyles?.(c);
732
739
  }
733
740
  }),
734
741
  []
735
- ), /* @__PURE__ */ V(
742
+ ), /* @__PURE__ */ I(
736
743
  "tbw-grid",
737
744
  {
738
- ref: (a) => {
739
- if (c.current = a, a) {
740
- const f = a;
741
- B && (f.gridConfig = B), n && (f.rows = n), L && (f.columns = L);
745
+ ref: (c) => {
746
+ if (u.current = c, c) {
747
+ const d = c;
748
+ B && (d.gridConfig = B), n && (d.rows = n), O && (d.columns = O);
742
749
  }
743
750
  },
744
- class: v,
745
- style: A,
746
- children: x
751
+ class: M,
752
+ style: T,
753
+ children: A
747
754
  }
748
755
  );
749
756
  });
750
- function Ke(r) {
757
+ function Qe(r) {
751
758
  const {
752
759
  field: t,
753
760
  header: e,
754
761
  type: n,
755
762
  editable: o,
756
- sortable: s,
763
+ sortable: a,
757
764
  resizable: i,
758
- width: d,
759
- minWidth: u,
760
- hidden: g,
765
+ width: s,
766
+ minWidth: l,
767
+ hidden: m,
761
768
  lockVisible: v,
762
- children: A,
763
- editor: x,
764
- options: E,
765
- multi: N,
766
- format: I
767
- } = r, C = P(null), c = y(
768
- (w) => {
769
- C.current = w, w && (A && Pe(w, A), x && Ge(w, x));
769
+ children: x,
770
+ editor: b,
771
+ options: M,
772
+ multi: T,
773
+ format: A
774
+ } = r, E = P(null), f = h(
775
+ (u) => {
776
+ E.current = u, u && (x && Ne(u, x), b && Ie(u, b));
770
777
  },
771
- [A, x, t]
772
- ), l = typeof d == "number" ? `${d}px` : d, p = {
778
+ [x, b, t]
779
+ ), p = typeof s == "number" ? `${s}px` : s, g = {
773
780
  field: t,
774
- ref: c
781
+ ref: f
775
782
  };
776
- return e !== void 0 && (p.header = e), n !== void 0 && (p.type = n), o !== void 0 && (p.editable = o), s !== void 0 && (p.sortable = s), i !== void 0 && (p.resizable = i), l !== void 0 && (p.width = l), u !== void 0 && (p["min-width"] = u), g !== void 0 && (p.hidden = g), v !== void 0 && (p["lock-visible"] = v), N !== void 0 && (p.multi = N), I && (p["data-has-format"] = "true"), E && (p["data-has-options"] = "true"), /* @__PURE__ */ V("tbw-grid-column", { ...p });
783
+ return e !== void 0 && (g.header = e), n !== void 0 && (g.type = n), o !== void 0 && (g.editable = o), a !== void 0 && (g.sortable = a), i !== void 0 && (g.resizable = i), p !== void 0 && (g.width = p), l !== void 0 && (g["min-width"] = l), m !== void 0 && (g.hidden = m), v !== void 0 && (g["lock-visible"] = v), T !== void 0 && (g.multi = T), A && (g["data-has-format"] = "true"), M && (g["data-has-options"] = "true"), /* @__PURE__ */ I("tbw-grid-column", { ...g });
777
784
  }
778
- function Ye({ children: r }) {
779
- return /* @__PURE__ */ V("tbw-grid-tool-buttons", { children: r });
785
+ function Xe({ children: r }) {
786
+ return /* @__PURE__ */ I("tbw-grid-tool-buttons", { children: r });
780
787
  }
781
- function Ze() {
782
- const r = P(null), [t, e] = ne(!1), [n, o] = ne(null);
783
- h(() => {
784
- const c = r.current;
785
- if (!c) return;
786
- let l = !0;
788
+ function et() {
789
+ const r = P(null), [t, e] = ie(!1), [n, o] = ie(null);
790
+ w(() => {
791
+ const f = r.current;
792
+ if (!f) return;
793
+ let p = !0;
787
794
  return (async () => {
788
795
  try {
789
- if (await c.ready?.(), l) {
796
+ if (await f.ready?.(), p) {
790
797
  e(!0);
791
- const w = await c.getConfig?.();
792
- l && w && o(w);
798
+ const u = await f.getConfig?.();
799
+ p && u && o(u);
793
800
  }
794
801
  } catch {
795
802
  }
796
803
  })(), () => {
797
- l = !1;
804
+ p = !1;
798
805
  };
799
806
  }, []);
800
- const s = y(async () => {
801
- const c = r.current;
802
- return c ? await c.getConfig?.() ?? null : null;
803
- }, []), i = y(async () => {
804
- const c = r.current;
805
- c && await c.forceLayout?.();
806
- }, []), d = y(async (c) => {
807
- const l = r.current;
808
- l && await l.toggleGroup?.(c);
809
- }, []), u = y((c, l) => {
810
- r.current?.registerStyles?.(c, l);
811
- }, []), g = y((c) => {
812
- r.current?.unregisterStyles?.(c);
813
- }, []), v = y(() => n?.columns ? n.columns.filter((c) => !c.hidden) : [], [n]), A = y(() => {
814
- const c = r.current?.element, l = c?.getPluginByName?.("selection");
815
- if (!l) {
807
+ const a = h(async () => {
808
+ const f = r.current;
809
+ return f ? await f.getConfig?.() ?? null : null;
810
+ }, []), i = h(async () => {
811
+ const f = r.current;
812
+ f && await f.forceLayout?.();
813
+ }, []), s = h(async (f) => {
814
+ const p = r.current;
815
+ p && await p.toggleGroup?.(f);
816
+ }, []), l = h((f, p) => {
817
+ r.current?.registerStyles?.(f, p);
818
+ }, []), m = h((f) => {
819
+ r.current?.unregisterStyles?.(f);
820
+ }, []), v = h(() => n?.columns ? n.columns.filter((f) => !f.hidden) : [], [n]), x = h(() => {
821
+ const f = r.current?.element, p = f?.getPluginByName?.("selection");
822
+ if (!p) {
816
823
  console.warn("[useGrid] selectAll requires SelectionPlugin");
817
824
  return;
818
825
  }
819
- if (l.config?.mode === "row") {
820
- const p = c?.rows ?? [], w = new Set(p.map((O, k) => k));
821
- l.selected = w, l.requestAfterRender?.();
826
+ if (p.config?.mode === "row") {
827
+ const g = f?.rows ?? [], u = new Set(g.map((V, k) => k));
828
+ p.selected = u, p.requestAfterRender?.();
822
829
  }
823
- }, []), x = y(() => {
824
- const l = r.current?.element?.getPluginByName?.("selection");
825
- l && l.clearSelection?.();
826
- }, []), E = y(() => {
827
- const l = r.current?.element?.getPluginByName?.("selection");
828
- return l ? new Set(l.selected ?? []) : /* @__PURE__ */ new Set();
829
- }, []), N = y(() => {
830
- const c = r.current?.element, l = c?.getPluginByName?.("selection");
831
- if (!l) return [];
832
- const p = c?.rows ?? [], w = l.selected ?? /* @__PURE__ */ new Set();
833
- return p.filter((O, k) => w.has(k));
834
- }, []), I = y((c) => {
835
- const p = r.current?.element?.getPluginByName?.("export");
836
- if (!p) {
830
+ }, []), b = h(() => {
831
+ const p = r.current?.element?.getPluginByName?.("selection");
832
+ p && p.clearSelection?.();
833
+ }, []), M = h(() => {
834
+ const p = r.current?.element?.getPluginByName?.("selection");
835
+ return p ? new Set(p.selected ?? []) : /* @__PURE__ */ new Set();
836
+ }, []), T = h(() => {
837
+ const f = r.current?.element, p = f?.getPluginByName?.("selection");
838
+ if (!p) return [];
839
+ const g = f?.rows ?? [], u = p.selected ?? /* @__PURE__ */ new Set();
840
+ return g.filter((V, k) => u.has(k));
841
+ }, []), A = h((f) => {
842
+ const g = r.current?.element?.getPluginByName?.("export");
843
+ if (!g) {
837
844
  console.warn("[useGrid] exportToCsv requires ExportPlugin (use export prop)");
838
845
  return;
839
846
  }
840
- p.exportCsv?.({ filename: c ?? "export.csv" });
841
- }, []), C = y((c) => {
842
- const p = r.current?.element?.getPluginByName?.("export");
843
- if (!p) {
847
+ g.exportCsv?.({ filename: f ?? "export.csv" });
848
+ }, []), E = h((f) => {
849
+ const g = r.current?.element?.getPluginByName?.("export");
850
+ if (!g) {
844
851
  console.warn("[useGrid] exportToJson requires ExportPlugin (use export prop)");
845
852
  return;
846
853
  }
847
- p.exportJson?.({ filename: c ?? "export.json" });
854
+ g.exportJson?.({ filename: f ?? "export.json" });
848
855
  }, []);
849
856
  return {
850
857
  ref: r,
851
858
  element: r.current?.element ?? null,
852
859
  isReady: t,
853
860
  config: n,
854
- getConfig: s,
861
+ getConfig: a,
855
862
  forceLayout: i,
856
- toggleGroup: d,
857
- registerStyles: u,
858
- unregisterStyles: g,
863
+ toggleGroup: s,
864
+ registerStyles: l,
865
+ unregisterStyles: m,
859
866
  getVisibleColumns: v,
860
867
  // Selection methods
861
- selectAll: A,
862
- clearSelection: x,
863
- getSelectedIndices: E,
864
- getSelectedRows: N,
868
+ selectAll: x,
869
+ clearSelection: b,
870
+ getSelectedIndices: M,
871
+ getSelectedRows: T,
865
872
  // Export methods
866
- exportToCsv: I,
867
- exportToJson: C
873
+ exportToCsv: A,
874
+ exportToJson: E
868
875
  };
869
876
  }
870
- let se = !1;
871
- function Qe(r, t, e, n = []) {
872
- !se && typeof window < "u" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes(".local")) && (se = !0, console.warn(
877
+ let ae = !1;
878
+ function tt(r, t, e, n = []) {
879
+ !ae && typeof window < "u" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes(".local")) && (ae = !0, console.warn(
873
880
  `[useGridEvent] Deprecated: Use event props directly on DataGrid instead.
874
881
  Example: <DataGrid onSelectionChange={(e) => ...} />
875
882
  See migration guide: https://toolbox-web.dev/grid-react/migration`
876
883
  ));
877
884
  const o = P(e);
878
- h(() => {
885
+ w(() => {
879
886
  o.current = e;
880
- }, [e, ...n]), h(() => {
881
- const s = r.current, i = s && "element" in s ? s.element : s;
887
+ }, [e, ...n]), w(() => {
888
+ const a = r.current, i = a && "element" in a ? a.element : a;
882
889
  if (!i) return;
883
- const d = ((u) => {
884
- o.current(u);
890
+ const s = ((l) => {
891
+ o.current(l);
885
892
  });
886
- return i.addEventListener(t, d), () => {
887
- i.removeEventListener(t, d);
893
+ return i.addEventListener(t, s), () => {
894
+ i.removeEventListener(t, s);
888
895
  };
889
896
  }, [r, t]);
890
897
  }
891
898
  export {
892
- Ue as DataGrid,
893
- Ke as GridColumn,
894
- xe as GridDetailPanel,
895
- ve as GridResponsiveCard,
896
- Ye as GridToolButtons,
897
- Je as GridToolPanel,
898
- _e as GridTypeProvider,
899
- Ie as ReactGridAdapter,
900
- Ze as useGrid,
901
- Qe as useGridEvent,
902
- We as useGridTypeDefaults,
903
- $e as useTypeDefault
899
+ Ze as DataGrid,
900
+ Qe as GridColumn,
901
+ Ge as GridDetailPanel,
902
+ be as GridResponsiveCard,
903
+ Xe as GridToolButtons,
904
+ Ye as GridToolPanel,
905
+ Je as GridTypeProvider,
906
+ ke as ReactGridAdapter,
907
+ et as useGrid,
908
+ tt as useGridEvent,
909
+ Ue as useGridTypeDefaults,
910
+ Ke as useTypeDefault
904
911
  };