fumandocs-ui 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +42 -2
- package/dist/components/callout.d.ts +20 -0
- package/dist/components/callout.js +101 -0
- package/dist/components/callout.module.js +12 -0
- package/dist/components/card.d.ts +14 -0
- package/dist/components/card.js +85 -0
- package/dist/components/card.module.js +8 -0
- package/dist/components/codeblock.d.ts +22 -0
- package/dist/components/codeblock.js +94 -0
- package/dist/components/codeblock.module.js +11 -0
- package/dist/components/heading.d.ts +9 -0
- package/dist/components/heading.js +55 -0
- package/dist/components/heading.module.js +7 -0
- package/dist/components/toc.d.ts +14 -0
- package/dist/components/toc.js +231 -0
- package/dist/components/toc.module.js +19 -0
- package/dist/layouts/docs/docs-layout.d.ts +24 -0
- package/dist/layouts/docs/docs-layout.js +383 -0
- package/dist/layouts/docs/docs-layout.module.js +28 -0
- package/dist/layouts/docs/index.d.ts +3 -0
- package/dist/layouts/docs/index.js +29 -0
- package/dist/layouts/docs/page.d.ts +47 -0
- package/dist/layouts/docs/page.js +347 -0
- package/dist/layouts/docs/page.module.js +15 -0
- package/dist/layouts/docs/prose.module.js +4 -0
- package/dist/layouts/shared.d.ts +33 -0
- package/dist/layouts/shared.js +0 -0
- package/dist/mdx.d.ts +33 -0
- package/dist/mdx.js +91 -0
- package/dist/mdx.module.js +4 -0
- package/dist/mdx.server.d.ts +7 -0
- package/dist/mdx.server.js +13 -0
- package/dist/provider/base.d.ts +14 -0
- package/dist/provider/base.js +47 -0
- package/dist/provider/base.module.js +4 -0
- package/dist/provider/next.d.ts +13 -0
- package/dist/provider/next.js +38 -0
- package/dist/search.d.ts +20 -0
- package/dist/search.js +177 -0
- package/dist/search.module.js +7 -0
- package/dist/style.css +1159 -0
- package/package.json +111 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Xiao Hanyu (https://xiaohanyu.me)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
-
#
|
|
1
|
+
# fumandocs-ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Mantine UI for [Fumadocs](https://fumadocs.dev): docs layout, page primitives,
|
|
4
|
+
provider, search, and MDX components — no Tailwind CSS.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pnpm add fumandocs-ui @mantine/core @mantine/hooks fumadocs-core fumadocs-mdx
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Import from **`fumandocs-ui/...`**. Upstream Fumadocs docs use the name
|
|
13
|
+
`fumadocs-ui`; swap the package name for the subpaths we support (see the
|
|
14
|
+
Fumandocs site export-compatibility page).
|
|
15
|
+
|
|
16
|
+
## Root layout (Next.js)
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import "@mantine/core/styles.css";
|
|
20
|
+
import "fumandocs-ui/style.css";
|
|
21
|
+
import { ColorSchemeScript } from "@mantine/core";
|
|
22
|
+
import { RootProvider } from "fumandocs-ui/provider/next";
|
|
23
|
+
|
|
24
|
+
export default function RootLayout({
|
|
25
|
+
children,
|
|
26
|
+
}: {
|
|
27
|
+
children: React.ReactNode;
|
|
28
|
+
}) {
|
|
29
|
+
return (
|
|
30
|
+
<html lang="en" suppressHydrationWarning>
|
|
31
|
+
<head>
|
|
32
|
+
<ColorSchemeScript defaultColorScheme="auto" />
|
|
33
|
+
</head>
|
|
34
|
+
<body>
|
|
35
|
+
<RootProvider>{children}</RootProvider>
|
|
36
|
+
</body>
|
|
37
|
+
</html>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
See the Fumandocs monorepo `apps/www` for a full site (`pnpm dev:site` from the
|
|
43
|
+
root).
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PaperProps } from "@mantine/core";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/components/callout.d.ts
|
|
4
|
+
type CalloutType = 'info' | 'warn' | 'warning' | 'error' | 'success' | 'idea';
|
|
5
|
+
interface CalloutContainerProps extends Omit<PaperProps, 'title'> {
|
|
6
|
+
type?: CalloutType;
|
|
7
|
+
title?: ReactNode;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
declare function Callout({ title, children, type, icon, ...props }: CalloutContainerProps): import("react").JSX.Element;
|
|
12
|
+
declare function CalloutContainer(props: CalloutContainerProps): import("react").JSX.Element;
|
|
13
|
+
declare function CalloutTitle({ children }: {
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
declare function CalloutDescription({ children }: {
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
}): import("react").JSX.Element;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Callout, CalloutContainer, CalloutContainerProps, CalloutDescription, CalloutTitle, CalloutType };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import callout_module_default from "./callout.module.js";
|
|
2
|
+
import { Box, Paper, Text } from "@mantine/core";
|
|
3
|
+
import { CheckCircleIcon, InfoIcon, LightbulbIcon, WarningIcon, XCircleIcon } from "@phosphor-icons/react/ssr";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/callout.tsx
|
|
6
|
+
/**
|
|
7
|
+
* MIT License
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2026 Xiao Hanyu (https://xiaohanyu.me)
|
|
10
|
+
*
|
|
11
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
* in the Software without restriction, including without limitation the rights
|
|
14
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
* furnished to do so, subject to the following conditions:
|
|
17
|
+
*
|
|
18
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
* copies or substantial portions of the Software.
|
|
20
|
+
*
|
|
21
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
* SOFTWARE.
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
function normalizeType(type) {
|
|
31
|
+
return type === "warn" ? "warning" : type;
|
|
32
|
+
}
|
|
33
|
+
const defaultIcons = {
|
|
34
|
+
info: /* @__PURE__ */ jsx(InfoIcon, {
|
|
35
|
+
size: 14,
|
|
36
|
+
"aria-hidden": true
|
|
37
|
+
}),
|
|
38
|
+
warning: /* @__PURE__ */ jsx(WarningIcon, {
|
|
39
|
+
size: 14,
|
|
40
|
+
"aria-hidden": true
|
|
41
|
+
}),
|
|
42
|
+
error: /* @__PURE__ */ jsx(XCircleIcon, {
|
|
43
|
+
size: 14,
|
|
44
|
+
"aria-hidden": true
|
|
45
|
+
}),
|
|
46
|
+
success: /* @__PURE__ */ jsx(CheckCircleIcon, {
|
|
47
|
+
size: 14,
|
|
48
|
+
"aria-hidden": true
|
|
49
|
+
}),
|
|
50
|
+
idea: /* @__PURE__ */ jsx(LightbulbIcon, {
|
|
51
|
+
size: 14,
|
|
52
|
+
"aria-hidden": true
|
|
53
|
+
})
|
|
54
|
+
};
|
|
55
|
+
function Callout({ title, children, type = "info", icon, ...props }) {
|
|
56
|
+
const resolved = normalizeType(type);
|
|
57
|
+
const iconEl = /* @__PURE__ */ jsx("span", {
|
|
58
|
+
className: callout_module_default.icon,
|
|
59
|
+
"aria-hidden": true,
|
|
60
|
+
children: icon ?? defaultIcons[resolved]
|
|
61
|
+
});
|
|
62
|
+
return /* @__PURE__ */ jsxs(Paper, {
|
|
63
|
+
withBorder: true,
|
|
64
|
+
radius: "xs",
|
|
65
|
+
...props,
|
|
66
|
+
"data-type": resolved,
|
|
67
|
+
className: [callout_module_default.root, props.className].filter(Boolean).join(" "),
|
|
68
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
69
|
+
className: callout_module_default.bar,
|
|
70
|
+
"aria-hidden": true
|
|
71
|
+
}), title ? /* @__PURE__ */ jsxs(Box, {
|
|
72
|
+
className: callout_module_default.content,
|
|
73
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
74
|
+
className: callout_module_default.header,
|
|
75
|
+
children: [iconEl, /* @__PURE__ */ jsx(CalloutTitle, { children: title })]
|
|
76
|
+
}), /* @__PURE__ */ jsx(CalloutDescription, { children })]
|
|
77
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [iconEl, /* @__PURE__ */ jsx(Box, {
|
|
78
|
+
className: callout_module_default.content,
|
|
79
|
+
children: /* @__PURE__ */ jsx(CalloutDescription, { children })
|
|
80
|
+
})] })]
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function CalloutContainer(props) {
|
|
84
|
+
return /* @__PURE__ */ jsx(Callout, { ...props });
|
|
85
|
+
}
|
|
86
|
+
function CalloutTitle({ children }) {
|
|
87
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
88
|
+
fw: 500,
|
|
89
|
+
size: "sm",
|
|
90
|
+
className: callout_module_default.title,
|
|
91
|
+
children
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function CalloutDescription({ children }) {
|
|
95
|
+
return /* @__PURE__ */ jsx("div", {
|
|
96
|
+
className: callout_module_default.description,
|
|
97
|
+
children
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { Callout, CalloutContainer, CalloutDescription, CalloutTitle };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/components/callout.module.css
|
|
2
|
+
var callout_module_default = {
|
|
3
|
+
"bar": "B98Wza_bar",
|
|
4
|
+
"content": "B98Wza_content",
|
|
5
|
+
"description": "B98Wza_description",
|
|
6
|
+
"header": "B98Wza_header",
|
|
7
|
+
"icon": "B98Wza_icon",
|
|
8
|
+
"root": "B98Wza_root",
|
|
9
|
+
"title": "B98Wza_title"
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { callout_module_default as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SimpleGridProps } from "@mantine/core";
|
|
2
|
+
import { HTMLAttributes, ReactNode } from "react";
|
|
3
|
+
//#region src/components/card.d.ts
|
|
4
|
+
declare function Cards(props: SimpleGridProps): import("react").JSX.Element;
|
|
5
|
+
interface CardProps extends Omit<HTMLAttributes<HTMLElement>, 'title'> {
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
description?: ReactNode;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
href?: string;
|
|
10
|
+
external?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare function Card({ title, description, icon, href, external, children, ...props }: CardProps): import("react").JSX.Element;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { Card, CardProps, Cards };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import card_module_default from "./card.module.js";
|
|
2
|
+
import { Card as Card$1, SimpleGrid, Text, ThemeIcon } from "@mantine/core";
|
|
3
|
+
import Link from "fumadocs-core/link";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/card.tsx
|
|
6
|
+
/**
|
|
7
|
+
* MIT License
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2026 Xiao Hanyu (https://xiaohanyu.me)
|
|
10
|
+
*
|
|
11
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
* in the Software without restriction, including without limitation the rights
|
|
14
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
* furnished to do so, subject to the following conditions:
|
|
17
|
+
*
|
|
18
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
* copies or substantial portions of the Software.
|
|
20
|
+
*
|
|
21
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
* SOFTWARE.
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
function Cards(props) {
|
|
31
|
+
return /* @__PURE__ */ jsx(SimpleGrid, {
|
|
32
|
+
cols: {
|
|
33
|
+
base: 1,
|
|
34
|
+
sm: 2
|
|
35
|
+
},
|
|
36
|
+
spacing: 16,
|
|
37
|
+
...props
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function Card({ title, description, icon, href, external, children, ...props }) {
|
|
41
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
42
|
+
icon && /* @__PURE__ */ jsx(ThemeIcon, {
|
|
43
|
+
variant: "default",
|
|
44
|
+
radius: "md",
|
|
45
|
+
mb: "sm",
|
|
46
|
+
className: card_module_default.icon,
|
|
47
|
+
children: icon
|
|
48
|
+
}),
|
|
49
|
+
/* @__PURE__ */ jsx(Text, {
|
|
50
|
+
fw: 500,
|
|
51
|
+
size: "sm",
|
|
52
|
+
children: title
|
|
53
|
+
}),
|
|
54
|
+
description && /* @__PURE__ */ jsx(Text, {
|
|
55
|
+
size: "sm",
|
|
56
|
+
mt: 4,
|
|
57
|
+
children: description
|
|
58
|
+
}),
|
|
59
|
+
children && /* @__PURE__ */ jsx("div", {
|
|
60
|
+
className: card_module_default.content,
|
|
61
|
+
children
|
|
62
|
+
})
|
|
63
|
+
] });
|
|
64
|
+
if (href) return /* @__PURE__ */ jsx(Card$1, {
|
|
65
|
+
component: Link,
|
|
66
|
+
href,
|
|
67
|
+
external,
|
|
68
|
+
withBorder: true,
|
|
69
|
+
padding: "md",
|
|
70
|
+
radius: "xs",
|
|
71
|
+
className: card_module_default.root,
|
|
72
|
+
...props,
|
|
73
|
+
children: content
|
|
74
|
+
});
|
|
75
|
+
return /* @__PURE__ */ jsx(Card$1, {
|
|
76
|
+
withBorder: true,
|
|
77
|
+
padding: "md",
|
|
78
|
+
radius: "xs",
|
|
79
|
+
className: card_module_default.root,
|
|
80
|
+
...props,
|
|
81
|
+
children: content
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { Card, Cards };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Tabs } from "@mantine/core";
|
|
2
|
+
import { ComponentProps, HTMLAttributes, ReactNode } from "react";
|
|
3
|
+
//#region src/components/codeblock.d.ts
|
|
4
|
+
interface CodeBlockProps extends Omit<ComponentProps<'figure'>, 'title'> {
|
|
5
|
+
title?: ReactNode;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
allowCopy?: boolean | 'true' | 'false';
|
|
8
|
+
viewportProps?: HTMLAttributes<HTMLDivElement>;
|
|
9
|
+
keepBackground?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare function Pre(props: ComponentProps<'pre'>): import("react").JSX.Element;
|
|
12
|
+
declare function CodeBlock({ title, icon, allowCopy, viewportProps, children, ...props }: CodeBlockProps): import("react").JSX.Element;
|
|
13
|
+
interface CodeBlockTabsProps extends Omit<ComponentProps<typeof Tabs>, 'groupId' | 'persist'> {
|
|
14
|
+
groupId?: string;
|
|
15
|
+
persist?: boolean;
|
|
16
|
+
}
|
|
17
|
+
declare function CodeBlockTabs({ className, groupId, persist, ...props }: CodeBlockTabsProps): import("react").JSX.Element;
|
|
18
|
+
declare function CodeBlockTabsList(props: ComponentProps<typeof Tabs.List>): import("react").JSX.Element;
|
|
19
|
+
declare function CodeBlockTabsTrigger(props: ComponentProps<typeof Tabs.Tab>): import("react").JSX.Element;
|
|
20
|
+
declare function CodeBlockTab(props: ComponentProps<typeof Tabs.Panel>): import("react").JSX.Element;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { CodeBlock, CodeBlockProps, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsProps, CodeBlockTabsTrigger, Pre };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import codeblock_module_default from "./codeblock.module.js";
|
|
3
|
+
import { ActionIcon, Group, Paper, Tabs, Text } from "@mantine/core";
|
|
4
|
+
import { CheckIcon, CopyIcon } from "@phosphor-icons/react/ssr";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useRef, useState } from "react";
|
|
7
|
+
//#region src/components/codeblock.tsx
|
|
8
|
+
/**
|
|
9
|
+
* MIT License
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2026 Xiao Hanyu (https://xiaohanyu.me)
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
* furnished to do so, subject to the following conditions:
|
|
19
|
+
*
|
|
20
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
* copies or substantial portions of the Software.
|
|
22
|
+
*
|
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
* SOFTWARE.
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
function Pre(props) {
|
|
33
|
+
return /* @__PURE__ */ jsx("pre", { ...props });
|
|
34
|
+
}
|
|
35
|
+
function CodeBlock({ title, icon, allowCopy = true, viewportProps, children, ...props }) {
|
|
36
|
+
const ref = useRef(null);
|
|
37
|
+
const [copied, setCopied] = useState(false);
|
|
38
|
+
const copy = async () => {
|
|
39
|
+
const content = ref.current?.querySelector("pre")?.textContent ?? ref.current?.textContent ?? "";
|
|
40
|
+
await navigator.clipboard.writeText(content);
|
|
41
|
+
setCopied(true);
|
|
42
|
+
window.setTimeout(() => setCopied(false), 1500);
|
|
43
|
+
};
|
|
44
|
+
return /* @__PURE__ */ jsxs(Paper, {
|
|
45
|
+
component: "figure",
|
|
46
|
+
withBorder: true,
|
|
47
|
+
radius: "xs",
|
|
48
|
+
...props,
|
|
49
|
+
className: [codeblock_module_default.root, props.className].filter(Boolean).join(" "),
|
|
50
|
+
children: [(title || icon) && /* @__PURE__ */ jsxs(Group, {
|
|
51
|
+
className: codeblock_module_default.header,
|
|
52
|
+
gap: "xs",
|
|
53
|
+
children: [icon, /* @__PURE__ */ jsx(Text, {
|
|
54
|
+
component: "figcaption",
|
|
55
|
+
size: "sm",
|
|
56
|
+
fw: 500,
|
|
57
|
+
children: title
|
|
58
|
+
})]
|
|
59
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
60
|
+
className: codeblock_module_default.body,
|
|
61
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
62
|
+
ref,
|
|
63
|
+
...viewportProps,
|
|
64
|
+
className: [codeblock_module_default.viewport, viewportProps?.className].filter(Boolean).join(" "),
|
|
65
|
+
children
|
|
66
|
+
}), allowCopy !== false && allowCopy !== "false" && /* @__PURE__ */ jsx(ActionIcon, {
|
|
67
|
+
onClick: copy,
|
|
68
|
+
variant: "subtle",
|
|
69
|
+
color: "gray",
|
|
70
|
+
className: codeblock_module_default.copyButton,
|
|
71
|
+
"aria-label": "Copy code",
|
|
72
|
+
children: copied ? /* @__PURE__ */ jsx(CheckIcon, { size: 14 }) : /* @__PURE__ */ jsx(CopyIcon, { size: 14 })
|
|
73
|
+
})]
|
|
74
|
+
})]
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function CodeBlockTabs({ className, groupId, persist, ...props }) {
|
|
78
|
+
return /* @__PURE__ */ jsx(Tabs, {
|
|
79
|
+
keepMounted: false,
|
|
80
|
+
...props,
|
|
81
|
+
className: [codeblock_module_default.codeTabs, className].filter(Boolean).join(" ")
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function CodeBlockTabsList(props) {
|
|
85
|
+
return /* @__PURE__ */ jsx(Tabs.List, { ...props });
|
|
86
|
+
}
|
|
87
|
+
function CodeBlockTabsTrigger(props) {
|
|
88
|
+
return /* @__PURE__ */ jsx(Tabs.Tab, { ...props });
|
|
89
|
+
}
|
|
90
|
+
function CodeBlockTab(props) {
|
|
91
|
+
return /* @__PURE__ */ jsx(Tabs.Panel, { ...props });
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
export { CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, Pre };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/components/codeblock.module.css
|
|
2
|
+
var codeblock_module_default = {
|
|
3
|
+
"body": "_3213aW_body",
|
|
4
|
+
"codeTabs": "_3213aW_codeTabs",
|
|
5
|
+
"copyButton": "_3213aW_copyButton",
|
|
6
|
+
"header": "_3213aW_header",
|
|
7
|
+
"root": "_3213aW_root",
|
|
8
|
+
"viewport": "_3213aW_viewport"
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { codeblock_module_default as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
//#region src/components/heading.d.ts
|
|
3
|
+
type HeadingTag = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
4
|
+
type HeadingProps<T extends HeadingTag = 'h2'> = Omit<ComponentPropsWithoutRef<T>, 'as'> & {
|
|
5
|
+
as?: T;
|
|
6
|
+
};
|
|
7
|
+
declare function Heading<T extends HeadingTag = 'h2'>({ as, children, ...props }: HeadingProps<T>): import("react").JSX.Element;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { Heading, HeadingProps };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import heading_module_default from "./heading.module.js";
|
|
3
|
+
import { ActionIcon } from "@mantine/core";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/heading.tsx
|
|
6
|
+
/**
|
|
7
|
+
* MIT License
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2026 Xiao Hanyu (https://xiaohanyu.me)
|
|
10
|
+
*
|
|
11
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
* in the Software without restriction, including without limitation the rights
|
|
14
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
* furnished to do so, subject to the following conditions:
|
|
17
|
+
*
|
|
18
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
* copies or substantial portions of the Software.
|
|
20
|
+
*
|
|
21
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
* SOFTWARE.
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
function Heading({ as, children, ...props }) {
|
|
31
|
+
const Element = as ?? "h2";
|
|
32
|
+
if (!props.id) return /* @__PURE__ */ jsx(Element, {
|
|
33
|
+
...props,
|
|
34
|
+
children
|
|
35
|
+
});
|
|
36
|
+
return /* @__PURE__ */ jsxs(Element, {
|
|
37
|
+
...props,
|
|
38
|
+
className: [heading_module_default.root, props.className].filter(Boolean).join(" "),
|
|
39
|
+
children: [/* @__PURE__ */ jsx("a", {
|
|
40
|
+
href: `#${props.id}`,
|
|
41
|
+
children
|
|
42
|
+
}), /* @__PURE__ */ jsx(ActionIcon, {
|
|
43
|
+
component: "a",
|
|
44
|
+
href: `#${props.id}`,
|
|
45
|
+
variant: "subtle",
|
|
46
|
+
color: "gray",
|
|
47
|
+
size: "sm",
|
|
48
|
+
"aria-label": "Link to this heading",
|
|
49
|
+
className: heading_module_default.anchor,
|
|
50
|
+
children: "#"
|
|
51
|
+
})]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { Heading };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import * as Primitive from "fumadocs-core/toc";
|
|
3
|
+
//#region src/components/toc.d.ts
|
|
4
|
+
interface TOCRailProps extends ComponentProps<'div'> {
|
|
5
|
+
items: Primitive.TOCItemType[];
|
|
6
|
+
thumbBox?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare function TOCRail({ items, thumbBox, className, children, ...props }: TOCRailProps): import("react").JSX.Element;
|
|
9
|
+
declare function TOCRailItem({ item, items, ...props }: Primitive.TOCItemProps & {
|
|
10
|
+
item: Primitive.TOCItemType;
|
|
11
|
+
items: Primitive.TOCItemType[];
|
|
12
|
+
}): import("react").JSX.Element;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { TOCRail, TOCRailItem, TOCRailProps };
|