@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.
Files changed (72) hide show
  1. package/css/generated/docs.css +5 -4
  2. package/css/generated/flux.css +3 -3
  3. package/css/generated/home.css +2 -3
  4. package/css/generated/notebook.css +4 -4
  5. package/css/generated/shared.css +2 -1
  6. package/dist/components/accordion.js +2 -2
  7. package/dist/components/dialog/search.js +2 -2
  8. package/dist/components/files.js +3 -3
  9. package/dist/components/heading.js +2 -2
  10. package/dist/components/sidebar/tabs/dropdown.js +1 -1
  11. package/dist/components/toc/index.d.ts +3 -2
  12. package/dist/components/toc/index.js +12 -2
  13. package/dist/components/ui/button.d.ts +1 -1
  14. package/dist/layouts/docs/client.d.ts +3 -3
  15. package/dist/layouts/docs/client.js +20 -23
  16. package/dist/layouts/docs/index.d.ts +1 -1
  17. package/dist/layouts/docs/page/index.d.ts +91 -3
  18. package/dist/layouts/docs/page/index.js +67 -7
  19. package/dist/layouts/docs/page/slots/breadcrumb.js +3 -1
  20. package/dist/layouts/docs/page/slots/container.js +2 -1
  21. package/dist/layouts/docs/page/slots/footer.js +1 -0
  22. package/dist/layouts/docs/page/slots/toc.d.ts +29 -1
  23. package/dist/layouts/docs/page/slots/toc.js +137 -4
  24. package/dist/layouts/docs/slots/container.js +2 -1
  25. package/dist/layouts/docs/slots/header.js +1 -0
  26. package/dist/layouts/docs/slots/sidebar.js +7 -7
  27. package/dist/layouts/flux/index.d.ts +4 -4
  28. package/dist/layouts/flux/index.js +8 -11
  29. package/dist/layouts/flux/page/index.d.ts +79 -3
  30. package/dist/layouts/flux/page/index.js +61 -7
  31. package/dist/layouts/flux/page/slots/breadcrumb.js +1 -0
  32. package/dist/layouts/flux/page/slots/container.js +2 -1
  33. package/dist/layouts/flux/page/slots/footer.js +1 -0
  34. package/dist/layouts/flux/page/slots/toc.d.ts +4 -1
  35. package/dist/layouts/flux/page/slots/toc.js +3 -2
  36. package/dist/layouts/flux/slots/container.js +1 -0
  37. package/dist/layouts/home/index.d.ts +3 -3
  38. package/dist/layouts/home/index.js +6 -8
  39. package/dist/layouts/home/slots/container.js +1 -0
  40. package/dist/layouts/home/slots/header.d.ts +1 -1
  41. package/dist/layouts/home/slots/header.js +5 -5
  42. package/dist/layouts/notebook/client.d.ts +3 -3
  43. package/dist/layouts/notebook/client.js +15 -18
  44. package/dist/layouts/notebook/index.d.ts +1 -1
  45. package/dist/layouts/notebook/page/index.d.ts +91 -3
  46. package/dist/layouts/notebook/page/index.js +67 -7
  47. package/dist/layouts/notebook/page/slots/breadcrumb.js +1 -0
  48. package/dist/layouts/notebook/page/slots/container.js +2 -1
  49. package/dist/layouts/notebook/page/slots/footer.js +1 -0
  50. package/dist/layouts/notebook/page/slots/toc.d.ts +29 -1
  51. package/dist/layouts/notebook/page/slots/toc.js +136 -4
  52. package/dist/layouts/notebook/slots/container.js +1 -0
  53. package/dist/layouts/notebook/slots/sidebar.js +5 -5
  54. package/dist/layouts/shared/client.d.ts +8 -8
  55. package/dist/layouts/shared/client.js +4 -4
  56. package/dist/layouts/shared/index.d.ts +6 -6
  57. package/dist/layouts/shared/page-actions.d.ts +2 -2
  58. package/dist/layouts/shared/page-actions.js +3 -3
  59. package/dist/layouts/shared/slots/search-trigger.d.ts +3 -3
  60. package/dist/page.d.ts +1 -2
  61. package/dist/page.js +1 -2
  62. package/package.json +4 -6
  63. package/dist/layouts/docs/page/client.d.ts +0 -98
  64. package/dist/layouts/docs/page/client.js +0 -110
  65. package/dist/layouts/docs/page/slots/toc-popover.d.ts +0 -31
  66. package/dist/layouts/docs/page/slots/toc-popover.js +0 -141
  67. package/dist/layouts/flux/page/client.d.ts +0 -82
  68. package/dist/layouts/flux/page/client.js +0 -94
  69. package/dist/layouts/notebook/page/client.d.ts +0 -98
  70. package/dist/layouts/notebook/page/client.js +0 -110
  71. package/dist/layouts/notebook/page/slots/toc-popover.d.ts +0 -31
  72. package/dist/layouts/notebook/page/slots/toc-popover.js +0 -141
@@ -1,12 +1,19 @@
1
1
  "use client";
2
- import { I18nLabel } from "../../../../contexts/i18n.js";
2
+ import { I18nLabel, useI18n } from "../../../../contexts/i18n.js";
3
3
  import { cn } from "../../../../utils/cn.js";
4
- import { TOCScrollArea } from "../../../../components/toc/index.js";
4
+ import { TOCProvider as TOCProvider$1, TOCScrollArea, useActiveAnchor, 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
+ import { useTreePath } from "../../../../contexts/tree.js";
8
+ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../../../../components/ui/collapsible.js";
9
+ import { useNotebookLayout } from "../../client.js";
10
+ import { createContext, use, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
7
11
  import { jsx, jsxs } from "react/jsx-runtime";
8
- import { Text } from "lucide-react";
12
+ import { ChevronDown, Text } from "lucide-react";
9
13
  //#region src/layouts/notebook/page/slots/toc.tsx
14
+ function TOCProvider(props) {
15
+ return /* @__PURE__ */ jsx(TOCProvider$1, { ...props });
16
+ }
10
17
  function TOC({ container, header, footer, style }) {
11
18
  return /* @__PURE__ */ jsxs("div", {
12
19
  id: "nd-toc",
@@ -24,5 +31,130 @@ function TOC({ container, header, footer, style }) {
24
31
  ]
25
32
  });
26
33
  }
34
+ const TocPopoverContext = createContext(null);
35
+ function TOCPopover({ container, trigger, content, header, footer, style }) {
36
+ return /* @__PURE__ */ jsxs(PageTOCPopover, {
37
+ ...container,
38
+ children: [/* @__PURE__ */ jsx(PageTOCPopoverTrigger, { ...trigger }), /* @__PURE__ */ jsxs(PageTOCPopoverContent, {
39
+ ...content,
40
+ children: [
41
+ header,
42
+ /* @__PURE__ */ jsx(TOCScrollArea, { children: style === "clerk" ? /* @__PURE__ */ jsx(TOCItems$1, {}) : /* @__PURE__ */ jsx(TOCItems, {}) }),
43
+ footer
44
+ ]
45
+ })]
46
+ });
47
+ }
48
+ function PageTOCPopover({ className, children, ...rest }) {
49
+ const ref = useRef(null);
50
+ const [open, setOpen] = useState(false);
51
+ const { isNavTransparent } = useNotebookLayout();
52
+ const onClick = useEffectEvent((e) => {
53
+ if (!open) return;
54
+ if (ref.current && !ref.current.contains(e.target)) setOpen(false);
55
+ });
56
+ useEffect(() => {
57
+ window.addEventListener("click", onClick);
58
+ return () => {
59
+ window.removeEventListener("click", onClick);
60
+ };
61
+ }, []);
62
+ return /* @__PURE__ */ jsx(TocPopoverContext, {
63
+ value: useMemo(() => ({
64
+ open,
65
+ setOpen
66
+ }), [setOpen, open]),
67
+ children: /* @__PURE__ */ jsx(Collapsible, {
68
+ open,
69
+ onOpenChange: setOpen,
70
+ "data-toc-popover": "",
71
+ className: cn("sticky top-(--fd-docs-row-2) z-10 [grid-area:toc-popover] h-(--fd-toc-popover-height) xl:hidden max-xl:layout:[--fd-toc-popover-height:--spacing(10)]", className),
72
+ ...rest,
73
+ children: /* @__PURE__ */ jsx("header", {
74
+ ref,
75
+ className: cn("border-b backdrop-blur-sm transition-colors", (!isNavTransparent || open) && "bg-fd-background/80", open && "shadow-lg"),
76
+ children
77
+ })
78
+ })
79
+ });
80
+ }
81
+ function PageTOCPopoverTrigger({ className, ...props }) {
82
+ const { text } = useI18n();
83
+ const { open } = use(TocPopoverContext);
84
+ const items = useTOCItems();
85
+ const active = useActiveAnchor();
86
+ const selected = useMemo(() => items.findIndex((item) => active === item.url.slice(1)), [items, active]);
87
+ const path = useTreePath().at(-1);
88
+ const showItem = selected !== -1 && !open;
89
+ return /* @__PURE__ */ jsxs(CollapsibleTrigger, {
90
+ className: cn("flex w-full h-10 items-center text-sm text-fd-muted-foreground gap-2.5 px-4 py-2.5 text-start focus-visible:outline-none [&_svg]:size-4 md:px-6", className),
91
+ "data-toc-popover-trigger": "",
92
+ ...props,
93
+ children: [
94
+ /* @__PURE__ */ jsx(ProgressCircle, {
95
+ value: (selected + 1) / Math.max(1, items.length),
96
+ max: 1,
97
+ className: cn("shrink-0", open && "text-fd-primary")
98
+ }),
99
+ /* @__PURE__ */ jsxs("span", {
100
+ className: "grid flex-1 *:my-auto *:row-start-1 *:col-start-1",
101
+ children: [/* @__PURE__ */ jsx("span", {
102
+ className: cn("truncate transition-[opacity,translate,color]", open && "text-fd-foreground", showItem && "opacity-0 -translate-y-full pointer-events-none"),
103
+ children: path?.name ?? text.toc
104
+ }), /* @__PURE__ */ jsx("span", {
105
+ className: cn("truncate transition-[opacity,translate]", !showItem && "opacity-0 translate-y-full pointer-events-none"),
106
+ children: items[selected]?.title
107
+ })]
108
+ }),
109
+ /* @__PURE__ */ jsx(ChevronDown, { className: cn("shrink-0 transition-transform mx-0.5", open && "rotate-180") })
110
+ ]
111
+ });
112
+ }
113
+ function clamp(input, min, max) {
114
+ if (input < min) return min;
115
+ if (input > max) return max;
116
+ return input;
117
+ }
118
+ function ProgressCircle({ value, strokeWidth = 2, size = 24, min = 0, max = 100, ...restSvgProps }) {
119
+ const normalizedValue = clamp(value, min, max);
120
+ const radius = (size - strokeWidth) / 2;
121
+ const circumference = 2 * Math.PI * radius;
122
+ const progress = normalizedValue / max * circumference;
123
+ const circleProps = {
124
+ cx: size / 2,
125
+ cy: size / 2,
126
+ r: radius,
127
+ fill: "none",
128
+ strokeWidth
129
+ };
130
+ return /* @__PURE__ */ jsxs("svg", {
131
+ role: "progressbar",
132
+ viewBox: `0 0 ${size} ${size}`,
133
+ "aria-valuenow": normalizedValue,
134
+ "aria-valuemin": min,
135
+ "aria-valuemax": max,
136
+ ...restSvgProps,
137
+ children: [/* @__PURE__ */ jsx("circle", {
138
+ ...circleProps,
139
+ className: "stroke-current/25"
140
+ }), /* @__PURE__ */ jsx("circle", {
141
+ ...circleProps,
142
+ stroke: "currentColor",
143
+ strokeDasharray: circumference,
144
+ strokeDashoffset: circumference - progress,
145
+ strokeLinecap: "round",
146
+ transform: `rotate(-90 ${size / 2} ${size / 2})`,
147
+ className: "transition-all"
148
+ })]
149
+ });
150
+ }
151
+ function PageTOCPopoverContent(props) {
152
+ return /* @__PURE__ */ jsx(CollapsibleContent, {
153
+ "data-toc-popover-content": "",
154
+ ...props,
155
+ className: cn("flex flex-col px-4 max-h-[50vh] md:px-6", props.className),
156
+ children: props.children
157
+ });
158
+ }
27
159
  //#endregion
28
- export { TOC };
160
+ export { TOC, TOCPopover, TOCProvider };
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { cn } from "../../../utils/cn.js";
2
3
  import { useNotebookLayout } from "../client.js";
3
4
  import { jsx } from "react/jsx-runtime";
@@ -2,19 +2,19 @@
2
2
  import { cn } from "../../../utils/cn.js";
3
3
  import { buttonVariants } from "../../../components/ui/button.js";
4
4
  import { mergeRefs } from "../../../utils/merge-refs.js";
5
- import { ScrollArea, ScrollViewport } from "../../../components/ui/scroll-area.js";
6
- 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";
7
- import { createPageTreeRenderer } from "../../../components/sidebar/page-tree.js";
8
5
  import { Popover, PopoverContent, PopoverTrigger } from "../../../components/ui/popover.js";
9
6
  import { LinkItem } from "../../shared/client.js";
10
7
  import { isLayoutTabActive } from "../../shared/index.js";
8
+ import { ScrollArea, ScrollViewport } from "../../../components/ui/scroll-area.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, base_exports, useFolder, useFolderDepth } from "../../../components/sidebar/base.js";
10
+ import { createPageTreeRenderer } from "../../../components/sidebar/page-tree.js";
11
11
  import { createLinkItemRenderer } from "../../../components/sidebar/link-item.js";
12
12
  import { useNotebookLayout } from "../client.js";
13
13
  import { createElement, useMemo, useRef, useState } from "react";
14
14
  import { usePathname } from "fumadocs-core/framework";
15
15
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
16
16
  import Link from "fumadocs-core/link";
17
- import { Check, ChevronsUpDown, Languages, Sidebar as Sidebar$1, X } from "lucide-react";
17
+ import { Check, ChevronsUpDown, Languages, SidebarIcon, X } from "lucide-react";
18
18
  import { cva } from "class-variance-authority";
19
19
  //#region src/layouts/notebook/slots/sidebar.tsx
20
20
  const itemVariants = cva("relative flex flex-row items-center gap-2 rounded-lg p-2 text-start text-fd-muted-foreground wrap-anywhere [&_svg]:size-4 [&_svg]:shrink-0", { variants: {
@@ -196,7 +196,7 @@ function Sidebar({ banner, footer, components, collapsible = true, ...rest }) {
196
196
  size: "icon-sm",
197
197
  className: "mt-px mb-auto text-fd-muted-foreground"
198
198
  })),
199
- children: /* @__PURE__ */ jsx(Sidebar$1, {})
199
+ children: /* @__PURE__ */ jsx(SidebarIcon, {})
200
200
  })
201
201
  ]
202
202
  }), tabs.length > 0 && /* @__PURE__ */ jsx(SidebarTabsDropdown, {
@@ -1,5 +1,5 @@
1
1
  import { LanguageSelectProps, LanguageSelectTextProps } from "./slots/language-select.js";
2
- import { FullSearchTriggeProps, SearchTriggerProps } from "./slots/search-trigger.js";
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
5
  import { ComponentProps, FC } from "react";
@@ -16,16 +16,16 @@ declare function LinkItem({
16
16
  }>;
17
17
  }): react_jsx_runtime0.JSX.Element;
18
18
  interface BaseSlots {
19
- navTitle?: FC<ComponentProps<'a'>>;
20
- searchTrigger?: {
19
+ navTitle: FC<ComponentProps<'a'>>;
20
+ themeSwitch: FC<ThemeSwitchProps> | false;
21
+ searchTrigger: {
21
22
  sm: FC<SearchTriggerProps>;
22
- full: FC<FullSearchTriggeProps>;
23
- };
24
- languageSelect?: {
23
+ full: FC<FullSearchTriggerProps>;
24
+ } | false;
25
+ languageSelect: {
25
26
  root: FC<LanguageSelectProps>;
26
27
  text: FC<LanguageSelectTextProps>;
27
- };
28
- themeSwitch?: FC<ThemeSwitchProps>;
28
+ } | false;
29
29
  }
30
30
  interface BaseSlotsProps<P extends BaseLayoutProps = BaseLayoutProps> extends Pick<P, 'nav'> {
31
31
  themeSwitch: Omit<NonNullable<P['themeSwitch']>, 'enabled'>;
@@ -62,15 +62,15 @@ function baseSlots({ useProps }) {
62
62
  return {
63
63
  baseSlots: {
64
64
  navTitle: slots.navTitle ?? InlineNavTitle,
65
- themeSwitch: themeSwitchEnabled ? slots.themeSwitch ?? InlineThemeSwitch : void 0,
65
+ themeSwitch: themeSwitchEnabled && (slots.themeSwitch ?? InlineThemeSwitch),
66
66
  languageSelect: i18n ? slots.languageSelect ?? {
67
67
  root: LanguageSelect,
68
68
  text: LanguageSelectText
69
- } : void 0,
70
- searchTrigger: searchToggleEnabled ? slots.searchTrigger ?? {
69
+ } : false,
70
+ searchTrigger: searchToggleEnabled && (slots.searchTrigger ?? {
71
71
  sm: InlineSearchTrigger,
72
72
  full: InlineSearchTriggerFull
73
- } : void 0
73
+ })
74
74
  },
75
75
  baseProps: {
76
76
  nav,
@@ -1,7 +1,7 @@
1
- import { FullSearchTriggeProps, SearchTriggerProps } from "./slots/search-trigger.js";
1
+ import { FullSearchTriggerProps, SearchTriggerProps } from "./slots/search-trigger.js";
2
2
  import { ThemeSwitchProps } from "./slots/theme-switch.js";
3
3
  import { BaseSlots, BaseSlotsProps, LinkItem, baseSlots } from "./client.js";
4
- import { ComponentProps, ReactNode } from "react";
4
+ import { ComponentProps, FC, ReactNode } from "react";
5
5
  import * as PageTree from "fumadocs-core/page-tree";
6
6
  import { I18nConfig } from "fumadocs-core/i18n";
7
7
 
@@ -9,7 +9,7 @@ import { I18nConfig } from "fumadocs-core/i18n";
9
9
  interface NavOptions {
10
10
  enabled?: boolean;
11
11
  children?: ReactNode;
12
- title?: ReactNode | ((props: ComponentProps<'a'>) => ReactNode);
12
+ title?: ReactNode | FC<ComponentProps<'a'>>;
13
13
  /**
14
14
  * Redirect url of title
15
15
  * @defaultValue '/'
@@ -36,7 +36,7 @@ interface BaseLayoutProps {
36
36
  * navigation config
37
37
  */
38
38
  nav?: NavOptions;
39
- slots?: BaseSlots;
39
+ slots?: Partial<BaseSlots>;
40
40
  children?: ReactNode;
41
41
  themeSwitch?: ThemeSwitchOptions;
42
42
  searchToggle?: SearchToggleOptions;
@@ -48,7 +48,7 @@ interface BaseLayoutProps {
48
48
  interface SearchToggleOptions {
49
49
  enabled?: boolean;
50
50
  sm?: SearchTriggerProps;
51
- full?: FullSearchTriggeProps;
51
+ full?: FullSearchTriggerProps;
52
52
  /** @deprecated use `slots.searchTrigger` instead */
53
53
  components?: {
54
54
  sm?: ReactNode;
@@ -75,7 +75,7 @@ interface LayoutTab {
75
75
  */
76
76
  $folder?: PageTree.Folder;
77
77
  /**
78
- * Detect from a list of urls (when not binded to page tree).
78
+ * Detect from a list of urls (when not bound to page tree).
79
79
  */
80
80
  urls?: Set<string>;
81
81
  }
@@ -26,11 +26,11 @@ declare function ViewOptionsPopover({
26
26
  /**
27
27
  * A URL to the raw Markdown/MDX content of page
28
28
  */
29
- markdownUrl: string;
29
+ markdownUrl?: string;
30
30
  /**
31
31
  * Source file URL on GitHub
32
32
  */
33
- githubUrl: string;
33
+ githubUrl?: string;
34
34
  }): react_jsx_runtime0.JSX.Element;
35
35
  //#endregion
36
36
  export { MarkdownCopyButton, ViewOptionsPopover };
@@ -46,7 +46,7 @@ function ViewOptionsPopover({ markdownUrl, githubUrl, ...props }) {
46
46
  const items = useMemo(() => {
47
47
  const q = `Read ${typeof window === "undefined" ? pathname : new URL(pathname, window.location.origin)}, I want to ask questions about it.`;
48
48
  return [
49
- {
49
+ githubUrl && {
50
50
  title: "Open in GitHub",
51
51
  href: githubUrl,
52
52
  icon: /* @__PURE__ */ jsxs("svg", {
@@ -56,7 +56,7 @@ function ViewOptionsPopover({ markdownUrl, githubUrl, ...props }) {
56
56
  children: [/* @__PURE__ */ jsx("title", { children: "GitHub" }), /* @__PURE__ */ jsx("path", { d: "M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" })]
57
57
  })
58
58
  },
59
- {
59
+ markdownUrl && {
60
60
  title: "View as Markdown",
61
61
  href: markdownUrl,
62
62
  icon: /* @__PURE__ */ jsx(TextIcon, {})
@@ -158,7 +158,7 @@ function ViewOptionsPopover({ markdownUrl, githubUrl, ...props }) {
158
158
  }),
159
159
  href: `https://cursor.com/link/prompt?${new URLSearchParams({ text: q })}`
160
160
  }
161
- ];
161
+ ].filter((v) => !!v);
162
162
  }, [
163
163
  githubUrl,
164
164
  markdownUrl,
@@ -12,12 +12,12 @@ declare function SearchTrigger({
12
12
  color,
13
13
  ...props
14
14
  }: SearchTriggerProps): react_jsx_runtime0.JSX.Element | null;
15
- interface FullSearchTriggeProps extends ComponentProps<'button'> {
15
+ interface FullSearchTriggerProps extends ComponentProps<'button'> {
16
16
  hideIfDisabled?: boolean;
17
17
  }
18
18
  declare function FullSearchTrigger({
19
19
  hideIfDisabled,
20
20
  ...props
21
- }: FullSearchTriggeProps): react_jsx_runtime0.JSX.Element | null;
21
+ }: FullSearchTriggerProps): react_jsx_runtime0.JSX.Element | null;
22
22
  //#endregion
23
- export { FullSearchTriggeProps, FullSearchTrigger, SearchTrigger, SearchTriggerProps };
23
+ export { FullSearchTrigger, FullSearchTriggerProps, SearchTrigger, SearchTriggerProps };
package/dist/page.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Breadcrumb } from "./layouts/docs/page/slots/breadcrumb.js";
2
- import { DocsPageProps as DocsPageProps$1, PageLastUpdate } from "./layouts/docs/page/client.js";
3
- import { DocsBody, DocsDescription, DocsTitle, EditOnGitHub } from "./layouts/docs/page/index.js";
2
+ import { DocsBody, DocsDescription, DocsPageProps as DocsPageProps$1, DocsTitle, EditOnGitHub, PageLastUpdate } from "./layouts/docs/page/index.js";
4
3
  import { ComponentProps } from "react";
5
4
  import * as react_jsx_runtime0 from "react/jsx-runtime";
6
5
 
package/dist/page.js CHANGED
@@ -2,8 +2,7 @@
2
2
  import { cn } from "./utils/cn.js";
3
3
  import { useIsDocsLayout } from "./layouts/docs/client.js";
4
4
  import { Breadcrumb } from "./layouts/docs/page/slots/breadcrumb.js";
5
- import { PageLastUpdate } from "./layouts/docs/page/client.js";
6
- import { DocsBody, DocsDescription, DocsTitle, EditOnGitHub, page_exports } from "./layouts/docs/page/index.js";
5
+ import { DocsBody, DocsDescription, DocsTitle, EditOnGitHub, PageLastUpdate, page_exports } from "./layouts/docs/page/index.js";
7
6
  import { page_exports as page_exports$1 } from "./layouts/notebook/page/index.js";
8
7
  import { jsx, jsxs } from "react/jsx-runtime";
9
8
  //#region src/page.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fumadocs/base-ui",
3
- "version": "16.7.0",
3
+ "version": "16.7.2",
4
4
  "description": "The Base UI version of Fumadocs UI",
5
5
  "keywords": [
6
6
  "Docs",
@@ -61,7 +61,6 @@
61
61
  "./layouts/docs/page/slots/container": "./dist/layouts/docs/page/slots/container.js",
62
62
  "./layouts/docs/page/slots/footer": "./dist/layouts/docs/page/slots/footer.js",
63
63
  "./layouts/docs/page/slots/toc": "./dist/layouts/docs/page/slots/toc.js",
64
- "./layouts/docs/page/slots/toc-popover": "./dist/layouts/docs/page/slots/toc-popover.js",
65
64
  "./layouts/docs/slots/container": "./dist/layouts/docs/slots/container.js",
66
65
  "./layouts/docs/slots/header": "./dist/layouts/docs/slots/header.js",
67
66
  "./layouts/docs/slots/sidebar": "./dist/layouts/docs/slots/sidebar.js",
@@ -85,7 +84,6 @@
85
84
  "./layouts/notebook/page/slots/container": "./dist/layouts/notebook/page/slots/container.js",
86
85
  "./layouts/notebook/page/slots/footer": "./dist/layouts/notebook/page/slots/footer.js",
87
86
  "./layouts/notebook/page/slots/toc": "./dist/layouts/notebook/page/slots/toc.js",
88
- "./layouts/notebook/page/slots/toc-popover": "./dist/layouts/notebook/page/slots/toc-popover.js",
89
87
  "./layouts/notebook/slots/container": "./dist/layouts/notebook/slots/container.js",
90
88
  "./layouts/notebook/slots/header": "./dist/layouts/notebook/slots/header.js",
91
89
  "./layouts/notebook/slots/sidebar": "./dist/layouts/notebook/slots/sidebar.js",
@@ -142,9 +140,9 @@
142
140
  "tailwindcss": "^4.2.2",
143
141
  "tsdown": "0.21.4",
144
142
  "unified": "^11.0.5",
145
- "@fumadocs/cli": "1.3.0",
146
143
  "eslint-config-custom": "0.0.0",
147
- "fumadocs-core": "16.7.0",
144
+ "@fumadocs/cli": "1.3.1",
145
+ "fumadocs-core": "16.7.2",
148
146
  "tsconfig": "0.0.0"
149
147
  },
150
148
  "peerDependencies": {
@@ -155,7 +153,7 @@
155
153
  "react": "^19.2.0",
156
154
  "react-dom": "^19.2.0",
157
155
  "shiki": "*",
158
- "fumadocs-core": "16.7.0"
156
+ "fumadocs-core": "16.7.2"
159
157
  },
160
158
  "peerDependenciesMeta": {
161
159
  "shiki": {
@@ -1,98 +0,0 @@
1
- import { TOCProviderProps } from "../../../components/toc/index.js";
2
- import { TOCProps } from "./slots/toc.js";
3
- import { TOCPopoverProps } from "./slots/toc-popover.js";
4
- import { FooterProps } from "./slots/footer.js";
5
- import { BreadcrumbProps } from "./slots/breadcrumb.js";
6
- import { ComponentProps, FC, ReactNode } from "react";
7
- import * as react_jsx_runtime0 from "react/jsx-runtime";
8
- import { TOCItemType } from "fumadocs-core/toc";
9
-
10
- //#region src/layouts/docs/page/client.d.ts
11
- interface DocsPageProps extends ComponentProps<'article'> {
12
- toc?: TOCItemType[];
13
- /**
14
- * Extend the page to fill all available space
15
- *
16
- * @defaultValue false
17
- */
18
- full?: boolean;
19
- slots?: DocsPageSlots;
20
- footer?: FooterOptions;
21
- breadcrumb?: BreadcrumbOptions;
22
- tableOfContent?: TableOfContentOptions;
23
- tableOfContentPopover?: TableOfContentPopoverOptions;
24
- }
25
- interface BreadcrumbOptions extends BreadcrumbProps {
26
- enabled?: boolean;
27
- /**
28
- * @deprecated use `slots.breadcrumb` instead.
29
- */
30
- component?: ReactNode;
31
- }
32
- interface FooterOptions extends FooterProps {
33
- enabled?: boolean;
34
- /**
35
- * @deprecated use `slots.footer` instead.
36
- */
37
- component?: ReactNode;
38
- }
39
- interface TableOfContentOptions extends Pick<TOCProviderProps, 'single'>, TOCProps {
40
- enabled?: boolean;
41
- /**
42
- * @deprecated use `slots.toc` instead.
43
- */
44
- component?: ReactNode;
45
- }
46
- interface TableOfContentPopoverOptions extends TOCPopoverProps {
47
- enabled?: boolean;
48
- /**
49
- * @deprecated use `slots.tocPopover` instead.
50
- */
51
- component?: ReactNode;
52
- }
53
- interface DocsPageSlots {
54
- toc?: FC<TOCProps>;
55
- container?: FC<ComponentProps<'article'>>;
56
- tocPopover?: FC<TOCPopoverProps>;
57
- tocProvider?: FC<TOCProviderProps>;
58
- footer?: FC<FooterProps>;
59
- breadcrumb?: FC<BreadcrumbProps>;
60
- }
61
- interface PageSlotsProps extends Pick<DocsPageProps, 'full' | 'breadcrumb' | 'footer'> {
62
- tableOfContent: TOCProps & {
63
- component?: ReactNode;
64
- };
65
- tableOfContentPopover: TOCPopoverProps & {
66
- component?: ReactNode;
67
- };
68
- }
69
- declare function useDocsPage(): {
70
- props: PageSlotsProps;
71
- slots: DocsPageSlots;
72
- };
73
- declare function DocsPage({
74
- tableOfContent: {
75
- enabled: tocEnabled,
76
- single,
77
- ...tocProps
78
- },
79
- tableOfContentPopover: {
80
- enabled: tocPopoverEnabled,
81
- ...tocPopoverProps
82
- },
83
- footer,
84
- breadcrumb,
85
- full,
86
- toc,
87
- slots: defaultSlots,
88
- children,
89
- ...containerProps
90
- }: DocsPageProps): react_jsx_runtime0.JSX.Element;
91
- declare function PageLastUpdate({
92
- date: value,
93
- ...props
94
- }: Omit<ComponentProps<'p'>, 'children'> & {
95
- date: Date;
96
- }): react_jsx_runtime0.JSX.Element;
97
- //#endregion
98
- export { DocsPage, DocsPageProps, DocsPageSlots, PageLastUpdate, useDocsPage };
@@ -1,110 +0,0 @@
1
- "use client";
2
- import { useI18n } from "../../../contexts/i18n.js";
3
- import { cn } from "../../../utils/cn.js";
4
- import { TOCProvider } from "../../../components/toc/index.js";
5
- import { TOC } from "./slots/toc.js";
6
- import { TOCPopover } from "./slots/toc-popover.js";
7
- import { Footer } from "./slots/footer.js";
8
- import { Breadcrumb } from "./slots/breadcrumb.js";
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";
12
- //#region src/layouts/docs/page/client.tsx
13
- const PageContext = createContext(null);
14
- function useDocsPage() {
15
- const context = use(PageContext);
16
- if (!context) throw new Error("Please use page components under <DocsPage /> (`fumadocs-ui/layouts/docs/page`).");
17
- return context;
18
- }
19
- function DocsPage({ tableOfContent: { enabled: tocEnabled, single = false, ...tocProps } = {}, tableOfContentPopover: { enabled: tocPopoverEnabled, ...tocPopoverProps } = {}, footer = {}, breadcrumb = {}, full = false, toc = [], slots: defaultSlots = {}, children, ...containerProps }) {
20
- tocEnabled ??= Boolean(!full && (toc.length > 0 || tocProps.footer || tocProps.header));
21
- tocPopoverEnabled ??= Boolean(toc.length > 0 || tocPopoverProps.header || tocPopoverProps.footer);
22
- const slots = {
23
- breadcrumb: breadcrumb.enabled !== false ? defaultSlots.breadcrumb ?? InlineBreadcrumb : void 0,
24
- footer: footer.enabled !== false ? defaultSlots.footer ?? InlineFooter : void 0,
25
- toc: tocEnabled ? defaultSlots.toc ?? InlineTOC : void 0,
26
- tocPopover: tocPopoverEnabled ? defaultSlots.tocPopover ?? InlineTOCPopover : void 0,
27
- tocProvider: defaultSlots.tocProvider ?? TOCProvider,
28
- container: defaultSlots.container ?? Container
29
- };
30
- let content = /* @__PURE__ */ jsxs(Fragment$1, { children: [
31
- slots.tocPopover && /* @__PURE__ */ jsx(slots.tocPopover, {}),
32
- slots.container && /* @__PURE__ */ jsxs(slots.container, {
33
- ...containerProps,
34
- children: [
35
- slots.breadcrumb && /* @__PURE__ */ jsx(slots.breadcrumb, {}),
36
- children,
37
- slots.footer && /* @__PURE__ */ jsx(slots.footer, {})
38
- ]
39
- }),
40
- slots.toc && /* @__PURE__ */ jsx(slots.toc, {})
41
- ] });
42
- if (slots.tocProvider) content = /* @__PURE__ */ jsx(slots.tocProvider, {
43
- single,
44
- toc: tocEnabled || tocPopoverEnabled ? toc : [],
45
- children: content
46
- });
47
- return /* @__PURE__ */ jsx(PageContext, {
48
- value: {
49
- props: {
50
- full,
51
- tableOfContent: tocProps,
52
- tableOfContentPopover: tocPopoverProps,
53
- footer,
54
- breadcrumb
55
- },
56
- slots
57
- },
58
- children: content
59
- });
60
- }
61
- function InlineBreadcrumb(props) {
62
- const { component, enabled: _, ...rest } = useDocsPage().props.breadcrumb ?? {};
63
- if (component) return component;
64
- return /* @__PURE__ */ jsx(Breadcrumb, {
65
- ...props,
66
- ...rest
67
- });
68
- }
69
- function InlineFooter(props) {
70
- const { component, enabled: _, ...rest } = useDocsPage().props.footer ?? {};
71
- if (component) return component;
72
- return /* @__PURE__ */ jsx(Footer, {
73
- ...props,
74
- ...rest
75
- });
76
- }
77
- function InlineTOCPopover(props) {
78
- const { tableOfContentPopover } = useDocsPage().props;
79
- if (tableOfContentPopover.component) return tableOfContentPopover.component;
80
- return /* @__PURE__ */ jsx(TOCPopover, {
81
- ...props,
82
- ...tableOfContentPopover
83
- });
84
- }
85
- function InlineTOC(props) {
86
- const { tableOfContent } = useDocsPage().props;
87
- if (tableOfContent.component) return tableOfContent.component;
88
- return /* @__PURE__ */ jsx(TOC, {
89
- ...props,
90
- ...tableOfContent
91
- });
92
- }
93
- function PageLastUpdate({ date: value, ...props }) {
94
- const { text } = useI18n();
95
- const [date, setDate] = useState("");
96
- useEffect(() => {
97
- setDate(value.toLocaleDateString());
98
- }, [value]);
99
- return /* @__PURE__ */ jsxs("p", {
100
- ...props,
101
- className: cn("text-sm text-fd-muted-foreground", props.className),
102
- children: [
103
- text.lastUpdate,
104
- " ",
105
- date
106
- ]
107
- });
108
- }
109
- //#endregion
110
- export { DocsPage, PageLastUpdate, useDocsPage };
@@ -1,31 +0,0 @@
1
- import { ComponentProps, ReactNode } from "react";
2
- import * as react_jsx_runtime0 from "react/jsx-runtime";
3
-
4
- //#region src/layouts/docs/page/slots/toc-popover.d.ts
5
- interface TOCPopoverProps {
6
- container?: ComponentProps<'div'>;
7
- trigger?: ComponentProps<'button'>;
8
- content?: ComponentProps<'div'>;
9
- /**
10
- * Custom content in TOC container, before the main TOC
11
- */
12
- header?: ReactNode;
13
- /**
14
- * Custom content in TOC container, after the main TOC
15
- */
16
- footer?: ReactNode;
17
- /**
18
- * @defaultValue 'normal'
19
- */
20
- style?: 'normal' | 'clerk';
21
- }
22
- declare function TOCPopover({
23
- container,
24
- trigger,
25
- content,
26
- header,
27
- footer,
28
- style
29
- }: TOCPopoverProps): react_jsx_runtime0.JSX.Element;
30
- //#endregion
31
- export { TOCPopover, TOCPopoverProps };