boltdocs 1.10.1 → 1.11.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 (226) hide show
  1. package/package.json +29 -7
  2. package/src/client/app/config-context.tsx +18 -0
  3. package/src/client/app/docs-layout.tsx +14 -0
  4. package/src/client/app/index.tsx +132 -260
  5. package/src/client/app/mdx-component.tsx +52 -0
  6. package/src/client/app/mdx-components-context.tsx +23 -0
  7. package/src/client/app/mdx-page.tsx +20 -0
  8. package/src/client/app/preload.tsx +38 -30
  9. package/src/client/app/router.tsx +30 -0
  10. package/src/client/app/scroll-handler.tsx +40 -0
  11. package/src/client/app/theme-context.tsx +75 -0
  12. package/src/client/components/default-layout.tsx +80 -0
  13. package/src/client/components/docs-layout.tsx +105 -0
  14. package/src/client/components/icons-dev.tsx +74 -0
  15. package/src/client/components/mdx/admonition.tsx +107 -0
  16. package/src/client/components/mdx/badge.tsx +41 -0
  17. package/src/client/components/mdx/button.tsx +35 -0
  18. package/src/client/components/mdx/card.tsx +124 -0
  19. package/src/client/components/mdx/code-block.tsx +119 -0
  20. package/src/client/components/mdx/component-preview.tsx +47 -0
  21. package/src/client/components/mdx/component-props.tsx +83 -0
  22. package/src/client/components/mdx/field.tsx +66 -0
  23. package/src/client/components/mdx/file-tree.tsx +287 -0
  24. package/src/client/components/mdx/hooks/use-code-block.ts +56 -0
  25. package/src/client/components/mdx/hooks/use-component-preview.ts +16 -0
  26. package/src/client/components/mdx/hooks/useTable.ts +74 -0
  27. package/src/client/components/mdx/hooks/useTabs.ts +68 -0
  28. package/src/client/components/mdx/image.tsx +23 -0
  29. package/src/client/components/mdx/index.ts +53 -0
  30. package/src/client/components/mdx/link.tsx +38 -0
  31. package/src/client/components/mdx/list.tsx +192 -0
  32. package/src/client/components/mdx/table.tsx +156 -0
  33. package/src/client/components/mdx/tabs.tsx +135 -0
  34. package/src/client/components/mdx/video.tsx +68 -0
  35. package/src/client/components/primitives/breadcrumbs.tsx +79 -0
  36. package/src/client/components/primitives/button-group.tsx +54 -0
  37. package/src/client/components/primitives/button.tsx +145 -0
  38. package/src/client/components/primitives/helpers/observer.ts +120 -0
  39. package/src/client/components/primitives/index.ts +17 -0
  40. package/src/client/components/primitives/link.tsx +122 -0
  41. package/src/client/components/primitives/menu.tsx +159 -0
  42. package/src/client/components/primitives/navbar.tsx +359 -0
  43. package/src/client/components/primitives/navigation-menu.tsx +116 -0
  44. package/src/client/components/primitives/on-this-page.tsx +461 -0
  45. package/src/client/components/primitives/page-nav.tsx +87 -0
  46. package/src/client/components/primitives/popover.tsx +47 -0
  47. package/src/client/components/primitives/search-dialog.tsx +183 -0
  48. package/src/client/components/primitives/sidebar.tsx +154 -0
  49. package/src/client/components/primitives/tabs.tsx +90 -0
  50. package/src/client/components/primitives/tooltip.tsx +83 -0
  51. package/src/client/components/primitives/types.ts +11 -0
  52. package/src/client/components/ui-base/breadcrumbs.tsx +42 -0
  53. package/src/client/components/ui-base/copy-markdown.tsx +112 -0
  54. package/src/client/components/ui-base/error-boundary.tsx +52 -0
  55. package/src/client/components/ui-base/github-stars.tsx +27 -0
  56. package/src/client/components/ui-base/head.tsx +69 -0
  57. package/src/client/components/ui-base/loading.tsx +87 -0
  58. package/src/client/components/ui-base/navbar.tsx +138 -0
  59. package/src/client/components/ui-base/not-found.tsx +24 -0
  60. package/src/client/components/ui-base/on-this-page.tsx +152 -0
  61. package/src/client/components/ui-base/page-nav.tsx +39 -0
  62. package/src/client/components/ui-base/powered-by.tsx +19 -0
  63. package/src/client/components/ui-base/progress-bar.tsx +67 -0
  64. package/src/client/components/ui-base/search-dialog.tsx +82 -0
  65. package/src/client/components/ui-base/sidebar.tsx +104 -0
  66. package/src/client/components/ui-base/tabs.tsx +65 -0
  67. package/src/client/components/ui-base/theme-toggle.tsx +32 -0
  68. package/src/client/hooks/index.ts +12 -0
  69. package/src/client/hooks/use-breadcrumbs.ts +22 -0
  70. package/src/client/hooks/use-i18n.ts +84 -0
  71. package/src/client/hooks/use-localized-to.ts +95 -0
  72. package/src/client/hooks/use-location.ts +5 -0
  73. package/src/client/hooks/use-navbar.ts +60 -0
  74. package/src/client/hooks/use-onthispage.ts +23 -0
  75. package/src/client/hooks/use-page-nav.ts +22 -0
  76. package/src/client/hooks/use-routes.ts +72 -0
  77. package/src/client/hooks/use-search.ts +71 -0
  78. package/src/client/hooks/use-sidebar.ts +49 -0
  79. package/src/client/hooks/use-tabs.ts +43 -0
  80. package/src/client/hooks/use-version.ts +78 -0
  81. package/src/client/index.ts +55 -18
  82. package/src/client/integrations/codesandbox.ts +179 -0
  83. package/src/client/ssr.tsx +27 -16
  84. package/src/client/theme/neutral.css +360 -0
  85. package/src/client/types.ts +131 -27
  86. package/src/client/utils/cn.ts +6 -0
  87. package/src/client/utils/copy-clipboard.ts +22 -0
  88. package/src/client/utils/get-base-file-path.ts +21 -0
  89. package/src/client/utils/github.ts +121 -0
  90. package/src/client/utils/use-on-change.ts +15 -0
  91. package/src/client/virtual.d.ts +24 -0
  92. package/src/node/cache.ts +156 -156
  93. package/src/node/config.ts +159 -103
  94. package/src/node/index.ts +13 -13
  95. package/src/node/mdx.ts +213 -61
  96. package/src/node/plugin/entry.ts +29 -18
  97. package/src/node/plugin/html.ts +11 -11
  98. package/src/node/plugin/index.ts +161 -83
  99. package/src/node/plugin/types.ts +2 -4
  100. package/src/node/routes/cache.ts +6 -6
  101. package/src/node/routes/index.ts +206 -113
  102. package/src/node/routes/parser.ts +106 -81
  103. package/src/node/routes/sorter.ts +15 -15
  104. package/src/node/routes/types.ts +24 -24
  105. package/src/node/ssg/index.ts +46 -46
  106. package/src/node/ssg/meta.ts +4 -4
  107. package/src/node/ssg/options.ts +5 -5
  108. package/src/node/ssg/sitemap.ts +14 -14
  109. package/src/node/utils.ts +31 -31
  110. package/tsconfig.json +25 -20
  111. package/tsup.config.ts +23 -14
  112. package/dist/PackageManagerTabs-NVT7G625.mjs +0 -99
  113. package/dist/SearchDialog-BEVZQ74P.css +0 -2679
  114. package/dist/SearchDialog-MEWGAONO.mjs +0 -194
  115. package/dist/Video-KNTY5BNO.mjs +0 -6
  116. package/dist/cache-KNL5B4EE.mjs +0 -12
  117. package/dist/chunk-7SFUJWTB.mjs +0 -211
  118. package/dist/chunk-FFBNU6IJ.mjs +0 -386
  119. package/dist/chunk-FMTOYQLO.mjs +0 -37
  120. package/dist/chunk-OZLYRXAD.mjs +0 -1914
  121. package/dist/chunk-Z7JHYNAS.mjs +0 -57
  122. package/dist/client/index.css +0 -2679
  123. package/dist/client/index.d.mts +0 -379
  124. package/dist/client/index.d.ts +0 -379
  125. package/dist/client/index.js +0 -3594
  126. package/dist/client/index.mjs +0 -658
  127. package/dist/client/ssr.css +0 -2679
  128. package/dist/client/ssr.d.mts +0 -27
  129. package/dist/client/ssr.d.ts +0 -27
  130. package/dist/client/ssr.js +0 -2930
  131. package/dist/client/ssr.mjs +0 -33
  132. package/dist/config-BsFQ-ErD.d.mts +0 -159
  133. package/dist/config-BsFQ-ErD.d.ts +0 -159
  134. package/dist/node/index.d.mts +0 -91
  135. package/dist/node/index.d.ts +0 -91
  136. package/dist/node/index.js +0 -1187
  137. package/dist/node/index.mjs +0 -762
  138. package/dist/types-Dj-bfnC3.d.mts +0 -74
  139. package/dist/types-Dj-bfnC3.d.ts +0 -74
  140. package/src/client/theme/components/CodeBlock/CodeBlock.tsx +0 -40
  141. package/src/client/theme/components/CodeBlock/index.ts +0 -1
  142. package/src/client/theme/components/PackageManagerTabs/PackageManagerTabs.tsx +0 -131
  143. package/src/client/theme/components/PackageManagerTabs/index.ts +0 -1
  144. package/src/client/theme/components/PackageManagerTabs/pkg-tabs.css +0 -64
  145. package/src/client/theme/components/Playground/Playground.tsx +0 -124
  146. package/src/client/theme/components/Playground/index.ts +0 -1
  147. package/src/client/theme/components/Playground/playground.css +0 -168
  148. package/src/client/theme/components/Video/Video.tsx +0 -84
  149. package/src/client/theme/components/Video/index.ts +0 -1
  150. package/src/client/theme/components/Video/video.css +0 -41
  151. package/src/client/theme/components/mdx/Admonition.tsx +0 -80
  152. package/src/client/theme/components/mdx/Badge.tsx +0 -31
  153. package/src/client/theme/components/mdx/Button.tsx +0 -50
  154. package/src/client/theme/components/mdx/Card.tsx +0 -80
  155. package/src/client/theme/components/mdx/Field.tsx +0 -60
  156. package/src/client/theme/components/mdx/FileTree.tsx +0 -229
  157. package/src/client/theme/components/mdx/List.tsx +0 -57
  158. package/src/client/theme/components/mdx/Table.tsx +0 -151
  159. package/src/client/theme/components/mdx/Tabs.tsx +0 -123
  160. package/src/client/theme/components/mdx/index.ts +0 -27
  161. package/src/client/theme/components/mdx/mdx-components.css +0 -764
  162. package/src/client/theme/icons/bun.tsx +0 -62
  163. package/src/client/theme/icons/deno.tsx +0 -20
  164. package/src/client/theme/icons/discord.tsx +0 -12
  165. package/src/client/theme/icons/github.tsx +0 -15
  166. package/src/client/theme/icons/npm.tsx +0 -13
  167. package/src/client/theme/icons/pnpm.tsx +0 -72
  168. package/src/client/theme/icons/twitter.tsx +0 -12
  169. package/src/client/theme/styles/markdown.css +0 -341
  170. package/src/client/theme/styles/variables.css +0 -187
  171. package/src/client/theme/styles.css +0 -38
  172. package/src/client/theme/ui/BackgroundGradient/BackgroundGradient.tsx +0 -10
  173. package/src/client/theme/ui/BackgroundGradient/index.ts +0 -1
  174. package/src/client/theme/ui/Breadcrumbs/Breadcrumbs.tsx +0 -68
  175. package/src/client/theme/ui/Breadcrumbs/index.ts +0 -1
  176. package/src/client/theme/ui/CopyMarkdown/CopyMarkdown.tsx +0 -82
  177. package/src/client/theme/ui/CopyMarkdown/copy-markdown.css +0 -114
  178. package/src/client/theme/ui/CopyMarkdown/index.ts +0 -1
  179. package/src/client/theme/ui/ErrorBoundary/ErrorBoundary.tsx +0 -46
  180. package/src/client/theme/ui/ErrorBoundary/index.ts +0 -1
  181. package/src/client/theme/ui/Footer/footer.css +0 -32
  182. package/src/client/theme/ui/Head/Head.tsx +0 -69
  183. package/src/client/theme/ui/Head/index.ts +0 -1
  184. package/src/client/theme/ui/LanguageSwitcher/LanguageSwitcher.tsx +0 -125
  185. package/src/client/theme/ui/LanguageSwitcher/index.ts +0 -1
  186. package/src/client/theme/ui/LanguageSwitcher/language-switcher.css +0 -98
  187. package/src/client/theme/ui/Layout/Layout.tsx +0 -208
  188. package/src/client/theme/ui/Layout/base.css +0 -105
  189. package/src/client/theme/ui/Layout/index.ts +0 -2
  190. package/src/client/theme/ui/Layout/pagination.css +0 -72
  191. package/src/client/theme/ui/Layout/responsive.css +0 -36
  192. package/src/client/theme/ui/Link/Link.tsx +0 -392
  193. package/src/client/theme/ui/Link/LinkPreview.tsx +0 -59
  194. package/src/client/theme/ui/Link/index.ts +0 -2
  195. package/src/client/theme/ui/Link/link-preview.css +0 -48
  196. package/src/client/theme/ui/Loading/Loading.tsx +0 -10
  197. package/src/client/theme/ui/Loading/index.ts +0 -1
  198. package/src/client/theme/ui/Loading/loading.css +0 -30
  199. package/src/client/theme/ui/Navbar/GithubStars.tsx +0 -27
  200. package/src/client/theme/ui/Navbar/Navbar.tsx +0 -193
  201. package/src/client/theme/ui/Navbar/Tabs.tsx +0 -99
  202. package/src/client/theme/ui/Navbar/index.ts +0 -2
  203. package/src/client/theme/ui/Navbar/navbar.css +0 -347
  204. package/src/client/theme/ui/NotFound/NotFound.tsx +0 -19
  205. package/src/client/theme/ui/NotFound/index.ts +0 -1
  206. package/src/client/theme/ui/NotFound/not-found.css +0 -64
  207. package/src/client/theme/ui/OnThisPage/OnThisPage.tsx +0 -244
  208. package/src/client/theme/ui/OnThisPage/index.ts +0 -1
  209. package/src/client/theme/ui/OnThisPage/toc.css +0 -152
  210. package/src/client/theme/ui/PoweredBy/PoweredBy.tsx +0 -18
  211. package/src/client/theme/ui/PoweredBy/index.ts +0 -1
  212. package/src/client/theme/ui/PoweredBy/powered-by.css +0 -76
  213. package/src/client/theme/ui/ProgressBar/ProgressBar.css +0 -17
  214. package/src/client/theme/ui/ProgressBar/ProgressBar.tsx +0 -51
  215. package/src/client/theme/ui/ProgressBar/index.ts +0 -1
  216. package/src/client/theme/ui/SearchDialog/SearchDialog.tsx +0 -209
  217. package/src/client/theme/ui/SearchDialog/index.ts +0 -1
  218. package/src/client/theme/ui/SearchDialog/search.css +0 -152
  219. package/src/client/theme/ui/Sidebar/Sidebar.tsx +0 -244
  220. package/src/client/theme/ui/Sidebar/index.ts +0 -1
  221. package/src/client/theme/ui/Sidebar/sidebar.css +0 -230
  222. package/src/client/theme/ui/ThemeToggle/ThemeToggle.tsx +0 -69
  223. package/src/client/theme/ui/ThemeToggle/index.ts +0 -1
  224. package/src/client/theme/ui/VersionSwitcher/VersionSwitcher.tsx +0 -136
  225. package/src/client/theme/ui/VersionSwitcher/index.ts +0 -1
  226. package/src/client/utils.ts +0 -49
@@ -1,84 +0,0 @@
1
- import React, { useRef, useState, useEffect } from "react";
2
-
3
- interface VideoProps {
4
- /** Video source URL */
5
- src?: string;
6
- /** Poster/thumbnail image URL */
7
- poster?: string;
8
- /** Alt text for accessibility */
9
- alt?: string;
10
- /** Show native video controls (default: true) */
11
- controls?: boolean;
12
- /** Preload strategy (default: 'none') */
13
- preload?: string;
14
- /** Children (e.g. <source> elements) */
15
- children?: React.ReactNode;
16
- /** Allow any additional HTML video attributes */
17
- [key: string]: any;
18
- }
19
-
20
- /**
21
- * Optimized video component with lazy loading via IntersectionObserver.
22
- * The `<video>` element is only rendered once it enters the viewport,
23
- * preventing unnecessary network downloads on initial page load.
24
- *
25
- * Usage in MDX:
26
- * ```mdx
27
- * <video src="/demo.mp4" poster="/demo-thumb.jpg" />
28
- * ```
29
- */
30
- export function Video({
31
- src,
32
- poster,
33
- alt,
34
- children,
35
- controls,
36
- preload = "metadata",
37
- ...rest
38
- }: VideoProps) {
39
- const containerRef = useRef<HTMLDivElement>(null);
40
- const [isVisible, setIsVisible] = useState(false);
41
-
42
- useEffect(() => {
43
- const el = containerRef.current;
44
- if (!el) return;
45
-
46
- const observer = new IntersectionObserver(
47
- ([entry]) => {
48
- if (entry.isIntersecting) {
49
- setIsVisible(true);
50
- observer.disconnect();
51
- }
52
- },
53
- { rootMargin: "200px" },
54
- );
55
-
56
- observer.observe(el);
57
- return () => observer.disconnect();
58
- }, []);
59
-
60
- return (
61
- <div ref={containerRef} className="boltdocs-video-wrapper">
62
- {isVisible ? (
63
- <video
64
- className="boltdocs-video"
65
- src={src}
66
- poster={poster}
67
- controls={true}
68
- preload={preload}
69
- playsInline
70
- {...rest}
71
- >
72
- {children}
73
- Your browser does not support the video tag.
74
- </video>
75
- ) : (
76
- <div
77
- className="boltdocs-video-placeholder"
78
- role="img"
79
- aria-label={alt || "Video"}
80
- />
81
- )}
82
- </div>
83
- );
84
- }
@@ -1 +0,0 @@
1
- export { Video } from "./Video";
@@ -1,41 +0,0 @@
1
- /* ─── Video ──────────────────────────────────────────────── */
2
- .boltdocs-video-wrapper {
3
- margin: 1.5rem 0;
4
- max-width: 100%;
5
- width: 100%;
6
- box-sizing: border-box;
7
- border-radius: var(--ld-radius-md);
8
- overflow: hidden;
9
- border: 1px solid var(--ld-border-subtle);
10
- background-color: var(--ld-surface);
11
- }
12
-
13
- .boltdocs-video {
14
- display: block;
15
- width: 100%;
16
- max-width: 100%;
17
- height: auto;
18
- border-radius: 0;
19
- animation: ld-video-fade-in 0.4s ease-out;
20
- }
21
-
22
- .boltdocs-video-placeholder {
23
- width: 100%;
24
- aspect-ratio: 16 / 9;
25
- background-color: var(--ld-surface);
26
- }
27
-
28
- /* Ensure video doesn't overflow boltdocs-page container */
29
- .boltdocs-page video {
30
- max-width: 100%;
31
- height: auto;
32
- }
33
-
34
- @keyframes ld-video-fade-in {
35
- from {
36
- opacity: 0;
37
- }
38
- to {
39
- opacity: 1;
40
- }
41
- }
@@ -1,80 +0,0 @@
1
- import React from "react";
2
- import {
3
- Info,
4
- Lightbulb,
5
- AlertTriangle,
6
- ShieldAlert,
7
- Bookmark,
8
- } from "lucide-react";
9
-
10
- const ICON_MAP: Record<string, React.ReactNode> = {
11
- note: <Bookmark size={18} />,
12
- tip: <Lightbulb size={18} />,
13
- info: <Info size={18} />,
14
- warning: <AlertTriangle size={18} />,
15
- danger: <ShieldAlert size={18} />,
16
- };
17
-
18
- const LABEL_MAP: Record<string, string> = {
19
- note: "Note",
20
- tip: "Tip",
21
- info: "Info",
22
- warning: "Warning",
23
- danger: "Danger",
24
- };
25
-
26
- export interface AdmonitionProps extends React.HTMLAttributes<HTMLDivElement> {
27
- /** Admonition type — controls color and icon */
28
- type?: "note" | "tip" | "info" | "warning" | "danger";
29
- /** Override the default title */
30
- title?: string;
31
- children: React.ReactNode;
32
- }
33
-
34
- /**
35
- * Callout / admonition box for notes, warnings, etc.
36
- *
37
- * ```mdx
38
- * <Admonition type="warning" title="Breaking Change">
39
- * This API has changed in v2.
40
- * </Admonition>
41
- * ```
42
- */
43
- export function Admonition({
44
- type = "note",
45
- title,
46
- children,
47
- className = "",
48
- ...rest
49
- }: AdmonitionProps) {
50
- return (
51
- <div
52
- className={`ld-admonition ld-admonition--${type} ${className}`.trim()}
53
- role={type === "warning" || type === "danger" ? "alert" : "note"}
54
- {...rest}
55
- >
56
- <div className="ld-admonition__header">
57
- <span className="ld-admonition__icon">{ICON_MAP[type]}</span>
58
- <span className="ld-admonition__title">{title || LABEL_MAP[type]}</span>
59
- </div>
60
- <div className="ld-admonition__body">{children}</div>
61
- </div>
62
- );
63
- }
64
-
65
- /* ─── Convenience aliases ─────────────────────────────────── */
66
- export const Note = (props: Omit<AdmonitionProps, "type">) => (
67
- <Admonition type="note" {...props} />
68
- );
69
- export const Tip = (props: Omit<AdmonitionProps, "type">) => (
70
- <Admonition type="tip" {...props} />
71
- );
72
- export const Warning = (props: Omit<AdmonitionProps, "type">) => (
73
- <Admonition type="warning" {...props} />
74
- );
75
- export const Danger = (props: Omit<AdmonitionProps, "type">) => (
76
- <Admonition type="danger" {...props} />
77
- );
78
- export const InfoBox = (props: Omit<AdmonitionProps, "type">) => (
79
- <Admonition type="info" {...props} />
80
- );
@@ -1,31 +0,0 @@
1
- import React from "react";
2
-
3
- export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
4
- /** Color variant */
5
- variant?: "default" | "primary" | "success" | "warning" | "danger" | "info";
6
- children: React.ReactNode;
7
- }
8
-
9
- /**
10
- * Inline badge / pill for labels, statuses, or tags.
11
- *
12
- * ```mdx
13
- * <Badge variant="success">Stable</Badge>
14
- * <Badge variant="warning">Beta</Badge>
15
- * ```
16
- */
17
- export function Badge({
18
- variant = "default",
19
- children,
20
- className = "",
21
- ...rest
22
- }: BadgeProps) {
23
- return (
24
- <span
25
- className={`ld-badge ld-badge--${variant} ${className}`.trim()}
26
- {...rest}
27
- >
28
- {children}
29
- </span>
30
- );
31
- }
@@ -1,50 +0,0 @@
1
- import React from "react";
2
-
3
- export type ButtonProps = React.AnchorHTMLAttributes<HTMLAnchorElement> &
4
- React.ButtonHTMLAttributes<HTMLButtonElement> & {
5
- /** Visual variant */
6
- variant?: "primary" | "secondary" | "outline" | "ghost";
7
- /** Size */
8
- size?: "sm" | "md" | "lg";
9
- /** If provided, renders as a link */
10
- href?: string;
11
- children: React.ReactNode;
12
- };
13
-
14
- /**
15
- * A versatile button/link component for use in MDX pages and the home page.
16
- *
17
- * ```mdx
18
- * <Button variant="primary" href="/docs/getting-started">Get Started →</Button>
19
- * <Button variant="secondary" href="https://github.com">GitHub</Button>
20
- * ```
21
- */
22
- export function Button({
23
- variant = "primary",
24
- size = "md",
25
- href,
26
- children,
27
- className = "",
28
- ...rest
29
- }: ButtonProps) {
30
- const cls = `ld-btn ld-btn--${variant} ld-btn--${size} ${className}`.trim();
31
-
32
- if (href) {
33
- return (
34
- <a
35
- href={href}
36
- style={{ textDecoration: "none" }}
37
- className={cls}
38
- {...(rest as any)}
39
- >
40
- {children}
41
- </a>
42
- );
43
- }
44
-
45
- return (
46
- <button className={cls} {...(rest as any)}>
47
- {children}
48
- </button>
49
- );
50
- }
@@ -1,80 +0,0 @@
1
- import React from "react";
2
-
3
- /* ─── Cards (grid container) ─────────────────────────────── */
4
- export interface CardsProps extends React.HTMLAttributes<HTMLDivElement> {
5
- /** Number of columns (defaults to 3) */
6
- cols?: 1 | 2 | 3 | 4;
7
- children: React.ReactNode;
8
- }
9
-
10
- /**
11
- * Grid wrapper for `<Card>` components.
12
- *
13
- * ```mdx
14
- * <Cards cols={3}>
15
- * <Card title="Fast" icon="⚡">Instant HMR.</Card>
16
- * <Card title="Simple" icon="📁">File-system routing.</Card>
17
- * </Cards>
18
- * ```
19
- */
20
- export function Cards({
21
- cols = 3,
22
- children,
23
- className = "",
24
- ...rest
25
- }: CardsProps) {
26
- return (
27
- <div className={`ld-cards ld-cards--${cols} ${className}`.trim()} {...rest}>
28
- {children}
29
- </div>
30
- );
31
- }
32
-
33
- /* ─── Card ─────────────────────────────────────────────────── */
34
- export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
35
- /** Card heading */
36
- title?: string;
37
- /** Emoji or icon string displayed above the title */
38
- icon?: React.ReactNode;
39
- /** If provided, the entire card becomes a link */
40
- href?: string;
41
- children?: React.ReactNode;
42
- }
43
-
44
- /**
45
- * Individual feature/info card.
46
- */
47
- export function Card({
48
- title,
49
- icon,
50
- href,
51
- children,
52
- className = "",
53
- ...rest
54
- }: CardProps) {
55
- const inner = (
56
- <>
57
- {icon && <span className="ld-card__icon">{icon}</span>}
58
- {title && <h3 className="ld-card__title">{title}</h3>}
59
- {children && <div className="ld-card__body">{children}</div>}
60
- </>
61
- );
62
-
63
- if (href) {
64
- return (
65
- <a
66
- href={href}
67
- className={`ld-card ld-card--link ${className}`.trim()}
68
- {...(rest as any)}
69
- >
70
- {inner}
71
- </a>
72
- );
73
- }
74
-
75
- return (
76
- <div className={`ld-card ${className}`.trim()} {...rest}>
77
- {inner}
78
- </div>
79
- );
80
- }
@@ -1,60 +0,0 @@
1
- import React from "react";
2
-
3
- export interface FieldProps {
4
- /** The name of the property or field */
5
- name: string;
6
- /** The data type of the field (e.g., "string", "number", "boolean") */
7
- type?: string;
8
- /** The default value if not provided */
9
- defaultValue?: string;
10
- /** Whether the field is required */
11
- required?: boolean;
12
- /** Description or additional content */
13
- children: React.ReactNode;
14
- /** Optional anchor ID for linking */
15
- id?: string;
16
- /** Optional extra class name */
17
- className?: string;
18
- }
19
-
20
- /**
21
- * A highly aesthetic and readable component for documenting API fields/properties.
22
- */
23
- export function Field({
24
- name,
25
- type,
26
- defaultValue,
27
- required = false,
28
- children,
29
- id,
30
- className = "",
31
- }: FieldProps) {
32
- return (
33
- <div className={`ld-field ${className}`.trim()} id={id}>
34
- <div className="ld-field__header">
35
- <div className="ld-field__signature">
36
- <code className="ld-field__name">{name}</code>
37
- {type && (
38
- <span className="ld-field__type-badge">
39
- {type}
40
- </span>
41
- )}
42
- {required && (
43
- <span className="ld-field__required-badge">required</span>
44
- )}
45
- </div>
46
-
47
- {defaultValue && (
48
- <div className="ld-field__default">
49
- <span className="ld-field__default-label">Default:</span>
50
- <code className="ld-field__default-value">{defaultValue}</code>
51
- </div>
52
- )}
53
- </div>
54
-
55
- <div className="ld-field__content">
56
- {children}
57
- </div>
58
- </div>
59
- );
60
- }
@@ -1,229 +0,0 @@
1
- import React, { Children, isValidElement, useState } from "react";
2
- import {
3
- Folder,
4
- FileText,
5
- File,
6
- FileCode,
7
- FileImage,
8
- ChevronRight,
9
- } from "lucide-react";
10
-
11
- export interface FileTreeProps {
12
- children: React.ReactNode;
13
- }
14
-
15
- function getTextContent(node: React.ReactNode): string {
16
- if (typeof node === "string") return node;
17
- if (typeof node === "number") return node.toString();
18
- if (Array.isArray(node)) return node.map(getTextContent).join("");
19
- if (isValidElement(node)) {
20
- return getTextContent((node.props as any).children);
21
- }
22
- return "";
23
- }
24
-
25
- function getFileIcon(filename: string) {
26
- const name = filename.toLowerCase();
27
-
28
- if (
29
- name.endsWith(".ts") ||
30
- name.endsWith(".tsx") ||
31
- name.endsWith(".js") ||
32
- name.endsWith(".jsx") ||
33
- name.endsWith(".json") ||
34
- name.endsWith(".mjs") ||
35
- name.endsWith(".cjs") ||
36
- name.endsWith(".astro") ||
37
- name.endsWith(".vue") ||
38
- name.endsWith(".svelte")
39
- ) {
40
- return (
41
- <FileCode size={16} strokeWidth={2} className="ld-file-tree__icon-file" />
42
- );
43
- }
44
-
45
- if (name.endsWith(".md") || name.endsWith(".mdx") || name.endsWith(".txt")) {
46
- return (
47
- <FileText size={16} strokeWidth={2} className="ld-file-tree__icon-file" />
48
- );
49
- }
50
-
51
- if (
52
- name.endsWith(".png") ||
53
- name.endsWith(".jpg") ||
54
- name.endsWith(".jpeg") ||
55
- name.endsWith(".svg") ||
56
- name.endsWith(".gif")
57
- ) {
58
- return (
59
- <FileImage
60
- size={16}
61
- strokeWidth={2}
62
- className="ld-file-tree__icon-file"
63
- />
64
- );
65
- }
66
-
67
- return <File size={16} strokeWidth={2} className="ld-file-tree__icon-file" />;
68
- }
69
-
70
- // Helper to reliably check for ul and li elements, including MDX wrappers
71
- function isListElement(node: any, tag: "ul" | "li"): boolean {
72
- if (typeof node.type === "string") {
73
- return node.type === tag;
74
- }
75
- if (typeof node.type === "function") {
76
- return node.type.name === tag || node.type.name?.toLowerCase() === tag;
77
- }
78
- // MDX specific wrapper detection
79
- if (node.props && node.props.originalType === tag) {
80
- return true;
81
- }
82
- if (node.props && node.props.mdxType === tag) {
83
- return true;
84
- }
85
- return false;
86
- }
87
-
88
- function FolderNode({
89
- labelText,
90
- nestedNodes,
91
- depth,
92
- }: {
93
- labelText: string;
94
- nestedNodes: React.ReactNode[];
95
- depth: number;
96
- }) {
97
- const [isOpen, setIsOpen] = useState(true);
98
-
99
- return (
100
- <li className="ld-file-tree__item">
101
- <div
102
- className="ld-file-tree__label ld-file-tree__label--folder"
103
- onClick={() => setIsOpen(!isOpen)}
104
- style={{ cursor: "pointer" }}
105
- >
106
- <span className="ld-file-tree__icon ld-file-tree__icon--chevron">
107
- <ChevronRight
108
- size={14}
109
- className={`ld-file-tree__chevron ${isOpen ? "ld-file-tree__chevron--open" : ""}`}
110
- strokeWidth={3}
111
- />
112
- </span>
113
- <span className="ld-file-tree__icon">
114
- <Folder
115
- size={16}
116
- strokeWidth={2}
117
- className="ld-file-tree__icon-folder"
118
- fill="currentColor"
119
- fillOpacity={0.15}
120
- />
121
- </span>
122
- <span className="ld-file-tree__name">{labelText}</span>
123
- </div>
124
- {isOpen && nestedNodes.length > 0 && (
125
- <div className="ld-file-tree__nested">
126
- {nestedNodes.map((child, index) => (
127
- <React.Fragment key={index}>
128
- {parseNode(child, depth)}
129
- </React.Fragment>
130
- ))}
131
- </div>
132
- )}
133
- </li>
134
- );
135
- }
136
-
137
- function parseNode(node: React.ReactNode, depth: number = 0): React.ReactNode {
138
- if (!isValidElement(node)) {
139
- return node;
140
- }
141
-
142
- if (isListElement(node, "ul")) {
143
- return (
144
- <ul
145
- className={`ld-file-tree__list ${depth === 0 ? "ld-file-tree__list--root" : ""}`}
146
- >
147
- {Children.map((node.props as any).children, (child, index) => (
148
- <React.Fragment key={index}>
149
- {parseNode(child, depth + 1)}
150
- </React.Fragment>
151
- ))}
152
- </ul>
153
- );
154
- }
155
-
156
- if (isListElement(node, "li")) {
157
- const children = Children.toArray((node.props as any).children);
158
-
159
- // Find nested list indicating a directory
160
- const nestedListIndex = children.findIndex(
161
- (child) => isValidElement(child) && isListElement(child, "ul"),
162
- );
163
- const hasNested = nestedListIndex !== -1;
164
-
165
- // Separate text label from nested items
166
- const labelNodes = hasNested
167
- ? children.slice(0, nestedListIndex)
168
- : children;
169
- const nestedNodes = hasNested ? children.slice(nestedListIndex) : [];
170
-
171
- const rawLabelContent = getTextContent(labelNodes).trim();
172
- const isExplicitDir = rawLabelContent.endsWith("/");
173
- const labelText = isExplicitDir
174
- ? rawLabelContent.slice(0, -1)
175
- : rawLabelContent;
176
-
177
- const isFolder = hasNested || isExplicitDir;
178
-
179
- if (isFolder) {
180
- return (
181
- <FolderNode
182
- labelText={labelText}
183
- nestedNodes={nestedNodes}
184
- depth={depth}
185
- />
186
- );
187
- }
188
-
189
- return (
190
- <li className="ld-file-tree__item">
191
- <div className="ld-file-tree__label ld-file-tree__label--file">
192
- <span className="ld-file-tree__icon ld-file-tree__icon--spacer"></span>
193
- <span className="ld-file-tree__icon">{getFileIcon(labelText)}</span>
194
- <span className="ld-file-tree__name">{labelText}</span>
195
- </div>
196
- </li>
197
- );
198
- }
199
-
200
- // If node is e.g. a paragraph injected by MDX wrapping the list
201
- if ((node.props as any).children) {
202
- return Children.map((node.props as any).children, (child, index) => (
203
- <React.Fragment key={index}>{parseNode(child, depth)}</React.Fragment>
204
- ));
205
- }
206
-
207
- return node;
208
- }
209
-
210
- /**
211
- * FileTree component displays a customized, styled tree structure for markdown lists.
212
- *
213
- * ```mdx
214
- * <FileTree>
215
- * - src/
216
- * - index.ts
217
- * - components/
218
- * - Button.tsx
219
- * - package.json
220
- * </FileTree>
221
- * ```
222
- */
223
- export function FileTree({ children }: FileTreeProps) {
224
- return (
225
- <div className="ld-file-tree" dir="ltr">
226
- {Children.map(children, (child) => parseNode(child, 0))}
227
- </div>
228
- );
229
- }