@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,259 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
createContext,
|
|
3
|
+
useCallback,
|
|
4
|
+
useContext,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
} from "react";
|
|
9
|
+
|
|
10
|
+
const SelectionContext = createContext(null);
|
|
11
|
+
|
|
12
|
+
const DEFAULT_CONTEXT = {
|
|
13
|
+
selectedIds: new Set(),
|
|
14
|
+
selectNode: () => {},
|
|
15
|
+
deselectNode: () => {},
|
|
16
|
+
toggleSelection: () => {},
|
|
17
|
+
clearSelection: () => {},
|
|
18
|
+
selectMultiple: () => {},
|
|
19
|
+
addToSelection: () => {},
|
|
20
|
+
isSelected: () => false,
|
|
21
|
+
registerNodeHandlers: () => () => {},
|
|
22
|
+
moveSelectedNodes: () => {},
|
|
23
|
+
cutSelectedNodes: () => {},
|
|
24
|
+
pasteNodes: () => {},
|
|
25
|
+
hasClipboard: false,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const filterNextToSelection = (next, selectedSet) => {
|
|
29
|
+
if (!next) return undefined;
|
|
30
|
+
|
|
31
|
+
if (Array.isArray(next)) {
|
|
32
|
+
const filtered = next.filter((id) => selectedSet.has(id));
|
|
33
|
+
return filtered.length > 0 ? filtered : undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return selectedSet.has(next) ? next : undefined;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const buildClipboardNode = (id, node, selectedSet) => {
|
|
40
|
+
const filteredNext = filterNextToSelection(node.next, selectedSet);
|
|
41
|
+
const hasPreviousInSelection =
|
|
42
|
+
node.previous && selectedSet.has(node.previous);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
...node,
|
|
46
|
+
id,
|
|
47
|
+
_originalId: id,
|
|
48
|
+
next: filteredNext,
|
|
49
|
+
previous: hasPreviousInSelection ? node.previous : undefined,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const buildPasteStructure = (clipboardNodes, position) => {
|
|
54
|
+
if (!clipboardNodes?.length) return null;
|
|
55
|
+
|
|
56
|
+
const seenIds = new Set();
|
|
57
|
+
const nodes = {};
|
|
58
|
+
|
|
59
|
+
clipboardNodes.forEach((clipNode) => {
|
|
60
|
+
const nodeId = clipNode._originalId || clipNode.id;
|
|
61
|
+
if (!nodeId || seenIds.has(nodeId)) return;
|
|
62
|
+
|
|
63
|
+
seenIds.add(nodeId);
|
|
64
|
+
|
|
65
|
+
nodes[nodeId] = {
|
|
66
|
+
id: nodeId,
|
|
67
|
+
label: clipNode.label,
|
|
68
|
+
next: clipNode.next,
|
|
69
|
+
previous: clipNode.previous,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
Object.keys(clipNode).forEach((key) => {
|
|
73
|
+
if (!["_originalId", "id", "next", "previous", "label"].includes(key)) {
|
|
74
|
+
nodes[nodeId][key] = clipNode[key];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const rootIds = Object.keys(nodes).filter((id) => !nodes[id].previous);
|
|
80
|
+
const uniqueRoots = [...new Set(rootIds)];
|
|
81
|
+
const finalRoots =
|
|
82
|
+
uniqueRoots.length > 0 ? uniqueRoots : [Object.keys(nodes)[0]];
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
nodes,
|
|
86
|
+
roots: finalRoots,
|
|
87
|
+
_pastePosition: position,
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const SelectionProvider = ({ children }) => {
|
|
92
|
+
const [selectedIds, setSelectedIds] = useState(new Set());
|
|
93
|
+
const [clipboard, setClipboard] = useState([]);
|
|
94
|
+
const nodeHandlersRef = useRef(new Map());
|
|
95
|
+
const isPastingRef = useRef(false);
|
|
96
|
+
|
|
97
|
+
const selectNode = useCallback((id, addToSelection = false) => {
|
|
98
|
+
setSelectedIds((prev) => {
|
|
99
|
+
const next = new Set(addToSelection ? prev : []);
|
|
100
|
+
next.add(id);
|
|
101
|
+
return next;
|
|
102
|
+
});
|
|
103
|
+
}, []);
|
|
104
|
+
|
|
105
|
+
const deselectNode = useCallback((id) => {
|
|
106
|
+
setSelectedIds((prev) => {
|
|
107
|
+
const next = new Set(prev);
|
|
108
|
+
next.delete(id);
|
|
109
|
+
return next;
|
|
110
|
+
});
|
|
111
|
+
}, []);
|
|
112
|
+
|
|
113
|
+
const toggleSelection = useCallback((id) => {
|
|
114
|
+
setSelectedIds((prev) => {
|
|
115
|
+
const next = new Set(prev);
|
|
116
|
+
next.has(id) ? next.delete(id) : next.add(id);
|
|
117
|
+
return next;
|
|
118
|
+
});
|
|
119
|
+
}, []);
|
|
120
|
+
|
|
121
|
+
const clearSelection = useCallback(() => setSelectedIds(new Set()), []);
|
|
122
|
+
|
|
123
|
+
const selectMultiple = useCallback((ids) => setSelectedIds(new Set(ids)), []);
|
|
124
|
+
|
|
125
|
+
const addToSelection = useCallback(
|
|
126
|
+
(ids) => setSelectedIds((prev) => new Set([...prev, ...ids])),
|
|
127
|
+
[]
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const isSelected = useCallback((id) => selectedIds.has(id), [selectedIds]);
|
|
131
|
+
|
|
132
|
+
const registerNodeHandlers = useCallback((id, handlers) => {
|
|
133
|
+
nodeHandlersRef.current.set(id, handlers);
|
|
134
|
+
return () => nodeHandlersRef.current.delete(id);
|
|
135
|
+
}, []);
|
|
136
|
+
|
|
137
|
+
const moveSelectedNodes = useCallback(
|
|
138
|
+
(deltaX, deltaY, excludeId = null) => {
|
|
139
|
+
selectedIds.forEach((id) => {
|
|
140
|
+
if (id === excludeId) return;
|
|
141
|
+
|
|
142
|
+
const handlers = nodeHandlersRef.current.get(id);
|
|
143
|
+
if (!handlers) return;
|
|
144
|
+
|
|
145
|
+
handlers.setOffset?.((prev) => ({
|
|
146
|
+
x: prev.x + deltaX,
|
|
147
|
+
y: prev.y + deltaY,
|
|
148
|
+
}));
|
|
149
|
+
handlers.onDrag?.();
|
|
150
|
+
});
|
|
151
|
+
},
|
|
152
|
+
[selectedIds]
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
const cutSelectedNodes = useCallback(
|
|
156
|
+
(nodesById, onCut) => {
|
|
157
|
+
if (!nodesById || selectedIds.size === 0) return;
|
|
158
|
+
|
|
159
|
+
const selectedSet = new Set(selectedIds);
|
|
160
|
+
const seenIds = new Set();
|
|
161
|
+
const cutNodes = [];
|
|
162
|
+
|
|
163
|
+
[...selectedIds].forEach((id) => {
|
|
164
|
+
if (!nodesById[id] || seenIds.has(id)) return;
|
|
165
|
+
seenIds.add(id);
|
|
166
|
+
cutNodes.push(buildClipboardNode(id, nodesById[id], selectedSet));
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
setClipboard(cutNodes);
|
|
170
|
+
onCut?.([...selectedIds]);
|
|
171
|
+
setSelectedIds(new Set());
|
|
172
|
+
},
|
|
173
|
+
[selectedIds]
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
const pasteNodes = useCallback(
|
|
177
|
+
(callback, x = 0, y = 0) => {
|
|
178
|
+
if (!clipboard.length || !callback || isPastingRef.current) return;
|
|
179
|
+
|
|
180
|
+
isPastingRef.current = true;
|
|
181
|
+
const nodesToPaste = [...clipboard];
|
|
182
|
+
|
|
183
|
+
const pasteData = buildPasteStructure(nodesToPaste, { x, y });
|
|
184
|
+
if (!pasteData) {
|
|
185
|
+
isPastingRef.current = false;
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
let result;
|
|
190
|
+
try {
|
|
191
|
+
result = callback(pasteData, { x, y });
|
|
192
|
+
} catch (error) {
|
|
193
|
+
isPastingRef.current = false;
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (result && typeof result.then === "function") {
|
|
198
|
+
return result
|
|
199
|
+
.then(() => {
|
|
200
|
+
setClipboard([]);
|
|
201
|
+
})
|
|
202
|
+
.finally(() => {
|
|
203
|
+
isPastingRef.current = false;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
setClipboard([]);
|
|
208
|
+
isPastingRef.current = false;
|
|
209
|
+
return result;
|
|
210
|
+
},
|
|
211
|
+
[clipboard]
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
const hasClipboard = clipboard.length > 0;
|
|
215
|
+
|
|
216
|
+
const contextValue = useMemo(
|
|
217
|
+
() => ({
|
|
218
|
+
selectedIds,
|
|
219
|
+
selectNode,
|
|
220
|
+
deselectNode,
|
|
221
|
+
toggleSelection,
|
|
222
|
+
clearSelection,
|
|
223
|
+
selectMultiple,
|
|
224
|
+
addToSelection,
|
|
225
|
+
isSelected,
|
|
226
|
+
registerNodeHandlers,
|
|
227
|
+
moveSelectedNodes,
|
|
228
|
+
cutSelectedNodes,
|
|
229
|
+
pasteNodes,
|
|
230
|
+
hasClipboard,
|
|
231
|
+
}),
|
|
232
|
+
[
|
|
233
|
+
selectedIds,
|
|
234
|
+
selectNode,
|
|
235
|
+
deselectNode,
|
|
236
|
+
toggleSelection,
|
|
237
|
+
clearSelection,
|
|
238
|
+
selectMultiple,
|
|
239
|
+
addToSelection,
|
|
240
|
+
isSelected,
|
|
241
|
+
registerNodeHandlers,
|
|
242
|
+
moveSelectedNodes,
|
|
243
|
+
cutSelectedNodes,
|
|
244
|
+
pasteNodes,
|
|
245
|
+
hasClipboard,
|
|
246
|
+
]
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
return (
|
|
250
|
+
<SelectionContext.Provider value={contextValue}>
|
|
251
|
+
{children}
|
|
252
|
+
</SelectionContext.Provider>
|
|
253
|
+
);
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
export const useSelection = () =>
|
|
257
|
+
useContext(SelectionContext) || DEFAULT_CONTEXT;
|
|
258
|
+
|
|
259
|
+
export default SelectionContext;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Box } from "@mui/material";
|
|
2
|
+
import { hexToRgba } from "../utils/flowUtils";
|
|
3
|
+
|
|
4
|
+
const SelectionOverlay = ({ box, selectionColor = "#64748b" }) => {
|
|
5
|
+
if (!box) return null;
|
|
6
|
+
|
|
7
|
+
const { startX, startY, currentX, currentY } = box;
|
|
8
|
+
const left = Math.min(startX, currentX);
|
|
9
|
+
const top = Math.min(startY, currentY);
|
|
10
|
+
const width = Math.abs(currentX - startX);
|
|
11
|
+
const height = Math.abs(currentY - startY);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Box
|
|
15
|
+
sx={{
|
|
16
|
+
position: "fixed",
|
|
17
|
+
left,
|
|
18
|
+
top,
|
|
19
|
+
width,
|
|
20
|
+
height,
|
|
21
|
+
border: `2px solid ${selectionColor}`,
|
|
22
|
+
backgroundColor: hexToRgba(selectionColor, 0.1),
|
|
23
|
+
pointerEvents: "none",
|
|
24
|
+
zIndex: 9999,
|
|
25
|
+
borderRadius: "4px",
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default SelectionOverlay;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
export const toPxNumber = (v, fallback = 1) => {
|
|
2
|
+
if (v == null) return fallback;
|
|
3
|
+
if (typeof v === "number") return v;
|
|
4
|
+
const n = parseFloat(String(v));
|
|
5
|
+
return Number.isFinite(n) ? n : fallback;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const getBaseStyleForVariant = (v) => {
|
|
9
|
+
switch (v) {
|
|
10
|
+
case "card":
|
|
11
|
+
return {
|
|
12
|
+
lineColor: "#b1b1b7",
|
|
13
|
+
lineWidth: "2px",
|
|
14
|
+
lineStyle: "solid",
|
|
15
|
+
gap: 56,
|
|
16
|
+
shape: 10,
|
|
17
|
+
bg: "background.paper",
|
|
18
|
+
hoverBg: "grey.50",
|
|
19
|
+
borderColor: "#e2e8f0",
|
|
20
|
+
selectionColor: "#64748b",
|
|
21
|
+
showDots: false,
|
|
22
|
+
showArrow: true,
|
|
23
|
+
arrowSize: 6,
|
|
24
|
+
animated: false,
|
|
25
|
+
animationSpeed: 1,
|
|
26
|
+
gradient: null,
|
|
27
|
+
curvature: 0.5,
|
|
28
|
+
};
|
|
29
|
+
case "pill":
|
|
30
|
+
return {
|
|
31
|
+
lineColor: "#8b5cf6",
|
|
32
|
+
lineWidth: "2px",
|
|
33
|
+
lineStyle: "solid",
|
|
34
|
+
gap: 48,
|
|
35
|
+
shape: 9999,
|
|
36
|
+
bg: "rgba(139, 92, 246, 0.08)",
|
|
37
|
+
hoverBg: "rgba(139, 92, 246, 0.16)",
|
|
38
|
+
borderColor: "#8b5cf6",
|
|
39
|
+
selectionColor: "#8b5cf6",
|
|
40
|
+
showDots: false,
|
|
41
|
+
showArrow: true,
|
|
42
|
+
arrowSize: 6,
|
|
43
|
+
animated: false,
|
|
44
|
+
animationSpeed: 1,
|
|
45
|
+
gradient: null,
|
|
46
|
+
curvature: 0.4,
|
|
47
|
+
};
|
|
48
|
+
case "n8n":
|
|
49
|
+
return {
|
|
50
|
+
lineColor: "#b1b1b7",
|
|
51
|
+
lineWidth: "2px",
|
|
52
|
+
lineStyle: "solid",
|
|
53
|
+
gap: 60,
|
|
54
|
+
shape: 8,
|
|
55
|
+
bg: "#ffffff",
|
|
56
|
+
hoverBg: "#f8fafc",
|
|
57
|
+
borderColor: "#e2e8f0",
|
|
58
|
+
selectionColor: "#ff6d5a",
|
|
59
|
+
showDots: false,
|
|
60
|
+
showArrow: true,
|
|
61
|
+
arrowSize: 6,
|
|
62
|
+
animated: false,
|
|
63
|
+
animationSpeed: 1,
|
|
64
|
+
gradient: null,
|
|
65
|
+
curvature: 0.5,
|
|
66
|
+
};
|
|
67
|
+
case "simple":
|
|
68
|
+
default:
|
|
69
|
+
return {
|
|
70
|
+
lineColor: "#b1b1b7",
|
|
71
|
+
lineWidth: "2px",
|
|
72
|
+
lineStyle: "solid",
|
|
73
|
+
gap: 50,
|
|
74
|
+
shape: 8,
|
|
75
|
+
bg: "background.paper",
|
|
76
|
+
hoverBg: "grey.50",
|
|
77
|
+
borderColor: "#e2e8f0",
|
|
78
|
+
selectionColor: "#64748b",
|
|
79
|
+
showDots: false,
|
|
80
|
+
showArrow: true,
|
|
81
|
+
arrowSize: 6,
|
|
82
|
+
animated: false,
|
|
83
|
+
animationSpeed: 1,
|
|
84
|
+
gradient: null,
|
|
85
|
+
curvature: 0.5,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const getDecisionNodeStyle = (nodeType) => {
|
|
91
|
+
const styles = {
|
|
92
|
+
start: { bg: "#E8F5E9", borderColor: "#4CAF50", shape: 8 },
|
|
93
|
+
decision: { bg: "#FFF3E0", borderColor: "#FF9800", shape: 24 },
|
|
94
|
+
process: { bg: "#E3F2FD", borderColor: "#2196F3", shape: 8 },
|
|
95
|
+
end: { bg: "#FFEBEE", borderColor: "#F44336", shape: 8 },
|
|
96
|
+
};
|
|
97
|
+
return styles[nodeType] || styles.process;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const applySemanticTokens = (styleObj, base) => {
|
|
101
|
+
const s = { ...styleObj };
|
|
102
|
+
|
|
103
|
+
const borderWeightMap = { light: 1, normal: 3, bold: 5 };
|
|
104
|
+
if (
|
|
105
|
+
typeof s.border === "string" &&
|
|
106
|
+
["light", "normal", "bold"].includes(s.border)
|
|
107
|
+
) {
|
|
108
|
+
const w = borderWeightMap[s.border];
|
|
109
|
+
if (s.borderWidth == null) s.borderWidth = w;
|
|
110
|
+
if (s.lineWidth == null) s.lineWidth = `${w}px`;
|
|
111
|
+
if (!s.borderColor)
|
|
112
|
+
s.borderColor = base.borderColor || base.lineColor || "#E0E0E0";
|
|
113
|
+
} else if (
|
|
114
|
+
typeof s.border === "string" &&
|
|
115
|
+
(s.border.startsWith("#") || s.border.startsWith("rgb"))
|
|
116
|
+
) {
|
|
117
|
+
s.borderColor = s.border;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const sizeMap = {
|
|
121
|
+
small: { cardWidth: 140, gap: 20 },
|
|
122
|
+
medium: { cardWidth: 180, gap: 30 },
|
|
123
|
+
large: { cardWidth: 220, gap: 40 },
|
|
124
|
+
};
|
|
125
|
+
if (s.size && sizeMap[s.size]) {
|
|
126
|
+
const { cardWidth, gap } = sizeMap[s.size];
|
|
127
|
+
if (s.cardWidth == null) s.cardWidth = cardWidth;
|
|
128
|
+
if (s.gap == null) s.gap = gap;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (s.shape === "square") {
|
|
132
|
+
const defaultSize = 140;
|
|
133
|
+
if (s.cardWidth != null && s.minHeight == null) s.minHeight = s.cardWidth;
|
|
134
|
+
else if (s.minHeight != null && s.cardWidth == null)
|
|
135
|
+
s.cardWidth = s.minHeight;
|
|
136
|
+
else if (s.cardWidth == null && s.minHeight == null) {
|
|
137
|
+
s.cardWidth = defaultSize;
|
|
138
|
+
s.minHeight = defaultSize;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (s.shape === "vertical") {
|
|
143
|
+
const defaultWidth = 160;
|
|
144
|
+
if (s.cardWidth == null) s.cardWidth = defaultWidth;
|
|
145
|
+
if (s.minHeight == null) s.minHeight = Math.max(s.cardWidth * 1.3, 110);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const shadowVariantMap = { none: 0, soft: 2, heavy: 6 };
|
|
149
|
+
if (s.shadow && shadowVariantMap[s.shadow] != null && s.shadowLevel == null) {
|
|
150
|
+
s.shadowLevel = shadowVariantMap[s.shadow];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return s;
|
|
154
|
+
};
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
export function assertLinkedGraph(data) {
|
|
2
|
+
if (!data || typeof data !== "object") {
|
|
3
|
+
throw new Error(
|
|
4
|
+
"FlowChart expected a linked graph object: { nodes, roots? }."
|
|
5
|
+
);
|
|
6
|
+
}
|
|
7
|
+
const { nodes, roots } = data;
|
|
8
|
+
if (!nodes || typeof nodes !== "object") {
|
|
9
|
+
throw new Error("FlowChart expected data.nodes to be an object.");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let useRoots = Array.isArray(roots) ? [...roots] : null;
|
|
13
|
+
if (!useRoots || useRoots.length === 0) {
|
|
14
|
+
useRoots = Object.keys(nodes).filter((id) => !nodes[id]?.previous);
|
|
15
|
+
}
|
|
16
|
+
if (useRoots.length === 0) {
|
|
17
|
+
const first = Object.keys(nodes)[0];
|
|
18
|
+
if (first) useRoots = [first];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
for (const r of useRoots) {
|
|
22
|
+
if (!nodes[r]) throw new Error(`Root id "${r}" not found in data.nodes.`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return { nodesById: nodes, roots: useRoots };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function buildTreeFromLinked(rootId, nodesById) {
|
|
29
|
+
if (!rootId || !nodesById?.[rootId]) return null;
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
|
|
32
|
+
const cloneNode = (node) => {
|
|
33
|
+
if (!node) return null;
|
|
34
|
+
const { next, previous, children, ...rest } = node;
|
|
35
|
+
return { ...rest, id: node.id, previous, next, children: [] };
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const dfs = (id) => {
|
|
39
|
+
if (!id || seen.has(id) || !nodesById[id]) return null;
|
|
40
|
+
seen.add(id);
|
|
41
|
+
|
|
42
|
+
const node = nodesById[id];
|
|
43
|
+
const out = cloneNode(node);
|
|
44
|
+
|
|
45
|
+
const nextArr = Array.isArray(node.next)
|
|
46
|
+
? node.next
|
|
47
|
+
: node.next != null
|
|
48
|
+
? [node.next]
|
|
49
|
+
: [];
|
|
50
|
+
|
|
51
|
+
for (const nxt of nextArr) {
|
|
52
|
+
const nextId = typeof nxt === "string" ? nxt : nxt?.id;
|
|
53
|
+
if (!nextId || !nodesById[nextId]) continue;
|
|
54
|
+
|
|
55
|
+
const target = nodesById[nextId];
|
|
56
|
+
if (target.previous == null || target.previous === id) {
|
|
57
|
+
const built = dfs(nextId);
|
|
58
|
+
if (built) out.children.push(built);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return dfs(rootId);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const getContentParts = (n) => {
|
|
68
|
+
const entries = Object.entries(n).filter(
|
|
69
|
+
([key]) =>
|
|
70
|
+
key !== "children" && key !== "id" && key !== "previous" && key !== "next"
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
if (entries.length === 0) {
|
|
74
|
+
return {
|
|
75
|
+
title: "(empty)",
|
|
76
|
+
subtitle: null,
|
|
77
|
+
metaEntries: [],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const preferredTitleKeys = ["label", "title", "name"];
|
|
82
|
+
const titleEntry =
|
|
83
|
+
entries.find(([key]) => preferredTitleKeys.includes(key)) || entries[0];
|
|
84
|
+
const [titleKey, rawTitle] = titleEntry;
|
|
85
|
+
const title = String(rawTitle);
|
|
86
|
+
let remaining = entries.filter(([key]) => key !== titleKey);
|
|
87
|
+
|
|
88
|
+
const preferredSubtitleKeys = ["description", "role", "type", "status"];
|
|
89
|
+
const subtitleEntry =
|
|
90
|
+
remaining.find(([key]) => preferredSubtitleKeys.includes(key)) || null;
|
|
91
|
+
|
|
92
|
+
let subtitle = null;
|
|
93
|
+
if (subtitleEntry) {
|
|
94
|
+
const [subtitleKey, raw] = subtitleEntry;
|
|
95
|
+
subtitle = String(raw);
|
|
96
|
+
remaining = remaining.filter(([key]) => key !== subtitleKey);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const metaEntries = remaining
|
|
100
|
+
.filter(([, value]) => {
|
|
101
|
+
const t = typeof value;
|
|
102
|
+
return (
|
|
103
|
+
(t === "string" || t === "number" || t === "boolean") &&
|
|
104
|
+
value !== "" &&
|
|
105
|
+
value !== null
|
|
106
|
+
);
|
|
107
|
+
})
|
|
108
|
+
.map(([k, v]) => [k, v]);
|
|
109
|
+
|
|
110
|
+
return { title, subtitle, metaEntries };
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const toNextArray = (next) => {
|
|
114
|
+
if (!next) return [];
|
|
115
|
+
return Array.isArray(next) ? next : [next];
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const setNextProperty = (node, nextIds) => {
|
|
119
|
+
if (!nextIds || nextIds.length === 0) {
|
|
120
|
+
delete node.next;
|
|
121
|
+
} else if (nextIds.length === 1) {
|
|
122
|
+
node.next = nextIds[0];
|
|
123
|
+
} else {
|
|
124
|
+
node.next = nextIds;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const addToNext = (node, childIds) => {
|
|
129
|
+
const current = toNextArray(node.next);
|
|
130
|
+
const newIds = childIds.filter((id) => !current.includes(id));
|
|
131
|
+
setNextProperty(node, [...current, ...newIds]);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const removeFromNext = (node, childIds) => {
|
|
135
|
+
const removeSet = new Set(childIds);
|
|
136
|
+
const filtered = toNextArray(node.next).filter((id) => !removeSet.has(id));
|
|
137
|
+
setNextProperty(node, filtered);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export const cleanupReferences = (nodes, removedIds) => {
|
|
141
|
+
const removeSet = new Set(removedIds);
|
|
142
|
+
Object.values(nodes).forEach((node) => {
|
|
143
|
+
if (removeSet.has(node.next)) {
|
|
144
|
+
delete node.next;
|
|
145
|
+
} else if (Array.isArray(node.next)) {
|
|
146
|
+
const filtered = node.next.filter((n) => !removeSet.has(n));
|
|
147
|
+
setNextProperty(node, filtered);
|
|
148
|
+
}
|
|
149
|
+
if (removeSet.has(node.previous)) {
|
|
150
|
+
delete node.previous;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const hexToRgba = (hex, alpha) => {
|
|
156
|
+
const r = parseInt(hex.slice(1, 3), 16);
|
|
157
|
+
const g = parseInt(hex.slice(3, 5), 16);
|
|
158
|
+
const b = parseInt(hex.slice(5, 7), 16);
|
|
159
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export const buildDetachedTree = (rootId, nodesById) => {
|
|
163
|
+
if (!rootId || !nodesById?.[rootId]) return null;
|
|
164
|
+
const seen = new Set();
|
|
165
|
+
|
|
166
|
+
const buildNode = (id) => {
|
|
167
|
+
if (!id || seen.has(id) || !nodesById[id]) return null;
|
|
168
|
+
seen.add(id);
|
|
169
|
+
|
|
170
|
+
const node = nodesById[id];
|
|
171
|
+
const { next, previous, ...rest } = node;
|
|
172
|
+
const result = { ...rest, id, children: [] };
|
|
173
|
+
|
|
174
|
+
const nextIds = Array.isArray(next) ? next : next != null ? [next] : [];
|
|
175
|
+
|
|
176
|
+
nextIds.forEach((nxt) => {
|
|
177
|
+
const nextId = typeof nxt === "string" ? nxt : nxt?.id;
|
|
178
|
+
if (!nextId || !nodesById[nextId]) return;
|
|
179
|
+
|
|
180
|
+
const child = buildNode(nextId);
|
|
181
|
+
if (child) result.children.push(child);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
return result;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
return buildNode(rootId);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export const getSelectedInStructure = (structure, selectedIds) =>
|
|
191
|
+
selectedIds.filter((id) => structure.nodes?.[id]);
|
|
192
|
+
|
|
193
|
+
export const getRootsToConnect = (structure, selectedIds) => {
|
|
194
|
+
const selectedSet = new Set(selectedIds);
|
|
195
|
+
const roots = [];
|
|
196
|
+
|
|
197
|
+
selectedIds.forEach((id) => {
|
|
198
|
+
let current = structure.nodes[id];
|
|
199
|
+
if (!current) return;
|
|
200
|
+
|
|
201
|
+
let rootId = id;
|
|
202
|
+
|
|
203
|
+
while (current.previous && structure.nodes[current.previous]) {
|
|
204
|
+
if (selectedSet.has(current.previous)) {
|
|
205
|
+
rootId = current.previous;
|
|
206
|
+
current = structure.nodes[current.previous];
|
|
207
|
+
} else break;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (!current.previous && !roots.includes(rootId)) {
|
|
211
|
+
roots.push(rootId);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
if (roots.length > 0) return roots;
|
|
216
|
+
|
|
217
|
+
return selectedIds.filter((id) => {
|
|
218
|
+
const node = structure.nodes[id];
|
|
219
|
+
return node && (!node.previous || !structure.nodes[node.previous]);
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export const collectSubtree = (structure, roots, selectedIds) => {
|
|
224
|
+
const selectedSet = new Set(selectedIds);
|
|
225
|
+
const collected = new Set();
|
|
226
|
+
|
|
227
|
+
const dfs = (id) => {
|
|
228
|
+
if (collected.has(id) || !structure.nodes[id]) return;
|
|
229
|
+
collected.add(id);
|
|
230
|
+
|
|
231
|
+
toNextArray(structure.nodes[id].next).forEach((childId) => {
|
|
232
|
+
if (structure.nodes[childId] && selectedSet.has(childId)) {
|
|
233
|
+
dfs(childId);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
roots.forEach(dfs);
|
|
239
|
+
return collected;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export const splitFloatingStructure = (structure, removedIds) => {
|
|
243
|
+
const remainingNodes = {};
|
|
244
|
+
|
|
245
|
+
Object.entries(structure.nodes).forEach(([id, node]) => {
|
|
246
|
+
if (!removedIds.has(id)) {
|
|
247
|
+
remainingNodes[id] = node;
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
cleanupReferences(remainingNodes, [...removedIds]);
|
|
252
|
+
|
|
253
|
+
const remainingRoots =
|
|
254
|
+
structure.roots?.filter((r) => !removedIds.has(r)) ?? [];
|
|
255
|
+
|
|
256
|
+
const roots =
|
|
257
|
+
remainingRoots.length > 0
|
|
258
|
+
? remainingRoots
|
|
259
|
+
: Object.keys(remainingNodes).filter(
|
|
260
|
+
(id) => !remainingNodes[id].previous
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
return {
|
|
264
|
+
...structure,
|
|
265
|
+
nodes: remainingNodes,
|
|
266
|
+
roots: [...new Set(roots)],
|
|
267
|
+
};
|
|
268
|
+
};
|