@toolbox-web/grid-react 1.6.0 → 1.6.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.
@@ -0,0 +1,68 @@
1
+ import { flushSync as d } from "react-dom";
2
+ import { createRoot as p } from "react-dom/client";
3
+ const o = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
4
+ let m = 0;
5
+ function B(e, t) {
6
+ t ? o.set(e, t) : o.delete(e);
7
+ }
8
+ function g(e, t) {
9
+ if (t) return t;
10
+ const n = e.closest("tbw-grid");
11
+ if (n) return n;
12
+ if (o.size === 1) return o.keys().next().value;
13
+ }
14
+ function u(e) {
15
+ const t = i.get(e);
16
+ if (t) {
17
+ try {
18
+ t.unmount();
19
+ } catch {
20
+ }
21
+ i.delete(e);
22
+ }
23
+ }
24
+ function v(e, t, n, r) {
25
+ const s = n ?? `p-${m++}`, a = g(e, r), l = a ? o.get(a) : void 0;
26
+ if (l)
27
+ u(s), a && f.set(s, a), l.renderPortal(s, e, t);
28
+ else {
29
+ let c = i.get(s);
30
+ c || (c = p(e), i.set(s, c)), d(() => c.render(t));
31
+ }
32
+ return s;
33
+ }
34
+ function M(e, t) {
35
+ const n = f.get(e);
36
+ (n ? o.get(n) : void 0)?.removePortal(e, t?.sync), f.delete(e), u(e);
37
+ }
38
+ function w(e) {
39
+ if (e) {
40
+ o.get(e)?.beginBatch();
41
+ return;
42
+ }
43
+ for (const t of o.values()) t.beginBatch();
44
+ }
45
+ function y(e) {
46
+ if (e) {
47
+ o.get(e)?.endBatch();
48
+ return;
49
+ }
50
+ for (const t of o.values()) t.endBatch();
51
+ }
52
+ function P(e) {
53
+ return (t) => {
54
+ const n = e(t);
55
+ if (n == null || n === !1) return null;
56
+ if (n instanceof HTMLElement) return n;
57
+ const r = document.createElement("div");
58
+ return r.style.display = "contents", v(r, n), r;
59
+ };
60
+ }
61
+ export {
62
+ v as a,
63
+ w as b,
64
+ P as c,
65
+ y as e,
66
+ M as r,
67
+ B as s
68
+ };
@@ -1,4 +1,4 @@
1
- import { a as u, r as f } from "./portal-bridge-CH_xMkYc.js";
1
+ import { a as u, r as f } from "./portal-bridge-BydpO5wl.js";
2
2
  const y = [];
3
3
  function H(e) {
4
4
  y.push(e);
@@ -1,16 +1,16 @@
1
- import { p as b, n as m, c as K } from "./react-column-config-B8Isgp88.js";
1
+ import { p as b, n as m, c as K } from "./react-column-config-Dz234dN8.js";
2
2
  import { jsx as T } from "react/jsx-runtime";
3
3
  import { useRef as k, useCallback as E, useEffect as w } from "react";
4
- import { a as u, r as g } from "./portal-bridge-CH_xMkYc.js";
4
+ import { a as u, r as g, b as B, e as D } from "./portal-bridge-BydpO5wl.js";
5
5
  const p = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new Map();
6
- function D(o) {
6
+ function M(o) {
7
7
  const e = p.get(o);
8
8
  if (e) return e;
9
9
  const t = o.id;
10
10
  if (t)
11
11
  return h.get(t);
12
12
  }
13
- function x(o) {
13
+ function W(o) {
14
14
  const { id: e, title: t, icon: r, tooltip: n, order: s = 100, children: i } = o, l = k(null), y = E(
15
15
  (a) => {
16
16
  l.current = a, a && (p.set(a, i), e && h.set(e, i));
@@ -33,47 +33,47 @@ function x(o) {
33
33
  );
34
34
  }
35
35
  let R = null, v = null, P = null;
36
- function S(o) {
36
+ function I(o) {
37
37
  R = o;
38
38
  }
39
- function W(o) {
39
+ function N(o) {
40
40
  v = o;
41
41
  }
42
- function I(o) {
42
+ function j(o) {
43
43
  P = o;
44
44
  }
45
- const d = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new Map();
46
- function N(o, e) {
47
- const t = o.getAttribute("field"), r = d.get(o) ?? {};
48
- if (r.renderer = e, d.set(o, r), t) {
49
- const n = c.get(t) ?? {};
50
- n.renderer = e, c.set(t, n);
45
+ const c = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new Map();
46
+ function q(o, e) {
47
+ const t = o.getAttribute("field"), r = c.get(o) ?? {};
48
+ if (r.renderer = e, c.set(o, r), t) {
49
+ const n = d.get(t) ?? {};
50
+ n.renderer = e, d.set(t, n);
51
51
  }
52
52
  }
53
- function j(o, e) {
54
- const t = o.getAttribute("field"), r = d.get(o) ?? {};
55
- if (r.editor = e, d.set(o, r), t) {
56
- const n = c.get(t) ?? {};
57
- n.editor = e, c.set(t, n);
53
+ function H(o, e) {
54
+ const t = o.getAttribute("field"), r = c.get(o) ?? {};
55
+ if (r.editor = e, c.set(o, r), t) {
56
+ const n = d.get(t) ?? {};
57
+ n.editor = e, d.set(t, n);
58
58
  }
59
59
  }
60
- function B(o) {
61
- let e = d.get(o)?.renderer;
60
+ function A(o) {
61
+ let e = c.get(o)?.renderer;
62
62
  if (!e) {
63
63
  const t = o.getAttribute("field");
64
- t && (e = c.get(t)?.renderer);
64
+ t && (e = d.get(t)?.renderer);
65
65
  }
66
66
  return e;
67
67
  }
68
- function M(o) {
69
- let e = d.get(o)?.editor;
68
+ function U(o) {
69
+ let e = c.get(o)?.editor;
70
70
  if (!e) {
71
71
  const t = o.getAttribute("field");
72
- t && (e = c.get(t)?.editor);
72
+ t && (e = d.get(t)?.editor);
73
73
  }
74
74
  return e;
75
75
  }
76
- class q {
76
+ class z {
77
77
  /** Portal keys for all managed portals (for cleanup on destroy). */
78
78
  allPortalKeys = /* @__PURE__ */ new Set();
79
79
  /** Portal keys for editor-specific portals (for per-cell cleanup via releaseCell). */
@@ -136,10 +136,10 @@ class q {
136
136
  */
137
137
  canHandle(e) {
138
138
  const t = e.getAttribute("field");
139
- let r = d.get(e);
139
+ let r = c.get(e);
140
140
  if (!r && t) {
141
- const i = c.get(t);
142
- i && (i.renderer || i.editor) && (r = i, d.set(e, r));
141
+ const i = d.get(t);
142
+ i && (i.renderer || i.editor) && (r = i, c.set(e, r));
143
143
  }
144
144
  const n = r?.renderer !== void 0, s = r?.editor !== void 0;
145
145
  return r !== void 0 && (n || s);
@@ -156,7 +156,7 @@ class q {
156
156
  * allowing the grid to use its default rendering.
157
157
  */
158
158
  createRenderer(e) {
159
- const t = B(e);
159
+ const t = A(e);
160
160
  if (!t)
161
161
  return;
162
162
  const r = e.closest("tbw-grid"), n = /* @__PURE__ */ new WeakMap();
@@ -195,7 +195,7 @@ class q {
195
195
  * with commit/cancel callbacks passed as props.
196
196
  */
197
197
  createEditor(e) {
198
- const t = M(e);
198
+ const t = U(e);
199
199
  if (!t)
200
200
  return () => document.createElement("div");
201
201
  const r = e.closest("tbw-grid") ?? void 0;
@@ -214,7 +214,7 @@ class q {
214
214
  /**
215
215
  * Creates a detail renderer function for MasterDetailPlugin.
216
216
  * Implementation is installed by `@toolbox-web/grid-react/features/master-detail`
217
- * via {@link registerDetailRendererBridge}. Returns undefined if the
217
+ * via `registerDetailRendererBridge`. Returns undefined if the
218
218
  * master-detail feature has not been imported, or if no GridDetailPanel
219
219
  * was registered for this grid.
220
220
  */
@@ -233,7 +233,7 @@ class q {
233
233
  /**
234
234
  * Creates a responsive card renderer function for ResponsivePlugin.
235
235
  * Implementation is installed by `@toolbox-web/grid-react/features/responsive`
236
- * via {@link registerResponsiveCardRendererBridge}. Returns undefined if
236
+ * via `registerResponsiveCardRendererBridge`. Returns undefined if
237
237
  * the responsive feature has not been imported, or if no GridResponsiveCard
238
238
  * was registered for this grid.
239
239
  */
@@ -258,7 +258,7 @@ class q {
258
258
  * Renders React components into tool panel containers.
259
259
  */
260
260
  createToolPanelRenderer(e) {
261
- const t = D(e);
261
+ const t = M(e);
262
262
  if (!t)
263
263
  return;
264
264
  const r = e.closest("tbw-grid");
@@ -365,7 +365,7 @@ class q {
365
365
  g(e);
366
366
  this.allPortalKeys.clear(), this.editorPortalKeys.clear(), this.keyToContainer.clear();
367
367
  for (const e of this.editorBeforeCloseUnsubs.values()) e();
368
- this.editorBeforeCloseUnsubs.clear(), c.clear();
368
+ this.editorBeforeCloseUnsubs.clear(), d.clear();
369
369
  }
370
370
  /**
371
371
  * Called when a cell's content is about to be wiped.
@@ -404,13 +404,33 @@ class q {
404
404
  const t = this.containerToKey.get(e);
405
405
  t && (g(t), this.untrackPortal(t));
406
406
  }
407
+ /**
408
+ * Open a teardown batch on the PortalManager. Grid core wraps multi-cell
409
+ * release loops (`_clearRowPool`, row-pool shrink, full row rebuild) with
410
+ * `beginBatch` / `endBatch` so the N per-cell sync removals collapse to a
411
+ * single deferred render instead of N `flushSync` calls. Eliminates the
412
+ * "flushSync was called from inside a lifecycle method" warning storm on
413
+ * grouping changes (#330).
414
+ */
415
+ beginBatch(e) {
416
+ B(e);
417
+ }
418
+ /**
419
+ * Close a teardown batch opened by {@link beginBatch}. Caller is
420
+ * responsible for ensuring affected containers are detached from the
421
+ * DOM before this returns; the manager's render-time `isConnected`
422
+ * filter then prunes them silently.
423
+ */
424
+ endBatch(e) {
425
+ D(e);
426
+ }
407
427
  }
408
428
  export {
409
- q as G,
410
- S as a,
411
- W as b,
412
- N as c,
413
- j as d,
414
- x as e,
415
- I as r
429
+ z as G,
430
+ I as a,
431
+ N as b,
432
+ q as c,
433
+ H as d,
434
+ W as e,
435
+ j as r
416
436
  };
@@ -1,5 +1,5 @@
1
1
  import "@toolbox-web/grid/features/editing";
2
- import { r, m as s } from "../chunks/react-column-config-B8Isgp88.js";
2
+ import { r, m as s } from "../chunks/react-column-config-Dz234dN8.js";
3
3
  r(({ container: t, gridEl: e }) => {
4
4
  const o = s(t);
5
5
  return e.addEventListener("before-edit-close", o), () => e.removeEventListener("before-edit-close", o);
@@ -2,8 +2,8 @@ import { FilteringPlugin as F } from "@toolbox-web/grid/plugins/filtering";
2
2
  import { useContext as h, useCallback as n } from "react";
3
3
  import { registerFeature as E } from "@toolbox-web/grid/features/registry";
4
4
  import { G as k } from "../chunks/grid-element-context-BU3WvNtM.js";
5
- import { r as v, a as m } from "../chunks/portal-bridge-CH_xMkYc.js";
6
- import { r as C } from "../chunks/react-grid-adapter-DeV_qtlr.js";
5
+ import { r as v, a as m } from "../chunks/portal-bridge-BydpO5wl.js";
6
+ import { r as C } from "../chunks/react-grid-adapter-KD5roD6F.js";
7
7
  E(
8
8
  "filtering",
9
9
  (l) => {
@@ -1,6 +1,6 @@
1
1
  import { GroupingColumnsPlugin as t } from "@toolbox-web/grid/plugins/grouping-columns";
2
2
  import { registerFeature as c } from "@toolbox-web/grid/features/registry";
3
- import { c as p } from "../chunks/portal-bridge-CH_xMkYc.js";
3
+ import { c as p } from "../chunks/portal-bridge-BydpO5wl.js";
4
4
  function u(n) {
5
5
  const r = p(n);
6
6
  return (o) => r(o) ?? document.createElement("div");
@@ -1,6 +1,6 @@
1
1
  import { GroupingRowsPlugin as o } from "@toolbox-web/grid/plugins/grouping-rows";
2
2
  import { registerFeature as c } from "@toolbox-web/grid/features/registry";
3
- import { c as p } from "../chunks/portal-bridge-CH_xMkYc.js";
3
+ import { c as p } from "../chunks/portal-bridge-BydpO5wl.js";
4
4
  c(
5
5
  "groupingRows",
6
6
  (e) => {
@@ -1,7 +1,7 @@
1
1
  import "@toolbox-web/grid/features/master-detail";
2
2
  import { g as c } from "../chunks/grid-detail-panel-CR7YUhdN.js";
3
- import { a as s } from "../chunks/portal-bridge-CH_xMkYc.js";
4
- import { a as d } from "../chunks/react-grid-adapter-DeV_qtlr.js";
3
+ import { a as s } from "../chunks/portal-bridge-BydpO5wl.js";
4
+ import { a as d } from "../chunks/react-grid-adapter-KD5roD6F.js";
5
5
  d((r, { trackPortal: n }) => {
6
6
  const t = c(r);
7
7
  if (t)
@@ -1,7 +1,7 @@
1
1
  import "@toolbox-web/grid/features/pinned-rows";
2
2
  import { PinnedRowsPlugin as o } from "@toolbox-web/grid/plugins/pinned-rows";
3
3
  import { registerFeature as m } from "@toolbox-web/grid/features/registry";
4
- import { c } from "../chunks/portal-bridge-CH_xMkYc.js";
4
+ import { c } from "../chunks/portal-bridge-BydpO5wl.js";
5
5
  function u(r) {
6
6
  return c(r);
7
7
  }
@@ -1,7 +1,7 @@
1
1
  import "@toolbox-web/grid/features/responsive";
2
2
  import { g as i } from "../chunks/grid-responsive-card-BB28Zl2O.js";
3
- import { a as c } from "../chunks/portal-bridge-CH_xMkYc.js";
4
- import { b as d } from "../chunks/react-grid-adapter-DeV_qtlr.js";
3
+ import { a as c } from "../chunks/portal-bridge-BydpO5wl.js";
4
+ import { b as d } from "../chunks/react-grid-adapter-KD5roD6F.js";
5
5
  d((r, { trackPortal: o }) => {
6
6
  const n = i(r);
7
7
  if (n)
package/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  export { DataGrid } from './lib/data-grid';
2
2
  export type { DataGridProps, DataGridRef } from './lib/data-grid';
3
3
  export { GridColumn } from './lib/grid-column';
4
+ export type { GridColumnProps } from './lib/grid-column';
4
5
  export { GridDetailPanel, type DetailPanelContext, type GridDetailPanelProps } from './lib/grid-detail-panel';
5
6
  export { GridResponsiveCard, type GridResponsiveCardProps, type ResponsiveCardContext, } from './lib/grid-responsive-card';
6
7
  export { GridToolButtons, type GridToolButtonsProps } from './lib/grid-tool-button';
7
8
  export { GridToolPanel, type GridToolPanelProps, type ToolPanelContext } from './lib/grid-tool-panel';
8
- export type { AllFeatureProps, FeatureProps, SSRProps } from './lib/feature-props';
9
+ export type { AllFeatureProps, FeatureProps, ReactColumnGroupDefinition, ReactFilterConfig, ReactGroupingColumnsConfig, SSRProps, } from './lib/feature-props';
9
10
  export { applyColumnDefaults, hasColumnShorthands, normalizeColumns, parseColumnShorthand, } from './lib/column-shorthand';
10
11
  export type { ColumnShorthand } from './lib/column-shorthand';
11
12
  export type { EventHandler, EventProps } from './lib/event-props';
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;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,YAAY,CAAC;AAGpB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAi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