@arquimedes.co/eureka-forms 1.9.134 → 2.0.0-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 (208) hide show
  1. package/dist/@Types/Form.d.ts +1 -1
  2. package/dist/@Types/FormStep.d.ts +2 -2
  3. package/dist/@Types/GenericFormSteps.d.ts +1 -0
  4. package/dist/App/App.css +6 -0
  5. package/dist/{App.d.ts → App/App.d.ts} +13 -21
  6. package/dist/App/App.js +76 -0
  7. package/dist/App/AppFunctions.d.ts +16 -0
  8. package/dist/App/AppFunctions.js +210 -0
  9. package/dist/App/AppHooks.d.ts +10 -0
  10. package/dist/App/AppHooks.js +235 -0
  11. package/dist/Contexts/CustomContext.d.ts +11 -0
  12. package/dist/Contexts/CustomContext.js +6 -0
  13. package/dist/Contexts/FormContext.d.ts +4 -0
  14. package/dist/Contexts/FormContext.js +19 -0
  15. package/dist/Contexts/SectionContext.d.ts +3 -0
  16. package/dist/Contexts/SectionContext.js +3 -0
  17. package/dist/Form/ConfirmationDialog/ConfirmationDialog.d.ts +2 -4
  18. package/dist/Form/ConfirmationDialog/ConfirmationDialog.js +3 -1
  19. package/dist/Form/Form.d.ts +17 -34
  20. package/dist/Form/Form.js +73 -124
  21. package/dist/Form/FormFunctions.d.ts +5 -4
  22. package/dist/Form/FormFunctions.js +24 -25
  23. package/dist/Form/FormTypes/ColumnForm/ColumnForm.d.ts +1 -1
  24. package/dist/Form/FormTypes/ColumnForm/ColumnForm.js +34 -58
  25. package/dist/Form/FormTypes/ColumnForm/ColumnForm.module.css +0 -4
  26. package/dist/Form/FormTypes/StepperForm/StepperForm.d.ts +1 -1
  27. package/dist/Form/FormTypes/StepperForm/StepperForm.js +122 -3
  28. package/dist/Form/FormTypes/StepperForm/StepperForm.module.css +53 -0
  29. package/dist/Form/Hooks.d.ts +9 -0
  30. package/dist/Form/Hooks.js +7 -0
  31. package/dist/Form/Section/MaterialSection/MaterialSection.d.ts +1 -1
  32. package/dist/Form/Section/MaterialSection/MaterialSection.js +15 -16
  33. package/dist/Form/Section/Section.d.ts +2 -34
  34. package/dist/Form/Section/Section.js +11 -5
  35. package/dist/Form/Terms/Term/MaterialTerm/MaterialTerm.d.ts +1 -1
  36. package/dist/Form/Terms/Term/MaterialTerm/MaterialTerm.js +19 -14
  37. package/dist/Form/Terms/Term/Term.d.ts +1 -8
  38. package/dist/Form/Terms/Term/Term.js +3 -1
  39. package/dist/Form/Terms/Terms.d.ts +1 -2
  40. package/dist/Form/Terms/Terms.js +17 -8
  41. package/dist/Form/Terms/Terms.module.css +3 -0
  42. package/dist/FormSteps/@Construction/CBRElementStep/CBRElementStep.d.ts +3 -3
  43. package/dist/FormSteps/@Construction/CBRElementStep/CBRElementStep.js +49 -38
  44. package/dist/FormSteps/@Construction/CBRIncidentsStep/CBRIncidentsStep.js +3 -1
  45. package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.d.ts +2 -2
  46. package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.js +11 -5
  47. package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +29 -27
  48. package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.module.css +0 -6
  49. package/dist/FormSteps/@Construction/CBRPropertyStep/CBRPropertyStep.js +39 -31
  50. package/dist/FormSteps/AYFStepMapper.js +42 -43
  51. package/dist/FormSteps/ApiSelectorStep/ApiSelectorStep.d.ts +1 -1
  52. package/dist/FormSteps/ApiSelectorStep/ApiSelectorStep.js +4 -14
  53. package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +84 -97
  54. package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.module.css +0 -9
  55. package/dist/FormSteps/CBRStepMapper.js +78 -74
  56. package/dist/FormSteps/CheckBoxStep/CheckBoxStep.d.ts +1 -1
  57. package/dist/FormSteps/CheckBoxStep/CheckBoxStep.js +4 -14
  58. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +33 -26
  59. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +17 -0
  60. package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.d.ts +1 -1
  61. package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.js +4 -14
  62. package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +34 -27
  63. package/dist/FormSteps/CollapsibleStep/CollapsibleStep.d.ts +1 -1
  64. package/dist/FormSteps/CollapsibleStep/CollapsibleStep.js +4 -2
  65. package/dist/FormSteps/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.js +16 -11
  66. package/dist/FormSteps/CustomStep.d.ts +23 -0
  67. package/dist/FormSteps/CustomStep.js +37 -0
  68. package/dist/FormSteps/DatePickerStep/DatePickerStep.js +3 -1
  69. package/dist/FormSteps/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.d.ts +1 -1
  70. package/dist/FormSteps/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +26 -14
  71. package/dist/FormSteps/EntityValueStep/EntityValuePickerStep.d.ts +1 -1
  72. package/dist/FormSteps/EntityValueStep/EntityValuePickerStep.js +4 -14
  73. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +93 -112
  74. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.module.css +0 -9
  75. package/dist/FormSteps/FileUploadStep/FileUploadStep.js +3 -1
  76. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.d.ts +1 -1
  77. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.js +1 -1
  78. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.module.css +0 -7
  79. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +32 -18
  80. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.module.css +0 -7
  81. package/dist/FormSteps/MapperStep/MapperStep.d.ts +2 -2
  82. package/dist/FormSteps/MapperStep/MapperStep.js +4 -14
  83. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/ListMapperElement/ListMapperElement.d.ts +1 -9
  84. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/ListMapperElement/ListMapperElement.js +7 -2
  85. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElement.d.ts +3 -2
  86. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElement.js +18 -10
  87. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.d.ts +1 -9
  88. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.js +7 -2
  89. package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.d.ts +1 -1
  90. package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.js +44 -228
  91. package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.module.css +0 -7
  92. package/dist/FormSteps/RatingStep/MaterialRatingStep/MaterialRatingStep.js +30 -14
  93. package/dist/FormSteps/RatingStep/RatingStep.js +3 -1
  94. package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +36 -26
  95. package/dist/FormSteps/SelectorStep/SelectorStep.d.ts +1 -1
  96. package/dist/FormSteps/SelectorStep/SelectorStep.js +4 -14
  97. package/dist/FormSteps/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.d.ts +1 -1
  98. package/dist/FormSteps/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.js +3 -1
  99. package/dist/FormSteps/SeparatorStep/SeparatorStep.d.ts +1 -1
  100. package/dist/FormSteps/SeparatorStep/SeparatorStep.js +4 -14
  101. package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.d.ts +5 -2
  102. package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +119 -199
  103. package/dist/FormSteps/SmartSelectStep/SmartSelectStep.d.ts +9 -10
  104. package/dist/FormSteps/SmartSelectStep/SmartSelectStep.js +3 -1
  105. package/dist/FormSteps/Step.d.ts +3 -4
  106. package/dist/FormSteps/Step.js +12 -8
  107. package/dist/FormSteps/StepFunctions.d.ts +10 -0
  108. package/dist/FormSteps/StepFunctions.js +156 -1
  109. package/dist/FormSteps/StepHooks.d.ts +23 -0
  110. package/dist/FormSteps/StepHooks.js +87 -0
  111. package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaEditorStep.d.ts +10 -0
  112. package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaEditorStep.js +148 -0
  113. package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.d.ts +1 -6
  114. package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +40 -186
  115. package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.module.css +0 -9
  116. package/dist/FormSteps/TextAreaStep/TextAreaStep.js +8 -2
  117. package/dist/FormSteps/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.d.ts +1 -1
  118. package/dist/FormSteps/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +43 -42
  119. package/dist/FormSteps/TextInputStep/TextInputStep.js +3 -1
  120. package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +11 -6
  121. package/dist/FormSteps/TitleStep/TitleStep.d.ts +1 -1
  122. package/dist/FormSteps/TitleStep/TitleStep.js +4 -14
  123. package/dist/Icons/Construction/LeakIcon.d.ts +2 -2
  124. package/dist/Icons/Construction/LeakIcon.js +2 -1
  125. package/dist/Icons/Construction/ProjectIcon.d.ts +2 -2
  126. package/dist/Icons/Construction/ProjectIcon.js +2 -1
  127. package/dist/Icons/Construction/PropertyIcon.d.ts +2 -2
  128. package/dist/Icons/Construction/PropertyIcon.js +2 -1
  129. package/dist/Icons/Construction/SpaceIcon.d.ts +2 -2
  130. package/dist/Icons/Construction/SpaceIcon.js +2 -1
  131. package/dist/Icons/DocumentIcon.d.ts +2 -2
  132. package/dist/Icons/DocumentIcon.js +2 -1
  133. package/dist/Icons/Entities/CheckListIcon.d.ts +2 -2
  134. package/dist/Icons/Entities/CheckListIcon.js +2 -1
  135. package/dist/Icons/Entities/GenericEntityIcon.d.ts +2 -1
  136. package/dist/Icons/Entities/GenericEntityIcon.js +1 -1
  137. package/dist/Icons/Entities/HandshakeIcon.d.ts +2 -1
  138. package/dist/Icons/Entities/HandshakeIcon.js +1 -1
  139. package/dist/Icons/Entities/SupplierIcon.d.ts +2 -1
  140. package/dist/Icons/Entities/SupplierIcon.js +4 -1
  141. package/dist/{controllers → Services}/FileService.d.ts +1 -1
  142. package/dist/{controllers → Services}/FileService.js +5 -5
  143. package/dist/Services/FormService.d.ts +5 -0
  144. package/dist/Services/FormService.js +59 -0
  145. package/dist/Services/OrganizationService.d.ts +2 -0
  146. package/dist/Services/OrganizationService.js +65 -0
  147. package/dist/Shared/Navbar/Navbar.module.css +8 -0
  148. package/dist/{shared → Shared}/Rating/Rating.d.ts +1 -1
  149. package/dist/Shared/Rating/Rating.module.css +18 -0
  150. package/dist/{shared → Shared}/Rating/Ratings/LikeRating.js +5 -5
  151. package/dist/{shared → Shared}/Rating/Ratings/SatisfactionRating.js +9 -9
  152. package/dist/{shared → Shared}/Rating/Ratings/ScaleRating.js +1 -2
  153. package/dist/{shared → Shared}/RoundedCheckBox/RoundedCheckBox.d.ts +1 -1
  154. package/dist/{shared → Shared}/RoundedSmartSelect/RoundedSmartSelect.js +4 -4
  155. package/dist/{shared → Shared}/RoundedTextField/RoundedTextField.d.ts +1 -1
  156. package/dist/{shared → Shared}/RoundedTextField/RoundedTextField.js +3 -2
  157. package/dist/Shared/RoundedTextField/RoundedTextField.stories.d.ts +24 -0
  158. package/dist/Shared/RoundedTextField/RoundedTextField.stories.js +25 -0
  159. package/dist/States/GlobalStateReducer.d.ts +35 -0
  160. package/dist/States/GlobalStateReducer.js +34 -0
  161. package/dist/States/SiteStateReducer.d.ts +63 -0
  162. package/dist/States/SiteStateReducer.js +110 -0
  163. package/dist/States/WidthStatsStateReducer.d.ts +11 -0
  164. package/dist/States/WidthStatsStateReducer.js +64 -0
  165. package/dist/Utils/DraftFunctions.d.ts +3 -0
  166. package/dist/Utils/DraftFunctions.js +42 -0
  167. package/dist/Utils/MaterialProviders.d.ts +6 -0
  168. package/dist/Utils/MaterialProviders.js +31 -0
  169. package/dist/Utils/store.d.ts +25 -0
  170. package/dist/Utils/store.js +52 -0
  171. package/dist/Widget.js +3 -3
  172. package/dist/constants/CBRFormStepTypes.d.ts +2 -2
  173. package/dist/constants/CBRFormStepTypes.js +22 -22
  174. package/dist/hooks.d.ts +5 -0
  175. package/dist/hooks.js +7 -0
  176. package/dist/index.js +1 -1
  177. package/dist/index.lib.d.ts +1 -1
  178. package/dist/index.lib.js +1 -1
  179. package/package.json +63 -44
  180. package/dist/App.js +0 -472
  181. package/dist/shared/Navbar/Navbar.module.css +0 -18
  182. package/dist/shared/Rating/Rating.module.css +0 -32
  183. package/dist/{App.module.css → App/App.module.css} +0 -0
  184. package/dist/{shared → Shared}/InputIcon/InputIcon.d.ts +0 -0
  185. package/dist/{shared → Shared}/InputIcon/InputIcon.js +0 -0
  186. package/dist/{shared → Shared}/Loader/Loader.d.ts +0 -0
  187. package/dist/{shared → Shared}/Loader/Loader.js +0 -0
  188. package/dist/{shared → Shared}/Loader/Loader.module.css +0 -0
  189. package/dist/{shared → Shared}/Navbar/Navbar.d.ts +0 -0
  190. package/dist/{shared → Shared}/Navbar/Navbar.js +0 -0
  191. package/dist/{shared → Shared}/Rating/Rating.js +2 -2
  192. /package/dist/{shared → Shared}/Rating/Ratings/LikeRating.d.ts +0 -0
  193. /package/dist/{shared → Shared}/Rating/Ratings/SatisfactionRating.d.ts +0 -0
  194. /package/dist/{shared → Shared}/Rating/Ratings/ScaleRating.d.ts +0 -0
  195. /package/dist/{shared → Shared}/RoundedButton/RoundedButton.d.ts +0 -0
  196. /package/dist/{shared → Shared}/RoundedButton/RoundedButton.js +0 -0
  197. /package/dist/{shared → Shared}/RoundedCheckBox/RoundedCheckBox.js +0 -0
  198. /package/dist/{shared → Shared}/RoundedDatePicker/RoundedDatePicker.d.ts +0 -0
  199. /package/dist/{shared → Shared}/RoundedDatePicker/RoundedDatePicker.js +0 -0
  200. /package/dist/{shared → Shared}/RoundedSelect/RoundedSelect.d.ts +0 -0
  201. /package/dist/{shared → Shared}/RoundedSelect/RoundedSelect.js +0 -0
  202. /package/dist/{shared → Shared}/RoundedSmartSelect/RoundedSmartSelect.d.ts +0 -0
  203. /package/dist/{AxiosAPI.d.ts → Utils/AxiosAPI.d.ts} +0 -0
  204. /package/dist/{AxiosAPI.js → Utils/AxiosAPI.js} +0 -0
  205. /package/dist/{AxiosWidget.d.ts → Utils/AxiosWidget.d.ts} +0 -0
  206. /package/dist/{AxiosWidget.js → Utils/AxiosWidget.js} +0 -0
  207. /package/dist/{utils/CbrFunctions.d.ts → Utils/CBRFunctions.d.ts} +0 -0
  208. /package/dist/{utils/CbrFunctions.js → Utils/CBRFunctions.js} +0 -0
@@ -56,21 +56,25 @@ var __rest = (this && this.__rest) || function (s, e) {
56
56
  }
57
57
  return t;
58
58
  };
59
- import { createElement as _createElement } from "react";
60
59
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
61
- import React, { useEffect, useState } from 'react';
60
+ import React, { useCallback, useContext, useState } from 'react';
62
61
  import FormStepTypes, { ApiSelectorOptionTypes, ApiSelectorParamTypes, } from '../../../constants/FormStepTypes';
63
62
  import styles from './MaterialApiSelectorStep.module.css';
64
63
  import StepComponent from '../../Step';
65
- import { Controller } from 'react-hook-form';
64
+ import { useController, useFormContext } from 'react-hook-form';
66
65
  import { calcFillerSize } from '../../StepFunctions';
67
66
  import { SmartSelect } from '../../SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep';
68
- import widgetInstance from '../../../AxiosWidget';
69
- import axiosInstance from '../../../AxiosAPI';
70
- import InputIcon from '../../../shared/InputIcon/InputIcon';
71
- function ApiSelector(_a) {
72
- var _this = this;
73
- var step = _a.step, form = _a.form, level = _a.level, value = _a.value, control = _a.control, editable = _a.editable, postview = _a.postview, inputRef = _a.inputRef, getValues = _a.getValues, widthStats = _a.widthStats, handleSizeChange = _a.handleSizeChange, others = __rest(_a, ["step", "form", "level", "value", "control", "editable", "postview", "inputRef", "getValues", "widthStats", "handleSizeChange"]);
67
+ import widgetInstance from '../../../Utils/AxiosWidget';
68
+ import axiosInstance from '../../../Utils/AxiosAPI';
69
+ import InputIcon from '../../../Shared/InputIcon/InputIcon';
70
+ import FormContext from '../../../Contexts/FormContext';
71
+ import { selectBreakPoint, useAppSelector } from '../../../hooks';
72
+ import { useStepDependency } from '../../StepHooks';
73
+ 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"]);
75
+ var form = useContext(FormContext);
76
+ var currentBreakPoint = useAppSelector(selectBreakPoint);
77
+ var getValues = useFormContext().getValues;
74
78
  var _b = useState(level === 0
75
79
  ? calcFillerSize(step, form.steps, getValues(), form.size)
76
80
  : 0), fillerSize = _b[0], setFillerSize = _b[1];
@@ -82,57 +86,6 @@ function ApiSelector(_a) {
82
86
  var _a;
83
87
  return (_a = option === null || option === void 0 ? void 0 : option[step.labelAttribute]) !== null && _a !== void 0 ? _a : '';
84
88
  }
85
- var getApiOptions = function (_a, _step, dependencyStore, domain) {
86
- var idOrganization = _a.idOrganization;
87
- return __awaiter(_this, void 0, void 0, function () {
88
- var params, _i, _b, filter, currentValue, url, response;
89
- var _c, _d;
90
- return __generator(this, function (_e) {
91
- switch (_e.label) {
92
- case 0:
93
- params = new URLSearchParams({});
94
- for (_i = 0, _b = step.queryParams; _i < _b.length; _i++) {
95
- filter = _b[_i];
96
- switch (filter.type) {
97
- case ApiSelectorParamTypes.STEP:
98
- currentValue = (_c = dependencyStore[filter.idStep]) === null || _c === void 0 ? void 0 : _c.value;
99
- if (currentValue) {
100
- if (typeof currentValue === 'string')
101
- params.set(filter.key, currentValue);
102
- else
103
- params.set(filter.key, (_d = currentValue.label) !== null && _d !== void 0 ? _d : currentValue.id);
104
- }
105
- else if (filter.required) {
106
- return [2 /*return*/, null];
107
- }
108
- break;
109
- case ApiSelectorParamTypes.VALUE:
110
- default:
111
- params.set(filter.key, filter.value);
112
- break;
113
- }
114
- }
115
- url = step.url.replace('capta.co', process.env.REACT_APP_DOMAIN);
116
- if (domain && url.includes(process.env.REACT_APP_DOMAIN))
117
- params.set('idOrganization', idOrganization);
118
- if (!step.url.includes('?'))
119
- url += '?';
120
- url += params.toString();
121
- return [4 /*yield*/, (domain
122
- ? widgetInstance.get(url)
123
- : axiosInstance.get(url))];
124
- case 1:
125
- response = _e.sent();
126
- return [2 /*return*/, response.data.filter(function (option) {
127
- var _a;
128
- return calcOptionId(option) &&
129
- ((_a = step.options[calcOptionId(option)]) === null || _a === void 0 ? void 0 : _a.type) !==
130
- ApiSelectorOptionTypes.HIDE;
131
- })];
132
- }
133
- });
134
- });
135
- };
136
89
  var sizeChange = function () {
137
90
  handleSizeChange === null || handleSizeChange === void 0 ? void 0 : handleSizeChange();
138
91
  if (level === 0) {
@@ -140,7 +93,7 @@ function ApiSelector(_a) {
140
93
  }
141
94
  };
142
95
  var renderSelect = function () {
143
- return (_jsx(SmartSelect, __assign({}, others, { form: form, level: level, control: control, postview: postview, getValues: getValues, widthStats: widthStats, value: value, inputRef: inputRef, editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getApiOptions, getOptionSelected: function (option, value) {
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) {
144
97
  return calcOptionId(option) === calcOptionId(value);
145
98
  }, calcDepError: function (steps) {
146
99
  for (var _i = 0, steps_1 = steps; _i < steps_1.length; _i++) {
@@ -158,18 +111,14 @@ function ApiSelector(_a) {
158
111
  if ((currentOption === null || currentOption === void 0 ? void 0 : currentOption.type) === ApiSelectorOptionTypes.NESTED) {
159
112
  return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idStep) {
160
113
  var subStep = form.steps[idStep];
161
- return (_createElement(StepComponent, __assign({}, others, { postview: postview, editable: editable, widthStats: widthStats, getValues: getValues, form: form, control: control, step: subStep, key: idStep, level: level + 1, handleSizeChange: function () {
162
- sizeChange();
163
- } })));
114
+ return (_jsx(StepComponent, { editable: editable, step: subStep, level: level + 1, handleSizeChange: sizeChange }, idStep));
164
115
  }) }));
165
116
  }
166
117
  }
167
118
  };
168
119
  if (level === 0 && step.maxSize && step.maxSize < form.size.blockNum) {
169
120
  return (_jsxs("div", __assign({ className: styles.firstLvlContainer, style: {
170
- width: widthStats.currentBreakPoint <= step.size
171
- ? '100%'
172
- : 'fit-content',
121
+ width: currentBreakPoint <= step.size ? '100%' : 'fit-content',
173
122
  } }, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize < form.size.blockNum && (_jsx("div", { className: styles.smallSeparator, style: {
174
123
  width: fillerSize,
175
124
  } }, "SEPARATOR"))] })));
@@ -180,34 +129,72 @@ function ApiSelector(_a) {
180
129
  }
181
130
  export default ApiSelectorStep;
182
131
  function ApiSelectorStep(props) {
183
- var _a, _b;
184
- var step = props.step, dependencyStore = props.dependencyStore, defaultValue = props.defaultValue, originalValues = props.originalValues;
185
- useEffect(function () {
186
- /** Al modificar tambien modificar en SmartSelect */
187
- if (!originalValues[step.id] && defaultValue) {
188
- props.setDependencyStore(function (dependencies) {
189
- var _a;
190
- return (__assign(__assign({}, dependencies), (_a = {}, _a[step.id] = { type: step.type, value: props.defaultValue }, _a)));
191
- });
192
- }
193
- }, []);
194
- 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: {
195
- required: props.step.required
196
- ? 'Este campo es obligatorio'
197
- : undefined,
198
- }, shouldUnregister: true, render: function (_a) {
199
- var _b = _a.field, ref = _b.ref, field = __rest(_b, ["ref"]);
200
- return (_jsx(ApiSelector, __assign({}, props, field, { inputRef: ref, onChange: function (value) {
201
- if (dependencyStore[step.id] !== undefined) {
202
- props.setDependencyStore(function (dependencies) {
203
- var _a;
204
- return (__assign(__assign({}, dependencies), (_a = {}, _a[step.id] = {
205
- type: step.type,
206
- value: value !== null && value !== void 0 ? value : null,
207
- }, _a)));
208
- });
209
- }
210
- field.onChange(value);
211
- } })));
212
- } }));
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 })));
213
147
  }
148
+ var getApiOptions = function (idOrganization, step, dependencyStore) { return __awaiter(void 0, void 0, void 0, function () {
149
+ function calcOptionId(option) {
150
+ var _a;
151
+ return (_a = option === null || option === void 0 ? void 0 : option[step.idAttribute]) !== null && _a !== void 0 ? _a : '';
152
+ }
153
+ var params, _i, _a, filter, currentValue, url, response;
154
+ var _b, _c;
155
+ return __generator(this, function (_d) {
156
+ switch (_d.label) {
157
+ case 0:
158
+ params = new URLSearchParams({});
159
+ for (_i = 0, _a = step.queryParams; _i < _a.length; _i++) {
160
+ filter = _a[_i];
161
+ switch (filter.type) {
162
+ case ApiSelectorParamTypes.STEP: {
163
+ currentValue = (_b = dependencyStore[filter.idStep]) === null || _b === void 0 ? void 0 : _b.value;
164
+ if (currentValue) {
165
+ if (typeof currentValue === 'string')
166
+ params.set(filter.key, currentValue);
167
+ else
168
+ params.set(filter.key, (_c = currentValue.label) !== null && _c !== void 0 ? _c : currentValue.id);
169
+ }
170
+ else if (filter.required) {
171
+ return [2 /*return*/, null];
172
+ }
173
+ break;
174
+ }
175
+ case ApiSelectorParamTypes.VALUE:
176
+ default:
177
+ params.set(filter.key, filter.value);
178
+ break;
179
+ }
180
+ }
181
+ url = step.url.replace('capta.co', process.env.REACT_APP_DOMAIN);
182
+ if (idOrganization && url.includes(process.env.REACT_APP_DOMAIN))
183
+ params.set('idOrganization', idOrganization);
184
+ if (!step.url.includes('?'))
185
+ url += '?';
186
+ url += params.toString();
187
+ return [4 /*yield*/, (idOrganization
188
+ ? widgetInstance.get(url)
189
+ : axiosInstance.get(url))];
190
+ case 1:
191
+ response = _d.sent();
192
+ return [2 /*return*/, response.data.filter(function (option) {
193
+ var _a;
194
+ return calcOptionId(option) &&
195
+ ((_a = step.options[calcOptionId(option)]) === null || _a === void 0 ? void 0 : _a.type) !==
196
+ ApiSelectorOptionTypes.HIDE;
197
+ })];
198
+ }
199
+ });
200
+ }); };
@@ -1,12 +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
- }
10
1
  .separator {
11
2
  flex-basis: 100%;
12
3
  height: 0;
@@ -55,91 +55,95 @@ import CBRIncidentsStep from './@Construction/CBRIncidentsStep/CBRIncidentsStep'
55
55
  import CBRElementStep from './@Construction/CBRElementStep/CBRElementStep';
56
56
  import axios from 'axios';
57
57
  import CBRPropertyStep from './@Construction/CBRPropertyStep/CBRPropertyStep';
58
- import InputIcon from '../shared/InputIcon/InputIcon';
58
+ import InputIcon from '../Shared/InputIcon/InputIcon';
59
59
  var baseUrl = "https://integrations.".concat(process.env.REACT_APP_DOMAIN, "/sinco/cbr/");
60
60
  function CBRStepMapper(props) {
61
61
  var _this = this;
62
- var getTipoDocOptions = function (_a) {
63
- var idOrganization = _a.idOrganization;
64
- return __awaiter(_this, void 0, void 0, function () {
65
- return __generator(this, function (_b) {
66
- switch (_b.label) {
67
- case 0: return [4 /*yield*/, axios.get(baseUrl + 'TiposDoc?idOrganization=' + idOrganization)];
68
- case 1: return [2 /*return*/, (_b.sent()).data];
69
- }
70
- });
62
+ var getTipoDocOptions = function (idOrganization) { return __awaiter(_this, void 0, void 0, function () {
63
+ return __generator(this, function (_a) {
64
+ switch (_a.label) {
65
+ case 0:
66
+ if (!idOrganization)
67
+ return [2 /*return*/, null];
68
+ return [4 /*yield*/, axios.get(baseUrl + 'TiposDoc?idOrganization=' + idOrganization)];
69
+ case 1: return [2 /*return*/, (_a.sent()).data];
70
+ }
71
71
  });
72
- };
73
- var getProyectoOptions = function (_a, step, dependencyStore) {
74
- var idOrganization = _a.idOrganization;
75
- return __awaiter(_this, void 0, void 0, function () {
76
- var idMacroProyecto, proyectos;
77
- var _b, _c, _d, _e;
78
- return __generator(this, function (_f) {
79
- switch (_f.label) {
80
- case 0:
81
- idMacroProyecto = (_e = (_d = dependencyStore[(_c = (_b = step.dependencies) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : '']) === null || _d === void 0 ? void 0 : _d.value) === null || _e === void 0 ? void 0 : _e.id;
82
- return [4 /*yield*/, axios.get(baseUrl + 'Proyectos?idOrganization=' + idOrganization)];
83
- case 1:
84
- proyectos = (_f.sent()).data;
85
- if (idMacroProyecto) {
86
- proyectos = proyectos.filter(function (proyecto) { return proyecto.idMacroProyecto === idMacroProyecto; });
87
- }
88
- return [2 /*return*/, proyectos];
89
- }
90
- });
72
+ }); };
73
+ var getProyectoOptions = function (idOrganization, step, dependencyStore) { return __awaiter(_this, void 0, void 0, function () {
74
+ var idMacroProyecto, proyectos;
75
+ var _a, _b, _c, _d;
76
+ return __generator(this, function (_e) {
77
+ switch (_e.label) {
78
+ case 0:
79
+ if (!idOrganization)
80
+ return [2 /*return*/, null];
81
+ idMacroProyecto = (_d = (_c = dependencyStore[(_b = (_a = step.dependencies) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '']) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.id;
82
+ return [4 /*yield*/, axios.get(baseUrl + 'Proyectos?idOrganization=' + idOrganization)];
83
+ case 1:
84
+ proyectos = (_e.sent()).data;
85
+ if (idMacroProyecto) {
86
+ proyectos = proyectos.filter(function (proyecto) { return proyecto.idMacroProyecto === idMacroProyecto; });
87
+ }
88
+ return [2 /*return*/, proyectos];
89
+ }
91
90
  });
92
- };
93
- var getMacroProyectoOptions = function (_a) {
94
- var idOrganization = _a.idOrganization;
95
- return __awaiter(_this, void 0, void 0, function () {
96
- return __generator(this, function (_b) {
97
- switch (_b.label) {
98
- case 0: return [4 /*yield*/, axios.get(baseUrl + 'MacroProyectos?idOrganization=' + idOrganization)];
99
- case 1: return [2 /*return*/, (_b.sent()).data];
100
- }
101
- });
91
+ }); };
92
+ var getMacroProyectoOptions = function (idOrganization) { return __awaiter(_this, void 0, void 0, function () {
93
+ return __generator(this, function (_a) {
94
+ switch (_a.label) {
95
+ case 0:
96
+ if (!idOrganization)
97
+ return [2 /*return*/, null];
98
+ return [4 /*yield*/, axios.get(baseUrl + 'MacroProyectos?idOrganization=' + idOrganization)];
99
+ case 1: return [2 /*return*/, (_a.sent()).data];
100
+ }
102
101
  });
103
- };
104
- var getTipoSolicitanteOptions = function (_a) {
105
- var idOrganization = _a.idOrganization;
106
- return __awaiter(_this, void 0, void 0, function () {
107
- return __generator(this, function (_b) {
108
- switch (_b.label) {
109
- case 0: return [4 /*yield*/, axios.get(baseUrl + 'TiposSolicitante?idOrganization=' + idOrganization)];
110
- case 1: return [2 /*return*/, (_b.sent()).data];
111
- }
112
- });
102
+ }); };
103
+ var getTipoSolicitanteOptions = function (idOrganization) { return __awaiter(_this, void 0, void 0, function () {
104
+ return __generator(this, function (_a) {
105
+ switch (_a.label) {
106
+ case 0:
107
+ if (!idOrganization)
108
+ return [2 /*return*/, null];
109
+ return [4 /*yield*/, axios.get(baseUrl + 'TiposSolicitante?idOrganization=' + idOrganization)];
110
+ case 1: return [2 /*return*/, (_a.sent()).data];
111
+ }
113
112
  });
114
- };
115
- var getTipoEspaciosOptions = function (_a, step, dependencyStore) {
116
- var idOrganization = _a.idOrganization;
117
- return __awaiter(_this, void 0, void 0, function () {
118
- var idProyecto;
119
- var _b, _c;
120
- return __generator(this, function (_d) {
121
- switch (_d.label) {
122
- case 0:
123
- if (!step.dependencies) return [3 /*break*/, 2];
124
- idProyecto = (_c = (_b = dependencyStore[step.dependencies[0]]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.id;
125
- if (!idProyecto) {
126
- return [2 /*return*/, null]; //null para indicar que falta la depedency
127
- }
128
- return [4 /*yield*/, axios.get(baseUrl +
129
- 'TiposEspacio?idProyecto=' +
130
- idProyecto +
131
- '&idOrganization=' +
132
- idOrganization)];
133
- case 1: return [2 /*return*/, (_d.sent()).data];
134
- case 2: return [2 /*return*/, null];
135
- }
136
- });
113
+ }); };
114
+ var getTipoEspaciosOptions = function (idOrganization, step, dependencyStore) { return __awaiter(_this, void 0, void 0, function () {
115
+ var idProyecto, params;
116
+ var _a, _b;
117
+ return __generator(this, function (_c) {
118
+ switch (_c.label) {
119
+ case 0:
120
+ if (!(step.dependencies && idOrganization)) return [3 /*break*/, 2];
121
+ idProyecto = (_b = (_a = dependencyStore[step.dependencies[0]]) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.id;
122
+ if (!idProyecto) {
123
+ return [2 /*return*/, null]; //null para indicar que falta la depedency
124
+ }
125
+ params = new URLSearchParams({ idProyecto: idProyecto, idOrganization: idOrganization });
126
+ return [4 /*yield*/, axios.get(baseUrl + 'TiposEspacio?' + params.toString())];
127
+ case 1: return [2 /*return*/, (_c.sent()).data];
128
+ case 2: return [2 /*return*/, null];
129
+ }
137
130
  });
138
- };
131
+ }); };
139
132
  switch (props.step.type) {
140
- case CBRFormStepTypes.CBR_CEL:
141
133
  case CBRFormStepTypes.CBR_EMAIL:
134
+ return (_jsx(TextInputStep, __assign({}, props, { step: props.step, validation: {
135
+ type: 'EMAIL',
136
+ value: /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
137
+ .source,
138
+ message: 'El correo no es válido',
139
+ } })));
140
+ case CBRFormStepTypes.CBR_CEL:
142
141
  case CBRFormStepTypes.CBR_PHONE:
142
+ return (_jsx(TextInputStep, __assign({}, props, { step: props.step, validation: {
143
+ type: 'OTHER',
144
+ value: /^(\+[0-9])|([0-9])$/.source,
145
+ message: 'El teléfono no es válido',
146
+ } })));
143
147
  case CBRFormStepTypes.CBR_LAST_NAME:
144
148
  case CBRFormStepTypes.CBR_FIRST_NAME:
145
149
  case CBRFormStepTypes.CBR_MIDDLE_NAME:
@@ -5,5 +5,5 @@ export interface CheckBoxStepProps extends StepProps {
5
5
  /** The CheckboxStep to display */
6
6
  step: CheckBox;
7
7
  }
8
- declare function CheckboxStep({ formStyle, ...others }: CheckBoxStepProps): JSX.Element;
8
+ declare function CheckboxStep(props: CheckBoxStepProps): JSX.Element;
9
9
  export default CheckboxStep;
@@ -9,26 +9,16 @@ 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
13
  import { FormStyleTypes } from '../../constants/FormStepTypes';
25
14
  import MaterialCheckBoxStep from './MaterialCheckBoxStep/MaterialCheckBoxStep';
26
- function CheckboxStep(_a) {
27
- var formStyle = _a.formStyle, others = __rest(_a, ["formStyle"]);
15
+ import { useAppSelector } from '../../hooks';
16
+ function CheckboxStep(props) {
17
+ var formStyle = useAppSelector(function (state) { return state.global; }).formStyle;
28
18
  switch (formStyle.type) {
29
19
  case FormStyleTypes.MATERIAL:
30
20
  default: {
31
- return _jsx(MaterialCheckBoxStep, __assign({ formStyle: formStyle }, others));
21
+ return _jsx(MaterialCheckBoxStep, __assign({}, props));
32
22
  }
33
23
  }
34
24
  }
@@ -20,20 +20,25 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  }
21
21
  return t;
22
22
  };
23
- import { createElement as _createElement } from "react";
24
23
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
25
24
  import styles from './MaterialCheckBoxStep.module.css';
26
25
  import { calcFillerSize, calcStepWidth } from '../../StepFunctions';
27
- import RoundedCheckBox from '../../../shared/RoundedCheckBox/RoundedCheckBox';
28
- import { Controller } from 'react-hook-form';
29
- import React, { useState } from 'react';
26
+ import RoundedCheckBox from '../../../Shared/RoundedCheckBox/RoundedCheckBox';
27
+ import { useController, useFormContext } from 'react-hook-form';
28
+ import React, { useCallback, useContext, useState } from 'react';
30
29
  import StepComponent from '../../Step';
30
+ import FormContext from '../../../Contexts/FormContext';
31
+ import { selectBreakPoint, useAppSelector } from '../../../hooks';
32
+ import { useStepDependency } from '../../StepHooks';
31
33
  function CheckBox(_a) {
32
- var step = _a.step, form = _a.form, value = _a.value, onBlur = _a.onBlur, errors = _a.errors, level = _a.level, onChange = _a.onChange, inputRef = _a.inputRef, editable = _a.editable, postview = _a.postview, getValues = _a.getValues, formStyle = _a.formStyle, widthStats = _a.widthStats, others = __rest(_a, ["step", "form", "value", "onBlur", "errors", "level", "onChange", "inputRef", "editable", "postview", "getValues", "formStyle", "widthStats"]);
33
- var handleSizeChange = others.handleSizeChange;
34
- var _b = useState(level === 0
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;
36
+ 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
35
40
  ? calcFillerSize(step, form.steps, getValues(), form.size)
36
- : 0), fillerSize = _b[0], setFillerSize = _b[1];
41
+ : 0), fillerSize = _d[0], setFillerSize = _d[1];
37
42
  var sizeChange = function () {
38
43
  handleSizeChange === null || handleSizeChange === void 0 ? void 0 : handleSizeChange();
39
44
  if (level === 0) {
@@ -42,7 +47,7 @@ function CheckBox(_a) {
42
47
  };
43
48
  var renderCheckbox = function () {
44
49
  return (_jsxs("div", __assign({ className: styles.container, style: {
45
- width: widthStats.currentBreakPoint <= step.size
50
+ width: currentBreakPoint <= step.size
46
51
  ? '100%'
47
52
  : calcStepWidth(step.size, form.size),
48
53
  minHeight: step.description ||
@@ -50,10 +55,10 @@ function CheckBox(_a) {
50
55
  ? '55px'
51
56
  : '43px',
52
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: {
53
- color: !!errors[step.id]
58
+ color: errors[step.id]
54
59
  ? formStyle.errorColor
55
60
  : formStyle.descriptionTextColor,
56
- } }, { children: !!errors[step.id]
61
+ } }, { children: errors[step.id]
57
62
  ? 'Este campo es obligatorio'
58
63
  : step.description })))] }), step.id));
59
64
  };
@@ -61,16 +66,12 @@ function CheckBox(_a) {
61
66
  var steps = value ? step.steps : step.uncheckedSteps;
62
67
  return (_jsx(React.Fragment, { children: steps === null || steps === void 0 ? void 0 : steps.map(function (idStep) {
63
68
  var subStep = form.steps[idStep];
64
- return (_createElement(StepComponent, __assign({}, others, { postview: postview, editable: editable, widthStats: widthStats, getValues: getValues, formStyle: formStyle, errors: errors, form: form, step: subStep, key: idStep, level: level + 1, handleSizeChange: function () {
65
- sizeChange();
66
- } })));
69
+ return (_jsx(StepComponent, { editable: editable, step: subStep, level: level + 1, handleSizeChange: sizeChange }, idStep));
67
70
  }) }));
68
71
  };
69
72
  if (level === 0 && step.maxSize && step.maxSize < form.size.blockNum) {
70
73
  return (_jsxs("div", __assign({ className: styles.firstLvlContainer, style: {
71
- width: widthStats.currentBreakPoint <= step.size
72
- ? '100%'
73
- : 'fit-content',
74
+ width: currentBreakPoint <= step.size ? '100%' : 'fit-content',
74
75
  } }, { children: [renderCheckbox(), renderNested(), level === 0 && step.maxSize < form.size.blockNum && (_jsx("div", { className: styles.smallSeparator, style: {
75
76
  width: fillerSize,
76
77
  } }, "SEPARATOR"))] })));
@@ -80,14 +81,20 @@ function CheckBox(_a) {
80
81
  }
81
82
  }
82
83
  function CheckBoxStep(props) {
83
- var _a, _b;
84
- return (_jsx(Controller, { name: props.step.id, control: props.control, defaultValue: (_b = (_a = props.originalValues[props.step.id]) !== null && _a !== void 0 ? _a : props.step.defaultValue) !== null && _b !== void 0 ? _b : false, rules: {
85
- required: props.step.required
86
- ? 'Este campo es obligatorio'
87
- : undefined,
88
- }, shouldUnregister: true, render: function (_a) {
89
- var _b = _a.field, ref = _b.ref, field = __rest(_b, ["ref"]);
90
- return (_jsx(CheckBox, __assign({}, props, field, { inputRef: ref })));
91
- } }));
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 })));
92
99
  }
93
100
  export default CheckBoxStep;
@@ -35,3 +35,20 @@
35
35
  overflow: hidden;
36
36
  text-overflow: ellipsis;
37
37
  }
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
+ }
@@ -5,5 +5,5 @@ export interface ClassifierSelectorStepProps extends StepProps {
5
5
  /** The ClassifierSelectorStep to display */
6
6
  step: ClassifierSelector;
7
7
  }
8
- declare function ClassifierSelectorStep({ formStyle, ...others }: ClassifierSelectorStepProps): JSX.Element;
8
+ declare function ClassifierSelectorStep(props: ClassifierSelectorStepProps): JSX.Element;
9
9
  export default ClassifierSelectorStep;
@@ -9,26 +9,16 @@ 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
13
  import { FormStyleTypes } from '../../constants/FormStepTypes';
25
14
  import MaterialClassifierSelectorStep from './MaterialClassifierSelectorStep/MaterialClassifierSelectorStep';
26
- function ClassifierSelectorStep(_a) {
27
- var formStyle = _a.formStyle, others = __rest(_a, ["formStyle"]);
15
+ import { useAppSelector } from '../../hooks';
16
+ function ClassifierSelectorStep(props) {
17
+ var formStyle = useAppSelector(function (state) { return state.global; }).formStyle;
28
18
  switch (formStyle.type) {
29
19
  case FormStyleTypes.MATERIAL:
30
20
  default: {
31
- return (_jsx(MaterialClassifierSelectorStep, __assign({ formStyle: formStyle }, others)));
21
+ return _jsx(MaterialClassifierSelectorStep, __assign({}, props));
32
22
  }
33
23
  }
34
24
  }