| 1 |
import React from 'react' |
| 2 |
import { __ } from '@wordpress/i18n' |
| 3 |
import { formatFileSize } from '../utils/fileUtils' |
| 4 |
|
| 5 |
interface SelectedFilesListProps { |
| 6 |
files: FileList |
| 7 |
onRemoveFile: (index: number) => void |
| 8 |
} |
| 9 |
|
| 10 |
export const SelectedFilesList: React.FC<SelectedFilesListProps> = ({ |
| 11 |
files, |
| 12 |
onRemoveFile |
| 13 |
}) => { |
| 14 |
return ( |
| 15 |
<div className="selected-files" style={{ marginBottom: '20px' }}> |
| 16 |
<h3 style={{ margin: '0 0 12px 0', fontSize: '14px', fontWeight: '600' }}> |
| 17 |
{__('Selected Files:', 'code-snippets')} ({files.length}) |
| 18 |
</h3> |
| 19 |
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}> |
| 20 |
{Array.from(files).map((file, index) => ( |
| 21 |
<div |
| 22 |
key={index} |
| 23 |
style={{ |
| 24 |
display: 'flex', |
| 25 |
alignItems: 'center', |
| 26 |
justifyContent: 'space-between', |
| 27 |
padding: '8px 12px', |
| 28 |
backgroundColor: '#f9f9f9', |
| 29 |
borderRadius: '4px', |
| 30 |
border: '1px solid #ddd' |
| 31 |
}} |
| 32 |
> |
| 33 |
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}> |
| 34 |
<span style={{ fontSize: '16px' }}>📄</span> |
| 35 |
<div> |
| 36 |
<div style={{ fontWeight: '500' }}>{file.name}</div> |
| 37 |
<div style={{ fontSize: '12px', color: '#666' }}> |
| 38 |
{formatFileSize(file.size)} |
| 39 |
</div> |
| 40 |
</div> |
| 41 |
</div> |
| 42 |
<button |
| 43 |
type="button" |
| 44 |
onClick={(e) => { |
| 45 |
e.stopPropagation() |
| 46 |
onRemoveFile(index) |
| 47 |
}} |
| 48 |
style={{ |
| 49 |
background: 'none', |
| 50 |
border: 'none', |
| 51 |
color: '#d63638', |
| 52 |
cursor: 'pointer', |
| 53 |
fontSize: '16px', |
| 54 |
padding: '4px' |
| 55 |
}} |
| 56 |
title={__('Remove file', 'code-snippets')} |
| 57 |
> |
| 58 |
✕ |
| 59 |
</button> |
| 60 |
</div> |
| 61 |
))} |
| 62 |
</div> |
| 63 |
</div> |
| 64 |
) |
| 65 |
} |
| 66 |
|