fumadocs-ui 14.2.1 → 14.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/accordion.d.ts +4 -7
- package/dist/components/accordion.d.ts.map +1 -0
- package/dist/components/accordion.js +32 -104
- package/dist/components/api.d.ts +4 -13
- package/dist/components/api.d.ts.map +1 -0
- package/dist/components/api.js +3 -16
- package/dist/components/banner.d.ts +3 -5
- package/dist/components/banner.d.ts.map +1 -0
- package/dist/components/banner.js +53 -120
- package/dist/components/callout.d.ts +4 -7
- package/dist/components/callout.d.ts.map +1 -0
- package/dist/components/callout.js +13 -9
- package/dist/components/card.d.ts +5 -7
- package/dist/components/card.d.ts.map +1 -0
- package/dist/components/card.js +10 -10
- package/dist/components/codeblock.d.ts +6 -9
- package/dist/components/codeblock.d.ts.map +1 -0
- package/dist/components/codeblock.js +41 -15
- package/dist/components/dialog/search-algolia.d.ts +7 -11
- package/dist/components/dialog/search-algolia.d.ts.map +1 -0
- package/dist/components/dialog/search-algolia.js +19 -79
- package/dist/components/dialog/search-default.d.ts +6 -10
- package/dist/components/dialog/search-default.d.ts.map +1 -0
- package/dist/components/dialog/search-default.js +24 -73
- package/dist/components/dialog/search-orama.d.ts +7 -11
- package/dist/components/dialog/search-orama.d.ts.map +1 -0
- package/dist/components/dialog/search-orama.js +22 -79
- package/dist/components/dialog/search.d.ts +7 -9
- package/dist/components/dialog/search.d.ts.map +1 -0
- package/dist/components/dialog/search.js +98 -13
- package/dist/components/dialog/tag-list.d.ts +13 -0
- package/dist/components/dialog/tag-list.d.ts.map +1 -0
- package/dist/components/dialog/tag-list.js +20 -0
- package/dist/components/files.d.ts +7 -9
- package/dist/components/files.d.ts.map +1 -0
- package/dist/components/files.js +15 -63
- package/dist/components/heading.d.ts +4 -5
- package/dist/components/heading.d.ts.map +1 -0
- package/dist/components/heading.js +9 -9
- package/dist/components/image-zoom.d.ts +7 -8
- package/dist/components/image-zoom.d.ts.map +1 -0
- package/dist/components/image-zoom.js +16 -40
- package/dist/components/inline-toc.d.ts +4 -6
- package/dist/components/inline-toc.d.ts.map +1 -0
- package/dist/components/inline-toc.js +8 -46
- package/dist/components/layout/breadcrumb.d.ts +11 -0
- package/dist/components/layout/breadcrumb.d.ts.map +1 -0
- package/dist/components/layout/breadcrumb.js +20 -0
- package/dist/components/layout/language-toggle.d.ts +5 -7
- package/dist/components/layout/language-toggle.d.ts.map +1 -0
- package/dist/components/layout/language-toggle.js +24 -14
- package/dist/components/layout/nav.d.ts +28 -0
- package/dist/components/layout/nav.d.ts.map +1 -0
- package/dist/components/layout/nav.js +29 -0
- package/dist/components/layout/root-toggle.d.ts +5 -7
- package/dist/components/layout/root-toggle.d.ts.map +1 -0
- package/dist/components/layout/root-toggle.js +28 -13
- package/dist/components/layout/search-toggle.d.ts +4 -0
- package/dist/components/layout/search-toggle.d.ts.map +1 -0
- package/dist/components/layout/search-toggle.js +24 -0
- package/dist/components/layout/theme-toggle.d.ts +3 -0
- package/dist/components/layout/theme-toggle.d.ts.map +1 -0
- package/dist/components/layout/theme-toggle.js +21 -0
- package/dist/components/layout/toc-clerk.d.ts +6 -0
- package/dist/components/layout/toc-clerk.d.ts.map +1 -0
- package/dist/components/layout/toc-clerk.js +76 -0
- package/dist/components/layout/toc-popover.d.ts +8 -0
- package/dist/components/layout/toc-popover.d.ts.map +1 -0
- package/dist/components/layout/toc-popover.js +20 -0
- package/dist/components/layout/toc-thumb.d.ts +6 -0
- package/dist/components/layout/toc-thumb.d.ts.map +1 -0
- package/dist/components/layout/toc-thumb.js +53 -0
- package/dist/components/layout/toc.d.ts +19 -0
- package/dist/components/layout/toc.d.ts.map +1 -0
- package/dist/components/layout/toc.js +25 -0
- package/dist/components/registry.d.ts +3 -0
- package/dist/components/registry.d.ts.map +1 -0
- package/dist/components/registry.js +70 -0
- package/dist/components/steps.d.ts +4 -6
- package/dist/components/steps.d.ts.map +1 -0
- package/dist/components/steps.js +5 -16
- package/dist/components/tabs.d.ts +7 -21
- package/dist/components/tabs.d.ts.map +1 -0
- package/dist/components/tabs.js +61 -171
- package/dist/components/type-table.d.ts +5 -6
- package/dist/components/type-table.d.ts.map +1 -0
- package/dist/components/type-table.js +18 -59
- package/dist/components/ui/button.d.ts +5 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +14 -0
- package/dist/components/ui/collapsible.d.ts +6 -0
- package/dist/components/ui/collapsible.d.ts.map +1 -0
- package/dist/components/ui/collapsible.js +12 -0
- package/dist/components/ui/navigation-menu.d.ts +11 -0
- package/dist/components/ui/navigation-menu.d.ts.map +1 -0
- package/dist/components/ui/navigation-menu.js +15 -0
- package/dist/components/ui/popover.d.ts +8 -0
- package/dist/components/ui/popover.d.ts.map +1 -0
- package/dist/components/ui/popover.js +11 -0
- package/dist/components/ui/scroll-area.d.ts +7 -0
- package/dist/components/ui/scroll-area.d.ts.map +1 -0
- package/dist/components/ui/scroll-area.js +11 -0
- package/dist/components/ui/tabs.d.ts +8 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/tabs.js +16 -0
- package/dist/{i18n-Db2HAPOu.d.ts → contexts/i18n.d.ts} +9 -5
- package/dist/contexts/i18n.d.ts.map +1 -0
- package/dist/contexts/i18n.js +23 -0
- package/dist/contexts/search.d.ts +50 -0
- package/dist/contexts/search.d.ts.map +1 -0
- package/dist/contexts/search.js +50 -0
- package/dist/contexts/sidebar.d.ts +18 -0
- package/dist/contexts/sidebar.d.ts.map +1 -0
- package/dist/contexts/sidebar.js +31 -0
- package/dist/contexts/tree.d.ts +13 -0
- package/dist/contexts/tree.d.ts.map +1 -0
- package/dist/contexts/tree.js +25 -0
- package/dist/i18n.d.ts +5 -6
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +31 -49
- package/dist/layouts/docs/navbar.d.ts +4 -0
- package/dist/layouts/docs/navbar.d.ts.map +1 -0
- package/dist/layouts/docs/navbar.js +22 -0
- package/dist/layouts/docs/sidebar.d.ts +40 -0
- package/dist/layouts/docs/sidebar.d.ts.map +1 -0
- package/dist/layouts/docs/sidebar.js +146 -0
- package/dist/layouts/docs.client.d.ts +14 -25
- package/dist/layouts/docs.client.d.ts.map +1 -0
- package/dist/layouts/docs.client.js +53 -195
- package/dist/layouts/docs.d.ts +34 -19
- package/dist/layouts/docs.d.ts.map +1 -0
- package/dist/layouts/docs.js +67 -202
- package/dist/layouts/home/menu.d.ts +6 -0
- package/dist/layouts/home/menu.d.ts.map +1 -0
- package/dist/layouts/home/menu.js +33 -0
- package/dist/layouts/home/navbar.d.ts +16 -0
- package/dist/layouts/home/navbar.d.ts.map +1 -0
- package/dist/layouts/home/navbar.js +48 -0
- package/dist/layouts/home.d.ts +5 -7
- package/dist/layouts/home.d.ts.map +1 -0
- package/dist/layouts/home.js +51 -59
- package/dist/layouts/links.d.ts +80 -0
- package/dist/layouts/links.d.ts.map +1 -0
- package/dist/layouts/links.js +14 -0
- package/dist/layouts/shared.d.ts +48 -2
- package/dist/layouts/shared.d.ts.map +1 -0
- package/dist/layouts/shared.js +27 -9
- package/dist/mdx.client.d.ts +3 -6
- package/dist/mdx.client.d.ts.map +1 -0
- package/dist/mdx.client.js +12 -19
- package/dist/mdx.d.ts +18 -20
- package/dist/mdx.d.ts.map +1 -0
- package/dist/mdx.js +47 -56
- package/dist/og.d.ts +6 -7
- package/dist/og.d.ts.map +1 -0
- package/dist/og.js +43 -102
- package/dist/page.client.d.ts +8 -41
- package/dist/page.client.d.ts.map +1 -0
- package/dist/page.client.js +71 -261
- package/dist/page.d.ts +28 -30
- package/dist/page.d.ts.map +1 -0
- package/dist/page.js +80 -168
- package/dist/provider.d.ts +12 -72
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +19 -55
- package/dist/style.css +1 -1
- package/dist/tailwind-plugin.d.ts +9 -20
- package/dist/tailwind-plugin.d.ts.map +1 -0
- package/dist/tailwind-plugin.js +191 -699
- package/dist/theme/animations.d.ts +170 -0
- package/dist/theme/animations.d.ts.map +1 -0
- package/dist/theme/animations.js +95 -0
- package/dist/theme/colors.d.ts +11 -0
- package/dist/theme/colors.d.ts.map +1 -0
- package/dist/theme/colors.js +327 -0
- package/dist/theme/typography.d.ts +70 -0
- package/dist/theme/typography.d.ts.map +1 -0
- package/dist/theme/typography.js +71 -0
- package/dist/utils/cn.d.ts +2 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/cn.js +1 -0
- package/dist/utils/get-sidebar-tabs.d.ts +7 -0
- package/dist/utils/get-sidebar-tabs.d.ts.map +1 -0
- package/dist/utils/get-sidebar-tabs.js +20 -0
- package/dist/utils/is-active.d.ts +2 -0
- package/dist/utils/is-active.d.ts.map +1 -0
- package/dist/utils/is-active.js +3 -0
- package/dist/utils/use-copy-button.d.ts +3 -0
- package/dist/utils/use-copy-button.d.ts.map +1 -0
- package/dist/utils/use-copy-button.js +25 -0
- package/package.json +9 -9
- package/dist/chunk-27HFSL7N.js +0 -53
- package/dist/chunk-2FLZOPQN.js +0 -54
- package/dist/chunk-2KMKNVSN.js +0 -29
- package/dist/chunk-AFMXKA2S.js +0 -125
- package/dist/chunk-CDPVENXR.js +0 -8
- package/dist/chunk-CLF6ZVYS.js +0 -259
- package/dist/chunk-DGKCMOIC.js +0 -56
- package/dist/chunk-DN6Z5VW6.js +0 -61
- package/dist/chunk-E3VO2QQT.js +0 -29
- package/dist/chunk-EFMHXXHW.js +0 -24
- package/dist/chunk-F534DZID.js +0 -43
- package/dist/chunk-GHOAONNQ.js +0 -48
- package/dist/chunk-IL64LMKR.js +0 -82
- package/dist/chunk-ILBYBJ5C.js +0 -38
- package/dist/chunk-IVBHRX3O.js +0 -31
- package/dist/chunk-J6XGK6ZG.js +0 -212
- package/dist/chunk-KZTWSBYY.js +0 -68
- package/dist/chunk-MCX7E6ZW.js +0 -57
- package/dist/chunk-MLKGABMK.js +0 -9
- package/dist/chunk-QKOA6KEZ.js +0 -22
- package/dist/chunk-TK3TM3MR.js +0 -6
- package/dist/chunk-TQJ6YPJ3.js +0 -31
- package/dist/chunk-UUGCW3UP.js +0 -84
- package/dist/chunk-VPJMNIJX.js +0 -542
- package/dist/chunk-W36BQGMB.js +0 -69
- package/dist/chunk-YL3MZH7N.js +0 -66
- package/dist/chunk-ZBOI25UW.js +0 -139
- package/dist/components/api.client.d.ts +0 -5
- package/dist/components/api.client.js +0 -8
- package/dist/dynamic-sidebar-SYEETGZL.js +0 -129
- package/dist/edit-on-github-FIYOWWPQ.js +0 -49
- package/dist/layouts/home.client.d.ts +0 -11
- package/dist/layouts/home.client.js +0 -274
- package/dist/shared-SScCiV7b.d.ts +0 -152
- package/dist/sidebar-CQ4HmzQl.d.ts +0 -50
- package/dist/tag-list-BsEgfE3x.d.ts +0 -6
- package/dist/toc-clerk-SKE4LBT7.js +0 -158
- package/dist/tree-06ley65N.d.ts +0 -21
package/dist/i18n.js
CHANGED
|
@@ -1,50 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return /* @__PURE__ */ jsx(
|
|
33
|
-
I18nContext.Provider,
|
|
34
|
-
{
|
|
35
|
-
value: {
|
|
36
|
-
locale,
|
|
37
|
-
locales,
|
|
38
|
-
text: {
|
|
39
|
-
...context.text,
|
|
40
|
-
...props.translations
|
|
41
|
-
},
|
|
42
|
-
onChange: props.onChange ?? onChange
|
|
43
|
-
},
|
|
44
|
-
children: props.children
|
|
45
|
-
}
|
|
46
|
-
);
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { useRouter, usePathname } from 'next/navigation';
|
|
5
|
+
import { useI18n, I18nContext, } from './contexts/i18n';
|
|
6
|
+
export function I18nProvider({ locales = [], locale, ...props }) {
|
|
7
|
+
const context = useI18n();
|
|
8
|
+
const router = useRouter();
|
|
9
|
+
const segments = usePathname()
|
|
10
|
+
.split('/')
|
|
11
|
+
.filter((v) => v.length > 0);
|
|
12
|
+
const onChange = useCallback((v) => {
|
|
13
|
+
// If locale prefix hidden
|
|
14
|
+
if (segments[0] !== locale) {
|
|
15
|
+
segments.unshift(v);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
segments[0] = v;
|
|
19
|
+
}
|
|
20
|
+
router.push(`/${segments.join('/')}`);
|
|
21
|
+
router.refresh();
|
|
22
|
+
}, [locale, segments, router]);
|
|
23
|
+
return (_jsx(I18nContext.Provider, { value: {
|
|
24
|
+
locale,
|
|
25
|
+
locales,
|
|
26
|
+
text: {
|
|
27
|
+
...context.text,
|
|
28
|
+
...props.translations,
|
|
29
|
+
},
|
|
30
|
+
onChange: props.onChange ?? onChange,
|
|
31
|
+
}, children: props.children }));
|
|
47
32
|
}
|
|
48
|
-
export {
|
|
49
|
-
I18nProvider
|
|
50
|
-
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type HTMLAttributes } from 'react';
|
|
2
|
+
export declare function Navbar(props: HTMLAttributes<HTMLElement>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function NavbarSidebarTrigger(): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
//# sourceMappingURL=navbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navbar.d.ts","sourceRoot":"","sources":["../../../src/layouts/docs/navbar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,OAAO,CAAC;AAOxD,wBAAgB,MAAM,CAAC,KAAK,EAAE,cAAc,CAAC,WAAW,CAAC,2CAiBxD;AAED,wBAAgB,oBAAoB,4CAgBnC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useSidebar } from '../../contexts/sidebar';
|
|
4
|
+
import { useContext } from 'react';
|
|
5
|
+
import { NavContext } from '../../components/layout/nav';
|
|
6
|
+
import { cn } from '../../utils/cn';
|
|
7
|
+
import { SidebarTrigger } from 'fumadocs-core/sidebar';
|
|
8
|
+
import { buttonVariants } from '../../components/ui/button';
|
|
9
|
+
import { Menu, X } from 'lucide-react';
|
|
10
|
+
export function Navbar(props) {
|
|
11
|
+
const { open } = useSidebar();
|
|
12
|
+
const { isTransparent } = useContext(NavContext);
|
|
13
|
+
return (_jsx("header", { id: "nd-subnav", ...props, className: cn('sticky top-[var(--fd-banner-height)] z-40 flex flex-row items-center border-b border-fd-foreground/10 px-4 transition-colors', (!isTransparent || open) && 'bg-fd-background/80 backdrop-blur-lg', props.className), children: props.children }));
|
|
14
|
+
}
|
|
15
|
+
export function NavbarSidebarTrigger() {
|
|
16
|
+
const { open } = useSidebar();
|
|
17
|
+
return (_jsx(SidebarTrigger, { className: cn(buttonVariants({
|
|
18
|
+
color: 'ghost',
|
|
19
|
+
size: 'icon',
|
|
20
|
+
className: '-me-2 md:hidden',
|
|
21
|
+
})), children: open ? _jsx(X, {}) : _jsx(Menu, {}) }));
|
|
22
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { type LinkProps } from 'fumadocs-core/link';
|
|
3
|
+
import { type ScrollAreaProps } from '@radix-ui/react-scroll-area';
|
|
4
|
+
import type { CollapsibleContentProps, CollapsibleTriggerProps } from '@radix-ui/react-collapsible';
|
|
5
|
+
export interface SidebarProps extends HTMLAttributes<HTMLElement> {
|
|
6
|
+
/**
|
|
7
|
+
* Open folders by default if their level is lower or equal to a specific level
|
|
8
|
+
* (Starting from 1)
|
|
9
|
+
*
|
|
10
|
+
* @defaultValue 0
|
|
11
|
+
*/
|
|
12
|
+
defaultOpenLevel?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Prefetch links
|
|
15
|
+
*
|
|
16
|
+
* @defaultValue true
|
|
17
|
+
*/
|
|
18
|
+
prefetch?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function CollapsibleSidebar(props: SidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function Sidebar({ defaultOpenLevel, prefetch, inner, ...props }: SidebarProps & {
|
|
22
|
+
inner?: HTMLAttributes<HTMLDivElement>;
|
|
23
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare function SidebarHeader(props: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare function SidebarFooter(props: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare function SidebarViewport(props: ScrollAreaProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare function SidebarSeparator(props: HTMLAttributes<HTMLParagraphElement>): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare function SidebarItem({ icon, ...props }: LinkProps & {
|
|
29
|
+
icon?: ReactNode;
|
|
30
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare function SidebarFolder({ level, defaultOpen, ...props }: {
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
defaultOpen?: boolean;
|
|
34
|
+
level: number;
|
|
35
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
export declare function SidebarFolderTrigger(props: CollapsibleTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export declare function SidebarFolderLink(props: LinkProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export declare function SidebarFolderContent(props: CollapsibleContentProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare function SidebarCollapseTrigger(props: ButtonHTMLAttributes<HTMLButtonElement>): import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
//# sourceMappingURL=sidebar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../../src/layouts/docs/sidebar.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,oBAAoB,EAEzB,KAAK,cAAc,EAEnB,KAAK,SAAS,EAOf,MAAM,OAAO,CAAC;AACf,OAAa,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAU1D,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAInE,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,6BAA6B,CAAC;AAErC,MAAM,WAAW,YAAa,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC/D;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA6BD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,YAAY,2CA4DrD;AAED,wBAAgB,OAAO,CAAC,EACtB,gBAAoB,EACpB,QAAe,EACf,KAAK,EACL,GAAG,KAAK,EACT,EAAE,YAAY,GAAG;IAAE,KAAK,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAA;CAAE,2CAuC3D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,2CAYlE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,2CAYlE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,2CAYrD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,CAAC,oBAAoB,CAAC,2CAY3E;AAED,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,SAAS,GAAG;IACb,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB,2CAiBA;AAED,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,WAAW,EACX,GAAG,KAAK,EACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf,2CAkBA;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,uBAAuB,2CAelE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,2CA0CjD;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,uBAAuB,2CAQlE;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,oBAAoB,CAAC,iBAAiB,CAAC,2CAuB/C"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ChevronDown, ExternalLink, SidebarIcon } from 'lucide-react';
|
|
4
|
+
import * as Base from 'fumadocs-core/sidebar';
|
|
5
|
+
import { usePathname } from 'next/navigation';
|
|
6
|
+
import { createContext, useCallback, useContext, useLayoutEffect, useMemo, useRef, useState, } from 'react';
|
|
7
|
+
import Link from 'fumadocs-core/link';
|
|
8
|
+
import { useOnChange } from 'fumadocs-core/utils/use-on-change';
|
|
9
|
+
import { cn } from '../../utils/cn';
|
|
10
|
+
import { ScrollArea, ScrollViewport } from '../../components/ui/scroll-area';
|
|
11
|
+
import { isActive } from '../../utils/is-active';
|
|
12
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from '../../components/ui/collapsible';
|
|
13
|
+
import { useSidebar } from '../../contexts/sidebar';
|
|
14
|
+
import { buttonVariants } from '../../components/ui/button';
|
|
15
|
+
import { cva } from 'class-variance-authority';
|
|
16
|
+
const itemVariants = cva('flex flex-row items-center gap-2 rounded-md px-3 py-2 text-fd-muted-foreground transition-colors duration-100 [overflow-wrap:anywhere] md:px-2 md:py-1.5 [&_svg]:size-4', {
|
|
17
|
+
variants: {
|
|
18
|
+
active: {
|
|
19
|
+
true: 'bg-fd-primary/10 font-medium text-fd-primary',
|
|
20
|
+
false: 'hover:bg-fd-accent/50 hover:text-fd-accent-foreground/80 hover:transition-none',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
const Context = createContext(undefined);
|
|
25
|
+
const FolderContext = createContext(undefined);
|
|
26
|
+
export function CollapsibleSidebar(props) {
|
|
27
|
+
const { collapsed } = useSidebar();
|
|
28
|
+
const [hover, setHover] = useState(false);
|
|
29
|
+
const timerRef = useRef(0);
|
|
30
|
+
const closeTimeRef = useRef(0);
|
|
31
|
+
useOnChange(collapsed, () => {
|
|
32
|
+
setHover(false);
|
|
33
|
+
closeTimeRef.current = Date.now() + 150;
|
|
34
|
+
});
|
|
35
|
+
const onEnter = useCallback((e) => {
|
|
36
|
+
if (e.pointerType === 'touch' || closeTimeRef.current > Date.now())
|
|
37
|
+
return;
|
|
38
|
+
window.clearTimeout(timerRef.current);
|
|
39
|
+
setHover(true);
|
|
40
|
+
}, []);
|
|
41
|
+
const onLeave = useCallback((e) => {
|
|
42
|
+
if (e.pointerType === 'touch')
|
|
43
|
+
return;
|
|
44
|
+
window.clearTimeout(timerRef.current);
|
|
45
|
+
timerRef.current = window.setTimeout(() => {
|
|
46
|
+
setHover(false);
|
|
47
|
+
closeTimeRef.current = Date.now() + 150;
|
|
48
|
+
}, Math.min(e.clientX, document.body.clientWidth - e.clientX) > 100
|
|
49
|
+
? 0
|
|
50
|
+
: 500);
|
|
51
|
+
}, []);
|
|
52
|
+
return (_jsxs(_Fragment, { children: [_jsx(SidebarCollapseTrigger, { className: cn('fixed bottom-3 start-2 z-20 transition-opacity max-md:hidden', (!collapsed || hover) && 'opacity-0') }), _jsx(Sidebar, { ...props, onPointerEnter: onEnter, onPointerLeave: onLeave, className: cn('transition-[flex,margin,opacity,transform]', collapsed &&
|
|
53
|
+
'md:-me-[var(--fd-sidebar-offset)] md:flex-initial md:translate-x-[calc(var(--fd-sidebar-offset)*-1)] rtl:md:translate-x-[var(--fd-sidebar-offset)]', collapsed && hover && 'md:translate-x-0', collapsed && !hover && 'md:z-10 md:opacity-0', props.className), style: {
|
|
54
|
+
'--fd-sidebar-offset': 'calc(var(--fd-sidebar-width) - 30px)',
|
|
55
|
+
} })] }));
|
|
56
|
+
}
|
|
57
|
+
export function Sidebar({ defaultOpenLevel = 0, prefetch = true, inner, ...props }) {
|
|
58
|
+
const context = useMemo(() => {
|
|
59
|
+
return {
|
|
60
|
+
defaultOpenLevel,
|
|
61
|
+
prefetch,
|
|
62
|
+
};
|
|
63
|
+
}, [defaultOpenLevel, prefetch]);
|
|
64
|
+
return (_jsx(Context.Provider, { value: context, children: _jsx(Base.SidebarList, { id: "nd-sidebar", blockScrollingWidth: 768, ...props, className: cn('fixed top-fd-layout-top z-30 bg-fd-card text-sm md:sticky md:h-[var(--fd-sidebar-height)] md:flex-1', 'max-md:inset-x-0 max-md:bottom-0 max-md:bg-fd-background/80 max-md:text-[15px] max-md:backdrop-blur-lg max-md:data-[open=false]:invisible', props.className), style: {
|
|
65
|
+
...props.style,
|
|
66
|
+
'--fd-sidebar-height': 'calc(100dvh - var(--fd-banner-height) - var(--fd-nav-height))',
|
|
67
|
+
}, children: _jsx("div", { ...inner, className: cn('flex size-full flex-col pt-2 md:ms-auto md:w-[var(--fd-sidebar-width)] md:border-e md:pt-4', inner?.className), children: props.children }) }) }));
|
|
68
|
+
}
|
|
69
|
+
export function SidebarHeader(props) {
|
|
70
|
+
return (_jsx("div", { ...props, className: cn('flex flex-col gap-2 px-4 empty:hidden md:px-3', props.className), children: props.children }));
|
|
71
|
+
}
|
|
72
|
+
export function SidebarFooter(props) {
|
|
73
|
+
return (_jsx("div", { ...props, className: cn('flex flex-col border-t px-4 py-3 empty:hidden', props.className), children: props.children }));
|
|
74
|
+
}
|
|
75
|
+
export function SidebarViewport(props) {
|
|
76
|
+
return (_jsx(ScrollArea, { ...props, className: cn('h-full', props.className), children: _jsx(ScrollViewport, { style: {
|
|
77
|
+
maskImage: 'linear-gradient(to bottom, transparent 2px, white 16px)',
|
|
78
|
+
}, children: props.children }) }));
|
|
79
|
+
}
|
|
80
|
+
export function SidebarSeparator(props) {
|
|
81
|
+
return (_jsx("p", { ...props, className: cn('mb-2 mt-8 px-3 text-sm font-medium first:mt-0 md:px-2', props.className), children: props.children }));
|
|
82
|
+
}
|
|
83
|
+
export function SidebarItem({ icon, ...props }) {
|
|
84
|
+
const pathname = usePathname();
|
|
85
|
+
const active = props.href !== undefined && isActive(props.href, pathname, false);
|
|
86
|
+
const { prefetch } = useInternalContext();
|
|
87
|
+
return (_jsxs(Link, { ...props, "data-active": active, className: cn(itemVariants({ active })), prefetch: prefetch, children: [icon ?? (props.external ? _jsx(ExternalLink, {}) : null), props.children] }));
|
|
88
|
+
}
|
|
89
|
+
export function SidebarFolder({ level, defaultOpen, ...props }) {
|
|
90
|
+
const { defaultOpenLevel } = useInternalContext();
|
|
91
|
+
const shouldExtend = defaultOpen ?? defaultOpenLevel >= level;
|
|
92
|
+
const [open, setOpen] = useState(shouldExtend);
|
|
93
|
+
useOnChange(shouldExtend, (v) => {
|
|
94
|
+
if (v)
|
|
95
|
+
setOpen(v);
|
|
96
|
+
});
|
|
97
|
+
return (_jsx(Collapsible, { open: open, onOpenChange: setOpen, children: _jsx(FolderContext.Provider, { value: useMemo(() => ({ open, setOpen }), [open]), children: props.children }) }));
|
|
98
|
+
}
|
|
99
|
+
export function SidebarFolderTrigger(props) {
|
|
100
|
+
const { open } = useFolderContext();
|
|
101
|
+
return (_jsxs(CollapsibleTrigger, { ...props, className: cn(itemVariants({ active: false }), 'w-full pe-3.5 md:pe-1.5'), children: [props.children, _jsx(ChevronDown, { "data-icon": true, className: cn('ms-auto transition-transform', !open && '-rotate-90') })] }));
|
|
102
|
+
}
|
|
103
|
+
export function SidebarFolderLink(props) {
|
|
104
|
+
const { open, setOpen } = useFolderContext();
|
|
105
|
+
const { prefetch } = useInternalContext();
|
|
106
|
+
const pathname = usePathname();
|
|
107
|
+
const active = props.href !== undefined && isActive(props.href, pathname, false);
|
|
108
|
+
useLayoutEffect(() => {
|
|
109
|
+
if (active) {
|
|
110
|
+
setOpen(true);
|
|
111
|
+
}
|
|
112
|
+
}, [active, setOpen]);
|
|
113
|
+
return (_jsxs(Link, { ...props, "data-active": active, className: cn(itemVariants({ active }), 'w-full pe-3.5 md:pe-1.5', props.className), onClick: (e) => {
|
|
114
|
+
if (
|
|
115
|
+
// clicking on icon
|
|
116
|
+
e.target.hasAttribute('data-icon') ||
|
|
117
|
+
active) {
|
|
118
|
+
setOpen((prev) => !prev);
|
|
119
|
+
e.preventDefault();
|
|
120
|
+
}
|
|
121
|
+
}, prefetch: prefetch, children: [props.children, _jsx(ChevronDown, { "data-icon": true, className: cn('ms-auto transition-transform', !open && '-rotate-90') })] }));
|
|
122
|
+
}
|
|
123
|
+
export function SidebarFolderContent(props) {
|
|
124
|
+
return (_jsx(CollapsibleContent, { ...props, children: _jsx("div", { className: "ms-3 border-s py-1.5 ps-1.5 md:ms-2 md:ps-2", children: props.children }) }));
|
|
125
|
+
}
|
|
126
|
+
export function SidebarCollapseTrigger(props) {
|
|
127
|
+
const { setCollapsed } = useSidebar();
|
|
128
|
+
return (_jsx("button", { type: "button", "aria-label": "Collapse Sidebar", ...props, className: cn(buttonVariants({
|
|
129
|
+
color: 'ghost',
|
|
130
|
+
size: 'icon',
|
|
131
|
+
}), props.className), onClick: () => {
|
|
132
|
+
setCollapsed((prev) => !prev);
|
|
133
|
+
}, children: _jsx(SidebarIcon, {}) }));
|
|
134
|
+
}
|
|
135
|
+
function useFolderContext() {
|
|
136
|
+
const ctx = useContext(FolderContext);
|
|
137
|
+
if (!ctx)
|
|
138
|
+
throw new Error('Missing sidebar folder');
|
|
139
|
+
return ctx;
|
|
140
|
+
}
|
|
141
|
+
function useInternalContext() {
|
|
142
|
+
const ctx = useContext(Context);
|
|
143
|
+
if (!ctx)
|
|
144
|
+
throw new Error('<Sidebar /> component required.');
|
|
145
|
+
return ctx;
|
|
146
|
+
}
|
|
@@ -1,27 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { T as TreeContextProvider } from '../tree-06ley65N.js';
|
|
7
|
-
export { LanguageToggle, LanguageToggleText } from '../components/layout/language-toggle.js';
|
|
8
|
-
import 'react/jsx-runtime';
|
|
9
|
-
import 'fumadocs-core/server';
|
|
10
|
-
|
|
11
|
-
interface MenuItemProps extends React.HTMLAttributes<HTMLElement> {
|
|
12
|
-
item: LinkItemType;
|
|
1
|
+
import { type ButtonHTMLAttributes, type HTMLAttributes } from 'react';
|
|
2
|
+
import { type LinkItemType } from '../layouts/links';
|
|
3
|
+
import type { SidebarComponents } from '../layouts/docs';
|
|
4
|
+
interface LinksMenuProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
5
|
+
items: LinkItemType[];
|
|
13
6
|
}
|
|
14
|
-
declare function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
declare function SubNav({ title, url, enableSearch, ...props }: Omit<SharedNavProps, 'transparentMode'> & {
|
|
19
|
-
className?: string;
|
|
20
|
-
}): React.ReactElement;
|
|
21
|
-
declare function SidebarCollapseTrigger(props: ButtonHTMLAttributes<HTMLButtonElement>): React.ReactElement;
|
|
22
|
-
interface LinksMenuProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
23
|
-
items?: ReactNode;
|
|
7
|
+
export declare function LinksMenu({ items, ...props }: LinksMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
interface MenuItemProps extends HTMLAttributes<HTMLElement> {
|
|
9
|
+
item: LinkItemType;
|
|
24
10
|
}
|
|
25
|
-
declare function
|
|
26
|
-
|
|
27
|
-
|
|
11
|
+
export declare function MenuItem({ item, ...props }: MenuItemProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function SidebarItems(props: {
|
|
13
|
+
components?: Partial<SidebarComponents>;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=docs.client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.client.d.ts","sourceRoot":"","sources":["../../src/layouts/docs.client.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,cAAc,EAGpB,MAAM,OAAO,CAAC;AASf,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQlE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAgBxD,UAAU,cAAe,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IACtE,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,2CAgB5D;AAED,UAAU,aAAc,SAAQ,cAAc,CAAC,WAAW,CAAC;IACzD,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,aAAa,2CAgDzD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,UAAU,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACzC,2CAQA"}
|
|
@@ -1,200 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
} from
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
import {
|
|
24
|
-
Collapsible,
|
|
25
|
-
CollapsibleContent,
|
|
26
|
-
CollapsibleTrigger
|
|
27
|
-
} from "../chunk-TQJ6YPJ3.js";
|
|
28
|
-
import {
|
|
29
|
-
buttonVariants
|
|
30
|
-
} from "../chunk-QKOA6KEZ.js";
|
|
31
|
-
import {
|
|
32
|
-
NavContext,
|
|
33
|
-
NavProvider,
|
|
34
|
-
Title
|
|
35
|
-
} from "../chunk-MCX7E6ZW.js";
|
|
36
|
-
import {
|
|
37
|
-
Popover,
|
|
38
|
-
PopoverContent,
|
|
39
|
-
PopoverTrigger
|
|
40
|
-
} from "../chunk-IVBHRX3O.js";
|
|
41
|
-
import "../chunk-2FLZOPQN.js";
|
|
42
|
-
import {
|
|
43
|
-
ChevronDown,
|
|
44
|
-
Menu,
|
|
45
|
-
PanelLeft,
|
|
46
|
-
X
|
|
47
|
-
} from "../chunk-VPJMNIJX.js";
|
|
48
|
-
import {
|
|
49
|
-
twMerge
|
|
50
|
-
} from "../chunk-TK3TM3MR.js";
|
|
51
|
-
import {
|
|
52
|
-
useSearchContext
|
|
53
|
-
} from "../chunk-UUGCW3UP.js";
|
|
54
|
-
import {
|
|
55
|
-
TreeContextProvider
|
|
56
|
-
} from "../chunk-YL3MZH7N.js";
|
|
57
|
-
import {
|
|
58
|
-
useSidebar
|
|
59
|
-
} from "../chunk-27HFSL7N.js";
|
|
60
|
-
import "../chunk-EFMHXXHW.js";
|
|
61
|
-
import "../chunk-MLKGABMK.js";
|
|
62
|
-
|
|
63
|
-
// src/layouts/docs.client.tsx
|
|
64
|
-
import { SidebarTrigger } from "fumadocs-core/sidebar";
|
|
65
|
-
import {
|
|
66
|
-
useContext,
|
|
67
|
-
useState
|
|
68
|
-
} from "react";
|
|
69
|
-
import { usePathname } from "next/navigation";
|
|
70
|
-
import { useOnChange } from "fumadocs-core/utils/use-on-change";
|
|
71
|
-
|
|
72
|
-
// src/layouts/menu-item.tsx
|
|
73
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
74
|
-
function MenuItem({ item, ...props }) {
|
|
75
|
-
if (item.type === "custom")
|
|
76
|
-
return /* @__PURE__ */ jsx("div", { ...props, className: twMerge("grid", props.className), children: item.children });
|
|
77
|
-
if (item.type === "menu") {
|
|
78
|
-
return /* @__PURE__ */ jsxs(Collapsible, { className: "flex flex-col", children: [
|
|
79
|
-
/* @__PURE__ */ jsxs(
|
|
80
|
-
CollapsibleTrigger,
|
|
81
|
-
{
|
|
82
|
-
...props,
|
|
83
|
-
"data-active": false,
|
|
84
|
-
className: twMerge(itemVariants(), "group/link", props.className),
|
|
85
|
-
children: [
|
|
86
|
-
item.icon,
|
|
87
|
-
item.text,
|
|
88
|
-
/* @__PURE__ */ jsx(ChevronDown, { className: "ms-auto transition-transform group-data-[state=closed]/link:-rotate-90" })
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
),
|
|
92
|
-
/* @__PURE__ */ jsx(CollapsibleContent, { children: /* @__PURE__ */ jsx("div", { className: "ms-2 flex flex-col border-s py-2 ps-2", children: item.items.map((child, i) => /* @__PURE__ */ jsx(MenuItem, { item: child }, i)) }) })
|
|
93
|
-
] });
|
|
94
|
-
}
|
|
95
|
-
if (item.type === "button") {
|
|
96
|
-
return /* @__PURE__ */ jsx(ButtonItem, { item, ...props });
|
|
97
|
-
}
|
|
98
|
-
return /* @__PURE__ */ jsxs(
|
|
99
|
-
BaseLinkItem,
|
|
100
|
-
{
|
|
101
|
-
item,
|
|
102
|
-
...props,
|
|
103
|
-
className: twMerge(itemVariants(), props.className),
|
|
104
|
-
children: [
|
|
105
|
-
item.icon,
|
|
106
|
-
item.text
|
|
107
|
-
]
|
|
108
|
-
}
|
|
109
|
-
);
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ChevronDown } from 'lucide-react';
|
|
4
|
+
import { useState, } from 'react';
|
|
5
|
+
import { usePathname } from 'next/navigation';
|
|
6
|
+
import { useOnChange } from 'fumadocs-core/utils/use-on-change';
|
|
7
|
+
import { cn } from '../utils/cn';
|
|
8
|
+
import { Popover, PopoverContent, PopoverTrigger, } from '../components/ui/popover';
|
|
9
|
+
import { BaseLinkItem } from '../layouts/links';
|
|
10
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from '../components/ui/collapsible';
|
|
11
|
+
import { cva } from 'class-variance-authority';
|
|
12
|
+
import { SidebarFolder, SidebarFolderContent, SidebarFolderLink, SidebarFolderTrigger, SidebarItem, SidebarSeparator, } from '../layouts/docs/sidebar';
|
|
13
|
+
import { useTreeContext, useTreePath } from '../contexts/tree';
|
|
14
|
+
import { buttonVariants } from '../components/ui/button';
|
|
15
|
+
const itemVariants = cva('flex flex-row items-center gap-2 rounded-md px-3 py-2.5 text-fd-muted-foreground transition-colors duration-100 [overflow-wrap:anywhere] hover:bg-fd-accent/50 hover:text-fd-accent-foreground/80 hover:transition-none md:px-2 md:py-1.5 [&_svg]:size-4');
|
|
16
|
+
export function LinksMenu({ items, ...props }) {
|
|
17
|
+
const [open, setOpen] = useState(false);
|
|
18
|
+
const pathname = usePathname();
|
|
19
|
+
useOnChange(pathname, () => {
|
|
20
|
+
setOpen(false);
|
|
21
|
+
});
|
|
22
|
+
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { ...props }), _jsx(PopoverContent, { className: "flex flex-col p-1", children: items?.map((item, i) => _jsx(MenuItem, { item: item }, i)) })] }));
|
|
110
23
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
url,
|
|
117
|
-
enableSearch = true,
|
|
118
|
-
...props
|
|
119
|
-
}) {
|
|
120
|
-
const { open } = useSidebar();
|
|
121
|
-
const { isTransparent } = useContext(NavContext);
|
|
122
|
-
const search = useSearchContext();
|
|
123
|
-
return /* @__PURE__ */ jsxs2(
|
|
124
|
-
"header",
|
|
125
|
-
{
|
|
126
|
-
id: "nd-subnav",
|
|
127
|
-
...props,
|
|
128
|
-
className: twMerge(
|
|
129
|
-
"sticky top-[var(--fd-banner-height)] z-40 flex flex-row items-center border-b border-fd-foreground/10 px-4 transition-colors",
|
|
130
|
-
(!isTransparent || open) && "bg-fd-background/80 backdrop-blur-lg",
|
|
131
|
-
props.className
|
|
132
|
-
),
|
|
133
|
-
children: [
|
|
134
|
-
/* @__PURE__ */ jsx2(Title, { url, title }),
|
|
135
|
-
/* @__PURE__ */ jsx2("div", { className: "flex flex-1 flex-row items-center gap-1", children: props.children }),
|
|
136
|
-
search.enabled && enableSearch ? /* @__PURE__ */ jsx2(SearchToggle, {}) : null,
|
|
137
|
-
/* @__PURE__ */ jsx2(
|
|
138
|
-
SidebarTrigger,
|
|
139
|
-
{
|
|
140
|
-
className: twMerge(
|
|
141
|
-
buttonVariants({
|
|
142
|
-
color: "ghost",
|
|
143
|
-
size: "icon",
|
|
144
|
-
className: "-me-2 md:hidden"
|
|
145
|
-
})
|
|
146
|
-
),
|
|
147
|
-
children: open ? /* @__PURE__ */ jsx2(X, {}) : /* @__PURE__ */ jsx2(Menu, {})
|
|
148
|
-
}
|
|
149
|
-
)
|
|
150
|
-
]
|
|
24
|
+
export function MenuItem({ item, ...props }) {
|
|
25
|
+
if (item.type === 'custom')
|
|
26
|
+
return (_jsx("div", { ...props, className: cn('grid', props.className), children: item.children }));
|
|
27
|
+
if (item.type === 'menu') {
|
|
28
|
+
return (_jsxs(Collapsible, { className: "flex flex-col", children: [_jsxs(CollapsibleTrigger, { ...props, className: cn(itemVariants(), 'group/link', props.className), children: [item.icon, item.text, _jsx(ChevronDown, { className: "ms-auto transition-transform group-data-[state=closed]/link:-rotate-90" })] }), _jsx(CollapsibleContent, { children: _jsx("div", { className: "flex flex-col py-2 ps-2", children: item.items.map((child, i) => (_jsx(MenuItem, { item: child }, i))) }) })] }));
|
|
151
29
|
}
|
|
152
|
-
|
|
30
|
+
return (_jsxs(BaseLinkItem, { item: item, ...props, className: cn(item.type === 'button'
|
|
31
|
+
? buttonVariants({
|
|
32
|
+
color: 'secondary',
|
|
33
|
+
className: 'gap-1.5 [&_svg]:size-4',
|
|
34
|
+
})
|
|
35
|
+
: itemVariants(), props.className), children: [item.icon, item.text] }));
|
|
153
36
|
}
|
|
154
|
-
function
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
"button",
|
|
158
|
-
{
|
|
159
|
-
type: "button",
|
|
160
|
-
"aria-label": "Collapse Sidebar",
|
|
161
|
-
...props,
|
|
162
|
-
className: twMerge(
|
|
163
|
-
buttonVariants({
|
|
164
|
-
color: "ghost",
|
|
165
|
-
size: "icon"
|
|
166
|
-
}),
|
|
167
|
-
props.className
|
|
168
|
-
),
|
|
169
|
-
onClick: () => {
|
|
170
|
-
setCollapsed((prev) => !prev);
|
|
171
|
-
},
|
|
172
|
-
children: /* @__PURE__ */ jsx2(PanelLeft, {})
|
|
173
|
-
}
|
|
174
|
-
);
|
|
37
|
+
export function SidebarItems(props) {
|
|
38
|
+
const { root } = useTreeContext();
|
|
39
|
+
return (_jsx("div", { className: "px-2 py-4 md:px-3", children: renderSidebarList(root.children, 1, props?.components ?? {}) }));
|
|
175
40
|
}
|
|
176
|
-
function
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
41
|
+
function PageTreeFolder({ item, children, level, }) {
|
|
42
|
+
const path = useTreePath();
|
|
43
|
+
return (_jsx(SidebarFolder, { defaultOpen: item.defaultOpen || path.includes(item), level: level + 1, children: children }));
|
|
44
|
+
}
|
|
45
|
+
function renderSidebarList(items, level, customComps) {
|
|
46
|
+
const { Separator, Item, Folder } = customComps;
|
|
47
|
+
return items.map((item, i) => {
|
|
48
|
+
const id = `${item.type}_${i.toString()}`;
|
|
49
|
+
switch (item.type) {
|
|
50
|
+
case 'separator':
|
|
51
|
+
return Separator ? (_jsx(Separator, { item: item }, id)) : (_jsx(SidebarSeparator, { children: item.name }, id));
|
|
52
|
+
case 'folder':
|
|
53
|
+
return Folder ? (_jsx(Folder, { item: item, level: level + 1 }, id)) : (_jsxs(PageTreeFolder, { item: item, level: level + 1, children: [item.index ? (_jsxs(SidebarFolderLink, { href: item.index.url, external: item.index.external, children: [item.icon, item.name] })) : (_jsxs(SidebarFolderTrigger, { children: [item.icon, item.name] })), _jsx(SidebarFolderContent, { children: renderSidebarList(item.children, level + 1, customComps) })] }, id));
|
|
54
|
+
default:
|
|
55
|
+
return Item ? (_jsx(Item, { item: item }, item.url)) : (_jsx(SidebarItem, { href: item.url, external: item.external, icon: item.icon, children: item.name }, item.url));
|
|
56
|
+
}
|
|
57
|
+
});
|
|
186
58
|
}
|
|
187
|
-
export {
|
|
188
|
-
IconItem,
|
|
189
|
-
LanguageToggle,
|
|
190
|
-
LanguageToggleText,
|
|
191
|
-
LinksMenu,
|
|
192
|
-
MenuItem,
|
|
193
|
-
NavProvider,
|
|
194
|
-
RootToggle,
|
|
195
|
-
Sidebar,
|
|
196
|
-
SidebarCollapseTrigger,
|
|
197
|
-
SubNav,
|
|
198
|
-
ThemeToggle,
|
|
199
|
-
TreeContextProvider
|
|
200
|
-
};
|