@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/docs/Canvas.md CHANGED
@@ -37,8 +37,11 @@ import { Canvas } from "@particle-academy/react-fancy";
37
37
  | maxZoom | `number` | `3` | Maximum zoom level |
38
38
  | pannable | `boolean` | `true` | Enable panning (click+drag on background) |
39
39
  | zoomable | `boolean` | `true` | Enable zoom (Ctrl+scroll) |
40
- | gridSize | `number` | - | Grid cell size in px |
41
- | showGrid | `boolean` | `false` | Display dot grid background |
40
+ | gridSize | `number` | `20` | Grid cell size in canvas-space pixels |
41
+ | showGrid | `boolean` | `false` | Display the canvas grid background |
42
+ | gridStyle | `'dots' \| 'lines' \| 'none'` | `'dots'` | Grid pattern when shown. `'none'` hides the grid even when `showGrid` is true |
43
+ | gridColor | `string` | `'rgb(161 161 170 / 0.3)'` | Any CSS color for grid dots/lines |
44
+ | snapToGrid | `boolean` | `false` | Snap dragged nodes to the grid |
42
45
  | fitOnMount | `boolean` | `false` | Auto-fit all nodes into view on mount |
43
46
  | className | `string` | - | Additional CSS classes |
44
47
  | style | `CSSProperties` | - | Inline styles |
package/docs/Diagram.md CHANGED
@@ -90,10 +90,42 @@ const schema = {
90
90
  | to | `string` | - | Target entity id (required) |
91
91
  | fromField | `string` | - | Source field name |
92
92
  | toField | `string` | - | Target field name |
93
- | type | `RelationType` | - | `"one-to-one"`, `"one-to-many"`, or `"many-to-many"` (required) |
94
- | label | `string` | - | Edge label |
93
+ | type | `RelationType` | - | Shorthand that sets `fromMarker` / `toMarker` / `lineStyle`. See **Relation types** below |
94
+ | fromMarker | `MarkerType` | depends on `type` | Marker shape at the source end |
95
+ | toMarker | `MarkerType` | depends on `type` | Marker shape at the target end |
96
+ | lineStyle | `'solid' \| 'dashed' \| 'dotted'` | from `type` | Line stroke style |
97
+ | routing | `'manhattan' \| 'bezier' \| 'straight'` | `'manhattan'` | Path routing algorithm |
98
+ | color | `string` | `'#71717a'` | Stroke color |
99
+ | strokeWidth | `number` | `2` | Stroke width |
100
+ | label | `string` | - | Edge label rendered at the path midpoint |
95
101
  | className | `string` | - | Additional CSS classes |
96
102
 
103
+ ### Relation types (`type` shorthand)
104
+
105
+ | Type | fromMarker | toMarker | lineStyle |
106
+ |------|-----------|----------|-----------|
107
+ | `one-to-one` | one | one | solid |
108
+ | `one-to-many` | one | many | solid |
109
+ | `many-to-one` | many | one | solid |
110
+ | `many-to-many` | many | many | solid |
111
+ | `association` | none | arrow | solid |
112
+ | `aggregation` | diamond-open | none | solid |
113
+ | `composition` | diamond | none | solid |
114
+ | `inheritance` | none | triangle-open | solid |
115
+ | `implementation` | none | triangle-open | dashed |
116
+ | `dependency` | none | arrow | dashed |
117
+ | `custom` | (caller's `fromMarker`) | (caller's `toMarker`) | solid |
118
+
119
+ ### MarkerType
120
+
121
+ `'none'`, `'arrow'`, `'arrow-open'`, `'circle'`, `'circle-open'`, `'square'`, `'square-open'`, `'diamond'`, `'diamond-open'`, `'triangle'`, `'triangle-open'`, `'one'`, `'many'`, `'optional-one'`, `'optional-many'`, `'cross'`, or any string starting with `emoji:` (e.g. `'emoji:🎯'`) for an emoji/text marker.
122
+
123
+ ### Routing
124
+
125
+ - **manhattan** (default) — right-angle elbows. Picks the side of each entity that faces the other, with a vertical (or horizontal) mid-line that automatically dodges entities lying along the path. Best for ERD/UML.
126
+ - **bezier** — smooth cubic curve with horizontal/vertical control points perpendicular to each side.
127
+ - **straight** — direct line between the two anchor points.
128
+
97
129
  ### Diagram.Toolbar
98
130
 
99
131
  | Prop | Type | Default | Description |
package/docs/TreeNav.md CHANGED
@@ -49,8 +49,10 @@ const files: TreeNodeData[] = [
49
49
  | selectedId | `string` | - | Currently selected node ID |
50
50
  | onSelect | `(id: string, node: TreeNodeData) => void` | - | Selection callback |
51
51
  | onNodeContextMenu | `(e: React.MouseEvent, node: TreeNodeData) => void` | - | Right-click callback per node |
52
- | draggable | `boolean` | `false` | Enable drag-and-drop reordering |
53
- | onNodeMove | `(sourceId: string, targetId: string, position: DropPosition) => void` | - | Callback when a node is moved via drag-and-drop |
52
+ | draggable | `boolean` | `false` | Enable drag-and-drop reordering of tree nodes |
53
+ | onNodeMove | `(sourceId: string, targetId: string, position: DropPosition) => void` | - | Callback when a node is moved via drag-and-drop within the tree |
54
+ | acceptExternalDrops | `boolean` | `false` | Accept drops from outside the tree — OS files, items dragged from other components, etc. |
55
+ | onExternalDrop | `(event: React.DragEvent, target: TreeNodeData, position: DropPosition) => void` | - | Fires on external drop. Read `event.dataTransfer.files` for OS file drops or `event.dataTransfer.getData(type)` for custom MIME payloads. |
54
56
  | expandedIds | `string[]` | - | Controlled expanded node IDs |
55
57
  | defaultExpandedIds | `string[]` | - | Initial expanded nodes (uncontrolled) |
56
58
  | onExpandedChange | `(ids: string[]) => void` | - | Callback when expanded state changes |
@@ -177,6 +179,29 @@ function handleNodeMove(sourceId: string, targetId: string, position: DropPositi
177
179
  - Folders auto-expand after 500ms when dragging over them
178
180
  - Disabled nodes cannot be dragged
179
181
 
182
+ ## External Drops (files, cross-component)
183
+
184
+ Set `acceptExternalDrops` and supply `onExternalDrop` to accept payloads from outside the tree — OS files dragged from the desktop, items dragged from a Kanban card, anything that ships a `dataTransfer`. The same `before` / `after` / `inside` indicators apply, and folders still auto-expand.
185
+
186
+ ```tsx
187
+ <TreeNav
188
+ nodes={files}
189
+ acceptExternalDrops
190
+ onExternalDrop={(event, target, position) => {
191
+ // OS file drop?
192
+ if (event.dataTransfer.files.length > 0) {
193
+ uploadFiles(event.dataTransfer.files, target.id);
194
+ return;
195
+ }
196
+ // Custom payload from another component?
197
+ const payload = event.dataTransfer.getData("application/x-card-id");
198
+ if (payload) attachCardToNode(payload, target.id, position);
199
+ }}
200
+ />
201
+ ```
202
+
203
+ `acceptExternalDrops` and `draggable` are independent — enable either, both, or neither. With both on, internal drag-reorder and external drops coexist; the handler distinguishes via the absence of an internal drag source.
204
+
180
205
  ## Context Menu
181
206
 
182
207
  Use `onNodeContextMenu` with the `ContextMenu` component to add right-click menus per node:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@particle-academy/react-fancy",
3
- "version": "2.8.1",
3
+ "version": "2.10.0",
4
4
  "description": "React UI component library — React port of the fancy-flux Blade component library",
5
5
  "repository": {
6
6
  "type": "git",