@evoke-platform/ui-components 1.5.0-testing.16 → 1.5.0-testing.18
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.
@@ -462,6 +462,6 @@ export class FormFieldComponent extends ReactComponent {
|
|
462
462
|
falsePositiveMaskError &&
|
463
463
|
isEmpty(this.errorDetails) &&
|
464
464
|
this.emit('changed-' + this.component.key, e.target.value);
|
465
|
-
}, ...this.component, id: inputId, defaultValue: this.dataValue, mask: this.component.inputMask, error: this.hasErrors(), size: this.component.fieldHeight ?? 'medium', required: this.component.validate?.required }))), root);
|
465
|
+
}, ...this.component, id: inputId, defaultValue: this.dataValue, mask: this.component.inputMask, error: this.hasErrors(), size: this.component.fieldHeight ?? 'medium', required: this.component.property.type === 'boolean' ? this.component.validate?.required : undefined }))), root);
|
466
466
|
}
|
467
467
|
}
|
@@ -28,27 +28,31 @@ const FileUploadControl = (props) => {
|
|
28
28
|
color: '#C7C7CD',
|
29
29
|
},
|
30
30
|
};
|
31
|
+
const onDrop = useCallback(
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
33
|
+
(acceptedFile) => {
|
34
|
+
setUploadedFile(acceptedFile[0]);
|
35
|
+
}, [setUploadedFile]);
|
36
|
+
const { getRootProps, getInputProps, isDragActive, open } = useDropzone({
|
37
|
+
onDrop,
|
38
|
+
multiple: false,
|
39
|
+
disabled: !!uploadedFile,
|
40
|
+
noClick: true,
|
41
|
+
});
|
31
42
|
useEffect(() => {
|
32
43
|
if (uploadedFile) {
|
33
44
|
props.onChange && props.onChange(property.id, uploadedFile, property);
|
34
45
|
}
|
35
46
|
}, [uploadedFile]);
|
36
|
-
const
|
47
|
+
const handleFileSelectionOrRemoval = () => {
|
37
48
|
if (uploadedFile) {
|
38
49
|
setUploadedFile(undefined);
|
39
50
|
props.onChange && props.onChange(property.id, undefined, property);
|
40
51
|
}
|
52
|
+
else {
|
53
|
+
open();
|
54
|
+
}
|
41
55
|
};
|
42
|
-
const onDrop = useCallback(
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
44
|
-
(acceptedFile) => {
|
45
|
-
setUploadedFile(acceptedFile[0]);
|
46
|
-
}, [setUploadedFile]);
|
47
|
-
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
48
|
-
onDrop,
|
49
|
-
multiple: false,
|
50
|
-
disabled: !!uploadedFile,
|
51
|
-
});
|
52
56
|
return (React.createElement(Grid, { container: true, ...getRootProps({
|
53
57
|
style: {
|
54
58
|
border: error ? '1px solid red' : '1px solid #c4c4c4',
|
@@ -57,9 +61,9 @@ const FileUploadControl = (props) => {
|
|
57
61
|
},
|
58
62
|
}) },
|
59
63
|
React.createElement(Grid, { item: true, flexGrow: 1 },
|
60
|
-
React.createElement("input", {
|
64
|
+
React.createElement("input", { ...getInputProps() }),
|
61
65
|
React.createElement(TextField, { id: id, sx: { '& fieldset': { border: 'none' } }, fullWidth: true, value: uploadedFile?.name ?? (isDragActive ? 'Drop your file here' : 'File'), error: error, errorMessage: errorMessage, required: required, ...(additionalProps ?? {}) })),
|
62
66
|
React.createElement(Grid, { item: true },
|
63
|
-
React.createElement(Button, { sx: { ...styles.button, ...styles.selectFileBtn }, onClick:
|
67
|
+
React.createElement(Button, { sx: { ...styles.button, ...styles.selectFileBtn }, onClick: handleFileSelectionOrRemoval }, uploadedFile ? 'Remove' : 'Select File'))));
|
64
68
|
};
|
65
69
|
export default FileUploadControl;
|