@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
@@ -1,4 +1,7 @@
1
- import Types, { ApiSelectorOptionTypes, ClassifierOptionTypes, EntityValueOptionTypes, OptionTypes, } from '../constants/FormStepTypes';
1
+ import { EditorState } from 'draft-js';
2
+ import Types, { ApiSelectorOptionTypes, ClassifierOptionTypes, EntityValueDataTypes, EntityValueOptionTypes, OptionTypes, StepTypes, } from '../constants/FormStepTypes';
3
+ import CBRFormStepTypes from '../constants/CBRFormStepTypes';
4
+ import AYFFormStepTypes from '../constants/AYFFormStepTypes';
2
5
  export function calcFillerSize(step, steps, values, size) {
3
6
  var _a;
4
7
  var maxSize = (_a = step.maxSize) !== null && _a !== void 0 ? _a : size.blockNum;
@@ -91,3 +94,155 @@ export function recursivelyCheckOpenSize(idStep, steps, values) {
91
94
  export var calcStepWidth = function (stepSize, size) {
92
95
  return size.blockSize * stepSize + size.spacingSize * (stepSize - 1);
93
96
  };
97
+ export var calcDefaultValue = function (step) {
98
+ var _a;
99
+ switch (step.type) {
100
+ case StepTypes.CHECKBOX:
101
+ return (_a = step.defaultValue) !== null && _a !== void 0 ? _a : false;
102
+ case StepTypes.TITLE:
103
+ return {
104
+ title: step.title,
105
+ description: step.description,
106
+ };
107
+ case StepTypes.SELECTOR:
108
+ case StepTypes.TEXTINPUT:
109
+ case StepTypes.CLASSIFIER_SELECTOR:
110
+ return '';
111
+ case StepTypes.TEXTAREA:
112
+ if (step.hasTextEditor)
113
+ return EditorState.createEmpty();
114
+ else
115
+ return '';
116
+ case StepTypes.RATING:
117
+ case StepTypes.DATEPICKER:
118
+ case StepTypes.API_SELECTOR:
119
+ case StepTypes.ENTITYVALUEPICKER:
120
+ return null;
121
+ case StepTypes.MAPPER:
122
+ case StepTypes.FILEUPLOAD:
123
+ return [];
124
+ case StepTypes.COLLAPSIBLE:
125
+ return false;
126
+ case StepTypes.SEPARATOR:
127
+ default:
128
+ return undefined;
129
+ }
130
+ };
131
+ export var iterateNestedSteps = function (idStep, steps, iteration) {
132
+ var step = steps[idStep];
133
+ iteration(step);
134
+ if (step.type == StepTypes.MAPPER) {
135
+ for (var _i = 0, _a = step.rootSteps; _i < _a.length; _i++) {
136
+ var idStep_1 = _a[_i];
137
+ iterateNestedSteps(idStep_1, step.steps, iteration);
138
+ }
139
+ }
140
+ else {
141
+ for (var _b = 0, _c = calcSubSteps(step); _b < _c.length; _b++) {
142
+ var idSubStep = _c[_b];
143
+ iterateNestedSteps(idSubStep, steps, iteration);
144
+ }
145
+ }
146
+ };
147
+ /**
148
+ * Utility function to handle the substeps of a step
149
+ * @param step step to calc the substeps
150
+ * @param idModifier optional modifier for the ids of the substeps and all other properties
151
+ * @returns list of the ids of the direct substeps of the step, if modifier returns modified steps
152
+ */
153
+ export var calcSubSteps = function (step, idModifier) {
154
+ var _a;
155
+ var subSteps = [];
156
+ var handleSteps = function (steps) {
157
+ for (var i = 0; i < steps.length; i++) {
158
+ var idStep = steps[i];
159
+ if (idModifier)
160
+ steps[i] = idModifier(idStep);
161
+ subSteps.push(idStep);
162
+ }
163
+ };
164
+ switch (step.type) {
165
+ case StepTypes.SELECTOR: {
166
+ for (var _i = 0, _b = step.options; _i < _b.length; _i++) {
167
+ var option = _b[_i];
168
+ if (option.type === OptionTypes.NESTED) {
169
+ handleSteps(option.steps);
170
+ }
171
+ }
172
+ break;
173
+ }
174
+ case StepTypes.CLASSIFIER_SELECTOR:
175
+ for (var _c = 0, _d = Object.keys(step.options); _c < _d.length; _c++) {
176
+ var idOption = _d[_c];
177
+ var option = step.options[idOption];
178
+ if (option.type === ClassifierOptionTypes.NESTED) {
179
+ handleSteps(option.steps);
180
+ }
181
+ }
182
+ break;
183
+ case StepTypes.RATING:
184
+ if (step.nestedSteps) {
185
+ for (var _e = 0, _f = step.nestedSteps; _e < _f.length; _e++) {
186
+ var steps = _f[_e];
187
+ handleSteps(steps);
188
+ }
189
+ }
190
+ break;
191
+ case StepTypes.COLLAPSIBLE: {
192
+ handleSteps(step.steps);
193
+ break;
194
+ }
195
+ case StepTypes.CHECKBOX: {
196
+ if (step.steps)
197
+ handleSteps(step.steps);
198
+ if (step.uncheckedSteps)
199
+ handleSteps(step.uncheckedSteps);
200
+ break;
201
+ }
202
+ case StepTypes.ENTITYVALUEPICKER:
203
+ if (idModifier) {
204
+ for (var _g = 0, _h = step.path; _g < _h.length; _g++) {
205
+ var path = _h[_g];
206
+ if (path.type === EntityValueDataTypes.STEP) {
207
+ path.idStep = idModifier(path.idStep);
208
+ }
209
+ }
210
+ for (var _j = 0, _k = step.filters; _j < _k.length; _j++) {
211
+ var filter = _k[_j];
212
+ if (filter.type === EntityValueDataTypes.STEP) {
213
+ filter.idStep = idModifier(filter.idStep);
214
+ }
215
+ }
216
+ }
217
+ for (var _l = 0, _m = Object.keys((_a = step.options) !== null && _a !== void 0 ? _a : {}); _l < _m.length; _l++) {
218
+ var idOption = _m[_l];
219
+ var option = step.options[idOption];
220
+ if (option.type === EntityValueOptionTypes.NESTED) {
221
+ handleSteps(option.steps);
222
+ }
223
+ }
224
+ break;
225
+ case CBRFormStepTypes.CBR_LOCATIVAS:
226
+ {
227
+ var elementStep = step;
228
+ if (elementStep.subStep) {
229
+ if (idModifier)
230
+ elementStep.subStep = idModifier(elementStep.subStep);
231
+ subSteps.push(elementStep.subStep);
232
+ }
233
+ }
234
+ break;
235
+ case AYFFormStepTypes.AYF_ICA_CITY: {
236
+ var cityStep = step;
237
+ if (cityStep.idNitStep) {
238
+ if (idModifier)
239
+ cityStep.idNitStep = idModifier(cityStep.idNitStep);
240
+ subSteps.push(cityStep.idNitStep);
241
+ }
242
+ break;
243
+ }
244
+ default:
245
+ break;
246
+ }
247
+ return subSteps;
248
+ };
@@ -0,0 +1,23 @@
1
+ import { GBaseStep } from '../@Types/GenericFormSteps';
2
+ import { Form } from '../@Types';
3
+ import { DependencyStore } from '../Form/Form';
4
+ export declare const useStepDependency: (step: GBaseStep, defaultValue?: any) => {
5
+ originalValue: any;
6
+ isDependency: boolean;
7
+ handleStepDep: (value: any | undefined) => void;
8
+ };
9
+ export declare const selectDependencies: ((state: {
10
+ global: import("../States/GlobalStateReducer").GlobalState;
11
+ site: import("../States/SiteStateReducer").SiteState;
12
+ widthStats: import("../Form/Form").WidthStats;
13
+ }, step: GBaseStep, form: Form) => {
14
+ invalids: string[];
15
+ emptyDep: boolean;
16
+ }) & import("reselect").OutputSelectorFields<(args_0: DependencyStore, args_1: GBaseStep, args_2: Form) => {
17
+ invalids: string[];
18
+ emptyDep: boolean;
19
+ }, {
20
+ clearCache: () => void;
21
+ }> & {
22
+ clearCache: () => void;
23
+ };
@@ -0,0 +1,87 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
10
+ import { useCallback, useEffect } from 'react';
11
+ import { useAppSelector, useAppDispatch } from '../hooks';
12
+ import { setStepDependency } from '../States/SiteStateReducer';
13
+ import { createSelector } from '@reduxjs/toolkit';
14
+ import { calcDefaultValue } from './StepFunctions';
15
+ var selectIsDependency = createSelector([
16
+ function (state) { return state.site.dependencies; },
17
+ function (state, step) { return step; },
18
+ ], function (dependencies, step) {
19
+ return dependencies[step.id] !== undefined;
20
+ });
21
+ var selectOriginalValue = createSelector([
22
+ function (state) { return state.site.values; },
23
+ function (state, step) { return step; },
24
+ ], function (values, step) { var _a; return (_a = values.sections[step.idSection]) === null || _a === void 0 ? void 0 : _a[step.id]; });
25
+ export var useStepDependency = function (step, defaultValue) {
26
+ var _a;
27
+ var isDependency = useAppSelector(function (state) {
28
+ return selectIsDependency(state, step);
29
+ });
30
+ var originalValue = useAppSelector(function (state) {
31
+ return selectOriginalValue(state, step);
32
+ });
33
+ var dispatch = useAppDispatch();
34
+ useEffect(function () {
35
+ if (isDependency && !originalValue && defaultValue) {
36
+ dispatch(setStepDependency({
37
+ step: step,
38
+ value: defaultValue,
39
+ }));
40
+ }
41
+ }, [isDependency]);
42
+ var handleStepDep = useCallback(function (value) {
43
+ if (!isDependency)
44
+ return;
45
+ dispatch(setStepDependency({
46
+ step: step,
47
+ value: value !== null && value !== void 0 ? value : null,
48
+ }));
49
+ }, [step.id, step.type, isDependency]);
50
+ return {
51
+ handleStepDep: handleStepDep,
52
+ isDependency: isDependency,
53
+ originalValue: (_a = originalValue !== null && originalValue !== void 0 ? originalValue : defaultValue) !== null && _a !== void 0 ? _a : calcDefaultValue(step),
54
+ };
55
+ };
56
+ export var selectDependencies = createSelector([
57
+ function (state) { return state.site.dependencies; },
58
+ function (state, step) { return step; },
59
+ function (state, step, form) { return form; },
60
+ ], function (dependencies, step, form) {
61
+ var invalids = [];
62
+ var emptyDep = false;
63
+ /** Show deep error changes even if not in dependencies */
64
+ for (var _i = 0, _a = calcDeepDependencies(step.id, form); _i < _a.length; _i++) {
65
+ var idDep = _a[_i];
66
+ var dependency = dependencies[idDep];
67
+ if ((dependency === null || dependency === void 0 ? void 0 : dependency.value) === null && form.steps[idDep]) {
68
+ invalids.push(idDep);
69
+ }
70
+ if (dependency === null || dependency === void 0 ? void 0 : dependency.empty)
71
+ emptyDep = true;
72
+ }
73
+ return { invalids: invalids, emptyDep: emptyDep };
74
+ });
75
+ var calcDeepDependencies = function (idStep, form, deps) {
76
+ if (deps === void 0) { deps = []; }
77
+ var step = form.steps[idStep];
78
+ if (step === null || step === void 0 ? void 0 : step.dependencies) {
79
+ for (var _i = 0, _a = step.dependencies; _i < _a.length; _i++) {
80
+ var dep = _a[_i];
81
+ if (!deps.includes(dep)) {
82
+ deps.push.apply(deps, __spreadArray(__spreadArray([], calcDeepDependencies(dep, form, deps), false), [dep], false));
83
+ }
84
+ }
85
+ }
86
+ return deps;
87
+ };
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
3
+ import './DraftEditor.css';
4
+ import { TextAreaStepProps } from '../TextAreaStep';
5
+ export interface Payload {
6
+ text: string;
7
+ draft: any;
8
+ }
9
+ declare function TextAreaStep({ step, editable }: TextAreaStepProps): JSX.Element;
10
+ export default TextAreaStep;
@@ -0,0 +1,148 @@
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 { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
24
+ import styles from './MaterialTextAreaStep.module.css';
25
+ import { useController } from 'react-hook-form';
26
+ import { Editor } from 'react-draft-wysiwyg'; //Load programatically only if step has editor
27
+ import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
28
+ import './DraftEditor.css';
29
+ import { useCallback, useState } from 'react';
30
+ import { ClickAwayListener } from '@material-ui/core';
31
+ import { useAppSelector } from '../../../hooks';
32
+ import { useStepDependency } from '../../StepHooks';
33
+ function TextAreaStep(_a) {
34
+ var _b;
35
+ var step = _a.step, editable = _a.editable;
36
+ var _c = useAppSelector(function (state) { return state.global; }), formStyle = _c.formStyle, postview = _c.postview;
37
+ var _d = useState(false), hovering = _d[0], setHovering = _d[1];
38
+ var _e = useState(false), focus = _e[0], setFocus = _e[1];
39
+ var _f = useState(), timer = _f[0], setTimer = _f[1];
40
+ var _g = useStepDependency(step), handleStepDep = _g.handleStepDep, originalValue = _g.originalValue, isDependency = _g.isDependency;
41
+ var _h = useController({
42
+ name: step.id,
43
+ shouldUnregister: true,
44
+ rules: step.required
45
+ ? {
46
+ validate: function (editorState) {
47
+ return editorState.getCurrentContent().hasText();
48
+ },
49
+ }
50
+ : {},
51
+ defaultValue: originalValue,
52
+ }), _j = _h.field, ref = _j.ref, field = __rest(_j, ["ref"]), error = _h.fieldState.error;
53
+ var onChange = useCallback(function (value) {
54
+ if (isDependency) {
55
+ try {
56
+ clearTimeout(timer);
57
+ // eslint-disable-next-line no-empty
58
+ }
59
+ catch (e) { }
60
+ setTimer(setTimeout(function () {
61
+ handleStepDep(value.getCurrentContent().getPlainText());
62
+ setTimer(undefined);
63
+ }, 1000));
64
+ }
65
+ onChange(value);
66
+ }, [handleStepDep, isDependency, field]);
67
+ var calcStyle = function () {
68
+ var backgroundColor = formStyle.stepBackgroundColor;
69
+ if (focus) {
70
+ return {
71
+ border: '2px solid ' + formStyle.primaryColor,
72
+ marginTop: -1,
73
+ marginLeft: -1,
74
+ marginBottom: 0,
75
+ backgroundColor: backgroundColor,
76
+ };
77
+ }
78
+ else if (hovering) {
79
+ return {
80
+ border: '1px solid ' + formStyle.primaryColor,
81
+ backgroundColor: backgroundColor,
82
+ };
83
+ }
84
+ else {
85
+ return {
86
+ border: '1px solid ' + formStyle.outlineColor,
87
+ backgroundColor: backgroundColor,
88
+ };
89
+ }
90
+ };
91
+ var canEdit = editable && !postview;
92
+ var value = field.value;
93
+ var editorClassName = styles.editor;
94
+ if (!value.getCurrentContent().hasText()) {
95
+ if (value.getCurrentContent().getBlockMap().first().getType() !==
96
+ 'unstyled') {
97
+ editorClassName += ' RichEditor-hidePlaceholder';
98
+ }
99
+ }
100
+ if (!canEdit) {
101
+ editorClassName += ' postview-editor';
102
+ }
103
+ return (_jsxs("div", __assign({ className: styles.textEditorContainer, style: {
104
+ '--eureka-outline': formStyle.outlineColor,
105
+ '--eureka-primary': formStyle.primaryColor,
106
+ } }, { children: [step.label && (_jsxs("div", __assign({ className: styles.textEditorLabel, style: {
107
+ color: error
108
+ ? formStyle.errorColor
109
+ : formStyle.textColor,
110
+ } }, { children: [step.label, " ", step.required ? ' *' : ''] }))), _jsx(ClickAwayListener, __assign({ mouseEvent: "onMouseDown", onClickAway: function () {
111
+ if (canEdit) {
112
+ setFocus(false);
113
+ }
114
+ } }, { children: _jsx("div", __assign({ className: postview
115
+ ? styles.postViewContainer + ' EF-DraftContainer'
116
+ : styles.textContainer + ' EF-DraftContainer', "data-testid": step.id, style: calcStyle(), onMouseEnter: function () {
117
+ if (canEdit) {
118
+ setHovering(true);
119
+ }
120
+ }, onMouseLeave: function () {
121
+ if (canEdit) {
122
+ setHovering(false);
123
+ }
124
+ }, onClick: function () {
125
+ if (canEdit) {
126
+ setFocus(true);
127
+ }
128
+ } }, { children: _jsx(Editor, __assign({}, field, { editorRef: ref, onFocus: function () {
129
+ setFocus(true);
130
+ }, readOnly: !canEdit, stripPastedStyles: true, onEditorStateChange: onChange, toolbarClassName: !canEdit ? ' postview-editor-toolbar' : '', editorClassName: editorClassName, wrapperClassName: styles.wrapper, placeholder: (_b = step.description) !== null && _b !== void 0 ? _b : '', toolbar: {
131
+ options: ['inline', 'list', 'history'],
132
+ inline: {
133
+ options: [
134
+ 'bold',
135
+ 'italic',
136
+ 'underline',
137
+ 'strikethrough',
138
+ ],
139
+ },
140
+ list: {
141
+ options: ['unordered'],
142
+ },
143
+ } })) })) })), _jsx("div", __assign({ className: styles.errorMsg, style: {
144
+ color: formStyle.errorColor,
145
+ height: !postview && editable ? '0.75rem' : 0,
146
+ } }, { children: !!error && 'Este campo es obligatorio' }))] })));
147
+ }
148
+ export default TextAreaStep;
@@ -1,13 +1,8 @@
1
1
  /// <reference types="react" />
2
- import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
3
- import './DraftEditor.css';
4
- import { RawDraftContentState } from 'draft-js';
5
2
  import { TextAreaStepProps } from '../TextAreaStep';
6
3
  export interface Payload {
7
4
  text: string;
8
5
  draft: any;
9
6
  }
10
- declare function TextAreaStep({ step, errors, partial, control, editable, postview, formStyle, maxLength, originalValues, }: TextAreaStepProps): JSX.Element;
7
+ declare function TextAreaStep({ step, editable, maxLength, }: TextAreaStepProps): JSX.Element;
11
8
  export default TextAreaStep;
12
- export declare function stringToDraft(text: string): RawDraftContentState;
13
- export declare const getRawText: (draft?: RawDraftContentState, text?: string) => RawDraftContentState;