@digigov/form 2.0.0-0edebf87 → 2.0.0-13876dba

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 (807) hide show
  1. package/Field/ErrorGroup/index.js +48 -0
  2. package/{Questions/index.spec → Field/ErrorGroup}/package.json +1 -1
  3. package/Field/ErrorGroup.d.ts +15 -0
  4. package/Field/ErrorGroup.js.map +7 -0
  5. package/Field/FieldBase/index.js +112 -77
  6. package/Field/FieldBase.js.map +7 -0
  7. package/Field/FieldBaseContainer/index.js +30 -37
  8. package/Field/FieldBaseContainer.js.map +7 -0
  9. package/Field/FieldConditional/index.js +79 -53
  10. package/Field/FieldConditional.js.map +7 -0
  11. package/Field/index.js +107 -63
  12. package/Field/index.js.map +7 -0
  13. package/Field/types/index.js +1 -1
  14. package/Field/types.d.ts +45 -5
  15. package/Field/types.js.map +7 -0
  16. package/Field/utils/calculateField/index.js +27 -0
  17. package/{FieldArray/FieldArray.stories → Field/utils/calculateField}/package.json +1 -1
  18. package/Field/utils/calculateField.d.ts +2 -0
  19. package/Field/utils/calculateField.js.map +7 -0
  20. package/Field/utils/evaluateFieldWithConditions/index.js +26 -0
  21. package/{inputs/DateInput/__stories__/Default → Field/utils/evaluateFieldWithConditions}/package.json +1 -1
  22. package/Field/utils/evaluateFieldWithConditions.d.ts +2 -0
  23. package/Field/utils/evaluateFieldWithConditions.js.map +7 -0
  24. package/Field/utils/index.d.ts +4 -0
  25. package/Field/utils/index.js +46 -115
  26. package/Field/utils/index.js.map +7 -0
  27. package/Field/utils/useField/index.js +57 -0
  28. package/{FormBuilder/FormBuilder → Field/utils/useField}/package.json +1 -1
  29. package/Field/utils/useField.d.ts +2 -0
  30. package/Field/utils/useField.js.map +7 -0
  31. package/FieldArray/FieldArray.stories.d.ts +3 -2
  32. package/FieldArray/FormDialog/index.js +279 -0
  33. package/{validators/validators.spec → FieldArray/FormDialog}/package.json +1 -1
  34. package/FieldArray/FormDialog.d.ts +53 -0
  35. package/FieldArray/FormDialog.js.map +7 -0
  36. package/FieldArray/__stories__/Default.d.ts +2 -2
  37. package/FieldArray/__stories__/WithExactLength.d.ts +2 -2
  38. package/FieldArray/__stories__/WithModal.d.ts +2 -0
  39. package/FieldArray/index.d.ts +6 -0
  40. package/FieldArray/index.js +108 -59
  41. package/FieldArray/index.js.map +7 -0
  42. package/FieldArray/index.test.d.ts +1 -0
  43. package/FieldObject/index.d.ts +5 -0
  44. package/FieldObject/index.js +74 -52
  45. package/FieldObject/index.js.map +7 -0
  46. package/Fieldset/FieldsetWithContext/index.js +27 -31
  47. package/Fieldset/FieldsetWithContext.js.map +7 -0
  48. package/Fieldset/index.d.ts +1 -1
  49. package/Fieldset/index.js +27 -29
  50. package/Fieldset/index.js.map +7 -0
  51. package/Fieldset/types/index.js +1 -1
  52. package/Fieldset/types.d.ts +3 -2
  53. package/Fieldset/types.js.map +7 -0
  54. package/FormBuilder/FormBuilder.stories.d.ts +5 -1
  55. package/FormBuilder/__stories__/AutoErrorGrouping.d.ts +3 -0
  56. package/FormBuilder/__stories__/Default.d.ts +2 -2
  57. package/FormBuilder/__stories__/ErrorGrouping.d.ts +3 -0
  58. package/FormBuilder/index.d.ts +8 -1
  59. package/FormBuilder/index.js +237 -2
  60. package/FormBuilder/index.js.map +7 -0
  61. package/FormBuilder/index.test.d.ts +1 -0
  62. package/FormBuilder/interaction.test.d.ts +1 -0
  63. package/FormBuilder/scenarios.test.d.ts +88 -0
  64. package/FormContext/index.js +7 -3
  65. package/FormContext.js.map +7 -0
  66. package/MultiplicityField/MultiplicityField.stories.d.ts +8 -6
  67. package/MultiplicityField/__stories__/Default.d.ts +2 -2
  68. package/MultiplicityField/__stories__/PreviewDisplay.d.ts +2 -2
  69. package/MultiplicityField/__stories__/WithExactLength.d.ts +2 -2
  70. package/MultiplicityField/__stories__/WithMaxLength.d.ts +2 -2
  71. package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +2 -2
  72. package/MultiplicityField/__stories__/WithMinLength.d.ts +2 -2
  73. package/MultiplicityField/add-objects/index.js +137 -132
  74. package/MultiplicityField/add-objects.d.ts +2 -1
  75. package/MultiplicityField/add-objects.js.map +7 -0
  76. package/MultiplicityField/index.d.ts +2 -19
  77. package/MultiplicityField/index.js +114 -106
  78. package/MultiplicityField/index.js.map +7 -0
  79. package/MultiplicityField/index.test.d.ts +1 -0
  80. package/MultiplicityField/types/index.js +1 -0
  81. package/MultiplicityField/types/package.json +6 -0
  82. package/MultiplicityField/types.d.ts +18 -0
  83. package/MultiplicityField/types.js.map +7 -0
  84. package/Questions/Questions/index.js +48 -56
  85. package/Questions/Questions.js.map +7 -0
  86. package/Questions/Questions.stories.d.ts +3 -1
  87. package/Questions/QuestionsContext/index.js +9 -9
  88. package/Questions/QuestionsContext.d.ts +0 -1
  89. package/Questions/QuestionsContext.js.map +7 -0
  90. package/Questions/Step/ReviewStep/index.js +35 -47
  91. package/Questions/Step/ReviewStep.js.map +7 -0
  92. package/Questions/Step/Step/index.js +39 -47
  93. package/Questions/Step/Step.js.map +7 -0
  94. package/Questions/Step/StepArrayReview/index.js +41 -45
  95. package/Questions/Step/StepArrayReview.js.map +7 -0
  96. package/Questions/Step/StepContext/index.js +15 -19
  97. package/Questions/Step/StepContext.d.ts +0 -1
  98. package/Questions/Step/StepContext.js.map +7 -0
  99. package/Questions/Step/StepDescription/index.js +22 -22
  100. package/Questions/Step/StepDescription.js.map +7 -0
  101. package/Questions/Step/StepForm/index.js +33 -43
  102. package/Questions/Step/StepForm.js.map +7 -0
  103. package/Questions/Step/StepQuote/index.js +10 -9
  104. package/Questions/Step/StepQuote.js.map +7 -0
  105. package/Questions/Step/StepTitle/index.js +41 -38
  106. package/Questions/Step/StepTitle.d.ts +2 -1
  107. package/Questions/Step/StepTitle.js.map +7 -0
  108. package/Questions/Step/getAddMoreFields/index.js +28 -20
  109. package/Questions/Step/getAddMoreFields.js.map +7 -0
  110. package/Questions/Step/index.d.ts +0 -1
  111. package/Questions/Step/index.js +16 -13
  112. package/Questions/Step/index.js.map +7 -0
  113. package/Questions/Step/types/index.js +1 -1
  114. package/Questions/Step/types.d.ts +1 -0
  115. package/Questions/Step/types.js.map +7 -0
  116. package/Questions/__stories__/Default.d.ts +2 -2
  117. package/Questions/getNextStep/index.js +12 -10
  118. package/Questions/getNextStep.js.map +7 -0
  119. package/Questions/index.js +7 -3
  120. package/Questions/index.js.map +7 -0
  121. package/Questions/index.test.d.ts +1 -0
  122. package/Questions/types/index.js +1 -1
  123. package/Questions/types.d.ts +1 -0
  124. package/Questions/types.js.map +7 -0
  125. package/cjs/Field/ErrorGroup/index.js +82 -0
  126. package/cjs/Field/ErrorGroup.js.map +7 -0
  127. package/cjs/Field/FieldBase/index.js +144 -83
  128. package/cjs/Field/FieldBase.js.map +7 -0
  129. package/cjs/Field/FieldBaseContainer/index.js +62 -43
  130. package/cjs/Field/FieldBaseContainer.js.map +7 -0
  131. package/cjs/Field/FieldConditional/index.js +111 -59
  132. package/cjs/Field/FieldConditional.js.map +7 -0
  133. package/cjs/Field/index.js +136 -72
  134. package/cjs/Field/index.js.map +7 -0
  135. package/cjs/Field/types/index.js +16 -5
  136. package/cjs/Field/types.js.map +7 -0
  137. package/cjs/Field/utils/calculateField/index.js +50 -0
  138. package/cjs/Field/utils/calculateField.js.map +7 -0
  139. package/cjs/Field/utils/evaluateFieldWithConditions/index.js +49 -0
  140. package/cjs/Field/utils/evaluateFieldWithConditions.js.map +7 -0
  141. package/cjs/Field/utils/index.js +90 -133
  142. package/cjs/Field/utils/index.js.map +7 -0
  143. package/cjs/Field/utils/useField/index.js +80 -0
  144. package/cjs/Field/utils/useField.js.map +7 -0
  145. package/cjs/FieldArray/FormDialog/index.js +301 -0
  146. package/cjs/FieldArray/FormDialog.js.map +7 -0
  147. package/cjs/FieldArray/index.js +140 -65
  148. package/cjs/FieldArray/index.js.map +7 -0
  149. package/cjs/FieldObject/index.js +103 -61
  150. package/cjs/FieldObject/index.js.map +7 -0
  151. package/cjs/Fieldset/FieldsetWithContext/index.js +54 -40
  152. package/cjs/Fieldset/FieldsetWithContext.js.map +7 -0
  153. package/cjs/Fieldset/index.js +61 -39
  154. package/cjs/Fieldset/index.js.map +7 -0
  155. package/cjs/Fieldset/types/index.js +16 -5
  156. package/cjs/Fieldset/types.js.map +7 -0
  157. package/cjs/FormBuilder/index.js +273 -8
  158. package/cjs/FormBuilder/index.js.map +7 -0
  159. package/cjs/FormContext/index.js +29 -8
  160. package/cjs/FormContext.js.map +7 -0
  161. package/cjs/MultiplicityField/add-objects/index.js +164 -138
  162. package/cjs/MultiplicityField/add-objects.js.map +7 -0
  163. package/cjs/MultiplicityField/index.js +142 -115
  164. package/cjs/MultiplicityField/index.js.map +7 -0
  165. package/cjs/MultiplicityField/types/index.js +16 -0
  166. package/cjs/MultiplicityField/types.js.map +7 -0
  167. package/cjs/Questions/Questions/index.js +80 -65
  168. package/cjs/Questions/Questions.js.map +7 -0
  169. package/cjs/Questions/QuestionsContext/index.js +31 -14
  170. package/cjs/Questions/QuestionsContext.js.map +7 -0
  171. package/cjs/Questions/Step/ReviewStep/index.js +61 -56
  172. package/cjs/Questions/Step/ReviewStep.js.map +7 -0
  173. package/cjs/Questions/Step/Step/index.js +71 -56
  174. package/cjs/Questions/Step/Step.js.map +7 -0
  175. package/cjs/Questions/Step/StepArrayReview/index.js +65 -54
  176. package/cjs/Questions/Step/StepArrayReview.js.map +7 -0
  177. package/cjs/Questions/Step/StepContext/index.js +37 -24
  178. package/cjs/Questions/Step/StepContext.js.map +7 -0
  179. package/cjs/Questions/Step/StepDescription/index.js +55 -31
  180. package/cjs/Questions/Step/StepDescription.js.map +7 -0
  181. package/cjs/Questions/Step/StepForm/index.js +65 -52
  182. package/cjs/Questions/Step/StepForm.js.map +7 -0
  183. package/cjs/Questions/Step/StepQuote/index.js +42 -15
  184. package/cjs/Questions/Step/StepQuote.js.map +7 -0
  185. package/cjs/Questions/Step/StepTitle/index.js +72 -47
  186. package/cjs/Questions/Step/StepTitle.js.map +7 -0
  187. package/cjs/Questions/Step/getAddMoreFields/index.js +50 -25
  188. package/cjs/Questions/Step/getAddMoreFields.js.map +7 -0
  189. package/cjs/Questions/Step/index.js +59 -143
  190. package/cjs/Questions/Step/index.js.map +7 -0
  191. package/cjs/Questions/Step/types/index.js +16 -5
  192. package/cjs/Questions/Step/types.js.map +7 -0
  193. package/cjs/Questions/getNextStep/index.js +33 -14
  194. package/cjs/Questions/getNextStep.js.map +7 -0
  195. package/cjs/Questions/index.js +29 -19
  196. package/cjs/Questions/index.js.map +7 -0
  197. package/cjs/Questions/types/index.js +16 -5
  198. package/cjs/Questions/types.js.map +7 -0
  199. package/cjs/index.js +47 -20
  200. package/cjs/index.js.map +7 -0
  201. package/cjs/inputs/AutoCompleteInput/index.js +92 -60
  202. package/cjs/inputs/AutoCompleteInput/index.js.map +7 -0
  203. package/cjs/inputs/Checkboxes/index.js +102 -96
  204. package/cjs/inputs/Checkboxes/index.js.map +7 -0
  205. package/cjs/inputs/DateInput/index.js +124 -109
  206. package/cjs/inputs/DateInput/index.js.map +7 -0
  207. package/cjs/inputs/DateTimeInput/index.js +211 -0
  208. package/cjs/inputs/DateTimeInput/index.js.map +7 -0
  209. package/cjs/inputs/FileInput/index.js +90 -63
  210. package/cjs/inputs/FileInput/index.js.map +7 -0
  211. package/cjs/inputs/ImageInput/index.js +96 -83
  212. package/cjs/inputs/ImageInput/index.js.map +7 -0
  213. package/cjs/inputs/Input/index.js +106 -71
  214. package/cjs/inputs/Input/index.js.map +7 -0
  215. package/cjs/inputs/Input/inputsInputScenarios/index.js +439 -0
  216. package/cjs/inputs/Input/inputsInputScenarios.js.map +7 -0
  217. package/cjs/inputs/Label/index.js +45 -24
  218. package/cjs/inputs/Label/index.js.map +7 -0
  219. package/cjs/inputs/OtpInput/index.js +143 -113
  220. package/cjs/inputs/OtpInput/index.js.map +7 -0
  221. package/cjs/inputs/Radio/index.js +131 -61
  222. package/cjs/inputs/Radio/index.js.map +7 -0
  223. package/cjs/inputs/Select/index.js +60 -36
  224. package/cjs/inputs/Select/index.js.map +7 -0
  225. package/cjs/inputs/index.js +62 -69
  226. package/cjs/inputs/index.js.map +7 -0
  227. package/cjs/inputs/inputsScenarios/index.js +533 -0
  228. package/cjs/inputs/inputsScenarios.js.map +7 -0
  229. package/cjs/internal/index.js +36 -346
  230. package/cjs/internal.js.map +7 -0
  231. package/cjs/lazy/index.js +109 -516
  232. package/cjs/lazy.js.map +7 -0
  233. package/cjs/locales/el/index.js +35 -0
  234. package/cjs/locales/el.js.map +7 -0
  235. package/cjs/registry/index.js +190 -142
  236. package/cjs/registry.js.map +7 -0
  237. package/cjs/types/index.js +22 -5
  238. package/cjs/types.js.map +7 -0
  239. package/cjs/utils/index.js +79 -83
  240. package/cjs/utils.js.map +7 -0
  241. package/cjs/validators/index.js +131 -164
  242. package/cjs/validators/index.js.map +7 -0
  243. package/cjs/validators/types/index.js +16 -5
  244. package/cjs/validators/types.js.map +7 -0
  245. package/cjs/validators/utils/afm/index.js +38 -21
  246. package/cjs/validators/utils/afm.js.map +7 -0
  247. package/cjs/validators/utils/date/index.js +138 -0
  248. package/cjs/validators/utils/date.js.map +7 -0
  249. package/cjs/validators/utils/datetime/index.js +151 -0
  250. package/cjs/validators/utils/datetime.js.map +7 -0
  251. package/cjs/validators/utils/file/index.js +44 -39
  252. package/cjs/validators/utils/file.js.map +7 -0
  253. package/cjs/validators/utils/iban/index.js +36 -17
  254. package/cjs/validators/utils/iban.js.map +7 -0
  255. package/cjs/validators/utils/image/index.js +88 -112
  256. package/cjs/validators/utils/image.js.map +7 -0
  257. package/cjs/validators/utils/index.js +99 -159
  258. package/cjs/validators/utils/index.js.map +7 -0
  259. package/cjs/validators/utils/int/index.js +35 -13
  260. package/cjs/validators/utils/int.js.map +7 -0
  261. package/cjs/validators/utils/number/index.js +34 -12
  262. package/cjs/validators/utils/number.js.map +7 -0
  263. package/cjs/validators/utils/otp/index.js +35 -13
  264. package/cjs/validators/utils/otp.js.map +7 -0
  265. package/cjs/validators/utils/phone/index.js +113 -58
  266. package/cjs/validators/utils/phone.js.map +7 -0
  267. package/cjs/validators/utils/postal_code/index.js +36 -16
  268. package/cjs/validators/utils/postal_code.js.map +7 -0
  269. package/cjs/validators/utils/text_limit/index.js +40 -25
  270. package/cjs/validators/utils/text_limit.js.map +7 -0
  271. package/cjs/validators/utils/uuid4/index.js +34 -13
  272. package/cjs/validators/utils/uuid4.js.map +7 -0
  273. package/index.d.ts +4 -1
  274. package/index.js +13 -4
  275. package/index.js.map +7 -0
  276. package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +4 -2
  277. package/inputs/AutoCompleteInput/__stories__/Default.d.ts +2 -2
  278. package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +2 -2
  279. package/inputs/AutoCompleteInput/index.d.ts +1 -1
  280. package/inputs/AutoCompleteInput/index.js +62 -51
  281. package/inputs/AutoCompleteInput/index.js.map +7 -0
  282. package/inputs/AutoCompleteInput/index.test.d.ts +1 -0
  283. package/inputs/Checkboxes/Checkboxes.stories.d.ts +5 -3
  284. package/inputs/Checkboxes/__stories__/Conditional.d.ts +2 -2
  285. package/inputs/Checkboxes/__stories__/Default.d.ts +2 -2
  286. package/inputs/Checkboxes/__stories__/WithDivider.d.ts +2 -2
  287. package/inputs/Checkboxes/index.d.ts +2 -1
  288. package/inputs/Checkboxes/index.js +74 -87
  289. package/inputs/Checkboxes/index.js.map +7 -0
  290. package/inputs/Checkboxes/index.test.d.ts +1 -0
  291. package/inputs/DateInput/DateInput.stories.d.ts +3 -1
  292. package/inputs/DateInput/__stories__/Default.d.ts +2 -2
  293. package/inputs/DateInput/index.d.ts +3 -4
  294. package/inputs/DateInput/index.js +94 -99
  295. package/inputs/DateInput/index.js.map +7 -0
  296. package/inputs/DateInput/index.test.d.ts +1 -0
  297. package/inputs/DateTimeInput/DateTimeInput.stories.d.ts +9 -0
  298. package/inputs/DateTimeInput/__stories__/Default.d.ts +3 -0
  299. package/inputs/DateTimeInput/index.d.ts +13 -0
  300. package/inputs/DateTimeInput/index.js +181 -0
  301. package/inputs/DateTimeInput/index.js.map +7 -0
  302. package/inputs/DateTimeInput/index.test.d.ts +1 -0
  303. package/inputs/DateTimeInput/package.json +6 -0
  304. package/inputs/FileInput/FileInput.stories.d.ts +3 -1
  305. package/inputs/FileInput/__stories__/Default.d.ts +2 -2
  306. package/inputs/FileInput/index.d.ts +9 -0
  307. package/inputs/FileInput/index.js +58 -54
  308. package/inputs/FileInput/index.js.map +7 -0
  309. package/inputs/FileInput/index.test.d.ts +1 -0
  310. package/inputs/ImageInput/ImageInput.stories.d.ts +5 -3
  311. package/inputs/ImageInput/__stories__/Default.d.ts +2 -2
  312. package/inputs/ImageInput/__stories__/MaxSize.d.ts +3 -0
  313. package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +2 -2
  314. package/inputs/ImageInput/index.js +64 -75
  315. package/inputs/ImageInput/index.js.map +7 -0
  316. package/inputs/ImageInput/index.test.d.ts +1 -0
  317. package/inputs/Input/Input.stories.d.ts +13 -10
  318. package/inputs/Input/__stories__/AFM.d.ts +2 -2
  319. package/inputs/Input/__stories__/Boolean.d.ts +2 -2
  320. package/inputs/Input/__stories__/IBAN.d.ts +2 -2
  321. package/inputs/Input/__stories__/Integer.d.ts +2 -2
  322. package/inputs/Input/__stories__/LandlineNumber.d.ts +2 -2
  323. package/inputs/Input/__stories__/MobilePhone.d.ts +2 -2
  324. package/inputs/Input/__stories__/PhoneNumber.d.ts +2 -2
  325. package/inputs/Input/__stories__/PostalCode.d.ts +2 -2
  326. package/inputs/Input/__stories__/String.d.ts +3 -0
  327. package/inputs/Input/__stories__/StringWithTrimValidation.d.ts +3 -0
  328. package/inputs/Input/__stories__/TextWithLimit.d.ts +3 -0
  329. package/inputs/Input/index.js +75 -66
  330. package/inputs/Input/index.js.map +7 -0
  331. package/inputs/Input/index.test.d.ts +1 -0
  332. package/inputs/Input/inputsInputScenarios/index.js +406 -0
  333. package/{FieldArray/__stories__/Default → inputs/Input/inputsInputScenarios}/package.json +1 -1
  334. package/inputs/Input/inputsInputScenarios.d.ts +57 -0
  335. package/inputs/Input/inputsInputScenarios.js.map +7 -0
  336. package/inputs/Label/Label.stories.d.ts +3 -1
  337. package/inputs/Label/__stories__/Default.d.ts +2 -2
  338. package/inputs/Label/index.d.ts +1 -3
  339. package/inputs/Label/index.js +12 -17
  340. package/inputs/Label/index.js.map +7 -0
  341. package/inputs/Label/index.test.d.ts +1 -0
  342. package/inputs/OtpInput/OtpInput.stories.d.ts +3 -1
  343. package/inputs/OtpInput/__stories__/Default.d.ts +2 -2
  344. package/inputs/OtpInput/index.d.ts +1 -1
  345. package/inputs/OtpInput/index.js +111 -104
  346. package/inputs/OtpInput/index.js.map +7 -0
  347. package/inputs/OtpInput/index.test.d.ts +1 -0
  348. package/inputs/Radio/Radio.stories.d.ts +5 -3
  349. package/inputs/Radio/__stories__/Conditional.d.ts +2 -2
  350. package/inputs/Radio/__stories__/Default.d.ts +2 -2
  351. package/inputs/Radio/__stories__/WithDivider.d.ts +2 -2
  352. package/inputs/Radio/index.d.ts +6 -1
  353. package/inputs/Radio/index.js +102 -55
  354. package/inputs/Radio/index.js.map +7 -0
  355. package/inputs/Radio/index.test.d.ts +1 -0
  356. package/inputs/Select/Select.stories.d.ts +3 -1
  357. package/inputs/Select/__stories__/Default.d.ts +2 -2
  358. package/inputs/Select/index.d.ts +1 -1
  359. package/inputs/Select/index.js +32 -31
  360. package/inputs/Select/index.js.map +7 -0
  361. package/inputs/Select/index.test.d.ts +1 -0
  362. package/inputs/index.js +21 -9
  363. package/inputs/index.js.map +7 -0
  364. package/inputs/inputsScenarios/index.js +499 -0
  365. package/inputs/inputsScenarios/package.json +6 -0
  366. package/inputs/inputsScenarios.d.ts +296 -0
  367. package/inputs/inputsScenarios.js.map +7 -0
  368. package/internal/index.js +10 -34
  369. package/internal.d.ts +2 -31
  370. package/internal.js.map +7 -0
  371. package/lazy/index.js +75 -393
  372. package/locales/el/index.js +6 -0
  373. package/{Form.stories → locales/el}/package.json +1 -1
  374. package/locales/el.d.ts +2 -0
  375. package/locales/el.js.map +7 -0
  376. package/package.json +7 -8
  377. package/registry/index.js +126 -99
  378. package/src/Field/ErrorGroup.tsx +84 -0
  379. package/src/Field/FieldBase.tsx +35 -22
  380. package/src/Field/FieldBaseContainer.tsx +7 -4
  381. package/src/Field/FieldConditional.tsx +5 -1
  382. package/src/Field/doc.mdx +207 -0
  383. package/src/Field/index.tsx +27 -3
  384. package/src/Field/types.tsx +74 -5
  385. package/src/Field/utils/calculateField.ts +49 -0
  386. package/src/Field/utils/evaluateFieldWithConditions.ts +30 -0
  387. package/src/Field/utils/index.ts +82 -0
  388. package/src/Field/utils/useField.ts +58 -0
  389. package/src/FieldArray/FieldArray.stories.js +3 -2
  390. package/src/FieldArray/FormDialog.tsx +378 -0
  391. package/src/FieldArray/__stories__/Default.tsx +2 -1
  392. package/src/FieldArray/__stories__/WithExactLength.tsx +2 -1
  393. package/src/FieldArray/__stories__/WithModal.tsx +159 -0
  394. package/src/FieldArray/index.test.tsx +32 -0
  395. package/src/FieldArray/index.tsx +92 -39
  396. package/src/FieldObject/index.tsx +31 -10
  397. package/src/Fieldset/index.tsx +5 -5
  398. package/src/Fieldset/types.tsx +5 -3
  399. package/src/FormBuilder/FormBuilder.stories.js +6 -1
  400. package/src/FormBuilder/__stories__/AutoErrorGrouping.tsx +63 -0
  401. package/src/FormBuilder/__stories__/Default.tsx +1 -1
  402. package/src/FormBuilder/__stories__/ErrorGrouping.tsx +43 -0
  403. package/{FormBuilder/FormBuilder.mdx → src/FormBuilder/doc.mdx} +27 -35
  404. package/src/FormBuilder/index.test.tsx +32 -0
  405. package/src/FormBuilder/index.tsx +263 -1
  406. package/src/FormBuilder/interaction.test.tsx +40 -0
  407. package/src/FormBuilder/scenarios.test.tsx +1978 -0
  408. package/src/FormContext.tsx +1 -2
  409. package/src/MultiplicityField/MultiplicityField.stories.js +9 -6
  410. package/src/MultiplicityField/__stories__/Default.tsx +1 -1
  411. package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +1 -1
  412. package/src/MultiplicityField/__stories__/WithExactLength.tsx +2 -2
  413. package/src/MultiplicityField/__stories__/WithMaxLength.tsx +2 -2
  414. package/src/MultiplicityField/__stories__/WithMinAndMaxLength.tsx +2 -2
  415. package/src/MultiplicityField/__stories__/WithMinLength.tsx +2 -2
  416. package/src/MultiplicityField/add-objects.tsx +31 -15
  417. package/{MultiplicityField/MultiplicityField.mdx → src/MultiplicityField/doc.mdx} +112 -98
  418. package/src/MultiplicityField/index.test.tsx +44 -0
  419. package/src/MultiplicityField/index.tsx +21 -34
  420. package/src/MultiplicityField/types.ts +21 -0
  421. package/src/Questions/Questions.stories.js +4 -1
  422. package/src/Questions/Questions.tsx +4 -4
  423. package/src/Questions/Step/StepArrayReview.tsx +1 -1
  424. package/src/Questions/Step/StepTitle.tsx +5 -3
  425. package/src/Questions/Step/index.ts +0 -1
  426. package/src/Questions/Step/types.tsx +1 -0
  427. package/src/Questions/__snapshots__/index.spec.tsx.snap +74 -587
  428. package/src/Questions/__stories__/Default.tsx +1 -1
  429. package/src/Questions/{index.mdx → doc.mdx} +34 -57
  430. package/src/Questions/index.spec.tsx +17 -5
  431. package/src/Questions/index.test.tsx +24 -0
  432. package/src/Questions/types.tsx +1 -0
  433. package/src/create-simple-form.mdx +2 -6
  434. package/{index.mdx → src/doc.mdx} +29 -18
  435. package/src/index.ts +4 -1
  436. package/src/inputs/AutoCompleteInput/AutoComplete.stories.js +5 -2
  437. package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +3 -11
  438. package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +2 -9
  439. package/{inputs/AutoCompleteInput/index.mdx → src/inputs/AutoCompleteInput/doc.mdx} +2 -13
  440. package/src/inputs/AutoCompleteInput/index.test.tsx +28 -0
  441. package/src/inputs/AutoCompleteInput/index.tsx +38 -31
  442. package/src/inputs/Checkboxes/Checkboxes.stories.js +6 -3
  443. package/src/inputs/Checkboxes/__stories__/Conditional.tsx +1 -1
  444. package/src/inputs/Checkboxes/__stories__/Default.tsx +1 -1
  445. package/src/inputs/Checkboxes/__stories__/WithDivider.tsx +1 -1
  446. package/src/inputs/Checkboxes/{index.mdx → doc.mdx} +5 -15
  447. package/src/inputs/Checkboxes/index.test.tsx +32 -0
  448. package/src/inputs/Checkboxes/index.tsx +38 -31
  449. package/src/inputs/DateInput/DateInput.stories.js +4 -1
  450. package/src/inputs/DateInput/__stories__/Default.tsx +17 -16
  451. package/src/inputs/DateInput/{index.mdx → doc.mdx} +1 -8
  452. package/src/inputs/DateInput/index.test.tsx +24 -0
  453. package/src/inputs/DateInput/index.tsx +14 -9
  454. package/src/inputs/DateTimeInput/DateTimeInput.stories.js +11 -0
  455. package/src/inputs/DateTimeInput/__stories__/Default.tsx +25 -0
  456. package/src/inputs/DateTimeInput/doc.mdx +16 -0
  457. package/src/inputs/DateTimeInput/index.test.tsx +24 -0
  458. package/src/inputs/DateTimeInput/index.tsx +194 -0
  459. package/src/inputs/FileInput/FileInput.stories.js +4 -1
  460. package/src/inputs/FileInput/__stories__/Default.tsx +1 -1
  461. package/src/inputs/FileInput/{index.mdx → doc.mdx} +1 -5
  462. package/src/inputs/FileInput/index.test.tsx +24 -0
  463. package/src/inputs/FileInput/index.tsx +33 -10
  464. package/src/inputs/ImageInput/ImageInput.stories.js +6 -3
  465. package/src/inputs/ImageInput/__stories__/Default.tsx +1 -1
  466. package/src/inputs/ImageInput/__stories__/{WithInvalidImageSize.tsx → MaxSize.tsx} +4 -3
  467. package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +3 -1
  468. package/src/inputs/ImageInput/doc.mdx +23 -0
  469. package/src/inputs/ImageInput/index.test.tsx +32 -0
  470. package/src/inputs/ImageInput/index.tsx +17 -16
  471. package/src/inputs/Input/Input.stories.js +14 -10
  472. package/src/inputs/Input/__stories__/AFM.tsx +1 -1
  473. package/src/inputs/Input/__stories__/Boolean.tsx +1 -1
  474. package/src/inputs/Input/__stories__/IBAN.tsx +1 -1
  475. package/src/inputs/Input/__stories__/Integer.tsx +1 -1
  476. package/src/inputs/Input/__stories__/LandlineNumber.tsx +3 -2
  477. package/src/inputs/Input/__stories__/MobilePhone.tsx +2 -1
  478. package/src/inputs/Input/__stories__/PhoneNumber.tsx +2 -1
  479. package/src/inputs/Input/__stories__/PostalCode.tsx +2 -1
  480. package/src/inputs/Input/__stories__/{Default.tsx → String.tsx} +2 -2
  481. package/src/inputs/Input/__stories__/StringWithTrimValidation.tsx +26 -0
  482. package/src/inputs/Input/__stories__/{TextWithCharacterLimit.tsx → TextWithLimit.tsx} +3 -2
  483. package/src/inputs/Input/doc.mdx +56 -0
  484. package/src/inputs/Input/index.test.tsx +64 -0
  485. package/src/inputs/Input/index.tsx +41 -30
  486. package/src/inputs/Input/inputsInputScenarios.ts +404 -0
  487. package/src/inputs/Label/Label.stories.js +4 -1
  488. package/src/inputs/Label/__stories__/Default.tsx +4 -2
  489. package/src/inputs/Label/doc.mdx +14 -0
  490. package/src/inputs/Label/index.test.tsx +24 -0
  491. package/src/inputs/Label/index.tsx +3 -10
  492. package/src/inputs/OtpInput/OtpInput.stories.js +4 -1
  493. package/src/inputs/OtpInput/__stories__/Default.tsx +1 -1
  494. package/{inputs/OtpInput/index.mdx → src/inputs/OtpInput/doc.mdx} +1 -8
  495. package/src/inputs/OtpInput/index.test.tsx +24 -0
  496. package/src/inputs/OtpInput/index.tsx +3 -1
  497. package/src/inputs/Radio/Radio.stories.js +6 -3
  498. package/src/inputs/Radio/__stories__/Conditional.tsx +3 -2
  499. package/src/inputs/Radio/__stories__/Default.tsx +1 -1
  500. package/src/inputs/Radio/__stories__/WithDivider.tsx +1 -1
  501. package/{cjs/inputs/Radio/index.mdx → src/inputs/Radio/doc.mdx} +5 -15
  502. package/src/inputs/Radio/index.test.tsx +32 -0
  503. package/src/inputs/Radio/index.tsx +79 -9
  504. package/src/inputs/Select/Select.stories.js +4 -1
  505. package/src/inputs/Select/__stories__/Default.tsx +1 -1
  506. package/{inputs/Select/index.mdx → src/inputs/Select/doc.mdx} +1 -5
  507. package/src/inputs/Select/index.test.tsx +24 -0
  508. package/src/inputs/Select/index.tsx +12 -4
  509. package/src/inputs/inputsScenarios.ts +496 -0
  510. package/src/installation.mdx +2 -5
  511. package/src/internal.ts +2 -31
  512. package/src/lazy.js +76 -59
  513. package/src/locales/el.ts +3 -0
  514. package/src/registry.js +109 -89
  515. package/src/types.tsx +11 -64
  516. package/src/utils.ts +34 -33
  517. package/src/validators/index.ts +90 -84
  518. package/src/validators/utils/date.ts +107 -0
  519. package/src/validators/utils/datetime.ts +130 -0
  520. package/src/validators/utils/file.ts +5 -3
  521. package/src/validators/utils/index.ts +2 -0
  522. package/src/validators/utils/int.ts +1 -1
  523. package/src/validators/utils/number.ts +1 -1
  524. package/src/validators/utils/phone.ts +63 -72
  525. package/src/validators/utils/postal_code.ts +1 -1
  526. package/src/validators/utils/uuid4.ts +2 -1
  527. package/src/validators/validators.spec.ts +6 -40
  528. package/types/index.js +2 -1
  529. package/types.d.ts +6 -35
  530. package/types.js.map +7 -0
  531. package/utils/index.js +57 -77
  532. package/utils.js.map +7 -0
  533. package/validators/index.js +112 -150
  534. package/validators/index.js.map +7 -0
  535. package/validators/types/index.js +1 -1
  536. package/validators/types.js.map +7 -0
  537. package/validators/utils/afm/index.js +16 -16
  538. package/validators/utils/afm.js.map +7 -0
  539. package/validators/utils/date/index.js +103 -0
  540. package/validators/utils/date/package.json +6 -0
  541. package/validators/utils/date.d.ts +9 -0
  542. package/validators/utils/date.js.map +7 -0
  543. package/validators/utils/datetime/index.js +116 -0
  544. package/{Questions/Questions.stories → validators/utils/datetime}/package.json +1 -1
  545. package/validators/utils/datetime.d.ts +9 -0
  546. package/validators/utils/datetime.js.map +7 -0
  547. package/validators/utils/file/index.js +22 -34
  548. package/validators/utils/file.js.map +7 -0
  549. package/validators/utils/iban/index.js +14 -12
  550. package/validators/utils/iban.js.map +7 -0
  551. package/validators/utils/image/index.js +66 -106
  552. package/validators/utils/image.js.map +7 -0
  553. package/validators/utils/index.d.ts +2 -0
  554. package/validators/utils/index.js +56 -48
  555. package/validators/utils/index.js.map +7 -0
  556. package/validators/utils/int/index.js +13 -8
  557. package/validators/utils/int.js.map +7 -0
  558. package/validators/utils/number/index.js +12 -7
  559. package/validators/utils/number.js.map +7 -0
  560. package/validators/utils/otp/index.js +13 -8
  561. package/validators/utils/otp.js.map +7 -0
  562. package/validators/utils/phone/index.js +89 -51
  563. package/validators/utils/phone.d.ts +1 -1
  564. package/validators/utils/phone.js.map +7 -0
  565. package/validators/utils/postal_code/index.js +14 -11
  566. package/validators/utils/postal_code.d.ts +1 -1
  567. package/validators/utils/postal_code.js.map +7 -0
  568. package/validators/utils/text_limit/index.js +18 -20
  569. package/validators/utils/text_limit.js.map +7 -0
  570. package/validators/utils/uuid4/index.js +12 -8
  571. package/validators/utils/uuid4.js.map +7 -0
  572. package/Field/index.mdx +0 -6
  573. package/Field/utils.d.ts +0 -5
  574. package/FieldArray/FieldArray.stories/index.js +0 -8
  575. package/FieldArray/FieldArray.stories.playwright.json +0 -353
  576. package/FieldArray/__stories__/Default/index.js +0 -88
  577. package/FieldArray/__stories__/WithExactLength/index.js +0 -88
  578. package/FieldArray/__stories__/WithExactLength/package.json +0 -6
  579. package/Form.stories/index.js +0 -3
  580. package/FormBuilder/FormBuilder/index.js +0 -152
  581. package/FormBuilder/FormBuilder.d.ts +0 -5
  582. package/FormBuilder/FormBuilder.stories/index.js +0 -7
  583. package/FormBuilder/FormBuilder.stories/package.json +0 -6
  584. package/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  585. package/FormBuilder/__stories__/Default/index.js +0 -26
  586. package/FormBuilder/__stories__/Default/package.json +0 -6
  587. package/MultiplicityField/MultiplicityField.stories/index.js +0 -12
  588. package/MultiplicityField/MultiplicityField.stories/package.json +0 -6
  589. package/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  590. package/MultiplicityField/__stories__/Default/index.js +0 -95
  591. package/MultiplicityField/__stories__/Default/package.json +0 -6
  592. package/MultiplicityField/__stories__/PreviewDisplay/index.js +0 -78
  593. package/MultiplicityField/__stories__/PreviewDisplay/package.json +0 -6
  594. package/MultiplicityField/__stories__/WithExactLength/index.js +0 -90
  595. package/MultiplicityField/__stories__/WithExactLength/package.json +0 -6
  596. package/MultiplicityField/__stories__/WithMaxLength/index.js +0 -93
  597. package/MultiplicityField/__stories__/WithMaxLength/package.json +0 -6
  598. package/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +0 -94
  599. package/MultiplicityField/__stories__/WithMinAndMaxLength/package.json +0 -6
  600. package/MultiplicityField/__stories__/WithMinLength/index.js +0 -93
  601. package/MultiplicityField/__stories__/WithMinLength/package.json +0 -6
  602. package/Questions/Questions.stories/index.js +0 -7
  603. package/Questions/__snapshots__/index.spec.tsx.snap +0 -596
  604. package/Questions/__stories__/Default/index.js +0 -102
  605. package/Questions/__stories__/Default/package.json +0 -6
  606. package/Questions/index.mdx +0 -415
  607. package/Questions/index.spec/index.js +0 -59
  608. package/cjs/Field/index.mdx +0 -6
  609. package/cjs/FieldArray/FieldArray.stories/index.js +0 -38
  610. package/cjs/FieldArray/FieldArray.stories.playwright.json +0 -353
  611. package/cjs/FieldArray/__stories__/Default/index.js +0 -98
  612. package/cjs/FieldArray/__stories__/WithExactLength/index.js +0 -98
  613. package/cjs/Form.stories/index.js +0 -9
  614. package/cjs/FormBuilder/FormBuilder/index.js +0 -162
  615. package/cjs/FormBuilder/FormBuilder.mdx +0 -256
  616. package/cjs/FormBuilder/FormBuilder.stories/index.js +0 -26
  617. package/cjs/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  618. package/cjs/FormBuilder/__stories__/Default/index.js +0 -36
  619. package/cjs/MultiplicityField/MultiplicityField.mdx +0 -590
  620. package/cjs/MultiplicityField/MultiplicityField.stories/index.js +0 -86
  621. package/cjs/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  622. package/cjs/MultiplicityField/__stories__/Default/index.js +0 -105
  623. package/cjs/MultiplicityField/__stories__/PreviewDisplay/index.js +0 -88
  624. package/cjs/MultiplicityField/__stories__/WithExactLength/index.js +0 -100
  625. package/cjs/MultiplicityField/__stories__/WithMaxLength/index.js +0 -103
  626. package/cjs/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +0 -104
  627. package/cjs/MultiplicityField/__stories__/WithMinLength/index.js +0 -103
  628. package/cjs/Questions/Questions.stories/index.js +0 -26
  629. package/cjs/Questions/__snapshots__/index.spec.tsx.snap +0 -596
  630. package/cjs/Questions/__stories__/Default/index.js +0 -113
  631. package/cjs/Questions/index.mdx +0 -415
  632. package/cjs/Questions/index.spec/index.js +0 -63
  633. package/cjs/create-simple-form.mdx +0 -539
  634. package/cjs/index.mdx +0 -51
  635. package/cjs/inputs/AutoCompleteInput/AutoComplete.stories/index.js +0 -38
  636. package/cjs/inputs/AutoCompleteInput/__stories__/Default/index.js +0 -51
  637. package/cjs/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -52
  638. package/cjs/inputs/AutoCompleteInput/index.mdx +0 -29
  639. package/cjs/inputs/Checkboxes/Checkboxes.stories/index.js +0 -50
  640. package/cjs/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  641. package/cjs/inputs/Checkboxes/__stories__/Conditional/index.js +0 -103
  642. package/cjs/inputs/Checkboxes/__stories__/Default/index.js +0 -50
  643. package/cjs/inputs/Checkboxes/__stories__/WithDivider/index.js +0 -51
  644. package/cjs/inputs/Checkboxes/index.mdx +0 -33
  645. package/cjs/inputs/DateInput/DateInput.stories/index.js +0 -26
  646. package/cjs/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  647. package/cjs/inputs/DateInput/__stories__/Default/index.js +0 -33
  648. package/cjs/inputs/DateInput/index.mdx +0 -23
  649. package/cjs/inputs/FileInput/FileInput.stories/index.js +0 -26
  650. package/cjs/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  651. package/cjs/inputs/FileInput/__stories__/Default/index.js +0 -30
  652. package/cjs/inputs/FileInput/index.mdx +0 -19
  653. package/cjs/inputs/ImageInput/ImageInput.stories/index.js +0 -50
  654. package/cjs/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
  655. package/cjs/inputs/ImageInput/__stories__/Default/index.js +0 -38
  656. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +0 -46
  657. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +0 -43
  658. package/cjs/inputs/ImageInput/index.mdx +0 -19
  659. package/cjs/inputs/Input/Input.stories/index.js +0 -134
  660. package/cjs/inputs/Input/Input.stories.playwright.json +0 -376
  661. package/cjs/inputs/Input/__stories__/AFM/index.js +0 -32
  662. package/cjs/inputs/Input/__stories__/Boolean/index.js +0 -33
  663. package/cjs/inputs/Input/__stories__/Default/index.js +0 -33
  664. package/cjs/inputs/Input/__stories__/IBAN/index.js +0 -33
  665. package/cjs/inputs/Input/__stories__/Integer/index.js +0 -41
  666. package/cjs/inputs/Input/__stories__/LandlineNumber/index.js +0 -36
  667. package/cjs/inputs/Input/__stories__/MobilePhone/index.js +0 -36
  668. package/cjs/inputs/Input/__stories__/PhoneNumber/index.js +0 -35
  669. package/cjs/inputs/Input/__stories__/PostalCode/index.js +0 -35
  670. package/cjs/inputs/Input/__stories__/TextWithCharacterLimit/index.js +0 -39
  671. package/cjs/inputs/Input/index.mdx +0 -95
  672. package/cjs/inputs/Label/Label.stories/index.js +0 -26
  673. package/cjs/inputs/Label/Label.stories.playwright.json +0 -40
  674. package/cjs/inputs/Label/__stories__/Default/index.js +0 -37
  675. package/cjs/inputs/Label/index.mdx +0 -0
  676. package/cjs/inputs/OtpInput/OtpInput.stories/index.js +0 -26
  677. package/cjs/inputs/OtpInput/__stories__/Default/index.js +0 -39
  678. package/cjs/inputs/OtpInput/index.mdx +0 -23
  679. package/cjs/inputs/Radio/Radio.stories/index.js +0 -50
  680. package/cjs/inputs/Radio/Radio.stories.playwright.json +0 -73
  681. package/cjs/inputs/Radio/__stories__/Conditional/index.js +0 -103
  682. package/cjs/inputs/Radio/__stories__/Default/index.js +0 -55
  683. package/cjs/inputs/Radio/__stories__/WithDivider/index.js +0 -56
  684. package/cjs/inputs/Select/Select.stories/index.js +0 -26
  685. package/cjs/inputs/Select/Select.stories.playwright.json +0 -22
  686. package/cjs/inputs/Select/__stories__/Default/index.js +0 -61
  687. package/cjs/inputs/Select/index.mdx +0 -17
  688. package/cjs/installation.mdx +0 -68
  689. package/cjs/validators/validators.spec/index.js +0 -87
  690. package/create-simple-form.mdx +0 -539
  691. package/inputs/AutoCompleteInput/AutoComplete.stories/index.js +0 -8
  692. package/inputs/AutoCompleteInput/AutoComplete.stories/package.json +0 -6
  693. package/inputs/AutoCompleteInput/__stories__/Default/index.js +0 -44
  694. package/inputs/AutoCompleteInput/__stories__/Default/package.json +0 -6
  695. package/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -45
  696. package/inputs/AutoCompleteInput/__stories__/Multiple/package.json +0 -6
  697. package/inputs/Checkboxes/Checkboxes.stories/index.js +0 -9
  698. package/inputs/Checkboxes/Checkboxes.stories/package.json +0 -6
  699. package/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  700. package/inputs/Checkboxes/__stories__/Conditional/index.js +0 -93
  701. package/inputs/Checkboxes/__stories__/Conditional/package.json +0 -6
  702. package/inputs/Checkboxes/__stories__/Default/index.js +0 -40
  703. package/inputs/Checkboxes/__stories__/Default/package.json +0 -6
  704. package/inputs/Checkboxes/__stories__/WithDivider/index.js +0 -41
  705. package/inputs/Checkboxes/__stories__/WithDivider/package.json +0 -6
  706. package/inputs/Checkboxes/index.mdx +0 -33
  707. package/inputs/DateInput/DateInput.stories/index.js +0 -7
  708. package/inputs/DateInput/DateInput.stories/package.json +0 -6
  709. package/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  710. package/inputs/DateInput/__stories__/Default/index.js +0 -23
  711. package/inputs/DateInput/index.mdx +0 -23
  712. package/inputs/FileInput/FileInput.stories/index.js +0 -7
  713. package/inputs/FileInput/FileInput.stories/package.json +0 -6
  714. package/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  715. package/inputs/FileInput/__stories__/Default/index.js +0 -20
  716. package/inputs/FileInput/__stories__/Default/package.json +0 -6
  717. package/inputs/FileInput/index.mdx +0 -19
  718. package/inputs/ImageInput/ImageInput.stories/index.js +0 -9
  719. package/inputs/ImageInput/ImageInput.stories/package.json +0 -6
  720. package/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
  721. package/inputs/ImageInput/__stories__/Default/index.js +0 -28
  722. package/inputs/ImageInput/__stories__/Default/package.json +0 -6
  723. package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +0 -36
  724. package/inputs/ImageInput/__stories__/WithInvalidImageDimension/package.json +0 -6
  725. package/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +0 -33
  726. package/inputs/ImageInput/__stories__/WithInvalidImageSize/package.json +0 -6
  727. package/inputs/ImageInput/__stories__/WithInvalidImageSize.d.ts +0 -3
  728. package/inputs/ImageInput/index.mdx +0 -19
  729. package/inputs/Input/Input.stories/index.js +0 -16
  730. package/inputs/Input/Input.stories/package.json +0 -6
  731. package/inputs/Input/Input.stories.playwright.json +0 -376
  732. package/inputs/Input/__stories__/AFM/index.js +0 -22
  733. package/inputs/Input/__stories__/AFM/package.json +0 -6
  734. package/inputs/Input/__stories__/Boolean/index.js +0 -23
  735. package/inputs/Input/__stories__/Boolean/package.json +0 -6
  736. package/inputs/Input/__stories__/Default/index.js +0 -23
  737. package/inputs/Input/__stories__/Default/package.json +0 -6
  738. package/inputs/Input/__stories__/Default.d.ts +0 -3
  739. package/inputs/Input/__stories__/IBAN/index.js +0 -23
  740. package/inputs/Input/__stories__/IBAN/package.json +0 -6
  741. package/inputs/Input/__stories__/Integer/index.js +0 -31
  742. package/inputs/Input/__stories__/Integer/package.json +0 -6
  743. package/inputs/Input/__stories__/LandlineNumber/index.js +0 -26
  744. package/inputs/Input/__stories__/LandlineNumber/package.json +0 -6
  745. package/inputs/Input/__stories__/MobilePhone/index.js +0 -26
  746. package/inputs/Input/__stories__/MobilePhone/package.json +0 -6
  747. package/inputs/Input/__stories__/PhoneNumber/index.js +0 -25
  748. package/inputs/Input/__stories__/PhoneNumber/package.json +0 -6
  749. package/inputs/Input/__stories__/PostalCode/index.js +0 -25
  750. package/inputs/Input/__stories__/PostalCode/package.json +0 -6
  751. package/inputs/Input/__stories__/TextWithCharacterLimit/index.js +0 -29
  752. package/inputs/Input/__stories__/TextWithCharacterLimit/package.json +0 -6
  753. package/inputs/Input/__stories__/TextWithCharacterLimit.d.ts +0 -3
  754. package/inputs/Input/index.mdx +0 -95
  755. package/inputs/Label/Label.stories/index.js +0 -7
  756. package/inputs/Label/Label.stories/package.json +0 -6
  757. package/inputs/Label/Label.stories.playwright.json +0 -40
  758. package/inputs/Label/__stories__/Default/index.js +0 -27
  759. package/inputs/Label/__stories__/Default/package.json +0 -6
  760. package/inputs/Label/index.mdx +0 -0
  761. package/inputs/OtpInput/OtpInput.stories/index.js +0 -7
  762. package/inputs/OtpInput/OtpInput.stories/package.json +0 -6
  763. package/inputs/OtpInput/__stories__/Default/index.js +0 -29
  764. package/inputs/OtpInput/__stories__/Default/package.json +0 -6
  765. package/inputs/Radio/Radio.stories/index.js +0 -9
  766. package/inputs/Radio/Radio.stories/package.json +0 -6
  767. package/inputs/Radio/Radio.stories.playwright.json +0 -73
  768. package/inputs/Radio/__stories__/Conditional/index.js +0 -93
  769. package/inputs/Radio/__stories__/Conditional/package.json +0 -6
  770. package/inputs/Radio/__stories__/Default/index.js +0 -45
  771. package/inputs/Radio/__stories__/Default/package.json +0 -6
  772. package/inputs/Radio/__stories__/WithDivider/index.js +0 -46
  773. package/inputs/Radio/__stories__/WithDivider/package.json +0 -6
  774. package/inputs/Radio/index.mdx +0 -33
  775. package/inputs/Select/Select.stories/index.js +0 -7
  776. package/inputs/Select/Select.stories/package.json +0 -6
  777. package/inputs/Select/Select.stories.playwright.json +0 -22
  778. package/inputs/Select/__stories__/Default/index.js +0 -51
  779. package/inputs/Select/__stories__/Default/package.json +0 -6
  780. package/installation.mdx +0 -68
  781. package/lazy.d.ts +0 -69
  782. package/registry.d.ts +0 -64
  783. package/src/Field/index.mdx +0 -6
  784. package/src/Field/utils.ts +0 -191
  785. package/src/FieldArray/FieldArray.stories.playwright.json +0 -353
  786. package/src/FormBuilder/FormBuilder.mdx +0 -256
  787. package/src/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  788. package/src/FormBuilder/FormBuilder.tsx +0 -166
  789. package/src/MultiplicityField/MultiplicityField.mdx +0 -590
  790. package/src/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  791. package/src/index.mdx +0 -51
  792. package/src/inputs/AutoCompleteInput/index.mdx +0 -29
  793. package/src/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  794. package/src/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  795. package/src/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  796. package/src/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
  797. package/src/inputs/ImageInput/index.mdx +0 -19
  798. package/src/inputs/Input/Input.stories.playwright.json +0 -376
  799. package/src/inputs/Input/index.mdx +0 -95
  800. package/src/inputs/Label/Label.stories.playwright.json +0 -40
  801. package/src/inputs/Label/index.mdx +0 -0
  802. package/src/inputs/OtpInput/index.mdx +0 -23
  803. package/src/inputs/Radio/Radio.stories.playwright.json +0 -73
  804. package/src/inputs/Radio/index.mdx +0 -33
  805. package/src/inputs/Select/Select.stories.playwright.json +0 -22
  806. package/src/inputs/Select/index.mdx +0 -17
  807. package/validators/validators.spec/index.js +0 -85
@@ -1,87 +1,83 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var utils_exports = {};
19
+ __export(utils_exports, {
20
+ yupResolver: () => yupResolver
7
21
  });
8
- exports.yupResolver = void 0;
9
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
- var _resolvers = require("@hookform/resolvers");
12
- var _reactHookForm = require("react-hook-form");
13
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
14
- /**
15
- * Why `path!` ? because it could be `undefined` in some case
16
- * https://github.com/jquense/yup#validationerrorerrors-string--arraystring-value-any-path-string
17
- */
18
- var parseErrorSchema = function parseErrorSchema(error, validateAllFieldCriteria) {
19
- return (error.inner || []).reduce(function (previous, error) {
20
- var _error$path;
21
- error.path = (_error$path = error.path) === null || _error$path === void 0 ? void 0 : _error$path.replace(/\[([0-9]+)\]/g, '.$1');
22
- if (!previous[error.path]) {
23
- previous[error.path] = {
24
- message: error.message,
25
- type: error.type
26
- };
22
+ module.exports = __toCommonJS(utils_exports);
23
+ var import_resolvers = require("@hookform/resolvers");
24
+ var import_react_hook_form = require("react-hook-form");
25
+ const parseErrorSchema = (error, validateAllFieldCriteria) => {
26
+ return (error.inner || []).reduce(
27
+ (previous, error2) => {
28
+ error2.path = error2.path?.replace(/\[([0-9]+)\]/g, ".$1");
29
+ if (!previous[error2.path]) {
30
+ previous[error2.path] = { message: error2.message, type: error2.type };
31
+ }
32
+ if (validateAllFieldCriteria) {
33
+ const types = previous[error2.path].types;
34
+ const messages = types && types[error2.type];
35
+ previous[error2.path] = (0, import_react_hook_form.appendErrors)(
36
+ error2.path,
37
+ validateAllFieldCriteria,
38
+ previous,
39
+ error2.type,
40
+ messages ? [].concat(messages, error2.message) : error2.message
41
+ );
42
+ }
43
+ return previous;
44
+ },
45
+ {}
46
+ );
47
+ };
48
+ const yupResolver = (schema, schemaOptions = {}, resolverOptions = {}) => async (values, context, options) => {
49
+ try {
50
+ if (schemaOptions.context && process.env.NODE_ENV === "development") {
51
+ console.warn(
52
+ "You should not used the yup options context. Please, use the 'useForm' context object instead"
53
+ );
27
54
  }
28
- if (validateAllFieldCriteria) {
29
- var types = previous[error.path].types;
30
- var messages = types && types[error.type];
31
- previous[error.path] = (0, _reactHookForm.appendErrors)(error.path, validateAllFieldCriteria, previous, error.type, messages ? [].concat(messages, error.message) : error.message);
55
+ const result = await schema[resolverOptions.mode === "sync" ? "validateSync" : "validate"](
56
+ values,
57
+ Object.assign({ abortEarly: false }, schemaOptions, { context })
58
+ );
59
+ if (options.shouldUseNativeValidation)
60
+ (0, import_resolvers.validateFieldsNatively)({}, options);
61
+ return {
62
+ values: resolverOptions.rawValues ? values : result,
63
+ errors: {}
64
+ };
65
+ } catch (e) {
66
+ if (!e.inner) {
67
+ throw e;
32
68
  }
33
- return previous;
34
- }, {});
35
- };
36
- var yupResolver = exports.yupResolver = function yupResolver(schema) {
37
- var schemaOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
38
- var resolverOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
39
- return /*#__PURE__*/function () {
40
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(values, context, options) {
41
- var result, parsed;
42
- return _regeneratorRuntime().wrap(function _callee$(_context) {
43
- while (1) switch (_context.prev = _context.next) {
44
- case 0:
45
- _context.prev = 0;
46
- if (schemaOptions.context && process.env.NODE_ENV === 'development') {
47
- // eslint-disable-next-line no-console
48
- console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead");
49
- }
50
- _context.next = 4;
51
- return schema[resolverOptions.mode === 'sync' ? 'validateSync' : 'validate'](values, (0, _extends2["default"])({
52
- abortEarly: false
53
- }, schemaOptions, {
54
- context: context
55
- }));
56
- case 4:
57
- result = _context.sent;
58
- options.shouldUseNativeValidation && (0, _resolvers.validateFieldsNatively)({}, options);
59
- return _context.abrupt("return", {
60
- values: resolverOptions.rawValues ? values : result,
61
- errors: {}
62
- });
63
- case 9:
64
- _context.prev = 9;
65
- _context.t0 = _context["catch"](0);
66
- if (_context.t0.inner) {
67
- _context.next = 13;
68
- break;
69
- }
70
- throw _context.t0;
71
- case 13:
72
- parsed = parseErrorSchema(_context.t0, !options.shouldUseNativeValidation && options.criteriaMode === 'all');
73
- return _context.abrupt("return", {
74
- values: {},
75
- errors: parsed
76
- });
77
- case 15:
78
- case "end":
79
- return _context.stop();
80
- }
81
- }, _callee, null, [[0, 9]]);
82
- }));
83
- return function (_x, _x2, _x3) {
84
- return _ref.apply(this, arguments);
69
+ const parsed = parseErrorSchema(
70
+ e,
71
+ !options.shouldUseNativeValidation && options.criteriaMode === "all"
72
+ );
73
+ return {
74
+ values: {},
75
+ errors: parsed
85
76
  };
86
- }();
87
- };
77
+ }
78
+ };
79
+ // Annotate the CommonJS export names for ESM import in node:
80
+ 0 && (module.exports = {
81
+ yupResolver
82
+ });
83
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils.ts"],
4
+ "sourcesContent": ["import { validateFieldsNatively } from '@hookform/resolvers';\nimport { appendErrors, FieldError } from 'react-hook-form';\nimport * as Yup from 'yup';\n\n/**\n * Why `path!` ? because it could be `undefined` in some case\n * https://github.com/jquense/yup#validationerrorerrors-string--arraystring-value-any-path-string\n */\nconst parseErrorSchema = (\n error: Yup.ValidationError,\n validateAllFieldCriteria: boolean\n) => {\n return (error.inner || []).reduce<Record<string, FieldError>>(\n (previous, error) => {\n error.path = error.path?.replace(/\\[([0-9]+)\\]/g, '.$1');\n if (!previous[error.path!]) {\n previous[error.path!] = { message: error.message, type: error.type! };\n }\n\n if (validateAllFieldCriteria) {\n const types = previous[error.path!].types;\n const messages = types && types[error.type!];\n\n previous[error.path!] = appendErrors(\n error.path!,\n validateAllFieldCriteria,\n previous,\n error.type!,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message\n ) as FieldError;\n }\n\n return previous;\n },\n {}\n );\n};\n\nexport const yupResolver =\n (schema: any, schemaOptions: any = {}, resolverOptions: any = {}) =>\n async (values, context, options) => {\n try {\n if (schemaOptions.context && process.env.NODE_ENV === 'development') {\n console.warn(\n \"You should not used the yup options context. Please, use the 'useForm' context object instead\"\n );\n }\n\n const result = await schema[\n resolverOptions.mode === 'sync' ? 'validateSync' : 'validate'\n ](\n values,\n Object.assign({ abortEarly: false }, schemaOptions, { context })\n );\n\n if (options.shouldUseNativeValidation)\n validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.rawValues ? values : result,\n errors: {},\n };\n } catch (e) {\n if (!e.inner) {\n throw e;\n }\n\n const parsed = parseErrorSchema(\n e,\n !options.shouldUseNativeValidation && options.criteriaMode === 'all'\n );\n return {\n values: {},\n errors: parsed,\n };\n }\n };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAuC;AACvC,6BAAyC;AAOzC,MAAM,mBAAmB,CACvB,OACA,6BACG;AACH,UAAQ,MAAM,SAAS,CAAC,GAAG;AAAA,IACzB,CAAC,UAAUA,WAAU;AACnB,MAAAA,OAAM,OAAOA,OAAM,MAAM,QAAQ,iBAAiB,KAAK;AACvD,UAAI,CAAC,SAASA,OAAM,IAAK,GAAG;AAC1B,iBAASA,OAAM,IAAK,IAAI,EAAE,SAASA,OAAM,SAAS,MAAMA,OAAM,KAAM;AAAA,MACtE;AAEA,UAAI,0BAA0B;AAC5B,cAAM,QAAQ,SAASA,OAAM,IAAK,EAAE;AACpC,cAAM,WAAW,SAAS,MAAMA,OAAM,IAAK;AAE3C,iBAASA,OAAM,IAAK,QAAI;AAAA,UACtBA,OAAM;AAAA,UACN;AAAA,UACA;AAAA,UACAA,OAAM;AAAA,UACN,WACK,CAAC,EAAe,OAAO,UAAsBA,OAAM,OAAO,IAC3DA,OAAM;AAAA,QACZ;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;AAEO,MAAM,cACX,CAAC,QAAa,gBAAqB,CAAC,GAAG,kBAAuB,CAAC,MAC/D,OAAO,QAAQ,SAAS,YAAY;AAClC,MAAI;AACF,QAAI,cAAc,WAAW,QAAQ,IAAI,aAAa,eAAe;AACnE,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAEA,UAAM,SAAS,MAAM,OACnB,gBAAgB,SAAS,SAAS,iBAAiB,UACrD;AAAA,MACE;AAAA,MACA,OAAO,OAAO,EAAE,YAAY,MAAM,GAAG,eAAe,EAAE,QAAQ,CAAC;AAAA,IACjE;AAEA,QAAI,QAAQ;AACV,mDAAuB,CAAC,GAAG,OAAO;AAEpC,WAAO;AAAA,MACL,QAAQ,gBAAgB,YAAY,SAAS;AAAA,MAC7C,QAAQ,CAAC;AAAA,IACX;AAAA,EACF,SAAS,GAAG;AACV,QAAI,CAAC,EAAE,OAAO;AACZ,YAAM;AAAA,IACR;AAEA,UAAM,SAAS;AAAA,MACb;AAAA,MACA,CAAC,QAAQ,6BAA6B,QAAQ,iBAAiB;AAAA,IACjE;AACA,WAAO;AAAA,MACL,QAAQ,CAAC;AAAA,MACT,QAAQ;AAAA,IACV;AAAA,EACF;AACF;",
6
+ "names": ["error"]
7
+ }
@@ -1,193 +1,160 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof3 = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.getYUPTypeMap = void 0;
9
- exports.useValidationSchema = useValidationSchema;
10
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
- var _react = require("react");
12
- var _dayjs = _interopRequireDefault(require("dayjs"));
13
- var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
14
- var yup = _interopRequireWildcard(require("yup"));
15
- var _utils = require("@digigov/form/validators/utils");
16
- var _int = require("@digigov/form/validators/utils/int");
17
- var _number = require("@digigov/form/validators/utils/number");
18
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
19
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
20
- _dayjs["default"].extend(_customParseFormat["default"]);
21
- var VALID_DATE_FORMATS = ['DD/MM/YYYY'];
22
- var DATE_CACHE = {};
23
- var getDate = function getDate(v) {
24
- return DATE_CACHE[v] ? DATE_CACHE[v] : (0, _dayjs["default"])(v, VALID_DATE_FORMATS, true);
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
25
18
  };
26
- var getYUPTypeMap = exports.getYUPTypeMap = function getYUPTypeMap() {
27
- var yupTypeMap = {
28
- file: function file(field) {
29
- return yup.mixed().transform(function (value) {
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var validators_exports = {};
29
+ __export(validators_exports, {
30
+ getYUPTypeMap: () => getYUPTypeMap,
31
+ useValidationSchema: () => useValidationSchema
32
+ });
33
+ module.exports = __toCommonJS(validators_exports);
34
+ var import_react = require("react");
35
+ var yup = __toESM(require("yup"));
36
+ var import_utils = require("@digigov/form/validators/utils");
37
+ var import_int = require("@digigov/form/validators/utils/int");
38
+ var import_number = require("@digigov/form/validators/utils/number");
39
+ const getYUPTypeMap = () => {
40
+ const yupTypeMap = {
41
+ file: (field) => {
42
+ return yup.mixed().transform((value) => {
30
43
  if (!value.length) {
31
44
  return null;
32
45
  }
33
46
  return value;
34
- }).nullable().test((0, _utils.FILE_MAX_SIZE_VALIDATOR)(field));
47
+ }).nullable().test((0, import_utils.FILE_MAX_SIZE_VALIDATOR)(field));
48
+ },
49
+ string: (field) => {
50
+ if (field.trim) {
51
+ return yup.string().trim();
52
+ } else {
53
+ return yup.string();
54
+ }
55
+ },
56
+ boolean: () => {
57
+ return yup.boolean().nullable().transform((value) => {
58
+ if (value === "" || typeof value === "string") return null;
59
+ if (typeof value === "boolean") return value;
60
+ if (value === 0 || value === 1) return Boolean(value);
61
+ return value;
62
+ });
35
63
  },
36
- string: yup.string,
37
- "boolean": yup["boolean"],
38
- object: function object(field) {
39
- return (0, _utils.getYupObjectShape)(field.extra.fields, yupTypeMap);
64
+ object: (field) => {
65
+ return (0, import_utils.getYupObjectShape)(field.extra.fields, yupTypeMap);
40
66
  },
41
- array: function array(field) {
42
- if ((0, _typeof2["default"])(field.extra.of) === 'object') {
43
- // else if the field is an object then it is a scalar type
44
- // eg. number, string etc.
45
- var arrayValidator = yup.array().of(yupTypeMap[field.extra.of.type](field.extra.of)).required(field.required);
46
- if (field.extra.length) arrayValidator = arrayValidator.length(field.extra.length, {
47
- key: 'form.error.array.length',
48
- context: {
49
- length: field.extra.length
50
- }
51
- });
52
- if (field.extra.min) arrayValidator = arrayValidator.min(field.extra.min, {
53
- key: 'form.error.array.min',
54
- context: {
55
- min: field.extra.min
56
- }
57
- });
58
- if (field.extra.max) arrayValidator = arrayValidator.max(field.extra.max, {
59
- key: 'form.error.array.max',
60
- context: {
61
- max: field.extra.max
62
- }
63
- });
67
+ array: (field) => {
68
+ if (typeof field.extra.of === "object") {
69
+ let arrayValidator = yup.array().of(yupTypeMap[field.extra.of.type](field.extra.of)).required(field.required);
70
+ if (field.extra.length)
71
+ arrayValidator = arrayValidator.length(field.extra.length, {
72
+ key: "form.error.array.length",
73
+ context: {
74
+ length: field.extra.length
75
+ }
76
+ });
77
+ if (field.extra.min)
78
+ arrayValidator = arrayValidator.min(field.extra.min, {
79
+ key: "form.error.array.min",
80
+ context: {
81
+ min: field.extra.min
82
+ }
83
+ });
84
+ if (field.extra.max)
85
+ arrayValidator = arrayValidator.max(field.extra.max, {
86
+ key: "form.error.array.max",
87
+ context: {
88
+ max: field.extra.max
89
+ }
90
+ });
64
91
  return arrayValidator;
65
- } else if (typeof field.extra.of === 'string') {
92
+ } else if (typeof field.extra.of === "string") {
66
93
  return yup.array().of(yupTypeMap[field.extra.of]());
67
94
  } else {
68
- // in any other case it will be string
69
95
  return yup.array().of(yup.string());
70
96
  }
71
97
  },
72
- "int": function int() {
73
- return yup.mixed().transform(function (_, val) {
74
- return val !== '' ? Number(val) : null;
75
- }).test((0, _number.NUMBER_VALIDATOR)()).test((0, _int.INT_VALIDATOR)());
76
- },
77
- email: function email() {
78
- return yup.string().email('form.error.email');
79
- },
80
- afm: function afm() {
81
- return yup.string().test(_utils.AFM_VALIDATOR);
82
- },
83
- uuid4: function uuid4() {
84
- return yup.string().test(_utils.UUID4_VALIDATOR);
85
- },
86
- iban: function iban(field) {
87
- return yup.string().test((0, _utils.IBAN_VALIDATOR)(field));
88
- },
89
- otp: function otp(field) {
90
- return yup.string().test((0, _utils.OTP_VALIDATOR)(field));
91
- },
92
- text: function text(field) {
93
- var _field$extra, _field$extra$limit, _field$extra2, _field$extra2$limit;
94
- if (field !== null && field !== void 0 && (_field$extra = field.extra) !== null && _field$extra !== void 0 && (_field$extra$limit = _field$extra.limit) !== null && _field$extra$limit !== void 0 && _field$extra$limit.max || !!(field !== null && field !== void 0 && (_field$extra2 = field.extra) !== null && _field$extra2 !== void 0 && (_field$extra2$limit = _field$extra2.limit) !== null && _field$extra2$limit !== void 0 && _field$extra2$limit.min)) {
95
- return yup.string().test((0, _utils.TEXT_LIMIT_VALIDATOR)(field));
98
+ number: () => yup.mixed().transform((_, val) => val !== "" ? Number(val) : void 0).test((0, import_number.NUMBER_VALIDATOR)()),
99
+ int: () => yup.mixed().transform((_, val) => val !== "" ? Number(val) : void 0).test((0, import_number.NUMBER_VALIDATOR)()).test((0, import_int.INT_VALIDATOR)()),
100
+ email: (field) => field.trim ? yup.string().trim().email("form.error.email") : yup.string().email("form.error.email"),
101
+ afm: (field) => field.trim ? yup.string().trim().test(import_utils.AFM_VALIDATOR) : yup.string().test(import_utils.AFM_VALIDATOR),
102
+ uuid4: (field) => field.trim ? yup.string().trim().test(import_utils.UUID4_VALIDATOR) : yup.string().test(import_utils.UUID4_VALIDATOR),
103
+ iban: (field) => field.trim ? yup.string().trim().test((0, import_utils.IBAN_VALIDATOR)(field)) : yup.string().trim().test((0, import_utils.IBAN_VALIDATOR)(field)),
104
+ otp: (field) => yup.string().trim().test((0, import_utils.OTP_VALIDATOR)(field)),
105
+ text: (field) => {
106
+ if (field?.extra?.limit?.max || !!field?.extra?.limit?.min) {
107
+ return field.trim ? yup.string().trim().test((0, import_utils.TEXT_LIMIT_VALIDATOR)(field)) : yup.string().test((0, import_utils.TEXT_LIMIT_VALIDATOR)(field));
96
108
  } else {
97
- return yup.string();
109
+ return field.trim ? yup.string().trim() : yup.string();
98
110
  }
99
111
  },
100
- image: function image(field) {
101
- return yup.mixed().transform(function (value) {
112
+ image: (field) => {
113
+ return yup.mixed().transform((value) => {
102
114
  if (!value.length || value.length === 0) {
103
115
  return null;
104
116
  }
105
117
  return value;
106
- }).nullable().test((0, _utils.FILE_MAX_SIZE_VALIDATOR)(field)).test((0, _utils.IMAGE_DIMENSION_VALIDATOR)(field));
107
- },
108
- postal_code: function postal_code(field) {
109
- return yup.string().test((0, _utils.POSTALCODE_VALIDATOR)(field));
110
- },
111
- mobile_phone: function mobile_phone() {
112
- return yup.string().test(_utils.MOBILE_PHONE_VALIDATOR);
113
- },
114
- phone_number: function phone_number(field) {
115
- return yup.string().test((0, _utils.PHONE_NUMBER_VALIDATOR)(field));
116
- },
117
- 'choice:multiple': function choiceMultiple() {
118
- return yup.array().of(yup.string()).nullable();
119
- },
120
- 'choice:single': function choiceSingle() {
121
- return yup.string().nullable();
118
+ }).nullable().test((0, import_utils.FILE_MAX_SIZE_VALIDATOR)(field)).test((0, import_utils.IMAGE_DIMENSION_VALIDATOR)(field));
119
+ },
120
+ postal_code: (field) => field.trim ? yup.string().trim().test((0, import_utils.POSTALCODE_VALIDATOR)(field)) : yup.string().test((0, import_utils.POSTALCODE_VALIDATOR)(field)),
121
+ mobile_phone: (field) => field.trim ? yup.string().trim().test(import_utils.MOBILE_PHONE_VALIDATOR) : yup.string().test(import_utils.MOBILE_PHONE_VALIDATOR),
122
+ phone_number: (field) => field.trim ? yup.string().trim().test((0, import_utils.PHONE_NUMBER_VALIDATOR)(field)) : yup.string().test((0, import_utils.PHONE_NUMBER_VALIDATOR)(field)),
123
+ "choice:multiple": () => yup.array().of(yup.string()).nullable(),
124
+ "choice:single": () => yup.string().nullable(),
125
+ date: (field) => {
126
+ let schema = yup.string().nullable();
127
+ if (field?.extra?.min) {
128
+ schema = schema.test((0, import_utils.LATER_THAN_VALIDATOR)(field));
129
+ }
130
+ if (field?.extra?.max) {
131
+ schema = schema.test((0, import_utils.EARLIER_THAN_VALIDATOR)(field));
132
+ } else {
133
+ schema = schema.test(import_utils.DATE_VALIDATOR);
134
+ }
135
+ return schema;
122
136
  },
123
- date: function date(field) {
124
- var simpleDate = yup.string().nullable(true).test('date', 'form.error.date.invalid', function (value) {
125
- if (!value) return true;
126
- var date = getDate(value);
127
- return date.isValid();
128
- });
129
- var params = field.extra || {};
130
- if (params.max) {
131
- var maxDate;
132
- if (params.max === 'now') {
133
- var today = new Date();
134
- maxDate = new Date(today);
135
- } else {
136
- maxDate = getDate(params.max).toDate();
137
- }
138
- var maxNextDate = new Date(maxDate);
139
- maxNextDate.setDate(maxDate.getDate() + 1);
140
- simpleDate = simpleDate.test({
141
- name: 'earlier-than',
142
- message: {
143
- key: 'form.error.date.earlier_than',
144
- context: {
145
- maxDate: maxNextDate.toLocaleDateString()
146
- }
147
- },
148
- test: function test(value) {
149
- if (!value) return true;
150
- var date = getDate(value);
151
- var isValid = +date.toDate() < +maxDate;
152
- return isValid;
153
- }
154
- });
137
+ datetime: (field) => {
138
+ if (field?.extra?.min) {
139
+ return yup.string().test((0, import_utils.LATER_THAN_DATETIME_VALIDATOR)(field));
155
140
  }
156
- if (params.min) {
157
- var minDate;
158
- if (params.min === 'now') {
159
- var _today = new Date();
160
- minDate = new Date(_today);
161
- } else {
162
- minDate = getDate(params.min).toDate();
163
- }
164
- var minPreviousDate = new Date(minDate);
165
- minPreviousDate.setDate(minDate.getDate() - 1);
166
- simpleDate = simpleDate.test({
167
- name: 'later-than',
168
- message: {
169
- key: 'form.error.date.later_than',
170
- context: {
171
- minDate: minPreviousDate.toLocaleDateString()
172
- }
173
- },
174
- test: function test(value) {
175
- if (!value) return true;
176
- var date = getDate(value);
177
- var isValid = +date.toDate() > +minDate;
178
- return isValid;
179
- }
180
- });
141
+ if (field?.extra?.max) {
142
+ return yup.string().test((0, import_utils.EARLIER_THAN_DATETIME_VALIDATOR)(field));
181
143
  }
182
- return simpleDate;
144
+ return yup.string().test(import_utils.DATETIME_VALIDATOR);
183
145
  }
184
146
  };
185
147
  return yupTypeMap;
186
148
  };
187
- // Create a yup validation schema from given fields input
188
149
  function useValidationSchema(fields, validatorRegistry) {
189
- return (0, _react.useMemo)(function () {
190
- var yupTypeMap = getYUPTypeMap();
191
- return (0, _utils.getYupObjectShape)(fields, yupTypeMap, validatorRegistry);
150
+ return (0, import_react.useMemo)(() => {
151
+ const yupTypeMap = getYUPTypeMap();
152
+ return (0, import_utils.getYupObjectShape)(fields, yupTypeMap, validatorRegistry);
192
153
  }, []);
193
- }
154
+ }
155
+ // Annotate the CommonJS export names for ESM import in node:
156
+ 0 && (module.exports = {
157
+ getYUPTypeMap,
158
+ useValidationSchema
159
+ });
160
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/validators/index.ts"],
4
+ "sourcesContent": ["import { MutableRefObject, useMemo } from 'react';\nimport * as yup from 'yup';\nimport { AnyObjectSchema, StringSchema } from 'yup';\nimport { RequiredArraySchema } from 'yup/lib/array';\nimport Lazy from 'yup/lib/Lazy';\nimport { MixedSchema } from 'yup/lib/mixed';\nimport { TypeOfShape, AssertsShape } from 'yup/lib/object';\nimport { AnyObject } from 'yup/lib/types';\nimport { FieldSpec } from '@digigov/form/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\nimport {\n getYupObjectShape,\n AFM_VALIDATOR,\n FILE_MAX_SIZE_VALIDATOR,\n IBAN_VALIDATOR,\n OTP_VALIDATOR,\n MOBILE_PHONE_VALIDATOR,\n PHONE_NUMBER_VALIDATOR,\n TEXT_LIMIT_VALIDATOR,\n POSTALCODE_VALIDATOR,\n UUID4_VALIDATOR,\n IMAGE_DIMENSION_VALIDATOR,\n DATE_VALIDATOR,\n LATER_THAN_VALIDATOR,\n EARLIER_THAN_VALIDATOR,\n DATETIME_VALIDATOR,\n LATER_THAN_DATETIME_VALIDATOR,\n EARLIER_THAN_DATETIME_VALIDATOR,\n} from '@digigov/form/validators/utils';\nimport { INT_VALIDATOR } from '@digigov/form/validators/utils/int';\nimport { NUMBER_VALIDATOR } from '@digigov/form/validators/utils/number';\n\nexport const getYUPTypeMap = (): Record<string, any> => {\n const yupTypeMap = {\n file: (field): MixedSchema => {\n return yup\n .mixed()\n .transform((value) => {\n if (!value.length) {\n return null;\n }\n return value;\n })\n .nullable()\n .test(FILE_MAX_SIZE_VALIDATOR(field));\n },\n string: (field): yup.StringSchema => {\n if (field.trim) {\n return yup.string().trim();\n } else {\n return yup.string();\n }\n },\n boolean: (): yup.BooleanSchema<\n boolean | null | undefined,\n AnyObject,\n boolean | null | undefined\n > => {\n return yup\n .boolean()\n .nullable()\n .transform((value) => {\n if (value === '' || typeof value === 'string') return null;\n if (typeof value === 'boolean') return value;\n if (value === 0 || value === 1) return Boolean(value);\n return value;\n });\n },\n object: (\n field\n ):\n | yup.ObjectSchema<any, AnyObject, TypeOfShape<any>, AssertsShape<any>>\n | Lazy<any, unknown> => {\n return getYupObjectShape(field.extra.fields, yupTypeMap);\n },\n array: (\n field\n ):\n | yup.ArraySchema<any, AnyObject, any[] | undefined>\n | RequiredArraySchema<any, AnyObject, any[] | undefined> => {\n if (typeof field.extra.of === 'object') {\n // else if the field is an object then it is a scalar type\n // eg. number, string etc.\n let arrayValidator = yup\n .array()\n .of(yupTypeMap[field.extra.of.type](field.extra.of))\n .required(field.required);\n if (field.extra.length)\n arrayValidator = arrayValidator.length(field.extra.length, {\n key: 'form.error.array.length',\n context: {\n length: field.extra.length,\n },\n });\n if (field.extra.min)\n arrayValidator = arrayValidator.min(field.extra.min, {\n key: 'form.error.array.min',\n context: {\n min: field.extra.min,\n },\n });\n if (field.extra.max)\n arrayValidator = arrayValidator.max(field.extra.max, {\n key: 'form.error.array.max',\n context: {\n max: field.extra.max,\n },\n });\n return arrayValidator;\n } else if (typeof field.extra.of === 'string') {\n return yup.array().of(yupTypeMap[field.extra.of]());\n } else {\n // in any other case it will be string\n return yup.array().of(yup.string());\n }\n },\n number: (): MixedSchema =>\n yup\n .mixed()\n .transform((_, val) => (val !== '' ? Number(val) : undefined))\n .test(NUMBER_VALIDATOR()),\n int: (): MixedSchema =>\n yup\n .mixed()\n .transform((_, val) => (val !== '' ? Number(val) : undefined))\n .test(NUMBER_VALIDATOR())\n .test(INT_VALIDATOR()),\n email: (field): yup.StringSchema =>\n field.trim\n ? yup.string().trim().email('form.error.email')\n : yup.string().email('form.error.email'),\n afm: (field): yup.StringSchema =>\n field.trim\n ? yup.string().trim().test(AFM_VALIDATOR)\n : yup.string().test(AFM_VALIDATOR),\n uuid4: (field): yup.StringSchema =>\n field.trim\n ? yup.string().trim().test(UUID4_VALIDATOR)\n : yup.string().test(UUID4_VALIDATOR),\n iban: (field): yup.StringSchema =>\n field.trim\n ? yup.string().trim().test(IBAN_VALIDATOR(field))\n : yup.string().trim().test(IBAN_VALIDATOR(field)),\n otp: (field): yup.StringSchema =>\n yup.string().trim().test(OTP_VALIDATOR(field)),\n text: (field): yup.StringSchema => {\n if (field?.extra?.limit?.max || !!field?.extra?.limit?.min) {\n return field.trim\n ? yup.string().trim().test(TEXT_LIMIT_VALIDATOR(field))\n : yup.string().test(TEXT_LIMIT_VALIDATOR(field));\n } else {\n return field.trim ? yup.string().trim() : yup.string();\n }\n },\n image: (field): MixedSchema => {\n return yup\n .mixed()\n .transform((value) => {\n if (!value.length || value.length === 0) {\n return null;\n }\n return value;\n })\n .nullable()\n .test(FILE_MAX_SIZE_VALIDATOR(field))\n .test(IMAGE_DIMENSION_VALIDATOR(field));\n },\n postal_code: (field): yup.StringSchema =>\n field.trim\n ? yup.string().trim().test(POSTALCODE_VALIDATOR(field))\n : yup.string().test(POSTALCODE_VALIDATOR(field)),\n mobile_phone: (field): yup.StringSchema =>\n field.trim\n ? yup.string().trim().test(MOBILE_PHONE_VALIDATOR)\n : yup.string().test(MOBILE_PHONE_VALIDATOR),\n phone_number: (field): yup.StringSchema =>\n field.trim\n ? yup.string().trim().test(PHONE_NUMBER_VALIDATOR(field))\n : yup.string().test(PHONE_NUMBER_VALIDATOR(field)),\n 'choice:multiple': (): yup.ArraySchema<\n yup.StringSchema<string | undefined, AnyObject, string | undefined>,\n AnyObject,\n (string | undefined)[] | null | undefined,\n (string | undefined)[] | null | undefined\n > => yup.array().of(yup.string()).nullable(),\n 'choice:single': (): StringSchema<\n string | null | undefined,\n AnyObject,\n string | null | undefined\n > => yup.string().nullable(),\n date: (\n field\n ): yup.StringSchema<\n string | null | undefined,\n AnyObject,\n string | null | undefined\n > => {\n let schema = yup.string().nullable();\n if (field?.extra?.min) {\n schema = schema.test(LATER_THAN_VALIDATOR(field));\n }\n if (field?.extra?.max) {\n schema = schema.test(EARLIER_THAN_VALIDATOR(field));\n } else {\n schema = schema.test(DATE_VALIDATOR);\n }\n return schema;\n },\n datetime: (field): yup.StringSchema => {\n if (field?.extra?.min) {\n return yup.string().test(LATER_THAN_DATETIME_VALIDATOR(field));\n }\n if (field?.extra?.max) {\n return yup.string().test(EARLIER_THAN_DATETIME_VALIDATOR(field));\n }\n return yup.string().test(DATETIME_VALIDATOR);\n },\n };\n return yupTypeMap;\n};\n\nexport interface MutableRefObjectProps {}\n// Create a yup validation schema from given fields input\nexport function useValidationSchema(\n fields: FieldSpec[] | MutableRefObject<MutableRefObjectProps>,\n validatorRegistry?: Record<string, ValidatorSchema[]>\n): Lazy<any, unknown> | AnyObjectSchema | void {\n return useMemo(() => {\n const yupTypeMap = getYUPTypeMap();\n return getYupObjectShape(fields, yupTypeMap, validatorRegistry);\n }, []);\n}\n"],
5
+ "mappings": "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",
6
+ "names": []
7
+ }
@@ -1,5 +1,16 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var types_exports = {};
15
+ module.exports = __toCommonJS(types_exports);
16
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/validators/types.ts"],
4
+ "sourcesContent": ["import * as yup from 'yup';\nexport type ValidatorSchema = yup.TestConfig;\n"],
5
+ "mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
6
+ "names": []
7
+ }