@veeqo/ui 12.4.0-beta-8 → 12.4.0-beta-9

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.
@@ -22,16 +22,15 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
22
22
 
23
23
  var React__default = /*#__PURE__*/_interopDefaultCompat(React);
24
24
 
25
- const UploadFile = React.forwardRef(({ id, name, maxBytes = 1000000, format = constants.FileSizeUnit.MB, fileTypes, disabled, multiple, label = multiple ? 'Upload files' : 'Upload file', hideUploadedFiles = false, onMaxFilesExceeded, maxFiles = constants.DEFAULT_MAXIMUM_MULTIPLE_FILES, disabledMessage, errorMessage, isDirty, ...otherProps }, outerRef) => {
26
- var _a;
25
+ const UploadFile = React.forwardRef(({ id, name, maxBytes = 1000000, format = constants.FileSizeUnit.MB, fileTypes, disabled, multiple, label = multiple ? 'Upload files' : 'Upload file', hideUploadedFiles = false, onMaxFilesExceeded, maxFiles = constants.DEFAULT_MAXIMUM_MULTIPLE_FILES, disabledMessage, errorMessage, ...otherProps }, outerRef) => {
26
+ var _a, _b;
27
27
  const { inputRef, fileList, setFileList, onCancel, removeFileFromList, clearFileSelection } = useUploadFile.useUploadFile();
28
- useValidateInput.useValidateInput({
28
+ const { validationCount } = useValidateInput.useValidateInput({
29
29
  customErrorMessage: errorMessage,
30
30
  inputRef,
31
31
  fileList,
32
32
  fileTypes,
33
33
  maxBytes,
34
- isDirty,
35
34
  });
36
35
  React.useImperativeHandle(outerRef, () => inputRef.current, [inputRef]);
37
36
  const [isDragOver, setIsDragOver] = React.useState(false);
@@ -110,13 +109,15 @@ const UploadFile = React.forwardRef(({ id, name, maxBytes = 1000000, format = co
110
109
  maxSizeCopy,
111
110
  React__default.default.createElement("br", null),
112
111
  acceptedTypesCopy),
113
- React__default.default.createElement(styled$1.DropZoneContainer, { isDirty: !!isDirty, hasUserProvidedNoFiles: hasUserProvidedNoFiles, isDragOver: isDragOver, "data-testid": "drop-zone-container", onDrop: onDrop, onDragEnter: onDragEnter, onDragOver: onDragOver, onDragLeave: onDragLeave },
112
+ React__default.default.createElement(styled$1.DropZoneContainer, { hasUserProvidedNoFiles: hasUserProvidedNoFiles, isDragOver: isDragOver, "data-testid": "drop-zone-container", onDrop: onDrop, onDragEnter: onDragEnter, onDragOver: onDragOver, onDragLeave: onDragLeave },
114
113
  isDragOver ? React__default.default.createElement(DropCopy.DropCopy, null) : React__default.default.createElement(UploadCopy.UploadCopy, null),
115
114
  React__default.default.createElement("input", { ref: inputRef, id: id, type: "file", accept: acceptedTypesForInputEl, name: name, disabled: disabled, multiple: multiple, ...otherProps })))),
116
115
  React__default.default.createElement(FlexCol.FlexCol, null,
117
- isDirty && hasUserProvidedNoFiles && (React__default.default.createElement(FlexRow.FlexRow, null,
116
+ ((_a = inputRef === null || inputRef === undefined ? undefined : inputRef.current) === null || _a === undefined ? undefined : _a.validity.valid) === false &&
117
+ hasUserProvidedNoFiles &&
118
+ !!validationCount && (React__default.default.createElement(FlexRow.FlexRow, null,
118
119
  React__default.default.createElement(CriticalIcon.ReactComponent, { width: 16, height: 16, color: index.theme.colors.secondary.red.base }),
119
- React__default.default.createElement(styled.Error, null, (_a = inputRef.current) === null || _a === undefined ? undefined : _a.validationMessage))),
120
+ React__default.default.createElement(styled.Error, null, (_b = inputRef.current) === null || _b === undefined ? undefined : _b.validationMessage))),
120
121
  disabledMessage && (React__default.default.createElement(FlexRow.FlexRow, { id: `${id}-disabled` },
121
122
  React__default.default.createElement(LockIcon.ReactComponent, { width: 16, height: 16, color: index.theme.colors.neutral.ink.light }),
122
123
  React__default.default.createElement(styled.Disabled, null, disabledMessage))),
@@ -1 +1 @@
1
- {"version":3,"file":"UploadFile.cjs","sources":["../../../src/components/UploadFile/UploadFile.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useState,\n DragEvent,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport { theme } from 'Theme';\nimport { CriticalIcon, LockIcon } from '../../icons';\nimport { DropZoneContainer } from './styled';\nimport { FileSizeUnit, DEFAULT_MAXIMUM_MULTIPLE_FILES } from './constants';\nimport { UploadCopy } from './components/UploadCopy/UploadCopy';\nimport { DropCopy } from './components/DropCopy/DropCopy';\nimport { getFileSizeString, getTypePropForInputEl, getValidTypesString } from './utils';\nimport { UploadFileProps } from './types';\nimport { Disabled, Error, Hint, Label, RootStack } from '../../hoc/withLabels/styled';\nimport { UploadedFile } from './components/UploadedFile/UploadedFile';\nimport { FlexCol } from '../Flex/FlexCol';\nimport { FlexRow } from '../Flex/FlexRow';\nimport { useUploadFile } from './hooks/useUploadFile';\nimport { useValidateInput } from './hooks/useValidateInput';\n\nexport const UploadFile = forwardRef<HTMLInputElement, UploadFileProps>(\n (\n {\n id,\n name,\n maxBytes = 1000000,\n format = FileSizeUnit.MB,\n fileTypes,\n disabled,\n multiple,\n label = multiple ? 'Upload files' : 'Upload file',\n hideUploadedFiles = false,\n onMaxFilesExceeded,\n maxFiles = DEFAULT_MAXIMUM_MULTIPLE_FILES,\n disabledMessage,\n errorMessage,\n isDirty,\n ...otherProps\n }: UploadFileProps,\n outerRef,\n ) => {\n const { inputRef, fileList, setFileList, onCancel, removeFileFromList, clearFileSelection } =\n useUploadFile();\n\n useValidateInput({\n customErrorMessage: errorMessage,\n inputRef,\n fileList,\n fileTypes,\n maxBytes,\n isDirty,\n });\n\n useImperativeHandle(outerRef, () => inputRef.current!, [inputRef]);\n\n const [isDragOver, setIsDragOver] = useState(false);\n\n // Computed properties based on params\n const maxSizeCopy = getFileSizeString({ maxBytes, format });\n const acceptedTypesCopy = getValidTypesString({ fileTypes });\n const acceptedTypesForInputEl = getTypePropForInputEl({ fileTypes });\n\n const validateMaximumFiles = useCallback(\n (files: FileList | null | undefined) => {\n if (files?.length && files?.length > maxFiles) {\n clearFileSelection();\n onMaxFilesExceeded?.();\n return false;\n }\n return true;\n },\n [clearFileSelection, maxFiles, onMaxFilesExceeded],\n );\n\n // Processes file and updates the UI appropriately:\n const updateFiles = useCallback(\n (files: FileList) => {\n if (!files.length) {\n return;\n }\n\n setFileList(files);\n },\n [setFileList],\n );\n\n // For focussing of input el and updating drop UI\n const onDragEnter = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(true);\n inputRef.current?.focus();\n };\n\n // For unfocussing of input el and updating drop UI\n const onDragLeave = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(false);\n };\n\n // Prevents default browser behaviour\n const onDragOver = (event: DragEvent<HTMLElement>) => event.preventDefault();\n\n // Process file when dropped into eligible area\n const onDrop = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(false);\n // Prevent reactions on dragging events that do not contain files\n if (!event.dataTransfer.files.length) return;\n\n const canUpdateFiles = validateMaximumFiles(event.dataTransfer.files);\n if (canUpdateFiles) {\n updateFiles(event.dataTransfer.files);\n }\n };\n\n // Updates UI based on a native file input change. Attached via useEffect below\n const onChange = useCallback(() => {\n const canUpdateFiles = validateMaximumFiles(inputRef?.current?.files);\n const files = inputRef?.current?.files;\n if (canUpdateFiles && files) {\n updateFiles(files);\n } else if (fileList) {\n updateFiles(fileList);\n }\n }, [validateMaximumFiles, inputRef, fileList, updateFiles]);\n\n useEffect(() => {\n const ref = inputRef?.current;\n ref?.addEventListener('change', onChange);\n ref?.addEventListener('cancel', onCancel);\n\n return () => {\n ref?.removeEventListener('change', onChange);\n ref?.removeEventListener('cancel', onCancel);\n };\n }, [onChange, onCancel, inputRef]);\n\n const hasUserProvidedNoFiles = !fileList?.length;\n\n return (\n <RootStack spacing=\"xs\" alignX=\"stretch\">\n <Label htmlFor={id}>\n {label}\n <FlexCol>\n <Hint>\n {maxSizeCopy}\n <br />\n {acceptedTypesCopy}\n </Hint>\n <DropZoneContainer\n isDirty={!!isDirty}\n hasUserProvidedNoFiles={hasUserProvidedNoFiles}\n isDragOver={isDragOver}\n data-testid=\"drop-zone-container\"\n onDrop={onDrop}\n onDragEnter={onDragEnter}\n onDragOver={onDragOver}\n onDragLeave={onDragLeave}\n >\n {isDragOver ? <DropCopy /> : <UploadCopy />}\n <input\n ref={inputRef}\n id={id}\n type=\"file\"\n accept={acceptedTypesForInputEl}\n name={name}\n disabled={disabled}\n multiple={multiple}\n {...otherProps}\n />\n </DropZoneContainer>\n </FlexCol>\n </Label>\n <FlexCol>\n {isDirty && hasUserProvidedNoFiles && (\n <FlexRow>\n <CriticalIcon width={16} height={16} color={theme.colors.secondary.red.base} />\n <Error>{inputRef.current?.validationMessage}</Error>\n </FlexRow>\n )}\n {disabledMessage && (\n <FlexRow id={`${id}-disabled`}>\n <LockIcon width={16} height={16} color={theme.colors.neutral.ink.light} />\n <Disabled>{disabledMessage}</Disabled>\n </FlexRow>\n )}\n {!hideUploadedFiles &&\n fileList && [\n Array.from(fileList).map((file) => {\n return (\n <UploadedFile\n key={`${file.name}`}\n file={file}\n removeFileFromList={removeFileFromList}\n disabled={disabled}\n format={format}\n maxBytes={maxBytes}\n fileTypes={fileTypes}\n />\n );\n }),\n ]}\n </FlexCol>\n </RootStack>\n );\n },\n);\n"],"names":["forwardRef","FileSizeUnit","DEFAULT_MAXIMUM_MULTIPLE_FILES","useUploadFile","useValidateInput","useImperativeHandle","useState","getFileSizeString","getValidTypesString","getTypePropForInputEl","useCallback","useEffect","React","RootStack","Label","FlexCol","Hint","DropZoneContainer","DropCopy","UploadCopy","FlexRow","CriticalIcon","theme","Error","LockIcon","Disabled","UploadedFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuBO,MAAM,UAAU,GAAGA,gBAAU,CAClC,CACE,EACE,EAAE,EACF,IAAI,EACJ,QAAQ,GAAG,OAAO,EAClB,MAAM,GAAGC,sBAAY,CAAC,EAAE,EACxB,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,KAAK,GAAG,QAAQ,GAAG,cAAc,GAAG,aAAa,EACjD,iBAAiB,GAAG,KAAK,EACzB,kBAAkB,EAClB,QAAQ,GAAGC,wCAA8B,EACzC,e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;"}
1
+ {"version":3,"file":"UploadFile.cjs","sources":["../../../src/components/UploadFile/UploadFile.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useState,\n DragEvent,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport { theme } from 'Theme';\nimport { CriticalIcon, LockIcon } from '../../icons';\nimport { DropZoneContainer } from './styled';\nimport { FileSizeUnit, DEFAULT_MAXIMUM_MULTIPLE_FILES } from './constants';\nimport { UploadCopy } from './components/UploadCopy/UploadCopy';\nimport { DropCopy } from './components/DropCopy/DropCopy';\nimport { getFileSizeString, getTypePropForInputEl, getValidTypesString } from './utils';\nimport { UploadFileProps } from './types';\nimport { Disabled, Error, Hint, Label, RootStack } from '../../hoc/withLabels/styled';\nimport { UploadedFile } from './components/UploadedFile/UploadedFile';\nimport { FlexCol } from '../Flex/FlexCol';\nimport { FlexRow } from '../Flex/FlexRow';\nimport { useUploadFile } from './hooks/useUploadFile';\nimport { useValidateInput } from './hooks/useValidateInput';\n\nexport const UploadFile = forwardRef<HTMLInputElement, UploadFileProps>(\n (\n {\n id,\n name,\n maxBytes = 1000000,\n format = FileSizeUnit.MB,\n fileTypes,\n disabled,\n multiple,\n label = multiple ? 'Upload files' : 'Upload file',\n hideUploadedFiles = false,\n onMaxFilesExceeded,\n maxFiles = DEFAULT_MAXIMUM_MULTIPLE_FILES,\n disabledMessage,\n errorMessage,\n ...otherProps\n }: UploadFileProps,\n outerRef,\n ) => {\n const { inputRef, fileList, setFileList, onCancel, removeFileFromList, clearFileSelection } =\n useUploadFile();\n\n const { validationCount } = useValidateInput({\n customErrorMessage: errorMessage,\n inputRef,\n fileList,\n fileTypes,\n maxBytes,\n });\n\n useImperativeHandle(outerRef, () => inputRef.current!, [inputRef]);\n\n const [isDragOver, setIsDragOver] = useState(false);\n\n // Computed properties based on params\n const maxSizeCopy = getFileSizeString({ maxBytes, format });\n const acceptedTypesCopy = getValidTypesString({ fileTypes });\n const acceptedTypesForInputEl = getTypePropForInputEl({ fileTypes });\n\n const validateMaximumFiles = useCallback(\n (files: FileList | null | undefined) => {\n if (files?.length && files?.length > maxFiles) {\n clearFileSelection();\n onMaxFilesExceeded?.();\n return false;\n }\n return true;\n },\n [clearFileSelection, maxFiles, onMaxFilesExceeded],\n );\n\n // Processes file and updates the UI appropriately:\n const updateFiles = useCallback(\n (files: FileList) => {\n if (!files.length) {\n return;\n }\n\n setFileList(files);\n },\n [setFileList],\n );\n\n // For focussing of input el and updating drop UI\n const onDragEnter = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(true);\n inputRef.current?.focus();\n };\n\n // For unfocussing of input el and updating drop UI\n const onDragLeave = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(false);\n };\n\n // Prevents default browser behaviour\n const onDragOver = (event: DragEvent<HTMLElement>) => event.preventDefault();\n\n // Process file when dropped into eligible area\n const onDrop = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(false);\n // Prevent reactions on dragging events that do not contain files\n if (!event.dataTransfer.files.length) return;\n\n const canUpdateFiles = validateMaximumFiles(event.dataTransfer.files);\n if (canUpdateFiles) {\n updateFiles(event.dataTransfer.files);\n }\n };\n\n // Updates UI based on a native file input change. Attached via useEffect below\n const onChange = useCallback(() => {\n const canUpdateFiles = validateMaximumFiles(inputRef?.current?.files);\n const files = inputRef?.current?.files;\n if (canUpdateFiles && files) {\n updateFiles(files);\n } else if (fileList) {\n updateFiles(fileList);\n }\n }, [validateMaximumFiles, inputRef, fileList, updateFiles]);\n\n useEffect(() => {\n const ref = inputRef?.current;\n ref?.addEventListener('change', onChange);\n ref?.addEventListener('cancel', onCancel);\n\n return () => {\n ref?.removeEventListener('change', onChange);\n ref?.removeEventListener('cancel', onCancel);\n };\n }, [onChange, onCancel, inputRef]);\n\n const hasUserProvidedNoFiles = !fileList?.length;\n\n return (\n <RootStack spacing=\"xs\" alignX=\"stretch\">\n <Label htmlFor={id}>\n {label}\n <FlexCol>\n <Hint>\n {maxSizeCopy}\n <br />\n {acceptedTypesCopy}\n </Hint>\n <DropZoneContainer\n hasUserProvidedNoFiles={hasUserProvidedNoFiles}\n isDragOver={isDragOver}\n data-testid=\"drop-zone-container\"\n onDrop={onDrop}\n onDragEnter={onDragEnter}\n onDragOver={onDragOver}\n onDragLeave={onDragLeave}\n >\n {isDragOver ? <DropCopy /> : <UploadCopy />}\n <input\n ref={inputRef}\n id={id}\n type=\"file\"\n accept={acceptedTypesForInputEl}\n name={name}\n disabled={disabled}\n multiple={multiple}\n {...otherProps}\n />\n </DropZoneContainer>\n </FlexCol>\n </Label>\n <FlexCol>\n {inputRef?.current?.validity.valid === false &&\n hasUserProvidedNoFiles &&\n !!validationCount && (\n <FlexRow>\n <CriticalIcon width={16} height={16} color={theme.colors.secondary.red.base} />\n <Error>{inputRef.current?.validationMessage}</Error>\n </FlexRow>\n )}\n {disabledMessage && (\n <FlexRow id={`${id}-disabled`}>\n <LockIcon width={16} height={16} color={theme.colors.neutral.ink.light} />\n <Disabled>{disabledMessage}</Disabled>\n </FlexRow>\n )}\n {!hideUploadedFiles &&\n fileList && [\n Array.from(fileList).map((file) => {\n return (\n <UploadedFile\n key={`${file.name}`}\n file={file}\n removeFileFromList={removeFileFromList}\n disabled={disabled}\n format={format}\n maxBytes={maxBytes}\n fileTypes={fileTypes}\n />\n );\n }),\n ]}\n </FlexCol>\n </RootStack>\n );\n },\n);\n"],"names":["forwardRef","FileSizeUnit","DEFAULT_MAXIMUM_MULTIPLE_FILES","useUploadFile","useValidateInput","useImperativeHandle","useState","getFileSizeString","getValidTypesString","getTypePropForInputEl","useCallback","useEffect","React","RootStack","Label","FlexCol","Hint","DropZoneContainer","DropCopy","UploadCopy","FlexRow","CriticalIcon","theme","Error","LockIcon","Disabled","UploadedFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuBO,MAAM,UAAU,GAAGA,gBAAU,CAClC,CACE,EACE,EAAE,EACF,IAAI,EACJ,QAAQ,GAAG,OAAO,E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KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAI;AAChC,oBAAA,QACEb,sBAAC,CAAA,aAAA,CAAAc,yBAAY,EACX,EAAA,GAAG,EAAE,CAAG,EAAA,IAAI,CAAC,IAAI,EAAE,EACnB,IAAI,EAAE,IAAI,EACV,kBAAkB,EAAE,kBAAkB,EACtC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EAAA,CACpB;AAEN,iBAAC,CAAC;aACH,CACK,CACA;AAEhB,CAAC;;;;"}
@@ -9,23 +9,22 @@ import { DropCopy } from './components/DropCopy/DropCopy.js';
9
9
  import { getValidTypesString } from './utils/getValidTypesString/getValidTypesString.js';
10
10
  import { getFileSizeString } from './utils/getFileSizeString/getFileSizeString.js';
11
11
  import { getTypePropForInputEl } from './utils/getTypePropForInputEl/getTypePropForInputEl.js';
12
- import { RootStack, Label, Hint, Error, Disabled } from '../../hoc/withLabels/styled.js';
12
+ import { RootStack, Label, Hint, Disabled, Error } from '../../hoc/withLabels/styled.js';
13
13
  import { UploadedFile } from './components/UploadedFile/UploadedFile.js';
14
14
  import { FlexCol } from '../Flex/FlexCol/FlexCol.js';
15
15
  import { FlexRow } from '../Flex/FlexRow/FlexRow.js';
16
16
  import { useUploadFile } from './hooks/useUploadFile/useUploadFile.js';
17
17
  import { useValidateInput } from './hooks/useValidateInput/useValidateInput.js';
18
18
 
19
- const UploadFile = forwardRef(({ id, name, maxBytes = 1000000, format = FileSizeUnit.MB, fileTypes, disabled, multiple, label = multiple ? 'Upload files' : 'Upload file', hideUploadedFiles = false, onMaxFilesExceeded, maxFiles = DEFAULT_MAXIMUM_MULTIPLE_FILES, disabledMessage, errorMessage, isDirty, ...otherProps }, outerRef) => {
20
- var _a;
19
+ const UploadFile = forwardRef(({ id, name, maxBytes = 1000000, format = FileSizeUnit.MB, fileTypes, disabled, multiple, label = multiple ? 'Upload files' : 'Upload file', hideUploadedFiles = false, onMaxFilesExceeded, maxFiles = DEFAULT_MAXIMUM_MULTIPLE_FILES, disabledMessage, errorMessage, ...otherProps }, outerRef) => {
20
+ var _a, _b;
21
21
  const { inputRef, fileList, setFileList, onCancel, removeFileFromList, clearFileSelection } = useUploadFile();
22
- useValidateInput({
22
+ const { validationCount } = useValidateInput({
23
23
  customErrorMessage: errorMessage,
24
24
  inputRef,
25
25
  fileList,
26
26
  fileTypes,
27
27
  maxBytes,
28
- isDirty,
29
28
  });
30
29
  useImperativeHandle(outerRef, () => inputRef.current, [inputRef]);
31
30
  const [isDragOver, setIsDragOver] = useState(false);
@@ -104,13 +103,15 @@ const UploadFile = forwardRef(({ id, name, maxBytes = 1000000, format = FileSize
104
103
  maxSizeCopy,
105
104
  React__default.createElement("br", null),
106
105
  acceptedTypesCopy),
107
- React__default.createElement(DropZoneContainer, { isDirty: !!isDirty, hasUserProvidedNoFiles: hasUserProvidedNoFiles, isDragOver: isDragOver, "data-testid": "drop-zone-container", onDrop: onDrop, onDragEnter: onDragEnter, onDragOver: onDragOver, onDragLeave: onDragLeave },
106
+ React__default.createElement(DropZoneContainer, { hasUserProvidedNoFiles: hasUserProvidedNoFiles, isDragOver: isDragOver, "data-testid": "drop-zone-container", onDrop: onDrop, onDragEnter: onDragEnter, onDragOver: onDragOver, onDragLeave: onDragLeave },
108
107
  isDragOver ? React__default.createElement(DropCopy, null) : React__default.createElement(UploadCopy, null),
109
108
  React__default.createElement("input", { ref: inputRef, id: id, type: "file", accept: acceptedTypesForInputEl, name: name, disabled: disabled, multiple: multiple, ...otherProps })))),
110
109
  React__default.createElement(FlexCol, null,
111
- isDirty && hasUserProvidedNoFiles && (React__default.createElement(FlexRow, null,
110
+ ((_a = inputRef === null || inputRef === undefined ? undefined : inputRef.current) === null || _a === undefined ? undefined : _a.validity.valid) === false &&
111
+ hasUserProvidedNoFiles &&
112
+ !!validationCount && (React__default.createElement(FlexRow, null,
112
113
  React__default.createElement(CriticalIcon, { width: 16, height: 16, color: theme.colors.secondary.red.base }),
113
- React__default.createElement(Error, null, (_a = inputRef.current) === null || _a === undefined ? undefined : _a.validationMessage))),
114
+ React__default.createElement(Error, null, (_b = inputRef.current) === null || _b === undefined ? undefined : _b.validationMessage))),
114
115
  disabledMessage && (React__default.createElement(FlexRow, { id: `${id}-disabled` },
115
116
  React__default.createElement(LockIcon, { width: 16, height: 16, color: theme.colors.neutral.ink.light }),
116
117
  React__default.createElement(Disabled, null, disabledMessage))),
@@ -1 +1 @@
1
- {"version":3,"file":"UploadFile.js","sources":["../../../src/components/UploadFile/UploadFile.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useState,\n DragEvent,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport { theme } from 'Theme';\nimport { CriticalIcon, LockIcon } from '../../icons';\nimport { DropZoneContainer } from './styled';\nimport { FileSizeUnit, DEFAULT_MAXIMUM_MULTIPLE_FILES } from './constants';\nimport { UploadCopy } from './components/UploadCopy/UploadCopy';\nimport { DropCopy } from './components/DropCopy/DropCopy';\nimport { getFileSizeString, getTypePropForInputEl, getValidTypesString } from './utils';\nimport { UploadFileProps } from './types';\nimport { Disabled, Error, Hint, Label, RootStack } from '../../hoc/withLabels/styled';\nimport { UploadedFile } from './components/UploadedFile/UploadedFile';\nimport { FlexCol } from '../Flex/FlexCol';\nimport { FlexRow } from '../Flex/FlexRow';\nimport { useUploadFile } from './hooks/useUploadFile';\nimport { useValidateInput } from './hooks/useValidateInput';\n\nexport const UploadFile = forwardRef<HTMLInputElement, UploadFileProps>(\n (\n {\n id,\n name,\n maxBytes = 1000000,\n format = FileSizeUnit.MB,\n fileTypes,\n disabled,\n multiple,\n label = multiple ? 'Upload files' : 'Upload file',\n hideUploadedFiles = false,\n onMaxFilesExceeded,\n maxFiles = DEFAULT_MAXIMUM_MULTIPLE_FILES,\n disabledMessage,\n errorMessage,\n isDirty,\n ...otherProps\n }: UploadFileProps,\n outerRef,\n ) => {\n const { inputRef, fileList, setFileList, onCancel, removeFileFromList, clearFileSelection } =\n useUploadFile();\n\n useValidateInput({\n customErrorMessage: errorMessage,\n inputRef,\n fileList,\n fileTypes,\n maxBytes,\n isDirty,\n });\n\n useImperativeHandle(outerRef, () => inputRef.current!, [inputRef]);\n\n const [isDragOver, setIsDragOver] = useState(false);\n\n // Computed properties based on params\n const maxSizeCopy = getFileSizeString({ maxBytes, format });\n const acceptedTypesCopy = getValidTypesString({ fileTypes });\n const acceptedTypesForInputEl = getTypePropForInputEl({ fileTypes });\n\n const validateMaximumFiles = useCallback(\n (files: FileList | null | undefined) => {\n if (files?.length && files?.length > maxFiles) {\n clearFileSelection();\n onMaxFilesExceeded?.();\n return false;\n }\n return true;\n },\n [clearFileSelection, maxFiles, onMaxFilesExceeded],\n );\n\n // Processes file and updates the UI appropriately:\n const updateFiles = useCallback(\n (files: FileList) => {\n if (!files.length) {\n return;\n }\n\n setFileList(files);\n },\n [setFileList],\n );\n\n // For focussing of input el and updating drop UI\n const onDragEnter = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(true);\n inputRef.current?.focus();\n };\n\n // For unfocussing of input el and updating drop UI\n const onDragLeave = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(false);\n };\n\n // Prevents default browser behaviour\n const onDragOver = (event: DragEvent<HTMLElement>) => event.preventDefault();\n\n // Process file when dropped into eligible area\n const onDrop = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(false);\n // Prevent reactions on dragging events that do not contain files\n if (!event.dataTransfer.files.length) return;\n\n const canUpdateFiles = validateMaximumFiles(event.dataTransfer.files);\n if (canUpdateFiles) {\n updateFiles(event.dataTransfer.files);\n }\n };\n\n // Updates UI based on a native file input change. Attached via useEffect below\n const onChange = useCallback(() => {\n const canUpdateFiles = validateMaximumFiles(inputRef?.current?.files);\n const files = inputRef?.current?.files;\n if (canUpdateFiles && files) {\n updateFiles(files);\n } else if (fileList) {\n updateFiles(fileList);\n }\n }, [validateMaximumFiles, inputRef, fileList, updateFiles]);\n\n useEffect(() => {\n const ref = inputRef?.current;\n ref?.addEventListener('change', onChange);\n ref?.addEventListener('cancel', onCancel);\n\n return () => {\n ref?.removeEventListener('change', onChange);\n ref?.removeEventListener('cancel', onCancel);\n };\n }, [onChange, onCancel, inputRef]);\n\n const hasUserProvidedNoFiles = !fileList?.length;\n\n return (\n <RootStack spacing=\"xs\" alignX=\"stretch\">\n <Label htmlFor={id}>\n {label}\n <FlexCol>\n <Hint>\n {maxSizeCopy}\n <br />\n {acceptedTypesCopy}\n </Hint>\n <DropZoneContainer\n isDirty={!!isDirty}\n hasUserProvidedNoFiles={hasUserProvidedNoFiles}\n isDragOver={isDragOver}\n data-testid=\"drop-zone-container\"\n onDrop={onDrop}\n onDragEnter={onDragEnter}\n onDragOver={onDragOver}\n onDragLeave={onDragLeave}\n >\n {isDragOver ? <DropCopy /> : <UploadCopy />}\n <input\n ref={inputRef}\n id={id}\n type=\"file\"\n accept={acceptedTypesForInputEl}\n name={name}\n disabled={disabled}\n multiple={multiple}\n {...otherProps}\n />\n </DropZoneContainer>\n </FlexCol>\n </Label>\n <FlexCol>\n {isDirty && hasUserProvidedNoFiles && (\n <FlexRow>\n <CriticalIcon width={16} height={16} color={theme.colors.secondary.red.base} />\n <Error>{inputRef.current?.validationMessage}</Error>\n </FlexRow>\n )}\n {disabledMessage && (\n <FlexRow id={`${id}-disabled`}>\n <LockIcon width={16} height={16} color={theme.colors.neutral.ink.light} />\n <Disabled>{disabledMessage}</Disabled>\n </FlexRow>\n )}\n {!hideUploadedFiles &&\n fileList && [\n Array.from(fileList).map((file) => {\n return (\n <UploadedFile\n key={`${file.name}`}\n file={file}\n removeFileFromList={removeFileFromList}\n disabled={disabled}\n format={format}\n maxBytes={maxBytes}\n fileTypes={fileTypes}\n />\n );\n }),\n ]}\n </FlexCol>\n </RootStack>\n );\n },\n);\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;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AAC,IAAI,EAAE,EACnB,IAAI,EAAE,IAAI,EACV,kBAAkB,EAAE,kBAAkB,EACtC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EAAA,CACpB;AAEN,iBAAC,CAAC;aACH,CACK,CACA;AAEhB,CAAC;;;;"}
1
+ {"version":3,"file":"UploadFile.js","sources":["../../../src/components/UploadFile/UploadFile.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useState,\n DragEvent,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport { theme } from 'Theme';\nimport { CriticalIcon, LockIcon } from '../../icons';\nimport { DropZoneContainer } from './styled';\nimport { FileSizeUnit, DEFAULT_MAXIMUM_MULTIPLE_FILES } from './constants';\nimport { UploadCopy } from './components/UploadCopy/UploadCopy';\nimport { DropCopy } from './components/DropCopy/DropCopy';\nimport { getFileSizeString, getTypePropForInputEl, getValidTypesString } from './utils';\nimport { UploadFileProps } from './types';\nimport { Disabled, Error, Hint, Label, RootStack } from '../../hoc/withLabels/styled';\nimport { UploadedFile } from './components/UploadedFile/UploadedFile';\nimport { FlexCol } from '../Flex/FlexCol';\nimport { FlexRow } from '../Flex/FlexRow';\nimport { useUploadFile } from './hooks/useUploadFile';\nimport { useValidateInput } from './hooks/useValidateInput';\n\nexport const UploadFile = forwardRef<HTMLInputElement, UploadFileProps>(\n (\n {\n id,\n name,\n maxBytes = 1000000,\n format = FileSizeUnit.MB,\n fileTypes,\n disabled,\n multiple,\n label = multiple ? 'Upload files' : 'Upload file',\n hideUploadedFiles = false,\n onMaxFilesExceeded,\n maxFiles = DEFAULT_MAXIMUM_MULTIPLE_FILES,\n disabledMessage,\n errorMessage,\n ...otherProps\n }: UploadFileProps,\n outerRef,\n ) => {\n const { inputRef, fileList, setFileList, onCancel, removeFileFromList, clearFileSelection } =\n useUploadFile();\n\n const { validationCount } = useValidateInput({\n customErrorMessage: errorMessage,\n inputRef,\n fileList,\n fileTypes,\n maxBytes,\n });\n\n useImperativeHandle(outerRef, () => inputRef.current!, [inputRef]);\n\n const [isDragOver, setIsDragOver] = useState(false);\n\n // Computed properties based on params\n const maxSizeCopy = getFileSizeString({ maxBytes, format });\n const acceptedTypesCopy = getValidTypesString({ fileTypes });\n const acceptedTypesForInputEl = getTypePropForInputEl({ fileTypes });\n\n const validateMaximumFiles = useCallback(\n (files: FileList | null | undefined) => {\n if (files?.length && files?.length > maxFiles) {\n clearFileSelection();\n onMaxFilesExceeded?.();\n return false;\n }\n return true;\n },\n [clearFileSelection, maxFiles, onMaxFilesExceeded],\n );\n\n // Processes file and updates the UI appropriately:\n const updateFiles = useCallback(\n (files: FileList) => {\n if (!files.length) {\n return;\n }\n\n setFileList(files);\n },\n [setFileList],\n );\n\n // For focussing of input el and updating drop UI\n const onDragEnter = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(true);\n inputRef.current?.focus();\n };\n\n // For unfocussing of input el and updating drop UI\n const onDragLeave = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(false);\n };\n\n // Prevents default browser behaviour\n const onDragOver = (event: DragEvent<HTMLElement>) => event.preventDefault();\n\n // Process file when dropped into eligible area\n const onDrop = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(false);\n // Prevent reactions on dragging events that do not contain files\n if (!event.dataTransfer.files.length) return;\n\n const canUpdateFiles = validateMaximumFiles(event.dataTransfer.files);\n if (canUpdateFiles) {\n updateFiles(event.dataTransfer.files);\n }\n };\n\n // Updates UI based on a native file input change. Attached via useEffect below\n const onChange = useCallback(() => {\n const canUpdateFiles = validateMaximumFiles(inputRef?.current?.files);\n const files = inputRef?.current?.files;\n if (canUpdateFiles && files) {\n updateFiles(files);\n } else if (fileList) {\n updateFiles(fileList);\n }\n }, [validateMaximumFiles, inputRef, fileList, updateFiles]);\n\n useEffect(() => {\n const ref = inputRef?.current;\n ref?.addEventListener('change', onChange);\n ref?.addEventListener('cancel', onCancel);\n\n return () => {\n ref?.removeEventListener('change', onChange);\n ref?.removeEventListener('cancel', onCancel);\n };\n }, [onChange, onCancel, inputRef]);\n\n const hasUserProvidedNoFiles = !fileList?.length;\n\n return (\n <RootStack spacing=\"xs\" alignX=\"stretch\">\n <Label htmlFor={id}>\n {label}\n <FlexCol>\n <Hint>\n {maxSizeCopy}\n <br />\n {acceptedTypesCopy}\n </Hint>\n <DropZoneContainer\n hasUserProvidedNoFiles={hasUserProvidedNoFiles}\n isDragOver={isDragOver}\n data-testid=\"drop-zone-container\"\n onDrop={onDrop}\n onDragEnter={onDragEnter}\n onDragOver={onDragOver}\n onDragLeave={onDragLeave}\n >\n {isDragOver ? <DropCopy /> : <UploadCopy />}\n <input\n ref={inputRef}\n id={id}\n type=\"file\"\n accept={acceptedTypesForInputEl}\n name={name}\n disabled={disabled}\n multiple={multiple}\n {...otherProps}\n />\n </DropZoneContainer>\n </FlexCol>\n </Label>\n <FlexCol>\n {inputRef?.current?.validity.valid === false &&\n hasUserProvidedNoFiles &&\n !!validationCount && (\n <FlexRow>\n <CriticalIcon width={16} height={16} color={theme.colors.secondary.red.base} />\n <Error>{inputRef.current?.validationMessage}</Error>\n </FlexRow>\n )}\n {disabledMessage && (\n <FlexRow id={`${id}-disabled`}>\n <LockIcon width={16} height={16} color={theme.colors.neutral.ink.light} />\n <Disabled>{disabledMessage}</Disabled>\n </FlexRow>\n )}\n {!hideUploadedFiles &&\n fileList && [\n Array.from(fileList).map((file) => {\n return (\n <UploadedFile\n key={`${file.name}`}\n file={file}\n removeFileFromList={removeFileFromList}\n disabled={disabled}\n format={format}\n maxBytes={maxBytes}\n fileTypes={fileTypes}\n />\n );\n }),\n ]}\n </FlexCol>\n </RootStack>\n );\n },\n);\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;AAuBO,MAAM,UAAU,GAAG,UAAU,CAClC,CACE,EACE,EAAE,EACF,IAAI,EACJ,QAAQ,GAAG,OAAO,EACl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AI,KAAI;AAChC,oBAAA,QACEA,cAAC,CAAA,aAAA,CAAA,YAAY,EACX,EAAA,GAAG,EAAE,CAAG,EAAA,IAAI,CAAC,IAAI,EAAE,EACnB,IAAI,EAAE,IAAI,EACV,kBAAkB,EAAE,kBAAkB,EACtC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EAAA,CACpB;AAEN,iBAAC,CAAC;aACH,CACK,CACA;AAEhB,CAAC;;;;"}
@@ -3,7 +3,7 @@
3
3
  var React = require('react');
4
4
  var constants = require('../../constants.cjs');
5
5
 
6
- const useValidateInput = ({ fileList, fileTypes, inputRef, maxBytes, customErrorMessage, isDirty, }) => {
6
+ const useValidateInput = ({ fileList, fileTypes, inputRef, maxBytes, customErrorMessage, }) => {
7
7
  // Tracks error states within the input element itself, using preset
8
8
  // error messages and assigns these to the input component based on the file
9
9
  const setInputValidation = React.useCallback(() => {
@@ -63,7 +63,22 @@ const useValidateInput = ({ fileList, fileTypes, inputRef, maxBytes, customError
63
63
  // Validate input whenever fileList or the custom error message changes
64
64
  React.useEffect(() => {
65
65
  setInputValidation();
66
- }, [fileList, setInputValidation, isDirty]);
66
+ }, [fileList, setInputValidation]);
67
+ // Used to force a re-render when input validity changes
68
+ const [validationCount, setValidationCount] = React.useState(0);
69
+ React.useEffect(() => {
70
+ const ref = inputRef === null || inputRef === undefined ? undefined : inputRef.current;
71
+ if (!ref)
72
+ return () => { };
73
+ const handleInvalid = () => setValidationCount((v) => v + 1);
74
+ ref.addEventListener('invalid', handleInvalid);
75
+ return () => {
76
+ ref.removeEventListener('invalid', handleInvalid);
77
+ };
78
+ }, [inputRef]);
79
+ return {
80
+ validationCount,
81
+ };
67
82
  };
68
83
 
69
84
  exports.useValidateInput = useValidateInput;
@@ -1 +1 @@
1
- {"version":3,"file":"useValidateInput.cjs","sources":["../../../../../src/components/UploadFile/hooks/useValidateInput/useValidateInput.ts"],"sourcesContent":["import { useEffect, useCallback } from 'react';\nimport { AcceptedFileTypes, InputErrorStateMessages } from '../../constants';\n\ntype UseValidateInputProps = {\n fileTypes: Array<AcceptedFileTypes>;\n maxBytes: number;\n fileList: FileList | undefined;\n inputRef: React.MutableRefObject<HTMLInputElement | null>;\n customErrorMessage?: string;\n isDirty?: boolean;\n};\n\nexport const useValidateInput = ({\n fileList,\n fileTypes,\n inputRef,\n maxBytes,\n customErrorMessage,\n isDirty,\n}: UseValidateInputProps) => {\n // Tracks error states within the input element itself, using preset\n // error messages and assigns these to the input component based on the file\n const setInputValidation = useCallback(() => {\n let errorMessage = customErrorMessage ?? InputErrorStateMessages.VALID;\n\n if (!inputRef.current?.files?.length) {\n inputRef.current?.setCustomValidity(errorMessage);\n return;\n }\n\n const results = {\n numberOfInvalidFormatFiles: 0,\n numberOfInvalidSizeFiles: 0,\n totalFiles: inputRef.current.files.length,\n };\n\n Array.from(inputRef.current.files).forEach((file) => {\n // Check file size\n if (file.size > maxBytes) {\n results.numberOfInvalidSizeFiles += 1;\n }\n\n // Check file type/format\n const [, extension] = file.type.split('/');\n const isTypeValid = fileTypes.find((validType) => validType.substring(1) === extension);\n if (!isTypeValid) {\n results.numberOfInvalidFormatFiles += 1;\n }\n });\n\n // Determine appropriate error message based on validation results\n const hasFormatErrors = results.numberOfInvalidFormatFiles > 0;\n const hasSizeErrors = results.numberOfInvalidSizeFiles > 0;\n const isSingleFile = results.totalFiles === 1;\n\n if (hasFormatErrors && hasSizeErrors) {\n // Both format and size errors exist\n errorMessage = InputErrorStateMessages.INVALID_FORMAT_AND_SIZE;\n } else if (hasFormatErrors && !hasSizeErrors) {\n // Only format errors\n if (isSingleFile) {\n errorMessage = InputErrorStateMessages.INVALID_FORMAT;\n } else {\n errorMessage = InputErrorStateMessages.INVALID_FORMATS;\n }\n } else if (!hasFormatErrors && hasSizeErrors) {\n // Only size errors\n if (isSingleFile) {\n errorMessage = InputErrorStateMessages.INVALID_SIZE;\n } else {\n errorMessage = InputErrorStateMessages.INVALID_SIZES;\n }\n }\n // If no errors, errorMessage remains VALID\n\n inputRef.current?.setCustomValidity(errorMessage);\n inputRef.current?.reportValidity();\n }, [customErrorMessage, inputRef, maxBytes, fileTypes]);\n\n // Validate input whenever fileList or the custom error message changes\n useEffect(() => {\n setInputValidation();\n }, [fileList, setInputValidation, isDirty]);\n};\n"],"names":["useCallback","InputErrorStateMessages","useEffect"],"mappings":";;;;;AAYa,MAAA,gBAAgB,GAAG,CAAC,EAC/B,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,OAAO,GACe,KAAI;;;AAG1B,IAAA,MAAM,kBAAkB,GAAGA,iBAAW,CAAC,MAAK;;QAC1C,IAAI,YAAY,GAAG,kBAAkB,KAAlB,IAAA,IAAA,kBAAkB,KAAlB,SAAA,GAAA,kBAAkB,GAAIC,iCAAuB,CAAC,KAAK;AAEtE,QAAA,IAAI,EAAC,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,QAAQ,CAAC,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,SAAA,GAAA,SAAA,GAAA,EAAA,CAAE,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,SAAA,GAAA,SAAA,GAAA,EAAA,CAAE,MAAM,CAAA,EAAE;YACpC,CAAA,EAAA,GAAA,QAAQ,CAAC,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,SAAA,GAAA,SAAA,GAAA,EAAA,CAAE,iBAAiB,CAAC,YAAY,CAAC;YACjD;AACD;AAED,QAAA,MAAM,OAAO,GAAG;AACd,YAAA,0BAA0B,EAAE,CAAC;AAC7B,YAAA,wBAAwB,EAAE,CAAC;AAC3B,YAAA,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM;SAC1C;AAED,QAAA,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;;AAEl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AAY,CAAC;AACjD,QAAA,CAAA,EAAA,GAAA,QAAQ,CAAC,OAAO,MAAE,IAAA,IAAA,EAAA,KAAA,SAAA,GAAA,SAAA,GAAA,EAAA,CAAA,cAAc,EAAE;KACnC,EAAE,CAAC,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;;IAGvDC,eAAS,CAAC,MAAK;AACb,QAAA,kBAAkB,EAAE;KACrB,EAAE,CAAC,QAAQ,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;AAC7C;;;;"}
1
+ {"version":3,"file":"useValidateInput.cjs","sources":["../../../../../src/components/UploadFile/hooks/useValidateInput/useValidateInput.ts"],"sourcesContent":["import { useEffect, useCallback, useState } from 'react';\nimport { AcceptedFileTypes, InputErrorStateMessages } from '../../constants';\n\ntype UseValidateInputProps = {\n fileTypes: Array<AcceptedFileTypes>;\n maxBytes: number;\n fileList: FileList | undefined;\n inputRef: React.MutableRefObject<HTMLInputElement | null>;\n customErrorMessage?: string;\n};\n\nexport const useValidateInput = ({\n fileList,\n fileTypes,\n inputRef,\n maxBytes,\n customErrorMessage,\n}: UseValidateInputProps) => {\n // Tracks error states within the input element itself, using preset\n // error messages and assigns these to the input component based on the file\n const setInputValidation = useCallback(() => {\n let errorMessage = customErrorMessage ?? InputErrorStateMessages.VALID;\n\n if (!inputRef.current?.files?.length) {\n inputRef.current?.setCustomValidity(errorMessage);\n return;\n }\n\n const results = {\n numberOfInvalidFormatFiles: 0,\n numberOfInvalidSizeFiles: 0,\n totalFiles: inputRef.current.files.length,\n };\n\n Array.from(inputRef.current.files).forEach((file) => {\n // Check file size\n if (file.size > maxBytes) {\n results.numberOfInvalidSizeFiles += 1;\n }\n\n // Check file type/format\n const [, extension] = file.type.split('/');\n const isTypeValid = fileTypes.find((validType) => validType.substring(1) === extension);\n if (!isTypeValid) {\n results.numberOfInvalidFormatFiles += 1;\n }\n });\n\n // Determine appropriate error message based on validation results\n const hasFormatErrors = results.numberOfInvalidFormatFiles > 0;\n const hasSizeErrors = results.numberOfInvalidSizeFiles > 0;\n const isSingleFile = results.totalFiles === 1;\n\n if (hasFormatErrors && hasSizeErrors) {\n // Both format and size errors exist\n errorMessage = InputErrorStateMessages.INVALID_FORMAT_AND_SIZE;\n } else if (hasFormatErrors && !hasSizeErrors) {\n // Only format errors\n if (isSingleFile) {\n errorMessage = InputErrorStateMessages.INVALID_FORMAT;\n } else {\n errorMessage = InputErrorStateMessages.INVALID_FORMATS;\n }\n } else if (!hasFormatErrors && hasSizeErrors) {\n // Only size errors\n if (isSingleFile) {\n errorMessage = InputErrorStateMessages.INVALID_SIZE;\n } else {\n errorMessage = InputErrorStateMessages.INVALID_SIZES;\n }\n }\n // If no errors, errorMessage remains VALID\n\n inputRef.current?.setCustomValidity(errorMessage);\n inputRef.current?.reportValidity();\n }, [customErrorMessage, inputRef, maxBytes, fileTypes]);\n\n // Validate input whenever fileList or the custom error message changes\n useEffect(() => {\n setInputValidation();\n }, [fileList, setInputValidation]);\n\n // Used to force a re-render when input validity changes\n const [validationCount, setValidationCount] = useState(0);\n\n useEffect(() => {\n const ref = inputRef?.current;\n if (!ref) return () => {};\n const handleInvalid = () => setValidationCount((v) => v + 1);\n ref.addEventListener('invalid', handleInvalid);\n return () => {\n ref.removeEventListener('invalid', handleInvalid);\n };\n }, [inputRef]);\n\n return {\n validationCount,\n };\n};\n"],"names":["useCallback","InputErrorStateMessages","useEffect","useState"],"mappings":";;;;;AAWa,MAAA,gBAAgB,GAAG,CAAC,EAC/B,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,kBAAkB,GACI,KAAI;;;AAG1B,IAAA,MAAM,kBAAkB,GAAGA,iBAAW,CAAC,MAAK;;QAC1C,IAAI,YAAY,GAAG,kBAAkB,KAAlB,IAAA,IAAA,kBAAkB,KAAlB,SAAA,GAAA,kBAAkB,GAAIC,iCAAuB,CAAC,KAAK;AAEtE,QAAA,IAAI,EAAC,CAAA,EAAA,GAAA,CA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AAM,aAAa,GAAG,MAAM,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5D,QAAA,GAAG,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC;AAC9C,QAAA,OAAO,MAAK;AACV,YAAA,GAAG,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC;AACnD,SAAC;AACH,KAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IAEd,OAAO;QACL,eAAe;KAChB;AACH;;;;"}
@@ -6,7 +6,8 @@ type UseValidateInputProps = {
6
6
  fileList: FileList | undefined;
7
7
  inputRef: React.MutableRefObject<HTMLInputElement | null>;
8
8
  customErrorMessage?: string;
9
- isDirty?: boolean;
10
9
  };
11
- export declare const useValidateInput: ({ fileList, fileTypes, inputRef, maxBytes, customErrorMessage, isDirty, }: UseValidateInputProps) => void;
10
+ export declare const useValidateInput: ({ fileList, fileTypes, inputRef, maxBytes, customErrorMessage, }: UseValidateInputProps) => {
11
+ validationCount: number;
12
+ };
12
13
  export {};
@@ -1,7 +1,7 @@
1
- import { useCallback, useEffect } from 'react';
1
+ import { useCallback, useEffect, useState } from 'react';
2
2
  import { InputErrorStateMessages } from '../../constants.js';
3
3
 
4
- const useValidateInput = ({ fileList, fileTypes, inputRef, maxBytes, customErrorMessage, isDirty, }) => {
4
+ const useValidateInput = ({ fileList, fileTypes, inputRef, maxBytes, customErrorMessage, }) => {
5
5
  // Tracks error states within the input element itself, using preset
6
6
  // error messages and assigns these to the input component based on the file
7
7
  const setInputValidation = useCallback(() => {
@@ -61,7 +61,22 @@ const useValidateInput = ({ fileList, fileTypes, inputRef, maxBytes, customError
61
61
  // Validate input whenever fileList or the custom error message changes
62
62
  useEffect(() => {
63
63
  setInputValidation();
64
- }, [fileList, setInputValidation, isDirty]);
64
+ }, [fileList, setInputValidation]);
65
+ // Used to force a re-render when input validity changes
66
+ const [validationCount, setValidationCount] = useState(0);
67
+ useEffect(() => {
68
+ const ref = inputRef === null || inputRef === undefined ? undefined : inputRef.current;
69
+ if (!ref)
70
+ return () => { };
71
+ const handleInvalid = () => setValidationCount((v) => v + 1);
72
+ ref.addEventListener('invalid', handleInvalid);
73
+ return () => {
74
+ ref.removeEventListener('invalid', handleInvalid);
75
+ };
76
+ }, [inputRef]);
77
+ return {
78
+ validationCount,
79
+ };
65
80
  };
66
81
 
67
82
  export { useValidateInput };
@@ -1 +1 @@
1
- {"version":3,"file":"useValidateInput.js","sources":["../../../../../src/components/UploadFile/hooks/useValidateInput/useValidateInput.ts"],"sourcesContent":["import { useEffect, useCallback } from 'react';\nimport { AcceptedFileTypes, InputErrorStateMessages } from '../../constants';\n\ntype UseValidateInputProps = {\n fileTypes: Array<AcceptedFileTypes>;\n maxBytes: number;\n fileList: FileList | undefined;\n inputRef: React.MutableRefObject<HTMLInputElement | null>;\n customErrorMessage?: string;\n isDirty?: boolean;\n};\n\nexport const useValidateInput = ({\n fileList,\n fileTypes,\n inputRef,\n maxBytes,\n customErrorMessage,\n isDirty,\n}: UseValidateInputProps) => {\n // Tracks error states within the input element itself, using preset\n // error messages and assigns these to the input component based on the file\n const setInputValidation = useCallback(() => {\n let errorMessage = customErrorMessage ?? InputErrorStateMessages.VALID;\n\n if (!inputRef.current?.files?.length) {\n inputRef.current?.setCustomValidity(errorMessage);\n return;\n }\n\n const results = {\n numberOfInvalidFormatFiles: 0,\n numberOfInvalidSizeFiles: 0,\n totalFiles: inputRef.current.files.length,\n };\n\n Array.from(inputRef.current.files).forEach((file) => {\n // Check file size\n if (file.size > maxBytes) {\n results.numberOfInvalidSizeFiles += 1;\n }\n\n // Check file type/format\n const [, extension] = file.type.split('/');\n const isTypeValid = fileTypes.find((validType) => validType.substring(1) === extension);\n if (!isTypeValid) {\n results.numberOfInvalidFormatFiles += 1;\n }\n });\n\n // Determine appropriate error message based on validation results\n const hasFormatErrors = results.numberOfInvalidFormatFiles > 0;\n const hasSizeErrors = results.numberOfInvalidSizeFiles > 0;\n const isSingleFile = results.totalFiles === 1;\n\n if (hasFormatErrors && hasSizeErrors) {\n // Both format and size errors exist\n errorMessage = InputErrorStateMessages.INVALID_FORMAT_AND_SIZE;\n } else if (hasFormatErrors && !hasSizeErrors) {\n // Only format errors\n if (isSingleFile) {\n errorMessage = InputErrorStateMessages.INVALID_FORMAT;\n } else {\n errorMessage = InputErrorStateMessages.INVALID_FORMATS;\n }\n } else if (!hasFormatErrors && hasSizeErrors) {\n // Only size errors\n if (isSingleFile) {\n errorMessage = InputErrorStateMessages.INVALID_SIZE;\n } else {\n errorMessage = InputErrorStateMessages.INVALID_SIZES;\n }\n }\n // If no errors, errorMessage remains VALID\n\n inputRef.current?.setCustomValidity(errorMessage);\n inputRef.current?.reportValidity();\n }, [customErrorMessage, inputRef, maxBytes, fileTypes]);\n\n // Validate input whenever fileList or the custom error message changes\n useEffect(() => {\n setInputValidation();\n }, [fileList, setInputValidation, isDirty]);\n};\n"],"names":[],"mappings":";;;AAYa,MAAA,gBAAgB,GAAG,CAAC,EAC/B,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,OAAO,GACe,KAAI;;;AAG1B,IAAA,MAAM,kBAAkB,GAAG,WAAW,CAAC,MAAK;;QAC1C,IAAI,YAAY,GAAG,kBAAkB,KAAlB,IAAA,IAAA,kBAAkB,KAAlB,SAAA,GAAA,kBAAkB,GAAI,uBAAuB,CAAC,KAAK;AAEtE,QAAA,IAAI,EAAC,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,QAAQ,CAAC,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,SAAA,GAAA,SAAA,GAAA,EAAA,CAAE,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,SAAA,GAAA,SAAA,GAAA,EAAA,CAAE,MAAM,CAAA,EAAE;YACpC,CAAA,EAAA,GAAA,QAAQ,CAAC,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,SAAA,GAAA,SAAA,GAAA,EAAA,CAAE,iBAAi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AAC,eAAe,IAAI,aAAa,EAAE;;AAE5C,YAAA,IAAI,YAAY,EAAE;AAChB,gBAAA,YAAY,GAAG,uBAAuB,CAAC,YAAY;AACpD;AAAM,iBAAA;AACL,gBAAA,YAAY,GAAG,uBAAuB,CAAC,aAAa;AACrD;AACF;;QAGD,CAAA,EAAA,GAAA,QAAQ,CAAC,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,SAAA,GAAA,SAAA,GAAA,EAAA,CAAE,iBAAiB,CAAC,YAAY,CAAC;AACjD,QAAA,CAAA,EAAA,GAAA,QAAQ,CAAC,OAAO,MAAE,IAAA,IAAA,EAAA,KAAA,SAAA,GAAA,SAAA,GAAA,EAAA,CAAA,cAAc,EAAE;KACnC,EAAE,CAAC,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;;IAGvD,SAAS,CAAC,MAAK;AACb,QAAA,kBAAkB,EAAE;KACrB,EAAE,CAAC,QAAQ,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;AAC7C;;;;"}
1
+ {"version":3,"file":"useValidateInput.js","sources":["../../../../../src/components/UploadFile/hooks/useValidateInput/useValidateInput.ts"],"sourcesContent":["import { useEffect, useCallback, useState } from 'react';\nimport { AcceptedFileTypes, InputErrorStateMessages } from '../../constants';\n\ntype UseValidateInputProps = {\n fileTypes: Array<AcceptedFileTypes>;\n maxBytes: number;\n fileList: FileList | undefined;\n inputRef: React.MutableRefObject<HTMLInputElement | null>;\n customErrorMessage?: string;\n};\n\nexport const useValidateInput = ({\n fileList,\n fileTypes,\n inputRef,\n maxBytes,\n customErrorMessage,\n}: UseValidateInputProps) => {\n // Tracks error states within the input element itself, using preset\n // error messages and assigns these to the input component based on the file\n const setInputValidation = useCallback(() => {\n let errorMessage = customErrorMessage ?? InputErrorStateMessages.VALID;\n\n if (!inputRef.current?.files?.length) {\n inputRef.current?.setCustomValidity(errorMessage);\n return;\n }\n\n const results = {\n numberOfInvalidFormatFiles: 0,\n numberOfInvalidSizeFiles: 0,\n totalFiles: inputRef.current.files.length,\n };\n\n Array.from(inputRef.current.files).forEach((file) => {\n // Check file size\n if (file.size > maxBytes) {\n results.numberOfInvalidSizeFiles += 1;\n }\n\n // Check file type/format\n const [, extension] = file.type.split('/');\n const isTypeValid = fileTypes.find((validType) => validType.substring(1) === extension);\n if (!isTypeValid) {\n results.numberOfInvalidFormatFiles += 1;\n }\n });\n\n // Determine appropriate error message based on validation results\n const hasFormatErrors = results.numberOfInvalidFormatFiles > 0;\n const hasSizeErrors = results.numberOfInvalidSizeFiles > 0;\n const isSingleFile = results.totalFiles === 1;\n\n if (hasFormatErrors && hasSizeErrors) {\n // Both format and size errors exist\n errorMessage = InputErrorStateMessages.INVALID_FORMAT_AND_SIZE;\n } else if (hasFormatErrors && !hasSizeErrors) {\n // Only format errors\n if (isSingleFile) {\n errorMessage = InputErrorStateMessages.INVALID_FORMAT;\n } else {\n errorMessage = InputErrorStateMessages.INVALID_FORMATS;\n }\n } else if (!hasFormatErrors && hasSizeErrors) {\n // Only size errors\n if (isSingleFile) {\n errorMessage = InputErrorStateMessages.INVALID_SIZE;\n } else {\n errorMessage = InputErrorStateMessages.INVALID_SIZES;\n }\n }\n // If no errors, errorMessage remains VALID\n\n inputRef.current?.setCustomValidity(errorMessage);\n inputRef.current?.reportValidity();\n }, [customErrorMessage, inputRef, maxBytes, fileTypes]);\n\n // Validate input whenever fileList or the custom error message changes\n useEffect(() => {\n setInputValidation();\n }, [fileList, setInputValidation]);\n\n // Used to force a re-render when input validity changes\n const [validationCount, setValidationCount] = useState(0);\n\n useEffect(() => {\n const ref = inputRef?.current;\n if (!ref) return () => {};\n const handleInvalid = () => setValidationCount((v) => v + 1);\n ref.addEventListener('invalid', handleInvalid);\n return () => {\n ref.removeEventListener('invalid', handleInvalid);\n };\n }, [inputRef]);\n\n return {\n validationCount,\n };\n};\n"],"names":[],"mappings":";;;AAWa,MAAA,gBAAgB,GAAG,CAAC,EAC/B,QAAQ,EACR,S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Ae,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IAEzD,SAAS,CAAC,MAAK;QACb,MAAM,GAAG,GAAG,QAAQ,KAAA,IAAA,IAAR,QAAQ,KAAR,SAAA,GAAA,SAAA,GAAA,QAAQ,CAAE,OAAO;AAC7B,QAAA,IAAI,CAAC,GAAG;AAAE,YAAA,OAAO,MAAO,GAAC;AACzB,QAAA,MAAM,aAAa,GAAG,MAAM,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5D,QAAA,GAAG,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC;AAC9C,QAAA,OAAO,MAAK;AACV,YAAA,GAAG,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC;AACnD,SAAC;AACH,KAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IAEd,OAAO;QACL,eAAe;KAChB;AACH;;;;"}
@@ -18,38 +18,13 @@ const DropZoneContainer = styled__default.default.div.withConfig({ displayName:
18
18
  svg {
19
19
  color: ${colors.colors.secondary.blue.base};
20
20
  }
21
- `} ${({ hasUserProvidedNoFiles, isDragOver, isDirty }) => hasUserProvidedNoFiles &&
22
- isDirty &&
23
- `
24
- border: 2px dashed ${colors.colors.secondary.red.base};
25
-
26
- :hover {
27
- border: 2px dashed ${colors.colors.secondary.red.base};
28
- background-color: ${colors.colors.secondary.red.lightest};
29
-
30
- svg {
31
- color: ${colors.colors.secondary.red.base};
32
- }
33
- }
34
-
35
- :active, :focus-within {
21
+ `} &:has(input[type='file']:user-invalid){border:2px dashed ${colors.colors.secondary.red.base};:hover{border:2px dashed ${colors.colors.secondary.red.base};background-color:${colors.colors.secondary.red.lightest};svg{color:${colors.colors.secondary.red.base};}}:active,:focus-within{border:2px dashed ${colors.colors.secondary.red.base};box-shadow:0 0 0 4px ${colors.colors.secondary.red.light};background-color:${colors.colors.secondary.red.lightest};svg{color:${colors.colors.secondary.red.base};}}${({ isDragOver }) => isDragOver
22
+ ? `
36
23
  border: 2px dashed ${colors.colors.secondary.red.base};
37
24
  box-shadow: 0 0 0 4px ${colors.colors.secondary.red.light};
38
25
  background-color: ${colors.colors.secondary.red.lightest};
39
-
40
- svg {
41
- color: ${colors.colors.secondary.red.base};
42
- }
43
- }
44
-
45
- ${isDragOver
46
- ? `
47
- border: 2px dashed ${colors.colors.secondary.red.base};
48
- box-shadow: 0 0 0 4px ${colors.colors.secondary.red.light};
49
- background-color: ${colors.colors.secondary.red.lightest};
50
- `
51
- : ''}
52
- `} &:has(input:disabled){cursor:not-allowed;box-shadow:none;background-color:${colors.colors.neutral.grey.light};border-color:${colors.colors.neutral.ink.lightest};color:${colors.colors.neutral.ink.light};svg{color:${colors.colors.neutral.ink.lightest};}}`;
26
+ `
27
+ : ''}}&:has(input:disabled){cursor:not-allowed;box-shadow:none;background-color:${colors.colors.neutral.grey.light};border-color:${colors.colors.neutral.ink.lightest};color:${colors.colors.neutral.ink.light};svg{color:${colors.colors.neutral.ink.lightest};}}`;
53
28
 
54
29
  exports.DropZoneContainer = DropZoneContainer;
55
30
  //# sourceMappingURL=styled.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"styled.cjs","sources":["../../../src/components/UploadFile/styled.tsx"],"sourcesContent":["import styled from 'styled-components';\nimport { colors } from '../../theme/modules/colors';\nimport { radius } from '../../theme/modules/radius';\nimport { sizes } from '../../theme/modules/sizes';\n\nexport const DropZoneContainer = styled.div<{\n hasUserProvidedNoFiles: boolean;\n isDirty: boolean;\n isDragOver?: boolean;\n}>`\n display: flex;\n align-items: center;\n justify-content: center;\n\n padding: ${sizes.base};\n border-radius: ${radius.base};\n\n input[type='file'] {\n position: absolute;\n opacity: 0;\n width: 1px;\n height: 1px;\n cursor: pointer;\n }\n\n cursor: pointer;\n\n border: 2px dashed ${colors.neutral.ink.lightest};\n background-color: ${colors.neutral.grey.lightest};\n\n :hover {\n border: 2px dashed ${colors.secondary.blue.base};\n background-color: ${colors.secondary.blue.lightest};\n\n svg {\n color: ${colors.secondary.blue.base};\n }\n }\n :active,\n :focus-within {\n border: 2px dashed ${colors.secondary.blue.base};\n box-shadow: 0 0 0 4px ${colors.secondary.blue.light};\n background-color: ${colors.secondary.blue.lightest};\n\n svg {\n color: ${colors.secondary.blue.base};\n }\n }\n\n ${({ isDragOver }) =>\n isDragOver &&\n `\n border: 2px dashed ${colors.secondary.blue.base};\n box-shadow: 0 0 0 4px ${colors.secondary.blue.light};\n background-color: ${colors.secondary.blue.lightest};\n\n svg {\n color: ${colors.secondary.blue.base};\n }\n `}\n\n ${({ hasUserProvidedNoFiles, isDragOver, isDirty }) =>\n hasUserProvidedNoFiles &&\n isDirty &&\n `\n border: 2px dashed ${colors.secondary.red.base};\n\n :hover {\n border: 2px dashed ${colors.secondary.red.base};\n background-color: ${colors.secondary.red.lightest};\n\n svg {\n color: ${colors.secondary.red.base};\n }\n }\n\n :active, :focus-within {\n border: 2px dashed ${colors.secondary.red.base};\n box-shadow: 0 0 0 4px ${colors.secondary.red.light};\n background-color: ${colors.secondary.red.lightest};\n\n svg {\n color: ${colors.secondary.red.base};\n }\n }\n\n ${\n isDragOver\n ? `\n border: 2px dashed ${colors.secondary.red.base};\n box-shadow: 0 0 0 4px ${colors.secondary.red.light};\n background-color: ${colors.secondary.red.lightest};\n `\n : ''\n }\n `}\n\n\n &:has(input:disabled) {\n cursor: not-allowed;\n box-shadow: none;\n background-color: ${colors.neutral.grey.light};\n border-color: ${colors.neutral.ink.lightest};\n color: ${colors.neutral.ink.light};\n\n svg {\n color: ${colors.neutral.ink.lightest};\n }\n }\n`;\n"],"names":["styled","sizes","radius","colors"],"mappings":";;;;;;;;;;;MAKa,iBAAiB,GAAGA,uBAAM,CAAC,GAAG,sJAS9BC,WAAK,CAAC,IAAI,CACJ,eAAA,EAAAC,aAAM,CAAC,IAAI,CAAA,sHAAA,EAYPC,aAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAC5B,kBAAA,EAAAA,aAAM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CAAC,GAAG,CAAC,IAAI,CAAA;AACtB,4BAAA,EAAAA,aAAM,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAA;AAC9B,wBAAA,EAAAA,aAAM,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAA;;;AAGtC,eAAA,EAAAA,aAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAA;;;;MAKpC;AACE,UAAE;AACe,uBAAA,EAAAA,aAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAA;AACtB,0BAAA,EAAAA,aAAM,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAA;AAC9B,sBAAA,EAAAA,aAAM,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAA;AAClD,EAAA;AACK,UAAE,EACN;AACD,EAAA,CAAA,CAAA,2EAAA,EAMqBA,aAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAC7B,cAAA,EAAAA,aAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAA,OAAA,EAClCA,aAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAGtB,WAAA,EAAAA,aAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ;;;;"}
1
+ {"version":3,"file":"styled.cjs","sources":["../../../src/components/UploadFile/styled.tsx"],"sourcesContent":["import styled from 'styled-components';\nimport { colors } from '../../theme/modules/colors';\nimport { radius } from '../../theme/modules/radius';\nimport { sizes } from '../../theme/modules/sizes';\n\nexport const DropZoneContainer = styled.div<{\n hasUserProvidedNoFiles: boolean;\n isDragOver?: boolean;\n}>`\n display: flex;\n align-items: center;\n justify-content: center;\n\n padding: ${sizes.base};\n border-radius: ${radius.base};\n\n input[type='file'] {\n position: absolute;\n opacity: 0;\n width: 1px;\n height: 1px;\n cursor: pointer;\n }\n\n cursor: pointer;\n\n border: 2px dashed ${colors.neutral.ink.lightest};\n background-color: ${colors.neutral.grey.lightest};\n\n :hover {\n border: 2px dashed ${colors.secondary.blue.base};\n background-color: ${colors.secondary.blue.lightest};\n\n svg {\n color: ${colors.secondary.blue.base};\n }\n }\n :active,\n :focus-within {\n border: 2px dashed ${colors.secondary.blue.base};\n box-shadow: 0 0 0 4px ${colors.secondary.blue.light};\n background-color: ${colors.secondary.blue.lightest};\n\n svg {\n color: ${colors.secondary.blue.base};\n }\n }\n\n ${({ isDragOver }) =>\n isDragOver &&\n `\n border: 2px dashed ${colors.secondary.blue.base};\n box-shadow: 0 0 0 4px ${colors.secondary.blue.light};\n background-color: ${colors.secondary.blue.lightest};\n\n svg {\n color: ${colors.secondary.blue.base};\n }\n `}\n\n &:has(input[type='file']:user-invalid) {\n border: 2px dashed ${colors.secondary.red.base};\n\n :hover {\n border: 2px dashed ${colors.secondary.red.base};\n background-color: ${colors.secondary.red.lightest};\n\n svg {\n color: ${colors.secondary.red.base};\n }\n }\n\n :active,\n :focus-within {\n border: 2px dashed ${colors.secondary.red.base};\n box-shadow: 0 0 0 4px ${colors.secondary.red.light};\n background-color: ${colors.secondary.red.lightest};\n\n svg {\n color: ${colors.secondary.red.base};\n }\n }\n\n ${({ isDragOver }) =>\n isDragOver\n ? `\n border: 2px dashed ${colors.secondary.red.base};\n box-shadow: 0 0 0 4px ${colors.secondary.red.light};\n background-color: ${colors.secondary.red.lightest};\n `\n : ''}\n }\n\n &:has(input:disabled) {\n cursor: not-allowed;\n box-shadow: none;\n background-color: ${colors.neutral.grey.light};\n border-color: ${colors.neutral.ink.lightest};\n color: ${colors.neutral.ink.light};\n\n svg {\n color: ${colors.neutral.ink.lightest};\n }\n }\n`;\n"],"names":["styled","sizes","radius","colors"],"mappings":";;;;;;;;;;;MAKa,iBAAiB,GAAGA,uBAAM,CAAC,GAAG,sJAQ9BC,WAAK,CAAC,IAAI,CACJ,eAAA,EAAAC,aAAM,CAAC,IAAI,CAAA,sHAAA,EAYPC,aAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAC5B,kBAAA,EAAAA,aAAM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CAAC,GAAG,CAAC,QAAQ,CAAA,WAAA,EAGtCA,aAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAIpC,GAAA,EAAA,CAAC,EAAE,UAAU,EAAE,KACf;AACE,MAAE;AACiB,yBAAA,EAAAA,aAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAA;AACtB,4BAAA,EAAAA,aAAM,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAA;AAC9B,wBAAA,EAAAA,aAAM,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAA;AAClD,IAAA;AACG,MAAE,EAAE,CAMY,2EAAA,EAAAA,aAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAC7B,cAAA,EAAAA,aAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAA,OAAA,EAClCA,aAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA,WAAA,EAGtBA,aAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ;;;;"}
@@ -1,5 +1,4 @@
1
1
  export declare const DropZoneContainer: import("styled-components").StyledComponent<"div", any, {
2
2
  hasUserProvidedNoFiles: boolean;
3
- isDirty: boolean;
4
3
  isDragOver?: boolean | undefined;
5
4
  }, never>;
@@ -12,38 +12,13 @@ const DropZoneContainer = styled.div.withConfig({ displayName: "vui--DropZoneCon
12
12
  svg {
13
13
  color: ${colors.secondary.blue.base};
14
14
  }
15
- `} ${({ hasUserProvidedNoFiles, isDragOver, isDirty }) => hasUserProvidedNoFiles &&
16
- isDirty &&
17
- `
18
- border: 2px dashed ${colors.secondary.red.base};
19
-
20
- :hover {
21
- border: 2px dashed ${colors.secondary.red.base};
22
- background-color: ${colors.secondary.red.lightest};
23
-
24
- svg {
25
- color: ${colors.secondary.red.base};
26
- }
27
- }
28
-
29
- :active, :focus-within {
15
+ `} &:has(input[type='file']:user-invalid){border:2px dashed ${colors.secondary.red.base};:hover{border:2px dashed ${colors.secondary.red.base};background-color:${colors.secondary.red.lightest};svg{color:${colors.secondary.red.base};}}:active,:focus-within{border:2px dashed ${colors.secondary.red.base};box-shadow:0 0 0 4px ${colors.secondary.red.light};background-color:${colors.secondary.red.lightest};svg{color:${colors.secondary.red.base};}}${({ isDragOver }) => isDragOver
16
+ ? `
30
17
  border: 2px dashed ${colors.secondary.red.base};
31
18
  box-shadow: 0 0 0 4px ${colors.secondary.red.light};
32
19
  background-color: ${colors.secondary.red.lightest};
33
-
34
- svg {
35
- color: ${colors.secondary.red.base};
36
- }
37
- }
38
-
39
- ${isDragOver
40
- ? `
41
- border: 2px dashed ${colors.secondary.red.base};
42
- box-shadow: 0 0 0 4px ${colors.secondary.red.light};
43
- background-color: ${colors.secondary.red.lightest};
44
- `
45
- : ''}
46
- `} &:has(input:disabled){cursor:not-allowed;box-shadow:none;background-color:${colors.neutral.grey.light};border-color:${colors.neutral.ink.lightest};color:${colors.neutral.ink.light};svg{color:${colors.neutral.ink.lightest};}}`;
20
+ `
21
+ : ''}}&:has(input:disabled){cursor:not-allowed;box-shadow:none;background-color:${colors.neutral.grey.light};border-color:${colors.neutral.ink.lightest};color:${colors.neutral.ink.light};svg{color:${colors.neutral.ink.lightest};}}`;
47
22
 
48
23
  export { DropZoneContainer };
49
24
  //# sourceMappingURL=styled.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styled.js","sources":["../../../src/components/UploadFile/styled.tsx"],"sourcesContent":["import styled from 'styled-components';\nimport { colors } from '../../theme/modules/colors';\nimport { radius } from '../../theme/modules/radius';\nimport { sizes } from '../../theme/modules/sizes';\n\nexport const DropZoneContainer = styled.div<{\n hasUserProvidedNoFiles: boolean;\n isDirty: boolean;\n isDragOver?: boolean;\n}>`\n display: flex;\n align-items: center;\n justify-content: center;\n\n padding: ${sizes.base};\n border-radius: ${radius.base};\n\n input[type='file'] {\n position: absolute;\n opacity: 0;\n width: 1px;\n height: 1px;\n cursor: pointer;\n }\n\n cursor: pointer;\n\n border: 2px dashed ${colors.neutral.ink.lightest};\n background-color: ${colors.neutral.grey.lightest};\n\n :hover {\n border: 2px dashed ${colors.secondary.blue.base};\n background-color: ${colors.secondary.blue.lightest};\n\n svg {\n color: ${colors.secondary.blue.base};\n }\n }\n :active,\n :focus-within {\n border: 2px dashed ${colors.secondary.blue.base};\n box-shadow: 0 0 0 4px ${colors.secondary.blue.light};\n background-color: ${colors.secondary.blue.lightest};\n\n svg {\n color: ${colors.secondary.blue.base};\n }\n }\n\n ${({ isDragOver }) =>\n isDragOver &&\n `\n border: 2px dashed ${colors.secondary.blue.base};\n box-shadow: 0 0 0 4px ${colors.secondary.blue.light};\n background-color: ${colors.secondary.blue.lightest};\n\n svg {\n color: ${colors.secondary.blue.base};\n }\n `}\n\n ${({ hasUserProvidedNoFiles, isDragOver, isDirty }) =>\n hasUserProvidedNoFiles &&\n isDirty &&\n `\n border: 2px dashed ${colors.secondary.red.base};\n\n :hover {\n border: 2px dashed ${colors.secondary.red.base};\n background-color: ${colors.secondary.red.lightest};\n\n svg {\n color: ${colors.secondary.red.base};\n }\n }\n\n :active, :focus-within {\n border: 2px dashed ${colors.secondary.red.base};\n box-shadow: 0 0 0 4px ${colors.secondary.red.light};\n background-color: ${colors.secondary.red.lightest};\n\n svg {\n color: ${colors.secondary.red.base};\n }\n }\n\n ${\n isDragOver\n ? `\n border: 2px dashed ${colors.secondary.red.base};\n box-shadow: 0 0 0 4px ${colors.secondary.red.light};\n background-color: ${colors.secondary.red.lightest};\n `\n : ''\n }\n `}\n\n\n &:has(input:disabled) {\n cursor: not-allowed;\n box-shadow: none;\n background-color: ${colors.neutral.grey.light};\n border-color: ${colors.neutral.ink.lightest};\n color: ${colors.neutral.ink.light};\n\n svg {\n color: ${colors.neutral.ink.lightest};\n }\n }\n`;\n"],"names":[],"mappings":";;;;;MAKa,iBAAiB,GAAG,MAAM,CAAC,GAAG,sJAS9B,KAAK,CAAC,IAAI,CACJ,eAAA,EAAA,MAAM,CAAC,IAAI,CAAA,sHAAA,EAYP,M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CAAA;;;;;AAKf,yBAAA,EAAA,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAA;AACtB,4BAAA,EAAA,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAA;AAC9B,wBAAA,EAAA,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAA;;;AAGtC,eAAA,EAAA,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAA;;;;MAKpC;AACE,UAAE;AACe,uBAAA,EAAA,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAA;AACtB,0BAAA,EAAA,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAA;AAC9B,sBAAA,EAAA,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAA;AAClD,EAAA;AACK,UAAE,EACN;AACD,EAAA,CAAA,CAAA,2EAAA,EAMqB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAC7B,cAAA,EAAA,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAA,OAAA,EAClC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAGtB,WAAA,EAAA,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ;;;;"}
1
+ {"version":3,"file":"styled.js","sources":["../../../src/components/UploadFile/styled.tsx"],"sourcesContent":["import styled from 'styled-components';\nimport { colors } from '../../theme/modules/colors';\nimport { radius } from '../../theme/modules/radius';\nimport { sizes } from '../../theme/modules/sizes';\n\nexport const DropZoneContainer = styled.div<{\n hasUserProvidedNoFiles: boolean;\n isDragOver?: boolean;\n}>`\n display: flex;\n align-items: center;\n justify-content: center;\n\n padding: ${sizes.base};\n border-radius: ${radius.base};\n\n input[type='file'] {\n position: absolute;\n opacity: 0;\n width: 1px;\n height: 1px;\n cursor: pointer;\n }\n\n cursor: pointer;\n\n border: 2px dashed ${colors.neutral.ink.lightest};\n background-color: ${colors.neutral.grey.lightest};\n\n :hover {\n border: 2px dashed ${colors.secondary.blue.base};\n background-color: ${colors.secondary.blue.lightest};\n\n svg {\n color: ${colors.secondary.blue.base};\n }\n }\n :active,\n :focus-within {\n border: 2px dashed ${colors.secondary.blue.base};\n box-shadow: 0 0 0 4px ${colors.secondary.blue.light};\n background-color: ${colors.secondary.blue.lightest};\n\n svg {\n color: ${colors.secondary.blue.base};\n }\n }\n\n ${({ isDragOver }) =>\n isDragOver &&\n `\n border: 2px dashed ${colors.secondary.blue.base};\n box-shadow: 0 0 0 4px ${colors.secondary.blue.light};\n background-color: ${colors.secondary.blue.lightest};\n\n svg {\n color: ${colors.secondary.blue.base};\n }\n `}\n\n &:has(input[type='file']:user-invalid) {\n border: 2px dashed ${colors.secondary.red.base};\n\n :hover {\n border: 2px dashed ${colors.secondary.red.base};\n background-color: ${colors.secondary.red.lightest};\n\n svg {\n color: ${colors.secondary.red.base};\n }\n }\n\n :active,\n :focus-within {\n border: 2px dashed ${colors.secondary.red.base};\n box-shadow: 0 0 0 4px ${colors.secondary.red.light};\n background-color: ${colors.secondary.red.lightest};\n\n svg {\n color: ${colors.secondary.red.base};\n }\n }\n\n ${({ isDragOver }) =>\n isDragOver\n ? `\n border: 2px dashed ${colors.secondary.red.base};\n box-shadow: 0 0 0 4px ${colors.secondary.red.light};\n background-color: ${colors.secondary.red.lightest};\n `\n : ''}\n }\n\n &:has(input:disabled) {\n cursor: not-allowed;\n box-shadow: none;\n background-color: ${colors.neutral.grey.light};\n border-color: ${colors.neutral.ink.lightest};\n color: ${colors.neutral.ink.light};\n\n svg {\n color: ${colors.neutral.ink.lightest};\n }\n }\n`;\n"],"names":[],"mappings":";;;;;MAKa,iBAAiB,GAAG,MAAM,CAAC,GAAG,sJAQ9B,KAAK,CAAC,IAAI,CACJ,eAAA,EAAA,MAAM,CAAC,IAAI,CAAA,sHAAA,EAYP,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAC5B,kBAAA,EAAA,M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QAAQ,CAAA,WAAA,EAGtC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAIpC,GAAA,EAAA,CAAC,EAAE,UAAU,EAAE,KACf;AACE,MAAE;AACiB,yBAAA,EAAA,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAA;AACtB,4BAAA,EAAA,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAA;AAC9B,wBAAA,EAAA,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAA;AAClD,IAAA;AACG,MAAE,EAAE,CAMY,2EAAA,EAAA,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAC7B,cAAA,EAAA,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAA,OAAA,EAClC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA,WAAA,EAGtB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ;;;;"}
@@ -11,7 +11,6 @@ export interface UploadFileProps extends React.InputHTMLAttributes<HTMLInputElem
11
11
  onMaxFilesExceeded?: () => void;
12
12
  maxFiles?: number;
13
13
  disabledMessage?: string;
14
- isDirty?: boolean;
15
14
  }
16
15
  export type UploadFileErrors = {
17
16
  criticalErrors: Array<UploadFileError>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veeqo/ui",
3
- "version": "12.4.0-beta-8",
3
+ "version": "12.4.0-beta-9",
4
4
  "description": "New optimised component library for Veeqo.",
5
5
  "author": "Robert Wealthall",
6
6
  "license": "ISC",