From e58e90da1ced6068e012205f2a9694b907536835 Mon Sep 17 00:00:00 2001 From: BrianHung Date: Sat, 22 Jun 2024 18:34:04 -0700 Subject: [PATCH] expose renderers prop to allow custom internal renderers --- packages/core/src/data-editor-all.tsx | 8 +++++-- packages/core/src/index.ts | 1 + packages/core/test/data-editor.test.tsx | 28 +++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/packages/core/src/data-editor-all.tsx b/packages/core/src/data-editor-all.tsx index 8cdd822c5..11ca5848c 100644 --- a/packages/core/src/data-editor-all.tsx +++ b/packages/core/src/data-editor-all.tsx @@ -5,7 +5,7 @@ import { sprites } from "./internal/data-grid/sprites.js"; import ImageWindowLoaderImpl from "./common/image-window-loader.js"; import type { ImageWindowLoader } from "./internal/data-grid/image-window-loader-interface.js"; -export interface DataEditorAllProps extends Omit { +export interface DataEditorAllProps extends Omit { imageWindowLoader?: ImageWindowLoader; } @@ -14,6 +14,10 @@ const DataEditorAllImpl: React.ForwardRefRenderFunction { + return p.renderers ?? AllCellRenderers; + }, [p.renderers]) + const imageWindowLoader = React.useMemo(() => { return p.imageWindowLoader ?? new ImageWindowLoaderImpl(); }, [p.imageWindowLoader]); @@ -21,7 +25,7 @@ const DataEditorAllImpl: React.ForwardRefRenderFunction { expect(onClickSpy).not.toBeCalled(); }); + test("renderers can override internal cells", async () => { + const spy = vi.fn(); + + vi.useFakeTimers(); + render( + , + ]} + rowMarkers="both" + />, + { + wrapper: Context, + } + ); + prep(); + expect(spy).toHaveBeenCalledTimes(31); // Math.ceil((height - headerHeight) / rowHeight) + }); + test("onCellsEdited blocks onCellEdited", async () => { const spy = vi.fn(); vi.useFakeTimers();