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