fumadocs-ui 11.3.1 → 12.0.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.
- package/dist/{chunk-24NYFO7H.js → chunk-2KMKNVSN.js} +2 -4
- package/dist/{chunk-C4PI62MH.js → chunk-34Z7WODD.js} +6 -8
- package/dist/{chunk-GDRBCN6Q.js → chunk-3F57TIUQ.js} +21 -7
- package/dist/{chunk-PXDQVGII.js → chunk-7EMVRXMS.js} +10 -1
- package/dist/{chunk-7F2LGCS6.js → chunk-AN2Y6MA2.js} +2 -4
- package/dist/{chunk-PW7TBOIJ.js → chunk-CRYPD6UZ.js} +2 -1
- package/dist/{chunk-UKE65HV3.js → chunk-IOHAG6BY.js} +1 -1
- package/dist/chunk-JQW5DMD2.js +226 -0
- package/dist/{chunk-WNKY4RA5.js → chunk-UBVEKNRF.js} +1 -1
- package/dist/{chunk-E2VA3Y4S.js → chunk-XXVXIK4M.js} +2 -3
- package/dist/components/accordion.js +2 -2
- package/dist/components/api.js +5 -8
- package/dist/components/callout.js +1 -1
- package/dist/components/card.js +1 -1
- package/dist/components/codeblock.js +3 -3
- package/dist/components/dialog/search-algolia.js +4 -3
- package/dist/components/dialog/search-default.js +4 -3
- package/dist/components/dialog/search.js +4 -3
- package/dist/components/files.js +1 -1
- package/dist/components/heading.js +2 -2
- package/dist/components/image-zoom.js +4 -6
- package/dist/components/inline-toc.js +1 -1
- package/dist/components/layout/language-toggle.d.ts +6 -0
- package/dist/components/layout/language-toggle.js +58 -0
- package/dist/components/layout/root-toggle.d.ts +16 -0
- package/dist/components/layout/root-toggle.js +60 -0
- package/dist/components/roll-button.js +2 -3
- package/dist/components/steps.js +1 -1
- package/dist/components/tabs.js +6 -11
- package/dist/components/type-table.js +2 -2
- package/dist/docs.client.d.ts +13 -0
- package/dist/docs.client.js +396 -0
- package/dist/{i18n-p5QWhj_3.d.ts → i18n-CE8z-AAs.d.ts} +1 -0
- package/dist/i18n.d.ts +3 -6
- package/dist/i18n.js +5 -104
- package/dist/{layout-vxXAvjoq.d.ts → layout.client-Duq0TTke.d.ts} +23 -15
- package/dist/layout.client.d.ts +2 -8
- package/dist/layout.client.js +39 -571
- package/dist/layout.d.ts +1 -1
- package/dist/layout.js +42 -28
- package/dist/mdx.client.js +3 -3
- package/dist/mdx.js +4 -4
- package/dist/page.client.js +7 -8
- package/dist/page.js +19 -10
- package/dist/provider.d.ts +12 -13
- package/dist/provider.js +10 -11
- package/dist/style.css +1 -1
- package/dist/tailwind-plugin.cjs +34 -43
- package/dist/tailwind-plugin.js +35 -44
- package/dist/twoslash/popup.js +8 -14
- package/dist/twoslash.css +1 -1
- package/package.json +4 -5
- /package/dist/{chunk-6C3VEZWH.js → chunk-MLKGABMK.js} +0 -0
- /package/dist/{tree-cqNEopxM.d.ts → tree-CrKzI9Nz.d.ts} +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Popover,
|
|
4
|
+
PopoverContent,
|
|
5
|
+
PopoverTrigger
|
|
6
|
+
} from "../../chunk-UBVEKNRF.js";
|
|
7
|
+
import {
|
|
8
|
+
useI18n
|
|
9
|
+
} from "../../chunk-CRYPD6UZ.js";
|
|
10
|
+
import {
|
|
11
|
+
buttonVariants
|
|
12
|
+
} from "../../chunk-7GZKFBAP.js";
|
|
13
|
+
import {
|
|
14
|
+
twMerge
|
|
15
|
+
} from "../../chunk-TK3TM3MR.js";
|
|
16
|
+
import "../../chunk-MLKGABMK.js";
|
|
17
|
+
|
|
18
|
+
// src/components/layout/language-toggle.tsx
|
|
19
|
+
import { useState } from "react";
|
|
20
|
+
import { LanguagesIcon } from "lucide-react";
|
|
21
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
22
|
+
function LanguageToggle(props) {
|
|
23
|
+
const context = useI18n();
|
|
24
|
+
const [open, setOpen] = useState(false);
|
|
25
|
+
if (!context.translations) throw new Error("Missing `<I18nProvider />`");
|
|
26
|
+
const languages = Object.entries(context.translations);
|
|
27
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, ...props, children: [
|
|
28
|
+
/* @__PURE__ */ jsx(
|
|
29
|
+
PopoverTrigger,
|
|
30
|
+
{
|
|
31
|
+
"aria-label": context.text.chooseLanguage,
|
|
32
|
+
className: twMerge(buttonVariants({ size: "icon", color: "ghost" })),
|
|
33
|
+
children: /* @__PURE__ */ jsx(LanguagesIcon, {})
|
|
34
|
+
}
|
|
35
|
+
),
|
|
36
|
+
/* @__PURE__ */ jsxs(PopoverContent, { className: "flex flex-col p-1", children: [
|
|
37
|
+
/* @__PURE__ */ jsx("p", { className: "mb-2 p-2 font-medium text-muted-foreground", children: context.text.chooseLanguage }),
|
|
38
|
+
languages.map(([lang, { name }]) => /* @__PURE__ */ jsx(
|
|
39
|
+
"button",
|
|
40
|
+
{
|
|
41
|
+
type: "button",
|
|
42
|
+
className: twMerge(
|
|
43
|
+
"rounded-md p-2 text-left text-sm transition-colors duration-100",
|
|
44
|
+
lang === context.locale ? "bg-primary/10 font-medium text-primary" : "hover:bg-accent hover:text-accent-foreground"
|
|
45
|
+
),
|
|
46
|
+
onClick: () => {
|
|
47
|
+
context.onChange?.(lang);
|
|
48
|
+
},
|
|
49
|
+
children: name
|
|
50
|
+
},
|
|
51
|
+
lang
|
|
52
|
+
))
|
|
53
|
+
] })
|
|
54
|
+
] });
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
LanguageToggle
|
|
58
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
interface Option {
|
|
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
|
+
declare function RootToggle({ options, }: {
|
|
13
|
+
options: Option[];
|
|
14
|
+
}): React.ReactElement;
|
|
15
|
+
|
|
16
|
+
export { RootToggle };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Popover,
|
|
4
|
+
PopoverContent,
|
|
5
|
+
PopoverTrigger
|
|
6
|
+
} from "../../chunk-UBVEKNRF.js";
|
|
7
|
+
import {
|
|
8
|
+
isActive
|
|
9
|
+
} from "../../chunk-AN2Y6MA2.js";
|
|
10
|
+
import {
|
|
11
|
+
twMerge
|
|
12
|
+
} from "../../chunk-TK3TM3MR.js";
|
|
13
|
+
import "../../chunk-MLKGABMK.js";
|
|
14
|
+
|
|
15
|
+
// src/components/layout/root-toggle.tsx
|
|
16
|
+
import { ChevronDown } from "lucide-react";
|
|
17
|
+
import { useState } from "react";
|
|
18
|
+
import Link from "next/link";
|
|
19
|
+
import { usePathname } from "next/navigation";
|
|
20
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
function RootToggle({
|
|
22
|
+
options
|
|
23
|
+
}) {
|
|
24
|
+
const [open, setOpen] = useState(false);
|
|
25
|
+
const pathname = usePathname();
|
|
26
|
+
const selected = options.find((item) => isActive(item.url, pathname, true)) ?? options[0];
|
|
27
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
28
|
+
/* @__PURE__ */ jsxs(PopoverTrigger, { className: "-mx-2 flex flex-row items-center gap-2 rounded-lg p-2 hover:bg-muted", children: [
|
|
29
|
+
/* @__PURE__ */ jsx(Item, { ...selected }),
|
|
30
|
+
/* @__PURE__ */ jsx(ChevronDown, { className: "size-4 text-muted-foreground" })
|
|
31
|
+
] }),
|
|
32
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-[var(--radix-popover-trigger-width)] overflow-hidden p-0", children: options.map((item) => /* @__PURE__ */ jsx(
|
|
33
|
+
Link,
|
|
34
|
+
{
|
|
35
|
+
href: item.url,
|
|
36
|
+
onClick: () => {
|
|
37
|
+
setOpen(false);
|
|
38
|
+
},
|
|
39
|
+
className: twMerge(
|
|
40
|
+
"flex w-full flex-row gap-2 p-2",
|
|
41
|
+
selected === item ? "bg-accent text-accent-foreground" : "hover:bg-accent/50"
|
|
42
|
+
),
|
|
43
|
+
children: /* @__PURE__ */ jsx(Item, { ...item })
|
|
44
|
+
},
|
|
45
|
+
item.url
|
|
46
|
+
)) })
|
|
47
|
+
] });
|
|
48
|
+
}
|
|
49
|
+
function Item({ title, icon, description }) {
|
|
50
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
51
|
+
icon,
|
|
52
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 text-left", children: [
|
|
53
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: title }),
|
|
54
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: description })
|
|
55
|
+
] })
|
|
56
|
+
] });
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
RootToggle
|
|
60
|
+
};
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
twMerge
|
|
7
7
|
} from "../chunk-TK3TM3MR.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-MLKGABMK.js";
|
|
9
9
|
|
|
10
10
|
// src/components/roll-button.tsx
|
|
11
11
|
import { ChevronUp } from "lucide-react";
|
|
@@ -18,8 +18,7 @@ function RollButton({
|
|
|
18
18
|
useEffect(() => {
|
|
19
19
|
const listener = () => {
|
|
20
20
|
const element = document.scrollingElement;
|
|
21
|
-
if (!element)
|
|
22
|
-
return;
|
|
21
|
+
if (!element) return;
|
|
23
22
|
const nearTop = element.scrollTop / (element.scrollHeight - element.clientHeight) < percentage;
|
|
24
23
|
setShow(!nearTop);
|
|
25
24
|
};
|
package/dist/components/steps.js
CHANGED
package/dist/components/tabs.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "../chunk-TK3TM3MR.js";
|
|
5
5
|
import {
|
|
6
6
|
__export
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-MLKGABMK.js";
|
|
8
8
|
|
|
9
9
|
// src/components/tabs.tsx
|
|
10
10
|
import { useEffect, useMemo, useState } from "react";
|
|
@@ -74,10 +74,8 @@ function update(id, v, persist) {
|
|
|
74
74
|
listeners.get(id)?.forEach((item) => {
|
|
75
75
|
item(v);
|
|
76
76
|
});
|
|
77
|
-
if (persist)
|
|
78
|
-
|
|
79
|
-
else
|
|
80
|
-
sessionStorage.setItem(id, v);
|
|
77
|
+
if (persist) localStorage.setItem(id, v);
|
|
78
|
+
else sessionStorage.setItem(id, v);
|
|
81
79
|
}
|
|
82
80
|
function Tabs2({
|
|
83
81
|
id,
|
|
@@ -89,15 +87,12 @@ function Tabs2({
|
|
|
89
87
|
const values = useMemo(() => items.map((item) => toValue(item)), [items]);
|
|
90
88
|
const [value, setValue] = useState(values[defaultIndex]);
|
|
91
89
|
useEffect(() => {
|
|
92
|
-
if (!id)
|
|
93
|
-
return;
|
|
90
|
+
if (!id) return;
|
|
94
91
|
const onUpdate = (v) => {
|
|
95
|
-
if (values.includes(v))
|
|
96
|
-
setValue(v);
|
|
92
|
+
if (values.includes(v)) setValue(v);
|
|
97
93
|
};
|
|
98
94
|
const previous = persist ? localStorage.getItem(id) : sessionStorage.getItem(id);
|
|
99
|
-
if (previous)
|
|
100
|
-
onUpdate(previous);
|
|
95
|
+
if (previous) onUpdate(previous);
|
|
101
96
|
addChangeListener(id, onUpdate);
|
|
102
97
|
return () => {
|
|
103
98
|
removeChangeListener(id, onUpdate);
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
Popover,
|
|
4
4
|
PopoverContent,
|
|
5
5
|
PopoverTrigger
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-UBVEKNRF.js";
|
|
7
7
|
import {
|
|
8
8
|
twMerge
|
|
9
9
|
} from "../chunk-TK3TM3MR.js";
|
|
10
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-MLKGABMK.js";
|
|
11
11
|
|
|
12
12
|
// src/components/type-table.tsx
|
|
13
13
|
import { InfoIcon } from "lucide-react";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { S as SidebarProps, N as NavProps } from './layout.client-Duq0TTke.js';
|
|
2
|
+
export { a as Sidebar } from './layout.client-Duq0TTke.js';
|
|
3
|
+
export { T as TreeContextProvider } from './tree-CrKzI9Nz.js';
|
|
4
|
+
import { ButtonHTMLAttributes } from 'react';
|
|
5
|
+
import 'fumadocs-core/server';
|
|
6
|
+
|
|
7
|
+
declare function DynamicSidebar(props: SidebarProps): React.ReactElement;
|
|
8
|
+
|
|
9
|
+
declare function ThemeToggle({ className, ...props }: ButtonHTMLAttributes<HTMLButtonElement>): React.ReactElement;
|
|
10
|
+
|
|
11
|
+
declare function SubNav({ title, url, children, enableSearch, }: NavProps): React.ReactElement;
|
|
12
|
+
|
|
13
|
+
export { DynamicSidebar, SubNav, ThemeToggle };
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
LargeSearchToggle,
|
|
4
|
+
LinkItem,
|
|
5
|
+
SearchToggle,
|
|
6
|
+
ThemeToggle
|
|
7
|
+
} from "./chunk-JQW5DMD2.js";
|
|
8
|
+
import {
|
|
9
|
+
TreeContextProvider,
|
|
10
|
+
useTreeContext
|
|
11
|
+
} from "./chunk-34Z7WODD.js";
|
|
12
|
+
import {
|
|
13
|
+
ScrollArea,
|
|
14
|
+
ScrollViewport
|
|
15
|
+
} from "./chunk-VYTHQTZE.js";
|
|
16
|
+
import "./chunk-UBVEKNRF.js";
|
|
17
|
+
import {
|
|
18
|
+
hasActive,
|
|
19
|
+
isActive
|
|
20
|
+
} from "./chunk-AN2Y6MA2.js";
|
|
21
|
+
import {
|
|
22
|
+
useSidebar
|
|
23
|
+
} from "./chunk-3F57TIUQ.js";
|
|
24
|
+
import {
|
|
25
|
+
useSearchContext
|
|
26
|
+
} from "./chunk-FSPYEOFC.js";
|
|
27
|
+
import "./chunk-CRYPD6UZ.js";
|
|
28
|
+
import {
|
|
29
|
+
Collapsible,
|
|
30
|
+
CollapsibleContent,
|
|
31
|
+
CollapsibleTrigger
|
|
32
|
+
} from "./chunk-7XPZOMJ2.js";
|
|
33
|
+
import {
|
|
34
|
+
buttonVariants
|
|
35
|
+
} from "./chunk-7GZKFBAP.js";
|
|
36
|
+
import {
|
|
37
|
+
twMerge
|
|
38
|
+
} from "./chunk-TK3TM3MR.js";
|
|
39
|
+
import "./chunk-MLKGABMK.js";
|
|
40
|
+
|
|
41
|
+
// src/docs.client.tsx
|
|
42
|
+
import Link2 from "next/link";
|
|
43
|
+
import { SidebarTrigger } from "fumadocs-core/sidebar";
|
|
44
|
+
import { Menu, X } from "lucide-react";
|
|
45
|
+
|
|
46
|
+
// src/components/layout/sidebar.tsx
|
|
47
|
+
import { cva } from "class-variance-authority";
|
|
48
|
+
import { ChevronDown, ExternalLinkIcon } from "lucide-react";
|
|
49
|
+
import * as Base from "fumadocs-core/sidebar";
|
|
50
|
+
import { usePathname } from "next/navigation";
|
|
51
|
+
import {
|
|
52
|
+
createContext,
|
|
53
|
+
useCallback,
|
|
54
|
+
useContext,
|
|
55
|
+
useEffect,
|
|
56
|
+
useMemo,
|
|
57
|
+
useState
|
|
58
|
+
} from "react";
|
|
59
|
+
import Link from "fumadocs-core/link";
|
|
60
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
61
|
+
var itemVariants = cva(
|
|
62
|
+
"flex w-full flex-row items-center gap-2 rounded-md px-2 py-1.5 text-muted-foreground transition-colors duration-100 [&_svg]:size-4",
|
|
63
|
+
{
|
|
64
|
+
variants: {
|
|
65
|
+
active: {
|
|
66
|
+
true: "bg-primary/10 font-medium text-primary",
|
|
67
|
+
false: "hover:bg-accent/50 hover:text-accent-foreground/80 hover:transition-none"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
var defaultComponents = {
|
|
73
|
+
Folder: FolderNode,
|
|
74
|
+
Separator: SeparatorNode,
|
|
75
|
+
Item: PageNode
|
|
76
|
+
};
|
|
77
|
+
var Context = createContext({
|
|
78
|
+
defaultOpenLevel: 1,
|
|
79
|
+
components: defaultComponents
|
|
80
|
+
});
|
|
81
|
+
function Sidebar({
|
|
82
|
+
footer,
|
|
83
|
+
components,
|
|
84
|
+
defaultOpenLevel = 1,
|
|
85
|
+
banner,
|
|
86
|
+
items,
|
|
87
|
+
aside,
|
|
88
|
+
bannerProps,
|
|
89
|
+
footerProps
|
|
90
|
+
}) {
|
|
91
|
+
const context = useMemo(
|
|
92
|
+
() => ({
|
|
93
|
+
defaultOpenLevel,
|
|
94
|
+
components: { ...defaultComponents, ...components }
|
|
95
|
+
}),
|
|
96
|
+
[components, defaultOpenLevel]
|
|
97
|
+
);
|
|
98
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value: context, children: /* @__PURE__ */ jsxs(
|
|
99
|
+
Base.SidebarList,
|
|
100
|
+
{
|
|
101
|
+
id: "nd-sidebar",
|
|
102
|
+
blockScrollingWidth: 768,
|
|
103
|
+
...aside,
|
|
104
|
+
className: twMerge(
|
|
105
|
+
"z-30 flex w-full flex-col text-[15px] md:sticky md:top-0 md:h-dvh md:w-[240px] md:border-e md:bg-card md:text-sm xl:w-[260px]",
|
|
106
|
+
"max-md:fixed max-md:inset-0 max-md:bg-background/80 max-md:pt-16 max-md:backdrop-blur-md max-md:data-[open=false]:hidden",
|
|
107
|
+
aside?.className
|
|
108
|
+
),
|
|
109
|
+
children: [
|
|
110
|
+
/* @__PURE__ */ jsxs(
|
|
111
|
+
"div",
|
|
112
|
+
{
|
|
113
|
+
...bannerProps,
|
|
114
|
+
className: twMerge(
|
|
115
|
+
"flex flex-col gap-2 border-b px-4 py-2 md:p-3 md:pt-10",
|
|
116
|
+
bannerProps?.className
|
|
117
|
+
),
|
|
118
|
+
children: [
|
|
119
|
+
banner,
|
|
120
|
+
/* @__PURE__ */ jsx(LargeSearchToggle, { className: "rounded-lg max-md:hidden" })
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
/* @__PURE__ */ jsx(ViewportContent, { children: items.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: items.map((item, i) => /* @__PURE__ */ jsx(LinkItem, { item, on: "menu" }, i)) }) }),
|
|
125
|
+
/* @__PURE__ */ jsx(
|
|
126
|
+
"div",
|
|
127
|
+
{
|
|
128
|
+
...footerProps,
|
|
129
|
+
className: twMerge(
|
|
130
|
+
"flex flex-row items-center border-t px-4 py-2 md:px-3",
|
|
131
|
+
footerProps?.className
|
|
132
|
+
),
|
|
133
|
+
children: footer
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
) });
|
|
139
|
+
}
|
|
140
|
+
function ViewportContent({
|
|
141
|
+
children
|
|
142
|
+
}) {
|
|
143
|
+
const { root } = useTreeContext();
|
|
144
|
+
return /* @__PURE__ */ jsx(ScrollArea, { className: "flex-1", children: /* @__PURE__ */ jsx(ScrollViewport, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-8 p-4 pb-10 md:px-3", children: [
|
|
145
|
+
children,
|
|
146
|
+
/* @__PURE__ */ jsx(NodeList, { items: root.children })
|
|
147
|
+
] }) }) });
|
|
148
|
+
}
|
|
149
|
+
function NodeList({
|
|
150
|
+
items,
|
|
151
|
+
level = 0,
|
|
152
|
+
...props
|
|
153
|
+
}) {
|
|
154
|
+
const { components } = useContext(Context);
|
|
155
|
+
return /* @__PURE__ */ jsx("div", { ...props, children: items.map((item) => {
|
|
156
|
+
const id = `${item.type}_${item.name}`;
|
|
157
|
+
switch (item.type) {
|
|
158
|
+
case "separator":
|
|
159
|
+
return /* @__PURE__ */ jsx(components.Separator, { item }, id);
|
|
160
|
+
case "folder":
|
|
161
|
+
return /* @__PURE__ */ jsx(components.Folder, { item, level: level + 1 }, id);
|
|
162
|
+
default:
|
|
163
|
+
return /* @__PURE__ */ jsx(components.Item, { item }, item.url);
|
|
164
|
+
}
|
|
165
|
+
}) });
|
|
166
|
+
}
|
|
167
|
+
function PageNode({
|
|
168
|
+
item: { icon, external = false, url, name }
|
|
169
|
+
}) {
|
|
170
|
+
const pathname = usePathname();
|
|
171
|
+
const { closeOnRedirect } = useSidebar();
|
|
172
|
+
const active = isActive(url, pathname, false);
|
|
173
|
+
return /* @__PURE__ */ jsxs(
|
|
174
|
+
Link,
|
|
175
|
+
{
|
|
176
|
+
href: url,
|
|
177
|
+
external,
|
|
178
|
+
className: twMerge(itemVariants({ active })),
|
|
179
|
+
onClick: useCallback(() => {
|
|
180
|
+
closeOnRedirect.current = !active;
|
|
181
|
+
}, [closeOnRedirect, active]),
|
|
182
|
+
children: [
|
|
183
|
+
icon ?? (external ? /* @__PURE__ */ jsx(ExternalLinkIcon, {}) : null),
|
|
184
|
+
name
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
function FolderNode({
|
|
190
|
+
item: { name, children, index, icon, defaultOpen = false },
|
|
191
|
+
level
|
|
192
|
+
}) {
|
|
193
|
+
const { defaultOpenLevel } = useContext(Context);
|
|
194
|
+
const { closeOnRedirect } = useSidebar();
|
|
195
|
+
const pathname = usePathname();
|
|
196
|
+
const active = index !== void 0 && isActive(index.url, pathname, false);
|
|
197
|
+
const childActive = useMemo(
|
|
198
|
+
() => hasActive(children, pathname),
|
|
199
|
+
[children, pathname]
|
|
200
|
+
);
|
|
201
|
+
const shouldExtend = active || childActive || defaultOpenLevel >= level || defaultOpen;
|
|
202
|
+
const [extend, setExtend] = useState(shouldExtend);
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
if (shouldExtend) setExtend(true);
|
|
205
|
+
}, [shouldExtend]);
|
|
206
|
+
const onClick = useCallback(
|
|
207
|
+
(e) => {
|
|
208
|
+
if (e.target !== e.currentTarget || active) {
|
|
209
|
+
setExtend((prev) => !prev);
|
|
210
|
+
e.preventDefault();
|
|
211
|
+
} else {
|
|
212
|
+
closeOnRedirect.current = !active;
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
[closeOnRedirect, active]
|
|
216
|
+
);
|
|
217
|
+
return /* @__PURE__ */ jsxs(Collapsible, { open: extend, onOpenChange: setExtend, children: [
|
|
218
|
+
index ? /* @__PURE__ */ jsxs(
|
|
219
|
+
Link,
|
|
220
|
+
{
|
|
221
|
+
className: twMerge(itemVariants({ active })),
|
|
222
|
+
href: index.url,
|
|
223
|
+
onClick,
|
|
224
|
+
children: [
|
|
225
|
+
icon,
|
|
226
|
+
name,
|
|
227
|
+
/* @__PURE__ */ jsx(
|
|
228
|
+
ChevronDown,
|
|
229
|
+
{
|
|
230
|
+
className: twMerge(
|
|
231
|
+
"ms-auto transition-transform",
|
|
232
|
+
!extend && "-rotate-90"
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
) : /* @__PURE__ */ jsxs(CollapsibleTrigger, { className: twMerge(itemVariants({ active })), children: [
|
|
239
|
+
icon,
|
|
240
|
+
name,
|
|
241
|
+
/* @__PURE__ */ jsx(
|
|
242
|
+
ChevronDown,
|
|
243
|
+
{
|
|
244
|
+
className: twMerge(
|
|
245
|
+
"ms-auto transition-transform",
|
|
246
|
+
!extend && "-rotate-90"
|
|
247
|
+
)
|
|
248
|
+
}
|
|
249
|
+
)
|
|
250
|
+
] }),
|
|
251
|
+
/* @__PURE__ */ jsx(CollapsibleContent, { children: /* @__PURE__ */ jsx(
|
|
252
|
+
NodeList,
|
|
253
|
+
{
|
|
254
|
+
className: "ms-2 flex flex-col border-s py-2 ps-2",
|
|
255
|
+
items: children,
|
|
256
|
+
level
|
|
257
|
+
}
|
|
258
|
+
) })
|
|
259
|
+
] });
|
|
260
|
+
}
|
|
261
|
+
function SeparatorNode({
|
|
262
|
+
item
|
|
263
|
+
}) {
|
|
264
|
+
return /* @__PURE__ */ jsx("p", { className: "mb-2 mt-8 px-2 font-medium first:mt-0", children: item.name });
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// src/components/layout/dynamic-sidebar.tsx
|
|
268
|
+
import { useCallback as useCallback2, useRef, useState as useState2 } from "react";
|
|
269
|
+
import { SidebarIcon } from "lucide-react";
|
|
270
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
271
|
+
function DynamicSidebar(props) {
|
|
272
|
+
const { collapsed, setCollapsed } = useSidebar();
|
|
273
|
+
const [hover, setHover] = useState2(false);
|
|
274
|
+
const timerRef = useRef(0);
|
|
275
|
+
const onCollapse = useCallback2(() => {
|
|
276
|
+
setCollapsed(!collapsed);
|
|
277
|
+
}, [collapsed, setCollapsed]);
|
|
278
|
+
const onHover = useCallback2((e) => {
|
|
279
|
+
if (e.pointerType === "touch") return;
|
|
280
|
+
window.clearTimeout(timerRef.current);
|
|
281
|
+
setHover(true);
|
|
282
|
+
}, []);
|
|
283
|
+
const onLeave = useCallback2((e) => {
|
|
284
|
+
if (e.pointerType === "touch") return;
|
|
285
|
+
window.clearTimeout(timerRef.current);
|
|
286
|
+
timerRef.current = window.setTimeout(() => {
|
|
287
|
+
setHover(false);
|
|
288
|
+
}, 300);
|
|
289
|
+
}, []);
|
|
290
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
291
|
+
collapsed ? /* @__PURE__ */ jsx2(
|
|
292
|
+
"div",
|
|
293
|
+
{
|
|
294
|
+
className: "fixed inset-y-0 start-0 w-4 max-md:hidden xl:static xl:w-[260px]",
|
|
295
|
+
onPointerEnter: onHover,
|
|
296
|
+
onPointerLeave: onLeave
|
|
297
|
+
}
|
|
298
|
+
) : null,
|
|
299
|
+
collapsed ? /* @__PURE__ */ jsx2(
|
|
300
|
+
"button",
|
|
301
|
+
{
|
|
302
|
+
type: "button",
|
|
303
|
+
"aria-label": "Collapse Sidebar",
|
|
304
|
+
className: twMerge(
|
|
305
|
+
buttonVariants({
|
|
306
|
+
color: "secondary",
|
|
307
|
+
size: "icon",
|
|
308
|
+
className: "fixed start-4 bottom-4 z-10 max-md:hidden"
|
|
309
|
+
})
|
|
310
|
+
),
|
|
311
|
+
onClick: onCollapse,
|
|
312
|
+
children: /* @__PURE__ */ jsx2(SidebarIcon, {})
|
|
313
|
+
}
|
|
314
|
+
) : null,
|
|
315
|
+
/* @__PURE__ */ jsx2(
|
|
316
|
+
Sidebar,
|
|
317
|
+
{
|
|
318
|
+
...props,
|
|
319
|
+
aside: {
|
|
320
|
+
"data-collapse": collapsed,
|
|
321
|
+
"data-hover": hover,
|
|
322
|
+
onPointerEnter: onHover,
|
|
323
|
+
onPointerLeave: onLeave,
|
|
324
|
+
"aria-hidden": Boolean(collapsed && !hover),
|
|
325
|
+
className: twMerge(
|
|
326
|
+
"overflow-hidden md:transition-transform",
|
|
327
|
+
collapsed && "md:fixed md:inset-y-2 md:start-2 md:h-auto md:rounded-xl md:border md:shadow-md"
|
|
328
|
+
)
|
|
329
|
+
},
|
|
330
|
+
footer: /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
331
|
+
props.footer,
|
|
332
|
+
/* @__PURE__ */ jsx2(
|
|
333
|
+
"button",
|
|
334
|
+
{
|
|
335
|
+
type: "button",
|
|
336
|
+
"aria-label": "Collapse Sidebar",
|
|
337
|
+
className: twMerge(
|
|
338
|
+
buttonVariants({
|
|
339
|
+
color: "ghost",
|
|
340
|
+
size: "icon",
|
|
341
|
+
className: "max-md:hidden"
|
|
342
|
+
})
|
|
343
|
+
),
|
|
344
|
+
onClick: onCollapse,
|
|
345
|
+
children: /* @__PURE__ */ jsx2(SidebarIcon, {})
|
|
346
|
+
}
|
|
347
|
+
)
|
|
348
|
+
] })
|
|
349
|
+
}
|
|
350
|
+
)
|
|
351
|
+
] });
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// src/docs.client.tsx
|
|
355
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
356
|
+
function SubNav({
|
|
357
|
+
title,
|
|
358
|
+
url = "/",
|
|
359
|
+
children,
|
|
360
|
+
enableSearch = true
|
|
361
|
+
}) {
|
|
362
|
+
const { open } = useSidebar();
|
|
363
|
+
const { enabled } = useSearchContext();
|
|
364
|
+
return /* @__PURE__ */ jsxs3(
|
|
365
|
+
"nav",
|
|
366
|
+
{
|
|
367
|
+
id: "nd-subnav",
|
|
368
|
+
className: "sticky top-0 z-40 flex h-16 w-full flex-row items-center border-b bg-background/50 px-4 backdrop-blur-md md:hidden [&_svg]:size-5",
|
|
369
|
+
children: [
|
|
370
|
+
/* @__PURE__ */ jsx3(Link2, { href: url, className: "inline-flex items-center gap-3 font-semibold", children: title }),
|
|
371
|
+
children,
|
|
372
|
+
enabled && enableSearch ? /* @__PURE__ */ jsx3(SearchToggle, { className: "ml-auto" }) : null,
|
|
373
|
+
/* @__PURE__ */ jsx3(
|
|
374
|
+
SidebarTrigger,
|
|
375
|
+
{
|
|
376
|
+
className: twMerge(
|
|
377
|
+
buttonVariants({
|
|
378
|
+
color: "ghost",
|
|
379
|
+
size: "icon",
|
|
380
|
+
className: (!enabled || !enableSearch) && "ml-auto"
|
|
381
|
+
})
|
|
382
|
+
),
|
|
383
|
+
children: open ? /* @__PURE__ */ jsx3(X, {}) : /* @__PURE__ */ jsx3(Menu, {})
|
|
384
|
+
}
|
|
385
|
+
)
|
|
386
|
+
]
|
|
387
|
+
}
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
export {
|
|
391
|
+
DynamicSidebar,
|
|
392
|
+
Sidebar,
|
|
393
|
+
SubNav,
|
|
394
|
+
ThemeToggle,
|
|
395
|
+
TreeContextProvider
|
|
396
|
+
};
|
package/dist/i18n.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { SelectProps } from '@radix-ui/react-select';
|
|
2
1
|
import { ReactNode } from 'react';
|
|
3
|
-
import { N as NamedTranslation } from './i18n-
|
|
4
|
-
export { T as Translations } from './i18n-
|
|
2
|
+
import { N as NamedTranslation } from './i18n-CE8z-AAs.js';
|
|
3
|
+
export { T as Translations } from './i18n-CE8z-AAs.js';
|
|
5
4
|
|
|
6
|
-
type LanguageSelectProps = Omit<SelectProps, 'value' | 'onValueChange'>;
|
|
7
|
-
declare function LanguageSelect({ ...props }: LanguageSelectProps): React.ReactElement;
|
|
8
5
|
interface I18nProviderProps {
|
|
9
6
|
/**
|
|
10
7
|
* Force a locale
|
|
@@ -18,4 +15,4 @@ interface I18nProviderProps {
|
|
|
18
15
|
}
|
|
19
16
|
declare function I18nProvider({ translations, locale: forceLocale, children, }: I18nProviderProps): React.ReactElement;
|
|
20
17
|
|
|
21
|
-
export { I18nProvider
|
|
18
|
+
export { I18nProvider };
|