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