Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/joint-react/src/components/paper/paper.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@ export type DefaultLink =
| ((context: DefaultLinkParams) => dia.Link | Partial<LinkRecord>)
| Partial<LinkRecord>;

/** 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) ─────────────────────────────────────────────────

/**
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -237,7 +240,7 @@ export type RenderLink<LinkData = unknown> = (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.
*
Expand Down
4 changes: 2 additions & 2 deletions packages/joint-react/src/hooks/use-create-portal-paper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 { DefaultLink, PaperProps, RenderLink } from '../components/paper/paper.types';
import { HTMLBox } from '../components/html-box';

import { mapLinkToAttributes } from '../state/data-mapping';
Expand Down Expand Up @@ -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: 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.
Expand Down
1 change: 1 addition & 0 deletions packages/joint-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type { IncrementalCellsChange } from './store/graph-projection';
export { Paper } from './components/paper/paper';
export type {
PaperProps,
PaperOptions,
PaperTransform,
RenderElement,
RenderLink,
Expand Down