@react-magma/dropzone 15.0.1-v6-next.0 → 15.1.1-v6-next.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 +11 -11
- 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/dist/src/src/components/dropzone/Dropzone.d.ts +10 -1
- package/dist/src/src/components/dropzone/Dropzone.stories.d.ts +16 -0
- package/package.json +5 -5
- package/src/components/dropzone/Dropzone.stories.tsx +16 -1
- package/src/components/dropzone/Dropzone.test.js +20 -1
- package/src/components/dropzone/Dropzone.tsx +22 -6
- package/src/components/dropzone/FileIcon.tsx +8 -8
- package/src/components/dropzone/Preview.tsx +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileuploader.modern.module.js","sources":["../src/components/dropzone/FileIcon.tsx","../src/components/dropzone/utils.ts","../src/components/dropzone/Dropzone.tsx","../src/components/dropzone/Preview.tsx"],"sourcesContent":["import React from 'react';\n\nimport { magma } from 'react-magma-dom';\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';\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.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n word: {\n Icon: FileWordIcon,\n style: {\n color: magma.colors.blue500,\n },\n inverseStyle: {\n color: magma.colors.blue500,\n },\n },\n excel: {\n Icon: FileExcelIcon,\n style: {\n color: magma.colors.green500,\n },\n inverseStyle: {\n color: magma.colors.green500,\n },\n },\n powerpoint: {\n Icon: FilePowerpointIcon,\n style: {\n color: magma.colors.tangerine600,\n },\n inverseStyle: {\n color: magma.colors.tangerine500,\n },\n },\n pdf: {\n Icon: FilePdfIcon,\n style: {\n color: magma.colors.red600,\n },\n inverseStyle: {\n color: magma.colors.red500,\n },\n },\n image: {\n Icon: ImageIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n video: {\n Icon: VideocamIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n audio: {\n Icon: AudiotrackIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n archive: {\n Icon: FileZipIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n};\n\nconst iconMapping: {\n [key: string]: {\n Icon: any;\n style: React.CSSProperties;\n inverseStyle: React.CSSProperties;\n };\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, inverseStyle } =\n iconMapping[extension] || iconMapping[category] || iconMapping.default;\n\n return (\n <Icon\n size={magma.iconSizes.medium}\n style={isInverse ? inverseStyle : style}\n />\n );\n};\n","export const formatFileSize = (\n bytes: number | undefined,\n decimalPoint = 2,\n bytesLabel = '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","/* 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, { useImperativeHandle } from 'react';\n\nimport { transparentize } from 'polished';\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 styled,\n Announce,\n VisuallyHidden,\n} from 'react-magma-dom';\nimport { CloudUploadIcon } from 'react-magma-icons';\n\nimport { FilePreview, FileError } from './FilePreview';\nimport { Preview } from './Preview';\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\nenum DragState {\n error = 'error',\n dragAccept = 'dragAccept',\n dragReject = 'dragReject',\n dragActive = 'dragActive',\n default = 'default',\n}\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 getErrorBorderColor = (\n dragState: DragState,\n theme: ThemeInterface,\n isInverse?: boolean\n) => {\n if (!isInverse) {\n return theme.colors.danger;\n }\n\n return dragState === DragState.error\n ? theme.colors.red500\n : theme.colors.red400;\n};\n\nconst getContainerBorder = ({\n dragState = DragState.default,\n noDrag,\n theme,\n isInverse,\n}: {\n dragState?: DragState;\n noDrag?: boolean;\n theme: ThemeInterface;\n isInverse?: boolean;\n}) => {\n if (noDrag) {\n return '0px';\n }\n\n if (dragState === DragState.dragReject || dragState === DragState.error) {\n const width = dragState === DragState.error ? '1px' : '2px';\n\n return `${width} dashed ${getErrorBorderColor(dragState, theme, isInverse)}`;\n }\n\n if (dragState === DragState.dragActive) {\n return `2px dashed ${theme.colors.blue500}`;\n }\n\n if (dragState === DragState.dragAccept) {\n return `2px dashed ${theme.colors.green500}`;\n }\n\n return `2px dashed ${\n isInverse ? theme.colors.neutral800 : theme.colors.neutral300\n }`;\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, theme }) =>\n noDrag ? theme.borderRadiusNone : theme.borderRadiusSmall};\n border: ${getContainerBorder};\n\n border-style: ${({ dragState = DragState.default }) =>\n dragState === DragState.error ? 'solid' : 'dashed'};\n background-color: ${({ theme, noDrag, isInverse }) =>\n noDrag\n ? 'transparent'\n : isInverse\n ? transparentize(0.6, theme.colors.neutral1200)\n : theme.colors.neutral100};\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.neutral500 : 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.neutral0 : theme.colors.brand.navy};\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`;\n\nconst PreviewList = styled.ul`\n list-style: none;\n padding: 0;\n`;\n\nconst PreviewItem = styled.li``;\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 const [announcement, setAnnouncement] = React.useState<string>('');\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 const helperMessageId = useGenerateId(`${id}-helper`);\n\n const browseFileButtonRef = React.useRef<HTMLButtonElement>(null);\n\n const onDrop = React.useCallback(\n (acceptedFiles: FilePreview[], rejectedFiles: FileRejection[]) => {\n const newFiles = [\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 setFiles((prevFiles: FilePreview[]) => [...prevFiles, ...newFiles]);\n\n if (acceptedFiles.length > 0) {\n const fileNames = acceptedFiles.map(file => file.name).join(', ');\n const message =\n acceptedFiles.length === 1\n ? i18n.dropzone.fileAdded.replace(/\\{fileName\\}/g, fileNames)\n : i18n.dropzone.filesAdded\n .replace(/\\{count\\}/g, acceptedFiles.length.toString())\n .replace(/\\{fileNames\\}/g, fileNames);\n\n setAnnouncement(message);\n }\n\n browseFileButtonRef.current && browseFileButtonRef.current.focus();\n },\n [i18n]\n );\n\n const {\n getInputProps,\n getRootProps,\n isDragAccept,\n isDragActive,\n isDragReject,\n open,\n inputRef,\n } = useDropzone({\n noClick: true,\n disabled,\n multiple,\n maxSize,\n minSize,\n accept,\n onDrop,\n noDrag,\n ...dropzoneOptions,\n });\n\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(\n ref,\n () => inputRef.current\n );\n\n const inputProps = getInputProps({ id });\n\n let dragState = DragState.default;\n\n if (errorMessage) {\n dragState = DragState.error;\n } else if (isDragAccept) {\n dragState = DragState.dragAccept;\n } else if (isDragReject) {\n dragState = DragState.dragReject;\n } else if (isDragActive) {\n dragState = DragState.dragActive;\n }\n\n const handleRemoveFile = (removedFile: FilePreview) => {\n setFiles(prevFiles => prevFiles.filter(file => file !== removedFile));\n\n if (onRemoveFile && typeof onRemoveFile === 'function') {\n onRemoveFile(removedFile);\n }\n\n const message = i18n.dropzone.fileRemoved.replace(\n /\\{fileName\\}/g,\n removedFile.name\n );\n\n setAnnouncement(message);\n\n browseFileButtonRef.current && browseFileButtonRef.current.focus();\n };\n\n const handleDeleteFile = (removedFile: FilePreview) => {\n setFiles(prevFiles => prevFiles.filter(file => file !== removedFile));\n\n if (onDeleteFile && typeof onDeleteFile === 'function') {\n onDeleteFile(removedFile);\n }\n\n const message = i18n.dropzone.fileDeleted.replace(\n /\\{fileName\\}/g,\n removedFile.name\n );\n\n setAnnouncement(message);\n\n browseFileButtonRef.current && browseFileButtonRef.current.focus();\n };\n\n const setProgress = (progressProps: {\n percent: number;\n file: FilePreview;\n }) => {\n setFiles(prevFiles =>\n prevFiles.map(file =>\n file === progressProps.file\n ? Object.assign(file, {\n processor: {\n ...file.processor,\n percent: `${progressProps.percent}%`,\n status: 'pending',\n },\n })\n : file\n )\n );\n\n // Announce progress every 25% to avoid too many announcements\n if (progressProps.percent > 0 && progressProps.percent % 25 === 0) {\n const message = i18n.dropzone.fileUploading\n .replace(/\\{fileName\\}/g, progressProps.file.name)\n .replace(/\\{percent\\}/g, progressProps.percent.toString());\n\n setAnnouncement(message);\n }\n };\n\n const setFinished = (finishedProps: { file: FilePreview }) => {\n setFiles(prevFiles =>\n prevFiles.map(file =>\n file === finishedProps.file\n ? Object.assign(file, {\n processor: {\n ...file.processor,\n percent: '',\n status: 'finished',\n },\n })\n : file\n )\n );\n\n // Announce successful upload\n const message = i18n.dropzone.fileUploaded.replace(\n /\\{fileName\\}/g,\n finishedProps.file.name\n );\n\n setAnnouncement(message);\n };\n\n const setError = (errorProps: {\n errors: FileError[];\n file: FilePreview;\n }) => {\n setFiles(prevFiles =>\n prevFiles.map(file =>\n file === errorProps.file\n ? Object.assign(file, {\n errors: errorProps.errors,\n processor: { ...file.processor, status: 'error' },\n })\n : file\n )\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 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\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 const minFileError = minFiles && files.length < minFiles;\n const maxFileError = maxFiles && files.length > maxFiles;\n\n let errorCode: string | null = null;\n\n if (maxFileError) {\n errorCode = 'too-many-files';\n } else if (minFileError) {\n errorCode = 'too-few-files';\n }\n\n setErrorMessage(formatError(errorCode, { minFiles, maxFiles }));\n\n if (sendFiles && files.length > 0 && !maxFileError && !minFileError) {\n setFiles((prevFiles: FilePreview[]) => {\n return prevFiles.map((file: FilePreview) => {\n if (!file.errors && !file.processor && onSendFile) {\n onSendFile({\n file,\n onError: setError,\n onFinish: setFinished,\n onProgress: setProgress,\n });\n }\n\n return file;\n });\n });\n }\n }, [\n sendFiles,\n files.length,\n onSendFile,\n maxFiles,\n minFiles,\n i18n.dropzone.errors,\n i18n.dropzone.files,\n ]);\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={{\n color: isInverse ? theme.colors.neutral0 : theme.colors.brand.navy,\n ...labelStyle,\n }}\n labelText={labelText}\n messageStyle={{ minHeight: 0 }}\n data-testid={testId}\n >\n <HelperMessage\n id={helperMessageId}\n theme={theme}\n isInverse={isInverse}\n >\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={inputRef}\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 data-testid=\"file-input\"\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 ref={browseFileButtonRef}\n aria-describedby={helperMessage ? helperMessageId : undefined}\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 ? theme.colors.neutral0 : theme.colors.neutral700\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 ref={browseFileButtonRef}\n aria-describedby={helperMessage ? helperMessageId : undefined}\n >\n {i18n.dropzone.browseFiles}\n </Button>\n </Flex>\n )}\n </Container>\n </FormFieldContainer>\n <PreviewList>\n {files.map((file: FilePreview) => (\n <PreviewItem key={file.name}>\n <Preview\n accept={accept}\n file={file}\n isInverse={isInverse}\n maxSize={maxSize}\n minSize={minSize}\n onDeleteFile={handleDeleteFile}\n onRemoveFile={handleRemoveFile}\n thumbnails={thumbnails}\n />\n </PreviewItem>\n ))}\n </PreviewList>\n\n <VisuallyHidden>\n <Announce>{announcement}</Announce>\n </VisuallyHidden>\n </InverseContext.Provider>\n );\n }\n);\n","import React, { forwardRef, useContext, useEffect, useState } from 'react';\n\nimport {\n ButtonColor,\n ButtonVariant,\n Card,\n CardBorderRadius,\n CardCornerTreatment,\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 styled,\n} from 'react-magma-dom';\nimport {\n CheckCircleIcon,\n CloseIcon,\n DeleteIcon,\n ErrorIcon,\n} from 'react-magma-icons';\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 PreviewIcon = ({\n file,\n isInverse,\n theme,\n thumbnails,\n}: {\n file: FilePreview;\n isInverse: boolean;\n theme: ThemeInterface;\n thumbnails: boolean;\n}) => {\n if (file.errors) {\n return (\n <ErrorIcon\n color={isInverse ? theme.colors.red500 : theme.colors.danger}\n size={24}\n />\n );\n }\n\n if (\n file.preview &&\n thumbnails &&\n file.type &&\n file.type.startsWith('image')\n ) {\n return <Thumb role=\"img\" file={file} />;\n }\n\n return <FileIcon isInverse={isInverse} file={file} />;\n};\n\nconst IconStyles = {\n marginRight: '12px',\n display: 'flex',\n};\n\nconst Errors = styled.div<{ isInverse: boolean }>`\n border-top: 1px solid\n ${({ theme, isInverse }) =>\n isInverse ? theme.colors.neutral500 : 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.red500\n : theme.colors.danger\n : isInverse\n ? theme.colors.neutral800\n : theme.colors.neutral200};\n border-width: 1px;\n color: ${({ file, theme, isInverse }) =>\n isInverse\n ? theme.colors.neutral0\n : file.errors\n ? theme.colors.neutral700\n : theme.colors.brand.navy};\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\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<\n HTMLDivElement,\n Omit<PreviewProps, 'children'>\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\n setTimeout(() => {\n if (mounted) {\n setDone(true);\n }\n }, 1000);\n\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.subtle}\n aria-label={`${i18n.dropzone.removeFile} ${file.name}`}\n icon={<CloseIcon />}\n />\n </StatusIcons>\n );\n }\n\n if (status === 'pending') {\n return (\n <StatusIcons>\n <Spinner\n color={\n isInverse ? theme.colors.brand.skyBlue : theme.colors.primary\n }\n />\n </StatusIcons>\n );\n }\n\n return (\n <StatusIcons>\n <Transition isOpen={!done} unmountOnExit fade>\n <CheckCircleIcon\n color={isInverse ? theme.colors.green500 : 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.subtle}\n aria-label={`${i18n.dropzone.deleteFile} ${file.name}`}\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 borderRadius={CardBorderRadius.small}\n cornerTreatment={CardCornerTreatment.all}\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 <PreviewIcon\n file={file}\n isInverse={isInverse}\n theme={theme}\n thumbnails={thumbnails}\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} isInverse={isInverse}>\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\n return (\n <React.Fragment key={code}>\n <ErrorHeader\n style={{\n color: isInverse\n ? theme.colors.red500\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"],"names":["icons","default","Icon","InsertDriveFileIcon","style","color","magma","colors","neutral700","inverseStyle","neutral300","word","FileWordIcon","blue500","excel","FileExcelIcon","green500","powerpoint","FilePowerpointIcon","tangerine600","tangerine500","pdf","FilePdfIcon","red600","red500","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","_templateObject","_templateObject2","_templateObject3","_templateObject4","_templateObject5","DragState","formatFileSize","bytes","decimalPoint","bytesLabel","undefined","sizes","i","Math","floor","log","parseFloat","pow","toFixed","Thumb","styled","div","_taggedTemplateLiteralLoose","preview","StatusIcons","PreviewIcon","theme","thumbnails","errors","ErrorIcon","danger","startsWith","role","IconStyles","marginRight","display","Errors","_ref3","neutral500","_ref4","typeScale","size02","fontSize","_ref5","lineHeight","StyledFlex","Flex","_ref6","_ref7","FileName","_ref8","_ref9","StyledCard","Card","_templateObject6","_ref0","neutral800","neutral200","_ref1","neutral0","brand","navy","ErrorHeader","span","_templateObject7","ErrorMessage","_templateObject8","Preview","forwardRef","props","ref","_file$processor2","accept","isInverseProp","maxSize","minSize","onDeleteFile","onRemoveFile","rest","_objectWithoutPropertiesLoose","_excluded","useContext","ThemeContext","i18n","React","I18nContext","useIsInverse","_useState","useState","CloseIcon","actions","setActions","handleRemoveFile","handleDeleteFile","FinishedActions","_ref10","_ref10$status","status","_useState2","done","setDone","useEffect","mounted","setTimeout","children","IconButton","onClick","variant","ButtonVariant","link","ButtonColor","subtle","dropzone","removeFile","name","icon","Spinner","skyBlue","primary","_jsxs","Transition","isOpen","unmountOnExit","fade","CheckCircleIcon","success","marginTop","deleteFile","DeleteIcon","_file$processor","processor","InverseContext","Provider","value","borderRadius","CardBorderRadius","small","cornerTreatment","CardCornerTreatment","all","testId","_extends","behavior","FlexBehavior","container","alignItems","FlexAlignItems","center","item","xs","marginLeft","percent","slice","map","_ref11","code","_formatError","error","constraints","byteLabel","Array","isArray","length","messageSuffix","join","message","formatError","_excluded2","_formatError$header","header","Fragment","Container","noDrag","borderRadiusNone","borderRadiusSmall","_ref$dragState","dragState","dragReject","red400","getErrorBorderColor","dragActive","dragAccept","_ref7$dragState","transparentize","neutral1200","neutral100","HelperMessage","Wrapper","_ref12","spaceScale","spacing01","PreviewList","ul","PreviewItem","li","Dropzone","containerStyle","disabled","_props$dropzoneOption","dropzoneOptions","multiple","helperMessage","defaultId","id","inputSize","isLabelVisuallyHidden","labelStyle","labelText","maxFiles","minFiles","_props$multiple","_props$noDrag","onSendFile","_props$sendFiles","sendFiles","_props$thumbnails","_React$useState","files","setFiles","_React$useState2","errorMessage","setErrorMessage","_React$useState3","announcement","setAnnouncement","useGenerateId","helperMessageId","browseFileButtonRef","useRef","onDrop","useCallback","acceptedFiles","rejectedFiles","newFiles","concat","Object","assign","URL","createObjectURL","_ref13","prevFiles","fileNames","fileAdded","replace","filesAdded","toString","current","focus","_useDropzone","useDropzone","noClick","getInputProps","getRootProps","isDragAccept","isDragActive","isDragReject","open","inputRef","useImperativeHandle","inputProps","removedFile","filter","fileRemoved","fileDeleted","setProgress","progressProps","fileUploading","setFinished","finishedProps","fileUploaded","setError","errorProps","forEach","revokeObjectURL","minFileError","maxFileError","errorCode","onError","onFinish","onProgress","FormFieldContainer","actionable","fieldId","messageStyle","minHeight","tabIndex","autoComplete","onChange","Button","margin","browseFiles","CloudUploadIcon","dragMessage","solid","VisuallyHidden","Announce"],"mappings":"y6BAuBA,IAAMA,EAAQ,CACZC,QAAS,CACPC,KAAMC,EACNC,MAAO,CACLC,MAAOC,EAAMC,OAAOC,YAEtBC,aAAc,CACZJ,MAAOC,EAAMC,OAAOG,aAGxBC,KAAM,CACJT,KAAMU,EACNR,MAAO,CACLC,MAAOC,EAAMC,OAAOM,SAEtBJ,aAAc,CACZJ,MAAOC,EAAMC,OAAOM,UAGxBC,MAAO,CACLZ,KAAMa,EACNX,MAAO,CACLC,MAAOC,EAAMC,OAAOS,UAEtBP,aAAc,CACZJ,MAAOC,EAAMC,OAAOS,WAGxBC,WAAY,CACVf,KAAMgB,EACNd,MAAO,CACLC,MAAOC,EAAMC,OAAOY,cAEtBV,aAAc,CACZJ,MAAOC,EAAMC,OAAOa,eAGxBC,IAAK,CACHnB,KAAMoB,EACNlB,MAAO,CACLC,MAAOC,EAAMC,OAAOgB,QAEtBd,aAAc,CACZJ,MAAOC,EAAMC,OAAOiB,SAGxBC,MAAO,CACLvB,KAAMwB,EACNtB,MAAO,CACLC,MAAOC,EAAMC,OAAOC,YAEtBC,aAAc,CACZJ,MAAOC,EAAMC,OAAOG,aAGxBiB,MAAO,CACLzB,KAAM0B,EACNxB,MAAO,CACLC,MAAOC,EAAMC,OAAOC,YAEtBC,aAAc,CACZJ,MAAOC,EAAMC,OAAOG,aAGxBmB,MAAO,CACL3B,KAAM4B,EACN1B,MAAO,CACLC,MAAOC,EAAMC,OAAOC,YAEtBC,aAAc,CACZJ,MAAOC,EAAMC,OAAOG,aAGxBqB,QAAS,CACP7B,K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,GACTjU,MAAO,CAAEkW,OAAQ,GACjB3N,IAAK6J,GACL,mBAAkB1B,EAAgByB,QAAkBxN,EAAU8F,SAE7DrB,GAAK6B,SAASkL,6BAInB3K,EAACzE,GAAKgG,SAAUC,EAAaK,KAAK5C,uBAChC5G,EAACuS,EAAe,CACd,cAAY,OACZnW,MACEkD,GAAYwC,GAAMxF,OAAOyH,SAAWjC,GAAMxF,OAAOC,WAEnD0D,KAAM,kBAERD,EAAC+L,IAAQzM,UAAWA,GAAWwC,MAAOA,GAAM8E,SACzCrB,GAAK6B,SAASoL,2BAEjBxS,EAACoS,EAAM,CACLhW,MAAO8K,EAAYQ,QACnB+E,SAAUA,EACVnN,UAAWA,GACXwH,QAASsJ,GACTjU,MAAO,CAAEkW,OAAQ,GACjBtL,QAASC,EAAcyL,MACvB/N,IAAK6J,GACL,mBAAkB1B,EAAgByB,QAAkBxN,EAAU8F,SAE7DrB,GAAK6B,SAASkL,qCAMzBtS,EAACmM,IAAWvF,SACTiH,EAAMhE,IAAI,SAACxK,gBAAiB,OAC3BW,EAACqM,GAAWzF,CAAAA,sBACV5G,EAACuE,GAAO,CACNK,OAAQA,EACRvF,KAAMA,EACNC,UAAWA,GACXwF,QAASA,EACTC,QAASA,EACTC,aAAciB,GACdhB,aAAce,GACdjE,WAAYA,KATE1C,EAAKiI,KAWT,kBAIlBtH,EAAC0S,GAAc9L,sBACb5G,EAAC2S,EAAQ/L,CAAAA,SAAEuH,SAInB"}
|
|
1
|
+
{"version":3,"file":"fileuploader.modern.module.js","sources":["../src/components/dropzone/FileIcon.tsx","../src/components/dropzone/utils.ts","../src/components/dropzone/Dropzone.tsx","../src/components/dropzone/Preview.tsx"],"sourcesContent":["import React from 'react';\n\nimport { magma } from 'react-magma-dom';\nimport {\n DraftOutlinedIcon,\n ImageOutlinedIcon,\n MusicNoteOutlinedIcon,\n VideocamOutlinedIcon,\n FileExcelIcon,\n FilePdfIcon,\n FilePowerpointIcon,\n FileWordIcon,\n FileZipIcon,\n IconProps,\n} from 'react-magma-icons';\n\nimport { FilePreview } from './FilePreview';\n\nexport interface FileIconProps extends IconProps {\n file: FilePreview;\n isInverse?: boolean;\n}\n\nconst icons = {\n default: {\n Icon: DraftOutlinedIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n word: {\n Icon: FileWordIcon,\n style: {\n color: magma.colors.blue500,\n },\n inverseStyle: {\n color: magma.colors.blue500,\n },\n },\n excel: {\n Icon: FileExcelIcon,\n style: {\n color: magma.colors.green500,\n },\n inverseStyle: {\n color: magma.colors.green500,\n },\n },\n powerpoint: {\n Icon: FilePowerpointIcon,\n style: {\n color: magma.colors.tangerine600,\n },\n inverseStyle: {\n color: magma.colors.tangerine500,\n },\n },\n pdf: {\n Icon: FilePdfIcon,\n style: {\n color: magma.colors.red600,\n },\n inverseStyle: {\n color: magma.colors.red500,\n },\n },\n image: {\n Icon: ImageOutlinedIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n video: {\n Icon: VideocamOutlinedIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n audio: {\n Icon: MusicNoteOutlinedIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n archive: {\n Icon: FileZipIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n};\n\nconst iconMapping: {\n [key: string]: {\n Icon: any;\n style: React.CSSProperties;\n inverseStyle: React.CSSProperties;\n };\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, inverseStyle } =\n iconMapping[extension] || iconMapping[category] || iconMapping.default;\n\n return (\n <Icon\n size={magma.iconSizes.medium}\n style={isInverse ? inverseStyle : style}\n />\n );\n};\n","export const formatFileSize = (\n bytes: number | undefined,\n decimalPoint = 2,\n bytesLabel = '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","/* 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, { useImperativeHandle } from 'react';\n\nimport { transparentize } from 'polished';\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 styled,\n Announce,\n VisuallyHidden,\n} from 'react-magma-dom';\nimport { CloudUploadOutlinedIcon } from 'react-magma-icons';\n\nimport { FilePreview, FileError } from './FilePreview';\nimport { Preview } from './Preview';\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\nenum DragState {\n error = 'error',\n dragAccept = 'dragAccept',\n dragReject = 'dragReject',\n dragActive = 'dragActive',\n default = 'default',\n}\n\nconst getBrowseButtonText = (\n buttonText: string | null | undefined,\n localizedText: string\n) => buttonText ?? localizedText;\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 * The color of the button used to browse for files.\n * @default ButtonColor.primary\n */\n buttonColor?: ButtonColor;\n /**\n * The text displayed in the button used to browse for files. Defaults to the localized browse files text.\n */\n buttonText?: 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 getErrorBorderColor = (\n dragState: DragState,\n theme: ThemeInterface,\n isInverse?: boolean\n) => {\n if (!isInverse) {\n return theme.colors.danger;\n }\n\n return dragState === DragState.error\n ? theme.colors.red500\n : theme.colors.red400;\n};\n\nconst getContainerBorder = ({\n dragState = DragState.default,\n noDrag,\n theme,\n isInverse,\n}: {\n dragState?: DragState;\n noDrag?: boolean;\n theme: ThemeInterface;\n isInverse?: boolean;\n}) => {\n if (noDrag) {\n return '0px';\n }\n\n if (dragState === DragState.dragReject || dragState === DragState.error) {\n const width = dragState === DragState.error ? '1px' : '2px';\n\n return `${width} dashed ${getErrorBorderColor(dragState, theme, isInverse)}`;\n }\n\n if (dragState === DragState.dragActive) {\n return `2px dashed ${theme.colors.blue500}`;\n }\n\n if (dragState === DragState.dragAccept) {\n return `2px dashed ${theme.colors.green500}`;\n }\n\n return `2px dashed ${\n isInverse ? theme.colors.neutral800 : theme.colors.neutral300\n }`;\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, theme }) =>\n noDrag ? theme.borderRadiusNone : theme.borderRadiusSmall};\n border: ${getContainerBorder};\n\n border-style: ${({ dragState = DragState.default }) =>\n dragState === DragState.error ? 'solid' : 'dashed'};\n background-color: ${({ theme, noDrag, isInverse }) =>\n noDrag\n ? 'transparent'\n : isInverse\n ? transparentize(0.6, theme.colors.neutral1200)\n : theme.colors.neutral100};\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.neutral500 : 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.neutral0 : theme.colors.brand.navy};\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`;\n\nconst PreviewList = styled.ul`\n list-style: none;\n padding: 0;\n`;\n\nconst PreviewItem = styled.li``;\n\nexport const Dropzone = React.forwardRef<HTMLInputElement, DropzoneProps>(\n (props, ref) => {\n const {\n accept,\n buttonColor = ButtonColor.primary,\n buttonText,\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 const [announcement, setAnnouncement] = React.useState<string>('');\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 const helperMessageId = useGenerateId(`${id}-helper`);\n\n const browseFileButtonRef = React.useRef<HTMLButtonElement>(null);\n\n const onDrop = React.useCallback(\n (acceptedFiles: FilePreview[], rejectedFiles: FileRejection[]) => {\n const newFiles = [\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 setFiles((prevFiles: FilePreview[]) => [...prevFiles, ...newFiles]);\n\n if (acceptedFiles.length > 0) {\n const fileNames = acceptedFiles.map(file => file.name).join(', ');\n const message =\n acceptedFiles.length === 1\n ? i18n.dropzone.fileAdded.replace(/\\{fileName\\}/g, fileNames)\n : i18n.dropzone.filesAdded\n .replace(/\\{count\\}/g, acceptedFiles.length.toString())\n .replace(/\\{fileNames\\}/g, fileNames);\n\n setAnnouncement(message);\n }\n\n browseFileButtonRef.current && browseFileButtonRef.current.focus();\n },\n [i18n]\n );\n\n const {\n getInputProps,\n getRootProps,\n isDragAccept,\n isDragActive,\n isDragReject,\n open,\n inputRef,\n } = useDropzone({\n noClick: true,\n disabled,\n multiple,\n maxSize,\n minSize,\n accept,\n onDrop,\n noDrag,\n ...dropzoneOptions,\n });\n\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(\n ref,\n () => inputRef.current\n );\n\n const inputProps = getInputProps({ id });\n\n let dragState = DragState.default;\n\n if (errorMessage) {\n dragState = DragState.error;\n } else if (isDragAccept) {\n dragState = DragState.dragAccept;\n } else if (isDragReject) {\n dragState = DragState.dragReject;\n } else if (isDragActive) {\n dragState = DragState.dragActive;\n }\n\n const handleRemoveFile = (removedFile: FilePreview) => {\n setFiles(prevFiles => prevFiles.filter(file => file !== removedFile));\n\n if (onRemoveFile && typeof onRemoveFile === 'function') {\n onRemoveFile(removedFile);\n }\n\n const message = i18n.dropzone.fileRemoved.replace(\n /\\{fileName\\}/g,\n removedFile.name\n );\n\n setAnnouncement(message);\n\n browseFileButtonRef.current && browseFileButtonRef.current.focus();\n };\n\n const handleDeleteFile = (removedFile: FilePreview) => {\n setFiles(prevFiles => prevFiles.filter(file => file !== removedFile));\n\n if (onDeleteFile && typeof onDeleteFile === 'function') {\n onDeleteFile(removedFile);\n }\n\n const message = i18n.dropzone.fileDeleted.replace(\n /\\{fileName\\}/g,\n removedFile.name\n );\n\n setAnnouncement(message);\n\n browseFileButtonRef.current && browseFileButtonRef.current.focus();\n };\n\n const setProgress = (progressProps: {\n percent: number;\n file: FilePreview;\n }) => {\n setFiles(prevFiles =>\n prevFiles.map(file =>\n file === progressProps.file\n ? Object.assign(file, {\n processor: {\n ...file.processor,\n percent: `${progressProps.percent}%`,\n status: 'pending',\n },\n })\n : file\n )\n );\n\n // Announce progress every 25% to avoid too many announcements\n if (progressProps.percent > 0 && progressProps.percent % 25 === 0) {\n const message = i18n.dropzone.fileUploading\n .replace(/\\{fileName\\}/g, progressProps.file.name)\n .replace(/\\{percent\\}/g, progressProps.percent.toString());\n\n setAnnouncement(message);\n }\n };\n\n const setFinished = (finishedProps: { file: FilePreview }) => {\n setFiles(prevFiles =>\n prevFiles.map(file =>\n file === finishedProps.file\n ? Object.assign(file, {\n processor: {\n ...file.processor,\n percent: '',\n status: 'finished',\n },\n })\n : file\n )\n );\n\n // Announce successful upload\n const message = i18n.dropzone.fileUploaded.replace(\n /\\{fileName\\}/g,\n finishedProps.file.name\n );\n\n setAnnouncement(message);\n };\n\n const setError = (errorProps: {\n errors: FileError[];\n file: FilePreview;\n }) => {\n setFiles(prevFiles =>\n prevFiles.map(file =>\n file === errorProps.file\n ? Object.assign(file, {\n errors: errorProps.errors,\n processor: { ...file.processor, status: 'error' },\n })\n : file\n )\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 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\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 const minFileError = minFiles && files.length < minFiles;\n const maxFileError = maxFiles && files.length > maxFiles;\n\n let errorCode: string | null = null;\n\n if (maxFileError) {\n errorCode = 'too-many-files';\n } else if (minFileError) {\n errorCode = 'too-few-files';\n }\n\n setErrorMessage(formatError(errorCode, { minFiles, maxFiles }));\n\n if (sendFiles && files.length > 0 && !maxFileError && !minFileError) {\n setFiles((prevFiles: FilePreview[]) => {\n return prevFiles.map((file: FilePreview) => {\n if (!file.errors && !file.processor && onSendFile) {\n onSendFile({\n file,\n onError: setError,\n onFinish: setFinished,\n onProgress: setProgress,\n });\n }\n\n return file;\n });\n });\n }\n }, [\n sendFiles,\n files.length,\n onSendFile,\n maxFiles,\n minFiles,\n i18n.dropzone.errors,\n i18n.dropzone.files,\n ]);\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={{\n color: isInverse ? theme.colors.neutral0 : theme.colors.brand.navy,\n ...labelStyle,\n }}\n labelText={labelText}\n messageStyle={{ minHeight: 0 }}\n data-testid={testId}\n >\n <HelperMessage\n id={helperMessageId}\n theme={theme}\n isInverse={isInverse}\n >\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={inputRef}\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 data-testid=\"file-input\"\n />\n {noDrag ? (\n <Flex xs behavior={FlexBehavior.item}>\n <Button\n color={buttonColor}\n disabled={disabled}\n isInverse={isInverse}\n onClick={open}\n style={{ margin: 0 }}\n ref={browseFileButtonRef}\n aria-describedby={helperMessage ? helperMessageId : undefined}\n >\n {getBrowseButtonText(buttonText, i18n.dropzone.browseFiles)}\n </Button>\n </Flex>\n ) : (\n <Flex behavior={FlexBehavior.item}>\n <CloudUploadOutlinedIcon\n aria-hidden=\"true\"\n color={\n isInverse ? theme.colors.neutral0 : theme.colors.neutral700\n }\n size={48}\n />\n <Wrapper isInverse={isInverse} theme={theme}>\n {i18n.dropzone.dragMessage}\n </Wrapper>\n <Button\n color={buttonColor}\n disabled={disabled}\n isInverse={isInverse}\n onClick={open}\n style={{ margin: 0 }}\n variant={ButtonVariant.solid}\n ref={browseFileButtonRef}\n aria-describedby={helperMessage ? helperMessageId : undefined}\n >\n {getBrowseButtonText(buttonText, i18n.dropzone.browseFiles)}\n </Button>\n </Flex>\n )}\n </Container>\n </FormFieldContainer>\n <PreviewList>\n {files.map((file: FilePreview) => (\n <PreviewItem key={file.name}>\n <Preview\n accept={accept}\n file={file}\n isInverse={isInverse}\n maxSize={maxSize}\n minSize={minSize}\n onDeleteFile={handleDeleteFile}\n onRemoveFile={handleRemoveFile}\n thumbnails={thumbnails}\n />\n </PreviewItem>\n ))}\n </PreviewList>\n\n <VisuallyHidden>\n <Announce>{announcement}</Announce>\n </VisuallyHidden>\n </InverseContext.Provider>\n );\n }\n);\n","import React, { forwardRef, useContext, useEffect, useState } from 'react';\n\nimport {\n ButtonColor,\n ButtonVariant,\n Card,\n CardBorderRadius,\n CardCornerTreatment,\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 styled,\n} from 'react-magma-dom';\nimport {\n CheckCircleOutlinedIcon,\n CloseOutlinedIcon,\n DeleteOutlinedIcon,\n ErrorOutlinedIcon,\n} from 'react-magma-icons';\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 PreviewIcon = ({\n file,\n isInverse,\n theme,\n thumbnails,\n}: {\n file: FilePreview;\n isInverse: boolean;\n theme: ThemeInterface;\n thumbnails: boolean;\n}) => {\n if (file.errors) {\n return (\n <ErrorOutlinedIcon\n color={isInverse ? theme.colors.red500 : theme.colors.danger}\n size={24}\n />\n );\n }\n\n if (\n file.preview &&\n thumbnails &&\n file.type &&\n file.type.startsWith('image')\n ) {\n return <Thumb role=\"img\" file={file} />;\n }\n\n return <FileIcon isInverse={isInverse} file={file} />;\n};\n\nconst IconStyles = {\n marginRight: '12px',\n display: 'flex',\n};\n\nconst Errors = styled.div<{ isInverse: boolean }>`\n border-top: 1px solid\n ${({ theme, isInverse }) =>\n isInverse ? theme.colors.neutral500 : 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.red500\n : theme.colors.danger\n : isInverse\n ? theme.colors.neutral800\n : theme.colors.neutral200};\n border-width: 1px;\n color: ${({ file, theme, isInverse }) =>\n isInverse\n ? theme.colors.neutral0\n : file.errors\n ? theme.colors.neutral700\n : theme.colors.brand.navy};\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\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<\n HTMLDivElement,\n Omit<PreviewProps, 'children'>\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(<CloseOutlinedIcon />);\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\n setTimeout(() => {\n if (mounted) {\n setDone(true);\n }\n }, 1000);\n\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.subtle}\n aria-label={`${i18n.dropzone.removeFile} ${file.name}`}\n icon={<CloseOutlinedIcon />}\n />\n </StatusIcons>\n );\n }\n\n if (status === 'pending') {\n return (\n <StatusIcons>\n <Spinner\n color={\n isInverse ? theme.colors.brand.skyBlue : theme.colors.primary\n }\n />\n </StatusIcons>\n );\n }\n\n return (\n <StatusIcons>\n <Transition isOpen={!done} unmountOnExit fade>\n <CheckCircleOutlinedIcon\n color={isInverse ? theme.colors.green500 : 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.subtle}\n aria-label={`${i18n.dropzone.deleteFile} ${file.name}`}\n icon={<DeleteOutlinedIcon />}\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 borderRadius={CardBorderRadius.small}\n cornerTreatment={CardCornerTreatment.all}\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 <PreviewIcon\n file={file}\n isInverse={isInverse}\n theme={theme}\n thumbnails={thumbnails}\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} isInverse={isInverse}>\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\n return (\n <React.Fragment key={code}>\n <ErrorHeader\n style={{\n color: isInverse\n ? theme.colors.red500\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"],"names":["icons","default","Icon","DraftOutlinedIcon","style","color","magma","colors","neutral700","inverseStyle","neutral300","word","FileWordIcon","blue500","excel","FileExcelIcon","green500","powerpoint","FilePowerpointIcon","tangerine600","tangerine500","pdf","FilePdfIcon","red600","red500","image","ImageOutlinedIcon","video","VideocamOutlinedIcon","audio","MusicNoteOutlinedIcon","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","_templateObject","_templateObject2","_templateObject3","_templateObject4","_templateObject5","DragState","formatFileSize","bytes","decimalPoint","bytesLabel","undefined","sizes","i","Math","floor","log","parseFloat","pow","toFixed","Thumb","styled","div","_taggedTemplateLiteralLoose","preview","StatusIcons","PreviewIcon","theme","thumbnails","errors","ErrorOutlinedIcon","danger","startsWith","role","IconStyles","marginRight","display","Errors","_ref3","neutral500","_ref4","typeScale","size02","fontSize","_ref5","lineHeight","StyledFlex","Flex","_ref6","_ref7","FileName","_ref8","_ref9","StyledCard","Card","_templateObject6","_ref0","neutral800","neutral200","_ref1","neutral0","brand","navy","ErrorHeader","span","_templateObject7","ErrorMessage","_templateObject8","Preview","forwardRef","props","ref","_file$processor2","accept","isInverseProp","maxSize","minSize","onDeleteFile","onRemoveFile","rest","_objectWithoutPropertiesLoose","_excluded","useContext","ThemeContext","i18n","React","I18nContext","useIsInverse","_useState","useState","CloseOutlinedIcon","actions","setActions","handleRemoveFile","handleDeleteFile","FinishedActions","_ref10","_ref10$status","status","_useState2","done","setDone","useEffect","mounted","setTimeout","children","IconButton","onClick","variant","ButtonVariant","link","ButtonColor","subtle","dropzone","removeFile","name","icon","Spinner","skyBlue","primary","_jsxs","Transition","isOpen","unmountOnExit","fade","CheckCircleOutlinedIcon","success","marginTop","deleteFile","DeleteOutlinedIcon","_file$processor","processor","InverseContext","Provider","value","borderRadius","CardBorderRadius","small","cornerTreatment","CardCornerTreatment","all","testId","_extends","behavior","FlexBehavior","container","alignItems","FlexAlignItems","center","item","xs","marginLeft","percent","slice","map","_ref11","code","_formatError","error","constraints","byteLabel","Array","isArray","length","messageSuffix","join","message","formatError","_excluded2","_formatError$header","header","Fragment","getBrowseButtonText","buttonText","localizedText","Container","noDrag","borderRadiusNone","borderRadiusSmall","_ref$dragState","dragState","dragReject","getErrorBorderColor","red400","dragActive","dragAccept","_ref7$dragState","transparentize","neutral1200","neutral100","HelperMessage","Wrapper","_ref12","spaceScale","spacing01","PreviewList","ul","PreviewItem","li","Dropzone","_props$buttonColor","buttonColor","containerStyle","disabled","_props$dropzoneOption","dropzoneOptions","multiple","helperMessage","defaultId","id","inputSize","isLabelVisuallyHidden","labelStyle","labelText","maxFiles","minFiles","_props$multiple","_props$noDrag","onSendFile","_props$sendFiles","sendFiles","_props$thumbnails","_React$useState","files","setFiles","_React$useState2","errorMessage","setErrorMessage","_React$useState3","announcement","setAnnouncement","useGenerateId","helperMessageId","browseFileButtonRef","useRef","onDrop","useCallback","acceptedFiles","rejectedFiles","newFiles","concat","Object","assign","URL","createObjectURL","_ref13","prevFiles","fileNames","fileAdded","replace","filesAdded","toString","current","focus","_useDropzone","useDropzone","noClick","getInputProps","getRootProps","isDragAccept","isDragActive","isDragReject","open","inputRef","useImperativeHandle","inputProps","removedFile","filter","fileRemoved","fileDeleted","setProgress","progressProps","fileUploading","setFinished","finishedProps","fileUploaded","setError","errorProps","forEach","revokeObjectURL","minFileError","maxFileError","errorCode","onError","onFinish","onProgress","FormFieldContainer","actionable","fieldId","messageStyle","minHeight","tabIndex","autoComplete","onChange","Button","margin","browseFiles","CloudUploadOutlinedIcon","dragMessage","solid","VisuallyHidden","Announce"],"mappings":"s+BAuBA,IAAMA,EAAQ,CACZC,QAAS,CACPC,KAAMC,EACNC,MAAO,CACLC,MAAOC,EAAMC,OAAOC,YAEtBC,aAAc,CACZJ,MAAOC,EAAMC,OAAOG,aAGxBC,KAAM,CACJT,KAAMU,EACNR,MAAO,CACLC,MAAOC,EAAMC,OAAOM,SAEtBJ,aAAc,CACZJ,MAAOC,EAAM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D0D,KAAM,kBAERD,EAACkM,IAAQ5M,UAAWA,GAAWwC,MAAOA,GAAM8E,SACzCrB,GAAK6B,SAASyL,2BAEjB7S,EAACyS,EAAM,CACLrW,MAAOwQ,EACPE,SAAUA,EACVxN,UAAWA,GACXwH,QAAS2J,GACTtU,MAAO,CAAEuW,OAAQ,GACjB3L,QAASC,EAAc8L,MACvBpO,IAAKkK,GACL,mBAAkB1B,EAAgByB,QAAkB7N,EAAU8F,SAE7DmE,GAAoBC,EAAYzF,GAAK6B,SAASuL,sCAMzD3S,EAACsM,GAAW,CAAA1F,SACTsH,GAAMrE,IAAI,SAACxK,gBACVW,OAAAA,EAACwM,IAAW5F,sBACV5G,EAACuE,IACCK,OAAQA,EACRvF,KAAMA,EACNC,UAAWA,GACXwF,QAASA,EACTC,QAASA,EACTC,aAAciB,GACdhB,aAAce,GACdjE,WAAYA,KATE1C,EAAKiI,KAWT,kBAIlBtH,EAAC+S,GAAcnM,sBACb5G,EAACgT,EAAQpM,CAAAA,SAAE4H,SAInB"}
|
package/dist/fileuploader.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react-magma-dom"),require("react-magma-icons"),require("react/jsx-runtime"),require("react"),require("polished"),require("react-dropzone")):"function"==typeof define&&define.amd?define(["exports","react-magma-dom","react-magma-icons","react/jsx-runtime","react","polished","react-dropzone"],n):n((e||self).dropzone={},e.reactMagmaDom,e.reactMagmaIcons,e.jsx,e.react,e.polished,e.reactDropzone)}(this,function(e,n,r,o,t,i,l){function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=/*#__PURE__*/a(t),c={default:{Icon:r.InsertDriveFileIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}},word:{Icon:r.FileWordIcon,style:{color:n.magma.colors.blue500},inverseStyle:{color:n.magma.colors.blue500}},excel:{Icon:r.FileExcelIcon,style:{color:n.magma.colors.green500},inverseStyle:{color:n.magma.colors.green500}},powerpoint:{Icon:r.FilePowerpointIcon,style:{color:n.magma.colors.tangerine600},inverseStyle:{color:n.magma.colors.tangerine500}},pdf:{Icon:r.FilePdfIcon,style:{color:n.magma.colors.red600},inverseStyle:{color:n.magma.colors.red500}},image:{Icon:r.ImageIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}},video:{Icon:r.VideocamIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}},audio:{Icon:r.AudiotrackIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}},archive:{Icon:r.FileZipIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}}},d={default:c.default,xlsx:c.excel,xlsm:c.excel,xlsb:c.excel,xltx:c.excel,xls:c.excel,xlt:c.excel,doc:c.word,docx:c.word,docm:c.word,dotx:c.word,dotm:c.word,docb:c.word,pptx:c.powerpoint,pptm:c.powerpoint,ppt:c.powerpoint,pdf:c.pdf,png:c.image,svg:c.image,image:c.image,audio:c.audio,video:c.video,zip:c.archive},u=function(e){var r=e.file,t=e.isInverse,i=r.path,l=void 0===i?"":i,a=r.type,s=(void 0===a?"":a).split("/")[0],c=l.split(".").pop()||"default",u=d[c]||d[s]||d.default;/*#__PURE__*/return o.jsx(u.Icon,{size:n.magma.iconSizes.medium,style:t?u.inverseStyle:u.style})};function p(){return p=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var o in r)({}).hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},p.apply(null,arguments)}function f(e,n){if(null==e)return{};var r={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(-1!==n.indexOf(o))continue;r[o]=e[o]}return r}function m(e,n){return n||(n=e.slice(0)),e.raw=n,e}var g,v,x,h,y,b,I,z,j,S,F,w,C,B,D=function(e,n,r){if(void 0===n&&(n=2),void 0===r&&(r="Bytes"),void 0!==e){if(0==e)return"0 "+r;var o=[r,"KB","MB","GB","TB","PB","EB","ZB","YB"],t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(n))+" "+o[t]}},k=["accept","file","isInverse","maxSize","minSize","onDeleteFile","onRemoveFile","testId","thumbnails"],R=["code"],A=n.styled.div(g||(g=m(["\n background-image: ",";\n background-repeat: no-repeat;\n background-size: cover;\n display: inline-block;\n vertical-align: middle;\n height: 40px;\n width: 40px;\n"])),function(e){var n=e.file;return"url('"+("preview"in n&&n.preview)+"')"}),O=n.styled.div(v||(v=m(["\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"]))),T=function(e){var n=e.file,t=e.isInverse,i=e.theme,l=e.thumbnails;return n.errors?/*#__PURE__*/o.jsx(r.ErrorIcon,{color:t?i.colors.red500:i.colors.danger,size:24}):n.preview&&l&&n.type&&n.type.startsWith("image")?/*#__PURE__*/o.jsx(A,{role:"img",file:n}):/*#__PURE__*/o.jsx(u,{isInverse:t,file:n})},E={marginRight:"12px",display:"flex"},M=n.styled.div(x||(x=m(["\n border-top: 1px solid\n ",";\n padding: 16px;\n font-size: ",";\n line-height: ",";\n"])),function(e){var n=e.theme;return e.isInverse?n.colors.neutral500:n.colors.neutral300},function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight}),H=n.styled(n.Flex)(h||(h=m(["\n height: 56px;\n padding: 0 8px 0 16px;\n font-size: ",";\n line-height: ",";\n"])),function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight}),P=n.styled(n.Flex)(y||(y=m(["\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: ",";\n line-height: ",";\n"])),function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight}),L=n.styled(n.Card)(b||(b=m(["\n background-color: none;\n border-color: ",";\n border-width: 1px;\n color: ",";\n margin: 10px 0;\n"])),function(e){var n=e.theme,r=e.isInverse;return e.file.errors?r?n.colors.red500:n.colors.danger:r?n.colors.neutral800:n.colors.neutral200},function(e){var n=e.theme;return e.isInverse?n.colors.neutral0:e.file.errors?n.colors.neutral700:n.colors.brand.navy}),V=n.styled.span(I||(I=m(["\n display: block;\n\n > div {\n display: flex;\n align-self: center;\n margin-right: 12px;\n }\n"]))),N=n.styled.span(z||(z=m(["\n display: block;\n"]))),U=/*#__PURE__*/t.forwardRef(function(e,i){var l,a=e.accept,c=e.file,d=e.isInverse,u=e.maxSize,m=e.minSize,g=e.onDeleteFile,v=e.onRemoveFile,x=e.thumbnails,h=f(e,k),y=t.useContext(n.ThemeContext),b=s.default.useContext(n.I18nContext),I=n.useIsInverse(d),z=t.useState(/*#__PURE__*/o.jsx(r.CloseIcon,{})),j=z[0],S=z[1],F=function(){v&&"function"==typeof v&&v(c)},w=function(){g&&"function"==typeof g&&g(c)},C=function(e){var i=e.status,l=void 0===i?"ready":i,a=t.useState(!1),s=a[0],d=a[1];return t.useEffect(function(){var e=!0;return setTimeout(function(){e&&d(!0)},1e3),function(){e=!1}},[l]),"error"===l||"ready"===l?/*#__PURE__*/o.jsx(O,{children:/*#__PURE__*/o.jsx(n.IconButton,{onClick:F,variant:n.ButtonVariant.link,color:n.ButtonColor.subtle,"aria-label":b.dropzone.removeFile+" "+c.name,icon:/*#__PURE__*/o.jsx(r.CloseIcon,{})})}):"pending"===l?/*#__PURE__*/o.jsx(O,{children:/*#__PURE__*/o.jsx(n.Spinner,{color:I?y.colors.brand.skyBlue:y.colors.primary})}):/*#__PURE__*/o.jsxs(O,{children:[/*#__PURE__*/o.jsx(n.Transition,{isOpen:!s,unmountOnExit:!0,fade:!0,children:/*#__PURE__*/o.jsx(r.CheckCircleIcon,{color:I?y.colors.green500:y.colors.success,style:{marginTop:"4px"}})}),/*#__PURE__*/o.jsx(n.Transition,{isOpen:s,unmountOnExit:!0,fade:!0,children:/*#__PURE__*/o.jsx(n.IconButton,{onClick:w,variant:n.ButtonVariant.link,color:n.ButtonColor.subtle,"aria-label":b.dropzone.deleteFile+" "+c.name,icon:/*#__PURE__*/o.jsx(r.DeleteIcon,{})})})]})};return t.useEffect(function(){var e;S(/*#__PURE__*/o.jsx(C,{status:null==c||null==(e=c.processor)?void 0:e.status}))},[null==c||null==(l=c.processor)?void 0:l.status]),/*#__PURE__*/o.jsx(n.InverseContext.Provider,{value:{isInverse:I},children:/*#__PURE__*/o.jsxs(L,{borderRadius:n.CardBorderRadius.small,cornerTreatment:n.CardCornerTreatment.all,isInverse:I,theme:y,file:c,"data-testid":e.testId,ref:i,role:c.errors?"alert":"",children:[/*#__PURE__*/o.jsxs(H,p({theme:y,behavior:n.FlexBehavior.container,alignItems:n.FlexAlignItems.center},h,{children:[/*#__PURE__*/o.jsx(n.Flex,{behavior:n.FlexBehavior.item,alignItems:n.FlexAlignItems.center,style:E,children:/*#__PURE__*/o.jsx(T,{file:c,isInverse:I,theme:y,thumbnails:x})}),/*#__PURE__*/o.jsx(P,{xs:!0,behavior:n.FlexBehavior.item,theme:y,children:c.name}),c.processor&&"pending"===c.processor.status&&/*#__PURE__*/o.jsx(n.Flex,{role:"progressbar",style:{marginLeft:"auto"},behavior:n.FlexBehavior.item,children:c.processor.percent}),/*#__PURE__*/o.jsx(n.Flex,{behavior:n.FlexBehavior.item,children:j})]})),c.errors&&/*#__PURE__*/o.jsx(M,{theme:y,isInverse:I,children:c.errors.slice(0,1).map(function(e){var n=e.code,r=function(e,n,r){var o=Array.isArray(n.accept)&&1===n.accept.length?n.accept[0]:n.accept,t=Array.isArray(o)?"one of "+o.join(", "):o;switch(e.code){case"file-too-large":return p({},e,{message:e.message+" "+D(n.maxSize,2,r)+"."});case"file-too-small":return p({},e,{message:e.message+" "+D(n.minSize,2,r)+"."});case"file-invalid-type":return p({},e,{message:e.message+": "+t});default:return e}}(p({code:n},f(e,R),b.dropzone.errors[n]),{accept:a,minSize:m,maxSize:u},b.dropzone.bytes),t=r.header,i=r.message;/*#__PURE__*/return o.jsxs(s.default.Fragment,{children:[/*#__PURE__*/o.jsx(V,{style:{color:I?y.colors.red500:y.colors.danger},children:void 0===t?"":t}),/*#__PURE__*/o.jsx(N,{children:i})]},n)})})]})})}),q=["accept","containerStyle","disabled","dropzoneOptions","helperMessage","id","inputSize","isInverse","isLabelVisuallyHidden","labelStyle","labelText","maxFiles","minFiles","maxSize","minSize","multiple","noDrag","onSendFile","onDeleteFile","onRemoveFile","sendFiles","testId","thumbnails"];!function(e){e.error="error",e.dragAccept="dragAccept",e.dragReject="dragReject",e.dragActive="dragActive",e.default="default"}(B||(B={}));var G=n.styled(n.Flex)(j||(j=m(["\n flex-direction: column;\n align-items: ",";\n justify-content: ",";\n text-align: ",";\n padding: ",";\n border-radius: ",";\n border: ",";\n\n border-style: ",";\n background-color: ",";\n outline: none;\n transition: ",";\n"])),function(e){return e.noDrag?"left":"center"},function(e){return e.noDrag?"left":"center"},function(e){return e.noDrag?"left":"center"},function(e){return e.noDrag?"0px":"24px"},function(e){var n=e.theme;return e.noDrag?n.borderRadiusNone:n.borderRadiusSmall},function(e){var n=e.dragState,r=void 0===n?B.default:n,o=e.theme,t=e.isInverse;return e.noDrag?"0px":r===B.dragReject||r===B.error?(r===B.error?"1px":"2px")+" dashed "+function(e,n,r){return r?e===B.error?n.colors.red500:n.colors.red400:n.colors.danger}(r,o,t):r===B.dragActive?"2px dashed "+o.colors.blue500:r===B.dragAccept?"2px dashed "+o.colors.green500:"2px dashed "+(t?o.colors.neutral800:o.colors.neutral300)},function(e){var n=e.dragState;return(void 0===n?B.default:n)===B.error?"solid":"dashed"},function(e){var n=e.theme;return e.noDrag?"transparent":e.isInverse?i.transparentize(.6,n.colors.neutral1200):n.colors.neutral100},function(e){return"border "+(e.noDrag?0:".24s")+" ease-in-out"}),W=n.styled.span(S||(S=m(["\n color: ",";\n display: block;\n font-size: 14px;\n margin: -8px 0 16px 0;\n"])),function(e){var n=e.theme;return e.isInverse?n.colors.neutral500:n.colors.neutral700}),Z=n.styled.div(F||(F=m(["\n color: ",";\n margin: 0 0 24px 0;\n font-size: ",";\n line-height: ",";\n font-weight: 500;\n padding: ",";\n"])),function(e){var n=e.theme;return e.isInverse?n.colors.neutral0:n.colors.brand.navy},function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight},function(e){return e.theme.spaceScale.spacing01}),K=n.styled.ul(w||(w=m(["\n list-style: none;\n padding: 0;\n"]))),Y=n.styled.li(C||(C=m([""])));e.Dropzone=/*#__PURE__*/s.default.forwardRef(function(e,i){var a=e.accept,c=e.containerStyle,d=e.disabled,u=e.dropzoneOptions,m=void 0===u?{multiple:!0}:u,g=e.helperMessage,v=e.id,x=e.inputSize,h=e.isInverse,y=e.isLabelVisuallyHidden,b=e.labelStyle,I=e.labelText,z=e.maxFiles,j=e.minFiles,S=e.maxSize,F=e.minSize,w=e.multiple,C=void 0===w||w,D=e.noDrag,k=void 0!==D&&D,R=e.onSendFile,A=e.onDeleteFile,O=e.onRemoveFile,T=e.sendFiles,E=void 0!==T&&T,M=e.testId,H=e.thumbnails,P=void 0===H||H,L=f(e,q),V=s.default.useState([]),N=V[0],J=V[1],Q=s.default.useState(null),X=Q[0],$=Q[1],_=s.default.useState(""),ee=_[0],ne=_[1],re=n.useIsInverse(h),oe=s.default.useContext(n.ThemeContext),te=s.default.useContext(n.I18nContext),ie=n.useGenerateId(v),le=n.useGenerateId(ie+"-helper"),ae=s.default.useRef(null),se=s.default.useCallback(function(e,n){var r=[].concat(e.map(function(e){return Object.assign(e,{preview:URL.createObjectURL(e)})}),n.map(function(e){return Object.assign(e.file,{errors:e.errors})}));if(J(function(e){return[].concat(e,r)}),e.length>0){var o=e.map(function(e){return e.name}).join(", "),t=1===e.length?te.dropzone.fileAdded.replace(/\{fileName\}/g,o):te.dropzone.filesAdded.replace(/\{count\}/g,e.length.toString()).replace(/\{fileNames\}/g,o);ne(t)}ae.current&&ae.current.focus()},[te]),ce=l.useDropzone(p({noClick:!0,disabled:d,multiple:C,maxSize:S,minSize:F,accept:a,onDrop:se,noDrag:k},m)),de=ce.getInputProps,ue=ce.getRootProps,pe=ce.isDragAccept,fe=ce.isDragActive,me=ce.isDragReject,ge=ce.open,ve=ce.inputRef;t.useImperativeHandle(i,function(){return ve.current});var xe=de({id:ie}),he=B.default;X?he=B.error:pe?he=B.dragAccept:me?he=B.dragReject:fe&&(he=B.dragActive);var ye=function(e){J(function(n){return n.filter(function(n){return n!==e})}),O&&"function"==typeof O&&O(e);var n=te.dropzone.fileRemoved.replace(/\{fileName\}/g,e.name);ne(n),ae.current&&ae.current.focus()},be=function(e){J(function(n){return n.filter(function(n){return n!==e})}),A&&"function"==typeof A&&A(e);var n=te.dropzone.fileDeleted.replace(/\{fileName\}/g,e.name);ne(n),ae.current&&ae.current.focus()},Ie=function(e){if(J(function(n){return n.map(function(n){return n===e.file?Object.assign(n,{processor:p({},n.processor,{percent:e.percent+"%",status:"pending"})}):n})}),e.percent>0&&e.percent%25==0){var n=te.dropzone.fileUploading.replace(/\{fileName\}/g,e.file.name).replace(/\{percent\}/g,e.percent.toString());ne(n)}},ze=function(e){J(function(n){return n.map(function(n){return n===e.file?Object.assign(n,{processor:p({},n.processor,{percent:"",status:"finished"})}):n})});var n=te.dropzone.fileUploaded.replace(/\{fileName\}/g,e.file.name);ne(n)},je=function(e){J(function(n){return n.map(function(n){return n===e.file?Object.assign(n,{errors:e.errors,processor:p({},n.processor,{status:"error"})}):n})})};return s.default.useEffect(function(){return function(){N.forEach(function(e){return e.preview&&URL.revokeObjectURL(e.preview)})}},[N]),s.default.useEffect(function(){var e=j&&N.length<j,n=z&&N.length>z,r=null;n?r="too-many-files":e&&(r="too-few-files"),$(function(e,n){if(null===e)return null;var r=te.dropzone.errors[e];switch(e){case"too-many-files":return r.message+" "+n.maxFiles+" "+te.dropzone.files+".";case"too-few-files":return r.message+" "+n.minFiles+" "+te.dropzone.files+".";default:return r.message}}(r,{minFiles:j,maxFiles:z})),E&&N.length>0&&!n&&!e&&J(function(e){return e.map(function(e){return e.errors||e.processor||!R||R({file:e,onError:je,onFinish:ze,onProgress:Ie}),e})})},[E,N.length,R,z,j,te.dropzone.errors,te.dropzone.files]),/*#__PURE__*/o.jsxs(n.InverseContext.Provider,{value:{isInverse:re},children:[/*#__PURE__*/o.jsxs(n.FormFieldContainer,{actionable:!1,containerStyle:c,errorMessage:X,fieldId:ie,inputSize:x,isInverse:re,isLabelVisuallyHidden:y,labelStyle:p({color:re?oe.colors.neutral0:oe.colors.brand.navy},b),labelText:I,messageStyle:{minHeight:0},"data-testid":M,children:[/*#__PURE__*/o.jsx(W,{id:le,theme:oe,isInverse:re,children:g}),/*#__PURE__*/o.jsxs(G,p({behavior:n.FlexBehavior.container,dragState:he,isInverse:re,noDrag:k,theme:oe},ue(),L,{testId:M,tabIndex:-1,children:[/*#__PURE__*/o.jsx("input",{ref:ve,type:xe.type,accept:xe.accept,autoComplete:xe.autoComplete,id:xe.id,multiple:xe.multiple,onChange:xe.onChange,onClick:xe.onClick,style:xe.style,tabIndex:xe.tabIndex,"data-testid":"file-input"}),k?/*#__PURE__*/o.jsx(n.Flex,{xs:!0,behavior:n.FlexBehavior.item,children:/*#__PURE__*/o.jsx(n.Button,{color:n.ButtonColor.primary,disabled:d,isInverse:re,onClick:ge,style:{margin:0},ref:ae,"aria-describedby":g?le:void 0,children:te.dropzone.browseFiles})}):/*#__PURE__*/o.jsxs(n.Flex,{behavior:n.FlexBehavior.item,children:[/*#__PURE__*/o.jsx(r.CloudUploadIcon,{"aria-hidden":"true",color:re?oe.colors.neutral0:oe.colors.neutral700,size:48}),/*#__PURE__*/o.jsx(Z,{isInverse:re,theme:oe,children:te.dropzone.dragMessage}),/*#__PURE__*/o.jsx(n.Button,{color:n.ButtonColor.primary,disabled:d,isInverse:re,onClick:ge,style:{margin:0},variant:n.ButtonVariant.solid,ref:ae,"aria-describedby":g?le:void 0,children:te.dropzone.browseFiles})]})]}))]}),/*#__PURE__*/o.jsx(K,{children:N.map(function(e){/*#__PURE__*/return o.jsx(Y,{children:/*#__PURE__*/o.jsx(U,{accept:a,file:e,isInverse:re,maxSize:S,minSize:F,onDeleteFile:be,onRemoveFile:ye,thumbnails:P})},e.name)})}),/*#__PURE__*/o.jsx(n.VisuallyHidden,{children:/*#__PURE__*/o.jsx(n.Announce,{children:ee})})]})}),e.FileIcon=u});
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react-magma-dom"),require("react-magma-icons"),require("react/jsx-runtime"),require("react"),require("polished"),require("react-dropzone")):"function"==typeof define&&define.amd?define(["exports","react-magma-dom","react-magma-icons","react/jsx-runtime","react","polished","react-dropzone"],n):n((e||self).dropzone={},e.reactMagmaDom,e.reactMagmaIcons,e.jsx,e.react,e.polished,e.reactDropzone)}(this,function(e,n,r,t,o,i,l){function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=/*#__PURE__*/a(o),c={default:{Icon:r.DraftOutlinedIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}},word:{Icon:r.FileWordIcon,style:{color:n.magma.colors.blue500},inverseStyle:{color:n.magma.colors.blue500}},excel:{Icon:r.FileExcelIcon,style:{color:n.magma.colors.green500},inverseStyle:{color:n.magma.colors.green500}},powerpoint:{Icon:r.FilePowerpointIcon,style:{color:n.magma.colors.tangerine600},inverseStyle:{color:n.magma.colors.tangerine500}},pdf:{Icon:r.FilePdfIcon,style:{color:n.magma.colors.red600},inverseStyle:{color:n.magma.colors.red500}},image:{Icon:r.ImageOutlinedIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}},video:{Icon:r.VideocamOutlinedIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}},audio:{Icon:r.MusicNoteOutlinedIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}},archive:{Icon:r.FileZipIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}}},u={default:c.default,xlsx:c.excel,xlsm:c.excel,xlsb:c.excel,xltx:c.excel,xls:c.excel,xlt:c.excel,doc:c.word,docx:c.word,docm:c.word,dotx:c.word,dotm:c.word,docb:c.word,pptx:c.powerpoint,pptm:c.powerpoint,ppt:c.powerpoint,pdf:c.pdf,png:c.image,svg:c.image,image:c.image,audio:c.audio,video:c.video,zip:c.archive},d=function(e){var r=e.file,o=e.isInverse,i=r.path,l=void 0===i?"":i,a=r.type,s=(void 0===a?"":a).split("/")[0],c=l.split(".").pop()||"default",d=u[c]||u[s]||u.default;/*#__PURE__*/return t.jsx(d.Icon,{size:n.magma.iconSizes.medium,style:o?d.inverseStyle:d.style})};function p(){return p=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)({}).hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},p.apply(null,arguments)}function f(e,n){if(null==e)return{};var r={};for(var t in e)if({}.hasOwnProperty.call(e,t)){if(-1!==n.indexOf(t))continue;r[t]=e[t]}return r}function m(e,n){return n||(n=e.slice(0)),e.raw=n,e}var g,v,x,h,y,b,I,z,j,S,F,w,C,B,D=function(e,n,r){if(void 0===n&&(n=2),void 0===r&&(r="Bytes"),void 0!==e){if(0==e)return"0 "+r;var t=[r,"KB","MB","GB","TB","PB","EB","ZB","YB"],o=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,o)).toFixed(n))+" "+t[o]}},O=["accept","file","isInverse","maxSize","minSize","onDeleteFile","onRemoveFile","testId","thumbnails"],R=["code"],k=n.styled.div(g||(g=m(["\n background-image: ",";\n background-repeat: no-repeat;\n background-size: cover;\n display: inline-block;\n vertical-align: middle;\n height: 40px;\n width: 40px;\n"])),function(e){var n=e.file;return"url('"+("preview"in n&&n.preview)+"')"}),A=n.styled.div(v||(v=m(["\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"]))),T=function(e){var n=e.file,o=e.isInverse,i=e.theme,l=e.thumbnails;return n.errors?/*#__PURE__*/t.jsx(r.ErrorOutlinedIcon,{color:o?i.colors.red500:i.colors.danger,size:24}):n.preview&&l&&n.type&&n.type.startsWith("image")?/*#__PURE__*/t.jsx(k,{role:"img",file:n}):/*#__PURE__*/t.jsx(d,{isInverse:o,file:n})},M={marginRight:"12px",display:"flex"},E=n.styled.div(x||(x=m(["\n border-top: 1px solid\n ",";\n padding: 16px;\n font-size: ",";\n line-height: ",";\n"])),function(e){var n=e.theme;return e.isInverse?n.colors.neutral500:n.colors.neutral300},function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight}),H=n.styled(n.Flex)(h||(h=m(["\n height: 56px;\n padding: 0 8px 0 16px;\n font-size: ",";\n line-height: ",";\n"])),function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight}),P=n.styled(n.Flex)(y||(y=m(["\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: ",";\n line-height: ",";\n"])),function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight}),L=n.styled(n.Card)(b||(b=m(["\n background-color: none;\n border-color: ",";\n border-width: 1px;\n color: ",";\n margin: 10px 0;\n"])),function(e){var n=e.theme,r=e.isInverse;return e.file.errors?r?n.colors.red500:n.colors.danger:r?n.colors.neutral800:n.colors.neutral200},function(e){var n=e.theme;return e.isInverse?n.colors.neutral0:e.file.errors?n.colors.neutral700:n.colors.brand.navy}),N=n.styled.span(I||(I=m(["\n display: block;\n\n > div {\n display: flex;\n align-self: center;\n margin-right: 12px;\n }\n"]))),V=n.styled.span(z||(z=m(["\n display: block;\n"]))),U=/*#__PURE__*/o.forwardRef(function(e,i){var l,a=e.accept,c=e.file,u=e.isInverse,d=e.maxSize,m=e.minSize,g=e.onDeleteFile,v=e.onRemoveFile,x=e.thumbnails,h=f(e,O),y=o.useContext(n.ThemeContext),b=s.default.useContext(n.I18nContext),I=n.useIsInverse(u),z=o.useState(/*#__PURE__*/t.jsx(r.CloseOutlinedIcon,{})),j=z[0],S=z[1],F=function(){v&&"function"==typeof v&&v(c)},w=function(){g&&"function"==typeof g&&g(c)},C=function(e){var i=e.status,l=void 0===i?"ready":i,a=o.useState(!1),s=a[0],u=a[1];return o.useEffect(function(){var e=!0;return setTimeout(function(){e&&u(!0)},1e3),function(){e=!1}},[l]),"error"===l||"ready"===l?/*#__PURE__*/t.jsx(A,{children:/*#__PURE__*/t.jsx(n.IconButton,{onClick:F,variant:n.ButtonVariant.link,color:n.ButtonColor.subtle,"aria-label":b.dropzone.removeFile+" "+c.name,icon:/*#__PURE__*/t.jsx(r.CloseOutlinedIcon,{})})}):"pending"===l?/*#__PURE__*/t.jsx(A,{children:/*#__PURE__*/t.jsx(n.Spinner,{color:I?y.colors.brand.skyBlue:y.colors.primary})}):/*#__PURE__*/t.jsxs(A,{children:[/*#__PURE__*/t.jsx(n.Transition,{isOpen:!s,unmountOnExit:!0,fade:!0,children:/*#__PURE__*/t.jsx(r.CheckCircleOutlinedIcon,{color:I?y.colors.green500:y.colors.success,style:{marginTop:"4px"}})}),/*#__PURE__*/t.jsx(n.Transition,{isOpen:s,unmountOnExit:!0,fade:!0,children:/*#__PURE__*/t.jsx(n.IconButton,{onClick:w,variant:n.ButtonVariant.link,color:n.ButtonColor.subtle,"aria-label":b.dropzone.deleteFile+" "+c.name,icon:/*#__PURE__*/t.jsx(r.DeleteOutlinedIcon,{})})})]})};return o.useEffect(function(){var e;S(/*#__PURE__*/t.jsx(C,{status:null==c||null==(e=c.processor)?void 0:e.status}))},[null==c||null==(l=c.processor)?void 0:l.status]),/*#__PURE__*/t.jsx(n.InverseContext.Provider,{value:{isInverse:I},children:/*#__PURE__*/t.jsxs(L,{borderRadius:n.CardBorderRadius.small,cornerTreatment:n.CardCornerTreatment.all,isInverse:I,theme:y,file:c,"data-testid":e.testId,ref:i,role:c.errors?"alert":"",children:[/*#__PURE__*/t.jsxs(H,p({theme:y,behavior:n.FlexBehavior.container,alignItems:n.FlexAlignItems.center},h,{children:[/*#__PURE__*/t.jsx(n.Flex,{behavior:n.FlexBehavior.item,alignItems:n.FlexAlignItems.center,style:M,children:/*#__PURE__*/t.jsx(T,{file:c,isInverse:I,theme:y,thumbnails:x})}),/*#__PURE__*/t.jsx(P,{xs:!0,behavior:n.FlexBehavior.item,theme:y,children:c.name}),c.processor&&"pending"===c.processor.status&&/*#__PURE__*/t.jsx(n.Flex,{role:"progressbar",style:{marginLeft:"auto"},behavior:n.FlexBehavior.item,children:c.processor.percent}),/*#__PURE__*/t.jsx(n.Flex,{behavior:n.FlexBehavior.item,children:j})]})),c.errors&&/*#__PURE__*/t.jsx(E,{theme:y,isInverse:I,children:c.errors.slice(0,1).map(function(e){var n=e.code,r=function(e,n,r){var t=Array.isArray(n.accept)&&1===n.accept.length?n.accept[0]:n.accept,o=Array.isArray(t)?"one of "+t.join(", "):t;switch(e.code){case"file-too-large":return p({},e,{message:e.message+" "+D(n.maxSize,2,r)+"."});case"file-too-small":return p({},e,{message:e.message+" "+D(n.minSize,2,r)+"."});case"file-invalid-type":return p({},e,{message:e.message+": "+o});default:return e}}(p({code:n},f(e,R),b.dropzone.errors[n]),{accept:a,minSize:m,maxSize:d},b.dropzone.bytes),o=r.header,i=r.message;/*#__PURE__*/return t.jsxs(s.default.Fragment,{children:[/*#__PURE__*/t.jsx(N,{style:{color:I?y.colors.red500:y.colors.danger},children:void 0===o?"":o}),/*#__PURE__*/t.jsx(V,{children:i})]},n)})})]})})}),q=["accept","buttonColor","buttonText","containerStyle","disabled","dropzoneOptions","helperMessage","id","inputSize","isInverse","isLabelVisuallyHidden","labelStyle","labelText","maxFiles","minFiles","maxSize","minSize","multiple","noDrag","onSendFile","onDeleteFile","onRemoveFile","sendFiles","testId","thumbnails"];!function(e){e.error="error",e.dragAccept="dragAccept",e.dragReject="dragReject",e.dragActive="dragActive",e.default="default"}(B||(B={}));var G=function(e,n){return null!=e?e:n},W=n.styled(n.Flex)(j||(j=m(["\n flex-direction: column;\n align-items: ",";\n justify-content: ",";\n text-align: ",";\n padding: ",";\n border-radius: ",";\n border: ",";\n\n border-style: ",";\n background-color: ",";\n outline: none;\n transition: ",";\n"])),function(e){return e.noDrag?"left":"center"},function(e){return e.noDrag?"left":"center"},function(e){return e.noDrag?"left":"center"},function(e){return e.noDrag?"0px":"24px"},function(e){var n=e.theme;return e.noDrag?n.borderRadiusNone:n.borderRadiusSmall},function(e){var n=e.dragState,r=void 0===n?B.default:n,t=e.theme,o=e.isInverse;return e.noDrag?"0px":r===B.dragReject||r===B.error?(r===B.error?"1px":"2px")+" dashed "+function(e,n,r){return r?e===B.error?n.colors.red500:n.colors.red400:n.colors.danger}(r,t,o):r===B.dragActive?"2px dashed "+t.colors.blue500:r===B.dragAccept?"2px dashed "+t.colors.green500:"2px dashed "+(o?t.colors.neutral800:t.colors.neutral300)},function(e){var n=e.dragState;return(void 0===n?B.default:n)===B.error?"solid":"dashed"},function(e){var n=e.theme;return e.noDrag?"transparent":e.isInverse?i.transparentize(.6,n.colors.neutral1200):n.colors.neutral100},function(e){return"border "+(e.noDrag?0:".24s")+" ease-in-out"}),Z=n.styled.span(S||(S=m(["\n color: ",";\n display: block;\n font-size: 14px;\n margin: -8px 0 16px 0;\n"])),function(e){var n=e.theme;return e.isInverse?n.colors.neutral500:n.colors.neutral700}),K=n.styled.div(F||(F=m(["\n color: ",";\n margin: 0 0 24px 0;\n font-size: ",";\n line-height: ",";\n font-weight: 500;\n padding: ",";\n"])),function(e){var n=e.theme;return e.isInverse?n.colors.neutral0:n.colors.brand.navy},function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight},function(e){return e.theme.spaceScale.spacing01}),Y=n.styled.ul(w||(w=m(["\n list-style: none;\n padding: 0;\n"]))),J=n.styled.li(C||(C=m([""])));e.Dropzone=/*#__PURE__*/s.default.forwardRef(function(e,i){var a=e.accept,c=e.buttonColor,u=void 0===c?n.ButtonColor.primary:c,d=e.buttonText,m=e.containerStyle,g=e.disabled,v=e.dropzoneOptions,x=void 0===v?{multiple:!0}:v,h=e.helperMessage,y=e.id,b=e.inputSize,I=e.isInverse,z=e.isLabelVisuallyHidden,j=e.labelStyle,S=e.labelText,F=e.maxFiles,w=e.minFiles,C=e.maxSize,D=e.minSize,O=e.multiple,R=void 0===O||O,k=e.noDrag,A=void 0!==k&&k,T=e.onSendFile,M=e.onDeleteFile,E=e.onRemoveFile,H=e.sendFiles,P=void 0!==H&&H,L=e.testId,N=e.thumbnails,V=void 0===N||N,Q=f(e,q),X=s.default.useState([]),$=X[0],_=X[1],ee=s.default.useState(null),ne=ee[0],re=ee[1],te=s.default.useState(""),oe=te[0],ie=te[1],le=n.useIsInverse(I),ae=s.default.useContext(n.ThemeContext),se=s.default.useContext(n.I18nContext),ce=n.useGenerateId(y),ue=n.useGenerateId(ce+"-helper"),de=s.default.useRef(null),pe=s.default.useCallback(function(e,n){var r=[].concat(e.map(function(e){return Object.assign(e,{preview:URL.createObjectURL(e)})}),n.map(function(e){return Object.assign(e.file,{errors:e.errors})}));if(_(function(e){return[].concat(e,r)}),e.length>0){var t=e.map(function(e){return e.name}).join(", "),o=1===e.length?se.dropzone.fileAdded.replace(/\{fileName\}/g,t):se.dropzone.filesAdded.replace(/\{count\}/g,e.length.toString()).replace(/\{fileNames\}/g,t);ie(o)}de.current&&de.current.focus()},[se]),fe=l.useDropzone(p({noClick:!0,disabled:g,multiple:R,maxSize:C,minSize:D,accept:a,onDrop:pe,noDrag:A},x)),me=fe.getInputProps,ge=fe.getRootProps,ve=fe.isDragAccept,xe=fe.isDragActive,he=fe.isDragReject,ye=fe.open,be=fe.inputRef;o.useImperativeHandle(i,function(){return be.current});var Ie=me({id:ce}),ze=B.default;ne?ze=B.error:ve?ze=B.dragAccept:he?ze=B.dragReject:xe&&(ze=B.dragActive);var je=function(e){_(function(n){return n.filter(function(n){return n!==e})}),E&&"function"==typeof E&&E(e);var n=se.dropzone.fileRemoved.replace(/\{fileName\}/g,e.name);ie(n),de.current&&de.current.focus()},Se=function(e){_(function(n){return n.filter(function(n){return n!==e})}),M&&"function"==typeof M&&M(e);var n=se.dropzone.fileDeleted.replace(/\{fileName\}/g,e.name);ie(n),de.current&&de.current.focus()},Fe=function(e){if(_(function(n){return n.map(function(n){return n===e.file?Object.assign(n,{processor:p({},n.processor,{percent:e.percent+"%",status:"pending"})}):n})}),e.percent>0&&e.percent%25==0){var n=se.dropzone.fileUploading.replace(/\{fileName\}/g,e.file.name).replace(/\{percent\}/g,e.percent.toString());ie(n)}},we=function(e){_(function(n){return n.map(function(n){return n===e.file?Object.assign(n,{processor:p({},n.processor,{percent:"",status:"finished"})}):n})});var n=se.dropzone.fileUploaded.replace(/\{fileName\}/g,e.file.name);ie(n)},Ce=function(e){_(function(n){return n.map(function(n){return n===e.file?Object.assign(n,{errors:e.errors,processor:p({},n.processor,{status:"error"})}):n})})};return s.default.useEffect(function(){return function(){$.forEach(function(e){return e.preview&&URL.revokeObjectURL(e.preview)})}},[$]),s.default.useEffect(function(){var e=w&&$.length<w,n=F&&$.length>F,r=null;n?r="too-many-files":e&&(r="too-few-files"),re(function(e,n){if(null===e)return null;var r=se.dropzone.errors[e];switch(e){case"too-many-files":return r.message+" "+n.maxFiles+" "+se.dropzone.files+".";case"too-few-files":return r.message+" "+n.minFiles+" "+se.dropzone.files+".";default:return r.message}}(r,{minFiles:w,maxFiles:F})),P&&$.length>0&&!n&&!e&&_(function(e){return e.map(function(e){return e.errors||e.processor||!T||T({file:e,onError:Ce,onFinish:we,onProgress:Fe}),e})})},[P,$.length,T,F,w,se.dropzone.errors,se.dropzone.files]),/*#__PURE__*/t.jsxs(n.InverseContext.Provider,{value:{isInverse:le},children:[/*#__PURE__*/t.jsxs(n.FormFieldContainer,{actionable:!1,containerStyle:m,errorMessage:ne,fieldId:ce,inputSize:b,isInverse:le,isLabelVisuallyHidden:z,labelStyle:p({color:le?ae.colors.neutral0:ae.colors.brand.navy},j),labelText:S,messageStyle:{minHeight:0},"data-testid":L,children:[/*#__PURE__*/t.jsx(Z,{id:ue,theme:ae,isInverse:le,children:h}),/*#__PURE__*/t.jsxs(W,p({behavior:n.FlexBehavior.container,dragState:ze,isInverse:le,noDrag:A,theme:ae},ge(),Q,{testId:L,tabIndex:-1,children:[/*#__PURE__*/t.jsx("input",{ref:be,type:Ie.type,accept:Ie.accept,autoComplete:Ie.autoComplete,id:Ie.id,multiple:Ie.multiple,onChange:Ie.onChange,onClick:Ie.onClick,style:Ie.style,tabIndex:Ie.tabIndex,"data-testid":"file-input"}),A?/*#__PURE__*/t.jsx(n.Flex,{xs:!0,behavior:n.FlexBehavior.item,children:/*#__PURE__*/t.jsx(n.Button,{color:u,disabled:g,isInverse:le,onClick:ye,style:{margin:0},ref:de,"aria-describedby":h?ue:void 0,children:G(d,se.dropzone.browseFiles)})}):/*#__PURE__*/t.jsxs(n.Flex,{behavior:n.FlexBehavior.item,children:[/*#__PURE__*/t.jsx(r.CloudUploadOutlinedIcon,{"aria-hidden":"true",color:le?ae.colors.neutral0:ae.colors.neutral700,size:48}),/*#__PURE__*/t.jsx(K,{isInverse:le,theme:ae,children:se.dropzone.dragMessage}),/*#__PURE__*/t.jsx(n.Button,{color:u,disabled:g,isInverse:le,onClick:ye,style:{margin:0},variant:n.ButtonVariant.solid,ref:de,"aria-describedby":h?ue:void 0,children:G(d,se.dropzone.browseFiles)})]})]}))]}),/*#__PURE__*/t.jsx(Y,{children:$.map(function(e){/*#__PURE__*/return t.jsx(J,{children:/*#__PURE__*/t.jsx(U,{accept:a,file:e,isInverse:le,maxSize:C,minSize:D,onDeleteFile:Se,onRemoveFile:je,thumbnails:V})},e.name)})}),/*#__PURE__*/t.jsx(n.VisuallyHidden,{children:/*#__PURE__*/t.jsx(n.Announce,{children:oe})})]})}),e.FileIcon=d});
|
|
2
2
|
//# sourceMappingURL=fileuploader.umd.js.map
|