Updated NodeBase to allow undefined types and still handle explicit ones
Updated svelte and react packages to accommodate this
This commit is contained in:
@@ -9,7 +9,7 @@ import { NodeTypes } from './general';
|
|||||||
*/
|
*/
|
||||||
export type Node<
|
export type Node<
|
||||||
NodeData extends Record<string, unknown> = Record<string, unknown>,
|
NodeData extends Record<string, unknown> = Record<string, unknown>,
|
||||||
NodeType extends string = string
|
NodeType extends string | undefined = undefined
|
||||||
> = NodeBase<NodeData, NodeType> & {
|
> = NodeBase<NodeData, NodeType> & {
|
||||||
style?: CSSProperties;
|
style?: CSSProperties;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export type InternalNode<NodeType extends Node = Node> = InternalNodeBase<NodeTy
|
|||||||
*/
|
*/
|
||||||
export type Node<
|
export type Node<
|
||||||
NodeData extends Record<string, unknown> = Record<string, unknown>,
|
NodeData extends Record<string, unknown> = Record<string, unknown>,
|
||||||
NodeType extends string = string
|
NodeType extends string | undefined = undefined
|
||||||
> = NodeBase<NodeData, NodeType> & {
|
> = NodeBase<NodeData, NodeType> & {
|
||||||
class?: string;
|
class?: string;
|
||||||
style?: string;
|
style?: string;
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ export type NodeBase<
|
|||||||
position: XYPosition;
|
position: XYPosition;
|
||||||
/** Arbitrary data passed to a node */
|
/** Arbitrary data passed to a node */
|
||||||
data: NodeData;
|
data: NodeData;
|
||||||
/** Type of node defined in nodeTypes */
|
|
||||||
type: NodeType;
|
|
||||||
/** Only relevant for default, source, target nodeType. controls source position
|
/** Only relevant for default, source, target nodeType. controls source position
|
||||||
* @example 'right', 'left', 'top', 'bottom'
|
* @example 'right', 'left', 'top', 'bottom'
|
||||||
*/
|
*/
|
||||||
@@ -63,7 +61,15 @@ export type NodeBase<
|
|||||||
width?: number;
|
width?: number;
|
||||||
height?: number;
|
height?: number;
|
||||||
};
|
};
|
||||||
};
|
} & (undefined extends NodeType
|
||||||
|
? {
|
||||||
|
/** Type of node defined in nodeTypes */
|
||||||
|
type?: string | undefined;
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
/** Type of node defined in nodeTypes */
|
||||||
|
type: NodeType;
|
||||||
|
});
|
||||||
|
|
||||||
export type InternalNodeBase<NodeType extends NodeBase = NodeBase> = NodeType & {
|
export type InternalNodeBase<NodeType extends NodeBase = NodeBase> = NodeType & {
|
||||||
measured: {
|
measured: {
|
||||||
|
|||||||
Reference in New Issue
Block a user