@arquimedes.co/eureka-forms 1.9.16-test → 1.9.17-test
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/App.js +98 -205
- package/dist/AxiosAPI.js +3 -3
- package/dist/AxiosWidget.js +4 -4
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +104 -207
- package/dist/FormComponents/Form/ConfirmationDialog/ConfirmationDialog.js +5 -17
- package/dist/FormComponents/Form/Form.js +29 -56
- package/dist/FormComponents/Form/StepperForm/StepperForm.js +1 -1
- package/dist/FormComponents/Section/MaterialSection/MaterialSection.js +7 -30
- package/dist/FormComponents/Section/Section.js +2 -13
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/CBRIncidentsStep.js +2 -13
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.js +9 -32
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +47 -64
- package/dist/FormComponents/Step/@Construction/CBRLocativasStep/CBRLocativasStep.js +41 -102
- package/dist/FormComponents/Step/@Construction/CBRPropertyStep/CBRPropertyStep.js +37 -92
- package/dist/FormComponents/Step/AYFStepMapper.js +23 -75
- package/dist/FormComponents/Step/CBRStepMapper.js +56 -144
- package/dist/FormComponents/Step/CheckBoxStep/CheckBoxStep.js +3 -26
- package/dist/FormComponents/Step/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +6 -21
- package/dist/FormComponents/Step/ClassifierSelectorStep/ClassifierSelectorStep.js +3 -26
- package/dist/FormComponents/Step/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +32 -65
- package/dist/FormComponents/Step/DatePickerStep/DatePickerStep.js +2 -13
- package/dist/FormComponents/Step/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +6 -21
- package/dist/FormComponents/Step/FileUploadStep/FileUploadStep.js +2 -13
- package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.js +27 -88
- package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +81 -171
- package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/MaterialRatingStep.js +15 -41
- package/dist/FormComponents/Step/RatingStep/RatingStep.js +2 -13
- package/dist/FormComponents/Step/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +25 -52
- package/dist/FormComponents/Step/SelectorStep/SelectorStep.js +3 -26
- package/dist/FormComponents/Step/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.js +1 -2
- package/dist/FormComponents/Step/SeparatorStep/SeparatorStep.js +3 -26
- package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +83 -145
- package/dist/FormComponents/Step/SmartSelectStep/SmartSelectStep.js +2 -13
- package/dist/FormComponents/Step/Step.js +19 -39
- package/dist/FormComponents/Step/StepFunctions.js +14 -16
- package/dist/FormComponents/Step/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +43 -62
- package/dist/FormComponents/Step/TextAreaStep/TextAreaStep.js +2 -13
- package/dist/FormComponents/Step/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +6 -21
- package/dist/FormComponents/Step/TextInputStep/TextInputStep.js +2 -13
- package/dist/FormComponents/Step/TitleStep/MaterialTitleStep/MaterialTitleStep.js +3 -15
- package/dist/FormComponents/Step/TitleStep/TitleStep.js +3 -26
- package/dist/FormComponents/Term/MaterialTerm/MaterialTerm.js +19 -35
- package/dist/FormComponents/Term/Term.js +2 -13
- package/dist/Widget.js +13 -25
- package/dist/constants/Files/FileExtensions.js +3 -3
- package/dist/constants/Files/FileMaxSize.js +1 -1
- package/dist/constants/InternalFormStyle.js +1 -1
- package/dist/constants/MaterialClassNameSeed.js +1 -1
- package/dist/controllers/FileService.js +29 -86
- package/dist/index.js +4 -15
- package/dist/shared/Loader/Loader.js +5 -17
- package/dist/shared/Navbar/Navbar.js +2 -14
- package/dist/shared/Rating/Rating.js +4 -27
- package/dist/shared/Rating/Ratings/LikeRating.js +9 -21
- package/dist/shared/Rating/Ratings/SatisfactionRating.js +15 -27
- package/dist/shared/Rating/Ratings/ScaleRating.js +22 -49
- package/dist/shared/RoundedButton/RoundedButton.js +12 -24
- package/dist/shared/RoundedCheckBox/RoundedCheckBox.js +39 -84
- package/dist/shared/RoundedDatePicker/RoundedDatePicker.js +235 -286
- package/dist/shared/RoundedSelect/RoundedSelect.js +103 -152
- package/dist/shared/RoundedSmartSelect/RoundedSmartSelect.js +125 -160
- package/dist/shared/RoundedTextField/RoundedTextField.js +92 -137
- package/dist/utils/CbrFunctions.js +30 -30
- package/package.json +4 -4
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
2
|
import { FormStyleTypes } from '../../../constants/FormStepTypes';
|
|
14
3
|
import MaterialFileUploadStep from './MaterialFileUploadStep/MaterialFileUploadStep';
|
|
15
4
|
function FileUploadStep(props) {
|
|
16
5
|
switch (props.formStyle.type) {
|
|
17
6
|
case FormStyleTypes.MATERIAL: {
|
|
18
|
-
return _jsx(MaterialFileUploadStep,
|
|
7
|
+
return _jsx(MaterialFileUploadStep, { ...props });
|
|
19
8
|
}
|
|
20
9
|
default: {
|
|
21
|
-
return _jsx(MaterialFileUploadStep,
|
|
10
|
+
return _jsx(MaterialFileUploadStep, { ...props });
|
|
22
11
|
}
|
|
23
12
|
}
|
|
24
13
|
}
|
|
@@ -1,50 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
2
|
import styles from './FileComponent.module.css';
|
|
50
3
|
import ClearRoundedIcon from '@material-ui/icons/ClearRounded';
|
|
@@ -52,72 +5,58 @@ import DescriptionRoundedIcon from '@material-ui/icons/DescriptionRounded';
|
|
|
52
5
|
import ErrorRoundedIcon from '@material-ui/icons/ErrorRounded';
|
|
53
6
|
import Loader from '../../../../../shared/Loader/Loader';
|
|
54
7
|
import { useState } from 'react';
|
|
55
|
-
function FileUploadComponent(
|
|
56
|
-
|
|
57
|
-
var _b, _c;
|
|
58
|
-
var file = _a.file, formStyle = _a.formStyle, error = _a.error, handleRemove = _a.handleRemove, fetchDownloadUrl = _a.fetchDownloadUrl;
|
|
59
|
-
var _d = useState(false), downloading = _d[0], setDownloading = _d[1];
|
|
8
|
+
function FileUploadComponent({ file, formStyle, error, handleRemove, fetchDownloadUrl, }) {
|
|
9
|
+
const [downloading, setDownloading] = useState(false);
|
|
60
10
|
if (!file) {
|
|
61
11
|
return _jsx("div", {});
|
|
62
12
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
a = document.createElement('a');
|
|
77
|
-
a.href = fileUrl;
|
|
78
|
-
a.setAttribute('download', file.fileName);
|
|
79
|
-
a.click();
|
|
80
|
-
setDownloading(false);
|
|
81
|
-
return [3 /*break*/, 4];
|
|
82
|
-
case 3:
|
|
83
|
-
error_1 = _a.sent();
|
|
84
|
-
console.error(error_1);
|
|
85
|
-
return [3 /*break*/, 4];
|
|
86
|
-
case 4: return [2 /*return*/];
|
|
13
|
+
const downloadFile = async () => {
|
|
14
|
+
if (fetchDownloadUrl && file.S3Key && file.fileName) {
|
|
15
|
+
try {
|
|
16
|
+
setDownloading(true);
|
|
17
|
+
const fileUrl = await fetchDownloadUrl(file.S3Key, file.fileName);
|
|
18
|
+
var a = document.createElement('a');
|
|
19
|
+
a.href = fileUrl;
|
|
20
|
+
a.setAttribute('download', file.fileName);
|
|
21
|
+
a.click();
|
|
22
|
+
setDownloading(false);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
console.error(error);
|
|
87
26
|
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const calcIcon = () => {
|
|
91
30
|
if (downloading) {
|
|
92
|
-
return (_jsx("div",
|
|
31
|
+
return (_jsx("div", { className: styles.loaderContainer, children: _jsx(Loader, { size: 26, color: formStyle.primaryColor }) }));
|
|
93
32
|
}
|
|
94
33
|
else if (file.state !== undefined) {
|
|
95
34
|
switch (file.state) {
|
|
96
35
|
case 'STARTING':
|
|
97
36
|
case 'UPLOADING':
|
|
98
|
-
return (_jsx("div",
|
|
37
|
+
return (_jsx("div", { className: styles.loaderContainer, children: _jsx(Loader, { size: 26, color: formStyle.primaryColor }) }));
|
|
99
38
|
case 'DONE':
|
|
100
|
-
return (_jsx("div",
|
|
39
|
+
return (_jsx("div", { className: styles.documentIcon, style: { color: formStyle.primaryColor }, children: _jsx(DescriptionRoundedIcon, {}) }));
|
|
101
40
|
case 'ERROR':
|
|
102
|
-
return (_jsx("div",
|
|
41
|
+
return (_jsx("div", { className: styles.documentIcon, style: { color: formStyle.errorColor }, children: _jsx(ErrorRoundedIcon, {}) }));
|
|
103
42
|
default:
|
|
104
43
|
return _jsx("div", {});
|
|
105
44
|
}
|
|
106
45
|
}
|
|
107
46
|
else {
|
|
108
|
-
return (_jsx("div",
|
|
47
|
+
return (_jsx("div", { className: styles.documentIcon, style: { color: formStyle.primaryColor }, children: _jsx(DescriptionRoundedIcon, {}) }));
|
|
109
48
|
}
|
|
110
49
|
};
|
|
111
|
-
return (_jsxs("div",
|
|
50
|
+
return (_jsxs("div", { className: styles.container, children: [_jsx("div", { className: styles.iconContainer, children: calcIcon() }), _jsx("div", { className: fetchDownloadUrl && file.S3Key
|
|
112
51
|
? styles.downloadableLbl
|
|
113
52
|
: styles.label, style: {
|
|
114
53
|
color: error ? formStyle.errorColor : formStyle.textColor,
|
|
115
|
-
}, onClick:
|
|
54
|
+
}, onClick: () => {
|
|
116
55
|
if (fetchDownloadUrl !== undefined && file.S3Key) {
|
|
117
56
|
downloadFile();
|
|
118
57
|
}
|
|
119
|
-
}
|
|
58
|
+
}, children: file.file?.name ?? file.fileName }), _jsx("div", { className: styles.deletBtn, onClick: () => {
|
|
120
59
|
handleRemove();
|
|
121
|
-
}
|
|
60
|
+
}, children: file.state !== undefined && (_jsx(ClearRoundedIcon, { fontSize: "inherit" })) })] }));
|
|
122
61
|
}
|
|
123
62
|
export default FileUploadComponent;
|
package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js
CHANGED
|
@@ -1,59 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
-
if (ar || !(i in from)) {
|
|
51
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
-
ar[i] = from[i];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
-
};
|
|
57
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
58
2
|
import styles from './MaterialFileUploadStep.module.css';
|
|
59
3
|
import { Controller } from 'react-hook-form';
|
|
@@ -63,16 +7,14 @@ import { getAcceptedExtensions } from '../../../../constants/Files/FileExtension
|
|
|
63
7
|
import { getUploadUrls, postFile } from '../../../../controllers/FileService';
|
|
64
8
|
import FileComponent from './FileComponent/FileComponent';
|
|
65
9
|
import maxSize from '../../../../constants/Files/FileMaxSize';
|
|
66
|
-
function FileUploadStep(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
for (var _i = 0, fileChange_1 = fileChange; _i < fileChange_1.length; _i++) {
|
|
75
|
-
var file = fileChange_1[_i];
|
|
10
|
+
function FileUploadStep({ step, errors, value, domain, btnRef, postview, onChange, editable, formStyle, clearErrors, fetchDownloadUrl, }) {
|
|
11
|
+
const [error, setError] = useState(undefined);
|
|
12
|
+
const [fileChange, setFileChange] = useState([]);
|
|
13
|
+
const inputRef = useRef();
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const filesToFetchLink = [];
|
|
16
|
+
const filesChanged = [];
|
|
17
|
+
for (const file of fileChange) {
|
|
76
18
|
if (file.state === 'STARTING') {
|
|
77
19
|
filesToFetchLink.push(file);
|
|
78
20
|
}
|
|
@@ -85,8 +27,8 @@ function FileUploadStep(_a) {
|
|
|
85
27
|
filesChanged.push(file);
|
|
86
28
|
}
|
|
87
29
|
if (file.state === 'CANCEL') {
|
|
88
|
-
|
|
89
|
-
for (
|
|
30
|
+
const newValue = [...value];
|
|
31
|
+
for (let i = 0; i < value.length; i++) {
|
|
90
32
|
if (value[i].file === file.file) {
|
|
91
33
|
newValue.splice(i, 1);
|
|
92
34
|
break;
|
|
@@ -96,10 +38,9 @@ function FileUploadStep(_a) {
|
|
|
96
38
|
}
|
|
97
39
|
}
|
|
98
40
|
if (filesChanged.length > 0) {
|
|
99
|
-
|
|
100
|
-
for (
|
|
101
|
-
|
|
102
|
-
for (var i = 0; i < value.length; i++) {
|
|
41
|
+
const newValue = [...value];
|
|
42
|
+
for (const file of filesChanged) {
|
|
43
|
+
for (let i = 0; i < value.length; i++) {
|
|
103
44
|
if (value[i].file === file.file) {
|
|
104
45
|
newValue[i] = file;
|
|
105
46
|
}
|
|
@@ -109,75 +50,54 @@ function FileUploadStep(_a) {
|
|
|
109
50
|
}
|
|
110
51
|
if (filesToFetchLink.length > 0) {
|
|
111
52
|
getLinks(filesToFetchLink);
|
|
112
|
-
onChange(
|
|
53
|
+
onChange([...value, ...filesToFetchLink]);
|
|
113
54
|
}
|
|
114
55
|
}, [fileChange]);
|
|
115
|
-
function getLinks(pFiles) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
case 1:
|
|
124
|
-
fileLinks_1 = _a.sent();
|
|
125
|
-
errorsExt_1 = [];
|
|
126
|
-
setFileChange(pFiles.map(function (file, index) {
|
|
127
|
-
var _a;
|
|
128
|
-
if (fileLinks_1[index] === 'ERROR:INVALIDEXTENSION') {
|
|
129
|
-
errorsExt_1.push((_a = file.file.name.split('.').pop()) !== null && _a !== void 0 ? _a : '');
|
|
130
|
-
return __assign(__assign({}, file), { state: 'ERROR' });
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
return __assign(__assign({}, file), { state: 'UPLOADING', postInfo: fileLinks_1[index] });
|
|
134
|
-
}
|
|
135
|
-
}));
|
|
136
|
-
if (errorsExt_1.length === 1) {
|
|
137
|
-
setError('La extención .' + errorsExt_1[0] + ' no es válida');
|
|
138
|
-
}
|
|
139
|
-
else if (errorsExt_1.length > 1) {
|
|
140
|
-
setError('Las extenciónes .' +
|
|
141
|
-
errorsExt_1.join(',.') +
|
|
142
|
-
' no son válidas');
|
|
143
|
-
}
|
|
144
|
-
return [3 /*break*/, 3];
|
|
145
|
-
case 2:
|
|
146
|
-
error_1 = _a.sent();
|
|
147
|
-
console.error(error_1);
|
|
148
|
-
return [3 /*break*/, 3];
|
|
149
|
-
case 3: return [2 /*return*/];
|
|
56
|
+
async function getLinks(pFiles) {
|
|
57
|
+
try {
|
|
58
|
+
const fileLinks = await getUploadUrls(pFiles.map((file) => file.file), domain);
|
|
59
|
+
const errorsExt = [];
|
|
60
|
+
setFileChange(pFiles.map((file, index) => {
|
|
61
|
+
if (fileLinks[index] === 'ERROR:INVALIDEXTENSION') {
|
|
62
|
+
errorsExt.push(file.file.name.split('.').pop() ?? '');
|
|
63
|
+
return { ...file, state: 'ERROR' };
|
|
150
64
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return __generator(this, function (_a) {
|
|
158
|
-
switch (_a.label) {
|
|
159
|
-
case 0:
|
|
160
|
-
_a.trys.push([0, 2, , 3]);
|
|
161
|
-
return [4 /*yield*/, Promise.all([
|
|
162
|
-
postFile(pFile.file, pFile.postInfo),
|
|
163
|
-
new Promise(function (resolve) { return setTimeout(resolve, 1000); }),
|
|
164
|
-
])];
|
|
165
|
-
case 1:
|
|
166
|
-
resp = _a.sent();
|
|
167
|
-
setFileChange([__assign(__assign(__assign({}, pFile), { state: 'DONE' }), resp[0])]);
|
|
168
|
-
return [3 /*break*/, 3];
|
|
169
|
-
case 2:
|
|
170
|
-
error_2 = _a.sent();
|
|
171
|
-
console.error(error_2);
|
|
172
|
-
return [3 /*break*/, 3];
|
|
173
|
-
case 3: return [2 /*return*/];
|
|
65
|
+
else {
|
|
66
|
+
return {
|
|
67
|
+
...file,
|
|
68
|
+
state: 'UPLOADING',
|
|
69
|
+
postInfo: fileLinks[index],
|
|
70
|
+
};
|
|
174
71
|
}
|
|
175
|
-
});
|
|
176
|
-
|
|
72
|
+
}));
|
|
73
|
+
if (errorsExt.length === 1) {
|
|
74
|
+
setError('La extención .' + errorsExt[0] + ' no es válida');
|
|
75
|
+
}
|
|
76
|
+
else if (errorsExt.length > 1) {
|
|
77
|
+
setError('Las extenciónes .' +
|
|
78
|
+
errorsExt.join(',.') +
|
|
79
|
+
' no son válidas');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error(error);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async function uploadFile(pFile) {
|
|
87
|
+
try {
|
|
88
|
+
const resp = await Promise.all([
|
|
89
|
+
postFile(pFile.file, pFile.postInfo),
|
|
90
|
+
new Promise((resolve) => setTimeout(resolve, 1000)),
|
|
91
|
+
]);
|
|
92
|
+
setFileChange([{ ...pFile, state: 'DONE', ...resp[0] }]);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
console.error(error);
|
|
96
|
+
}
|
|
177
97
|
}
|
|
178
|
-
|
|
98
|
+
const calcErrorMsg = () => {
|
|
179
99
|
if (!!errors[step.id]) {
|
|
180
|
-
|
|
100
|
+
const errNum = value.filter((val) => val.state === 'ERROR').length;
|
|
181
101
|
if (errNum === 1) {
|
|
182
102
|
return 'Este archivo no es válido';
|
|
183
103
|
}
|
|
@@ -190,68 +110,58 @@ function FileUploadStep(_a) {
|
|
|
190
110
|
}
|
|
191
111
|
return '';
|
|
192
112
|
};
|
|
193
|
-
return (_jsxs("div",
|
|
194
|
-
(error || !!errors[step.id] ? ' EF-error' : ''), "data-testid": step.id
|
|
195
|
-
|
|
113
|
+
return (_jsxs("div", { className: styles.container +
|
|
114
|
+
(error || !!errors[step.id] ? ' EF-error' : ''), "data-testid": step.id, children: [_jsx("div", { className: styles.labelLabel, children: step.label }), step.description && (_jsx("div", { className: styles.stepDescriptionLabel, style: { color: formStyle.descriptionTextColor }, children: step.description })), _jsx("input", { type: "file", ref: inputRef, className: styles.filesInput, onChange: (e) => {
|
|
115
|
+
const files = e.target.files;
|
|
196
116
|
if (files) {
|
|
197
|
-
|
|
198
|
-
|
|
117
|
+
const filesArray = Array.from(files);
|
|
118
|
+
const maxFiles = filesArray.filter((file) => file.size > maxSize);
|
|
199
119
|
if (maxFiles.length > 0) {
|
|
200
120
|
setError('El tamaño máximo de carga es de 30Mb.');
|
|
201
121
|
}
|
|
202
122
|
else {
|
|
203
123
|
setFileChange(filesArray
|
|
204
|
-
.filter(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return ({
|
|
212
|
-
state: 'STARTING',
|
|
213
|
-
file: file,
|
|
214
|
-
postInfo: null,
|
|
215
|
-
});
|
|
216
|
-
}));
|
|
124
|
+
.filter((file) => value.find((val) => val.file ===
|
|
125
|
+
file) === undefined)
|
|
126
|
+
.map((file) => ({
|
|
127
|
+
state: 'STARTING',
|
|
128
|
+
file,
|
|
129
|
+
postInfo: null,
|
|
130
|
+
})));
|
|
217
131
|
}
|
|
218
132
|
inputRef.current.value = '';
|
|
219
133
|
}
|
|
220
|
-
}, multiple: true, accept: getAcceptedExtensions() }), _jsxs("div",
|
|
134
|
+
}, multiple: true, accept: getAcceptedExtensions() }), _jsxs("div", { className: styles.btnContainer, children: [_jsx("input", { ref: btnRef, className: styles.hiddenInput }), _jsx(RoundedButton, { disabled: !editable || postview, text: 'Examinar' + (step.required ? ' *' : ''), color: formStyle.primaryContrastColor, backgroundColor: formStyle.primaryColor, fontSize: '1rem', padding: '5px 15px 5px 15px', onClick: () => {
|
|
221
135
|
if (editable && !postview) {
|
|
222
|
-
|
|
136
|
+
const input = inputRef.current;
|
|
223
137
|
if (input !== null) {
|
|
224
138
|
clearErrors(step.id);
|
|
225
139
|
setError(undefined);
|
|
226
140
|
input.click();
|
|
227
141
|
}
|
|
228
142
|
}
|
|
229
|
-
} })] })
|
|
143
|
+
} })] }), _jsx("div", { className: styles.filesContainer, children: value.map((file, index) => (_jsx(FileComponent, { formStyle: formStyle, file: file, error: (!!errors[step.id] &&
|
|
230
144
|
file.state !== 'DONE') ||
|
|
231
|
-
file.state === 'ERROR', handleRemove:
|
|
232
|
-
if (value.filter(
|
|
233
|
-
return val.state === 'ERROR';
|
|
234
|
-
}).length === 1) {
|
|
145
|
+
file.state === 'ERROR', handleRemove: () => {
|
|
146
|
+
if (value.filter((val) => val.state === 'ERROR').length === 1) {
|
|
235
147
|
clearErrors(step.id);
|
|
236
148
|
setError(undefined);
|
|
237
149
|
}
|
|
238
150
|
if (file.state !== undefined) {
|
|
239
151
|
setFileChange([
|
|
240
|
-
|
|
152
|
+
{
|
|
153
|
+
...file,
|
|
154
|
+
state: 'CANCEL',
|
|
155
|
+
},
|
|
241
156
|
]);
|
|
242
157
|
}
|
|
243
|
-
}, fetchDownloadUrl: fetchDownloadUrl }, index))
|
|
158
|
+
}, fetchDownloadUrl: fetchDownloadUrl }, index))) }), _jsx("div", { className: styles.errorMsg, style: { color: formStyle.errorColor }, children: error ?? calcErrorMsg() })] }));
|
|
244
159
|
}
|
|
245
160
|
function UploadStepComponent(props) {
|
|
246
161
|
return (_jsx(Controller, { name: props.step.id, control: props.control, defaultValue: [], rules: {
|
|
247
|
-
validate:
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
},
|
|
252
|
-
}, shouldUnregister: true, render: function (_a) {
|
|
253
|
-
var field = _a.field;
|
|
254
|
-
return (_jsx(FileUploadStep, __assign({}, props, { btnRef: field.ref, onChange: field.onChange, value: field.value })));
|
|
255
|
-
} }));
|
|
162
|
+
validate: (array) => ((props.step.required && array.length > 0) ||
|
|
163
|
+
!props.step.required) &&
|
|
164
|
+
array.find((file) => !file.S3Key) === undefined,
|
|
165
|
+
}, shouldUnregister: true, render: ({ field }) => (_jsx(FileUploadStep, { ...props, btnRef: field.ref, onChange: field.onChange, value: field.value })) }));
|
|
256
166
|
}
|
|
257
167
|
export default UploadStepComponent;
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
2
|
import { createElement as _createElement } from "react";
|
|
25
3
|
import styles from './MaterialRatingStep.module.css';
|
|
@@ -28,11 +6,9 @@ import React from 'react';
|
|
|
28
6
|
import Rating from '../../../../shared/Rating/Rating';
|
|
29
7
|
import { RatingTypes } from '../../../../constants/FormStepTypes';
|
|
30
8
|
import StepComponent from '../../Step';
|
|
31
|
-
function MaterialRatingStep(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var renderNestedOption = function () {
|
|
35
|
-
var currentOption;
|
|
9
|
+
function MaterialRatingStep({ form, step, value, level, errors, onChange, inputRef, editable, postview, formStyle, widthStats, ...others }) {
|
|
10
|
+
const renderNestedOption = () => {
|
|
11
|
+
let currentOption;
|
|
36
12
|
if (value !== undefined && value !== null && step.nestedSteps) {
|
|
37
13
|
if (step.ratingType === RatingTypes.LIKE) {
|
|
38
14
|
currentOption = step.nestedSteps[value];
|
|
@@ -41,31 +17,29 @@ function MaterialRatingStep(_a) {
|
|
|
41
17
|
currentOption = step.nestedSteps[value - 1];
|
|
42
18
|
}
|
|
43
19
|
if (currentOption && currentOption.length > 0) {
|
|
44
|
-
return (_jsx(React.Fragment, { children: currentOption.map(
|
|
45
|
-
|
|
46
|
-
return (_createElement(StepComponent,
|
|
20
|
+
return (_jsx(React.Fragment, { children: currentOption.map((idSubStep, index) => {
|
|
21
|
+
const subStep = form.steps[idSubStep];
|
|
22
|
+
return (_createElement(StepComponent, { ...others, form: form, postview: postview, editable: editable, formStyle: formStyle, errors: errors, widthStats: widthStats, step: subStep, key: index, level: level + 1 }));
|
|
47
23
|
}) }));
|
|
48
24
|
}
|
|
49
25
|
}
|
|
50
26
|
};
|
|
51
|
-
return (_jsxs(React.Fragment, { children: [_jsxs("div",
|
|
27
|
+
return (_jsxs(React.Fragment, { children: [_jsxs("div", { className: styles.container, style: {
|
|
52
28
|
paddingBottom: step.description || step.required ? 0 : 15,
|
|
53
|
-
}
|
|
29
|
+
}, children: [_jsx("div", { className: styles.labelLabel, children: step.label + (step.required ? ' *' : '') }), _jsx("div", { className: styles.ratingContainer, children: _jsx(Rating, { name: step.id, type: step.ratingType, isMobile: widthStats.isMobile, focusColor: formStyle.primaryColor ?? '#3d5a7f', unSelectedColor: formStyle.outlineColor ?? '#b8b8b8', disabled: !editable || postview, value: value, onChange: onChange, inputRef: inputRef }) }), (step.description || step.required) && (_jsx("div", { className: styles.stepDescriptionLabel, style: {
|
|
54
30
|
color: !!errors[step.id] && value === null
|
|
55
|
-
?
|
|
56
|
-
:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
31
|
+
? formStyle.errorColor ?? '#cc2936'
|
|
32
|
+
: formStyle.descriptionTextColor ??
|
|
33
|
+
'#989898',
|
|
34
|
+
}, children: !!errors[step.id] && value === null
|
|
35
|
+
? errors[step.id]?.message
|
|
36
|
+
: step.description }))] }), renderNestedOption()] }));
|
|
60
37
|
}
|
|
61
38
|
function RatingStep(props) {
|
|
62
39
|
return (_jsx(Controller, { name: props.step.id, control: props.control, defaultValue: null, rules: {
|
|
63
40
|
required: props.step.required
|
|
64
41
|
? 'Este campo es obligatorio'
|
|
65
42
|
: undefined,
|
|
66
|
-
}, shouldUnregister: true, render:
|
|
67
|
-
var field = _a.field;
|
|
68
|
-
return (_jsx(MaterialRatingStep, __assign({}, props, { inputRef: field.ref, value: field.value, onChange: field.onChange })));
|
|
69
|
-
} }));
|
|
43
|
+
}, shouldUnregister: true, render: ({ field }) => (_jsx(MaterialRatingStep, { ...props, inputRef: field.ref, value: field.value, onChange: field.onChange })) }));
|
|
70
44
|
}
|
|
71
45
|
export default RatingStep;
|
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
2
|
import { FormStyleTypes } from '../../../constants/FormStepTypes';
|
|
14
3
|
import MaterialRatingStep from './MaterialRatingStep/MaterialRatingStep';
|
|
15
4
|
function RatingStep(props) {
|
|
16
5
|
switch (props.formStyle.type) {
|
|
17
6
|
case FormStyleTypes.MATERIAL: {
|
|
18
|
-
return _jsx(MaterialRatingStep,
|
|
7
|
+
return _jsx(MaterialRatingStep, { ...props });
|
|
19
8
|
}
|
|
20
9
|
default: {
|
|
21
|
-
return _jsx(MaterialRatingStep,
|
|
10
|
+
return _jsx(MaterialRatingStep, { ...props });
|
|
22
11
|
}
|
|
23
12
|
}
|
|
24
13
|
}
|