fumadocs-ui 15.5.4 → 15.6.0

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 (38) hide show
  1. package/css/neutral.css +2 -2
  2. package/css/preset.css +9 -2
  3. package/css/shiki.css +7 -1
  4. package/dist/components/banner.d.ts +8 -2
  5. package/dist/components/banner.d.ts.map +1 -1
  6. package/dist/components/banner.js +24 -29
  7. package/dist/components/callout.d.ts.map +1 -1
  8. package/dist/components/callout.js +12 -22
  9. package/dist/components/card.d.ts.map +1 -1
  10. package/dist/components/card.js +2 -2
  11. package/dist/components/codeblock.d.ts +14 -33
  12. package/dist/components/codeblock.d.ts.map +1 -1
  13. package/dist/components/codeblock.js +50 -25
  14. package/dist/components/layout/sidebar.js +1 -1
  15. package/dist/components/tabs.d.ts +8 -19
  16. package/dist/components/tabs.d.ts.map +1 -1
  17. package/dist/components/tabs.js +17 -74
  18. package/dist/components/tabs.unstyled.d.ts +24 -0
  19. package/dist/components/tabs.unstyled.d.ts.map +1 -0
  20. package/dist/components/tabs.unstyled.js +89 -0
  21. package/dist/layouts/docs/page-client.js +1 -1
  22. package/dist/layouts/docs/page.js +1 -1
  23. package/dist/layouts/docs.js +3 -3
  24. package/dist/layouts/home/navbar.d.ts.map +1 -1
  25. package/dist/layouts/home/navbar.js +3 -1
  26. package/dist/layouts/notebook-client.d.ts +3 -2
  27. package/dist/layouts/notebook-client.d.ts.map +1 -1
  28. package/dist/layouts/notebook-client.js +15 -11
  29. package/dist/layouts/notebook.d.ts.map +1 -1
  30. package/dist/layouts/notebook.js +6 -6
  31. package/dist/mdx.d.ts +5 -0
  32. package/dist/mdx.d.ts.map +1 -1
  33. package/dist/mdx.js +5 -1
  34. package/dist/style.css +114 -110
  35. package/package.json +6 -6
  36. package/dist/components/ui/tabs.d.ts +0 -8
  37. package/dist/components/ui/tabs.d.ts.map +0 -1
  38. package/dist/components/ui/tabs.js +0 -16
@@ -0,0 +1,24 @@
1
+ import { type ComponentProps } from 'react';
2
+ import * as Primitive from '@radix-ui/react-tabs';
3
+ export interface TabsProps extends ComponentProps<typeof Primitive.Tabs> {
4
+ /**
5
+ * Identifier for Sharing value of tabs
6
+ */
7
+ groupId?: string;
8
+ /**
9
+ * Enable persistent
10
+ */
11
+ persist?: boolean;
12
+ /**
13
+ * If true, updates the URL hash based on the tab's id
14
+ */
15
+ updateAnchor?: boolean;
16
+ }
17
+ export declare const TabsList: import("react").ForwardRefExoticComponent<Primitive.TabsListProps & import("react").RefAttributes<HTMLDivElement>>;
18
+ export declare const TabsTrigger: import("react").ForwardRefExoticComponent<Primitive.TabsTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
19
+ /**
20
+ * @internal You better not use it
21
+ */
22
+ export declare function Tabs({ ref, groupId, persist, updateAnchor, defaultValue, value: _value, onValueChange: _onValueChange, ...props }: TabsProps): import("react/jsx-runtime").JSX.Element;
23
+ export declare function TabsContent({ value, ...props }: ComponentProps<typeof Primitive.TabsContent>): import("react/jsx-runtime").JSX.Element;
24
+ //# sourceMappingURL=tabs.unstyled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs.unstyled.d.ts","sourceRoot":"","sources":["../../src/components/tabs.unstyled.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EAOpB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAqBlD,MAAM,WAAW,SAAU,SAAQ,cAAc,CAAC,OAAO,SAAS,CAAC,IAAI,CAAC;IACtE;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAYD,eAAO,MAAM,QAAQ,oHAAqB,CAAC;AAE3C,eAAO,MAAM,WAAW,0HAAwB,CAAC;AAEjD;;GAEG;AACH,wBAAgB,IAAI,CAAC,EACnB,GAAG,EACH,OAAO,EACP,OAAe,EACf,YAAoB,EACpB,YAAY,EACZ,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,cAAc,EAC7B,GAAG,KAAK,EACT,EAAE,SAAS,2CAsEX;AAED,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,OAAO,SAAS,CAAC,WAAW,CAAC,2CAY9C"}
@@ -0,0 +1,89 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useLayoutEffect, useMemo, useRef, useState, } from 'react';
4
+ import * as Primitive from '@radix-ui/react-tabs';
5
+ import { mergeRefs } from '../utils/merge-refs.js';
6
+ import { useEffectEvent } from 'fumadocs-core/utils/use-effect-event';
7
+ const listeners = new Map();
8
+ function addChangeListener(id, listener) {
9
+ const list = listeners.get(id) ?? [];
10
+ list.push(listener);
11
+ listeners.set(id, list);
12
+ }
13
+ function removeChangeListener(id, listener) {
14
+ const list = listeners.get(id) ?? [];
15
+ listeners.set(id, list.filter((item) => item !== listener));
16
+ }
17
+ const TabsContext = createContext(null);
18
+ function useTabContext() {
19
+ const ctx = useContext(TabsContext);
20
+ if (!ctx)
21
+ throw new Error('You must wrap your component in <Tabs>');
22
+ return ctx;
23
+ }
24
+ export const TabsList = Primitive.TabsList;
25
+ export const TabsTrigger = Primitive.TabsTrigger;
26
+ /**
27
+ * @internal You better not use it
28
+ */
29
+ export function Tabs({ ref, groupId, persist = false, updateAnchor = false, defaultValue, value: _value, onValueChange: _onValueChange, ...props }) {
30
+ const tabsRef = useRef(null);
31
+ const [value, setValue] = _value === undefined
32
+ ? // eslint-disable-next-line react-hooks/rules-of-hooks -- not supposed to change controlled/uncontrolled
33
+ useState(defaultValue)
34
+ : [_value, _onValueChange ?? (() => undefined)];
35
+ const onChange = useEffectEvent((v) => setValue(v));
36
+ const valueToIdMap = useMemo(() => new Map(), []);
37
+ useLayoutEffect(() => {
38
+ if (!groupId)
39
+ return;
40
+ const previous = persist
41
+ ? localStorage.getItem(groupId)
42
+ : sessionStorage.getItem(groupId);
43
+ if (previous)
44
+ onChange(previous);
45
+ addChangeListener(groupId, onChange);
46
+ return () => {
47
+ removeChangeListener(groupId, onChange);
48
+ };
49
+ }, [groupId, onChange, persist]);
50
+ useLayoutEffect(() => {
51
+ const hash = window.location.hash.slice(1);
52
+ if (!hash)
53
+ return;
54
+ for (const [value, id] of valueToIdMap.entries()) {
55
+ if (id === hash) {
56
+ onChange(value);
57
+ tabsRef.current?.scrollIntoView();
58
+ break;
59
+ }
60
+ }
61
+ }, [onChange, valueToIdMap]);
62
+ return (_jsx(Primitive.Tabs, { ref: mergeRefs(ref, tabsRef), value: value, onValueChange: (v) => {
63
+ if (updateAnchor) {
64
+ const id = valueToIdMap.get(v);
65
+ if (id) {
66
+ window.history.replaceState(null, '', `#${id}`);
67
+ }
68
+ }
69
+ if (groupId) {
70
+ listeners.get(groupId)?.forEach((item) => {
71
+ item(v);
72
+ });
73
+ if (persist)
74
+ localStorage.setItem(groupId, v);
75
+ else
76
+ sessionStorage.setItem(groupId, v);
77
+ }
78
+ else {
79
+ setValue(v);
80
+ }
81
+ }, ...props, children: _jsx(TabsContext.Provider, { value: useMemo(() => ({ valueToIdMap }), [valueToIdMap]), children: props.children }) }));
82
+ }
83
+ export function TabsContent({ value, ...props }) {
84
+ const { valueToIdMap } = useTabContext();
85
+ if (props.id) {
86
+ valueToIdMap.set(value, props.id);
87
+ }
88
+ return (_jsx(Primitive.TabsContent, { value: value, ...props, children: props.children }));
89
+ }
@@ -150,7 +150,7 @@ export function PageBreadcrumb({ includeRoot = false, includeSeparator, includeP
150
150
  }, [includePage, includeRoot, includeSeparator, path, root]);
151
151
  if (items.length === 0)
152
152
  return null;
153
- return (_jsx("div", { ...props, className: cn('flex items-center gap-1.5 text-[15px] text-fd-muted-foreground', props.className), children: items.map((item, i) => {
153
+ return (_jsx("div", { ...props, className: cn('flex items-center gap-1.5 text-sm text-fd-muted-foreground', props.className), children: items.map((item, i) => {
154
154
  const className = cn('truncate', i === items.length - 1 && 'text-fd-primary font-medium');
155
155
  return (_jsxs(Fragment, { children: [i !== 0 && _jsx("span", { className: "text-fd-foreground/30", children: "/" }), item.url ? (_jsx(Link, { href: item.url, className: cn(className, 'transition-opacity hover:opacity-80'), children: item.name })) : (_jsx("span", { className: className, children: item.name }))] }, i));
156
156
  }) }));
@@ -21,6 +21,6 @@ export function PageTOCPopoverItems({ variant = 'normal', ...props }) {
21
21
  return (_jsx(TOCScrollArea, { ...props, children: variant === 'clerk' ? _jsx(ClerkTOCItems, {}) : _jsx(TOCItems, {}) }));
22
22
  }
23
23
  export function PageArticle(props) {
24
- return (_jsx("article", { ...props, className: cn('flex min-w-0 w-full flex-col gap-6 px-4 pt-8 md:px-6 md:mx-auto xl:pt-12 xl:px-12', props.className), children: props.children }));
24
+ return (_jsx("article", { ...props, className: cn('flex min-w-0 w-full flex-col gap-4 px-4 pt-8 md:px-6 md:mx-auto xl:pt-12 xl:px-12', props.className), children: props.children }));
25
25
  }
26
26
  export { PageRoot, PageBreadcrumb, PageFooter, PageLastUpdate, PageTOC, PageTOCPopover, PageTOCPopoverTrigger, PageTOCPopoverContent, };
@@ -22,17 +22,17 @@ export function DocsLayout({ nav: { transparentMode, ...nav } = {}, sidebar: { t
22
22
  const variables = cn('md:[--fd-sidebar-width:268px] lg:[--fd-sidebar-width:286px] xl:[--fd-toc-width:286px]', !nav.component && nav.enabled !== false
23
23
  ? '[--fd-nav-height:56px] md:[--fd-nav-height:0px]'
24
24
  : undefined);
25
- const sidebar = sidebarComponent ?? (_jsxs(_Fragment, { children: [sidebarCollapsible ? _jsx(CollapsibleControl, {}) : null, _jsxs(Sidebar, { ...sidebarProps, collapsible: sidebarCollapsible, children: [_jsx(HideIfEmpty, { children: _jsxs(SidebarHeader, { children: [_jsxs("div", { className: "flex max-md:hidden", children: [_jsx(Link, { href: nav.url ?? '/', className: "inline-flex text-[15px] items-center gap-2.5 font-medium me-auto", children: nav.title }), nav.children, sidebarCollapsible && (_jsx(SidebarCollapseTrigger, { className: cn(buttonVariants({
25
+ const sidebar = sidebarComponent ?? (_jsxs(_Fragment, { children: [sidebarCollapsible ? _jsx(CollapsibleControl, {}) : null, _jsxs(Sidebar, { ...sidebarProps, collapsible: sidebarCollapsible, children: [_jsx(HideIfEmpty, { children: _jsxs(SidebarHeader, { className: "data-[empty=true]:hidden", children: [_jsxs("div", { className: "flex max-md:hidden", children: [_jsx(Link, { href: nav.url ?? '/', className: "inline-flex text-[15px] items-center gap-2.5 font-medium me-auto", children: nav.title }), nav.children, sidebarCollapsible && (_jsx(SidebarCollapseTrigger, { className: cn(buttonVariants({
26
26
  color: 'ghost',
27
27
  size: 'icon-sm',
28
28
  className: 'mb-auto text-fd-muted-foreground max-md:hidden',
29
29
  })), children: _jsx(SidebarIcon, {}) }))] }), searchToggle.enabled !== false &&
30
30
  (searchToggle.components?.lg ?? (_jsx(LargeSearchToggle, { hideIfDisabled: true, className: "max-md:hidden" }))), tabs.length > 0 && _jsx(RootToggle, { options: tabs }), sidebarBanner] }) }), _jsxs(SidebarViewport, { children: [links
31
31
  .filter((v) => v.type !== 'icon')
32
- .map((item, i, list) => (_jsx(SidebarLinkItem, { item: item, className: cn(i === list.length - 1 && 'mb-4') }, i))), _jsx(SidebarPageTree, { components: sidebarComponents })] }), _jsxs(SidebarFooter, { className: "empty:hidden", children: [_jsx(HideIfEmpty, { children: _jsxs("div", { className: "flex items-center justify-end", children: [links
32
+ .map((item, i, list) => (_jsx(SidebarLinkItem, { item: item, className: cn(i === list.length - 1 && 'mb-4') }, i))), _jsx(SidebarPageTree, { components: sidebarComponents })] }), _jsx(HideIfEmpty, { children: _jsxs(SidebarFooter, { className: "data-[empty=true]:hidden", children: [_jsxs("div", { className: "flex items-center justify-end empty:hidden", children: [links
33
33
  .filter((item) => item.type === 'icon')
34
34
  .map((item, i, arr) => (_jsx(BaseLinkItem, { item: item, className: cn(buttonVariants({ size: 'icon', color: 'ghost' }), 'text-fd-muted-foreground md:[&_svg]:size-4.5', i === arr.length - 1 && 'me-auto'), "aria-label": item.label, children: item.icon }, i))), i18n ? (_jsxs(LanguageToggle, { className: "me-1.5", children: [_jsx(Languages, { className: "size-4.5" }), _jsx(LanguageToggleText, { className: "md:hidden" })] })) : null, themeSwitch.enabled !== false &&
35
- (themeSwitch.component ?? (_jsx(ThemeToggle, { className: "p-0", mode: themeSwitch.mode })))] }) }), sidebarFooter] })] })] }));
35
+ (themeSwitch.component ?? (_jsx(ThemeToggle, { className: "p-0", mode: themeSwitch.mode })))] }), sidebarFooter] }) })] })] }));
36
36
  return (_jsx(TreeContextProvider, { tree: props.tree, children: _jsxs(NavProvider, { transparentMode: transparentMode, children: [nav.enabled !== false &&
37
37
  (nav.component ?? (_jsxs(Navbar, { className: "h-14 md:hidden", children: [_jsx(Link, { href: nav.url ?? '/', className: "inline-flex items-center gap-2.5 font-semibold", children: nav.title }), _jsx("div", { className: "flex-1", children: nav.children }), searchToggle?.enabled !== false &&
38
38
  (searchToggle.components?.sm ?? (_jsx(SearchToggle, { className: "p-2", hideIfDisabled: true }))), _jsx(NavbarSidebarTrigger, { className: "p-2 -me-1.5 md:hidden" })] }))), _jsxs(LayoutBody, { ...props.containerProps, className: cn(variables, props.containerProps?.className), children: [sidebarEnabled && sidebar, children] })] }) }));
@@ -1 +1 @@
1
- {"version":3,"file":"navbar.d.ts","sourceRoot":"","sources":["../../../src/layouts/home/navbar.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAY,MAAM,OAAO,CAAC;AACtD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAa,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAW/C,OAAO,KAAK,EACV,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,iCAAiC,CAAC;AAO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AE,cAAc,CAAC,OAAO,YAAY,CAAC,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,2CAczE"}
@@ -12,7 +12,9 @@ const navItemVariants = cva('inline-flex items-center gap-1 p-2 text-fd-muted-fo
12
12
  export function Navbar(props) {
13
13
  const [value, setValue] = useState('');
14
14
  const { isTransparent } = useNav();
15
- return (_jsx(NavigationMenu, { value: value, onValueChange: setValue, asChild: true, children: _jsxs("header", { id: "nd-nav", ...props, className: cn('fixed top-(--fd-banner-height) z-40 inset-x-0 backdrop-blur-lg border-b transition-colors *:mx-auto *:max-w-fd-container', value.length > 0 ? 'shadow-lg' : 'shadow-sm', (!isTransparent || value.length > 0) && 'bg-fd-background/80', props.className), children: [_jsx(NavigationMenuList, { className: "flex h-14 w-full items-center px-4", asChild: true, children: _jsx("nav", { children: props.children }) }), _jsx(NavigationMenuViewport, { className: "text-fd-popover-foreground" })] }) }));
15
+ return (_jsx(NavigationMenu, { value: value, onValueChange: setValue, asChild: true, children: _jsxs("header", { id: "nd-nav", ...props, className: cn('fixed top-(--fd-banner-height) z-40 left-0 backdrop-blur-lg border-b transition-colors *:mx-auto *:max-w-fd-container', value.length > 0 && 'max-lg:shadow-lg max-lg:rounded-b-2xl', (!isTransparent || value.length > 0) && 'bg-fd-background/80', props.className), style: {
16
+ right: 'var(--removed-body-scroll-bar-size, 0px)',
17
+ }, children: [_jsx(NavigationMenuList, { className: "flex h-14 w-full items-center px-4", asChild: true, children: _jsx("nav", { children: props.children }) }), _jsx(NavigationMenuViewport, {})] }) }));
16
18
  }
17
19
  export const NavbarMenu = NavigationMenuItem;
18
20
  export function NavbarMenuContent(props) {
@@ -5,6 +5,7 @@ export declare function Navbar({ mode, ...props }: ComponentProps<'header'> & {
5
5
  }): import("react/jsx-runtime").JSX.Element;
6
6
  export declare function LayoutBody(props: ComponentProps<'main'>): import("react/jsx-runtime").JSX.Element;
7
7
  export declare function NavbarSidebarTrigger({ className, ...props }: ComponentProps<'button'>): import("react/jsx-runtime").JSX.Element;
8
- export declare function LayoutTabs(props: ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
9
- export declare function LayoutTab(item: Option): import("react/jsx-runtime").JSX.Element;
8
+ export declare function LayoutTabs({ options, ...props }: ComponentProps<'div'> & {
9
+ options: Option[];
10
+ }): import("react/jsx-runtime").JSX.Element;
10
11
  //# sourceMappingURL=notebook-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notebook-client.d.ts","sourceRoot":"","sources":["../../src/layouts/notebook-client.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAQ5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAE9D,wBAAgB,MAAM,CAAC,EACrB,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG;IAAE,IAAI,EAAE,KAAK,GAAG,MAAM,CAAA;CAAE,2CAoBrD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,2CAqBvD;AAED,wBAAgB,oBAAoB,CAAC,EACnC,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,QAAQ,CAAC,2CAkB1B;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,2CAYtD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,2CAqBrC"}
1
+ {"version":3,"file":"notebook-client.d.ts","sourceRoot":"","sources":["../../src/layouts/notebook-client.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,cAAc,EAAW,MAAM,OAAO,CAAC;AAQrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAE9D,wBAAgB,MAAM,CAAC,EACrB,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG;IAAE,IAAI,EAAE,KAAK,GAAG,MAAM,CAAA;CAAE,2CAoBrD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,2CAqBvD;AAED,wBAAgB,oBAAoB,CAAC,EACnC,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,QAAQ,CAAC,2CAkB1B;AAED,wBAAgB,UAAU,CAAC,EACzB,OAAO,EACP,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,2CA+BA"}
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { cn } from '../utils/cn.js';
4
+ import { useMemo } from 'react';
4
5
  import { useSidebar } from '../contexts/sidebar.js';
5
6
  import { useNav } from '../contexts/layout.js';
6
7
  import { buttonVariants } from '../components/ui/button.js';
@@ -32,16 +33,19 @@ export function NavbarSidebarTrigger({ className, ...props }) {
32
33
  className,
33
34
  })), onClick: () => setOpen((prev) => !prev), children: _jsx(SidebarIcon, {}) }));
34
35
  }
35
- export function LayoutTabs(props) {
36
- return (_jsx("div", { ...props, className: cn('flex flex-row items-end gap-6 overflow-auto', props.className), children: props.children }));
37
- }
38
- export function LayoutTab(item) {
39
- const { closeOnRedirect } = useSidebar();
36
+ export function LayoutTabs({ options, ...props }) {
40
37
  const pathname = usePathname();
41
- const selected = item.urls
42
- ? item.urls.has(pathname.endsWith('/') ? pathname.slice(0, -1) : pathname)
43
- : isActive(item.url, pathname, true);
44
- return (_jsx(Link, { className: cn('inline-flex items-center py-2.5 border-b border-transparent gap-2 text-fd-muted-foreground text-sm text-nowrap', selected && 'text-fd-foreground font-medium border-fd-primary'), href: item.url, onClick: () => {
45
- closeOnRedirect.current = false;
46
- }, children: item.title }));
38
+ const selected = useMemo(() => {
39
+ const url = pathname.endsWith('/') ? pathname.slice(0, -1) : pathname;
40
+ return options.findLast((option) => {
41
+ if (option.urls) {
42
+ return option.urls.has(url);
43
+ }
44
+ return isActive(option.url, pathname, true);
45
+ });
46
+ }, [options, pathname]);
47
+ return (_jsx("div", { ...props, className: cn('flex flex-row items-center gap-2 overflow-auto', props.className), children: options.map((option) => (_jsx(LayoutTab, { selected: selected === option, option: option }, option.url))) }));
48
+ }
49
+ function LayoutTab({ option, selected = false, }) {
50
+ return (_jsx(Link, { className: cn('inline-flex rounded-full items-center px-2 py-1.5 font-medium gap-2 text-fd-muted-foreground text-sm text-nowrap', selected && 'bg-fd-primary/10 text-fd-primary'), href: option.url, children: option.title }));
47
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"notebook.d.ts","sourceRoot":"","sources":["../../src/layouts/notebook.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAW,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,KAAK,eAAe,EAAY,MAAM,kBAAkB,CAAC;AAqBlE,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAIL,MAAM,EACN,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAU3B,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAE/B,GAAG,CAAC,EAAE,eAAe,CAAC,KAAK,CAAC,GAAG;QAC7B,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;KACvB,CAAC;IAEF,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IAElC,cAAc,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CACjD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,2CAiJhD;AAsLD,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAC"}
1
+ {"version":3,"file":"notebook.d.ts","sourceRoot":"","sources":["../../src/layouts/notebook.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAW,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,KAAK,eAAe,EAAY,MAAM,kBAAkB,CAAC;AAqBlE,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAGL,MAAM,EACN,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAU3B,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAE/B,GAAG,CAAC,EAAE,eAAe,CAAC,KAAK,CAAC,GAAG;QAC7B,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;KACvB,CAAC;IAEF,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IAElC,cAAc,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CACjD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,2CAiJhD;AAiMD,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAC"}
@@ -11,7 +11,7 @@ import { LanguageToggle } from '../components/layout/language-toggle.js';
11
11
  import { ThemeToggle } from '../components/layout/theme-toggle.js';
12
12
  import { Popover, PopoverContent, PopoverTrigger, } from '../components/ui/popover.js';
13
13
  import { getSidebarTabsFromOptions, SidebarLinkItem, } from '../layouts/docs/shared.js';
14
- import { LayoutBody, LayoutTab, LayoutTabs, Navbar, NavbarSidebarTrigger, } from './notebook-client.js';
14
+ import { LayoutBody, LayoutTabs, Navbar, NavbarSidebarTrigger, } from './notebook-client.js';
15
15
  import { NavProvider } from '../contexts/layout.js';
16
16
  import { RootToggle } from '../components/layout/root-toggle.js';
17
17
  import Link from 'fumadocs-core/link';
@@ -29,10 +29,10 @@ export function DocsLayout(props) {
29
29
  className: 'mt-px mb-auto text-fd-muted-foreground',
30
30
  })), children: _jsx(SidebarIcon, {}) }))] }));
31
31
  return (_jsx(TreeContextProvider, { tree: props.tree, children: _jsx(NavProvider, { transparentMode: transparentMode, children: _jsxs(LayoutBody, { ...props.containerProps, className: cn(variables, props.containerProps?.className), children: [_jsxs(Sidebar, { ...sidebar, className: cn(navMode === 'top'
32
- ? 'md:bg-transparent'
33
- : 'md:[--fd-nav-height:0px]', sidebar.className), children: [_jsx(HideIfEmpty, { children: _jsxs(SidebarHeader, { children: [navMode === 'auto' && sidebarHeader, nav.children, sidebarBanner, tabMode === 'sidebar' && tabs.length > 0 ? (_jsx(RootToggle, { className: "mb-2", options: tabs })) : null, tabMode === 'navbar' && tabs.length > 0 && (_jsx(RootToggle, { options: tabs, className: "lg:hidden" }))] }) }), _jsxs(SidebarViewport, { children: [links
32
+ ? 'border-e-0 md:bg-transparent'
33
+ : 'md:[--fd-nav-height:0px]', sidebar.className), children: [_jsx(HideIfEmpty, { children: _jsxs(SidebarHeader, { className: "data-[empty=true]:hidden", children: [navMode === 'auto' && sidebarHeader, nav.children, sidebarBanner, tabMode === 'sidebar' && tabs.length > 0 ? (_jsx(RootToggle, { className: "mb-2", options: tabs })) : null, tabMode === 'navbar' && tabs.length > 0 && (_jsx(RootToggle, { options: tabs, className: "lg:hidden" }))] }) }), _jsxs(SidebarViewport, { children: [links
34
34
  .filter((item) => item.type !== 'icon')
35
- .map((item, i) => (_jsx(SidebarLinkItem, { item: item, className: cn('lg:hidden', i === links.length - 1 && 'mb-4') }, i))), _jsx(SidebarPageTree, { components: sidebarComponents })] }), _jsx(HideIfEmpty, { children: _jsxs(SidebarFooter, { className: "flex flex-row items-center justify-end", children: [_jsx("div", { className: "flex items-center flex-1 empty:hidden lg:hidden", children: links
35
+ .map((item, i) => (_jsx(SidebarLinkItem, { item: item, className: cn('lg:hidden', i === links.length - 1 && 'mb-4') }, i))), _jsx(SidebarPageTree, { components: sidebarComponents })] }), _jsx(HideIfEmpty, { children: _jsxs(SidebarFooter, { className: "flex flex-row items-center justify-end data-[empty=true]:hidden", children: [_jsx("div", { className: "flex items-center flex-1 empty:hidden lg:hidden", children: links
36
36
  .filter((item) => item.type === 'icon')
37
37
  .map((item, i) => (_jsx(BaseLinkItem, { item: item, className: cn(buttonVariants({
38
38
  size: 'icon-sm',
@@ -49,7 +49,7 @@ function DocsNavbar({ links, tabs, searchToggle = {}, themeSwitch = {}, ...props
49
49
  color: 'ghost',
50
50
  size: 'icon-sm',
51
51
  }), 'text-fd-muted-foreground -ms-1.5 me-2 data-[collapsed=false]:hidden max-md:hidden'), children: _jsx(SidebarIcon, {}) })) : null, nav] }), searchToggle.enabled !== false &&
52
- (searchToggle.components?.lg ?? (_jsx(LargeSearchToggle, { hideIfDisabled: true, className: cn('w-full my-auto max-md:hidden', navMode === 'top'
52
+ (searchToggle.components?.lg ? (_jsx("div", { className: cn('w-full my-auto max-md:hidden', navMode === 'top' ? 'rounded-xl max-w-sm' : 'max-w-[240px]'), children: searchToggle.components?.lg })) : (_jsx(LargeSearchToggle, { hideIfDisabled: true, className: cn('w-full my-auto max-md:hidden', navMode === 'top'
53
53
  ? 'rounded-xl max-w-sm ps-2.5'
54
54
  : 'max-w-[240px]') }))), _jsxs("div", { className: "flex flex-1 flex-row items-center justify-end", children: [_jsx("div", { className: "flex flex-row items-center gap-6 px-4 empty:hidden max-lg:hidden", children: links
55
55
  .filter((item) => item.type !== 'icon')
@@ -60,7 +60,7 @@ function DocsNavbar({ links, tabs, searchToggle = {}, themeSwitch = {}, ...props
60
60
  (themeSwitch.component ?? (_jsx(ThemeToggle, { className: "ms-2 max-md:hidden", mode: themeSwitch.mode ?? 'light-dark-system' }))), sidebarCollapsible && navMode === 'top' ? (_jsx(SidebarCollapseTrigger, { className: cn(buttonVariants({
61
61
  color: 'secondary',
62
62
  size: 'icon-sm',
63
- }), 'ms-2 text-fd-muted-foreground rounded-full max-md:hidden'), children: _jsx(SidebarIcon, {}) })) : null] })] }), tabs.length > 0 ? (_jsx(LayoutTabs, { className: "px-6 border-b h-10 max-lg:hidden", children: tabs.map((tab) => (_jsx(LayoutTab, { ...tab }, tab.url))) })) : null] }));
63
+ }), 'ms-2 text-fd-muted-foreground rounded-full max-md:hidden'), children: _jsx(SidebarIcon, {}) })) : null] })] }), tabs.length > 0 && (_jsx(LayoutTabs, { className: cn('border-b h-10 max-lg:hidden', navMode === 'top' ? 'px-4' : 'px-6'), options: tabs }))] }));
64
64
  }
65
65
  function NavbarLinkItem({ item, ...props }) {
66
66
  if (item.type === 'menu') {
package/dist/mdx.d.ts CHANGED
@@ -1,10 +1,15 @@
1
1
  import type { AnchorHTMLAttributes, FC, HTMLAttributes, ImgHTMLAttributes, TableHTMLAttributes } from 'react';
2
2
  import { Card, Cards } from './components/card.js';
3
+ import { CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger } from './components/codeblock.js';
3
4
  declare function Image(props: ImgHTMLAttributes<HTMLImageElement> & {
4
5
  sizes?: string;
5
6
  }): import("react/jsx-runtime").JSX.Element;
6
7
  declare function Table(props: TableHTMLAttributes<HTMLTableElement>): import("react/jsx-runtime").JSX.Element;
7
8
  declare const defaultMdxComponents: {
9
+ CodeBlockTab: (props: import("react").ComponentProps<typeof import("./components/tabs.unstyled.js").TabsContent>) => import("react/jsx-runtime").JSX.Element;
10
+ CodeBlockTabs: typeof CodeBlockTabs;
11
+ CodeBlockTabsList: typeof CodeBlockTabsList;
12
+ CodeBlockTabsTrigger: typeof CodeBlockTabsTrigger;
8
13
  pre: (props: HTMLAttributes<HTMLPreElement>) => import("react/jsx-runtime").JSX.Element;
9
14
  Card: typeof Card;
10
15
  Cards: typeof Cards;
package/dist/mdx.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mdx.d.ts","sourceRoot":"","sources":["../src/mdx.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,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CAUF;AAED,iBAAS,KAAK,CAAC,KAAK,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,2CAM1D;AAED,QAAA,MAAM,oBAAoB;;;;;iBAKX,cAAc,CAAC,cAAc,CAAC;;;OAOhC,EAAE,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;;gBAE1C,cAAc,CAAC,kBAAkB,CAAC;gBAGlC,cAAc,CAAC,kBAAkB,CAAC;gBAGlC,cAAc,CAAC,kBAAkB,CAAC;gBAGlC,cAAc,CAAC,kBAAkB,CAAC;gBAGlC,cAAc,CAAC,kBAAkB,CAAC;gBAGlC,cAAc,CAAC,kBAAkB,CAAC;;;;;;;CAK/C,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,cAAc,cAAc,EAAE,kBAK5D,CAAC;AAEJ,OAAO,EAAE,oBAAoB,IAAI,OAAO,EAAE,CAAC"}
package/dist/mdx.js CHANGED
@@ -5,7 +5,7 @@ import { Card, Cards } from './components/card.js';
5
5
  import { Callout } from './components/callout.js';
6
6
  import { Heading } from './components/heading.js';
7
7
  import { cn } from './utils/cn.js';
8
- import { CodeBlock, Pre } from './components/codeblock.js';
8
+ import { CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, Pre, } from './components/codeblock.js';
9
9
  function Image(props) {
10
10
  return (_jsx(FrameworkImage, { sizes: "(max-width: 768px) 100vw, (max-width: 1200px) 70vw, 900px", ...props, src: props.src, className: cn('rounded-lg', props.className) }));
11
11
  }
@@ -13,6 +13,10 @@ function Table(props) {
13
13
  return (_jsx("div", { className: "relative overflow-auto prose-no-margin my-6", children: _jsx("table", { ...props }) }));
14
14
  }
15
15
  const defaultMdxComponents = {
16
+ CodeBlockTab,
17
+ CodeBlockTabs,
18
+ CodeBlockTabsList,
19
+ CodeBlockTabsTrigger,
16
20
  pre: (props) => (_jsx(CodeBlock, { ...props, children: _jsx(Pre, { children: props.children }) })),
17
21
  Card,
18
22
  Cards,