@arquimedes.co/eureka-forms 2.0.19 → 2.0.20-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 (57) hide show
  1. package/dist/@Types/FormStep.d.ts +1 -0
  2. package/dist/App/App.js +2 -2
  3. package/dist/App/AppFunctions.js +1 -1
  4. package/dist/Form/Section/MaterialSection/MaterialSection.js +1 -1
  5. package/dist/Form/Terms/Term/MaterialTerm/MaterialTerm.js +1 -1
  6. package/dist/FormSteps/@Construction/CBRElementStep/CBRElementStep.js +2 -2
  7. package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.d.ts +1 -1
  8. package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.js +2 -2
  9. package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.d.ts +2 -2
  10. package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +20 -63
  11. package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.module.css +0 -16
  12. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.d.ts +1 -1
  13. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +21 -76
  14. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +0 -28
  15. package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.d.ts +1 -1
  16. package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +39 -96
  17. package/dist/FormSteps/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.js +2 -2
  18. package/dist/FormSteps/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +7 -38
  19. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.d.ts +1 -1
  20. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +20 -74
  21. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.d.ts +2 -2
  22. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +18 -42
  23. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElementComponent.js +2 -2
  24. package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.js +9 -5
  25. package/dist/FormSteps/RatingStep/MaterialRatingStep/MaterialRatingStep.d.ts +1 -1
  26. package/dist/FormSteps/RatingStep/MaterialRatingStep/MaterialRatingStep.js +15 -43
  27. package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.d.ts +2 -2
  28. package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +22 -78
  29. package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.module.css +0 -16
  30. package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.d.ts +1 -9
  31. package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +26 -57
  32. package/dist/FormSteps/Step.d.ts +0 -2
  33. package/dist/FormSteps/StepFunctions.d.ts +2 -1
  34. package/dist/FormSteps/StepFunctions.js +70 -63
  35. package/dist/FormSteps/StepHooks.d.ts +16 -0
  36. package/dist/FormSteps/StepHooks.js +58 -2
  37. package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaEditorStep.js +1 -1
  38. package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +6 -37
  39. package/dist/FormSteps/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +13 -39
  40. package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.d.ts +1 -1
  41. package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +4 -24
  42. package/dist/FormSteps/Utils/@StepFiller/StepFiller.d.ts +9 -0
  43. package/dist/FormSteps/Utils/@StepFiller/StepFiller.js +48 -0
  44. package/dist/FormSteps/{EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.module.css → Utils/@StepFiller/StepFiller.module.css} +16 -16
  45. package/dist/FormSteps/Utils/MaterialInputContainer/MaterialInputContainer.d.ts +11 -0
  46. package/dist/FormSteps/Utils/MaterialInputContainer/MaterialInputContainer.js +32 -0
  47. package/dist/FormSteps/{DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.module.css → Utils/MaterialInputContainer/MaterialInputContainer.module.css} +9 -9
  48. package/dist/Shared/RoundedCheckBox/RoundedCheckBox.d.ts +3 -3
  49. package/dist/Shared/RoundedSmartSelect/RoundedSmartSelect.d.ts +1 -4
  50. package/dist/Shared/RoundedSmartSelect/RoundedSmartSelect.js +1 -3
  51. package/dist/States/SiteSlice.d.ts +2 -1
  52. package/dist/States/SiteSlice.js +25 -6
  53. package/dist/hooks.d.ts +2 -0
  54. package/dist/hooks.js +5 -1
  55. package/package.json +1 -1
  56. package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.module.css +0 -25
  57. package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.module.css +0 -9
@@ -9,52 +9,21 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
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
12
  import { jsx as _jsx } from "react/jsx-runtime";
24
- import styles from './MaterialDatePickerStep.module.css';
25
- import { useController } from 'react-hook-form';
26
13
  import RoundedDatePicker from '../../../Shared/RoundedDatePicker/RoundedDatePicker';
27
- import { calcStepWidth } from '../../StepFunctions';
28
- import { selectBreakPoint, useAppSelector } from '../../../hooks';
29
- import FormContext from '../../../Contexts/FormContext';
30
- import { useCallback, useContext } from 'react';
31
- import { useStepDependency } from '../../StepHooks';
14
+ import { useAppSelector } from '../../../hooks';
15
+ import { useFormStep } from '../../StepHooks';
16
+ import MaterialInputContainer from '../../Utils/MaterialInputContainer/MaterialInputContainer';
32
17
  function DatePickerStep(_a) {
33
18
  var _b;
34
19
  var step = _a.step, editable = _a.editable, defaultValue = _a.defaultValue;
35
- var currentBreakPoint = useAppSelector(selectBreakPoint);
36
20
  var _c = useAppSelector(function (state) { return state.global; }), formStyle = _c.formStyle, postview = _c.postview;
37
- var form = useContext(FormContext);
38
- var _d = useStepDependency(step, defaultValue), handleStepDep = _d.handleStepDep, originalValue = _d.originalValue;
39
- var _e = useController({
40
- name: step.id,
21
+ var _d = useFormStep(step, {
22
+ defaultValue: defaultValue,
41
23
  rules: {
42
24
  required: step.required ? 'Este campo es obligatorio' : undefined,
43
25
  },
44
- shouldUnregister: true,
45
- defaultValue: originalValue,
46
- }), _f = _e.field, ref = _f.ref, field = __rest(_f, ["ref"]), error = _e.fieldState.error;
47
- var onChange = useCallback(function (value) {
48
- handleStepDep(value);
49
- field.onChange(value);
50
- }, [handleStepDep, field]);
51
- return (_jsx("div", __assign({ className: styles.container, style: {
52
- width: currentBreakPoint <= step.size
53
- ? '100%'
54
- : calcStepWidth(step.size, form.size),
55
- minHeight: step.description || (!postview && editable && step.required)
56
- ? '55px'
57
- : '43px',
58
- } }, { children: _jsx(RoundedDatePicker, __assign({}, field, { onChange: onChange, pickTime: step.pickTime, clearable: !step.required, clearLabel: "Borrar", inputRef: ref, cantEdit: !editable || postview, "data-testid": step.id, secondaryColor: formStyle.secondaryColor, contrastColor: formStyle.secondaryContrastColor, accentColor: formStyle.textColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, textColor: formStyle.textColor, errorColor: formStyle.errorColor, helperTextColor: formStyle.descriptionTextColor, fontWeight: 400, label: step.label, helperText: (_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : step.description, error: !!error, required: step.required })) })));
26
+ }), ref = _d.ref, value = _d.value, onChange = _d.onChange, error = _d.error, field = _d.field;
27
+ return (_jsx(MaterialInputContainer, __assign({ step: step, editable: editable }, { children: _jsx(RoundedDatePicker, __assign({}, field, { value: value, onChange: onChange, pickTime: step.pickTime, clearable: !step.required, clearLabel: "Borrar", inputRef: ref, cantEdit: !editable || postview, secondaryColor: formStyle.secondaryColor, contrastColor: formStyle.secondaryContrastColor, accentColor: formStyle.textColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, textColor: formStyle.textColor, errorColor: formStyle.errorColor, helperTextColor: formStyle.descriptionTextColor, fontWeight: 400, label: step.label, helperText: (_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : step.description, error: !!error, required: step.required })) })));
59
28
  }
60
29
  export default DatePickerStep;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { EntityValuePickerStepProps } from '../EntityValuePickerStep';
3
+ declare function EntityValuePickerStep({ step, editable, }: EntityValuePickerStepProps): JSX.Element;
3
4
  export default EntityValuePickerStep;
4
- declare function EntityValuePickerStep(props: EntityValuePickerStepProps): JSX.Element;
@@ -45,46 +45,19 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
46
  }
47
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
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
60
- import React, { useCallback, useContext, useState } from 'react';
48
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
49
+ import React, { useContext } from 'react';
61
50
  import FormStepTypes, { EntityValueDataTypes, EntityValueOptionTypes, } from '../../../constants/FormStepTypes';
62
- import styles from './MaterialEntityValuePickerStep.module.css';
63
51
  import StepComponent from '../../Step';
64
- import { useController, useFormContext } from 'react-hook-form';
65
- import { calcFillerSize } from '../../StepFunctions';
66
- import { SmartSelect } from '../../SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep';
52
+ import SmartSelect from '../../SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep';
67
53
  import widgetInstance from '../../../Utils/AxiosWidget';
68
54
  import InputIcon from '../../../Shared/InputIcon/InputIcon';
69
55
  import FormContext from '../../../Contexts/FormContext';
70
- import { selectBreakPoint, useAppSelector } from '../../../hooks';
71
- import { useStepDependency } from '../../StepHooks';
72
- function EntityValuePickerComponent(_a) {
73
- var step = _a.step, error = _a.error, level = _a.level, value = _a.value, editable = _a.editable, inputRef = _a.inputRef, onBlur = _a.onBlur, onChange = _a.onChange, handleSizeChange = _a.handleSizeChange;
56
+ import StepFillerContainer from '../../Utils/@StepFiller/StepFiller';
57
+ function EntityValuePickerStep(_a) {
58
+ var step = _a.step, editable = _a.editable;
74
59
  var form = useContext(FormContext);
75
- var getValues = useFormContext().getValues;
76
- var currentBreakPoint = useAppSelector(selectBreakPoint);
77
- var _b = useState(level === 0
78
- ? calcFillerSize(step, form.steps, getValues(), form.size)
79
- : 0), fillerSize = _b[0], setFillerSize = _b[1];
80
- var sizeChange = function () {
81
- handleSizeChange === null || handleSizeChange === void 0 ? void 0 : handleSizeChange();
82
- if (level === 0) {
83
- setFillerSize(calcFillerSize(step, form.steps, getValues(), form.size));
84
- }
85
- };
86
- var renderSelect = function () {
87
- return (_jsx(SmartSelect, { onBlur: onBlur, error: error, onChange: onChange, level: level, value: value, inputRef: inputRef, editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getEntityValueOptions, getOptionSelected: function (option, value) {
60
+ return (_jsx(StepFillerContainer, __assign({ step: step }, { children: _jsx(SmartSelect, { editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getEntityValueOptions, getOptionSelected: function (option, value) {
88
61
  return option._id === value._id;
89
62
  }, calcDepError: function (steps) {
90
63
  for (var _i = 0, steps_1 = steps; _i < steps_1.length; _i++) {
@@ -94,48 +67,21 @@ function EntityValuePickerComponent(_a) {
94
67
  }
95
68
  }
96
69
  return undefined;
97
- }, getValueString: function (value) { return value === null || value === void 0 ? void 0 : value._id; } }));
98
- };
99
- var mapNestedOption = function () {
100
- if (value) {
101
- var currentOption = step.options[value._id];
102
- if ((currentOption === null || currentOption === void 0 ? void 0 : currentOption.type) === EntityValueOptionTypes.NESTED) {
103
- return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idStep) {
104
- var subStep = form.steps[idStep];
105
- return (_jsx(StepComponent, { editable: editable, step: subStep, level: level + 1, handleSizeChange: sizeChange }, idStep));
106
- }) }));
107
- }
108
- }
109
- };
110
- if (level === 0 && step.maxSize && step.maxSize < form.size.blockNum) {
111
- return (_jsxs("div", __assign({ className: styles.firstLvlContainer, style: {
112
- width: currentBreakPoint <= step.size ? '100%' : 'fit-content',
113
- } }, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize < form.size.blockNum && (_jsx("div", { className: styles.smallSeparator, style: {
114
- width: fillerSize,
115
- } }, "SEPARATOR"))] })));
116
- }
117
- else {
118
- return (_jsxs(React.Fragment, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize && (_jsx("div", { className: styles.separator }))] }));
119
- }
70
+ }, getValueString: function (value) { return value === null || value === void 0 ? void 0 : value._id; }, renderNestedSteps: function (value) {
71
+ if (!value)
72
+ return _jsx(_Fragment, {});
73
+ var currentOption = step.options[value._id];
74
+ if ((currentOption === null || currentOption === void 0 ? void 0 : currentOption.type) === EntityValueOptionTypes.NESTED) {
75
+ return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idStep) {
76
+ var subStep = form.steps[idStep];
77
+ return (_jsx(StepComponent, { editable: editable, step: subStep }, idStep));
78
+ }) }));
79
+ }
80
+ else
81
+ return _jsx(_Fragment, {});
82
+ } }) })));
120
83
  }
121
84
  export default EntityValuePickerStep;
122
- function EntityValuePickerStep(props) {
123
- var step = props.step, defaultValue = props.defaultValue;
124
- var _a = useStepDependency(step, defaultValue), handleStepDep = _a.handleStepDep, originalValue = _a.originalValue;
125
- var _b = useController({
126
- name: step.id,
127
- rules: {
128
- required: step.required ? 'Este campo es obligatorio' : undefined,
129
- },
130
- shouldUnregister: true,
131
- defaultValue: originalValue,
132
- }), _c = _b.field, ref = _c.ref, field = __rest(_c, ["ref"]), error = _b.fieldState.error;
133
- var onChange = useCallback(function (value) {
134
- handleStepDep(value);
135
- field.onChange(value);
136
- }, [handleStepDep, field]);
137
- return (_jsx(EntityValuePickerComponent, __assign({}, props, field, { error: error, inputRef: ref, onChange: onChange })));
138
- }
139
85
  var getEntityValueOptions = function (idOrganization, step, dependencyStore) { return __awaiter(void 0, void 0, void 0, function () {
140
86
  var urlPath, _i, _a, path, idEntityValue, currentValue, params, _b, _c, filter, currentValue, url, response;
141
87
  var _d, _e, _f, _g, _h;
@@ -14,5 +14,5 @@ export interface UploadedFileObject {
14
14
  downloadUrl?: string;
15
15
  }
16
16
  export declare function isUploadedFileObject(file: UploadedFileObject | FileObject): file is UploadedFileObject;
17
- declare function UploadStepComponent(props: FileUploadStepProps): JSX.Element;
18
- export default UploadStepComponent;
17
+ declare function FileUploadStep({ step, editable }: FileUploadStepProps): JSX.Element;
18
+ export default FileUploadStep;
@@ -45,17 +45,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
46
  }
47
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
48
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
60
49
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
61
50
  if (ar || !(i in from)) {
@@ -67,26 +56,34 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
67
56
  };
68
57
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
69
58
  import styles from './MaterialFileUploadStep.module.css';
70
- import { useController, useFormContext } from 'react-hook-form';
59
+ import { useFormContext } from 'react-hook-form';
71
60
  import RoundedButton from '../../../Shared/RoundedButton/RoundedButton';
72
- import { useCallback, useContext, useEffect, useRef, useState } from 'react';
61
+ import { useContext, useEffect, useRef, useState } from 'react';
73
62
  import { getAcceptedExtensions } from '../../../constants/Files/FileExtensions';
74
63
  import { getUploadUrls, postFile } from '../../../Services/FileService';
75
64
  import FileComponent from './FileComponent/FileComponent';
76
65
  import maxSize from '../../../constants/Files/FileMaxSize';
77
66
  import { useAppSelector } from '../../../hooks';
78
67
  import CustomContext from '../../../Contexts/CustomContext';
79
- import { useStepDependency } from '../../StepHooks';
68
+ import { useFormStep } from '../../StepHooks';
80
69
  export function isUploadedFileObject(file) {
81
70
  return file.state === undefined && file.S3Key !== undefined;
82
71
  }
83
72
  function FileUploadStep(_a) {
84
- var step = _a.step, value = _a.value, btnRef = _a.btnRef, onChange = _a.onChange, editable = _a.editable, fieldError = _a.fieldError;
73
+ var step = _a.step, editable = _a.editable;
74
+ var _b = useFormStep(step, {
75
+ rules: {
76
+ validate: function (array) {
77
+ return ((step.required && array.length > 0) || !step.required) &&
78
+ array.find(function (file) { return !file.S3Key; }) === undefined;
79
+ },
80
+ },
81
+ }), ref = _b.ref, value = _b.value, onChange = _b.onChange, fieldError = _b.error;
85
82
  var fetchDownloadUrl = useContext(CustomContext).fetchDownloadUrl;
86
- var _b = useAppSelector(function (state) { return state.global; }), formStyle = _b.formStyle, idOrganization = _b.idOrganization, postview = _b.postview;
83
+ var _c = useAppSelector(function (state) { return state.global; }), formStyle = _c.formStyle, idOrganization = _c.idOrganization, postview = _c.postview;
87
84
  var clearErrors = useFormContext().clearErrors;
88
- var _c = useState(undefined), error = _c[0], setError = _c[1];
89
- var _d = useState([]), fileChange = _d[0], setFileChange = _d[1];
85
+ var _d = useState(undefined), error = _d[0], setError = _d[1];
86
+ var _e = useState([]), fileChange = _e[0], setFileChange = _e[1];
90
87
  var inputRef = useRef();
91
88
  useEffect(function () {
92
89
  var filesToFetchLink = [];
@@ -210,7 +207,7 @@ function FileUploadStep(_a) {
210
207
  }
211
208
  return '';
212
209
  };
213
- return (_jsxs("div", __assign({ className: styles.container + (error || !!fieldError ? ' EF-error' : ''), style: editable == false || postview
210
+ return (_jsxs("div", __assign({ className: styles.container + (error || !!fieldError ? ' EF-error' : ''), style: editable === false || postview
214
211
  ? {}
215
212
  : {
216
213
  minHeight: '100px',
@@ -240,7 +237,7 @@ function FileUploadStep(_a) {
240
237
  }
241
238
  inputRef.current.value = '';
242
239
  }
243
- }, multiple: true, accept: getAcceptedExtensions() }), _jsxs("div", __assign({ className: styles.btnContainer }, { children: [_jsx("input", { ref: btnRef, className: 'hidden-input' }), _jsx(RoundedButton, { disabled: !editable || postview, text: 'Examinar' + (step.required ? ' *' : ''), color: formStyle.primaryContrastColor, backgroundColor: formStyle.primaryColor, fontSize: '1rem', padding: '5px 15px 5px 15px', onClick: function () {
240
+ }, multiple: true, accept: getAcceptedExtensions() }), _jsxs("div", __assign({ className: styles.btnContainer }, { children: [_jsx("input", { ref: ref, className: 'hidden-input' }), _jsx(RoundedButton, { disabled: !editable || postview, text: 'Examinar' + (step.required ? ' *' : ''), color: formStyle.primaryContrastColor, backgroundColor: formStyle.primaryColor, fontSize: '1rem', padding: '5px 15px 5px 15px', onClick: function () {
244
241
  if (editable && !postview) {
245
242
  var input = inputRef.current;
246
243
  if (input !== null) {
@@ -265,25 +262,4 @@ function FileUploadStep(_a) {
265
262
  }
266
263
  }, fetchDownloadUrl: fetchDownloadUrl }, index)); }) })), _jsx("div", __assign({ className: styles.errorMsg, style: { color: formStyle.errorColor } }, { children: error !== null && error !== void 0 ? error : calcErrorMsg() }))] })));
267
264
  }
268
- function UploadStepComponent(props) {
269
- var step = props.step;
270
- var _a = useStepDependency(step), handleStepDep = _a.handleStepDep, originalValue = _a.originalValue;
271
- var _b = useController({
272
- name: step.id,
273
- rules: {
274
- validate: function (array) {
275
- return ((props.step.required && array.length > 0) ||
276
- !props.step.required) &&
277
- array.find(function (file) { return !file.S3Key; }) === undefined;
278
- },
279
- },
280
- shouldUnregister: true,
281
- defaultValue: originalValue,
282
- }), _c = _b.field, ref = _c.ref, field = __rest(_c, ["ref"]), error = _b.fieldState.error;
283
- var onChange = useCallback(function (value) {
284
- handleStepDep(value);
285
- field.onChange(value);
286
- }, [handleStepDep, field]);
287
- return (_jsx(FileUploadStep, __assign({}, props, field, { btnRef: ref, fieldError: error, onChange: onChange })));
288
- }
289
- export default UploadStepComponent;
265
+ export default FileUploadStep;
@@ -20,7 +20,7 @@ import FormContext from '../../../../Contexts/FormContext';
20
20
  import CustomContext from '../../../../Contexts/CustomContext';
21
21
  function MapperElementComponent(props) {
22
22
  var _a;
23
- var level = props.level, step = props.step, element = props.element, editable = props.editable;
23
+ var step = props.step, element = props.element, editable = props.editable;
24
24
  var customContext = useContext(CustomContext);
25
25
  var form = useContext(FormContext);
26
26
  if (element.deleted) {
@@ -35,7 +35,7 @@ function MapperElementComponent(props) {
35
35
  return (_jsx(CustomContext.Provider, __assign({ value: nestedCustomContext }, { children: step.rootSteps.map(function (idSubStep) {
36
36
  var _a;
37
37
  var subStep = form.steps[element.ids[idSubStep]];
38
- return (_createElement(StepComponent, __assign({}, props, { editable: editable ? (_a = step.editable) !== null && _a !== void 0 ? _a : true : false, step: subStep, key: element.ids[idSubStep], level: level + 1 })));
38
+ return (_createElement(StepComponent, __assign({}, props, { editable: editable ? (_a = step.editable) !== null && _a !== void 0 ? _a : true : false, step: subStep, key: element.ids[idSubStep] })));
39
39
  }) })));
40
40
  };
41
41
  switch ((_a = step.style) === null || _a === void 0 ? void 0 : _a.type) {
@@ -56,10 +56,10 @@ function MapperStep(_a) {
56
56
  name: step.id,
57
57
  rules: {
58
58
  validate: function (array) {
59
- return (step.required &&
60
- array.filter(function (elem) { return !elem.deleted; })
61
- .length > 0) ||
62
- !step.required;
59
+ return !step.required ||
60
+ (step.required &&
61
+ array.filter(function (elem) { return !elem.deleted; })
62
+ .length > 0);
63
63
  },
64
64
  },
65
65
  shouldUnregister: true,
@@ -122,7 +122,11 @@ function MapperStep(_a) {
122
122
  margin: step.description
123
123
  ? '10px 0px'
124
124
  : '0px 0px 5px 0px',
125
- } }, { children: step.description }))), mapElements(), _jsx("input", { id: step.id, ref: ref, className: 'hidden-input', readOnly: true, value: inputValue }), step.creatable !== false && (_jsxs("div", __assign({ className: styles.btnContainer }, { children: [!customAdd && (_jsx(RoundedButton, { disabled: !editable || postview, text: step.addBtnLabel + (step.required ? ' *' : ''), color: formStyle.primaryContrastColor, backgroundColor: formStyle.primaryColor, fontSize: '1rem', padding: '5px 15px 5px 15px', onClick: function () {
125
+ } }, { children: step.description }))), mapElements(), _jsx("input", { id: step.id, ref: ref, className: 'hidden-input', readOnly: true, value: inputValue }), step.creatable !== false &&
126
+ (!step.max ||
127
+ value.filter(function (elem) { return !elem.deleted; })
128
+ .length < step.max) && (_jsxs("div", __assign({ className: styles.btnContainer }, { children: [!customAdd && (_jsx(RoundedButton, { disabled: !editable || postview, text: step.addBtnLabel +
129
+ (step.required ? ' *' : ''), color: formStyle.primaryContrastColor, backgroundColor: formStyle.primaryColor, fontSize: '1rem', padding: '5px 15px 5px 15px', onClick: function () {
126
130
  if (editable && !postview) {
127
131
  handleAddElement();
128
132
  }
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { RatingStepProps } from '../RatingStep';
3
- declare function RatingStep(props: RatingStepProps): JSX.Element;
3
+ declare function RatingStep({ step, editable }: RatingStepProps): JSX.Element;
4
4
  export default RatingStep;
@@ -9,34 +9,26 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
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
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
13
  import styles from './MaterialRatingStep.module.css';
25
- import { useController, useFormContext } from 'react-hook-form';
26
- import React, { useCallback, useContext } from 'react';
14
+ import React, { useContext } from 'react';
27
15
  import Rating from '../../../Shared/Rating/Rating';
28
16
  import { RatingTypes } from '../../../constants/FormStepTypes';
29
17
  import StepComponent from '../../Step';
30
18
  import FormContext from '../../../Contexts/FormContext';
31
19
  import { useAppSelector } from '../../../hooks';
32
- import { useStepDependency } from '../../StepHooks';
33
- function MaterialRatingStep(_a) {
34
- var _b, _c, _d, _e, _f;
35
- var step = _a.step, value = _a.value, level = _a.level, onChange = _a.onChange, inputRef = _a.inputRef, editable = _a.editable;
20
+ import { useFormStep } from '../../StepHooks';
21
+ function RatingStep(_a) {
22
+ var _b, _c, _d, _e;
23
+ var step = _a.step, editable = _a.editable;
24
+ var _f = useFormStep(step, {
25
+ rules: {
26
+ required: step.required ? 'Este campo es obligatorio' : undefined,
27
+ },
28
+ }), ref = _f.ref, value = _f.value, onChange = _f.onChange, error = _f.error;
36
29
  var _g = useAppSelector(function (state) { return state.global; }), formStyle = _g.formStyle, postview = _g.postview;
37
30
  var form = useContext(FormContext);
38
31
  var widthStats = useAppSelector(function (state) { return state.widthStats; });
39
- var errors = useFormContext().formState.errors;
40
32
  var renderNestedOption = function () {
41
33
  var currentOption;
42
34
  if (value !== undefined && value !== null && step.nestedSteps) {
@@ -49,39 +41,19 @@ function MaterialRatingStep(_a) {
49
41
  if (currentOption && currentOption.length > 0) {
50
42
  return (_jsx(React.Fragment, { children: currentOption.map(function (idSubStep) {
51
43
  var subStep = form.steps[idSubStep];
52
- return (_jsx(StepComponent, { editable: editable, step: subStep, level: level + 1 }, idSubStep));
44
+ return (_jsx(StepComponent, { editable: editable, step: subStep }, idSubStep));
53
45
  }) }));
54
46
  }
55
47
  }
56
48
  };
57
49
  return (_jsxs(React.Fragment, { children: [_jsxs("div", __assign({ className: styles.container, style: {
58
50
  paddingBottom: step.description || step.required ? 0 : 15,
59
- } }, { children: [_jsx("div", __assign({ className: styles.labelLabel }, { children: step.label + (step.required ? ' *' : '') })), _jsx("div", __assign({ className: styles.ratingContainer }, { children: _jsx(Rating, { name: step.id, type: step.ratingType, isMobile: widthStats.isMobile, focusColor: (_b = formStyle.primaryColor) !== null && _b !== void 0 ? _b : '#3d5a7f', unSelectedColor: (_c = formStyle.outlineColor) !== null && _c !== void 0 ? _c : '#b8b8b8', disabled: !editable || postview, value: value, onChange: onChange, inputRef: inputRef }) })), (step.description || step.required) && (_jsx("div", __assign({ className: styles.stepDescriptionLabel, style: {
60
- color: !!errors[step.id] && value === null
51
+ } }, { children: [_jsx("div", __assign({ className: styles.labelLabel }, { children: step.label + (step.required ? ' *' : '') })), _jsx("div", __assign({ className: styles.ratingContainer }, { children: _jsx(Rating, { name: step.id, type: step.ratingType, isMobile: widthStats.isMobile, focusColor: (_b = formStyle.primaryColor) !== null && _b !== void 0 ? _b : '#3d5a7f', unSelectedColor: (_c = formStyle.outlineColor) !== null && _c !== void 0 ? _c : '#b8b8b8', disabled: !editable || postview, value: value, onChange: onChange, inputRef: ref }) })), (step.description || step.required) && (_jsx("div", __assign({ className: styles.stepDescriptionLabel, style: {
52
+ color: !!error && value === null
61
53
  ? (_d = formStyle.errorColor) !== null && _d !== void 0 ? _d : '#cc2936'
62
54
  : (_e = formStyle.descriptionTextColor) !== null && _e !== void 0 ? _e : '#989898',
63
- } }, { children: !!errors[step.id] && value === null
64
- ? (_f = errors[step.id]) === null || _f === void 0 ? void 0 : _f.message
55
+ } }, { children: !!error && value === null
56
+ ? error === null || error === void 0 ? void 0 : error.message
65
57
  : step.description })))] })), renderNestedOption()] }));
66
58
  }
67
- function RatingStep(props) {
68
- var step = props.step;
69
- var _a = useStepDependency(step), handleStepDep = _a.handleStepDep, originalValue = _a.originalValue;
70
- var _b = useController({
71
- name: step.id,
72
- shouldUnregister: true,
73
- rules: {
74
- required: step.required ? 'Este campo es obligatorio' : undefined,
75
- },
76
- defaultValue: originalValue,
77
- }).field, ref = _b.ref, field = __rest(_b, ["ref"]);
78
- var onChange = useCallback(function (value) {
79
- handleStepDep(value);
80
- field.onChange(value);
81
- }, [handleStepDep, field]);
82
- return (_jsx(MaterialRatingStep, __assign({}, props, field, { inputRef: ref, onChange: function (value) {
83
- handleStepDep(value);
84
- onChange(value);
85
- } })));
86
- }
87
59
  export default RatingStep;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { SelectorStepProps } from '../SelectorStep';
3
- declare function SelectorStep(props: SelectorStepProps): JSX.Element;
4
- export default SelectorStep;
3
+ declare function SelectorStepContainer(props: SelectorStepProps): JSX.Element;
4
+ export default SelectorStepContainer;
@@ -9,59 +9,27 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
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
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
- import React, { useCallback, useContext, useState } from 'react';
13
+ import React, { useContext } from 'react';
25
14
  import { OptionTypes } from '../../../constants/FormStepTypes';
26
- import styles from './MaterialSelectorStep.module.css';
27
15
  import StepComponent from '../../Step';
28
- import { calcFillerSize, calcStepWidth } from '../../StepFunctions';
29
- import { useController, useFormContext } from 'react-hook-form';
30
16
  import RoundedSmartSelect from '../../../Shared/RoundedSmartSelect/RoundedSmartSelect';
31
17
  import FormContext from '../../../Contexts/FormContext';
32
- import { selectBreakPoint, useAppSelector } from '../../../hooks';
33
- import { useStepDependency } from '../../StepHooks';
34
- function Selector(_a) {
35
- var step = _a.step, value = _a.value, level = _a.level, onBlur = _a.onBlur, editable = _a.editable, onChange = _a.onChange, handleSizeChange = _a.handleSizeChange, inputRef = _a.inputRef;
18
+ import { useAppSelector } from '../../../hooks';
19
+ import { useFormStep } from '../../StepHooks';
20
+ import StepFillerContainer from '../../Utils/@StepFiller/StepFiller';
21
+ import MaterialInputContainer from '../../Utils/MaterialInputContainer/MaterialInputContainer';
22
+ function SelectorStep(_a) {
23
+ var _b, _c, _d;
24
+ var step = _a.step, editable = _a.editable;
25
+ var _e = useFormStep(step, {
26
+ rules: {
27
+ required: step.required ? 'Este campo es obligatorio' : undefined,
28
+ },
29
+ sizeChange: true,
30
+ }), ref = _e.ref, value = _e.value, onChange = _e.onChange, error = _e.error, field = _e.field;
36
31
  var form = useContext(FormContext);
37
- var _b = useAppSelector(function (state) { return state.global; }), postview = _b.postview, formStyle = _b.formStyle;
38
- var currentBreakPoint = useAppSelector(selectBreakPoint);
39
- var _c = useFormContext(), getValues = _c.getValues, errors = _c.formState.errors;
40
- var _d = useState(level === 0
41
- ? calcFillerSize(step, form.steps, getValues(), form.size)
42
- : 0), fillerSize = _d[0], setFillerSize = _d[1];
43
- var sizeChange = function () {
44
- handleSizeChange === null || handleSizeChange === void 0 ? void 0 : handleSizeChange();
45
- if (level === 0) {
46
- setFillerSize(calcFillerSize(step, form.steps, getValues(), form.size));
47
- }
48
- };
49
- var renderSelect = function () {
50
- var _a, _b, _c, _d;
51
- return (_jsx("div", __assign({ className: styles.container, style: {
52
- width: currentBreakPoint <= step.size
53
- ? '100%'
54
- : calcStepWidth(step.size, form.size),
55
- minHeight: step.description ||
56
- (!postview && editable && step.required)
57
- ? '55px'
58
- : '43px',
59
- } }, { children: _jsx(RoundedSmartSelect, { value: value, onBlur: onBlur, disabled: false, loading: false, options: step.options, inputRef: inputRef, cantEdit: !editable || postview, fullWidth: true, backgroundColor: (_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) {
60
- onChange(value);
61
- }, getOptionSelected: function (option, value) {
62
- return (option === null || option === void 0 ? void 0 : option.value) === (value === null || value === void 0 ? void 0 : value.value);
63
- }, helperText: (_d = (_c = (_b = errors[step.id]) === null || _b === void 0 ? void 0 : _b.message) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : step.description, error: !!errors[step.id] }) })));
64
- };
32
+ var _f = useAppSelector(function (state) { return state.global; }), postview = _f.postview, formStyle = _f.formStyle;
65
33
  var mapNestedOption = function () {
66
34
  var currentOptionIndex = null;
67
35
  var currentOption = null;
@@ -76,39 +44,15 @@ function Selector(_a) {
76
44
  currentOptionIndex !== null) {
77
45
  return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idSubStep) {
78
46
  var subStep = form.steps[idSubStep];
79
- return (_jsx(StepComponent, { editable: editable, step: subStep, level: level + 1, handleSizeChange: sizeChange }, idSubStep));
47
+ return (_jsx(StepComponent, { editable: editable, step: subStep }, idSubStep));
80
48
  }) }));
81
49
  }
82
50
  };
83
- if (level === 0 && step.maxSize && step.maxSize < form.size.blockNum) {
84
- return (_jsxs("div", __assign({ className: styles.firstLvlContainer, style: {
85
- width: currentBreakPoint <= step.size ? '100%' : 'fit-content',
86
- } }, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize < form.size.blockNum && (_jsx("div", { className: styles.smallSeparator, style: {
87
- width: fillerSize,
88
- } }))] })));
89
- }
90
- else {
91
- return (_jsxs(React.Fragment, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize && (_jsx("div", { className: styles.separator }))] }));
92
- }
51
+ return (_jsxs(React.Fragment, { children: [_jsx(MaterialInputContainer, __assign({ step: step, editable: editable }, { children: _jsx(RoundedSmartSelect, __assign({}, field, { value: value, inputRef: ref, handleUpdate: onChange, disabled: false, loading: false, options: step.options, cantEdit: !editable || postview, fullWidth: true, backgroundColor: (_b = formStyle.stepBackgroundColor) !== null && _b !== void 0 ? _b : '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", getOptionSelected: function (option, value) {
52
+ return (option === null || option === void 0 ? void 0 : option.value) === (value === null || value === void 0 ? void 0 : value.value);
53
+ }, helperText: (_d = (_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : step.description, error: !!error })) })), value && mapNestedOption()] }));
93
54
  }
94
- function SelectorStep(props) {
95
- var step = props.step;
96
- var _a = useStepDependency(step), handleStepDep = _a.handleStepDep, originalValue = _a.originalValue;
97
- var _b = useController({
98
- name: step.id,
99
- rules: {
100
- required: step.required ? 'Este campo es obligatorio' : undefined,
101
- },
102
- shouldUnregister: true,
103
- defaultValue: originalValue,
104
- }).field, ref = _b.ref, field = __rest(_b, ["ref"]);
105
- var onChange = useCallback(function (value) {
106
- handleStepDep(value);
107
- field.onChange(value);
108
- }, [handleStepDep, field]);
109
- return (_jsx(Selector, __assign({}, props, field, { inputRef: ref, onChange: function (value) {
110
- handleStepDep(value);
111
- onChange(value);
112
- } })));
55
+ function SelectorStepContainer(props) {
56
+ return (_jsx(StepFillerContainer, __assign({ step: props.step }, { children: _jsx(SelectorStep, __assign({}, props)) })));
113
57
  }
114
- export default SelectorStep;
58
+ export default SelectorStepContainer;
@@ -7,19 +7,3 @@
7
7
  padding-top: 5px;
8
8
  margin-bottom: 0px;
9
9
  }
10
- .separator {
11
- flex-basis: 100%;
12
- height: 0;
13
- }
14
-
15
- .firstLvlContainer {
16
- max-width: 100%;
17
- display: flex;
18
- flex-flow: row wrap;
19
- }
20
-
21
- .smallSeparator {
22
- height: 0;
23
- max-width: 100%;
24
- flex-basis: 0;
25
- }
@@ -1,13 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { FieldError } from 'react-hook-form';
3
2
  import { SmartSelectStepProps } from '../SmartSelectStep';
4
3
  import { GSmartSelect } from '../../../@Types/GenericFormSteps';
5
- export declare function SmartSelect<StepType extends GSmartSelect>({ icon, step, value, error, onBlur, editable, onChange, inputRef, getOptions, calcDepError, valueOverwrite, getValueString, changeListener, getValueWarning, getOptionSelected, renderNestedSteps, }: SmartSelectStepProps<StepType> & {
6
- error: FieldError | undefined;
7
- onChange: any;
8
- onBlur: (event: any) => void;
9
- value: any;
10
- inputRef: any;
11
- }): JSX.Element;
12
- declare function SmartSelectStep(props: SmartSelectStepProps): JSX.Element;
4
+ declare function SmartSelectStep<StepType extends GSmartSelect>({ icon, step, editable, getOptions, calcDepError, defaultValue, valueOverwrite, getValueString, changeListener, getValueWarning, getOptionSelected, renderNestedSteps, }: SmartSelectStepProps<StepType>): JSX.Element;
13
5
  export default SmartSelectStep;