@fragments-sdk/cli 0.10.1 → 0.12.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/ai-client-I6MDWNYA.js +21 -0
- package/dist/bin.js +292 -367
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-PW7QTQA6.js → chunk-4OC7FTJB.js} +2 -2
- package/dist/{chunk-HRFUSSZI.js → chunk-AM4MRTMN.js} +2 -2
- package/dist/{chunk-5G3VZH43.js → chunk-GVDSFQ4E.js} +281 -351
- package/dist/chunk-GVDSFQ4E.js.map +1 -0
- package/dist/chunk-JJ2VRTBU.js +626 -0
- package/dist/chunk-JJ2VRTBU.js.map +1 -0
- package/dist/{chunk-D5PYOXEI.js → chunk-LVWFOLUZ.js} +148 -13
- package/dist/{chunk-D5PYOXEI.js.map → chunk-LVWFOLUZ.js.map} +1 -1
- package/dist/{chunk-WXSR2II7.js → chunk-OQKMEFOS.js} +58 -6
- package/dist/chunk-OQKMEFOS.js.map +1 -0
- package/dist/chunk-SXTKFDCR.js +104 -0
- package/dist/chunk-SXTKFDCR.js.map +1 -0
- package/dist/chunk-T5OMVL7E.js +443 -0
- package/dist/chunk-T5OMVL7E.js.map +1 -0
- package/dist/{chunk-ZM4ZQZWZ.js → chunk-TPWGL2XS.js} +39 -37
- package/dist/chunk-TPWGL2XS.js.map +1 -0
- package/dist/{chunk-OQO55NKV.js → chunk-WFS63PCW.js} +85 -11
- package/dist/chunk-WFS63PCW.js.map +1 -0
- package/dist/core/index.js +9 -1
- package/dist/{discovery-NEOY4MPN.js → discovery-ZJQSXF56.js} +3 -3
- package/dist/{generate-FBHSXR3D.js → generate-RJFS2JWA.js} +4 -4
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/init-ZSX3NRCZ.js +636 -0
- package/dist/init-ZSX3NRCZ.js.map +1 -0
- package/dist/mcp-bin.js +2 -2
- package/dist/{scan-CJF2DOQW.js → scan-3PMCJ4RB.js} +6 -6
- package/dist/scan-generate-SYU4PYZD.js +1115 -0
- package/dist/scan-generate-SYU4PYZD.js.map +1 -0
- package/dist/{service-TQYWY65E.js → service-VMGNJZ42.js} +3 -3
- package/dist/snapshot-XOISO2IS.js +139 -0
- package/dist/snapshot-XOISO2IS.js.map +1 -0
- package/dist/{static-viewer-NUBFPKWH.js → static-viewer-5GXH2MGE.js} +3 -3
- package/dist/static-viewer-5GXH2MGE.js.map +1 -0
- package/dist/{test-Z5LVO724.js → test-SI4NSHQX.js} +4 -4
- package/dist/{tokens-CE46OTMD.js → tokens-T6SIVUT5.js} +5 -5
- package/dist/{viewer-DNMNC5VS.js → viewer-7ZEAFBVN.js} +80 -58
- package/dist/viewer-7ZEAFBVN.js.map +1 -0
- package/package.json +6 -14
- package/src/ai-client.ts +156 -0
- package/src/bin.ts +74 -2
- package/src/build.ts +95 -33
- package/src/commands/__tests__/drift-sync.test.ts +252 -0
- package/src/commands/__tests__/scan-generate.test.ts +497 -45
- package/src/commands/enhance.ts +11 -35
- package/src/commands/init.ts +296 -193
- package/src/commands/scan-generate.ts +740 -139
- package/src/commands/scan.ts +37 -32
- package/src/commands/setup.ts +143 -52
- package/src/commands/snapshot.ts +197 -0
- package/src/commands/sync.ts +357 -0
- package/src/commands/validate.ts +43 -1
- package/src/core/component-extractor.test.ts +282 -0
- package/src/core/component-extractor.ts +1030 -0
- package/src/core/discovery.ts +93 -7
- package/src/service/enhance/props-extractor.ts +235 -13
- package/src/validators.ts +236 -0
- 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-5G3VZH43.js.map +0 -1
- package/dist/chunk-OQO55NKV.js.map +0 -1
- package/dist/chunk-WXSR2II7.js.map +0 -1
- package/dist/chunk-ZM4ZQZWZ.js.map +0 -1
- package/dist/init-NDQXUWDU.js +0 -796
- package/dist/init-NDQXUWDU.js.map +0 -1
- package/dist/scan-generate-SJAN5MVI.js +0 -691
- package/dist/scan-generate-SJAN5MVI.js.map +0 -1
- package/dist/viewer-DNMNC5VS.js.map +0 -1
- package/src/ai.ts +0 -266
- package/src/commands/init-framework.ts +0 -414
- package/src/mcp/bin.ts +0 -36
- package/src/migrate/bin.ts +0 -114
- package/src/theme/index.ts +0 -77
- 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/assets/fragments_logo.png +0 -0
- package/src/viewer/bin.ts +0 -86
- package/src/viewer/cli/health.ts +0 -256
- package/src/viewer/cli/index.ts +0 -33
- package/src/viewer/cli/scan.ts +0 -124
- package/src/viewer/cli/utils.ts +0 -174
- 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 -137
- 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/{discovery-NEOY4MPN.js.map → ai-client-I6MDWNYA.js.map} +0 -0
- /package/dist/{chunk-PW7QTQA6.js.map → chunk-4OC7FTJB.js.map} +0 -0
- /package/dist/{chunk-HRFUSSZI.js.map → chunk-AM4MRTMN.js.map} +0 -0
- /package/dist/{scan-CJF2DOQW.js.map → discovery-ZJQSXF56.js.map} +0 -0
- /package/dist/{generate-FBHSXR3D.js.map → generate-RJFS2JWA.js.map} +0 -0
- /package/dist/{service-TQYWY65E.js.map → scan-3PMCJ4RB.js.map} +0 -0
- /package/dist/{static-viewer-NUBFPKWH.js.map → service-VMGNJZ42.js.map} +0 -0
- /package/dist/{test-Z5LVO724.js.map → test-SI4NSHQX.js.map} +0 -0
- /package/dist/{tokens-CE46OTMD.js.map → tokens-T6SIVUT5.js.map} +0 -0
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ResizablePanel - A bottom-docked panel that can be resized by dragging
|
|
3
|
-
*
|
|
4
|
-
* Features:
|
|
5
|
-
* - Drag-to-resize from the top edge
|
|
6
|
-
* - Collapsible via chevron toggle
|
|
7
|
-
* - Persists size and open state to localStorage
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
useState,
|
|
12
|
-
useEffect,
|
|
13
|
-
useCallback,
|
|
14
|
-
useRef,
|
|
15
|
-
type ReactNode,
|
|
16
|
-
type CSSProperties,
|
|
17
|
-
} from "react";
|
|
18
|
-
import { BRAND } from "../../core/index.js";
|
|
19
|
-
import { ChevronDownIcon } from "./Icons.js";
|
|
20
|
-
import { Box, Stack, Button } from "@fragments-sdk/ui";
|
|
21
|
-
|
|
22
|
-
// Storage key for persisting panel state
|
|
23
|
-
const STORAGE_KEY = `${BRAND.storagePrefix}panel-state`;
|
|
24
|
-
|
|
25
|
-
interface PanelState {
|
|
26
|
-
height: number;
|
|
27
|
-
isOpen: boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const DEFAULT_STATE: PanelState = {
|
|
31
|
-
height: 180,
|
|
32
|
-
isOpen: true,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const MIN_HEIGHT = 120;
|
|
36
|
-
const MAX_HEIGHT = 600;
|
|
37
|
-
|
|
38
|
-
function loadPanelState(): PanelState {
|
|
39
|
-
try {
|
|
40
|
-
const stored = localStorage.getItem(STORAGE_KEY);
|
|
41
|
-
if (stored) {
|
|
42
|
-
const parsed = JSON.parse(stored);
|
|
43
|
-
return { ...DEFAULT_STATE, ...parsed };
|
|
44
|
-
}
|
|
45
|
-
} catch {
|
|
46
|
-
// Ignore parse errors
|
|
47
|
-
}
|
|
48
|
-
return DEFAULT_STATE;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function savePanelState(state: PanelState): void {
|
|
52
|
-
try {
|
|
53
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(state));
|
|
54
|
-
} catch {
|
|
55
|
-
// Ignore storage errors
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
interface ResizablePanelProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
60
|
-
/** Panel header content (tabs, title, etc.) */
|
|
61
|
-
header: ReactNode;
|
|
62
|
-
/** Panel body content */
|
|
63
|
-
children: ReactNode;
|
|
64
|
-
/** Whether to show the panel at all */
|
|
65
|
-
visible?: boolean;
|
|
66
|
-
/** Additional class name for the panel container */
|
|
67
|
-
className?: string;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function ResizablePanel({
|
|
71
|
-
header,
|
|
72
|
-
children,
|
|
73
|
-
visible = true,
|
|
74
|
-
className,
|
|
75
|
-
...props
|
|
76
|
-
}: ResizablePanelProps) {
|
|
77
|
-
const [state, setState] = useState<PanelState>(loadPanelState);
|
|
78
|
-
const [isResizing, setIsResizing] = useState(false);
|
|
79
|
-
const panelRef = useRef<HTMLDivElement>(null);
|
|
80
|
-
const startYRef = useRef(0);
|
|
81
|
-
const startHeightRef = useRef(0);
|
|
82
|
-
|
|
83
|
-
// Save state changes to localStorage
|
|
84
|
-
useEffect(() => {
|
|
85
|
-
savePanelState(state);
|
|
86
|
-
}, [state]);
|
|
87
|
-
|
|
88
|
-
const handleMouseDown = useCallback(
|
|
89
|
-
(e: React.MouseEvent) => {
|
|
90
|
-
e.preventDefault();
|
|
91
|
-
setIsResizing(true);
|
|
92
|
-
startYRef.current = e.clientY;
|
|
93
|
-
startHeightRef.current = state.height;
|
|
94
|
-
},
|
|
95
|
-
[state.height]
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
const handleMouseMove = useCallback(
|
|
99
|
-
(e: MouseEvent) => {
|
|
100
|
-
if (!isResizing) return;
|
|
101
|
-
|
|
102
|
-
const deltaY = startYRef.current - e.clientY;
|
|
103
|
-
const newHeight = Math.max(MIN_HEIGHT, Math.min(MAX_HEIGHT, startHeightRef.current + deltaY));
|
|
104
|
-
setState((s) => ({ ...s, height: newHeight }));
|
|
105
|
-
},
|
|
106
|
-
[isResizing]
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
const handleMouseUp = useCallback(() => {
|
|
110
|
-
setIsResizing(false);
|
|
111
|
-
}, []);
|
|
112
|
-
|
|
113
|
-
// Add global mouse event listeners during resize
|
|
114
|
-
useEffect(() => {
|
|
115
|
-
if (isResizing) {
|
|
116
|
-
document.addEventListener("mousemove", handleMouseMove);
|
|
117
|
-
document.addEventListener("mouseup", handleMouseUp);
|
|
118
|
-
document.body.style.cursor = "ns-resize";
|
|
119
|
-
document.body.style.userSelect = "none";
|
|
120
|
-
|
|
121
|
-
return () => {
|
|
122
|
-
document.removeEventListener("mousemove", handleMouseMove);
|
|
123
|
-
document.removeEventListener("mouseup", handleMouseUp);
|
|
124
|
-
document.body.style.cursor = "";
|
|
125
|
-
document.body.style.userSelect = "";
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
}, [isResizing, handleMouseMove, handleMouseUp]);
|
|
129
|
-
|
|
130
|
-
const toggleOpen = useCallback(() => {
|
|
131
|
-
setState((s) => ({ ...s, isOpen: !s.isOpen }));
|
|
132
|
-
}, []);
|
|
133
|
-
|
|
134
|
-
if (!visible) return null;
|
|
135
|
-
|
|
136
|
-
const isOpen = state.isOpen;
|
|
137
|
-
|
|
138
|
-
// Heights for layout calculation
|
|
139
|
-
const headerHeight = 40; // h-10 = 2.5rem = 40px
|
|
140
|
-
const grabHandleHeight = 12; // 6px top padding + 4px pill + 2px bottom padding
|
|
141
|
-
|
|
142
|
-
// Compute container styles — drawer appearance
|
|
143
|
-
const containerStyle: CSSProperties = {
|
|
144
|
-
flexShrink: 0,
|
|
145
|
-
backgroundColor: "var(--bg-secondary)",
|
|
146
|
-
// Only transition when NOT resizing (for smooth open/close animations)
|
|
147
|
-
transition: isResizing ? "none" : "height 300ms ease",
|
|
148
|
-
height: isOpen ? state.height : headerHeight,
|
|
149
|
-
// Prevent content from being selected during resize
|
|
150
|
-
...(isResizing && { pointerEvents: "none" as const }),
|
|
151
|
-
position: "sticky",
|
|
152
|
-
bottom: 0,
|
|
153
|
-
// Drawer visual treatment
|
|
154
|
-
borderTopLeftRadius: "12px",
|
|
155
|
-
borderTopRightRadius: "12px",
|
|
156
|
-
boxShadow: "0 -4px 16px rgba(0, 0, 0, 0.08), 0 -1px 4px rgba(0, 0, 0, 0.04)",
|
|
157
|
-
borderTop: "1px solid var(--border)",
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
// Resize handle styles — extends above panel for easier grabbing
|
|
161
|
-
const resizeHandleStyle: CSSProperties = {
|
|
162
|
-
position: "absolute",
|
|
163
|
-
zIndex: 20,
|
|
164
|
-
top: "-8px",
|
|
165
|
-
left: 0,
|
|
166
|
-
right: 0,
|
|
167
|
-
height: "16px",
|
|
168
|
-
cursor: "ns-resize",
|
|
169
|
-
...(isResizing && { backgroundColor: "rgba(var(--color-accent-rgb, 59, 130, 246), 0.2)" }),
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
// Grab handle pill — always visible in drawer style
|
|
173
|
-
const grabHandleStyle: CSSProperties = {
|
|
174
|
-
width: "100%",
|
|
175
|
-
display: "flex",
|
|
176
|
-
justifyContent: "center",
|
|
177
|
-
padding: "6px 0 2px",
|
|
178
|
-
cursor: "ns-resize",
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
const grabPillStyle: CSSProperties = {
|
|
182
|
-
width: "36px",
|
|
183
|
-
height: "4px",
|
|
184
|
-
borderRadius: "9999px",
|
|
185
|
-
backgroundColor: "var(--text-muted)",
|
|
186
|
-
opacity: isResizing ? 0.8 : 0.3,
|
|
187
|
-
transition: "opacity 150ms ease",
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
// Chevron icon rotation
|
|
191
|
-
const chevronStyle: CSSProperties = {
|
|
192
|
-
width: "16px",
|
|
193
|
-
height: "16px",
|
|
194
|
-
transition: "transform 150ms ease",
|
|
195
|
-
...(!isOpen && { transform: "rotate(180deg)" }),
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
return (
|
|
199
|
-
<div ref={panelRef} className={className} style={containerStyle} {...props}>
|
|
200
|
-
{/* Full-viewport overlay during resize - prevents iframes from capturing events */}
|
|
201
|
-
{isResizing && (
|
|
202
|
-
<div
|
|
203
|
-
style={{
|
|
204
|
-
position: "fixed",
|
|
205
|
-
inset: 0,
|
|
206
|
-
zIndex: 50,
|
|
207
|
-
cursor: "ns-resize",
|
|
208
|
-
// Must explicitly enable pointer events since parent has pointerEvents: none
|
|
209
|
-
pointerEvents: "auto",
|
|
210
|
-
}}
|
|
211
|
-
/>
|
|
212
|
-
)}
|
|
213
|
-
|
|
214
|
-
{/* Resize Handle - extends above panel for easier grabbing */}
|
|
215
|
-
{isOpen && (
|
|
216
|
-
<div
|
|
217
|
-
style={resizeHandleStyle}
|
|
218
|
-
onMouseDown={handleMouseDown}
|
|
219
|
-
/>
|
|
220
|
-
)}
|
|
221
|
-
|
|
222
|
-
{/* Grab handle pill — always visible drawer indicator */}
|
|
223
|
-
{isOpen && (
|
|
224
|
-
<div
|
|
225
|
-
style={grabHandleStyle}
|
|
226
|
-
onMouseDown={handleMouseDown}
|
|
227
|
-
onMouseEnter={(e) => {
|
|
228
|
-
const pill = e.currentTarget.querySelector("[data-grab-pill]") as HTMLElement;
|
|
229
|
-
if (pill) pill.style.opacity = "0.6";
|
|
230
|
-
}}
|
|
231
|
-
onMouseLeave={(e) => {
|
|
232
|
-
const pill = e.currentTarget.querySelector("[data-grab-pill]") as HTMLElement;
|
|
233
|
-
if (pill) pill.style.opacity = isResizing ? "0.8" : "0.3";
|
|
234
|
-
}}
|
|
235
|
-
>
|
|
236
|
-
<div data-grab-pill style={grabPillStyle} />
|
|
237
|
-
</div>
|
|
238
|
-
)}
|
|
239
|
-
|
|
240
|
-
{/* Panel Header */}
|
|
241
|
-
<Stack direction="row" align="center" justify="between" style={{ padding: '0 16px', height: '40px', borderBottom: '1px solid var(--border-subtle)' }}>
|
|
242
|
-
<Stack direction="row" align="center" gap="xs" style={{ flex: 1, overflow: 'hidden' }}>
|
|
243
|
-
{header}
|
|
244
|
-
</Stack>
|
|
245
|
-
<Stack direction="row" align="center" gap="xs">
|
|
246
|
-
{/* Collapse toggle button */}
|
|
247
|
-
<Button
|
|
248
|
-
variant="ghost"
|
|
249
|
-
size="sm"
|
|
250
|
-
icon
|
|
251
|
-
onClick={toggleOpen}
|
|
252
|
-
aria-label={isOpen ? "Collapse panel" : "Expand panel"}
|
|
253
|
-
>
|
|
254
|
-
<span style={chevronStyle}>
|
|
255
|
-
<ChevronDownIcon />
|
|
256
|
-
</span>
|
|
257
|
-
</Button>
|
|
258
|
-
</Stack>
|
|
259
|
-
</Stack>
|
|
260
|
-
|
|
261
|
-
{/* Panel Content */}
|
|
262
|
-
{isOpen && (
|
|
263
|
-
<Box overflow="auto" style={{ height: `calc(100% - ${headerHeight}px)`, width: '100%' }}>
|
|
264
|
-
{children}
|
|
265
|
-
</Box>
|
|
266
|
-
)}
|
|
267
|
-
</div>
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
export default ResizablePanel;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import type { FragmentDefinition } from '../../core/index.js';
|
|
2
|
-
import { useScrollSpy } from '../hooks/useScrollSpy.js';
|
|
3
|
-
import { Sidebar, Text } from '@fragments-sdk/ui';
|
|
4
|
-
|
|
5
|
-
interface RightSidebarProps {
|
|
6
|
-
fragment: FragmentDefinition;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface TocItem {
|
|
10
|
-
id: string;
|
|
11
|
-
label: string;
|
|
12
|
-
children?: TocItem[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function RightSidebar({ fragment }: RightSidebarProps) {
|
|
16
|
-
// Build table of contents from fragment
|
|
17
|
-
const tocItems: TocItem[] = [];
|
|
18
|
-
|
|
19
|
-
// Overview section
|
|
20
|
-
tocItems.push({ id: 'overview', label: 'Overview' });
|
|
21
|
-
|
|
22
|
-
// Variants section with nested items
|
|
23
|
-
if (fragment.variants && fragment.variants.length > 0) {
|
|
24
|
-
tocItems.push({
|
|
25
|
-
id: 'variants',
|
|
26
|
-
label: 'Variants',
|
|
27
|
-
children: fragment.variants.map((variant, index) => ({
|
|
28
|
-
id: `variant-${index}`,
|
|
29
|
-
label: variant.name,
|
|
30
|
-
})),
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Usage section
|
|
35
|
-
if (fragment.usage) {
|
|
36
|
-
tocItems.push({ id: 'usage', label: 'Usage' });
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Props section
|
|
40
|
-
if (fragment.props && Object.keys(fragment.props).length > 0) {
|
|
41
|
-
tocItems.push({ id: 'props', label: 'Props' });
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Relations section
|
|
45
|
-
if (fragment.relations && fragment.relations.length > 0) {
|
|
46
|
-
tocItems.push({ id: 'relations', label: 'Relations' });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Flatten for scroll spy
|
|
50
|
-
const allIds = tocItems.flatMap((item) => [
|
|
51
|
-
item.id,
|
|
52
|
-
...(item.children?.map((child) => child.id) ?? []),
|
|
53
|
-
]);
|
|
54
|
-
|
|
55
|
-
const { activeId, scrollToSection } = useScrollSpy({
|
|
56
|
-
sectionIds: allIds,
|
|
57
|
-
offset: 100,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<Sidebar position="right" collapsible="none" style={{ padding: '8px 0' }}>
|
|
62
|
-
<Sidebar.Header>
|
|
63
|
-
<Text size="2xs" weight="medium" color="tertiary" style={{ textTransform: 'uppercase', letterSpacing: '0.05em' }}>
|
|
64
|
-
On this page
|
|
65
|
-
</Text>
|
|
66
|
-
</Sidebar.Header>
|
|
67
|
-
<Sidebar.Nav aria-label="On this page">
|
|
68
|
-
{tocItems.map((item) => {
|
|
69
|
-
const isActive = activeId === item.id;
|
|
70
|
-
const hasActiveChild = item.children?.some((child) => activeId === child.id);
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<Sidebar.Section key={item.id}>
|
|
74
|
-
<Sidebar.Item
|
|
75
|
-
active={isActive || !!hasActiveChild}
|
|
76
|
-
onClick={() => scrollToSection(item.id)}
|
|
77
|
-
>
|
|
78
|
-
{item.label}
|
|
79
|
-
</Sidebar.Item>
|
|
80
|
-
{item.children && item.children.length > 0 && (
|
|
81
|
-
<>
|
|
82
|
-
{item.children.map((child) => {
|
|
83
|
-
const isChildActive = activeId === child.id;
|
|
84
|
-
return (
|
|
85
|
-
<Sidebar.SubItem
|
|
86
|
-
key={child.id}
|
|
87
|
-
active={isChildActive}
|
|
88
|
-
onClick={() => scrollToSection(child.id)}
|
|
89
|
-
>
|
|
90
|
-
{child.label}
|
|
91
|
-
</Sidebar.SubItem>
|
|
92
|
-
);
|
|
93
|
-
})}
|
|
94
|
-
</>
|
|
95
|
-
)}
|
|
96
|
-
</Sidebar.Section>
|
|
97
|
-
);
|
|
98
|
-
})}
|
|
99
|
-
</Sidebar.Nav>
|
|
100
|
-
</Sidebar>
|
|
101
|
-
);
|
|
102
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import { useWebMCPTools } from '@fragments-sdk/webmcp/react';
|
|
3
|
-
import { useCompiledFragments } from '../hooks/useCompiledFragments.js';
|
|
4
|
-
import { createRuntimeWebMCPTools } from '../webmcp/runtime-tools.js';
|
|
5
|
-
|
|
6
|
-
export function RuntimeToolsRegistrar() {
|
|
7
|
-
const { data } = useCompiledFragments();
|
|
8
|
-
|
|
9
|
-
const tools = useMemo(() => {
|
|
10
|
-
if (!data) return [];
|
|
11
|
-
return createRuntimeWebMCPTools({ compiledData: data });
|
|
12
|
-
}, [data]);
|
|
13
|
-
|
|
14
|
-
useWebMCPTools(tools);
|
|
15
|
-
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ScreenshotButton component - captures screenshots of the preview area.
|
|
3
|
-
* Saves directly to file.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { useState, memo } from 'react';
|
|
7
|
-
import html2canvas from 'html2canvas';
|
|
8
|
-
import { Button, Tooltip } from '@fragments-sdk/ui';
|
|
9
|
-
import { CameraIcon } from './Icons.js';
|
|
10
|
-
|
|
11
|
-
interface ScreenshotButtonProps {
|
|
12
|
-
componentName: string;
|
|
13
|
-
variantName: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const ScreenshotButton = memo(function ScreenshotButton({ componentName, variantName }: ScreenshotButtonProps) {
|
|
17
|
-
const [status, setStatus] = useState<'idle' | 'loading' | 'success' | 'error'>('idle');
|
|
18
|
-
|
|
19
|
-
const handleSaveToFile = async () => {
|
|
20
|
-
setStatus('loading');
|
|
21
|
-
try {
|
|
22
|
-
const previewContainer = document.querySelector('[data-preview-container="true"]');
|
|
23
|
-
if (!previewContainer) throw new Error('Preview container not found');
|
|
24
|
-
|
|
25
|
-
await document.fonts.ready;
|
|
26
|
-
|
|
27
|
-
const canvas = await html2canvas(previewContainer as HTMLElement, {
|
|
28
|
-
backgroundColor: null,
|
|
29
|
-
scale: 2,
|
|
30
|
-
logging: false,
|
|
31
|
-
useCORS: true,
|
|
32
|
-
allowTaint: true,
|
|
33
|
-
onclone: (clonedDoc) => {
|
|
34
|
-
const clonedElement = clonedDoc.querySelector('[data-preview-container="true"]');
|
|
35
|
-
if (clonedElement) {
|
|
36
|
-
const style = clonedDoc.createElement('style');
|
|
37
|
-
style.textContent = Array.from(document.styleSheets)
|
|
38
|
-
.map(sheet => {
|
|
39
|
-
try {
|
|
40
|
-
return Array.from(sheet.cssRules)
|
|
41
|
-
.map(rule => rule.cssText)
|
|
42
|
-
.join('\n');
|
|
43
|
-
} catch {
|
|
44
|
-
return '';
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
.join('\n');
|
|
48
|
-
clonedDoc.head.appendChild(style);
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const blob = await new Promise<Blob>((resolve, reject) => {
|
|
54
|
-
canvas.toBlob((b) => {
|
|
55
|
-
if (b) resolve(b);
|
|
56
|
-
else reject(new Error('Failed to create blob'));
|
|
57
|
-
}, 'image/png');
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const url = URL.createObjectURL(blob);
|
|
61
|
-
const a = document.createElement('a');
|
|
62
|
-
a.href = url;
|
|
63
|
-
a.download = `${componentName}-${variantName}.png`;
|
|
64
|
-
document.body.appendChild(a);
|
|
65
|
-
a.click();
|
|
66
|
-
document.body.removeChild(a);
|
|
67
|
-
URL.revokeObjectURL(url);
|
|
68
|
-
setStatus('success');
|
|
69
|
-
setTimeout(() => setStatus('idle'), 2000);
|
|
70
|
-
} catch (err) {
|
|
71
|
-
console.error('Screenshot save failed:', err);
|
|
72
|
-
setStatus('error');
|
|
73
|
-
setTimeout(() => setStatus('idle'), 2000);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<Tooltip content="Save screenshot">
|
|
79
|
-
<Button
|
|
80
|
-
variant="ghost"
|
|
81
|
-
size="sm"
|
|
82
|
-
icon
|
|
83
|
-
disabled={status === 'loading'}
|
|
84
|
-
onClick={handleSaveToFile}
|
|
85
|
-
>
|
|
86
|
-
<CameraIcon style={{ width: '16px', height: '16px' }} />
|
|
87
|
-
</Button>
|
|
88
|
-
</Tooltip>
|
|
89
|
-
);
|
|
90
|
-
});
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import React, { useState, useMemo } from 'react';
|
|
2
|
-
import type { FragmentDefinition } from '../../core/index.js';
|
|
3
|
-
|
|
4
|
-
interface SidebarProps {
|
|
5
|
-
fragments: Array<{ path: string; fragment: FragmentDefinition }>;
|
|
6
|
-
activeFragment: string | null;
|
|
7
|
-
onSelect: (path: string) => void;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function Sidebar({ fragments, activeFragment, onSelect }: SidebarProps): React.ReactElement {
|
|
11
|
-
const [search, setSearch] = useState('');
|
|
12
|
-
|
|
13
|
-
// Group fragments by category
|
|
14
|
-
const grouped = useMemo(() => {
|
|
15
|
-
const groups: Record<string, typeof fragments> = {};
|
|
16
|
-
|
|
17
|
-
for (const item of fragments) {
|
|
18
|
-
const category = item.fragment.meta.category || 'uncategorized';
|
|
19
|
-
if (!groups[category]) {
|
|
20
|
-
groups[category] = [];
|
|
21
|
-
}
|
|
22
|
-
groups[category].push(item);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Filter by search
|
|
26
|
-
if (search) {
|
|
27
|
-
const filtered: Record<string, typeof fragments> = {};
|
|
28
|
-
for (const [category, items] of Object.entries(groups)) {
|
|
29
|
-
const matchingItems = items.filter(
|
|
30
|
-
(item) =>
|
|
31
|
-
item.fragment.meta.name.toLowerCase().includes(search.toLowerCase()) ||
|
|
32
|
-
item.fragment.meta.description.toLowerCase().includes(search.toLowerCase())
|
|
33
|
-
);
|
|
34
|
-
if (matchingItems.length > 0) {
|
|
35
|
-
filtered[category] = matchingItems;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return filtered;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return groups;
|
|
42
|
-
}, [fragments, search]);
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<div
|
|
46
|
-
style={{
|
|
47
|
-
width: '280px',
|
|
48
|
-
height: '100vh',
|
|
49
|
-
background: '#f9fafb',
|
|
50
|
-
borderRight: '1px solid #e5e7eb',
|
|
51
|
-
display: 'flex',
|
|
52
|
-
flexDirection: 'column',
|
|
53
|
-
overflow: 'hidden',
|
|
54
|
-
}}
|
|
55
|
-
>
|
|
56
|
-
{/* Header */}
|
|
57
|
-
<div
|
|
58
|
-
style={{
|
|
59
|
-
padding: '16px',
|
|
60
|
-
borderBottom: '1px solid #e5e7eb',
|
|
61
|
-
}}
|
|
62
|
-
>
|
|
63
|
-
<h1
|
|
64
|
-
style={{
|
|
65
|
-
margin: 0,
|
|
66
|
-
fontSize: '18px',
|
|
67
|
-
fontWeight: 700,
|
|
68
|
-
color: '#111827',
|
|
69
|
-
}}
|
|
70
|
-
>
|
|
71
|
-
Fragments
|
|
72
|
-
</h1>
|
|
73
|
-
<p
|
|
74
|
-
style={{
|
|
75
|
-
margin: '4px 0 0',
|
|
76
|
-
fontSize: '12px',
|
|
77
|
-
color: '#6b7280',
|
|
78
|
-
}}
|
|
79
|
-
>
|
|
80
|
-
{fragments.length} component{fragments.length !== 1 ? 's' : ''}
|
|
81
|
-
</p>
|
|
82
|
-
</div>
|
|
83
|
-
|
|
84
|
-
{/* Search */}
|
|
85
|
-
<div style={{ padding: '12px 16px' }}>
|
|
86
|
-
<input
|
|
87
|
-
type="text"
|
|
88
|
-
placeholder="Search components..."
|
|
89
|
-
value={search}
|
|
90
|
-
onChange={(e) => setSearch(e.target.value)}
|
|
91
|
-
style={{
|
|
92
|
-
width: '100%',
|
|
93
|
-
padding: '8px 12px',
|
|
94
|
-
border: '1px solid #d1d5db',
|
|
95
|
-
borderRadius: '6px',
|
|
96
|
-
fontSize: '13px',
|
|
97
|
-
outline: 'none',
|
|
98
|
-
boxSizing: 'border-box',
|
|
99
|
-
}}
|
|
100
|
-
/>
|
|
101
|
-
</div>
|
|
102
|
-
|
|
103
|
-
{/* Component list */}
|
|
104
|
-
<div
|
|
105
|
-
style={{
|
|
106
|
-
flex: 1,
|
|
107
|
-
overflow: 'auto',
|
|
108
|
-
padding: '0 8px 16px',
|
|
109
|
-
}}
|
|
110
|
-
>
|
|
111
|
-
{Object.entries(grouped).map(([category, items]) => (
|
|
112
|
-
<div key={category} style={{ marginBottom: '16px' }}>
|
|
113
|
-
<div
|
|
114
|
-
style={{
|
|
115
|
-
padding: '8px',
|
|
116
|
-
fontSize: '11px',
|
|
117
|
-
fontWeight: 600,
|
|
118
|
-
color: '#6b7280',
|
|
119
|
-
textTransform: 'uppercase',
|
|
120
|
-
letterSpacing: '0.05em',
|
|
121
|
-
}}
|
|
122
|
-
>
|
|
123
|
-
{category}
|
|
124
|
-
</div>
|
|
125
|
-
{items.map((item) => (
|
|
126
|
-
<button
|
|
127
|
-
key={item.path}
|
|
128
|
-
onClick={() => onSelect(item.path)}
|
|
129
|
-
style={{
|
|
130
|
-
display: 'block',
|
|
131
|
-
width: '100%',
|
|
132
|
-
padding: '8px 12px',
|
|
133
|
-
border: 'none',
|
|
134
|
-
borderRadius: '6px',
|
|
135
|
-
background: activeFragment === item.path ? '#e5e7eb' : 'transparent',
|
|
136
|
-
textAlign: 'left',
|
|
137
|
-
cursor: 'pointer',
|
|
138
|
-
transition: 'background 0.15s',
|
|
139
|
-
}}
|
|
140
|
-
>
|
|
141
|
-
<div
|
|
142
|
-
style={{
|
|
143
|
-
fontSize: '13px',
|
|
144
|
-
fontWeight: 500,
|
|
145
|
-
color: '#111827',
|
|
146
|
-
}}
|
|
147
|
-
>
|
|
148
|
-
{item.fragment.meta.name}
|
|
149
|
-
</div>
|
|
150
|
-
<div
|
|
151
|
-
style={{
|
|
152
|
-
fontSize: '12px',
|
|
153
|
-
color: '#6b7280',
|
|
154
|
-
marginTop: '2px',
|
|
155
|
-
overflow: 'hidden',
|
|
156
|
-
textOverflow: 'ellipsis',
|
|
157
|
-
whiteSpace: 'nowrap',
|
|
158
|
-
}}
|
|
159
|
-
>
|
|
160
|
-
{item.fragment.meta.description}
|
|
161
|
-
</div>
|
|
162
|
-
</button>
|
|
163
|
-
))}
|
|
164
|
-
</div>
|
|
165
|
-
))}
|
|
166
|
-
</div>
|
|
167
|
-
</div>
|
|
168
|
-
);
|
|
169
|
-
}
|