fix(node-resizer): pass minWidth and minHeight to child components

This commit is contained in:
Christopher Möller
2022-12-06 19:25:45 +01:00
parent c8adc98fd2
commit 527cf13352
5 changed files with 17 additions and 3 deletions

View File

@@ -4,10 +4,10 @@ import { Handle, Position, NodeProps } from 'reactflow';
import { NodeResizer } from '@reactflow/node-resizer';
import '@reactflow/node-resizer/dist/style.css';
const CustomNode: FC<NodeProps> = ({ id, data, selected }) => {
const CustomNode: FC<NodeProps> = ({ data, selected }) => {
return (
<>
<NodeResizer isVisible={selected} />
<NodeResizer minWidth={100} minHeight={100} isVisible={selected} />
<Handle type="target" position={Position.Left} />
<div>{data.label}</div>
<Handle type="source" position={Position.Right} />

View File

@@ -1,5 +1,11 @@
# @reactflow/node-resizer
## 1.0.1
### Patch Changes
- pass `minWidth` and `minHeight` from `NodeResizer` component to `NodeResizeControl`
## 1.0.0
This is a new package that exports components to build a UI for resizing a node 🎉 It exports a [`<NodeResizer />`](https://reactflow.dev/docs/api/nodes/node-resizer/) component and a [`<NodeResizeControl />`](https://reactflow.dev/docs/api/nodes/node-resizer/#noderesizecontrol--component) component.

View File

@@ -1,6 +1,6 @@
{
"name": "@reactflow/node-resizer",
"version": "1.0.0",
"version": "1.0.1",
"description": "A helper component for resizing nodes.",
"keywords": [
"react",

View File

@@ -12,6 +12,8 @@ export default function NodeResizer({
lineClassName,
lineStyle,
color,
minWidth = 10,
minHeight = 10,
}: NodeResizerProps) {
if (!isVisible) {
return null;
@@ -28,6 +30,8 @@ export default function NodeResizer({
position={c}
variant={ResizeControlVariant.Line}
color={color}
minWidth={minWidth}
minHeight={minHeight}
/>
))}
{handleControls.map((c) => (
@@ -38,6 +42,8 @@ export default function NodeResizer({
nodeId={nodeId}
position={c}
color={color}
minWidth={minWidth}
minHeight={minHeight}
/>
))}
</>

View File

@@ -9,6 +9,8 @@ export type NodeResizerProps = {
lineClassName?: string;
lineStyle?: CSSProperties;
isVisible?: boolean;
minWidth?: number;
minHeight?: number;
};
export type ControlLinePosition = 'top' | 'bottom' | 'left' | 'right';