diff --git a/.changeset/hip-chairs-tap.md b/.changeset/hip-chairs-tap.md new file mode 100644 index 00000000..cac9ef29 --- /dev/null +++ b/.changeset/hip-chairs-tap.md @@ -0,0 +1,5 @@ +--- +'@xyflow/system': patch +--- + +Allow null for extent diff --git a/packages/system/src/types/nodes.ts b/packages/system/src/types/nodes.ts index 687f81ba..37293e61 100644 --- a/packages/system/src/types/nodes.ts +++ b/packages/system/src/types/nodes.ts @@ -57,7 +57,7 @@ export type NodeBase< * Boundary a node can be moved in. * @example 'parent' or [[0, 0], [100, 100]] */ - extent?: 'parent' | CoordinateExtent; + extent?: 'parent' | CoordinateExtent | null; /** * When `true`, the parent node will automatically expand if this node is dragged to the edge of * the parent node's bounds. @@ -151,12 +151,7 @@ export type NodeDragItem = { internals: { positionAbsolute: XYPosition; }; - extent?: 'parent' | CoordinateExtent; - parentId?: string; - dragging?: boolean; - origin?: NodeOrigin; - expandParent?: boolean; -}; +} & Pick; /** * The origin of a Node determines how it is placed relative to its own coordinates. diff --git a/packages/system/src/utils/general.ts b/packages/system/src/utils/general.ts index fdfd6b75..a57b25a2 100644 --- a/packages/system/src/utils/general.ts +++ b/packages/system/src/utils/general.ts @@ -335,8 +335,8 @@ export const getViewportForBounds = ( export const isMacOs = () => typeof navigator !== 'undefined' && navigator?.userAgent?.indexOf('Mac') >= 0; -export function isCoordinateExtent(extent?: CoordinateExtent | 'parent'): extent is CoordinateExtent { - return extent !== undefined && extent !== 'parent'; +export function isCoordinateExtent(extent?: CoordinateExtent | 'parent' | null): extent is CoordinateExtent { + return extent !== undefined && extent !== null && extent !== 'parent'; } export function getNodeDimensions(node: { diff --git a/packages/system/src/xyresizer/XYResizer.ts b/packages/system/src/xyresizer/XYResizer.ts index 03a0675e..e6aace30 100644 --- a/packages/system/src/xyresizer/XYResizer.ts +++ b/packages/system/src/xyresizer/XYResizer.ts @@ -41,7 +41,7 @@ export type XYResizerChange = { export type XYResizerChildChange = { id: string; position: XYPosition; - extent?: 'parent' | CoordinateExtent; + extent?: NodeBase['extent']; }; type XYResizerParams = {