@arquimedes.co/eureka-forms 1.9.19-test → 1.9.20
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 +70 -49
- 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 +29 -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,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 React, { useEffect, useState } from 'react';
|
|
3
25
|
import { FormStyleTypes, FormTypes } from '../../constants/FormStepTypes';
|
|
@@ -12,27 +34,31 @@ import { SEED } from '../../constants/MaterialClassNameSeed';
|
|
|
12
34
|
import InternalFormStyle from '../../constants/InternalFormStyle';
|
|
13
35
|
import enLocale from 'date-fns/locale/en-US';
|
|
14
36
|
import esLocale from 'date-fns/locale/es';
|
|
15
|
-
|
|
37
|
+
var localeMap = {
|
|
16
38
|
en: enLocale,
|
|
17
39
|
'en-US': enLocale,
|
|
18
40
|
es: esLocale,
|
|
19
41
|
};
|
|
20
|
-
export
|
|
21
|
-
|
|
42
|
+
export var getLocale = function () {
|
|
43
|
+
var _a;
|
|
44
|
+
return ((_a = localeMap[navigator.languages && navigator.languages.length
|
|
22
45
|
? navigator.languages[0]
|
|
23
46
|
: navigator.userLanguage ||
|
|
24
47
|
navigator.language ||
|
|
25
|
-
navigator.browserLanguage]
|
|
48
|
+
navigator.browserLanguage]) !== null && _a !== void 0 ? _a : localeMap.es);
|
|
26
49
|
};
|
|
27
|
-
function FormComponent(
|
|
28
|
-
|
|
29
|
-
|
|
50
|
+
function FormComponent(_a) {
|
|
51
|
+
var _b, _c;
|
|
52
|
+
var form = _a.form, isWidget = _a.isWidget, internal = _a.internal, postview = _a.postview, organization = _a.organization, containerRef = _a.containerRef, others = __rest(_a, ["form", "isWidget", "internal", "postview", "organization", "containerRef"]);
|
|
53
|
+
var _d = useState(false), loaded = _d[0], setLoaded = _d[1];
|
|
54
|
+
var _e = useState(undefined), widthStats = _e[0], setWidthStats = _e[1];
|
|
30
55
|
/** Calcs the currentBreakPoint and if is mobile */
|
|
31
|
-
|
|
32
|
-
|
|
56
|
+
var handleResize = function () {
|
|
57
|
+
var _a;
|
|
58
|
+
var currentWidth = (_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth;
|
|
33
59
|
if (currentWidth !== undefined) {
|
|
34
|
-
|
|
35
|
-
|
|
60
|
+
var currentBreakPoint = form.size.blockNum;
|
|
61
|
+
var padding = postview || internal || !form.isStandAlone ? 0 : 40;
|
|
36
62
|
while (currentWidth <
|
|
37
63
|
(form.size.blockSize + form.size.spacingSize) *
|
|
38
64
|
currentBreakPoint +
|
|
@@ -46,71 +72,72 @@ function FormComponent({ form, isWidget, internal, postview, organization, conta
|
|
|
46
72
|
padding,
|
|
47
73
|
isMobile: currentWidth <
|
|
48
74
|
(form.size.blockSize + form.size.spacingSize) * 2 + padding,
|
|
49
|
-
currentBreakPoint,
|
|
75
|
+
currentBreakPoint: currentBreakPoint,
|
|
50
76
|
});
|
|
51
77
|
}
|
|
52
78
|
};
|
|
53
|
-
useEffect(()
|
|
79
|
+
useEffect(function () {
|
|
54
80
|
/** On load add a resize listener to calc the currentBreakpoint */
|
|
55
81
|
window.addEventListener('resize', handleResize);
|
|
56
82
|
handleResize();
|
|
57
|
-
return ()
|
|
83
|
+
return function () {
|
|
58
84
|
window.removeEventListener('resize', handleResize);
|
|
59
85
|
};
|
|
60
|
-
}, [containerRef.current, containerRef.current
|
|
86
|
+
}, [containerRef.current, (_b = containerRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth]);
|
|
61
87
|
//If currently displaying internal or form is standalone
|
|
62
88
|
if ((postview || internal || !form.isStandAlone) &&
|
|
63
89
|
widthStats !== undefined) {
|
|
64
|
-
return (_jsx("div", { style: {
|
|
90
|
+
return (_jsx("div", __assign({ style: {
|
|
65
91
|
backgroundColor: internal
|
|
66
92
|
? InternalFormStyle.backgroundColor
|
|
67
93
|
: form.style.backgroundColor,
|
|
68
94
|
minHeight: form.isStandAlone && !isWidget ? '100vh' : '100%',
|
|
69
|
-
}, children: _jsx("div", { className: styles.widgetFormContainer, ref: containerRef, children: _jsx(FormTypeComponent, {
|
|
95
|
+
} }, { children: _jsx("div", __assign({ className: styles.widgetFormContainer, ref: containerRef }, { children: _jsx(FormTypeComponent, __assign({}, others, { handleLoaded: function () {
|
|
70
96
|
setLoaded(true);
|
|
71
|
-
}, widthStats: widthStats, form: form, internal: internal, postview: postview, organization: organization, formStyle: internal ? InternalFormStyle : form.style }) }) }));
|
|
97
|
+
}, widthStats: widthStats, form: form, internal: internal, postview: postview, organization: organization, formStyle: internal ? InternalFormStyle : form.style })) })) })));
|
|
72
98
|
}
|
|
73
99
|
else if (organization && widthStats !== undefined) {
|
|
74
100
|
//Standalone cant have widget
|
|
75
|
-
return (_jsxs(React.Fragment, { children: [_jsx(Navbar, { logo: organization.logoUrl, color: organization.styles
|
|
101
|
+
return (_jsxs(React.Fragment, { children: [_jsx(Navbar, { logo: organization.logoUrl, color: (_c = organization.styles) === null || _c === void 0 ? void 0 : _c.primaryColor }), _jsx("div", __assign({ className: styles.standAloneFormContainer, ref: containerRef }, { children: _jsx("div", __assign({ className: widthStats.isResponsive
|
|
76
102
|
? styles.fullScreenStandAloneForm
|
|
77
103
|
: styles.standAloneFormCard, style: {
|
|
78
104
|
backgroundColor: form.style.backgroundColor,
|
|
79
105
|
visibility: loaded ? 'visible' : 'hidden',
|
|
80
|
-
}, children: _jsx(FormTypeComponent, {
|
|
106
|
+
} }, { children: _jsx(FormTypeComponent, __assign({}, others, { internal: internal, postview: postview, widthStats: widthStats, form: form, formStyle: form.style, organization: organization, handleLoaded: function () {
|
|
81
107
|
setLoaded(true);
|
|
82
|
-
} }) }) })] }));
|
|
108
|
+
} })) })) }))] }));
|
|
83
109
|
}
|
|
84
110
|
else {
|
|
85
111
|
return _jsx("div", {});
|
|
86
112
|
}
|
|
87
113
|
}
|
|
88
|
-
|
|
114
|
+
var muiTheme = createTheme({
|
|
89
115
|
typography: {
|
|
90
116
|
fontFamily: 'inherit',
|
|
91
117
|
},
|
|
92
118
|
});
|
|
93
|
-
|
|
119
|
+
var generateClassName = createGenerateClassName({
|
|
94
120
|
seed: SEED,
|
|
95
121
|
productionPrefix: 'efjss',
|
|
96
122
|
});
|
|
97
|
-
function FormTypeComponent(
|
|
98
|
-
|
|
123
|
+
function FormTypeComponent(_a) {
|
|
124
|
+
var props = __rest(_a, []);
|
|
125
|
+
var renderTypes = function () {
|
|
99
126
|
switch (props.form.type) {
|
|
100
127
|
case FormTypes.COLUMN: {
|
|
101
|
-
return _jsx(ColumnForm, {
|
|
128
|
+
return _jsx(ColumnForm, __assign({}, props));
|
|
102
129
|
}
|
|
103
130
|
case FormTypes.STEPPER: {
|
|
104
|
-
return _jsx(StepperForm, {
|
|
131
|
+
return _jsx(StepperForm, __assign({}, props));
|
|
105
132
|
}
|
|
106
133
|
default: {
|
|
107
|
-
return _jsx(ColumnForm, {
|
|
134
|
+
return _jsx(ColumnForm, __assign({}, props));
|
|
108
135
|
}
|
|
109
136
|
}
|
|
110
137
|
};
|
|
111
138
|
switch (props.formStyle.type) {
|
|
112
139
|
case FormStyleTypes.MATERIAL:
|
|
113
|
-
return (_jsx(StylesProvider, { generateClassName: generateClassName, children: _jsx(ThemeProvider, { theme: muiTheme, children: _jsx(MuiPickersUtilsProvider, { utils: DateFnsUtils, locale: getLocale(), children: renderTypes() }) }) }));
|
|
140
|
+
return (_jsx(StylesProvider, __assign({ generateClassName: generateClassName }, { children: _jsx(ThemeProvider, __assign({ theme: muiTheme }, { children: _jsx(MuiPickersUtilsProvider, __assign({ utils: DateFnsUtils, locale: getLocale() }, { children: renderTypes() })) })) })));
|
|
114
141
|
default:
|
|
115
142
|
return renderTypes();
|
|
116
143
|
}
|
|
@@ -1,18 +1,41 @@
|
|
|
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 { createElement as _createElement } from "react";
|
|
2
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
25
|
import StepComponent from '../../Step/Step';
|
|
4
26
|
import styles from './MaterialSection.module.css';
|
|
5
|
-
function MaterialSection(
|
|
6
|
-
|
|
7
|
-
|
|
27
|
+
function MaterialSection(_a) {
|
|
28
|
+
var form = _a.form, section = _a.section, widthStats = _a.widthStats, sendLabel = _a.sendLabel, others = __rest(_a, ["form", "section", "widthStats", "sendLabel"]);
|
|
29
|
+
var postview = others.postview, partial = others.partial, originalValues = others.originalValues;
|
|
30
|
+
return (_jsx("div", __assign({ className: styles.container, style: {
|
|
8
31
|
width: (form.size.blockSize + form.size.spacingSize) *
|
|
9
32
|
form.size.blockNum,
|
|
10
33
|
justifyContent: sendLabel !== undefined &&
|
|
11
34
|
widthStats.currentBreakPoint < form.size.blockNum
|
|
12
35
|
? 'center'
|
|
13
36
|
: 'normal',
|
|
14
|
-
}, children: section.steps.map((idStep, index)
|
|
15
|
-
|
|
37
|
+
} }, { children: section.steps.map(function (idStep, index) {
|
|
38
|
+
var step = form.steps[idStep];
|
|
16
39
|
//If partial is active only display steps with originalValues
|
|
17
40
|
if (postview &&
|
|
18
41
|
partial &&
|
|
@@ -20,12 +43,12 @@ function MaterialSection({ form, section, widthStats, sendLabel, ...others }) {
|
|
|
20
43
|
return _jsx("div", {}, index);
|
|
21
44
|
}
|
|
22
45
|
else if (step) {
|
|
23
|
-
return (_createElement(StepComponent, {
|
|
46
|
+
return (_createElement(StepComponent, __assign({}, others, { widthStats: widthStats, form: form, step: step, handleSizeChange: function () { }, key: index, level: 0 })));
|
|
24
47
|
}
|
|
25
48
|
else {
|
|
26
49
|
console.error('Step not found:', idStep);
|
|
27
50
|
return _jsx("div", {}, index);
|
|
28
51
|
}
|
|
29
|
-
}) }));
|
|
52
|
+
}) })));
|
|
30
53
|
}
|
|
31
54
|
export default MaterialSection;
|
|
@@ -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 MaterialSection from './MaterialSection/MaterialSection';
|
|
4
15
|
function SectionComponent(props) {
|
|
5
16
|
switch (props.formStyle.type) {
|
|
6
17
|
case FormStyleTypes.MATERIAL: {
|
|
7
|
-
return _jsx(MaterialSection, {
|
|
18
|
+
return _jsx(MaterialSection, __assign({}, props));
|
|
8
19
|
}
|
|
9
20
|
default: {
|
|
10
|
-
return _jsx(MaterialSection, {
|
|
21
|
+
return _jsx(MaterialSection, __assign({}, props));
|
|
11
22
|
}
|
|
12
23
|
}
|
|
13
24
|
}
|
|
@@ -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 MaterialCBRIncidentsStep from './MaterialCBRIncidentsStep/MaterialCBRIncidentsStep';
|
|
4
15
|
function CBRIncidentsStep(props) {
|
|
5
16
|
switch (props.formStyle.type) {
|
|
6
17
|
case FormStyleTypes.MATERIAL: {
|
|
7
|
-
return _jsx(MaterialCBRIncidentsStep, {
|
|
18
|
+
return _jsx(MaterialCBRIncidentsStep, __assign({}, props));
|
|
8
19
|
}
|
|
9
20
|
default: {
|
|
10
|
-
return _jsx(MaterialCBRIncidentsStep, {
|
|
21
|
+
return _jsx(MaterialCBRIncidentsStep, __assign({}, props));
|
|
11
22
|
}
|
|
12
23
|
}
|
|
13
24
|
}
|
|
@@ -1,26 +1,49 @@
|
|
|
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 styles from './Incident.module.css';
|
|
3
25
|
import StepComponent from '../../../../Step';
|
|
4
26
|
import DeleteRoundedIcon from '@material-ui/icons/DeleteRounded';
|
|
5
27
|
import TextAreaStep from '../../../../TextAreaStep/TextAreaStep';
|
|
6
|
-
function IncidentComponent(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
28
|
+
function IncidentComponent(_a) {
|
|
29
|
+
var step = _a.step, form = _a.form, level = _a.level, incident = _a.incident, formStyle = _a.formStyle, handleDelete = _a.handleDelete, others = __rest(_a, ["step", "form", "level", "incident", "formStyle", "handleDelete"]);
|
|
30
|
+
var spaceStep = form.steps[incident.idSpaceStep];
|
|
31
|
+
var elementStep = form.steps[incident.idElementStep];
|
|
32
|
+
var commentStep = form.steps[incident.idCommentStep];
|
|
10
33
|
if (incident.deleted) {
|
|
11
34
|
return _jsx("div", {});
|
|
12
35
|
}
|
|
13
|
-
return (_jsx("div", { className: others.widthStats.isMobile || form.size.blockNum < 3
|
|
36
|
+
return (_jsx("div", __assign({ className: others.widthStats.isMobile || form.size.blockNum < 3
|
|
14
37
|
? styles.mobileContainer
|
|
15
|
-
: styles.container, children: _jsxs("div", { className: styles.contentContainer, style: {
|
|
38
|
+
: styles.container }, { children: _jsxs("div", __assign({ className: styles.contentContainer, style: {
|
|
16
39
|
width: (form.size.blockSize + form.size.spacingSize) *
|
|
17
40
|
(form.size.blockNum - 1),
|
|
18
|
-
}, children: [_jsxs("div", { className: styles.titleLbl, style: { color: formStyle.textColor }, children: [step.unitLabel + ' ' + incident.num, ":"] }), _jsx("div", { className: !others.editable || others.postview
|
|
41
|
+
} }, { children: [_jsxs("div", __assign({ className: styles.titleLbl, style: { color: formStyle.textColor } }, { children: [step.unitLabel + ' ' + incident.num, ":"] })), _jsx("div", __assign({ className: !others.editable || others.postview
|
|
19
42
|
? styles.disabledDeleteBtn
|
|
20
|
-
: styles.deleteBtn, style: { color: formStyle.textColor }, onClick: ()
|
|
43
|
+
: styles.deleteBtn, style: { color: formStyle.textColor }, onClick: function () {
|
|
21
44
|
if (others.editable && !others.postview) {
|
|
22
45
|
handleDelete();
|
|
23
46
|
}
|
|
24
|
-
}, children: _jsx(DeleteRoundedIcon, { fontSize: "inherit" }) }), _jsx(StepComponent, {
|
|
47
|
+
} }, { children: _jsx(DeleteRoundedIcon, { fontSize: "inherit" }) })), _jsx(StepComponent, __assign({}, others, { formStyle: formStyle, form: form, step: spaceStep, handleSizeChange: function () { }, level: level + 1 })), _jsx(StepComponent, __assign({}, others, { form: form, formStyle: formStyle, step: elementStep, handleSizeChange: function () { }, level: level + 1 })), _jsx(TextAreaStep, __assign({}, others, { form: form, backgroundColor: 'transparent', formStyle: formStyle, step: commentStep, maxLength: 200, handleSizeChange: function () { }, level: level + 1 }))] })) })));
|
|
25
48
|
}
|
|
26
49
|
export default IncidentComponent;
|
|
@@ -1,3 +1,34 @@
|
|
|
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
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
24
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
25
|
+
if (ar || !(i in from)) {
|
|
26
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
27
|
+
ar[i] = from[i];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31
|
+
};
|
|
1
32
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
33
|
/* eslint-disable no-console */
|
|
3
34
|
import { useEffect, useState } from 'react';
|
|
@@ -7,94 +38,84 @@ import IncidentComponent from './Incident/Incident';
|
|
|
7
38
|
import styles from './MaterialCBRIncidentsStep.module.css';
|
|
8
39
|
import { nanoid } from 'nanoid';
|
|
9
40
|
import RoundedButton from '../../../../../shared/RoundedButton/RoundedButton';
|
|
10
|
-
function Incidents(
|
|
41
|
+
function Incidents(_a) {
|
|
42
|
+
var step = _a.step, form = _a.form, btnRef = _a.btnRef, editable = _a.editable, postview = _a.postview, onChange = _a.onChange, incidents = _a.incidents, formStyle = _a.formStyle, dependencyStore = _a.dependencyStore, setDependencyStore = _a.setDependencyStore, others = __rest(_a, ["step", "form", "btnRef", "editable", "postview", "onChange", "incidents", "formStyle", "dependencyStore", "setDependencyStore"]);
|
|
11
43
|
/** Form to pass down with aditional steps */
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
44
|
+
var _b = useState(__assign(__assign({}, form), { steps: __assign({}, form.steps) })), localForm = _b[0], setLocalForm = _b[1];
|
|
45
|
+
var _c = useState(false), firstRender = _c[0], setFirstRender = _c[1];
|
|
46
|
+
useEffect(function () {
|
|
47
|
+
setFirstRender(true);
|
|
48
|
+
}, []);
|
|
49
|
+
useEffect(function () {
|
|
50
|
+
if (firstRender && incidents.length === 0 && !postview && editable) {
|
|
18
51
|
handleAddIncident();
|
|
19
52
|
}
|
|
20
|
-
}, []);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
53
|
+
}, [firstRender]);
|
|
54
|
+
var handleAddIncident = function () {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
var current = incidents.filter(function (incident) { return !incident.deleted; });
|
|
57
|
+
var newIncident = {
|
|
24
58
|
idSpaceStep: CBRFormStepTypes.CBR_TIPO_ESPACIO + '-' + nanoid(),
|
|
25
59
|
idCommentStep: CBRFormStepTypes.CBR_COMENTARIO + '-' + nanoid(),
|
|
26
60
|
idElementStep: CBRFormStepTypes.CBR_LOCATIVAS + '-' + nanoid(),
|
|
27
61
|
num: current.length + 1,
|
|
28
62
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
dependencies: step.dependencies,
|
|
37
|
-
};
|
|
38
|
-
newSteps[newIncident.idCommentStep] = {
|
|
39
|
-
...step.commentStep,
|
|
40
|
-
id: newIncident.idCommentStep,
|
|
41
|
-
type: CBRFormStepTypes.CBR_COMENTARIO,
|
|
42
|
-
};
|
|
43
|
-
const deps = { ...dependencyStore };
|
|
44
|
-
addRecursiveElementStep(newIncident.idElementStep, step.elementStep, null, newSteps, deps, step.dependencies?.[0] ?? '');
|
|
45
|
-
onChange([...incidents, newIncident]);
|
|
46
|
-
setLocalForm({ ...localForm, steps: newSteps });
|
|
63
|
+
var newSteps = __assign({}, localForm.steps);
|
|
64
|
+
newSteps[newIncident.idSpaceStep] = __assign(__assign({}, step.spaceStep), { id: newIncident.idSpaceStep, type: CBRFormStepTypes.CBR_TIPO_ESPACIO, dependencies: step.dependencies });
|
|
65
|
+
newSteps[newIncident.idCommentStep] = __assign(__assign({}, step.commentStep), { id: newIncident.idCommentStep, type: CBRFormStepTypes.CBR_COMENTARIO });
|
|
66
|
+
var deps = __assign({}, dependencyStore);
|
|
67
|
+
addRecursiveElementStep(newIncident.idElementStep, step.elementStep, null, newSteps, deps, (_b = (_a = step.dependencies) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '');
|
|
68
|
+
onChange(__spreadArray(__spreadArray([], incidents, true), [newIncident], false));
|
|
69
|
+
setLocalForm(__assign(__assign({}, localForm), { steps: newSteps }));
|
|
47
70
|
setDependencyStore(deps);
|
|
48
71
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
id: idStep,
|
|
55
|
-
type: CBRFormStepTypes.CBR_LOCATIVAS,
|
|
56
|
-
parentStep: idParent,
|
|
57
|
-
dependencies: [idProjectDep],
|
|
58
|
-
subStep: null,
|
|
59
|
-
};
|
|
72
|
+
var addRecursiveElementStep = function (idStep, step, idParent, steps, dependencyStore, idProjectDep) {
|
|
73
|
+
var _a, _b;
|
|
74
|
+
var idSubStep = CBRFormStepTypes.CBR_LOCATIVAS + '-' + nanoid();
|
|
75
|
+
var newSubStep = step.subStep ? __assign({}, step.subStep) : undefined;
|
|
76
|
+
var newStep = __assign(__assign({}, step), { id: idStep, type: CBRFormStepTypes.CBR_LOCATIVAS, parentStep: idParent, dependencies: [idProjectDep], subStep: null });
|
|
60
77
|
if (newSubStep) {
|
|
61
78
|
newStep.subStep = idSubStep;
|
|
62
79
|
}
|
|
63
80
|
if (idParent) {
|
|
64
81
|
dependencyStore[idParent] = null;
|
|
65
|
-
newStep.dependencies
|
|
82
|
+
(_b = (_a = newStep.dependencies) === null || _a === void 0 ? void 0 : _a.push) === null || _b === void 0 ? void 0 : _b.call(_a, idParent);
|
|
66
83
|
}
|
|
67
84
|
steps[idStep] = newStep;
|
|
68
85
|
if (newSubStep) {
|
|
69
86
|
addRecursiveElementStep(idSubStep, newSubStep, idStep, steps, dependencyStore, idProjectDep);
|
|
70
87
|
}
|
|
71
88
|
};
|
|
72
|
-
return (_jsxs("div", { className: styles.container, style: { color: formStyle.textColor }, children: [_jsx("div", { className: styles.titleLbl, children: step.label }), step.description && (_jsx("p", { className: styles.descriptionPar, style: {
|
|
89
|
+
return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [_jsx("div", __assign({ className: styles.titleLbl }, { children: step.label })), step.description && (_jsx("p", __assign({ className: styles.descriptionPar, style: {
|
|
73
90
|
margin: step.description
|
|
74
91
|
? '10px 0px'
|
|
75
92
|
: '0px 0px 5px 0px',
|
|
76
|
-
}, children: step.description })), incidents.map((incident, index)
|
|
77
|
-
|
|
93
|
+
} }, { children: step.description }))), incidents.map(function (incident, index) { return (_jsx(IncidentComponent, __assign({ incident: incident, formStyle: formStyle, step: step, form: localForm, editable: editable, postview: postview, dependencyStore: dependencyStore, setDependencyStore: setDependencyStore, handleDelete: function () {
|
|
94
|
+
var tempIncidents = __spreadArray([], incidents, true);
|
|
78
95
|
tempIncidents[index].deleted = true;
|
|
79
|
-
|
|
80
|
-
for (
|
|
96
|
+
var n = 1;
|
|
97
|
+
for (var _i = 0, tempIncidents_1 = tempIncidents; _i < tempIncidents_1.length; _i++) {
|
|
98
|
+
var inc = tempIncidents_1[_i];
|
|
81
99
|
if (!inc.deleted) {
|
|
82
100
|
inc.num = n;
|
|
83
101
|
n++;
|
|
84
102
|
}
|
|
85
103
|
}
|
|
86
104
|
onChange(tempIncidents);
|
|
87
|
-
},
|
|
105
|
+
} }, others), index)); }), _jsxs("div", __assign({ className: styles.btnContainer }, { children: [_jsx("input", { ref: btnRef, className: styles.hiddenInput }), _jsx(RoundedButton, { disabled: !editable || postview, text: step.addBtnLabel, color: formStyle.primaryContrastColor, backgroundColor: formStyle.primaryColor, fontSize: '1rem', padding: '5px 15px 5px 15px', onClick: function () {
|
|
88
106
|
if (editable && !postview) {
|
|
89
107
|
handleAddIncident();
|
|
90
108
|
}
|
|
91
|
-
} })] })] }));
|
|
109
|
+
} })] }))] })));
|
|
92
110
|
}
|
|
93
111
|
function CBRIncidentsStep(props) {
|
|
94
112
|
return (_jsx(Controller, { name: props.step.id, control: props.control, defaultValue: [], rules: {
|
|
95
113
|
required: props.step.required
|
|
96
114
|
? 'Este campo es obligatorio'
|
|
97
115
|
: undefined,
|
|
98
|
-
}, shouldUnregister: true, render: (
|
|
116
|
+
}, shouldUnregister: true, render: function (_a) {
|
|
117
|
+
var field = _a.field;
|
|
118
|
+
return (_jsx(Incidents, __assign({}, props, { incidents: field.value, onChange: field.onChange, btnRef: field.ref })));
|
|
119
|
+
} }));
|
|
99
120
|
}
|
|
100
121
|
export default CBRIncidentsStep;
|