fumadocs-ui 16.1.0 → 16.2.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/css/black.css +1 -1
- package/css/catppuccin.css +1 -1
- package/css/colors/index.css +51 -0
- package/css/dusk.css +1 -1
- package/css/layouts/docs.css +1 -0
- package/css/layouts/home.css +1 -0
- package/css/layouts/notebook.css +1 -0
- package/css/neutral.css +1 -40
- package/css/ocean.css +1 -1
- package/css/preset.css +21 -28
- package/css/purple.css +1 -1
- package/css/shadcn.css +0 -2
- package/css/shiki.css +1 -3
- package/css/solar.css +49 -18
- package/css/vitepress.css +1 -1
- package/dist/components/image-zoom.d.ts +3 -3
- package/dist/components/image-zoom.d.ts.map +1 -1
- package/dist/components/image-zoom.js +1 -1
- package/dist/components/sidebar/base.d.ts +62 -0
- package/dist/components/sidebar/base.d.ts.map +1 -0
- package/dist/components/sidebar/base.js +174 -0
- package/dist/components/sidebar/link-item.d.ts +11 -0
- package/dist/components/sidebar/link-item.d.ts.map +1 -0
- package/dist/components/sidebar/link-item.js +13 -0
- package/dist/components/sidebar/page-tree.d.ts +19 -0
- package/dist/components/sidebar/page-tree.d.ts.map +1 -0
- package/dist/components/sidebar/page-tree.js +34 -0
- package/dist/components/{layout/root-toggle.d.ts → sidebar/tabs.d.ts} +4 -4
- package/dist/components/sidebar/tabs.d.ts.map +1 -0
- package/dist/components/{layout/root-toggle.js → sidebar/tabs.js} +3 -3
- package/dist/components/tabs.unstyled.d.ts +0 -3
- package/dist/components/tabs.unstyled.d.ts.map +1 -1
- package/dist/components/tabs.unstyled.js +23 -32
- package/dist/components/toc/clerk.d.ts +3 -0
- package/dist/components/toc/clerk.d.ts.map +1 -0
- package/dist/components/{layout/toc-clerk.js → toc/clerk.js} +5 -6
- package/dist/components/toc/default.d.ts +3 -0
- package/dist/components/toc/default.d.ts.map +1 -0
- package/dist/components/{layout/toc.js → toc/default.js} +5 -16
- package/dist/components/{layout/toc.d.ts → toc/index.d.ts} +7 -3
- package/dist/components/toc/index.d.ts.map +1 -0
- package/dist/components/{layout/toc-thumb.js → toc/index.js} +17 -3
- package/dist/contexts/search.js +1 -1
- package/dist/contexts/tree.d.ts +1 -1
- package/dist/contexts/tree.d.ts.map +1 -1
- package/dist/contexts/tree.js +3 -3
- package/dist/layouts/docs/client.d.ts +12 -5
- package/dist/layouts/docs/client.d.ts.map +1 -1
- package/dist/layouts/docs/client.js +31 -22
- package/dist/layouts/docs/index.d.ts +9 -9
- package/dist/layouts/docs/index.d.ts.map +1 -1
- package/dist/layouts/docs/index.js +37 -48
- package/dist/layouts/docs/{page-client.d.ts → page/client.d.ts} +3 -4
- package/dist/layouts/docs/page/client.d.ts.map +1 -0
- package/dist/layouts/docs/{page-client.js → page/client.js} +39 -76
- package/dist/layouts/docs/page/index.d.ts +58 -0
- package/dist/layouts/docs/page/index.d.ts.map +1 -0
- package/dist/layouts/docs/page/index.js +51 -0
- package/dist/layouts/docs/sidebar.d.ts +17 -0
- package/dist/layouts/docs/sidebar.d.ts.map +1 -0
- package/dist/layouts/docs/sidebar.js +82 -0
- package/dist/layouts/home/client.d.ts +2 -20
- package/dist/layouts/home/client.d.ts.map +1 -1
- package/dist/layouts/home/client.js +54 -17
- package/dist/layouts/home/index.d.ts +2 -3
- package/dist/layouts/home/index.d.ts.map +1 -1
- package/dist/layouts/home/index.js +3 -35
- package/dist/layouts/notebook/client.d.ts +20 -8
- package/dist/layouts/notebook/client.d.ts.map +1 -1
- package/dist/layouts/notebook/client.js +59 -33
- package/dist/layouts/notebook/index.d.ts +9 -9
- package/dist/layouts/notebook/index.d.ts.map +1 -1
- package/dist/layouts/notebook/index.js +47 -70
- package/dist/layouts/notebook/page/client.d.ts +24 -0
- package/dist/layouts/notebook/page/client.d.ts.map +1 -0
- package/dist/layouts/notebook/page/client.js +119 -0
- package/dist/layouts/notebook/page/index.d.ts +58 -0
- package/dist/layouts/notebook/page/index.d.ts.map +1 -0
- package/dist/layouts/notebook/page/index.js +51 -0
- package/dist/layouts/notebook/sidebar.d.ts +17 -0
- package/dist/layouts/notebook/sidebar.d.ts.map +1 -0
- package/dist/layouts/notebook/sidebar.js +87 -0
- package/dist/layouts/shared/index.d.ts +12 -78
- package/dist/layouts/shared/index.d.ts.map +1 -1
- package/dist/layouts/shared/index.js +11 -15
- package/dist/layouts/shared/language-toggle.d.ts +5 -0
- package/dist/layouts/shared/language-toggle.d.ts.map +1 -0
- package/dist/layouts/shared/link-item.d.ts +78 -0
- package/dist/layouts/shared/link-item.d.ts.map +1 -0
- package/dist/layouts/shared/{client.js → link-item.js} +1 -1
- package/dist/layouts/shared/search-toggle.d.ts.map +1 -0
- package/dist/{components/layout → layouts/shared}/theme-toggle.d.ts +2 -2
- package/dist/layouts/shared/theme-toggle.d.ts.map +1 -0
- package/dist/{components/layout → layouts/shared}/theme-toggle.js +3 -3
- package/dist/page.d.ts +6 -59
- package/dist/page.d.ts.map +1 -1
- package/dist/page.js +16 -50
- package/dist/provider/base.d.ts.map +1 -1
- package/dist/provider/base.js +2 -3
- package/dist/style.css +187 -160
- package/dist/utils/use-footer-items.d.ts +6 -0
- package/dist/utils/use-footer-items.d.ts.map +1 -0
- package/dist/utils/use-footer-items.js +27 -0
- package/dist/utils/use-is-scroll-top.d.ts +4 -0
- package/dist/utils/use-is-scroll-top.d.ts.map +1 -0
- package/dist/utils/use-is-scroll-top.js +17 -0
- package/package.json +11 -24
- package/css/default.css +0 -34
- package/dist/components/layout/language-toggle.d.ts +0 -5
- package/dist/components/layout/language-toggle.d.ts.map +0 -1
- package/dist/components/layout/root-toggle.d.ts.map +0 -1
- package/dist/components/layout/search-toggle.d.ts.map +0 -1
- package/dist/components/layout/sidebar.d.ts +0 -66
- package/dist/components/layout/sidebar.d.ts.map +0 -1
- package/dist/components/layout/sidebar.js +0 -200
- package/dist/components/layout/theme-toggle.d.ts.map +0 -1
- package/dist/components/layout/toc-clerk.d.ts +0 -3
- package/dist/components/layout/toc-clerk.d.ts.map +0 -1
- package/dist/components/layout/toc-thumb.d.ts +0 -7
- package/dist/components/layout/toc-thumb.d.ts.map +0 -1
- package/dist/components/layout/toc.d.ts.map +0 -1
- package/dist/contexts/layout.d.ts +0 -28
- package/dist/contexts/layout.d.ts.map +0 -1
- package/dist/contexts/layout.js +0 -38
- package/dist/contexts/sidebar.d.ts +0 -18
- package/dist/contexts/sidebar.d.ts.map +0 -1
- package/dist/contexts/sidebar.js +0 -31
- package/dist/layouts/docs/page-client.d.ts.map +0 -1
- package/dist/layouts/docs/page.d.ts +0 -17
- package/dist/layouts/docs/page.d.ts.map +0 -1
- package/dist/layouts/docs/page.js +0 -26
- package/dist/layouts/shared/client.d.ts +0 -6
- package/dist/layouts/shared/client.d.ts.map +0 -1
- package/dist/provider/index.d.ts +0 -11
- package/dist/provider/index.d.ts.map +0 -1
- package/dist/provider/index.js +0 -12
- /package/dist/{components/layout → layouts/shared}/language-toggle.js +0 -0
- /package/dist/{components/layout → layouts/shared}/search-toggle.d.ts +0 -0
- /package/dist/{components/layout → layouts/shared}/search-toggle.js +0 -0
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { Fragment, useState } from 'react';
|
|
3
|
+
import { Fragment, useMemo, useState } from 'react';
|
|
4
4
|
import { cva } from 'class-variance-authority';
|
|
5
5
|
import Link from 'fumadocs-core/link';
|
|
6
6
|
import { cn } from '../../utils/cn.js';
|
|
7
|
-
import {
|
|
7
|
+
import { resolveLinkItems, } from '../../layouts/shared/index.js';
|
|
8
|
+
import { LinkItem } from '../../layouts/shared/link-item.js';
|
|
8
9
|
import { NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, } from '../../components/ui/navigation-menu.js';
|
|
9
|
-
import { useNav } from '../../contexts/layout.js';
|
|
10
10
|
import { buttonVariants } from '../../components/ui/button.js';
|
|
11
|
+
import { LargeSearchToggle, SearchToggle, } from '../../layouts/shared/search-toggle.js';
|
|
12
|
+
import { ThemeToggle } from '../../layouts/shared/theme-toggle.js';
|
|
13
|
+
import { LanguageToggle, LanguageToggleText, } from '../../layouts/shared/language-toggle.js';
|
|
14
|
+
import { ChevronDown, Languages } from '../../icons.js';
|
|
15
|
+
import { useIsScrollTop } from '../../utils/use-is-scroll-top.js';
|
|
11
16
|
export const navItemVariants = cva('[&_svg]:size-4', {
|
|
12
17
|
variants: {
|
|
13
18
|
variant: {
|
|
@@ -26,13 +31,51 @@ export const navItemVariants = cva('[&_svg]:size-4', {
|
|
|
26
31
|
variant: 'main',
|
|
27
32
|
},
|
|
28
33
|
});
|
|
29
|
-
export function
|
|
34
|
+
export function Header({ nav = {}, i18n = false, links, githubUrl, themeSwitch = {}, searchToggle = {}, }) {
|
|
35
|
+
const { navItems, menuItems } = useMemo(() => {
|
|
36
|
+
const navItems = [];
|
|
37
|
+
const menuItems = [];
|
|
38
|
+
for (const item of resolveLinkItems({ links, githubUrl })) {
|
|
39
|
+
switch (item.on ?? 'all') {
|
|
40
|
+
case 'menu':
|
|
41
|
+
menuItems.push(item);
|
|
42
|
+
break;
|
|
43
|
+
case 'nav':
|
|
44
|
+
navItems.push(item);
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
navItems.push(item);
|
|
48
|
+
menuItems.push(item);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return { navItems, menuItems };
|
|
52
|
+
}, [links, githubUrl]);
|
|
53
|
+
return (_jsxs(HeaderNavigationMenu, { transparentMode: nav.transparentMode, children: [_jsx(Link, { href: nav.url ?? '/', className: "inline-flex items-center gap-2.5 font-semibold", children: nav.title }), nav.children, _jsx("ul", { className: "flex flex-row items-center gap-2 px-6 max-sm:hidden", children: navItems
|
|
54
|
+
.filter((item) => !isSecondary(item))
|
|
55
|
+
.map((item, i) => (_jsx(NavigationMenuLinkItem, { item: item, className: "text-sm" }, i))) }), _jsxs("div", { className: "flex flex-row items-center justify-end gap-1.5 flex-1 max-lg:hidden", children: [searchToggle.enabled !== false &&
|
|
56
|
+
(searchToggle.components?.lg ?? (_jsx(LargeSearchToggle, { className: "w-full rounded-full ps-2.5 max-w-[240px]", hideIfDisabled: true }))), themeSwitch.enabled !== false &&
|
|
57
|
+
(themeSwitch.component ?? _jsx(ThemeToggle, { mode: themeSwitch?.mode })), i18n && (_jsx(LanguageToggle, { children: _jsx(Languages, { className: "size-5" }) })), _jsx("ul", { className: "flex flex-row gap-2 items-center empty:hidden", children: navItems.filter(isSecondary).map((item, i) => (_jsx(NavigationMenuLinkItem, { className: cn(item.type === 'icon' && '-mx-1 first:ms-0 last:me-0'), item: item }, i))) })] }), _jsxs("ul", { className: "flex flex-row items-center ms-auto -me-1.5 lg:hidden", children: [searchToggle.enabled !== false &&
|
|
58
|
+
(searchToggle.components?.sm ?? (_jsx(SearchToggle, { className: "p-2", hideIfDisabled: true }))), _jsxs(NavigationMenuItem, { children: [_jsx(NavigationMenuTrigger, { "aria-label": "Toggle Menu", className: cn(buttonVariants({
|
|
59
|
+
size: 'icon',
|
|
60
|
+
color: 'ghost',
|
|
61
|
+
className: 'group [&_svg]:size-5.5',
|
|
62
|
+
})), onPointerMove: nav.enableHoverToOpen ? undefined : (e) => e.preventDefault(), children: _jsx(ChevronDown, { className: "transition-transform duration-300 group-data-[state=open]:rotate-180" }) }), _jsxs(NavigationMenuContent, { className: "flex flex-col p-4 sm:flex-row sm:items-center sm:justify-end", children: [menuItems
|
|
63
|
+
.filter((item) => !isSecondary(item))
|
|
64
|
+
.map((item, i) => (_jsx(MobileNavigationMenuLinkItem, { item: item, className: "sm:hidden" }, i))), _jsxs("div", { className: "-ms-1.5 flex flex-row items-center gap-2 max-sm:mt-2", children: [menuItems.filter(isSecondary).map((item, i) => (_jsx(MobileNavigationMenuLinkItem, { item: item, className: cn(item.type === 'icon' && '-mx-1 first:ms-0') }, i))), _jsx("div", { role: "separator", className: "flex-1" }), i18n && (_jsxs(LanguageToggle, { children: [_jsx(Languages, { className: "size-5" }), _jsx(LanguageToggleText, {}), _jsx(ChevronDown, { className: "size-3 text-fd-muted-foreground" })] })), themeSwitch.enabled !== false &&
|
|
65
|
+
(themeSwitch.component ?? (_jsx(ThemeToggle, { mode: themeSwitch?.mode })))] })] })] })] })] }));
|
|
66
|
+
}
|
|
67
|
+
function isSecondary(item) {
|
|
68
|
+
if ('secondary' in item && item.secondary != null)
|
|
69
|
+
return item.secondary;
|
|
70
|
+
return item.type === 'icon';
|
|
71
|
+
}
|
|
72
|
+
function HeaderNavigationMenu({ transparentMode = 'none', ...props }) {
|
|
30
73
|
const [value, setValue] = useState('');
|
|
31
|
-
const {
|
|
32
|
-
|
|
74
|
+
const isTop = useIsScrollTop({ enabled: transparentMode === 'top' }) ?? true;
|
|
75
|
+
const isTransparent = transparentMode === 'top' ? isTop : transparentMode === 'always';
|
|
76
|
+
return (_jsx(NavigationMenu, { value: value, onValueChange: setValue, asChild: true, children: _jsx("header", { id: "nd-nav", ...props, className: cn('sticky h-14 top-0 z-40', props.className), children: _jsxs("div", { className: cn('backdrop-blur-lg border-b transition-colors *:mx-auto *:max-w-(--fd-layout-width)', value.length > 0 && 'max-lg:shadow-lg max-lg:rounded-b-2xl', (!isTransparent || value.length > 0) && 'bg-fd-background/80'), children: [_jsx(NavigationMenuList, { className: "flex h-14 w-full items-center px-4", asChild: true, children: _jsx("nav", { children: props.children }) }), _jsx(NavigationMenuViewport, {})] }) }) }));
|
|
33
77
|
}
|
|
34
|
-
|
|
35
|
-
export function NavigationMenuLinkItem({ item, ...props }) {
|
|
78
|
+
function NavigationMenuLinkItem({ item, ...props }) {
|
|
36
79
|
if (item.type === 'custom')
|
|
37
80
|
return _jsx("div", { ...props, children: item.children });
|
|
38
81
|
if (item.type === 'menu') {
|
|
@@ -45,16 +88,16 @@ export function NavigationMenuLinkItem({ item, ...props }) {
|
|
|
45
88
|
});
|
|
46
89
|
return (_jsxs(NavigationMenuItem, { ...props, children: [_jsx(NavigationMenuTrigger, { className: cn(navItemVariants(), 'rounded-md'), children: item.url ? (_jsx(Link, { href: item.url, external: item.external, children: item.text })) : (item.text) }), _jsx(NavigationMenuContent, { className: "grid grid-cols-1 gap-2 p-4 md:grid-cols-2 lg:grid-cols-3", children: children })] }));
|
|
47
90
|
}
|
|
48
|
-
return (_jsx(NavigationMenuItem, { ...props, children: _jsx(NavigationMenuLink, { asChild: true, children: _jsx(
|
|
91
|
+
return (_jsx(NavigationMenuItem, { ...props, children: _jsx(NavigationMenuLink, { asChild: true, children: _jsx(LinkItem, { item: item, "aria-label": item.type === 'icon' ? item.label : undefined, className: cn(navItemVariants({ variant: item.type })), children: item.type === 'icon' ? item.icon : item.text }) }) }));
|
|
49
92
|
}
|
|
50
|
-
|
|
93
|
+
function MobileNavigationMenuLinkItem({ item, ...props }) {
|
|
51
94
|
if (item.type === 'custom')
|
|
52
95
|
return _jsx("div", { className: cn('grid', props.className), children: item.children });
|
|
53
96
|
if (item.type === 'menu') {
|
|
54
97
|
const header = (_jsxs(_Fragment, { children: [item.icon, item.text] }));
|
|
55
98
|
return (_jsxs("div", { className: cn('mb-4 flex flex-col', props.className), children: [_jsx("p", { className: "mb-1 text-sm text-fd-muted-foreground", children: item.url ? (_jsx(NavigationMenuLink, { asChild: true, children: _jsx(Link, { href: item.url, external: item.external, children: header }) })) : (header) }), item.items.map((child, i) => (_jsx(MobileNavigationMenuLinkItem, { item: child }, i)))] }));
|
|
56
99
|
}
|
|
57
|
-
return (_jsx(NavigationMenuLink, { asChild: true, children: _jsxs(
|
|
100
|
+
return (_jsx(NavigationMenuLink, { asChild: true, children: _jsxs(LinkItem, { item: item, className: cn({
|
|
58
101
|
main: 'inline-flex items-center gap-2 py-1.5 transition-colors hover:text-fd-popover-foreground/50 data-[active=true]:font-medium data-[active=true]:text-fd-primary [&_svg]:size-4',
|
|
59
102
|
icon: buttonVariants({
|
|
60
103
|
size: 'icon',
|
|
@@ -66,9 +109,3 @@ export function MobileNavigationMenuLinkItem({ item, ...props }) {
|
|
|
66
109
|
}),
|
|
67
110
|
}[item.type ?? 'main'], props.className), "aria-label": item.type === 'icon' ? item.label : undefined, children: [item.icon, item.type === 'icon' ? undefined : item.text] }) }));
|
|
68
111
|
}
|
|
69
|
-
export function MobileNavigationMenuTrigger({ enableHover = false, ...props }) {
|
|
70
|
-
return (_jsx(NavigationMenuTrigger, { ...props, onPointerMove: enableHover ? undefined : (e) => e.preventDefault(), children: props.children }));
|
|
71
|
-
}
|
|
72
|
-
export function MobileNavigationMenuContent(props) {
|
|
73
|
-
return (_jsx(NavigationMenuContent, { ...props, className: cn('flex flex-col p-4', props.className), children: props.children }));
|
|
74
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
2
|
import { type BaseLayoutProps, type NavOptions } from '../../layouts/shared/index.js';
|
|
3
3
|
export interface HomeLayoutProps extends BaseLayoutProps {
|
|
4
4
|
nav?: Partial<NavOptions & {
|
|
@@ -8,6 +8,5 @@ export interface HomeLayoutProps extends BaseLayoutProps {
|
|
|
8
8
|
enableHoverToOpen?: boolean;
|
|
9
9
|
}>;
|
|
10
10
|
}
|
|
11
|
-
export declare function HomeLayout(props: HomeLayoutProps &
|
|
12
|
-
export declare function Header({ nav, i18n, links, githubUrl, themeSwitch, searchToggle, }: HomeLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function HomeLayout(props: HomeLayoutProps & ComponentProps<'main'>): import("react/jsx-runtime").JSX.Element;
|
|
13
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/layouts/home/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/layouts/home/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGzE,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,GAAG,CAAC,EAAE,OAAO,CACX,UAAU,GAAG;QACX;;WAEG;QACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;KAC7B,CACF,CAAC;CACH;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,cAAc,CAAC,MAAM,CAAC,2CAkCzE"}
|
|
@@ -1,40 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from 'react';
|
|
3
2
|
import { cn } from '../../utils/cn.js';
|
|
4
|
-
import {
|
|
5
|
-
import { NavProvider } from '../../contexts/layout.js';
|
|
6
|
-
import { LargeSearchToggle, SearchToggle, } from '../../components/layout/search-toggle.js';
|
|
7
|
-
import { ThemeToggle } from '../../components/layout/theme-toggle.js';
|
|
8
|
-
import { LanguageToggle, LanguageToggleText, } from '../../components/layout/language-toggle.js';
|
|
9
|
-
import { ChevronDown, Languages } from '../../icons.js';
|
|
10
|
-
import Link from 'fumadocs-core/link';
|
|
11
|
-
import { Navbar, NavigationMenuLinkItem, MobileNavigationMenuContent, MobileNavigationMenuLinkItem, MobileNavigationMenuTrigger, NavigationMenuItem, } from '../../layouts/home/client.js';
|
|
12
|
-
import { buttonVariants } from '../../components/ui/button.js';
|
|
3
|
+
import { Header } from '../../layouts/home/client.js';
|
|
13
4
|
export function HomeLayout(props) {
|
|
14
5
|
const { nav = {}, links, githubUrl, i18n, themeSwitch = {}, searchToggle, ...rest } = props;
|
|
15
|
-
return (
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
export function Header({ nav = {}, i18n = false, links, githubUrl, themeSwitch = {}, searchToggle = {}, }) {
|
|
19
|
-
const finalLinks = useMemo(() => getLinks(links, githubUrl), [links, githubUrl]);
|
|
20
|
-
const navItems = finalLinks.filter((item) => ['nav', 'all'].includes(item.on ?? 'all'));
|
|
21
|
-
const menuItems = finalLinks.filter((item) => ['menu', 'all'].includes(item.on ?? 'all'));
|
|
22
|
-
return (_jsxs(Navbar, { children: [_jsx(Link, { href: nav.url ?? '/', className: "inline-flex items-center gap-2.5 font-semibold", children: nav.title }), nav.children, _jsx("ul", { className: "flex flex-row items-center gap-2 px-6 max-sm:hidden", children: navItems
|
|
23
|
-
.filter((item) => !isSecondary(item))
|
|
24
|
-
.map((item, i) => (_jsx(NavigationMenuLinkItem, { item: item, className: "text-sm" }, i))) }), _jsxs("div", { className: "flex flex-row items-center justify-end gap-1.5 flex-1 max-lg:hidden", children: [searchToggle.enabled !== false &&
|
|
25
|
-
(searchToggle.components?.lg ?? (_jsx(LargeSearchToggle, { className: "w-full rounded-full ps-2.5 max-w-[240px]", hideIfDisabled: true }))), themeSwitch.enabled !== false &&
|
|
26
|
-
(themeSwitch.component ?? _jsx(ThemeToggle, { mode: themeSwitch?.mode })), i18n && (_jsx(LanguageToggle, { children: _jsx(Languages, { className: "size-5" }) })), _jsx("ul", { className: "flex flex-row gap-2 items-center empty:hidden", children: navItems.filter(isSecondary).map((item, i) => (_jsx(NavigationMenuLinkItem, { className: cn(item.type === 'icon' && '-mx-1 first:ms-0 last:me-0'), item: item }, i))) })] }), _jsxs("ul", { className: "flex flex-row items-center ms-auto -me-1.5 lg:hidden", children: [searchToggle.enabled !== false &&
|
|
27
|
-
(searchToggle.components?.sm ?? (_jsx(SearchToggle, { className: "p-2", hideIfDisabled: true }))), _jsxs(NavigationMenuItem, { children: [_jsx(MobileNavigationMenuTrigger, { "aria-label": "Toggle Menu", className: cn(buttonVariants({
|
|
28
|
-
size: 'icon',
|
|
29
|
-
color: 'ghost',
|
|
30
|
-
className: 'group [&_svg]:size-5.5',
|
|
31
|
-
})), enableHover: nav.enableHoverToOpen, children: _jsx(ChevronDown, { className: "transition-transform duration-300 group-data-[state=open]:rotate-180" }) }), _jsxs(MobileNavigationMenuContent, { className: "sm:flex-row sm:items-center sm:justify-end", children: [menuItems
|
|
32
|
-
.filter((item) => !isSecondary(item))
|
|
33
|
-
.map((item, i) => (_jsx(MobileNavigationMenuLinkItem, { item: item, className: "sm:hidden" }, i))), _jsxs("div", { className: "-ms-1.5 flex flex-row items-center gap-2 max-sm:mt-2", children: [menuItems.filter(isSecondary).map((item, i) => (_jsx(MobileNavigationMenuLinkItem, { item: item, className: cn(item.type === 'icon' && '-mx-1 first:ms-0') }, i))), _jsx("div", { role: "separator", className: "flex-1" }), i18n && (_jsxs(LanguageToggle, { children: [_jsx(Languages, { className: "size-5" }), _jsx(LanguageToggleText, {}), _jsx(ChevronDown, { className: "size-3 text-fd-muted-foreground" })] })), themeSwitch.enabled !== false &&
|
|
34
|
-
(themeSwitch.component ?? (_jsx(ThemeToggle, { mode: themeSwitch?.mode })))] })] })] })] })] }));
|
|
35
|
-
}
|
|
36
|
-
function isSecondary(item) {
|
|
37
|
-
if ('secondary' in item && item.secondary != null)
|
|
38
|
-
return item.secondary;
|
|
39
|
-
return item.type === 'icon';
|
|
6
|
+
return (_jsxs("main", { id: "nd-home-layout", ...rest, className: cn('flex flex-1 flex-col [--fd-layout-width:1400px]', rest.className), children: [nav.enabled !== false &&
|
|
7
|
+
(nav.component ?? (_jsx(Header, { links: links, nav: nav, themeSwitch: themeSwitch, searchToggle: searchToggle, i18n: i18n, githubUrl: githubUrl }))), props.children] }));
|
|
40
8
|
}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
import { type ComponentProps } from 'react';
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { type ComponentProps, type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { type LinkItemType } from '../shared/link-item.js';
|
|
3
|
+
import type { SidebarTabWithProps } from '../../components/sidebar/tabs.js';
|
|
4
|
+
export declare const LayoutContext: import("react").Context<(LayoutInfo & {
|
|
5
|
+
isNavTransparent: boolean;
|
|
6
|
+
}) | null>;
|
|
7
|
+
export interface LayoutInfo {
|
|
8
|
+
tabMode: 'sidebar' | 'navbar';
|
|
9
|
+
navMode: 'top' | 'auto';
|
|
10
|
+
}
|
|
11
|
+
export declare function LayoutContextProvider({ navTransparentMode, navMode, tabMode, children, }: LayoutInfo & {
|
|
12
|
+
navTransparentMode?: 'always' | 'top' | 'none';
|
|
13
|
+
children: ReactNode;
|
|
5
14
|
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
options:
|
|
15
|
+
export declare function LayoutHeader(props: ComponentProps<'header'>): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function LayoutBody({ className, style, children, ...props }: ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function LayoutHeaderTabs({ options, className, ...props }: ComponentProps<'div'> & {
|
|
18
|
+
options: SidebarTabWithProps[];
|
|
10
19
|
}): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function NavbarLinkItem({ item, className, ...props }: {
|
|
21
|
+
item: LinkItemType;
|
|
22
|
+
} & HTMLAttributes<HTMLElement>): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
11
23
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/layouts/notebook/client.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/layouts/notebook/client.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EAGnB,KAAK,cAAc,EACnB,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AAOf,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMlE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,eAAO,MAAM,aAAa;sBAEF,OAAO;UAGxB,CAAC;AAER,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC9B,OAAO,EAAE,KAAK,GAAG,MAAM,CAAC;CACzB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,kBAA2B,EAC3B,OAAO,EACP,OAAO,EACP,QAAQ,GACT,EAAE,UAAU,GAAG;IACd,kBAAkB,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;IAC/C,QAAQ,EAAE,SAAS,CAAC;CACrB,2CAoBA;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,CAAC,QAAQ,CAAC,2CAS3D;AAED,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,KAAK,EACL,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,KAAK,CAAC,2CAuCvB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG;IACzB,OAAO,EAAE,mBAAmB,EAAE,CAAC;CAChC,2CAmCA;AAED,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,SAAS,EACT,GAAG,KAAK,EACT,EAAE;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GAAG,cAAc,CAAC,WAAW,CAAC,2UAqDtD"}
|
|
@@ -1,45 +1,71 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { cn } from '../../utils/cn.js';
|
|
4
|
-
import { useMemo } from 'react';
|
|
5
|
-
import { useSidebar } from '../../
|
|
6
|
-
import {
|
|
7
|
-
import { buttonVariants } from '../../components/ui/button.js';
|
|
8
|
-
import { Sidebar as SidebarIcon } from '../../icons.js';
|
|
4
|
+
import { createContext, Fragment, use, useMemo, } from 'react';
|
|
5
|
+
import { useSidebar } from '../../components/sidebar/base.js';
|
|
6
|
+
import { ChevronDown } from '../../icons.js';
|
|
9
7
|
import Link from 'fumadocs-core/link';
|
|
10
8
|
import { usePathname } from 'fumadocs-core/framework';
|
|
11
9
|
import { isTabActive } from '../../utils/is-active.js';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
import { useIsScrollTop } from '../../utils/use-is-scroll-top.js';
|
|
11
|
+
import { LinkItem } from '../shared/link-item.js';
|
|
12
|
+
import { Popover, PopoverContent, PopoverTrigger, } from '../../components/ui/popover.js';
|
|
13
|
+
export const LayoutContext = createContext(null);
|
|
14
|
+
export function LayoutContextProvider({ navTransparentMode = 'none', navMode, tabMode, children, }) {
|
|
15
|
+
const isTop = useIsScrollTop({ enabled: navTransparentMode === 'top' }) ?? true;
|
|
16
|
+
const isNavTransparent = navTransparentMode === 'top' ? isTop : navTransparentMode === 'always';
|
|
17
|
+
return (_jsx(LayoutContext, { value: useMemo(() => ({
|
|
18
|
+
isNavTransparent,
|
|
19
|
+
navMode,
|
|
20
|
+
tabMode,
|
|
21
|
+
}), [isNavTransparent, navMode, tabMode]), children: children }));
|
|
18
22
|
}
|
|
19
|
-
export function
|
|
20
|
-
const {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
paddingInlineStart: collapsed
|
|
24
|
-
? 'min(calc(100vw - var(--fd-page-width)), var(--fd-sidebar-width))'
|
|
25
|
-
: 'var(--fd-sidebar-width)',
|
|
26
|
-
}, children: props.children }));
|
|
23
|
+
export function LayoutHeader(props) {
|
|
24
|
+
const { open } = useSidebar();
|
|
25
|
+
const { isNavTransparent } = use(LayoutContext);
|
|
26
|
+
return (_jsx("header", { "data-transparent": isNavTransparent && !open, ...props, children: props.children }));
|
|
27
27
|
}
|
|
28
|
-
export function
|
|
29
|
-
const {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
export function LayoutBody({ className, style, children, ...props }) {
|
|
29
|
+
const { navMode } = use(LayoutContext);
|
|
30
|
+
const { collapsed } = useSidebar();
|
|
31
|
+
const pageCol = 'calc(var(--fd-layout-width,97rem) - var(--fd-sidebar-col) - var(--fd-toc-width))';
|
|
32
|
+
return (_jsx("div", { id: "nd-notebook-layout", className: cn('grid overflow-x-clip min-h-(--fd-docs-height) [--fd-docs-height:100dvh] [--fd-header-height:0px] [--fd-toc-popover-height:0px] [--fd-sidebar-width:0px] [--fd-toc-width:0px]', className), style: {
|
|
33
|
+
gridTemplate: navMode === 'top'
|
|
34
|
+
? `". header header header ."
|
|
35
|
+
"sidebar sidebar toc-popover toc-popover ."
|
|
36
|
+
"sidebar sidebar main toc toc" 1fr / minmax(min-content, 1fr) var(--fd-sidebar-col) minmax(0, ${pageCol}) var(--fd-toc-width) minmax(min-content, 1fr)`
|
|
37
|
+
: `"sidebar sidebar header header ."
|
|
38
|
+
"sidebar sidebar toc-popover toc-popover ."
|
|
39
|
+
"sidebar sidebar main toc ." 1fr / minmax(min-content, 1fr) var(--fd-sidebar-col) minmax(0, ${pageCol}) var(--fd-toc-width) minmax(min-content, 1fr)`,
|
|
40
|
+
'--fd-docs-row-1': 'var(--fd-banner-height, 0px)',
|
|
41
|
+
'--fd-docs-row-2': 'calc(var(--fd-docs-row-1) + var(--fd-header-height))',
|
|
42
|
+
'--fd-docs-row-3': 'calc(var(--fd-docs-row-2) + var(--fd-toc-popover-height))',
|
|
43
|
+
'--fd-sidebar-col': collapsed ? '0px' : 'var(--fd-sidebar-width)',
|
|
44
|
+
gridAutoColumns: 'auto',
|
|
45
|
+
gridAutoRows: 'auto',
|
|
46
|
+
...style,
|
|
47
|
+
}, ...props, children: children }));
|
|
35
48
|
}
|
|
36
|
-
export function
|
|
49
|
+
export function LayoutHeaderTabs({ options, className, ...props }) {
|
|
37
50
|
const pathname = usePathname();
|
|
38
|
-
const
|
|
39
|
-
return options.
|
|
51
|
+
const selectedIdx = useMemo(() => {
|
|
52
|
+
return options.findLastIndex((option) => isTabActive(option, pathname));
|
|
40
53
|
}, [options, pathname]);
|
|
41
|
-
return (_jsx("div", {
|
|
54
|
+
return (_jsx("div", { className: cn('flex flex-row items-end gap-6', className), ...props, children: options.map((option, i) => {
|
|
55
|
+
const { title, url, unlisted, props: { className, ...rest } = {}, } = option;
|
|
56
|
+
const isSelected = selectedIdx === i;
|
|
57
|
+
return (_jsx(Link, { href: url, className: cn('inline-flex border-b-2 border-transparent transition-colors items-center pb-1.5 font-medium gap-2 text-fd-muted-foreground text-sm text-nowrap hover:text-fd-accent-foreground', unlisted && !isSelected && 'hidden', isSelected && 'border-fd-primary text-fd-primary', className), ...rest, children: title }, i));
|
|
58
|
+
}) }));
|
|
42
59
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
60
|
+
export function NavbarLinkItem({ item, className, ...props }) {
|
|
61
|
+
if (item.type === 'custom')
|
|
62
|
+
return item.children;
|
|
63
|
+
if (item.type === 'menu') {
|
|
64
|
+
return (_jsxs(Popover, { children: [_jsxs(PopoverTrigger, { className: cn('inline-flex items-center gap-1.5 text-sm text-fd-muted-foreground has-data-[active=true]:text-fd-primary', className), ...props, children: [item.url ? (_jsx(LinkItem, { item: item, children: item.text })) : (item.text), _jsx(ChevronDown, { className: "size-3" })] }), _jsx(PopoverContent, { className: "flex flex-col", children: item.items.map((child, i) => {
|
|
65
|
+
if (child.type === 'custom')
|
|
66
|
+
return _jsx(Fragment, { children: child.children }, i);
|
|
67
|
+
return (_jsxs(LinkItem, { item: child, className: "inline-flex items-center gap-2 rounded-md p-2 text-start hover:bg-fd-accent hover:text-fd-accent-foreground data-[active=true]:text-fd-primary [&_svg]:size-4", children: [child.icon, child.text] }, i));
|
|
68
|
+
}) })] }));
|
|
69
|
+
}
|
|
70
|
+
return (_jsx(LinkItem, { item: item, className: cn('text-sm text-fd-muted-foreground transition-colors hover:text-fd-accent-foreground data-[active=true]:text-fd-primary', className), ...props, children: item.text }));
|
|
45
71
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type ComponentProps, type FC, type HTMLAttributes, type ReactNode } from 'react';
|
|
2
2
|
import { type BaseLayoutProps } from '../../layouts/shared/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { Sidebar } from './sidebar.js';
|
|
4
4
|
import type * as PageTree from 'fumadocs-core/page-tree';
|
|
5
|
-
import { Navbar, NavbarSidebarTrigger } from '../../layouts/notebook/client.js';
|
|
6
|
-
import { type Option } from '../../components/layout/root-toggle.js';
|
|
7
5
|
import { type GetSidebarTabsOptions } from '../../utils/get-sidebar-tabs.js';
|
|
6
|
+
import type { SidebarPageTreeComponents } from '../../components/sidebar/page-tree.js';
|
|
7
|
+
import { type SidebarTabWithProps } from '../../components/sidebar/tabs.js';
|
|
8
8
|
export interface DocsLayoutProps extends BaseLayoutProps {
|
|
9
9
|
tree: PageTree.Root;
|
|
10
10
|
tabMode?: 'sidebar' | 'navbar';
|
|
@@ -14,14 +14,14 @@ export interface DocsLayoutProps extends BaseLayoutProps {
|
|
|
14
14
|
sidebar?: SidebarOptions;
|
|
15
15
|
containerProps?: HTMLAttributes<HTMLDivElement>;
|
|
16
16
|
}
|
|
17
|
-
interface SidebarOptions extends ComponentProps<'aside'>, Pick<
|
|
18
|
-
components?: Partial<
|
|
17
|
+
interface SidebarOptions extends ComponentProps<'aside'>, Pick<ComponentProps<typeof Sidebar>, 'defaultOpenLevel' | 'prefetch'> {
|
|
18
|
+
components?: Partial<SidebarPageTreeComponents>;
|
|
19
19
|
/**
|
|
20
20
|
* Root Toggle options
|
|
21
21
|
*/
|
|
22
|
-
tabs?:
|
|
23
|
-
banner?: ReactNode | FC<ComponentProps<
|
|
24
|
-
footer?: ReactNode | FC<ComponentProps<
|
|
22
|
+
tabs?: SidebarTabWithProps[] | GetSidebarTabsOptions | false;
|
|
23
|
+
banner?: ReactNode | FC<ComponentProps<'div'>>;
|
|
24
|
+
footer?: ReactNode | FC<ComponentProps<'div'>>;
|
|
25
25
|
/**
|
|
26
26
|
* Support collapsing the sidebar on desktop mode
|
|
27
27
|
*
|
|
@@ -30,5 +30,5 @@ interface SidebarOptions extends ComponentProps<'aside'>, Pick<SidebarProps, 'de
|
|
|
30
30
|
collapsible?: boolean;
|
|
31
31
|
}
|
|
32
32
|
export declare function DocsLayout(props: DocsLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
-
export {
|
|
33
|
+
export {};
|
|
34
34
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/layouts/notebook/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/layouts/notebook/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,EAAE,EACP,KAAK,cAAc,EACnB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,eAAe,EAAoB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EACL,OAAO,EAQR,MAAM,WAAW,CAAC;AAOnB,OAAO,KAAK,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AAazD,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAE/B,GAAG,CAAC,EAAE,eAAe,CAAC,KAAK,CAAC,GAAG;QAC7B,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;KACvB,CAAC;IAEF,OAAO,CAAC,EAAE,cAAc,CAAC;IAEzB,cAAc,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CACjD;AAED,UAAU,cACR,SAAQ,cAAc,CAAC,OAAO,CAAC,EAC7B,IAAI,CAAC,cAAc,CAAC,OAAO,OAAO,CAAC,EAAE,kBAAkB,GAAG,UAAU,CAAC;IACvE,UAAU,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAEhD;;OAEG;IACH,IAAI,CAAC,EAAE,mBAAmB,EAAE,GAAG,qBAAqB,GAAG,KAAK,CAAC;IAE7D,MAAM,CAAC,EAAE,SAAS,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,MAAM,CAAC,EAAE,SAAS,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IAE/C;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,2CAsNhD"}
|
|
@@ -1,79 +1,72 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Sidebar, SidebarCollapseTrigger, SidebarContent,
|
|
2
|
+
import { useMemo, } from 'react';
|
|
3
|
+
import { resolveLinkItems } from '../../layouts/shared/index.js';
|
|
4
|
+
import { Sidebar, SidebarCollapseTrigger, SidebarContent, SidebarDrawer, SidebarLinkItem, SidebarPageTree, SidebarTrigger, SidebarViewport, } from './sidebar.js';
|
|
5
5
|
import { TreeContextProvider } from '../../contexts/tree.js';
|
|
6
6
|
import { cn } from '../../utils/cn.js';
|
|
7
7
|
import { buttonVariants } from '../../components/ui/button.js';
|
|
8
|
-
import {
|
|
9
|
-
import { LanguageToggle } from '../../
|
|
10
|
-
import { ThemeToggle } from '../../
|
|
11
|
-
import {
|
|
12
|
-
import { LayoutBody, LayoutTabs, Navbar, NavbarSidebarTrigger, } from '../../layouts/notebook/client.js';
|
|
13
|
-
import { NavProvider } from '../../contexts/layout.js';
|
|
14
|
-
import { RootToggle } from '../../components/layout/root-toggle.js';
|
|
8
|
+
import { Languages, Sidebar as SidebarIcon, X } from '../../icons.js';
|
|
9
|
+
import { LanguageToggle } from '../../layouts/shared/language-toggle.js';
|
|
10
|
+
import { ThemeToggle } from '../../layouts/shared/theme-toggle.js';
|
|
11
|
+
import { LayoutBody, LayoutContextProvider, LayoutHeaderTabs, LayoutHeader, NavbarLinkItem, } from '../../layouts/notebook/client.js';
|
|
15
12
|
import Link from 'fumadocs-core/link';
|
|
16
|
-
import { LargeSearchToggle, SearchToggle, } from '../../
|
|
13
|
+
import { LargeSearchToggle, SearchToggle, } from '../../layouts/shared/search-toggle.js';
|
|
17
14
|
import { getSidebarTabs, } from '../../utils/get-sidebar-tabs.js';
|
|
15
|
+
import { LinkItem } from '../../layouts/shared/link-item.js';
|
|
16
|
+
import { SidebarTabTrigger, } from '../../components/sidebar/tabs.js';
|
|
18
17
|
export function DocsLayout(props) {
|
|
19
|
-
const { tabMode = 'sidebar', nav
|
|
18
|
+
const { tabMode = 'sidebar', nav = {}, sidebar: { tabs: tabOptions, defaultOpenLevel, prefetch, ...sidebarProps } = {}, i18n = false, themeSwitch = {}, tree, } = props;
|
|
20
19
|
const navMode = nav.mode ?? 'auto';
|
|
21
|
-
const links =
|
|
20
|
+
const links = resolveLinkItems(props);
|
|
22
21
|
const tabs = useMemo(() => {
|
|
23
22
|
if (Array.isArray(tabOptions)) {
|
|
24
23
|
return tabOptions;
|
|
25
24
|
}
|
|
26
25
|
if (typeof tabOptions === 'object') {
|
|
27
|
-
return getSidebarTabs(
|
|
26
|
+
return getSidebarTabs(tree, tabOptions);
|
|
28
27
|
}
|
|
29
28
|
if (tabOptions !== false) {
|
|
30
|
-
return getSidebarTabs(
|
|
29
|
+
return getSidebarTabs(tree);
|
|
31
30
|
}
|
|
32
31
|
return [];
|
|
33
|
-
}, [tabOptions,
|
|
32
|
+
}, [tabOptions, tree]);
|
|
34
33
|
function sidebar() {
|
|
35
|
-
const { banner, footer, components, collapsible = true,
|
|
34
|
+
const { banner, footer, components, collapsible = true, ...rest } = sidebarProps;
|
|
36
35
|
const Header = typeof banner === 'function'
|
|
37
36
|
? banner
|
|
38
|
-
: (props) => (_jsxs(
|
|
37
|
+
: ({ className, ...props }) => (_jsxs("div", { className: cn('flex flex-col gap-3 p-4 pb-2', className), ...props, children: [props.children, banner] }));
|
|
39
38
|
const Footer = typeof footer === 'function'
|
|
40
39
|
? footer
|
|
41
|
-
: (props) => (_jsxs(
|
|
40
|
+
: ({ className, ...props }) => (_jsxs("div", { className: cn('flex flex-col border-t p-4 pt-2', className), ...props, children: [props.children, footer] }));
|
|
42
41
|
const iconLinks = links.filter((item) => item.type === 'icon');
|
|
43
|
-
const rootToggle = (_jsxs(_Fragment, { children: [tabMode === 'sidebar' && tabs.length > 0 && (_jsx(RootToggle, { className: "mb-2", options: tabs })), tabMode === 'navbar' && tabs.length > 0 && (_jsx(RootToggle, { options: tabs, className: "lg:hidden" }))] }));
|
|
44
42
|
const viewport = (_jsxs(SidebarViewport, { children: [links
|
|
45
43
|
.filter((item) => item.type !== 'icon')
|
|
46
|
-
.map((item, i, arr) => (_jsx(SidebarLinkItem, { item: item, className: cn('lg:hidden', i === arr.length - 1 && 'mb-4') }, i))), _jsx(SidebarPageTree, { components
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
.map((item, i, arr) => (_jsx(SidebarLinkItem, { item: item, className: cn('lg:hidden', i === arr.length - 1 && 'mb-4') }, i))), _jsx(SidebarPageTree, { ...components })] }));
|
|
45
|
+
return (_jsxs(_Fragment, { children: [_jsxs(SidebarContent, { ...rest, children: [_jsxs(Header, { className: "empty:hidden", children: [navMode === 'auto' && (_jsxs("div", { className: "flex justify-between", children: [_jsx(Link, { href: nav.url ?? '/', className: "inline-flex items-center gap-2.5 font-medium", children: nav.title }), collapsible && (_jsx(SidebarCollapseTrigger, { className: cn(buttonVariants({
|
|
46
|
+
color: 'ghost',
|
|
47
|
+
size: 'icon-sm',
|
|
48
|
+
className: 'mt-px mb-auto text-fd-muted-foreground',
|
|
49
|
+
})), children: _jsx(SidebarIcon, {}) }))] })), nav.children, tabs.length > 0 && (_jsx(SidebarTabTrigger, { options: tabs, className: cn(tabMode === 'navbar' && 'lg:hidden') }))] }), viewport, _jsx(Footer, { className: cn('hidden flex-row text-fd-muted-foreground items-center', iconLinks.length > 0 && 'max-lg:flex'), children: iconLinks.map((item, i) => (_jsx(LinkItem, { item: item, className: cn(buttonVariants({
|
|
50
|
+
size: 'icon-sm',
|
|
51
|
+
color: 'ghost',
|
|
52
|
+
className: 'lg:hidden',
|
|
53
|
+
})), "aria-label": item.label, children: item.icon }, i))) })] }), _jsxs(SidebarDrawer, { ...rest, children: [_jsxs(Header, { children: [_jsx(SidebarTrigger, { className: cn(buttonVariants({
|
|
54
|
+
size: 'icon-sm',
|
|
50
55
|
color: 'ghost',
|
|
56
|
+
className: 'ms-auto text-fd-muted-foreground',
|
|
57
|
+
})), children: _jsx(X, {}) }), tabs.length > 0 && _jsx(SidebarTabTrigger, { options: tabs })] }), viewport, _jsxs(Footer, { className: cn('hidden flex-row items-center justify-end', (i18n || themeSwitch.enabled !== false) && 'flex', iconLinks.length > 0 && 'max-lg:flex'), children: [iconLinks.map((item, i) => (_jsx(LinkItem, { item: item, className: cn(buttonVariants({
|
|
51
58
|
size: 'icon-sm',
|
|
52
|
-
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
color: 'ghost',
|
|
56
|
-
className: 'lg:hidden',
|
|
57
|
-
})), "aria-label": item.label, children: item.icon }, i))) })] }));
|
|
58
|
-
const mobile = (_jsxs(SidebarContentMobile, { ...rest, children: [_jsxs(Header, { children: [_jsx(SidebarTrigger, { className: cn(buttonVariants({
|
|
59
|
-
size: 'icon-sm',
|
|
60
|
-
color: 'ghost',
|
|
61
|
-
className: 'ms-auto text-fd-muted-foreground',
|
|
62
|
-
})), children: _jsx(X, {}) }), rootToggle] }), viewport, _jsxs(Footer, { className: cn('hidden flex-row items-center justify-end', (i18n || themeSwitch.enabled !== false) && 'flex', iconLinks.length > 0 && 'max-lg:flex'), children: [iconLinks.map((item, i) => (_jsx(BaseLinkItem, { item: item, className: cn(buttonVariants({
|
|
63
|
-
size: 'icon-sm',
|
|
64
|
-
color: 'ghost',
|
|
65
|
-
}), 'text-fd-muted-foreground lg:hidden', i === iconLinks.length - 1 && 'me-auto'), "aria-label": item.label, children: item.icon }, i))), i18n && (_jsx(LanguageToggle, { children: _jsx(Languages, { className: "size-4.5 text-fd-muted-foreground" }) })), themeSwitch.enabled !== false &&
|
|
66
|
-
(themeSwitch.component ?? (_jsx(ThemeToggle, { mode: themeSwitch.mode ?? 'light-dark-system' })))] })] }));
|
|
67
|
-
return (_jsx(Sidebar, { defaultOpenLevel: defaultOpenLevel, prefetch: prefetch, Content: content, Mobile: mobile }));
|
|
59
|
+
color: 'ghost',
|
|
60
|
+
}), 'text-fd-muted-foreground lg:hidden', i === iconLinks.length - 1 && 'me-auto'), "aria-label": item.label, children: item.icon }, i))), i18n && (_jsx(LanguageToggle, { children: _jsx(Languages, { className: "size-4.5 text-fd-muted-foreground" }) })), themeSwitch.enabled !== false &&
|
|
61
|
+
(themeSwitch.component ?? (_jsx(ThemeToggle, { mode: themeSwitch.mode ?? 'light-dark-system' })))] })] })] }));
|
|
68
62
|
}
|
|
69
|
-
return (_jsx(TreeContextProvider, { tree:
|
|
63
|
+
return (_jsx(TreeContextProvider, { tree: tree, children: _jsx(LayoutContextProvider, { navMode: nav.mode ?? 'auto', tabMode: tabMode, navTransparentMode: nav.transparentMode, children: _jsx(Sidebar, { defaultOpenLevel: defaultOpenLevel, prefetch: prefetch, children: _jsxs(LayoutBody, { ...props.containerProps, children: [sidebar(), _jsx(DocsNavbar, { ...props, links: links, tabs: tabs }), props.children] }) }) }) }));
|
|
70
64
|
}
|
|
71
|
-
function DocsNavbar({ links, tabs, sidebar: { collapsible: sidebarCollapsible = true } = {}, searchToggle = {}, themeSwitch = {}, nav = {}, i18n, }) {
|
|
65
|
+
function DocsNavbar({ links, tabs, tabMode = 'sidebar', sidebar: { collapsible: sidebarCollapsible = true } = {}, searchToggle = {}, themeSwitch = {}, nav = {}, i18n, }) {
|
|
72
66
|
const navMode = nav.mode ?? 'auto';
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
]), children: [sidebarCollapsible && navMode === 'auto' && (_jsx(SidebarCollapseTrigger, { className: cn(buttonVariants({
|
|
67
|
+
const showLayoutTabs = tabMode === 'navbar' && tabs.length > 0;
|
|
68
|
+
return (_jsxs(LayoutHeader, { id: "nd-subnav", className: cn('sticky [grid-area:header] flex flex-col top-(--fd-docs-row-1) z-10 backdrop-blur-sm transition-colors data-[transparent=false]:bg-fd-background/80 layout:[--fd-header-height:--spacing(14)]', showLayoutTabs && 'lg:layout:[--fd-header-height:--spacing(24)]'), children: [_jsxs("div", { "data-header-body": "", className: "flex border-b px-4 gap-2 h-14 md:px-6", children: [_jsxs("div", { className: cn('items-center', navMode === 'top' && 'flex flex-1', navMode === 'auto' &&
|
|
69
|
+
'hidden has-data-[collapsed=true]:md:flex max-md:flex'), children: [sidebarCollapsible && navMode === 'auto' && (_jsx(SidebarCollapseTrigger, { className: cn(buttonVariants({
|
|
77
70
|
color: 'ghost',
|
|
78
71
|
size: 'icon-sm',
|
|
79
72
|
}), 'text-fd-muted-foreground data-[collapsed=false]:hidden max-md:hidden'), children: _jsx(SidebarIcon, {}) })), _jsx(Link, { href: nav.url ?? '/', className: cn('inline-flex items-center gap-2.5 font-semibold', navMode === 'auto' && 'md:hidden'), children: nav.title })] }), searchToggle.enabled !== false &&
|
|
@@ -81,32 +74,16 @@ function DocsNavbar({ links, tabs, sidebar: { collapsible: sidebarCollapsible =
|
|
|
81
74
|
? 'rounded-xl max-w-sm ps-2.5'
|
|
82
75
|
: 'max-w-[240px]') }))), _jsxs("div", { className: "flex flex-1 items-center justify-end md:gap-2", children: [_jsx("div", { className: "flex items-center gap-6 empty:hidden max-lg:hidden", children: links
|
|
83
76
|
.filter((item) => item.type !== 'icon')
|
|
84
|
-
.map((item, i) => (_jsx(NavbarLinkItem, { item: item
|
|
77
|
+
.map((item, i) => (_jsx(NavbarLinkItem, { item: item }, i))) }), nav.children, links
|
|
85
78
|
.filter((item) => item.type === 'icon')
|
|
86
|
-
.map((item, i) => (_jsx(
|
|
87
|
-
(searchToggle.components?.sm ?? (_jsx(SearchToggle, { hideIfDisabled: true, className: "p-2" }))), _jsx(
|
|
79
|
+
.map((item, i) => (_jsx(LinkItem, { item: item, className: cn(buttonVariants({ size: 'icon-sm', color: 'ghost' }), 'text-fd-muted-foreground max-lg:hidden'), "aria-label": item.label, children: item.icon }, i))), _jsxs("div", { className: "flex items-center md:hidden", children: [searchToggle.enabled !== false &&
|
|
80
|
+
(searchToggle.components?.sm ?? (_jsx(SearchToggle, { hideIfDisabled: true, className: "p-2" }))), _jsx(SidebarTrigger, { className: cn(buttonVariants({
|
|
81
|
+
color: 'ghost',
|
|
82
|
+
size: 'icon-sm',
|
|
83
|
+
className: 'p-2 -me-1.5',
|
|
84
|
+
})), children: _jsx(SidebarIcon, {}) })] }), _jsxs("div", { className: "flex items-center gap-2 max-md:hidden", children: [i18n && (_jsx(LanguageToggle, { children: _jsx(Languages, { className: "size-4.5 text-fd-muted-foreground" }) })), themeSwitch.enabled !== false &&
|
|
88
85
|
(themeSwitch.component ?? (_jsx(ThemeToggle, { mode: themeSwitch.mode ?? 'light-dark-system' }))), sidebarCollapsible && navMode === 'top' && (_jsx(SidebarCollapseTrigger, { className: cn(buttonVariants({
|
|
89
86
|
color: 'secondary',
|
|
90
87
|
size: 'icon-sm',
|
|
91
|
-
}), 'text-fd-muted-foreground rounded-full -me-1.5'), children: _jsx(SidebarIcon, {}) }))] })] })] }),
|
|
92
|
-
}
|
|
93
|
-
function NavbarLinkItem({ item, ...props }) {
|
|
94
|
-
if (item.type === 'menu') {
|
|
95
|
-
return (_jsxs(Popover, { children: [_jsxs(PopoverTrigger, { ...props, className: cn('inline-flex items-center gap-1.5 has-data-[active=true]:text-fd-primary', props.className), children: [item.url ? (_jsx(BaseLinkItem, { item: item, children: item.text })) : (item.text), _jsx(ChevronDown, { className: "size-3" })] }), _jsx(PopoverContent, { className: "flex flex-col", children: item.items.map((child, i) => {
|
|
96
|
-
if (child.type === 'custom')
|
|
97
|
-
return _jsx(Fragment, { children: child.children }, i);
|
|
98
|
-
return (_jsxs(BaseLinkItem, { item: child, className: "inline-flex items-center gap-2 rounded-md p-2 text-start hover:bg-fd-accent hover:text-fd-accent-foreground data-[active=true]:text-fd-primary [&_svg]:size-4", children: [child.icon, child.text] }, i));
|
|
99
|
-
}) })] }));
|
|
100
|
-
}
|
|
101
|
-
if (item.type === 'custom')
|
|
102
|
-
return item.children;
|
|
103
|
-
return (_jsx(BaseLinkItem, { item: item, ...props, children: item.text }));
|
|
104
|
-
}
|
|
105
|
-
function SidebarLinkItem({ item, ...props }) {
|
|
106
|
-
if (item.type === 'menu')
|
|
107
|
-
return (_jsxs(SidebarFolder, { ...props, children: [item.url ? (_jsxs(SidebarFolderLink, { href: item.url, external: item.external, children: [item.icon, item.text] })) : (_jsxs(SidebarFolderTrigger, { children: [item.icon, item.text] })), _jsx(SidebarFolderContent, { children: item.items.map((child, i) => (_jsx(SidebarLinkItem, { item: child }, i))) })] }));
|
|
108
|
-
if (item.type === 'custom')
|
|
109
|
-
return _jsx("div", { ...props, children: item.children });
|
|
110
|
-
return (_jsx(SidebarItem, { href: item.url, icon: item.icon, external: item.external, ...props, children: item.text }));
|
|
88
|
+
}), 'text-fd-muted-foreground rounded-full -me-1.5'), children: _jsx(SidebarIcon, {}) }))] })] })] }), showLayoutTabs && (_jsx(LayoutHeaderTabs, { "data-header-tabs": "", className: "overflow-x-auto border-b px-6 h-10 max-lg:hidden", options: tabs }))] }));
|
|
111
89
|
}
|
|
112
|
-
export { Navbar, NavbarSidebarTrigger };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ComponentProps } from 'react';
|
|
2
|
+
import type * as PageTree from 'fumadocs-core/page-tree';
|
|
3
|
+
import { type BreadcrumbOptions } from 'fumadocs-core/breadcrumb';
|
|
4
|
+
export declare function PageTOCPopover({ className, children, ...rest }: ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function PageTOCPopoverTrigger({ className, ...props }: ComponentProps<'button'>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function PageTOCPopoverContent(props: ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function PageLastUpdate({ date: value, ...props }: Omit<ComponentProps<'p'>, 'children'> & {
|
|
8
|
+
date: Date;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
type Item = Pick<PageTree.Item, 'name' | 'description' | 'url'>;
|
|
11
|
+
export interface FooterProps extends ComponentProps<'div'> {
|
|
12
|
+
/**
|
|
13
|
+
* Items including information for the next and previous page
|
|
14
|
+
*/
|
|
15
|
+
items?: {
|
|
16
|
+
previous?: Item;
|
|
17
|
+
next?: Item;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export declare function PageFooter({ items, ...props }: FooterProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export type BreadcrumbProps = BreadcrumbOptions & ComponentProps<'div'>;
|
|
22
|
+
export declare function PageBreadcrumb({ includeRoot, includeSeparator, includePage, ...props }: BreadcrumbProps): import("react/jsx-runtime").JSX.Element | null;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=client.d.ts.map
|