@digigov/form 2.0.0-cbc56209 → 2.0.0-d2ffc726

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 (925) hide show
  1. package/Field/ErrorGroup/index.js +48 -0
  2. package/{Questions/index.spec → Field/ErrorGroup}/package.json +1 -1
  3. package/Field/ErrorGroup.d.ts +15 -0
  4. package/Field/ErrorGroup.js.map +7 -0
  5. package/Field/FieldBase/index.js +115 -76
  6. package/Field/FieldBase.d.ts +1 -1
  7. package/Field/FieldBase.js.map +7 -0
  8. package/Field/FieldBaseContainer/index.js +50 -38
  9. package/Field/FieldBaseContainer.d.ts +2 -2
  10. package/Field/FieldBaseContainer.js.map +7 -0
  11. package/Field/FieldConditional/index.js +83 -53
  12. package/Field/FieldConditional.d.ts +1 -1
  13. package/Field/FieldConditional.js.map +7 -0
  14. package/Field/index.d.ts +1 -1
  15. package/Field/index.js +106 -66
  16. package/Field/index.js.map +7 -0
  17. package/Field/types/index.js +1 -1
  18. package/Field/types.d.ts +59 -11
  19. package/Field/types.js.map +7 -0
  20. package/Field/utils/evaluateFieldWithConditions/index.js +26 -0
  21. package/{inputs/DateInput/__stories__/Default → Field/utils/evaluateFieldWithConditions}/package.json +1 -1
  22. package/Field/utils/evaluateFieldWithConditions.d.ts +2 -0
  23. package/Field/utils/evaluateFieldWithConditions.js.map +7 -0
  24. package/Field/utils/resolveField/index.js +35 -0
  25. package/{Questions/Questions.stories → Field/utils/resolveField}/package.json +1 -1
  26. package/Field/utils/resolveField.d.ts +3 -0
  27. package/Field/utils/resolveField.js.map +7 -0
  28. package/Field/utils/useField/index.js +66 -0
  29. package/{FormBuilder/FormBuilder → Field/utils/useField}/package.json +1 -1
  30. package/Field/utils/useField.d.ts +2 -0
  31. package/Field/utils/useField.js.map +7 -0
  32. package/FieldArray/BaseFieldArray/index.js +76 -0
  33. package/FieldArray/BaseFieldArray/package.json +6 -0
  34. package/FieldArray/BaseFieldArray.d.ts +5 -0
  35. package/FieldArray/BaseFieldArray.js.map +7 -0
  36. package/FieldArray/FieldArray.stories.d.ts +4 -2
  37. package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/index.js +23 -0
  38. package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/package.json +6 -0
  39. package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.d.ts +9 -0
  40. package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js.map +7 -0
  41. package/FieldArray/FormDialog/ArrayDisplay/ArrayDisplay.stories.d.ts +13 -0
  42. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/index.js +184 -0
  43. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/package.json +6 -0
  44. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.d.ts +26 -0
  45. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js.map +7 -0
  46. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/index.js +11 -0
  47. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/package.json +6 -0
  48. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.d.ts +5 -0
  49. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js.map +7 -0
  50. package/FieldArray/FormDialog/ArrayDisplay/__stories__/Cards.d.ts +2 -0
  51. package/FieldArray/FormDialog/ArrayDisplay/__stories__/Default.d.ts +2 -0
  52. package/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnly.d.ts +2 -0
  53. package/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnlyCards.d.ts +2 -0
  54. package/FieldArray/FormDialog/ArrayDisplay/__stories__/Sortable.d.ts +2 -0
  55. package/FieldArray/FormDialog/ArrayDisplay/__stories__/SortableCards.d.ts +2 -0
  56. package/FieldArray/FormDialog/ArrayDisplay/index.d.ts +15 -0
  57. package/FieldArray/FormDialog/ArrayDisplay/index.js +57 -0
  58. package/FieldArray/FormDialog/ArrayDisplay/index.js.map +7 -0
  59. package/{inputs/DateInput/DateInput.stories → FieldArray/FormDialog/ArrayDisplay}/package.json +1 -1
  60. package/FieldArray/FormDialog/ArrayEditModal/index.js +158 -0
  61. package/{inputs/Checkboxes/Checkboxes.stories → FieldArray/FormDialog/ArrayEditModal}/package.json +1 -1
  62. package/FieldArray/FormDialog/ArrayEditModal.d.ts +26 -0
  63. package/FieldArray/FormDialog/ArrayEditModal.js.map +7 -0
  64. package/FieldArray/FormDialog/index.d.ts +19 -0
  65. package/FieldArray/FormDialog/index.js +236 -0
  66. package/FieldArray/FormDialog/index.js.map +7 -0
  67. package/FieldArray/FormDialog/package.json +6 -0
  68. package/FieldArray/__stories__/CardsWithError.d.ts +15 -0
  69. package/FieldArray/__stories__/Default.d.ts +2 -2
  70. package/FieldArray/__stories__/WithExactLength.d.ts +2 -2
  71. package/FieldArray/__stories__/WithModal.d.ts +2 -0
  72. package/FieldArray/index.d.ts +11 -2
  73. package/FieldArray/index.js +91 -59
  74. package/FieldArray/index.js.map +7 -0
  75. package/FieldObject/index.d.ts +11 -3
  76. package/FieldObject/index.js +78 -52
  77. package/FieldObject/index.js.map +7 -0
  78. package/Fieldset/FieldsetWithContext/index.js +27 -31
  79. package/Fieldset/FieldsetWithContext.js.map +7 -0
  80. package/Fieldset/index.d.ts +2 -2
  81. package/Fieldset/index.js +27 -29
  82. package/Fieldset/index.js.map +7 -0
  83. package/Fieldset/types/index.js +1 -1
  84. package/Fieldset/types.d.ts +3 -2
  85. package/Fieldset/types.js.map +7 -0
  86. package/FormBuilder/FormBuilder.stories.d.ts +5 -1
  87. package/FormBuilder/__stories__/AutoErrorGrouping.d.ts +3 -0
  88. package/FormBuilder/__stories__/Default.d.ts +2 -2
  89. package/FormBuilder/__stories__/ErrorGrouping.d.ts +3 -0
  90. package/FormBuilder/index.d.ts +8 -1
  91. package/FormBuilder/index.js +267 -2
  92. package/FormBuilder/index.js.map +7 -0
  93. package/FormContext/index.js +11 -3
  94. package/FormContext.d.ts +3 -2
  95. package/FormContext.js.map +7 -0
  96. package/MultiplicityField/MultiplicityField.stories.d.ts +8 -6
  97. package/MultiplicityField/__stories__/Default.d.ts +2 -2
  98. package/MultiplicityField/__stories__/PreviewDisplay.d.ts +2 -2
  99. package/MultiplicityField/__stories__/WithExactLength.d.ts +2 -2
  100. package/MultiplicityField/__stories__/WithMaxLength.d.ts +2 -2
  101. package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +2 -2
  102. package/MultiplicityField/__stories__/WithMinLength.d.ts +2 -2
  103. package/MultiplicityField/add-objects/index.js +131 -133
  104. package/MultiplicityField/add-objects.d.ts +3 -2
  105. package/MultiplicityField/add-objects.js.map +7 -0
  106. package/MultiplicityField/index.d.ts +2 -19
  107. package/MultiplicityField/index.js +117 -106
  108. package/MultiplicityField/index.js.map +7 -0
  109. package/MultiplicityField/types/index.js +1 -0
  110. package/MultiplicityField/types/package.json +6 -0
  111. package/MultiplicityField/types.d.ts +19 -0
  112. package/MultiplicityField/types.js.map +7 -0
  113. package/Questions/Questions/index.js +48 -56
  114. package/Questions/Questions.d.ts +1 -1
  115. package/Questions/Questions.js.map +7 -0
  116. package/Questions/Questions.stories.d.ts +3 -1
  117. package/Questions/QuestionsContext/index.js +9 -9
  118. package/Questions/QuestionsContext.d.ts +1 -2
  119. package/Questions/QuestionsContext.js.map +7 -0
  120. package/Questions/Step/ReviewStep/index.js +35 -47
  121. package/Questions/Step/ReviewStep.js.map +7 -0
  122. package/Questions/Step/Step/index.js +39 -47
  123. package/Questions/Step/Step.d.ts +1 -1
  124. package/Questions/Step/Step.js.map +7 -0
  125. package/Questions/Step/StepArrayReview/index.js +41 -45
  126. package/Questions/Step/StepArrayReview.d.ts +1 -1
  127. package/Questions/Step/StepArrayReview.js.map +7 -0
  128. package/Questions/Step/StepContext/index.js +15 -19
  129. package/Questions/Step/StepContext.d.ts +1 -2
  130. package/Questions/Step/StepContext.js.map +7 -0
  131. package/Questions/Step/StepDescription/index.js +22 -22
  132. package/Questions/Step/StepDescription.d.ts +1 -1
  133. package/Questions/Step/StepDescription.js.map +7 -0
  134. package/Questions/Step/StepForm/index.js +33 -43
  135. package/Questions/Step/StepForm.d.ts +2 -2
  136. package/Questions/Step/StepForm.js.map +7 -0
  137. package/Questions/Step/StepQuote/index.js +10 -9
  138. package/Questions/Step/StepQuote.d.ts +1 -1
  139. package/Questions/Step/StepQuote.js.map +7 -0
  140. package/Questions/Step/StepTitle/index.js +41 -38
  141. package/Questions/Step/StepTitle.d.ts +2 -1
  142. package/Questions/Step/StepTitle.js.map +7 -0
  143. package/Questions/Step/getAddMoreFields/index.js +28 -20
  144. package/Questions/Step/getAddMoreFields.d.ts +2 -2
  145. package/Questions/Step/getAddMoreFields.js.map +7 -0
  146. package/Questions/Step/index.d.ts +0 -1
  147. package/Questions/Step/index.js +16 -13
  148. package/Questions/Step/index.js.map +7 -0
  149. package/Questions/Step/types/index.js +1 -1
  150. package/Questions/Step/types.d.ts +2 -1
  151. package/Questions/Step/types.js.map +7 -0
  152. package/Questions/__stories__/Default.d.ts +2 -2
  153. package/Questions/getNextStep/index.js +12 -10
  154. package/Questions/getNextStep.d.ts +1 -1
  155. package/Questions/getNextStep.js.map +7 -0
  156. package/Questions/index.js +7 -3
  157. package/Questions/index.js.map +7 -0
  158. package/Questions/types/index.js +1 -1
  159. package/Questions/types.d.ts +2 -1
  160. package/Questions/types.js.map +7 -0
  161. package/cjs/Field/ErrorGroup/index.js +82 -0
  162. package/cjs/Field/ErrorGroup.js.map +7 -0
  163. package/cjs/Field/FieldBase/index.js +147 -82
  164. package/cjs/Field/FieldBase.js.map +7 -0
  165. package/cjs/Field/FieldBaseContainer/index.js +83 -45
  166. package/cjs/Field/FieldBaseContainer.js.map +7 -0
  167. package/cjs/Field/FieldConditional/index.js +115 -59
  168. package/cjs/Field/FieldConditional.js.map +7 -0
  169. package/cjs/Field/index.js +138 -75
  170. package/cjs/Field/index.js.map +7 -0
  171. package/cjs/Field/types/index.js +16 -5
  172. package/cjs/Field/types.js.map +7 -0
  173. package/cjs/Field/utils/evaluateFieldWithConditions/index.js +49 -0
  174. package/cjs/Field/utils/evaluateFieldWithConditions.js.map +7 -0
  175. package/cjs/Field/utils/resolveField/index.js +55 -0
  176. package/cjs/Field/utils/resolveField.js.map +7 -0
  177. package/cjs/Field/utils/useField/index.js +89 -0
  178. package/cjs/Field/utils/useField.js.map +7 -0
  179. package/cjs/FieldArray/BaseFieldArray/index.js +109 -0
  180. package/cjs/FieldArray/BaseFieldArray.js.map +7 -0
  181. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/index.js +56 -0
  182. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js.map +7 -0
  183. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/index.js +209 -0
  184. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js.map +7 -0
  185. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/index.js +44 -0
  186. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js.map +7 -0
  187. package/cjs/FieldArray/FormDialog/ArrayDisplay/index.js +90 -0
  188. package/cjs/FieldArray/FormDialog/ArrayDisplay/index.js.map +7 -0
  189. package/cjs/FieldArray/FormDialog/ArrayEditModal/index.js +186 -0
  190. package/cjs/FieldArray/FormDialog/ArrayEditModal.js.map +7 -0
  191. package/cjs/FieldArray/FormDialog/index.js +263 -0
  192. package/cjs/FieldArray/FormDialog/index.js.map +7 -0
  193. package/cjs/FieldArray/index.js +123 -65
  194. package/cjs/FieldArray/index.js.map +7 -0
  195. package/cjs/FieldObject/index.js +110 -61
  196. package/cjs/FieldObject/index.js.map +7 -0
  197. package/cjs/Fieldset/FieldsetWithContext/index.js +54 -40
  198. package/cjs/Fieldset/FieldsetWithContext.js.map +7 -0
  199. package/cjs/Fieldset/index.js +61 -39
  200. package/cjs/Fieldset/index.js.map +7 -0
  201. package/cjs/Fieldset/types/index.js +16 -5
  202. package/cjs/Fieldset/types.js.map +7 -0
  203. package/cjs/FormBuilder/index.js +302 -7
  204. package/cjs/FormBuilder/index.js.map +7 -0
  205. package/cjs/FormContext/index.js +34 -8
  206. package/cjs/FormContext.js.map +7 -0
  207. package/cjs/MultiplicityField/add-objects/index.js +163 -139
  208. package/cjs/MultiplicityField/add-objects.js.map +7 -0
  209. package/cjs/MultiplicityField/index.js +145 -115
  210. package/cjs/MultiplicityField/index.js.map +7 -0
  211. package/cjs/MultiplicityField/types/index.js +16 -0
  212. package/cjs/MultiplicityField/types.js.map +7 -0
  213. package/cjs/Questions/Questions/index.js +80 -65
  214. package/cjs/Questions/Questions.js.map +7 -0
  215. package/cjs/Questions/QuestionsContext/index.js +31 -14
  216. package/cjs/Questions/QuestionsContext.js.map +7 -0
  217. package/cjs/Questions/Step/ReviewStep/index.js +61 -56
  218. package/cjs/Questions/Step/ReviewStep.js.map +7 -0
  219. package/cjs/Questions/Step/Step/index.js +71 -56
  220. package/cjs/Questions/Step/Step.js.map +7 -0
  221. package/cjs/Questions/Step/StepArrayReview/index.js +65 -54
  222. package/cjs/Questions/Step/StepArrayReview.js.map +7 -0
  223. package/cjs/Questions/Step/StepContext/index.js +37 -24
  224. package/cjs/Questions/Step/StepContext.js.map +7 -0
  225. package/cjs/Questions/Step/StepDescription/index.js +55 -31
  226. package/cjs/Questions/Step/StepDescription.js.map +7 -0
  227. package/cjs/Questions/Step/StepForm/index.js +65 -52
  228. package/cjs/Questions/Step/StepForm.js.map +7 -0
  229. package/cjs/Questions/Step/StepQuote/index.js +42 -15
  230. package/cjs/Questions/Step/StepQuote.js.map +7 -0
  231. package/cjs/Questions/Step/StepTitle/index.js +72 -47
  232. package/cjs/Questions/Step/StepTitle.js.map +7 -0
  233. package/cjs/Questions/Step/getAddMoreFields/index.js +50 -25
  234. package/cjs/Questions/Step/getAddMoreFields.js.map +7 -0
  235. package/cjs/Questions/Step/index.js +59 -143
  236. package/cjs/Questions/Step/index.js.map +7 -0
  237. package/cjs/Questions/Step/types/index.js +16 -5
  238. package/cjs/Questions/Step/types.js.map +7 -0
  239. package/cjs/Questions/getNextStep/index.js +33 -14
  240. package/cjs/Questions/getNextStep.js.map +7 -0
  241. package/cjs/Questions/index.js +29 -19
  242. package/cjs/Questions/index.js.map +7 -0
  243. package/cjs/Questions/types/index.js +16 -5
  244. package/cjs/Questions/types.js.map +7 -0
  245. package/cjs/hooks/useFieldFocusManager/index.js +135 -0
  246. package/cjs/hooks/useFieldFocusManager.js.map +7 -0
  247. package/cjs/hooks/utils/index.js +98 -0
  248. package/cjs/hooks/utils.js.map +7 -0
  249. package/cjs/index.js +47 -20
  250. package/cjs/index.js.map +7 -0
  251. package/cjs/inputs/AutoCompleteInput/index.js +92 -46
  252. package/cjs/inputs/AutoCompleteInput/index.js.map +7 -0
  253. package/cjs/inputs/Checkboxes/index.js +102 -92
  254. package/cjs/inputs/Checkboxes/index.js.map +7 -0
  255. package/cjs/inputs/DateInput/index.js +164 -117
  256. package/cjs/inputs/DateInput/index.js.map +7 -0
  257. package/cjs/inputs/DateTimeInput/index.js +250 -0
  258. package/cjs/inputs/DateTimeInput/index.js.map +7 -0
  259. package/cjs/inputs/FileInput/index.js +115 -65
  260. package/cjs/inputs/FileInput/index.js.map +7 -0
  261. package/cjs/inputs/ImageInput/__stories__/logo.d/index.js +1 -0
  262. package/cjs/inputs/ImageInput/__stories__/logo.d.js.map +7 -0
  263. package/cjs/inputs/ImageInput/index.js +127 -83
  264. package/cjs/inputs/ImageInput/index.js.map +7 -0
  265. package/cjs/inputs/Input/index.js +101 -68
  266. package/cjs/inputs/Input/index.js.map +7 -0
  267. package/cjs/inputs/Label/index.js +45 -24
  268. package/cjs/inputs/Label/index.js.map +7 -0
  269. package/cjs/inputs/OtpInput/index.js +163 -127
  270. package/cjs/inputs/OtpInput/index.js.map +7 -0
  271. package/cjs/inputs/Radio/index.js +132 -61
  272. package/cjs/inputs/Radio/index.js.map +7 -0
  273. package/cjs/inputs/Select/index.js +61 -36
  274. package/cjs/inputs/Select/index.js.map +7 -0
  275. package/cjs/inputs/index.js +62 -69
  276. package/cjs/inputs/index.js.map +7 -0
  277. package/cjs/inputs/registry/index.js +121 -0
  278. package/cjs/inputs/registry.js.map +7 -0
  279. package/cjs/internal/index.js +36 -346
  280. package/cjs/internal.js.map +7 -0
  281. package/cjs/lazy/index.js +113 -516
  282. package/cjs/lazy.js.map +7 -0
  283. package/cjs/registry/index.js +204 -142
  284. package/cjs/registry.js.map +7 -0
  285. package/cjs/types/index.js +22 -5
  286. package/cjs/types.js.map +7 -0
  287. package/cjs/utils/index.js +93 -83
  288. package/cjs/utils.js.map +7 -0
  289. package/cjs/validators/index.js +142 -167
  290. package/cjs/validators/index.js.map +7 -0
  291. package/cjs/validators/types/index.js +16 -5
  292. package/cjs/validators/types.js.map +7 -0
  293. package/cjs/validators/utils/afm/index.js +38 -21
  294. package/cjs/validators/utils/afm.js.map +7 -0
  295. package/cjs/validators/utils/amka/index.js +60 -0
  296. package/cjs/validators/utils/amka.js.map +7 -0
  297. package/cjs/validators/utils/date/index.js +161 -0
  298. package/cjs/validators/utils/date.js.map +7 -0
  299. package/cjs/validators/utils/datetime/index.js +245 -0
  300. package/cjs/validators/utils/datetime.js.map +7 -0
  301. package/cjs/validators/utils/email/index.js +39 -0
  302. package/cjs/validators/utils/email.js.map +7 -0
  303. package/cjs/validators/utils/file/index.js +53 -43
  304. package/cjs/validators/utils/file.js.map +7 -0
  305. package/cjs/validators/utils/iban/index.js +36 -17
  306. package/cjs/validators/utils/iban.js.map +7 -0
  307. package/cjs/validators/utils/image/index.js +88 -112
  308. package/cjs/validators/utils/image.js.map +7 -0
  309. package/cjs/validators/utils/index.js +103 -159
  310. package/cjs/validators/utils/index.js.map +7 -0
  311. package/cjs/validators/utils/int/index.js +35 -13
  312. package/cjs/validators/utils/int.js.map +7 -0
  313. package/cjs/validators/utils/number/index.js +34 -12
  314. package/cjs/validators/utils/number.js.map +7 -0
  315. package/cjs/validators/utils/otp/index.js +35 -13
  316. package/cjs/validators/utils/otp.js.map +7 -0
  317. package/cjs/validators/utils/phone/index.js +113 -58
  318. package/cjs/validators/utils/phone.js.map +7 -0
  319. package/cjs/validators/utils/postal_code/index.js +36 -16
  320. package/cjs/validators/utils/postal_code.js.map +7 -0
  321. package/cjs/validators/utils/text_limit/index.js +40 -25
  322. package/cjs/validators/utils/text_limit.js.map +7 -0
  323. package/cjs/validators/utils/uuid4/index.js +34 -13
  324. package/cjs/validators/utils/uuid4.js.map +7 -0
  325. package/hooks/useFieldFocusManager/index.js +116 -0
  326. package/hooks/useFieldFocusManager/package.json +6 -0
  327. package/hooks/useFieldFocusManager.d.ts +25 -0
  328. package/hooks/useFieldFocusManager.js.map +7 -0
  329. package/hooks/utils/index.js +73 -0
  330. package/{Form.stories → hooks/utils}/package.json +1 -1
  331. package/hooks/utils.d.ts +18 -0
  332. package/hooks/utils.js.map +7 -0
  333. package/index.d.ts +4 -1
  334. package/index.js +13 -4
  335. package/index.js.map +7 -0
  336. package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +4 -1
  337. package/inputs/AutoCompleteInput/__stories__/Default.d.ts +3 -2
  338. package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +3 -0
  339. package/inputs/AutoCompleteInput/index.d.ts +5 -5
  340. package/inputs/AutoCompleteInput/index.js +60 -37
  341. package/inputs/AutoCompleteInput/index.js.map +7 -0
  342. package/inputs/Checkboxes/Checkboxes.stories.d.ts +5 -3
  343. package/inputs/Checkboxes/__stories__/Conditional.d.ts +3 -2
  344. package/inputs/Checkboxes/__stories__/Default.d.ts +2 -2
  345. package/inputs/Checkboxes/__stories__/WithDivider.d.ts +2 -2
  346. package/inputs/Checkboxes/index.d.ts +5 -4
  347. package/inputs/Checkboxes/index.js +73 -82
  348. package/inputs/Checkboxes/index.js.map +7 -0
  349. package/inputs/DateInput/DateInput.stories.d.ts +7 -1
  350. package/inputs/DateInput/__stories__/Default.d.ts +2 -2
  351. package/inputs/DateInput/__stories__/WithDefaultValue.d.ts +3 -0
  352. package/inputs/DateInput/__stories__/WithInitialValue.d.ts +3 -0
  353. package/inputs/DateInput/__stories__/WithWrongDefaultValue.d.ts +3 -0
  354. package/inputs/DateInput/__stories__/WithWrongInitialValue.d.ts +3 -0
  355. package/inputs/DateInput/index.d.ts +3 -7
  356. package/inputs/DateInput/index.js +133 -106
  357. package/inputs/DateInput/index.js.map +7 -0
  358. package/inputs/DateTimeInput/DateTimeInput.stories.d.ts +14 -0
  359. package/inputs/DateTimeInput/__stories__/Default.d.ts +3 -0
  360. package/inputs/DateTimeInput/__stories__/WithDefaultValue.d.ts +3 -0
  361. package/inputs/DateTimeInput/__stories__/WithInitialValue.d.ts +3 -0
  362. package/inputs/DateTimeInput/__stories__/WithWrongDefaultValue.d.ts +3 -0
  363. package/inputs/DateTimeInput/__stories__/WithWrongInitialValue.d.ts +3 -0
  364. package/inputs/DateTimeInput/index.d.ts +10 -0
  365. package/inputs/DateTimeInput/index.js +220 -0
  366. package/inputs/DateTimeInput/index.js.map +7 -0
  367. package/inputs/DateTimeInput/package.json +6 -0
  368. package/inputs/FileInput/FileInput.stories.d.ts +4 -1
  369. package/inputs/FileInput/__stories__/Default.d.ts +2 -2
  370. package/inputs/FileInput/__stories__/WithBorderAndLink.d.ts +3 -0
  371. package/inputs/FileInput/index.d.ts +18 -2
  372. package/inputs/FileInput/index.js +83 -56
  373. package/inputs/FileInput/index.js.map +7 -0
  374. package/inputs/ImageInput/ImageInput.stories.d.ts +6 -3
  375. package/inputs/ImageInput/__stories__/Default.d.ts +2 -2
  376. package/inputs/ImageInput/__stories__/MaxSize.d.ts +3 -0
  377. package/inputs/ImageInput/__stories__/WithInitialValues.d.ts +3 -0
  378. package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +2 -2
  379. package/inputs/ImageInput/__stories__/logo.d/index.js +1 -0
  380. package/inputs/{FileInput/__stories__/Default → ImageInput/__stories__/logo.d}/package.json +1 -1
  381. package/inputs/ImageInput/__stories__/logo.d.js.map +7 -0
  382. package/inputs/ImageInput/index.d.ts +10 -2
  383. package/inputs/ImageInput/index.js +95 -75
  384. package/inputs/ImageInput/index.js.map +7 -0
  385. package/inputs/Input/Input.stories.d.ts +15 -10
  386. package/inputs/Input/__stories__/AFM.d.ts +2 -2
  387. package/inputs/Input/__stories__/AMKA.d.ts +3 -0
  388. package/inputs/Input/__stories__/Boolean.d.ts +2 -2
  389. package/inputs/Input/__stories__/Email.d.ts +3 -0
  390. package/inputs/Input/__stories__/IBAN.d.ts +2 -2
  391. package/inputs/Input/__stories__/Integer.d.ts +2 -2
  392. package/inputs/Input/__stories__/LandlineNumber.d.ts +2 -2
  393. package/inputs/Input/__stories__/MobilePhone.d.ts +2 -2
  394. package/inputs/Input/__stories__/PhoneNumber.d.ts +2 -2
  395. package/inputs/Input/__stories__/PostalCode.d.ts +2 -2
  396. package/inputs/Input/__stories__/String.d.ts +3 -0
  397. package/inputs/Input/__stories__/StringWithTrimValidation.d.ts +3 -0
  398. package/inputs/Input/__stories__/TextWithLimit.d.ts +3 -0
  399. package/inputs/Input/index.d.ts +4 -3
  400. package/inputs/Input/index.js +69 -62
  401. package/inputs/Input/index.js.map +7 -0
  402. package/inputs/Label/Label.stories.d.ts +3 -1
  403. package/inputs/Label/__stories__/Default.d.ts +2 -2
  404. package/inputs/Label/index.d.ts +2 -4
  405. package/inputs/Label/index.js +12 -17
  406. package/inputs/Label/index.js.map +7 -0
  407. package/inputs/OtpInput/OtpInput.stories.d.ts +3 -1
  408. package/inputs/OtpInput/__stories__/Default.d.ts +2 -2
  409. package/inputs/OtpInput/index.d.ts +9 -6
  410. package/inputs/OtpInput/index.js +129 -117
  411. package/inputs/OtpInput/index.js.map +7 -0
  412. package/inputs/Radio/Radio.stories.d.ts +5 -3
  413. package/inputs/Radio/__stories__/Conditional.d.ts +3 -2
  414. package/inputs/Radio/__stories__/Default.d.ts +2 -2
  415. package/inputs/Radio/__stories__/WithDivider.d.ts +2 -2
  416. package/inputs/Radio/index.d.ts +8 -3
  417. package/inputs/Radio/index.js +103 -55
  418. package/inputs/Radio/index.js.map +7 -0
  419. package/inputs/Select/Select.stories.d.ts +3 -1
  420. package/inputs/Select/__stories__/Default.d.ts +2 -2
  421. package/inputs/Select/index.d.ts +5 -4
  422. package/inputs/Select/index.js +33 -31
  423. package/inputs/Select/index.js.map +7 -0
  424. package/inputs/index.js +21 -9
  425. package/inputs/index.js.map +7 -0
  426. package/inputs/registry/index.js +86 -0
  427. package/{Field/utils → inputs/registry}/package.json +1 -1
  428. package/inputs/registry.d.ts +5 -0
  429. package/inputs/registry.js.map +7 -0
  430. package/internal/index.js +10 -34
  431. package/internal.d.ts +2 -31
  432. package/internal.js.map +7 -0
  433. package/lazy/index.js +79 -393
  434. package/package.json +8 -9
  435. package/registry/index.js +140 -99
  436. package/src/Field/ErrorGroup.tsx +84 -0
  437. package/src/Field/FieldBase.tsx +41 -24
  438. package/src/Field/FieldBaseContainer.tsx +71 -47
  439. package/src/Field/FieldConditional.tsx +10 -2
  440. package/src/Field/doc.mdx +207 -0
  441. package/src/Field/index.tsx +37 -23
  442. package/src/Field/types.tsx +89 -13
  443. package/src/Field/utils/evaluateFieldWithConditions.ts +33 -0
  444. package/src/Field/utils/resolveField.ts +58 -0
  445. package/src/Field/utils/useField.ts +68 -0
  446. package/src/FieldArray/BaseFieldArray.tsx +97 -0
  447. package/src/FieldArray/FieldArray.stories.js +4 -2
  448. package/src/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.tsx +45 -0
  449. package/src/FieldArray/FormDialog/ArrayDisplay/ArrayDisplay.stories.js +14 -0
  450. package/src/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.tsx +335 -0
  451. package/src/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.tsx +15 -0
  452. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Cards.tsx +88 -0
  453. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Default.tsx +93 -0
  454. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnly.tsx +79 -0
  455. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnlyCards.tsx +75 -0
  456. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Sortable.tsx +93 -0
  457. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/SortableCards.tsx +88 -0
  458. package/src/FieldArray/FormDialog/ArrayDisplay/index.test.tsx +44 -0
  459. package/src/FieldArray/FormDialog/ArrayDisplay/index.tsx +67 -0
  460. package/src/FieldArray/FormDialog/ArrayEditModal.tsx +243 -0
  461. package/src/FieldArray/FormDialog/index.tsx +304 -0
  462. package/src/FieldArray/__stories__/CardsWithError.tsx +124 -0
  463. package/src/FieldArray/__stories__/Default.tsx +2 -1
  464. package/src/FieldArray/__stories__/WithExactLength.tsx +2 -1
  465. package/src/FieldArray/__stories__/WithModal.tsx +160 -0
  466. package/src/FieldArray/__tests__/fieldset-multiplicity.spec.tsx +271 -0
  467. package/src/FieldArray/__tests__/multiplicity-attachment.spec.tsx +280 -0
  468. package/src/FieldArray/__tests__/multiplicity-optional.spec.tsx +232 -0
  469. package/src/FieldArray/__tests__/multiplicity-required.spec.tsx +170 -0
  470. package/src/FieldArray/__tests__/nested-fieldset-multiplicity.spec.tsx +627 -0
  471. package/src/FieldArray/__tests__/preference-multiple-choice.spec.tsx +222 -0
  472. package/src/FieldArray/index.spec.tsx +355 -0
  473. package/src/FieldArray/index.test.tsx +36 -0
  474. package/src/FieldArray/index.tsx +84 -55
  475. package/src/FieldObject/index.tsx +53 -27
  476. package/src/Fieldset/FieldsetWithContext.tsx +1 -1
  477. package/src/Fieldset/index.tsx +6 -6
  478. package/src/Fieldset/types.tsx +5 -3
  479. package/src/FormBuilder/FormBuilder.stories.js +6 -1
  480. package/src/FormBuilder/__stories__/AutoErrorGrouping.tsx +63 -0
  481. package/src/FormBuilder/__stories__/Default.tsx +1 -1
  482. package/src/FormBuilder/__stories__/ErrorGrouping.tsx +43 -0
  483. package/src/FormBuilder/{FormBuilder.mdx → doc.mdx} +27 -35
  484. package/src/FormBuilder/index.test.tsx +32 -0
  485. package/src/FormBuilder/index.tsx +314 -1
  486. package/src/FormBuilder/interaction.test.tsx +40 -0
  487. package/src/FormBuilder/scenarios.test.tsx +2737 -0
  488. package/src/FormContext.tsx +7 -3
  489. package/src/MultiplicityField/MultiplicityField.stories.js +9 -6
  490. package/src/MultiplicityField/__stories__/Default.tsx +1 -1
  491. package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +3 -3
  492. package/src/MultiplicityField/__stories__/WithExactLength.tsx +2 -2
  493. package/src/MultiplicityField/__stories__/WithMaxLength.tsx +2 -2
  494. package/src/MultiplicityField/__stories__/WithMinAndMaxLength.tsx +2 -2
  495. package/src/MultiplicityField/__stories__/WithMinLength.tsx +2 -2
  496. package/src/MultiplicityField/add-objects.tsx +39 -30
  497. package/{cjs/MultiplicityField/MultiplicityField.mdx → src/MultiplicityField/doc.mdx} +112 -98
  498. package/src/MultiplicityField/index.test.tsx +44 -0
  499. package/src/MultiplicityField/index.tsx +25 -34
  500. package/src/MultiplicityField/types.ts +25 -0
  501. package/src/Questions/Questions.stories.js +4 -1
  502. package/src/Questions/Questions.tsx +6 -6
  503. package/src/Questions/QuestionsContext.tsx +1 -1
  504. package/src/Questions/Step/Step.tsx +1 -1
  505. package/src/Questions/Step/StepArrayReview.tsx +3 -3
  506. package/src/Questions/Step/StepContext.tsx +1 -1
  507. package/src/Questions/Step/StepDescription.tsx +2 -1
  508. package/src/Questions/Step/StepForm.tsx +2 -2
  509. package/src/Questions/Step/StepQuote.tsx +2 -1
  510. package/src/Questions/Step/StepTitle.tsx +6 -3
  511. package/src/Questions/Step/getAddMoreFields.tsx +2 -2
  512. package/src/Questions/Step/index.ts +0 -1
  513. package/src/Questions/Step/types.tsx +2 -1
  514. package/src/Questions/__snapshots__/index.spec.tsx.snap +74 -587
  515. package/src/Questions/__stories__/Default.tsx +1 -1
  516. package/src/Questions/{index.mdx → doc.mdx} +34 -57
  517. package/src/Questions/getNextStep.tsx +1 -1
  518. package/src/Questions/index.spec.tsx +17 -5
  519. package/src/Questions/index.test.tsx +24 -0
  520. package/src/Questions/types.tsx +2 -1
  521. package/src/create-simple-form.mdx +2 -6
  522. package/{index.mdx → src/doc.mdx} +29 -18
  523. package/src/hooks/__tests__/useFieldFocusManager.spec.tsx +1079 -0
  524. package/src/hooks/__tests__/utils.spec.ts +568 -0
  525. package/src/hooks/useFieldFocusManager.ts +162 -0
  526. package/src/hooks/utils.ts +122 -0
  527. package/src/index.ts +4 -1
  528. package/src/inputs/AutoCompleteInput/AutoComplete.stories.js +5 -1
  529. package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +20 -19
  530. package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +47 -0
  531. package/src/inputs/AutoCompleteInput/doc.mdx +18 -0
  532. package/src/inputs/AutoCompleteInput/index.test.tsx +28 -0
  533. package/src/inputs/AutoCompleteInput/index.tsx +48 -33
  534. package/src/inputs/Checkboxes/Checkboxes.stories.js +6 -3
  535. package/src/inputs/Checkboxes/__stories__/Conditional.tsx +3 -4
  536. package/src/inputs/Checkboxes/__stories__/Default.tsx +1 -1
  537. package/src/inputs/Checkboxes/__stories__/WithDivider.tsx +1 -1
  538. package/src/inputs/Checkboxes/doc.mdx +23 -0
  539. package/src/inputs/Checkboxes/index.test.tsx +32 -0
  540. package/src/inputs/Checkboxes/index.tsx +103 -92
  541. package/src/inputs/DateInput/DateInput.stories.js +8 -1
  542. package/src/inputs/DateInput/__stories__/Default.tsx +17 -16
  543. package/src/inputs/DateInput/__stories__/WithDefaultValue.tsx +26 -0
  544. package/src/inputs/DateInput/__stories__/WithInitialValue.tsx +28 -0
  545. package/src/inputs/DateInput/__stories__/WithWrongDefaultValue.tsx +26 -0
  546. package/src/inputs/DateInput/__stories__/WithWrongInitialValue.tsx +28 -0
  547. package/src/inputs/DateInput/doc.mdx +16 -0
  548. package/src/inputs/DateInput/index.test.tsx +40 -0
  549. package/src/inputs/DateInput/index.tsx +77 -27
  550. package/src/inputs/DateTimeInput/DateTimeInput.stories.js +14 -0
  551. package/src/inputs/DateTimeInput/__stories__/Default.tsx +25 -0
  552. package/src/inputs/DateTimeInput/__stories__/WithDefaultValue.tsx +26 -0
  553. package/src/inputs/DateTimeInput/__stories__/WithInitialValue.tsx +28 -0
  554. package/src/inputs/DateTimeInput/__stories__/WithWrongDefaultValue.tsx +26 -0
  555. package/src/inputs/DateTimeInput/__stories__/WithWrongInitialValue.tsx +28 -0
  556. package/src/inputs/DateTimeInput/doc.mdx +16 -0
  557. package/src/inputs/DateTimeInput/index.test.tsx +40 -0
  558. package/src/inputs/DateTimeInput/index.tsx +246 -0
  559. package/src/inputs/FileInput/FileInput.stories.js +5 -1
  560. package/src/inputs/FileInput/__stories__/Default.tsx +1 -1
  561. package/src/inputs/FileInput/__stories__/WithBorderAndLink.tsx +34 -0
  562. package/src/inputs/FileInput/doc.mdx +15 -0
  563. package/src/inputs/FileInput/index.test.tsx +28 -0
  564. package/src/inputs/FileInput/index.tsx +109 -42
  565. package/src/inputs/ImageInput/ImageInput.stories.js +7 -3
  566. package/src/inputs/ImageInput/__stories__/Default.tsx +1 -1
  567. package/src/inputs/ImageInput/__stories__/{WithInvalidImageSize.tsx → MaxSize.tsx} +5 -3
  568. package/src/inputs/ImageInput/__stories__/WithInitialValues.tsx +45 -0
  569. package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +3 -1
  570. package/src/inputs/ImageInput/__stories__/logo.d.ts +4 -0
  571. package/src/inputs/ImageInput/__stories__/logo.png +0 -0
  572. package/src/inputs/ImageInput/doc.mdx +23 -0
  573. package/src/inputs/ImageInput/index.test.tsx +36 -0
  574. package/src/inputs/ImageInput/index.tsx +104 -51
  575. package/src/inputs/Input/Input.stories.js +16 -10
  576. package/src/inputs/Input/__stories__/AFM.tsx +1 -1
  577. package/src/inputs/Input/__stories__/AMKA.tsx +23 -0
  578. package/src/inputs/Input/__stories__/Boolean.tsx +1 -1
  579. package/src/inputs/Input/__stories__/Email.tsx +23 -0
  580. package/src/inputs/Input/__stories__/IBAN.tsx +1 -1
  581. package/src/inputs/Input/__stories__/Integer.tsx +1 -1
  582. package/src/inputs/Input/__stories__/LandlineNumber.tsx +3 -2
  583. package/src/inputs/Input/__stories__/MobilePhone.tsx +2 -1
  584. package/src/inputs/Input/__stories__/PhoneNumber.tsx +2 -1
  585. package/src/inputs/Input/__stories__/PostalCode.tsx +2 -1
  586. package/src/inputs/Input/__stories__/{Default.tsx → String.tsx} +2 -2
  587. package/src/inputs/Input/__stories__/StringWithTrimValidation.tsx +26 -0
  588. package/src/inputs/Input/__stories__/{TextWithCharacterLimit.tsx → TextWithLimit.tsx} +3 -2
  589. package/src/inputs/Input/doc.mdx +56 -0
  590. package/src/inputs/Input/index.test.tsx +72 -0
  591. package/src/inputs/Input/index.tsx +87 -73
  592. package/src/inputs/Label/Label.stories.js +4 -1
  593. package/src/inputs/Label/__stories__/Default.tsx +4 -2
  594. package/src/inputs/Label/doc.mdx +14 -0
  595. package/src/inputs/Label/index.test.tsx +24 -0
  596. package/src/inputs/Label/index.tsx +4 -11
  597. package/src/inputs/OtpInput/OtpInput.stories.js +4 -1
  598. package/src/inputs/OtpInput/__stories__/Default.tsx +1 -1
  599. package/src/inputs/OtpInput/doc.mdx +16 -0
  600. package/src/inputs/OtpInput/index.test.tsx +24 -0
  601. package/src/inputs/OtpInput/index.tsx +46 -35
  602. package/src/inputs/Radio/Radio.stories.js +6 -3
  603. package/src/inputs/Radio/__stories__/Conditional.tsx +5 -2
  604. package/src/inputs/Radio/__stories__/Default.tsx +1 -1
  605. package/src/inputs/Radio/__stories__/WithDivider.tsx +1 -1
  606. package/src/inputs/Radio/doc.mdx +23 -0
  607. package/src/inputs/Radio/index.test.tsx +32 -0
  608. package/src/inputs/Radio/index.tsx +90 -12
  609. package/src/inputs/Select/Select.stories.js +4 -1
  610. package/src/inputs/Select/__stories__/Default.tsx +1 -1
  611. package/src/inputs/Select/doc.mdx +13 -0
  612. package/src/inputs/Select/index.test.tsx +24 -0
  613. package/src/inputs/Select/index.tsx +20 -9
  614. package/src/inputs/registry.ts +86 -0
  615. package/src/installation.mdx +2 -5
  616. package/src/internal.ts +2 -31
  617. package/src/lazy.js +80 -59
  618. package/src/registry.js +123 -89
  619. package/src/types.tsx +21 -65
  620. package/src/utils.ts +58 -35
  621. package/src/validators/index.ts +120 -99
  622. package/src/validators/types.ts +1 -1
  623. package/src/validators/utils/amka.ts +39 -0
  624. package/src/validators/utils/date.ts +131 -0
  625. package/src/validators/utils/datetime.ts +222 -0
  626. package/src/validators/utils/email.ts +11 -0
  627. package/src/validators/utils/file.ts +36 -20
  628. package/src/validators/utils/iban.ts +2 -2
  629. package/src/validators/utils/image.ts +2 -2
  630. package/src/validators/utils/index.ts +8 -3
  631. package/src/validators/utils/int.ts +2 -2
  632. package/src/validators/utils/number.ts +2 -2
  633. package/src/validators/utils/otp.ts +2 -2
  634. package/src/validators/utils/phone.ts +65 -74
  635. package/src/validators/utils/postal_code.ts +3 -3
  636. package/src/validators/utils/text_limit.ts +2 -2
  637. package/src/validators/utils/uuid4.ts +2 -1
  638. package/src/validators/validators.spec.ts +6 -40
  639. package/types/index.js +2 -1
  640. package/types.d.ts +14 -37
  641. package/types.js.map +7 -0
  642. package/utils/index.js +71 -77
  643. package/utils.d.ts +3 -1
  644. package/utils.js.map +7 -0
  645. package/validators/index.d.ts +6 -6
  646. package/validators/index.js +124 -153
  647. package/validators/index.js.map +7 -0
  648. package/validators/types/index.js +1 -1
  649. package/validators/types.d.ts +1 -1
  650. package/validators/types.js.map +7 -0
  651. package/validators/utils/afm/index.js +16 -16
  652. package/validators/utils/afm.js.map +7 -0
  653. package/validators/utils/amka/index.js +36 -0
  654. package/validators/utils/amka/package.json +6 -0
  655. package/validators/utils/amka.d.ts +6 -0
  656. package/validators/utils/amka.js.map +7 -0
  657. package/validators/utils/date/index.js +126 -0
  658. package/validators/utils/date/package.json +6 -0
  659. package/validators/utils/date.d.ts +9 -0
  660. package/validators/utils/date.js.map +7 -0
  661. package/validators/utils/datetime/index.js +210 -0
  662. package/validators/utils/datetime/package.json +6 -0
  663. package/validators/utils/datetime.d.ts +9 -0
  664. package/validators/utils/datetime.js.map +7 -0
  665. package/validators/utils/email/index.js +16 -0
  666. package/validators/utils/email/package.json +6 -0
  667. package/validators/utils/email.d.ts +5 -0
  668. package/validators/utils/email.js.map +7 -0
  669. package/validators/utils/file/index.js +31 -38
  670. package/validators/utils/file.d.ts +2 -2
  671. package/validators/utils/file.js.map +7 -0
  672. package/validators/utils/iban/index.js +14 -12
  673. package/validators/utils/iban.d.ts +2 -2
  674. package/validators/utils/iban.js.map +7 -0
  675. package/validators/utils/image/index.js +66 -106
  676. package/validators/utils/image.d.ts +2 -2
  677. package/validators/utils/image.js.map +7 -0
  678. package/validators/utils/index.d.ts +5 -2
  679. package/validators/utils/index.js +59 -48
  680. package/validators/utils/index.js.map +7 -0
  681. package/validators/utils/int/index.js +13 -8
  682. package/validators/utils/int.d.ts +1 -1
  683. package/validators/utils/int.js.map +7 -0
  684. package/validators/utils/number/index.js +12 -7
  685. package/validators/utils/number.d.ts +1 -1
  686. package/validators/utils/number.js.map +7 -0
  687. package/validators/utils/otp/index.js +13 -8
  688. package/validators/utils/otp.d.ts +2 -2
  689. package/validators/utils/otp.js.map +7 -0
  690. package/validators/utils/phone/index.js +89 -51
  691. package/validators/utils/phone.d.ts +3 -3
  692. package/validators/utils/phone.js.map +7 -0
  693. package/validators/utils/postal_code/index.js +14 -11
  694. package/validators/utils/postal_code.d.ts +3 -3
  695. package/validators/utils/postal_code.js.map +7 -0
  696. package/validators/utils/text_limit/index.js +18 -20
  697. package/validators/utils/text_limit.d.ts +2 -2
  698. package/validators/utils/text_limit.js.map +7 -0
  699. package/validators/utils/uuid4/index.js +12 -8
  700. package/validators/utils/uuid4.js.map +7 -0
  701. package/Field/index.mdx +0 -6
  702. package/Field/utils/index.js +0 -153
  703. package/Field/utils.d.ts +0 -5
  704. package/FieldArray/FieldArray.stories/index.js +0 -8
  705. package/FieldArray/FieldArray.stories/package.json +0 -6
  706. package/FieldArray/FieldArray.stories.playwright.json +0 -353
  707. package/FieldArray/__stories__/Default/index.js +0 -88
  708. package/FieldArray/__stories__/Default/package.json +0 -6
  709. package/FieldArray/__stories__/WithExactLength/index.js +0 -88
  710. package/FieldArray/__stories__/WithExactLength/package.json +0 -6
  711. package/Form.stories/index.js +0 -3
  712. package/FormBuilder/FormBuilder/index.js +0 -152
  713. package/FormBuilder/FormBuilder.d.ts +0 -5
  714. package/FormBuilder/FormBuilder.mdx +0 -256
  715. package/FormBuilder/FormBuilder.stories/index.js +0 -7
  716. package/FormBuilder/FormBuilder.stories/package.json +0 -6
  717. package/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  718. package/FormBuilder/__stories__/Default/index.js +0 -26
  719. package/FormBuilder/__stories__/Default/package.json +0 -6
  720. package/MultiplicityField/MultiplicityField.mdx +0 -590
  721. package/MultiplicityField/MultiplicityField.stories/index.js +0 -12
  722. package/MultiplicityField/MultiplicityField.stories/package.json +0 -6
  723. package/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  724. package/MultiplicityField/__stories__/Default/index.js +0 -95
  725. package/MultiplicityField/__stories__/Default/package.json +0 -6
  726. package/MultiplicityField/__stories__/PreviewDisplay/index.js +0 -72
  727. package/MultiplicityField/__stories__/PreviewDisplay/package.json +0 -6
  728. package/MultiplicityField/__stories__/WithExactLength/index.js +0 -90
  729. package/MultiplicityField/__stories__/WithExactLength/package.json +0 -6
  730. package/MultiplicityField/__stories__/WithMaxLength/index.js +0 -93
  731. package/MultiplicityField/__stories__/WithMaxLength/package.json +0 -6
  732. package/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +0 -94
  733. package/MultiplicityField/__stories__/WithMinAndMaxLength/package.json +0 -6
  734. package/MultiplicityField/__stories__/WithMinLength/index.js +0 -93
  735. package/MultiplicityField/__stories__/WithMinLength/package.json +0 -6
  736. package/Questions/Questions.stories/index.js +0 -7
  737. package/Questions/__snapshots__/index.spec.tsx.snap +0 -596
  738. package/Questions/__stories__/Default/index.js +0 -102
  739. package/Questions/__stories__/Default/package.json +0 -6
  740. package/Questions/index.mdx +0 -415
  741. package/Questions/index.spec/index.js +0 -59
  742. package/cjs/Field/index.mdx +0 -6
  743. package/cjs/Field/utils/index.js +0 -167
  744. package/cjs/FieldArray/FieldArray.stories/index.js +0 -38
  745. package/cjs/FieldArray/FieldArray.stories.playwright.json +0 -353
  746. package/cjs/FieldArray/__stories__/Default/index.js +0 -98
  747. package/cjs/FieldArray/__stories__/WithExactLength/index.js +0 -98
  748. package/cjs/Form.stories/index.js +0 -9
  749. package/cjs/FormBuilder/FormBuilder/index.js +0 -162
  750. package/cjs/FormBuilder/FormBuilder.mdx +0 -256
  751. package/cjs/FormBuilder/FormBuilder.stories/index.js +0 -26
  752. package/cjs/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  753. package/cjs/FormBuilder/__stories__/Default/index.js +0 -36
  754. package/cjs/MultiplicityField/MultiplicityField.stories/index.js +0 -86
  755. package/cjs/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  756. package/cjs/MultiplicityField/__stories__/Default/index.js +0 -105
  757. package/cjs/MultiplicityField/__stories__/PreviewDisplay/index.js +0 -82
  758. package/cjs/MultiplicityField/__stories__/WithExactLength/index.js +0 -100
  759. package/cjs/MultiplicityField/__stories__/WithMaxLength/index.js +0 -103
  760. package/cjs/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +0 -104
  761. package/cjs/MultiplicityField/__stories__/WithMinLength/index.js +0 -103
  762. package/cjs/Questions/Questions.stories/index.js +0 -26
  763. package/cjs/Questions/__snapshots__/index.spec.tsx.snap +0 -596
  764. package/cjs/Questions/__stories__/Default/index.js +0 -113
  765. package/cjs/Questions/index.mdx +0 -415
  766. package/cjs/Questions/index.spec/index.js +0 -63
  767. package/cjs/create-simple-form.mdx +0 -539
  768. package/cjs/index.mdx +0 -51
  769. package/cjs/inputs/AutoCompleteInput/AutoComplete.stories/index.js +0 -26
  770. package/cjs/inputs/AutoCompleteInput/__stories__/Default/index.js +0 -56
  771. package/cjs/inputs/Checkboxes/Checkboxes.stories/index.js +0 -50
  772. package/cjs/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  773. package/cjs/inputs/Checkboxes/__stories__/Conditional/index.js +0 -102
  774. package/cjs/inputs/Checkboxes/__stories__/Default/index.js +0 -50
  775. package/cjs/inputs/Checkboxes/__stories__/WithDivider/index.js +0 -51
  776. package/cjs/inputs/Checkboxes/index.mdx +0 -0
  777. package/cjs/inputs/DateInput/DateInput.stories/index.js +0 -26
  778. package/cjs/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  779. package/cjs/inputs/DateInput/__stories__/Default/index.js +0 -33
  780. package/cjs/inputs/FileInput/FileInput.stories/index.js +0 -26
  781. package/cjs/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  782. package/cjs/inputs/FileInput/__stories__/Default/index.js +0 -30
  783. package/cjs/inputs/ImageInput/ImageInput.stories/index.js +0 -50
  784. package/cjs/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
  785. package/cjs/inputs/ImageInput/__stories__/Default/index.js +0 -38
  786. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +0 -46
  787. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +0 -43
  788. package/cjs/inputs/Input/Input.stories/index.js +0 -134
  789. package/cjs/inputs/Input/Input.stories.playwright.json +0 -376
  790. package/cjs/inputs/Input/__stories__/AFM/index.js +0 -32
  791. package/cjs/inputs/Input/__stories__/Boolean/index.js +0 -33
  792. package/cjs/inputs/Input/__stories__/Default/index.js +0 -33
  793. package/cjs/inputs/Input/__stories__/IBAN/index.js +0 -33
  794. package/cjs/inputs/Input/__stories__/Integer/index.js +0 -41
  795. package/cjs/inputs/Input/__stories__/LandlineNumber/index.js +0 -36
  796. package/cjs/inputs/Input/__stories__/MobilePhone/index.js +0 -36
  797. package/cjs/inputs/Input/__stories__/PhoneNumber/index.js +0 -35
  798. package/cjs/inputs/Input/__stories__/PostalCode/index.js +0 -35
  799. package/cjs/inputs/Input/__stories__/TextWithCharacterLimit/index.js +0 -39
  800. package/cjs/inputs/Input/index.mdx +0 -8
  801. package/cjs/inputs/Label/Label.stories/index.js +0 -26
  802. package/cjs/inputs/Label/Label.stories.playwright.json +0 -40
  803. package/cjs/inputs/Label/__stories__/Default/index.js +0 -37
  804. package/cjs/inputs/Label/index.mdx +0 -0
  805. package/cjs/inputs/OtpInput/OtpInput.stories/index.js +0 -26
  806. package/cjs/inputs/OtpInput/__stories__/Default/index.js +0 -39
  807. package/cjs/inputs/Radio/Radio.stories/index.js +0 -50
  808. package/cjs/inputs/Radio/Radio.stories.playwright.json +0 -73
  809. package/cjs/inputs/Radio/__stories__/Conditional/index.js +0 -102
  810. package/cjs/inputs/Radio/__stories__/Default/index.js +0 -55
  811. package/cjs/inputs/Radio/__stories__/WithDivider/index.js +0 -56
  812. package/cjs/inputs/Radio/index.mdx +0 -0
  813. package/cjs/inputs/Select/Select.stories/index.js +0 -26
  814. package/cjs/inputs/Select/Select.stories.playwright.json +0 -22
  815. package/cjs/inputs/Select/__stories__/Default/index.js +0 -61
  816. package/cjs/installation.mdx +0 -68
  817. package/cjs/validators/validators.spec/index.js +0 -87
  818. package/create-simple-form.mdx +0 -539
  819. package/inputs/AutoCompleteInput/AutoComplete.stories/index.js +0 -7
  820. package/inputs/AutoCompleteInput/AutoComplete.stories/package.json +0 -6
  821. package/inputs/AutoCompleteInput/__stories__/Default/index.js +0 -46
  822. package/inputs/AutoCompleteInput/__stories__/Default/package.json +0 -6
  823. package/inputs/Checkboxes/Checkboxes.stories/index.js +0 -9
  824. package/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  825. package/inputs/Checkboxes/__stories__/Conditional/index.js +0 -92
  826. package/inputs/Checkboxes/__stories__/Conditional/package.json +0 -6
  827. package/inputs/Checkboxes/__stories__/Default/index.js +0 -40
  828. package/inputs/Checkboxes/__stories__/Default/package.json +0 -6
  829. package/inputs/Checkboxes/__stories__/WithDivider/index.js +0 -41
  830. package/inputs/Checkboxes/__stories__/WithDivider/package.json +0 -6
  831. package/inputs/Checkboxes/index.mdx +0 -0
  832. package/inputs/DateInput/DateInput.stories/index.js +0 -7
  833. package/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  834. package/inputs/DateInput/__stories__/Default/index.js +0 -23
  835. package/inputs/FileInput/FileInput.stories/index.js +0 -7
  836. package/inputs/FileInput/FileInput.stories/package.json +0 -6
  837. package/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  838. package/inputs/FileInput/__stories__/Default/index.js +0 -20
  839. package/inputs/ImageInput/ImageInput.stories/index.js +0 -9
  840. package/inputs/ImageInput/ImageInput.stories/package.json +0 -6
  841. package/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
  842. package/inputs/ImageInput/__stories__/Default/index.js +0 -28
  843. package/inputs/ImageInput/__stories__/Default/package.json +0 -6
  844. package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +0 -36
  845. package/inputs/ImageInput/__stories__/WithInvalidImageDimension/package.json +0 -6
  846. package/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +0 -33
  847. package/inputs/ImageInput/__stories__/WithInvalidImageSize/package.json +0 -6
  848. package/inputs/ImageInput/__stories__/WithInvalidImageSize.d.ts +0 -3
  849. package/inputs/Input/Input.stories/index.js +0 -16
  850. package/inputs/Input/Input.stories/package.json +0 -6
  851. package/inputs/Input/Input.stories.playwright.json +0 -376
  852. package/inputs/Input/__stories__/AFM/index.js +0 -22
  853. package/inputs/Input/__stories__/AFM/package.json +0 -6
  854. package/inputs/Input/__stories__/Boolean/index.js +0 -23
  855. package/inputs/Input/__stories__/Boolean/package.json +0 -6
  856. package/inputs/Input/__stories__/Default/index.js +0 -23
  857. package/inputs/Input/__stories__/Default/package.json +0 -6
  858. package/inputs/Input/__stories__/Default.d.ts +0 -3
  859. package/inputs/Input/__stories__/IBAN/index.js +0 -23
  860. package/inputs/Input/__stories__/IBAN/package.json +0 -6
  861. package/inputs/Input/__stories__/Integer/index.js +0 -31
  862. package/inputs/Input/__stories__/Integer/package.json +0 -6
  863. package/inputs/Input/__stories__/LandlineNumber/index.js +0 -26
  864. package/inputs/Input/__stories__/LandlineNumber/package.json +0 -6
  865. package/inputs/Input/__stories__/MobilePhone/index.js +0 -26
  866. package/inputs/Input/__stories__/MobilePhone/package.json +0 -6
  867. package/inputs/Input/__stories__/PhoneNumber/index.js +0 -25
  868. package/inputs/Input/__stories__/PhoneNumber/package.json +0 -6
  869. package/inputs/Input/__stories__/PostalCode/index.js +0 -25
  870. package/inputs/Input/__stories__/PostalCode/package.json +0 -6
  871. package/inputs/Input/__stories__/TextWithCharacterLimit/index.js +0 -29
  872. package/inputs/Input/__stories__/TextWithCharacterLimit/package.json +0 -6
  873. package/inputs/Input/__stories__/TextWithCharacterLimit.d.ts +0 -3
  874. package/inputs/Input/index.mdx +0 -8
  875. package/inputs/Label/Label.stories/index.js +0 -7
  876. package/inputs/Label/Label.stories/package.json +0 -6
  877. package/inputs/Label/Label.stories.playwright.json +0 -40
  878. package/inputs/Label/__stories__/Default/index.js +0 -27
  879. package/inputs/Label/__stories__/Default/package.json +0 -6
  880. package/inputs/Label/index.mdx +0 -0
  881. package/inputs/OtpInput/OtpInput.stories/index.js +0 -7
  882. package/inputs/OtpInput/OtpInput.stories/package.json +0 -6
  883. package/inputs/OtpInput/__stories__/Default/index.js +0 -29
  884. package/inputs/OtpInput/__stories__/Default/package.json +0 -6
  885. package/inputs/Radio/Radio.stories/index.js +0 -9
  886. package/inputs/Radio/Radio.stories/package.json +0 -6
  887. package/inputs/Radio/Radio.stories.playwright.json +0 -73
  888. package/inputs/Radio/__stories__/Conditional/index.js +0 -92
  889. package/inputs/Radio/__stories__/Conditional/package.json +0 -6
  890. package/inputs/Radio/__stories__/Default/index.js +0 -45
  891. package/inputs/Radio/__stories__/Default/package.json +0 -6
  892. package/inputs/Radio/__stories__/WithDivider/index.js +0 -46
  893. package/inputs/Radio/__stories__/WithDivider/package.json +0 -6
  894. package/inputs/Radio/index.mdx +0 -0
  895. package/inputs/Select/Select.stories/index.js +0 -7
  896. package/inputs/Select/Select.stories/package.json +0 -6
  897. package/inputs/Select/Select.stories.playwright.json +0 -22
  898. package/inputs/Select/__stories__/Default/index.js +0 -51
  899. package/inputs/Select/__stories__/Default/package.json +0 -6
  900. package/installation.mdx +0 -68
  901. package/lazy.d.ts +0 -69
  902. package/registry.d.ts +0 -64
  903. package/src/Field/index.mdx +0 -6
  904. package/src/Field/utils.ts +0 -191
  905. package/src/FieldArray/FieldArray.stories.playwright.json +0 -353
  906. package/src/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  907. package/src/FormBuilder/FormBuilder.tsx +0 -166
  908. package/src/MultiplicityField/MultiplicityField.mdx +0 -590
  909. package/src/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  910. package/src/index.mdx +0 -51
  911. package/src/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  912. package/src/inputs/Checkboxes/index.mdx +0 -0
  913. package/src/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  914. package/src/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  915. package/src/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
  916. package/src/inputs/Input/Input.stories.playwright.json +0 -376
  917. package/src/inputs/Input/index.mdx +0 -8
  918. package/src/inputs/Label/Label.stories.playwright.json +0 -40
  919. package/src/inputs/Label/index.mdx +0 -0
  920. package/src/inputs/Radio/Radio.stories.playwright.json +0 -73
  921. package/src/inputs/Radio/index.mdx +0 -0
  922. package/src/inputs/Select/Select.stories.playwright.json +0 -22
  923. package/validators/validators.spec/index.js +0 -85
  924. package/validators/validators.spec/package.json +0 -6
  925. /package/{Questions/index.spec.d.ts → hooks/__tests__/utils.spec.d.ts} +0 -0
@@ -1,23 +1,23 @@
1
- import { FieldSpec } from '@digigov/form/types';
2
- import { ValidatorSchema } from '@digigov/form/validators/types';
1
+ import type { FieldSpec } from '@digigov/form/types';
2
+ import type { ValidatorSchema } from '@digigov/form/validators/types';
3
3
 
4
4
  export type PhoneNumberType = 'landline' | 'mobile' | null;
5
5
  // add more countries from here libphonenumber-js/metadata.full.json
6
6
  const countryPhoneData = {
7
- "GR": [
8
- "30",
9
- "00",
10
- "5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}",
7
+ GR: [
8
+ '30',
9
+ '00',
10
+ '5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}',
11
11
  [10, 11, 12],
12
12
  [
13
- ["(\\d{2})(\\d{4})(\\d{4})", "$1 $2 $3", ["21|7"]],
13
+ ['(\\d{2})(\\d{4})(\\d{4})', '$1 $2 $3', ['21|7']],
14
14
  [
15
- "(\\d{4})(\\d{6})",
16
- "$1 $2",
17
- ["2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5"]
15
+ '(\\d{4})(\\d{6})',
16
+ '$1 $2',
17
+ ['2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5'],
18
18
  ],
19
- ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["[2689]"]],
20
- ["(\\d{3})(\\d{3,4})(\\d{5})", "$1 $2 $3", ["8"]]
19
+ ['(\\d{3})(\\d{3})(\\d{4})', '$1 $2 $3', ['[2689]']],
20
+ ['(\\d{3})(\\d{3,4})(\\d{5})', '$1 $2 $3', ['8']],
21
21
  ],
22
22
  0,
23
23
  0,
@@ -27,93 +27,77 @@ const countryPhoneData = {
27
27
  0,
28
28
  [
29
29
  [
30
- "2(?:1\\d\\d|2(?:2[1-46-9]|[36][1-8]|4[1-7]|5[1-4]|7[1-5]|[89][1-9])|3(?:1\\d|2[1-57]|[35][1-3]|4[13]|7[1-7]|8[124-6]|9[1-79])|4(?:1\\d|2[1-8]|3[1-4]|4[13-5]|6[1-578]|9[1-5])|5(?:1\\d|[29][1-4]|3[1-5]|4[124]|5[1-6])|6(?:1\\d|[269][1-6]|3[1245]|4[1-7]|5[13-9]|7[14]|8[1-5])|7(?:1\\d|2[1-5]|3[1-6]|4[1-7]|5[1-57]|6[135]|9[125-7])|8(?:1\\d|2[1-5]|[34][1-4]|9[1-57]))\\d{6}",
31
- [10]
30
+ '2(?:1\\d\\d|2(?:2[1-46-9]|[36][1-8]|4[1-7]|5[1-4]|7[1-5]|[89][1-9])|3(?:1\\d|2[1-57]|[35][1-3]|4[13]|7[1-7]|8[124-6]|9[1-79])|4(?:1\\d|2[1-8]|3[1-4]|4[13-5]|6[1-578]|9[1-5])|5(?:1\\d|[29][1-4]|3[1-5]|4[124]|5[1-6])|6(?:1\\d|[269][1-6]|3[1245]|4[1-7]|5[13-9]|7[14]|8[1-5])|7(?:1\\d|2[1-5]|3[1-6]|4[1-7]|5[1-57]|6[135]|9[125-7])|8(?:1\\d|2[1-5]|[34][1-4]|9[1-57]))\\d{6}',
31
+ [10],
32
32
  ],
33
- ["68[57-9]\\d{7}|(?:69|94)\\d{8}", [10]],
34
- ["800\\d{7,9}"],
35
- ["90[19]\\d{7}", [10]],
36
- ["70\\d{8}", [10]],
33
+ ['68[57-9]\\d{7}|(?:69|94)\\d{8}', [10]],
34
+ ['800\\d{7,9}'],
35
+ ['90[19]\\d{7}', [10]],
36
+ ['70\\d{8}', [10]],
37
37
  0,
38
- ["5005000\\d{3}", [10]],
38
+ ['5005000\\d{3}', [10]],
39
39
  0,
40
40
  0,
41
- ["8(?:0[16]|12|[27]5|50)\\d{7}", [10]]
42
- ]
43
- ]
44
- }
41
+ ['8(?:0[16]|12|[27]5|50)\\d{7}', [10]],
42
+ ],
43
+ ],
44
+ };
45
45
 
46
46
  function expandPhoneNumberStructure(compressed) {
47
47
  const countries = Object.keys(compressed);
48
- const expanded: any = {}
48
+ const expanded: any = {};
49
49
  for (const country of countries) {
50
50
  expanded[country] = {
51
51
  fixedLine: {
52
52
  possibleLengths: {
53
- _national:
54
- compressed[country][3].map(
55
- String
56
- ),
53
+ _national: compressed[country][3].map(String),
57
54
  },
58
- nationalNumberPattern:
59
- compressed[country][11][0][0],
55
+ nationalNumberPattern: compressed[country][11][0][0],
60
56
  },
61
57
  mobile: {
62
- nationalNumberPattern:
63
- compressed[country][11][1][0],
58
+ nationalNumberPattern: compressed[country][11][1][0],
64
59
  },
65
60
  tollFree: {
66
- nationalNumberPattern:
67
- compressed[country][11][2][0],
61
+ nationalNumberPattern: compressed[country][11][2][0],
68
62
  },
69
63
  premiumRate: {
70
- nationalNumberPattern:
71
- compressed[country][11][3][0],
64
+ nationalNumberPattern: compressed[country][11][3][0],
72
65
  },
73
66
  sharedCost: {
74
- nationalNumberPattern:
75
- compressed[country][11][9][0],
67
+ nationalNumberPattern: compressed[country][11][9][0],
76
68
  },
77
69
  personalNumber: {
78
- nationalNumberPattern:
79
- compressed[country][11][4][0],
70
+ nationalNumberPattern: compressed[country][11][4][0],
80
71
  },
81
72
  uan: {
82
- nationalNumberPattern:
83
- compressed[country][11][6][0],
73
+ nationalNumberPattern: compressed[country][11][6][0],
84
74
  },
85
75
  id: country,
86
- countryCode:
87
- compressed[country][0],
88
- internationalPrefix:
89
- compressed[country][1],
90
-
91
- }
76
+ countryCode: compressed[country][0],
77
+ internationalPrefix: compressed[country][1],
78
+ };
92
79
  }
93
80
  return expanded;
94
81
  }
95
82
  const PHONENUMBER_SPEC = expandPhoneNumberStructure(countryPhoneData);
96
- export function discoverPhoneType(
97
- phoneNumber: string,
98
- config: any
99
- ): string {
83
+ export function discoverPhoneType(phoneNumber: string, config: any): string {
100
84
  const cleanNumber = phoneNumber
101
- .replace(/\D/g, "")
102
- .replace(/\s/g, "")
103
- .replace(/^\+/, "")
104
- .replace(new RegExp("^" + config.internationalPrefix, ""), "")
105
- .replace(new RegExp("^" + config.countryCode, ""), "");
85
+ .replace(/\D/g, '')
86
+ .replace(/\s/g, '')
87
+ .replace(/^\+/, '')
88
+ .replace(new RegExp('^' + config.internationalPrefix, ''), '')
89
+ .replace(new RegExp('^' + config.countryCode, ''), '');
106
90
  const categories = {
107
- "landline": config.fixedLine,
91
+ landline: config.fixedLine,
108
92
  mobile: config.mobile,
109
- "toll-free": config.tollFree,
110
- "premium-rate": config.premiumRate,
93
+ 'toll-free': config.tollFree,
94
+ 'premium-rate': config.premiumRate,
111
95
  };
112
96
 
113
97
  for (const [categoryName, categoryDetails] of Object.entries(categories)) {
114
98
  const pattern = new RegExp(
115
- "^(" + categoryDetails.nationalNumberPattern.replace(/\s/g, "") + ")$",
116
- ""
99
+ '^(' + categoryDetails.nationalNumberPattern.replace(/\s/g, '') + ')$',
100
+ ''
117
101
  );
118
102
  if (cleanNumber.match(pattern)) {
119
103
  return categoryName; // Returns the category name if the number matches the pattern
@@ -121,47 +105,54 @@ export function discoverPhoneType(
121
105
  }
122
106
 
123
107
  // If no category matches, return 'Unknown'
124
- return "unknown";
108
+ return 'unknown';
125
109
  }
126
110
  function getNumberType(phoneNumber: string, country: string) {
127
111
  const spec = PHONENUMBER_SPEC[country.toUpperCase()];
128
- if(!spec) {
112
+ if (!spec) {
129
113
  throw new Error(`Country ${country} is not supported`);
130
114
  }
131
115
  const type = discoverPhoneType(phoneNumber, spec);
132
116
  return type;
133
117
  }
134
118
 
135
- function isPhoneNumberValid(phoneNumber: string, countries: string[], types=['mobile', 'landline']) {
119
+ function isPhoneNumberValid(
120
+ phoneNumber: string,
121
+ countries: string[],
122
+ types = ['mobile', 'landline']
123
+ ) {
136
124
  return countries.some((country) => {
137
125
  const numberType = getNumberType(phoneNumber, country);
138
126
  if (numberType && types.includes(numberType)) {
139
- return true
127
+ return true;
140
128
  }
141
- return false
142
- })
129
+ return false;
130
+ });
143
131
  }
144
132
  function isNumberOfType(phoneNumber: string, country: string, type: string) {
145
133
  const numberType = getNumberType(phoneNumber, country);
146
134
  if (numberType === type) {
147
- return true
135
+ return true;
148
136
  }
149
- return false
137
+ return false;
150
138
  }
151
139
  export function validatePhoneNumber(
152
140
  phoneNumber: string,
153
- countries: Array<string> = ['gr'],
141
+ countries: string[] = ['gr'],
154
142
  typeOfPhoneNumber?: PhoneNumberType
155
143
  ): boolean {
156
144
  if (!countries || countries.length === 0) {
157
145
  return true;
158
146
  }
159
- return isPhoneNumberValid(phoneNumber, countries, typeOfPhoneNumber? [typeOfPhoneNumber] : undefined);
147
+ return isPhoneNumberValid(
148
+ phoneNumber,
149
+ countries,
150
+ typeOfPhoneNumber ? [typeOfPhoneNumber] : undefined
151
+ );
160
152
  }
161
153
 
162
-
163
154
  function validateMobile(value): boolean {
164
- return isNumberOfType(value, 'gr','mobile');
155
+ return isNumberOfType(value, 'gr', 'mobile');
165
156
  }
166
157
 
167
158
  export const MOBILE_PHONE_VALIDATOR = {
@@ -1,10 +1,10 @@
1
- import { FieldSpec } from '@digigov/form/types';
2
- import { ValidatorSchema } from '@digigov/form/validators/types';
1
+ import type { FieldSpec } from '@digigov/form/types';
2
+ import type { ValidatorSchema } from '@digigov/form/validators/types';
3
3
 
4
4
  const CODE_REGEX = /^[12345678][0-9]{4}$/;
5
5
  export function validatePostalCode(
6
6
  number: string,
7
- countries: Array<string>
7
+ countries: string[]
8
8
  ): boolean {
9
9
  if (!countries) {
10
10
  return false;
@@ -1,5 +1,5 @@
1
- import { FieldSpec } from '@digigov/form/types';
2
- import { ValidatorSchema } from '@digigov/form/validators/types';
1
+ import type { FieldSpec } from '@digigov/form/types';
2
+ import type { ValidatorSchema } from '@digigov/form/validators/types';
3
3
 
4
4
  export function validateText(value: string, min: number, max: number): boolean {
5
5
  let validator;
@@ -1,4 +1,5 @@
1
- const UUID4_PATTERN = /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
1
+ const UUID4_PATTERN =
2
+ /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
2
3
 
3
4
  export function validateUUID4(uuid4: string): boolean {
4
5
  if (uuid4.length !== 36) {
@@ -69,54 +69,20 @@ it('validates phone number type landline with greek country code', () => {
69
69
  expect(validatePhoneNumber('2102934896', ['GR'], 'landline')).toBe(true);
70
70
  });
71
71
 
72
- it('validates phone number type landline with ch country code', () => {
73
- expect(validatePhoneNumber('2102934896', ['CH'], 'landline')).toBe(false);
74
- });
75
-
76
- it('validates phone number type landline with ch and gr countries code', () => {
77
- expect(validatePhoneNumber('2102934896', ['GR', 'CH'], 'landline')).toBe(
78
- true
79
- );
80
- });
81
-
82
- it('validatesphone number type landline with ch and gr countries code', () => {
83
- expect(validatePhoneNumber('41446681800', ['GR', 'CH'], 'landline')).toBe(
84
- true
72
+ it('throws if given country is not supported', () => {
73
+ expect(() => validatePhoneNumber('2102934896', ['CH'], 'landline')).toThrow(
74
+ 'Country CH is not supported'
85
75
  );
86
76
  });
87
77
 
88
- it('validates phone number type landline with ch and gr countries code but phone number is mobile', () => {
89
- expect(validatePhoneNumber('2102934896', ['GR', 'CH'], 'mobile')).toBe(false);
90
- });
91
-
92
- it('validates phone number type mobile with ch and gr countries code', () => {
93
- expect(validatePhoneNumber('6934100982', ['GR', 'CH'], 'mobile')).toBe(true);
94
- });
95
-
96
- it('validates phone number type mobile with gr country code', () => {
78
+ it('validates phone number type mobile with gr country code', () => {
97
79
  expect(validatePhoneNumber('6934100982', ['GR'], 'mobile')).toBe(true);
98
80
  });
99
81
 
100
- it('validates phone number type mobile with ch country code', () => {
101
- expect(validatePhoneNumber('6934100982', ['CH'], 'mobile')).toBe(false);
102
- });
103
-
104
- it('validates phone number with no type and ch country code', () => {
105
- expect(validatePhoneNumber('6934100982', ['CH'], null)).toBe(false);
106
- });
107
-
108
- it('validates phone number with no type and gr country code', () => {
82
+ it('validates phone number with no type and gr country code', () => {
109
83
  expect(validatePhoneNumber('6934100982', ['gr'], null)).toBe(true);
110
84
  });
111
85
 
112
- it('validates phone number with no type and ch country code', () => {
113
- expect(validatePhoneNumber('41446681800', ['CH'], null)).toBe(true);
114
- });
115
-
116
- it('validates phone number with no type and gr country code', () => {
86
+ it('validates invalid phone number with no type and gr country code', () => {
117
87
  expect(validatePhoneNumber('41446681800', ['gr'], null)).toBe(false);
118
88
  });
119
-
120
- it('validates phone number with no type and gr and ch countries code', () => {
121
- expect(validatePhoneNumber('41446681800', ['gr', 'ch'], null)).toBe(true);
122
- });
package/types/index.js CHANGED
@@ -1 +1,2 @@
1
- export {};
1
+ export * from "@digigov/form/Field/types";
2
+ //# sourceMappingURL=types.js.map
package/types.d.ts CHANGED
@@ -1,40 +1,10 @@
1
- /// <reference types="react" />
2
- import { UseFormReturn, UseFormProps } from 'react-hook-form';
3
- import { FieldComponentRegistry } from '@digigov/form/Field/types';
4
- import { ValidatorSchema } from '@digigov/form/validators/types';
5
- import { GridProps } from '@digigov/ui/layouts/Grid';
6
- export type FieldError = {
1
+ import type { UseFormReturn, UseFormProps, ErrorOption } from 'react-hook-form';
2
+ import type { FieldLabelProps, FieldSpec, FormData } from '@digigov/form/Field/types';
3
+ import type { FieldComponentRegistry } from '@digigov/form/inputs/registry';
4
+ import type { ValidatorSchema } from '@digigov/form/validators/types';
5
+ export * from '@digigov/form/Field/types';
6
+ export interface FieldError {
7
7
  message: string;
8
- };
9
- export type FieldLabelProps = {
10
- primary?: string;
11
- secondary?: string;
12
- };
13
- export interface FieldCondition {
14
- is: string | string[] | number | number[] | boolean | boolean[];
15
- then?: Partial<FieldSpec>;
16
- else?: Partial<FieldSpec>;
17
- }
18
- export interface FieldSpec {
19
- key: string;
20
- type?: 'int' | 'string' | 'text' | 'boolean' | 'email' | 'uuid4' | 'choice:multiple' | 'choice:single' | 'mobile_phone' | 'date' | 'otp' | 'afm' | 'iban' | 'file' | 'image' | 'postal_code' | 'phone_number' | 'array' | 'object';
21
- component?: any;
22
- maxLength?: number;
23
- condition?: Record<string, FieldCondition>;
24
- controlled?: boolean;
25
- label?: FieldLabelProps;
26
- extra?: {
27
- [key: string]: any;
28
- };
29
- editable?: boolean;
30
- required?: boolean;
31
- enabled?: boolean;
32
- layout?: Record<string, GridProps['xs'] | GridProps['sm'] | GridProps['md'] | GridProps['lg'] | GridProps['xl']>;
33
- validators?: ValidatorSchema[];
34
- wrapper?: 'label' | 'fieldset';
35
- maxWidth?: string;
36
- maxHeight?: string;
37
- width?: string;
38
8
  }
39
9
  export interface FieldsetSpec {
40
10
  key: string;
@@ -42,24 +12,29 @@ export interface FieldsetSpec {
42
12
  label?: FieldLabelProps;
43
13
  body?: React.ReactNode;
44
14
  }
45
- export type FormData = UseFormProps['defaultValues'];
15
+ export type registerFieldFocus = (fieldName: string, element: HTMLElement) => (name: string) => void;
46
16
  export interface FormContextProps {
47
17
  fieldsetsMap?: Record<string, FieldsetSpec>;
48
18
  fieldsMap: Record<string, FieldSpec>;
49
19
  control: UseFormReturn['control'];
50
20
  register: UseFormReturn['register'];
51
21
  trigger: UseFormReturn['trigger'];
22
+ setError: UseFormReturn['setError'];
52
23
  clearErrors: UseFormReturn['clearErrors'];
53
24
  watch: UseFormReturn['watch'];
54
25
  getFieldState: UseFormReturn['getFieldState'];
55
26
  setValue: UseFormReturn['setValue'];
56
27
  getValues: UseFormReturn['getValues'];
28
+ getValuesFromParentForm?: UseFormReturn['getValues'];
57
29
  unregister: UseFormReturn['unregister'];
58
30
  formState: UseFormReturn['formState'];
59
31
  reset: UseFormReturn['reset'];
32
+ resetField: UseFormReturn['resetField'];
60
33
  registerField: (field: FieldSpec) => void;
34
+ registerFieldFocus: registerFieldFocus;
61
35
  errors: UseFormReturn['formState']['errors'];
62
36
  componentRegistry?: FieldComponentRegistry;
37
+ submit: () => Promise<void> | void;
63
38
  }
64
39
  export interface FormBuilderProps {
65
40
  fields?: FieldSpec[];
@@ -75,6 +50,8 @@ export interface FormBuilderProps {
75
50
  validatorRegistry?: Record<string, ValidatorSchema[]>;
76
51
  componentRegistry?: FieldComponentRegistry;
77
52
  grid?: boolean;
53
+ controlledFieldsOnly?: boolean;
54
+ errors?: ErrorOption;
78
55
  }
79
56
  export interface FormBaseProps extends Omit<FormBuilderProps, 'fields' | 'fieldsets' | 'auto'> {
80
57
  fieldsetsMap?: Record<string, FieldsetSpec>;
package/types.js.map ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/types.tsx"],
4
+ "sourcesContent": ["import type { UseFormReturn, UseFormProps, ErrorOption } from 'react-hook-form';\nimport type {\n FieldLabelProps,\n FieldSpec,\n FormData,\n} from '@digigov/form/Field/types';\nimport type { FieldComponentRegistry } from '@digigov/form/inputs/registry';\nimport type { ValidatorSchema } from '@digigov/form/validators/types';\nexport * from '@digigov/form/Field/types';\nexport interface FieldError {\n message: string;\n}\n\nexport interface FieldsetSpec {\n key: string;\n fields: string[];\n label?: FieldLabelProps;\n body?: React.ReactNode;\n}\n\nexport type registerFieldFocus = (\n fieldName: string,\n element: HTMLElement\n) => (name: string) => void;\n\nexport interface FormContextProps {\n fieldsetsMap?: Record<string, FieldsetSpec>;\n fieldsMap: Record<string, FieldSpec>;\n control: UseFormReturn['control'];\n register: UseFormReturn['register'];\n trigger: UseFormReturn['trigger'];\n setError: UseFormReturn['setError'];\n clearErrors: UseFormReturn['clearErrors'];\n watch: UseFormReturn['watch'];\n getFieldState: UseFormReturn['getFieldState'];\n setValue: UseFormReturn['setValue'];\n getValues: UseFormReturn['getValues'];\n getValuesFromParentForm?: UseFormReturn['getValues'];\n unregister: UseFormReturn['unregister'];\n formState: UseFormReturn['formState'];\n reset: UseFormReturn['reset'];\n resetField: UseFormReturn['resetField'];\n registerField: (field: FieldSpec) => void;\n registerFieldFocus: registerFieldFocus;\n errors: UseFormReturn['formState']['errors'];\n componentRegistry?: FieldComponentRegistry;\n submit: () => Promise<void> | void;\n}\n\nexport interface FormBuilderProps {\n fields?: FieldSpec[];\n fieldsets?: FieldsetSpec[];\n initial?: FormData;\n onSubmit?: (data: FormData) => void | null | FieldError[];\n mode?: UseFormProps['mode'];\n reValidateMode?: UseFormProps['reValidateMode'];\n criteriaMode?: UseFormProps['criteriaMode'];\n children?: React.ReactNode;\n shouldFocusError?: boolean;\n auto?: boolean;\n validatorRegistry?: Record<string, ValidatorSchema[]>;\n componentRegistry?: FieldComponentRegistry;\n grid?: boolean;\n controlledFieldsOnly?: boolean;\n errors?: ErrorOption;\n}\n\nexport interface FormBaseProps\n extends Omit<FormBuilderProps, 'fields' | 'fieldsets' | 'auto'> {\n fieldsetsMap?: Record<string, FieldsetSpec>;\n fieldsMap: Record<string, FieldSpec>;\n registerField: (field: FieldSpec) => void;\n resolver: any;\n}\n"],
5
+ "mappings": "AAQA,cAAc;",
6
+ "names": []
7
+ }
package/utils/index.js CHANGED
@@ -1,80 +1,74 @@
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
- };
20
- }
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);
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
+ function isPlainObject(obj) {
27
+ return typeof obj === "object" && obj !== null && Object.prototype.toString.call(obj) === "[object Object]";
28
+ }
29
+ function flattenObject(obj, prefix = "") {
30
+ return Object.keys(obj).reduce((acc, key) => {
31
+ const prefixedKey = prefix ? `${prefix}.${key}` : key;
32
+ if (isPlainObject(obj[key])) {
33
+ Object.assign(acc, flattenObject(obj[key], prefixedKey));
34
+ } else {
35
+ acc[prefixedKey] = obj[key];
25
36
  }
26
- return previous;
37
+ return acc;
27
38
  }, {});
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);
39
+ }
40
+ const yupResolver = (schema, schemaOptions = {}, resolverOptions = {}) => async (values, context, options) => {
41
+ try {
42
+ if (schemaOptions.context && process.env.NODE_ENV === "development") {
43
+ console.warn(
44
+ "You should not used the yup options context. Please, use the 'useForm' context object instead"
45
+ );
46
+ }
47
+ const result = await schema[resolverOptions.mode === "sync" ? "validateSync" : "validate"](
48
+ flattenObject(values),
49
+ Object.assign({ abortEarly: false }, schemaOptions, { context })
50
+ );
51
+ if (options.shouldUseNativeValidation)
52
+ validateFieldsNatively({}, options);
53
+ return {
54
+ values: resolverOptions.rawValues ? values : result,
55
+ errors: {}
78
56
  };
79
- }();
80
- };
57
+ } catch (e) {
58
+ if (!e.inner) {
59
+ throw e;
60
+ }
61
+ return {
62
+ values: {},
63
+ errors: parseErrorSchema(
64
+ e,
65
+ !options.shouldUseNativeValidation && options.criteriaMode === "all"
66
+ ),
67
+ options
68
+ };
69
+ }
70
+ };
71
+ export {
72
+ yupResolver
73
+ };
74
+ //# sourceMappingURL=utils.js.map
package/utils.d.ts CHANGED
@@ -1,8 +1,10 @@
1
- import { FieldError } from 'react-hook-form';
1
+ import type { FieldError } from 'react-hook-form';
2
2
  export declare const yupResolver: (schema: any, schemaOptions?: any, resolverOptions?: any) => (values: any, context: any, options: any) => Promise<{
3
3
  values: any;
4
4
  errors: {};
5
+ options?: undefined;
5
6
  } | {
6
7
  values: {};
7
8
  errors: Record<string, FieldError>;
9
+ options: any;
8
10
  }>;
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 type { FieldError } from 'react-hook-form';\nimport { appendErrors } from 'react-hook-form';\nimport type * 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 // error.path = error.path?.replace(/\\[\"(.*?)\"\\]/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};\nfunction isPlainObject(obj) {\n return (\n typeof obj === 'object' &&\n obj !== null &&\n Object.prototype.toString.call(obj) === '[object Object]'\n );\n}\nfunction flattenObject(obj, prefix = '') {\n return Object.keys(obj).reduce((acc, key) => {\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n\n if (isPlainObject(obj[key])) {\n Object.assign(acc, flattenObject(obj[key], prefixedKey));\n } else {\n acc[prefixedKey] = obj[key];\n }\n\n return acc;\n }, {});\n}\n\nexport const yupResolver =\n (schema: any, schemaOptions: any = {}, resolverOptions: any = {}) =>\n async (values, context, options) => {\n try {\n if (schemaOptions.context && process.env.NODE_ENV === 'development') {\n console.warn(\n \"You should not used the yup options context. Please, use the 'useForm' context object instead\"\n );\n }\n\n const result = await schema[\n resolverOptions.mode === 'sync' ? 'validateSync' : 'validate'\n ](\n flattenObject(values),\n Object.assign({ abortEarly: false }, schemaOptions, { context })\n );\n\n if (options.shouldUseNativeValidation)\n validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.rawValues ? values : result,\n errors: {},\n };\n } catch (e) {\n if (!e.inner) {\n throw e;\n }\n\n return {\n values: {},\n errors: parseErrorSchema(\n e,\n !options.shouldUseNativeValidation && options.criteriaMode === 'all'\n ),\n options,\n };\n }\n };\n"],
5
+ "mappings": "AAAA,SAAS,8BAA8B;AAEvC,SAAS,oBAAoB;AAO7B,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;AAEvD,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;AACA,SAAS,cAAc,KAAK;AAC1B,SACE,OAAO,QAAQ,YACf,QAAQ,QACR,OAAO,UAAU,SAAS,KAAK,GAAG,MAAM;AAE5C;AACA,SAAS,cAAc,KAAK,SAAS,IAAI;AACvC,SAAO,OAAO,KAAK,GAAG,EAAE,OAAO,CAAC,KAAK,QAAQ;AAC3C,UAAM,cAAc,SAAS,GAAG,MAAM,IAAI,GAAG,KAAK;AAElD,QAAI,cAAc,IAAI,GAAG,CAAC,GAAG;AAC3B,aAAO,OAAO,KAAK,cAAc,IAAI,GAAG,GAAG,WAAW,CAAC;AAAA,IACzD,OAAO;AACL,UAAI,WAAW,IAAI,IAAI,GAAG;AAAA,IAC5B;AAEA,WAAO;AAAA,EACT,GAAG,CAAC,CAAC;AACP;AAEO,MAAM,cACX,CAAC,QAAa,gBAAqB,CAAC,GAAG,kBAAuB,CAAC,MAC/D,OAAO,QAAQ,SAAS,YAAY;AAClC,MAAI;AACF,QAAI,cAAc,WAAW,QAAQ,IAAI,aAAa,eAAe;AACnE,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAEA,UAAM,SAAS,MAAM,OACnB,gBAAgB,SAAS,SAAS,iBAAiB,UACrD;AAAA,MACE,cAAc,MAAM;AAAA,MACpB,OAAO,OAAO,EAAE,YAAY,MAAM,GAAG,eAAe,EAAE,QAAQ,CAAC;AAAA,IACjE;AAEA,QAAI,QAAQ;AACV,6BAAuB,CAAC,GAAG,OAAO;AAEpC,WAAO;AAAA,MACL,QAAQ,gBAAgB,YAAY,SAAS;AAAA,MAC7C,QAAQ,CAAC;AAAA,IACX;AAAA,EACF,SAAS,GAAG;AACV,QAAI,CAAC,EAAE,OAAO;AACZ,YAAM;AAAA,IACR;AAEA,WAAO;AAAA,MACL,QAAQ,CAAC;AAAA,MACT,QAAQ;AAAA,QACN;AAAA,QACA,CAAC,QAAQ,6BAA6B,QAAQ,iBAAiB;AAAA,MACjE;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": ["error"]
7
+ }