@fumadocs/base-ui 16.7.1 → 16.7.3

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 (75) hide show
  1. package/css/generated/docs.css +5 -9
  2. package/css/generated/flux.css +3 -6
  3. package/css/generated/home.css +28 -14
  4. package/css/generated/notebook.css +5 -5
  5. package/css/generated/shared.css +63 -10
  6. package/dist/components/sidebar/base.js +1 -2
  7. package/dist/components/tabs.d.ts +9 -4
  8. package/dist/components/tabs.js +12 -13
  9. package/dist/components/toc/clerk.js +65 -29
  10. package/dist/components/toc/default.js +5 -3
  11. package/dist/components/toc/index.d.ts +4 -2
  12. package/dist/components/toc/index.js +46 -19
  13. package/dist/components/ui/collapsible.js +1 -1
  14. package/dist/components/ui/navigation-menu.d.ts +24 -12
  15. package/dist/components/ui/navigation-menu.js +47 -32
  16. package/dist/components/ui/popover.d.ts +7 -1
  17. package/dist/components/ui/popover.js +13 -13
  18. package/dist/components/ui/scroll-area.d.ts +15 -4
  19. package/dist/components/ui/scroll-area.js +26 -27
  20. package/dist/layouts/docs/client.d.ts +3 -3
  21. package/dist/layouts/docs/client.js +19 -22
  22. package/dist/layouts/docs/index.d.ts +1 -1
  23. package/dist/layouts/docs/page/index.d.ts +91 -3
  24. package/dist/layouts/docs/page/index.js +67 -7
  25. package/dist/layouts/docs/page/slots/breadcrumb.js +1 -0
  26. package/dist/layouts/docs/page/slots/container.js +2 -1
  27. package/dist/layouts/docs/page/slots/footer.js +1 -0
  28. package/dist/layouts/docs/page/slots/toc.js +3 -3
  29. package/dist/layouts/docs/slots/container.js +1 -0
  30. package/dist/layouts/docs/slots/header.js +1 -0
  31. package/dist/layouts/docs/slots/sidebar.js +9 -19
  32. package/dist/layouts/flux/index.d.ts +4 -4
  33. package/dist/layouts/flux/index.js +8 -11
  34. package/dist/layouts/flux/page/index.d.ts +79 -3
  35. package/dist/layouts/flux/page/index.js +61 -7
  36. package/dist/layouts/flux/page/slots/breadcrumb.js +1 -0
  37. package/dist/layouts/flux/page/slots/container.js +2 -1
  38. package/dist/layouts/flux/page/slots/footer.js +1 -0
  39. package/dist/layouts/flux/page/slots/toc.d.ts +4 -1
  40. package/dist/layouts/flux/page/slots/toc.js +6 -5
  41. package/dist/layouts/flux/slots/container.js +1 -0
  42. package/dist/layouts/flux/slots/sidebar.js +8 -13
  43. package/dist/layouts/home/index.d.ts +3 -3
  44. package/dist/layouts/home/index.js +11 -8
  45. package/dist/layouts/home/navbar.d.ts +2 -4
  46. package/dist/layouts/home/navbar.js +6 -9
  47. package/dist/layouts/home/slots/container.js +1 -0
  48. package/dist/layouts/home/slots/header.d.ts +2 -3
  49. package/dist/layouts/home/slots/header.js +125 -115
  50. package/dist/layouts/notebook/client.d.ts +3 -3
  51. package/dist/layouts/notebook/client.js +14 -17
  52. package/dist/layouts/notebook/index.d.ts +1 -1
  53. package/dist/layouts/notebook/page/index.d.ts +91 -3
  54. package/dist/layouts/notebook/page/index.js +67 -7
  55. package/dist/layouts/notebook/page/slots/breadcrumb.js +1 -0
  56. package/dist/layouts/notebook/page/slots/container.js +2 -1
  57. package/dist/layouts/notebook/page/slots/footer.js +1 -0
  58. package/dist/layouts/notebook/page/slots/toc.js +3 -3
  59. package/dist/layouts/notebook/slots/container.js +1 -0
  60. package/dist/layouts/notebook/slots/sidebar.js +9 -19
  61. package/dist/layouts/shared/client.d.ts +6 -6
  62. package/dist/layouts/shared/client.js +4 -4
  63. package/dist/layouts/shared/index.d.ts +3 -3
  64. package/dist/layouts/shared/page-actions.d.ts +2 -2
  65. package/dist/layouts/shared/page-actions.js +3 -3
  66. package/dist/page.d.ts +1 -2
  67. package/dist/page.js +1 -2
  68. package/dist/style.css +302 -60
  69. package/package.json +3 -3
  70. package/dist/layouts/docs/page/client.d.ts +0 -98
  71. package/dist/layouts/docs/page/client.js +0 -110
  72. package/dist/layouts/flux/page/client.d.ts +0 -82
  73. package/dist/layouts/flux/page/client.js +0 -94
  74. package/dist/layouts/notebook/page/client.d.ts +0 -98
  75. package/dist/layouts/notebook/page/client.js +0 -110
@@ -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";
6
+ import { TOC, TOCPopover, TOCProvider } from "./slots/toc.js";
5
7
  import { Footer } from "./slots/footer.js";
6
8
  import { Breadcrumb } from "./slots/breadcrumb.js";
7
- import { DocsPage, PageLastUpdate, useDocsPage } from "./client.js";
9
+ import { Container } from "./slots/container.js";
8
10
  import { MarkdownCopyButton, ViewOptionsPopover } from "../../shared/page-actions.js";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
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/docs/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/docs/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
- className: "gap-1.5 not-prose"
34
- }), props.className),
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,3 +1,4 @@
1
+ "use client";
1
2
  import { cn } from "../../../../utils/cn.js";
2
3
  import { useTreeContext, useTreePath } from "../../../../contexts/tree.js";
3
4
  import { Fragment, useMemo } from "react";
@@ -1,5 +1,6 @@
1
+ "use client";
1
2
  import { cn } from "../../../../utils/cn.js";
2
- import { useDocsPage } from "../client.js";
3
+ import { useDocsPage } from "../index.js";
3
4
  import { jsx } from "react/jsx-runtime";
4
5
  //#region src/layouts/docs/page/slots/container.tsx
5
6
  function Container(props) {
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { useI18n } from "../../../../contexts/i18n.js";
2
3
  import { cn } from "../../../../utils/cn.js";
3
4
  import { isActive } from "../../../../utils/urls.js";
@@ -36,13 +36,13 @@ const TocPopoverContext = createContext(null);
36
36
  function TOCPopover({ container, trigger, content, header, footer, style }) {
37
37
  return /* @__PURE__ */ jsxs(PageTOCPopover, {
38
38
  ...container,
39
- children: [/* @__PURE__ */ jsx(PageTOCPopoverTrigger, { ...trigger }), /* @__PURE__ */ jsxs(PageTOCPopoverContent, {
39
+ children: [/* @__PURE__ */ jsx(PageTOCPopoverTrigger, { ...trigger }), /* @__PURE__ */ jsx(PageTOCPopoverContent, {
40
40
  ...content,
41
- children: [
41
+ children: /* @__PURE__ */ jsxs("div", { children: [
42
42
  header,
43
43
  /* @__PURE__ */ jsx(TOCScrollArea, { children: style === "clerk" ? /* @__PURE__ */ jsx(TOCItems$1, {}) : /* @__PURE__ */ jsx(TOCItems, {}) }),
44
44
  footer
45
- ]
45
+ ] })
46
46
  })]
47
47
  });
48
48
  }
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { cn } from "../../../utils/cn.js";
2
3
  import { useDocsLayout } from "../client.js";
3
4
  import "../index.js";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { cn } from "../../../utils/cn.js";
2
3
  import { buttonVariants } from "../../../components/ui/button.js";
3
4
  import { useDocsLayout } from "../client.js";
@@ -6,8 +6,7 @@ import { Popover, PopoverContent, PopoverTrigger } from "../../../components/ui/
6
6
  import { SearchTrigger } from "../../shared/slots/search-trigger.js";
7
7
  import { LinkItem } from "../../shared/client.js";
8
8
  import { isLayoutTabActive } from "../../shared/index.js";
9
- import { ScrollArea, ScrollViewport } from "../../../components/ui/scroll-area.js";
10
- import { SidebarCollapseTrigger as SidebarCollapseTrigger$1, SidebarContent as SidebarContent$1, SidebarDrawerContent, SidebarDrawerOverlay, SidebarFolder as SidebarFolder$1, SidebarFolderContent as SidebarFolderContent$1, SidebarFolderLink as SidebarFolderLink$1, SidebarFolderTrigger as SidebarFolderTrigger$1, SidebarItem as SidebarItem$1, SidebarProvider as SidebarProvider$1, SidebarSeparator as SidebarSeparator$1, SidebarTrigger as SidebarTrigger$1, base_exports, useFolder, useFolderDepth } from "../../../components/sidebar/base.js";
9
+ import { SidebarCollapseTrigger as SidebarCollapseTrigger$1, SidebarContent as SidebarContent$1, SidebarDrawerContent, SidebarDrawerOverlay, SidebarFolder as SidebarFolder$1, SidebarFolderContent as SidebarFolderContent$1, SidebarFolderLink as SidebarFolderLink$1, SidebarFolderTrigger as SidebarFolderTrigger$1, SidebarItem as SidebarItem$1, SidebarProvider as SidebarProvider$1, SidebarSeparator as SidebarSeparator$1, SidebarTrigger as SidebarTrigger$1, SidebarViewport, base_exports, useFolder, useFolderDepth } from "../../../components/sidebar/base.js";
11
10
  import { createPageTreeRenderer } from "../../../components/sidebar/page-tree.js";
12
11
  import { createLinkItemRenderer } from "../../../components/sidebar/link-item.js";
13
12
  import { useDocsLayout } from "../client.js";
@@ -32,10 +31,13 @@ function SidebarProvider(props) {
32
31
  function Sidebar({ footer, banner, collapsible = true, components, ...rest }) {
33
32
  const { menuItems, slots, props: { tabs, nav, tabMode } } = useDocsLayout();
34
33
  const iconLinks = menuItems.filter((item) => item.type === "icon");
35
- const viewport = /* @__PURE__ */ jsxs(SidebarViewport, { children: [menuItems.filter((v) => v.type !== "icon").map((item, i, list) => /* @__PURE__ */ jsx(SidebarLinkItem, {
36
- item,
37
- className: cn(i === list.length - 1 && "mb-4")
38
- }, i)), /* @__PURE__ */ jsx(SidebarPageTree, { ...components })] });
34
+ const viewport = /* @__PURE__ */ jsx(SidebarViewport, { children: /* @__PURE__ */ jsxs("div", {
35
+ className: "flex flex-col gap-0.5",
36
+ children: [menuItems.filter((v) => v.type !== "icon").map((item, i, list) => /* @__PURE__ */ jsx(SidebarLinkItem, {
37
+ item,
38
+ className: cn(i === list.length - 1 && "mb-4")
39
+ }, i)), /* @__PURE__ */ jsx(SidebarPageTree, { ...components })]
40
+ }) });
39
41
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(SidebarContent, {
40
42
  ...rest,
41
43
  children: [
@@ -132,18 +134,6 @@ function SidebarFolder(props) {
132
134
  function SidebarCollapseTrigger(props) {
133
135
  return /* @__PURE__ */ jsx(SidebarCollapseTrigger$1, { ...props });
134
136
  }
135
- function SidebarViewport(props) {
136
- const { className, ...rest } = props;
137
- return /* @__PURE__ */ jsx(ScrollArea, {
138
- ...rest,
139
- className: (state) => cn("min-h-0 flex-1", typeof className === "function" ? className(state) : className),
140
- children: /* @__PURE__ */ jsx(ScrollViewport, {
141
- className: "*:flex! *:flex-col! *:gap-0.5! p-4 overscroll-contain",
142
- style: { maskImage: "linear-gradient(to bottom, transparent, white 12px, white calc(100% - 12px), transparent)" },
143
- children: props.children
144
- })
145
- });
146
- }
147
137
  function SidebarTrigger(props) {
148
138
  return /* @__PURE__ */ jsx(SidebarTrigger$1, { ...props });
149
139
  }
@@ -245,7 +235,7 @@ function SidebarFolderLink({ className, style, ...props }) {
245
235
  function SidebarFolderContent({ className, children, ...props }) {
246
236
  const depth = useFolderDepth();
247
237
  return /* @__PURE__ */ jsx(SidebarFolderContent$1, {
248
- className: (state) => cn("relative flex flex-col gap-0.5 *:first:mt-0.5", depth === 1 && "before:content-[''] before:absolute before:w-px before:inset-y-1 before:bg-fd-border before:start-2.5", typeof className === "function" ? className(state) : className),
238
+ className: (state) => cn("relative flex flex-col gap-0.5 pt-0.5", depth === 1 && "before:content-[''] before:absolute before:w-px before:inset-y-1 before:bg-fd-border before:start-2.5", typeof className === "function" ? className(state) : className),
249
239
  ...props,
250
240
  children
251
241
  });
@@ -9,9 +9,9 @@ import { motion } from "motion/react";
9
9
 
10
10
  //#region src/layouts/flux/index.d.ts
11
11
  interface DocsSlots extends BaseSlots {
12
- container?: FC<ComponentProps<'div'>>;
13
- tabDropdown?: FC<TabDropdownProps>;
14
- sidebar?: {
12
+ container: FC<ComponentProps<'div'>>;
13
+ tabDropdown: FC<TabDropdownProps>;
14
+ sidebar: {
15
15
  provider: FC<SidebarProviderProps>;
16
16
  trigger: FC<ComponentProps<'button'>>;
17
17
  root: FC<SidebarProps>;
@@ -26,7 +26,7 @@ interface DocsLayoutProps extends BaseLayoutProps {
26
26
  tree: PageTree.Root;
27
27
  sidebar?: SidebarOptions;
28
28
  tabs?: LayoutTab[] | GetLayoutTabsOptions | false;
29
- slots?: DocsSlots;
29
+ slots?: Partial<DocsSlots>;
30
30
  renderNavigationPanel?: (props: NavigationPanelProps) => ReactNode;
31
31
  containerProps?: ComponentProps<'div'>;
32
32
  }
@@ -44,16 +44,6 @@ function DocsLayout(props) {
44
44
  useSidebar
45
45
  }
46
46
  };
47
- let content = /* @__PURE__ */ jsxs(Fragment$1, { children: [sidebarEnabled && slots.sidebar && /* @__PURE__ */ jsx(slots.sidebar.root, { ...sidebarProps }), children] });
48
- if (slots.container) content = /* @__PURE__ */ jsx(slots.container, {
49
- ...containerProps,
50
- children: content
51
- });
52
- if (slots.sidebar) content = /* @__PURE__ */ jsx(slots.sidebar.provider, {
53
- defaultOpenLevel,
54
- prefetch,
55
- children: content
56
- });
57
47
  return /* @__PURE__ */ jsx(LayoutContext, {
58
48
  value: {
59
49
  props: baseProps,
@@ -62,7 +52,14 @@ function DocsLayout(props) {
62
52
  },
63
53
  children: /* @__PURE__ */ jsxs(TreeContextProvider, {
64
54
  tree,
65
- children: [content, renderNavigationPanel({
55
+ children: [/* @__PURE__ */ jsx(slots.sidebar.provider, {
56
+ defaultOpenLevel,
57
+ prefetch,
58
+ children: /* @__PURE__ */ jsxs(slots.container, {
59
+ ...containerProps,
60
+ children: [sidebarEnabled && /* @__PURE__ */ jsx(slots.sidebar.root, { ...sidebarProps }), children]
61
+ })
62
+ }), renderNavigationPanel({
66
63
  head: /* @__PURE__ */ jsxs(Fragment$1, { children: [slots.navTitle && /* @__PURE__ */ jsx(slots.navTitle, { className: "inline-flex items-center gap-2.5 text-sm font-semibold" }), nav.children] }),
67
64
  tabDropdown: slots.tabDropdown && tabs.length > 0 && /* @__PURE__ */ jsx(slots.tabDropdown, {
68
65
  className: "flex-1",
@@ -1,11 +1,81 @@
1
1
  import { MarkdownCopyButton, ViewOptionsPopover } from "../../shared/page-actions.js";
2
+ import { 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 { DocsPage, DocsPageProps, DocsPageSlots, PageLastUpdate, useDocsPage } from "./client.js";
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/flux/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
+ children?: ReactNode;
19
+ slots?: Partial<DocsPageSlots>;
20
+ footer?: FooterOptions;
21
+ breadcrumb?: BreadcrumbOptions;
22
+ tableOfContent?: TableOfContentOptions;
23
+ }
24
+ interface TableOfContentOptions extends Pick<TOCProviderProps, 'single'>, TOCProps {
25
+ enabled?: boolean;
26
+ /**
27
+ * @deprecated use `slots.toc` instead.
28
+ */
29
+ component?: ReactNode;
30
+ }
31
+ interface BreadcrumbOptions extends BreadcrumbProps {
32
+ enabled?: boolean;
33
+ /**
34
+ * @deprecated use `slots.breadcrumb` instead.
35
+ */
36
+ component?: ReactNode;
37
+ }
38
+ interface FooterOptions extends FooterProps {
39
+ enabled?: boolean;
40
+ /**
41
+ * @deprecated use `slots.footer` instead.
42
+ */
43
+ component?: ReactNode;
44
+ }
45
+ interface DocsPageSlots {
46
+ toc: {
47
+ provider: FC<TOCProviderProps>;
48
+ main: FC<TOCProps>;
49
+ };
50
+ container: FC<ComponentProps<'article'>>;
51
+ footer: FC<FooterProps>;
52
+ breadcrumb: FC<BreadcrumbProps>;
53
+ }
54
+ type PageSlotsProps = Pick<DocsPageProps, 'full'>;
55
+ declare function useDocsPage(): {
56
+ props: PageSlotsProps;
57
+ slots: DocsPageSlots;
58
+ };
59
+ declare function DocsPage({
60
+ tableOfContent: {
61
+ enabled: tocEnabled,
62
+ single,
63
+ ...tocProps
64
+ },
65
+ breadcrumb: {
66
+ enabled: breadcrumbEnabled,
67
+ ...breadcrumb
68
+ },
69
+ footer: {
70
+ enabled: footerEnabled,
71
+ ...footer
72
+ },
73
+ full,
74
+ toc,
75
+ slots: defaultSlots,
76
+ children,
77
+ ...containerProps
78
+ }: DocsPageProps): react_jsx_runtime0.JSX.Element;
9
79
  declare function EditOnGitHub(props: ComponentProps<'a'>): react_jsx_runtime0.JSX.Element;
10
80
  /**
11
81
  * Add typography styles
@@ -25,5 +95,11 @@ declare function DocsTitle({
25
95
  className,
26
96
  ...props
27
97
  }: ComponentProps<'h1'>): react_jsx_runtime0.JSX.Element;
98
+ declare function PageLastUpdate({
99
+ date: value,
100
+ ...props
101
+ }: Omit<ComponentProps<'p'>, 'children'> & {
102
+ date: Date;
103
+ }): react_jsx_runtime0.JSX.Element;
28
104
  //#endregion
29
- export { type BreadcrumbProps, DocsBody, DocsDescription, DocsPage, type DocsPageProps, type DocsPageSlots, DocsTitle, EditOnGitHub, type FooterProps, MarkdownCopyButton, Breadcrumb as PageBreadcrumb, Footer as PageFooter, PageLastUpdate, ViewOptionsPopover, useDocsPage };
105
+ export { type BreadcrumbProps, DocsBody, DocsDescription, DocsPage, DocsPageProps, DocsTitle, EditOnGitHub, type FooterProps, MarkdownCopyButton, Breadcrumb as PageBreadcrumb, Footer as PageFooter, PageLastUpdate, ViewOptionsPopover, useDocsPage };
@@ -1,13 +1,52 @@
1
- import { I18nLabel } from "../../../contexts/i18n.js";
1
+ "use client";
2
+ import { I18nLabel, useI18n } from "../../../contexts/i18n.js";
2
3
  import { cn } from "../../../utils/cn.js";
3
4
  import { buttonVariants } from "../../../components/ui/button.js";
4
5
  import { MarkdownCopyButton, ViewOptionsPopover } from "../../shared/page-actions.js";
6
+ import { TOC, TOCProvider } from "./slots/toc.js";
5
7
  import { Footer } from "./slots/footer.js";
6
8
  import { Breadcrumb } from "./slots/breadcrumb.js";
7
- import { DocsPage, PageLastUpdate, useDocsPage } from "./client.js";
8
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ import { Container } from "./slots/container.js";
10
+ import { createContext, use, useEffect, useState } from "react";
11
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
12
  import { Edit } from "lucide-react";
10
13
  //#region src/layouts/flux/page/index.tsx
14
+ const PageContext = createContext(null);
15
+ function useDocsPage() {
16
+ const context = use(PageContext);
17
+ if (!context) throw new Error("Please use page components under <DocsPage /> (`fumadocs-ui/layouts/flux/page`).");
18
+ return context;
19
+ }
20
+ function DocsPage({ tableOfContent: { enabled: tocEnabled, single, ...tocProps } = {}, breadcrumb: { enabled: breadcrumbEnabled = true, ...breadcrumb } = {}, footer: { enabled: footerEnabled = true, ...footer } = {}, full = false, toc = [], slots: defaultSlots = {}, children, ...containerProps }) {
21
+ tocEnabled ??= Boolean(toc.length > 0 || tocProps.header || tocProps.footer);
22
+ const slots = {
23
+ breadcrumb: defaultSlots.breadcrumb ?? Breadcrumb,
24
+ footer: defaultSlots.footer ?? Footer,
25
+ container: defaultSlots.container ?? Container,
26
+ toc: defaultSlots.toc ?? {
27
+ provider: TOCProvider,
28
+ main: TOC
29
+ }
30
+ };
31
+ return /* @__PURE__ */ jsx(PageContext, {
32
+ value: {
33
+ props: { full },
34
+ slots
35
+ },
36
+ children: /* @__PURE__ */ jsxs(slots.toc.provider, {
37
+ single,
38
+ toc: tocEnabled ? toc : [],
39
+ children: [tocEnabled && (tocProps.component ?? /* @__PURE__ */ jsx(slots.toc.main, { ...tocProps })), /* @__PURE__ */ jsxs(slots.container, {
40
+ ...containerProps,
41
+ children: [
42
+ breadcrumbEnabled && (breadcrumb.component ?? /* @__PURE__ */ jsx(slots.breadcrumb, { ...breadcrumb })),
43
+ children,
44
+ footerEnabled && (footer.component ?? /* @__PURE__ */ jsx(slots.footer, { ...footer }))
45
+ ]
46
+ })]
47
+ })
48
+ });
49
+ }
11
50
  function EditOnGitHub(props) {
12
51
  return /* @__PURE__ */ jsx("a", {
13
52
  target: "_blank",
@@ -15,10 +54,9 @@ function EditOnGitHub(props) {
15
54
  ...props,
16
55
  className: cn(buttonVariants({
17
56
  color: "secondary",
18
- size: "sm",
19
- className: "gap-1.5 not-prose"
20
- }), props.className),
21
- children: props.children ?? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Edit, { className: "size-3.5" }), /* @__PURE__ */ jsx(I18nLabel, { label: "editOnGithub" })] })
57
+ size: "sm"
58
+ }), "gap-1.5 not-prose", props.className),
59
+ children: props.children ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Edit, { className: "size-3.5" }), /* @__PURE__ */ jsx(I18nLabel, { label: "editOnGithub" })] })
22
60
  });
23
61
  }
24
62
  /**
@@ -46,5 +84,21 @@ function DocsTitle({ children, className, ...props }) {
46
84
  children
47
85
  });
48
86
  }
87
+ function PageLastUpdate({ date: value, ...props }) {
88
+ const { text } = useI18n();
89
+ const [date, setDate] = useState("");
90
+ useEffect(() => {
91
+ setDate(value.toLocaleDateString());
92
+ }, [value]);
93
+ return /* @__PURE__ */ jsxs("p", {
94
+ ...props,
95
+ className: cn("text-sm text-fd-muted-foreground", props.className),
96
+ children: [
97
+ text.lastUpdate,
98
+ " ",
99
+ date
100
+ ]
101
+ });
102
+ }
49
103
  //#endregion
50
104
  export { DocsBody, DocsDescription, DocsPage, DocsTitle, EditOnGitHub, MarkdownCopyButton, Breadcrumb as PageBreadcrumb, Footer as PageFooter, PageLastUpdate, ViewOptionsPopover, useDocsPage };
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { cn } from "../../../../utils/cn.js";
2
3
  import { useTreeContext, useTreePath } from "../../../../contexts/tree.js";
3
4
  import { Fragment, useMemo } from "react";
@@ -1,5 +1,6 @@
1
+ "use client";
1
2
  import { cn } from "../../../../utils/cn.js";
2
- import { useDocsPage } from "../client.js";
3
+ import { useDocsPage } from "../index.js";
3
4
  import { jsx } from "react/jsx-runtime";
4
5
  //#region src/layouts/flux/page/slots/container.tsx
5
6
  function Container(props) {
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { useI18n } from "../../../../contexts/i18n.js";
2
3
  import { cn } from "../../../../utils/cn.js";
3
4
  import { isActive } from "../../../../utils/urls.js";
@@ -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,16 +14,17 @@ 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,
20
- children: [/* @__PURE__ */ jsxs(PageTOCPopoverContent, {
21
+ children: [/* @__PURE__ */ jsx(PageTOCPopoverContent, {
21
22
  ...content,
22
- children: [
23
+ children: /* @__PURE__ */ jsxs("div", { children: [
23
24
  header,
24
25
  /* @__PURE__ */ jsx(TOCScrollArea, { children: style === "clerk" ? /* @__PURE__ */ jsx(TOCItems$1, {}) : /* @__PURE__ */ jsx(TOCItems, {}) }),
25
26
  footer
26
- ]
27
+ ] })
27
28
  }), /* @__PURE__ */ jsx(PageTOCPopoverTrigger, { ...trigger })]
28
29
  });
29
30
  }
@@ -166,4 +167,4 @@ function PageTOCPopoverContent(props) {
166
167
  });
167
168
  }
168
169
  //#endregion
169
- export { TOC };
170
+ export { TOC, TOCProvider };
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { cn } from "../../../utils/cn.js";
2
3
  import { jsx } from "react/jsx-runtime";
3
4
  //#region src/layouts/flux/slots/container.tsx
@@ -1,8 +1,7 @@
1
1
  "use client";
2
2
  import { cn } from "../../../utils/cn.js";
3
3
  import { mergeRefs } from "../../../utils/merge-refs.js";
4
- import { ScrollArea, ScrollViewport } from "../../../components/ui/scroll-area.js";
5
- import { SidebarFolder as SidebarFolder$1, SidebarFolderContent as SidebarFolderContent$1, SidebarFolderLink as SidebarFolderLink$1, SidebarFolderTrigger as SidebarFolderTrigger$1, SidebarItem as SidebarItem$1, SidebarProvider as SidebarProvider$1, SidebarSeparator as SidebarSeparator$1, base_exports, useFolder, useFolderDepth } from "../../../components/sidebar/base.js";
4
+ import { SidebarFolder as SidebarFolder$1, SidebarFolderContent as SidebarFolderContent$1, SidebarFolderLink as SidebarFolderLink$1, SidebarFolderTrigger as SidebarFolderTrigger$1, SidebarItem as SidebarItem$1, SidebarProvider as SidebarProvider$1, SidebarSeparator as SidebarSeparator$1, SidebarViewport, base_exports, useFolder, useFolderDepth } from "../../../components/sidebar/base.js";
6
5
  import { createPageTreeRenderer } from "../../../components/sidebar/page-tree.js";
7
6
  import { createLinkItemRenderer } from "../../../components/sidebar/link-item.js";
8
7
  import { useFluxLayout } from "../index.js";
@@ -40,17 +39,13 @@ function Sidebar({ footer, banner, components, ...rest }) {
40
39
  className: "flex flex-col gap-3 p-4 pb-2 empty:hidden",
41
40
  children: banner
42
41
  }),
43
- /* @__PURE__ */ jsx(ScrollArea, {
44
- className: "min-h-0 flex-1",
45
- children: /* @__PURE__ */ jsxs(ScrollViewport, {
46
- className: "p-4 overscroll-contain",
47
- style: { maskImage: "linear-gradient(to bottom, transparent, white 12px, white calc(100% - 12px), transparent)" },
48
- children: [menuItems.filter((v) => v.type !== "icon").map((item, i, list) => /* @__PURE__ */ jsx(SidebarLinkItem, {
49
- item,
50
- className: cn(i === list.length - 1 && "mb-4")
51
- }, i)), /* @__PURE__ */ jsx(SidebarPageTree, { ...components })]
52
- })
53
- }),
42
+ /* @__PURE__ */ jsx(SidebarViewport, { children: /* @__PURE__ */ jsxs("div", {
43
+ className: "flex flex-col",
44
+ children: [menuItems.filter((v) => v.type !== "icon").map((item, i, list) => /* @__PURE__ */ jsx(SidebarLinkItem, {
45
+ item,
46
+ className: cn(i === list.length - 1 && "mb-4")
47
+ }, i)), /* @__PURE__ */ jsx(SidebarPageTree, { ...components })]
48
+ }) }),
54
49
  footer
55
50
  ]
56
51
  });
@@ -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?: FC<ComponentProps<'header'>>;
19
- container?: FC<ComponentProps<'main'>>;
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 { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
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,22 +21,25 @@ function HomeLayout(props) {
21
21
  const linkItems = useLinkItems(props);
22
22
  const slots = {
23
23
  ...baseSlots,
24
- header: navEnabled ? defaultSlots?.header ?? Header : void 0,
24
+ header: defaultSlots?.header ?? InlineHeader,
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: content
33
+ children: /* @__PURE__ */ jsxs(slots.container, {
34
+ ...rest,
35
+ children: [navEnabled && /* @__PURE__ */ jsx(slots.header, {}), children]
36
+ })
39
37
  });
40
38
  }
39
+ function InlineHeader(props) {
40
+ const { nav } = useHomeLayout().props;
41
+ if (nav?.component) return nav.component;
42
+ return /* @__PURE__ */ jsx(Header, { ...props });
43
+ }
41
44
  //#endregion
42
45
  export { HomeLayout, useHomeLayout };