@toolbox-web/grid-react 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { DataGrid } from './lib/data-grid';
2
2
  export { GridColumn } from './lib/grid-column';
3
3
  export { GridDetailPanel, type DetailPanelContext, type GridDetailPanelProps } from './lib/grid-detail-panel';
4
+ export { GridResponsiveCard, type GridResponsiveCardProps, type ResponsiveCardContext, } from './lib/grid-responsive-card';
4
5
  export { GridToolButtons, type GridToolButtonsProps } from './lib/grid-tool-button';
5
6
  export { GridToolPanel, type GridToolPanelProps, type ToolPanelContext } from './lib/grid-tool-panel';
6
7
  export { GridTypeProvider, useGridTypeDefaults, useTypeDefault, type GridTypeProviderProps, type ReactTypeDefault, type TypeDefaultsMap, } from './lib/grid-type-registry';
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../libs/grid-react/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,YAAY,CAAC;AAGpB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC9G,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGtG,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,0BAA0B,CAAC;AAGlC,YAAY,EAAE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M,gBAAgB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAGjF,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGvH,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC"}
package/index.js CHANGED
@@ -1,33 +1,33 @@
1
- import { jsx as T } from "react/jsx-runtime";
2
- import { DataGridElement as _ } from "@toolbox-web/grid";
3
- import { useRef as k, useCallback as D, createContext as j, useContext as F, forwardRef as $, useMemo as J, useEffect as v, useImperativeHandle as K, useState as N } from "react";
4
- import { flushSync as R } from "react-dom";
1
+ import { jsx as x } from "react/jsx-runtime";
2
+ import { DataGridElement as J } from "@toolbox-web/grid";
3
+ import { useRef as S, useCallback as E, createContext as K, useContext as N, forwardRef as Q, useMemo as U, useEffect as R, useImperativeHandle as X, useState as F } from "react";
4
+ import { flushSync as v } from "react-dom";
5
5
  import { createRoot as b } from "react-dom/client";
6
- const H = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new Map();
7
- function z(n) {
6
+ const W = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new Map();
7
+ function B(n) {
8
8
  const t = n.querySelector("tbw-grid-detail");
9
9
  if (t) {
10
- const r = H.get(t);
10
+ const r = W.get(t);
11
11
  if (r) return r;
12
12
  }
13
13
  const e = n.id || n.getAttribute("data-grid-id");
14
14
  if (e)
15
15
  return q.get(e);
16
16
  }
17
- function le(n) {
18
- const { children: t, showExpandColumn: e = !0, animation: r = "slide" } = n, i = k(null), s = D(
17
+ function me(n) {
18
+ const { children: t, showExpandColumn: e = !0, animation: r = "slide" } = n, i = S(null), s = E(
19
19
  (c) => {
20
20
  if (i.current = c, !c) return;
21
- H.set(c, t);
22
- const u = c.closest("tbw-grid");
23
- if (u) {
24
- const l = u.id || u.getAttribute("data-grid-id");
21
+ W.set(c, t);
22
+ const d = c.closest("tbw-grid");
23
+ if (d) {
24
+ const l = d.id || d.getAttribute("data-grid-id");
25
25
  l && q.set(l, t);
26
26
  }
27
27
  },
28
28
  [t]
29
29
  );
30
- return /* @__PURE__ */ T(
30
+ return /* @__PURE__ */ x(
31
31
  "tbw-grid-detail",
32
32
  {
33
33
  ref: s,
@@ -36,74 +36,100 @@ function le(n) {
36
36
  }
37
37
  );
38
38
  }
39
- const L = j(null), fe = ({ defaults: n, children: t }) => /* @__PURE__ */ T(L.Provider, { value: n, children: t });
40
- function ge() {
41
- return F(L);
39
+ const z = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new Map();
40
+ function _(n) {
41
+ const t = n.querySelector("tbw-grid-responsive-card");
42
+ if (t) {
43
+ const r = z.get(t);
44
+ if (r) return r;
45
+ }
46
+ const e = n.id || n.getAttribute("data-grid-id");
47
+ if (e)
48
+ return O.get(e);
42
49
  }
43
- function me(n) {
44
- return F(L)?.[n];
50
+ function ye(n) {
51
+ const { children: t, cardRowHeight: e = "auto" } = n, r = S(null), i = E(
52
+ (o) => {
53
+ if (r.current = o, !o) return;
54
+ z.set(o, t);
55
+ const c = o.closest("tbw-grid");
56
+ if (c) {
57
+ const d = c.id || c.getAttribute("data-grid-id");
58
+ d && O.set(d, t);
59
+ }
60
+ },
61
+ [t]
62
+ ), s = e === "auto" ? "auto" : String(e);
63
+ return /* @__PURE__ */ x("tbw-grid-responsive-card", { ref: i, cardRowHeight: s });
64
+ }
65
+ const I = K(null), he = ({ defaults: n, children: t }) => /* @__PURE__ */ x(I.Provider, { value: n, children: t });
66
+ function we() {
67
+ return N(I);
45
68
  }
46
- const Q = L;
47
- function U(n) {
69
+ function Re(n) {
70
+ return N(I)?.[n];
71
+ }
72
+ const Y = I;
73
+ function Z(n) {
48
74
  const t = /* @__PURE__ */ new WeakMap();
49
75
  return (e) => {
50
76
  const r = e.cellEl;
51
77
  if (r) {
52
78
  const o = t.get(r);
53
79
  if (o)
54
- return R(() => {
80
+ return v(() => {
55
81
  o.root.render(n(e));
56
82
  }), o.container;
57
83
  }
58
84
  const i = document.createElement("div");
59
85
  i.className = "react-cell-renderer", i.style.display = "contents";
60
86
  const s = b(i);
61
- return R(() => {
87
+ return v(() => {
62
88
  s.render(n(e));
63
89
  }), r && t.set(r, { root: s, container: i }), i;
64
90
  };
65
91
  }
66
- function X(n) {
92
+ function ee(n) {
67
93
  return (t) => {
68
94
  const e = document.createElement("div");
69
95
  e.className = "react-cell-editor", e.style.display = "contents";
70
96
  const r = b(e);
71
- return R(() => {
97
+ return v(() => {
72
98
  r.render(n(t));
73
99
  }), e;
74
100
  };
75
101
  }
76
- function Y(n) {
102
+ function te(n) {
77
103
  if (!n) return;
78
104
  if (!n.columns) return n;
79
105
  const t = n.columns.map((e) => {
80
106
  const { renderer: r, editor: i, ...s } = e, o = { ...s };
81
- return r && (o.renderer = U(r)), i && (o.editor = X(i)), o;
107
+ return r && (o.renderer = Z(r)), i && (o.editor = ee(i)), o;
82
108
  });
83
109
  return {
84
110
  ...n,
85
111
  columns: t
86
112
  };
87
113
  }
88
- const B = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new Map();
89
- function Z(n) {
90
- const t = B.get(n);
114
+ const j = /* @__PURE__ */ new WeakMap(), $ = /* @__PURE__ */ new Map();
115
+ function re(n) {
116
+ const t = j.get(n);
91
117
  if (t) return t;
92
118
  const e = n.id;
93
119
  if (e)
94
- return O.get(e);
120
+ return $.get(e);
95
121
  }
96
- function pe(n) {
97
- const { id: t, title: e, icon: r, tooltip: i, order: s = 100, children: o } = n, c = k(null), u = D(
122
+ function ve(n) {
123
+ const { id: t, title: e, icon: r, tooltip: i, order: s = 100, children: o } = n, c = S(null), d = E(
98
124
  (l) => {
99
- c.current = l, l && (B.set(l, o), t && O.set(t, o));
125
+ c.current = l, l && (j.set(l, o), t && $.set(t, o));
100
126
  },
101
127
  [o, t]
102
128
  );
103
- return /* @__PURE__ */ T(
129
+ return /* @__PURE__ */ x(
104
130
  "tbw-grid-tool-panel",
105
131
  {
106
- ref: u,
132
+ ref: d,
107
133
  id: t,
108
134
  title: e,
109
135
  icon: r,
@@ -112,41 +138,41 @@ function pe(n) {
112
138
  }
113
139
  );
114
140
  }
115
- const A = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new Map();
116
- function ee(n, t) {
117
- const e = n.getAttribute("field"), r = A.get(n) ?? {};
118
- if (r.renderer = t, A.set(n, r), e) {
119
- const i = G.get(e) ?? {};
120
- i.renderer = t, G.set(e, i);
141
+ const G = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new Map();
142
+ function ne(n, t) {
143
+ const e = n.getAttribute("field"), r = G.get(n) ?? {};
144
+ if (r.renderer = t, G.set(n, r), e) {
145
+ const i = k.get(e) ?? {};
146
+ i.renderer = t, k.set(e, i);
121
147
  }
122
148
  }
123
- function te(n, t) {
124
- const e = n.getAttribute("field"), r = A.get(n) ?? {};
125
- if (r.editor = t, A.set(n, r), e) {
126
- const i = G.get(e) ?? {};
127
- i.editor = t, G.set(e, i);
149
+ function ie(n, t) {
150
+ const e = n.getAttribute("field"), r = G.get(n) ?? {};
151
+ if (r.editor = t, G.set(n, r), e) {
152
+ const i = k.get(e) ?? {};
153
+ i.editor = t, k.set(e, i);
128
154
  }
129
155
  }
130
- function re(n) {
131
- let t = A.get(n)?.renderer;
156
+ function oe(n) {
157
+ let t = G.get(n)?.renderer;
132
158
  if (!t) {
133
159
  const e = n.getAttribute("field");
134
- e && (t = G.get(e)?.renderer);
160
+ e && (t = k.get(e)?.renderer);
135
161
  }
136
162
  return t;
137
163
  }
138
- function ne(n) {
139
- let t = A.get(n)?.editor;
164
+ function se(n) {
165
+ let t = G.get(n)?.editor;
140
166
  if (!t) {
141
167
  const e = n.getAttribute("field");
142
- e && (t = G.get(e)?.editor);
168
+ e && (t = k.get(e)?.editor);
143
169
  }
144
170
  return t;
145
171
  }
146
- function ye() {
147
- return Array.from(G.keys());
172
+ function Ce() {
173
+ return Array.from(k.keys());
148
174
  }
149
- class ie {
175
+ class ce {
150
176
  mountedViews = [];
151
177
  typeDefaults = null;
152
178
  /**
@@ -164,10 +190,10 @@ class ie {
164
190
  */
165
191
  canHandle(t) {
166
192
  const e = t.getAttribute("field");
167
- let r = A.get(t);
193
+ let r = G.get(t);
168
194
  if (!r && e) {
169
- const o = G.get(e);
170
- o && (o.renderer || o.editor) && (r = o, A.set(t, r));
195
+ const o = k.get(e);
196
+ o && (o.renderer || o.editor) && (r = o, G.set(t, r));
171
197
  }
172
198
  const i = r?.renderer !== void 0, s = r?.editor !== void 0;
173
199
  return r !== void 0 && (i || s);
@@ -184,29 +210,29 @@ class ie {
184
210
  * allowing the grid to use its default rendering.
185
211
  */
186
212
  createRenderer(t) {
187
- const e = re(t);
213
+ const e = oe(t);
188
214
  if (!e)
189
215
  return;
190
216
  const r = /* @__PURE__ */ new WeakMap();
191
217
  return (i) => {
192
218
  const s = i.cellEl;
193
219
  if (s) {
194
- const u = r.get(s);
195
- if (u)
196
- return R(() => {
197
- u.root.render(e(i));
198
- }), u.container;
220
+ const d = r.get(s);
221
+ if (d)
222
+ return v(() => {
223
+ d.root.render(e(i));
224
+ }), d.container;
199
225
  const l = document.createElement("div");
200
226
  l.className = "react-cell-renderer", l.style.display = "contents";
201
227
  const w = b(l);
202
- return R(() => {
228
+ return v(() => {
203
229
  w.render(e(i));
204
230
  }), r.set(s, { root: w, container: l, lastRowIndex: i.rowIndex ?? -1 }), this.mountedViews.push({ root: w, container: l }), l;
205
231
  }
206
232
  const o = document.createElement("div");
207
233
  o.className = "react-cell-renderer", o.style.display = "contents";
208
234
  const c = b(o);
209
- return R(() => {
235
+ return v(() => {
210
236
  c.render(e(i));
211
237
  }), this.mountedViews.push({ root: c, container: o }), o;
212
238
  };
@@ -216,12 +242,12 @@ class ie {
216
242
  * with commit/cancel callbacks passed as props.
217
243
  */
218
244
  createEditor(t) {
219
- const e = ne(t);
245
+ const e = se(t);
220
246
  return e ? (r) => {
221
247
  const i = document.createElement("div");
222
248
  i.className = "react-cell-editor", i.style.display = "contents";
223
249
  const s = b(i);
224
- return R(() => {
250
+ return v(() => {
225
251
  s.render(e(r));
226
252
  }), this.mountedViews.push({ root: s, container: i }), i;
227
253
  } : () => document.createElement("div");
@@ -231,13 +257,13 @@ class ie {
231
257
  * Renders React components for expandable detail rows.
232
258
  */
233
259
  createDetailRenderer(t) {
234
- const e = z(t);
260
+ const e = B(t);
235
261
  if (e)
236
262
  return (r, i) => {
237
263
  const s = document.createElement("div");
238
264
  s.className = "react-detail-panel";
239
265
  const o = { row: r, rowIndex: i }, c = b(s);
240
- return R(() => {
266
+ return v(() => {
241
267
  c.render(e(o));
242
268
  }), this.mountedViews.push({ root: c, container: s }), s;
243
269
  };
@@ -251,12 +277,28 @@ class ie {
251
277
  if (e)
252
278
  return this.createDetailRenderer(e);
253
279
  }
280
+ /**
281
+ * Creates a responsive card renderer function for ResponsivePlugin.
282
+ * Renders React components for card layout in responsive mode.
283
+ */
284
+ createResponsiveCardRenderer(t) {
285
+ const e = _(t);
286
+ if (e)
287
+ return (r, i) => {
288
+ const s = document.createElement("div");
289
+ s.className = "react-responsive-card";
290
+ const o = { row: r, index: i }, c = b(s);
291
+ return v(() => {
292
+ c.render(e(o));
293
+ }), this.mountedViews.push({ root: c, container: s }), s;
294
+ };
295
+ }
254
296
  /**
255
297
  * Creates a tool panel renderer from a light DOM element.
256
298
  * Renders React components into tool panel containers.
257
299
  */
258
300
  createToolPanelRenderer(t) {
259
- const e = Z(t);
301
+ const e = re(t);
260
302
  if (!e)
261
303
  return;
262
304
  const r = t.closest("tbw-grid");
@@ -264,14 +306,14 @@ class ie {
264
306
  const s = {
265
307
  grid: r ?? i
266
308
  }, o = b(i);
267
- return R(() => {
309
+ return v(() => {
268
310
  o.render(e(s));
269
311
  }), this.mountedViews.push({ root: o, container: i }), () => {
270
- const c = this.mountedViews.findIndex((u) => u.container === i);
312
+ const c = this.mountedViews.findIndex((d) => d.container === i);
271
313
  if (c !== -1) {
272
- const { root: u } = this.mountedViews[c];
314
+ const { root: d } = this.mountedViews[c];
273
315
  try {
274
- u.unmount();
316
+ d.unmount();
275
317
  } catch {
276
318
  }
277
319
  this.mountedViews.splice(c, 1);
@@ -323,7 +365,7 @@ class ie {
323
365
  const r = document.createElement("span");
324
366
  r.style.display = "contents";
325
367
  const i = b(r);
326
- return this.mountedViews.push({ root: i, container: r }), R(() => {
368
+ return this.mountedViews.push({ root: i, container: r }), v(() => {
327
369
  i.render(t(e));
328
370
  }), r;
329
371
  };
@@ -337,7 +379,7 @@ class ie {
337
379
  const r = document.createElement("span");
338
380
  r.style.display = "contents";
339
381
  const i = b(r);
340
- return this.mountedViews.push({ root: i, container: r }), R(() => {
382
+ return this.mountedViews.push({ root: i, container: r }), v(() => {
341
383
  i.render(t(e));
342
384
  }), r;
343
385
  };
@@ -369,116 +411,135 @@ class ie {
369
411
  }
370
412
  }
371
413
  }
372
- let W = !1, M = null;
373
- function P() {
374
- return W || (M = new ie(), _.registerAdapter(M), W = !0), M;
414
+ let H = !1, M = null;
415
+ function L() {
416
+ return H || (M = new ce(), J.registerAdapter(M), H = !0), M;
375
417
  }
376
- P();
377
- function oe(n, t) {
418
+ L();
419
+ function de(n, t) {
378
420
  const e = n, r = e.getPluginByName?.("masterDetail");
379
421
  if (r && typeof r.refreshDetailRenderer == "function") {
380
422
  r.refreshDetailRenderer();
381
423
  return;
382
424
  }
383
425
  const i = n.querySelector("tbw-grid-detail");
384
- !i || !z(n) || import("@toolbox-web/grid/all").then(({ MasterDetailPlugin: o }) => {
426
+ !i || !B(n) || import("@toolbox-web/grid/all").then(({ MasterDetailPlugin: o }) => {
385
427
  const c = t.createDetailRenderer(n);
386
428
  if (!c) return;
387
- const u = i.getAttribute("animation");
429
+ const d = i.getAttribute("animation");
388
430
  let l = "slide";
389
- u === "false" ? l = !1 : u === "fade" && (l = "fade");
390
- const w = i.getAttribute("showExpandColumn") !== "false", a = new o({
431
+ d === "false" ? l = !1 : d === "fade" && (l = "fade");
432
+ const w = i.getAttribute("showExpandColumn") !== "false", u = new o({
391
433
  detailRenderer: c,
392
434
  showExpandColumn: w,
393
435
  animation: l
394
- }), m = e.gridConfig || {}, S = m.plugins || [];
436
+ }), p = e.gridConfig || {}, A = p.plugins || [];
395
437
  e.gridConfig = {
396
- ...m,
397
- plugins: [...S, a]
438
+ ...p,
439
+ plugins: [...A, u]
398
440
  };
399
441
  }).catch(() => {
400
442
  });
401
443
  }
402
- const he = $(function(t, e) {
444
+ function ae(n, t) {
445
+ const e = n;
446
+ if (!n.querySelector("tbw-grid-responsive-card") || !_(n)) return;
447
+ const s = e.getPluginByName?.("responsive");
448
+ if (s && typeof s.setCardRenderer == "function") {
449
+ const o = t.createResponsiveCardRenderer(n);
450
+ o && s.setCardRenderer(o);
451
+ return;
452
+ }
453
+ console.warn(
454
+ `[tbw-grid-react] <GridResponsiveCard> found but ResponsivePlugin is not configured.
455
+ Add ResponsivePlugin to your gridConfig.plugins array:
456
+
457
+ import { ResponsivePlugin } from "@toolbox-web/grid/all";
458
+ const config = {
459
+ plugins: [new ResponsivePlugin({ breakpoint: 500 })],
460
+ };`
461
+ );
462
+ }
463
+ const be = Q(function(t, e) {
403
464
  const {
404
465
  rows: r,
405
466
  gridConfig: i,
406
467
  columns: s,
407
468
  fitMode: o,
408
469
  editOn: c,
409
- customStyles: u,
470
+ customStyles: d,
410
471
  className: l,
411
472
  style: w,
412
- children: a,
413
- onRowsChange: m,
414
- onCellEdit: S,
415
- onRowClick: E,
416
- onColumnStateChange: x,
417
- onSortChange: I
418
- } = t, f = k(null), V = k(null), y = F(Q), C = J(() => Y(i), [i]);
419
- return v(() => {
420
- P().setTypeDefaults(y);
421
- }, [y]), v(() => {
473
+ children: u,
474
+ onRowsChange: p,
475
+ onCellEdit: A,
476
+ onRowClick: D,
477
+ onColumnStateChange: P,
478
+ onSortChange: T
479
+ } = t, f = S(null), V = S(null), y = N(Y), C = U(() => te(i), [i]);
480
+ return R(() => {
481
+ L().setTypeDefaults(y);
482
+ }, [y]), R(() => {
422
483
  f.current && (f.current.rows = r);
423
- }, [r]), v(() => {
484
+ }, [r]), R(() => {
424
485
  f.current && C && (f.current.gridConfig = C);
425
- }, [C]), v(() => {
486
+ }, [C]), R(() => {
426
487
  f.current && s && (f.current.columns = s);
427
- }, [s]), v(() => {
488
+ }, [s]), R(() => {
428
489
  f.current && o !== void 0 && (f.current.fitMode = o);
429
- }, [o]), v(() => {
490
+ }, [o]), R(() => {
430
491
  f.current && c !== void 0 && (f.current.editOn = c);
431
- }, [c]), v(() => {
432
- const d = f.current;
433
- if (!d) return;
434
- const p = P();
435
- d.__frameworkAdapter = p, oe(d, p);
492
+ }, [c]), R(() => {
493
+ const a = f.current;
494
+ if (!a) return;
495
+ const m = L();
496
+ a.__frameworkAdapter = m, de(a, m), ae(a, m);
436
497
  let g = !1;
437
498
  const h = requestAnimationFrame(() => {
438
- g || (typeof d.refreshColumns == "function" && d.refreshColumns(), typeof d.refreshShellHeader == "function" && d.refreshShellHeader());
499
+ g || (typeof a.refreshColumns == "function" && a.refreshColumns(), typeof a.refreshShellHeader == "function" && a.refreshShellHeader());
439
500
  });
440
501
  return () => {
441
502
  g = !0, cancelAnimationFrame(h);
442
503
  };
443
- }, []), v(() => {
444
- if (!f.current || !u) return;
445
- const d = f.current, p = "react-custom-styles";
504
+ }, []), R(() => {
505
+ if (!f.current || !d) return;
506
+ const a = f.current, m = "react-custom-styles";
446
507
  let g = !0;
447
- return d.ready?.().then(() => {
448
- g && u && (d.registerStyles?.(p, u), V.current = p);
508
+ return a.ready?.().then(() => {
509
+ g && d && (a.registerStyles?.(m, d), V.current = m);
449
510
  }), () => {
450
- g = !1, V.current && (d.unregisterStyles?.(V.current), V.current = null);
511
+ g = !1, V.current && (a.unregisterStyles?.(V.current), V.current = null);
451
512
  };
452
- }, [u]), v(() => {
453
- const d = f.current;
454
- if (!d) return;
455
- const p = [];
456
- if (m) {
457
- const g = ((h) => m(h.detail.rows));
458
- d.addEventListener("rows-change", g), p.push(["rows-change", g]);
513
+ }, [d]), R(() => {
514
+ const a = f.current;
515
+ if (!a) return;
516
+ const m = [];
517
+ if (p) {
518
+ const g = ((h) => p(h.detail.rows));
519
+ a.addEventListener("rows-change", g), m.push(["rows-change", g]);
459
520
  }
460
- if (S) {
461
- const g = ((h) => S(h));
462
- d.addEventListener("cell-edit", g), p.push(["cell-edit", g]);
521
+ if (A) {
522
+ const g = ((h) => A(h));
523
+ a.addEventListener("cell-edit", g), m.push(["cell-edit", g]);
463
524
  }
464
- if (E) {
465
- const g = ((h) => E(h));
466
- d.addEventListener("row-click", g), p.push(["row-click", g]);
525
+ if (D) {
526
+ const g = ((h) => D(h));
527
+ a.addEventListener("row-click", g), m.push(["row-click", g]);
467
528
  }
468
- if (x) {
469
- const g = ((h) => x(h));
470
- d.addEventListener("column-state-change", g), p.push(["column-state-change", g]);
529
+ if (P) {
530
+ const g = ((h) => P(h));
531
+ a.addEventListener("column-state-change", g), m.push(["column-state-change", g]);
471
532
  }
472
- if (I) {
473
- const g = ((h) => I(h));
474
- d.addEventListener("sort-change", g), p.push(["sort-change", g]);
533
+ if (T) {
534
+ const g = ((h) => T(h));
535
+ a.addEventListener("sort-change", g), m.push(["sort-change", g]);
475
536
  }
476
537
  return () => {
477
- p.forEach(([g, h]) => {
478
- d.removeEventListener(g, h);
538
+ m.forEach(([g, h]) => {
539
+ a.removeEventListener(g, h);
479
540
  });
480
541
  };
481
- }, [m, S, E, x, I]), K(
542
+ }, [p, A, D, P, T]), X(
482
543
  e,
483
544
  () => ({
484
545
  get element() {
@@ -493,33 +554,33 @@ const he = $(function(t, e) {
493
554
  async forceLayout() {
494
555
  return f.current?.forceLayout?.();
495
556
  },
496
- async toggleGroup(d) {
497
- return f.current?.toggleGroup?.(d);
557
+ async toggleGroup(a) {
558
+ return f.current?.toggleGroup?.(a);
498
559
  },
499
- registerStyles(d, p) {
500
- f.current?.registerStyles?.(d, p);
560
+ registerStyles(a, m) {
561
+ f.current?.registerStyles?.(a, m);
501
562
  },
502
- unregisterStyles(d) {
503
- f.current?.unregisterStyles?.(d);
563
+ unregisterStyles(a) {
564
+ f.current?.unregisterStyles?.(a);
504
565
  }
505
566
  }),
506
567
  []
507
- ), /* @__PURE__ */ T(
568
+ ), /* @__PURE__ */ x(
508
569
  "tbw-grid",
509
570
  {
510
- ref: (d) => {
511
- if (f.current = d, d) {
512
- const p = d;
513
- C && (p.gridConfig = C), r && (p.rows = r), s && (p.columns = s);
571
+ ref: (a) => {
572
+ if (f.current = a, a) {
573
+ const m = a;
574
+ C && (m.gridConfig = C), r && (m.rows = r), s && (m.columns = s);
514
575
  }
515
576
  },
516
577
  class: l,
517
578
  style: w,
518
- children: a
579
+ children: u
519
580
  }
520
581
  );
521
582
  });
522
- function we(n) {
583
+ function Ee(n) {
523
584
  const {
524
585
  field: t,
525
586
  header: e,
@@ -528,61 +589,61 @@ function we(n) {
528
589
  sortable: s,
529
590
  resizable: o,
530
591
  width: c,
531
- minWidth: u,
592
+ minWidth: d,
532
593
  hidden: l,
533
594
  lockVisible: w,
534
- children: a,
535
- editor: m,
536
- options: S,
537
- multi: E,
538
- format: x
539
- } = n, I = k(null), f = D(
595
+ children: u,
596
+ editor: p,
597
+ options: A,
598
+ multi: D,
599
+ format: P
600
+ } = n, T = S(null), f = E(
540
601
  (C) => {
541
- I.current = C, C && (a && ee(C, a), m && te(C, m));
602
+ T.current = C, C && (u && ne(C, u), p && ie(C, p));
542
603
  },
543
- [a, m, t]
604
+ [u, p, t]
544
605
  ), V = typeof c == "number" ? `${c}px` : c, y = {
545
606
  field: t,
546
607
  ref: f
547
608
  };
548
- return e !== void 0 && (y.header = e), r !== void 0 && (y.type = r), i !== void 0 && (y.editable = i), s !== void 0 && (y.sortable = s), o !== void 0 && (y.resizable = o), V !== void 0 && (y.width = V), u !== void 0 && (y["min-width"] = u), l !== void 0 && (y.hidden = l), w !== void 0 && (y["lock-visible"] = w), E !== void 0 && (y.multi = E), x && (y["data-has-format"] = "true"), S && (y["data-has-options"] = "true"), /* @__PURE__ */ T("tbw-grid-column", { ...y });
609
+ return e !== void 0 && (y.header = e), r !== void 0 && (y.type = r), i !== void 0 && (y.editable = i), s !== void 0 && (y.sortable = s), o !== void 0 && (y.resizable = o), V !== void 0 && (y.width = V), d !== void 0 && (y["min-width"] = d), l !== void 0 && (y.hidden = l), w !== void 0 && (y["lock-visible"] = w), D !== void 0 && (y.multi = D), P && (y["data-has-format"] = "true"), A && (y["data-has-options"] = "true"), /* @__PURE__ */ x("tbw-grid-column", { ...y });
549
610
  }
550
- function ve({ children: n }) {
551
- return /* @__PURE__ */ T("tbw-grid-tool-buttons", { children: n });
611
+ function De({ children: n }) {
612
+ return /* @__PURE__ */ x("tbw-grid-tool-buttons", { children: n });
552
613
  }
553
- function Re() {
554
- const n = k(null), [t, e] = N(!1), [r, i] = N(null);
555
- v(() => {
556
- const a = n.current;
557
- if (!a) return;
558
- let m = !0;
614
+ function Ae() {
615
+ const n = S(null), [t, e] = F(!1), [r, i] = F(null);
616
+ R(() => {
617
+ const u = n.current;
618
+ if (!u) return;
619
+ let p = !0;
559
620
  return (async () => {
560
621
  try {
561
- if (await a.ready?.(), m) {
622
+ if (await u.ready?.(), p) {
562
623
  e(!0);
563
- const E = await a.getConfig?.();
564
- m && E && i(E);
624
+ const D = await u.getConfig?.();
625
+ p && D && i(D);
565
626
  }
566
627
  } catch {
567
628
  }
568
629
  })(), () => {
569
- m = !1;
630
+ p = !1;
570
631
  };
571
632
  }, []);
572
- const s = D(async () => {
573
- const a = n.current;
574
- return a ? await a.getConfig?.() ?? null : null;
575
- }, []), o = D(async () => {
576
- const a = n.current;
577
- a && await a.forceLayout?.();
578
- }, []), c = D(async (a) => {
579
- const m = n.current;
580
- m && await m.toggleGroup?.(a);
581
- }, []), u = D((a, m) => {
582
- n.current?.registerStyles?.(a, m);
583
- }, []), l = D((a) => {
584
- n.current?.unregisterStyles?.(a);
585
- }, []), w = D(() => r?.columns ? r.columns.filter((a) => !a.hidden) : [], [r]);
633
+ const s = E(async () => {
634
+ const u = n.current;
635
+ return u ? await u.getConfig?.() ?? null : null;
636
+ }, []), o = E(async () => {
637
+ const u = n.current;
638
+ u && await u.forceLayout?.();
639
+ }, []), c = E(async (u) => {
640
+ const p = n.current;
641
+ p && await p.toggleGroup?.(u);
642
+ }, []), d = E((u, p) => {
643
+ n.current?.registerStyles?.(u, p);
644
+ }, []), l = E((u) => {
645
+ n.current?.unregisterStyles?.(u);
646
+ }, []), w = E(() => r?.columns ? r.columns.filter((u) => !u.hidden) : [], [r]);
586
647
  return {
587
648
  ref: n,
588
649
  isReady: t,
@@ -590,20 +651,20 @@ function Re() {
590
651
  getConfig: s,
591
652
  forceLayout: o,
592
653
  toggleGroup: c,
593
- registerStyles: u,
654
+ registerStyles: d,
594
655
  unregisterStyles: l,
595
656
  getVisibleColumns: w
596
657
  };
597
658
  }
598
- function Ce(n, t, e, r = []) {
599
- const i = k(e);
600
- v(() => {
659
+ function Se(n, t, e, r = []) {
660
+ const i = S(e);
661
+ R(() => {
601
662
  i.current = e;
602
- }, [e, ...r]), v(() => {
663
+ }, [e, ...r]), R(() => {
603
664
  const s = n.current, o = s && "element" in s ? s.element : s;
604
665
  if (!o) return;
605
- const c = ((u) => {
606
- i.current(u);
666
+ const c = ((d) => {
667
+ i.current(d);
607
668
  });
608
669
  return o.addEventListener(t, c), () => {
609
670
  o.removeEventListener(t, c);
@@ -611,16 +672,17 @@ function Ce(n, t, e, r = []) {
611
672
  }, [n, t]);
612
673
  }
613
674
  export {
614
- he as DataGrid,
615
- we as GridColumn,
616
- le as GridDetailPanel,
617
- ve as GridToolButtons,
618
- pe as GridToolPanel,
619
- fe as GridTypeProvider,
620
- ie as ReactGridAdapter,
621
- ye as getRegisteredFields,
622
- Re as useGrid,
623
- Ce as useGridEvent,
624
- ge as useGridTypeDefaults,
625
- me as useTypeDefault
675
+ be as DataGrid,
676
+ Ee as GridColumn,
677
+ me as GridDetailPanel,
678
+ ye as GridResponsiveCard,
679
+ De as GridToolButtons,
680
+ ve as GridToolPanel,
681
+ he as GridTypeProvider,
682
+ ce as ReactGridAdapter,
683
+ Ce as getRegisteredFields,
684
+ Ae as useGrid,
685
+ Se as useGridEvent,
686
+ we as useGridTypeDefaults,
687
+ Re as useTypeDefault
626
688
  };
@@ -1 +1 @@
1
- {"version":3,"file":"data-grid.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/data-grid.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEnF,OAAO,EAA2E,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAChH,OAAO,aAAa,CAAC;AAGrB,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAgGrF;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,IAAI,GAAG,OAAO;IAC3C,0BAA0B;IAC1B,IAAI,EAAE,IAAI,EAAE,CAAC;IACb;;;;;;;;;;;;;;OAcG;IACH,UAAU,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IACnC,6DAA6D;IAC7D,OAAO,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAC/B,iCAAiC;IACjC,OAAO,CAAC,EAAE,SAAS,GAAG,aAAa,GAAG,UAAU,CAAC;IACjD,wBAAwB;IACxB,MAAM,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;IACvC,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,oEAAoE;IACpE,QAAQ,CAAC,EAAE,SAAS,CAAC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AO,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrD,oCAAoC;IACpC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,mCAAmC;IACnC,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,yBAAyB;IACzB,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,6BAA6B;IAC7B,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,+BAA+B;IAC/B,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,eAAO,MAAM,QAAQ,EAmPf,CAAC,IAAI,GAAG,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAA;CAAE,KAAK,KAAK,CAAC,YAAY,CAAC"}
@@ -0,0 +1,88 @@
1
+ import { ReactNode, ReactElement } from 'react';
2
+ /**
3
+ * Context object passed to the responsive card render function.
4
+ */
5
+ export interface ResponsiveCardContext<TRow = unknown> {
6
+ /** The row data for this card */
7
+ row: TRow;
8
+ /** The row index (zero-based) */
9
+ index: number;
10
+ }
11
+ /**
12
+ * Get the responsive card renderer for a grid element.
13
+ * @internal
14
+ */
15
+ export declare function getResponsiveCardRenderer(gridElement: HTMLElement): ((ctx: ResponsiveCardContext<unknown>) => ReactNode) | undefined;
16
+ /**
17
+ * Props for the GridResponsiveCard component.
18
+ */
19
+ export interface GridResponsiveCardProps<TRow = unknown> {
20
+ /**
21
+ * Render function for the card content.
22
+ * Receives the row data and row index.
23
+ *
24
+ * @example
25
+ * ```tsx
26
+ * <GridResponsiveCard>
27
+ * {({ row, index }) => (
28
+ * <div className="custom-card">
29
+ * <img src={row.avatar} alt={row.name} />
30
+ * <span>{row.name}</span>
31
+ * </div>
32
+ * )}
33
+ * </GridResponsiveCard>
34
+ * ```
35
+ */
36
+ children: (ctx: ResponsiveCardContext<TRow>) => ReactNode;
37
+ /**
38
+ * Card row height in pixels.
39
+ * Use 'auto' for dynamic height based on content.
40
+ * @default 'auto'
41
+ */
42
+ cardRowHeight?: number | 'auto';
43
+ }
44
+ /**
45
+ * Component for defining custom card layouts in responsive mode.
46
+ *
47
+ * Renders a `<tbw-grid-responsive-card>` custom element in the light DOM that
48
+ * the ResponsivePlugin picks up to render custom cards in mobile/narrow layouts.
49
+ *
50
+ * ## Usage
51
+ *
52
+ * ```tsx
53
+ * import { DataGrid, GridResponsiveCard } from '@toolbox-web/grid-react';
54
+ * import { ResponsivePlugin } from '@toolbox-web/grid/all';
55
+ *
56
+ * function EmployeeGrid() {
57
+ * const config = {
58
+ * plugins: [new ResponsivePlugin({ breakpoint: 500 })],
59
+ * // ... other config
60
+ * };
61
+ *
62
+ * return (
63
+ * <DataGrid rows={employees} gridConfig={config}>
64
+ * <GridResponsiveCard cardRowHeight={80}>
65
+ * {({ row, index }) => (
66
+ * <div className="employee-card">
67
+ * <img src={row.avatar} alt="" />
68
+ * <div>
69
+ * <strong>{row.name}</strong>
70
+ * <span>{row.department}</span>
71
+ * </div>
72
+ * </div>
73
+ * )}
74
+ * </GridResponsiveCard>
75
+ * </DataGrid>
76
+ * );
77
+ * }
78
+ * ```
79
+ *
80
+ * ## How it works
81
+ *
82
+ * 1. This component renders a `<tbw-grid-responsive-card>` element in the grid's light DOM
83
+ * 2. The ReactGridAdapter detects this element and creates a card renderer
84
+ * 3. When the grid enters responsive mode, the plugin calls your render function for each row
85
+ * 4. The React component is rendered into the card container
86
+ */
87
+ export declare function GridResponsiveCard<TRow = unknown>(props: GridResponsiveCardProps<TRow>): ReactElement;
88
+ //# sourceMappingURL=grid-responsive-card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-responsive-card.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/grid-responsive-card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,IAAI,GAAG,OAAO;IACnD,iCAAiC;IACjC,GAAG,EAAE,IAAI,CAAC;IACV,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;CACf;AAUD;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,WAAW,GACvB,CAAC,CAAC,GAAG,EAAE,qBAAqB,CAAC,OAAO,CAAC,KAAK,SAAS,CAAC,GAAG,SAAS,CAelE;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB,CAAC,IAAI,GAAG,OAAO;IACrD;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,EAAE,CAAC,GAAG,EAAE,qBAAqB,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;IAE1D;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,GAAG,OAAO,EAAE,KAAK,EAAE,uBAAuB,CAAC,IAAI,CAAC,GAAG,YAAY,CA+BrG"}
@@ -98,6 +98,11 @@ export declare class ReactGridAdapter implements FrameworkAdapter {
98
98
  * Parses the <tbw-grid-detail> element and returns a React-based renderer.
99
99
  */
100
100
  parseDetailElement<TRow = unknown>(detailElement: Element): ((row: TRow, rowIndex: number) => HTMLElement | string) | undefined;
101
+ /**
102
+ * Creates a responsive card renderer function for ResponsivePlugin.
103
+ * Renders React components for card layout in responsive mode.
104
+ */
105
+ createResponsiveCardRenderer<TRow = unknown>(gridElement: HTMLElement): ((row: TRow, rowIndex: number) => HTMLElement) | undefined;
101
106
  /**
102
107
  * Creates a tool panel renderer from a light DOM element.
103
108
  * Renders React components into tool panel containers.
@@ -127,7 +132,7 @@ export declare class ReactGridAdapter implements FrameworkAdapter {
127
132
  * // Any grid with type: 'country' columns will use these components
128
133
  * ```
129
134
  */
130
- getTypeDefault(type: string): TypeDefault | undefined;
135
+ getTypeDefault<TRow = unknown>(type: string): TypeDefault<TRow> | undefined;
131
136
  /**
132
137
  * Creates a renderer function from a React render function for type defaults.
133
138
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"react-grid-adapter.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/react-grid-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,OAAO,KAAK,EAAoB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAiB9E;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,CAAC,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,SAAS,GAChE,IAAI,CAaN;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,CAAC,GAAG,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,SAAS,GAChE,IAAI,CAYN;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,WAAW,GACnB,CAAC,CAAC,GAAG,EAAE,iBAAiB,CAA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AAC,IAAI,GAAG,OAAO,EACzC,WAAW,EAAE,WAAW,GACvB,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,WAAW,CAAC,GAAG,SAAS;IAwB7D;;;OAGG;IACH,uBAAuB,CAAC,OAAO,EAAE,WAAW,GAAG,CAAC,CAAC,SAAS,EAAE,WAAW,KAAK,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,SAAS;IAqC5G;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,cAAc,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,SAAS;IA6B3E;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAkB1B;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAkBxB;;;OAGG;IACH,OAAO,IAAI,IAAI;IAWf;;OAEG;IACH,OAAO,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI;CAYtC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolbox-web/grid-react",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "React adapter for @toolbox-web/grid data grid component",
5
5
  "type": "module",
6
6
  "main": "./index.js",