fumadocs-ui 12.4.2 → 12.5.1
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-NZA3MCPM.js → chunk-4NMHXJDQ.js} +67 -145
- package/dist/chunk-FMI5QZTV.js +21 -0
- package/dist/{chunk-BZ53GHJX.js → chunk-INUQLSIT.js} +66 -18
- package/dist/{docs.client.js → chunk-IY5T63PK.js} +20 -179
- package/dist/{chunk-KH555T4I.js → chunk-QQAMPLSA.js} +1 -1
- package/dist/{chunk-NUPTR2L5.js → chunk-QZBW7643.js} +6 -10
- package/dist/chunk-UDMQQ2YW.js +90 -0
- package/dist/chunk-V7IGWU5C.js +13 -0
- package/dist/{chunk-6JD7NGHG.js → chunk-YKLVLKDA.js} +4 -6
- package/dist/{chunk-VUIQ7ZYI.js → chunk-YSCK5YFO.js} +1 -0
- package/dist/{chunk-3F57TIUQ.js → chunk-YXSAWF3G.js} +9 -6
- package/dist/components/accordion.js +2 -2
- package/dist/components/api.d.ts +16 -2
- package/dist/components/api.js +19 -6
- package/dist/components/banner.js +1 -1
- package/dist/components/codeblock.js +2 -2
- package/dist/components/dialog/search-algolia.d.ts +10 -2
- package/dist/components/dialog/search-algolia.js +41 -7
- package/dist/components/dialog/search-default.d.ts +6 -2
- package/dist/components/dialog/search-default.js +21 -7
- package/dist/components/dialog/search.d.ts +16 -5
- package/dist/components/dialog/search.js +8 -5
- package/dist/components/files.d.ts +1 -0
- package/dist/components/layout/language-toggle.js +1 -1
- package/dist/components/layout/root-toggle.js +11 -4
- package/dist/components/roll-button.js +1 -1
- package/dist/components/tabs.d.ts +3 -5
- package/dist/components/tabs.js +1 -1
- package/dist/{docs.client.d.ts → docs-layout.client.d.ts} +4 -5
- package/dist/docs-layout.client.js +83 -0
- package/dist/dynamic-sidebar-YIDNYTMX.js +123 -0
- package/dist/{layout.client.d.ts → home-layout.client.d.ts} +1 -2
- package/dist/{layout.client.js → home-layout.client.js} +10 -7
- package/dist/home-layout.d.ts +7 -0
- package/dist/home-layout.js +29 -0
- package/dist/layout.d.ts +29 -3
- package/dist/layout.js +17 -22
- package/dist/{layout-ZAteQVYk.d.ts → layout.shared-GQuo9xqE.d.ts} +12 -65
- package/dist/mdx.client.js +2 -2
- package/dist/page.client.js +17 -9
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +5 -4
- package/dist/sidebar-C7MbvaPk.d.ts +39 -0
- package/dist/style.css +1 -1
- package/package.json +15 -7
|
@@ -1,50 +1,35 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
import {
|
|
3
2
|
LargeSearchToggle,
|
|
4
|
-
LinkItem
|
|
5
|
-
|
|
6
|
-
NavBox,
|
|
7
|
-
SearchToggle,
|
|
8
|
-
ThemeToggle,
|
|
9
|
-
Title
|
|
10
|
-
} from "./chunk-NZA3MCPM.js";
|
|
3
|
+
LinkItem
|
|
4
|
+
} from "./chunk-4NMHXJDQ.js";
|
|
11
5
|
import {
|
|
12
6
|
ScrollArea,
|
|
13
7
|
ScrollViewport
|
|
14
8
|
} from "./chunk-VYTHQTZE.js";
|
|
15
|
-
import "./chunk-GHKJ6EFT.js";
|
|
16
9
|
import {
|
|
17
|
-
TreeContextProvider,
|
|
18
10
|
useTreeContext
|
|
19
11
|
} from "./chunk-R3M2OC5U.js";
|
|
20
12
|
import {
|
|
21
13
|
hasActive,
|
|
22
14
|
isActive
|
|
23
15
|
} from "./chunk-IIDV3RNQ.js";
|
|
24
|
-
import {
|
|
25
|
-
useSidebar
|
|
26
|
-
} from "./chunk-3F57TIUQ.js";
|
|
27
16
|
import {
|
|
28
17
|
useSearchContext
|
|
29
18
|
} from "./chunk-ET4TW6M5.js";
|
|
30
|
-
import
|
|
19
|
+
import {
|
|
20
|
+
useOnChange
|
|
21
|
+
} from "./chunk-V7IGWU5C.js";
|
|
31
22
|
import {
|
|
32
23
|
Collapsible,
|
|
33
24
|
CollapsibleContent,
|
|
34
25
|
CollapsibleTrigger
|
|
35
26
|
} from "./chunk-7XPZOMJ2.js";
|
|
36
27
|
import {
|
|
37
|
-
buttonVariants,
|
|
38
28
|
itemVariants
|
|
39
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-YSCK5YFO.js";
|
|
40
30
|
import {
|
|
41
31
|
twMerge
|
|
42
32
|
} from "./chunk-TK3TM3MR.js";
|
|
43
|
-
import "./chunk-MLKGABMK.js";
|
|
44
|
-
|
|
45
|
-
// src/docs.client.tsx
|
|
46
|
-
import { SidebarTrigger } from "fumadocs-core/sidebar";
|
|
47
|
-
import { Menu, X } from "lucide-react";
|
|
48
33
|
|
|
49
34
|
// src/components/layout/sidebar.tsx
|
|
50
35
|
import { ChevronDown, ExternalLinkIcon } from "lucide-react";
|
|
@@ -54,7 +39,6 @@ import {
|
|
|
54
39
|
createContext,
|
|
55
40
|
useCallback,
|
|
56
41
|
useContext,
|
|
57
|
-
useEffect,
|
|
58
42
|
useMemo,
|
|
59
43
|
useState
|
|
60
44
|
} from "react";
|
|
@@ -168,7 +152,6 @@ function PageNode({
|
|
|
168
152
|
item: { icon, external = false, url, name }
|
|
169
153
|
}) {
|
|
170
154
|
const pathname = usePathname();
|
|
171
|
-
const { closeOnRedirect } = useSidebar();
|
|
172
155
|
const active = isActive(url, pathname, false);
|
|
173
156
|
return /* @__PURE__ */ jsxs(
|
|
174
157
|
Link,
|
|
@@ -176,9 +159,6 @@ function PageNode({
|
|
|
176
159
|
href: url,
|
|
177
160
|
external,
|
|
178
161
|
className: twMerge(itemVariants({ active })),
|
|
179
|
-
onClick: useCallback(() => {
|
|
180
|
-
closeOnRedirect.current = !active;
|
|
181
|
-
}, [closeOnRedirect, active]),
|
|
182
162
|
children: [
|
|
183
163
|
icon ?? (external ? /* @__PURE__ */ jsx(ExternalLinkIcon, {}) : null),
|
|
184
164
|
name
|
|
@@ -191,7 +171,6 @@ function FolderNode({
|
|
|
191
171
|
level
|
|
192
172
|
}) {
|
|
193
173
|
const { defaultOpenLevel } = useContext(Context);
|
|
194
|
-
const { closeOnRedirect } = useSidebar();
|
|
195
174
|
const pathname = usePathname();
|
|
196
175
|
const active = index !== void 0 && isActive(index.url, pathname, false);
|
|
197
176
|
const childActive = useMemo(
|
|
@@ -199,20 +178,21 @@ function FolderNode({
|
|
|
199
178
|
[children, pathname]
|
|
200
179
|
);
|
|
201
180
|
const shouldExtend = active || childActive || defaultOpenLevel >= level || defaultOpen;
|
|
202
|
-
const [
|
|
203
|
-
|
|
204
|
-
if (
|
|
205
|
-
}
|
|
181
|
+
const [open, setOpen] = useState(shouldExtend);
|
|
182
|
+
useOnChange(shouldExtend, (v) => {
|
|
183
|
+
if (v) setOpen(v);
|
|
184
|
+
});
|
|
206
185
|
const onClick = useCallback(
|
|
207
186
|
(e) => {
|
|
208
|
-
if (
|
|
209
|
-
|
|
187
|
+
if (
|
|
188
|
+
// clicking on icon
|
|
189
|
+
e.target.hasAttribute("data-icon") || active
|
|
190
|
+
) {
|
|
191
|
+
setOpen((prev) => !prev);
|
|
210
192
|
e.preventDefault();
|
|
211
|
-
} else {
|
|
212
|
-
closeOnRedirect.current = !active;
|
|
213
193
|
}
|
|
214
194
|
},
|
|
215
|
-
[
|
|
195
|
+
[active]
|
|
216
196
|
);
|
|
217
197
|
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
218
198
|
icon,
|
|
@@ -220,11 +200,12 @@ function FolderNode({
|
|
|
220
200
|
/* @__PURE__ */ jsx(
|
|
221
201
|
ChevronDown,
|
|
222
202
|
{
|
|
223
|
-
|
|
203
|
+
"data-icon": true,
|
|
204
|
+
className: twMerge("ms-auto transition-transform", !open && "-rotate-90")
|
|
224
205
|
}
|
|
225
206
|
)
|
|
226
207
|
] });
|
|
227
|
-
return /* @__PURE__ */ jsxs(Collapsible, { open
|
|
208
|
+
return /* @__PURE__ */ jsxs(Collapsible, { open, onOpenChange: setOpen, children: [
|
|
228
209
|
index ? /* @__PURE__ */ jsx(
|
|
229
210
|
Link,
|
|
230
211
|
{
|
|
@@ -250,146 +231,6 @@ function SeparatorNode({
|
|
|
250
231
|
return /* @__PURE__ */ jsx("p", { className: "mb-2 mt-8 px-2 font-medium first:mt-0", children: item.name });
|
|
251
232
|
}
|
|
252
233
|
|
|
253
|
-
// src/components/layout/dynamic-sidebar.tsx
|
|
254
|
-
import { useCallback as useCallback2, useRef, useState as useState2 } from "react";
|
|
255
|
-
import { SidebarIcon } from "lucide-react";
|
|
256
|
-
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
257
|
-
function DynamicSidebar(props) {
|
|
258
|
-
const { collapsed, setCollapsed } = useSidebar();
|
|
259
|
-
const [hover, setHover] = useState2(false);
|
|
260
|
-
const timerRef = useRef(0);
|
|
261
|
-
const closeTimeRef = useRef(0);
|
|
262
|
-
const onCollapse = useCallback2(() => {
|
|
263
|
-
setCollapsed((v) => !v);
|
|
264
|
-
setHover(false);
|
|
265
|
-
closeTimeRef.current = Date.now() + 150;
|
|
266
|
-
}, [setCollapsed]);
|
|
267
|
-
const onEnter = useCallback2((e) => {
|
|
268
|
-
if (e.pointerType === "touch" || closeTimeRef.current > Date.now()) return;
|
|
269
|
-
window.clearTimeout(timerRef.current);
|
|
270
|
-
setHover(true);
|
|
271
|
-
}, []);
|
|
272
|
-
const onLeave = useCallback2((e) => {
|
|
273
|
-
if (e.pointerType === "touch") return;
|
|
274
|
-
window.clearTimeout(timerRef.current);
|
|
275
|
-
timerRef.current = window.setTimeout(
|
|
276
|
-
() => {
|
|
277
|
-
setHover(false);
|
|
278
|
-
closeTimeRef.current = Date.now() + 150;
|
|
279
|
-
},
|
|
280
|
-
Math.min(e.clientX, document.body.clientWidth - e.clientX) > 100 ? 0 : 500
|
|
281
|
-
);
|
|
282
|
-
}, []);
|
|
283
|
-
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
284
|
-
collapsed ? /* @__PURE__ */ jsx2(
|
|
285
|
-
"div",
|
|
286
|
-
{
|
|
287
|
-
className: "fixed inset-y-0 start-0 w-6 max-md:hidden xl:w-[50px]",
|
|
288
|
-
onPointerEnter: onEnter,
|
|
289
|
-
onPointerLeave: onLeave
|
|
290
|
-
}
|
|
291
|
-
) : null,
|
|
292
|
-
collapsed ? /* @__PURE__ */ jsx2(
|
|
293
|
-
"button",
|
|
294
|
-
{
|
|
295
|
-
type: "button",
|
|
296
|
-
"aria-label": "Collapse Sidebar",
|
|
297
|
-
className: twMerge(
|
|
298
|
-
buttonVariants({
|
|
299
|
-
color: "secondary",
|
|
300
|
-
size: "icon",
|
|
301
|
-
className: "fixed start-4 bottom-2 z-10 max-md:hidden"
|
|
302
|
-
})
|
|
303
|
-
),
|
|
304
|
-
onClick: onCollapse,
|
|
305
|
-
children: /* @__PURE__ */ jsx2(SidebarIcon, {})
|
|
306
|
-
}
|
|
307
|
-
) : null,
|
|
308
|
-
/* @__PURE__ */ jsx2(
|
|
309
|
-
Sidebar,
|
|
310
|
-
{
|
|
311
|
-
...props,
|
|
312
|
-
aside: {
|
|
313
|
-
"data-collapse": collapsed,
|
|
314
|
-
"data-hover": hover,
|
|
315
|
-
onPointerEnter: onEnter,
|
|
316
|
-
onPointerLeave: onLeave,
|
|
317
|
-
"aria-hidden": Boolean(collapsed && !hover),
|
|
318
|
-
className: twMerge(
|
|
319
|
-
"md:transition-[transform,margin]",
|
|
320
|
-
collapsed && [
|
|
321
|
-
"md:top-1 md:mr-[-240px] md:h-[calc(100dvh-4px)] md:animate-sidebar-collapse md:rounded-xl md:border md:shadow-md xl:mr-[-260px]",
|
|
322
|
-
hover ? "md:translate-x-1 rtl:md:-translate-x-1" : "md:-translate-x-full rtl:md:translate-x-full"
|
|
323
|
-
]
|
|
324
|
-
)
|
|
325
|
-
},
|
|
326
|
-
footer: /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
327
|
-
props.footer,
|
|
328
|
-
/* @__PURE__ */ jsx2(
|
|
329
|
-
"button",
|
|
330
|
-
{
|
|
331
|
-
type: "button",
|
|
332
|
-
"aria-label": "Collapse Sidebar",
|
|
333
|
-
className: twMerge(
|
|
334
|
-
buttonVariants({
|
|
335
|
-
color: "ghost",
|
|
336
|
-
size: "icon",
|
|
337
|
-
className: "max-md:hidden"
|
|
338
|
-
})
|
|
339
|
-
),
|
|
340
|
-
onClick: onCollapse,
|
|
341
|
-
children: /* @__PURE__ */ jsx2(SidebarIcon, {})
|
|
342
|
-
}
|
|
343
|
-
)
|
|
344
|
-
] })
|
|
345
|
-
}
|
|
346
|
-
)
|
|
347
|
-
] });
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
// src/docs.client.tsx
|
|
351
|
-
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
352
|
-
function SubNav({
|
|
353
|
-
title,
|
|
354
|
-
url,
|
|
355
|
-
transparentMode,
|
|
356
|
-
children,
|
|
357
|
-
enableSearch = true
|
|
358
|
-
}) {
|
|
359
|
-
const { open } = useSidebar();
|
|
360
|
-
const { enabled } = useSearchContext();
|
|
361
|
-
return /* @__PURE__ */ jsxs3(
|
|
362
|
-
NavBox,
|
|
363
|
-
{
|
|
364
|
-
id: "nd-subnav",
|
|
365
|
-
className: "flex h-14 flex-row items-center px-4 md:hidden",
|
|
366
|
-
transparentMode,
|
|
367
|
-
children: [
|
|
368
|
-
/* @__PURE__ */ jsx3(Title, { url, title }),
|
|
369
|
-
/* @__PURE__ */ jsx3("div", { className: "flex flex-1 flex-row items-center", children }),
|
|
370
|
-
enabled && enableSearch ? /* @__PURE__ */ jsx3(SearchToggle, {}) : null,
|
|
371
|
-
/* @__PURE__ */ jsx3(
|
|
372
|
-
SidebarTrigger,
|
|
373
|
-
{
|
|
374
|
-
className: twMerge(
|
|
375
|
-
buttonVariants({
|
|
376
|
-
color: "ghost",
|
|
377
|
-
size: "icon",
|
|
378
|
-
className: "-me-2"
|
|
379
|
-
})
|
|
380
|
-
),
|
|
381
|
-
children: open ? /* @__PURE__ */ jsx3(X, {}) : /* @__PURE__ */ jsx3(Menu, {})
|
|
382
|
-
}
|
|
383
|
-
)
|
|
384
|
-
]
|
|
385
|
-
}
|
|
386
|
-
);
|
|
387
|
-
}
|
|
388
234
|
export {
|
|
389
|
-
|
|
390
|
-
LinksMenu,
|
|
391
|
-
Sidebar,
|
|
392
|
-
SubNav,
|
|
393
|
-
ThemeToggle,
|
|
394
|
-
TreeContextProvider
|
|
235
|
+
Sidebar
|
|
395
236
|
};
|
|
@@ -6,12 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-MLKGABMK.js";
|
|
7
7
|
|
|
8
8
|
// src/components/tabs.tsx
|
|
9
|
-
import {
|
|
10
|
-
useEffect,
|
|
11
|
-
useMemo,
|
|
12
|
-
useState,
|
|
13
|
-
useCallback
|
|
14
|
-
} from "react";
|
|
9
|
+
import { useMemo, useState, useCallback, useLayoutEffect } from "react";
|
|
15
10
|
|
|
16
11
|
// src/components/ui/tabs.tsx
|
|
17
12
|
var tabs_exports = {};
|
|
@@ -99,11 +94,11 @@ function Tabs2({
|
|
|
99
94
|
items = [],
|
|
100
95
|
persist = false,
|
|
101
96
|
defaultIndex = 0,
|
|
102
|
-
|
|
97
|
+
...props
|
|
103
98
|
}) {
|
|
104
99
|
const values = useMemo(() => items.map((item) => toValue(item)), [items]);
|
|
105
100
|
const [value, setValue] = useState(values[defaultIndex]);
|
|
106
|
-
|
|
101
|
+
useLayoutEffect(() => {
|
|
107
102
|
if (!id) return;
|
|
108
103
|
const onUpdate = (v) => {
|
|
109
104
|
if (values.includes(v)) setValue(v);
|
|
@@ -130,10 +125,11 @@ function Tabs2({
|
|
|
130
125
|
{
|
|
131
126
|
value,
|
|
132
127
|
onValueChange,
|
|
133
|
-
|
|
128
|
+
...props,
|
|
129
|
+
className: twMerge("my-4", props.className),
|
|
134
130
|
children: [
|
|
135
131
|
/* @__PURE__ */ jsx2(TabsList, { children: values.map((v, i) => /* @__PURE__ */ jsx2(TabsTrigger, { value: v, children: items[i] }, v)) }),
|
|
136
|
-
children
|
|
132
|
+
props.children
|
|
137
133
|
]
|
|
138
134
|
}
|
|
139
135
|
);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
twMerge
|
|
3
|
+
} from "./chunk-TK3TM3MR.js";
|
|
4
|
+
|
|
5
|
+
// src/components/layout/nav.tsx
|
|
6
|
+
import Link from "fumadocs-core/link";
|
|
7
|
+
import {
|
|
8
|
+
useEffect,
|
|
9
|
+
useState
|
|
10
|
+
} from "react";
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
function NavBox({
|
|
13
|
+
transparentMode = "none",
|
|
14
|
+
...props
|
|
15
|
+
}) {
|
|
16
|
+
const [transparent, setTransparent] = useState(transparentMode !== "none");
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (transparentMode !== "top") return;
|
|
19
|
+
const listener = () => {
|
|
20
|
+
setTransparent(window.scrollY < 10);
|
|
21
|
+
};
|
|
22
|
+
listener();
|
|
23
|
+
window.addEventListener("scroll", listener);
|
|
24
|
+
return () => {
|
|
25
|
+
window.removeEventListener("scroll", listener);
|
|
26
|
+
};
|
|
27
|
+
}, [transparentMode]);
|
|
28
|
+
return /* @__PURE__ */ jsx(
|
|
29
|
+
"header",
|
|
30
|
+
{
|
|
31
|
+
...props,
|
|
32
|
+
className: twMerge(
|
|
33
|
+
"sticky top-0 z-50 border-b transition-colors",
|
|
34
|
+
transparent ? "border-transparent" : "border-foreground/10 bg-background/60 backdrop-blur-md",
|
|
35
|
+
props.className
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
function Title({ title, url = "/" }) {
|
|
41
|
+
return /* @__PURE__ */ jsx(Link, { href: url, className: "inline-flex items-center gap-2.5 font-semibold", children: title });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/components/layout/theme-toggle.tsx
|
|
45
|
+
import { cva } from "class-variance-authority";
|
|
46
|
+
import { Moon, Sun } from "lucide-react";
|
|
47
|
+
import { useTheme } from "next-themes";
|
|
48
|
+
import { useCallback } from "react";
|
|
49
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
50
|
+
var buttonVariants = cva("size-7 rounded-full p-1.5 text-muted-foreground", {
|
|
51
|
+
variants: {
|
|
52
|
+
dark: {
|
|
53
|
+
true: "dark:bg-accent dark:text-accent-foreground",
|
|
54
|
+
false: "bg-accent text-accent-foreground dark:bg-transparent dark:text-muted-foreground"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
function ThemeToggle({
|
|
59
|
+
className,
|
|
60
|
+
...props
|
|
61
|
+
}) {
|
|
62
|
+
const { setTheme, resolvedTheme } = useTheme();
|
|
63
|
+
const onToggle = useCallback(() => {
|
|
64
|
+
setTheme(resolvedTheme === "dark" ? "light" : "dark");
|
|
65
|
+
}, [setTheme, resolvedTheme]);
|
|
66
|
+
return /* @__PURE__ */ jsxs(
|
|
67
|
+
"button",
|
|
68
|
+
{
|
|
69
|
+
type: "button",
|
|
70
|
+
className: twMerge(
|
|
71
|
+
"inline-flex items-center rounded-full border p-0.5",
|
|
72
|
+
className
|
|
73
|
+
),
|
|
74
|
+
"data-theme-toggle": "",
|
|
75
|
+
"aria-label": "Toggle Theme",
|
|
76
|
+
onClick: onToggle,
|
|
77
|
+
...props,
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsx2(Sun, { className: twMerge(buttonVariants({ dark: false })) }),
|
|
80
|
+
/* @__PURE__ */ jsx2(Moon, { className: twMerge(buttonVariants({ dark: true })) })
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
NavBox,
|
|
88
|
+
Title,
|
|
89
|
+
ThemeToggle
|
|
90
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/utils/use-on-change.ts
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
function useOnChange(value, onChange) {
|
|
4
|
+
const [prev, setPrev] = useState(value);
|
|
5
|
+
if (prev !== value) {
|
|
6
|
+
onChange(value, prev);
|
|
7
|
+
setPrev(value);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
useOnChange
|
|
13
|
+
};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-2KMKNVSN.js";
|
|
4
4
|
import {
|
|
5
5
|
buttonVariants
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YSCK5YFO.js";
|
|
7
7
|
import {
|
|
8
8
|
twMerge
|
|
9
9
|
} from "./chunk-TK3TM3MR.js";
|
|
@@ -24,10 +24,8 @@ var Accordions = forwardRef(({ type = "single", className, defaultValue, ...prop
|
|
|
24
24
|
useEffect(() => {
|
|
25
25
|
const id = window.location.hash.substring(1);
|
|
26
26
|
if (id.length > 0)
|
|
27
|
-
setValue((prev) =>
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
}, [type]);
|
|
27
|
+
setValue((prev) => typeof prev === "string" ? id : [id, ...prev]);
|
|
28
|
+
}, []);
|
|
31
29
|
return (
|
|
32
30
|
// @ts-expect-error -- Multiple types
|
|
33
31
|
/* @__PURE__ */ jsx(
|
|
@@ -37,7 +35,7 @@ var Accordions = forwardRef(({ type = "single", className, defaultValue, ...prop
|
|
|
37
35
|
ref,
|
|
38
36
|
value,
|
|
39
37
|
onValueChange: setValue,
|
|
40
|
-
collapsible: true,
|
|
38
|
+
collapsible: type === "single" ? true : void 0,
|
|
41
39
|
className: twMerge(
|
|
42
40
|
"divide-y divide-border overflow-hidden rounded-lg border bg-card",
|
|
43
41
|
className
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useOnChange
|
|
3
|
+
} from "./chunk-V7IGWU5C.js";
|
|
4
|
+
|
|
1
5
|
// src/contexts/sidebar.tsx
|
|
2
6
|
import {
|
|
3
7
|
createContext,
|
|
4
8
|
useContext,
|
|
5
9
|
useState,
|
|
6
10
|
useMemo,
|
|
7
|
-
useRef
|
|
8
|
-
useEffect
|
|
11
|
+
useRef
|
|
9
12
|
} from "react";
|
|
10
13
|
import { usePathname } from "next/navigation";
|
|
11
14
|
import { SidebarProvider as BaseProvider } from "fumadocs-core/sidebar";
|
|
@@ -19,16 +22,16 @@ function useSidebar() {
|
|
|
19
22
|
function SidebarProvider({
|
|
20
23
|
children
|
|
21
24
|
}) {
|
|
22
|
-
const closeOnRedirect = useRef(
|
|
25
|
+
const closeOnRedirect = useRef(true);
|
|
23
26
|
const [open, setOpen] = useState(false);
|
|
24
27
|
const [collapsed, setCollapsed] = useState(false);
|
|
25
28
|
const pathname = usePathname();
|
|
26
|
-
|
|
29
|
+
useOnChange(pathname, () => {
|
|
27
30
|
if (closeOnRedirect.current) {
|
|
28
31
|
setOpen(false);
|
|
29
|
-
closeOnRedirect.current = false;
|
|
30
32
|
}
|
|
31
|
-
|
|
33
|
+
closeOnRedirect.current = true;
|
|
34
|
+
});
|
|
32
35
|
return /* @__PURE__ */ jsx(
|
|
33
36
|
SidebarContext.Provider,
|
|
34
37
|
{
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
Accordion,
|
|
4
4
|
Accordions
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-YKLVLKDA.js";
|
|
6
6
|
import "../chunk-2KMKNVSN.js";
|
|
7
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-YSCK5YFO.js";
|
|
8
8
|
import "../chunk-TK3TM3MR.js";
|
|
9
9
|
import "../chunk-MLKGABMK.js";
|
|
10
10
|
export {
|
package/dist/components/api.d.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
import { HTMLAttributes, ReactNode } from 'react';
|
|
1
|
+
import { MouseEventHandler, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export { twMerge as cn } from 'tailwind-merge';
|
|
3
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
4
|
import { Tabs, Tab } from './tabs.js';
|
|
3
5
|
import '@radix-ui/react-tabs';
|
|
4
6
|
|
|
7
|
+
declare function useOnChange<T>(value: T, onChange: (current: T, previous: T) => void): void;
|
|
8
|
+
|
|
9
|
+
declare function useCopyButton(onCopy: () => void): [checked: boolean, onClick: MouseEventHandler];
|
|
10
|
+
|
|
11
|
+
declare const buttonVariants: (props?: ({
|
|
12
|
+
color?: "outline" | "ghost" | "secondary" | null | undefined;
|
|
13
|
+
size?: "sm" | "icon" | null | undefined;
|
|
14
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
15
|
+
declare const itemVariants: (props?: ({
|
|
16
|
+
active?: boolean | null | undefined;
|
|
17
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
18
|
+
|
|
5
19
|
declare function Root({ children, className, ...props }: HTMLAttributes<HTMLDivElement>): React.ReactElement;
|
|
6
20
|
declare function API({ className, children, ...props }: HTMLAttributes<HTMLDivElement>): React.ReactElement;
|
|
7
21
|
interface APIInfoProps extends HTMLAttributes<HTMLDivElement> {
|
|
@@ -36,4 +50,4 @@ declare function ObjectCollapsible(props: {
|
|
|
36
50
|
children: ReactNode;
|
|
37
51
|
}): React.ReactElement;
|
|
38
52
|
|
|
39
|
-
export { API, APIExample, APIInfo, type APIInfoProps, ExampleResponse, ObjectCollapsible, Property, Request, Requests, Response, ResponseTypes, Responses, Root, TypeScriptResponse };
|
|
53
|
+
export { API, APIExample, APIInfo, type APIInfoProps, ExampleResponse, ObjectCollapsible, Property, Request, Requests, Response, ResponseTypes, Responses, Root, TypeScriptResponse, buttonVariants, itemVariants, useCopyButton, useOnChange };
|
package/dist/components/api.js
CHANGED
|
@@ -2,19 +2,27 @@
|
|
|
2
2
|
import {
|
|
3
3
|
Accordion,
|
|
4
4
|
Accordions
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import
|
|
5
|
+
} from "../chunk-YKLVLKDA.js";
|
|
6
|
+
import {
|
|
7
|
+
useCopyButton
|
|
8
|
+
} from "../chunk-2KMKNVSN.js";
|
|
9
|
+
import {
|
|
10
|
+
useOnChange
|
|
11
|
+
} from "../chunk-V7IGWU5C.js";
|
|
7
12
|
import {
|
|
8
13
|
Tab,
|
|
9
14
|
Tabs
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import
|
|
15
|
+
} from "../chunk-QZBW7643.js";
|
|
16
|
+
import {
|
|
17
|
+
buttonVariants,
|
|
18
|
+
itemVariants
|
|
19
|
+
} from "../chunk-YSCK5YFO.js";
|
|
12
20
|
import {
|
|
13
21
|
twMerge
|
|
14
22
|
} from "../chunk-TK3TM3MR.js";
|
|
15
23
|
import "../chunk-MLKGABMK.js";
|
|
16
24
|
|
|
17
|
-
// src/components/api.tsx
|
|
25
|
+
// src/components/api-legacy.tsx
|
|
18
26
|
import { cva } from "class-variance-authority";
|
|
19
27
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
28
|
function Root({
|
|
@@ -154,5 +162,10 @@ export {
|
|
|
154
162
|
ResponseTypes,
|
|
155
163
|
Responses,
|
|
156
164
|
Root,
|
|
157
|
-
TypeScriptResponse
|
|
165
|
+
TypeScriptResponse,
|
|
166
|
+
buttonVariants,
|
|
167
|
+
twMerge as cn,
|
|
168
|
+
itemVariants,
|
|
169
|
+
useCopyButton,
|
|
170
|
+
useOnChange
|
|
158
171
|
};
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
CodeBlock,
|
|
4
4
|
Pre
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-QQAMPLSA.js";
|
|
6
6
|
import "../chunk-VYTHQTZE.js";
|
|
7
7
|
import "../chunk-2KMKNVSN.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-YSCK5YFO.js";
|
|
9
9
|
import "../chunk-TK3TM3MR.js";
|
|
10
10
|
import "../chunk-MLKGABMK.js";
|
|
11
11
|
export {
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { SearchIndex } from 'algoliasearch/lite';
|
|
2
2
|
import { Options } from 'fumadocs-core/search-algolia/client';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { SharedProps } from './search.js';
|
|
4
|
+
import { SharedProps, TagItem } from './search.js';
|
|
5
5
|
import 'fumadocs-core/search/shared';
|
|
6
6
|
|
|
7
7
|
interface AlgoliaSearchDialogProps extends SharedProps {
|
|
8
8
|
index: SearchIndex;
|
|
9
9
|
searchOptions?: Options;
|
|
10
10
|
footer?: ReactNode;
|
|
11
|
+
defaultTag?: string;
|
|
12
|
+
tags?: TagItem[];
|
|
13
|
+
/**
|
|
14
|
+
* Add the "Powered by Algolia" label, this is useful for free tier users
|
|
15
|
+
*
|
|
16
|
+
* @defaultValue false
|
|
17
|
+
*/
|
|
18
|
+
showAlgolia?: boolean;
|
|
11
19
|
}
|
|
12
|
-
declare function AlgoliaSearchDialog({ index, searchOptions, ...props }: AlgoliaSearchDialogProps): React.ReactElement;
|
|
20
|
+
declare function AlgoliaSearchDialog({ index, searchOptions, tags, defaultTag, showAlgolia, ...props }: AlgoliaSearchDialogProps): React.ReactElement;
|
|
13
21
|
|
|
14
22
|
export { type AlgoliaSearchDialogProps, AlgoliaSearchDialog as default };
|