hrm_ui_lib 4.0.8 → 4.0.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.
|
@@ -10,7 +10,7 @@ import IconEditFilled from '../SVGIcons/IconEditFilled';
|
|
|
10
10
|
import IconEdit from '../SVGIcons/IconEdit';
|
|
11
11
|
import IconAttach from '../SVGIcons/IconAttach';
|
|
12
12
|
export const FileUpload = (props) => {
|
|
13
|
-
const { allowedTypes = 'application/pdf, .png, .jpg, .jpeg, image/jpeg, image/png, image/jpg, text/plain, image/*, .pdf, .doc, .docx, application/vnd', label, getFiles, removeFiles, handleFileClick, name, setFieldValue, toBase64, required, disabled, buttonText, withFilePreview = true, multiple = true, uploadedFiles, value, labelAddons, onError, fileAllowedSize, mode = FileUploadMode.attach, size = 'medium', iconProps = { Component: IconAttach }, dataTestId = '' } = props;
|
|
13
|
+
const { allowedTypes = 'application/pdf, .png, .jpg, .jpeg, image/jpeg, image/png, image/jpg, text/plain, image/*, .pdf, .doc, .docx, application/vnd', label, getFiles, removeFiles, handleFileClick, name, setFieldValue, toBase64, required, disabled, buttonText, withFilePreview = true, multiple = true, uploadedFiles, value, labelAddons, onError, fileAllowedSize, mode = FileUploadMode.attach, size = 'medium', iconProps = { Component: IconAttach }, dataTestId = '', uploading = false } = props;
|
|
14
14
|
const files = value || uploadedFiles || [];
|
|
15
15
|
const fileInputRef = useRef(null);
|
|
16
16
|
const [isHovered, setHoverState] = useState(false);
|
|
@@ -66,5 +66,5 @@ export const FileUpload = (props) => {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}, [files, removeFiles]);
|
|
69
|
-
return (_jsxs("div", { className: "file-upload", "data-test-id": dataTestId, children: [_jsx(Label, { text: label, required: required, disabled: disabled, labelAddons: labelAddons, dataTestId: dataTestId ? `${dataTestId}-label` : '' }), _jsxs("div", { className: "file-upload__inner", children: [_jsx("input", { name: name, type: "file", multiple: multiple, className: "hide", ref: fileInputRef, accept: allowedTypes, "data-test-id": dataTestId ? `${dataTestId}-input` : '', onChange: handleChange }), mode === FileUploadMode.edit && (_jsx("div", { className: "edit__icon", "data-test-id": dataTestId ? `${dataTestId}-trigger` : '', onMouseEnter: onMouseEnterOrLeave, onMouseLeave: onMouseEnterOrLeave, onClick: onUploadClick, children: isHovered ? (_jsx(IconEditFilled, { size: "xxsmall", type: "secondary" })) : (_jsx(IconEdit, { size: "xxsmall", type: "secondary" })) })), mode === FileUploadMode.attach && (_jsx(Button, { type: "secondary", size: size, disabled: disabled, iconProps: iconProps, onClick: onUploadClick, buttonText: buttonText, dataTestId: dataTestId ? `${dataTestId}-action` : '' })), _jsx(UploadItems, { handleFileClick: handleFileClick, onRemove: handleFileRemove, files: files, withFilePreview: withFilePreview, dataTestId: dataTestId })] })] }));
|
|
69
|
+
return (_jsxs("div", { className: "file-upload", "data-test-id": dataTestId, children: [_jsx(Label, { text: label, required: required, disabled: disabled, labelAddons: labelAddons, dataTestId: dataTestId ? `${dataTestId}-label` : '' }), _jsxs("div", { className: "file-upload__inner", children: [_jsx("input", { name: name, type: "file", multiple: multiple, className: "hide", ref: fileInputRef, accept: allowedTypes, "data-test-id": dataTestId ? `${dataTestId}-input` : '', onChange: handleChange }), mode === FileUploadMode.edit && (_jsx("div", { className: "edit__icon", "data-test-id": dataTestId ? `${dataTestId}-trigger` : '', onMouseEnter: onMouseEnterOrLeave, onMouseLeave: onMouseEnterOrLeave, onClick: onUploadClick, children: isHovered ? (_jsx(IconEditFilled, { size: "xxsmall", type: "secondary" })) : (_jsx(IconEdit, { size: "xxsmall", type: "secondary" })) })), mode === FileUploadMode.attach && (_jsx(Button, { type: "secondary", size: size, disabled: disabled, iconProps: iconProps, onClick: onUploadClick, buttonText: buttonText, isLoading: uploading, dataTestId: dataTestId ? `${dataTestId}-action` : '' })), _jsx(UploadItems, { handleFileClick: handleFileClick, onRemove: handleFileRemove, files: files, withFilePreview: withFilePreview, dataTestId: dataTestId })] })] }));
|
|
70
70
|
};
|
|
@@ -4,6 +4,7 @@ import { Dispatch, SetStateAction } from 'react';
|
|
|
4
4
|
import { Accept, DropzoneOptions } from 'react-dropzone';
|
|
5
5
|
import { TButtonPropTypes } from '../Button/types';
|
|
6
6
|
export interface TFileUploadProps extends IFormCompProps {
|
|
7
|
+
uploading?: boolean;
|
|
7
8
|
allowedTypes?: string;
|
|
8
9
|
label?: string | React.ReactElement;
|
|
9
10
|
buttonText?: string | React.ReactElement;
|