doccupine 0.0.133 → 0.0.135
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.
- package/README.md +50 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.js +478 -45
- package/dist/lib/config-manager.d.ts +8 -1
- package/dist/lib/config-manager.js +98 -4
- package/dist/lib/metadata.d.ts +5 -0
- package/dist/lib/metadata.js +15 -4
- package/dist/lib/openapi-types.d.ts +120 -0
- package/dist/lib/openapi-types.js +14 -0
- package/dist/lib/openapi.d.ts +52 -0
- package/dist/lib/openapi.js +603 -0
- package/dist/lib/rss.d.ts +24 -0
- package/dist/lib/rss.js +137 -0
- package/dist/lib/structures.js +50 -4
- package/dist/lib/types.d.ts +22 -0
- package/dist/lib/utils.d.ts +8 -0
- package/dist/lib/utils.js +14 -0
- package/dist/templates/app/api/playground/route.d.ts +1 -0
- package/dist/templates/app/api/playground/route.js +199 -0
- package/dist/templates/app/rssRoute.d.ts +11 -0
- package/dist/templates/app/rssRoute.js +30 -0
- package/dist/templates/components/Docs.d.ts +1 -1
- package/dist/templates/components/Docs.js +15 -3
- package/dist/templates/components/MDXComponents.d.ts +1 -1
- package/dist/templates/components/MDXComponents.js +29 -0
- package/dist/templates/components/SideBar.d.ts +1 -1
- package/dist/templates/components/SideBar.js +13 -0
- package/dist/templates/components/layout/Accordion.d.ts +1 -1
- package/dist/templates/components/layout/Accordion.js +3 -2
- package/dist/templates/components/layout/ActionBar.d.ts +1 -1
- package/dist/templates/components/layout/ActionBar.js +65 -27
- package/dist/templates/components/layout/ApiPlayground.d.ts +1 -0
- package/dist/templates/components/layout/ApiPlayground.js +1075 -0
- package/dist/templates/components/layout/ApiPlaygroundDemo.d.ts +1 -0
- package/dist/templates/components/layout/ApiPlaygroundDemo.js +81 -0
- package/dist/templates/components/layout/Badge.d.ts +1 -0
- package/dist/templates/components/layout/Badge.js +455 -0
- package/dist/templates/components/layout/Code.d.ts +1 -1
- package/dist/templates/components/layout/Code.js +10 -22
- package/dist/templates/components/layout/CopyButton.d.ts +1 -0
- package/dist/templates/components/layout/CopyButton.js +68 -0
- package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
- package/dist/templates/components/layout/DocsComponents.js +14 -0
- package/dist/templates/components/layout/Mermaid.d.ts +1 -1
- package/dist/templates/components/layout/Mermaid.js +21 -3
- package/dist/templates/components/layout/Prompt.d.ts +1 -0
- package/dist/templates/components/layout/Prompt.js +149 -0
- package/dist/templates/components/layout/SharedStyles.d.ts +1 -1
- package/dist/templates/components/layout/SharedStyles.js +0 -4
- package/dist/templates/components/layout/Steps.d.ts +1 -1
- package/dist/templates/components/layout/Steps.js +0 -1
- package/dist/templates/components/layout/Tooltip.d.ts +1 -0
- package/dist/templates/components/layout/Tooltip.js +222 -0
- package/dist/templates/components/layout/Tree.d.ts +1 -0
- package/dist/templates/components/layout/Tree.js +322 -0
- package/dist/templates/components/layout/TreeData.d.ts +1 -0
- package/dist/templates/components/layout/TreeData.js +131 -0
- package/dist/templates/components/layout/Update.d.ts +1 -1
- package/dist/templates/components/layout/Update.js +5 -1
- package/dist/templates/lib/rss.d.ts +1 -0
- package/dist/templates/lib/rss.js +78 -0
- package/dist/templates/mdx/accordion.mdx.d.ts +1 -1
- package/dist/templates/mdx/accordion.mdx.js +19 -1
- package/dist/templates/mdx/ai-assistant.mdx.d.ts +1 -1
- package/dist/templates/mdx/ai-assistant.mdx.js +3 -2
- package/dist/templates/mdx/analytics.mdx.d.ts +1 -1
- package/dist/templates/mdx/analytics.mdx.js +2 -2
- package/dist/templates/mdx/api-playground.mdx.d.ts +1 -0
- package/dist/templates/mdx/api-playground.mdx.js +158 -0
- package/dist/templates/mdx/authentication.mdx.d.ts +1 -1
- package/dist/templates/mdx/authentication.mdx.js +3 -3
- package/dist/templates/mdx/badges.mdx.d.ts +1 -0
- package/dist/templates/mdx/badges.mdx.js +237 -0
- package/dist/templates/mdx/buttons.mdx.d.ts +1 -1
- package/dist/templates/mdx/buttons.mdx.js +1 -1
- package/dist/templates/mdx/callouts.mdx.d.ts +1 -1
- package/dist/templates/mdx/callouts.mdx.js +1 -1
- package/dist/templates/mdx/cards.mdx.d.ts +1 -1
- package/dist/templates/mdx/cards.mdx.js +1 -1
- package/dist/templates/mdx/color-swatches.mdx.d.ts +1 -1
- package/dist/templates/mdx/color-swatches.mdx.js +1 -1
- package/dist/templates/mdx/columns.mdx.d.ts +1 -1
- package/dist/templates/mdx/columns.mdx.js +1 -1
- package/dist/templates/mdx/commands.mdx.d.ts +1 -1
- package/dist/templates/mdx/commands.mdx.js +3 -2
- package/dist/templates/mdx/components.mdx.d.ts +1 -1
- package/dist/templates/mdx/components.mdx.js +25 -10
- package/dist/templates/mdx/deployment-and-hosting.mdx.d.ts +1 -1
- package/dist/templates/mdx/deployment-and-hosting.mdx.js +4 -3
- package/dist/templates/mdx/fields.mdx.d.ts +1 -1
- package/dist/templates/mdx/fields.mdx.js +1 -1
- package/dist/templates/mdx/fonts.mdx.d.ts +1 -1
- package/dist/templates/mdx/fonts.mdx.js +2 -2
- package/dist/templates/mdx/footer-links.mdx.d.ts +1 -1
- package/dist/templates/mdx/footer-links.mdx.js +1 -1
- package/dist/templates/mdx/frames.mdx.d.ts +1 -1
- package/dist/templates/mdx/frames.mdx.js +1 -1
- package/dist/templates/mdx/globals.mdx.d.ts +1 -1
- package/dist/templates/mdx/globals.mdx.js +1 -1
- package/dist/templates/mdx/icons.mdx.d.ts +1 -1
- package/dist/templates/mdx/icons.mdx.js +1 -1
- package/dist/templates/mdx/image-and-embeds.mdx.d.ts +1 -1
- package/dist/templates/mdx/image-and-embeds.mdx.js +1 -1
- package/dist/templates/mdx/images-and-embeds.mdx.d.ts +1 -0
- package/dist/templates/mdx/images-and-embeds.mdx.js +118 -0
- package/dist/templates/mdx/media-and-assets.mdx.d.ts +1 -1
- package/dist/templates/mdx/media-and-assets.mdx.js +2 -2
- package/dist/templates/mdx/mermaid.mdx.d.ts +1 -1
- package/dist/templates/mdx/mermaid.mdx.js +1 -1
- package/dist/templates/mdx/model-context-protocol.mdx.d.ts +1 -1
- package/dist/templates/mdx/model-context-protocol.mdx.js +2 -2
- package/dist/templates/mdx/navigation.mdx.d.ts +1 -1
- package/dist/templates/mdx/navigation.mdx.js +27 -12
- package/dist/templates/mdx/platform/ai-assistant.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/ai-assistant.mdx.js +4 -3
- package/dist/templates/mdx/platform/analytics.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/analytics.mdx.js +2 -2
- package/dist/templates/mdx/platform/api-playground.mdx.d.ts +1 -0
- package/dist/templates/mdx/platform/api-playground.mdx.js +62 -0
- package/dist/templates/mdx/platform/billing.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/billing.mdx.js +1 -1
- package/dist/templates/mdx/platform/build-and-deploy.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/build-and-deploy.mdx.js +1 -1
- package/dist/templates/mdx/platform/creating-a-project.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/creating-a-project.mdx.js +12 -2
- package/dist/templates/mdx/platform/custom-domains.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/custom-domains.mdx.js +1 -1
- package/dist/templates/mdx/platform/fonts-settings.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/fonts-settings.mdx.js +1 -1
- package/dist/templates/mdx/platform/footer-links.mdx.d.ts +1 -0
- package/dist/templates/mdx/platform/{external-links.mdx.js → footer-links.mdx.js} +5 -5
- package/dist/templates/mdx/platform/import-from-github.mdx.d.ts +1 -0
- package/dist/templates/mdx/platform/import-from-github.mdx.js +91 -0
- package/dist/templates/mdx/platform/mcp.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/mcp.mdx.js +3 -3
- package/dist/templates/mdx/platform/project-settings.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/project-settings.mdx.js +1 -1
- package/dist/templates/mdx/platform/self-updating-docs.mdx.d.ts +1 -0
- package/dist/templates/mdx/platform/self-updating-docs.mdx.js +113 -0
- package/dist/templates/mdx/platform/team-members.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/team-members.mdx.js +1 -1
- package/dist/templates/mdx/prompt.mdx.d.ts +1 -0
- package/dist/templates/mdx/prompt.mdx.js +69 -0
- package/dist/templates/mdx/sections.mdx.d.ts +1 -1
- package/dist/templates/mdx/sections.mdx.js +1 -1
- package/dist/templates/mdx/steps.mdx.d.ts +1 -1
- package/dist/templates/mdx/steps.mdx.js +1 -1
- package/dist/templates/mdx/tabs.mdx.d.ts +1 -1
- package/dist/templates/mdx/tabs.mdx.js +1 -1
- package/dist/templates/mdx/theme.mdx.d.ts +1 -1
- package/dist/templates/mdx/theme.mdx.js +1 -1
- package/dist/templates/mdx/tooltips.mdx.d.ts +1 -0
- package/dist/templates/mdx/tooltips.mdx.js +57 -0
- package/dist/templates/mdx/tree.mdx.d.ts +1 -0
- package/dist/templates/mdx/tree.mdx.js +158 -0
- package/dist/templates/mdx/update.mdx.d.ts +1 -1
- package/dist/templates/mdx/update.mdx.js +42 -2
- package/dist/templates/mdx/what-is-doccupine.mdx.d.ts +1 -1
- package/dist/templates/mdx/what-is-doccupine.mdx.js +1 -1
- package/dist/templates/package.js +7 -7
- package/dist/templates/services/openapi/playgroundAllowlistStub.d.ts +1 -0
- package/dist/templates/services/openapi/playgroundAllowlistStub.js +4 -0
- package/dist/templates/types/openapi.d.ts +1 -0
- package/dist/templates/types/openapi.js +93 -0
- package/dist/templates/utils/apiSnippets.d.ts +1 -0
- package/dist/templates/utils/apiSnippets.js +94 -0
- package/dist/templates/utils/orderNavItems.d.ts +1 -1
- package/dist/templates/utils/orderNavItems.js +3 -0
- package/dist/templates/utils/playgroundAllowlist.d.ts +1 -0
- package/dist/templates/utils/playgroundAllowlist.js +70 -0
- package/dist/templates/utils/ssrfGuard.d.ts +1 -0
- package/dist/templates/utils/ssrfGuard.js +217 -0
- package/package.json +4 -3
- package/dist/templates/mdx/platform/external-links.mdx.d.ts +0 -1
|
@@ -139,20 +139,14 @@ const TabList = styled.div<{ theme: Theme }>\`
|
|
|
139
139
|
min-width: 0;
|
|
140
140
|
overflow-x: auto;
|
|
141
141
|
\${thinScrollbar};
|
|
142
|
-
|
|
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
|
|
184
|
-
|
|
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
|
-
&:
|
|
188
|
-
|
|
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 { Badge } from \"@/components/layout/Badge\";\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).\n// The look is Badge's mono variation (tinted, solid when active); only\n// sidebar metrics are adjusted here.\nexport const StyledSidebarMethodTag = styled(Badge)`\n flex-shrink: 0;\n font-size: 9px;\n letter-spacing: 0.02em;\n padding: 1px 4px;\n border: none;\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";
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
styledTable,
|
|
16
16
|
stylesLists,
|
|
17
17
|
} from "@/components/layout/SharedStyled";
|
|
18
|
+
import { Badge } from "@/components/layout/Badge";
|
|
18
19
|
import { ChatContext } from "@/components/Chat";
|
|
19
20
|
|
|
20
21
|
const SectionBarContext = createContext(false);
|
|
@@ -340,6 +341,19 @@ export const StyledSidebarListItemLink = styled(Link)<Props>\`
|
|
|
340
341
|
\${sidebarRowStyles};
|
|
341
342
|
\`;
|
|
342
343
|
|
|
344
|
+
// Compact HTTP-method label shown before a generated API endpoint link, colored
|
|
345
|
+
// by verb so endpoints are scannable in the sidebar. Only rendered when a link
|
|
346
|
+
// carries an \`httpMethod\` (endpoint pages do; hand-written pages do not).
|
|
347
|
+
// The look is Badge's mono variation (tinted, solid when active); only
|
|
348
|
+
// sidebar metrics are adjusted here.
|
|
349
|
+
export const StyledSidebarMethodTag = styled(Badge)\`
|
|
350
|
+
flex-shrink: 0;
|
|
351
|
+
font-size: 9px;
|
|
352
|
+
letter-spacing: 0.02em;
|
|
353
|
+
padding: 1px 4px;
|
|
354
|
+
border: none;
|
|
355
|
+
\`;
|
|
356
|
+
|
|
343
357
|
// Nested navigation group. The header shares the link appearance/hover; a
|
|
344
358
|
// non-navigable group is a single toggle button, while a group that is also a
|
|
345
359
|
// 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 {
|
|
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
|
|
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);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const promptTemplate = "\"use client\";\nimport React from \"react\";\nimport styled from \"styled-components\";\nimport {\n interactiveStyles,\n styledSmall,\n styledText,\n} from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { CopyButton } from \"@/components/layout/CopyButton\";\n\ntype PromptAction = \"copy\" | \"cursor\";\n\nconst CURSOR_DEEPLINK = \"cursor://anysphere.cursor-deeplink/prompt?text=\";\n\n// The prompt body arrives as rendered MDX elements, but the copy and Cursor\n// actions need plain text. Paragraphs and lists become separate lines and\n// list items keep a \"- \" marker so the copied prompt stays readable.\nfunction promptText(node: React.ReactNode): string {\n if (node == null || typeof node === \"boolean\") return \"\";\n if (typeof node === \"string\" || typeof node === \"number\") {\n return String(node);\n }\n if (Array.isArray(node)) return node.map(promptText).join(\"\");\n if (React.isValidElement(node)) {\n const element = node as React.ReactElement<{\n children?: React.ReactNode;\n }>;\n const inner = promptText(element.props.children);\n if (element.type === \"p\") return inner + \"\\n\\n\";\n if (element.type === \"ul\" || element.type === \"ol\") return inner + \"\\n\";\n if (element.type === \"li\") return \"- \" + inner + \"\\n\";\n return inner;\n }\n return \"\";\n}\n\nconst StyledPrompt = styled.div<{ theme: Theme }>`\n background: ${({ theme }) => theme.colors.light};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 20px;\n width: 100%;\n`;\n\nconst StyledPromptHeader = styled.div<{ theme: Theme }>`\n display: flex;\n align-items: center;\n gap: 10px;\n margin: 0 0 15px;\n ${({ theme }) => styledSmall(theme)};\n font-weight: 700;\n color: ${({ theme }) => theme.colors.dark};\n\n & > svg.lucide {\n flex-shrink: 0;\n color: inherit;\n }\n`;\n\nconst StyledPromptDescription = styled.span`\n flex: 1;\n min-width: 0;\n`;\n\nconst StyledPromptActions = styled.span`\n display: flex;\n align-items: center;\n gap: 5px;\n flex-shrink: 0;\n`;\n\n// Matches the CopyButton chrome so the two actions read as one control\n// group; a link rather than a button because it navigates to the Cursor\n// deeplink.\nconst StyledCursorLink = styled.a<{ theme: Theme }>`\n ${interactiveStyles}\n display: flex;\n align-items: center;\n gap: 5px;\n background: ${({ theme }) => theme.colors.light};\n border-color: ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n padding: 4px 8px;\n font-size: 12px;\n line-height: 16px;\n font-weight: 600;\n color: ${({ theme }) => theme.colors.grayDark};\n text-decoration: none;\n\n & svg.lucide {\n margin: 0;\n color: inherit;\n }\n`;\n\nconst StyledPromptBody = styled.div<{ theme: Theme }>`\n ${({ theme }) => styledText(theme)};\n color: ${({ theme }) => theme.colors.grayDark};\n display: flex;\n flex-direction: column;\n gap: 20px;\n`;\n\ninterface PromptProps {\n children: React.ReactNode;\n description: string;\n icon?: string;\n actions?: PromptAction[];\n}\n\nfunction Prompt({\n children,\n description,\n icon,\n actions = [\"copy\"],\n}: PromptProps) {\n const text = promptText(children)\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .trim();\n\n return (\n <StyledPrompt>\n <StyledPromptHeader>\n {icon ? <Icon name={icon} size={16} /> : null}\n <StyledPromptDescription>{description}</StyledPromptDescription>\n <StyledPromptActions>\n {actions.includes(\"copy\") && (\n <CopyButton text={text} label=\"Copy prompt\" size={16} />\n )}\n {actions.includes(\"cursor\") && (\n <StyledCursorLink\n href={CURSOR_DEEPLINK + encodeURIComponent(text)}\n aria-label=\"Open prompt in Cursor\"\n >\n Cursor\n <Icon name=\"arrow-up-right\" size={12} />\n </StyledCursorLink>\n )}\n </StyledPromptActions>\n </StyledPromptHeader>\n <StyledPromptBody>{children}</StyledPromptBody>\n </StyledPrompt>\n );\n}\n\nexport { Prompt };\n";
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
export const promptTemplate = `"use client";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import {
|
|
5
|
+
interactiveStyles,
|
|
6
|
+
styledSmall,
|
|
7
|
+
styledText,
|
|
8
|
+
} from "cherry-styled-components";
|
|
9
|
+
import { Theme } from "@/app/theme";
|
|
10
|
+
import { Icon } from "@/components/layout/Icon";
|
|
11
|
+
import { CopyButton } from "@/components/layout/CopyButton";
|
|
12
|
+
|
|
13
|
+
type PromptAction = "copy" | "cursor";
|
|
14
|
+
|
|
15
|
+
const CURSOR_DEEPLINK = "cursor://anysphere.cursor-deeplink/prompt?text=";
|
|
16
|
+
|
|
17
|
+
// The prompt body arrives as rendered MDX elements, but the copy and Cursor
|
|
18
|
+
// actions need plain text. Paragraphs and lists become separate lines and
|
|
19
|
+
// list items keep a "- " marker so the copied prompt stays readable.
|
|
20
|
+
function promptText(node: React.ReactNode): string {
|
|
21
|
+
if (node == null || typeof node === "boolean") return "";
|
|
22
|
+
if (typeof node === "string" || typeof node === "number") {
|
|
23
|
+
return String(node);
|
|
24
|
+
}
|
|
25
|
+
if (Array.isArray(node)) return node.map(promptText).join("");
|
|
26
|
+
if (React.isValidElement(node)) {
|
|
27
|
+
const element = node as React.ReactElement<{
|
|
28
|
+
children?: React.ReactNode;
|
|
29
|
+
}>;
|
|
30
|
+
const inner = promptText(element.props.children);
|
|
31
|
+
if (element.type === "p") return inner + "\\n\\n";
|
|
32
|
+
if (element.type === "ul" || element.type === "ol") return inner + "\\n";
|
|
33
|
+
if (element.type === "li") return "- " + inner + "\\n";
|
|
34
|
+
return inner;
|
|
35
|
+
}
|
|
36
|
+
return "";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const StyledPrompt = styled.div<{ theme: Theme }>\`
|
|
40
|
+
background: \${({ theme }) => theme.colors.light};
|
|
41
|
+
border: solid 1px \${({ theme }) => theme.colors.grayLight};
|
|
42
|
+
border-radius: \${({ theme }) => theme.spacing.radius.lg};
|
|
43
|
+
padding: 20px;
|
|
44
|
+
width: 100%;
|
|
45
|
+
\`;
|
|
46
|
+
|
|
47
|
+
const StyledPromptHeader = styled.div<{ theme: Theme }>\`
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
gap: 10px;
|
|
51
|
+
margin: 0 0 15px;
|
|
52
|
+
\${({ theme }) => styledSmall(theme)};
|
|
53
|
+
font-weight: 700;
|
|
54
|
+
color: \${({ theme }) => theme.colors.dark};
|
|
55
|
+
|
|
56
|
+
& > svg.lucide {
|
|
57
|
+
flex-shrink: 0;
|
|
58
|
+
color: inherit;
|
|
59
|
+
}
|
|
60
|
+
\`;
|
|
61
|
+
|
|
62
|
+
const StyledPromptDescription = styled.span\`
|
|
63
|
+
flex: 1;
|
|
64
|
+
min-width: 0;
|
|
65
|
+
\`;
|
|
66
|
+
|
|
67
|
+
const StyledPromptActions = styled.span\`
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
gap: 5px;
|
|
71
|
+
flex-shrink: 0;
|
|
72
|
+
\`;
|
|
73
|
+
|
|
74
|
+
// Matches the CopyButton chrome so the two actions read as one control
|
|
75
|
+
// group; a link rather than a button because it navigates to the Cursor
|
|
76
|
+
// deeplink.
|
|
77
|
+
const StyledCursorLink = styled.a<{ theme: Theme }>\`
|
|
78
|
+
\${interactiveStyles}
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
gap: 5px;
|
|
82
|
+
background: \${({ theme }) => theme.colors.light};
|
|
83
|
+
border-color: \${({ theme }) => theme.colors.grayLight};
|
|
84
|
+
border-radius: \${({ theme }) => theme.spacing.radius.xs};
|
|
85
|
+
padding: 4px 8px;
|
|
86
|
+
font-size: 12px;
|
|
87
|
+
line-height: 16px;
|
|
88
|
+
font-weight: 600;
|
|
89
|
+
color: \${({ theme }) => theme.colors.grayDark};
|
|
90
|
+
text-decoration: none;
|
|
91
|
+
|
|
92
|
+
& svg.lucide {
|
|
93
|
+
margin: 0;
|
|
94
|
+
color: inherit;
|
|
95
|
+
}
|
|
96
|
+
\`;
|
|
97
|
+
|
|
98
|
+
const StyledPromptBody = styled.div<{ theme: Theme }>\`
|
|
99
|
+
\${({ theme }) => styledText(theme)};
|
|
100
|
+
color: \${({ theme }) => theme.colors.grayDark};
|
|
101
|
+
display: flex;
|
|
102
|
+
flex-direction: column;
|
|
103
|
+
gap: 20px;
|
|
104
|
+
\`;
|
|
105
|
+
|
|
106
|
+
interface PromptProps {
|
|
107
|
+
children: React.ReactNode;
|
|
108
|
+
description: string;
|
|
109
|
+
icon?: string;
|
|
110
|
+
actions?: PromptAction[];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function Prompt({
|
|
114
|
+
children,
|
|
115
|
+
description,
|
|
116
|
+
icon,
|
|
117
|
+
actions = ["copy"],
|
|
118
|
+
}: PromptProps) {
|
|
119
|
+
const text = promptText(children)
|
|
120
|
+
.replace(/\\n{3,}/g, "\\n\\n")
|
|
121
|
+
.trim();
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<StyledPrompt>
|
|
125
|
+
<StyledPromptHeader>
|
|
126
|
+
{icon ? <Icon name={icon} size={16} /> : null}
|
|
127
|
+
<StyledPromptDescription>{description}</StyledPromptDescription>
|
|
128
|
+
<StyledPromptActions>
|
|
129
|
+
{actions.includes("copy") && (
|
|
130
|
+
<CopyButton text={text} label="Copy prompt" size={16} />
|
|
131
|
+
)}
|
|
132
|
+
{actions.includes("cursor") && (
|
|
133
|
+
<StyledCursorLink
|
|
134
|
+
href={CURSOR_DEEPLINK + encodeURIComponent(text)}
|
|
135
|
+
aria-label="Open prompt in Cursor"
|
|
136
|
+
>
|
|
137
|
+
Cursor
|
|
138
|
+
<Icon name="arrow-up-right" size={12} />
|
|
139
|
+
</StyledCursorLink>
|
|
140
|
+
)}
|
|
141
|
+
</StyledPromptActions>
|
|
142
|
+
</StyledPromptHeader>
|
|
143
|
+
<StyledPromptBody>{children}</StyledPromptBody>
|
|
144
|
+
</StyledPrompt>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export { Prompt };
|
|
149
|
+
`;
|
|
@@ -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 &
|
|
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";
|
|
@@ -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
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const tooltipTemplate = "\"use client\";\nimport { useEffect, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport Link from \"next/link\";\nimport styled, { css } from \"styled-components\";\nimport { styledSmall } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\n\n// Layout cannot be measured during SSR; fall back to useEffect there so\n// prerendering stays warning-free while the browser still measures before\n// paint.\nconst useIsomorphicLayoutEffect =\n typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\nconst VIEWPORT_MARGIN = 8;\n\nconst StyledTooltip = styled.span`\n position: relative;\n display: inline-block;\n`;\n\nconst StyledTooltipTrigger = styled.span<{ theme: Theme }>`\n cursor: help;\n text-decoration: underline dotted 1.5px;\n text-decoration-color: ${({ theme }) => theme.colors.gray};\n text-underline-offset: 4px;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n\n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\n// The gap between trigger and bubble is padding on the positioner (not a\n// margin) so the pointer never crosses empty space on its way to the CTA\n// link, which would fire mouseleave and close the tooltip early.\nconst StyledTooltipBubble = styled.span<{\n theme: Theme;\n $isOpen: boolean;\n $placement: \"top\" | \"bottom\";\n $shift: number;\n}>`\n position: absolute;\n left: 50%;\n transform: translateX(calc(-50% + ${({ $shift }) => $shift}px));\n width: max-content;\n max-width: min(260px, calc(100vw - 16px));\n z-index: 10;\n opacity: 0;\n visibility: hidden;\n transition:\n opacity 0.2s ease,\n visibility 0.2s ease;\n\n ${({ $placement }) =>\n $placement === \"top\"\n ? css`\n bottom: 100%;\n padding-bottom: 8px;\n `\n : css`\n top: 100%;\n padding-top: 8px;\n `}\n\n ${({ $isOpen }) =>\n $isOpen &&\n css`\n opacity: 1;\n visibility: visible;\n `}\n`;\n\nconst StyledTooltipContent = styled.span<{ theme: Theme }>`\n display: block;\n background: ${({ theme }) => theme.colors.light};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 10px 14px;\n ${({ theme }) => styledSmall(theme)};\n color: ${({ theme }) => theme.colors.grayDark};\n text-align: left;\n`;\n\nconst StyledTooltipHeadline = styled.span<{ theme: Theme }>`\n display: block;\n font-weight: 700;\n color: ${({ theme }) => theme.colors.dark};\n`;\n\nconst StyledTooltipCta = styled.a<{ theme: Theme }>`\n display: block;\n margin-top: 5px;\n font-weight: 700;\n color: ${({ theme }) => theme.colors.primary};\n text-decoration: none;\n transition: color 0.3s ease;\n\n &:hover {\n color: ${({ theme }) => theme.colors.primaryDark};\n }\n`;\n\ninterface TooltipProps {\n children: React.ReactNode;\n tip: string;\n headline?: string;\n cta?: string;\n href?: string;\n}\n\nfunction Tooltip({ children, tip, headline, cta, href }: TooltipProps) {\n const [isOpen, setIsOpen] = useState(false);\n const [placement, setPlacement] = useState<\"top\" | \"bottom\">(\"top\");\n const [shift, setShift] = useState(0);\n const wrapperRef = useRef<HTMLSpanElement>(null);\n const bubbleRef = useRef<HTMLSpanElement>(null);\n const tooltipId = useId();\n\n // Keep the bubble inside the viewport: shift it horizontally when the\n // trigger sits near a screen edge, and flip it below the trigger when\n // there is no room above. The hidden bubble still has layout, so it can\n // be measured the moment it opens.\n useIsomorphicLayoutEffect(() => {\n if (!isOpen) return;\n const wrapper = wrapperRef.current;\n const bubble = bubbleRef.current;\n if (!wrapper || !bubble) return;\n const triggerRect = wrapper.getBoundingClientRect();\n const bubbleRect = bubble.getBoundingClientRect();\n setPlacement(\n triggerRect.top - bubbleRect.height - VIEWPORT_MARGIN < 0\n ? \"bottom\"\n : \"top\",\n );\n const center = triggerRect.left + triggerRect.width / 2;\n const half = bubbleRect.width / 2;\n if (center - half < VIEWPORT_MARGIN) {\n setShift(VIEWPORT_MARGIN - (center - half));\n } else if (center + half > window.innerWidth - VIEWPORT_MARGIN) {\n setShift(window.innerWidth - VIEWPORT_MARGIN - (center + half));\n } else {\n setShift(0);\n }\n }, [isOpen]);\n\n // Touch devices have no hover and fire blur unreliably, so a tap anywhere\n // outside must close the tooltip explicitly.\n useEffect(() => {\n if (!isOpen) return;\n const closeOnOutsidePointer = (event: PointerEvent) => {\n const wrapper = wrapperRef.current;\n if (\n wrapper &&\n event.target instanceof Node &&\n !wrapper.contains(event.target)\n ) {\n setIsOpen(false);\n }\n };\n document.addEventListener(\"pointerdown\", closeOnOutsidePointer);\n return () =>\n document.removeEventListener(\"pointerdown\", closeOnOutsidePointer);\n }, [isOpen]);\n\n return (\n <StyledTooltip\n ref={wrapperRef}\n onMouseEnter={() => setIsOpen(true)}\n onMouseLeave={() => setIsOpen(false)}\n onFocus={() => setIsOpen(true)}\n onBlur={(e) =>\n !e.currentTarget.contains(e.relatedTarget) && setIsOpen(false)\n }\n onKeyDown={(e) => e.key === \"Escape\" && setIsOpen(false)}\n >\n {/* Click opens but never toggles closed: on touch, a tap can fire\n focus and click in the same gesture, and a toggle would close the\n tooltip the instant it opened. */}\n <StyledTooltipTrigger\n tabIndex={0}\n aria-describedby={tooltipId}\n onClick={() => setIsOpen(true)}\n >\n {children}\n </StyledTooltipTrigger>\n <StyledTooltipBubble\n ref={bubbleRef}\n id={tooltipId}\n role=\"tooltip\"\n $isOpen={isOpen}\n $placement={placement}\n $shift={shift}\n >\n <StyledTooltipContent>\n {headline && (\n <StyledTooltipHeadline>{headline}</StyledTooltipHeadline>\n )}\n {tip}\n {cta &&\n href &&\n (href.startsWith(\"/\") ? (\n <StyledTooltipCta as={Link} href={href}>\n {cta}\n </StyledTooltipCta>\n ) : (\n <StyledTooltipCta\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {cta}\n </StyledTooltipCta>\n ))}\n </StyledTooltipContent>\n </StyledTooltipBubble>\n </StyledTooltip>\n );\n}\n\nexport { Tooltip };\n";
|