@flowuent-org/diagramming-core 1.3.10 → 1.4.1
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/.editorconfig +13 -13
- package/.eslintignore +1 -1
- package/.eslintrc.json +35 -35
- package/.prettierignore +3 -3
- package/.prettierrc +3 -3
- package/.vscode/settings.json +6 -6
- package/README.md +95 -95
- package/apps/authentication/tsconfig.app.json +23 -23
- package/apps/authentication/tsconfig.json +21 -21
- package/apps/authentication/tsconfig.spec.json +28 -28
- package/apps/diagramming/.eslintrc.json +18 -18
- package/apps/diagramming/index.html +16 -16
- package/apps/diagramming/project.json +53 -53
- package/apps/diagramming/public/aws-icons/compute/App Runner.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Application Auto Scaling.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Batch.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Bottlerocket.svg +19 -19
- package/apps/diagramming/public/aws-icons/compute/Compute Optimizer.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/EC2 Auto Scaling.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/EC2 Image Builder.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/EC2.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Elastic Beanstalk.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Elastic Fabric Adapter.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Fargate.svg +19 -19
- package/apps/diagramming/public/aws-icons/compute/Genomics CLI.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Lambda.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Local Zones.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/NICE DCV.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/NICE EnginFrame.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Nitro Enclaves.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Outposts family.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Outposts rack.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Outposts servers.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/ParallelCluster.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Serverless Application Repository.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/SimSpace Weaver.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Thinkbox Deadline.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Thinkbox Frost.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Thinkbox Sequoia.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Thinkbox Stoke.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Thinkbox XMesh.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/VMware Cloud on AWS.svg +17 -17
- package/apps/diagramming/public/aws-icons/compute/Wavelength.svg +17 -17
- package/apps/diagramming/public/aws-icons/container/ECS Anywhere.svg +17 -17
- package/apps/diagramming/public/aws-icons/container/EKS Anywhere.svg +17 -17
- package/apps/diagramming/public/aws-icons/container/EKS Cloud.svg +17 -17
- package/apps/diagramming/public/aws-icons/container/EKS Distro.svg +17 -17
- package/apps/diagramming/public/aws-icons/container/Elastic Container Registry.svg +17 -17
- package/apps/diagramming/public/aws-icons/container/Elastic Container Service.svg +17 -17
- package/apps/diagramming/public/aws-icons/container/Elastic Kubernetes Service.svg +17 -17
- package/apps/diagramming/public/aws-icons/container/Fargate.svg +19 -19
- package/apps/diagramming/public/aws-icons/container/Red Hat OpenShift Service on AWS.svg +17 -17
- package/apps/diagramming/public/aws-icons/database/Aurora.svg +17 -17
- package/apps/diagramming/public/aws-icons/database/Database Migration Service.svg +17 -17
- package/apps/diagramming/public/aws-icons/database/DocumentDB.svg +17 -17
- package/apps/diagramming/public/aws-icons/database/ElastiCache.svg +17 -17
- package/apps/diagramming/public/aws-icons/database/Keyspaces.svg +15 -15
- package/apps/diagramming/public/aws-icons/database/MemoryDB for Redis.svg +17 -17
- package/apps/diagramming/public/aws-icons/database/Neptune.svg +17 -17
- package/apps/diagramming/public/aws-icons/database/RDS on VMware.svg +17 -17
- package/apps/diagramming/public/aws-icons/database/RDS.svg +17 -17
- package/apps/diagramming/public/aws-icons/database/Timestream.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/App Mesh.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/Client VPN.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/Cloud Directory.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/Cloud Map.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/Cloud WAN.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/CloudFront.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/Direct Connect.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/Elastic Load Balancing.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/Global Accelerator.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/Private 5G.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/PrivateLink.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/Route 53.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/Site to Site VPN.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/Transit Gateway.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/VPC Lattice.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/Verified Access.svg +17 -17
- package/apps/diagramming/public/aws-icons/networking/Virtual Private Cloud.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Artifact.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Audit Manager.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Certificate Manager.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/CloudHSM.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Cognito.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Detective.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Directory Service.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Firewall Manager.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/GuardDuty.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/IAM Identity Center.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Identity and Access Management.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Inspector.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Key Management Service.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Macie.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Network Firewall.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Resource Access Manager.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Secrets Manager.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Security Hub.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Security Lake.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Shield.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Signer.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/Verified Permissions.svg +17 -17
- package/apps/diagramming/public/aws-icons/security/WAF.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/Backup.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/EFS.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/Elastic Block Store.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/Elastic Disaster Recovery.svg +15 -15
- package/apps/diagramming/public/aws-icons/storage/FSx for Lustre.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/FSx for NetApp ONTAP.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/FSx for OpenZFS.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/FSx for WFS.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/FSx.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/File Cache.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/S3 on Outposts.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/Simple Storage Service Glacier.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/Simple Storage Service.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/Snowball Edge.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/Snowball.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/Snowcone.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/Snowmobile.svg +17 -17
- package/apps/diagramming/public/aws-icons/storage/Storage Gateway.svg +17 -17
- package/apps/diagramming/public/azure-icons/compute/02112-icon-service-Automanaged-VM.svg +1 -1
- package/apps/diagramming/public/azure-icons/databases/02390-icon-service-Azure-SQL.svg +1 -1
- package/apps/diagramming/public/azure-icons/databases/02392-icon-service-SSIS-Lift-And-Shift-IR.svg +1 -1
- package/apps/diagramming/public/azure-icons/networking/02145-icon-service-Resource-Management-Private-Link.svg +1 -1
- package/apps/diagramming/public/azure-icons/security/02247-icon-service-Microsoft-Defender-for-IoT.svg +1 -1
- package/apps/diagramming/public/sample-node-complete.json +63 -63
- package/apps/diagramming/public/sample-node-data.json +63 -63
- package/apps/diagramming/src/AutomationDiagramData.ts +147 -480
- package/apps/diagramming/src/CollaborationDiagramData.ts +127 -127
- package/apps/diagramming/src/CustomIconExamples.ts +233 -233
- package/apps/diagramming/src/DiagramTabs.tsx +205 -205
- package/apps/diagramming/src/Pages/DevPlayground.tsx +3 -3
- package/apps/diagramming/src/Pages/Home.tsx +111 -111
- package/apps/diagramming/src/SequenceDiagramData.ts +215 -215
- package/apps/diagramming/src/StateMachineDiagramData.ts +64 -64
- package/apps/diagramming/src/UseCaseDiagramData.ts +52 -52
- package/apps/diagramming/src/cloud-data.ts +371 -371
- package/apps/diagramming/src/components/AddNodeView.tsx +252 -252
- package/apps/diagramming/src/createSelecors.tsx +17 -17
- package/apps/diagramming/src/index.scss +12 -12
- package/apps/diagramming/src/main.tsx +463 -463
- package/apps/diagramming/src/node-data.ts +664 -664
- package/apps/diagramming/src/sample-workflow-content.ts +55 -55
- package/apps/diagramming/src/stencil-items.ts +31 -31
- package/apps/diagramming/src/style.css +13 -13
- package/apps/diagramming/src/tabsStore.tsx +152 -152
- package/apps/diagramming/src/vite-env.d.ts +1 -1
- package/apps/diagramming/tsconfig.app.json +23 -23
- package/apps/diagramming/tsconfig.json +21 -21
- package/apps/diagramming/tsconfig.spec.json +28 -28
- package/apps/diagramming/vite.config.ts +34 -34
- package/apps/diagramming/webpack.config.js +13 -13
- package/apps/workflow/.eslintrc.json +18 -18
- package/apps/workflow/group/group-form-hooks/index.ts +3 -3
- package/apps/workflow/group/group-form-hooks/useFormValidation.ts +20 -20
- package/apps/workflow/group/group-form-schema/SettingsTabFormSchema.ts +7 -7
- package/apps/workflow/group/group-form-schema/index.ts +3 -3
- package/apps/workflow/i18n.ts +19 -19
- package/apps/workflow/index.html +16 -16
- package/apps/workflow/locales/en/translation.json +713 -713
- package/apps/workflow/project.json +8 -8
- package/apps/workflow/src/app/app.module.css +1 -1
- package/apps/workflow/src/app/app.spec.tsx +15 -15
- package/apps/workflow/src/app/app.tsx +370 -370
- package/apps/workflow/src/main.tsx +13 -13
- package/apps/workflow/src/styles.css +1 -1
- package/apps/workflow/src/theme/index.ts +546 -546
- package/apps/workflow/tsconfig.app.json +23 -23
- package/apps/workflow/tsconfig.json +21 -21
- package/apps/workflow/tsconfig.spec.json +28 -28
- package/apps/workflow/vite.config.ts +51 -51
- package/nx.json +58 -58
- package/package.json +1 -1
- package/packages/api/.babelrc +12 -12
- package/packages/api/.eslintrc.json +18 -18
- package/packages/api/README.md +7 -7
- package/packages/api/project.json +8 -8
- package/packages/api/src/index.ts +3 -3
- package/packages/api/src/lib/jsonPlaceholderService/endpoints.ts +3 -3
- package/packages/api/src/lib/jsonPlaceholderService/service.ts +13 -13
- package/packages/api/tsconfig.json +17 -17
- package/packages/api/tsconfig.lib.json +24 -24
- package/packages/atoms/.babelrc +12 -12
- package/packages/atoms/.eslintrc.json +18 -18
- package/packages/atoms/README.md +7 -7
- package/packages/atoms/forms/AuthenticationTabForm/authenticationTabForm.json +224 -224
- package/packages/atoms/forms/AuthenticationTabForm/index.tsx +255 -255
- package/packages/atoms/forms/SettingsTabForm/index.tsx +85 -85
- package/packages/atoms/forms/SettingsTabForm/settingTabForm.json +27 -27
- package/packages/atoms/forms/index.ts +4 -4
- package/packages/atoms/project.json +8 -8
- package/packages/atoms/src/index.ts +33 -33
- package/packages/atoms/src/lib/Accordion/Accordion.module.css +7 -7
- package/packages/atoms/src/lib/Accordion/Accordion.spec.tsx +13 -13
- package/packages/atoms/src/lib/Accordion/Accordion.tsx +29 -29
- package/packages/atoms/src/lib/Alert/Alert.module.css +7 -7
- package/packages/atoms/src/lib/Alert/Alert.spec.tsx +10 -10
- package/packages/atoms/src/lib/Alert/Alert.tsx +19 -19
- package/packages/atoms/src/lib/Avatar/Avatar.module.css +7 -7
- package/packages/atoms/src/lib/Avatar/Avatar.spec.tsx +10 -10
- package/packages/atoms/src/lib/Avatar/Avatar.tsx +22 -22
- package/packages/atoms/src/lib/Box/Box.module.css +7 -7
- package/packages/atoms/src/lib/Box/Box.spec.tsx +10 -10
- package/packages/atoms/src/lib/Box/Box.tsx +19 -19
- package/packages/atoms/src/lib/BulkEdit/BulkEdit.module.css +7 -7
- package/packages/atoms/src/lib/BulkEdit/BulkEdit.spec.tsx +10 -10
- package/packages/atoms/src/lib/BulkEdit/BulkEdit.tsx +15 -15
- package/packages/atoms/src/lib/Button/Button.module.css +7 -7
- package/packages/atoms/src/lib/Button/Button.spec.tsx +10 -10
- package/packages/atoms/src/lib/Button/Button.tsx +78 -78
- package/packages/atoms/src/lib/Card/Card.module.css +7 -7
- package/packages/atoms/src/lib/Card/Card.spec.tsx +10 -10
- package/packages/atoms/src/lib/Card/Card.tsx +19 -19
- package/packages/atoms/src/lib/CardContent/CardContent.module.css +7 -7
- package/packages/atoms/src/lib/CardContent/CardContent.spec.tsx +10 -10
- package/packages/atoms/src/lib/CardContent/CardContent.tsx +22 -22
- package/packages/atoms/src/lib/FormTextField/FormTextField.module.css +7 -7
- package/packages/atoms/src/lib/FormTextField/FormTextField.spec.tsx +10 -10
- package/packages/atoms/src/lib/FormTextField/FormTextField.tsx +35 -35
- package/packages/atoms/src/lib/Grid/Grid.module.css +7 -7
- package/packages/atoms/src/lib/Grid/Grid.spec.tsx +10 -10
- package/packages/atoms/src/lib/Grid/Grid.tsx +19 -19
- package/packages/atoms/src/lib/Stack/Stack.module.css +7 -7
- package/packages/atoms/src/lib/Stack/Stack.spec.tsx +10 -10
- package/packages/atoms/src/lib/Stack/Stack.tsx +19 -19
- package/packages/atoms/src/lib/Switch/Switch.module.css +7 -7
- package/packages/atoms/src/lib/Switch/Switch.spec.tsx +10 -10
- package/packages/atoms/src/lib/Switch/Switch.tsx +46 -46
- package/packages/atoms/src/lib/TableView/TableView.module.css +7 -7
- package/packages/atoms/src/lib/TableView/TableView.spec.tsx +10 -10
- package/packages/atoms/src/lib/TableView/TableView.tsx +88 -88
- package/packages/atoms/src/lib/TextField/TextField.module.css +7 -7
- package/packages/atoms/src/lib/TextField/TextField.spec.tsx +10 -10
- package/packages/atoms/src/lib/TextField/TextField.tsx +17 -17
- package/packages/atoms/src/lib/Typography/Typography.module.css +7 -7
- package/packages/atoms/src/lib/Typography/Typography.spec.tsx +10 -10
- package/packages/atoms/src/lib/Typography/Typography.tsx +22 -22
- package/packages/atoms/tsconfig.json +17 -17
- package/packages/atoms/tsconfig.lib.json +30 -30
- package/packages/common/.babelrc +12 -12
- package/packages/common/.eslintrc.json +18 -18
- package/packages/common/README.md +7 -7
- package/packages/common/project.json +8 -8
- package/packages/common/src/index.ts +4 -4
- package/packages/common/src/lib/generateRandomProfilePic.ts +3 -3
- package/packages/common/src/lib/generateValidationSchema.ts +46 -46
- package/packages/common/tsconfig.json +17 -17
- package/packages/common/tsconfig.lib.json +24 -24
- package/packages/contexts/.babelrc +12 -12
- package/packages/contexts/.eslintrc.json +18 -18
- package/packages/contexts/README.md +7 -7
- package/packages/contexts/project.json +8 -8
- package/packages/contexts/src/index.ts +2 -2
- package/packages/contexts/tsconfig.json +17 -17
- package/packages/contexts/tsconfig.lib.json +24 -24
- package/packages/diagrams/.babelrc +12 -12
- package/packages/diagrams/.ctirc +208 -208
- package/packages/diagrams/.eslintrc.json +17 -17
- package/packages/diagrams/CUSTOM_ICONS.md +232 -232
- package/packages/diagrams/GOOGLE_SHEETS_IMPLEMENTATION.md +233 -233
- package/packages/diagrams/NODE_DATA_UPDATE_API.md +430 -430
- package/packages/diagrams/README.md +7 -7
- package/packages/diagrams/UNDO_REDO_API.md +306 -306
- package/packages/diagrams/locales/en/translation.json +713 -713
- package/packages/diagrams/package.json +27 -27
- package/packages/diagrams/pnpm-lock.yaml +2606 -2606
- package/packages/diagrams/project.json +42 -42
- package/packages/diagrams/rollup.config.js +26 -26
- package/packages/diagrams/src/DiagramFlow.tsx +7 -7
- package/packages/diagrams/src/declarations.d.ts +7 -7
- package/packages/diagrams/src/index.ts +8 -1
- package/packages/diagrams/src/index.ts.bak +99 -99
- package/packages/diagrams/src/lib/assets/markers/markers.param.tsx +101 -101
- package/packages/diagrams/src/lib/assets/markers/markers.type.ts +10 -10
- package/packages/diagrams/src/lib/atoms/ActorNode.tsx +123 -123
- package/packages/diagrams/src/lib/atoms/AddParallelColButton.tsx +26 -26
- package/packages/diagrams/src/lib/atoms/BendpointNode.tsx +71 -71
- package/packages/diagrams/src/lib/atoms/CardBlockTypeSelector.tsx +35 -35
- package/packages/diagrams/src/lib/atoms/CardEditableTitle.tsx +76 -76
- package/packages/diagrams/src/lib/atoms/CardMainContent.tsx +19 -19
- package/packages/diagrams/src/lib/atoms/ConnectionPoints.tsx +149 -149
- package/packages/diagrams/src/lib/atoms/ContentAssist.tsx +341 -341
- package/packages/diagrams/src/lib/atoms/DiagramControls.tsx +56 -56
- package/packages/diagrams/src/lib/atoms/ExpressionInput.tsx +437 -437
- package/packages/diagrams/src/lib/atoms/FloatingConnectionLine.tsx +73 -73
- package/packages/diagrams/src/lib/atoms/LazyIcon.tsx +31 -31
- package/packages/diagrams/src/lib/atoms/MarkerSelector.tsx +106 -106
- package/packages/diagrams/src/lib/atoms/MultiSelectInput.tsx +87 -87
- package/packages/diagrams/src/lib/atoms/ParameterInput.tsx +199 -199
- package/packages/diagrams/src/lib/atoms/PropertyInput.tsx +114 -114
- package/packages/diagrams/src/lib/atoms/StyledBox.tsx +69 -69
- package/packages/diagrams/src/lib/atoms/ValidationError.tsx +37 -37
- package/packages/diagrams/src/lib/atoms/ValidationMessage.tsx +63 -63
- package/packages/diagrams/src/lib/components/AiButton.tsx +52 -52
- package/packages/diagrams/src/lib/components/ControlEdgeList.tsx +303 -303
- package/packages/diagrams/src/lib/components/CreateFunctionModal.tsx +264 -264
- package/packages/diagrams/src/lib/components/CustomCodeModal.tsx +287 -287
- package/packages/diagrams/src/lib/components/DiagramPanel.tsx +331 -331
- package/packages/diagrams/src/lib/components/FunctionModalTooltip.tsx +30 -30
- package/packages/diagrams/src/lib/components/GraphQLCustomCodeModal.tsx +210 -210
- package/packages/diagrams/src/lib/components/Header.tsx +143 -143
- package/packages/diagrams/src/lib/components/MiniMapCommon.tsx +24 -24
- package/packages/diagrams/src/lib/components/ResizeIcon.tsx +81 -81
- package/packages/diagrams/src/lib/components/SideBar.tsx +40 -40
- package/packages/diagrams/src/lib/components/automation/AISuggestionsModal.tsx +269 -269
- package/packages/diagrams/src/lib/components/automation/AISuggestionsPanel.tsx +28 -175
- package/packages/diagrams/src/lib/components/automation/AutomationApiNode.tsx +1 -1
- package/packages/diagrams/src/lib/components/automation/AutomationDecisionNode.tsx +94 -0
- package/packages/diagrams/src/lib/components/automation/AutomationEndNode.tsx +1 -1
- package/packages/diagrams/src/lib/components/automation/AutomationExecutionPanel.tsx +439 -439
- package/packages/diagrams/src/lib/components/automation/AutomationFormattingNode.tsx +1 -1
- package/packages/diagrams/src/lib/components/automation/AutomationInteractionNode.tsx +693 -693
- package/packages/diagrams/src/lib/components/automation/AutomationMonitoringNode.tsx +399 -399
- package/packages/diagrams/src/lib/components/automation/AutomationNavigationNode.tsx +1 -1
- package/packages/diagrams/src/lib/components/automation/AutomationNodeCard.tsx +414 -0
- package/packages/diagrams/src/lib/components/automation/AutomationSlackNode.tsx +694 -694
- package/packages/diagrams/src/lib/components/automation/AutomationSmsNode.tsx +62 -0
- package/packages/diagrams/src/lib/components/automation/AutomationStartNode.tsx +1 -1
- package/packages/diagrams/src/lib/components/automation/AutomationTelegramNode.tsx +664 -664
- package/packages/diagrams/src/lib/components/automation/AutomationVoiceCallNode.tsx +65 -0
- package/packages/diagrams/src/lib/components/automation/AutomationWorkflowNode.tsx +85 -0
- package/packages/diagrams/src/lib/components/automation/NodeAIAssistantPopup.tsx +504 -504
- package/packages/diagrams/src/lib/components/automation/index.ts +29 -19
- package/packages/diagrams/src/lib/components/automation/statusColors.ts +124 -124
- package/packages/diagrams/src/lib/contexts/CardDataProvider.tsx +111 -111
- package/packages/diagrams/src/lib/contexts/DiagramProvider.tsx +392 -391
- package/packages/diagrams/src/lib/contexts/diagramStoreTypes.tsx +134 -134
- package/packages/diagrams/src/lib/contexts/onConnect.ts +39 -39
- package/packages/diagrams/src/lib/contexts/onDragStart.ts +45 -45
- package/packages/diagrams/src/lib/contexts/onNodeDragEnd.ts +179 -179
- package/packages/diagrams/src/lib/contexts/onNodesChange.ts +406 -406
- package/packages/diagrams/src/lib/contexts/onReconnect.ts +59 -59
- package/packages/diagrams/src/lib/contexts/onWorkflowNodeDelete.ts +65 -65
- package/packages/diagrams/src/lib/contexts/setContentHeight.ts +14 -14
- package/packages/diagrams/src/lib/contexts/setDiagramType.ts +10 -10
- package/packages/diagrams/src/lib/contexts/setEdgeShapeType.ts +7 -7
- package/packages/diagrams/src/lib/contexts/setEdges.ts +9 -9
- package/packages/diagrams/src/lib/contexts/setLayoutDirection.ts +9 -9
- package/packages/diagrams/src/lib/contexts/setNodeSetting.ts +17 -17
- package/packages/diagrams/src/lib/contexts/setNodes.ts +10 -10
- package/packages/diagrams/src/lib/contexts/setPannable.ts +7 -7
- package/packages/diagrams/src/lib/contexts/setSelectedEdge.ts +7 -7
- package/packages/diagrams/src/lib/contexts/setSelectedNode.ts +7 -7
- package/packages/diagrams/src/lib/contexts/undo.ts +163 -163
- package/packages/diagrams/src/lib/contexts/updateNodeSetting.ts +17 -17
- package/packages/diagrams/src/lib/examples/TwilioWhatsAppConfigExample.ts +128 -128
- package/packages/diagrams/src/lib/externals.ts +4 -4
- package/packages/diagrams/src/lib/hooks/customUseReactFlow.tsx +90 -90
- package/packages/diagrams/src/lib/hooks/updateNodes.ts +45 -45
- package/packages/diagrams/src/lib/hooks/useAddChildButton.tsx +61 -61
- package/packages/diagrams/src/lib/hooks/useAddSwitchCase.ts +75 -75
- package/packages/diagrams/src/lib/hooks/useAutoRegisterFunctions.ts +135 -135
- package/packages/diagrams/src/lib/hooks/useAutoRegisterVariables.ts +286 -286
- package/packages/diagrams/src/lib/hooks/useDeleteNodeByEvent.ts +64 -64
- package/packages/diagrams/src/lib/hooks/useDragCallbacks.tsx +122 -122
- package/packages/diagrams/src/lib/hooks/useFormValidation.ts +349 -349
- package/packages/diagrams/src/lib/hooks/useFunctionFormCallbacks.ts +136 -136
- package/packages/diagrams/src/lib/hooks/useIsSelectedNode.ts +11 -11
- package/packages/diagrams/src/lib/hooks/useModalControls.ts +13 -13
- package/packages/diagrams/src/lib/hooks/useNodeDragHandlers.ts +43 -43
- package/packages/diagrams/src/lib/hooks/useNodeSelection.ts +55 -55
- package/packages/diagrams/src/lib/hooks/useRenderDividers.tsx +19 -19
- package/packages/diagrams/src/lib/hooks/useRenderPins.tsx +74 -74
- package/packages/diagrams/src/lib/hooks/useResizeObserver.ts +21 -21
- package/packages/diagrams/src/lib/hooks/useTreeChildNode.ts +536 -536
- package/packages/diagrams/src/lib/i18n.ts +42 -42
- package/packages/diagrams/src/lib/icons/icons.tsx +324 -0
- package/packages/diagrams/src/lib/icons/index.ts +29 -0
- package/packages/diagrams/src/lib/icons/types.ts +7 -0
- package/packages/diagrams/src/lib/molecules/AddingBlock.tsx +147 -147
- package/packages/diagrams/src/lib/molecules/AvailableVariablesDisplay.tsx +57 -57
- package/packages/diagrams/src/lib/molecules/Block.tsx +143 -143
- package/packages/diagrams/src/lib/molecules/BlockProvider.tsx +28 -28
- package/packages/diagrams/src/lib/molecules/BlockWrapper.tsx +14 -14
- package/packages/diagrams/src/lib/molecules/ConditionRule.tsx +131 -131
- package/packages/diagrams/src/lib/molecules/DraggablePane.tsx +198 -198
- package/packages/diagrams/src/lib/molecules/EntityNodeBlocks.tsx +66 -66
- package/packages/diagrams/src/lib/molecules/SideHandles.tsx +215 -215
- package/packages/diagrams/src/lib/molecules/StencilItem.tsx +85 -85
- package/packages/diagrams/src/lib/molecules/WorkflowNodeActionButtons.tsx +62 -62
- package/packages/diagrams/src/lib/molecules/animated-add-button.tsx +83 -83
- package/packages/diagrams/src/lib/molecules/json-viewer.tsx +107 -107
- package/packages/diagrams/src/lib/organisms/AddNodeView.tsx +102 -102
- package/packages/diagrams/src/lib/organisms/Card/EntityNode.tsx +259 -259
- package/packages/diagrams/src/lib/organisms/Card/card.params.ts +29 -29
- package/packages/diagrams/src/lib/organisms/Card/card.types.ts +5 -5
- package/packages/diagrams/src/lib/organisms/CodeModal.tsx +105 -105
- package/packages/diagrams/src/lib/organisms/ConditionRuleGroup.tsx +138 -138
- package/packages/diagrams/src/lib/organisms/CustomEdge/EdgeMarkers.tsx +51 -51
- package/packages/diagrams/src/lib/organisms/CustomEdge/custom-edge-generator.tsx +135 -135
- package/packages/diagrams/src/lib/organisms/CustomEdge/custom-edge.params.ts +6 -6
- package/packages/diagrams/src/lib/organisms/CustomEdge/custom-edge.type.ts +15 -15
- package/packages/diagrams/src/lib/organisms/CustomEdge/useCreateBendPoint.tsx +121 -121
- package/packages/diagrams/src/lib/organisms/CustomEdge/useEdgeModal.ts +37 -37
- package/packages/diagrams/src/lib/organisms/CustomEdge/useEdgePath.tsx +99 -99
- package/packages/diagrams/src/lib/organisms/DownloadPanel.tsx +345 -345
- package/packages/diagrams/src/lib/organisms/EdgeModal.tsx +243 -243
- package/packages/diagrams/src/lib/organisms/HistoryPane.tsx +118 -118
- package/packages/diagrams/src/lib/organisms/NodeContextMenu.tsx +259 -259
- package/packages/diagrams/src/lib/organisms/PropertiesPane.tsx +276 -276
- package/packages/diagrams/src/lib/organisms/SmartDynamicForm.tsx +226 -226
- package/packages/diagrams/src/lib/organisms/Stencil.tsx +60 -60
- package/packages/diagrams/src/lib/organisms/UseDiagramStore.tsx +4 -4
- package/packages/diagrams/src/lib/organisms/WorkFlowNode/NodeActionButtons.tsx +45 -45
- package/packages/diagrams/src/lib/organisms/WorkFlowNode/NodeTypeDisplay.tsx +114 -114
- package/packages/diagrams/src/lib/organisms/WorkFlowNode/WorkflowNodeIcons.tsx +21 -23
- package/packages/diagrams/src/lib/organisms/WorkflowNode.tsx +484 -484
- package/packages/diagrams/src/lib/services/GoogleSheetsService.ts +961 -961
- package/packages/diagrams/src/lib/services/SlackService.ts +134 -134
- package/packages/diagrams/src/lib/services/TwilioWhatsAppService.ts +273 -273
- package/packages/diagrams/src/lib/styles.css +55 -55
- package/packages/diagrams/src/lib/templates/PageLinks.tsx +13 -13
- package/packages/diagrams/src/lib/templates/arch/ArchDiagram.tsx +793 -793
- package/packages/diagrams/src/lib/templates/arch/components/EdgeDialog.tsx +82 -82
- package/packages/diagrams/src/lib/templates/arch/components/EdgeSettings.tsx +81 -81
- package/packages/diagrams/src/lib/templates/arch/components/GroupControls.tsx +59 -59
- package/packages/diagrams/src/lib/templates/arch/components/GroupSizeDialog.tsx +81 -81
- package/packages/diagrams/src/lib/templates/arch/components/NodeDialog.tsx +214 -214
- package/packages/diagrams/src/lib/templates/arch/components/nodeTypes.ts +91 -91
- package/packages/diagrams/src/lib/templates/arch/controls/ArchDiagramControls.tsx +349 -349
- package/packages/diagrams/src/lib/templates/arch/data/templatee-data.ts +212 -212
- package/packages/diagrams/src/lib/templates/cloud-arch/components/CloudArchitectureDiagram.tsx +3912 -3912
- package/packages/diagrams/src/lib/templates/cloud-arch/components/FormatConverter.tsx +809 -809
- package/packages/diagrams/src/lib/templates/cloud-arch/components/FragmentImporter.tsx +276 -276
- package/packages/diagrams/src/lib/templates/cloud-arch/components/PropertiesPanel.tsx +1063 -1063
- package/packages/diagrams/src/lib/templates/cloud-arch/components/ServiceIconPicker.tsx +138 -138
- package/packages/diagrams/src/lib/templates/cloud-arch/components/SettingsSidebar.tsx +656 -656
- package/packages/diagrams/src/lib/templates/cloud-arch/components/SubnetSelector.tsx +468 -468
- package/packages/diagrams/src/lib/templates/cloud-arch/components/nodes/ServiceNode.tsx +310 -310
- package/packages/diagrams/src/lib/templates/cloud-arch/components/nodes/SubnetNode.tsx +475 -475
- package/packages/diagrams/src/lib/templates/cloud-arch/components/nodes/UsersNode.tsx +277 -277
- package/packages/diagrams/src/lib/templates/cloud-arch/data/diagramManager.ts +364 -364
- package/packages/diagrams/src/lib/templates/cloud-arch/data/types.ts +183 -183
- package/packages/diagrams/src/lib/templates/cloud-arch/integration/diagramValidator.ts +379 -379
- package/packages/diagrams/src/lib/templates/cloud-arch/messages/errorMessages.json +95 -95
- package/packages/diagrams/src/lib/templates/cloud-arch/types/localization.ts +368 -368
- package/packages/diagrams/src/lib/templates/cloud-arch/types/validation.ts +72 -72
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/aws-icons.ts +557 -557
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/awsValidation.ts +446 -446
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/azure-icons.ts +802 -802
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/azureValidation.ts +495 -495
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/cloudValidation.ts +929 -929
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/errorMessages.ts +283 -283
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/gcp-icons.ts +186 -186
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/gcpValidation.ts +312 -312
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/genericValidation.ts +689 -689
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/iconMapping.ts +383 -383
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/idGenerator.ts +220 -220
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/localizationManager.ts +300 -300
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/restrictionEngine.ts +550 -550
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/restrictionValidator.ts +400 -400
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/serviceIcons.tsx +129 -129
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/serviceMapping.ts +330 -330
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/translations.ts +54 -54
- package/packages/diagrams/src/lib/templates/cloud-arch/utils/validationExtractor.ts +342 -342
- package/packages/diagrams/src/lib/templates/collaborationDiagram/CollaborationDiagram.tsx +15 -15
- package/packages/diagrams/src/lib/templates/collaborationDiagram/components/AddCollabEdgeDialog.tsx +181 -181
- package/packages/diagrams/src/lib/templates/collaborationDiagram/components/CollabLayout.ts +182 -182
- package/packages/diagrams/src/lib/templates/collaborationDiagram/components/CollabObjectNodeSettings.tsx +86 -86
- package/packages/diagrams/src/lib/templates/collaborationDiagram/components/CollaborationDiagramFlow.tsx +731 -731
- package/packages/diagrams/src/lib/templates/collaborationDiagram/components/DraggableEdgeLabel.tsx +123 -123
- package/packages/diagrams/src/lib/templates/collaborationDiagram/controls/CollaborationControls.tsx +131 -131
- package/packages/diagrams/src/lib/templates/collaborationDiagram/nodes/CollabEdge.tsx +170 -170
- package/packages/diagrams/src/lib/templates/collaborationDiagram/nodes/CollabObjectNode.tsx +178 -178
- package/packages/diagrams/src/lib/templates/home.style.css +16 -16
- package/packages/diagrams/src/lib/templates/node-forms/ApiForm.tsx +416 -416
- package/packages/diagrams/src/lib/templates/node-forms/CallForm.tsx +370 -370
- package/packages/diagrams/src/lib/templates/node-forms/ForLoopNode.tsx +313 -313
- package/packages/diagrams/src/lib/templates/node-forms/FunctionForm.tsx +211 -211
- package/packages/diagrams/src/lib/templates/node-forms/GraphQLForm.tsx +679 -679
- package/packages/diagrams/src/lib/templates/node-forms/IfNodeForm.tsx +97 -97
- package/packages/diagrams/src/lib/templates/node-forms/LetNodeForm.tsx +533 -533
- package/packages/diagrams/src/lib/templates/node-forms/LoopNode.tsx +149 -149
- package/packages/diagrams/src/lib/templates/node-forms/NodeForm.tsx +383 -383
- package/packages/diagrams/src/lib/templates/node-forms/ReturnNodeForm.tsx +96 -96
- package/packages/diagrams/src/lib/templates/node-forms/SetNodeForm.tsx +141 -141
- package/packages/diagrams/src/lib/templates/node-forms/SwitchNodeForm.tsx +249 -249
- package/packages/diagrams/src/lib/templates/node-forms/TryCatchForm.tsx +167 -167
- package/packages/diagrams/src/lib/templates/nodeFormSchema.json +84 -84
- package/packages/diagrams/src/lib/templates/sequence/SequenceDiagram.tsx +22 -22
- package/packages/diagrams/src/lib/templates/sequence/components/ActivationBarNode.tsx +33 -33
- package/packages/diagrams/src/lib/templates/sequence/components/AddMessageDialog.tsx +302 -302
- package/packages/diagrams/src/lib/templates/sequence/components/CombinedFragmentNode.tsx +65 -65
- package/packages/diagrams/src/lib/templates/sequence/components/EntitySettings.tsx +559 -559
- package/packages/diagrams/src/lib/templates/sequence/components/FragmentSettings.tsx +116 -116
- package/packages/diagrams/src/lib/templates/sequence/components/SequenceComponents.tsx +14 -14
- package/packages/diagrams/src/lib/templates/sequence/components/SequenceDiagramFlow.tsx +1361 -1361
- package/packages/diagrams/src/lib/templates/sequence/components/SequenceEntityNode.tsx +394 -394
- package/packages/diagrams/src/lib/templates/sequence/components/SequenceMessageEdge.tsx +272 -272
- package/packages/diagrams/src/lib/templates/sequence/components/SimpleEntitySettings.tsx +89 -89
- package/packages/diagrams/src/lib/templates/sequence/controls/DiagramControls.tsx +707 -707
- package/packages/diagrams/src/lib/templates/sequence/data/template-data.ts +635 -635
- package/packages/diagrams/src/lib/templates/stateMachine/StateMachineDiagram.tsx +66 -66
- package/packages/diagrams/src/lib/templates/stateMachine/components/CompositeStateNodeSettings.tsx +638 -638
- package/packages/diagrams/src/lib/templates/stateMachine/components/CustomEdge.tsx +220 -220
- package/packages/diagrams/src/lib/templates/stateMachine/components/EdgeSettings.tsx +193 -193
- package/packages/diagrams/src/lib/templates/stateMachine/components/SelfConnectingEdge.tsx +41 -41
- package/packages/diagrams/src/lib/templates/stateMachine/components/StateMachineComponents.tsx +49 -49
- package/packages/diagrams/src/lib/templates/stateMachine/components/StateMachineDiagramFlow.tsx +1238 -1238
- package/packages/diagrams/src/lib/templates/stateMachine/components/StateMachineLayout.ts +350 -350
- package/packages/diagrams/src/lib/templates/stateMachine/components/StateNodeSettings.tsx +188 -188
- package/packages/diagrams/src/lib/templates/stateMachine/components/useSelfTransition.ts +114 -114
- package/packages/diagrams/src/lib/templates/stateMachine/controls/StateDiagramControls.tsx +488 -488
- package/packages/diagrams/src/lib/templates/stateMachine/data/template-data.ts +4 -4
- package/packages/diagrams/src/lib/templates/stateMachine/nodes/ChoicePointNode.tsx +54 -54
- package/packages/diagrams/src/lib/templates/stateMachine/nodes/CompositeStateNode.tsx +225 -225
- package/packages/diagrams/src/lib/templates/stateMachine/nodes/EntryPointNode.tsx +31 -31
- package/packages/diagrams/src/lib/templates/stateMachine/nodes/ExitPointNode.tsx +44 -44
- package/packages/diagrams/src/lib/templates/stateMachine/nodes/FinalStateNode.tsx +41 -41
- package/packages/diagrams/src/lib/templates/stateMachine/nodes/ForkJoinNode.tsx +53 -53
- package/packages/diagrams/src/lib/templates/stateMachine/nodes/HistoryStateNode.tsx +36 -36
- package/packages/diagrams/src/lib/templates/stateMachine/nodes/InitialStateNode.tsx +29 -29
- package/packages/diagrams/src/lib/templates/stateMachine/nodes/JunctionPointNode.tsx +33 -33
- package/packages/diagrams/src/lib/templates/stateMachine/nodes/PinPointNode.tsx +111 -111
- package/packages/diagrams/src/lib/templates/stateMachine/nodes/StateNode.tsx +124 -124
- package/packages/diagrams/src/lib/templates/stateMachine/nodes/bendPoint.tsx +71 -71
- package/packages/diagrams/src/lib/templates/systemFlow/SystemFlowDiagram.tsx +67 -67
- package/packages/diagrams/src/lib/templates/systemFlow/components/EdgeSettings.tsx +330 -330
- package/packages/diagrams/src/lib/templates/systemFlow/components/FloatingEdge.tsx +219 -219
- package/packages/diagrams/src/lib/templates/systemFlow/components/SystemFlowComponents.tsx +28 -28
- package/packages/diagrams/src/lib/templates/systemFlow/components/SystemFlowDiagramFlow.tsx +1179 -1179
- package/packages/diagrams/src/lib/templates/systemFlow/components/SystemFlowNodeSettings.tsx +151 -151
- package/packages/diagrams/src/lib/templates/systemFlow/controls/SystemFlowControls.tsx +435 -435
- package/packages/diagrams/src/lib/templates/systemFlow/data/template-data.ts +308 -308
- package/packages/diagrams/src/lib/templates/systemFlow/demo.tsx +91 -91
- package/packages/diagrams/src/lib/templates/systemFlow/index.ts +5 -5
- package/packages/diagrams/src/lib/templates/systemFlow/nodes/BendpointNode.tsx +80 -80
- package/packages/diagrams/src/lib/templates/systemFlow/nodes/SystemNode.tsx +92 -92
- package/packages/diagrams/src/lib/templates/systemFlow/nodes/TreeSystemNode.tsx +755 -755
- package/packages/diagrams/src/lib/templates/useCaseDiagram/UseCaseDiagram.tsx +16 -16
- package/packages/diagrams/src/lib/templates/useCaseDiagram/components/ActorNodeSettings.tsx +103 -103
- package/packages/diagrams/src/lib/templates/useCaseDiagram/components/AddRelationshipDialog.tsx +186 -186
- package/packages/diagrams/src/lib/templates/useCaseDiagram/components/PackageNodeSettings.tsx +205 -205
- package/packages/diagrams/src/lib/templates/useCaseDiagram/components/UseCaseDiagramFlow.tsx +637 -637
- package/packages/diagrams/src/lib/templates/useCaseDiagram/components/UseCaseNodeSettings.tsx +120 -120
- package/packages/diagrams/src/lib/templates/useCaseDiagram/controls/UseCaseControls.tsx +289 -289
- package/packages/diagrams/src/lib/templates/useCaseDiagram/nodes/PackageNode.tsx +83 -83
- package/packages/diagrams/src/lib/templates/useCaseDiagram/nodes/UseCaseEdge.tsx +115 -115
- package/packages/diagrams/src/lib/templates/useCaseDiagram/nodes/UseCaseNode.tsx +230 -230
- package/packages/diagrams/src/lib/templates/validationSchema.json +277 -277
- package/packages/diagrams/src/lib/theme.ts +439 -439
- package/packages/diagrams/src/lib/types/FunctionSignature.ts +11 -11
- package/packages/diagrams/src/lib/types/SmartDynamicFormField.ts +37 -37
- package/packages/diagrams/src/lib/types/automation-node-data-types.ts +45 -131
- package/packages/diagrams/src/lib/types/available-variables.ts +18 -18
- package/packages/diagrams/src/lib/types/card-node.ts +68 -68
- package/packages/diagrams/src/lib/types/collaboration-types.ts +114 -114
- package/packages/diagrams/src/lib/types/colors.ts +25 -25
- package/packages/diagrams/src/lib/types/condition-builder.ts +18 -18
- package/packages/diagrams/src/lib/types/diagram-types.ts +14 -14
- package/packages/diagrams/src/lib/types/edge-types.ts +39 -39
- package/packages/diagrams/src/lib/types/function-execution.ts +35 -35
- package/packages/diagrams/src/lib/types/hooks.types.ts +6 -6
- package/packages/diagrams/src/lib/types/ndoe-form-types.ts +139 -139
- package/packages/diagrams/src/lib/types/node-types.ts +13 -23
- package/packages/diagrams/src/lib/types/sequence-types.ts +178 -178
- package/packages/diagrams/src/lib/types/shared-node-types.ts +21 -21
- package/packages/diagrams/src/lib/types/state-machine-types.ts +225 -225
- package/packages/diagrams/src/lib/types/stencil-item.ts +7 -7
- package/packages/diagrams/src/lib/types/structures.ts +80 -80
- package/packages/diagrams/src/lib/types/system-flow-types.ts +129 -129
- package/packages/diagrams/src/lib/types/usecase-types.ts +84 -84
- package/packages/diagrams/src/lib/types/validation-types.ts +134 -134
- package/packages/diagrams/src/lib/types/workflow-content-dynamic-form-type.ts +23 -23
- package/packages/diagrams/src/lib/types/workflow-node-data-types.ts +172 -172
- package/packages/diagrams/src/lib/utils/AutomationExecutionEngine.ts +658 -1179
- package/packages/diagrams/src/lib/utils/add-new-block.ts +34 -34
- package/packages/diagrams/src/lib/utils/add-new-node.ts +52 -52
- package/packages/diagrams/src/lib/utils/addToHistory.ts +15 -15
- package/packages/diagrams/src/lib/utils/automation-flow-processor.ts +556 -619
- package/packages/diagrams/src/lib/utils/closestPoint.ts +45 -45
- package/packages/diagrams/src/lib/utils/color-options.tsx +26 -26
- package/packages/diagrams/src/lib/utils/compress-img.ts +59 -59
- package/packages/diagrams/src/lib/utils/configLoader.ts +329 -329
- package/packages/diagrams/src/lib/utils/constant-lengths.ts +8 -8
- package/packages/diagrams/src/lib/utils/create-updated.tsx +40 -40
- package/packages/diagrams/src/lib/utils/createHistoryChange.ts +3 -3
- package/packages/diagrams/src/lib/utils/dividerUtils.tsx +59 -59
- package/packages/diagrams/src/lib/utils/edge-hooks.ts +53 -53
- package/packages/diagrams/src/lib/utils/elkLayout.ts +297 -297
- package/packages/diagrams/src/lib/utils/event-hooks.ts +69 -69
- package/packages/diagrams/src/lib/utils/event-store.ts +58 -58
- package/packages/diagrams/src/lib/utils/flow-node-hooks.ts +28 -28
- package/packages/diagrams/src/lib/utils/flow-to-js.ts +1465 -1465
- package/packages/diagrams/src/lib/utils/functionGenerator.ts +38 -38
- package/packages/diagrams/src/lib/utils/generateEdgesFromNodeOrder.ts +113 -113
- package/packages/diagrams/src/lib/utils/helpers.types.ts +10 -10
- package/packages/diagrams/src/lib/utils/highlightText.tsx +93 -93
- package/packages/diagrams/src/lib/utils/iconMapper.tsx +76 -76
- package/packages/diagrams/src/lib/utils/logger.ts +5 -5
- package/packages/diagrams/src/lib/utils/model-hooks.ts +129 -129
- package/packages/diagrams/src/lib/utils/node-hooks.ts +78 -78
- package/packages/diagrams/src/lib/utils/nodeAIAssistantConfig.ts +54 -54
- package/packages/diagrams/src/lib/utils/nodeOrderByEdges.ts +437 -437
- package/packages/diagrams/src/lib/utils/nodeutils.ts +242 -242
- package/packages/diagrams/src/lib/utils/object.ts +13 -13
- package/packages/diagrams/src/lib/utils/useDebounce.ts +19 -19
- package/packages/diagrams/src/lib/utils/utilities.ts +105 -105
- package/packages/diagrams/src/lib/utils/validationEngine.ts +610 -610
- package/packages/diagrams/src/lib/utils/vhToPixels.ts +9 -9
- package/packages/diagrams/tsconfig.json +21 -21
- package/packages/diagrams/tsconfig.lib.json +26 -25
- package/packages/diagrams/webpack.config.js +17 -17
- package/packages/interfaces/.babelrc +12 -12
- package/packages/interfaces/.eslintrc.json +18 -18
- package/packages/interfaces/README.md +7 -7
- package/packages/interfaces/project.json +8 -8
- package/packages/interfaces/src/index.ts +21 -21
- package/packages/interfaces/src/lib/Button.tsx +1 -1
- package/packages/interfaces/src/lib/DataGrid.ts +14 -14
- package/packages/interfaces/src/lib/StyledBox.tsx +1 -1
- package/packages/interfaces/src/lib/ToolbarItem.ts +7 -7
- package/packages/interfaces/src/lib/UserCard.ts +8 -8
- package/packages/interfaces/src/lib/yup.ts +3 -3
- package/packages/interfaces/tsconfig.json +17 -17
- package/packages/interfaces/tsconfig.lib.json +24 -24
- package/packages/molecules/.babelrc +12 -12
- package/packages/molecules/.eslintrc.json +18 -18
- package/packages/molecules/README.md +7 -7
- package/packages/molecules/project.json +8 -8
- package/packages/molecules/src/index.ts +47 -41
- package/packages/molecules/src/lib/ActionTextField/ActionTextField.module.css +7 -7
- package/packages/molecules/src/lib/ActionTextField/ActionTextField.spec.tsx +10 -10
- package/packages/molecules/src/lib/ActionTextField/ActionTextField.tsx +33 -33
- package/packages/molecules/src/lib/ClosableButton/CloseableButton.module.css +7 -7
- package/packages/molecules/src/lib/ClosableButton/CloseableButton.spec.tsx +11 -11
- package/packages/molecules/src/lib/ClosableButton/CloseableButton.tsx +69 -69
- package/packages/molecules/src/lib/EditorTab/EditorTab.module.css +7 -7
- package/packages/molecules/src/lib/EditorTab/EditorTab.spec.tsx +10 -10
- package/packages/molecules/src/lib/EditorTab/EditorTab.tsx +42 -42
- package/packages/molecules/src/lib/EditorTab/TabPanel.tsx +25 -25
- package/packages/molecules/src/lib/ParamsActionField/ParamsActionField.module.css +7 -7
- package/packages/molecules/src/lib/ParamsActionField/ParamsActionField.spec.tsx +10 -10
- package/packages/molecules/src/lib/ParamsActionField/ParamsActionField.tsx +24 -24
- package/packages/molecules/src/lib/SvgIcons/icons.tsx +323 -291
- package/packages/molecules/src/lib/SvgIcons/index.ts +31 -25
- package/packages/molecules/src/lib/SvgIcons/types.ts +7 -7
- package/packages/molecules/src/lib/TableWithInlineView/TableWithInlineView.module.css +7 -7
- package/packages/molecules/src/lib/TableWithInlineView/TableWithInlineView.spec.tsx +10 -10
- package/packages/molecules/src/lib/TableWithInlineView/TableWithInlineView.tsx +47 -47
- package/packages/molecules/src/lib/UserCard/UserCard.module.css +7 -7
- package/packages/molecules/src/lib/UserCard/UserCard.spec.tsx +11 -11
- package/packages/molecules/src/lib/UserCard/UserCard.tsx +22 -22
- package/packages/molecules/src/lib/VerbSelection/HTTPVerbSelection.module.css +7 -7
- package/packages/molecules/src/lib/VerbSelection/HTTPVerbSelection.spec.tsx +10 -10
- package/packages/molecules/src/lib/VerbSelection/HTTPVerbSelection.tsx +72 -72
- package/packages/molecules/tsconfig.json +17 -17
- package/packages/molecules/tsconfig.lib.json +30 -30
- package/packages/organisms/.babelrc +12 -12
- package/packages/organisms/.eslintrc.json +18 -18
- package/packages/organisms/README.md +7 -7
- package/packages/organisms/project.json +8 -8
- package/packages/organisms/src/index.ts +4 -4
- package/packages/organisms/src/lib/EditorToolbar/EditorToolbar.module.css +7 -7
- package/packages/organisms/src/lib/EditorToolbar/EditorToolbar.spec.tsx +10 -10
- package/packages/organisms/src/lib/EditorToolbar/EditorToolbar.tsx +117 -117
- package/packages/organisms/src/lib/EditorToolbar/SortableItem.tsx +51 -51
- package/packages/organisms/src/lib/UserList/UserList.module.css +7 -7
- package/packages/organisms/src/lib/UserList/UserList.spec.tsx +11 -11
- package/packages/organisms/src/lib/UserList/UserList.tsx +48 -48
- package/packages/organisms/src/lib/UserList/store.ts +49 -49
- package/packages/organisms/tsconfig.json +17 -17
- package/packages/organisms/tsconfig.lib.json +24 -24
- package/packages/zustand/.babelrc +12 -12
- package/packages/zustand/.eslintrc.json +18 -18
- package/packages/zustand/README.md +7 -7
- package/packages/zustand/project.json +8 -8
- package/packages/zustand/src/index.ts +4 -4
- package/packages/zustand/tsconfig.json +17 -17
- package/packages/zustand/tsconfig.lib.json +24 -24
- package/tsconfig.base.json +29 -29
- package/packages/diagrams/src/lib/components/automation/AutomationAISuggestionNode.tsx +0 -304
- package/packages/diagrams/src/lib/components/automation/AutomationEmailNode.tsx +0 -773
- package/packages/diagrams/src/lib/components/automation/AutomationGoogleServicesNode.tsx +0 -779
- package/packages/diagrams/src/lib/components/automation/AutomationNoteNode.tsx +0 -422
- package/packages/diagrams/src/lib/components/automation/AutomationSheetsNode.tsx +0 -1135
- package/packages/diagrams/src/lib/examples/GoogleSheetsConfigurationExamples.ts +0 -306
|
@@ -1,793 +1,793 @@
|
|
|
1
|
-
import { useCallback, useState, useEffect } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
ReactFlow,
|
|
4
|
-
addEdge,
|
|
5
|
-
Background,
|
|
6
|
-
useNodesState,
|
|
7
|
-
useEdgesState,
|
|
8
|
-
Controls,
|
|
9
|
-
Connection,
|
|
10
|
-
Edge,
|
|
11
|
-
Panel,
|
|
12
|
-
Node,
|
|
13
|
-
useReactFlow,
|
|
14
|
-
ReactFlowProvider,
|
|
15
|
-
MarkerType,
|
|
16
|
-
} from '@xyflow/react';
|
|
17
|
-
import { Box, Button, Paper, ClickAwayListener } from '@mui/material';
|
|
18
|
-
import UndoIcon from '@mui/icons-material/Undo';
|
|
19
|
-
import RedoIcon from '@mui/icons-material/Redo';
|
|
20
|
-
import DownloadIcon from '@mui/icons-material/Download';
|
|
21
|
-
import UploadIcon from '@mui/icons-material/Upload';
|
|
22
|
-
|
|
23
|
-
import NodeDialog from './components/NodeDialog';
|
|
24
|
-
import EdgeSettings from './components/EdgeSettings';
|
|
25
|
-
import GroupSizeDialog from './components/GroupSizeDialog';
|
|
26
|
-
import ArchDiagramControls from './controls/ArchDiagramControls';
|
|
27
|
-
|
|
28
|
-
import '@xyflow/react/dist/style.css';
|
|
29
|
-
import {
|
|
30
|
-
eventDrivenTemplate,
|
|
31
|
-
microservicesTemplate,
|
|
32
|
-
nodeColors,
|
|
33
|
-
threeTierTemplate,
|
|
34
|
-
} from './data/templatee-data';
|
|
35
|
-
import {
|
|
36
|
-
animatedEdgeStyle,
|
|
37
|
-
defaultEdgeStyle,
|
|
38
|
-
EdgeData,
|
|
39
|
-
edgeStyles,
|
|
40
|
-
NodeData,
|
|
41
|
-
nodeTypes,
|
|
42
|
-
NodeTypes,
|
|
43
|
-
} from './components/nodeTypes';
|
|
44
|
-
|
|
45
|
-
const ArchDiagramInner = ({
|
|
46
|
-
archNodes,
|
|
47
|
-
archEdges,
|
|
48
|
-
}: {
|
|
49
|
-
archNodes: Node<NodeData>[];
|
|
50
|
-
archEdges: Edge<EdgeData>[];
|
|
51
|
-
}) => {
|
|
52
|
-
const [nodes, setNodes, onNodesChange] = useNodesState<Node<NodeData>>([]);
|
|
53
|
-
const [edges, setEdges, onEdgesChange] = useEdgesState<Edge<EdgeData>>([]);
|
|
54
|
-
const [history, setHistory] = useState<
|
|
55
|
-
{ nodes: Node<NodeData>[]; edges: Edge<EdgeData>[] }[]
|
|
56
|
-
>([{ nodes: [], edges: [] }]);
|
|
57
|
-
const [historyIndex, setHistoryIndex] = useState(0);
|
|
58
|
-
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
|
59
|
-
const [selectedNode, setSelectedNode] = useState<Node<NodeData> | null>(null);
|
|
60
|
-
const [newNodeType, setNewNodeType] = useState<keyof NodeTypes>('service');
|
|
61
|
-
const [newNodeLabel, setNewNodeLabel] = useState('');
|
|
62
|
-
const [selectedColor, setSelectedColor] = useState<string>('blue');
|
|
63
|
-
const [groupWidth, setGroupWidth] = useState(600);
|
|
64
|
-
const [groupHeight, setGroupHeight] = useState(200);
|
|
65
|
-
const [selectedEdge, setSelectedEdge] = useState<Edge<EdgeData> | null>(null);
|
|
66
|
-
const [edgeLabel, setEdgeLabel] = useState('');
|
|
67
|
-
const [isEdgeAnimated, setIsEdgeAnimated] = useState(false);
|
|
68
|
-
const [isInitialized, setIsInitialized] = useState(false);
|
|
69
|
-
|
|
70
|
-
const { getNodes, getViewport } = useReactFlow();
|
|
71
|
-
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
if (archNodes && archEdges) {
|
|
74
|
-
// Ensure nodes have valid positions and styles
|
|
75
|
-
const validNodes = archNodes.map(node => {
|
|
76
|
-
// Handle different node types
|
|
77
|
-
const nodeType = node.type;
|
|
78
|
-
|
|
79
|
-
let nodeStyle;
|
|
80
|
-
if (nodeType === 'subnetNode') {
|
|
81
|
-
nodeStyle = {
|
|
82
|
-
backgroundColor: node.data?.color || 'transparent',
|
|
83
|
-
border: `1px solid ${node.data?.borderColor || '#777'}`,
|
|
84
|
-
borderRadius: '8px',
|
|
85
|
-
padding: '20px',
|
|
86
|
-
width: node.data?.width || 500,
|
|
87
|
-
height: node.data?.height || 250,
|
|
88
|
-
zIndex: node.style?.zIndex || 1,
|
|
89
|
-
} as const;
|
|
90
|
-
} else if (nodeType === 'serviceNode') {
|
|
91
|
-
nodeStyle = {
|
|
92
|
-
backgroundColor: node.data?.color || nodeColors.blue,
|
|
93
|
-
border: '1px solid #777',
|
|
94
|
-
borderRadius: '8px',
|
|
95
|
-
padding: '10px',
|
|
96
|
-
width: 130,
|
|
97
|
-
height: 80,
|
|
98
|
-
zIndex: node.style?.zIndex || 2,
|
|
99
|
-
} as const;
|
|
100
|
-
} else {
|
|
101
|
-
nodeStyle = {
|
|
102
|
-
backgroundColor: node.data?.color || nodeColors.blue,
|
|
103
|
-
border: '1px solid #777',
|
|
104
|
-
borderRadius: '8px',
|
|
105
|
-
padding: '10px',
|
|
106
|
-
width: node.style?.width || 130,
|
|
107
|
-
height: node.style?.height || 80,
|
|
108
|
-
zIndex: node.style?.zIndex || 1,
|
|
109
|
-
} as const;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return {
|
|
113
|
-
...node,
|
|
114
|
-
position: node.position || { x: 0, y: 0 },
|
|
115
|
-
style: nodeStyle as React.CSSProperties,
|
|
116
|
-
data: {
|
|
117
|
-
...node.data,
|
|
118
|
-
label: node.data?.label || 'New Node',
|
|
119
|
-
}
|
|
120
|
-
} as Node<NodeData>;
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// Ensure edges have proper styling
|
|
124
|
-
const validEdges = archEdges.map(edge => {
|
|
125
|
-
const edgeStyle = {
|
|
126
|
-
stroke: edge.style?.stroke || '#555',
|
|
127
|
-
strokeWidth: edge.style?.strokeWidth || 2,
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
...edge,
|
|
132
|
-
type: edge.type || 'smoothstep',
|
|
133
|
-
animated: edge.animated || false,
|
|
134
|
-
style: edgeStyle,
|
|
135
|
-
markerEnd: {
|
|
136
|
-
type: MarkerType.ArrowClosed,
|
|
137
|
-
width: 20,
|
|
138
|
-
height: 20,
|
|
139
|
-
color: edgeStyle.stroke,
|
|
140
|
-
},
|
|
141
|
-
} as Edge<EdgeData>;
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
setNodes(validNodes);
|
|
145
|
-
setEdges(validEdges);
|
|
146
|
-
setHistory([{ nodes: validNodes, edges: validEdges }]);
|
|
147
|
-
setIsInitialized(true);
|
|
148
|
-
}
|
|
149
|
-
}, [archNodes, archEdges]);
|
|
150
|
-
|
|
151
|
-
const findCenterPosition = useCallback(() => {
|
|
152
|
-
// Default center position
|
|
153
|
-
const defaultPosition = {
|
|
154
|
-
x: window.innerWidth / 2,
|
|
155
|
-
y: window.innerHeight / 2,
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
if (!isInitialized) {
|
|
159
|
-
return defaultPosition;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
try {
|
|
163
|
-
const viewport = getViewport();
|
|
164
|
-
if (
|
|
165
|
-
!viewport ||
|
|
166
|
-
typeof viewport.x === 'undefined' ||
|
|
167
|
-
typeof viewport.y === 'undefined' ||
|
|
168
|
-
typeof viewport.zoom === 'undefined'
|
|
169
|
-
) {
|
|
170
|
-
return defaultPosition;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const centerX =
|
|
174
|
-
-viewport.x / viewport.zoom + window.innerWidth / (2 * viewport.zoom);
|
|
175
|
-
const centerY =
|
|
176
|
-
-viewport.y / viewport.zoom + window.innerHeight / (2 * viewport.zoom);
|
|
177
|
-
|
|
178
|
-
const existingNodes = getNodes();
|
|
179
|
-
if (!existingNodes || existingNodes.length === 0) {
|
|
180
|
-
return { x: centerX, y: centerY };
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const centerThreshold = 100;
|
|
184
|
-
const centeredNodes = existingNodes.filter((node) => {
|
|
185
|
-
if (
|
|
186
|
-
!node ||
|
|
187
|
-
!node.position ||
|
|
188
|
-
typeof node.position.x === 'undefined' ||
|
|
189
|
-
typeof node.position.y === 'undefined'
|
|
190
|
-
) {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
const dx = Math.abs(node.position.x - centerX);
|
|
194
|
-
const dy = Math.abs(node.position.y - centerY);
|
|
195
|
-
return dx < centerThreshold && dy < centerThreshold;
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
if (centeredNodes.length > 0) {
|
|
199
|
-
const leftmostX = Math.min(
|
|
200
|
-
...centeredNodes.map((node) => node.position?.x || 0),
|
|
201
|
-
);
|
|
202
|
-
return {
|
|
203
|
-
x: leftmostX - 200,
|
|
204
|
-
y: centerY,
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return { x: centerX, y: centerY };
|
|
209
|
-
} catch (error) {
|
|
210
|
-
console.error('Error calculating center position:', error);
|
|
211
|
-
return defaultPosition;
|
|
212
|
-
}
|
|
213
|
-
}, [getViewport, getNodes, isInitialized]);
|
|
214
|
-
|
|
215
|
-
const onConnect = useCallback(
|
|
216
|
-
(connection: Connection) => {
|
|
217
|
-
const newEdge = {
|
|
218
|
-
...connection,
|
|
219
|
-
id: `edge-${Date.now()}`,
|
|
220
|
-
...(isEdgeAnimated ? animatedEdgeStyle : edgeStyles),
|
|
221
|
-
type: 'smoothstep',
|
|
222
|
-
label: '',
|
|
223
|
-
labelStyle: {
|
|
224
|
-
...defaultEdgeStyle.labelStyle,
|
|
225
|
-
display: edgeLabel ? 'block' : 'none',
|
|
226
|
-
},
|
|
227
|
-
labelBgStyle: defaultEdgeStyle.labelBgStyle,
|
|
228
|
-
};
|
|
229
|
-
setEdges((eds) => addEdge(newEdge as Edge<EdgeData>, eds));
|
|
230
|
-
},
|
|
231
|
-
[isEdgeAnimated, edgeLabel],
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
const toggleEdgeAnimation = useCallback((edgeId: string) => {
|
|
235
|
-
setEdges((eds) =>
|
|
236
|
-
eds.map((edge) => {
|
|
237
|
-
if (edge.id === edgeId) {
|
|
238
|
-
const isCurrentlyAnimated = edge.animated;
|
|
239
|
-
return {
|
|
240
|
-
...edge,
|
|
241
|
-
...(isCurrentlyAnimated ? edgeStyles : animatedEdgeStyle),
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
return edge;
|
|
245
|
-
}),
|
|
246
|
-
);
|
|
247
|
-
}, []);
|
|
248
|
-
|
|
249
|
-
const onDragOver = useCallback((event: React.DragEvent) => {
|
|
250
|
-
event.preventDefault();
|
|
251
|
-
event.dataTransfer.dropEffect = 'move';
|
|
252
|
-
}, []);
|
|
253
|
-
|
|
254
|
-
const handleGroupSizeChange = useCallback(
|
|
255
|
-
(width: number, height: number) => {
|
|
256
|
-
if (!selectedNode?.data?.isGroup) return;
|
|
257
|
-
|
|
258
|
-
setGroupWidth(width);
|
|
259
|
-
setGroupHeight(height);
|
|
260
|
-
|
|
261
|
-
setNodes((nds) =>
|
|
262
|
-
nds.map((node) =>
|
|
263
|
-
node.id === selectedNode.id
|
|
264
|
-
? {
|
|
265
|
-
...node,
|
|
266
|
-
style: {
|
|
267
|
-
...node.style,
|
|
268
|
-
width,
|
|
269
|
-
height,
|
|
270
|
-
},
|
|
271
|
-
}
|
|
272
|
-
: node,
|
|
273
|
-
),
|
|
274
|
-
);
|
|
275
|
-
},
|
|
276
|
-
[selectedNode, setNodes],
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
const onNodeClick = (event: React.MouseEvent, node: Node<NodeData>) => {
|
|
280
|
-
if ((event.target as HTMLElement).classList.contains('nodrag')) {
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
setSelectedNode(node);
|
|
285
|
-
setNewNodeLabel(node.data?.label || '');
|
|
286
|
-
|
|
287
|
-
if (!node.data?.isGroup) {
|
|
288
|
-
setIsDialogOpen(true);
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
const handleAddGroupNode = () => {
|
|
293
|
-
const position = findCenterPosition();
|
|
294
|
-
|
|
295
|
-
const newNode = {
|
|
296
|
-
id: `group-${Date.now()}`,
|
|
297
|
-
type: 'group',
|
|
298
|
-
data: {
|
|
299
|
-
label: newNodeLabel || 'New Group',
|
|
300
|
-
isGroup: true,
|
|
301
|
-
},
|
|
302
|
-
position,
|
|
303
|
-
style: {
|
|
304
|
-
width: groupWidth,
|
|
305
|
-
height: groupHeight,
|
|
306
|
-
backgroundColor: 'rgba(240, 240, 240, 0.5)',
|
|
307
|
-
border: '1px dashed #777',
|
|
308
|
-
borderRadius: '8px',
|
|
309
|
-
padding: '20px',
|
|
310
|
-
zIndex: -1,
|
|
311
|
-
},
|
|
312
|
-
selectable: true,
|
|
313
|
-
draggable: true,
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
const groupNode = newNode as Node<NodeData>;
|
|
317
|
-
setNodes((nds) => [...nds, groupNode]);
|
|
318
|
-
setNewNodeLabel('');
|
|
319
|
-
setIsDialogOpen(false);
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
useEffect(() => {
|
|
323
|
-
setNodes((nds) =>
|
|
324
|
-
nds.map((node) => {
|
|
325
|
-
if (node.data?.isGroup) {
|
|
326
|
-
return {
|
|
327
|
-
...node,
|
|
328
|
-
style: {
|
|
329
|
-
...node.style,
|
|
330
|
-
zIndex: -1,
|
|
331
|
-
},
|
|
332
|
-
draggable: true,
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
return node;
|
|
336
|
-
}),
|
|
337
|
-
);
|
|
338
|
-
}, []);
|
|
339
|
-
|
|
340
|
-
const handleAddNode = (type: string, color: string) => {
|
|
341
|
-
const nodeInfo = nodeTypes[type as keyof NodeTypes];
|
|
342
|
-
const position = findCenterPosition();
|
|
343
|
-
|
|
344
|
-
const newNode = {
|
|
345
|
-
id: `${type}-${Date.now()}`,
|
|
346
|
-
type,
|
|
347
|
-
data: { label: `New ${nodeInfo.label}` },
|
|
348
|
-
position,
|
|
349
|
-
draggable: true,
|
|
350
|
-
style: {
|
|
351
|
-
background: color,
|
|
352
|
-
border: '1px solid #777',
|
|
353
|
-
borderRadius: '8px',
|
|
354
|
-
padding: '10px',
|
|
355
|
-
width: 130,
|
|
356
|
-
},
|
|
357
|
-
};
|
|
358
|
-
setNodes((nds) => [...nds, newNode as Node<NodeData>]);
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
const handleAddChildNode = (parentId: string) => {
|
|
362
|
-
const parent = nodes.find((node) => node.id === parentId);
|
|
363
|
-
if (!parent || !parent.data?.isGroup) return;
|
|
364
|
-
|
|
365
|
-
// Calculate position relative to parent
|
|
366
|
-
const childPosition = {
|
|
367
|
-
x: parent.position.x + 50,
|
|
368
|
-
y: parent.position.y + 50,
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
const newNode = {
|
|
372
|
-
id: `service-${Date.now()}`,
|
|
373
|
-
type: 'service',
|
|
374
|
-
data: {
|
|
375
|
-
label: 'New Service',
|
|
376
|
-
parentId: parentId,
|
|
377
|
-
},
|
|
378
|
-
position: childPosition,
|
|
379
|
-
draggable: true,
|
|
380
|
-
style: {
|
|
381
|
-
background: nodeColors.blue,
|
|
382
|
-
border: '1px solid #777',
|
|
383
|
-
borderRadius: '8px',
|
|
384
|
-
padding: '10px',
|
|
385
|
-
width: 130,
|
|
386
|
-
},
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
setNodes((nds) => [...nds, newNode as Node<NodeData>]);
|
|
390
|
-
setIsDialogOpen(false);
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
const handleUpdateLabel = () => {
|
|
394
|
-
if (!selectedNode) return;
|
|
395
|
-
|
|
396
|
-
setNodes((nds) =>
|
|
397
|
-
nds.map((node) =>
|
|
398
|
-
node.id === selectedNode.id
|
|
399
|
-
? { ...node, data: { ...node.data, label: newNodeLabel } }
|
|
400
|
-
: node,
|
|
401
|
-
),
|
|
402
|
-
);
|
|
403
|
-
setIsDialogOpen(false);
|
|
404
|
-
};
|
|
405
|
-
|
|
406
|
-
const onEdgeClick = useCallback(
|
|
407
|
-
(event: React.MouseEvent, edge: Edge<EdgeData>) => {
|
|
408
|
-
event.preventDefault();
|
|
409
|
-
if (event.shiftKey) {
|
|
410
|
-
// Toggle animation when clicking with shift key
|
|
411
|
-
toggleEdgeAnimation(edge.id);
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
setSelectedEdge(edge);
|
|
415
|
-
setEdgeLabel(String(edge.label || edge.data?.label || ''));
|
|
416
|
-
setIsEdgeAnimated(!!edge.animated);
|
|
417
|
-
},
|
|
418
|
-
[toggleEdgeAnimation],
|
|
419
|
-
);
|
|
420
|
-
|
|
421
|
-
const handleEdgeUpdate = useCallback(() => {
|
|
422
|
-
if (!selectedEdge) return;
|
|
423
|
-
|
|
424
|
-
setEdges((eds) =>
|
|
425
|
-
eds.map((edge) => {
|
|
426
|
-
if (edge.id === selectedEdge.id) {
|
|
427
|
-
const updatedEdge = {
|
|
428
|
-
...edge,
|
|
429
|
-
label: edgeLabel || '',
|
|
430
|
-
data: {
|
|
431
|
-
...edge.data,
|
|
432
|
-
label: edgeLabel || '',
|
|
433
|
-
} as EdgeData,
|
|
434
|
-
style: {
|
|
435
|
-
...(edge.animated ? animatedEdgeStyle.style : edgeStyles.style),
|
|
436
|
-
},
|
|
437
|
-
labelStyle: {
|
|
438
|
-
...defaultEdgeStyle.labelStyle,
|
|
439
|
-
display: edgeLabel ? 'block' : 'none',
|
|
440
|
-
},
|
|
441
|
-
labelBgStyle: defaultEdgeStyle.labelBgStyle,
|
|
442
|
-
};
|
|
443
|
-
return updatedEdge;
|
|
444
|
-
}
|
|
445
|
-
return edge;
|
|
446
|
-
}),
|
|
447
|
-
);
|
|
448
|
-
setSelectedEdge(null);
|
|
449
|
-
setEdgeLabel('');
|
|
450
|
-
}, [selectedEdge, edgeLabel]);
|
|
451
|
-
|
|
452
|
-
const handleLoadTemplate = useCallback((templateType: string) => {
|
|
453
|
-
let template;
|
|
454
|
-
switch (templateType) {
|
|
455
|
-
case 'microservices':
|
|
456
|
-
template = microservicesTemplate;
|
|
457
|
-
break;
|
|
458
|
-
case 'three-tier':
|
|
459
|
-
template = threeTierTemplate;
|
|
460
|
-
break;
|
|
461
|
-
case 'event-driven':
|
|
462
|
-
template = eventDrivenTemplate;
|
|
463
|
-
break;
|
|
464
|
-
default:
|
|
465
|
-
return;
|
|
466
|
-
}
|
|
467
|
-
setNodes(template.nodes as Node<NodeData>[]);
|
|
468
|
-
setEdges(template.edges as Edge<EdgeData>[]);
|
|
469
|
-
}, []);
|
|
470
|
-
|
|
471
|
-
// Handle undo
|
|
472
|
-
const handleUndo = useCallback(() => {
|
|
473
|
-
if (historyIndex > 0) {
|
|
474
|
-
const newIndex = historyIndex - 1;
|
|
475
|
-
const previousState = history[newIndex];
|
|
476
|
-
setNodes(previousState.nodes);
|
|
477
|
-
setEdges(previousState.edges);
|
|
478
|
-
setHistoryIndex(newIndex);
|
|
479
|
-
}
|
|
480
|
-
}, [history, historyIndex]);
|
|
481
|
-
|
|
482
|
-
// Handle redo
|
|
483
|
-
const handleRedo = useCallback(() => {
|
|
484
|
-
if (historyIndex < history.length - 1) {
|
|
485
|
-
const newIndex = historyIndex + 1;
|
|
486
|
-
const nextState = history[newIndex];
|
|
487
|
-
setNodes(nextState.nodes);
|
|
488
|
-
setEdges(nextState.edges);
|
|
489
|
-
setHistoryIndex(newIndex);
|
|
490
|
-
}
|
|
491
|
-
}, [history, historyIndex]);
|
|
492
|
-
|
|
493
|
-
// Export diagram
|
|
494
|
-
const exportDiagram = useCallback(() => {
|
|
495
|
-
const diagramData = {
|
|
496
|
-
nodes,
|
|
497
|
-
edges,
|
|
498
|
-
};
|
|
499
|
-
const dataStr = JSON.stringify(diagramData, null, 2);
|
|
500
|
-
const dataUri =
|
|
501
|
-
'data:application/json;charset=utf-8,' + encodeURIComponent(dataStr);
|
|
502
|
-
const exportFileDefaultName = 'diagram.json';
|
|
503
|
-
|
|
504
|
-
const linkElement = document.createElement('a');
|
|
505
|
-
linkElement.setAttribute('href', dataUri);
|
|
506
|
-
linkElement.setAttribute('download', exportFileDefaultName);
|
|
507
|
-
linkElement.click();
|
|
508
|
-
}, [nodes, edges]);
|
|
509
|
-
|
|
510
|
-
// Import diagram
|
|
511
|
-
const importDiagram = useCallback(
|
|
512
|
-
(event: React.ChangeEvent<HTMLInputElement>) => {
|
|
513
|
-
const file = event.target.files?.[0];
|
|
514
|
-
if (file) {
|
|
515
|
-
const reader = new FileReader();
|
|
516
|
-
reader.onload = (e) => {
|
|
517
|
-
try {
|
|
518
|
-
const content = e.target?.result as string;
|
|
519
|
-
const { nodes: importedNodes, edges: importedEdges } =
|
|
520
|
-
JSON.parse(content);
|
|
521
|
-
setNodes(importedNodes);
|
|
522
|
-
setEdges(importedEdges);
|
|
523
|
-
// Add to history
|
|
524
|
-
const newHistory = history.slice(0, historyIndex + 1);
|
|
525
|
-
newHistory.push({ nodes: importedNodes, edges: importedEdges });
|
|
526
|
-
setHistory(newHistory);
|
|
527
|
-
setHistoryIndex(newHistory.length - 1);
|
|
528
|
-
} catch (error) {
|
|
529
|
-
console.error('Error importing diagram:', error);
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
reader.readAsText(file);
|
|
533
|
-
}
|
|
534
|
-
},
|
|
535
|
-
[history, historyIndex],
|
|
536
|
-
);
|
|
537
|
-
|
|
538
|
-
// Update history when nodes or edges change
|
|
539
|
-
useEffect(() => {
|
|
540
|
-
const currentState = { nodes, edges };
|
|
541
|
-
if (
|
|
542
|
-
JSON.stringify(currentState) !==
|
|
543
|
-
JSON.stringify(history[history.length - 1])
|
|
544
|
-
) {
|
|
545
|
-
const newHistory = history.slice(0, historyIndex + 1);
|
|
546
|
-
newHistory.push(currentState);
|
|
547
|
-
setHistory(newHistory);
|
|
548
|
-
setHistoryIndex(newHistory.length - 1);
|
|
549
|
-
}
|
|
550
|
-
}, [nodes, edges]);
|
|
551
|
-
|
|
552
|
-
const handleClickAway = () => {
|
|
553
|
-
setIsDialogOpen(false);
|
|
554
|
-
setSelectedNode(null);
|
|
555
|
-
setSelectedEdge(null);
|
|
556
|
-
setEdgeLabel('');
|
|
557
|
-
};
|
|
558
|
-
|
|
559
|
-
// Add handler for diagram pane clicks
|
|
560
|
-
const handlePaneClick = useCallback(() => {
|
|
561
|
-
handleClickAway();
|
|
562
|
-
}, []);
|
|
563
|
-
|
|
564
|
-
return (
|
|
565
|
-
<div style={{ width: '100vw', height: '100vh' }}>
|
|
566
|
-
<ReactFlow<Node<NodeData>, Edge<EdgeData>>
|
|
567
|
-
nodes={nodes}
|
|
568
|
-
edges={edges}
|
|
569
|
-
onNodesChange={onNodesChange}
|
|
570
|
-
onEdgesChange={onEdgesChange}
|
|
571
|
-
onConnect={onConnect}
|
|
572
|
-
onNodeClick={onNodeClick}
|
|
573
|
-
onEdgeClick={onEdgeClick}
|
|
574
|
-
onPaneClick={handlePaneClick}
|
|
575
|
-
onDragOver={onDragOver}
|
|
576
|
-
className="react-flow-subflows-example"
|
|
577
|
-
fitView
|
|
578
|
-
minZoom={0.2}
|
|
579
|
-
maxZoom={1.5}
|
|
580
|
-
defaultEdgeOptions={{
|
|
581
|
-
type: 'smoothstep',
|
|
582
|
-
animated: false,
|
|
583
|
-
style: edgeStyles,
|
|
584
|
-
}}
|
|
585
|
-
nodesDraggable={true}
|
|
586
|
-
nodesConnectable={true}
|
|
587
|
-
elementsSelectable={true}
|
|
588
|
-
edgesFocusable={true}
|
|
589
|
-
onInit={() => setIsInitialized(true)}
|
|
590
|
-
>
|
|
591
|
-
<Panel position="top-left">
|
|
592
|
-
<Box sx={{ display: 'flex', gap: 2, alignItems: 'flex-start' }}>
|
|
593
|
-
<ArchDiagramControls
|
|
594
|
-
onAddNode={handleAddNode}
|
|
595
|
-
onAddGroup={handleAddGroupNode}
|
|
596
|
-
onUndo={handleUndo}
|
|
597
|
-
onRedo={handleRedo}
|
|
598
|
-
canUndo={historyIndex > 0}
|
|
599
|
-
canRedo={historyIndex < history.length - 1}
|
|
600
|
-
onLoadTemplate={handleLoadTemplate}
|
|
601
|
-
/>
|
|
602
|
-
</Box>
|
|
603
|
-
</Panel>
|
|
604
|
-
|
|
605
|
-
{/* Edge Settings */}
|
|
606
|
-
{selectedEdge && (
|
|
607
|
-
<ClickAwayListener
|
|
608
|
-
onClickAway={handleClickAway}
|
|
609
|
-
mouseEvent="onMouseDown"
|
|
610
|
-
touchEvent="onTouchStart"
|
|
611
|
-
>
|
|
612
|
-
<EdgeSettings
|
|
613
|
-
selectedEdge={selectedEdge}
|
|
614
|
-
edgeLabel={edgeLabel}
|
|
615
|
-
onEdgeLabelChange={setEdgeLabel}
|
|
616
|
-
onEdgeUpdate={handleEdgeUpdate}
|
|
617
|
-
isAnimated={isEdgeAnimated}
|
|
618
|
-
onAnimationToggle={(checked) => {
|
|
619
|
-
setIsEdgeAnimated(checked);
|
|
620
|
-
if (selectedEdge) {
|
|
621
|
-
toggleEdgeAnimation(selectedEdge.id);
|
|
622
|
-
}
|
|
623
|
-
}}
|
|
624
|
-
/>
|
|
625
|
-
</ClickAwayListener>
|
|
626
|
-
)}
|
|
627
|
-
|
|
628
|
-
{/* Add GroupSizeDialog */}
|
|
629
|
-
<GroupSizeDialog
|
|
630
|
-
selectedNode={selectedNode}
|
|
631
|
-
groupWidth={groupWidth}
|
|
632
|
-
groupHeight={groupHeight}
|
|
633
|
-
onGroupSizeChange={handleGroupSizeChange}
|
|
634
|
-
/>
|
|
635
|
-
|
|
636
|
-
<Panel position="bottom-right">
|
|
637
|
-
<Paper
|
|
638
|
-
elevation={3}
|
|
639
|
-
sx={{
|
|
640
|
-
p: 1.5,
|
|
641
|
-
borderRadius: 2,
|
|
642
|
-
bgcolor: 'background.paper',
|
|
643
|
-
maxWidth: '480px',
|
|
644
|
-
}}
|
|
645
|
-
>
|
|
646
|
-
<Box
|
|
647
|
-
sx={{
|
|
648
|
-
display: 'flex',
|
|
649
|
-
flexDirection: 'row',
|
|
650
|
-
gap: 1,
|
|
651
|
-
justifyContent: 'space-between',
|
|
652
|
-
}}
|
|
653
|
-
>
|
|
654
|
-
<Button
|
|
655
|
-
variant="contained"
|
|
656
|
-
color="primary"
|
|
657
|
-
size="small"
|
|
658
|
-
onClick={() => {
|
|
659
|
-
const clearedState = { nodes: [], edges: [] };
|
|
660
|
-
const newHistory = history.slice(0, historyIndex + 1);
|
|
661
|
-
newHistory.push(clearedState);
|
|
662
|
-
setNodes([]);
|
|
663
|
-
setEdges([]);
|
|
664
|
-
setHistory(newHistory);
|
|
665
|
-
setHistoryIndex(newHistory.length - 1);
|
|
666
|
-
}}
|
|
667
|
-
>
|
|
668
|
-
Clear
|
|
669
|
-
</Button>
|
|
670
|
-
|
|
671
|
-
<Box sx={{ display: 'flex', gap: 1 }}>
|
|
672
|
-
<Button
|
|
673
|
-
variant="contained"
|
|
674
|
-
color="primary"
|
|
675
|
-
size="small"
|
|
676
|
-
startIcon={<UndoIcon />}
|
|
677
|
-
onClick={handleUndo}
|
|
678
|
-
disabled={historyIndex <= 0}
|
|
679
|
-
sx={{
|
|
680
|
-
minWidth: '40px',
|
|
681
|
-
px: 1,
|
|
682
|
-
}}
|
|
683
|
-
>
|
|
684
|
-
Undo
|
|
685
|
-
</Button>
|
|
686
|
-
<Button
|
|
687
|
-
variant="contained"
|
|
688
|
-
color="primary"
|
|
689
|
-
size="small"
|
|
690
|
-
startIcon={<RedoIcon />}
|
|
691
|
-
onClick={handleRedo}
|
|
692
|
-
disabled={historyIndex >= history.length - 1}
|
|
693
|
-
sx={{
|
|
694
|
-
minWidth: '40px',
|
|
695
|
-
px: 1,
|
|
696
|
-
}}
|
|
697
|
-
>
|
|
698
|
-
Redo
|
|
699
|
-
</Button>
|
|
700
|
-
</Box>
|
|
701
|
-
|
|
702
|
-
<Box sx={{ display: 'flex', gap: 1 }}>
|
|
703
|
-
<Button
|
|
704
|
-
variant="outlined"
|
|
705
|
-
size="small"
|
|
706
|
-
onClick={exportDiagram}
|
|
707
|
-
startIcon={<DownloadIcon />}
|
|
708
|
-
sx={{
|
|
709
|
-
minWidth: '40px',
|
|
710
|
-
px: 1,
|
|
711
|
-
}}
|
|
712
|
-
>
|
|
713
|
-
Export
|
|
714
|
-
</Button>
|
|
715
|
-
<Button
|
|
716
|
-
variant="outlined"
|
|
717
|
-
component="label"
|
|
718
|
-
size="small"
|
|
719
|
-
startIcon={<UploadIcon />}
|
|
720
|
-
sx={{
|
|
721
|
-
minWidth: '40px',
|
|
722
|
-
px: 1,
|
|
723
|
-
}}
|
|
724
|
-
>
|
|
725
|
-
Import
|
|
726
|
-
<input
|
|
727
|
-
type="file"
|
|
728
|
-
onChange={importDiagram}
|
|
729
|
-
accept=".json"
|
|
730
|
-
style={{ display: 'none' }}
|
|
731
|
-
/>
|
|
732
|
-
</Button>
|
|
733
|
-
</Box>
|
|
734
|
-
</Box>
|
|
735
|
-
</Paper>
|
|
736
|
-
</Panel>
|
|
737
|
-
|
|
738
|
-
<Controls />
|
|
739
|
-
<Background color="#E6E6E6" gap={16} />
|
|
740
|
-
</ReactFlow>
|
|
741
|
-
|
|
742
|
-
{/* Node Dialog with ClickAwayListener */}
|
|
743
|
-
{isDialogOpen && (
|
|
744
|
-
<ClickAwayListener
|
|
745
|
-
onClickAway={handleClickAway}
|
|
746
|
-
mouseEvent="onMouseDown"
|
|
747
|
-
touchEvent="onTouchStart"
|
|
748
|
-
>
|
|
749
|
-
<NodeDialog
|
|
750
|
-
open={isDialogOpen}
|
|
751
|
-
onClose={() => setIsDialogOpen(false)}
|
|
752
|
-
selectedNode={selectedNode}
|
|
753
|
-
newNodeType={newNodeType}
|
|
754
|
-
newNodeLabel={newNodeLabel}
|
|
755
|
-
selectedColor={selectedColor}
|
|
756
|
-
nodeTypes={nodeTypes}
|
|
757
|
-
colorOptions={[
|
|
758
|
-
{ value: 'blue', label: 'Blue', color: nodeColors.blue },
|
|
759
|
-
{ value: 'green', label: 'Green', color: nodeColors.green },
|
|
760
|
-
{ value: 'orange', label: 'Orange', color: nodeColors.orange },
|
|
761
|
-
{ value: 'purple', label: 'Purple', color: nodeColors.purple },
|
|
762
|
-
{ value: 'pink', label: 'Pink', color: nodeColors.pink },
|
|
763
|
-
]}
|
|
764
|
-
onNodeTypeChange={setNewNodeType}
|
|
765
|
-
onColorChange={setSelectedColor}
|
|
766
|
-
onLabelChange={setNewNodeLabel}
|
|
767
|
-
onAddNode={() =>
|
|
768
|
-
handleAddNode(
|
|
769
|
-
newNodeType,
|
|
770
|
-
nodeColors[selectedColor as keyof typeof nodeColors],
|
|
771
|
-
)
|
|
772
|
-
}
|
|
773
|
-
onUpdateLabel={handleUpdateLabel}
|
|
774
|
-
onAddChildNode={handleAddChildNode}
|
|
775
|
-
/>
|
|
776
|
-
</ClickAwayListener>
|
|
777
|
-
)}
|
|
778
|
-
</div>
|
|
779
|
-
);
|
|
780
|
-
};
|
|
781
|
-
|
|
782
|
-
const ArchDiagram = (props: {
|
|
783
|
-
archNodes: Node<NodeData>[];
|
|
784
|
-
archEdges: Edge<EdgeData>[];
|
|
785
|
-
}) => {
|
|
786
|
-
return (
|
|
787
|
-
<ReactFlowProvider>
|
|
788
|
-
<ArchDiagramInner {...props} />
|
|
789
|
-
</ReactFlowProvider>
|
|
790
|
-
);
|
|
791
|
-
};
|
|
792
|
-
|
|
793
|
-
export default ArchDiagram;
|
|
1
|
+
import { useCallback, useState, useEffect } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ReactFlow,
|
|
4
|
+
addEdge,
|
|
5
|
+
Background,
|
|
6
|
+
useNodesState,
|
|
7
|
+
useEdgesState,
|
|
8
|
+
Controls,
|
|
9
|
+
Connection,
|
|
10
|
+
Edge,
|
|
11
|
+
Panel,
|
|
12
|
+
Node,
|
|
13
|
+
useReactFlow,
|
|
14
|
+
ReactFlowProvider,
|
|
15
|
+
MarkerType,
|
|
16
|
+
} from '@xyflow/react';
|
|
17
|
+
import { Box, Button, Paper, ClickAwayListener } from '@mui/material';
|
|
18
|
+
import UndoIcon from '@mui/icons-material/Undo';
|
|
19
|
+
import RedoIcon from '@mui/icons-material/Redo';
|
|
20
|
+
import DownloadIcon from '@mui/icons-material/Download';
|
|
21
|
+
import UploadIcon from '@mui/icons-material/Upload';
|
|
22
|
+
|
|
23
|
+
import NodeDialog from './components/NodeDialog';
|
|
24
|
+
import EdgeSettings from './components/EdgeSettings';
|
|
25
|
+
import GroupSizeDialog from './components/GroupSizeDialog';
|
|
26
|
+
import ArchDiagramControls from './controls/ArchDiagramControls';
|
|
27
|
+
|
|
28
|
+
import '@xyflow/react/dist/style.css';
|
|
29
|
+
import {
|
|
30
|
+
eventDrivenTemplate,
|
|
31
|
+
microservicesTemplate,
|
|
32
|
+
nodeColors,
|
|
33
|
+
threeTierTemplate,
|
|
34
|
+
} from './data/templatee-data';
|
|
35
|
+
import {
|
|
36
|
+
animatedEdgeStyle,
|
|
37
|
+
defaultEdgeStyle,
|
|
38
|
+
EdgeData,
|
|
39
|
+
edgeStyles,
|
|
40
|
+
NodeData,
|
|
41
|
+
nodeTypes,
|
|
42
|
+
NodeTypes,
|
|
43
|
+
} from './components/nodeTypes';
|
|
44
|
+
|
|
45
|
+
const ArchDiagramInner = ({
|
|
46
|
+
archNodes,
|
|
47
|
+
archEdges,
|
|
48
|
+
}: {
|
|
49
|
+
archNodes: Node<NodeData>[];
|
|
50
|
+
archEdges: Edge<EdgeData>[];
|
|
51
|
+
}) => {
|
|
52
|
+
const [nodes, setNodes, onNodesChange] = useNodesState<Node<NodeData>>([]);
|
|
53
|
+
const [edges, setEdges, onEdgesChange] = useEdgesState<Edge<EdgeData>>([]);
|
|
54
|
+
const [history, setHistory] = useState<
|
|
55
|
+
{ nodes: Node<NodeData>[]; edges: Edge<EdgeData>[] }[]
|
|
56
|
+
>([{ nodes: [], edges: [] }]);
|
|
57
|
+
const [historyIndex, setHistoryIndex] = useState(0);
|
|
58
|
+
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
|
59
|
+
const [selectedNode, setSelectedNode] = useState<Node<NodeData> | null>(null);
|
|
60
|
+
const [newNodeType, setNewNodeType] = useState<keyof NodeTypes>('service');
|
|
61
|
+
const [newNodeLabel, setNewNodeLabel] = useState('');
|
|
62
|
+
const [selectedColor, setSelectedColor] = useState<string>('blue');
|
|
63
|
+
const [groupWidth, setGroupWidth] = useState(600);
|
|
64
|
+
const [groupHeight, setGroupHeight] = useState(200);
|
|
65
|
+
const [selectedEdge, setSelectedEdge] = useState<Edge<EdgeData> | null>(null);
|
|
66
|
+
const [edgeLabel, setEdgeLabel] = useState('');
|
|
67
|
+
const [isEdgeAnimated, setIsEdgeAnimated] = useState(false);
|
|
68
|
+
const [isInitialized, setIsInitialized] = useState(false);
|
|
69
|
+
|
|
70
|
+
const { getNodes, getViewport } = useReactFlow();
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (archNodes && archEdges) {
|
|
74
|
+
// Ensure nodes have valid positions and styles
|
|
75
|
+
const validNodes = archNodes.map(node => {
|
|
76
|
+
// Handle different node types
|
|
77
|
+
const nodeType = node.type;
|
|
78
|
+
|
|
79
|
+
let nodeStyle;
|
|
80
|
+
if (nodeType === 'subnetNode') {
|
|
81
|
+
nodeStyle = {
|
|
82
|
+
backgroundColor: node.data?.color || 'transparent',
|
|
83
|
+
border: `1px solid ${node.data?.borderColor || '#777'}`,
|
|
84
|
+
borderRadius: '8px',
|
|
85
|
+
padding: '20px',
|
|
86
|
+
width: node.data?.width || 500,
|
|
87
|
+
height: node.data?.height || 250,
|
|
88
|
+
zIndex: node.style?.zIndex || 1,
|
|
89
|
+
} as const;
|
|
90
|
+
} else if (nodeType === 'serviceNode') {
|
|
91
|
+
nodeStyle = {
|
|
92
|
+
backgroundColor: node.data?.color || nodeColors.blue,
|
|
93
|
+
border: '1px solid #777',
|
|
94
|
+
borderRadius: '8px',
|
|
95
|
+
padding: '10px',
|
|
96
|
+
width: 130,
|
|
97
|
+
height: 80,
|
|
98
|
+
zIndex: node.style?.zIndex || 2,
|
|
99
|
+
} as const;
|
|
100
|
+
} else {
|
|
101
|
+
nodeStyle = {
|
|
102
|
+
backgroundColor: node.data?.color || nodeColors.blue,
|
|
103
|
+
border: '1px solid #777',
|
|
104
|
+
borderRadius: '8px',
|
|
105
|
+
padding: '10px',
|
|
106
|
+
width: node.style?.width || 130,
|
|
107
|
+
height: node.style?.height || 80,
|
|
108
|
+
zIndex: node.style?.zIndex || 1,
|
|
109
|
+
} as const;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
...node,
|
|
114
|
+
position: node.position || { x: 0, y: 0 },
|
|
115
|
+
style: nodeStyle as React.CSSProperties,
|
|
116
|
+
data: {
|
|
117
|
+
...node.data,
|
|
118
|
+
label: node.data?.label || 'New Node',
|
|
119
|
+
}
|
|
120
|
+
} as Node<NodeData>;
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Ensure edges have proper styling
|
|
124
|
+
const validEdges = archEdges.map(edge => {
|
|
125
|
+
const edgeStyle = {
|
|
126
|
+
stroke: edge.style?.stroke || '#555',
|
|
127
|
+
strokeWidth: edge.style?.strokeWidth || 2,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
...edge,
|
|
132
|
+
type: edge.type || 'smoothstep',
|
|
133
|
+
animated: edge.animated || false,
|
|
134
|
+
style: edgeStyle,
|
|
135
|
+
markerEnd: {
|
|
136
|
+
type: MarkerType.ArrowClosed,
|
|
137
|
+
width: 20,
|
|
138
|
+
height: 20,
|
|
139
|
+
color: edgeStyle.stroke,
|
|
140
|
+
},
|
|
141
|
+
} as Edge<EdgeData>;
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
setNodes(validNodes);
|
|
145
|
+
setEdges(validEdges);
|
|
146
|
+
setHistory([{ nodes: validNodes, edges: validEdges }]);
|
|
147
|
+
setIsInitialized(true);
|
|
148
|
+
}
|
|
149
|
+
}, [archNodes, archEdges]);
|
|
150
|
+
|
|
151
|
+
const findCenterPosition = useCallback(() => {
|
|
152
|
+
// Default center position
|
|
153
|
+
const defaultPosition = {
|
|
154
|
+
x: window.innerWidth / 2,
|
|
155
|
+
y: window.innerHeight / 2,
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
if (!isInitialized) {
|
|
159
|
+
return defaultPosition;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
try {
|
|
163
|
+
const viewport = getViewport();
|
|
164
|
+
if (
|
|
165
|
+
!viewport ||
|
|
166
|
+
typeof viewport.x === 'undefined' ||
|
|
167
|
+
typeof viewport.y === 'undefined' ||
|
|
168
|
+
typeof viewport.zoom === 'undefined'
|
|
169
|
+
) {
|
|
170
|
+
return defaultPosition;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const centerX =
|
|
174
|
+
-viewport.x / viewport.zoom + window.innerWidth / (2 * viewport.zoom);
|
|
175
|
+
const centerY =
|
|
176
|
+
-viewport.y / viewport.zoom + window.innerHeight / (2 * viewport.zoom);
|
|
177
|
+
|
|
178
|
+
const existingNodes = getNodes();
|
|
179
|
+
if (!existingNodes || existingNodes.length === 0) {
|
|
180
|
+
return { x: centerX, y: centerY };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const centerThreshold = 100;
|
|
184
|
+
const centeredNodes = existingNodes.filter((node) => {
|
|
185
|
+
if (
|
|
186
|
+
!node ||
|
|
187
|
+
!node.position ||
|
|
188
|
+
typeof node.position.x === 'undefined' ||
|
|
189
|
+
typeof node.position.y === 'undefined'
|
|
190
|
+
) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
const dx = Math.abs(node.position.x - centerX);
|
|
194
|
+
const dy = Math.abs(node.position.y - centerY);
|
|
195
|
+
return dx < centerThreshold && dy < centerThreshold;
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
if (centeredNodes.length > 0) {
|
|
199
|
+
const leftmostX = Math.min(
|
|
200
|
+
...centeredNodes.map((node) => node.position?.x || 0),
|
|
201
|
+
);
|
|
202
|
+
return {
|
|
203
|
+
x: leftmostX - 200,
|
|
204
|
+
y: centerY,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return { x: centerX, y: centerY };
|
|
209
|
+
} catch (error) {
|
|
210
|
+
console.error('Error calculating center position:', error);
|
|
211
|
+
return defaultPosition;
|
|
212
|
+
}
|
|
213
|
+
}, [getViewport, getNodes, isInitialized]);
|
|
214
|
+
|
|
215
|
+
const onConnect = useCallback(
|
|
216
|
+
(connection: Connection) => {
|
|
217
|
+
const newEdge = {
|
|
218
|
+
...connection,
|
|
219
|
+
id: `edge-${Date.now()}`,
|
|
220
|
+
...(isEdgeAnimated ? animatedEdgeStyle : edgeStyles),
|
|
221
|
+
type: 'smoothstep',
|
|
222
|
+
label: '',
|
|
223
|
+
labelStyle: {
|
|
224
|
+
...defaultEdgeStyle.labelStyle,
|
|
225
|
+
display: edgeLabel ? 'block' : 'none',
|
|
226
|
+
},
|
|
227
|
+
labelBgStyle: defaultEdgeStyle.labelBgStyle,
|
|
228
|
+
};
|
|
229
|
+
setEdges((eds) => addEdge(newEdge as Edge<EdgeData>, eds));
|
|
230
|
+
},
|
|
231
|
+
[isEdgeAnimated, edgeLabel],
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
const toggleEdgeAnimation = useCallback((edgeId: string) => {
|
|
235
|
+
setEdges((eds) =>
|
|
236
|
+
eds.map((edge) => {
|
|
237
|
+
if (edge.id === edgeId) {
|
|
238
|
+
const isCurrentlyAnimated = edge.animated;
|
|
239
|
+
return {
|
|
240
|
+
...edge,
|
|
241
|
+
...(isCurrentlyAnimated ? edgeStyles : animatedEdgeStyle),
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
return edge;
|
|
245
|
+
}),
|
|
246
|
+
);
|
|
247
|
+
}, []);
|
|
248
|
+
|
|
249
|
+
const onDragOver = useCallback((event: React.DragEvent) => {
|
|
250
|
+
event.preventDefault();
|
|
251
|
+
event.dataTransfer.dropEffect = 'move';
|
|
252
|
+
}, []);
|
|
253
|
+
|
|
254
|
+
const handleGroupSizeChange = useCallback(
|
|
255
|
+
(width: number, height: number) => {
|
|
256
|
+
if (!selectedNode?.data?.isGroup) return;
|
|
257
|
+
|
|
258
|
+
setGroupWidth(width);
|
|
259
|
+
setGroupHeight(height);
|
|
260
|
+
|
|
261
|
+
setNodes((nds) =>
|
|
262
|
+
nds.map((node) =>
|
|
263
|
+
node.id === selectedNode.id
|
|
264
|
+
? {
|
|
265
|
+
...node,
|
|
266
|
+
style: {
|
|
267
|
+
...node.style,
|
|
268
|
+
width,
|
|
269
|
+
height,
|
|
270
|
+
},
|
|
271
|
+
}
|
|
272
|
+
: node,
|
|
273
|
+
),
|
|
274
|
+
);
|
|
275
|
+
},
|
|
276
|
+
[selectedNode, setNodes],
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
const onNodeClick = (event: React.MouseEvent, node: Node<NodeData>) => {
|
|
280
|
+
if ((event.target as HTMLElement).classList.contains('nodrag')) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
setSelectedNode(node);
|
|
285
|
+
setNewNodeLabel(node.data?.label || '');
|
|
286
|
+
|
|
287
|
+
if (!node.data?.isGroup) {
|
|
288
|
+
setIsDialogOpen(true);
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const handleAddGroupNode = () => {
|
|
293
|
+
const position = findCenterPosition();
|
|
294
|
+
|
|
295
|
+
const newNode = {
|
|
296
|
+
id: `group-${Date.now()}`,
|
|
297
|
+
type: 'group',
|
|
298
|
+
data: {
|
|
299
|
+
label: newNodeLabel || 'New Group',
|
|
300
|
+
isGroup: true,
|
|
301
|
+
},
|
|
302
|
+
position,
|
|
303
|
+
style: {
|
|
304
|
+
width: groupWidth,
|
|
305
|
+
height: groupHeight,
|
|
306
|
+
backgroundColor: 'rgba(240, 240, 240, 0.5)',
|
|
307
|
+
border: '1px dashed #777',
|
|
308
|
+
borderRadius: '8px',
|
|
309
|
+
padding: '20px',
|
|
310
|
+
zIndex: -1,
|
|
311
|
+
},
|
|
312
|
+
selectable: true,
|
|
313
|
+
draggable: true,
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const groupNode = newNode as Node<NodeData>;
|
|
317
|
+
setNodes((nds) => [...nds, groupNode]);
|
|
318
|
+
setNewNodeLabel('');
|
|
319
|
+
setIsDialogOpen(false);
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
useEffect(() => {
|
|
323
|
+
setNodes((nds) =>
|
|
324
|
+
nds.map((node) => {
|
|
325
|
+
if (node.data?.isGroup) {
|
|
326
|
+
return {
|
|
327
|
+
...node,
|
|
328
|
+
style: {
|
|
329
|
+
...node.style,
|
|
330
|
+
zIndex: -1,
|
|
331
|
+
},
|
|
332
|
+
draggable: true,
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
return node;
|
|
336
|
+
}),
|
|
337
|
+
);
|
|
338
|
+
}, []);
|
|
339
|
+
|
|
340
|
+
const handleAddNode = (type: string, color: string) => {
|
|
341
|
+
const nodeInfo = nodeTypes[type as keyof NodeTypes];
|
|
342
|
+
const position = findCenterPosition();
|
|
343
|
+
|
|
344
|
+
const newNode = {
|
|
345
|
+
id: `${type}-${Date.now()}`,
|
|
346
|
+
type,
|
|
347
|
+
data: { label: `New ${nodeInfo.label}` },
|
|
348
|
+
position,
|
|
349
|
+
draggable: true,
|
|
350
|
+
style: {
|
|
351
|
+
background: color,
|
|
352
|
+
border: '1px solid #777',
|
|
353
|
+
borderRadius: '8px',
|
|
354
|
+
padding: '10px',
|
|
355
|
+
width: 130,
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
setNodes((nds) => [...nds, newNode as Node<NodeData>]);
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
const handleAddChildNode = (parentId: string) => {
|
|
362
|
+
const parent = nodes.find((node) => node.id === parentId);
|
|
363
|
+
if (!parent || !parent.data?.isGroup) return;
|
|
364
|
+
|
|
365
|
+
// Calculate position relative to parent
|
|
366
|
+
const childPosition = {
|
|
367
|
+
x: parent.position.x + 50,
|
|
368
|
+
y: parent.position.y + 50,
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
const newNode = {
|
|
372
|
+
id: `service-${Date.now()}`,
|
|
373
|
+
type: 'service',
|
|
374
|
+
data: {
|
|
375
|
+
label: 'New Service',
|
|
376
|
+
parentId: parentId,
|
|
377
|
+
},
|
|
378
|
+
position: childPosition,
|
|
379
|
+
draggable: true,
|
|
380
|
+
style: {
|
|
381
|
+
background: nodeColors.blue,
|
|
382
|
+
border: '1px solid #777',
|
|
383
|
+
borderRadius: '8px',
|
|
384
|
+
padding: '10px',
|
|
385
|
+
width: 130,
|
|
386
|
+
},
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
setNodes((nds) => [...nds, newNode as Node<NodeData>]);
|
|
390
|
+
setIsDialogOpen(false);
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
const handleUpdateLabel = () => {
|
|
394
|
+
if (!selectedNode) return;
|
|
395
|
+
|
|
396
|
+
setNodes((nds) =>
|
|
397
|
+
nds.map((node) =>
|
|
398
|
+
node.id === selectedNode.id
|
|
399
|
+
? { ...node, data: { ...node.data, label: newNodeLabel } }
|
|
400
|
+
: node,
|
|
401
|
+
),
|
|
402
|
+
);
|
|
403
|
+
setIsDialogOpen(false);
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
const onEdgeClick = useCallback(
|
|
407
|
+
(event: React.MouseEvent, edge: Edge<EdgeData>) => {
|
|
408
|
+
event.preventDefault();
|
|
409
|
+
if (event.shiftKey) {
|
|
410
|
+
// Toggle animation when clicking with shift key
|
|
411
|
+
toggleEdgeAnimation(edge.id);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
setSelectedEdge(edge);
|
|
415
|
+
setEdgeLabel(String(edge.label || edge.data?.label || ''));
|
|
416
|
+
setIsEdgeAnimated(!!edge.animated);
|
|
417
|
+
},
|
|
418
|
+
[toggleEdgeAnimation],
|
|
419
|
+
);
|
|
420
|
+
|
|
421
|
+
const handleEdgeUpdate = useCallback(() => {
|
|
422
|
+
if (!selectedEdge) return;
|
|
423
|
+
|
|
424
|
+
setEdges((eds) =>
|
|
425
|
+
eds.map((edge) => {
|
|
426
|
+
if (edge.id === selectedEdge.id) {
|
|
427
|
+
const updatedEdge = {
|
|
428
|
+
...edge,
|
|
429
|
+
label: edgeLabel || '',
|
|
430
|
+
data: {
|
|
431
|
+
...edge.data,
|
|
432
|
+
label: edgeLabel || '',
|
|
433
|
+
} as EdgeData,
|
|
434
|
+
style: {
|
|
435
|
+
...(edge.animated ? animatedEdgeStyle.style : edgeStyles.style),
|
|
436
|
+
},
|
|
437
|
+
labelStyle: {
|
|
438
|
+
...defaultEdgeStyle.labelStyle,
|
|
439
|
+
display: edgeLabel ? 'block' : 'none',
|
|
440
|
+
},
|
|
441
|
+
labelBgStyle: defaultEdgeStyle.labelBgStyle,
|
|
442
|
+
};
|
|
443
|
+
return updatedEdge;
|
|
444
|
+
}
|
|
445
|
+
return edge;
|
|
446
|
+
}),
|
|
447
|
+
);
|
|
448
|
+
setSelectedEdge(null);
|
|
449
|
+
setEdgeLabel('');
|
|
450
|
+
}, [selectedEdge, edgeLabel]);
|
|
451
|
+
|
|
452
|
+
const handleLoadTemplate = useCallback((templateType: string) => {
|
|
453
|
+
let template;
|
|
454
|
+
switch (templateType) {
|
|
455
|
+
case 'microservices':
|
|
456
|
+
template = microservicesTemplate;
|
|
457
|
+
break;
|
|
458
|
+
case 'three-tier':
|
|
459
|
+
template = threeTierTemplate;
|
|
460
|
+
break;
|
|
461
|
+
case 'event-driven':
|
|
462
|
+
template = eventDrivenTemplate;
|
|
463
|
+
break;
|
|
464
|
+
default:
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
setNodes(template.nodes as Node<NodeData>[]);
|
|
468
|
+
setEdges(template.edges as Edge<EdgeData>[]);
|
|
469
|
+
}, []);
|
|
470
|
+
|
|
471
|
+
// Handle undo
|
|
472
|
+
const handleUndo = useCallback(() => {
|
|
473
|
+
if (historyIndex > 0) {
|
|
474
|
+
const newIndex = historyIndex - 1;
|
|
475
|
+
const previousState = history[newIndex];
|
|
476
|
+
setNodes(previousState.nodes);
|
|
477
|
+
setEdges(previousState.edges);
|
|
478
|
+
setHistoryIndex(newIndex);
|
|
479
|
+
}
|
|
480
|
+
}, [history, historyIndex]);
|
|
481
|
+
|
|
482
|
+
// Handle redo
|
|
483
|
+
const handleRedo = useCallback(() => {
|
|
484
|
+
if (historyIndex < history.length - 1) {
|
|
485
|
+
const newIndex = historyIndex + 1;
|
|
486
|
+
const nextState = history[newIndex];
|
|
487
|
+
setNodes(nextState.nodes);
|
|
488
|
+
setEdges(nextState.edges);
|
|
489
|
+
setHistoryIndex(newIndex);
|
|
490
|
+
}
|
|
491
|
+
}, [history, historyIndex]);
|
|
492
|
+
|
|
493
|
+
// Export diagram
|
|
494
|
+
const exportDiagram = useCallback(() => {
|
|
495
|
+
const diagramData = {
|
|
496
|
+
nodes,
|
|
497
|
+
edges,
|
|
498
|
+
};
|
|
499
|
+
const dataStr = JSON.stringify(diagramData, null, 2);
|
|
500
|
+
const dataUri =
|
|
501
|
+
'data:application/json;charset=utf-8,' + encodeURIComponent(dataStr);
|
|
502
|
+
const exportFileDefaultName = 'diagram.json';
|
|
503
|
+
|
|
504
|
+
const linkElement = document.createElement('a');
|
|
505
|
+
linkElement.setAttribute('href', dataUri);
|
|
506
|
+
linkElement.setAttribute('download', exportFileDefaultName);
|
|
507
|
+
linkElement.click();
|
|
508
|
+
}, [nodes, edges]);
|
|
509
|
+
|
|
510
|
+
// Import diagram
|
|
511
|
+
const importDiagram = useCallback(
|
|
512
|
+
(event: React.ChangeEvent<HTMLInputElement>) => {
|
|
513
|
+
const file = event.target.files?.[0];
|
|
514
|
+
if (file) {
|
|
515
|
+
const reader = new FileReader();
|
|
516
|
+
reader.onload = (e) => {
|
|
517
|
+
try {
|
|
518
|
+
const content = e.target?.result as string;
|
|
519
|
+
const { nodes: importedNodes, edges: importedEdges } =
|
|
520
|
+
JSON.parse(content);
|
|
521
|
+
setNodes(importedNodes);
|
|
522
|
+
setEdges(importedEdges);
|
|
523
|
+
// Add to history
|
|
524
|
+
const newHistory = history.slice(0, historyIndex + 1);
|
|
525
|
+
newHistory.push({ nodes: importedNodes, edges: importedEdges });
|
|
526
|
+
setHistory(newHistory);
|
|
527
|
+
setHistoryIndex(newHistory.length - 1);
|
|
528
|
+
} catch (error) {
|
|
529
|
+
console.error('Error importing diagram:', error);
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
reader.readAsText(file);
|
|
533
|
+
}
|
|
534
|
+
},
|
|
535
|
+
[history, historyIndex],
|
|
536
|
+
);
|
|
537
|
+
|
|
538
|
+
// Update history when nodes or edges change
|
|
539
|
+
useEffect(() => {
|
|
540
|
+
const currentState = { nodes, edges };
|
|
541
|
+
if (
|
|
542
|
+
JSON.stringify(currentState) !==
|
|
543
|
+
JSON.stringify(history[history.length - 1])
|
|
544
|
+
) {
|
|
545
|
+
const newHistory = history.slice(0, historyIndex + 1);
|
|
546
|
+
newHistory.push(currentState);
|
|
547
|
+
setHistory(newHistory);
|
|
548
|
+
setHistoryIndex(newHistory.length - 1);
|
|
549
|
+
}
|
|
550
|
+
}, [nodes, edges]);
|
|
551
|
+
|
|
552
|
+
const handleClickAway = () => {
|
|
553
|
+
setIsDialogOpen(false);
|
|
554
|
+
setSelectedNode(null);
|
|
555
|
+
setSelectedEdge(null);
|
|
556
|
+
setEdgeLabel('');
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
// Add handler for diagram pane clicks
|
|
560
|
+
const handlePaneClick = useCallback(() => {
|
|
561
|
+
handleClickAway();
|
|
562
|
+
}, []);
|
|
563
|
+
|
|
564
|
+
return (
|
|
565
|
+
<div style={{ width: '100vw', height: '100vh' }}>
|
|
566
|
+
<ReactFlow<Node<NodeData>, Edge<EdgeData>>
|
|
567
|
+
nodes={nodes}
|
|
568
|
+
edges={edges}
|
|
569
|
+
onNodesChange={onNodesChange}
|
|
570
|
+
onEdgesChange={onEdgesChange}
|
|
571
|
+
onConnect={onConnect}
|
|
572
|
+
onNodeClick={onNodeClick}
|
|
573
|
+
onEdgeClick={onEdgeClick}
|
|
574
|
+
onPaneClick={handlePaneClick}
|
|
575
|
+
onDragOver={onDragOver}
|
|
576
|
+
className="react-flow-subflows-example"
|
|
577
|
+
fitView
|
|
578
|
+
minZoom={0.2}
|
|
579
|
+
maxZoom={1.5}
|
|
580
|
+
defaultEdgeOptions={{
|
|
581
|
+
type: 'smoothstep',
|
|
582
|
+
animated: false,
|
|
583
|
+
style: edgeStyles,
|
|
584
|
+
}}
|
|
585
|
+
nodesDraggable={true}
|
|
586
|
+
nodesConnectable={true}
|
|
587
|
+
elementsSelectable={true}
|
|
588
|
+
edgesFocusable={true}
|
|
589
|
+
onInit={() => setIsInitialized(true)}
|
|
590
|
+
>
|
|
591
|
+
<Panel position="top-left">
|
|
592
|
+
<Box sx={{ display: 'flex', gap: 2, alignItems: 'flex-start' }}>
|
|
593
|
+
<ArchDiagramControls
|
|
594
|
+
onAddNode={handleAddNode}
|
|
595
|
+
onAddGroup={handleAddGroupNode}
|
|
596
|
+
onUndo={handleUndo}
|
|
597
|
+
onRedo={handleRedo}
|
|
598
|
+
canUndo={historyIndex > 0}
|
|
599
|
+
canRedo={historyIndex < history.length - 1}
|
|
600
|
+
onLoadTemplate={handleLoadTemplate}
|
|
601
|
+
/>
|
|
602
|
+
</Box>
|
|
603
|
+
</Panel>
|
|
604
|
+
|
|
605
|
+
{/* Edge Settings */}
|
|
606
|
+
{selectedEdge && (
|
|
607
|
+
<ClickAwayListener
|
|
608
|
+
onClickAway={handleClickAway}
|
|
609
|
+
mouseEvent="onMouseDown"
|
|
610
|
+
touchEvent="onTouchStart"
|
|
611
|
+
>
|
|
612
|
+
<EdgeSettings
|
|
613
|
+
selectedEdge={selectedEdge}
|
|
614
|
+
edgeLabel={edgeLabel}
|
|
615
|
+
onEdgeLabelChange={setEdgeLabel}
|
|
616
|
+
onEdgeUpdate={handleEdgeUpdate}
|
|
617
|
+
isAnimated={isEdgeAnimated}
|
|
618
|
+
onAnimationToggle={(checked) => {
|
|
619
|
+
setIsEdgeAnimated(checked);
|
|
620
|
+
if (selectedEdge) {
|
|
621
|
+
toggleEdgeAnimation(selectedEdge.id);
|
|
622
|
+
}
|
|
623
|
+
}}
|
|
624
|
+
/>
|
|
625
|
+
</ClickAwayListener>
|
|
626
|
+
)}
|
|
627
|
+
|
|
628
|
+
{/* Add GroupSizeDialog */}
|
|
629
|
+
<GroupSizeDialog
|
|
630
|
+
selectedNode={selectedNode}
|
|
631
|
+
groupWidth={groupWidth}
|
|
632
|
+
groupHeight={groupHeight}
|
|
633
|
+
onGroupSizeChange={handleGroupSizeChange}
|
|
634
|
+
/>
|
|
635
|
+
|
|
636
|
+
<Panel position="bottom-right">
|
|
637
|
+
<Paper
|
|
638
|
+
elevation={3}
|
|
639
|
+
sx={{
|
|
640
|
+
p: 1.5,
|
|
641
|
+
borderRadius: 2,
|
|
642
|
+
bgcolor: 'background.paper',
|
|
643
|
+
maxWidth: '480px',
|
|
644
|
+
}}
|
|
645
|
+
>
|
|
646
|
+
<Box
|
|
647
|
+
sx={{
|
|
648
|
+
display: 'flex',
|
|
649
|
+
flexDirection: 'row',
|
|
650
|
+
gap: 1,
|
|
651
|
+
justifyContent: 'space-between',
|
|
652
|
+
}}
|
|
653
|
+
>
|
|
654
|
+
<Button
|
|
655
|
+
variant="contained"
|
|
656
|
+
color="primary"
|
|
657
|
+
size="small"
|
|
658
|
+
onClick={() => {
|
|
659
|
+
const clearedState = { nodes: [], edges: [] };
|
|
660
|
+
const newHistory = history.slice(0, historyIndex + 1);
|
|
661
|
+
newHistory.push(clearedState);
|
|
662
|
+
setNodes([]);
|
|
663
|
+
setEdges([]);
|
|
664
|
+
setHistory(newHistory);
|
|
665
|
+
setHistoryIndex(newHistory.length - 1);
|
|
666
|
+
}}
|
|
667
|
+
>
|
|
668
|
+
Clear
|
|
669
|
+
</Button>
|
|
670
|
+
|
|
671
|
+
<Box sx={{ display: 'flex', gap: 1 }}>
|
|
672
|
+
<Button
|
|
673
|
+
variant="contained"
|
|
674
|
+
color="primary"
|
|
675
|
+
size="small"
|
|
676
|
+
startIcon={<UndoIcon />}
|
|
677
|
+
onClick={handleUndo}
|
|
678
|
+
disabled={historyIndex <= 0}
|
|
679
|
+
sx={{
|
|
680
|
+
minWidth: '40px',
|
|
681
|
+
px: 1,
|
|
682
|
+
}}
|
|
683
|
+
>
|
|
684
|
+
Undo
|
|
685
|
+
</Button>
|
|
686
|
+
<Button
|
|
687
|
+
variant="contained"
|
|
688
|
+
color="primary"
|
|
689
|
+
size="small"
|
|
690
|
+
startIcon={<RedoIcon />}
|
|
691
|
+
onClick={handleRedo}
|
|
692
|
+
disabled={historyIndex >= history.length - 1}
|
|
693
|
+
sx={{
|
|
694
|
+
minWidth: '40px',
|
|
695
|
+
px: 1,
|
|
696
|
+
}}
|
|
697
|
+
>
|
|
698
|
+
Redo
|
|
699
|
+
</Button>
|
|
700
|
+
</Box>
|
|
701
|
+
|
|
702
|
+
<Box sx={{ display: 'flex', gap: 1 }}>
|
|
703
|
+
<Button
|
|
704
|
+
variant="outlined"
|
|
705
|
+
size="small"
|
|
706
|
+
onClick={exportDiagram}
|
|
707
|
+
startIcon={<DownloadIcon />}
|
|
708
|
+
sx={{
|
|
709
|
+
minWidth: '40px',
|
|
710
|
+
px: 1,
|
|
711
|
+
}}
|
|
712
|
+
>
|
|
713
|
+
Export
|
|
714
|
+
</Button>
|
|
715
|
+
<Button
|
|
716
|
+
variant="outlined"
|
|
717
|
+
component="label"
|
|
718
|
+
size="small"
|
|
719
|
+
startIcon={<UploadIcon />}
|
|
720
|
+
sx={{
|
|
721
|
+
minWidth: '40px',
|
|
722
|
+
px: 1,
|
|
723
|
+
}}
|
|
724
|
+
>
|
|
725
|
+
Import
|
|
726
|
+
<input
|
|
727
|
+
type="file"
|
|
728
|
+
onChange={importDiagram}
|
|
729
|
+
accept=".json"
|
|
730
|
+
style={{ display: 'none' }}
|
|
731
|
+
/>
|
|
732
|
+
</Button>
|
|
733
|
+
</Box>
|
|
734
|
+
</Box>
|
|
735
|
+
</Paper>
|
|
736
|
+
</Panel>
|
|
737
|
+
|
|
738
|
+
<Controls />
|
|
739
|
+
<Background color="#E6E6E6" gap={16} />
|
|
740
|
+
</ReactFlow>
|
|
741
|
+
|
|
742
|
+
{/* Node Dialog with ClickAwayListener */}
|
|
743
|
+
{isDialogOpen && (
|
|
744
|
+
<ClickAwayListener
|
|
745
|
+
onClickAway={handleClickAway}
|
|
746
|
+
mouseEvent="onMouseDown"
|
|
747
|
+
touchEvent="onTouchStart"
|
|
748
|
+
>
|
|
749
|
+
<NodeDialog
|
|
750
|
+
open={isDialogOpen}
|
|
751
|
+
onClose={() => setIsDialogOpen(false)}
|
|
752
|
+
selectedNode={selectedNode}
|
|
753
|
+
newNodeType={newNodeType}
|
|
754
|
+
newNodeLabel={newNodeLabel}
|
|
755
|
+
selectedColor={selectedColor}
|
|
756
|
+
nodeTypes={nodeTypes}
|
|
757
|
+
colorOptions={[
|
|
758
|
+
{ value: 'blue', label: 'Blue', color: nodeColors.blue },
|
|
759
|
+
{ value: 'green', label: 'Green', color: nodeColors.green },
|
|
760
|
+
{ value: 'orange', label: 'Orange', color: nodeColors.orange },
|
|
761
|
+
{ value: 'purple', label: 'Purple', color: nodeColors.purple },
|
|
762
|
+
{ value: 'pink', label: 'Pink', color: nodeColors.pink },
|
|
763
|
+
]}
|
|
764
|
+
onNodeTypeChange={setNewNodeType}
|
|
765
|
+
onColorChange={setSelectedColor}
|
|
766
|
+
onLabelChange={setNewNodeLabel}
|
|
767
|
+
onAddNode={() =>
|
|
768
|
+
handleAddNode(
|
|
769
|
+
newNodeType,
|
|
770
|
+
nodeColors[selectedColor as keyof typeof nodeColors],
|
|
771
|
+
)
|
|
772
|
+
}
|
|
773
|
+
onUpdateLabel={handleUpdateLabel}
|
|
774
|
+
onAddChildNode={handleAddChildNode}
|
|
775
|
+
/>
|
|
776
|
+
</ClickAwayListener>
|
|
777
|
+
)}
|
|
778
|
+
</div>
|
|
779
|
+
);
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
const ArchDiagram = (props: {
|
|
783
|
+
archNodes: Node<NodeData>[];
|
|
784
|
+
archEdges: Edge<EdgeData>[];
|
|
785
|
+
}) => {
|
|
786
|
+
return (
|
|
787
|
+
<ReactFlowProvider>
|
|
788
|
+
<ArchDiagramInner {...props} />
|
|
789
|
+
</ReactFlowProvider>
|
|
790
|
+
);
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
export default ArchDiagram;
|