@@ -6,11 +6,9 @@ import {Text1, Text2, Text3} from './text';
66import Inline from './inline' ;
77import IconWarningRegular from './generated/mistica-icons/icon-warning-regular' ;
88import { vars as skinVars } from './skins/skin-contract.css' ;
9- import { Boxed } from './boxed' ;
109import Box from './box' ;
1110import { useInnerText , useTheme } from './hooks' ;
1211import * as textTokens from './text-tokens' ;
13- import { IconButton } from './icon-button' ;
1412import Image from './image' ;
1513import IconCloseRegular from './generated/mistica-icons/icon-close-regular' ;
1614import IconFilePdfRegular from './generated/mistica-icons/icon-file-pdf-regular' ;
@@ -32,6 +30,7 @@ import IconClipRegular from './generated/mistica-icons/icon-clip-regular';
3230import * as styles from './file-upload.css' ;
3331import { useThemeVariant } from './theme-variant-context' ;
3432import { getPrefixedDataAttributes } from './utils/dom' ;
33+ import { BoxedRow , BoxedRowList } from './list' ;
3534
3635import type { DataAttributes , IconProps } from './utils/types' ;
3736import type { ExclusifyUnion } from './utils/utility-types' ;
@@ -349,40 +348,28 @@ const useFileUpload = ({
349348type FileItemProps = {
350349 file : File ;
351350 onRemove : ( file : File ) => void ;
352- formatSize ?: ( sizeInBytes : number ) => string ;
353351 removeLabel ?: string ;
354352} ;
355353
356354export const FileItem = ( { file, onRemove, removeLabel} : FileItemProps ) : JSX . Element => {
357355 const { i18n, t, texts} = useTheme ( ) ;
358356
359357 return (
360- < Boxed >
361- < Box paddingX = { 8 } paddingY = { 16 } >
362- < Inline space = "between" alignItems = "center" >
363- < Inline space = { 8 } alignItems = "center" >
364- < FileIcon file = { file } />
365- < Text2 regular > { file . name } </ Text2 >
366- </ Inline >
367- < Inline space = { 16 } alignItems = "center" >
368- < Text2 regular color = { skinVars . colors . textSecondary } >
369- { formatSize ( file . size , i18n . locale ) }
370- </ Text2 >
371- < IconButton
372- Icon = { IconCloseRegular }
373- type = "neutral"
374- small
375- onPress = { ( ) => onRemove ( file ) }
376- aria-label = {
377- removeLabel ??
378- texts . fileUploadRemoveFile ??
379- t ( textTokens . fileUploadRemoveFile , file . name )
380- }
381- />
382- </ Inline >
383- </ Inline >
384- </ Box >
385- </ Boxed >
358+ < BoxedRow
359+ title = { file . name }
360+ asset = { < FileIcon file = { file } /> }
361+ detail = { formatSize ( file . size , i18n . locale ) }
362+ iconButton = { {
363+ type : 'neutral' ,
364+ Icon : IconCloseRegular ,
365+ small : true ,
366+ onPress : ( ) => onRemove ( file ) ,
367+ 'aria-label' :
368+ removeLabel ??
369+ texts . fileUploadRemoveFile ??
370+ t ( textTokens . fileUploadRemoveFile , file . name ) ,
371+ } }
372+ />
386373 ) ;
387374} ;
388375
@@ -610,15 +597,13 @@ const FileUpload = (props: Props): JSX.Element => {
610597 ? renderFiles ( { files, removeFile} )
611598 : files &&
612599 files . length > 0 && (
613- < Stack
614- space = { 8 }
615- role = "list"
600+ < BoxedRowList
616601 aria-label = { texts . fileUploadListLabel ?? t ( textTokens . fileUploadListLabel ) }
617602 >
618603 { Array . from ( files ) . map ( ( file , index ) => (
619604 < FileItem key = { index } file = { file } onRemove = { removeFile } />
620605 ) ) }
621- </ Stack >
606+ </ BoxedRowList >
622607 ) }
623608 </ Stack >
624609 ) ;
0 commit comments