fumadocs-ui 15.7.5 → 15.7.6
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/components/layout/root-toggle.d.ts +2 -13
- package/dist/components/layout/root-toggle.d.ts.map +1 -1
- package/dist/components/layout/root-toggle.js +2 -7
- package/dist/components/layout/sidebar.js +1 -1
- package/dist/layouts/notebook/client.d.ts.map +1 -1
- package/dist/layouts/notebook/client.js +4 -10
- package/dist/style.css +3 -0
- package/dist/utils/get-sidebar-tabs.d.ts +17 -3
- package/dist/utils/get-sidebar-tabs.d.ts.map +1 -1
- package/dist/utils/get-sidebar-tabs.js +7 -9
- package/dist/utils/is-active.d.ts +2 -0
- package/dist/utils/is-active.d.ts.map +1 -1
- package/dist/utils/is-active.js +5 -0
- package/package.json +3 -3
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Redirect URL of the folder, usually the index page
|
|
5
|
-
*/
|
|
6
|
-
url: string;
|
|
7
|
-
icon?: ReactNode;
|
|
8
|
-
title: ReactNode;
|
|
9
|
-
description?: ReactNode;
|
|
10
|
-
unlisted?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Detect from a list of urls
|
|
13
|
-
*/
|
|
14
|
-
urls?: Set<string>;
|
|
2
|
+
import type { SidebarTab } from '../../utils/get-sidebar-tabs.js';
|
|
3
|
+
export interface Option extends SidebarTab {
|
|
15
4
|
props?: ComponentProps<'a'>;
|
|
16
5
|
}
|
|
17
6
|
export declare function RootToggle({ options, placeholder, ...props }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root-toggle.d.ts","sourceRoot":"","sources":["../../../src/components/layout/root-toggle.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"root-toggle.d.ts","sourceRoot":"","sources":["../../../src/components/layout/root-toggle.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAC;AAO/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,MAAM,WAAW,MAAO,SAAQ,UAAU;IACxC,KAAK,CAAC,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;CAC7B;AAED,wBAAgB,UAAU,CAAC,EACzB,OAAO,EACP,WAAW,EACX,GAAG,KAAK,EACT,EAAE;IACD,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,GAAG,cAAc,CAAC,QAAQ,CAAC,2CAgF3B"}
|
|
@@ -5,7 +5,7 @@ import { useMemo, useState } from 'react';
|
|
|
5
5
|
import Link from 'fumadocs-core/link';
|
|
6
6
|
import { usePathname } from 'fumadocs-core/framework';
|
|
7
7
|
import { cn } from '../../utils/cn.js';
|
|
8
|
-
import {
|
|
8
|
+
import { isTabActive } from '../../utils/is-active.js';
|
|
9
9
|
import { useSidebar } from '../../contexts/sidebar.js';
|
|
10
10
|
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover.js';
|
|
11
11
|
export function RootToggle({ options, placeholder, ...props }) {
|
|
@@ -13,12 +13,7 @@ export function RootToggle({ options, placeholder, ...props }) {
|
|
|
13
13
|
const { closeOnRedirect } = useSidebar();
|
|
14
14
|
const pathname = usePathname();
|
|
15
15
|
const selected = useMemo(() => {
|
|
16
|
-
|
|
17
|
-
return options.findLast((item) => {
|
|
18
|
-
if (item.urls)
|
|
19
|
-
return item.urls.has(lookup);
|
|
20
|
-
return isActive(item.url, pathname, true);
|
|
21
|
-
});
|
|
16
|
+
return options.findLast((item) => isTabActive(item, pathname));
|
|
22
17
|
}, [options, pathname]);
|
|
23
18
|
const onClick = () => {
|
|
24
19
|
closeOnRedirect.current = false;
|
|
@@ -88,7 +88,7 @@ export function SidebarHeader(props) {
|
|
|
88
88
|
return (_jsx("div", { ...props, className: cn('flex flex-col gap-3 p-4 pb-2', props.className), children: props.children }));
|
|
89
89
|
}
|
|
90
90
|
export function SidebarFooter(props) {
|
|
91
|
-
return (_jsx("div", { ...props, className: cn('flex flex-col border-t
|
|
91
|
+
return (_jsx("div", { ...props, className: cn('flex flex-col border-t p-4 pt-2', props.className), children: props.children }));
|
|
92
92
|
}
|
|
93
93
|
export function SidebarViewport(props) {
|
|
94
94
|
return (_jsx(ScrollArea, { ...props, className: cn('h-full', props.className), children: _jsx(ScrollViewport, { className: "p-4 overscroll-contain", style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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,2CAsBvD;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,
|
|
1
|
+
{"version":3,"file":"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,2CAsBvD;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,2CAuBA"}
|
|
@@ -8,7 +8,7 @@ import { buttonVariants } from '../../components/ui/button.js';
|
|
|
8
8
|
import { Sidebar as SidebarIcon } from '../../icons.js';
|
|
9
9
|
import Link from 'fumadocs-core/link';
|
|
10
10
|
import { usePathname } from 'fumadocs-core/framework';
|
|
11
|
-
import {
|
|
11
|
+
import { isTabActive } from '../../utils/is-active.js';
|
|
12
12
|
export function Navbar({ mode, ...props }) {
|
|
13
13
|
const { open, collapsed } = useSidebar();
|
|
14
14
|
const { isTransparent } = useNav();
|
|
@@ -36,16 +36,10 @@ export function NavbarSidebarTrigger({ className, ...props }) {
|
|
|
36
36
|
export function LayoutTabs({ options, ...props }) {
|
|
37
37
|
const pathname = usePathname();
|
|
38
38
|
const selected = useMemo(() => {
|
|
39
|
-
|
|
40
|
-
return options.findLast((option) => {
|
|
41
|
-
if (option.urls) {
|
|
42
|
-
return option.urls.has(url);
|
|
43
|
-
}
|
|
44
|
-
return isActive(option.url, pathname, true);
|
|
45
|
-
});
|
|
39
|
+
return options.findLast((option) => isTabActive(option, pathname));
|
|
46
40
|
}, [options, pathname]);
|
|
47
41
|
return (_jsx("div", { ...props, className: cn('flex flex-row items-end gap-6 overflow-auto', props.className), children: options.map((option) => (_jsx(LayoutTab, { selected: selected === option, option: option }, option.url))) }));
|
|
48
42
|
}
|
|
49
|
-
function LayoutTab({ option, selected = false, }) {
|
|
50
|
-
return (_jsx(Link, { className: cn('inline-flex border-b-2 border-transparent transition-colors items-center pb-1.5 font-medium gap-2 text-fd-muted-foreground text-sm text-nowrap hover:text-fd-accent-foreground',
|
|
43
|
+
function LayoutTab({ option: { title, url, unlisted, props }, selected = false, }) {
|
|
44
|
+
return (_jsx(Link, { href: url, ...props, className: cn('inline-flex border-b-2 border-transparent transition-colors items-center pb-1.5 font-medium gap-2 text-fd-muted-foreground text-sm text-nowrap hover:text-fd-accent-foreground', unlisted && !selected && 'hidden', selected && 'border-fd-primary text-fd-primary', props?.className), children: title }));
|
|
51
45
|
}
|
package/dist/style.css
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import type { PageTree } from 'fumadocs-core/server';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
export interface SidebarTab {
|
|
4
|
+
/**
|
|
5
|
+
* Redirect URL of the folder, usually the index page
|
|
6
|
+
*/
|
|
7
|
+
url: string;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
title: ReactNode;
|
|
10
|
+
description?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Detect from a list of urls
|
|
13
|
+
*/
|
|
14
|
+
urls?: Set<string>;
|
|
15
|
+
unlisted?: boolean;
|
|
16
|
+
}
|
|
3
17
|
export interface GetSidebarTabsOptions {
|
|
4
|
-
transform?: (option:
|
|
18
|
+
transform?: (option: SidebarTab, node: PageTree.Folder) => SidebarTab | null;
|
|
5
19
|
}
|
|
6
|
-
export declare function getSidebarTabs(tree: PageTree.Root, { transform }?: GetSidebarTabsOptions):
|
|
20
|
+
export declare function getSidebarTabs(tree: PageTree.Root, { transform }?: GetSidebarTabsOptions): SidebarTab[];
|
|
7
21
|
//# sourceMappingURL=get-sidebar-tabs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-sidebar-tabs.d.ts","sourceRoot":"","sources":["../../src/utils/get-sidebar-tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"get-sidebar-tabs.d.ts","sourceRoot":"","sources":["../../src/utils/get-sidebar-tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,SAAS,CAAC;IAExB;;OAEG;IACH,IAAI,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,KAAK,UAAU,GAAG,IAAI,CAAC;CAC9E;AAeD,wBAAgB,cAAc,CAC5B,IAAI,EAAE,QAAQ,CAAC,IAAI,EACnB,EAAE,SAA4B,EAAE,GAAE,qBAA0B,GAC3D,UAAU,EAAE,CAkCd"}
|
|
@@ -8,8 +8,8 @@ const defaultTransform = (option, node) => {
|
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
export function getSidebarTabs(tree, { transform = defaultTransform } = {}) {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const results = [];
|
|
12
|
+
function scanOptions(node, unlisted) {
|
|
13
13
|
if ('root' in node && node.root) {
|
|
14
14
|
const urls = getFolderUrls(node);
|
|
15
15
|
if (urls.size > 0) {
|
|
@@ -28,15 +28,13 @@ export function getSidebarTabs(tree, { transform = defaultTransform } = {}) {
|
|
|
28
28
|
}
|
|
29
29
|
for (const child of node.children) {
|
|
30
30
|
if (child.type === 'folder')
|
|
31
|
-
|
|
31
|
+
scanOptions(child, unlisted);
|
|
32
32
|
}
|
|
33
|
-
return results;
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
if (tree.fallback)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return options;
|
|
34
|
+
scanOptions(tree);
|
|
35
|
+
if (tree.fallback)
|
|
36
|
+
scanOptions(tree.fallback, true);
|
|
37
|
+
return results;
|
|
40
38
|
}
|
|
41
39
|
function getFolderUrls(folder, output = new Set()) {
|
|
42
40
|
if (folder.index)
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import type { SidebarTab } from '../utils/get-sidebar-tabs.js';
|
|
1
2
|
export declare function isActive(url: string, pathname: string, nested?: boolean): boolean;
|
|
3
|
+
export declare function isTabActive(tab: SidebarTab, pathname: string): boolean;
|
|
2
4
|
//# sourceMappingURL=is-active.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-active.d.ts","sourceRoot":"","sources":["../../src/utils/is-active.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-active.d.ts","sourceRoot":"","sources":["../../src/utils/is-active.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAO3D,wBAAgB,QAAQ,CACtB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,MAAM,UAAO,GACZ,OAAO,CAKT;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAI5D"}
|
package/dist/utils/is-active.js
CHANGED
|
@@ -8,3 +8,8 @@ export function isActive(url, pathname, nested = true) {
|
|
|
8
8
|
pathname = normalize(pathname);
|
|
9
9
|
return url === pathname || (nested && pathname.startsWith(`${url}/`));
|
|
10
10
|
}
|
|
11
|
+
export function isTabActive(tab, pathname) {
|
|
12
|
+
if (tab.urls)
|
|
13
|
+
return tab.urls.has(normalize(pathname));
|
|
14
|
+
return isActive(tab.url, pathname, true);
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-ui",
|
|
3
|
-
"version": "15.7.
|
|
3
|
+
"version": "15.7.6",
|
|
4
4
|
"description": "The framework for building a documentation website in Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"react-medium-image-zoom": "^5.3.0",
|
|
122
122
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
123
123
|
"tailwind-merge": "^3.3.1",
|
|
124
|
-
"fumadocs-core": "15.7.
|
|
124
|
+
"fumadocs-core": "15.7.6"
|
|
125
125
|
},
|
|
126
126
|
"devDependencies": {
|
|
127
127
|
"@next/eslint-plugin-next": "^15.5.2",
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
"tsc-alias": "^1.8.16",
|
|
135
135
|
"@fumadocs/cli": "1.0.1",
|
|
136
136
|
"eslint-config-custom": "0.0.0",
|
|
137
|
-
"fumadocs-core": "15.7.
|
|
137
|
+
"fumadocs-core": "15.7.6",
|
|
138
138
|
"tsconfig": "0.0.0"
|
|
139
139
|
},
|
|
140
140
|
"peerDependencies": {
|