@toolbox-web/grid-react 2.4.0 → 2.5.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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/chunks/feature-registry-DKPyd2rV.js +2 -0
  4. package/chunks/{react-column-config-Cto2WHGC.js → react-column-config-CkBIwx2L.js} +1 -1
  5. package/chunks/{react-grid-adapter-C_TSA5_P.js → react-grid-adapter-DP9A9ytc.js} +131 -93
  6. package/chunks/use-grid-is-ready-Baa67cu3.js +15 -0
  7. package/features/editing.js +3 -3
  8. package/features/export.d.ts +6 -0
  9. package/features/export.d.ts.map +1 -1
  10. package/features/export.js +17 -15
  11. package/features/filtering.d.ts +6 -0
  12. package/features/filtering.d.ts.map +1 -1
  13. package/features/filtering.js +40 -38
  14. package/features/grouping-columns.js +1 -1
  15. package/features/grouping-rows.js +1 -1
  16. package/features/master-detail.js +2 -2
  17. package/features/pinned-rows.js +1 -1
  18. package/features/print.d.ts +6 -0
  19. package/features/print.d.ts.map +1 -1
  20. package/features/print.js +10 -8
  21. package/features/responsive.js +2 -2
  22. package/features/selection.d.ts +32 -0
  23. package/features/selection.d.ts.map +1 -1
  24. package/features/selection.js +35 -19
  25. package/features/undo-redo.d.ts +6 -0
  26. package/features/undo-redo.d.ts.map +1 -1
  27. package/features/undo-redo.js +38 -27
  28. package/index.d.ts +3 -0
  29. package/index.d.ts.map +1 -1
  30. package/index.js +242 -229
  31. package/lib/column-options.d.ts +33 -0
  32. package/lib/column-options.d.ts.map +1 -0
  33. package/lib/grid-column.d.ts +21 -11
  34. package/lib/grid-column.d.ts.map +1 -1
  35. package/lib/react-grid-adapter.d.ts +37 -1
  36. package/lib/react-grid-adapter.d.ts.map +1 -1
  37. package/lib/use-grid-is-ready.d.ts +9 -0
  38. package/lib/use-grid-is-ready.d.ts.map +1 -0
  39. package/lib/use-grid.d.ts +2 -0
  40. package/lib/use-grid.d.ts.map +1 -1
  41. package/package.json +1 -1
  42. package/chunks/feature-registry-8K2rOVnC.js +0 -2
package/index.js CHANGED
@@ -1,19 +1,20 @@
1
- import { c as e, d as t, f as n, l as r, n as i, p as a, r as o, s, t as c, u as l } from "./chunks/react-grid-adapter-C_TSA5_P.js";
2
- import { a as u, i as d, o as f } from "./chunks/portal-bridge-zxgm_jwK.js";
3
- import { n as p, t as m } from "./chunks/post-mount-refresh-hooks-D7BDK4Kl.js";
4
- import { a as h, r as g } from "./chunks/react-column-config-Cto2WHGC.js";
5
- import "./chunks/feature-registry-8K2rOVnC.js";
6
- import { t as _ } from "./chunks/grid-element-context-DpuQsoie.js";
7
- import { t as v } from "./chunks/grid-detail-panel-CLdX0T_A.js";
8
- import { t as y } from "./chunks/grid-responsive-card-Dx5U6Prm.js";
9
- import { DataGridElement as b, parseColumnShorthand as x } from "@toolbox-web/grid";
10
- import { Component as S, createContext as C, createElement as ee, forwardRef as w, useCallback as T, useContext as E, useEffect as D, useId as O, useImperativeHandle as te, useLayoutEffect as ne, useMemo as k, useReducer as A, useRef as j, useState as M } from "react";
11
- import { Fragment as N, jsx as P, jsxs as re } from "react/jsx-runtime";
12
- import { createPortal as F, flushSync as I } from "react-dom";
13
- import { createPluginsFromFeatures as L } from "@toolbox-web/grid/features/registry";
1
+ import { a as e, d as t, f as n, h as r, i, l as a, m as o, n as s, p as c, r as l, t as u, u as d } from "./chunks/react-grid-adapter-DP9A9ytc.js";
2
+ import { a as f, i as p, o as m } from "./chunks/portal-bridge-zxgm_jwK.js";
3
+ import { n as h, t as g } from "./chunks/post-mount-refresh-hooks-D7BDK4Kl.js";
4
+ import { r as _, s as v } from "./chunks/react-column-config-CkBIwx2L.js";
5
+ import { a as y, i as b, n as x, o as S, r as C, t as w } from "./chunks/feature-registry-DKPyd2rV.js";
6
+ import { t as T } from "./chunks/grid-element-context-DpuQsoie.js";
7
+ import { t as E } from "./chunks/grid-detail-panel-CLdX0T_A.js";
8
+ import { t as D } from "./chunks/grid-responsive-card-Dx5U6Prm.js";
9
+ import { t as O } from "./chunks/use-grid-is-ready-Baa67cu3.js";
10
+ import { DataGridElement as ee, parseColumnShorthand as k } from "@toolbox-web/grid";
11
+ import { Component as A, createContext as j, createElement as te, forwardRef as M, useCallback as N, useContext as P, useEffect as F, useId as I, useImperativeHandle as ne, useLayoutEffect as re, useMemo as L, useReducer as R, useRef as z, useState as B } from "react";
12
+ import { Fragment as V, jsx as H, jsxs as ie } from "react/jsx-runtime";
13
+ import { createPortal as U, flushSync as W } from "react-dom";
14
+ import { createPluginsFromFeatures as G } from "@toolbox-web/grid/features/registry";
14
15
  //#region libs/grid-react/src/lib/column-shorthand.ts
15
- function R(e) {
16
- let { field: t, header: n, type: r } = x(e);
16
+ function K(e) {
17
+ let { field: t, header: n, type: r } = k(e);
17
18
  return r === void 0 ? {
18
19
  field: t,
19
20
  header: n
@@ -23,21 +24,21 @@ function R(e) {
23
24
  type: r
24
25
  };
25
26
  }
26
- function z(e) {
27
- return e.map((e) => typeof e == "string" ? R(e) : e);
27
+ function ae(e) {
28
+ return e.map((e) => typeof e == "string" ? K(e) : e);
28
29
  }
29
- function B(e, t) {
30
+ function oe(e, t) {
30
31
  return t ? e.map((e) => ({
31
32
  ...t,
32
33
  ...e
33
34
  })) : e;
34
35
  }
35
- function V(e) {
36
+ function q(e) {
36
37
  return e.some((e) => typeof e == "string");
37
38
  }
38
39
  //#endregion
39
40
  //#region libs/grid-react/src/lib/event-props.ts
40
- var H = {
41
+ var J = {
41
42
  onCellClick: "cell-click",
42
43
  onRowClick: "row-click",
43
44
  onCellActivate: "cell-activate",
@@ -85,24 +86,24 @@ var H = {
85
86
  onPrintComplete: "print-complete",
86
87
  onTbwScroll: "tbw-scroll",
87
88
  onRender: "render"
88
- }, U = C(null), W = ({ icons: e, children: t }) => /* @__PURE__ */ P(U.Provider, {
89
+ }, Y = j(null), se = ({ icons: e, children: t }) => /* @__PURE__ */ H(Y.Provider, {
89
90
  value: e,
90
91
  children: t
91
92
  });
92
- function G() {
93
- return E(U);
93
+ function ce() {
94
+ return P(Y);
94
95
  }
95
- var ie = U, K = C(null), q = ({ defaults: e, children: t }) => /* @__PURE__ */ P(K.Provider, {
96
+ var le = Y, X = j(null), ue = ({ defaults: e, children: t }) => /* @__PURE__ */ H(X.Provider, {
96
97
  value: e,
97
98
  children: t
98
99
  });
99
- function J() {
100
- return E(K);
100
+ function de() {
101
+ return P(X);
101
102
  }
102
- function Y(e) {
103
- return E(K)?.[e];
103
+ function fe(e) {
104
+ return P(X)?.[e];
104
105
  }
105
- var ae = K, X = class extends S {
106
+ var pe = X, me = class extends A {
106
107
  state = { failed: !1 };
107
108
  static getDerivedStateFromError() {
108
109
  return { failed: !0 };
@@ -113,10 +114,10 @@ var ae = K, X = class extends S {
113
114
  render() {
114
115
  return this.state.failed ? null : this.props.children;
115
116
  }
116
- }, oe = w(function(e, t) {
117
- let n = j(/* @__PURE__ */ new Map()), [, r] = A((e) => e + 1, 0), i = j(!1), a = j(0), o = j(0), s = j(!1), c = j(!1), l = () => {
117
+ }, he = M(function(e, t) {
118
+ let n = z(/* @__PURE__ */ new Map()), [, r] = R((e) => e + 1, 0), i = z(!1), a = z(0), o = z(0), s = z(!1), c = z(!1), l = () => {
118
119
  i.current || (i.current = !0, queueMicrotask(() => {
119
- i.current = !1, !c.current && (I(r), u());
120
+ i.current = !1, !c.current && (W(r), u());
120
121
  }));
121
122
  }, u = () => {
122
123
  a.current ||= requestAnimationFrame(() => {
@@ -125,7 +126,7 @@ var ae = K, X = class extends S {
125
126
  }, d = (e, t) => {
126
127
  console.error(`[grid-react] Portal "${e}" crashed; dropping.`, t), n.current.delete(e), u();
127
128
  };
128
- te(t, () => ({
129
+ ne(t, () => ({
129
130
  renderPortal(e, t, r) {
130
131
  c.current || (n.current.set(e, {
131
132
  container: t,
@@ -137,7 +138,7 @@ var ae = K, X = class extends S {
137
138
  n.current.delete(e);
138
139
  return;
139
140
  }
140
- n.current.delete(e) && (o.current > 0 ? s.current = !0 : t ? I(r) : l());
141
+ n.current.delete(e) && (o.current > 0 ? s.current = !0 : t ? W(r) : l());
141
142
  },
142
143
  beginBatch() {
143
144
  o.current++;
@@ -152,7 +153,7 @@ var ae = K, X = class extends S {
152
153
  }
153
154
  n.current.size > 0 && (n.current.clear(), a.current &&= (cancelAnimationFrame(a.current), 0), l());
154
155
  }
155
- }), []), ne(() => {
156
+ }), []), re(() => {
156
157
  c.current = !1;
157
158
  let e = n.current;
158
159
  return () => {
@@ -165,7 +166,7 @@ var ae = K, X = class extends S {
165
166
  (p ??= []).push(e);
166
167
  continue;
167
168
  }
168
- f.push(F(/* @__PURE__ */ P(X, {
169
+ f.push(U(/* @__PURE__ */ H(me, {
169
170
  portalKey: e,
170
171
  onError: d,
171
172
  children: r
@@ -177,11 +178,11 @@ var ae = K, X = class extends S {
177
178
  for (let t of e) n.current.delete(t);
178
179
  });
179
180
  }
180
- return /* @__PURE__ */ P(N, { children: f });
181
+ return /* @__PURE__ */ H(V, { children: f });
181
182
  });
182
183
  //#endregion
183
184
  //#region libs/grid-react/src/lib/row-diff.ts
184
- function se(e, t, n) {
185
+ function ge(e, t, n) {
185
186
  if (t.length === 0 || e.length !== t.length) return null;
186
187
  let r = [];
187
188
  for (let i = 0; i < e.length; i++) {
@@ -196,117 +197,117 @@ function se(e, t, n) {
196
197
  }
197
198
  //#endregion
198
199
  //#region libs/grid-react/src/lib/use-sync-plugins.ts
199
- var Z = {
200
+ var _e = {
200
201
  undoRedo: ["editing"],
201
202
  clipboard: ["selection"]
202
203
  };
203
- function ce(e) {
204
+ function ve(e) {
204
205
  let t = new Set(e);
205
206
  for (let n of e) {
206
- let e = Z[n];
207
+ let e = _e[n];
207
208
  if (e) for (let r of e) t.has(r) || console.warn(`[DataGrid] Feature "${n}" requires "${r}" to be enabled. Add the "${r}" prop to your DataGrid.`);
208
209
  }
209
210
  }
210
- function le(e) {
211
+ function ye(e) {
211
212
  let t = [];
212
213
  for (let [n, r] of Object.entries(e)) r === void 0 || r === !1 || t.push(n);
213
- return ce(t), L(e);
214
+ return ve(t), G(e);
214
215
  }
215
216
  //#endregion
216
217
  //#region libs/grid-react/src/lib/data-grid.tsx
217
- var ue = !1, Q = null;
218
- function $() {
219
- return ue ||= (Q = new c(), b.registerAdapter(Q), !0), Q;
218
+ var be = !1, Z = null;
219
+ function Q() {
220
+ return be ||= (Z = new u(), ee.registerAdapter(Z), !0), Z;
220
221
  }
221
- $();
222
- var de = /* @__PURE__ */ new WeakMap(), fe = 0;
223
- function pe(e) {
224
- let t = de.get(e);
225
- return t === void 0 && (t = ++fe, de.set(e, t)), t;
222
+ Q();
223
+ var xe = /* @__PURE__ */ new WeakMap(), Se = 0;
224
+ function Ce(e) {
225
+ let t = xe.get(e);
226
+ return t === void 0 && (t = ++Se, xe.set(e, t)), t;
226
227
  }
227
- a("GridDetailPanel", (e) => {
228
+ r("GridDetailPanel", (e) => {
228
229
  let t = e.props;
229
230
  return { masterDetail: {
230
231
  showExpandColumn: t.showExpandColumn ?? !0,
231
232
  animation: t.animation ?? "slide"
232
233
  } };
233
- }), a("GridResponsiveCard", () => ({ responsive: !0 }));
234
- var me = w(function(e, t) {
235
- let { rows: r, gridConfig: i, columns: a, columnDefaults: o, fitMode: s, columnInference: c, sortable: u, filterable: d, selectable: p, loading: h, customStyles: v, className: y, style: x, children: S, plugins: C, onRowsChange: w, ...T } = e, O = j(null), A = j(null), M = j(!1), F = j([]), I = j(void 0), L = E(ae), R = E(ie), V = k(() => {
236
- let e = {}, t = T;
237
- for (let n of l()) {
238
- let r = t[n];
239
- r !== void 0 && (e[n] = r);
234
+ }), r("GridResponsiveCard", () => ({ responsive: !0 }));
235
+ var we = M(function(e, t) {
236
+ let { rows: r, gridConfig: i, columns: a, columnDefaults: s, fitMode: c, columnInference: l, sortable: u, filterable: d, selectable: f, loading: p, customStyles: h, className: v, style: y, children: b, plugins: x, onRowsChange: S, ...C } = e, w = z(null), E = z(null), D = z(!1), O = z([]), k = z(void 0), A = P(pe), j = P(le), M = L(() => {
237
+ let e = {}, t = C;
238
+ for (let r of n()) {
239
+ let n = t[r];
240
+ n !== void 0 && (e[r] = n);
240
241
  }
241
242
  return e;
242
- }, [k(() => l().map((e) => {
243
- let t = T[e];
243
+ }, [L(() => n().map((e) => {
244
+ let t = C[e];
244
245
  if (t === void 0) return "";
245
246
  let n;
246
247
  try {
247
248
  n = JSON.stringify(t) ?? "undefined";
248
249
  } catch {
249
- n = typeof t == "object" && t ? `ref#${pe(t)}` : `prim:${String(t)}`;
250
+ n = typeof t == "object" && t ? `ref#${Ce(t)}` : `prim:${String(t)}`;
250
251
  }
251
252
  return `${e}:${n}`;
252
- }).filter(Boolean).join("|"), [T])]), U = k(() => n(S), [S]), W = k(() => {
253
+ }).filter(Boolean).join("|"), [C])]), N = L(() => o(b), [b]), I = L(() => {
253
254
  let e = i?.features, t = {};
254
- for (let [n, r] of Object.entries(U)) e && n in e && e[n] !== void 0 && e[n] !== !1 || (t[n] = r);
255
+ for (let [n, r] of Object.entries(N)) e && n in e && e[n] !== void 0 && e[n] !== !1 || (t[n] = r);
255
256
  return {
256
257
  ...t,
257
- ...V
258
+ ...M
258
259
  };
259
260
  }, [
260
- V,
261
- U,
261
+ M,
262
+ N,
262
263
  i
263
- ]), G = k(() => C ? [] : le(W), [W, C]), K = k(() => {
264
- if (C) {
265
- let e = new Set(C.map((e) => e.name)), t = G.filter((t) => !e.has(t.name));
266
- return [...C, ...t];
264
+ ]), R = L(() => x ? [] : ye(I), [I, x]), B = L(() => {
265
+ if (x) {
266
+ let e = new Set(x.map((e) => e.name)), t = R.filter((t) => !e.has(t.name));
267
+ return [...x, ...t];
267
268
  }
268
- return G;
269
- }, [C, G]), q = k(() => a && B(z(a), o), [a, o]), J = k(() => {
270
- let e = g(i), t = {};
271
- if (u !== void 0 && (t.sortable = u), d !== void 0 && (t.filterable = d), p !== void 0 && (t.selectable = p), R) {
269
+ return R;
270
+ }, [x, R]), U = L(() => a && oe(ae(a), s), [a, s]), W = L(() => {
271
+ let e = _(i), t = {};
272
+ if (u !== void 0 && (t.sortable = u), d !== void 0 && (t.filterable = d), f !== void 0 && (t.selectable = f), j) {
272
273
  let n = e?.icons || i?.icons || {};
273
274
  t.icons = {
274
- ...R,
275
+ ...j,
275
276
  ...n
276
277
  };
277
278
  }
278
- if (K.length > 0 && e) {
279
- let n = e.plugins || [], r = new Set(n.map((e) => e.name)), i = K.filter((e) => !r.has(e.name));
279
+ if (B.length > 0 && e) {
280
+ let n = e.plugins || [], r = new Set(n.map((e) => e.name)), i = B.filter((e) => !r.has(e.name));
280
281
  return {
281
282
  ...e,
282
283
  ...t,
283
284
  plugins: [...n, ...i]
284
285
  };
285
286
  }
286
- return K.length > 0 && !e ? {
287
+ return B.length > 0 && !e ? {
287
288
  ...t,
288
- plugins: K
289
+ plugins: B
289
290
  } : Object.keys(t).length > 0 ? {
290
291
  ...e,
291
292
  ...t
292
293
  } : e;
293
294
  }, [
294
295
  i,
295
- K,
296
+ B,
296
297
  u,
297
298
  d,
298
- p,
299
- R
299
+ f,
300
+ j
300
301
  ]);
301
- D(() => {
302
- I.current = J?.getRowId;
303
- }, [J]), D(() => {
304
- $().setTypeDefaults(L);
305
- }, [L]), D(() => {
306
- let e = O.current;
302
+ F(() => {
303
+ k.current = W?.getRowId;
304
+ }, [W]), F(() => {
305
+ Q().setTypeDefaults(A);
306
+ }, [A]), F(() => {
307
+ let e = w.current;
307
308
  if (!e) return;
308
- let t = I.current, n = t ? se(r, F.current, t) : null;
309
- if (F.current = r, n !== null) {
309
+ let t = k.current, n = t ? ge(r, O.current, t) : null;
310
+ if (O.current = r, n !== null) {
310
311
  if (n.length > 0) try {
311
312
  e.updateRows(n, "sync");
312
313
  } catch {
@@ -315,129 +316,150 @@ var me = w(function(e, t) {
315
316
  return;
316
317
  }
317
318
  e.rows = r;
318
- }, [r]), D(() => {
319
- O.current && J && (O.current.gridConfig = J);
320
- }, [J]), D(() => {
321
- O.current && q && (O.current.columns = q);
322
- }, [q]), D(() => {
323
- O.current && s !== void 0 && (O.current.fitMode = s);
324
- }, [s]), D(() => {
325
- O.current && (O.current.columnInference = c);
326
- }, [c]), D(() => {
327
- O.current && h !== void 0 && (O.current.loading = h);
328
- }, [h]), D(() => {
329
- let e = O.current;
319
+ }, [r]), F(() => {
320
+ w.current && W && (w.current.gridConfig = W);
321
+ }, [W]), F(() => {
322
+ w.current && U && (w.current.columns = U);
323
+ }, [U]), F(() => {
324
+ w.current && c !== void 0 && (w.current.fitMode = c);
325
+ }, [c]), F(() => {
326
+ w.current && (w.current.columnInference = l);
327
+ }, [l]), F(() => {
328
+ w.current && p !== void 0 && (w.current.loading = p);
329
+ }, [p]), F(() => {
330
+ let e = w.current;
330
331
  if (!e) return;
331
- e.__frameworkAdapter = $(), m(e);
332
+ e.__frameworkAdapter = Q(), g(e);
332
333
  let t = !1, n = requestAnimationFrame(() => {
333
334
  t || (typeof e.refreshColumns == "function" && e.refreshColumns(), typeof e.refreshShellHeader == "function" && e.refreshShellHeader());
334
335
  });
335
336
  return () => {
336
337
  t = !0, cancelAnimationFrame(n);
337
338
  };
338
- }, []), D(() => {
339
- if (!O.current || !v) return;
340
- let e = O.current, t = "react-custom-styles", n = !0;
339
+ }, []), F(() => {
340
+ if (!w.current || !h) return;
341
+ let e = w.current, t = "react-custom-styles", n = !0;
341
342
  return e.ready?.().then(() => {
342
- n && v && (e.registerStyles?.(t, v), A.current = t);
343
+ n && h && (e.registerStyles?.(t, h), E.current = t);
343
344
  }), () => {
344
- n = !1, A.current &&= (e.unregisterStyles?.(A.current), null);
345
+ n = !1, E.current &&= (e.unregisterStyles?.(E.current), null);
345
346
  };
346
- }, [v]), D(() => {
347
- let e = O.current;
347
+ }, [h]), F(() => {
348
+ let e = w.current;
348
349
  if (!e) return;
349
350
  let t = [];
350
- return w && t.push(e.on("rows-change", (e) => w(e.rows))), () => {
351
+ return S && t.push(e.on("rows-change", (e) => S(e.rows))), () => {
351
352
  t.forEach((e) => e());
352
353
  };
353
- }, [w]);
354
- let Y = k(() => Object.keys(H).filter((e) => typeof T[e] == "function").sort().join("|"), [T]), X = j({});
355
- for (let e of Object.keys(H)) X.current[e] = T[e];
356
- D(() => {
357
- let e = O.current;
354
+ }, [S]);
355
+ let G = L(() => Object.keys(J).filter((e) => typeof C[e] == "function").sort().join("|"), [C]), K = z({});
356
+ for (let e of Object.keys(J)) K.current[e] = C[e];
357
+ F(() => {
358
+ let e = w.current;
358
359
  if (!e) return;
359
360
  let t = [];
360
- for (let [n, r] of Object.entries(H)) Y.includes(n) && t.push(e.on(r, (e, t) => {
361
- X.current[n]?.(e, t);
361
+ for (let [n, r] of Object.entries(J)) G.includes(n) && t.push(e.on(r, (e, t) => {
362
+ K.current[n]?.(e, t);
362
363
  }));
363
364
  return () => {
364
365
  t.forEach((e) => e());
365
366
  };
366
- }, [Y]), te(t, () => ({
367
+ }, [G]), ne(t, () => ({
367
368
  get element() {
368
- return O.current;
369
+ return w.current;
369
370
  },
370
371
  async getConfig() {
371
- return O.current?.getConfig?.() ?? {};
372
+ return w.current?.getConfig?.() ?? {};
372
373
  },
373
374
  async ready() {
374
- return O.current?.ready?.();
375
+ return w.current?.ready?.();
375
376
  },
376
377
  async forceLayout() {
377
- return O.current?.forceLayout?.();
378
+ return w.current?.forceLayout?.();
378
379
  },
379
380
  async toggleGroup(e) {
380
- return O.current?.toggleGroup?.(e);
381
+ return w.current?.toggleGroup?.(e);
381
382
  },
382
383
  registerStyles(e, t) {
383
- O.current?.registerStyles?.(e, t);
384
+ w.current?.registerStyles?.(e, t);
384
385
  },
385
386
  unregisterStyles(e) {
386
- O.current?.unregisterStyles?.(e);
387
+ w.current?.unregisterStyles?.(e);
387
388
  },
388
389
  setRowLoading(e, t) {
389
- O.current?.setRowLoading?.(e, t);
390
+ w.current?.setRowLoading?.(e, t);
390
391
  },
391
392
  setCellLoading(e, t, n) {
392
- O.current?.setCellLoading?.(e, t, n);
393
+ w.current?.setCellLoading?.(e, t, n);
393
394
  },
394
395
  isRowLoading(e) {
395
- return O.current?.isRowLoading?.(e) ?? !1;
396
+ return w.current?.isRowLoading?.(e) ?? !1;
396
397
  },
397
398
  isCellLoading(e, t) {
398
- return O.current?.isCellLoading?.(e, t) ?? !1;
399
+ return w.current?.isCellLoading?.(e, t) ?? !1;
399
400
  },
400
401
  clearAllLoading() {
401
- O.current?.clearAllLoading?.();
402
+ w.current?.clearAllLoading?.();
402
403
  }
403
404
  }), []);
404
- let Z = j(null);
405
- return ne(() => {
406
- let e = O.current;
407
- return e && Z.current && f(e, Z.current), () => {
408
- e && f(e, null);
405
+ let q = z(null);
406
+ return re(() => {
407
+ let e = w.current;
408
+ return e && q.current && m(e, q.current), () => {
409
+ e && m(e, null);
409
410
  };
410
- }, []), /* @__PURE__ */ re(N, { children: [/* @__PURE__ */ P(oe, { ref: Z }), ee(b.activeTag, {
411
+ }, []), /* @__PURE__ */ ie(V, { children: [/* @__PURE__ */ H(he, { ref: q }), te(ee.activeTag, {
411
412
  ref: (e) => {
412
- if (O.current = e, e && !M.current) {
413
- M.current = !0;
413
+ if (w.current = e, e && !D.current) {
414
+ D.current = !0;
414
415
  let t = e;
415
- J && (t.gridConfig = J), r && (t.rows = r), q && (t.columns = q);
416
+ W && (t.gridConfig = W), r && (t.rows = r), U && (t.columns = U);
416
417
  }
417
418
  },
418
- class: y,
419
- style: x
420
- }, /* @__PURE__ */ P(_.Provider, {
421
- value: O,
422
- children: S
419
+ class: v,
420
+ style: y
421
+ }, /* @__PURE__ */ H(T.Provider, {
422
+ value: w,
423
+ children: b
423
424
  }))] });
424
425
  });
425
426
  //#endregion
427
+ //#region libs/grid-react/src/lib/column-options.ts
428
+ function Te(e) {
429
+ if (e.length !== 0) return e.map((e) => {
430
+ if (typeof e == "string" || typeof e == "number") return $(String(e));
431
+ let t = $(String(e.value)), n = $(e.label);
432
+ return e.label === t ? t : `${t}:${n}`;
433
+ }).join(",");
434
+ }
435
+ function $(e) {
436
+ return (e.includes(",") || e.includes(":")) && console.warn(`[tbw-grid:column] Option "${e}" contains "," or ":", which the grid's options parser treats as separators. The option list will not round-trip. Use the \`columns\` config instead of the \`options\` prop for such values.`), e;
437
+ }
438
+ //#endregion
426
439
  //#region libs/grid-react/src/lib/grid-column.tsx
427
- function he(e) {
428
- let { field: t, header: n, type: r, editable: a, sortable: s, resizable: c, width: l, minWidth: u, order: d, hidden: f, lockVisible: p, children: m, editor: h, options: g, multi: _, format: v } = e, y = j(null), b = T((e) => {
429
- y.current = e, e && (m && o(e, m), h && i(e, h));
430
- }, [m, h]), x = typeof l == "number" ? `${l}px` : l, S = {
431
- field: t,
432
- ref: b
440
+ function Ee(t) {
441
+ let { field: n, header: r, type: a, editable: o, sortable: c, resizable: u, width: d, minWidth: f, order: p, hidden: m, lockVisible: h, options: g, children: _, editor: v, headerRenderer: y, headerLabelRenderer: b } = t, x = z(null), S = N((t) => {
442
+ x.current = t, t && (_ && e(t, _), v && s(t, v), y && i(t, y), b && l(t, b));
443
+ }, [
444
+ _,
445
+ v,
446
+ y,
447
+ b
448
+ ]), C = typeof d == "number" ? `${d}px` : d, w = {
449
+ field: n,
450
+ ref: S
433
451
  };
434
- return n !== void 0 && (S.header = n), r !== void 0 && (S.type = r), a !== void 0 && (S.editable = a), s !== void 0 && (S.sortable = s), c !== void 0 && (S.resizable = c), x !== void 0 && (S.width = x), u !== void 0 && (S["min-width"] = u), d !== void 0 && (S.order = d), f !== void 0 && (S.hidden = f), p !== void 0 && (S["lock-visible"] = p), _ !== void 0 && (S.multi = _), v && (S["data-has-format"] = "true"), g && (S["data-has-options"] = "true"), /* @__PURE__ */ P("tbw-grid-column", { ...S });
452
+ if (r !== void 0 && (w.header = r), a !== void 0 && (w.type = a), o !== void 0 && (w.editable = o), c !== void 0 && (w.sortable = c), u !== void 0 && (w.resizable = u), C !== void 0 && (w.width = C), f !== void 0 && (w["min-width"] = f), p !== void 0 && (w.order = p), m !== void 0 && (w.hidden = m), h !== void 0 && (w["lock-visible"] = h), g) {
453
+ let e = Te(g);
454
+ e !== void 0 && (w.options = e);
455
+ }
456
+ return /* @__PURE__ */ H("tbw-grid-column", { ...w });
435
457
  }
436
458
  //#endregion
437
459
  //#region libs/grid-react/src/lib/grid-header-content.tsx
438
- function ge({ id: e, order: t = 100, children: n }) {
439
- let r = O(), i = e ?? `tbw-header-content-${r}`, a = E(_), [o, s] = M(null), c = j(null);
440
- return D(() => {
460
+ function De({ id: e, order: t = 100, children: n }) {
461
+ let r = I(), i = e ?? `tbw-header-content-${r}`, a = P(T), [o, s] = B(null), c = z(null);
462
+ return F(() => {
441
463
  let e = a?.current;
442
464
  if (!e) return;
443
465
  let n = c, r = !1;
@@ -455,16 +477,16 @@ function ge({ id: e, order: t = 100, children: n }) {
455
477
  };
456
478
  e.getPluginByName?.("shell")?.registerHeaderContent(n);
457
479
  })(), () => {
458
- r = !0, e.getPluginByName?.("shell")?.unregisterHeaderContent(i), n.current &&= (d(n.current, { sync: !0 }), null), s(null);
480
+ r = !0, e.getPluginByName?.("shell")?.unregisterHeaderContent(i), n.current &&= (p(n.current, { sync: !0 }), null), s(null);
459
481
  };
460
482
  }, [
461
483
  a,
462
484
  i,
463
485
  t
464
- ]), D(() => {
486
+ ]), F(() => {
465
487
  if (!o) return;
466
488
  let e = a?.current ?? void 0;
467
- c.current = u(o, n, c.current ?? void 0, e);
489
+ c.current = f(o, n, c.current ?? void 0, e);
468
490
  }, [
469
491
  n,
470
492
  o,
@@ -473,14 +495,14 @@ function ge({ id: e, order: t = 100, children: n }) {
473
495
  }
474
496
  //#endregion
475
497
  //#region libs/grid-react/src/lib/grid-tool-button.tsx
476
- function _e({ children: e }) {
477
- return /* @__PURE__ */ P("tbw-grid-tool-buttons", { children: e });
498
+ function Oe({ children: e }) {
499
+ return /* @__PURE__ */ H("tbw-grid-tool-buttons", { children: e });
478
500
  }
479
501
  //#endregion
480
502
  //#region libs/grid-react/src/lib/grid-toolbar-content.tsx
481
- function ve({ id: e, order: t = 100, children: n }) {
482
- let r = O(), i = e ?? `tbw-toolbar-content-${r}`, a = E(_), [o, s] = M(null), c = j(null);
483
- return D(() => {
503
+ function ke({ id: e, order: t = 100, children: n }) {
504
+ let r = I(), i = e ?? `tbw-toolbar-content-${r}`, a = P(T), [o, s] = B(null), c = z(null);
505
+ return F(() => {
484
506
  let e = a?.current;
485
507
  if (!e) return;
486
508
  let n = c, r = !1;
@@ -498,16 +520,16 @@ function ve({ id: e, order: t = 100, children: n }) {
498
520
  };
499
521
  e.getPluginByName?.("shell")?.registerToolbarContent(n);
500
522
  })(), () => {
501
- r = !0, e.getPluginByName?.("shell")?.unregisterToolbarContent(i), n.current &&= (d(n.current, { sync: !0 }), null), s(null);
523
+ r = !0, e.getPluginByName?.("shell")?.unregisterToolbarContent(i), n.current &&= (p(n.current, { sync: !0 }), null), s(null);
502
524
  };
503
525
  }, [
504
526
  a,
505
527
  i,
506
528
  t
507
- ]), D(() => {
529
+ ]), F(() => {
508
530
  if (!o) return;
509
531
  let e = a?.current ?? void 0;
510
- c.current = u(o, n, c.current ?? void 0, e);
532
+ c.current = f(o, n, c.current ?? void 0, e);
511
533
  }, [
512
534
  n,
513
535
  o,
@@ -516,107 +538,98 @@ function ve({ id: e, order: t = 100, children: n }) {
516
538
  }
517
539
  //#endregion
518
540
  //#region libs/grid-react/src/lib/grid-type.tsx
519
- function ye(e) {
541
+ function Ae(e) {
520
542
  return e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
521
543
  }
522
- function be(t) {
523
- let { name: n, params: r, children: i, editor: a } = t, o = j(null), c = {
524
- name: n,
525
- ref: T((t) => {
526
- o.current = t, t && (i && e(t, i), a && s(t, a));
527
- }, [i, a])
544
+ function je(e) {
545
+ let { name: t, params: n, children: r, editor: i } = e, o = z(null), s = {
546
+ name: t,
547
+ ref: N((e) => {
548
+ o.current = e, e && (r && d(e, r), i && a(e, i));
549
+ }, [r, i])
528
550
  };
529
- if (r) for (let [e, t] of Object.entries(r)) c[`data-${ye(e)}`] = String(t);
530
- return /* @__PURE__ */ re("tbw-grid-type", {
531
- ...c,
532
- children: [i ? /* @__PURE__ */ P("tbw-grid-column-view", {}) : null, a ? /* @__PURE__ */ P("tbw-grid-column-editor", {}) : null]
551
+ if (n) for (let [e, t] of Object.entries(n)) s[`data-${Ae(e)}`] = String(t);
552
+ return /* @__PURE__ */ ie("tbw-grid-type", {
553
+ ...s,
554
+ children: [r ? /* @__PURE__ */ H("tbw-grid-column-view", {}) : null, i ? /* @__PURE__ */ H("tbw-grid-column-editor", {}) : null]
533
555
  });
534
556
  }
535
557
  //#endregion
536
558
  //#region libs/grid-react/src/lib/grid-provider.tsx
537
- var xe = ({ icons: e, defaults: t, children: n }) => {
559
+ var Me = ({ icons: e, defaults: t, children: n }) => {
538
560
  let r = n;
539
- return t && (r = /* @__PURE__ */ P(q, {
561
+ return t && (r = /* @__PURE__ */ H(ue, {
540
562
  defaults: t,
541
563
  children: r
542
- })), e && (r = /* @__PURE__ */ P(W, {
564
+ })), e && (r = /* @__PURE__ */ H(se, {
543
565
  icons: e,
544
566
  children: r
545
- })), /* @__PURE__ */ P(N, { children: r });
567
+ })), /* @__PURE__ */ H(V, { children: r });
546
568
  };
547
569
  //#endregion
548
570
  //#region libs/grid-react/src/lib/use-grid.ts
549
- function Se(e) {
550
- let t = j(null), [n, r] = M(!1), [i, a] = M(null), o = j(null), s = T(() => e ? (o.current ??= document.querySelector(e), o.current) : t.current?.element ?? null, [e]);
551
- D(() => {
552
- let n = !0;
553
- return (async () => {
554
- try {
555
- if (e) {
556
- let t = document.querySelector(e);
557
- if (!t) return;
558
- if (o.current = t, await t.ready?.(), n) {
559
- r(!0);
560
- let e = await t.getConfig?.();
561
- n && e && a(e);
562
- }
563
- } else {
564
- let e = t.current;
565
- if (!e) return;
566
- if (await e.ready?.(), n) {
567
- r(!0);
568
- let t = await e.getConfig?.();
569
- n && t && a(t);
570
- }
571
- }
572
- } catch {}
573
- })(), () => {
574
- n = !1;
571
+ function Ne(e) {
572
+ let t = z(null), [n, r] = B(null), i = z(null), a = N(() => e ? (i.current ??= document.querySelector(e), i.current) : t.current?.element ?? null, [e]), o = O(a);
573
+ F(() => {
574
+ if (!o) return;
575
+ let e = !0, t = a();
576
+ if (t) return Promise.resolve(t.getConfig?.()).then((t) => {
577
+ e && t && r(t);
578
+ }).catch(() => {}), () => {
579
+ e = !1;
575
580
  };
576
- }, [e]);
577
- let c = T(async () => {
578
- let e = s();
581
+ }, [o, a]);
582
+ let s = N(async () => {
583
+ let e = a();
579
584
  if (e) return await e.getConfig?.() ?? null;
580
585
  let n = t.current;
581
586
  return n ? await n.getConfig?.() ?? null : null;
582
- }, [s]), l = T(async () => {
583
- let e = s();
587
+ }, [a]), c = N(async () => {
588
+ let e = a();
584
589
  if (e) {
585
590
  await e.forceLayout?.();
586
591
  return;
587
592
  }
588
593
  let n = t.current;
589
594
  n && await n.forceLayout?.();
590
- }, [s]), u = T(async (e) => {
591
- let n = s();
595
+ }, [a]), l = N(async () => {
596
+ let e = a();
597
+ if (e) {
598
+ await e.ready?.();
599
+ return;
600
+ }
601
+ await t.current?.ready?.();
602
+ }, [a]), u = N(async (e) => {
603
+ let n = a();
592
604
  if (n) {
593
605
  await n.toggleGroup?.(e);
594
606
  return;
595
607
  }
596
608
  let r = t.current;
597
609
  r && await r.toggleGroup?.(e);
598
- }, [s]), d = T((e) => s()?.getPlugin?.(e), [s]), f = T(((e) => s()?.getPluginByName?.(e)), [s]), p = T((e, n) => {
599
- let r = s();
610
+ }, [a]), d = N((e) => a()?.getPlugin?.(e), [a]), f = N(((e) => a()?.getPluginByName?.(e)), [a]), p = N((e, n) => {
611
+ let r = a();
600
612
  if (r) {
601
613
  r.registerStyles?.(e, n);
602
614
  return;
603
615
  }
604
616
  t.current?.registerStyles?.(e, n);
605
- }, [s]), m = T((e) => {
606
- let n = s();
617
+ }, [a]), m = N((e) => {
618
+ let n = a();
607
619
  if (n) {
608
620
  n.unregisterStyles?.(e);
609
621
  return;
610
622
  }
611
623
  t.current?.unregisterStyles?.(e);
612
- }, [s]), h = T(() => i?.columns ? i.columns.filter((e) => !e.hidden) : [], [i]);
624
+ }, [a]), h = N(() => n?.columns ? n.columns.filter((e) => !e.hidden) : [], [n]);
613
625
  return {
614
626
  ref: t,
615
- element: s(),
616
- isReady: n,
617
- config: i,
618
- getConfig: c,
619
- forceLayout: l,
627
+ element: a(),
628
+ isReady: o,
629
+ config: n,
630
+ getConfig: s,
631
+ ready: l,
632
+ forceLayout: c,
620
633
  toggleGroup: u,
621
634
  getPlugin: d,
622
635
  getPluginByName: f,
@@ -627,9 +640,9 @@ function Se(e) {
627
640
  }
628
641
  //#endregion
629
642
  //#region libs/grid-react/src/lib/use-grid-overlay.ts
630
- function Ce(e, t = {}) {
631
- let { open: n = !0, gridElement: r } = t, i = E(_);
632
- D(() => {
643
+ function Pe(e, t = {}) {
644
+ let { open: n = !0, gridElement: r } = t, i = P(T);
645
+ F(() => {
633
646
  if (!n) return;
634
647
  let t = e.current;
635
648
  if (!t) return;
@@ -645,4 +658,4 @@ function Ce(e, t = {}) {
645
658
  ]);
646
659
  }
647
660
  //#endregion
648
- export { me as DataGrid, c as GridAdapter, he as GridColumn, v as GridDetailPanel, ge as GridHeaderContent, W as GridIconProvider, xe as GridProvider, y as GridResponsiveCard, _e as GridToolButtons, r as GridToolPanel, ve as GridToolbarContent, be as GridType, q as GridTypeProvider, B as applyColumnDefaults, V as hasColumnShorthands, z as normalizeColumns, R as parseColumnShorthand, a as registerChildFeatureDetector, h as registerEditorMountHook, t as registerFeaturePropKey, p as registerPostMountRefresh, Se as useGrid, G as useGridIcons, Ce as useGridOverlay, J as useGridTypeDefaults, Y as useTypeDefault };
661
+ export { we as DataGrid, u as GridAdapter, Ee as GridColumn, E as GridDetailPanel, De as GridHeaderContent, se as GridIconProvider, Me as GridProvider, D as GridResponsiveCard, Oe as GridToolButtons, t as GridToolPanel, ke as GridToolbarContent, je as GridType, ue as GridTypeProvider, oe as applyColumnDefaults, w as clearFeatureRegistry, x as createPluginFromFeature, C as getFeatureFactory, b as getRegisteredFeatures, q as hasColumnShorthands, y as isFeatureRegistered, ae as normalizeColumns, K as parseColumnShorthand, r as registerChildFeatureDetector, v as registerEditorMountHook, S as registerFeature, c as registerFeaturePropKey, h as registerPostMountRefresh, Ne as useGrid, ce as useGridIcons, Pe as useGridOverlay, de as useGridTypeDefaults, fe as useTypeDefault };