zudoku 0.0.2-dev.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/cli.js +1 -0
- package/dist/app/DevPortal.d.ts +26 -0
- package/dist/app/DevPortal.js +41 -0
- package/dist/app/DevPortal.js.map +1 -0
- package/dist/app/Heading.d.ts +9 -0
- package/dist/app/Heading.js +27 -0
- package/dist/app/Heading.js.map +1 -0
- package/dist/app/app.d.ts +2 -0
- package/dist/app/app.js +69 -0
- package/dist/app/app.js.map +1 -0
- package/dist/app/authentication/authentication.d.ts +13 -0
- package/dist/app/authentication/authentication.js +2 -0
- package/dist/app/authentication/authentication.js.map +1 -0
- package/dist/app/authentication/clerk.d.ts +5 -0
- package/dist/app/authentication/clerk.js +36 -0
- package/dist/app/authentication/clerk.js.map +1 -0
- package/dist/app/authentication/openid.d.ts +11 -0
- package/dist/app/authentication/openid.js +118 -0
- package/dist/app/authentication/openid.js.map +1 -0
- package/dist/app/components/AnchorLink.d.ts +5 -0
- package/dist/app/components/AnchorLink.js +17 -0
- package/dist/app/components/AnchorLink.js.map +1 -0
- package/dist/app/components/CategoryHeading.d.ts +5 -0
- package/dist/app/components/CategoryHeading.js +6 -0
- package/dist/app/components/CategoryHeading.js.map +1 -0
- package/dist/app/components/DynamicIcon.d.ts +6 -0
- package/dist/app/components/DynamicIcon.js +6 -0
- package/dist/app/components/DynamicIcon.js.map +1 -0
- package/dist/app/components/Header.d.ts +2 -0
- package/dist/app/components/Header.js +15 -0
- package/dist/app/components/Header.js.map +1 -0
- package/dist/app/components/Layout.d.ts +4 -0
- package/dist/app/components/Layout.js +31 -0
- package/dist/app/components/Layout.js.map +1 -0
- package/dist/app/components/Markdown.d.ts +5 -0
- package/dist/app/components/Markdown.js +20 -0
- package/dist/app/components/Markdown.js.map +1 -0
- package/dist/app/components/SyntaxHighlight.d.ts +9 -0
- package/dist/app/components/SyntaxHighlight.js +31 -0
- package/dist/app/components/SyntaxHighlight.js.map +1 -0
- package/dist/app/components/TopNavigation.d.ts +1 -0
- package/dist/app/components/TopNavigation.js +11 -0
- package/dist/app/components/TopNavigation.js.map +1 -0
- package/dist/app/components/context/ComponentsContext.d.ts +10 -0
- package/dist/app/components/context/ComponentsContext.js +11 -0
- package/dist/app/components/context/ComponentsContext.js.map +1 -0
- package/dist/app/components/context/DevPortalProvider.d.ts +10 -0
- package/dist/app/components/context/DevPortalProvider.js +39 -0
- package/dist/app/components/context/DevPortalProvider.js.map +1 -0
- package/dist/app/components/context/PluginSystem.d.ts +1 -0
- package/dist/app/components/context/PluginSystem.js +2 -0
- package/dist/app/components/context/PluginSystem.js.map +1 -0
- package/dist/app/components/context/ThemeContext.d.ts +5 -0
- package/dist/app/components/context/ThemeContext.js +33 -0
- package/dist/app/components/context/ThemeContext.js.map +1 -0
- package/dist/app/components/context/ViewportAnchorContext.d.ts +15 -0
- package/dist/app/components/context/ViewportAnchorContext.js +89 -0
- package/dist/app/components/context/ViewportAnchorContext.js.map +1 -0
- package/dist/app/components/navigation/SideNavigation.d.ts +1 -0
- package/dist/app/components/navigation/SideNavigation.js +11 -0
- package/dist/app/components/navigation/SideNavigation.js.map +1 -0
- package/dist/app/components/navigation/SideNavigationCategory.d.ts +4 -0
- package/dist/app/components/navigation/SideNavigationCategory.js +26 -0
- package/dist/app/components/navigation/SideNavigationCategory.js.map +1 -0
- package/dist/app/components/navigation/SideNavigationItem.d.ts +12 -0
- package/dist/app/components/navigation/SideNavigationItem.js +38 -0
- package/dist/app/components/navigation/SideNavigationItem.js.map +1 -0
- package/dist/app/components/navigation/SideNavigationWrapper.d.ts +4 -0
- package/dist/app/components/navigation/SideNavigationWrapper.js +6 -0
- package/dist/app/components/navigation/SideNavigationWrapper.js.map +1 -0
- package/dist/app/components/navigation/useNavigationCollapsibleState.d.ts +7 -0
- package/dist/app/components/navigation/useNavigationCollapsibleState.js +16 -0
- package/dist/app/components/navigation/useNavigationCollapsibleState.js.map +1 -0
- package/dist/app/components/navigation/util.d.ts +8 -0
- package/dist/app/components/navigation/util.js +15 -0
- package/dist/app/components/navigation/util.js.map +1 -0
- package/dist/app/config.d.ts +3 -0
- package/dist/app/config.js +9 -0
- package/dist/app/config.js.map +1 -0
- package/dist/app/core/DevPortalContext.d.ts +80 -0
- package/dist/app/core/DevPortalContext.js +68 -0
- package/dist/app/core/DevPortalContext.js.map +1 -0
- package/dist/app/core/helmet.d.ts +4 -0
- package/dist/app/core/helmet.js +5 -0
- package/dist/app/core/helmet.js.map +1 -0
- package/dist/app/core/icons.d.ts +1 -0
- package/dist/app/core/icons.js +2 -0
- package/dist/app/core/icons.js.map +1 -0
- package/dist/app/core/plugins.d.ts +24 -0
- package/dist/app/core/plugins.js +4 -0
- package/dist/app/core/plugins.js.map +1 -0
- package/dist/app/core/router.d.ts +1 -0
- package/dist/app/core/router.js +2 -0
- package/dist/app/core/router.js.map +1 -0
- package/dist/app/core/types/combine.d.ts +4 -0
- package/dist/app/core/types/combine.js +2 -0
- package/dist/app/core/types/combine.js.map +1 -0
- package/dist/app/main.d.ts +1 -0
- package/dist/app/main.js +18 -0
- package/dist/app/main.js.map +1 -0
- package/dist/app/markdowns.d.ts +3 -0
- package/dist/app/markdowns.js +5 -0
- package/dist/app/markdowns.js.map +1 -0
- package/dist/app/oas/graphql/index.d.ts +12 -0
- package/dist/app/oas/graphql/index.js +290 -0
- package/dist/app/oas/graphql/index.js.map +1 -0
- package/dist/app/oas/graphql/server.d.ts +1 -0
- package/dist/app/oas/graphql/server.js +8 -0
- package/dist/app/oas/graphql/server.js.map +1 -0
- package/dist/app/oas/parser/dereference/index.d.ts +5 -0
- package/dist/app/oas/parser/dereference/index.js +43 -0
- package/dist/app/oas/parser/dereference/index.js.map +1 -0
- package/dist/app/oas/parser/dereference/resolveRef.d.ts +5 -0
- package/dist/app/oas/parser/dereference/resolveRef.js +26 -0
- package/dist/app/oas/parser/dereference/resolveRef.js.map +1 -0
- package/dist/app/oas/parser/index.d.ts +21 -0
- package/dist/app/oas/parser/index.js +58 -0
- package/dist/app/oas/parser/index.js.map +1 -0
- package/dist/app/oas/parser/schemas/v3.0.json +1489 -0
- package/dist/app/oas/parser/schemas/v3.1.json +1298 -0
- package/dist/app/oas/parser/upgrade/index.d.ts +9 -0
- package/dist/app/oas/parser/upgrade/index.js +90 -0
- package/dist/app/oas/parser/upgrade/index.js.map +1 -0
- package/dist/app/plugins/api-key/SettingsApiKeys.d.ts +4 -0
- package/dist/app/plugins/api-key/SettingsApiKeys.js +7 -0
- package/dist/app/plugins/api-key/SettingsApiKeys.js.map +1 -0
- package/dist/app/plugins/api-key/index.d.ts +32 -0
- package/dist/app/plugins/api-key/index.js +55 -0
- package/dist/app/plugins/api-key/index.js.map +1 -0
- package/dist/app/plugins/markdown/MdxPage.d.ts +3 -0
- package/dist/app/plugins/markdown/MdxPage.js +55 -0
- package/dist/app/plugins/markdown/MdxPage.js.map +1 -0
- package/dist/app/plugins/markdown/Toc.d.ts +4 -0
- package/dist/app/plugins/markdown/Toc.js +40 -0
- package/dist/app/plugins/markdown/Toc.js.map +1 -0
- package/dist/app/plugins/markdown/generateRoutes.d.ts +3 -0
- package/dist/app/plugins/markdown/generateRoutes.js +50 -0
- package/dist/app/plugins/markdown/generateRoutes.js.map +1 -0
- package/dist/app/plugins/markdown/index.d.ts +19 -0
- package/dist/app/plugins/markdown/index.js +9 -0
- package/dist/app/plugins/markdown/index.js.map +1 -0
- package/dist/app/plugins/openapi/ColorizedParam.d.ts +8 -0
- package/dist/app/plugins/openapi/ColorizedParam.js +40 -0
- package/dist/app/plugins/openapi/ColorizedParam.js.map +1 -0
- package/dist/app/plugins/openapi/MakeRequest.d.ts +4 -0
- package/dist/app/plugins/openapi/MakeRequest.js +11 -0
- package/dist/app/plugins/openapi/MakeRequest.js.map +1 -0
- package/dist/app/plugins/openapi/MethodBadge.d.ts +13 -0
- package/dist/app/plugins/openapi/MethodBadge.js +26 -0
- package/dist/app/plugins/openapi/MethodBadge.js.map +1 -0
- package/dist/app/plugins/openapi/OperationList.d.ts +47 -0
- package/dist/app/plugins/openapi/OperationList.js +82 -0
- package/dist/app/plugins/openapi/OperationList.js.map +1 -0
- package/dist/app/plugins/openapi/OperationListItem.d.ts +7 -0
- package/dist/app/plugins/openapi/OperationListItem.js +15 -0
- package/dist/app/plugins/openapi/OperationListItem.js.map +1 -0
- package/dist/app/plugins/openapi/ParameterList.d.ts +7 -0
- package/dist/app/plugins/openapi/ParameterList.js +5 -0
- package/dist/app/plugins/openapi/ParameterList.js.map +1 -0
- package/dist/app/plugins/openapi/ParameterListItem.d.ts +8 -0
- package/dist/app/plugins/openapi/ParameterListItem.js +13 -0
- package/dist/app/plugins/openapi/ParameterListItem.js.map +1 -0
- package/dist/app/plugins/openapi/RequestBodySidecarBox.d.ts +6 -0
- package/dist/app/plugins/openapi/RequestBodySidecarBox.js +19 -0
- package/dist/app/plugins/openapi/RequestBodySidecarBox.js.map +1 -0
- package/dist/app/plugins/openapi/ResponsesSidecarBox.d.ts +6 -0
- package/dist/app/plugins/openapi/ResponsesSidecarBox.js +15 -0
- package/dist/app/plugins/openapi/ResponsesSidecarBox.js.map +1 -0
- package/dist/app/plugins/openapi/Select.d.ts +9 -0
- package/dist/app/plugins/openapi/Select.js +5 -0
- package/dist/app/plugins/openapi/Select.js.map +1 -0
- package/dist/app/plugins/openapi/Sidecar.d.ts +4 -0
- package/dist/app/plugins/openapi/Sidecar.js +39 -0
- package/dist/app/plugins/openapi/Sidecar.js.map +1 -0
- package/dist/app/plugins/openapi/SidecarBox.d.ts +10 -0
- package/dist/app/plugins/openapi/SidecarBox.js +8 -0
- package/dist/app/plugins/openapi/SidecarBox.js.map +1 -0
- package/dist/app/plugins/openapi/graphql/index.d.ts +836 -0
- package/dist/app/plugins/openapi/graphql/index.js +4 -0
- package/dist/app/plugins/openapi/graphql/index.js.map +1 -0
- package/dist/app/plugins/openapi/index.d.ts +22 -0
- package/dist/app/plugins/openapi/index.js +91 -0
- package/dist/app/plugins/openapi/index.js.map +1 -0
- package/dist/app/plugins/openapi/util/generateSchemaExample.d.ts +3 -0
- package/dist/app/plugins/openapi/util/generateSchemaExample.js +52 -0
- package/dist/app/plugins/openapi/util/generateSchemaExample.js.map +1 -0
- package/dist/app/plugins/openapi/util/getCode.d.ts +2 -0
- package/dist/app/plugins/openapi/util/getCode.js +54 -0
- package/dist/app/plugins/openapi/util/getCode.js.map +1 -0
- package/dist/app/plugins/openapi/util/urql.d.ts +8 -0
- package/dist/app/plugins/openapi/util/urql.js +8 -0
- package/dist/app/plugins/openapi/util/urql.js.map +1 -0
- package/dist/app/plugins/openapi/worker/createSharedWorkerClient.d.ts +5 -0
- package/dist/app/plugins/openapi/worker/createSharedWorkerClient.js +47 -0
- package/dist/app/plugins/openapi/worker/createSharedWorkerClient.js.map +1 -0
- package/dist/app/plugins/openapi/worker/worker.d.ts +1 -0
- package/dist/app/plugins/openapi/worker/worker.js +20 -0
- package/dist/app/plugins/openapi/worker/worker.js.map +1 -0
- package/dist/app/plugins/redirect/index.d.ts +10 -0
- package/dist/app/plugins/redirect/index.js +11 -0
- package/dist/app/plugins/redirect/index.js.map +1 -0
- package/dist/app/tailwind.d.ts +3 -0
- package/dist/app/tailwind.js +69 -0
- package/dist/app/tailwind.js.map +1 -0
- package/dist/app/ui/Callout.d.ts +51 -0
- package/dist/app/ui/Callout.js +50 -0
- package/dist/app/ui/Callout.js.map +1 -0
- package/dist/app/ui/Card.d.ts +8 -0
- package/dist/app/ui/Card.js +17 -0
- package/dist/app/ui/Card.js.map +1 -0
- package/dist/app/ui/Note.d.ts +8 -0
- package/dist/app/ui/Note.js +23 -0
- package/dist/app/ui/Note.js.map +1 -0
- package/dist/app/util/MdxComponents.d.ts +27 -0
- package/dist/app/util/MdxComponents.js +40 -0
- package/dist/app/util/MdxComponents.js.map +1 -0
- package/dist/app/util/cn.d.ts +2 -0
- package/dist/app/util/cn.js +6 -0
- package/dist/app/util/cn.js.map +1 -0
- package/dist/app/util/createWaitForNotify.d.ts +1 -0
- package/dist/app/util/createWaitForNotify.js +15 -0
- package/dist/app/util/createWaitForNotify.js.map +1 -0
- package/dist/app/util/groupBy.d.ts +6 -0
- package/dist/app/util/groupBy.js +9 -0
- package/dist/app/util/groupBy.js.map +1 -0
- package/dist/app/util/joinPath.d.ts +1 -0
- package/dist/app/util/joinPath.js +8 -0
- package/dist/app/util/joinPath.js.map +1 -0
- package/dist/app/util/pastellize.d.ts +4 -0
- package/dist/app/util/pastellize.js +14 -0
- package/dist/app/util/pastellize.js.map +1 -0
- package/dist/app/util/slugify.d.ts +3 -0
- package/dist/app/util/slugify.js +3 -0
- package/dist/app/util/slugify.js.map +1 -0
- package/dist/app/util/traverseNavigation.d.ts +6 -0
- package/dist/app/util/traverseNavigation.js +30 -0
- package/dist/app/util/traverseNavigation.js.map +1 -0
- package/dist/app/util/useScrollToAnchor.d.ts +1 -0
- package/dist/app/util/useScrollToAnchor.js +33 -0
- package/dist/app/util/useScrollToAnchor.js.map +1 -0
- package/dist/app/util/useScrollToTop.d.ts +1 -0
- package/dist/app/util/useScrollToTop.js +13 -0
- package/dist/app/util/useScrollToTop.js.map +1 -0
- package/dist/auth.d.ts +2 -0
- package/dist/auth.js +3 -0
- package/dist/auth.js.map +1 -0
- package/dist/cli/build/handler.d.ts +4 -0
- package/dist/cli/build/handler.js +9 -0
- package/dist/cli/build/handler.js.map +1 -0
- package/dist/cli/cli.d.ts +1 -0
- package/dist/cli/cli.js +64 -0
- package/dist/cli/cli.js.map +1 -0
- package/dist/cli/cmds/build.d.ts +8 -0
- package/dist/cli/cmds/build.js +23 -0
- package/dist/cli/cmds/build.js.map +1 -0
- package/dist/cli/cmds/dev.d.ts +8 -0
- package/dist/cli/cmds/dev.js +29 -0
- package/dist/cli/cmds/dev.js.map +1 -0
- package/dist/cli/common/analytics/lib.d.ts +17 -0
- package/dist/cli/common/analytics/lib.js +53 -0
- package/dist/cli/common/analytics/lib.js.map +1 -0
- package/dist/cli/common/constants.d.ts +5 -0
- package/dist/cli/common/constants.js +9 -0
- package/dist/cli/common/constants.js.map +1 -0
- package/dist/cli/common/logger.d.ts +2 -0
- package/dist/cli/common/logger.js +14 -0
- package/dist/cli/common/logger.js.map +1 -0
- package/dist/cli/common/machine-id/lib.d.ts +1 -0
- package/dist/cli/common/machine-id/lib.js +74 -0
- package/dist/cli/common/machine-id/lib.js.map +1 -0
- package/dist/cli/common/outdated.d.ts +1 -0
- package/dist/cli/common/outdated.js +70 -0
- package/dist/cli/common/outdated.js.map +1 -0
- package/dist/cli/common/output.d.ts +9 -0
- package/dist/cli/common/output.js +65 -0
- package/dist/cli/common/output.js.map +1 -0
- package/dist/cli/common/utils/box.d.ts +33 -0
- package/dist/cli/common/utils/box.js +81 -0
- package/dist/cli/common/utils/box.js.map +1 -0
- package/dist/cli/common/utils/ports.d.ts +1 -0
- package/dist/cli/common/utils/ports.js +18 -0
- package/dist/cli/common/utils/ports.js.map +1 -0
- package/dist/cli/common/validators/lib.d.ts +20 -0
- package/dist/cli/common/validators/lib.js +31 -0
- package/dist/cli/common/validators/lib.js.map +1 -0
- package/dist/cli/common/xdg/lib.d.ts +6 -0
- package/dist/cli/common/xdg/lib.js +18 -0
- package/dist/cli/common/xdg/lib.js.map +1 -0
- package/dist/cli/dev/handler.d.ts +5 -0
- package/dist/cli/dev/handler.js +22 -0
- package/dist/cli/dev/handler.js.map +1 -0
- package/dist/config/config.d.ts +37 -0
- package/dist/config/config.js +2 -0
- package/dist/config/config.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins.d.ts +4 -0
- package/dist/plugins.js +6 -0
- package/dist/plugins.js.map +1 -0
- package/dist/vite/build.d.ts +3 -0
- package/dist/vite/build.js +29 -0
- package/dist/vite/build.js.map +1 -0
- package/dist/vite/config.d.ts +6 -0
- package/dist/vite/config.js +74 -0
- package/dist/vite/config.js.map +1 -0
- package/dist/vite/dev-server.d.ts +10 -0
- package/dist/vite/dev-server.js +53 -0
- package/dist/vite/dev-server.js.map +1 -0
- package/dist/vite/html.d.ts +5 -0
- package/dist/vite/html.js +32 -0
- package/dist/vite/html.js.map +1 -0
- package/dist/vite/import-auth-plugin.d.ts +3 -0
- package/dist/vite/import-auth-plugin.js +28 -0
- package/dist/vite/import-auth-plugin.js.map +1 -0
- package/dist/vite/plugin.d.ts +7 -0
- package/dist/vite/plugin.js +109 -0
- package/dist/vite/plugin.js.map +1 -0
- package/package.json +118 -0
- package/src/app/DevPortal.tsx +115 -0
- package/src/app/Heading.tsx +60 -0
- package/src/app/app.tsx +85 -0
- package/src/app/authentication/authentication.ts +18 -0
- package/src/app/authentication/clerk.ts +47 -0
- package/src/app/authentication/openid.ts +192 -0
- package/src/app/components/AnchorLink.tsx +19 -0
- package/src/app/components/CategoryHeading.tsx +16 -0
- package/src/app/components/DynamicIcon.tsx +60 -0
- package/src/app/components/Header.tsx +69 -0
- package/src/app/components/Layout.tsx +56 -0
- package/src/app/components/Markdown.tsx +37 -0
- package/src/app/components/SyntaxHighlight.tsx +92 -0
- package/src/app/components/TopNavigation.tsx +32 -0
- package/src/app/components/context/ComponentsContext.tsx +24 -0
- package/src/app/components/context/DevPortalProvider.ts +54 -0
- package/src/app/components/context/PluginSystem.ts +0 -0
- package/src/app/components/context/ThemeContext.tsx +46 -0
- package/src/app/components/context/ViewportAnchorContext.tsx +139 -0
- package/src/app/components/navigation/SideNavigation.tsx +18 -0
- package/src/app/components/navigation/SideNavigationCategory.tsx +74 -0
- package/src/app/components/navigation/SideNavigationItem.tsx +143 -0
- package/src/app/components/navigation/SideNavigationWrapper.tsx +15 -0
- package/src/app/components/navigation/useNavigationCollapsibleState.ts +27 -0
- package/src/app/components/navigation/util.ts +38 -0
- package/src/app/config.ts +20 -0
- package/src/app/core/DevPortalContext.ts +164 -0
- package/src/app/core/helmet.ts +5 -0
- package/src/app/core/icons.tsx +1 -0
- package/src/app/core/plugins.ts +43 -0
- package/src/app/core/router.tsx +1 -0
- package/src/app/core/types/combine.ts +16 -0
- package/src/app/main.css +137 -0
- package/src/app/main.tsx +22 -0
- package/src/app/markdowns.ts +7 -0
- package/src/app/oas/graphql/index.ts +422 -0
- package/src/app/oas/graphql/server.ts +10 -0
- package/src/app/oas/parser/dereference/index.ts +59 -0
- package/src/app/oas/parser/dereference/resolveRef.ts +32 -0
- package/src/app/oas/parser/index.ts +94 -0
- package/src/app/oas/parser/schemas/v3.0.json +1489 -0
- package/src/app/oas/parser/schemas/v3.1.json +1298 -0
- package/src/app/oas/parser/upgrade/index.ts +108 -0
- package/src/app/plugins/api-key/SettingsApiKeys.tsx +22 -0
- package/src/app/plugins/api-key/index.tsx +123 -0
- package/src/app/plugins/markdown/MdxPage.tsx +128 -0
- package/src/app/plugins/markdown/Toc.tsx +122 -0
- package/src/app/plugins/markdown/generateRoutes.tsx +72 -0
- package/src/app/plugins/markdown/index.tsx +31 -0
- package/src/app/plugins/openapi/ColorizedParam.tsx +73 -0
- package/src/app/plugins/openapi/MakeRequest.tsx +30 -0
- package/src/app/plugins/openapi/MethodBadge.tsx +36 -0
- package/src/app/plugins/openapi/OperationList.tsx +119 -0
- package/src/app/plugins/openapi/OperationListItem.tsx +55 -0
- package/src/app/plugins/openapi/ParameterList.tsx +32 -0
- package/src/app/plugins/openapi/ParameterListItem.tsx +60 -0
- package/src/app/plugins/openapi/RequestBodySidecarBox.tsx +48 -0
- package/src/app/plugins/openapi/ResponsesSidecarBox.tsx +60 -0
- package/src/app/plugins/openapi/Select.tsx +35 -0
- package/src/app/plugins/openapi/Sidecar.tsx +99 -0
- package/src/app/plugins/openapi/SidecarBox.tsx +35 -0
- package/src/app/plugins/openapi/graphql/env.d.ts +48 -0
- package/src/app/plugins/openapi/graphql/index.ts +13 -0
- package/src/app/plugins/openapi/index.tsx +142 -0
- package/src/app/plugins/openapi/util/generateSchemaExample.ts +59 -0
- package/src/app/plugins/openapi/util/getCode.tsx +69 -0
- package/src/app/plugins/openapi/util/urql.ts +8 -0
- package/src/app/plugins/openapi/worker/createSharedWorkerClient.ts +60 -0
- package/src/app/plugins/openapi/worker/worker.ts +30 -0
- package/src/app/plugins/redirect/index.tsx +20 -0
- package/src/app/tailwind.ts +72 -0
- package/src/app/ui/Callout.tsx +87 -0
- package/src/app/ui/Card.tsx +82 -0
- package/src/app/ui/Note.tsx +58 -0
- package/src/app/util/MdxComponents.tsx +70 -0
- package/src/app/util/cn.ts +6 -0
- package/src/app/util/createWaitForNotify.ts +18 -0
- package/src/app/util/groupBy.ts +24 -0
- package/src/app/util/joinPath.tsx +10 -0
- package/src/app/util/pastellize.ts +25 -0
- package/src/app/util/slugify.ts +3 -0
- package/src/app/util/traverseNavigation.ts +55 -0
- package/src/app/util/useScrollToAnchor.ts +38 -0
- package/src/app/util/useScrollToTop.ts +13 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Highlight,
|
|
3
|
+
Prism,
|
|
4
|
+
themes,
|
|
5
|
+
type HighlightProps,
|
|
6
|
+
} from "prism-react-renderer";
|
|
7
|
+
|
|
8
|
+
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
9
|
+
|
|
10
|
+
if (!import.meta.env.SSR) {
|
|
11
|
+
globalThis.Prism = Prism;
|
|
12
|
+
// @ts-expect-error This is untyped
|
|
13
|
+
import("prismjs/components/prism-bash.min.js");
|
|
14
|
+
// @ts-expect-error This is untyped
|
|
15
|
+
import("prismjs/components/prism-ruby.min.js");
|
|
16
|
+
// @ts-expect-error This is untyped
|
|
17
|
+
import("prismjs/components/prism-markup-templating.js");
|
|
18
|
+
// @ts-expect-error This is untyped
|
|
19
|
+
import("prismjs/components/prism-php.min.js");
|
|
20
|
+
// @ts-expect-error This is untyped
|
|
21
|
+
import("prismjs/components/prism-json.min.js");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
import { useState } from "react";
|
|
25
|
+
import { cn } from "../util/cn.js";
|
|
26
|
+
import { useTheme } from "./context/ThemeContext.js";
|
|
27
|
+
|
|
28
|
+
type SyntaxHighlightProps = {
|
|
29
|
+
className?: string;
|
|
30
|
+
noBackground?: boolean;
|
|
31
|
+
wrapLines?: boolean;
|
|
32
|
+
copyable?: boolean;
|
|
33
|
+
} & Omit<HighlightProps, "children">;
|
|
34
|
+
|
|
35
|
+
export const SyntaxHighlight = ({
|
|
36
|
+
copyable = true,
|
|
37
|
+
...props
|
|
38
|
+
}: SyntaxHighlightProps) => {
|
|
39
|
+
const [isDark] = useTheme();
|
|
40
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Highlight theme={isDark ? themes.vsDark : themes.github} {...props}>
|
|
44
|
+
{({ className, style, tokens, getLineProps, getTokenProps }) => (
|
|
45
|
+
<pre
|
|
46
|
+
className={cn(
|
|
47
|
+
"group relative",
|
|
48
|
+
className,
|
|
49
|
+
props.className,
|
|
50
|
+
props.noBackground && "!bg-transparent",
|
|
51
|
+
props.wrapLines && "whitespace-pre-wrap break-words",
|
|
52
|
+
)}
|
|
53
|
+
style={style}
|
|
54
|
+
>
|
|
55
|
+
{copyable && (
|
|
56
|
+
<button
|
|
57
|
+
type="button"
|
|
58
|
+
aria-label="Copy code"
|
|
59
|
+
className="absolute top-1.5 right-3 p-3 opacity-0 group-hover:opacity-100 transition hover:bg-zinc-500/10 hover:dark:bg-zinc-700/25 rounded-lg text-sm text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-400"
|
|
60
|
+
disabled={isCopied}
|
|
61
|
+
onClick={() => {
|
|
62
|
+
setIsCopied(true);
|
|
63
|
+
navigator.clipboard.writeText(
|
|
64
|
+
tokens
|
|
65
|
+
.map((line) => line.map(({ content }) => content).join(""))
|
|
66
|
+
.join("\n"),
|
|
67
|
+
);
|
|
68
|
+
setTimeout(() => setIsCopied(false), 2000);
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
{isCopied ? (
|
|
72
|
+
<CheckIcon className="text-emerald-600" size={18} />
|
|
73
|
+
) : (
|
|
74
|
+
<CopyIcon size={18} />
|
|
75
|
+
)}
|
|
76
|
+
</button>
|
|
77
|
+
)}
|
|
78
|
+
<span className="absolute top-1.5 right-3 text-[11px] font-mono text-muted-foreground transition group-hover:opacity-0">
|
|
79
|
+
{props.language}
|
|
80
|
+
</span>
|
|
81
|
+
{tokens.map((line, i) => (
|
|
82
|
+
<div key={i} {...getLineProps({ line })}>
|
|
83
|
+
{line.map((token, key) => (
|
|
84
|
+
<span key={key} {...getTokenProps({ token })} />
|
|
85
|
+
))}
|
|
86
|
+
</div>
|
|
87
|
+
))}
|
|
88
|
+
</pre>
|
|
89
|
+
)}
|
|
90
|
+
</Highlight>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { cx } from "class-variance-authority";
|
|
2
|
+
import { NavLink } from "react-router-dom";
|
|
3
|
+
|
|
4
|
+
import { useDevPortal } from "./context/DevPortalProvider.js";
|
|
5
|
+
|
|
6
|
+
export const TopNavigation = () => {
|
|
7
|
+
const { navigation } = useDevPortal();
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<nav className="border-b border-border text-sm px-12 h-[--top-nav-height]">
|
|
11
|
+
<ul className="flex flex-row items-center gap-8">
|
|
12
|
+
{navigation.map((item) => (
|
|
13
|
+
<li key={item.label}>
|
|
14
|
+
<NavLink
|
|
15
|
+
className={({ isActive }) =>
|
|
16
|
+
cx(
|
|
17
|
+
"block py-3.5 font-medium -mb-px border-b-2",
|
|
18
|
+
isActive
|
|
19
|
+
? "border-primary text-foreground"
|
|
20
|
+
: "border-transparent text-foreground/75 hover:text-foreground hover:border-accent-foreground/25",
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
to={item.path}
|
|
24
|
+
>
|
|
25
|
+
{item.label}
|
|
26
|
+
</NavLink>
|
|
27
|
+
</li>
|
|
28
|
+
))}
|
|
29
|
+
</ul>
|
|
30
|
+
</nav>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
useContext,
|
|
4
|
+
type ComponentProps,
|
|
5
|
+
type ComponentType,
|
|
6
|
+
} from "react";
|
|
7
|
+
import { Header } from "../Header.js";
|
|
8
|
+
|
|
9
|
+
export const DEFAULT_COMPONENTS = {
|
|
10
|
+
Header,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type ComponentsContextType = {
|
|
14
|
+
Header?: ComponentType<ComponentProps<typeof Header>>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const ComponentsContext =
|
|
18
|
+
createContext<Required<ComponentsContextType>>(DEFAULT_COMPONENTS);
|
|
19
|
+
|
|
20
|
+
export const ComponentsProvider = ComponentsContext.Provider;
|
|
21
|
+
|
|
22
|
+
export const useComponents = () => {
|
|
23
|
+
return useContext(ComponentsContext);
|
|
24
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useSuspenseQuery } from "@tanstack/react-query";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { matchPath, useLocation } from "react-router-dom";
|
|
4
|
+
import { DevPortalContext } from "../../core/DevPortalContext.js";
|
|
5
|
+
|
|
6
|
+
const DevPortalReactContext = createContext<DevPortalContext | undefined>(
|
|
7
|
+
undefined,
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export const DevPortalProvider = DevPortalReactContext.Provider;
|
|
11
|
+
|
|
12
|
+
export const useDevPortal = () => {
|
|
13
|
+
const context = useContext(DevPortalReactContext);
|
|
14
|
+
|
|
15
|
+
if (!context) {
|
|
16
|
+
throw new Error("useDevPortal must be used within a DevPortalProvider.");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return context;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const useApiIdentities = () => {
|
|
23
|
+
const { getApiIdentities } = useDevPortal();
|
|
24
|
+
return useSuspenseQuery({
|
|
25
|
+
queryFn: getApiIdentities,
|
|
26
|
+
queryKey: ["api-keys"],
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const useTopNavigationItem = () => {
|
|
31
|
+
const { navigation } = useDevPortal();
|
|
32
|
+
const location = useLocation();
|
|
33
|
+
|
|
34
|
+
return navigation.find((item) =>
|
|
35
|
+
matchPath({ path: item.path, end: false }, location.pathname),
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const useNavigation = () => {
|
|
40
|
+
const { getNavigation } = useDevPortal();
|
|
41
|
+
const navItem = useTopNavigationItem();
|
|
42
|
+
|
|
43
|
+
const path = navItem?.path ?? "";
|
|
44
|
+
|
|
45
|
+
return useSuspenseQuery({
|
|
46
|
+
queryFn: async () => {
|
|
47
|
+
return {
|
|
48
|
+
items: [...(navItem?.categories ?? []), ...(await getNavigation(path))],
|
|
49
|
+
currentTopNavItem: navItem,
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
queryKey: ["navigation", path],
|
|
53
|
+
});
|
|
54
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
type ReactNode,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useState,
|
|
7
|
+
useContext,
|
|
8
|
+
} from "react";
|
|
9
|
+
|
|
10
|
+
const ThemeContext = createContext<readonly [boolean, () => void]>([
|
|
11
|
+
false,
|
|
12
|
+
() => {},
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
export const useTheme = () => {
|
|
16
|
+
const context = useContext(ThemeContext);
|
|
17
|
+
if (!context) {
|
|
18
|
+
throw new Error("useTheme must be used within a ThemeProvider");
|
|
19
|
+
}
|
|
20
|
+
return context;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const ThemeProvider = (props: { children: ReactNode }) => {
|
|
24
|
+
const [dark, setDark] = useState(false);
|
|
25
|
+
|
|
26
|
+
// On mount, read the preferred theme from the persistence
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const theme = localStorage.getItem("theme");
|
|
29
|
+
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)");
|
|
30
|
+
const isDark = theme === "dark" || (!theme && prefersDark.matches);
|
|
31
|
+
|
|
32
|
+
setDark(isDark);
|
|
33
|
+
}, [dark]);
|
|
34
|
+
|
|
35
|
+
// To toggle between dark and light modes
|
|
36
|
+
const toggle = useCallback(() => {
|
|
37
|
+
const toggled = !dark;
|
|
38
|
+
document.documentElement.classList.toggle("dark", toggled);
|
|
39
|
+
localStorage.setItem("theme", toggled ? "dark" : "light");
|
|
40
|
+
setDark(toggled);
|
|
41
|
+
}, [dark]);
|
|
42
|
+
|
|
43
|
+
const value = [dark, toggle] as const;
|
|
44
|
+
|
|
45
|
+
return <ThemeContext.Provider value={value} {...props} />;
|
|
46
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ReactNode,
|
|
3
|
+
createContext,
|
|
4
|
+
useCallback,
|
|
5
|
+
useContext,
|
|
6
|
+
useEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
} from "react";
|
|
11
|
+
|
|
12
|
+
type AnchorContextType = {
|
|
13
|
+
activeAnchor?: string;
|
|
14
|
+
setActiveAnchor: (anchor: string) => void;
|
|
15
|
+
observe: (element: HTMLElement | null) => void;
|
|
16
|
+
unobserve: (element: HTMLElement | null) => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const ViewportAnchorContext = createContext<AnchorContextType | undefined>(
|
|
20
|
+
undefined,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export const useViewportAnchor = () => {
|
|
24
|
+
const context = useContext(ViewportAnchorContext);
|
|
25
|
+
|
|
26
|
+
if (!context) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
"useViewportAnchor must be used within a CurrentAnchorProvider",
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return context;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const useRegisterAnchorElement = () => {
|
|
36
|
+
const elementRef = useRef<HTMLElement | null>(null);
|
|
37
|
+
|
|
38
|
+
const { observe, unobserve } = useViewportAnchor();
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const element = elementRef.current;
|
|
42
|
+
|
|
43
|
+
if (!element) return;
|
|
44
|
+
|
|
45
|
+
observe(element);
|
|
46
|
+
|
|
47
|
+
return () => unobserve(element);
|
|
48
|
+
}, [observe, unobserve]);
|
|
49
|
+
|
|
50
|
+
const setRef = useCallback((el: HTMLElement | null) => {
|
|
51
|
+
if (!el) return;
|
|
52
|
+
elementRef.current = el;
|
|
53
|
+
}, []);
|
|
54
|
+
|
|
55
|
+
return { ref: setRef };
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const ViewportAnchorProvider = ({
|
|
59
|
+
children,
|
|
60
|
+
}: {
|
|
61
|
+
children: ReactNode;
|
|
62
|
+
}) => {
|
|
63
|
+
const [activeAnchor, setActiveAnchor] = useState("");
|
|
64
|
+
const observerRef = useRef<IntersectionObserver | null>(null);
|
|
65
|
+
const registeredElements = useRef(new Set<HTMLElement>());
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
observerRef.current = new IntersectionObserver(
|
|
69
|
+
(entries) => {
|
|
70
|
+
for (const entry of entries) {
|
|
71
|
+
if (entry.isIntersecting && entry.target.id) {
|
|
72
|
+
setActiveAnchor(entry.target.id);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
// 115px is the height of the sticky header
|
|
78
|
+
// see --header-height in `main.css`
|
|
79
|
+
rootMargin: "115px 0px -80% 0px",
|
|
80
|
+
threshold: 0.75,
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return () => observerRef.current?.disconnect();
|
|
85
|
+
}, []);
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const elements = registeredElements.current;
|
|
89
|
+
const handleScroll = () => {
|
|
90
|
+
const hasReachedTop = window.scrollY === 0;
|
|
91
|
+
const hasReachedBottom =
|
|
92
|
+
window.innerHeight + window.scrollY >= document.body.scrollHeight;
|
|
93
|
+
|
|
94
|
+
if (hasReachedTop) {
|
|
95
|
+
// reset the active anchor when we reach the top
|
|
96
|
+
setActiveAnchor("");
|
|
97
|
+
} else if (hasReachedBottom) {
|
|
98
|
+
requestIdleCallback(() => {
|
|
99
|
+
// set the last anchor when we reach the bottom
|
|
100
|
+
const lastItem = Array.from(elements).pop();
|
|
101
|
+
setActiveAnchor(lastItem?.id ?? "");
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
document.addEventListener("scroll", handleScroll);
|
|
107
|
+
|
|
108
|
+
return () => {
|
|
109
|
+
elements.clear();
|
|
110
|
+
document.removeEventListener("scroll", handleScroll);
|
|
111
|
+
};
|
|
112
|
+
}, []);
|
|
113
|
+
|
|
114
|
+
const observeFns = useMemo(() => {
|
|
115
|
+
return {
|
|
116
|
+
observe: (element: HTMLElement | null) => {
|
|
117
|
+
if (!element || !observerRef.current) return;
|
|
118
|
+
registeredElements.current.add(element);
|
|
119
|
+
observerRef.current.observe(element);
|
|
120
|
+
},
|
|
121
|
+
unobserve: (element: HTMLElement | null) => {
|
|
122
|
+
if (!element || !observerRef.current) return;
|
|
123
|
+
registeredElements.current.delete(element);
|
|
124
|
+
observerRef.current.unobserve(element);
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}, []);
|
|
128
|
+
|
|
129
|
+
const value = useMemo(
|
|
130
|
+
() => ({ activeAnchor, setActiveAnchor, ...observeFns }),
|
|
131
|
+
[activeAnchor, setActiveAnchor, observeFns],
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<ViewportAnchorContext.Provider value={value}>
|
|
136
|
+
{children}
|
|
137
|
+
</ViewportAnchorContext.Provider>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { useNavigation } from "../context/DevPortalProvider.js";
|
|
4
|
+
import { SideNavigationCategory } from "./SideNavigationCategory.js";
|
|
5
|
+
import { SideNavigationWrapper } from "./SideNavigationWrapper.js";
|
|
6
|
+
|
|
7
|
+
export const SideNavigation = () => {
|
|
8
|
+
const navRef = useRef<HTMLDivElement | null>(null);
|
|
9
|
+
const navigation = useNavigation();
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<SideNavigationWrapper ref={navRef}>
|
|
13
|
+
{navigation.data.items.map((category) => (
|
|
14
|
+
<SideNavigationCategory key={category.label} category={category} />
|
|
15
|
+
))}
|
|
16
|
+
</SideNavigationWrapper>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as Collapsible from "@radix-ui/react-collapsible";
|
|
2
|
+
import { ChevronRightIcon } from "lucide-react";
|
|
3
|
+
import { useLocation } from "react-router-dom";
|
|
4
|
+
import type { NavigationCategory } from "../../core/DevPortalContext.js";
|
|
5
|
+
import { cn } from "../../util/cn.js";
|
|
6
|
+
import { joinPath } from "../../util/joinPath.js";
|
|
7
|
+
import { useTopNavigationItem } from "../context/DevPortalProvider.js";
|
|
8
|
+
import { useViewportAnchor } from "../context/ViewportAnchorContext.js";
|
|
9
|
+
import { SideNavigationItem } from "./SideNavigationItem.js";
|
|
10
|
+
import { useNavigationCollapsibleState } from "./useNavigationCollapsibleState.js";
|
|
11
|
+
import { checkHasActiveItem, isPathItem } from "./util.js";
|
|
12
|
+
|
|
13
|
+
export const SideNavigationCategory = ({
|
|
14
|
+
category,
|
|
15
|
+
}: {
|
|
16
|
+
category: NavigationCategory;
|
|
17
|
+
}) => {
|
|
18
|
+
const { activeAnchor } = useViewportAnchor();
|
|
19
|
+
const navItem = useTopNavigationItem();
|
|
20
|
+
const location = useLocation();
|
|
21
|
+
|
|
22
|
+
const isCollapsible = category.collapsible ?? true;
|
|
23
|
+
|
|
24
|
+
const [isOpen, setIsOpen] = useNavigationCollapsibleState({
|
|
25
|
+
item: category,
|
|
26
|
+
path: navItem?.path ?? "",
|
|
27
|
+
defaultOpen: () =>
|
|
28
|
+
!isCollapsible ||
|
|
29
|
+
category.expanded ||
|
|
30
|
+
checkHasActiveItem(category, location.pathname, navItem?.path ?? ""),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Collapsible.Root
|
|
35
|
+
key={category.label}
|
|
36
|
+
open={isOpen}
|
|
37
|
+
onOpenChange={() => setIsOpen((prev) => !prev)}
|
|
38
|
+
>
|
|
39
|
+
{category.label.length > 0 && (
|
|
40
|
+
<Collapsible.Trigger asChild={isCollapsible} disabled={!isCollapsible}>
|
|
41
|
+
<h5
|
|
42
|
+
className={cn(
|
|
43
|
+
"flex group items-center justify-between cursor-pointer font-semibold text-foreground/90 px-[--padding-nav-item] py-1.5 rounded-lg transition-colors duration-300 -mx-[--padding-nav-item]",
|
|
44
|
+
isCollapsible ? "hover:bg-accent" : "cursor-auto",
|
|
45
|
+
)}
|
|
46
|
+
>
|
|
47
|
+
{category.label}
|
|
48
|
+
{isCollapsible && (
|
|
49
|
+
<ChevronRightIcon
|
|
50
|
+
className="group-data-[state=open]:rotate-90 transition"
|
|
51
|
+
size={16}
|
|
52
|
+
/>
|
|
53
|
+
)}
|
|
54
|
+
</h5>
|
|
55
|
+
</Collapsible.Trigger>
|
|
56
|
+
)}
|
|
57
|
+
<Collapsible.Content className="CollapsibleContent -mx-[--padding-nav-item]">
|
|
58
|
+
{/* margin on Collapsible.Content will lead jumpiness when animating because it's not added to the calculated height */}
|
|
59
|
+
<ul className="space-y-0.5 mt-1.5 mb-4 ms-3">
|
|
60
|
+
{category.children.map((item) => (
|
|
61
|
+
<SideNavigationItem
|
|
62
|
+
key={isPathItem(item) ? item.path + item.label : item.href}
|
|
63
|
+
category={category}
|
|
64
|
+
item={item}
|
|
65
|
+
activeAnchor={activeAnchor}
|
|
66
|
+
currentTopNavItem={navItem}
|
|
67
|
+
basePath={joinPath(navItem?.path, category.path)}
|
|
68
|
+
/>
|
|
69
|
+
))}
|
|
70
|
+
</ul>
|
|
71
|
+
</Collapsible.Content>
|
|
72
|
+
</Collapsible.Root>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import * as Collapsible from "@radix-ui/react-collapsible";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import { ChevronRightIcon, ExternalLinkIcon } from "lucide-react";
|
|
4
|
+
import { NavLink, useLocation } from "react-router-dom";
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
NavigationCategory,
|
|
8
|
+
NavigationCategoryItem,
|
|
9
|
+
NavigationItem,
|
|
10
|
+
} from "../../core/DevPortalContext.js";
|
|
11
|
+
import { cn } from "../../util/cn.js";
|
|
12
|
+
import { joinPath } from "../../util/joinPath.js";
|
|
13
|
+
import { AnchorLink } from "../AnchorLink.js";
|
|
14
|
+
import { DynamicIcon, isValidIcon } from "../DynamicIcon.js";
|
|
15
|
+
import { useNavigationCollapsibleState } from "./useNavigationCollapsibleState.js";
|
|
16
|
+
import { checkHasActiveItem, isLinkItem, isPathItem } from "./util.js";
|
|
17
|
+
|
|
18
|
+
export const linkItem = cva(
|
|
19
|
+
"flex px-[--padding-nav-item] py-1.5 rounded-lg hover:bg-accent transition-colors duration-300",
|
|
20
|
+
{
|
|
21
|
+
variants: {
|
|
22
|
+
isActive: {
|
|
23
|
+
true: "text-primary font-medium",
|
|
24
|
+
false: "text-foreground/80",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export const DATA_ANCHOR_ATTR = "data-anchor";
|
|
31
|
+
|
|
32
|
+
export const SideNavigationItem = ({
|
|
33
|
+
category,
|
|
34
|
+
item,
|
|
35
|
+
activeAnchor,
|
|
36
|
+
currentTopNavItem,
|
|
37
|
+
basePath = "",
|
|
38
|
+
}: {
|
|
39
|
+
category: NavigationCategory;
|
|
40
|
+
item: NavigationCategoryItem;
|
|
41
|
+
activeAnchor?: string;
|
|
42
|
+
currentTopNavItem?: NavigationItem;
|
|
43
|
+
basePath?: string;
|
|
44
|
+
}) => {
|
|
45
|
+
const currentPath = isPathItem(item) ? joinPath(basePath, item.path) : "";
|
|
46
|
+
const location = useLocation();
|
|
47
|
+
|
|
48
|
+
const [isOpen, setIsOpen] = useNavigationCollapsibleState({
|
|
49
|
+
item,
|
|
50
|
+
path: currentPath,
|
|
51
|
+
defaultOpen: () => checkHasActiveItem(item, location.pathname, currentPath),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (isLinkItem(item)) {
|
|
55
|
+
const classes = cn(
|
|
56
|
+
"flex items-center gap-2",
|
|
57
|
+
linkItem({ isActive: item.href === location.pathname }),
|
|
58
|
+
);
|
|
59
|
+
return item.href.startsWith("http") ? (
|
|
60
|
+
<a
|
|
61
|
+
className={classes}
|
|
62
|
+
href={item.href}
|
|
63
|
+
target="_blank"
|
|
64
|
+
rel="noopener noreferrer"
|
|
65
|
+
>
|
|
66
|
+
{item.label}
|
|
67
|
+
<ExternalLinkIcon size={14} />
|
|
68
|
+
</a>
|
|
69
|
+
) : (
|
|
70
|
+
<NavLink className={classes} to={item.href}>
|
|
71
|
+
{item.label}
|
|
72
|
+
</NavLink>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const linkContent = (
|
|
77
|
+
<div className="flex justify-between w-full">
|
|
78
|
+
<div className="flex items-center gap-2 truncate w-full">
|
|
79
|
+
{isValidIcon(item.icon) && <DynamicIcon name={item.icon} size={16} />}
|
|
80
|
+
{typeof item.label !== "string" ? (
|
|
81
|
+
item.label
|
|
82
|
+
) : (
|
|
83
|
+
<span className="truncate">{item.label}</span>
|
|
84
|
+
)}
|
|
85
|
+
</div>
|
|
86
|
+
{item.children && (
|
|
87
|
+
<ChevronRightIcon
|
|
88
|
+
size={16}
|
|
89
|
+
className="transition shrink-0 group-data-[state=open]:rotate-90"
|
|
90
|
+
/>
|
|
91
|
+
)}
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<li title={typeof item.label === "string" ? item.label : item.title}>
|
|
97
|
+
{item.children ? (
|
|
98
|
+
<Collapsible.Root
|
|
99
|
+
open={isOpen}
|
|
100
|
+
onOpenChange={() => setIsOpen((prev) => !prev)}
|
|
101
|
+
className="flex flex-col"
|
|
102
|
+
>
|
|
103
|
+
<Collapsible.Trigger
|
|
104
|
+
className={cn("group text-start", linkItem({ isActive: false }))}
|
|
105
|
+
>
|
|
106
|
+
{linkContent}
|
|
107
|
+
</Collapsible.Trigger>
|
|
108
|
+
<Collapsible.Content className="CollapsibleContent ms-[calc(var(--padding-nav-item)*1.125)]">
|
|
109
|
+
<ul className="mt-1 border-border border-l ps-1.5">
|
|
110
|
+
{item.children.map((child) => (
|
|
111
|
+
<SideNavigationItem
|
|
112
|
+
key={isPathItem(child) ? child.path : child.href}
|
|
113
|
+
category={category}
|
|
114
|
+
item={child}
|
|
115
|
+
activeAnchor={activeAnchor}
|
|
116
|
+
currentTopNavItem={currentTopNavItem}
|
|
117
|
+
basePath={currentPath}
|
|
118
|
+
/>
|
|
119
|
+
))}
|
|
120
|
+
</ul>
|
|
121
|
+
</Collapsible.Content>
|
|
122
|
+
</Collapsible.Root>
|
|
123
|
+
) : item.path.startsWith("#") ? (
|
|
124
|
+
<AnchorLink
|
|
125
|
+
to={item.path}
|
|
126
|
+
{...{ [DATA_ANCHOR_ATTR]: item.path }}
|
|
127
|
+
className={linkItem({
|
|
128
|
+
isActive: item.path.slice(1) === activeAnchor,
|
|
129
|
+
})}
|
|
130
|
+
>
|
|
131
|
+
{linkContent}
|
|
132
|
+
</AnchorLink>
|
|
133
|
+
) : (
|
|
134
|
+
<NavLink
|
|
135
|
+
className={({ isActive }) => linkItem({ isActive })}
|
|
136
|
+
to={currentPath}
|
|
137
|
+
>
|
|
138
|
+
{linkContent}
|
|
139
|
+
</NavLink>
|
|
140
|
+
)}
|
|
141
|
+
</li>
|
|
142
|
+
);
|
|
143
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { forwardRef, type PropsWithChildren } from "react";
|
|
2
|
+
|
|
3
|
+
export const SideNavigationWrapper = forwardRef<
|
|
4
|
+
HTMLDivElement,
|
|
5
|
+
PropsWithChildren
|
|
6
|
+
>(({ children }, ref) => {
|
|
7
|
+
return (
|
|
8
|
+
<nav
|
|
9
|
+
className="hidden lg:flex flex-col fixed text-sm overflow-y-auto shrink-0 p-[--padding-nav-item] -mx-[--padding-nav-item] pb-20 pt-[--padding-content-top] w-[--side-nav-width] h-[calc(100%-var(--header-height))] scroll-pt-2 gap-2"
|
|
10
|
+
ref={ref}
|
|
11
|
+
>
|
|
12
|
+
{children}
|
|
13
|
+
</nav>
|
|
14
|
+
);
|
|
15
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { useLocation } from "react-router-dom";
|
|
3
|
+
import type { NavigationNode } from "../../util/traverseNavigation.js";
|
|
4
|
+
import { checkHasActiveItem } from "./util.js";
|
|
5
|
+
|
|
6
|
+
export const useNavigationCollapsibleState = ({
|
|
7
|
+
item,
|
|
8
|
+
defaultOpen,
|
|
9
|
+
path,
|
|
10
|
+
}: {
|
|
11
|
+
item: NavigationNode;
|
|
12
|
+
defaultOpen: () => boolean;
|
|
13
|
+
path: string;
|
|
14
|
+
}) => {
|
|
15
|
+
const [isOpen, setIsOpen] = useState(defaultOpen);
|
|
16
|
+
const location = useLocation();
|
|
17
|
+
const previousLocationPath = useRef(location.pathname);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!isOpen && previousLocationPath.current !== location.pathname) {
|
|
21
|
+
setIsOpen(checkHasActiveItem(item, location.pathname, path));
|
|
22
|
+
}
|
|
23
|
+
previousLocationPath.current = location.pathname;
|
|
24
|
+
}, [isOpen, item, path, location.pathname]);
|
|
25
|
+
|
|
26
|
+
return [isOpen, setIsOpen] as const;
|
|
27
|
+
};
|