@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 { 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(_a) {
33
- var step = _a.step, form = _a.form, value = _a.value, level = _a.level, onBlur = _a.onBlur, control = _a.control, editable = _a.editable, onChange = _a.onChange, postview = _a.postview, formStyle = _a.formStyle, getValues = _a.getValues, widthStats = _a.widthStats, handleSizeChange = _a.handleSizeChange, errors = _a.errors, inputRef = _a.inputRef, others = __rest(_a, ["step", "form", "value", "level", "onBlur", "control", "editable", "onChange", "postview", "formStyle", "getValues", "widthStats", "handleSizeChange", "errors", "inputRef"]);
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), fillerSize = _b[0], setFillerSize = _b[1];
37
- var sizeChange = function () {
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
- var renderSelect = function () {
44
- var _a;
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
- } }, { children: _jsx(RoundedSmartSelect, { value: value, onBlur: onBlur, disabled: false, loading: false, options: step.options, inputRef: inputRef, cantEdit: !editable || postview, fullWidth: true, backgroundColor: "transparent", innerBackgroundColor: (_a = formStyle.stepBackgroundColor) !== null && _a !== void 0 ? _a : '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: function (value) {
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: function (option, value) {
53
- return (option === null || option === void 0 ? void 0 : option.value) === (value === null || value === void 0 ? void 0 : value.value);
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
- var mapNestedOption = function () {
59
- var currentOptionIndex = null;
60
- var currentOption = null;
61
- for (var i = 0; i < step.options.length; i++) {
62
- var option = step.options[i];
63
- if ((option === null || option === void 0 ? void 0 : option.value) === (value === null || value === void 0 ? void 0 : value.value)) {
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 ((currentOption === null || currentOption === void 0 ? void 0 : currentOption.type) === OptionTypes.NESTED &&
44
+ if (currentOption?.type === OptionTypes.NESTED &&
69
45
  currentOptionIndex !== null) {
70
- return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idSubStep, index) {
71
- var subStep = form.steps[idSubStep];
72
- return (_createElement(StepComponent, __assign({}, 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: function () {
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", __assign({ className: styles.firstLvlContainer, style: {
55
+ return (_jsxs("div", { className: styles.firstLvlContainer, style: {
80
56
  width: widthStats.currentBreakPoint <= step.size
81
57
  ? '100%'
82
58
  : 'fit-content',
83
- } }, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize < form.size.blockNum && (_jsx("div", { className: styles.smallSeparator, style: {
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: function (_a) {
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(_a) {
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, __assign({ formStyle: formStyle }, others));
7
+ return _jsx(MaterialSelectorStep, { formStyle: formStyle, ...others });
31
8
  }
32
9
  default: {
33
- return _jsx(MaterialSelectorStep, __assign({ formStyle: formStyle }, others));
10
+ return _jsx(MaterialSelectorStep, { formStyle: formStyle, ...others });
34
11
  }
35
12
  }
36
13
  }
@@ -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(_a) {
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(_a) {
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, __assign({ step: step, formStyle: formStyle }, others)));
7
+ return (_jsx(MaterialSeparatorStep, { step: step, formStyle: formStyle, ...others }));
31
8
  }
32
9
  default: {
33
- return (_jsx(MaterialSeparatorStep, __assign({ step: step, formStyle: formStyle }, others)));
10
+ return (_jsx(MaterialSeparatorStep, { step: step, formStyle: formStyle, ...others }));
34
11
  }
35
12
  }
36
13
  }
@@ -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(_a) {
67
- var _this = this;
68
- var _b, _c, _d, _e;
69
- var icon = _a.icon, step = _a.step, form = _a.form, value = _a.value, onBlur = _a.onBlur, errors = _a.errors, trigger = _a.trigger, children = _a.children, editable = _a.editable, onChange = _a.onChange, inputRef = _a.inputRef, postview = _a.postview, formStyle = _a.formStyle, getOptions = _a.getOptions, widthStats = _a.widthStats, organization = _a.organization, calcDepError = _a.calcDepError, valueOverwrite = _a.valueOverwrite, getValueString = _a.getValueString, originalValues = _a.originalValues, changeListener = _a.changeListener, dependencyStore = _a.dependencyStore, _f = _a.calcInvalidDeps, calcInvalidDeps = _f === void 0 ? function (step, depStore) {
70
- var _a;
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
- return missingDeps;
79
- } : _f, getValueWarning = _a.getValueWarning, getOptionSelected = _a.getOptionSelected, setDependencyStore = _a.setDependencyStore, others = __rest(_a, ["icon", "step", "form", "value", "onBlur", "errors", "trigger", "children", "editable", "onChange", "inputRef", "postview", "formStyle", "getOptions", "widthStats", "organization", "calcDepError", "valueOverwrite", "getValueString", "originalValues", "changeListener", "dependencyStore", "calcInvalidDeps", "getValueWarning", "getOptionSelected", "setDependencyStore"]);
80
- var _g = useState(true), first = _g[0], setFirst = _g[1];
81
- var _h = useState(), options = _h[0], setOptions = _h[1];
82
- var _j = useState(), error = _j[0], setError = _j[1];
83
- var _k = useState(false), loading = _k[0], setLoading = _k[1];
84
- var calcOptions = function (currentValue, invalidDeps) { return __awaiter(_this, void 0, void 0, function () {
85
- var resp, currentOption, invalids;
86
- var _a;
87
- return __generator(this, function (_b) {
88
- switch (_b.label) {
89
- case 0: return [4 /*yield*/, (getOptions === null || getOptions === void 0 ? void 0 : getOptions(organization.idOrganization, step, dependencyStore))];
90
- case 1:
91
- resp = _b.sent();
92
- if (resp !== null) {
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
- useEffect(function () {
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
- var invalids = calcInvalidDeps(step, dependencyStore).filter(function (idDep) { return originalValues[idDep]; });
119
- setError(calcDepError === null || calcDepError === void 0 ? void 0 : calcDepError(invalids.map(function (idDep) { var _a; return (_a = form.steps[idDep]) === null || _a === void 0 ? void 0 : _a.type; })));
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
- }, (_c = (_b = step.dependencies) === null || _b === void 0 ? void 0 : _b.map(function (dep) { return dependencyStore[dep]; })) !== null && _c !== void 0 ? _c : []);
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(function () {
139
- var original = originalValues[step.id];
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
- var newValue = options.find(function (option) { return getValueString(option) === getValueString(original); });
70
+ const newValue = options.find((option) => getValueString(option) === getValueString(original));
145
71
  onChange(newValue);
146
72
  }
147
73
  }, [originalValues[step.id], options]);
148
- var handleMissingDep = function () { return __awaiter(_this, void 0, void 0, function () {
149
- var invalids;
150
- return __generator(this, function (_a) {
151
- if (step.dependencies) {
152
- invalids = calcInvalidDeps(step, dependencyStore);
153
- setError(calcDepError === null || calcDepError === void 0 ? void 0 : calcDepError(invalids.map(function (idDep) { var _a; return (_a = form.steps[idDep]) === null || _a === void 0 ? void 0 : _a.type; })));
154
- if (!value) {
155
- if (invalids.length > 0) {
156
- trigger(invalids, { shouldFocus: true });
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
- return [2 /*return*/];
164
- });
165
- }); };
166
- var warning = getValueWarning === null || getValueWarning === void 0 ? void 0 : getValueWarning(value);
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: function () {
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 }, { children: _jsx(RoundedSmartSelect, { value: value, onBlur: onBlur, disabled: options === null, loading: loading, options: options !== null && options !== void 0 ? options : [], inputRef: inputRef, cantEdit: !editable || postview, fullWidth: true, backgroundColor: "transparent", innerBackgroundColor: (_d = formStyle.stepBackgroundColor) !== null && _d !== void 0 ? _d : '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: function (value) {
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(__assign(__assign({}, dependencyStore), (_a = {}, _a[step.id] = value, _a)));
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: (_e = error !== null && error !== void 0 ? error : warning) !== null && _e !== void 0 ? _e : (errors[step.id]
189
- ? errors[step.id].message
190
- : step.description), error: error !== undefined ||
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] }) })), children &&
118
+ !!errors[step.id] }) }), children &&
193
119
  cloneElement(children, {
194
- value: value,
195
- stepProps: __assign({ step: step, form: form, errors: errors, trigger: trigger, postview: postview, editable: editable, formStyle: formStyle, widthStats: widthStats, organization: organization, originalValues: originalValues, dependencyStore: dependencyStore, setDependencyStore: setDependencyStore }, others),
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
- var _a, _b;
200
- return (_jsx(Controller, { name: props.step.id, control: props.control, defaultValue: (_b = (_a = props.originalValues[props.step.id]) !== null && _a !== void 0 ? _a : props.defaultValue) !== null && _b !== void 0 ? _b : null, rules: {
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: function (_a) {
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, __assign({}, props));
7
+ return _jsx(MaterialSmartSelectStep, { ...props });
19
8
  }
20
9
  default: {
21
- return _jsx(MaterialSmartSelectStep, __assign({}, props));
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(_a) {
38
- var _b;
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(__assign(__assign({ step: step }, props), ((_b = customStep.componentProps) !== null && _b !== void 0 ? _b : {})));
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, __assign({ step: step }, props));
26
+ return _jsx(TitleStep, { step: step, ...props });
47
27
  }
48
28
  case Types.SELECTOR: {
49
- return _jsx(SelectorStep, __assign({ step: step }, props));
29
+ return _jsx(SelectorStep, { step: step, ...props });
50
30
  }
51
31
  case Types.CHECKBOX: {
52
- return _jsx(CheckBoxStep, __assign({ step: step }, props));
32
+ return _jsx(CheckBoxStep, { step: step, ...props });
53
33
  }
54
34
  case Types.CLASSIFIER_SELECTOR: {
55
- return (_jsx(ClassifierSelectorStep, __assign({ step: step }, props)));
35
+ return (_jsx(ClassifierSelectorStep, { step: step, ...props }));
56
36
  }
57
37
  case Types.TEXTAREA: {
58
- return _jsx(TextAreaStep, __assign({ step: step }, props));
38
+ return _jsx(TextAreaStep, { step: step, ...props });
59
39
  }
60
40
  case Types.TEXTINPUT: {
61
- return _jsx(TextInputStep, __assign({ step: step }, props));
41
+ return _jsx(TextInputStep, { step: step, ...props });
62
42
  }
63
43
  case Types.DATEPICKER: {
64
- return _jsx(DatePickerStep, __assign({ step: step }, props));
44
+ return _jsx(DatePickerStep, { step: step, ...props });
65
45
  }
66
46
  case Types.SEPARATOR: {
67
- return _jsx(SeparatorStep, __assign({ step: step }, props));
47
+ return _jsx(SeparatorStep, { step: step, ...props });
68
48
  }
69
49
  case Types.FILEUPLOAD: {
70
- return _jsx(FileUploadStep, __assign({ step: step }, props));
50
+ return _jsx(FileUploadStep, { step: step, ...props });
71
51
  }
72
52
  case Types.RATING: {
73
- return _jsx(RatingStep, __assign({ step: step }, props));
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, __assign({}, props, { step: step }));
59
+ return _jsx(CBRStepMapper, { ...props, step: step });
80
60
  }
81
61
  else if (step.type.startsWith('AYF')) {
82
- return _jsx(AYFStepMapper, __assign({}, props, { step: step }));
62
+ return _jsx(AYFStepMapper, { ...props, step: step });
83
63
  }
84
64
  return _jsx("div", {});
85
65
  }