refactor(handle): pass children and standard HTMLAttributes props closes #833
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { memo, useContext, useCallback } from 'react';
|
import React, { memo, useContext, useCallback, FunctionComponent, HTMLAttributes } from 'react';
|
||||||
import cc from 'classcat';
|
import cc from 'classcat';
|
||||||
|
|
||||||
import { useStoreActions, useStoreState } from '../../store/hooks';
|
import { useStoreActions, useStoreState } from '../../store/hooks';
|
||||||
@@ -9,16 +9,17 @@ import { onMouseDown } from './handler';
|
|||||||
|
|
||||||
const alwaysValid = () => true;
|
const alwaysValid = () => true;
|
||||||
|
|
||||||
const Handle = ({
|
const Handle: FunctionComponent<HandleProps & Omit<HTMLAttributes<HTMLDivElement>, 'id'>> = ({
|
||||||
type = 'source',
|
type = 'source',
|
||||||
position = Position.Top,
|
position = Position.Top,
|
||||||
isValidConnection = alwaysValid,
|
isValidConnection = alwaysValid,
|
||||||
isConnectable = true,
|
isConnectable = true,
|
||||||
style,
|
|
||||||
className,
|
|
||||||
id,
|
id,
|
||||||
onConnect,
|
onConnect,
|
||||||
}: HandleProps) => {
|
children,
|
||||||
|
className,
|
||||||
|
...rest
|
||||||
|
}) => {
|
||||||
const nodeId = useContext(NodeIdContext) as ElementId;
|
const nodeId = useContext(NodeIdContext) as ElementId;
|
||||||
const setPosition = useStoreActions((actions) => actions.setConnectionPosition);
|
const setPosition = useStoreActions((actions) => actions.setConnectionPosition);
|
||||||
const setConnectionNodeId = useStoreActions((actions) => actions.setConnectionNodeId);
|
const setConnectionNodeId = useStoreActions((actions) => actions.setConnectionNodeId);
|
||||||
@@ -89,8 +90,10 @@ const Handle = ({
|
|||||||
data-handlepos={position}
|
data-handlepos={position}
|
||||||
className={handleClasses}
|
className={handleClasses}
|
||||||
onMouseDown={onMouseDownHandler}
|
onMouseDown={onMouseDownHandler}
|
||||||
style={style}
|
{...rest}
|
||||||
/>
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -319,8 +319,6 @@ export interface HandleProps {
|
|||||||
onConnect?: OnConnectFunc;
|
onConnect?: OnConnectFunc;
|
||||||
isValidConnection?: (connection: Connection) => boolean;
|
isValidConnection?: (connection: Connection) => boolean;
|
||||||
id?: ElementId;
|
id?: ElementId;
|
||||||
style?: CSSProperties;
|
|
||||||
className?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type NodePosUpdate = {
|
export type NodePosUpdate = {
|
||||||
|
|||||||
Reference in New Issue
Block a user