@fumadocs/base-ui 16.7.0 → 16.7.2
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/generated/docs.css +5 -4
- package/css/generated/flux.css +3 -3
- package/css/generated/home.css +2 -3
- package/css/generated/notebook.css +4 -4
- package/css/generated/shared.css +2 -1
- package/dist/components/accordion.js +2 -2
- package/dist/components/dialog/search.js +2 -2
- package/dist/components/files.js +3 -3
- package/dist/components/heading.js +2 -2
- package/dist/components/sidebar/tabs/dropdown.js +1 -1
- package/dist/components/toc/index.d.ts +3 -2
- package/dist/components/toc/index.js +12 -2
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/layouts/docs/client.d.ts +3 -3
- package/dist/layouts/docs/client.js +20 -23
- package/dist/layouts/docs/index.d.ts +1 -1
- package/dist/layouts/docs/page/index.d.ts +91 -3
- package/dist/layouts/docs/page/index.js +67 -7
- package/dist/layouts/docs/page/slots/breadcrumb.js +3 -1
- package/dist/layouts/docs/page/slots/container.js +2 -1
- package/dist/layouts/docs/page/slots/footer.js +1 -0
- package/dist/layouts/docs/page/slots/toc.d.ts +29 -1
- package/dist/layouts/docs/page/slots/toc.js +137 -4
- package/dist/layouts/docs/slots/container.js +2 -1
- package/dist/layouts/docs/slots/header.js +1 -0
- package/dist/layouts/docs/slots/sidebar.js +7 -7
- package/dist/layouts/flux/index.d.ts +4 -4
- package/dist/layouts/flux/index.js +8 -11
- package/dist/layouts/flux/page/index.d.ts +79 -3
- package/dist/layouts/flux/page/index.js +61 -7
- package/dist/layouts/flux/page/slots/breadcrumb.js +1 -0
- package/dist/layouts/flux/page/slots/container.js +2 -1
- package/dist/layouts/flux/page/slots/footer.js +1 -0
- package/dist/layouts/flux/page/slots/toc.d.ts +4 -1
- package/dist/layouts/flux/page/slots/toc.js +3 -2
- package/dist/layouts/flux/slots/container.js +1 -0
- package/dist/layouts/home/index.d.ts +3 -3
- package/dist/layouts/home/index.js +6 -8
- package/dist/layouts/home/slots/container.js +1 -0
- package/dist/layouts/home/slots/header.d.ts +1 -1
- package/dist/layouts/home/slots/header.js +5 -5
- package/dist/layouts/notebook/client.d.ts +3 -3
- package/dist/layouts/notebook/client.js +15 -18
- package/dist/layouts/notebook/index.d.ts +1 -1
- package/dist/layouts/notebook/page/index.d.ts +91 -3
- package/dist/layouts/notebook/page/index.js +67 -7
- package/dist/layouts/notebook/page/slots/breadcrumb.js +1 -0
- package/dist/layouts/notebook/page/slots/container.js +2 -1
- package/dist/layouts/notebook/page/slots/footer.js +1 -0
- package/dist/layouts/notebook/page/slots/toc.d.ts +29 -1
- package/dist/layouts/notebook/page/slots/toc.js +136 -4
- package/dist/layouts/notebook/slots/container.js +1 -0
- package/dist/layouts/notebook/slots/sidebar.js +5 -5
- package/dist/layouts/shared/client.d.ts +8 -8
- package/dist/layouts/shared/client.js +4 -4
- package/dist/layouts/shared/index.d.ts +6 -6
- package/dist/layouts/shared/page-actions.d.ts +2 -2
- package/dist/layouts/shared/page-actions.js +3 -3
- package/dist/layouts/shared/slots/search-trigger.d.ts +3 -3
- package/dist/page.d.ts +1 -2
- package/dist/page.js +1 -2
- package/package.json +4 -6
- package/dist/layouts/docs/page/client.d.ts +0 -98
- package/dist/layouts/docs/page/client.js +0 -110
- package/dist/layouts/docs/page/slots/toc-popover.d.ts +0 -31
- package/dist/layouts/docs/page/slots/toc-popover.js +0 -141
- package/dist/layouts/flux/page/client.d.ts +0 -82
- package/dist/layouts/flux/page/client.js +0 -94
- package/dist/layouts/notebook/page/client.d.ts +0 -98
- package/dist/layouts/notebook/page/client.js +0 -110
- package/dist/layouts/notebook/page/slots/toc-popover.d.ts +0 -31
- package/dist/layouts/notebook/page/slots/toc-popover.js +0 -141
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { TOCProvider as TOCProvider$1, TOCProviderProps as TOCProviderProps$1 } from "../../../../components/toc/index.js";
|
|
1
2
|
import { ComponentProps, ReactNode } from "react";
|
|
2
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
4
|
|
|
4
5
|
//#region src/layouts/flux/page/slots/toc.d.ts
|
|
6
|
+
type TOCProviderProps = TOCProviderProps$1;
|
|
7
|
+
declare const TOCProvider: typeof TOCProvider$1;
|
|
5
8
|
interface TOCProps {
|
|
6
9
|
container?: ComponentProps<'div'>;
|
|
7
10
|
trigger?: ComponentProps<'button'>;
|
|
@@ -28,4 +31,4 @@ declare function TOC({
|
|
|
28
31
|
style
|
|
29
32
|
}: TOCProps): react_jsx_runtime0.JSX.Element;
|
|
30
33
|
//#endregion
|
|
31
|
-
export { TOC, TOCProps };
|
|
34
|
+
export { TOC, TOCProps, TOCProvider, TOCProviderProps };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useI18n } from "../../../../contexts/i18n.js";
|
|
3
3
|
import { cn } from "../../../../utils/cn.js";
|
|
4
|
-
import { TOCScrollArea, useTOCItems } from "../../../../components/toc/index.js";
|
|
4
|
+
import { TOCScrollArea, toc_exports, useTOCItems } from "../../../../components/toc/index.js";
|
|
5
5
|
import { TOCItems } from "../../../../components/toc/default.js";
|
|
6
6
|
import { TOCItems as TOCItems$1 } from "../../../../components/toc/clerk.js";
|
|
7
7
|
import { useTreePath } from "../../../../contexts/tree.js";
|
|
@@ -14,6 +14,7 @@ import { createPortal } from "react-dom";
|
|
|
14
14
|
import { AnimatePresence, motion } from "motion/react";
|
|
15
15
|
//#region src/layouts/flux/page/slots/toc.tsx
|
|
16
16
|
const TocPopoverContext = createContext(null);
|
|
17
|
+
const { TOCProvider } = toc_exports;
|
|
17
18
|
function TOC({ container, trigger, content, header, footer, style }) {
|
|
18
19
|
return /* @__PURE__ */ jsxs(PageTOCPopover, {
|
|
19
20
|
...container,
|
|
@@ -166,4 +167,4 @@ function PageTOCPopoverContent(props) {
|
|
|
166
167
|
});
|
|
167
168
|
}
|
|
168
169
|
//#endregion
|
|
169
|
-
export { TOC };
|
|
170
|
+
export { TOC, TOCProvider };
|
|
@@ -6,7 +6,7 @@ import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
6
6
|
//#region src/layouts/home/index.d.ts
|
|
7
7
|
interface HomeLayoutProps extends BaseLayoutProps, ComponentProps<'main'> {
|
|
8
8
|
nav?: Nav;
|
|
9
|
-
slots?: HomeSlots
|
|
9
|
+
slots?: Partial<HomeSlots>;
|
|
10
10
|
}
|
|
11
11
|
interface Nav extends NavOptions {
|
|
12
12
|
/**
|
|
@@ -15,8 +15,8 @@ interface Nav extends NavOptions {
|
|
|
15
15
|
enableHoverToOpen?: boolean;
|
|
16
16
|
}
|
|
17
17
|
interface HomeSlots extends BaseSlots {
|
|
18
|
-
header
|
|
19
|
-
container
|
|
18
|
+
header: FC<ComponentProps<'header'>>;
|
|
19
|
+
container: FC<ComponentProps<'main'>>;
|
|
20
20
|
}
|
|
21
21
|
declare function useHomeLayout(): {
|
|
22
22
|
props: BaseSlotsProps<HomeLayoutProps>;
|
|
@@ -4,7 +4,7 @@ import { useLinkItems } from "../shared/index.js";
|
|
|
4
4
|
import { Container } from "./slots/container.js";
|
|
5
5
|
import { Header } from "./slots/header.js";
|
|
6
6
|
import { createContext, use } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
//#region src/layouts/home/index.tsx
|
|
9
9
|
const LayoutContext = createContext(null);
|
|
10
10
|
function useHomeLayout() {
|
|
@@ -21,21 +21,19 @@ function HomeLayout(props) {
|
|
|
21
21
|
const linkItems = useLinkItems(props);
|
|
22
22
|
const slots = {
|
|
23
23
|
...baseSlots,
|
|
24
|
-
header:
|
|
24
|
+
header: defaultSlots?.header ?? Header,
|
|
25
25
|
container: defaultSlots?.container ?? Container
|
|
26
26
|
};
|
|
27
|
-
let content = /* @__PURE__ */ jsxs(Fragment$1, { children: [slots.header && /* @__PURE__ */ jsx(slots.header, {}), children] });
|
|
28
|
-
if (slots.container) content = /* @__PURE__ */ jsx(slots.container, {
|
|
29
|
-
...rest,
|
|
30
|
-
children: content
|
|
31
|
-
});
|
|
32
27
|
return /* @__PURE__ */ jsx(LayoutContext, {
|
|
33
28
|
value: {
|
|
34
29
|
props: baseProps,
|
|
35
30
|
slots,
|
|
36
31
|
...linkItems
|
|
37
32
|
},
|
|
38
|
-
children:
|
|
33
|
+
children: /* @__PURE__ */ jsxs(slots.container, {
|
|
34
|
+
...rest,
|
|
35
|
+
children: [navEnabled && /* @__PURE__ */ jsx(slots.header, {}), children]
|
|
36
|
+
})
|
|
39
37
|
});
|
|
40
38
|
}
|
|
41
39
|
//#endregion
|
|
@@ -5,7 +5,7 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
|
|
|
5
5
|
|
|
6
6
|
//#region src/layouts/home/slots/header.d.ts
|
|
7
7
|
declare const navItemVariants: (props?: ({
|
|
8
|
-
variant?: "
|
|
8
|
+
variant?: "icon" | "button" | "main" | null | undefined;
|
|
9
9
|
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
10
10
|
declare function Header(props: ComponentProps<'header'>): string | number | bigint | true | react_jsx_runtime0.JSX.Element | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined>;
|
|
11
11
|
//#endregion
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../../../utils/cn.js";
|
|
3
3
|
import { buttonVariants } from "../../../components/ui/button.js";
|
|
4
|
-
import { useIsScrollTop } from "../../../utils/use-is-scroll-top.js";
|
|
5
4
|
import { LinkItem } from "../../shared/client.js";
|
|
6
5
|
import "../../shared/index.js";
|
|
6
|
+
import { useIsScrollTop } from "../../../utils/use-is-scroll-top.js";
|
|
7
7
|
import { NavigationMenu as NavigationMenuRoot, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport } from "../../../components/ui/navigation-menu.js";
|
|
8
8
|
import { useHomeLayout } from "../index.js";
|
|
9
9
|
import { Fragment, useState } from "react";
|
|
@@ -45,12 +45,12 @@ function Header(props) {
|
|
|
45
45
|
/* @__PURE__ */ jsxs("div", {
|
|
46
46
|
className: "flex flex-row items-center justify-end gap-1.5 flex-1 max-lg:hidden",
|
|
47
47
|
children: [
|
|
48
|
-
slots.searchTrigger
|
|
48
|
+
slots.searchTrigger && /* @__PURE__ */ jsx(slots.searchTrigger.full, {
|
|
49
49
|
hideIfDisabled: true,
|
|
50
50
|
className: "w-full rounded-full ps-2.5 max-w-[240px]"
|
|
51
51
|
}),
|
|
52
52
|
slots.themeSwitch && /* @__PURE__ */ jsx(slots.themeSwitch, {}),
|
|
53
|
-
slots.languageSelect
|
|
53
|
+
slots.languageSelect && /* @__PURE__ */ jsx(slots.languageSelect.root, { children: /* @__PURE__ */ jsx(Languages, { className: "size-5" }) }),
|
|
54
54
|
/* @__PURE__ */ jsx("ul", {
|
|
55
55
|
className: "flex flex-row gap-2 items-center empty:hidden",
|
|
56
56
|
children: navItems.filter(isSecondary).map((item, i) => /* @__PURE__ */ jsx(NavigationMenuLinkItem, {
|
|
@@ -62,7 +62,7 @@ function Header(props) {
|
|
|
62
62
|
}),
|
|
63
63
|
/* @__PURE__ */ jsxs("div", {
|
|
64
64
|
className: "flex flex-row items-center ms-auto -me-1.5 lg:hidden",
|
|
65
|
-
children: [slots.searchTrigger
|
|
65
|
+
children: [slots.searchTrigger && /* @__PURE__ */ jsx(slots.searchTrigger.sm, {
|
|
66
66
|
hideIfDisabled: true,
|
|
67
67
|
className: "p-2"
|
|
68
68
|
}), /* @__PURE__ */ jsx(NavigationMenuItem, { children: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(NavigationMenuTrigger, {
|
|
@@ -90,7 +90,7 @@ function Header(props) {
|
|
|
90
90
|
role: "separator",
|
|
91
91
|
className: "flex-1"
|
|
92
92
|
}),
|
|
93
|
-
slots.languageSelect
|
|
93
|
+
slots.languageSelect && /* @__PURE__ */ jsxs(slots.languageSelect.root, { children: [
|
|
94
94
|
/* @__PURE__ */ jsx(Languages, { className: "size-5" }),
|
|
95
95
|
slots.languageSelect.text && /* @__PURE__ */ jsx(slots.languageSelect.text, {}),
|
|
96
96
|
/* @__PURE__ */ jsx(ChevronDown, { className: "size-3 text-fd-muted-foreground" })
|
|
@@ -5,9 +5,9 @@ import { DocsLayoutProps } from "./index.js";
|
|
|
5
5
|
import { ComponentProps, FC } from "react";
|
|
6
6
|
//#region src/layouts/notebook/client.d.ts
|
|
7
7
|
interface DocsSlots extends BaseSlots {
|
|
8
|
-
container
|
|
9
|
-
header
|
|
10
|
-
sidebar
|
|
8
|
+
container: FC<ComponentProps<'div'>>;
|
|
9
|
+
header: FC<ComponentProps<'header'>>;
|
|
10
|
+
sidebar: {
|
|
11
11
|
provider: FC<SidebarProviderProps>;
|
|
12
12
|
root: FC<SidebarProps>;
|
|
13
13
|
trigger: FC<ComponentProps<'button'>>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { TreeContextProvider } from "../../contexts/tree.js";
|
|
3
|
-
import { useIsScrollTop } from "../../utils/use-is-scroll-top.js";
|
|
4
3
|
import { baseSlots } from "../shared/client.js";
|
|
5
4
|
import { useLinkItems } from "../shared/index.js";
|
|
5
|
+
import { useIsScrollTop } from "../../utils/use-is-scroll-top.js";
|
|
6
6
|
import { Container } from "./slots/container.js";
|
|
7
7
|
import { Sidebar, SidebarCollapseTrigger, SidebarProvider, SidebarTrigger, useSidebar } from "./slots/sidebar.js";
|
|
8
8
|
import { Header } from "./slots/header.js";
|
|
9
9
|
import { createContext, use } from "react";
|
|
10
|
-
import {
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
//#region src/layouts/notebook/client.tsx
|
|
12
12
|
const { useProvider } = baseSlots({ useProps() {
|
|
13
13
|
return useNotebookLayout().props;
|
|
@@ -26,7 +26,7 @@ function LayoutBody(props) {
|
|
|
26
26
|
const linkItems = useLinkItems(props);
|
|
27
27
|
const slots = {
|
|
28
28
|
...baseSlots,
|
|
29
|
-
header:
|
|
29
|
+
header: defaultSlots?.header ?? Header,
|
|
30
30
|
container: defaultSlots?.container ?? Container,
|
|
31
31
|
sidebar: defaultSlots?.sidebar ?? {
|
|
32
32
|
provider: SidebarProvider,
|
|
@@ -36,20 +36,6 @@ function LayoutBody(props) {
|
|
|
36
36
|
useSidebar
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
let content = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
40
|
-
slots.header && /* @__PURE__ */ jsx(slots.header, {}),
|
|
41
|
-
slots.sidebar && /* @__PURE__ */ jsx(slots.sidebar.root, { ...sidebarProps }),
|
|
42
|
-
children
|
|
43
|
-
] });
|
|
44
|
-
if (slots.container) content = /* @__PURE__ */ jsx(slots.container, {
|
|
45
|
-
...containerProps,
|
|
46
|
-
children: content
|
|
47
|
-
});
|
|
48
|
-
if (slots.sidebar) content = /* @__PURE__ */ jsx(slots.sidebar.provider, {
|
|
49
|
-
defaultOpenLevel,
|
|
50
|
-
prefetch,
|
|
51
|
-
children: content
|
|
52
|
-
});
|
|
53
39
|
return /* @__PURE__ */ jsx(TreeContextProvider, {
|
|
54
40
|
tree,
|
|
55
41
|
children: /* @__PURE__ */ jsx(LayoutContext, {
|
|
@@ -64,7 +50,18 @@ function LayoutBody(props) {
|
|
|
64
50
|
slots,
|
|
65
51
|
...linkItems
|
|
66
52
|
},
|
|
67
|
-
children:
|
|
53
|
+
children: /* @__PURE__ */ jsx(slots.sidebar.provider, {
|
|
54
|
+
defaultOpenLevel,
|
|
55
|
+
prefetch,
|
|
56
|
+
children: /* @__PURE__ */ jsxs(slots.container, {
|
|
57
|
+
...containerProps,
|
|
58
|
+
children: [
|
|
59
|
+
navEnabled && /* @__PURE__ */ jsx(slots.header, {}),
|
|
60
|
+
/* @__PURE__ */ jsx(slots.sidebar.root, { ...sidebarProps }),
|
|
61
|
+
children
|
|
62
|
+
]
|
|
63
|
+
})
|
|
64
|
+
})
|
|
68
65
|
})
|
|
69
66
|
});
|
|
70
67
|
}
|
|
@@ -13,7 +13,7 @@ interface DocsLayoutProps extends BaseLayoutProps {
|
|
|
13
13
|
sidebar?: SidebarOptions;
|
|
14
14
|
nav?: Nav;
|
|
15
15
|
containerProps?: HTMLAttributes<HTMLDivElement>;
|
|
16
|
-
slots?: DocsSlots
|
|
16
|
+
slots?: Partial<DocsSlots>;
|
|
17
17
|
}
|
|
18
18
|
interface Nav extends NavOptions {
|
|
19
19
|
mode?: 'top' | 'auto';
|
|
@@ -1,11 +1,93 @@
|
|
|
1
1
|
import { MarkdownCopyButton, ViewOptionsPopover } from "../../shared/page-actions.js";
|
|
2
|
+
import { TOCPopoverProps, TOCProps, TOCProviderProps } from "./slots/toc.js";
|
|
2
3
|
import { Footer, FooterProps } from "./slots/footer.js";
|
|
3
4
|
import { Breadcrumb, BreadcrumbProps } from "./slots/breadcrumb.js";
|
|
4
|
-
import {
|
|
5
|
-
import { ComponentProps } from "react";
|
|
5
|
+
import { ComponentProps, FC, ReactNode } from "react";
|
|
6
6
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
7
|
+
import { TOCItemType } from "fumadocs-core/toc";
|
|
7
8
|
|
|
8
9
|
//#region src/layouts/notebook/page/index.d.ts
|
|
10
|
+
interface DocsPageProps extends ComponentProps<'article'> {
|
|
11
|
+
toc?: TOCItemType[];
|
|
12
|
+
/**
|
|
13
|
+
* Extend the page to fill all available space
|
|
14
|
+
*
|
|
15
|
+
* @defaultValue false
|
|
16
|
+
*/
|
|
17
|
+
full?: boolean;
|
|
18
|
+
slots?: Partial<DocsPageSlots>;
|
|
19
|
+
footer?: FooterOptions;
|
|
20
|
+
breadcrumb?: BreadcrumbOptions;
|
|
21
|
+
tableOfContent?: TableOfContentOptions;
|
|
22
|
+
tableOfContentPopover?: TableOfContentPopoverOptions;
|
|
23
|
+
}
|
|
24
|
+
interface BreadcrumbOptions extends BreadcrumbProps {
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated use `slots.breadcrumb` instead.
|
|
28
|
+
*/
|
|
29
|
+
component?: ReactNode;
|
|
30
|
+
}
|
|
31
|
+
interface FooterOptions extends FooterProps {
|
|
32
|
+
enabled?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated use `slots.footer` instead.
|
|
35
|
+
*/
|
|
36
|
+
component?: ReactNode;
|
|
37
|
+
}
|
|
38
|
+
interface TableOfContentOptions extends Pick<TOCProviderProps, 'single'>, TOCProps {
|
|
39
|
+
enabled?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated use `slots.toc` instead.
|
|
42
|
+
*/
|
|
43
|
+
component?: ReactNode;
|
|
44
|
+
}
|
|
45
|
+
interface TableOfContentPopoverOptions extends TOCPopoverProps {
|
|
46
|
+
enabled?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated use `slots.tocPopover` instead.
|
|
49
|
+
*/
|
|
50
|
+
component?: ReactNode;
|
|
51
|
+
}
|
|
52
|
+
interface DocsPageSlots {
|
|
53
|
+
toc: {
|
|
54
|
+
provider: FC<TOCProviderProps>;
|
|
55
|
+
main: FC<TOCProps>;
|
|
56
|
+
popover: FC<TOCPopoverProps>;
|
|
57
|
+
};
|
|
58
|
+
container: FC<ComponentProps<'article'>>;
|
|
59
|
+
footer: FC<FooterProps>;
|
|
60
|
+
breadcrumb: FC<BreadcrumbProps>;
|
|
61
|
+
}
|
|
62
|
+
type PageSlotsProps = Pick<DocsPageProps, 'full'>;
|
|
63
|
+
declare function useDocsPage(): {
|
|
64
|
+
props: PageSlotsProps;
|
|
65
|
+
slots: DocsPageSlots;
|
|
66
|
+
};
|
|
67
|
+
declare function DocsPage({
|
|
68
|
+
tableOfContent: {
|
|
69
|
+
enabled: tocEnabled,
|
|
70
|
+
single,
|
|
71
|
+
...tocProps
|
|
72
|
+
},
|
|
73
|
+
tableOfContentPopover: {
|
|
74
|
+
enabled: tocPopoverEnabled,
|
|
75
|
+
...tocPopoverProps
|
|
76
|
+
},
|
|
77
|
+
breadcrumb: {
|
|
78
|
+
enabled: breadcrumbEnabled,
|
|
79
|
+
...breadcrumb
|
|
80
|
+
},
|
|
81
|
+
footer: {
|
|
82
|
+
enabled: footerEnabled,
|
|
83
|
+
...footer
|
|
84
|
+
},
|
|
85
|
+
full,
|
|
86
|
+
toc,
|
|
87
|
+
slots: defaultSlots,
|
|
88
|
+
children,
|
|
89
|
+
...containerProps
|
|
90
|
+
}: DocsPageProps): react_jsx_runtime0.JSX.Element;
|
|
9
91
|
declare function EditOnGitHub(props: ComponentProps<'a'>): react_jsx_runtime0.JSX.Element;
|
|
10
92
|
/**
|
|
11
93
|
* Add typography styles
|
|
@@ -25,5 +107,11 @@ declare function DocsTitle({
|
|
|
25
107
|
className,
|
|
26
108
|
...props
|
|
27
109
|
}: ComponentProps<'h1'>): react_jsx_runtime0.JSX.Element;
|
|
110
|
+
declare function PageLastUpdate({
|
|
111
|
+
date: value,
|
|
112
|
+
...props
|
|
113
|
+
}: Omit<ComponentProps<'p'>, 'children'> & {
|
|
114
|
+
date: Date;
|
|
115
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
28
116
|
//#endregion
|
|
29
|
-
export { type BreadcrumbProps, DocsBody, DocsDescription, DocsPage,
|
|
117
|
+
export { type BreadcrumbProps, DocsBody, DocsDescription, DocsPage, DocsPageProps, DocsTitle, EditOnGitHub, type FooterProps, MarkdownCopyButton, Breadcrumb as PageBreadcrumb, Footer as PageFooter, PageLastUpdate, ViewOptionsPopover, useDocsPage };
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { __exportAll } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { I18nLabel } from "../../../contexts/i18n.js";
|
|
3
|
+
import { I18nLabel, useI18n } from "../../../contexts/i18n.js";
|
|
3
4
|
import { cn } from "../../../utils/cn.js";
|
|
4
5
|
import { buttonVariants } from "../../../components/ui/button.js";
|
|
5
6
|
import { MarkdownCopyButton, ViewOptionsPopover } from "../../shared/page-actions.js";
|
|
7
|
+
import { TOC, TOCPopover, TOCProvider } from "./slots/toc.js";
|
|
6
8
|
import { Footer } from "./slots/footer.js";
|
|
7
9
|
import { Breadcrumb } from "./slots/breadcrumb.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
+
import { Container } from "./slots/container.js";
|
|
11
|
+
import { createContext, use, useEffect, useState } from "react";
|
|
12
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
13
|
import { Edit } from "lucide-react";
|
|
11
14
|
//#region src/layouts/notebook/page/index.tsx
|
|
12
15
|
var page_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -22,6 +25,48 @@ var page_exports = /* @__PURE__ */ __exportAll({
|
|
|
22
25
|
ViewOptionsPopover: () => ViewOptionsPopover,
|
|
23
26
|
useDocsPage: () => useDocsPage
|
|
24
27
|
});
|
|
28
|
+
const PageContext = createContext(null);
|
|
29
|
+
function useDocsPage() {
|
|
30
|
+
const context = use(PageContext);
|
|
31
|
+
if (!context) throw new Error("Please use page components under <DocsPage /> (`fumadocs-ui/layouts/notebook/page`).");
|
|
32
|
+
return context;
|
|
33
|
+
}
|
|
34
|
+
function DocsPage({ tableOfContent: { enabled: tocEnabled, single, ...tocProps } = {}, tableOfContentPopover: { enabled: tocPopoverEnabled, ...tocPopoverProps } = {}, breadcrumb: { enabled: breadcrumbEnabled = true, ...breadcrumb } = {}, footer: { enabled: footerEnabled = true, ...footer } = {}, full = false, toc = [], slots: defaultSlots = {}, children, ...containerProps }) {
|
|
35
|
+
tocEnabled ??= Boolean(!full && (toc.length > 0 || tocProps.footer || tocProps.header));
|
|
36
|
+
tocPopoverEnabled ??= Boolean(toc.length > 0 || tocPopoverProps.header || tocPopoverProps.footer);
|
|
37
|
+
const slots = {
|
|
38
|
+
breadcrumb: defaultSlots.breadcrumb ?? Breadcrumb,
|
|
39
|
+
footer: defaultSlots.footer ?? Footer,
|
|
40
|
+
toc: defaultSlots.toc ?? {
|
|
41
|
+
provider: TOCProvider,
|
|
42
|
+
main: TOC,
|
|
43
|
+
popover: TOCPopover
|
|
44
|
+
},
|
|
45
|
+
container: defaultSlots.container ?? Container
|
|
46
|
+
};
|
|
47
|
+
return /* @__PURE__ */ jsx(PageContext, {
|
|
48
|
+
value: {
|
|
49
|
+
props: { full },
|
|
50
|
+
slots
|
|
51
|
+
},
|
|
52
|
+
children: /* @__PURE__ */ jsxs(slots.toc.provider, {
|
|
53
|
+
single,
|
|
54
|
+
toc: tocEnabled || tocPopoverEnabled ? toc : [],
|
|
55
|
+
children: [
|
|
56
|
+
tocPopoverEnabled && (tocPopoverProps.component ?? /* @__PURE__ */ jsx(slots.toc.popover, { ...tocPopoverProps })),
|
|
57
|
+
/* @__PURE__ */ jsxs(slots.container, {
|
|
58
|
+
...containerProps,
|
|
59
|
+
children: [
|
|
60
|
+
breadcrumbEnabled && (breadcrumb.component ?? /* @__PURE__ */ jsx(slots.breadcrumb, { ...breadcrumb })),
|
|
61
|
+
children,
|
|
62
|
+
footerEnabled && (footer.component ?? /* @__PURE__ */ jsx(slots.footer, { ...footer }))
|
|
63
|
+
]
|
|
64
|
+
}),
|
|
65
|
+
tocEnabled && (tocProps.component ?? /* @__PURE__ */ jsx(slots.toc.main, { ...tocProps }))
|
|
66
|
+
]
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
}
|
|
25
70
|
function EditOnGitHub(props) {
|
|
26
71
|
return /* @__PURE__ */ jsx("a", {
|
|
27
72
|
target: "_blank",
|
|
@@ -29,10 +74,9 @@ function EditOnGitHub(props) {
|
|
|
29
74
|
...props,
|
|
30
75
|
className: cn(buttonVariants({
|
|
31
76
|
color: "secondary",
|
|
32
|
-
size: "sm"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
children: props.children ?? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Edit, { className: "size-3.5" }), /* @__PURE__ */ jsx(I18nLabel, { label: "editOnGithub" })] })
|
|
77
|
+
size: "sm"
|
|
78
|
+
}), "gap-1.5 not-prose", props.className),
|
|
79
|
+
children: props.children ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Edit, { className: "size-3.5" }), /* @__PURE__ */ jsx(I18nLabel, { label: "editOnGithub" })] })
|
|
36
80
|
});
|
|
37
81
|
}
|
|
38
82
|
/**
|
|
@@ -60,5 +104,21 @@ function DocsTitle({ children, className, ...props }) {
|
|
|
60
104
|
children
|
|
61
105
|
});
|
|
62
106
|
}
|
|
107
|
+
function PageLastUpdate({ date: value, ...props }) {
|
|
108
|
+
const { text } = useI18n();
|
|
109
|
+
const [date, setDate] = useState("");
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
setDate(value.toLocaleDateString());
|
|
112
|
+
}, [value]);
|
|
113
|
+
return /* @__PURE__ */ jsxs("p", {
|
|
114
|
+
...props,
|
|
115
|
+
className: cn("text-sm text-fd-muted-foreground", props.className),
|
|
116
|
+
children: [
|
|
117
|
+
text.lastUpdate,
|
|
118
|
+
" ",
|
|
119
|
+
date
|
|
120
|
+
]
|
|
121
|
+
});
|
|
122
|
+
}
|
|
63
123
|
//#endregion
|
|
64
124
|
export { DocsBody, DocsDescription, DocsPage, DocsTitle, EditOnGitHub, MarkdownCopyButton, Breadcrumb as PageBreadcrumb, Footer as PageFooter, PageLastUpdate, ViewOptionsPopover, page_exports, useDocsPage };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { cn } from "../../../../utils/cn.js";
|
|
2
|
-
import { useDocsPage } from "../
|
|
3
|
+
import { useDocsPage } from "../index.js";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
//#region src/layouts/notebook/page/slots/container.tsx
|
|
5
6
|
function Container(props) {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { TOCProviderProps as TOCProviderProps$1 } from "../../../../components/toc/index.js";
|
|
1
2
|
import { ComponentProps, ReactNode } from "react";
|
|
2
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
4
|
|
|
4
5
|
//#region src/layouts/notebook/page/slots/toc.d.ts
|
|
6
|
+
type TOCProviderProps = TOCProviderProps$1;
|
|
7
|
+
declare function TOCProvider(props: TOCProviderProps): react_jsx_runtime0.JSX.Element;
|
|
5
8
|
interface TOCProps {
|
|
6
9
|
container?: ComponentProps<'div'>;
|
|
7
10
|
/**
|
|
@@ -23,5 +26,30 @@ declare function TOC({
|
|
|
23
26
|
footer,
|
|
24
27
|
style
|
|
25
28
|
}: TOCProps): react_jsx_runtime0.JSX.Element;
|
|
29
|
+
interface TOCPopoverProps {
|
|
30
|
+
container?: ComponentProps<'div'>;
|
|
31
|
+
trigger?: ComponentProps<'button'>;
|
|
32
|
+
content?: ComponentProps<'div'>;
|
|
33
|
+
/**
|
|
34
|
+
* Custom content in TOC container, before the main TOC
|
|
35
|
+
*/
|
|
36
|
+
header?: ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* Custom content in TOC container, after the main TOC
|
|
39
|
+
*/
|
|
40
|
+
footer?: ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* @defaultValue 'normal'
|
|
43
|
+
*/
|
|
44
|
+
style?: 'normal' | 'clerk';
|
|
45
|
+
}
|
|
46
|
+
declare function TOCPopover({
|
|
47
|
+
container,
|
|
48
|
+
trigger,
|
|
49
|
+
content,
|
|
50
|
+
header,
|
|
51
|
+
footer,
|
|
52
|
+
style
|
|
53
|
+
}: TOCPopoverProps): react_jsx_runtime0.JSX.Element;
|
|
26
54
|
//#endregion
|
|
27
|
-
export { TOC, TOCProps };
|
|
55
|
+
export { TOC, TOCPopover, TOCPopoverProps, TOCProps, TOCProvider, TOCProviderProps };
|