@digigov/form 1.2.0-dcbd7ded → 2.0.0-0c4be34e

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