@react-magma/dropzone 6.0.1-next.0 → 7.0.0
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/fileuploader.js +1 -1
- package/dist/fileuploader.js.map +1 -1
- package/dist/fileuploader.modern.js +12 -12
- package/dist/fileuploader.modern.js.map +1 -1
- package/dist/fileuploader.modern.module.js +1 -1
- package/dist/fileuploader.modern.module.js.map +1 -1
- package/dist/fileuploader.umd.js +1 -1
- package/dist/fileuploader.umd.js.map +1 -1
- package/package.json +3 -3
- package/src/components/dropzone/Dropzone.tsx +6 -4
- package/src/components/dropzone/Preview.tsx +10 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileuploader.umd.js","sources":["../src/components/dropzone/FileIcon.tsx","../src/components/dropzone/utils.ts","../src/components/dropzone/Preview.tsx","../src/components/dropzone/Dropzone.tsx"],"sourcesContent":["import React from 'react';\nimport {\n InsertDriveFileIcon,\n ImageIcon,\n AudiotrackIcon,\n VideocamIcon,\n FileExcelIcon,\n FilePdfIcon,\n FilePowerpointIcon,\n FileWordIcon,\n FileZipIcon,\n IconProps,\n} from 'react-magma-icons';\n\nimport { FilePreview } from './FilePreview';\nimport { magma } from 'react-magma-dom';\n\nexport interface FileIconProps extends IconProps {\n file: FilePreview;\n isInverse?: boolean;\n}\n\nconst icons = {\n default: {\n Icon: InsertDriveFileIcon,\n style: {\n color: magma.colors.neutral500,\n },\n },\n word: {\n Icon: FileWordIcon,\n style: {\n color: magma.colors.info500,\n },\n },\n excel: {\n Icon: FileExcelIcon,\n style: {\n color: magma.colors.success500,\n },\n },\n powerpoint: {\n Icon: FilePowerpointIcon,\n style: {\n color: magma.colors.warning500,\n },\n },\n pdf: {\n Icon: FilePdfIcon,\n style: {\n color: magma.colors.danger500,\n },\n },\n image: {\n Icon: ImageIcon,\n style: {\n color: magma.colors.neutral500,\n },\n },\n video: {\n Icon: VideocamIcon,\n style: {\n color: magma.colors.neutral500,\n },\n },\n audio: {\n Icon: AudiotrackIcon,\n style: {\n color: magma.colors.neutral500,\n },\n },\n archive: {\n Icon: FileZipIcon,\n style: {\n color: magma.colors.neutral500,\n },\n },\n};\n\nconst iconMapping: {\n [key: string]: { Icon: any; style: React.CSSProperties };\n} = {\n default: icons.default,\n xlsx: icons.excel,\n xlsm: icons.excel,\n xlsb: icons.excel,\n xltx: icons.excel,\n xls: icons.excel,\n xlt: icons.excel,\n doc: icons.word,\n docx: icons.word,\n docm: icons.word,\n dotx: icons.word,\n dotm: icons.word,\n docb: icons.word,\n pptx: icons.powerpoint,\n pptm: icons.powerpoint,\n ppt: icons.powerpoint,\n pdf: icons.pdf,\n png: icons.image,\n svg: icons.image,\n image: icons.image,\n audio: icons.audio,\n video: icons.video,\n zip: icons.archive,\n};\n\nexport const FileIcon = ({ file, isInverse }: FileIconProps) => {\n const { path = '', type = '' } = file;\n const category = type.split('/')[0];\n const extension = path.split('.').pop() || 'default';\n const { Icon, style } =\n iconMapping[extension] || iconMapping[category] || iconMapping.default;\n\n return <Icon size={magma.iconSizes.medium} style={isInverse ? {} : style} />;\n};\n","export const formatFileSize = (\n bytes: number | undefined,\n decimalPoint: number = 2,\n bytesLabel: string = 'Bytes'\n) => {\n if (bytes === undefined) return;\n if (bytes == 0) return `0 ${bytesLabel}`;\n const k = 1024;\n const sizes = [bytesLabel, 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n return (\n parseFloat((bytes / Math.pow(k, i)).toFixed(decimalPoint)) + ' ' + sizes[i]\n );\n};\n","import React, { forwardRef, useContext, useEffect, useState } from 'react';\n\nimport {\n CheckCircleIcon,\n CloseIcon,\n DeleteIcon,\n ErrorIcon,\n} from 'react-magma-icons';\n\nimport {\n ButtonColor,\n ButtonVariant,\n Card,\n Flex,\n FlexAlignItems,\n FlexBehavior,\n FlexProps,\n I18nContext,\n I18nInterface,\n IconButton,\n InverseContext,\n ThemeContext,\n ThemeInterface,\n Transition,\n Spinner,\n styled,\n useIsInverse,\n} from 'react-magma-dom';\n\nimport { FileIcon } from './FileIcon';\nimport { FilePreview } from './FilePreview';\nimport { formatFileSize } from './utils';\n\nexport interface PreviewProps extends Omit<FlexProps, 'behavior'> {\n accept?: string | string[];\n file: FilePreview;\n isInverse?: boolean;\n maxSize?: number;\n minSize?: number;\n onDeleteFile?: (file: FilePreview) => void;\n onRemoveFile?: (file: FilePreview) => void;\n /**\n * @internal\n */\n testId?: string;\n thumbnails: boolean;\n}\n\nconst Thumb = styled.div<{ file: FilePreview }>`\n background-image: ${({ file }) =>\n `url('${'preview' in file && file.preview}')`};\n background-repeat: no-repeat;\n background-size: cover;\n display: inline-block;\n vertical-align: middle;\n height: 40px;\n width: 40px;\n`;\n\nconst StatusIcons = styled.div`\n display: grid;\n grid-template-areas: 'inner-div';\n height: auto;\n place-items: center;\n width: 46px;\n & > div {\n display: inline-block;\n right: 0;\n grid-area: inner-div;\n }\n`;\n\nconst IconStyles = {\n marginRight: '12px',\n display: 'flex',\n};\n\nconst Errors = styled.div`\n border-top: 1px solid ${({ theme }) => theme.colors.neutral300};\n padding: 16px;\n font-size: ${({ theme }) => theme.typeScale.size02.fontSize};\n line-height: ${({ theme }) => theme.typeScale.size02.lineHeight};\n`;\n\nconst StyledFlex = styled(Flex)`\n height: 56px;\n padding: 0 8px 0 16px;\n font-size: ${({ theme }) => theme.typeScale.size02.fontSize};\n line-height: ${({ theme }) => theme.typeScale.size02.lineHeight};\n`;\n\nconst FileName = styled(Flex)`\n overflow: hidden;\n white-space: nowrap;\n align-items: center;\n text-overflow: ellipsis;\n display: block;\n margin-right: 24px;\n font-size: ${({ theme }) => theme.typeScale.size02.fontSize};\n line-height: ${({ theme }) => theme.typeScale.size02.lineHeight};\n`;\n\nconst StyledCard = styled(Card)<{ file: FilePreview; isInverse: boolean }>`\n background-color: none;\n border-color: ${({ file, theme, isInverse }) =>\n file.errors\n ? isInverse\n ? theme.colors.danger200\n : theme.colors.danger\n : theme.colors.neutral300};\n border-width: 1px;\n margin: 10px 0;\n`;\n\nconst ErrorHeader = styled.span`\n display: block;\n\n > div {\n display: flex;\n align-self: center;\n margin-right: 12px;\n }\n`;\n\nconst ErrorMessage = styled.span`\n display: block;\n`;\n\nconst formatError = (\n error: { header?: string; message: string; code: string },\n constraints: {\n maxSize?: number;\n minSize?: number;\n accept?: string | string[];\n },\n byteLabel: string\n) => {\n const accept =\n Array.isArray(constraints.accept) && constraints.accept.length === 1\n ? constraints.accept[0]\n : constraints.accept;\n const messageSuffix = Array.isArray(accept)\n ? `one of ${accept.join(', ')}`\n : accept;\n switch (error.code) {\n case 'file-too-large':\n return {\n ...error,\n message: `${error.message} ${formatFileSize(\n constraints.maxSize,\n 2,\n byteLabel\n )}.`,\n };\n case 'file-too-small':\n return {\n ...error,\n message: `${error.message} ${formatFileSize(\n constraints.minSize,\n 2,\n byteLabel\n )}.`,\n };\n case 'file-invalid-type':\n return { ...error, message: `${error.message}: ${messageSuffix}` };\n default:\n return error;\n }\n};\n\nexport const Preview = forwardRef<HTMLDivElement, PreviewProps>(\n // eslint-disable-next-line complexity\n (props, ref) => {\n const {\n accept,\n file,\n isInverse: isInverseProp,\n maxSize,\n minSize,\n onDeleteFile,\n onRemoveFile,\n testId,\n thumbnails,\n ...rest\n } = props;\n\n const theme: ThemeInterface = useContext(ThemeContext);\n const i18n: I18nInterface = React.useContext(I18nContext);\n const isInverse = useIsInverse(isInverseProp);\n const [actions, setActions] = useState(<CloseIcon />);\n\n const handleRemoveFile = () => {\n onRemoveFile && typeof onRemoveFile === 'function' && onRemoveFile(file);\n };\n\n const handleDeleteFile = () => {\n onDeleteFile && typeof onDeleteFile === 'function' && onDeleteFile(file);\n };\n\n const FinishedActions = ({ status = 'ready' }: { status?: string }) => {\n const [done, setDone] = useState<boolean>(false);\n\n useEffect(() => {\n let mounted = true;\n setTimeout(() => {\n if (mounted) {\n setDone(true);\n }\n }, 1000);\n return () => {\n mounted = false;\n };\n }, [status]);\n\n if (status === 'error' || status === 'ready') {\n return (\n <StatusIcons>\n <IconButton\n onClick={handleRemoveFile}\n variant={ButtonVariant.link}\n color={ButtonColor.secondary}\n aria-label={i18n.dropzone.removeFile}\n icon={<CloseIcon />}\n />\n </StatusIcons>\n );\n }\n\n if (status === 'pending') {\n return (\n <StatusIcons>\n <Spinner\n color={isInverse ? theme.colors.neutral100 : theme.colors.primary}\n />\n </StatusIcons>\n );\n }\n\n return (\n <StatusIcons>\n <Transition isOpen={!done} unmountOnExit fade>\n <CheckCircleIcon\n color={isInverse ? theme.colors.success200 : theme.colors.success}\n style={{ marginTop: '4px' }}\n />\n </Transition>\n <Transition isOpen={done} unmountOnExit fade>\n <IconButton\n onClick={handleDeleteFile}\n variant={ButtonVariant.link}\n color={ButtonColor.secondary}\n aria-label={i18n.dropzone.deleteFile}\n icon={<DeleteIcon />}\n />\n </Transition>\n </StatusIcons>\n );\n };\n\n useEffect(() => {\n setActions(<FinishedActions status={file?.processor?.status} />);\n }, [file?.processor?.status]);\n\n return (\n <InverseContext.Provider value={{ isInverse }}>\n <StyledCard\n isInverse={isInverse}\n theme={theme}\n file={file}\n data-testid={props.testId}\n ref={ref}\n role={file.errors ? 'alert' : ''}\n >\n <StyledFlex\n theme={theme}\n behavior={FlexBehavior.container}\n alignItems={FlexAlignItems.center}\n {...rest}\n >\n <Flex\n behavior={FlexBehavior.item}\n alignItems={FlexAlignItems.center}\n style={IconStyles}\n >\n {file.errors ? (\n <ErrorIcon\n color={\n isInverse ? theme.colors.danger200 : theme.colors.danger\n }\n size={24}\n />\n ) : file.preview &&\n thumbnails &&\n file.type &&\n file.type.startsWith('image') ? (\n <Thumb role=\"img\" file={file} />\n ) : (\n <FileIcon isInverse={isInverse} file={file} />\n )}\n </Flex>\n <FileName xs behavior={FlexBehavior.item} theme={theme}>\n {file.name}\n </FileName>\n {file.processor && file.processor.status === 'pending' && (\n <Flex\n role=\"progressbar\"\n style={{ marginLeft: 'auto' }}\n behavior={FlexBehavior.item}\n >\n {file.processor.percent}\n </Flex>\n )}\n <Flex behavior={FlexBehavior.item}>{actions}</Flex>\n </StyledFlex>\n {file.errors && (\n <Errors theme={theme}>\n {file.errors.slice(0, 1).map(({ code, ...rest }) => {\n const { header = '', message } = formatError(\n { code, ...rest, ...i18n.dropzone.errors[code] },\n { accept, minSize, maxSize },\n i18n.dropzone.bytes\n );\n return (\n <React.Fragment key={code}>\n <ErrorHeader\n style={{\n color: isInverse\n ? theme.colors.danger200\n : theme.colors.danger,\n }}\n >\n {header}\n </ErrorHeader>\n <ErrorMessage>{message}</ErrorMessage>\n </React.Fragment>\n );\n })}\n </Errors>\n )}\n </StyledCard>\n </InverseContext.Provider>\n );\n }\n);\n","/* eslint-disable no-empty-pattern */\n/**\n * HELPFUL NOTE!\n * SINCE THIS PACKAGE USES `FILE` WE MUST USE `Object.assign` IN LIEU OF SPREADING\n * `{...file}` WILL NOT COPY ALL OF THE FILE PROPERTIES\n */\n\nimport React from 'react';\nimport {\n useDropzone,\n DropzoneOptions,\n DropzoneRootProps,\n FileRejection,\n} from 'react-dropzone';\nimport {\n Button,\n ButtonColor,\n ButtonVariant,\n Flex,\n FlexBehavior,\n FlexProps,\n FormFieldContainer,\n FormFieldContainerBaseProps,\n I18nContext,\n I18nInterface,\n InverseContext,\n ThemeContext,\n ThemeInterface,\n styled,\n useGenerateId,\n useIsInverse,\n} from 'react-magma-dom';\n\nimport { CloudUploadIcon } from 'react-magma-icons';\nimport { Preview } from './Preview';\nimport { FilePreview, FileError } from './FilePreview';\nimport { transparentize } from 'polished';\n\nexport interface OnSendFileProps {\n file: FilePreview;\n onError?: ({}: { errors: FileError[]; file: FilePreview }) => void;\n onFinish?: ({}: { file: FilePreview }) => void;\n onProgress?: ({}: { percent: number; file: FilePreview }) => void;\n}\n\ntype DragState =\n | 'error'\n | 'dragAccept'\n | 'dragReject'\n | 'dragActive'\n | 'default';\n\n// NOTE: These props are manually copied to dropzone.mdx\nexport interface DropzoneProps\n extends Omit<FormFieldContainerBaseProps, 'fieldId' | 'errorMessage'> {\n /**\n * Set accepted file types. See https://github.com/okonet/attr-accept for more information. Keep in mind that mime type determination is not reliable across platforms. CSV files, for example, are reported as text/plain under macOS but as application/vnd.ms-excel under Windows. In some cases there might not be a mime type set at all. See: https://github.com/react-dropzone/react-dropzone/issues/276\n */\n accept?: string | string[];\n /**\n * Enable/Disable the input\n */\n disabled?: boolean;\n /**\n * Additional props to pass to the dropzone, see https://react-dropzone.js.org/#src\n */\n dropzoneOptions?: Partial<Omit<DropzoneOptions, 'onDrop'>>;\n /**\n * Content of the helper message.\n */\n helperMessage?: string;\n /**\n * @internal\n */\n id?: string;\n /**\n * Maximum accepted number of files The default value is 0 which means there is no limitation to how many files are accepted.\n * @default 0\n */\n maxFiles?: number;\n /**\n * Minimum accepted number of files.\n */\n minFiles?: number;\n /**\n * Maximum file size (in bytes)\n * @default Infinity\n */\n maxSize?: number;\n /**\n * Minimum file size (in bytes)\n * @default 0\n */\n minSize?: number;\n /**\n * Allow drag 'n' drop (or selection from the file dialog) of multiple files.\n * @default true\n */\n multiple?: boolean;\n /**\n * If true, disables drag 'n' drop\n * @default false\n */\n noDrag?: boolean;\n /**\n * Callback for when a file is deleted\n */\n onDeleteFile?: (file: FilePreview) => void;\n /**\n * Callback for when a file is deleted\n */\n onRemoveFile?: (file: FilePreview) => void;\n /**\n * Callback for when a file is added to the preview list via dropping or selecting. Will be ran on new files when `sendFiles` is true.\n */\n onSendFile?: (props: OnSendFileProps) => void;\n /**\n * Run `onSendFile` on any new files. Delay processing by setting to `false` until processing is desired.\n * @default false\n */\n sendFiles?: boolean;\n /**\n * @internal\n */\n testId?: string;\n /**\n * Show thumbnails for images in lieu of the file icon.\n * @default true\n */\n thumbnails?: boolean;\n}\n\nconst Container = styled(Flex)<\n DropzoneRootProps &\n FlexProps & {\n dragState?: DragState;\n noDrag?: boolean;\n isInverse?: boolean;\n }\n>`\n flex-direction: column;\n align-items: ${({ noDrag }) => (noDrag ? 'left' : 'center')};\n justify-content: ${({ noDrag }) => (noDrag ? 'left' : 'center')};\n text-align: ${({ noDrag }) => (noDrag ? 'left' : 'center')};\n padding: ${({ noDrag }) => (noDrag ? '0px' : '24px')};\n border-radius: ${({ noDrag }) => (noDrag ? '0px' : '4px')};\n border: ${({ dragState = 'default', noDrag, theme, isInverse }) =>\n noDrag\n ? `0px`\n : dragState === 'dragReject' || dragState === 'error'\n ? isInverse\n ? `1px dashed ${theme.colors.danger200}`\n : `1px dashed ${theme.colors.danger}`\n : dragState === 'dragActive'\n ? `1px dashed ${theme.colors.primary}`\n : dragState === 'dragAccept'\n ? `1px dashed ${theme.colors.success}`\n : `1px dashed ${theme.colors.neutral400}`};\n\n border-style: ${({ dragState = 'default' }) =>\n dragState === 'error' ? 'solid' : 'dashed'};\n background-color: ${({ theme, noDrag, isInverse }) =>\n noDrag\n ? 'transparent'\n : isInverse\n ? transparentize(0.75, theme.colors.neutral900)\n : theme.colors.neutral200};\n outline: none;\n transition: ${({ noDrag }) => `border ${noDrag ? 0 : '.24s'} ease-in-out`};\n`;\n\nconst HelperMessage = styled.span<{ isInverse?: boolean }>`\n color: ${({ theme, isInverse }) =>\n isInverse ? theme.colors.neutral100 : theme.colors.neutral700};\n display: block;\n font-size: 14px;\n margin: -8px 0 16px 0;\n`;\n\nconst Wrapper = styled.div<{ isInverse?: boolean }>`\n color: ${({ theme, isInverse }) =>\n isInverse ? theme.colors.neutral100 : theme.colors.neutral700};\n margin: 0 0 24px 0;\n font-size: ${({ theme }) => theme.typeScale.size02.fontSize};\n line-height: ${({ theme }) => theme.typeScale.size02.lineHeight};\n font-weight: 500;\n padding: ${({ theme }) => theme.spaceScale.spacing01};\n`;\nexport const Dropzone = React.forwardRef<HTMLInputElement, DropzoneProps>(\n (props, ref) => {\n const {\n accept,\n containerStyle,\n disabled,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n dropzoneOptions = {\n multiple: true,\n },\n helperMessage,\n id: defaultId,\n inputSize,\n isInverse: isInverseProp,\n isLabelVisuallyHidden,\n labelStyle,\n labelText,\n maxFiles,\n minFiles,\n maxSize,\n minSize,\n multiple = true,\n noDrag = false,\n onSendFile,\n onDeleteFile,\n onRemoveFile,\n sendFiles = false,\n testId,\n thumbnails = true,\n ...rest\n } = props;\n\n const [files, setFiles] = React.useState<FilePreview[]>([]);\n const [errorMessage, setErrorMessage] = React.useState<string | null>(null);\n\n const isInverse = useIsInverse(isInverseProp);\n const theme: ThemeInterface = React.useContext(ThemeContext);\n const i18n: I18nInterface = React.useContext(I18nContext);\n const id = useGenerateId(defaultId);\n\n const onDrop = React.useCallback(\n (acceptedFiles: FilePreview[], rejectedFiles: FileRejection[]) => {\n setFiles((files: FilePreview[]) => [\n ...files,\n ...acceptedFiles.map((file: FilePreview) =>\n Object.assign(file, {\n preview: URL.createObjectURL(file),\n })\n ),\n ...rejectedFiles.map(\n ({ file, errors }: { file: FilePreview; errors: FileError[] }) =>\n Object.assign(file, {\n errors,\n })\n ),\n ]);\n },\n []\n );\n\n const {\n getInputProps,\n getRootProps,\n isDragAccept,\n isDragActive,\n isDragReject,\n open,\n } = useDropzone({\n noClick: true,\n disabled,\n multiple,\n maxSize,\n minSize,\n accept,\n onDrop,\n noDrag,\n });\n\n const inputProps = getInputProps({ id });\n\n const dragState: DragState = errorMessage\n ? 'error'\n : isDragAccept\n ? 'dragAccept'\n : isDragReject\n ? 'dragReject'\n : isDragActive\n ? 'dragActive'\n : 'default';\n\n const handleRemoveFile = (removedFile: FilePreview) => {\n setFiles(files => files.filter(file => file !== removedFile));\n onRemoveFile &&\n typeof onRemoveFile === 'function' &&\n onRemoveFile(removedFile);\n };\n\n const handleDeleteFile = (removedFile: FilePreview) => {\n setFiles(files => files.filter(file => file !== removedFile));\n onDeleteFile &&\n typeof onDeleteFile === 'function' &&\n onDeleteFile(removedFile);\n };\n\n const setProgress = (props: { percent: number; file: FilePreview }) => {\n setFiles(files =>\n files.map(file =>\n file === props.file\n ? Object.assign(file, {\n processor: {\n ...file.processor,\n percent: `${props.percent}%`,\n status: 'pending',\n },\n })\n : file\n )\n );\n };\n\n const setFinished = (props: { file: FilePreview }) => {\n setFiles(files =>\n files.map(file =>\n file === props.file\n ? Object.assign(file, {\n processor: {\n ...file.processor,\n percent: '',\n status: 'finished',\n },\n })\n : file\n )\n );\n };\n\n const setError = (props: { errors: FileError[]; file: FilePreview }) => {\n setFiles(files =>\n files.map(file =>\n file === props.file\n ? Object.assign(file, {\n errors: props.errors,\n processor: { ...file.processor, status: 'error' },\n })\n : file\n )\n );\n };\n\n const formatError = (\n code: string | null,\n constraints: { maxFiles?: number; minFiles?: number }\n ) => {\n if (code === null) return null;\n const error = i18n.dropzone.errors[code];\n switch (code) {\n case 'too-many-files':\n return `${error.message} ${constraints.maxFiles} ${i18n.dropzone.files}.`;\n case 'too-few-files':\n return `${error.message} ${constraints.minFiles} ${i18n.dropzone.files}.`;\n default:\n return error.message;\n }\n };\n\n React.useEffect(\n () => () => {\n files.forEach(\n file => file.preview && URL.revokeObjectURL(file.preview)\n );\n },\n [files]\n );\n\n React.useEffect(() => {\n const minFileError = minFiles && files.length < minFiles;\n const maxFileError = maxFiles && files.length > maxFiles;\n\n setErrorMessage(\n formatError(\n maxFileError\n ? 'too-many-files'\n : minFileError\n ? 'too-few-files'\n : null,\n { minFiles, maxFiles }\n )\n );\n\n if (sendFiles && files.length > 0 && !maxFileError && !minFileError) {\n setFiles((files: FilePreview[]) => {\n return files.map((file: FilePreview) => {\n !file.errors &&\n !file.processor &&\n onSendFile &&\n onSendFile({\n file,\n onError: setError,\n onFinish: setFinished,\n onProgress: setProgress,\n });\n return file;\n });\n });\n }\n }, [sendFiles, files.length, onSendFile]);\n\n return (\n <InverseContext.Provider value={{ isInverse }}>\n <FormFieldContainer\n actionable={false}\n containerStyle={containerStyle}\n errorMessage={errorMessage}\n fieldId={id}\n inputSize={inputSize}\n isInverse={isInverse}\n isLabelVisuallyHidden={isLabelVisuallyHidden}\n labelStyle={labelStyle}\n labelText={labelText}\n messageStyle={{ minHeight: 0 }}\n data-testid={testId}\n >\n <HelperMessage theme={theme} isInverse={isInverse}>\n {helperMessage}\n </HelperMessage>\n <Container\n behavior={FlexBehavior.container}\n dragState={dragState}\n isInverse={isInverse}\n noDrag={noDrag}\n theme={theme}\n {...getRootProps()}\n {...rest}\n testId={testId}\n tabIndex={-1}\n >\n <input\n ref={ref}\n type={inputProps.type}\n accept={inputProps.accept}\n autoComplete={inputProps.autoComplete}\n id={inputProps.id}\n multiple={inputProps.multiple}\n onChange={inputProps.onChange}\n onClick={inputProps.onClick}\n style={inputProps.style}\n tabIndex={inputProps.tabIndex}\n />\n {noDrag ? (\n <Flex xs behavior={FlexBehavior.item}>\n <Button\n color={ButtonColor.primary}\n disabled={disabled}\n isInverse={isInverse}\n onClick={open}\n style={{ margin: 0 }}\n >\n {i18n.dropzone.browseFiles}\n </Button>\n </Flex>\n ) : (\n <Flex behavior={FlexBehavior.item}>\n <CloudUploadIcon\n aria-hidden=\"true\"\n color={\n isInverse\n ? theme.colors.neutral100\n : theme.colors.neutral500\n }\n size={48}\n />\n <Wrapper isInverse={isInverse} theme={theme}>\n {i18n.dropzone.dragMessage}\n </Wrapper>\n <Button\n color={ButtonColor.primary}\n disabled={disabled}\n isInverse={isInverse}\n onClick={open}\n style={{ margin: 0 }}\n variant={ButtonVariant.solid}\n >\n {i18n.dropzone.browseFiles}\n </Button>\n </Flex>\n )}\n </Container>\n </FormFieldContainer>\n {files.map((file: FilePreview) => (\n <Preview\n accept={accept}\n file={file}\n isInverse={isInverse}\n key={file.name}\n maxSize={maxSize}\n minSize={minSize}\n onDeleteFile={handleDeleteFile}\n onRemoveFile={handleRemoveFile}\n thumbnails={thumbnails}\n />\n ))}\n </InverseContext.Provider>\n );\n }\n);\n"],"names":["default","Icon","InsertDriveFileIcon","style","color","magma","colors","neutral500","word","FileWordIcon","info500","excel","FileExcelIcon","success500","powerpoint","FilePowerpointIcon","warning500","pdf","FilePdfIcon","danger500","image","ImageIcon","video","VideocamIcon","audio","AudiotrackIcon","archive","FileZipIcon","icons","xlsx","xlsm","xlsb","xltx","xls","xlt","doc","docx","docm","dotx","dotm","docb","pptx","pptm","ppt","png","svg","zip","file","isInverse","path","type","split","pop","iconMapping","extension","category","_jsx","size","iconSizes","medium","bytes","decimalPoint","bytesLabel","undefined","Math","floor","log","pow","i","toFixed","sizes","styled","div","preview","marginRight","display","theme","neutral300","typeScale","size02","fontSize","lineHeight","Flex","Card","errors","danger200","danger","span","forwardRef","props","ref","accept","isInverseProp","maxSize","minSize","onDeleteFile","onRemoveFile","thumbnails","rest","useContext","ThemeContext","React","I18nContext","useIsInverse","useState","CloseIcon","actions","setActions","status","done","setDone","useEffect","setTimeout","mounted","StatusIcons","IconButton","onClick","handleRemoveFile","variant","ButtonVariant","link","ButtonColor","secondary","i18n","dropzone","removeFile","icon","Spinner","neutral100","primary","_jsxs","Transition","isOpen","unmountOnExit","fade","CheckCircleIcon","success200","success","marginTop","handleDeleteFile","deleteFile","DeleteIcon","FinishedActions","processor","_file$processor","_file$processor2","InverseContext","Provider","value","StyledCard","testId","role","StyledFlex","behavior","FlexBehavior","container","alignItems","FlexAlignItems","center","item","IconStyles","ErrorIcon","startsWith","Thumb","FileIcon","FileName","xs","name","marginLeft","percent","Errors","slice","map","code","error","constraints","byteLabel","Array","isArray","length","join","message","formatFileSize","messageSuffix","formatError","header","Fragment","ErrorHeader","ErrorMessage","noDrag","dragState","neutral400","transparentize","neutral900","neutral200","neutral700","spaceScale","spacing01","containerStyle","disabled","helperMessage","defaultId","id","inputSize","isLabelVisuallyHidden","labelStyle","labelText","maxFiles","minFiles","multiple","onSendFile","sendFiles","files","setFiles","errorMessage","setErrorMessage","useGenerateId","useCallback","acceptedFiles","rejectedFiles","assign","URL","createObjectURL","useDropzone","noClick","onDrop","getRootProps","isDragAccept","isDragActive","isDragReject","open","getInputProps","removedFile","filter","Object","forEach","revokeObjectURL","maxFileError","minFileError","onError","setError","onFinish","setFinished","onProgress","setProgress","FormFieldContainer","actionable","fieldId","messageStyle","minHeight","HelperMessage","Container","tabIndex","inputProps","autoComplete","onChange","Button","margin","browseFiles","CloudUploadIcon","Wrapper","dragMessage","solid","Preview"],"mappings":"goBAsBc,CACZA,QAAS,CACPC,KAAMC,sBACNC,MAAO,CACLC,MAAOC,QAAMC,OAAOC,aAGxBC,KAAM,CACJP,KAAMQ,eACNN,MAAO,CACLC,MAAOC,QAAMC,OAAOI,UAGxBC,MAAO,CACLV,KAAMW,gBACNT,MAAO,CACLC,MAAOC,QAAMC,OAAOO,aAGxBC,WAAY,CACVb,KAAMc,qBACNZ,MAAO,CACLC,MAAOC,QAAMC,OAAOU,aAGxBC,IAAK,CACHhB,KAAMiB,cACNf,MAAO,CACLC,MAAOC,QAAMC,OAAOa,YAGxBC,MAAO,CACLnB,KAAMoB,YACNlB,MAAO,CACLC,MAAOC,QAAMC,OAAOC,aAGxBe,MAAO,CACLrB,KAAMsB,eACNpB,MAAO,CACLC,MAAOC,QAAMC,OAAOC,aAGxBiB,MAAO,CACLvB,KAAMwB,iBACNtB,MAAO,CACLC,MAAOC,QAAMC,OAAOC,aAGxBmB,QAAS,CACPzB,KAAM0B,cACNxB,MAAO,CACLC,MAAOC,QAAMC,OAAOC,gBAOtB,CACFP,QAAS4B,UACTC,KAAMD,EAAMjB,MACZmB,KAAMF,EAAMjB,MACZoB,KAAMH,EAAMjB,MACZqB,KAAMJ,EAAMjB,MACZsB,IAAKL,EAAMjB,MACXuB,IAAKN,EAAMjB,MACXwB,IAAKP,EAAMpB,KACX4B,KAAMR,EAAMpB,KACZ6B,KAAMT,EAAMpB,KACZ8B,KAAMV,EAAMpB,KACZ+B,KAAMX,EAAMpB,KACZgC,KAAMZ,EAAMpB,KACZiC,KAAMb,EAAMd,WACZ4B,KAAMd,EAAMd,WACZ6B,IAAKf,EAAMd,WACXG,IAAKW,EAAMX,IACX2B,IAAKhB,EAAMR,MACXyB,IAAKjB,EAAMR,MACXA,MAA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ClG,SAAUC,eAAaC,UACvBmC,UAAWA,GACX9I,UAAWA,EACX6I,OAAQA,EACRjH,MAAOA,GACHsJ,IACAhI,GACJoD,OAAQA,EACRsG,UAAW,YAEXpM,eACEkC,IAAKA,EACLxC,KAAM2M,GAAW3M,KACjByC,OAAQkK,GAAWlK,OACnBmK,aAAcD,GAAWC,aACzBpD,GAAImD,GAAWnD,GACfO,SAAU4C,GAAW5C,SACrB8C,SAAUF,GAAWE,SACrB3I,QAASyI,GAAWzI,QACpBjH,MAAO0P,GAAW1P,MAClByP,SAAUC,GAAWD,WAEtB/D,EACCrI,MAAC0B,QAAKoF,MAAGb,SAAUC,eAAaK,cAC9BvG,MAACwM,UACC5P,MAAOqH,cAAYQ,QACnBsE,SAAUA,EACVvJ,UAAWA,EACXoE,QAASkH,GACTnO,MAAO,CAAE8P,OAAQ,YAEhBtI,EAAKC,SAASsI,gBAInBhI,OAAChD,QAAKuE,SAAUC,eAAaK,eAC3BvG,MAAC2M,mBACC,cAAY,OACZ/P,MACE4C,EACI4B,EAAMtE,OAAO0H,WACbpD,EAAMtE,OAAOC,WAEnBkD,KAAM,KAERD,MAAC4M,GAAQpN,UAAWA,EAAW4B,MAAOA,WACnC+C,EAAKC,SAASyI,cAEjB7M,MAACwM,UACC5P,MAAOqH,cAAYQ,QACnBsE,SAAUA,EACVvJ,UAAWA,EACXoE,QAASkH,GACTnO,MAAO,CAAE8P,OAAQ,GACjB3I,QAASC,gBAAc+I,eAEtB3I,EAAKC,SAASsI,wBAMxB9C,EAAMxC,IAAI,SAAC7H,UACVS,MAAC+M,GACC5K,OAAQA,EACR5C,KAAMA,EACNC,UAAWA,EAEX6C,QAASA,EACTC,QAASA,EACTC,aAAc4C,GACd3C,aAAcqB,GACdpB,WAAYA,GALPlD,EAAKwH,KAMV,KAIV"}
|
|
1
|
+
{"version":3,"file":"fileuploader.umd.js","sources":["../src/components/dropzone/FileIcon.tsx","../src/components/dropzone/utils.ts","../src/components/dropzone/Preview.tsx","../src/components/dropzone/Dropzone.tsx"],"sourcesContent":["import React from 'react';\nimport {\n InsertDriveFileIcon,\n ImageIcon,\n AudiotrackIcon,\n VideocamIcon,\n FileExcelIcon,\n FilePdfIcon,\n FilePowerpointIcon,\n FileWordIcon,\n FileZipIcon,\n IconProps,\n} from 'react-magma-icons';\n\nimport { FilePreview } from './FilePreview';\nimport { magma } from 'react-magma-dom';\n\nexport interface FileIconProps extends IconProps {\n file: FilePreview;\n isInverse?: boolean;\n}\n\nconst icons = {\n default: {\n Icon: InsertDriveFileIcon,\n style: {\n color: magma.colors.neutral500,\n },\n },\n word: {\n Icon: FileWordIcon,\n style: {\n color: magma.colors.info500,\n },\n },\n excel: {\n Icon: FileExcelIcon,\n style: {\n color: magma.colors.success500,\n },\n },\n powerpoint: {\n Icon: FilePowerpointIcon,\n style: {\n color: magma.colors.warning500,\n },\n },\n pdf: {\n Icon: FilePdfIcon,\n style: {\n color: magma.colors.danger500,\n },\n },\n image: {\n Icon: ImageIcon,\n style: {\n color: magma.colors.neutral500,\n },\n },\n video: {\n Icon: VideocamIcon,\n style: {\n color: magma.colors.neutral500,\n },\n },\n audio: {\n Icon: AudiotrackIcon,\n style: {\n color: magma.colors.neutral500,\n },\n },\n archive: {\n Icon: FileZipIcon,\n style: {\n color: magma.colors.neutral500,\n },\n },\n};\n\nconst iconMapping: {\n [key: string]: { Icon: any; style: React.CSSProperties };\n} = {\n default: icons.default,\n xlsx: icons.excel,\n xlsm: icons.excel,\n xlsb: icons.excel,\n xltx: icons.excel,\n xls: icons.excel,\n xlt: icons.excel,\n doc: icons.word,\n docx: icons.word,\n docm: icons.word,\n dotx: icons.word,\n dotm: icons.word,\n docb: icons.word,\n pptx: icons.powerpoint,\n pptm: icons.powerpoint,\n ppt: icons.powerpoint,\n pdf: icons.pdf,\n png: icons.image,\n svg: icons.image,\n image: icons.image,\n audio: icons.audio,\n video: icons.video,\n zip: icons.archive,\n};\n\nexport const FileIcon = ({ file, isInverse }: FileIconProps) => {\n const { path = '', type = '' } = file;\n const category = type.split('/')[0];\n const extension = path.split('.').pop() || 'default';\n const { Icon, style } =\n iconMapping[extension] || iconMapping[category] || iconMapping.default;\n\n return <Icon size={magma.iconSizes.medium} style={isInverse ? {} : style} />;\n};\n","export const formatFileSize = (\n bytes: number | undefined,\n decimalPoint: number = 2,\n bytesLabel: string = 'Bytes'\n) => {\n if (bytes === undefined) return;\n if (bytes == 0) return `0 ${bytesLabel}`;\n const k = 1024;\n const sizes = [bytesLabel, 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n return (\n parseFloat((bytes / Math.pow(k, i)).toFixed(decimalPoint)) + ' ' + sizes[i]\n );\n};\n","import React, { forwardRef, useContext, useEffect, useState } from 'react';\n\nimport {\n CheckCircleIcon,\n CloseIcon,\n DeleteIcon,\n ErrorIcon,\n} from 'react-magma-icons';\n\nimport {\n ButtonColor,\n ButtonVariant,\n Card,\n Flex,\n FlexAlignItems,\n FlexBehavior,\n FlexProps,\n I18nContext,\n I18nInterface,\n IconButton,\n InverseContext,\n ThemeContext,\n ThemeInterface,\n Transition,\n Spinner,\n useIsInverse,\n} from 'react-magma-dom';\n\nimport { FileIcon } from './FileIcon';\nimport { FilePreview } from './FilePreview';\nimport { formatFileSize } from './utils';\n\nimport styled, { CreateStyled } from '@emotion/styled';\n\nconst typedStyled = styled as CreateStyled<ThemeInterface>;\n\nexport interface PreviewProps extends Omit<FlexProps, 'behavior'> {\n accept?: string | string[];\n file: FilePreview;\n isInverse?: boolean;\n maxSize?: number;\n minSize?: number;\n onDeleteFile?: (file: FilePreview) => void;\n onRemoveFile?: (file: FilePreview) => void;\n /**\n * @internal\n */\n testId?: string;\n thumbnails: boolean;\n}\n\nconst Thumb = typedStyled.div<{ file: FilePreview }>`\n background-image: ${({ file }) =>\n `url('${'preview' in file && file.preview}')`};\n background-repeat: no-repeat;\n background-size: cover;\n display: inline-block;\n vertical-align: middle;\n height: 40px;\n width: 40px;\n`;\n\nconst StatusIcons = typedStyled.div`\n display: grid;\n grid-template-areas: 'inner-div';\n height: auto;\n place-items: center;\n width: 46px;\n & > div {\n display: inline-block;\n right: 0;\n grid-area: inner-div;\n }\n`;\n\nconst IconStyles = {\n marginRight: '12px',\n display: 'flex',\n};\n\nconst Errors = typedStyled.div`\n border-top: 1px solid ${({ theme }) => theme.colors.neutral300};\n padding: 16px;\n font-size: ${({ theme }) => theme.typeScale.size02.fontSize};\n line-height: ${({ theme }) => theme.typeScale.size02.lineHeight};\n`;\n\nconst StyledFlex = typedStyled(Flex)`\n height: 56px;\n padding: 0 8px 0 16px;\n font-size: ${({ theme }) => theme.typeScale.size02.fontSize};\n line-height: ${({ theme }) => theme.typeScale.size02.lineHeight};\n`;\n\nconst FileName = typedStyled(Flex)`\n overflow: hidden;\n white-space: nowrap;\n align-items: center;\n text-overflow: ellipsis;\n display: block;\n margin-right: 24px;\n font-size: ${({ theme }) => theme.typeScale.size02.fontSize};\n line-height: ${({ theme }) => theme.typeScale.size02.lineHeight};\n`;\n\nconst StyledCard = typedStyled(Card)<{ file: FilePreview; isInverse: boolean }>`\n background-color: none;\n border-color: ${({ file, theme, isInverse }) =>\n file.errors\n ? isInverse\n ? theme.colors.danger200\n : theme.colors.danger\n : theme.colors.neutral300};\n border-width: 1px;\n margin: 10px 0;\n`;\n\nconst ErrorHeader = styled.span`\n display: block;\n\n > div {\n display: flex;\n align-self: center;\n margin-right: 12px;\n }\n`;\n\nconst ErrorMessage = styled.span`\n display: block;\n`;\n\nconst formatError = (\n error: { header?: string; message: string; code: string },\n constraints: {\n maxSize?: number;\n minSize?: number;\n accept?: string | string[];\n },\n byteLabel: string\n) => {\n const accept =\n Array.isArray(constraints.accept) && constraints.accept.length === 1\n ? constraints.accept[0]\n : constraints.accept;\n const messageSuffix = Array.isArray(accept)\n ? `one of ${accept.join(', ')}`\n : accept;\n switch (error.code) {\n case 'file-too-large':\n return {\n ...error,\n message: `${error.message} ${formatFileSize(\n constraints.maxSize,\n 2,\n byteLabel\n )}.`,\n };\n case 'file-too-small':\n return {\n ...error,\n message: `${error.message} ${formatFileSize(\n constraints.minSize,\n 2,\n byteLabel\n )}.`,\n };\n case 'file-invalid-type':\n return { ...error, message: `${error.message}: ${messageSuffix}` };\n default:\n return error;\n }\n};\n\nexport const Preview = forwardRef<HTMLDivElement, PreviewProps>(\n // eslint-disable-next-line complexity\n (props, ref) => {\n const {\n accept,\n file,\n isInverse: isInverseProp,\n maxSize,\n minSize,\n onDeleteFile,\n onRemoveFile,\n testId,\n thumbnails,\n ...rest\n } = props;\n\n const theme: ThemeInterface = useContext(ThemeContext);\n const i18n: I18nInterface = React.useContext(I18nContext);\n const isInverse = useIsInverse(isInverseProp);\n const [actions, setActions] = useState(<CloseIcon />);\n\n const handleRemoveFile = () => {\n onRemoveFile && typeof onRemoveFile === 'function' && onRemoveFile(file);\n };\n\n const handleDeleteFile = () => {\n onDeleteFile && typeof onDeleteFile === 'function' && onDeleteFile(file);\n };\n\n const FinishedActions = ({ status = 'ready' }: { status?: string }) => {\n const [done, setDone] = useState<boolean>(false);\n\n useEffect(() => {\n let mounted = true;\n setTimeout(() => {\n if (mounted) {\n setDone(true);\n }\n }, 1000);\n return () => {\n mounted = false;\n };\n }, [status]);\n\n if (status === 'error' || status === 'ready') {\n return (\n <StatusIcons>\n <IconButton\n onClick={handleRemoveFile}\n variant={ButtonVariant.link}\n color={ButtonColor.secondary}\n aria-label={i18n.dropzone.removeFile}\n icon={<CloseIcon />}\n />\n </StatusIcons>\n );\n }\n\n if (status === 'pending') {\n return (\n <StatusIcons>\n <Spinner\n color={isInverse ? theme.colors.neutral100 : theme.colors.primary}\n />\n </StatusIcons>\n );\n }\n\n return (\n <StatusIcons>\n <Transition isOpen={!done} unmountOnExit fade>\n <CheckCircleIcon\n color={isInverse ? theme.colors.success200 : theme.colors.success}\n style={{ marginTop: '4px' }}\n />\n </Transition>\n <Transition isOpen={done} unmountOnExit fade>\n <IconButton\n onClick={handleDeleteFile}\n variant={ButtonVariant.link}\n color={ButtonColor.secondary}\n aria-label={i18n.dropzone.deleteFile}\n icon={<DeleteIcon />}\n />\n </Transition>\n </StatusIcons>\n );\n };\n\n useEffect(() => {\n setActions(<FinishedActions status={file?.processor?.status} />);\n }, [file?.processor?.status]);\n\n return (\n <InverseContext.Provider value={{ isInverse }}>\n <StyledCard\n isInverse={isInverse}\n theme={theme}\n file={file}\n data-testid={props.testId}\n ref={ref}\n role={file.errors ? 'alert' : ''}\n >\n <StyledFlex\n theme={theme}\n behavior={FlexBehavior.container}\n alignItems={FlexAlignItems.center}\n {...rest}\n >\n <Flex\n behavior={FlexBehavior.item}\n alignItems={FlexAlignItems.center}\n style={IconStyles}\n >\n {file.errors ? (\n <ErrorIcon\n color={\n isInverse ? theme.colors.danger200 : theme.colors.danger\n }\n size={24}\n />\n ) : file.preview &&\n thumbnails &&\n file.type &&\n file.type.startsWith('image') ? (\n <Thumb role=\"img\" file={file} />\n ) : (\n <FileIcon isInverse={isInverse} file={file} />\n )}\n </Flex>\n <FileName xs behavior={FlexBehavior.item} theme={theme}>\n {file.name}\n </FileName>\n {file.processor && file.processor.status === 'pending' && (\n <Flex\n role=\"progressbar\"\n style={{ marginLeft: 'auto' }}\n behavior={FlexBehavior.item}\n >\n {file.processor.percent}\n </Flex>\n )}\n <Flex behavior={FlexBehavior.item}>{actions}</Flex>\n </StyledFlex>\n {file.errors && (\n <Errors theme={theme}>\n {file.errors.slice(0, 1).map(({ code, ...rest }) => {\n const { header = '', message } = formatError(\n { code, ...rest, ...i18n.dropzone.errors[code] },\n { accept, minSize, maxSize },\n i18n.dropzone.bytes\n );\n return (\n <React.Fragment key={code}>\n <ErrorHeader\n style={{\n color: isInverse\n ? theme.colors.danger200\n : theme.colors.danger,\n }}\n >\n {header}\n </ErrorHeader>\n <ErrorMessage>{message}</ErrorMessage>\n </React.Fragment>\n );\n })}\n </Errors>\n )}\n </StyledCard>\n </InverseContext.Provider>\n );\n }\n);\n","/* eslint-disable no-empty-pattern */\n/**\n * HELPFUL NOTE!\n * SINCE THIS PACKAGE USES `FILE` WE MUST USE `Object.assign` IN LIEU OF SPREADING\n * `{...file}` WILL NOT COPY ALL OF THE FILE PROPERTIES\n */\n\nimport React from 'react';\nimport {\n useDropzone,\n DropzoneOptions,\n DropzoneRootProps,\n FileRejection,\n} from 'react-dropzone';\nimport {\n Button,\n ButtonColor,\n ButtonVariant,\n Flex,\n FlexBehavior,\n FlexProps,\n FormFieldContainer,\n FormFieldContainerBaseProps,\n I18nContext,\n I18nInterface,\n InverseContext,\n ThemeContext,\n ThemeInterface,\n useGenerateId,\n useIsInverse,\n} from 'react-magma-dom';\n\nimport { CloudUploadIcon } from 'react-magma-icons';\nimport { Preview } from './Preview';\nimport { FilePreview, FileError } from './FilePreview';\nimport { transparentize } from 'polished';\nimport styled, { CreateStyled } from '@emotion/styled';\n\nconst typedStyled = styled as CreateStyled<ThemeInterface>;\n\nexport interface OnSendFileProps {\n file: FilePreview;\n onError?: ({}: { errors: FileError[]; file: FilePreview }) => void;\n onFinish?: ({}: { file: FilePreview }) => void;\n onProgress?: ({}: { percent: number; file: FilePreview }) => void;\n}\n\ntype DragState =\n | 'error'\n | 'dragAccept'\n | 'dragReject'\n | 'dragActive'\n | 'default';\n\n// NOTE: These props are manually copied to dropzone.mdx\nexport interface DropzoneProps\n extends Omit<FormFieldContainerBaseProps, 'fieldId' | 'errorMessage'> {\n /**\n * Set accepted file types. See https://github.com/okonet/attr-accept for more information. Keep in mind that mime type determination is not reliable across platforms. CSV files, for example, are reported as text/plain under macOS but as application/vnd.ms-excel under Windows. In some cases there might not be a mime type set at all. See: https://github.com/react-dropzone/react-dropzone/issues/276\n */\n accept?: string | string[];\n /**\n * Enable/Disable the input\n */\n disabled?: boolean;\n /**\n * Additional props to pass to the dropzone, see https://react-dropzone.js.org/#src\n */\n dropzoneOptions?: Partial<Omit<DropzoneOptions, 'onDrop'>>;\n /**\n * Content of the helper message.\n */\n helperMessage?: string;\n /**\n * @internal\n */\n id?: string;\n /**\n * Maximum accepted number of files The default value is 0 which means there is no limitation to how many files are accepted.\n * @default 0\n */\n maxFiles?: number;\n /**\n * Minimum accepted number of files.\n */\n minFiles?: number;\n /**\n * Maximum file size (in bytes)\n * @default Infinity\n */\n maxSize?: number;\n /**\n * Minimum file size (in bytes)\n * @default 0\n */\n minSize?: number;\n /**\n * Allow drag 'n' drop (or selection from the file dialog) of multiple files.\n * @default true\n */\n multiple?: boolean;\n /**\n * If true, disables drag 'n' drop\n * @default false\n */\n noDrag?: boolean;\n /**\n * Callback for when a file is deleted\n */\n onDeleteFile?: (file: FilePreview) => void;\n /**\n * Callback for when a file is deleted\n */\n onRemoveFile?: (file: FilePreview) => void;\n /**\n * Callback for when a file is added to the preview list via dropping or selecting. Will be ran on new files when `sendFiles` is true.\n */\n onSendFile?: (props: OnSendFileProps) => void;\n /**\n * Run `onSendFile` on any new files. Delay processing by setting to `false` until processing is desired.\n * @default false\n */\n sendFiles?: boolean;\n /**\n * @internal\n */\n testId?: string;\n /**\n * Show thumbnails for images in lieu of the file icon.\n * @default true\n */\n thumbnails?: boolean;\n}\n\nconst Container = typedStyled(Flex)<\n DropzoneRootProps &\n FlexProps & {\n dragState?: DragState;\n noDrag?: boolean;\n isInverse?: boolean;\n }\n>`\n flex-direction: column;\n align-items: ${({ noDrag }) => (noDrag ? 'left' : 'center')};\n justify-content: ${({ noDrag }) => (noDrag ? 'left' : 'center')};\n text-align: ${({ noDrag }) => (noDrag ? 'left' : 'center')};\n padding: ${({ noDrag }) => (noDrag ? '0px' : '24px')};\n border-radius: ${({ noDrag }) => (noDrag ? '0px' : '4px')};\n border: ${({ dragState = 'default', noDrag, theme, isInverse }) =>\n noDrag\n ? `0px`\n : dragState === 'dragReject' || dragState === 'error'\n ? isInverse\n ? `1px dashed ${theme.colors.danger200}`\n : `1px dashed ${theme.colors.danger}`\n : dragState === 'dragActive'\n ? `1px dashed ${theme.colors.primary}`\n : dragState === 'dragAccept'\n ? `1px dashed ${theme.colors.success}`\n : `1px dashed ${theme.colors.neutral400}`};\n\n border-style: ${({ dragState = 'default' }) =>\n dragState === 'error' ? 'solid' : 'dashed'};\n background-color: ${({ theme, noDrag, isInverse }) =>\n noDrag\n ? 'transparent'\n : isInverse\n ? transparentize(0.75, theme.colors.neutral900)\n : theme.colors.neutral200};\n outline: none;\n transition: ${({ noDrag }) => `border ${noDrag ? 0 : '.24s'} ease-in-out`};\n`;\n\nconst HelperMessage = typedStyled.span<{ isInverse?: boolean }>`\n color: ${({ theme, isInverse }) =>\n isInverse ? theme.colors.neutral100 : theme.colors.neutral700};\n display: block;\n font-size: 14px;\n margin: -8px 0 16px 0;\n`;\n\nconst Wrapper = typedStyled.div<{ isInverse?: boolean }>`\n color: ${({ theme, isInverse }) =>\n isInverse ? theme.colors.neutral100 : theme.colors.neutral700};\n margin: 0 0 24px 0;\n font-size: ${({ theme }) => theme.typeScale.size02.fontSize};\n line-height: ${({ theme }) => theme.typeScale.size02.lineHeight};\n font-weight: 500;\n padding: ${({ theme }) => theme.spaceScale.spacing01};\n`;\nexport const Dropzone = React.forwardRef<HTMLInputElement, DropzoneProps>(\n (props, ref) => {\n const {\n accept,\n containerStyle,\n disabled,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n dropzoneOptions = {\n multiple: true,\n },\n helperMessage,\n id: defaultId,\n inputSize,\n isInverse: isInverseProp,\n isLabelVisuallyHidden,\n labelStyle,\n labelText,\n maxFiles,\n minFiles,\n maxSize,\n minSize,\n multiple = true,\n noDrag = false,\n onSendFile,\n onDeleteFile,\n onRemoveFile,\n sendFiles = false,\n testId,\n thumbnails = true,\n ...rest\n } = props;\n\n const [files, setFiles] = React.useState<FilePreview[]>([]);\n const [errorMessage, setErrorMessage] = React.useState<string | null>(null);\n\n const isInverse = useIsInverse(isInverseProp);\n const theme: ThemeInterface = React.useContext(ThemeContext);\n const i18n: I18nInterface = React.useContext(I18nContext);\n const id = useGenerateId(defaultId);\n\n const onDrop = React.useCallback(\n (acceptedFiles: FilePreview[], rejectedFiles: FileRejection[]) => {\n setFiles((files: FilePreview[]) => [\n ...files,\n ...acceptedFiles.map((file: FilePreview) =>\n Object.assign(file, {\n preview: URL.createObjectURL(file),\n })\n ),\n ...rejectedFiles.map(\n ({ file, errors }: { file: FilePreview; errors: FileError[] }) =>\n Object.assign(file, {\n errors,\n })\n ),\n ]);\n },\n []\n );\n\n const {\n getInputProps,\n getRootProps,\n isDragAccept,\n isDragActive,\n isDragReject,\n open,\n } = useDropzone({\n noClick: true,\n disabled,\n multiple,\n maxSize,\n minSize,\n accept,\n onDrop,\n noDrag,\n });\n\n const inputProps = getInputProps({ id });\n\n const dragState: DragState = errorMessage\n ? 'error'\n : isDragAccept\n ? 'dragAccept'\n : isDragReject\n ? 'dragReject'\n : isDragActive\n ? 'dragActive'\n : 'default';\n\n const handleRemoveFile = (removedFile: FilePreview) => {\n setFiles(files => files.filter(file => file !== removedFile));\n onRemoveFile &&\n typeof onRemoveFile === 'function' &&\n onRemoveFile(removedFile);\n };\n\n const handleDeleteFile = (removedFile: FilePreview) => {\n setFiles(files => files.filter(file => file !== removedFile));\n onDeleteFile &&\n typeof onDeleteFile === 'function' &&\n onDeleteFile(removedFile);\n };\n\n const setProgress = (props: { percent: number; file: FilePreview }) => {\n setFiles(files =>\n files.map(file =>\n file === props.file\n ? Object.assign(file, {\n processor: {\n ...file.processor,\n percent: `${props.percent}%`,\n status: 'pending',\n },\n })\n : file\n )\n );\n };\n\n const setFinished = (props: { file: FilePreview }) => {\n setFiles(files =>\n files.map(file =>\n file === props.file\n ? Object.assign(file, {\n processor: {\n ...file.processor,\n percent: '',\n status: 'finished',\n },\n })\n : file\n )\n );\n };\n\n const setError = (props: { errors: FileError[]; file: FilePreview }) => {\n setFiles(files =>\n files.map(file =>\n file === props.file\n ? Object.assign(file, {\n errors: props.errors,\n processor: { ...file.processor, status: 'error' },\n })\n : file\n )\n );\n };\n\n const formatError = (\n code: string | null,\n constraints: { maxFiles?: number; minFiles?: number }\n ) => {\n if (code === null) return null;\n const error = i18n.dropzone.errors[code];\n switch (code) {\n case 'too-many-files':\n return `${error.message} ${constraints.maxFiles} ${i18n.dropzone.files}.`;\n case 'too-few-files':\n return `${error.message} ${constraints.minFiles} ${i18n.dropzone.files}.`;\n default:\n return error.message;\n }\n };\n\n React.useEffect(\n () => () => {\n files.forEach(\n file => file.preview && URL.revokeObjectURL(file.preview)\n );\n },\n [files]\n );\n\n React.useEffect(() => {\n const minFileError = minFiles && files.length < minFiles;\n const maxFileError = maxFiles && files.length > maxFiles;\n\n setErrorMessage(\n formatError(\n maxFileError\n ? 'too-many-files'\n : minFileError\n ? 'too-few-files'\n : null,\n { minFiles, maxFiles }\n )\n );\n\n if (sendFiles && files.length > 0 && !maxFileError && !minFileError) {\n setFiles((files: FilePreview[]) => {\n return files.map((file: FilePreview) => {\n !file.errors &&\n !file.processor &&\n onSendFile &&\n onSendFile({\n file,\n onError: setError,\n onFinish: setFinished,\n onProgress: setProgress,\n });\n return file;\n });\n });\n }\n }, [sendFiles, files.length, onSendFile]);\n\n return (\n <InverseContext.Provider value={{ isInverse }}>\n <FormFieldContainer\n actionable={false}\n containerStyle={containerStyle}\n errorMessage={errorMessage}\n fieldId={id}\n inputSize={inputSize}\n isInverse={isInverse}\n isLabelVisuallyHidden={isLabelVisuallyHidden}\n labelStyle={labelStyle}\n labelText={labelText}\n messageStyle={{ minHeight: 0 }}\n data-testid={testId}\n >\n <HelperMessage theme={theme} isInverse={isInverse}>\n {helperMessage}\n </HelperMessage>\n <Container\n behavior={FlexBehavior.container}\n dragState={dragState}\n isInverse={isInverse}\n noDrag={noDrag}\n theme={theme}\n {...getRootProps()}\n {...rest}\n testId={testId}\n tabIndex={-1}\n >\n <input\n ref={ref}\n type={inputProps.type}\n accept={inputProps.accept}\n autoComplete={inputProps.autoComplete}\n id={inputProps.id}\n multiple={inputProps.multiple}\n onChange={inputProps.onChange}\n onClick={inputProps.onClick}\n style={inputProps.style}\n tabIndex={inputProps.tabIndex}\n />\n {noDrag ? (\n <Flex xs behavior={FlexBehavior.item}>\n <Button\n color={ButtonColor.primary}\n disabled={disabled}\n isInverse={isInverse}\n onClick={open}\n style={{ margin: 0 }}\n >\n {i18n.dropzone.browseFiles}\n </Button>\n </Flex>\n ) : (\n <Flex behavior={FlexBehavior.item}>\n <CloudUploadIcon\n aria-hidden=\"true\"\n color={\n isInverse\n ? theme.colors.neutral100\n : theme.colors.neutral500\n }\n size={48}\n />\n <Wrapper isInverse={isInverse} theme={theme}>\n {i18n.dropzone.dragMessage}\n </Wrapper>\n <Button\n color={ButtonColor.primary}\n disabled={disabled}\n isInverse={isInverse}\n onClick={open}\n style={{ margin: 0 }}\n variant={ButtonVariant.solid}\n >\n {i18n.dropzone.browseFiles}\n </Button>\n </Flex>\n )}\n </Container>\n </FormFieldContainer>\n {files.map((file: FilePreview) => (\n <Preview\n accept={accept}\n file={file}\n isInverse={isInverse}\n key={file.name}\n maxSize={maxSize}\n minSize={minSize}\n onDeleteFile={handleDeleteFile}\n onRemoveFile={handleRemoveFile}\n thumbnails={thumbnails}\n />\n ))}\n </InverseContext.Provider>\n );\n }\n);\n"],"names":["icons","default","Icon","InsertDriveFileIcon","style","color","magma","colors","neutral500","word","FileWordIcon","info500","excel","FileExcelIcon","success500","powerpoint","FilePowerpointIcon","warning500","pdf","FilePdfIcon","danger500","image","ImageIcon","video","VideocamIcon","audio","AudiotrackIcon","archive","FileZipIcon","iconMapping","xlsx","xlsm","xlsb","xltx","xls","xlt","doc","docx","docm","dotx","dotm","docb","pptx","pptm","ppt","png","svg","zip","FileIcon","_ref","file","isInverse","_file$path","path","_file$type","type","category","split","extension","pop","_ref2","_jsx","size","iconSizes","medium","formatFileSize","bytes","decimalPoint","bytesLabel","undefined","sizes","i","Math","floor","log","parseFloat","pow","toFixed","typedStyled","styled","Thumb","div","_templateObject","_taggedTemplateLiteralLoose","preview","StatusIcons","_templateObject2","IconStyles","marginRight","display","Errors","_templateObject3","theme","neutral300","_ref3","typeScale","size02","fontSize","_ref4","lineHeight","StyledFlex","Flex","_templateObject4","_ref5","_ref6","FileName","_templateObject5","_ref7","_ref8","StyledCard","Card","_templateObject6","_ref9","errors","danger200","danger","ErrorHeader","span","_templateObject7","ErrorMessage","_templateObject8","Preview","forwardRef","props","ref","accept","isInverseProp","maxSize","minSize","onDeleteFile","onRemoveFile","thumbnails","rest","_objectWithoutPropertiesLoose","_excluded","useContext","ThemeContext","i18n","React","I18nContext","useIsInverse","_useState","useState","CloseIcon","actions","setActions","handleRemoveFile","handleDeleteFile","FinishedActions","_ref10","status","_ref10$status","_useState2","done","setDone","useEffect","mounted","setTimeout","children","IconButton","onClick","variant","ButtonVariant","link","ButtonColor","secondary","dropzone","removeFile","icon","Spinner","neutral100","primary","_jsxs","Transition","isOpen","unmountOnExit","fade","CheckCircleIcon","success200","success","marginTop","deleteFile","DeleteIcon","_file$processor","processor","_file$processor2","InverseContext","Provider","value","testId","role","_extends","behavior","FlexBehavior","container","alignItems","FlexAlignItems","center","item","ErrorIcon","startsWith","xs","name","marginLeft","percent","slice","map","_ref11","code","_formatError","error","constraints","byteLabel","Array","isArray","length","messageSuffix","join","message","formatError","_excluded2","_formatError$header","header","Fragment","Container","noDrag","_ref6$dragState","dragState","neutral400","_ref7$dragState","transparentize","neutral900","neutral200","HelperMessage","neutral700","Wrapper","_ref12","_ref13","_ref14","spaceScale","spacing01","containerStyle","disabled","helperMessage","defaultId","id","inputSize","isLabelVisuallyHidden","labelStyle","labelText","maxFiles","minFiles","_props$multiple","multiple","_props$noDrag","onSendFile","_props$sendFiles","sendFiles","_props$thumbnails","_React$useState","files","setFiles","_React$useState2","errorMessage","setErrorMessage","useGenerateId","onDrop","useCallback","acceptedFiles","rejectedFiles","concat","Object","assign","URL","createObjectURL","_ref15","_useDropzone","useDropzone","noClick","getRootProps","isDragAccept","isDragActive","isDragReject","open","inputProps","getInputProps","removedFile","filter","setProgress","setFinished","setError","forEach","revokeObjectURL","minFileError","maxFileError","onError","onFinish","onProgress","FormFieldContainer","actionable","fieldId","messageStyle","minHeight","tabIndex","autoComplete","onChange","Button","margin","browseFiles","CloudUploadIcon","dragMessage","solid"],"mappings":"6rBAsBMA,EAAQ,CACZC,QAAS,CACPC,KAAMC,sBACNC,MAAO,CACLC,MAAOC,QAAMC,OAAOC,aAGxBC,KAAM,CACJP,KAAMQ,eACNN,MAAO,CACLC,MAAOC,QAAMC,OAAOI,UAGxBC,MAAO,CACLV,KAAMW,gBACNT,MAAO,CACLC,MAAOC,QAAMC,OAAOO,aAGxBC,WAAY,CACVb,KAAMc,qBACNZ,MAAO,CACLC,MAAOC,QAAMC,OAAOU,aAGxBC,IAAK,CACHhB,KAAMiB,cACNf,MAAO,CACLC,MAAOC,QAAMC,OAAOa,YAGxBC,MAAO,CACLnB,KAAMoB,YACNlB,MAAO,CACLC,MAAOC,QAAMC,OAAOC,aAGxBe,MAAO,CACLrB,KAAMsB,eACNpB,MAAO,CACLC,MAAOC,QAAMC,OAAOC,aAGxBiB,MAAO,CACLvB,KAAMwB,iBACNtB,MAAO,CACLC,MAAOC,QAAMC,OAAOC,aAGxBmB,QAAS,CACPzB,KAAM0B,cACNxB,MAAO,CACLC,MAAOC,QAAMC,OAAOC,cAKpBqB,EAEF,CACF5B,QAASD,UACT8B,KAAM9B,EAAMY,MACZmB,KAAM/B,EAAMY,MACZoB,KAAMhC,EAAMY,MACZqB,KAAMjC,EAAMY,MACZsB,IAAKlC,EAAMY,MACXuB,IAAKnC,EAAMY,MACXwB,IAAKpC,EAAMS,KACX4B,KAAMrC,EAAMS,KACZ6B,KAAMtC,EAAMS,KACZ8B,KAAMvC,EAAMS,KACZ+B,KAAMxC,EAAMS,KACZgC,KAAMzC,EAAMS,KACZiC,KAAM1C,EAAMe,WACZ4B,KAAM3C,EAAMe,WACZ6B,IAAK5C,EAAMe,WACXG,IAAKlB,EAAMkB,IACX2B,IAAK7C,EAAMqB,MACXyB,IAAK9C,EAAMqB,MACXA,MAA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GAAWmB,WAEtB9E,EACCpK,MAACwC,QAAKoG,MAAGT,SAAUC,eAAaK,KAAKxC,SACnCjG,MAACqP,UACC7S,MAAO+J,cAAYO,QACnBuE,SAAUA,EACV/L,UAAWA,EACX6G,QAAS2H,GACTvR,MAAO,CAAE+S,OAAQ,GAAIrJ,SAEpBrB,EAAK6B,SAAS8I,gBAInBxI,OAACvE,QAAK2F,SAAUC,eAAaK,KAAKxC,UAChCjG,MAACwP,mBACC,cAAY,OACZhT,MACE8C,EACIyC,EAAMrF,OAAOmK,WACb9E,EAAMrF,OAAOC,WAEnBsD,KAAM,KAERD,MAAC8K,GAAQxL,UAAWA,EAAWyC,MAAOA,EAAMkE,SACzCrB,EAAK6B,SAASgJ,cAEjBzP,MAACqP,UACC7S,MAAO+J,cAAYO,QACnBuE,SAAUA,EACV/L,UAAWA,EACX6G,QAAS2H,GACTvR,MAAO,CAAE+S,OAAQ,GACjBlJ,QAASC,gBAAcqJ,MAAMzJ,SAE5BrB,EAAK6B,SAAS8I,wBAMxBhD,EAAMtD,IAAI,SAAC5J,UACVW,MAAC4D,GACCI,OAAQA,EACR3E,KAAMA,EACNC,UAAWA,EAEX4E,QAASA,EACTC,QAASA,EACTC,aAAckB,GACdjB,aAAcgB,GACdf,WAAYA,GALPjF,EAAKwJ,KAMV,KAIV"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-magma/dropzone",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@emotion/styled": "^10.0.27",
|
|
31
31
|
"react": "^17.0.2",
|
|
32
32
|
"react-dom": "^17.0.2",
|
|
33
|
-
"react-magma-dom": "^4.
|
|
33
|
+
"react-magma-dom": "^4.4.0-next.2",
|
|
34
34
|
"react-magma-icons": "^3.0.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@emotion/styled": "^10.0.27",
|
|
43
43
|
"react": "^17.0.2",
|
|
44
44
|
"react-dom": "^17.0.2",
|
|
45
|
-
"react-magma-dom": "^4.
|
|
45
|
+
"react-magma-dom": "^4.4.0",
|
|
46
46
|
"react-magma-icons": "^3.0.0"
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
InverseContext,
|
|
27
27
|
ThemeContext,
|
|
28
28
|
ThemeInterface,
|
|
29
|
-
styled,
|
|
30
29
|
useGenerateId,
|
|
31
30
|
useIsInverse,
|
|
32
31
|
} from 'react-magma-dom';
|
|
@@ -35,6 +34,9 @@ import { CloudUploadIcon } from 'react-magma-icons';
|
|
|
35
34
|
import { Preview } from './Preview';
|
|
36
35
|
import { FilePreview, FileError } from './FilePreview';
|
|
37
36
|
import { transparentize } from 'polished';
|
|
37
|
+
import styled, { CreateStyled } from '@emotion/styled';
|
|
38
|
+
|
|
39
|
+
const typedStyled = styled as CreateStyled<ThemeInterface>;
|
|
38
40
|
|
|
39
41
|
export interface OnSendFileProps {
|
|
40
42
|
file: FilePreview;
|
|
@@ -130,7 +132,7 @@ export interface DropzoneProps
|
|
|
130
132
|
thumbnails?: boolean;
|
|
131
133
|
}
|
|
132
134
|
|
|
133
|
-
const Container =
|
|
135
|
+
const Container = typedStyled(Flex)<
|
|
134
136
|
DropzoneRootProps &
|
|
135
137
|
FlexProps & {
|
|
136
138
|
dragState?: DragState;
|
|
@@ -169,7 +171,7 @@ const Container = styled(Flex)<
|
|
|
169
171
|
transition: ${({ noDrag }) => `border ${noDrag ? 0 : '.24s'} ease-in-out`};
|
|
170
172
|
`;
|
|
171
173
|
|
|
172
|
-
const HelperMessage =
|
|
174
|
+
const HelperMessage = typedStyled.span<{ isInverse?: boolean }>`
|
|
173
175
|
color: ${({ theme, isInverse }) =>
|
|
174
176
|
isInverse ? theme.colors.neutral100 : theme.colors.neutral700};
|
|
175
177
|
display: block;
|
|
@@ -177,7 +179,7 @@ const HelperMessage = styled.span<{ isInverse?: boolean }>`
|
|
|
177
179
|
margin: -8px 0 16px 0;
|
|
178
180
|
`;
|
|
179
181
|
|
|
180
|
-
const Wrapper =
|
|
182
|
+
const Wrapper = typedStyled.div<{ isInverse?: boolean }>`
|
|
181
183
|
color: ${({ theme, isInverse }) =>
|
|
182
184
|
isInverse ? theme.colors.neutral100 : theme.colors.neutral700};
|
|
183
185
|
margin: 0 0 24px 0;
|
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
ThemeInterface,
|
|
24
24
|
Transition,
|
|
25
25
|
Spinner,
|
|
26
|
-
styled,
|
|
27
26
|
useIsInverse,
|
|
28
27
|
} from 'react-magma-dom';
|
|
29
28
|
|
|
@@ -31,6 +30,10 @@ import { FileIcon } from './FileIcon';
|
|
|
31
30
|
import { FilePreview } from './FilePreview';
|
|
32
31
|
import { formatFileSize } from './utils';
|
|
33
32
|
|
|
33
|
+
import styled, { CreateStyled } from '@emotion/styled';
|
|
34
|
+
|
|
35
|
+
const typedStyled = styled as CreateStyled<ThemeInterface>;
|
|
36
|
+
|
|
34
37
|
export interface PreviewProps extends Omit<FlexProps, 'behavior'> {
|
|
35
38
|
accept?: string | string[];
|
|
36
39
|
file: FilePreview;
|
|
@@ -46,7 +49,7 @@ export interface PreviewProps extends Omit<FlexProps, 'behavior'> {
|
|
|
46
49
|
thumbnails: boolean;
|
|
47
50
|
}
|
|
48
51
|
|
|
49
|
-
const Thumb =
|
|
52
|
+
const Thumb = typedStyled.div<{ file: FilePreview }>`
|
|
50
53
|
background-image: ${({ file }) =>
|
|
51
54
|
`url('${'preview' in file && file.preview}')`};
|
|
52
55
|
background-repeat: no-repeat;
|
|
@@ -57,7 +60,7 @@ const Thumb = styled.div<{ file: FilePreview }>`
|
|
|
57
60
|
width: 40px;
|
|
58
61
|
`;
|
|
59
62
|
|
|
60
|
-
const StatusIcons =
|
|
63
|
+
const StatusIcons = typedStyled.div`
|
|
61
64
|
display: grid;
|
|
62
65
|
grid-template-areas: 'inner-div';
|
|
63
66
|
height: auto;
|
|
@@ -75,21 +78,21 @@ const IconStyles = {
|
|
|
75
78
|
display: 'flex',
|
|
76
79
|
};
|
|
77
80
|
|
|
78
|
-
const Errors =
|
|
81
|
+
const Errors = typedStyled.div`
|
|
79
82
|
border-top: 1px solid ${({ theme }) => theme.colors.neutral300};
|
|
80
83
|
padding: 16px;
|
|
81
84
|
font-size: ${({ theme }) => theme.typeScale.size02.fontSize};
|
|
82
85
|
line-height: ${({ theme }) => theme.typeScale.size02.lineHeight};
|
|
83
86
|
`;
|
|
84
87
|
|
|
85
|
-
const StyledFlex =
|
|
88
|
+
const StyledFlex = typedStyled(Flex)`
|
|
86
89
|
height: 56px;
|
|
87
90
|
padding: 0 8px 0 16px;
|
|
88
91
|
font-size: ${({ theme }) => theme.typeScale.size02.fontSize};
|
|
89
92
|
line-height: ${({ theme }) => theme.typeScale.size02.lineHeight};
|
|
90
93
|
`;
|
|
91
94
|
|
|
92
|
-
const FileName =
|
|
95
|
+
const FileName = typedStyled(Flex)`
|
|
93
96
|
overflow: hidden;
|
|
94
97
|
white-space: nowrap;
|
|
95
98
|
align-items: center;
|
|
@@ -100,7 +103,7 @@ const FileName = styled(Flex)`
|
|
|
100
103
|
line-height: ${({ theme }) => theme.typeScale.size02.lineHeight};
|
|
101
104
|
`;
|
|
102
105
|
|
|
103
|
-
const StyledCard =
|
|
106
|
+
const StyledCard = typedStyled(Card)<{ file: FilePreview; isInverse: boolean }>`
|
|
104
107
|
background-color: none;
|
|
105
108
|
border-color: ${({ file, theme, isInverse }) =>
|
|
106
109
|
file.errors
|