@fragments-sdk/cli 0.10.0 → 0.11.1
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/bin.js +26 -8
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-ZDA3PLQ6.js → chunk-5G3VZH43.js} +2 -2
- package/dist/{chunk-566BNPQZ.js → chunk-HRFUSSZI.js} +25 -6
- package/dist/chunk-HRFUSSZI.js.map +1 -0
- package/dist/{chunk-CAMXG5HJ.js → chunk-ZM4ZQZWZ.js} +2 -2
- package/dist/{generate-BGKTKO6E.js → generate-FBHSXR3D.js} +2 -2
- package/dist/index.js +2 -2
- package/dist/{init-Q53R5Q2T.js → init-UFGK5TCN.js} +77 -6
- package/dist/init-UFGK5TCN.js.map +1 -0
- package/dist/{scan-OQU7M4GH.js → scan-CJF2DOQW.js} +3 -3
- package/dist/{scan-generate-T5QNUG7N.js → scan-generate-SJAN5MVI.js} +2 -2
- package/dist/snapshot-SV2JOFZH.js +139 -0
- package/dist/snapshot-SV2JOFZH.js.map +1 -0
- package/dist/{test-2CSOSS3B.js → test-Z5LVO724.js} +2 -2
- package/dist/{tokens-DXEGYTOJ.js → tokens-CE46OTMD.js} +2 -2
- package/dist/{viewer-DBEPYM3G.js → viewer-DLLJIMCK.js} +69 -47
- package/dist/viewer-DLLJIMCK.js.map +1 -0
- package/package.json +6 -14
- package/src/bin.ts +30 -0
- package/src/commands/init.ts +76 -1
- package/src/commands/snapshot.ts +197 -0
- package/src/core/loader.ts +38 -8
- package/src/viewer/__tests__/viewer-integration.test.ts +85 -74
- package/src/viewer/server.ts +37 -22
- package/src/viewer/vite-plugin.ts +25 -9
- package/dist/chunk-566BNPQZ.js.map +0 -1
- package/dist/init-Q53R5Q2T.js.map +0 -1
- package/dist/viewer-DBEPYM3G.js.map +0 -1
- package/src/viewer/__tests__/a11y-fixes.test.ts +0 -358
- package/src/viewer/__tests__/jsx-parser.test.ts +0 -502
- package/src/viewer/__tests__/render-utils.test.ts +0 -232
- package/src/viewer/__tests__/style-utils.test.ts +0 -404
- package/src/viewer/assets/fragments-logo.ts +0 -4
- package/src/viewer/components/AccessibilityPanel.tsx +0 -1457
- package/src/viewer/components/ActionCapture.tsx +0 -172
- package/src/viewer/components/ActionsPanel.tsx +0 -332
- package/src/viewer/components/AllVariantsPreview.tsx +0 -78
- package/src/viewer/components/App.tsx +0 -582
- package/src/viewer/components/BottomPanel.tsx +0 -288
- package/src/viewer/components/CodePanel.naming.test.tsx +0 -59
- package/src/viewer/components/CodePanel.tsx +0 -118
- package/src/viewer/components/CommandPalette.tsx +0 -392
- package/src/viewer/components/ComponentDocView.tsx +0 -164
- package/src/viewer/components/ComponentGraph.tsx +0 -380
- package/src/viewer/components/ComponentHeader.tsx +0 -88
- package/src/viewer/components/ContractPanel.tsx +0 -241
- package/src/viewer/components/EmptyVariantMessage.tsx +0 -54
- package/src/viewer/components/ErrorBoundary.tsx +0 -97
- package/src/viewer/components/FigmaEmbed.tsx +0 -238
- package/src/viewer/components/FragmentEditor.tsx +0 -525
- package/src/viewer/components/FragmentRenderer.tsx +0 -61
- package/src/viewer/components/HeaderSearch.tsx +0 -24
- package/src/viewer/components/HealthDashboard.tsx +0 -441
- package/src/viewer/components/HmrStatusIndicator.tsx +0 -61
- package/src/viewer/components/Icons.tsx +0 -479
- package/src/viewer/components/InteractionsPanel.tsx +0 -757
- package/src/viewer/components/IsolatedPreviewFrame.tsx +0 -346
- package/src/viewer/components/IsolatedRender.tsx +0 -113
- package/src/viewer/components/KeyboardShortcutsHelp.tsx +0 -53
- package/src/viewer/components/LandingPage.tsx +0 -421
- package/src/viewer/components/Layout.tsx +0 -27
- package/src/viewer/components/LeftSidebar.tsx +0 -472
- package/src/viewer/components/LoadErrorMessage.tsx +0 -102
- package/src/viewer/components/MultiViewportPreview.tsx +0 -522
- package/src/viewer/components/NoVariantsMessage.tsx +0 -59
- package/src/viewer/components/PanelShell.tsx +0 -161
- package/src/viewer/components/PerformancePanel.tsx +0 -304
- package/src/viewer/components/PreviewArea.tsx +0 -472
- package/src/viewer/components/PreviewAside.tsx +0 -168
- package/src/viewer/components/PreviewFrameHost.tsx +0 -303
- package/src/viewer/components/PreviewPane.tsx +0 -149
- package/src/viewer/components/PreviewToolbar.tsx +0 -80
- package/src/viewer/components/PropsEditor.tsx +0 -506
- package/src/viewer/components/PropsTable.tsx +0 -111
- package/src/viewer/components/RelationsSection.tsx +0 -88
- package/src/viewer/components/ResizablePanel.tsx +0 -271
- package/src/viewer/components/RightSidebar.tsx +0 -102
- package/src/viewer/components/RuntimeToolsRegistrar.tsx +0 -17
- package/src/viewer/components/ScreenshotButton.tsx +0 -90
- package/src/viewer/components/Sidebar.tsx +0 -169
- package/src/viewer/components/SkeletonLoader.tsx +0 -161
- package/src/viewer/components/ThemeProvider.tsx +0 -42
- package/src/viewer/components/Toast.tsx +0 -3
- package/src/viewer/components/TokenStylePanel.tsx +0 -699
- package/src/viewer/components/TopToolbar.tsx +0 -159
- package/src/viewer/components/UsageSection.tsx +0 -95
- package/src/viewer/components/VariantMatrix.tsx +0 -388
- package/src/viewer/components/VariantRenderer.tsx +0 -131
- package/src/viewer/components/VariantTabs.tsx +0 -40
- package/src/viewer/components/ViewerHeader.tsx +0 -69
- package/src/viewer/components/ViewerStateSync.tsx +0 -52
- package/src/viewer/components/ViewportSelector.tsx +0 -172
- package/src/viewer/components/WebMCPDevTools.tsx +0 -503
- package/src/viewer/components/WebMCPIntegration.tsx +0 -47
- package/src/viewer/components/WebMCPStatusIndicator.tsx +0 -60
- package/src/viewer/components/_future/CreatePage.tsx +0 -836
- package/src/viewer/components/viewer-utils.ts +0 -16
- package/src/viewer/composition-renderer.ts +0 -381
- package/src/viewer/constants/index.ts +0 -1
- package/src/viewer/constants/ui.ts +0 -166
- package/src/viewer/entry.tsx +0 -335
- package/src/viewer/hooks/index.ts +0 -2
- package/src/viewer/hooks/useA11yCache.ts +0 -383
- package/src/viewer/hooks/useA11yService.ts +0 -364
- package/src/viewer/hooks/useActions.ts +0 -138
- package/src/viewer/hooks/useAppState.ts +0 -147
- package/src/viewer/hooks/useCompiledFragments.ts +0 -42
- package/src/viewer/hooks/useFigmaIntegration.ts +0 -132
- package/src/viewer/hooks/useHmrStatus.ts +0 -109
- package/src/viewer/hooks/useKeyboardShortcuts.ts +0 -270
- package/src/viewer/hooks/usePreviewBridge.ts +0 -347
- package/src/viewer/hooks/useScrollSpy.ts +0 -78
- package/src/viewer/hooks/useUrlState.ts +0 -318
- package/src/viewer/hooks/useViewSettings.ts +0 -111
- package/src/viewer/index.html +0 -28
- package/src/viewer/intelligence/healthReport.ts +0 -505
- package/src/viewer/intelligence/styleDrift.ts +0 -340
- package/src/viewer/intelligence/usageScanner.ts +0 -309
- package/src/viewer/jsx-parser.ts +0 -486
- package/src/viewer/preview-frame-entry.tsx +0 -25
- package/src/viewer/preview-frame.html +0 -125
- package/src/viewer/public/favicon.ico +0 -0
- package/src/viewer/render-template.html +0 -68
- package/src/viewer/styles/globals.css +0 -278
- package/src/viewer/types/a11y.ts +0 -197
- package/src/viewer/utils/a11y-fixes.ts +0 -509
- package/src/viewer/utils/actionExport.ts +0 -372
- package/src/viewer/utils/colorSchemes.ts +0 -201
- package/src/viewer/utils/detectRelationships.ts +0 -256
- package/src/viewer/vendor/shared/src/ComponentDocContent.module.scss +0 -10
- package/src/viewer/vendor/shared/src/ComponentDocContent.module.scss.d.ts +0 -2
- package/src/viewer/vendor/shared/src/ComponentDocContent.tsx +0 -274
- package/src/viewer/vendor/shared/src/DocsHeaderBar.tsx +0 -129
- package/src/viewer/vendor/shared/src/DocsPageAsideHost.tsx +0 -89
- package/src/viewer/vendor/shared/src/DocsPageShell.tsx +0 -124
- package/src/viewer/vendor/shared/src/DocsSearchCommand.tsx +0 -99
- package/src/viewer/vendor/shared/src/DocsSidebarNav.tsx +0 -66
- package/src/viewer/vendor/shared/src/PropsTable.module.scss +0 -68
- package/src/viewer/vendor/shared/src/PropsTable.module.scss.d.ts +0 -2
- package/src/viewer/vendor/shared/src/PropsTable.tsx +0 -76
- package/src/viewer/vendor/shared/src/VariantPreviewCard.module.scss +0 -114
- package/src/viewer/vendor/shared/src/VariantPreviewCard.module.scss.d.ts +0 -2
- package/src/viewer/vendor/shared/src/VariantPreviewCard.tsx +0 -134
- package/src/viewer/vendor/shared/src/docs-data/index.ts +0 -32
- package/src/viewer/vendor/shared/src/docs-data/mcp-configs.ts +0 -72
- package/src/viewer/vendor/shared/src/docs-data/palettes.ts +0 -75
- package/src/viewer/vendor/shared/src/docs-data/setup-examples.ts +0 -55
- package/src/viewer/vendor/shared/src/docs-layout.scss +0 -28
- package/src/viewer/vendor/shared/src/docs-layout.scss.d.ts +0 -2
- package/src/viewer/vendor/shared/src/index.ts +0 -34
- package/src/viewer/vendor/shared/src/types.ts +0 -53
- package/src/viewer/webmcp/__tests__/analytics.test.ts +0 -108
- package/src/viewer/webmcp/analytics.ts +0 -165
- package/src/viewer/webmcp/index.ts +0 -3
- package/src/viewer/webmcp/posthog-bridge.ts +0 -39
- package/src/viewer/webmcp/runtime-tools.ts +0 -152
- package/src/viewer/webmcp/scan-utils.ts +0 -135
- package/src/viewer/webmcp/use-tool-analytics.ts +0 -69
- package/src/viewer/webmcp/viewer-state.ts +0 -45
- /package/dist/{chunk-ZDA3PLQ6.js.map → chunk-5G3VZH43.js.map} +0 -0
- /package/dist/{chunk-CAMXG5HJ.js.map → chunk-ZM4ZQZWZ.js.map} +0 -0
- /package/dist/{generate-BGKTKO6E.js.map → generate-FBHSXR3D.js.map} +0 -0
- /package/dist/{scan-OQU7M4GH.js.map → scan-CJF2DOQW.js.map} +0 -0
- /package/dist/{scan-generate-T5QNUG7N.js.map → scan-generate-SJAN5MVI.js.map} +0 -0
- /package/dist/{test-2CSOSS3B.js.map → test-Z5LVO724.js.map} +0 -0
- /package/dist/{tokens-DXEGYTOJ.js.map → tokens-CE46OTMD.js.map} +0 -0
|
@@ -1,506 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import type { PropDefinition } from "../../core/index.js";
|
|
3
|
-
import { Box, Stack, Text, Button, Badge, Card, Input, Select, Toggle } from "@fragments-sdk/ui";
|
|
4
|
-
import { ControlsIcon, ChevronDownIcon, RefreshIcon } from "./Icons.js";
|
|
5
|
-
|
|
6
|
-
interface PropsEditorProps {
|
|
7
|
-
props: Record<string, PropDefinition>;
|
|
8
|
-
values: Record<string, unknown>;
|
|
9
|
-
onChange: (name: string, value: unknown) => void;
|
|
10
|
-
onReset: () => void;
|
|
11
|
-
hasChanges: boolean;
|
|
12
|
-
compact?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function PropsEditor({
|
|
16
|
-
props,
|
|
17
|
-
values,
|
|
18
|
-
onChange,
|
|
19
|
-
onReset,
|
|
20
|
-
hasChanges,
|
|
21
|
-
compact = false,
|
|
22
|
-
}: PropsEditorProps) {
|
|
23
|
-
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
24
|
-
const propEntries = Object.entries(props);
|
|
25
|
-
|
|
26
|
-
if (propEntries.length === 0) return null;
|
|
27
|
-
|
|
28
|
-
// Compact mode - show controls in a single horizontal line
|
|
29
|
-
if (compact) {
|
|
30
|
-
return (
|
|
31
|
-
<Stack gap="lg">
|
|
32
|
-
{propEntries.map(([name, prop]) => (
|
|
33
|
-
<PropControl
|
|
34
|
-
key={name}
|
|
35
|
-
name={name}
|
|
36
|
-
prop={prop}
|
|
37
|
-
value={values[name]}
|
|
38
|
-
onChange={(value) => onChange(name, value)}
|
|
39
|
-
compact
|
|
40
|
-
/>
|
|
41
|
-
))}
|
|
42
|
-
{hasChanges && (
|
|
43
|
-
<Button variant="ghost" size="sm" onClick={onReset}>
|
|
44
|
-
<RefreshIcon style={{ width: 12, height: 12 }} />
|
|
45
|
-
Reset
|
|
46
|
-
</Button>
|
|
47
|
-
)}
|
|
48
|
-
</Stack>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<Card>
|
|
54
|
-
{/* Header */}
|
|
55
|
-
<Button
|
|
56
|
-
variant="ghost"
|
|
57
|
-
fullWidth
|
|
58
|
-
onClick={() => setIsCollapsed(!isCollapsed)}
|
|
59
|
-
style={{ justifyContent: 'space-between', padding: '12px 16px', borderRadius: 0, borderBottom: '1px solid var(--border)' }}
|
|
60
|
-
>
|
|
61
|
-
<Stack direction="row" align="center" gap="sm">
|
|
62
|
-
<ControlsIcon style={{ width: 16, height: 16 }} />
|
|
63
|
-
<Text size="sm" weight="medium">Props Editor</Text>
|
|
64
|
-
{hasChanges && <Badge variant="info" size="sm">Modified</Badge>}
|
|
65
|
-
</Stack>
|
|
66
|
-
<ChevronDownIcon style={{ width: 16, height: 16, transition: 'transform 0.15s', transform: isCollapsed ? 'rotate(-90deg)' : 'rotate(0deg)' }} />
|
|
67
|
-
</Button>
|
|
68
|
-
|
|
69
|
-
{/* Content */}
|
|
70
|
-
{!isCollapsed && (
|
|
71
|
-
<Box padding="md">
|
|
72
|
-
<Stack gap="md">
|
|
73
|
-
{/* Reset button */}
|
|
74
|
-
{hasChanges && (
|
|
75
|
-
<Button variant="ghost" size="sm" onClick={onReset}>
|
|
76
|
-
<RefreshIcon style={{ width: 14, height: 14 }} />
|
|
77
|
-
Reset to defaults
|
|
78
|
-
</Button>
|
|
79
|
-
)}
|
|
80
|
-
|
|
81
|
-
{/* Prop controls */}
|
|
82
|
-
<Stack gap="sm">
|
|
83
|
-
{propEntries.map(([name, prop]) => (
|
|
84
|
-
<PropControl
|
|
85
|
-
key={name}
|
|
86
|
-
name={name}
|
|
87
|
-
prop={prop}
|
|
88
|
-
value={values[name]}
|
|
89
|
-
onChange={(value) => onChange(name, value)}
|
|
90
|
-
/>
|
|
91
|
-
))}
|
|
92
|
-
</Stack>
|
|
93
|
-
</Stack>
|
|
94
|
-
</Box>
|
|
95
|
-
)}
|
|
96
|
-
</Card>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
interface PropControlProps {
|
|
101
|
-
name: string;
|
|
102
|
-
prop: PropDefinition;
|
|
103
|
-
value: unknown;
|
|
104
|
-
onChange: (value: unknown) => void;
|
|
105
|
-
compact?: boolean;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Determine which control to render based on prop type and controlType
|
|
110
|
-
*/
|
|
111
|
-
function getControlForProp(
|
|
112
|
-
prop: PropDefinition,
|
|
113
|
-
displayValue: unknown,
|
|
114
|
-
onChange: (value: unknown) => void,
|
|
115
|
-
compact: boolean = false
|
|
116
|
-
) {
|
|
117
|
-
// Check controlType first for special controls (color, date, range)
|
|
118
|
-
if (prop.controlType === "color") {
|
|
119
|
-
return (
|
|
120
|
-
<ColorControl
|
|
121
|
-
value={displayValue as string}
|
|
122
|
-
onChange={onChange}
|
|
123
|
-
presetColors={prop.controlOptions?.presetColors}
|
|
124
|
-
/>
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (prop.controlType === "date") {
|
|
129
|
-
return <DateControl value={displayValue as string} onChange={onChange} />;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (prop.controlType === "range") {
|
|
133
|
-
return (
|
|
134
|
-
<RangeControl
|
|
135
|
-
value={displayValue as number}
|
|
136
|
-
onChange={onChange}
|
|
137
|
-
min={prop.controlOptions?.min}
|
|
138
|
-
max={prop.controlOptions?.max}
|
|
139
|
-
step={prop.controlOptions?.step}
|
|
140
|
-
/>
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Fall back to type-based controls
|
|
145
|
-
if (prop.type === "boolean") {
|
|
146
|
-
return <BooleanControl value={displayValue as boolean} onChange={onChange} />;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (prop.type === "enum" && prop.values) {
|
|
150
|
-
return (
|
|
151
|
-
<EnumControl
|
|
152
|
-
value={displayValue as string}
|
|
153
|
-
values={prop.values as string[]}
|
|
154
|
-
onChange={onChange}
|
|
155
|
-
/>
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (prop.type === "number") {
|
|
160
|
-
return <NumberControl value={displayValue as number} onChange={onChange} />;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (prop.type === "string") {
|
|
164
|
-
return <StringControl value={displayValue as string} onChange={onChange} compact={compact} />;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (prop.type === "function") {
|
|
168
|
-
return <FunctionControl value={displayValue} onChange={onChange} />;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return <StringControl value={String(displayValue)} onChange={onChange} compact={compact} />;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function PropControl({
|
|
175
|
-
name,
|
|
176
|
-
prop,
|
|
177
|
-
value,
|
|
178
|
-
onChange,
|
|
179
|
-
compact = false,
|
|
180
|
-
}: PropControlProps) {
|
|
181
|
-
const displayValue = value ?? prop.default ?? "";
|
|
182
|
-
|
|
183
|
-
if (compact) {
|
|
184
|
-
return (
|
|
185
|
-
<Stack direction="row" gap="sm">
|
|
186
|
-
<Text as="label" size="xs" weight="medium" font="mono" style={{ whiteSpace: 'nowrap', minWidth: '100px' }} color="secondary">
|
|
187
|
-
{name}
|
|
188
|
-
</Text>
|
|
189
|
-
{getControlForProp(prop, displayValue, onChange, true)}
|
|
190
|
-
</Stack>
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return (
|
|
195
|
-
<Stack gap="sm">
|
|
196
|
-
<Stack direction="row" align="center" gap="sm">
|
|
197
|
-
<Text as="label" size="xs" weight="medium" font="mono">
|
|
198
|
-
{name}
|
|
199
|
-
{prop.required && (
|
|
200
|
-
<span style={{ color: 'var(--color-danger, #ef4444)', marginLeft: '2px' }}>*</span>
|
|
201
|
-
)}
|
|
202
|
-
</Text>
|
|
203
|
-
<Text size="xs" color="tertiary">{prop.type}</Text>
|
|
204
|
-
{prop.controlType && prop.controlType !== prop.type && (
|
|
205
|
-
<Badge size="sm">{prop.controlType}</Badge>
|
|
206
|
-
)}
|
|
207
|
-
</Stack>
|
|
208
|
-
|
|
209
|
-
{getControlForProp(prop, displayValue, onChange, false)}
|
|
210
|
-
|
|
211
|
-
{prop.description && (
|
|
212
|
-
<Text as="p" size="xs" color="tertiary" style={{ lineHeight: 1.6 }}>
|
|
213
|
-
{prop.description}
|
|
214
|
-
</Text>
|
|
215
|
-
)}
|
|
216
|
-
</Stack>
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function BooleanControl({
|
|
221
|
-
value,
|
|
222
|
-
onChange,
|
|
223
|
-
}: {
|
|
224
|
-
value: boolean;
|
|
225
|
-
onChange: (v: boolean) => void;
|
|
226
|
-
}) {
|
|
227
|
-
return (
|
|
228
|
-
<Toggle
|
|
229
|
-
checked={value}
|
|
230
|
-
onChange={() => onChange(!value)}
|
|
231
|
-
/>
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function EnumControl({
|
|
236
|
-
value,
|
|
237
|
-
values,
|
|
238
|
-
onChange,
|
|
239
|
-
}: {
|
|
240
|
-
value: string;
|
|
241
|
-
values: string[];
|
|
242
|
-
onChange: (v: string) => void;
|
|
243
|
-
}) {
|
|
244
|
-
return (
|
|
245
|
-
<Select
|
|
246
|
-
value={value}
|
|
247
|
-
onChange={(e: React.ChangeEvent<HTMLSelectElement>) => onChange(e.target.value)}
|
|
248
|
-
>
|
|
249
|
-
{values.map((v) => (
|
|
250
|
-
<option key={v} value={v}>
|
|
251
|
-
{v}
|
|
252
|
-
</option>
|
|
253
|
-
))}
|
|
254
|
-
</Select>
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function NumberControl({
|
|
259
|
-
value,
|
|
260
|
-
onChange,
|
|
261
|
-
}: {
|
|
262
|
-
value: number;
|
|
263
|
-
onChange: (v: number) => void;
|
|
264
|
-
}) {
|
|
265
|
-
return (
|
|
266
|
-
<Input
|
|
267
|
-
type="number"
|
|
268
|
-
value={value ?? ""}
|
|
269
|
-
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
|
|
270
|
-
onChange(
|
|
271
|
-
e.target.value
|
|
272
|
-
? Number(e.target.value)
|
|
273
|
-
: (undefined as unknown as number)
|
|
274
|
-
)
|
|
275
|
-
}
|
|
276
|
-
style={{ width: '128px', fontFamily: 'monospace' }}
|
|
277
|
-
/>
|
|
278
|
-
);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
function StringControl({
|
|
282
|
-
value,
|
|
283
|
-
onChange,
|
|
284
|
-
compact = false,
|
|
285
|
-
}: {
|
|
286
|
-
value: string;
|
|
287
|
-
onChange: (v: string) => void;
|
|
288
|
-
compact?: boolean;
|
|
289
|
-
}) {
|
|
290
|
-
return (
|
|
291
|
-
<Input
|
|
292
|
-
type="text"
|
|
293
|
-
value={value ?? ""}
|
|
294
|
-
onChange={(e: React.ChangeEvent<HTMLInputElement>) => onChange(e.target.value)}
|
|
295
|
-
style={compact
|
|
296
|
-
? { width: '96px', fontSize: '11px', fontFamily: 'monospace' }
|
|
297
|
-
: { width: '100%', maxWidth: '320px', fontFamily: 'monospace' }
|
|
298
|
-
}
|
|
299
|
-
/>
|
|
300
|
-
);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
function FunctionControl({
|
|
304
|
-
value,
|
|
305
|
-
onChange,
|
|
306
|
-
}: {
|
|
307
|
-
value: unknown;
|
|
308
|
-
onChange: (v: unknown) => void;
|
|
309
|
-
}) {
|
|
310
|
-
const [isEditing, setIsEditing] = useState(false);
|
|
311
|
-
const [inputValue, setInputValue] = useState('');
|
|
312
|
-
|
|
313
|
-
// Get a display string for the function
|
|
314
|
-
const getDisplayValue = () => {
|
|
315
|
-
if (typeof value === 'function') {
|
|
316
|
-
const fnStr = value.toString();
|
|
317
|
-
// Truncate if too long
|
|
318
|
-
if (fnStr.length > 50) {
|
|
319
|
-
return fnStr.slice(0, 47) + '...';
|
|
320
|
-
}
|
|
321
|
-
return fnStr;
|
|
322
|
-
}
|
|
323
|
-
if (typeof value === 'string' && value.trim()) {
|
|
324
|
-
return value;
|
|
325
|
-
}
|
|
326
|
-
return '() => {}';
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
const handleStartEdit = () => {
|
|
330
|
-
// Convert function to string for editing
|
|
331
|
-
if (typeof value === 'function') {
|
|
332
|
-
setInputValue(value.toString());
|
|
333
|
-
} else if (typeof value === 'string') {
|
|
334
|
-
setInputValue(value);
|
|
335
|
-
} else {
|
|
336
|
-
setInputValue('() => {}');
|
|
337
|
-
}
|
|
338
|
-
setIsEditing(true);
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
const handleSave = () => {
|
|
342
|
-
// Save as string - the parent will handle conversion
|
|
343
|
-
onChange(inputValue);
|
|
344
|
-
setIsEditing(false);
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
const handleCancel = () => {
|
|
348
|
-
setIsEditing(false);
|
|
349
|
-
setInputValue('');
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
if (isEditing) {
|
|
353
|
-
return (
|
|
354
|
-
<Stack gap="sm" style={{ flex: 1 }}>
|
|
355
|
-
<textarea
|
|
356
|
-
value={inputValue}
|
|
357
|
-
onChange={(e) => setInputValue(e.target.value)}
|
|
358
|
-
style={{
|
|
359
|
-
width: '100%',
|
|
360
|
-
padding: '6px 8px',
|
|
361
|
-
fontSize: '11px',
|
|
362
|
-
fontFamily: 'monospace',
|
|
363
|
-
background: 'var(--bg-primary)',
|
|
364
|
-
border: '1px solid var(--border)',
|
|
365
|
-
borderRadius: '4px',
|
|
366
|
-
color: 'var(--text-primary)',
|
|
367
|
-
outline: 'none',
|
|
368
|
-
resize: 'vertical',
|
|
369
|
-
minHeight: '60px',
|
|
370
|
-
}}
|
|
371
|
-
placeholder="() => console.log('clicked')"
|
|
372
|
-
autoFocus
|
|
373
|
-
/>
|
|
374
|
-
<Stack direction="row" gap="sm">
|
|
375
|
-
<Button variant="primary" size="sm" onClick={handleSave}>Apply</Button>
|
|
376
|
-
<Button variant="ghost" size="sm" onClick={handleCancel}>Cancel</Button>
|
|
377
|
-
</Stack>
|
|
378
|
-
</Stack>
|
|
379
|
-
);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
return (
|
|
383
|
-
<button
|
|
384
|
-
onClick={handleStartEdit}
|
|
385
|
-
style={{
|
|
386
|
-
padding: '6px 10px',
|
|
387
|
-
fontSize: '11px',
|
|
388
|
-
fontFamily: 'monospace',
|
|
389
|
-
color: 'var(--text-tertiary)',
|
|
390
|
-
background: 'var(--bg-secondary)',
|
|
391
|
-
borderRadius: '6px',
|
|
392
|
-
width: 'fit-content',
|
|
393
|
-
textAlign: 'left',
|
|
394
|
-
transition: 'background 0.15s',
|
|
395
|
-
cursor: 'pointer',
|
|
396
|
-
border: 'none',
|
|
397
|
-
}}
|
|
398
|
-
title="Click to edit function"
|
|
399
|
-
>
|
|
400
|
-
{getDisplayValue()}
|
|
401
|
-
</button>
|
|
402
|
-
);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
function ColorControl({
|
|
406
|
-
value,
|
|
407
|
-
onChange,
|
|
408
|
-
presetColors,
|
|
409
|
-
}: {
|
|
410
|
-
value: string;
|
|
411
|
-
onChange: (v: string) => void;
|
|
412
|
-
presetColors?: string[];
|
|
413
|
-
}) {
|
|
414
|
-
return (
|
|
415
|
-
<Stack direction="row" align="center" gap="sm">
|
|
416
|
-
<input
|
|
417
|
-
type="color"
|
|
418
|
-
value={value || "#000000"}
|
|
419
|
-
onChange={(e) => onChange(e.target.value)}
|
|
420
|
-
style={{ width: '32px', height: '32px', borderRadius: '4px', border: '1px solid var(--border)', cursor: 'pointer', background: 'transparent' }}
|
|
421
|
-
/>
|
|
422
|
-
<Input
|
|
423
|
-
type="text"
|
|
424
|
-
value={value ?? ""}
|
|
425
|
-
onChange={(e: React.ChangeEvent<HTMLInputElement>) => onChange(e.target.value)}
|
|
426
|
-
placeholder="#000000"
|
|
427
|
-
style={{ width: '96px', fontSize: '11px', fontFamily: 'monospace' }}
|
|
428
|
-
/>
|
|
429
|
-
{presetColors && presetColors.length > 0 && (
|
|
430
|
-
<Stack direction="row" gap="xs" wrap>
|
|
431
|
-
{presetColors.slice(0, 6).map((color) => (
|
|
432
|
-
<button
|
|
433
|
-
key={color}
|
|
434
|
-
onClick={() => onChange(color)}
|
|
435
|
-
style={{
|
|
436
|
-
width: '20px',
|
|
437
|
-
height: '20px',
|
|
438
|
-
borderRadius: '4px',
|
|
439
|
-
border: '1px solid var(--border)',
|
|
440
|
-
backgroundColor: color,
|
|
441
|
-
cursor: 'pointer',
|
|
442
|
-
padding: 0,
|
|
443
|
-
}}
|
|
444
|
-
title={color}
|
|
445
|
-
/>
|
|
446
|
-
))}
|
|
447
|
-
</Stack>
|
|
448
|
-
)}
|
|
449
|
-
</Stack>
|
|
450
|
-
);
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
function DateControl({
|
|
454
|
-
value,
|
|
455
|
-
onChange,
|
|
456
|
-
}: {
|
|
457
|
-
value: string;
|
|
458
|
-
onChange: (v: string) => void;
|
|
459
|
-
}) {
|
|
460
|
-
// Convert ISO string to datetime-local format for input
|
|
461
|
-
const inputValue = value
|
|
462
|
-
? new Date(value).toISOString().slice(0, 16)
|
|
463
|
-
: "";
|
|
464
|
-
|
|
465
|
-
return (
|
|
466
|
-
<Input
|
|
467
|
-
type="datetime-local"
|
|
468
|
-
value={inputValue}
|
|
469
|
-
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
470
|
-
const date = e.target.value ? new Date(e.target.value).toISOString() : "";
|
|
471
|
-
onChange(date);
|
|
472
|
-
}}
|
|
473
|
-
/>
|
|
474
|
-
);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
function RangeControl({
|
|
478
|
-
value,
|
|
479
|
-
onChange,
|
|
480
|
-
min = 0,
|
|
481
|
-
max = 100,
|
|
482
|
-
step = 1,
|
|
483
|
-
}: {
|
|
484
|
-
value: number;
|
|
485
|
-
onChange: (v: number) => void;
|
|
486
|
-
min?: number;
|
|
487
|
-
max?: number;
|
|
488
|
-
step?: number;
|
|
489
|
-
}) {
|
|
490
|
-
return (
|
|
491
|
-
<Stack direction="row" align="center" gap="sm">
|
|
492
|
-
<input
|
|
493
|
-
type="range"
|
|
494
|
-
value={value ?? min}
|
|
495
|
-
min={min}
|
|
496
|
-
max={max}
|
|
497
|
-
step={step}
|
|
498
|
-
onChange={(e) => onChange(Number(e.target.value))}
|
|
499
|
-
style={{ flex: 1, height: '8px', background: 'var(--bg-secondary)', borderRadius: '8px', cursor: 'pointer', accentColor: 'var(--color-accent)' }}
|
|
500
|
-
/>
|
|
501
|
-
<Text size="xs" font="mono" color="secondary" style={{ minWidth: '3rem', textAlign: 'right' }}>
|
|
502
|
-
{value ?? min}
|
|
503
|
-
</Text>
|
|
504
|
-
</Stack>
|
|
505
|
-
);
|
|
506
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import type { PropDefinition } from '../../core/index.js';
|
|
3
|
-
import { DataTable, createColumns, Badge, Text, Stack } from '@fragments-sdk/ui';
|
|
4
|
-
import { WarningIcon } from './Icons.js';
|
|
5
|
-
|
|
6
|
-
interface PropsTableProps {
|
|
7
|
-
props: Record<string, PropDefinition>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface PropRow {
|
|
11
|
-
name: string;
|
|
12
|
-
required: boolean;
|
|
13
|
-
type: string;
|
|
14
|
-
values?: string[];
|
|
15
|
-
default: unknown;
|
|
16
|
-
description: string;
|
|
17
|
-
constraints?: string[];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function PropsTable({ props }: PropsTableProps) {
|
|
21
|
-
const propEntries = Object.entries(props);
|
|
22
|
-
|
|
23
|
-
const data = useMemo<PropRow[]>(() =>
|
|
24
|
-
propEntries.map(([name, prop]) => ({
|
|
25
|
-
name,
|
|
26
|
-
required: !!prop.required,
|
|
27
|
-
type: prop.type,
|
|
28
|
-
values: prop.values,
|
|
29
|
-
default: prop.default,
|
|
30
|
-
description: prop.description,
|
|
31
|
-
constraints: prop.constraints,
|
|
32
|
-
})),
|
|
33
|
-
[propEntries]
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const columns = useMemo(() => createColumns<PropRow>([
|
|
37
|
-
{
|
|
38
|
-
key: 'name',
|
|
39
|
-
header: 'Prop',
|
|
40
|
-
cell: (row) => (
|
|
41
|
-
<Text font="mono" size="sm" weight="medium">
|
|
42
|
-
{row.name}
|
|
43
|
-
{row.required && <span style={{ color: 'var(--color-danger, #ef4444)', marginLeft: '2px' }}>*</span>}
|
|
44
|
-
</Text>
|
|
45
|
-
),
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
key: 'type',
|
|
49
|
-
header: 'Type',
|
|
50
|
-
cell: (row) => {
|
|
51
|
-
if (row.type === 'enum' && row.values && row.values.length > 0) {
|
|
52
|
-
return (
|
|
53
|
-
<Stack direction="row" gap="xs" style={{ flexWrap: 'wrap' }}>
|
|
54
|
-
{row.values.map((value, index) => (
|
|
55
|
-
<span key={value} style={{ display: 'inline-flex', alignItems: 'center' }}>
|
|
56
|
-
<Badge size="sm">{value}</Badge>
|
|
57
|
-
{index < row.values!.length - 1 && <Text size="xs" color="tertiary" style={{ margin: '0 4px' }}>|</Text>}
|
|
58
|
-
</span>
|
|
59
|
-
))}
|
|
60
|
-
</Stack>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
return <Text font="mono" size="xs" color="secondary">{row.type}</Text>;
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
key: 'default',
|
|
68
|
-
header: 'Default',
|
|
69
|
-
cell: (row) => {
|
|
70
|
-
if (row.default !== undefined) {
|
|
71
|
-
return <Text font="mono" size="xs" color="secondary">{String(row.default)}</Text>;
|
|
72
|
-
}
|
|
73
|
-
return <Text color="tertiary">—</Text>;
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
key: 'description',
|
|
78
|
-
header: 'Description',
|
|
79
|
-
cell: (row) => (
|
|
80
|
-
<Stack gap="xs">
|
|
81
|
-
<Text size="sm" color="secondary">{row.description}</Text>
|
|
82
|
-
{row.constraints && row.constraints.length > 0 && (
|
|
83
|
-
<Stack gap="xs">
|
|
84
|
-
{row.constraints.map((constraint, index) => (
|
|
85
|
-
<Stack key={index} direction="row" gap="xs" align="start" style={{ fontSize: '12px', color: 'var(--color-warning, #f59e0b)' }}>
|
|
86
|
-
<WarningIcon style={{ width: 12, height: 12, marginTop: '2px', flexShrink: 0 }} />
|
|
87
|
-
<span>{constraint}</span>
|
|
88
|
-
</Stack>
|
|
89
|
-
))}
|
|
90
|
-
</Stack>
|
|
91
|
-
)}
|
|
92
|
-
</Stack>
|
|
93
|
-
),
|
|
94
|
-
},
|
|
95
|
-
]), []);
|
|
96
|
-
|
|
97
|
-
if (propEntries.length === 0) return null;
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<section id="props" style={{ scrollMarginTop: '96px' }}>
|
|
101
|
-
<Text as="h2" size="md" weight="semibold" style={{ marginBottom: '16px' }}>Props</Text>
|
|
102
|
-
<DataTable
|
|
103
|
-
columns={columns}
|
|
104
|
-
data={data}
|
|
105
|
-
size="sm"
|
|
106
|
-
bordered
|
|
107
|
-
getRowId={(row) => row.name}
|
|
108
|
-
/>
|
|
109
|
-
</section>
|
|
110
|
-
);
|
|
111
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import type { ComponentRelation } from '../../core/index.js';
|
|
3
|
-
import { getRelationshipConfig } from '../constants/ui.js';
|
|
4
|
-
import { ChevronRightIcon } from './Icons.js';
|
|
5
|
-
|
|
6
|
-
interface RelationsSectionProps {
|
|
7
|
-
relations: ComponentRelation[];
|
|
8
|
-
onNavigate?: (componentName: string) => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function RelationsSection({ relations, onNavigate }: RelationsSectionProps) {
|
|
12
|
-
if (relations.length === 0) return null;
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<section id="relations" style={{ scrollMarginTop: '96px' }}>
|
|
16
|
-
<h2 style={{ fontSize: '16px', fontWeight: 600, color: 'var(--text-primary)', marginBottom: '16px' }}>Related Components</h2>
|
|
17
|
-
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(280px, 1fr))', gap: '12px' }}>
|
|
18
|
-
{relations.map((relation, index) => (
|
|
19
|
-
<RelationButton key={index} relation={relation} onNavigate={onNavigate} />
|
|
20
|
-
))}
|
|
21
|
-
</div>
|
|
22
|
-
</section>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function RelationButton({ relation, onNavigate }: { relation: ComponentRelation; onNavigate?: (componentName: string) => void }) {
|
|
27
|
-
const config = getRelationshipConfig(relation.relationship);
|
|
28
|
-
const [hovered, setHovered] = useState(false);
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<button
|
|
32
|
-
onClick={() => onNavigate?.(relation.component)}
|
|
33
|
-
onMouseEnter={() => setHovered(true)}
|
|
34
|
-
onMouseLeave={() => setHovered(false)}
|
|
35
|
-
style={{
|
|
36
|
-
textAlign: 'left',
|
|
37
|
-
padding: '16px',
|
|
38
|
-
borderRadius: '12px',
|
|
39
|
-
border: `1px solid ${hovered ? 'var(--border-strong)' : 'var(--border)'}`,
|
|
40
|
-
background: 'var(--bg-elevated)',
|
|
41
|
-
transition: 'all 150ms',
|
|
42
|
-
cursor: 'pointer',
|
|
43
|
-
outline: 'none',
|
|
44
|
-
}}
|
|
45
|
-
>
|
|
46
|
-
<div style={{ display: 'flex', alignItems: 'center', gap: '8px', marginBottom: '6px' }}>
|
|
47
|
-
<span style={{
|
|
48
|
-
fontSize: '13px',
|
|
49
|
-
fontWeight: 500,
|
|
50
|
-
color: hovered ? 'var(--color-accent)' : 'var(--text-primary)',
|
|
51
|
-
transition: 'color 150ms',
|
|
52
|
-
}}>
|
|
53
|
-
{relation.component}
|
|
54
|
-
</span>
|
|
55
|
-
<span style={{
|
|
56
|
-
fontSize: '10px',
|
|
57
|
-
fontWeight: 500,
|
|
58
|
-
padding: '2px 6px',
|
|
59
|
-
borderRadius: '4px',
|
|
60
|
-
background: config.bgColor ?? 'var(--bg-tertiary)',
|
|
61
|
-
color: config.textColor ?? 'var(--text-secondary)',
|
|
62
|
-
}}>
|
|
63
|
-
{config.label}
|
|
64
|
-
</span>
|
|
65
|
-
</div>
|
|
66
|
-
{relation.note && (
|
|
67
|
-
<p style={{ fontSize: '13px', color: 'var(--text-secondary)', lineHeight: 1.6, margin: 0 }}>{relation.note}</p>
|
|
68
|
-
)}
|
|
69
|
-
<div style={{
|
|
70
|
-
marginTop: '8px',
|
|
71
|
-
display: 'flex',
|
|
72
|
-
alignItems: 'center',
|
|
73
|
-
fontSize: '12px',
|
|
74
|
-
color: hovered ? 'var(--text-secondary)' : 'var(--text-tertiary)',
|
|
75
|
-
transition: 'color 150ms',
|
|
76
|
-
}}>
|
|
77
|
-
<span>View component</span>
|
|
78
|
-
<ChevronRightIcon style={{
|
|
79
|
-
width: '12px',
|
|
80
|
-
height: '12px',
|
|
81
|
-
marginLeft: '4px',
|
|
82
|
-
transform: hovered ? 'translateX(2px)' : 'translateX(0)',
|
|
83
|
-
transition: 'transform 150ms',
|
|
84
|
-
}} />
|
|
85
|
-
</div>
|
|
86
|
-
</button>
|
|
87
|
-
);
|
|
88
|
-
}
|