@vx-oss/docs-react 1.0.3
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/LICENSE +21 -0
- package/README.md +5 -0
- package/css/aspen.css +39 -0
- package/css/black.css +39 -0
- package/css/catppuccin.css +49 -0
- package/css/dusk.css +47 -0
- package/css/emerald.css +39 -0
- package/css/generated/docs.css +1 -0
- package/css/generated/flux.css +1 -0
- package/css/generated/glass.css +1 -0
- package/css/generated/home.css +1 -0
- package/css/generated/notebook.css +1 -0
- package/css/generated/shared.css +1 -0
- package/css/lib/base.css +296 -0
- package/css/lib/default-colors.css +51 -0
- package/css/lib/shiki.css +108 -0
- package/css/neutral.css +7 -0
- package/css/ocean.css +44 -0
- package/css/preset-legacy.css +43 -0
- package/css/preset.css +11 -0
- package/css/purple.css +39 -0
- package/css/ruby.css +39 -0
- package/css/shadcn.css +36 -0
- package/css/solar.css +65 -0
- package/css/style.css +9 -0
- package/css/vitepress.css +72 -0
- package/dist/.translations/index.d.ts +55 -0
- package/dist/.translations/keys.js +55 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/components/accordion.d.ts +10 -0
- package/dist/components/accordion.js +68 -0
- package/dist/components/banner.d.ts +25 -0
- package/dist/components/banner.js +85 -0
- package/dist/components/callout.d.ts +21 -0
- package/dist/components/callout.js +60 -0
- package/dist/components/card.d.ts +13 -0
- package/dist/components/card.js +39 -0
- package/dist/components/codeblock.d.ts +45 -0
- package/dist/components/codeblock.js +126 -0
- package/dist/components/codeblock.rsc.d.ts +15 -0
- package/dist/components/codeblock.rsc.js +22 -0
- package/dist/components/dialog/search-algolia.d.ts +27 -0
- package/dist/components/dialog/search-algolia.js +64 -0
- package/dist/components/dialog/search-default.d.ts +29 -0
- package/dist/components/dialog/search-default.js +66 -0
- package/dist/components/dialog/search-orama.d.ts +32 -0
- package/dist/components/dialog/search-orama.js +69 -0
- package/dist/components/dialog/search.d.ts +76 -0
- package/dist/components/dialog/search.js +351 -0
- package/dist/components/dynamic-codeblock.core.d.ts +26 -0
- package/dist/components/dynamic-codeblock.core.js +51 -0
- package/dist/components/dynamic-codeblock.d.ts +8 -0
- package/dist/components/dynamic-codeblock.js +17 -0
- package/dist/components/files.d.ts +21 -0
- package/dist/components/files.js +40 -0
- package/dist/components/github-info.d.ts +20 -0
- package/dist/components/github-info.js +75 -0
- package/dist/components/heading.d.ts +9 -0
- package/dist/components/heading.js +38 -0
- package/dist/components/image-zoom.d.ts +18 -0
- package/dist/components/image-zoom.js +32 -0
- package/dist/components/image-zoom2.css +71 -0
- package/dist/components/inline-toc.d.ts +10 -0
- package/dist/components/inline-toc.js +28 -0
- package/dist/components/sidebar/base.d.ts +85 -0
- package/dist/components/sidebar/base.js +277 -0
- package/dist/components/sidebar/link-item.d.ts +12 -0
- package/dist/components/sidebar/link-item.js +37 -0
- package/dist/components/sidebar/page-tree.d.ts +20 -0
- package/dist/components/sidebar/page-tree.js +69 -0
- package/dist/components/sidebar/tabs/dropdown.d.ts +15 -0
- package/dist/components/sidebar/tabs/dropdown.js +83 -0
- package/dist/components/sidebar/tabs/index.d.ts +8 -0
- package/dist/components/sidebar/tabs/index.js +46 -0
- package/dist/components/steps.d.ts +10 -0
- package/dist/components/steps.js +16 -0
- package/dist/components/tabs.d.ts +33 -0
- package/dist/components/tabs.js +95 -0
- package/dist/components/toc/clerk.d.ts +11 -0
- package/dist/components/toc/clerk.js +227 -0
- package/dist/components/toc/default.d.ts +13 -0
- package/dist/components/toc/default.js +260 -0
- package/dist/components/toc/index.d.ts +10 -0
- package/dist/components/toc/index.js +45 -0
- package/dist/components/type-table.d.ts +37 -0
- package/dist/components/type-table.js +117 -0
- package/dist/components/ui/accordion.d.ts +10 -0
- package/dist/components/ui/accordion.js +42 -0
- package/dist/components/ui/button.d.ts +10 -0
- package/dist/components/ui/button.js +20 -0
- package/dist/components/ui/collapsible.d.ts +11 -0
- package/dist/components/ui/collapsible.js +21 -0
- package/dist/components/ui/navigation-menu.d.ts +14 -0
- package/dist/components/ui/navigation-menu.js +41 -0
- package/dist/components/ui/popover.d.ts +9 -0
- package/dist/components/ui/popover.js +20 -0
- package/dist/components/ui/scroll-area.d.ts +9 -0
- package/dist/components/ui/scroll-area.js +34 -0
- package/dist/components/ui/tabs.d.ts +23 -0
- package/dist/components/ui/tabs.js +102 -0
- package/dist/contexts/i18n.d.ts +34 -0
- package/dist/contexts/i18n.js +37 -0
- package/dist/contexts/search.d.ts +64 -0
- package/dist/contexts/search.js +68 -0
- package/dist/contexts/tree.d.ts +29 -0
- package/dist/contexts/tree.js +91 -0
- package/dist/i18n.d.ts +15 -0
- package/dist/i18n.js +38 -0
- package/dist/layouts/docs/client.d.ts +33 -0
- package/dist/layouts/docs/client.js +94 -0
- package/dist/layouts/docs/index.d.ts +32 -0
- package/dist/layouts/docs/index.js +23 -0
- package/dist/layouts/docs/page/index.d.ts +76 -0
- package/dist/layouts/docs/page/index.js +124 -0
- package/dist/layouts/docs/page/slots/breadcrumb.d.ts +7 -0
- package/dist/layouts/docs/page/slots/breadcrumb.js +44 -0
- package/dist/layouts/docs/page/slots/container.d.ts +5 -0
- package/dist/layouts/docs/page/slots/container.js +22 -0
- package/dist/layouts/docs/page/slots/footer.d.ts +16 -0
- package/dist/layouts/docs/page/slots/footer.js +56 -0
- package/dist/layouts/docs/page/slots/toc.d.ts +47 -0
- package/dist/layouts/docs/page/slots/toc.js +182 -0
- package/dist/layouts/docs/slots/container.d.ts +5 -0
- package/dist/layouts/docs/slots/container.js +36 -0
- package/dist/layouts/docs/slots/header.d.ts +5 -0
- package/dist/layouts/docs/slots/header.js +38 -0
- package/dist/layouts/docs/slots/sidebar.d.ts +22 -0
- package/dist/layouts/docs/slots/sidebar.js +268 -0
- package/dist/layouts/flux/index.d.ts +61 -0
- package/dist/layouts/flux/index.js +146 -0
- package/dist/layouts/flux/page/index.d.ts +67 -0
- package/dist/layouts/flux/page/index.js +104 -0
- package/dist/layouts/flux/page/slots/breadcrumb.d.ts +7 -0
- package/dist/layouts/flux/page/slots/breadcrumb.js +44 -0
- package/dist/layouts/flux/page/slots/container.d.ts +5 -0
- package/dist/layouts/flux/page/slots/container.js +22 -0
- package/dist/layouts/flux/page/slots/footer.d.ts +16 -0
- package/dist/layouts/flux/page/slots/footer.js +56 -0
- package/dist/layouts/flux/page/slots/toc.d.ts +29 -0
- package/dist/layouts/flux/page/slots/toc.js +181 -0
- package/dist/layouts/flux/slots/container.d.ts +5 -0
- package/dist/layouts/flux/slots/container.js +13 -0
- package/dist/layouts/flux/slots/sidebar.d.ts +16 -0
- package/dist/layouts/flux/slots/sidebar.js +243 -0
- package/dist/layouts/flux/slots/tab-dropdown.d.ts +10 -0
- package/dist/layouts/flux/slots/tab-dropdown.js +88 -0
- package/dist/layouts/glass/index.d.ts +39 -0
- package/dist/layouts/glass/index.js +70 -0
- package/dist/layouts/glass/layout-tabs.js +54 -0
- package/dist/layouts/glass/page/index.d.ts +31 -0
- package/dist/layouts/glass/page/index.js +92 -0
- package/dist/layouts/glass/page/slots/breadcrumb.d.ts +7 -0
- package/dist/layouts/glass/page/slots/breadcrumb.js +44 -0
- package/dist/layouts/glass/page/slots/footer.d.ts +16 -0
- package/dist/layouts/glass/page/slots/footer.js +56 -0
- package/dist/layouts/glass/page/slots/toc.d.ts +19 -0
- package/dist/layouts/glass/page/slots/toc.js +108 -0
- package/dist/layouts/glass/slots/header.d.ts +6 -0
- package/dist/layouts/glass/slots/header.js +68 -0
- package/dist/layouts/glass/slots/sidebar.d.ts +21 -0
- package/dist/layouts/glass/slots/sidebar.js +267 -0
- package/dist/layouts/home/index.d.ts +27 -0
- package/dist/layouts/home/index.js +40 -0
- package/dist/layouts/home/navbar.d.ts +9 -0
- package/dist/layouts/home/navbar.js +34 -0
- package/dist/layouts/home/not-found.d.ts +7 -0
- package/dist/layouts/home/not-found.js +41 -0
- package/dist/layouts/home/slots/container.d.ts +5 -0
- package/dist/layouts/home/slots/container.js +13 -0
- package/dist/layouts/home/slots/header.d.ts +8 -0
- package/dist/layouts/home/slots/header.js +239 -0
- package/dist/layouts/notebook/client.d.ts +35 -0
- package/dist/layouts/notebook/client.js +69 -0
- package/dist/layouts/notebook/index.d.ts +26 -0
- package/dist/layouts/notebook/index.js +23 -0
- package/dist/layouts/notebook/page/index.d.ts +76 -0
- package/dist/layouts/notebook/page/index.js +124 -0
- package/dist/layouts/notebook/page/slots/breadcrumb.d.ts +7 -0
- package/dist/layouts/notebook/page/slots/breadcrumb.js +44 -0
- package/dist/layouts/notebook/page/slots/container.d.ts +5 -0
- package/dist/layouts/notebook/page/slots/container.js +22 -0
- package/dist/layouts/notebook/page/slots/footer.d.ts +16 -0
- package/dist/layouts/notebook/page/slots/footer.js +56 -0
- package/dist/layouts/notebook/page/slots/toc.d.ts +47 -0
- package/dist/layouts/notebook/page/slots/toc.js +181 -0
- package/dist/layouts/notebook/slots/container.d.ts +5 -0
- package/dist/layouts/notebook/slots/container.js +38 -0
- package/dist/layouts/notebook/slots/header.d.ts +5 -0
- package/dist/layouts/notebook/slots/header.js +204 -0
- package/dist/layouts/notebook/slots/sidebar.d.ts +23 -0
- package/dist/layouts/notebook/slots/sidebar.js +240 -0
- package/dist/layouts/shared/client.d.ts +37 -0
- package/dist/layouts/shared/client.js +85 -0
- package/dist/layouts/shared/index.d.ts +169 -0
- package/dist/layouts/shared/index.js +98 -0
- package/dist/layouts/shared/page-actions.d.ts +27 -0
- package/dist/layouts/shared/page-actions.js +199 -0
- package/dist/layouts/shared/slots/language-select.d.ts +12 -0
- package/dist/layouts/shared/slots/language-select.js +43 -0
- package/dist/layouts/shared/slots/search-trigger.d.ts +13 -0
- package/dist/layouts/shared/slots/search-trigger.js +53 -0
- package/dist/layouts/shared/slots/theme-switch.d.ts +8 -0
- package/dist/layouts/shared/slots/theme-switch.js +70 -0
- package/dist/legacy/layout.d.ts +29 -0
- package/dist/legacy/layout.js +44 -0
- package/dist/legacy/sidebar.d.ts +14 -0
- package/dist/legacy/sidebar.js +34 -0
- package/dist/mdx.d.ts +44 -0
- package/dist/mdx.js +70 -0
- package/dist/mdx.server.d.ts +14 -0
- package/dist/mdx.server.js +20 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/controlled.d.ts +30 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/controlled.js +461 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/index.d.ts +3 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/uncontrolled.d.ts +6 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/uncontrolled.js +17 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/utils/adjust-svg-ids.js +53 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/utils/compute-positioned-style.js +25 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/utils/element-tests.js +12 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/utils/get-div-img-style.js +45 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/utils/get-img-alt.js +10 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/utils/get-img-object-fit-style.js +57 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/utils/get-img-regular-style.js +21 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/utils/get-img-src.js +14 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/utils/get-modal-img-transform.js +22 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/utils/get-scale.js +27 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/utils/get-style-ghost.js +31 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/utils/get-style-modal-img.js +75 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/utils/get-target-dimension.js +4 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/utils/parse-position.js +7 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-medium-image-zoom/dist/utils/test-has-scalable-src.js +5 -0
- package/dist/og/takumi.d.ts +15 -0
- package/dist/og/takumi.js +91 -0
- package/dist/og.d.ts +16 -0
- package/dist/og.js +91 -0
- package/dist/page.d.ts +29 -0
- package/dist/page.js +33 -0
- package/dist/provider/astro.d.ts +29 -0
- package/dist/provider/astro.js +20 -0
- package/dist/provider/base.d.ts +48 -0
- package/dist/provider/base.js +73 -0
- package/dist/provider/next.d.ts +16 -0
- package/dist/provider/next.js +17 -0
- package/dist/provider/react-router.d.ts +16 -0
- package/dist/provider/react-router.js +17 -0
- package/dist/provider/tanstack.d.ts +16 -0
- package/dist/provider/tanstack.js +17 -0
- package/dist/provider/waku.d.ts +16 -0
- package/dist/provider/waku.js +17 -0
- package/dist/style.css +3640 -0
- package/dist/tailwind/typography.d.ts +2 -0
- package/dist/tailwind/typography.js +2 -0
- package/dist/utils/cn.js +2 -0
- package/dist/utils/merge-refs.js +11 -0
- package/dist/utils/urls.js +15 -0
- package/dist/utils/use-copy-button.d.ts +5 -0
- package/dist/utils/use-copy-button.js +26 -0
- package/dist/utils/use-footer-items.d.ts +8 -0
- package/dist/utils/use-footer-items.js +24 -0
- package/dist/utils/use-is-scroll-top.d.ts +6 -0
- package/dist/utils/use-is-scroll-top.js +20 -0
- package/package.json +212 -0
|
@@ -0,0 +1,240 @@
|
|
|
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 { LinkItem } from "../../shared/client.js";
|
|
6
|
+
import "../../shared/index.js";
|
|
7
|
+
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";
|
|
8
|
+
import { createPageTreeRenderer } from "../../../components/sidebar/page-tree.js";
|
|
9
|
+
import { createLinkItemRenderer } from "../../../components/sidebar/link-item.js";
|
|
10
|
+
import { SidebarTabsDropdown } from "../../../components/sidebar/tabs/dropdown.js";
|
|
11
|
+
import { useNotebookLayout } from "../client.js";
|
|
12
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Languages, SidebarIcon, X } from "lucide-react";
|
|
14
|
+
import { cva } from "class-variance-authority";
|
|
15
|
+
import { createElement, useRef } from "react";
|
|
16
|
+
//#region src/layouts/notebook/slots/sidebar.tsx
|
|
17
|
+
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: {
|
|
18
|
+
variant: {
|
|
19
|
+
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",
|
|
20
|
+
button: "transition-colors hover:bg-fd-accent/50 hover:text-fd-accent-foreground/80 hover:transition-none"
|
|
21
|
+
},
|
|
22
|
+
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:inset-s-2.5" }
|
|
23
|
+
} });
|
|
24
|
+
function getItemOffset(depth) {
|
|
25
|
+
return `calc(${2 + 3 * depth} * var(--spacing))`;
|
|
26
|
+
}
|
|
27
|
+
const { useSidebar } = base_exports;
|
|
28
|
+
function SidebarProvider(props) {
|
|
29
|
+
return /* @__PURE__ */ jsx(SidebarProvider$1, { ...props });
|
|
30
|
+
}
|
|
31
|
+
function SidebarTrigger(props) {
|
|
32
|
+
return /* @__PURE__ */ jsx(SidebarTrigger$1, { ...props });
|
|
33
|
+
}
|
|
34
|
+
function SidebarCollapseTrigger(props) {
|
|
35
|
+
return /* @__PURE__ */ jsx(SidebarCollapseTrigger$1, { ...props });
|
|
36
|
+
}
|
|
37
|
+
function SidebarContent({ ref: refProp, className, children, ...props }) {
|
|
38
|
+
const { props: { nav } } = useNotebookLayout();
|
|
39
|
+
const navMode = nav?.mode ?? "auto";
|
|
40
|
+
const ref = useRef(null);
|
|
41
|
+
return /* @__PURE__ */ jsx(SidebarContent$1, { children: ({ collapsed, hovered, ref: asideRef, ...rest }) => /* @__PURE__ */ jsxs("div", {
|
|
42
|
+
"data-sidebar-placeholder": "",
|
|
43
|
+
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))]"),
|
|
44
|
+
children: [collapsed && /* @__PURE__ */ jsx("div", {
|
|
45
|
+
className: "absolute inset-s-0 inset-y-0 w-4",
|
|
46
|
+
...rest
|
|
47
|
+
}), /* @__PURE__ */ jsx("aside", {
|
|
48
|
+
id: "nd-sidebar",
|
|
49
|
+
ref: mergeRefs(ref, refProp, asideRef),
|
|
50
|
+
"data-collapsed": collapsed,
|
|
51
|
+
"data-hovered": collapsed && hovered,
|
|
52
|
+
className: cn("absolute flex flex-col w-full inset-s-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),
|
|
53
|
+
...props,
|
|
54
|
+
...rest,
|
|
55
|
+
children
|
|
56
|
+
})]
|
|
57
|
+
}) });
|
|
58
|
+
}
|
|
59
|
+
function SidebarDrawer({ children, className, ...props }) {
|
|
60
|
+
return /* @__PURE__ */ jsxs(Fragment, { 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, {
|
|
61
|
+
className: cn("fixed text-[0.9375rem] flex flex-col shadow-lg border-s inset-e-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),
|
|
62
|
+
...props,
|
|
63
|
+
children
|
|
64
|
+
})] });
|
|
65
|
+
}
|
|
66
|
+
function SidebarFolder(props) {
|
|
67
|
+
return /* @__PURE__ */ jsx(SidebarFolder$1, { ...props });
|
|
68
|
+
}
|
|
69
|
+
function SidebarSeparator({ className, style, children, ...props }) {
|
|
70
|
+
const depth = useFolderDepth();
|
|
71
|
+
return /* @__PURE__ */ jsx(SidebarSeparator$1, {
|
|
72
|
+
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),
|
|
73
|
+
style: {
|
|
74
|
+
paddingInlineStart: getItemOffset(depth),
|
|
75
|
+
...style
|
|
76
|
+
},
|
|
77
|
+
...props,
|
|
78
|
+
children
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function SidebarItem({ className, style, children, ...props }) {
|
|
82
|
+
const depth = useFolderDepth();
|
|
83
|
+
return /* @__PURE__ */ jsx(SidebarItem$1, {
|
|
84
|
+
className: cn(itemVariants({
|
|
85
|
+
variant: "link",
|
|
86
|
+
highlight: depth >= 1
|
|
87
|
+
}), className),
|
|
88
|
+
style: {
|
|
89
|
+
paddingInlineStart: getItemOffset(depth),
|
|
90
|
+
...style
|
|
91
|
+
},
|
|
92
|
+
...props,
|
|
93
|
+
children
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function SidebarFolderTrigger({ className, style, ...props }) {
|
|
97
|
+
const { depth, collapsible } = useFolder();
|
|
98
|
+
return /* @__PURE__ */ jsx(SidebarFolderTrigger$1, {
|
|
99
|
+
className: cn(itemVariants({ variant: collapsible ? "button" : null }), "w-full", className),
|
|
100
|
+
style: {
|
|
101
|
+
paddingInlineStart: getItemOffset(depth - 1),
|
|
102
|
+
...style
|
|
103
|
+
},
|
|
104
|
+
...props,
|
|
105
|
+
children: props.children
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function SidebarFolderLink({ className, style, ...props }) {
|
|
109
|
+
const depth = useFolderDepth();
|
|
110
|
+
return /* @__PURE__ */ jsx(SidebarFolderLink$1, {
|
|
111
|
+
className: cn(itemVariants({
|
|
112
|
+
variant: "link",
|
|
113
|
+
highlight: depth > 1
|
|
114
|
+
}), "w-full", className),
|
|
115
|
+
style: {
|
|
116
|
+
paddingInlineStart: getItemOffset(depth - 1),
|
|
117
|
+
...style
|
|
118
|
+
},
|
|
119
|
+
...props,
|
|
120
|
+
children: props.children
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function SidebarFolderContent({ className, children, ...props }) {
|
|
124
|
+
const depth = useFolderDepth();
|
|
125
|
+
return /* @__PURE__ */ jsx(SidebarFolderContent$1, {
|
|
126
|
+
className: cn("relative", depth === 1 && "before:content-[''] before:absolute before:w-px before:inset-y-1 before:bg-fd-border before:inset-s-2.5", className),
|
|
127
|
+
...props,
|
|
128
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
129
|
+
className: "flex flex-col gap-0.5 pt-0.5",
|
|
130
|
+
children
|
|
131
|
+
})
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const SidebarPageTree = createPageTreeRenderer({
|
|
135
|
+
SidebarFolder,
|
|
136
|
+
SidebarFolderContent,
|
|
137
|
+
SidebarFolderLink,
|
|
138
|
+
SidebarFolderTrigger,
|
|
139
|
+
SidebarItem,
|
|
140
|
+
SidebarSeparator
|
|
141
|
+
});
|
|
142
|
+
const SidebarLinkItem = createLinkItemRenderer({
|
|
143
|
+
SidebarFolder,
|
|
144
|
+
SidebarFolderContent,
|
|
145
|
+
SidebarFolderLink,
|
|
146
|
+
SidebarFolderTrigger,
|
|
147
|
+
SidebarItem
|
|
148
|
+
});
|
|
149
|
+
function Sidebar({ banner, footer, components, collapsible = true, ...rest }) {
|
|
150
|
+
const { menuItems, slots, props: { nav, tabs, tabMode } } = useNotebookLayout();
|
|
151
|
+
const navMode = nav?.mode ?? "auto";
|
|
152
|
+
const iconLinks = menuItems.filter((item) => item.type === "icon");
|
|
153
|
+
function renderHeader(props) {
|
|
154
|
+
if (typeof banner === "function") return createElement(banner, props);
|
|
155
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
156
|
+
...props,
|
|
157
|
+
className: cn("flex flex-col gap-3 p-4 pb-2 empty:hidden", props.className),
|
|
158
|
+
children: [props.children, banner]
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function renderFooter(props) {
|
|
162
|
+
if (typeof footer === "function") return createElement(footer, props);
|
|
163
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
164
|
+
...props,
|
|
165
|
+
children: [props.children, footer]
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
const viewport = /* @__PURE__ */ jsxs(SidebarViewport, { children: [menuItems.filter((item) => item.type !== "icon").map((item, i, arr) => /* @__PURE__ */ jsx(SidebarLinkItem, {
|
|
169
|
+
item,
|
|
170
|
+
className: cn("lg:hidden", i === arr.length - 1 && "mb-3")
|
|
171
|
+
}, i)), /* @__PURE__ */ jsx(SidebarPageTree, { ...components })] });
|
|
172
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(SidebarContent, {
|
|
173
|
+
...rest,
|
|
174
|
+
children: [
|
|
175
|
+
renderHeader({ children: /* @__PURE__ */ jsxs(Fragment, { children: [navMode === "auto" && /* @__PURE__ */ jsxs("div", {
|
|
176
|
+
className: "flex justify-between",
|
|
177
|
+
children: [
|
|
178
|
+
slots.navTitle && /* @__PURE__ */ jsx(slots.navTitle, { className: "inline-flex items-center gap-2.5 font-medium" }),
|
|
179
|
+
nav?.children,
|
|
180
|
+
collapsible && /* @__PURE__ */ jsx(SidebarCollapseTrigger, {
|
|
181
|
+
className: cn(buttonVariants({
|
|
182
|
+
color: "ghost",
|
|
183
|
+
size: "icon-sm",
|
|
184
|
+
className: "mt-px mb-auto text-fd-muted-foreground"
|
|
185
|
+
})),
|
|
186
|
+
children: /* @__PURE__ */ jsx(SidebarIcon, {})
|
|
187
|
+
})
|
|
188
|
+
]
|
|
189
|
+
}), tabs.length > 0 && /* @__PURE__ */ jsx(SidebarTabsDropdown, {
|
|
190
|
+
options: tabs,
|
|
191
|
+
className: cn(tabMode === "navbar" && "lg:hidden")
|
|
192
|
+
})] }) }),
|
|
193
|
+
viewport,
|
|
194
|
+
renderFooter({
|
|
195
|
+
className: cn("hidden flex-row text-fd-muted-foreground items-center border-t px-4 py-2.5", iconLinks.length > 0 && "max-lg:flex"),
|
|
196
|
+
children: iconLinks.map((item, i) => /* @__PURE__ */ jsx(LinkItem, {
|
|
197
|
+
item,
|
|
198
|
+
className: cn(buttonVariants({
|
|
199
|
+
size: "icon-sm",
|
|
200
|
+
color: "ghost",
|
|
201
|
+
className: "lg:hidden"
|
|
202
|
+
})),
|
|
203
|
+
"aria-label": item.label,
|
|
204
|
+
children: item.icon
|
|
205
|
+
}, i))
|
|
206
|
+
})
|
|
207
|
+
]
|
|
208
|
+
}), /* @__PURE__ */ jsxs(SidebarDrawer, {
|
|
209
|
+
...rest,
|
|
210
|
+
children: [
|
|
211
|
+
renderHeader({ children: /* @__PURE__ */ jsxs(Fragment, { 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 text-fd-muted-foreground items-center border-t p-4 pt-2 justify-end", (slots.languageSelect || slots.themeSwitch) && "flex", iconLinks.length > 0 && "max-lg:flex"),
|
|
222
|
+
children: /* @__PURE__ */ jsxs(Fragment, { 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
|
+
//#endregion
|
|
240
|
+
export { Sidebar, SidebarCollapseTrigger, SidebarProvider, SidebarTrigger, useSidebar };
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
//#region src/layouts/shared/client.d.ts
|
|
7
|
+
declare function LinkItem({ ref, item, ...props }: Omit<ComponentProps<'a'>, 'href'> & {
|
|
8
|
+
item: Extract<LinkItemType, {
|
|
9
|
+
url: string;
|
|
10
|
+
}>;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
interface BaseSlots {
|
|
13
|
+
navTitle: FC<ComponentProps<'a'>>;
|
|
14
|
+
themeSwitch: FC<ThemeSwitchProps> | false;
|
|
15
|
+
searchTrigger: {
|
|
16
|
+
sm: FC<SearchTriggerProps>;
|
|
17
|
+
full: FC<FullSearchTriggerProps>;
|
|
18
|
+
} | false;
|
|
19
|
+
languageSelect: {
|
|
20
|
+
root: FC<LanguageSelectProps>;
|
|
21
|
+
text: FC<LanguageSelectTextProps>;
|
|
22
|
+
} | false;
|
|
23
|
+
}
|
|
24
|
+
interface BaseSlotsProps<P extends BaseLayoutProps = BaseLayoutProps> extends Pick<P, 'nav'> {
|
|
25
|
+
themeSwitch: Omit<NonNullable<P['themeSwitch']>, 'enabled'>;
|
|
26
|
+
searchToggle: Omit<NonNullable<P['searchToggle']>, 'enabled'>;
|
|
27
|
+
}
|
|
28
|
+
declare function baseSlots({ useProps }: {
|
|
29
|
+
useProps: () => BaseSlotsProps;
|
|
30
|
+
}): {
|
|
31
|
+
useBaseSlots(options: BaseLayoutProps): {
|
|
32
|
+
baseSlots: BaseSlots;
|
|
33
|
+
baseProps: BaseSlotsProps;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
37
|
+
export { BaseSlots, BaseSlotsProps, LinkItem, baseSlots };
|
|
@@ -0,0 +1,85 @@
|
|
|
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 Link from "@vx-oss/docs-core/link";
|
|
8
|
+
import { usePathname } from "@vx-oss/docs-core/framework";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
//#region src/layouts/shared/client.tsx
|
|
11
|
+
function LinkItem({ ref, item, ...props }) {
|
|
12
|
+
const pathname = usePathname();
|
|
13
|
+
const active = isLinkItemActive(item, pathname);
|
|
14
|
+
return /* @__PURE__ */ jsx(Link, {
|
|
15
|
+
ref,
|
|
16
|
+
href: item.url,
|
|
17
|
+
external: item.external,
|
|
18
|
+
...props,
|
|
19
|
+
"data-active": active,
|
|
20
|
+
children: props.children
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function baseSlots({ useProps }) {
|
|
24
|
+
function InlineThemeSwitch(props) {
|
|
25
|
+
const { themeSwitch } = useProps();
|
|
26
|
+
if (themeSwitch.component) return themeSwitch.component;
|
|
27
|
+
return /* @__PURE__ */ jsx(ThemeSwitch, {
|
|
28
|
+
...props,
|
|
29
|
+
...themeSwitch
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function InlineSearchTrigger(props) {
|
|
33
|
+
const { searchToggle } = useProps();
|
|
34
|
+
if (searchToggle.components?.sm) return searchToggle.components.sm;
|
|
35
|
+
return /* @__PURE__ */ jsx(SearchTrigger, {
|
|
36
|
+
...props,
|
|
37
|
+
...searchToggle.sm
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function InlineSearchTriggerFull(props) {
|
|
41
|
+
const { searchToggle } = useProps();
|
|
42
|
+
if (searchToggle.components?.lg) return searchToggle.components.lg;
|
|
43
|
+
return /* @__PURE__ */ jsx(FullSearchTrigger, {
|
|
44
|
+
...props,
|
|
45
|
+
...searchToggle.full
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function InlineNavTitle({ href: defaultUrl = "/", ...props }) {
|
|
49
|
+
const { url = defaultUrl, title } = useProps().nav ?? {};
|
|
50
|
+
if (typeof title === "function") return title({
|
|
51
|
+
href: url,
|
|
52
|
+
...props
|
|
53
|
+
});
|
|
54
|
+
return /* @__PURE__ */ jsx(Link, {
|
|
55
|
+
href: url,
|
|
56
|
+
...props,
|
|
57
|
+
children: title
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return { useBaseSlots(options) {
|
|
61
|
+
const { locales = [] } = useI18n();
|
|
62
|
+
const { nav, slots = {}, i18n = locales.length > 1, searchToggle: { enabled: searchToggleEnabled = true, ...searchToggle } = {}, themeSwitch: { enabled: themeSwitchEnabled = true, ...themeSwitch } = {} } = options;
|
|
63
|
+
return {
|
|
64
|
+
baseSlots: {
|
|
65
|
+
navTitle: slots.navTitle ?? InlineNavTitle,
|
|
66
|
+
themeSwitch: themeSwitchEnabled && (slots.themeSwitch ?? InlineThemeSwitch),
|
|
67
|
+
languageSelect: i18n ? slots.languageSelect ?? {
|
|
68
|
+
root: LanguageSelect,
|
|
69
|
+
text: LanguageSelectText
|
|
70
|
+
} : false,
|
|
71
|
+
searchTrigger: searchToggleEnabled && (slots.searchTrigger ?? {
|
|
72
|
+
sm: InlineSearchTrigger,
|
|
73
|
+
full: InlineSearchTriggerFull
|
|
74
|
+
})
|
|
75
|
+
},
|
|
76
|
+
baseProps: {
|
|
77
|
+
nav,
|
|
78
|
+
searchToggle,
|
|
79
|
+
themeSwitch
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
} };
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { LinkItem, baseSlots };
|
|
@@ -0,0 +1,169 @@
|
|
|
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 "@vx-oss/docs-core/page-tree";
|
|
6
|
+
import { I18nConfig } from "@vx-oss/docs-core/i18n";
|
|
7
|
+
//#region src/layouts/shared/index.d.ts
|
|
8
|
+
interface NavOptions {
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
title?: ReactNode | FC<ComponentProps<'a'>>;
|
|
12
|
+
/**
|
|
13
|
+
* Redirect url of title
|
|
14
|
+
* @defaultValue '/'
|
|
15
|
+
*/
|
|
16
|
+
url?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Use transparent background
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue none
|
|
21
|
+
*/
|
|
22
|
+
transparentMode?: 'always' | 'top' | 'none';
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated use `slots.header` instead.
|
|
25
|
+
*/
|
|
26
|
+
component?: ReactNode;
|
|
27
|
+
}
|
|
28
|
+
interface BaseLayoutProps {
|
|
29
|
+
/**
|
|
30
|
+
* GitHub url
|
|
31
|
+
*/
|
|
32
|
+
githubUrl?: string;
|
|
33
|
+
links?: LinkItemType[];
|
|
34
|
+
/**
|
|
35
|
+
* navigation config
|
|
36
|
+
*/
|
|
37
|
+
nav?: NavOptions;
|
|
38
|
+
slots?: Partial<BaseSlots>;
|
|
39
|
+
children?: ReactNode;
|
|
40
|
+
themeSwitch?: ThemeSwitchOptions;
|
|
41
|
+
searchToggle?: SearchToggleOptions;
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated this is now optional for i18n setups, you can still customize language switch from `slots`.
|
|
44
|
+
*/
|
|
45
|
+
i18n?: boolean | I18nConfig;
|
|
46
|
+
}
|
|
47
|
+
interface SearchToggleOptions {
|
|
48
|
+
enabled?: boolean;
|
|
49
|
+
sm?: SearchTriggerProps;
|
|
50
|
+
full?: FullSearchTriggerProps;
|
|
51
|
+
/** @deprecated use `slots.searchTrigger` instead */
|
|
52
|
+
components?: {
|
|
53
|
+
sm?: ReactNode;
|
|
54
|
+
lg?: ReactNode;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
interface ThemeSwitchOptions extends ThemeSwitchProps {
|
|
58
|
+
enabled?: boolean;
|
|
59
|
+
/** @deprecated use `slots.themeSwitch` instead */
|
|
60
|
+
component?: ReactNode;
|
|
61
|
+
}
|
|
62
|
+
interface LayoutTab {
|
|
63
|
+
/**
|
|
64
|
+
* Redirect URL of the folder, usually the index page
|
|
65
|
+
*/
|
|
66
|
+
url: string;
|
|
67
|
+
icon?: ReactNode;
|
|
68
|
+
title: ReactNode;
|
|
69
|
+
description?: ReactNode;
|
|
70
|
+
unlisted?: boolean;
|
|
71
|
+
props?: ComponentProps<'a'>;
|
|
72
|
+
/**
|
|
73
|
+
* bind to a page tree node.
|
|
74
|
+
*/
|
|
75
|
+
$folder?: PageTree.Folder;
|
|
76
|
+
/**
|
|
77
|
+
* Detect from a list of urls (when not binded to page tree).
|
|
78
|
+
*/
|
|
79
|
+
urls?: Set<string>;
|
|
80
|
+
}
|
|
81
|
+
interface GetLayoutTabsOptions {
|
|
82
|
+
transform?: (option: LayoutTab, node: PageTree.Folder) => LayoutTab | null;
|
|
83
|
+
}
|
|
84
|
+
declare function getLayoutTabs(tree: PageTree.Root, { transform }?: GetLayoutTabsOptions): LayoutTab[];
|
|
85
|
+
declare function isLayoutTabActive(tab: LayoutTab, pathname: string): boolean;
|
|
86
|
+
interface Filterable {
|
|
87
|
+
/**
|
|
88
|
+
* Restrict where the item is displayed
|
|
89
|
+
*
|
|
90
|
+
* @defaultValue 'all'
|
|
91
|
+
*/
|
|
92
|
+
on?: 'menu' | 'nav' | 'all';
|
|
93
|
+
}
|
|
94
|
+
interface WithHref {
|
|
95
|
+
url: string;
|
|
96
|
+
/**
|
|
97
|
+
* When the item is marked as active
|
|
98
|
+
*
|
|
99
|
+
* @defaultValue 'url'
|
|
100
|
+
*/
|
|
101
|
+
active?: 'url' | 'nested-url' | 'none';
|
|
102
|
+
external?: boolean;
|
|
103
|
+
}
|
|
104
|
+
interface MainItemType extends WithHref, Filterable {
|
|
105
|
+
type?: 'main';
|
|
106
|
+
icon?: ReactNode;
|
|
107
|
+
text: ReactNode;
|
|
108
|
+
description?: ReactNode;
|
|
109
|
+
}
|
|
110
|
+
interface IconItemType extends WithHref, Filterable {
|
|
111
|
+
type: 'icon';
|
|
112
|
+
/**
|
|
113
|
+
* `aria-label` of icon button
|
|
114
|
+
*/
|
|
115
|
+
label?: string;
|
|
116
|
+
icon: ReactNode;
|
|
117
|
+
text: ReactNode;
|
|
118
|
+
/**
|
|
119
|
+
* @defaultValue true
|
|
120
|
+
*/
|
|
121
|
+
secondary?: boolean;
|
|
122
|
+
}
|
|
123
|
+
interface ButtonItemType extends WithHref, Filterable {
|
|
124
|
+
type: 'button';
|
|
125
|
+
icon?: ReactNode;
|
|
126
|
+
text: ReactNode;
|
|
127
|
+
/**
|
|
128
|
+
* @defaultValue false
|
|
129
|
+
*/
|
|
130
|
+
secondary?: boolean;
|
|
131
|
+
}
|
|
132
|
+
interface MenuItemType extends Partial<WithHref>, Filterable {
|
|
133
|
+
type: 'menu';
|
|
134
|
+
icon?: ReactNode;
|
|
135
|
+
text: ReactNode;
|
|
136
|
+
items: ((MainItemType & {
|
|
137
|
+
/**
|
|
138
|
+
* Options when displayed on navigation menu
|
|
139
|
+
*/
|
|
140
|
+
menu?: ComponentProps<'a'> & {
|
|
141
|
+
banner?: ReactNode;
|
|
142
|
+
};
|
|
143
|
+
}) | CustomItemType)[];
|
|
144
|
+
/**
|
|
145
|
+
* @defaultValue false
|
|
146
|
+
*/
|
|
147
|
+
secondary?: boolean;
|
|
148
|
+
}
|
|
149
|
+
interface CustomItemType extends Filterable {
|
|
150
|
+
type: 'custom';
|
|
151
|
+
/**
|
|
152
|
+
* @defaultValue false
|
|
153
|
+
*/
|
|
154
|
+
secondary?: boolean;
|
|
155
|
+
children: ReactNode;
|
|
156
|
+
}
|
|
157
|
+
type LinkItemType = MainItemType | IconItemType | ButtonItemType | MenuItemType | CustomItemType;
|
|
158
|
+
/**
|
|
159
|
+
* Get link items with shortcuts
|
|
160
|
+
*/
|
|
161
|
+
declare function resolveLinkItems({ links, githubUrl }: Pick<BaseLayoutProps, 'links' | 'githubUrl'>): LinkItemType[];
|
|
162
|
+
declare function useLinkItems({ githubUrl, links }: Pick<BaseLayoutProps, 'links' | 'githubUrl'>): {
|
|
163
|
+
navItems: LinkItemType[];
|
|
164
|
+
menuItems: LinkItemType[];
|
|
165
|
+
all: LinkItemType[];
|
|
166
|
+
};
|
|
167
|
+
declare function isLinkItemActive(link: LinkItemType, pathname: string): boolean;
|
|
168
|
+
//#endregion
|
|
169
|
+
export { BaseLayoutProps, type BaseSlots, type BaseSlotsProps, ButtonItemType, CustomItemType, GetLayoutTabsOptions, IconItemType, LayoutTab, LinkItem, LinkItemType, MainItemType, MenuItemType, NavOptions, baseSlots, getLayoutTabs, isLayoutTabActive, isLinkItemActive, resolveLinkItems, useLinkItems };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { isActive, normalize } from "../../utils/urls.js";
|
|
2
|
+
import { LinkItem, baseSlots } from "./client.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import * as PageTree from "@vx-oss/docs-core/page-tree";
|
|
6
|
+
//#region src/layouts/shared/index.tsx
|
|
7
|
+
const defaultTransform = (option, node) => {
|
|
8
|
+
if (!node.icon) return option;
|
|
9
|
+
return {
|
|
10
|
+
...option,
|
|
11
|
+
icon: /* @__PURE__ */ jsx("div", {
|
|
12
|
+
className: "size-full [&_svg]:size-full max-md:p-1.5 max-md:rounded-md max-md:border max-md:bg-fd-secondary",
|
|
13
|
+
children: node.icon
|
|
14
|
+
})
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
function getLayoutTabs(tree, { transform = defaultTransform } = {}) {
|
|
18
|
+
const results = [];
|
|
19
|
+
function next(node, unlisted) {
|
|
20
|
+
if ("root" in node && node.root) {
|
|
21
|
+
const url = node.index?.url ?? node.children.find((node) => node.type === "page")?.url;
|
|
22
|
+
if (url) {
|
|
23
|
+
const option = {
|
|
24
|
+
title: node.name,
|
|
25
|
+
icon: node.icon,
|
|
26
|
+
description: node.description,
|
|
27
|
+
url,
|
|
28
|
+
unlisted,
|
|
29
|
+
$folder: node
|
|
30
|
+
};
|
|
31
|
+
const mapped = transform ? transform(option, node) : option;
|
|
32
|
+
if (mapped) results.push(mapped);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
for (const child of node.children) if (child.type === "folder") next(child, unlisted);
|
|
36
|
+
}
|
|
37
|
+
next(tree);
|
|
38
|
+
if (tree.fallback) next(tree.fallback, true);
|
|
39
|
+
return results;
|
|
40
|
+
}
|
|
41
|
+
function isLayoutTabActive(tab, pathname) {
|
|
42
|
+
if (tab.$folder) return PageTree.findPath(tab.$folder.children, (node) => node.type === "page" && isActive(node.url, pathname)) !== null;
|
|
43
|
+
if (tab.urls) return tab.urls.has(normalize(pathname));
|
|
44
|
+
return isActive(tab.url, pathname, true);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get link items with shortcuts
|
|
48
|
+
*/
|
|
49
|
+
function resolveLinkItems({ links = [], githubUrl }) {
|
|
50
|
+
const result = [...links];
|
|
51
|
+
if (githubUrl) result.push({
|
|
52
|
+
type: "icon",
|
|
53
|
+
url: githubUrl,
|
|
54
|
+
text: "Github",
|
|
55
|
+
label: "GitHub",
|
|
56
|
+
icon: /* @__PURE__ */ jsx("svg", {
|
|
57
|
+
role: "img",
|
|
58
|
+
viewBox: "0 0 24 24",
|
|
59
|
+
fill: "currentColor",
|
|
60
|
+
children: /* @__PURE__ */ jsx("path", { d: "M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" })
|
|
61
|
+
}),
|
|
62
|
+
external: true
|
|
63
|
+
});
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
function useLinkItems({ githubUrl, links }) {
|
|
67
|
+
return useMemo(() => {
|
|
68
|
+
const all = resolveLinkItems({
|
|
69
|
+
links,
|
|
70
|
+
githubUrl
|
|
71
|
+
});
|
|
72
|
+
const navItems = [];
|
|
73
|
+
const menuItems = [];
|
|
74
|
+
for (const item of all) switch (item.on) {
|
|
75
|
+
case "menu":
|
|
76
|
+
menuItems.push(item);
|
|
77
|
+
break;
|
|
78
|
+
case "nav":
|
|
79
|
+
navItems.push(item);
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
navItems.push(item);
|
|
83
|
+
menuItems.push(item);
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
navItems,
|
|
87
|
+
menuItems,
|
|
88
|
+
all
|
|
89
|
+
};
|
|
90
|
+
}, [links, githubUrl]);
|
|
91
|
+
}
|
|
92
|
+
function isLinkItemActive(link, pathname) {
|
|
93
|
+
if (link.type === "custom" || !link.url) return false;
|
|
94
|
+
if (link.active === "none") return false;
|
|
95
|
+
return isActive(link.url, pathname, link.active === "nested-url");
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
export { LinkItem, baseSlots, getLayoutTabs, isLayoutTabActive, isLinkItemActive, resolveLinkItems, useLinkItems };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PopoverTrigger } from "../../components/ui/popover.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
//#region src/layouts/shared/page-actions.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* see https://fumadocs.dev/docs/integrations/llms#page-actions to customize.
|
|
6
|
+
*/
|
|
7
|
+
declare function MarkdownCopyButton({ markdownUrl, ...props }: ComponentProps<'button'> & {
|
|
8
|
+
/**
|
|
9
|
+
* A URL to fetch the raw Markdown/MDX content of page
|
|
10
|
+
*/
|
|
11
|
+
markdownUrl: string;
|
|
12
|
+
}): import("react").JSX.Element;
|
|
13
|
+
/**
|
|
14
|
+
* see https://fumadocs.dev/docs/integrations/llms#page-actions to customize.
|
|
15
|
+
*/
|
|
16
|
+
declare function ViewOptionsPopover({ markdownUrl, githubUrl, ...props }: ComponentProps<typeof PopoverTrigger> & {
|
|
17
|
+
/**
|
|
18
|
+
* A URL to the raw Markdown/MDX content of page
|
|
19
|
+
*/
|
|
20
|
+
markdownUrl?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Source file URL on GitHub
|
|
23
|
+
*/
|
|
24
|
+
githubUrl?: string;
|
|
25
|
+
}): import("react").JSX.Element;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { MarkdownCopyButton, ViewOptionsPopover };
|