@vx-oss/docs-react 1.0.4 → 1.0.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/README.md +3 -3
- package/css/generated/docs.css +1 -1
- package/css/generated/flux.css +1 -1
- package/css/generated/glass.css +1 -1
- package/css/generated/home.css +1 -1
- package/css/generated/notebook.css +1 -1
- package/css/generated/shared.css +1 -1
- package/css/lib/base.css +0 -127
- package/css/preset.css +1 -2
- package/css/style.css +1 -0
- package/dist/components/accordion.js +1 -68
- package/dist/components/banner.js +1 -85
- package/dist/components/callout.js +1 -60
- package/dist/components/card.js +1 -39
- package/dist/components/codeblock.js +1 -126
- package/dist/components/codeblock.rsc.js +1 -22
- package/dist/components/dialog/search-algolia.js +2 -64
- package/dist/components/dialog/search-default.js +2 -66
- package/dist/components/dialog/search-orama.js +2 -69
- package/dist/components/dialog/search.js +1 -351
- package/dist/components/dynamic-codeblock.core.js +1 -51
- package/dist/components/dynamic-codeblock.js +1 -17
- package/dist/components/files.js +1 -40
- package/dist/components/github-info.js +1 -75
- package/dist/components/heading.js +1 -38
- package/dist/components/image-zoom.js +1 -32
- package/dist/components/inline-toc.js +1 -28
- package/dist/components/sidebar/base.js +1 -277
- package/dist/components/sidebar/link-item.js +1 -37
- package/dist/components/sidebar/page-tree.js +1 -69
- package/dist/components/sidebar/tabs/dropdown.js +1 -83
- package/dist/components/sidebar/tabs/index.js +1 -46
- package/dist/components/steps.js +1 -16
- package/dist/components/tabs.js +1 -95
- package/dist/components/toc/clerk.js +1 -227
- package/dist/components/toc/default.js +1 -260
- package/dist/components/toc/index.js +1 -45
- package/dist/components/type-table.js +1 -117
- package/dist/components/ui/accordion.js +1 -42
- package/dist/components/ui/button.js +1 -20
- package/dist/components/ui/collapsible.js +1 -21
- package/dist/components/ui/popover.js +1 -20
- package/dist/components/ui/scroll-area.js +1 -34
- package/dist/components/ui/tabs.js +1 -102
- package/dist/contexts/i18n.js +1 -37
- package/dist/contexts/search.js +1 -68
- package/dist/contexts/tree.js +1 -91
- package/dist/i18n.js +1 -38
- package/dist/index.js +1 -0
- package/dist/layouts/docs/index.js +1 -23
- package/dist/layouts/docs/page/index.js +1 -124
- package/dist/layouts/docs/page/slots/breadcrumb.js +1 -44
- package/dist/layouts/docs/page/slots/container.js +1 -22
- package/dist/layouts/docs/page/slots/footer.js +1 -56
- package/dist/layouts/docs/page/slots/toc.js +1 -182
- package/dist/layouts/docs/slots/container.js +1 -36
- package/dist/layouts/docs/slots/header.js +1 -38
- package/dist/layouts/docs/slots/sidebar.js +1 -268
- package/dist/layouts/flux/index.js +1 -146
- package/dist/layouts/flux/page/index.js +1 -104
- package/dist/layouts/flux/page/slots/breadcrumb.js +1 -44
- package/dist/layouts/flux/page/slots/container.js +1 -22
- package/dist/layouts/flux/page/slots/footer.js +1 -56
- package/dist/layouts/flux/page/slots/toc.js +1 -181
- package/dist/layouts/flux/slots/container.js +1 -13
- package/dist/layouts/flux/slots/sidebar.js +1 -243
- package/dist/layouts/flux/slots/tab-dropdown.js +1 -88
- package/dist/layouts/glass/index.js +1 -70
- package/dist/layouts/glass/page/index.js +1 -92
- package/dist/layouts/glass/page/slots/breadcrumb.js +1 -44
- package/dist/layouts/glass/page/slots/footer.js +1 -56
- package/dist/layouts/glass/page/slots/toc.js +1 -108
- package/dist/layouts/glass/slots/header.js +1 -68
- package/dist/layouts/glass/slots/sidebar.js +1 -267
- package/dist/layouts/home/index.js +1 -40
- package/dist/layouts/home/navbar.js +1 -34
- package/dist/layouts/home/not-found.js +1 -41
- package/dist/layouts/home/slots/container.js +1 -13
- package/dist/layouts/home/slots/header.js +1 -239
- package/dist/layouts/notebook/index.js +1 -23
- package/dist/layouts/notebook/page/index.js +1 -124
- package/dist/layouts/notebook/page/slots/breadcrumb.js +1 -44
- package/dist/layouts/notebook/page/slots/container.js +1 -22
- package/dist/layouts/notebook/page/slots/footer.js +1 -56
- package/dist/layouts/notebook/page/slots/toc.js +1 -181
- package/dist/layouts/notebook/slots/container.js +1 -38
- package/dist/layouts/notebook/slots/header.js +1 -204
- package/dist/layouts/notebook/slots/sidebar.js +1 -240
- package/dist/layouts/shared/index.js +1 -98
- package/dist/layouts/shared/slots/language-select.js +1 -43
- package/dist/layouts/shared/slots/search-trigger.js +1 -53
- package/dist/layouts/shared/slots/theme-switch.js +1 -70
- package/dist/mdx.d.ts +2 -44
- package/dist/mdx.js +2 -70
- package/dist/mdx.server.js +2 -20
- package/dist/og/takumi.js +1 -91
- package/dist/og.js +1 -91
- package/dist/page.js +1 -33
- package/dist/primitives/accordion.js +1 -0
- package/dist/primitives/collapsible.js +1 -0
- package/dist/primitives/dialog.js +1 -0
- package/dist/primitives/direction-provider.js +1 -0
- package/dist/primitives/drawer.js +1 -0
- package/dist/primitives/navigation-menu.js +1 -0
- package/dist/primitives/popover.js +1 -0
- package/dist/primitives/scroll-area.js +1 -0
- package/dist/primitives/shared.js +1 -0
- package/dist/primitives/tabs.js +1 -0
- package/dist/provider/astro.js +1 -20
- package/dist/provider/base.js +1 -73
- package/dist/provider/next.js +1 -17
- package/dist/provider/react-router.js +1 -17
- package/dist/provider/tanstack.js +1 -17
- package/dist/provider/waku.js +1 -17
- package/dist/style.css +11577 -310
- package/dist/utils/use-copy-button.js +1 -26
- package/dist/utils/use-footer-items.js +1 -24
- package/dist/utils/use-is-scroll-top.js +1 -20
- package/package.json +28 -66
- package/css/preset-legacy.css +0 -43
- package/dist/.translations/index.d.ts +0 -55
- package/dist/.translations/keys.js +0 -55
- package/dist/_virtual/_rolldown/runtime.js +0 -13
- package/dist/components/accordion.d.ts +0 -10
- package/dist/components/banner.d.ts +0 -25
- package/dist/components/callout.d.ts +0 -21
- package/dist/components/card.d.ts +0 -13
- package/dist/components/codeblock.d.ts +0 -45
- package/dist/components/codeblock.rsc.d.ts +0 -15
- package/dist/components/dialog/search-algolia.d.ts +0 -27
- package/dist/components/dialog/search-default.d.ts +0 -29
- package/dist/components/dialog/search-orama.d.ts +0 -32
- package/dist/components/dialog/search.d.ts +0 -76
- package/dist/components/dynamic-codeblock.core.d.ts +0 -26
- package/dist/components/dynamic-codeblock.d.ts +0 -8
- package/dist/components/files.d.ts +0 -21
- package/dist/components/github-info.d.ts +0 -20
- package/dist/components/heading.d.ts +0 -9
- package/dist/components/image-zoom.d.ts +0 -18
- package/dist/components/inline-toc.d.ts +0 -10
- package/dist/components/sidebar/base.d.ts +0 -85
- package/dist/components/sidebar/link-item.d.ts +0 -12
- package/dist/components/sidebar/page-tree.d.ts +0 -20
- package/dist/components/sidebar/tabs/dropdown.d.ts +0 -15
- package/dist/components/sidebar/tabs/index.d.ts +0 -8
- package/dist/components/steps.d.ts +0 -10
- package/dist/components/tabs.d.ts +0 -33
- package/dist/components/toc/clerk.d.ts +0 -11
- package/dist/components/toc/default.d.ts +0 -13
- package/dist/components/toc/index.d.ts +0 -10
- package/dist/components/type-table.d.ts +0 -37
- package/dist/components/ui/accordion.d.ts +0 -10
- package/dist/components/ui/button.d.ts +0 -10
- package/dist/components/ui/collapsible.d.ts +0 -11
- package/dist/components/ui/navigation-menu.d.ts +0 -14
- package/dist/components/ui/navigation-menu.js +0 -41
- package/dist/components/ui/popover.d.ts +0 -9
- package/dist/components/ui/scroll-area.d.ts +0 -9
- package/dist/components/ui/tabs.d.ts +0 -23
- package/dist/contexts/i18n.d.ts +0 -34
- package/dist/contexts/search.d.ts +0 -64
- package/dist/contexts/tree.d.ts +0 -29
- package/dist/i18n.d.ts +0 -15
- package/dist/layouts/docs/client.d.ts +0 -33
- package/dist/layouts/docs/client.js +0 -94
- package/dist/layouts/docs/index.d.ts +0 -32
- package/dist/layouts/docs/page/index.d.ts +0 -76
- package/dist/layouts/docs/page/slots/breadcrumb.d.ts +0 -7
- package/dist/layouts/docs/page/slots/container.d.ts +0 -5
- package/dist/layouts/docs/page/slots/footer.d.ts +0 -16
- package/dist/layouts/docs/page/slots/toc.d.ts +0 -47
- package/dist/layouts/docs/slots/container.d.ts +0 -5
- package/dist/layouts/docs/slots/header.d.ts +0 -5
- package/dist/layouts/docs/slots/sidebar.d.ts +0 -22
- package/dist/layouts/flux/index.d.ts +0 -61
- package/dist/layouts/flux/page/index.d.ts +0 -67
- package/dist/layouts/flux/page/slots/breadcrumb.d.ts +0 -7
- package/dist/layouts/flux/page/slots/container.d.ts +0 -5
- package/dist/layouts/flux/page/slots/footer.d.ts +0 -16
- package/dist/layouts/flux/page/slots/toc.d.ts +0 -29
- package/dist/layouts/flux/slots/container.d.ts +0 -5
- package/dist/layouts/flux/slots/sidebar.d.ts +0 -16
- package/dist/layouts/flux/slots/tab-dropdown.d.ts +0 -10
- package/dist/layouts/glass/index.d.ts +0 -39
- package/dist/layouts/glass/layout-tabs.js +0 -54
- package/dist/layouts/glass/page/index.d.ts +0 -31
- package/dist/layouts/glass/page/slots/breadcrumb.d.ts +0 -7
- package/dist/layouts/glass/page/slots/footer.d.ts +0 -16
- package/dist/layouts/glass/page/slots/toc.d.ts +0 -19
- package/dist/layouts/glass/slots/header.d.ts +0 -6
- package/dist/layouts/glass/slots/sidebar.d.ts +0 -21
- package/dist/layouts/home/index.d.ts +0 -27
- package/dist/layouts/home/navbar.d.ts +0 -9
- package/dist/layouts/home/not-found.d.ts +0 -7
- package/dist/layouts/home/slots/container.d.ts +0 -5
- package/dist/layouts/home/slots/header.d.ts +0 -8
- package/dist/layouts/notebook/client.d.ts +0 -35
- package/dist/layouts/notebook/client.js +0 -69
- package/dist/layouts/notebook/index.d.ts +0 -26
- package/dist/layouts/notebook/page/index.d.ts +0 -76
- package/dist/layouts/notebook/page/slots/breadcrumb.d.ts +0 -7
- package/dist/layouts/notebook/page/slots/container.d.ts +0 -5
- package/dist/layouts/notebook/page/slots/footer.d.ts +0 -16
- package/dist/layouts/notebook/page/slots/toc.d.ts +0 -47
- package/dist/layouts/notebook/slots/container.d.ts +0 -5
- package/dist/layouts/notebook/slots/header.d.ts +0 -5
- package/dist/layouts/notebook/slots/sidebar.d.ts +0 -23
- package/dist/layouts/shared/client.d.ts +0 -37
- package/dist/layouts/shared/client.js +0 -85
- package/dist/layouts/shared/index.d.ts +0 -169
- package/dist/layouts/shared/page-actions.d.ts +0 -27
- package/dist/layouts/shared/page-actions.js +0 -199
- package/dist/layouts/shared/slots/language-select.d.ts +0 -12
- package/dist/layouts/shared/slots/search-trigger.d.ts +0 -13
- package/dist/layouts/shared/slots/theme-switch.d.ts +0 -8
- package/dist/legacy/layout.d.ts +0 -29
- package/dist/legacy/layout.js +0 -44
- package/dist/legacy/sidebar.d.ts +0 -14
- package/dist/legacy/sidebar.js +0 -34
- package/dist/mdx.server.d.ts +0 -14
- 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 +0 -30
- 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 +0 -461
- 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 +0 -3
- 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 +0 -6
- 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 +0 -17
- 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 +0 -53
- 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 +0 -25
- 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 +0 -12
- 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 +0 -45
- 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 +0 -10
- 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 +0 -57
- 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 +0 -21
- 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 +0 -14
- 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 +0 -22
- 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 +0 -27
- 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 +0 -31
- 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 +0 -75
- 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 +0 -4
- 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 +0 -7
- 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 +0 -5
- package/dist/og/takumi.d.ts +0 -15
- package/dist/og.d.ts +0 -16
- package/dist/page.d.ts +0 -29
- package/dist/provider/astro.d.ts +0 -29
- package/dist/provider/base.d.ts +0 -48
- package/dist/provider/next.d.ts +0 -16
- package/dist/provider/react-router.d.ts +0 -16
- package/dist/provider/tanstack.d.ts +0 -16
- package/dist/provider/waku.d.ts +0 -16
- package/dist/utils/cn.js +0 -2
- package/dist/utils/merge-refs.js +0 -11
- package/dist/utils/urls.js +0 -15
- package/dist/utils/use-copy-button.d.ts +0 -5
- package/dist/utils/use-footer-items.d.ts +0 -8
- package/dist/utils/use-is-scroll-top.d.ts +0 -6
|
@@ -1,277 +1 @@
|
|
|
1
|
-
|
|
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 };
|
|
1
|
+
export * from '@vx-oss/docs-vezham-ui/components/sidebar/base';
|
|
@@ -1,37 +1 @@
|
|
|
1
|
-
|
|
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 };
|
|
1
|
+
export * from '@vx-oss/docs-vezham-ui/components/sidebar/link-item';
|
|
@@ -1,69 +1 @@
|
|
|
1
|
-
|
|
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 };
|
|
1
|
+
export * from '@vx-oss/docs-vezham-ui/components/sidebar/page-tree';
|
|
@@ -1,83 +1 @@
|
|
|
1
|
-
|
|
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 };
|
|
1
|
+
export * from '@vx-oss/docs-vezham-ui/components/sidebar/tabs/dropdown';
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
|
|
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 };
|
|
1
|
+
export * from '@vx-oss/docs-vezham-ui/components/sidebar/tabs';
|
package/dist/components/steps.js
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
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 };
|
|
1
|
+
export * from '@vx-oss/docs-vezham-ui/components/steps';
|
package/dist/components/tabs.js
CHANGED
|
@@ -1,95 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { cn } from "../utils/cn.js";
|
|
3
|
-
import { Tabs as Tabs$1, TabsContent as TabsContent$1, TabsList as TabsList$1, TabsTrigger as TabsTrigger$1 } from "./ui/tabs.js";
|
|
4
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { createContext, useContext, useEffect, useId, useMemo, useState } from "react";
|
|
6
|
-
//#region src/components/tabs.tsx
|
|
7
|
-
const TabsContext = createContext(null);
|
|
8
|
-
function useTabContext() {
|
|
9
|
-
const ctx = useContext(TabsContext);
|
|
10
|
-
if (!ctx) throw new Error("You must wrap your component in <Tabs>");
|
|
11
|
-
return ctx;
|
|
12
|
-
}
|
|
13
|
-
function TabsList(props) {
|
|
14
|
-
return /* @__PURE__ */ jsx(TabsList$1, {
|
|
15
|
-
...props,
|
|
16
|
-
className: cn("flex gap-3.5 text-fd-secondary-foreground overflow-x-auto px-4 not-prose", props.className)
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
function TabsTrigger(props) {
|
|
20
|
-
return /* @__PURE__ */ jsx(TabsTrigger$1, {
|
|
21
|
-
...props,
|
|
22
|
-
className: cn("inline-flex items-center gap-2 whitespace-nowrap text-fd-muted-foreground border-b border-transparent py-2 text-sm font-medium transition-colors [&_svg]:size-4 hover:text-fd-accent-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=active]:border-fd-primary data-[state=active]:text-fd-primary", props.className)
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
function Tabs({ ref, className, items, label, defaultIndex = 0, defaultValue = items ? escapeValue(items[defaultIndex]) : void 0, ...props }) {
|
|
26
|
-
const [value, setValue] = useState(defaultValue);
|
|
27
|
-
const collection = useMemo(() => [], []);
|
|
28
|
-
return /* @__PURE__ */ jsxs(Tabs$1, {
|
|
29
|
-
ref,
|
|
30
|
-
className: cn("flex flex-col overflow-hidden rounded-xl border bg-fd-secondary my-4", className),
|
|
31
|
-
value,
|
|
32
|
-
onValueChange: (v) => {
|
|
33
|
-
if (items && !items.some((item) => escapeValue(item) === v)) return;
|
|
34
|
-
setValue(v);
|
|
35
|
-
},
|
|
36
|
-
...props,
|
|
37
|
-
children: [items && /* @__PURE__ */ jsxs(TabsList, { children: [label && /* @__PURE__ */ jsx("span", {
|
|
38
|
-
className: "text-sm font-medium my-auto me-auto",
|
|
39
|
-
children: label
|
|
40
|
-
}), items.map((item) => /* @__PURE__ */ jsx(TabsTrigger, {
|
|
41
|
-
value: escapeValue(item),
|
|
42
|
-
children: item
|
|
43
|
-
}, item))] }), /* @__PURE__ */ jsx(TabsContext.Provider, {
|
|
44
|
-
value: useMemo(() => ({
|
|
45
|
-
items,
|
|
46
|
-
collection
|
|
47
|
-
}), [collection, items]),
|
|
48
|
-
children: props.children
|
|
49
|
-
})]
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function Tab({ value, ...props }) {
|
|
53
|
-
const { items } = useTabContext();
|
|
54
|
-
const resolved = value ?? items?.at(useCollectionIndex());
|
|
55
|
-
if (!resolved) throw new Error("Failed to resolve tab `value`, please pass a `value` prop to the Tab component.");
|
|
56
|
-
return /* @__PURE__ */ jsx(TabsContent, {
|
|
57
|
-
value: escapeValue(resolved),
|
|
58
|
-
...props,
|
|
59
|
-
children: props.children
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function TabsContent({ value, className, ...props }) {
|
|
63
|
-
return /* @__PURE__ */ jsx(TabsContent$1, {
|
|
64
|
-
value,
|
|
65
|
-
className: cn("p-4 text-[0.9375rem] bg-fd-background rounded-xl outline-none prose-no-margin data-[state=inactive]:hidden [&>figure:only-child]:-m-4 [&>figure:only-child]:border-none", className),
|
|
66
|
-
...props,
|
|
67
|
-
children: props.children
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Inspired by Headless UI.
|
|
72
|
-
*
|
|
73
|
-
* Return the index of children, this is made possible by registering the order of render from children using React context.
|
|
74
|
-
* This is supposed by work with pre-rendering & pure client-side rendering.
|
|
75
|
-
*/
|
|
76
|
-
function useCollectionIndex() {
|
|
77
|
-
const key = useId();
|
|
78
|
-
const { collection } = useTabContext();
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
return () => {
|
|
81
|
-
const idx = collection.indexOf(key);
|
|
82
|
-
if (idx !== -1) collection.splice(idx, 1);
|
|
83
|
-
};
|
|
84
|
-
}, [key, collection]);
|
|
85
|
-
if (!collection.includes(key)) collection.push(key);
|
|
86
|
-
return collection.indexOf(key);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* only escape whitespaces in values in simple mode
|
|
90
|
-
*/
|
|
91
|
-
function escapeValue(v) {
|
|
92
|
-
return v.toLowerCase().replace(/\s/, "-");
|
|
93
|
-
}
|
|
94
|
-
//#endregion
|
|
95
|
-
export { Tab, Tabs, TabsContent, TabsList, TabsTrigger };
|
|
1
|
+
export * from '@vx-oss/docs-vezham-ui/components/tabs';
|