@react-magma/dropzone 16.0.0-next.1 → 16.0.0-v6-next.2
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 +85 -0
- package/dist/fileuploader.modern.js.map +1 -0
- package/dist/fileuploader.modern.module.js +1 -1
- package/dist/fileuploader.modern.module.js.map +1 -1
- package/dist/fileuploader.umd.js +1 -1
- package/dist/fileuploader.umd.js.map +1 -1
- package/dist/src/src/components/dropzone/Dropzone.d.ts +110 -101
- package/dist/src/src/components/dropzone/Dropzone.stories.d.ts +64 -0
- package/dist/src/src/components/dropzone/Dropzone.test.d.ts +1 -1
- package/dist/src/src/components/dropzone/FileIcon.d.ts +8 -7
- package/dist/src/src/components/dropzone/FilePreview.d.ts +15 -15
- package/dist/src/src/components/dropzone/Preview.d.ts +18 -18
- package/dist/src/src/components/dropzone/index.d.ts +4 -4
- package/dist/src/src/components/dropzone/utils.d.ts +1 -1
- package/dist/src/src/index.d.ts +1 -1
- package/package.json +15 -18
- package/src/components/dropzone/Dropzone.stories.tsx +16 -5
- package/src/components/dropzone/Dropzone.test.js +25 -6
- package/src/components/dropzone/Dropzone.tsx +70 -25
- package/src/components/dropzone/Preview.tsx +41 -14
- package/src/components/dropzone/utils.ts +0 -1
- package/dist/fileuploader.modern.mjs +0 -85
- package/dist/fileuploader.modern.mjs.map +0 -1
|
@@ -0,0 +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,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,EACC,CAAA,cAAY,OACZxU,MACEiD,GAAY0C,GAAMzF,OAAOgH,SAAWvB,GAAMzF,OAAOC,WAEnDsD,KAAM,kBAERD,EAACmL,GAAO,CAAC1L,UAAWA,GAAW0C,MAAOA,GAAM6D,SACzCjB,GAAKyB,SAASyK,2BAEjBjR,EAAC6Q,EAAM,CACLrU,MAAOmP,EACPE,SAAUA,EACVpM,UAAWA,GACXyG,QAASyI,GACTpS,MAAO,CAAEuU,OAAQ,GACjB3K,QAASC,EAAc8K,MACvB/M,IAAKgJ,GACL,mBAAkBnB,EAAgBkB,QAAkB1M,EAAUwF,SAE7DiE,GAAoBC,EAAYnF,GAAKyB,SAASuK,sCAMzD/Q,EAACsL,GAAWtF,CAAAA,SACT2G,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,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 d,FlexAlignItems as u,IconButton as p,ButtonVariant as f,ButtonColor as m,Spinner as g,Transition as v,useGenerateId as h,FormFieldContainer as y,Button as b,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 A,ErrorIcon as C,CheckCircleIcon as B,DeleteIcon as M,CloudUploadIcon as H}from"react-magma-icons";import{jsx as L,jsxs as P}from"react/jsx-runtime";import E,{forwardRef as N,useContext as T,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 L(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,de,ue,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={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}),be=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}),xe=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}),ze=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}),Se=r.span(te||(te=X(["\n display: block;\n\n > div {\n display: flex;\n align-self: center;\n margin-right: 12px;\n }\n"]))),Ie=r.span(ie||(ie=X(["\n display: block;\n"]))),we=/*#__PURE__*/N(function(e,r){var o,h=e.accept,y=e.file,b=e.isInverse,x=e.maxSize,z=e.minSize,S=e.onDeleteFile,I=e.onRemoveFile,w=e.thumbnails,F=Q(e,fe),k=T(t),R=E.useContext(i),D=l(b),j=U(/*#__PURE__*/L(A,{})),O=j[0],H=j[1],N=function(){I&&"function"==typeof I&&I(y)},G=function(){S&&"function"==typeof S&&S(y)},K=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__*/L(ve,{children:/*#__PURE__*/L(p,{onClick:N,variant:f.link,color:m.subtle,"aria-label":R.dropzone.removeFile+" "+y.name,icon:/*#__PURE__*/L(A,{})})}):"pending"===n?/*#__PURE__*/L(ve,{children:/*#__PURE__*/L(g,{color:D?k.colors.brand.skyBlue:k.colors.primary})}):/*#__PURE__*/P(ve,{children:[/*#__PURE__*/L(v,{isOpen:!t,unmountOnExit:!0,fade:!0,children:/*#__PURE__*/L(B,{color:D?k.colors.green500:k.colors.success,style:{marginTop:"4px"}})}),/*#__PURE__*/L(v,{isOpen:t,unmountOnExit:!0,fade:!0,children:/*#__PURE__*/L(p,{onClick:G,variant:f.link,color:m.subtle,"aria-label":R.dropzone.deleteFile+" "+y.name,icon:/*#__PURE__*/L(M,{})})})]})};return V(function(){var e;H(/*#__PURE__*/L(K,{status:null==y||null==(e=y.processor)?void 0:e.status}))},[null==y||null==(o=y.processor)?void 0:o.status]),/*#__PURE__*/L(a.Provider,{value:{isInverse:D},children:/*#__PURE__*/P(ze,{borderRadius:s.small,cornerTreatment:c.all,isInverse:D,theme:k,file:y,"data-testid":e.testId,ref:r,role:y.errors?"alert":"",children:[/*#__PURE__*/P(be,J({theme:k,behavior:d.container,alignItems:u.center},F,{children:[/*#__PURE__*/L(n,{behavior:d.item,alignItems:u.center,style:he,children:y.errors?/*#__PURE__*/L(C,{color:D?k.colors.red500:k.colors.danger,size:24}):y.preview&&w&&y.type&&y.type.startsWith("image")?/*#__PURE__*/L(ge,{role:"img",file:y}):/*#__PURE__*/L(q,{isInverse:D,file:y})}),/*#__PURE__*/L(xe,{xs:!0,behavior:d.item,theme:k,children:y.name}),y.processor&&"pending"===y.processor.status&&/*#__PURE__*/L(n,{role:"progressbar",style:{marginLeft:"auto"},behavior:d.item,children:y.processor.percent}),/*#__PURE__*/L(n,{behavior:d.item,children:O})]})),y.errors&&/*#__PURE__*/L(ye,{theme:k,isInverse:D,children:y.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 P(E.Fragment,{children:[/*#__PURE__*/L(Se,{style:{color:D?k.colors.red500:k.colors.danger},children:void 0===o?"":o}),/*#__PURE__*/L(Ie,{children:t})]},r)})})]})})}),Fe=["accept","containerStyle","disabled","dropzoneOptions","helperMessage","id","inputSize","isInverse","isLabelVisuallyHidden","labelStyle","labelText","maxFiles","minFiles","maxSize","minSize","multiple","noDrag","onSendFile","onDeleteFile","onRemoveFile","sendFiles","testId","thumbnails"];!function(e){e.error="error",e.dragAccept="dragAccept",e.dragReject="dragReject",e.dragActive="dragActive",e.default="default"}(ue||(ue={}));var ke=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?ue.default:r,o=e.theme,t=e.isInverse;return e.noDrag?"0px":n===ue.dragReject||n===ue.error?t?(n===ue.error?"1px":"2px")+" dashed "+(n===ue.error?o.colors.red500:o.colors.red400):(n===ue.error?"1px":"2px")+" dashed "+o.colors.danger:n===ue.dragActive?"2px dashed "+o.colors.blue500:n===ue.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?ue.default:r)===ue.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"}),Re=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}),De=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}),je=r.ul(ce||(ce=X(["\n list-style: none;\n padding: 0;\n"]))),Oe=r.li(de||(de=X([""]))),Ae=/*#__PURE__*/E.forwardRef(function(e,r){var o=e.accept,s=e.containerStyle,c=e.disabled,u=e.dropzoneOptions,p=void 0===u?{multiple:!0}:u,g=e.helperMessage,v=e.id,S=e.inputSize,I=e.isInverse,w=e.isLabelVisuallyHidden,F=e.labelStyle,k=e.labelText,R=e.maxFiles,D=e.minFiles,j=e.maxSize,O=e.minSize,A=e.multiple,C=void 0===A||A,B=e.noDrag,M=void 0!==B&&B,N=e.onSendFile,T=e.onDeleteFile,U=e.onRemoveFile,V=e.sendFiles,K=void 0!==V&&V,Y=e.testId,Z=e.thumbnails,q=void 0===Z||Z,X=Q(e,Fe),$=E.useState([]),_=$[0],ee=$[1],re=E.useState(null),ne=re[0],oe=re[1],te=E.useState(""),ie=te[0],le=te[1],ae=l(I),se=E.useContext(t),ce=E.useContext(i),de=h(v),pe=h(de+"-helper"),fe=E.useRef(null),me=E.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(ee(function(e){return[].concat(e,n)}),e.length>0){var o=e.map(function(e){return e.name}).join(", "),t=1===e.length?ce.dropzone.fileAdded.replace(/\{fileName\}/g,o):ce.dropzone.filesAdded.replace(/\{count\}/g,e.length.toString()).replace(/\{fileNames\}/g,o);le(t)}fe.current&&fe.current.focus()},[ce]),ge=W(J({noClick:!0,disabled:c,multiple:C,maxSize:j,minSize:O,accept:o,onDrop:me,noDrag:M},p)),ve=ge.getInputProps,he=ge.getRootProps,ye=ge.isDragAccept,be=ge.isDragActive,xe=ge.isDragReject,ze=ge.open,Se=ge.inputRef;G(r,function(){return Se.current});var Ie=ve({id:de}),Ae=ue.default;ne?Ae=ue.error:ye?Ae=ue.dragAccept:xe?Ae=ue.dragReject:be&&(Ae=ue.dragActive);var Ce=function(e){ee(function(r){return r.filter(function(r){return r!==e})}),U&&"function"==typeof U&&U(e);var r=ce.dropzone.fileRemoved.replace(/\{fileName\}/g,e.name);le(r),fe.current&&fe.current.focus()},Be=function(e){ee(function(r){return r.filter(function(r){return r!==e})}),T&&"function"==typeof T&&T(e);var r=ce.dropzone.fileDeleted.replace(/\{fileName\}/g,e.name);le(r),fe.current&&fe.current.focus()},Me=function(e){if(ee(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=ce.dropzone.fileUploading.replace(/\{fileName\}/g,e.file.name).replace(/\{percent\}/g,e.percent.toString());le(r)}},He=function(e){ee(function(r){return r.map(function(r){return r===e.file?Object.assign(r,{processor:J({},r.processor,{percent:"",status:"finished"})}):r})});var r=ce.dropzone.fileUploaded.replace(/\{fileName\}/g,e.file.name);le(r)},Le=function(e){ee(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 E.useEffect(function(){return function(){_.forEach(function(e){return e.preview&&URL.revokeObjectURL(e.preview)})}},[_]),E.useEffect(function(){var e=D&&_.length<D,r=R&&_.length>R,n=null;r?n="too-many-files":e&&(n="too-few-files"),oe(function(e,r){if(null===e)return null;var n=ce.dropzone.errors[e];switch(e){case"too-many-files":return n.message+" "+r.maxFiles+" "+ce.dropzone.files+".";case"too-few-files":return n.message+" "+r.minFiles+" "+ce.dropzone.files+".";default:return n.message}}(n,{minFiles:D,maxFiles:R})),K&&_.length>0&&!r&&!e&&ee(function(e){return e.map(function(e){return e.errors||e.processor||!N||N({file:e,onError:Le,onFinish:He,onProgress:Me}),e})})},[K,_.length,N,R,D,ce.dropzone.errors,ce.dropzone.files]),/*#__PURE__*/P(a.Provider,{value:{isInverse:ae},children:[/*#__PURE__*/P(y,{actionable:!1,containerStyle:s,errorMessage:ne,fieldId:de,inputSize:S,isInverse:ae,isLabelVisuallyHidden:w,labelStyle:J({color:ae?se.colors.neutral0:se.colors.brand.navy},F),labelText:k,messageStyle:{minHeight:0},"data-testid":Y,children:[/*#__PURE__*/L(Re,{id:pe,theme:se,isInverse:ae,children:g}),/*#__PURE__*/P(ke,J({behavior:d.container,dragState:Ae,isInverse:ae,noDrag:M,theme:se},he(),X,{testId:Y,tabIndex:-1,children:[/*#__PURE__*/L("input",{ref:Se,type:Ie.type,accept:Ie.accept,autoComplete:Ie.autoComplete,id:Ie.id,multiple:Ie.multiple,onChange:Ie.onChange,onClick:Ie.onClick,style:Ie.style,tabIndex:Ie.tabIndex,"data-testid":"file-input"}),M?/*#__PURE__*/L(n,{xs:!0,behavior:d.item,children:/*#__PURE__*/L(b,{color:m.primary,disabled:c,isInverse:ae,onClick:ze,style:{margin:0},ref:fe,"aria-describedby":g?pe:void 0,children:ce.dropzone.browseFiles})}):/*#__PURE__*/P(n,{behavior:d.item,children:[/*#__PURE__*/L(H,{"aria-hidden":"true",color:ae?se.colors.neutral0:se.colors.neutral700,size:48}),/*#__PURE__*/L(De,{isInverse:ae,theme:se,children:ce.dropzone.dragMessage}),/*#__PURE__*/L(b,{color:m.primary,disabled:c,isInverse:ae,onClick:ze,style:{margin:0},variant:f.solid,ref:fe,"aria-describedby":g?pe:void 0,children:ce.dropzone.browseFiles})]})]}))]}),/*#__PURE__*/L(je,{children:_.map(function(e){/*#__PURE__*/return L(Oe,{children:/*#__PURE__*/L(we,{accept:o,file:e,isInverse:ae,maxSize:j,minSize:O,onDeleteFile:Be,onRemoveFile:Ce,thumbnails:q})},e.name)})}),/*#__PURE__*/L(x,{children:/*#__PURE__*/L(z,{children:ie})})]})});export{Ae 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{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};
|
|
2
2
|
//# sourceMappingURL=fileuploader.modern.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileuploader.modern.module.js","sources":["../src/components/dropzone/FileIcon.tsx","../src/components/dropzone/utils.ts","../src/components/dropzone/Dropzone.tsx","../src/components/dropzone/Preview.tsx"],"sourcesContent":["import React from 'react';\n\nimport { magma } from 'react-magma-dom';\nimport {\n InsertDriveFileIcon,\n ImageIcon,\n AudiotrackIcon,\n VideocamIcon,\n FileExcelIcon,\n FilePdfIcon,\n FilePowerpointIcon,\n FileWordIcon,\n FileZipIcon,\n IconProps,\n} from 'react-magma-icons';\n\nimport { FilePreview } from './FilePreview';\n\nexport interface FileIconProps extends IconProps {\n file: FilePreview;\n isInverse?: boolean;\n}\n\nconst icons = {\n default: {\n Icon: InsertDriveFileIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n word: {\n Icon: FileWordIcon,\n style: {\n color: magma.colors.blue500,\n },\n inverseStyle: {\n color: magma.colors.blue500,\n },\n },\n excel: {\n Icon: FileExcelIcon,\n style: {\n color: magma.colors.green500,\n },\n inverseStyle: {\n color: magma.colors.green500,\n },\n },\n powerpoint: {\n Icon: FilePowerpointIcon,\n style: {\n color: magma.colors.tangerine600,\n },\n inverseStyle: {\n color: magma.colors.tangerine500,\n },\n },\n pdf: {\n Icon: FilePdfIcon,\n style: {\n color: magma.colors.red600,\n },\n inverseStyle: {\n color: magma.colors.red500,\n },\n },\n image: {\n Icon: ImageIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n video: {\n Icon: VideocamIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n audio: {\n Icon: AudiotrackIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n archive: {\n Icon: FileZipIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n};\n\nconst iconMapping: {\n [key: string]: {\n Icon: any;\n style: React.CSSProperties;\n inverseStyle: React.CSSProperties;\n };\n} = {\n default: icons.default,\n xlsx: icons.excel,\n xlsm: icons.excel,\n xlsb: icons.excel,\n xltx: icons.excel,\n xls: icons.excel,\n xlt: icons.excel,\n doc: icons.word,\n docx: icons.word,\n docm: icons.word,\n dotx: icons.word,\n dotm: icons.word,\n docb: icons.word,\n pptx: icons.powerpoint,\n pptm: icons.powerpoint,\n ppt: icons.powerpoint,\n pdf: icons.pdf,\n png: icons.image,\n svg: icons.image,\n image: icons.image,\n audio: icons.audio,\n video: icons.video,\n zip: icons.archive,\n};\n\nexport const FileIcon = ({ file, isInverse }: FileIconProps) => {\n const { path = '', type = '' } = file;\n const category = type.split('/')[0];\n const extension = path.split('.').pop() || 'default';\n const { Icon, style, inverseStyle } =\n iconMapping[extension] || iconMapping[category] || iconMapping.default;\n\n return (\n <Icon\n size={magma.iconSizes.medium}\n style={isInverse ? inverseStyle : style}\n />\n );\n};\n","export const formatFileSize = (\n bytes: number | undefined,\n decimalPoint = 2,\n bytesLabel = 'Bytes'\n) => {\n if (bytes === undefined) return;\n if (bytes == 0) return `0 ${bytesLabel}`;\n const k = 1024;\n const sizes = [bytesLabel, 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n\n return (\n parseFloat((bytes / Math.pow(k, i)).toFixed(decimalPoint)) + ' ' + sizes[i]\n );\n};\n","/* eslint-disable no-empty-pattern */\n/**\n * HELPFUL NOTE!\n * SINCE THIS PACKAGE USES `FILE` WE MUST USE `Object.assign` IN LIEU OF SPREADING\n * `{...file}` WILL NOT COPY ALL OF THE FILE PROPERTIES\n */\n\nimport React, { useImperativeHandle } from 'react';\n\nimport { transparentize } from 'polished';\nimport {\n useDropzone,\n DropzoneOptions,\n DropzoneRootProps,\n FileRejection,\n} from 'react-dropzone';\nimport {\n Button,\n ButtonColor,\n ButtonVariant,\n Flex,\n FlexBehavior,\n FlexProps,\n FormFieldContainer,\n FormFieldContainerBaseProps,\n I18nContext,\n I18nInterface,\n InverseContext,\n ThemeContext,\n ThemeInterface,\n useGenerateId,\n useIsInverse,\n styled,\n Announce,\n VisuallyHidden,\n} from 'react-magma-dom';\nimport { CloudUploadIcon } from 'react-magma-icons';\n\nimport { FilePreview, FileError } from './FilePreview';\nimport { Preview } from './Preview';\n\nexport interface OnSendFileProps {\n file: FilePreview;\n onError?: ({}: { errors: FileError[]; file: FilePreview }) => void;\n onFinish?: ({}: { file: FilePreview }) => void;\n onProgress?: ({}: { percent: number; file: FilePreview }) => void;\n}\n\nenum DragState {\n error = 'error',\n dragAccept = 'dragAccept',\n dragReject = 'dragReject',\n dragActive = 'dragActive',\n default = 'default',\n}\n\n// NOTE: These props are manually copied to dropzone.mdx\nexport interface DropzoneProps\n extends Omit<FormFieldContainerBaseProps, 'fieldId' | 'errorMessage'> {\n /**\n * Set accepted file types. See https://github.com/okonet/attr-accept for more information. Keep in mind that mime type determination is not reliable across platforms. CSV files, for example, are reported as text/plain under macOS but as application/vnd.ms-excel under Windows. In some cases there might not be a mime type set at all. See: https://github.com/react-dropzone/react-dropzone/issues/276\n */\n accept?: string | string[];\n /**\n * Enable/Disable the input\n */\n disabled?: boolean;\n /**\n * Additional props to pass to the dropzone, see https://react-dropzone.js.org/#src\n */\n dropzoneOptions?: Partial<Omit<DropzoneOptions, 'onDrop'>>;\n /**\n * Content of the helper message.\n */\n helperMessage?: string;\n /**\n * @internal\n */\n id?: string;\n /**\n * Maximum accepted number of files The default value is 0 which means there is no limitation to how many files are accepted.\n * @default 0\n */\n maxFiles?: number;\n /**\n * Minimum accepted number of files.\n */\n minFiles?: number;\n /**\n * Maximum file size (in bytes)\n * @default Infinity\n */\n maxSize?: number;\n /**\n * Minimum file size (in bytes)\n * @default 0\n */\n minSize?: number;\n /**\n * Allow drag 'n' drop (or selection from the file dialog) of multiple files.\n * @default true\n */\n multiple?: boolean;\n /**\n * If true, disables drag 'n' drop\n * @default false\n */\n noDrag?: boolean;\n /**\n * Callback for when a file is deleted\n */\n onDeleteFile?: (file: FilePreview) => void;\n /**\n * Callback for when a file is deleted\n */\n onRemoveFile?: (file: FilePreview) => void;\n /**\n * Callback for when a file is added to the preview list via dropping or selecting. Will be ran on new files when `sendFiles` is true.\n */\n onSendFile?: (props: OnSendFileProps) => void;\n /**\n * Run `onSendFile` on any new files. Delay processing by setting to `false` until processing is desired.\n * @default false\n */\n sendFiles?: boolean;\n /**\n * @internal\n */\n testId?: string;\n /**\n * Show thumbnails for images in lieu of the file icon.\n * @default true\n */\n thumbnails?: boolean;\n}\n\nconst 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: ${({ dragState = DragState.default, noDrag, theme, isInverse }) =>\n noDrag\n ? `0px`\n : dragState === DragState.dragReject || dragState === DragState.error\n ? isInverse\n ? `${dragState === DragState.error ? '1px' : '2px'} dashed ${\n dragState === DragState.error\n ? theme.colors.red500\n : theme.colors.red400\n }`\n : `${dragState === DragState.error ? '1px' : '2px'} dashed ${\n theme.colors.danger\n }`\n : dragState === DragState.dragActive\n ? `2px dashed ${theme.colors.blue500}`\n : dragState === DragState.dragAccept\n ? `2px dashed ${theme.colors.green500}`\n : `2px dashed ${\n isInverse ? theme.colors.neutral800 : theme.colors.neutral300\n }`};\n\n border-style: ${({ dragState = DragState.default }) =>\n dragState === DragState.error ? 'solid' : 'dashed'};\n background-color: ${({ theme, noDrag, isInverse }) =>\n noDrag\n ? 'transparent'\n : isInverse\n ? transparentize(0.6, theme.colors.neutral1200)\n : theme.colors.neutral100};\n outline: none;\n transition: ${({ noDrag }) => `border ${noDrag ? 0 : '.24s'} ease-in-out`};\n`;\n\nconst HelperMessage = styled.span<{ isInverse?: boolean }>`\n color: ${({ theme, isInverse }) =>\n isInverse ? theme.colors.neutral500 : theme.colors.neutral700};\n display: block;\n font-size: 14px;\n margin: -8px 0 16px 0;\n`;\n\nconst Wrapper = styled.div<{ isInverse?: boolean }>`\n color: ${({ theme, isInverse }) =>\n isInverse ? theme.colors.neutral0 : theme.colors.brand.navy};\n margin: 0 0 24px 0;\n font-size: ${({ theme }) => theme.typeScale.size02.fontSize};\n line-height: ${({ theme }) => theme.typeScale.size02.lineHeight};\n font-weight: 500;\n padding: ${({ theme }) => theme.spaceScale.spacing01};\n`;\n\nconst PreviewList = styled.ul`\n list-style: none;\n padding: 0;\n`;\n\nconst PreviewItem = styled.li``;\n\nexport const Dropzone = React.forwardRef<HTMLInputElement, DropzoneProps>(\n (props, ref) => {\n const {\n accept,\n containerStyle,\n disabled,\n\n dropzoneOptions = {\n multiple: true,\n },\n helperMessage,\n id: defaultId,\n inputSize,\n isInverse: isInverseProp,\n isLabelVisuallyHidden,\n labelStyle,\n labelText,\n maxFiles,\n minFiles,\n maxSize,\n minSize,\n multiple = true,\n noDrag = false,\n onSendFile,\n onDeleteFile,\n onRemoveFile,\n sendFiles = false,\n testId,\n thumbnails = true,\n ...rest\n } = props;\n\n const [files, setFiles] = React.useState<FilePreview[]>([]);\n const [errorMessage, setErrorMessage] = React.useState<string | null>(null);\n const [announcement, setAnnouncement] = React.useState<string>('');\n\n const isInverse = useIsInverse(isInverseProp);\n const theme: ThemeInterface = React.useContext(ThemeContext);\n const i18n: I18nInterface = React.useContext(I18nContext);\n const id = useGenerateId(defaultId);\n const helperMessageId = useGenerateId(`${id}-helper`);\n\n const browseFileButtonRef = React.useRef<HTMLButtonElement>(null);\n\n const onDrop = React.useCallback(\n (acceptedFiles: FilePreview[], rejectedFiles: FileRejection[]) => {\n const newFiles = [\n ...acceptedFiles.map((file: FilePreview) =>\n Object.assign(file, {\n preview: URL.createObjectURL(file),\n })\n ),\n ...rejectedFiles.map(\n ({ file, errors }: { file: FilePreview; errors: FileError[] }) =>\n Object.assign(file, {\n errors,\n })\n ),\n ];\n\n setFiles((prevFiles: FilePreview[]) => [...prevFiles, ...newFiles]);\n\n if (acceptedFiles.length > 0) {\n const fileNames = acceptedFiles.map(file => file.name).join(', ');\n const message =\n acceptedFiles.length === 1\n ? i18n.dropzone.fileAdded.replace(/\\{fileName\\}/g, fileNames)\n : i18n.dropzone.filesAdded\n .replace(/\\{count\\}/g, acceptedFiles.length.toString())\n .replace(/\\{fileNames\\}/g, fileNames);\n\n setAnnouncement(message);\n }\n\n browseFileButtonRef.current && browseFileButtonRef.current.focus();\n },\n [i18n]\n );\n\n const {\n getInputProps,\n getRootProps,\n isDragAccept,\n isDragActive,\n isDragReject,\n open,\n inputRef,\n } = useDropzone({\n noClick: true,\n disabled,\n multiple,\n maxSize,\n minSize,\n accept,\n onDrop,\n noDrag,\n ...dropzoneOptions,\n });\n\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(\n ref,\n () => inputRef.current\n );\n\n const inputProps = getInputProps({ id });\n\n let dragState = DragState.default;\n\n if (errorMessage) {\n dragState = DragState.error;\n } else if (isDragAccept) {\n dragState = DragState.dragAccept;\n } else if (isDragReject) {\n dragState = DragState.dragReject;\n } else if (isDragActive) {\n dragState = DragState.dragActive;\n }\n\n const handleRemoveFile = (removedFile: FilePreview) => {\n setFiles(prevFiles => prevFiles.filter(file => file !== removedFile));\n\n if (onRemoveFile && typeof onRemoveFile === 'function') {\n onRemoveFile(removedFile);\n }\n\n const message = i18n.dropzone.fileRemoved.replace(\n /\\{fileName\\}/g,\n removedFile.name\n );\n\n setAnnouncement(message);\n\n browseFileButtonRef.current && browseFileButtonRef.current.focus();\n };\n\n const handleDeleteFile = (removedFile: FilePreview) => {\n setFiles(prevFiles => prevFiles.filter(file => file !== removedFile));\n\n if (onDeleteFile && typeof onDeleteFile === 'function') {\n onDeleteFile(removedFile);\n }\n\n const message = i18n.dropzone.fileDeleted.replace(\n /\\{fileName\\}/g,\n removedFile.name\n );\n\n setAnnouncement(message);\n\n browseFileButtonRef.current && browseFileButtonRef.current.focus();\n };\n\n const setProgress = (progressProps: {\n percent: number;\n file: FilePreview;\n }) => {\n setFiles(prevFiles =>\n prevFiles.map(file =>\n file === progressProps.file\n ? Object.assign(file, {\n processor: {\n ...file.processor,\n percent: `${progressProps.percent}%`,\n status: 'pending',\n },\n })\n : file\n )\n );\n\n // Announce progress every 25% to avoid too many announcements\n if (progressProps.percent > 0 && progressProps.percent % 25 === 0) {\n const message = i18n.dropzone.fileUploading\n .replace(/\\{fileName\\}/g, progressProps.file.name)\n .replace(/\\{percent\\}/g, progressProps.percent.toString());\n\n setAnnouncement(message);\n }\n };\n\n const setFinished = (finishedProps: { file: FilePreview }) => {\n setFiles(prevFiles =>\n prevFiles.map(file =>\n file === finishedProps.file\n ? Object.assign(file, {\n processor: {\n ...file.processor,\n percent: '',\n status: 'finished',\n },\n })\n : file\n )\n );\n\n // Announce successful upload\n const message = i18n.dropzone.fileUploaded.replace(\n /\\{fileName\\}/g,\n finishedProps.file.name\n );\n\n setAnnouncement(message);\n };\n\n const setError = (errorProps: {\n errors: FileError[];\n file: FilePreview;\n }) => {\n setFiles(prevFiles =>\n prevFiles.map(file =>\n file === errorProps.file\n ? Object.assign(file, {\n errors: errorProps.errors,\n processor: { ...file.processor, status: 'error' },\n })\n : file\n )\n );\n };\n\n React.useEffect(\n () => () => {\n files.forEach(\n file => file.preview && URL.revokeObjectURL(file.preview)\n );\n },\n [files]\n );\n\n React.useEffect(() => {\n const formatError = (\n code: string | null,\n constraints: { maxFiles?: number; minFiles?: number }\n ) => {\n if (code === null) return null;\n const error = i18n.dropzone.errors[code];\n\n switch (code) {\n case 'too-many-files':\n return `${error.message} ${constraints.maxFiles} ${i18n.dropzone.files}.`;\n case 'too-few-files':\n return `${error.message} ${constraints.minFiles} ${i18n.dropzone.files}.`;\n default:\n return error.message;\n }\n };\n\n const minFileError = minFiles && files.length < minFiles;\n const maxFileError = maxFiles && files.length > maxFiles;\n\n let errorCode: string | null = null;\n\n if (maxFileError) {\n errorCode = 'too-many-files';\n } else if (minFileError) {\n errorCode = 'too-few-files';\n }\n\n setErrorMessage(formatError(errorCode, { minFiles, maxFiles }));\n\n if (sendFiles && files.length > 0 && !maxFileError && !minFileError) {\n setFiles((prevFiles: FilePreview[]) => {\n return prevFiles.map((file: FilePreview) => {\n if (!file.errors && !file.processor && onSendFile) {\n onSendFile({\n file,\n onError: setError,\n onFinish: setFinished,\n onProgress: setProgress,\n });\n }\n\n return file;\n });\n });\n }\n }, [\n sendFiles,\n files.length,\n onSendFile,\n maxFiles,\n minFiles,\n i18n.dropzone.errors,\n i18n.dropzone.files,\n ]);\n\n return (\n <InverseContext.Provider value={{ isInverse }}>\n <FormFieldContainer\n actionable={false}\n containerStyle={containerStyle}\n errorMessage={errorMessage}\n fieldId={id}\n inputSize={inputSize}\n isInverse={isInverse}\n isLabelVisuallyHidden={isLabelVisuallyHidden}\n labelStyle={{\n color: isInverse ? theme.colors.neutral0 : theme.colors.brand.navy,\n ...labelStyle,\n }}\n labelText={labelText}\n messageStyle={{ minHeight: 0 }}\n data-testid={testId}\n >\n <HelperMessage\n id={helperMessageId}\n theme={theme}\n isInverse={isInverse}\n >\n {helperMessage}\n </HelperMessage>\n <Container\n behavior={FlexBehavior.container}\n dragState={dragState}\n isInverse={isInverse}\n noDrag={noDrag}\n theme={theme}\n {...getRootProps()}\n {...rest}\n testId={testId}\n tabIndex={-1}\n >\n <input\n ref={inputRef}\n type={inputProps.type}\n accept={inputProps.accept}\n autoComplete={inputProps.autoComplete}\n id={inputProps.id}\n multiple={inputProps.multiple}\n onChange={inputProps.onChange}\n onClick={inputProps.onClick}\n style={inputProps.style}\n tabIndex={inputProps.tabIndex}\n data-testid=\"file-input\"\n />\n {noDrag ? (\n <Flex xs behavior={FlexBehavior.item}>\n <Button\n color={ButtonColor.primary}\n disabled={disabled}\n isInverse={isInverse}\n onClick={open}\n style={{ margin: 0 }}\n ref={browseFileButtonRef}\n aria-describedby={helperMessage ? helperMessageId : undefined}\n >\n {i18n.dropzone.browseFiles}\n </Button>\n </Flex>\n ) : (\n <Flex behavior={FlexBehavior.item}>\n <CloudUploadIcon\n aria-hidden=\"true\"\n color={\n isInverse ? theme.colors.neutral0 : theme.colors.neutral700\n }\n size={48}\n />\n <Wrapper isInverse={isInverse} theme={theme}>\n {i18n.dropzone.dragMessage}\n </Wrapper>\n <Button\n color={ButtonColor.primary}\n disabled={disabled}\n isInverse={isInverse}\n onClick={open}\n style={{ margin: 0 }}\n variant={ButtonVariant.solid}\n ref={browseFileButtonRef}\n aria-describedby={helperMessage ? helperMessageId : undefined}\n >\n {i18n.dropzone.browseFiles}\n </Button>\n </Flex>\n )}\n </Container>\n </FormFieldContainer>\n <PreviewList>\n {files.map((file: FilePreview) => (\n <PreviewItem key={file.name}>\n <Preview\n accept={accept}\n file={file}\n isInverse={isInverse}\n maxSize={maxSize}\n minSize={minSize}\n onDeleteFile={handleDeleteFile}\n onRemoveFile={handleRemoveFile}\n thumbnails={thumbnails}\n />\n </PreviewItem>\n ))}\n </PreviewList>\n\n <VisuallyHidden>\n <Announce>{announcement}</Announce>\n </VisuallyHidden>\n </InverseContext.Provider>\n );\n }\n);\n","import React, { forwardRef, useContext, useEffect, useState } from 'react';\n\nimport {\n ButtonColor,\n ButtonVariant,\n Card,\n CardBorderRadius,\n CardCornerTreatment,\n Flex,\n FlexAlignItems,\n FlexBehavior,\n FlexProps,\n I18nContext,\n I18nInterface,\n IconButton,\n InverseContext,\n ThemeContext,\n ThemeInterface,\n Transition,\n Spinner,\n useIsInverse,\n styled,\n} from 'react-magma-dom';\nimport {\n CheckCircleIcon,\n CloseIcon,\n DeleteIcon,\n ErrorIcon,\n} from 'react-magma-icons';\n\nimport { FileIcon } from './FileIcon';\nimport { FilePreview } from './FilePreview';\nimport { formatFileSize } from './utils';\n\nexport interface PreviewProps extends Omit<FlexProps, 'behavior'> {\n accept?: string | string[];\n file: FilePreview;\n isInverse?: boolean;\n maxSize?: number;\n minSize?: number;\n onDeleteFile?: (file: FilePreview) => void;\n onRemoveFile?: (file: FilePreview) => void;\n /**\n * @internal\n */\n testId?: string;\n thumbnails: boolean;\n}\n\nconst Thumb = styled.div<{ file: FilePreview }>`\n background-image: ${({ file }) =>\n `url('${'preview' in file && file.preview}')`};\n background-repeat: no-repeat;\n background-size: cover;\n display: inline-block;\n vertical-align: middle;\n height: 40px;\n width: 40px;\n`;\n\nconst StatusIcons = styled.div`\n display: grid;\n grid-template-areas: 'inner-div';\n height: auto;\n place-items: center;\n width: 46px;\n & > div {\n display: inline-block;\n right: 0;\n grid-area: inner-div;\n }\n`;\n\nconst 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={isInverse ? theme.colors.brand.skyBlue : theme.colors.primary}\n />\n </StatusIcons>\n );\n }\n\n return (\n <StatusIcons>\n <Transition isOpen={!done} unmountOnExit fade>\n <CheckCircleIcon\n color={isInverse ? theme.colors.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 {file.errors ? (\n <ErrorIcon\n color={isInverse ? theme.colors.red500 : theme.colors.danger}\n size={24}\n />\n ) : file.preview &&\n thumbnails &&\n file.type &&\n file.type.startsWith('image') ? (\n <Thumb role=\"img\" file={file} />\n ) : (\n <FileIcon isInverse={isInverse} file={file} />\n )}\n </Flex>\n <FileName xs behavior={FlexBehavior.item} theme={theme}>\n {file.name}\n </FileName>\n {file.processor && file.processor.status === 'pending' && (\n <Flex\n role=\"progressbar\"\n style={{ marginLeft: 'auto' }}\n behavior={FlexBehavior.item}\n >\n {file.processor.percent}\n </Flex>\n )}\n <Flex behavior={FlexBehavior.item}>{actions}</Flex>\n </StyledFlex>\n {file.errors && (\n <Errors theme={theme} isInverse={isInverse}>\n {file.errors.slice(0, 1).map(({ code, ...rest }) => {\n const { header = '', message } = formatError(\n { code, ...rest, ...i18n.dropzone.errors[code] },\n { accept, minSize, maxSize },\n i18n.dropzone.bytes\n );\n\n return (\n <React.Fragment key={code}>\n <ErrorHeader\n style={{\n color: isInverse\n ? theme.colors.red500\n : theme.colors.danger,\n }}\n >\n {header}\n </ErrorHeader>\n <ErrorMessage>{message}</ErrorMessage>\n </React.Fragment>\n );\n })}\n </Errors>\n )}\n </StyledCard>\n </InverseContext.Provider>\n );\n});\n"],"names":["icons","default","Icon","InsertDriveFileIcon","style","color","magma","colors","neutral700","inverseStyle","neutral300","word","FileWordIcon","blue500","excel","FileExcelIcon","green500","powerpoint","FilePowerpointIcon","tangerine600","tangerine500","pdf","FilePdfIcon","red600","red500","image","ImageIcon","video","VideocamIcon","audio","AudiotrackIcon","archive","FileZipIcon","iconMapping","xlsx","xlsm","xlsb","xltx","xls","xlt","doc","docx","docm","dotx","dotm","docb","pptx","pptm","ppt","png","svg","zip","FileIcon","_ref","file","isInverse","_file$path","path","_file$type","type","category","split","extension","pop","_ref2","_jsx","size","iconSizes","medium","_templateObject","_templateObject2","_templateObject3","_templateObject4","_templateObject5","DragState","formatFileSize","bytes","decimalPoint","bytesLabel","undefined","sizes","i","Math","floor","log","parseFloat","pow","toFixed","Thumb","styled","div","_taggedTemplateLiteralLoose","preview","StatusIcons","IconStyles","marginRight","display","Errors","theme","neutral500","_ref3","typeScale","size02","fontSize","_ref4","lineHeight","StyledFlex","Flex","_ref5","_ref6","FileName","_ref7","_ref8","StyledCard","Card","_templateObject6","_ref9","errors","danger","neutral800","neutral200","_ref0","neutral0","brand","navy","ErrorHeader","span","_templateObject7","ErrorMessage","_templateObject8","Preview","forwardRef","props","ref","_file$processor2","accept","isInverseProp","maxSize","minSize","onDeleteFile","onRemoveFile","thumbnails","rest","_objectWithoutPropertiesLoose","_excluded","useContext","ThemeContext","i18n","React","I18nContext","useIsInverse","_useState","useState","CloseIcon","actions","setActions","handleRemoveFile","handleDeleteFile","FinishedActions","_ref1","_ref1$status","status","_useState2","done","setDone","useEffect","mounted","setTimeout","children","IconButton","onClick","variant","ButtonVariant","link","ButtonColor","subtle","dropzone","removeFile","name","icon","Spinner","skyBlue","primary","_jsxs","Transition","isOpen","unmountOnExit","fade","CheckCircleIcon","success","marginTop","deleteFile","DeleteIcon","_file$processor","processor","InverseContext","Provider","value","borderRadius","CardBorderRadius","small","cornerTreatment","CardCornerTreatment","all","testId","role","_extends","behavior","FlexBehavior","container","alignItems","FlexAlignItems","center","item","ErrorIcon","startsWith","xs","marginLeft","percent","slice","map","_ref10","code","_formatError","error","constraints","byteLabel","Array","isArray","length","messageSuffix","join","message","formatError","_excluded2","_formatError$header","header","Fragment","Container","noDrag","borderRadiusNone","borderRadiusSmall","_ref6$dragState","dragState","dragReject","red400","dragActive","dragAccept","_ref7$dragState","transparentize","neutral1200","neutral100","HelperMessage","Wrapper","_ref11","_ref12","spaceScale","spacing01","PreviewList","ul","PreviewItem","li","Dropzone","containerStyle","disabled","_props$dropzoneOption","dropzoneOptions","multiple","helperMessage","defaultId","id","inputSize","isLabelVisuallyHidden","labelStyle","labelText","maxFiles","minFiles","_props$multiple","_props$noDrag","onSendFile","_props$sendFiles","sendFiles","_props$thumbnails","_React$useState","files","setFiles","_React$useState2","errorMessage","setErrorMessage","_React$useState3","announcement","setAnnouncement","useGenerateId","helperMessageId","browseFileButtonRef","useRef","onDrop","useCallback","acceptedFiles","rejectedFiles","newFiles","concat","Object","assign","URL","createObjectURL","_ref13","prevFiles","fileNames","fileAdded","replace","filesAdded","toString","current","focus","_useDropzone","useDropzone","noClick","getInputProps","getRootProps","isDragAccept","isDragActive","isDragReject","open","inputRef","useImperativeHandle","inputProps","removedFile","filter","fileRemoved","fileDeleted","setProgress","progressProps","fileUploading","setFinished","finishedProps","fileUploaded","setError","errorProps","forEach","revokeObjectURL","minFileError","maxFileError","errorCode","onError","onFinish","onProgress","FormFieldContainer","actionable","fieldId","messageStyle","minHeight","tabIndex","autoComplete","onChange","Button","margin","browseFiles","CloudUploadIcon","dragMessage","solid","VisuallyHidden","Announce"],"mappings":"y6BAuBA,IAAMA,EAAQ,CACZC,QAAS,CACPC,KAAMC,EACNC,MAAO,CACLC,MAAOC,EAAMC,OAAOC,YAEtBC,aAAc,CACZJ,MAAOC,EAAMC,OAAOG,aAGxBC,KAAM,CACJT,KAAMU,EACNR,MAAO,CACLC,MAAOC,EAAMC,OAAOM,SAEtBJ,aAAc,CACZJ,MAAOC,EAAMC,OAAOM,UAGxBC,MAAO,CACLZ,KAAMa,EACNX,MAAO,CACLC,MAAOC,EAAMC,OAAOS,UAEtBP,aAAc,CACZJ,MAAOC,EAAMC,OAAOS,WAGxBC,WAAY,CACVf,KAAMgB,EACNd,MAAO,CACLC,MAAOC,EAAMC,OAAOY,cAEtBV,aAAc,CACZJ,MAAOC,EAAMC,OAAOa,eAGxBC,IAAK,CACHnB,KAAMoB,EACNlB,MAAO,CACLC,MAAOC,EAAMC,OAAOgB,QAEtBd,aAAc,CACZJ,MAAOC,EAAMC,OAAOiB,SAGxBC,MAAO,CACLvB,KAAMwB,EACNtB,MAAO,CACLC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,QACnBkF,SAAUA,EACVjN,UAAWA,GACXmH,QAASyJ,GACT/T,MAAO,CAAEgW,OAAQ,GACjB/N,IAAKiK,GACL,mBAAkB1B,EAAgByB,QAAkBtN,EAAUyF,SAE7DrB,GAAK6B,SAASqL,6BAInB9K,EAAC5E,EAAI,CAACoG,SAAUC,EAAaK,KAAK7C,SAAA,cAChCvG,EAACqS,EACC,CAAA,cAAY,OACZjW,MACEkD,GAAY2C,GAAM3F,OAAOmH,SAAWxB,GAAM3F,OAAOC,WAEnD0D,KAAM,kBAERD,EAAC4L,IAAQtM,UAAWA,GAAW2C,MAAOA,GAAMsE,SACzCrB,GAAK6B,SAASuL,2BAEjBtS,EAACkS,EACC9V,CAAAA,MAAOyK,EAAYQ,QACnBkF,SAAUA,EACVjN,UAAWA,GACXmH,QAASyJ,GACT/T,MAAO,CAAEgW,OAAQ,GACjBzL,QAASC,EAAc4L,MACvBnO,IAAKiK,GACL,mBAAkB1B,EAAgByB,QAAkBtN,EAAUyF,SAE7DrB,GAAK6B,SAASqL,qCAMzBpS,EAACiM,GAAW1F,CAAAA,SACToH,EAAMhE,IAAI,SAACtK,gBAAiB,OAC3BW,EAACmM,GAAW5F,CAAAA,sBACVvG,EAACiE,GAAO,CACNK,OAAQA,EACRjF,KAAMA,EACNC,UAAWA,GACXkF,QAASA,EACTC,QAASA,EACTC,aAAckB,GACdjB,aAAcgB,GACdf,WAAYA,KATEvF,EAAK4H,KAWT,kBAIlBjH,EAACwS,EAAc,CAAAjM,sBACbvG,EAACyS,GAAQlM,SAAE0H,SAInB"}
|
|
1
|
+
{"version":3,"file":"fileuploader.modern.module.js","sources":["../src/components/dropzone/FileIcon.tsx","../src/components/dropzone/utils.ts","../src/components/dropzone/Dropzone.tsx","../src/components/dropzone/Preview.tsx"],"sourcesContent":["import React from 'react';\n\nimport { magma } from 'react-magma-dom';\nimport {\n InsertDriveFileIcon,\n ImageIcon,\n AudiotrackIcon,\n VideocamIcon,\n FileExcelIcon,\n FilePdfIcon,\n FilePowerpointIcon,\n FileWordIcon,\n FileZipIcon,\n IconProps,\n} from 'react-magma-icons';\n\nimport { FilePreview } from './FilePreview';\n\nexport interface FileIconProps extends IconProps {\n file: FilePreview;\n isInverse?: boolean;\n}\n\nconst icons = {\n default: {\n Icon: InsertDriveFileIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n word: {\n Icon: FileWordIcon,\n style: {\n color: magma.colors.blue500,\n },\n inverseStyle: {\n color: magma.colors.blue500,\n },\n },\n excel: {\n Icon: FileExcelIcon,\n style: {\n color: magma.colors.green500,\n },\n inverseStyle: {\n color: magma.colors.green500,\n },\n },\n powerpoint: {\n Icon: FilePowerpointIcon,\n style: {\n color: magma.colors.tangerine600,\n },\n inverseStyle: {\n color: magma.colors.tangerine500,\n },\n },\n pdf: {\n Icon: FilePdfIcon,\n style: {\n color: magma.colors.red600,\n },\n inverseStyle: {\n color: magma.colors.red500,\n },\n },\n image: {\n Icon: ImageIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n video: {\n Icon: VideocamIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n audio: {\n Icon: AudiotrackIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n archive: {\n Icon: FileZipIcon,\n style: {\n color: magma.colors.neutral700,\n },\n inverseStyle: {\n color: magma.colors.neutral300,\n },\n },\n};\n\nconst iconMapping: {\n [key: string]: {\n Icon: any;\n style: React.CSSProperties;\n inverseStyle: React.CSSProperties;\n };\n} = {\n default: icons.default,\n xlsx: icons.excel,\n xlsm: icons.excel,\n xlsb: icons.excel,\n xltx: icons.excel,\n xls: icons.excel,\n xlt: icons.excel,\n doc: icons.word,\n docx: icons.word,\n docm: icons.word,\n dotx: icons.word,\n dotm: icons.word,\n docb: icons.word,\n pptx: icons.powerpoint,\n pptm: icons.powerpoint,\n ppt: icons.powerpoint,\n pdf: icons.pdf,\n png: icons.image,\n svg: icons.image,\n image: icons.image,\n audio: icons.audio,\n video: icons.video,\n zip: icons.archive,\n};\n\nexport const FileIcon = ({ file, isInverse }: FileIconProps) => {\n const { path = '', type = '' } = file;\n const category = type.split('/')[0];\n const extension = path.split('.').pop() || 'default';\n const { Icon, style, inverseStyle } =\n iconMapping[extension] || iconMapping[category] || iconMapping.default;\n\n return (\n <Icon\n size={magma.iconSizes.medium}\n style={isInverse ? inverseStyle : style}\n />\n );\n};\n","export const formatFileSize = (\n bytes: number | undefined,\n decimalPoint = 2,\n bytesLabel = 'Bytes'\n) => {\n if (bytes === undefined) return;\n if (bytes == 0) return `0 ${bytesLabel}`;\n const k = 1024;\n const sizes = [bytesLabel, 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n return (\n parseFloat((bytes / Math.pow(k, i)).toFixed(decimalPoint)) + ' ' + sizes[i]\n );\n};\n","/* eslint-disable no-empty-pattern */\n/**\n * HELPFUL NOTE!\n * SINCE THIS PACKAGE USES `FILE` WE MUST USE `Object.assign` IN LIEU OF SPREADING\n * `{...file}` WILL NOT COPY ALL OF THE FILE PROPERTIES\n */\n\nimport React, { useImperativeHandle } from 'react';\n\nimport { transparentize } from 'polished';\nimport {\n useDropzone,\n DropzoneOptions,\n DropzoneRootProps,\n FileRejection,\n} from 'react-dropzone';\nimport {\n Button,\n ButtonColor,\n ButtonVariant,\n Flex,\n FlexBehavior,\n FlexProps,\n FormFieldContainer,\n FormFieldContainerBaseProps,\n I18nContext,\n I18nInterface,\n InverseContext,\n ThemeContext,\n ThemeInterface,\n useGenerateId,\n useIsInverse,\n styled,\n Announce,\n VisuallyHidden,\n} from 'react-magma-dom';\nimport { CloudUploadIcon } from 'react-magma-icons';\n\nimport { FilePreview, FileError } from './FilePreview';\nimport { Preview } from './Preview';\n\nexport interface OnSendFileProps {\n file: FilePreview;\n onError?: ({}: { errors: FileError[]; file: FilePreview }) => void;\n onFinish?: ({}: { file: FilePreview }) => void;\n onProgress?: ({}: { percent: number; file: FilePreview }) => void;\n}\n\nenum DragState {\n error = 'error',\n dragAccept = 'dragAccept',\n dragReject = 'dragReject',\n dragActive = 'dragActive',\n default = 'default',\n}\n\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","import React, { forwardRef, useContext, useEffect, useState } from 'react';\n\nimport {\n ButtonColor,\n ButtonVariant,\n Card,\n CardBorderRadius,\n CardCornerTreatment,\n Flex,\n FlexAlignItems,\n FlexBehavior,\n FlexProps,\n I18nContext,\n I18nInterface,\n IconButton,\n InverseContext,\n ThemeContext,\n ThemeInterface,\n Transition,\n Spinner,\n useIsInverse,\n styled,\n} from 'react-magma-dom';\nimport {\n CheckCircleIcon,\n CloseIcon,\n DeleteIcon,\n ErrorIcon,\n} from 'react-magma-icons';\n\nimport { FileIcon } from './FileIcon';\nimport { FilePreview } from './FilePreview';\nimport { formatFileSize } from './utils';\n\nexport interface PreviewProps extends Omit<FlexProps, 'behavior'> {\n accept?: string | string[];\n file: FilePreview;\n isInverse?: boolean;\n maxSize?: number;\n minSize?: number;\n onDeleteFile?: (file: FilePreview) => void;\n onRemoveFile?: (file: FilePreview) => void;\n /**\n * @internal\n */\n testId?: string;\n thumbnails: boolean;\n}\n\nconst Thumb = styled.div<{ file: FilePreview }>`\n background-image: ${({ file }) =>\n `url('${'preview' in file && file.preview}')`};\n background-repeat: no-repeat;\n background-size: cover;\n display: inline-block;\n vertical-align: middle;\n height: 40px;\n width: 40px;\n`;\n\nconst StatusIcons = styled.div`\n display: grid;\n grid-template-areas: 'inner-div';\n height: auto;\n place-items: center;\n width: 46px;\n & > div {\n display: inline-block;\n right: 0;\n grid-area: inner-div;\n }\n`;\n\nconst PreviewIcon = ({\n file,\n isInverse,\n theme,\n thumbnails,\n}: {\n file: FilePreview;\n isInverse: boolean;\n theme: ThemeInterface;\n thumbnails: boolean;\n}) => {\n if (file.errors) {\n return (\n <ErrorIcon\n color={isInverse ? theme.colors.red500 : theme.colors.danger}\n size={24}\n />\n );\n }\n\n if (\n file.preview &&\n thumbnails &&\n file.type &&\n file.type.startsWith('image')\n ) {\n return <Thumb role=\"img\" file={file} />;\n }\n\n return <FileIcon isInverse={isInverse} file={file} />;\n};\n\nconst IconStyles = {\n marginRight: '12px',\n display: 'flex',\n};\n\nconst Errors = styled.div<{ isInverse: boolean }>`\n border-top: 1px solid\n ${({ theme, isInverse }) =>\n isInverse ? theme.colors.neutral500 : theme.colors.neutral300};\n padding: 16px;\n font-size: ${({ theme }) => theme.typeScale.size02.fontSize};\n line-height: ${({ theme }) => theme.typeScale.size02.lineHeight};\n`;\n\nconst StyledFlex = styled(Flex)`\n height: 56px;\n padding: 0 8px 0 16px;\n font-size: ${({ theme }) => theme.typeScale.size02.fontSize};\n line-height: ${({ theme }) => theme.typeScale.size02.lineHeight};\n`;\n\nconst FileName = styled(Flex)`\n overflow: hidden;\n white-space: nowrap;\n align-items: center;\n text-overflow: ellipsis;\n display: block;\n margin-right: 24px;\n font-size: ${({ theme }) => theme.typeScale.size02.fontSize};\n line-height: ${({ theme }) => theme.typeScale.size02.lineHeight};\n`;\n\nconst StyledCard = styled(Card)<{ file: FilePreview; isInverse: boolean }>`\n background-color: none;\n border-color: ${({ file, theme, isInverse }) =>\n file.errors\n ? isInverse\n ? theme.colors.red500\n : theme.colors.danger\n : isInverse\n ? theme.colors.neutral800\n : theme.colors.neutral200};\n border-width: 1px;\n color: ${({ file, theme, isInverse }) =>\n isInverse\n ? theme.colors.neutral0\n : file.errors\n ? theme.colors.neutral700\n : theme.colors.brand.navy};\n margin: 10px 0;\n`;\n\nconst ErrorHeader = styled.span`\n display: block;\n\n > div {\n display: flex;\n align-self: center;\n margin-right: 12px;\n }\n`;\n\nconst ErrorMessage = styled.span`\n display: block;\n`;\n\nconst formatError = (\n error: { header?: string; message: string; code: string },\n constraints: {\n maxSize?: number;\n minSize?: number;\n accept?: string | string[];\n },\n byteLabel: string\n) => {\n const accept =\n Array.isArray(constraints.accept) && constraints.accept.length === 1\n ? constraints.accept[0]\n : constraints.accept;\n const messageSuffix = Array.isArray(accept)\n ? `one of ${accept.join(', ')}`\n : accept;\n\n switch (error.code) {\n case 'file-too-large':\n return {\n ...error,\n message: `${error.message} ${formatFileSize(\n constraints.maxSize,\n 2,\n byteLabel\n )}.`,\n };\n case 'file-too-small':\n return {\n ...error,\n message: `${error.message} ${formatFileSize(\n constraints.minSize,\n 2,\n byteLabel\n )}.`,\n };\n case 'file-invalid-type':\n return { ...error, message: `${error.message}: ${messageSuffix}` };\n default:\n return error;\n }\n};\n\nexport const Preview = forwardRef<\n HTMLDivElement,\n Omit<PreviewProps, 'children'>\n>((props, ref) => {\n const {\n accept,\n file,\n isInverse: isInverseProp,\n maxSize,\n minSize,\n onDeleteFile,\n onRemoveFile,\n testId,\n thumbnails,\n ...rest\n } = props;\n\n const theme: ThemeInterface = useContext(ThemeContext);\n const i18n: I18nInterface = React.useContext(I18nContext);\n const isInverse = useIsInverse(isInverseProp);\n const [actions, setActions] = useState(<CloseIcon />);\n\n const handleRemoveFile = () => {\n onRemoveFile && typeof onRemoveFile === 'function' && onRemoveFile(file);\n };\n\n const handleDeleteFile = () => {\n onDeleteFile && typeof onDeleteFile === 'function' && onDeleteFile(file);\n };\n\n const FinishedActions = ({ status = 'ready' }: { status?: string }) => {\n const [done, setDone] = useState<boolean>(false);\n\n useEffect(() => {\n let mounted = true;\n\n setTimeout(() => {\n if (mounted) {\n setDone(true);\n }\n }, 1000);\n\n return () => {\n mounted = false;\n };\n }, [status]);\n\n if (status === 'error' || status === 'ready') {\n return (\n <StatusIcons>\n <IconButton\n onClick={handleRemoveFile}\n variant={ButtonVariant.link}\n color={ButtonColor.subtle}\n aria-label={`${i18n.dropzone.removeFile} ${file.name}`}\n icon={<CloseIcon />}\n />\n </StatusIcons>\n );\n }\n\n if (status === 'pending') {\n return (\n <StatusIcons>\n <Spinner\n color={\n isInverse ? theme.colors.brand.skyBlue : theme.colors.primary\n }\n />\n </StatusIcons>\n );\n }\n\n return (\n <StatusIcons>\n <Transition isOpen={!done} unmountOnExit fade>\n <CheckCircleIcon\n color={isInverse ? theme.colors.green500 : theme.colors.success}\n style={{ marginTop: '4px' }}\n />\n </Transition>\n <Transition isOpen={done} unmountOnExit fade>\n <IconButton\n onClick={handleDeleteFile}\n variant={ButtonVariant.link}\n color={ButtonColor.subtle}\n aria-label={`${i18n.dropzone.deleteFile} ${file.name}`}\n icon={<DeleteIcon />}\n />\n </Transition>\n </StatusIcons>\n );\n };\n\n useEffect(() => {\n setActions(<FinishedActions status={file?.processor?.status} />);\n }, [file?.processor?.status]);\n\n return (\n <InverseContext.Provider value={{ isInverse }}>\n <StyledCard\n borderRadius={CardBorderRadius.small}\n cornerTreatment={CardCornerTreatment.all}\n isInverse={isInverse}\n theme={theme}\n file={file}\n data-testid={props.testId}\n ref={ref}\n role={file.errors ? 'alert' : ''}\n >\n <StyledFlex\n theme={theme}\n behavior={FlexBehavior.container}\n alignItems={FlexAlignItems.center}\n {...rest}\n >\n <Flex\n behavior={FlexBehavior.item}\n alignItems={FlexAlignItems.center}\n style={IconStyles}\n >\n <PreviewIcon\n file={file}\n isInverse={isInverse}\n theme={theme}\n thumbnails={thumbnails}\n />\n </Flex>\n <FileName xs behavior={FlexBehavior.item} theme={theme}>\n {file.name}\n </FileName>\n {file.processor && file.processor.status === 'pending' && (\n <Flex\n role=\"progressbar\"\n style={{ marginLeft: 'auto' }}\n behavior={FlexBehavior.item}\n >\n {file.processor.percent}\n </Flex>\n )}\n <Flex behavior={FlexBehavior.item}>{actions}</Flex>\n </StyledFlex>\n {file.errors && (\n <Errors theme={theme} isInverse={isInverse}>\n {file.errors.slice(0, 1).map(({ code, ...rest }) => {\n const { header = '', message } = formatError(\n { code, ...rest, ...i18n.dropzone.errors[code] },\n { accept, minSize, maxSize },\n i18n.dropzone.bytes\n );\n\n return (\n <React.Fragment key={code}>\n <ErrorHeader\n style={{\n color: isInverse\n ? theme.colors.red500\n : theme.colors.danger,\n }}\n >\n {header}\n </ErrorHeader>\n <ErrorMessage>{message}</ErrorMessage>\n </React.Fragment>\n );\n })}\n </Errors>\n )}\n </StyledCard>\n </InverseContext.Provider>\n );\n});\n"],"names":["icons","default","Icon","InsertDriveFileIcon","style","color","magma","colors","neutral700","inverseStyle","neutral300","word","FileWordIcon","blue500","excel","FileExcelIcon","green500","powerpoint","FilePowerpointIcon","tangerine600","tangerine500","pdf","FilePdfIcon","red600","red500","image","ImageIcon","video","VideocamIcon","audio","AudiotrackIcon","archive","FileZipIcon","iconMapping","xlsx","xlsm","xlsb","xltx","xls","xlt","doc","docx","docm","dotx","dotm","docb","pptx","pptm","ppt","png","svg","zip","FileIcon","_ref","file","isInverse","_file$path","path","_file$type","type","category","split","extension","pop","_ref2","_jsx","size","iconSizes","medium","_templateObject","_templateObject2","_templateObject3","_templateObject4","_templateObject5","DragState","formatFileSize","bytes","decimalPoint","bytesLabel","undefined","sizes","i","Math","floor","log","parseFloat","pow","toFixed","Thumb","styled","div","_taggedTemplateLiteralLoose","preview","StatusIcons","PreviewIcon","theme","thumbnails","errors","ErrorIcon","danger","startsWith","role","IconStyles","marginRight","display","Errors","_ref3","neutral500","_ref4","typeScale","size02","fontSize","_ref5","lineHeight","StyledFlex","Flex","_ref6","_ref7","FileName","_ref8","_ref9","StyledCard","Card","_templateObject6","_ref0","neutral800","neutral200","_ref1","neutral0","brand","navy","ErrorHeader","span","_templateObject7","ErrorMessage","_templateObject8","Preview","forwardRef","props","ref","_file$processor2","accept","isInverseProp","maxSize","minSize","onDeleteFile","onRemoveFile","rest","_objectWithoutPropertiesLoose","_excluded","useContext","ThemeContext","i18n","React","I18nContext","useIsInverse","_useState","useState","CloseIcon","actions","setActions","handleRemoveFile","handleDeleteFile","FinishedActions","_ref10","_ref10$status","status","_useState2","done","setDone","useEffect","mounted","setTimeout","children","IconButton","onClick","variant","ButtonVariant","link","ButtonColor","subtle","dropzone","removeFile","name","icon","Spinner","skyBlue","primary","_jsxs","Transition","isOpen","unmountOnExit","fade","CheckCircleIcon","success","marginTop","deleteFile","DeleteIcon","_file$processor","processor","InverseContext","Provider","value","borderRadius","CardBorderRadius","small","cornerTreatment","CardCornerTreatment","all","testId","_extends","behavior","FlexBehavior","container","alignItems","FlexAlignItems","center","item","xs","marginLeft","percent","slice","map","_ref11","code","_formatError","error","constraints","byteLabel","Array","isArray","length","messageSuffix","join","message","formatError","_excluded2","_formatError$header","header","Fragment","getBrowseButtonText","buttonText","localizedText","Container","noDrag","borderRadiusNone","borderRadiusSmall","_ref$dragState","dragState","dragReject","getErrorBorderColor","red400","dragActive","dragAccept","_ref7$dragState","transparentize","neutral1200","neutral100","HelperMessage","Wrapper","_ref12","spaceScale","spacing01","PreviewList","ul","PreviewItem","li","Dropzone","_props$buttonColor","buttonColor","containerStyle","disabled","_props$dropzoneOption","dropzoneOptions","multiple","helperMessage","defaultId","id","inputSize","isLabelVisuallyHidden","labelStyle","labelText","maxFiles","minFiles","_props$multiple","_props$noDrag","onSendFile","_props$sendFiles","sendFiles","_props$thumbnails","_React$useState","files","setFiles","_React$useState2","errorMessage","setErrorMessage","_React$useState3","announcement","setAnnouncement","useGenerateId","helperMessageId","browseFileButtonRef","useRef","onDrop","useCallback","acceptedFiles","rejectedFiles","newFiles","concat","Object","assign","URL","createObjectURL","_ref13","prevFiles","fileNames","fileAdded","replace","filesAdded","toString","current","focus","_useDropzone","useDropzone","noClick","getInputProps","getRootProps","isDragAccept","isDragActive","isDragReject","open","inputRef","useImperativeHandle","inputProps","removedFile","filter","fileRemoved","fileDeleted","setProgress","progressProps","fileUploading","setFinished","finishedProps","fileUploaded","setError","errorProps","forEach","revokeObjectURL","minFileError","maxFileError","errorCode","onError","onFinish","onProgress","FormFieldContainer","actionable","fieldId","messageStyle","minHeight","tabIndex","autoComplete","onChange","Button","margin","browseFiles","CloudUploadIcon","dragMessage","solid","VisuallyHidden","Announce"],"mappings":"y6BAuBA,IAAMA,EAAQ,CACZC,QAAS,CACPC,KAAMC,EACNC,MAAO,CACLC,MAAOC,EAAMC,OAAOC,YAEtBC,aAAc,CACZJ,MAAOC,EAAMC,OAAOG,aAGxBC,KAAM,CACJT,KAAMU,EACNR,MAAO,CACLC,MAAOC,EAAMC,OAAOM,SAEtBJ,aAAc,CACZJ,MAAOC,EAAMC,OAAOM,UAGxBC,MAAO,CACLZ,KAAMa,EACNX,MAAO,CACLC,MAAOC,EAAMC,OAAOS,UAEtBP,aAAc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B7S,EAACyS,EAAM,CACLrW,MAAOwQ,EACPE,SAAUA,EACVxN,UAAWA,GACXwH,QAAS2J,GACTtU,MAAO,CAAEuW,OAAQ,GACjB3L,QAASC,EAAc8L,MACvBpO,IAAKkK,GACL,mBAAkB1B,EAAgByB,QAAkB7N,EAAU8F,SAE7DmE,GAAoBC,EAAYzF,GAAK6B,SAASuL,sCAMzD3S,EAACsM,GAAW,CAAA1F,SACTsH,GAAMrE,IAAI,SAACxK,gBACVW,OAAAA,EAACwM,IAAW5F,sBACV5G,EAACuE,IACCK,OAAQA,EACRvF,KAAMA,EACNC,UAAWA,GACXwF,QAASA,EACTC,QAASA,EACTC,aAAciB,GACdhB,aAAce,GACdjE,WAAYA,KATE1C,EAAKiI,KAWT,kBAIlBtH,EAAC+S,GAAcnM,sBACb5G,EAACgT,EAAQpM,CAAAA,SAAE4H,SAInB"}
|
package/dist/fileuploader.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react-magma-dom"),require("react-magma-icons"),require("react/jsx-runtime"),require("react"),require("polished"),require("react-dropzone")):"function"==typeof define&&define.amd?define(["exports","react-magma-dom","react-magma-icons","react/jsx-runtime","react","polished","react-dropzone"],n):n((e||self).dropzone={},e.reactMagmaDom,e.reactMagmaIcons,e.jsx,e.react,e.polished,e.reactDropzone)}(this,function(e,n,r,o,t,i,l){function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=/*#__PURE__*/a(t),c={default:{Icon:r.InsertDriveFileIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}},word:{Icon:r.FileWordIcon,style:{color:n.magma.colors.blue500},inverseStyle:{color:n.magma.colors.blue500}},excel:{Icon:r.FileExcelIcon,style:{color:n.magma.colors.green500},inverseStyle:{color:n.magma.colors.green500}},powerpoint:{Icon:r.FilePowerpointIcon,style:{color:n.magma.colors.tangerine600},inverseStyle:{color:n.magma.colors.tangerine500}},pdf:{Icon:r.FilePdfIcon,style:{color:n.magma.colors.red600},inverseStyle:{color:n.magma.colors.red500}},image:{Icon:r.ImageIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}},video:{Icon:r.VideocamIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}},audio:{Icon:r.AudiotrackIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}},archive:{Icon:r.FileZipIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}}},d={default:c.default,xlsx:c.excel,xlsm:c.excel,xlsb:c.excel,xltx:c.excel,xls:c.excel,xlt:c.excel,doc:c.word,docx:c.word,docm:c.word,dotx:c.word,dotm:c.word,docb:c.word,pptx:c.powerpoint,pptm:c.powerpoint,ppt:c.powerpoint,pdf:c.pdf,png:c.image,svg:c.image,image:c.image,audio:c.audio,video:c.video,zip:c.archive},u=function(e){var r=e.file,t=e.isInverse,i=r.path,l=void 0===i?"":i,a=r.type,s=(void 0===a?"":a).split("/")[0],c=l.split(".").pop()||"default",u=d[c]||d[s]||d.default;/*#__PURE__*/return o.jsx(u.Icon,{size:n.magma.iconSizes.medium,style:t?u.inverseStyle:u.style})};function p(){return p=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var o in r)({}).hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},p.apply(null,arguments)}function f(e,n){if(null==e)return{};var r={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(-1!==n.indexOf(o))continue;r[o]=e[o]}return r}function m(e,n){return n||(n=e.slice(0)),e.raw=n,e}var g,v,x,h,y,b,I,z,j,S,F,w,C,B,D=function(e,n,r){if(void 0===n&&(n=2),void 0===r&&(r="Bytes"),void 0!==e){if(0==e)return"0 "+r;var o=[r,"KB","MB","GB","TB","PB","EB","ZB","YB"],t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(n))+" "+o[t]}},k=["accept","file","isInverse","maxSize","minSize","onDeleteFile","onRemoveFile","testId","thumbnails"],R=["code"],A=n.styled.div(g||(g=m(["\n background-image: ",";\n background-repeat: no-repeat;\n background-size: cover;\n display: inline-block;\n vertical-align: middle;\n height: 40px;\n width: 40px;\n"])),function(e){var n=e.file;return"url('"+("preview"in n&&n.preview)+"')"}),O=n.styled.div(v||(v=m(["\n display: grid;\n grid-template-areas: 'inner-div';\n height: auto;\n place-items: center;\n width: 46px;\n & > div {\n display: inline-block;\n right: 0;\n grid-area: inner-div;\n }\n"]))),T={marginRight:"12px",display:"flex"},E=n.styled.div(x||(x=m(["\n border-top: 1px solid\n ",";\n padding: 16px;\n font-size: ",";\n line-height: ",";\n"])),function(e){var n=e.theme;return e.isInverse?n.colors.neutral500:n.colors.neutral300},function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight}),M=n.styled(n.Flex)(h||(h=m(["\n height: 56px;\n padding: 0 8px 0 16px;\n font-size: ",";\n line-height: ",";\n"])),function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight}),H=n.styled(n.Flex)(y||(y=m(["\n overflow: hidden;\n white-space: nowrap;\n align-items: center;\n text-overflow: ellipsis;\n display: block;\n margin-right: 24px;\n font-size: ",";\n line-height: ",";\n"])),function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight}),P=n.styled(n.Card)(b||(b=m(["\n background-color: none;\n border-color: ",";\n border-width: 1px;\n color: ",";\n margin: 10px 0;\n"])),function(e){var n=e.theme,r=e.isInverse;return e.file.errors?r?n.colors.red500:n.colors.danger:r?n.colors.neutral800:n.colors.neutral200},function(e){var n=e.theme;return e.isInverse?n.colors.neutral0:e.file.errors?n.colors.neutral700:n.colors.brand.navy}),L=n.styled.span(I||(I=m(["\n display: block;\n\n > div {\n display: flex;\n align-self: center;\n margin-right: 12px;\n }\n"]))),V=n.styled.span(z||(z=m(["\n display: block;\n"]))),N=/*#__PURE__*/t.forwardRef(function(e,i){var l,a=e.accept,c=e.file,d=e.isInverse,m=e.maxSize,g=e.minSize,v=e.onDeleteFile,x=e.onRemoveFile,h=e.thumbnails,y=f(e,k),b=t.useContext(n.ThemeContext),I=s.default.useContext(n.I18nContext),z=n.useIsInverse(d),j=t.useState(/*#__PURE__*/o.jsx(r.CloseIcon,{})),S=j[0],F=j[1],w=function(){x&&"function"==typeof x&&x(c)},C=function(){v&&"function"==typeof v&&v(c)},B=function(e){var i=e.status,l=void 0===i?"ready":i,a=t.useState(!1),s=a[0],d=a[1];return t.useEffect(function(){var e=!0;return setTimeout(function(){e&&d(!0)},1e3),function(){e=!1}},[l]),"error"===l||"ready"===l?/*#__PURE__*/o.jsx(O,{children:/*#__PURE__*/o.jsx(n.IconButton,{onClick:w,variant:n.ButtonVariant.link,color:n.ButtonColor.subtle,"aria-label":I.dropzone.removeFile+" "+c.name,icon:/*#__PURE__*/o.jsx(r.CloseIcon,{})})}):"pending"===l?/*#__PURE__*/o.jsx(O,{children:/*#__PURE__*/o.jsx(n.Spinner,{color:z?b.colors.brand.skyBlue:b.colors.primary})}):/*#__PURE__*/o.jsxs(O,{children:[/*#__PURE__*/o.jsx(n.Transition,{isOpen:!s,unmountOnExit:!0,fade:!0,children:/*#__PURE__*/o.jsx(r.CheckCircleIcon,{color:z?b.colors.green500:b.colors.success,style:{marginTop:"4px"}})}),/*#__PURE__*/o.jsx(n.Transition,{isOpen:s,unmountOnExit:!0,fade:!0,children:/*#__PURE__*/o.jsx(n.IconButton,{onClick:C,variant:n.ButtonVariant.link,color:n.ButtonColor.subtle,"aria-label":I.dropzone.deleteFile+" "+c.name,icon:/*#__PURE__*/o.jsx(r.DeleteIcon,{})})})]})};return t.useEffect(function(){var e;F(/*#__PURE__*/o.jsx(B,{status:null==c||null==(e=c.processor)?void 0:e.status}))},[null==c||null==(l=c.processor)?void 0:l.status]),/*#__PURE__*/o.jsx(n.InverseContext.Provider,{value:{isInverse:z},children:/*#__PURE__*/o.jsxs(P,{borderRadius:n.CardBorderRadius.small,cornerTreatment:n.CardCornerTreatment.all,isInverse:z,theme:b,file:c,"data-testid":e.testId,ref:i,role:c.errors?"alert":"",children:[/*#__PURE__*/o.jsxs(M,p({theme:b,behavior:n.FlexBehavior.container,alignItems:n.FlexAlignItems.center},y,{children:[/*#__PURE__*/o.jsx(n.Flex,{behavior:n.FlexBehavior.item,alignItems:n.FlexAlignItems.center,style:T,children:c.errors?/*#__PURE__*/o.jsx(r.ErrorIcon,{color:z?b.colors.red500:b.colors.danger,size:24}):c.preview&&h&&c.type&&c.type.startsWith("image")?/*#__PURE__*/o.jsx(A,{role:"img",file:c}):/*#__PURE__*/o.jsx(u,{isInverse:z,file:c})}),/*#__PURE__*/o.jsx(H,{xs:!0,behavior:n.FlexBehavior.item,theme:b,children:c.name}),c.processor&&"pending"===c.processor.status&&/*#__PURE__*/o.jsx(n.Flex,{role:"progressbar",style:{marginLeft:"auto"},behavior:n.FlexBehavior.item,children:c.processor.percent}),/*#__PURE__*/o.jsx(n.Flex,{behavior:n.FlexBehavior.item,children:S})]})),c.errors&&/*#__PURE__*/o.jsx(E,{theme:b,isInverse:z,children:c.errors.slice(0,1).map(function(e){var n=e.code,r=function(e,n,r){var o=Array.isArray(n.accept)&&1===n.accept.length?n.accept[0]:n.accept,t=Array.isArray(o)?"one of "+o.join(", "):o;switch(e.code){case"file-too-large":return p({},e,{message:e.message+" "+D(n.maxSize,2,r)+"."});case"file-too-small":return p({},e,{message:e.message+" "+D(n.minSize,2,r)+"."});case"file-invalid-type":return p({},e,{message:e.message+": "+t});default:return e}}(p({code:n},f(e,R),I.dropzone.errors[n]),{accept:a,minSize:g,maxSize:m},I.dropzone.bytes),t=r.header,i=r.message;/*#__PURE__*/return o.jsxs(s.default.Fragment,{children:[/*#__PURE__*/o.jsx(L,{style:{color:z?b.colors.red500:b.colors.danger},children:void 0===t?"":t}),/*#__PURE__*/o.jsx(V,{children:i})]},n)})})]})})}),U=["accept","containerStyle","disabled","dropzoneOptions","helperMessage","id","inputSize","isInverse","isLabelVisuallyHidden","labelStyle","labelText","maxFiles","minFiles","maxSize","minSize","multiple","noDrag","onSendFile","onDeleteFile","onRemoveFile","sendFiles","testId","thumbnails"];!function(e){e.error="error",e.dragAccept="dragAccept",e.dragReject="dragReject",e.dragActive="dragActive",e.default="default"}(B||(B={}));var q=n.styled(n.Flex)(j||(j=m(["\n flex-direction: column;\n align-items: ",";\n justify-content: ",";\n text-align: ",";\n padding: ",";\n border-radius: ",";\n border: ",";\n\n border-style: ",";\n background-color: ",";\n outline: none;\n transition: ",";\n"])),function(e){return e.noDrag?"left":"center"},function(e){return e.noDrag?"left":"center"},function(e){return e.noDrag?"left":"center"},function(e){return e.noDrag?"0px":"24px"},function(e){var n=e.theme;return e.noDrag?n.borderRadiusNone:n.borderRadiusSmall},function(e){var n=e.dragState,r=void 0===n?B.default:n,o=e.theme,t=e.isInverse;return e.noDrag?"0px":r===B.dragReject||r===B.error?t?(r===B.error?"1px":"2px")+" dashed "+(r===B.error?o.colors.red500:o.colors.red400):(r===B.error?"1px":"2px")+" dashed "+o.colors.danger:r===B.dragActive?"2px dashed "+o.colors.blue500:r===B.dragAccept?"2px dashed "+o.colors.green500:"2px dashed "+(t?o.colors.neutral800:o.colors.neutral300)},function(e){var n=e.dragState;return(void 0===n?B.default:n)===B.error?"solid":"dashed"},function(e){var n=e.theme;return e.noDrag?"transparent":e.isInverse?i.transparentize(.6,n.colors.neutral1200):n.colors.neutral100},function(e){return"border "+(e.noDrag?0:".24s")+" ease-in-out"}),G=n.styled.span(S||(S=m(["\n color: ",";\n display: block;\n font-size: 14px;\n margin: -8px 0 16px 0;\n"])),function(e){var n=e.theme;return e.isInverse?n.colors.neutral500:n.colors.neutral700}),W=n.styled.div(F||(F=m(["\n color: ",";\n margin: 0 0 24px 0;\n font-size: ",";\n line-height: ",";\n font-weight: 500;\n padding: ",";\n"])),function(e){var n=e.theme;return e.isInverse?n.colors.neutral0:n.colors.brand.navy},function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight},function(e){return e.theme.spaceScale.spacing01}),Z=n.styled.ul(w||(w=m(["\n list-style: none;\n padding: 0;\n"]))),K=n.styled.li(C||(C=m([""])));e.Dropzone=/*#__PURE__*/s.default.forwardRef(function(e,i){var a=e.accept,c=e.containerStyle,d=e.disabled,u=e.dropzoneOptions,m=void 0===u?{multiple:!0}:u,g=e.helperMessage,v=e.id,x=e.inputSize,h=e.isInverse,y=e.isLabelVisuallyHidden,b=e.labelStyle,I=e.labelText,z=e.maxFiles,j=e.minFiles,S=e.maxSize,F=e.minSize,w=e.multiple,C=void 0===w||w,D=e.noDrag,k=void 0!==D&&D,R=e.onSendFile,A=e.onDeleteFile,O=e.onRemoveFile,T=e.sendFiles,E=void 0!==T&&T,M=e.testId,H=e.thumbnails,P=void 0===H||H,L=f(e,U),V=s.default.useState([]),Y=V[0],J=V[1],Q=s.default.useState(null),X=Q[0],$=Q[1],_=s.default.useState(""),ee=_[0],ne=_[1],re=n.useIsInverse(h),oe=s.default.useContext(n.ThemeContext),te=s.default.useContext(n.I18nContext),ie=n.useGenerateId(v),le=n.useGenerateId(ie+"-helper"),ae=s.default.useRef(null),se=s.default.useCallback(function(e,n){var r=[].concat(e.map(function(e){return Object.assign(e,{preview:URL.createObjectURL(e)})}),n.map(function(e){return Object.assign(e.file,{errors:e.errors})}));if(J(function(e){return[].concat(e,r)}),e.length>0){var o=e.map(function(e){return e.name}).join(", "),t=1===e.length?te.dropzone.fileAdded.replace(/\{fileName\}/g,o):te.dropzone.filesAdded.replace(/\{count\}/g,e.length.toString()).replace(/\{fileNames\}/g,o);ne(t)}ae.current&&ae.current.focus()},[te]),ce=l.useDropzone(p({noClick:!0,disabled:d,multiple:C,maxSize:S,minSize:F,accept:a,onDrop:se,noDrag:k},m)),de=ce.getInputProps,ue=ce.getRootProps,pe=ce.isDragAccept,fe=ce.isDragActive,me=ce.isDragReject,ge=ce.open,ve=ce.inputRef;t.useImperativeHandle(i,function(){return ve.current});var xe=de({id:ie}),he=B.default;X?he=B.error:pe?he=B.dragAccept:me?he=B.dragReject:fe&&(he=B.dragActive);var ye=function(e){J(function(n){return n.filter(function(n){return n!==e})}),O&&"function"==typeof O&&O(e);var n=te.dropzone.fileRemoved.replace(/\{fileName\}/g,e.name);ne(n),ae.current&&ae.current.focus()},be=function(e){J(function(n){return n.filter(function(n){return n!==e})}),A&&"function"==typeof A&&A(e);var n=te.dropzone.fileDeleted.replace(/\{fileName\}/g,e.name);ne(n),ae.current&&ae.current.focus()},Ie=function(e){if(J(function(n){return n.map(function(n){return n===e.file?Object.assign(n,{processor:p({},n.processor,{percent:e.percent+"%",status:"pending"})}):n})}),e.percent>0&&e.percent%25==0){var n=te.dropzone.fileUploading.replace(/\{fileName\}/g,e.file.name).replace(/\{percent\}/g,e.percent.toString());ne(n)}},ze=function(e){J(function(n){return n.map(function(n){return n===e.file?Object.assign(n,{processor:p({},n.processor,{percent:"",status:"finished"})}):n})});var n=te.dropzone.fileUploaded.replace(/\{fileName\}/g,e.file.name);ne(n)},je=function(e){J(function(n){return n.map(function(n){return n===e.file?Object.assign(n,{errors:e.errors,processor:p({},n.processor,{status:"error"})}):n})})};return s.default.useEffect(function(){return function(){Y.forEach(function(e){return e.preview&&URL.revokeObjectURL(e.preview)})}},[Y]),s.default.useEffect(function(){var e=j&&Y.length<j,n=z&&Y.length>z,r=null;n?r="too-many-files":e&&(r="too-few-files"),$(function(e,n){if(null===e)return null;var r=te.dropzone.errors[e];switch(e){case"too-many-files":return r.message+" "+n.maxFiles+" "+te.dropzone.files+".";case"too-few-files":return r.message+" "+n.minFiles+" "+te.dropzone.files+".";default:return r.message}}(r,{minFiles:j,maxFiles:z})),E&&Y.length>0&&!n&&!e&&J(function(e){return e.map(function(e){return e.errors||e.processor||!R||R({file:e,onError:je,onFinish:ze,onProgress:Ie}),e})})},[E,Y.length,R,z,j,te.dropzone.errors,te.dropzone.files]),/*#__PURE__*/o.jsxs(n.InverseContext.Provider,{value:{isInverse:re},children:[/*#__PURE__*/o.jsxs(n.FormFieldContainer,{actionable:!1,containerStyle:c,errorMessage:X,fieldId:ie,inputSize:x,isInverse:re,isLabelVisuallyHidden:y,labelStyle:p({color:re?oe.colors.neutral0:oe.colors.brand.navy},b),labelText:I,messageStyle:{minHeight:0},"data-testid":M,children:[/*#__PURE__*/o.jsx(G,{id:le,theme:oe,isInverse:re,children:g}),/*#__PURE__*/o.jsxs(q,p({behavior:n.FlexBehavior.container,dragState:he,isInverse:re,noDrag:k,theme:oe},ue(),L,{testId:M,tabIndex:-1,children:[/*#__PURE__*/o.jsx("input",{ref:ve,type:xe.type,accept:xe.accept,autoComplete:xe.autoComplete,id:xe.id,multiple:xe.multiple,onChange:xe.onChange,onClick:xe.onClick,style:xe.style,tabIndex:xe.tabIndex,"data-testid":"file-input"}),k?/*#__PURE__*/o.jsx(n.Flex,{xs:!0,behavior:n.FlexBehavior.item,children:/*#__PURE__*/o.jsx(n.Button,{color:n.ButtonColor.primary,disabled:d,isInverse:re,onClick:ge,style:{margin:0},ref:ae,"aria-describedby":g?le:void 0,children:te.dropzone.browseFiles})}):/*#__PURE__*/o.jsxs(n.Flex,{behavior:n.FlexBehavior.item,children:[/*#__PURE__*/o.jsx(r.CloudUploadIcon,{"aria-hidden":"true",color:re?oe.colors.neutral0:oe.colors.neutral700,size:48}),/*#__PURE__*/o.jsx(W,{isInverse:re,theme:oe,children:te.dropzone.dragMessage}),/*#__PURE__*/o.jsx(n.Button,{color:n.ButtonColor.primary,disabled:d,isInverse:re,onClick:ge,style:{margin:0},variant:n.ButtonVariant.solid,ref:ae,"aria-describedby":g?le:void 0,children:te.dropzone.browseFiles})]})]}))]}),/*#__PURE__*/o.jsx(Z,{children:Y.map(function(e){/*#__PURE__*/return o.jsx(K,{children:/*#__PURE__*/o.jsx(N,{accept:a,file:e,isInverse:re,maxSize:S,minSize:F,onDeleteFile:be,onRemoveFile:ye,thumbnails:P})},e.name)})}),/*#__PURE__*/o.jsx(n.VisuallyHidden,{children:/*#__PURE__*/o.jsx(n.Announce,{children:ee})})]})}),e.FileIcon=u});
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react-magma-dom"),require("react-magma-icons"),require("react/jsx-runtime"),require("react"),require("polished"),require("react-dropzone")):"function"==typeof define&&define.amd?define(["exports","react-magma-dom","react-magma-icons","react/jsx-runtime","react","polished","react-dropzone"],n):n((e||self).dropzone={},e.reactMagmaDom,e.reactMagmaIcons,e.jsx,e.react,e.polished,e.reactDropzone)}(this,function(e,n,r,o,t,i,l){function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=/*#__PURE__*/a(t),c={default:{Icon:r.InsertDriveFileIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}},word:{Icon:r.FileWordIcon,style:{color:n.magma.colors.blue500},inverseStyle:{color:n.magma.colors.blue500}},excel:{Icon:r.FileExcelIcon,style:{color:n.magma.colors.green500},inverseStyle:{color:n.magma.colors.green500}},powerpoint:{Icon:r.FilePowerpointIcon,style:{color:n.magma.colors.tangerine600},inverseStyle:{color:n.magma.colors.tangerine500}},pdf:{Icon:r.FilePdfIcon,style:{color:n.magma.colors.red600},inverseStyle:{color:n.magma.colors.red500}},image:{Icon:r.ImageIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}},video:{Icon:r.VideocamIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}},audio:{Icon:r.AudiotrackIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}},archive:{Icon:r.FileZipIcon,style:{color:n.magma.colors.neutral700},inverseStyle:{color:n.magma.colors.neutral300}}},u={default:c.default,xlsx:c.excel,xlsm:c.excel,xlsb:c.excel,xltx:c.excel,xls:c.excel,xlt:c.excel,doc:c.word,docx:c.word,docm:c.word,dotx:c.word,dotm:c.word,docb:c.word,pptx:c.powerpoint,pptm:c.powerpoint,ppt:c.powerpoint,pdf:c.pdf,png:c.image,svg:c.image,image:c.image,audio:c.audio,video:c.video,zip:c.archive},d=function(e){var r=e.file,t=e.isInverse,i=r.path,l=void 0===i?"":i,a=r.type,s=(void 0===a?"":a).split("/")[0],c=l.split(".").pop()||"default",d=u[c]||u[s]||u.default;/*#__PURE__*/return o.jsx(d.Icon,{size:n.magma.iconSizes.medium,style:t?d.inverseStyle:d.style})};function p(){return p=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var o in r)({}).hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},p.apply(null,arguments)}function f(e,n){if(null==e)return{};var r={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(-1!==n.indexOf(o))continue;r[o]=e[o]}return r}function m(e,n){return n||(n=e.slice(0)),e.raw=n,e}var g,v,x,h,y,b,I,z,j,S,F,w,C,B,D=function(e,n,r){if(void 0===n&&(n=2),void 0===r&&(r="Bytes"),void 0!==e){if(0==e)return"0 "+r;var o=[r,"KB","MB","GB","TB","PB","EB","ZB","YB"],t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(n))+" "+o[t]}},k=["accept","file","isInverse","maxSize","minSize","onDeleteFile","onRemoveFile","testId","thumbnails"],R=["code"],A=n.styled.div(g||(g=m(["\n background-image: ",";\n background-repeat: no-repeat;\n background-size: cover;\n display: inline-block;\n vertical-align: middle;\n height: 40px;\n width: 40px;\n"])),function(e){var n=e.file;return"url('"+("preview"in n&&n.preview)+"')"}),O=n.styled.div(v||(v=m(["\n display: grid;\n grid-template-areas: 'inner-div';\n height: auto;\n place-items: center;\n width: 46px;\n & > div {\n display: inline-block;\n right: 0;\n grid-area: inner-div;\n }\n"]))),T=function(e){var n=e.file,t=e.isInverse,i=e.theme,l=e.thumbnails;return n.errors?/*#__PURE__*/o.jsx(r.ErrorIcon,{color:t?i.colors.red500:i.colors.danger,size:24}):n.preview&&l&&n.type&&n.type.startsWith("image")?/*#__PURE__*/o.jsx(A,{role:"img",file:n}):/*#__PURE__*/o.jsx(d,{isInverse:t,file:n})},E={marginRight:"12px",display:"flex"},M=n.styled.div(x||(x=m(["\n border-top: 1px solid\n ",";\n padding: 16px;\n font-size: ",";\n line-height: ",";\n"])),function(e){var n=e.theme;return e.isInverse?n.colors.neutral500:n.colors.neutral300},function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight}),H=n.styled(n.Flex)(h||(h=m(["\n height: 56px;\n padding: 0 8px 0 16px;\n font-size: ",";\n line-height: ",";\n"])),function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight}),P=n.styled(n.Flex)(y||(y=m(["\n overflow: hidden;\n white-space: nowrap;\n align-items: center;\n text-overflow: ellipsis;\n display: block;\n margin-right: 24px;\n font-size: ",";\n line-height: ",";\n"])),function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight}),L=n.styled(n.Card)(b||(b=m(["\n background-color: none;\n border-color: ",";\n border-width: 1px;\n color: ",";\n margin: 10px 0;\n"])),function(e){var n=e.theme,r=e.isInverse;return e.file.errors?r?n.colors.red500:n.colors.danger:r?n.colors.neutral800:n.colors.neutral200},function(e){var n=e.theme;return e.isInverse?n.colors.neutral0:e.file.errors?n.colors.neutral700:n.colors.brand.navy}),V=n.styled.span(I||(I=m(["\n display: block;\n\n > div {\n display: flex;\n align-self: center;\n margin-right: 12px;\n }\n"]))),N=n.styled.span(z||(z=m(["\n display: block;\n"]))),U=/*#__PURE__*/t.forwardRef(function(e,i){var l,a=e.accept,c=e.file,u=e.isInverse,d=e.maxSize,m=e.minSize,g=e.onDeleteFile,v=e.onRemoveFile,x=e.thumbnails,h=f(e,k),y=t.useContext(n.ThemeContext),b=s.default.useContext(n.I18nContext),I=n.useIsInverse(u),z=t.useState(/*#__PURE__*/o.jsx(r.CloseIcon,{})),j=z[0],S=z[1],F=function(){v&&"function"==typeof v&&v(c)},w=function(){g&&"function"==typeof g&&g(c)},C=function(e){var i=e.status,l=void 0===i?"ready":i,a=t.useState(!1),s=a[0],u=a[1];return t.useEffect(function(){var e=!0;return setTimeout(function(){e&&u(!0)},1e3),function(){e=!1}},[l]),"error"===l||"ready"===l?/*#__PURE__*/o.jsx(O,{children:/*#__PURE__*/o.jsx(n.IconButton,{onClick:F,variant:n.ButtonVariant.link,color:n.ButtonColor.subtle,"aria-label":b.dropzone.removeFile+" "+c.name,icon:/*#__PURE__*/o.jsx(r.CloseIcon,{})})}):"pending"===l?/*#__PURE__*/o.jsx(O,{children:/*#__PURE__*/o.jsx(n.Spinner,{color:I?y.colors.brand.skyBlue:y.colors.primary})}):/*#__PURE__*/o.jsxs(O,{children:[/*#__PURE__*/o.jsx(n.Transition,{isOpen:!s,unmountOnExit:!0,fade:!0,children:/*#__PURE__*/o.jsx(r.CheckCircleIcon,{color:I?y.colors.green500:y.colors.success,style:{marginTop:"4px"}})}),/*#__PURE__*/o.jsx(n.Transition,{isOpen:s,unmountOnExit:!0,fade:!0,children:/*#__PURE__*/o.jsx(n.IconButton,{onClick:w,variant:n.ButtonVariant.link,color:n.ButtonColor.subtle,"aria-label":b.dropzone.deleteFile+" "+c.name,icon:/*#__PURE__*/o.jsx(r.DeleteIcon,{})})})]})};return t.useEffect(function(){var e;S(/*#__PURE__*/o.jsx(C,{status:null==c||null==(e=c.processor)?void 0:e.status}))},[null==c||null==(l=c.processor)?void 0:l.status]),/*#__PURE__*/o.jsx(n.InverseContext.Provider,{value:{isInverse:I},children:/*#__PURE__*/o.jsxs(L,{borderRadius:n.CardBorderRadius.small,cornerTreatment:n.CardCornerTreatment.all,isInverse:I,theme:y,file:c,"data-testid":e.testId,ref:i,role:c.errors?"alert":"",children:[/*#__PURE__*/o.jsxs(H,p({theme:y,behavior:n.FlexBehavior.container,alignItems:n.FlexAlignItems.center},h,{children:[/*#__PURE__*/o.jsx(n.Flex,{behavior:n.FlexBehavior.item,alignItems:n.FlexAlignItems.center,style:E,children:/*#__PURE__*/o.jsx(T,{file:c,isInverse:I,theme:y,thumbnails:x})}),/*#__PURE__*/o.jsx(P,{xs:!0,behavior:n.FlexBehavior.item,theme:y,children:c.name}),c.processor&&"pending"===c.processor.status&&/*#__PURE__*/o.jsx(n.Flex,{role:"progressbar",style:{marginLeft:"auto"},behavior:n.FlexBehavior.item,children:c.processor.percent}),/*#__PURE__*/o.jsx(n.Flex,{behavior:n.FlexBehavior.item,children:j})]})),c.errors&&/*#__PURE__*/o.jsx(M,{theme:y,isInverse:I,children:c.errors.slice(0,1).map(function(e){var n=e.code,r=function(e,n,r){var o=Array.isArray(n.accept)&&1===n.accept.length?n.accept[0]:n.accept,t=Array.isArray(o)?"one of "+o.join(", "):o;switch(e.code){case"file-too-large":return p({},e,{message:e.message+" "+D(n.maxSize,2,r)+"."});case"file-too-small":return p({},e,{message:e.message+" "+D(n.minSize,2,r)+"."});case"file-invalid-type":return p({},e,{message:e.message+": "+t});default:return e}}(p({code:n},f(e,R),b.dropzone.errors[n]),{accept:a,minSize:m,maxSize:d},b.dropzone.bytes),t=r.header,i=r.message;/*#__PURE__*/return o.jsxs(s.default.Fragment,{children:[/*#__PURE__*/o.jsx(V,{style:{color:I?y.colors.red500:y.colors.danger},children:void 0===t?"":t}),/*#__PURE__*/o.jsx(N,{children:i})]},n)})})]})})}),q=["accept","buttonColor","buttonText","containerStyle","disabled","dropzoneOptions","helperMessage","id","inputSize","isInverse","isLabelVisuallyHidden","labelStyle","labelText","maxFiles","minFiles","maxSize","minSize","multiple","noDrag","onSendFile","onDeleteFile","onRemoveFile","sendFiles","testId","thumbnails"];!function(e){e.error="error",e.dragAccept="dragAccept",e.dragReject="dragReject",e.dragActive="dragActive",e.default="default"}(B||(B={}));var G=function(e,n){return null!=e?e:n},W=n.styled(n.Flex)(j||(j=m(["\n flex-direction: column;\n align-items: ",";\n justify-content: ",";\n text-align: ",";\n padding: ",";\n border-radius: ",";\n border: ",";\n\n border-style: ",";\n background-color: ",";\n outline: none;\n transition: ",";\n"])),function(e){return e.noDrag?"left":"center"},function(e){return e.noDrag?"left":"center"},function(e){return e.noDrag?"left":"center"},function(e){return e.noDrag?"0px":"24px"},function(e){var n=e.theme;return e.noDrag?n.borderRadiusNone:n.borderRadiusSmall},function(e){var n=e.dragState,r=void 0===n?B.default:n,o=e.theme,t=e.isInverse;return e.noDrag?"0px":r===B.dragReject||r===B.error?(r===B.error?"1px":"2px")+" dashed "+function(e,n,r){return r?e===B.error?n.colors.red500:n.colors.red400:n.colors.danger}(r,o,t):r===B.dragActive?"2px dashed "+o.colors.blue500:r===B.dragAccept?"2px dashed "+o.colors.green500:"2px dashed "+(t?o.colors.neutral800:o.colors.neutral300)},function(e){var n=e.dragState;return(void 0===n?B.default:n)===B.error?"solid":"dashed"},function(e){var n=e.theme;return e.noDrag?"transparent":e.isInverse?i.transparentize(.6,n.colors.neutral1200):n.colors.neutral100},function(e){return"border "+(e.noDrag?0:".24s")+" ease-in-out"}),Z=n.styled.span(S||(S=m(["\n color: ",";\n display: block;\n font-size: 14px;\n margin: -8px 0 16px 0;\n"])),function(e){var n=e.theme;return e.isInverse?n.colors.neutral500:n.colors.neutral700}),K=n.styled.div(F||(F=m(["\n color: ",";\n margin: 0 0 24px 0;\n font-size: ",";\n line-height: ",";\n font-weight: 500;\n padding: ",";\n"])),function(e){var n=e.theme;return e.isInverse?n.colors.neutral0:n.colors.brand.navy},function(e){return e.theme.typeScale.size02.fontSize},function(e){return e.theme.typeScale.size02.lineHeight},function(e){return e.theme.spaceScale.spacing01}),Y=n.styled.ul(w||(w=m(["\n list-style: none;\n padding: 0;\n"]))),J=n.styled.li(C||(C=m([""])));e.Dropzone=/*#__PURE__*/s.default.forwardRef(function(e,i){var a=e.accept,c=e.buttonColor,u=void 0===c?n.ButtonColor.primary:c,d=e.buttonText,m=e.containerStyle,g=e.disabled,v=e.dropzoneOptions,x=void 0===v?{multiple:!0}:v,h=e.helperMessage,y=e.id,b=e.inputSize,I=e.isInverse,z=e.isLabelVisuallyHidden,j=e.labelStyle,S=e.labelText,F=e.maxFiles,w=e.minFiles,C=e.maxSize,D=e.minSize,k=e.multiple,R=void 0===k||k,A=e.noDrag,O=void 0!==A&&A,T=e.onSendFile,E=e.onDeleteFile,M=e.onRemoveFile,H=e.sendFiles,P=void 0!==H&&H,L=e.testId,V=e.thumbnails,N=void 0===V||V,Q=f(e,q),X=s.default.useState([]),$=X[0],_=X[1],ee=s.default.useState(null),ne=ee[0],re=ee[1],oe=s.default.useState(""),te=oe[0],ie=oe[1],le=n.useIsInverse(I),ae=s.default.useContext(n.ThemeContext),se=s.default.useContext(n.I18nContext),ce=n.useGenerateId(y),ue=n.useGenerateId(ce+"-helper"),de=s.default.useRef(null),pe=s.default.useCallback(function(e,n){var r=[].concat(e.map(function(e){return Object.assign(e,{preview:URL.createObjectURL(e)})}),n.map(function(e){return Object.assign(e.file,{errors:e.errors})}));if(_(function(e){return[].concat(e,r)}),e.length>0){var o=e.map(function(e){return e.name}).join(", "),t=1===e.length?se.dropzone.fileAdded.replace(/\{fileName\}/g,o):se.dropzone.filesAdded.replace(/\{count\}/g,e.length.toString()).replace(/\{fileNames\}/g,o);ie(t)}de.current&&de.current.focus()},[se]),fe=l.useDropzone(p({noClick:!0,disabled:g,multiple:R,maxSize:C,minSize:D,accept:a,onDrop:pe,noDrag:O},x)),me=fe.getInputProps,ge=fe.getRootProps,ve=fe.isDragAccept,xe=fe.isDragActive,he=fe.isDragReject,ye=fe.open,be=fe.inputRef;t.useImperativeHandle(i,function(){return be.current});var Ie=me({id:ce}),ze=B.default;ne?ze=B.error:ve?ze=B.dragAccept:he?ze=B.dragReject:xe&&(ze=B.dragActive);var je=function(e){_(function(n){return n.filter(function(n){return n!==e})}),M&&"function"==typeof M&&M(e);var n=se.dropzone.fileRemoved.replace(/\{fileName\}/g,e.name);ie(n),de.current&&de.current.focus()},Se=function(e){_(function(n){return n.filter(function(n){return n!==e})}),E&&"function"==typeof E&&E(e);var n=se.dropzone.fileDeleted.replace(/\{fileName\}/g,e.name);ie(n),de.current&&de.current.focus()},Fe=function(e){if(_(function(n){return n.map(function(n){return n===e.file?Object.assign(n,{processor:p({},n.processor,{percent:e.percent+"%",status:"pending"})}):n})}),e.percent>0&&e.percent%25==0){var n=se.dropzone.fileUploading.replace(/\{fileName\}/g,e.file.name).replace(/\{percent\}/g,e.percent.toString());ie(n)}},we=function(e){_(function(n){return n.map(function(n){return n===e.file?Object.assign(n,{processor:p({},n.processor,{percent:"",status:"finished"})}):n})});var n=se.dropzone.fileUploaded.replace(/\{fileName\}/g,e.file.name);ie(n)},Ce=function(e){_(function(n){return n.map(function(n){return n===e.file?Object.assign(n,{errors:e.errors,processor:p({},n.processor,{status:"error"})}):n})})};return s.default.useEffect(function(){return function(){$.forEach(function(e){return e.preview&&URL.revokeObjectURL(e.preview)})}},[$]),s.default.useEffect(function(){var e=w&&$.length<w,n=F&&$.length>F,r=null;n?r="too-many-files":e&&(r="too-few-files"),re(function(e,n){if(null===e)return null;var r=se.dropzone.errors[e];switch(e){case"too-many-files":return r.message+" "+n.maxFiles+" "+se.dropzone.files+".";case"too-few-files":return r.message+" "+n.minFiles+" "+se.dropzone.files+".";default:return r.message}}(r,{minFiles:w,maxFiles:F})),P&&$.length>0&&!n&&!e&&_(function(e){return e.map(function(e){return e.errors||e.processor||!T||T({file:e,onError:Ce,onFinish:we,onProgress:Fe}),e})})},[P,$.length,T,F,w,se.dropzone.errors,se.dropzone.files]),/*#__PURE__*/o.jsxs(n.InverseContext.Provider,{value:{isInverse:le},children:[/*#__PURE__*/o.jsxs(n.FormFieldContainer,{actionable:!1,containerStyle:m,errorMessage:ne,fieldId:ce,inputSize:b,isInverse:le,isLabelVisuallyHidden:z,labelStyle:p({color:le?ae.colors.neutral0:ae.colors.brand.navy},j),labelText:S,messageStyle:{minHeight:0},"data-testid":L,children:[/*#__PURE__*/o.jsx(Z,{id:ue,theme:ae,isInverse:le,children:h}),/*#__PURE__*/o.jsxs(W,p({behavior:n.FlexBehavior.container,dragState:ze,isInverse:le,noDrag:O,theme:ae},ge(),Q,{testId:L,tabIndex:-1,children:[/*#__PURE__*/o.jsx("input",{ref:be,type:Ie.type,accept:Ie.accept,autoComplete:Ie.autoComplete,id:Ie.id,multiple:Ie.multiple,onChange:Ie.onChange,onClick:Ie.onClick,style:Ie.style,tabIndex:Ie.tabIndex,"data-testid":"file-input"}),O?/*#__PURE__*/o.jsx(n.Flex,{xs:!0,behavior:n.FlexBehavior.item,children:/*#__PURE__*/o.jsx(n.Button,{color:u,disabled:g,isInverse:le,onClick:ye,style:{margin:0},ref:de,"aria-describedby":h?ue:void 0,children:G(d,se.dropzone.browseFiles)})}):/*#__PURE__*/o.jsxs(n.Flex,{behavior:n.FlexBehavior.item,children:[/*#__PURE__*/o.jsx(r.CloudUploadIcon,{"aria-hidden":"true",color:le?ae.colors.neutral0:ae.colors.neutral700,size:48}),/*#__PURE__*/o.jsx(K,{isInverse:le,theme:ae,children:se.dropzone.dragMessage}),/*#__PURE__*/o.jsx(n.Button,{color:u,disabled:g,isInverse:le,onClick:ye,style:{margin:0},variant:n.ButtonVariant.solid,ref:de,"aria-describedby":h?ue:void 0,children:G(d,se.dropzone.browseFiles)})]})]}))]}),/*#__PURE__*/o.jsx(Y,{children:$.map(function(e){/*#__PURE__*/return o.jsx(J,{children:/*#__PURE__*/o.jsx(U,{accept:a,file:e,isInverse:le,maxSize:C,minSize:D,onDeleteFile:Se,onRemoveFile:je,thumbnails:N})},e.name)})}),/*#__PURE__*/o.jsx(n.VisuallyHidden,{children:/*#__PURE__*/o.jsx(n.Announce,{children:te})})]})}),e.FileIcon=d});
|
|
2
2
|
//# sourceMappingURL=fileuploader.umd.js.map
|