boltdocs 2.7.10 → 2.8.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.
Files changed (193) hide show
  1. package/README.md +2 -2
  2. package/dist/banner-3N4Jd_L9.d.ts +100 -0
  3. package/dist/banner-MynZD_Ox.d.cts +100 -0
  4. package/dist/cache-BMUyNiiA.mjs +6 -0
  5. package/dist/cache-CKm45d2w.cjs +6 -0
  6. package/dist/client/index.cjs +2268 -1
  7. package/dist/client/index.d.cts +86 -110
  8. package/dist/client/index.d.ts +87 -111
  9. package/dist/client/index.js +2214 -1
  10. package/dist/client/mdx.cjs +12 -1
  11. package/dist/client/mdx.d.cts +39 -93
  12. package/dist/client/mdx.d.ts +38 -93
  13. package/dist/client/mdx.js +7 -1
  14. package/dist/client/primitives.cjs +60 -1
  15. package/dist/client/primitives.d.cts +411 -347
  16. package/dist/client/primitives.d.ts +411 -347
  17. package/dist/client/primitives.js +20 -1
  18. package/dist/docs-layout-CwCq42Zt.cjs +1348 -0
  19. package/dist/docs-layout-Dn6S5g59.js +1167 -0
  20. package/dist/doctor-BArviV8X.cjs +28 -0
  21. package/dist/doctor-CgLA7_Uv.mjs +28 -0
  22. package/dist/{doctor-CrytFkqW.cjs → doctor-DyNUVe96.cjs} +1 -1
  23. package/dist/{routes-DP1vmWRj.cjs → doctor-aN_leTbh.mjs} +1 -1
  24. package/dist/{generator-ClVanhvi.mjs → generator-BHCrLU6h.mjs} +2 -2
  25. package/dist/{generator-CHqxiQhF.cjs → generator-CC2yHzhZ.cjs} +2 -2
  26. package/dist/icons-dev-DvJ-hh9x.cjs +1209 -0
  27. package/dist/icons-dev-Oju24Wjp.js +845 -0
  28. package/dist/image-Ch4-GxdO.cjs +268 -0
  29. package/dist/image-Do8V9PCW.js +214 -0
  30. package/dist/mdx-D3A2_l7P.js +520 -0
  31. package/dist/mdx-PLhhPJRS.cjs +531 -0
  32. package/dist/node/cli-entry.cjs +3 -1
  33. package/dist/node/cli-entry.mjs +3 -1
  34. package/dist/node/index.cjs +1 -1
  35. package/dist/node/index.d.cts +258 -152
  36. package/dist/node/index.d.mts +258 -150
  37. package/dist/node/index.mjs +1 -1
  38. package/dist/node/routes/worker.cjs +1 -1
  39. package/dist/node/routes/worker.mjs +1 -1
  40. package/dist/node-BmlP0eBP.cjs +159 -0
  41. package/dist/node-Y8_4ayje.mjs +159 -0
  42. package/dist/package-2nFy_NsW.cjs +6 -0
  43. package/dist/{package--0Yf0t1N.mjs → package-DAbtltXX.mjs} +1 -1
  44. package/dist/parser-B7-6PyQz.cjs +6 -0
  45. package/dist/{parser-Aq8LoH-0.cjs → parser-BzB-zCkF.cjs} +1 -1
  46. package/dist/parser-WGZdWs0X.mjs +6 -0
  47. package/dist/routes-BDDSxAl0.mjs +6 -0
  48. package/dist/routes-DJNJ-rTt.cjs +6 -0
  49. package/dist/routes-DiYC4nD2.cjs +6 -0
  50. package/dist/routes-_Bb2f4eI.mjs +6 -0
  51. package/dist/search-dialog-BXVoecTx.cjs +483 -0
  52. package/dist/search-dialog-BYhOov4S.cjs +331 -0
  53. package/dist/search-dialog-C09riYmx.js +313 -0
  54. package/dist/search-dialog-CUeAfy-8.cjs +8 -0
  55. package/dist/search-dialog-D8gLkhUV.js +453 -0
  56. package/dist/search-dialog-DHc_8FFX.js +8 -0
  57. package/dist/{sidebar-CcBkrm06.d.cts → sidebar-DNq4_ZAa.d.ts} +118 -52
  58. package/dist/{sidebar-CyZS9YOm.d.ts → sidebar-Dlkgbxs6.d.cts} +118 -52
  59. package/dist/utils-BYITg7T5.mjs +7 -0
  60. package/dist/utils-Cjmx1hhk.cjs +7 -0
  61. package/dist/worker-pool-CtqklOXq.cjs +6 -0
  62. package/dist/worker-pool-k0DY6k8T.mjs +6 -0
  63. package/package.json +5 -6
  64. package/src/shared/config-utils.ts +4 -0
  65. package/src/shared/types.ts +52 -6
  66. package/dist/cache-Ba-DZQNH.cjs +0 -6
  67. package/dist/cache-BuMZ58L5.mjs +0 -6
  68. package/dist/cards-BakZPTz9.d.ts +0 -30
  69. package/dist/cards-CQn9mXZS.d.cts +0 -30
  70. package/dist/docs-layout-KoWNZc8_.js +0 -6
  71. package/dist/docs-layout-x2yKt2cL.cjs +0 -6
  72. package/dist/doctor-Be7Ly1oM.mjs +0 -21
  73. package/dist/doctor-jMxWZyLJ.cjs +0 -21
  74. package/dist/icons-dev-B_RZIyxu.js +0 -6
  75. package/dist/icons-dev-BlV3wWFT.cjs +0 -6
  76. package/dist/image-BHhTvQzr.cjs +0 -6
  77. package/dist/image-CqKzYD8f.js +0 -6
  78. package/dist/mdx-DudBEac0.js +0 -7
  79. package/dist/mdx-r4cDQxWu.cjs +0 -7
  80. package/dist/node-DtEDyN1u.cjs +0 -111
  81. package/dist/node-_1jhMGYx.mjs +0 -111
  82. package/dist/package-DrwtlXfk.cjs +0 -6
  83. package/dist/parser-CdNbqN5y.cjs +0 -6
  84. package/dist/parser-nE792MLO.mjs +0 -6
  85. package/dist/rolldown-runtime-fkIsjY3S.mjs +0 -6
  86. package/dist/routes-2k3tbUmC.cjs +0 -6
  87. package/dist/routes-CpxZIsMM.mjs +0 -6
  88. package/dist/search-dialog-B584t9ZF.js +0 -6
  89. package/dist/search-dialog-BvBopRsZ.cjs +0 -6
  90. package/dist/search-dialog-ByvGScjt.js +0 -6
  91. package/dist/search-dialog-Cyko6TJm.cjs +0 -6
  92. package/dist/search-dialog-D6BNohIJ.js +0 -6
  93. package/dist/search-dialog-DuYTIefy.cjs +0 -6
  94. package/dist/utils-CG65J0Sc.mjs +0 -7
  95. package/dist/utils-CKunkU96.cjs +0 -7
  96. package/dist/worker-pool-CGn7DrLb.mjs +0 -6
  97. package/dist/worker-pool-Crbqgw5R.cjs +0 -6
  98. package/src/client/app/config-context.tsx +0 -51
  99. package/src/client/app/doc-page.tsx +0 -38
  100. package/src/client/app/docs-layout.tsx +0 -28
  101. package/src/client/app/head.tsx +0 -122
  102. package/src/client/app/helmet-compat.tsx +0 -36
  103. package/src/client/app/mdx-component.tsx +0 -8
  104. package/src/client/app/mdx-components-context.tsx +0 -72
  105. package/src/client/app/routes-context.tsx +0 -34
  106. package/src/client/app/scroll-handler.tsx +0 -74
  107. package/src/client/app/theme-context.tsx +0 -103
  108. package/src/client/app/ui-context.tsx +0 -42
  109. package/src/client/components/docs-layout-default.tsx +0 -85
  110. package/src/client/components/icons-dev.tsx +0 -282
  111. package/src/client/components/mdx/callout.tsx +0 -97
  112. package/src/client/components/mdx/card.tsx +0 -99
  113. package/src/client/components/mdx/cards.tsx +0 -27
  114. package/src/client/components/mdx/code-block.tsx +0 -184
  115. package/src/client/components/mdx/field.tsx +0 -33
  116. package/src/client/components/mdx/image.tsx +0 -44
  117. package/src/client/components/mdx/index.ts +0 -19
  118. package/src/client/components/mdx/table.tsx +0 -54
  119. package/src/client/components/mdx/typographics.tsx +0 -120
  120. package/src/client/components/mdx/use-code-block.ts +0 -34
  121. package/src/client/components/primitives/breadcrumbs.tsx +0 -54
  122. package/src/client/components/primitives/button-group.tsx +0 -54
  123. package/src/client/components/primitives/button.tsx +0 -6
  124. package/src/client/components/primitives/code-block.tsx +0 -120
  125. package/src/client/components/primitives/docs-layout.tsx +0 -125
  126. package/src/client/components/primitives/error-boundary.tsx +0 -107
  127. package/src/client/components/primitives/heading.tsx +0 -128
  128. package/src/client/components/primitives/helpers/observer.ts +0 -141
  129. package/src/client/components/primitives/image.tsx +0 -26
  130. package/src/client/components/primitives/link.tsx +0 -102
  131. package/src/client/components/primitives/menu.tsx +0 -137
  132. package/src/client/components/primitives/navbar.tsx +0 -466
  133. package/src/client/components/primitives/on-this-page.tsx +0 -430
  134. package/src/client/components/primitives/page-nav.tsx +0 -51
  135. package/src/client/components/primitives/popover.tsx +0 -28
  136. package/src/client/components/primitives/search-dialog.tsx +0 -193
  137. package/src/client/components/primitives/sidebar.tsx +0 -423
  138. package/src/client/components/primitives/skeleton.tsx +0 -26
  139. package/src/client/components/primitives/tabs.tsx +0 -70
  140. package/src/client/components/primitives/tooltip.tsx +0 -81
  141. package/src/client/components/primitives/types.ts +0 -11
  142. package/src/client/components/ui-base/banner.tsx +0 -66
  143. package/src/client/components/ui-base/breadcrumbs.tsx +0 -44
  144. package/src/client/components/ui-base/copy-markdown.tsx +0 -107
  145. package/src/client/components/ui-base/error-boundary.tsx +0 -15
  146. package/src/client/components/ui-base/github-stars.tsx +0 -29
  147. package/src/client/components/ui-base/icons.tsx +0 -240
  148. package/src/client/components/ui-base/index.ts +0 -16
  149. package/src/client/components/ui-base/last-updated.tsx +0 -27
  150. package/src/client/components/ui-base/navbar.tsx +0 -266
  151. package/src/client/components/ui-base/not-found.tsx +0 -26
  152. package/src/client/components/ui-base/on-this-page.tsx +0 -57
  153. package/src/client/components/ui-base/page-nav.tsx +0 -50
  154. package/src/client/components/ui-base/search-dialog.tsx +0 -163
  155. package/src/client/components/ui-base/search-highlight.tsx +0 -10
  156. package/src/client/components/ui-base/sidebar.tsx +0 -92
  157. package/src/client/components/ui-base/tabs.tsx +0 -83
  158. package/src/client/components/ui-base/theme-toggle.tsx +0 -130
  159. package/src/client/components/ui-base/version-i18n.tsx +0 -80
  160. package/src/client/hooks/index.ts +0 -13
  161. package/src/client/hooks/use-analytics.ts +0 -272
  162. package/src/client/hooks/use-breadcrumbs.ts +0 -22
  163. package/src/client/hooks/use-i18n.ts +0 -182
  164. package/src/client/hooks/use-localized-to.ts +0 -113
  165. package/src/client/hooks/use-location.ts +0 -5
  166. package/src/client/hooks/use-navbar.ts +0 -130
  167. package/src/client/hooks/use-page-nav.ts +0 -46
  168. package/src/client/hooks/use-routes.ts +0 -108
  169. package/src/client/hooks/use-search-highlight.ts +0 -185
  170. package/src/client/hooks/use-search.ts +0 -118
  171. package/src/client/hooks/use-sidebar.ts +0 -205
  172. package/src/client/hooks/use-tabs.ts +0 -46
  173. package/src/client/hooks/use-version.ts +0 -111
  174. package/src/client/index.ts +0 -31
  175. package/src/client/mdx.ts +0 -2
  176. package/src/client/primitives.ts +0 -19
  177. package/src/client/ssg/boltdocs-shell.tsx +0 -148
  178. package/src/client/ssg/create-routes.tsx +0 -473
  179. package/src/client/ssg/index.ts +0 -4
  180. package/src/client/ssg/mdx-page.tsx +0 -38
  181. package/src/client/store/boltdocs-context.tsx +0 -137
  182. package/src/client/theme/neutral.css +0 -141
  183. package/src/client/theme/reset.css +0 -189
  184. package/src/client/types.ts +0 -116
  185. package/src/client/utils/cn.ts +0 -6
  186. package/src/client/utils/copy-clipboard.ts +0 -22
  187. package/src/client/utils/get-base-file-path.ts +0 -21
  188. package/src/client/utils/github.ts +0 -121
  189. package/src/client/utils/i18n.ts +0 -23
  190. package/src/client/utils/path.ts +0 -9
  191. package/src/client/utils/react-to-text.ts +0 -34
  192. package/src/client/virtual.d.ts +0 -24
  193. /package/dist/{meta-loader-CWg2gnbY.mjs → meta-loader-DzwDFtdT.mjs} +0 -0
@@ -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
@@ -1,54 +0,0 @@
1
- import { cn } from '../../utils/cn'
2
- import type { ComponentBase } from './types'
3
-
4
- export interface ButtonGroupProps extends ComponentBase {
5
- vertical?: boolean
6
- }
7
-
8
- export const ButtonGroup = ({
9
- children,
10
- className,
11
- vertical = false,
12
- }: ButtonGroupProps) => {
13
- return (
14
- <div
15
- className={cn(
16
- 'inline-flex',
17
- vertical ? 'flex-col' : 'flex-row',
18
- // Handle nested button borders and radii
19
- !vertical && [
20
- '[&>*:not(:first-child)]:-ml-px',
21
- '[&>*:first-child]:rounded-r-none',
22
- '[&>*:last-child]:rounded-l-none',
23
- '[&>*:not(:first-child):not(:last-child)]:rounded-none',
24
- // Extra polish for outer corners
25
- className?.includes('rounded-full') && [
26
- '[&>*:first-child]:rounded-l-full',
27
- '[&>*:last-child]:rounded-r-full',
28
- ],
29
- className?.includes('rounded-xl') && [
30
- '[&>*:first-child]:rounded-l-xl',
31
- '[&>*:last-child]:rounded-r-xl',
32
- ],
33
- className?.includes('rounded-lg') && [
34
- '[&>*:first-child]:rounded-l-lg',
35
- '[&>*:last-child]:rounded-r-lg',
36
- ],
37
- ],
38
- vertical && [
39
- '[&>*:not(:first-child)]:-mt-px',
40
- '[&>*:first-child]:rounded-b-none',
41
- '[&>*:last-child]:rounded-t-none',
42
- '[&>*:not(:first-child):not(:last-child)]:rounded-none',
43
- className?.includes('rounded-full') && [
44
- '[&>*:first-child]:rounded-t-full',
45
- '[&>*:last-child]:rounded-b-full',
46
- ],
47
- ],
48
- className,
49
- )}
50
- >
51
- {children}
52
- </div>
53
- )
54
- }
@@ -1,6 +0,0 @@
1
- import * as RAC from 'react-aria-components'
2
- export interface ButtonProps extends RAC.ButtonProps {}
3
-
4
- export const Button = ({ ...props }: ButtonProps) => {
5
- return <RAC.Button {...props} />
6
- }