-
Notifications
You must be signed in to change notification settings - Fork 3
bump react flow to v12 #274
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
5b2a1a6
bump to v12
tomatophantastico 453736f
fix comile error, not noticed because storybook worked fine ...
tomatophantastico 53f833a
lint
tomatophantastico 7dda483
downgrade string-width and ansi-width, as they most likely no longer…
tomatophantastico 574ebc1
Added EdgeDefaultV12
fiorsaoirse afeab7f
re-integrated typescript unsafe code.
tomatophantastico 12216a1
Adjusted edge label component for v12
fiorsaoirse 932692b
Add handles
fiorsaoirse 983fba7
Added EdgeDefs container, changed the story
fiorsaoirse db75db8
Merge branch 'develop' into feature/bump-react-flow-v12-CMEM-6506
haschek bc64e27
Import styles via scss file
fiorsaoirse 018a2de
Fix stylings
fiorsaoirse 33315d0
Fix compile
fiorsaoirse 66109c1
Fix stories issues, fix edge label
fiorsaoirse f8bf6c7
Merge remote-tracking branch 'origin/develop' into feature/bump-react…
haschek 11ddb98
align examples in size and configuration
haschek 0d8625b
Fix strokeType for EdgeDefaultV12, fixed story for NodeContentV12
fiorsaoirse a79157b
Added missed import of EdgeDefs
fiorsaoirse 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
146 changes: 146 additions & 0 deletions
146
src/extensions/react-flow/edges/stories/EdgeDefaultV12.stories.tsx
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 |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| import React, { useCallback, useMemo, useState } from "react"; | ||
| import { Node, Edge, ReactFlow } from "@xyflow/react"; | ||
| import { ArrowHeadType, getMarkerEnd } from "react-flow-renderer"; | ||
| import { Meta, StoryFn } from "@storybook/react"; | ||
|
|
||
| import { EdgeLabel, EdgeLabelObject } from "./../../../../../index"; | ||
| import { EdgeDefault as ActualEdge, EdgeDefaultDataProps as EdgeData } from "./../EdgeDefault"; | ||
| import { NodeDefaultV12 } from "../../nodes/NodeDefaultV12"; | ||
|
|
||
| /** | ||
| * this is only a mock to get it as sub element in the table | ||
| */ | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| const EdgeDefaultDataProps = (data: EdgeData) => { | ||
| return <></>; | ||
| }; | ||
|
|
||
| const edgeTypes = { | ||
| default: ActualEdge, | ||
| }; | ||
| const nodeTypes = { | ||
| default: NodeDefaultV12, | ||
| }; | ||
| export default { | ||
| title: "Extensions/React Flow V12/Edge", | ||
| component: ActualEdge, | ||
| subcomponents: { EdgeDefaultDataProps }, | ||
| } as Meta<typeof ActualEdge>; | ||
|
|
||
| const EdgeDefault = (args: Edge) => { | ||
| const [reactflowInstance, setReactflowInstance] = useState(null); | ||
|
|
||
| const [nodes, edges] = useMemo<[Node[], Edge[]]>(() => { | ||
| return [ | ||
| [ | ||
| { | ||
| id: args.source, | ||
| type: "default", | ||
| data: { | ||
| label: "Default ", | ||
| content: "Example content.", | ||
| minimalShape: "none", | ||
| }, | ||
| position: { x: 50, y: 0 }, | ||
| }, | ||
| { | ||
| id: args.target, | ||
| type: "default", | ||
| data: { | ||
| label: "Default ", | ||
| content: "Example content.", | ||
| minimalShape: "none", | ||
| }, | ||
| position: { x: 300, y: 0 }, | ||
| }, | ||
| ] as Node[], | ||
| [args], | ||
| ]; | ||
| }, [args]); | ||
|
|
||
| const onLoad = useCallback( | ||
| (rfi) => { | ||
| if (!reactflowInstance) { | ||
| setReactflowInstance(rfi); | ||
| } | ||
| }, | ||
| [reactflowInstance] | ||
| ); | ||
|
|
||
| return ( | ||
| <div style={{ width: "1000px", height: "800px" }}> | ||
| <ReactFlow | ||
| defaultNodes={nodes} | ||
| defaultEdges={edges} | ||
| onLoad={onLoad} | ||
| edgeTypes={edgeTypes} | ||
| nodeTypes={nodeTypes} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| const Template: StoryFn<typeof EdgeDefault> = (args) => <EdgeDefault {...args} />; | ||
|
|
||
| const defaultEdge: Edge = { | ||
| id: "default", | ||
| label: "edge", | ||
| source: "node-1", | ||
| target: "node-2", | ||
| data: { | ||
| edgeSvgProps: { | ||
| className: "storybook__test__classname", | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export const Default = Template.bind({}); | ||
| Default.args = defaultEdge; | ||
|
|
||
| export const CustomLabel = Template.bind({}); | ||
| CustomLabel.args = { | ||
| ...Default.args, | ||
| id: "customlabel", | ||
| label: undefined, | ||
| data: { | ||
| renderLabel: (edgeCenter: [number, number, number, number]) => ( | ||
| <EdgeLabelObject edgeCenter={edgeCenter}> | ||
| <EdgeLabel text="Custom label that is very long" /> | ||
| </EdgeLabelObject> | ||
| ), | ||
| }, | ||
| }; | ||
|
|
||
| export const InverseEdge = Template.bind({}); | ||
| InverseEdge.args = { | ||
| ...Default.args, | ||
| id: "inverse", | ||
| data: { | ||
| inversePath: true, | ||
| markerStart: getMarkerEnd(`${ArrowHeadType.ArrowClosed}-inverse` as ArrowHeadType), | ||
| }, | ||
| }; | ||
|
|
||
| export const AdjustStrokeType = Template.bind({}); | ||
| AdjustStrokeType.args = { | ||
| ...Default.args, | ||
| data: { | ||
| strokeType: "double", | ||
| }, | ||
| }; | ||
|
|
||
| export const AdjustIntent = Template.bind({}); | ||
| AdjustIntent.args = { | ||
| ...Default.args, | ||
| data: { | ||
| intent: "warning", | ||
| }, | ||
| }; | ||
|
|
||
| export const AdjustHighlight = Template.bind({}); | ||
| AdjustHighlight.args = { | ||
| ...Default.args, | ||
| data: { | ||
| highlightColor: ["default", "alternate"], | ||
| }, | ||
| }; |
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.
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.
Uh oh!
There was an error while loading. Please reload this page.