@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,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 { createElement as _createElement } from "react";
|
|
24
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
3
|
import React, { useState } from 'react';
|
|
@@ -29,60 +7,58 @@ import StepComponent from '../../Step';
|
|
|
29
7
|
import { calcFillerSize, calcStepWidth } from '../../StepFunctions';
|
|
30
8
|
import { Controller } from 'react-hook-form';
|
|
31
9
|
import RoundedSmartSelect from '../../../../shared/RoundedSmartSelect/RoundedSmartSelect';
|
|
32
|
-
function Selector(
|
|
33
|
-
|
|
34
|
-
var _b = useState(level === 0
|
|
10
|
+
function Selector({ step, form, value, level, onBlur, control, editable, onChange, postview, formStyle, getValues, widthStats, handleSizeChange, errors, inputRef, ...others }) {
|
|
11
|
+
const [fillerSize, setFillerSize] = useState(level === 0
|
|
35
12
|
? calcFillerSize(step, form.steps, getValues(), form.size)
|
|
36
|
-
: 0)
|
|
37
|
-
|
|
13
|
+
: 0);
|
|
14
|
+
const sizeChange = () => {
|
|
38
15
|
handleSizeChange();
|
|
39
16
|
if (level === 0) {
|
|
40
17
|
setFillerSize(calcFillerSize(step, form.steps, getValues(), form.size));
|
|
41
18
|
}
|
|
42
19
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return (_jsx("div", __assign({ className: styles.container, style: {
|
|
20
|
+
const renderSelect = () => {
|
|
21
|
+
return (_jsx("div", { className: styles.container, style: {
|
|
46
22
|
width: widthStats.currentBreakPoint <= step.size
|
|
47
23
|
? '100%'
|
|
48
24
|
: calcStepWidth(step.size, form.size),
|
|
49
25
|
minHeight: step.description || step.required ? '55px' : '43px',
|
|
50
|
-
}
|
|
26
|
+
}, children: _jsx(RoundedSmartSelect, { value: value, onBlur: onBlur, disabled: false, loading: false, options: step.options, inputRef: inputRef, cantEdit: !editable || postview, fullWidth: true, backgroundColor: "transparent", innerBackgroundColor: formStyle.stepBackgroundColor ?? 'white', label: step.label, required: step.required, height: '31px', searchable: step.searchable, icon: undefined, helperTextColor: formStyle.descriptionTextColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, errorColor: formStyle.errorColor, color: formStyle.textColor, containerMargin: "0px", handleUpdate: (value) => {
|
|
51
27
|
onChange(value);
|
|
52
|
-
}, getOptionSelected:
|
|
53
|
-
return
|
|
28
|
+
}, getOptionSelected: (option, value) => {
|
|
29
|
+
return option?.value === value?.value;
|
|
54
30
|
}, helperText: errors[step.id]
|
|
55
31
|
? errors[step.id].message
|
|
56
|
-
: step.description, error: !!errors[step.id] }) }))
|
|
32
|
+
: step.description, error: !!errors[step.id] }) }));
|
|
57
33
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
for (
|
|
62
|
-
|
|
63
|
-
if (
|
|
34
|
+
const mapNestedOption = () => {
|
|
35
|
+
let currentOptionIndex = null;
|
|
36
|
+
let currentOption = null;
|
|
37
|
+
for (let i = 0; i < step.options.length; i++) {
|
|
38
|
+
const option = step.options[i];
|
|
39
|
+
if (option?.value === value?.value) {
|
|
64
40
|
currentOptionIndex = i;
|
|
65
41
|
currentOption = option;
|
|
66
42
|
}
|
|
67
43
|
}
|
|
68
|
-
if (
|
|
44
|
+
if (currentOption?.type === OptionTypes.NESTED &&
|
|
69
45
|
currentOptionIndex !== null) {
|
|
70
|
-
return (_jsx(React.Fragment, { children: currentOption.steps.map(
|
|
71
|
-
|
|
72
|
-
return (_createElement(StepComponent,
|
|
46
|
+
return (_jsx(React.Fragment, { children: currentOption.steps.map((idSubStep, index) => {
|
|
47
|
+
const subStep = form.steps[idSubStep];
|
|
48
|
+
return (_createElement(StepComponent, { ...others, postview: postview, editable: editable, formStyle: formStyle, form: form, getValues: getValues, errors: errors, control: control, widthStats: widthStats, step: subStep, key: index, level: level + 1, handleSizeChange: () => {
|
|
73
49
|
sizeChange();
|
|
74
|
-
} }))
|
|
50
|
+
} }));
|
|
75
51
|
}) }));
|
|
76
52
|
}
|
|
77
53
|
};
|
|
78
54
|
if (level === 0 && step.maxSize < form.size.blockNum) {
|
|
79
|
-
return (_jsxs("div",
|
|
55
|
+
return (_jsxs("div", { className: styles.firstLvlContainer, style: {
|
|
80
56
|
width: widthStats.currentBreakPoint <= step.size
|
|
81
57
|
? '100%'
|
|
82
58
|
: 'fit-content',
|
|
83
|
-
}
|
|
59
|
+
}, children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize < form.size.blockNum && (_jsx("div", { className: styles.smallSeparator, style: {
|
|
84
60
|
width: fillerSize,
|
|
85
|
-
} }))] }))
|
|
61
|
+
} }))] }));
|
|
86
62
|
}
|
|
87
63
|
else {
|
|
88
64
|
return (_jsxs(React.Fragment, { children: [renderSelect(), mapNestedOption(), level === 0 && _jsx("div", { className: styles.separator })] }));
|
|
@@ -93,9 +69,6 @@ function SelectorStep(props) {
|
|
|
93
69
|
required: props.step.required
|
|
94
70
|
? 'Este campo es obligatorio'
|
|
95
71
|
: undefined,
|
|
96
|
-
}, shouldUnregister: true, render:
|
|
97
|
-
var field = _a.field;
|
|
98
|
-
return (_jsx(Selector, __assign({}, props, { inputRef: field.ref, value: field.value, onChange: field.onChange, onBlur: field.onBlur })));
|
|
99
|
-
} }));
|
|
72
|
+
}, shouldUnregister: true, render: ({ field }) => (_jsx(Selector, { ...props, inputRef: field.ref, value: field.value, onChange: field.onChange, onBlur: field.onBlur })) }));
|
|
100
73
|
}
|
|
101
74
|
export default SelectorStep;
|
|
@@ -1,36 +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
|
-
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 } from "react/jsx-runtime";
|
|
24
2
|
import { FormStyleTypes } from '../../../constants/FormStepTypes';
|
|
25
3
|
import MaterialSelectorStep from './MaterialSelectorStep/MaterialSelectorStep';
|
|
26
|
-
function SelectorStep(
|
|
27
|
-
var formStyle = _a.formStyle, others = __rest(_a, ["formStyle"]);
|
|
4
|
+
function SelectorStep({ formStyle, ...others }) {
|
|
28
5
|
switch (formStyle.type) {
|
|
29
6
|
case FormStyleTypes.MATERIAL: {
|
|
30
|
-
return _jsx(MaterialSelectorStep,
|
|
7
|
+
return _jsx(MaterialSelectorStep, { formStyle: formStyle, ...others });
|
|
31
8
|
}
|
|
32
9
|
default: {
|
|
33
|
-
return _jsx(MaterialSelectorStep,
|
|
10
|
+
return _jsx(MaterialSelectorStep, { formStyle: formStyle, ...others });
|
|
34
11
|
}
|
|
35
12
|
}
|
|
36
13
|
}
|
package/dist/FormComponents/Step/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import styles from './MaterialSeparatorStep.module.css';
|
|
3
|
-
function SeparatorStep(
|
|
4
|
-
var step = _a.step, formStyle = _a.formStyle;
|
|
3
|
+
function SeparatorStep({ step, formStyle }) {
|
|
5
4
|
return (_jsx("div", { className: styles.container, style: {
|
|
6
5
|
backgroundColor: step.transparent
|
|
7
6
|
? 'transparent'
|
|
@@ -1,36 +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
|
-
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 } from "react/jsx-runtime";
|
|
24
2
|
import { FormStyleTypes } from '../../../constants/FormStepTypes';
|
|
25
3
|
import MaterialSeparatorStep from './MaterialSeparatorStep/MaterialSeparatorStep';
|
|
26
|
-
function SeparatorStep(
|
|
27
|
-
var step = _a.step, formStyle = _a.formStyle, others = __rest(_a, ["step", "formStyle"]);
|
|
4
|
+
function SeparatorStep({ step, formStyle, ...others }) {
|
|
28
5
|
switch (formStyle.type) {
|
|
29
6
|
case FormStyleTypes.MATERIAL: {
|
|
30
|
-
return (_jsx(MaterialSeparatorStep,
|
|
7
|
+
return (_jsx(MaterialSeparatorStep, { step: step, formStyle: formStyle, ...others }));
|
|
31
8
|
}
|
|
32
9
|
default: {
|
|
33
|
-
return (_jsx(MaterialSeparatorStep,
|
|
10
|
+
return (_jsx(MaterialSeparatorStep, { step: step, formStyle: formStyle, ...others }));
|
|
34
11
|
}
|
|
35
12
|
}
|
|
36
13
|
}
|
package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js
CHANGED
|
@@ -1,61 +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 __rest = (this && this.__rest) || function (s, e) {
|
|
49
|
-
var t = {};
|
|
50
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
-
t[p] = s[p];
|
|
52
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
-
t[p[i]] = s[p[i]];
|
|
56
|
-
}
|
|
57
|
-
return t;
|
|
58
|
-
};
|
|
59
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
60
2
|
import styles from './MaterialSmartSelectStep.module.css';
|
|
61
3
|
import { Controller } from 'react-hook-form';
|
|
@@ -63,60 +5,44 @@ import { calcStepWidth } from '../../StepFunctions';
|
|
|
63
5
|
import RoundedSmartSelect from '../../../../shared/RoundedSmartSelect/RoundedSmartSelect';
|
|
64
6
|
import { cloneElement, useEffect, useState } from 'react';
|
|
65
7
|
import React from 'react';
|
|
66
|
-
function SmartSelect(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var missingDeps = [];
|
|
72
|
-
for (var _i = 0, _b = (_a = step.dependencies) !== null && _a !== void 0 ? _a : []; _i < _b.length; _i++) {
|
|
73
|
-
var idDep = _b[_i];
|
|
74
|
-
if (depStore[idDep] === null) {
|
|
75
|
-
missingDeps.push(idDep);
|
|
76
|
-
}
|
|
8
|
+
function SmartSelect({ icon, step, form, value, onBlur, errors, trigger, children, editable, onChange, inputRef, postview, formStyle, getOptions, widthStats, organization, calcDepError, valueOverwrite, getValueString, originalValues, changeListener, dependencyStore, calcInvalidDeps = (step, depStore) => {
|
|
9
|
+
const missingDeps = [];
|
|
10
|
+
for (const idDep of step.dependencies ?? []) {
|
|
11
|
+
if (depStore[idDep] === null) {
|
|
12
|
+
missingDeps.push(idDep);
|
|
77
13
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (invalidDeps !== undefined && currentValue) {
|
|
94
|
-
currentOption = resp.find(function (option) {
|
|
95
|
-
return getOptionSelected(option, currentValue);
|
|
96
|
-
});
|
|
97
|
-
if (!currentOption) {
|
|
98
|
-
setError('Este campo es obligatorio');
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
invalids = (_a = calcInvalidDeps === null || calcInvalidDeps === void 0 ? void 0 : calcInvalidDeps(step, dependencyStore)) !== null && _a !== void 0 ? _a : [];
|
|
103
|
-
if (invalids.length === 0) {
|
|
104
|
-
setError(undefined);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
setOptions(resp);
|
|
109
|
-
setLoading(false);
|
|
110
|
-
return [2 /*return*/];
|
|
14
|
+
}
|
|
15
|
+
return missingDeps;
|
|
16
|
+
}, getValueWarning, getOptionSelected, setDependencyStore, ...others }) {
|
|
17
|
+
const [first, setFirst] = useState(true);
|
|
18
|
+
const [options, setOptions] = useState();
|
|
19
|
+
const [error, setError] = useState();
|
|
20
|
+
const [loading, setLoading] = useState(false);
|
|
21
|
+
const calcOptions = async (currentValue, invalidDeps) => {
|
|
22
|
+
const resp = await getOptions?.(organization.idOrganization, step, dependencyStore);
|
|
23
|
+
if (resp !== null) {
|
|
24
|
+
if (invalidDeps !== undefined && currentValue) {
|
|
25
|
+
const currentOption = resp.find((option) => getOptionSelected(option, currentValue));
|
|
26
|
+
if (!currentOption) {
|
|
27
|
+
setError('Este campo es obligatorio');
|
|
28
|
+
}
|
|
111
29
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
30
|
+
else {
|
|
31
|
+
const invalids = calcInvalidDeps?.(step, dependencyStore) ?? [];
|
|
32
|
+
if (invalids.length === 0) {
|
|
33
|
+
setError(undefined);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
setOptions(resp);
|
|
38
|
+
setLoading(false);
|
|
39
|
+
};
|
|
40
|
+
useEffect(() => {
|
|
115
41
|
if (!postview) {
|
|
116
42
|
if (first) {
|
|
117
43
|
setFirst(false);
|
|
118
|
-
|
|
119
|
-
setError(calcDepError
|
|
44
|
+
const invalids = calcInvalidDeps(step, dependencyStore).filter((idDep) => originalValues[idDep]);
|
|
45
|
+
setError(calcDepError?.(invalids.map((idDep) => form.steps[idDep]?.type)));
|
|
120
46
|
calcOptions(value, invalids);
|
|
121
47
|
}
|
|
122
48
|
else {
|
|
@@ -131,79 +57,91 @@ function SmartSelect(_a) {
|
|
|
131
57
|
else if (value && !step.searchable) {
|
|
132
58
|
setOptions([value]);
|
|
133
59
|
}
|
|
134
|
-
},
|
|
60
|
+
}, step.dependencies?.map((dep) => dependencyStore[dep]) ?? []);
|
|
135
61
|
/**
|
|
136
62
|
* If the original value has no label search for it in the list.
|
|
137
63
|
*/
|
|
138
|
-
useEffect(
|
|
139
|
-
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
const original = originalValues[step.id];
|
|
140
66
|
if (original &&
|
|
141
67
|
options &&
|
|
142
68
|
getValueString(original) !== undefined &&
|
|
143
69
|
!original.label) {
|
|
144
|
-
|
|
70
|
+
const newValue = options.find((option) => getValueString(option) === getValueString(original));
|
|
145
71
|
onChange(newValue);
|
|
146
72
|
}
|
|
147
73
|
}, [originalValues[step.id], options]);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
else {
|
|
159
|
-
setLoading(true);
|
|
160
|
-
}
|
|
74
|
+
const handleMissingDep = async () => {
|
|
75
|
+
if (step.dependencies) {
|
|
76
|
+
const invalids = calcInvalidDeps(step, dependencyStore);
|
|
77
|
+
setError(calcDepError?.(invalids.map((idDep) => form.steps[idDep]?.type)));
|
|
78
|
+
if (!value) {
|
|
79
|
+
if (invalids.length > 0) {
|
|
80
|
+
trigger(invalids, { shouldFocus: true });
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
setLoading(true);
|
|
161
84
|
}
|
|
162
85
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return (_jsxs(React.Fragment, { children: [_jsx("div", __assign({ className: styles.container, style: {
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const warning = getValueWarning?.(value);
|
|
89
|
+
return (_jsxs(React.Fragment, { children: [_jsx("div", { className: styles.container, style: {
|
|
168
90
|
width: widthStats.currentBreakPoint <= step.size
|
|
169
91
|
? '100%'
|
|
170
92
|
: calcStepWidth(step.size, form.size),
|
|
171
93
|
minHeight: step.description || step.required ? '55px' : '43px',
|
|
172
|
-
}, onClick:
|
|
94
|
+
}, onClick: () => {
|
|
173
95
|
if (options === null && !(!editable || postview)) {
|
|
174
96
|
handleMissingDep();
|
|
175
97
|
}
|
|
176
98
|
if (options === undefined && !(!editable || postview)) {
|
|
177
99
|
setLoading(true);
|
|
178
100
|
}
|
|
179
|
-
}, "data-testid": step.id
|
|
180
|
-
var _a;
|
|
101
|
+
}, "data-testid": step.id, children: _jsx(RoundedSmartSelect, { value: value, onBlur: onBlur, disabled: options === null, loading: loading, options: options ?? [], inputRef: inputRef, cantEdit: !editable || postview, fullWidth: true, backgroundColor: "transparent", innerBackgroundColor: formStyle.stepBackgroundColor ?? 'white', label: step.label, required: step.required, height: '31px', changeListener: changeListener, searchable: step.searchable, icon: step.showIcon ? icon : undefined, helperTextColor: formStyle.descriptionTextColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, errorColor: formStyle.errorColor, color: formStyle.textColor, containerMargin: "0px", handleUpdate: (value) => {
|
|
181
102
|
if (dependencyStore[step.id] !== undefined) {
|
|
182
|
-
setDependencyStore(
|
|
103
|
+
setDependencyStore({
|
|
104
|
+
...dependencyStore,
|
|
105
|
+
[step.id]: value,
|
|
106
|
+
});
|
|
183
107
|
}
|
|
184
108
|
valueOverwrite
|
|
185
109
|
? onChange(valueOverwrite(value))
|
|
186
110
|
: onChange(value);
|
|
187
111
|
setError(undefined);
|
|
188
|
-
}, getOptionSelected: getOptionSelected, getValueString: getValueString, helperText:
|
|
189
|
-
|
|
190
|
-
|
|
112
|
+
}, getOptionSelected: getOptionSelected, getValueString: getValueString, helperText: error ??
|
|
113
|
+
warning ??
|
|
114
|
+
(errors[step.id]
|
|
115
|
+
? errors[step.id].message
|
|
116
|
+
: step.description), error: error !== undefined ||
|
|
191
117
|
(warning !== undefined && warning !== null) ||
|
|
192
|
-
!!errors[step.id] }) })
|
|
118
|
+
!!errors[step.id] }) }), children &&
|
|
193
119
|
cloneElement(children, {
|
|
194
|
-
value
|
|
195
|
-
stepProps:
|
|
120
|
+
value,
|
|
121
|
+
stepProps: {
|
|
122
|
+
step,
|
|
123
|
+
form,
|
|
124
|
+
errors,
|
|
125
|
+
trigger,
|
|
126
|
+
postview,
|
|
127
|
+
editable,
|
|
128
|
+
formStyle,
|
|
129
|
+
widthStats,
|
|
130
|
+
organization,
|
|
131
|
+
originalValues,
|
|
132
|
+
dependencyStore,
|
|
133
|
+
setDependencyStore,
|
|
134
|
+
...others,
|
|
135
|
+
},
|
|
196
136
|
})] }));
|
|
197
137
|
}
|
|
198
138
|
function SmartSelectStep(props) {
|
|
199
|
-
|
|
200
|
-
|
|
139
|
+
return (_jsx(Controller, { name: props.step.id, control: props.control, defaultValue: props.originalValues[props.step.id] ??
|
|
140
|
+
props.defaultValue ??
|
|
141
|
+
null, rules: {
|
|
201
142
|
required: props.step.required
|
|
202
143
|
? 'Este campo es obligatorio'
|
|
203
144
|
: undefined,
|
|
204
|
-
}, shouldUnregister: true, render:
|
|
205
|
-
var field = _a.field;
|
|
206
|
-
return (_jsx(SmartSelect, __assign({}, props, { inputRef: field.ref, value: field.value, onChange: field.onChange, onBlur: field.onBlur })));
|
|
207
|
-
} }));
|
|
145
|
+
}, shouldUnregister: true, render: ({ field }) => (_jsx(SmartSelect, { ...props, inputRef: field.ref, value: field.value, onChange: field.onChange, onBlur: field.onBlur })) }));
|
|
208
146
|
}
|
|
209
147
|
export default SmartSelectStep;
|
|
@@ -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 MaterialSmartSelectStep from './MaterialSmartSelectStep/MaterialSmartSelectStep';
|
|
15
4
|
function SmartSelectStep(props) {
|
|
16
5
|
switch (props.formStyle.type) {
|
|
17
6
|
case FormStyleTypes.MATERIAL: {
|
|
18
|
-
return _jsx(MaterialSmartSelectStep,
|
|
7
|
+
return _jsx(MaterialSmartSelectStep, { ...props });
|
|
19
8
|
}
|
|
20
9
|
default: {
|
|
21
|
-
return _jsx(MaterialSmartSelectStep,
|
|
10
|
+
return _jsx(MaterialSmartSelectStep, { ...props });
|
|
22
11
|
}
|
|
23
12
|
}
|
|
24
13
|
}
|
|
@@ -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 } from "react/jsx-runtime";
|
|
24
2
|
import Types from '../../constants/FormStepTypes';
|
|
25
3
|
import SelectorStep from './SelectorStep/SelectorStep';
|
|
@@ -34,52 +12,54 @@ import CheckBoxStep from './CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxSt
|
|
|
34
12
|
import CBRStepMapper from './CBRStepMapper';
|
|
35
13
|
import RatingStep from './RatingStep/RatingStep';
|
|
36
14
|
import AYFStepMapper from './AYFStepMapper';
|
|
37
|
-
function StepComponent(
|
|
38
|
-
|
|
39
|
-
var step = _a.step, props = __rest(_a, ["step"]);
|
|
40
|
-
var customStep = props.customSteps[step.type];
|
|
15
|
+
function StepComponent({ step, ...props }) {
|
|
16
|
+
const customStep = props.customSteps[step.type];
|
|
41
17
|
if (customStep) {
|
|
42
|
-
return customStep.component(
|
|
18
|
+
return customStep.component({
|
|
19
|
+
step,
|
|
20
|
+
...props,
|
|
21
|
+
...(customStep.componentProps ?? {}),
|
|
22
|
+
});
|
|
43
23
|
}
|
|
44
24
|
switch (step.type) {
|
|
45
25
|
case Types.TITLE: {
|
|
46
|
-
return _jsx(TitleStep,
|
|
26
|
+
return _jsx(TitleStep, { step: step, ...props });
|
|
47
27
|
}
|
|
48
28
|
case Types.SELECTOR: {
|
|
49
|
-
return _jsx(SelectorStep,
|
|
29
|
+
return _jsx(SelectorStep, { step: step, ...props });
|
|
50
30
|
}
|
|
51
31
|
case Types.CHECKBOX: {
|
|
52
|
-
return _jsx(CheckBoxStep,
|
|
32
|
+
return _jsx(CheckBoxStep, { step: step, ...props });
|
|
53
33
|
}
|
|
54
34
|
case Types.CLASSIFIER_SELECTOR: {
|
|
55
|
-
return (_jsx(ClassifierSelectorStep,
|
|
35
|
+
return (_jsx(ClassifierSelectorStep, { step: step, ...props }));
|
|
56
36
|
}
|
|
57
37
|
case Types.TEXTAREA: {
|
|
58
|
-
return _jsx(TextAreaStep,
|
|
38
|
+
return _jsx(TextAreaStep, { step: step, ...props });
|
|
59
39
|
}
|
|
60
40
|
case Types.TEXTINPUT: {
|
|
61
|
-
return _jsx(TextInputStep,
|
|
41
|
+
return _jsx(TextInputStep, { step: step, ...props });
|
|
62
42
|
}
|
|
63
43
|
case Types.DATEPICKER: {
|
|
64
|
-
return _jsx(DatePickerStep,
|
|
44
|
+
return _jsx(DatePickerStep, { step: step, ...props });
|
|
65
45
|
}
|
|
66
46
|
case Types.SEPARATOR: {
|
|
67
|
-
return _jsx(SeparatorStep,
|
|
47
|
+
return _jsx(SeparatorStep, { step: step, ...props });
|
|
68
48
|
}
|
|
69
49
|
case Types.FILEUPLOAD: {
|
|
70
|
-
return _jsx(FileUploadStep,
|
|
50
|
+
return _jsx(FileUploadStep, { step: step, ...props });
|
|
71
51
|
}
|
|
72
52
|
case Types.RATING: {
|
|
73
|
-
return _jsx(RatingStep,
|
|
53
|
+
return _jsx(RatingStep, { step: step, ...props });
|
|
74
54
|
}
|
|
75
55
|
default:
|
|
76
56
|
break;
|
|
77
57
|
}
|
|
78
58
|
if (step.type.startsWith('CBR')) {
|
|
79
|
-
return _jsx(CBRStepMapper,
|
|
59
|
+
return _jsx(CBRStepMapper, { ...props, step: step });
|
|
80
60
|
}
|
|
81
61
|
else if (step.type.startsWith('AYF')) {
|
|
82
|
-
return _jsx(AYFStepMapper,
|
|
62
|
+
return _jsx(AYFStepMapper, { ...props, step: step });
|
|
83
63
|
}
|
|
84
64
|
return _jsx("div", {});
|
|
85
65
|
}
|