@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,277 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../ui/collapsible.js";
|
|
5
|
+
import { ScrollArea, ScrollViewport } from "../ui/scroll-area.js";
|
|
6
|
+
import Link from "@vx-oss/docs-core/link";
|
|
7
|
+
import { usePathname } from "@vx-oss/docs-core/framework";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { ChevronDown, ExternalLink } from "lucide-react";
|
|
10
|
+
import { createContext, use, useEffect, useMemo, useRef, useState } from "react";
|
|
11
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
12
|
+
import { useOnChange } from "@vx-oss/docs-core/utils/use-on-change";
|
|
13
|
+
import { useMediaQuery } from "@vx-oss/docs-core/utils/use-media-query";
|
|
14
|
+
import { Presence } from "@radix-ui/react-presence";
|
|
15
|
+
import scrollIntoView from "scroll-into-view-if-needed";
|
|
16
|
+
//#region src/components/sidebar/base.tsx
|
|
17
|
+
var base_exports = /* @__PURE__ */ __exportAll({
|
|
18
|
+
SidebarCollapseTrigger: () => SidebarCollapseTrigger,
|
|
19
|
+
SidebarContent: () => SidebarContent,
|
|
20
|
+
SidebarDrawerContent: () => SidebarDrawerContent,
|
|
21
|
+
SidebarDrawerOverlay: () => SidebarDrawerOverlay,
|
|
22
|
+
SidebarFolder: () => SidebarFolder,
|
|
23
|
+
SidebarFolderContent: () => SidebarFolderContent,
|
|
24
|
+
SidebarFolderLink: () => SidebarFolderLink,
|
|
25
|
+
SidebarFolderTrigger: () => SidebarFolderTrigger,
|
|
26
|
+
SidebarItem: () => SidebarItem,
|
|
27
|
+
SidebarProvider: () => SidebarProvider,
|
|
28
|
+
SidebarSeparator: () => SidebarSeparator,
|
|
29
|
+
SidebarTrigger: () => SidebarTrigger,
|
|
30
|
+
SidebarViewport: () => SidebarViewport,
|
|
31
|
+
useAutoScroll: () => useAutoScroll,
|
|
32
|
+
useFolder: () => useFolder,
|
|
33
|
+
useFolderDepth: () => useFolderDepth,
|
|
34
|
+
useSidebar: () => useSidebar
|
|
35
|
+
});
|
|
36
|
+
const SidebarContext = createContext(null);
|
|
37
|
+
const FolderContext = createContext(null);
|
|
38
|
+
function SidebarProvider({ defaultOpenLevel = 0, prefetch, children }) {
|
|
39
|
+
const closeOnRedirect = useRef(true);
|
|
40
|
+
const [open, setOpen] = useState(false);
|
|
41
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
42
|
+
const pathname = usePathname();
|
|
43
|
+
const mode = useMediaQuery("(width < 768px)") ? "drawer" : "full";
|
|
44
|
+
useOnChange(pathname, () => {
|
|
45
|
+
if (closeOnRedirect.current) setOpen(false);
|
|
46
|
+
closeOnRedirect.current = true;
|
|
47
|
+
});
|
|
48
|
+
return /* @__PURE__ */ jsx(SidebarContext, {
|
|
49
|
+
value: useMemo(() => ({
|
|
50
|
+
open,
|
|
51
|
+
setOpen,
|
|
52
|
+
collapsed,
|
|
53
|
+
setCollapsed,
|
|
54
|
+
closeOnRedirect,
|
|
55
|
+
defaultOpenLevel,
|
|
56
|
+
prefetch,
|
|
57
|
+
mode
|
|
58
|
+
}), [
|
|
59
|
+
open,
|
|
60
|
+
collapsed,
|
|
61
|
+
defaultOpenLevel,
|
|
62
|
+
prefetch,
|
|
63
|
+
mode
|
|
64
|
+
]),
|
|
65
|
+
children
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function useSidebar() {
|
|
69
|
+
const ctx = use(SidebarContext);
|
|
70
|
+
if (!ctx) throw new Error("Missing SidebarContext, make sure you have wrapped the component in <DocsLayout /> and the context is available.");
|
|
71
|
+
return ctx;
|
|
72
|
+
}
|
|
73
|
+
function useFolder() {
|
|
74
|
+
return use(FolderContext);
|
|
75
|
+
}
|
|
76
|
+
function useFolderDepth() {
|
|
77
|
+
return use(FolderContext)?.depth ?? 0;
|
|
78
|
+
}
|
|
79
|
+
function SidebarContent({ mode: allowedMode = "full", children }) {
|
|
80
|
+
const { collapsed, mode } = useSidebar();
|
|
81
|
+
const [hover, setHover] = useState(false);
|
|
82
|
+
const ref = useRef(null);
|
|
83
|
+
const timerRef = useRef(0);
|
|
84
|
+
useOnChange(collapsed, () => {
|
|
85
|
+
if (collapsed) setHover(false);
|
|
86
|
+
});
|
|
87
|
+
if (allowedMode !== true && allowedMode !== mode) return;
|
|
88
|
+
function shouldIgnoreHover(e) {
|
|
89
|
+
const element = ref.current;
|
|
90
|
+
if (!element) return true;
|
|
91
|
+
return !collapsed || e.pointerType === "touch" || element.getAnimations().length > 0;
|
|
92
|
+
}
|
|
93
|
+
return children({
|
|
94
|
+
ref,
|
|
95
|
+
collapsed,
|
|
96
|
+
hovered: hover,
|
|
97
|
+
onPointerEnter(e) {
|
|
98
|
+
if (shouldIgnoreHover(e)) return;
|
|
99
|
+
window.clearTimeout(timerRef.current);
|
|
100
|
+
setHover(true);
|
|
101
|
+
},
|
|
102
|
+
onPointerLeave(e) {
|
|
103
|
+
if (shouldIgnoreHover(e)) return;
|
|
104
|
+
window.clearTimeout(timerRef.current);
|
|
105
|
+
timerRef.current = window.setTimeout(() => setHover(false), Math.min(e.clientX, document.body.clientWidth - e.clientX) > 100 ? 0 : 500);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function SidebarViewport({ area, viewport, children }) {
|
|
110
|
+
return /* @__PURE__ */ jsx(ScrollArea, {
|
|
111
|
+
...area,
|
|
112
|
+
className: cn("min-h-0 flex-1", area?.className),
|
|
113
|
+
children: /* @__PURE__ */ jsx(ScrollViewport, {
|
|
114
|
+
...viewport,
|
|
115
|
+
className: cn("*:flex! *:flex-col! *:gap-0.5! p-4 overscroll-contain mask-[linear-gradient(to_bottom,transparent,white_12px,white_calc(100%-12px),transparent)]", viewport?.className),
|
|
116
|
+
children
|
|
117
|
+
})
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function SidebarDrawerOverlay(props) {
|
|
121
|
+
const { open, setOpen, mode } = useSidebar();
|
|
122
|
+
if (mode !== "drawer") return;
|
|
123
|
+
return /* @__PURE__ */ jsx(Presence, {
|
|
124
|
+
present: open,
|
|
125
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
126
|
+
"data-state": open ? "open" : "closed",
|
|
127
|
+
onClick: () => setOpen(false),
|
|
128
|
+
...props
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function SidebarDrawerContent({ className, children, ...props }) {
|
|
133
|
+
const { open, mode } = useSidebar();
|
|
134
|
+
const state = open ? "open" : "closed";
|
|
135
|
+
if (mode !== "drawer") return;
|
|
136
|
+
return /* @__PURE__ */ jsx(Presence, {
|
|
137
|
+
present: open,
|
|
138
|
+
children: ({ present }) => /* @__PURE__ */ jsx("aside", {
|
|
139
|
+
id: "nd-sidebar-mobile",
|
|
140
|
+
"data-state": state,
|
|
141
|
+
className: cn(!present && "invisible", className),
|
|
142
|
+
...props,
|
|
143
|
+
children
|
|
144
|
+
})
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function SidebarSeparator(props) {
|
|
148
|
+
return /* @__PURE__ */ jsx("p", { ...props });
|
|
149
|
+
}
|
|
150
|
+
function SidebarItem({ icon, active = false, children, ...props }) {
|
|
151
|
+
const ref = useRef(null);
|
|
152
|
+
const { prefetch } = useSidebar();
|
|
153
|
+
useAutoScroll(active, ref);
|
|
154
|
+
return /* @__PURE__ */ jsxs(Link, {
|
|
155
|
+
ref,
|
|
156
|
+
"data-active": active,
|
|
157
|
+
prefetch,
|
|
158
|
+
...props,
|
|
159
|
+
children: [icon ?? (props.external ? /* @__PURE__ */ jsx(ExternalLink, {}) : null), children]
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function SidebarFolder({ defaultOpen: defaultOpenProp, collapsible = true, active = false, children, ...props }) {
|
|
163
|
+
const { defaultOpenLevel } = useSidebar();
|
|
164
|
+
const depth = useFolderDepth() + 1;
|
|
165
|
+
const defaultOpen = collapsible === false || active || (defaultOpenProp ?? defaultOpenLevel >= depth);
|
|
166
|
+
const [open, setOpen] = useState(defaultOpen);
|
|
167
|
+
useOnChange(defaultOpen, (v) => {
|
|
168
|
+
if (v) setOpen(v);
|
|
169
|
+
});
|
|
170
|
+
return /* @__PURE__ */ jsx(Collapsible, {
|
|
171
|
+
open,
|
|
172
|
+
onOpenChange: setOpen,
|
|
173
|
+
disabled: !collapsible,
|
|
174
|
+
...props,
|
|
175
|
+
children: /* @__PURE__ */ jsx(FolderContext, {
|
|
176
|
+
value: useMemo(() => ({
|
|
177
|
+
open,
|
|
178
|
+
setOpen,
|
|
179
|
+
depth,
|
|
180
|
+
collapsible
|
|
181
|
+
}), [
|
|
182
|
+
collapsible,
|
|
183
|
+
depth,
|
|
184
|
+
open
|
|
185
|
+
]),
|
|
186
|
+
children
|
|
187
|
+
})
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function SidebarFolderTrigger({ children, ...props }) {
|
|
191
|
+
const { open, collapsible } = use(FolderContext);
|
|
192
|
+
if (collapsible) return /* @__PURE__ */ jsxs(CollapsibleTrigger, {
|
|
193
|
+
...props,
|
|
194
|
+
children: [children, /* @__PURE__ */ jsx(ChevronDown, {
|
|
195
|
+
"data-icon": true,
|
|
196
|
+
className: cn("ms-auto transition-transform", !open && "-rotate-90 rtl:rotate-90")
|
|
197
|
+
})]
|
|
198
|
+
});
|
|
199
|
+
return /* @__PURE__ */ jsx("div", {
|
|
200
|
+
...props,
|
|
201
|
+
children
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function SidebarFolderLink({ children, active = false, ...props }) {
|
|
205
|
+
const ref = useRef(null);
|
|
206
|
+
const { open, setOpen, collapsible } = use(FolderContext);
|
|
207
|
+
const { prefetch } = useSidebar();
|
|
208
|
+
useAutoScroll(active, ref);
|
|
209
|
+
return /* @__PURE__ */ jsxs(Link, {
|
|
210
|
+
ref,
|
|
211
|
+
"data-active": active,
|
|
212
|
+
onClick: (e) => {
|
|
213
|
+
if (!collapsible) return;
|
|
214
|
+
if (e.target instanceof Element && e.target.matches("[data-icon], [data-icon] *")) {
|
|
215
|
+
setOpen(!open);
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
} else setOpen(active ? !open : true);
|
|
218
|
+
},
|
|
219
|
+
prefetch,
|
|
220
|
+
...props,
|
|
221
|
+
children: [children, collapsible && /* @__PURE__ */ jsx(ChevronDown, {
|
|
222
|
+
"data-icon": true,
|
|
223
|
+
className: cn("ms-auto transition-transform", !open && "-rotate-90 rtl:rotate-90")
|
|
224
|
+
})]
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
function SidebarFolderContent(props) {
|
|
228
|
+
return /* @__PURE__ */ jsx(CollapsibleContent, {
|
|
229
|
+
...props,
|
|
230
|
+
children: props.children
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
function SidebarTrigger({ children, ...props }) {
|
|
234
|
+
const { open, setOpen } = useSidebar();
|
|
235
|
+
const t = useTranslations({ note: "sidebar" });
|
|
236
|
+
return /* @__PURE__ */ jsx("button", {
|
|
237
|
+
type: "button",
|
|
238
|
+
"aria-label": open ? t("Close Sidebar", { note: "aria-label" }) : t("Open Sidebar", { note: "aria-label" }),
|
|
239
|
+
"aria-expanded": open,
|
|
240
|
+
"aria-controls": "nd-sidebar-mobile",
|
|
241
|
+
onClick: () => setOpen((prev) => !prev),
|
|
242
|
+
...props,
|
|
243
|
+
children
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
function SidebarCollapseTrigger(props) {
|
|
247
|
+
const { collapsed, setCollapsed } = useSidebar();
|
|
248
|
+
const t = useTranslations({ note: "sidebar" });
|
|
249
|
+
return /* @__PURE__ */ jsx("button", {
|
|
250
|
+
type: "button",
|
|
251
|
+
"aria-label": t("Collapse Sidebar", { note: "aria-label" }),
|
|
252
|
+
"data-collapsed": collapsed,
|
|
253
|
+
onClick: () => {
|
|
254
|
+
setCollapsed((prev) => !prev);
|
|
255
|
+
},
|
|
256
|
+
...props,
|
|
257
|
+
children: props.children
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* scroll to the element if `active` is true
|
|
262
|
+
*/
|
|
263
|
+
function useAutoScroll(active, ref) {
|
|
264
|
+
const { mode } = useSidebar();
|
|
265
|
+
useEffect(() => {
|
|
266
|
+
if (active && ref.current) scrollIntoView(ref.current, {
|
|
267
|
+
boundary: document.getElementById(mode === "drawer" ? "nd-sidebar-mobile" : "nd-sidebar"),
|
|
268
|
+
scrollMode: "if-needed"
|
|
269
|
+
});
|
|
270
|
+
}, [
|
|
271
|
+
active,
|
|
272
|
+
mode,
|
|
273
|
+
ref
|
|
274
|
+
]);
|
|
275
|
+
}
|
|
276
|
+
//#endregion
|
|
277
|
+
export { SidebarCollapseTrigger, SidebarContent, SidebarDrawerContent, SidebarDrawerOverlay, SidebarFolder, SidebarFolderContent, SidebarFolderLink, SidebarFolderTrigger, SidebarItem, SidebarProvider, SidebarSeparator, SidebarTrigger, SidebarViewport, base_exports, useAutoScroll, useFolder, useFolderDepth, useSidebar };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { base_d_exports } from "./base.js";
|
|
2
|
+
import { LinkItemType } from "../../layouts/shared/index.js";
|
|
3
|
+
import { HTMLAttributes } from "react";
|
|
4
|
+
//#region src/components/sidebar/link-item.d.ts
|
|
5
|
+
type InternalComponents = Pick<typeof base_d_exports, 'SidebarFolder' | 'SidebarFolderLink' | 'SidebarFolderContent' | 'SidebarFolderTrigger' | 'SidebarItem'>;
|
|
6
|
+
declare function createLinkItemRenderer({ SidebarFolder, SidebarFolderContent, SidebarFolderLink, SidebarFolderTrigger, SidebarItem }: InternalComponents): ({ item, ...props }: HTMLAttributes<HTMLElement> & {
|
|
7
|
+
item: Exclude<LinkItemType, {
|
|
8
|
+
type: "icon";
|
|
9
|
+
}>;
|
|
10
|
+
}) => import("react").JSX.Element;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { createLinkItemRenderer };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { isLinkItemActive } from "../../layouts/shared/index.js";
|
|
3
|
+
import { usePathname } from "@vx-oss/docs-core/framework";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/sidebar/link-item.tsx
|
|
6
|
+
function createLinkItemRenderer({ SidebarFolder, SidebarFolderContent, SidebarFolderLink, SidebarFolderTrigger, SidebarItem }) {
|
|
7
|
+
/**
|
|
8
|
+
* Render sidebar items from page tree
|
|
9
|
+
*/
|
|
10
|
+
return function SidebarLinkItem({ item, ...props }) {
|
|
11
|
+
const pathname = usePathname();
|
|
12
|
+
const active = isLinkItemActive(item, pathname);
|
|
13
|
+
if (item.type === "custom") return /* @__PURE__ */ jsx("div", {
|
|
14
|
+
...props,
|
|
15
|
+
children: item.children
|
|
16
|
+
});
|
|
17
|
+
if (item.type === "menu") return /* @__PURE__ */ jsxs(SidebarFolder, {
|
|
18
|
+
...props,
|
|
19
|
+
children: [item.url ? /* @__PURE__ */ jsxs(SidebarFolderLink, {
|
|
20
|
+
href: item.url,
|
|
21
|
+
active,
|
|
22
|
+
external: item.external,
|
|
23
|
+
children: [item.icon, item.text]
|
|
24
|
+
}) : /* @__PURE__ */ jsxs(SidebarFolderTrigger, { children: [item.icon, item.text] }), /* @__PURE__ */ jsx(SidebarFolderContent, { children: item.items.map((child, i) => /* @__PURE__ */ jsx(SidebarLinkItem, { item: child }, i)) })]
|
|
25
|
+
});
|
|
26
|
+
return /* @__PURE__ */ jsx(SidebarItem, {
|
|
27
|
+
href: item.url,
|
|
28
|
+
icon: item.icon,
|
|
29
|
+
external: item.external,
|
|
30
|
+
active,
|
|
31
|
+
...props,
|
|
32
|
+
children: item.text
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { createLinkItemRenderer };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { base_d_exports } from "./base.js";
|
|
2
|
+
import { FC, ReactNode } from "react";
|
|
3
|
+
import * as PageTree from "@vx-oss/docs-core/page-tree";
|
|
4
|
+
//#region src/components/sidebar/page-tree.d.ts
|
|
5
|
+
interface SidebarPageTreeComponents {
|
|
6
|
+
Item: FC<{
|
|
7
|
+
item: PageTree.Item;
|
|
8
|
+
}>;
|
|
9
|
+
Folder: FC<{
|
|
10
|
+
item: PageTree.Folder;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
}>;
|
|
13
|
+
Separator: FC<{
|
|
14
|
+
item: PageTree.Separator;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
type InternalComponents = Pick<typeof base_d_exports, 'SidebarSeparator' | 'SidebarFolder' | 'SidebarFolderLink' | 'SidebarFolderContent' | 'SidebarFolderTrigger' | 'SidebarItem'>;
|
|
18
|
+
declare function createPageTreeRenderer({ SidebarFolder, SidebarFolderContent, SidebarFolderLink, SidebarFolderTrigger, SidebarSeparator, SidebarItem }: InternalComponents): (components: Partial<SidebarPageTreeComponents>) => import("react").JSX.Element;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { SidebarPageTreeComponents, createPageTreeRenderer };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { useTreeContext, useTreePath } from "../../contexts/tree.js";
|
|
2
|
+
import { isActive } from "../../utils/urls.js";
|
|
3
|
+
import { usePathname } from "@vx-oss/docs-core/framework";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Fragment as Fragment$1, createContext, use, useMemo } from "react";
|
|
6
|
+
//#region src/components/sidebar/page-tree.tsx
|
|
7
|
+
const RendererContext = createContext(null);
|
|
8
|
+
function createPageTreeRenderer({ SidebarFolder, SidebarFolderContent, SidebarFolderLink, SidebarFolderTrigger, SidebarSeparator, SidebarItem }) {
|
|
9
|
+
function renderList(nodes) {
|
|
10
|
+
return nodes.map((node, i) => /* @__PURE__ */ jsx(PageTreeNode, { node }, i));
|
|
11
|
+
}
|
|
12
|
+
function PageTreeNode({ node }) {
|
|
13
|
+
const { Separator, Item, Folder, pathname } = use(RendererContext);
|
|
14
|
+
if (node.type === "separator") {
|
|
15
|
+
if (Separator) return /* @__PURE__ */ jsx(Separator, { item: node });
|
|
16
|
+
return /* @__PURE__ */ jsxs(SidebarSeparator, { children: [node.icon, node.name] });
|
|
17
|
+
}
|
|
18
|
+
if (node.type === "folder") {
|
|
19
|
+
const path = useTreePath();
|
|
20
|
+
if (Folder) return /* @__PURE__ */ jsx(Folder, {
|
|
21
|
+
item: node,
|
|
22
|
+
children: renderList(node.children)
|
|
23
|
+
});
|
|
24
|
+
return /* @__PURE__ */ jsxs(SidebarFolder, {
|
|
25
|
+
collapsible: node.collapsible,
|
|
26
|
+
active: path.includes(node),
|
|
27
|
+
defaultOpen: node.defaultOpen,
|
|
28
|
+
children: [node.index ? /* @__PURE__ */ jsxs(SidebarFolderLink, {
|
|
29
|
+
href: node.index.url,
|
|
30
|
+
active: isActive(node.index.url, pathname),
|
|
31
|
+
external: node.index.external,
|
|
32
|
+
children: [node.icon, node.name]
|
|
33
|
+
}) : /* @__PURE__ */ jsxs(SidebarFolderTrigger, { children: [node.icon, node.name] }), /* @__PURE__ */ jsx(SidebarFolderContent, { children: renderList(node.children) })]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (Item) return /* @__PURE__ */ jsx(Item, { item: node });
|
|
37
|
+
return /* @__PURE__ */ jsx(SidebarItem, {
|
|
38
|
+
href: node.url,
|
|
39
|
+
external: node.external,
|
|
40
|
+
active: isActive(node.url, pathname),
|
|
41
|
+
icon: node.icon,
|
|
42
|
+
children: node.name
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Render sidebar items from page tree
|
|
47
|
+
*/
|
|
48
|
+
return function SidebarPageTree(components) {
|
|
49
|
+
const { Folder, Item, Separator } = components;
|
|
50
|
+
const { root } = useTreeContext();
|
|
51
|
+
const pathname = usePathname();
|
|
52
|
+
return /* @__PURE__ */ jsx(RendererContext, {
|
|
53
|
+
value: useMemo(() => ({
|
|
54
|
+
Folder,
|
|
55
|
+
Item,
|
|
56
|
+
Separator,
|
|
57
|
+
pathname
|
|
58
|
+
}), [
|
|
59
|
+
Folder,
|
|
60
|
+
Item,
|
|
61
|
+
Separator,
|
|
62
|
+
pathname
|
|
63
|
+
]),
|
|
64
|
+
children: /* @__PURE__ */ jsx(Fragment$1, { children: renderList(root.children) }, root.$id)
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { createPageTreeRenderer };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LayoutTab, isLayoutTabActive } from "../../../layouts/shared/index.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
//#region src/components/sidebar/tabs/dropdown.d.ts
|
|
4
|
+
type SidebarTabWithProps = LayoutTab;
|
|
5
|
+
/**
|
|
6
|
+
* Renders the given tabs as a dropdown per tabs group, one for each root folder on the
|
|
7
|
+
* current page's path, letting users switch between root folders of the same type.
|
|
8
|
+
*/
|
|
9
|
+
declare function SidebarTabsDropdown({ options, placeholder, ...props }: {
|
|
10
|
+
placeholder?: ReactNode;
|
|
11
|
+
options: LayoutTab[];
|
|
12
|
+
} & ComponentProps<'button'>): import("react").JSX.Element[];
|
|
13
|
+
declare const isTabActive: typeof isLayoutTabActive;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { SidebarTabWithProps, SidebarTabsDropdown, isTabActive };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../../utils/cn.js";
|
|
3
|
+
import { useTabsGroups } from "../../../contexts/tree.js";
|
|
4
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../../ui/popover.js";
|
|
5
|
+
import { isLayoutTabActive } from "../../../layouts/shared/index.js";
|
|
6
|
+
import { useSidebar } from "../base.js";
|
|
7
|
+
import Link from "@vx-oss/docs-core/link";
|
|
8
|
+
import { usePathname } from "@vx-oss/docs-core/framework";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { Check, ChevronsUpDown } from "lucide-react";
|
|
11
|
+
import { useMemo, useState } from "react";
|
|
12
|
+
//#region src/components/sidebar/tabs/dropdown.tsx
|
|
13
|
+
/**
|
|
14
|
+
* Renders the given tabs as a dropdown per tabs group, one for each root folder on the
|
|
15
|
+
* current page's path, letting users switch between root folders of the same type.
|
|
16
|
+
*/
|
|
17
|
+
function SidebarTabsDropdown({ options, placeholder, ...props }) {
|
|
18
|
+
return useTabsGroups(options).map((group, i) => /* @__PURE__ */ jsx(Dropdown, {
|
|
19
|
+
options: group.options,
|
|
20
|
+
placeholder,
|
|
21
|
+
...props
|
|
22
|
+
}, i));
|
|
23
|
+
}
|
|
24
|
+
function Dropdown({ options, placeholder, ...props }) {
|
|
25
|
+
const [open, setOpen] = useState(false);
|
|
26
|
+
const { closeOnRedirect } = useSidebar();
|
|
27
|
+
const pathname = usePathname();
|
|
28
|
+
const selected = useMemo(() => {
|
|
29
|
+
return options.findLast((item) => isLayoutTabActive(item, pathname));
|
|
30
|
+
}, [options, pathname]);
|
|
31
|
+
const onClick = () => {
|
|
32
|
+
closeOnRedirect.current = false;
|
|
33
|
+
setOpen(false);
|
|
34
|
+
};
|
|
35
|
+
const item = selected ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
36
|
+
className: "size-9 shrink-0 empty:hidden md:size-5",
|
|
37
|
+
children: selected.icon
|
|
38
|
+
}), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
39
|
+
className: "text-sm font-medium",
|
|
40
|
+
children: selected.title
|
|
41
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
42
|
+
className: "text-sm text-fd-muted-foreground empty:hidden md:hidden",
|
|
43
|
+
children: selected.description
|
|
44
|
+
})] })] }) : placeholder;
|
|
45
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
46
|
+
open,
|
|
47
|
+
onOpenChange: setOpen,
|
|
48
|
+
children: [item && /* @__PURE__ */ jsxs(PopoverTrigger, {
|
|
49
|
+
...props,
|
|
50
|
+
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),
|
|
51
|
+
children: [item, /* @__PURE__ */ jsx(ChevronsUpDown, { className: "shrink-0 ms-auto size-4 text-fd-muted-foreground" })]
|
|
52
|
+
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
53
|
+
className: "flex flex-col gap-1 w-(--radix-popover-trigger-width) p-1 fd-scroll-container",
|
|
54
|
+
children: options.map((item) => {
|
|
55
|
+
const isActive = selected && item.url === selected.url;
|
|
56
|
+
if (!isActive && item.unlisted) return;
|
|
57
|
+
return /* @__PURE__ */ jsxs(Link, {
|
|
58
|
+
href: item.url,
|
|
59
|
+
onClick,
|
|
60
|
+
...item.props,
|
|
61
|
+
className: cn("flex items-center gap-2 rounded-lg p-1.5 hover:bg-fd-accent hover:text-fd-accent-foreground", item.props?.className),
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ jsx("div", {
|
|
64
|
+
className: "shrink-0 size-9 md:mb-auto md:size-5 empty:hidden",
|
|
65
|
+
children: item.icon
|
|
66
|
+
}),
|
|
67
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
68
|
+
className: "text-sm font-medium leading-none",
|
|
69
|
+
children: item.title
|
|
70
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
71
|
+
className: "text-[0.8125rem] text-fd-muted-foreground mt-1 empty:hidden",
|
|
72
|
+
children: item.description
|
|
73
|
+
})] }),
|
|
74
|
+
/* @__PURE__ */ jsx(Check, { className: cn("shrink-0 ms-auto size-3.5 text-fd-primary", !isActive && "invisible") })
|
|
75
|
+
]
|
|
76
|
+
}, item.url);
|
|
77
|
+
})
|
|
78
|
+
})]
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const isTabActive = isLayoutTabActive;
|
|
82
|
+
//#endregion
|
|
83
|
+
export { SidebarTabsDropdown, isTabActive };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GetLayoutTabsOptions, LayoutTab } from "../../../layouts/shared/index.js";
|
|
2
|
+
import * as PageTree from "@vx-oss/docs-core/page-tree";
|
|
3
|
+
//#region src/components/sidebar/tabs/index.d.ts
|
|
4
|
+
type SidebarTab = LayoutTab;
|
|
5
|
+
type GetSidebarTabsOptions = GetLayoutTabsOptions;
|
|
6
|
+
declare function getSidebarTabs(tree: PageTree.Root, { transform }?: GetSidebarTabsOptions): SidebarTab[];
|
|
7
|
+
//#endregion
|
|
8
|
+
export { GetSidebarTabsOptions, SidebarTab, getSidebarTabs };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
//#region src/components/sidebar/tabs/index.tsx
|
|
3
|
+
const defaultTransform = (option, node) => {
|
|
4
|
+
if (!node.icon) return option;
|
|
5
|
+
return {
|
|
6
|
+
...option,
|
|
7
|
+
icon: /* @__PURE__ */ jsx("div", {
|
|
8
|
+
className: "size-full [&_svg]:size-full max-md:p-1.5 max-md:rounded-md max-md:border max-md:bg-fd-secondary",
|
|
9
|
+
children: node.icon
|
|
10
|
+
})
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
function getSidebarTabs(tree, { transform = defaultTransform } = {}) {
|
|
14
|
+
const results = [];
|
|
15
|
+
function scanOptions(node, unlisted) {
|
|
16
|
+
if ("root" in node && node.root) {
|
|
17
|
+
const urls = getFolderUrls(node);
|
|
18
|
+
if (urls.size > 0) {
|
|
19
|
+
const option = {
|
|
20
|
+
url: urls.values().next().value ?? "",
|
|
21
|
+
title: node.name,
|
|
22
|
+
icon: node.icon,
|
|
23
|
+
unlisted,
|
|
24
|
+
description: node.description,
|
|
25
|
+
urls
|
|
26
|
+
};
|
|
27
|
+
const mapped = transform ? transform(option, node) : option;
|
|
28
|
+
if (mapped) results.push(mapped);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (const child of node.children) if (child.type === "folder") scanOptions(child, unlisted);
|
|
32
|
+
}
|
|
33
|
+
scanOptions(tree);
|
|
34
|
+
if (tree.fallback) scanOptions(tree.fallback, true);
|
|
35
|
+
return results;
|
|
36
|
+
}
|
|
37
|
+
function getFolderUrls(folder, output = /* @__PURE__ */ new Set()) {
|
|
38
|
+
if (folder.index) output.add(folder.index.url);
|
|
39
|
+
for (const child of folder.children) {
|
|
40
|
+
if (child.type === "page" && !child.external) output.add(child.url);
|
|
41
|
+
if (child.type === "folder") getFolderUrls(child, output);
|
|
42
|
+
}
|
|
43
|
+
return output;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { getSidebarTabs };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
//#region src/components/steps.d.ts
|
|
3
|
+
declare function Steps({ children }: {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}): import("react").JSX.Element;
|
|
6
|
+
declare function Step({ children }: {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { Step, Steps };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
//#region src/components/steps.tsx
|
|
3
|
+
function Steps({ children }) {
|
|
4
|
+
return /* @__PURE__ */ jsx("div", {
|
|
5
|
+
className: "fd-steps",
|
|
6
|
+
children
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
function Step({ children }) {
|
|
10
|
+
return /* @__PURE__ */ jsx("div", {
|
|
11
|
+
className: "fd-step",
|
|
12
|
+
children
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { Step, Steps };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Tabs as Tabs$1, TabsContent as TabsContent$1, TabsList as TabsList$1, TabsTrigger as TabsTrigger$1 } from "./ui/tabs.js";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
import { ComponentProps, ReactNode } from "react";
|
|
4
|
+
//#region src/components/tabs.d.ts
|
|
5
|
+
interface TabsProps extends Omit<ComponentProps<typeof Tabs$1>, 'value' | 'onValueChange'> {
|
|
6
|
+
/**
|
|
7
|
+
* Use simple mode instead of advanced usage as documented in https://radix-ui.com/primitives/docs/components/tabs.
|
|
8
|
+
*/
|
|
9
|
+
items?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Shortcut for `defaultValue` when `items` is provided.
|
|
12
|
+
*
|
|
13
|
+
* @defaultValue 0
|
|
14
|
+
*/
|
|
15
|
+
defaultIndex?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Additional label in tabs list when `items` is provided.
|
|
18
|
+
*/
|
|
19
|
+
label?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
declare function TabsList(props: React$1.ComponentProps<typeof TabsList$1>): React$1.JSX.Element;
|
|
22
|
+
declare function TabsTrigger(props: React$1.ComponentProps<typeof TabsTrigger$1>): React$1.JSX.Element;
|
|
23
|
+
declare function Tabs({ ref, className, items, label, defaultIndex, defaultValue, ...props }: TabsProps): React$1.JSX.Element;
|
|
24
|
+
interface TabProps extends Omit<ComponentProps<typeof TabsContent$1>, 'value'> {
|
|
25
|
+
/**
|
|
26
|
+
* Value of tab, detect from index if unspecified.
|
|
27
|
+
*/
|
|
28
|
+
value?: string;
|
|
29
|
+
}
|
|
30
|
+
declare function Tab({ value, ...props }: TabProps): React$1.JSX.Element;
|
|
31
|
+
declare function TabsContent({ value, className, ...props }: ComponentProps<typeof TabsContent$1>): React$1.JSX.Element;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { Tab, TabProps, Tabs, TabsContent, TabsList, TabsProps, TabsTrigger };
|