-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: initial implementation of subflows * feat: allow to select group node * fix: improve layer order for direct children * feat: keep child node in bounds of parent * feat: compute global point on multiple levels * fix: improve layer order for nested children * fix: rounded group in safari * refactor: make parentId private * feat: add color field to default group * feat: implement template group * feat: add selectable class to template group * feat: support handles on group nodes * feat: add more type utils * feat: set initial order for nodes * feat: add optimization setting * feat: allow to set null for parentId * docs: add page about subflows * up version
- Loading branch information
1 parent
b9ec1dc
commit 0680dcd
Showing
19 changed files
with
378 additions
and
46 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
...ngx-vflow-demo/src/app/categories/features/pages/subflows/demo/subflows-demo.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
import { Edge, Node, VflowModule } from 'projects/ngx-vflow-lib/src/public-api'; | ||
|
||
@Component({ | ||
template: `<vflow [nodes]="nodes" [edges]="edges"> | ||
<ng-template groupNode let-ctx> | ||
<svg:rect | ||
selectable | ||
rx="5" | ||
ry="5" | ||
[attr.width]="ctx.node.width" | ||
[attr.height]="ctx.node.height" | ||
[style.stroke]="'red'" | ||
[style.fill]="'red'" | ||
[style.fill-opacity]="0.05" | ||
[style.stroke-width]="ctx.selected() ? 3 : 1" | ||
> | ||
<handle type="source" position="right" /> | ||
</svg:rect> | ||
</ng-template> | ||
</vflow>`, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [VflowModule] | ||
}) | ||
export class SubflowsDemoComponent { | ||
public nodes: Node[] = [ | ||
{ | ||
id: '1', | ||
point: { x: 10, y: 10 }, | ||
type: 'default', | ||
text: `1`, | ||
parentId: '3' | ||
}, | ||
{ | ||
id: '2', | ||
point: { x: 90, y: 80 }, | ||
type: 'default', | ||
// it's possible to pass html in this field | ||
text: `<strong>2</strong>`, | ||
parentId: '3' | ||
}, | ||
{ | ||
id: '3', | ||
point: { x: 10, y: 10 }, | ||
type: 'default-group', | ||
width: 250, | ||
height: 250 | ||
}, | ||
{ | ||
id: '4', | ||
point: { x: 280, y: 10 }, | ||
type: 'default', | ||
text: `4`, | ||
}, | ||
{ | ||
id: '5', | ||
point: { x: 10, y: 160 }, | ||
type: 'template-group', | ||
width: 170, | ||
height: 70, | ||
parentId: '3' | ||
}, | ||
{ | ||
id: '6', | ||
point: { x: 10, y: 10 }, | ||
type: 'default', | ||
text: `6`, | ||
parentId: '5' | ||
}, | ||
] | ||
|
||
public edges: Edge[] = [ | ||
{ | ||
source: '1', | ||
target: '2', | ||
id: '1 -> 2' | ||
}, | ||
{ | ||
source: '2', | ||
target: '4', | ||
id: '2 -> 4' | ||
}, | ||
{ | ||
source: '5', | ||
target: '4', | ||
id: '5 -> 4' | ||
}, | ||
] | ||
} |
18 changes: 18 additions & 0 deletions
18
projects/ngx-vflow-demo/src/app/categories/features/pages/subflows/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# {{ NgDocPage.title }} | ||
|
||
A subflow is a node that can contain child nodes. Key things about subflows: | ||
|
||
- To create a subflow, you need to use a `default-group` or `template-group` `type` on `Node` or `DynamicNode`. | ||
- To associate a node with a subflow, set the `parentId` to the ID of the subflow. | ||
- Nodes within a subflow have coordinates *relative* to that subflow. | ||
- A subflow is itself a node, so it can act as a source or a target (this functionality is available only for `template-group` subflows). | ||
- Use the `groupNode` directive on an `ng-template` to define your custom subflow. While a custom subflow can theoretically be any SVG structure, it's recommended to use the `<rect />` element. | ||
|
||
{{ NgDocActions.demo("SubflowsDemoComponent", { expanded: true }) }} | ||
|
||
## See also | ||
|
||
- `DefaultGroupNode` | ||
- `TemplateGroupNode` | ||
- `DefaultDynamicGroupNode` | ||
- `TemplateDynamicGroupNode` |
13 changes: 13 additions & 0 deletions
13
projects/ngx-vflow-demo/src/app/categories/features/pages/subflows/ng-doc.page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { NgDocPage } from '@ng-doc/core'; | ||
import ExamplesCategory from '../../ng-doc.category' | ||
import { SubflowsDemoComponent } from './demo/subflows-demo.component'; | ||
|
||
const TestPage: NgDocPage = { | ||
title: `Subflows`, | ||
mdFile: './index.md', | ||
category: ExamplesCategory, | ||
demos: { SubflowsDemoComponent }, | ||
order: 1 | ||
}; | ||
|
||
export default TestPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.