@arquimedes.co/eureka-forms 2.0.99 → 3.0.0-refactor

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 (339) hide show
  1. package/dist/App/App.js +21 -46
  2. package/dist/App/AppFunctions.js +177 -328
  3. package/dist/App/AppFunctions.test.js +638 -0
  4. package/dist/App/AppHooks.js +127 -223
  5. package/dist/App/AppHooks.test.js +154 -0
  6. package/dist/Contexts/CustomContext.js +1 -1
  7. package/dist/Contexts/FormContext.js +3 -2
  8. package/dist/Contexts/SectionContext.js +1 -1
  9. package/dist/Form/ConfirmationDialog/ConfirmationDialog.js +43 -62
  10. package/dist/Form/Form.js +75 -160
  11. package/dist/Form/FormFunctions.js +64 -114
  12. package/dist/Form/FormFunctions.test.js +454 -0
  13. package/dist/Form/FormHooks.js +14 -21
  14. package/dist/Form/FormTypes/ColumnForm/ColumnForm.js +34 -105
  15. package/dist/Form/FormTypes/StepperForm/StepperForm.js +48 -110
  16. package/dist/Form/Section/MaterialSection/MaterialSection.js +10 -23
  17. package/dist/Form/Section/MaterialSection/MaterialSection.module.css +0 -2
  18. package/dist/Form/Section/Section.js +4 -15
  19. package/dist/Form/Terms/Term/MaterialTerm/MaterialTerm.js +30 -65
  20. package/dist/Form/Terms/Term/Term.js +2 -13
  21. package/dist/Form/Terms/Terms.js +11 -27
  22. package/dist/FormSteps/@Construction/CBRElementStep/CBRElementStep.js +36 -106
  23. package/dist/FormSteps/@Construction/CBRIncidentsStep/CBRIncidentsStep.js +2 -13
  24. package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.js +12 -40
  25. package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +57 -77
  26. package/dist/FormSteps/@Construction/CBRPropertyStep/CBRPropertyStep.js +46 -111
  27. package/dist/FormSteps/AYFStepMapper.js +63 -127
  28. package/dist/FormSteps/ApiSelectorStep/ApiSelectorStep.js +2 -13
  29. package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +63 -165
  30. package/dist/FormSteps/CBRStepMapper.js +61 -152
  31. package/dist/FormSteps/CheckBoxStep/CheckBoxStep.js +2 -13
  32. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +19 -37
  33. package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.js +2 -13
  34. package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +47 -80
  35. package/dist/FormSteps/CollapsibleStep/CollapsibleStep.js +3 -26
  36. package/dist/FormSteps/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.js +33 -61
  37. package/dist/FormSteps/CustomStep.js +17 -31
  38. package/dist/FormSteps/DatePickerStep/DatePickerStep.js +2 -13
  39. package/dist/FormSteps/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +7 -20
  40. package/dist/FormSteps/EntityValueStep/EntityValuePickerStep.js +2 -13
  41. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValueDialog/MaterialEntityValueDialog.js +16 -32
  42. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +94 -180
  43. package/dist/FormSteps/FileUploadStep/FileUploadStep.js +2 -13
  44. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.js +33 -95
  45. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileFunctions.js +3 -0
  46. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +86 -180
  47. package/dist/FormSteps/MapperStep/MapperStep.js +2 -13
  48. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/ListMapperElement/ListMapperElement.js +16 -38
  49. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElementComponent.js +21 -31
  50. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PagedMapperElement/PagedMapperElement.js +89 -175
  51. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.js +20 -47
  52. package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.js +81 -117
  53. package/dist/FormSteps/PhoneInputStep/MaterialTextInputStep/MaterialPhoneInputStep.js +15 -33
  54. package/dist/FormSteps/PhoneInputStep/PhoneInputStep.js +2 -13
  55. package/dist/FormSteps/RatingStep/MaterialRatingStep/MaterialRatingStep.js +17 -31
  56. package/dist/FormSteps/RatingStep/RatingStep.js +2 -13
  57. package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +35 -61
  58. package/dist/FormSteps/SelectorStep/SelectorStep.js +2 -13
  59. package/dist/FormSteps/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.js +2 -3
  60. package/dist/FormSteps/SeparatorStep/SeparatorStep.js +2 -13
  61. package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +77 -142
  62. package/dist/FormSteps/SmartSelectStep/SmartSelectStep.js +2 -13
  63. package/dist/FormSteps/Step.js +29 -58
  64. package/dist/FormSteps/StepFunctions.js +149 -204
  65. package/dist/FormSteps/StepFunctions.test.js +695 -0
  66. package/dist/FormSteps/StepHooks.js +94 -146
  67. package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaEditorStep.js +38 -74
  68. package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +12 -28
  69. package/dist/FormSteps/TextAreaStep/TextAreaStep.js +3 -14
  70. package/dist/FormSteps/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +12 -30
  71. package/dist/FormSteps/TextInputStep/TextInputStep.js +2 -13
  72. package/dist/FormSteps/TimePickerStep/MaterialTimePickerStep/MaterialTimePickerStep.js +9 -26
  73. package/dist/FormSteps/TimePickerStep/TimePickerStep.js +2 -13
  74. package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +13 -26
  75. package/dist/FormSteps/TitleStep/TitleStep.js +2 -13
  76. package/dist/FormSteps/Utils/@StepFiller/StepFiller.js +14 -26
  77. package/dist/FormSteps/Utils/MaterialInputContainer/MaterialInputContainer.js +6 -18
  78. package/dist/Icons/ArrowLeftIcon.js +6 -0
  79. package/dist/Icons/ArrowRightIcon.js +6 -0
  80. package/dist/Icons/CalendarIcon.js +3 -14
  81. package/dist/Icons/CheckCircleIcon.js +6 -0
  82. package/dist/Icons/CheckboxCheckedIcon.js +6 -0
  83. package/dist/Icons/CheckboxUncheckedIcon.js +6 -0
  84. package/dist/Icons/ClockIcon.js +6 -0
  85. package/dist/Icons/CloseIcon.js +6 -0
  86. package/dist/Icons/Construction/LeakIcon.js +3 -14
  87. package/dist/Icons/Construction/ProjectIcon.js +3 -14
  88. package/dist/Icons/Construction/PropertyIcon.js +3 -14
  89. package/dist/Icons/Construction/SpaceIcon.js +3 -14
  90. package/dist/Icons/DeleteIcon.js +6 -0
  91. package/dist/Icons/DocumentIcon.js +3 -14
  92. package/dist/Icons/Entities/CheckListIcon.js +3 -14
  93. package/dist/Icons/Entities/GenericEntityIcon.js +4 -15
  94. package/dist/Icons/Entities/HandshakeIcon.js +4 -15
  95. package/dist/Icons/Entities/SupplierIcon.js +4 -15
  96. package/dist/Icons/ErkIcon.module.css +9 -0
  97. package/dist/Icons/ErrorIcon.js +6 -0
  98. package/dist/Icons/ExpandLessIcon.js +6 -0
  99. package/dist/Icons/ExpandMoreIcon.js +6 -0
  100. package/dist/Icons/FileIcon.js +6 -0
  101. package/dist/Icons/InfoIcon.js +6 -0
  102. package/dist/Icons/LocationIcon.js +3 -14
  103. package/dist/Icons/PersonIcon.js +4 -15
  104. package/dist/Icons/Ratings/DislikeIcon.js +6 -0
  105. package/dist/Icons/Ratings/DissatisfiedIcon.js +6 -0
  106. package/dist/Icons/Ratings/LikeIcon.js +6 -0
  107. package/dist/Icons/Ratings/SatisfiedIcon.js +6 -0
  108. package/dist/Icons/Ratings/StarIcon.js +6 -0
  109. package/dist/Icons/Ratings/VeryDissatisfiedIcon.js +6 -0
  110. package/dist/Icons/Ratings/VerySatisfiedIcon.js +6 -0
  111. package/dist/Icons/WarningIcon.js +6 -0
  112. package/dist/Init.js +2 -0
  113. package/dist/Services/FileService.js +29 -86
  114. package/dist/Services/FormService.js +11 -56
  115. package/dist/Services/OrganizationService.js +11 -62
  116. package/dist/Shared/CustomBtn/CustomBtn.js +25 -88
  117. package/dist/Shared/ErkButton/ErkButton.js +31 -0
  118. package/dist/Shared/{RoundedButton/RoundedButton.stories.js → ErkButton/ErkButton.stories.js} +6 -6
  119. package/dist/Shared/ErkCheckbox/ErkCheckBox.js +30 -0
  120. package/dist/Shared/ErkCheckbox/ErkCheckBox.stories.js +37 -0
  121. package/dist/Shared/ErkDatePicker/ErkDatePicker.js +210 -0
  122. package/dist/Shared/ErkDatePicker/ErkDatePicker.stories.js +103 -0
  123. package/dist/Shared/ErkPhoneInput/EkrPhoneInput.js +83 -0
  124. package/dist/Shared/ErkSelect/ErkSelect.js +90 -0
  125. package/dist/Shared/ErkSelect/ErkSelect.stories.js +64 -0
  126. package/dist/Shared/ErkSmartSelect/ErkSmartSelect.js +56 -0
  127. package/dist/Shared/ErkSmartSelect/ErkSmartSelect.stories.js +167 -0
  128. package/dist/Shared/ErkTextField/ErkTextField.js +111 -0
  129. package/dist/Shared/ErkTextField/ErkTextField.stories.js +105 -0
  130. package/dist/Shared/ErkTimePicker/ErkTimePicker.js +131 -0
  131. package/dist/Shared/InputIcon/InputIcon.js +25 -48
  132. package/dist/Shared/Loader/Loader.js +6 -18
  133. package/dist/Shared/Navbar/Navbar.js +2 -14
  134. package/dist/Shared/Navbar/Navbar.stories.js +2 -2
  135. package/dist/Shared/Rating/Rating.js +4 -27
  136. package/dist/Shared/Rating/Rating.stories.js +13 -19
  137. package/dist/Shared/Rating/Ratings/LikeRating.js +19 -33
  138. package/dist/Shared/Rating/Ratings/SatisfactionRating.js +27 -47
  139. package/dist/Shared/Rating/Ratings/ScaleRating.js +23 -54
  140. package/dist/Shared/Toggle/Toggle.js +11 -34
  141. package/dist/States/GlobalSlice.js +6 -17
  142. package/dist/States/SiteSlice.js +58 -76
  143. package/dist/States/WidthStatsSlice.js +8 -9
  144. package/dist/Utils/AxiosAPI.js +3 -3
  145. package/dist/Utils/AxiosWidget.js +4 -4
  146. package/dist/Utils/CBRFunctions.js +29 -30
  147. package/dist/Utils/DraftFunctions.js +102 -143
  148. package/dist/Utils/FormStepFunctions.js +27 -45
  149. package/dist/Utils/LocaleUtils.js +12 -0
  150. package/dist/Utils/MaterialProviders.js +43 -28
  151. package/dist/Utils/MuiClassnameSetup.js +3 -0
  152. package/dist/Utils/PhoneFunctions.js +5 -5
  153. package/dist/Utils/TestUtils.js +22 -51
  154. package/dist/Utils/store.js +10 -65
  155. package/dist/Widget.js +15 -26
  156. package/dist/constants/Files/FileExtensions.js +3 -3
  157. package/dist/constants/Files/FileMaxSize.js +1 -1
  158. package/dist/constants/InternalFormStyle.js +1 -1
  159. package/dist/hooks.js +14 -16
  160. package/dist/index.css +4 -0
  161. package/dist/main.js +22 -0
  162. package/package.json +108 -124
  163. package/dist/@Types/@Types.d.ts +0 -2
  164. package/dist/@Types/AYFFormStep.d.ts +0 -19
  165. package/dist/@Types/Branding.d.ts +0 -13
  166. package/dist/@Types/CBRFormStep.d.ts +0 -74
  167. package/dist/@Types/Condition.d.ts +0 -143
  168. package/dist/@Types/Draft/Draft.d.ts +0 -12
  169. package/dist/@Types/Draft/DraftEntityData.d.ts +0 -54
  170. package/dist/@Types/Entity.d.ts +0 -36
  171. package/dist/@Types/Form.d.ts +0 -75
  172. package/dist/@Types/FormStep.d.ts +0 -219
  173. package/dist/@Types/GenericFormSteps.d.ts +0 -84
  174. package/dist/@Types/MapperElement.d.ts +0 -8
  175. package/dist/@Types/Organization.d.ts +0 -11
  176. package/dist/@Types/Time.d.ts +0 -6
  177. package/dist/@Types/index.d.ts +0 -1
  178. package/dist/App/App.d.ts +0 -59
  179. package/dist/App/AppFunctions.d.ts +0 -23
  180. package/dist/App/AppHooks.d.ts +0 -10
  181. package/dist/Contexts/CustomContext.d.ts +0 -12
  182. package/dist/Contexts/FormContext.d.ts +0 -6
  183. package/dist/Contexts/SectionContext.d.ts +0 -3
  184. package/dist/Form/ConfirmationDialog/ConfirmationDialog.d.ts +0 -12
  185. package/dist/Form/Form.d.ts +0 -40
  186. package/dist/Form/FormFunctions.d.ts +0 -12
  187. package/dist/Form/FormHooks.d.ts +0 -3
  188. package/dist/Form/FormTypes/ColumnForm/ColumnForm.d.ts +0 -4
  189. package/dist/Form/FormTypes/StepperForm/StepperForm.d.ts +0 -4
  190. package/dist/Form/Section/MaterialSection/MaterialSection.d.ts +0 -4
  191. package/dist/Form/Section/Section.d.ts +0 -6
  192. package/dist/Form/Terms/Term/MaterialTerm/MaterialTerm.d.ts +0 -4
  193. package/dist/Form/Terms/Term/Term.d.ts +0 -8
  194. package/dist/Form/Terms/Terms.d.ts +0 -3
  195. package/dist/FormSteps/@Construction/CBRElementStep/CBRElementStep.d.ts +0 -8
  196. package/dist/FormSteps/@Construction/CBRIncidentsStep/CBRIncidentsStep.d.ts +0 -9
  197. package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.d.ts +0 -8
  198. package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.d.ts +0 -11
  199. package/dist/FormSteps/@Construction/CBRPropertyStep/CBRPropertyStep.d.ts +0 -8
  200. package/dist/FormSteps/AYFStepMapper.d.ts +0 -12
  201. package/dist/FormSteps/ApiSelectorStep/ApiSelectorStep.d.ts +0 -15
  202. package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.d.ts +0 -4
  203. package/dist/FormSteps/CBRStepMapper.d.ts +0 -13
  204. package/dist/FormSteps/CheckBoxStep/CheckBoxStep.d.ts +0 -9
  205. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.d.ts +0 -4
  206. package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.d.ts +0 -9
  207. package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.d.ts +0 -4
  208. package/dist/FormSteps/CollapsibleStep/CollapsibleStep.d.ts +0 -9
  209. package/dist/FormSteps/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.d.ts +0 -4
  210. package/dist/FormSteps/CustomStep.d.ts +0 -27
  211. package/dist/FormSteps/DatePickerStep/DatePickerStep.d.ts +0 -11
  212. package/dist/FormSteps/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.d.ts +0 -4
  213. package/dist/FormSteps/EntityValueStep/EntityValuePickerStep.d.ts +0 -15
  214. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValueDialog/MaterialEntityValueDialog.d.ts +0 -12
  215. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.d.ts +0 -4
  216. package/dist/FormSteps/FileUploadStep/FileUploadStep.d.ts +0 -9
  217. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.d.ts +0 -14
  218. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.d.ts +0 -18
  219. package/dist/FormSteps/MapperStep/MapperStep.d.ts +0 -18
  220. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/ListMapperElement/ListMapperElement.d.ts +0 -5
  221. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElementComponent.d.ts +0 -15
  222. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PagedMapperElement/PagedMapperElement.d.ts +0 -5
  223. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.d.ts +0 -5
  224. package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.d.ts +0 -21
  225. package/dist/FormSteps/PhoneInputStep/MaterialTextInputStep/MaterialPhoneInputStep.d.ts +0 -4
  226. package/dist/FormSteps/PhoneInputStep/PhoneInputStep.d.ts +0 -11
  227. package/dist/FormSteps/RatingStep/MaterialRatingStep/MaterialRatingStep.d.ts +0 -4
  228. package/dist/FormSteps/RatingStep/RatingStep.d.ts +0 -9
  229. package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.d.ts +0 -4
  230. package/dist/FormSteps/SelectorStep/SelectorStep.d.ts +0 -9
  231. package/dist/FormSteps/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.d.ts +0 -4
  232. package/dist/FormSteps/SeparatorStep/SeparatorStep.d.ts +0 -9
  233. package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.d.ts +0 -5
  234. package/dist/FormSteps/SmartSelectStep/SmartSelectStep.d.ts +0 -35
  235. package/dist/FormSteps/Step.d.ts +0 -8
  236. package/dist/FormSteps/StepFunctions.d.ts +0 -29
  237. package/dist/FormSteps/StepHooks.d.ts +0 -55
  238. package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaEditorStep.d.ts +0 -10
  239. package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.d.ts +0 -8
  240. package/dist/FormSteps/TextAreaStep/TextAreaStep.d.ts +0 -10
  241. package/dist/FormSteps/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.d.ts +0 -4
  242. package/dist/FormSteps/TextInputStep/TextInputStep.d.ts +0 -17
  243. package/dist/FormSteps/TimePickerStep/MaterialTimePickerStep/MaterialTimePickerStep.d.ts +0 -4
  244. package/dist/FormSteps/TimePickerStep/TimePickerStep.d.ts +0 -12
  245. package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.d.ts +0 -4
  246. package/dist/FormSteps/TitleStep/TitleStep.d.ts +0 -9
  247. package/dist/FormSteps/Utils/@StepFiller/StepFiller.d.ts +0 -9
  248. package/dist/FormSteps/Utils/MaterialInputContainer/MaterialInputContainer.d.ts +0 -12
  249. package/dist/Icons/@IconTypes.d.ts +0 -7
  250. package/dist/Icons/CalendarIcon.d.ts +0 -4
  251. package/dist/Icons/Construction/LeakIcon.d.ts +0 -3
  252. package/dist/Icons/Construction/ProjectIcon.d.ts +0 -3
  253. package/dist/Icons/Construction/PropertyIcon.d.ts +0 -3
  254. package/dist/Icons/Construction/SpaceIcon.d.ts +0 -3
  255. package/dist/Icons/DocumentIcon.d.ts +0 -3
  256. package/dist/Icons/Entities/CheckListIcon.d.ts +0 -3
  257. package/dist/Icons/Entities/GenericEntityIcon.d.ts +0 -3
  258. package/dist/Icons/Entities/HandshakeIcon.d.ts +0 -3
  259. package/dist/Icons/Entities/SupplierIcon.d.ts +0 -3
  260. package/dist/Icons/LocationIcon.d.ts +0 -4
  261. package/dist/Icons/PersonIcon.d.ts +0 -4
  262. package/dist/Services/FileService.d.ts +0 -5
  263. package/dist/Services/FormService.d.ts +0 -5
  264. package/dist/Services/OrganizationService.d.ts +0 -2
  265. package/dist/Shared/CustomBtn/CustomBtn.d.ts +0 -18
  266. package/dist/Shared/InputIcon/InputIcon.d.ts +0 -7
  267. package/dist/Shared/Loader/Loader.d.ts +0 -18
  268. package/dist/Shared/Navbar/Navbar.d.ts +0 -9
  269. package/dist/Shared/Navbar/Navbar.stories.d.ts +0 -13
  270. package/dist/Shared/Rating/Rating.d.ts +0 -15
  271. package/dist/Shared/Rating/Rating.stories.d.ts +0 -15
  272. package/dist/Shared/Rating/Ratings/LikeRating.d.ts +0 -4
  273. package/dist/Shared/Rating/Ratings/SatisfactionRating.d.ts +0 -4
  274. package/dist/Shared/Rating/Ratings/ScaleRating.d.ts +0 -4
  275. package/dist/Shared/RoundedButton/RoundedButton.d.ts +0 -30
  276. package/dist/Shared/RoundedButton/RoundedButton.js +0 -45
  277. package/dist/Shared/RoundedButton/RoundedButton.stories.d.ts +0 -23
  278. package/dist/Shared/RoundedCheckBox/RoundedCheckBox.d.ts +0 -24
  279. package/dist/Shared/RoundedCheckBox/RoundedCheckBox.js +0 -101
  280. package/dist/Shared/RoundedCheckBox/RoundedCheckBox.stories.d.ts +0 -21
  281. package/dist/Shared/RoundedCheckBox/RoundedCheckBox.stories.js +0 -50
  282. package/dist/Shared/RoundedDatePicker/RoundedDatePicker.d.ts +0 -49
  283. package/dist/Shared/RoundedDatePicker/RoundedDatePicker.js +0 -351
  284. package/dist/Shared/RoundedDatePicker/RoundedDatePicker.stories.d.ts +0 -36
  285. package/dist/Shared/RoundedDatePicker/RoundedDatePicker.stories.js +0 -223
  286. package/dist/Shared/RoundedPhoneInput/RoundedPhoneInput.d.ts +0 -43
  287. package/dist/Shared/RoundedPhoneInput/RoundedPhoneInput.js +0 -226
  288. package/dist/Shared/RoundedSelect/RoundedSelect.d.ts +0 -68
  289. package/dist/Shared/RoundedSelect/RoundedSelect.js +0 -214
  290. package/dist/Shared/RoundedSelect/RoundedSelect.stories.d.ts +0 -28
  291. package/dist/Shared/RoundedSelect/RoundedSelect.stories.js +0 -91
  292. package/dist/Shared/RoundedSmartSelect/RoundedSmartSelect.d.ts +0 -63
  293. package/dist/Shared/RoundedSmartSelect/RoundedSmartSelect.js +0 -236
  294. package/dist/Shared/RoundedSmartSelect/RoundedSmartSelect.stories.d.ts +0 -36
  295. package/dist/Shared/RoundedSmartSelect/RoundedSmartSelect.stories.js +0 -318
  296. package/dist/Shared/RoundedTextField/RoundedTextField.d.ts +0 -45
  297. package/dist/Shared/RoundedTextField/RoundedTextField.js +0 -175
  298. package/dist/Shared/RoundedTextField/RoundedTextField.stories.d.ts +0 -37
  299. package/dist/Shared/RoundedTextField/RoundedTextField.stories.js +0 -224
  300. package/dist/Shared/RoundedTimePicker/RoundedTimePicker.d.ts +0 -41
  301. package/dist/Shared/RoundedTimePicker/RoundedTimePicker.js +0 -314
  302. package/dist/Shared/Toggle/Toggle.d.ts +0 -18
  303. package/dist/States/GlobalSlice.d.ts +0 -46
  304. package/dist/States/SiteSlice.d.ts +0 -95
  305. package/dist/States/WidthStatsSlice.d.ts +0 -7
  306. package/dist/Utils/AxiosAPI.d.ts +0 -2
  307. package/dist/Utils/AxiosWidget.d.ts +0 -2
  308. package/dist/Utils/CBRFunctions.d.ts +0 -8
  309. package/dist/Utils/DraftFunctions.d.ts +0 -56
  310. package/dist/Utils/FormStepFunctions.d.ts +0 -15
  311. package/dist/Utils/MaterialProviders.d.ts +0 -6
  312. package/dist/Utils/PhoneFunctions.d.ts +0 -2
  313. package/dist/Utils/TestUtils.d.ts +0 -77
  314. package/dist/Utils/store.d.ts +0 -27
  315. package/dist/Widget.d.ts +0 -1
  316. package/dist/__mocks__/axios.d.ts +0 -2
  317. package/dist/__mocks__/axios.js +0 -2
  318. package/dist/constants/AYFFormStepTypes.d.ts +0 -9
  319. package/dist/constants/CBRFormStepTypes.d.ts +0 -21
  320. package/dist/constants/ConditionTypes.d.ts +0 -27
  321. package/dist/constants/Draft/DraftEntityDataTypes.d.ts +0 -11
  322. package/dist/constants/Draft/DraftEntityTypes.d.ts +0 -3
  323. package/dist/constants/Draft/DraftStyleTypes.d.ts +0 -7
  324. package/dist/constants/EntityPropertyTypes.d.ts +0 -10
  325. package/dist/constants/Files/FileExtensions.d.ts +0 -3
  326. package/dist/constants/Files/FileMaxSize.d.ts +0 -2
  327. package/dist/constants/FormStepTypes.d.ts +0 -64
  328. package/dist/constants/IconTypes.d.ts +0 -15
  329. package/dist/constants/InternalFormStyle.d.ts +0 -3
  330. package/dist/constants/MaterialClassNameSeed.d.ts +0 -1
  331. package/dist/constants/MaterialClassNameSeed.js +0 -1
  332. package/dist/constants/TicketPropertyTypes.d.ts +0 -3
  333. package/dist/hooks.d.ts +0 -7
  334. package/dist/index.d.ts +0 -1
  335. package/dist/index.js +0 -31
  336. package/dist/index.lib.d.ts +0 -7
  337. package/dist/setupTests.d.ts +0 -1
  338. /package/dist/Shared/{RoundedTimePicker/RoundedTimePicker.module.css → ErkTimePicker/ErkTimePicker.module.css} +0 -0
  339. /package/dist/{setupTests.js → __tests__/setup.js} +0 -0
@@ -0,0 +1,454 @@
1
+ /* eslint-disable @typescript-eslint/require-await */
2
+ import { ContentState, EditorState } from 'draft-js';
3
+ import FormStepTypes, { EntityValueDataTypes } from '../constants/FormStepTypes';
4
+ import { calcDependencies, calcValue } from './FormFunctions';
5
+ import { stringToDraft } from '../Utils/DraftFunctions';
6
+ import { describe, expect, test } from 'vitest';
7
+ describe('FormFunctions', function () {
8
+ describe('calcValue', function () {
9
+ test('Empty', async () => {
10
+ const value = calcValue('idStep', {}, {}, {}, [], undefined);
11
+ expect(value).toBeUndefined();
12
+ });
13
+ test('Custom Step', async () => {
14
+ const value = calcValue('idStep', {
15
+ idStep: {
16
+ id: 'idStep',
17
+ type: 'CUSTOM',
18
+ },
19
+ }, {}, {
20
+ CUSTOM: {
21
+ calcValue: () => 'custom',
22
+ },
23
+ }, [], undefined);
24
+ expect(value).toBe('custom');
25
+ const value2 = calcValue('idStep', {
26
+ idStep: {
27
+ id: 'idStep',
28
+ type: 'CUSTOM',
29
+ },
30
+ }, {}, {
31
+ CUSTOM: {},
32
+ }, [], undefined);
33
+ expect(value2).toBeUndefined();
34
+ });
35
+ test('Base Step', async () => {
36
+ const value = calcValue('idStep', {
37
+ idStep: {
38
+ id: 'idStep',
39
+ type: FormStepTypes.TEXTINPUT,
40
+ label: '',
41
+ description: '',
42
+ idSection: 'idSection',
43
+ required: false,
44
+ size: 1,
45
+ },
46
+ }, {}, {}, [], 'Value');
47
+ expect(value).toBe('Value');
48
+ });
49
+ test('Textarea without editor', async () => {
50
+ const value = calcValue('idStep', {
51
+ idStep: {
52
+ id: 'idStep',
53
+ type: FormStepTypes.TEXTAREA,
54
+ label: '',
55
+ description: '',
56
+ idSection: 'idSection',
57
+ required: false,
58
+ hasTextEditor: false,
59
+ },
60
+ }, {}, {}, [], 'Value');
61
+ expect(value.value).toBe('Value');
62
+ expect(value.draft.blocks[0].text).toBe('Value');
63
+ });
64
+ test('Textarea with editor', async () => {
65
+ const value = calcValue('idStep', {
66
+ idStep: {
67
+ id: 'idStep',
68
+ type: FormStepTypes.TEXTAREA,
69
+ label: '',
70
+ description: '',
71
+ idSection: 'idSection',
72
+ required: false,
73
+ hasTextEditor: true,
74
+ },
75
+ }, {}, {}, [], EditorState.createWithContent(ContentState.createFromText('Value')));
76
+ expect(value.value).toBe('Value');
77
+ expect(value.draft.blocks[0].text).toBe('Value');
78
+ });
79
+ test('FileUpload', async () => {
80
+ const value = calcValue('idStep', {
81
+ idStep: {
82
+ id: 'idStep',
83
+ type: FormStepTypes.FILEUPLOAD,
84
+ label: '',
85
+ description: '',
86
+ idSection: 'idSection',
87
+ required: false,
88
+ },
89
+ }, {}, {}, [], [
90
+ {
91
+ S3Key: 'S3Key',
92
+ fileName: 'fileName',
93
+ extra: 'extra',
94
+ },
95
+ ]);
96
+ expect(value[0].S3Key).toBe('S3Key');
97
+ expect(value[0].extra).toBeUndefined();
98
+ });
99
+ test('ClassifierSelector', async () => {
100
+ const value = calcValue('idStep', {
101
+ idStep: {
102
+ id: 'idStep',
103
+ type: FormStepTypes.CLASSIFIER_SELECTOR,
104
+ },
105
+ }, {}, {}, [], {
106
+ value: 'value',
107
+ label: 'Label',
108
+ });
109
+ expect(value).toBe('value');
110
+ });
111
+ test('Selector', async () => {
112
+ const value = calcValue('idStep', {
113
+ idStep: {
114
+ id: 'idStep',
115
+ type: FormStepTypes.SELECTOR,
116
+ },
117
+ }, {}, {}, [], {
118
+ value: 'value',
119
+ label: 'Label',
120
+ });
121
+ expect(value).toBe('value');
122
+ });
123
+ test('TimePicker', async () => {
124
+ const value = calcValue('idStep', {
125
+ idStep: {
126
+ id: 'idStep',
127
+ type: FormStepTypes.TIMEPICKER,
128
+ },
129
+ }, {}, {}, [], {
130
+ days: 0,
131
+ hours: 0,
132
+ minutes: 0,
133
+ working: true,
134
+ });
135
+ expect(value.days).toBe(0);
136
+ expect(value.hours).toBe(0);
137
+ expect(value.minutes).toBe(0);
138
+ expect(value.working).toBe(true);
139
+ });
140
+ test('Title', async () => {
141
+ const deleteIds = [];
142
+ const value = calcValue('idStep', {
143
+ idStep: {
144
+ id: 'idStep',
145
+ type: FormStepTypes.TITLE,
146
+ },
147
+ }, {}, {}, deleteIds, null);
148
+ expect(value).toBeUndefined();
149
+ });
150
+ test('Collapsible', async () => {
151
+ const deleteIds = [];
152
+ const value = calcValue('idStep', {
153
+ idStep: {
154
+ id: 'idStep',
155
+ type: FormStepTypes.COLLAPSIBLE,
156
+ },
157
+ }, {}, {}, deleteIds, null);
158
+ expect(deleteIds[0]).toBe('idStep');
159
+ expect(value).toBeUndefined();
160
+ });
161
+ test('Mapper with deleted', async () => {
162
+ const value = calcValue('idStep', {
163
+ idStep: {
164
+ id: 'idStep',
165
+ type: FormStepTypes.MAPPER,
166
+ },
167
+ }, {}, {}, [], { elements: [{ deleted: true }], page: 0 });
168
+ expect(value.length).toBe(0);
169
+ });
170
+ test('Mapper', async () => {
171
+ const deleteIds = [];
172
+ const value = calcValue('idStep', {
173
+ idStep: {
174
+ id: 'idStep',
175
+ type: FormStepTypes.MAPPER,
176
+ steps: {
177
+ idSubStep: {
178
+ id: 'idSubStep',
179
+ type: FormStepTypes.TEXTINPUT,
180
+ },
181
+ },
182
+ },
183
+ }, {
184
+ mappedIdSubStep: 'subValue',
185
+ }, {}, deleteIds, {
186
+ elements: [
187
+ {
188
+ id: 'idElement',
189
+ ids: {
190
+ idSubStep: 'mappedIdSubStep',
191
+ },
192
+ originalValues: {
193
+ original: 'Original',
194
+ },
195
+ value: 'value',
196
+ },
197
+ ],
198
+ page: 0,
199
+ });
200
+ expect(value[0].id).toBe('idElement');
201
+ expect(value[0].original).toBe('Original');
202
+ expect(value[0].value).toBe('value');
203
+ expect(value[0].idSubStep).toBe('subValue');
204
+ });
205
+ });
206
+ describe('calcDependencies', function () {
207
+ test('Empty', async () => {
208
+ const dependencyStore = calcDependencies({}, {}, {});
209
+ expect(Object.keys(dependencyStore).length).toBe(0);
210
+ });
211
+ test('Basic Dependency', async () => {
212
+ const allSteps = {
213
+ idStep: {
214
+ id: 'idStep',
215
+ type: FormStepTypes.TEXTINPUT,
216
+ },
217
+ idStep2: {
218
+ id: 'idStep2',
219
+ type: FormStepTypes.TEXTINPUT,
220
+ dependencies: ['idStep'],
221
+ },
222
+ };
223
+ const dependencyStore = calcDependencies(allSteps, {}, allSteps);
224
+ expect(Object.keys(dependencyStore).length).toBe(1);
225
+ expect(dependencyStore.idStep.value).toBeNull();
226
+ expect(dependencyStore.idStep.dependents.length).toBe(1);
227
+ expect(dependencyStore.idStep.type).toBe(FormStepTypes.TEXTINPUT);
228
+ });
229
+ test('Basic Dependency with originalValue', async () => {
230
+ const allSteps = {
231
+ idStep: {
232
+ id: 'idStep',
233
+ type: FormStepTypes.TEXTINPUT,
234
+ idSection: 'FIRST',
235
+ },
236
+ idStep2: {
237
+ id: 'idStep2',
238
+ type: FormStepTypes.TEXTINPUT,
239
+ dependencies: ['idStep'],
240
+ },
241
+ };
242
+ const dependencyStore = calcDependencies(allSteps, {}, allSteps, {}, {
243
+ sections: {
244
+ FIRST: {
245
+ idStep: 'Original',
246
+ },
247
+ },
248
+ global: {},
249
+ });
250
+ expect(Object.keys(dependencyStore).length).toBe(1);
251
+ expect(dependencyStore.idStep.value).toBe('Original');
252
+ expect(dependencyStore.idStep.dependents.length).toBe(1);
253
+ expect(dependencyStore.idStep.type).toBe(FormStepTypes.TEXTINPUT);
254
+ });
255
+ test('Basic TextArea Dependency with originalValue with editor', async () => {
256
+ const allSteps = {
257
+ idStep: {
258
+ id: 'idStep',
259
+ type: FormStepTypes.TEXTAREA,
260
+ idSection: 'FIRST',
261
+ hasTextEditor: true,
262
+ },
263
+ idStep2: {
264
+ id: 'idStep2',
265
+ type: FormStepTypes.TEXTINPUT,
266
+ dependencies: ['idStep'],
267
+ },
268
+ };
269
+ const dependencyStore = calcDependencies(allSteps, {}, allSteps, {}, {
270
+ sections: {
271
+ FIRST: {
272
+ idStep: stringToDraft('Original'),
273
+ },
274
+ },
275
+ global: {},
276
+ });
277
+ expect(Object.keys(dependencyStore).length).toBe(1);
278
+ expect(dependencyStore.idStep.value).toBe('Original');
279
+ expect(dependencyStore.idStep.dependents.length).toBe(1);
280
+ expect(dependencyStore.idStep.type).toBe(FormStepTypes.TEXTAREA);
281
+ });
282
+ test('Basic TextArea Dependency with originalValue without editor', async () => {
283
+ const allSteps = {
284
+ idStep: {
285
+ id: 'idStep',
286
+ type: FormStepTypes.TEXTAREA,
287
+ idSection: 'FIRST',
288
+ hasTextEditor: false,
289
+ },
290
+ idStep2: {
291
+ id: 'idStep2',
292
+ type: FormStepTypes.TEXTINPUT,
293
+ dependencies: ['idStep'],
294
+ },
295
+ };
296
+ const dependencyStore = calcDependencies(allSteps, {}, allSteps, {}, {
297
+ sections: {
298
+ FIRST: {
299
+ idStep: 'Original',
300
+ },
301
+ },
302
+ global: {},
303
+ });
304
+ expect(Object.keys(dependencyStore).length).toBe(1);
305
+ expect(dependencyStore.idStep.value).toBe('Original');
306
+ expect(dependencyStore.idStep.dependents.length).toBe(1);
307
+ expect(dependencyStore.idStep.type).toBe(FormStepTypes.TEXTAREA);
308
+ });
309
+ test('Basic Dependency with missing originalValue', async () => {
310
+ const allSteps = {
311
+ idStep: {
312
+ id: 'idStep',
313
+ type: FormStepTypes.TEXTINPUT,
314
+ dependencies: ['idOriginal'],
315
+ },
316
+ };
317
+ const dependencyStore = calcDependencies(allSteps, {}, allSteps, {}, {
318
+ sections: {},
319
+ global: { idOriginal: 'Original' },
320
+ });
321
+ expect(Object.keys(dependencyStore).length).toBe(1);
322
+ expect(dependencyStore.idOriginal.value).toBe('Original');
323
+ expect(dependencyStore.idOriginal.dependents.length).toBe(1);
324
+ expect(dependencyStore.idOriginal.type).toBe('ORIGINAL');
325
+ });
326
+ test('Missing Dependency', async () => {
327
+ const dependencyStore = calcDependencies({
328
+ idStep: {
329
+ id: 'idStep',
330
+ type: FormStepTypes.TEXTINPUT,
331
+ dependencies: ['idMissingStep'],
332
+ },
333
+ }, {}, {});
334
+ expect(Object.keys(dependencyStore).length).toBe(1);
335
+ expect(dependencyStore.idMissingStep.value).toBeNull();
336
+ expect(dependencyStore.idMissingStep.dependents.length).toBe(1);
337
+ expect(dependencyStore.idMissingStep.type).toBe('MISSING');
338
+ });
339
+ test('Basic Dependency without dependents', async () => {
340
+ const allSteps = {
341
+ idStep: {
342
+ id: 'idStep',
343
+ type: FormStepTypes.TEXTINPUT,
344
+ },
345
+ idStep2: {
346
+ id: 'idStep2',
347
+ type: FormStepTypes.TEXTINPUT,
348
+ dependencies: ['idStep'],
349
+ },
350
+ };
351
+ const dependencyStore = calcDependencies(allSteps, {}, allSteps, {}, { global: {}, sections: {} }, false);
352
+ expect(Object.keys(dependencyStore).length).toBe(1);
353
+ expect(dependencyStore.idStep.value).toBeNull();
354
+ });
355
+ test('Double Basic Dependency', async () => {
356
+ const dependencyStore = calcDependencies({
357
+ idStep: {
358
+ id: 'idStep',
359
+ type: FormStepTypes.TEXTINPUT,
360
+ },
361
+ idStep2: {
362
+ id: 'idStep2',
363
+ type: FormStepTypes.TEXTINPUT,
364
+ dependencies: ['idStep'],
365
+ },
366
+ idStep3: {
367
+ id: 'idStep3',
368
+ type: FormStepTypes.TEXTINPUT,
369
+ dependencies: ['idStep'],
370
+ },
371
+ }, {}, {});
372
+ expect(Object.keys(dependencyStore).length).toBe(1);
373
+ expect(dependencyStore.idStep.value).toBeNull();
374
+ expect(dependencyStore.idStep.dependents.length).toBe(2);
375
+ });
376
+ test('EntityValue Dependencies', async () => {
377
+ const allSteps = {
378
+ idStep: {
379
+ id: 'idStep',
380
+ type: FormStepTypes.TEXTINPUT,
381
+ },
382
+ idStep2: {
383
+ id: 'idStep2',
384
+ type: FormStepTypes.ENTITYVALUEPICKER,
385
+ path: [
386
+ {
387
+ type: EntityValueDataTypes.STEP,
388
+ idStep: 'idStep',
389
+ },
390
+ {
391
+ type: EntityValueDataTypes.VALUE,
392
+ },
393
+ ],
394
+ filters: [
395
+ {
396
+ type: EntityValueDataTypes.STEP,
397
+ idStep: 'idMissingStep',
398
+ },
399
+ ],
400
+ dependencies: ['idMissingStep'],
401
+ options: {},
402
+ },
403
+ };
404
+ const dependencyStore = calcDependencies(allSteps, {}, allSteps);
405
+ expect(Object.keys(dependencyStore).length).toBe(2);
406
+ expect(dependencyStore.idStep.value).toBeNull();
407
+ expect(dependencyStore.idStep.dependents.length).toBe(1);
408
+ });
409
+ test('Mapper Dependencies', async () => {
410
+ const allSteps = {
411
+ idStep: {
412
+ id: 'idStep',
413
+ type: FormStepTypes.TEXTINPUT,
414
+ idSection: 'FIRST',
415
+ },
416
+ idStep2: {
417
+ id: 'idStep2',
418
+ type: FormStepTypes.MAPPER,
419
+ idSection: 'FIRST',
420
+ steps: {
421
+ idSubStep: {
422
+ id: 'idSubStep',
423
+ type: FormStepTypes.TEXTINPUT,
424
+ idSection: 'FIRST',
425
+ dependencies: ['idStep'],
426
+ },
427
+ },
428
+ },
429
+ };
430
+ const dependencyStore = calcDependencies(allSteps, {}, allSteps, {}, {
431
+ sections: {
432
+ FIRST: {
433
+ idStep2: {
434
+ elements: [
435
+ {
436
+ id: 'idElement',
437
+ ids: {
438
+ idSubStep: 'mappedIdSubStep',
439
+ },
440
+ },
441
+ ],
442
+ page: 0,
443
+ },
444
+ mappedIdSubStep: 'Original',
445
+ },
446
+ },
447
+ global: {},
448
+ });
449
+ expect(Object.keys(dependencyStore).length).toBe(1);
450
+ expect(dependencyStore.idStep.value).toBeNull();
451
+ expect(dependencyStore.idStep.dependents.length).toBe(1);
452
+ });
453
+ });
454
+ });
@@ -2,41 +2,34 @@ import { useCallback, useLayoutEffect } from 'react';
2
2
  import { updateWidthStats } from '../States/WidthStatsSlice';
3
3
  import { useAppDispatch } from '../hooks';
4
4
  export function useWidthStats(containerRef, form, postview, internal) {
5
- var calcWidthStats = useCallback(function (currentWidth) {
6
- var currentBreakPoint = form.size.blockNum;
7
- var padding = postview || internal || !form.isStandAlone ? 0 : 40;
8
- while (currentWidth <
9
- (form.size.blockSize + form.size.spacingSize) *
10
- currentBreakPoint +
11
- padding) {
5
+ const calcWidthStats = useCallback((currentWidth) => {
6
+ let currentBreakPoint = form.size.blockNum;
7
+ const padding = postview || internal || !form.isStandAlone ? 0 : 40;
8
+ while (currentWidth < (form.size.blockSize + form.size.spacingSize) * currentBreakPoint + padding) {
12
9
  currentBreakPoint--;
13
10
  }
14
11
  return {
15
- isResponsive: currentWidth <
16
- (form.size.blockSize + form.size.spacingSize) *
17
- form.size.blockNum +
18
- padding,
19
- isMobile: currentWidth <
20
- (form.size.blockSize + form.size.spacingSize) * 2 + padding,
21
- currentBreakPoint: currentBreakPoint,
12
+ isResponsive: currentWidth < (form.size.blockSize + form.size.spacingSize) * form.size.blockNum + padding,
13
+ isMobile: currentWidth < (form.size.blockSize + form.size.spacingSize) * 2 + padding,
14
+ currentBreakPoint,
22
15
  };
23
16
  }, [form, postview, internal]);
24
- var dispatch = useAppDispatch();
17
+ const dispatch = useAppDispatch();
25
18
  /** Calcs the currentBreakPoint and if is mobile */
26
- useLayoutEffect(function () {
27
- var handleResize = function () {
28
- var _a;
29
- var currentWidth = (_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth;
19
+ useLayoutEffect(() => {
20
+ const handleResize = () => {
21
+ const currentWidth = containerRef?.current?.offsetWidth;
30
22
  if (currentWidth !== undefined) {
31
- var current = calcWidthStats(currentWidth);
23
+ const current = calcWidthStats(currentWidth);
32
24
  dispatch(updateWidthStats(current));
33
25
  }
34
26
  };
35
27
  /** On load add a resize listener to calc the currentBreakpoint */
36
28
  window.addEventListener('resize', handleResize);
37
29
  handleResize();
38
- return function () {
30
+ return () => {
39
31
  window.removeEventListener('resize', handleResize);
40
32
  };
33
+ // eslint-disable-next-line react-hooks/exhaustive-deps
41
34
  }, []);
42
35
  }
@@ -1,61 +1,3 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- var __rest = (this && this.__rest) || function (s, e) {
49
- var t = {};
50
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
- t[p] = s[p];
52
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
- t[p[i]] = s[p[i]];
56
- }
57
- return t;
58
- };
59
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
60
2
  import { useCallback, useContext, useEffect, useState } from 'react';
61
3
  import styles from './ColumnForm.module.css';
@@ -66,60 +8,47 @@ import { useAppDispatch, useAppSelector } from '../../../hooks';
66
8
  import Section from '../../Section/Section';
67
9
  import CustomContext from '../../../Contexts/CustomContext';
68
10
  import CustomBtn from '../../../Shared/CustomBtn/CustomBtn';
69
- import FormContext from '../../../Contexts/FormContext';
11
+ import FormContext, { IdFormContext } from '../../../Contexts/FormContext';
70
12
  import { addPagedValues } from '../../../States/SiteSlice';
71
13
  import { getAppState } from '../../../Utils/store';
72
- import { IdFormContext } from '../../../App/App';
73
- function ColumnForm(_a) {
74
- var _this = this;
75
- var onSubmit = _a.onSubmit, customSubmitBtns = _a.customSubmitBtns, props = __rest(_a, ["onSubmit", "customSubmitBtns"]);
76
- var _b = useState(false), loading = _b[0], setLoading = _b[1];
77
- var _c = useAppSelector(function (state) { return state.global; }), postview = _c.postview, editable = _c.editable, formStyle = _c.formStyle;
78
- var _d = useFormContext(), trigger = _d.trigger, getValues = _d.getValues, handleSubmit = _d.handleSubmit;
79
- var sendLabel = useContext(CustomContext).sendLabel;
80
- var form = useContext(FormContext);
81
- var dispatch = useAppDispatch();
82
- var idForm = useContext(IdFormContext);
83
- var previous = useAppSelector(function (state) { return state.site.previousSections; });
84
- var next = useAppSelector(function (state) { return state.site.nextSections; });
85
- var idCurrent = useAppSelector(function (state) { return state.site.idCurrentSection; });
86
- useEffect(function () {
14
+ function ColumnForm({ onSubmit, customSubmitBtns, ...props }) {
15
+ const [loading, setLoading] = useState(false);
16
+ const { postview, editable, formStyle } = useAppSelector((state) => state.global);
17
+ const { trigger, getValues, handleSubmit } = useFormContext();
18
+ const { sendLabel } = useContext(CustomContext);
19
+ const form = useContext(FormContext);
20
+ const dispatch = useAppDispatch();
21
+ const idForm = useContext(IdFormContext);
22
+ const previous = useAppSelector((state) => state.site.previousSections);
23
+ const next = useAppSelector((state) => state.site.nextSections);
24
+ const idCurrent = useAppSelector((state) => state.site.idCurrentSection);
25
+ useEffect(() => {
87
26
  if (props.setSubmit)
88
27
  props.setSubmit(submit);
28
+ // eslint-disable-next-line react-hooks/exhaustive-deps
89
29
  }, [props.setSubmit]);
90
30
  /** Esto se usa para no tener que escuchar todo el tiempo los errores del formulario */
91
- var handleErrors = handleSubmit(function () { }, function (errors) {
31
+ const handleErrors = handleSubmit(() => { }, (errors) => {
92
32
  console.error('Errors:', errors);
93
33
  });
94
- var submit = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
95
- var valid, values, state;
96
- return __generator(this, function (_a) {
97
- switch (_a.label) {
98
- case 0:
99
- setLoading(true);
100
- return [4 /*yield*/, trigger(undefined, { shouldFocus: true })];
101
- case 1:
102
- valid = _a.sent();
103
- /** Imprimir errores si no es valido */
104
- if (!valid) {
105
- handleErrors();
106
- return [2 /*return*/, setLoading(false)];
107
- }
108
- values = getValues();
109
- if (!idCurrent) return [3 /*break*/, 3];
110
- return [4 /*yield*/, dispatch(getAppState({ idForm: idForm })).unwrap()];
111
- case 2:
112
- state = _a.sent();
113
- addPagedValues(form.steps, values, state.site.values.sections[idCurrent]);
114
- _a.label = 3;
115
- case 3: return [4 /*yield*/, onSubmit(values)];
116
- case 4:
117
- values = _a.sent();
118
- setLoading(false);
119
- return [2 /*return*/, values];
120
- }
121
- });
122
- }); }, [form]);
123
- return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }), previous.map(function (idSection) { return (_jsx(Section, { idSection: idSection }, idSection)); }), next.map(function (idSection) { return (_jsx(Section, { idSection: idSection }, idSection)); }), _jsx(Terms, {}), !postview && editable && (_jsxs(React.Fragment, { children: [customSubmitBtns === undefined && (_jsx("div", __assign({ className: styles.submitBtnContainer }, { children: _jsx(CustomBtn, { onClick: submit, width: "calc(100% - 70px)", label: sendLabel !== null && sendLabel !== void 0 ? sendLabel : 'Enviar', backgroundColor: formStyle.primaryColor, color: formStyle.primaryContrastColor, loading: loading, "data-testid": "form__submit" }) }))), customSubmitBtns === null || customSubmitBtns === void 0 ? void 0 : customSubmitBtns(submit, loading)] }))] })));
34
+ const submit = useCallback(async () => {
35
+ setLoading(true);
36
+ const valid = await trigger(undefined, { shouldFocus: true });
37
+ /** Imprimir errores si no es valido */
38
+ if (!valid) {
39
+ void handleErrors();
40
+ return setLoading(false);
41
+ }
42
+ let values = getValues();
43
+ if (idCurrent) {
44
+ const state = await dispatch(getAppState({ idForm })).unwrap();
45
+ addPagedValues(form.steps, values, state.site.values.sections[idCurrent]);
46
+ }
47
+ values = await onSubmit(values);
48
+ setLoading(false);
49
+ return values;
50
+ // eslint-disable-next-line react-hooks/exhaustive-deps
51
+ }, [form]);
52
+ return (_jsxs("div", { className: styles.container, style: { color: formStyle.textColor }, children: [loading && _jsx("div", { className: styles.curtain }), previous.map((idSection) => (_jsx(Section, { idSection: idSection }, idSection))), next.map((idSection) => (_jsx(Section, { idSection: idSection }, idSection))), _jsx(Terms, {}), !postview && editable && (_jsxs(React.Fragment, { children: [customSubmitBtns === undefined && (_jsx("div", { className: styles.submitBtnContainer, children: _jsx(CustomBtn, { onClick: () => void submit(), width: "calc(100% - 70px)", label: sendLabel ?? 'Enviar', backgroundColor: formStyle.primaryColor, color: formStyle.primaryContrastColor, loading: loading, "data-testid": "form__submit" }) })), customSubmitBtns?.(submit, loading)] }))] }));
124
53
  }
125
54
  export default ColumnForm;