fumadocs-ui 14.5.5 → 14.5.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 +4 -4
- package/dist/components/layout/root-toggle.d.ts.map +1 -1
- package/dist/components/layout/root-toggle.js +6 -7
- package/dist/style.css +1 -1
- package/dist/utils/get-sidebar-tabs.d.ts.map +1 -1
- package/dist/utils/get-sidebar-tabs.js +23 -9
- package/package.json +4 -4
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
-
import type { PageTree } from 'fumadocs-core/server';
|
|
3
2
|
export interface Option {
|
|
4
3
|
/**
|
|
5
4
|
* Redirect URL of the folder, usually the index page
|
|
@@ -9,12 +8,13 @@ export interface Option {
|
|
|
9
8
|
title: ReactNode;
|
|
10
9
|
description?: ReactNode;
|
|
11
10
|
/**
|
|
12
|
-
* Detect from
|
|
11
|
+
* Detect from a list of urls
|
|
13
12
|
*/
|
|
14
|
-
|
|
13
|
+
urls?: string[];
|
|
15
14
|
props?: HTMLAttributes<HTMLElement>;
|
|
16
15
|
}
|
|
17
|
-
export declare function RootToggle({ options, ...props }: {
|
|
16
|
+
export declare function RootToggle({ options, placeholder, ...props }: {
|
|
17
|
+
placeholder?: ReactNode;
|
|
18
18
|
options: Option[];
|
|
19
19
|
} & HTMLAttributes<HTMLButtonElement>): import("react/jsx-runtime").JSX.Element;
|
|
20
20
|
//# sourceMappingURL=root-toggle.d.ts.map
|
|
@@ -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;AAQ/E,MAAM,WAAW,MAAM;IACrB;;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,MAAM,EAAE,CAAC;IAEhB,KAAK,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;CACrC;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,iBAAiB,CAAC,2CAuDpC"}
|
|
@@ -8,22 +8,21 @@ import { cn } from '../../utils/cn';
|
|
|
8
8
|
import { isActive } from '../../utils/is-active';
|
|
9
9
|
import { useSidebar } from '../../contexts/sidebar';
|
|
10
10
|
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';
|
|
11
|
-
|
|
12
|
-
export function RootToggle({ options, ...props }) {
|
|
11
|
+
export function RootToggle({ options, placeholder, ...props }) {
|
|
13
12
|
const [open, setOpen] = useState(false);
|
|
14
13
|
const { closeOnRedirect } = useSidebar();
|
|
15
14
|
const pathname = usePathname();
|
|
16
|
-
const path = useTreePath();
|
|
17
15
|
const selected = useMemo(() => {
|
|
18
|
-
return options.findLast((item) => item.
|
|
19
|
-
?
|
|
16
|
+
return options.findLast((item) => item.urls
|
|
17
|
+
? item.urls.includes(pathname)
|
|
20
18
|
: isActive(item.url, pathname, true));
|
|
21
|
-
}, [
|
|
19
|
+
}, [options, pathname]);
|
|
22
20
|
const onClick = () => {
|
|
23
21
|
closeOnRedirect.current = false;
|
|
24
22
|
setOpen(false);
|
|
25
23
|
};
|
|
26
|
-
|
|
24
|
+
const item = selected ? _jsx(Item, { ...selected }) : placeholder;
|
|
25
|
+
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [item ? (_jsxs(PopoverTrigger, { ...props, className: cn('flex flex-row items-center gap-2 rounded-lg px-2 py-1.5 hover:bg-fd-accent/50 hover:text-fd-accent-foreground', props.className), children: [item, _jsx(ChevronDown, { className: "me-1.5 size-4 text-fd-muted-foreground" })] })) : null, _jsx(PopoverContent, { className: "w-[var(--radix-popover-trigger-width)] overflow-hidden p-0", children: options.map((item) => (_jsx(Link, { href: item.url, onClick: onClick, ...item.props, className: cn('flex w-full flex-row items-center gap-2 px-2 py-1.5', selected === item
|
|
27
26
|
? 'bg-fd-accent text-fd-accent-foreground'
|
|
28
27
|
: 'hover:bg-fd-accent/50', item.props?.className), children: _jsx(Item, { ...item }) }, item.url))) })] }));
|
|
29
28
|
}
|
package/dist/style.css
CHANGED
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
--tw-contain-paint: ;
|
|
106
106
|
--tw-contain-style: ;
|
|
107
107
|
}/*
|
|
108
|
-
! tailwindcss v3.4.
|
|
108
|
+
! tailwindcss v3.4.16 | MIT License | https://tailwindcss.com
|
|
109
109
|
*//*
|
|
110
110
|
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
|
|
111
111
|
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
|
|
@@ -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,iCAAiC,CAAC;AAE9D,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;CACtE;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,QAAQ,CAAC,IAAI,EACvB,EAAE,SAAS,EAAE,GAAE,UAAe,GAC7B,MAAM,EAAE,
|
|
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,iCAAiC,CAAC;AAE9D,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;CACtE;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,QAAQ,CAAC,IAAI,EACvB,EAAE,SAAS,EAAE,GAAE,UAAe,GAC7B,MAAM,EAAE,CA8BV"}
|
|
@@ -1,24 +1,38 @@
|
|
|
1
1
|
export function getSidebarTabs(pageTree, { transform } = {}) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (node.
|
|
2
|
+
function findOptions(node) {
|
|
3
|
+
const results = [];
|
|
4
|
+
if (node.root) {
|
|
5
5
|
const index = node.index ?? node.children.at(0);
|
|
6
6
|
if (index?.type === 'page') {
|
|
7
7
|
const option = {
|
|
8
8
|
url: index.url,
|
|
9
9
|
title: node.name,
|
|
10
10
|
icon: node.icon,
|
|
11
|
-
folder: node,
|
|
12
11
|
description: node.description,
|
|
12
|
+
urls: getFolderUrls(node),
|
|
13
13
|
};
|
|
14
14
|
const mapped = transform ? transform(option, node) : option;
|
|
15
15
|
if (mapped)
|
|
16
|
-
|
|
16
|
+
results.push(mapped);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
for (const child of node.children) {
|
|
20
|
+
if (child.type === 'folder')
|
|
21
|
+
results.push(...findOptions(child));
|
|
22
|
+
}
|
|
23
|
+
return results;
|
|
24
|
+
}
|
|
25
|
+
return findOptions(pageTree);
|
|
26
|
+
}
|
|
27
|
+
function getFolderUrls(folder) {
|
|
28
|
+
const results = [];
|
|
29
|
+
if (folder.index)
|
|
30
|
+
results.push(folder.index.url);
|
|
31
|
+
for (const child of folder.children) {
|
|
32
|
+
if (child.type === 'page')
|
|
33
|
+
results.push(child.url);
|
|
34
|
+
if (child.type === 'folder')
|
|
35
|
+
results.push(...getFolderUrls(child));
|
|
21
36
|
}
|
|
22
|
-
|
|
23
|
-
return options;
|
|
37
|
+
return results;
|
|
24
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-ui",
|
|
3
|
-
"version": "14.5.
|
|
3
|
+
"version": "14.5.6",
|
|
4
4
|
"description": "The framework for building a documentation website in Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -63,12 +63,12 @@
|
|
|
63
63
|
"@radix-ui/react-tabs": "^1.1.1",
|
|
64
64
|
"class-variance-authority": "^0.7.1",
|
|
65
65
|
"lodash.merge": "^4.6.2",
|
|
66
|
-
"lucide-react": "^0.
|
|
66
|
+
"lucide-react": "^0.465.0",
|
|
67
67
|
"next-themes": "^0.4.3",
|
|
68
68
|
"postcss-selector-parser": "^7.0.0",
|
|
69
69
|
"react-medium-image-zoom": "^5.2.11",
|
|
70
70
|
"tailwind-merge": "^2.5.5",
|
|
71
|
-
"fumadocs-core": "14.5.
|
|
71
|
+
"fumadocs-core": "14.5.6"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@next/eslint-plugin-next": "^15.0.3",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"next": "15.0.3",
|
|
80
80
|
"postcss": "^8.4.49",
|
|
81
81
|
"postcss-cli": "^11.0.0",
|
|
82
|
-
"tailwindcss": "^3.4.
|
|
82
|
+
"tailwindcss": "^3.4.16",
|
|
83
83
|
"tsc-alias": "^1.8.10",
|
|
84
84
|
"@fumadocs/cli": "0.0.4",
|
|
85
85
|
"eslint-config-custom": "0.0.0",
|