@particle-academy/react-fancy 2.8.1 → 2.10.0
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/index.cjs +808 -129
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -5
- package/dist/index.d.ts +54 -5
- package/dist/index.js +808 -129
- package/dist/index.js.map +1 -1
- package/docs/Canvas.md +5 -2
- package/docs/Diagram.md +34 -2
- package/docs/TreeNav.md +27 -2
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2231,7 +2231,12 @@ interface CanvasContextValue {
|
|
|
2231
2231
|
nodeRects: Map<string, NodeRect>;
|
|
2232
2232
|
registryVersion: number;
|
|
2233
2233
|
containerRef: React.RefObject<HTMLDivElement | null>;
|
|
2234
|
+
/** Grid spacing in canvas-space pixels (unaffected by zoom). */
|
|
2235
|
+
gridSize: number;
|
|
2236
|
+
/** When true, dragged nodes snap their top-left corner to the grid. */
|
|
2237
|
+
snapToGrid: boolean;
|
|
2234
2238
|
}
|
|
2239
|
+
type GridStyle = "dots" | "lines" | "none";
|
|
2235
2240
|
interface CanvasProps {
|
|
2236
2241
|
children: ReactNode;
|
|
2237
2242
|
viewport?: ViewportState;
|
|
@@ -2241,8 +2246,17 @@ interface CanvasProps {
|
|
|
2241
2246
|
maxZoom?: number;
|
|
2242
2247
|
pannable?: boolean;
|
|
2243
2248
|
zoomable?: boolean;
|
|
2249
|
+
/** Grid spacing in canvas-space pixels. Defaults to 20. */
|
|
2244
2250
|
gridSize?: number;
|
|
2251
|
+
/** Show/hide the canvas grid. Defaults to false. */
|
|
2245
2252
|
showGrid?: boolean;
|
|
2253
|
+
/** Grid pattern when shown — dots (default), lines, or none. Setting this
|
|
2254
|
+
* to "none" hides the grid even when `showGrid` is true. */
|
|
2255
|
+
gridStyle?: GridStyle;
|
|
2256
|
+
/** Grid color (any CSS color). Defaults to a faint zinc. */
|
|
2257
|
+
gridColor?: string;
|
|
2258
|
+
/** Snap dragged nodes to the grid. Defaults to false. */
|
|
2259
|
+
snapToGrid?: boolean;
|
|
2246
2260
|
/** Automatically fit all nodes into view on initial mount */
|
|
2247
2261
|
fitOnMount?: boolean;
|
|
2248
2262
|
className?: string;
|
|
@@ -2308,7 +2322,7 @@ declare namespace CanvasControls {
|
|
|
2308
2322
|
var displayName: string;
|
|
2309
2323
|
}
|
|
2310
2324
|
|
|
2311
|
-
declare function CanvasRoot({ children, viewport: controlledViewport, defaultViewport, onViewportChange, minZoom, maxZoom, pannable, zoomable, showGrid, fitOnMount, className, style, }: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
2325
|
+
declare function CanvasRoot({ children, viewport: controlledViewport, defaultViewport, onViewportChange, minZoom, maxZoom, pannable, zoomable, showGrid, gridStyle, gridSize, gridColor, snapToGrid, fitOnMount, className, style, }: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
2312
2326
|
declare const Canvas: typeof CanvasRoot & {
|
|
2313
2327
|
Node: typeof CanvasNode;
|
|
2314
2328
|
Edge: typeof CanvasEdge;
|
|
@@ -2319,7 +2333,13 @@ declare const Canvas: typeof CanvasRoot & {
|
|
|
2319
2333
|
declare function useCanvas(): CanvasContextValue;
|
|
2320
2334
|
|
|
2321
2335
|
type DiagramType = "erd" | "flowchart" | "general";
|
|
2322
|
-
|
|
2336
|
+
/** ERD/UML shorthand — sets fromMarker/toMarker (and lineStyle for some). */
|
|
2337
|
+
type RelationType = "one-to-one" | "one-to-many" | "many-to-one" | "many-to-many" | "association" | "aggregation" | "composition" | "inheritance" | "implementation" | "dependency" | "custom";
|
|
2338
|
+
/** Shape painted at each line endpoint. Strings prefixed `emoji:` render the
|
|
2339
|
+
* rest of the string as text at the endpoint (e.g. `emoji:🎯`). */
|
|
2340
|
+
type MarkerType = "none" | "arrow" | "arrow-open" | "circle" | "circle-open" | "square" | "square-open" | "diamond" | "diamond-open" | "triangle" | "triangle-open" | "one" | "many" | "optional-one" | "optional-many" | "cross" | (string & {});
|
|
2341
|
+
type LineStyle = "solid" | "dashed" | "dotted";
|
|
2342
|
+
type RoutingMode = "manhattan" | "bezier" | "straight";
|
|
2323
2343
|
type ExportFormat = "erd" | "uml" | "dfd";
|
|
2324
2344
|
interface DiagramFieldData {
|
|
2325
2345
|
name: string;
|
|
@@ -2344,6 +2364,11 @@ interface DiagramRelationData {
|
|
|
2344
2364
|
fromField?: string;
|
|
2345
2365
|
toField?: string;
|
|
2346
2366
|
type: RelationType;
|
|
2367
|
+
fromMarker?: MarkerType;
|
|
2368
|
+
toMarker?: MarkerType;
|
|
2369
|
+
lineStyle?: LineStyle;
|
|
2370
|
+
routing?: RoutingMode;
|
|
2371
|
+
color?: string;
|
|
2347
2372
|
label?: string;
|
|
2348
2373
|
}
|
|
2349
2374
|
interface DiagramSchema {
|
|
@@ -2399,7 +2424,20 @@ interface DiagramRelationProps {
|
|
|
2399
2424
|
to: string;
|
|
2400
2425
|
fromField?: string;
|
|
2401
2426
|
toField?: string;
|
|
2402
|
-
|
|
2427
|
+
/** ERD/UML shorthand. Provides defaults for fromMarker/toMarker/lineStyle. */
|
|
2428
|
+
type?: RelationType;
|
|
2429
|
+
/** Override start endpoint marker. */
|
|
2430
|
+
fromMarker?: MarkerType;
|
|
2431
|
+
/** Override end endpoint marker. */
|
|
2432
|
+
toMarker?: MarkerType;
|
|
2433
|
+
/** Line style — solid (default), dashed, dotted. */
|
|
2434
|
+
lineStyle?: LineStyle;
|
|
2435
|
+
/** Routing algorithm — manhattan (default), bezier, straight. */
|
|
2436
|
+
routing?: RoutingMode;
|
|
2437
|
+
/** Stroke color. Defaults to a zinc gray. */
|
|
2438
|
+
color?: string;
|
|
2439
|
+
/** Stroke width. Default 2. */
|
|
2440
|
+
strokeWidth?: number;
|
|
2403
2441
|
label?: string;
|
|
2404
2442
|
className?: string;
|
|
2405
2443
|
}
|
|
@@ -2417,7 +2455,7 @@ declare namespace DiagramField {
|
|
|
2417
2455
|
var displayName: string;
|
|
2418
2456
|
}
|
|
2419
2457
|
|
|
2420
|
-
declare function DiagramRelation({ from, to, fromField: fromFieldProp, toField: toFieldProp, type, label, }: DiagramRelationProps): react_jsx_runtime.JSX.Element | null;
|
|
2458
|
+
declare function DiagramRelation({ from, to, fromField: fromFieldProp, toField: toFieldProp, type, fromMarker: fromMarkerProp, toMarker: toMarkerProp, lineStyle: lineStyleProp, routing, color, strokeWidth, label, }: DiagramRelationProps): react_jsx_runtime.JSX.Element | null;
|
|
2421
2459
|
declare namespace DiagramRelation {
|
|
2422
2460
|
var _isCanvasEdge: boolean;
|
|
2423
2461
|
var displayName: string;
|
|
@@ -2474,6 +2512,15 @@ interface TreeNavProps {
|
|
|
2474
2512
|
draggable?: boolean;
|
|
2475
2513
|
/** Callback when a node is moved via drag and drop */
|
|
2476
2514
|
onNodeMove?: (sourceId: string, targetId: string, position: DropPosition) => void;
|
|
2515
|
+
/** Accept drops from outside the tree — OS files, items from other
|
|
2516
|
+
* components, etc. When true, drag-over is allowed for any data source
|
|
2517
|
+
* and `onExternalDrop` fires on drop. (default: false) */
|
|
2518
|
+
acceptExternalDrops?: boolean;
|
|
2519
|
+
/** Called when an external drag (file or cross-component) is dropped on
|
|
2520
|
+
* a node. The raw event lets you read `event.dataTransfer.files` for OS
|
|
2521
|
+
* file drops or `event.dataTransfer.getData(type)` for custom MIME
|
|
2522
|
+
* payloads from other components. */
|
|
2523
|
+
onExternalDrop?: (event: React.DragEvent, target: TreeNodeData, position: DropPosition) => void;
|
|
2477
2524
|
/** Controlled expanded node IDs */
|
|
2478
2525
|
expandedIds?: string[];
|
|
2479
2526
|
/** Default expanded node IDs (uncontrolled) */
|
|
@@ -2501,6 +2548,8 @@ interface TreeNavContextValue {
|
|
|
2501
2548
|
dragState: DragState;
|
|
2502
2549
|
setDragState: (state: DragState) => void;
|
|
2503
2550
|
onNodeMove?: (sourceId: string, targetId: string, position: DropPosition) => void;
|
|
2551
|
+
acceptExternalDrops: boolean;
|
|
2552
|
+
onExternalDrop?: (event: React.DragEvent, target: TreeNodeData, position: DropPosition) => void;
|
|
2504
2553
|
nodes: TreeNodeData[];
|
|
2505
2554
|
expandNode: (id: string) => void;
|
|
2506
2555
|
}
|
|
@@ -2515,7 +2564,7 @@ declare namespace TreeNode {
|
|
|
2515
2564
|
var displayName: string;
|
|
2516
2565
|
}
|
|
2517
2566
|
|
|
2518
|
-
declare function TreeNavRoot({ nodes, selectedId, onSelect, onNodeContextMenu, draggable, onNodeMove, expandedIds: controlledExpanded, defaultExpandedIds, onExpandedChange, defaultExpandAll, indentSize, showIcons, className, }: TreeNavProps): react_jsx_runtime.JSX.Element;
|
|
2567
|
+
declare function TreeNavRoot({ nodes, selectedId, onSelect, onNodeContextMenu, draggable, onNodeMove, acceptExternalDrops, onExternalDrop, expandedIds: controlledExpanded, defaultExpandedIds, onExpandedChange, defaultExpandAll, indentSize, showIcons, className, }: TreeNavProps): react_jsx_runtime.JSX.Element;
|
|
2519
2568
|
declare namespace TreeNavRoot {
|
|
2520
2569
|
var displayName: string;
|
|
2521
2570
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2231,7 +2231,12 @@ interface CanvasContextValue {
|
|
|
2231
2231
|
nodeRects: Map<string, NodeRect>;
|
|
2232
2232
|
registryVersion: number;
|
|
2233
2233
|
containerRef: React.RefObject<HTMLDivElement | null>;
|
|
2234
|
+
/** Grid spacing in canvas-space pixels (unaffected by zoom). */
|
|
2235
|
+
gridSize: number;
|
|
2236
|
+
/** When true, dragged nodes snap their top-left corner to the grid. */
|
|
2237
|
+
snapToGrid: boolean;
|
|
2234
2238
|
}
|
|
2239
|
+
type GridStyle = "dots" | "lines" | "none";
|
|
2235
2240
|
interface CanvasProps {
|
|
2236
2241
|
children: ReactNode;
|
|
2237
2242
|
viewport?: ViewportState;
|
|
@@ -2241,8 +2246,17 @@ interface CanvasProps {
|
|
|
2241
2246
|
maxZoom?: number;
|
|
2242
2247
|
pannable?: boolean;
|
|
2243
2248
|
zoomable?: boolean;
|
|
2249
|
+
/** Grid spacing in canvas-space pixels. Defaults to 20. */
|
|
2244
2250
|
gridSize?: number;
|
|
2251
|
+
/** Show/hide the canvas grid. Defaults to false. */
|
|
2245
2252
|
showGrid?: boolean;
|
|
2253
|
+
/** Grid pattern when shown — dots (default), lines, or none. Setting this
|
|
2254
|
+
* to "none" hides the grid even when `showGrid` is true. */
|
|
2255
|
+
gridStyle?: GridStyle;
|
|
2256
|
+
/** Grid color (any CSS color). Defaults to a faint zinc. */
|
|
2257
|
+
gridColor?: string;
|
|
2258
|
+
/** Snap dragged nodes to the grid. Defaults to false. */
|
|
2259
|
+
snapToGrid?: boolean;
|
|
2246
2260
|
/** Automatically fit all nodes into view on initial mount */
|
|
2247
2261
|
fitOnMount?: boolean;
|
|
2248
2262
|
className?: string;
|
|
@@ -2308,7 +2322,7 @@ declare namespace CanvasControls {
|
|
|
2308
2322
|
var displayName: string;
|
|
2309
2323
|
}
|
|
2310
2324
|
|
|
2311
|
-
declare function CanvasRoot({ children, viewport: controlledViewport, defaultViewport, onViewportChange, minZoom, maxZoom, pannable, zoomable, showGrid, fitOnMount, className, style, }: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
2325
|
+
declare function CanvasRoot({ children, viewport: controlledViewport, defaultViewport, onViewportChange, minZoom, maxZoom, pannable, zoomable, showGrid, gridStyle, gridSize, gridColor, snapToGrid, fitOnMount, className, style, }: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
2312
2326
|
declare const Canvas: typeof CanvasRoot & {
|
|
2313
2327
|
Node: typeof CanvasNode;
|
|
2314
2328
|
Edge: typeof CanvasEdge;
|
|
@@ -2319,7 +2333,13 @@ declare const Canvas: typeof CanvasRoot & {
|
|
|
2319
2333
|
declare function useCanvas(): CanvasContextValue;
|
|
2320
2334
|
|
|
2321
2335
|
type DiagramType = "erd" | "flowchart" | "general";
|
|
2322
|
-
|
|
2336
|
+
/** ERD/UML shorthand — sets fromMarker/toMarker (and lineStyle for some). */
|
|
2337
|
+
type RelationType = "one-to-one" | "one-to-many" | "many-to-one" | "many-to-many" | "association" | "aggregation" | "composition" | "inheritance" | "implementation" | "dependency" | "custom";
|
|
2338
|
+
/** Shape painted at each line endpoint. Strings prefixed `emoji:` render the
|
|
2339
|
+
* rest of the string as text at the endpoint (e.g. `emoji:🎯`). */
|
|
2340
|
+
type MarkerType = "none" | "arrow" | "arrow-open" | "circle" | "circle-open" | "square" | "square-open" | "diamond" | "diamond-open" | "triangle" | "triangle-open" | "one" | "many" | "optional-one" | "optional-many" | "cross" | (string & {});
|
|
2341
|
+
type LineStyle = "solid" | "dashed" | "dotted";
|
|
2342
|
+
type RoutingMode = "manhattan" | "bezier" | "straight";
|
|
2323
2343
|
type ExportFormat = "erd" | "uml" | "dfd";
|
|
2324
2344
|
interface DiagramFieldData {
|
|
2325
2345
|
name: string;
|
|
@@ -2344,6 +2364,11 @@ interface DiagramRelationData {
|
|
|
2344
2364
|
fromField?: string;
|
|
2345
2365
|
toField?: string;
|
|
2346
2366
|
type: RelationType;
|
|
2367
|
+
fromMarker?: MarkerType;
|
|
2368
|
+
toMarker?: MarkerType;
|
|
2369
|
+
lineStyle?: LineStyle;
|
|
2370
|
+
routing?: RoutingMode;
|
|
2371
|
+
color?: string;
|
|
2347
2372
|
label?: string;
|
|
2348
2373
|
}
|
|
2349
2374
|
interface DiagramSchema {
|
|
@@ -2399,7 +2424,20 @@ interface DiagramRelationProps {
|
|
|
2399
2424
|
to: string;
|
|
2400
2425
|
fromField?: string;
|
|
2401
2426
|
toField?: string;
|
|
2402
|
-
|
|
2427
|
+
/** ERD/UML shorthand. Provides defaults for fromMarker/toMarker/lineStyle. */
|
|
2428
|
+
type?: RelationType;
|
|
2429
|
+
/** Override start endpoint marker. */
|
|
2430
|
+
fromMarker?: MarkerType;
|
|
2431
|
+
/** Override end endpoint marker. */
|
|
2432
|
+
toMarker?: MarkerType;
|
|
2433
|
+
/** Line style — solid (default), dashed, dotted. */
|
|
2434
|
+
lineStyle?: LineStyle;
|
|
2435
|
+
/** Routing algorithm — manhattan (default), bezier, straight. */
|
|
2436
|
+
routing?: RoutingMode;
|
|
2437
|
+
/** Stroke color. Defaults to a zinc gray. */
|
|
2438
|
+
color?: string;
|
|
2439
|
+
/** Stroke width. Default 2. */
|
|
2440
|
+
strokeWidth?: number;
|
|
2403
2441
|
label?: string;
|
|
2404
2442
|
className?: string;
|
|
2405
2443
|
}
|
|
@@ -2417,7 +2455,7 @@ declare namespace DiagramField {
|
|
|
2417
2455
|
var displayName: string;
|
|
2418
2456
|
}
|
|
2419
2457
|
|
|
2420
|
-
declare function DiagramRelation({ from, to, fromField: fromFieldProp, toField: toFieldProp, type, label, }: DiagramRelationProps): react_jsx_runtime.JSX.Element | null;
|
|
2458
|
+
declare function DiagramRelation({ from, to, fromField: fromFieldProp, toField: toFieldProp, type, fromMarker: fromMarkerProp, toMarker: toMarkerProp, lineStyle: lineStyleProp, routing, color, strokeWidth, label, }: DiagramRelationProps): react_jsx_runtime.JSX.Element | null;
|
|
2421
2459
|
declare namespace DiagramRelation {
|
|
2422
2460
|
var _isCanvasEdge: boolean;
|
|
2423
2461
|
var displayName: string;
|
|
@@ -2474,6 +2512,15 @@ interface TreeNavProps {
|
|
|
2474
2512
|
draggable?: boolean;
|
|
2475
2513
|
/** Callback when a node is moved via drag and drop */
|
|
2476
2514
|
onNodeMove?: (sourceId: string, targetId: string, position: DropPosition) => void;
|
|
2515
|
+
/** Accept drops from outside the tree — OS files, items from other
|
|
2516
|
+
* components, etc. When true, drag-over is allowed for any data source
|
|
2517
|
+
* and `onExternalDrop` fires on drop. (default: false) */
|
|
2518
|
+
acceptExternalDrops?: boolean;
|
|
2519
|
+
/** Called when an external drag (file or cross-component) is dropped on
|
|
2520
|
+
* a node. The raw event lets you read `event.dataTransfer.files` for OS
|
|
2521
|
+
* file drops or `event.dataTransfer.getData(type)` for custom MIME
|
|
2522
|
+
* payloads from other components. */
|
|
2523
|
+
onExternalDrop?: (event: React.DragEvent, target: TreeNodeData, position: DropPosition) => void;
|
|
2477
2524
|
/** Controlled expanded node IDs */
|
|
2478
2525
|
expandedIds?: string[];
|
|
2479
2526
|
/** Default expanded node IDs (uncontrolled) */
|
|
@@ -2501,6 +2548,8 @@ interface TreeNavContextValue {
|
|
|
2501
2548
|
dragState: DragState;
|
|
2502
2549
|
setDragState: (state: DragState) => void;
|
|
2503
2550
|
onNodeMove?: (sourceId: string, targetId: string, position: DropPosition) => void;
|
|
2551
|
+
acceptExternalDrops: boolean;
|
|
2552
|
+
onExternalDrop?: (event: React.DragEvent, target: TreeNodeData, position: DropPosition) => void;
|
|
2504
2553
|
nodes: TreeNodeData[];
|
|
2505
2554
|
expandNode: (id: string) => void;
|
|
2506
2555
|
}
|
|
@@ -2515,7 +2564,7 @@ declare namespace TreeNode {
|
|
|
2515
2564
|
var displayName: string;
|
|
2516
2565
|
}
|
|
2517
2566
|
|
|
2518
|
-
declare function TreeNavRoot({ nodes, selectedId, onSelect, onNodeContextMenu, draggable, onNodeMove, expandedIds: controlledExpanded, defaultExpandedIds, onExpandedChange, defaultExpandAll, indentSize, showIcons, className, }: TreeNavProps): react_jsx_runtime.JSX.Element;
|
|
2567
|
+
declare function TreeNavRoot({ nodes, selectedId, onSelect, onNodeContextMenu, draggable, onNodeMove, acceptExternalDrops, onExternalDrop, expandedIds: controlledExpanded, defaultExpandedIds, onExpandedChange, defaultExpandAll, indentSize, showIcons, className, }: TreeNavProps): react_jsx_runtime.JSX.Element;
|
|
2519
2568
|
declare namespace TreeNavRoot {
|
|
2520
2569
|
var displayName: string;
|
|
2521
2570
|
}
|