fumadocs-ui 12.1.1 → 12.1.3
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-45QF3XKA.js → chunk-BHP6OUWK.js} +1 -1
- package/dist/{chunk-YJDZJ4BG.js → chunk-IOZPSMRL.js} +68 -22
- package/dist/chunk-MXPAPA74.js +106 -0
- package/dist/chunk-NUPTR2L5.js +166 -0
- package/dist/components/accordion.js +6 -100
- package/dist/components/api.d.ts +19 -1
- package/dist/components/api.js +44 -29
- package/dist/components/dialog/search-algolia.js +2 -2
- package/dist/components/dialog/search-default.js +2 -2
- package/dist/components/dialog/search.js +2 -2
- package/dist/components/tabs.js +7 -157
- package/dist/docs.client.d.ts +3 -3
- package/dist/docs.client.js +18 -13
- package/dist/{layout.client-BzAmSQXB.d.ts → layout-DAwDgfTa.d.ts} +20 -19
- package/dist/layout.client.d.ts +8 -2
- package/dist/layout.client.js +42 -73
- package/dist/layout.d.ts +1 -1
- package/dist/layout.js +1 -1
- package/dist/page.client.d.ts +2 -2
- package/dist/page.client.js +14 -4
- package/dist/page.d.ts +7 -1
- package/dist/page.js +12 -5
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/dist/{chunk-FSPYEOFC.js → chunk-ET4TW6M5.js} +4 -4
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "./chunk-AN2Y6MA2.js";
|
|
9
9
|
import {
|
|
10
10
|
useSearchContext
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ET4TW6M5.js";
|
|
12
12
|
import {
|
|
13
13
|
useI18n
|
|
14
14
|
} from "./chunk-HLGNIWUN.js";
|
|
@@ -67,22 +67,64 @@ function LargeSearchToggle(props) {
|
|
|
67
67
|
children: [
|
|
68
68
|
/* @__PURE__ */ jsx(SearchIcon, { className: "ms-1 size-4" }),
|
|
69
69
|
text.search,
|
|
70
|
-
/* @__PURE__ */ jsx("div", { className: "ms-auto inline-flex gap-0.5
|
|
70
|
+
/* @__PURE__ */ jsx("div", { className: "ms-auto inline-flex gap-0.5", children: hotKey.map((k, i) => /* @__PURE__ */ jsx("kbd", { className: "rounded-md border bg-background px-1.5", children: k.display }, i)) })
|
|
71
71
|
]
|
|
72
72
|
}
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
// src/components/layout/
|
|
77
|
-
import
|
|
78
|
-
import {
|
|
76
|
+
// src/components/layout/nav.tsx
|
|
77
|
+
import Link from "fumadocs-core/link";
|
|
78
|
+
import {
|
|
79
|
+
useEffect,
|
|
80
|
+
useState
|
|
81
|
+
} from "react";
|
|
82
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
83
|
+
function NavBox({
|
|
84
|
+
transparentMode = "none",
|
|
85
|
+
...props
|
|
86
|
+
}) {
|
|
87
|
+
const [transparent, setTransparent] = useState(transparentMode !== "none");
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (transparentMode !== "top") return;
|
|
90
|
+
const listener = () => {
|
|
91
|
+
setTransparent(window.scrollY < 10);
|
|
92
|
+
};
|
|
93
|
+
listener();
|
|
94
|
+
window.addEventListener("scroll", listener);
|
|
95
|
+
return () => {
|
|
96
|
+
window.removeEventListener("scroll", listener);
|
|
97
|
+
};
|
|
98
|
+
}, [transparentMode]);
|
|
99
|
+
return /* @__PURE__ */ jsx2(
|
|
100
|
+
"header",
|
|
101
|
+
{
|
|
102
|
+
...props,
|
|
103
|
+
className: twMerge(
|
|
104
|
+
"sticky top-0 z-50 h-16 border-b transition-colors",
|
|
105
|
+
transparent ? "border-transparent" : "border-foreground/10 bg-background/80 backdrop-blur-md",
|
|
106
|
+
props.className
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
function Title({ title, url = "/" }) {
|
|
112
|
+
return /* @__PURE__ */ jsx2(
|
|
113
|
+
Link,
|
|
114
|
+
{
|
|
115
|
+
href: url,
|
|
116
|
+
className: "inline-flex items-center gap-2.5 font-semibold [&_svg]:size-5",
|
|
117
|
+
children: title
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
}
|
|
79
121
|
|
|
80
122
|
// src/components/layout/link-item.tsx
|
|
81
|
-
import
|
|
123
|
+
import Link2 from "fumadocs-core/link";
|
|
82
124
|
import { ChevronDown } from "lucide-react";
|
|
83
125
|
import { usePathname } from "next/navigation";
|
|
84
126
|
import { cva } from "class-variance-authority";
|
|
85
|
-
import { jsx as
|
|
127
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
86
128
|
var linkItemVariants = cva(
|
|
87
129
|
"inline-flex items-center gap-1.5 rounded-lg p-2 text-muted-foreground transition-colors data-[state=open]:bg-accent [&_svg]:size-4",
|
|
88
130
|
{
|
|
@@ -113,11 +155,11 @@ function LinkItem({
|
|
|
113
155
|
...props,
|
|
114
156
|
children: [
|
|
115
157
|
item.text,
|
|
116
|
-
/* @__PURE__ */
|
|
158
|
+
/* @__PURE__ */ jsx3(ChevronDown, { className: "ms-auto size-4" })
|
|
117
159
|
]
|
|
118
160
|
}
|
|
119
161
|
),
|
|
120
|
-
/* @__PURE__ */
|
|
162
|
+
/* @__PURE__ */ jsx3(PopoverContent, { className: "flex flex-col", children: item.items.map((child, i) => /* @__PURE__ */ jsx3(LinkItem, { item: child, on: "menu" }, i)) })
|
|
121
163
|
] });
|
|
122
164
|
}
|
|
123
165
|
if (item.type === "menu") {
|
|
@@ -130,18 +172,18 @@ function LinkItem({
|
|
|
130
172
|
children: [
|
|
131
173
|
item.icon,
|
|
132
174
|
item.text,
|
|
133
|
-
/* @__PURE__ */
|
|
175
|
+
/* @__PURE__ */ jsx3(ChevronDown, { className: "ms-auto size-4 group-data-[state=closed]/link:-rotate-90" })
|
|
134
176
|
]
|
|
135
177
|
}
|
|
136
178
|
),
|
|
137
|
-
/* @__PURE__ */
|
|
179
|
+
/* @__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)) }) })
|
|
138
180
|
] });
|
|
139
181
|
}
|
|
140
182
|
const activeType = item.active ?? "url";
|
|
141
183
|
const active = activeType !== "none" ? isActive(item.url, pathname, activeType === "nested-url") : false;
|
|
142
184
|
if (item.type === "secondary" && on === "nav") {
|
|
143
|
-
return /* @__PURE__ */
|
|
144
|
-
|
|
185
|
+
return /* @__PURE__ */ jsx3(
|
|
186
|
+
Link2,
|
|
145
187
|
{
|
|
146
188
|
"aria-label": item.text,
|
|
147
189
|
href: item.url,
|
|
@@ -159,7 +201,7 @@ function LinkItem({
|
|
|
159
201
|
);
|
|
160
202
|
}
|
|
161
203
|
return /* @__PURE__ */ jsxs2(
|
|
162
|
-
|
|
204
|
+
Link2,
|
|
163
205
|
{
|
|
164
206
|
href: item.url,
|
|
165
207
|
external: item.external,
|
|
@@ -179,19 +221,21 @@ function LinkItem({
|
|
|
179
221
|
}
|
|
180
222
|
|
|
181
223
|
// src/components/layout/links-menu.tsx
|
|
182
|
-
import {
|
|
224
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
225
|
+
import { usePathname as usePathname2 } from "next/navigation";
|
|
226
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
183
227
|
function LinksMenu({
|
|
184
228
|
items,
|
|
185
229
|
footer,
|
|
186
230
|
...props
|
|
187
231
|
}) {
|
|
188
|
-
const [open, setOpen] =
|
|
232
|
+
const [open, setOpen] = useState2(false);
|
|
189
233
|
const pathname = usePathname2();
|
|
190
|
-
|
|
234
|
+
useEffect2(() => {
|
|
191
235
|
setOpen(false);
|
|
192
236
|
}, [pathname]);
|
|
193
237
|
return /* @__PURE__ */ jsxs3(Popover, { open, onOpenChange: setOpen, children: [
|
|
194
|
-
/* @__PURE__ */
|
|
238
|
+
/* @__PURE__ */ jsx4(
|
|
195
239
|
PopoverTrigger,
|
|
196
240
|
{
|
|
197
241
|
...props,
|
|
@@ -205,7 +249,7 @@ function LinksMenu({
|
|
|
205
249
|
}
|
|
206
250
|
),
|
|
207
251
|
/* @__PURE__ */ jsxs3(PopoverContent, { className: "flex flex-col", children: [
|
|
208
|
-
items.map((item, i) => /* @__PURE__ */
|
|
252
|
+
items.map((item, i) => /* @__PURE__ */ jsx4(LinkItem, { item, on: "menu" }, i)),
|
|
209
253
|
footer
|
|
210
254
|
] })
|
|
211
255
|
] });
|
|
@@ -216,7 +260,7 @@ import { cva as cva2 } from "class-variance-authority";
|
|
|
216
260
|
import { Moon, Sun } from "lucide-react";
|
|
217
261
|
import { useTheme } from "next-themes";
|
|
218
262
|
import { useCallback as useCallback2 } from "react";
|
|
219
|
-
import { jsx as
|
|
263
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
220
264
|
var buttonVariants2 = cva2("size-7 rounded-full p-1.5 text-muted-foreground", {
|
|
221
265
|
variants: {
|
|
222
266
|
dark: {
|
|
@@ -245,8 +289,8 @@ function ThemeToggle({
|
|
|
245
289
|
onClick: onToggle,
|
|
246
290
|
...props,
|
|
247
291
|
children: [
|
|
248
|
-
/* @__PURE__ */
|
|
249
|
-
/* @__PURE__ */
|
|
292
|
+
/* @__PURE__ */ jsx5(Sun, { className: twMerge(buttonVariants2({ dark: false })) }),
|
|
293
|
+
/* @__PURE__ */ jsx5(Moon, { className: twMerge(buttonVariants2({ dark: true })) })
|
|
250
294
|
]
|
|
251
295
|
}
|
|
252
296
|
);
|
|
@@ -255,6 +299,8 @@ function ThemeToggle({
|
|
|
255
299
|
export {
|
|
256
300
|
SearchToggle,
|
|
257
301
|
LargeSearchToggle,
|
|
302
|
+
NavBox,
|
|
303
|
+
Title,
|
|
258
304
|
LinkItem,
|
|
259
305
|
LinksMenu,
|
|
260
306
|
ThemeToggle
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useCopyButton
|
|
3
|
+
} from "./chunk-2KMKNVSN.js";
|
|
4
|
+
import {
|
|
5
|
+
buttonVariants
|
|
6
|
+
} from "./chunk-H5USAX5W.js";
|
|
7
|
+
import {
|
|
8
|
+
twMerge
|
|
9
|
+
} from "./chunk-TK3TM3MR.js";
|
|
10
|
+
|
|
11
|
+
// src/components/accordion.tsx
|
|
12
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
13
|
+
import { Check, ChevronRight, LinkIcon } from "lucide-react";
|
|
14
|
+
import {
|
|
15
|
+
forwardRef,
|
|
16
|
+
useState,
|
|
17
|
+
useEffect
|
|
18
|
+
} from "react";
|
|
19
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
var Accordions = forwardRef(({ type = "single", className, defaultValue, ...props }, ref) => {
|
|
21
|
+
const [value, setValue] = useState(
|
|
22
|
+
type === "single" ? defaultValue ?? "" : defaultValue ?? []
|
|
23
|
+
);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const id = window.location.hash.substring(1);
|
|
26
|
+
if (id.length > 0)
|
|
27
|
+
setValue((prev) => {
|
|
28
|
+
return type === "single" ? id : [id, ...Array.isArray(prev) ? prev : []];
|
|
29
|
+
});
|
|
30
|
+
}, [type]);
|
|
31
|
+
return (
|
|
32
|
+
// @ts-expect-error -- Multiple types
|
|
33
|
+
/* @__PURE__ */ jsx(
|
|
34
|
+
AccordionPrimitive.Root,
|
|
35
|
+
{
|
|
36
|
+
type,
|
|
37
|
+
ref,
|
|
38
|
+
value,
|
|
39
|
+
onValueChange: setValue,
|
|
40
|
+
collapsible: true,
|
|
41
|
+
className: twMerge(
|
|
42
|
+
"divide-y divide-border overflow-hidden rounded-lg border bg-card",
|
|
43
|
+
className
|
|
44
|
+
),
|
|
45
|
+
...props
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
Accordions.displayName = "Accordions";
|
|
51
|
+
var Accordion = forwardRef(({ title, className, id, children, ...props }, ref) => {
|
|
52
|
+
return /* @__PURE__ */ jsxs(
|
|
53
|
+
AccordionPrimitive.Item,
|
|
54
|
+
{
|
|
55
|
+
ref,
|
|
56
|
+
value: id ?? title,
|
|
57
|
+
className: twMerge("group/accordion relative scroll-m-20", className),
|
|
58
|
+
...props,
|
|
59
|
+
children: [
|
|
60
|
+
/* @__PURE__ */ jsxs(
|
|
61
|
+
AccordionPrimitive.Header,
|
|
62
|
+
{
|
|
63
|
+
id,
|
|
64
|
+
className: "not-prose flex flex-row items-center font-medium text-foreground",
|
|
65
|
+
children: [
|
|
66
|
+
/* @__PURE__ */ jsxs(AccordionPrimitive.Trigger, { className: "flex flex-1 items-center gap-2 p-4 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: [
|
|
67
|
+
/* @__PURE__ */ jsx(ChevronRight, { className: "-ms-1 size-4 text-muted-foreground transition-transform duration-200 group-data-[state=open]/accordion:rotate-90" }),
|
|
68
|
+
title
|
|
69
|
+
] }),
|
|
70
|
+
id ? /* @__PURE__ */ jsx(CopyButton, { id }) : null
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
),
|
|
74
|
+
/* @__PURE__ */ jsx(AccordionPrimitive.Content, { className: "overflow-hidden data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down", children: /* @__PURE__ */ jsx("div", { className: "p-4 pt-0 prose-no-margin", children }) })
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
function CopyButton({ id }) {
|
|
80
|
+
const [checked, onClick] = useCopyButton(() => {
|
|
81
|
+
const url = new URL(window.location.href);
|
|
82
|
+
url.hash = id;
|
|
83
|
+
void navigator.clipboard.writeText(url.toString());
|
|
84
|
+
});
|
|
85
|
+
return /* @__PURE__ */ jsx(
|
|
86
|
+
"button",
|
|
87
|
+
{
|
|
88
|
+
type: "button",
|
|
89
|
+
"aria-label": "Copy Link",
|
|
90
|
+
className: twMerge(
|
|
91
|
+
buttonVariants({
|
|
92
|
+
color: "ghost",
|
|
93
|
+
className: "text-muted-foreground me-2"
|
|
94
|
+
})
|
|
95
|
+
),
|
|
96
|
+
onClick,
|
|
97
|
+
children: checked ? /* @__PURE__ */ jsx(Check, { className: "size-3.5" }) : /* @__PURE__ */ jsx(LinkIcon, { className: "size-3.5" })
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
Accordion.displayName = "Accordion";
|
|
102
|
+
|
|
103
|
+
export {
|
|
104
|
+
Accordions,
|
|
105
|
+
Accordion
|
|
106
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import {
|
|
2
|
+
twMerge
|
|
3
|
+
} from "./chunk-TK3TM3MR.js";
|
|
4
|
+
import {
|
|
5
|
+
__export
|
|
6
|
+
} from "./chunk-MLKGABMK.js";
|
|
7
|
+
|
|
8
|
+
// src/components/tabs.tsx
|
|
9
|
+
import {
|
|
10
|
+
useEffect,
|
|
11
|
+
useMemo,
|
|
12
|
+
useState,
|
|
13
|
+
useCallback
|
|
14
|
+
} from "react";
|
|
15
|
+
|
|
16
|
+
// src/components/ui/tabs.tsx
|
|
17
|
+
var tabs_exports = {};
|
|
18
|
+
__export(tabs_exports, {
|
|
19
|
+
Tabs: () => Tabs,
|
|
20
|
+
TabsContent: () => TabsContent,
|
|
21
|
+
TabsList: () => TabsList,
|
|
22
|
+
TabsTrigger: () => TabsTrigger
|
|
23
|
+
});
|
|
24
|
+
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
25
|
+
import * as React from "react";
|
|
26
|
+
import { jsx } from "react/jsx-runtime";
|
|
27
|
+
var Tabs = React.forwardRef((props, ref) => {
|
|
28
|
+
return /* @__PURE__ */ jsx(
|
|
29
|
+
TabsPrimitive.Root,
|
|
30
|
+
{
|
|
31
|
+
ref,
|
|
32
|
+
...props,
|
|
33
|
+
className: twMerge(
|
|
34
|
+
"flex flex-col overflow-hidden rounded-xl border bg-card",
|
|
35
|
+
props.className
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
Tabs.displayName = "Tabs";
|
|
41
|
+
var TabsList = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(
|
|
42
|
+
TabsPrimitive.List,
|
|
43
|
+
{
|
|
44
|
+
ref,
|
|
45
|
+
...props,
|
|
46
|
+
className: twMerge(
|
|
47
|
+
"flex flex-row items-end gap-4 overflow-x-auto bg-secondary px-4 text-muted-foreground",
|
|
48
|
+
props.className
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
));
|
|
52
|
+
TabsList.displayName = "TabsList";
|
|
53
|
+
var TabsTrigger = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(
|
|
54
|
+
TabsPrimitive.Trigger,
|
|
55
|
+
{
|
|
56
|
+
ref,
|
|
57
|
+
...props,
|
|
58
|
+
className: twMerge(
|
|
59
|
+
"whitespace-nowrap border-b border-transparent py-2 text-sm font-medium transition-colors hover:text-accent-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=active]:border-primary data-[state=active]:text-primary",
|
|
60
|
+
props.className
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
));
|
|
64
|
+
TabsTrigger.displayName = "TabsTrigger";
|
|
65
|
+
var TabsContent = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(
|
|
66
|
+
TabsPrimitive.Content,
|
|
67
|
+
{
|
|
68
|
+
ref,
|
|
69
|
+
...props,
|
|
70
|
+
className: twMerge("p-4", props.className)
|
|
71
|
+
}
|
|
72
|
+
));
|
|
73
|
+
TabsContent.displayName = "TabsContent";
|
|
74
|
+
|
|
75
|
+
// src/components/tabs.tsx
|
|
76
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
77
|
+
var listeners = /* @__PURE__ */ new Map();
|
|
78
|
+
function addChangeListener(id, listener) {
|
|
79
|
+
const list = listeners.get(id) ?? [];
|
|
80
|
+
list.push(listener);
|
|
81
|
+
listeners.set(id, list);
|
|
82
|
+
}
|
|
83
|
+
function removeChangeListener(id, listener) {
|
|
84
|
+
const list = listeners.get(id) ?? [];
|
|
85
|
+
listeners.set(
|
|
86
|
+
id,
|
|
87
|
+
list.filter((item) => item !== listener)
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
function update(id, v, persist) {
|
|
91
|
+
listeners.get(id)?.forEach((item) => {
|
|
92
|
+
item(v);
|
|
93
|
+
});
|
|
94
|
+
if (persist) localStorage.setItem(id, v);
|
|
95
|
+
else sessionStorage.setItem(id, v);
|
|
96
|
+
}
|
|
97
|
+
function Tabs2({
|
|
98
|
+
id,
|
|
99
|
+
items = [],
|
|
100
|
+
persist = false,
|
|
101
|
+
defaultIndex = 0,
|
|
102
|
+
children
|
|
103
|
+
}) {
|
|
104
|
+
const values = useMemo(() => items.map((item) => toValue(item)), [items]);
|
|
105
|
+
const [value, setValue] = useState(values[defaultIndex]);
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (!id) return;
|
|
108
|
+
const onUpdate = (v) => {
|
|
109
|
+
if (values.includes(v)) setValue(v);
|
|
110
|
+
};
|
|
111
|
+
const previous = persist ? localStorage.getItem(id) : sessionStorage.getItem(id);
|
|
112
|
+
if (previous) onUpdate(previous);
|
|
113
|
+
addChangeListener(id, onUpdate);
|
|
114
|
+
return () => {
|
|
115
|
+
removeChangeListener(id, onUpdate);
|
|
116
|
+
};
|
|
117
|
+
}, [id, persist, values]);
|
|
118
|
+
const onValueChange = useCallback(
|
|
119
|
+
(v) => {
|
|
120
|
+
if (id) {
|
|
121
|
+
update(id, v, persist);
|
|
122
|
+
} else {
|
|
123
|
+
setValue(v);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
[id, persist]
|
|
127
|
+
);
|
|
128
|
+
return /* @__PURE__ */ jsxs(
|
|
129
|
+
Tabs,
|
|
130
|
+
{
|
|
131
|
+
value,
|
|
132
|
+
onValueChange,
|
|
133
|
+
className: "my-4",
|
|
134
|
+
children: [
|
|
135
|
+
/* @__PURE__ */ jsx2(TabsList, { children: values.map((v, i) => /* @__PURE__ */ jsx2(TabsTrigger, { value: v, children: items[i] }, v)) }),
|
|
136
|
+
children
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
function toValue(v) {
|
|
142
|
+
return v.toLowerCase().replace(/\s/, "-");
|
|
143
|
+
}
|
|
144
|
+
function Tab({
|
|
145
|
+
value,
|
|
146
|
+
className,
|
|
147
|
+
...props
|
|
148
|
+
}) {
|
|
149
|
+
return /* @__PURE__ */ jsx2(
|
|
150
|
+
TabsContent,
|
|
151
|
+
{
|
|
152
|
+
value: toValue(value),
|
|
153
|
+
className: twMerge(
|
|
154
|
+
"prose-no-margin [&>figure:only-child]:-m-4 [&>figure:only-child]:rounded-none [&>figure:only-child]:border-none",
|
|
155
|
+
className
|
|
156
|
+
),
|
|
157
|
+
...props
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export {
|
|
163
|
+
tabs_exports,
|
|
164
|
+
Tabs2 as Tabs,
|
|
165
|
+
Tab
|
|
166
|
+
};
|
|
@@ -1,106 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
twMerge
|
|
10
|
-
} from "../chunk-TK3TM3MR.js";
|
|
3
|
+
Accordion,
|
|
4
|
+
Accordions
|
|
5
|
+
} from "../chunk-MXPAPA74.js";
|
|
6
|
+
import "../chunk-2KMKNVSN.js";
|
|
7
|
+
import "../chunk-H5USAX5W.js";
|
|
8
|
+
import "../chunk-TK3TM3MR.js";
|
|
11
9
|
import "../chunk-MLKGABMK.js";
|
|
12
|
-
|
|
13
|
-
// src/components/accordion.tsx
|
|
14
|
-
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
15
|
-
import { Check, ChevronRight, LinkIcon } from "lucide-react";
|
|
16
|
-
import {
|
|
17
|
-
forwardRef,
|
|
18
|
-
useState,
|
|
19
|
-
useEffect
|
|
20
|
-
} from "react";
|
|
21
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
22
|
-
var Accordions = forwardRef(({ type = "single", className, defaultValue, ...props }, ref) => {
|
|
23
|
-
const [value, setValue] = useState(
|
|
24
|
-
type === "single" ? defaultValue ?? "" : defaultValue ?? []
|
|
25
|
-
);
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
const id = window.location.hash.substring(1);
|
|
28
|
-
if (id.length > 0)
|
|
29
|
-
setValue((prev) => {
|
|
30
|
-
return type === "single" ? id : [id, ...Array.isArray(prev) ? prev : []];
|
|
31
|
-
});
|
|
32
|
-
}, [type]);
|
|
33
|
-
return (
|
|
34
|
-
// @ts-expect-error -- Multiple types
|
|
35
|
-
/* @__PURE__ */ jsx(
|
|
36
|
-
AccordionPrimitive.Root,
|
|
37
|
-
{
|
|
38
|
-
type,
|
|
39
|
-
ref,
|
|
40
|
-
value,
|
|
41
|
-
onValueChange: setValue,
|
|
42
|
-
collapsible: true,
|
|
43
|
-
className: twMerge(
|
|
44
|
-
"divide-y divide-border overflow-hidden rounded-lg border bg-card",
|
|
45
|
-
className
|
|
46
|
-
),
|
|
47
|
-
...props
|
|
48
|
-
}
|
|
49
|
-
)
|
|
50
|
-
);
|
|
51
|
-
});
|
|
52
|
-
Accordions.displayName = "Accordions";
|
|
53
|
-
var Accordion = forwardRef(({ title, className, id, children, ...props }, ref) => {
|
|
54
|
-
return /* @__PURE__ */ jsxs(
|
|
55
|
-
AccordionPrimitive.Item,
|
|
56
|
-
{
|
|
57
|
-
ref,
|
|
58
|
-
value: id ?? title,
|
|
59
|
-
className: twMerge("group/accordion relative scroll-m-20", className),
|
|
60
|
-
...props,
|
|
61
|
-
children: [
|
|
62
|
-
/* @__PURE__ */ jsxs(
|
|
63
|
-
AccordionPrimitive.Header,
|
|
64
|
-
{
|
|
65
|
-
id,
|
|
66
|
-
className: "not-prose flex flex-row items-center font-medium text-foreground",
|
|
67
|
-
children: [
|
|
68
|
-
/* @__PURE__ */ jsxs(AccordionPrimitive.Trigger, { className: "flex flex-1 items-center gap-2 p-4 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: [
|
|
69
|
-
/* @__PURE__ */ jsx(ChevronRight, { className: "size-4 text-muted-foreground transition-transform duration-200 group-data-[state=open]/accordion:rotate-90" }),
|
|
70
|
-
title
|
|
71
|
-
] }),
|
|
72
|
-
id ? /* @__PURE__ */ jsx(CopyButton, { id }) : null
|
|
73
|
-
]
|
|
74
|
-
}
|
|
75
|
-
),
|
|
76
|
-
/* @__PURE__ */ jsx(AccordionPrimitive.Content, { className: "overflow-hidden data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down", children: /* @__PURE__ */ jsx("div", { className: "ms-2 p-4 pt-0 prose-no-margin", children }) })
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
function CopyButton({ id }) {
|
|
82
|
-
const [checked, onClick] = useCopyButton(() => {
|
|
83
|
-
const url = new URL(window.location.href);
|
|
84
|
-
url.hash = id;
|
|
85
|
-
void navigator.clipboard.writeText(url.toString());
|
|
86
|
-
});
|
|
87
|
-
return /* @__PURE__ */ jsx(
|
|
88
|
-
"button",
|
|
89
|
-
{
|
|
90
|
-
type: "button",
|
|
91
|
-
"aria-label": "Copy Link",
|
|
92
|
-
className: twMerge(
|
|
93
|
-
buttonVariants({
|
|
94
|
-
color: "ghost",
|
|
95
|
-
className: "text-muted-foreground me-2"
|
|
96
|
-
})
|
|
97
|
-
),
|
|
98
|
-
onClick,
|
|
99
|
-
children: checked ? /* @__PURE__ */ jsx(Check, { className: "size-3.5" }) : /* @__PURE__ */ jsx(LinkIcon, { className: "size-3.5" })
|
|
100
|
-
}
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
Accordion.displayName = "Accordion";
|
|
104
10
|
export {
|
|
105
11
|
Accordion,
|
|
106
12
|
Accordions
|
package/dist/components/api.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { Tabs, Tab } from './tabs.js';
|
|
3
|
+
import '@radix-ui/react-tabs';
|
|
2
4
|
|
|
3
5
|
declare function Root({ children, className, ...props }: HTMLAttributes<HTMLDivElement>): React.ReactElement;
|
|
4
6
|
declare function API({ className, children, ...props }: HTMLAttributes<HTMLDivElement>): React.ReactElement;
|
|
@@ -16,5 +18,21 @@ interface PropertyProps {
|
|
|
16
18
|
}
|
|
17
19
|
declare function Property({ name, type, required, deprecated, children, }: PropertyProps): React.ReactElement;
|
|
18
20
|
declare function APIExample({ children, className, ...props }: HTMLAttributes<HTMLDivElement>): React.ReactElement;
|
|
21
|
+
declare const Responses: typeof Tabs;
|
|
22
|
+
declare const Response: typeof Tab;
|
|
23
|
+
declare const Requests: typeof Tabs;
|
|
24
|
+
declare const Request: typeof Tab;
|
|
25
|
+
declare function ResponseTypes(props: {
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
}): React.ReactElement;
|
|
28
|
+
declare function ExampleResponse(props: {
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
}): React.ReactElement;
|
|
31
|
+
declare function TypeScriptResponse(props: {
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
}): React.ReactElement;
|
|
34
|
+
declare function ObjectCollapsible(props: {
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
}): React.ReactElement;
|
|
19
37
|
|
|
20
|
-
export { API, APIExample, APIInfo, type APIInfoProps, Property, Root };
|
|
38
|
+
export { API, APIExample, APIInfo, type APIInfoProps, ExampleResponse, ObjectCollapsible, Property, Request, Requests, Response, ResponseTypes, Responses, Root, TypeScriptResponse };
|