@digigov/form 1.1.2 → 1.1.4-mobile

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 (727) hide show
  1. package/Field/FieldBase/index.js +103 -76
  2. package/Field/FieldBase.js.map +7 -0
  3. package/Field/FieldBaseContainer/index.js +29 -37
  4. package/Field/FieldBaseContainer.js.map +7 -0
  5. package/Field/FieldConditional/index.js +79 -53
  6. package/Field/FieldConditional.js.map +7 -0
  7. package/Field/index.js +89 -63
  8. package/Field/index.js.map +7 -0
  9. package/Field/types/index.js +1 -1
  10. package/Field/types.d.ts +4 -0
  11. package/Field/types.js.map +7 -0
  12. package/Field/utils/index.js +96 -85
  13. package/Field/utils.d.ts +1 -0
  14. package/Field/utils.js.map +7 -0
  15. package/FieldArray/FieldArray.stories/index.js +12 -6
  16. package/FieldArray/FieldArray.stories.d.ts +2 -2
  17. package/FieldArray/FieldArray.stories.js.map +7 -0
  18. package/FieldArray/__stories__/Default/index.js +87 -80
  19. package/FieldArray/__stories__/Default.d.ts +2 -2
  20. package/FieldArray/__stories__/Default.js.map +7 -0
  21. package/FieldArray/__stories__/WithExactLength/index.js +87 -80
  22. package/FieldArray/__stories__/WithExactLength.d.ts +2 -2
  23. package/FieldArray/__stories__/WithExactLength.js.map +7 -0
  24. package/FieldArray/index.d.ts +1 -0
  25. package/FieldArray/index.js +65 -59
  26. package/FieldArray/index.js.map +7 -0
  27. package/FieldArray/index.test.d.ts +1 -0
  28. package/FieldObject/index.d.ts +3 -0
  29. package/FieldObject/index.js +66 -52
  30. package/FieldObject/index.js.map +7 -0
  31. package/Fieldset/FieldsetWithContext/index.js +27 -31
  32. package/Fieldset/FieldsetWithContext.js.map +7 -0
  33. package/Fieldset/index.js +27 -29
  34. package/Fieldset/index.js.map +7 -0
  35. package/Fieldset/types/index.js +1 -1
  36. package/Fieldset/types.d.ts +2 -0
  37. package/Fieldset/types.js.map +7 -0
  38. package/Form.stories/index.js +7 -3
  39. package/Form.stories.js.map +7 -0
  40. package/FormBuilder/FormBuilder/index.js +123 -118
  41. package/FormBuilder/FormBuilder.d.ts +1 -0
  42. package/FormBuilder/FormBuilder.js.map +7 -0
  43. package/FormBuilder/FormBuilder.stories/index.js +10 -5
  44. package/FormBuilder/FormBuilder.stories.d.ts +1 -1
  45. package/FormBuilder/FormBuilder.stories.js.map +7 -0
  46. package/FormBuilder/__stories__/Default/index.js +27 -21
  47. package/FormBuilder/__stories__/Default.d.ts +2 -2
  48. package/FormBuilder/__stories__/Default.js.map +7 -0
  49. package/FormBuilder/index.js +6 -2
  50. package/FormBuilder/index.js.map +7 -0
  51. package/FormBuilder/index.test.d.ts +1 -0
  52. package/FormBuilder/scenarios.test.d.ts +88 -0
  53. package/FormContext/index.js +7 -3
  54. package/FormContext.js.map +7 -0
  55. package/MultiplicityField/MultiplicityField.stories/index.js +20 -10
  56. package/MultiplicityField/MultiplicityField.stories.d.ts +6 -6
  57. package/MultiplicityField/MultiplicityField.stories.js.map +7 -0
  58. package/MultiplicityField/__stories__/Default/index.js +90 -85
  59. package/MultiplicityField/__stories__/Default.d.ts +2 -2
  60. package/MultiplicityField/__stories__/Default.js.map +7 -0
  61. package/MultiplicityField/__stories__/PreviewDisplay/index.js +70 -72
  62. package/MultiplicityField/__stories__/PreviewDisplay.d.ts +2 -2
  63. package/MultiplicityField/__stories__/PreviewDisplay.js.map +7 -0
  64. package/MultiplicityField/__stories__/WithExactLength/index.js +87 -80
  65. package/MultiplicityField/__stories__/WithExactLength.d.ts +2 -2
  66. package/MultiplicityField/__stories__/WithExactLength.js.map +7 -0
  67. package/MultiplicityField/__stories__/WithMaxLength/index.js +90 -83
  68. package/MultiplicityField/__stories__/WithMaxLength.d.ts +2 -2
  69. package/MultiplicityField/__stories__/WithMaxLength.js.map +7 -0
  70. package/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +91 -84
  71. package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +2 -2
  72. package/MultiplicityField/__stories__/WithMinAndMaxLength.js.map +7 -0
  73. package/MultiplicityField/__stories__/WithMinLength/index.js +90 -83
  74. package/MultiplicityField/__stories__/WithMinLength.d.ts +2 -2
  75. package/MultiplicityField/__stories__/WithMinLength.js.map +7 -0
  76. package/MultiplicityField/add-objects/index.js +130 -132
  77. package/MultiplicityField/add-objects.d.ts +1 -0
  78. package/MultiplicityField/add-objects.js.map +7 -0
  79. package/MultiplicityField/index.d.ts +1 -1
  80. package/MultiplicityField/index.js +111 -101
  81. package/MultiplicityField/index.js.map +7 -0
  82. package/MultiplicityField/index.test.d.ts +1 -0
  83. package/Questions/Questions/index.js +44 -53
  84. package/Questions/Questions.js.map +7 -0
  85. package/Questions/Questions.stories/index.js +10 -5
  86. package/Questions/Questions.stories.d.ts +1 -1
  87. package/Questions/Questions.stories.js.map +7 -0
  88. package/Questions/QuestionsContext/index.js +9 -9
  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.js.map +7 -0
  98. package/Questions/Step/StepDescription/index.js +22 -22
  99. package/Questions/Step/StepDescription.js.map +7 -0
  100. package/Questions/Step/StepForm/index.js +33 -43
  101. package/Questions/Step/StepForm.js.map +7 -0
  102. package/Questions/Step/StepQuote/index.js +10 -9
  103. package/Questions/Step/StepQuote.js.map +7 -0
  104. package/Questions/Step/StepTitle/index.js +40 -38
  105. package/Questions/Step/StepTitle.d.ts +1 -0
  106. package/Questions/Step/StepTitle.js.map +7 -0
  107. package/Questions/Step/getAddMoreFields/index.js +28 -20
  108. package/Questions/Step/getAddMoreFields.js.map +7 -0
  109. package/Questions/Step/index.d.ts +0 -1
  110. package/Questions/Step/index.js +16 -13
  111. package/Questions/Step/index.js.map +7 -0
  112. package/Questions/Step/types/index.js +1 -1
  113. package/Questions/Step/types.d.ts +2 -0
  114. package/Questions/Step/types.js.map +7 -0
  115. package/Questions/__stories__/Default/index.js +106 -100
  116. package/Questions/__stories__/Default.d.ts +2 -2
  117. package/Questions/__stories__/Default.js.map +7 -0
  118. package/Questions/getNextStep/index.js +12 -10
  119. package/Questions/getNextStep.js.map +7 -0
  120. package/Questions/index.js +7 -3
  121. package/Questions/index.js.map +7 -0
  122. package/Questions/index.test.d.ts +1 -0
  123. package/Questions/types/index.js +1 -1
  124. package/Questions/types.d.ts +2 -0
  125. package/Questions/types.js.map +7 -0
  126. package/cjs/Field/FieldBase/index.js +135 -82
  127. package/cjs/Field/FieldBase.js.map +7 -0
  128. package/cjs/Field/FieldBaseContainer/index.js +61 -43
  129. package/cjs/Field/FieldBaseContainer.js.map +7 -0
  130. package/cjs/Field/FieldConditional/index.js +111 -59
  131. package/cjs/Field/FieldConditional.js.map +7 -0
  132. package/cjs/Field/index.js +121 -72
  133. package/cjs/Field/index.js.map +7 -0
  134. package/cjs/Field/types/index.js +16 -5
  135. package/cjs/Field/types.js.map +7 -0
  136. package/cjs/Field/utils/index.js +139 -106
  137. package/cjs/Field/utils.js.map +7 -0
  138. package/cjs/FieldArray/FieldArray.stories/index.js +46 -36
  139. package/cjs/FieldArray/FieldArray.stories.js.map +7 -0
  140. package/cjs/FieldArray/__stories__/Default/index.js +119 -89
  141. package/cjs/FieldArray/__stories__/Default.js.map +7 -0
  142. package/cjs/FieldArray/__stories__/WithExactLength/index.js +119 -89
  143. package/cjs/FieldArray/__stories__/WithExactLength.js.map +7 -0
  144. package/cjs/FieldArray/index.js +97 -65
  145. package/cjs/FieldArray/index.js.map +7 -0
  146. package/cjs/FieldObject/index.js +98 -61
  147. package/cjs/FieldObject/index.js.map +7 -0
  148. package/cjs/Fieldset/FieldsetWithContext/index.js +54 -40
  149. package/cjs/Fieldset/FieldsetWithContext.js.map +7 -0
  150. package/cjs/Fieldset/index.js +61 -39
  151. package/cjs/Fieldset/index.js.map +7 -0
  152. package/cjs/Fieldset/types/index.js +16 -5
  153. package/cjs/Fieldset/types.js.map +7 -0
  154. package/cjs/Form.stories/index.js +25 -8
  155. package/cjs/Form.stories.js.map +7 -0
  156. package/cjs/FormBuilder/FormBuilder/index.js +158 -128
  157. package/cjs/FormBuilder/FormBuilder.js.map +7 -0
  158. package/cjs/FormBuilder/FormBuilder.stories/index.js +43 -24
  159. package/cjs/FormBuilder/FormBuilder.stories.js.map +7 -0
  160. package/cjs/FormBuilder/__stories__/Default/index.js +60 -31
  161. package/cjs/FormBuilder/__stories__/Default.js.map +7 -0
  162. package/cjs/FormBuilder/index.js +24 -7
  163. package/cjs/FormBuilder/index.js.map +7 -0
  164. package/cjs/FormContext/index.js +29 -8
  165. package/cjs/FormContext.js.map +7 -0
  166. package/cjs/MultiplicityField/MultiplicityField.stories/index.js +58 -84
  167. package/cjs/MultiplicityField/MultiplicityField.stories.js.map +7 -0
  168. package/cjs/MultiplicityField/__stories__/Default/index.js +122 -94
  169. package/cjs/MultiplicityField/__stories__/Default.js.map +7 -0
  170. package/cjs/MultiplicityField/__stories__/PreviewDisplay/index.js +85 -81
  171. package/cjs/MultiplicityField/__stories__/PreviewDisplay.js.map +7 -0
  172. package/cjs/MultiplicityField/__stories__/WithExactLength/index.js +119 -89
  173. package/cjs/MultiplicityField/__stories__/WithExactLength.js.map +7 -0
  174. package/cjs/MultiplicityField/__stories__/WithMaxLength/index.js +122 -92
  175. package/cjs/MultiplicityField/__stories__/WithMaxLength.js.map +7 -0
  176. package/cjs/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +123 -93
  177. package/cjs/MultiplicityField/__stories__/WithMinAndMaxLength.js.map +7 -0
  178. package/cjs/MultiplicityField/__stories__/WithMinLength/index.js +122 -92
  179. package/cjs/MultiplicityField/__stories__/WithMinLength.js.map +7 -0
  180. package/cjs/MultiplicityField/add-objects/index.js +160 -138
  181. package/cjs/MultiplicityField/add-objects.js.map +7 -0
  182. package/cjs/MultiplicityField/index.js +144 -110
  183. package/cjs/MultiplicityField/index.js.map +7 -0
  184. package/cjs/Questions/Questions/index.js +76 -62
  185. package/cjs/Questions/Questions.js.map +7 -0
  186. package/cjs/Questions/Questions.stories/index.js +43 -24
  187. package/cjs/Questions/Questions.stories.js.map +7 -0
  188. package/cjs/Questions/QuestionsContext/index.js +31 -14
  189. package/cjs/Questions/QuestionsContext.js.map +7 -0
  190. package/cjs/Questions/Step/ReviewStep/index.js +61 -56
  191. package/cjs/Questions/Step/ReviewStep.js.map +7 -0
  192. package/cjs/Questions/Step/Step/index.js +71 -56
  193. package/cjs/Questions/Step/Step.js.map +7 -0
  194. package/cjs/Questions/Step/StepArrayReview/index.js +65 -54
  195. package/cjs/Questions/Step/StepArrayReview.js.map +7 -0
  196. package/cjs/Questions/Step/StepContext/index.js +37 -24
  197. package/cjs/Questions/Step/StepContext.js.map +7 -0
  198. package/cjs/Questions/Step/StepDescription/index.js +55 -31
  199. package/cjs/Questions/Step/StepDescription.js.map +7 -0
  200. package/cjs/Questions/Step/StepForm/index.js +65 -52
  201. package/cjs/Questions/Step/StepForm.js.map +7 -0
  202. package/cjs/Questions/Step/StepQuote/index.js +42 -15
  203. package/cjs/Questions/Step/StepQuote.js.map +7 -0
  204. package/cjs/Questions/Step/StepTitle/index.js +72 -47
  205. package/cjs/Questions/Step/StepTitle.js.map +7 -0
  206. package/cjs/Questions/Step/getAddMoreFields/index.js +50 -25
  207. package/cjs/Questions/Step/getAddMoreFields.js.map +7 -0
  208. package/cjs/Questions/Step/index.js +59 -143
  209. package/cjs/Questions/Step/index.js.map +7 -0
  210. package/cjs/Questions/Step/types/index.js +16 -5
  211. package/cjs/Questions/Step/types.js.map +7 -0
  212. package/cjs/Questions/__stories__/Default/index.js +132 -109
  213. package/cjs/Questions/__stories__/Default.js.map +7 -0
  214. package/cjs/Questions/getNextStep/index.js +33 -14
  215. package/cjs/Questions/getNextStep.js.map +7 -0
  216. package/cjs/Questions/index.js +29 -19
  217. package/cjs/Questions/index.js.map +7 -0
  218. package/cjs/Questions/types/index.js +16 -5
  219. package/cjs/Questions/types.js.map +7 -0
  220. package/cjs/index.js +47 -20
  221. package/cjs/index.js.map +7 -0
  222. package/cjs/inputs/AutoCompleteInput/AutoComplete.stories/index.js +46 -24
  223. package/cjs/inputs/AutoCompleteInput/AutoComplete.stories.js.map +7 -0
  224. package/cjs/inputs/AutoCompleteInput/__stories__/Default/index.js +78 -51
  225. package/cjs/inputs/AutoCompleteInput/__stories__/Default.js.map +7 -0
  226. package/cjs/inputs/AutoCompleteInput/__stories__/Multiple/index.js +84 -0
  227. package/cjs/inputs/AutoCompleteInput/__stories__/Multiple.js.map +7 -0
  228. package/cjs/inputs/AutoCompleteInput/index.js +90 -46
  229. package/cjs/inputs/AutoCompleteInput/index.js.map +7 -0
  230. package/cjs/inputs/Checkboxes/Checkboxes.stories/index.js +49 -48
  231. package/cjs/inputs/Checkboxes/Checkboxes.stories.js.map +7 -0
  232. package/cjs/inputs/Checkboxes/__stories__/Conditional/index.js +120 -89
  233. package/cjs/inputs/Checkboxes/__stories__/Conditional.js.map +7 -0
  234. package/cjs/inputs/Checkboxes/__stories__/Default/index.js +73 -46
  235. package/cjs/inputs/Checkboxes/__stories__/Default.js.map +7 -0
  236. package/cjs/inputs/Checkboxes/__stories__/WithDivider/index.js +74 -47
  237. package/cjs/inputs/Checkboxes/__stories__/WithDivider.js.map +7 -0
  238. package/cjs/inputs/Checkboxes/index.js +102 -96
  239. package/cjs/inputs/Checkboxes/index.js.map +7 -0
  240. package/cjs/inputs/DateInput/DateInput.stories/index.js +43 -24
  241. package/cjs/inputs/DateInput/DateInput.stories.js.map +7 -0
  242. package/cjs/inputs/DateInput/__stories__/Default/index.js +56 -28
  243. package/cjs/inputs/DateInput/__stories__/Default.js.map +7 -0
  244. package/cjs/inputs/DateInput/index.js +122 -109
  245. package/cjs/inputs/DateInput/index.js.map +7 -0
  246. package/cjs/inputs/FileInput/FileInput.stories/index.js +43 -24
  247. package/cjs/inputs/FileInput/FileInput.stories.js.map +7 -0
  248. package/cjs/inputs/FileInput/__stories__/Default/index.js +57 -26
  249. package/cjs/inputs/FileInput/__stories__/Default.js.map +7 -0
  250. package/cjs/inputs/FileInput/index.js +76 -63
  251. package/cjs/inputs/FileInput/index.js.map +7 -0
  252. package/cjs/inputs/ImageInput/ImageInput.stories/index.js +49 -48
  253. package/cjs/inputs/ImageInput/ImageInput.stories.js.map +7 -0
  254. package/cjs/inputs/ImageInput/__stories__/Default/index.js +58 -33
  255. package/cjs/inputs/ImageInput/__stories__/Default.js.map +7 -0
  256. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +65 -40
  257. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +7 -0
  258. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +62 -37
  259. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageSize.js.map +7 -0
  260. package/cjs/inputs/ImageInput/index.js +91 -83
  261. package/cjs/inputs/ImageInput/index.js.map +7 -0
  262. package/cjs/inputs/Input/Input.stories/index.js +70 -120
  263. package/cjs/inputs/Input/Input.stories.js.map +7 -0
  264. package/cjs/inputs/Input/__stories__/AFM/index.js +60 -29
  265. package/cjs/inputs/Input/__stories__/AFM.js.map +7 -0
  266. package/cjs/inputs/Input/__stories__/Boolean/index.js +61 -30
  267. package/cjs/inputs/Input/__stories__/Boolean.js.map +7 -0
  268. package/cjs/inputs/Input/__stories__/IBAN/index.js +61 -30
  269. package/cjs/inputs/Input/__stories__/IBAN.js.map +7 -0
  270. package/cjs/inputs/Input/__stories__/Integer/index.js +75 -38
  271. package/cjs/inputs/Input/__stories__/Integer.js.map +7 -0
  272. package/cjs/inputs/Input/__stories__/LandlineNumber/index.js +67 -0
  273. package/cjs/inputs/Input/__stories__/LandlineNumber.js.map +7 -0
  274. package/cjs/inputs/Input/__stories__/MobilePhone/index.js +64 -29
  275. package/cjs/inputs/Input/__stories__/MobilePhone.js.map +7 -0
  276. package/cjs/inputs/Input/__stories__/PhoneNumber/index.js +63 -29
  277. package/cjs/inputs/Input/__stories__/PhoneNumber.js.map +7 -0
  278. package/cjs/inputs/Input/__stories__/PostalCode/index.js +60 -31
  279. package/cjs/inputs/Input/__stories__/PostalCode.js.map +7 -0
  280. package/cjs/inputs/Input/__stories__/String/index.js +64 -0
  281. package/cjs/inputs/Input/__stories__/String.js.map +7 -0
  282. package/cjs/inputs/Input/__stories__/TextWithLimit/index.js +64 -0
  283. package/cjs/inputs/Input/__stories__/TextWithLimit.js.map +7 -0
  284. package/cjs/inputs/Input/index.js +87 -72
  285. package/cjs/inputs/Input/index.js.map +7 -0
  286. package/cjs/inputs/Input/inputsInputScenarios/index.js +439 -0
  287. package/cjs/inputs/Input/inputsInputScenarios.js.map +7 -0
  288. package/cjs/inputs/Label/Label.stories/index.js +43 -24
  289. package/cjs/inputs/Label/Label.stories.js.map +7 -0
  290. package/cjs/inputs/Label/__stories__/Default/index.js +66 -33
  291. package/cjs/inputs/Label/__stories__/Default.js.map +7 -0
  292. package/cjs/inputs/Label/index.js +45 -24
  293. package/cjs/inputs/Label/index.js.map +7 -0
  294. package/cjs/inputs/OtpInput/OtpInput.stories/index.js +43 -24
  295. package/cjs/inputs/OtpInput/OtpInput.stories.js.map +7 -0
  296. package/cjs/inputs/OtpInput/__stories__/Default/index.js +59 -34
  297. package/cjs/inputs/OtpInput/__stories__/Default.js.map +7 -0
  298. package/cjs/inputs/OtpInput/index.js +142 -112
  299. package/cjs/inputs/OtpInput/index.js.map +7 -0
  300. package/cjs/inputs/Radio/Radio.stories/index.js +49 -48
  301. package/cjs/inputs/Radio/Radio.stories.js.map +7 -0
  302. package/cjs/inputs/Radio/__stories__/Conditional/index.js +120 -89
  303. package/cjs/inputs/Radio/__stories__/Conditional.js.map +7 -0
  304. package/cjs/inputs/Radio/__stories__/Default/index.js +77 -51
  305. package/cjs/inputs/Radio/__stories__/Default.js.map +7 -0
  306. package/cjs/inputs/Radio/__stories__/WithDivider/index.js +78 -52
  307. package/cjs/inputs/Radio/__stories__/WithDivider.js.map +7 -0
  308. package/cjs/inputs/Radio/index.js +132 -61
  309. package/cjs/inputs/Radio/index.js.map +7 -0
  310. package/cjs/inputs/Select/Select.stories/index.js +43 -24
  311. package/cjs/inputs/Select/Select.stories.js.map +7 -0
  312. package/cjs/inputs/Select/__stories__/Default/index.js +82 -57
  313. package/cjs/inputs/Select/__stories__/Default.js.map +7 -0
  314. package/cjs/inputs/Select/index.js +55 -36
  315. package/cjs/inputs/Select/index.js.map +7 -0
  316. package/cjs/inputs/index.js +62 -69
  317. package/cjs/inputs/index.js.map +7 -0
  318. package/cjs/inputs/inputsScenarios/index.js +540 -0
  319. package/cjs/inputs/inputsScenarios.js.map +7 -0
  320. package/cjs/internal/index.js +116 -346
  321. package/cjs/internal.js.map +7 -0
  322. package/cjs/lazy/index.js +93 -0
  323. package/cjs/lazy.js.map +7 -0
  324. package/cjs/locales/el/index.js +35 -0
  325. package/cjs/locales/el.js.map +7 -0
  326. package/cjs/registry/index.js +174 -142
  327. package/cjs/registry.js.map +7 -0
  328. package/cjs/types/index.js +16 -5
  329. package/cjs/types.js.map +7 -0
  330. package/cjs/utils/index.js +78 -83
  331. package/cjs/utils.js.map +7 -0
  332. package/cjs/validators/index.js +130 -128
  333. package/cjs/validators/index.js.map +7 -0
  334. package/cjs/validators/types/index.js +16 -5
  335. package/cjs/validators/types.js.map +7 -0
  336. package/cjs/validators/utils/afm/index.js +38 -21
  337. package/cjs/validators/utils/afm.js.map +7 -0
  338. package/cjs/validators/utils/file/index.js +44 -47
  339. package/cjs/validators/utils/file.js.map +7 -0
  340. package/cjs/validators/utils/iban/index.js +36 -17
  341. package/cjs/validators/utils/iban.js.map +7 -0
  342. package/cjs/validators/utils/image/index.js +88 -112
  343. package/cjs/validators/utils/image.js.map +7 -0
  344. package/cjs/validators/utils/index.js +95 -159
  345. package/cjs/validators/utils/index.js.map +7 -0
  346. package/cjs/validators/utils/int/index.js +34 -12
  347. package/cjs/validators/utils/int.js.map +7 -0
  348. package/cjs/validators/utils/number/index.js +33 -11
  349. package/cjs/validators/utils/number.js.map +7 -0
  350. package/cjs/validators/utils/otp/index.js +35 -13
  351. package/cjs/validators/utils/otp.js.map +7 -0
  352. package/cjs/validators/utils/phone/index.js +171 -92
  353. package/cjs/validators/utils/phone.js.map +7 -0
  354. package/cjs/validators/utils/postal_code/index.js +36 -16
  355. package/cjs/validators/utils/postal_code.js.map +7 -0
  356. package/cjs/validators/utils/text_limit/index.js +40 -25
  357. package/cjs/validators/utils/text_limit.js.map +7 -0
  358. package/cjs/validators/utils/uuid4/index.js +34 -13
  359. package/cjs/validators/utils/uuid4.js.map +7 -0
  360. package/index.d.ts +4 -1
  361. package/index.js +13 -4
  362. package/index.js.map +7 -0
  363. package/inputs/AutoCompleteInput/AutoComplete.stories/index.js +12 -5
  364. package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +2 -1
  365. package/inputs/AutoCompleteInput/AutoComplete.stories.js.map +7 -0
  366. package/inputs/AutoCompleteInput/__stories__/Default/index.js +46 -42
  367. package/inputs/AutoCompleteInput/__stories__/Default.d.ts +3 -2
  368. package/inputs/AutoCompleteInput/__stories__/Default.js.map +7 -0
  369. package/inputs/AutoCompleteInput/__stories__/Multiple/index.js +51 -0
  370. package/inputs/AutoCompleteInput/__stories__/Multiple/package.json +6 -0
  371. package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +3 -0
  372. package/inputs/AutoCompleteInput/__stories__/Multiple.js.map +7 -0
  373. package/inputs/AutoCompleteInput/index.d.ts +1 -1
  374. package/inputs/AutoCompleteInput/index.js +58 -37
  375. package/inputs/AutoCompleteInput/index.js.map +7 -0
  376. package/inputs/AutoCompleteInput/index.test.d.ts +1 -0
  377. package/inputs/Checkboxes/Checkboxes.stories/index.js +14 -7
  378. package/inputs/Checkboxes/Checkboxes.stories.d.ts +3 -3
  379. package/inputs/Checkboxes/Checkboxes.stories.js.map +7 -0
  380. package/inputs/Checkboxes/__stories__/Conditional/index.js +88 -80
  381. package/inputs/Checkboxes/__stories__/Conditional.d.ts +3 -2
  382. package/inputs/Checkboxes/__stories__/Conditional.js.map +7 -0
  383. package/inputs/Checkboxes/__stories__/Default/index.js +40 -36
  384. package/inputs/Checkboxes/__stories__/Default.d.ts +2 -2
  385. package/inputs/Checkboxes/__stories__/Default.js.map +7 -0
  386. package/inputs/Checkboxes/__stories__/WithDivider/index.js +41 -37
  387. package/inputs/Checkboxes/__stories__/WithDivider.d.ts +2 -2
  388. package/inputs/Checkboxes/__stories__/WithDivider.js.map +7 -0
  389. package/inputs/Checkboxes/index.js +70 -87
  390. package/inputs/Checkboxes/index.js.map +7 -0
  391. package/inputs/Checkboxes/index.test.d.ts +1 -0
  392. package/inputs/DateInput/DateInput.stories/index.js +10 -5
  393. package/inputs/DateInput/DateInput.stories.d.ts +1 -1
  394. package/inputs/DateInput/DateInput.stories.js.map +7 -0
  395. package/inputs/DateInput/__stories__/Default/index.js +23 -18
  396. package/inputs/DateInput/__stories__/Default.d.ts +2 -2
  397. package/inputs/DateInput/__stories__/Default.js.map +7 -0
  398. package/inputs/DateInput/index.d.ts +2 -2
  399. package/inputs/DateInput/index.js +89 -99
  400. package/inputs/DateInput/index.js.map +7 -0
  401. package/inputs/DateInput/index.test.d.ts +1 -0
  402. package/inputs/FileInput/FileInput.stories/index.js +10 -5
  403. package/inputs/FileInput/FileInput.stories.d.ts +1 -1
  404. package/inputs/FileInput/FileInput.stories.js.map +7 -0
  405. package/inputs/FileInput/__stories__/Default/index.js +24 -16
  406. package/inputs/FileInput/__stories__/Default.d.ts +2 -2
  407. package/inputs/FileInput/__stories__/Default.js.map +7 -0
  408. package/inputs/FileInput/index.js +44 -54
  409. package/inputs/FileInput/index.js.map +7 -0
  410. package/inputs/FileInput/index.test.d.ts +1 -0
  411. package/inputs/ImageInput/ImageInput.stories/index.js +14 -7
  412. package/inputs/ImageInput/ImageInput.stories.d.ts +3 -3
  413. package/inputs/ImageInput/ImageInput.stories.js.map +7 -0
  414. package/inputs/ImageInput/__stories__/Default/index.js +25 -23
  415. package/inputs/ImageInput/__stories__/Default.d.ts +2 -2
  416. package/inputs/ImageInput/__stories__/Default.js.map +7 -0
  417. package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +32 -30
  418. package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +2 -2
  419. package/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +7 -0
  420. package/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +29 -27
  421. package/inputs/ImageInput/__stories__/WithInvalidImageSize.d.ts +2 -2
  422. package/inputs/ImageInput/__stories__/WithInvalidImageSize.js.map +7 -0
  423. package/inputs/ImageInput/index.js +59 -75
  424. package/inputs/ImageInput/index.js.map +7 -0
  425. package/inputs/ImageInput/index.test.d.ts +1 -0
  426. package/inputs/Input/Input.stories/index.js +28 -13
  427. package/inputs/Input/Input.stories.d.ts +10 -9
  428. package/inputs/Input/Input.stories.js.map +7 -0
  429. package/inputs/Input/__stories__/AFM/index.js +27 -19
  430. package/inputs/Input/__stories__/AFM.d.ts +2 -2
  431. package/inputs/Input/__stories__/AFM.js.map +7 -0
  432. package/inputs/Input/__stories__/Boolean/index.js +28 -20
  433. package/inputs/Input/__stories__/Boolean.d.ts +2 -2
  434. package/inputs/Input/__stories__/Boolean.js.map +7 -0
  435. package/inputs/Input/__stories__/IBAN/index.js +28 -20
  436. package/inputs/Input/__stories__/IBAN.d.ts +2 -2
  437. package/inputs/Input/__stories__/IBAN.js.map +7 -0
  438. package/inputs/Input/__stories__/Integer/index.js +43 -29
  439. package/inputs/Input/__stories__/Integer.d.ts +2 -2
  440. package/inputs/Input/__stories__/Integer.js.map +7 -0
  441. package/inputs/Input/__stories__/LandlineNumber/index.js +34 -0
  442. package/inputs/Input/__stories__/LandlineNumber/package.json +6 -0
  443. package/inputs/Input/__stories__/LandlineNumber.d.ts +3 -0
  444. package/inputs/Input/__stories__/LandlineNumber.js.map +7 -0
  445. package/inputs/Input/__stories__/MobilePhone/index.js +31 -19
  446. package/inputs/Input/__stories__/MobilePhone.d.ts +2 -2
  447. package/inputs/Input/__stories__/MobilePhone.js.map +7 -0
  448. package/inputs/Input/__stories__/PhoneNumber/index.js +30 -19
  449. package/inputs/Input/__stories__/PhoneNumber.d.ts +2 -2
  450. package/inputs/Input/__stories__/PhoneNumber.js.map +7 -0
  451. package/inputs/Input/__stories__/PostalCode/index.js +27 -21
  452. package/inputs/Input/__stories__/PostalCode.d.ts +2 -2
  453. package/inputs/Input/__stories__/PostalCode.js.map +7 -0
  454. package/inputs/Input/__stories__/String/index.js +31 -0
  455. package/inputs/Input/__stories__/{Default → String}/package.json +1 -1
  456. package/inputs/Input/__stories__/String.d.ts +3 -0
  457. package/inputs/Input/__stories__/String.js.map +7 -0
  458. package/inputs/Input/__stories__/TextWithLimit/index.js +31 -0
  459. package/inputs/Input/__stories__/TextWithLimit/package.json +6 -0
  460. package/inputs/Input/__stories__/TextWithLimit.d.ts +3 -0
  461. package/inputs/Input/__stories__/TextWithLimit.js.map +7 -0
  462. package/inputs/Input/index.js +56 -67
  463. package/inputs/Input/index.js.map +7 -0
  464. package/inputs/Input/index.test.d.ts +1 -0
  465. package/inputs/Input/inputsInputScenarios/index.js +406 -0
  466. package/inputs/Input/inputsInputScenarios/package.json +6 -0
  467. package/inputs/Input/inputsInputScenarios.d.ts +57 -0
  468. package/inputs/Input/inputsInputScenarios.js.map +7 -0
  469. package/inputs/Label/Label.stories/index.js +10 -5
  470. package/inputs/Label/Label.stories.d.ts +1 -1
  471. package/inputs/Label/Label.stories.js.map +7 -0
  472. package/inputs/Label/__stories__/Default/index.js +33 -23
  473. package/inputs/Label/__stories__/Default.d.ts +2 -2
  474. package/inputs/Label/__stories__/Default.js.map +7 -0
  475. package/inputs/Label/index.d.ts +1 -1
  476. package/inputs/Label/index.js +12 -17
  477. package/inputs/Label/index.js.map +7 -0
  478. package/inputs/Label/index.test.d.ts +1 -0
  479. package/inputs/OtpInput/OtpInput.stories/index.js +10 -5
  480. package/inputs/OtpInput/OtpInput.stories.d.ts +1 -1
  481. package/inputs/OtpInput/OtpInput.stories.js.map +7 -0
  482. package/inputs/OtpInput/__stories__/Default/index.js +26 -24
  483. package/inputs/OtpInput/__stories__/Default.d.ts +2 -2
  484. package/inputs/OtpInput/__stories__/Default.js.map +7 -0
  485. package/inputs/OtpInput/index.d.ts +9 -2
  486. package/inputs/OtpInput/index.js +109 -103
  487. package/inputs/OtpInput/index.js.map +7 -0
  488. package/inputs/OtpInput/index.test.d.ts +1 -0
  489. package/inputs/Radio/Radio.stories/index.js +14 -7
  490. package/inputs/Radio/Radio.stories.d.ts +3 -3
  491. package/inputs/Radio/Radio.stories.js.map +7 -0
  492. package/inputs/Radio/__stories__/Conditional/index.js +88 -80
  493. package/inputs/Radio/__stories__/Conditional.d.ts +3 -2
  494. package/inputs/Radio/__stories__/Conditional.js.map +7 -0
  495. package/inputs/Radio/__stories__/Default/index.js +44 -41
  496. package/inputs/Radio/__stories__/Default.d.ts +2 -2
  497. package/inputs/Radio/__stories__/Default.js.map +7 -0
  498. package/inputs/Radio/__stories__/WithDivider/index.js +45 -42
  499. package/inputs/Radio/__stories__/WithDivider.d.ts +2 -2
  500. package/inputs/Radio/__stories__/WithDivider.js.map +7 -0
  501. package/inputs/Radio/index.d.ts +4 -0
  502. package/inputs/Radio/index.js +99 -55
  503. package/inputs/Radio/index.js.map +7 -0
  504. package/inputs/Radio/index.test.d.ts +1 -0
  505. package/inputs/Select/Select.stories/index.js +10 -5
  506. package/inputs/Select/Select.stories.d.ts +1 -1
  507. package/inputs/Select/Select.stories.js.map +7 -0
  508. package/inputs/Select/__stories__/Default/index.js +49 -47
  509. package/inputs/Select/__stories__/Default.d.ts +2 -2
  510. package/inputs/Select/__stories__/Default.js.map +7 -0
  511. package/inputs/Select/index.js +24 -31
  512. package/inputs/Select/index.js.map +7 -0
  513. package/inputs/Select/index.test.d.ts +1 -0
  514. package/inputs/index.js +21 -9
  515. package/inputs/index.js.map +7 -0
  516. package/inputs/inputsScenarios/index.js +506 -0
  517. package/{validators/validators.spec → inputs/inputsScenarios}/package.json +1 -1
  518. package/inputs/inputsScenarios.d.ts +338 -0
  519. package/inputs/inputsScenarios.js.map +7 -0
  520. package/internal/index.js +51 -34
  521. package/internal.js.map +7 -0
  522. package/lazy/index.js +64 -0
  523. package/{Questions/index.spec → lazy}/package.json +1 -1
  524. package/lazy.d.ts +70 -0
  525. package/lazy.js.map +7 -0
  526. package/locales/el/index.js +6 -0
  527. package/locales/el/package.json +6 -0
  528. package/locales/el.d.ts +2 -0
  529. package/locales/el.js.map +7 -0
  530. package/package.json +5 -7
  531. package/registry/index.js +146 -134
  532. package/registry.d.ts +3 -0
  533. package/registry.js.map +7 -0
  534. package/src/Field/FieldBase.tsx +2 -0
  535. package/src/Field/FieldBaseContainer.tsx +1 -1
  536. package/src/Field/FieldConditional.tsx +4 -0
  537. package/src/Field/index.tsx +7 -1
  538. package/src/Field/types.tsx +7 -0
  539. package/src/Field/utils.ts +13 -6
  540. package/src/FieldArray/FieldArray.stories.js +2 -2
  541. package/src/FieldArray/index.test.tsx +24 -0
  542. package/src/FieldArray/index.tsx +12 -6
  543. package/src/FieldObject/index.tsx +10 -2
  544. package/src/Fieldset/types.tsx +3 -1
  545. package/src/FormBuilder/FormBuilder.stories.js +1 -1
  546. package/src/FormBuilder/FormBuilder.tsx +15 -3
  547. package/src/FormBuilder/index.test.tsx +20 -0
  548. package/src/FormBuilder/scenarios.test.tsx +1864 -0
  549. package/src/MultiplicityField/MultiplicityField.stories.js +6 -6
  550. package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +2 -2
  551. package/src/MultiplicityField/__stories__/WithExactLength.tsx +1 -1
  552. package/src/MultiplicityField/__stories__/WithMaxLength.tsx +1 -1
  553. package/src/MultiplicityField/__stories__/WithMinAndMaxLength.tsx +1 -1
  554. package/src/MultiplicityField/__stories__/WithMinLength.tsx +1 -1
  555. package/src/MultiplicityField/add-objects.tsx +26 -23
  556. package/src/MultiplicityField/index.test.tsx +40 -0
  557. package/src/MultiplicityField/index.tsx +9 -9
  558. package/src/Questions/Questions.stories.js +1 -1
  559. package/src/Questions/Step/StepTitle.tsx +1 -0
  560. package/src/Questions/Step/index.ts +0 -1
  561. package/src/Questions/Step/types.tsx +1 -0
  562. package/src/Questions/__snapshots__/index.spec.tsx.snap +67 -586
  563. package/src/Questions/index.mdx +4 -4
  564. package/src/Questions/index.spec.tsx +3 -3
  565. package/src/Questions/index.test.tsx +20 -0
  566. package/src/Questions/types.tsx +1 -0
  567. package/src/index.ts +4 -1
  568. package/src/inputs/AutoCompleteInput/AutoComplete.stories.js +2 -1
  569. package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +27 -18
  570. package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +54 -0
  571. package/src/inputs/AutoCompleteInput/index.mdx +29 -0
  572. package/src/inputs/AutoCompleteInput/index.test.tsx +24 -0
  573. package/src/inputs/AutoCompleteInput/index.tsx +29 -17
  574. package/src/inputs/Checkboxes/Checkboxes.stories.js +3 -3
  575. package/src/inputs/Checkboxes/__stories__/Conditional.tsx +2 -3
  576. package/src/inputs/Checkboxes/index.mdx +33 -0
  577. package/src/inputs/Checkboxes/index.test.tsx +29 -0
  578. package/src/inputs/Checkboxes/index.tsx +28 -26
  579. package/src/inputs/DateInput/DateInput.stories.js +1 -1
  580. package/src/inputs/DateInput/__stories__/Default.tsx +21 -15
  581. package/src/inputs/DateInput/index.mdx +23 -0
  582. package/src/inputs/DateInput/index.test.tsx +20 -0
  583. package/src/inputs/DateInput/index.tsx +3 -3
  584. package/src/inputs/FileInput/FileInput.stories.js +1 -1
  585. package/src/inputs/FileInput/index.mdx +19 -0
  586. package/src/inputs/FileInput/index.test.tsx +20 -0
  587. package/src/inputs/ImageInput/ImageInput.stories.js +3 -3
  588. package/src/inputs/ImageInput/index.mdx +19 -0
  589. package/src/inputs/ImageInput/index.test.tsx +28 -0
  590. package/src/inputs/ImageInput/index.tsx +4 -4
  591. package/src/inputs/Input/Input.stories.js +10 -9
  592. package/src/inputs/Input/__stories__/LandlineNumber.tsx +27 -0
  593. package/src/inputs/Input/__stories__/MobilePhone.tsx +4 -0
  594. package/src/inputs/Input/__stories__/PhoneNumber.tsx +4 -1
  595. package/src/inputs/Input/__stories__/{Default.tsx → String.tsx} +2 -2
  596. package/src/inputs/Input/__stories__/{TextWithCharacterLimit.tsx → TextWithLimit.tsx} +2 -2
  597. package/src/inputs/Input/index.mdx +90 -3
  598. package/src/inputs/Input/index.test.tsx +56 -0
  599. package/src/inputs/Input/index.tsx +13 -13
  600. package/src/inputs/Input/inputsInputScenarios.ts +405 -0
  601. package/src/inputs/Label/Label.stories.js +1 -1
  602. package/src/inputs/Label/index.test.tsx +20 -0
  603. package/src/inputs/Label/index.tsx +1 -4
  604. package/src/inputs/OtpInput/OtpInput.stories.js +1 -1
  605. package/src/inputs/OtpInput/index.mdx +23 -0
  606. package/src/inputs/OtpInput/index.test.tsx +20 -0
  607. package/src/inputs/OtpInput/index.tsx +2 -2
  608. package/src/inputs/Radio/Radio.stories.js +3 -3
  609. package/src/inputs/Radio/__stories__/Conditional.tsx +4 -1
  610. package/src/inputs/Radio/index.mdx +33 -0
  611. package/src/inputs/Radio/index.test.tsx +28 -0
  612. package/src/inputs/Radio/index.tsx +65 -6
  613. package/src/inputs/Select/Select.stories.js +1 -1
  614. package/src/inputs/Select/index.mdx +17 -0
  615. package/src/inputs/Select/index.test.tsx +20 -0
  616. package/src/inputs/inputsScenarios.ts +503 -0
  617. package/src/lazy.js +61 -0
  618. package/src/locales/el.ts +3 -0
  619. package/src/registry.js +6 -0
  620. package/src/types.tsx +21 -19
  621. package/src/utils.ts +34 -33
  622. package/src/validators/index.ts +5 -0
  623. package/src/validators/utils/file.ts +9 -9
  624. package/src/validators/utils/phone.ts +143 -72
  625. package/src/validators/validators.spec.ts +3 -37
  626. package/types/index.js +1 -1
  627. package/types.d.ts +2 -0
  628. package/types.js.map +7 -0
  629. package/utils/index.js +56 -77
  630. package/utils.js.map +7 -0
  631. package/validators/index.js +101 -110
  632. package/validators/index.js.map +7 -0
  633. package/validators/types/index.js +1 -1
  634. package/validators/types.js.map +7 -0
  635. package/validators/utils/afm/index.js +16 -16
  636. package/validators/utils/afm.js.map +7 -0
  637. package/validators/utils/file/index.js +22 -42
  638. package/validators/utils/file.js.map +7 -0
  639. package/validators/utils/iban/index.js +14 -12
  640. package/validators/utils/iban.js.map +7 -0
  641. package/validators/utils/image/index.js +66 -106
  642. package/validators/utils/image.js.map +7 -0
  643. package/validators/utils/index.js +54 -48
  644. package/validators/utils/index.js.map +7 -0
  645. package/validators/utils/int/index.js +12 -7
  646. package/validators/utils/int.js.map +7 -0
  647. package/validators/utils/number/index.js +11 -6
  648. package/validators/utils/number.js.map +7 -0
  649. package/validators/utils/otp/index.js +13 -8
  650. package/validators/utils/otp.js.map +7 -0
  651. package/validators/utils/phone/index.js +146 -82
  652. package/validators/utils/phone.d.ts +2 -2
  653. package/validators/utils/phone.js.map +7 -0
  654. package/validators/utils/postal_code/index.js +14 -11
  655. package/validators/utils/postal_code.js.map +7 -0
  656. package/validators/utils/text_limit/index.js +18 -20
  657. package/validators/utils/text_limit.js.map +7 -0
  658. package/validators/utils/uuid4/index.js +12 -8
  659. package/validators/utils/uuid4.js.map +7 -0
  660. package/Field/index.mdx +0 -6
  661. package/FieldArray/FieldArray.stories.playwright.json +0 -353
  662. package/FormBuilder/FormBuilder.mdx +0 -256
  663. package/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  664. package/MultiplicityField/MultiplicityField.mdx +0 -590
  665. package/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  666. package/Questions/__snapshots__/index.spec.tsx.snap +0 -596
  667. package/Questions/index.mdx +0 -415
  668. package/Questions/index.spec/index.js +0 -59
  669. package/cjs/Field/index.mdx +0 -6
  670. package/cjs/FieldArray/FieldArray.stories.playwright.json +0 -353
  671. package/cjs/FormBuilder/FormBuilder.mdx +0 -256
  672. package/cjs/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  673. package/cjs/MultiplicityField/MultiplicityField.mdx +0 -590
  674. package/cjs/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  675. package/cjs/Questions/__snapshots__/index.spec.tsx.snap +0 -596
  676. package/cjs/Questions/index.mdx +0 -415
  677. package/cjs/Questions/index.spec/index.js +0 -63
  678. package/cjs/create-simple-form.mdx +0 -539
  679. package/cjs/index.mdx +0 -51
  680. package/cjs/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  681. package/cjs/inputs/Checkboxes/index.mdx +0 -0
  682. package/cjs/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  683. package/cjs/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  684. package/cjs/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
  685. package/cjs/inputs/Input/Input.stories.playwright.json +0 -376
  686. package/cjs/inputs/Input/__stories__/Default/index.js +0 -33
  687. package/cjs/inputs/Input/__stories__/TextWithCharacterLimit/index.js +0 -39
  688. package/cjs/inputs/Input/index.mdx +0 -8
  689. package/cjs/inputs/Label/Label.stories.playwright.json +0 -40
  690. package/cjs/inputs/Label/index.mdx +0 -0
  691. package/cjs/inputs/Radio/Radio.stories.playwright.json +0 -73
  692. package/cjs/inputs/Radio/index.mdx +0 -0
  693. package/cjs/inputs/Select/Select.stories.playwright.json +0 -22
  694. package/cjs/installation.mdx +0 -68
  695. package/cjs/validators/validators.spec/index.js +0 -87
  696. package/create-simple-form.mdx +0 -539
  697. package/index.mdx +0 -51
  698. package/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  699. package/inputs/Checkboxes/index.mdx +0 -0
  700. package/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  701. package/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  702. package/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
  703. package/inputs/Input/Input.stories.playwright.json +0 -376
  704. package/inputs/Input/__stories__/Default/index.js +0 -23
  705. package/inputs/Input/__stories__/Default.d.ts +0 -3
  706. package/inputs/Input/__stories__/TextWithCharacterLimit/index.js +0 -29
  707. package/inputs/Input/__stories__/TextWithCharacterLimit/package.json +0 -6
  708. package/inputs/Input/__stories__/TextWithCharacterLimit.d.ts +0 -3
  709. package/inputs/Input/index.mdx +0 -8
  710. package/inputs/Label/Label.stories.playwright.json +0 -40
  711. package/inputs/Label/index.mdx +0 -0
  712. package/inputs/Radio/Radio.stories.playwright.json +0 -73
  713. package/inputs/Radio/index.mdx +0 -0
  714. package/inputs/Select/Select.stories.playwright.json +0 -22
  715. package/installation.mdx +0 -68
  716. package/src/FieldArray/FieldArray.stories.playwright.json +0 -353
  717. package/src/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  718. package/src/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  719. package/src/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  720. package/src/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  721. package/src/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  722. package/src/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
  723. package/src/inputs/Input/Input.stories.playwright.json +0 -376
  724. package/src/inputs/Label/Label.stories.playwright.json +0 -40
  725. package/src/inputs/Radio/Radio.stories.playwright.json +0 -73
  726. package/src/inputs/Select/Select.stories.playwright.json +0 -22
  727. package/validators/validators.spec/index.js +0 -85
package/utils/index.js CHANGED
@@ -1,80 +1,59 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
- import _extends from "@babel/runtime/helpers/extends";
3
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
- 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; }
5
- import { validateFieldsNatively } from '@hookform/resolvers';
6
- import { appendErrors } from 'react-hook-form';
7
- /**
8
- * Why `path!` ? because it could be `undefined` in some case
9
- * https://github.com/jquense/yup#validationerrorerrors-string--arraystring-value-any-path-string
10
- */
11
- var parseErrorSchema = function parseErrorSchema(error, validateAllFieldCriteria) {
12
- return (error.inner || []).reduce(function (previous, error) {
13
- var _error$path;
14
- error.path = (_error$path = error.path) === null || _error$path === void 0 ? void 0 : _error$path.replace(/\[([0-9]+)\]/g, '.$1');
15
- if (!previous[error.path]) {
16
- previous[error.path] = {
17
- message: error.message,
18
- type: error.type
19
- };
1
+ import { validateFieldsNatively } from "@hookform/resolvers";
2
+ import { appendErrors } from "react-hook-form";
3
+ const parseErrorSchema = (error, validateAllFieldCriteria) => {
4
+ return (error.inner || []).reduce(
5
+ (previous, error2) => {
6
+ error2.path = error2.path?.replace(/\[([0-9]+)\]/g, ".$1");
7
+ if (!previous[error2.path]) {
8
+ previous[error2.path] = { message: error2.message, type: error2.type };
9
+ }
10
+ if (validateAllFieldCriteria) {
11
+ const types = previous[error2.path].types;
12
+ const messages = types && types[error2.type];
13
+ previous[error2.path] = appendErrors(
14
+ error2.path,
15
+ validateAllFieldCriteria,
16
+ previous,
17
+ error2.type,
18
+ messages ? [].concat(messages, error2.message) : error2.message
19
+ );
20
+ }
21
+ return previous;
22
+ },
23
+ {}
24
+ );
25
+ };
26
+ const yupResolver = (schema, schemaOptions = {}, resolverOptions = {}) => async (values, context, options) => {
27
+ try {
28
+ if (schemaOptions.context && process.env.NODE_ENV === "development") {
29
+ console.warn(
30
+ "You should not used the yup options context. Please, use the 'useForm' context object instead"
31
+ );
20
32
  }
21
- if (validateAllFieldCriteria) {
22
- var types = previous[error.path].types;
23
- var messages = types && types[error.type];
24
- previous[error.path] = appendErrors(error.path, validateAllFieldCriteria, previous, error.type, messages ? [].concat(messages, error.message) : error.message);
33
+ const result = await schema[resolverOptions.mode === "sync" ? "validateSync" : "validate"](
34
+ values,
35
+ Object.assign({ abortEarly: false }, schemaOptions, { context })
36
+ );
37
+ options.shouldUseNativeValidation && validateFieldsNatively({}, options);
38
+ return {
39
+ values: resolverOptions.rawValues ? values : result,
40
+ errors: {}
41
+ };
42
+ } catch (e) {
43
+ if (!e.inner) {
44
+ throw e;
25
45
  }
26
- return previous;
27
- }, {});
28
- };
29
- export var yupResolver = function yupResolver(schema) {
30
- var schemaOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
31
- var resolverOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
32
- return /*#__PURE__*/function () {
33
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(values, context, options) {
34
- var result, parsed;
35
- return _regeneratorRuntime().wrap(function _callee$(_context) {
36
- while (1) switch (_context.prev = _context.next) {
37
- case 0:
38
- _context.prev = 0;
39
- if (schemaOptions.context && process.env.NODE_ENV === 'development') {
40
- // eslint-disable-next-line no-console
41
- console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead");
42
- }
43
- _context.next = 4;
44
- return schema[resolverOptions.mode === 'sync' ? 'validateSync' : 'validate'](values, _extends({
45
- abortEarly: false
46
- }, schemaOptions, {
47
- context: context
48
- }));
49
- case 4:
50
- result = _context.sent;
51
- options.shouldUseNativeValidation && validateFieldsNatively({}, options);
52
- return _context.abrupt("return", {
53
- values: resolverOptions.rawValues ? values : result,
54
- errors: {}
55
- });
56
- case 9:
57
- _context.prev = 9;
58
- _context.t0 = _context["catch"](0);
59
- if (_context.t0.inner) {
60
- _context.next = 13;
61
- break;
62
- }
63
- throw _context.t0;
64
- case 13:
65
- parsed = parseErrorSchema(_context.t0, !options.shouldUseNativeValidation && options.criteriaMode === 'all');
66
- return _context.abrupt("return", {
67
- values: {},
68
- errors: parsed
69
- });
70
- case 15:
71
- case "end":
72
- return _context.stop();
73
- }
74
- }, _callee, null, [[0, 9]]);
75
- }));
76
- return function (_x, _x2, _x3) {
77
- return _ref.apply(this, arguments);
46
+ const parsed = parseErrorSchema(
47
+ e,
48
+ !options.shouldUseNativeValidation && options.criteriaMode === "all"
49
+ );
50
+ return {
51
+ values: {},
52
+ errors: parsed
78
53
  };
79
- }();
80
- };
54
+ }
55
+ };
56
+ export {
57
+ yupResolver
58
+ };
59
+ //# sourceMappingURL=utils.js.map
package/utils.js.map ADDED
@@ -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 // eslint-disable-next-line no-console\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 options.shouldUseNativeValidation && 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,SAAS,8BAA8B;AACvC,SAAS,oBAAgC;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,IAAI;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;AAEnE,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,YAAQ,6BAA6B,uBAAuB,CAAC,GAAG,OAAO;AAEvE,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,21 +1,32 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
- import { useMemo } from 'react';
3
- import dayjs from 'dayjs';
4
- import customParseFormat from 'dayjs/plugin/customParseFormat';
5
- import * as yup from 'yup';
6
- import { getYupObjectShape, AFM_VALIDATOR, FILE_MAX_SIZE_VALIDATOR, IBAN_VALIDATOR, OTP_VALIDATOR, MOBILE_PHONE_VALIDATOR, PHONE_NUMBER_VALIDATOR, TEXT_LIMIT_VALIDATOR, POSTALCODE_VALIDATOR, UUID4_VALIDATOR, IMAGE_DIMENSION_VALIDATOR } from '@digigov/form/validators/utils';
7
- import { INT_VALIDATOR } from '@digigov/form/validators/utils/int';
8
- import { NUMBER_VALIDATOR } from '@digigov/form/validators/utils/number';
1
+ import { useMemo } from "react";
2
+ import dayjs from "dayjs";
3
+ import customParseFormat from "dayjs/plugin/customParseFormat";
4
+ import * as yup from "yup";
5
+ import {
6
+ getYupObjectShape,
7
+ AFM_VALIDATOR,
8
+ FILE_MAX_SIZE_VALIDATOR,
9
+ IBAN_VALIDATOR,
10
+ OTP_VALIDATOR,
11
+ MOBILE_PHONE_VALIDATOR,
12
+ PHONE_NUMBER_VALIDATOR,
13
+ TEXT_LIMIT_VALIDATOR,
14
+ POSTALCODE_VALIDATOR,
15
+ UUID4_VALIDATOR,
16
+ IMAGE_DIMENSION_VALIDATOR
17
+ } from "@digigov/form/validators/utils";
18
+ import { INT_VALIDATOR } from "@digigov/form/validators/utils/int";
19
+ import { NUMBER_VALIDATOR } from "@digigov/form/validators/utils/number";
9
20
  dayjs.extend(customParseFormat);
10
- var VALID_DATE_FORMATS = ['DD/MM/YYYY'];
11
- var DATE_CACHE = {};
12
- var getDate = function getDate(v) {
21
+ const VALID_DATE_FORMATS = ["DD/MM/YYYY"];
22
+ const DATE_CACHE = {};
23
+ const getDate = (v) => {
13
24
  return DATE_CACHE[v] ? DATE_CACHE[v] : dayjs(v, VALID_DATE_FORMATS, true);
14
25
  };
15
- export var getYUPTypeMap = function getYUPTypeMap() {
16
- var yupTypeMap = {
17
- file: function file(field) {
18
- return yup.mixed().transform(function (value) {
26
+ const getYUPTypeMap = () => {
27
+ const yupTypeMap = {
28
+ file: (field) => {
29
+ return yup.mixed().transform((value) => {
19
30
  if (!value.length) {
20
31
  return null;
21
32
  }
@@ -23,147 +34,123 @@ export var getYUPTypeMap = function getYUPTypeMap() {
23
34
  }).nullable().test(FILE_MAX_SIZE_VALIDATOR(field));
24
35
  },
25
36
  string: yup.string,
26
- "boolean": yup["boolean"],
27
- object: function object(field) {
37
+ boolean: yup.boolean,
38
+ object: (field) => {
28
39
  return getYupObjectShape(field.extra.fields, yupTypeMap);
29
40
  },
30
- array: function array(field) {
31
- if (_typeof(field.extra.of) === 'object') {
32
- // else if the field is an object then it is a scalar type
33
- // eg. number, string etc.
34
- var arrayValidator = yup.array().of(yupTypeMap[field.extra.of.type](field.extra.of)).required(field.required);
35
- if (field.extra.length) arrayValidator = arrayValidator.length(field.extra.length, {
36
- key: 'form.error.array.length',
37
- context: {
38
- length: field.extra.length
39
- }
40
- });
41
- if (field.extra.min) arrayValidator = arrayValidator.min(field.extra.min, {
42
- key: 'form.error.array.min',
43
- context: {
44
- min: field.extra.min
45
- }
46
- });
47
- if (field.extra.max) arrayValidator = arrayValidator.max(field.extra.max, {
48
- key: 'form.error.array.max',
49
- context: {
50
- max: field.extra.max
51
- }
52
- });
41
+ array: (field) => {
42
+ if (typeof field.extra.of === "object") {
43
+ let arrayValidator = yup.array().of(yupTypeMap[field.extra.of.type](field.extra.of)).required(field.required);
44
+ if (field.extra.length)
45
+ arrayValidator = arrayValidator.length(field.extra.length, {
46
+ key: "form.error.array.length",
47
+ context: {
48
+ length: field.extra.length
49
+ }
50
+ });
51
+ if (field.extra.min)
52
+ 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)
59
+ arrayValidator = arrayValidator.max(field.extra.max, {
60
+ key: "form.error.array.max",
61
+ context: {
62
+ max: field.extra.max
63
+ }
64
+ });
53
65
  return arrayValidator;
54
- } else if (typeof field.extra.of === 'string') {
66
+ } else if (typeof field.extra.of === "string") {
55
67
  return yup.array().of(yupTypeMap[field.extra.of]());
56
68
  } else {
57
- // in any other case it will be string
58
69
  return yup.array().of(yup.string());
59
70
  }
60
71
  },
61
- "int": function int() {
62
- return yup.mixed().transform(function (_, val) {
63
- return val !== '' ? Number(val) : null;
64
- }).test(NUMBER_VALIDATOR()).test(INT_VALIDATOR());
65
- },
66
- email: function email() {
67
- return yup.string().email('form.error.email');
68
- },
69
- afm: function afm() {
70
- return yup.string().test(AFM_VALIDATOR);
71
- },
72
- uuid4: function uuid4() {
73
- return yup.string().test(UUID4_VALIDATOR);
74
- },
75
- iban: function iban(field) {
76
- return yup.string().test(IBAN_VALIDATOR(field));
77
- },
78
- otp: function otp(field) {
79
- return yup.string().test(OTP_VALIDATOR(field));
80
- },
81
- text: function text(field) {
82
- var _field$extra, _field$extra$limit, _field$extra2, _field$extra2$limit;
83
- 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)) {
72
+ number: () => yup.mixed().transform((_, val) => val !== "" ? Number(val) : null).test(NUMBER_VALIDATOR()),
73
+ int: () => yup.mixed().transform((_, val) => val !== "" ? Number(val) : null).test(NUMBER_VALIDATOR()).test(INT_VALIDATOR()),
74
+ email: () => yup.string().email("form.error.email"),
75
+ afm: () => yup.string().test(AFM_VALIDATOR),
76
+ uuid4: () => yup.string().test(UUID4_VALIDATOR),
77
+ iban: (field) => yup.string().test(IBAN_VALIDATOR(field)),
78
+ otp: (field) => yup.string().test(OTP_VALIDATOR(field)),
79
+ text: (field) => {
80
+ if (field?.extra?.limit?.max || !!field?.extra?.limit?.min) {
84
81
  return yup.string().test(TEXT_LIMIT_VALIDATOR(field));
85
82
  } else {
86
83
  return yup.string();
87
84
  }
88
85
  },
89
- image: function image(field) {
90
- return yup.mixed().transform(function (value) {
86
+ image: (field) => {
87
+ return yup.mixed().transform((value) => {
91
88
  if (!value.length || value.length === 0) {
92
89
  return null;
93
90
  }
94
91
  return value;
95
92
  }).nullable().test(FILE_MAX_SIZE_VALIDATOR(field)).test(IMAGE_DIMENSION_VALIDATOR(field));
96
93
  },
97
- postal_code: function postal_code(field) {
98
- return yup.string().test(POSTALCODE_VALIDATOR(field));
99
- },
100
- mobile_phone: function mobile_phone() {
101
- return yup.string().test(MOBILE_PHONE_VALIDATOR);
102
- },
103
- phone_number: function phone_number(field) {
104
- return yup.string().test(PHONE_NUMBER_VALIDATOR(field));
105
- },
106
- 'choice:multiple': function choiceMultiple() {
107
- return yup.array().of(yup.string()).nullable();
108
- },
109
- 'choice:single': function choiceSingle() {
110
- return yup.string().nullable();
111
- },
112
- date: function date(field) {
113
- var simpleDate = yup.string().nullable(true).test('date', 'form.error.date.invalid', function (value) {
94
+ postal_code: (field) => yup.string().test(POSTALCODE_VALIDATOR(field)),
95
+ mobile_phone: () => yup.string().test(MOBILE_PHONE_VALIDATOR),
96
+ phone_number: (field) => yup.string().test(PHONE_NUMBER_VALIDATOR(field)),
97
+ "choice:multiple": () => yup.array().of(yup.string()).nullable(),
98
+ "choice:single": () => yup.string().nullable(),
99
+ date: (field) => {
100
+ let simpleDate = yup.string().nullable(true).test("date", "form.error.date.invalid", function(value) {
114
101
  if (!value) return true;
115
- var date = getDate(value);
102
+ const date = getDate(value);
116
103
  return date.isValid();
117
104
  });
118
- var params = field.extra || {};
105
+ const params = field.extra || {};
119
106
  if (params.max) {
120
- var maxDate;
121
- if (params.max === 'now') {
122
- var today = new Date();
107
+ let maxDate;
108
+ if (params.max === "now") {
109
+ const today = /* @__PURE__ */ new Date();
123
110
  maxDate = new Date(today);
124
111
  } else {
125
112
  maxDate = getDate(params.max).toDate();
126
113
  }
127
- var maxNextDate = new Date(maxDate);
114
+ const maxNextDate = new Date(maxDate);
128
115
  maxNextDate.setDate(maxDate.getDate() + 1);
129
116
  simpleDate = simpleDate.test({
130
- name: 'earlier-than',
117
+ name: "earlier-than",
131
118
  message: {
132
- key: 'form.error.date.earlier_than',
119
+ key: "form.error.date.earlier_than",
133
120
  context: {
134
121
  maxDate: maxNextDate.toLocaleDateString()
135
122
  }
136
123
  },
137
- test: function test(value) {
124
+ test: function(value) {
138
125
  if (!value) return true;
139
- var date = getDate(value);
140
- var isValid = +date.toDate() < +maxDate;
126
+ const date = getDate(value);
127
+ const isValid = +date.toDate() < +maxDate;
141
128
  return isValid;
142
129
  }
143
130
  });
144
131
  }
145
132
  if (params.min) {
146
- var minDate;
147
- if (params.min === 'now') {
148
- var _today = new Date();
149
- minDate = new Date(_today);
133
+ let minDate;
134
+ if (params.min === "now") {
135
+ const today = /* @__PURE__ */ new Date();
136
+ minDate = new Date(today);
150
137
  } else {
151
138
  minDate = getDate(params.min).toDate();
152
139
  }
153
- var minPreviousDate = new Date(minDate);
140
+ const minPreviousDate = new Date(minDate);
154
141
  minPreviousDate.setDate(minDate.getDate() - 1);
155
142
  simpleDate = simpleDate.test({
156
- name: 'later-than',
143
+ name: "later-than",
157
144
  message: {
158
- key: 'form.error.date.later_than',
145
+ key: "form.error.date.later_than",
159
146
  context: {
160
147
  minDate: minPreviousDate.toLocaleDateString()
161
148
  }
162
149
  },
163
- test: function test(value) {
150
+ test: function(value) {
164
151
  if (!value) return true;
165
- var date = getDate(value);
166
- var isValid = +date.toDate() > +minDate;
152
+ const date = getDate(value);
153
+ const isValid = +date.toDate() > +minDate;
167
154
  return isValid;
168
155
  }
169
156
  });
@@ -173,10 +160,14 @@ export var getYUPTypeMap = function getYUPTypeMap() {
173
160
  };
174
161
  return yupTypeMap;
175
162
  };
176
- // Create a yup validation schema from given fields input
177
- export function useValidationSchema(fields, validatorRegistry) {
178
- return useMemo(function () {
179
- var yupTypeMap = getYUPTypeMap();
163
+ function useValidationSchema(fields, validatorRegistry) {
164
+ return useMemo(() => {
165
+ const yupTypeMap = getYUPTypeMap();
180
166
  return getYupObjectShape(fields, yupTypeMap, validatorRegistry);
181
167
  }, []);
182
- }
168
+ }
169
+ export {
170
+ getYUPTypeMap,
171
+ useValidationSchema
172
+ };
173
+ //# 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 dayjs from 'dayjs';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\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} from '@digigov/form/validators/utils';\nimport { INT_VALIDATOR } from '@digigov/form/validators/utils/int';\nimport { NUMBER_VALIDATOR } from '@digigov/form/validators/utils/number';\ndayjs.extend(customParseFormat);\n\nconst VALID_DATE_FORMATS = ['DD/MM/YYYY'];\nconst DATE_CACHE = {};\nconst getDate = (v) => {\n return DATE_CACHE[v] ? DATE_CACHE[v] : dayjs(v, VALID_DATE_FORMATS, true);\n};\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: yup.string,\n boolean: yup.boolean,\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) : null))\n .test(NUMBER_VALIDATOR()),\n int: (): MixedSchema =>\n yup\n .mixed()\n .transform((_, val) => (val !== '' ? Number(val) : null))\n .test(NUMBER_VALIDATOR())\n .test(INT_VALIDATOR()),\n email: (): yup.StringSchema => yup.string().email('form.error.email'),\n afm: (): yup.StringSchema => yup.string().test(AFM_VALIDATOR),\n uuid4: (): yup.StringSchema => yup.string().test(UUID4_VALIDATOR),\n iban: (field): yup.StringSchema => yup.string().test(IBAN_VALIDATOR(field)),\n otp: (field): yup.StringSchema => yup.string().test(OTP_VALIDATOR(field)),\n text: (field): yup.StringSchema => {\n if (field?.extra?.limit?.max || !!field?.extra?.limit?.min) {\n return yup.string().test(TEXT_LIMIT_VALIDATOR(field));\n } else {\n return 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 yup.string().test(POSTALCODE_VALIDATOR(field)),\n mobile_phone: (): yup.StringSchema =>\n yup.string().test(MOBILE_PHONE_VALIDATOR),\n phone_number: (field): yup.StringSchema =>\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: (field) => {\n let simpleDate = yup\n .string()\n .nullable(true)\n .test('date', 'form.error.date.invalid', function (value) {\n if (!value) return true;\n const date = getDate(value);\n return date.isValid();\n });\n const params = field.extra || {};\n if (params.max) {\n let maxDate;\n if (params.max === 'now') {\n const today = new Date();\n maxDate = new Date(today);\n } else {\n maxDate = getDate(params.max).toDate();\n }\n const maxNextDate = new Date(maxDate);\n maxNextDate.setDate(maxDate.getDate() + 1);\n simpleDate = simpleDate.test({\n name: 'earlier-than',\n message: {\n key: 'form.error.date.earlier_than',\n context: {\n maxDate: maxNextDate.toLocaleDateString(),\n },\n },\n test: function (value) {\n if (!value) return true;\n const date = getDate(value);\n const isValid = +date.toDate() < +maxDate;\n return isValid;\n },\n });\n }\n if (params.min) {\n let minDate;\n if (params.min === 'now') {\n const today = new Date();\n minDate = new Date(today);\n } else {\n minDate = getDate(params.min).toDate();\n }\n const minPreviousDate = new Date(minDate);\n minPreviousDate.setDate(minDate.getDate() - 1);\n simpleDate = simpleDate.test({\n name: 'later-than',\n message: {\n key: 'form.error.date.later_than',\n context: {\n minDate: minPreviousDate.toLocaleDateString(),\n },\n },\n test: function (value) {\n if (!value) return true;\n const date = getDate(value);\n const isValid = +date.toDate() > +minDate;\n return isValid;\n },\n });\n }\n return simpleDate;\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 +1 @@
1
- export {};
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,31 +1,31 @@
1
- export function validateAFM(afm) {
1
+ function validateAFM(afm) {
2
2
  if (afm.length !== 9) {
3
- // "afm should be 9 digits"
4
3
  return false;
5
4
  }
6
5
  if (!/^\d+$/.test(afm)) {
7
- // "This is not a number"
8
6
  return false;
9
7
  }
10
- if (afm === '0'.repeat(9)) {
11
- // "This is zero number (000000000)"
8
+ if (afm === "0".repeat(9)) {
12
9
  return false;
13
10
  }
14
- var sum = afm.substring(0, 8).split('').reduce(function (s, v, i) {
15
- return s + (parseInt(v) << 8 - i);
16
- }, 0);
17
- var calc = sum % 11;
18
- var d9 = parseInt(afm[8]);
19
- var valid = calc % 10 === d9;
11
+ const sum = afm.substring(0, 8).split("").reduce((s, v, i) => s + (parseInt(v) << 8 - i), 0);
12
+ const calc = sum % 11;
13
+ const d9 = parseInt(afm[8]);
14
+ const valid = calc % 10 === d9;
20
15
  return valid;
21
16
  }
22
- export var AFM_VALIDATOR = {
23
- name: 'afm-validator',
24
- message: 'form.error.afm',
25
- test: function test(value) {
17
+ const AFM_VALIDATOR = {
18
+ name: "afm-validator",
19
+ message: "form.error.afm",
20
+ test: (value) => {
26
21
  if (value) {
27
22
  return validateAFM(value);
28
23
  }
29
24
  return true;
30
25
  }
31
- };
26
+ };
27
+ export {
28
+ AFM_VALIDATOR,
29
+ validateAFM
30
+ };
31
+ //# sourceMappingURL=afm.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/validators/utils/afm.ts"],
4
+ "sourcesContent": ["export function validateAFM(afm: string): boolean {\n if (afm.length !== 9) {\n // \"afm should be 9 digits\"\n return false;\n }\n\n if (!/^\\d+$/.test(afm)) {\n // \"This is not a number\"\n return false;\n }\n\n if (afm === '0'.repeat(9)) {\n // \"This is zero number (000000000)\"\n return false;\n }\n\n const sum = afm\n .substring(0, 8)\n .split('')\n .reduce((s, v, i) => s + (parseInt(v) << (8 - i)), 0);\n\n const calc = sum % 11;\n const d9 = parseInt(afm[8]);\n const valid = calc % 10 === d9;\n return valid;\n}\n\nexport const AFM_VALIDATOR = {\n name: 'afm-validator',\n message: 'form.error.afm',\n test: (value): boolean => {\n if (value) {\n return validateAFM(value);\n }\n return true;\n },\n};\n"],
5
+ "mappings": "AAAO,SAAS,YAAY,KAAsB;AAChD,MAAI,IAAI,WAAW,GAAG;AAEpB,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,QAAQ,KAAK,GAAG,GAAG;AAEtB,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,IAAI,OAAO,CAAC,GAAG;AAEzB,WAAO;AAAA,EACT;AAEA,QAAM,MAAM,IACT,UAAU,GAAG,CAAC,EACd,MAAM,EAAE,EACR,OAAO,CAAC,GAAG,GAAG,MAAM,KAAK,SAAS,CAAC,KAAM,IAAI,IAAK,CAAC;AAEtD,QAAM,OAAO,MAAM;AACnB,QAAM,KAAK,SAAS,IAAI,CAAC,CAAC;AAC1B,QAAM,QAAQ,OAAO,OAAO;AAC5B,SAAO;AACT;AAEO,MAAM,gBAAgB;AAAA,EAC3B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM,CAAC,UAAmB;AACxB,QAAI,OAAO;AACT,aAAO,YAAY,KAAK;AAAA,IAC1B;AACA,WAAO;AAAA,EACT;AACF;",
6
+ "names": []
7
+ }
@@ -1,45 +1,25 @@
1
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
2
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
- var DEFAULT_FILE_MAX_SIZE = 10000000;
5
- export var FILE_MAX_SIZE_VALIDATOR = function FILE_MAX_SIZE_VALIDATOR(field) {
6
- return {
7
- name: 'file-max-size-validator',
8
- message: 'form.error.file_size',
9
- test: function test(value) {
10
- var _field$extra, _field$extra2;
11
- if (field !== null && field !== void 0 && (_field$extra = field.extra) !== null && _field$extra !== void 0 && _field$extra.limit && field !== null && field !== void 0 && (_field$extra2 = field.extra) !== null && _field$extra2 !== void 0 && _field$extra2.limit.maxSize && value) {
12
- var _iterator = _createForOfIteratorHelper(value),
13
- _step;
14
- try {
15
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
16
- var file = _step.value;
17
- if (file.size >= field.extra.limit.maxSize) {
18
- return false;
19
- }
20
- }
21
- } catch (err) {
22
- _iterator.e(err);
23
- } finally {
24
- _iterator.f();
25
- }
26
- } else if (value) {
27
- var _iterator2 = _createForOfIteratorHelper(value),
28
- _step2;
29
- try {
30
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
31
- var _file = _step2.value;
32
- if (_file.size >= DEFAULT_FILE_MAX_SIZE) {
33
- return false;
34
- }
35
- }
36
- } catch (err) {
37
- _iterator2.e(err);
38
- } finally {
39
- _iterator2.f();
1
+ const DEFAULT_FILE_MAX_SIZE = 1e7;
2
+ const FILE_MAX_SIZE_VALIDATOR = (field) => ({
3
+ name: "file-max-size-validator",
4
+ message: {
5
+ key: "form.error.file_size",
6
+ context: {
7
+ maxSizeToMb: (field?.extra?.limit.maxSize || DEFAULT_FILE_MAX_SIZE) / 1e6
8
+ }
9
+ },
10
+ test: (value) => {
11
+ if (value) {
12
+ for (const file of value) {
13
+ const maxSize = field?.extra?.limit?.maxSize || DEFAULT_FILE_MAX_SIZE;
14
+ if (file.size > maxSize) {
15
+ return false;
40
16
  }
41
17
  }
42
- return true;
43
18
  }
44
- };
45
- };
19
+ return true;
20
+ }
21
+ });
22
+ export {
23
+ FILE_MAX_SIZE_VALIDATOR
24
+ };
25
+ //# sourceMappingURL=file.js.map