boltdocs 2.7.9 → 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.
Files changed (174) hide show
  1. package/dist/{cache-DorPMFgW.cjs → cache-Ba-DZQNH.cjs} +1 -1
  2. package/dist/{cache-CQKlT4fI.mjs → cache-BuMZ58L5.mjs} +1 -1
  3. package/dist/chunk-CU-zTemE.cjs +6 -0
  4. package/dist/client/index.cjs +1929 -1
  5. package/dist/client/index.js +1880 -1
  6. package/dist/client/mdx.cjs +7 -1
  7. package/dist/client/mdx.js +7 -1
  8. package/dist/client/primitives.cjs +60 -1
  9. package/dist/client/primitives.js +20 -1
  10. package/dist/docs-layout-BXHV0xw_.cjs +1431 -0
  11. package/dist/docs-layout-DwFndmj5.js +1231 -0
  12. package/dist/doctor-Be7Ly1oM.mjs +21 -0
  13. package/dist/{doctor-D4_Y7M4p.cjs → doctor-CrytFkqW.cjs} +1 -1
  14. package/dist/doctor-jMxWZyLJ.cjs +21 -0
  15. package/dist/generator-CHqxiQhF.cjs +21 -0
  16. package/dist/generator-ClVanhvi.mjs +21 -0
  17. package/dist/icons-dev-3cZMyt8r.cjs +1204 -0
  18. package/dist/icons-dev-Df8OQ481.js +839 -0
  19. package/dist/image-DtrI2cw3.cjs +268 -0
  20. package/dist/image-jxPb-2iV.js +214 -0
  21. package/dist/mdx-BdWkJTeB.cjs +523 -0
  22. package/dist/mdx-UTTLFWJq.js +494 -0
  23. package/dist/meta-loader-CWg2gnbY.mjs +6 -0
  24. package/dist/meta-loader-Cv9O0Pzl.cjs +6 -0
  25. package/dist/node/cli-entry.cjs +1 -1
  26. package/dist/node/cli-entry.mjs +1 -1
  27. package/dist/node/index.cjs +1 -1
  28. package/dist/node/index.mjs +1 -1
  29. package/dist/node/routes/worker.cjs +1 -1
  30. package/dist/node/routes/worker.mjs +1 -1
  31. package/dist/node-BSM4qcDK.cjs +111 -0
  32. package/dist/node-BspZN3R2.mjs +111 -0
  33. package/dist/{package-VfQM94VL.cjs → package-DIIrjuWI.cjs} +1 -1
  34. package/dist/{package-B4MD00N3.mjs → package-K0zsjGIz.mjs} +1 -1
  35. package/dist/{parser-Bh11BsdA.cjs → parser-Aq8LoH-0.cjs} +1 -1
  36. package/dist/{parser-DYRzXWmA.cjs → parser-CdNbqN5y.cjs} +1 -1
  37. package/dist/parser-nE792MLO.mjs +6 -0
  38. package/dist/rolldown-runtime-fkIsjY3S.mjs +6 -0
  39. package/dist/{routes-Co1mRM58.cjs → routes-2k3tbUmC.cjs} +1 -1
  40. package/dist/routes-CpxZIsMM.mjs +6 -0
  41. package/dist/{routes-CHf76Ye4.cjs → routes-DP1vmWRj.cjs} +1 -1
  42. package/dist/search-dialog-BHuIiUC6.js +8 -0
  43. package/dist/search-dialog-BNF10tDl.js +375 -0
  44. package/dist/search-dialog-BwkDuI9R.cjs +220 -0
  45. package/dist/search-dialog-C7xuvyNk.cjs +386 -0
  46. package/dist/search-dialog-CIQg6k8c.cjs +8 -0
  47. package/dist/search-dialog-D-DDN7zJ.js +208 -0
  48. package/dist/utils-CG65J0Sc.mjs +7 -0
  49. package/dist/utils-CKunkU96.cjs +7 -0
  50. package/dist/{worker-pool-BwU8ckrg.cjs → worker-pool-Crbqgw5R.cjs} +1 -1
  51. package/package.json +5 -5
  52. package/dist/chunk-Ds5LZdWN.cjs +0 -6
  53. package/dist/docs-layout-KoWNZc8_.js +0 -6
  54. package/dist/docs-layout-x2yKt2cL.cjs +0 -6
  55. package/dist/doctor-BD1BSB03.mjs +0 -23
  56. package/dist/doctor-BHc9ua6r.cjs +0 -23
  57. package/dist/generator-DGW6pkCC.cjs +0 -22
  58. package/dist/generator-Dv3wEmhZ.mjs +0 -22
  59. package/dist/icons-dev-B_RZIyxu.js +0 -6
  60. package/dist/icons-dev-BlV3wWFT.cjs +0 -6
  61. package/dist/image-BHhTvQzr.cjs +0 -6
  62. package/dist/image-CqKzYD8f.js +0 -6
  63. package/dist/mdx-DudBEac0.js +0 -7
  64. package/dist/mdx-r4cDQxWu.cjs +0 -7
  65. package/dist/meta-loader-0gJ4PtBC.cjs +0 -6
  66. package/dist/meta-loader-9IpAHWDS.mjs +0 -6
  67. package/dist/node-DBaH7kat.mjs +0 -111
  68. package/dist/node-t5C3Q85p.cjs +0 -111
  69. package/dist/parser-9cVdK7w9.mjs +0 -6
  70. package/dist/routes-DwrMa5-z.mjs +0 -6
  71. package/dist/search-dialog-B584t9ZF.js +0 -6
  72. package/dist/search-dialog-BvBopRsZ.cjs +0 -6
  73. package/dist/search-dialog-ByvGScjt.js +0 -6
  74. package/dist/search-dialog-Cyko6TJm.cjs +0 -6
  75. package/dist/search-dialog-D6BNohIJ.js +0 -6
  76. package/dist/search-dialog-DuYTIefy.cjs +0 -6
  77. package/dist/utils-BxNAXhZZ.mjs +0 -7
  78. package/dist/utils-Clzu7jvb.cjs +0 -7
  79. package/src/client/app/config-context.tsx +0 -51
  80. package/src/client/app/doc-page.tsx +0 -38
  81. package/src/client/app/docs-layout.tsx +0 -28
  82. package/src/client/app/head.tsx +0 -122
  83. package/src/client/app/helmet-compat.tsx +0 -36
  84. package/src/client/app/mdx-component.tsx +0 -8
  85. package/src/client/app/mdx-components-context.tsx +0 -72
  86. package/src/client/app/routes-context.tsx +0 -34
  87. package/src/client/app/scroll-handler.tsx +0 -74
  88. package/src/client/app/theme-context.tsx +0 -103
  89. package/src/client/app/ui-context.tsx +0 -42
  90. package/src/client/components/docs-layout-default.tsx +0 -85
  91. package/src/client/components/icons-dev.tsx +0 -282
  92. package/src/client/components/mdx/callout.tsx +0 -97
  93. package/src/client/components/mdx/card.tsx +0 -99
  94. package/src/client/components/mdx/cards.tsx +0 -27
  95. package/src/client/components/mdx/code-block.tsx +0 -184
  96. package/src/client/components/mdx/field.tsx +0 -33
  97. package/src/client/components/mdx/image.tsx +0 -44
  98. package/src/client/components/mdx/index.ts +0 -19
  99. package/src/client/components/mdx/table.tsx +0 -54
  100. package/src/client/components/mdx/typographics.tsx +0 -120
  101. package/src/client/components/mdx/use-code-block.ts +0 -34
  102. package/src/client/components/primitives/breadcrumbs.tsx +0 -54
  103. package/src/client/components/primitives/button-group.tsx +0 -54
  104. package/src/client/components/primitives/button.tsx +0 -6
  105. package/src/client/components/primitives/code-block.tsx +0 -120
  106. package/src/client/components/primitives/docs-layout.tsx +0 -125
  107. package/src/client/components/primitives/error-boundary.tsx +0 -107
  108. package/src/client/components/primitives/heading.tsx +0 -128
  109. package/src/client/components/primitives/helpers/observer.ts +0 -141
  110. package/src/client/components/primitives/image.tsx +0 -26
  111. package/src/client/components/primitives/link.tsx +0 -102
  112. package/src/client/components/primitives/menu.tsx +0 -137
  113. package/src/client/components/primitives/navbar.tsx +0 -466
  114. package/src/client/components/primitives/on-this-page.tsx +0 -430
  115. package/src/client/components/primitives/page-nav.tsx +0 -51
  116. package/src/client/components/primitives/popover.tsx +0 -28
  117. package/src/client/components/primitives/search-dialog.tsx +0 -193
  118. package/src/client/components/primitives/sidebar.tsx +0 -423
  119. package/src/client/components/primitives/skeleton.tsx +0 -26
  120. package/src/client/components/primitives/tabs.tsx +0 -70
  121. package/src/client/components/primitives/tooltip.tsx +0 -81
  122. package/src/client/components/primitives/types.ts +0 -11
  123. package/src/client/components/ui-base/banner.tsx +0 -66
  124. package/src/client/components/ui-base/breadcrumbs.tsx +0 -44
  125. package/src/client/components/ui-base/copy-markdown.tsx +0 -107
  126. package/src/client/components/ui-base/error-boundary.tsx +0 -15
  127. package/src/client/components/ui-base/github-stars.tsx +0 -29
  128. package/src/client/components/ui-base/icons.tsx +0 -240
  129. package/src/client/components/ui-base/index.ts +0 -16
  130. package/src/client/components/ui-base/last-updated.tsx +0 -27
  131. package/src/client/components/ui-base/navbar.tsx +0 -266
  132. package/src/client/components/ui-base/not-found.tsx +0 -26
  133. package/src/client/components/ui-base/on-this-page.tsx +0 -57
  134. package/src/client/components/ui-base/page-nav.tsx +0 -50
  135. package/src/client/components/ui-base/search-dialog.tsx +0 -163
  136. package/src/client/components/ui-base/search-highlight.tsx +0 -10
  137. package/src/client/components/ui-base/sidebar.tsx +0 -92
  138. package/src/client/components/ui-base/tabs.tsx +0 -83
  139. package/src/client/components/ui-base/theme-toggle.tsx +0 -130
  140. package/src/client/components/ui-base/version-i18n.tsx +0 -80
  141. package/src/client/hooks/index.ts +0 -13
  142. package/src/client/hooks/use-analytics.ts +0 -272
  143. package/src/client/hooks/use-breadcrumbs.ts +0 -22
  144. package/src/client/hooks/use-i18n.ts +0 -182
  145. package/src/client/hooks/use-localized-to.ts +0 -113
  146. package/src/client/hooks/use-location.ts +0 -5
  147. package/src/client/hooks/use-navbar.ts +0 -130
  148. package/src/client/hooks/use-page-nav.ts +0 -46
  149. package/src/client/hooks/use-routes.ts +0 -108
  150. package/src/client/hooks/use-search-highlight.ts +0 -185
  151. package/src/client/hooks/use-search.ts +0 -118
  152. package/src/client/hooks/use-sidebar.ts +0 -205
  153. package/src/client/hooks/use-tabs.ts +0 -46
  154. package/src/client/hooks/use-version.ts +0 -111
  155. package/src/client/index.ts +0 -31
  156. package/src/client/mdx.ts +0 -2
  157. package/src/client/primitives.ts +0 -19
  158. package/src/client/ssg/boltdocs-shell.tsx +0 -148
  159. package/src/client/ssg/create-routes.tsx +0 -473
  160. package/src/client/ssg/index.ts +0 -4
  161. package/src/client/ssg/mdx-page.tsx +0 -38
  162. package/src/client/store/boltdocs-context.tsx +0 -137
  163. package/src/client/theme/neutral.css +0 -141
  164. package/src/client/theme/reset.css +0 -189
  165. package/src/client/types.ts +0 -116
  166. package/src/client/utils/cn.ts +0 -6
  167. package/src/client/utils/copy-clipboard.ts +0 -22
  168. package/src/client/utils/get-base-file-path.ts +0 -21
  169. package/src/client/utils/github.ts +0 -121
  170. package/src/client/utils/i18n.ts +0 -23
  171. package/src/client/utils/path.ts +0 -9
  172. package/src/client/utils/react-to-text.ts +0 -34
  173. package/src/client/virtual.d.ts +0 -24
  174. /package/dist/{worker-pool-Bd8Y9KDv.mjs → worker-pool-CGn7DrLb.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
- }