From 540caf93a000d54ba1913f3ccda38b7481e39167 Mon Sep 17 00:00:00 2001 From: Roman Bruckner Date: Thu, 11 Jun 2026 11:23:29 +0200 Subject: [PATCH 1/2] refactor(joint-react): align Paper options naming with react-plus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirror the `@joint/react-plus` convention so the two packages name the same concepts the same way: - Add and export `PaperOptions = dia.Paper.Options` — a named type for the `options` escape-hatch prop (was an inline type with no public name). Symmetric with react-plus `Options`. - Rename the supported-props base `PortalPaperOptions` -> `PaperSupportedOptions` (internal; not exported), matching react-plus `SupportedOptions`. No behavior change; `PaperProps` is unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/joint-react/src/components/paper/paper.types.ts | 9 ++++++--- .../joint-react/src/hooks/use-create-portal-paper.tsx | 4 ++-- packages/joint-react/src/index.ts | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/joint-react/src/components/paper/paper.types.ts b/packages/joint-react/src/components/paper/paper.types.ts index 00f8866ef0..7947d6db7f 100644 --- a/packages/joint-react/src/components/paper/paper.types.ts +++ b/packages/joint-react/src/components/paper/paper.types.ts @@ -44,13 +44,16 @@ export type DefaultLink = | ((context: DefaultLinkParams) => dia.Link | Partial) | Partial; +/** Raw `dia.Paper.Options` passthrough — the type of the `options` escape-hatch prop. */ +export type PaperOptions = dia.Paper.Options; + /** * Officially supported Paper options. Pass-through props inherit their exact * native types via indexed access (`dia.Paper.Options['name']`), so any * type-level change in JointJS propagates automatically. Anything not listed * here is reachable via the `options` escape hatch, never implicitly exposed. */ -export interface PortalPaperOptions { +export interface PaperSupportedOptions { // ── Wrapped (structured) ───────────────────────────────────────────────── /** @@ -186,7 +189,7 @@ export interface PortalPaperOptions { * (`async`, `sorting`, `viewManagement`, `frozen`, `autoFreeze`) — the * portal rendering depends on their set values. */ - readonly options?: dia.Paper.Options; + readonly options?: PaperOptions; } /** @@ -237,7 +240,7 @@ export type RenderLink = (data: LinkData) => ReactNode; * use the `usePaperEvents` hook. * @see https://docs.jointjs.com/api/dia/Paper */ -export interface PaperProps extends PortalPaperOptions, PropsWithChildren, PaperEventHandlers { +export interface PaperProps extends PaperSupportedOptions, PropsWithChildren, PaperEventHandlers { /** * A function that renders the element. * diff --git a/packages/joint-react/src/hooks/use-create-portal-paper.tsx b/packages/joint-react/src/hooks/use-create-portal-paper.tsx index c0e9a2b618..5c2b9eea63 100644 --- a/packages/joint-react/src/hooks/use-create-portal-paper.tsx +++ b/packages/joint-react/src/hooks/use-create-portal-paper.tsx @@ -21,7 +21,7 @@ import { useCallback, useSyncExternalStore } from 'react'; import type { LinkRecord } from '../types/cell.types'; import type { PaperStore } from '../store'; import { ReactPaper } from '../mvc/react-paper'; -import type { PaperProps, PortalPaperOptions, RenderLink } from '../components/paper/paper.types'; +import type { PaperProps, PaperSupportedOptions, RenderLink } from '../components/paper/paper.types'; import { HTMLBox } from '../components/html-box'; import { mapLinkToAttributes } from '../state/data-mapping'; @@ -101,7 +101,7 @@ function getLinkModelConstructor(graph: dia.Graph): LinkModelConstructor { * into JointJS link model instances. * @param defaultLink */ -function createDefaultLinkCallback(defaultLink: PortalPaperOptions['defaultLink']) { +function createDefaultLinkCallback(defaultLink: PaperSupportedOptions['defaultLink']) { // Guard for JS callers (TS already forbids it): a raw `dia.Link` instance // would force defensive `.clone()` on every connection and silently couple // every created link to one mutable model. Require a factory instead. diff --git a/packages/joint-react/src/index.ts b/packages/joint-react/src/index.ts index 465e939589..02f52d1b67 100644 --- a/packages/joint-react/src/index.ts +++ b/packages/joint-react/src/index.ts @@ -18,6 +18,7 @@ export type { IncrementalCellsChange } from './store/graph-projection'; export { Paper } from './components/paper/paper'; export type { PaperProps, + PaperOptions, PaperTransform, RenderElement, RenderLink, From b90cf93652cc8b1ab3a5014b2eeb6847b7c1f394 Mon Sep 17 00:00:00 2001 From: Roman Bruckner Date: Thu, 11 Jun 2026 14:38:37 +0200 Subject: [PATCH 2/2] refactor(joint-react): type defaultLink helper with DefaultLink Use the canonical exported `DefaultLink` type directly (with `| undefined`, since the `defaultLink` prop is optional and the helper handles the absent case) instead of the internal `PaperSupportedOptions` base or a `PaperProps['defaultLink']` indexed access. Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/joint-react/src/hooks/use-create-portal-paper.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/joint-react/src/hooks/use-create-portal-paper.tsx b/packages/joint-react/src/hooks/use-create-portal-paper.tsx index 5c2b9eea63..9aff129efc 100644 --- a/packages/joint-react/src/hooks/use-create-portal-paper.tsx +++ b/packages/joint-react/src/hooks/use-create-portal-paper.tsx @@ -21,7 +21,7 @@ import { useCallback, useSyncExternalStore } from 'react'; import type { LinkRecord } from '../types/cell.types'; import type { PaperStore } from '../store'; import { ReactPaper } from '../mvc/react-paper'; -import type { PaperProps, PaperSupportedOptions, RenderLink } from '../components/paper/paper.types'; +import type { DefaultLink, PaperProps, RenderLink } from '../components/paper/paper.types'; import { HTMLBox } from '../components/html-box'; import { mapLinkToAttributes } from '../state/data-mapping'; @@ -101,7 +101,7 @@ function getLinkModelConstructor(graph: dia.Graph): LinkModelConstructor { * into JointJS link model instances. * @param defaultLink */ -function createDefaultLinkCallback(defaultLink: PaperSupportedOptions['defaultLink']) { +function createDefaultLinkCallback(defaultLink: DefaultLink | undefined) { // Guard for JS callers (TS already forbids it): a raw `dia.Link` instance // would force defensive `.clone()` on every connection and silently couple // every created link to one mutable model. Require a factory instead.