@arquimedes.co/eureka-forms 2.0.18 → 2.0.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 (55) hide show
  1. package/dist/@Types/Form.d.ts +1 -0
  2. package/dist/@Types/FormStep.d.ts +1 -0
  3. package/dist/App/AppFunctions.js +11 -11
  4. package/dist/Form/Section/MaterialSection/MaterialSection.js +1 -1
  5. package/dist/Form/Terms/Term/MaterialTerm/MaterialTerm.js +9 -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/package.json +1 -1
  54. package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.module.css +0 -25
  55. package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.module.css +0 -9
@@ -15,6 +15,7 @@ export interface Form {
15
15
  Branding?: Branding;
16
16
  classifiers?: Record<string, Classifier>;
17
17
  terms?: Term[];
18
+ hiddenSteps?: string[];
18
19
  }
19
20
  export interface FormSize {
20
21
  blockNum: 1 | 2 | 3 | 4;
@@ -190,5 +190,6 @@ export interface Mapper extends GSteps.GBaseStep {
190
190
  unitLabel: string;
191
191
  creatable?: boolean;
192
192
  deletable?: boolean;
193
+ max?: number;
193
194
  }
194
195
  export {};
@@ -15,7 +15,7 @@ import { getRawText, stringToDraft } from '../Utils/DraftFunctions';
15
15
  import { calcSubSteps } from '../FormSteps/StepFunctions';
16
16
  export var calcValuesStore = function (form, originalValues, postview, customSteps) {
17
17
  var _a;
18
- var _b;
18
+ var _b, _c;
19
19
  if (originalValues === void 0) { originalValues = {}; }
20
20
  if (postview === void 0) { postview = false; }
21
21
  if (customSteps === void 0) { customSteps = {}; }
@@ -23,10 +23,10 @@ export var calcValuesStore = function (form, originalValues, postview, customSte
23
23
  global: {},
24
24
  sections: {},
25
25
  };
26
- for (var _i = 0, _c = Object.keys(originalValues); _i < _c.length; _i++) {
27
- var idValue = _c[_i];
26
+ for (var _i = 0, _d = Object.keys(originalValues); _i < _d.length; _i++) {
27
+ var idValue = _d[_i];
28
28
  var step = form.steps[idValue];
29
- if (step) {
29
+ if (step && !((_b = form.hiddenSteps) === null || _b === void 0 ? void 0 : _b.includes(step.id))) {
30
30
  var value = mapOriginalValue(step, originalValues[step.id], values, form);
31
31
  if (value !== undefined) {
32
32
  if (!values.sections[step.idSection])
@@ -40,17 +40,17 @@ export var calcValuesStore = function (form, originalValues, postview, customSte
40
40
  }
41
41
  if (postview)
42
42
  return values;
43
- for (var _d = 0, _e = Object.values(form.sections); _d < _e.length; _d++) {
44
- var section = _e[_d];
45
- for (var _f = 0, _g = section.steps; _f < _g.length; _f++) {
46
- var idStep = _g[_f];
43
+ for (var _e = 0, _f = Object.values(form.sections); _e < _f.length; _e++) {
44
+ var section = _f[_e];
45
+ for (var _g = 0, _h = section.steps; _g < _h.length; _g++) {
46
+ var idStep = _h[_g];
47
47
  var step = form.steps[idStep];
48
48
  if (step.type !== StepTypes.MAPPER ||
49
- ((_b = values.sections[step.idSection]) === null || _b === void 0 ? void 0 : _b[step.id]))
49
+ ((_c = values.sections[step.idSection]) === null || _c === void 0 ? void 0 : _c[step.id]))
50
50
  continue;
51
51
  if (!values.sections[step.idSection])
52
52
  values.sections[step.idSection] = {};
53
- var _h = addMapperStep(step, customSteps), element = _h.element, mappers = _h.mappers;
53
+ var _j = addMapperStep(step, customSteps), element = _j.element, mappers = _j.mappers;
54
54
  values.sections[step.idSection] = __assign(__assign(__assign({}, values.sections[step.idSection]), mappers), (_a = {}, _a[step.id] = [element], _a));
55
55
  }
56
56
  }
@@ -166,7 +166,7 @@ export var mapOriginalValue = function (step, value, values, form) {
166
166
  }
167
167
  }
168
168
  case StepTypes.SELECTOR: {
169
- var option = step.options.find(function (option) { return option.value == value; });
169
+ var option = step.options.find(function (option) { return option.value === value; });
170
170
  if (!(value === null || value === void 0 ? void 0 : value.value))
171
171
  return option;
172
172
  return value;
@@ -35,7 +35,7 @@ function MaterialSection(_a) {
35
35
  : 'normal',
36
36
  } }, { children: (_b = section.steps) === null || _b === void 0 ? void 0 : _b.map(function (idStep) {
37
37
  var step = form.steps[idStep];
38
- return (_jsx(StepComponent, { editable: editable, step: step, level: 0 }, idStep));
38
+ return (_jsx(StepComponent, { editable: editable, step: step }, idStep));
39
39
  }) })));
40
40
  }
41
41
  export default MaterialSection;
@@ -30,16 +30,24 @@ import RoundedCheckBox from '../../../../Shared/RoundedCheckBox/RoundedCheckBox'
30
30
  import CloseRoundedIcon from '@material-ui/icons/CloseRounded';
31
31
  import styles from './MaterialTerm.module.css';
32
32
  import { useAppSelector } from '../../../../hooks';
33
+ import { createSelector } from '@reduxjs/toolkit';
34
+ var selectOriginalValue = createSelector([
35
+ function (state) { return state.site.values; },
36
+ function (state, idTerm) { return idTerm; },
37
+ ], function (values, idTerm) { return values.global[idTerm]; });
33
38
  function TermComponent(_a) {
34
39
  var _b;
35
40
  var term = _a.term, tempError = _a.tempError;
36
41
  var _c = useAppSelector(function (state) { return state.global; }), formStyle = _c.formStyle, postview = _c.postview;
42
+ var originalValue = useAppSelector(function (state) {
43
+ return selectOriginalValue(state, term.id);
44
+ });
37
45
  var _d = useController({
38
46
  name: term.id,
39
47
  rules: {
40
48
  required: true,
41
49
  },
42
- defaultValue: false,
50
+ defaultValue: originalValue !== null && originalValue !== void 0 ? originalValue : false,
43
51
  shouldUnregister: true,
44
52
  }), _e = _d.field, ref = _e.ref, field = __rest(_e, ["ref"]), error = _d.fieldState.error;
45
53
  var _f = useState(false), showDialog = _f[0], setShowDialog = _f[1];
@@ -80,14 +80,14 @@ function ElementSubStepRenderer(_a) {
80
80
  var _b;
81
81
  var value = _a.value, stepProps = __rest(_a, ["value"]);
82
82
  var form = useContext(FormContext);
83
- if (!value || stepProps == undefined) {
83
+ if (!value || stepProps === undefined) {
84
84
  return _jsx("div", {});
85
85
  }
86
86
  var subStep = form.steps[(_b = stepProps.step.subStep) !== null && _b !== void 0 ? _b : ''];
87
87
  if ((subStep === null || subStep === void 0 ? void 0 : subStep.type) !== CBRFormStepTypes.CBR_LOCATIVAS) {
88
88
  return _jsx("div", {});
89
89
  }
90
- return (_jsx(SmartSelectStep, __assign({}, stepProps, { step: subStep, level: stepProps.level + 1, icon: _jsx(InputIcon, { icon: 'LEAK' }), getOptions: getElementOptions, calcDepError: calcDepError, getOptionSelected: function (option, value) {
90
+ return (_jsx(SmartSelectStep, __assign({}, stepProps, { step: subStep, icon: _jsx(InputIcon, { icon: 'LEAK' }), getOptions: getElementOptions, calcDepError: calcDepError, getOptionSelected: function (option, value) {
91
91
  return option.id === value.id;
92
92
  }, getValueString: function (value) { return value === null || value === void 0 ? void 0 : value.id; }, renderNestedSteps: function (value) { return (_jsx(ElementSubStepRenderer, __assign({ value: value }, stepProps, { step: subStep }))); } })));
93
93
  }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { CBRIncidentsStepProps } from '../../CBRIncidentsStep';
3
3
  import { Incident } from '../MaterialCBRIncidentsStep';
4
- declare function IncidentComponent({ step, level, incident, handleDelete, ...others }: CBRIncidentsStepProps & {
4
+ declare function IncidentComponent({ step, incident, handleDelete, ...others }: CBRIncidentsStepProps & {
5
5
  incident: Incident;
6
6
  handleDelete: () => void;
7
7
  }): JSX.Element;
@@ -29,7 +29,7 @@ import FormContext from '../../../../../Contexts/FormContext';
29
29
  import { useAppSelector } from '../../../../../hooks';
30
30
  import { useContext } from 'react';
31
31
  function IncidentComponent(_a) {
32
- var step = _a.step, level = _a.level, incident = _a.incident, handleDelete = _a.handleDelete, others = __rest(_a, ["step", "level", "incident", "handleDelete"]);
32
+ var step = _a.step, incident = _a.incident, handleDelete = _a.handleDelete, others = __rest(_a, ["step", "incident", "handleDelete"]);
33
33
  var _b = useAppSelector(function (state) { return state.global; }), formStyle = _b.formStyle, postview = _b.postview;
34
34
  var form = useContext(FormContext);
35
35
  var widthStats = useAppSelector(function (state) { return state.widthStats; });
@@ -50,6 +50,6 @@ function IncidentComponent(_a) {
50
50
  if (others.editable && !postview) {
51
51
  handleDelete();
52
52
  }
53
- } }, { children: _jsx(DeleteRoundedIcon, { fontSize: "inherit" }) })), _jsx(StepComponent, __assign({}, others, { step: spaceStep, level: level + 1 })), _jsx(StepComponent, __assign({}, others, { step: elementStep, level: level + 1 })), _jsx(TextAreaStep, __assign({}, others, { step: commentStep, maxLength: 200, level: level + 1 }))] })) })));
53
+ } }, { children: _jsx(DeleteRoundedIcon, { fontSize: "inherit" }) })), _jsx(StepComponent, __assign({}, others, { step: spaceStep })), _jsx(StepComponent, __assign({}, others, { step: elementStep })), _jsx(TextAreaStep, __assign({}, others, { step: commentStep, maxLength: 200 }))] })) })));
54
54
  }
55
55
  export default IncidentComponent;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { ApiSelectorStepProps } from '../ApiSelectorStep';
3
- export default ApiSelectorStep;
4
- declare function ApiSelectorStep(props: ApiSelectorStepProps): JSX.Element;
3
+ declare function ApiSelectorComponent({ step, editable, ...others }: ApiSelectorStepProps): JSX.Element;
4
+ export default ApiSelectorComponent;
@@ -56,28 +56,19 @@ var __rest = (this && this.__rest) || function (s, e) {
56
56
  }
57
57
  return t;
58
58
  };
59
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
60
- import React, { useCallback, useContext, useState } from 'react';
59
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
60
+ import React, { useContext } from 'react';
61
61
  import FormStepTypes, { ApiSelectorOptionTypes, ApiSelectorParamTypes, } from '../../../constants/FormStepTypes';
62
- import styles from './MaterialApiSelectorStep.module.css';
63
62
  import StepComponent from '../../Step';
64
- import { useController, useFormContext } from 'react-hook-form';
65
- import { calcFillerSize } from '../../StepFunctions';
66
- import { SmartSelect } from '../../SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep';
63
+ import SmartSelect from '../../SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep';
67
64
  import widgetInstance from '../../../Utils/AxiosWidget';
68
65
  import axiosInstance from '../../../Utils/AxiosAPI';
69
66
  import InputIcon from '../../../Shared/InputIcon/InputIcon';
70
67
  import FormContext from '../../../Contexts/FormContext';
71
- import { selectBreakPoint, useAppSelector } from '../../../hooks';
72
- import { useStepDependency } from '../../StepHooks';
68
+ import StepFillerContainer from '../../Utils/@StepFiller/StepFiller';
73
69
  function ApiSelectorComponent(_a) {
74
- var step = _a.step, level = _a.level, value = _a.value, editable = _a.editable, inputRef = _a.inputRef, handleSizeChange = _a.handleSizeChange, others = __rest(_a, ["step", "level", "value", "editable", "inputRef", "handleSizeChange"]);
70
+ var step = _a.step, editable = _a.editable, others = __rest(_a, ["step", "editable"]);
75
71
  var form = useContext(FormContext);
76
- var currentBreakPoint = useAppSelector(selectBreakPoint);
77
- var getValues = useFormContext().getValues;
78
- var _b = useState(level === 0
79
- ? calcFillerSize(step, form.steps, getValues(), form.size)
80
- : 0), fillerSize = _b[0], setFillerSize = _b[1];
81
72
  function calcOptionId(option) {
82
73
  var _a;
83
74
  return (_a = option === null || option === void 0 ? void 0 : option[step.idAttribute]) !== null && _a !== void 0 ? _a : '';
@@ -86,14 +77,7 @@ function ApiSelectorComponent(_a) {
86
77
  var _a;
87
78
  return (_a = option === null || option === void 0 ? void 0 : option[step.labelAttribute]) !== null && _a !== void 0 ? _a : '';
88
79
  }
89
- var sizeChange = function () {
90
- handleSizeChange === null || handleSizeChange === void 0 ? void 0 : handleSizeChange();
91
- if (level === 0) {
92
- setFillerSize(calcFillerSize(step, form.steps, getValues(), form.size));
93
- }
94
- };
95
- var renderSelect = function () {
96
- return (_jsx(SmartSelect, __assign({}, others, { level: level, value: value, inputRef: inputRef, editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getApiOptions, getOptionSelected: function (option, value) {
80
+ return (_jsx(StepFillerContainer, __assign({ step: step }, { children: _jsx(SmartSelect, __assign({}, others, { editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getApiOptions, getOptionSelected: function (option, value) {
97
81
  return calcOptionId(option) === calcOptionId(value);
98
82
  }, calcDepError: function (steps) {
99
83
  for (var _i = 0, steps_1 = steps; _i < steps_1.length; _i++) {
@@ -103,48 +87,21 @@ function ApiSelectorComponent(_a) {
103
87
  }
104
88
  }
105
89
  return undefined;
106
- }, getValueString: function (value) { return calcOptionLabel(value); } })));
107
- };
108
- var mapNestedOption = function () {
109
- if (value) {
110
- var currentOption = step.options[calcOptionId(value)];
111
- if ((currentOption === null || currentOption === void 0 ? void 0 : currentOption.type) === ApiSelectorOptionTypes.NESTED) {
112
- return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idStep) {
113
- var subStep = form.steps[idStep];
114
- return (_jsx(StepComponent, { editable: editable, step: subStep, level: level + 1, handleSizeChange: sizeChange }, idStep));
115
- }) }));
116
- }
117
- }
118
- };
119
- if (level === 0 && step.maxSize && step.maxSize < form.size.blockNum) {
120
- return (_jsxs("div", __assign({ className: styles.firstLvlContainer, style: {
121
- width: currentBreakPoint <= step.size ? '100%' : 'fit-content',
122
- } }, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize < form.size.blockNum && (_jsx("div", { className: styles.smallSeparator, style: {
123
- width: fillerSize,
124
- } }, "SEPARATOR"))] })));
125
- }
126
- else {
127
- return (_jsxs(React.Fragment, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize && (_jsx("div", { className: styles.separator }))] }));
128
- }
129
- }
130
- export default ApiSelectorStep;
131
- function ApiSelectorStep(props) {
132
- var step = props.step, defaultValue = props.defaultValue;
133
- var _a = useStepDependency(step, defaultValue), handleStepDep = _a.handleStepDep, originalValue = _a.originalValue;
134
- var _b = useController({
135
- name: step.id,
136
- rules: {
137
- required: step.required ? 'Este campo es obligatorio' : undefined,
138
- },
139
- shouldUnregister: true,
140
- defaultValue: originalValue,
141
- }), _c = _b.field, ref = _c.ref, field = __rest(_c, ["ref"]), error = _b.fieldState.error;
142
- var onChange = useCallback(function (value) {
143
- handleStepDep(value);
144
- field.onChange(value);
145
- }, [handleStepDep, field]);
146
- return (_jsx(ApiSelectorComponent, __assign({}, props, field, { error: error, inputRef: ref, onChange: onChange })));
90
+ }, getValueString: function (value) { return calcOptionLabel(value); }, renderNestedSteps: function (value) {
91
+ if (!value)
92
+ return _jsx(_Fragment, {});
93
+ var currentOption = step.options[calcOptionId(value)];
94
+ if ((currentOption === null || currentOption === void 0 ? void 0 : currentOption.type) === ApiSelectorOptionTypes.NESTED) {
95
+ return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idStep) {
96
+ var subStep = form.steps[idStep];
97
+ return (_jsx(StepComponent, { editable: editable, step: subStep }, idStep));
98
+ }) }));
99
+ }
100
+ else
101
+ return _jsx(_Fragment, {});
102
+ } })) })));
147
103
  }
104
+ export default ApiSelectorComponent;
148
105
  var getApiOptions = function (idOrganization, step, dependencyStore) { return __awaiter(void 0, void 0, void 0, function () {
149
106
  function calcOptionId(option) {
150
107
  var _a;
@@ -1,16 +0,0 @@
1
- .separator {
2
- flex-basis: 100%;
3
- height: 0;
4
- }
5
-
6
- .firstLvlContainer {
7
- max-width: 100%;
8
- display: flex;
9
- flex-flow: row wrap;
10
- }
11
-
12
- .smallSeparator {
13
- height: 0;
14
- max-width: 100%;
15
- flex-basis: 0;
16
- }
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { CheckBoxStepProps } from '../CheckBoxStep';
3
- declare function CheckBoxStep(props: CheckBoxStepProps): JSX.Element;
3
+ declare function CheckBoxStep({ step, editable }: CheckBoxStepProps): JSX.Element;
4
4
  export default CheckBoxStep;
@@ -9,92 +9,37 @@ 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
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
13
  import styles from './MaterialCheckBoxStep.module.css';
25
- import { calcFillerSize, calcStepWidth } from '../../StepFunctions';
26
14
  import RoundedCheckBox from '../../../Shared/RoundedCheckBox/RoundedCheckBox';
27
- import { useController, useFormContext } from 'react-hook-form';
28
- import React, { useCallback, useContext, useState } from 'react';
15
+ import React, { useContext } from 'react';
29
16
  import StepComponent from '../../Step';
30
17
  import FormContext from '../../../Contexts/FormContext';
31
- import { selectBreakPoint, useAppSelector } from '../../../hooks';
32
- import { useStepDependency } from '../../StepHooks';
33
- function CheckBox(_a) {
34
- var step = _a.step, value = _a.value, onBlur = _a.onBlur, level = _a.level, onChange = _a.onChange, inputRef = _a.inputRef, editable = _a.editable, handleSizeChange = _a.handleSizeChange;
35
- var _b = useAppSelector(function (state) { return state.global; }), formStyle = _b.formStyle, postview = _b.postview;
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 CheckBoxStep(_a) {
23
+ var step = _a.step, editable = _a.editable;
24
+ var _b = useFormStep(step, {
25
+ rules: {
26
+ required: step.required ? 'Este campo es obligatorio' : undefined,
27
+ },
28
+ sizeChange: true,
29
+ }), ref = _b.ref, value = _b.value, onChange = _b.onChange, error = _b.error, field = _b.field;
30
+ var _c = useAppSelector(function (state) { return state.global; }), formStyle = _c.formStyle, postview = _c.postview;
36
31
  var form = useContext(FormContext);
37
- var currentBreakPoint = useAppSelector(selectBreakPoint);
38
- var _c = useFormContext(), getValues = _c.getValues, errors = _c.formState.errors;
39
- var _d = useState(level === 0
40
- ? calcFillerSize(step, form.steps, getValues(), form.size)
41
- : 0), fillerSize = _d[0], setFillerSize = _d[1];
42
- var sizeChange = function () {
43
- handleSizeChange === null || handleSizeChange === void 0 ? void 0 : handleSizeChange();
44
- if (level === 0) {
45
- setFillerSize(calcFillerSize(step, form.steps, getValues(), form.size));
46
- }
47
- };
48
- var renderCheckbox = function () {
49
- return (_jsxs("div", __assign({ className: styles.container, style: {
50
- width: currentBreakPoint <= step.size
51
- ? '100%'
52
- : calcStepWidth(step.size, form.size),
53
- minHeight: step.description ||
54
- (!postview && editable && step.required)
55
- ? '55px'
56
- : '43px',
57
- } }, { children: [_jsxs("div", __assign({ className: styles.labelCheckBoxContainer }, { children: [step.label && (_jsxs("div", __assign({ className: styles.checkboxLbl }, { children: [step.label, step.required ? ' *' : '', ":"] }))), _jsx(RoundedCheckBox, { onChange: onChange, onBlur: onBlur, "data-testid": step.id, inputRef: inputRef, padding: "0px", size: "1.6rem", error: !!errors[step.id], cantEdit: !editable || postview, checkedColor: formStyle.primaryColor, uncheckedColor: formStyle.outlineColor, checked: value })] })), (step.description || !!errors[step.id]) && (_jsx("div", __assign({ className: styles.descriptionPar, style: {
58
- color: errors[step.id]
59
- ? formStyle.errorColor
60
- : formStyle.descriptionTextColor,
61
- } }, { children: errors[step.id]
62
- ? 'Este campo es obligatorio'
63
- : step.description })))] }), step.id));
64
- };
65
32
  var renderNested = function () {
66
33
  var steps = value ? step.steps : step.uncheckedSteps;
67
34
  return (_jsx(React.Fragment, { children: steps === null || steps === void 0 ? void 0 : steps.map(function (idStep) {
68
35
  var subStep = form.steps[idStep];
69
- return (_jsx(StepComponent, { editable: editable, step: subStep, level: level + 1, handleSizeChange: sizeChange }, idStep));
36
+ return (_jsx(StepComponent, { editable: editable, step: subStep }, idStep));
70
37
  }) }));
71
38
  };
72
- if (level === 0 && step.maxSize && step.maxSize < form.size.blockNum) {
73
- return (_jsxs("div", __assign({ className: styles.firstLvlContainer, style: {
74
- width: currentBreakPoint <= step.size ? '100%' : 'fit-content',
75
- } }, { children: [renderCheckbox(), renderNested(), level === 0 && step.maxSize < form.size.blockNum && (_jsx("div", { className: styles.smallSeparator, style: {
76
- width: fillerSize,
77
- } }, "SEPARATOR"))] })));
78
- }
79
- else {
80
- return (_jsxs(React.Fragment, { children: [renderCheckbox(), renderNested(), level === 0 && step.maxSize && (_jsx("div", { className: styles.separator }))] }));
81
- }
82
- }
83
- function CheckBoxStep(props) {
84
- var step = props.step;
85
- var _a = useStepDependency(step), handleStepDep = _a.handleStepDep, originalValue = _a.originalValue;
86
- var _b = useController({
87
- name: step.id,
88
- rules: {
89
- required: step.required ? 'Este campo es obligatorio' : undefined,
90
- },
91
- shouldUnregister: true,
92
- defaultValue: originalValue,
93
- }).field, ref = _b.ref, field = __rest(_b, ["ref"]);
94
- var onChange = useCallback(function (value) {
95
- handleStepDep(value);
96
- field.onChange(value);
97
- }, [handleStepDep, field]);
98
- return (_jsx(CheckBox, __assign({}, props, field, { inputRef: ref, onChange: onChange })));
39
+ return (_jsxs(StepFillerContainer, __assign({ step: step }, { children: [_jsxs(MaterialInputContainer, __assign({ step: step, editable: editable }, { children: [_jsxs("div", __assign({ className: styles.labelCheckBoxContainer }, { children: [step.label && (_jsxs("div", __assign({ className: styles.checkboxLbl }, { children: [step.label, step.required ? ' *' : '', ":"] }))), _jsx(RoundedCheckBox, __assign({}, field, { inputRef: ref, onChange: onChange, "data-testid": step.id, padding: "0px", size: "1.6rem", error: !!error, cantEdit: !editable || postview, checkedColor: formStyle.primaryColor, uncheckedColor: formStyle.outlineColor, checked: value }))] })), (step.description || !!error) && (_jsx("div", __assign({ className: styles.descriptionPar, style: {
40
+ color: error
41
+ ? formStyle.errorColor
42
+ : formStyle.descriptionTextColor,
43
+ } }, { children: error ? 'Este campo es obligatorio' : step.description })))] })), renderNested()] })));
99
44
  }
100
45
  export default CheckBoxStep;
@@ -1,14 +1,3 @@
1
- .container {
2
- width: fit-content;
3
- max-width: calc(100% - 20px);
4
- display: flex;
5
- padding: 10px;
6
- padding-bottom: 0px;
7
- padding-top: 5px;
8
- margin-bottom: 0px;
9
- flex-direction: column;
10
- }
11
-
12
1
  .checkboxLbl {
13
2
  font-size: 18px;
14
3
  margin-right: 10px;
@@ -35,20 +24,3 @@
35
24
  overflow: hidden;
36
25
  text-overflow: ellipsis;
37
26
  }
38
-
39
- .separator {
40
- flex-basis: 100%;
41
- height: 0;
42
- }
43
-
44
- .firstLvlContainer {
45
- max-width: 100%;
46
- display: flex;
47
- flex-flow: row wrap;
48
- }
49
-
50
- .smallSeparator {
51
- height: 0;
52
- max-width: 100%;
53
- flex-basis: 0;
54
- }
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { ClassifierSelectorStepProps } from '../ClassifierSelectorStep';
3
+ declare function ClassifierSelectorStep({ step, editable, }: ClassifierSelectorStepProps): JSX.Element;
3
4
  export default ClassifierSelectorStep;
4
- declare function ClassifierSelectorStep(props: ClassifierSelectorStepProps): JSX.Element;
@@ -9,120 +9,63 @@ 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, useMemo } from 'react';
25
14
  import { ClassifierOptionTypes } from '../../../constants/FormStepTypes';
26
- import styles from './MaterialClassifierSelectorStep.module.css';
27
15
  import StepComponent from '../../Step';
28
- import { useController, useFormContext } from 'react-hook-form';
29
- import { calcFillerSize, calcStepWidth } from '../../StepFunctions';
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 ClassifierSelector(_a) {
35
- var _b, _c;
36
- var step = _a.step, level = _a.level, value = _a.value, onBlur = _a.onBlur, onChange = _a.onChange, inputRef = _a.inputRef, editable = _a.editable, handleSizeChange = _a.handleSizeChange;
37
- var _d = useAppSelector(function (state) { return state.global; }), formStyle = _d.formStyle, postview = _d.postview, preview = _d.preview;
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 ClassifierSelectorStep(_a) {
23
+ var _b, _c, _d, _e;
24
+ var step = _a.step, editable = _a.editable;
25
+ var _f = useFormStep(step, {
26
+ sizeChange: true,
27
+ rules: {
28
+ required: step.required ? 'Este campo es obligatorio' : undefined,
29
+ },
30
+ }), ref = _f.ref, value = _f.value, onChange = _f.onChange, error = _f.error, field = _f.field;
31
+ var _g = useAppSelector(function (state) { return state.global; }), formStyle = _g.formStyle, postview = _g.postview, preview = _g.preview;
38
32
  var form = useContext(FormContext);
39
- var currentBreakPoint = useAppSelector(selectBreakPoint);
40
- var _e = useFormContext(), getValues = _e.getValues, errors = _e.formState.errors;
41
- var _f = useState(level === 0
42
- ? calcFillerSize(step, form.steps, getValues(), form.size)
43
- : 0), fillerSize = _f[0], setFillerSize = _f[1];
44
- if (!step.idClassifier) {
33
+ if (!step.idClassifier)
45
34
  return _jsx("div", {});
46
- }
47
35
  var classifier = (_b = form.classifiers) === null || _b === void 0 ? void 0 : _b[step.idClassifier];
48
- if (!classifier) {
36
+ if (!classifier)
49
37
  return _jsx("div", {});
50
- }
51
- var options = (_c = classifier.children) === null || _c === void 0 ? void 0 : _c.filter(function (idClassifier) {
52
- var _a, _b;
53
- return ((_a = step.options[idClassifier]) === null || _a === void 0 ? void 0 : _a.type) !==
54
- ClassifierOptionTypes.HIDE &&
55
- ((_b = form.classifiers) === null || _b === void 0 ? void 0 : _b[idClassifier]);
56
- }).map(function (idClassifier) {
57
- var _a, _b, _c;
58
- var classifier = (_a = form.classifiers) === null || _a === void 0 ? void 0 : _a[idClassifier];
59
- return {
60
- value: classifier === null || classifier === void 0 ? void 0 : classifier._id,
61
- label: ((_c = (_b = classifier === null || classifier === void 0 ? void 0 : classifier.clientName) === null || _b === void 0 ? void 0 : _b.trim) === null || _c === void 0 ? void 0 : _c.call(_b)) && preview
62
- ? classifier === null || classifier === void 0 ? void 0 : classifier.clientName
63
- : classifier === null || classifier === void 0 ? void 0 : classifier.name,
64
- };
65
- });
66
- var sizeChange = function () {
67
- handleSizeChange === null || handleSizeChange === void 0 ? void 0 : handleSizeChange();
68
- if (level === 0) {
69
- setFillerSize(calcFillerSize(step, form.steps, getValues(), form.size));
70
- }
71
- };
72
- var renderSelect = function () {
73
- var _a, _b, _c, _d;
74
- return (_jsx("div", __assign({ className: styles.container, style: {
75
- width: currentBreakPoint <= step.size
76
- ? '100%'
77
- : calcStepWidth(step.size, form.size),
78
- minHeight: step.description ||
79
- (!postview && editable && step.required)
80
- ? '55px'
81
- : '43px',
82
- }, "data-testid": step.id }, { children: _jsx(RoundedSmartSelect, { value: value, onBlur: onBlur, disabled: false, loading: false, options: options, inputRef: inputRef, cantEdit: !editable || postview, fullWidth: true, backgroundColor: (_a = formStyle.stepBackgroundColor) !== null && _a !== void 0 ? _a : 'white', label: step.label ? step.label : classifier.name, 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) {
83
- onChange(value);
84
- sizeChange();
85
- }, getOptionSelected: function (option, value) {
86
- return option.value === (value === null || value === void 0 ? void 0 : value.value);
87
- }, 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] }) }), step.id));
88
- };
38
+ var options = useMemo(function () {
39
+ var _a;
40
+ return (_a = classifier.children) === null || _a === void 0 ? void 0 : _a.filter(function (idClassifier) {
41
+ var _a, _b;
42
+ return ((_a = step.options[idClassifier]) === null || _a === void 0 ? void 0 : _a.type) !==
43
+ ClassifierOptionTypes.HIDE &&
44
+ ((_b = form.classifiers) === null || _b === void 0 ? void 0 : _b[idClassifier]);
45
+ }).map(function (idClassifier) {
46
+ var _a, _b, _c;
47
+ var classifier = (_a = form.classifiers) === null || _a === void 0 ? void 0 : _a[idClassifier];
48
+ return {
49
+ value: classifier === null || classifier === void 0 ? void 0 : classifier._id,
50
+ label: ((_c = (_b = classifier === null || classifier === void 0 ? void 0 : classifier.clientName) === null || _b === void 0 ? void 0 : _b.trim) === null || _c === void 0 ? void 0 : _c.call(_b)) && preview
51
+ ? classifier === null || classifier === void 0 ? void 0 : classifier.clientName
52
+ : classifier === null || classifier === void 0 ? void 0 : classifier.name,
53
+ };
54
+ });
55
+ }, []);
89
56
  var mapNestedOption = function () {
90
57
  if (value) {
91
58
  var currentOption = step.options[value.value];
92
59
  if ((currentOption === null || currentOption === void 0 ? void 0 : currentOption.type) === ClassifierOptionTypes.NESTED) {
93
60
  return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idStep) {
94
61
  var subStep = form.steps[idStep];
95
- return (_jsx(StepComponent, { step: subStep, level: level + 1, editable: editable, handleSizeChange: sizeChange }, idStep));
62
+ return (_jsx(StepComponent, { step: subStep, editable: editable }, idStep));
96
63
  }) }));
97
64
  }
98
65
  }
99
66
  };
100
- if (level === 0 && step.maxSize && step.maxSize < form.size.blockNum) {
101
- return (_jsxs("div", __assign({ className: styles.firstLvlContainer, style: {
102
- width: currentBreakPoint <= step.size ? '100%' : 'fit-content',
103
- } }, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize < form.size.blockNum && (_jsx("div", { className: styles.smallSeparator, style: {
104
- width: fillerSize,
105
- } }, "SEPARATOR"))] })));
106
- }
107
- else {
108
- return (_jsxs(React.Fragment, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize && (_jsx("div", { className: styles.separator }))] }));
109
- }
67
+ return (_jsxs(StepFillerContainer, __assign({ step: step }, { children: [_jsx(MaterialInputContainer, __assign({ step: step, editable: editable }, { children: _jsx(RoundedSmartSelect, __assign({}, field, { inputRef: ref, value: value, disabled: false, loading: false, options: options, cantEdit: !editable || postview, fullWidth: true, backgroundColor: (_c = formStyle.stepBackgroundColor) !== null && _c !== void 0 ? _c : 'white', label: step.label ? step.label : classifier.name, 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: onChange, getOptionSelected: function (option, value) {
68
+ return option.value === (value === null || value === void 0 ? void 0 : value.value);
69
+ }, helperText: (_e = (_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.toString()) !== null && _e !== void 0 ? _e : step.description, error: !!error })) })), mapNestedOption()] })));
110
70
  }
111
71
  export default ClassifierSelectorStep;
112
- function ClassifierSelectorStep(props) {
113
- var step = props.step;
114
- var _a = useStepDependency(step), handleStepDep = _a.handleStepDep, originalValue = _a.originalValue;
115
- var _b = useController({
116
- name: step.id,
117
- rules: {
118
- required: step.required ? 'Este campo es obligatorio' : undefined,
119
- },
120
- shouldUnregister: true,
121
- defaultValue: originalValue,
122
- }).field, ref = _b.ref, field = __rest(_b, ["ref"]);
123
- var onChange = useCallback(function (value) {
124
- handleStepDep(value);
125
- field.onChange(value);
126
- }, [handleStepDep, field]);
127
- return (_jsx(ClassifierSelector, __assign({}, props, field, { inputRef: ref, onChange: onChange })));
128
- }