-
Notifications
You must be signed in to change notification settings - Fork 10
feat(Groups): CollapsibleGroup #259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
draedful
wants to merge
18
commits into
main
Choose a base branch
from
collapse_group
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,910
−152
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
756f575
...
draedful f547a48
...
draedful e11fded
...
draedful e4e21b1
...
draedful cb3d02c
...
draedful ac1ad64
...
draedful 3c0efd2
...
draedful 06e133b
...
draedful 2369d94
...
draedful 8b78adb
...
draedful 027d955
...
draedful 220b32b
Update collapsible-group.spec.ts
draedful 39cefbd
...
draedful f1551b0
...
draedful 6becd7c
...
draedful e637769
...
draedful e54a46d
chore: remove darwin screenshot snapshots and review file
draedful ceba070
...
draedful File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -108,6 +108,66 @@ if (graph.rootStore.connectionsList.hasPort("block-1_output")) { | |
|
|
||
| **Ownership Model**: Components that own ports (blocks, anchors) are responsible for updating port coordinates. Components that observe ports (connections) read coordinates for rendering but don't control them. Ports are automatically cleaned up when they have no owner and no observers. | ||
|
|
||
| ### Port Delegation | ||
|
|
||
| Port delegation allows one component to temporarily take control of another component's port position. While delegated, the port mirrors the position of its delegate target. The original owner continues to call `setPoint()` as usual, but those values are silently saved — the effective position comes from the delegate. When delegation ends, the port restores its last saved position as if nothing happened. | ||
|
|
||
| **Why this is useful:** Sometimes a component needs to intercept port positions of other components without those components knowing about it. For example, `CollapsibleGroup` collapses a group of blocks into a compact header. When collapsed, the group hides all its blocks but their external connections must remain visible — now originating from the group's edges instead of the hidden blocks. The group creates its own edge ports and delegates all block ports to them: | ||
|
|
||
| ``` | ||
| Before collapse: After collapse: | ||
| ┌─────────────┐ | ||
| [Block-1] ──conn──→ [Outer] │ [−] Group ├──conn──→ [Outer] | ||
| [Block-2] └─────────────┘ | ||
| ``` | ||
|
|
||
| The block ports don't know they're delegated — they keep receiving `setPoint()` calls from their owners as blocks move inside the group. When the group expands, delegation is removed and connections snap back to their original block positions. | ||
|
|
||
| #### API | ||
|
|
||
| ```typescript | ||
| const blockPort = graph.rootStore.connectionsList.ports.getPort("block-1_output"); | ||
| const groupEdgePort = graph.rootStore.connectionsList.ports.getPort("group-1_right"); | ||
|
|
||
| // Delegate: blockPort now mirrors groupEdgePort's position | ||
| blockPort.delegate(groupEdgePort); | ||
|
|
||
| blockPort.getPoint(); // returns groupEdgePort's position | ||
| blockPort.isDelegated; // true | ||
|
|
||
| // Owner keeps calling setPoint — values are saved, not applied | ||
| blockPort.setPoint(100, 200); | ||
| blockPort.getPoint(); // still returns groupEdgePort's position | ||
|
|
||
| // Moving the delegate target automatically updates all delegated ports | ||
| groupEdgePort.setPoint(300, 400); | ||
| blockPort.getPoint(); // { x: 300, y: 400 } | ||
|
|
||
| // Remove delegation — restores last saved position | ||
| blockPort.undelegate(); | ||
| blockPort.getPoint(); // { x: 100, y: 200 } | ||
| blockPort.isDelegated; // false | ||
| ``` | ||
|
|
||
| #### How CollapsibleGroup uses delegation | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove it parts |
||
|
|
||
| When a group collapses: | ||
| 1. The group creates two edge ports (left and right) positioned at the collapsed rect edges | ||
| 2. All block ports inside the group are delegated to the appropriate edge port (input → left, output → right) | ||
| 3. External connections now visually originate from the group's edges | ||
| 4. Internal connections (both endpoints in the group) are hidden via `$hidden` signal | ||
| 5. When the group is dragged, only the edge ports need to move — all delegated ports follow automatically | ||
|
|
||
| When the group expands: | ||
| 1. All block ports are undelegated — they restore their original positions | ||
| 2. Connections snap back to their block positions | ||
|
|
||
| #### Key behaviors | ||
|
|
||
| - `$point` signal is reactive — subscribers (connections) automatically update when the delegate moves | ||
| - If `setPoint()` is never called during delegation, `undelegate()` restores the position from before `delegate()` was called | ||
| - If `setPoint()` is called multiple times during delegation, the last value wins on `undelegate()` | ||
|
|
||
| ## Styling and Visual Customization | ||
|
|
||
| Global settings control the visual appearance the default [BlockConnection](../../src/components/canvas/connections/BlockConnection.md) and behavior of all connections in your graph: | ||
|
|
||
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Less details please