@m3ui-vue/m3ui-vue 1.3.2 → 1.3.4

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/API.md CHANGED
@@ -1,4 +1,4 @@
1
- # @m3ui-vue/m3ui-vue 1.3.2 — API reference
1
+ # @m3ui-vue/m3ui-vue 1.3.4 — API reference
2
2
 
3
3
  Material Design 3 components for Vue 3 + Tailwind CSS v4. Generated from the source by
4
4
  `scripts/generate-api.mjs`; full docs with live demos at https://m3ui.dev.
@@ -1625,6 +1625,7 @@ Props:
1625
1625
  - `nodesConnectable?: boolean = true`
1626
1626
  - `elementsSelectable?: boolean = true`
1627
1627
  - `edgesReconnectable?: boolean = true`
1628
+ - `edgesReroutable?: boolean = false` — The segments of a selected `smoothstep`/`step` edge get grips: drag one sideways to reroute the edge (it keeps the route in `edge.route`), or drag a leg at either end to add a jog. Default off
1628
1629
  - `defaultEdgeOptions?: Partial<FlowEdge<any>>` — Merged into edges made by connecting (`type`, `animated`, `markerEnd`…)
1629
1630
  - `autoConnect?: boolean = true` — Adds an edge to `edges` when a connection is made; off, only `connect` fires
1630
1631
  - `isValidConnection?: ((c: FlowConnection) => boolean)` — Whether a connection may be made (no duplicates or same-node loops are offered either way)
@@ -1640,7 +1641,7 @@ Props:
1640
1641
  - `dropIntoGroups?: boolean = false` — Nodes dropped onto a `group` join it (and leave it when dropped outside)
1641
1642
  - `animate?: boolean = true` — Positions spring to their new place when they change from outside
1642
1643
  - `getId?: ((kind: "edge" | "node") => string)` — Makes ids for pasted nodes and new edges
1643
- - `edgeBranching?: boolean = false` — A drag that starts on an edge draws a new edge from the same source, a branch, as in a circuit editor (the preview leaves from where you grabbed it). A click still selects the edge; with a finger, only a selected edge branches, so a swipe across one still pans
1644
+ - `edgeBranching?: boolean | "junction" = false` — A drag that starts on an edge draws a new edge from the same source, a branch, as in a circuit editor (the preview leaves from where you grabbed it). A click still selects the edge; with a finger, only a selected edge branches, so a swipe across one still pans. `'junction'`: the branch leaves from the very point you grabbed, as in Logisim: nothing is added, `branch` fires with that point on the edge, and you split the edge there with a junction node of your own (or leave a loose end where it was dropped on nothing)
1644
1645
  - `nativeContextMenu?: boolean = false` — Let the browser's own context menu open on the canvas (right click, or a long press on a phone). Off by default: the `*-contextmenu` events still fire, for a menu of your own (MContextMenu's `showAt`). Text fields inside nodes always keep it, for copy and paste
1645
1646
  - `label?: string` — The canvas's accessible name
1646
1647
 
@@ -1653,8 +1654,10 @@ Events:
1653
1654
  - `update:locked(boolean)`
1654
1655
  - `connect(FlowConnection)` — A connection was made (it's also added to `edges` with `autoConnect`)
1655
1656
  - `connect-start({ nodeId: string; handleId: string | null; type: "source" | "target"; })` — A connection drag started from a handle
1657
+ - `branch({ edge: FlowEdge<any>; connection: FlowConnection | null; position: FlowXY; direction: FlowPosition; end: FlowXY; routes?: { before: number[]; after: number[]; } | undefined; })` — A branch was dragged off an edge (edgeBranching) and dropped: `{ edge, connection, position, direction, end }`, the connection null when it was dropped on nothing, `position` the point on the edge where it was grabbed (on the grid along the edge with snapToGrid), `direction` the way the edge runs there toward its target, `end` where it was dropped, and for an edge with its own `route`, `routes` that keep each half's shape. With `'junction'` this is all that happens: split the edge with a node there whose handles are at `position="auto"`, the first half arriving with `targetPosition` opposite to `direction` and the second leaving with `sourcePosition: direction`, so it runs on straight through
1656
1658
  - `connect-end({ connection: FlowConnection | null; position: FlowXY; from: { nodeId: string; handleId: string | null; type: "source" | "target"; }; })` — A connection drag ended: `{ connection }` when it connected, else the flow `position` it was dropped at and where it came from
1657
1659
  - `reconnect({ edge: FlowEdge<any>; connection: FlowConnection; })` — An edge's end was moved to another handle: `{ edge, connection }`
1660
+ - `reroute(edge: FlowEdge<any>)` — A segment of an edge was dragged (`edgesReroutable`): the edge with its new `route`
1658
1661
  - `insert({ node: FlowNode<any>; edge: FlowEdge<any>; connections: [FlowConnection, FlowConnection]; })` — A lone node was dropped onto an edge and spliced in: `{ node, edge, connections }` (with `autoConnect` the edge is replaced by the two connections, keeping its type and look)
1659
1662
  - `node-click(FlowNode<any>, MouseEvent)` — / node-dblclick / node-contextmenu `(node, event)`
1660
1663
  - `node-dblclick(FlowNode<any>, MouseEvent)`
@@ -1680,6 +1683,7 @@ Exposed (template ref):
1680
1683
  - `getAbsolutePosition: (id: string) => FlowXY` — A node's top left corner in flow coordinates, its parents added, where it's drawn right now
1681
1684
  - `getSize: (id: string) => { width: number; height: number; }` — A node's measured (or set) size
1682
1685
  - `getIntersectingNodes: (node: string | { x: number; y: number; width: number; height: number; }) => FlowNode<any>[]` — Nodes overlapping this one (or a rectangle in flow coordinates), groups and its own family left out
1686
+ - `getEdgeAt: (p: FlowXY, opts?: { radius?: number | undefined; ignore?: ((e: FlowEdge<any>) => boolean) | undefined; } | undefined) => FlowEdgeHit | null` — The edge passing within `radius` (flow units, default 8) of a flow point, nearest first, skipping the ones `ignore` returns true for: where on it the point falls (on the grid along it with snapToGrid), the way it runs there toward its target, and for an edge with its own route, the routes that keep each half's shape if it's split there (as the `branch` event gives). For dropping something onto an edge, e.g. a junction
1683
1687
  - `screenToFlow: (p: { x: number; y: number; }) => FlowXY` — Page (client) coordinates → flow coordinates
1684
1688
  - `flowToScreen: (p: FlowXY) => { x: number; y: number; }`
1685
1689
  - `setViewport: (v: Partial<FlowViewport>, opts?: { animate?: boolean | undefined; } | undefined) => void`
@@ -1689,6 +1693,7 @@ Exposed (template ref):
1689
1693
  - `zoomTo: (zoom: number, opts?: { animate?: boolean | undefined; } | undefined) => void`
1690
1694
  - `addNodes: (nodes: FlowNode<any> | FlowNode<any>[]) => void`
1691
1695
  - `addEdges: (edges: FlowEdge<any> | FlowEdge<any>[]) => void`
1696
+ - `change: (next: { nodes?: FlowNode<any>[] | undefined; edges?: FlowEdge<any>[] | undefined; }) => void` — Several changes as one undoable step (nodes and edges added, changed or removed together): each list given replaces the current one
1692
1697
  - `updateNode: (id: string, patch: Partial<FlowNode<any>> | ((n: FlowNode<any>) => FlowNode<any>)) => void`
1693
1698
  - `updateEdge: (id: string, patch: Partial<FlowEdge<any>> | ((e: FlowEdge<any>) => FlowEdge<any>)) => void`
1694
1699
  - `remove: (ids: { nodes?: string[] | undefined; edges?: string[] | undefined; }) => void` — Deletes nodes (with their edges and children) and edges by id
@@ -1728,7 +1733,7 @@ A connection point on a node in MFlow: drag from it to another node's handle to
1728
1733
 
1729
1734
  Props:
1730
1735
  - `type?: "source" | "target" = "source"` — `source`: edges leave from it; `target`: they arrive
1731
- - `position?: FlowPosition`
1736
+ - `position?: "auto" | FlowPosition` — Its side; `'auto'` sits in the node's middle (or where you put it) and each edge leaves or arrives on the side facing its other end
1732
1737
  - `id?: string`
1733
1738
  - `connectable?: boolean = true`
1734
1739
 
@@ -4935,7 +4940,7 @@ Import from `@m3ui-vue/m3ui-vue/flow`.
4935
4940
  `getSmoothStepPath` with sharp corners
4936
4941
 
4937
4942
  ```ts
4938
- getStepPath(p: FlowEdgePathParams & { offset?: number }): FlowEdgePath
4943
+ getStepPath(p: FlowEdgePathParams & { offset?: number; route?: number[] }): FlowEdgePath
4939
4944
  ```
4940
4945
 
4941
4946
  ### getStraightPath
@@ -4958,6 +4963,36 @@ The corners of an orthogonal route between the ends, leaving and arriving square
4958
4963
  smoothStepPoints(p: FlowEdgePathParams & { offset?: number }): Pt[]
4959
4964
  ```
4960
4965
 
4966
+ ### routePoints
4967
+
4968
+ Import from `@m3ui-vue/m3ui-vue/flow`.
4969
+
4970
+ The corners of an orthogonal edge routed through `route`: the positions of its segments after the first, alternately x and y, starting with where the leg leaving the source ends (an x when the source's side is left or right). The legs at the ends stretch to wherever the nodes are, and a corner is added before the target when it's needed to arrive square to its side, so the route stays orthogonal as the nodes move.
4971
+
4972
+ ```ts
4973
+ routePoints(p: FlowEdgePathParams & { route: number[] }): Pt[]
4974
+ ```
4975
+
4976
+ ### pointsToRoute
4977
+
4978
+ Import from `@m3ui-vue/m3ui-vue/flow`.
4979
+
4980
+ The other way round: the `route` that runs an orthogonal edge through these corners (its ends first and last)
4981
+
4982
+ ```ts
4983
+ pointsToRoute(points: Pt[], sourcePosition: FlowPosition = 'bottom', targetPosition?: FlowPosition): number[]
4984
+ ```
4985
+
4986
+ ### getRoutedPath
4987
+
4988
+ Import from `@m3ui-vue/m3ui-vue/flow`.
4989
+
4990
+ Right-angled steps through `route` (see `routePoints`), rounded like `getSmoothStepPath`
4991
+
4992
+ ```ts
4993
+ getRoutedPath(p: FlowEdgePathParams & { route: number[]; borderRadius?: number }): FlowEdgePath
4994
+ ```
4995
+
4961
4996
  ### arrowPath
4962
4997
 
4963
4998
  Import from `@m3ui-vue/m3ui-vue/flow`.
@@ -6270,6 +6305,13 @@ export interface FlowContext {
6270
6305
  getSize(id: string): { width: number; height: number }
6271
6306
  /** Nodes overlapping this one (or a rectangle in flow coordinates), groups and its own family left out */
6272
6307
  getIntersectingNodes(node: string | { x: number; y: number; width: number; height: number }): FlowNode[]
6308
+ /**
6309
+ * The edge passing within `radius` (flow units, default 8) of a flow point, nearest first, skipping the ones
6310
+ * `ignore` returns true for: where on it the point falls (on the grid along it with snapToGrid), the way it runs
6311
+ * there toward its target, and for an edge with its own route, the routes that keep each half's shape if it's split
6312
+ * there (as the `branch` event gives). For dropping something onto an edge, e.g. a junction
6313
+ */
6314
+ getEdgeAt(p: FlowXY, opts?: { radius?: number; ignore?: (e: FlowEdge) => boolean }): FlowEdgeHit | null
6273
6315
  /** Page (client) coordinates → flow coordinates */
6274
6316
  screenToFlow(p: { x: number; y: number }): FlowXY
6275
6317
  flowToScreen(p: FlowXY): { x: number; y: number }
@@ -6282,6 +6324,8 @@ export interface FlowContext {
6282
6324
  zoomTo(zoom: number, opts?: { animate?: boolean }): void
6283
6325
  addNodes(nodes: FlowNode | FlowNode[]): void
6284
6326
  addEdges(edges: FlowEdge | FlowEdge[]): void
6327
+ /** Several changes as one undoable step (nodes and edges added, changed or removed together): each list given replaces the current one */
6328
+ change(next: { nodes?: FlowNode[]; edges?: FlowEdge[] }): void
6285
6329
  updateNode(id: string, patch: Partial<FlowNode> | ((n: FlowNode) => FlowNode)): void
6286
6330
  updateEdge(id: string, patch: Partial<FlowEdge> | ((e: FlowEdge) => FlowEdge)): void
6287
6331
  /** Deletes nodes (with their edges and children) and edges by id */
@@ -6341,10 +6385,32 @@ export interface FlowEdge<D = any> {
6341
6385
  deletable?: boolean
6342
6386
  /** Its ends can be dragged to other handles once selected; default MFlow's `edgesReconnectable` */
6343
6387
  reconnectable?: boolean
6388
+ /**
6389
+ * A `smoothstep`/`step` edge's own route: where its segments after the first run, alternately x and y (see
6390
+ * `routePoints`). Dragging a selected edge's segments writes it (MFlow's `edgesReroutable`); without one it's
6391
+ * routed automatically
6392
+ */
6393
+ route?: number[]
6394
+ /** Its segments can be dragged once selected; default MFlow's `edgesReroutable` */
6395
+ reroutable?: boolean
6396
+ /** The side it leaves an `'auto'` handle by (default the side facing its other end) */
6397
+ sourcePosition?: FlowPosition
6398
+ /** The side it arrives at an `'auto'` handle by (default the side facing its other end) */
6399
+ targetPosition?: FlowPosition
6344
6400
  class?: string
6345
6401
  }
6346
6402
  ```
6347
6403
 
6404
+ ```ts
6405
+ /** An edge found under a point (`getEdgeAt`) */
6406
+ export interface FlowEdgeHit {
6407
+ edge: FlowEdge
6408
+ position: FlowXY
6409
+ direction: FlowPosition
6410
+ routes?: { before: number[]; after: number[] }
6411
+ }
6412
+ ```
6413
+
6348
6414
  ```ts
6349
6415
  export interface FlowFitOptions {
6350
6416
  /** Room around the nodes, a fraction of the view (default 0.1) */
@@ -6363,7 +6429,8 @@ export interface FlowFitOptions {
6363
6429
  export interface FlowHandleBounds {
6364
6430
  id: string | null
6365
6431
  type: 'source' | 'target'
6366
- position: FlowPosition
6432
+ /** 'auto': each edge leaves or arrives on the side that faces its other end */
6433
+ position: FlowPosition | 'auto'
6367
6434
  x: number
6368
6435
  y: number
6369
6436
  connectable: boolean
@@ -6408,6 +6475,11 @@ export interface FlowNode<D = any> {
6408
6475
  deletable?: boolean
6409
6476
  /** `false` keeps it from splicing into an edge when dropped onto one */
6410
6477
  insertable?: boolean
6478
+ /**
6479
+ * With snapToGrid, what lands on the grid is its position plus this (default its corner): `{ x: w / 2, y: h / 2 }`
6480
+ * puts its middle on the grid, e.g. a junction dot whose wires run along the grid lines
6481
+ */
6482
+ gridOffset?: FlowXY
6411
6483
  class?: string
6412
6484
  }
6413
6485
  ```