boltdocs 1.10.2 → 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 (225) 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 -17
  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-AGVF6JBO.mjs +0 -194
  114. package/dist/SearchDialog-YPDOM7Q6.css +0 -2847
  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-TKLQWU7H.mjs +0 -1920
  121. package/dist/chunk-Z7JHYNAS.mjs +0 -57
  122. package/dist/client/index.css +0 -2847
  123. package/dist/client/index.d.mts +0 -372
  124. package/dist/client/index.d.ts +0 -372
  125. package/dist/client/index.js +0 -3630
  126. package/dist/client/index.mjs +0 -697
  127. package/dist/client/ssr.css +0 -2847
  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 -2928
  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 -61
  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 -180
  146. package/src/client/theme/components/Playground/index.ts +0 -1
  147. package/src/client/theme/components/Playground/playground.css +0 -238
  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 -394
  170. package/src/client/theme/styles/variables.css +0 -175
  171. package/src/client/theme/styles.css +0 -39
  172. package/src/client/theme/ui/Breadcrumbs/Breadcrumbs.tsx +0 -68
  173. package/src/client/theme/ui/Breadcrumbs/index.ts +0 -1
  174. package/src/client/theme/ui/CopyMarkdown/CopyMarkdown.tsx +0 -82
  175. package/src/client/theme/ui/CopyMarkdown/copy-markdown.css +0 -112
  176. package/src/client/theme/ui/CopyMarkdown/index.ts +0 -1
  177. package/src/client/theme/ui/ErrorBoundary/ErrorBoundary.tsx +0 -50
  178. package/src/client/theme/ui/ErrorBoundary/error-boundary.css +0 -55
  179. package/src/client/theme/ui/ErrorBoundary/index.ts +0 -1
  180. package/src/client/theme/ui/Footer/footer.css +0 -32
  181. package/src/client/theme/ui/Head/Head.tsx +0 -69
  182. package/src/client/theme/ui/Head/index.ts +0 -1
  183. package/src/client/theme/ui/LanguageSwitcher/LanguageSwitcher.tsx +0 -125
  184. package/src/client/theme/ui/LanguageSwitcher/index.ts +0 -1
  185. package/src/client/theme/ui/LanguageSwitcher/language-switcher.css +0 -98
  186. package/src/client/theme/ui/Layout/Layout.tsx +0 -203
  187. package/src/client/theme/ui/Layout/base.css +0 -106
  188. package/src/client/theme/ui/Layout/index.ts +0 -2
  189. package/src/client/theme/ui/Layout/pagination.css +0 -72
  190. package/src/client/theme/ui/Layout/responsive.css +0 -47
  191. package/src/client/theme/ui/Link/Link.tsx +0 -392
  192. package/src/client/theme/ui/Link/LinkPreview.tsx +0 -59
  193. package/src/client/theme/ui/Link/index.ts +0 -2
  194. package/src/client/theme/ui/Link/link-preview.css +0 -48
  195. package/src/client/theme/ui/Loading/Loading.tsx +0 -10
  196. package/src/client/theme/ui/Loading/index.ts +0 -1
  197. package/src/client/theme/ui/Loading/loading.css +0 -30
  198. package/src/client/theme/ui/Navbar/GithubStars.tsx +0 -27
  199. package/src/client/theme/ui/Navbar/Navbar.tsx +0 -193
  200. package/src/client/theme/ui/Navbar/Tabs.tsx +0 -99
  201. package/src/client/theme/ui/Navbar/index.ts +0 -2
  202. package/src/client/theme/ui/Navbar/navbar.css +0 -347
  203. package/src/client/theme/ui/NotFound/NotFound.tsx +0 -19
  204. package/src/client/theme/ui/NotFound/index.ts +0 -1
  205. package/src/client/theme/ui/NotFound/not-found.css +0 -64
  206. package/src/client/theme/ui/OnThisPage/OnThisPage.tsx +0 -244
  207. package/src/client/theme/ui/OnThisPage/index.ts +0 -1
  208. package/src/client/theme/ui/OnThisPage/toc.css +0 -152
  209. package/src/client/theme/ui/PoweredBy/PoweredBy.tsx +0 -18
  210. package/src/client/theme/ui/PoweredBy/index.ts +0 -1
  211. package/src/client/theme/ui/PoweredBy/powered-by.css +0 -76
  212. package/src/client/theme/ui/ProgressBar/ProgressBar.css +0 -17
  213. package/src/client/theme/ui/ProgressBar/ProgressBar.tsx +0 -51
  214. package/src/client/theme/ui/ProgressBar/index.ts +0 -1
  215. package/src/client/theme/ui/SearchDialog/SearchDialog.tsx +0 -209
  216. package/src/client/theme/ui/SearchDialog/index.ts +0 -1
  217. package/src/client/theme/ui/SearchDialog/search.css +0 -152
  218. package/src/client/theme/ui/Sidebar/Sidebar.tsx +0 -244
  219. package/src/client/theme/ui/Sidebar/index.ts +0 -1
  220. package/src/client/theme/ui/Sidebar/sidebar.css +0 -230
  221. package/src/client/theme/ui/ThemeToggle/ThemeToggle.tsx +0 -69
  222. package/src/client/theme/ui/ThemeToggle/index.ts +0 -1
  223. package/src/client/theme/ui/VersionSwitcher/VersionSwitcher.tsx +0 -136
  224. package/src/client/theme/ui/VersionSwitcher/index.ts +0 -1
  225. package/src/client/utils.ts +0 -49
@@ -1,697 +0,0 @@
1
- import {
2
- Breadcrumbs,
3
- CodeBlock,
4
- Head,
5
- Loading,
6
- Navbar,
7
- NotFound,
8
- OnThisPage,
9
- Sidebar,
10
- ThemeLayout,
11
- createBoltdocsApp
12
- } from "../chunk-TKLQWU7H.mjs";
13
- import {
14
- Video
15
- } from "../chunk-Z7JHYNAS.mjs";
16
- import {
17
- Bun,
18
- Deno,
19
- NPM,
20
- Pnpm
21
- } from "../chunk-7SFUJWTB.mjs";
22
- import "../chunk-FMTOYQLO.mjs";
23
-
24
- // src/client/theme/components/Playground/Playground.tsx
25
- import React, { useState, useMemo } from "react";
26
- import { LiveProvider, LiveEditor, LiveError, LivePreview } from "react-live";
27
- import { Copy, Check, Terminal, Play } from "lucide-react";
28
- import { jsx, jsxs } from "react/jsx-runtime";
29
- function prepareCode(raw) {
30
- const trimmed = (raw || "").trim();
31
- const fnMatch = trimmed.match(/export\s+default\s+function\s+(\w+)/);
32
- if (fnMatch) {
33
- const name = fnMatch[1];
34
- const code = trimmed.replace(/export\s+default\s+/, "") + `
35
-
36
- render(<${name} />);`;
37
- return { code, noInline: true };
38
- }
39
- const varMatch = trimmed.match(/export\s+default\s+(\w+)\s*;?\s*$/);
40
- if (varMatch) {
41
- const name = varMatch[1];
42
- const code = trimmed.replace(/export\s+default\s+\w+\s*;?\s*$/, "") + `
43
- render(<${name} />);`;
44
- return { code, noInline: true };
45
- }
46
- return { code: trimmed, noInline: false };
47
- }
48
- function Playground({
49
- code: propsCode,
50
- children,
51
- preview,
52
- scope = {},
53
- readonly = false,
54
- noInline: forceNoInline
55
- }) {
56
- const initialCode = useMemo(() => {
57
- let base = propsCode || "";
58
- if (!base && typeof children === "string") {
59
- base = children;
60
- }
61
- return base.trim();
62
- }, [propsCode, children]);
63
- const prepared = useMemo(() => prepareCode(initialCode), [initialCode]);
64
- const useNoInline = forceNoInline ?? prepared.noInline;
65
- const [copied, setCopied] = useState(false);
66
- const [activeCode, setActiveCode] = useState(prepared.code);
67
- const [isExpanded, setIsExpanded] = useState(false);
68
- React.useEffect(() => {
69
- setActiveCode(prepared.code);
70
- }, [prepared.code]);
71
- const handleCopy = () => {
72
- const textToCopy = !!preview ? initialCode : activeCode;
73
- navigator.clipboard.writeText(textToCopy);
74
- setCopied(true);
75
- setTimeout(() => setCopied(false), 2e3);
76
- };
77
- const extendedScope = { React, ...scope };
78
- const charLimit = 800;
79
- const isExpandable = (propsCode || initialCode).length > charLimit;
80
- const shouldTruncate = isExpandable && !isExpanded;
81
- const isStatic = !!preview;
82
- const staticTransform = (code) => {
83
- return "render(<div style={{display:'none'}} />)";
84
- };
85
- return /* @__PURE__ */ jsx("div", { className: `boltdocs-playground ${shouldTruncate ? "is-truncated" : ""}`, "data-readonly": readonly || isStatic, children: /* @__PURE__ */ jsxs("div", { className: "playground-split-container", children: [
86
- /* @__PURE__ */ jsxs("div", { className: "playground-panel playground-preview-panel", children: [
87
- /* @__PURE__ */ jsx("div", { className: "playground-panel-header", children: /* @__PURE__ */ jsxs("div", { className: "playground-panel-title", children: [
88
- /* @__PURE__ */ jsx(Play, { size: 14 }),
89
- /* @__PURE__ */ jsx("span", { children: "Preview" })
90
- ] }) }),
91
- /* @__PURE__ */ jsx("div", { className: "playground-panel-content playground-preview", children: isStatic ? preview : /* @__PURE__ */ jsxs(
92
- LiveProvider,
93
- {
94
- code: activeCode,
95
- scope: extendedScope,
96
- theme: void 0,
97
- noInline: useNoInline,
98
- children: [
99
- /* @__PURE__ */ jsx(LivePreview, {}),
100
- /* @__PURE__ */ jsx(LiveError, { className: "playground-error" })
101
- ]
102
- }
103
- ) })
104
- ] }),
105
- /* @__PURE__ */ jsxs("div", { className: "playground-panel playground-editor-panel", children: [
106
- !isStatic && /* @__PURE__ */ jsx("div", { className: "playground-panel-header", children: /* @__PURE__ */ jsxs("div", { className: "playground-panel-title", children: [
107
- /* @__PURE__ */ jsx(Terminal, { size: 14 }),
108
- /* @__PURE__ */ jsx("span", { children: readonly ? "Code Example" : "Live Editor" })
109
- ] }) }),
110
- /* @__PURE__ */ jsxs("div", { className: "playground-panel-content playground-editor", children: [
111
- /* @__PURE__ */ jsx(
112
- "button",
113
- {
114
- className: "playground-copy-btn-inner",
115
- onClick: handleCopy,
116
- title: "Copy code",
117
- children: copied ? /* @__PURE__ */ jsx(Check, { size: 14 }) : /* @__PURE__ */ jsx(Copy, { size: 14 })
118
- }
119
- ),
120
- isStatic ? /* @__PURE__ */ jsx(
121
- LiveProvider,
122
- {
123
- code: initialCode,
124
- noInline: true,
125
- transformCode: staticTransform,
126
- children: /* @__PURE__ */ jsx(LiveEditor, { disabled: true })
127
- }
128
- ) : /* @__PURE__ */ jsx(
129
- LiveProvider,
130
- {
131
- code: activeCode,
132
- scope: extendedScope,
133
- theme: void 0,
134
- noInline: useNoInline,
135
- children: /* @__PURE__ */ jsx(LiveEditor, { disabled: readonly, onChange: setActiveCode })
136
- }
137
- )
138
- ] }),
139
- isExpandable && /* @__PURE__ */ jsx("div", { className: "playground-expand-wrapper", children: /* @__PURE__ */ jsx(
140
- "button",
141
- {
142
- className: "playground-expand-btn",
143
- onClick: () => setIsExpanded(!isExpanded),
144
- children: isExpanded ? "Show less" : "Expand code"
145
- }
146
- ) })
147
- ] })
148
- ] }) });
149
- }
150
-
151
- // src/client/theme/components/mdx/Button.tsx
152
- import { jsx as jsx2 } from "react/jsx-runtime";
153
- function Button({
154
- variant = "primary",
155
- size = "md",
156
- href,
157
- children,
158
- className = "",
159
- ...rest
160
- }) {
161
- const cls = `ld-btn ld-btn--${variant} ld-btn--${size} ${className}`.trim();
162
- if (href) {
163
- return /* @__PURE__ */ jsx2(
164
- "a",
165
- {
166
- href,
167
- style: { textDecoration: "none" },
168
- className: cls,
169
- ...rest,
170
- children
171
- }
172
- );
173
- }
174
- return /* @__PURE__ */ jsx2("button", { className: cls, ...rest, children });
175
- }
176
-
177
- // src/client/theme/components/mdx/Badge.tsx
178
- import { jsx as jsx3 } from "react/jsx-runtime";
179
- function Badge({
180
- variant = "default",
181
- children,
182
- className = "",
183
- ...rest
184
- }) {
185
- return /* @__PURE__ */ jsx3(
186
- "span",
187
- {
188
- className: `ld-badge ld-badge--${variant} ${className}`.trim(),
189
- ...rest,
190
- children
191
- }
192
- );
193
- }
194
-
195
- // src/client/theme/components/mdx/Card.tsx
196
- import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
197
- function Cards({
198
- cols = 3,
199
- children,
200
- className = "",
201
- ...rest
202
- }) {
203
- return /* @__PURE__ */ jsx4("div", { className: `ld-cards ld-cards--${cols} ${className}`.trim(), ...rest, children });
204
- }
205
- function Card({
206
- title,
207
- icon,
208
- href,
209
- children,
210
- className = "",
211
- ...rest
212
- }) {
213
- const inner = /* @__PURE__ */ jsxs2(Fragment, { children: [
214
- icon && /* @__PURE__ */ jsx4("span", { className: "ld-card__icon", children: icon }),
215
- title && /* @__PURE__ */ jsx4("h3", { className: "ld-card__title", children: title }),
216
- children && /* @__PURE__ */ jsx4("div", { className: "ld-card__body", children })
217
- ] });
218
- if (href) {
219
- return /* @__PURE__ */ jsx4(
220
- "a",
221
- {
222
- href,
223
- className: `ld-card ld-card--link ${className}`.trim(),
224
- ...rest,
225
- children: inner
226
- }
227
- );
228
- }
229
- return /* @__PURE__ */ jsx4("div", { className: `ld-card ${className}`.trim(), ...rest, children: inner });
230
- }
231
-
232
- // src/client/theme/components/mdx/Tabs.tsx
233
- import { useState as useState2, Children, isValidElement, useRef } from "react";
234
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
235
- function Tab({ children }) {
236
- const content = typeof children === "string" ? /* @__PURE__ */ jsx5(CodeBlock, { className: "language-bash", children: /* @__PURE__ */ jsx5("code", { children: children.trim() }) }) : children;
237
- return /* @__PURE__ */ jsx5("div", { className: "ld-tab-panel", children: content });
238
- }
239
- var getIconForLabel = (label) => {
240
- const l = label.toLowerCase();
241
- if (l.includes("pnpm")) return /* @__PURE__ */ jsx5(Pnpm, {});
242
- if (l.includes("npm")) return /* @__PURE__ */ jsx5(NPM, {});
243
- if (l.includes("bun")) return /* @__PURE__ */ jsx5(Bun, {});
244
- if (l.includes("deno")) return /* @__PURE__ */ jsx5(Deno, {});
245
- return null;
246
- };
247
- function Tabs({ defaultIndex = 0, children }) {
248
- const [active, setActive] = useState2(defaultIndex);
249
- const tabRefs = useRef([]);
250
- const tabs = Children.toArray(children).filter(
251
- (child) => isValidElement(child) && child.props?.label
252
- );
253
- const handleKeyDown = (e) => {
254
- let newIndex = active;
255
- if (e.key === "ArrowRight") {
256
- newIndex = (active + 1) % tabs.length;
257
- } else if (e.key === "ArrowLeft") {
258
- newIndex = (active - 1 + tabs.length) % tabs.length;
259
- }
260
- if (newIndex !== active) {
261
- setActive(newIndex);
262
- tabRefs.current[newIndex]?.focus();
263
- }
264
- };
265
- return /* @__PURE__ */ jsxs3("div", { className: "ld-tabs", children: [
266
- /* @__PURE__ */ jsx5("div", { className: "ld-tabs__bar", role: "tablist", onKeyDown: handleKeyDown, children: tabs.map((child, i) => {
267
- const label = child.props.label;
268
- const Icon = getIconForLabel(label);
269
- return /* @__PURE__ */ jsxs3(
270
- "button",
271
- {
272
- role: "tab",
273
- "aria-selected": i === active,
274
- "aria-controls": `tabpanel-${i}`,
275
- id: `tab-${i}`,
276
- tabIndex: i === active ? 0 : -1,
277
- ref: (el) => {
278
- tabRefs.current[i] = el;
279
- },
280
- className: `ld-tabs__trigger ${i === active ? "ld-tabs__trigger--active" : ""}`,
281
- onClick: () => setActive(i),
282
- children: [
283
- Icon,
284
- /* @__PURE__ */ jsx5("span", { children: label })
285
- ]
286
- },
287
- i
288
- );
289
- }) }),
290
- /* @__PURE__ */ jsx5(
291
- "div",
292
- {
293
- className: "ld-tabs__content",
294
- role: "tabpanel",
295
- id: `tabpanel-${active}`,
296
- "aria-labelledby": `tab-${active}`,
297
- children: tabs[active]
298
- }
299
- )
300
- ] });
301
- }
302
-
303
- // src/client/theme/components/mdx/Admonition.tsx
304
- import {
305
- Info,
306
- Lightbulb,
307
- AlertTriangle,
308
- ShieldAlert,
309
- Bookmark
310
- } from "lucide-react";
311
- import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
312
- var ICON_MAP = {
313
- note: /* @__PURE__ */ jsx6(Bookmark, { size: 18 }),
314
- tip: /* @__PURE__ */ jsx6(Lightbulb, { size: 18 }),
315
- info: /* @__PURE__ */ jsx6(Info, { size: 18 }),
316
- warning: /* @__PURE__ */ jsx6(AlertTriangle, { size: 18 }),
317
- danger: /* @__PURE__ */ jsx6(ShieldAlert, { size: 18 })
318
- };
319
- var LABEL_MAP = {
320
- note: "Note",
321
- tip: "Tip",
322
- info: "Info",
323
- warning: "Warning",
324
- danger: "Danger"
325
- };
326
- function Admonition({
327
- type = "note",
328
- title,
329
- children,
330
- className = "",
331
- ...rest
332
- }) {
333
- return /* @__PURE__ */ jsxs4(
334
- "div",
335
- {
336
- className: `ld-admonition ld-admonition--${type} ${className}`.trim(),
337
- role: type === "warning" || type === "danger" ? "alert" : "note",
338
- ...rest,
339
- children: [
340
- /* @__PURE__ */ jsxs4("div", { className: "ld-admonition__header", children: [
341
- /* @__PURE__ */ jsx6("span", { className: "ld-admonition__icon", children: ICON_MAP[type] }),
342
- /* @__PURE__ */ jsx6("span", { className: "ld-admonition__title", children: title || LABEL_MAP[type] })
343
- ] }),
344
- /* @__PURE__ */ jsx6("div", { className: "ld-admonition__body", children })
345
- ]
346
- }
347
- );
348
- }
349
- var Note = (props) => /* @__PURE__ */ jsx6(Admonition, { type: "note", ...props });
350
- var Tip = (props) => /* @__PURE__ */ jsx6(Admonition, { type: "tip", ...props });
351
- var Warning = (props) => /* @__PURE__ */ jsx6(Admonition, { type: "warning", ...props });
352
- var Danger = (props) => /* @__PURE__ */ jsx6(Admonition, { type: "danger", ...props });
353
- var InfoBox = (props) => /* @__PURE__ */ jsx6(Admonition, { type: "info", ...props });
354
-
355
- // src/client/theme/components/mdx/List.tsx
356
- import React3, { Children as Children2 } from "react";
357
- import { Check as Check2, ChevronRight } from "lucide-react";
358
- import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
359
- var ICON_MAP2 = {
360
- checked: /* @__PURE__ */ jsx7(Check2, { size: 14, className: "ld-list__icon" }),
361
- arrow: /* @__PURE__ */ jsx7(ChevronRight, { size: 14, className: "ld-list__icon" })
362
- };
363
- function List({
364
- variant = "default",
365
- children,
366
- className = "",
367
- ...rest
368
- }) {
369
- if (variant === "default") {
370
- return /* @__PURE__ */ jsx7("ul", { className: `ld-list ${className}`.trim(), ...rest, children });
371
- }
372
- const icon = ICON_MAP2[variant];
373
- return /* @__PURE__ */ jsx7("ul", { className: `ld-list ld-list--${variant} ${className}`.trim(), ...rest, children: Children2.map(children, (child) => {
374
- if (!React3.isValidElement(child)) return child;
375
- return /* @__PURE__ */ jsxs5("li", { className: "ld-list__item", children: [
376
- icon,
377
- /* @__PURE__ */ jsx7("span", { className: "ld-list__text", children: child.props.children })
378
- ] });
379
- }) });
380
- }
381
-
382
- // src/client/theme/components/mdx/FileTree.tsx
383
- import React4, { Children as Children3, isValidElement as isValidElement2, useState as useState3 } from "react";
384
- import {
385
- Folder,
386
- FileText,
387
- File,
388
- FileCode,
389
- FileImage,
390
- ChevronRight as ChevronRight2
391
- } from "lucide-react";
392
- import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
393
- function getTextContent(node) {
394
- if (typeof node === "string") return node;
395
- if (typeof node === "number") return node.toString();
396
- if (Array.isArray(node)) return node.map(getTextContent).join("");
397
- if (isValidElement2(node)) {
398
- return getTextContent(node.props.children);
399
- }
400
- return "";
401
- }
402
- function getFileIcon(filename) {
403
- const name = filename.toLowerCase();
404
- if (name.endsWith(".ts") || name.endsWith(".tsx") || name.endsWith(".js") || name.endsWith(".jsx") || name.endsWith(".json") || name.endsWith(".mjs") || name.endsWith(".cjs") || name.endsWith(".astro") || name.endsWith(".vue") || name.endsWith(".svelte")) {
405
- return /* @__PURE__ */ jsx8(FileCode, { size: 16, strokeWidth: 2, className: "ld-file-tree__icon-file" });
406
- }
407
- if (name.endsWith(".md") || name.endsWith(".mdx") || name.endsWith(".txt")) {
408
- return /* @__PURE__ */ jsx8(FileText, { size: 16, strokeWidth: 2, className: "ld-file-tree__icon-file" });
409
- }
410
- if (name.endsWith(".png") || name.endsWith(".jpg") || name.endsWith(".jpeg") || name.endsWith(".svg") || name.endsWith(".gif")) {
411
- return /* @__PURE__ */ jsx8(
412
- FileImage,
413
- {
414
- size: 16,
415
- strokeWidth: 2,
416
- className: "ld-file-tree__icon-file"
417
- }
418
- );
419
- }
420
- return /* @__PURE__ */ jsx8(File, { size: 16, strokeWidth: 2, className: "ld-file-tree__icon-file" });
421
- }
422
- function isListElement(node, tag) {
423
- if (typeof node.type === "string") {
424
- return node.type === tag;
425
- }
426
- if (typeof node.type === "function") {
427
- return node.type.name === tag || node.type.name?.toLowerCase() === tag;
428
- }
429
- if (node.props && node.props.originalType === tag) {
430
- return true;
431
- }
432
- if (node.props && node.props.mdxType === tag) {
433
- return true;
434
- }
435
- return false;
436
- }
437
- function FolderNode({
438
- labelText,
439
- nestedNodes,
440
- depth
441
- }) {
442
- const [isOpen, setIsOpen] = useState3(true);
443
- return /* @__PURE__ */ jsxs6("li", { className: "ld-file-tree__item", children: [
444
- /* @__PURE__ */ jsxs6(
445
- "div",
446
- {
447
- className: "ld-file-tree__label ld-file-tree__label--folder",
448
- onClick: () => setIsOpen(!isOpen),
449
- style: { cursor: "pointer" },
450
- children: [
451
- /* @__PURE__ */ jsx8("span", { className: "ld-file-tree__icon ld-file-tree__icon--chevron", children: /* @__PURE__ */ jsx8(
452
- ChevronRight2,
453
- {
454
- size: 14,
455
- className: `ld-file-tree__chevron ${isOpen ? "ld-file-tree__chevron--open" : ""}`,
456
- strokeWidth: 3
457
- }
458
- ) }),
459
- /* @__PURE__ */ jsx8("span", { className: "ld-file-tree__icon", children: /* @__PURE__ */ jsx8(
460
- Folder,
461
- {
462
- size: 16,
463
- strokeWidth: 2,
464
- className: "ld-file-tree__icon-folder",
465
- fill: "currentColor",
466
- fillOpacity: 0.15
467
- }
468
- ) }),
469
- /* @__PURE__ */ jsx8("span", { className: "ld-file-tree__name", children: labelText })
470
- ]
471
- }
472
- ),
473
- isOpen && nestedNodes.length > 0 && /* @__PURE__ */ jsx8("div", { className: "ld-file-tree__nested", children: nestedNodes.map((child, index) => /* @__PURE__ */ jsx8(React4.Fragment, { children: parseNode(child, depth) }, index)) })
474
- ] });
475
- }
476
- function parseNode(node, depth = 0) {
477
- if (!isValidElement2(node)) {
478
- return node;
479
- }
480
- if (isListElement(node, "ul")) {
481
- return /* @__PURE__ */ jsx8(
482
- "ul",
483
- {
484
- className: `ld-file-tree__list ${depth === 0 ? "ld-file-tree__list--root" : ""}`,
485
- children: Children3.map(node.props.children, (child, index) => /* @__PURE__ */ jsx8(React4.Fragment, { children: parseNode(child, depth + 1) }, index))
486
- }
487
- );
488
- }
489
- if (isListElement(node, "li")) {
490
- const children = Children3.toArray(node.props.children);
491
- const nestedListIndex = children.findIndex(
492
- (child) => isValidElement2(child) && isListElement(child, "ul")
493
- );
494
- const hasNested = nestedListIndex !== -1;
495
- const labelNodes = hasNested ? children.slice(0, nestedListIndex) : children;
496
- const nestedNodes = hasNested ? children.slice(nestedListIndex) : [];
497
- const rawLabelContent = getTextContent(labelNodes).trim();
498
- const isExplicitDir = rawLabelContent.endsWith("/");
499
- const labelText = isExplicitDir ? rawLabelContent.slice(0, -1) : rawLabelContent;
500
- const isFolder = hasNested || isExplicitDir;
501
- if (isFolder) {
502
- return /* @__PURE__ */ jsx8(
503
- FolderNode,
504
- {
505
- labelText,
506
- nestedNodes,
507
- depth
508
- }
509
- );
510
- }
511
- return /* @__PURE__ */ jsx8("li", { className: "ld-file-tree__item", children: /* @__PURE__ */ jsxs6("div", { className: "ld-file-tree__label ld-file-tree__label--file", children: [
512
- /* @__PURE__ */ jsx8("span", { className: "ld-file-tree__icon ld-file-tree__icon--spacer" }),
513
- /* @__PURE__ */ jsx8("span", { className: "ld-file-tree__icon", children: getFileIcon(labelText) }),
514
- /* @__PURE__ */ jsx8("span", { className: "ld-file-tree__name", children: labelText })
515
- ] }) });
516
- }
517
- if (node.props.children) {
518
- return Children3.map(node.props.children, (child, index) => /* @__PURE__ */ jsx8(React4.Fragment, { children: parseNode(child, depth) }, index));
519
- }
520
- return node;
521
- }
522
- function FileTree({ children }) {
523
- return /* @__PURE__ */ jsx8("div", { className: "ld-file-tree", dir: "ltr", children: Children3.map(children, (child) => parseNode(child, 0)) });
524
- }
525
-
526
- // src/client/theme/components/mdx/Table.tsx
527
- import { useState as useState4, useMemo as useMemo2 } from "react";
528
- import { ChevronUp, ChevronDown, ChevronLeft, ChevronRight as ChevronRight3, ChevronsLeft, ChevronsRight } from "lucide-react";
529
- import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
530
- function Table({
531
- headers,
532
- data,
533
- children,
534
- className = "",
535
- sortable = false,
536
- paginated = false,
537
- pageSize = 10
538
- }) {
539
- const [sortConfig, setSortConfig] = useState4(null);
540
- const [currentPage, setCurrentPage] = useState4(1);
541
- const processedData = useMemo2(() => {
542
- if (!data) return [];
543
- let items = [...data];
544
- if (sortable && sortConfig !== null) {
545
- items.sort((a, b) => {
546
- const aVal = a[sortConfig.key];
547
- const bVal = b[sortConfig.key];
548
- const aStr = typeof aVal === "string" ? aVal : "";
549
- const bStr = typeof bVal === "string" ? bVal : "";
550
- if (aStr < bStr) return sortConfig.direction === "asc" ? -1 : 1;
551
- if (aStr > bStr) return sortConfig.direction === "asc" ? 1 : -1;
552
- return 0;
553
- });
554
- }
555
- return items;
556
- }, [data, sortConfig, sortable]);
557
- const totalPages = Math.ceil(processedData.length / pageSize);
558
- const paginatedData = useMemo2(() => {
559
- if (!paginated) return processedData;
560
- const start = (currentPage - 1) * pageSize;
561
- return processedData.slice(start, start + pageSize);
562
- }, [processedData, paginated, currentPage, pageSize]);
563
- const requestSort = (index) => {
564
- if (!sortable) return;
565
- let direction = "asc";
566
- if (sortConfig && sortConfig.key === index && sortConfig.direction === "asc") {
567
- direction = "desc";
568
- }
569
- setSortConfig({ key: index, direction });
570
- };
571
- const renderSortIcon = (index) => {
572
- if (!sortable) return null;
573
- if (sortConfig?.key !== index) return /* @__PURE__ */ jsx9(ChevronDown, { size: 14, className: "ld-table-sort-icon ld-table-sort-icon--hidden" });
574
- return sortConfig.direction === "asc" ? /* @__PURE__ */ jsx9(ChevronUp, { size: 14, className: "ld-table-sort-icon" }) : /* @__PURE__ */ jsx9(ChevronDown, { size: 14, className: "ld-table-sort-icon" });
575
- };
576
- const tableContent = children ? children : /* @__PURE__ */ jsxs7(Fragment2, { children: [
577
- headers && /* @__PURE__ */ jsx9("thead", { children: /* @__PURE__ */ jsx9("tr", { children: headers.map((header, i) => /* @__PURE__ */ jsx9(
578
- "th",
579
- {
580
- onClick: () => requestSort(i),
581
- className: sortable ? "ld-table-header--sortable" : "",
582
- children: /* @__PURE__ */ jsxs7("div", { className: "ld-table-header-content", children: [
583
- header,
584
- renderSortIcon(i)
585
- ] })
586
- },
587
- i
588
- )) }) }),
589
- paginatedData && /* @__PURE__ */ jsx9("tbody", { children: paginatedData.map((row, i) => /* @__PURE__ */ jsx9("tr", { children: row.map((cell, j) => /* @__PURE__ */ jsx9("td", { children: cell }, j)) }, i)) })
590
- ] });
591
- return /* @__PURE__ */ jsxs7("div", { className: `ld-table-container ${className}`.trim(), children: [
592
- /* @__PURE__ */ jsx9("div", { className: "ld-table-wrapper", children: /* @__PURE__ */ jsx9("table", { className: "ld-table", children: tableContent }) }),
593
- paginated && totalPages > 1 && /* @__PURE__ */ jsxs7("div", { className: "ld-table-pagination", children: [
594
- /* @__PURE__ */ jsxs7("div", { className: "ld-table-pagination-info", children: [
595
- "Page ",
596
- currentPage,
597
- " of ",
598
- totalPages
599
- ] }),
600
- /* @__PURE__ */ jsxs7("div", { className: "ld-table-pagination-controls", children: [
601
- /* @__PURE__ */ jsx9(
602
- "button",
603
- {
604
- onClick: () => setCurrentPage(1),
605
- disabled: currentPage === 1,
606
- className: "ld-table-pagination-btn",
607
- children: /* @__PURE__ */ jsx9(ChevronsLeft, { size: 16 })
608
- }
609
- ),
610
- /* @__PURE__ */ jsx9(
611
- "button",
612
- {
613
- onClick: () => setCurrentPage((prev) => Math.max(prev - 1, 1)),
614
- disabled: currentPage === 1,
615
- className: "ld-table-pagination-btn",
616
- children: /* @__PURE__ */ jsx9(ChevronLeft, { size: 16 })
617
- }
618
- ),
619
- /* @__PURE__ */ jsx9(
620
- "button",
621
- {
622
- onClick: () => setCurrentPage((prev) => Math.min(prev + 1, totalPages)),
623
- disabled: currentPage === totalPages,
624
- className: "ld-table-pagination-btn",
625
- children: /* @__PURE__ */ jsx9(ChevronRight3, { size: 16 })
626
- }
627
- ),
628
- /* @__PURE__ */ jsx9(
629
- "button",
630
- {
631
- onClick: () => setCurrentPage(totalPages),
632
- disabled: currentPage === totalPages,
633
- className: "ld-table-pagination-btn",
634
- children: /* @__PURE__ */ jsx9(ChevronsRight, { size: 16 })
635
- }
636
- )
637
- ] })
638
- ] })
639
- ] });
640
- }
641
-
642
- // src/client/theme/components/mdx/Field.tsx
643
- import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
644
- function Field({
645
- name,
646
- type,
647
- defaultValue,
648
- required = false,
649
- children,
650
- id,
651
- className = ""
652
- }) {
653
- return /* @__PURE__ */ jsxs8("div", { className: `ld-field ${className}`.trim(), id, children: [
654
- /* @__PURE__ */ jsxs8("div", { className: "ld-field__header", children: [
655
- /* @__PURE__ */ jsxs8("div", { className: "ld-field__signature", children: [
656
- /* @__PURE__ */ jsx10("code", { className: "ld-field__name", children: name }),
657
- type && /* @__PURE__ */ jsx10("span", { className: "ld-field__type-badge", children: type }),
658
- required && /* @__PURE__ */ jsx10("span", { className: "ld-field__required-badge", children: "required" })
659
- ] }),
660
- defaultValue && /* @__PURE__ */ jsxs8("div", { className: "ld-field__default", children: [
661
- /* @__PURE__ */ jsx10("span", { className: "ld-field__default-label", children: "Default:" }),
662
- /* @__PURE__ */ jsx10("code", { className: "ld-field__default-value", children: defaultValue })
663
- ] })
664
- ] }),
665
- /* @__PURE__ */ jsx10("div", { className: "ld-field__content", children })
666
- ] });
667
- }
668
- export {
669
- Admonition,
670
- Badge,
671
- Breadcrumbs,
672
- Button,
673
- Card,
674
- Cards,
675
- CodeBlock,
676
- Danger,
677
- Field,
678
- FileTree,
679
- Head,
680
- InfoBox,
681
- List,
682
- Loading,
683
- Navbar,
684
- NotFound,
685
- Note,
686
- OnThisPage,
687
- Playground,
688
- Sidebar,
689
- Tab,
690
- Table,
691
- Tabs,
692
- ThemeLayout,
693
- Tip,
694
- Video,
695
- Warning,
696
- createBoltdocsApp
697
- };