@foblex/flow 18.6.1 → 19.0.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/AI.md +113 -9
- package/README.md +5 -0
- package/fesm2022/foblex-flow.mjs +7079 -4549
- package/fesm2022/foblex-flow.mjs.map +1 -1
- package/index.d.ts +5340 -4308
- package/package.json +1 -1
- package/schematics/ng-add/index.d.ts +5 -1
- package/schematics/ng-add/index.js +58 -2
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/schema.json +7 -1
- package/styles/domains/_connector.scss +22 -8
package/AI.md
CHANGED
|
@@ -16,26 +16,92 @@ It provides rendering, connectors, interactions, selection, zoom, and connection
|
|
|
16
16
|
- Your app updates state.
|
|
17
17
|
- Angular rerenders.
|
|
18
18
|
|
|
19
|
+
## Minimal Working Setup
|
|
20
|
+
|
|
21
|
+
Three files must be correct at the same time. Missing any one produces a blank or inert canvas, usually without errors.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// component — FFlowModule is required: fNode, fConnector, f-connection are not standalone
|
|
25
|
+
import { FFlowModule } from '@foblex/flow';
|
|
26
|
+
|
|
27
|
+
@Component({
|
|
28
|
+
standalone: true,
|
|
29
|
+
imports: [FFlowModule],
|
|
30
|
+
templateUrl: './flow.html',
|
|
31
|
+
styleUrl: './flow.scss',
|
|
32
|
+
})
|
|
33
|
+
export class Flow {}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<!-- template — the hierarchy f-flow > f-canvas > fNode/f-connection is mandatory -->
|
|
38
|
+
<f-flow fDraggable>
|
|
39
|
+
<f-canvas>
|
|
40
|
+
<f-connection fSourceId="out-1" fTargetId="in-1"></f-connection>
|
|
41
|
+
|
|
42
|
+
<div fNode fDragHandle [fNodePosition]="{ x: 100, y: 100 }">
|
|
43
|
+
Node A
|
|
44
|
+
<div fConnector fConnectorType="source" fConnectorId="out-1"></div>
|
|
45
|
+
</div>
|
|
46
|
+
<div fNode fDragHandle [fNodePosition]="{ x: 320, y: 100 }">
|
|
47
|
+
Node B
|
|
48
|
+
<div fConnector fConnectorType="target" fConnectorId="in-1"></div>
|
|
49
|
+
</div>
|
|
50
|
+
</f-canvas>
|
|
51
|
+
</f-flow>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```scss
|
|
55
|
+
/* styles — f-flow must have a nonzero height or nothing is visible */
|
|
56
|
+
f-flow {
|
|
57
|
+
display: block;
|
|
58
|
+
height: 600px;
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The default theme is wired by `ng add @foblex/flow` (adds `node_modules/@foblex/flow/styles/default.scss` to `angular.json`). Without a theme, nodes and connections render unstyled or invisible.
|
|
63
|
+
|
|
19
64
|
## Verified Building Blocks
|
|
20
65
|
|
|
21
66
|
- `<f-flow>`: root flow host.
|
|
22
67
|
- `<f-canvas>`: canvas/viewport container.
|
|
23
68
|
- `[fNode]` and `[fGroup]`: place nodes and groups in the template.
|
|
24
|
-
- `[
|
|
25
|
-
- `[fNodeInput]`
|
|
26
|
-
- `
|
|
27
|
-
- `<f-connection>`: render an existing connection between connectors.
|
|
69
|
+
- `[fConnector]` with `fConnectorId` and `fConnectorType` (`'source' | 'target' | 'source-target' | 'outlet'`): the **unified connector**. Preferred for new code.
|
|
70
|
+
- `[fNodeOutput]` / `[fNodeInput]` / `[fNodeOutlet]`: legacy connectors, still supported, deprecated in favor of `fConnector`.
|
|
71
|
+
- `<f-connection>` with `fSourceId` / `fTargetId`: render an existing connection between connectors (`fOutputId` / `fInputId` are deprecated aliases).
|
|
28
72
|
- `<f-connection-for-create>`: optional preview connection used during drag-to-connect UX.
|
|
29
73
|
- `fDraggable` on `<f-flow>`: enables pointer interactions and emits interaction events.
|
|
74
|
+
- `fZoom` on `<f-canvas>`: opt-in wheel / double-click / pinch zoom.
|
|
75
|
+
- `<f-selection-area>`: opt-in rectangle multi-select.
|
|
76
|
+
- `provideFFlow(...)` with features: `withConnectionFlow('click')` (click-to-connect gesture alongside drag; custom gestures implement `IFConnectionFlow` and drive `FCreateConnectionSession`), `withControlScheme(...)` (gesture-to-action mapping, presets `F_DEFAULT_CONTROL_SCHEME`, `F_SCROLL_PAN_CONTROL_SCHEME`, `F_DRAG_SELECT_CONTROL_SCHEME`), `withReflowOnResize(...)` (auto layout on node resize), `withFCanvas(...)` (canvas defaults such as layer order), `withA11y(...)` (enables the keyboard accessibility layer — spatial arrow navigation, grab-move, keyboard connection creation, `Delete` emits `fDeleteSelected`; configurable steps, key bindings `IFA11yKeys`, localizable announcements `IFA11yMessages`; ARIA semantics and the live region are always on even without the feature).
|
|
30
77
|
|
|
31
78
|
## Hard Rules
|
|
32
79
|
|
|
33
80
|
- Never invent Inputs, Outputs, methods, directives, or selectors.
|
|
34
|
-
- Do **not** assume React Flow style APIs such as `[nodes]`, `[edges]`, `setNodes()`, `addEdge()`, `useNodesState()`, or similar patterns.
|
|
81
|
+
- Do **not** assume React Flow style APIs such as `[nodes]`, `[edges]`, `setNodes()`, `addEdge()`, `useNodesState()`, `<Handle>`, `<Background>`, `<Controls>`, or similar patterns.
|
|
35
82
|
- Do **not** assume a built-in graph store. The app owns state.
|
|
36
83
|
- Connections are connector-to-connector, not generic node-to-node edges.
|
|
37
|
-
- Template connections use `fOutputId -> fInputId
|
|
38
|
-
- Do **not** interpret `[fNodes]` or `[fConnections]` as graph-state inputs.
|
|
84
|
+
- Template connections use `fSourceId -> fTargetId` referencing `fConnectorId` values (legacy: `fOutputId -> fInputId` referencing output/input ids).
|
|
85
|
+
- Do **not** interpret `[fNodes]` or `[fConnections]` as graph-state inputs. They are content-projection slot markers used with `ngProjectAs` (see the nested control flow rule below).
|
|
86
|
+
- **Nested control flow requires `ngProjectAs`.** Nodes, groups, or connections rendered inside nested template blocks (`@for` in `@if`, `@for` in `@for`, `@if` in `@if`, or a wrapper element) are NOT projected into the canvas — Angular creates them detached, geometry collapses to 0×0, and nothing renders, with no error. Wrap such blocks:
|
|
87
|
+
|
|
88
|
+
```html
|
|
89
|
+
@if (isEditable()) {
|
|
90
|
+
<ng-container ngProjectAs="[fNodes]">
|
|
91
|
+
@for (node of nodes(); track node.id) {
|
|
92
|
+
<div fNode [fNodePosition]="node.position">{{ node.label }}</div>
|
|
93
|
+
}
|
|
94
|
+
</ng-container>
|
|
95
|
+
<ng-container ngProjectAs="[fConnections]">
|
|
96
|
+
@for (c of connections(); track c.id) {
|
|
97
|
+
<f-connection [fSourceId]="c.source" [fTargetId]="c.target" />
|
|
98
|
+
}
|
|
99
|
+
</ng-container>
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Use `"[fNodes]"` for nodes, `"[fGroups]"` for groups, `"[fConnections]"` for connections. A single top-level `@for` / `@if` directly inside `<f-canvas>` needs no wrapper.
|
|
104
|
+
|
|
39
105
|
- Examples may include app-specific state, layout logic, persistence, undo/redo, toolbars, or validation. Those are example implementations, not built-in package features.
|
|
40
106
|
- Some exports are low-level, compatibility-oriented, or testing-oriented. Do not treat every export from `@foblex/flow` as the recommended app-facing API.
|
|
41
107
|
- If a symbol, selector, event, or behavior is not confirmed in the installed package, say: `not found in @foblex/flow`.
|
|
@@ -43,16 +109,47 @@ It provides rendering, connectors, interactions, selection, zoom, and connection
|
|
|
43
109
|
## Correct Usage Pattern
|
|
44
110
|
|
|
45
111
|
- Render nodes and groups from your Angular state using normal Angular templates.
|
|
46
|
-
- Put connectors on the node element itself or on child elements with `
|
|
112
|
+
- Put connectors on the node element itself or on child elements with `fConnector`.
|
|
47
113
|
- Render persisted connections explicitly with `<f-connection>`.
|
|
48
114
|
- Add `fDraggable` to `<f-flow>` when you want drag, selection, connect, reassign, or drop interactions.
|
|
49
115
|
- Handle events such as `fCreateConnection`, `fReassignConnection`, `fMoveNodes`, `fSelectionChange`, `fCreateNode`, `fDropToGroup`, and `fConnectionWaypointsChanged`.
|
|
50
116
|
- Update your own state in those handlers, then let Angular rerender.
|
|
51
117
|
- Use node/group position bindings and change outputs to keep positions in app state when needed.
|
|
52
118
|
|
|
119
|
+
## Common Silent Failures — Check These First
|
|
120
|
+
|
|
121
|
+
When the flow compiles but looks wrong, verify in this order:
|
|
122
|
+
|
|
123
|
+
1. **Connection not visible**: `fSourceId` / `fTargetId` does not match any rendered `fConnectorId` exactly (string comparison; `1` vs `'1'` from different sources is a classic mismatch). The connection silently does not render.
|
|
124
|
+
2. **Blank canvas**: `f-flow` has zero height, or the theme SCSS is not wired in `angular.json`.
|
|
125
|
+
3. **`'f-flow' is not a known element`** or connectors not working: `FFlowModule` missing from the component `imports`.
|
|
126
|
+
4. **Nothing is draggable / no events fire**: `fDraggable` missing on `<f-flow>`.
|
|
127
|
+
5. **Wheel does nothing**: `fZoom` missing on `<f-canvas>` (zoom is opt-in).
|
|
128
|
+
6. **Node ignores position**: `[fNodePosition]` must be a property binding to `{ x, y }`, and nodes must be direct content of `<f-canvas>`.
|
|
129
|
+
7. **`[f-flow][FF1003]` error**: a connector is placed outside an `[fNode]` / `[fGroup]` element.
|
|
130
|
+
8. **Nodes/connections exist in state but nothing renders, no errors** (`FF1004` warns in dev mode): flow content sits inside nested `@if`/`@for` blocks without `<ng-container ngProjectAs="[fNodes]">` (`"[fGroups]"` / `"[fConnections]"`) — see the Hard Rules section.
|
|
131
|
+
9. **Handles/selection/connect present but inert** (`FF1005`): `fDraggable` is missing on `<f-flow>` while `fDragHandle` / `f-selection-area` / `f-connection-for-create` / resize / rotate are used.
|
|
132
|
+
10. **Connections attach to the wrong place** (`FF1006`): a connector is hidden with CSS (`display: none`) — its geometry is a 0×0 point. Conditionally render instead of hiding.
|
|
133
|
+
11. **Node moves but its bindings never fire** (`FF1007`): an `fNode` element is nested inside another node element. One `fNode` per node; hierarchy is id-based (`fNodeParentId`), not DOM-based.
|
|
134
|
+
12. **Group behaviors don't apply** (`FF1008`): `fNodeParentId` / `fGroupParentId` references an id no rendered group has.
|
|
135
|
+
13. **Wrong initial viewport** (`FF1009`): `fitToScreen()` / `resetScaleAndCenter()` / `centerGroupOrNode()` called before nodes were rendered — call them from `(fNodesRendered)` (earliest safe) or `(fFullRendered)`.
|
|
136
|
+
|
|
137
|
+
To verify programmatically: listen to `(fFullRendered)` on `<f-flow>`, then call `flow.getState()` and assert every declared connection resolved to existing connectors.
|
|
138
|
+
|
|
139
|
+
## Additional Rules
|
|
140
|
+
|
|
141
|
+
- The library runs outside the Angular zone: its events do not trigger change detection. With OnPush or zoneless apps, replace arrays/objects (new references) instead of mutating, and call `markForCheck()` where needed.
|
|
142
|
+
- Always set stable, app-owned ids on nodes and connections; auto-generated ids (`f-connection-3`) cannot be mapped back to your model and break selection/persistence across re-renders.
|
|
143
|
+
- Style flow internals (connection paths, minimap, markers) in global styles or via `::ng-deep` — component-scoped CSS never reaches them. Wire the default theme via `ng add`.
|
|
144
|
+
- Do not combine `fAutoSizeToFitChildren` with restoring a persisted group size in the same render: pass `false` while restoring, enable it afterwards.
|
|
145
|
+
- With several `<f-flow>` instances on one page, keep `fDraggable` enabled only on the active flow.
|
|
146
|
+
- Connections define `SELECTED_START` / `SELECTED_END` marker variants in addition to `START` / `END`, or markers disappear when the connection is selected.
|
|
147
|
+
- An empty `fCanBeConnectedTo` allow-list means "no restriction", not "allow nothing"; category strings must match exactly.
|
|
148
|
+
- Above ~500 nodes enable `[fCache]` on `<f-flow>` and render nodes with `*fVirtualFor` inside `<ng-container ngProjectAs="[fNodes]">`.
|
|
149
|
+
|
|
53
150
|
## Naming Distinction
|
|
54
151
|
|
|
55
|
-
- In templates, connector ids are `fOutputId`
|
|
152
|
+
- In templates, connector ids are `fConnectorId` (unified) or legacy `fOutputId` / `fInputId`; connection endpoints are `fSourceId` / `fTargetId`.
|
|
56
153
|
- In `FCreateConnectionEvent`, prefer `sourceId`, `targetId`, and `dropPosition`.
|
|
57
154
|
- `FCreateConnectionEvent` still exposes legacy aliases `fOutputId`, `fInputId`, and `fDropPosition`.
|
|
58
155
|
- In `FReassignConnectionEvent`, prefer `connectionId`, `endpoint`, `previousSourceId`, `nextSourceId`, `previousTargetId`, `nextTargetId`, and `dropPosition`.
|
|
@@ -64,6 +161,13 @@ It provides rendering, connectors, interactions, selection, zoom, and connection
|
|
|
64
161
|
|
|
65
162
|
See [STYLING.md](./STYLING.md).
|
|
66
163
|
|
|
164
|
+
## More Documentation
|
|
165
|
+
|
|
166
|
+
- Full LLM-readable reference: https://flow.foblex.com/llms-full.txt
|
|
167
|
+
- Docs index for agents: https://flow.foblex.com/llms.txt
|
|
168
|
+
- Human docs: https://flow.foblex.com/docs/get-started
|
|
169
|
+
- Live examples with source: https://flow.foblex.com/examples/overview
|
|
170
|
+
|
|
67
171
|
## Fallback Rule
|
|
68
172
|
|
|
69
173
|
If something cannot be verified from the installed package, answer with: `not found in @foblex/flow`.
|
package/README.md
CHANGED
|
@@ -149,6 +149,11 @@ Full guide: [Default Theme and Styling](https://flow.foblex.com/docs/default-the
|
|
|
149
149
|
- [Roadmap](https://github.com/Foblex/f-flow/blob/main/ROADMAP.md)
|
|
150
150
|
- [Changelog](https://github.com/Foblex/f-flow/blob/main/CHANGELOG.md)
|
|
151
151
|
|
|
152
|
+
### For AI Agents and LLMs
|
|
153
|
+
|
|
154
|
+
- [llms.txt](https://flow.foblex.com/llms.txt) — docs index for agents; [llms-full.txt](https://flow.foblex.com/llms-full.txt) — complete LLM-readable API reference
|
|
155
|
+
- [AI usage guide](https://github.com/Foblex/f-flow/blob/main/libs/f-flow/AI.md) — strict code-generation rules, also shipped inside this package at `node_modules/@foblex/flow/AI.md`
|
|
156
|
+
|
|
152
157
|
## Community and Support
|
|
153
158
|
|
|
154
159
|
- [GitHub Repository](https://github.com/Foblex/f-flow)
|