doccupine 0.0.134 → 0.0.136

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 (85) hide show
  1. package/README.md +11 -9
  2. package/dist/index.js +282 -46
  3. package/dist/lib/metadata.d.ts +5 -0
  4. package/dist/lib/metadata.js +15 -4
  5. package/dist/lib/rss.d.ts +24 -0
  6. package/dist/lib/rss.js +137 -0
  7. package/dist/lib/structures.js +22 -2
  8. package/dist/templates/app/rssRoute.d.ts +11 -0
  9. package/dist/templates/app/rssRoute.js +30 -0
  10. package/dist/templates/components/Docs.d.ts +1 -1
  11. package/dist/templates/components/Docs.js +5 -2
  12. package/dist/templates/components/MDXComponents.d.ts +1 -1
  13. package/dist/templates/components/MDXComponents.js +29 -0
  14. package/dist/templates/components/SideBar.d.ts +1 -1
  15. package/dist/templates/components/SideBar.js +5 -2
  16. package/dist/templates/components/layout/ActionBar.d.ts +1 -1
  17. package/dist/templates/components/layout/ActionBar.js +44 -13
  18. package/dist/templates/components/layout/ApiPlayground.d.ts +1 -1
  19. package/dist/templates/components/layout/ApiPlayground.js +20 -28
  20. package/dist/templates/components/layout/Badge.d.ts +1 -0
  21. package/dist/templates/components/layout/Badge.js +455 -0
  22. package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
  23. package/dist/templates/components/layout/DocsComponents.js +5 -30
  24. package/dist/templates/components/layout/Prompt.d.ts +1 -0
  25. package/dist/templates/components/layout/Prompt.js +149 -0
  26. package/dist/templates/components/layout/Tooltip.d.ts +1 -0
  27. package/dist/templates/components/layout/Tooltip.js +222 -0
  28. package/dist/templates/components/layout/Tree.d.ts +1 -0
  29. package/dist/templates/components/layout/Tree.js +322 -0
  30. package/dist/templates/components/layout/TreeData.d.ts +1 -0
  31. package/dist/templates/components/layout/TreeData.js +131 -0
  32. package/dist/templates/components/layout/Update.d.ts +1 -1
  33. package/dist/templates/components/layout/Update.js +3 -0
  34. package/dist/templates/lib/rss.d.ts +1 -0
  35. package/dist/templates/lib/rss.js +83 -0
  36. package/dist/templates/mdx/accordion.mdx.d.ts +1 -1
  37. package/dist/templates/mdx/accordion.mdx.js +1 -1
  38. package/dist/templates/mdx/api-playground.mdx.d.ts +1 -1
  39. package/dist/templates/mdx/api-playground.mdx.js +1 -1
  40. package/dist/templates/mdx/badges.mdx.d.ts +1 -0
  41. package/dist/templates/mdx/badges.mdx.js +237 -0
  42. package/dist/templates/mdx/buttons.mdx.d.ts +1 -1
  43. package/dist/templates/mdx/buttons.mdx.js +1 -1
  44. package/dist/templates/mdx/callouts.mdx.d.ts +1 -1
  45. package/dist/templates/mdx/callouts.mdx.js +1 -1
  46. package/dist/templates/mdx/cards.mdx.d.ts +1 -1
  47. package/dist/templates/mdx/cards.mdx.js +1 -1
  48. package/dist/templates/mdx/color-swatches.mdx.d.ts +1 -1
  49. package/dist/templates/mdx/color-swatches.mdx.js +1 -1
  50. package/dist/templates/mdx/columns.mdx.d.ts +1 -1
  51. package/dist/templates/mdx/columns.mdx.js +1 -1
  52. package/dist/templates/mdx/components.mdx.d.ts +1 -1
  53. package/dist/templates/mdx/components.mdx.js +14 -2
  54. package/dist/templates/mdx/fields.mdx.d.ts +1 -1
  55. package/dist/templates/mdx/fields.mdx.js +1 -1
  56. package/dist/templates/mdx/frames.mdx.d.ts +1 -1
  57. package/dist/templates/mdx/frames.mdx.js +1 -1
  58. package/dist/templates/mdx/icons.mdx.d.ts +1 -1
  59. package/dist/templates/mdx/icons.mdx.js +1 -1
  60. package/dist/templates/mdx/image-and-embeds.mdx.d.ts +1 -1
  61. package/dist/templates/mdx/image-and-embeds.mdx.js +1 -1
  62. package/dist/templates/mdx/images-and-embeds.mdx.d.ts +1 -0
  63. package/dist/templates/mdx/images-and-embeds.mdx.js +118 -0
  64. package/dist/templates/mdx/mermaid.mdx.d.ts +1 -1
  65. package/dist/templates/mdx/mermaid.mdx.js +1 -1
  66. package/dist/templates/mdx/navigation.mdx.d.ts +1 -1
  67. package/dist/templates/mdx/navigation.mdx.js +5 -1
  68. package/dist/templates/mdx/prompt.mdx.d.ts +1 -0
  69. package/dist/templates/mdx/prompt.mdx.js +69 -0
  70. package/dist/templates/mdx/steps.mdx.d.ts +1 -1
  71. package/dist/templates/mdx/steps.mdx.js +1 -1
  72. package/dist/templates/mdx/tabs.mdx.d.ts +1 -1
  73. package/dist/templates/mdx/tabs.mdx.js +1 -1
  74. package/dist/templates/mdx/tooltips.mdx.d.ts +1 -0
  75. package/dist/templates/mdx/tooltips.mdx.js +57 -0
  76. package/dist/templates/mdx/tree.mdx.d.ts +1 -0
  77. package/dist/templates/mdx/tree.mdx.js +158 -0
  78. package/dist/templates/mdx/update.mdx.d.ts +1 -1
  79. package/dist/templates/mdx/update.mdx.js +42 -2
  80. package/dist/templates/package.js +1 -1
  81. package/package.json +2 -2
  82. package/dist/templates/mdx/platform/external-links.mdx.d.ts +0 -1
  83. package/dist/templates/mdx/platform/external-links.mdx.js +0 -47
  84. package/dist/templates/utils/apiAnchors.d.ts +0 -1
  85. package/dist/templates/utils/apiAnchors.js +0 -39
@@ -0,0 +1,137 @@
1
+ // Feed extraction for subscribable changelogs: pages that contain <Update>
2
+ // blocks publish an RSS feed at {page-url}/rss.xml.
3
+ //
4
+ // Anchor parity is the load-bearing constraint here. Feed entry links are
5
+ // `{pageUrl}#{anchor}`, and the anchor must byte-match the id the generated
6
+ // app assigns: one shared slugger walks the fenced-code-stripped document
7
+ // collecting markdown headings AND <Update label> open tags in byte order
8
+ // (components/Docs.tsx `extractHeadings` + components/MDXComponents.tsx).
9
+ // `slugify`/`createSlugger` below are byte-exact ports of the generated
10
+ // app's components/layout/Slug.ts, and `parseUpdateBlocks` replays that
11
+ // exact walk - headings consume slugger slots too, so an `## Setup` before
12
+ // `<Update label="Setup">` pushes the entry's anchor to "setup-1".
13
+ // rss.test.ts guards both ports against template drift.
14
+ export function slugify(text) {
15
+ return (text ?? "")
16
+ .toLowerCase()
17
+ .replace(/[^\w\s-]/g, "")
18
+ .replace(/\s+/g, "-")
19
+ .trim();
20
+ }
21
+ export function createSlugger() {
22
+ const seen = new Map();
23
+ return (text) => {
24
+ const base = slugify(text);
25
+ const count = seen.get(base) ?? 0;
26
+ seen.set(base, count + 1);
27
+ return count === 0 ? base : `${base}-${count}`;
28
+ };
29
+ }
30
+ export function parseUpdateBlocks(mdx) {
31
+ // Fenced code is stripped before any matching, mirroring extractHeadings:
32
+ // an <Update> example inside a fence is not an entry, and positions below
33
+ // are measured in the stripped string on both sides of the parity contract.
34
+ const content = mdx.replace(/```[\s\S]*?```/g, "");
35
+ const entries = [];
36
+ let match;
37
+ const headingRegex = /^(#{1,6})\s+(.+)$/gm;
38
+ while ((match = headingRegex.exec(content)) !== null) {
39
+ entries.push({
40
+ kind: "heading",
41
+ text: match[2].trim(),
42
+ position: match.index,
43
+ tag: "",
44
+ tagEnd: 0,
45
+ });
46
+ }
47
+ // [^>] spans newlines, so multi-line open tags match - same as the app.
48
+ const updateRegex = /<Update\b[^>]*?\blabel=["']([^"']+)["'][^>]*>/g;
49
+ while ((match = updateRegex.exec(content)) !== null) {
50
+ entries.push({
51
+ kind: "update",
52
+ text: match[1].trim(),
53
+ position: match.index,
54
+ tag: match[0],
55
+ tagEnd: match.index + match[0].length,
56
+ });
57
+ }
58
+ entries.sort((a, b) => a.position - b.position);
59
+ const slug = createSlugger();
60
+ const items = [];
61
+ for (const entry of entries) {
62
+ const anchor = slug(entry.text);
63
+ if (entry.kind !== "update")
64
+ continue;
65
+ const rssAttr = /\brss=["']([^"']*)["']/.exec(entry.tag)?.[1];
66
+ const inner = entry.tag.endsWith("/>")
67
+ ? ""
68
+ : extractInner(content, entry.tagEnd);
69
+ items.push({
70
+ label: entry.text,
71
+ anchor,
72
+ description: rssAttr !== undefined ? rssAttr.trim() : toRssMarkdown(inner),
73
+ });
74
+ }
75
+ return items;
76
+ }
77
+ /**
78
+ * Slice out an Update block's children: scan from the end of its open tag to
79
+ * the matching close tag, tracking depth so nested <Update> blocks close
80
+ * correctly. An unclosed block runs to the end of the document (the renderer
81
+ * swallows the rest of the page in that case too).
82
+ */
83
+ function extractInner(content, from) {
84
+ const token = /<Update\b[^>]*?>|<\/Update\s*>/g;
85
+ token.lastIndex = from;
86
+ let depth = 1;
87
+ let match;
88
+ while ((match = token.exec(content)) !== null) {
89
+ if (match[0].startsWith("</")) {
90
+ depth -= 1;
91
+ if (depth === 0)
92
+ return content.slice(from, match.index);
93
+ }
94
+ else if (!match[0].endsWith("/>")) {
95
+ depth += 1;
96
+ }
97
+ }
98
+ return content.slice(from);
99
+ }
100
+ /**
101
+ * Reduce an Update block's children to pure Markdown for feed readers:
102
+ * components, code, and HTML are removed (tag children text survives),
103
+ * images collapse to their alt text, inline code keeps its text. Markdown
104
+ * inline syntax (emphasis, links, lists, headings) passes through, including
105
+ * autolinks - `<https://...>` never matches the tag pattern because a `:`
106
+ * follows the leading word characters.
107
+ */
108
+ export function toRssMarkdown(inner) {
109
+ const stripped = inner
110
+ .replace(/```[\s\S]*?```/g, "")
111
+ .replace(/<!--[\s\S]*?-->/g, "")
112
+ .replace(/<\/?[A-Za-z][a-zA-Z0-9]*(?:\s[^>]*)?\/?>/g, "")
113
+ .replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1")
114
+ .replace(/`([^`]*)`/g, "$1");
115
+ return dedent(stripped)
116
+ .replace(/[ \t]+$/gm, "")
117
+ .replace(/\n{3,}/g, "\n\n")
118
+ .trim();
119
+ }
120
+ /**
121
+ * Update children are conventionally indented under the open tag; strip the
122
+ * common leading indentation so lists and headings arrive at column 0.
123
+ */
124
+ function dedent(text) {
125
+ const lines = text.split("\n");
126
+ let minIndent = Infinity;
127
+ for (const line of lines) {
128
+ if (line.trim() === "")
129
+ continue;
130
+ const indent = /^ */.exec(line)[0].length;
131
+ if (indent < minIndent)
132
+ minIndent = indent;
133
+ }
134
+ if (!Number.isFinite(minIndent) || minIndent === 0)
135
+ return text;
136
+ return lines.map((line) => line.slice(minIndent)).join("\n");
137
+ }
@@ -33,6 +33,7 @@ import { spinnerTemplate } from "../templates/components/Spinner.js";
33
33
  import { sectionBarTemplate } from "../templates/components/layout/SectionBar.js";
34
34
  import { accordionTemplate } from "../templates/components/layout/Accordion.js";
35
35
  import { actionBarTemplate } from "../templates/components/layout/ActionBar.js";
36
+ import { badgeTemplate } from "../templates/components/layout/Badge.js";
36
37
  import { buttonTemplate } from "../templates/components/layout/Button.js";
37
38
  import { calloutTemplate } from "../templates/components/layout/Callout.js";
38
39
  import { cardTemplate } from "../templates/components/layout/Card.js";
@@ -50,6 +51,7 @@ import { globalStylesTemplate } from "../templates/components/layout/GlobalStyle
50
51
  import { headerTemplate } from "../templates/components/layout/Header.js";
51
52
  import { iconTemplate } from "../templates/components/layout/Icon.js";
52
53
  import { pictogramsTemplate } from "../templates/components/layout/Pictograms.js";
54
+ import { promptTemplate } from "../templates/components/layout/Prompt.js";
53
55
  import { sharedStyledTemplate } from "../templates/components/layout/SharedStyles.js";
54
56
  import { notFoundComponentTemplate } from "../templates/components/layout/NotFound.js";
55
57
  import { siteGateComponentTemplate } from "../templates/components/layout/SiteGate.js";
@@ -57,6 +59,9 @@ import { slugTemplate } from "../templates/components/layout/Slug.js";
57
59
  import { staticLinksTemplate } from "../templates/components/layout/StaticLinks.js";
58
60
  import { stepsTemplate } from "../templates/components/layout/Steps.js";
59
61
  import { tabsTemplate } from "../templates/components/layout/Tabs.js";
62
+ import { tooltipTemplate } from "../templates/components/layout/Tooltip.js";
63
+ import { treeTemplate } from "../templates/components/layout/Tree.js";
64
+ import { treeDataTemplate } from "../templates/components/layout/TreeData.js";
60
65
  import { typographyTemplate } from "../templates/components/layout/Typography.js";
61
66
  import { updateTemplate } from "../templates/components/layout/Update.js";
62
67
  import { searchServiceTemplate } from "../templates/services/search.js";
@@ -72,6 +77,7 @@ import { llmIndexTemplate } from "../templates/services/llm/index.js";
72
77
  import { llmTypesTemplate } from "../templates/services/llm/types.js";
73
78
  import { buildDocsIndexScriptTemplate } from "../templates/scripts/build-docs-index.js";
74
79
  import { posthogServerTemplate } from "../templates/lib/posthog.js";
80
+ import { rssLibTemplate } from "../templates/lib/rss.js";
75
81
  import { siteGateTemplate } from "../templates/lib/siteGate.js";
76
82
  import { styledDTemplate } from "../templates/types/styled.js";
77
83
  import { openapiTypesTemplate } from "../templates/types/openapi.js";
@@ -92,6 +98,7 @@ import { aiAssistantMdxTemplate } from "../templates/mdx/ai-assistant.mdx.js";
92
98
  import { analyticsMdxTemplate } from "../templates/mdx/analytics.mdx.js";
93
99
  import { apiPlaygroundMdxTemplate } from "../templates/mdx/api-playground.mdx.js";
94
100
  import { authenticationMdxTemplate } from "../templates/mdx/authentication.mdx.js";
101
+ import { badgesMdxTemplate } from "../templates/mdx/badges.mdx.js";
95
102
  import { buttonsMdxTemplate } from "../templates/mdx/buttons.mdx.js";
96
103
  import { calloutsMdxTemplate } from "../templates/mdx/callouts.mdx.js";
97
104
  import { cardsMdxTemplate } from "../templates/mdx/cards.mdx.js";
@@ -106,7 +113,7 @@ import { fontsMdxTemplate } from "../templates/mdx/fonts.mdx.js";
106
113
  import { globalsMdxTemplate } from "../templates/mdx/globals.mdx.js";
107
114
  import { headersAndTextMdxTemplate } from "../templates/mdx/headers-and-text.mdx.js";
108
115
  import { iconsMdxTemplate } from "../templates/mdx/icons.mdx.js";
109
- import { imageAndEmbedsMdxTemplate } from "../templates/mdx/image-and-embeds.mdx.js";
116
+ import { imagesAndEmbedsMdxTemplate } from "../templates/mdx/images-and-embeds.mdx.js";
110
117
  import { indexMdxTemplate } from "../templates/mdx/index.mdx.js";
111
118
  import { footerLinksMdxTemplate } from "../templates/mdx/footer-links.mdx.js";
112
119
  import { framesMdxTemplate } from "../templates/mdx/frames.mdx.js";
@@ -115,10 +122,13 @@ import { mediaAndAssetsMdxTemplate } from "../templates/mdx/media-and-assets.mdx
115
122
  import { mermaidMdxTemplate } from "../templates/mdx/mermaid.mdx.js";
116
123
  import { mcpMdxTemplate } from "../templates/mdx/model-context-protocol.mdx.js";
117
124
  import { navigationMdxTemplate } from "../templates/mdx/navigation.mdx.js";
125
+ import { promptMdxTemplate } from "../templates/mdx/prompt.mdx.js";
118
126
  import { sectionsMdxTemplate } from "../templates/mdx/sections.mdx.js";
119
127
  import { stepsMdxTemplate } from "../templates/mdx/steps.mdx.js";
120
128
  import { tabsMdxTemplate } from "../templates/mdx/tabs.mdx.js";
121
129
  import { themeMdxTemplate } from "../templates/mdx/theme.mdx.js";
130
+ import { tooltipsMdxTemplate } from "../templates/mdx/tooltips.mdx.js";
131
+ import { treeMdxTemplate } from "../templates/mdx/tree.mdx.js";
122
132
  import { updateMdxTemplate } from "../templates/mdx/update.mdx.js";
123
133
  import { whatIsDoccupineMdxTemplate } from "../templates/mdx/what-is-doccupine.mdx.js";
124
134
  import { platformIndexMdxTemplate } from "../templates/mdx/platform/index.mdx.js";
@@ -174,6 +184,7 @@ export const appStructure = {
174
184
  "types/styled.d.ts": styledDTemplate,
175
185
  "types/openapi.ts": openapiTypesTemplate,
176
186
  "lib/posthog.ts": posthogServerTemplate,
187
+ "lib/rss.ts": rssLibTemplate,
177
188
  "lib/siteGate.ts": siteGateTemplate,
178
189
  "utils/branding.ts": brandingTemplate,
179
190
  "utils/mermaid.ts": mermaidTemplate,
@@ -202,6 +213,7 @@ export const appStructure = {
202
213
  "components/layout/ActionBar.tsx": actionBarTemplate,
203
214
  "components/layout/ApiPlayground.tsx": apiPlaygroundTemplate,
204
215
  "components/layout/ApiPlaygroundDemo.tsx": apiPlaygroundDemoTemplate,
216
+ "components/layout/Badge.tsx": badgeTemplate,
205
217
  "components/layout/Button.tsx": buttonTemplate,
206
218
  "components/layout/Callout.tsx": calloutTemplate,
207
219
  "components/layout/Card.tsx": cardTemplate,
@@ -222,6 +234,7 @@ export const appStructure = {
222
234
  "components/layout/Icon.tsx": iconTemplate,
223
235
  "components/layout/Mermaid.tsx": mermaidViewTemplate,
224
236
  "components/layout/Pictograms.tsx": pictogramsTemplate,
237
+ "components/layout/Prompt.tsx": promptTemplate,
225
238
  "components/layout/SharedStyled.ts": sharedStyledTemplate,
226
239
  "components/layout/NotFound.tsx": notFoundComponentTemplate,
227
240
  "components/layout/SiteGate.tsx": siteGateComponentTemplate,
@@ -229,6 +242,9 @@ export const appStructure = {
229
242
  "components/layout/StaticLinks.tsx": staticLinksTemplate,
230
243
  "components/layout/Steps.tsx": stepsTemplate,
231
244
  "components/layout/Tabs.tsx": tabsTemplate,
245
+ "components/layout/Tooltip.tsx": tooltipTemplate,
246
+ "components/layout/Tree.tsx": treeTemplate,
247
+ "components/layout/TreeData.ts": treeDataTemplate,
232
248
  "components/layout/Typography.ts": typographyTemplate,
233
249
  "components/layout/Update.tsx": updateTemplate,
234
250
  };
@@ -247,6 +263,7 @@ export const startingDocsStructure = {
247
263
  "analytics.mdx": analyticsMdxTemplate,
248
264
  "api-playground.mdx": apiPlaygroundMdxTemplate,
249
265
  "authentication.mdx": authenticationMdxTemplate,
266
+ "badges.mdx": badgesMdxTemplate,
250
267
  "buttons.mdx": buttonsMdxTemplate,
251
268
  "callouts.mdx": calloutsMdxTemplate,
252
269
  "cards.mdx": cardsMdxTemplate,
@@ -261,7 +278,7 @@ export const startingDocsStructure = {
261
278
  "globals.mdx": globalsMdxTemplate,
262
279
  "headers-and-text.mdx": headersAndTextMdxTemplate,
263
280
  "icons.mdx": iconsMdxTemplate,
264
- "image-and-embeds.mdx": imageAndEmbedsMdxTemplate,
281
+ "images-and-embeds.mdx": imagesAndEmbedsMdxTemplate,
265
282
  "index.mdx": indexMdxTemplate,
266
283
  "footer-links.mdx": footerLinksMdxTemplate,
267
284
  "frames.mdx": framesMdxTemplate,
@@ -270,10 +287,13 @@ export const startingDocsStructure = {
270
287
  "mermaid.mdx": mermaidMdxTemplate,
271
288
  "model-context-protocol.mdx": mcpMdxTemplate,
272
289
  "navigation.mdx": navigationMdxTemplate,
290
+ "prompt.mdx": promptMdxTemplate,
273
291
  "sections.mdx": sectionsMdxTemplate,
274
292
  "steps.mdx": stepsMdxTemplate,
275
293
  "tabs.mdx": tabsMdxTemplate,
276
294
  "theme.mdx": themeMdxTemplate,
295
+ "tooltips.mdx": tooltipsMdxTemplate,
296
+ "tree.mdx": treeMdxTemplate,
277
297
  "update.mdx": updateMdxTemplate,
278
298
  "what-is-doccupine.mdx": whatIsDoccupineMdxTemplate,
279
299
  "platform/index.mdx": platformIndexMdxTemplate,
@@ -0,0 +1,11 @@
1
+ export interface RssRouteData {
2
+ pagePath: string;
3
+ title: string | null;
4
+ description: string | null;
5
+ items: {
6
+ title: string;
7
+ anchor: string;
8
+ description: string;
9
+ }[];
10
+ }
11
+ export declare const rssRouteTemplate: (feed: RssRouteData) => string;
@@ -0,0 +1,30 @@
1
+ import { toJsStringLiteral } from "../../lib/utils.js";
2
+ export const rssRouteTemplate = (feed) => {
3
+ // JSON.stringify + toJsStringLiteral is total escaping for arbitrary entry
4
+ // strings (quotes, newlines, backticks), and JSON.parse at load undoes it -
5
+ // the same trick as the OpenAPI operation embed in generatePageFromMDX.
6
+ // The call always overflows 80 cols, so emit it pre-wrapped in the shape
7
+ // Prettier produces (argument on its own line with a trailing comma) to
8
+ // keep generated routes format-stable without running a formatter.
9
+ const arg = toJsStringLiteral(JSON.stringify(feed));
10
+ const inline = `const FEED: RssFeedData = JSON.parse(${arg});`;
11
+ const decl = inline.length <= 80
12
+ ? inline
13
+ : `const FEED: RssFeedData = JSON.parse(\n ${arg},\n);`;
14
+ return `import { buildRssFeed, type RssFeedData } from "@/lib/rss";
15
+
16
+ // Feed data is extracted from this page's MDX at generation time.
17
+ ${decl}
18
+
19
+ // The feed derives entirely from generation-time content, so it renders once
20
+ // at build and serves from the static cache like the page it belongs to.
21
+ export const dynamic = "force-static";
22
+ export const revalidate = false;
23
+
24
+ export function GET(): Response {
25
+ return new Response(buildRssFeed(FEED), {
26
+ headers: { "Content-Type": "application/rss+xml; charset=utf-8" },
27
+ });
28
+ }
29
+ `;
30
+ };
@@ -1 +1 @@
1
- export declare const docsTemplate = "import React from \"react\";\nimport { Flex } from \"cherry-styled-components\";\nimport {\n DocsContainer,\n StyledMarkdownContainer,\n StyledMissingComponent,\n} from \"@/components/layout/DocsComponents\";\nimport { MDXRemote } from \"next-mdx-remote/rsc\";\nimport remarkGfm from \"remark-gfm\";\nimport { useMDXComponents } from \"@/components/MDXComponents\";\nimport { createMermaidPre } from \"@/components/MermaidPre\";\nimport { DocsSideBar } from \"@/components/DocsSideBar\";\nimport { ActionBar } from \"@/components/layout/ActionBar\";\nimport { ApiPlaygroundDemo } from \"@/components/layout/ApiPlaygroundDemo\";\nimport { createSlugger } from \"@/components/layout/Slug\";\nimport { rehypeCodeMeta } from \"@/utils/rehypeCodeMeta\";\n\ninterface DocsProps {\n content: string;\n sourcePath?: string;\n // Extra content rendered inside the markdown column, after the MDX body.\n // Used to place generated widgets (e.g. the API playground) inside the docs\n // content area rather than outside its layout.\n children?: React.ReactNode;\n}\n\ninterface Heading {\n id: string;\n text: string;\n level: number;\n}\n\nfunction extractHeadings(content: string): Heading[] {\n const contentWithoutCodeBlocks = content.replace(/```[\\s\\S]*?```/g, \"\");\n const entries: { text: string; level: number; position: number }[] = [];\n let match;\n\n // Markdown headings (# .. ######)\n const headingRegex = /^(#{1,6})\\s+(.+)$/gm;\n while ((match = headingRegex.exec(contentWithoutCodeBlocks)) !== null) {\n const level = match[1].length;\n const text = match[2].trim();\n entries.push({ text, level, position: match.index });\n }\n\n // <Update label=\"...\"> blocks surface their label as a top-level entry\n const updateRegex = /<Update\\b[^>]*?\\blabel=[\"']([^\"']+)[\"'][^>]*>/g;\n while ((match = updateRegex.exec(contentWithoutCodeBlocks)) !== null) {\n entries.push({ text: match[1].trim(), level: 1, position: match.index });\n }\n\n // Assign ids in document order with a shared slugger so repeated heading\n // text produces unique anchors (\"setup\", \"setup-1\", ...) that stay in sync\n // with the ids rendered by MDXComponents/Update.\n const slug = createSlugger();\n return entries\n .sort((a, b) => a.position - b.position)\n .map(({ text, level }) => ({ id: slug(text), text, level }));\n}\n\nfunction extractComponentNames(source: string): string[] {\n const stripped = source\n .replace(/```[\\s\\S]*?```/g, \"\")\n .replace(/`[^`]*`/g, \"\");\n const tagRegex = /<([A-Z][a-zA-Z0-9]*)/g;\n const names = new Set<string>();\n let match;\n while ((match = tagRegex.exec(stripped)) !== null) {\n names.add(match[1]);\n }\n return Array.from(names);\n}\n\nfunction MissingComponent({\n componentName,\n children: _children,\n}: {\n componentName: string;\n children?: React.ReactNode;\n}) {\n return (\n <StyledMissingComponent>\n Missing component: &lt;{componentName} /&gt;\n </StyledMissingComponent>\n );\n}\n\nfunction Docs({ content, sourcePath, children }: DocsProps) {\n const headings = extractHeadings(content);\n const components = useMDXComponents({\n pre: createMermaidPre(sourcePath),\n ApiPlaygroundDemo,\n });\n\n const knownNames = Object.keys(components);\n const usedNames = extractComponentNames(content);\n const missingNames = usedNames.filter((name) => !knownNames.includes(name));\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const stubs: Record<string, React.ComponentType<any>> = {};\n for (const name of missingNames) {\n stubs[name] = ({ children }: { children?: React.ReactNode }) => (\n <MissingComponent componentName={name}>{children}</MissingComponent>\n );\n }\n\n const allComponents = { ...components, ...stubs };\n\n return (\n <>\n <DocsContainer>\n <ActionBar content={content}>\n <Flex $gap={20}>\n <StyledMarkdownContainer>\n {children}\n {content && (\n <MDXRemote\n source={content}\n options={{\n blockJS: false,\n mdxOptions: {\n remarkPlugins: [remarkGfm],\n rehypePlugins: [rehypeCodeMeta],\n },\n }}\n components={allComponents}\n />\n )}\n </StyledMarkdownContainer>\n </Flex>\n </ActionBar>\n </DocsContainer>\n <DocsSideBar headings={headings} />\n </>\n );\n}\n\nexport { Docs };\n";
1
+ export declare const docsTemplate = "import React from \"react\";\nimport { Flex } from \"cherry-styled-components\";\nimport {\n DocsContainer,\n StyledMarkdownContainer,\n StyledMissingComponent,\n} from \"@/components/layout/DocsComponents\";\nimport { MDXRemote } from \"next-mdx-remote/rsc\";\nimport remarkGfm from \"remark-gfm\";\nimport { useMDXComponents } from \"@/components/MDXComponents\";\nimport { createMermaidPre } from \"@/components/MermaidPre\";\nimport { DocsSideBar } from \"@/components/DocsSideBar\";\nimport { ActionBar } from \"@/components/layout/ActionBar\";\nimport { ApiPlaygroundDemo } from \"@/components/layout/ApiPlaygroundDemo\";\nimport { createSlugger } from \"@/components/layout/Slug\";\nimport { rehypeCodeMeta } from \"@/utils/rehypeCodeMeta\";\n\ninterface DocsProps {\n content: string;\n sourcePath?: string;\n // Path of this page's RSS feed; when set, the action bar shows an RSS\n // button linking to it.\n rssHref?: string;\n // Extra content rendered inside the markdown column, after the MDX body.\n // Used to place generated widgets (e.g. the API playground) inside the docs\n // content area rather than outside its layout.\n children?: React.ReactNode;\n}\n\ninterface Heading {\n id: string;\n text: string;\n level: number;\n}\n\nfunction extractHeadings(content: string): Heading[] {\n const contentWithoutCodeBlocks = content.replace(/```[\\s\\S]*?```/g, \"\");\n const entries: { text: string; level: number; position: number }[] = [];\n let match;\n\n // Markdown headings (# .. ######)\n const headingRegex = /^(#{1,6})\\s+(.+)$/gm;\n while ((match = headingRegex.exec(contentWithoutCodeBlocks)) !== null) {\n const level = match[1].length;\n const text = match[2].trim();\n entries.push({ text, level, position: match.index });\n }\n\n // <Update label=\"...\"> blocks surface their label as a top-level entry\n const updateRegex = /<Update\\b[^>]*?\\blabel=[\"']([^\"']+)[\"'][^>]*>/g;\n while ((match = updateRegex.exec(contentWithoutCodeBlocks)) !== null) {\n entries.push({ text: match[1].trim(), level: 1, position: match.index });\n }\n\n // Assign ids in document order with a shared slugger so repeated heading\n // text produces unique anchors (\"setup\", \"setup-1\", ...) that stay in sync\n // with the ids rendered by MDXComponents/Update.\n const slug = createSlugger();\n return entries\n .sort((a, b) => a.position - b.position)\n .map(({ text, level }) => ({ id: slug(text), text, level }));\n}\n\nfunction extractComponentNames(source: string): string[] {\n const stripped = source\n .replace(/```[\\s\\S]*?```/g, \"\")\n .replace(/`[^`]*`/g, \"\");\n const tagRegex = /<([A-Z][a-zA-Z0-9]*)/g;\n const names = new Set<string>();\n let match;\n while ((match = tagRegex.exec(stripped)) !== null) {\n names.add(match[1]);\n }\n return Array.from(names);\n}\n\nfunction MissingComponent({\n componentName,\n children: _children,\n}: {\n componentName: string;\n children?: React.ReactNode;\n}) {\n return (\n <StyledMissingComponent>\n Missing component: &lt;{componentName} /&gt;\n </StyledMissingComponent>\n );\n}\n\nfunction Docs({ content, sourcePath, rssHref, children }: DocsProps) {\n const headings = extractHeadings(content);\n const components = useMDXComponents({\n pre: createMermaidPre(sourcePath),\n ApiPlaygroundDemo,\n });\n\n const knownNames = Object.keys(components);\n const usedNames = extractComponentNames(content);\n const missingNames = usedNames.filter((name) => !knownNames.includes(name));\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const stubs: Record<string, React.ComponentType<any>> = {};\n for (const name of missingNames) {\n stubs[name] = ({ children }: { children?: React.ReactNode }) => (\n <MissingComponent componentName={name}>{children}</MissingComponent>\n );\n }\n\n const allComponents = { ...components, ...stubs };\n\n return (\n <>\n <DocsContainer>\n <ActionBar content={content} rssHref={rssHref}>\n <Flex $gap={20}>\n <StyledMarkdownContainer>\n {children}\n {content && (\n <MDXRemote\n source={content}\n options={{\n blockJS: false,\n mdxOptions: {\n remarkPlugins: [remarkGfm],\n rehypePlugins: [rehypeCodeMeta],\n },\n }}\n components={allComponents}\n />\n )}\n </StyledMarkdownContainer>\n </Flex>\n </ActionBar>\n </DocsContainer>\n <DocsSideBar headings={headings} />\n </>\n );\n}\n\nexport { Docs };\n";
@@ -18,6 +18,9 @@ import { rehypeCodeMeta } from "@/utils/rehypeCodeMeta";
18
18
  interface DocsProps {
19
19
  content: string;
20
20
  sourcePath?: string;
21
+ // Path of this page's RSS feed; when set, the action bar shows an RSS
22
+ // button linking to it.
23
+ rssHref?: string;
21
24
  // Extra content rendered inside the markdown column, after the MDX body.
22
25
  // Used to place generated widgets (e.g. the API playground) inside the docs
23
26
  // content area rather than outside its layout.
@@ -85,7 +88,7 @@ function MissingComponent({
85
88
  );
86
89
  }
87
90
 
88
- function Docs({ content, sourcePath, children }: DocsProps) {
91
+ function Docs({ content, sourcePath, rssHref, children }: DocsProps) {
89
92
  const headings = extractHeadings(content);
90
93
  const components = useMDXComponents({
91
94
  pre: createMermaidPre(sourcePath),
@@ -109,7 +112,7 @@ function Docs({ content, sourcePath, children }: DocsProps) {
109
112
  return (
110
113
  <>
111
114
  <DocsContainer>
112
- <ActionBar content={content}>
115
+ <ActionBar content={content} rssHref={rssHref}>
113
116
  <Flex $gap={20}>
114
117
  <StyledMarkdownContainer>
115
118
  {children}
@@ -1 +1 @@
1
- export declare const mdxComponentsTemplate = "import React from \"react\";\nimport Link from \"next/link\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype MDXComponents = Record<string, React.ComponentType<any>>;\nimport { Space } from \"cherry-styled-components\";\nimport { Code as CodeBlock, CodeTabs } from \"@/components/layout/Code\";\nimport { Card } from \"@/components/layout/Card\";\nimport { Accordion } from \"@/components/layout/Accordion\";\nimport { Tabs, TabContent } from \"@/components/layout/Tabs\";\nimport { Callout } from \"@/components/layout/Callout\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { Columns } from \"@/components/layout/Columns\";\nimport { Field } from \"@/components/layout/Field\";\nimport { Frame } from \"@/components/layout/Frame\";\nimport { Update } from \"@/components/layout/Update\";\nimport { Steps, Step } from \"@/components/layout/Steps\";\nimport { Button } from \"@/components/layout/Button\";\nimport { ColorSwatch, ColorSwatchGroup } from \"@/components/layout/ColorSwatch\";\nimport { DemoTheme } from \"@/components/layout/DemoTheme\";\nimport { createSlugger } from \"@/components/layout/Slug\";\n\ninterface HeadingProps extends React.HTMLAttributes<HTMLHeadingElement> {\n children?: React.ReactNode;\n}\n\ninterface PreProps extends React.HTMLAttributes<HTMLPreElement> {\n children?: React.ReactNode;\n}\n\nexport function extractAllTextFromChildren(children: React.ReactNode): string {\n if (children == null) return \"\";\n if (typeof children === \"string\") return children;\n if (typeof children === \"number\") return String(children);\n if (typeof children === \"boolean\") return \"\";\n if (Array.isArray(children))\n return children.map(extractAllTextFromChildren).join(\"\");\n if (React.isValidElement(children)) {\n const element = children as React.ReactElement<{\n children?: React.ReactNode;\n }>;\n return extractAllTextFromChildren(element.props.children);\n }\n return \"\";\n}\n\n// Map <pre><code class=\"language-xyz\"> to our <Code /> component\nexport function Pre(props: PreProps) {\n const child = React.Children.only(props.children) as React.ReactElement<{\n className?: string;\n children?: React.ReactNode;\n }> | null;\n if (child && child.type === \"code\") {\n const className = child.props.className || \"\";\n const match = /language-(\\w+)/.exec(className);\n const language = match ? match[1] : undefined;\n const code = extractAllTextFromChildren(child.props.children).replace(\n /\\n$/,\n \"\",\n );\n if (language) {\n return (\n <CodeBlock className={className} code={code} language={language} />\n );\n }\n }\n return <pre {...props} />;\n}\n\nexport function useMDXComponents(components: MDXComponents): MDXComponents {\n // One slugger per render so repeated heading text (and <Update> labels)\n // resolve to unique, document-order ids that match the index sidebar built\n // in components/Docs.tsx.\n const slug = createSlugger();\n return {\n // Headings with auto-generated ids for TOC and deep links\n h1: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h1 id={id} {...props}>\n {children}\n </h1>\n );\n },\n h2: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h2 id={id} {...props}>\n {children}\n </h2>\n );\n },\n h3: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h3 id={id} {...props}>\n {children}\n </h3>\n );\n },\n h4: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h4 id={id} {...props}>\n {children}\n </h4>\n );\n },\n h5: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h5 id={id} {...props}>\n {children}\n </h5>\n );\n },\n h6: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h6 id={id} {...props}>\n {children}\n </h6>\n );\n },\n\n // Links - use Next.js Link for internal paths\n a: ({\n href,\n children,\n ...props\n }: React.AnchorHTMLAttributes<HTMLAnchorElement>) => {\n if (href && href.startsWith(\"/\")) {\n return (\n <Link href={href} {...props}>\n {children}\n </Link>\n );\n }\n return (\n <a href={href} target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n );\n },\n\n // Tables - wrap in a div for responsive overflow\n table: (props: React.TableHTMLAttributes<HTMLTableElement>) => (\n <div className=\"table-wrapper\">\n <table {...props} />\n </div>\n ),\n\n // Code blocks\n pre: Pre,\n\n // Expose your custom components for MDX usage\n Code: CodeBlock,\n CodeTabs,\n Card,\n Accordion,\n Tabs,\n TabContent,\n Callout,\n Icon,\n Columns,\n Field,\n Frame,\n // Share the heading slugger so an <Update> label anchor stays unique and\n // in document order alongside the surrounding headings. Only consume a\n // slug when a label is present so a label-less <Update> does not crash the\n // slugger (Update itself renders gracefully without a label anchor).\n Update: (props: React.ComponentProps<typeof Update>) => (\n <Update {...props} id={props.label ? slug(props.label) : undefined} />\n ),\n Steps,\n Step,\n Button,\n ColorSwatch,\n ColorSwatchGroup,\n DemoTheme,\n Space,\n ...components,\n };\n}\n";
1
+ export declare const mdxComponentsTemplate = "import React from \"react\";\nimport Link from \"next/link\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype MDXComponents = Record<string, React.ComponentType<any>>;\nimport { Space } from \"cherry-styled-components\";\nimport { Badge } from \"@/components/layout/Badge\";\nimport { Code as CodeBlock, CodeTabs } from \"@/components/layout/Code\";\nimport { Card } from \"@/components/layout/Card\";\nimport { Accordion } from \"@/components/layout/Accordion\";\nimport { Tabs, TabContent } from \"@/components/layout/Tabs\";\nimport { Callout } from \"@/components/layout/Callout\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { Columns } from \"@/components/layout/Columns\";\nimport { Field } from \"@/components/layout/Field\";\nimport { Frame } from \"@/components/layout/Frame\";\nimport { Prompt } from \"@/components/layout/Prompt\";\nimport { Update } from \"@/components/layout/Update\";\nimport { Steps, Step } from \"@/components/layout/Steps\";\nimport { Button } from \"@/components/layout/Button\";\nimport { ColorSwatch, ColorSwatchGroup } from \"@/components/layout/ColorSwatch\";\nimport { DemoTheme } from \"@/components/layout/DemoTheme\";\nimport { Tooltip } from \"@/components/layout/Tooltip\";\nimport { Tree as TreeRoot } from \"@/components/layout/Tree\";\nimport {\n parseTreeChildren,\n TreeFolder,\n TreeFile,\n} from \"@/components/layout/TreeData\";\nimport { createSlugger } from \"@/components/layout/Slug\";\n\ninterface HeadingProps extends React.HTMLAttributes<HTMLHeadingElement> {\n children?: React.ReactNode;\n}\n\ninterface PreProps extends React.HTMLAttributes<HTMLPreElement> {\n children?: React.ReactNode;\n}\n\n// The Tree compound is assembled here in shared code: statics attached to\n// the client component would not survive the client-reference boundary, and\n// the Tree.Folder / Tree.File elements MDX creates must be parsed in the\n// same runtime that created them, where marker identity is guaranteed. Only\n// the resulting plain TreeNode data crosses to the client component.\nconst Tree = Object.assign(\n function Tree({ children }: { children?: React.ReactNode }) {\n return <TreeRoot nodes={parseTreeChildren(children, \"node\")} />;\n },\n { Folder: TreeFolder, File: TreeFile },\n);\n\n// <Tree> and <FileTree> are aliases; either tag supports either syntax.\nconst FileTree = Tree;\n\nexport function extractAllTextFromChildren(children: React.ReactNode): string {\n if (children == null) return \"\";\n if (typeof children === \"string\") return children;\n if (typeof children === \"number\") return String(children);\n if (typeof children === \"boolean\") return \"\";\n if (Array.isArray(children))\n return children.map(extractAllTextFromChildren).join(\"\");\n if (React.isValidElement(children)) {\n const element = children as React.ReactElement<{\n children?: React.ReactNode;\n }>;\n return extractAllTextFromChildren(element.props.children);\n }\n return \"\";\n}\n\n// Map <pre><code class=\"language-xyz\"> to our <Code /> component\nexport function Pre(props: PreProps) {\n const child = React.Children.only(props.children) as React.ReactElement<{\n className?: string;\n children?: React.ReactNode;\n }> | null;\n if (child && child.type === \"code\") {\n const className = child.props.className || \"\";\n const match = /language-(\\w+)/.exec(className);\n const language = match ? match[1] : undefined;\n const code = extractAllTextFromChildren(child.props.children).replace(\n /\\n$/,\n \"\",\n );\n if (language) {\n return (\n <CodeBlock className={className} code={code} language={language} />\n );\n }\n }\n return <pre {...props} />;\n}\n\nexport function useMDXComponents(components: MDXComponents): MDXComponents {\n // One slugger per render so repeated heading text (and <Update> labels)\n // resolve to unique, document-order ids that match the index sidebar built\n // in components/Docs.tsx.\n const slug = createSlugger();\n return {\n // Headings with auto-generated ids for TOC and deep links\n h1: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h1 id={id} {...props}>\n {children}\n </h1>\n );\n },\n h2: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h2 id={id} {...props}>\n {children}\n </h2>\n );\n },\n h3: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h3 id={id} {...props}>\n {children}\n </h3>\n );\n },\n h4: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h4 id={id} {...props}>\n {children}\n </h4>\n );\n },\n h5: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h5 id={id} {...props}>\n {children}\n </h5>\n );\n },\n h6: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h6 id={id} {...props}>\n {children}\n </h6>\n );\n },\n\n // Links - use Next.js Link for internal paths\n a: ({\n href,\n children,\n ...props\n }: React.AnchorHTMLAttributes<HTMLAnchorElement>) => {\n if (href && href.startsWith(\"/\")) {\n return (\n <Link href={href} {...props}>\n {children}\n </Link>\n );\n }\n return (\n <a href={href} target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n );\n },\n\n // Tables - wrap in a div for responsive overflow\n table: (props: React.TableHTMLAttributes<HTMLTableElement>) => (\n <div className=\"table-wrapper\">\n <table {...props} />\n </div>\n ),\n\n // Code blocks\n pre: Pre,\n\n // Expose your custom components for MDX usage\n Badge,\n Code: CodeBlock,\n CodeTabs,\n Card,\n Accordion,\n Tabs,\n TabContent,\n Callout,\n Icon,\n Columns,\n Field,\n Frame,\n Prompt,\n // Share the heading slugger so an <Update> label anchor stays unique and\n // in document order alongside the surrounding headings. Only consume a\n // slug when a label is present so a label-less <Update> does not crash the\n // slugger (Update itself renders gracefully without a label anchor).\n Update: (props: React.ComponentProps<typeof Update>) => (\n <Update {...props} id={props.label ? slug(props.label) : undefined} />\n ),\n Steps,\n Step,\n Button,\n ColorSwatch,\n ColorSwatchGroup,\n DemoTheme,\n Tooltip,\n Tree,\n FileTree,\n Space,\n ...components,\n };\n}\n";
@@ -4,6 +4,7 @@ import Link from "next/link";
4
4
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
5
  type MDXComponents = Record<string, React.ComponentType<any>>;
6
6
  import { Space } from "cherry-styled-components";
7
+ import { Badge } from "@/components/layout/Badge";
7
8
  import { Code as CodeBlock, CodeTabs } from "@/components/layout/Code";
8
9
  import { Card } from "@/components/layout/Card";
9
10
  import { Accordion } from "@/components/layout/Accordion";
@@ -13,11 +14,19 @@ import { Icon } from "@/components/layout/Icon";
13
14
  import { Columns } from "@/components/layout/Columns";
14
15
  import { Field } from "@/components/layout/Field";
15
16
  import { Frame } from "@/components/layout/Frame";
17
+ import { Prompt } from "@/components/layout/Prompt";
16
18
  import { Update } from "@/components/layout/Update";
17
19
  import { Steps, Step } from "@/components/layout/Steps";
18
20
  import { Button } from "@/components/layout/Button";
19
21
  import { ColorSwatch, ColorSwatchGroup } from "@/components/layout/ColorSwatch";
20
22
  import { DemoTheme } from "@/components/layout/DemoTheme";
23
+ import { Tooltip } from "@/components/layout/Tooltip";
24
+ import { Tree as TreeRoot } from "@/components/layout/Tree";
25
+ import {
26
+ parseTreeChildren,
27
+ TreeFolder,
28
+ TreeFile,
29
+ } from "@/components/layout/TreeData";
21
30
  import { createSlugger } from "@/components/layout/Slug";
22
31
 
23
32
  interface HeadingProps extends React.HTMLAttributes<HTMLHeadingElement> {
@@ -28,6 +37,21 @@ interface PreProps extends React.HTMLAttributes<HTMLPreElement> {
28
37
  children?: React.ReactNode;
29
38
  }
30
39
 
40
+ // The Tree compound is assembled here in shared code: statics attached to
41
+ // the client component would not survive the client-reference boundary, and
42
+ // the Tree.Folder / Tree.File elements MDX creates must be parsed in the
43
+ // same runtime that created them, where marker identity is guaranteed. Only
44
+ // the resulting plain TreeNode data crosses to the client component.
45
+ const Tree = Object.assign(
46
+ function Tree({ children }: { children?: React.ReactNode }) {
47
+ return <TreeRoot nodes={parseTreeChildren(children, "node")} />;
48
+ },
49
+ { Folder: TreeFolder, File: TreeFile },
50
+ );
51
+
52
+ // <Tree> and <FileTree> are aliases; either tag supports either syntax.
53
+ const FileTree = Tree;
54
+
31
55
  export function extractAllTextFromChildren(children: React.ReactNode): string {
32
56
  if (children == null) return "";
33
57
  if (typeof children === "string") return children;
@@ -154,6 +178,7 @@ export function useMDXComponents(components: MDXComponents): MDXComponents {
154
178
  pre: Pre,
155
179
 
156
180
  // Expose your custom components for MDX usage
181
+ Badge,
157
182
  Code: CodeBlock,
158
183
  CodeTabs,
159
184
  Card,
@@ -165,6 +190,7 @@ export function useMDXComponents(components: MDXComponents): MDXComponents {
165
190
  Columns,
166
191
  Field,
167
192
  Frame,
193
+ Prompt,
168
194
  // Share the heading slugger so an <Update> label anchor stays unique and
169
195
  // in document order alongside the surrounding headings. Only consume a
170
196
  // slug when a label is present so a label-less <Update> does not crash the
@@ -178,6 +204,9 @@ export function useMDXComponents(components: MDXComponents): MDXComponents {
178
204
  ColorSwatch,
179
205
  ColorSwatchGroup,
180
206
  DemoTheme,
207
+ Tooltip,
208
+ Tree,
209
+ FileTree,
181
210
  Space,
182
211
  ...components,
183
212
  };
@@ -1 +1 @@
1
- export declare const sideBarTemplate = "\"use client\";\nimport { useContext, useEffect, useRef, useState } from \"react\";\nimport { usePathname } from \"next/navigation\";\nimport { Flex, Space, ThemeToggle } from \"cherry-styled-components\";\nimport {\n DocsSidebar,\n SectionBarContext,\n StyledSidebar,\n StyledSidebarList,\n StyledSidebarListItem,\n StyledStrong,\n StyledSidebarListItemLink,\n StyledSidebarMethodTag,\n StyledSidebarGroupButton,\n StyledSidebarGroupRow,\n StyledSidebarGroupLink,\n StyledSidebarGroupChevron,\n StyledSidebarGroupContent,\n StyledSidebarFooter,\n StyleMobileBar,\n StyledMobileBurger,\n} from \"@/components/layout/DocsComponents\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { useLockBodyScroll } from \"@/components/LockBodyScroll\";\n\n// A link can be a leaf (slug + title) or a group with nested children. Both the\n// category icon and the per-link icon are optional Lucide names.\ntype NavItemLink = {\n slug?: string;\n title: string;\n icon?: string;\n httpMethod?: string;\n links?: NavItemLink[];\n};\n\ntype NavItem = {\n label: string;\n icon?: string;\n links: NavItemLink[];\n};\n\ninterface SideBarProps {\n result: NavItem[];\n}\n\nfunction linkContainsActivePath(link: NavItemLink, pathname: string): boolean {\n if (link.slug !== undefined && pathname === `/${link.slug}`) {\n return true;\n }\n return (link.links ?? []).some((child) =>\n linkContainsActivePath(child, pathname),\n );\n}\n\nfunction SidebarNavLink({\n link,\n depth,\n pathname,\n onNavigate,\n}: {\n link: NavItemLink;\n depth: number;\n pathname: string;\n onNavigate: () => void;\n}) {\n const children = link.links ?? [];\n const hasChildren = children.length > 0;\n const href = link.slug !== undefined ? `/${link.slug}` : undefined;\n const isActive = href !== undefined && pathname === href;\n const indent = { paddingLeft: `${20 + depth * 14}px` };\n\n // Open collapsible groups that contain the active page so deep links land\n // with their ancestors already expanded.\n const [isOpen, setIsOpen] = useState(\n hasChildren\n ? children.some((child) => linkContainsActivePath(child, pathname))\n : false,\n );\n\n if (!hasChildren) {\n return (\n <StyledSidebarListItem>\n <StyledSidebarListItemLink\n href={href ?? \"#\"}\n $isActive={isActive}\n aria-current={isActive ? \"page\" : undefined}\n onClick={onNavigate}\n style={indent}\n >\n {link.httpMethod && (\n <StyledSidebarMethodTag\n $method={link.httpMethod}\n $isActive={isActive}\n >\n {link.httpMethod}\n </StyledSidebarMethodTag>\n )}\n {link.icon && <Icon name={link.icon} size={16} />}\n {link.title}\n </StyledSidebarListItemLink>\n </StyledSidebarListItem>\n );\n }\n\n const toggle = () => setIsOpen((prev) => !prev);\n const toggleLabel = isOpen\n ? `Collapse ${link.title}`\n : `Expand ${link.title}`;\n const groupActive = linkContainsActivePath(link, pathname);\n\n return (\n <li>\n {href !== undefined ? (\n <StyledSidebarGroupRow\n $isActive={groupActive}\n $isOpen={isOpen}\n style={indent}\n >\n <StyledSidebarGroupLink\n href={href}\n aria-current={pathname === href ? \"page\" : undefined}\n onClick={onNavigate}\n >\n {link.icon && <Icon name={link.icon} size={16} />}\n {link.title}\n </StyledSidebarGroupLink>\n <StyledSidebarGroupChevron\n type=\"button\"\n onClick={toggle}\n aria-expanded={isOpen}\n aria-label={toggleLabel}\n >\n <Icon name=\"chevron-right\" size={16} />\n </StyledSidebarGroupChevron>\n </StyledSidebarGroupRow>\n ) : (\n <StyledSidebarGroupButton\n type=\"button\"\n onClick={toggle}\n $isActive={groupActive}\n $isOpen={isOpen}\n style={indent}\n aria-expanded={isOpen}\n aria-label={toggleLabel}\n >\n {link.icon && <Icon name={link.icon} size={16} />}\n {link.title}\n <Icon name=\"chevron-right\" size={16} />\n </StyledSidebarGroupButton>\n )}\n <StyledSidebarGroupContent $isOpen={isOpen}>\n {children.map((child: NavItemLink, index: number) => (\n <SidebarNavLink\n key={index}\n link={child}\n depth={depth + 1}\n pathname={pathname}\n onNavigate={onNavigate}\n />\n ))}\n </StyledSidebarGroupContent>\n </li>\n );\n}\n\nfunction SideBar({ result }: SideBarProps) {\n const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);\n const hasSectionBar = useContext(SectionBarContext);\n const pathname = usePathname();\n const navRef = useRef<HTMLElement>(null);\n const footerRef = useRef<HTMLDivElement>(null);\n\n useLockBodyScroll(isMobileMenuOpen);\n\n // Bring the current page's link into view within the sidebar's own scroll\n // area when it starts off-screen (deep pages, in-content links, search).\n // Scoped to the nav via scrollTo so the main document never jumps.\n useEffect(() => {\n const nav = navRef.current;\n if (!nav) return;\n const active = nav.querySelector<HTMLElement>('[aria-current=\"page\"]');\n if (!active) return;\n\n const navRect = nav.getBoundingClientRect();\n const activeRect = active.getBoundingClientRect();\n\n // The theme-toggle footer is sticky over the bottom of the scroll area\n // (~60px tall), so links underneath it are covered rather than visible.\n // Clamp the visible bottom to the footer's top edge when it's pinned.\n const footerRect = footerRef.current?.getBoundingClientRect();\n const visibleBottom = footerRect\n ? Math.min(navRect.bottom, footerRect.top)\n : navRect.bottom;\n\n const isOutOfView =\n activeRect.top < navRect.top || activeRect.bottom > visibleBottom;\n if (!isOutOfView) return;\n\n // Center within the visible band (nav top .. footer top), not the full\n // nav height, so the link never settles behind the footer.\n const visibleHeight = visibleBottom - navRect.top;\n const target =\n nav.scrollTop +\n (activeRect.top - navRect.top) -\n (visibleHeight - active.clientHeight) / 2;\n\n // Animate the scroll, but honor users who opt out of motion.\n const prefersReducedMotion = window.matchMedia(\n \"(prefers-reduced-motion: reduce)\",\n ).matches;\n nav.scrollTo({\n top: Math.max(0, target),\n behavior: prefersReducedMotion ? \"auto\" : \"smooth\",\n });\n }, [pathname]);\n\n return (\n <DocsSidebar>\n <StyleMobileBar\n onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}\n $isActive={isMobileMenuOpen}\n aria-label={\n isMobileMenuOpen ? \"Close navigation menu\" : \"Open navigation menu\"\n }\n aria-expanded={isMobileMenuOpen}\n >\n <StyledMobileBurger $isActive={isMobileMenuOpen} />\n </StyleMobileBar>\n\n <StyledSidebar\n ref={navRef}\n $isActive={isMobileMenuOpen}\n $hasSectionBar={hasSectionBar}\n >\n {result &&\n result.map((item: NavItem, index: number) => {\n return (\n <StyledSidebarList key={index}>\n <StyledSidebarListItem>\n <StyledStrong>\n {item.icon && <Icon name={item.icon} size={16} />}\n {item.label}\n </StyledStrong>{\" \"}\n </StyledSidebarListItem>\n <li>\n <Space $size={20} />\n </li>\n {item.links &&\n item.links.map((link: NavItemLink, indexChild: number) => (\n <SidebarNavLink\n key={indexChild}\n link={link}\n depth={0}\n pathname={pathname}\n onNavigate={() => setIsMobileMenuOpen(false)}\n />\n ))}\n <li aria-hidden=\"true\">\n <Space $size={20} />\n </li>\n </StyledSidebarList>\n );\n })}\n <StyledSidebarFooter ref={footerRef}>\n <Flex $xsJustifyContent=\"flex-start\" $lgJustifyContent=\"flex-end\">\n <ThemeToggle $shortcut />\n </Flex>\n </StyledSidebarFooter>\n </StyledSidebar>\n </DocsSidebar>\n );\n}\n\nexport { SideBar };\n";
1
+ export declare const sideBarTemplate = "\"use client\";\nimport { useContext, useEffect, useRef, useState } from \"react\";\nimport { usePathname } from \"next/navigation\";\nimport { Flex, Space, ThemeToggle } from \"cherry-styled-components\";\nimport { httpMethodBadgeColor } from \"@/components/layout/Badge\";\nimport {\n DocsSidebar,\n SectionBarContext,\n StyledSidebar,\n StyledSidebarList,\n StyledSidebarListItem,\n StyledStrong,\n StyledSidebarListItemLink,\n StyledSidebarMethodTag,\n StyledSidebarGroupButton,\n StyledSidebarGroupRow,\n StyledSidebarGroupLink,\n StyledSidebarGroupChevron,\n StyledSidebarGroupContent,\n StyledSidebarFooter,\n StyleMobileBar,\n StyledMobileBurger,\n} from \"@/components/layout/DocsComponents\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { useLockBodyScroll } from \"@/components/LockBodyScroll\";\n\n// A link can be a leaf (slug + title) or a group with nested children. Both the\n// category icon and the per-link icon are optional Lucide names.\ntype NavItemLink = {\n slug?: string;\n title: string;\n icon?: string;\n httpMethod?: string;\n links?: NavItemLink[];\n};\n\ntype NavItem = {\n label: string;\n icon?: string;\n links: NavItemLink[];\n};\n\ninterface SideBarProps {\n result: NavItem[];\n}\n\nfunction linkContainsActivePath(link: NavItemLink, pathname: string): boolean {\n if (link.slug !== undefined && pathname === `/${link.slug}`) {\n return true;\n }\n return (link.links ?? []).some((child) =>\n linkContainsActivePath(child, pathname),\n );\n}\n\nfunction SidebarNavLink({\n link,\n depth,\n pathname,\n onNavigate,\n}: {\n link: NavItemLink;\n depth: number;\n pathname: string;\n onNavigate: () => void;\n}) {\n const children = link.links ?? [];\n const hasChildren = children.length > 0;\n const href = link.slug !== undefined ? `/${link.slug}` : undefined;\n const isActive = href !== undefined && pathname === href;\n const indent = { paddingLeft: `${20 + depth * 14}px` };\n\n // Open collapsible groups that contain the active page so deep links land\n // with their ancestors already expanded.\n const [isOpen, setIsOpen] = useState(\n hasChildren\n ? children.some((child) => linkContainsActivePath(child, pathname))\n : false,\n );\n\n if (!hasChildren) {\n return (\n <StyledSidebarListItem>\n <StyledSidebarListItemLink\n href={href ?? \"#\"}\n $isActive={isActive}\n aria-current={isActive ? \"page\" : undefined}\n onClick={onNavigate}\n style={indent}\n >\n {link.httpMethod && (\n <StyledSidebarMethodTag\n mono\n solid={isActive}\n size=\"xs\"\n color={httpMethodBadgeColor(link.httpMethod)}\n >\n {link.httpMethod}\n </StyledSidebarMethodTag>\n )}\n {link.icon && <Icon name={link.icon} size={16} />}\n {link.title}\n </StyledSidebarListItemLink>\n </StyledSidebarListItem>\n );\n }\n\n const toggle = () => setIsOpen((prev) => !prev);\n const toggleLabel = isOpen\n ? `Collapse ${link.title}`\n : `Expand ${link.title}`;\n const groupActive = linkContainsActivePath(link, pathname);\n\n return (\n <li>\n {href !== undefined ? (\n <StyledSidebarGroupRow\n $isActive={groupActive}\n $isOpen={isOpen}\n style={indent}\n >\n <StyledSidebarGroupLink\n href={href}\n aria-current={pathname === href ? \"page\" : undefined}\n onClick={onNavigate}\n >\n {link.icon && <Icon name={link.icon} size={16} />}\n {link.title}\n </StyledSidebarGroupLink>\n <StyledSidebarGroupChevron\n type=\"button\"\n onClick={toggle}\n aria-expanded={isOpen}\n aria-label={toggleLabel}\n >\n <Icon name=\"chevron-right\" size={16} />\n </StyledSidebarGroupChevron>\n </StyledSidebarGroupRow>\n ) : (\n <StyledSidebarGroupButton\n type=\"button\"\n onClick={toggle}\n $isActive={groupActive}\n $isOpen={isOpen}\n style={indent}\n aria-expanded={isOpen}\n aria-label={toggleLabel}\n >\n {link.icon && <Icon name={link.icon} size={16} />}\n {link.title}\n <Icon name=\"chevron-right\" size={16} />\n </StyledSidebarGroupButton>\n )}\n <StyledSidebarGroupContent $isOpen={isOpen}>\n {children.map((child: NavItemLink, index: number) => (\n <SidebarNavLink\n key={index}\n link={child}\n depth={depth + 1}\n pathname={pathname}\n onNavigate={onNavigate}\n />\n ))}\n </StyledSidebarGroupContent>\n </li>\n );\n}\n\nfunction SideBar({ result }: SideBarProps) {\n const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);\n const hasSectionBar = useContext(SectionBarContext);\n const pathname = usePathname();\n const navRef = useRef<HTMLElement>(null);\n const footerRef = useRef<HTMLDivElement>(null);\n\n useLockBodyScroll(isMobileMenuOpen);\n\n // Bring the current page's link into view within the sidebar's own scroll\n // area when it starts off-screen (deep pages, in-content links, search).\n // Scoped to the nav via scrollTo so the main document never jumps.\n useEffect(() => {\n const nav = navRef.current;\n if (!nav) return;\n const active = nav.querySelector<HTMLElement>('[aria-current=\"page\"]');\n if (!active) return;\n\n const navRect = nav.getBoundingClientRect();\n const activeRect = active.getBoundingClientRect();\n\n // The theme-toggle footer is sticky over the bottom of the scroll area\n // (~60px tall), so links underneath it are covered rather than visible.\n // Clamp the visible bottom to the footer's top edge when it's pinned.\n const footerRect = footerRef.current?.getBoundingClientRect();\n const visibleBottom = footerRect\n ? Math.min(navRect.bottom, footerRect.top)\n : navRect.bottom;\n\n const isOutOfView =\n activeRect.top < navRect.top || activeRect.bottom > visibleBottom;\n if (!isOutOfView) return;\n\n // Center within the visible band (nav top .. footer top), not the full\n // nav height, so the link never settles behind the footer.\n const visibleHeight = visibleBottom - navRect.top;\n const target =\n nav.scrollTop +\n (activeRect.top - navRect.top) -\n (visibleHeight - active.clientHeight) / 2;\n\n // Animate the scroll, but honor users who opt out of motion.\n const prefersReducedMotion = window.matchMedia(\n \"(prefers-reduced-motion: reduce)\",\n ).matches;\n nav.scrollTo({\n top: Math.max(0, target),\n behavior: prefersReducedMotion ? \"auto\" : \"smooth\",\n });\n }, [pathname]);\n\n return (\n <DocsSidebar>\n <StyleMobileBar\n onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}\n $isActive={isMobileMenuOpen}\n aria-label={\n isMobileMenuOpen ? \"Close navigation menu\" : \"Open navigation menu\"\n }\n aria-expanded={isMobileMenuOpen}\n >\n <StyledMobileBurger $isActive={isMobileMenuOpen} />\n </StyleMobileBar>\n\n <StyledSidebar\n ref={navRef}\n $isActive={isMobileMenuOpen}\n $hasSectionBar={hasSectionBar}\n >\n {result &&\n result.map((item: NavItem, index: number) => {\n return (\n <StyledSidebarList key={index}>\n <StyledSidebarListItem>\n <StyledStrong>\n {item.icon && <Icon name={item.icon} size={16} />}\n {item.label}\n </StyledStrong>{\" \"}\n </StyledSidebarListItem>\n <li>\n <Space $size={20} />\n </li>\n {item.links &&\n item.links.map((link: NavItemLink, indexChild: number) => (\n <SidebarNavLink\n key={indexChild}\n link={link}\n depth={0}\n pathname={pathname}\n onNavigate={() => setIsMobileMenuOpen(false)}\n />\n ))}\n <li aria-hidden=\"true\">\n <Space $size={20} />\n </li>\n </StyledSidebarList>\n );\n })}\n <StyledSidebarFooter ref={footerRef}>\n <Flex $xsJustifyContent=\"flex-start\" $lgJustifyContent=\"flex-end\">\n <ThemeToggle $shortcut />\n </Flex>\n </StyledSidebarFooter>\n </StyledSidebar>\n </DocsSidebar>\n );\n}\n\nexport { SideBar };\n";
@@ -2,6 +2,7 @@ export const sideBarTemplate = `"use client";
2
2
  import { useContext, useEffect, useRef, useState } from "react";
3
3
  import { usePathname } from "next/navigation";
4
4
  import { Flex, Space, ThemeToggle } from "cherry-styled-components";
5
+ import { httpMethodBadgeColor } from "@/components/layout/Badge";
5
6
  import {
6
7
  DocsSidebar,
7
8
  SectionBarContext,
@@ -89,8 +90,10 @@ function SidebarNavLink({
89
90
  >
90
91
  {link.httpMethod && (
91
92
  <StyledSidebarMethodTag
92
- $method={link.httpMethod}
93
- $isActive={isActive}
93
+ mono
94
+ solid={isActive}
95
+ size="xs"
96
+ color={httpMethodBadgeColor(link.httpMethod)}
94
97
  >
95
98
  {link.httpMethod}
96
99
  </StyledSidebarMethodTag>
@@ -1 +1 @@
1
- export declare const actionBarTemplate = "\"use client\";\nimport { useContext, useState } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { mq, Theme } from \"@/app/theme\";\nimport {\n interactiveStyles,\n resetButton,\n Textarea,\n} from \"cherry-styled-components\";\nimport { SectionBarContext } from \"@/components/layout/DocsComponents\";\nimport { StyledSmallButton } from \"@/components/layout/SharedStyled\";\n\ninterface ActionBarProps {\n children: React.ReactNode;\n content: string;\n}\n\nconst StyledActionBar = styled.div<{\n theme: Theme;\n $isChatOpen?: boolean;\n}>`\n border-bottom: solid 1px ${({ theme }) => theme.colors.grayLight};\n left: 0;\n padding: 12px 0;\n display: flex;\n justify-content: space-between;\n width: 100%;\n max-width: 640px;\n margin: auto;\n transition: all 0.3s ease;\n\n ${mq(\"lg\")} {\n padding: 12px 0;\n }\n`;\n\nconst StyledActionBarContent = styled.div`\n margin: auto 0;\n`;\n\nconst StyledCopyButton = styled(StyledSmallButton)<{\n theme: Theme;\n $copied: boolean;\n}>`\n border: solid 1px\n ${({ theme, $copied }) =>\n $copied ? theme.colors.success : theme.colors.grayLight};\n color: ${({ theme, $copied }) =>\n $copied ? theme.colors.success : theme.colors.primary};\n\n & svg.lucide {\n color: ${({ theme, $copied }) =>\n $copied ? theme.colors.success : theme.colors.primary};\n }\n`;\n\n// Mirrors the geometry and interaction of Cherry's ThemeToggle so the two\n// pills look identical side by side: interactiveStyles supplies the border\n// highlight + focus/active rings (no scale effect), and the space-between\n// layout with 6px padding puts each 16px icon's center exactly where the\n// 24px knob's center sits in its resting (left: 2px) and active\n// (translateX(26px)) positions.\nconst StyledToggle = styled.button<{ theme: Theme; $isActive?: boolean }>`\n ${resetButton}\n ${interactiveStyles}\n width: 56px;\n height: 30px;\n border-radius: 30px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0 6px;\n position: relative;\n margin: auto 0;\n background: ${({ theme }) => theme.colors.light};\n border-color: ${({ theme }) => theme.colors.grayLight};\n\n &::after {\n content: \"\";\n position: absolute;\n top: 2px;\n left: 2px;\n width: 24px;\n height: 24px;\n border-radius: 50%;\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 20%, transparent)`};\n transition: all 0.3s ease;\n z-index: 1;\n ${({ $isActive }) =>\n !$isActive &&\n css`\n transform: translateX(26px);\n `}\n }\n\n & svg {\n width: 16px;\n height: 16px;\n object-fit: contain;\n transition: all 0.3s ease;\n position: relative;\n z-index: 2;\n }\n\n & svg[stroke] {\n stroke: ${({ theme }) => theme.colors.primary};\n }\n\n &:hover svg[stroke] {\n stroke: ${({ theme }) => theme.colors.accent};\n }\n`;\n\n// The raw-content view renders a full-viewport textarea. That rule is scoped to\n// the raw view (`$raw`) so it never leaks into textareas rendered inside page\n// content - e.g. the API playground's request-body editor, which sits inside\n// this same ActionBar in the normal (view) mode.\nconst StyledContent = styled.div<{\n theme: Theme;\n $hasSectionBar?: boolean;\n $raw?: boolean;\n}>`\n padding-top: 20px;\n transition: all 0.3s ease;\n\n ${({ $raw, $hasSectionBar }) =>\n $raw &&\n css`\n & textarea {\n max-width: 640px;\n margin: auto;\n width: 100%;\n height: 100%;\n min-height: calc(100vh - ${$hasSectionBar ? 202 : 160}px);\n\n ${mq(\"lg\")} {\n min-height: calc(100vh - 159px);\n }\n }\n `}\n`;\n\nfunction ActionBar({ children, content }: ActionBarProps) {\n const [isView, setIsView] = useState(true);\n const [copied, setCopied] = useState(false);\n const hasSectionBar = useContext(SectionBarContext);\n\n const handleCopyContent = async () => {\n try {\n await navigator.clipboard.writeText(content);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (err) {\n console.error(\"Failed to copy:\", err);\n }\n };\n\n return (\n <>\n <StyledActionBar>\n <StyledCopyButton onClick={handleCopyContent} $copied={copied}>\n {copied ? (\n <>\n <Icon name=\"check\" size={16} />\n Copied!\n </>\n ) : (\n <>\n <Icon name=\"copy\" size={16} />\n Copy content\n </>\n )}\n </StyledCopyButton>\n <StyledActionBarContent>\n <StyledToggle\n onClick={() => setIsView(!isView)}\n aria-label=\"Toggle View\"\n $isActive={isView}\n >\n <Icon name=\"Eye\" />\n <Icon name=\"CodeXml\" />\n </StyledToggle>\n </StyledActionBarContent>\n </StyledActionBar>\n {isView && (\n <StyledContent $hasSectionBar={hasSectionBar}>{children}</StyledContent>\n )}\n {!isView && (\n <StyledContent $hasSectionBar={hasSectionBar} $raw>\n <Textarea defaultValue={content} $fullWidth />\n </StyledContent>\n )}\n </>\n );\n}\n\nexport { ActionBar };\n";
1
+ export declare const actionBarTemplate = "\"use client\";\nimport { useContext, useState } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { mq, Theme } from \"@/app/theme\";\nimport {\n interactiveStyles,\n resetButton,\n Textarea,\n} from \"cherry-styled-components\";\nimport { SectionBarContext } from \"@/components/layout/DocsComponents\";\nimport { StyledSmallButton } from \"@/components/layout/SharedStyled\";\n\ninterface ActionBarProps {\n children: React.ReactNode;\n content: string;\n // When set, an RSS button linking to this page's feed renders next to the\n // copy pill.\n rssHref?: string;\n}\n\nconst StyledActionBar = styled.div<{\n theme: Theme;\n $isChatOpen?: boolean;\n}>`\n border-bottom: solid 1px ${({ theme }) => theme.colors.grayLight};\n left: 0;\n padding: 12px 0;\n display: flex;\n justify-content: space-between;\n width: 100%;\n max-width: 640px;\n margin: auto;\n transition: all 0.3s ease;\n\n ${mq(\"lg\")} {\n padding: 12px 0;\n }\n`;\n\nconst StyledActionBarContent = styled.div`\n margin: auto 0;\n`;\n\nconst StyledCopyButton = styled(StyledSmallButton)<{\n theme: Theme;\n $copied: boolean;\n}>`\n border: solid 1px\n ${({ theme, $copied }) =>\n $copied ? theme.colors.success : theme.colors.grayLight};\n color: ${({ theme, $copied }) =>\n $copied ? theme.colors.success : theme.colors.primary};\n\n & svg.lucide {\n color: ${({ theme, $copied }) =>\n $copied ? theme.colors.success : theme.colors.primary};\n }\n`;\n\n// StyledSmallButton carries a -6px right margin for edge alignment; inside\n// the pill group that would eat into the gap, so it is neutralized here.\nconst StyledActionBarGroup = styled.div`\n display: flex;\n gap: 12px;\n\n & > * {\n margin-right: 0;\n }\n`;\n\nconst StyledRssLink = styled(StyledSmallButton)<{ theme: Theme }>`\n text-decoration: none;\n color: ${({ theme }) => theme.colors.primary};\n\n & svg.lucide {\n color: ${({ theme }) => theme.colors.primary};\n }\n`;\n\n// Mirrors the geometry and interaction of Cherry's ThemeToggle so the two\n// pills look identical side by side: interactiveStyles supplies the border\n// highlight + focus/active rings (no scale effect), and the space-between\n// layout with 6px padding puts each 16px icon's center exactly where the\n// 24px knob's center sits in its resting (left: 2px) and active\n// (translateX(26px)) positions.\nconst StyledToggle = styled.button<{ theme: Theme; $isActive?: boolean }>`\n ${resetButton}\n ${interactiveStyles}\n width: 56px;\n height: 30px;\n border-radius: 30px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0 6px;\n position: relative;\n margin: auto 0;\n background: ${({ theme }) => theme.colors.light};\n border-color: ${({ theme }) => theme.colors.grayLight};\n\n &::after {\n content: \"\";\n position: absolute;\n top: 2px;\n left: 2px;\n width: 24px;\n height: 24px;\n border-radius: 50%;\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 20%, transparent)`};\n transition: all 0.3s ease;\n z-index: 1;\n ${({ $isActive }) =>\n !$isActive &&\n css`\n transform: translateX(26px);\n `}\n }\n\n & svg {\n width: 16px;\n height: 16px;\n object-fit: contain;\n transition: all 0.3s ease;\n position: relative;\n z-index: 2;\n }\n\n & svg[stroke] {\n stroke: ${({ theme }) => theme.colors.primary};\n }\n\n &:hover svg[stroke] {\n stroke: ${({ theme }) => theme.colors.accent};\n }\n`;\n\n// The raw-content view renders a full-viewport textarea. That rule is scoped to\n// the raw view (`$raw`) so it never leaks into textareas rendered inside page\n// content - e.g. the API playground's request-body editor, which sits inside\n// this same ActionBar in the normal (view) mode.\nconst StyledContent = styled.div<{\n theme: Theme;\n $hasSectionBar?: boolean;\n $raw?: boolean;\n}>`\n padding-top: 20px;\n transition: all 0.3s ease;\n\n ${({ $raw, $hasSectionBar }) =>\n $raw &&\n css`\n & textarea {\n max-width: 640px;\n margin: auto;\n width: 100%;\n height: 100%;\n min-height: calc(100vh - ${$hasSectionBar ? 202 : 160}px);\n\n ${mq(\"lg\")} {\n min-height: calc(100vh - 159px);\n }\n }\n `}\n`;\n\nfunction ActionBar({ children, content, rssHref }: ActionBarProps) {\n const [isView, setIsView] = useState(true);\n const [copied, setCopied] = useState(false);\n const hasSectionBar = useContext(SectionBarContext);\n\n const handleCopyContent = async () => {\n try {\n await navigator.clipboard.writeText(content);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (err) {\n console.error(\"Failed to copy:\", err);\n }\n };\n\n return (\n <>\n <StyledActionBar>\n <StyledActionBarGroup>\n <StyledCopyButton onClick={handleCopyContent} $copied={copied}>\n {copied ? (\n <>\n <Icon name=\"check\" size={16} />\n Copied!\n </>\n ) : (\n <>\n <Icon name=\"copy\" size={16} />\n Copy content\n </>\n )}\n </StyledCopyButton>\n {rssHref && (\n <StyledRssLink as=\"a\" href={rssHref} aria-label=\"RSS feed\">\n <Icon name=\"rss\" size={16} />\n RSS\n </StyledRssLink>\n )}\n </StyledActionBarGroup>\n <StyledActionBarContent>\n <StyledToggle\n onClick={() => setIsView(!isView)}\n aria-label=\"Toggle View\"\n $isActive={isView}\n >\n <Icon name=\"Eye\" />\n <Icon name=\"CodeXml\" />\n </StyledToggle>\n </StyledActionBarContent>\n </StyledActionBar>\n {isView && (\n <StyledContent $hasSectionBar={hasSectionBar}>{children}</StyledContent>\n )}\n {!isView && (\n <StyledContent $hasSectionBar={hasSectionBar} $raw>\n <Textarea defaultValue={content} $fullWidth />\n </StyledContent>\n )}\n </>\n );\n}\n\nexport { ActionBar };\n";