doccupine 0.0.133 → 0.0.134

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 (143) hide show
  1. package/README.md +40 -1
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +274 -19
  4. package/dist/lib/config-manager.d.ts +8 -1
  5. package/dist/lib/config-manager.js +98 -4
  6. package/dist/lib/openapi-types.d.ts +120 -0
  7. package/dist/lib/openapi-types.js +14 -0
  8. package/dist/lib/openapi.d.ts +52 -0
  9. package/dist/lib/openapi.js +603 -0
  10. package/dist/lib/structures.js +28 -2
  11. package/dist/lib/types.d.ts +22 -0
  12. package/dist/lib/utils.d.ts +8 -0
  13. package/dist/lib/utils.js +14 -0
  14. package/dist/templates/app/api/playground/route.d.ts +1 -0
  15. package/dist/templates/app/api/playground/route.js +199 -0
  16. package/dist/templates/components/Docs.d.ts +1 -1
  17. package/dist/templates/components/Docs.js +11 -2
  18. package/dist/templates/components/SideBar.d.ts +1 -1
  19. package/dist/templates/components/SideBar.js +10 -0
  20. package/dist/templates/components/layout/Accordion.d.ts +1 -1
  21. package/dist/templates/components/layout/Accordion.js +3 -2
  22. package/dist/templates/components/layout/ActionBar.d.ts +1 -1
  23. package/dist/templates/components/layout/ActionBar.js +21 -14
  24. package/dist/templates/components/layout/ApiPlayground.d.ts +1 -0
  25. package/dist/templates/components/layout/ApiPlayground.js +1083 -0
  26. package/dist/templates/components/layout/ApiPlaygroundDemo.d.ts +1 -0
  27. package/dist/templates/components/layout/ApiPlaygroundDemo.js +81 -0
  28. package/dist/templates/components/layout/Code.d.ts +1 -1
  29. package/dist/templates/components/layout/Code.js +10 -22
  30. package/dist/templates/components/layout/CopyButton.d.ts +1 -0
  31. package/dist/templates/components/layout/CopyButton.js +68 -0
  32. package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
  33. package/dist/templates/components/layout/DocsComponents.js +39 -0
  34. package/dist/templates/components/layout/Mermaid.d.ts +1 -1
  35. package/dist/templates/components/layout/Mermaid.js +21 -3
  36. package/dist/templates/components/layout/SharedStyles.d.ts +1 -1
  37. package/dist/templates/components/layout/SharedStyles.js +0 -4
  38. package/dist/templates/components/layout/Steps.d.ts +1 -1
  39. package/dist/templates/components/layout/Steps.js +0 -1
  40. package/dist/templates/components/layout/Update.d.ts +1 -1
  41. package/dist/templates/components/layout/Update.js +2 -1
  42. package/dist/templates/mdx/accordion.mdx.d.ts +1 -1
  43. package/dist/templates/mdx/accordion.mdx.js +19 -1
  44. package/dist/templates/mdx/ai-assistant.mdx.d.ts +1 -1
  45. package/dist/templates/mdx/ai-assistant.mdx.js +3 -2
  46. package/dist/templates/mdx/analytics.mdx.d.ts +1 -1
  47. package/dist/templates/mdx/analytics.mdx.js +2 -2
  48. package/dist/templates/mdx/api-playground.mdx.d.ts +1 -0
  49. package/dist/templates/mdx/api-playground.mdx.js +158 -0
  50. package/dist/templates/mdx/authentication.mdx.d.ts +1 -1
  51. package/dist/templates/mdx/authentication.mdx.js +3 -3
  52. package/dist/templates/mdx/buttons.mdx.d.ts +1 -1
  53. package/dist/templates/mdx/buttons.mdx.js +1 -1
  54. package/dist/templates/mdx/callouts.mdx.d.ts +1 -1
  55. package/dist/templates/mdx/callouts.mdx.js +1 -1
  56. package/dist/templates/mdx/cards.mdx.d.ts +1 -1
  57. package/dist/templates/mdx/cards.mdx.js +1 -1
  58. package/dist/templates/mdx/color-swatches.mdx.d.ts +1 -1
  59. package/dist/templates/mdx/color-swatches.mdx.js +1 -1
  60. package/dist/templates/mdx/commands.mdx.d.ts +1 -1
  61. package/dist/templates/mdx/commands.mdx.js +3 -2
  62. package/dist/templates/mdx/components.mdx.d.ts +1 -1
  63. package/dist/templates/mdx/components.mdx.js +12 -9
  64. package/dist/templates/mdx/deployment-and-hosting.mdx.d.ts +1 -1
  65. package/dist/templates/mdx/deployment-and-hosting.mdx.js +4 -3
  66. package/dist/templates/mdx/fields.mdx.d.ts +1 -1
  67. package/dist/templates/mdx/fields.mdx.js +1 -1
  68. package/dist/templates/mdx/fonts.mdx.d.ts +1 -1
  69. package/dist/templates/mdx/fonts.mdx.js +2 -2
  70. package/dist/templates/mdx/footer-links.mdx.d.ts +1 -1
  71. package/dist/templates/mdx/footer-links.mdx.js +1 -1
  72. package/dist/templates/mdx/frames.mdx.d.ts +1 -1
  73. package/dist/templates/mdx/frames.mdx.js +1 -1
  74. package/dist/templates/mdx/globals.mdx.d.ts +1 -1
  75. package/dist/templates/mdx/globals.mdx.js +1 -1
  76. package/dist/templates/mdx/icons.mdx.d.ts +1 -1
  77. package/dist/templates/mdx/icons.mdx.js +1 -1
  78. package/dist/templates/mdx/image-and-embeds.mdx.d.ts +1 -1
  79. package/dist/templates/mdx/image-and-embeds.mdx.js +1 -1
  80. package/dist/templates/mdx/media-and-assets.mdx.d.ts +1 -1
  81. package/dist/templates/mdx/media-and-assets.mdx.js +2 -2
  82. package/dist/templates/mdx/mermaid.mdx.d.ts +1 -1
  83. package/dist/templates/mdx/mermaid.mdx.js +1 -1
  84. package/dist/templates/mdx/model-context-protocol.mdx.d.ts +1 -1
  85. package/dist/templates/mdx/model-context-protocol.mdx.js +2 -2
  86. package/dist/templates/mdx/navigation.mdx.d.ts +1 -1
  87. package/dist/templates/mdx/navigation.mdx.js +22 -11
  88. package/dist/templates/mdx/platform/ai-assistant.mdx.d.ts +1 -1
  89. package/dist/templates/mdx/platform/ai-assistant.mdx.js +4 -3
  90. package/dist/templates/mdx/platform/analytics.mdx.d.ts +1 -1
  91. package/dist/templates/mdx/platform/analytics.mdx.js +2 -2
  92. package/dist/templates/mdx/platform/api-playground.mdx.d.ts +1 -0
  93. package/dist/templates/mdx/platform/api-playground.mdx.js +62 -0
  94. package/dist/templates/mdx/platform/billing.mdx.d.ts +1 -1
  95. package/dist/templates/mdx/platform/billing.mdx.js +1 -1
  96. package/dist/templates/mdx/platform/build-and-deploy.mdx.d.ts +1 -1
  97. package/dist/templates/mdx/platform/build-and-deploy.mdx.js +1 -1
  98. package/dist/templates/mdx/platform/creating-a-project.mdx.d.ts +1 -1
  99. package/dist/templates/mdx/platform/creating-a-project.mdx.js +12 -2
  100. package/dist/templates/mdx/platform/custom-domains.mdx.d.ts +1 -1
  101. package/dist/templates/mdx/platform/custom-domains.mdx.js +1 -1
  102. package/dist/templates/mdx/platform/fonts-settings.mdx.d.ts +1 -1
  103. package/dist/templates/mdx/platform/fonts-settings.mdx.js +1 -1
  104. package/dist/templates/mdx/platform/footer-links.mdx.d.ts +1 -0
  105. package/dist/templates/mdx/platform/footer-links.mdx.js +47 -0
  106. package/dist/templates/mdx/platform/import-from-github.mdx.d.ts +1 -0
  107. package/dist/templates/mdx/platform/import-from-github.mdx.js +91 -0
  108. package/dist/templates/mdx/platform/mcp.mdx.d.ts +1 -1
  109. package/dist/templates/mdx/platform/mcp.mdx.js +3 -3
  110. package/dist/templates/mdx/platform/project-settings.mdx.d.ts +1 -1
  111. package/dist/templates/mdx/platform/project-settings.mdx.js +1 -1
  112. package/dist/templates/mdx/platform/self-updating-docs.mdx.d.ts +1 -0
  113. package/dist/templates/mdx/platform/self-updating-docs.mdx.js +113 -0
  114. package/dist/templates/mdx/platform/team-members.mdx.d.ts +1 -1
  115. package/dist/templates/mdx/platform/team-members.mdx.js +1 -1
  116. package/dist/templates/mdx/sections.mdx.d.ts +1 -1
  117. package/dist/templates/mdx/sections.mdx.js +1 -1
  118. package/dist/templates/mdx/steps.mdx.d.ts +1 -1
  119. package/dist/templates/mdx/steps.mdx.js +1 -1
  120. package/dist/templates/mdx/tabs.mdx.d.ts +1 -1
  121. package/dist/templates/mdx/tabs.mdx.js +1 -1
  122. package/dist/templates/mdx/theme.mdx.d.ts +1 -1
  123. package/dist/templates/mdx/theme.mdx.js +1 -1
  124. package/dist/templates/mdx/update.mdx.d.ts +1 -1
  125. package/dist/templates/mdx/update.mdx.js +1 -1
  126. package/dist/templates/mdx/what-is-doccupine.mdx.d.ts +1 -1
  127. package/dist/templates/mdx/what-is-doccupine.mdx.js +1 -1
  128. package/dist/templates/package.js +6 -6
  129. package/dist/templates/services/openapi/playgroundAllowlistStub.d.ts +1 -0
  130. package/dist/templates/services/openapi/playgroundAllowlistStub.js +4 -0
  131. package/dist/templates/types/openapi.d.ts +1 -0
  132. package/dist/templates/types/openapi.js +93 -0
  133. package/dist/templates/utils/apiAnchors.d.ts +1 -0
  134. package/dist/templates/utils/apiAnchors.js +39 -0
  135. package/dist/templates/utils/apiSnippets.d.ts +1 -0
  136. package/dist/templates/utils/apiSnippets.js +94 -0
  137. package/dist/templates/utils/orderNavItems.d.ts +1 -1
  138. package/dist/templates/utils/orderNavItems.js +3 -0
  139. package/dist/templates/utils/playgroundAllowlist.d.ts +1 -0
  140. package/dist/templates/utils/playgroundAllowlist.js +70 -0
  141. package/dist/templates/utils/ssrfGuard.d.ts +1 -0
  142. package/dist/templates/utils/ssrfGuard.js +217 -0
  143. package/package.json +3 -2
@@ -0,0 +1 @@
1
+ export declare const apiPlaygroundDemoTemplate = "\"use client\";\nimport dynamic from \"next/dynamic\";\nimport type { OperationDescriptor } from \"@/types/openapi\";\nimport type { AllowlistEntry } from \"@/utils/playgroundAllowlist\";\n\n// Lazy-load the playground so it only ships to pages that actually render the\n// demo (this wrapper is registered globally for MDX, but the heavy component\n// stays in its own chunk). SSR is left on (the default) so the compact bar is\n// present in the initial HTML and does not flash in after hydration - the\n// modal is closed on first render, so there is nothing browser-only to run.\nconst ApiPlayground = dynamic(() =>\n import(\"@/components/layout/ApiPlayground\").then((m) => m.ApiPlayground),\n);\n\n// A self-contained live demo for the docs. It calls a public, CORS-enabled test\n// API in direct mode, so it works even without a configured OpenAPI spec. The\n// server proxy is unaffected - it still only forwards to allowlisted servers;\n// this inline allowlist only relaxes the client-side pre-flight for the demo.\nconst DEMO_OPERATION: OperationDescriptor = {\n specName: \"demo\",\n operationId: \"createPost\",\n method: \"post\",\n path: \"/posts\",\n summary: \"Create a post\",\n description:\n \"Creates a blog post for a user. This demo calls JSONPlaceholder, a free public test API, so it is safe to run - it echoes your request back with a new id. Edit the body below and press Send.\",\n tags: [\"Posts\"],\n parameters: [],\n requestBody: {\n required: true,\n content: [\n {\n contentType: \"application/json\",\n schema: {\n type: \"object\",\n required: [\"title\", \"userId\"],\n properties: {\n title: { type: \"string\", description: \"The title of the post.\" },\n body: { type: \"string\", description: \"The post's body text.\" },\n userId: {\n type: \"integer\",\n description: \"Id of the user creating the post.\",\n },\n },\n },\n example: {\n title: \"Hello from the playground\",\n body: \"This request was sent straight from the docs.\",\n userId: 1,\n },\n },\n ],\n },\n responses: [\n {\n status: \"201\",\n description: \"The created post, echoed back with a new id.\",\n content: [{ contentType: \"application/json\" }],\n headers: [],\n },\n ],\n servers: [{ url: \"https://jsonplaceholder.typicode.com\" }],\n security: [],\n slug: \"\",\n endpointAnchor: \"demo\",\n};\n\nconst DEMO_ALLOWLIST: AllowlistEntry[] = [\n { scheme: \"https\", host: \"jsonplaceholder.typicode.com\", port: null },\n];\n\nexport function ApiPlaygroundDemo() {\n return (\n <ApiPlayground\n operation={DEMO_OPERATION}\n allowlist={DEMO_ALLOWLIST}\n defaultMode=\"direct\"\n />\n );\n}\n";
@@ -0,0 +1,81 @@
1
+ export const apiPlaygroundDemoTemplate = `"use client";
2
+ import dynamic from "next/dynamic";
3
+ import type { OperationDescriptor } from "@/types/openapi";
4
+ import type { AllowlistEntry } from "@/utils/playgroundAllowlist";
5
+
6
+ // Lazy-load the playground so it only ships to pages that actually render the
7
+ // demo (this wrapper is registered globally for MDX, but the heavy component
8
+ // stays in its own chunk). SSR is left on (the default) so the compact bar is
9
+ // present in the initial HTML and does not flash in after hydration - the
10
+ // modal is closed on first render, so there is nothing browser-only to run.
11
+ const ApiPlayground = dynamic(() =>
12
+ import("@/components/layout/ApiPlayground").then((m) => m.ApiPlayground),
13
+ );
14
+
15
+ // A self-contained live demo for the docs. It calls a public, CORS-enabled test
16
+ // API in direct mode, so it works even without a configured OpenAPI spec. The
17
+ // server proxy is unaffected - it still only forwards to allowlisted servers;
18
+ // this inline allowlist only relaxes the client-side pre-flight for the demo.
19
+ const DEMO_OPERATION: OperationDescriptor = {
20
+ specName: "demo",
21
+ operationId: "createPost",
22
+ method: "post",
23
+ path: "/posts",
24
+ summary: "Create a post",
25
+ description:
26
+ "Creates a blog post for a user. This demo calls JSONPlaceholder, a free public test API, so it is safe to run - it echoes your request back with a new id. Edit the body below and press Send.",
27
+ tags: ["Posts"],
28
+ parameters: [],
29
+ requestBody: {
30
+ required: true,
31
+ content: [
32
+ {
33
+ contentType: "application/json",
34
+ schema: {
35
+ type: "object",
36
+ required: ["title", "userId"],
37
+ properties: {
38
+ title: { type: "string", description: "The title of the post." },
39
+ body: { type: "string", description: "The post's body text." },
40
+ userId: {
41
+ type: "integer",
42
+ description: "Id of the user creating the post.",
43
+ },
44
+ },
45
+ },
46
+ example: {
47
+ title: "Hello from the playground",
48
+ body: "This request was sent straight from the docs.",
49
+ userId: 1,
50
+ },
51
+ },
52
+ ],
53
+ },
54
+ responses: [
55
+ {
56
+ status: "201",
57
+ description: "The created post, echoed back with a new id.",
58
+ content: [{ contentType: "application/json" }],
59
+ headers: [],
60
+ },
61
+ ],
62
+ servers: [{ url: "https://jsonplaceholder.typicode.com" }],
63
+ security: [],
64
+ slug: "",
65
+ endpointAnchor: "demo",
66
+ };
67
+
68
+ const DEMO_ALLOWLIST: AllowlistEntry[] = [
69
+ { scheme: "https", host: "jsonplaceholder.typicode.com", port: null },
70
+ ];
71
+
72
+ export function ApiPlaygroundDemo() {
73
+ return (
74
+ <ApiPlayground
75
+ operation={DEMO_OPERATION}
76
+ allowlist={DEMO_ALLOWLIST}
77
+ defaultMode="direct"
78
+ />
79
+ );
80
+ }
81
+ `;
@@ -1 +1 @@
1
- export declare const codeTemplate = "\"use client\";\nimport { useState, useCallback, useMemo, useId } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport {\n interactiveStyles,\n resetButton,\n styledCode,\n} from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { unified } from \"unified\";\nimport rehypeParse from \"rehype-parse\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeStringify from \"rehype-stringify\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { thinScrollbar } from \"@/components/layout/SharedStyled\";\n\ninterface CodeProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n \"theme\"\n> {\n code: string;\n language?: string;\n title?: string;\n theme?: Theme;\n}\n\ninterface CodeTab {\n label: string;\n code: string;\n language?: string;\n}\n\ninterface CodeTabsProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n \"theme\"\n> {\n tabs: CodeTab[];\n theme?: Theme;\n}\n\nconst CodeWrapper = styled.span<{ theme: Theme }>`\n position: relative;\n z-index: 2;\n display: block;\n width: 100%;\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n background: ${({ theme }) => theme.colors.light};\n`;\n\n/* Code block uses a fixed GitHub-style palette for the syntax tokens in both\n modes so highlighting stays legible regardless of brand colors. The dark-mode\n surface, however, matches the left sidebar's translucent brand tint\n (color-mix of theme.colors.primaryLight over the black page) instead of\n GitHub's #0d1117, so the window sits on the same background as the nav. Dark\n variants live in :root.dark & blocks so the swap happens via the active\n <html> class with no re-render. */\nconst TopBar = styled.div<{ theme: Theme }>`\n position: relative;\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 5%, transparent)`};\n border-top-left-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-top-right-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-bottom: solid 1px ${({ theme }) => theme.colors.grayLight};\n height: 33px;\n width: 100%;\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 5px;\n padding: 0 10px;\n`;\n\nconst DotsContainer = styled.div`\n display: flex;\n gap: 5px;\n`;\n\nconst Dot = styled.span<{ theme: Theme }>`\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background: rgba(0, 0, 0, 0.1);\n\n :root.dark & {\n background: rgba(255, 255, 255, 0.1);\n }\n`;\n\n/* Icon-only copy button. interactiveStyles supplies the border highlight on\n hover plus the focus/active rings (no scale effect). Colors come from theme\n tokens (grayLight border, success/grayDark icon) that swap for dark mode via\n the theme prop, so no :root.dark & override is needed and the copied state\n reads consistently in both modes. */\nconst CopyButton = styled.button<{ theme: Theme; $copied: boolean }>`\n ${resetButton}\n ${interactiveStyles}\n background: ${({ theme }) => theme.colors.light};\n border-color: ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n margin-right: -6px;\n\n & svg.lucide {\n margin: 0;\n color: ${({ theme, $copied }) =>\n $copied ? theme.colors.success : theme.colors.grayDark};\n }\n`;\n\n/* Centered file name in the TopBar. Sits absolutely over the flex row so the\n dots and copy button keep their edge alignment. Monospace + a muted grayDark\n token that swaps for dark mode via the theme prop. pointer-events off so\n clicks fall through to nothing and never steal focus from the buttons. */\nconst TopBarTitle = styled.span<{ theme: Theme }>`\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n max-width: 60%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n pointer-events: none;\n font-family: ${({ theme }) => theme.fonts.mono};\n font-size: 12px;\n line-height: 2;\n color: ${({ theme }) => theme.colors.grayDark};\n`;\n\n/* Segmented control living in the TopBar for CodeTabs. Scrolls horizontally\n with the thin scrollbar when the labels overflow the 33px bar. */\nconst TabList = styled.div<{ theme: Theme }>`\n display: flex;\n align-items: center;\n gap: 2px;\n min-width: 0;\n overflow-x: auto;\n ${thinScrollbar};\n margin-left: -6px;\n`;\n\n/* Individual tab button. The active tab reads as part of the window: a\n theme.colors.light fill that echoes the code body, with a soft grayLight\n border. Inactive tabs are muted (grayDark) and transparent. resetButton\n strips native styling; focus-visible draws an inset brand primary ring on a\n pseudo-element so the scrolling TabList can't clip it. Colors come from theme\n tokens that swap for dark mode via the theme prop, so no :root.dark &\n override is needed. */\nconst CodeTab = styled.button<{ theme: Theme; $active: boolean }>`\n ${resetButton}\n flex: 0 0 auto;\n position: relative;\n font-family: ${({ theme }) => theme.fonts.mono};\n font-size: 12px;\n line-height: 1;\n padding: 5px;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n cursor: pointer;\n white-space: nowrap;\n transition:\n color 0.15s ease,\n background 0.15s ease,\n border-color 0.15s ease;\n border: solid 1px\n ${({ theme, $active }) =>\n $active ? theme.colors.grayLight : \"transparent\"};\n background: ${({ theme, $active }) =>\n $active ? theme.colors.light : \"transparent\"};\n color: ${({ theme, $active }) =>\n $active ? theme.colors.dark : theme.colors.grayDark};\n\n &:hover {\n color: ${({ theme }) => theme.colors.dark};\n background: ${({ theme, $active }) =>\n $active\n ? theme.colors.light\n : `color-mix(in srgb, ${theme.colors.dark} 4%, transparent)`};\n }\n\n &:focus-visible {\n outline: none;\n }\n\n &:focus-visible::after {\n content: \"\";\n position: absolute;\n inset: 2px;\n border: solid 2px ${({ theme }) => theme.colors.primary};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n pointer-events: none;\n }\n`;\n\n/* GitHub Light syntax highlighting by default; GitHub Dark in :root.dark.\n Browser resolves which rule wins based on the active <html> class with no\n JS or React re-render involved. */\nconst lightSyntaxHighlight = css`\n & .hljs {\n color: #24292f;\n background: #ffffff;\n }\n & .hljs-doctag,\n & .hljs-keyword,\n & .hljs-meta .hljs-keyword,\n & .hljs-template-tag,\n & .hljs-template-variable,\n & .hljs-type,\n & .hljs-variable.language_ {\n color: #cf222e;\n }\n & .hljs-title,\n & .hljs-title.class_,\n & .hljs-title.class_.inherited__,\n & .hljs-title.function_ {\n color: #8250df;\n }\n & .hljs-attr,\n & .hljs-attribute,\n & .hljs-literal,\n & .hljs-meta,\n & .hljs-number,\n & .hljs-operator,\n & .hljs-selector-attr,\n & .hljs-selector-class,\n & .hljs-selector-id,\n & .hljs-variable {\n color: #0550ae;\n }\n & .hljs-meta .hljs-string,\n & .hljs-regexp,\n & .hljs-string {\n color: #0a3069;\n }\n & .hljs-built_in,\n & .hljs-symbol {\n color: #953800;\n }\n & .hljs-code,\n & .hljs-comment,\n & .hljs-formula {\n color: #6e7781;\n }\n & .hljs-name,\n & .hljs-quote,\n & .hljs-selector-pseudo,\n & .hljs-selector-tag {\n color: #116329;\n }\n & .hljs-subst {\n color: #24292f;\n }\n & .hljs-section {\n color: #0550ae;\n font-weight: 700;\n }\n & .hljs-bullet {\n color: #953800;\n }\n & .hljs-emphasis {\n color: #24292f;\n font-style: italic;\n }\n & .hljs-strong {\n color: #24292f;\n font-weight: 700;\n }\n`;\n\nconst darkSyntaxHighlight = css`\n & .hljs {\n color: #c9d1d9;\n background: transparent;\n }\n & .hljs-doctag,\n & .hljs-keyword,\n & .hljs-meta .hljs-keyword,\n & .hljs-template-tag,\n & .hljs-template-variable,\n & .hljs-type,\n & .hljs-variable.language_ {\n color: #ff7b72;\n }\n & .hljs-title,\n & .hljs-title.class_,\n & .hljs-title.class_.inherited__,\n & .hljs-title.function_ {\n color: #d2a8ff;\n }\n & .hljs-attr,\n & .hljs-attribute,\n & .hljs-literal,\n & .hljs-meta,\n & .hljs-number,\n & .hljs-operator,\n & .hljs-selector-attr,\n & .hljs-selector-class,\n & .hljs-selector-id,\n & .hljs-variable {\n color: #79c0ff;\n }\n & .hljs-meta .hljs-string,\n & .hljs-regexp,\n & .hljs-string {\n color: #a5d6ff;\n }\n & .hljs-built_in,\n & .hljs-symbol {\n color: #ffa657;\n }\n & .hljs-code,\n & .hljs-comment,\n & .hljs-formula {\n color: #8b949e;\n }\n & .hljs-name,\n & .hljs-quote,\n & .hljs-selector-pseudo,\n & .hljs-selector-tag {\n color: #7ee787;\n }\n & .hljs-subst {\n color: #c9d1d9;\n }\n & .hljs-section {\n color: #1f6feb;\n font-weight: 700;\n }\n & .hljs-bullet {\n color: #f2cc60;\n }\n & .hljs-emphasis {\n color: #c9d1d9;\n font-style: italic;\n }\n & .hljs-strong {\n color: #c9d1d9;\n font-weight: 700;\n }\n`;\n\nconst Body = styled.div<{ theme: Theme }>`\n background: #ffffff;\n border-bottom-left-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-bottom-right-radius: ${({ theme }) => theme.spacing.radius.lg};\n color: #24292f;\n padding: 20px 0;\n font-family: ${({ theme }) => theme.fonts.mono};\n text-align: left;\n overflow-x: auto;\n overflow-y: auto;\n max-height: calc(100dvh - 400px);\n ${thinScrollbar};\n ${({ theme }) => styledCode(theme)};\n ${lightSyntaxHighlight};\n\n /* The 20px side gutter sits on the <code> element instead of the Body so it\n scrolls with the content: the right gutter survives a scroll to the end of\n a long line, and diff rows can bleed back through it to the window edge. */\n & .hljs {\n display: block;\n width: 100%;\n min-width: min-content;\n padding: 0 20px;\n }\n\n /* Diff rows: highlight.js wraps each +/- line in its own span, so tinting it\n edge to edge reads like a GitHub diff. inline-table keeps the trailing\n newline as the line break instead of adding an empty row, and the negative\n margin pulls the row back through the gutter so the accent bar sits flush\n against the window edge. border-left + padding-left add up to the same\n 20px, keeping the code itself aligned with the untouched lines. The tints\n are the success/error tokens at low alpha, so a custom theme.json palette\n carries through and the syntax colors underneath stay legible. */\n & .hljs-addition,\n & .hljs-deletion {\n display: inline-table;\n width: calc(100% + 40px);\n margin: 0 -20px;\n padding: 0 20px 0 17px;\n border-left: solid 3px transparent;\n }\n\n & .hljs-addition {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.success} 12%, transparent)`};\n border-left-color: ${({ theme }) => theme.colors.success};\n }\n\n & .hljs-deletion {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.error} 12%, transparent)`};\n border-left-color: ${({ theme }) => theme.colors.error};\n }\n\n :root.dark & {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 5%, transparent)`};\n color: #ffffff;\n ${darkSyntaxHighlight};\n\n /* The tints sit on a near-black surface in dark mode, so they need a few\n more points of alpha to read at the same strength as in light. */\n & .hljs-addition {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.success} 16%, transparent)`};\n }\n\n & .hljs-deletion {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.error} 16%, transparent)`};\n }\n }\n`;\n\nconst escapeHtml = (unsafe: string): string => {\n return unsafe\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#039;\");\n};\n\nconst sanitizeLanguage = (lang: string): string =>\n lang.replace(/[^a-zA-Z0-9_-]/g, \"\");\n\nconst highlightCode = (code: string, language: string): string => {\n const escapedCode = escapeHtml(code);\n const safeLang = sanitizeLanguage(language);\n const result = unified()\n .use(rehypeParse, { fragment: true })\n .use(rehypeHighlight, {\n detect: true,\n ignoreMissing: true,\n })\n .use(rehypeStringify)\n .processSync(\n `<pre><code class=\"language-${safeLang}\">${escapedCode}</code></pre>`,\n );\n\n return String(result);\n};\n\nfunction Code({\n code,\n language = \"javascript\",\n title,\n theme,\n className,\n}: CodeProps) {\n const [copied, setCopied] = useState(false);\n const highlightedCode = useMemo(\n () => highlightCode(code, language),\n [code, language],\n );\n\n const handleCopy = useCallback(async () => {\n try {\n await navigator.clipboard.writeText(code);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (err) {\n console.error(\"Failed to copy code:\", err);\n }\n }, [code]);\n\n return (\n <CodeWrapper\n className={`${className ?? \"\"} code-wrapper`.trim()}\n theme={theme}\n >\n <TopBar theme={theme}>\n <DotsContainer>\n <Dot theme={theme} />\n <Dot theme={theme} />\n <Dot theme={theme} />\n </DotsContainer>\n {title ? <TopBarTitle theme={theme}>{title}</TopBarTitle> : null}\n <CopyButton\n onClick={handleCopy}\n $copied={copied}\n theme={theme}\n aria-label={copied ? \"Copied\" : \"Copy code\"}\n >\n <Icon name={copied ? \"check\" : \"copy\"} size={12} />\n </CopyButton>\n </TopBar>\n <Body\n dangerouslySetInnerHTML={{ __html: highlightedCode }}\n theme={theme}\n className=\"code-wrapper-body\"\n />\n </CodeWrapper>\n );\n}\n\n/* Multi-variant code block (npm / pnpm / yarn, etc). Tabs replace the macOS\n dots in the TopBar as a keyboard-accessible tablist; the copy button copies\n whichever tab is active and resets its copied state when the tab changes. */\nfunction CodeTabs({ tabs, theme, className }: CodeTabsProps) {\n const baseId = useId();\n const [active, setActive] = useState(0);\n const [copied, setCopied] = useState(false);\n\n const safeActive = active < tabs.length ? active : 0;\n const activeTab = tabs[safeActive];\n\n const highlightedCode = useMemo(\n () =>\n activeTab\n ? highlightCode(activeTab.code, activeTab.language ?? \"bash\")\n : \"\",\n [activeTab],\n );\n\n const handleSelect = useCallback((index: number) => {\n setActive(index);\n setCopied(false);\n }, []);\n\n const handleCopy = useCallback(async () => {\n if (!activeTab) return;\n try {\n await navigator.clipboard.writeText(activeTab.code);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (err) {\n console.error(\"Failed to copy code:\", err);\n }\n }, [activeTab]);\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLButtonElement>) => {\n let next = safeActive;\n if (event.key === \"ArrowRight\" || event.key === \"ArrowDown\") {\n next = (safeActive + 1) % tabs.length;\n } else if (event.key === \"ArrowLeft\" || event.key === \"ArrowUp\") {\n next = (safeActive - 1 + tabs.length) % tabs.length;\n } else if (event.key === \"Home\") {\n next = 0;\n } else if (event.key === \"End\") {\n next = tabs.length - 1;\n } else {\n return;\n }\n event.preventDefault();\n handleSelect(next);\n const target = document.getElementById(`${baseId}-tab-${next}`);\n if (target) target.focus();\n },\n [baseId, handleSelect, safeActive, tabs.length],\n );\n\n if (!tabs || tabs.length === 0) return null;\n\n return (\n <CodeWrapper\n className={`${className ?? \"\"} code-wrapper`.trim()}\n theme={theme}\n >\n <TopBar theme={theme}>\n <TabList role=\"tablist\" aria-label=\"Code variants\">\n {tabs.map((tab, index) => (\n <CodeTab\n key={`${tab.label}-${index}`}\n type=\"button\"\n role=\"tab\"\n id={`${baseId}-tab-${index}`}\n aria-selected={index === safeActive}\n aria-controls={`${baseId}-panel`}\n tabIndex={index === safeActive ? 0 : -1}\n onClick={() => handleSelect(index)}\n onKeyDown={handleKeyDown}\n $active={index === safeActive}\n theme={theme}\n >\n {tab.label}\n </CodeTab>\n ))}\n </TabList>\n <CopyButton\n onClick={handleCopy}\n $copied={copied}\n theme={theme}\n aria-label={copied ? \"Copied\" : \"Copy code\"}\n >\n <Icon name={copied ? \"check\" : \"copy\"} size={12} />\n </CopyButton>\n </TopBar>\n <Body\n id={`${baseId}-panel`}\n role=\"tabpanel\"\n aria-labelledby={`${baseId}-tab-${safeActive}`}\n dangerouslySetInnerHTML={{ __html: highlightedCode }}\n theme={theme}\n className=\"code-wrapper-body\"\n />\n </CodeWrapper>\n );\n}\n\nexport { Code, CodeTabs };\n";
1
+ export declare const codeTemplate = "\"use client\";\nimport { useState, useCallback, useMemo, useId } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport {\n interactiveStyles,\n resetButton,\n styledCode,\n} from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { unified } from \"unified\";\nimport rehypeParse from \"rehype-parse\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeStringify from \"rehype-stringify\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { thinScrollbar } from \"@/components/layout/SharedStyled\";\n\ninterface CodeProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n \"theme\"\n> {\n code: string;\n language?: string;\n title?: string;\n theme?: Theme;\n}\n\ninterface CodeTab {\n label: string;\n code: string;\n language?: string;\n}\n\ninterface CodeTabsProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n \"theme\"\n> {\n tabs: CodeTab[];\n theme?: Theme;\n}\n\nconst CodeWrapper = styled.span<{ theme: Theme }>`\n position: relative;\n z-index: 2;\n display: block;\n width: 100%;\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n background: ${({ theme }) => theme.colors.light};\n`;\n\n/* Code block uses a fixed GitHub-style palette for the syntax tokens in both\n modes so highlighting stays legible regardless of brand colors. The dark-mode\n surface, however, matches the left sidebar's translucent brand tint\n (color-mix of theme.colors.primaryLight over the black page) instead of\n GitHub's #0d1117, so the window sits on the same background as the nav. Dark\n variants live in :root.dark & blocks so the swap happens via the active\n <html> class with no re-render. */\nconst TopBar = styled.div<{ theme: Theme }>`\n position: relative;\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 5%, transparent)`};\n border-top-left-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-top-right-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-bottom: solid 1px ${({ theme }) => theme.colors.grayLight};\n height: 33px;\n width: 100%;\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 5px;\n padding: 0 10px;\n`;\n\nconst DotsContainer = styled.div`\n display: flex;\n gap: 5px;\n`;\n\nconst Dot = styled.span<{ theme: Theme }>`\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background: rgba(0, 0, 0, 0.1);\n\n :root.dark & {\n background: rgba(255, 255, 255, 0.1);\n }\n`;\n\n/* Icon-only copy button. interactiveStyles supplies the border highlight on\n hover plus the focus/active rings (no scale effect). Colors come from theme\n tokens (grayLight border, success/grayDark icon) that swap for dark mode via\n the theme prop, so no :root.dark & override is needed and the copied state\n reads consistently in both modes. */\nconst CopyButton = styled.button<{ theme: Theme; $copied: boolean }>`\n ${resetButton}\n ${interactiveStyles}\n background: ${({ theme }) => theme.colors.light};\n border-color: ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n margin-right: -6px;\n\n & svg.lucide {\n margin: 0;\n color: ${({ theme, $copied }) =>\n $copied ? theme.colors.success : theme.colors.grayDark};\n }\n`;\n\n/* Centered file name in the TopBar. Sits absolutely over the flex row so the\n dots and copy button keep their edge alignment. Monospace + a muted grayDark\n token that swaps for dark mode via the theme prop. pointer-events off so\n clicks fall through to nothing and never steal focus from the buttons. */\nconst TopBarTitle = styled.span<{ theme: Theme }>`\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n max-width: 60%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n pointer-events: none;\n font-family: ${({ theme }) => theme.fonts.mono};\n font-size: 12px;\n line-height: 2;\n color: ${({ theme }) => theme.colors.grayDark};\n`;\n\n/* Segmented control living in the TopBar for CodeTabs. Scrolls horizontally\n with the thin scrollbar when the labels overflow the 33px bar. */\nconst TabList = styled.div<{ theme: Theme }>`\n display: flex;\n align-items: center;\n gap: 2px;\n min-width: 0;\n overflow-x: auto;\n ${thinScrollbar};\n padding: 2px;\n margin-left: -8px;\n`;\n\nconst CodeTab = styled.button<{ theme: Theme; $active: boolean }>`\n ${resetButton}\n ${interactiveStyles}\n flex: 0 0 auto;\n font-family: ${({ theme }) => theme.fonts.mono};\n font-size: 12px;\n line-height: 1;\n padding: 5px;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n cursor: pointer;\n white-space: nowrap;\n transition: all 0.3s ease;\n border: solid 1px\n ${({ theme, $active }) =>\n $active ? theme.colors.grayLight : \"transparent\"};\n background: ${({ theme, $active }) =>\n $active ? theme.colors.light : \"transparent\"};\n color: ${({ theme, $active }) =>\n $active ? theme.colors.dark : theme.colors.grayDark};\n box-shadow: 0 0 0 0px ${({ theme }) => theme.colors.primary};\n\n &:hover {\n color: ${({ theme }) => theme.colors.dark};\n background: ${({ theme, $active }) =>\n $active\n ? theme.colors.light\n : `color-mix(in srgb, ${theme.colors.dark} 4%, transparent)`};\n }\n\n &:focus {\n border-color: ${({ theme }) => theme.colors.primary};\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n\n &:active {\n box-shadow: 0 0 0 1px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\n/* GitHub Light syntax highlighting by default; GitHub Dark in :root.dark.\n Browser resolves which rule wins based on the active <html> class with no\n JS or React re-render involved. */\nconst lightSyntaxHighlight = css`\n & .hljs {\n color: #24292f;\n background: #ffffff;\n }\n & .hljs-doctag,\n & .hljs-keyword,\n & .hljs-meta .hljs-keyword,\n & .hljs-template-tag,\n & .hljs-template-variable,\n & .hljs-type,\n & .hljs-variable.language_ {\n color: #cf222e;\n }\n & .hljs-title,\n & .hljs-title.class_,\n & .hljs-title.class_.inherited__,\n & .hljs-title.function_ {\n color: #8250df;\n }\n & .hljs-attr,\n & .hljs-attribute,\n & .hljs-literal,\n & .hljs-meta,\n & .hljs-number,\n & .hljs-operator,\n & .hljs-selector-attr,\n & .hljs-selector-class,\n & .hljs-selector-id,\n & .hljs-variable {\n color: #0550ae;\n }\n & .hljs-meta .hljs-string,\n & .hljs-regexp,\n & .hljs-string {\n color: #0a3069;\n }\n & .hljs-built_in,\n & .hljs-symbol {\n color: #953800;\n }\n & .hljs-code,\n & .hljs-comment,\n & .hljs-formula {\n color: #6e7781;\n }\n & .hljs-name,\n & .hljs-quote,\n & .hljs-selector-pseudo,\n & .hljs-selector-tag {\n color: #116329;\n }\n & .hljs-subst {\n color: #24292f;\n }\n & .hljs-section {\n color: #0550ae;\n font-weight: 700;\n }\n & .hljs-bullet {\n color: #953800;\n }\n & .hljs-emphasis {\n color: #24292f;\n font-style: italic;\n }\n & .hljs-strong {\n color: #24292f;\n font-weight: 700;\n }\n`;\n\nconst darkSyntaxHighlight = css`\n & .hljs {\n color: #c9d1d9;\n background: transparent;\n }\n & .hljs-doctag,\n & .hljs-keyword,\n & .hljs-meta .hljs-keyword,\n & .hljs-template-tag,\n & .hljs-template-variable,\n & .hljs-type,\n & .hljs-variable.language_ {\n color: #ff7b72;\n }\n & .hljs-title,\n & .hljs-title.class_,\n & .hljs-title.class_.inherited__,\n & .hljs-title.function_ {\n color: #d2a8ff;\n }\n & .hljs-attr,\n & .hljs-attribute,\n & .hljs-literal,\n & .hljs-meta,\n & .hljs-number,\n & .hljs-operator,\n & .hljs-selector-attr,\n & .hljs-selector-class,\n & .hljs-selector-id,\n & .hljs-variable {\n color: #79c0ff;\n }\n & .hljs-meta .hljs-string,\n & .hljs-regexp,\n & .hljs-string {\n color: #a5d6ff;\n }\n & .hljs-built_in,\n & .hljs-symbol {\n color: #ffa657;\n }\n & .hljs-code,\n & .hljs-comment,\n & .hljs-formula {\n color: #8b949e;\n }\n & .hljs-name,\n & .hljs-quote,\n & .hljs-selector-pseudo,\n & .hljs-selector-tag {\n color: #7ee787;\n }\n & .hljs-subst {\n color: #c9d1d9;\n }\n & .hljs-section {\n color: #1f6feb;\n font-weight: 700;\n }\n & .hljs-bullet {\n color: #f2cc60;\n }\n & .hljs-emphasis {\n color: #c9d1d9;\n font-style: italic;\n }\n & .hljs-strong {\n color: #c9d1d9;\n font-weight: 700;\n }\n`;\n\nconst Body = styled.div<{ theme: Theme }>`\n background: #ffffff;\n border-bottom-left-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-bottom-right-radius: ${({ theme }) => theme.spacing.radius.lg};\n color: #24292f;\n padding: 20px 0;\n font-family: ${({ theme }) => theme.fonts.mono};\n text-align: left;\n overflow-x: auto;\n overflow-y: auto;\n max-height: calc(100dvh - 400px);\n ${thinScrollbar};\n ${({ theme }) => styledCode(theme)};\n ${lightSyntaxHighlight};\n\n /* The 20px side gutter sits on the <code> element instead of the Body so it\n scrolls with the content: the right gutter survives a scroll to the end of\n a long line, and diff rows can bleed back through it to the window edge. */\n & .hljs {\n display: block;\n width: 100%;\n min-width: min-content;\n padding: 0 20px;\n }\n\n /* Diff rows: highlight.js wraps each +/- line in its own span, so tinting it\n edge to edge reads like a GitHub diff. inline-table keeps the trailing\n newline as the line break instead of adding an empty row, and the negative\n margin pulls the row back through the gutter so the accent bar sits flush\n against the window edge. border-left + padding-left add up to the same\n 20px, keeping the code itself aligned with the untouched lines. The tints\n are the success/error tokens at low alpha, so a custom theme.json palette\n carries through and the syntax colors underneath stay legible. */\n & .hljs-addition,\n & .hljs-deletion {\n display: inline-table;\n width: calc(100% + 40px);\n margin: 0 -20px;\n padding: 0 20px 0 17px;\n border-left: solid 3px transparent;\n }\n\n & .hljs-addition {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.success} 12%, transparent)`};\n border-left-color: ${({ theme }) => theme.colors.success};\n }\n\n & .hljs-deletion {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.error} 12%, transparent)`};\n border-left-color: ${({ theme }) => theme.colors.error};\n }\n\n :root.dark & {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 5%, transparent)`};\n color: #ffffff;\n ${darkSyntaxHighlight};\n\n /* The tints sit on a near-black surface in dark mode, so they need a few\n more points of alpha to read at the same strength as in light. */\n & .hljs-addition {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.success} 16%, transparent)`};\n }\n\n & .hljs-deletion {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.error} 16%, transparent)`};\n }\n }\n`;\n\nconst escapeHtml = (unsafe: string): string => {\n return unsafe\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#039;\");\n};\n\nconst sanitizeLanguage = (lang: string): string =>\n lang.replace(/[^a-zA-Z0-9_-]/g, \"\");\n\nconst highlightCode = (code: string, language: string): string => {\n const escapedCode = escapeHtml(code);\n const safeLang = sanitizeLanguage(language);\n const result = unified()\n .use(rehypeParse, { fragment: true })\n .use(rehypeHighlight, {\n detect: true,\n ignoreMissing: true,\n })\n .use(rehypeStringify)\n .processSync(\n `<pre><code class=\"language-${safeLang}\">${escapedCode}</code></pre>`,\n );\n\n return String(result);\n};\n\nfunction Code({\n code,\n language = \"javascript\",\n title,\n theme,\n className,\n}: CodeProps) {\n const [copied, setCopied] = useState(false);\n const highlightedCode = useMemo(\n () => highlightCode(code, language),\n [code, language],\n );\n\n const handleCopy = useCallback(async () => {\n try {\n await navigator.clipboard.writeText(code);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (err) {\n console.error(\"Failed to copy code:\", err);\n }\n }, [code]);\n\n return (\n <CodeWrapper\n className={`${className ?? \"\"} code-wrapper`.trim()}\n theme={theme}\n >\n <TopBar theme={theme}>\n <DotsContainer>\n <Dot theme={theme} />\n <Dot theme={theme} />\n <Dot theme={theme} />\n </DotsContainer>\n {title ? <TopBarTitle theme={theme}>{title}</TopBarTitle> : null}\n <CopyButton\n onClick={handleCopy}\n $copied={copied}\n theme={theme}\n aria-label={copied ? \"Copied\" : \"Copy code\"}\n >\n <Icon name={copied ? \"check\" : \"copy\"} size={12} />\n </CopyButton>\n </TopBar>\n <Body\n dangerouslySetInnerHTML={{ __html: highlightedCode }}\n theme={theme}\n className=\"code-wrapper-body\"\n />\n </CodeWrapper>\n );\n}\n\n/* Multi-variant code block (npm / pnpm / yarn, etc). Tabs replace the macOS\n dots in the TopBar as a keyboard-accessible tablist; the copy button copies\n whichever tab is active and resets its copied state when the tab changes. */\nfunction CodeTabs({ tabs, theme, className }: CodeTabsProps) {\n const baseId = useId();\n const [active, setActive] = useState(0);\n const [copied, setCopied] = useState(false);\n\n const safeActive = active < tabs.length ? active : 0;\n const activeTab = tabs[safeActive];\n\n const highlightedCode = useMemo(\n () =>\n activeTab\n ? highlightCode(activeTab.code, activeTab.language ?? \"bash\")\n : \"\",\n [activeTab],\n );\n\n const handleSelect = useCallback((index: number) => {\n setActive(index);\n setCopied(false);\n }, []);\n\n const handleCopy = useCallback(async () => {\n if (!activeTab) return;\n try {\n await navigator.clipboard.writeText(activeTab.code);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (err) {\n console.error(\"Failed to copy code:\", err);\n }\n }, [activeTab]);\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLButtonElement>) => {\n let next = safeActive;\n if (event.key === \"ArrowRight\" || event.key === \"ArrowDown\") {\n next = (safeActive + 1) % tabs.length;\n } else if (event.key === \"ArrowLeft\" || event.key === \"ArrowUp\") {\n next = (safeActive - 1 + tabs.length) % tabs.length;\n } else if (event.key === \"Home\") {\n next = 0;\n } else if (event.key === \"End\") {\n next = tabs.length - 1;\n } else {\n return;\n }\n event.preventDefault();\n handleSelect(next);\n const target = document.getElementById(`${baseId}-tab-${next}`);\n if (target) target.focus();\n },\n [baseId, handleSelect, safeActive, tabs.length],\n );\n\n if (!tabs || tabs.length === 0) return null;\n\n return (\n <CodeWrapper\n className={`${className ?? \"\"} code-wrapper`.trim()}\n theme={theme}\n >\n <TopBar theme={theme}>\n <TabList role=\"tablist\" aria-label=\"Code variants\">\n {tabs.map((tab, index) => (\n <CodeTab\n key={`${tab.label}-${index}`}\n type=\"button\"\n role=\"tab\"\n id={`${baseId}-tab-${index}`}\n aria-selected={index === safeActive}\n aria-controls={`${baseId}-panel`}\n tabIndex={index === safeActive ? 0 : -1}\n onClick={() => handleSelect(index)}\n onKeyDown={handleKeyDown}\n $active={index === safeActive}\n theme={theme}\n >\n {tab.label}\n </CodeTab>\n ))}\n </TabList>\n <CopyButton\n onClick={handleCopy}\n $copied={copied}\n theme={theme}\n aria-label={copied ? \"Copied\" : \"Copy code\"}\n >\n <Icon name={copied ? \"check\" : \"copy\"} size={12} />\n </CopyButton>\n </TopBar>\n <Body\n id={`${baseId}-panel`}\n role=\"tabpanel\"\n aria-labelledby={`${baseId}-tab-${safeActive}`}\n dangerouslySetInnerHTML={{ __html: highlightedCode }}\n theme={theme}\n className=\"code-wrapper-body\"\n />\n </CodeWrapper>\n );\n}\n\nexport { Code, CodeTabs };\n";
@@ -139,20 +139,14 @@ const TabList = styled.div<{ theme: Theme }>\`
139
139
  min-width: 0;
140
140
  overflow-x: auto;
141
141
  \${thinScrollbar};
142
- margin-left: -6px;
142
+ padding: 2px;
143
+ margin-left: -8px;
143
144
  \`;
144
145
 
145
- /* Individual tab button. The active tab reads as part of the window: a
146
- theme.colors.light fill that echoes the code body, with a soft grayLight
147
- border. Inactive tabs are muted (grayDark) and transparent. resetButton
148
- strips native styling; focus-visible draws an inset brand primary ring on a
149
- pseudo-element so the scrolling TabList can't clip it. Colors come from theme
150
- tokens that swap for dark mode via the theme prop, so no :root.dark &
151
- override is needed. */
152
146
  const CodeTab = styled.button<{ theme: Theme; $active: boolean }>\`
153
147
  \${resetButton}
148
+ \${interactiveStyles}
154
149
  flex: 0 0 auto;
155
- position: relative;
156
150
  font-family: \${({ theme }) => theme.fonts.mono};
157
151
  font-size: 12px;
158
152
  line-height: 1;
@@ -160,10 +154,7 @@ const CodeTab = styled.button<{ theme: Theme; $active: boolean }>\`
160
154
  border-radius: \${({ theme }) => theme.spacing.radius.xs};
161
155
  cursor: pointer;
162
156
  white-space: nowrap;
163
- transition:
164
- color 0.15s ease,
165
- background 0.15s ease,
166
- border-color 0.15s ease;
157
+ transition: all 0.3s ease;
167
158
  border: solid 1px
168
159
  \${({ theme, $active }) =>
169
160
  $active ? theme.colors.grayLight : "transparent"};
@@ -171,6 +162,7 @@ const CodeTab = styled.button<{ theme: Theme; $active: boolean }>\`
171
162
  $active ? theme.colors.light : "transparent"};
172
163
  color: \${({ theme, $active }) =>
173
164
  $active ? theme.colors.dark : theme.colors.grayDark};
165
+ box-shadow: 0 0 0 0px \${({ theme }) => theme.colors.primary};
174
166
 
175
167
  &:hover {
176
168
  color: \${({ theme }) => theme.colors.dark};
@@ -180,17 +172,13 @@ const CodeTab = styled.button<{ theme: Theme; $active: boolean }>\`
180
172
  : \`color-mix(in srgb, \${theme.colors.dark} 4%, transparent)\`};
181
173
  }
182
174
 
183
- &:focus-visible {
184
- outline: none;
175
+ &:focus {
176
+ border-color: \${({ theme }) => theme.colors.primary};
177
+ box-shadow: 0 0 0 2px \${({ theme }) => theme.colors.primaryLight};
185
178
  }
186
179
 
187
- &:focus-visible::after {
188
- content: "";
189
- position: absolute;
190
- inset: 2px;
191
- border: solid 2px \${({ theme }) => theme.colors.primary};
192
- border-radius: \${({ theme }) => theme.spacing.radius.xs};
193
- pointer-events: none;
180
+ &:active {
181
+ box-shadow: 0 0 0 1px \${({ theme }) => theme.colors.primaryLight};
194
182
  }
195
183
  \`;
196
184
 
@@ -0,0 +1 @@
1
+ export declare const copyButtonTemplate = "\"use client\";\nimport { useCallback, useState } from \"react\";\nimport styled from \"styled-components\";\nimport { resetButton, interactiveStyles } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon } from \"@/components/layout/Icon\";\n\n/* Icon-only copy-to-clipboard button. Same look/behaviour as the copy button in\n the code block: interactiveStyles supplies the border highlight on hover plus\n the focus/active rings, and the icon swaps to a check in success green for two\n seconds after a successful copy. Theme tokens swap for dark mode on their own,\n so no :root.dark override is needed. */\nconst StyledCopyButton = styled.button<{ theme: Theme; $copied: boolean }>`\n ${resetButton}\n ${interactiveStyles}\n background: ${({ theme }) => theme.colors.light};\n border-color: ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n\n & svg.lucide {\n margin: 0;\n color: ${({ theme, $copied }) =>\n $copied ? theme.colors.success : theme.colors.grayDark};\n }\n`;\n\ninterface CopyButtonProps {\n text: string;\n size?: number;\n label?: string;\n className?: string;\n}\n\nexport function CopyButton({\n text,\n size = 12,\n label = \"Copy\",\n className,\n}: CopyButtonProps) {\n const [copied, setCopied] = useState(false);\n\n const handleCopy = useCallback(async () => {\n try {\n await navigator.clipboard.writeText(text);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (err) {\n console.error(\"Failed to copy:\", err);\n }\n }, [text]);\n\n return (\n <StyledCopyButton\n type=\"button\"\n onClick={handleCopy}\n $copied={copied}\n aria-label={copied ? \"Copied\" : label}\n className={className}\n >\n <Icon name={copied ? \"check\" : \"copy\"} size={size} />\n </StyledCopyButton>\n );\n}\n";
@@ -0,0 +1,68 @@
1
+ export const copyButtonTemplate = `"use client";
2
+ import { useCallback, useState } from "react";
3
+ import styled from "styled-components";
4
+ import { resetButton, interactiveStyles } from "cherry-styled-components";
5
+ import { Theme } from "@/app/theme";
6
+ import { Icon } from "@/components/layout/Icon";
7
+
8
+ /* Icon-only copy-to-clipboard button. Same look/behaviour as the copy button in
9
+ the code block: interactiveStyles supplies the border highlight on hover plus
10
+ the focus/active rings, and the icon swaps to a check in success green for two
11
+ seconds after a successful copy. Theme tokens swap for dark mode on their own,
12
+ so no :root.dark override is needed. */
13
+ const StyledCopyButton = styled.button<{ theme: Theme; $copied: boolean }>\`
14
+ \${resetButton}
15
+ \${interactiveStyles}
16
+ background: \${({ theme }) => theme.colors.light};
17
+ border-color: \${({ theme }) => theme.colors.grayLight};
18
+ border-radius: \${({ theme }) => theme.spacing.radius.xs};
19
+ padding: 4px;
20
+ display: flex;
21
+ align-items: center;
22
+ justify-content: center;
23
+
24
+ & svg.lucide {
25
+ margin: 0;
26
+ color: \${({ theme, $copied }) =>
27
+ $copied ? theme.colors.success : theme.colors.grayDark};
28
+ }
29
+ \`;
30
+
31
+ interface CopyButtonProps {
32
+ text: string;
33
+ size?: number;
34
+ label?: string;
35
+ className?: string;
36
+ }
37
+
38
+ export function CopyButton({
39
+ text,
40
+ size = 12,
41
+ label = "Copy",
42
+ className,
43
+ }: CopyButtonProps) {
44
+ const [copied, setCopied] = useState(false);
45
+
46
+ const handleCopy = useCallback(async () => {
47
+ try {
48
+ await navigator.clipboard.writeText(text);
49
+ setCopied(true);
50
+ setTimeout(() => setCopied(false), 2000);
51
+ } catch (err) {
52
+ console.error("Failed to copy:", err);
53
+ }
54
+ }, [text]);
55
+
56
+ return (
57
+ <StyledCopyButton
58
+ type="button"
59
+ onClick={handleCopy}
60
+ $copied={copied}
61
+ aria-label={copied ? "Copied" : label}
62
+ className={className}
63
+ >
64
+ <Icon name={copied ? "check" : "copy"} size={size} />
65
+ </StyledCopyButton>
66
+ );
67
+ }
68
+ `;
@@ -1 +1 @@
1
- export declare const docsComponentsTemplate = "\"use client\";\nimport React, { createContext, useContext } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport {\n resetButton,\n styledSmall,\n styledStrong,\n styledText,\n} from \"cherry-styled-components\";\nimport Link from \"next/link\";\nimport { mq, Theme } from \"@/app/theme\";\nimport {\n styledAnchor,\n styledTable,\n stylesLists,\n} from \"@/components/layout/SharedStyled\";\nimport { ChatContext } from \"@/components/Chat\";\n\nconst SectionBarContext = createContext(false);\n\nfunction SectionBarProvider({\n hasSectionBar,\n children,\n}: {\n hasSectionBar: boolean;\n children: React.ReactNode;\n}) {\n return (\n <SectionBarContext.Provider value={hasSectionBar}>\n {children}\n </SectionBarContext.Provider>\n );\n}\n\ninterface DocsProps {\n children: React.ReactNode;\n}\n\nconst StyledDocsWrapper = styled.main<{ theme: Theme }>`\n position: relative;\n`;\n\nconst StyledDocsSidebar = styled.div<{ theme: Theme }>`\n clear: both;\n`;\n\nconst StyledDocsContainer = styled.div<{ theme: Theme; $isChatOpen?: boolean }>`\n position: relative;\n padding: 0 20px 100px 20px;\n width: 100%;\n ${({ theme }) => styledText(theme)};\n transition: all 0.3s ease;\n\n ${mq(\"lg\")} {\n padding: 0 300px 80px 300px;\n\n ${({ $isChatOpen }) =>\n $isChatOpen &&\n css`\n padding: 0 440px 80px 300px;\n `}\n }\n\n & p {\n color: ${({ theme }) => theme.colors.grayDark};\n hyphens: auto;\n }\n\n & pre {\n max-width: 100%;\n }\n\n ${styledAnchor};\n ${stylesLists};\n ${styledTable};\n\n & img,\n & video,\n & iframe {\n max-width: 100%;\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n }\n\n & code:not([class]),\n & kbd {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 20%, transparent)`};\n color: ${({ theme }) => theme.colors.dark};\n padding: 2px 4px;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n overflow-wrap: anywhere;\n }\n\n & .lucide {\n color: ${({ theme }) => theme.colors.primary};\n }\n\n & .aspect-video {\n aspect-ratio: 16 / 9;\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n }\n`;\n\nexport const StyledMarkdownContainer = styled.div`\n display: flex;\n flex-direction: column;\n gap: 20px;\n flex: 1;\n max-width: 640px;\n margin: auto;\n`;\n\ninterface Props {\n theme?: Theme;\n $isActive?: boolean;\n $isOpen?: boolean;\n $hasSectionBar?: boolean;\n}\n\nexport const StyledSidebar = styled.nav<Props>`\n position: fixed;\n overflow-y: auto;\n max-height: calc(\n 100dvh - ${({ $hasSectionBar }) => ($hasSectionBar ? 104 : 62)}px\n );\n width: 100%;\n z-index: 99;\n top: ${({ $hasSectionBar }) => ($hasSectionBar ? 104 : 62)}px;\n height: 100%;\n padding: 20px;\n opacity: 0;\n pointer-events: none;\n transition: all 0.3s ease;\n transform: translateY(30px);\n left: 0;\n background: ${({ theme }) => theme.colors.light};\n -webkit-overflow-scrolling: touch;\n display: flex;\n flex-direction: column;\n\n &::-webkit-scrollbar {\n display: none;\n }\n\n ${mq(\"lg\")} {\n border-right: solid 1px ${({ theme }) => theme.colors.grayLight};\n transition: none;\n max-height: 100dvh;\n width: 220px;\n background: transparent;\n padding: 82px 20px 20px 20px;\n opacity: 1;\n pointer-events: all;\n transform: translateY(0);\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 5%, transparent)`};\n top: 0;\n width: 280px;\n }\n\n ${({ $isActive }) =>\n $isActive &&\n css`\n transform: translateY(0);\n opacity: 1;\n pointer-events: all;\n `}\n`;\n\nexport const StyledSidebarFooter = styled.div`\n padding: 22px 20px;\n position: sticky;\n border-top: 1px solid ${({ theme }) => theme.colors.grayLight};\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 5%, transparent)`};\n margin: 0 -20px -20px;\n bottom: -20px;\n backdrop-filter: blur(10px);\n\n ${mq(\"lg\")} {\n padding: 16px 20px;\n }\n`;\n\nexport const StyledIndexSidebar = styled.ul<{ theme: Theme }>`\n display: none;\n list-style: none;\n margin: 0;\n padding: 0;\n position: fixed;\n top: 0;\n right: 0;\n width: 280px;\n height: 100dvh;\n overflow-y: auto;\n z-index: 1;\n padding: 82px 20px 20px 20px;\n background: ${({ theme }) => theme.colors.light};\n border-left: solid 1px ${({ theme }) => theme.colors.grayLight};\n -webkit-overflow-scrolling: touch;\n\n &::-webkit-scrollbar {\n display: none;\n }\n\n ${mq(\"lg\")} {\n display: block;\n }\n\n & li {\n padding: 5px 0;\n }\n`;\n\nexport const StyledIndexSidebarLabel = styled.span<{ theme: Theme }>`\n ${({ theme }) => styledSmall(theme)};\n color: ${({ theme }) => theme.colors.grayDark};\n`;\n\nexport const StyledIndexSidebarLi = styled.li<{\n theme: Theme;\n $isActive: boolean;\n}>`\n &::before {\n content: \"\";\n display: block;\n position: absolute;\n left: 0;\n height: 20px;\n width: 1px;\n background: transparent;\n transition: all 0.3s ease;\n }\n\n ${({ $isActive, theme }) =>\n $isActive &&\n css`\n &::before {\n background: ${theme.colors.primary};\n }\n `}\n`;\n\nexport const StyledIndexSidebarLink = styled.a<{\n theme: Theme;\n $isActive: boolean;\n}>`\n ${({ theme }) => styledSmall(theme)};\n color: ${({ theme, $isActive }) =>\n $isActive ? theme.colors.primary : theme.colors.dark};\n font-weight: ${({ $isActive }) => ($isActive ? \"600\" : \"400\")};\n text-decoration: none;\n transition: all 0.3s ease;\n\n &:hover {\n color: ${({ theme }) => theme.colors.primary};\n }\n`;\n\nexport const StyledSidebarList = styled.ul`\n list-style: none;\n margin: 0;\n padding: 0;\n\n &:last-of-type {\n margin-bottom: auto;\n }\n`;\n\nexport const StyledStrong = styled.strong<{ theme: Theme }>`\n font-weight: 600;\n ${({ theme }) => styledStrong(theme)};\n color: ${({ theme }) => theme.colors.accentStrong};\n display: inline-flex;\n align-items: center;\n gap: 8px;\n\n & svg {\n flex-shrink: 0;\n }\n`;\n\nexport const StyledSidebarListItem = styled.li`\n display: flex;\n gap: 10px;\n clear: both;\n`;\n\n// Shared appearance for every sidebar row - leaf links AND nested group\n// headers - so hover, active state, and the left rail read identically.\nconst sidebarRowStyles = css<Props>`\n text-decoration: none;\n font-size: ${({ theme }) => theme.fontSizes.small.lg};\n line-height: 1.6;\n color: ${({ theme }) => theme.colors.accentMuted};\n padding: 5px 0 5px 20px;\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n min-width: 0;\n transition: all 0.3s ease;\n border-left: solid 1px ${({ theme }) => theme.colors.grayLight};\n\n & svg {\n flex-shrink: 0;\n }\n\n &:hover {\n color: ${({ theme }) => theme.colors.accent};\n border-color: ${({ theme }) => theme.colors.primary};\n }\n\n ${({ $isActive, theme }) =>\n $isActive &&\n css`\n color: ${theme.colors.accentStrong};\n border-color: ${theme.colors.primary};\n font-weight: 600;\n `};\n`;\n\n// The collapse chevron points right when closed and rotates to point down\n// when the group is open.\nconst sidebarChevron = css<Props>`\n & .lucide-chevron-right {\n margin-left: auto;\n transition: transform 0.3s ease;\n\n ${({ $isOpen }) =>\n $isOpen &&\n css`\n transform: rotate(90deg);\n `}\n }\n`;\n\nexport const StyledSidebarListItemLink = styled(Link)<Props>`\n ${sidebarRowStyles};\n`;\n\n// Nested navigation group. The header shares the link appearance/hover; a\n// non-navigable group is a single toggle button, while a group that is also a\n// page pairs a link with a chevron toggle. Children live in\n// StyledSidebarGroupContent, which animates open/closed via height 0 <-> auto\n// (enabled by interpolate-size in GlobalStyles, same as the Accordion).\nexport const StyledSidebarGroupButton = styled.button<Props>`\n ${resetButton};\n ${sidebarRowStyles};\n ${sidebarChevron};\n width: 100%;\n text-align: left;\n\n /* Buttons aren't covered by the global a:focus-visible ring, so this\n nav-row toggle carries its own copy of it. */\n &:focus-visible {\n outline: none;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\nexport const StyledSidebarGroupRow = styled.div<Props>`\n ${sidebarRowStyles};\n ${sidebarChevron};\n\n /* The row is a plain div, so it never matches :focus-visible itself. Ring the\n whole row when its inner link or chevron takes keyboard focus instead, to\n match the leaf-row focus treatment. */\n &:has(:focus-visible) {\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\nexport const StyledSidebarGroupLink = styled(Link)`\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n min-width: 0;\n color: inherit;\n text-decoration: none;\n\n & svg {\n flex-shrink: 0;\n }\n\n /* Ring is drawn on the parent row via :has(:focus-visible); suppress the\n global a:focus-visible glow so it isn't drawn twice. */\n &:focus-visible {\n outline: none;\n box-shadow: none;\n }\n`;\n\nexport const StyledSidebarGroupChevron = styled.button`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n padding: 0;\n border: 0;\n background: none;\n color: inherit;\n cursor: pointer;\n\n /* Ring is drawn on the parent row via :has(:focus-visible). */\n &:focus-visible {\n outline: none;\n }\n`;\n\nexport const StyledSidebarGroupContent = styled.ul<Props>`\n list-style: none;\n margin: 0;\n padding: 0;\n height: 0;\n overflow: clip;\n transition: all 0.3s ease;\n\n ${({ $isOpen }) =>\n $isOpen &&\n css`\n height: auto;\n `}\n`;\n\nexport const StyleMobileBar = styled.button<Props>`\n ${resetButton};\n position: fixed;\n z-index: 999;\n bottom: 0;\n right: 20px;\n font-size: ${({ theme }) => theme.fontSizes.strong.lg};\n line-height: ${({ theme }) => theme.fontSizes.strong.lg};\n box-shadow: ${({ theme }) => theme.shadows.sm};\n background: ${({ theme }) => theme.colors.primary};\n color: ${({ theme }) => theme.colors.surface};\n backdrop-filter: blur(10px);\n -webkit-backdrop-filter: blur(10px);\n padding: 10px;\n border-radius: 100px;\n margin: 0 0 20px 0;\n font-weight: 600;\n display: flex;\n justify-content: flex-start;\n width: auto;\n\n ${mq(\"lg\")} {\n display: none;\n }\n\n ${({ $isActive }) => $isActive && `position: fixed;`};\n`;\n\nexport const StyledMobileBurger = styled.span<Props>`\n display: block;\n margin: auto 0;\n width: 18px;\n height: 18px;\n position: relative;\n overflow: hidden;\n background: transparent;\n position: relative;\n transform: scale(0.8);\n\n &::before,\n &::after {\n content: \"\";\n display: block;\n position: absolute;\n width: 18px;\n height: 3px;\n border-radius: 3px;\n background: ${({ theme }) => theme.colors.surface};\n transition: all 0.3s ease;\n }\n\n &::before {\n top: 3px;\n }\n\n &::after {\n bottom: 3px;\n }\n\n ${({ $isActive }) =>\n $isActive &&\n css`\n &::before {\n transform: translateY(5px) rotate(45deg);\n }\n\n &::after {\n transform: translateY(-4px) rotate(-45deg);\n }\n `};\n`;\n\nexport const StyledMissingComponent = styled.div`\n background: ${({ theme }) => theme.colors.error};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 20px;\n font-size: ${({ theme }) => theme.fontSizes.small.lg};\n color: ${({ theme }) => theme.colors.surface};\n font-weight: 600;\n display: flex;\n gap: 10px;\n align-items: center;\n`;\n\ninterface DocsWrapperProps {\n children: React.ReactNode;\n}\n\nfunction DocsWrapper({ children }: DocsWrapperProps) {\n return <StyledDocsWrapper>{children}</StyledDocsWrapper>;\n}\n\nfunction DocsSidebar({ children }: DocsProps) {\n return <StyledDocsSidebar>{children}</StyledDocsSidebar>;\n}\n\nfunction DocsContainer({ children }: DocsProps) {\n const { isOpen } = useContext(ChatContext);\n\n return (\n <StyledDocsContainer $isChatOpen={isOpen}>{children}</StyledDocsContainer>\n );\n}\n\nexport {\n DocsWrapper,\n DocsSidebar,\n DocsContainer,\n SectionBarContext,\n SectionBarProvider,\n};\n";
1
+ export declare const docsComponentsTemplate = "\"use client\";\nimport React, { createContext, useContext } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport {\n resetButton,\n styledSmall,\n styledStrong,\n styledText,\n} from \"cherry-styled-components\";\nimport Link from \"next/link\";\nimport { mq, Theme } from \"@/app/theme\";\nimport {\n styledAnchor,\n styledTable,\n stylesLists,\n} from \"@/components/layout/SharedStyled\";\nimport { ChatContext } from \"@/components/Chat\";\n\nconst SectionBarContext = createContext(false);\n\nfunction SectionBarProvider({\n hasSectionBar,\n children,\n}: {\n hasSectionBar: boolean;\n children: React.ReactNode;\n}) {\n return (\n <SectionBarContext.Provider value={hasSectionBar}>\n {children}\n </SectionBarContext.Provider>\n );\n}\n\ninterface DocsProps {\n children: React.ReactNode;\n}\n\nconst StyledDocsWrapper = styled.main<{ theme: Theme }>`\n position: relative;\n`;\n\nconst StyledDocsSidebar = styled.div<{ theme: Theme }>`\n clear: both;\n`;\n\nconst StyledDocsContainer = styled.div<{ theme: Theme; $isChatOpen?: boolean }>`\n position: relative;\n padding: 0 20px 100px 20px;\n width: 100%;\n ${({ theme }) => styledText(theme)};\n transition: all 0.3s ease;\n\n ${mq(\"lg\")} {\n padding: 0 300px 80px 300px;\n\n ${({ $isChatOpen }) =>\n $isChatOpen &&\n css`\n padding: 0 440px 80px 300px;\n `}\n }\n\n & p {\n color: ${({ theme }) => theme.colors.grayDark};\n hyphens: auto;\n }\n\n & pre {\n max-width: 100%;\n }\n\n ${styledAnchor};\n ${stylesLists};\n ${styledTable};\n\n & img,\n & video,\n & iframe {\n max-width: 100%;\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n }\n\n & code:not([class]),\n & kbd {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 20%, transparent)`};\n color: ${({ theme }) => theme.colors.dark};\n padding: 2px 4px;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n overflow-wrap: anywhere;\n }\n\n & .lucide {\n color: ${({ theme }) => theme.colors.primary};\n }\n\n & .aspect-video {\n aspect-ratio: 16 / 9;\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n }\n`;\n\nexport const StyledMarkdownContainer = styled.div`\n display: flex;\n flex-direction: column;\n gap: 20px;\n flex: 1;\n max-width: 640px;\n margin: auto;\n`;\n\ninterface Props {\n theme?: Theme;\n $isActive?: boolean;\n $isOpen?: boolean;\n $hasSectionBar?: boolean;\n}\n\nexport const StyledSidebar = styled.nav<Props>`\n position: fixed;\n overflow-y: auto;\n max-height: calc(\n 100dvh - ${({ $hasSectionBar }) => ($hasSectionBar ? 104 : 62)}px\n );\n width: 100%;\n z-index: 99;\n top: ${({ $hasSectionBar }) => ($hasSectionBar ? 104 : 62)}px;\n height: 100%;\n padding: 20px;\n opacity: 0;\n pointer-events: none;\n transition: all 0.3s ease;\n transform: translateY(30px);\n left: 0;\n background: ${({ theme }) => theme.colors.light};\n -webkit-overflow-scrolling: touch;\n display: flex;\n flex-direction: column;\n\n &::-webkit-scrollbar {\n display: none;\n }\n\n ${mq(\"lg\")} {\n border-right: solid 1px ${({ theme }) => theme.colors.grayLight};\n transition: none;\n max-height: 100dvh;\n width: 220px;\n background: transparent;\n padding: 82px 20px 20px 20px;\n opacity: 1;\n pointer-events: all;\n transform: translateY(0);\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 5%, transparent)`};\n top: 0;\n width: 280px;\n }\n\n ${({ $isActive }) =>\n $isActive &&\n css`\n transform: translateY(0);\n opacity: 1;\n pointer-events: all;\n `}\n`;\n\nexport const StyledSidebarFooter = styled.div`\n padding: 22px 20px;\n position: sticky;\n border-top: 1px solid ${({ theme }) => theme.colors.grayLight};\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 5%, transparent)`};\n margin: 0 -20px -20px;\n bottom: -20px;\n backdrop-filter: blur(10px);\n\n ${mq(\"lg\")} {\n padding: 16px 20px;\n }\n`;\n\nexport const StyledIndexSidebar = styled.ul<{ theme: Theme }>`\n display: none;\n list-style: none;\n margin: 0;\n padding: 0;\n position: fixed;\n top: 0;\n right: 0;\n width: 280px;\n height: 100dvh;\n overflow-y: auto;\n z-index: 1;\n padding: 82px 20px 20px 20px;\n background: ${({ theme }) => theme.colors.light};\n border-left: solid 1px ${({ theme }) => theme.colors.grayLight};\n -webkit-overflow-scrolling: touch;\n\n &::-webkit-scrollbar {\n display: none;\n }\n\n ${mq(\"lg\")} {\n display: block;\n }\n\n & li {\n padding: 5px 0;\n }\n`;\n\nexport const StyledIndexSidebarLabel = styled.span<{ theme: Theme }>`\n ${({ theme }) => styledSmall(theme)};\n color: ${({ theme }) => theme.colors.grayDark};\n`;\n\nexport const StyledIndexSidebarLi = styled.li<{\n theme: Theme;\n $isActive: boolean;\n}>`\n &::before {\n content: \"\";\n display: block;\n position: absolute;\n left: 0;\n height: 20px;\n width: 1px;\n background: transparent;\n transition: all 0.3s ease;\n }\n\n ${({ $isActive, theme }) =>\n $isActive &&\n css`\n &::before {\n background: ${theme.colors.primary};\n }\n `}\n`;\n\nexport const StyledIndexSidebarLink = styled.a<{\n theme: Theme;\n $isActive: boolean;\n}>`\n ${({ theme }) => styledSmall(theme)};\n color: ${({ theme, $isActive }) =>\n $isActive ? theme.colors.primary : theme.colors.dark};\n font-weight: ${({ $isActive }) => ($isActive ? \"600\" : \"400\")};\n text-decoration: none;\n transition: all 0.3s ease;\n\n &:hover {\n color: ${({ theme }) => theme.colors.primary};\n }\n`;\n\nexport const StyledSidebarList = styled.ul`\n list-style: none;\n margin: 0;\n padding: 0;\n\n &:last-of-type {\n margin-bottom: auto;\n }\n`;\n\nexport const StyledStrong = styled.strong<{ theme: Theme }>`\n font-weight: 600;\n ${({ theme }) => styledStrong(theme)};\n color: ${({ theme }) => theme.colors.accentStrong};\n display: inline-flex;\n align-items: center;\n gap: 8px;\n\n & svg {\n flex-shrink: 0;\n }\n`;\n\nexport const StyledSidebarListItem = styled.li`\n display: flex;\n gap: 10px;\n clear: both;\n`;\n\n// Shared appearance for every sidebar row - leaf links AND nested group\n// headers - so hover, active state, and the left rail read identically.\nconst sidebarRowStyles = css<Props>`\n text-decoration: none;\n font-size: ${({ theme }) => theme.fontSizes.small.lg};\n line-height: 1.6;\n color: ${({ theme }) => theme.colors.accentMuted};\n padding: 5px 0 5px 20px;\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n min-width: 0;\n transition: all 0.3s ease;\n border-left: solid 1px ${({ theme }) => theme.colors.grayLight};\n\n & svg {\n flex-shrink: 0;\n }\n\n &:hover {\n color: ${({ theme }) => theme.colors.accent};\n border-color: ${({ theme }) => theme.colors.primary};\n }\n\n ${({ $isActive, theme }) =>\n $isActive &&\n css`\n color: ${theme.colors.accentStrong};\n border-color: ${theme.colors.primary};\n font-weight: 600;\n `};\n`;\n\n// The collapse chevron points right when closed and rotates to point down\n// when the group is open.\nconst sidebarChevron = css<Props>`\n & .lucide-chevron-right {\n margin-left: auto;\n transition: transform 0.3s ease;\n\n ${({ $isOpen }) =>\n $isOpen &&\n css`\n transform: rotate(90deg);\n `}\n }\n`;\n\nexport const StyledSidebarListItemLink = styled(Link)<Props>`\n ${sidebarRowStyles};\n`;\n\n// Compact HTTP-method label shown before a generated API endpoint link, colored\n// by verb so endpoints are scannable in the sidebar. Only rendered when a link\n// carries an `httpMethod` (endpoint pages do; hand-written pages do not).\nconst METHOD_TAG_COLORS: Record<string, keyof Theme[\"colors\"]> = {\n get: \"info\",\n post: \"success\",\n put: \"warning\",\n patch: \"warning\",\n delete: \"error\",\n head: \"gray\",\n options: \"gray\",\n trace: \"gray\",\n};\n\nfunction methodTagColor(theme: Theme, method: string): string {\n return theme.colors[METHOD_TAG_COLORS[method.toLowerCase()] ?? \"gray\"];\n}\n\nexport const StyledSidebarMethodTag = styled.span<{\n theme: Theme;\n $method: string;\n $isActive?: boolean;\n}>`\n flex-shrink: 0;\n font-family: ${({ theme }) => theme.fonts.mono};\n font-size: 9px;\n font-weight: 700;\n letter-spacing: 0.02em;\n text-transform: uppercase;\n padding: 1px 4px;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n color: ${({ theme, $method, $isActive }) =>\n $isActive ? theme.colors.surface : methodTagColor(theme, $method)};\n background: ${({ theme, $method, $isActive }) =>\n $isActive\n ? methodTagColor(theme, $method)\n : `color-mix(in srgb, ${methodTagColor(theme, $method)} 15%, transparent)`};\n`;\n\n// Nested navigation group. The header shares the link appearance/hover; a\n// non-navigable group is a single toggle button, while a group that is also a\n// page pairs a link with a chevron toggle. Children live in\n// StyledSidebarGroupContent, which animates open/closed via height 0 <-> auto\n// (enabled by interpolate-size in GlobalStyles, same as the Accordion).\nexport const StyledSidebarGroupButton = styled.button<Props>`\n ${resetButton};\n ${sidebarRowStyles};\n ${sidebarChevron};\n width: 100%;\n text-align: left;\n\n /* Buttons aren't covered by the global a:focus-visible ring, so this\n nav-row toggle carries its own copy of it. */\n &:focus-visible {\n outline: none;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\nexport const StyledSidebarGroupRow = styled.div<Props>`\n ${sidebarRowStyles};\n ${sidebarChevron};\n\n /* The row is a plain div, so it never matches :focus-visible itself. Ring the\n whole row when its inner link or chevron takes keyboard focus instead, to\n match the leaf-row focus treatment. */\n &:has(:focus-visible) {\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\nexport const StyledSidebarGroupLink = styled(Link)`\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n min-width: 0;\n color: inherit;\n text-decoration: none;\n\n & svg {\n flex-shrink: 0;\n }\n\n /* Ring is drawn on the parent row via :has(:focus-visible); suppress the\n global a:focus-visible glow so it isn't drawn twice. */\n &:focus-visible {\n outline: none;\n box-shadow: none;\n }\n`;\n\nexport const StyledSidebarGroupChevron = styled.button`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n padding: 0;\n border: 0;\n background: none;\n color: inherit;\n cursor: pointer;\n\n /* Ring is drawn on the parent row via :has(:focus-visible). */\n &:focus-visible {\n outline: none;\n }\n`;\n\nexport const StyledSidebarGroupContent = styled.ul<Props>`\n list-style: none;\n margin: 0;\n padding: 0;\n height: 0;\n overflow: clip;\n transition: all 0.3s ease;\n\n ${({ $isOpen }) =>\n $isOpen &&\n css`\n height: auto;\n `}\n`;\n\nexport const StyleMobileBar = styled.button<Props>`\n ${resetButton};\n position: fixed;\n z-index: 999;\n bottom: 0;\n right: 20px;\n font-size: ${({ theme }) => theme.fontSizes.strong.lg};\n line-height: ${({ theme }) => theme.fontSizes.strong.lg};\n box-shadow: ${({ theme }) => theme.shadows.sm};\n background: ${({ theme }) => theme.colors.primary};\n color: ${({ theme }) => theme.colors.surface};\n backdrop-filter: blur(10px);\n -webkit-backdrop-filter: blur(10px);\n padding: 10px;\n border-radius: 100px;\n margin: 0 0 20px 0;\n font-weight: 600;\n display: flex;\n justify-content: flex-start;\n width: auto;\n\n ${mq(\"lg\")} {\n display: none;\n }\n\n ${({ $isActive }) => $isActive && `position: fixed;`};\n`;\n\nexport const StyledMobileBurger = styled.span<Props>`\n display: block;\n margin: auto 0;\n width: 18px;\n height: 18px;\n position: relative;\n overflow: hidden;\n background: transparent;\n position: relative;\n transform: scale(0.8);\n\n &::before,\n &::after {\n content: \"\";\n display: block;\n position: absolute;\n width: 18px;\n height: 3px;\n border-radius: 3px;\n background: ${({ theme }) => theme.colors.surface};\n transition: all 0.3s ease;\n }\n\n &::before {\n top: 3px;\n }\n\n &::after {\n bottom: 3px;\n }\n\n ${({ $isActive }) =>\n $isActive &&\n css`\n &::before {\n transform: translateY(5px) rotate(45deg);\n }\n\n &::after {\n transform: translateY(-4px) rotate(-45deg);\n }\n `};\n`;\n\nexport const StyledMissingComponent = styled.div`\n background: ${({ theme }) => theme.colors.error};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 20px;\n font-size: ${({ theme }) => theme.fontSizes.small.lg};\n color: ${({ theme }) => theme.colors.surface};\n font-weight: 600;\n display: flex;\n gap: 10px;\n align-items: center;\n`;\n\ninterface DocsWrapperProps {\n children: React.ReactNode;\n}\n\nfunction DocsWrapper({ children }: DocsWrapperProps) {\n return <StyledDocsWrapper>{children}</StyledDocsWrapper>;\n}\n\nfunction DocsSidebar({ children }: DocsProps) {\n return <StyledDocsSidebar>{children}</StyledDocsSidebar>;\n}\n\nfunction DocsContainer({ children }: DocsProps) {\n const { isOpen } = useContext(ChatContext);\n\n return (\n <StyledDocsContainer $isChatOpen={isOpen}>{children}</StyledDocsContainer>\n );\n}\n\nexport {\n DocsWrapper,\n DocsSidebar,\n DocsContainer,\n SectionBarContext,\n SectionBarProvider,\n};\n";
@@ -340,6 +340,45 @@ export const StyledSidebarListItemLink = styled(Link)<Props>\`
340
340
  \${sidebarRowStyles};
341
341
  \`;
342
342
 
343
+ // Compact HTTP-method label shown before a generated API endpoint link, colored
344
+ // by verb so endpoints are scannable in the sidebar. Only rendered when a link
345
+ // carries an \`httpMethod\` (endpoint pages do; hand-written pages do not).
346
+ const METHOD_TAG_COLORS: Record<string, keyof Theme["colors"]> = {
347
+ get: "info",
348
+ post: "success",
349
+ put: "warning",
350
+ patch: "warning",
351
+ delete: "error",
352
+ head: "gray",
353
+ options: "gray",
354
+ trace: "gray",
355
+ };
356
+
357
+ function methodTagColor(theme: Theme, method: string): string {
358
+ return theme.colors[METHOD_TAG_COLORS[method.toLowerCase()] ?? "gray"];
359
+ }
360
+
361
+ export const StyledSidebarMethodTag = styled.span<{
362
+ theme: Theme;
363
+ $method: string;
364
+ $isActive?: boolean;
365
+ }>\`
366
+ flex-shrink: 0;
367
+ font-family: \${({ theme }) => theme.fonts.mono};
368
+ font-size: 9px;
369
+ font-weight: 700;
370
+ letter-spacing: 0.02em;
371
+ text-transform: uppercase;
372
+ padding: 1px 4px;
373
+ border-radius: \${({ theme }) => theme.spacing.radius.xs};
374
+ color: \${({ theme, $method, $isActive }) =>
375
+ $isActive ? theme.colors.surface : methodTagColor(theme, $method)};
376
+ background: \${({ theme, $method, $isActive }) =>
377
+ $isActive
378
+ ? methodTagColor(theme, $method)
379
+ : \`color-mix(in srgb, \${methodTagColor(theme, $method)} 15%, transparent)\`};
380
+ \`;
381
+
343
382
  // Nested navigation group. The header shares the link appearance/hover; a
344
383
  // non-navigable group is a single toggle button, while a group that is also a
345
384
  // page pairs a link with a chevron toggle. Children live in
@@ -1 +1 @@
1
- export declare const mermaidViewTemplate = "\"use client\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { interactiveStyles, resetButton } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon } from \"@/components/layout/Icon\";\n\nconst MIN_SCALE = 0.5;\nconst MAX_SCALE = 4;\nconst SCALE_STEP = 0.25;\nconst PAN_STEP = 48;\nconst AUTO_ACTIONS_MIN_HEIGHT = 120;\n\nexport type MermaidPlacement =\n \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n\ninterface MermaidViewProps {\n svg: string;\n width?: number | null;\n placement?: MermaidPlacement;\n actions?: boolean;\n theme?: Theme;\n}\n\nconst Viewport = styled.div<{ $draggable: boolean; $dragging: boolean }>`\n overflow: hidden;\n padding: 16px;\n ${({ $draggable, $dragging }) =>\n $draggable &&\n css`\n cursor: ${$dragging ? \"grabbing\" : \"grab\"};\n user-select: none;\n `}\n`;\n\nconst Stage = styled.div<{\n $scale: number;\n $x: number;\n $y: number;\n $dragging: boolean;\n}>`\n transform: translate(${({ $x }) => $x}px, ${({ $y }) => $y}px)\n scale(${({ $scale }) => $scale});\n transform-origin: center center;\n transition: ${({ $dragging }) =>\n $dragging ? \"none\" : \"transform 0.15s ease-out\"};\n margin: 0 auto;\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n\n & > svg {\n display: block;\n width: 100%;\n height: auto;\n margin: 0 auto;\n }\n`;\n\nconst Figure = styled.figure<{ theme: Theme }>`\n position: relative;\n flex-shrink: 0;\n margin: 0;\n padding: 0;\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n background: ${({ theme }) => theme.colors.light};\n overflow: hidden;\n\n &:fullscreen {\n border: none;\n border-radius: 0;\n\n ${Viewport} {\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n ${Stage} {\n width: 100%;\n height: 100%;\n }\n\n ${Stage} > svg {\n height: 100%;\n }\n }\n`;\n\nconst Controls = styled.div<{ theme: Theme; $placement: MermaidPlacement }>`\n position: absolute;\n ${({ $placement }) => {\n const [vertical, horizontal] = $placement.split(\"-\");\n return css`\n ${vertical}: 8px;\n ${horizontal}: 8px;\n `;\n }}\n display: grid;\n grid-template-columns: repeat(3, 24px);\n grid-template-rows: repeat(3, 24px);\n gap: 2px;\n padding: 4px;\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n background: ${({ theme }) => theme.colors.light};\n box-shadow: ${({ theme }) => theme.shadows.sm};\n`;\n\nconst ControlButton = styled.button<{ theme: Theme }>`\n ${resetButton};\n ${interactiveStyles};\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n color: ${({ theme }) => theme.colors.grayDark};\n cursor: pointer;\n\n &:hover:not(:disabled) {\n background: ${({ theme }) => theme.colors.grayLight};\n color: ${({ theme }) => theme.colors.dark};\n }\n\n &:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n }\n`;\n\nfunction MermaidView({\n svg,\n width,\n placement = \"bottom-right\",\n actions,\n ...props\n}: MermaidViewProps) {\n const [scale, setScale] = useState(1);\n const [offset, setOffset] = useState({ x: 0, y: 0 });\n const [autoShow, setAutoShow] = useState(false);\n const [dragging, setDragging] = useState(false);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const [canFullscreen, setCanFullscreen] = useState(false);\n const viewportRef = useRef<HTMLDivElement>(null);\n const figureRef = useRef<HTMLElement>(null);\n const dragStart = useRef<{\n x: number;\n y: number;\n ox: number;\n oy: number;\n } | null>(null);\n\n useEffect(() => {\n if (actions !== undefined) return;\n const element = viewportRef.current;\n if (!element || typeof ResizeObserver === \"undefined\") return;\n\n const measure = () => {\n setAutoShow(\n element.getBoundingClientRect().height > AUTO_ACTIONS_MIN_HEIGHT,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, [actions]);\n\n useEffect(() => {\n setCanFullscreen(Boolean(document.fullscreenEnabled));\n const onChange = () =>\n setIsFullscreen(document.fullscreenElement === figureRef.current);\n document.addEventListener(\"fullscreenchange\", onChange);\n return () => document.removeEventListener(\"fullscreenchange\", onChange);\n }, []);\n\n const showControls = actions ?? autoShow;\n\n const zoom = useCallback((delta: number) => {\n setScale((current) =>\n Math.min(\n MAX_SCALE,\n Math.max(MIN_SCALE, Math.round((current + delta) * 100) / 100),\n ),\n );\n }, []);\n\n const pan = useCallback((x: number, y: number) => {\n setOffset((current) => ({ x: current.x + x, y: current.y + y }));\n }, []);\n\n const reset = useCallback(() => {\n setScale(1);\n setOffset({ x: 0, y: 0 });\n }, []);\n\n const toggleFullscreen = useCallback(() => {\n const element = figureRef.current;\n if (!element) return;\n if (document.fullscreenElement === element) {\n void document.exitFullscreen().catch(() => {});\n } else {\n void element.requestFullscreen().catch(() => {});\n }\n }, []);\n\n const handlePointerDown = (event: React.PointerEvent<HTMLDivElement>) => {\n if (!showControls || event.pointerType !== \"mouse\" || event.button !== 0) {\n return;\n }\n event.currentTarget.setPointerCapture(event.pointerId);\n dragStart.current = {\n x: event.clientX,\n y: event.clientY,\n ox: offset.x,\n oy: offset.y,\n };\n setDragging(true);\n };\n\n const handlePointerMove = (event: React.PointerEvent<HTMLDivElement>) => {\n const start = dragStart.current;\n if (!start) return;\n setOffset({\n x: start.ox + (event.clientX - start.x),\n y: start.oy + (event.clientY - start.y),\n });\n };\n\n const endDrag = (event: React.PointerEvent<HTMLDivElement>) => {\n if (!dragStart.current) return;\n dragStart.current = null;\n setDragging(false);\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n };\n\n const isReset = scale === 1 && offset.x === 0 && offset.y === 0;\n\n return (\n <Figure ref={figureRef} {...props}>\n <Viewport\n ref={viewportRef}\n $draggable={showControls}\n $dragging={dragging}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={endDrag}\n onPointerCancel={endDrag}\n >\n <Stage\n $scale={scale}\n $x={offset.x}\n $y={offset.y}\n $dragging={dragging}\n style={\n width && !isFullscreen ? { maxWidth: `${width}px` } : undefined\n }\n dangerouslySetInnerHTML={{ __html: svg }}\n />\n </Viewport>\n\n {showControls && (\n <Controls $placement={placement}>\n <ControlButton\n type=\"button\"\n aria-label=\"Zoom out\"\n onClick={() => zoom(-SCALE_STEP)}\n disabled={scale <= MIN_SCALE}\n >\n <Icon name=\"zoom-out\" size={14} />\n </ControlButton>\n <ControlButton\n type=\"button\"\n aria-label=\"Pan up\"\n onClick={() => pan(0, -PAN_STEP)}\n >\n <Icon name=\"chevron-up\" size={14} />\n </ControlButton>\n <ControlButton\n type=\"button\"\n aria-label=\"Zoom in\"\n onClick={() => zoom(SCALE_STEP)}\n disabled={scale >= MAX_SCALE}\n >\n <Icon name=\"zoom-in\" size={14} />\n </ControlButton>\n\n <ControlButton\n type=\"button\"\n aria-label=\"Pan left\"\n onClick={() => pan(-PAN_STEP, 0)}\n >\n <Icon name=\"chevron-left\" size={14} />\n </ControlButton>\n <ControlButton\n type=\"button\"\n aria-label=\"Reset view\"\n onClick={reset}\n disabled={isReset}\n >\n <Icon name=\"rotate-ccw\" size={14} />\n </ControlButton>\n <ControlButton\n type=\"button\"\n aria-label=\"Pan right\"\n onClick={() => pan(PAN_STEP, 0)}\n >\n <Icon name=\"chevron-right\" size={14} />\n </ControlButton>\n\n {canFullscreen ? (\n <ControlButton\n type=\"button\"\n aria-label={isFullscreen ? \"Exit full screen\" : \"Full screen\"}\n onClick={toggleFullscreen}\n >\n <Icon name={isFullscreen ? \"minimize\" : \"maximize\"} size={14} />\n </ControlButton>\n ) : (\n <span />\n )}\n <ControlButton\n type=\"button\"\n aria-label=\"Pan down\"\n onClick={() => pan(0, PAN_STEP)}\n >\n <Icon name=\"chevron-down\" size={14} />\n </ControlButton>\n <span />\n </Controls>\n )}\n </Figure>\n );\n}\n\nexport { MermaidView };\n";
1
+ export declare const mermaidViewTemplate = "\"use client\";\nimport {\n useCallback,\n useEffect,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { interactiveStyles, resetButton } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon } from \"@/components/layout/Icon\";\n\nconst MIN_SCALE = 0.5;\nconst MAX_SCALE = 4;\nconst SCALE_STEP = 0.25;\nconst PAN_STEP = 48;\nconst AUTO_ACTIONS_MIN_HEIGHT = 120;\n\n// Whether the Fullscreen API is available. Read via useSyncExternalStore so it\n// resolves during render (SSR-safe: false on the server) instead of via a\n// synchronous setState inside an effect. The capability never changes, so the\n// subscribe callback is a stable no-op.\nconst subscribeFullscreenCapability = () => () => {};\nconst getFullscreenCapability = () =>\n typeof document !== \"undefined\" && Boolean(document.fullscreenEnabled);\nconst getFullscreenCapabilityServer = () => false;\n\nexport type MermaidPlacement =\n \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n\ninterface MermaidViewProps {\n svg: string;\n width?: number | null;\n placement?: MermaidPlacement;\n actions?: boolean;\n theme?: Theme;\n}\n\nconst Viewport = styled.div<{ $draggable: boolean; $dragging: boolean }>`\n overflow: hidden;\n padding: 16px;\n ${({ $draggable, $dragging }) =>\n $draggable &&\n css`\n cursor: ${$dragging ? \"grabbing\" : \"grab\"};\n user-select: none;\n `}\n`;\n\nconst Stage = styled.div<{\n $scale: number;\n $x: number;\n $y: number;\n $dragging: boolean;\n}>`\n transform: translate(${({ $x }) => $x}px, ${({ $y }) => $y}px)\n scale(${({ $scale }) => $scale});\n transform-origin: center center;\n transition: ${({ $dragging }) =>\n $dragging ? \"none\" : \"transform 0.15s ease-out\"};\n margin: 0 auto;\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n\n & > svg {\n display: block;\n width: 100%;\n height: auto;\n margin: 0 auto;\n }\n`;\n\nconst Figure = styled.figure<{ theme: Theme }>`\n position: relative;\n flex-shrink: 0;\n margin: 0;\n padding: 0;\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n background: ${({ theme }) => theme.colors.light};\n overflow: hidden;\n\n &:fullscreen {\n border: none;\n border-radius: 0;\n\n ${Viewport} {\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n ${Stage} {\n width: 100%;\n height: 100%;\n }\n\n ${Stage} > svg {\n height: 100%;\n }\n }\n`;\n\nconst Controls = styled.div<{ theme: Theme; $placement: MermaidPlacement }>`\n position: absolute;\n ${({ $placement }) => {\n const [vertical, horizontal] = $placement.split(\"-\");\n return css`\n ${vertical}: 8px;\n ${horizontal}: 8px;\n `;\n }}\n display: grid;\n grid-template-columns: repeat(3, 24px);\n grid-template-rows: repeat(3, 24px);\n gap: 2px;\n padding: 4px;\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n background: ${({ theme }) => theme.colors.light};\n box-shadow: ${({ theme }) => theme.shadows.sm};\n`;\n\nconst ControlButton = styled.button<{ theme: Theme }>`\n ${resetButton};\n ${interactiveStyles};\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n color: ${({ theme }) => theme.colors.grayDark};\n cursor: pointer;\n\n &:hover:not(:disabled) {\n background: ${({ theme }) => theme.colors.grayLight};\n color: ${({ theme }) => theme.colors.dark};\n }\n\n &:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n }\n`;\n\nfunction MermaidView({\n svg,\n width,\n placement = \"bottom-right\",\n actions,\n ...props\n}: MermaidViewProps) {\n const [scale, setScale] = useState(1);\n const [offset, setOffset] = useState({ x: 0, y: 0 });\n const [autoShow, setAutoShow] = useState(false);\n const [dragging, setDragging] = useState(false);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const canFullscreen = useSyncExternalStore(\n subscribeFullscreenCapability,\n getFullscreenCapability,\n getFullscreenCapabilityServer,\n );\n const viewportRef = useRef<HTMLDivElement>(null);\n const figureRef = useRef<HTMLElement>(null);\n const dragStart = useRef<{\n x: number;\n y: number;\n ox: number;\n oy: number;\n } | null>(null);\n\n useEffect(() => {\n if (actions !== undefined) return;\n const element = viewportRef.current;\n if (!element || typeof ResizeObserver === \"undefined\") return;\n\n const measure = () => {\n setAutoShow(\n element.getBoundingClientRect().height > AUTO_ACTIONS_MIN_HEIGHT,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, [actions]);\n\n useEffect(() => {\n const onChange = () =>\n setIsFullscreen(document.fullscreenElement === figureRef.current);\n document.addEventListener(\"fullscreenchange\", onChange);\n return () => document.removeEventListener(\"fullscreenchange\", onChange);\n }, []);\n\n const showControls = actions ?? autoShow;\n\n const zoom = useCallback((delta: number) => {\n setScale((current) =>\n Math.min(\n MAX_SCALE,\n Math.max(MIN_SCALE, Math.round((current + delta) * 100) / 100),\n ),\n );\n }, []);\n\n const pan = useCallback((x: number, y: number) => {\n setOffset((current) => ({ x: current.x + x, y: current.y + y }));\n }, []);\n\n const reset = useCallback(() => {\n setScale(1);\n setOffset({ x: 0, y: 0 });\n }, []);\n\n const toggleFullscreen = useCallback(() => {\n const element = figureRef.current;\n if (!element) return;\n if (document.fullscreenElement === element) {\n void document.exitFullscreen().catch(() => {});\n } else {\n void element.requestFullscreen().catch(() => {});\n }\n }, []);\n\n const handlePointerDown = (event: React.PointerEvent<HTMLDivElement>) => {\n if (!showControls || event.pointerType !== \"mouse\" || event.button !== 0) {\n return;\n }\n event.currentTarget.setPointerCapture(event.pointerId);\n dragStart.current = {\n x: event.clientX,\n y: event.clientY,\n ox: offset.x,\n oy: offset.y,\n };\n setDragging(true);\n };\n\n const handlePointerMove = (event: React.PointerEvent<HTMLDivElement>) => {\n const start = dragStart.current;\n if (!start) return;\n setOffset({\n x: start.ox + (event.clientX - start.x),\n y: start.oy + (event.clientY - start.y),\n });\n };\n\n const endDrag = (event: React.PointerEvent<HTMLDivElement>) => {\n if (!dragStart.current) return;\n dragStart.current = null;\n setDragging(false);\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n };\n\n const isReset = scale === 1 && offset.x === 0 && offset.y === 0;\n\n return (\n <Figure ref={figureRef} {...props}>\n <Viewport\n ref={viewportRef}\n $draggable={showControls}\n $dragging={dragging}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={endDrag}\n onPointerCancel={endDrag}\n >\n <Stage\n $scale={scale}\n $x={offset.x}\n $y={offset.y}\n $dragging={dragging}\n style={\n width && !isFullscreen ? { maxWidth: `${width}px` } : undefined\n }\n dangerouslySetInnerHTML={{ __html: svg }}\n />\n </Viewport>\n\n {showControls && (\n <Controls $placement={placement}>\n <ControlButton\n type=\"button\"\n aria-label=\"Zoom out\"\n onClick={() => zoom(-SCALE_STEP)}\n disabled={scale <= MIN_SCALE}\n >\n <Icon name=\"zoom-out\" size={14} />\n </ControlButton>\n <ControlButton\n type=\"button\"\n aria-label=\"Pan up\"\n onClick={() => pan(0, -PAN_STEP)}\n >\n <Icon name=\"chevron-up\" size={14} />\n </ControlButton>\n <ControlButton\n type=\"button\"\n aria-label=\"Zoom in\"\n onClick={() => zoom(SCALE_STEP)}\n disabled={scale >= MAX_SCALE}\n >\n <Icon name=\"zoom-in\" size={14} />\n </ControlButton>\n\n <ControlButton\n type=\"button\"\n aria-label=\"Pan left\"\n onClick={() => pan(-PAN_STEP, 0)}\n >\n <Icon name=\"chevron-left\" size={14} />\n </ControlButton>\n <ControlButton\n type=\"button\"\n aria-label=\"Reset view\"\n onClick={reset}\n disabled={isReset}\n >\n <Icon name=\"rotate-ccw\" size={14} />\n </ControlButton>\n <ControlButton\n type=\"button\"\n aria-label=\"Pan right\"\n onClick={() => pan(PAN_STEP, 0)}\n >\n <Icon name=\"chevron-right\" size={14} />\n </ControlButton>\n\n {canFullscreen ? (\n <ControlButton\n type=\"button\"\n aria-label={isFullscreen ? \"Exit full screen\" : \"Full screen\"}\n onClick={toggleFullscreen}\n >\n <Icon name={isFullscreen ? \"minimize\" : \"maximize\"} size={14} />\n </ControlButton>\n ) : (\n <span />\n )}\n <ControlButton\n type=\"button\"\n aria-label=\"Pan down\"\n onClick={() => pan(0, PAN_STEP)}\n >\n <Icon name=\"chevron-down\" size={14} />\n </ControlButton>\n <span />\n </Controls>\n )}\n </Figure>\n );\n}\n\nexport { MermaidView };\n";
@@ -1,5 +1,11 @@
1
1
  export const mermaidViewTemplate = `"use client";
2
- import { useCallback, useEffect, useRef, useState } from "react";
2
+ import {
3
+ useCallback,
4
+ useEffect,
5
+ useRef,
6
+ useState,
7
+ useSyncExternalStore,
8
+ } from "react";
3
9
  import styled, { css } from "styled-components";
4
10
  import { interactiveStyles, resetButton } from "cherry-styled-components";
5
11
  import { Theme } from "@/app/theme";
@@ -11,6 +17,15 @@ const SCALE_STEP = 0.25;
11
17
  const PAN_STEP = 48;
12
18
  const AUTO_ACTIONS_MIN_HEIGHT = 120;
13
19
 
20
+ // Whether the Fullscreen API is available. Read via useSyncExternalStore so it
21
+ // resolves during render (SSR-safe: false on the server) instead of via a
22
+ // synchronous setState inside an effect. The capability never changes, so the
23
+ // subscribe callback is a stable no-op.
24
+ const subscribeFullscreenCapability = () => () => {};
25
+ const getFullscreenCapability = () =>
26
+ typeof document !== "undefined" && Boolean(document.fullscreenEnabled);
27
+ const getFullscreenCapabilityServer = () => false;
28
+
14
29
  export type MermaidPlacement =
15
30
  "top-left" | "top-right" | "bottom-left" | "bottom-right";
16
31
 
@@ -143,7 +158,11 @@ function MermaidView({
143
158
  const [autoShow, setAutoShow] = useState(false);
144
159
  const [dragging, setDragging] = useState(false);
145
160
  const [isFullscreen, setIsFullscreen] = useState(false);
146
- const [canFullscreen, setCanFullscreen] = useState(false);
161
+ const canFullscreen = useSyncExternalStore(
162
+ subscribeFullscreenCapability,
163
+ getFullscreenCapability,
164
+ getFullscreenCapabilityServer,
165
+ );
147
166
  const viewportRef = useRef<HTMLDivElement>(null);
148
167
  const figureRef = useRef<HTMLElement>(null);
149
168
  const dragStart = useRef<{
@@ -170,7 +189,6 @@ function MermaidView({
170
189
  }, [actions]);
171
190
 
172
191
  useEffect(() => {
173
- setCanFullscreen(Boolean(document.fullscreenEnabled));
174
192
  const onChange = () =>
175
193
  setIsFullscreen(document.fullscreenElement === figureRef.current);
176
194
  document.addEventListener("fullscreenchange", onChange);
@@ -1 +1 @@
1
- export declare const sharedStyledTemplate = "\"use client\";\nimport { styledSmall, styledText } from \"cherry-styled-components\";\nimport { mq, Theme } from \"@/app/theme\";\nimport styled, { css } from \"styled-components\";\n\n/** Slim, theme-aware scrollbar for internal scroll areas (code blocks,\n modals, tables) so the chunky native bar doesn't stand out, especially\n in dark mode. */\nexport const thinScrollbar = css<{ theme: Theme }>`\n scrollbar-width: thin;\n scrollbar-color: ${({ theme }) => theme.colors.grayLight} transparent;\n`;\n\nexport const interactiveStyles = css<{ theme: Theme }>`\n transition: all 0.3s ease;\n border: solid 1px transparent;\n box-shadow: 0 0 0 0px ${({ theme }) => theme.colors.primary};\n\n &:hover {\n border-color: ${({ theme }) => theme.colors.primary};\n }\n\n &:focus {\n border-color: ${({ theme }) => theme.colors.primary};\n box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};\n }\n\n &:active {\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\nexport const styledAnchor = css<{ theme: Theme }>`\n & a:not([class]):not(:has(img)) {\n color: inherit;\n transition: all 0.3s ease;\n text-decoration: none;\n box-shadow: 0 2px 0 0 ${({ theme }) => theme.colors.primary};\n\n &:hover {\n color: ${({ theme }) => theme.colors.accent};\n box-shadow: 0 1px 0 0 ${({ theme }) => theme.colors.primary};\n }\n\n /* Same primaryLight focus glow as the global a:focus-visible ring, but\n layered over the link's own box-shadow underline (same property) so the\n underline is preserved. */\n &:focus-visible {\n outline: none;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n box-shadow:\n 0 2px 0 0 ${({ theme }) => theme.colors.primary},\n 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n }\n`;\n\nexport const stylesLists = css<{ theme: Theme }>`\n & ul,\n & ol {\n & li {\n & > .code-wrapper {\n margin: 10px 0;\n }\n\n & p {\n display: inline;\n }\n }\n }\n\n & ul {\n list-style: none;\n padding: 0;\n margin: 0;\n\n & li {\n text-indent: 0;\n display: block;\n position: relative;\n padding: 0 0 0 24px;\n margin: 0;\n ${({ theme }) => styledText(theme)};\n min-height: 23px;\n\n ${mq(\"lg\")} {\n min-height: 27px;\n }\n\n &::before {\n content: \"\";\n display: block;\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: ${({ theme }) => theme.colors.primary};\n position: absolute;\n top: 8px;\n left: 9px;\n\n ${mq(\"lg\")} {\n top: 10px;\n }\n }\n }\n }\n\n & ol {\n counter-reset: item;\n padding: 0;\n margin: 0;\n\n & ul {\n padding-left: 15px;\n }\n\n & > li {\n counter-increment: item;\n padding: 0 0 0 24px;\n margin: 0;\n ${({ theme }) => styledText(theme)};\n\n &::before {\n content: counter(item) \".\";\n display: inline-block;\n min-width: 20px;\n margin-left: -24px;\n margin-right: 4px;\n text-align: right;\n font-weight: 700;\n color: ${({ theme }) => theme.colors.primary};\n }\n }\n }\n`;\n\nexport const styledTable = css<{ theme: Theme }>`\n & .table-wrapper {\n overflow-x: auto;\n width: 100%;\n ${thinScrollbar};\n }\n\n & table {\n margin: 0;\n padding: 0;\n border-collapse: collapse;\n width: 100%;\n text-align: left;\n\n & tr {\n margin: 0;\n padding: 0;\n }\n\n & th {\n border-bottom: solid 1px ${({ theme }) => theme.colors.grayLight};\n padding: 10px 10px 10px 0;\n ${({ theme }) => styledSmall(theme)};\n font-weight: 600;\n color: ${({ theme }) => theme.colors.dark};\n }\n\n & td {\n border-bottom: solid 1px ${({ theme }) => theme.colors.grayLight};\n padding: 10px 10px 10px 0;\n color: ${({ theme }) => theme.colors.grayDark};\n ${({ theme }) => styledSmall(theme)};\n }\n }\n`;\n\nexport const StyledSmallButton = styled.button<{ theme: Theme }>`\n ${interactiveStyles};\n background: ${({ theme }) => theme.colors.light};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n color: ${({ theme }) => theme.colors.accent};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n padding: 6px 8px;\n font-size: 12px;\n font-family: inherit;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s ease;\n display: flex;\n align-items: center;\n gap: 6px;\n margin-right: -6px;\n\n & svg.lucide {\n color: inherit;\n }\n`;\n";
1
+ export declare const sharedStyledTemplate = "\"use client\";\nimport { styledSmall, styledText } from \"cherry-styled-components\";\nimport { mq, Theme } from \"@/app/theme\";\nimport styled, { css } from \"styled-components\";\n\n/** Slim, theme-aware scrollbar for internal scroll areas (code blocks,\n modals, tables) so the chunky native bar doesn't stand out, especially\n in dark mode. */\nexport const thinScrollbar = css<{ theme: Theme }>`\n scrollbar-width: thin;\n scrollbar-color: ${({ theme }) => theme.colors.grayLight} transparent;\n`;\n\nexport const interactiveStyles = css<{ theme: Theme }>`\n transition: all 0.3s ease;\n border: solid 1px transparent;\n box-shadow: 0 0 0 0px ${({ theme }) => theme.colors.primary};\n\n &:hover {\n border-color: ${({ theme }) => theme.colors.primary};\n }\n\n &:focus {\n border-color: ${({ theme }) => theme.colors.primary};\n box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};\n }\n\n &:active {\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\nexport const styledAnchor = css<{ theme: Theme }>`\n & a:not([class]):not(:has(img)) {\n color: inherit;\n transition: all 0.3s ease;\n text-decoration: none;\n box-shadow: 0 2px 0 0 ${({ theme }) => theme.colors.primary};\n\n &:hover {\n color: ${({ theme }) => theme.colors.accent};\n box-shadow: 0 1px 0 0 ${({ theme }) => theme.colors.primary};\n }\n\n /* Same primaryLight focus glow as the global a:focus-visible ring, but\n layered over the link's own box-shadow underline (same property) so the\n underline is preserved. */\n &:focus-visible {\n outline: none;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n box-shadow:\n 0 2px 0 0 ${({ theme }) => theme.colors.primary},\n 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n }\n`;\n\nexport const stylesLists = css<{ theme: Theme }>`\n & ul,\n & ol {\n & li {\n & > .code-wrapper {\n margin: 10px 0;\n }\n\n & p {\n display: inline;\n }\n }\n }\n\n & ul {\n list-style: none;\n padding: 0;\n margin: 0;\n\n & li {\n text-indent: 0;\n display: block;\n position: relative;\n padding: 0 0 0 24px;\n margin: 0;\n ${({ theme }) => styledText(theme)};\n min-height: 23px;\n\n ${mq(\"lg\")} {\n min-height: 27px;\n }\n\n &::before {\n content: \"\";\n display: block;\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: ${({ theme }) => theme.colors.primary};\n position: absolute;\n top: 8px;\n left: 9px;\n\n ${mq(\"lg\")} {\n top: 10px;\n }\n }\n }\n }\n\n & ol {\n counter-reset: item;\n padding: 0;\n margin: 0;\n\n & > li {\n counter-increment: item;\n padding: 0 0 0 24px;\n margin: 0;\n ${({ theme }) => styledText(theme)};\n\n &::before {\n content: counter(item) \".\";\n display: inline-block;\n min-width: 20px;\n margin-left: -24px;\n margin-right: 4px;\n text-align: right;\n font-weight: 700;\n color: ${({ theme }) => theme.colors.primary};\n }\n }\n }\n`;\n\nexport const styledTable = css<{ theme: Theme }>`\n & .table-wrapper {\n overflow-x: auto;\n width: 100%;\n ${thinScrollbar};\n }\n\n & table {\n margin: 0;\n padding: 0;\n border-collapse: collapse;\n width: 100%;\n text-align: left;\n\n & tr {\n margin: 0;\n padding: 0;\n }\n\n & th {\n border-bottom: solid 1px ${({ theme }) => theme.colors.grayLight};\n padding: 10px 10px 10px 0;\n ${({ theme }) => styledSmall(theme)};\n font-weight: 600;\n color: ${({ theme }) => theme.colors.dark};\n }\n\n & td {\n border-bottom: solid 1px ${({ theme }) => theme.colors.grayLight};\n padding: 10px 10px 10px 0;\n color: ${({ theme }) => theme.colors.grayDark};\n ${({ theme }) => styledSmall(theme)};\n }\n }\n`;\n\nexport const StyledSmallButton = styled.button<{ theme: Theme }>`\n ${interactiveStyles};\n background: ${({ theme }) => theme.colors.light};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n color: ${({ theme }) => theme.colors.accent};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n padding: 6px 8px;\n font-size: 12px;\n font-family: inherit;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s ease;\n display: flex;\n align-items: center;\n gap: 6px;\n margin-right: -6px;\n\n & svg.lucide {\n color: inherit;\n }\n`;\n";
@@ -110,10 +110,6 @@ export const stylesLists = css<{ theme: Theme }>\`
110
110
  padding: 0;
111
111
  margin: 0;
112
112
 
113
- & ul {
114
- padding-left: 15px;
115
- }
116
-
117
113
  & > li {
118
114
  counter-increment: item;
119
115
  padding: 0 0 0 24px;
@@ -1 +1 @@
1
- export declare const stepsTemplate = "\"use client\";\nimport React from \"react\";\nimport styled, { useTheme } from \"styled-components\";\nimport { styledText } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon, IconProps } from \"@/components/layout/Icon\";\n\nconst StyledStepsContainer = styled.div<{ theme: Theme }>`\n position: relative;\n width: 100%;\n`;\n\nconst StyledStep = styled.div<{ theme: Theme }>`\n background: ${({ theme }) => theme.colors.light};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 0 0 20px 52px;\n margin: 0;\n position: relative;\n ${({ theme }) => styledText(theme)}\n color: ${({ theme }) => theme.colors.grayDark};\n\n &::after {\n content: \"\";\n position: absolute;\n left: 16px;\n top: 0;\n width: 1px;\n height: 100%;\n background: ${({ theme }) => theme.colors.primary};\n background: linear-gradient(\n 180deg,\n ${({ theme }) => theme.colors.primary},\n transparent\n );\n border-radius: 4px;\n }\n`;\n\nconst StepNumber = styled.div<{ theme: Theme }>`\n width: 32px;\n height: 32px;\n border-radius: 50%;\n background: ${({ theme }) => theme.colors.primary};\n color: ${({ theme }) => theme.colors.light};\n display: flex;\n align-items: center;\n justify-content: center;\n font-weight: 700;\n margin-bottom: 12px;\n ${({ theme }) => styledText(theme)};\n position: absolute;\n left: 0;\n top: 0;\n z-index: 1;\n`;\n\nconst StyledStepTitle = styled.div<{ theme: Theme }>`\n margin: 0 0 10px 0;\n padding: 2px 0 0 0;\n color: ${({ theme }) => theme.colors.dark};\n ${({ theme }) => styledText(theme)};\n font-weight: 700;\n display: flex;\n align-items: center;\n gap: 10px;\n`;\n\nconst StepContent = styled.div<{ theme: Theme }>`\n color: ${({ theme }) => theme.colors.grayDark};\n ${({ theme }) => styledText(theme)};\n\n & > .code-wrapper {\n margin: 10px 0;\n }\n`;\n\ninterface StepProps extends React.HTMLAttributes<HTMLDivElement> {\n title?: string;\n children: React.ReactNode;\n icon?: IconProps;\n}\n\nfunction Step(_props: StepProps) {\n return null;\n}\n\ninterface StepsProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n}\n\nfunction Steps({ children }: StepsProps) {\n const theme = useTheme() as Theme;\n\n const steps = React.Children.toArray(children).filter(\n (child): child is React.ReactElement<StepProps> =>\n React.isValidElement(child),\n );\n\n return (\n <StyledStepsContainer theme={theme}>\n {steps.map((step, index) => {\n const { title, children: stepContent, icon } = step.props;\n\n return (\n <StyledStep key={index} theme={theme}>\n <StepNumber theme={theme}>{index + 1}</StepNumber>\n {(title || icon) && (\n <StyledStepTitle theme={theme}>\n {icon && <Icon name={icon} color={theme.colors.primary} />}\n {title}\n </StyledStepTitle>\n )}\n <StepContent theme={theme}>{stepContent}</StepContent>\n </StyledStep>\n );\n })}\n </StyledStepsContainer>\n );\n}\n\nexport { Steps, Step };\n";
1
+ export declare const stepsTemplate = "\"use client\";\nimport React from \"react\";\nimport styled, { useTheme } from \"styled-components\";\nimport { styledText } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon, IconProps } from \"@/components/layout/Icon\";\n\nconst StyledStepsContainer = styled.div<{ theme: Theme }>`\n position: relative;\n width: 100%;\n`;\n\nconst StyledStep = styled.div<{ theme: Theme }>`\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 0 0 20px 52px;\n margin: 0;\n position: relative;\n ${({ theme }) => styledText(theme)}\n color: ${({ theme }) => theme.colors.grayDark};\n\n &::after {\n content: \"\";\n position: absolute;\n left: 16px;\n top: 0;\n width: 1px;\n height: 100%;\n background: ${({ theme }) => theme.colors.primary};\n background: linear-gradient(\n 180deg,\n ${({ theme }) => theme.colors.primary},\n transparent\n );\n border-radius: 4px;\n }\n`;\n\nconst StepNumber = styled.div<{ theme: Theme }>`\n width: 32px;\n height: 32px;\n border-radius: 50%;\n background: ${({ theme }) => theme.colors.primary};\n color: ${({ theme }) => theme.colors.light};\n display: flex;\n align-items: center;\n justify-content: center;\n font-weight: 700;\n margin-bottom: 12px;\n ${({ theme }) => styledText(theme)};\n position: absolute;\n left: 0;\n top: 0;\n z-index: 1;\n`;\n\nconst StyledStepTitle = styled.div<{ theme: Theme }>`\n margin: 0 0 10px 0;\n padding: 2px 0 0 0;\n color: ${({ theme }) => theme.colors.dark};\n ${({ theme }) => styledText(theme)};\n font-weight: 700;\n display: flex;\n align-items: center;\n gap: 10px;\n`;\n\nconst StepContent = styled.div<{ theme: Theme }>`\n color: ${({ theme }) => theme.colors.grayDark};\n ${({ theme }) => styledText(theme)};\n\n & > .code-wrapper {\n margin: 10px 0;\n }\n`;\n\ninterface StepProps extends React.HTMLAttributes<HTMLDivElement> {\n title?: string;\n children: React.ReactNode;\n icon?: IconProps;\n}\n\nfunction Step(_props: StepProps) {\n return null;\n}\n\ninterface StepsProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n}\n\nfunction Steps({ children }: StepsProps) {\n const theme = useTheme() as Theme;\n\n const steps = React.Children.toArray(children).filter(\n (child): child is React.ReactElement<StepProps> =>\n React.isValidElement(child),\n );\n\n return (\n <StyledStepsContainer theme={theme}>\n {steps.map((step, index) => {\n const { title, children: stepContent, icon } = step.props;\n\n return (\n <StyledStep key={index} theme={theme}>\n <StepNumber theme={theme}>{index + 1}</StepNumber>\n {(title || icon) && (\n <StyledStepTitle theme={theme}>\n {icon && <Icon name={icon} color={theme.colors.primary} />}\n {title}\n </StyledStepTitle>\n )}\n <StepContent theme={theme}>{stepContent}</StepContent>\n </StyledStep>\n );\n })}\n </StyledStepsContainer>\n );\n}\n\nexport { Steps, Step };\n";
@@ -11,7 +11,6 @@ const StyledStepsContainer = styled.div<{ theme: Theme }>\`
11
11
  \`;
12
12
 
13
13
  const StyledStep = styled.div<{ theme: Theme }>\`
14
- background: \${({ theme }) => theme.colors.light};
15
14
  border-radius: \${({ theme }) => theme.spacing.radius.lg};
16
15
  padding: 0 0 20px 52px;
17
16
  margin: 0;
@@ -1 +1 @@
1
- export declare const updateTemplate = "\"use client\";\nimport styled from \"styled-components\";\nimport { styledSmall } from \"cherry-styled-components\";\nimport { mq, Theme } from \"@/app/theme\";\nimport { slugify } from \"@/components/layout/Slug\";\n\nconst StyledUpdate = styled.div<{ theme: Theme; $columns?: number }>`\n position: relative;\n display: flex;\n gap: 20px;\n flex-direction: column;\n\n ${mq(\"lg\")} {\n margin: 20px 0;\n flex-direction: row;\n }\n`;\n\nconst StyledUpdateLabel = styled.a<{ theme: Theme }>`\n display: inline-block;\n width: fit-content;\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 20%, transparent)`};\n color: ${({ theme }) => theme.colors.primary};\n padding: 2px 4px;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n font-weight: 600;\n text-decoration: none;\n ${({ theme }) => styledSmall(theme)};\n\n &:hover {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 35%, transparent)`};\n }\n`;\n\nconst StyledUpdateDescription = styled.div<{ theme: Theme }>`\n ${({ theme }) => styledSmall(theme)};\n color: ${({ theme }) => theme.colors.gray};\n`;\n\nconst StyledUpdateSidebar = styled.div`\n display: flex;\n flex-direction: column;\n gap: 10px;\n\n ${mq(\"lg\")} {\n position: sticky;\n top: 80px;\n align-self: flex-start;\n min-width: 160px;\n }\n`;\n\nconst StyledUpdateChildren = styled.div`\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 20px;\n`;\n\ninterface UpdateProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n label: string;\n description?: string;\n}\n\nfunction Update({ children, label = \"Label\", description, id }: UpdateProps) {\n // MDXComponents injects a de-duplicated id from the shared slugger so the\n // index sidebar anchor resolves here; fall back to a plain slug when used\n // outside the MDX pipeline. The label doubles as an anchor so readers can\n // right-click to copy the deep link (native #anchor jump is offset by the\n // global scroll-padding-top).\n const anchor = id ?? slugify(label);\n return (\n <StyledUpdate id={anchor}>\n <StyledUpdateSidebar>\n <div>\n <StyledUpdateLabel href={`#${anchor}`}>{label}</StyledUpdateLabel>\n </div>\n {description && (\n <StyledUpdateDescription>{description}</StyledUpdateDescription>\n )}\n </StyledUpdateSidebar>\n <StyledUpdateChildren>{children}</StyledUpdateChildren>\n </StyledUpdate>\n );\n}\n\nexport { Update };\n";
1
+ export declare const updateTemplate = "\"use client\";\nimport styled from \"styled-components\";\nimport { styledSmall } from \"cherry-styled-components\";\nimport { mq, Theme } from \"@/app/theme\";\nimport { slugify } from \"@/components/layout/Slug\";\n\nconst StyledUpdate = styled.div<{ theme: Theme; $columns?: number }>`\n position: relative;\n display: flex;\n gap: 20px;\n flex-direction: column;\n\n ${mq(\"lg\")} {\n margin: 20px 0;\n flex-direction: row;\n }\n`;\n\nconst StyledUpdateLabel = styled.a<{ theme: Theme }>`\n display: inline-block;\n width: fit-content;\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 20%, transparent)`};\n color: ${({ theme }) => theme.colors.primary};\n padding: 2px 4px;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n font-weight: 600;\n text-decoration: none;\n ${({ theme }) => styledSmall(theme)};\n\n &:hover {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 35%, transparent)`};\n }\n`;\n\nconst StyledUpdateDescription = styled.div<{ theme: Theme }>`\n ${({ theme }) => styledSmall(theme)};\n color: ${({ theme }) => theme.colors.gray};\n`;\n\nconst StyledUpdateSidebar = styled.div`\n display: flex;\n flex-direction: column;\n gap: 10px;\n\n ${mq(\"lg\")} {\n position: sticky;\n top: 80px;\n align-self: flex-start;\n min-width: 160px;\n }\n`;\n\nconst StyledUpdateChildren = styled.div<{ theme: Theme }>`\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 20px;\n color: ${({ theme }) => theme.colors.gray};\n`;\n\ninterface UpdateProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n label: string;\n description?: string;\n}\n\nfunction Update({ children, label = \"Label\", description, id }: UpdateProps) {\n // MDXComponents injects a de-duplicated id from the shared slugger so the\n // index sidebar anchor resolves here; fall back to a plain slug when used\n // outside the MDX pipeline. The label doubles as an anchor so readers can\n // right-click to copy the deep link (native #anchor jump is offset by the\n // global scroll-padding-top).\n const anchor = id ?? slugify(label);\n return (\n <StyledUpdate id={anchor}>\n <StyledUpdateSidebar>\n <div>\n <StyledUpdateLabel href={`#${anchor}`}>{label}</StyledUpdateLabel>\n </div>\n {description && (\n <StyledUpdateDescription>{description}</StyledUpdateDescription>\n )}\n </StyledUpdateSidebar>\n <StyledUpdateChildren>{children}</StyledUpdateChildren>\n </StyledUpdate>\n );\n}\n\nexport { Update };\n";