@digigov/form 1.0.0-88820b1e → 1.0.0-8b33e4c8

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 (476) hide show
  1. package/Field/FieldBase.js +14 -31
  2. package/Field/FieldBaseContainer.js +19 -41
  3. package/Field/FieldConditional.js +14 -33
  4. package/Field/index.js +18 -45
  5. package/Field/package.json +6 -0
  6. package/Field/types.js +1 -5
  7. package/Field/utils.js +30 -63
  8. package/FieldArray/FieldArray.stories.js +5 -42
  9. package/FieldArray/__stories__/Default.js +11 -32
  10. package/FieldArray/__stories__/WithExactLength.js +11 -32
  11. package/FieldArray/index.js +19 -41
  12. package/FieldArray/package.json +6 -0
  13. package/FieldObject/index.js +16 -41
  14. package/FieldObject/package.json +6 -0
  15. package/Fieldset/FieldsetWithContext.js +13 -35
  16. package/Fieldset/index.js +21 -51
  17. package/Fieldset/package.json +6 -0
  18. package/Fieldset/types.js +1 -5
  19. package/Form.stories.js +2 -9
  20. package/FormBuilder/FormBuilder.js +33 -62
  21. package/FormBuilder/FormBuilder.stories.js +4 -28
  22. package/FormBuilder/__stories__/Default.js +8 -29
  23. package/FormBuilder/index.js +2 -11
  24. package/FormBuilder/package.json +6 -0
  25. package/FormContext.js +3 -12
  26. package/MultiplicityField/MultiplicityField.stories.js +9 -98
  27. package/MultiplicityField/__stories__/Default.js +11 -32
  28. package/MultiplicityField/__stories__/PreviewDisplay.js +29 -52
  29. package/MultiplicityField/__stories__/WithExactLength.js +11 -32
  30. package/MultiplicityField/__stories__/WithMaxLength.js +11 -32
  31. package/MultiplicityField/__stories__/WithMinAndMaxLength.js +11 -32
  32. package/MultiplicityField/__stories__/WithMinLength.js +11 -32
  33. package/MultiplicityField/add-objects.js +25 -49
  34. package/MultiplicityField/index.js +26 -55
  35. package/MultiplicityField/package.json +6 -0
  36. package/Questions/Questions.js +14 -35
  37. package/Questions/Questions.stories.js +4 -28
  38. package/Questions/QuestionsContext.js +3 -12
  39. package/Questions/Step/ReviewStep.js +21 -47
  40. package/Questions/Step/Step.js +18 -42
  41. package/Questions/Step/StepArrayReview.js +23 -52
  42. package/Questions/Step/StepContext.js +3 -13
  43. package/Questions/Step/StepDescription.js +14 -42
  44. package/Questions/Step/StepForm.js +19 -45
  45. package/Questions/Step/StepQuote.js +8 -23
  46. package/Questions/Step/StepTitle.d.ts +2 -2
  47. package/Questions/Step/StepTitle.js +18 -43
  48. package/Questions/Step/getAddMoreFields.js +2 -11
  49. package/Questions/Step/index.d.ts +4 -4
  50. package/Questions/Step/index.js +13 -153
  51. package/Questions/Step/package.json +6 -0
  52. package/Questions/Step/types.js +1 -5
  53. package/Questions/__stories__/Default.js +24 -51
  54. package/Questions/getNextStep.js +1 -8
  55. package/Questions/index.js +3 -25
  56. package/Questions/index.spec.js +12 -23
  57. package/Questions/package.json +6 -0
  58. package/Questions/types.js +1 -5
  59. package/{es → cjs}/Field/FieldBase.js +31 -14
  60. package/cjs/Field/FieldBaseContainer.js +65 -0
  61. package/cjs/Field/FieldConditional.js +81 -0
  62. package/cjs/Field/index.js +103 -0
  63. package/cjs/Field/types.js +5 -0
  64. package/{es → cjs}/Field/utils.js +63 -30
  65. package/cjs/FieldArray/FieldArray.stories.js +45 -0
  66. package/cjs/FieldArray/__stories__/Default.js +111 -0
  67. package/cjs/FieldArray/__stories__/WithExactLength.js +111 -0
  68. package/cjs/FieldArray/index.js +87 -0
  69. package/cjs/FieldObject/index.js +83 -0
  70. package/cjs/Fieldset/FieldsetWithContext.js +63 -0
  71. package/cjs/Fieldset/index.js +64 -0
  72. package/cjs/Fieldset/types.js +5 -0
  73. package/cjs/Form.stories.js +10 -0
  74. package/{esm → cjs}/FormBuilder/FormBuilder.js +62 -33
  75. package/cjs/FormBuilder/FormBuilder.stories.js +31 -0
  76. package/cjs/FormBuilder/__stories__/Default.js +49 -0
  77. package/cjs/FormBuilder/index.js +11 -0
  78. package/cjs/FormContext.js +14 -0
  79. package/cjs/MultiplicityField/MultiplicityField.stories.js +101 -0
  80. package/{es → cjs}/MultiplicityField/__stories__/Default.js +32 -11
  81. package/cjs/MultiplicityField/__stories__/PreviewDisplay.js +106 -0
  82. package/{esm → cjs}/MultiplicityField/__stories__/WithExactLength.js +32 -11
  83. package/{es → cjs}/MultiplicityField/__stories__/WithMaxLength.js +32 -11
  84. package/{es → cjs}/MultiplicityField/__stories__/WithMinAndMaxLength.js +32 -11
  85. package/{esm → cjs}/MultiplicityField/__stories__/WithMinLength.js +32 -11
  86. package/{esm → cjs}/MultiplicityField/add-objects.js +49 -25
  87. package/cjs/MultiplicityField/index.js +143 -0
  88. package/cjs/Questions/Questions.js +105 -0
  89. package/cjs/Questions/Questions.stories.js +31 -0
  90. package/cjs/Questions/QuestionsContext.js +20 -0
  91. package/cjs/Questions/Step/ReviewStep.js +79 -0
  92. package/cjs/Questions/Step/Step.js +93 -0
  93. package/cjs/Questions/Step/StepArrayReview.js +79 -0
  94. package/{esm → cjs}/Questions/Step/StepContext.js +13 -3
  95. package/cjs/Questions/Step/StepDescription.js +55 -0
  96. package/cjs/Questions/Step/StepForm.js +74 -0
  97. package/cjs/Questions/Step/StepQuote.js +26 -0
  98. package/cjs/Questions/Step/StepTitle.js +75 -0
  99. package/{es → cjs}/Questions/Step/getAddMoreFields.js +11 -2
  100. package/cjs/Questions/Step/index.js +170 -0
  101. package/cjs/Questions/Step/types.js +5 -0
  102. package/cjs/Questions/__stories__/Default.js +135 -0
  103. package/{esm → cjs}/Questions/getNextStep.js +8 -1
  104. package/cjs/Questions/index.js +25 -0
  105. package/cjs/Questions/index.spec.js +73 -0
  106. package/cjs/Questions/types.js +5 -0
  107. package/cjs/index.js +28 -0
  108. package/cjs/inputs/AutoComplete/AutoComplete.stories.js +31 -0
  109. package/cjs/inputs/AutoComplete/__stories__/Default.js +71 -0
  110. package/cjs/inputs/AutoComplete/index.js +68 -0
  111. package/cjs/inputs/Checkboxes/Checkboxes.stories.js +59 -0
  112. package/{es → cjs}/inputs/Checkboxes/__stories__/Conditional.js +28 -8
  113. package/cjs/inputs/Checkboxes/__stories__/Default.js +62 -0
  114. package/cjs/inputs/Checkboxes/__stories__/WithDivider.js +63 -0
  115. package/cjs/inputs/Checkboxes/index.js +127 -0
  116. package/cjs/inputs/DateInput/DateInput.stories.js +31 -0
  117. package/cjs/inputs/DateInput/__stories__/Default.js +45 -0
  118. package/cjs/inputs/DateInput/index.js +181 -0
  119. package/cjs/inputs/FileInput/FileInput.stories.js +31 -0
  120. package/cjs/inputs/FileInput/__stories__/Default.js +42 -0
  121. package/cjs/inputs/FileInput/index.js +92 -0
  122. package/cjs/inputs/Input/Input.stories.js +143 -0
  123. package/cjs/inputs/Input/__stories__/AFM.js +44 -0
  124. package/cjs/inputs/Input/__stories__/Boolean.js +45 -0
  125. package/cjs/inputs/Input/__stories__/Default.js +45 -0
  126. package/cjs/inputs/Input/__stories__/IBAN.js +45 -0
  127. package/cjs/inputs/Input/__stories__/Integer.js +53 -0
  128. package/cjs/inputs/Input/__stories__/MobilePhone.js +44 -0
  129. package/cjs/inputs/Input/__stories__/PhoneNumber.js +44 -0
  130. package/cjs/inputs/Input/__stories__/PostalCode.js +47 -0
  131. package/cjs/inputs/Input/__stories__/TextWithCharacterLimit.js +51 -0
  132. package/cjs/inputs/Input/index.js +96 -0
  133. package/cjs/inputs/Label/Label.stories.js +31 -0
  134. package/cjs/inputs/Label/__stories__/Default.js +49 -0
  135. package/cjs/inputs/Label/index.js +41 -0
  136. package/cjs/inputs/OtpInput/OtpInput.stories.js +31 -0
  137. package/cjs/inputs/OtpInput/__stories__/Default.js +52 -0
  138. package/cjs/inputs/OtpInput/index.js +182 -0
  139. package/cjs/inputs/Radio/Radio.stories.js +59 -0
  140. package/{es → cjs}/inputs/Radio/__stories__/Conditional.js +28 -8
  141. package/cjs/inputs/Radio/__stories__/Default.js +67 -0
  142. package/cjs/inputs/Radio/__stories__/WithDivider.js +68 -0
  143. package/cjs/inputs/Radio/index.js +82 -0
  144. package/cjs/inputs/Select/Select.stories.js +31 -0
  145. package/cjs/inputs/Select/__stories__/Default.js +73 -0
  146. package/cjs/inputs/Select/index.js +49 -0
  147. package/cjs/inputs/index.js +71 -0
  148. package/cjs/internal.js +391 -0
  149. package/cjs/registry.js +208 -0
  150. package/cjs/types.js +5 -0
  151. package/{es → cjs}/utils.js +26 -12
  152. package/{es → cjs}/validators/index.js +54 -26
  153. package/cjs/validators/types.js +5 -0
  154. package/{es → cjs}/validators/utils/afm.js +13 -3
  155. package/{es → cjs}/validators/utils/file.js +12 -2
  156. package/{esm → cjs}/validators/utils/iban.js +13 -2
  157. package/cjs/validators/utils/index.js +229 -0
  158. package/{esm → cjs}/validators/utils/int.js +14 -3
  159. package/cjs/validators/utils/number.js +27 -0
  160. package/{esm → cjs}/validators/utils/otp.js +14 -3
  161. package/{esm → cjs}/validators/utils/phone.js +28 -6
  162. package/{es → cjs}/validators/utils/postal_code.js +14 -3
  163. package/{esm → cjs}/validators/utils/text_limit.js +14 -3
  164. package/{esm → cjs}/validators/utils/uuid4.js +13 -3
  165. package/cjs/validators/validators.spec.js +88 -0
  166. package/index.js +8 -28
  167. package/inputs/AutoComplete/AutoComplete.stories.js +4 -28
  168. package/inputs/AutoComplete/__stories__/Default.js +13 -35
  169. package/inputs/AutoComplete/index.js +12 -35
  170. package/inputs/AutoComplete/package.json +6 -0
  171. package/inputs/Checkboxes/Checkboxes.stories.js +6 -56
  172. package/inputs/Checkboxes/__stories__/Conditional.js +8 -28
  173. package/inputs/Checkboxes/__stories__/Default.js +8 -28
  174. package/inputs/Checkboxes/__stories__/WithDivider.js +8 -28
  175. package/inputs/Checkboxes/index.js +25 -52
  176. package/inputs/Checkboxes/package.json +6 -0
  177. package/inputs/DateInput/DateInput.stories.js +4 -28
  178. package/inputs/DateInput/__stories__/Default.js +8 -46
  179. package/inputs/DateInput/index.js +26 -52
  180. package/inputs/DateInput/package.json +6 -0
  181. package/inputs/FileInput/FileInput.stories.js +4 -28
  182. package/inputs/FileInput/__stories__/Default.js +8 -28
  183. package/inputs/FileInput/index.js +22 -52
  184. package/inputs/FileInput/package.json +6 -0
  185. package/inputs/Input/Input.stories.js +12 -140
  186. package/inputs/Input/__stories__/AFM.js +8 -28
  187. package/inputs/Input/__stories__/Boolean.js +8 -28
  188. package/inputs/Input/__stories__/Default.js +8 -28
  189. package/inputs/Input/__stories__/IBAN.js +8 -28
  190. package/inputs/Input/__stories__/Integer.js +9 -29
  191. package/inputs/Input/__stories__/MobilePhone.js +8 -28
  192. package/inputs/Input/__stories__/PhoneNumber.js +8 -28
  193. package/inputs/Input/__stories__/PostalCode.js +8 -28
  194. package/inputs/Input/__stories__/TextWithCharacterLimit.js +8 -28
  195. package/inputs/Input/index.js +19 -40
  196. package/inputs/Input/package.json +6 -0
  197. package/inputs/Label/Label.stories.js +4 -28
  198. package/inputs/Label/__stories__/Default.js +9 -29
  199. package/inputs/Label/index.js +9 -25
  200. package/inputs/Label/package.json +6 -0
  201. package/inputs/OtpInput/OtpInput.stories.js +4 -28
  202. package/inputs/OtpInput/__stories__/Default.js +9 -30
  203. package/inputs/OtpInput/index.js +28 -53
  204. package/inputs/OtpInput/package.json +6 -0
  205. package/inputs/Radio/Radio.stories.js +6 -56
  206. package/inputs/Radio/__stories__/Conditional.js +8 -28
  207. package/inputs/Radio/__stories__/Default.js +9 -29
  208. package/inputs/Radio/__stories__/WithDivider.js +9 -29
  209. package/inputs/Radio/index.js +24 -45
  210. package/inputs/Radio/package.json +6 -0
  211. package/inputs/Select/Select.stories.js +4 -28
  212. package/inputs/Select/__stories__/Default.js +9 -29
  213. package/inputs/Select/index.js +12 -29
  214. package/inputs/Select/package.json +6 -0
  215. package/inputs/index.js +8 -71
  216. package/inputs/package.json +6 -0
  217. package/internal.js +34 -391
  218. package/package.json +6 -6
  219. package/registry.js +61 -133
  220. package/src/Questions/Step/StepTitle.tsx +5 -5
  221. package/src/Questions/Step/index.ts +4 -4
  222. package/src/inputs/DateInput/__stories__/Default.tsx +0 -16
  223. package/src/inputs/Radio/__stories__/Default.tsx +1 -1
  224. package/src/inputs/Radio/__stories__/WithDivider.tsx +1 -1
  225. package/src/inputs/Select/__stories__/Default.tsx +1 -1
  226. package/types.js +1 -5
  227. package/utils.js +12 -26
  228. package/validators/index.js +26 -54
  229. package/validators/package.json +6 -0
  230. package/validators/types.js +1 -5
  231. package/validators/utils/afm.js +3 -13
  232. package/validators/utils/file.js +2 -12
  233. package/validators/utils/iban.js +2 -13
  234. package/validators/utils/index.js +12 -139
  235. package/validators/utils/int.js +3 -14
  236. package/validators/utils/number.js +3 -14
  237. package/validators/utils/otp.js +3 -14
  238. package/validators/utils/package.json +6 -0
  239. package/validators/utils/phone.js +6 -28
  240. package/validators/utils/postal_code.js +3 -14
  241. package/validators/utils/text_limit.js +3 -14
  242. package/validators/utils/uuid4.js +3 -13
  243. package/validators/validators.spec.js +29 -32
  244. package/es/Field/FieldBaseContainer.js +0 -43
  245. package/es/Field/FieldConditional.js +0 -62
  246. package/es/Field/index.js +0 -76
  247. package/es/Field/types.js +0 -1
  248. package/es/FieldArray/FieldArray.stories.js +0 -8
  249. package/es/FieldArray/__stories__/Default.js +0 -90
  250. package/es/FieldArray/__stories__/WithExactLength.js +0 -90
  251. package/es/FieldArray/index.js +0 -65
  252. package/es/FieldObject/index.js +0 -58
  253. package/es/Fieldset/FieldsetWithContext.js +0 -41
  254. package/es/Fieldset/index.js +0 -34
  255. package/es/Fieldset/types.js +0 -1
  256. package/es/Form.stories.js +0 -3
  257. package/es/FormBuilder/FormBuilder.js +0 -160
  258. package/es/FormBuilder/FormBuilder.stories.js +0 -7
  259. package/es/FormBuilder/__stories__/Default.js +0 -28
  260. package/es/FormBuilder/index.js +0 -2
  261. package/es/FormContext.js +0 -5
  262. package/es/MultiplicityField/MultiplicityField.stories.js +0 -12
  263. package/es/MultiplicityField/__stories__/PreviewDisplay.js +0 -83
  264. package/es/MultiplicityField/__stories__/WithExactLength.js +0 -92
  265. package/es/MultiplicityField/__stories__/WithMinLength.js +0 -95
  266. package/es/MultiplicityField/add-objects.js +0 -160
  267. package/es/MultiplicityField/index.js +0 -114
  268. package/es/Questions/Questions.js +0 -84
  269. package/es/Questions/Questions.stories.js +0 -7
  270. package/es/Questions/QuestionsContext.js +0 -11
  271. package/es/Questions/Step/ReviewStep.js +0 -53
  272. package/es/Questions/Step/Step.js +0 -69
  273. package/es/Questions/Step/StepArrayReview.js +0 -50
  274. package/es/Questions/Step/StepContext.js +0 -27
  275. package/es/Questions/Step/StepDescription.js +0 -27
  276. package/es/Questions/Step/StepForm.js +0 -48
  277. package/es/Questions/Step/StepQuote.js +0 -11
  278. package/es/Questions/Step/StepTitle.js +0 -40
  279. package/es/Questions/Step/index.js +0 -13
  280. package/es/Questions/Step/types.js +0 -1
  281. package/es/Questions/__stories__/Default.js +0 -108
  282. package/es/Questions/getNextStep.js +0 -23
  283. package/es/Questions/index.js +0 -3
  284. package/es/Questions/index.spec.js +0 -62
  285. package/es/Questions/types.js +0 -1
  286. package/es/index.js +0 -3
  287. package/es/inputs/AutoComplete/AutoComplete.stories.js +0 -7
  288. package/es/inputs/AutoComplete/__stories__/Default.js +0 -49
  289. package/es/inputs/AutoComplete/index.js +0 -45
  290. package/es/inputs/Checkboxes/Checkboxes.stories.js +0 -9
  291. package/es/inputs/Checkboxes/__stories__/Default.js +0 -42
  292. package/es/inputs/Checkboxes/__stories__/WithDivider.js +0 -43
  293. package/es/inputs/Checkboxes/index.js +0 -100
  294. package/es/inputs/DateInput/DateInput.stories.js +0 -7
  295. package/es/inputs/DateInput/__stories__/Default.js +0 -43
  296. package/es/inputs/DateInput/index.js +0 -155
  297. package/es/inputs/FileInput/FileInput.stories.js +0 -7
  298. package/es/inputs/FileInput/__stories__/Default.js +0 -22
  299. package/es/inputs/FileInput/index.js +0 -62
  300. package/es/inputs/Input/Input.stories.js +0 -15
  301. package/es/inputs/Input/__stories__/AFM.js +0 -24
  302. package/es/inputs/Input/__stories__/Boolean.js +0 -25
  303. package/es/inputs/Input/__stories__/Default.js +0 -25
  304. package/es/inputs/Input/__stories__/IBAN.js +0 -25
  305. package/es/inputs/Input/__stories__/Integer.js +0 -33
  306. package/es/inputs/Input/__stories__/MobilePhone.js +0 -24
  307. package/es/inputs/Input/__stories__/PhoneNumber.js +0 -24
  308. package/es/inputs/Input/__stories__/PostalCode.js +0 -27
  309. package/es/inputs/Input/__stories__/TextWithCharacterLimit.js +0 -31
  310. package/es/inputs/Input/index.js +0 -75
  311. package/es/inputs/Label/Label.stories.js +0 -7
  312. package/es/inputs/Label/__stories__/Default.js +0 -29
  313. package/es/inputs/Label/index.js +0 -25
  314. package/es/inputs/OtpInput/OtpInput.stories.js +0 -7
  315. package/es/inputs/OtpInput/__stories__/Default.js +0 -31
  316. package/es/inputs/OtpInput/index.js +0 -157
  317. package/es/inputs/Radio/Radio.stories.js +0 -9
  318. package/es/inputs/Radio/__stories__/Default.js +0 -47
  319. package/es/inputs/Radio/__stories__/WithDivider.js +0 -48
  320. package/es/inputs/Radio/index.js +0 -61
  321. package/es/inputs/Select/Select.stories.js +0 -7
  322. package/es/inputs/Select/__stories__/Default.js +0 -53
  323. package/es/inputs/Select/index.js +0 -32
  324. package/es/inputs/index.js +0 -8
  325. package/es/internal.js +0 -34
  326. package/es/registry.js +0 -136
  327. package/es/types.js +0 -1
  328. package/es/validators/types.js +0 -1
  329. package/es/validators/utils/iban.js +0 -123
  330. package/es/validators/utils/index.js +0 -102
  331. package/es/validators/utils/int.js +0 -20
  332. package/es/validators/utils/number.js +0 -16
  333. package/es/validators/utils/otp.js +0 -26
  334. package/es/validators/utils/phone.js +0 -122
  335. package/es/validators/utils/text_limit.js +0 -54
  336. package/es/validators/utils/uuid4.js +0 -20
  337. package/es/validators/validators.spec.js +0 -85
  338. package/esm/Field/FieldBase.js +0 -84
  339. package/esm/Field/FieldBaseContainer.js +0 -43
  340. package/esm/Field/FieldConditional.js +0 -62
  341. package/esm/Field/index.js +0 -76
  342. package/esm/Field/index.mdx +0 -6
  343. package/esm/Field/types.js +0 -1
  344. package/esm/Field/utils.js +0 -162
  345. package/esm/FieldArray/FieldArray.stories.js +0 -8
  346. package/esm/FieldArray/FieldArray.stories.playwright.json +0 -353
  347. package/esm/FieldArray/__stories__/Default.js +0 -90
  348. package/esm/FieldArray/__stories__/WithExactLength.js +0 -90
  349. package/esm/FieldArray/index.js +0 -65
  350. package/esm/FieldObject/index.js +0 -58
  351. package/esm/Fieldset/FieldsetWithContext.js +0 -41
  352. package/esm/Fieldset/index.js +0 -34
  353. package/esm/Fieldset/types.js +0 -1
  354. package/esm/Form.stories.js +0 -3
  355. package/esm/FormBuilder/FormBuilder.mdx +0 -256
  356. package/esm/FormBuilder/FormBuilder.stories.js +0 -7
  357. package/esm/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  358. package/esm/FormBuilder/__stories__/Default.js +0 -28
  359. package/esm/FormBuilder/index.js +0 -2
  360. package/esm/FormContext.js +0 -5
  361. package/esm/MultiplicityField/MultiplicityField.mdx +0 -590
  362. package/esm/MultiplicityField/MultiplicityField.stories.js +0 -12
  363. package/esm/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  364. package/esm/MultiplicityField/__stories__/Default.js +0 -97
  365. package/esm/MultiplicityField/__stories__/PreviewDisplay.js +0 -83
  366. package/esm/MultiplicityField/__stories__/WithMaxLength.js +0 -95
  367. package/esm/MultiplicityField/__stories__/WithMinAndMaxLength.js +0 -96
  368. package/esm/MultiplicityField/index.js +0 -114
  369. package/esm/Questions/Questions.js +0 -84
  370. package/esm/Questions/Questions.stories.js +0 -7
  371. package/esm/Questions/QuestionsContext.js +0 -11
  372. package/esm/Questions/Step/ReviewStep.js +0 -53
  373. package/esm/Questions/Step/Step.js +0 -69
  374. package/esm/Questions/Step/StepArrayReview.js +0 -50
  375. package/esm/Questions/Step/StepDescription.js +0 -27
  376. package/esm/Questions/Step/StepForm.js +0 -48
  377. package/esm/Questions/Step/StepQuote.js +0 -11
  378. package/esm/Questions/Step/StepTitle.js +0 -40
  379. package/esm/Questions/Step/getAddMoreFields.js +0 -22
  380. package/esm/Questions/Step/index.js +0 -13
  381. package/esm/Questions/Step/types.js +0 -1
  382. package/esm/Questions/__snapshots__/index.spec.tsx.snap +0 -596
  383. package/esm/Questions/__stories__/Default.js +0 -108
  384. package/esm/Questions/index.js +0 -3
  385. package/esm/Questions/index.mdx +0 -415
  386. package/esm/Questions/index.spec.js +0 -62
  387. package/esm/Questions/types.js +0 -1
  388. package/esm/create-simple-form.mdx +0 -539
  389. package/esm/index.js +0 -8
  390. package/esm/index.mdx +0 -51
  391. package/esm/inputs/AutoComplete/AutoComplete.stories.js +0 -7
  392. package/esm/inputs/AutoComplete/__stories__/Default.js +0 -49
  393. package/esm/inputs/AutoComplete/index.js +0 -45
  394. package/esm/inputs/Checkboxes/Checkboxes.stories.js +0 -9
  395. package/esm/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  396. package/esm/inputs/Checkboxes/__stories__/Conditional.js +0 -95
  397. package/esm/inputs/Checkboxes/__stories__/Default.js +0 -42
  398. package/esm/inputs/Checkboxes/__stories__/WithDivider.js +0 -43
  399. package/esm/inputs/Checkboxes/index.js +0 -100
  400. package/esm/inputs/Checkboxes/index.mdx +0 -0
  401. package/esm/inputs/DateInput/DateInput.stories.js +0 -7
  402. package/esm/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  403. package/esm/inputs/DateInput/__stories__/Default.js +0 -43
  404. package/esm/inputs/DateInput/index.js +0 -155
  405. package/esm/inputs/FileInput/FileInput.stories.js +0 -7
  406. package/esm/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  407. package/esm/inputs/FileInput/__stories__/Default.js +0 -22
  408. package/esm/inputs/FileInput/index.js +0 -62
  409. package/esm/inputs/Input/Input.stories.js +0 -15
  410. package/esm/inputs/Input/Input.stories.playwright.json +0 -376
  411. package/esm/inputs/Input/__stories__/AFM.js +0 -24
  412. package/esm/inputs/Input/__stories__/Boolean.js +0 -25
  413. package/esm/inputs/Input/__stories__/Default.js +0 -25
  414. package/esm/inputs/Input/__stories__/IBAN.js +0 -25
  415. package/esm/inputs/Input/__stories__/Integer.js +0 -33
  416. package/esm/inputs/Input/__stories__/MobilePhone.js +0 -24
  417. package/esm/inputs/Input/__stories__/PhoneNumber.js +0 -24
  418. package/esm/inputs/Input/__stories__/PostalCode.js +0 -27
  419. package/esm/inputs/Input/__stories__/TextWithCharacterLimit.js +0 -31
  420. package/esm/inputs/Input/index.js +0 -75
  421. package/esm/inputs/Input/index.mdx +0 -8
  422. package/esm/inputs/Label/Label.stories.js +0 -7
  423. package/esm/inputs/Label/Label.stories.playwright.json +0 -40
  424. package/esm/inputs/Label/__stories__/Default.js +0 -29
  425. package/esm/inputs/Label/index.js +0 -25
  426. package/esm/inputs/Label/index.mdx +0 -0
  427. package/esm/inputs/OtpInput/OtpInput.stories.js +0 -7
  428. package/esm/inputs/OtpInput/__stories__/Default.js +0 -31
  429. package/esm/inputs/OtpInput/index.js +0 -157
  430. package/esm/inputs/Radio/Radio.stories.js +0 -9
  431. package/esm/inputs/Radio/Radio.stories.playwright.json +0 -73
  432. package/esm/inputs/Radio/__stories__/Conditional.js +0 -95
  433. package/esm/inputs/Radio/__stories__/Default.js +0 -47
  434. package/esm/inputs/Radio/__stories__/WithDivider.js +0 -48
  435. package/esm/inputs/Radio/index.js +0 -61
  436. package/esm/inputs/Radio/index.mdx +0 -0
  437. package/esm/inputs/Select/Select.stories.js +0 -7
  438. package/esm/inputs/Select/Select.stories.playwright.json +0 -22
  439. package/esm/inputs/Select/__stories__/Default.js +0 -53
  440. package/esm/inputs/Select/index.js +0 -32
  441. package/esm/inputs/index.js +0 -8
  442. package/esm/installation.mdx +0 -68
  443. package/esm/internal.js +0 -34
  444. package/esm/registry.js +0 -136
  445. package/esm/types.js +0 -1
  446. package/esm/utils.js +0 -99
  447. package/esm/validators/index.js +0 -186
  448. package/esm/validators/types.js +0 -1
  449. package/esm/validators/utils/afm.js +0 -35
  450. package/esm/validators/utils/file.js +0 -52
  451. package/esm/validators/utils/index.js +0 -102
  452. package/esm/validators/utils/number.js +0 -16
  453. package/esm/validators/utils/postal_code.js +0 -29
  454. package/esm/validators/validators.spec.js +0 -85
  455. /package/{es → cjs}/Field/index.mdx +0 -0
  456. /package/{es → cjs}/FieldArray/FieldArray.stories.playwright.json +0 -0
  457. /package/{es → cjs}/FormBuilder/FormBuilder.mdx +0 -0
  458. /package/{es → cjs}/FormBuilder/FormBuilder.stories.playwright.json +0 -0
  459. /package/{es → cjs}/MultiplicityField/MultiplicityField.mdx +0 -0
  460. /package/{es → cjs}/MultiplicityField/MultiplicityField.stories.playwright.json +0 -0
  461. /package/{es → cjs}/Questions/__snapshots__/index.spec.tsx.snap +0 -0
  462. /package/{es → cjs}/Questions/index.mdx +0 -0
  463. /package/{es → cjs}/create-simple-form.mdx +0 -0
  464. /package/{es → cjs}/index.mdx +0 -0
  465. /package/{es → cjs}/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -0
  466. /package/{es → cjs}/inputs/Checkboxes/index.mdx +0 -0
  467. /package/{es → cjs}/inputs/DateInput/DateInput.stories.playwright.json +0 -0
  468. /package/{es → cjs}/inputs/FileInput/FileInput.stories.playwright.json +0 -0
  469. /package/{es → cjs}/inputs/Input/Input.stories.playwright.json +0 -0
  470. /package/{es → cjs}/inputs/Input/index.mdx +0 -0
  471. /package/{es → cjs}/inputs/Label/Label.stories.playwright.json +0 -0
  472. /package/{es → cjs}/inputs/Label/index.mdx +0 -0
  473. /package/{es → cjs}/inputs/Radio/Radio.stories.playwright.json +0 -0
  474. /package/{es → cjs}/inputs/Radio/index.mdx +0 -0
  475. /package/{es → cjs}/inputs/Select/Select.stories.playwright.json +0 -0
  476. /package/{es → cjs}/installation.mdx +0 -0
package/esm/utils.js DELETED
@@ -1,99 +0,0 @@
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
-
5
- 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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
6
-
7
- import { validateFieldsNatively } from '@hookform/resolvers';
8
- import { appendErrors } from 'react-hook-form';
9
-
10
- /**
11
- * Why `path!` ? because it could be `undefined` in some case
12
- * https://github.com/jquense/yup#validationerrorerrors-string--arraystring-value-any-path-string
13
- */
14
- var parseErrorSchema = function parseErrorSchema(error, validateAllFieldCriteria) {
15
- return (error.inner || []).reduce(function (previous, error) {
16
- var _error$path;
17
-
18
- error.path = (_error$path = error.path) === null || _error$path === void 0 ? void 0 : _error$path.replace(/\[([0-9]+)\]/g, '.$1');
19
-
20
- if (!previous[error.path]) {
21
- previous[error.path] = {
22
- message: error.message,
23
- type: error.type
24
- };
25
- }
26
-
27
- if (validateAllFieldCriteria) {
28
- var types = previous[error.path].types;
29
- var messages = types && types[error.type];
30
- previous[error.path] = appendErrors(error.path, validateAllFieldCriteria, previous, error.type, messages ? [].concat(messages, error.message) : error.message);
31
- }
32
-
33
- return previous;
34
- }, {});
35
- };
36
-
37
- export var yupResolver = function yupResolver(schema) {
38
- var schemaOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
39
- var resolverOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
40
- return /*#__PURE__*/function () {
41
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(values, context, options) {
42
- var result, parsed;
43
- return _regeneratorRuntime().wrap(function _callee$(_context) {
44
- while (1) {
45
- switch (_context.prev = _context.next) {
46
- case 0:
47
- _context.prev = 0;
48
-
49
- if (schemaOptions.context && process.env.NODE_ENV === 'development') {
50
- // eslint-disable-next-line no-console
51
- console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead");
52
- }
53
-
54
- _context.next = 4;
55
- return schema[resolverOptions.mode === 'sync' ? 'validateSync' : 'validate'](values, _extends({
56
- abortEarly: false
57
- }, schemaOptions, {
58
- context: context
59
- }));
60
-
61
- case 4:
62
- result = _context.sent;
63
- options.shouldUseNativeValidation && validateFieldsNatively({}, options);
64
- return _context.abrupt("return", {
65
- values: resolverOptions.rawValues ? values : result,
66
- errors: {}
67
- });
68
-
69
- case 9:
70
- _context.prev = 9;
71
- _context.t0 = _context["catch"](0);
72
-
73
- if (_context.t0.inner) {
74
- _context.next = 13;
75
- break;
76
- }
77
-
78
- throw _context.t0;
79
-
80
- case 13:
81
- parsed = parseErrorSchema(_context.t0, !options.shouldUseNativeValidation && options.criteriaMode === 'all');
82
- return _context.abrupt("return", {
83
- values: {},
84
- errors: parsed
85
- });
86
-
87
- case 15:
88
- case "end":
89
- return _context.stop();
90
- }
91
- }
92
- }, _callee, null, [[0, 9]]);
93
- }));
94
-
95
- return function (_x, _x2, _x3) {
96
- return _ref.apply(this, arguments);
97
- };
98
- }();
99
- };
@@ -1,186 +0,0 @@
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 } 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';
9
- dayjs.extend(customParseFormat);
10
- var VALID_DATE_FORMATS = ['DD/MM/YYYY'];
11
- var DATE_CACHE = {};
12
-
13
- var getDate = function getDate(v) {
14
- return DATE_CACHE[v] ? DATE_CACHE[v] : dayjs(v, VALID_DATE_FORMATS, true);
15
- };
16
-
17
- export var getYUPTypeMap = function getYUPTypeMap() {
18
- var yupTypeMap = {
19
- file: function file(field) {
20
- return yup.mixed().transform(function (value) {
21
- if (!value.length) {
22
- return null;
23
- }
24
-
25
- return value;
26
- }).nullable().test(FILE_MAX_SIZE_VALIDATOR(field));
27
- },
28
- string: yup.string,
29
- "boolean": yup["boolean"],
30
- object: function object(field) {
31
- return getYupObjectShape(field.extra.fields, yupTypeMap);
32
- },
33
- array: function array(field) {
34
- if (_typeof(field.extra.of) === 'object') {
35
- // else if the field is an object then it is a scalar type
36
- // eg. number, string etc.
37
- var arrayValidator = yup.array().of(yupTypeMap[field.extra.of.type](field.extra.of)).required(field.required);
38
- if (field.extra.length) arrayValidator = arrayValidator.length(field.extra.length, {
39
- key: 'form.error.array.length',
40
- context: {
41
- length: field.extra.length
42
- }
43
- });
44
- if (field.extra.min) arrayValidator = arrayValidator.min(field.extra.min, {
45
- key: 'form.error.array.min',
46
- context: {
47
- min: field.extra.min
48
- }
49
- });
50
- if (field.extra.max) arrayValidator = arrayValidator.max(field.extra.max, {
51
- key: 'form.error.array.max',
52
- context: {
53
- max: field.extra.max
54
- }
55
- });
56
- return arrayValidator;
57
- } else if (typeof field.extra.of === 'string') {
58
- return yup.array().of(yupTypeMap[field.extra.of]());
59
- } else {
60
- // in any other case it will be string
61
- return yup.array().of(yup.string());
62
- }
63
- },
64
- "int": function int() {
65
- return yup.mixed().transform(function (_, val) {
66
- return val !== '' ? Number(val) : null;
67
- }).test(NUMBER_VALIDATOR()).test(INT_VALIDATOR());
68
- },
69
- email: function email() {
70
- return yup.string().email('form.error.email');
71
- },
72
- afm: function afm() {
73
- return yup.string().test(AFM_VALIDATOR);
74
- },
75
- uuid4: function uuid4() {
76
- return yup.string().test(UUID4_VALIDATOR);
77
- },
78
- iban: function iban(field) {
79
- return yup.string().test(IBAN_VALIDATOR(field));
80
- },
81
- otp: function otp(field) {
82
- return yup.string().test(OTP_VALIDATOR(field));
83
- },
84
- text: function text(field) {
85
- var _field$extra, _field$extra$limit, _field$extra2, _field$extra2$limit;
86
-
87
- 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)) {
88
- return yup.string().test(TEXT_LIMIT_VALIDATOR(field));
89
- } else {
90
- return yup.string();
91
- }
92
- },
93
- postal_code: function postal_code(field) {
94
- return yup.string().test(POSTALCODE_VALIDATOR(field));
95
- },
96
- mobile_phone: function mobile_phone() {
97
- return yup.string().test(MOBILE_PHONE_VALIDATOR);
98
- },
99
- phone_number: function phone_number(field) {
100
- return yup.string().test(PHONE_NUMBER_VALIDATOR(field));
101
- },
102
- 'choice:multiple': function choiceMultiple() {
103
- return yup.array().of(yup.string()).nullable();
104
- },
105
- 'choice:single': function choiceSingle() {
106
- return yup.string().nullable();
107
- },
108
- date: function date(field) {
109
- var simpleDate = yup.string().nullable(true).test('date', 'form.error.date.invalid', function (value) {
110
- if (!value) return true;
111
- var date = getDate(value);
112
- return date.isValid();
113
- });
114
- var params = field.extra || {};
115
-
116
- if (params.max) {
117
- var maxDate;
118
-
119
- if (params.max === 'now') {
120
- var today = new Date();
121
- maxDate = new Date(today);
122
- } else {
123
- maxDate = getDate(params.max).toDate();
124
- }
125
-
126
- var maxNextDate = new Date(maxDate);
127
- maxNextDate.setDate(maxDate.getDate() + 1);
128
- simpleDate = simpleDate.test({
129
- name: 'earlier-than',
130
- message: {
131
- key: 'form.error.date.earlier_than',
132
- context: {
133
- maxDate: maxNextDate.toLocaleDateString()
134
- }
135
- },
136
- test: function test(value) {
137
- if (!value) return true;
138
- var date = getDate(value);
139
- var isValid = +date.toDate() < +maxDate;
140
- return isValid;
141
- }
142
- });
143
- }
144
-
145
- if (params.min) {
146
- var minDate;
147
-
148
- if (params.min === 'now') {
149
- var _today = new Date();
150
-
151
- minDate = new Date(_today);
152
- } else {
153
- minDate = getDate(params.min).toDate();
154
- }
155
-
156
- var minPreviousDate = new Date(minDate);
157
- minPreviousDate.setDate(minDate.getDate() - 1);
158
- simpleDate = simpleDate.test({
159
- name: 'later-than',
160
- message: {
161
- key: 'form.error.date.later_than',
162
- context: {
163
- minDate: minPreviousDate.toLocaleDateString()
164
- }
165
- },
166
- test: function test(value) {
167
- if (!value) return true;
168
- var date = getDate(value);
169
- var isValid = +date.toDate() > +minDate;
170
- return isValid;
171
- }
172
- });
173
- }
174
-
175
- return simpleDate;
176
- }
177
- };
178
- return yupTypeMap;
179
- };
180
- // Create a yup validation schema from given fields input
181
- export function useValidationSchema(fields, validatorRegistry) {
182
- return useMemo(function () {
183
- var yupTypeMap = getYUPTypeMap();
184
- return getYupObjectShape(fields, yupTypeMap, validatorRegistry);
185
- }, []);
186
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,35 +0,0 @@
1
- export function validateAFM(afm) {
2
- if (afm.length !== 9) {
3
- // "afm should be 9 digits"
4
- return false;
5
- }
6
-
7
- if (!/^\d+$/.test(afm)) {
8
- // "This is not a number"
9
- return false;
10
- }
11
-
12
- if (afm === '0'.repeat(9)) {
13
- // "This is zero number (000000000)"
14
- return false;
15
- }
16
-
17
- var sum = afm.substring(0, 8).split('').reduce(function (s, v, i) {
18
- return s + (parseInt(v) << 8 - i);
19
- }, 0);
20
- var calc = sum % 11;
21
- var d9 = parseInt(afm[8]);
22
- var valid = calc % 10 === d9;
23
- return valid;
24
- }
25
- export var AFM_VALIDATOR = {
26
- name: 'afm-validator',
27
- message: 'form.error.afm',
28
- test: function test(value) {
29
- if (value) {
30
- return validateAFM(value);
31
- }
32
-
33
- return true;
34
- }
35
- };
@@ -1,52 +0,0 @@
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
-
3
- 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); }
4
-
5
- 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; }
6
-
7
- var DEFAULT_FILE_MAX_SIZE = 10000000;
8
- export var FILE_MAX_SIZE_VALIDATOR = function FILE_MAX_SIZE_VALIDATOR(field) {
9
- return {
10
- name: 'file-max-size-validator',
11
- message: 'form.error.file_size',
12
- test: function test(value) {
13
- if (field.extra && field.extra.maxSize && value) {
14
- var _iterator = _createForOfIteratorHelper(value),
15
- _step;
16
-
17
- try {
18
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
19
- var file = _step.value;
20
-
21
- if (file.size >= field.extra.maxSize) {
22
- return false;
23
- }
24
- }
25
- } catch (err) {
26
- _iterator.e(err);
27
- } finally {
28
- _iterator.f();
29
- }
30
- } else if (value) {
31
- var _iterator2 = _createForOfIteratorHelper(value),
32
- _step2;
33
-
34
- try {
35
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
36
- var _file = _step2.value;
37
-
38
- if (_file.size >= DEFAULT_FILE_MAX_SIZE) {
39
- return false;
40
- }
41
- }
42
- } catch (err) {
43
- _iterator2.e(err);
44
- } finally {
45
- _iterator2.f();
46
- }
47
- }
48
-
49
- return true;
50
- }
51
- };
52
- };
@@ -1,102 +0,0 @@
1
- import * as yup from 'yup';
2
- export * from '@digigov/form/validators/utils/afm';
3
- export * from '@digigov/form/validators/utils/file';
4
- export * from '@digigov/form/validators/utils/iban';
5
- export * from '@digigov/form/validators/utils/otp';
6
- export * from '@digigov/form/validators/utils/phone';
7
- export * from '@digigov/form/validators/utils/postal_code';
8
- export * from '@digigov/form/validators/utils/uuid4';
9
- export * from '@digigov/form/validators/utils/text_limit';
10
- export function getYupField(field, yupTypeMap) {
11
- var yupField = yupTypeMap[(field === null || field === void 0 ? void 0 : field.type) || 'string'] || yupTypeMap['string'];
12
- return yupField(field);
13
- }
14
- export function computeShape(fields, yupTypeMap, validatorRegistry) {
15
- var fieldSchemas = {};
16
- var objectFields = {};
17
- fields.forEach(function (field) {
18
- var yupField = getYupField(field, yupTypeMap);
19
-
20
- if (field.condition) {
21
- var _loop = function _loop(key) {
22
- var then = void 0,
23
- otherwise = void 0;
24
-
25
- if (field.condition[key].then) {
26
- var _field$condition$key$, _field$condition$key$2;
27
-
28
- if (((_field$condition$key$ = field.condition[key].then) === null || _field$condition$key$ === void 0 ? void 0 : _field$condition$key$.required) === false) {
29
- then = yupField.nullable();
30
- } else if (((_field$condition$key$2 = field.condition[key].then) === null || _field$condition$key$2 === void 0 ? void 0 : _field$condition$key$2.required) === true) {
31
- then = yupField.nullable().required('form.error.required');
32
- }
33
- }
34
-
35
- if (field.condition[key]["else"]) {
36
- var _field$condition$key$3, _field$condition$key$4;
37
-
38
- if (((_field$condition$key$3 = field.condition[key]["else"]) === null || _field$condition$key$3 === void 0 ? void 0 : _field$condition$key$3.required) === false) {
39
- otherwise = yupField.nullable();
40
- } else if (((_field$condition$key$4 = field.condition[key]["else"]) === null || _field$condition$key$4 === void 0 ? void 0 : _field$condition$key$4.required) === true) {
41
- otherwise = yupField.nullable().required('form.error.required');
42
- }
43
- }
44
-
45
- if (then || otherwise) {
46
- yupField = yupField.when(key, {
47
- is: function is(val) {
48
- //@ts-ignore
49
- var is = field.condition[key].is;
50
-
51
- if (is === val || Array.isArray(val) && val.includes(is)) {
52
- return true;
53
- } else {
54
- return false;
55
- }
56
- },
57
- then: then,
58
- otherwise: otherwise
59
- });
60
- }
61
- };
62
-
63
- for (var key in field.condition) {
64
- _loop(key);
65
- }
66
- } else if (field.required) {
67
- yupField = yupField.nullable().required('form.error.required');
68
- }
69
-
70
- if (validatorRegistry && field.type && validatorRegistry[field.type]) {
71
- validatorRegistry[field.type].forEach(function (validator) {
72
- yupField = yupField.test(validator);
73
- });
74
- }
75
-
76
- if (field.validators) {
77
- field.validators.forEach(function (validator) {
78
- yupField = yupField.test(validator);
79
- });
80
- }
81
-
82
- fieldSchemas[field.key] = yupField;
83
- });
84
-
85
- for (var objectKey in objectFields) {
86
- fieldSchemas[objectKey] = getYupObjectShape(objectFields[objectKey], yupTypeMap, validatorRegistry);
87
- }
88
-
89
- return fieldSchemas;
90
- }
91
- export function getYupObjectShape( // eslint-disable-next-line @typescript-eslint/no-explicit-any
92
- fields, yupTypeMap, validatorRegistry) {
93
- if (!fields.current) {
94
- var fieldSchemas = computeShape(fields, yupTypeMap, validatorRegistry);
95
- return yup.object().shape(fieldSchemas);
96
- }
97
-
98
- return yup.lazy(function () {
99
- var fieldSchemas = computeShape(Object.values(fields.current), yupTypeMap, validatorRegistry);
100
- return yup.object().shape(fieldSchemas);
101
- });
102
- }
@@ -1,16 +0,0 @@
1
- export function validateNumber(number) {
2
- return !Number.isNaN(number);
3
- }
4
- export var NUMBER_VALIDATOR = function NUMBER_VALIDATOR() {
5
- return {
6
- name: 'number-validator',
7
- message: 'form.error.number',
8
- test: function test(value) {
9
- if (value === null) {
10
- return true;
11
- }
12
-
13
- return validateNumber(value);
14
- }
15
- };
16
- };
@@ -1,29 +0,0 @@
1
- var CODE_REGEX = /^[12345678][0-9]{4}$/;
2
- export function validatePostalCode(number, countries) {
3
- if (!countries) {
4
- return false;
5
- } else {
6
- if (countries.length === 1 && countries[0].toUpperCase() === 'GR') {
7
- // Greek postal code must be 5 digits long and shouldn't start with 0 or 9.
8
- return CODE_REGEX.test(number);
9
- } else {
10
- return true;
11
- }
12
- }
13
- }
14
- export var POSTALCODE_VALIDATOR = function POSTALCODE_VALIDATOR(field) {
15
- var _field$extra;
16
-
17
- var countryCode = field === null || field === void 0 ? void 0 : (_field$extra = field.extra) === null || _field$extra === void 0 ? void 0 : _field$extra.countries;
18
- return {
19
- name: 'postal-code-validator',
20
- message: 'form.error.postalCode',
21
- test: function test(value) {
22
- if (!value) {
23
- return true;
24
- }
25
-
26
- return validatePostalCode(value, countryCode);
27
- }
28
- };
29
- };
@@ -1,85 +0,0 @@
1
- import { validateUUID4, validateIban, validatePostalCode, validatePhoneNumber } from '@digigov/form/validators/utils';
2
- it('validates wrong uuid4 for empty value', function () {
3
- expect(validateUUID4('')).toBe(false);
4
- });
5
- it('validates wrong uuid4 because of length', function () {
6
- expect(validateUUID4('9e463bc44a294bab8ee23af6cc3cbbe3')).toBe(false);
7
- });
8
- it('validates wrong uuid4 with correct length and wrong form', function () {
9
- expect(validateUUID4('ab123cd1-1234-ad34-ad45-12345abcdefg')).toBe(false);
10
- });
11
- it('validates correct uuid4 validator', function () {
12
- expect(validateUUID4('9e463bc4-4a29-4bab-8ee2-3af6cc3cbbe3')).toBe(true);
13
- });
14
- it('validates correct gr iban', function () {
15
- expect(validateIban('GR7801100800000008009825202', 'GR')).toBe(true);
16
- });
17
- it('validates correct iban with spaces and dashes', function () {
18
- expect(validateIban('GR 7801-1008 0000-0008 0098-25202', 'GR')).toBe(true);
19
- });
20
- it('validates correct foreign iban', function () {
21
- expect(validateIban('DE75512108001245126199', 'DE')).toBe(true);
22
- });
23
- it('validates wrong iban for empty value', function () {
24
- expect(validateIban('', '')).toBe(false);
25
- });
26
- it('validates wrong greek iban for wrong length', function () {
27
- expect(validateIban('GR78011008000000080098252020', 'gr')).toBe(false);
28
- });
29
- it('validates wrong iban for non existing country code', function () {
30
- expect(validateIban('AAA78011008000000080098252020', 'aaa')).toBe(false);
31
- });
32
- it('validates correct greek iban whithout country code', function () {
33
- expect(validateIban('7801100800000008009825202', '')).toBe(true);
34
- });
35
- it('validates wrong postal code without country code', function () {
36
- expect(validatePostalCode('123', [])).toBe(true);
37
- });
38
- it('validates wrong postal code with wrong country code', function () {
39
- expect(validatePostalCode('123', ['FR'])).toBe(true);
40
- });
41
- it('validates wrong postal code with greek country code', function () {
42
- expect(validatePostalCode('123', ['GR'])).toBe(false);
43
- });
44
- it('validates postal code with greek country code', function () {
45
- expect(validatePostalCode('11143', ['GR'])).toBe(true);
46
- });
47
- it('validates phone number type landline with greek country code', function () {
48
- expect(validatePhoneNumber('2102934896', ['GR'], 'landline')).toBe(true);
49
- });
50
- it('validates phone number type landline with ch country code', function () {
51
- expect(validatePhoneNumber('2102934896', ['CH'], 'landline')).toBe(false);
52
- });
53
- it('validates phone number type landline with ch and gr countries code', function () {
54
- expect(validatePhoneNumber('2102934896', ['GR', 'CH'], 'landline')).toBe(true);
55
- });
56
- it('validatesphone number type landline with ch and gr countries code', function () {
57
- expect(validatePhoneNumber('41446681800', ['GR', 'CH'], 'landline')).toBe(true);
58
- });
59
- it('validates phone number type landline with ch and gr countries code but phone number is mobile', function () {
60
- expect(validatePhoneNumber('2102934896', ['GR', 'CH'], 'mobile')).toBe(false);
61
- });
62
- it('validates phone number type mobile with ch and gr countries code', function () {
63
- expect(validatePhoneNumber('6934100982', ['GR', 'CH'], 'mobile')).toBe(true);
64
- });
65
- it('validates phone number type mobile with gr country code', function () {
66
- expect(validatePhoneNumber('6934100982', ['GR'], 'mobile')).toBe(true);
67
- });
68
- it('validates phone number type mobile with ch country code', function () {
69
- expect(validatePhoneNumber('6934100982', ['CH'], 'mobile')).toBe(false);
70
- });
71
- it('validates phone number with no type and ch country code', function () {
72
- expect(validatePhoneNumber('6934100982', ['CH'], null)).toBe(false);
73
- });
74
- it('validates phone number with no type and gr country code', function () {
75
- expect(validatePhoneNumber('6934100982', ['gr'], null)).toBe(true);
76
- });
77
- it('validates phone number with no type and ch country code', function () {
78
- expect(validatePhoneNumber('41446681800', ['CH'], null)).toBe(true);
79
- });
80
- it('validates phone number with no type and gr country code', function () {
81
- expect(validatePhoneNumber('41446681800', ['gr'], null)).toBe(false);
82
- });
83
- it('validates phone number with no type and gr and ch countries code', function () {
84
- expect(validatePhoneNumber('41446681800', ['gr', 'ch'], null)).toBe(true);
85
- });
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes