@fumadocs/base-ui 16.7.0 → 16.7.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.
- package/css/generated/docs.css +1 -3
- package/css/generated/notebook.css +1 -3
- package/css/generated/shared.css +2 -1
- package/dist/components/accordion.js +2 -2
- package/dist/components/dialog/search.js +2 -2
- package/dist/components/files.js +3 -3
- package/dist/components/heading.js +2 -2
- package/dist/components/sidebar/tabs/dropdown.js +1 -1
- package/dist/components/toc/index.d.ts +3 -2
- package/dist/components/toc/index.js +3 -2
- package/dist/layouts/docs/client.js +1 -1
- package/dist/layouts/docs/page/client.d.ts +6 -6
- package/dist/layouts/docs/page/client.js +10 -10
- package/dist/layouts/docs/page/slots/breadcrumb.js +2 -1
- package/dist/layouts/docs/page/slots/toc.d.ts +29 -1
- package/dist/layouts/docs/page/slots/toc.js +137 -4
- package/dist/layouts/docs/slots/container.js +1 -1
- package/dist/layouts/docs/slots/sidebar.js +7 -7
- package/dist/layouts/home/slots/header.js +1 -1
- package/dist/layouts/notebook/client.js +1 -1
- package/dist/layouts/notebook/page/client.d.ts +6 -6
- package/dist/layouts/notebook/page/client.js +10 -10
- package/dist/layouts/notebook/page/slots/toc.d.ts +29 -1
- package/dist/layouts/notebook/page/slots/toc.js +136 -4
- package/dist/layouts/notebook/slots/sidebar.js +5 -5
- package/dist/layouts/shared/client.d.ts +2 -2
- package/dist/layouts/shared/index.d.ts +3 -3
- package/dist/layouts/shared/slots/search-trigger.d.ts +3 -3
- package/package.json +4 -6
- package/dist/layouts/docs/page/slots/toc-popover.d.ts +0 -31
- package/dist/layouts/docs/page/slots/toc-popover.js +0 -141
- package/dist/layouts/notebook/page/slots/toc-popover.d.ts +0 -31
- package/dist/layouts/notebook/page/slots/toc-popover.js +0 -141
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useI18n } from "../../../contexts/i18n.js";
|
|
3
3
|
import { cn } from "../../../utils/cn.js";
|
|
4
|
-
import { TOCProvider } from "
|
|
5
|
-
import { TOC } from "./slots/toc.js";
|
|
6
|
-
import { TOCPopover } from "./slots/toc-popover.js";
|
|
4
|
+
import { TOC, TOCPopover, TOCProvider } from "./slots/toc.js";
|
|
7
5
|
import { Footer } from "./slots/footer.js";
|
|
8
6
|
import { Breadcrumb } from "./slots/breadcrumb.js";
|
|
9
7
|
import { Container } from "./slots/container.js";
|
|
@@ -16,19 +14,21 @@ function useDocsPage() {
|
|
|
16
14
|
if (!context) throw new Error("Please use page components under <DocsPage /> (`fumadocs-ui/layouts/notebook/page`).");
|
|
17
15
|
return context;
|
|
18
16
|
}
|
|
19
|
-
function DocsPage({ tableOfContent: { enabled: tocEnabled, single
|
|
17
|
+
function DocsPage({ tableOfContent: { enabled: tocEnabled, single, ...tocProps } = {}, tableOfContentPopover: { enabled: tocPopoverEnabled, ...tocPopoverProps } = {}, footer = {}, breadcrumb = {}, full = false, toc = [], slots: defaultSlots = {}, children, ...containerProps }) {
|
|
20
18
|
tocEnabled ??= Boolean(!full && (toc.length > 0 || tocProps.footer || tocProps.header));
|
|
21
19
|
tocPopoverEnabled ??= Boolean(toc.length > 0 || tocPopoverProps.header || tocPopoverProps.footer);
|
|
22
20
|
const slots = {
|
|
23
21
|
breadcrumb: breadcrumb.enabled !== false ? defaultSlots.breadcrumb ?? InlineBreadcrumb : void 0,
|
|
24
22
|
footer: footer.enabled !== false ? defaultSlots.footer ?? InlineFooter : void 0,
|
|
25
|
-
toc:
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
toc: defaultSlots.toc ?? {
|
|
24
|
+
provider: TOCProvider,
|
|
25
|
+
main: tocEnabled ? InlineTOC : void 0,
|
|
26
|
+
popover: tocPopoverEnabled ? InlineTOCPopover : void 0
|
|
27
|
+
},
|
|
28
28
|
container: defaultSlots.container ?? Container
|
|
29
29
|
};
|
|
30
30
|
let content = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
31
|
-
slots.
|
|
31
|
+
slots.toc?.popover && /* @__PURE__ */ jsx(slots.toc.popover, {}),
|
|
32
32
|
slots.container && /* @__PURE__ */ jsxs(slots.container, {
|
|
33
33
|
...containerProps,
|
|
34
34
|
children: [
|
|
@@ -37,9 +37,9 @@ function DocsPage({ tableOfContent: { enabled: tocEnabled, single = false, ...to
|
|
|
37
37
|
slots.footer && /* @__PURE__ */ jsx(slots.footer, {})
|
|
38
38
|
]
|
|
39
39
|
}),
|
|
40
|
-
slots.toc && /* @__PURE__ */ jsx(slots.toc, {})
|
|
40
|
+
slots.toc?.main && /* @__PURE__ */ jsx(slots.toc.main, {})
|
|
41
41
|
] });
|
|
42
|
-
if (slots.
|
|
42
|
+
if (slots.toc) content = /* @__PURE__ */ jsx(slots.toc.provider, {
|
|
43
43
|
single,
|
|
44
44
|
toc: tocEnabled || tocPopoverEnabled ? toc : [],
|
|
45
45
|
children: content
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { TOCProviderProps as TOCProviderProps$1 } from "../../../../components/toc/index.js";
|
|
1
2
|
import { ComponentProps, ReactNode } from "react";
|
|
2
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
4
|
|
|
4
5
|
//#region src/layouts/notebook/page/slots/toc.d.ts
|
|
6
|
+
type TOCProviderProps = TOCProviderProps$1;
|
|
7
|
+
declare function TOCProvider(props: TOCProviderProps): react_jsx_runtime0.JSX.Element;
|
|
5
8
|
interface TOCProps {
|
|
6
9
|
container?: ComponentProps<'div'>;
|
|
7
10
|
/**
|
|
@@ -23,5 +26,30 @@ declare function TOC({
|
|
|
23
26
|
footer,
|
|
24
27
|
style
|
|
25
28
|
}: TOCProps): react_jsx_runtime0.JSX.Element;
|
|
29
|
+
interface TOCPopoverProps {
|
|
30
|
+
container?: ComponentProps<'div'>;
|
|
31
|
+
trigger?: ComponentProps<'button'>;
|
|
32
|
+
content?: ComponentProps<'div'>;
|
|
33
|
+
/**
|
|
34
|
+
* Custom content in TOC container, before the main TOC
|
|
35
|
+
*/
|
|
36
|
+
header?: ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* Custom content in TOC container, after the main TOC
|
|
39
|
+
*/
|
|
40
|
+
footer?: ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* @defaultValue 'normal'
|
|
43
|
+
*/
|
|
44
|
+
style?: 'normal' | 'clerk';
|
|
45
|
+
}
|
|
46
|
+
declare function TOCPopover({
|
|
47
|
+
container,
|
|
48
|
+
trigger,
|
|
49
|
+
content,
|
|
50
|
+
header,
|
|
51
|
+
footer,
|
|
52
|
+
style
|
|
53
|
+
}: TOCPopoverProps): react_jsx_runtime0.JSX.Element;
|
|
26
54
|
//#endregion
|
|
27
|
-
export { TOC, TOCProps };
|
|
55
|
+
export { TOC, TOCPopover, TOCPopoverProps, TOCProps, TOCProvider, TOCProviderProps };
|
|
@@ -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 };
|
|
@@ -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,
|
|
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(
|
|
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 {
|
|
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";
|
|
@@ -19,7 +19,7 @@ interface BaseSlots {
|
|
|
19
19
|
navTitle?: FC<ComponentProps<'a'>>;
|
|
20
20
|
searchTrigger?: {
|
|
21
21
|
sm: FC<SearchTriggerProps>;
|
|
22
|
-
full: FC<
|
|
22
|
+
full: FC<FullSearchTriggerProps>;
|
|
23
23
|
};
|
|
24
24
|
languageSelect?: {
|
|
25
25
|
root: FC<LanguageSelectProps>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
4
|
import { ComponentProps, ReactNode } from "react";
|
|
@@ -48,7 +48,7 @@ interface BaseLayoutProps {
|
|
|
48
48
|
interface SearchToggleOptions {
|
|
49
49
|
enabled?: boolean;
|
|
50
50
|
sm?: SearchTriggerProps;
|
|
51
|
-
full?:
|
|
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
|
|
78
|
+
* Detect from a list of urls (when not bound to page tree).
|
|
79
79
|
*/
|
|
80
80
|
urls?: Set<string>;
|
|
81
81
|
}
|
|
@@ -12,12 +12,12 @@ declare function SearchTrigger({
|
|
|
12
12
|
color,
|
|
13
13
|
...props
|
|
14
14
|
}: SearchTriggerProps): react_jsx_runtime0.JSX.Element | null;
|
|
15
|
-
interface
|
|
15
|
+
interface FullSearchTriggerProps extends ComponentProps<'button'> {
|
|
16
16
|
hideIfDisabled?: boolean;
|
|
17
17
|
}
|
|
18
18
|
declare function FullSearchTrigger({
|
|
19
19
|
hideIfDisabled,
|
|
20
20
|
...props
|
|
21
|
-
}:
|
|
21
|
+
}: FullSearchTriggerProps): react_jsx_runtime0.JSX.Element | null;
|
|
22
22
|
//#endregion
|
|
23
|
-
export {
|
|
23
|
+
export { FullSearchTrigger, FullSearchTriggerProps, SearchTrigger, SearchTriggerProps };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fumadocs/base-ui",
|
|
3
|
-
"version": "16.7.
|
|
3
|
+
"version": "16.7.1",
|
|
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.
|
|
143
|
+
"@fumadocs/cli": "1.3.1",
|
|
146
144
|
"eslint-config-custom": "0.0.0",
|
|
147
|
-
"fumadocs-core": "16.7.
|
|
145
|
+
"fumadocs-core": "16.7.1",
|
|
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.
|
|
156
|
+
"fumadocs-core": "16.7.1"
|
|
159
157
|
},
|
|
160
158
|
"peerDependenciesMeta": {
|
|
161
159
|
"shiki": {
|
|
@@ -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 };
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useI18n } from "../../../../contexts/i18n.js";
|
|
3
|
-
import { cn } from "../../../../utils/cn.js";
|
|
4
|
-
import { TOCScrollArea, useTOCItems } from "../../../../components/toc/index.js";
|
|
5
|
-
import { TOCItems } from "../../../../components/toc/default.js";
|
|
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 { useDocsLayout } from "../../client.js";
|
|
10
|
-
import { createContext, use, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
|
|
11
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
import { ChevronDown } from "lucide-react";
|
|
13
|
-
import { useActiveAnchor } from "fumadocs-core/toc";
|
|
14
|
-
//#region src/layouts/docs/page/slots/toc-popover.tsx
|
|
15
|
-
const TocPopoverContext = createContext(null);
|
|
16
|
-
function TOCPopover({ container, trigger, content, header, footer, style }) {
|
|
17
|
-
return /* @__PURE__ */ jsxs(PageTOCPopover, {
|
|
18
|
-
...container,
|
|
19
|
-
children: [/* @__PURE__ */ jsx(PageTOCPopoverTrigger, { ...trigger }), /* @__PURE__ */ jsxs(PageTOCPopoverContent, {
|
|
20
|
-
...content,
|
|
21
|
-
children: [
|
|
22
|
-
header,
|
|
23
|
-
/* @__PURE__ */ jsx(TOCScrollArea, { children: style === "clerk" ? /* @__PURE__ */ jsx(TOCItems$1, {}) : /* @__PURE__ */ jsx(TOCItems, {}) }),
|
|
24
|
-
footer
|
|
25
|
-
]
|
|
26
|
-
})]
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
function PageTOCPopover({ className, children, ...rest }) {
|
|
30
|
-
const ref = useRef(null);
|
|
31
|
-
const [open, setOpen] = useState(false);
|
|
32
|
-
const { isNavTransparent } = useDocsLayout();
|
|
33
|
-
const onClick = useEffectEvent((e) => {
|
|
34
|
-
if (!open) return;
|
|
35
|
-
if (ref.current && !ref.current.contains(e.target)) setOpen(false);
|
|
36
|
-
});
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
window.addEventListener("click", onClick);
|
|
39
|
-
return () => {
|
|
40
|
-
window.removeEventListener("click", onClick);
|
|
41
|
-
};
|
|
42
|
-
}, []);
|
|
43
|
-
return /* @__PURE__ */ jsx(TocPopoverContext, {
|
|
44
|
-
value: useMemo(() => ({
|
|
45
|
-
open,
|
|
46
|
-
setOpen
|
|
47
|
-
}), [setOpen, open]),
|
|
48
|
-
children: /* @__PURE__ */ jsx(Collapsible, {
|
|
49
|
-
open,
|
|
50
|
-
onOpenChange: setOpen,
|
|
51
|
-
"data-toc-popover": "",
|
|
52
|
-
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),
|
|
53
|
-
...rest,
|
|
54
|
-
children: /* @__PURE__ */ jsx("header", {
|
|
55
|
-
ref,
|
|
56
|
-
className: cn("border-b backdrop-blur-sm transition-colors", (!isNavTransparent || open) && "bg-fd-background/80", open && "shadow-lg"),
|
|
57
|
-
children
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function PageTOCPopoverTrigger({ className, ...props }) {
|
|
63
|
-
const { text } = useI18n();
|
|
64
|
-
const { open } = use(TocPopoverContext);
|
|
65
|
-
const items = useTOCItems();
|
|
66
|
-
const active = useActiveAnchor();
|
|
67
|
-
const selected = useMemo(() => items.findIndex((item) => active === item.url.slice(1)), [items, active]);
|
|
68
|
-
const path = useTreePath().at(-1);
|
|
69
|
-
const showItem = selected !== -1 && !open;
|
|
70
|
-
return /* @__PURE__ */ jsxs(CollapsibleTrigger, {
|
|
71
|
-
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),
|
|
72
|
-
"data-toc-popover-trigger": "",
|
|
73
|
-
...props,
|
|
74
|
-
children: [
|
|
75
|
-
/* @__PURE__ */ jsx(ProgressCircle, {
|
|
76
|
-
value: (selected + 1) / Math.max(1, items.length),
|
|
77
|
-
max: 1,
|
|
78
|
-
className: cn("shrink-0", open && "text-fd-primary")
|
|
79
|
-
}),
|
|
80
|
-
/* @__PURE__ */ jsxs("span", {
|
|
81
|
-
className: "grid flex-1 *:my-auto *:row-start-1 *:col-start-1",
|
|
82
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
83
|
-
className: cn("truncate transition-[opacity,translate,color]", open && "text-fd-foreground", showItem && "opacity-0 -translate-y-full pointer-events-none"),
|
|
84
|
-
children: path?.name ?? text.toc
|
|
85
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
86
|
-
className: cn("truncate transition-[opacity,translate]", !showItem && "opacity-0 translate-y-full pointer-events-none"),
|
|
87
|
-
children: items[selected]?.title
|
|
88
|
-
})]
|
|
89
|
-
}),
|
|
90
|
-
/* @__PURE__ */ jsx(ChevronDown, { className: cn("shrink-0 transition-transform mx-0.5", open && "rotate-180") })
|
|
91
|
-
]
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
function clamp(input, min, max) {
|
|
95
|
-
if (input < min) return min;
|
|
96
|
-
if (input > max) return max;
|
|
97
|
-
return input;
|
|
98
|
-
}
|
|
99
|
-
function ProgressCircle({ value, strokeWidth = 2, size = 24, min = 0, max = 100, ...restSvgProps }) {
|
|
100
|
-
const normalizedValue = clamp(value, min, max);
|
|
101
|
-
const radius = (size - strokeWidth) / 2;
|
|
102
|
-
const circumference = 2 * Math.PI * radius;
|
|
103
|
-
const progress = normalizedValue / max * circumference;
|
|
104
|
-
const circleProps = {
|
|
105
|
-
cx: size / 2,
|
|
106
|
-
cy: size / 2,
|
|
107
|
-
r: radius,
|
|
108
|
-
fill: "none",
|
|
109
|
-
strokeWidth
|
|
110
|
-
};
|
|
111
|
-
return /* @__PURE__ */ jsxs("svg", {
|
|
112
|
-
role: "progressbar",
|
|
113
|
-
viewBox: `0 0 ${size} ${size}`,
|
|
114
|
-
"aria-valuenow": normalizedValue,
|
|
115
|
-
"aria-valuemin": min,
|
|
116
|
-
"aria-valuemax": max,
|
|
117
|
-
...restSvgProps,
|
|
118
|
-
children: [/* @__PURE__ */ jsx("circle", {
|
|
119
|
-
...circleProps,
|
|
120
|
-
className: "stroke-current/25"
|
|
121
|
-
}), /* @__PURE__ */ jsx("circle", {
|
|
122
|
-
...circleProps,
|
|
123
|
-
stroke: "currentColor",
|
|
124
|
-
strokeDasharray: circumference,
|
|
125
|
-
strokeDashoffset: circumference - progress,
|
|
126
|
-
strokeLinecap: "round",
|
|
127
|
-
transform: `rotate(-90 ${size / 2} ${size / 2})`,
|
|
128
|
-
className: "transition-all"
|
|
129
|
-
})]
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
function PageTOCPopoverContent(props) {
|
|
133
|
-
return /* @__PURE__ */ jsx(CollapsibleContent, {
|
|
134
|
-
"data-toc-popover-content": "",
|
|
135
|
-
...props,
|
|
136
|
-
className: cn("flex flex-col px-4 max-h-[50vh] md:px-6", props.className),
|
|
137
|
-
children: props.children
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
//#endregion
|
|
141
|
-
export { TOCPopover };
|
|
@@ -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/notebook/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 };
|