@infinit-canvas/react 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react-infinite-canvas.cjs +2 -2
- package/dist/react-infinite-canvas.js +151 -136
- package/package.json +1 -1
- package/src/types.d.ts +153 -0
package/package.json
CHANGED
package/src/types.d.ts
CHANGED
|
@@ -8,6 +8,18 @@ export type SnapGrid = [number, number];
|
|
|
8
8
|
export type CoordinateExtent = [[number, number], [number, number]];
|
|
9
9
|
|
|
10
10
|
export type Position = 'top' | 'bottom' | 'left' | 'right';
|
|
11
|
+
export declare const Position: {
|
|
12
|
+
readonly Top: 'top';
|
|
13
|
+
readonly Bottom: 'bottom';
|
|
14
|
+
readonly Left: 'left';
|
|
15
|
+
readonly Right: 'right';
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type MarkerType = 'arrow' | 'arrowclosed';
|
|
19
|
+
export declare const MarkerType: {
|
|
20
|
+
readonly Arrow: 'arrow';
|
|
21
|
+
readonly ArrowClosed: 'arrowclosed';
|
|
22
|
+
};
|
|
11
23
|
export type HandleType = 'source' | 'target';
|
|
12
24
|
export type ConnectionMode = 'strict' | 'loose';
|
|
13
25
|
export type SelectionMode = 'full' | 'partial';
|
|
@@ -236,8 +248,13 @@ export interface InfiniteCanvasProps {
|
|
|
236
248
|
nodes?: Node[];
|
|
237
249
|
edges?: Edge[];
|
|
238
250
|
|
|
251
|
+
// Custom types
|
|
252
|
+
nodeTypes?: NodeTypes;
|
|
253
|
+
edgeTypes?: EdgeTypes;
|
|
254
|
+
|
|
239
255
|
// Appearance
|
|
240
256
|
dark?: boolean;
|
|
257
|
+
colorMode?: ColorMode;
|
|
241
258
|
gridSize?: number;
|
|
242
259
|
width?: string | number;
|
|
243
260
|
height?: string | number;
|
|
@@ -320,6 +337,20 @@ export interface InfiniteCanvasProps {
|
|
|
320
337
|
elevateNodesOnSelect?: boolean;
|
|
321
338
|
elevateEdgesOnSelect?: boolean;
|
|
322
339
|
|
|
340
|
+
// DOM event passthrough
|
|
341
|
+
onDragOver?: (event: React.DragEvent) => void;
|
|
342
|
+
onDrop?: (event: React.DragEvent) => void;
|
|
343
|
+
|
|
344
|
+
// React Flow compatibility
|
|
345
|
+
proOptions?: ProOptions;
|
|
346
|
+
nodeOrigin?: NodeOrigin;
|
|
347
|
+
defaultViewport?: Viewport;
|
|
348
|
+
selectNodesOnDrag?: boolean;
|
|
349
|
+
onSelectionDragStart?: SelectionDragHandler;
|
|
350
|
+
onNodesDelete?: OnNodesDelete;
|
|
351
|
+
onEdgesDelete?: OnEdgesDelete;
|
|
352
|
+
onNodeDragStart?: OnNodeDrag;
|
|
353
|
+
|
|
323
354
|
// Legacy
|
|
324
355
|
onHudUpdate?: (data: HudData) => void;
|
|
325
356
|
showHud?: boolean;
|
|
@@ -328,6 +359,9 @@ export interface InfiniteCanvasProps {
|
|
|
328
359
|
|
|
329
360
|
// Children
|
|
330
361
|
children?: React.ReactNode;
|
|
362
|
+
|
|
363
|
+
// Allow additional props
|
|
364
|
+
[key: string]: any;
|
|
331
365
|
}
|
|
332
366
|
|
|
333
367
|
export interface ControlsProps {
|
|
@@ -470,3 +504,122 @@ export declare function Controls(props: ControlsProps): JSX.Element;
|
|
|
470
504
|
export declare function MiniMap(props: MiniMapProps): JSX.Element;
|
|
471
505
|
export declare function Background(props: BackgroundProps): JSX.Element;
|
|
472
506
|
export declare function Panel(props: PanelProps): JSX.Element;
|
|
507
|
+
|
|
508
|
+
// ─── React Flow Compatibility Types ─────────────────────────────
|
|
509
|
+
|
|
510
|
+
export interface Box {
|
|
511
|
+
x: number;
|
|
512
|
+
y: number;
|
|
513
|
+
x2: number;
|
|
514
|
+
y2: number;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
export declare function nodeToBox(node: Node): Box;
|
|
518
|
+
|
|
519
|
+
export interface InternalNode<NodeType extends Node = Node> extends NodeType {
|
|
520
|
+
_absolutePosition: XYPosition;
|
|
521
|
+
measured?: { width?: number; height?: number };
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
export type BuiltInNode = Node;
|
|
525
|
+
|
|
526
|
+
export interface NodeProps<NodeType extends Node = Node> {
|
|
527
|
+
id: string;
|
|
528
|
+
data: NodeType['data'];
|
|
529
|
+
type: string;
|
|
530
|
+
selected: boolean;
|
|
531
|
+
dragging: boolean;
|
|
532
|
+
width?: number;
|
|
533
|
+
height?: number;
|
|
534
|
+
positionAbsoluteX: number;
|
|
535
|
+
positionAbsoluteY: number;
|
|
536
|
+
zIndex: number;
|
|
537
|
+
isConnectable: boolean;
|
|
538
|
+
sourcePosition?: Position;
|
|
539
|
+
targetPosition?: Position;
|
|
540
|
+
dragHandle?: string;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
export interface EdgeProps<EdgeType extends Edge = Edge> {
|
|
544
|
+
id: string;
|
|
545
|
+
source: string;
|
|
546
|
+
target: string;
|
|
547
|
+
sourceX: number;
|
|
548
|
+
sourceY: number;
|
|
549
|
+
targetX: number;
|
|
550
|
+
targetY: number;
|
|
551
|
+
selected?: boolean;
|
|
552
|
+
animated?: boolean;
|
|
553
|
+
data?: EdgeType['data'];
|
|
554
|
+
label?: string;
|
|
555
|
+
type?: string;
|
|
556
|
+
sourceHandleId?: string | null;
|
|
557
|
+
targetHandleId?: string | null;
|
|
558
|
+
sourcePosition: Position;
|
|
559
|
+
targetPosition: Position;
|
|
560
|
+
style?: React.CSSProperties;
|
|
561
|
+
markerStart?: string;
|
|
562
|
+
markerEnd?: string;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
export interface HandleProps {
|
|
566
|
+
type: HandleType;
|
|
567
|
+
position: Position;
|
|
568
|
+
id?: string;
|
|
569
|
+
isConnectable?: boolean;
|
|
570
|
+
isConnectableStart?: boolean;
|
|
571
|
+
isConnectableEnd?: boolean;
|
|
572
|
+
onConnect?: (connection: Connection) => void;
|
|
573
|
+
style?: React.CSSProperties;
|
|
574
|
+
className?: string;
|
|
575
|
+
children?: React.ReactNode;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
export interface ConnectionLineComponentProps {
|
|
579
|
+
fromX: number;
|
|
580
|
+
fromY: number;
|
|
581
|
+
toX: number;
|
|
582
|
+
toY: number;
|
|
583
|
+
fromPosition: Position;
|
|
584
|
+
toPosition: Position;
|
|
585
|
+
fromNode?: Node;
|
|
586
|
+
toNode?: Node;
|
|
587
|
+
connectionLineType?: string;
|
|
588
|
+
connectionLineStyle?: React.CSSProperties;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
export interface MiniMapNodeProps {
|
|
592
|
+
id: string;
|
|
593
|
+
x: number;
|
|
594
|
+
y: number;
|
|
595
|
+
width: number;
|
|
596
|
+
height: number;
|
|
597
|
+
selected: boolean;
|
|
598
|
+
color?: string;
|
|
599
|
+
style?: React.CSSProperties;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
export type NodeTypes = Record<string, React.ComponentType<NodeProps<any>>>;
|
|
603
|
+
export type EdgeTypes = Record<string, React.ComponentType<EdgeProps<any>>>;
|
|
604
|
+
|
|
605
|
+
export type InfiniteCanvasInstance = ReactFlowInstance;
|
|
606
|
+
export type InfiniteCanvasState = {
|
|
607
|
+
nodes: Node[];
|
|
608
|
+
edges: Edge[];
|
|
609
|
+
domNode: HTMLDivElement | null;
|
|
610
|
+
width: number;
|
|
611
|
+
height: number;
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
export type NodeOrigin = [number, number];
|
|
615
|
+
|
|
616
|
+
export interface ProOptions {
|
|
617
|
+
account?: string;
|
|
618
|
+
hideAttribution?: boolean;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
export type SelectionDragHandler = (event: React.MouseEvent, nodes: Node[]) => void;
|
|
622
|
+
export type OnNodesDelete = (nodes: Node[]) => void;
|
|
623
|
+
export type OnEdgesDelete = (edges: Edge[]) => void;
|
|
624
|
+
|
|
625
|
+
export type useShallow = <T>(selector: (state: any) => T) => T;
|