@ebubekirylmaz/link-test 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +3 -0
- package/.browserslistrc +1 -0
- package/.env +2 -0
- package/.eslintignore +3 -0
- package/.eslintrc.json +58 -0
- package/.gitattributes +1 -0
- package/.github/workflows/publish.yml +66 -0
- package/.prettierignore +1 -0
- package/.prettierrc +10 -0
- package/.storybook/main.js +15 -0
- package/.storybook/preview.js +17 -0
- package/.storybook/vitest.setup.js +6 -0
- package/README.md +1 -0
- package/cypress.config.js +11 -0
- package/index.js +1 -0
- package/package.json +111 -0
- package/project/.eslintrc.cjs +22 -0
- package/project/config.js +18 -0
- package/project/config.menu.js +39 -0
- package/project/config.template.js +31 -0
- package/project/cypress/e2e/layouts.cy.js +170 -0
- package/project/cypress/e2e/login.cy.js +35 -0
- package/project/cypress/e2e/selectbar.cy.js +80 -0
- package/project/cypress/fixtures/CONFIG/MENU_CONFIG.js +39 -0
- package/project/cypress/fixtures/EMPEROR/EMPERORS_GET.json +51 -0
- package/project/cypress/fixtures/EMPEROR/EMPERORS_POST.json +9 -0
- package/project/cypress/fixtures/OAUTH/GITHUB/user.json +46 -0
- package/project/cypress/fixtures/example.json +5 -0
- package/project/cypress/support/commands.js +104 -0
- package/project/cypress/support/e2e.js +1 -0
- package/project/cypress.config.js +10 -0
- package/project/index.html +12 -0
- package/project/media/ProjectIcons/3d.png +0 -0
- package/project/media/ProjectIcons/box.png +0 -0
- package/project/media/ProjectIcons/cafe.png +0 -0
- package/project/media/ProjectIcons/cargo.png +0 -0
- package/project/media/ProjectIcons/cloud.png +0 -0
- package/project/media/ProjectIcons/code.png +0 -0
- package/project/media/ProjectIcons/company.png +0 -0
- package/project/media/ProjectIcons/conversation.png +0 -0
- package/project/media/ProjectIcons/distributed.png +0 -0
- package/project/media/ProjectIcons/fingerprint.png +0 -0
- package/project/media/ProjectIcons/forest.png +0 -0
- package/project/media/ProjectIcons/headphones.png +0 -0
- package/project/media/ProjectIcons/office.png +0 -0
- package/project/media/ProjectIcons/path.png +0 -0
- package/project/media/ProjectIcons/printer.png +0 -0
- package/project/media/ProjectIcons/project.png +0 -0
- package/project/media/ProjectIcons/resume.png +0 -0
- package/project/media/ProjectIcons/rocket.png +0 -0
- package/project/media/ProjectIcons/rtruck.png +0 -0
- package/project/media/ProjectIcons/sign.png +0 -0
- package/project/media/ProjectIcons/site.png +0 -0
- package/project/media/ProjectIcons/truck.png +0 -0
- package/project/media/logo.png +0 -0
- package/project/package-lock.json +22434 -0
- package/project/package.json +42 -0
- package/project/public/assets/background/overlay_2.jpg +0 -0
- package/project/public/assets/illustrations/illustration_dashboard.png +0 -0
- package/project/public/media/largeLogo.png +0 -0
- package/project/public/media/logo.png +0 -0
- package/project/public/vite.svg +1 -0
- package/project/routes.jsx +47 -0
- package/project/server/mock.json +110 -0
- package/project/server/oauthMock.js +27 -0
- package/project/server/package-lock.json +1505 -0
- package/project/server/package.json +20 -0
- package/project/server/server.js +127 -0
- package/project/src/Container.jsx +7 -0
- package/project/src/components/ActionButton.jsx +18 -0
- package/project/src/hooks/useEmperor.jsx +21 -0
- package/project/src/http/index.js +39 -0
- package/project/src/main.jsx +10 -0
- package/project/src/pages/Battles.jsx +16 -0
- package/project/src/pages/Emperor.jsx +50 -0
- package/project/src/pages/index.jsx +33 -0
- package/project/src/theme.js +151 -0
- package/project/src/widgets/ActionButton.jsx +68 -0
- package/project/src/widgets/AddNewEmperor.jsx +120 -0
- package/project/src/widgets/ProjectContainer.jsx +27 -0
- package/project/vite.config.js +6 -0
- package/project/vite.config.js.timestamp-1709564450418-45fdd27900806.mjs +341 -0
- package/public/assets/background/overlay_2.jpg +0 -0
- package/public/assets/illustrations/illustration_dashboard.png +0 -0
- package/public/vite.svg +1 -0
- package/src/ContextProvider/ContextProvider.jsx +19 -0
- package/src/GlobalSnackMessage/GlobalSnackMessage.jsx +45 -0
- package/src/GlobalSnackMessage/index.js +1 -0
- package/src/GlobalSnackMessage/styles.js +3 -0
- package/src/Platform.jsx +76 -0
- package/src/RouteManager/RouteManager.jsx +56 -0
- package/src/RouteManager/index.js +1 -0
- package/src/assets/illustrations/avatar-shape.jsx +31 -0
- package/src/assets/illustrations/background-shape.jsx +37 -0
- package/src/assets/illustrations/booking-illustration.jsx +335 -0
- package/src/assets/illustrations/check-in-illustration.jsx +96 -0
- package/src/assets/illustrations/check-out-illustration.jsx +69 -0
- package/src/assets/illustrations/coming-soon-illustration.jsx +125 -0
- package/src/assets/illustrations/forbidden-illustration.jsx +95 -0
- package/src/assets/illustrations/index.js +2 -0
- package/src/assets/illustrations/maintenance-illustration.jsx +228 -0
- package/src/assets/illustrations/motivation-illustration.jsx +74 -0
- package/src/assets/illustrations/order-complete-illustration.jsx +126 -0
- package/src/assets/illustrations/page-not-found-illustration.jsx +81 -0
- package/src/assets/illustrations/seo-illustration.jsx +244 -0
- package/src/assets/illustrations/sever-error-illustration.jsx +152 -0
- package/src/assets/illustrations/upgrade-storage-illustration.jsx +161 -0
- package/src/assets/illustrations/upload-illustration.jsx +622 -0
- package/src/components/Iconify/Iconify.jsx +18 -0
- package/src/components/Iconify/index.js +1 -0
- package/src/components/MiniTopBar/MiniTopBar.jsx +25 -0
- package/src/components/MiniTopBar/index.js +1 -0
- package/src/components/MiniTopBar/styles.js +6 -0
- package/src/components/NucleoidLoginForm/NucleoidLoginForm.jsx +69 -0
- package/src/components/NucleoidLoginForm/index.js +1 -0
- package/src/components/NucleoidLoginForm/styles.js +3 -0
- package/src/components/Sidebar/Sidebar.jsx +76 -0
- package/src/components/Sidebar/index.js +1 -0
- package/src/components/Sidebar/styles.js +25 -0
- package/src/components/SocialLoginButtons/SocialLoginButtons.jsx +55 -0
- package/src/components/SocialLoginButtons/index.js +1 -0
- package/src/components/SocialLoginButtons/styles.js +3 -0
- package/src/components/TopNavBar/TopNavBar.jsx +186 -0
- package/src/components/TopNavBar/index.js +1 -0
- package/src/components/TopNavBar/styles.js +7 -0
- package/src/components/animate/index.js +4 -0
- package/src/components/animate/motion-container.jsx +38 -0
- package/src/components/animate/motion-lazy.jsx +11 -0
- package/src/components/animate/motion-viewport.jsx +30 -0
- package/src/components/animate/variants/actions.js +4 -0
- package/src/components/animate/variants/background.js +97 -0
- package/src/components/animate/variants/bounce.js +107 -0
- package/src/components/animate/variants/container.js +20 -0
- package/src/components/animate/variants/fade.js +127 -0
- package/src/components/animate/variants/flip.js +54 -0
- package/src/components/animate/variants/index.js +12 -0
- package/src/components/animate/variants/path.js +12 -0
- package/src/components/animate/variants/rotate.js +33 -0
- package/src/components/animate/variants/scale.js +54 -0
- package/src/components/animate/variants/slide.js +65 -0
- package/src/components/animate/variants/transition.js +20 -0
- package/src/components/animate/variants/zoom.js +130 -0
- package/src/components/chart/chart.js +69 -0
- package/src/components/chart/index.js +5 -0
- package/src/components/chart/use-chart.js +215 -0
- package/src/components/custom-popover/custom-popover.jsx +46 -0
- package/src/components/custom-popover/index.js +3 -0
- package/src/components/custom-popover/styles.js +84 -0
- package/src/components/custom-popover/use-popover.js +22 -0
- package/src/components/custom-popover/utils.js +100 -0
- package/src/components/file-thumbnail/download-button.jsx +39 -0
- package/src/components/file-thumbnail/file-thumbnail.jsx +72 -0
- package/src/components/file-thumbnail/index.js +5 -0
- package/src/components/file-thumbnail/utils.js +148 -0
- package/src/components/image/image.jsx +119 -0
- package/src/components/image/index.js +1 -0
- package/src/components/image/utils.js +15 -0
- package/src/components/label/index.js +1 -0
- package/src/components/label/label.jsx +51 -0
- package/src/components/label/styles.js +78 -0
- package/src/components/loading-screen/index.js +2 -0
- package/src/components/loading-screen/loading-screen.jsx +23 -0
- package/src/components/loading-screen/splash-screen.jsx +95 -0
- package/src/components/logo/index.js +1 -0
- package/src/components/logo/logo.jsx +61 -0
- package/src/components/logo/styles.js +17 -0
- package/src/components/nav-section/horizontal/index.js +1 -0
- package/src/components/nav-section/horizontal/nav-item.jsx +224 -0
- package/src/components/nav-section/horizontal/nav-list.jsx +113 -0
- package/src/components/nav-section/horizontal/nav-section-horizontal.jsx +41 -0
- package/src/components/nav-section/index.js +3 -0
- package/src/components/nav-section/mini/index.js +1 -0
- package/src/components/nav-section/mini/nav-item.jsx +242 -0
- package/src/components/nav-section/mini/nav-list.jsx +107 -0
- package/src/components/nav-section/mini/nav-section-mini.jsx +35 -0
- package/src/components/nav-section/vertical/index.js +1 -0
- package/src/components/nav-section/vertical/nav-item.jsx +294 -0
- package/src/components/nav-section/vertical/nav-list.jsx +66 -0
- package/src/components/nav-section/vertical/nav-section-vertical.jsx +74 -0
- package/src/components/scrollbar/index.js +1 -0
- package/src/components/scrollbar/scrollbar.jsx +39 -0
- package/src/components/scrollbar/styles.js +27 -0
- package/src/components/search-not-found/index.js +1 -0
- package/src/components/search-not-found/search-not-found.jsx +29 -0
- package/src/components/settings/context/index.js +2 -0
- package/src/components/settings/context/settings-context.js +14 -0
- package/src/components/settings/context/settings-provider.jsx +46 -0
- package/src/components/settings/drawer/base-option.jsx +52 -0
- package/src/components/settings/drawer/fullscreen-option.jsx +58 -0
- package/src/components/settings/drawer/index.js +1 -0
- package/src/components/settings/drawer/layout-options.jsx +144 -0
- package/src/components/settings/drawer/presets-options.jsx +53 -0
- package/src/components/settings/drawer/settings-drawer.jsx +189 -0
- package/src/components/settings/drawer/stretch-options.jsx +67 -0
- package/src/components/settings/index.js +3 -0
- package/src/components/svg-color/index.js +1 -0
- package/src/components/svg-color/svg-color.jsx +23 -0
- package/src/config/config.js +48 -0
- package/src/config/schemas.js +148 -0
- package/src/context/reducer.js +52 -0
- package/src/global.css +2 -0
- package/src/hooks/index.js +2 -0
- package/src/hooks/use-boolean.js +27 -0
- package/src/hooks/use-event-listener.js +34 -0
- package/src/hooks/use-local-storage.js +89 -0
- package/src/hooks/use-off-set-top.js +37 -0
- package/src/hooks/use-responsive.js +47 -0
- package/src/hooks/use-scroll-to-top.js +14 -0
- package/src/hooks/use-user.js +58 -0
- package/src/hooks/useApi.js +25 -0
- package/src/hooks/useItemsState.js +23 -0
- package/src/hooks/useProjects.js +24 -0
- package/src/hooks/useSettings.jsx +51 -0
- package/src/http/index.js +155 -0
- package/src/http/oauth.js +27 -0
- package/src/http/user.js +110 -0
- package/src/layouts/AppLayout.jsx +113 -0
- package/src/layouts/CompactLayout/CompactLayout.jsx +32 -0
- package/src/layouts/CompactLayout/index.js +1 -0
- package/src/layouts/DashboardLayout/DashboardLayout.jsx +87 -0
- package/src/layouts/DashboardLayout/config-navigation.jsx +0 -0
- package/src/layouts/DashboardLayout/header.jsx +104 -0
- package/src/layouts/DashboardLayout/index.js +2 -0
- package/src/layouts/DashboardLayout/main.jsx +64 -0
- package/src/layouts/DashboardLayout/nav-horizontal.jsx +62 -0
- package/src/layouts/DashboardLayout/nav-mini.jsx +99 -0
- package/src/layouts/DashboardLayout/nav-vertical.jsx +201 -0
- package/src/layouts/FullScreenLayout/FullScreenLayout.jsx +101 -0
- package/src/layouts/FullScreenLayout/index.js +1 -0
- package/src/layouts/FullScreenLayout/nav-horizontal.jsx +50 -0
- package/src/layouts/FullScreenLayout/nav-vertical.jsx +136 -0
- package/src/layouts/MainLayout/MainLayout.jsx +21 -0
- package/src/layouts/MainLayout/footer.jsx +153 -0
- package/src/layouts/MainLayout/header.jsx +81 -0
- package/src/layouts/MainLayout/index.js +1 -0
- package/src/layouts/MainLayout/nav/desktop/index.jsx +20 -0
- package/src/layouts/MainLayout/nav/desktop/nav-item.jsx +186 -0
- package/src/layouts/MainLayout/nav/desktop/nav-list.jsx +145 -0
- package/src/layouts/MainLayout/nav/mobile/index.jsx +60 -0
- package/src/layouts/MainLayout/nav/mobile/nav-item.jsx +90 -0
- package/src/layouts/MainLayout/nav/mobile/nav-list.jsx +72 -0
- package/src/layouts/Page.jsx +16 -0
- package/src/layouts/SimpleLayout/SimpleLayout.jsx +8 -0
- package/src/layouts/SimpleLayout/index.js +1 -0
- package/src/layouts/TwoSideLayout/TwoSideLayout.jsx +31 -0
- package/src/layouts/TwoSideLayout/index.js +1 -0
- package/src/layouts/auth/classic.jsx +95 -0
- package/src/layouts/auth/modern-compact.jsx +51 -0
- package/src/layouts/auth/modern.jsx +94 -0
- package/src/layouts/common/ProjectBar/index.jsx +325 -0
- package/src/layouts/common/ProjectBar/result-item.jsx +90 -0
- package/src/layouts/common/ProjectBar/utils.js +86 -0
- package/src/layouts/common/account-popover.jsx +116 -0
- package/src/layouts/common/header-shadow.jsx +26 -0
- package/src/layouts/common/header-sim.jsx +52 -0
- package/src/layouts/common/header-simple.jsx +76 -0
- package/src/layouts/common/nav-toggle-button.jsx +57 -0
- package/src/layouts/common/notifications-popover/index.jsx +177 -0
- package/src/layouts/common/notifications-popover/notification-item.jsx +252 -0
- package/src/layouts/common/settings-button.jsx +48 -0
- package/src/layouts/config-layout.js +12 -0
- package/src/layouts/index.js +7 -0
- package/src/lib/AddItemWizard/AddItemWizard.jsx +211 -0
- package/src/lib/AddItemWizard/index.js +1 -0
- package/src/lib/CustomBreadcrumbs/CustomBreadcrumbs.jsx +88 -0
- package/src/lib/CustomBreadcrumbs/index.js +1 -0
- package/src/lib/CustomBreadcrumbs/link-item.jsx +58 -0
- package/src/lib/CustomPopover/CustomPopover.jsx +46 -0
- package/src/lib/CustomPopover/index.js +3 -0
- package/src/lib/CustomPopover/styles.js +82 -0
- package/src/lib/CustomPopover/usePopover.js +20 -0
- package/src/lib/CustomPopover/utils.js +100 -0
- package/src/lib/Flow/connectors/DynamicConnector.jsx +247 -0
- package/src/lib/Flow/core/Flow.jsx +79 -0
- package/src/lib/Flow/core/FlowNode.jsx +68 -0
- package/src/lib/Flow/core/FlowViewport.jsx +259 -0
- package/src/lib/Flow/graph/FloatingGraph.jsx +44 -0
- package/src/lib/Flow/hooks/useGraphOperations.js +362 -0
- package/src/lib/Flow/hooks/useNodeStyle.js +56 -0
- package/src/lib/Flow/index.js +1 -0
- package/src/lib/Flow/layouts/ActionNode.jsx +78 -0
- package/src/lib/Flow/layouts/AnimatedNode.jsx +22 -0
- package/src/lib/Flow/layouts/CardLayout.jsx +397 -0
- package/src/lib/Flow/layouts/InfoNode.jsx +255 -0
- package/src/lib/Flow/layouts/LoadingNode.jsx +37 -0
- package/src/lib/Flow/nodes/DefaultCard.jsx +107 -0
- package/src/lib/Flow/nodes/DraggableNode.jsx +162 -0
- package/src/lib/Flow/nodes/FlowNodeView.jsx +214 -0
- package/src/lib/Flow/selection/SelectionContext.jsx +259 -0
- package/src/lib/Flow/selection/SelectionOverlay.jsx +31 -0
- package/src/lib/Flow/styles.js +154 -0
- package/src/lib/Flow/utils/flowUtils.js +268 -0
- package/src/lib/FormProvider/FormProvider.jsx +16 -0
- package/src/lib/FormProvider/index.js +1 -0
- package/src/lib/IconSelector/IconSelector.jsx +89 -0
- package/src/lib/Iconify/Iconify.jsx +17 -0
- package/src/lib/Iconify/index.js +1 -0
- package/src/lib/Image/Image.jsx +116 -0
- package/src/lib/Image/index.js +1 -0
- package/src/lib/Image/utils.js +15 -0
- package/src/lib/ItemSummary/ItemSummary.jsx +77 -0
- package/src/lib/ItemSummary/ItemsSummary.jsx +163 -0
- package/src/lib/Label/Label.jsx +51 -0
- package/src/lib/Label/index.js +1 -0
- package/src/lib/Label/styles.js +76 -0
- package/src/lib/ProjectWizard.jsx +137 -0
- package/src/lib/RHFTextfield/RHFTextfield.jsx +39 -0
- package/src/lib/RHFTextfield/index.js +1 -0
- package/src/lib/Scrollbar/Scrollbar.jsx +39 -0
- package/src/lib/Scrollbar/index.js +1 -0
- package/src/lib/Scrollbar/styles.js +27 -0
- package/src/lib/SearchNotFound/SearchNotFound.jsx +29 -0
- package/src/lib/SearchNotFound/index.js +1 -0
- package/src/lib/SparkleInput/SparkleInput.jsx +51 -0
- package/src/lib/StepComponent/StepComponent.jsx +98 -0
- package/src/lib/SvgColor/SvgColor.jsx +28 -0
- package/src/lib/SvgColor/index.js +1 -0
- package/src/lib/TableHeadCustom/TableHeadCustom.jsx +87 -0
- package/src/lib/TableHeadCustom/index.js +1 -0
- package/src/lib/TableSelectedAction/TableSelectedAction.jsx +72 -0
- package/src/lib/TableSelectedAction/index.js +1 -0
- package/src/lib/index.js +36 -0
- package/src/lib/lib/Icons.js +40 -0
- package/src/lib/lib/context.json +272 -0
- package/src/lib/useChart/useChart.js +179 -0
- package/src/lib/useTable/useTable.js +121 -0
- package/src/pages/404.jsx +17 -0
- package/src/pages/Callback.jsx +126 -0
- package/src/pages/ConfigError.jsx +49 -0
- package/src/pages/LoginPage.jsx +43 -0
- package/src/routes/components/index.js +1 -0
- package/src/routes/components/router-link.jsx +11 -0
- package/src/routes/hooks/index.js +4 -0
- package/src/routes/hooks/use-active-link.js +15 -0
- package/src/routes/hooks/use-pathname.js +10 -0
- package/src/routes/hooks/use-router.js +21 -0
- package/src/stories/FlowChart.stories.jsx +333 -0
- package/src/stories/Iconify.stories.jsx +183 -0
- package/src/stories/Label.stories.jsx +447 -0
- package/src/stories/Navbar.stories.jsx +588 -0
- package/src/theme/css.js +152 -0
- package/src/theme/custom-shadows.js +47 -0
- package/src/theme/index.jsx +100 -0
- package/src/theme/options/contrast.js +34 -0
- package/src/theme/options/presets.js +89 -0
- package/src/theme/options/right-to-left.jsx +26 -0
- package/src/theme/overrides/components/accordion.js +43 -0
- package/src/theme/overrides/components/alert.js +69 -0
- package/src/theme/overrides/components/appbar.js +13 -0
- package/src/theme/overrides/components/autocomplete.js +44 -0
- package/src/theme/overrides/components/avatar.js +111 -0
- package/src/theme/overrides/components/backdrop.js +18 -0
- package/src/theme/overrides/components/badge.js +90 -0
- package/src/theme/overrides/components/breadcrumbs.js +21 -0
- package/src/theme/overrides/components/button-group.js +90 -0
- package/src/theme/overrides/components/button.js +145 -0
- package/src/theme/overrides/components/card.js +30 -0
- package/src/theme/overrides/components/checkbox.js +13 -0
- package/src/theme/overrides/components/chip.js +129 -0
- package/src/theme/overrides/components/css-baseline.js +48 -0
- package/src/theme/overrides/components/data-grid.js +94 -0
- package/src/theme/overrides/components/date-picker.jsx +94 -0
- package/src/theme/overrides/components/dialog.js +49 -0
- package/src/theme/overrides/components/drawer.js +39 -0
- package/src/theme/overrides/components/fab.js +165 -0
- package/src/theme/overrides/components/list.js +33 -0
- package/src/theme/overrides/components/loading-button.js +30 -0
- package/src/theme/overrides/components/menu.js +15 -0
- package/src/theme/overrides/components/pagination.js +81 -0
- package/src/theme/overrides/components/paper.js +18 -0
- package/src/theme/overrides/components/popover.js +20 -0
- package/src/theme/overrides/components/progress.js +40 -0
- package/src/theme/overrides/components/radio.js +22 -0
- package/src/theme/overrides/components/rating.js +40 -0
- package/src/theme/overrides/components/select.js +26 -0
- package/src/theme/overrides/components/skeleton.js +16 -0
- package/src/theme/overrides/components/slider.js +30 -0
- package/src/theme/overrides/components/stepper.js +13 -0
- package/src/theme/overrides/components/svg-icon.js +15 -0
- package/src/theme/overrides/components/switch.js +66 -0
- package/src/theme/overrides/components/table.js +79 -0
- package/src/theme/overrides/components/tabs.js +39 -0
- package/src/theme/overrides/components/textfield.js +146 -0
- package/src/theme/overrides/components/timeline.js +20 -0
- package/src/theme/overrides/components/toggle-button.js +70 -0
- package/src/theme/overrides/components/tooltip.js +18 -0
- package/src/theme/overrides/components/tree-view.js +16 -0
- package/src/theme/overrides/components/typography.js +16 -0
- package/src/theme/overrides/default-props.jsx +238 -0
- package/src/theme/overrides/index.js +100 -0
- package/src/theme/palette.js +144 -0
- package/src/theme/shadows.js +41 -0
- package/src/theme/typography.js +107 -0
- package/src/utils/flatten-array.js +16 -0
- package/src/utils/format-number.js +37 -0
- package/src/utils/format-time.js +27 -0
- package/src/utils/storage-available.js +24 -0
- package/src/widgets/Login/CognitoLogin.jsx +43 -0
- package/src/widgets/Login/Login.jsx +58 -0
- package/src/widgets/Login/cognitoAuth.jsx +26 -0
- package/src/widgets/LoginForm/LoginForm.jsx +87 -0
- package/src/widgets/LoginForm/LoginFormStyles.js +43 -0
- package/src/widgets/LoginForm/index.js +1 -0
- package/src/widgets/SettingsDialog.jsx +308 -0
- package/src/widgets/error/index.js +1 -0
- package/src/widgets/error/not-found-view.jsx +42 -0
- package/vite/vite.js +77 -0
- package/vite.config.js +7 -0
- package/vitest.config.js +32 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import React, { useId, useLayoutEffect, useMemo, useState } from "react";
|
|
2
|
+
|
|
3
|
+
const DynamicConnector = ({
|
|
4
|
+
containerEl,
|
|
5
|
+
parentEl,
|
|
6
|
+
childEls,
|
|
7
|
+
stroke = "#b1b1b7",
|
|
8
|
+
strokeWidth = 2,
|
|
9
|
+
lineStyle = "solid",
|
|
10
|
+
tick = 0,
|
|
11
|
+
orientation = "vertical",
|
|
12
|
+
showDots = false,
|
|
13
|
+
dotRadius = 4,
|
|
14
|
+
dotColor,
|
|
15
|
+
showArrow = true,
|
|
16
|
+
arrowSize = 6,
|
|
17
|
+
animated = false,
|
|
18
|
+
animationSpeed = 1,
|
|
19
|
+
gradient = null,
|
|
20
|
+
curvature = 0.5,
|
|
21
|
+
}) => {
|
|
22
|
+
const uniqueId = useId();
|
|
23
|
+
const [dims, setDims] = useState(null);
|
|
24
|
+
const [points, setPoints] = useState({
|
|
25
|
+
parent: null,
|
|
26
|
+
children: [],
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const isHorizontal = orientation === "horizontal";
|
|
30
|
+
|
|
31
|
+
useLayoutEffect(() => {
|
|
32
|
+
if (!containerEl || !parentEl || !childEls?.length) return;
|
|
33
|
+
|
|
34
|
+
const update = () => {
|
|
35
|
+
const cRect = containerEl.getBoundingClientRect();
|
|
36
|
+
const pRect = parentEl.getBoundingClientRect();
|
|
37
|
+
|
|
38
|
+
let parentPoint;
|
|
39
|
+
let childPoints = [];
|
|
40
|
+
|
|
41
|
+
if (isHorizontal) {
|
|
42
|
+
parentPoint = {
|
|
43
|
+
x: pRect.right - cRect.left,
|
|
44
|
+
y: pRect.top + pRect.height / 2 - cRect.top,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
childPoints = childEls.map((el) => {
|
|
48
|
+
if (!el) return { x: parentPoint.x + 100, y: parentPoint.y };
|
|
49
|
+
const r = el.getBoundingClientRect();
|
|
50
|
+
return {
|
|
51
|
+
x: r.left - cRect.left,
|
|
52
|
+
y: r.top + r.height / 2 - cRect.top,
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
parentPoint = {
|
|
57
|
+
x: pRect.left + pRect.width / 2 - cRect.left,
|
|
58
|
+
y: pRect.bottom - cRect.top,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
childPoints = childEls.map((el) => {
|
|
62
|
+
if (!el) return { x: parentPoint.x, y: parentPoint.y + 100 };
|
|
63
|
+
const r = el.getBoundingClientRect();
|
|
64
|
+
return {
|
|
65
|
+
x: r.left + r.width / 2 - cRect.left,
|
|
66
|
+
y: r.top - cRect.top,
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
setPoints({ parent: parentPoint, children: childPoints });
|
|
72
|
+
setDims({ w: cRect.width, h: cRect.height });
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
update();
|
|
76
|
+
|
|
77
|
+
const ro = new ResizeObserver(update);
|
|
78
|
+
ro.observe(containerEl);
|
|
79
|
+
ro.observe(parentEl);
|
|
80
|
+
childEls.forEach((el) => el && ro.observe(el));
|
|
81
|
+
|
|
82
|
+
return () => ro.disconnect();
|
|
83
|
+
}, [containerEl, parentEl, childEls, tick, isHorizontal]);
|
|
84
|
+
|
|
85
|
+
const ids = useMemo(
|
|
86
|
+
() => ({
|
|
87
|
+
gradient: `gradient-${uniqueId}`,
|
|
88
|
+
arrow: `arrow-${uniqueId}`,
|
|
89
|
+
}),
|
|
90
|
+
[uniqueId]
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const getPath = (from, to) => {
|
|
94
|
+
const dx = Math.abs(to.x - from.x);
|
|
95
|
+
const dy = Math.abs(to.y - from.y);
|
|
96
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
97
|
+
|
|
98
|
+
const baseCurvature = Math.max(40, Math.min(distance * curvature, 150));
|
|
99
|
+
|
|
100
|
+
if (isHorizontal) {
|
|
101
|
+
const cp1x = from.x + baseCurvature;
|
|
102
|
+
const cp2x = to.x - baseCurvature;
|
|
103
|
+
return `M ${from.x} ${from.y} C ${cp1x} ${from.y}, ${cp2x} ${to.y}, ${to.x} ${to.y}`;
|
|
104
|
+
} else {
|
|
105
|
+
const cp1y = from.y + baseCurvature;
|
|
106
|
+
const cp2y = to.y - baseCurvature;
|
|
107
|
+
return `M ${from.x} ${from.y} C ${from.x} ${cp1y}, ${to.x} ${cp2y}, ${to.x} ${to.y}`;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const getDashArray = () => {
|
|
112
|
+
if (lineStyle === "dashed") return `${strokeWidth * 4},${strokeWidth * 3}`;
|
|
113
|
+
if (lineStyle === "dotted") return `${strokeWidth},${strokeWidth * 2}`;
|
|
114
|
+
return undefined;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const animationStyle = animated
|
|
118
|
+
? `
|
|
119
|
+
@keyframes flowAnimation {
|
|
120
|
+
from { stroke-dashoffset: 24; }
|
|
121
|
+
to { stroke-dashoffset: 0; }
|
|
122
|
+
}
|
|
123
|
+
`
|
|
124
|
+
: "";
|
|
125
|
+
|
|
126
|
+
if (!dims || !points.parent || !points.children.length) return null;
|
|
127
|
+
|
|
128
|
+
const effectiveDotColor = dotColor || stroke;
|
|
129
|
+
const dashArray = getDashArray();
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<svg
|
|
133
|
+
style={{
|
|
134
|
+
position: "absolute",
|
|
135
|
+
inset: 0,
|
|
136
|
+
pointerEvents: "none",
|
|
137
|
+
overflow: "visible",
|
|
138
|
+
zIndex: 0,
|
|
139
|
+
}}
|
|
140
|
+
width="100%"
|
|
141
|
+
height="100%"
|
|
142
|
+
viewBox={`0 0 ${dims.w} ${dims.h}`}
|
|
143
|
+
>
|
|
144
|
+
<defs>
|
|
145
|
+
{gradient && (
|
|
146
|
+
<linearGradient
|
|
147
|
+
id={ids.gradient}
|
|
148
|
+
gradientUnits="userSpaceOnUse"
|
|
149
|
+
x1={points.parent.x}
|
|
150
|
+
y1={points.parent.y}
|
|
151
|
+
x2={points.children[0]?.x || points.parent.x}
|
|
152
|
+
y2={points.children[0]?.y || points.parent.y}
|
|
153
|
+
>
|
|
154
|
+
<stop offset="0%" stopColor={gradient.from} />
|
|
155
|
+
<stop offset="100%" stopColor={gradient.to} />
|
|
156
|
+
</linearGradient>
|
|
157
|
+
)}
|
|
158
|
+
|
|
159
|
+
{showArrow && (
|
|
160
|
+
<marker
|
|
161
|
+
id={ids.arrow}
|
|
162
|
+
viewBox="0 0 10 10"
|
|
163
|
+
refX="9"
|
|
164
|
+
refY="5"
|
|
165
|
+
markerWidth={arrowSize}
|
|
166
|
+
markerHeight={arrowSize}
|
|
167
|
+
orient="auto-start-reverse"
|
|
168
|
+
>
|
|
169
|
+
<path
|
|
170
|
+
d="M 0 0 L 10 5 L 0 10 z"
|
|
171
|
+
fill={gradient ? `url(#${ids.gradient})` : stroke}
|
|
172
|
+
/>
|
|
173
|
+
</marker>
|
|
174
|
+
)}
|
|
175
|
+
|
|
176
|
+
{animated && <style>{animationStyle}</style>}
|
|
177
|
+
</defs>
|
|
178
|
+
|
|
179
|
+
{points.children.map((child, i) => {
|
|
180
|
+
const pathD = getPath(points.parent, child);
|
|
181
|
+
const pathStroke = gradient ? `url(#${ids.gradient})` : stroke;
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<g key={i}>
|
|
185
|
+
<path
|
|
186
|
+
d={pathD}
|
|
187
|
+
fill="none"
|
|
188
|
+
stroke={pathStroke}
|
|
189
|
+
strokeWidth={strokeWidth}
|
|
190
|
+
strokeDasharray={animated ? "8,4" : dashArray}
|
|
191
|
+
strokeLinecap="round"
|
|
192
|
+
strokeLinejoin="round"
|
|
193
|
+
markerEnd={showArrow ? `url(#${ids.arrow})` : undefined}
|
|
194
|
+
style={{
|
|
195
|
+
transition: "stroke 0.2s ease, stroke-width 0.2s ease",
|
|
196
|
+
...(animated
|
|
197
|
+
? {
|
|
198
|
+
animation: `flowAnimation ${
|
|
199
|
+
0.5 / animationSpeed
|
|
200
|
+
}s linear infinite`,
|
|
201
|
+
}
|
|
202
|
+
: {}),
|
|
203
|
+
}}
|
|
204
|
+
/>
|
|
205
|
+
</g>
|
|
206
|
+
);
|
|
207
|
+
})}
|
|
208
|
+
|
|
209
|
+
{showDots && (
|
|
210
|
+
<>
|
|
211
|
+
<circle
|
|
212
|
+
cx={points.parent.x}
|
|
213
|
+
cy={points.parent.y}
|
|
214
|
+
r={dotRadius}
|
|
215
|
+
fill={gradient ? gradient.from : effectiveDotColor}
|
|
216
|
+
stroke="#fff"
|
|
217
|
+
strokeWidth={1.5}
|
|
218
|
+
style={{
|
|
219
|
+
filter: "drop-shadow(0 1px 2px rgba(0,0,0,0.15))",
|
|
220
|
+
}}
|
|
221
|
+
/>
|
|
222
|
+
|
|
223
|
+
{points.children.map((child, i) => {
|
|
224
|
+
const dotFill = gradient ? gradient.to : effectiveDotColor;
|
|
225
|
+
|
|
226
|
+
return (
|
|
227
|
+
<circle
|
|
228
|
+
key={i}
|
|
229
|
+
cx={child.x}
|
|
230
|
+
cy={child.y}
|
|
231
|
+
r={dotRadius}
|
|
232
|
+
fill={dotFill}
|
|
233
|
+
stroke="#fff"
|
|
234
|
+
strokeWidth={1.5}
|
|
235
|
+
style={{
|
|
236
|
+
filter: "drop-shadow(0 1px 2px rgba(0,0,0,0.15))",
|
|
237
|
+
}}
|
|
238
|
+
/>
|
|
239
|
+
);
|
|
240
|
+
})}
|
|
241
|
+
</>
|
|
242
|
+
)}
|
|
243
|
+
</svg>
|
|
244
|
+
);
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export default DynamicConnector;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import FlowNode from "./FlowNode";
|
|
2
|
+
import { useGraphOperations } from "../hooks/useGraphOperations";
|
|
3
|
+
|
|
4
|
+
import React, { useMemo, useState } from "react";
|
|
5
|
+
import { assertLinkedGraph, buildTreeFromLinked } from "../utils/flowUtils";
|
|
6
|
+
|
|
7
|
+
export const Flow = ({
|
|
8
|
+
data,
|
|
9
|
+
variant = "simple",
|
|
10
|
+
style,
|
|
11
|
+
plugin,
|
|
12
|
+
editable = false,
|
|
13
|
+
onChange,
|
|
14
|
+
}) => {
|
|
15
|
+
const [floatingNodes, setFloatingNodes] = useState([]);
|
|
16
|
+
|
|
17
|
+
const { nodesById, roots } = useMemo(() => assertLinkedGraph(data), [data]);
|
|
18
|
+
|
|
19
|
+
const { handleCut, handlePaste, handleConnect } = useGraphOperations({
|
|
20
|
+
nodesById,
|
|
21
|
+
roots,
|
|
22
|
+
onChange,
|
|
23
|
+
floatingNodes,
|
|
24
|
+
setFloatingNodes,
|
|
25
|
+
editable,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const allNodesById = useMemo(() => {
|
|
29
|
+
if (!floatingNodes.length) return nodesById;
|
|
30
|
+
|
|
31
|
+
const merged = { ...nodesById };
|
|
32
|
+
|
|
33
|
+
for (const structure of floatingNodes) {
|
|
34
|
+
if (structure?.nodes) {
|
|
35
|
+
Object.assign(merged, structure.nodes);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return merged;
|
|
40
|
+
}, [nodesById, floatingNodes]);
|
|
41
|
+
|
|
42
|
+
const treeData = useMemo(() => {
|
|
43
|
+
if (!roots?.length) return null;
|
|
44
|
+
|
|
45
|
+
if (roots.length === 1) {
|
|
46
|
+
return (
|
|
47
|
+
buildTreeFromLinked(roots[0], nodesById) || {
|
|
48
|
+
id: roots[0],
|
|
49
|
+
children: [],
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const children = roots
|
|
55
|
+
.map((r) => buildTreeFromLinked(r, nodesById))
|
|
56
|
+
.filter(Boolean);
|
|
57
|
+
|
|
58
|
+
return children.length > 0
|
|
59
|
+
? { id: "__root__", label: "Start", children }
|
|
60
|
+
: null;
|
|
61
|
+
}, [nodesById, roots]);
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<FlowNode
|
|
65
|
+
node={treeData}
|
|
66
|
+
variant={variant}
|
|
67
|
+
style={style}
|
|
68
|
+
plugin={plugin}
|
|
69
|
+
isRoot={true}
|
|
70
|
+
nodesById={allNodesById}
|
|
71
|
+
onPaste={editable ? handlePaste : undefined}
|
|
72
|
+
onCut={editable ? handleCut : undefined}
|
|
73
|
+
onConnect={editable ? handleConnect : undefined}
|
|
74
|
+
floatingNodes={floatingNodes}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default Flow;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import FlowNodeView from "../nodes/FlowNodeView";
|
|
2
|
+
import FlowViewport from "./FlowViewport";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { SelectionProvider } from "../selection/SelectionContext";
|
|
5
|
+
import { getBaseStyleForVariant } from "../styles";
|
|
6
|
+
|
|
7
|
+
const FlowNode = ({
|
|
8
|
+
isRoot = false,
|
|
9
|
+
onAddNode,
|
|
10
|
+
variant,
|
|
11
|
+
nodesById,
|
|
12
|
+
onPaste,
|
|
13
|
+
onCut,
|
|
14
|
+
onConnect,
|
|
15
|
+
floatingNodes,
|
|
16
|
+
style,
|
|
17
|
+
plugin,
|
|
18
|
+
node,
|
|
19
|
+
...props
|
|
20
|
+
}) => {
|
|
21
|
+
if (!isRoot) {
|
|
22
|
+
if (!node) return null;
|
|
23
|
+
return (
|
|
24
|
+
<FlowNodeView
|
|
25
|
+
node={node}
|
|
26
|
+
onAddNode={onAddNode}
|
|
27
|
+
variant={variant}
|
|
28
|
+
style={style}
|
|
29
|
+
plugin={plugin}
|
|
30
|
+
onConnect={onConnect}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const baseStyle = getBaseStyleForVariant(variant);
|
|
37
|
+
const selectionColor = baseStyle.selectionColor ?? "#64748b";
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<SelectionProvider>
|
|
41
|
+
<FlowViewport
|
|
42
|
+
selectionColor={selectionColor}
|
|
43
|
+
nodesById={nodesById}
|
|
44
|
+
onPaste={onPaste}
|
|
45
|
+
onCut={onCut}
|
|
46
|
+
onConnect={onConnect}
|
|
47
|
+
floatingNodes={floatingNodes}
|
|
48
|
+
variant={variant}
|
|
49
|
+
style={style}
|
|
50
|
+
plugin={plugin}
|
|
51
|
+
>
|
|
52
|
+
{node && (
|
|
53
|
+
<FlowNodeView
|
|
54
|
+
node={node}
|
|
55
|
+
onAddNode={onAddNode}
|
|
56
|
+
variant={variant}
|
|
57
|
+
style={style}
|
|
58
|
+
plugin={plugin}
|
|
59
|
+
onConnect={onConnect}
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
)}
|
|
63
|
+
</FlowViewport>
|
|
64
|
+
</SelectionProvider>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default FlowNode;
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { Box } from "@mui/material";
|
|
2
|
+
import FloatingGraph from "../graph/FloatingGraph";
|
|
3
|
+
import SelectionOverlay from "../selection/SelectionOverlay";
|
|
4
|
+
import { useSelection } from "../selection/SelectionContext";
|
|
5
|
+
|
|
6
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
7
|
+
|
|
8
|
+
const FlowViewport = ({
|
|
9
|
+
children,
|
|
10
|
+
selectionColor = "#64748b",
|
|
11
|
+
nodesById,
|
|
12
|
+
onPaste,
|
|
13
|
+
onCut,
|
|
14
|
+
onConnect,
|
|
15
|
+
floatingNodes = [],
|
|
16
|
+
variant,
|
|
17
|
+
style,
|
|
18
|
+
plugin,
|
|
19
|
+
}) => {
|
|
20
|
+
const clampZoom = (zoom) => Math.min(2.5, Math.max(0.25, zoom));
|
|
21
|
+
|
|
22
|
+
const [offset, setOffset] = useState({ x: 0, y: 0 });
|
|
23
|
+
const [zoom, setZoom] = useState(1);
|
|
24
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
25
|
+
const [selectionBox, setSelectionBox] = useState(null);
|
|
26
|
+
|
|
27
|
+
const containerRef = useRef(null);
|
|
28
|
+
const selectionBoxRef = useRef(null);
|
|
29
|
+
const mousePositionRef = useRef({ x: 0, y: 0 });
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
clearSelection,
|
|
33
|
+
selectMultiple,
|
|
34
|
+
addToSelection,
|
|
35
|
+
cutSelectedNodes,
|
|
36
|
+
pasteNodes,
|
|
37
|
+
selectedIds,
|
|
38
|
+
} = useSelection();
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const handleMouseMove = (e) => {
|
|
42
|
+
mousePositionRef.current = { x: e.clientX, y: e.clientY };
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
46
|
+
|
|
47
|
+
return () => {
|
|
48
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
49
|
+
};
|
|
50
|
+
}, []);
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
const onWheel = (e) => {
|
|
54
|
+
const wantsZoom = e.ctrlKey || e.metaKey;
|
|
55
|
+
if (!wantsZoom) return;
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
const direction = e.deltaY > 0 ? -1 : 1;
|
|
58
|
+
const factor = direction > 0 ? 1.1 : 1 / 1.1;
|
|
59
|
+
setZoom((z) => clampZoom(z * factor));
|
|
60
|
+
};
|
|
61
|
+
window.addEventListener("wheel", onWheel, { passive: false });
|
|
62
|
+
return () => window.removeEventListener("wheel", onWheel);
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
const handleKeyDown = (e) => {
|
|
67
|
+
const isMod = e.ctrlKey || e.metaKey;
|
|
68
|
+
if (!isMod) return;
|
|
69
|
+
|
|
70
|
+
if (e.key === "x" && selectedIds.size > 0 && nodesById) {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
cutSelectedNodes(nodesById, onCut);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (e.key === "v" && onPaste) {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
const containerRect = containerRef.current?.getBoundingClientRect();
|
|
78
|
+
const mousePos = mousePositionRef.current;
|
|
79
|
+
|
|
80
|
+
const canvasX = containerRect
|
|
81
|
+
? (mousePos.x -
|
|
82
|
+
containerRect.left -
|
|
83
|
+
containerRect.width / 2 -
|
|
84
|
+
offset.x) /
|
|
85
|
+
zoom
|
|
86
|
+
: 0;
|
|
87
|
+
const canvasY = containerRect
|
|
88
|
+
? (mousePos.y -
|
|
89
|
+
containerRect.top -
|
|
90
|
+
containerRect.height / 2 -
|
|
91
|
+
offset.y) /
|
|
92
|
+
zoom
|
|
93
|
+
: 0;
|
|
94
|
+
|
|
95
|
+
pasteNodes(onPaste, canvasX, canvasY);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
100
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
101
|
+
}, [
|
|
102
|
+
cutSelectedNodes,
|
|
103
|
+
pasteNodes,
|
|
104
|
+
selectedIds,
|
|
105
|
+
nodesById,
|
|
106
|
+
onPaste,
|
|
107
|
+
onCut,
|
|
108
|
+
offset,
|
|
109
|
+
zoom,
|
|
110
|
+
]);
|
|
111
|
+
|
|
112
|
+
const handleViewportMouseDown = (e) => {
|
|
113
|
+
if (e.target?.closest?.(".MuiCard-root") || e.target?.closest?.("button"))
|
|
114
|
+
return;
|
|
115
|
+
|
|
116
|
+
if (e.button !== 0) return;
|
|
117
|
+
|
|
118
|
+
const startX = e.clientX;
|
|
119
|
+
const startY = e.clientY;
|
|
120
|
+
|
|
121
|
+
if (e.shiftKey || e.ctrlKey || e.metaKey) {
|
|
122
|
+
setSelectionBox({ startX, startY, currentX: startX, currentY: startY });
|
|
123
|
+
selectionBoxRef.current = {
|
|
124
|
+
startX,
|
|
125
|
+
startY,
|
|
126
|
+
currentX: startX,
|
|
127
|
+
currentY: startY,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const onMove = (ev) => {
|
|
131
|
+
const newBox = {
|
|
132
|
+
startX,
|
|
133
|
+
startY,
|
|
134
|
+
currentX: ev.clientX,
|
|
135
|
+
currentY: ev.clientY,
|
|
136
|
+
};
|
|
137
|
+
setSelectionBox(newBox);
|
|
138
|
+
selectionBoxRef.current = newBox;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const onUp = () => {
|
|
142
|
+
if (containerRef.current && selectionBoxRef.current) {
|
|
143
|
+
const box = selectionBoxRef.current;
|
|
144
|
+
const nodes = containerRef.current.querySelectorAll("[data-node-id]");
|
|
145
|
+
const selectedNodeIds = [];
|
|
146
|
+
|
|
147
|
+
const boxLeft = Math.min(box.startX, box.currentX);
|
|
148
|
+
const boxRight = Math.max(box.startX, box.currentX);
|
|
149
|
+
const boxTop = Math.min(box.startY, box.currentY);
|
|
150
|
+
const boxBottom = Math.max(box.startY, box.currentY);
|
|
151
|
+
|
|
152
|
+
nodes.forEach((node) => {
|
|
153
|
+
const rect = node.getBoundingClientRect();
|
|
154
|
+
|
|
155
|
+
if (
|
|
156
|
+
rect.left < boxRight &&
|
|
157
|
+
rect.right > boxLeft &&
|
|
158
|
+
rect.top < boxBottom &&
|
|
159
|
+
rect.bottom > boxTop
|
|
160
|
+
) {
|
|
161
|
+
const nodeId = node.getAttribute("data-node-id");
|
|
162
|
+
if (nodeId) selectedNodeIds.push(nodeId);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
if (selectedNodeIds.length > 0) {
|
|
167
|
+
if (e.shiftKey) {
|
|
168
|
+
addToSelection(selectedNodeIds);
|
|
169
|
+
} else {
|
|
170
|
+
selectMultiple(selectedNodeIds);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
setSelectionBox(null);
|
|
176
|
+
selectionBoxRef.current = null;
|
|
177
|
+
window.removeEventListener("mousemove", onMove);
|
|
178
|
+
window.removeEventListener("mouseup", onUp);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
window.addEventListener("mousemove", onMove);
|
|
182
|
+
window.addEventListener("mouseup", onUp);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
clearSelection();
|
|
187
|
+
|
|
188
|
+
setIsDragging(true);
|
|
189
|
+
const startOffset = { ...offset };
|
|
190
|
+
|
|
191
|
+
const onMove = (ev) => {
|
|
192
|
+
setOffset({
|
|
193
|
+
x: startOffset.x + (ev.clientX - startX),
|
|
194
|
+
y: startOffset.y + (ev.clientY - startY),
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const onUp = () => {
|
|
199
|
+
setIsDragging(false);
|
|
200
|
+
window.removeEventListener("mousemove", onMove);
|
|
201
|
+
window.removeEventListener("mouseup", onUp);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
window.addEventListener("mousemove", onMove);
|
|
205
|
+
window.addEventListener("mouseup", onUp);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
return (
|
|
209
|
+
<Box
|
|
210
|
+
ref={containerRef}
|
|
211
|
+
onMouseDown={handleViewportMouseDown}
|
|
212
|
+
sx={{
|
|
213
|
+
width: "100vw",
|
|
214
|
+
height: "100vh",
|
|
215
|
+
overflow: "hidden",
|
|
216
|
+
bgcolor: "none",
|
|
217
|
+
cursor: isDragging ? "grabbing" : "default",
|
|
218
|
+
userSelect: "none",
|
|
219
|
+
position: "relative",
|
|
220
|
+
}}
|
|
221
|
+
>
|
|
222
|
+
<SelectionOverlay box={selectionBox} selectionColor={selectionColor} />
|
|
223
|
+
<Box
|
|
224
|
+
sx={{
|
|
225
|
+
transform: `translate(${offset.x}px, ${offset.y}px) scale(${zoom})`,
|
|
226
|
+
transformOrigin: "center center",
|
|
227
|
+
width: "100%",
|
|
228
|
+
height: "100%",
|
|
229
|
+
display: "flex",
|
|
230
|
+
alignItems: "center",
|
|
231
|
+
justifyContent: "center",
|
|
232
|
+
transition: isDragging ? "none" : "transform 0.1s ease-out",
|
|
233
|
+
pointerEvents: "auto",
|
|
234
|
+
position: "relative",
|
|
235
|
+
}}
|
|
236
|
+
>
|
|
237
|
+
{children}
|
|
238
|
+
{floatingNodes.map((structure, index) => {
|
|
239
|
+
const structureKey =
|
|
240
|
+
(structure && (structure.id || structure.key)) ??
|
|
241
|
+
`floating-${index}`;
|
|
242
|
+
return (
|
|
243
|
+
<FloatingGraph
|
|
244
|
+
key={structureKey}
|
|
245
|
+
structure={structure}
|
|
246
|
+
variant={variant}
|
|
247
|
+
style={style}
|
|
248
|
+
plugin={plugin}
|
|
249
|
+
selectionColor={selectionColor}
|
|
250
|
+
onConnect={onConnect}
|
|
251
|
+
/>
|
|
252
|
+
);
|
|
253
|
+
})}
|
|
254
|
+
</Box>
|
|
255
|
+
</Box>
|
|
256
|
+
);
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
export default FlowViewport;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Box } from "@mui/material";
|
|
2
|
+
import FlowNodeView from "../nodes/FlowNodeView";
|
|
3
|
+
import { buildDetachedTree } from "../utils/flowUtils";
|
|
4
|
+
|
|
5
|
+
import React, { useMemo } from "react";
|
|
6
|
+
|
|
7
|
+
const FloatingGraph = ({ structure, variant, style, plugin, onConnect }) => {
|
|
8
|
+
const position = structure?._pastePosition || { x: 0, y: 0 };
|
|
9
|
+
|
|
10
|
+
const treesData = useMemo(() => {
|
|
11
|
+
if (!structure?.roots?.length || !structure?.nodes) return [];
|
|
12
|
+
return structure.roots
|
|
13
|
+
.map((rootId) => buildDetachedTree(rootId, structure.nodes))
|
|
14
|
+
.filter(Boolean);
|
|
15
|
+
}, [structure]);
|
|
16
|
+
|
|
17
|
+
if (!treesData.length) return null;
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Box
|
|
21
|
+
sx={{
|
|
22
|
+
position: "absolute",
|
|
23
|
+
left: "50%",
|
|
24
|
+
top: "50%",
|
|
25
|
+
transform: `translate(${position.x}px, ${position.y}px)`,
|
|
26
|
+
display: "flex",
|
|
27
|
+
gap: 2,
|
|
28
|
+
}}
|
|
29
|
+
>
|
|
30
|
+
{treesData.map((tree, idx) => (
|
|
31
|
+
<FlowNodeView
|
|
32
|
+
key={tree.id || `floating-${idx}`}
|
|
33
|
+
node={tree}
|
|
34
|
+
variant={variant}
|
|
35
|
+
style={style}
|
|
36
|
+
plugin={plugin}
|
|
37
|
+
onConnect={onConnect}
|
|
38
|
+
/>
|
|
39
|
+
))}
|
|
40
|
+
</Box>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default FloatingGraph;
|