@toolbox-web/grid-react 1.10.0 → 2.0.0-beta.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,69 +1,48 @@
1
- import { jsx as E, Fragment as W, jsxs as ve } from "react/jsx-runtime";
2
- import { DataGridElement as ae } from "@toolbox-web/grid";
3
- import { Children as we, isValidElement as Re, createContext as le, useContext as k, forwardRef as fe, useRef as G, useReducer as be, useImperativeHandle as de, useLayoutEffect as ge, Component as Pe, useMemo as T, useEffect as P, createElement as Ge, useCallback as F, useId as pe, useState as O } from "react";
4
- import { g as ne, G as Se, c as xe, d as Ee } from "./chunks/react-grid-adapter-LBf2Mqhn.js";
5
- import { e as vr, f as wr } from "./chunks/react-grid-adapter-LBf2Mqhn.js";
6
- import { s as oe, r as me, a as Ce } from "./chunks/portal-bridge-CvxNt40O.js";
7
- import { flushSync as ie, createPortal as De } from "react-dom";
8
- import { n as Fe } from "./chunks/post-mount-refresh-hooks-Dt7mPoZC.js";
9
- import { r as br } from "./chunks/post-mount-refresh-hooks-Dt7mPoZC.js";
10
- import { p as Te } from "./chunks/react-column-config-BOe_PgL1.js";
11
- import { r as Gr } from "./chunks/react-column-config-BOe_PgL1.js";
12
- import { createPluginsFromFeatures as ke } from "@toolbox-web/grid/features/registry";
13
- import { G as H } from "./chunks/grid-element-context-BU3WvNtM.js";
1
+ import { jsx as S, Fragment as U, jsxs as ce } from "react/jsx-runtime";
2
+ import { parseColumnShorthand as Ce, DataGridElement as ue } from "@toolbox-web/grid";
3
+ import { Children as ve, isValidElement as we, createContext as ae, useContext as k, forwardRef as le, useRef as b, useReducer as Re, useImperativeHandle as fe, useLayoutEffect as de, Component as be, useMemo as T, useEffect as R, createElement as Pe, useCallback as E, useId as ge, useState as A } from "react";
4
+ import { g as te, G as Ge, c as Se, d as Ee, e as xe, f as Fe } from "./chunks/react-grid-adapter-BhC9x425.js";
5
+ import { h as wr, i as Rr } from "./chunks/react-grid-adapter-BhC9x425.js";
6
+ import { s as ne, r as pe, a as me } from "./chunks/portal-bridge-CvxNt40O.js";
7
+ import { flushSync as oe, createPortal as De } from "react-dom";
8
+ import { n as Te } from "./chunks/post-mount-refresh-hooks-Dt7mPoZC.js";
9
+ import { r as Pr } from "./chunks/post-mount-refresh-hooks-Dt7mPoZC.js";
10
+ import { p as ke } from "./chunks/react-column-config-BOe_PgL1.js";
11
+ import { r as Sr } from "./chunks/react-column-config-BOe_PgL1.js";
12
+ import { createPluginsFromFeatures as Me } from "@toolbox-web/grid/features/registry";
13
+ import { G as $ } from "./chunks/grid-element-context-BU3WvNtM.js";
14
14
  import { G as xr } from "./chunks/grid-detail-panel-BZFcujsZ.js";
15
15
  import { G as Dr } from "./chunks/grid-responsive-card-CSZhDCoN.js";
16
- const V = /* @__PURE__ */ new Map();
16
+ const _ = /* @__PURE__ */ new Map();
17
17
  function ye(t, r) {
18
- V.set(t, r);
18
+ _.set(t, r);
19
19
  }
20
20
  function Ie(t) {
21
21
  const r = {};
22
- return V.size === 0 || we.forEach(t, (d) => {
23
- if (!Re(d)) return;
24
- const n = d.type, s = typeof n == "string" ? void 0 : n?.displayName;
25
- if (typeof s != "string") return;
26
- const g = V.get(s);
27
- if (!g) return;
28
- const l = g(d);
29
- l && Object.assign(r, l);
22
+ return _.size === 0 || ve.forEach(t, (l) => {
23
+ if (!we(l)) return;
24
+ const n = l.type, c = typeof n == "string" ? void 0 : n?.displayName;
25
+ if (typeof c != "string") return;
26
+ const d = _.get(c);
27
+ if (!d) return;
28
+ const f = d(l);
29
+ f && Object.assign(r, f);
30
30
  }), r;
31
31
  }
32
32
  function Le(t) {
33
- return t.charAt(0).toUpperCase() + t.slice(1);
34
- }
35
- function se(t) {
36
- return t.toLowerCase() === "id" ? "ID" : t.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").split(" ").filter(Boolean).map(Le).join(" ");
37
- }
38
- const Ae = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime", "currency"]);
39
- function Me(t) {
40
- const r = t.lastIndexOf(":");
41
- if (r > 0) {
42
- const d = t.slice(r + 1).toLowerCase();
43
- if (Ae.has(d)) {
44
- const n = t.slice(0, r);
45
- return {
46
- field: n,
47
- header: se(n),
48
- type: d
49
- };
50
- }
51
- }
52
- return {
53
- field: t,
54
- header: se(t)
55
- };
33
+ const { field: r, header: l, type: n } = Ce(t);
34
+ return n === void 0 ? { field: r, header: l } : { field: r, header: l, type: n };
56
35
  }
57
36
  function Ne(t) {
58
- return t.map((r) => typeof r == "string" ? Me(r) : r);
37
+ return t.map((r) => typeof r == "string" ? Le(r) : r);
59
38
  }
60
- function Oe(t, r) {
61
- return r ? t.map((d) => ({ ...r, ...d })) : t;
39
+ function Ae(t, r) {
40
+ return r ? t.map((l) => ({ ...r, ...l })) : t;
62
41
  }
63
42
  function ir(t) {
64
43
  return t.some((r) => typeof r == "string");
65
44
  }
66
- const _ = {
45
+ const H = {
67
46
  onCellClick: "cell-click",
68
47
  onRowClick: "row-click",
69
48
  onCellActivate: "cell-activate",
@@ -106,19 +85,19 @@ const _ = {
106
85
  onPrintComplete: "print-complete",
107
86
  onTbwScroll: "tbw-scroll",
108
87
  onRender: "render"
109
- }, J = le(null), He = ({ icons: t, children: r }) => /* @__PURE__ */ E(J.Provider, { value: t, children: r });
88
+ }, W = ae(null), $e = ({ icons: t, children: r }) => /* @__PURE__ */ S(W.Provider, { value: t, children: r });
110
89
  function sr() {
111
- return k(J);
90
+ return k(W);
112
91
  }
113
- const $e = J, $ = le(null), je = ({ defaults: t, children: r }) => /* @__PURE__ */ E($.Provider, { value: t, children: r });
92
+ const Oe = W, O = ae(null), je = ({ defaults: t, children: r }) => /* @__PURE__ */ S(O.Provider, { value: t, children: r });
114
93
  function cr() {
115
- return k($);
94
+ return k(O);
116
95
  }
117
96
  function ur(t) {
118
- return k($)?.[t];
97
+ return k(O)?.[t];
119
98
  }
120
- const Be = $;
121
- class ze extends Pe {
99
+ const Be = O;
100
+ class ze extends be {
122
101
  state = { failed: !1 };
123
102
  static getDerivedStateFromError() {
124
103
  return { failed: !0 };
@@ -130,108 +109,108 @@ class ze extends Pe {
130
109
  return this.state.failed ? null : this.props.children;
131
110
  }
132
111
  }
133
- const Ke = fe(function(r, d) {
134
- const n = G(/* @__PURE__ */ new Map()), [, s] = be((m) => m + 1, 0), g = G(!1), l = G(0), a = G(0), w = G(!1), f = G(!1), h = () => {
135
- g.current || (g.current = !0, queueMicrotask(() => {
136
- g.current = !1, !f.current && (ie(s), b());
112
+ const Ke = le(function(r, l) {
113
+ const n = b(/* @__PURE__ */ new Map()), [, c] = Re((y) => y + 1, 0), d = b(!1), f = b(0), u = b(0), m = b(!1), g = b(!1), C = () => {
114
+ d.current || (d.current = !0, queueMicrotask(() => {
115
+ d.current = !1, !g.current && (oe(c), v());
137
116
  }));
138
- }, b = () => {
139
- l.current || (l.current = requestAnimationFrame(() => {
140
- l.current = 0, !f.current && s();
117
+ }, v = () => {
118
+ f.current || (f.current = requestAnimationFrame(() => {
119
+ f.current = 0, !g.current && c();
141
120
  }));
142
- }, C = (m, i) => {
143
- console.error(`[grid-react] Portal "${m}" crashed; dropping.`, i), n.current.delete(m), b();
121
+ }, G = (y, s) => {
122
+ console.error(`[grid-react] Portal "${y}" crashed; dropping.`, s), n.current.delete(y), v();
144
123
  };
145
- de(
146
- d,
124
+ fe(
125
+ l,
147
126
  () => ({
148
- renderPortal(m, i, p) {
149
- f.current || (n.current.set(m, { container: i, element: p }), h());
127
+ renderPortal(y, s, p) {
128
+ g.current || (n.current.set(y, { container: s, element: p }), C());
150
129
  },
151
- removePortal(m, i) {
152
- if (f.current) {
153
- n.current.delete(m);
130
+ removePortal(y, s) {
131
+ if (g.current) {
132
+ n.current.delete(y);
154
133
  return;
155
134
  }
156
- n.current.delete(m) && (a.current > 0 ? w.current = !0 : i ? ie(s) : h());
135
+ n.current.delete(y) && (u.current > 0 ? m.current = !0 : s ? oe(c) : C());
157
136
  },
158
137
  beginBatch() {
159
- a.current++;
138
+ u.current++;
160
139
  },
161
140
  endBatch() {
162
- a.current !== 0 && (a.current--, a.current === 0 && w.current && (w.current = !1, s()));
141
+ u.current !== 0 && (u.current--, u.current === 0 && m.current && (m.current = !1, c()));
163
142
  },
164
143
  clear() {
165
- if (f.current) {
144
+ if (g.current) {
166
145
  n.current.clear();
167
146
  return;
168
147
  }
169
- n.current.size > 0 && (n.current.clear(), l.current && (cancelAnimationFrame(l.current), l.current = 0), h());
148
+ n.current.size > 0 && (n.current.clear(), f.current && (cancelAnimationFrame(f.current), f.current = 0), C());
170
149
  }
171
150
  }),
172
151
  // forceRender is stable (useReducer dispatch), refs are stable
173
152
  // eslint-disable-next-line react-hooks/exhaustive-deps
174
153
  []
175
- ), ge(() => {
176
- f.current = !1;
177
- const m = n.current;
154
+ ), de(() => {
155
+ g.current = !1;
156
+ const y = n.current;
178
157
  return () => {
179
- f.current = !0, l.current && (cancelAnimationFrame(l.current), l.current = 0), m.clear();
158
+ g.current = !0, f.current && (cancelAnimationFrame(f.current), f.current = 0), y.clear();
180
159
  };
181
160
  }, []);
182
- const R = [];
183
- let S = null;
184
- for (const [m, { container: i, element: p }] of n.current) {
185
- if (!i.isConnected) {
186
- (S ??= []).push(m);
161
+ const w = [];
162
+ let F = null;
163
+ for (const [y, { container: s, element: p }] of n.current) {
164
+ if (!s.isConnected) {
165
+ (F ??= []).push(y);
187
166
  continue;
188
167
  }
189
- R.push(
168
+ w.push(
190
169
  De(
191
- /* @__PURE__ */ E(ze, { portalKey: m, onError: C, children: p }),
192
- i,
193
- m
170
+ /* @__PURE__ */ S(ze, { portalKey: y, onError: G, children: p }),
171
+ s,
172
+ y
194
173
  )
195
174
  );
196
175
  }
197
- if (S) {
198
- const m = S;
176
+ if (F) {
177
+ const y = F;
199
178
  queueMicrotask(() => {
200
- for (const i of m) n.current.delete(i);
179
+ for (const s of y) n.current.delete(s);
201
180
  });
202
181
  }
203
- return /* @__PURE__ */ E(W, { children: R });
204
- }), _e = {
182
+ return /* @__PURE__ */ S(U, { children: w });
183
+ }), He = {
205
184
  undoRedo: ["editing"],
206
185
  clipboard: ["selection"]
207
186
  };
208
187
  function qe(t) {
209
188
  const r = new Set(t);
210
- for (const d of t) {
211
- const n = _e[d];
189
+ for (const l of t) {
190
+ const n = He[l];
212
191
  if (n)
213
- for (const s of n)
214
- r.has(s) || console.warn(
215
- `[DataGrid] Feature "${d}" requires "${s}" to be enabled. Add the "${s}" prop to your DataGrid.`
192
+ for (const c of n)
193
+ r.has(c) || console.warn(
194
+ `[DataGrid] Feature "${l}" requires "${c}" to be enabled. Add the "${c}" prop to your DataGrid.`
216
195
  );
217
196
  }
218
197
  }
219
- function Ve(t) {
198
+ function _e(t) {
220
199
  const r = [];
221
- for (const [d, n] of Object.entries(t))
222
- n === void 0 || n === !1 || r.push(d);
223
- return qe(r), ke(t);
200
+ for (const [l, n] of Object.entries(t))
201
+ n === void 0 || n === !1 || r.push(l);
202
+ return qe(r), Me(t);
224
203
  }
225
- let ce = !1, q = null;
226
- function U() {
227
- return ce || (q = new Se(), ae.registerAdapter(q), ce = !0), q;
204
+ let ie = !1, q = null;
205
+ function V() {
206
+ return ie || (q = new Ge(), ue.registerAdapter(q), ie = !0), q;
228
207
  }
229
- U();
230
- const ue = /* @__PURE__ */ new WeakMap();
231
- let Ue = 0;
232
- function We(t) {
233
- let r = ue.get(t);
234
- return r === void 0 && (r = ++Ue, ue.set(t, r)), r;
208
+ V();
209
+ const se = /* @__PURE__ */ new WeakMap();
210
+ let Ve = 0;
211
+ function Ue(t) {
212
+ let r = se.get(t);
213
+ return r === void 0 && (r = ++Ve, se.set(t, r)), r;
235
214
  }
236
215
  ye("GridDetailPanel", (t) => {
237
216
  const r = t.props;
@@ -248,434 +227,450 @@ ye("GridResponsiveCard", () => ({
248
227
  // responsive prop. Enable the plugin with defaults — user can override.
249
228
  responsive: !0
250
229
  }));
251
- const ar = fe(function(r, d) {
230
+ const ar = le(function(r, l) {
252
231
  const {
253
232
  // Core props
254
233
  rows: n,
255
- gridConfig: s,
256
- columns: g,
257
- columnDefaults: l,
258
- fitMode: a,
259
- columnInference: w,
260
- sortable: f,
261
- filterable: h,
262
- selectable: b,
263
- loading: C,
264
- customStyles: R,
265
- className: S,
266
- style: m,
267
- children: i,
234
+ gridConfig: c,
235
+ columns: d,
236
+ columnDefaults: f,
237
+ fitMode: u,
238
+ columnInference: m,
239
+ sortable: g,
240
+ filterable: C,
241
+ selectable: v,
242
+ loading: G,
243
+ customStyles: w,
244
+ className: F,
245
+ style: y,
246
+ children: s,
268
247
  // Plugin props
269
248
  plugins: p,
270
- // SSR mode (deprecated - see SSRProps)
271
- ssr: v,
272
249
  // Legacy event handlers
273
- onRowsChange: x,
250
+ onRowsChange: h,
274
251
  // Feature props and event props are in ...rest
275
- ...y
276
- } = r, c = G(null), N = G(null), Y = G(!1), Z = k(Be), j = k($e), he = T(() => ne().map((e) => {
277
- const o = y[e];
278
- if (o === void 0) return "";
279
- let u;
252
+ ...P
253
+ } = r, o = b(null), D = b(null), J = b(!1), Z = k(Be), j = k(Oe), he = T(() => te().map((e) => {
254
+ const i = P[e];
255
+ if (i === void 0) return "";
256
+ let a;
280
257
  try {
281
- u = JSON.stringify(o) ?? "undefined";
258
+ a = JSON.stringify(i) ?? "undefined";
282
259
  } catch {
283
- u = typeof o == "object" && o !== null ? `ref#${We(o)}` : `prim:${String(o)}`;
260
+ a = typeof i == "object" && i !== null ? `ref#${Ue(i)}` : `prim:${String(i)}`;
284
261
  }
285
- return `${e}:${u}`;
286
- }).filter(Boolean).join("|"), [y]), Q = T(() => {
287
- const e = {}, o = y;
288
- for (const u of ne()) {
289
- const D = o[u];
290
- D !== void 0 && (e[u] = D);
262
+ return `${e}:${a}`;
263
+ }).filter(Boolean).join("|"), [P]), Q = T(() => {
264
+ const e = {}, i = P;
265
+ for (const a of te()) {
266
+ const x = i[a];
267
+ x !== void 0 && (e[a] = x);
291
268
  }
292
269
  return e;
293
- }, [he]), X = T(() => Ie(i), [i]), ee = T(() => {
294
- const e = s?.features, o = {};
295
- for (const [u, D] of Object.entries(X))
296
- e && u in e && e[u] !== void 0 && e[u] !== !1 || (o[u] = D);
297
- return { ...o, ...Q };
298
- }, [Q, X, s]), B = T(() => p || v ? [] : Ve(ee), [ee, p, v]), I = T(() => {
270
+ }, [he]), X = T(() => Ie(s), [s]), Y = T(() => {
271
+ const e = c?.features, i = {};
272
+ for (const [a, x] of Object.entries(X))
273
+ e && a in e && e[a] !== void 0 && e[a] !== !1 || (i[a] = x);
274
+ return { ...i, ...Q };
275
+ }, [Q, X, c]), B = T(() => p ? [] : _e(Y), [Y, p]), M = T(() => {
299
276
  if (p) {
300
- const e = new Set(p.map((u) => u.name)), o = B.filter((u) => !e.has(u.name));
301
- return [...p, ...o];
277
+ const e = new Set(p.map((a) => a.name)), i = B.filter((a) => !e.has(a.name));
278
+ return [...p, ...i];
302
279
  }
303
280
  return B;
304
- }, [p, B]), L = T(() => g && Oe(Ne(g), l), [g, l]), A = T(() => {
305
- const e = Te(s), o = {};
306
- if (f !== void 0 && (o.sortable = f), h !== void 0 && (o.filterable = h), b !== void 0 && (o.selectable = b), j) {
307
- const u = e?.icons || s?.icons || {};
308
- o.icons = { ...j, ...u };
281
+ }, [p, B]), I = T(() => d && Ae(Ne(d), f), [d, f]), L = T(() => {
282
+ const e = ke(c), i = {};
283
+ if (g !== void 0 && (i.sortable = g), C !== void 0 && (i.filterable = C), v !== void 0 && (i.selectable = v), j) {
284
+ const a = e?.icons || c?.icons || {};
285
+ i.icons = { ...j, ...a };
309
286
  }
310
- if (I.length > 0 && e) {
311
- const u = e.plugins || [], D = new Set(u.map((M) => M.name)), K = I.filter((M) => !D.has(M.name));
287
+ if (M.length > 0 && e) {
288
+ const a = e.plugins || [], x = new Set(a.map((N) => N.name)), K = M.filter((N) => !x.has(N.name));
312
289
  return {
313
290
  ...e,
314
- ...o,
315
- plugins: [...u, ...K]
291
+ ...i,
292
+ plugins: [...a, ...K]
316
293
  };
317
294
  }
318
- return I.length > 0 && !e ? { ...o, plugins: I } : Object.keys(o).length > 0 ? { ...e, ...o } : e;
319
- }, [s, I, f, h, b, j]);
320
- P(() => {
321
- U().setTypeDefaults(Z);
322
- }, [Z]), P(() => {
323
- c.current && (c.current.rows = n);
324
- }, [n]), P(() => {
325
- c.current && A && (c.current.gridConfig = A);
326
- }, [A]), P(() => {
327
- c.current && L && (c.current.columns = L);
328
- }, [L]), P(() => {
329
- c.current && a !== void 0 && (c.current.fitMode = a);
330
- }, [a]), P(() => {
331
- c.current && (c.current.columnInference = w);
332
- }, [w]), P(() => {
333
- c.current && C !== void 0 && (c.current.loading = C);
334
- }, [C]), P(() => {
335
- const e = c.current;
295
+ return M.length > 0 && !e ? { ...i, plugins: M } : Object.keys(i).length > 0 ? { ...e, ...i } : e;
296
+ }, [c, M, g, C, v, j]);
297
+ R(() => {
298
+ V().setTypeDefaults(Z);
299
+ }, [Z]), R(() => {
300
+ o.current && (o.current.rows = n);
301
+ }, [n]), R(() => {
302
+ o.current && L && (o.current.gridConfig = L);
303
+ }, [L]), R(() => {
304
+ o.current && I && (o.current.columns = I);
305
+ }, [I]), R(() => {
306
+ o.current && u !== void 0 && (o.current.fitMode = u);
307
+ }, [u]), R(() => {
308
+ o.current && (o.current.columnInference = m);
309
+ }, [m]), R(() => {
310
+ o.current && G !== void 0 && (o.current.loading = G);
311
+ }, [G]), R(() => {
312
+ const e = o.current;
336
313
  if (!e) return;
337
- const o = U();
338
- e.__frameworkAdapter = o, Fe(e);
339
- let u = !1;
340
- const D = requestAnimationFrame(() => {
341
- u || (typeof e.refreshColumns == "function" && e.refreshColumns(), typeof e.refreshShellHeader == "function" && e.refreshShellHeader());
314
+ const i = V();
315
+ e.__frameworkAdapter = i, Te(e);
316
+ let a = !1;
317
+ const x = requestAnimationFrame(() => {
318
+ a || (typeof e.refreshColumns == "function" && e.refreshColumns(), typeof e.refreshShellHeader == "function" && e.refreshShellHeader());
342
319
  });
343
320
  return () => {
344
- u = !0, cancelAnimationFrame(D);
321
+ a = !0, cancelAnimationFrame(x);
345
322
  };
346
- }, []), P(() => {
347
- if (!c.current || !R) return;
348
- const e = c.current, o = "react-custom-styles";
349
- let u = !0;
323
+ }, []), R(() => {
324
+ if (!o.current || !w) return;
325
+ const e = o.current, i = "react-custom-styles";
326
+ let a = !0;
350
327
  return e.ready?.().then(() => {
351
- u && R && (e.registerStyles?.(o, R), N.current = o);
328
+ a && w && (e.registerStyles?.(i, w), D.current = i);
352
329
  }), () => {
353
- u = !1, N.current && (e.unregisterStyles?.(N.current), N.current = null);
330
+ a = !1, D.current && (e.unregisterStyles?.(D.current), D.current = null);
354
331
  };
355
- }, [R]), P(() => {
356
- const e = c.current;
332
+ }, [w]), R(() => {
333
+ const e = o.current;
357
334
  if (!e) return;
358
- const o = [];
359
- return x && o.push(e.on("rows-change", (u) => x(u.rows))), () => {
360
- o.forEach((u) => u());
335
+ const i = [];
336
+ return h && i.push(e.on("rows-change", (a) => h(a.rows))), () => {
337
+ i.forEach((a) => a());
361
338
  };
362
- }, [x]);
363
- const re = T(() => Object.keys(_).filter((e) => typeof y[e] == "function").sort().join("|"), [y]), te = G({});
364
- for (const e of Object.keys(_))
365
- te.current[e] = y[e];
366
- P(() => {
367
- const e = c.current;
339
+ }, [h]);
340
+ const ee = T(() => Object.keys(H).filter((e) => typeof P[e] == "function").sort().join("|"), [P]), re = b({});
341
+ for (const e of Object.keys(H))
342
+ re.current[e] = P[e];
343
+ R(() => {
344
+ const e = o.current;
368
345
  if (!e) return;
369
- const o = [];
370
- for (const [u, D] of Object.entries(_))
371
- re.includes(u) && o.push(
372
- e.on(D, (K, M) => {
373
- te.current[u]?.(K, M);
346
+ const i = [];
347
+ for (const [a, x] of Object.entries(H))
348
+ ee.includes(a) && i.push(
349
+ e.on(x, (K, N) => {
350
+ re.current[a]?.(K, N);
374
351
  })
375
352
  );
376
353
  return () => {
377
- o.forEach((u) => u());
354
+ i.forEach((a) => a());
378
355
  };
379
- }, [re]), de(
380
- d,
356
+ }, [ee]), fe(
357
+ l,
381
358
  () => ({
382
359
  get element() {
383
- return c.current;
360
+ return o.current;
384
361
  },
385
362
  async getConfig() {
386
- return c.current?.getConfig?.() ?? {};
363
+ return o.current?.getConfig?.() ?? {};
387
364
  },
388
365
  async ready() {
389
- return c.current?.ready?.();
366
+ return o.current?.ready?.();
390
367
  },
391
368
  async forceLayout() {
392
- return c.current?.forceLayout?.();
369
+ return o.current?.forceLayout?.();
393
370
  },
394
371
  async toggleGroup(e) {
395
- return c.current?.toggleGroup?.(e);
372
+ return o.current?.toggleGroup?.(e);
396
373
  },
397
- registerStyles(e, o) {
398
- c.current?.registerStyles?.(e, o);
374
+ registerStyles(e, i) {
375
+ o.current?.registerStyles?.(e, i);
399
376
  },
400
377
  unregisterStyles(e) {
401
- c.current?.unregisterStyles?.(e);
378
+ o.current?.unregisterStyles?.(e);
402
379
  },
403
- setRowLoading(e, o) {
404
- c.current?.setRowLoading?.(e, o);
380
+ setRowLoading(e, i) {
381
+ o.current?.setRowLoading?.(e, i);
405
382
  },
406
- setCellLoading(e, o, u) {
407
- c.current?.setCellLoading?.(e, o, u);
383
+ setCellLoading(e, i, a) {
384
+ o.current?.setCellLoading?.(e, i, a);
408
385
  },
409
386
  isRowLoading(e) {
410
- return c.current?.isRowLoading?.(e) ?? !1;
387
+ return o.current?.isRowLoading?.(e) ?? !1;
411
388
  },
412
- isCellLoading(e, o) {
413
- return c.current?.isCellLoading?.(e, o) ?? !1;
389
+ isCellLoading(e, i) {
390
+ return o.current?.isCellLoading?.(e, i) ?? !1;
414
391
  },
415
392
  clearAllLoading() {
416
- c.current?.clearAllLoading?.();
393
+ o.current?.clearAllLoading?.();
417
394
  }
418
395
  }),
419
396
  []
420
397
  );
421
- const z = G(null);
422
- return ge(() => {
423
- const e = c.current;
424
- return e && z.current && oe(e, z.current), () => {
425
- e && oe(e, null);
398
+ const z = b(null);
399
+ return de(() => {
400
+ const e = o.current;
401
+ return e && z.current && ne(e, z.current), () => {
402
+ e && ne(e, null);
426
403
  };
427
- }, []), /* @__PURE__ */ ve(W, { children: [
428
- /* @__PURE__ */ E(Ke, { ref: z }),
429
- Ge(
430
- ae.activeTag,
404
+ }, []), /* @__PURE__ */ ce(U, { children: [
405
+ /* @__PURE__ */ S(Ke, { ref: z }),
406
+ Pe(
407
+ ue.activeTag,
431
408
  {
432
409
  ref: (e) => {
433
- if (c.current = e, e && !Y.current) {
434
- Y.current = !0;
435
- const o = e;
436
- A && (o.gridConfig = A), n && (o.rows = n), L && (o.columns = L);
410
+ if (o.current = e, e && !J.current) {
411
+ J.current = !0;
412
+ const i = e;
413
+ L && (i.gridConfig = L), n && (i.rows = n), I && (i.columns = I);
437
414
  }
438
415
  },
439
- class: S,
440
- style: m
416
+ class: F,
417
+ style: y
441
418
  },
442
- /* @__PURE__ */ E(H.Provider, { value: c, children: i })
419
+ /* @__PURE__ */ S($.Provider, { value: o, children: s })
443
420
  )
444
421
  ] });
445
422
  });
446
423
  function lr(t) {
447
424
  const {
448
425
  field: r,
449
- header: d,
426
+ header: l,
450
427
  type: n,
451
- editable: s,
452
- sortable: g,
453
- resizable: l,
454
- width: a,
455
- minWidth: w,
456
- order: f,
457
- hidden: h,
458
- lockVisible: b,
459
- children: C,
460
- editor: R,
461
- options: S,
462
- multi: m,
463
- format: i
464
- } = t, p = G(null), v = F(
465
- (c) => {
466
- p.current = c, c && (C && xe(c, C), R && Ee(c, R));
428
+ editable: c,
429
+ sortable: d,
430
+ resizable: f,
431
+ width: u,
432
+ minWidth: m,
433
+ order: g,
434
+ hidden: C,
435
+ lockVisible: v,
436
+ children: G,
437
+ editor: w,
438
+ options: F,
439
+ multi: y,
440
+ format: s
441
+ } = t, p = b(null), h = E(
442
+ (D) => {
443
+ p.current = D, D && (G && Se(D, G), w && Ee(D, w));
467
444
  },
468
- [C, R]
469
- ), x = typeof a == "number" ? `${a}px` : a, y = {
445
+ [G, w]
446
+ ), P = typeof u == "number" ? `${u}px` : u, o = {
470
447
  field: r,
471
- ref: v
448
+ ref: h
472
449
  };
473
- return d !== void 0 && (y.header = d), n !== void 0 && (y.type = n), s !== void 0 && (y.editable = s), g !== void 0 && (y.sortable = g), l !== void 0 && (y.resizable = l), x !== void 0 && (y.width = x), w !== void 0 && (y["min-width"] = w), f !== void 0 && (y.order = f), h !== void 0 && (y.hidden = h), b !== void 0 && (y["lock-visible"] = b), m !== void 0 && (y.multi = m), i && (y["data-has-format"] = "true"), S && (y["data-has-options"] = "true"), /* @__PURE__ */ E("tbw-grid-column", { ...y });
450
+ return l !== void 0 && (o.header = l), n !== void 0 && (o.type = n), c !== void 0 && (o.editable = c), d !== void 0 && (o.sortable = d), f !== void 0 && (o.resizable = f), P !== void 0 && (o.width = P), m !== void 0 && (o["min-width"] = m), g !== void 0 && (o.order = g), C !== void 0 && (o.hidden = C), v !== void 0 && (o["lock-visible"] = v), y !== void 0 && (o.multi = y), s && (o["data-has-format"] = "true"), F && (o["data-has-options"] = "true"), /* @__PURE__ */ S("tbw-grid-column", { ...o });
474
451
  }
475
- function fr({ id: t, order: r = 100, children: d }) {
476
- const n = pe(), s = t ?? `tbw-header-content-${n}`, g = k(H), [l, a] = O(null), w = G(null);
477
- return P(() => {
478
- const f = g?.current;
479
- if (!f) return;
480
- const h = w;
481
- let b = !1;
452
+ function fr({ id: t, order: r = 100, children: l }) {
453
+ const n = ge(), c = t ?? `tbw-header-content-${n}`, d = k($), [f, u] = A(null), m = b(null);
454
+ return R(() => {
455
+ const g = d?.current;
456
+ if (!g) return;
457
+ const C = m;
458
+ let v = !1;
482
459
  return (async () => {
483
460
  try {
484
- await f.ready?.();
461
+ await g.ready?.();
485
462
  } catch {
486
463
  return;
487
464
  }
488
- if (b) return;
489
- const C = {
490
- id: s,
465
+ if (v) return;
466
+ const G = {
467
+ id: c,
491
468
  order: r,
492
- render: (S) => (a(S), () => {
469
+ render: (w) => (u(w), () => {
493
470
  })
494
- }, R = f.getPluginByName?.("shell");
495
- R?.registerHeaderContent ? R.registerHeaderContent(C) : f.registerHeaderContent?.(C);
471
+ };
472
+ g.getPluginByName?.("shell")?.registerHeaderContent(G);
496
473
  })(), () => {
497
- b = !0;
498
- const C = f.getPluginByName?.("shell");
499
- C?.unregisterHeaderContent ? C.unregisterHeaderContent(s) : f.unregisterHeaderContent?.(s), h.current && (me(h.current, { sync: !0 }), h.current = null), a(null);
474
+ v = !0, g.getPluginByName?.("shell")?.unregisterHeaderContent(c), C.current && (pe(C.current, { sync: !0 }), C.current = null), u(null);
500
475
  };
501
- }, [g, s, r]), P(() => {
502
- if (!l) return;
503
- const f = g?.current ?? void 0;
504
- w.current = Ce(l, d, w.current ?? void 0, f);
505
- }, [d, l, g]), null;
476
+ }, [d, c, r]), R(() => {
477
+ if (!f) return;
478
+ const g = d?.current ?? void 0;
479
+ m.current = me(f, l, m.current ?? void 0, g);
480
+ }, [l, f, d]), null;
506
481
  }
507
482
  function dr({ children: t }) {
508
- return /* @__PURE__ */ E("tbw-grid-tool-buttons", { children: t });
483
+ return /* @__PURE__ */ S("tbw-grid-tool-buttons", { children: t });
509
484
  }
510
- function gr({ id: t, order: r = 100, children: d }) {
511
- const n = pe(), s = t ?? `tbw-toolbar-content-${n}`, g = k(H), [l, a] = O(null), w = G(null);
512
- return P(() => {
513
- const f = g?.current;
514
- if (!f) return;
515
- const h = w;
516
- let b = !1;
485
+ function gr({ id: t, order: r = 100, children: l }) {
486
+ const n = ge(), c = t ?? `tbw-toolbar-content-${n}`, d = k($), [f, u] = A(null), m = b(null);
487
+ return R(() => {
488
+ const g = d?.current;
489
+ if (!g) return;
490
+ const C = m;
491
+ let v = !1;
517
492
  return (async () => {
518
493
  try {
519
- await f.ready?.();
494
+ await g.ready?.();
520
495
  } catch {
521
496
  return;
522
497
  }
523
- if (b) return;
524
- const C = {
525
- id: s,
498
+ if (v) return;
499
+ const G = {
500
+ id: c,
526
501
  order: r,
527
- render: (S) => (a(S), () => {
502
+ render: (w) => (u(w), () => {
528
503
  })
529
- }, R = f.getPluginByName?.("shell");
530
- R?.registerToolbarContent ? R.registerToolbarContent(C) : f.registerToolbarContent?.(C);
504
+ };
505
+ g.getPluginByName?.("shell")?.registerToolbarContent(G);
531
506
  })(), () => {
532
- b = !0;
533
- const C = f.getPluginByName?.("shell");
534
- C?.unregisterToolbarContent ? C.unregisterToolbarContent(s) : f.unregisterToolbarContent?.(s), h.current && (me(h.current, { sync: !0 }), h.current = null), a(null);
507
+ v = !0, g.getPluginByName?.("shell")?.unregisterToolbarContent(c), C.current && (pe(C.current, { sync: !0 }), C.current = null), u(null);
535
508
  };
536
- }, [g, s, r]), P(() => {
537
- if (!l) return;
538
- const f = g?.current ?? void 0;
539
- w.current = Ce(l, d, w.current ?? void 0, f);
540
- }, [d, l, g]), null;
509
+ }, [d, c, r]), R(() => {
510
+ if (!f) return;
511
+ const g = d?.current ?? void 0;
512
+ m.current = me(f, l, m.current ?? void 0, g);
513
+ }, [l, f, d]), null;
541
514
  }
542
- const pr = ({ icons: t, defaults: r, children: d }) => {
543
- let n = d;
544
- return r && (n = /* @__PURE__ */ E(je, { defaults: r, children: n })), t && (n = /* @__PURE__ */ E(He, { icons: t, children: n })), /* @__PURE__ */ E(W, { children: n });
515
+ function We(t) {
516
+ return t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
517
+ }
518
+ function pr(t) {
519
+ const { name: r, params: l, children: n, editor: c } = t, d = b(null), f = E(
520
+ (m) => {
521
+ d.current = m, m && (n && xe(m, n), c && Fe(m, c));
522
+ },
523
+ [n, c]
524
+ ), u = {
525
+ name: r,
526
+ ref: f
527
+ };
528
+ if (l)
529
+ for (const [m, g] of Object.entries(l))
530
+ u[`data-${We(m)}`] = String(g);
531
+ return /* @__PURE__ */ ce("tbw-grid-type", { ...u, children: [
532
+ n ? /* @__PURE__ */ S("tbw-grid-column-view", {}) : null,
533
+ c ? /* @__PURE__ */ S("tbw-grid-column-editor", {}) : null
534
+ ] });
535
+ }
536
+ const mr = ({ icons: t, defaults: r, children: l }) => {
537
+ let n = l;
538
+ return r && (n = /* @__PURE__ */ S(je, { defaults: r, children: n })), t && (n = /* @__PURE__ */ S($e, { icons: t, children: n })), /* @__PURE__ */ S(U, { children: n });
545
539
  };
546
- function mr(t) {
547
- const r = G(null), [d, n] = O(!1), [s, g] = O(null), l = G(null), a = F(() => t ? (l.current ??= document.querySelector(t), l.current) : r.current?.element ?? null, [t]);
548
- P(() => {
549
- let i = !0;
540
+ function yr(t) {
541
+ const r = b(null), [l, n] = A(!1), [c, d] = A(null), f = b(null), u = E(() => t ? (f.current ??= document.querySelector(t), f.current) : r.current?.element ?? null, [t]);
542
+ R(() => {
543
+ let s = !0;
550
544
  return (async () => {
551
545
  try {
552
546
  if (t) {
553
- const v = document.querySelector(t);
554
- if (!v) return;
555
- if (l.current = v, await v.ready?.(), i) {
547
+ const h = document.querySelector(t);
548
+ if (!h) return;
549
+ if (f.current = h, await h.ready?.(), s) {
556
550
  n(!0);
557
- const x = await v.getConfig?.();
558
- i && x && g(x);
551
+ const P = await h.getConfig?.();
552
+ s && P && d(P);
559
553
  }
560
554
  } else {
561
- const v = r.current;
562
- if (!v) return;
563
- if (await v.ready?.(), i) {
555
+ const h = r.current;
556
+ if (!h) return;
557
+ if (await h.ready?.(), s) {
564
558
  n(!0);
565
- const x = await v.getConfig?.();
566
- i && x && g(x);
559
+ const P = await h.getConfig?.();
560
+ s && P && d(P);
567
561
  }
568
562
  }
569
563
  } catch {
570
564
  }
571
565
  })(), () => {
572
- i = !1;
566
+ s = !1;
573
567
  };
574
568
  }, [t]);
575
- const w = F(async () => {
576
- const i = a();
577
- if (i)
578
- return await i.getConfig?.() ?? null;
569
+ const m = E(async () => {
570
+ const s = u();
571
+ if (s)
572
+ return await s.getConfig?.() ?? null;
579
573
  const p = r.current;
580
574
  return p ? await p.getConfig?.() ?? null : null;
581
- }, [a]), f = F(async () => {
582
- const i = a();
583
- if (i) {
584
- await i.forceLayout?.();
575
+ }, [u]), g = E(async () => {
576
+ const s = u();
577
+ if (s) {
578
+ await s.forceLayout?.();
585
579
  return;
586
580
  }
587
581
  const p = r.current;
588
582
  p && await p.forceLayout?.();
589
- }, [a]), h = F(
590
- async (i) => {
591
- const p = a();
583
+ }, [u]), C = E(
584
+ async (s) => {
585
+ const p = u();
592
586
  if (p) {
593
- await p.toggleGroup?.(i);
587
+ await p.toggleGroup?.(s);
594
588
  return;
595
589
  }
596
- const v = r.current;
597
- v && await v.toggleGroup?.(i);
590
+ const h = r.current;
591
+ h && await h.toggleGroup?.(s);
598
592
  },
599
- [a]
600
- ), b = F(
601
- (i) => a()?.getPlugin?.(i),
602
- [a]
603
- ), C = F(
604
- ((i) => a()?.getPluginByName?.(i)),
605
- [a]
606
- ), R = F(
607
- (i, p) => {
608
- const v = a();
609
- if (v) {
610
- v.registerStyles?.(i, p);
593
+ [u]
594
+ ), v = E(
595
+ (s) => u()?.getPlugin?.(s),
596
+ [u]
597
+ ), G = E(
598
+ ((s) => u()?.getPluginByName?.(s)),
599
+ [u]
600
+ ), w = E(
601
+ (s, p) => {
602
+ const h = u();
603
+ if (h) {
604
+ h.registerStyles?.(s, p);
611
605
  return;
612
606
  }
613
- r.current?.registerStyles?.(i, p);
607
+ r.current?.registerStyles?.(s, p);
614
608
  },
615
- [a]
616
- ), S = F(
617
- (i) => {
618
- const p = a();
609
+ [u]
610
+ ), F = E(
611
+ (s) => {
612
+ const p = u();
619
613
  if (p) {
620
- p.unregisterStyles?.(i);
614
+ p.unregisterStyles?.(s);
621
615
  return;
622
616
  }
623
- r.current?.unregisterStyles?.(i);
617
+ r.current?.unregisterStyles?.(s);
624
618
  },
625
- [a]
626
- ), m = F(() => s?.columns ? s.columns.filter((i) => !i.hidden) : [], [s]);
619
+ [u]
620
+ ), y = E(() => c?.columns ? c.columns.filter((s) => !s.hidden) : [], [c]);
627
621
  return {
628
622
  ref: r,
629
- element: a(),
630
- isReady: d,
631
- config: s,
632
- getConfig: w,
633
- forceLayout: f,
634
- toggleGroup: h,
635
- getPlugin: b,
636
- getPluginByName: C,
637
- registerStyles: R,
638
- unregisterStyles: S,
639
- getVisibleColumns: m
623
+ element: u(),
624
+ isReady: l,
625
+ config: c,
626
+ getConfig: m,
627
+ forceLayout: g,
628
+ toggleGroup: C,
629
+ getPlugin: v,
630
+ getPluginByName: G,
631
+ registerStyles: w,
632
+ unregisterStyles: F,
633
+ getVisibleColumns: y
640
634
  };
641
635
  }
642
- function Cr(t, r = {}) {
643
- const { open: d = !0, gridElement: n } = r, s = k(H);
644
- P(() => {
636
+ function hr(t, r = {}) {
637
+ const { open: l = !0, gridElement: n } = r, c = k($);
638
+ R(() => {
639
+ if (!l) return;
640
+ const d = t.current;
645
641
  if (!d) return;
646
- const g = t.current;
647
- if (!g) return;
648
- const l = n ?? g.closest("tbw-grid, [data-tbw-grid]") ?? s?.current ?? null;
649
- if (l)
650
- return l.registerExternalFocusContainer?.(g), () => {
651
- l.unregisterExternalFocusContainer?.(g);
642
+ const f = n ?? d.closest("tbw-grid, [data-tbw-grid]") ?? c?.current ?? null;
643
+ if (f)
644
+ return f.registerExternalFocusContainer?.(d), () => {
645
+ f.unregisterExternalFocusContainer?.(d);
652
646
  };
653
- }, [d, n, s, t]);
647
+ }, [l, n, c, t]);
654
648
  }
655
649
  export {
656
650
  ar as DataGrid,
657
- Se as GridAdapter,
651
+ Ge as GridAdapter,
658
652
  lr as GridColumn,
659
653
  xr as GridDetailPanel,
660
654
  fr as GridHeaderContent,
661
- He as GridIconProvider,
662
- pr as GridProvider,
655
+ $e as GridIconProvider,
656
+ mr as GridProvider,
663
657
  Dr as GridResponsiveCard,
664
658
  dr as GridToolButtons,
665
- vr as GridToolPanel,
659
+ wr as GridToolPanel,
666
660
  gr as GridToolbarContent,
661
+ pr as GridType,
667
662
  je as GridTypeProvider,
668
- Oe as applyColumnDefaults,
663
+ Ae as applyColumnDefaults,
669
664
  ir as hasColumnShorthands,
670
665
  Ne as normalizeColumns,
671
- Me as parseColumnShorthand,
666
+ Le as parseColumnShorthand,
672
667
  ye as registerChildFeatureDetector,
673
- Gr as registerEditorMountHook,
674
- wr as registerFeaturePropKey,
675
- br as registerPostMountRefresh,
676
- mr as useGrid,
668
+ Sr as registerEditorMountHook,
669
+ Rr as registerFeaturePropKey,
670
+ Pr as registerPostMountRefresh,
671
+ yr as useGrid,
677
672
  sr as useGridIcons,
678
- Cr as useGridOverlay,
673
+ hr as useGridOverlay,
679
674
  cr as useGridTypeDefaults,
680
675
  ur as useTypeDefault
681
676
  };