@fumadocs/base-ui 16.15.18 → 16.16.1

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.
Files changed (45) hide show
  1. package/css/generated/docs.css +1 -1
  2. package/css/generated/flux.css +1 -1
  3. package/css/generated/glass.css +1 -1
  4. package/css/generated/notebook.css +1 -1
  5. package/css/generated/shared.css +1 -1
  6. package/css/generated/spacious.css +1 -0
  7. package/css/lib/base.css +26 -1
  8. package/dist/.translations/index.d.ts +3 -0
  9. package/dist/.translations/keys.js +3 -0
  10. package/dist/components/toc/block.js +4 -2
  11. package/dist/layouts/docs/client.d.ts +1 -0
  12. package/dist/layouts/docs/client.js +9 -3
  13. package/dist/layouts/docs/index.d.ts +2 -1
  14. package/dist/layouts/docs/page/slots/toc.js +2 -1
  15. package/dist/layouts/docs/slots/container.js +1 -8
  16. package/dist/layouts/glass/index.d.ts +11 -13
  17. package/dist/layouts/glass/index.js +11 -6
  18. package/dist/layouts/glass/page/slots/toc.js +3 -1
  19. package/dist/layouts/glass/slots/header.js +1 -1
  20. package/dist/layouts/notebook/client.d.ts +1 -0
  21. package/dist/layouts/notebook/client.js +9 -3
  22. package/dist/layouts/notebook/index.d.ts +2 -1
  23. package/dist/layouts/notebook/page/slots/toc.js +2 -1
  24. package/dist/layouts/notebook/slots/container.js +6 -12
  25. package/dist/layouts/shared/client.d.ts +1 -1
  26. package/dist/layouts/shared/client.js +17 -1
  27. package/dist/layouts/shared/index.d.ts +8 -0
  28. package/dist/layouts/spacious/index.d.ts +37 -0
  29. package/dist/layouts/spacious/index.js +80 -0
  30. package/dist/layouts/spacious/page/index.d.ts +56 -0
  31. package/dist/layouts/spacious/page/index.js +150 -0
  32. package/dist/layouts/spacious/page/slots/breadcrumb.d.ts +10 -0
  33. package/dist/layouts/spacious/page/slots/breadcrumb.js +51 -0
  34. package/dist/layouts/spacious/page/slots/footer.d.ts +15 -0
  35. package/dist/layouts/spacious/page/slots/footer.js +61 -0
  36. package/dist/layouts/spacious/page/slots/toc.d.ts +44 -0
  37. package/dist/layouts/spacious/page/slots/toc.js +208 -0
  38. package/dist/layouts/spacious/slots/actions.d.ts +5 -0
  39. package/dist/layouts/spacious/slots/actions.js +224 -0
  40. package/dist/layouts/spacious/slots/header.d.ts +5 -0
  41. package/dist/layouts/spacious/slots/header.js +34 -0
  42. package/dist/layouts/spacious/slots/sidebar.d.ts +9 -0
  43. package/dist/layouts/spacious/slots/sidebar.js +305 -0
  44. package/dist/style.css +600 -18
  45. package/package.json +17 -9
@@ -2,35 +2,29 @@
2
2
  import { cn } from "../../../utils/cn.js";
3
3
  import { useNotebookLayout } from "../client.js";
4
4
  import { jsx } from "react/jsx-runtime";
5
- import { useEffect, useState } from "react";
6
5
  //#region src/layouts/notebook/slots/container.tsx
7
6
  function Container(props) {
8
- const { props: { nav }, slots } = useNotebookLayout();
9
- const pageCol = "calc(var(--fd-layout-width,97rem) - var(--fd-sidebar-col) - var(--fd-toc-width))";
7
+ const { props: { nav, aiChat }, slots } = useNotebookLayout();
8
+ const pageCol = "calc(var(--fd-layout-width,97rem) - var(--fd-sidebar-col) - var(--fd-toc-col))";
10
9
  const { collapsed } = slots.sidebar?.useSidebar?.() ?? {};
11
- const [previousCollapsed, setPreviousCollapsed] = useState(collapsed);
12
- const isCollapseChanged = previousCollapsed !== collapsed;
13
- useEffect(() => {
14
- if (isCollapseChanged) setPreviousCollapsed(collapsed);
15
- }, [collapsed, isCollapseChanged]);
10
+ const aiChatOpen = Boolean(aiChat?.open && aiChat.panel);
16
11
  return /* @__PURE__ */ jsx("div", {
17
12
  id: "nd-notebook-layout",
18
13
  "data-sidebar-collapsed": collapsed,
19
- "data-column-changed": isCollapseChanged,
20
14
  ...props,
21
15
  style: {
22
16
  gridTemplate: nav?.mode === "top" ? `". header header header ."
23
17
  "sidebar sidebar toc-popover toc-popover ."
24
- "sidebar sidebar main toc ." 1fr / minmax(min-content, 1fr) var(--fd-sidebar-col) minmax(0, ${pageCol}) var(--fd-toc-width) minmax(min-content, 1fr)` : `"sidebar sidebar header header ."
18
+ "sidebar sidebar main toc ." 1fr / minmax(min-content, 1fr) var(--fd-sidebar-col) minmax(0, ${pageCol}) var(--fd-toc-col) minmax(min-content, 1fr)` : `"sidebar sidebar header header ."
25
19
  "sidebar sidebar toc-popover toc-popover ."
26
- "sidebar sidebar main toc ." 1fr / minmax(min-content, 1fr) var(--fd-sidebar-col) minmax(0, ${pageCol}) var(--fd-toc-width) minmax(min-content, 1fr)`,
20
+ "sidebar sidebar main toc ." 1fr / minmax(min-content, 1fr) var(--fd-sidebar-col) minmax(0, ${pageCol}) var(--fd-toc-col) minmax(min-content, 1fr)`,
27
21
  "--fd-docs-row-1": "var(--fd-banner-height, 0px)",
28
22
  "--fd-docs-row-2": "calc(var(--fd-docs-row-1) + var(--fd-header-height))",
29
23
  "--fd-docs-row-3": "calc(var(--fd-docs-row-2) + var(--fd-toc-popover-height))",
30
24
  "--fd-sidebar-col": collapsed ? "0px" : "var(--fd-sidebar-width)",
31
25
  ...props.style
32
26
  },
33
- className: cn("grid overflow-x-clip min-h-(--fd-docs-height) auto-cols-auto auto-rows-auto [--fd-docs-height:100dvh] [--fd-header-height:0px] [--fd-toc-popover-height:0px] [--fd-sidebar-width:0px] [--fd-toc-width:0px] data-[column-changed=true]:transition-[grid-template-columns]", props.className),
27
+ className: cn("grid overflow-x-clip min-h-(--fd-docs-height) auto-cols-auto auto-rows-auto [--fd-docs-height:100dvh] [--fd-header-height:0px] [--fd-toc-popover-height:0px] [--fd-sidebar-width:0px] [--fd-toc-width:0px] [--fd-toc-col:max(var(--fd-toc-width),var(--fd-ai-chat-col))] [transition:--fd-sidebar-col_150ms,--fd-ai-chat-col_300ms_ease-in-out]", aiChatOpen && "xl:[--fd-ai-chat-col:var(--fd-ai-chat-width)]", props.className),
34
28
  children: props.children
35
29
  });
36
30
  }
@@ -2,7 +2,7 @@ import { LanguageSelectProps, LanguageSelectTextProps } from "./slots/language-s
2
2
  import { FullSearchTriggerProps, SearchTriggerProps } from "./slots/search-trigger.js";
3
3
  import { ThemeSwitchProps } from "./slots/theme-switch.js";
4
4
  import { BaseLayoutProps, LinkItemType } from "./index.js";
5
- import { ComponentProps, FC } from "react";
5
+ import { ComponentProps, FC, ReactNode } from "react";
6
6
  //#region src/layouts/shared/client.d.ts
7
7
  export declare function LinkItem({ ref, item, ...props }: Omit<ComponentProps<'a'>, 'href'> & {
8
8
  item: Extract<LinkItemType, {
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { cn } from "../../utils/cn.js";
2
3
  import { useI18n } from "../../contexts/i18n.js";
3
4
  import { LanguageSelect, LanguageSelectText } from "./slots/language-select.js";
4
5
  import { FullSearchTrigger, SearchTrigger } from "./slots/search-trigger.js";
@@ -7,6 +8,7 @@ import { isLinkItemActive } from "./index.js";
7
8
  import Link from "fumadocs-core/link";
8
9
  import { usePathname } from "fumadocs-core/framework";
9
10
  import { jsx } from "react/jsx-runtime";
11
+ import { useState } from "react";
10
12
  //#region src/layouts/shared/client.tsx
11
13
  function LinkItem({ ref, item, ...props }) {
12
14
  const pathname = usePathname();
@@ -20,6 +22,20 @@ function LinkItem({ ref, item, ...props }) {
20
22
  children: props.children
21
23
  });
22
24
  }
25
+ /**
26
+ * The place of AI chat, docked by the layout on wide viewports, and floating on smaller ones.
27
+ */
28
+ function AIChatPanel({ open, className, children }) {
29
+ const [mounted, setMounted] = useState(open);
30
+ if (open && !mounted) setMounted(true);
31
+ return /* @__PURE__ */ jsx("aside", {
32
+ className: cn("z-40 overflow-clip bg-fd-card text-fd-card-foreground layout:[--fd-ai-chat-width:min(--spacing(100),100vw---spacing(4))] transition-[width,margin,translate,visibility] duration-300 ease-in-out motion-reduce:transition-none max-xl:fixed max-xl:inset-y-2 max-xl:end-2 max-xl:w-(--fd-ai-chat-width) max-xl:rounded-2xl max-xl:border max-xl:shadow-xl", open ? "w-(--fd-ai-chat-width)" : "invisible w-0 max-xl:translate-x-[calc(100%+--spacing(2))] rtl:max-xl:-translate-x-[calc(100%+--spacing(2))]", className),
33
+ children: /* @__PURE__ */ jsx("div", {
34
+ className: "flex flex-col size-full xl:w-(--fd-ai-chat-width)",
35
+ children: mounted && children
36
+ })
37
+ });
38
+ }
23
39
  function baseSlots({ useProps }) {
24
40
  function InlineThemeSwitch(props) {
25
41
  const { themeSwitch } = useProps();
@@ -82,4 +98,4 @@ function baseSlots({ useProps }) {
82
98
  } };
83
99
  }
84
100
  //#endregion
85
- export { LinkItem, baseSlots };
101
+ export { AIChatPanel, LinkItem, baseSlots };
@@ -59,6 +59,14 @@ interface ThemeSwitchOptions extends ThemeSwitchProps {
59
59
  /** @deprecated use `slots.themeSwitch` instead */
60
60
  component?: ReactNode;
61
61
  }
62
+ export interface AIChatOptions {
63
+ open: boolean;
64
+ onOpenChange: (open: boolean) => void;
65
+ /**
66
+ * The chat panel, placed beside the page on wide viewports, and floating over it on smaller ones.
67
+ */
68
+ panel?: ReactNode;
69
+ }
62
70
  export interface LayoutTab {
63
71
  /**
64
72
  * Redirect URL of the folder, usually the index page
@@ -0,0 +1,37 @@
1
+ import { BaseSlots, BaseSlotsProps } from "../shared/client.js";
2
+ import { AIChatOptions, BaseLayoutProps, GetLayoutTabsOptions, LayoutTab, LinkItemType } from "../shared/index.js";
3
+ import { SidebarProps, SidebarProviderProps } from "./slots/sidebar.js";
4
+ import { ComponentProps, FC } from "react";
5
+ import * as PageTree from "fumadocs-core/page-tree";
6
+ //#region src/layouts/spacious/index.d.ts
7
+ export interface DocsSlots extends BaseSlots {
8
+ header: FC<ComponentProps<'header'>>;
9
+ /**
10
+ * The actions at the top right of page panel
11
+ */
12
+ actions: FC<ComponentProps<'div'>>;
13
+ sidebar: {
14
+ provider: FC<SidebarProviderProps>;
15
+ main: FC<SidebarProps>;
16
+ drawer: FC;
17
+ };
18
+ }
19
+ export interface DocsLayoutProps extends BaseLayoutProps {
20
+ tree: PageTree.Root;
21
+ tabs?: LayoutTab[] | GetLayoutTabsOptions | false;
22
+ aiChat?: AIChatOptions;
23
+ sidebar?: Omit<SidebarProviderProps, 'children'>;
24
+ slots?: Partial<DocsSlots>;
25
+ }
26
+ interface SlotsProps extends BaseSlotsProps<DocsLayoutProps> {
27
+ tabs: LayoutTab[];
28
+ aiChat?: DocsLayoutProps['aiChat'];
29
+ }
30
+ export declare function useSpaciousLayout(): {
31
+ props: SlotsProps;
32
+ navItems: LinkItemType[];
33
+ menuItems: LinkItemType[];
34
+ slots: DocsSlots;
35
+ };
36
+ export declare function DocsLayout(props: DocsLayoutProps): import("react").JSX.Element;
37
+ //#endregion
@@ -0,0 +1,80 @@
1
+ "use client";
2
+ import { cn } from "../../utils/cn.js";
3
+ import { TreeContextProvider } from "../../contexts/tree.js";
4
+ import { AIChatPanel, baseSlots } from "../shared/client.js";
5
+ import { getLayoutTabs, useLinkItems } from "../shared/index.js";
6
+ import { Sidebar, SidebarDrawer, SidebarProvider } from "./slots/sidebar.js";
7
+ import { Header } from "./slots/header.js";
8
+ import { HeaderActions } from "./slots/actions.js";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ import { createContext, use, useMemo } from "react";
11
+ //#region src/layouts/spacious/index.tsx
12
+ const LayoutContext = createContext(null);
13
+ function useSpaciousLayout() {
14
+ const context = use(LayoutContext);
15
+ if (!context) throw new Error("Please use Spacious layout components under <DocsLayout /> (`fumadocs-ui/layouts/spacious`).");
16
+ return context;
17
+ }
18
+ const { useBaseSlots } = baseSlots({ useProps() {
19
+ return useSpaciousLayout().props;
20
+ } });
21
+ function DocsLayout(props) {
22
+ const { tree, tabs: tabsOptions, aiChat, sidebar, slots: customSlots = {}, children } = props;
23
+ const linkItems = useLinkItems(props);
24
+ const { baseSlots, baseProps } = useBaseSlots(props);
25
+ const tabs = useMemo(() => {
26
+ if (Array.isArray(tabsOptions)) return tabsOptions;
27
+ if (tabsOptions === false) return [];
28
+ return getLayoutTabs(tree, {
29
+ transform: (option) => option,
30
+ ...tabsOptions
31
+ });
32
+ }, [tree, tabsOptions]);
33
+ const slots = {
34
+ ...baseSlots,
35
+ header: customSlots.header ?? Header,
36
+ actions: customSlots.actions ?? HeaderActions,
37
+ sidebar: customSlots.sidebar ?? {
38
+ provider: SidebarProvider,
39
+ main: Sidebar,
40
+ drawer: SidebarDrawer
41
+ }
42
+ };
43
+ return /* @__PURE__ */ jsx(LayoutContext, {
44
+ value: {
45
+ props: {
46
+ tabs,
47
+ aiChat,
48
+ ...baseProps
49
+ },
50
+ slots,
51
+ ...linkItems
52
+ },
53
+ children: /* @__PURE__ */ jsx(TreeContextProvider, {
54
+ tree,
55
+ children: /* @__PURE__ */ jsx(slots.sidebar.provider, {
56
+ ...sidebar,
57
+ children: /* @__PURE__ */ jsxs("div", {
58
+ id: "fd-spacious-layout",
59
+ className: "relative grid min-h-(--fd-layout-height) bg-fd-card transition-[grid-template-columns] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none [--fd-layout-height:calc(100dvh-var(--fd-banner-height,0px))] [--fd-header-height:--spacing(14)] [--fd-page-width:760px] [--fd-sidebar-width:0px] [--fd-sidebar-col:var(--fd-sidebar-width)] [--fd-toc-width:0px] max-md:[--fd-docs-row-3:calc(var(--fd-banner-height,0px)+var(--fd-header-height)+var(--fd-toc-popover-height,0px))] md:h-(--fd-layout-height) md:overflow-clip print:h-auto print:overflow-visible",
60
+ style: { gridTemplate: `"sidebar header right" auto
61
+ "sidebar toc-popover right" auto
62
+ "sidebar main right" 1fr / var(--fd-sidebar-col) minmax(0, 1fr) auto` },
63
+ children: [
64
+ /* @__PURE__ */ jsx(slots.sidebar.main, {}),
65
+ /* @__PURE__ */ jsx(slots.header, {}),
66
+ children,
67
+ aiChat?.panel && /* @__PURE__ */ jsx(AIChatPanel, {
68
+ open: aiChat.open,
69
+ className: cn("[grid-area:right] xl:my-2 xl:rounded-2xl xl:border xl:bg-fd-background xl:shadow-sm", aiChat.open && "xl:me-2"),
70
+ children: aiChat.panel
71
+ }),
72
+ /* @__PURE__ */ jsx(slots.sidebar.drawer, {})
73
+ ]
74
+ })
75
+ })
76
+ })
77
+ });
78
+ }
79
+ //#endregion
80
+ export { DocsLayout, useSpaciousLayout };
@@ -0,0 +1,56 @@
1
+ import { MarkdownCopyButton, ViewOptionsPopover } from "../../shared/page-actions.js";
2
+ import { TOCDropdownProps, TOCPopoverProps, TOCProps, TOCProviderProps } from "./slots/toc.js";
3
+ import { Footer, FooterProps } from "./slots/footer.js";
4
+ import { Breadcrumb, BreadcrumbProps } from "./slots/breadcrumb.js";
5
+ import { ComponentProps, FC } from "react";
6
+ import { TOCItemType } from "fumadocs-core/toc";
7
+ //#region src/layouts/spacious/page/index.d.ts
8
+ interface DocsPageSlots {
9
+ toc: {
10
+ provider: FC<TOCProviderProps>;
11
+ main: FC<TOCProps>;
12
+ popover: FC<TOCPopoverProps>;
13
+ dropdown: FC<TOCDropdownProps>;
14
+ };
15
+ footer: FC<FooterProps>;
16
+ breadcrumb: FC<BreadcrumbProps>;
17
+ }
18
+ export interface DocsPageProps extends ComponentProps<'article'> {
19
+ toc?: TOCItemType[];
20
+ /**
21
+ * Extend the page to fill all available space
22
+ *
23
+ * @defaultValue false
24
+ */
25
+ full?: boolean;
26
+ slots?: Partial<DocsPageSlots>;
27
+ footer?: FooterProps & {
28
+ enabled?: boolean;
29
+ };
30
+ breadcrumb?: BreadcrumbProps & {
31
+ enabled?: boolean;
32
+ };
33
+ tableOfContent?: TOCProps & Pick<TOCProviderProps, 'single'> & {
34
+ enabled?: boolean;
35
+ };
36
+ tableOfContentPopover?: TOCPopoverProps & {
37
+ enabled?: boolean;
38
+ };
39
+ }
40
+ export declare function useDocsPage(): {
41
+ full: boolean;
42
+ slots: DocsPageSlots;
43
+ };
44
+ export declare function DocsPage({ full, toc, tableOfContent: { enabled: tocEnabled, single, ...tocProps }, tableOfContentPopover: { enabled: tocPopoverEnabled, ...tocPopoverProps }, breadcrumb: { enabled: breadcrumbEnabled, ...breadcrumb }, footer: { enabled: footerEnabled, ...footer }, slots: customSlots, className, children, ...props }: DocsPageProps): import("react").JSX.Element;
45
+ export declare function EditOnGitHub(props: ComponentProps<'a'>): import("react").JSX.Element;
46
+ /**
47
+ * Add typography styles
48
+ */
49
+ export declare function DocsBody({ className, ...props }: ComponentProps<'div'>): import("react").JSX.Element;
50
+ export declare function DocsDescription({ children, className, ...props }: ComponentProps<'p'>): import("react").JSX.Element | null;
51
+ export declare function DocsTitle({ className, ...props }: ComponentProps<'h1'>): import("react").JSX.Element;
52
+ export declare function PageLastUpdate({ date: value, ...props }: Omit<ComponentProps<'p'>, 'children'> & {
53
+ date: Date;
54
+ }): import("react").JSX.Element;
55
+ //#endregion
56
+ export { type BreadcrumbProps, type FooterProps, MarkdownCopyButton, Breadcrumb as PageBreadcrumb, Footer as PageFooter, ViewOptionsPopover };
@@ -0,0 +1,150 @@
1
+ "use client";
2
+ import { cn } from "../../../utils/cn.js";
3
+ import { buttonVariants } from "../../../components/ui/button.js";
4
+ import { SidebarCollapseTrigger, useSidebar } from "../../../components/sidebar/base.js";
5
+ import { MarkdownCopyButton, ViewOptionsPopover } from "../../shared/page-actions.js";
6
+ import { useSpaciousLayout } from "../index.js";
7
+ import { TOC, TOCDropdown, TOCPopover, TOCProvider } from "./slots/toc.js";
8
+ import { Footer } from "./slots/footer.js";
9
+ import { Breadcrumb, useBreadcrumbItems } from "./slots/breadcrumb.js";
10
+ import { usePathname } from "fumadocs-core/framework";
11
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
+ import { EditIcon, SidebarIcon } from "lucide-react";
13
+ import { createContext, use, useSyncExternalStore } from "react";
14
+ import { useTranslations } from "@fuma-translate/react";
15
+ //#region src/layouts/spacious/page/index.tsx
16
+ const PageContext = createContext(null);
17
+ function useDocsPage() {
18
+ const context = use(PageContext);
19
+ if (!context) throw new Error("Please use page components under <DocsPage /> (`fumadocs-ui/layouts/spacious/page`).");
20
+ return context;
21
+ }
22
+ function DocsPage({ full = false, toc = [], tableOfContent: { enabled: tocEnabled = !full, single, ...tocProps } = {}, tableOfContentPopover: { enabled: tocPopoverEnabled, ...tocPopoverProps } = {}, breadcrumb: { enabled: breadcrumbEnabled = true, ...breadcrumb } = {}, footer: { enabled: footerEnabled = true, ...footer } = {}, slots: customSlots = {}, className, children, ...props }) {
23
+ tocPopoverEnabled ??= Boolean(toc.length > 0 || tocPopoverProps.header || tocPopoverProps.footer);
24
+ const slots = {
25
+ breadcrumb: customSlots.breadcrumb ?? Breadcrumb,
26
+ footer: customSlots.footer ?? Footer,
27
+ toc: customSlots.toc ?? {
28
+ provider: TOCProvider,
29
+ main: TOC,
30
+ popover: TOCPopover,
31
+ dropdown: TOCDropdown
32
+ }
33
+ };
34
+ const layout = useSpaciousLayout();
35
+ const { aiChat } = layout.props;
36
+ const hasFolders = useBreadcrumbItems(breadcrumb).length > 0 && breadcrumbEnabled;
37
+ const pathname = usePathname();
38
+ return /* @__PURE__ */ jsx(PageContext, {
39
+ value: {
40
+ full,
41
+ slots
42
+ },
43
+ children: /* @__PURE__ */ jsxs(slots.toc.provider, {
44
+ single,
45
+ toc: tocEnabled || tocPopoverEnabled ? toc : [],
46
+ children: [
47
+ tocPopoverEnabled && /* @__PURE__ */ jsx(slots.toc.popover, { ...tocPopoverProps }),
48
+ /* @__PURE__ */ jsxs("div", {
49
+ id: "nd-page-panel",
50
+ className: "@container relative flex flex-col min-w-0 min-h-0 [grid-area:main] mx-2 bg-fd-background md:ms-0 md:my-2 md:overflow-clip md:rounded-2xl md:border md:shadow-sm print:overflow-visible",
51
+ children: [/* @__PURE__ */ jsxs("header", {
52
+ className: cn("absolute inset-x-0 top-0 z-10 flex items-center gap-1.5 h-(--fd-header-height) ps-6 pe-4 bg-linear-to-b from-fd-background to-transparent pointer-events-none *:pointer-events-auto max-md:hidden", hasFolders || tocPopoverEnabled ? "from-50%" : "to-40%"),
53
+ children: [
54
+ /* @__PURE__ */ jsx(ExpandSidebar, {}),
55
+ breadcrumbEnabled && /* @__PURE__ */ jsx(slots.breadcrumb, { ...breadcrumb }),
56
+ tocPopoverEnabled && /* @__PURE__ */ jsxs("div", {
57
+ className: cn("flex items-center gap-1.5 min-w-0 transition-[opacity,visibility] duration-300 motion-reduce:transition-none", tocEnabled && !(aiChat?.open && aiChat.panel) && "invisible opacity-0 @max-5xl:visible @max-5xl:opacity-100 @max-5xl:transition-none"),
58
+ children: [hasFolders && /* @__PURE__ */ jsx("span", {
59
+ className: "text-sm text-fd-muted-foreground/50",
60
+ children: "/"
61
+ }), /* @__PURE__ */ jsx(slots.toc.dropdown, { ...tocPopoverProps })]
62
+ }),
63
+ /* @__PURE__ */ jsx(layout.slots.actions, { className: "ms-auto" })
64
+ ]
65
+ }), /* @__PURE__ */ jsxs("div", {
66
+ className: "flex flex-1 items-start px-4 md:min-h-0 md:pt-(--fd-header-height) md:px-[max(--spacing(6),calc((100%-var(--fd-page-width)-var(--fd-toc-width))/2))] md:overflow-y-auto md:overscroll-y-contain md:scrollbar-thin md:scrollbar-gutter-stable md:scroll-pt-(--fd-header-height) md:[&_[id]]:scroll-mt-2",
67
+ children: [/* @__PURE__ */ jsxs("article", {
68
+ id: "nd-page",
69
+ "data-full": full,
70
+ className: cn("flex flex-col gap-4 w-full min-w-0 max-w-(--fd-page-width) pt-6 pb-8 md:pb-16", full && "layout:[--fd-page-width:1200px]", className),
71
+ ...props,
72
+ children: [
73
+ breadcrumbEnabled && /* @__PURE__ */ jsx(slots.breadcrumb, {
74
+ ...breadcrumb,
75
+ className: cn("md:hidden", breadcrumb.className)
76
+ }),
77
+ children,
78
+ footerEnabled && /* @__PURE__ */ jsx(slots.footer, { ...footer })
79
+ ]
80
+ }), tocEnabled && /* @__PURE__ */ jsx(slots.toc.main, { ...tocProps })]
81
+ })]
82
+ }, pathname),
83
+ /* @__PURE__ */ jsx("div", { className: "fixed inset-x-2 bottom-0 top-(--fd-docs-row-3) supports-[top:anchor(--a_bottom)]:top-[anchor(--fd-top-bar_bottom)] z-20 rounded-t-2xl border-x border-t outline-8 outline-fd-card bg-origin-border bg-[linear-gradient(var(--color-fd-background),transparent_16px)] pointer-events-none md:hidden" })
84
+ ]
85
+ })
86
+ });
87
+ }
88
+ function ExpandSidebar() {
89
+ const { collapsed } = useSidebar();
90
+ if (!collapsed) return;
91
+ return /* @__PURE__ */ jsx(SidebarCollapseTrigger, {
92
+ className: cn(buttonVariants({
93
+ variant: "ghost",
94
+ size: "icon-sm"
95
+ }), "-ms-2 size-8 text-fd-muted-foreground"),
96
+ children: /* @__PURE__ */ jsx(SidebarIcon, {})
97
+ });
98
+ }
99
+ function EditOnGitHub(props) {
100
+ const t = useTranslations({ note: "edit page" });
101
+ return /* @__PURE__ */ jsx("a", {
102
+ target: "_blank",
103
+ rel: "noreferrer noopener",
104
+ ...props,
105
+ className: cn(buttonVariants({
106
+ variant: "secondary",
107
+ size: "sm"
108
+ }), "gap-1.5 not-prose", props.className),
109
+ children: props.children ?? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(EditIcon, { className: "size-3.5" }), t("Edit on GitHub")] })
110
+ });
111
+ }
112
+ /**
113
+ * Add typography styles
114
+ */
115
+ function DocsBody({ className, ...props }) {
116
+ return /* @__PURE__ */ jsx("div", {
117
+ ...props,
118
+ className: cn("prose flex-1", className)
119
+ });
120
+ }
121
+ function DocsDescription({ children, className, ...props }) {
122
+ if (children === void 0) return null;
123
+ return /* @__PURE__ */ jsx("p", {
124
+ ...props,
125
+ className: cn("mb-8 text-lg text-fd-muted-foreground", className),
126
+ children
127
+ });
128
+ }
129
+ function DocsTitle({ className, ...props }) {
130
+ return /* @__PURE__ */ jsx("h1", {
131
+ ...props,
132
+ className: cn("text-[1.75em] font-semibold", className)
133
+ });
134
+ }
135
+ const subscribe = () => () => {};
136
+ function PageLastUpdate({ date: value, ...props }) {
137
+ const t = useTranslations({ note: "page footer" });
138
+ const date = useSyncExternalStore(subscribe, () => value.toLocaleDateString(), () => "");
139
+ return /* @__PURE__ */ jsxs("p", {
140
+ ...props,
141
+ className: cn("text-sm text-fd-muted-foreground", props.className),
142
+ children: [
143
+ t("Last updated on"),
144
+ " ",
145
+ date
146
+ ]
147
+ });
148
+ }
149
+ //#endregion
150
+ export { DocsBody, DocsDescription, DocsPage, DocsTitle, EditOnGitHub, MarkdownCopyButton, Breadcrumb as PageBreadcrumb, Footer as PageFooter, PageLastUpdate, ViewOptionsPopover, useDocsPage };
@@ -0,0 +1,10 @@
1
+ import { ComponentProps } from "react";
2
+ import { BreadcrumbOptions } from "fumadocs-core/breadcrumb";
3
+ //#region src/layouts/spacious/page/slots/breadcrumb.d.ts
4
+ export type BreadcrumbProps = BreadcrumbOptions & ComponentProps<'nav'>;
5
+ export declare function useBreadcrumbItems({ includeRoot, includeSeparator, includePage }?: BreadcrumbOptions): import("fumadocs-core/breadcrumb").BreadcrumbItem[];
6
+ /**
7
+ * The folders of current page
8
+ */
9
+ export declare function Breadcrumb({ includeRoot, includeSeparator, includePage, className, ...props }: BreadcrumbProps): import("react").JSX.Element | undefined;
10
+ //#endregion
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import { cn } from "../../../../utils/cn.js";
3
+ import { useTreeContext, useTreePath } from "../../../../contexts/tree.js";
4
+ import Link from "fumadocs-core/link";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { Fragment as Fragment$1, useMemo } from "react";
7
+ import { getBreadcrumbItemsFromPath } from "fumadocs-core/breadcrumb";
8
+ //#region src/layouts/spacious/page/slots/breadcrumb.tsx
9
+ function useBreadcrumbItems({ includeRoot, includeSeparator, includePage } = {}) {
10
+ const path = useTreePath();
11
+ const { root } = useTreeContext();
12
+ return useMemo(() => getBreadcrumbItemsFromPath(root, path, {
13
+ includePage,
14
+ includeSeparator,
15
+ includeRoot
16
+ }), [
17
+ includePage,
18
+ includeRoot,
19
+ includeSeparator,
20
+ path,
21
+ root
22
+ ]);
23
+ }
24
+ /**
25
+ * The folders of current page
26
+ */
27
+ function Breadcrumb({ includeRoot, includeSeparator, includePage, className, ...props }) {
28
+ const items = useBreadcrumbItems({
29
+ includeRoot,
30
+ includeSeparator,
31
+ includePage
32
+ });
33
+ if (items.length === 0) return;
34
+ return /* @__PURE__ */ jsx("nav", {
35
+ className: cn("flex items-center gap-1.5 min-w-0 text-sm text-fd-muted-foreground", className),
36
+ ...props,
37
+ children: items.map((item, i) => /* @__PURE__ */ jsxs(Fragment$1, { children: [i > 0 && /* @__PURE__ */ jsx("span", {
38
+ className: "shrink-0 text-fd-muted-foreground/50",
39
+ children: "/"
40
+ }), item.url ? /* @__PURE__ */ jsx(Link, {
41
+ href: item.url,
42
+ className: "truncate transition-colors hover:text-fd-accent-foreground",
43
+ children: item.name
44
+ }) : /* @__PURE__ */ jsx("span", {
45
+ className: "truncate",
46
+ children: item.name
47
+ })] }, i))
48
+ });
49
+ }
50
+ //#endregion
51
+ export { Breadcrumb, useBreadcrumbItems };
@@ -0,0 +1,15 @@
1
+ import { ComponentProps } from "react";
2
+ import * as PageTree from "fumadocs-core/page-tree";
3
+ //#region src/layouts/spacious/page/slots/footer.d.ts
4
+ type Item = Pick<PageTree.Item, 'name' | 'description' | 'url'>;
5
+ export interface FooterProps extends ComponentProps<'nav'> {
6
+ /**
7
+ * Items including information for the next and previous page
8
+ */
9
+ items?: {
10
+ previous?: Item;
11
+ next?: Item;
12
+ };
13
+ }
14
+ export declare function Footer({ items, className, ...props }: FooterProps): import("react").JSX.Element | undefined;
15
+ //#endregion
@@ -0,0 +1,61 @@
1
+ "use client";
2
+ import { cn } from "../../../../utils/cn.js";
3
+ import { isActive } from "../../../../utils/urls.js";
4
+ import { useFooterItems } from "../../../../utils/use-footer-items.js";
5
+ import Link from "fumadocs-core/link";
6
+ import { usePathname } from "fumadocs-core/framework";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react";
9
+ import { useMemo } from "react";
10
+ import { useTranslations } from "@fuma-translate/react";
11
+ //#region src/layouts/spacious/page/slots/footer.tsx
12
+ function Footer({ items, className, ...props }) {
13
+ const footerList = useFooterItems();
14
+ const pathname = usePathname();
15
+ const { previous, next } = useMemo(() => {
16
+ if (items) return items;
17
+ const idx = footerList.findIndex((item) => isActive(item.url, pathname));
18
+ if (idx === -1) return {};
19
+ return {
20
+ previous: footerList[idx - 1],
21
+ next: footerList[idx + 1]
22
+ };
23
+ }, [
24
+ footerList,
25
+ items,
26
+ pathname
27
+ ]);
28
+ if (!previous && !next) return;
29
+ return /* @__PURE__ */ jsxs("nav", {
30
+ className: cn("@container grid grid-cols-2 gap-3 mt-8", className),
31
+ ...props,
32
+ children: [previous && /* @__PURE__ */ jsx(FooterItem, {
33
+ item: previous,
34
+ next: false
35
+ }), next && /* @__PURE__ */ jsx(FooterItem, {
36
+ item: next,
37
+ next: true
38
+ })]
39
+ });
40
+ }
41
+ function FooterItem({ item, next }) {
42
+ const t = useTranslations({ note: "pagination" });
43
+ const Icon = next ? ArrowRightIcon : ArrowLeftIcon;
44
+ return /* @__PURE__ */ jsxs(Link, {
45
+ href: item.url,
46
+ className: cn("group flex flex-col gap-1 rounded-2xl border p-4 text-sm transition-colors hover:bg-fd-accent/40 @max-md:col-span-full", next && "col-start-2 items-end text-end"),
47
+ children: [/* @__PURE__ */ jsxs("span", {
48
+ className: "inline-flex items-center gap-1.5 text-fd-muted-foreground",
49
+ children: [
50
+ !next && /* @__PURE__ */ jsx(Icon, { className: "size-3.5 transition-transform group-hover:-translate-x-0.5 rtl:rotate-180" }),
51
+ next ? t("Next Page") : t("Previous Page"),
52
+ next && /* @__PURE__ */ jsx(Icon, { className: "size-3.5 transition-transform group-hover:translate-x-0.5 rtl:rotate-180" })
53
+ ]
54
+ }), /* @__PURE__ */ jsx("span", {
55
+ className: "font-medium",
56
+ children: item.name
57
+ })]
58
+ });
59
+ }
60
+ //#endregion
61
+ export { Footer };
@@ -0,0 +1,44 @@
1
+ import { TOCItemsProps, default_d_exports } from "../../../../components/toc/default.js";
2
+ import { TOCItemsProps as TOCItemsProps$1, block_d_exports } from "../../../../components/toc/block.js";
3
+ import { TOCItemsProps as TOCItemsProps$2, clerk_d_exports } from "../../../../components/toc/clerk.js";
4
+ import { TOCProviderProps as TOCProviderProps$1, index_d_exports } from "../../../../components/toc/index.js";
5
+ import { ComponentProps, ReactNode } from "react";
6
+ //#region src/layouts/spacious/page/slots/toc.d.ts
7
+ export type TOCProviderProps = TOCProviderProps$1;
8
+ export declare function TOCProvider(props: TOCProviderProps): import("react").JSX.Element;
9
+ type TOCStyle = {
10
+ style?: 'block';
11
+ list?: TOCItemsProps$1;
12
+ } | {
13
+ style: 'normal';
14
+ list?: TOCItemsProps;
15
+ } | {
16
+ style: 'clerk';
17
+ list?: TOCItemsProps$2;
18
+ };
19
+ type TOCContent = {
20
+ /**
21
+ * Custom content in TOC container, before the main TOC
22
+ */
23
+ header?: ReactNode;
24
+ /**
25
+ * Custom content in TOC container, after the main TOC
26
+ */
27
+ footer?: ReactNode;
28
+ } & TOCStyle;
29
+ export type TOCProps = TOCContent & {
30
+ container?: ComponentProps<'div'>;
31
+ };
32
+ export declare function TOC({ container, header, footer, ...props }: TOCProps): import("react").JSX.Element | undefined;
33
+ export type TOCDropdownProps = TOCContent & {
34
+ trigger?: ComponentProps<'button'>;
35
+ content?: ComponentProps<'div'>;
36
+ };
37
+ export type TOCPopoverProps = TOCDropdownProps & {
38
+ container?: ComponentProps<'div'>;
39
+ };
40
+ /** the TOC bar for mobile */
41
+ export declare function TOCPopover({ container, trigger, content, header, footer, ...props }: TOCPopoverProps): import("react").JSX.Element;
42
+ /** the TOC dropdown for page header */
43
+ export declare function TOCDropdown({ trigger, content, header, footer, ...props }: TOCDropdownProps): import("react").JSX.Element;
44
+ //#endregion