|
1 | 1 | 'use client' |
2 | 2 |
|
3 | 3 | import { useState } from 'react' |
4 | | -import { ChevronDown, ChevronUp, Maximize2, X, Zap } from 'lucide-react' |
| 4 | +import { Maximize2, X, Zap } from 'lucide-react' |
5 | 5 | import { Badge, Button } from '@/components/emcn' |
6 | | -import { cn } from '@/lib/core/utils/cn' |
7 | 6 | import { getBlock } from '@/blocks' |
8 | 7 | import type { BlockConfig, SubBlockConfig } from '@/blocks/types' |
9 | 8 | import type { BlockState } from '@/stores/workflows/workflow/types' |
10 | 9 |
|
11 | 10 | function ExpandableValue({ title, value }: { title: string; value: unknown }) { |
12 | | - const [isExpanded, setIsExpanded] = useState(false) |
13 | 11 | const [isModalOpen, setIsModalOpen] = useState(false) |
14 | 12 |
|
15 | 13 | const displayValue = formatSubBlockValue(value) |
16 | 14 | const isLargeValue = displayValue.length > 100 || displayValue.includes('\n') |
17 | 15 |
|
18 | | - if (!isLargeValue) { |
19 | | - return ( |
20 | | - <div className='rounded-[4px] border border-[var(--border)] bg-[var(--surface-3)] p-[10px]'> |
21 | | - <pre className='whitespace-pre-wrap break-words font-mono text-[12px] text-[var(--text-primary)]'> |
22 | | - {displayValue} |
23 | | - </pre> |
24 | | - </div> |
25 | | - ) |
26 | | - } |
27 | | - |
28 | 16 | return ( |
29 | 17 | <> |
30 | | - <div> |
31 | | - <div className='mb-[4px] flex items-center justify-end gap-[4px]'> |
| 18 | + <div className='relative'> |
| 19 | + {isLargeValue && ( |
32 | 20 | <button |
33 | 21 | onClick={() => setIsModalOpen(true)} |
34 | | - className='rounded-[4px] p-[4px] text-[var(--text-secondary)] transition-colors hover:bg-[var(--surface-3)] hover:text-[var(--text-primary)]' |
| 22 | + className='absolute top-[6px] right-[6px] z-10 rounded-[4px] p-[4px] text-[var(--text-secondary)] transition-colors hover:bg-[var(--surface-4)] hover:text-[var(--text-primary)]' |
35 | 23 | title='Expand in modal' |
36 | 24 | type='button' |
37 | 25 | > |
38 | 26 | <Maximize2 className='h-[12px] w-[12px]' /> |
39 | 27 | </button> |
40 | | - <button |
41 | | - onClick={() => setIsExpanded(!isExpanded)} |
42 | | - className='rounded-[4px] p-[4px] text-[var(--text-secondary)] transition-colors hover:bg-[var(--surface-3)] hover:text-[var(--text-primary)]' |
43 | | - type='button' |
44 | | - > |
45 | | - {isExpanded ? ( |
46 | | - <ChevronUp className='h-[12px] w-[12px]' /> |
47 | | - ) : ( |
48 | | - <ChevronDown className='h-[12px] w-[12px]' /> |
49 | | - )} |
50 | | - </button> |
51 | | - </div> |
52 | | - <div |
53 | | - className={cn( |
54 | | - 'overflow-y-auto rounded-[4px] border border-[var(--border)] bg-[var(--surface-3)] p-[10px] font-mono text-[12px] transition-all duration-200', |
55 | | - isExpanded ? 'max-h-64' : 'max-h-20' |
56 | | - )} |
57 | | - > |
| 28 | + )} |
| 29 | + <div className='max-h-24 overflow-y-auto rounded-[4px] border border-[var(--border)] bg-[var(--surface-3)] p-[10px] font-mono text-[12px]'> |
58 | 30 | <pre className='whitespace-pre-wrap break-words text-[var(--text-primary)]'> |
59 | 31 | {displayValue} |
60 | 32 | </pre> |
|
0 commit comments