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