@toolbox-web/grid-react 1.3.0 → 1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"portal-manager.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/portal-manager.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAuD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAU5F;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,GAAG,IAAI,CAAC;IAE5E;;;;;;;OAOG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEhD,0BAA0B;IAC1B,KAAK,IAAI,IAAI,CAAC;CACf;AAMD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,+FAsFxB,CAAC"}
1
+ {"version":3,"file":"portal-manager.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/portal-manager.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAkE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAsDvG;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,GAAG,IAAI,CAAC;IAE5E;;;;;;;OAOG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEhD,0BAA0B;IAC1B,KAAK,IAAI,IAAI,CAAC;CACf;AAMD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,+FA6IxB,CAAC"}
@@ -81,12 +81,18 @@ export type GridConfig<TRow = unknown> = Omit<BaseGridConfig<TRow>, 'columns' |
81
81
  loadingRenderer?: BaseGridConfig<TRow>['loadingRenderer'] | ((ctx: LoadingContext) => ReactNode);
82
82
  };
83
83
  /**
84
- * Clean up config-based editor portals whose containers are inside the given element.
85
- * Called by the React GridAdapter's releaseCell to properly unmount editor portals
86
- * that were created by `wrapReactEditor` (which bypasses the adapter's tracking).
84
+ * Clean up config-based editor and renderer portals whose containers are
85
+ * inside the given element. Called by the React GridAdapter's `releaseCell`
86
+ * to unmount portals created by `wrapReactEditor` / `wrapReactRenderer`
87
+ * (which bypass the adapter's per-cell portal tracking).
87
88
  *
88
- * Only targets editor containers (`.react-cell-editor`), not renderer containers,
89
- * since renderers use a WeakMap cache and must survive cell recycling.
89
+ * Targets both `.react-cell-editor` AND `.react-cell-renderer` containers:
90
+ * editors always tear down on cell release, and renderers MUST also tear
91
+ * down before the editing pipeline runs `cell.innerHTML = ''` (otherwise
92
+ * React's still-mounted fiber tree points at orphan DOM and throws on the
93
+ * next commit — see `wrapReactRenderer` doc and issue #250). The renderer
94
+ * cache will create a fresh container on the next render via its
95
+ * cellEl.contains() check.
90
96
  *
91
97
  * @internal
92
98
  */
@@ -94,6 +100,21 @@ export declare function cleanupConfigRootsIn(parentEl: HTMLElement): void;
94
100
  /**
95
101
  * Wraps a React renderer function into a DOM-returning viewRenderer.
96
102
  * Used internally by DataGrid to process reactRenderer properties.
103
+ *
104
+ * Cache invariant: a cached `{ portalKey, container }` is only safe to reuse
105
+ * while `container` is still attached to the original cell. The editing
106
+ * pipeline (`editor-injection.ts`) wipes a cell with `cell.innerHTML = ''`
107
+ * when an editor opens — this detaches the renderer container from the cell
108
+ * without React knowing, leaving React's fiber tree pointing at orphaned
109
+ * nodes. If we then reuse the cached entry on the next render, the user's
110
+ * `onCellCommit` → `setRows` triggers a React commit that tries to
111
+ * `removeChild` nodes that no longer exist in the DOM and throws
112
+ * `NotFoundError: Failed to execute 'removeChild' on 'Node'` (issue #250).
113
+ *
114
+ * Defense: before reusing a cached entry, verify the container is still
115
+ * inside the cell. If not, synchronously unmount the stale React root
116
+ * (`removeFromContainer(..., { sync: true })` so it tears down before any
117
+ * batched user setState runs against it) and create a fresh container.
97
118
  */
98
119
  export declare function wrapReactRenderer<TRow>(renderFn: (ctx: CellRenderContext<TRow>) => ReactNode): (ctx: CellRenderContext<TRow>) => HTMLElement;
99
120
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"react-column-config.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/react-column-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,UAAU,IAAI,cAAc,EAC5B,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,YAAY,CAAC,IAAI,GAAG,OAAO,CAAE,SAAQ,IAAI,CACxD,gBAAgB,CAAC,IAAI,CAAC,EACtB,UAAU,GAAG,cAAc,GAAG,QAAQ,GAAG,gBAAgB,GAAG,qBAAqB,CAClF;IACC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;IAEvD;;;;;OAKG;IACH,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,mBAAmB,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;IAEvD;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;IAE7D;;;OAGG;IACH,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,kBAAkB,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;CACpE;AAKD;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;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,SAAS,GAC3C,CAAC,GAAG,EAAE,cAAc,KAAK,WAAW,GAAG,MAAM,CAoB/C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC,GAAG,SAAS,CA0D9G"}
1
+ {"version":3,"file":"react-column-config.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/react-column-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,UAAU,IAAI,cAAc,EAC5B,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,YAAY,CAAC,IAAI,GAAG,OAAO,CAAE,SAAQ,IAAI,CACxD,gBAAgB,CAAC,IAAI,CAAC,EACtB,UAAU,GAAG,cAAc,GAAG,QAAQ,GAAG,gBAAgB,GAAG,qBAAqB,CAClF;IACC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;IAEvD;;;;;OAKG;IACH,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,mBAAmB,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;IAEvD;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;IAE7D;;;OAGG;IACH,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,kBAAkB,CAAC,IAAI,CAAC,KAAK,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AAE,kBAAkB,CAAC,IAAI,CAAC,KAAK,WAAW,CAWhD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,SAAS,GAC3C,CAAC,GAAG,EAAE,cAAc,KAAK,WAAW,GAAG,MAAM,CAoB/C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC,GAAG,SAAS,CA0D9G"}
@@ -69,6 +69,38 @@ export declare class GridAdapter implements FrameworkAdapter {
69
69
  private editorPortalKeys;
70
70
  /** Maps portal keys to their containers (for container-based lookups in releaseCell/unmount). */
71
71
  private keyToContainer;
72
+ /**
73
+ * Reverse index: container element → portal key. Maintained alongside
74
+ * `keyToContainer` so `releaseCell` can resolve only the containers
75
+ * actually inside the released cell (via `cellEl.querySelectorAll`)
76
+ * instead of scanning every tracked portal — important for grids with
77
+ * many cells, where `releaseCell` runs on every cell teardown.
78
+ */
79
+ private containerToKey;
80
+ /**
81
+ * Per-editor `before-edit-close` listener teardown functions, keyed by portal key.
82
+ *
83
+ * The grid's editing plugin emits `before-edit-close` on the host `<tbw-grid>`
84
+ * before tearing down a row's managed editors. React editors commonly write
85
+ * `onBlur={commit}` to flush local state on click-away, but Tab / programmatic
86
+ * row exit rebuilds the cell DOM synchronously without giving the focused
87
+ * input a chance to fire `blur` first.
88
+ *
89
+ * To bridge that gap we call `.blur()` on the focused input inside the editor
90
+ * container as soon as `before-edit-close` fires. The native `.blur()` method
91
+ * is what React's event system actually observes — React 17+ delegates focus
92
+ * events at the root by listening to `focusout` (bubbling) and mapping it to
93
+ * `onBlur`. A bare `dispatchEvent(new FocusEvent('blur'))` would be ignored
94
+ * by React because `blur` does not bubble. Calling the native `.blur()`
95
+ * dispatches the full focus-loss chain (`blur` + `focusout`) and also moves
96
+ * focus off the input — both desirable here since the editor DOM is about to
97
+ * be torn down anyway.
98
+ *
99
+ * Mirrors the Angular adapter's `BaseGridEditor.onBeforeEditClose()` hook.
100
+ * Requires zero per-editor code: any editor with `onBlur={commit}` is
101
+ * automatically covered for Tab commits and programmatic row exit.
102
+ */
103
+ private editorBeforeCloseUnsubs;
72
104
  private typeDefaults;
73
105
  /**
74
106
  * Sets the type defaults map for this adapter.
@@ -185,9 +217,25 @@ export declare class GridAdapter implements FrameworkAdapter {
185
217
  destroy(): void;
186
218
  /**
187
219
  * Called when a cell's content is about to be wiped.
188
- * Destroys editor portals whose container is inside the cell.
189
- * Also cleans up config-based editor roots (from processGridConfig/wrapReactEditor)
190
- * that bypass the adapter's tracking.
220
+ *
221
+ * Destroys editor portals AND renderer portals whose container is inside
222
+ * the cell. Releasing renderers here is critical: the editing pipeline
223
+ * runs `cell.innerHTML = ''` immediately after this returns, which
224
+ * silently detaches React-managed renderer containers from the DOM.
225
+ * If we leave the React root mounted, its fiber tree still believes
226
+ * the now-orphaned children are present — a subsequent React commit
227
+ * (e.g. the user's `onCellCommit` → `setRows`) tries to `removeChild`
228
+ * those gone nodes and throws `NotFoundError` (issue #250).
229
+ *
230
+ * Calling this BEFORE the wipe lets React unmount cleanly while DOM
231
+ * still matches its fiber tree. The `wrapReactRenderer` cache will
232
+ * detect the missing entry on the next render and create a fresh
233
+ * container — see the cache-validation defense in `createRenderer`
234
+ * and `wrapReactRenderer` (`react-column-config.ts`).
235
+ *
236
+ * Also cleans up config-based editor and renderer roots
237
+ * (from processGridConfig/wrapReactEditor/wrapReactRenderer) that
238
+ * bypass the adapter's own portal tracking.
191
239
  */
192
240
  releaseCell(cellEl: HTMLElement): void;
193
241
  /**
@@ -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,E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;OAuBG;IACH,cAAc,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,SAAS;IAmCjG;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAiB1B;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAiBxB;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IAmBjC,oDAAoD;IACpD,OAAO,CAAC,WAAW;IASnB,sDAAsD;IACtD,OAAO,CAAC,aAAa;IAerB;;;OAGG;IACH,OAAO,IAAI,IAAI;IAaf;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAiBtC;;OAEG;IACH,OAAO,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI;CAOtC"}
@@ -0,0 +1,74 @@
1
+ import { DataGridElement } from '@toolbox-web/grid';
2
+ import { RefObject } from 'react';
3
+ /**
4
+ * Options for {@link useGridOverlay}.
5
+ *
6
+ * @public
7
+ */
8
+ export interface UseGridOverlayOptions {
9
+ /**
10
+ * Whether the overlay is currently open.
11
+ *
12
+ * Set to `false` to unregister the panel without unmounting it (e.g. when
13
+ * the consumer toggles visibility via CSS rather than conditional render).
14
+ * Defaults to `true`.
15
+ */
16
+ open?: boolean;
17
+ /**
18
+ * Optional explicit grid element. When omitted, the hook resolves the
19
+ * grid by:
20
+ *
21
+ * 1. Walking up the DOM from `panelRef.current` via `closest('tbw-grid')`
22
+ * (works for inline overlays).
23
+ * 2. Falling back to the {@link GridElementContext} populated by
24
+ * `<DataGrid>` / `<GridProvider>` (works for portal-rendered overlays
25
+ * whose DOM is detached from the grid subtree).
26
+ */
27
+ gridElement?: DataGridElement | null;
28
+ }
29
+ /**
30
+ * Register a custom overlay panel (popover, listbox, calendar, color
31
+ * picker) as part of the active editor so the grid does not commit and
32
+ * exit row edit when focus or pointer interaction enters the panel.
33
+ *
34
+ * Mirrors the Angular `BaseOverlayEditor` contract for React custom
35
+ * editors. Wires `registerExternalFocusContainer(panel)` on mount/open
36
+ * and `unregisterExternalFocusContainer(panel)` on unmount/close.
37
+ *
38
+ * Pair with `ColumnEditorContext.grid` (see {@link DataGridElement}) when
39
+ * the panel is rendered outside any `<DataGrid>` provider.
40
+ *
41
+ * @example
42
+ * ```tsx
43
+ * function AutocompleteEditor({ value, commit, cancel }: GridEditorContext<Row>) {
44
+ * const [open, setOpen] = useState(false);
45
+ * const panelRef = useRef<HTMLDivElement | null>(null);
46
+ * useGridOverlay(panelRef, { open });
47
+ * return (
48
+ * <>
49
+ * <input
50
+ * aria-expanded={open}
51
+ * aria-controls="ac-listbox"
52
+ * onClick={() => setOpen(true)}
53
+ * onKeyDown={(e) => e.key === 'Enter' && commit(e.currentTarget.value)}
54
+ * />
55
+ * {open &&
56
+ * createPortal(
57
+ * <div id="ac-listbox" ref={panelRef} role="listbox">
58
+ * {options}
59
+ * </div>,
60
+ * document.body,
61
+ * )}
62
+ * </>
63
+ * );
64
+ * }
65
+ * ```
66
+ *
67
+ * @param panelRef - Ref to the overlay panel DOM element. The hook is a
68
+ * no-op while `panelRef.current` is `null`.
69
+ * @param options - {@link UseGridOverlayOptions}.
70
+ *
71
+ * @public
72
+ */
73
+ export declare function useGridOverlay(panelRef: RefObject<HTMLElement | null>, options?: UseGridOverlayOptions): void;
74
+ //# sourceMappingURL=use-grid-overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-grid-overlay.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/use-grid-overlay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAI9D;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EAAE,OAAO,GAAE,qBAA0B,GAAG,IAAI,CAiBjH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolbox-web/grid-react",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "React adapter for @toolbox-web/grid data grid component",
5
5
  "type": "module",
6
6
  "main": "./index.js",