@toolbox-web/grid-react 1.1.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { jsx as b, Fragment as ne, jsxs as Pe } from "react/jsx-runtime";
2
2
  import { DataGridElement as be } from "@toolbox-web/grid";
3
- import { createContext as me, useContext as O, useRef as E, useCallback as S, useEffect as P, forwardRef as he, useReducer as Ee, useImperativeHandle as ve, useMemo as D, useLayoutEffect as ke, Children as Se, isValidElement as De, useState as fe } from "react";
3
+ import { createContext as ye, useContext as O, useRef as k, useCallback as E, useEffect as P, forwardRef as he, useReducer as Ee, useImperativeHandle as Re, useMemo as S, useLayoutEffect as ke, Children as Se, isValidElement as De, useState as fe } from "react";
4
4
  import { a as w, r as H, s as ge } from "./chunks/portal-bridge-DZ4yQkmm.js";
5
- import { flushSync as W, createPortal as Ge } from "react-dom";
5
+ import { flushSync as V, createPortal as Ge } from "react-dom";
6
6
  import { createPluginsFromFeatures as Ae } from "@toolbox-web/grid/features/registry";
7
7
  import { G as Te } from "./chunks/grid-element-context-BU3WvNtM.js";
8
8
  function xe(n) {
@@ -33,7 +33,7 @@ function Ne(n) {
33
33
  function Fe(n) {
34
34
  return n.map((e) => typeof e == "string" ? Ne(e) : e);
35
35
  }
36
- const B = {
36
+ const W = {
37
37
  onCellClick: "cell-click",
38
38
  onRowClick: "row-click",
39
39
  onCellActivate: "cell-activate",
@@ -49,6 +49,10 @@ const B = {
49
49
  onColumnStateChange: "column-state-change",
50
50
  onSelectionChange: "selection-change",
51
51
  onRowMove: "row-move",
52
+ onRowDragStart: "row-drag-start",
53
+ onRowDragEnd: "row-drag-end",
54
+ onRowDrop: "row-drop",
55
+ onRowTransfer: "row-transfer",
52
56
  onGroupToggle: "group-toggle",
53
57
  onTreeExpand: "tree-expand",
54
58
  onDetailExpand: "detail-expand",
@@ -60,12 +64,12 @@ const B = {
60
64
  onPrintStart: "print-start",
61
65
  onPrintComplete: "print-complete",
62
66
  onTbwScroll: "tbw-scroll"
63
- }, oe = me(null), Ie = ({ icons: n, children: e }) => /* @__PURE__ */ b(oe.Provider, { value: n, children: e });
67
+ }, oe = ye(null), Ie = ({ icons: n, children: e }) => /* @__PURE__ */ b(oe.Provider, { value: n, children: e });
64
68
  function pt() {
65
69
  return O(oe);
66
70
  }
67
71
  const Le = oe, Y = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new Map();
68
- function Ce(n) {
72
+ function ve(n) {
69
73
  const e = n.querySelector("tbw-grid-responsive-card");
70
74
  if (e) {
71
75
  const r = Y.get(e);
@@ -76,14 +80,14 @@ function Ce(n) {
76
80
  return Z.get(t);
77
81
  }
78
82
  function Me(n) {
79
- const { children: e, cardRowHeight: t = "auto" } = n, r = E(null), o = S(
83
+ const { children: e, cardRowHeight: t = "auto" } = n, r = k(null), o = E(
80
84
  (c) => {
81
85
  if (r.current = c, !c) return;
82
86
  Y.set(c, e);
83
- const a = c.closest("tbw-grid");
84
- if (a) {
85
- const f = a.id || a.getAttribute("data-grid-id");
86
- f && Z.set(f, e);
87
+ const s = c.closest("tbw-grid");
88
+ if (s) {
89
+ const g = s.id || s.getAttribute("data-grid-id");
90
+ g && Z.set(g, e);
87
91
  }
88
92
  },
89
93
  [e]
@@ -92,49 +96,49 @@ function Me(n) {
92
96
  const c = r.current;
93
97
  if (c) {
94
98
  Y.delete(c);
95
- const a = c.closest("tbw-grid");
96
- if (a) {
97
- const f = a.id || a.getAttribute("data-grid-id");
98
- f && Z.delete(f);
99
+ const s = c.closest("tbw-grid");
100
+ if (s) {
101
+ const g = s.id || s.getAttribute("data-grid-id");
102
+ g && Z.delete(g);
99
103
  }
100
104
  }
101
105
  }, []);
102
- const s = t === "auto" ? "auto" : String(t);
103
- return /* @__PURE__ */ b("tbw-grid-responsive-card", { ref: o, cardRowHeight: s });
106
+ const a = t === "auto" ? "auto" : String(t);
107
+ return /* @__PURE__ */ b("tbw-grid-responsive-card", { ref: o, cardRowHeight: a });
104
108
  }
105
109
  Me.displayName = "GridResponsiveCard";
106
- const z = me(null), He = ({ defaults: n, children: e }) => /* @__PURE__ */ b(z.Provider, { value: n, children: e });
107
- function yt() {
110
+ const z = ye(null), He = ({ defaults: n, children: e }) => /* @__PURE__ */ b(z.Provider, { value: n, children: e });
111
+ function mt() {
108
112
  return O(z);
109
113
  }
110
- function mt(n) {
114
+ function yt(n) {
111
115
  return O(z)?.[n];
112
116
  }
113
117
  const Oe = z, je = he(function(e, t) {
114
- const r = E(/* @__PURE__ */ new Map()), [, o] = Ee((g) => g + 1, 0), s = E(!1), c = E(0), a = () => {
115
- s.current || (s.current = !0, queueMicrotask(() => {
116
- s.current = !1, W(o), f();
118
+ const r = k(/* @__PURE__ */ new Map()), [, o] = Ee((p) => p + 1, 0), a = k(!1), c = k(0), s = () => {
119
+ a.current || (a.current = !0, queueMicrotask(() => {
120
+ a.current = !1, V(o), g();
117
121
  }));
118
- }, f = () => {
122
+ }, g = () => {
119
123
  c.current || (c.current = requestAnimationFrame(() => {
120
124
  c.current = 0;
121
- let g = !1;
122
- for (const [C, R] of r.current)
123
- R.container.isConnected || (r.current.delete(C), g = !0);
124
- g && W(o);
125
+ let p = !1;
126
+ for (const [v, C] of r.current)
127
+ C.container.isConnected || (r.current.delete(v), p = !0);
128
+ p && V(o);
125
129
  }));
126
130
  };
127
- ve(
131
+ Re(
128
132
  t,
129
133
  () => ({
130
- renderPortal(g, C, R) {
131
- r.current.set(g, { container: C, element: R }), a();
134
+ renderPortal(p, v, C) {
135
+ r.current.set(p, { container: v, element: C }), s();
132
136
  },
133
- removePortal(g, C) {
134
- r.current.delete(g) && (C ? W(o) : a());
137
+ removePortal(p, v) {
138
+ r.current.delete(p) && (v ? V(o) : s());
135
139
  },
136
140
  clear() {
137
- r.current.size > 0 && (r.current.clear(), c.current && (cancelAnimationFrame(c.current), c.current = 0), a());
141
+ r.current.size > 0 && (r.current.clear(), c.current && (cancelAnimationFrame(c.current), c.current = 0), s());
138
142
  }
139
143
  }),
140
144
  // forceRender is stable (useReducer dispatch), refs are stable
@@ -142,14 +146,14 @@ const Oe = z, je = he(function(e, t) {
142
146
  []
143
147
  );
144
148
  const d = [];
145
- for (const [g, { container: C, element: R }] of r.current)
146
- d.push(Ge(R, C, g));
149
+ for (const [p, { container: v, element: C }] of r.current)
150
+ d.push(Ge(C, v, p));
147
151
  return /* @__PURE__ */ b(ne, { children: d });
148
- }), U = /* @__PURE__ */ Symbol("reactProcessed"), G = [];
152
+ }), U = /* @__PURE__ */ Symbol("reactProcessed"), D = [];
149
153
  function ze(n) {
150
- for (let e = G.length - 1; e >= 0; e--) {
151
- const t = G[e];
152
- n.contains(t.container) && t.container.classList.contains("react-cell-editor") && (H(t.key), G.splice(e, 1));
154
+ for (let e = D.length - 1; e >= 0; e--) {
155
+ const t = D[e];
156
+ n.contains(t.container) && t.container.classList.contains("react-cell-editor") && (H(t.key), D.splice(e, 1));
153
157
  }
154
158
  }
155
159
  function qe(n) {
@@ -163,8 +167,8 @@ function qe(n) {
163
167
  }
164
168
  const o = document.createElement("div");
165
169
  o.className = "react-cell-renderer", o.style.display = "contents";
166
- const s = w(o, n(t));
167
- return r && e.set(r, { portalKey: s, container: o }), G.push({ key: s, container: o }), o;
170
+ const a = w(o, n(t));
171
+ return r && e.set(r, { portalKey: a, container: o }), D.push({ key: a, container: o }), o;
168
172
  };
169
173
  }
170
174
  function _e(n) {
@@ -172,7 +176,7 @@ function _e(n) {
172
176
  const t = document.createElement("div");
173
177
  t.className = "react-cell-editor", t.style.display = "contents";
174
178
  const r = w(t, n(e));
175
- return G.push({ key: r, container: t }), t;
179
+ return D.push({ key: r, container: t }), t;
176
180
  };
177
181
  }
178
182
  function $e(n) {
@@ -180,18 +184,18 @@ function $e(n) {
180
184
  const t = document.createElement("div");
181
185
  t.className = "react-header-renderer", t.style.display = "contents";
182
186
  const r = w(t, n(e));
183
- return G.push({ key: r, container: t }), t;
187
+ return D.push({ key: r, container: t }), t;
184
188
  };
185
189
  }
186
- function Ve(n) {
190
+ function Be(n) {
187
191
  return (e) => {
188
192
  const t = document.createElement("div");
189
193
  t.className = "react-header-label-renderer", t.style.display = "contents";
190
194
  const r = w(t, n(e));
191
- return G.push({ key: r, container: t }), t;
195
+ return D.push({ key: r, container: t }), t;
192
196
  };
193
197
  }
194
- function We(n) {
198
+ function Ve(n) {
195
199
  return (e) => {
196
200
  const t = n(e);
197
201
  if (t instanceof HTMLElement || typeof t == "string")
@@ -199,17 +203,17 @@ function We(n) {
199
203
  const r = document.createElement("div");
200
204
  r.className = "react-loading-renderer", r.style.display = "contents";
201
205
  const o = w(r, t);
202
- return G.push({ key: o, container: r }), r;
206
+ return D.push({ key: o, container: r }), r;
203
207
  };
204
208
  }
205
- function Re(n) {
209
+ function Ce(n) {
206
210
  if (!n) return;
207
211
  if (n[U]) return n;
208
212
  if (n.loadingRenderer && typeof n.loadingRenderer == "function") {
209
213
  const r = n.loadingRenderer;
210
214
  n = {
211
215
  ...n,
212
- loadingRenderer: We(r)
216
+ loadingRenderer: Ve(r)
213
217
  };
214
218
  }
215
219
  if (!n.columns) {
@@ -217,8 +221,8 @@ function Re(n) {
217
221
  return r[U] = !0, r;
218
222
  }
219
223
  const e = n.columns.map((r) => {
220
- const { renderer: o, editor: s, headerRenderer: c, headerLabelRenderer: a, ...f } = r, d = { ...f };
221
- return o && (d.renderer = qe(o)), s && (d.editor = _e(s)), c && (d.headerRenderer = $e(c)), a && (d.headerLabelRenderer = Ve(a)), d;
224
+ const { renderer: o, editor: a, headerRenderer: c, headerLabelRenderer: s, ...g } = r, d = { ...g };
225
+ return o && (d.renderer = qe(o)), a && (d.editor = _e(a)), c && (d.headerRenderer = $e(c)), s && (d.headerLabelRenderer = Be(s)), d;
222
226
  }), t = {
223
227
  ...n,
224
228
  columns: e
@@ -226,7 +230,7 @@ function Re(n) {
226
230
  return t[U] = !0, t;
227
231
  }
228
232
  const Q = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new Map();
229
- function Be(n) {
233
+ function We(n) {
230
234
  const e = n.querySelector("tbw-grid-detail");
231
235
  if (e) {
232
236
  const r = Q.get(e);
@@ -237,34 +241,34 @@ function Be(n) {
237
241
  return X.get(t);
238
242
  }
239
243
  function Ue(n) {
240
- const { children: e, showExpandColumn: t = !0, animation: r = "slide" } = n, o = E(null), s = S(
241
- (a) => {
242
- if (o.current = a, !a) return;
243
- Q.set(a, e);
244
- const f = a.closest("tbw-grid");
245
- if (f) {
246
- const d = f.id || f.getAttribute("data-grid-id");
244
+ const { children: e, showExpandColumn: t = !0, animation: r = "slide" } = n, o = k(null), a = E(
245
+ (s) => {
246
+ if (o.current = s, !s) return;
247
+ Q.set(s, e);
248
+ const g = s.closest("tbw-grid");
249
+ if (g) {
250
+ const d = g.id || g.getAttribute("data-grid-id");
247
251
  d && X.set(d, e);
248
252
  }
249
253
  },
250
254
  [e]
251
255
  );
252
256
  return P(() => () => {
253
- const a = o.current;
254
- if (a) {
255
- Q.delete(a);
256
- const f = a.closest("tbw-grid");
257
- if (f) {
258
- const g = f.id || f.getAttribute("data-grid-id");
259
- g && X.delete(g);
257
+ const s = o.current;
258
+ if (s) {
259
+ Q.delete(s);
260
+ const g = s.closest("tbw-grid");
261
+ if (g) {
262
+ const p = g.id || g.getAttribute("data-grid-id");
263
+ p && X.delete(p);
260
264
  }
261
- const d = a.parentNode;
262
- d && d.contains(a);
265
+ const d = s.parentNode;
266
+ d && d.contains(s);
263
267
  }
264
268
  }, []), /* @__PURE__ */ b(
265
269
  "tbw-grid-detail",
266
270
  {
267
- ref: s,
271
+ ref: a,
268
272
  showExpandColumn: t ? void 0 : "false",
269
273
  animation: r === !1 ? "false" : r
270
274
  }
@@ -280,55 +284,55 @@ function Je(n) {
280
284
  return te.get(t);
281
285
  }
282
286
  function ht(n) {
283
- const { id: e, title: t, icon: r, tooltip: o, order: s = 100, children: c } = n, a = E(null), f = S(
287
+ const { id: e, title: t, icon: r, tooltip: o, order: a = 100, children: c } = n, s = k(null), g = E(
284
288
  (d) => {
285
- a.current = d, d && (ee.set(d, c), e && te.set(e, c));
289
+ s.current = d, d && (ee.set(d, c), e && te.set(e, c));
286
290
  },
287
291
  [c, e]
288
292
  );
289
293
  return P(() => () => {
290
- const d = a.current;
294
+ const d = s.current;
291
295
  d && (ee.delete(d), e && te.delete(e));
292
296
  }, [e]), /* @__PURE__ */ b(
293
297
  "tbw-grid-tool-panel",
294
298
  {
295
- ref: f,
299
+ ref: g,
296
300
  id: e,
297
301
  title: t,
298
302
  icon: r,
299
303
  tooltip: o,
300
- order: s?.toString()
304
+ order: a?.toString()
301
305
  }
302
306
  );
303
307
  }
304
- const A = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new Map();
308
+ const G = /* @__PURE__ */ new WeakMap(), A = /* @__PURE__ */ new Map();
305
309
  function Ye(n, e) {
306
- const t = n.getAttribute("field"), r = A.get(n) ?? {};
307
- if (r.renderer = e, A.set(n, r), t) {
308
- const o = T.get(t) ?? {};
309
- o.renderer = e, T.set(t, o);
310
+ const t = n.getAttribute("field"), r = G.get(n) ?? {};
311
+ if (r.renderer = e, G.set(n, r), t) {
312
+ const o = A.get(t) ?? {};
313
+ o.renderer = e, A.set(t, o);
310
314
  }
311
315
  }
312
316
  function Ze(n, e) {
313
- const t = n.getAttribute("field"), r = A.get(n) ?? {};
314
- if (r.editor = e, A.set(n, r), t) {
315
- const o = T.get(t) ?? {};
316
- o.editor = e, T.set(t, o);
317
+ const t = n.getAttribute("field"), r = G.get(n) ?? {};
318
+ if (r.editor = e, G.set(n, r), t) {
319
+ const o = A.get(t) ?? {};
320
+ o.editor = e, A.set(t, o);
317
321
  }
318
322
  }
319
323
  function Qe(n) {
320
- let e = A.get(n)?.renderer;
324
+ let e = G.get(n)?.renderer;
321
325
  if (!e) {
322
326
  const t = n.getAttribute("field");
323
- t && (e = T.get(t)?.renderer);
327
+ t && (e = A.get(t)?.renderer);
324
328
  }
325
329
  return e;
326
330
  }
327
331
  function Xe(n) {
328
- let e = A.get(n)?.editor;
332
+ let e = G.get(n)?.editor;
329
333
  if (!e) {
330
334
  const t = n.getAttribute("field");
331
- t && (e = T.get(t)?.editor);
335
+ t && (e = A.get(t)?.editor);
332
336
  }
333
337
  return e;
334
338
  }
@@ -355,7 +359,7 @@ class et {
355
359
  * Converts React renderer/editor functions to DOM-returning functions.
356
360
  */
357
361
  processConfig(e) {
358
- return Re(e) ?? e;
362
+ return Ce(e) ?? e;
359
363
  }
360
364
  /**
361
365
  * Determines if this adapter can handle the given element.
@@ -363,13 +367,13 @@ class et {
363
367
  */
364
368
  canHandle(e) {
365
369
  const t = e.getAttribute("field");
366
- let r = A.get(e);
370
+ let r = G.get(e);
367
371
  if (!r && t) {
368
- const c = T.get(t);
369
- c && (c.renderer || c.editor) && (r = c, A.set(e, r));
372
+ const c = A.get(t);
373
+ c && (c.renderer || c.editor) && (r = c, G.set(e, r));
370
374
  }
371
- const o = r?.renderer !== void 0, s = r?.editor !== void 0;
372
- return r !== void 0 && (o || s);
375
+ const o = r?.renderer !== void 0, a = r?.editor !== void 0;
376
+ return r !== void 0 && (o || a);
373
377
  }
374
378
  /**
375
379
  * Creates a view renderer function that renders a React component
@@ -387,31 +391,31 @@ class et {
387
391
  if (!t)
388
392
  return;
389
393
  const r = e.closest("tbw-grid"), o = /* @__PURE__ */ new WeakMap();
390
- return (s) => {
391
- const c = s.cellEl;
394
+ return (a) => {
395
+ const c = a.cellEl;
392
396
  if (c) {
393
397
  const d = o.get(c);
394
398
  if (d)
395
- return w(d.container, t(s), d.portalKey), d.container;
396
- const g = document.createElement("div");
397
- g.className = "react-cell-renderer", g.style.display = "contents";
398
- const C = w(
399
- g,
400
- t(s),
399
+ return w(d.container, t(a), d.portalKey), d.container;
400
+ const p = document.createElement("div");
401
+ p.className = "react-cell-renderer", p.style.display = "contents";
402
+ const v = w(
403
+ p,
404
+ t(a),
401
405
  void 0,
402
406
  r ?? void 0
403
407
  );
404
- return o.set(c, { portalKey: C, container: g }), this.trackPortal(C, g, !1), g;
408
+ return o.set(c, { portalKey: v, container: p }), this.trackPortal(v, p, !1), p;
405
409
  }
406
- const a = document.createElement("div");
407
- a.className = "react-cell-renderer", a.style.display = "contents";
408
- const f = w(
409
- a,
410
- t(s),
410
+ const s = document.createElement("div");
411
+ s.className = "react-cell-renderer", s.style.display = "contents";
412
+ const g = w(
413
+ s,
414
+ t(a),
411
415
  void 0,
412
416
  r ?? void 0
413
417
  );
414
- return this.trackPortal(f, a, !1), a;
418
+ return this.trackPortal(g, s, !1), s;
415
419
  };
416
420
  }
417
421
  /**
@@ -424,15 +428,15 @@ class et {
424
428
  return () => document.createElement("div");
425
429
  const r = e.closest("tbw-grid") ?? void 0;
426
430
  return (o) => {
427
- const s = document.createElement("div");
428
- s.className = "react-cell-editor", s.style.display = "contents";
431
+ const a = document.createElement("div");
432
+ a.className = "react-cell-editor", a.style.display = "contents";
429
433
  const c = w(
430
- s,
434
+ a,
431
435
  t(o),
432
436
  void 0,
433
437
  r
434
438
  );
435
- return this.trackPortal(c, s, !0), s;
439
+ return this.trackPortal(c, a, !0), a;
436
440
  };
437
441
  }
438
442
  /**
@@ -440,18 +444,18 @@ class et {
440
444
  * Renders React components for expandable detail rows.
441
445
  */
442
446
  createDetailRenderer(e) {
443
- const t = Be(e);
447
+ const t = We(e);
444
448
  if (t)
445
449
  return (r, o) => {
446
- const s = document.createElement("div");
447
- s.className = "react-detail-panel";
448
- const a = w(
449
- s,
450
+ const a = document.createElement("div");
451
+ a.className = "react-detail-panel";
452
+ const s = w(
453
+ a,
450
454
  t({ row: r, rowIndex: o }),
451
455
  void 0,
452
456
  e
453
457
  );
454
- return this.trackPortal(a, s, !1), s;
458
+ return this.trackPortal(s, a, !1), a;
455
459
  };
456
460
  }
457
461
  /**
@@ -468,20 +472,33 @@ class et {
468
472
  * Renders React components for card layout in responsive mode.
469
473
  */
470
474
  createResponsiveCardRenderer(e) {
471
- const t = Ce(e);
475
+ const t = ve(e);
472
476
  if (t)
473
477
  return (r, o) => {
474
- const s = document.createElement("div");
475
- s.className = "react-responsive-card";
476
- const a = w(
477
- s,
478
+ const a = document.createElement("div");
479
+ a.className = "react-responsive-card";
480
+ const s = w(
481
+ a,
478
482
  t({ row: r, index: o }),
479
483
  void 0,
480
484
  e
481
485
  );
482
- return this.trackPortal(a, s, !1), s;
486
+ return this.trackPortal(s, a, !1), a;
483
487
  };
484
488
  }
489
+ /**
490
+ * FrameworkAdapter hook called by ResponsivePlugin during attach().
491
+ * Parses the `<tbw-grid-responsive-card>` element and delegates to
492
+ * {@link createResponsiveCardRenderer}. Needed for parity with the Vue
493
+ * and Angular adapters so ResponsivePlugin's standard lookup path works
494
+ * for React users as well, not just via the imperative
495
+ * `refreshResponsiveCardRenderer` hook in DataGrid.
496
+ */
497
+ parseResponsiveCardElement(e) {
498
+ const t = e.closest("tbw-grid");
499
+ if (t)
500
+ return this.createResponsiveCardRenderer(t);
501
+ }
485
502
  /**
486
503
  * Creates a tool panel renderer from a light DOM element.
487
504
  * Renders React components into tool panel containers.
@@ -543,7 +560,7 @@ class et {
543
560
  return (r) => {
544
561
  const o = document.createElement("span");
545
562
  o.style.display = "contents";
546
- const s = r.cellEl?.closest("tbw-grid") ?? t, c = w(o, e(r), void 0, s);
563
+ const a = r.cellEl?.closest("tbw-grid") ?? t, c = w(o, e(r), void 0, a);
547
564
  return this.trackPortal(c, o, !1), o;
548
565
  };
549
566
  }
@@ -555,8 +572,8 @@ class et {
555
572
  return (r) => {
556
573
  const o = document.createElement("span");
557
574
  o.style.display = "contents";
558
- const s = w(o, e(r), void 0, t);
559
- return this.trackPortal(s, o, !0), o;
575
+ const a = w(o, e(r), void 0, t);
576
+ return this.trackPortal(a, o, !0), o;
560
577
  };
561
578
  }
562
579
  /**
@@ -565,10 +582,10 @@ class et {
565
582
  */
566
583
  createFilterPanelRenderer(e, t) {
567
584
  return (r, o) => {
568
- const s = document.createElement("div");
569
- s.style.display = "contents";
570
- const c = r.closest("tbw-grid") ?? t, a = w(s, e(o), void 0, c);
571
- this.trackPortal(a, s, !1), r.appendChild(s);
585
+ const a = document.createElement("div");
586
+ a.style.display = "contents";
587
+ const c = r.closest("tbw-grid") ?? t, s = w(a, e(o), void 0, c);
588
+ this.trackPortal(s, a, !1), r.appendChild(a);
572
589
  };
573
590
  }
574
591
  // #region Portal tracking helpers
@@ -588,7 +605,7 @@ class et {
588
605
  destroy() {
589
606
  for (const e of this.allPortalKeys)
590
607
  H(e);
591
- this.allPortalKeys.clear(), this.editorPortalKeys.clear(), this.keyToContainer.clear(), T.clear();
608
+ this.allPortalKeys.clear(), this.editorPortalKeys.clear(), this.keyToContainer.clear(), A.clear();
592
609
  }
593
610
  /**
594
611
  * Called when a cell's content is about to be wiped.
@@ -635,9 +652,9 @@ function nt(n) {
635
652
  r === void 0 || r === !1 || e.push(t);
636
653
  return rt(e), Ae(n);
637
654
  }
638
- let ye = !1, J = null;
655
+ let me = !1, J = null;
639
656
  function re() {
640
- return ye || (J = new et(), be.registerAdapter(J), ye = !0), J;
657
+ return me || (J = new et(), be.registerAdapter(J), me = !0), J;
641
658
  }
642
659
  re();
643
660
  function ot(n) {
@@ -646,11 +663,11 @@ function ot(n) {
646
663
  }
647
664
  function it(n, e) {
648
665
  const t = n;
649
- if (!n.querySelector("tbw-grid-responsive-card") || !Ce(n)) return;
650
- const s = t.getPluginByName?.("responsive");
651
- if (s && typeof s.setCardRenderer == "function") {
666
+ if (!n.querySelector("tbw-grid-responsive-card") || !ve(n)) return;
667
+ const a = t.getPluginByName?.("responsive");
668
+ if (a && typeof a.setCardRenderer == "function") {
652
669
  const c = e.createResponsiveCardRenderer(n);
653
- c && s.setCardRenderer(c);
670
+ c && a.setCardRenderer(c);
654
671
  }
655
672
  }
656
673
  function st(n) {
@@ -670,31 +687,31 @@ function st(n) {
670
687
  }
671
688
  }), e;
672
689
  }
673
- const vt = he(function(e, t) {
690
+ const Rt = he(function(e, t) {
674
691
  const {
675
692
  // Core props
676
693
  rows: r,
677
694
  gridConfig: o,
678
- columns: s,
695
+ columns: a,
679
696
  columnDefaults: c,
680
- fitMode: a,
681
- sortable: f,
697
+ fitMode: s,
698
+ sortable: g,
682
699
  filterable: d,
683
- selectable: g,
684
- loading: C,
685
- customStyles: R,
700
+ selectable: p,
701
+ loading: v,
702
+ customStyles: C,
686
703
  className: K,
687
- style: p,
688
- children: v,
704
+ style: x,
705
+ children: T,
689
706
  // Plugin props
690
- plugins: m,
707
+ plugins: u,
691
708
  // SSR mode
692
- ssr: k,
709
+ ssr: h,
693
710
  // Legacy event handlers
694
- onRowsChange: x,
711
+ onRowsChange: R,
695
712
  // Feature props and event props are in ...rest
696
- ...h
697
- } = e, u = E(null), j = E(null), ie = O(Oe), q = O(Le), se = [
713
+ ...m
714
+ } = e, f = k(null), j = k(null), ie = O(Oe), q = O(Le), se = [
698
715
  "selection",
699
716
  "editing",
700
717
  "filtering",
@@ -703,6 +720,7 @@ const vt = he(function(e, t) {
703
720
  "contextMenu",
704
721
  "reorderColumns",
705
722
  "reorderRows",
723
+ "rowDragDrop",
706
724
  "visibility",
707
725
  "undoRedo",
708
726
  "tree",
@@ -718,58 +736,58 @@ const vt = he(function(e, t) {
718
736
  "pivot",
719
737
  "serverSide",
720
738
  "tooltip"
721
- ], we = D(() => se.map((i) => {
722
- const l = h[i];
739
+ ], we = S(() => se.map((i) => {
740
+ const l = m[i];
723
741
  return l !== void 0 ? `${i}:${JSON.stringify(l)}` : "";
724
- }).filter(Boolean).join("|"), [h]), ce = D(() => {
742
+ }).filter(Boolean).join("|"), [m]), ae = S(() => {
725
743
  const i = {};
726
744
  for (const l of se)
727
- l in h && h[l] !== void 0 && (i[l] = h[l]);
745
+ l in m && m[l] !== void 0 && (i[l] = m[l]);
728
746
  return i;
729
- }, [we]), ae = D(() => st(v), [v]), le = D(() => ({ ...ae, ...ce }), [ce, ae]), _ = D(() => m || k ? [] : nt(le), [le, m, k]), N = D(() => {
730
- if (m) {
731
- const i = new Set(m.map((y) => y.name)), l = _.filter((y) => !i.has(y.name));
732
- return [...m, ...l];
747
+ }, [we]), ce = S(() => st(T), [T]), le = S(() => ({ ...ce, ...ae }), [ae, ce]), _ = S(() => u || h ? [] : nt(le), [le, u, h]), N = S(() => {
748
+ if (u) {
749
+ const i = new Set(u.map((y) => y.name)), l = _.filter((y) => !i.has(y.name));
750
+ return [...u, ...l];
733
751
  }
734
752
  return _;
735
- }, [m, _]), F = D(() => {
736
- if (!s) return s;
737
- const i = Fe(s);
753
+ }, [u, _]), F = S(() => {
754
+ if (!a) return a;
755
+ const i = Fe(a);
738
756
  return c ? i.map((l) => ({
739
757
  ...c,
740
758
  ...l
741
759
  // Individual column props override defaults
742
760
  })) : i;
743
- }, [s, c]), I = D(() => {
744
- const i = Re(o), l = {};
745
- if (f !== void 0 && (l.sortable = f), d !== void 0 && (l.filterable = d), g !== void 0 && (l.selectable = g), q) {
761
+ }, [a, c]), I = S(() => {
762
+ const i = Ce(o), l = {};
763
+ if (g !== void 0 && (l.sortable = g), d !== void 0 && (l.filterable = d), p !== void 0 && (l.selectable = p), q) {
746
764
  const y = i?.icons || o?.icons || {};
747
765
  l.icons = { ...q, ...y };
748
766
  }
749
767
  if (N.length > 0 && i) {
750
- const y = i.plugins || [], L = new Set(y.map((M) => M.name)), V = N.filter((M) => !L.has(M.name));
768
+ const y = i.plugins || [], L = new Set(y.map((M) => M.name)), B = N.filter((M) => !L.has(M.name));
751
769
  return {
752
770
  ...i,
753
771
  ...l,
754
- plugins: [...y, ...V]
772
+ plugins: [...y, ...B]
755
773
  };
756
774
  }
757
775
  return N.length > 0 && !i ? { ...l, plugins: N } : Object.keys(l).length > 0 ? { ...i, ...l } : i;
758
- }, [o, N, f, d, g, q]);
776
+ }, [o, N, g, d, p, q]);
759
777
  P(() => {
760
778
  re().setTypeDefaults(ie);
761
779
  }, [ie]), P(() => {
762
- u.current && (u.current.rows = r);
780
+ f.current && (f.current.rows = r);
763
781
  }, [r]), P(() => {
764
- u.current && I && (u.current.gridConfig = I);
782
+ f.current && I && (f.current.gridConfig = I);
765
783
  }, [I]), P(() => {
766
- u.current && F && (u.current.columns = F);
784
+ f.current && F && (f.current.columns = F);
767
785
  }, [F]), P(() => {
768
- u.current && a !== void 0 && (u.current.fitMode = a);
769
- }, [a]), P(() => {
770
- u.current && C !== void 0 && (u.current.loading = C);
771
- }, [C]), P(() => {
772
- const i = u.current;
786
+ f.current && s !== void 0 && (f.current.fitMode = s);
787
+ }, [s]), P(() => {
788
+ f.current && v !== void 0 && (f.current.loading = v);
789
+ }, [v]), P(() => {
790
+ const i = f.current;
773
791
  if (!i) return;
774
792
  const l = re();
775
793
  i.__frameworkAdapter = l, ot(i), it(i, l);
@@ -781,83 +799,83 @@ const vt = he(function(e, t) {
781
799
  y = !0, cancelAnimationFrame(L);
782
800
  };
783
801
  }, []), P(() => {
784
- if (!u.current || !R) return;
785
- const i = u.current, l = "react-custom-styles";
802
+ if (!f.current || !C) return;
803
+ const i = f.current, l = "react-custom-styles";
786
804
  let y = !0;
787
805
  return i.ready?.().then(() => {
788
- y && R && (i.registerStyles?.(l, R), j.current = l);
806
+ y && C && (i.registerStyles?.(l, C), j.current = l);
789
807
  }), () => {
790
808
  y = !1, j.current && (i.unregisterStyles?.(j.current), j.current = null);
791
809
  };
792
- }, [R]), P(() => {
793
- const i = u.current;
810
+ }, [C]), P(() => {
811
+ const i = f.current;
794
812
  if (!i) return;
795
813
  const l = [];
796
- return x && l.push(i.on("rows-change", (y) => x(y.rows))), () => {
814
+ return R && l.push(i.on("rows-change", (y) => R(y.rows))), () => {
797
815
  l.forEach((y) => y());
798
816
  };
799
- }, [x]);
800
- const de = D(() => Object.keys(B).filter((i) => typeof h[i] == "function").sort().join("|"), [h]), ue = E({});
801
- for (const i of Object.keys(B))
802
- ue.current[i] = h[i];
817
+ }, [R]);
818
+ const de = S(() => Object.keys(W).filter((i) => typeof m[i] == "function").sort().join("|"), [m]), ue = k({});
819
+ for (const i of Object.keys(W))
820
+ ue.current[i] = m[i];
803
821
  P(() => {
804
- const i = u.current;
822
+ const i = f.current;
805
823
  if (!i) return;
806
824
  const l = [];
807
- for (const [y, L] of Object.entries(B))
825
+ for (const [y, L] of Object.entries(W))
808
826
  de.includes(y) && l.push(
809
- i.on(L, (V, M) => {
810
- ue.current[y]?.(V, M);
827
+ i.on(L, (B, M) => {
828
+ ue.current[y]?.(B, M);
811
829
  })
812
830
  );
813
831
  return () => {
814
832
  l.forEach((y) => y());
815
833
  };
816
- }, [de]), ve(
834
+ }, [de]), Re(
817
835
  t,
818
836
  () => ({
819
837
  get element() {
820
- return u.current;
838
+ return f.current;
821
839
  },
822
840
  async getConfig() {
823
- return u.current?.getConfig?.() ?? {};
841
+ return f.current?.getConfig?.() ?? {};
824
842
  },
825
843
  async ready() {
826
- return u.current?.ready?.();
844
+ return f.current?.ready?.();
827
845
  },
828
846
  async forceLayout() {
829
- return u.current?.forceLayout?.();
847
+ return f.current?.forceLayout?.();
830
848
  },
831
849
  async toggleGroup(i) {
832
- return u.current?.toggleGroup?.(i);
850
+ return f.current?.toggleGroup?.(i);
833
851
  },
834
852
  registerStyles(i, l) {
835
- u.current?.registerStyles?.(i, l);
853
+ f.current?.registerStyles?.(i, l);
836
854
  },
837
855
  unregisterStyles(i) {
838
- u.current?.unregisterStyles?.(i);
856
+ f.current?.unregisterStyles?.(i);
839
857
  },
840
858
  setRowLoading(i, l) {
841
- u.current?.setRowLoading?.(i, l);
859
+ f.current?.setRowLoading?.(i, l);
842
860
  },
843
861
  setCellLoading(i, l, y) {
844
- u.current?.setCellLoading?.(i, l, y);
862
+ f.current?.setCellLoading?.(i, l, y);
845
863
  },
846
864
  isRowLoading(i) {
847
- return u.current?.isRowLoading?.(i) ?? !1;
865
+ return f.current?.isRowLoading?.(i) ?? !1;
848
866
  },
849
867
  isCellLoading(i, l) {
850
- return u.current?.isCellLoading?.(i, l) ?? !1;
868
+ return f.current?.isCellLoading?.(i, l) ?? !1;
851
869
  },
852
870
  clearAllLoading() {
853
- u.current?.clearAllLoading?.();
871
+ f.current?.clearAllLoading?.();
854
872
  }
855
873
  }),
856
874
  []
857
875
  );
858
- const $ = E(null);
876
+ const $ = k(null);
859
877
  return ke(() => {
860
- const i = u.current;
878
+ const i = f.current;
861
879
  return i && $.current && ge(i, $.current), () => {
862
880
  i && ge(i, null);
863
881
  };
@@ -867,47 +885,47 @@ const vt = he(function(e, t) {
867
885
  "tbw-grid",
868
886
  {
869
887
  ref: (i) => {
870
- if (u.current = i, i) {
888
+ if (f.current = i, i) {
871
889
  const l = i;
872
890
  I && (l.gridConfig = I), r && (l.rows = r), F && (l.columns = F);
873
891
  }
874
892
  },
875
893
  class: K,
876
- style: p,
877
- children: /* @__PURE__ */ b(Te.Provider, { value: u, children: v })
894
+ style: x,
895
+ children: /* @__PURE__ */ b(Te.Provider, { value: f, children: T })
878
896
  }
879
897
  )
880
898
  ] });
881
899
  });
882
- function Ct(n) {
900
+ function vt(n) {
883
901
  const {
884
902
  field: e,
885
903
  header: t,
886
904
  type: r,
887
905
  editable: o,
888
- sortable: s,
906
+ sortable: a,
889
907
  resizable: c,
890
- width: a,
891
- minWidth: f,
908
+ width: s,
909
+ minWidth: g,
892
910
  hidden: d,
893
- lockVisible: g,
894
- children: C,
895
- editor: R,
911
+ lockVisible: p,
912
+ children: v,
913
+ editor: C,
896
914
  options: K,
897
- multi: p,
898
- format: v
899
- } = n, m = E(null), k = S(
900
- (u) => {
901
- m.current = u, u && (C && Ye(u, C), R && Ze(u, R));
915
+ multi: x,
916
+ format: T
917
+ } = n, u = k(null), h = E(
918
+ (f) => {
919
+ u.current = f, f && (v && Ye(f, v), C && Ze(f, C));
902
920
  },
903
- [C, R, e]
904
- ), x = typeof a == "number" ? `${a}px` : a, h = {
921
+ [v, C, e]
922
+ ), R = typeof s == "number" ? `${s}px` : s, m = {
905
923
  field: e,
906
- ref: k
924
+ ref: h
907
925
  };
908
- return t !== void 0 && (h.header = t), r !== void 0 && (h.type = r), o !== void 0 && (h.editable = o), s !== void 0 && (h.sortable = s), c !== void 0 && (h.resizable = c), x !== void 0 && (h.width = x), f !== void 0 && (h["min-width"] = f), d !== void 0 && (h.hidden = d), g !== void 0 && (h["lock-visible"] = g), p !== void 0 && (h.multi = p), v && (h["data-has-format"] = "true"), K && (h["data-has-options"] = "true"), /* @__PURE__ */ b("tbw-grid-column", { ...h });
926
+ return t !== void 0 && (m.header = t), r !== void 0 && (m.type = r), o !== void 0 && (m.editable = o), a !== void 0 && (m.sortable = a), c !== void 0 && (m.resizable = c), R !== void 0 && (m.width = R), g !== void 0 && (m["min-width"] = g), d !== void 0 && (m.hidden = d), p !== void 0 && (m["lock-visible"] = p), x !== void 0 && (m.multi = x), T && (m["data-has-format"] = "true"), K && (m["data-has-options"] = "true"), /* @__PURE__ */ b("tbw-grid-column", { ...m });
909
927
  }
910
- function Rt({ children: n }) {
928
+ function Ct({ children: n }) {
911
929
  return /* @__PURE__ */ b("tbw-grid-tool-buttons", { children: n });
912
930
  }
913
931
  const wt = ({ icons: n, defaults: e, children: t }) => {
@@ -915,106 +933,114 @@ const wt = ({ icons: n, defaults: e, children: t }) => {
915
933
  return e && (r = /* @__PURE__ */ b(He, { defaults: e, children: r })), n && (r = /* @__PURE__ */ b(Ie, { icons: n, children: r })), /* @__PURE__ */ b(ne, { children: r });
916
934
  };
917
935
  function Pt(n) {
918
- const e = E(null), [t, r] = fe(!1), [o, s] = fe(null), c = E(null), a = S(() => n ? (c.current ??= document.querySelector(n), c.current) : e.current?.element ?? null, [n]);
936
+ const e = k(null), [t, r] = fe(!1), [o, a] = fe(null), c = k(null), s = E(() => n ? (c.current ??= document.querySelector(n), c.current) : e.current?.element ?? null, [n]);
919
937
  P(() => {
920
- let p = !0;
938
+ let u = !0;
921
939
  return (async () => {
922
940
  try {
923
941
  if (n) {
924
- const m = document.querySelector(n);
925
- if (!m) return;
926
- if (c.current = m, await m.ready?.(), p) {
942
+ const R = document.querySelector(n);
943
+ if (!R) return;
944
+ if (c.current = R, await R.ready?.(), u) {
927
945
  r(!0);
928
- const k = await m.getConfig?.();
929
- p && k && s(k);
946
+ const m = await R.getConfig?.();
947
+ u && m && a(m);
930
948
  }
931
949
  } else {
932
- const m = e.current;
933
- if (!m) return;
934
- if (await m.ready?.(), p) {
950
+ const R = e.current;
951
+ if (!R) return;
952
+ if (await R.ready?.(), u) {
935
953
  r(!0);
936
- const k = await m.getConfig?.();
937
- p && k && s(k);
954
+ const m = await R.getConfig?.();
955
+ u && m && a(m);
938
956
  }
939
957
  }
940
958
  } catch {
941
959
  }
942
960
  })(), () => {
943
- p = !1;
961
+ u = !1;
944
962
  };
945
963
  }, [n]);
946
- const f = S(async () => {
947
- const p = a();
948
- if (p)
949
- return await p.getConfig?.() ?? null;
950
- const v = e.current;
951
- return v ? await v.getConfig?.() ?? null : null;
952
- }, [a]), d = S(async () => {
953
- const p = a();
954
- if (p) {
955
- await p.forceLayout?.();
964
+ const g = E(async () => {
965
+ const u = s();
966
+ if (u)
967
+ return await u.getConfig?.() ?? null;
968
+ const h = e.current;
969
+ return h ? await h.getConfig?.() ?? null : null;
970
+ }, [s]), d = E(async () => {
971
+ const u = s();
972
+ if (u) {
973
+ await u.forceLayout?.();
956
974
  return;
957
975
  }
958
- const v = e.current;
959
- v && await v.forceLayout?.();
960
- }, [a]), g = S(
961
- async (p) => {
962
- const v = a();
963
- if (v) {
964
- await v.toggleGroup?.(p);
976
+ const h = e.current;
977
+ h && await h.forceLayout?.();
978
+ }, [s]), p = E(
979
+ async (u) => {
980
+ const h = s();
981
+ if (h) {
982
+ await h.toggleGroup?.(u);
965
983
  return;
966
984
  }
967
- const m = e.current;
968
- m && await m.toggleGroup?.(p);
985
+ const R = e.current;
986
+ R && await R.toggleGroup?.(u);
969
987
  },
970
- [a]
971
- ), C = S(
972
- (p, v) => {
973
- const m = a();
974
- if (m) {
975
- m.registerStyles?.(p, v);
988
+ [s]
989
+ ), v = E(
990
+ (u) => s()?.getPlugin?.(u),
991
+ [s]
992
+ ), C = E(
993
+ ((u) => s()?.getPluginByName?.(u)),
994
+ [s]
995
+ ), K = E(
996
+ (u, h) => {
997
+ const R = s();
998
+ if (R) {
999
+ R.registerStyles?.(u, h);
976
1000
  return;
977
1001
  }
978
- e.current?.registerStyles?.(p, v);
1002
+ e.current?.registerStyles?.(u, h);
979
1003
  },
980
- [a]
981
- ), R = S(
982
- (p) => {
983
- const v = a();
984
- if (v) {
985
- v.unregisterStyles?.(p);
1004
+ [s]
1005
+ ), x = E(
1006
+ (u) => {
1007
+ const h = s();
1008
+ if (h) {
1009
+ h.unregisterStyles?.(u);
986
1010
  return;
987
1011
  }
988
- e.current?.unregisterStyles?.(p);
1012
+ e.current?.unregisterStyles?.(u);
989
1013
  },
990
- [a]
991
- ), K = S(() => o?.columns ? o.columns.filter((p) => !p.hidden) : [], [o]);
1014
+ [s]
1015
+ ), T = E(() => o?.columns ? o.columns.filter((u) => !u.hidden) : [], [o]);
992
1016
  return {
993
1017
  ref: e,
994
- element: a(),
1018
+ element: s(),
995
1019
  isReady: t,
996
1020
  config: o,
997
- getConfig: f,
1021
+ getConfig: g,
998
1022
  forceLayout: d,
999
- toggleGroup: g,
1000
- registerStyles: C,
1001
- unregisterStyles: R,
1002
- getVisibleColumns: K
1023
+ toggleGroup: p,
1024
+ getPlugin: v,
1025
+ getPluginByName: C,
1026
+ registerStyles: K,
1027
+ unregisterStyles: x,
1028
+ getVisibleColumns: T
1003
1029
  };
1004
1030
  }
1005
1031
  export {
1006
- vt as DataGrid,
1032
+ Rt as DataGrid,
1007
1033
  et as GridAdapter,
1008
- Ct as GridColumn,
1034
+ vt as GridColumn,
1009
1035
  Ue as GridDetailPanel,
1010
1036
  Ie as GridIconProvider,
1011
1037
  wt as GridProvider,
1012
1038
  Me as GridResponsiveCard,
1013
- Rt as GridToolButtons,
1039
+ Ct as GridToolButtons,
1014
1040
  ht as GridToolPanel,
1015
1041
  He as GridTypeProvider,
1016
1042
  Pt as useGrid,
1017
1043
  pt as useGridIcons,
1018
- yt as useGridTypeDefaults,
1019
- mt as useTypeDefault
1044
+ mt as useGridTypeDefaults,
1045
+ yt as useTypeDefault
1020
1046
  };