fumadocs-ui 11.3.2 → 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-TDTHXDET.js → chunk-34Z7WODD.js} +2 -1
- package/dist/{chunk-IN5NHEZV.js → chunk-3F57TIUQ.js} +20 -5
- package/dist/{chunk-PXDQVGII.js → chunk-7EMVRXMS.js} +10 -1
- 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/components/api.js +1 -1
- package/dist/components/dialog/search-algolia.js +3 -2
- package/dist/components/dialog/search-default.js +3 -2
- package/dist/components/dialog/search.js +3 -2
- package/dist/components/heading.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/type-table.js +1 -1
- package/dist/docs.client.d.ts +13 -0
- package/dist/docs.client.js +396 -0
- package/dist/{i18n-K879Pt9h.d.ts → i18n-CE8z-AAs.d.ts} +1 -0
- package/dist/i18n.d.ts +3 -6
- package/dist/i18n.js +4 -102
- package/dist/{layout-WuS8Ab4e.d.ts → layout.client-Duq0TTke.d.ts} +23 -15
- package/dist/layout.client.d.ts +2 -8
- package/dist/layout.client.js +37 -565
- package/dist/layout.d.ts +1 -1
- package/dist/layout.js +40 -26
- package/dist/mdx.js +2 -2
- package/dist/page.client.js +4 -4
- package/dist/page.js +17 -8
- package/dist/provider.d.ts +11 -12
- package/dist/provider.js +9 -10
- package/dist/style.css +1 -1
- package/dist/tailwind-plugin.cjs +17 -22
- package/dist/tailwind-plugin.js +17 -22
- package/dist/twoslash/popup.js +1 -1
- package/dist/twoslash.css +1 -1
- package/package.json +4 -5
|
@@ -36,9 +36,10 @@ function TreeContextProvider({
|
|
|
36
36
|
const pathname = usePathname();
|
|
37
37
|
const value = useMemo(() => {
|
|
38
38
|
const root = findRoot(tree.children, pathname) ?? tree;
|
|
39
|
+
const navigation = getNavigationList(root.children);
|
|
39
40
|
return {
|
|
40
41
|
root,
|
|
41
|
-
navigation
|
|
42
|
+
navigation,
|
|
42
43
|
tree
|
|
43
44
|
};
|
|
44
45
|
}, [pathname, tree]);
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
// src/contexts/sidebar.tsx
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createContext,
|
|
4
|
+
useContext,
|
|
5
|
+
useState,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useEffect
|
|
9
|
+
} from "react";
|
|
10
|
+
import { usePathname } from "next/navigation";
|
|
3
11
|
import { SidebarProvider as BaseProvider } from "fumadocs-core/sidebar";
|
|
4
12
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
var SidebarContext = createContext(
|
|
6
|
-
void 0
|
|
7
|
-
);
|
|
13
|
+
var SidebarContext = createContext(void 0);
|
|
8
14
|
function useSidebar() {
|
|
9
15
|
const ctx = useContext(SidebarContext);
|
|
10
16
|
if (!ctx) throw new Error("Missing root provider");
|
|
@@ -13,8 +19,16 @@ function useSidebar() {
|
|
|
13
19
|
function SidebarProvider({
|
|
14
20
|
children
|
|
15
21
|
}) {
|
|
22
|
+
const closeOnRedirect = useRef(false);
|
|
16
23
|
const [open, setOpen] = useState(false);
|
|
17
24
|
const [collapsed, setCollapsed] = useState(false);
|
|
25
|
+
const pathname = usePathname();
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (closeOnRedirect.current) {
|
|
28
|
+
setOpen(false);
|
|
29
|
+
closeOnRedirect.current = false;
|
|
30
|
+
}
|
|
31
|
+
}, [pathname]);
|
|
18
32
|
return /* @__PURE__ */ jsx(
|
|
19
33
|
SidebarContext.Provider,
|
|
20
34
|
{
|
|
@@ -23,7 +37,8 @@ function SidebarProvider({
|
|
|
23
37
|
open,
|
|
24
38
|
setOpen,
|
|
25
39
|
collapsed,
|
|
26
|
-
setCollapsed
|
|
40
|
+
setCollapsed,
|
|
41
|
+
closeOnRedirect
|
|
27
42
|
}),
|
|
28
43
|
[open, collapsed]
|
|
29
44
|
),
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useSidebar
|
|
3
|
+
} from "./chunk-3F57TIUQ.js";
|
|
1
4
|
import {
|
|
2
5
|
useSearchContext
|
|
3
6
|
} from "./chunk-FSPYEOFC.js";
|
|
4
7
|
import {
|
|
5
8
|
useI18n
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-CRYPD6UZ.js";
|
|
7
10
|
import {
|
|
8
11
|
buttonVariants
|
|
9
12
|
} from "./chunk-7GZKFBAP.js";
|
|
@@ -180,11 +183,17 @@ function Search2({
|
|
|
180
183
|
const { text } = useI18n();
|
|
181
184
|
const router = useRouter();
|
|
182
185
|
const { setOpenSearch } = useSearchContext();
|
|
186
|
+
const sidebar = useSidebar();
|
|
183
187
|
const items = results === "empty" ? defaultItems : results;
|
|
184
188
|
const hideList = results === "empty" && defaultItems.length === 0;
|
|
185
189
|
const onOpen = (url) => {
|
|
186
190
|
router.push(url);
|
|
187
191
|
setOpenSearch(false);
|
|
192
|
+
if (location.pathname === url.split("#")[0]) {
|
|
193
|
+
sidebar.setOpen(false);
|
|
194
|
+
} else {
|
|
195
|
+
sidebar.closeOnRedirect.current = true;
|
|
196
|
+
}
|
|
188
197
|
};
|
|
189
198
|
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
190
199
|
/* @__PURE__ */ jsx2(
|
|
@@ -11,7 +11,7 @@ function Heading({
|
|
|
11
11
|
...props
|
|
12
12
|
}) {
|
|
13
13
|
const As = as ?? "h1";
|
|
14
|
-
return /* @__PURE__ */ jsx(As, { className: twMerge("scroll-m-20", className), ...props, children: props.id ? /* @__PURE__ */ jsxs("a", { href: `#${props.id}`, className: "
|
|
14
|
+
return /* @__PURE__ */ jsx(As, { className: twMerge("scroll-m-20", className), ...props, children: props.id ? /* @__PURE__ */ jsxs("a", { href: `#${props.id}`, className: "group", children: [
|
|
15
15
|
props.children,
|
|
16
16
|
/* @__PURE__ */ jsx(
|
|
17
17
|
LinkIcon,
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Popover,
|
|
3
|
+
PopoverContent,
|
|
4
|
+
PopoverTrigger
|
|
5
|
+
} from "./chunk-UBVEKNRF.js";
|
|
6
|
+
import {
|
|
7
|
+
isActive
|
|
8
|
+
} from "./chunk-AN2Y6MA2.js";
|
|
9
|
+
import {
|
|
10
|
+
useSearchContext
|
|
11
|
+
} from "./chunk-FSPYEOFC.js";
|
|
12
|
+
import {
|
|
13
|
+
useI18n
|
|
14
|
+
} from "./chunk-CRYPD6UZ.js";
|
|
15
|
+
import {
|
|
16
|
+
Collapsible,
|
|
17
|
+
CollapsibleContent,
|
|
18
|
+
CollapsibleTrigger
|
|
19
|
+
} from "./chunk-7XPZOMJ2.js";
|
|
20
|
+
import {
|
|
21
|
+
buttonVariants
|
|
22
|
+
} from "./chunk-7GZKFBAP.js";
|
|
23
|
+
import {
|
|
24
|
+
twMerge
|
|
25
|
+
} from "./chunk-TK3TM3MR.js";
|
|
26
|
+
|
|
27
|
+
// src/components/layout/search-toggle.tsx
|
|
28
|
+
import { useCallback } from "react";
|
|
29
|
+
import { SearchIcon } from "lucide-react";
|
|
30
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
31
|
+
function SearchToggle(props) {
|
|
32
|
+
const { setOpenSearch } = useSearchContext();
|
|
33
|
+
return /* @__PURE__ */ jsx(
|
|
34
|
+
"button",
|
|
35
|
+
{
|
|
36
|
+
type: "button",
|
|
37
|
+
className: twMerge(
|
|
38
|
+
buttonVariants({
|
|
39
|
+
size: "icon",
|
|
40
|
+
color: "ghost",
|
|
41
|
+
className: props.className
|
|
42
|
+
})
|
|
43
|
+
),
|
|
44
|
+
"aria-label": "Open Search",
|
|
45
|
+
onClick: useCallback(() => {
|
|
46
|
+
setOpenSearch(true);
|
|
47
|
+
}, [setOpenSearch]),
|
|
48
|
+
children: /* @__PURE__ */ jsx(SearchIcon, {})
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
function LargeSearchToggle(props) {
|
|
53
|
+
const { hotKey, setOpenSearch } = useSearchContext();
|
|
54
|
+
const { text } = useI18n();
|
|
55
|
+
return /* @__PURE__ */ jsxs(
|
|
56
|
+
"button",
|
|
57
|
+
{
|
|
58
|
+
type: "button",
|
|
59
|
+
...props,
|
|
60
|
+
className: twMerge(
|
|
61
|
+
"inline-flex items-center gap-2 rounded-full border bg-secondary/50 p-1.5 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground",
|
|
62
|
+
props.className
|
|
63
|
+
),
|
|
64
|
+
onClick: useCallback(() => {
|
|
65
|
+
setOpenSearch(true);
|
|
66
|
+
}, [setOpenSearch]),
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ jsx(SearchIcon, { className: "ms-1 size-4" }),
|
|
69
|
+
text.search,
|
|
70
|
+
/* @__PURE__ */ jsx("div", { className: "ms-auto inline-flex gap-0.5 text-xs", children: hotKey.map((k, i) => /* @__PURE__ */ jsx("kbd", { className: "rounded-md border bg-background px-1.5", children: k.display }, i)) })
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// src/components/layout/theme-toggle.tsx
|
|
77
|
+
import { cva } from "class-variance-authority";
|
|
78
|
+
import { Moon, Sun } from "lucide-react";
|
|
79
|
+
import { useTheme } from "next-themes";
|
|
80
|
+
import { useCallback as useCallback2 } from "react";
|
|
81
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
82
|
+
var buttonVariants2 = cva("size-7 rounded-full p-1.5 text-muted-foreground", {
|
|
83
|
+
variants: {
|
|
84
|
+
dark: {
|
|
85
|
+
true: "dark:bg-accent dark:text-accent-foreground",
|
|
86
|
+
false: "bg-accent text-accent-foreground dark:bg-transparent dark:text-muted-foreground"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
function ThemeToggle({
|
|
91
|
+
className,
|
|
92
|
+
...props
|
|
93
|
+
}) {
|
|
94
|
+
const { setTheme, resolvedTheme } = useTheme();
|
|
95
|
+
const onToggle = useCallback2(() => {
|
|
96
|
+
setTheme(resolvedTheme === "dark" ? "light" : "dark");
|
|
97
|
+
}, [setTheme, resolvedTheme]);
|
|
98
|
+
return /* @__PURE__ */ jsxs2(
|
|
99
|
+
"button",
|
|
100
|
+
{
|
|
101
|
+
type: "button",
|
|
102
|
+
className: twMerge(
|
|
103
|
+
"inline-flex items-center rounded-full border p-0.5",
|
|
104
|
+
className
|
|
105
|
+
),
|
|
106
|
+
"aria-label": "Toggle Theme",
|
|
107
|
+
onClick: onToggle,
|
|
108
|
+
...props,
|
|
109
|
+
children: [
|
|
110
|
+
/* @__PURE__ */ jsx2(Sun, { className: twMerge(buttonVariants2({ dark: false })) }),
|
|
111
|
+
/* @__PURE__ */ jsx2(Moon, { className: twMerge(buttonVariants2({ dark: true })) })
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/components/link-item.tsx
|
|
118
|
+
import Link from "fumadocs-core/link";
|
|
119
|
+
import { ChevronDown } from "lucide-react";
|
|
120
|
+
import { usePathname } from "next/navigation";
|
|
121
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
122
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
123
|
+
var linkItemVariants = cva2(
|
|
124
|
+
"inline-flex items-center gap-1.5 rounded-lg p-2 text-muted-foreground transition-colors [&_svg]:size-4",
|
|
125
|
+
{
|
|
126
|
+
variants: {
|
|
127
|
+
active: {
|
|
128
|
+
true: "bg-accent text-accent-foreground",
|
|
129
|
+
false: "hover:bg-accent"
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
defaultVariants: {
|
|
133
|
+
active: false
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
function LinkItem({
|
|
138
|
+
item,
|
|
139
|
+
on = "nav",
|
|
140
|
+
className,
|
|
141
|
+
...props
|
|
142
|
+
}) {
|
|
143
|
+
const pathname = usePathname();
|
|
144
|
+
if (item.type === "menu" && on === "nav") {
|
|
145
|
+
return /* @__PURE__ */ jsxs3(Popover, { children: [
|
|
146
|
+
/* @__PURE__ */ jsxs3(
|
|
147
|
+
PopoverTrigger,
|
|
148
|
+
{
|
|
149
|
+
className: twMerge(
|
|
150
|
+
linkItemVariants({ className }),
|
|
151
|
+
"data-[state=open]:bg-accent"
|
|
152
|
+
),
|
|
153
|
+
...props,
|
|
154
|
+
children: [
|
|
155
|
+
item.text,
|
|
156
|
+
/* @__PURE__ */ jsx3(ChevronDown, { className: "ml-auto size-4" })
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
/* @__PURE__ */ jsx3(PopoverContent, { className: "flex flex-col", children: item.items.map((child, i) => /* @__PURE__ */ jsx3(LinkItem, { item: child, on: "menu" }, i)) })
|
|
161
|
+
] });
|
|
162
|
+
}
|
|
163
|
+
if (item.type === "menu") {
|
|
164
|
+
return /* @__PURE__ */ jsxs3(Collapsible, { className: "flex flex-col", children: [
|
|
165
|
+
/* @__PURE__ */ jsxs3(
|
|
166
|
+
CollapsibleTrigger,
|
|
167
|
+
{
|
|
168
|
+
className: twMerge(linkItemVariants({ className }), "group/link"),
|
|
169
|
+
...props,
|
|
170
|
+
children: [
|
|
171
|
+
item.icon,
|
|
172
|
+
item.text,
|
|
173
|
+
/* @__PURE__ */ jsx3(ChevronDown, { className: "ml-auto size-4 group-data-[state=closed]/link:-rotate-90" })
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
/* @__PURE__ */ jsx3(CollapsibleContent, { children: /* @__PURE__ */ jsx3("div", { className: "flex flex-col py-1 ps-4", children: item.items.map((child, i) => /* @__PURE__ */ jsx3(LinkItem, { item: child, on: "menu" }, i)) }) })
|
|
178
|
+
] });
|
|
179
|
+
}
|
|
180
|
+
const activeType = item.active ?? "url";
|
|
181
|
+
const active = activeType !== "none" ? isActive(item.url, pathname, activeType === "nested-url") : false;
|
|
182
|
+
if (item.type === "secondary" && on === "nav") {
|
|
183
|
+
return /* @__PURE__ */ jsx3(
|
|
184
|
+
Link,
|
|
185
|
+
{
|
|
186
|
+
"aria-label": item.text,
|
|
187
|
+
href: item.url,
|
|
188
|
+
external: item.external,
|
|
189
|
+
className: twMerge(
|
|
190
|
+
buttonVariants({
|
|
191
|
+
size: "icon",
|
|
192
|
+
color: "ghost",
|
|
193
|
+
className
|
|
194
|
+
})
|
|
195
|
+
),
|
|
196
|
+
...props,
|
|
197
|
+
children: item.icon
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
return /* @__PURE__ */ jsxs3(
|
|
202
|
+
Link,
|
|
203
|
+
{
|
|
204
|
+
href: item.url,
|
|
205
|
+
external: item.external,
|
|
206
|
+
className: twMerge(
|
|
207
|
+
linkItemVariants({
|
|
208
|
+
active,
|
|
209
|
+
className
|
|
210
|
+
})
|
|
211
|
+
),
|
|
212
|
+
...props,
|
|
213
|
+
children: [
|
|
214
|
+
on === "menu" ? item.icon : null,
|
|
215
|
+
item.text
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export {
|
|
222
|
+
SearchToggle,
|
|
223
|
+
LargeSearchToggle,
|
|
224
|
+
LinkItem,
|
|
225
|
+
ThemeToggle
|
|
226
|
+
};
|
|
@@ -16,7 +16,7 @@ var PopoverContent = React.forwardRef(({ className, align = "center", sideOffset
|
|
|
16
16
|
sideOffset,
|
|
17
17
|
side: "bottom",
|
|
18
18
|
className: twMerge(
|
|
19
|
-
"z-50 min-w-[
|
|
19
|
+
"z-50 min-w-[240px] max-w-[98vw] rounded-lg border bg-popover p-2 text-sm text-popover-foreground shadow-md outline-none data-[state=closed]:animate-popover-out data-[state=open]:animate-popover-in",
|
|
20
20
|
className
|
|
21
21
|
),
|
|
22
22
|
...props
|
package/dist/components/api.js
CHANGED
|
@@ -93,7 +93,7 @@ function APIExample({
|
|
|
93
93
|
return /* @__PURE__ */ jsxs(
|
|
94
94
|
"div",
|
|
95
95
|
{
|
|
96
|
-
className: twMerge("sticky top-
|
|
96
|
+
className: twMerge("sticky top-6 h-fit xl:w-2/5 xl:min-w-[400px]", className),
|
|
97
97
|
...props,
|
|
98
98
|
children: [
|
|
99
99
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center gap-4 xl:hidden", children: [
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
SearchDialog
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-7EMVRXMS.js";
|
|
5
|
+
import "../../chunk-3F57TIUQ.js";
|
|
5
6
|
import "../../chunk-FSPYEOFC.js";
|
|
6
|
-
import "../../chunk-
|
|
7
|
+
import "../../chunk-CRYPD6UZ.js";
|
|
7
8
|
import "../../chunk-7GZKFBAP.js";
|
|
8
9
|
import "../../chunk-TK3TM3MR.js";
|
|
9
10
|
import "../../chunk-MLKGABMK.js";
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
SearchDialog
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-7EMVRXMS.js";
|
|
5
|
+
import "../../chunk-3F57TIUQ.js";
|
|
5
6
|
import "../../chunk-FSPYEOFC.js";
|
|
6
7
|
import {
|
|
7
8
|
useI18n
|
|
8
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-CRYPD6UZ.js";
|
|
9
10
|
import "../../chunk-7GZKFBAP.js";
|
|
10
11
|
import "../../chunk-TK3TM3MR.js";
|
|
11
12
|
import "../../chunk-MLKGABMK.js";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SearchDialog
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-7EMVRXMS.js";
|
|
4
|
+
import "../../chunk-3F57TIUQ.js";
|
|
4
5
|
import "../../chunk-FSPYEOFC.js";
|
|
5
|
-
import "../../chunk-
|
|
6
|
+
import "../../chunk-CRYPD6UZ.js";
|
|
6
7
|
import "../../chunk-7GZKFBAP.js";
|
|
7
8
|
import "../../chunk-TK3TM3MR.js";
|
|
8
9
|
import "../../chunk-MLKGABMK.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PopoverProps } from '@radix-ui/react-popover';
|
|
2
|
+
|
|
3
|
+
type LanguageSelectProps = Omit<PopoverProps, 'open' | 'onOpenChange'>;
|
|
4
|
+
declare function LanguageToggle(props: LanguageSelectProps): React.ReactElement;
|
|
5
|
+
|
|
6
|
+
export { type LanguageSelectProps, LanguageToggle };
|
|
@@ -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
|
+
};
|
|
@@ -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 };
|