boltdocs 2.7.10 → 2.7.11
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/client/index.cjs +1929 -1
- package/dist/client/index.js +1880 -1
- package/dist/client/mdx.cjs +7 -1
- package/dist/client/mdx.js +7 -1
- package/dist/client/primitives.cjs +60 -1
- package/dist/client/primitives.js +20 -1
- package/dist/docs-layout-BXHV0xw_.cjs +1431 -0
- package/dist/docs-layout-DwFndmj5.js +1231 -0
- package/dist/icons-dev-3cZMyt8r.cjs +1204 -0
- package/dist/icons-dev-Df8OQ481.js +839 -0
- package/dist/image-DtrI2cw3.cjs +268 -0
- package/dist/image-jxPb-2iV.js +214 -0
- package/dist/mdx-BdWkJTeB.cjs +523 -0
- package/dist/mdx-UTTLFWJq.js +494 -0
- package/dist/node/cli-entry.cjs +1 -1
- package/dist/node/cli-entry.mjs +1 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.mjs +1 -1
- package/dist/{node-DtEDyN1u.cjs → node-BSM4qcDK.cjs} +1 -1
- package/dist/{node-_1jhMGYx.mjs → node-BspZN3R2.mjs} +1 -1
- package/dist/{package-DrwtlXfk.cjs → package-DIIrjuWI.cjs} +1 -1
- package/dist/{package--0Yf0t1N.mjs → package-K0zsjGIz.mjs} +1 -1
- package/dist/{search-dialog-ByvGScjt.js → search-dialog-BHuIiUC6.js} +3 -1
- package/dist/search-dialog-BNF10tDl.js +375 -0
- package/dist/search-dialog-BwkDuI9R.cjs +220 -0
- package/dist/search-dialog-C7xuvyNk.cjs +386 -0
- package/dist/search-dialog-CIQg6k8c.cjs +8 -0
- package/dist/search-dialog-D-DDN7zJ.js +208 -0
- package/package.json +3 -4
- package/dist/docs-layout-KoWNZc8_.js +0 -6
- package/dist/docs-layout-x2yKt2cL.cjs +0 -6
- package/dist/icons-dev-B_RZIyxu.js +0 -6
- package/dist/icons-dev-BlV3wWFT.cjs +0 -6
- package/dist/image-BHhTvQzr.cjs +0 -6
- package/dist/image-CqKzYD8f.js +0 -6
- package/dist/mdx-DudBEac0.js +0 -7
- package/dist/mdx-r4cDQxWu.cjs +0 -7
- package/dist/search-dialog-B584t9ZF.js +0 -6
- package/dist/search-dialog-BvBopRsZ.cjs +0 -6
- package/dist/search-dialog-Cyko6TJm.cjs +0 -6
- package/dist/search-dialog-D6BNohIJ.js +0 -6
- package/dist/search-dialog-DuYTIefy.cjs +0 -6
- package/src/client/app/config-context.tsx +0 -51
- package/src/client/app/doc-page.tsx +0 -38
- package/src/client/app/docs-layout.tsx +0 -28
- package/src/client/app/head.tsx +0 -122
- package/src/client/app/helmet-compat.tsx +0 -36
- package/src/client/app/mdx-component.tsx +0 -8
- package/src/client/app/mdx-components-context.tsx +0 -72
- package/src/client/app/routes-context.tsx +0 -34
- package/src/client/app/scroll-handler.tsx +0 -74
- package/src/client/app/theme-context.tsx +0 -103
- package/src/client/app/ui-context.tsx +0 -42
- package/src/client/components/docs-layout-default.tsx +0 -85
- package/src/client/components/icons-dev.tsx +0 -282
- package/src/client/components/mdx/callout.tsx +0 -97
- package/src/client/components/mdx/card.tsx +0 -99
- package/src/client/components/mdx/cards.tsx +0 -27
- package/src/client/components/mdx/code-block.tsx +0 -184
- package/src/client/components/mdx/field.tsx +0 -33
- package/src/client/components/mdx/image.tsx +0 -44
- package/src/client/components/mdx/index.ts +0 -19
- package/src/client/components/mdx/table.tsx +0 -54
- package/src/client/components/mdx/typographics.tsx +0 -120
- package/src/client/components/mdx/use-code-block.ts +0 -34
- package/src/client/components/primitives/breadcrumbs.tsx +0 -54
- package/src/client/components/primitives/button-group.tsx +0 -54
- package/src/client/components/primitives/button.tsx +0 -6
- package/src/client/components/primitives/code-block.tsx +0 -120
- package/src/client/components/primitives/docs-layout.tsx +0 -125
- package/src/client/components/primitives/error-boundary.tsx +0 -107
- package/src/client/components/primitives/heading.tsx +0 -128
- package/src/client/components/primitives/helpers/observer.ts +0 -141
- package/src/client/components/primitives/image.tsx +0 -26
- package/src/client/components/primitives/link.tsx +0 -102
- package/src/client/components/primitives/menu.tsx +0 -137
- package/src/client/components/primitives/navbar.tsx +0 -466
- package/src/client/components/primitives/on-this-page.tsx +0 -430
- package/src/client/components/primitives/page-nav.tsx +0 -51
- package/src/client/components/primitives/popover.tsx +0 -28
- package/src/client/components/primitives/search-dialog.tsx +0 -193
- package/src/client/components/primitives/sidebar.tsx +0 -423
- package/src/client/components/primitives/skeleton.tsx +0 -26
- package/src/client/components/primitives/tabs.tsx +0 -70
- package/src/client/components/primitives/tooltip.tsx +0 -81
- package/src/client/components/primitives/types.ts +0 -11
- package/src/client/components/ui-base/banner.tsx +0 -66
- package/src/client/components/ui-base/breadcrumbs.tsx +0 -44
- package/src/client/components/ui-base/copy-markdown.tsx +0 -107
- package/src/client/components/ui-base/error-boundary.tsx +0 -15
- package/src/client/components/ui-base/github-stars.tsx +0 -29
- package/src/client/components/ui-base/icons.tsx +0 -240
- package/src/client/components/ui-base/index.ts +0 -16
- package/src/client/components/ui-base/last-updated.tsx +0 -27
- package/src/client/components/ui-base/navbar.tsx +0 -266
- package/src/client/components/ui-base/not-found.tsx +0 -26
- package/src/client/components/ui-base/on-this-page.tsx +0 -57
- package/src/client/components/ui-base/page-nav.tsx +0 -50
- package/src/client/components/ui-base/search-dialog.tsx +0 -163
- package/src/client/components/ui-base/search-highlight.tsx +0 -10
- package/src/client/components/ui-base/sidebar.tsx +0 -92
- package/src/client/components/ui-base/tabs.tsx +0 -83
- package/src/client/components/ui-base/theme-toggle.tsx +0 -130
- package/src/client/components/ui-base/version-i18n.tsx +0 -80
- package/src/client/hooks/index.ts +0 -13
- package/src/client/hooks/use-analytics.ts +0 -272
- package/src/client/hooks/use-breadcrumbs.ts +0 -22
- package/src/client/hooks/use-i18n.ts +0 -182
- package/src/client/hooks/use-localized-to.ts +0 -113
- package/src/client/hooks/use-location.ts +0 -5
- package/src/client/hooks/use-navbar.ts +0 -130
- package/src/client/hooks/use-page-nav.ts +0 -46
- package/src/client/hooks/use-routes.ts +0 -108
- package/src/client/hooks/use-search-highlight.ts +0 -185
- package/src/client/hooks/use-search.ts +0 -118
- package/src/client/hooks/use-sidebar.ts +0 -205
- package/src/client/hooks/use-tabs.ts +0 -46
- package/src/client/hooks/use-version.ts +0 -111
- package/src/client/index.ts +0 -31
- package/src/client/mdx.ts +0 -2
- package/src/client/primitives.ts +0 -19
- package/src/client/ssg/boltdocs-shell.tsx +0 -148
- package/src/client/ssg/create-routes.tsx +0 -473
- package/src/client/ssg/index.ts +0 -4
- package/src/client/ssg/mdx-page.tsx +0 -38
- package/src/client/store/boltdocs-context.tsx +0 -137
- package/src/client/theme/neutral.css +0 -141
- package/src/client/theme/reset.css +0 -189
- package/src/client/types.ts +0 -116
- package/src/client/utils/cn.ts +0 -6
- package/src/client/utils/copy-clipboard.ts +0 -22
- package/src/client/utils/get-base-file-path.ts +0 -21
- package/src/client/utils/github.ts +0 -121
- package/src/client/utils/i18n.ts +0 -23
- package/src/client/utils/path.ts +0 -9
- package/src/client/utils/react-to-text.ts +0 -34
- package/src/client/virtual.d.ts +0 -24
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { useState, useRef } from 'react'
|
|
2
|
-
import { cn } from '../../utils/cn'
|
|
3
|
-
|
|
4
|
-
export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
-
title?: React.ReactNode
|
|
6
|
-
icon?: React.ReactNode
|
|
7
|
-
href?: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function Card({
|
|
11
|
-
className,
|
|
12
|
-
title,
|
|
13
|
-
icon,
|
|
14
|
-
href,
|
|
15
|
-
children,
|
|
16
|
-
...props
|
|
17
|
-
}: CardProps) {
|
|
18
|
-
const [position, setPosition] = useState({ x: 0, y: 0 })
|
|
19
|
-
const [opacity, setOpacity] = useState(0)
|
|
20
|
-
const cardRef = useRef<HTMLDivElement>(null)
|
|
21
|
-
|
|
22
|
-
const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
23
|
-
if (!cardRef.current) return
|
|
24
|
-
const rect = cardRef.current.getBoundingClientRect()
|
|
25
|
-
setPosition({ x: e.clientX - rect.left, y: e.clientY - rect.top })
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const handleMouseEnter = () => setOpacity(1)
|
|
29
|
-
const handleMouseLeave = () => setOpacity(0)
|
|
30
|
-
|
|
31
|
-
const Wrapper = href ? 'a' : 'div'
|
|
32
|
-
const spotlightColor = 'var(--color-primary-500, #eb5828)'
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<Wrapper
|
|
36
|
-
ref={cardRef}
|
|
37
|
-
href={href}
|
|
38
|
-
onMouseMove={handleMouseMove}
|
|
39
|
-
onMouseEnter={handleMouseEnter}
|
|
40
|
-
onMouseLeave={handleMouseLeave}
|
|
41
|
-
className={cn(
|
|
42
|
-
'group relative flex flex-col gap-3 rounded-2xl border p-6 overflow-hidden transition-all duration-300',
|
|
43
|
-
'hover:shadow-lg dark:hover:shadow-none hover:-translate-y-0.5',
|
|
44
|
-
'bg-surface border-subtle text-paragraph',
|
|
45
|
-
href && 'cursor-pointer',
|
|
46
|
-
className,
|
|
47
|
-
)}
|
|
48
|
-
{...(props as any)}
|
|
49
|
-
>
|
|
50
|
-
{/* Background Spotlight */}
|
|
51
|
-
<div
|
|
52
|
-
className="pointer-events-none absolute inset-0 transition-opacity duration-300"
|
|
53
|
-
style={{
|
|
54
|
-
opacity,
|
|
55
|
-
background: `radial-gradient(600px circle at ${position.x}px ${position.y}px, color-mix(in srgb, ${spotlightColor} 8%, transparent), transparent 40%)`,
|
|
56
|
-
}}
|
|
57
|
-
/>
|
|
58
|
-
{/* Border Spotlight Glow */}
|
|
59
|
-
<div
|
|
60
|
-
className="pointer-events-none absolute inset-0 rounded-2xl transition-opacity duration-300"
|
|
61
|
-
style={{
|
|
62
|
-
opacity,
|
|
63
|
-
padding: '1px',
|
|
64
|
-
background: `radial-gradient(400px circle at ${position.x}px ${position.y}px, color-mix(in srgb, ${spotlightColor} 50%, transparent), transparent 40%)`,
|
|
65
|
-
WebkitMask:
|
|
66
|
-
'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',
|
|
67
|
-
WebkitMaskComposite: 'xor',
|
|
68
|
-
maskComposite: 'exclude',
|
|
69
|
-
}}
|
|
70
|
-
/>
|
|
71
|
-
|
|
72
|
-
{/* Header Content */}
|
|
73
|
-
<div className="relative z-10 flex items-center gap-3">
|
|
74
|
-
{icon && (
|
|
75
|
-
<div
|
|
76
|
-
className={cn(
|
|
77
|
-
'shrink-0 transition-transform duration-500 group-hover:rotate-[15deg] group-hover:scale-110 flex items-center justify-center text-muted group-hover:text-primary-500',
|
|
78
|
-
'[&>svg]:w-6 [&>svg]:h-6 [&>svg]:stroke-[1.5]',
|
|
79
|
-
)}
|
|
80
|
-
>
|
|
81
|
-
{icon}
|
|
82
|
-
</div>
|
|
83
|
-
)}
|
|
84
|
-
{title && (
|
|
85
|
-
<h3 className="font-semibold text-base m-0 leading-none text-body">
|
|
86
|
-
{title}
|
|
87
|
-
</h3>
|
|
88
|
-
)}
|
|
89
|
-
</div>
|
|
90
|
-
|
|
91
|
-
{/* Body Content */}
|
|
92
|
-
<div className="relative z-10 text-[0.875rem] leading-[1.6] opacity-90 prose prose-neutral dark:prose-invert max-w-none [&>p]:m-0 [&>p+p]:mt-2">
|
|
93
|
-
{children}
|
|
94
|
-
</div>
|
|
95
|
-
</Wrapper>
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export default Card
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { cn } from '../../utils/cn'
|
|
2
|
-
|
|
3
|
-
export interface CardsProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
-
cols?: 1 | 2 | 3 | 4
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function Cards({ children, className, cols = 2, ...props }: CardsProps) {
|
|
8
|
-
return (
|
|
9
|
-
<div
|
|
10
|
-
className={cn(
|
|
11
|
-
'grid gap-4 my-6',
|
|
12
|
-
{
|
|
13
|
-
'grid-cols-1': cols === 1,
|
|
14
|
-
'grid-cols-1 sm:grid-cols-2': cols === 2,
|
|
15
|
-
'grid-cols-1 sm:grid-cols-2 md:grid-cols-3': cols === 3,
|
|
16
|
-
'grid-cols-1 sm:grid-cols-2 lg:grid-cols-4': cols === 4,
|
|
17
|
-
},
|
|
18
|
-
className,
|
|
19
|
-
)}
|
|
20
|
-
{...props}
|
|
21
|
-
>
|
|
22
|
-
{children}
|
|
23
|
-
</div>
|
|
24
|
-
)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default Cards
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { Button } from 'react-aria-components'
|
|
2
|
-
import { Copy, Check, File } from '../ui-base/icons'
|
|
3
|
-
import { cn } from '../../utils/cn'
|
|
4
|
-
import { reactToText } from '../../utils/react-to-text'
|
|
5
|
-
import { useCodeBlock } from './use-code-block'
|
|
6
|
-
import * as CodePrimitive from '../primitives/code-block'
|
|
7
|
-
import {
|
|
8
|
-
TypeScript,
|
|
9
|
-
JavaScript,
|
|
10
|
-
React as ReactIcon,
|
|
11
|
-
Json,
|
|
12
|
-
Css,
|
|
13
|
-
BracketsOrange,
|
|
14
|
-
Markdown,
|
|
15
|
-
Shell,
|
|
16
|
-
Yaml,
|
|
17
|
-
Rust,
|
|
18
|
-
BracketsRed,
|
|
19
|
-
Csv,
|
|
20
|
-
} from '../icons-dev'
|
|
21
|
-
import { Tooltip } from '../primitives/tooltip'
|
|
22
|
-
|
|
23
|
-
const langIconMap: Record<string, React.ComponentType<{ size?: number }>> = {
|
|
24
|
-
ts: TypeScript,
|
|
25
|
-
tsx: ReactIcon,
|
|
26
|
-
js: JavaScript,
|
|
27
|
-
jsx: ReactIcon,
|
|
28
|
-
json: Json,
|
|
29
|
-
css: Css,
|
|
30
|
-
html: BracketsOrange,
|
|
31
|
-
md: Markdown,
|
|
32
|
-
mdx: Markdown,
|
|
33
|
-
bash: Shell,
|
|
34
|
-
sh: Shell,
|
|
35
|
-
yaml: Yaml,
|
|
36
|
-
yml: Yaml,
|
|
37
|
-
rs: Rust,
|
|
38
|
-
rust: Rust,
|
|
39
|
-
toml: BracketsRed,
|
|
40
|
-
csv: Csv,
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface CodeBlockProps {
|
|
44
|
-
children?: React.ReactNode
|
|
45
|
-
className?: string
|
|
46
|
-
hideCopy?: boolean
|
|
47
|
-
title?: string
|
|
48
|
-
lang?: string
|
|
49
|
-
highlightedHtml?: string
|
|
50
|
-
'data-lang'?: string
|
|
51
|
-
'data-title'?: string
|
|
52
|
-
plain?: boolean
|
|
53
|
-
[key: string]: any
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const CopyButton = ({
|
|
57
|
-
copied,
|
|
58
|
-
handleCopy,
|
|
59
|
-
}: {
|
|
60
|
-
copied: boolean
|
|
61
|
-
handleCopy: () => void
|
|
62
|
-
}) => {
|
|
63
|
-
return (
|
|
64
|
-
<Tooltip content={copied ? 'Copied!' : 'Copy code'}>
|
|
65
|
-
{/* @ts-ignore */}
|
|
66
|
-
<Button
|
|
67
|
-
onPress={handleCopy}
|
|
68
|
-
className={cn(
|
|
69
|
-
'grid place-items-center size-8 bg-transparent outline-none cursor-pointer transition-all duration-200 hover:scale-110 active:scale-95 [&>svg]:size-4 [&>svg]:stroke-2 z-10',
|
|
70
|
-
copied ? 'text-emerald-400' : 'text-muted hover:text-body',
|
|
71
|
-
)}
|
|
72
|
-
aria-label="Copy code"
|
|
73
|
-
>
|
|
74
|
-
{/* @ts-ignore */}
|
|
75
|
-
{copied ? <Check size={20} /> : <Copy size={20} />}
|
|
76
|
-
</Button>
|
|
77
|
-
</Tooltip>
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function CodeBlock(props: CodeBlockProps) {
|
|
82
|
-
const {
|
|
83
|
-
children,
|
|
84
|
-
hideCopy = false,
|
|
85
|
-
highlightedHtml,
|
|
86
|
-
'data-highlighted-html': dataHighlightedHtml,
|
|
87
|
-
title,
|
|
88
|
-
'data-title': dataTitle,
|
|
89
|
-
'data-lang': dataLang,
|
|
90
|
-
plain = false,
|
|
91
|
-
...rest
|
|
92
|
-
} = props
|
|
93
|
-
|
|
94
|
-
const rawHighlightedHtml = highlightedHtml || dataHighlightedHtml
|
|
95
|
-
const effectiveHighlightedHtml =
|
|
96
|
-
typeof rawHighlightedHtml === 'string'
|
|
97
|
-
? rawHighlightedHtml.replace(
|
|
98
|
-
/<span class="line">\s*(?:<span[^>]*>\s*<\/span>)?\s*<\/span>\s*(<\/code>\s*<\/pre>)/g,
|
|
99
|
-
'$1',
|
|
100
|
-
)
|
|
101
|
-
: rawHighlightedHtml
|
|
102
|
-
const effectiveTitle = title || dataTitle
|
|
103
|
-
const lang = props.lang || dataLang || ''
|
|
104
|
-
|
|
105
|
-
const {
|
|
106
|
-
copied,
|
|
107
|
-
isExpanded,
|
|
108
|
-
setIsExpanded,
|
|
109
|
-
isExpandable,
|
|
110
|
-
preRef,
|
|
111
|
-
handleCopy,
|
|
112
|
-
shouldTruncate,
|
|
113
|
-
} = useCodeBlock(props)
|
|
114
|
-
|
|
115
|
-
const LangIcon = langIconMap[lang]
|
|
116
|
-
|
|
117
|
-
return (
|
|
118
|
-
<CodePrimitive.CodeBlock plain={plain} className={props.className}>
|
|
119
|
-
{(effectiveTitle || !hideCopy) && (
|
|
120
|
-
<CodePrimitive.CodeBlockHeader
|
|
121
|
-
className={cn({
|
|
122
|
-
'absolute top-2 left-0 w-full': !effectiveTitle,
|
|
123
|
-
})}
|
|
124
|
-
>
|
|
125
|
-
<CodePrimitive.CodeBlockGroup>
|
|
126
|
-
{effectiveTitle && (
|
|
127
|
-
<>
|
|
128
|
-
{LangIcon ? (
|
|
129
|
-
<LangIcon size={14} />
|
|
130
|
-
) : (
|
|
131
|
-
<File size={14} className="opacity-60" />
|
|
132
|
-
)}
|
|
133
|
-
<span>{effectiveTitle}</span>
|
|
134
|
-
</>
|
|
135
|
-
)}
|
|
136
|
-
</CodePrimitive.CodeBlockGroup>
|
|
137
|
-
<div className="flex items-center gap-1">
|
|
138
|
-
{!hideCopy && (
|
|
139
|
-
<CopyButton copied={copied} handleCopy={handleCopy} />
|
|
140
|
-
)}
|
|
141
|
-
</div>
|
|
142
|
-
</CodePrimitive.CodeBlockHeader>
|
|
143
|
-
)}
|
|
144
|
-
|
|
145
|
-
<CodePrimitive.CodeBlockContent shouldTruncate={shouldTruncate}>
|
|
146
|
-
{effectiveHighlightedHtml ? (
|
|
147
|
-
<div
|
|
148
|
-
// @ts-expect-error
|
|
149
|
-
ref={preRef}
|
|
150
|
-
className="shiki-wrapper overflow-x-auto [&>pre]:m-0! [&>pre]:rounded-none! [&>pre]:border-none! [&>pre]:bg-inherit! [&>pre>code]:grid! [&>pre>code]:p-5! [&>pre>code]:text-[0.875rem]! [&>pre>code]:leading-[1.6]! [&>.shiki.shiki-themes]:bg-transparent!"
|
|
151
|
-
dangerouslySetInnerHTML={{ __html: effectiveHighlightedHtml }}
|
|
152
|
-
/>
|
|
153
|
-
) : (
|
|
154
|
-
<pre
|
|
155
|
-
ref={preRef}
|
|
156
|
-
className="m-0! p-5! rounded-none! border-none! bg-inherit! font-mono text-[0.875rem] leading-[1.6] overflow-x-auto"
|
|
157
|
-
{...rest}
|
|
158
|
-
>
|
|
159
|
-
{reactToText(children).trimEnd()}
|
|
160
|
-
</pre>
|
|
161
|
-
)}
|
|
162
|
-
|
|
163
|
-
{/* Expand/Collapse Trigger */}
|
|
164
|
-
{isExpandable && (
|
|
165
|
-
<div
|
|
166
|
-
className={cn(
|
|
167
|
-
shouldTruncate
|
|
168
|
-
? 'absolute bottom-0 inset-x-0 h-24 bg-linear-to-t from-(--color-code-bg) to-transparent flex items-end justify-center pb-4 z-10'
|
|
169
|
-
: 'relative flex justify-center pb-4 pt-1 -mt-4',
|
|
170
|
-
)}
|
|
171
|
-
>
|
|
172
|
-
{/* @ts-ignore */}
|
|
173
|
-
<Button
|
|
174
|
-
onPress={() => setIsExpanded(!isExpanded)}
|
|
175
|
-
className="rounded-full bg-surface border border-subtle px-5 py-2 text-[0.8125rem] font-medium text-body outline-none cursor-pointer transition-all hover:bg-soft hover:-translate-y-px backdrop-blur-md"
|
|
176
|
-
>
|
|
177
|
-
{isExpanded ? 'Show less' : 'Expand code'}
|
|
178
|
-
</Button>
|
|
179
|
-
</div>
|
|
180
|
-
)}
|
|
181
|
-
</CodePrimitive.CodeBlockContent>
|
|
182
|
-
</CodePrimitive.CodeBlock>
|
|
183
|
-
)
|
|
184
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export interface FieldProps {
|
|
2
|
-
children?: React.ReactNode
|
|
3
|
-
name: string
|
|
4
|
-
type?: string
|
|
5
|
-
description?: string
|
|
6
|
-
required?: boolean
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const Field = ({
|
|
10
|
-
children,
|
|
11
|
-
name,
|
|
12
|
-
type,
|
|
13
|
-
description,
|
|
14
|
-
required,
|
|
15
|
-
}: FieldProps) => (
|
|
16
|
-
<div className="my-4 border border-subtle bg-surface/50 p-4 rounded-xl flex flex-col gap-1 text-sm select-none">
|
|
17
|
-
<div className="flex items-center gap-2">
|
|
18
|
-
<span className="font-mono font-bold text-primary-500">{name}</span>
|
|
19
|
-
{type && (
|
|
20
|
-
<span className="text-xs text-muted font-mono bg-soft px-1.5 py-0.5 rounded-md">
|
|
21
|
-
{type}
|
|
22
|
-
</span>
|
|
23
|
-
)}
|
|
24
|
-
{required && (
|
|
25
|
-
<span className="text-xs text-rose-500 font-semibold">required</span>
|
|
26
|
-
)}
|
|
27
|
-
</div>
|
|
28
|
-
{description && (
|
|
29
|
-
<div className="text-muted text-xs mt-1">{description}</div>
|
|
30
|
-
)}
|
|
31
|
-
{children && <div className="mt-2">{children}</div>}
|
|
32
|
-
</div>
|
|
33
|
-
)
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { useTheme } from '../../app/theme-context'
|
|
2
|
-
import { cn } from '../../utils/cn'
|
|
3
|
-
import { Image as ImagePrimitive } from '../primitives/image'
|
|
4
|
-
|
|
5
|
-
export interface ImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
|
|
6
|
-
theme?: 'light' | 'dark'
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const Image = ({ src, alt, title, theme, className, ...props }: ImageProps) => {
|
|
10
|
-
const { theme: themeContext } = useTheme()
|
|
11
|
-
if (!src) return null
|
|
12
|
-
if (theme !== themeContext) return null
|
|
13
|
-
|
|
14
|
-
const caption = title || alt
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<figure className="my-6 sm:my-8 flex flex-col items-center justify-center group not-prose">
|
|
18
|
-
<div className="relative w-full overflow-hidden rounded-lg sm:rounded-2xl border border-subtle bg-soft/30 transition-all duration-300 sm:max-w-[85%] lg:max-w-full">
|
|
19
|
-
<ImagePrimitive
|
|
20
|
-
src={src}
|
|
21
|
-
alt={alt || ''}
|
|
22
|
-
theme={theme}
|
|
23
|
-
loading="lazy"
|
|
24
|
-
decoding="async"
|
|
25
|
-
className={cn(
|
|
26
|
-
'w-full h-auto object-contain transition-transform duration-500 group-hover:scale-[1.01] my-0 rounded-md sm:rounded-xl block',
|
|
27
|
-
className,
|
|
28
|
-
)}
|
|
29
|
-
{...props}
|
|
30
|
-
/>
|
|
31
|
-
</div>
|
|
32
|
-
{caption && (
|
|
33
|
-
<figcaption className="mt-2 sm:mt-3 text-center text-xs sm:text-sm text-muted font-medium select-none tracking-wide opacity-90 sm:opacity-80 group-hover:opacity-100 transition-opacity duration-300 px-2">
|
|
34
|
-
{caption}
|
|
35
|
-
</figcaption>
|
|
36
|
-
)}
|
|
37
|
-
</figure>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const ImageComponents = {
|
|
42
|
-
img: Image,
|
|
43
|
-
Image,
|
|
44
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Field } from './field'
|
|
2
|
-
import { Typographics } from './typographics'
|
|
3
|
-
import { TableComponents } from './table'
|
|
4
|
-
import { Callout } from './callout'
|
|
5
|
-
import { CodeBlock } from './code-block'
|
|
6
|
-
import { ImageComponents } from './image'
|
|
7
|
-
import { Card } from './card'
|
|
8
|
-
import { Cards } from './cards'
|
|
9
|
-
|
|
10
|
-
export const mdx_components_default = {
|
|
11
|
-
...Typographics,
|
|
12
|
-
...TableComponents,
|
|
13
|
-
...ImageComponents,
|
|
14
|
-
pre: CodeBlock,
|
|
15
|
-
Field,
|
|
16
|
-
Callout,
|
|
17
|
-
Card,
|
|
18
|
-
Cards,
|
|
19
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { cn } from '../../utils/cn'
|
|
2
|
-
|
|
3
|
-
const Table = (props: React.HTMLAttributes<HTMLTableElement>) => (
|
|
4
|
-
<div className="my-6 w-full overflow-x-auto rounded-xl border border-subtle bg-surface/30">
|
|
5
|
-
<table className="w-full border-collapse text-left text-sm" {...props} />
|
|
6
|
-
</div>
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
const TableHead = (props: React.HTMLAttributes<HTMLTableSectionElement>) => (
|
|
10
|
-
<thead
|
|
11
|
-
className={cn('border-b border-subtle bg-soft/50', props.className)}
|
|
12
|
-
{...props}
|
|
13
|
-
/>
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
const TableBody = (props: React.HTMLAttributes<HTMLTableSectionElement>) => (
|
|
17
|
-
<tbody {...props} />
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
const TableRow = (props: React.HTMLAttributes<HTMLTableRowElement>) => (
|
|
21
|
-
<tr
|
|
22
|
-
className={cn(
|
|
23
|
-
'border-b border-subtle last:border-0 even:bg-soft/10 hover:bg-soft/20 transition-colors',
|
|
24
|
-
props.className,
|
|
25
|
-
)}
|
|
26
|
-
{...props}
|
|
27
|
-
/>
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
const TableHeader = (props: React.HTMLAttributes<HTMLTableCellElement>) => (
|
|
31
|
-
<th
|
|
32
|
-
className={cn(
|
|
33
|
-
'px-4 py-3 font-semibold text-body text-xs font-mono',
|
|
34
|
-
props.className,
|
|
35
|
-
)}
|
|
36
|
-
{...props}
|
|
37
|
-
/>
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
const TableCell = (props: React.HTMLAttributes<HTMLTableCellElement>) => (
|
|
41
|
-
<td
|
|
42
|
-
className={cn('px-4 py-3 text-paragraph leading-relaxed', props.className)}
|
|
43
|
-
{...props}
|
|
44
|
-
/>
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
export const TableComponents = {
|
|
48
|
-
table: Table,
|
|
49
|
-
thead: TableHead,
|
|
50
|
-
tbody: TableBody,
|
|
51
|
-
tr: TableRow,
|
|
52
|
-
th: TableHeader,
|
|
53
|
-
td: TableCell,
|
|
54
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { Link } from '../primitives/link'
|
|
2
|
-
import { cn } from '../../utils/cn'
|
|
3
|
-
import { Heading as HeadingPrimitive } from '../primitives/heading'
|
|
4
|
-
|
|
5
|
-
const Anchor = ({
|
|
6
|
-
href,
|
|
7
|
-
children,
|
|
8
|
-
className,
|
|
9
|
-
...props
|
|
10
|
-
}: React.AnchorHTMLAttributes<HTMLAnchorElement>) => {
|
|
11
|
-
return (
|
|
12
|
-
<Link
|
|
13
|
-
href={href || ''}
|
|
14
|
-
className={cn(
|
|
15
|
-
'text-primary-500 hover:text-primary-400 dark:text-primary-500 hover:underline font-medium transition-colors duration-200',
|
|
16
|
-
className,
|
|
17
|
-
)}
|
|
18
|
-
{...props}
|
|
19
|
-
>
|
|
20
|
-
{children}
|
|
21
|
-
</Link>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const HEADING_CLASSES: Record<number, string> = {
|
|
26
|
-
1: 'text-3xl sm:text-[2.5rem] font-extrabold tracking-tight text-body mb-4 leading-tight',
|
|
27
|
-
2: 'text-2xl sm:text-[1.75rem] font-bold tracking-tight text-body mt-14 mb-5 pb-2 border-b border-subtle scroll-mt-24',
|
|
28
|
-
3: 'text-lg sm:text-[1.4rem] font-semibold tracking-tight text-body mt-10 mb-4 scroll-mt-24',
|
|
29
|
-
4: 'text-base sm:text-[1.1rem] font-semibold tracking-tight text-body mt-8 mb-3 scroll-mt-24',
|
|
30
|
-
5: 'text-sm sm:text-[0.9rem] font-semibold tracking-tight text-body mt-6 mb-2 scroll-mt-24',
|
|
31
|
-
6: 'text-xs sm:text-[0.75rem] font-semibold tracking-tight text-body mt-6 mb-2 scroll-mt-24',
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const Heading = ({
|
|
35
|
-
level,
|
|
36
|
-
className,
|
|
37
|
-
...props
|
|
38
|
-
}: React.ComponentProps<typeof HeadingPrimitive>) => {
|
|
39
|
-
const headingClass = HEADING_CLASSES[level] || ''
|
|
40
|
-
return (
|
|
41
|
-
<HeadingPrimitive
|
|
42
|
-
level={level}
|
|
43
|
-
className={cn(headingClass, className)}
|
|
44
|
-
{...props}
|
|
45
|
-
/>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const Typographics = {
|
|
50
|
-
a: Anchor,
|
|
51
|
-
h1: (props: React.HTMLAttributes<HTMLHeadingElement>) => (
|
|
52
|
-
<Heading level={1} {...props} />
|
|
53
|
-
),
|
|
54
|
-
h2: (props: React.HTMLAttributes<HTMLHeadingElement>) => (
|
|
55
|
-
<Heading level={2} {...props} />
|
|
56
|
-
),
|
|
57
|
-
h3: (props: React.HTMLAttributes<HTMLHeadingElement>) => (
|
|
58
|
-
<Heading level={3} {...props} />
|
|
59
|
-
),
|
|
60
|
-
h4: (props: React.HTMLAttributes<HTMLHeadingElement>) => (
|
|
61
|
-
<Heading level={4} {...props} />
|
|
62
|
-
),
|
|
63
|
-
h5: (props: React.HTMLAttributes<HTMLHeadingElement>) => (
|
|
64
|
-
<Heading level={5} {...props} />
|
|
65
|
-
),
|
|
66
|
-
h6: (props: React.HTMLAttributes<HTMLHeadingElement>) => (
|
|
67
|
-
<Heading level={6} {...props} />
|
|
68
|
-
),
|
|
69
|
-
p: ({ className, ...props }: React.HTMLAttributes<HTMLParagraphElement>) => (
|
|
70
|
-
<p
|
|
71
|
-
className={cn('text-paragraph leading-relaxed my-5', className)}
|
|
72
|
-
{...props}
|
|
73
|
-
/>
|
|
74
|
-
),
|
|
75
|
-
strong: ({ className, ...props }: React.HTMLAttributes<HTMLElement>) => (
|
|
76
|
-
<strong className={cn('font-semibold text-body', className)} {...props} />
|
|
77
|
-
),
|
|
78
|
-
mark: ({ className, ...props }: React.HTMLAttributes<HTMLElement>) => (
|
|
79
|
-
<mark
|
|
80
|
-
className={cn(
|
|
81
|
-
'bg-primary-500/10 text-primary-500 font-semibold px-1.5 py-0.5 rounded-md',
|
|
82
|
-
className,
|
|
83
|
-
)}
|
|
84
|
-
{...props}
|
|
85
|
-
/>
|
|
86
|
-
),
|
|
87
|
-
blockquote: ({
|
|
88
|
-
className,
|
|
89
|
-
...props
|
|
90
|
-
}: React.HTMLAttributes<HTMLQuoteElement>) => (
|
|
91
|
-
<blockquote
|
|
92
|
-
className={cn(
|
|
93
|
-
'border-l-4 border-primary-500 bg-soft/30 pl-4 py-2 my-6 italic text-muted rounded-r-lg',
|
|
94
|
-
className,
|
|
95
|
-
)}
|
|
96
|
-
{...props}
|
|
97
|
-
/>
|
|
98
|
-
),
|
|
99
|
-
hr: ({ className, ...props }: React.HTMLAttributes<HTMLHRElement>) => (
|
|
100
|
-
<hr className={cn('my-8 border-t border-subtle', className)} {...props} />
|
|
101
|
-
),
|
|
102
|
-
ul: ({ className, ...props }: React.HTMLAttributes<HTMLUListElement>) => (
|
|
103
|
-
<ul
|
|
104
|
-
className={cn('list-disc pl-6 my-5 space-y-2 text-paragraph', className)}
|
|
105
|
-
{...props}
|
|
106
|
-
/>
|
|
107
|
-
),
|
|
108
|
-
ol: ({ className, ...props }: React.HTMLAttributes<HTMLOListElement>) => (
|
|
109
|
-
<ol
|
|
110
|
-
className={cn(
|
|
111
|
-
'list-decimal pl-6 my-5 space-y-2 text-paragraph',
|
|
112
|
-
className,
|
|
113
|
-
)}
|
|
114
|
-
{...props}
|
|
115
|
-
/>
|
|
116
|
-
),
|
|
117
|
-
li: ({ className, ...props }: React.HTMLAttributes<HTMLLIElement>) => (
|
|
118
|
-
<li className={cn('pl-1', className)} {...props} />
|
|
119
|
-
),
|
|
120
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { copyToClipboard } from '../../utils/copy-clipboard'
|
|
2
|
-
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
3
|
-
import type { CodeBlockProps } from './code-block'
|
|
4
|
-
|
|
5
|
-
export function useCodeBlock(props: CodeBlockProps) {
|
|
6
|
-
const [copied, setCopied] = useState(false)
|
|
7
|
-
const [isExpanded, setIsExpanded] = useState(false)
|
|
8
|
-
const [isExpandable, setIsExpandable] = useState(false)
|
|
9
|
-
const preRef = useRef<HTMLPreElement>(null)
|
|
10
|
-
|
|
11
|
-
const handleCopy = useCallback(async () => {
|
|
12
|
-
const code = preRef.current?.textContent ?? ''
|
|
13
|
-
copyToClipboard(code)
|
|
14
|
-
setCopied(true)
|
|
15
|
-
setTimeout(() => setCopied(false), 2000)
|
|
16
|
-
}, [])
|
|
17
|
-
|
|
18
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: updates when content changes
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
const code = preRef.current?.textContent ?? ''
|
|
21
|
-
const lines = code.trim().split('\n').length
|
|
22
|
-
setIsExpandable(lines > 6)
|
|
23
|
-
}, [props.children, props.highlightedHtml])
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
copied,
|
|
27
|
-
isExpanded,
|
|
28
|
-
setIsExpanded,
|
|
29
|
-
isExpandable,
|
|
30
|
-
preRef,
|
|
31
|
-
handleCopy,
|
|
32
|
-
shouldTruncate: isExpandable && !isExpanded,
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Breadcrumb,
|
|
3
|
-
Breadcrumbs as BreadcrumbsRAC,
|
|
4
|
-
} from 'react-aria-components'
|
|
5
|
-
import { Link } from './link'
|
|
6
|
-
import type { LinkProps } from 'react-aria-components'
|
|
7
|
-
import { ChevronRight } from '../ui-base/icons'
|
|
8
|
-
import { cn } from '../../utils/cn'
|
|
9
|
-
import type { ComponentBase } from './types'
|
|
10
|
-
|
|
11
|
-
export const Breadcrumbs = ({
|
|
12
|
-
children,
|
|
13
|
-
className,
|
|
14
|
-
...props
|
|
15
|
-
}: ComponentBase) => {
|
|
16
|
-
return (
|
|
17
|
-
<BreadcrumbsRAC
|
|
18
|
-
className={cn('flex flex-wrap items-center', className)}
|
|
19
|
-
{...props}
|
|
20
|
-
>
|
|
21
|
-
{children as any}
|
|
22
|
-
</BreadcrumbsRAC>
|
|
23
|
-
)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const BreadcrumbsItem = ({ children, className, ...props }: ComponentBase) => {
|
|
27
|
-
return (
|
|
28
|
-
<Breadcrumb className={cn('flex items-center', className)} {...props}>
|
|
29
|
-
{children as any}
|
|
30
|
-
</Breadcrumb>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const BreadcrumbsLink = ({
|
|
35
|
-
children,
|
|
36
|
-
href,
|
|
37
|
-
className,
|
|
38
|
-
...props
|
|
39
|
-
}: LinkProps & { className?: string }) => {
|
|
40
|
-
return (
|
|
41
|
-
<Link href={href} className={cn('cursor-pointer', className)} {...props}>
|
|
42
|
-
{children as any}
|
|
43
|
-
</Link>
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const BreadcrumbsSeparator = ({ className }: ComponentBase) => {
|
|
48
|
-
return <ChevronRight size={14} className={cn('shrink-0', className)} />
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
Breadcrumbs.Root = Breadcrumbs
|
|
52
|
-
Breadcrumbs.Item = BreadcrumbsItem
|
|
53
|
-
Breadcrumbs.Link = BreadcrumbsLink
|
|
54
|
-
Breadcrumbs.Separator = BreadcrumbsSeparator
|