@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.
Files changed (64) hide show
  1. package/dist/App.js +205 -98
  2. package/dist/AxiosAPI.js +3 -3
  3. package/dist/AxiosWidget.js +4 -4
  4. package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +207 -104
  5. package/dist/FormComponents/Form/ConfirmationDialog/ConfirmationDialog.js +17 -5
  6. package/dist/FormComponents/Form/Form.js +56 -29
  7. package/dist/FormComponents/Form/StepperForm/StepperForm.js +1 -1
  8. package/dist/FormComponents/Section/MaterialSection/MaterialSection.js +30 -7
  9. package/dist/FormComponents/Section/Section.js +13 -2
  10. package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/CBRIncidentsStep.js +13 -2
  11. package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.js +32 -9
  12. package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +70 -49
  13. package/dist/FormComponents/Step/@Construction/CBRLocativasStep/CBRLocativasStep.js +102 -41
  14. package/dist/FormComponents/Step/@Construction/CBRPropertyStep/CBRPropertyStep.js +92 -37
  15. package/dist/FormComponents/Step/AYFStepMapper.js +75 -23
  16. package/dist/FormComponents/Step/CBRStepMapper.js +144 -56
  17. package/dist/FormComponents/Step/CheckBoxStep/CheckBoxStep.js +26 -3
  18. package/dist/FormComponents/Step/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +21 -6
  19. package/dist/FormComponents/Step/ClassifierSelectorStep/ClassifierSelectorStep.js +26 -3
  20. package/dist/FormComponents/Step/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +65 -32
  21. package/dist/FormComponents/Step/DatePickerStep/DatePickerStep.js +13 -2
  22. package/dist/FormComponents/Step/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +21 -6
  23. package/dist/FormComponents/Step/FileUploadStep/FileUploadStep.js +13 -2
  24. package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.js +88 -27
  25. package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +171 -81
  26. package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/MaterialRatingStep.js +41 -15
  27. package/dist/FormComponents/Step/RatingStep/RatingStep.js +13 -2
  28. package/dist/FormComponents/Step/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +52 -25
  29. package/dist/FormComponents/Step/SelectorStep/SelectorStep.js +26 -3
  30. package/dist/FormComponents/Step/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.js +2 -1
  31. package/dist/FormComponents/Step/SeparatorStep/SeparatorStep.js +26 -3
  32. package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +145 -83
  33. package/dist/FormComponents/Step/SmartSelectStep/SmartSelectStep.js +13 -2
  34. package/dist/FormComponents/Step/Step.js +39 -19
  35. package/dist/FormComponents/Step/StepFunctions.js +16 -14
  36. package/dist/FormComponents/Step/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +62 -43
  37. package/dist/FormComponents/Step/TextAreaStep/TextAreaStep.js +13 -2
  38. package/dist/FormComponents/Step/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +21 -6
  39. package/dist/FormComponents/Step/TextInputStep/TextInputStep.js +13 -2
  40. package/dist/FormComponents/Step/TitleStep/MaterialTitleStep/MaterialTitleStep.js +15 -3
  41. package/dist/FormComponents/Step/TitleStep/TitleStep.js +26 -3
  42. package/dist/FormComponents/Term/MaterialTerm/MaterialTerm.js +35 -19
  43. package/dist/FormComponents/Term/Term.js +13 -2
  44. package/dist/Widget.js +29 -13
  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 +86 -29
  50. package/dist/index.js +15 -4
  51. package/dist/shared/Loader/Loader.js +17 -5
  52. package/dist/shared/Navbar/Navbar.js +14 -2
  53. package/dist/shared/Rating/Rating.js +27 -4
  54. package/dist/shared/Rating/Ratings/LikeRating.js +21 -9
  55. package/dist/shared/Rating/Ratings/SatisfactionRating.js +27 -15
  56. package/dist/shared/Rating/Ratings/ScaleRating.js +49 -22
  57. package/dist/shared/RoundedButton/RoundedButton.js +24 -12
  58. package/dist/shared/RoundedCheckBox/RoundedCheckBox.js +84 -39
  59. package/dist/shared/RoundedDatePicker/RoundedDatePicker.js +286 -235
  60. package/dist/shared/RoundedSelect/RoundedSelect.js +152 -103
  61. package/dist/shared/RoundedSmartSelect/RoundedSmartSelect.js +160 -125
  62. package/dist/shared/RoundedTextField/RoundedTextField.js +137 -92
  63. package/dist/utils/CbrFunctions.js +30 -30
  64. 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 { createElement as _createElement } from "react";
2
24
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
25
  import React, { useState } from 'react';
@@ -7,58 +29,60 @@ import StepComponent from '../../Step';
7
29
  import { calcFillerSize, calcStepWidth } from '../../StepFunctions';
8
30
  import { Controller } from 'react-hook-form';
9
31
  import RoundedSmartSelect from '../../../../shared/RoundedSmartSelect/RoundedSmartSelect';
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
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
12
35
  ? calcFillerSize(step, form.steps, getValues(), form.size)
13
- : 0);
14
- const sizeChange = () => {
36
+ : 0), fillerSize = _b[0], setFillerSize = _b[1];
37
+ var sizeChange = function () {
15
38
  handleSizeChange();
16
39
  if (level === 0) {
17
40
  setFillerSize(calcFillerSize(step, form.steps, getValues(), form.size));
18
41
  }
19
42
  };
20
- const renderSelect = () => {
21
- return (_jsx("div", { className: styles.container, style: {
43
+ var renderSelect = function () {
44
+ var _a;
45
+ return (_jsx("div", __assign({ className: styles.container, style: {
22
46
  width: widthStats.currentBreakPoint <= step.size
23
47
  ? '100%'
24
48
  : calcStepWidth(step.size, form.size),
25
49
  minHeight: step.description || step.required ? '55px' : '43px',
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) => {
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) {
27
51
  onChange(value);
28
- }, getOptionSelected: (option, value) => {
29
- return option?.value === value?.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);
30
54
  }, helperText: errors[step.id]
31
55
  ? errors[step.id].message
32
- : step.description, error: !!errors[step.id] }) }));
56
+ : step.description, error: !!errors[step.id] }) })));
33
57
  };
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) {
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)) {
40
64
  currentOptionIndex = i;
41
65
  currentOption = option;
42
66
  }
43
67
  }
44
- if (currentOption?.type === OptionTypes.NESTED &&
68
+ if ((currentOption === null || currentOption === void 0 ? void 0 : currentOption.type) === OptionTypes.NESTED &&
45
69
  currentOptionIndex !== null) {
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: () => {
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 () {
49
73
  sizeChange();
50
- } }));
74
+ } })));
51
75
  }) }));
52
76
  }
53
77
  };
54
78
  if (level === 0 && step.maxSize < form.size.blockNum) {
55
- return (_jsxs("div", { className: styles.firstLvlContainer, style: {
79
+ return (_jsxs("div", __assign({ className: styles.firstLvlContainer, style: {
56
80
  width: widthStats.currentBreakPoint <= step.size
57
81
  ? '100%'
58
82
  : 'fit-content',
59
- }, children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize < form.size.blockNum && (_jsx("div", { className: styles.smallSeparator, style: {
83
+ } }, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize < form.size.blockNum && (_jsx("div", { className: styles.smallSeparator, style: {
60
84
  width: fillerSize,
61
- } }))] }));
85
+ } }))] })));
62
86
  }
63
87
  else {
64
88
  return (_jsxs(React.Fragment, { children: [renderSelect(), mapNestedOption(), level === 0 && _jsx("div", { className: styles.separator })] }));
@@ -69,6 +93,9 @@ function SelectorStep(props) {
69
93
  required: props.step.required
70
94
  ? 'Este campo es obligatorio'
71
95
  : undefined,
72
- }, shouldUnregister: true, render: ({ field }) => (_jsx(Selector, { ...props, inputRef: field.ref, value: field.value, onChange: field.onChange, onBlur: field.onBlur })) }));
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
+ } }));
73
100
  }
74
101
  export default SelectorStep;
@@ -1,13 +1,36 @@
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 } from "react/jsx-runtime";
2
24
  import { FormStyleTypes } from '../../../constants/FormStepTypes';
3
25
  import MaterialSelectorStep from './MaterialSelectorStep/MaterialSelectorStep';
4
- function SelectorStep({ formStyle, ...others }) {
26
+ function SelectorStep(_a) {
27
+ var formStyle = _a.formStyle, others = __rest(_a, ["formStyle"]);
5
28
  switch (formStyle.type) {
6
29
  case FormStyleTypes.MATERIAL: {
7
- return _jsx(MaterialSelectorStep, { formStyle: formStyle, ...others });
30
+ return _jsx(MaterialSelectorStep, __assign({ formStyle: formStyle }, others));
8
31
  }
9
32
  default: {
10
- return _jsx(MaterialSelectorStep, { formStyle: formStyle, ...others });
33
+ return _jsx(MaterialSelectorStep, __assign({ formStyle: formStyle }, others));
11
34
  }
12
35
  }
13
36
  }
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import styles from './MaterialSeparatorStep.module.css';
3
- function SeparatorStep({ step, formStyle }) {
3
+ function SeparatorStep(_a) {
4
+ var step = _a.step, formStyle = _a.formStyle;
4
5
  return (_jsx("div", { className: styles.container, style: {
5
6
  backgroundColor: step.transparent
6
7
  ? 'transparent'
@@ -1,13 +1,36 @@
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 } from "react/jsx-runtime";
2
24
  import { FormStyleTypes } from '../../../constants/FormStepTypes';
3
25
  import MaterialSeparatorStep from './MaterialSeparatorStep/MaterialSeparatorStep';
4
- function SeparatorStep({ step, formStyle, ...others }) {
26
+ function SeparatorStep(_a) {
27
+ var step = _a.step, formStyle = _a.formStyle, others = __rest(_a, ["step", "formStyle"]);
5
28
  switch (formStyle.type) {
6
29
  case FormStyleTypes.MATERIAL: {
7
- return (_jsx(MaterialSeparatorStep, { step: step, formStyle: formStyle, ...others }));
30
+ return (_jsx(MaterialSeparatorStep, __assign({ step: step, formStyle: formStyle }, others)));
8
31
  }
9
32
  default: {
10
- return (_jsx(MaterialSeparatorStep, { step: step, formStyle: formStyle, ...others }));
33
+ return (_jsx(MaterialSeparatorStep, __assign({ step: step, formStyle: formStyle }, others)));
11
34
  }
12
35
  }
13
36
  }
@@ -1,3 +1,61 @@
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
+ };
1
59
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
60
  import styles from './MaterialSmartSelectStep.module.css';
3
61
  import { Controller } from 'react-hook-form';
@@ -5,44 +63,60 @@ import { calcStepWidth } from '../../StepFunctions';
5
63
  import RoundedSmartSelect from '../../../../shared/RoundedSmartSelect/RoundedSmartSelect';
6
64
  import { cloneElement, useEffect, useState } from 'react';
7
65
  import React from 'react';
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);
13
- }
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
- }
29
- }
30
- else {
31
- const invalids = calcInvalidDeps?.(step, dependencyStore) ?? [];
32
- if (invalids.length === 0) {
33
- setError(undefined);
34
- }
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);
35
76
  }
36
77
  }
37
- setOptions(resp);
38
- setLoading(false);
39
- };
40
- useEffect(() => {
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*/];
111
+ }
112
+ });
113
+ }); };
114
+ useEffect(function () {
41
115
  if (!postview) {
42
116
  if (first) {
43
117
  setFirst(false);
44
- const invalids = calcInvalidDeps(step, dependencyStore).filter((idDep) => originalValues[idDep]);
45
- setError(calcDepError?.(invalids.map((idDep) => form.steps[idDep]?.type)));
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; })));
46
120
  calcOptions(value, invalids);
47
121
  }
48
122
  else {
@@ -57,91 +131,79 @@ function SmartSelect({ icon, step, form, value, onBlur, errors, trigger, childre
57
131
  else if (value && !step.searchable) {
58
132
  setOptions([value]);
59
133
  }
60
- }, step.dependencies?.map((dep) => dependencyStore[dep]) ?? []);
134
+ }, (_c = (_b = step.dependencies) === null || _b === void 0 ? void 0 : _b.map(function (dep) { return dependencyStore[dep]; })) !== null && _c !== void 0 ? _c : []);
61
135
  /**
62
136
  * If the original value has no label search for it in the list.
63
137
  */
64
- useEffect(() => {
65
- const original = originalValues[step.id];
138
+ useEffect(function () {
139
+ var original = originalValues[step.id];
66
140
  if (original &&
67
141
  options &&
68
142
  getValueString(original) !== undefined &&
69
143
  !original.label) {
70
- const newValue = options.find((option) => getValueString(option) === getValueString(original));
144
+ var newValue = options.find(function (option) { return getValueString(option) === getValueString(original); });
71
145
  onChange(newValue);
72
146
  }
73
147
  }, [originalValues[step.id], options]);
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);
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
+ }
84
161
  }
85
162
  }
86
- }
87
- };
88
- const warning = getValueWarning?.(value);
89
- return (_jsxs(React.Fragment, { children: [_jsx("div", { className: styles.container, style: {
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: {
90
168
  width: widthStats.currentBreakPoint <= step.size
91
169
  ? '100%'
92
170
  : calcStepWidth(step.size, form.size),
93
171
  minHeight: step.description || step.required ? '55px' : '43px',
94
- }, onClick: () => {
172
+ }, onClick: function () {
95
173
  if (options === null && !(!editable || postview)) {
96
174
  handleMissingDep();
97
175
  }
98
176
  if (options === undefined && !(!editable || postview)) {
99
177
  setLoading(true);
100
178
  }
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) => {
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;
102
181
  if (dependencyStore[step.id] !== undefined) {
103
- setDependencyStore({
104
- ...dependencyStore,
105
- [step.id]: value,
106
- });
182
+ setDependencyStore(__assign(__assign({}, dependencyStore), (_a = {}, _a[step.id] = value, _a)));
107
183
  }
108
184
  valueOverwrite
109
185
  ? onChange(valueOverwrite(value))
110
186
  : onChange(value);
111
187
  setError(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 ||
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 ||
117
191
  (warning !== undefined && warning !== null) ||
118
- !!errors[step.id] }) }), children &&
192
+ !!errors[step.id] }) })), children &&
119
193
  cloneElement(children, {
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
- },
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),
136
196
  })] }));
137
197
  }
138
198
  function SmartSelectStep(props) {
139
- return (_jsx(Controller, { name: props.step.id, control: props.control, defaultValue: props.originalValues[props.step.id] ??
140
- props.defaultValue ??
141
- null, rules: {
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: {
142
201
  required: props.step.required
143
202
  ? 'Este campo es obligatorio'
144
203
  : undefined,
145
- }, shouldUnregister: true, render: ({ field }) => (_jsx(SmartSelect, { ...props, inputRef: field.ref, value: field.value, onChange: field.onChange, onBlur: field.onBlur })) }));
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
+ } }));
146
208
  }
147
209
  export default SmartSelectStep;
@@ -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 MaterialSmartSelectStep from './MaterialSmartSelectStep/MaterialSmartSelectStep';
4
15
  function SmartSelectStep(props) {
5
16
  switch (props.formStyle.type) {
6
17
  case FormStyleTypes.MATERIAL: {
7
- return _jsx(MaterialSmartSelectStep, { ...props });
18
+ return _jsx(MaterialSmartSelectStep, __assign({}, props));
8
19
  }
9
20
  default: {
10
- return _jsx(MaterialSmartSelectStep, { ...props });
21
+ return _jsx(MaterialSmartSelectStep, __assign({}, props));
11
22
  }
12
23
  }
13
24
  }
@@ -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 } from "react/jsx-runtime";
2
24
  import Types from '../../constants/FormStepTypes';
3
25
  import SelectorStep from './SelectorStep/SelectorStep';
@@ -12,54 +34,52 @@ import CheckBoxStep from './CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxSt
12
34
  import CBRStepMapper from './CBRStepMapper';
13
35
  import RatingStep from './RatingStep/RatingStep';
14
36
  import AYFStepMapper from './AYFStepMapper';
15
- function StepComponent({ step, ...props }) {
16
- const customStep = props.customSteps[step.type];
37
+ function StepComponent(_a) {
38
+ var _b;
39
+ var step = _a.step, props = __rest(_a, ["step"]);
40
+ var customStep = props.customSteps[step.type];
17
41
  if (customStep) {
18
- return customStep.component({
19
- step,
20
- ...props,
21
- ...(customStep.componentProps ?? {}),
22
- });
42
+ return customStep.component(__assign(__assign({ step: step }, props), ((_b = customStep.componentProps) !== null && _b !== void 0 ? _b : {})));
23
43
  }
24
44
  switch (step.type) {
25
45
  case Types.TITLE: {
26
- return _jsx(TitleStep, { step: step, ...props });
46
+ return _jsx(TitleStep, __assign({ step: step }, props));
27
47
  }
28
48
  case Types.SELECTOR: {
29
- return _jsx(SelectorStep, { step: step, ...props });
49
+ return _jsx(SelectorStep, __assign({ step: step }, props));
30
50
  }
31
51
  case Types.CHECKBOX: {
32
- return _jsx(CheckBoxStep, { step: step, ...props });
52
+ return _jsx(CheckBoxStep, __assign({ step: step }, props));
33
53
  }
34
54
  case Types.CLASSIFIER_SELECTOR: {
35
- return (_jsx(ClassifierSelectorStep, { step: step, ...props }));
55
+ return (_jsx(ClassifierSelectorStep, __assign({ step: step }, props)));
36
56
  }
37
57
  case Types.TEXTAREA: {
38
- return _jsx(TextAreaStep, { step: step, ...props });
58
+ return _jsx(TextAreaStep, __assign({ step: step }, props));
39
59
  }
40
60
  case Types.TEXTINPUT: {
41
- return _jsx(TextInputStep, { step: step, ...props });
61
+ return _jsx(TextInputStep, __assign({ step: step }, props));
42
62
  }
43
63
  case Types.DATEPICKER: {
44
- return _jsx(DatePickerStep, { step: step, ...props });
64
+ return _jsx(DatePickerStep, __assign({ step: step }, props));
45
65
  }
46
66
  case Types.SEPARATOR: {
47
- return _jsx(SeparatorStep, { step: step, ...props });
67
+ return _jsx(SeparatorStep, __assign({ step: step }, props));
48
68
  }
49
69
  case Types.FILEUPLOAD: {
50
- return _jsx(FileUploadStep, { step: step, ...props });
70
+ return _jsx(FileUploadStep, __assign({ step: step }, props));
51
71
  }
52
72
  case Types.RATING: {
53
- return _jsx(RatingStep, { step: step, ...props });
73
+ return _jsx(RatingStep, __assign({ step: step }, props));
54
74
  }
55
75
  default:
56
76
  break;
57
77
  }
58
78
  if (step.type.startsWith('CBR')) {
59
- return _jsx(CBRStepMapper, { ...props, step: step });
79
+ return _jsx(CBRStepMapper, __assign({}, props, { step: step }));
60
80
  }
61
81
  else if (step.type.startsWith('AYF')) {
62
- return _jsx(AYFStepMapper, { ...props, step: step });
82
+ return _jsx(AYFStepMapper, __assign({}, props, { step: step }));
63
83
  }
64
84
  return _jsx("div", {});
65
85
  }