@arquimedes.co/eureka-forms 1.9.134 → 2.0.1-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 +17 -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 +22 -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
@@ -20,21 +20,27 @@ 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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
25
- import React, { useState } from 'react';
24
+ import React, { useCallback, useContext, useState } from 'react';
26
25
  import { ClassifierOptionTypes } from '../../../constants/FormStepTypes';
27
26
  import styles from './MaterialClassifierSelectorStep.module.css';
28
27
  import StepComponent from '../../Step';
29
- import { Controller } from 'react-hook-form';
28
+ import { useController, useFormContext } from 'react-hook-form';
30
29
  import { calcFillerSize, calcStepWidth } from '../../StepFunctions';
31
- import RoundedSmartSelect from '../../../shared/RoundedSmartSelect/RoundedSmartSelect';
30
+ import RoundedSmartSelect from '../../../Shared/RoundedSmartSelect/RoundedSmartSelect';
31
+ import FormContext from '../../../Contexts/FormContext';
32
+ import { selectBreakPoint, useAppSelector } from '../../../hooks';
33
+ import { useStepDependency } from '../../StepHooks';
32
34
  function ClassifierSelector(_a) {
33
35
  var _b, _c;
34
- var step = _a.step, form = _a.form, level = _a.level, errors = _a.errors, value = _a.value, onBlur = _a.onBlur, control = _a.control, editable = _a.editable, onChange = _a.onChange, postview = _a.postview, inputRef = _a.inputRef, formStyle = _a.formStyle, getValues = _a.getValues, widthStats = _a.widthStats, handleSizeChange = _a.handleSizeChange, others = __rest(_a, ["step", "form", "level", "errors", "value", "onBlur", "control", "editable", "onChange", "postview", "inputRef", "formStyle", "getValues", "widthStats", "handleSizeChange"]);
35
- var _d = useState(level === 0
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;
38
+ 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
36
42
  ? calcFillerSize(step, form.steps, getValues(), form.size)
37
- : 0), fillerSize = _d[0], setFillerSize = _d[1];
43
+ : 0), fillerSize = _f[0], setFillerSize = _f[1];
38
44
  if (!step.idClassifier) {
39
45
  return _jsx("div", {});
40
46
  }
@@ -52,7 +58,7 @@ function ClassifierSelector(_a) {
52
58
  var classifier = (_a = form.classifiers) === null || _a === void 0 ? void 0 : _a[idClassifier];
53
59
  return {
54
60
  value: classifier === null || classifier === void 0 ? void 0 : classifier._id,
55
- 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)) && others.preview
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
56
62
  ? classifier === null || classifier === void 0 ? void 0 : classifier.clientName
57
63
  : classifier === null || classifier === void 0 ? void 0 : classifier.name,
58
64
  };
@@ -64,9 +70,9 @@ function ClassifierSelector(_a) {
64
70
  }
65
71
  };
66
72
  var renderSelect = function () {
67
- var _a;
73
+ var _a, _b, _c, _d;
68
74
  return (_jsx("div", __assign({ className: styles.container, style: {
69
- width: widthStats.currentBreakPoint <= step.size
75
+ width: currentBreakPoint <= step.size
70
76
  ? '100%'
71
77
  : calcStepWidth(step.size, form.size),
72
78
  minHeight: step.description ||
@@ -78,9 +84,7 @@ function ClassifierSelector(_a) {
78
84
  sizeChange();
79
85
  }, getOptionSelected: function (option, value) {
80
86
  return option.value === (value === null || value === void 0 ? void 0 : value.value);
81
- }, helperText: errors[step.id]
82
- ? errors[step.id].message
83
- : step.description, error: !!errors[step.id] }) }), step.id));
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));
84
88
  };
85
89
  var mapNestedOption = function () {
86
90
  if (value) {
@@ -88,18 +92,14 @@ function ClassifierSelector(_a) {
88
92
  if ((currentOption === null || currentOption === void 0 ? void 0 : currentOption.type) === ClassifierOptionTypes.NESTED) {
89
93
  return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idStep) {
90
94
  var subStep = form.steps[idStep];
91
- return (_createElement(StepComponent, __assign({}, others, { postview: postview, editable: editable, widthStats: widthStats, getValues: getValues, formStyle: formStyle, errors: errors, form: form, control: control, step: subStep, key: idStep, level: level + 1, handleSizeChange: function () {
92
- sizeChange();
93
- } })));
95
+ return (_jsx(StepComponent, { step: subStep, level: level + 1, editable: editable, handleSizeChange: sizeChange }, idStep));
94
96
  }) }));
95
97
  }
96
98
  }
97
99
  };
98
100
  if (level === 0 && step.maxSize && step.maxSize < form.size.blockNum) {
99
101
  return (_jsxs("div", __assign({ className: styles.firstLvlContainer, style: {
100
- width: widthStats.currentBreakPoint <= step.size
101
- ? '100%'
102
- : 'fit-content',
102
+ width: currentBreakPoint <= step.size ? '100%' : 'fit-content',
103
103
  } }, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize < form.size.blockNum && (_jsx("div", { className: styles.smallSeparator, style: {
104
104
  width: fillerSize,
105
105
  } }, "SEPARATOR"))] })));
@@ -110,12 +110,19 @@ function ClassifierSelector(_a) {
110
110
  }
111
111
  export default ClassifierSelectorStep;
112
112
  function ClassifierSelectorStep(props) {
113
- return (_jsx(Controller, { name: props.step.id, control: props.control, defaultValue: "", rules: {
114
- required: props.step.required
115
- ? 'Este campo es obligatorio'
116
- : undefined,
117
- }, shouldUnregister: true, render: function (_a) {
118
- var _b = _a.field, ref = _b.ref, field = __rest(_b, ["ref"]);
119
- return (_jsx(ClassifierSelector, __assign({}, props, field, { inputRef: ref })));
120
- } }));
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 })));
121
128
  }
@@ -5,5 +5,5 @@ export interface CollapsibleStepProps extends StepProps {
5
5
  /** The CollapsibleStep to display */
6
6
  step: Collapsible;
7
7
  }
8
- declare function CollapsibleStep({ step, formStyle, ...others }: CollapsibleStepProps): JSX.Element;
8
+ declare function CollapsibleStep({ step, ...others }: CollapsibleStepProps): JSX.Element;
9
9
  export default CollapsibleStep;
@@ -21,16 +21,18 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  return t;
22
22
  };
23
23
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
24
+ import { useAppSelector } from '../../hooks';
24
25
  import { FormStyleTypes } from '../../constants/FormStepTypes';
25
26
  import MaterialCollapsibleStep from './MaterialTitleStep/MaterialCollapsibleStep';
26
27
  function CollapsibleStep(_a) {
27
- var step = _a.step, formStyle = _a.formStyle, others = __rest(_a, ["step", "formStyle"]);
28
+ var step = _a.step, others = __rest(_a, ["step"]);
29
+ var formStyle = useAppSelector(function (state) { return state.global; }).formStyle;
28
30
  if (step.steps.length === 0)
29
31
  return _jsx(_Fragment, {});
30
32
  switch (formStyle.type) {
31
33
  case FormStyleTypes.MATERIAL:
32
34
  default: {
33
- return (_jsx(MaterialCollapsibleStep, __assign({ step: step, formStyle: formStyle }, others)));
35
+ return _jsx(MaterialCollapsibleStep, __assign({ step: step }, others));
34
36
  }
35
37
  }
36
38
  }
@@ -22,20 +22,25 @@ var __rest = (this && this.__rest) || function (s, e) {
22
22
  };
23
23
  import { createElement as _createElement } from "react";
24
24
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
25
- import React, { useEffect } from 'react';
25
+ import React, { useContext, useEffect } from 'react';
26
26
  import styles from './MaterialCollapsibleStep.module.css';
27
- import { Controller } from 'react-hook-form';
27
+ import { Controller, useFormContext } from 'react-hook-form';
28
28
  import StepComponent from '../../Step';
29
29
  import ExpandMoreRoundedIcon from '@material-ui/icons/ExpandMoreRounded';
30
30
  import ExpandLessRoundedIcon from '@material-ui/icons/ExpandLessRounded';
31
+ import FormContext from '../../../Contexts/FormContext';
32
+ import { useAppSelector } from '../../../hooks';
31
33
  function Collapsible(_a) {
32
34
  var _b, _c, _d, _e;
33
- var step = _a.step, open = _a.open, setOpen = _a.setOpen, formStyle = _a.formStyle, widthStats = _a.widthStats, form = _a.form, errors = _a.errors, clearErrors = _a.clearErrors, others = __rest(_a, ["step", "open", "setOpen", "formStyle", "widthStats", "form", "errors", "clearErrors"]);
35
+ var step = _a.step, open = _a.open, setOpen = _a.setOpen, level = _a.level, others = __rest(_a, ["step", "open", "setOpen", "level"]);
36
+ var formStyle = useAppSelector(function (state) { return state.global; }).formStyle;
37
+ var form = useContext(FormContext);
38
+ var errors = useFormContext().formState.errors;
34
39
  var contentRef = React.useRef(null);
35
40
  useEffect(function () {
36
41
  var _a;
37
42
  if (!open && ((_a = step.dependencies) === null || _a === void 0 ? void 0 : _a.find(function (dep) { return !!errors[dep]; }))) {
38
- setOpen('TRUE');
43
+ setOpen(true);
39
44
  }
40
45
  }, (_c = (_b = step.dependencies) === null || _b === void 0 ? void 0 : _b.map(function (dep) { return errors[dep]; })) !== null && _c !== void 0 ? _c : []);
41
46
  return (_jsxs(React.Fragment, { children: [_jsxs("div", __assign({ className: styles.container, style: {
@@ -53,23 +58,23 @@ function Collapsible(_a) {
53
58
  : 0,
54
59
  } }, { children: _jsx("div", __assign({ className: styles.contentContainer, ref: contentRef }, { children: step.steps.map(function (idSubStep) {
55
60
  var subStep = form.steps[idSubStep];
56
- return (_createElement(StepComponent, __assign({}, others, { clearErrors: clearErrors, errors: errors, formStyle: formStyle, form: form, widthStats: widthStats, step: subStep, key: idSubStep, handleSizeChange: function () { } })));
61
+ return (_createElement(StepComponent, __assign({}, others, { step: subStep, key: idSubStep, level: level + 1 })));
57
62
  }) })) })), _jsx("div", { className: styles.separator, style: {
58
63
  backgroundColor: formStyle.primaryColor,
59
64
  } })] }));
60
65
  }
61
66
  function CollapsibleStep(props) {
62
- var _a, _b;
63
- 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 : props.postview)
64
- ? false
65
- : true, render: function (_a) {
67
+ var _a;
68
+ var postview = useAppSelector(function (state) { return state.global; }).postview;
69
+ var _b = useFormContext(), clearErrors = _b.clearErrors, errors = _b.formState.errors;
70
+ return (_jsx(Controller, { name: props.step.id, defaultValue: ((_a = props.step.defaultValue) !== null && _a !== void 0 ? _a : postview) ? false : true, render: function (_a) {
66
71
  var _b = _a.field, value = _b.value, onChange = _b.onChange;
67
72
  return (_jsx(Collapsible, __assign({}, props, { open: value, setOpen: function (open) {
68
73
  var _a;
69
74
  if (!open) {
70
- var deps = (_a = props.step.dependencies) === null || _a === void 0 ? void 0 : _a.filter(function (dep) { return !!props.errors[dep]; });
75
+ var deps = (_a = props.step.dependencies) === null || _a === void 0 ? void 0 : _a.filter(function (dep) { return !!errors[dep]; });
71
76
  if (deps)
72
- props.clearErrors(deps);
77
+ clearErrors(deps);
73
78
  }
74
79
  onChange(open);
75
80
  } })));
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import { UseFormReturn } from 'react-hook-form';
3
+ import { StepProps } from './Step';
4
+ import { Form } from '../@Types';
5
+ import { GlobalState } from '../States/GlobalStateReducer';
6
+ export interface CustomStepProps extends StepProps, UseFormReturn, GlobalState {
7
+ form: Form;
8
+ customStepProps: Record<string, any>;
9
+ }
10
+ export interface CustomStep {
11
+ componentProps?: Record<string, any>;
12
+ component: (props: CustomStepProps) => JSX.Element;
13
+ calcValue?: (step: any, value: any) => any;
14
+ /** Function to change custom steps nested step ids to the generated ones. */
15
+ calcRecursiveData?: (step: any, ids: Record<string, string>) => void;
16
+ calcDependencyValue?: (step: any, value: any) => any;
17
+ }
18
+ interface CustomStepComponentProps extends StepProps {
19
+ customStep: CustomStep;
20
+ }
21
+ declare function CustomStepComponent({ customStep, ...props }: CustomStepComponentProps): JSX.Element;
22
+ export default CustomStepComponent;
@@ -0,0 +1,37 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { useFormContext } from 'react-hook-form';
24
+ import FormContext from '../Contexts/FormContext';
25
+ import { useAppSelector } from '../hooks';
26
+ import CustomStepPropsContext from '../Contexts/CustomContext';
27
+ import { useContext } from 'react';
28
+ function CustomStepComponent(_a) {
29
+ var _b;
30
+ var customStep = _a.customStep, props = __rest(_a, ["customStep"]);
31
+ var form = useContext(FormContext);
32
+ var global = useAppSelector(function (state) { return state.global; });
33
+ var customStepProps = useContext(CustomStepPropsContext);
34
+ var formController = useFormContext();
35
+ return customStep.component(__assign(__assign(__assign(__assign(__assign({}, props), formController), { form: form, customStepProps: customStepProps }), global), ((_b = customStep.componentProps) !== null && _b !== void 0 ? _b : {})));
36
+ }
37
+ export default CustomStepComponent;
@@ -12,8 +12,10 @@ var __assign = (this && this.__assign) || function () {
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { FormStyleTypes } from '../../constants/FormStepTypes';
14
14
  import MaterialDatePickerStep from './MaterialDatePickerStep/MaterialDatePickerStep';
15
+ import { useAppSelector } from '../../hooks';
15
16
  function DatePickerStep(props) {
16
- switch (props.formStyle.type) {
17
+ var formStyle = useAppSelector(function (state) { return state.global; }).formStyle;
18
+ switch (formStyle.type) {
17
19
  case FormStyleTypes.MATERIAL:
18
20
  default: {
19
21
  return _jsx(MaterialDatePickerStep, __assign({}, props));
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { DatePickerStepProps } from '../DatePickerStep';
3
- declare function DatePickerStep({ step, form, errors, control, editable, postview, formStyle, widthStats, defaultValue, }: DatePickerStepProps): JSX.Element;
3
+ declare function DatePickerStep({ step, editable, defaultValue, }: DatePickerStepProps): JSX.Element;
4
4
  export default DatePickerStep;
@@ -22,27 +22,39 @@ var __rest = (this && this.__rest) || function (s, e) {
22
22
  };
23
23
  import { jsx as _jsx } from "react/jsx-runtime";
24
24
  import styles from './MaterialDatePickerStep.module.css';
25
- import { Controller } from 'react-hook-form';
26
- import RoundedDatePicker from '../../../shared/RoundedDatePicker/RoundedDatePicker';
25
+ import { useController } from 'react-hook-form';
26
+ import RoundedDatePicker from '../../../Shared/RoundedDatePicker/RoundedDatePicker';
27
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';
28
32
  function DatePickerStep(_a) {
29
- var step = _a.step, form = _a.form, errors = _a.errors, control = _a.control, editable = _a.editable, postview = _a.postview, formStyle = _a.formStyle, widthStats = _a.widthStats, _b = _a.defaultValue, defaultValue = _b === void 0 ? null : _b;
33
+ var _b;
34
+ var step = _a.step, editable = _a.editable, defaultValue = _a.defaultValue;
35
+ var currentBreakPoint = useAppSelector(selectBreakPoint);
36
+ 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,
41
+ rules: {
42
+ required: step.required ? 'Este campo es obligatorio' : undefined,
43
+ },
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]);
30
51
  return (_jsx("div", __assign({ className: styles.container, style: {
31
- width: widthStats.currentBreakPoint <= step.size
52
+ width: currentBreakPoint <= step.size
32
53
  ? '100%'
33
54
  : calcStepWidth(step.size, form.size),
34
55
  minHeight: step.description || (!postview && editable && step.required)
35
56
  ? '55px'
36
57
  : '43px',
37
- } }, { children: _jsx(Controller, { name: step.id, control: control, defaultValue: defaultValue, rules: {
38
- required: step.required
39
- ? 'Este campo es obligatorio'
40
- : undefined,
41
- }, shouldUnregister: true, render: function (_a) {
42
- var _b = _a.field, ref = _b.ref, field = __rest(_b, ["ref"]);
43
- return (_jsx(RoundedDatePicker, __assign({}, field, { 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: errors[step.id]
44
- ? errors[step.id].message
45
- : step.description, error: !!errors[step.id], required: step.required })));
46
- } }) })));
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 })) })));
47
59
  }
48
60
  export default DatePickerStep;
@@ -11,5 +11,5 @@ export interface EntityValuePickerStepProps extends StepProps {
11
11
  /** Default value to display */
12
12
  defaultValue?: Date | null;
13
13
  }
14
- declare function EntityValuePickerStep({ ...props }: EntityValuePickerStepProps): JSX.Element;
14
+ declare function EntityValuePickerStep(props: EntityValuePickerStepProps): JSX.Element;
15
15
  export default EntityValuePickerStep;
@@ -9,23 +9,13 @@ 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";
13
+ import { useAppSelector } from '../../hooks';
24
14
  import { FormStyleTypes } from '../../constants/FormStepTypes';
25
15
  import MaterialEntityValuePickerStep from './MaterialEntityValuePickerStep/MaterialEntityValuePickerStep';
26
- function EntityValuePickerStep(_a) {
27
- var props = __rest(_a, []);
28
- switch (props.formStyle.type) {
16
+ function EntityValuePickerStep(props) {
17
+ var formStyle = useAppSelector(function (state) { return state.global; }).formStyle;
18
+ switch (formStyle.type) {
29
19
  case FormStyleTypes.MATERIAL:
30
20
  default: {
31
21
  return _jsx(MaterialEntityValuePickerStep, __assign({}, props));