({ isOpen, onClose, background, props })
| 358 | const PKG_MANAGERS = ['pnpm', 'npm', 'yarn', 'bun']; |
| 359 | |
| 360 | const ExportModal = ({ isOpen, onClose, background, props }) => { |
| 361 | const { languagePreset, stylePreset } = useOptions() || {}; |
| 362 | const [copied, setCopied] = useState(null); |
| 363 | const [pkg, setPkg] = useState('pnpm'); |
| 364 | const codeRef = useRef(null); |
| 365 | |
| 366 | const language = languagePreset || 'JS'; |
| 367 | const style = stylePreset === 'TW' ? 'Tailwind' : stylePreset || 'CSS'; |
| 368 | |
| 369 | const { commands, jsxCode } = useMemo( |
| 370 | () => generateExportCode(background, props, { language, style }), |
| 371 | [background, props, language, style] |
| 372 | ); |
| 373 | |
| 374 | const currentCommand = useMemo(() => { |
| 375 | if (!commands) return ''; |
| 376 | const key = pkg === 'npm' ? 'npx' : pkg; |
| 377 | return commands.shadcn?.[key] || ''; |
| 378 | }, [commands, pkg]); |
| 379 | |
| 380 | const copyToClipboard = useCallback((text, type) => { |
| 381 | navigator.clipboard.writeText(text); |
| 382 | setCopied(type); |
| 383 | setTimeout(() => setCopied(null), 2000); |
| 384 | }, []); |
| 385 | |
| 386 | if (!isOpen) return null; |
| 387 | |
| 388 | return ( |
| 389 | <Box |
| 390 | position="fixed" |
| 391 | top={0} |
| 392 | left={0} |
| 393 | right={0} |
| 394 | bottom={0} |
| 395 | bg="rgba(0,0,0,0.8)" |
| 396 | zIndex={1000} |
| 397 | display="flex" |
| 398 | alignItems="center" |
| 399 | justifyContent="center" |
| 400 | onClick={onClose} |
| 401 | > |
| 402 | <Box |
| 403 | bg="var(--bg-card)" |
| 404 | border="1px solid var(--border-primary)" |
| 405 | borderRadius="40px" |
| 406 | p={6} |
| 407 | maxW="700px" |
| 408 | w="90%" |
| 409 | maxH="80vh" |
| 410 | overflowY="auto" |
| 411 | onClick={e => e.stopPropagation()} |
| 412 | css={{ |
| 413 | '&::-webkit-scrollbar': { display: 'none' }, |
| 414 | scrollbarWidth: 'none', |
| 415 | msOverflowStyle: 'none' |
| 416 | }} |
| 417 | > |
nothing calls this directly
no test coverage detected