@vercel/geistdocs 1.25.1-canary.e417a18 → 1.25.1-canary.f56ac48
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/dist/cli/index.js +1 -1
- package/dist/components/callout.d.ts.map +1 -1
- package/dist/components/callout.js +1 -1
- package/dist/components/command-prompt.d.ts.map +1 -1
- package/dist/components/command-prompt.js +15 -22
- package/dist/components/copy-prompt.d.ts +2 -1
- package/dist/components/copy-prompt.d.ts.map +1 -1
- package/dist/components/copy-prompt.js +2 -2
- package/dist/components/heading.d.ts +7 -0
- package/dist/components/heading.d.ts.map +1 -0
- package/dist/components/heading.js +14 -0
- package/dist/controls.d.ts.map +1 -1
- package/dist/controls.js +4 -3
- package/dist/internal/chat/context.d.ts +2 -0
- package/dist/internal/chat/context.d.ts.map +1 -1
- package/dist/internal/chat/context.js +24 -3
- package/dist/internal/chat/dots-spinner.d.ts.map +1 -1
- package/dist/internal/chat/dots-spinner.js +15 -9
- package/dist/internal/chat/loading-skeleton.d.ts +7 -0
- package/dist/internal/chat/loading-skeleton.d.ts.map +1 -0
- package/dist/internal/chat/loading-skeleton.js +46 -0
- package/dist/internal/chat/message.d.ts.map +1 -1
- package/dist/internal/chat/message.js +23 -3
- package/dist/internal/chat/shell.d.ts.map +1 -1
- package/dist/internal/chat/shell.js +10 -15
- package/dist/internal/chat/sources.d.ts.map +1 -1
- package/dist/internal/chat/sources.js +4 -1
- package/dist/internal/navbar/desktop-menu.js +1 -1
- package/dist/internal/navbar/mobile-menu.d.ts.map +1 -1
- package/dist/internal/navbar/mobile-menu.js +8 -13
- package/dist/internal/page-actions-client.d.ts.map +1 -1
- package/dist/internal/page-actions-client.js +36 -32
- package/dist/internal/provider-client.d.ts.map +1 -1
- package/dist/internal/provider-client.js +39 -5
- package/dist/internal/sidebar-responsive.d.ts +0 -1
- package/dist/internal/sidebar-responsive.d.ts.map +1 -1
- package/dist/internal/sidebar-responsive.js +0 -9
- package/dist/internal/sidebar.d.ts.map +1 -1
- package/dist/internal/sidebar.js +50 -25
- package/dist/internal/table-of-contents.d.ts.map +1 -1
- package/dist/internal/table-of-contents.js +1 -1
- package/dist/internal/toc-items.d.ts.map +1 -1
- package/dist/internal/toc-items.js +16 -6
- package/dist/internal/ui/dropdown-menu.js +6 -6
- package/dist/internal/ui/navigation-menu.js +2 -2
- package/dist/internal/use-mobile.d.ts.map +1 -1
- package/dist/internal/use-mobile.js +2 -12
- package/dist/layout.d.ts +1 -0
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +2 -0
- package/dist/mdx.d.ts.map +1 -1
- package/dist/mdx.js +8 -1
- package/dist/pages/docs.d.ts.map +1 -1
- package/dist/pages/docs.js +5 -2
- package/dist/routes/chat.d.ts +1 -1
- package/dist/routes/chat.js +1 -1
- package/dist/versions.js +2 -2
- package/docs/agents.md +1 -1
- package/docs/llms.txt +50 -4
- package/docs/manifest.json +1 -1
- package/docs/pages/ask-ai.md +2 -2
- package/docs/pages/md.md +1 -1
- package/docs/pages/syntax.md +46 -0
- package/package.json +2 -1
- package/template/app/[lang]/layout.tsx +4 -0
- package/template/app/styles/geistdocs.css +1 -1
- package/template/components/ui/button.tsx +1 -1
- package/template/content/docs/ask-ai.cn.mdx +2 -2
- package/template/content/docs/ask-ai.mdx +2 -2
- package/template/content/docs/md.mdx +1 -1
- package/template/content/docs/syntax.mdx +50 -0
- package/template/package.json +1 -1
- package/theme.css +7 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobile-menu.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/mobile-menu.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mobile-menu.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/mobile-menu.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,yBAAyB,EAEzB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAQtB,UAAU,eAAe;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,gBAAgB,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC1C,mEAAmE;IACnE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AA6PD,eAAO,MAAM,UAAU,GAAI,0DAMxB,eAAe,4CA4HjB,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
import { ThemeSwitcher } from "@vercel/geistcn/components/theme-switcher";
|
|
4
4
|
import { cn } from "@vercel/geistcn/utils";
|
|
5
5
|
import { IconChevronDownSmall } from "@vercel/geistcn-assets/icons";
|
|
6
|
+
import { useMediaQuery } from "phase/react";
|
|
6
7
|
import { useEffect, useState } from "react";
|
|
7
8
|
import { SearchButton } from "../../controls";
|
|
8
9
|
import { ExternalArrow } from "../external-arrow";
|
|
@@ -50,9 +51,10 @@ function OssCollapsible({ sections, onLinkClick, }) {
|
|
|
50
51
|
return (_jsxs("details", { className: "group flex flex-col", name: "geistdocs-mobile-nav", children: [_jsxs("summary", { className: "flex min-h-11 cursor-pointer list-none items-center justify-between rounded-md px-3 font-normal text-2xl text-gray-900 outline-none transition-colors hover:bg-gray-alpha-100 hover:text-gray-1000 [&::-webkit-details-marker]:hidden", children: [_jsxs("span", { children: ["Vercel OSS", _jsx(ExternalArrow, { className: "mt-1" })] }), _jsx(IconChevronDownSmall, { className: "relative shrink-0 text-gray-700 transition-transform duration-150 group-open:rotate-180", size: 24 })] }), _jsx("div", { className: "flex flex-col gap-6 px-3 py-4", children: sections.map((section) => (_jsxs("div", { className: "flex flex-col", children: [_jsx("p", { className: "mb-2 font-mono text-gray-700 text-xs uppercase tracking-wider", children: section.heading }), _jsx("ul", { className: "-mx-3 flex list-none flex-col", children: section.items.map((product) => (_jsx("li", { children: _jsx(SubNavLink, { external: product.external ?? product.href.startsWith("http"), href: product.href, onClick: onLinkClick, children: product.label }) }, product.href))) })] }, section.heading))) })] }));
|
|
51
52
|
}
|
|
52
53
|
function MobileMenuButton({ expanded, onClick, }) {
|
|
53
|
-
return (_jsx("button", { "aria-expanded": expanded, "aria-label": expanded ? "Close menu" : "Open menu", className: "relative flex @min-[1024px]:hidden size-8 items-center justify-center rounded-full border border-gray-200 transition-colors hover:bg-gray-100", "data-slot": "mobile-menu-toggle", onClick: onClick, type: "button", children: _jsxs("span", { className: "flex flex-col items-center justify-center gap-[5px]", children: [_jsx("span", { className: cn("block h-[1.5px] w-3.5 bg-gray-1000 transition-
|
|
54
|
+
return (_jsx("button", { "aria-expanded": expanded, "aria-label": expanded ? "Close menu" : "Open menu", className: "relative flex @min-[1024px]:hidden size-8 items-center justify-center rounded-full border border-gray-200 transition-colors hover:bg-gray-100", "data-slot": "mobile-menu-toggle", onClick: onClick, type: "button", children: _jsxs("span", { className: "flex flex-col items-center justify-center gap-[5px]", children: [_jsx("span", { className: cn("block h-[1.5px] w-3.5 bg-gray-1000 transition-transform duration-150", expanded && "translate-y-[3.25px] rotate-45") }), _jsx("span", { className: cn("block h-[1.5px] w-3.5 bg-gray-1000 transition-transform duration-150", expanded && "-translate-y-[3.25px] -rotate-45") })] }) }));
|
|
54
55
|
}
|
|
55
56
|
export const MobileMenu = ({ activeProduct, githubUrl, nav, ossProducts, showOss = false, }) => {
|
|
57
|
+
const isDesktop = useMediaQuery("(min-width: 1024px)");
|
|
56
58
|
const [show, setShow] = useState(false);
|
|
57
59
|
const isActive = useNavActive();
|
|
58
60
|
// Resolve the default/custom list and drop the active product here on the
|
|
@@ -83,18 +85,11 @@ export const MobileMenu = ({ activeProduct, githubUrl, nav, ossProducts, showOss
|
|
|
83
85
|
useEffect(() => {
|
|
84
86
|
setShow(false);
|
|
85
87
|
}, []);
|
|
86
|
-
// Close the sheet when resizing up to desktop (also releases the scroll lock).
|
|
87
88
|
useEffect(() => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
onChange();
|
|
95
|
-
mq.addEventListener("change", onChange);
|
|
96
|
-
return () => mq.removeEventListener("change", onChange);
|
|
97
|
-
}, []);
|
|
89
|
+
if (isDesktop) {
|
|
90
|
+
setShow(false);
|
|
91
|
+
}
|
|
92
|
+
}, [isDesktop]);
|
|
98
93
|
useEffect(() => {
|
|
99
94
|
const handleEscape = (e) => {
|
|
100
95
|
if (e.key === "Escape" && show) {
|
|
@@ -113,7 +108,7 @@ export const MobileMenu = ({ activeProduct, githubUrl, nav, ossProducts, showOss
|
|
|
113
108
|
const close = () => setShow(false);
|
|
114
109
|
return (_jsxs(_Fragment, { children: [_jsx(MobileMenuButton, { expanded: show, onClick: () => setShow(!show) }), _jsx("div", { className: cn("fixed inset-0 top-16 z-40 @min-[1024px]:hidden bg-background-200 transition-opacity duration-200", show
|
|
115
110
|
? "pointer-events-auto opacity-100"
|
|
116
|
-
: "pointer-events-none opacity-0"), onClick: close }), _jsxs("div", { className: cn("fixed inset-x-0 top-16 bottom-0 z-40 @min-[1024px]:hidden overflow-y-auto bg-background-200 px-2 transition-
|
|
111
|
+
: "pointer-events-none opacity-0"), onClick: close }), _jsxs("div", { className: cn("fixed inset-x-0 top-16 bottom-0 z-40 @min-[1024px]:hidden overflow-y-auto bg-background-200 px-2 transition-[transform,opacity] duration-200", show
|
|
117
112
|
? "translate-y-0 opacity-100"
|
|
118
113
|
: "pointer-events-none -translate-y-2 opacity-0"), children: [_jsx("div", { className: "p-4", children: _jsx(SearchButton, { className: "w-full py-4.5", onClick: close }) }), _jsxs("nav", { className: "flex flex-col px-1", children: [nav.map((item) => "items" in item ? (_jsx(NavDropdownCollapsible, { dropdown: item, onLinkClick: close }, item.label)) : (_jsx(NavLink, { active: isActive(item.href), external: item.href.startsWith("http"), href: item.href, onClick: close, children: item.label }, item.href))), githubUrl ? (_jsx(NavLink, { external: true, href: githubUrl, onClick: close, children: "GitHub" })) : null, _jsx(OssCollapsible, { onLinkClick: close, sections: ossSections })] }), _jsx("div", { className: "mt-2 flex justify-end px-4 py-4", children: _jsx(ThemeSwitcher, { small: true }) })] })] }));
|
|
119
114
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-actions-client.d.ts","sourceRoot":"","sources":["../../src/internal/page-actions-client.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAKL,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAgBjD,UAAU,gBAAgB;IACxB,MAAM,EAAE,IAAI,CACV,eAAe,EACf,IAAI,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,CACxD,CAAC;IACF;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5B,IAAI,EAAE;QACJ,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH;AAED,UAAU,oCAAoC;IAC5C,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,aAAa,GAAG,QAAQ,CAAC,CAAC;IACrE,YAAY,EAAE,SAAS,EAAE,CAAC;CAC3B;
|
|
1
|
+
{"version":3,"file":"page-actions-client.d.ts","sourceRoot":"","sources":["../../src/internal/page-actions-client.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAKL,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAgBjD,UAAU,gBAAgB;IACxB,MAAM,EAAE,IAAI,CACV,eAAe,EACf,IAAI,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,CACxD,CAAC;IACF;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5B,IAAI,EAAE;QACJ,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH;AAED,UAAU,oCAAoC;IAC5C,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,aAAa,GAAG,QAAQ,CAAC,CAAC;IACrE,YAAY,EAAE,SAAS,EAAE,CAAC;CAC3B;AAqrBD,eAAO,MAAM,oBAAoB,GAAI,yBAIlC,gBAAgB,mDAyGlB,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAAI,2BAG7C,oCAAoC,4CAiBtC,CAAC"}
|
|
@@ -17,6 +17,26 @@ const actionClassName = "group flex min-h-8 w-full min-w-0 touch-manipulation it
|
|
|
17
17
|
// Inline page-action link (icon + label) used in the mobile action row.
|
|
18
18
|
const inlineActionClassName = "group flex touch-manipulation items-center gap-1.5 whitespace-nowrap text-gray-900 text-label-12 font-medium transition-colors hover:text-gray-1000 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-700 focus-visible:ring-offset-2 focus-visible:ring-offset-background-100 motion-reduce:transition-none [&_svg]:size-3.5 [&_svg]:shrink-0";
|
|
19
19
|
const DEFAULT_EDIT_PATH = "content/docs/{path}";
|
|
20
|
+
const markdownRequests = new Map();
|
|
21
|
+
const getMarkdown = (url) => {
|
|
22
|
+
const cached = markdownRequests.get(url);
|
|
23
|
+
if (cached) {
|
|
24
|
+
return cached;
|
|
25
|
+
}
|
|
26
|
+
const request = fetch(url)
|
|
27
|
+
.then((response) => {
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
throw new Error(`Failed to fetch markdown from ${url}`);
|
|
30
|
+
}
|
|
31
|
+
return response.text();
|
|
32
|
+
})
|
|
33
|
+
.catch((error) => {
|
|
34
|
+
markdownRequests.delete(url);
|
|
35
|
+
throw error;
|
|
36
|
+
});
|
|
37
|
+
markdownRequests.set(url, request);
|
|
38
|
+
return request;
|
|
39
|
+
};
|
|
20
40
|
const trimSlashes = (value) => value.replace(/^\/+|\/+$/g, "");
|
|
21
41
|
const resolveEditPath = ({ editPath = DEFAULT_EDIT_PATH, path, }) => {
|
|
22
42
|
const pagePath = trimSlashes(path);
|
|
@@ -153,18 +173,22 @@ const FeedbackAction = ({ siteId }) => {
|
|
|
153
173
|
};
|
|
154
174
|
// The mobile action row: three primary actions rendered inline below the
|
|
155
175
|
// page description.
|
|
156
|
-
const InlinePageActions = ({ askAIEnabled, checked, copyEnabled, onAskAI, onCopy, onViewMarkdown, }) => {
|
|
176
|
+
const InlinePageActions = ({ askAIEnabled, checked, copyEnabled, onAskAI, onCopy, onPrefetchMarkdown, onViewMarkdown, }) => {
|
|
157
177
|
const CopyStateIcon = checked ? IconCheck : IconCopy;
|
|
158
|
-
|
|
178
|
+
let copyLabel = "Copy for LLM";
|
|
179
|
+
if (checked) {
|
|
180
|
+
copyLabel = "Copied";
|
|
181
|
+
}
|
|
182
|
+
return (_jsxs("div", { className: "flex items-center gap-3 border-b pb-3 text-label-12", children: [copyEnabled ? (_jsxs(_Fragment, { children: [_jsxs("button", { className: inlineActionClassName, onClick: onCopy, onFocus: onPrefetchMarkdown, onPointerEnter: onPrefetchMarkdown, type: "button", children: [_jsx(CopyStateIcon, {}), _jsx("span", { children: copyLabel })] }), _jsx("span", { "aria-hidden": "true", className: "h-4 w-px shrink-0 bg-gray-alpha-400 max-sm:hidden" }), _jsxs("button", { className: cn(inlineActionClassName, "max-sm:hidden"), onClick: onViewMarkdown, type: "button", children: [_jsx(IconAcronymMarkdown, { "aria-hidden": "true" }), _jsx("span", { children: "View Markdown" })] })] })) : null, copyEnabled && askAIEnabled ? (_jsx("span", { "aria-hidden": "true", className: "h-4 w-px shrink-0 bg-gray-alpha-400" })) : null, askAIEnabled ? (_jsxs("button", { className: inlineActionClassName, onClick: onAskAI, type: "button", children: [_jsx(IconMessage, {}), _jsx("span", { children: "Ask AI about this page" })] })) : null] }));
|
|
159
183
|
};
|
|
160
184
|
// The desktop action control: a compact copy button plus an actions dropdown,
|
|
161
185
|
// aligned beside the page title.
|
|
162
|
-
const DesktopPageActions = ({ askAIEnabled, checked, copyEnabled, editSourceEnabled, editSourceUrl, isMobile, menuView, onAskAI, onCopy, onViewMarkdown, openInChatEnabled, openInChatRef, otherProviders, providersBackRef, query, setMenuView, v0Provider, }) => {
|
|
163
|
-
return (_jsxs("div", { className: "inline-flex shrink-0 overflow-hidden rounded-md border border-gray-400 bg-background-100", children: [copyEnabled ? (_jsxs("button", { "aria-label": "Copy page", className: "inline-flex h-8 touch-manipulation items-center gap-1.5 whitespace-nowrap px-3 font-medium text-sm transition-colors hover:bg-gray-100 hover:text-gray-1000 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-gray-600/50", onClick: onCopy, type: "button", children: [_jsxs("span", { className: "relative size-4", children: [_jsx(IconCopy, { className: cn("absolute inset-0 size-4 transition-
|
|
186
|
+
const DesktopPageActions = ({ askAIEnabled, checked, copyEnabled, editSourceEnabled, editSourceUrl, isMobile, menuView, onAskAI, onCopy, onPrefetchMarkdown, onViewMarkdown, openInChatEnabled, openInChatRef, otherProviders, providersBackRef, query, setMenuView, v0Provider, }) => {
|
|
187
|
+
return (_jsxs("div", { className: "inline-flex shrink-0 overflow-hidden rounded-md border border-gray-400 bg-background-100", children: [copyEnabled ? (_jsxs("button", { "aria-label": "Copy page", className: "inline-flex h-8 touch-manipulation items-center gap-1.5 whitespace-nowrap px-3 font-medium text-sm transition-colors hover:bg-gray-100 hover:text-gray-1000 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-gray-600/50", onClick: onCopy, onFocus: onPrefetchMarkdown, onPointerEnter: onPrefetchMarkdown, type: "button", children: [_jsxs("span", { className: "relative size-4", children: [_jsx(IconCopy, { className: cn("absolute inset-0 size-4 transition-[transform,opacity] duration-200", checked ? "scale-75 opacity-0" : "scale-100 opacity-100") }), _jsx(IconCheck, { className: cn("absolute inset-0 size-4 transition-[transform,opacity] duration-200", checked ? "scale-100 opacity-100" : "scale-75 opacity-0") })] }), _jsx("span", { children: "Copy page" })] })) : null, _jsxs(DropdownMenu, { onOpenChange: (open) => {
|
|
164
188
|
if (!open) {
|
|
165
189
|
setMenuView("main");
|
|
166
190
|
}
|
|
167
|
-
}, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs("button", { "aria-label": copyEnabled ? "Open page actions" : "Page actions", className: "inline-flex h-8 touch-manipulation items-center justify-center gap-1.5 border-gray-400 border-l px-2 transition-colors hover:
|
|
191
|
+
}, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs("button", { "aria-label": copyEnabled ? "Open page actions" : "Page actions", className: "inline-flex h-8 touch-manipulation items-center justify-center gap-1.5 border-gray-400 border-l px-2 transition-colors hover:text-gray-1000 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-gray-600/50 data-[state=closed]:bg-transparent data-[state=open]:bg-gray-100 data-[state=closed]:hover:bg-gray-100", type: "button", children: [copyEnabled ? null : _jsx("span", { children: "Page actions" }), _jsx(IconChevronDown, { className: "size-4" })] }) }), _jsx(DropdownMenuContent, { align: "end", className: "w-80 max-w-[calc(100vw-1rem)]", sideOffset: 8, children: isMobile && menuView === "providers" ? (_jsx(ProviderMenuView, { backRef: providersBackRef, onBack: () => {
|
|
168
192
|
setMenuView("main");
|
|
169
193
|
requestAnimationFrame(() => openInChatRef.current?.focus());
|
|
170
194
|
}, providers: otherProviders, query: query })) : (_jsx(PageActionsMainMenu, { askAIEnabled: askAIEnabled, copyEnabled: copyEnabled, editSourceEnabled: editSourceEnabled, editSourceUrl: editSourceUrl, handleCopy: onCopy, isMobile: isMobile, onAskAI: onAskAI, onShowProviders: () => {
|
|
@@ -174,41 +198,20 @@ const DesktopPageActions = ({ askAIEnabled, checked, copyEnabled, editSourceEnab
|
|
|
174
198
|
};
|
|
175
199
|
export const GeistdocsPageActions = ({ config, page, only, }) => {
|
|
176
200
|
const isMobile = useIsMobile();
|
|
177
|
-
const { enabled: chatEnabled, setIsOpen, setPrompt } = useGeistdocsChat();
|
|
201
|
+
const { enabled: chatEnabled, preloadChat, setIsOpen, setPrompt, } = useGeistdocsChat();
|
|
178
202
|
const [menuView, setMenuView] = useState("main");
|
|
179
203
|
const openInChatRef = useRef(null);
|
|
180
204
|
const providersBackRef = useRef(null);
|
|
181
205
|
const markdownUrl = page.markdownUrl;
|
|
182
|
-
const fetchMarkdown =
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
throw new Error(`Failed to fetch markdown from ${markdownUrl}`);
|
|
186
|
-
}
|
|
187
|
-
return await response.text();
|
|
206
|
+
const fetchMarkdown = () => getMarkdown(markdownUrl);
|
|
207
|
+
const prefetchMarkdown = () => {
|
|
208
|
+
getMarkdown(markdownUrl).catch(() => undefined);
|
|
188
209
|
};
|
|
189
210
|
const [checked, handleCopy] = useCopyButton(async () => {
|
|
190
211
|
await navigator.clipboard.writeText(await fetchMarkdown());
|
|
191
212
|
});
|
|
192
213
|
const handleViewMarkdown = () => {
|
|
193
|
-
|
|
194
|
-
// markdown into a blob URL — keeps `.md` URLs out of the address bar
|
|
195
|
-
// and browser history (agents should cite canonical page URLs).
|
|
196
|
-
const viewer = window.open("about:blank", "_blank");
|
|
197
|
-
if (!viewer) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
fetchMarkdown()
|
|
201
|
-
.then((markdown) => {
|
|
202
|
-
const blob = new Blob([markdown], {
|
|
203
|
-
type: "text/plain;charset=utf-8",
|
|
204
|
-
});
|
|
205
|
-
const blobUrl = URL.createObjectURL(blob);
|
|
206
|
-
viewer.location.href = blobUrl;
|
|
207
|
-
setTimeout(() => URL.revokeObjectURL(blobUrl), 60_000);
|
|
208
|
-
})
|
|
209
|
-
.catch(() => {
|
|
210
|
-
viewer.close();
|
|
211
|
-
});
|
|
214
|
+
window.open(markdownUrl, "_blank", "noopener");
|
|
212
215
|
};
|
|
213
216
|
const editSourceUrl = getEditSourceUrl({
|
|
214
217
|
github: config.github,
|
|
@@ -229,13 +232,14 @@ export const GeistdocsPageActions = ({ config, page, only, }) => {
|
|
|
229
232
|
const showDesktop = only !== "mobile";
|
|
230
233
|
const showMobile = only !== "desktop";
|
|
231
234
|
const onAskAI = () => {
|
|
235
|
+
preloadChat();
|
|
232
236
|
setPrompt(getPageQuery(page.url, window.location.origin));
|
|
233
237
|
setIsOpen(true);
|
|
234
238
|
};
|
|
235
239
|
// Desktop variant aligns beside the title (self-end); the mobile variant is
|
|
236
240
|
// rendered below the description and left-aligned.
|
|
237
241
|
const rootClassName = only === "mobile" ? "@min-[961px]:hidden" : "self-end @max-[960px]:hidden";
|
|
238
|
-
return (_jsxs("div", { className: rootClassName, children: [showDesktop ? (_jsx(DesktopPageActions, { askAIEnabled: askAIEnabled, checked: checked, copyEnabled: copyEnabled, editSourceEnabled: editSourceEnabled, editSourceUrl: editSourceUrl, isMobile: isMobile, menuView: menuView, onAskAI: onAskAI, onCopy: handleCopy, onViewMarkdown: handleViewMarkdown, openInChatEnabled: openInChatEnabled, openInChatRef: openInChatRef, otherProviders: otherProviders, providersBackRef: providersBackRef, query: query, setMenuView: setMenuView, v0Provider: v0Provider })) : null, showMobile && (copyEnabled || askAIEnabled) ? (_jsx(InlinePageActions, { askAIEnabled: askAIEnabled, checked: checked, copyEnabled: copyEnabled, onAskAI: onAskAI, onCopy: handleCopy, onViewMarkdown: handleViewMarkdown })) : null, _jsx("span", { "aria-live": "polite", className: "sr-only", children: checked ? "Page copied" : "" })] }));
|
|
242
|
+
return (_jsxs("div", { className: rootClassName, onFocusCapture: preloadChat, onPointerEnter: preloadChat, children: [showDesktop ? (_jsx(DesktopPageActions, { askAIEnabled: askAIEnabled, checked: checked, copyEnabled: copyEnabled, editSourceEnabled: editSourceEnabled, editSourceUrl: editSourceUrl, isMobile: isMobile, menuView: menuView, onAskAI: onAskAI, onCopy: handleCopy, onPrefetchMarkdown: prefetchMarkdown, onViewMarkdown: handleViewMarkdown, openInChatEnabled: openInChatEnabled, openInChatRef: openInChatRef, otherProviders: otherProviders, providersBackRef: providersBackRef, query: query, setMenuView: setMenuView, v0Provider: v0Provider })) : null, showMobile && (copyEnabled || askAIEnabled) ? (_jsx(InlinePageActions, { askAIEnabled: askAIEnabled, checked: checked, copyEnabled: copyEnabled, onAskAI: onAskAI, onCopy: handleCopy, onPrefetchMarkdown: prefetchMarkdown, onViewMarkdown: handleViewMarkdown })) : null, _jsx("span", { "aria-live": "polite", className: "sr-only", children: checked ? "Page copied" : "" })] }));
|
|
239
243
|
};
|
|
240
244
|
export const GeistdocsTableOfContentsActions = ({ config, extraActions, }) => {
|
|
241
245
|
const actions = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-client.d.ts","sourceRoot":"","sources":["../../src/internal/provider-client.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"provider-client.d.ts","sourceRoot":"","sources":["../../src/internal/provider-client.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EACL,KAAK,cAAc,EAKpB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAejD,MAAM,WAAW,sBACf,SAAQ,cAAc,CAAC,OAAO,YAAY,CAAC;IAC3C,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AA0FD,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,4CAQ9D,CAAC"}
|
|
@@ -4,21 +4,55 @@ import { Toasts } from "@vercel/geistcn/components/toasts";
|
|
|
4
4
|
import { GeistProvider } from "@vercel/geistcn/core";
|
|
5
5
|
import { cn } from "@vercel/geistcn/utils";
|
|
6
6
|
import { RootProvider } from "fumadocs-ui/provider/next";
|
|
7
|
-
import { useCallback } from "react";
|
|
7
|
+
import { lazy, Suspense, useCallback, useEffect, } from "react";
|
|
8
8
|
import { GeistdocsChatProvider, useGeistdocsChat } from "./chat/context";
|
|
9
|
-
import {
|
|
9
|
+
import { ChatLoadingSkeleton } from "./chat/loading-skeleton";
|
|
10
10
|
import { GeistdocsConfigProvider } from "./config-context";
|
|
11
11
|
import { createGeistdocsI18n } from "./i18n";
|
|
12
12
|
import { GeistdocsSearchDialog } from "./search";
|
|
13
13
|
import { useIsMobile } from "./use-mobile";
|
|
14
|
+
const chatShellImport = () => import("./chat/shell");
|
|
15
|
+
const GeistdocsChatShell = lazy(() => chatShellImport().then(({ GeistdocsChatShell: Component }) => ({
|
|
16
|
+
default: Component,
|
|
17
|
+
})));
|
|
14
18
|
const GeistdocsProviderInner = ({ config, search, theme: _theme, lang, ...props }) => {
|
|
15
19
|
const { i18n, i18nProvider } = createGeistdocsI18n(config);
|
|
16
|
-
const { enabled, isOpen } = useGeistdocsChat();
|
|
20
|
+
const { enabled, hasBeenOpened, isOpen, setIsOpen } = useGeistdocsChat();
|
|
17
21
|
const isMobile = useIsMobile();
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!enabled) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const idle = window.requestIdleCallback(() => {
|
|
27
|
+
chatShellImport().catch(() => undefined);
|
|
28
|
+
});
|
|
29
|
+
return () => window.cancelIdleCallback(idle);
|
|
30
|
+
}, [enabled]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!enabled) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const handleKeyDown = (event) => {
|
|
36
|
+
if (event.key === "Escape" && isOpen) {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
setIsOpen(false);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if ((event.metaKey || event.ctrlKey) &&
|
|
42
|
+
!event.altKey &&
|
|
43
|
+
!event.shiftKey &&
|
|
44
|
+
event.key.toLowerCase() === "i") {
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
setIsOpen((open) => !open);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
document.addEventListener("keydown", handleKeyDown, true);
|
|
50
|
+
return () => document.removeEventListener("keydown", handleKeyDown, true);
|
|
51
|
+
}, [enabled, isOpen, setIsOpen]);
|
|
18
52
|
const SearchDialogComponent = useCallback((searchProps) => (_jsx(GeistdocsSearchDialog, { basePath: config.basePath, ...searchProps })), [config.basePath]);
|
|
19
53
|
return (_jsxs("div", { className: cn("@container transition-[padding-right] duration-150 ease-[cubic-bezier(0.175,0.885,0.32,1.1)] motion-reduce:transition-none", enabled && isOpen && !isMobile ? "pr-[400px]!" : null), "data-geistdocs-container": true, children: [_jsx(RootProvider, { i18n: i18nProvider(lang ?? i18n.defaultLanguage), search: {
|
|
20
54
|
SearchDialog: SearchDialogComponent,
|
|
21
55
|
...search,
|
|
22
|
-
}, theme: { enabled: false }, ...props }), _jsx(Toasts, {}), _jsx(GeistdocsChatShell, {})] }));
|
|
56
|
+
}, theme: { enabled: false }, ...props }), _jsx(Toasts, {}), hasBeenOpened ? (_jsx(Suspense, { fallback: isOpen ? (_jsx(ChatLoadingSkeleton, { isMobile: isMobile, title: config.title })) : null, children: _jsx(GeistdocsChatShell, {}) })) : null] }));
|
|
23
57
|
};
|
|
24
|
-
export const GeistdocsProvider = (props) => (_jsx(GeistProvider, { storageKey: "geistdocs-theme", children: _jsx(GeistdocsConfigProvider, { config: props.config, children: _jsx(GeistdocsChatProvider, { config: props.config, children: _jsx(GeistdocsProviderInner, { ...props }) }) }) }));
|
|
58
|
+
export const GeistdocsProvider = (props) => (_jsx(GeistProvider, { storageKey: "geistdocs-theme", withScript: false, children: _jsx(GeistdocsConfigProvider, { config: props.config, children: _jsx(GeistdocsChatProvider, { config: props.config, children: _jsx(GeistdocsProviderInner, { ...props }) }) }) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar-responsive.d.ts","sourceRoot":"","sources":["../../src/internal/sidebar-responsive.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,MAAM,CAAC
|
|
1
|
+
{"version":3,"file":"sidebar-responsive.d.ts","sourceRoot":"","sources":["../../src/internal/sidebar-responsive.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,MAAM,CAAC"}
|
|
@@ -1,10 +1 @@
|
|
|
1
1
|
export const SIDEBAR_DESKTOP_MIN_WIDTH = 961;
|
|
2
|
-
export const observeSidebarContainer = (container, onDesktop) => {
|
|
3
|
-
const resizeObserver = new ResizeObserver(([entry]) => {
|
|
4
|
-
if (entry && entry.contentRect.width >= SIDEBAR_DESKTOP_MIN_WIDTH) {
|
|
5
|
-
onDesktop();
|
|
6
|
-
}
|
|
7
|
-
});
|
|
8
|
-
resizeObserver.observe(container);
|
|
9
|
-
return () => resizeObserver.disconnect();
|
|
10
|
-
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../src/internal/sidebar.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAEL,KAAK,SAAS,EAQf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,oBAAoB,EAAuB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../src/internal/sidebar.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAEL,KAAK,SAAS,EAQf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,oBAAoB,EAAuB,MAAM,YAAY,CAAC;AA28B5E,eAAO,MAAM,gBAAgB,GAAI,6BAI9B;IACD,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB,4CAiEA,CAAC"}
|
package/dist/internal/sidebar.js
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, } from "@vercel/geistcn/components/sheet";
|
|
4
4
|
import { cn } from "@vercel/geistcn/utils";
|
|
5
|
-
import {
|
|
5
|
+
import { IconArrowUpRightSmall, IconChevronRightSmall, } from "@vercel/geistcn-assets/icons";
|
|
6
6
|
import Link from "fumadocs-core/link";
|
|
7
7
|
import { useTreeContext } from "fumadocs-ui/contexts/tree";
|
|
8
8
|
import { useParams, usePathname } from "next/navigation";
|
|
9
|
+
import { useSize } from "phase/react";
|
|
9
10
|
import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState, } from "react";
|
|
10
11
|
import { SearchButton } from "../controls";
|
|
11
12
|
import { useGeistdocsSidebar } from "../sidebar";
|
|
12
|
-
import {
|
|
13
|
+
import { SIDEBAR_DESKTOP_MIN_WIDTH } from "./sidebar-responsive";
|
|
13
14
|
import { findActiveRootSection, getDescendantFolderIds, getInitialOpenFolderIds, getSidebarBadgeTone, getSidebarItemBadge, getSidebarNodeId, getSidebarRootGroups, getSidebarSectionItems, hasSeparateRootDisclosure, isExternalSidebarItem, isExternalSidebarUrl, } from "./sidebar-tree";
|
|
14
15
|
const UNSAFE_ID_CHARACTERS = /[^a-zA-Z0-9_-]/g;
|
|
15
16
|
const collectPageUrls = (nodes) => {
|
|
@@ -66,6 +67,10 @@ const getDomId = (prefix, id) => `${prefix}-${id.replace(UNSAFE_ID_CHARACTERS, "
|
|
|
66
67
|
const getRootDisclosureLabel = (name) => typeof name === "string" || typeof name === "number"
|
|
67
68
|
? `Browse ${name}`
|
|
68
69
|
: "Browse Section";
|
|
70
|
+
const updateSidebarFades = (nav) => {
|
|
71
|
+
nav.dataset.fadeTop = String(nav.scrollTop > 0);
|
|
72
|
+
nav.dataset.fadeBottom = String(nav.scrollTop + nav.clientHeight < nav.scrollHeight - 1);
|
|
73
|
+
};
|
|
69
74
|
const scrollItemIntoView = (scrollContainer, item) => {
|
|
70
75
|
const containerRect = scrollContainer.getBoundingClientRect();
|
|
71
76
|
const itemRect = item.getBoundingClientRect();
|
|
@@ -137,7 +142,8 @@ const getSidebarRowTone = (isSelected, isGroup) => {
|
|
|
137
142
|
}
|
|
138
143
|
return "text-gray-900 hover:bg-gray-100 hover:text-gray-1000 focus-visible:bg-gray-100 focus-visible:text-gray-1000";
|
|
139
144
|
};
|
|
140
|
-
const SidebarDisclosureIcon = ({ expanded }) => (_jsx(
|
|
145
|
+
const SidebarDisclosureIcon = ({ expanded }) => (_jsx(IconChevronRightSmall, { className: cn(expanded && "rotate-90"), size: 16 }));
|
|
146
|
+
const SidebarTrailingIcon = ({ children, className, }) => (_jsx("span", { className: cn("grid h-9 w-8 flex-none place-content-center text-gray-900", className), children: children }));
|
|
141
147
|
const SidebarBadge = ({ label }) => label ? (_jsx("span", { className: cn("inline-flex h-6 max-w-24 shrink-0 items-center truncate rounded-full px-2 text-button-12", getSidebarBadgeTone(label)), children: label })) : null;
|
|
142
148
|
const SidebarTreeNode = ({ depth, node, path, state, }) => {
|
|
143
149
|
const nodeId = getSidebarNodeId(node, path, state.idScope);
|
|
@@ -154,7 +160,7 @@ const SidebarTreeNode = ({ depth, node, path, state, }) => {
|
|
|
154
160
|
const menuId = getDomId(state.idPrefix, nodeId);
|
|
155
161
|
const labelId = `${menuId}-label`;
|
|
156
162
|
const rowClassName = cn("flex h-9 origin-left touch-manipulation flex-row items-center rounded-md pr-1 pl-2.5 motion-reduce:transition-none", getSidebarRowTone(isSelected, isGroup));
|
|
157
|
-
const content = (_jsxs(_Fragment, { children: [node.icon ? (_jsx("span", { className: "shrink-0 [&_svg]:size-4", children: node.icon })) : null, _jsxs("span", { className: cn("flex min-w-0 flex-1 items-center gap-1.5 truncate text-button-14", depth > 0 && "font-normal"), children: [_jsx(SidebarBadge, { label: badge }), _jsx("span", { className: "min-w-0 flex-1 truncate", id: labelId, children: node.name }), isExternalSidebarItem(item) ? (_jsx(
|
|
163
|
+
const content = (_jsxs(_Fragment, { children: [node.icon ? (_jsx("span", { className: "shrink-0 [&_svg]:size-4", children: node.icon })) : null, _jsxs("span", { className: cn("flex min-w-0 flex-1 items-center gap-1.5 truncate text-button-14", depth > 0 && "font-normal"), children: [_jsx(SidebarBadge, { label: badge }), _jsx("span", { className: "min-w-0 flex-1 truncate", id: labelId, children: node.name }), isExternalSidebarItem(item) ? (_jsx(SidebarTrailingIcon, { children: _jsx(IconArrowUpRightSmall, { size: 16 }) })) : null] })] }));
|
|
158
164
|
const handleLinkClick = (event) => {
|
|
159
165
|
state.onNavigate?.();
|
|
160
166
|
if (opensOutsideCurrentPage(event, item?.external, item?.url ?? "")) {
|
|
@@ -170,7 +176,7 @@ const SidebarTreeNode = ({ depth, node, path, state, }) => {
|
|
|
170
176
|
primaryControl = (_jsx(Link, { "aria-current": isSelected ? "page" : undefined, className: cn(rowClassName, "min-w-0 flex-1 no-underline outline-none focus-visible:shadow-[var(--ds-focus-ring)]"), external: item.external, href: item.url, onClick: handleLinkClick, prefetch: true, children: content }));
|
|
171
177
|
}
|
|
172
178
|
else if (folder && hasChildren) {
|
|
173
|
-
primaryControl = (_jsxs("button", { "aria-controls": menuId, "aria-expanded": isExpanded, className: cn(rowClassName, "w-full min-w-0 flex-1 cursor-pointer border-0 bg-transparent text-left outline-none focus-visible:shadow-[var(--ds-focus-ring)]"), onClick: () => state.toggleFolder(folder, path), type: "button", children: [content, _jsx(
|
|
179
|
+
primaryControl = (_jsxs("button", { "aria-controls": menuId, "aria-expanded": isExpanded, className: cn(rowClassName, "w-full min-w-0 flex-1 cursor-pointer border-0 bg-transparent text-left outline-none focus-visible:shadow-[var(--ds-focus-ring)]"), onClick: () => state.toggleFolder(folder, path), type: "button", children: [content, _jsx(SidebarTrailingIcon, { className: "-mr-1", children: _jsx(SidebarDisclosureIcon, { expanded: isExpanded }) })] }));
|
|
174
180
|
}
|
|
175
181
|
else {
|
|
176
182
|
primaryControl = (_jsx("span", { className: cn(rowClassName, "min-w-0 flex-1"), children: content }));
|
|
@@ -210,7 +216,7 @@ const SidebarRootItem = ({ activeSection, activeUrl, item, onSelect, }) => {
|
|
|
210
216
|
const className = cn("flex h-9 touch-manipulation items-center gap-2 rounded-md pr-2 pl-2.5 no-underline outline-none focus-visible:shadow-[var(--ds-focus-ring)] motion-reduce:transition-none", isActive
|
|
211
217
|
? "bg-gray-200 text-gray-1000"
|
|
212
218
|
: "text-gray-900 hover:bg-gray-100 hover:text-gray-1000 focus-visible:bg-gray-100");
|
|
213
|
-
const content = (_jsxs(_Fragment, { children: [item.icon ? (_jsx("span", { className: "shrink-0 [&_svg]:size-4", children: item.icon })) : null, _jsx(SidebarBadge, { label: badge }), _jsx("span", { className: cn("min-w-0 flex-1 truncate text-button-14", labelWeight), children: item.name }), isExternalSidebarItem(linkItem) ? (_jsx(
|
|
219
|
+
const content = (_jsxs(_Fragment, { children: [item.icon ? (_jsx("span", { className: "shrink-0 [&_svg]:size-4", children: item.icon })) : null, _jsx(SidebarBadge, { label: badge }), _jsx("span", { className: cn("min-w-0 flex-1 truncate text-button-14", labelWeight), children: item.name }), isExternalSidebarItem(linkItem) ? (_jsx(SidebarTrailingIcon, { children: _jsx(IconArrowUpRightSmall, { size: 16 }) })) : null, opensSection && !separateDisclosure ? (_jsx(SidebarTrailingIcon, { children: _jsx(IconChevronRightSmall, { size: 16 }) })) : null] }));
|
|
214
220
|
let renderedItem;
|
|
215
221
|
if (linkItem) {
|
|
216
222
|
renderedItem = (_jsx(Link, { "aria-current": isCurrentPage ? "page" : undefined, className: cn(className, separateDisclosure && "min-w-0 flex-1"), "data-sidebar-active": isActive, external: linkItem.external, href: linkItem.url, onClick: folder && opensSection
|
|
@@ -227,9 +233,9 @@ const SidebarRootItem = ({ activeSection, activeUrl, item, onSelect, }) => {
|
|
|
227
233
|
else {
|
|
228
234
|
renderedItem = _jsx("span", { className: className, children: content });
|
|
229
235
|
}
|
|
230
|
-
return (_jsxs("li", { className: cn(separateDisclosure && "flex items-center gap-px"), children: [renderedItem, separateDisclosure ? (_jsx("button", { "aria-label": getRootDisclosureLabel(item.name), className: "grid size-8 flex-none cursor-pointer touch-manipulation place-content-center rounded-md bg-transparent p-0 text-gray-900 hover:bg-gray-100 focus-visible:bg-gray-100 focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:outline-none motion-reduce:transition-none", onClick: (event) => onSelect(item, event.currentTarget), type: "button", children: _jsx(
|
|
236
|
+
return (_jsxs("li", { className: cn(separateDisclosure && "flex items-center gap-px"), children: [renderedItem, separateDisclosure ? (_jsx("button", { "aria-label": getRootDisclosureLabel(item.name), className: "grid size-8 flex-none cursor-pointer touch-manipulation place-content-center rounded-md bg-transparent p-0 text-gray-900 hover:bg-gray-100 focus-visible:bg-gray-100 focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:outline-none motion-reduce:transition-none", onClick: (event) => onSelect(item, event.currentTarget), type: "button", children: _jsx(IconChevronRightSmall, { size: 16 }) })) : null] }));
|
|
231
237
|
};
|
|
232
|
-
const SidebarSectionHeader = ({ buttonRef, onBack, section, }) => (_jsx("div", { className: "mb-2 px-2 pt-1", children: _jsxs("button", { "aria-label": "Back to all documentation sections", className: "flex w-full cursor-pointer touch-manipulation flex-row items-center justify-between gap-1 rounded-md border-0 bg-transparent p-0 text-gray-900 hover:bg-gray-100 hover:text-gray-1000 focus-visible:bg-gray-100 focus-visible:text-gray-1000 focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:outline-none motion-reduce:transition-none", onClick: onBack, ref: buttonRef, type: "button", children: [_jsx("span", { className: "grid size-9 flex-none place-content-center", children: _jsx(
|
|
238
|
+
const SidebarSectionHeader = ({ buttonRef, onBack, section, }) => (_jsx("div", { className: "mb-2 px-2 pt-1", children: _jsxs("button", { "aria-label": "Back to all documentation sections", className: "flex w-full cursor-pointer touch-manipulation flex-row items-center justify-between gap-1 rounded-md border-0 bg-transparent p-0 text-gray-900 hover:bg-gray-100 hover:text-gray-1000 focus-visible:bg-gray-100 focus-visible:text-gray-1000 focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:outline-none motion-reduce:transition-none", onClick: onBack, ref: buttonRef, type: "button", children: [_jsx("span", { className: "grid size-9 flex-none place-content-center", children: _jsx(IconChevronRightSmall, { className: "rotate-180", size: 16 }) }), _jsx("span", { className: "flex min-w-0 flex-1 items-center justify-center text-button-14", children: _jsx("span", { className: "truncate", children: section.name }) }), _jsx("span", { className: "size-9 flex-none" })] }) }));
|
|
233
239
|
const DesktopSectionsSidebar = ({ activeUrl, nodes, rootScope, top, }) => {
|
|
234
240
|
const groups = useMemo(() => getSidebarRootGroups(nodes), [nodes]);
|
|
235
241
|
const currentSection = useMemo(() => findActiveRootSection(nodes, activeUrl), [activeUrl, nodes]);
|
|
@@ -238,6 +244,14 @@ const DesktopSectionsSidebar = ({ activeUrl, nodes, rootScope, top, }) => {
|
|
|
238
244
|
const [view, setView] = useState(currentSection ? "section" : "root");
|
|
239
245
|
const [sectionRevealed, setSectionRevealed] = useState(view === "section");
|
|
240
246
|
const navRef = useRef(null);
|
|
247
|
+
useSize({
|
|
248
|
+
onResize: () => {
|
|
249
|
+
if (navRef.current) {
|
|
250
|
+
updateSidebarFades(navRef.current);
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
ref: navRef,
|
|
254
|
+
});
|
|
241
255
|
const returnFocusRef = useRef(null);
|
|
242
256
|
const sectionHeaderRef = useRef(null);
|
|
243
257
|
const shouldFocusRootRef = useRef(false);
|
|
@@ -263,17 +277,24 @@ const DesktopSectionsSidebar = ({ activeUrl, nodes, rootScope, top, }) => {
|
|
|
263
277
|
if (!nav) {
|
|
264
278
|
return;
|
|
265
279
|
}
|
|
266
|
-
const updateFades = () =>
|
|
267
|
-
|
|
268
|
-
|
|
280
|
+
const updateFades = () => updateSidebarFades(nav);
|
|
281
|
+
let frame;
|
|
282
|
+
const scheduleFadeUpdate = () => {
|
|
283
|
+
if (frame !== undefined) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
frame = requestAnimationFrame(() => {
|
|
287
|
+
frame = undefined;
|
|
288
|
+
updateFades();
|
|
289
|
+
});
|
|
269
290
|
};
|
|
270
|
-
const resizeObserver = new ResizeObserver(updateFades);
|
|
271
291
|
updateFades();
|
|
272
|
-
nav.addEventListener("scroll",
|
|
273
|
-
resizeObserver.observe(nav);
|
|
292
|
+
nav.addEventListener("scroll", scheduleFadeUpdate, { passive: true });
|
|
274
293
|
return () => {
|
|
275
|
-
|
|
276
|
-
|
|
294
|
+
if (frame !== undefined) {
|
|
295
|
+
cancelAnimationFrame(frame);
|
|
296
|
+
}
|
|
297
|
+
nav.removeEventListener("scroll", scheduleFadeUpdate);
|
|
277
298
|
};
|
|
278
299
|
}, []);
|
|
279
300
|
const sectionShown = view === "section" && sectionRevealed;
|
|
@@ -318,7 +339,15 @@ const MobileSidebar = ({ activeUrl, idScope, nodes, onOpenChange, open, top, })
|
|
|
318
339
|
export const GeistdocsSidebar = ({ mode = "sections", showDesktop = true, top, }) => {
|
|
319
340
|
const { root, full } = useTreeContext();
|
|
320
341
|
const { isOpen, setIsOpen } = useGeistdocsSidebar();
|
|
321
|
-
const
|
|
342
|
+
const containerRef = useRef(null);
|
|
343
|
+
useSize({
|
|
344
|
+
onResize: ({ width }) => {
|
|
345
|
+
if (width >= SIDEBAR_DESKTOP_MIN_WIDTH) {
|
|
346
|
+
setIsOpen(false);
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
ref: containerRef,
|
|
350
|
+
});
|
|
322
351
|
const pathname = usePathname();
|
|
323
352
|
const previousPathname = useRef(pathname);
|
|
324
353
|
const params = useParams();
|
|
@@ -334,12 +363,8 @@ export const GeistdocsSidebar = ({ mode = "sections", showDesktop = true, top, }
|
|
|
334
363
|
previousPathname.current = pathname;
|
|
335
364
|
}
|
|
336
365
|
}, [pathname, setIsOpen]);
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}
|
|
342
|
-
return observeSidebarContainer(container, () => setIsOpen(false));
|
|
343
|
-
}, [setIsOpen]);
|
|
344
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { hidden: true, ref: containerMarkerRef }), showDesktop ? (_jsx(DesktopSidebar, { activeUrl: activeUrl, mode: mode, nodes: root.children, rootScope: rootScope, top: top }, root.$id)) : null, _jsx(MobileSidebar, { activeUrl: activeUrl, idScope: rootScope, nodes: root.children, onOpenChange: setIsOpen, open: isOpen, top: top })] }));
|
|
366
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { hidden: true, ref: (marker) => {
|
|
367
|
+
containerRef.current =
|
|
368
|
+
marker?.closest("[data-geistdocs-container]") ?? null;
|
|
369
|
+
} }), showDesktop ? (_jsx(DesktopSidebar, { activeUrl: activeUrl, mode: mode, nodes: root.children, rootScope: rootScope, top: top }, root.$id)) : null, _jsx(MobileSidebar, { activeUrl: activeUrl, idScope: rootScope, nodes: root.children, onOpenChange: setIsOpen, open: isOpen, top: top })] }));
|
|
345
370
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-of-contents.d.ts","sourceRoot":"","sources":["../../src/internal/table-of-contents.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,UAAU,6BAA6B;IACrC,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,GAAG,EAAE,eAAe,CAAC;CACtB;AAED,eAAO,MAAM,wBAAwB,GAAI,0BAItC,6BAA6B,
|
|
1
|
+
{"version":3,"file":"table-of-contents.d.ts","sourceRoot":"","sources":["../../src/internal/table-of-contents.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,UAAU,6BAA6B;IACrC,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,GAAG,EAAE,eAAe,CAAC;CACtB;AAED,eAAO,MAAM,wBAAwB,GAAI,0BAItC,6BAA6B,4CAwB/B,CAAC"}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { TOCScrollArea } from "fumadocs-ui/components/toc/index";
|
|
4
4
|
import { TOCItems } from "./toc-items";
|
|
5
|
-
export const GeistdocsTableOfContents = ({ footer, header, toc, }) => (_jsx("aside", { "aria-label": "Page navigation", className: "sticky top-(--fd-docs-row-1) hidden h-[calc(var(--fd-docs-height)-var(--fd-docs-row-1))] w-(--fd-toc-width) flex-col pt-14 pr-4 pb-2 [grid-area:toc] xl:flex", id: "nd-toc", children: _jsxs("nav", { "aria-label": "On this page", className: "flex min-h-0 flex-1 flex-col", children: [header, toc.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("p", { className: "mb-2 font-medium text-gray-1000 text-sm", children: "On this page" }), _jsx(TOCScrollArea, { className: "geistdocs-toc-scroll", children: _jsx(TOCItems, {}) })] })) : null, footer] }) }));
|
|
5
|
+
export const GeistdocsTableOfContents = ({ footer, header, toc, }) => (_jsx("aside", { "aria-label": "Page navigation", className: "sticky top-(--fd-docs-row-1) hidden h-[calc(var(--fd-docs-height)-var(--fd-docs-row-1))] w-(--fd-toc-width) flex-col pt-14 pr-4 pb-2 [grid-area:toc] xl:flex", id: "nd-toc", children: _jsxs("nav", { "aria-label": "On this page", className: "ml-0.5 flex min-h-0 flex-1 flex-col", children: [header, toc.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("p", { className: "mb-2 font-medium text-gray-1000 text-sm", children: "On this page" }), _jsx(TOCScrollArea, { className: "geistdocs-toc-scroll", children: _jsx(TOCItems, {}) })] })) : null, footer] }) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toc-items.d.ts","sourceRoot":"","sources":["../../src/internal/toc-items.tsx"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,cAAc,EAKpB,MAAM,OAAO,CAAC;AAsCf,eAAO,MAAM,QAAQ,GAAI,yBAAyB,cAAc,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"toc-items.d.ts","sourceRoot":"","sources":["../../src/internal/toc-items.tsx"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,cAAc,EAKpB,MAAM,OAAO,CAAC;AAsCf,eAAO,MAAM,QAAQ,GAAI,yBAAyB,cAAc,CAAC,KAAK,CAAC,4CA2FtE,CAAC"}
|
|
@@ -40,6 +40,7 @@ export const TOCItems = ({ className, ...props }) => {
|
|
|
40
40
|
}, ANCHOR_SCROLL_MS);
|
|
41
41
|
}, []);
|
|
42
42
|
useEffect(() => {
|
|
43
|
+
let frame;
|
|
43
44
|
const syncFromHash = () => select(window.location.hash.slice(1) || null);
|
|
44
45
|
const updateAtBottom = () => {
|
|
45
46
|
const doc = document.documentElement;
|
|
@@ -50,21 +51,30 @@ export const TOCItems = ({ className, ...props }) => {
|
|
|
50
51
|
// Any real scroll — wheel, touch, keyboard, or scrollbar drag — hands the
|
|
51
52
|
// indicator back to viewport-based tracking, unless it is the programmatic
|
|
52
53
|
// jump from a click/deep-link.
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
setSelected(null);
|
|
54
|
+
const scheduleScrollUpdate = () => {
|
|
55
|
+
if (frame !== undefined) {
|
|
56
|
+
return;
|
|
57
57
|
}
|
|
58
|
+
frame = requestAnimationFrame(() => {
|
|
59
|
+
frame = undefined;
|
|
60
|
+
updateAtBottom();
|
|
61
|
+
if (!ignoreScroll.current) {
|
|
62
|
+
setSelected(null);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
58
65
|
};
|
|
59
66
|
syncFromHash();
|
|
60
67
|
updateAtBottom();
|
|
61
68
|
window.addEventListener("hashchange", syncFromHash);
|
|
62
|
-
window.addEventListener("scroll",
|
|
69
|
+
window.addEventListener("scroll", scheduleScrollUpdate, { passive: true });
|
|
63
70
|
window.addEventListener("resize", updateAtBottom);
|
|
64
71
|
return () => {
|
|
65
72
|
clearTimeout(ignoreTimer.current);
|
|
73
|
+
if (frame !== undefined) {
|
|
74
|
+
cancelAnimationFrame(frame);
|
|
75
|
+
}
|
|
66
76
|
window.removeEventListener("hashchange", syncFromHash);
|
|
67
|
-
window.removeEventListener("scroll",
|
|
77
|
+
window.removeEventListener("scroll", scheduleScrollUpdate);
|
|
68
78
|
window.removeEventListener("resize", updateAtBottom);
|
|
69
79
|
};
|
|
70
80
|
}, [select]);
|
|
@@ -10,10 +10,10 @@ export function DropdownMenuTrigger(props) {
|
|
|
10
10
|
return (_jsx(DropdownMenuPrimitive.Trigger, { "data-slot": "dropdown-menu-trigger", ...props }));
|
|
11
11
|
}
|
|
12
12
|
export function DropdownMenuContent({ className, sideOffset = 4, ...props }) {
|
|
13
|
-
return (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuPrimitive.Content, { className: cn("data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 material-menu z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-y-auto overflow-x-hidden overscroll-contain p-
|
|
13
|
+
return (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuPrimitive.Content, { className: cn("data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 material-menu z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-y-auto overflow-x-hidden overscroll-contain p-(--ds-popover-padding) text-gray-1000 data-[state=closed]:animate-out motion-reduce:animate-none", className), "data-slot": "dropdown-menu-content", sideOffset: sideOffset, ...props }) }));
|
|
14
14
|
}
|
|
15
15
|
export function DropdownMenuItem({ className, inset, variant = "default", ...props }) {
|
|
16
|
-
return (_jsx(DropdownMenuPrimitive.Item, { className: cn("data-[variant=destructive]:*:[svg]:!text-red-800 relative flex cursor-default touch-manipulation select-none items-center gap-2 rounded-
|
|
16
|
+
return (_jsx(DropdownMenuPrimitive.Item, { className: cn("data-[variant=destructive]:*:[svg]:!text-red-800 relative flex cursor-default touch-manipulation select-none items-center gap-2 rounded-(--ds-popover-row-radius) px-2 py-1.5 text-label-14 outline-hidden focus:bg-gray-100 focus:text-gray-1000 data-[disabled]:pointer-events-none data-[inset]:pl-8 data-[variant=destructive]:text-red-800 data-[disabled]:opacity-50 data-[variant=destructive]:focus:bg-red-800/10 data-[variant=destructive]:focus:text-red-800 dark:data-[variant=destructive]:focus:bg-red-800/20 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-gray-900 [&_svg]:pointer-events-none [&_svg]:shrink-0", className), "data-inset": inset, "data-slot": "dropdown-menu-item", "data-variant": variant, ...props }));
|
|
17
17
|
}
|
|
18
18
|
export function DropdownMenuLabel({ className, inset, ...props }) {
|
|
19
19
|
return (_jsx(DropdownMenuPrimitive.Label, { className: cn("px-2 py-1.5 font-medium text-sm data-[inset]:pl-8", className), "data-inset": inset, "data-slot": "dropdown-menu-label", ...props }));
|
|
@@ -22,20 +22,20 @@ export function DropdownMenuSeparator({ className, ...props }) {
|
|
|
22
22
|
return (_jsx(DropdownMenuPrimitive.Separator, { className: cn("-mx-1 my-1 h-px bg-gray-alpha-400", className), "data-slot": "dropdown-menu-separator", ...props }));
|
|
23
23
|
}
|
|
24
24
|
export function DropdownMenuCheckboxItem({ className, children, checked, ...props }) {
|
|
25
|
-
return (_jsxs(DropdownMenuPrimitive.CheckboxItem, { checked: checked, className: cn("relative flex cursor-default select-none items-center gap-2 rounded-
|
|
25
|
+
return (_jsxs(DropdownMenuPrimitive.CheckboxItem, { checked: checked, className: cn("relative flex cursor-default select-none items-center gap-2 rounded-(--ds-popover-row-radius) py-1.5 pr-2 pl-8 text-sm outline-hidden focus:bg-gray-100 focus:text-gray-1000 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0", className), "data-slot": "dropdown-menu-checkbox-item", ...props, children: [_jsx("span", { className: "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx(IconCheck, { className: "size-4" }) }) }), children] }));
|
|
26
26
|
}
|
|
27
27
|
export function DropdownMenuRadioGroup(props) {
|
|
28
28
|
return (_jsx(DropdownMenuPrimitive.RadioGroup, { "data-slot": "dropdown-menu-radio-group", ...props }));
|
|
29
29
|
}
|
|
30
30
|
export function DropdownMenuRadioItem({ className, children, ...props }) {
|
|
31
|
-
return (_jsxs(DropdownMenuPrimitive.RadioItem, { className: cn("relative flex cursor-default select-none items-center gap-2 rounded-
|
|
31
|
+
return (_jsxs(DropdownMenuPrimitive.RadioItem, { className: cn("relative flex cursor-default select-none items-center gap-2 rounded-(--ds-popover-row-radius) py-1.5 pr-2 pl-8 text-sm outline-hidden focus:bg-gray-100 focus:text-gray-1000 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0", className), "data-slot": "dropdown-menu-radio-item", ...props, children: [_jsx("span", { className: "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx(IconCircle, { className: "size-2 fill-current" }) }) }), children] }));
|
|
32
32
|
}
|
|
33
33
|
export function DropdownMenuSub(props) {
|
|
34
34
|
return _jsx(DropdownMenuPrimitive.Sub, { "data-slot": "dropdown-menu-sub", ...props });
|
|
35
35
|
}
|
|
36
36
|
export function DropdownMenuSubTrigger({ className, inset, children, ...props }) {
|
|
37
|
-
return (_jsxs(DropdownMenuPrimitive.SubTrigger, { className: cn("flex cursor-default touch-manipulation select-none items-center gap-2 rounded-
|
|
37
|
+
return (_jsxs(DropdownMenuPrimitive.SubTrigger, { className: cn("flex cursor-default touch-manipulation select-none items-center gap-2 rounded-(--ds-popover-row-radius) px-2 py-1.5 text-label-14 outline-hidden focus:bg-gray-100 focus:text-gray-1000 data-[state=open]:bg-gray-100 data-[inset]:pl-8 data-[state=open]:text-gray-1000 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-gray-900 [&_svg]:pointer-events-none [&_svg]:shrink-0", className), "data-inset": inset, "data-slot": "dropdown-menu-sub-trigger", ...props, children: [children, _jsx(IconChevronRight, { className: "ml-auto size-4" })] }));
|
|
38
38
|
}
|
|
39
39
|
export function DropdownMenuSubContent({ className, ...props }) {
|
|
40
|
-
return (_jsx(DropdownMenuPrimitive.SubContent, { className: cn("data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 material-menu z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden overscroll-contain p-
|
|
40
|
+
return (_jsx(DropdownMenuPrimitive.SubContent, { className: cn("data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 material-menu z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden overscroll-contain p-(--ds-popover-padding) text-gray-1000 data-[state=closed]:animate-out motion-reduce:animate-none", className), "data-slot": "dropdown-menu-sub-content", ...props }));
|
|
41
41
|
}
|