@hanzo/docs-base-ui 16.5.3 → 16.7.5
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/css/generated/docs.css +68 -33
- package/css/generated/flux.css +44 -34
- package/css/generated/home.css +88 -4
- package/css/generated/notebook.css +65 -31
- package/css/generated/shared.css +199 -59
- package/css/lib/base.css +1 -4
- package/css/lib/shiki.css +49 -41
- package/css/preset.css +3 -0
- package/dist/_virtual/_rolldown/runtime.js +6 -11
- package/dist/components/accordion.d.ts +1 -2
- package/dist/components/accordion.js +3 -7
- package/dist/components/banner.d.ts +1 -2
- package/dist/components/banner.js +1 -5
- package/dist/components/callout.d.ts +1 -2
- package/dist/components/callout.js +0 -3
- package/dist/components/card.d.ts +1 -2
- package/dist/components/card.js +0 -3
- package/dist/components/codeblock.d.ts +1 -2
- package/dist/components/codeblock.js +2 -6
- package/dist/components/codeblock.rsc.d.ts +21 -0
- package/dist/components/codeblock.rsc.js +22 -0
- package/dist/components/dialog/search-algolia.d.ts +1 -3
- package/dist/components/dialog/search-algolia.js +1 -5
- package/dist/components/dialog/search-default.d.ts +1 -3
- package/dist/components/dialog/search-default.js +1 -5
- package/dist/components/dialog/search-orama.d.ts +1 -3
- package/dist/components/dialog/search-orama.js +1 -5
- package/dist/components/dialog/search.d.ts +5 -5
- package/dist/components/dialog/search.js +124 -47
- package/dist/components/dynamic-codeblock.core.d.ts +7 -5
- package/dist/components/dynamic-codeblock.core.js +17 -32
- package/dist/components/dynamic-codeblock.d.ts +5 -3
- package/dist/components/dynamic-codeblock.js +8 -13
- package/dist/components/files.d.ts +1 -2
- package/dist/components/files.js +4 -8
- package/dist/components/github-info.d.ts +22 -9
- package/dist/components/github-info.js +33 -28
- package/dist/components/heading.d.ts +1 -2
- package/dist/components/heading.js +2 -5
- package/dist/components/image-zoom.d.ts +1 -2
- package/dist/components/image-zoom.js +2 -5
- package/dist/components/inline-toc.d.ts +1 -2
- package/dist/components/inline-toc.js +1 -5
- package/dist/components/sidebar/base.d.ts +7 -3
- package/dist/components/sidebar/base.js +6 -16
- package/dist/components/sidebar/link-item.d.ts +2 -3
- package/dist/components/sidebar/link-item.js +6 -3
- package/dist/components/sidebar/page-tree.d.ts +1 -2
- package/dist/components/sidebar/page-tree.js +54 -43
- package/dist/components/sidebar/tabs/dropdown.d.ts +4 -7
- package/dist/components/sidebar/tabs/dropdown.js +4 -11
- package/dist/components/sidebar/tabs/index.d.ts +3 -17
- package/dist/components/sidebar/tabs/index.js +0 -3
- package/dist/components/steps.d.ts +1 -2
- package/dist/components/steps.js +0 -3
- package/dist/components/tabs.d.ts +11 -7
- package/dist/components/tabs.js +13 -18
- package/dist/components/toc/clerk.d.ts +9 -2
- package/dist/components/toc/clerk.js +117 -62
- package/dist/components/toc/default.d.ts +9 -2
- package/dist/components/toc/default.js +28 -21
- package/dist/components/toc/index.d.ts +8 -5
- package/dist/components/toc/index.js +50 -25
- package/dist/components/type-table.d.ts +10 -5
- package/dist/components/type-table.js +22 -17
- package/dist/components/ui/accordion.d.ts +1 -2
- package/dist/components/ui/accordion.js +1 -5
- package/dist/components/ui/button.d.ts +2 -3
- package/dist/components/ui/button.js +0 -3
- package/dist/components/ui/collapsible.d.ts +1 -2
- package/dist/components/ui/collapsible.js +2 -6
- package/dist/components/ui/navigation-menu.d.ts +26 -12
- package/dist/components/ui/navigation-menu.js +52 -30
- package/dist/components/ui/popover.d.ts +10 -5
- package/dist/components/ui/popover.js +14 -18
- package/dist/components/ui/scroll-area.d.ts +17 -7
- package/dist/components/ui/scroll-area.js +26 -30
- package/dist/components/ui/tabs.d.ts +1 -2
- package/dist/components/ui/tabs.js +1 -5
- package/dist/contexts/i18n.d.ts +7 -5
- package/dist/contexts/i18n.js +3 -8
- package/dist/contexts/search.d.ts +2 -2
- package/dist/contexts/search.js +4 -6
- package/dist/contexts/tree.d.ts +1 -2
- package/dist/contexts/tree.js +1 -5
- package/dist/i18n.d.ts +16 -9
- package/dist/i18n.js +14 -14
- package/dist/layouts/docs/client.d.ts +30 -29
- package/dist/layouts/docs/client.js +72 -48
- package/dist/layouts/docs/index.d.ts +19 -33
- package/dist/layouts/docs/index.js +16 -172
- package/dist/layouts/docs/page/index.d.ts +67 -55
- package/dist/layouts/docs/page/index.js +74 -54
- package/dist/layouts/docs/page/slots/breadcrumb.d.ts +14 -0
- package/dist/layouts/docs/page/slots/breadcrumb.js +44 -0
- package/dist/layouts/docs/page/slots/container.d.ts +7 -0
- package/dist/layouts/docs/page/slots/container.js +17 -0
- package/dist/layouts/docs/page/slots/footer.d.ts +23 -0
- package/dist/layouts/docs/page/slots/footer.js +56 -0
- package/dist/layouts/docs/page/slots/toc.d.ts +55 -0
- package/dist/layouts/docs/page/slots/toc.js +166 -0
- package/dist/layouts/docs/slots/container.d.ts +7 -0
- package/dist/layouts/docs/slots/container.js +29 -0
- package/dist/layouts/docs/slots/header.d.ts +8 -0
- package/dist/layouts/docs/slots/header.js +38 -0
- package/dist/layouts/docs/slots/sidebar.d.ts +30 -0
- package/dist/layouts/docs/slots/sidebar.js +319 -0
- package/dist/layouts/flux/index.d.ts +34 -39
- package/dist/layouts/flux/index.js +77 -99
- package/dist/layouts/flux/page/index.d.ts +56 -49
- package/dist/layouts/flux/page/index.js +63 -35
- package/dist/layouts/flux/page/slots/breadcrumb.d.ts +14 -0
- package/dist/layouts/flux/page/slots/breadcrumb.js +44 -0
- package/dist/layouts/flux/page/slots/container.d.ts +7 -0
- package/dist/layouts/flux/page/slots/container.js +17 -0
- package/dist/layouts/flux/page/slots/footer.d.ts +23 -0
- package/dist/layouts/flux/page/slots/footer.js +56 -0
- package/dist/layouts/flux/page/slots/toc.d.ts +34 -0
- package/dist/layouts/flux/page/slots/toc.js +172 -0
- package/dist/layouts/flux/slots/container.d.ts +7 -0
- package/dist/layouts/flux/slots/container.js +13 -0
- package/dist/layouts/flux/slots/sidebar.d.ts +23 -0
- package/dist/layouts/flux/{sidebar.js → slots/sidebar.js} +74 -34
- package/dist/layouts/flux/slots/tab-dropdown.d.ts +17 -0
- package/dist/layouts/flux/{tab-dropdown.js → slots/tab-dropdown.js} +13 -24
- package/dist/layouts/home/index.d.ts +24 -7
- package/dist/layouts/home/index.js +39 -19
- package/dist/layouts/home/navbar.d.ts +5 -14
- package/dist/layouts/home/navbar.js +10 -12
- package/dist/layouts/home/not-found.d.ts +9 -0
- package/dist/layouts/home/not-found.js +38 -0
- package/dist/layouts/home/slots/container.d.ts +7 -0
- package/dist/layouts/home/slots/container.js +13 -0
- package/dist/layouts/home/slots/header.d.ts +11 -0
- package/dist/layouts/home/slots/header.js +242 -0
- package/dist/layouts/notebook/client.d.ts +32 -44
- package/dist/layouts/notebook/client.js +57 -147
- package/dist/layouts/notebook/index.d.ts +25 -24
- package/dist/layouts/notebook/index.js +16 -212
- package/dist/layouts/notebook/page/index.d.ts +67 -55
- package/dist/layouts/notebook/page/index.js +74 -54
- package/dist/layouts/notebook/page/slots/breadcrumb.d.ts +14 -0
- package/dist/layouts/notebook/page/slots/breadcrumb.js +44 -0
- package/dist/layouts/notebook/page/slots/container.d.ts +7 -0
- package/dist/layouts/notebook/page/slots/container.js +17 -0
- package/dist/layouts/notebook/page/slots/footer.d.ts +23 -0
- package/dist/layouts/notebook/page/slots/footer.js +56 -0
- package/dist/layouts/notebook/page/slots/toc.d.ts +55 -0
- package/dist/layouts/notebook/page/slots/toc.js +165 -0
- package/dist/layouts/notebook/slots/container.d.ts +7 -0
- package/dist/layouts/notebook/slots/container.js +31 -0
- package/dist/layouts/notebook/slots/header.d.ts +8 -0
- package/dist/layouts/notebook/slots/header.js +194 -0
- package/dist/layouts/notebook/slots/sidebar.d.ts +40 -0
- package/dist/layouts/notebook/slots/sidebar.js +297 -0
- package/dist/layouts/shared/client.d.ts +45 -0
- package/dist/layouts/shared/client.js +84 -0
- package/dist/layouts/shared/index.d.ts +136 -34
- package/dist/layouts/shared/index.js +49 -17
- package/dist/layouts/shared/page-actions.d.ts +36 -0
- package/dist/layouts/shared/page-actions.js +190 -0
- package/dist/layouts/shared/slots/language-select.d.ts +10 -0
- package/dist/layouts/shared/{language-toggle.js → slots/language-select.js} +11 -15
- package/dist/layouts/shared/slots/search-trigger.d.ts +23 -0
- package/dist/layouts/shared/{search-toggle.js → slots/search-trigger.js} +9 -13
- package/dist/layouts/shared/slots/theme-switch.d.ts +14 -0
- package/dist/layouts/shared/{theme-toggle.js → slots/theme-switch.js} +5 -9
- package/dist/mdx.d.ts +13 -3
- package/dist/mdx.js +0 -4
- package/dist/mdx.server.d.ts +1 -2
- package/dist/mdx.server.js +0 -3
- package/dist/og/takumi.d.ts +21 -0
- package/dist/og/takumi.js +70 -0
- package/dist/og.d.ts +1 -2
- package/dist/og.js +6 -6
- package/dist/page.d.ts +3 -4
- package/dist/page.js +6 -11
- package/dist/provider/base.d.ts +1 -2
- package/dist/provider/base.js +2 -6
- package/dist/provider/next.d.ts +1 -2
- package/dist/provider/next.js +1 -5
- package/dist/provider/react-router.d.ts +1 -2
- package/dist/provider/react-router.js +1 -5
- package/dist/provider/tanstack.d.ts +1 -2
- package/dist/provider/tanstack.js +1 -5
- package/dist/provider/waku.d.ts +1 -2
- package/dist/provider/waku.js +1 -5
- package/dist/style.css +433 -166
- package/dist/tailwind/typography.d.ts +2 -0
- package/dist/tailwind/typography.js +2 -0
- package/dist/utils/cn.js +1 -2
- package/dist/utils/merge-refs.js +0 -2
- package/dist/utils/urls.js +1 -3
- package/dist/utils/use-copy-button.d.ts +1 -2
- package/dist/utils/use-copy-button.js +1 -5
- package/dist/utils/use-footer-items.d.ts +1 -2
- package/dist/utils/use-footer-items.js +4 -8
- package/dist/utils/use-is-scroll-top.d.ts +1 -2
- package/dist/utils/use-is-scroll-top.js +1 -5
- package/package.json +139 -103
- package/LICENSE +0 -21
- package/dist/components/accordion.d.ts.map +0 -1
- package/dist/components/accordion.js.map +0 -1
- package/dist/components/banner.d.ts.map +0 -1
- package/dist/components/banner.js.map +0 -1
- package/dist/components/callout.d.ts.map +0 -1
- package/dist/components/callout.js.map +0 -1
- package/dist/components/card.d.ts.map +0 -1
- package/dist/components/card.js.map +0 -1
- package/dist/components/codeblock.d.ts.map +0 -1
- package/dist/components/codeblock.js.map +0 -1
- package/dist/components/dialog/search-algolia.d.ts.map +0 -1
- package/dist/components/dialog/search-algolia.js.map +0 -1
- package/dist/components/dialog/search-default.d.ts.map +0 -1
- package/dist/components/dialog/search-default.js.map +0 -1
- package/dist/components/dialog/search-orama.d.ts.map +0 -1
- package/dist/components/dialog/search-orama.js.map +0 -1
- package/dist/components/dialog/search.d.ts.map +0 -1
- package/dist/components/dialog/search.js.map +0 -1
- package/dist/components/dynamic-codeblock.core.d.ts.map +0 -1
- package/dist/components/dynamic-codeblock.core.js.map +0 -1
- package/dist/components/dynamic-codeblock.d.ts.map +0 -1
- package/dist/components/dynamic-codeblock.js.map +0 -1
- package/dist/components/files.d.ts.map +0 -1
- package/dist/components/files.js.map +0 -1
- package/dist/components/github-info.d.ts.map +0 -1
- package/dist/components/github-info.js.map +0 -1
- package/dist/components/heading.d.ts.map +0 -1
- package/dist/components/heading.js.map +0 -1
- package/dist/components/image-zoom-DGvp66QF.css +0 -80
- package/dist/components/image-zoom-DGvp66QF.css.map +0 -1
- package/dist/components/image-zoom.d.ts.map +0 -1
- package/dist/components/image-zoom.js.map +0 -1
- package/dist/components/image-zoom2.js +0 -1
- package/dist/components/inline-toc.d.ts.map +0 -1
- package/dist/components/inline-toc.js.map +0 -1
- package/dist/components/sidebar/base.d.ts.map +0 -1
- package/dist/components/sidebar/base.js.map +0 -1
- package/dist/components/sidebar/link-item.d.ts.map +0 -1
- package/dist/components/sidebar/link-item.js.map +0 -1
- package/dist/components/sidebar/page-tree.d.ts.map +0 -1
- package/dist/components/sidebar/page-tree.js.map +0 -1
- package/dist/components/sidebar/tabs/dropdown.d.ts.map +0 -1
- package/dist/components/sidebar/tabs/dropdown.js.map +0 -1
- package/dist/components/sidebar/tabs/index.d.ts.map +0 -1
- package/dist/components/sidebar/tabs/index.js.map +0 -1
- package/dist/components/steps.d.ts.map +0 -1
- package/dist/components/steps.js.map +0 -1
- package/dist/components/tabs.d.ts.map +0 -1
- package/dist/components/tabs.js.map +0 -1
- package/dist/components/toc/clerk.d.ts.map +0 -1
- package/dist/components/toc/clerk.js.map +0 -1
- package/dist/components/toc/default.d.ts.map +0 -1
- package/dist/components/toc/default.js.map +0 -1
- package/dist/components/toc/index.d.ts.map +0 -1
- package/dist/components/toc/index.js.map +0 -1
- package/dist/components/type-table.d.ts.map +0 -1
- package/dist/components/type-table.js.map +0 -1
- package/dist/components/ui/accordion.d.ts.map +0 -1
- package/dist/components/ui/accordion.js.map +0 -1
- package/dist/components/ui/button.d.ts.map +0 -1
- package/dist/components/ui/button.js.map +0 -1
- package/dist/components/ui/collapsible.d.ts.map +0 -1
- package/dist/components/ui/collapsible.js.map +0 -1
- package/dist/components/ui/navigation-menu.d.ts.map +0 -1
- package/dist/components/ui/navigation-menu.js.map +0 -1
- package/dist/components/ui/popover.d.ts.map +0 -1
- package/dist/components/ui/popover.js.map +0 -1
- package/dist/components/ui/scroll-area.d.ts.map +0 -1
- package/dist/components/ui/scroll-area.js.map +0 -1
- package/dist/components/ui/tabs.d.ts.map +0 -1
- package/dist/components/ui/tabs.js.map +0 -1
- package/dist/contexts/i18n.d.ts.map +0 -1
- package/dist/contexts/i18n.js.map +0 -1
- package/dist/contexts/search.d.ts.map +0 -1
- package/dist/contexts/search.js.map +0 -1
- package/dist/contexts/tree.d.ts.map +0 -1
- package/dist/contexts/tree.js.map +0 -1
- package/dist/i18n.d.ts.map +0 -1
- package/dist/i18n.js.map +0 -1
- package/dist/layouts/docs/client.d.ts.map +0 -1
- package/dist/layouts/docs/client.js.map +0 -1
- package/dist/layouts/docs/index.d.ts.map +0 -1
- package/dist/layouts/docs/index.js.map +0 -1
- package/dist/layouts/docs/page/client.d.ts +0 -48
- package/dist/layouts/docs/page/client.d.ts.map +0 -1
- package/dist/layouts/docs/page/client.js +0 -227
- package/dist/layouts/docs/page/client.js.map +0 -1
- package/dist/layouts/docs/page/index.d.ts.map +0 -1
- package/dist/layouts/docs/page/index.js.map +0 -1
- package/dist/layouts/docs/sidebar.d.ts +0 -64
- package/dist/layouts/docs/sidebar.d.ts.map +0 -1
- package/dist/layouts/docs/sidebar.js +0 -162
- package/dist/layouts/docs/sidebar.js.map +0 -1
- package/dist/layouts/flux/index.d.ts.map +0 -1
- package/dist/layouts/flux/index.js.map +0 -1
- package/dist/layouts/flux/page/client.d.ts +0 -45
- package/dist/layouts/flux/page/client.d.ts.map +0 -1
- package/dist/layouts/flux/page/client.js +0 -255
- package/dist/layouts/flux/page/client.js.map +0 -1
- package/dist/layouts/flux/page/index.d.ts.map +0 -1
- package/dist/layouts/flux/page/index.js.map +0 -1
- package/dist/layouts/flux/sidebar.d.ts +0 -59
- package/dist/layouts/flux/sidebar.d.ts.map +0 -1
- package/dist/layouts/flux/sidebar.js.map +0 -1
- package/dist/layouts/flux/tab-dropdown.d.ts +0 -21
- package/dist/layouts/flux/tab-dropdown.d.ts.map +0 -1
- package/dist/layouts/flux/tab-dropdown.js.map +0 -1
- package/dist/layouts/home/client.d.ts +0 -19
- package/dist/layouts/home/client.d.ts.map +0 -1
- package/dist/layouts/home/client.js +0 -267
- package/dist/layouts/home/client.js.map +0 -1
- package/dist/layouts/home/index.d.ts.map +0 -1
- package/dist/layouts/home/index.js.map +0 -1
- package/dist/layouts/home/navbar.d.ts.map +0 -1
- package/dist/layouts/home/navbar.js.map +0 -1
- package/dist/layouts/notebook/client.d.ts.map +0 -1
- package/dist/layouts/notebook/client.js.map +0 -1
- package/dist/layouts/notebook/index.d.ts.map +0 -1
- package/dist/layouts/notebook/index.js.map +0 -1
- package/dist/layouts/notebook/page/client.d.ts +0 -48
- package/dist/layouts/notebook/page/client.d.ts.map +0 -1
- package/dist/layouts/notebook/page/client.js +0 -227
- package/dist/layouts/notebook/page/client.js.map +0 -1
- package/dist/layouts/notebook/page/index.d.ts.map +0 -1
- package/dist/layouts/notebook/page/index.js.map +0 -1
- package/dist/layouts/notebook/sidebar.d.ts +0 -60
- package/dist/layouts/notebook/sidebar.d.ts.map +0 -1
- package/dist/layouts/notebook/sidebar.js +0 -133
- package/dist/layouts/notebook/sidebar.js.map +0 -1
- package/dist/layouts/shared/index.d.ts.map +0 -1
- package/dist/layouts/shared/index.js.map +0 -1
- package/dist/layouts/shared/language-toggle.d.ts +0 -10
- package/dist/layouts/shared/language-toggle.d.ts.map +0 -1
- package/dist/layouts/shared/language-toggle.js.map +0 -1
- package/dist/layouts/shared/search-toggle.d.ts +0 -23
- package/dist/layouts/shared/search-toggle.d.ts.map +0 -1
- package/dist/layouts/shared/search-toggle.js.map +0 -1
- package/dist/layouts/shared/theme-toggle.d.ts +0 -14
- package/dist/layouts/shared/theme-toggle.d.ts.map +0 -1
- package/dist/layouts/shared/theme-toggle.js.map +0 -1
- package/dist/mdx.d.ts.map +0 -1
- package/dist/mdx.js.map +0 -1
- package/dist/mdx.server.d.ts.map +0 -1
- package/dist/mdx.server.js.map +0 -1
- package/dist/og.d.ts.map +0 -1
- package/dist/og.js.map +0 -1
- package/dist/page.d.ts.map +0 -1
- package/dist/page.js.map +0 -1
- package/dist/provider/base.d.ts.map +0 -1
- package/dist/provider/base.js.map +0 -1
- package/dist/provider/next.d.ts.map +0 -1
- package/dist/provider/next.js.map +0 -1
- package/dist/provider/react-router.d.ts.map +0 -1
- package/dist/provider/react-router.js.map +0 -1
- package/dist/provider/tanstack.d.ts.map +0 -1
- package/dist/provider/tanstack.js.map +0 -1
- package/dist/provider/waku.d.ts.map +0 -1
- package/dist/provider/waku.js.map +0 -1
- package/dist/utils/link-item.d.ts +0 -86
- package/dist/utils/link-item.d.ts.map +0 -1
- package/dist/utils/link-item.js +0 -25
- package/dist/utils/link-item.js.map +0 -1
- package/dist/utils/merge-refs.js.map +0 -1
- package/dist/utils/urls.js.map +0 -1
- package/dist/utils/use-copy-button.d.ts.map +0 -1
- package/dist/utils/use-copy-button.js.map +0 -1
- package/dist/utils/use-footer-items.d.ts.map +0 -1
- package/dist/utils/use-footer-items.js.map +0 -1
- package/dist/utils/use-is-scroll-top.d.ts.map +0 -1
- package/dist/utils/use-is-scroll-top.js.map +0 -1
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../../utils/cn.js";
|
|
3
|
+
import { buttonVariants } from "../../../components/ui/button.js";
|
|
4
|
+
import { mergeRefs } from "../../../utils/merge-refs.js";
|
|
5
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../../../components/ui/popover.js";
|
|
6
|
+
import { LinkItem } from "../../shared/client.js";
|
|
7
|
+
import { isLayoutTabActive } from "../../shared/index.js";
|
|
8
|
+
import { SidebarCollapseTrigger as SidebarCollapseTrigger$1, SidebarContent as SidebarContent$1, SidebarDrawerContent, SidebarDrawerOverlay, SidebarFolder as SidebarFolder$1, SidebarFolderContent as SidebarFolderContent$1, SidebarFolderLink as SidebarFolderLink$1, SidebarFolderTrigger as SidebarFolderTrigger$1, SidebarItem as SidebarItem$1, SidebarProvider as SidebarProvider$1, SidebarSeparator as SidebarSeparator$1, SidebarTrigger as SidebarTrigger$1, SidebarViewport, base_exports, useFolder, useFolderDepth } from "../../../components/sidebar/base.js";
|
|
9
|
+
import { createPageTreeRenderer } from "../../../components/sidebar/page-tree.js";
|
|
10
|
+
import { createLinkItemRenderer } from "../../../components/sidebar/link-item.js";
|
|
11
|
+
import { useNotebookLayout } from "../client.js";
|
|
12
|
+
import { createElement, useMemo, useRef, useState } from "react";
|
|
13
|
+
import { usePathname } from "@hanzo/docs-core/framework";
|
|
14
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
import Link from "@hanzo/docs-core/link";
|
|
16
|
+
import { Check, ChevronsUpDown, Languages, SidebarIcon, X } from "lucide-react";
|
|
17
|
+
import { cva } from "class-variance-authority";
|
|
18
|
+
//#region src/layouts/notebook/slots/sidebar.tsx
|
|
19
|
+
const itemVariants = cva("relative flex flex-row items-center gap-2 rounded-lg p-2 text-start text-fd-muted-foreground wrap-anywhere [&_svg]:size-4 [&_svg]:shrink-0", { variants: {
|
|
20
|
+
variant: {
|
|
21
|
+
link: "transition-colors hover:bg-fd-accent/50 hover:text-fd-accent-foreground/80 hover:transition-none data-[active=true]:bg-fd-primary/10 data-[active=true]:text-fd-primary data-[active=true]:hover:transition-colors",
|
|
22
|
+
button: "transition-colors hover:bg-fd-accent/50 hover:text-fd-accent-foreground/80 hover:transition-none"
|
|
23
|
+
},
|
|
24
|
+
highlight: { true: "data-[active=true]:before:content-[''] data-[active=true]:before:bg-fd-primary data-[active=true]:before:absolute data-[active=true]:before:w-px data-[active=true]:before:inset-y-2.5 data-[active=true]:before:start-2.5" }
|
|
25
|
+
} });
|
|
26
|
+
function getItemOffset(depth) {
|
|
27
|
+
return `calc(${2 + 3 * depth} * var(--spacing))`;
|
|
28
|
+
}
|
|
29
|
+
const { useSidebar } = base_exports;
|
|
30
|
+
function SidebarProvider(props) {
|
|
31
|
+
return /* @__PURE__ */ jsx(SidebarProvider$1, { ...props });
|
|
32
|
+
}
|
|
33
|
+
function SidebarTrigger(props) {
|
|
34
|
+
return /* @__PURE__ */ jsx(SidebarTrigger$1, { ...props });
|
|
35
|
+
}
|
|
36
|
+
function SidebarCollapseTrigger(props) {
|
|
37
|
+
return /* @__PURE__ */ jsx(SidebarCollapseTrigger$1, { ...props });
|
|
38
|
+
}
|
|
39
|
+
function SidebarContent({ ref: refProp, className, children, ...props }) {
|
|
40
|
+
const { props: { nav } } = useNotebookLayout();
|
|
41
|
+
const navMode = nav?.mode ?? "auto";
|
|
42
|
+
const ref = useRef(null);
|
|
43
|
+
return /* @__PURE__ */ jsx(SidebarContent$1, { children: ({ collapsed, hovered, ref: asideRef, ...rest }) => /* @__PURE__ */ jsxs("div", {
|
|
44
|
+
"data-sidebar-placeholder": "",
|
|
45
|
+
className: cn("sticky z-20 [grid-area:sidebar] pointer-events-none *:pointer-events-auto md:layout:[--fd-sidebar-width:268px] max-md:hidden", navMode === "auto" ? "top-(--fd-docs-row-1) h-[calc(var(--fd-docs-height)-var(--fd-docs-row-1))]" : "top-(--fd-docs-row-2) h-[calc(var(--fd-docs-height)-var(--fd-docs-row-2))]"),
|
|
46
|
+
children: [collapsed && /* @__PURE__ */ jsx("div", {
|
|
47
|
+
className: "absolute start-0 inset-y-0 w-4",
|
|
48
|
+
...rest
|
|
49
|
+
}), /* @__PURE__ */ jsx("aside", {
|
|
50
|
+
id: "nd-sidebar",
|
|
51
|
+
ref: mergeRefs(ref, refProp, asideRef),
|
|
52
|
+
"data-collapsed": collapsed,
|
|
53
|
+
"data-hovered": collapsed && hovered,
|
|
54
|
+
className: cn("absolute flex flex-col w-full start-0 inset-y-0 items-end text-sm duration-250 *:w-(--fd-sidebar-width)", navMode === "auto" && "bg-fd-card border-e", collapsed && ["inset-y-2 rounded-xl bg-fd-card transition-transform border w-(--fd-sidebar-width)", hovered ? "shadow-lg translate-x-2 rtl:-translate-x-2" : "-translate-x-(--fd-sidebar-width) rtl:translate-x-full"], ref.current && ref.current.getAttribute("data-collapsed") === "true" !== collapsed && "transition-[width,inset-block,translate,background-color]", className),
|
|
55
|
+
...props,
|
|
56
|
+
...rest,
|
|
57
|
+
children
|
|
58
|
+
})]
|
|
59
|
+
}) });
|
|
60
|
+
}
|
|
61
|
+
function SidebarDrawer({ children, className, ...props }) {
|
|
62
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SidebarDrawerOverlay, { className: "fixed z-40 inset-0 backdrop-blur-xs data-[state=open]:animate-fd-fade-in data-[state=closed]:animate-fd-fade-out" }), /* @__PURE__ */ jsx(SidebarDrawerContent, {
|
|
63
|
+
className: cn("fixed text-[0.9375rem] flex flex-col shadow-lg border-s end-0 inset-y-0 w-[85%] max-w-[380px] z-40 bg-fd-background data-[state=open]:animate-fd-sidebar-in data-[state=closed]:animate-fd-sidebar-out", className),
|
|
64
|
+
...props,
|
|
65
|
+
children
|
|
66
|
+
})] });
|
|
67
|
+
}
|
|
68
|
+
function SidebarFolder(props) {
|
|
69
|
+
return /* @__PURE__ */ jsx(SidebarFolder$1, { ...props });
|
|
70
|
+
}
|
|
71
|
+
function SidebarSeparator({ className, style, children, ...props }) {
|
|
72
|
+
const depth = useFolderDepth();
|
|
73
|
+
return /* @__PURE__ */ jsx(SidebarSeparator$1, {
|
|
74
|
+
className: cn("inline-flex items-center gap-2 mb-1.5 px-2 mt-6 empty:mb-0 [&_svg]:size-4 [&_svg]:shrink-0", depth === 0 && "first:mt-0", className),
|
|
75
|
+
style: {
|
|
76
|
+
paddingInlineStart: getItemOffset(depth),
|
|
77
|
+
...style
|
|
78
|
+
},
|
|
79
|
+
...props,
|
|
80
|
+
children
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function SidebarItem({ className, style, children, ...props }) {
|
|
84
|
+
const depth = useFolderDepth();
|
|
85
|
+
return /* @__PURE__ */ jsx(SidebarItem$1, {
|
|
86
|
+
className: cn(itemVariants({
|
|
87
|
+
variant: "link",
|
|
88
|
+
highlight: depth >= 1
|
|
89
|
+
}), className),
|
|
90
|
+
style: {
|
|
91
|
+
paddingInlineStart: getItemOffset(depth),
|
|
92
|
+
...style
|
|
93
|
+
},
|
|
94
|
+
...props,
|
|
95
|
+
children
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function SidebarFolderTrigger({ className, style, ...props }) {
|
|
99
|
+
const { depth, collapsible } = useFolder();
|
|
100
|
+
return /* @__PURE__ */ jsx(SidebarFolderTrigger$1, {
|
|
101
|
+
className: (state) => cn(itemVariants({ variant: collapsible ? "button" : null }), "w-full", typeof className === "function" ? className(state) : className),
|
|
102
|
+
style: {
|
|
103
|
+
paddingInlineStart: getItemOffset(depth - 1),
|
|
104
|
+
...style
|
|
105
|
+
},
|
|
106
|
+
...props,
|
|
107
|
+
children: props.children
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function SidebarFolderLink({ className, style, ...props }) {
|
|
111
|
+
const depth = useFolderDepth();
|
|
112
|
+
return /* @__PURE__ */ jsx(SidebarFolderLink$1, {
|
|
113
|
+
className: cn(itemVariants({
|
|
114
|
+
variant: "link",
|
|
115
|
+
highlight: depth > 1
|
|
116
|
+
}), "w-full", className),
|
|
117
|
+
style: {
|
|
118
|
+
paddingInlineStart: getItemOffset(depth - 1),
|
|
119
|
+
...style
|
|
120
|
+
},
|
|
121
|
+
...props,
|
|
122
|
+
children: props.children
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function SidebarFolderContent({ className, children, ...props }) {
|
|
126
|
+
const depth = useFolderDepth();
|
|
127
|
+
return /* @__PURE__ */ jsx(SidebarFolderContent$1, {
|
|
128
|
+
className: (state) => cn("relative flex flex-col gap-0.5 pt-0.5", depth === 1 && "before:content-[''] before:absolute before:w-px before:inset-y-1 before:bg-fd-border before:start-2.5", typeof className === "function" ? className(state) : className),
|
|
129
|
+
...props,
|
|
130
|
+
children
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const SidebarPageTree = createPageTreeRenderer({
|
|
134
|
+
SidebarFolder,
|
|
135
|
+
SidebarFolderContent,
|
|
136
|
+
SidebarFolderLink,
|
|
137
|
+
SidebarFolderTrigger,
|
|
138
|
+
SidebarItem,
|
|
139
|
+
SidebarSeparator
|
|
140
|
+
});
|
|
141
|
+
const SidebarLinkItem = createLinkItemRenderer({
|
|
142
|
+
SidebarFolder,
|
|
143
|
+
SidebarFolderContent,
|
|
144
|
+
SidebarFolderLink,
|
|
145
|
+
SidebarFolderTrigger,
|
|
146
|
+
SidebarItem
|
|
147
|
+
});
|
|
148
|
+
function Sidebar({ banner, footer, components, collapsible = true, ...rest }) {
|
|
149
|
+
const { menuItems, slots, props: { nav, tabs, tabMode } } = useNotebookLayout();
|
|
150
|
+
const navMode = nav?.mode ?? "auto";
|
|
151
|
+
const iconLinks = menuItems.filter((item) => item.type === "icon");
|
|
152
|
+
function renderHeader(props) {
|
|
153
|
+
if (typeof banner === "function") return createElement(banner, props);
|
|
154
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
155
|
+
...props,
|
|
156
|
+
className: cn("flex flex-col gap-3 p-4 pb-2 empty:hidden", props.className),
|
|
157
|
+
children: [props.children, banner]
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function renderFooter(props) {
|
|
161
|
+
if (typeof footer === "function") return createElement(footer, props);
|
|
162
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
163
|
+
...props,
|
|
164
|
+
className: cn("hidden flex-row text-fd-muted-foreground items-center border-t p-4 pt-2", iconLinks.length > 0 && "max-lg:flex", props.className),
|
|
165
|
+
children: [props.children, footer]
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
const viewport = /* @__PURE__ */ jsx(SidebarViewport, { children: /* @__PURE__ */ jsxs("div", {
|
|
169
|
+
className: "flex flex-col gap-0.5",
|
|
170
|
+
children: [menuItems.filter((item) => item.type !== "icon").map((item, i, arr) => /* @__PURE__ */ jsx(SidebarLinkItem, {
|
|
171
|
+
item,
|
|
172
|
+
className: cn("lg:hidden", i === arr.length - 1 && "mb-4")
|
|
173
|
+
}, i)), /* @__PURE__ */ jsx(SidebarPageTree, { ...components })]
|
|
174
|
+
}) });
|
|
175
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(SidebarContent, {
|
|
176
|
+
...rest,
|
|
177
|
+
children: [
|
|
178
|
+
renderHeader({ children: /* @__PURE__ */ jsxs(Fragment$1, { children: [navMode === "auto" && /* @__PURE__ */ jsxs("div", {
|
|
179
|
+
className: "flex justify-between",
|
|
180
|
+
children: [
|
|
181
|
+
slots.navTitle && /* @__PURE__ */ jsx(slots.navTitle, { className: "inline-flex items-center gap-2.5 font-medium" }),
|
|
182
|
+
nav?.children,
|
|
183
|
+
collapsible && /* @__PURE__ */ jsx(SidebarCollapseTrigger, {
|
|
184
|
+
className: cn(buttonVariants({
|
|
185
|
+
color: "ghost",
|
|
186
|
+
size: "icon-sm",
|
|
187
|
+
className: "mt-px mb-auto text-fd-muted-foreground"
|
|
188
|
+
})),
|
|
189
|
+
children: /* @__PURE__ */ jsx(SidebarIcon, {})
|
|
190
|
+
})
|
|
191
|
+
]
|
|
192
|
+
}), tabs.length > 0 && /* @__PURE__ */ jsx(SidebarTabsDropdown, {
|
|
193
|
+
options: tabs,
|
|
194
|
+
className: cn(tabMode === "navbar" && "lg:hidden")
|
|
195
|
+
})] }) }),
|
|
196
|
+
viewport,
|
|
197
|
+
renderFooter({ children: iconLinks.map((item, i) => /* @__PURE__ */ jsx(LinkItem, {
|
|
198
|
+
item,
|
|
199
|
+
className: cn(buttonVariants({
|
|
200
|
+
size: "icon-sm",
|
|
201
|
+
color: "ghost",
|
|
202
|
+
className: "lg:hidden"
|
|
203
|
+
})),
|
|
204
|
+
"aria-label": item.label,
|
|
205
|
+
children: item.icon
|
|
206
|
+
}, i)) })
|
|
207
|
+
]
|
|
208
|
+
}), /* @__PURE__ */ jsxs(SidebarDrawer, {
|
|
209
|
+
...rest,
|
|
210
|
+
children: [
|
|
211
|
+
renderHeader({ children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SidebarTrigger, {
|
|
212
|
+
className: cn(buttonVariants({
|
|
213
|
+
size: "icon-sm",
|
|
214
|
+
color: "ghost",
|
|
215
|
+
className: "ms-auto text-fd-muted-foreground"
|
|
216
|
+
})),
|
|
217
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
218
|
+
}), tabs.length > 0 && /* @__PURE__ */ jsx(SidebarTabsDropdown, { options: tabs })] }) }),
|
|
219
|
+
viewport,
|
|
220
|
+
renderFooter({
|
|
221
|
+
className: cn("hidden flex-row items-center justify-end", (slots.languageSelect || slots.themeSwitch) && "flex", iconLinks.length > 0 && "max-lg:flex"),
|
|
222
|
+
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
223
|
+
iconLinks.map((item, i) => /* @__PURE__ */ jsx(LinkItem, {
|
|
224
|
+
item,
|
|
225
|
+
className: cn(buttonVariants({
|
|
226
|
+
size: "icon-sm",
|
|
227
|
+
color: "ghost"
|
|
228
|
+
}), "text-fd-muted-foreground lg:hidden", i === iconLinks.length - 1 && "me-auto"),
|
|
229
|
+
"aria-label": item.label,
|
|
230
|
+
children: item.icon
|
|
231
|
+
}, i)),
|
|
232
|
+
slots.languageSelect && /* @__PURE__ */ jsx(slots.languageSelect.root, { children: /* @__PURE__ */ jsx(Languages, { className: "size-4.5 text-fd-muted-foreground" }) }),
|
|
233
|
+
slots.themeSwitch && /* @__PURE__ */ jsx(slots.themeSwitch, {})
|
|
234
|
+
] })
|
|
235
|
+
})
|
|
236
|
+
]
|
|
237
|
+
})] });
|
|
238
|
+
}
|
|
239
|
+
function SidebarTabsDropdown({ options, placeholder, ...props }) {
|
|
240
|
+
const [open, setOpen] = useState(false);
|
|
241
|
+
const { closeOnRedirect } = useSidebar();
|
|
242
|
+
const pathname = usePathname();
|
|
243
|
+
const selected = useMemo(() => {
|
|
244
|
+
return options.findLast((item) => isLayoutTabActive(item, pathname));
|
|
245
|
+
}, [options, pathname]);
|
|
246
|
+
const onClick = () => {
|
|
247
|
+
closeOnRedirect.current = false;
|
|
248
|
+
setOpen(false);
|
|
249
|
+
};
|
|
250
|
+
const item = selected ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
251
|
+
className: "size-9 shrink-0 empty:hidden md:size-5",
|
|
252
|
+
children: selected.icon
|
|
253
|
+
}), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
254
|
+
className: "text-sm font-medium",
|
|
255
|
+
children: selected.title
|
|
256
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
257
|
+
className: "text-sm text-fd-muted-foreground empty:hidden md:hidden",
|
|
258
|
+
children: selected.description
|
|
259
|
+
})] })] }) : placeholder;
|
|
260
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
261
|
+
open,
|
|
262
|
+
onOpenChange: setOpen,
|
|
263
|
+
children: [item && /* @__PURE__ */ jsxs(PopoverTrigger, {
|
|
264
|
+
...props,
|
|
265
|
+
className: cn("flex items-center gap-2 rounded-lg p-2 border bg-fd-secondary/50 text-start text-fd-secondary-foreground transition-colors hover:bg-fd-accent data-[state=open]:bg-fd-accent data-[state=open]:text-fd-accent-foreground", props.className),
|
|
266
|
+
children: [item, /* @__PURE__ */ jsx(ChevronsUpDown, { className: "shrink-0 ms-auto size-4 text-fd-muted-foreground" })]
|
|
267
|
+
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
268
|
+
className: "flex flex-col gap-1 w-(--radix-popover-trigger-width) p-1 fd-scroll-container",
|
|
269
|
+
children: options.map((item) => {
|
|
270
|
+
const isActive = selected && item.url === selected.url;
|
|
271
|
+
if (!isActive && item.unlisted) return;
|
|
272
|
+
return /* @__PURE__ */ jsxs(Link, {
|
|
273
|
+
href: item.url,
|
|
274
|
+
onClick,
|
|
275
|
+
...item.props,
|
|
276
|
+
className: cn("flex items-center gap-2 rounded-lg p-1.5 hover:bg-fd-accent hover:text-fd-accent-foreground", item.props?.className),
|
|
277
|
+
children: [
|
|
278
|
+
/* @__PURE__ */ jsx("div", {
|
|
279
|
+
className: "shrink-0 size-9 md:mb-auto md:size-5 empty:hidden",
|
|
280
|
+
children: item.icon
|
|
281
|
+
}),
|
|
282
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
283
|
+
className: "text-sm font-medium leading-none",
|
|
284
|
+
children: item.title
|
|
285
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
286
|
+
className: "text-[0.8125rem] text-fd-muted-foreground mt-1 empty:hidden",
|
|
287
|
+
children: item.description
|
|
288
|
+
})] }),
|
|
289
|
+
/* @__PURE__ */ jsx(Check, { className: cn("shrink-0 ms-auto size-3.5 text-fd-primary", !isActive && "invisible") })
|
|
290
|
+
]
|
|
291
|
+
}, item.url);
|
|
292
|
+
})
|
|
293
|
+
})]
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
//#endregion
|
|
297
|
+
export { Sidebar, SidebarCollapseTrigger, SidebarProvider, SidebarTabsDropdown, SidebarTrigger, useSidebar };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { LanguageSelectProps, LanguageSelectTextProps } from "./slots/language-select.js";
|
|
2
|
+
import { FullSearchTriggerProps, SearchTriggerProps } from "./slots/search-trigger.js";
|
|
3
|
+
import { ThemeSwitchProps } from "./slots/theme-switch.js";
|
|
4
|
+
import { BaseLayoutProps, LinkItemType } from "./index.js";
|
|
5
|
+
import { ComponentProps, FC } from "react";
|
|
6
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
//#region src/layouts/shared/client.d.ts
|
|
9
|
+
declare function LinkItem({
|
|
10
|
+
ref,
|
|
11
|
+
item,
|
|
12
|
+
...props
|
|
13
|
+
}: Omit<ComponentProps<'a'>, 'href'> & {
|
|
14
|
+
item: Extract<LinkItemType, {
|
|
15
|
+
url: string;
|
|
16
|
+
}>;
|
|
17
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
18
|
+
interface BaseSlots {
|
|
19
|
+
navTitle: FC<ComponentProps<'a'>>;
|
|
20
|
+
themeSwitch: FC<ThemeSwitchProps> | false;
|
|
21
|
+
searchTrigger: {
|
|
22
|
+
sm: FC<SearchTriggerProps>;
|
|
23
|
+
full: FC<FullSearchTriggerProps>;
|
|
24
|
+
} | false;
|
|
25
|
+
languageSelect: {
|
|
26
|
+
root: FC<LanguageSelectProps>;
|
|
27
|
+
text: FC<LanguageSelectTextProps>;
|
|
28
|
+
} | false;
|
|
29
|
+
}
|
|
30
|
+
interface BaseSlotsProps<P extends BaseLayoutProps = BaseLayoutProps> extends Pick<P, 'nav'> {
|
|
31
|
+
themeSwitch: Omit<NonNullable<P['themeSwitch']>, 'enabled'>;
|
|
32
|
+
searchToggle: Omit<NonNullable<P['searchToggle']>, 'enabled'>;
|
|
33
|
+
}
|
|
34
|
+
declare function baseSlots({
|
|
35
|
+
useProps
|
|
36
|
+
}: {
|
|
37
|
+
useProps: () => BaseSlotsProps;
|
|
38
|
+
}): {
|
|
39
|
+
useProvider(options: BaseLayoutProps): {
|
|
40
|
+
baseSlots: BaseSlots;
|
|
41
|
+
baseProps: BaseSlotsProps;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { BaseSlots, BaseSlotsProps, LinkItem, baseSlots };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useI18n } from "../../contexts/i18n.js";
|
|
3
|
+
import { LanguageSelect, LanguageSelectText } from "./slots/language-select.js";
|
|
4
|
+
import { FullSearchTrigger, SearchTrigger } from "./slots/search-trigger.js";
|
|
5
|
+
import { ThemeSwitch } from "./slots/theme-switch.js";
|
|
6
|
+
import { isLinkItemActive } from "./index.js";
|
|
7
|
+
import { usePathname } from "@hanzo/docs-core/framework";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
import Link from "@hanzo/docs-core/link";
|
|
10
|
+
//#region src/layouts/shared/client.tsx
|
|
11
|
+
function LinkItem({ ref, item, ...props }) {
|
|
12
|
+
const active = isLinkItemActive(item, usePathname());
|
|
13
|
+
return /* @__PURE__ */ jsx(Link, {
|
|
14
|
+
ref,
|
|
15
|
+
href: item.url,
|
|
16
|
+
external: item.external,
|
|
17
|
+
...props,
|
|
18
|
+
"data-active": active,
|
|
19
|
+
children: props.children
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function baseSlots({ useProps }) {
|
|
23
|
+
function InlineThemeSwitch(props) {
|
|
24
|
+
const { themeSwitch } = useProps();
|
|
25
|
+
if (themeSwitch.component) return themeSwitch.component;
|
|
26
|
+
return /* @__PURE__ */ jsx(ThemeSwitch, {
|
|
27
|
+
...props,
|
|
28
|
+
...themeSwitch
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function InlineSearchTrigger(props) {
|
|
32
|
+
const { searchToggle } = useProps();
|
|
33
|
+
if (searchToggle.components?.sm) return searchToggle.components.sm;
|
|
34
|
+
return /* @__PURE__ */ jsx(SearchTrigger, {
|
|
35
|
+
...props,
|
|
36
|
+
...searchToggle.sm
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function InlineSearchTriggerFull(props) {
|
|
40
|
+
const { searchToggle } = useProps();
|
|
41
|
+
if (searchToggle.components?.lg) return searchToggle.components.lg;
|
|
42
|
+
return /* @__PURE__ */ jsx(FullSearchTrigger, {
|
|
43
|
+
...props,
|
|
44
|
+
...searchToggle.full
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function InlineNavTitle({ href: defaultUrl = "/", ...props }) {
|
|
48
|
+
const { url = defaultUrl, title } = useProps().nav ?? {};
|
|
49
|
+
if (typeof title === "function") return title({
|
|
50
|
+
href: url,
|
|
51
|
+
...props
|
|
52
|
+
});
|
|
53
|
+
return /* @__PURE__ */ jsx(Link, {
|
|
54
|
+
href: url,
|
|
55
|
+
...props,
|
|
56
|
+
children: title
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return { useProvider(options) {
|
|
60
|
+
const { locales = [] } = useI18n();
|
|
61
|
+
const { nav, slots = {}, i18n = locales.length > 1, searchToggle: { enabled: searchToggleEnabled = true, ...searchToggle } = {}, themeSwitch: { enabled: themeSwitchEnabled = true, ...themeSwitch } = {} } = options;
|
|
62
|
+
return {
|
|
63
|
+
baseSlots: {
|
|
64
|
+
navTitle: slots.navTitle ?? InlineNavTitle,
|
|
65
|
+
themeSwitch: themeSwitchEnabled && (slots.themeSwitch ?? InlineThemeSwitch),
|
|
66
|
+
languageSelect: i18n ? slots.languageSelect ?? {
|
|
67
|
+
root: LanguageSelect,
|
|
68
|
+
text: LanguageSelectText
|
|
69
|
+
} : false,
|
|
70
|
+
searchTrigger: searchToggleEnabled && (slots.searchTrigger ?? {
|
|
71
|
+
sm: InlineSearchTrigger,
|
|
72
|
+
full: InlineSearchTriggerFull
|
|
73
|
+
})
|
|
74
|
+
},
|
|
75
|
+
baseProps: {
|
|
76
|
+
nav,
|
|
77
|
+
searchToggle,
|
|
78
|
+
themeSwitch
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
} };
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { LinkItem, baseSlots };
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
import { FullSearchTriggerProps, SearchTriggerProps } from "./slots/search-trigger.js";
|
|
2
|
+
import { ThemeSwitchProps } from "./slots/theme-switch.js";
|
|
3
|
+
import { BaseSlots, BaseSlotsProps, LinkItem, baseSlots } from "./client.js";
|
|
4
|
+
import { ComponentProps, FC, ReactNode } from "react";
|
|
5
|
+
import * as PageTree from "@hanzo/docs-core/page-tree";
|
|
5
6
|
import { I18nConfig } from "@hanzo/docs-core/i18n";
|
|
6
7
|
|
|
7
8
|
//#region src/layouts/shared/index.d.ts
|
|
8
9
|
interface NavOptions {
|
|
9
|
-
enabled
|
|
10
|
-
|
|
11
|
-
title?: ReactNode |
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
title?: ReactNode | FC<ComponentProps<'a'>>;
|
|
12
13
|
/**
|
|
13
14
|
* Redirect url of title
|
|
14
15
|
* @defaultValue '/'
|
|
@@ -20,38 +21,143 @@ interface NavOptions {
|
|
|
20
21
|
* @defaultValue none
|
|
21
22
|
*/
|
|
22
23
|
transparentMode?: 'always' | 'top' | 'none';
|
|
23
|
-
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated use `slots.header` instead.
|
|
26
|
+
*/
|
|
27
|
+
component?: ReactNode;
|
|
24
28
|
}
|
|
25
29
|
interface BaseLayoutProps {
|
|
26
|
-
themeSwitch?: {
|
|
27
|
-
enabled?: boolean;
|
|
28
|
-
component?: ReactNode;
|
|
29
|
-
mode?: 'light-dark' | 'light-dark-system';
|
|
30
|
-
};
|
|
31
|
-
searchToggle?: Partial<{
|
|
32
|
-
enabled: boolean;
|
|
33
|
-
components: Partial<{
|
|
34
|
-
sm: ReactNode;
|
|
35
|
-
lg: ReactNode;
|
|
36
|
-
}>;
|
|
37
|
-
}>;
|
|
38
|
-
/**
|
|
39
|
-
* I18n options
|
|
40
|
-
*
|
|
41
|
-
* @defaultValue false
|
|
42
|
-
*/
|
|
43
|
-
i18n?: boolean | I18nConfig;
|
|
44
30
|
/**
|
|
45
31
|
* GitHub url
|
|
46
32
|
*/
|
|
47
33
|
githubUrl?: string;
|
|
48
34
|
links?: LinkItemType[];
|
|
49
35
|
/**
|
|
50
|
-
*
|
|
36
|
+
* navigation config
|
|
51
37
|
*/
|
|
52
|
-
nav?:
|
|
38
|
+
nav?: NavOptions;
|
|
39
|
+
slots?: Partial<BaseSlots>;
|
|
53
40
|
children?: ReactNode;
|
|
41
|
+
themeSwitch?: ThemeSwitchOptions;
|
|
42
|
+
searchToggle?: SearchToggleOptions;
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated this is now optional for i18n setups, you can still customise language switch from `slots`.
|
|
45
|
+
*/
|
|
46
|
+
i18n?: boolean | I18nConfig;
|
|
47
|
+
}
|
|
48
|
+
interface SearchToggleOptions {
|
|
49
|
+
enabled?: boolean;
|
|
50
|
+
sm?: SearchTriggerProps;
|
|
51
|
+
full?: FullSearchTriggerProps;
|
|
52
|
+
/** @deprecated use `slots.searchTrigger` instead */
|
|
53
|
+
components?: {
|
|
54
|
+
sm?: ReactNode;
|
|
55
|
+
lg?: ReactNode;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
interface ThemeSwitchOptions extends ThemeSwitchProps {
|
|
59
|
+
enabled?: boolean;
|
|
60
|
+
/** @deprecated use `slots.themeSwitch` instead */
|
|
61
|
+
component?: ReactNode;
|
|
62
|
+
}
|
|
63
|
+
interface LayoutTab {
|
|
64
|
+
/**
|
|
65
|
+
* Redirect URL of the folder, usually the index page
|
|
66
|
+
*/
|
|
67
|
+
url: string;
|
|
68
|
+
icon?: ReactNode;
|
|
69
|
+
title: ReactNode;
|
|
70
|
+
description?: ReactNode;
|
|
71
|
+
unlisted?: boolean;
|
|
72
|
+
props?: ComponentProps<'a'>;
|
|
73
|
+
/**
|
|
74
|
+
* bind to a page tree node.
|
|
75
|
+
*/
|
|
76
|
+
$folder?: PageTree.Folder;
|
|
77
|
+
/**
|
|
78
|
+
* Detect from a list of urls (when not bound to page tree).
|
|
79
|
+
*/
|
|
80
|
+
urls?: Set<string>;
|
|
81
|
+
}
|
|
82
|
+
interface GetLayoutTabsOptions {
|
|
83
|
+
transform?: (option: LayoutTab, node: PageTree.Folder) => LayoutTab | null;
|
|
84
|
+
}
|
|
85
|
+
declare function getLayoutTabs(tree: PageTree.Root, {
|
|
86
|
+
transform
|
|
87
|
+
}?: GetLayoutTabsOptions): LayoutTab[];
|
|
88
|
+
declare function isLayoutTabActive(tab: LayoutTab, pathname: string): boolean;
|
|
89
|
+
interface Filterable {
|
|
90
|
+
/**
|
|
91
|
+
* Restrict where the item is displayed
|
|
92
|
+
*
|
|
93
|
+
* @defaultValue 'all'
|
|
94
|
+
*/
|
|
95
|
+
on?: 'menu' | 'nav' | 'all';
|
|
96
|
+
}
|
|
97
|
+
interface WithHref {
|
|
98
|
+
url: string;
|
|
99
|
+
/**
|
|
100
|
+
* When the item is marked as active
|
|
101
|
+
*
|
|
102
|
+
* @defaultValue 'url'
|
|
103
|
+
*/
|
|
104
|
+
active?: 'url' | 'nested-url' | 'none';
|
|
105
|
+
external?: boolean;
|
|
106
|
+
}
|
|
107
|
+
interface MainItemType extends WithHref, Filterable {
|
|
108
|
+
type?: 'main';
|
|
109
|
+
icon?: ReactNode;
|
|
110
|
+
text: ReactNode;
|
|
111
|
+
description?: ReactNode;
|
|
112
|
+
}
|
|
113
|
+
interface IconItemType extends WithHref, Filterable {
|
|
114
|
+
type: 'icon';
|
|
115
|
+
/**
|
|
116
|
+
* `aria-label` of icon button
|
|
117
|
+
*/
|
|
118
|
+
label?: string;
|
|
119
|
+
icon: ReactNode;
|
|
120
|
+
text: ReactNode;
|
|
121
|
+
/**
|
|
122
|
+
* @defaultValue true
|
|
123
|
+
*/
|
|
124
|
+
secondary?: boolean;
|
|
125
|
+
}
|
|
126
|
+
interface ButtonItemType extends WithHref, Filterable {
|
|
127
|
+
type: 'button';
|
|
128
|
+
icon?: ReactNode;
|
|
129
|
+
text: ReactNode;
|
|
130
|
+
/**
|
|
131
|
+
* @defaultValue false
|
|
132
|
+
*/
|
|
133
|
+
secondary?: boolean;
|
|
134
|
+
}
|
|
135
|
+
interface MenuItemType extends Partial<WithHref>, Filterable {
|
|
136
|
+
type: 'menu';
|
|
137
|
+
icon?: ReactNode;
|
|
138
|
+
text: ReactNode;
|
|
139
|
+
items: ((MainItemType & {
|
|
140
|
+
/**
|
|
141
|
+
* Options when displayed on navigation menu
|
|
142
|
+
*/
|
|
143
|
+
menu?: ComponentProps<'a'> & {
|
|
144
|
+
banner?: ReactNode;
|
|
145
|
+
};
|
|
146
|
+
}) | CustomItemType)[];
|
|
147
|
+
/**
|
|
148
|
+
* @defaultValue false
|
|
149
|
+
*/
|
|
150
|
+
secondary?: boolean;
|
|
151
|
+
}
|
|
152
|
+
interface CustomItemType extends Filterable {
|
|
153
|
+
type: 'custom';
|
|
154
|
+
/**
|
|
155
|
+
* @defaultValue false
|
|
156
|
+
*/
|
|
157
|
+
secondary?: boolean;
|
|
158
|
+
children: ReactNode;
|
|
54
159
|
}
|
|
160
|
+
type LinkItemType = MainItemType | IconItemType | ButtonItemType | MenuItemType | CustomItemType;
|
|
55
161
|
/**
|
|
56
162
|
* Get link items with shortcuts
|
|
57
163
|
*/
|
|
@@ -59,10 +165,6 @@ declare function resolveLinkItems({
|
|
|
59
165
|
links,
|
|
60
166
|
githubUrl
|
|
61
167
|
}: Pick<BaseLayoutProps, 'links' | 'githubUrl'>): LinkItemType[];
|
|
62
|
-
declare function renderTitleNav({
|
|
63
|
-
title,
|
|
64
|
-
url
|
|
65
|
-
}: Partial<NavOptions>, props: ComponentProps<'a'>): string | number | bigint | boolean | react_jsx_runtime0.JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
|
|
66
168
|
declare function useLinkItems({
|
|
67
169
|
githubUrl,
|
|
68
170
|
links
|
|
@@ -71,6 +173,6 @@ declare function useLinkItems({
|
|
|
71
173
|
menuItems: LinkItemType[];
|
|
72
174
|
all: LinkItemType[];
|
|
73
175
|
};
|
|
176
|
+
declare function isLinkItemActive(link: LinkItemType, pathname: string): boolean;
|
|
74
177
|
//#endregion
|
|
75
|
-
export { BaseLayoutProps, ButtonItemType, CustomItemType, IconItemType, LinkItem, LinkItemType, MainItemType, MenuItemType, NavOptions,
|
|
76
|
-
//# sourceMappingURL=index.d.ts.map
|
|
178
|
+
export { BaseLayoutProps, type BaseSlots, type BaseSlotsProps, ButtonItemType, CustomItemType, GetLayoutTabsOptions, IconItemType, LayoutTab, LinkItem, LinkItemType, MainItemType, MenuItemType, NavOptions, baseSlots, getLayoutTabs, isLayoutTabActive, isLinkItemActive, resolveLinkItems, useLinkItems };
|