@react-magma/dropzone 16.0.0-v6-next.3 → 16.0.0-v6-next.5
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 +1 -1
- package/dist/fileuploader.modern.js.map +1 -1
- package/dist/fileuploader.modern.module.js +1 -1
- package/dist/fileuploader.modern.module.js.map +1 -1
- package/dist/fileuploader.umd.js +1 -1
- package/dist/fileuploader.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/components/dropzone/Dropzone.tsx +2 -2
- package/src/components/dropzone/FileIcon.tsx +8 -8
- package/src/components/dropzone/Preview.tsx +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileuploader.modern.js","sources":["../src/components/dropzone/FileIcon.tsx","../src/components/dropzone/utils.ts","../src/components/dropzone/Preview.tsx","../src/components/dropzone/Dropzone.tsx"],"sourcesContent":["import React from 'react';\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","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","/* 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\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 <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}\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"],"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","file","isInverse","path","type","category","split","extension","pop","_jsx","size","iconSizes","medium","formatFileSize","bytes","decimalPoint","bytesLabel","undefined","sizes","i","Math","floor","log","parseFloat","pow","toFixed","_excluded","_excluded2","_t","_t2","_t3","_t4","_t5","_t6","_t7","_t8","_","t","Thumb","styled","div","preview","StatusIcons","PreviewIcon","theme","thumbnails","errors","ErrorIcon","danger","startsWith","role","IconStyles","marginRight","display","Errors","neutral500","typeScale","size02","fontSize","lineHeight","StyledFlex","Flex","FileName","StyledCard","Card","neutral800","neutral200","neutral0","brand","navy","ErrorHeader","span","ErrorMessage","Preview","forwardRef","props","ref","_file$processor2","accept","isInverseProp","maxSize","minSize","onDeleteFile","onRemoveFile","rest","_objectWithoutPropertiesLoose","useContext","ThemeContext","i18n","React","I18nContext","useIsInverse","actions","setActions","useState","CloseIcon","handleRemoveFile","handleDeleteFile","FinishedActions","status","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","_ref","code","header","message","formatError","error","constraints","byteLabel","Array","isArray","length","messageSuffix","join","Fragment","DragState","getBrowseButtonText","buttonText","localizedText","Container","noDrag","borderRadiusNone","borderRadiusSmall","getContainerBorder","dragState","dragReject","getErrorBorderColor","red400","dragActive","dragAccept","transparentize","neutral1200","neutral100","HelperMessage","Wrapper","spaceScale","spacing01","PreviewList","ul","PreviewItem","li","Dropzone","buttonColor","containerStyle","disabled","dropzoneOptions","multiple","helperMessage","id","defaultId","inputSize","isLabelVisuallyHidden","labelStyle","labelText","maxFiles","minFiles","onSendFile","sendFiles","files","setFiles","errorMessage","setErrorMessage","announcement","setAnnouncement","useGenerateId","helperMessageId","browseFileButtonRef","useRef","onDrop","useCallback","acceptedFiles","rejectedFiles","newFiles","Object","assign","URL","createObjectURL","prevFiles","fileNames","fileAdded","replace","filesAdded","toString","current","focus","getInputProps","getRootProps","isDragAccept","isDragActive","isDragReject","open","inputRef","useDropzone","noClick","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,MAAMA,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,KAAM8B,EACN5B,MAAO,CACLC,MAAOC,EAAMC,OAAOC,YAEtBC,aAAc,CACZJ,MAAOC,EAAMC,OAAOG,cAKpBuB,EAMF,CACFhC,QAASD,EAAMC,QACfiC,KAAMlC,EAAMc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,EAAM1D,IAAKzJ,gBACVQ,EAACwL,GAAW,CAAAxF,sBACVhG,EAACgE,GACCK,CAAAA,OAAQA,EACR7E,KAAMA,EACNC,UAAWA,GACX8E,QAASA,EACTC,QAASA,EACTC,aAAce,GACdd,aAAca,GACdnD,WAAYA,KATE5C,EAAKkH,sBAe3B1G,EAACmR,EAAc,CAAAnL,sBACbhG,EAACoR,EAAQpL,CAAAA,SAAE+G,QAEU"}
|
|
1
|
+
{"version":3,"file":"fileuploader.modern.js","sources":["../src/components/dropzone/FileIcon.tsx","../src/components/dropzone/utils.ts","../src/components/dropzone/Preview.tsx","../src/components/dropzone/Dropzone.tsx"],"sourcesContent":["import React from 'react';\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","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","/* 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"],"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","file","isInverse","path","type","category","split","extension","pop","_jsx","size","iconSizes","medium","formatFileSize","bytes","decimalPoint","bytesLabel","undefined","sizes","i","Math","floor","log","parseFloat","pow","toFixed","_excluded","_excluded2","_t","_t2","_t3","_t4","_t5","_t6","_t7","_t8","_","t","Thumb","styled","div","preview","StatusIcons","PreviewIcon","theme","thumbnails","errors","ErrorOutlinedIcon","danger","startsWith","role","IconStyles","marginRight","display","Errors","neutral500","typeScale","size02","fontSize","lineHeight","StyledFlex","Flex","FileName","StyledCard","Card","neutral800","neutral200","neutral0","brand","navy","ErrorHeader","span","ErrorMessage","Preview","forwardRef","props","ref","_file$processor2","accept","isInverseProp","maxSize","minSize","onDeleteFile","onRemoveFile","rest","_objectWithoutPropertiesLoose","useContext","ThemeContext","i18n","React","I18nContext","useIsInverse","actions","setActions","useState","CloseOutlinedIcon","handleRemoveFile","handleDeleteFile","FinishedActions","status","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","_ref","code","header","message","formatError","error","constraints","byteLabel","Array","isArray","length","messageSuffix","join","Fragment","DragState","getBrowseButtonText","buttonText","localizedText","Container","noDrag","borderRadiusNone","borderRadiusSmall","getContainerBorder","dragState","dragReject","getErrorBorderColor","red400","dragActive","dragAccept","transparentize","neutral1200","neutral100","HelperMessage","Wrapper","spaceScale","spacing01","PreviewList","ul","PreviewItem","li","Dropzone","buttonColor","containerStyle","disabled","dropzoneOptions","multiple","helperMessage","id","defaultId","inputSize","isLabelVisuallyHidden","labelStyle","labelText","maxFiles","minFiles","onSendFile","sendFiles","files","setFiles","errorMessage","setErrorMessage","announcement","setAnnouncement","useGenerateId","helperMessageId","browseFileButtonRef","useRef","onDrop","useCallback","acceptedFiles","rejectedFiles","newFiles","Object","assign","URL","createObjectURL","prevFiles","fileNames","fileAdded","replace","filesAdded","toString","current","focus","getInputProps","getRootProps","isDragAccept","isDragActive","isDragReject","open","inputRef","useDropzone","noClick","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,MAAMA,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,KAAM8B,EACN5B,MAAO,CACLC,MAAOC,EAAMC,OAAOC,YAEtBC,aAAc,CACZJ,MAAOC,EAAMC,OAAOG,cAKpBuB,EAMF,CACFhC,QAASD,EAAMC,QACfiC,KAAMlC,EAAMc,MACZqB,KAAMnC,EAAMc,MACZsB,KAAMpC,EAAMc,MACZuB,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sBACVhG,EAACgE,GACCK,CAAAA,OAAQA,EACR7E,KAAMA,EACNC,UAAWA,GACX8E,QAASA,EACTC,QAASA,EACTC,aAAce,GACdd,aAAca,GACdnD,WAAYA,KATE5C,EAAKkH,sBAe3B1G,EAACmR,EAAc,CAAAnL,sBACbhG,EAACoR,EAAQpL,CAAAA,SAAE+G,QAEU"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{magma as e,styled as r,Flex as n,Card as o,ThemeContext as t,I18nContext as i,useIsInverse as l,InverseContext as a,CardBorderRadius as s,CardCornerTreatment as c,FlexBehavior as u,FlexAlignItems as d,IconButton as p,ButtonVariant as f,ButtonColor as m,Spinner as g,Transition as v,useGenerateId as h,FormFieldContainer as b,Button as y,VisuallyHidden as x,Announce as z}from"react-magma-dom";import{InsertDriveFileIcon as S,FileWordIcon as I,FileExcelIcon as w,FilePowerpointIcon as F,FilePdfIcon as k,ImageIcon as R,VideocamIcon as D,AudiotrackIcon as j,FileZipIcon as O,CloseIcon as C,ErrorIcon as A,CheckCircleIcon as B,DeleteIcon as M,CloudUploadIcon as T}from"react-magma-icons";import{jsx as H,jsxs as L}from"react/jsx-runtime";import P,{forwardRef as E,useContext as N,useState as U,useEffect as V,useImperativeHandle as G}from"react";import{transparentize as K}from"polished";import{useDropzone as W}from"react-dropzone";var Y={default:{Icon:S,style:{color:e.colors.neutral700},inverseStyle:{color:e.colors.neutral300}},word:{Icon:I,style:{color:e.colors.blue500},inverseStyle:{color:e.colors.blue500}},excel:{Icon:w,style:{color:e.colors.green500},inverseStyle:{color:e.colors.green500}},powerpoint:{Icon:F,style:{color:e.colors.tangerine600},inverseStyle:{color:e.colors.tangerine500}},pdf:{Icon:k,style:{color:e.colors.red600},inverseStyle:{color:e.colors.red500}},image:{Icon:R,style:{color:e.colors.neutral700},inverseStyle:{color:e.colors.neutral300}},video:{Icon:D,style:{color:e.colors.neutral700},inverseStyle:{color:e.colors.neutral300}},audio:{Icon:j,style:{color:e.colors.neutral700},inverseStyle:{color:e.colors.neutral300}},archive:{Icon:O,style:{color:e.colors.neutral700},inverseStyle:{color:e.colors.neutral300}}},Z={default:Y.default,xlsx:Y.excel,xlsm:Y.excel,xlsb:Y.excel,xltx:Y.excel,xls:Y.excel,xlt:Y.excel,doc:Y.word,docx:Y.word,docm:Y.word,dotx:Y.word,dotm:Y.word,docb:Y.word,pptx:Y.powerpoint,pptm:Y.powerpoint,ppt:Y.powerpoint,pdf:Y.pdf,png:Y.image,svg:Y.image,image:Y.image,audio:Y.audio,video:Y.video,zip:Y.archive},q=function(r){var n=r.file,o=r.isInverse,t=n.path,i=void 0===t?"":t,l=n.type,a=(void 0===l?"":l).split("/")[0],s=i.split(".").pop()||"default",c=Z[s]||Z[a]||Z.default;/*#__PURE__*/return H(c.Icon,{size:e.iconSizes.medium,style:o?c.inverseStyle:c.style})};function J(){return J=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},J.apply(null,arguments)}function Q(e,r){if(null==e)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(-1!==r.indexOf(o))continue;n[o]=e[o]}return n}function X(e,r){return r||(r=e.slice(0)),e.raw=r,e}var $,_,ee,re,ne,oe,te,ie,le,ae,se,ce,ue,de,pe=function(e,r,n){if(void 0===r&&(r=2),void 0===n&&(n="Bytes"),void 0!==e){if(0==e)return"0 "+n;var o=[n,"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(r))+" "+o[t]}},fe=["accept","file","isInverse","maxSize","minSize","onDeleteFile","onRemoveFile","testId","thumbnails"],me=["code"],ge=r.div($||($=X(["\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 r=e.file;return"url('"+("preview"in r&&r.preview)+"')"}),ve=r.div(_||(_=X(["\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"]))),he=function(e){var r=e.file,n=e.isInverse,o=e.theme,t=e.thumbnails;return r.errors?/*#__PURE__*/H(A,{color:n?o.colors.red500:o.colors.danger,size:24}):r.preview&&t&&r.type&&r.type.startsWith("image")?/*#__PURE__*/H(ge,{role:"img",file:r}):/*#__PURE__*/H(q,{isInverse:n,file:r})},be={marginRight:"12px",display:"flex"},ye=r.div(ee||(ee=X(["\n border-top: 1px solid\n ",";\n padding: 16px;\n font-size: ",";\n line-height: ",";\n"])),function(e){var r=e.theme;return e.isInverse?r.colors.neutral500:r.colors.neutral300},function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight}),xe=r(n)(re||(re=X(["\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}),ze=r(n)(ne||(ne=X(["\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}),Se=r(o)(oe||(oe=X(["\n background-color: none;\n border-color: ",";\n border-width: 1px;\n color: ",";\n margin: 10px 0;\n"])),function(e){var r=e.theme,n=e.isInverse;return e.file.errors?n?r.colors.red500:r.colors.danger:n?r.colors.neutral800:r.colors.neutral200},function(e){var r=e.theme;return e.isInverse?r.colors.neutral0:e.file.errors?r.colors.neutral700:r.colors.brand.navy}),Ie=r.span(te||(te=X(["\n display: block;\n\n > div {\n display: flex;\n align-self: center;\n margin-right: 12px;\n }\n"]))),we=r.span(ie||(ie=X(["\n display: block;\n"]))),Fe=/*#__PURE__*/E(function(e,r){var o,h=e.accept,b=e.file,y=e.isInverse,x=e.maxSize,z=e.minSize,S=e.onDeleteFile,I=e.onRemoveFile,w=e.thumbnails,F=Q(e,fe),k=N(t),R=P.useContext(i),D=l(y),j=U(/*#__PURE__*/H(C,{})),O=j[0],A=j[1],T=function(){I&&"function"==typeof I&&I(b)},E=function(){S&&"function"==typeof S&&S(b)},G=function(e){var r=e.status,n=void 0===r?"ready":r,o=U(!1),t=o[0],i=o[1];return V(function(){var e=!0;return setTimeout(function(){e&&i(!0)},1e3),function(){e=!1}},[n]),"error"===n||"ready"===n?/*#__PURE__*/H(ve,{children:/*#__PURE__*/H(p,{onClick:T,variant:f.link,color:m.subtle,"aria-label":R.dropzone.removeFile+" "+b.name,icon:/*#__PURE__*/H(C,{})})}):"pending"===n?/*#__PURE__*/H(ve,{children:/*#__PURE__*/H(g,{color:D?k.colors.brand.skyBlue:k.colors.primary})}):/*#__PURE__*/L(ve,{children:[/*#__PURE__*/H(v,{isOpen:!t,unmountOnExit:!0,fade:!0,children:/*#__PURE__*/H(B,{color:D?k.colors.green500:k.colors.success,style:{marginTop:"4px"}})}),/*#__PURE__*/H(v,{isOpen:t,unmountOnExit:!0,fade:!0,children:/*#__PURE__*/H(p,{onClick:E,variant:f.link,color:m.subtle,"aria-label":R.dropzone.deleteFile+" "+b.name,icon:/*#__PURE__*/H(M,{})})})]})};return V(function(){var e;A(/*#__PURE__*/H(G,{status:null==b||null==(e=b.processor)?void 0:e.status}))},[null==b||null==(o=b.processor)?void 0:o.status]),/*#__PURE__*/H(a.Provider,{value:{isInverse:D},children:/*#__PURE__*/L(Se,{borderRadius:s.small,cornerTreatment:c.all,isInverse:D,theme:k,file:b,"data-testid":e.testId,ref:r,role:b.errors?"alert":"",children:[/*#__PURE__*/L(xe,J({theme:k,behavior:u.container,alignItems:d.center},F,{children:[/*#__PURE__*/H(n,{behavior:u.item,alignItems:d.center,style:be,children:/*#__PURE__*/H(he,{file:b,isInverse:D,theme:k,thumbnails:w})}),/*#__PURE__*/H(ze,{xs:!0,behavior:u.item,theme:k,children:b.name}),b.processor&&"pending"===b.processor.status&&/*#__PURE__*/H(n,{role:"progressbar",style:{marginLeft:"auto"},behavior:u.item,children:b.processor.percent}),/*#__PURE__*/H(n,{behavior:u.item,children:O})]})),b.errors&&/*#__PURE__*/H(ye,{theme:k,isInverse:D,children:b.errors.slice(0,1).map(function(e){var r=e.code,n=function(e,r,n){var o=Array.isArray(r.accept)&&1===r.accept.length?r.accept[0]:r.accept,t=Array.isArray(o)?"one of "+o.join(", "):o;switch(e.code){case"file-too-large":return J({},e,{message:e.message+" "+pe(r.maxSize,2,n)+"."});case"file-too-small":return J({},e,{message:e.message+" "+pe(r.minSize,2,n)+"."});case"file-invalid-type":return J({},e,{message:e.message+": "+t});default:return e}}(J({code:r},Q(e,me),R.dropzone.errors[r]),{accept:h,minSize:z,maxSize:x},R.dropzone.bytes),o=n.header,t=n.message;/*#__PURE__*/return L(P.Fragment,{children:[/*#__PURE__*/H(Ie,{style:{color:D?k.colors.red500:k.colors.danger},children:void 0===o?"":o}),/*#__PURE__*/H(we,{children:t})]},r)})})]})})}),ke=["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"}(de||(de={}));var Re=function(e,r){return null!=e?e:r},De=r(n)(le||(le=X(["\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 r=e.theme;return e.noDrag?r.borderRadiusNone:r.borderRadiusSmall},function(e){var r=e.dragState,n=void 0===r?de.default:r,o=e.theme,t=e.isInverse;return e.noDrag?"0px":n===de.dragReject||n===de.error?(n===de.error?"1px":"2px")+" dashed "+function(e,r,n){return n?e===de.error?r.colors.red500:r.colors.red400:r.colors.danger}(n,o,t):n===de.dragActive?"2px dashed "+o.colors.blue500:n===de.dragAccept?"2px dashed "+o.colors.green500:"2px dashed "+(t?o.colors.neutral800:o.colors.neutral300)},function(e){var r=e.dragState;return(void 0===r?de.default:r)===de.error?"solid":"dashed"},function(e){var r=e.theme;return e.noDrag?"transparent":e.isInverse?K(.6,r.colors.neutral1200):r.colors.neutral100},function(e){return"border "+(e.noDrag?0:".24s")+" ease-in-out"}),je=r.span(ae||(ae=X(["\n color: ",";\n display: block;\n font-size: 14px;\n margin: -8px 0 16px 0;\n"])),function(e){var r=e.theme;return e.isInverse?r.colors.neutral500:r.colors.neutral700}),Oe=r.div(se||(se=X(["\n color: ",";\n margin: 0 0 24px 0;\n font-size: ",";\n line-height: ",";\n font-weight: 500;\n padding: ",";\n"])),function(e){var r=e.theme;return e.isInverse?r.colors.neutral0:r.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}),Ce=r.ul(ce||(ce=X(["\n list-style: none;\n padding: 0;\n"]))),Ae=r.li(ue||(ue=X([""]))),Be=/*#__PURE__*/P.forwardRef(function(e,r){var o=e.accept,s=e.buttonColor,c=void 0===s?m.primary:s,d=e.buttonText,p=e.containerStyle,g=e.disabled,v=e.dropzoneOptions,S=void 0===v?{multiple:!0}:v,I=e.helperMessage,w=e.id,F=e.inputSize,k=e.isInverse,R=e.isLabelVisuallyHidden,D=e.labelStyle,j=e.labelText,O=e.maxFiles,C=e.minFiles,A=e.maxSize,B=e.minSize,M=e.multiple,E=void 0===M||M,N=e.noDrag,U=void 0!==N&&N,V=e.onSendFile,K=e.onDeleteFile,Y=e.onRemoveFile,Z=e.sendFiles,q=void 0!==Z&&Z,X=e.testId,$=e.thumbnails,_=void 0===$||$,ee=Q(e,ke),re=P.useState([]),ne=re[0],oe=re[1],te=P.useState(null),ie=te[0],le=te[1],ae=P.useState(""),se=ae[0],ce=ae[1],ue=l(k),pe=P.useContext(t),fe=P.useContext(i),me=h(w),ge=h(me+"-helper"),ve=P.useRef(null),he=P.useCallback(function(e,r){var n=[].concat(e.map(function(e){return Object.assign(e,{preview:URL.createObjectURL(e)})}),r.map(function(e){return Object.assign(e.file,{errors:e.errors})}));if(oe(function(e){return[].concat(e,n)}),e.length>0){var o=e.map(function(e){return e.name}).join(", "),t=1===e.length?fe.dropzone.fileAdded.replace(/\{fileName\}/g,o):fe.dropzone.filesAdded.replace(/\{count\}/g,e.length.toString()).replace(/\{fileNames\}/g,o);ce(t)}ve.current&&ve.current.focus()},[fe]),be=W(J({noClick:!0,disabled:g,multiple:E,maxSize:A,minSize:B,accept:o,onDrop:he,noDrag:U},S)),ye=be.getInputProps,xe=be.getRootProps,ze=be.isDragAccept,Se=be.isDragActive,Ie=be.isDragReject,we=be.open,Be=be.inputRef;G(r,function(){return Be.current});var Me=ye({id:me}),Te=de.default;ie?Te=de.error:ze?Te=de.dragAccept:Ie?Te=de.dragReject:Se&&(Te=de.dragActive);var He=function(e){oe(function(r){return r.filter(function(r){return r!==e})}),Y&&"function"==typeof Y&&Y(e);var r=fe.dropzone.fileRemoved.replace(/\{fileName\}/g,e.name);ce(r),ve.current&&ve.current.focus()},Le=function(e){oe(function(r){return r.filter(function(r){return r!==e})}),K&&"function"==typeof K&&K(e);var r=fe.dropzone.fileDeleted.replace(/\{fileName\}/g,e.name);ce(r),ve.current&&ve.current.focus()},Pe=function(e){if(oe(function(r){return r.map(function(r){return r===e.file?Object.assign(r,{processor:J({},r.processor,{percent:e.percent+"%",status:"pending"})}):r})}),e.percent>0&&e.percent%25==0){var r=fe.dropzone.fileUploading.replace(/\{fileName\}/g,e.file.name).replace(/\{percent\}/g,e.percent.toString());ce(r)}},Ee=function(e){oe(function(r){return r.map(function(r){return r===e.file?Object.assign(r,{processor:J({},r.processor,{percent:"",status:"finished"})}):r})});var r=fe.dropzone.fileUploaded.replace(/\{fileName\}/g,e.file.name);ce(r)},Ne=function(e){oe(function(r){return r.map(function(r){return r===e.file?Object.assign(r,{errors:e.errors,processor:J({},r.processor,{status:"error"})}):r})})};return P.useEffect(function(){return function(){ne.forEach(function(e){return e.preview&&URL.revokeObjectURL(e.preview)})}},[ne]),P.useEffect(function(){var e=C&&ne.length<C,r=O&&ne.length>O,n=null;r?n="too-many-files":e&&(n="too-few-files"),le(function(e,r){if(null===e)return null;var n=fe.dropzone.errors[e];switch(e){case"too-many-files":return n.message+" "+r.maxFiles+" "+fe.dropzone.files+".";case"too-few-files":return n.message+" "+r.minFiles+" "+fe.dropzone.files+".";default:return n.message}}(n,{minFiles:C,maxFiles:O})),q&&ne.length>0&&!r&&!e&&oe(function(e){return e.map(function(e){return e.errors||e.processor||!V||V({file:e,onError:Ne,onFinish:Ee,onProgress:Pe}),e})})},[q,ne.length,V,O,C,fe.dropzone.errors,fe.dropzone.files]),/*#__PURE__*/L(a.Provider,{value:{isInverse:ue},children:[/*#__PURE__*/L(b,{actionable:!1,containerStyle:p,errorMessage:ie,fieldId:me,inputSize:F,isInverse:ue,isLabelVisuallyHidden:R,labelStyle:J({color:ue?pe.colors.neutral0:pe.colors.brand.navy},D),labelText:j,messageStyle:{minHeight:0},"data-testid":X,children:[/*#__PURE__*/H(je,{id:ge,theme:pe,isInverse:ue,children:I}),/*#__PURE__*/L(De,J({behavior:u.container,dragState:Te,isInverse:ue,noDrag:U,theme:pe},xe(),ee,{testId:X,tabIndex:-1,children:[/*#__PURE__*/H("input",{ref:Be,type:Me.type,accept:Me.accept,autoComplete:Me.autoComplete,id:Me.id,multiple:Me.multiple,onChange:Me.onChange,onClick:Me.onClick,style:Me.style,tabIndex:Me.tabIndex,"data-testid":"file-input"}),U?/*#__PURE__*/H(n,{xs:!0,behavior:u.item,children:/*#__PURE__*/H(y,{color:c,disabled:g,isInverse:ue,onClick:we,style:{margin:0},ref:ve,"aria-describedby":I?ge:void 0,children:Re(d,fe.dropzone.browseFiles)})}):/*#__PURE__*/L(n,{behavior:u.item,children:[/*#__PURE__*/H(T,{"aria-hidden":"true",color:ue?pe.colors.neutral0:pe.colors.neutral700,size:48}),/*#__PURE__*/H(Oe,{isInverse:ue,theme:pe,children:fe.dropzone.dragMessage}),/*#__PURE__*/H(y,{color:c,disabled:g,isInverse:ue,onClick:we,style:{margin:0},variant:f.solid,ref:ve,"aria-describedby":I?ge:void 0,children:Re(d,fe.dropzone.browseFiles)})]})]}))]}),/*#__PURE__*/H(Ce,{children:ne.map(function(e){/*#__PURE__*/return H(Ae,{children:/*#__PURE__*/H(Fe,{accept:o,file:e,isInverse:ue,maxSize:A,minSize:B,onDeleteFile:Le,onRemoveFile:He,thumbnails:_})},e.name)})}),/*#__PURE__*/H(x,{children:/*#__PURE__*/H(z,{children:se})})]})});export{Be as Dropzone,q as FileIcon};
|
|
1
|
+
import{magma as e,styled as r,Flex as n,Card as o,ThemeContext as t,I18nContext as i,useIsInverse as l,InverseContext as a,CardBorderRadius as s,CardCornerTreatment as c,FlexBehavior as u,FlexAlignItems as d,IconButton as p,ButtonVariant as f,ButtonColor as m,Spinner as g,Transition as v,useGenerateId as h,FormFieldContainer as b,Button as y,VisuallyHidden as x,Announce as z}from"react-magma-dom";import{DraftOutlinedIcon as S,FileWordIcon as I,FileExcelIcon as w,FilePowerpointIcon as F,FilePdfIcon as k,ImageOutlinedIcon as R,VideocamOutlinedIcon as D,MusicNoteOutlinedIcon as j,FileZipIcon as O,CloseOutlinedIcon as C,ErrorOutlinedIcon as A,CheckCircleOutlinedIcon as B,DeleteOutlinedIcon as M,CloudUploadOutlinedIcon as T}from"react-magma-icons";import{jsx as H,jsxs as L}from"react/jsx-runtime";import P,{forwardRef as E,useContext as N,useState as U,useEffect as V,useImperativeHandle as G}from"react";import{transparentize as K}from"polished";import{useDropzone as W}from"react-dropzone";var Y={default:{Icon:S,style:{color:e.colors.neutral700},inverseStyle:{color:e.colors.neutral300}},word:{Icon:I,style:{color:e.colors.blue500},inverseStyle:{color:e.colors.blue500}},excel:{Icon:w,style:{color:e.colors.green500},inverseStyle:{color:e.colors.green500}},powerpoint:{Icon:F,style:{color:e.colors.tangerine600},inverseStyle:{color:e.colors.tangerine500}},pdf:{Icon:k,style:{color:e.colors.red600},inverseStyle:{color:e.colors.red500}},image:{Icon:R,style:{color:e.colors.neutral700},inverseStyle:{color:e.colors.neutral300}},video:{Icon:D,style:{color:e.colors.neutral700},inverseStyle:{color:e.colors.neutral300}},audio:{Icon:j,style:{color:e.colors.neutral700},inverseStyle:{color:e.colors.neutral300}},archive:{Icon:O,style:{color:e.colors.neutral700},inverseStyle:{color:e.colors.neutral300}}},Z={default:Y.default,xlsx:Y.excel,xlsm:Y.excel,xlsb:Y.excel,xltx:Y.excel,xls:Y.excel,xlt:Y.excel,doc:Y.word,docx:Y.word,docm:Y.word,dotx:Y.word,dotm:Y.word,docb:Y.word,pptx:Y.powerpoint,pptm:Y.powerpoint,ppt:Y.powerpoint,pdf:Y.pdf,png:Y.image,svg:Y.image,image:Y.image,audio:Y.audio,video:Y.video,zip:Y.archive},q=function(r){var n=r.file,o=r.isInverse,t=n.path,i=void 0===t?"":t,l=n.type,a=(void 0===l?"":l).split("/")[0],s=i.split(".").pop()||"default",c=Z[s]||Z[a]||Z.default;/*#__PURE__*/return H(c.Icon,{size:e.iconSizes.medium,style:o?c.inverseStyle:c.style})};function J(){return J=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},J.apply(null,arguments)}function Q(e,r){if(null==e)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(-1!==r.indexOf(o))continue;n[o]=e[o]}return n}function X(e,r){return r||(r=e.slice(0)),e.raw=r,e}var $,_,ee,re,ne,oe,te,ie,le,ae,se,ce,ue,de,pe=function(e,r,n){if(void 0===r&&(r=2),void 0===n&&(n="Bytes"),void 0!==e){if(0==e)return"0 "+n;var o=[n,"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(r))+" "+o[t]}},fe=["accept","file","isInverse","maxSize","minSize","onDeleteFile","onRemoveFile","testId","thumbnails"],me=["code"],ge=r.div($||($=X(["\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 r=e.file;return"url('"+("preview"in r&&r.preview)+"')"}),ve=r.div(_||(_=X(["\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"]))),he=function(e){var r=e.file,n=e.isInverse,o=e.theme,t=e.thumbnails;return r.errors?/*#__PURE__*/H(A,{color:n?o.colors.red500:o.colors.danger,size:24}):r.preview&&t&&r.type&&r.type.startsWith("image")?/*#__PURE__*/H(ge,{role:"img",file:r}):/*#__PURE__*/H(q,{isInverse:n,file:r})},be={marginRight:"12px",display:"flex"},ye=r.div(ee||(ee=X(["\n border-top: 1px solid\n ",";\n padding: 16px;\n font-size: ",";\n line-height: ",";\n"])),function(e){var r=e.theme;return e.isInverse?r.colors.neutral500:r.colors.neutral300},function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight}),xe=r(n)(re||(re=X(["\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}),ze=r(n)(ne||(ne=X(["\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}),Se=r(o)(oe||(oe=X(["\n background-color: none;\n border-color: ",";\n border-width: 1px;\n color: ",";\n margin: 10px 0;\n"])),function(e){var r=e.theme,n=e.isInverse;return e.file.errors?n?r.colors.red500:r.colors.danger:n?r.colors.neutral800:r.colors.neutral200},function(e){var r=e.theme;return e.isInverse?r.colors.neutral0:e.file.errors?r.colors.neutral700:r.colors.brand.navy}),Ie=r.span(te||(te=X(["\n display: block;\n\n > div {\n display: flex;\n align-self: center;\n margin-right: 12px;\n }\n"]))),we=r.span(ie||(ie=X(["\n display: block;\n"]))),Fe=/*#__PURE__*/E(function(e,r){var o,h=e.accept,b=e.file,y=e.isInverse,x=e.maxSize,z=e.minSize,S=e.onDeleteFile,I=e.onRemoveFile,w=e.thumbnails,F=Q(e,fe),k=N(t),R=P.useContext(i),D=l(y),j=U(/*#__PURE__*/H(C,{})),O=j[0],A=j[1],T=function(){I&&"function"==typeof I&&I(b)},E=function(){S&&"function"==typeof S&&S(b)},G=function(e){var r=e.status,n=void 0===r?"ready":r,o=U(!1),t=o[0],i=o[1];return V(function(){var e=!0;return setTimeout(function(){e&&i(!0)},1e3),function(){e=!1}},[n]),"error"===n||"ready"===n?/*#__PURE__*/H(ve,{children:/*#__PURE__*/H(p,{onClick:T,variant:f.link,color:m.subtle,"aria-label":R.dropzone.removeFile+" "+b.name,icon:/*#__PURE__*/H(C,{})})}):"pending"===n?/*#__PURE__*/H(ve,{children:/*#__PURE__*/H(g,{color:D?k.colors.brand.skyBlue:k.colors.primary})}):/*#__PURE__*/L(ve,{children:[/*#__PURE__*/H(v,{isOpen:!t,unmountOnExit:!0,fade:!0,children:/*#__PURE__*/H(B,{color:D?k.colors.green500:k.colors.success,style:{marginTop:"4px"}})}),/*#__PURE__*/H(v,{isOpen:t,unmountOnExit:!0,fade:!0,children:/*#__PURE__*/H(p,{onClick:E,variant:f.link,color:m.subtle,"aria-label":R.dropzone.deleteFile+" "+b.name,icon:/*#__PURE__*/H(M,{})})})]})};return V(function(){var e;A(/*#__PURE__*/H(G,{status:null==b||null==(e=b.processor)?void 0:e.status}))},[null==b||null==(o=b.processor)?void 0:o.status]),/*#__PURE__*/H(a.Provider,{value:{isInverse:D},children:/*#__PURE__*/L(Se,{borderRadius:s.small,cornerTreatment:c.all,isInverse:D,theme:k,file:b,"data-testid":e.testId,ref:r,role:b.errors?"alert":"",children:[/*#__PURE__*/L(xe,J({theme:k,behavior:u.container,alignItems:d.center},F,{children:[/*#__PURE__*/H(n,{behavior:u.item,alignItems:d.center,style:be,children:/*#__PURE__*/H(he,{file:b,isInverse:D,theme:k,thumbnails:w})}),/*#__PURE__*/H(ze,{xs:!0,behavior:u.item,theme:k,children:b.name}),b.processor&&"pending"===b.processor.status&&/*#__PURE__*/H(n,{role:"progressbar",style:{marginLeft:"auto"},behavior:u.item,children:b.processor.percent}),/*#__PURE__*/H(n,{behavior:u.item,children:O})]})),b.errors&&/*#__PURE__*/H(ye,{theme:k,isInverse:D,children:b.errors.slice(0,1).map(function(e){var r=e.code,n=function(e,r,n){var o=Array.isArray(r.accept)&&1===r.accept.length?r.accept[0]:r.accept,t=Array.isArray(o)?"one of "+o.join(", "):o;switch(e.code){case"file-too-large":return J({},e,{message:e.message+" "+pe(r.maxSize,2,n)+"."});case"file-too-small":return J({},e,{message:e.message+" "+pe(r.minSize,2,n)+"."});case"file-invalid-type":return J({},e,{message:e.message+": "+t});default:return e}}(J({code:r},Q(e,me),R.dropzone.errors[r]),{accept:h,minSize:z,maxSize:x},R.dropzone.bytes),o=n.header,t=n.message;/*#__PURE__*/return L(P.Fragment,{children:[/*#__PURE__*/H(Ie,{style:{color:D?k.colors.red500:k.colors.danger},children:void 0===o?"":o}),/*#__PURE__*/H(we,{children:t})]},r)})})]})})}),ke=["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"}(de||(de={}));var Re=function(e,r){return null!=e?e:r},De=r(n)(le||(le=X(["\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 r=e.theme;return e.noDrag?r.borderRadiusNone:r.borderRadiusSmall},function(e){var r=e.dragState,n=void 0===r?de.default:r,o=e.theme,t=e.isInverse;return e.noDrag?"0px":n===de.dragReject||n===de.error?(n===de.error?"1px":"2px")+" dashed "+function(e,r,n){return n?e===de.error?r.colors.red500:r.colors.red400:r.colors.danger}(n,o,t):n===de.dragActive?"2px dashed "+o.colors.blue500:n===de.dragAccept?"2px dashed "+o.colors.green500:"2px dashed "+(t?o.colors.neutral800:o.colors.neutral300)},function(e){var r=e.dragState;return(void 0===r?de.default:r)===de.error?"solid":"dashed"},function(e){var r=e.theme;return e.noDrag?"transparent":e.isInverse?K(.6,r.colors.neutral1200):r.colors.neutral100},function(e){return"border "+(e.noDrag?0:".24s")+" ease-in-out"}),je=r.span(ae||(ae=X(["\n color: ",";\n display: block;\n font-size: 14px;\n margin: -8px 0 16px 0;\n"])),function(e){var r=e.theme;return e.isInverse?r.colors.neutral500:r.colors.neutral700}),Oe=r.div(se||(se=X(["\n color: ",";\n margin: 0 0 24px 0;\n font-size: ",";\n line-height: ",";\n font-weight: 500;\n padding: ",";\n"])),function(e){var r=e.theme;return e.isInverse?r.colors.neutral0:r.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}),Ce=r.ul(ce||(ce=X(["\n list-style: none;\n padding: 0;\n"]))),Ae=r.li(ue||(ue=X([""]))),Be=/*#__PURE__*/P.forwardRef(function(e,r){var o=e.accept,s=e.buttonColor,c=void 0===s?m.primary:s,d=e.buttonText,p=e.containerStyle,g=e.disabled,v=e.dropzoneOptions,S=void 0===v?{multiple:!0}:v,I=e.helperMessage,w=e.id,F=e.inputSize,k=e.isInverse,R=e.isLabelVisuallyHidden,D=e.labelStyle,j=e.labelText,O=e.maxFiles,C=e.minFiles,A=e.maxSize,B=e.minSize,M=e.multiple,E=void 0===M||M,N=e.noDrag,U=void 0!==N&&N,V=e.onSendFile,K=e.onDeleteFile,Y=e.onRemoveFile,Z=e.sendFiles,q=void 0!==Z&&Z,X=e.testId,$=e.thumbnails,_=void 0===$||$,ee=Q(e,ke),re=P.useState([]),ne=re[0],oe=re[1],te=P.useState(null),ie=te[0],le=te[1],ae=P.useState(""),se=ae[0],ce=ae[1],ue=l(k),pe=P.useContext(t),fe=P.useContext(i),me=h(w),ge=h(me+"-helper"),ve=P.useRef(null),he=P.useCallback(function(e,r){var n=[].concat(e.map(function(e){return Object.assign(e,{preview:URL.createObjectURL(e)})}),r.map(function(e){return Object.assign(e.file,{errors:e.errors})}));if(oe(function(e){return[].concat(e,n)}),e.length>0){var o=e.map(function(e){return e.name}).join(", "),t=1===e.length?fe.dropzone.fileAdded.replace(/\{fileName\}/g,o):fe.dropzone.filesAdded.replace(/\{count\}/g,e.length.toString()).replace(/\{fileNames\}/g,o);ce(t)}ve.current&&ve.current.focus()},[fe]),be=W(J({noClick:!0,disabled:g,multiple:E,maxSize:A,minSize:B,accept:o,onDrop:he,noDrag:U},S)),ye=be.getInputProps,xe=be.getRootProps,ze=be.isDragAccept,Se=be.isDragActive,Ie=be.isDragReject,we=be.open,Be=be.inputRef;G(r,function(){return Be.current});var Me=ye({id:me}),Te=de.default;ie?Te=de.error:ze?Te=de.dragAccept:Ie?Te=de.dragReject:Se&&(Te=de.dragActive);var He=function(e){oe(function(r){return r.filter(function(r){return r!==e})}),Y&&"function"==typeof Y&&Y(e);var r=fe.dropzone.fileRemoved.replace(/\{fileName\}/g,e.name);ce(r),ve.current&&ve.current.focus()},Le=function(e){oe(function(r){return r.filter(function(r){return r!==e})}),K&&"function"==typeof K&&K(e);var r=fe.dropzone.fileDeleted.replace(/\{fileName\}/g,e.name);ce(r),ve.current&&ve.current.focus()},Pe=function(e){if(oe(function(r){return r.map(function(r){return r===e.file?Object.assign(r,{processor:J({},r.processor,{percent:e.percent+"%",status:"pending"})}):r})}),e.percent>0&&e.percent%25==0){var r=fe.dropzone.fileUploading.replace(/\{fileName\}/g,e.file.name).replace(/\{percent\}/g,e.percent.toString());ce(r)}},Ee=function(e){oe(function(r){return r.map(function(r){return r===e.file?Object.assign(r,{processor:J({},r.processor,{percent:"",status:"finished"})}):r})});var r=fe.dropzone.fileUploaded.replace(/\{fileName\}/g,e.file.name);ce(r)},Ne=function(e){oe(function(r){return r.map(function(r){return r===e.file?Object.assign(r,{errors:e.errors,processor:J({},r.processor,{status:"error"})}):r})})};return P.useEffect(function(){return function(){ne.forEach(function(e){return e.preview&&URL.revokeObjectURL(e.preview)})}},[ne]),P.useEffect(function(){var e=C&&ne.length<C,r=O&&ne.length>O,n=null;r?n="too-many-files":e&&(n="too-few-files"),le(function(e,r){if(null===e)return null;var n=fe.dropzone.errors[e];switch(e){case"too-many-files":return n.message+" "+r.maxFiles+" "+fe.dropzone.files+".";case"too-few-files":return n.message+" "+r.minFiles+" "+fe.dropzone.files+".";default:return n.message}}(n,{minFiles:C,maxFiles:O})),q&&ne.length>0&&!r&&!e&&oe(function(e){return e.map(function(e){return e.errors||e.processor||!V||V({file:e,onError:Ne,onFinish:Ee,onProgress:Pe}),e})})},[q,ne.length,V,O,C,fe.dropzone.errors,fe.dropzone.files]),/*#__PURE__*/L(a.Provider,{value:{isInverse:ue},children:[/*#__PURE__*/L(b,{actionable:!1,containerStyle:p,errorMessage:ie,fieldId:me,inputSize:F,isInverse:ue,isLabelVisuallyHidden:R,labelStyle:J({color:ue?pe.colors.neutral0:pe.colors.brand.navy},D),labelText:j,messageStyle:{minHeight:0},"data-testid":X,children:[/*#__PURE__*/H(je,{id:ge,theme:pe,isInverse:ue,children:I}),/*#__PURE__*/L(De,J({behavior:u.container,dragState:Te,isInverse:ue,noDrag:U,theme:pe},xe(),ee,{testId:X,tabIndex:-1,children:[/*#__PURE__*/H("input",{ref:Be,type:Me.type,accept:Me.accept,autoComplete:Me.autoComplete,id:Me.id,multiple:Me.multiple,onChange:Me.onChange,onClick:Me.onClick,style:Me.style,tabIndex:Me.tabIndex,"data-testid":"file-input"}),U?/*#__PURE__*/H(n,{xs:!0,behavior:u.item,children:/*#__PURE__*/H(y,{color:c,disabled:g,isInverse:ue,onClick:we,style:{margin:0},ref:ve,"aria-describedby":I?ge:void 0,children:Re(d,fe.dropzone.browseFiles)})}):/*#__PURE__*/L(n,{behavior:u.item,children:[/*#__PURE__*/H(T,{"aria-hidden":"true",color:ue?pe.colors.neutral0:pe.colors.neutral700,size:48}),/*#__PURE__*/H(Oe,{isInverse:ue,theme:pe,children:fe.dropzone.dragMessage}),/*#__PURE__*/H(y,{color:c,disabled:g,isInverse:ue,onClick:we,style:{margin:0},variant:f.solid,ref:ve,"aria-describedby":I?ge:void 0,children:Re(d,fe.dropzone.browseFiles)})]})]}))]}),/*#__PURE__*/H(Ce,{children:ne.map(function(e){/*#__PURE__*/return H(Ae,{children:/*#__PURE__*/H(Fe,{accept:o,file:e,isInverse:ue,maxSize:A,minSize:B,onDeleteFile:Le,onRemoveFile:He,thumbnails:_})},e.name)})}),/*#__PURE__*/H(x,{children:/*#__PURE__*/H(z,{children:se})})]})});export{Be as Dropzone,q as FileIcon};
|
|
2
2
|
//# sourceMappingURL=fileuploader.modern.module.js.map
|