@fragments-sdk/ui 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/ui.css +320 -183
- package/dist/components/Header/Header.module.scss.cjs +42 -21
- package/dist/components/Header/Header.module.scss.js +42 -21
- package/dist/components/Header/index.cjs +121 -3
- package/dist/components/Header/index.d.ts +26 -3
- package/dist/components/Header/index.d.ts.map +1 -1
- package/dist/components/Header/index.js +122 -4
- package/dist/components/Sidebar/Sidebar.module.scss.cjs +42 -42
- package/dist/components/Sidebar/Sidebar.module.scss.js +42 -42
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/fragments.json +1 -1
- package/package.json +3 -3
- package/src/components/Accordion/Accordion.contract.json +169 -0
- package/src/components/Alert/Alert.contract.json +157 -0
- package/src/components/AppShell/AppShell.contract.json +155 -0
- package/src/components/Avatar/Avatar.contract.json +189 -0
- package/src/components/Badge/Badge.contract.json +187 -0
- package/src/components/BentoGrid/BentoGrid.contract.json +135 -0
- package/src/components/Box/Box.contract.json +423 -0
- package/src/components/Breadcrumbs/Breadcrumbs.contract.json +143 -0
- package/src/components/Button/Button.contract.json +205 -0
- package/src/components/ButtonGroup/ButtonGroup.contract.json +140 -0
- package/src/components/Card/Card.contract.json +185 -0
- package/src/components/Chart/Chart.contract.json +129 -0
- package/src/components/Checkbox/Checkbox.contract.json +246 -0
- package/src/components/Chip/Chip.contract.json +212 -0
- package/src/components/CodeBlock/CodeBlock.contract.json +388 -0
- package/src/components/Collapsible/Collapsible.contract.json +154 -0
- package/src/components/ColorPicker/ColorPicker.contract.json +212 -0
- package/src/components/Combobox/Combobox.contract.json +297 -0
- package/src/components/Command/Command.contract.json +165 -0
- package/src/components/ConversationList/ConversationList.contract.json +151 -0
- package/src/components/DataTable/DataTable.contract.json +302 -0
- package/src/components/DatePicker/DatePicker.contract.json +288 -0
- package/src/components/Dialog/Dialog.contract.json +159 -0
- package/src/components/Drawer/Drawer.contract.json +160 -0
- package/src/components/Editor/Editor.contract.json +263 -0
- package/src/components/EmptyState/EmptyState.contract.json +133 -0
- package/src/components/Field/Field.contract.json +157 -0
- package/src/components/Fieldset/Fieldset.contract.json +117 -0
- package/src/components/Form/Form.contract.json +145 -0
- package/src/components/Grid/Grid.contract.json +195 -0
- package/src/components/Header/Header.contract.json +194 -0
- package/src/components/Header/Header.module.scss +99 -0
- package/src/components/Header/index.tsx +191 -10
- package/src/components/Icon/Icon.contract.json +194 -0
- package/src/components/Image/Image.contract.json +209 -0
- package/src/components/Input/Input.contract.json +344 -0
- package/src/components/Link/Link.contract.json +180 -0
- package/src/components/List/List.contract.json +154 -0
- package/src/components/Listbox/Listbox.contract.json +158 -0
- package/src/components/Loading/Loading.contract.json +167 -0
- package/src/components/Markdown/Markdown.contract.json +127 -0
- package/src/components/Menu/Menu.contract.json +177 -0
- package/src/components/Message/Message.contract.json +183 -0
- package/src/components/NavigationMenu/NavigationMenu.contract.json +203 -0
- package/src/components/Pagination/Pagination.contract.json +163 -0
- package/src/components/Popover/Popover.contract.json +163 -0
- package/src/components/Progress/Progress.contract.json +176 -0
- package/src/components/Prompt/Prompt.contract.json +211 -0
- package/src/components/RadioGroup/RadioGroup.contract.json +226 -0
- package/src/components/ScrollArea/ScrollArea.contract.json +131 -0
- package/src/components/Select/Select.contract.json +269 -0
- package/src/components/Separator/Separator.contract.json +143 -0
- package/src/components/Sidebar/Sidebar.contract.json +258 -0
- package/src/components/Sidebar/Sidebar.module.scss +6 -4
- package/src/components/Skeleton/Skeleton.contract.json +166 -0
- package/src/components/Slider/Slider.contract.json +248 -0
- package/src/components/Stack/Stack.contract.json +220 -0
- package/src/components/Table/Table.contract.json +171 -0
- package/src/components/TableOfContents/TableOfContents.contract.json +145 -0
- package/src/components/Tabs/Tabs.contract.json +159 -0
- package/src/components/Text/Text.contract.json +239 -0
- package/src/components/Textarea/Textarea.contract.json +308 -0
- package/src/components/Theme/Theme.contract.json +152 -0
- package/src/components/ThinkingIndicator/ThinkingIndicator.contract.json +165 -0
- package/src/components/Toast/Toast.contract.json +181 -0
- package/src/components/Toggle/Toggle.contract.json +231 -0
- package/src/components/ToggleGroup/ToggleGroup.contract.json +206 -0
- package/src/components/Tooltip/Tooltip.contract.json +214 -0
- package/src/components/VisuallyHidden/VisuallyHidden.contract.json +116 -0
- package/src/index.ts +1 -0
- package/src/tokens/_derive.scss +4 -1
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://usefragments.com/schemas/contract.v1.json",
|
|
3
|
+
"name": "CodeBlock",
|
|
4
|
+
"description": "Syntax-highlighted code display with copy functionality, theming, diff view, and collapsible sections",
|
|
5
|
+
"category": "display",
|
|
6
|
+
"tags": [
|
|
7
|
+
"code",
|
|
8
|
+
"syntax",
|
|
9
|
+
"highlighting",
|
|
10
|
+
"documentation",
|
|
11
|
+
"developer",
|
|
12
|
+
"diff"
|
|
13
|
+
],
|
|
14
|
+
"status": "stable",
|
|
15
|
+
"sourcePath": "src/components/CodeBlock/index.tsx",
|
|
16
|
+
"exportName": "CodeBlock",
|
|
17
|
+
"propsSummary": [
|
|
18
|
+
"code: string (required)",
|
|
19
|
+
"language: tsx|typescript|ts|javascript|js|jsx|bash|shell|css|scss|sass|json|html|xml|markdown|md|yaml|yml|python|py|ruby|go|rust|java|kotlin|swift|c|cpp|csharp|php|sql|graphql|diff|plaintext|text (default: tsx)",
|
|
20
|
+
"theme: synthwave-84|github-dark|github-light|one-dark-pro|dracula|nord|monokai|vitesse-dark|vitesse-light|min-dark|min-light (default: one-dark-pro)",
|
|
21
|
+
"showCopy: boolean (default: true)",
|
|
22
|
+
"title: string",
|
|
23
|
+
"filename: string",
|
|
24
|
+
"caption: string",
|
|
25
|
+
"showLineNumbers: boolean (default: false)",
|
|
26
|
+
"startLineNumber: number (default: 1)",
|
|
27
|
+
"highlightLines: array",
|
|
28
|
+
"addedLines: array",
|
|
29
|
+
"removedLines: array",
|
|
30
|
+
"wordWrap: boolean (default: false)",
|
|
31
|
+
"maxHeight: number",
|
|
32
|
+
"collapsible: boolean (default: false)",
|
|
33
|
+
"defaultCollapsed: boolean (default: false)",
|
|
34
|
+
"collapsedLines: number (default: 5)",
|
|
35
|
+
"compact: boolean (default: false)",
|
|
36
|
+
"persistentCopy: boolean (default: false)",
|
|
37
|
+
"copyPlacement: auto|header|overlay (default: auto)",
|
|
38
|
+
"bg: string",
|
|
39
|
+
"onCopy: function"
|
|
40
|
+
],
|
|
41
|
+
"props": {
|
|
42
|
+
"code": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"description": "The code string to display",
|
|
45
|
+
"required": true
|
|
46
|
+
},
|
|
47
|
+
"language": {
|
|
48
|
+
"type": "enum",
|
|
49
|
+
"description": "Programming language for syntax highlighting",
|
|
50
|
+
"default": "tsx",
|
|
51
|
+
"required": false,
|
|
52
|
+
"values": [
|
|
53
|
+
"tsx",
|
|
54
|
+
"typescript",
|
|
55
|
+
"ts",
|
|
56
|
+
"javascript",
|
|
57
|
+
"js",
|
|
58
|
+
"jsx",
|
|
59
|
+
"bash",
|
|
60
|
+
"shell",
|
|
61
|
+
"css",
|
|
62
|
+
"scss",
|
|
63
|
+
"sass",
|
|
64
|
+
"json",
|
|
65
|
+
"html",
|
|
66
|
+
"xml",
|
|
67
|
+
"markdown",
|
|
68
|
+
"md",
|
|
69
|
+
"yaml",
|
|
70
|
+
"yml",
|
|
71
|
+
"python",
|
|
72
|
+
"py",
|
|
73
|
+
"ruby",
|
|
74
|
+
"go",
|
|
75
|
+
"rust",
|
|
76
|
+
"java",
|
|
77
|
+
"kotlin",
|
|
78
|
+
"swift",
|
|
79
|
+
"c",
|
|
80
|
+
"cpp",
|
|
81
|
+
"csharp",
|
|
82
|
+
"php",
|
|
83
|
+
"sql",
|
|
84
|
+
"graphql",
|
|
85
|
+
"diff",
|
|
86
|
+
"plaintext",
|
|
87
|
+
"text"
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
"theme": {
|
|
91
|
+
"type": "enum",
|
|
92
|
+
"description": "Syntax highlighting theme",
|
|
93
|
+
"default": "one-dark-pro",
|
|
94
|
+
"required": false,
|
|
95
|
+
"values": [
|
|
96
|
+
"synthwave-84",
|
|
97
|
+
"github-dark",
|
|
98
|
+
"github-light",
|
|
99
|
+
"one-dark-pro",
|
|
100
|
+
"dracula",
|
|
101
|
+
"nord",
|
|
102
|
+
"monokai",
|
|
103
|
+
"vitesse-dark",
|
|
104
|
+
"vitesse-light",
|
|
105
|
+
"min-dark",
|
|
106
|
+
"min-light"
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
"showCopy": {
|
|
110
|
+
"type": "boolean",
|
|
111
|
+
"description": "Whether to show the copy button",
|
|
112
|
+
"default": "true",
|
|
113
|
+
"required": false
|
|
114
|
+
},
|
|
115
|
+
"title": {
|
|
116
|
+
"type": "string",
|
|
117
|
+
"description": "Optional title displayed above the code block (external label)",
|
|
118
|
+
"required": false
|
|
119
|
+
},
|
|
120
|
+
"filename": {
|
|
121
|
+
"type": "string",
|
|
122
|
+
"description": "Optional filename shown in header bar inside code block",
|
|
123
|
+
"required": false
|
|
124
|
+
},
|
|
125
|
+
"caption": {
|
|
126
|
+
"type": "string",
|
|
127
|
+
"description": "Optional caption displayed below the code block",
|
|
128
|
+
"required": false
|
|
129
|
+
},
|
|
130
|
+
"showLineNumbers": {
|
|
131
|
+
"type": "boolean",
|
|
132
|
+
"description": "Whether to display line numbers",
|
|
133
|
+
"default": "false",
|
|
134
|
+
"required": false
|
|
135
|
+
},
|
|
136
|
+
"startLineNumber": {
|
|
137
|
+
"type": "number",
|
|
138
|
+
"description": "Starting line number (useful for code excerpts)",
|
|
139
|
+
"default": "1",
|
|
140
|
+
"required": false
|
|
141
|
+
},
|
|
142
|
+
"highlightLines": {
|
|
143
|
+
"type": "array",
|
|
144
|
+
"description": "Lines to highlight (e.g., [1, 3, \"5-7\"])",
|
|
145
|
+
"required": false
|
|
146
|
+
},
|
|
147
|
+
"addedLines": {
|
|
148
|
+
"type": "array",
|
|
149
|
+
"description": "Lines marked as added in diff view (e.g., [2, \"4-6\"])",
|
|
150
|
+
"required": false
|
|
151
|
+
},
|
|
152
|
+
"removedLines": {
|
|
153
|
+
"type": "array",
|
|
154
|
+
"description": "Lines marked as removed in diff view (e.g., [1, 3])",
|
|
155
|
+
"required": false
|
|
156
|
+
},
|
|
157
|
+
"wordWrap": {
|
|
158
|
+
"type": "boolean",
|
|
159
|
+
"description": "Enable word wrapping for long lines",
|
|
160
|
+
"default": "false",
|
|
161
|
+
"required": false
|
|
162
|
+
},
|
|
163
|
+
"maxHeight": {
|
|
164
|
+
"type": "number",
|
|
165
|
+
"description": "Maximum height in pixels (enables scrolling)",
|
|
166
|
+
"required": false
|
|
167
|
+
},
|
|
168
|
+
"collapsible": {
|
|
169
|
+
"type": "boolean",
|
|
170
|
+
"description": "Allow collapsing/expanding the code block",
|
|
171
|
+
"default": "false",
|
|
172
|
+
"required": false
|
|
173
|
+
},
|
|
174
|
+
"defaultCollapsed": {
|
|
175
|
+
"type": "boolean",
|
|
176
|
+
"description": "Initial collapsed state (only applies when collapsible is true)",
|
|
177
|
+
"default": "false",
|
|
178
|
+
"required": false
|
|
179
|
+
},
|
|
180
|
+
"collapsedLines": {
|
|
181
|
+
"type": "number",
|
|
182
|
+
"description": "Number of lines to show when collapsed",
|
|
183
|
+
"default": "5",
|
|
184
|
+
"required": false
|
|
185
|
+
},
|
|
186
|
+
"compact": {
|
|
187
|
+
"type": "boolean",
|
|
188
|
+
"description": "Compact mode with reduced padding",
|
|
189
|
+
"default": "false",
|
|
190
|
+
"required": false
|
|
191
|
+
},
|
|
192
|
+
"persistentCopy": {
|
|
193
|
+
"type": "boolean",
|
|
194
|
+
"description": "Show a persistent copy button that is always visible",
|
|
195
|
+
"default": "false",
|
|
196
|
+
"required": false
|
|
197
|
+
},
|
|
198
|
+
"copyPlacement": {
|
|
199
|
+
"type": "enum",
|
|
200
|
+
"description": "Where to place the copy button when not using persistentCopy",
|
|
201
|
+
"default": "auto",
|
|
202
|
+
"required": false,
|
|
203
|
+
"values": [
|
|
204
|
+
"auto",
|
|
205
|
+
"header",
|
|
206
|
+
"overlay"
|
|
207
|
+
]
|
|
208
|
+
},
|
|
209
|
+
"bg": {
|
|
210
|
+
"type": "string",
|
|
211
|
+
"description": "Custom background color for the code block (useful when the content area is pure black or dark gray)",
|
|
212
|
+
"required": false
|
|
213
|
+
},
|
|
214
|
+
"onCopy": {
|
|
215
|
+
"type": "function",
|
|
216
|
+
"description": "Callback fired when the copy button is clicked and copy succeeds",
|
|
217
|
+
"required": false
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
"usage": {
|
|
221
|
+
"when": [
|
|
222
|
+
"Displaying code examples in documentation",
|
|
223
|
+
"Showing installation commands",
|
|
224
|
+
"Presenting configuration snippets",
|
|
225
|
+
"Teaching programming concepts",
|
|
226
|
+
"Showing code diffs or changes",
|
|
227
|
+
"Displaying long code files with collapse functionality"
|
|
228
|
+
],
|
|
229
|
+
"whenNot": [
|
|
230
|
+
"User-editable code (use code editor)",
|
|
231
|
+
"Very short inline code (use <code> element)",
|
|
232
|
+
"Non-code content (use Text or Card)"
|
|
233
|
+
],
|
|
234
|
+
"guidelines": [
|
|
235
|
+
"Always specify the correct language for accurate highlighting",
|
|
236
|
+
"Use filename prop to show source file name in header bar",
|
|
237
|
+
"Use copyPlacement=\"auto\" to render copy in overlay mode when no filename is provided",
|
|
238
|
+
"Use title prop for external labels above the code block",
|
|
239
|
+
"Enable line numbers for longer code samples",
|
|
240
|
+
"Use highlightLines to draw attention to key lines",
|
|
241
|
+
"Use addedLines/removedLines for diff highlighting",
|
|
242
|
+
"Set maxHeight for very long code blocks to prevent layout issues",
|
|
243
|
+
"Use collapsible for code samples that users may want to skim",
|
|
244
|
+
"Choose a theme that matches your documentation style",
|
|
245
|
+
"Keep code examples concise and focused",
|
|
246
|
+
"Use CodeBlock.Tabbed for multi-language snippets; tabs support controlled value/onValueChange and explicit tab values"
|
|
247
|
+
],
|
|
248
|
+
"accessibility": [
|
|
249
|
+
"Code is presented in a semantic pre/code structure",
|
|
250
|
+
"Copy button has appropriate aria-label",
|
|
251
|
+
"Keyboard accessible copy functionality",
|
|
252
|
+
"Collapse button has aria-expanded state"
|
|
253
|
+
]
|
|
254
|
+
},
|
|
255
|
+
"examples": [
|
|
256
|
+
{
|
|
257
|
+
"name": "Default",
|
|
258
|
+
"description": "Basic code block with syntax highlighting",
|
|
259
|
+
"code": "<CodeBlock code={`import { Button } from '@fragments-sdk/ui';\n\nfunction App() {\n return <Button>Click me</Button>;\n}`} language=\"tsx\" />"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"name": "With Filename",
|
|
263
|
+
"description": "Code block with filename in header bar",
|
|
264
|
+
"code": "<CodeBlock filename=\"app.tsx\" code={`import { Button, Card } from '@fragments-sdk/ui';\n\nfunction App() {\n return (\n <Card>\n <Card.Header>Welcome</Card.Header>\n <Card.Content>\n <Button>Get Started</Button>\n </Card.Content>\n </Card>\n );\n}`} language=\"tsx\" />"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"name": "With Title",
|
|
268
|
+
"description": "Code block with external title label",
|
|
269
|
+
"code": "<CodeBlock title=\"Installation\" code=\"npm install @fragments-sdk/ui\" language=\"bash\" />"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"name": "With Caption",
|
|
273
|
+
"description": "Code block with footer caption",
|
|
274
|
+
"code": "<CodeBlock\n code={`const API_URL = process.env.NEXT_PUBLIC_API_URL;`}\n language=\"typescript\"\n caption=\"Environment variables must be prefixed with NEXT_PUBLIC_ to be available in the browser.\"\n/>"
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"name": "With Line Numbers",
|
|
278
|
+
"description": "Shows line numbers for reference",
|
|
279
|
+
"code": "<CodeBlock code={`const greeting = \"Hello\";\nconst name = \"World\";\nconsole.log(\\`\\${greeting}, \\${name}!\\`);`} language=\"typescript\" showLineNumbers />"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"name": "Custom Start Line",
|
|
283
|
+
"description": "Shows code excerpt starting from a specific line number",
|
|
284
|
+
"code": "<CodeBlock\n code={` return (\n <button onClick={() => setCount(c => c + 1)}>\n Count: {count}\n </button>\n );\n}`}\n language=\"tsx\"\n showLineNumbers\n startLineNumber={15}\n caption=\"Lines 15-20 from Counter.tsx\"\n/>"
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"name": "With Highlighted Lines",
|
|
288
|
+
"description": "Emphasizes specific lines of code",
|
|
289
|
+
"code": "<CodeBlock code={`import { useState } from 'react';\n\nfunction Counter() {\n const [count, setCount] = useState(0);\n\n return (\n <button onClick={() => setCount(c => c + 1)}>\n Count: {count}\n </button>\n );\n}`} language=\"tsx\" showLineNumbers highlightLines={[4, '7-9']} />"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
"name": "Diff View",
|
|
293
|
+
"description": "Shows added and removed lines in a diff-like format",
|
|
294
|
+
"code": "<CodeBlock\n code={`import { useState } from 'react';\nimport { useCallback } from 'react';\n\nfunction Counter() {\n const [count, setCount] = useState(0);\n const increment = () => setCount(c => c + 1);\n const increment = useCallback(() => setCount(c => c + 1), []);\n\n return <button onClick={increment}>Count: {count}</button>;\n}`}\n language=\"tsx\"\n showLineNumbers\n removedLines={[6]}\n addedLines={[2, 7]}\n/>"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
"name": "GitHub Dark Theme",
|
|
298
|
+
"description": "Using the GitHub Dark theme",
|
|
299
|
+
"code": "<CodeBlock\n code={`async function fetchUser(id: string) {\n const response = await fetch(\\`/api/users/\\${id}\\`);\n return response.json();\n}`}\n language=\"typescript\"\n theme=\"github-dark\"\n/>"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"name": "GitHub Light Theme",
|
|
303
|
+
"description": "Using the GitHub Light theme for light backgrounds",
|
|
304
|
+
"code": "<CodeBlock\n code={`def fibonacci(n):\n if n <= 1:\n return n\n return fibonacci(n - 1) + fibonacci(n - 2)`}\n language=\"python\"\n theme=\"github-light\"\n/>"
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"name": "Dracula Theme",
|
|
308
|
+
"description": "Using the popular Dracula theme",
|
|
309
|
+
"code": "<CodeBlock\n code={`fn main() {\n println!(\"Hello, Rust!\");\n}`}\n language=\"rust\"\n theme=\"dracula\"\n/>"
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"name": "Word Wrap",
|
|
313
|
+
"description": "Long lines wrap instead of scrolling horizontally",
|
|
314
|
+
"code": "<CodeBlock\n code={`const longString = \"This is a very long string that would normally cause horizontal scrolling, but with word wrap enabled it will break to the next line instead.\";`}\n language=\"typescript\"\n wordWrap\n/>"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"name": "Max Height with Scroll",
|
|
318
|
+
"description": "Constrains height with scrollable content",
|
|
319
|
+
"code": "<CodeBlock\n code={`// This code block has a maximum height\nfunction processItems(items: string[]) {\n const results = [];\n for (const item of items) {\n if (item.startsWith('_')) {\n continue;\n }\n const processed = item.trim().toLowerCase();\n if (processed.length > 0) {\n results.push(processed);\n }\n }\n return results;\n}\n\nexport default processItems;`}\n language=\"typescript\"\n maxHeight={150}\n showLineNumbers\n/>"
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"name": "Collapsible",
|
|
323
|
+
"description": "Long code that can be expanded/collapsed",
|
|
324
|
+
"code": "<CodeBlock\n code={`import React, { useState, useEffect } from 'react';\n\ninterface User {\n id: string;\n name: string;\n email: string;\n avatar?: string;\n}\n\nexport function UserProfile({ userId }: { userId: string }) {\n const [user, setUser] = useState<User | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n async function fetchUser() {\n try {\n setLoading(true);\n const response = await fetch(\\`/api/users/\\${userId}\\`);\n if (!response.ok) throw new Error('Failed to fetch');\n const data = await response.json();\n setUser(data);\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Unknown error');\n } finally {\n setLoading(false);\n }\n }\n fetchUser();\n }, [userId]);\n\n if (loading) return <div>Loading...</div>;\n if (error) return <div>Error: {error}</div>;\n if (!user) return null;\n\n return (\n <div>\n <h1>{user.name}</h1>\n <p>{user.email}</p>\n </div>\n );\n}`}\n language=\"tsx\"\n showLineNumbers\n collapsible\n defaultCollapsed\n collapsedLines={8}\n/>"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"name": "JSON",
|
|
328
|
+
"description": "Configuration file example",
|
|
329
|
+
"code": "<CodeBlock title=\"package.json\" code={`{\n \"name\": \"my-app\",\n \"dependencies\": {\n \"@fragments-sdk/ui\": \"^0.3.0\"\n }\n}`} language=\"json\" />"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"name": "Without Copy Button",
|
|
333
|
+
"description": "Minimal display without copy functionality",
|
|
334
|
+
"code": "<CodeBlock code=\"const simple = true;\" language=\"typescript\" showCopy={false} />"
|
|
335
|
+
}
|
|
336
|
+
],
|
|
337
|
+
"relations": [
|
|
338
|
+
{
|
|
339
|
+
"component": "Card",
|
|
340
|
+
"relationship": "parent",
|
|
341
|
+
"note": "Can be wrapped in Card for additional context"
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
"component": "Tabs",
|
|
345
|
+
"relationship": "child",
|
|
346
|
+
"note": "Use in Tabs for showing code in multiple languages"
|
|
347
|
+
}
|
|
348
|
+
],
|
|
349
|
+
"contract": {
|
|
350
|
+
"propsSummary": [
|
|
351
|
+
"code: string - required code content",
|
|
352
|
+
"language: tsx|typescript|javascript|jsx|bash|shell|css|scss|sass|json|html|xml|markdown|md|yaml|yml|python|py|ruby|go|rust|java|kotlin|swift|c|cpp|csharp|php|sql|graphql|diff|plaintext",
|
|
353
|
+
"theme: synthwave-84|github-dark|github-light|one-dark-pro|dracula|nord|monokai|vitesse-dark|vitesse-light|min-dark|min-light (default: one-dark-pro)",
|
|
354
|
+
"showCopy: boolean (default: true)",
|
|
355
|
+
"copyPlacement: auto|header|overlay (default: auto)",
|
|
356
|
+
"title: string - optional external label",
|
|
357
|
+
"filename: string - optional filename in header bar",
|
|
358
|
+
"caption: string - optional footer caption",
|
|
359
|
+
"showLineNumbers: boolean (default: false)",
|
|
360
|
+
"startLineNumber: number (default: 1)",
|
|
361
|
+
"highlightLines: (number | string)[] - lines to emphasize",
|
|
362
|
+
"addedLines: (number | string)[] - diff added lines",
|
|
363
|
+
"removedLines: (number | string)[] - diff removed lines",
|
|
364
|
+
"wordWrap: boolean (default: false)",
|
|
365
|
+
"maxHeight: number - max height with scrolling",
|
|
366
|
+
"collapsible: boolean (default: false)",
|
|
367
|
+
"defaultCollapsed: boolean (default: false)",
|
|
368
|
+
"collapsedLines: number (default: 5)",
|
|
369
|
+
"CodeBlock.Tabbed: tabs[] plus optional defaultTab/value/onValueChange for multi-language snippets"
|
|
370
|
+
],
|
|
371
|
+
"a11yRules": [
|
|
372
|
+
"A11Y_CODE_SEMANTIC",
|
|
373
|
+
"A11Y_BTN_LABEL"
|
|
374
|
+
]
|
|
375
|
+
},
|
|
376
|
+
"ai": {
|
|
377
|
+
"compositionPattern": "compound",
|
|
378
|
+
"subComponents": [
|
|
379
|
+
"Tabbed"
|
|
380
|
+
]
|
|
381
|
+
},
|
|
382
|
+
"provenance": {
|
|
383
|
+
"source": "migrated",
|
|
384
|
+
"verified": false,
|
|
385
|
+
"frameworkSupport": "native",
|
|
386
|
+
"extractedAt": "2026-03-13T23:18:52.626Z"
|
|
387
|
+
}
|
|
388
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://usefragments.com/schemas/contract.v1.json",
|
|
3
|
+
"name": "Collapsible",
|
|
4
|
+
"description": "An interactive component that expands/collapses to show or hide content",
|
|
5
|
+
"category": "layout",
|
|
6
|
+
"tags": [
|
|
7
|
+
"collapsible",
|
|
8
|
+
"expandable",
|
|
9
|
+
"accordion",
|
|
10
|
+
"disclosure",
|
|
11
|
+
"toggle"
|
|
12
|
+
],
|
|
13
|
+
"status": "stable",
|
|
14
|
+
"sourcePath": "src/components/Collapsible/index.tsx",
|
|
15
|
+
"exportName": "Collapsible",
|
|
16
|
+
"propsSummary": [
|
|
17
|
+
"children: node (required)",
|
|
18
|
+
"defaultOpen: boolean (default: false)",
|
|
19
|
+
"open: boolean",
|
|
20
|
+
"onOpenChange: function",
|
|
21
|
+
"disabled: boolean (default: false)"
|
|
22
|
+
],
|
|
23
|
+
"props": {
|
|
24
|
+
"children": {
|
|
25
|
+
"type": "node",
|
|
26
|
+
"description": "Collapsible.Trigger and Collapsible.Content components",
|
|
27
|
+
"required": true
|
|
28
|
+
},
|
|
29
|
+
"defaultOpen": {
|
|
30
|
+
"type": "boolean",
|
|
31
|
+
"description": "Whether the collapsible is initially open (uncontrolled)",
|
|
32
|
+
"default": "false",
|
|
33
|
+
"required": false
|
|
34
|
+
},
|
|
35
|
+
"open": {
|
|
36
|
+
"type": "boolean",
|
|
37
|
+
"description": "Controlled open state",
|
|
38
|
+
"required": false
|
|
39
|
+
},
|
|
40
|
+
"onOpenChange": {
|
|
41
|
+
"type": "function",
|
|
42
|
+
"description": "Callback when open state changes - (open: boolean) => void",
|
|
43
|
+
"required": false
|
|
44
|
+
},
|
|
45
|
+
"disabled": {
|
|
46
|
+
"type": "boolean",
|
|
47
|
+
"description": "Whether the collapsible is disabled",
|
|
48
|
+
"default": "false",
|
|
49
|
+
"required": false
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"usage": {
|
|
53
|
+
"when": [
|
|
54
|
+
"Showing/hiding additional content on demand",
|
|
55
|
+
"Building accordions or expandable sections",
|
|
56
|
+
"Collapsible navigation sections",
|
|
57
|
+
"FAQ sections with expandable answers",
|
|
58
|
+
"Settings panels with grouped options"
|
|
59
|
+
],
|
|
60
|
+
"whenNot": [
|
|
61
|
+
"Single item disclosure (use Accordion instead)",
|
|
62
|
+
"Navigation menus with complex interactions (use Menu)",
|
|
63
|
+
"Modal or overlay content (use Dialog or Popover)"
|
|
64
|
+
],
|
|
65
|
+
"guidelines": [
|
|
66
|
+
"Use clear trigger labels that indicate expandable content",
|
|
67
|
+
"Consider defaultOpen for primary content users often need",
|
|
68
|
+
"Keep trigger text concise but descriptive",
|
|
69
|
+
"Use chevron icons consistently to indicate collapsible state"
|
|
70
|
+
],
|
|
71
|
+
"accessibility": [
|
|
72
|
+
"Trigger must have aria-expanded to indicate state",
|
|
73
|
+
"Content region needs aria-labelledby pointing to trigger",
|
|
74
|
+
"Keyboard: Enter/Space toggles open state",
|
|
75
|
+
"Focus should remain on trigger after toggle"
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
"examples": [
|
|
79
|
+
{
|
|
80
|
+
"name": "Default",
|
|
81
|
+
"description": "Basic collapsible with trigger and content",
|
|
82
|
+
"code": "<Collapsible>\n <Collapsible.Trigger>Click to expand</Collapsible.Trigger>\n <Collapsible.Content>\n <p>This content is hidden by default and revealed when the trigger is clicked.</p>\n </Collapsible.Content>\n</Collapsible>"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "Default Open",
|
|
86
|
+
"description": "Collapsible that starts in the expanded state",
|
|
87
|
+
"code": "<Collapsible defaultOpen>\n <Collapsible.Trigger>Section Title</Collapsible.Trigger>\n <Collapsible.Content>\n <p>This content is visible by default. Click the trigger to collapse.</p>\n </Collapsible.Content>\n</Collapsible>"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "Chevron Start",
|
|
91
|
+
"description": "Collapsible with chevron icon on the left",
|
|
92
|
+
"code": "<Collapsible>\n <Collapsible.Trigger chevronPosition=\"start\">Navigation</Collapsible.Trigger>\n <Collapsible.Content>\n <ul style={{ margin: 0, paddingLeft: '1.5rem' }}>\n <li>Dashboard</li>\n <li>Settings</li>\n <li>Profile</li>\n </ul>\n </Collapsible.Content>\n</Collapsible>"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "No Chevron",
|
|
96
|
+
"description": "Collapsible without chevron indicator",
|
|
97
|
+
"code": "<Collapsible>\n <Collapsible.Trigger showChevron={false}>Show more details</Collapsible.Trigger>\n <Collapsible.Content>\n <p>Hidden details that appear when triggered.</p>\n </Collapsible.Content>\n</Collapsible>"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"name": "Disabled",
|
|
101
|
+
"description": "Collapsible in disabled state",
|
|
102
|
+
"code": "<Collapsible disabled>\n <Collapsible.Trigger>Cannot toggle (disabled)</Collapsible.Trigger>\n <Collapsible.Content>\n <p>This content cannot be shown because the collapsible is disabled.</p>\n </Collapsible.Content>\n</Collapsible>"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "Multiple Sections",
|
|
106
|
+
"description": "Multiple independent collapsible sections",
|
|
107
|
+
"code": "<div style={{ display: 'flex', flexDirection: 'column', gap: '4px' }}>\n <Collapsible defaultOpen>\n <Collapsible.Trigger>Getting Started</Collapsible.Trigger>\n <Collapsible.Content>\n <p>Introduction and setup instructions.</p>\n </Collapsible.Content>\n </Collapsible>\n <Collapsible>\n <Collapsible.Trigger>Advanced Usage</Collapsible.Trigger>\n <Collapsible.Content>\n <p>Advanced configuration options.</p>\n </Collapsible.Content>\n </Collapsible>\n <Collapsible>\n <Collapsible.Trigger>API Reference</Collapsible.Trigger>\n <Collapsible.Content>\n <p>Complete API documentation.</p>\n </Collapsible.Content>\n </Collapsible>\n</div>"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"relations": [
|
|
111
|
+
{
|
|
112
|
+
"component": "Accordion",
|
|
113
|
+
"relationship": "alternative",
|
|
114
|
+
"note": "Use Accordion for multiple exclusive collapsible sections"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"component": "Sidebar",
|
|
118
|
+
"relationship": "used-by",
|
|
119
|
+
"note": "Sidebar uses Collapsible for section expand/collapse"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"component": "Menu",
|
|
123
|
+
"relationship": "alternative",
|
|
124
|
+
"note": "Use Menu for dropdown navigation with actions"
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
"contract": {
|
|
128
|
+
"propsSummary": [
|
|
129
|
+
"defaultOpen: boolean - initial open state (default: false)",
|
|
130
|
+
"open: boolean - controlled open state",
|
|
131
|
+
"onOpenChange: (open: boolean) => void - state change callback",
|
|
132
|
+
"disabled: boolean - prevents interaction"
|
|
133
|
+
],
|
|
134
|
+
"a11yRules": [
|
|
135
|
+
"A11Y_EXPANDED_STATE",
|
|
136
|
+
"A11Y_REGION_LABEL",
|
|
137
|
+
"A11Y_KEYBOARD_NAV"
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
"ai": {
|
|
141
|
+
"compositionPattern": "compound",
|
|
142
|
+
"subComponents": [
|
|
143
|
+
"Root",
|
|
144
|
+
"Trigger",
|
|
145
|
+
"Content"
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
"provenance": {
|
|
149
|
+
"source": "migrated",
|
|
150
|
+
"verified": false,
|
|
151
|
+
"frameworkSupport": "native",
|
|
152
|
+
"extractedAt": "2026-03-13T23:18:52.800Z"
|
|
153
|
+
}
|
|
154
|
+
}
|