@digigov/form 2.0.0-cbc56209 → 2.0.0-d4fe516b

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 (774) hide show
  1. package/Field/ErrorGroup/index.js +48 -0
  2. package/{Questions/index.spec → Field/ErrorGroup}/package.json +1 -1
  3. package/Field/ErrorGroup.d.ts +15 -0
  4. package/Field/ErrorGroup.js.map +7 -0
  5. package/Field/FieldBase/index.js +112 -76
  6. package/Field/FieldBase.js.map +7 -0
  7. package/Field/FieldBaseContainer/index.js +30 -37
  8. package/Field/FieldBaseContainer.js.map +7 -0
  9. package/Field/FieldConditional/index.js +79 -53
  10. package/Field/FieldConditional.js.map +7 -0
  11. package/Field/index.js +107 -63
  12. package/Field/index.js.map +7 -0
  13. package/Field/types/index.js +1 -1
  14. package/Field/types.d.ts +44 -5
  15. package/Field/types.js.map +7 -0
  16. package/Field/utils/calculateField/index.js +27 -0
  17. package/{FieldArray/FieldArray.stories → Field/utils/calculateField}/package.json +1 -1
  18. package/Field/utils/calculateField.d.ts +2 -0
  19. package/Field/utils/calculateField.js.map +7 -0
  20. package/Field/utils/evaluateFieldWithConditions/index.js +26 -0
  21. package/{inputs/DateInput/__stories__/Default → Field/utils/evaluateFieldWithConditions}/package.json +1 -1
  22. package/Field/utils/evaluateFieldWithConditions.d.ts +2 -0
  23. package/Field/utils/evaluateFieldWithConditions.js.map +7 -0
  24. package/Field/utils/index.d.ts +4 -0
  25. package/Field/utils/index.js +47 -116
  26. package/Field/utils/index.js.map +7 -0
  27. package/Field/utils/useField/index.js +57 -0
  28. package/{FormBuilder/FormBuilder → Field/utils/useField}/package.json +1 -1
  29. package/Field/utils/useField.d.ts +2 -0
  30. package/Field/utils/useField.js.map +7 -0
  31. package/FieldArray/FieldArray.stories.d.ts +2 -2
  32. package/FieldArray/FormDialog/index.js +280 -0
  33. package/{validators/validators.spec → FieldArray/FormDialog}/package.json +1 -1
  34. package/FieldArray/FormDialog.d.ts +53 -0
  35. package/FieldArray/FormDialog.js.map +7 -0
  36. package/FieldArray/__stories__/Default.d.ts +2 -2
  37. package/FieldArray/__stories__/WithExactLength.d.ts +2 -2
  38. package/FieldArray/index.d.ts +6 -0
  39. package/FieldArray/index.js +108 -59
  40. package/FieldArray/index.js.map +7 -0
  41. package/FieldArray/index.test.d.ts +1 -0
  42. package/FieldObject/index.d.ts +5 -0
  43. package/FieldObject/index.js +75 -52
  44. package/FieldObject/index.js.map +7 -0
  45. package/Fieldset/FieldsetWithContext/index.js +27 -31
  46. package/Fieldset/FieldsetWithContext.js.map +7 -0
  47. package/Fieldset/index.d.ts +1 -1
  48. package/Fieldset/index.js +27 -29
  49. package/Fieldset/index.js.map +7 -0
  50. package/Fieldset/types/index.js +1 -1
  51. package/Fieldset/types.d.ts +3 -2
  52. package/Fieldset/types.js.map +7 -0
  53. package/FormBuilder/FormBuilder.stories.d.ts +3 -1
  54. package/FormBuilder/__stories__/AutoErrorGrouping.d.ts +3 -0
  55. package/FormBuilder/__stories__/Default.d.ts +2 -2
  56. package/FormBuilder/__stories__/ErrorGrouping.d.ts +3 -0
  57. package/FormBuilder/index.d.ts +8 -1
  58. package/FormBuilder/index.js +237 -2
  59. package/FormBuilder/index.js.map +7 -0
  60. package/FormBuilder/index.test.d.ts +1 -0
  61. package/FormBuilder/interaction.test.d.ts +1 -0
  62. package/FormBuilder/scenarios.test.d.ts +88 -0
  63. package/FormContext/index.js +7 -3
  64. package/FormContext.js.map +7 -0
  65. package/MultiplicityField/MultiplicityField.stories.d.ts +6 -6
  66. package/MultiplicityField/__stories__/Default.d.ts +2 -2
  67. package/MultiplicityField/__stories__/PreviewDisplay.d.ts +2 -2
  68. package/MultiplicityField/__stories__/WithExactLength.d.ts +2 -2
  69. package/MultiplicityField/__stories__/WithMaxLength.d.ts +2 -2
  70. package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +2 -2
  71. package/MultiplicityField/__stories__/WithMinLength.d.ts +2 -2
  72. package/MultiplicityField/add-objects/index.js +137 -132
  73. package/MultiplicityField/add-objects.d.ts +2 -1
  74. package/MultiplicityField/add-objects.js.map +7 -0
  75. package/MultiplicityField/index.d.ts +2 -19
  76. package/MultiplicityField/index.js +114 -106
  77. package/MultiplicityField/index.js.map +7 -0
  78. package/MultiplicityField/index.test.d.ts +1 -0
  79. package/MultiplicityField/types/index.js +1 -0
  80. package/MultiplicityField/types/package.json +6 -0
  81. package/MultiplicityField/types.d.ts +18 -0
  82. package/MultiplicityField/types.js.map +7 -0
  83. package/Questions/Questions/index.js +48 -56
  84. package/Questions/Questions.js.map +7 -0
  85. package/Questions/Questions.stories.d.ts +1 -1
  86. package/Questions/QuestionsContext/index.js +9 -9
  87. package/Questions/QuestionsContext.d.ts +0 -1
  88. package/Questions/QuestionsContext.js.map +7 -0
  89. package/Questions/Step/ReviewStep/index.js +35 -47
  90. package/Questions/Step/ReviewStep.js.map +7 -0
  91. package/Questions/Step/Step/index.js +39 -47
  92. package/Questions/Step/Step.js.map +7 -0
  93. package/Questions/Step/StepArrayReview/index.js +41 -45
  94. package/Questions/Step/StepArrayReview.js.map +7 -0
  95. package/Questions/Step/StepContext/index.js +15 -19
  96. package/Questions/Step/StepContext.d.ts +0 -1
  97. package/Questions/Step/StepContext.js.map +7 -0
  98. package/Questions/Step/StepDescription/index.js +22 -22
  99. package/Questions/Step/StepDescription.js.map +7 -0
  100. package/Questions/Step/StepForm/index.js +33 -43
  101. package/Questions/Step/StepForm.js.map +7 -0
  102. package/Questions/Step/StepQuote/index.js +10 -9
  103. package/Questions/Step/StepQuote.js.map +7 -0
  104. package/Questions/Step/StepTitle/index.js +41 -38
  105. package/Questions/Step/StepTitle.d.ts +2 -1
  106. package/Questions/Step/StepTitle.js.map +7 -0
  107. package/Questions/Step/getAddMoreFields/index.js +28 -20
  108. package/Questions/Step/getAddMoreFields.js.map +7 -0
  109. package/Questions/Step/index.d.ts +0 -1
  110. package/Questions/Step/index.js +16 -13
  111. package/Questions/Step/index.js.map +7 -0
  112. package/Questions/Step/types/index.js +1 -1
  113. package/Questions/Step/types.d.ts +1 -0
  114. package/Questions/Step/types.js.map +7 -0
  115. package/Questions/__stories__/Default.d.ts +2 -2
  116. package/Questions/getNextStep/index.js +12 -10
  117. package/Questions/getNextStep.js.map +7 -0
  118. package/Questions/index.js +7 -3
  119. package/Questions/index.js.map +7 -0
  120. package/Questions/index.test.d.ts +1 -0
  121. package/Questions/types/index.js +1 -1
  122. package/Questions/types.d.ts +1 -0
  123. package/Questions/types.js.map +7 -0
  124. package/cjs/Field/ErrorGroup/index.js +82 -0
  125. package/cjs/Field/ErrorGroup.js.map +7 -0
  126. package/cjs/Field/FieldBase/index.js +144 -82
  127. package/cjs/Field/FieldBase.js.map +7 -0
  128. package/cjs/Field/FieldBaseContainer/index.js +62 -43
  129. package/cjs/Field/FieldBaseContainer.js.map +7 -0
  130. package/cjs/Field/FieldConditional/index.js +111 -59
  131. package/cjs/Field/FieldConditional.js.map +7 -0
  132. package/cjs/Field/index.js +136 -72
  133. package/cjs/Field/index.js.map +7 -0
  134. package/cjs/Field/types/index.js +16 -5
  135. package/cjs/Field/types.js.map +7 -0
  136. package/cjs/Field/utils/calculateField/index.js +50 -0
  137. package/cjs/Field/utils/calculateField.js.map +7 -0
  138. package/cjs/Field/utils/evaluateFieldWithConditions/index.js +49 -0
  139. package/cjs/Field/utils/evaluateFieldWithConditions.js.map +7 -0
  140. package/cjs/Field/utils/index.js +91 -139
  141. package/cjs/Field/utils/index.js.map +7 -0
  142. package/cjs/Field/utils/useField/index.js +80 -0
  143. package/cjs/Field/utils/useField.js.map +7 -0
  144. package/cjs/FieldArray/FormDialog/index.js +302 -0
  145. package/cjs/FieldArray/FormDialog.js.map +7 -0
  146. package/cjs/FieldArray/index.js +140 -65
  147. package/cjs/FieldArray/index.js.map +7 -0
  148. package/cjs/FieldObject/index.js +104 -61
  149. package/cjs/FieldObject/index.js.map +7 -0
  150. package/cjs/Fieldset/FieldsetWithContext/index.js +54 -40
  151. package/cjs/Fieldset/FieldsetWithContext.js.map +7 -0
  152. package/cjs/Fieldset/index.js +61 -39
  153. package/cjs/Fieldset/index.js.map +7 -0
  154. package/cjs/Fieldset/types/index.js +16 -5
  155. package/cjs/Fieldset/types.js.map +7 -0
  156. package/cjs/FormBuilder/index.js +273 -8
  157. package/cjs/FormBuilder/index.js.map +7 -0
  158. package/cjs/FormContext/index.js +29 -8
  159. package/cjs/FormContext.js.map +7 -0
  160. package/cjs/MultiplicityField/add-objects/index.js +164 -138
  161. package/cjs/MultiplicityField/add-objects.js.map +7 -0
  162. package/cjs/MultiplicityField/index.js +142 -115
  163. package/cjs/MultiplicityField/index.js.map +7 -0
  164. package/cjs/MultiplicityField/types/index.js +16 -0
  165. package/cjs/MultiplicityField/types.js.map +7 -0
  166. package/cjs/Questions/Questions/index.js +80 -65
  167. package/cjs/Questions/Questions.js.map +7 -0
  168. package/cjs/Questions/QuestionsContext/index.js +31 -14
  169. package/cjs/Questions/QuestionsContext.js.map +7 -0
  170. package/cjs/Questions/Step/ReviewStep/index.js +61 -56
  171. package/cjs/Questions/Step/ReviewStep.js.map +7 -0
  172. package/cjs/Questions/Step/Step/index.js +71 -56
  173. package/cjs/Questions/Step/Step.js.map +7 -0
  174. package/cjs/Questions/Step/StepArrayReview/index.js +65 -54
  175. package/cjs/Questions/Step/StepArrayReview.js.map +7 -0
  176. package/cjs/Questions/Step/StepContext/index.js +37 -24
  177. package/cjs/Questions/Step/StepContext.js.map +7 -0
  178. package/cjs/Questions/Step/StepDescription/index.js +55 -31
  179. package/cjs/Questions/Step/StepDescription.js.map +7 -0
  180. package/cjs/Questions/Step/StepForm/index.js +65 -52
  181. package/cjs/Questions/Step/StepForm.js.map +7 -0
  182. package/cjs/Questions/Step/StepQuote/index.js +42 -15
  183. package/cjs/Questions/Step/StepQuote.js.map +7 -0
  184. package/cjs/Questions/Step/StepTitle/index.js +72 -47
  185. package/cjs/Questions/Step/StepTitle.js.map +7 -0
  186. package/cjs/Questions/Step/getAddMoreFields/index.js +50 -25
  187. package/cjs/Questions/Step/getAddMoreFields.js.map +7 -0
  188. package/cjs/Questions/Step/index.js +59 -143
  189. package/cjs/Questions/Step/index.js.map +7 -0
  190. package/cjs/Questions/Step/types/index.js +16 -5
  191. package/cjs/Questions/Step/types.js.map +7 -0
  192. package/cjs/Questions/getNextStep/index.js +33 -14
  193. package/cjs/Questions/getNextStep.js.map +7 -0
  194. package/cjs/Questions/index.js +29 -19
  195. package/cjs/Questions/index.js.map +7 -0
  196. package/cjs/Questions/types/index.js +16 -5
  197. package/cjs/Questions/types.js.map +7 -0
  198. package/cjs/index.js +47 -20
  199. package/cjs/index.js.map +7 -0
  200. package/cjs/inputs/AutoCompleteInput/index.js +92 -46
  201. package/cjs/inputs/AutoCompleteInput/index.js.map +7 -0
  202. package/cjs/inputs/Checkboxes/index.js +101 -96
  203. package/cjs/inputs/Checkboxes/index.js.map +7 -0
  204. package/cjs/inputs/DateInput/index.js +121 -109
  205. package/cjs/inputs/DateInput/index.js.map +7 -0
  206. package/cjs/inputs/DateTimeInput/index.js +206 -0
  207. package/cjs/inputs/DateTimeInput/index.js.map +7 -0
  208. package/cjs/inputs/FileInput/index.js +75 -63
  209. package/cjs/inputs/FileInput/index.js.map +7 -0
  210. package/cjs/inputs/ImageInput/index.js +95 -83
  211. package/cjs/inputs/ImageInput/index.js.map +7 -0
  212. package/cjs/inputs/Input/index.js +105 -71
  213. package/cjs/inputs/Input/index.js.map +7 -0
  214. package/cjs/inputs/Input/inputsInputScenarios/index.js +439 -0
  215. package/cjs/inputs/Input/inputsInputScenarios.js.map +7 -0
  216. package/cjs/inputs/Label/index.js +45 -24
  217. package/cjs/inputs/Label/index.js.map +7 -0
  218. package/cjs/inputs/OtpInput/index.js +142 -112
  219. package/cjs/inputs/OtpInput/index.js.map +7 -0
  220. package/cjs/inputs/Radio/index.js +131 -61
  221. package/cjs/inputs/Radio/index.js.map +7 -0
  222. package/cjs/inputs/Select/index.js +59 -36
  223. package/cjs/inputs/Select/index.js.map +7 -0
  224. package/cjs/inputs/index.js +62 -69
  225. package/cjs/inputs/index.js.map +7 -0
  226. package/cjs/inputs/inputsScenarios/index.js +533 -0
  227. package/cjs/inputs/inputsScenarios.js.map +7 -0
  228. package/cjs/internal/index.js +36 -346
  229. package/cjs/internal.js.map +7 -0
  230. package/cjs/lazy/index.js +109 -516
  231. package/cjs/lazy.js.map +7 -0
  232. package/cjs/locales/el/index.js +35 -0
  233. package/cjs/locales/el.js.map +7 -0
  234. package/cjs/registry/index.js +190 -142
  235. package/cjs/registry.js.map +7 -0
  236. package/cjs/types/index.js +22 -5
  237. package/cjs/types.js.map +7 -0
  238. package/cjs/utils/index.js +79 -83
  239. package/cjs/utils.js.map +7 -0
  240. package/cjs/validators/index.js +131 -164
  241. package/cjs/validators/index.js.map +7 -0
  242. package/cjs/validators/types/index.js +16 -5
  243. package/cjs/validators/types.js.map +7 -0
  244. package/cjs/validators/utils/afm/index.js +38 -21
  245. package/cjs/validators/utils/afm.js.map +7 -0
  246. package/cjs/validators/utils/date/index.js +138 -0
  247. package/cjs/validators/utils/date.js.map +7 -0
  248. package/cjs/validators/utils/datetime/index.js +151 -0
  249. package/cjs/validators/utils/datetime.js.map +7 -0
  250. package/cjs/validators/utils/file/index.js +44 -47
  251. package/cjs/validators/utils/file.js.map +7 -0
  252. package/cjs/validators/utils/iban/index.js +36 -17
  253. package/cjs/validators/utils/iban.js.map +7 -0
  254. package/cjs/validators/utils/image/index.js +88 -112
  255. package/cjs/validators/utils/image.js.map +7 -0
  256. package/cjs/validators/utils/index.js +99 -159
  257. package/cjs/validators/utils/index.js.map +7 -0
  258. package/cjs/validators/utils/int/index.js +35 -13
  259. package/cjs/validators/utils/int.js.map +7 -0
  260. package/cjs/validators/utils/number/index.js +34 -12
  261. package/cjs/validators/utils/number.js.map +7 -0
  262. package/cjs/validators/utils/otp/index.js +35 -13
  263. package/cjs/validators/utils/otp.js.map +7 -0
  264. package/cjs/validators/utils/phone/index.js +113 -58
  265. package/cjs/validators/utils/phone.js.map +7 -0
  266. package/cjs/validators/utils/postal_code/index.js +36 -16
  267. package/cjs/validators/utils/postal_code.js.map +7 -0
  268. package/cjs/validators/utils/text_limit/index.js +40 -25
  269. package/cjs/validators/utils/text_limit.js.map +7 -0
  270. package/cjs/validators/utils/uuid4/index.js +34 -13
  271. package/cjs/validators/utils/uuid4.js.map +7 -0
  272. package/index.d.ts +4 -1
  273. package/index.js +13 -4
  274. package/index.js.map +7 -0
  275. package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +2 -1
  276. package/inputs/AutoCompleteInput/__stories__/Default.d.ts +3 -2
  277. package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +3 -0
  278. package/inputs/AutoCompleteInput/index.d.ts +2 -2
  279. package/inputs/AutoCompleteInput/index.js +62 -37
  280. package/inputs/AutoCompleteInput/index.js.map +7 -0
  281. package/inputs/AutoCompleteInput/index.test.d.ts +1 -0
  282. package/inputs/Checkboxes/Checkboxes.stories.d.ts +3 -3
  283. package/inputs/Checkboxes/__stories__/Conditional.d.ts +3 -2
  284. package/inputs/Checkboxes/__stories__/Default.d.ts +2 -2
  285. package/inputs/Checkboxes/__stories__/WithDivider.d.ts +2 -2
  286. package/inputs/Checkboxes/index.d.ts +2 -1
  287. package/inputs/Checkboxes/index.js +73 -87
  288. package/inputs/Checkboxes/index.js.map +7 -0
  289. package/inputs/Checkboxes/index.test.d.ts +1 -0
  290. package/inputs/DateInput/DateInput.stories.d.ts +1 -1
  291. package/inputs/DateInput/__stories__/Default.d.ts +2 -2
  292. package/inputs/DateInput/index.d.ts +3 -4
  293. package/inputs/DateInput/index.js +91 -99
  294. package/inputs/DateInput/index.js.map +7 -0
  295. package/inputs/DateInput/index.test.d.ts +1 -0
  296. package/inputs/DateTimeInput/DateTimeInput.stories.d.ts +7 -0
  297. package/inputs/DateTimeInput/__stories__/Default.d.ts +3 -0
  298. package/inputs/DateTimeInput/index.d.ts +13 -0
  299. package/inputs/DateTimeInput/index.js +176 -0
  300. package/inputs/DateTimeInput/index.js.map +7 -0
  301. package/inputs/DateTimeInput/index.test.d.ts +1 -0
  302. package/inputs/DateTimeInput/package.json +6 -0
  303. package/inputs/FileInput/FileInput.stories.d.ts +1 -1
  304. package/inputs/FileInput/__stories__/Default.d.ts +2 -2
  305. package/inputs/FileInput/index.js +43 -54
  306. package/inputs/FileInput/index.js.map +7 -0
  307. package/inputs/FileInput/index.test.d.ts +1 -0
  308. package/inputs/ImageInput/ImageInput.stories.d.ts +3 -3
  309. package/inputs/ImageInput/__stories__/Default.d.ts +2 -2
  310. package/inputs/ImageInput/__stories__/MaxSize.d.ts +3 -0
  311. package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +2 -2
  312. package/inputs/ImageInput/__stories__/WithInvalidImageSize.d.ts +2 -2
  313. package/inputs/ImageInput/index.js +63 -75
  314. package/inputs/ImageInput/index.js.map +7 -0
  315. package/inputs/ImageInput/index.test.d.ts +1 -0
  316. package/inputs/Input/Input.stories.d.ts +11 -10
  317. package/inputs/Input/__stories__/AFM.d.ts +2 -2
  318. package/inputs/Input/__stories__/Boolean.d.ts +2 -2
  319. package/inputs/Input/__stories__/IBAN.d.ts +2 -2
  320. package/inputs/Input/__stories__/Integer.d.ts +2 -2
  321. package/inputs/Input/__stories__/LandlineNumber.d.ts +2 -2
  322. package/inputs/Input/__stories__/MobilePhone.d.ts +2 -2
  323. package/inputs/Input/__stories__/PhoneNumber.d.ts +2 -2
  324. package/inputs/Input/__stories__/PostalCode.d.ts +2 -2
  325. package/inputs/Input/__stories__/String.d.ts +3 -0
  326. package/inputs/Input/__stories__/StringWithTrimValidation.d.ts +3 -0
  327. package/inputs/Input/__stories__/TextWithLimit.d.ts +3 -0
  328. package/inputs/Input/index.js +74 -66
  329. package/inputs/Input/index.js.map +7 -0
  330. package/inputs/Input/index.test.d.ts +1 -0
  331. package/inputs/Input/inputsInputScenarios/index.js +406 -0
  332. package/{FieldArray/__stories__/Default → inputs/Input/inputsInputScenarios}/package.json +1 -1
  333. package/inputs/Input/inputsInputScenarios.d.ts +57 -0
  334. package/inputs/Input/inputsInputScenarios.js.map +7 -0
  335. package/inputs/Label/Label.stories.d.ts +1 -1
  336. package/inputs/Label/__stories__/Default.d.ts +2 -2
  337. package/inputs/Label/index.d.ts +1 -3
  338. package/inputs/Label/index.js +12 -17
  339. package/inputs/Label/index.js.map +7 -0
  340. package/inputs/Label/index.test.d.ts +1 -0
  341. package/inputs/OtpInput/OtpInput.stories.d.ts +1 -1
  342. package/inputs/OtpInput/__stories__/Default.d.ts +2 -2
  343. package/inputs/OtpInput/index.d.ts +9 -2
  344. package/inputs/OtpInput/index.js +109 -103
  345. package/inputs/OtpInput/index.js.map +7 -0
  346. package/inputs/OtpInput/index.test.d.ts +1 -0
  347. package/inputs/Radio/Radio.stories.d.ts +3 -3
  348. package/inputs/Radio/__stories__/Conditional.d.ts +3 -2
  349. package/inputs/Radio/__stories__/Default.d.ts +2 -2
  350. package/inputs/Radio/__stories__/WithDivider.d.ts +2 -2
  351. package/inputs/Radio/index.d.ts +6 -1
  352. package/inputs/Radio/index.js +102 -55
  353. package/inputs/Radio/index.js.map +7 -0
  354. package/inputs/Radio/index.test.d.ts +1 -0
  355. package/inputs/Select/Select.stories.d.ts +1 -1
  356. package/inputs/Select/__stories__/Default.d.ts +2 -2
  357. package/inputs/Select/index.d.ts +1 -1
  358. package/inputs/Select/index.js +31 -31
  359. package/inputs/Select/index.js.map +7 -0
  360. package/inputs/Select/index.test.d.ts +1 -0
  361. package/inputs/index.js +21 -9
  362. package/inputs/index.js.map +7 -0
  363. package/inputs/inputsScenarios/index.js +499 -0
  364. package/inputs/inputsScenarios/package.json +6 -0
  365. package/inputs/inputsScenarios.d.ts +296 -0
  366. package/inputs/inputsScenarios.js.map +7 -0
  367. package/internal/index.js +10 -34
  368. package/internal.d.ts +2 -31
  369. package/internal.js.map +7 -0
  370. package/lazy/index.js +75 -393
  371. package/locales/el/index.js +6 -0
  372. package/{Form.stories → locales/el}/package.json +1 -1
  373. package/locales/el.d.ts +2 -0
  374. package/locales/el.js.map +7 -0
  375. package/package.json +7 -8
  376. package/registry/index.js +125 -98
  377. package/src/Field/ErrorGroup.tsx +84 -0
  378. package/src/Field/FieldBase.tsx +36 -22
  379. package/src/Field/FieldBaseContainer.tsx +7 -4
  380. package/src/Field/FieldConditional.tsx +5 -1
  381. package/src/Field/index.tsx +27 -3
  382. package/src/Field/types.tsx +73 -5
  383. package/src/Field/utils/calculateField.ts +49 -0
  384. package/src/Field/utils/evaluateFieldWithConditions.ts +30 -0
  385. package/src/Field/utils/index.ts +82 -0
  386. package/src/Field/utils/useField.ts +58 -0
  387. package/src/FieldArray/FieldArray.stories.js +2 -2
  388. package/src/FieldArray/FormDialog.tsx +379 -0
  389. package/src/FieldArray/__stories__/Default.tsx +1 -0
  390. package/src/FieldArray/__stories__/WithExactLength.tsx +77 -13
  391. package/src/FieldArray/index.test.tsx +24 -0
  392. package/src/FieldArray/index.tsx +92 -39
  393. package/src/FieldObject/index.tsx +28 -8
  394. package/src/Fieldset/index.tsx +5 -5
  395. package/src/Fieldset/types.tsx +5 -3
  396. package/src/FormBuilder/FormBuilder.stories.js +3 -1
  397. package/src/FormBuilder/__stories__/AutoErrorGrouping.tsx +63 -0
  398. package/src/FormBuilder/__stories__/ErrorGrouping.tsx +43 -0
  399. package/{FormBuilder/FormBuilder.mdx → src/FormBuilder/doc.mdx} +20 -33
  400. package/src/FormBuilder/index.test.tsx +29 -0
  401. package/src/FormBuilder/index.tsx +263 -1
  402. package/src/FormBuilder/interaction.test.tsx +32 -0
  403. package/src/FormBuilder/scenarios.test.tsx +1971 -0
  404. package/src/FormContext.tsx +1 -2
  405. package/src/MultiplicityField/MultiplicityField.stories.js +6 -6
  406. package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +2 -2
  407. package/src/MultiplicityField/__stories__/WithExactLength.tsx +1 -1
  408. package/src/MultiplicityField/__stories__/WithMaxLength.tsx +1 -1
  409. package/src/MultiplicityField/__stories__/WithMinAndMaxLength.tsx +1 -1
  410. package/src/MultiplicityField/__stories__/WithMinLength.tsx +1 -1
  411. package/src/MultiplicityField/add-objects.tsx +31 -15
  412. package/{MultiplicityField/MultiplicityField.mdx → src/MultiplicityField/doc.mdx} +12 -16
  413. package/src/MultiplicityField/index.test.tsx +40 -0
  414. package/src/MultiplicityField/index.tsx +22 -35
  415. package/src/MultiplicityField/types.ts +21 -0
  416. package/src/Questions/Questions.stories.js +1 -1
  417. package/src/Questions/Questions.tsx +4 -4
  418. package/src/Questions/Step/StepArrayReview.tsx +1 -1
  419. package/src/Questions/Step/StepTitle.tsx +5 -3
  420. package/src/Questions/Step/index.ts +0 -1
  421. package/src/Questions/Step/types.tsx +1 -0
  422. package/src/Questions/__snapshots__/index.spec.tsx.snap +73 -587
  423. package/src/Questions/{index.mdx → doc.mdx} +13 -16
  424. package/src/Questions/index.spec.tsx +17 -5
  425. package/src/Questions/index.test.tsx +20 -0
  426. package/src/Questions/types.tsx +1 -0
  427. package/src/create-simple-form.mdx +2 -6
  428. package/{index.mdx → src/doc.mdx} +4 -8
  429. package/src/index.ts +4 -1
  430. package/src/inputs/AutoCompleteInput/AutoComplete.stories.js +2 -1
  431. package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +19 -18
  432. package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +47 -0
  433. package/src/inputs/AutoCompleteInput/doc.mdx +18 -0
  434. package/src/inputs/AutoCompleteInput/index.test.tsx +24 -0
  435. package/src/inputs/AutoCompleteInput/index.tsx +46 -29
  436. package/src/inputs/Checkboxes/Checkboxes.stories.js +3 -3
  437. package/src/inputs/Checkboxes/__stories__/Conditional.tsx +2 -3
  438. package/src/inputs/Checkboxes/doc.mdx +23 -0
  439. package/src/inputs/Checkboxes/index.test.tsx +28 -0
  440. package/src/inputs/Checkboxes/index.tsx +39 -33
  441. package/src/inputs/DateInput/DateInput.stories.js +1 -1
  442. package/src/inputs/DateInput/__stories__/Default.tsx +16 -15
  443. package/src/inputs/DateInput/doc.mdx +16 -0
  444. package/src/inputs/DateInput/index.test.tsx +20 -0
  445. package/src/inputs/DateInput/index.tsx +11 -9
  446. package/src/inputs/DateTimeInput/DateTimeInput.stories.js +8 -0
  447. package/src/inputs/DateTimeInput/__stories__/Default.tsx +25 -0
  448. package/src/inputs/DateTimeInput/doc.mdx +16 -0
  449. package/src/inputs/DateTimeInput/index.test.tsx +18 -0
  450. package/src/inputs/DateTimeInput/index.tsx +189 -0
  451. package/src/inputs/FileInput/FileInput.stories.js +1 -1
  452. package/src/inputs/FileInput/doc.mdx +15 -0
  453. package/src/inputs/FileInput/index.test.tsx +20 -0
  454. package/src/inputs/FileInput/index.tsx +8 -9
  455. package/src/inputs/ImageInput/ImageInput.stories.js +3 -3
  456. package/src/inputs/ImageInput/__stories__/MaxSize.tsx +37 -0
  457. package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +2 -0
  458. package/src/inputs/ImageInput/doc.mdx +23 -0
  459. package/src/inputs/ImageInput/index.test.tsx +32 -0
  460. package/src/inputs/ImageInput/index.tsx +16 -16
  461. package/src/inputs/Input/Input.stories.js +11 -10
  462. package/src/inputs/Input/__stories__/LandlineNumber.tsx +2 -1
  463. package/src/inputs/Input/__stories__/MobilePhone.tsx +1 -0
  464. package/src/inputs/Input/__stories__/PhoneNumber.tsx +1 -0
  465. package/src/inputs/Input/__stories__/PostalCode.tsx +1 -0
  466. package/src/inputs/Input/__stories__/{Default.tsx → String.tsx} +2 -2
  467. package/src/inputs/Input/__stories__/StringWithTrimValidation.tsx +26 -0
  468. package/src/inputs/Input/__stories__/{TextWithCharacterLimit.tsx → TextWithLimit.tsx} +3 -2
  469. package/src/inputs/Input/doc.mdx +56 -0
  470. package/src/inputs/Input/index.test.tsx +60 -0
  471. package/src/inputs/Input/index.tsx +40 -30
  472. package/src/inputs/Input/inputsInputScenarios.ts +404 -0
  473. package/src/inputs/Label/Label.stories.js +1 -1
  474. package/src/inputs/Label/__stories__/Default.tsx +3 -1
  475. package/src/inputs/Label/doc.mdx +14 -0
  476. package/src/inputs/Label/index.test.tsx +20 -0
  477. package/src/inputs/Label/index.tsx +3 -10
  478. package/src/inputs/OtpInput/OtpInput.stories.js +1 -1
  479. package/src/inputs/OtpInput/doc.mdx +16 -0
  480. package/src/inputs/OtpInput/index.test.tsx +20 -0
  481. package/src/inputs/OtpInput/index.tsx +4 -3
  482. package/src/inputs/Radio/Radio.stories.js +3 -3
  483. package/src/inputs/Radio/__stories__/Conditional.tsx +4 -1
  484. package/src/inputs/Radio/doc.mdx +23 -0
  485. package/src/inputs/Radio/index.test.tsx +28 -0
  486. package/src/inputs/Radio/index.tsx +79 -9
  487. package/src/inputs/Select/Select.stories.js +1 -1
  488. package/src/inputs/Select/doc.mdx +13 -0
  489. package/src/inputs/Select/index.test.tsx +20 -0
  490. package/src/inputs/Select/index.tsx +11 -4
  491. package/src/inputs/inputsScenarios.ts +496 -0
  492. package/src/installation.mdx +2 -5
  493. package/src/internal.ts +2 -31
  494. package/src/lazy.js +76 -59
  495. package/src/locales/el.ts +3 -0
  496. package/src/registry.js +108 -88
  497. package/src/types.tsx +11 -64
  498. package/src/utils.ts +34 -33
  499. package/src/validators/index.ts +90 -84
  500. package/src/validators/utils/date.ts +107 -0
  501. package/src/validators/utils/datetime.ts +130 -0
  502. package/src/validators/utils/file.ts +11 -9
  503. package/src/validators/utils/index.ts +2 -0
  504. package/src/validators/utils/int.ts +1 -1
  505. package/src/validators/utils/number.ts +1 -1
  506. package/src/validators/utils/phone.ts +63 -72
  507. package/src/validators/utils/postal_code.ts +1 -1
  508. package/src/validators/utils/uuid4.ts +2 -1
  509. package/src/validators/validators.spec.ts +6 -40
  510. package/types/index.js +2 -1
  511. package/types.d.ts +6 -35
  512. package/types.js.map +7 -0
  513. package/utils/index.js +57 -77
  514. package/utils.js.map +7 -0
  515. package/validators/index.js +112 -150
  516. package/validators/index.js.map +7 -0
  517. package/validators/types/index.js +1 -1
  518. package/validators/types.js.map +7 -0
  519. package/validators/utils/afm/index.js +16 -16
  520. package/validators/utils/afm.js.map +7 -0
  521. package/validators/utils/date/index.js +103 -0
  522. package/validators/utils/date/package.json +6 -0
  523. package/validators/utils/date.d.ts +9 -0
  524. package/validators/utils/date.js.map +7 -0
  525. package/validators/utils/datetime/index.js +116 -0
  526. package/{Questions/Questions.stories → validators/utils/datetime}/package.json +1 -1
  527. package/validators/utils/datetime.d.ts +9 -0
  528. package/validators/utils/datetime.js.map +7 -0
  529. package/validators/utils/file/index.js +22 -42
  530. package/validators/utils/file.js.map +7 -0
  531. package/validators/utils/iban/index.js +14 -12
  532. package/validators/utils/iban.js.map +7 -0
  533. package/validators/utils/image/index.js +66 -106
  534. package/validators/utils/image.js.map +7 -0
  535. package/validators/utils/index.d.ts +2 -0
  536. package/validators/utils/index.js +56 -48
  537. package/validators/utils/index.js.map +7 -0
  538. package/validators/utils/int/index.js +13 -8
  539. package/validators/utils/int.js.map +7 -0
  540. package/validators/utils/number/index.js +12 -7
  541. package/validators/utils/number.js.map +7 -0
  542. package/validators/utils/otp/index.js +13 -8
  543. package/validators/utils/otp.js.map +7 -0
  544. package/validators/utils/phone/index.js +89 -51
  545. package/validators/utils/phone.d.ts +1 -1
  546. package/validators/utils/phone.js.map +7 -0
  547. package/validators/utils/postal_code/index.js +14 -11
  548. package/validators/utils/postal_code.d.ts +1 -1
  549. package/validators/utils/postal_code.js.map +7 -0
  550. package/validators/utils/text_limit/index.js +18 -20
  551. package/validators/utils/text_limit.js.map +7 -0
  552. package/validators/utils/uuid4/index.js +12 -8
  553. package/validators/utils/uuid4.js.map +7 -0
  554. package/Field/utils.d.ts +0 -5
  555. package/FieldArray/FieldArray.stories/index.js +0 -8
  556. package/FieldArray/FieldArray.stories.playwright.json +0 -353
  557. package/FieldArray/__stories__/Default/index.js +0 -88
  558. package/FieldArray/__stories__/WithExactLength/index.js +0 -88
  559. package/FieldArray/__stories__/WithExactLength/package.json +0 -6
  560. package/Form.stories/index.js +0 -3
  561. package/FormBuilder/FormBuilder/index.js +0 -152
  562. package/FormBuilder/FormBuilder.d.ts +0 -5
  563. package/FormBuilder/FormBuilder.stories/index.js +0 -7
  564. package/FormBuilder/FormBuilder.stories/package.json +0 -6
  565. package/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  566. package/FormBuilder/__stories__/Default/index.js +0 -26
  567. package/FormBuilder/__stories__/Default/package.json +0 -6
  568. package/MultiplicityField/MultiplicityField.stories/index.js +0 -12
  569. package/MultiplicityField/MultiplicityField.stories/package.json +0 -6
  570. package/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  571. package/MultiplicityField/__stories__/Default/index.js +0 -95
  572. package/MultiplicityField/__stories__/Default/package.json +0 -6
  573. package/MultiplicityField/__stories__/PreviewDisplay/index.js +0 -72
  574. package/MultiplicityField/__stories__/PreviewDisplay/package.json +0 -6
  575. package/MultiplicityField/__stories__/WithExactLength/index.js +0 -90
  576. package/MultiplicityField/__stories__/WithExactLength/package.json +0 -6
  577. package/MultiplicityField/__stories__/WithMaxLength/index.js +0 -93
  578. package/MultiplicityField/__stories__/WithMaxLength/package.json +0 -6
  579. package/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +0 -94
  580. package/MultiplicityField/__stories__/WithMinAndMaxLength/package.json +0 -6
  581. package/MultiplicityField/__stories__/WithMinLength/index.js +0 -93
  582. package/MultiplicityField/__stories__/WithMinLength/package.json +0 -6
  583. package/Questions/Questions.stories/index.js +0 -7
  584. package/Questions/__snapshots__/index.spec.tsx.snap +0 -596
  585. package/Questions/__stories__/Default/index.js +0 -102
  586. package/Questions/__stories__/Default/package.json +0 -6
  587. package/Questions/index.mdx +0 -415
  588. package/Questions/index.spec/index.js +0 -59
  589. package/cjs/Field/index.mdx +0 -6
  590. package/cjs/FieldArray/FieldArray.stories/index.js +0 -38
  591. package/cjs/FieldArray/FieldArray.stories.playwright.json +0 -353
  592. package/cjs/FieldArray/__stories__/Default/index.js +0 -98
  593. package/cjs/FieldArray/__stories__/WithExactLength/index.js +0 -98
  594. package/cjs/Form.stories/index.js +0 -9
  595. package/cjs/FormBuilder/FormBuilder/index.js +0 -162
  596. package/cjs/FormBuilder/FormBuilder.mdx +0 -256
  597. package/cjs/FormBuilder/FormBuilder.stories/index.js +0 -26
  598. package/cjs/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  599. package/cjs/FormBuilder/__stories__/Default/index.js +0 -36
  600. package/cjs/MultiplicityField/MultiplicityField.mdx +0 -590
  601. package/cjs/MultiplicityField/MultiplicityField.stories/index.js +0 -86
  602. package/cjs/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  603. package/cjs/MultiplicityField/__stories__/Default/index.js +0 -105
  604. package/cjs/MultiplicityField/__stories__/PreviewDisplay/index.js +0 -82
  605. package/cjs/MultiplicityField/__stories__/WithExactLength/index.js +0 -100
  606. package/cjs/MultiplicityField/__stories__/WithMaxLength/index.js +0 -103
  607. package/cjs/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +0 -104
  608. package/cjs/MultiplicityField/__stories__/WithMinLength/index.js +0 -103
  609. package/cjs/Questions/Questions.stories/index.js +0 -26
  610. package/cjs/Questions/__snapshots__/index.spec.tsx.snap +0 -596
  611. package/cjs/Questions/__stories__/Default/index.js +0 -113
  612. package/cjs/Questions/index.mdx +0 -415
  613. package/cjs/Questions/index.spec/index.js +0 -63
  614. package/cjs/create-simple-form.mdx +0 -539
  615. package/cjs/index.mdx +0 -51
  616. package/cjs/inputs/AutoCompleteInput/AutoComplete.stories/index.js +0 -26
  617. package/cjs/inputs/AutoCompleteInput/__stories__/Default/index.js +0 -56
  618. package/cjs/inputs/Checkboxes/Checkboxes.stories/index.js +0 -50
  619. package/cjs/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  620. package/cjs/inputs/Checkboxes/__stories__/Conditional/index.js +0 -102
  621. package/cjs/inputs/Checkboxes/__stories__/Default/index.js +0 -50
  622. package/cjs/inputs/Checkboxes/__stories__/WithDivider/index.js +0 -51
  623. package/cjs/inputs/Checkboxes/index.mdx +0 -0
  624. package/cjs/inputs/DateInput/DateInput.stories/index.js +0 -26
  625. package/cjs/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  626. package/cjs/inputs/DateInput/__stories__/Default/index.js +0 -33
  627. package/cjs/inputs/FileInput/FileInput.stories/index.js +0 -26
  628. package/cjs/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  629. package/cjs/inputs/FileInput/__stories__/Default/index.js +0 -30
  630. package/cjs/inputs/ImageInput/ImageInput.stories/index.js +0 -50
  631. package/cjs/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
  632. package/cjs/inputs/ImageInput/__stories__/Default/index.js +0 -38
  633. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +0 -46
  634. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +0 -43
  635. package/cjs/inputs/Input/Input.stories/index.js +0 -134
  636. package/cjs/inputs/Input/Input.stories.playwright.json +0 -376
  637. package/cjs/inputs/Input/__stories__/AFM/index.js +0 -32
  638. package/cjs/inputs/Input/__stories__/Boolean/index.js +0 -33
  639. package/cjs/inputs/Input/__stories__/Default/index.js +0 -33
  640. package/cjs/inputs/Input/__stories__/IBAN/index.js +0 -33
  641. package/cjs/inputs/Input/__stories__/Integer/index.js +0 -41
  642. package/cjs/inputs/Input/__stories__/LandlineNumber/index.js +0 -36
  643. package/cjs/inputs/Input/__stories__/MobilePhone/index.js +0 -36
  644. package/cjs/inputs/Input/__stories__/PhoneNumber/index.js +0 -35
  645. package/cjs/inputs/Input/__stories__/PostalCode/index.js +0 -35
  646. package/cjs/inputs/Input/__stories__/TextWithCharacterLimit/index.js +0 -39
  647. package/cjs/inputs/Input/index.mdx +0 -8
  648. package/cjs/inputs/Label/Label.stories/index.js +0 -26
  649. package/cjs/inputs/Label/Label.stories.playwright.json +0 -40
  650. package/cjs/inputs/Label/__stories__/Default/index.js +0 -37
  651. package/cjs/inputs/Label/index.mdx +0 -0
  652. package/cjs/inputs/OtpInput/OtpInput.stories/index.js +0 -26
  653. package/cjs/inputs/OtpInput/__stories__/Default/index.js +0 -39
  654. package/cjs/inputs/Radio/Radio.stories/index.js +0 -50
  655. package/cjs/inputs/Radio/Radio.stories.playwright.json +0 -73
  656. package/cjs/inputs/Radio/__stories__/Conditional/index.js +0 -102
  657. package/cjs/inputs/Radio/__stories__/Default/index.js +0 -55
  658. package/cjs/inputs/Radio/__stories__/WithDivider/index.js +0 -56
  659. package/cjs/inputs/Radio/index.mdx +0 -0
  660. package/cjs/inputs/Select/Select.stories/index.js +0 -26
  661. package/cjs/inputs/Select/Select.stories.playwright.json +0 -22
  662. package/cjs/inputs/Select/__stories__/Default/index.js +0 -61
  663. package/cjs/installation.mdx +0 -68
  664. package/cjs/validators/validators.spec/index.js +0 -87
  665. package/create-simple-form.mdx +0 -539
  666. package/inputs/AutoCompleteInput/AutoComplete.stories/index.js +0 -7
  667. package/inputs/AutoCompleteInput/AutoComplete.stories/package.json +0 -6
  668. package/inputs/AutoCompleteInput/__stories__/Default/index.js +0 -46
  669. package/inputs/AutoCompleteInput/__stories__/Default/package.json +0 -6
  670. package/inputs/Checkboxes/Checkboxes.stories/index.js +0 -9
  671. package/inputs/Checkboxes/Checkboxes.stories/package.json +0 -6
  672. package/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  673. package/inputs/Checkboxes/__stories__/Conditional/index.js +0 -92
  674. package/inputs/Checkboxes/__stories__/Conditional/package.json +0 -6
  675. package/inputs/Checkboxes/__stories__/Default/index.js +0 -40
  676. package/inputs/Checkboxes/__stories__/Default/package.json +0 -6
  677. package/inputs/Checkboxes/__stories__/WithDivider/index.js +0 -41
  678. package/inputs/Checkboxes/__stories__/WithDivider/package.json +0 -6
  679. package/inputs/Checkboxes/index.mdx +0 -0
  680. package/inputs/DateInput/DateInput.stories/index.js +0 -7
  681. package/inputs/DateInput/DateInput.stories/package.json +0 -6
  682. package/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  683. package/inputs/DateInput/__stories__/Default/index.js +0 -23
  684. package/inputs/FileInput/FileInput.stories/index.js +0 -7
  685. package/inputs/FileInput/FileInput.stories/package.json +0 -6
  686. package/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  687. package/inputs/FileInput/__stories__/Default/index.js +0 -20
  688. package/inputs/FileInput/__stories__/Default/package.json +0 -6
  689. package/inputs/ImageInput/ImageInput.stories/index.js +0 -9
  690. package/inputs/ImageInput/ImageInput.stories/package.json +0 -6
  691. package/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
  692. package/inputs/ImageInput/__stories__/Default/index.js +0 -28
  693. package/inputs/ImageInput/__stories__/Default/package.json +0 -6
  694. package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +0 -36
  695. package/inputs/ImageInput/__stories__/WithInvalidImageDimension/package.json +0 -6
  696. package/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +0 -33
  697. package/inputs/ImageInput/__stories__/WithInvalidImageSize/package.json +0 -6
  698. package/inputs/Input/Input.stories/index.js +0 -16
  699. package/inputs/Input/Input.stories/package.json +0 -6
  700. package/inputs/Input/Input.stories.playwright.json +0 -376
  701. package/inputs/Input/__stories__/AFM/index.js +0 -22
  702. package/inputs/Input/__stories__/AFM/package.json +0 -6
  703. package/inputs/Input/__stories__/Boolean/index.js +0 -23
  704. package/inputs/Input/__stories__/Boolean/package.json +0 -6
  705. package/inputs/Input/__stories__/Default/index.js +0 -23
  706. package/inputs/Input/__stories__/Default/package.json +0 -6
  707. package/inputs/Input/__stories__/Default.d.ts +0 -3
  708. package/inputs/Input/__stories__/IBAN/index.js +0 -23
  709. package/inputs/Input/__stories__/IBAN/package.json +0 -6
  710. package/inputs/Input/__stories__/Integer/index.js +0 -31
  711. package/inputs/Input/__stories__/Integer/package.json +0 -6
  712. package/inputs/Input/__stories__/LandlineNumber/index.js +0 -26
  713. package/inputs/Input/__stories__/LandlineNumber/package.json +0 -6
  714. package/inputs/Input/__stories__/MobilePhone/index.js +0 -26
  715. package/inputs/Input/__stories__/MobilePhone/package.json +0 -6
  716. package/inputs/Input/__stories__/PhoneNumber/index.js +0 -25
  717. package/inputs/Input/__stories__/PhoneNumber/package.json +0 -6
  718. package/inputs/Input/__stories__/PostalCode/index.js +0 -25
  719. package/inputs/Input/__stories__/PostalCode/package.json +0 -6
  720. package/inputs/Input/__stories__/TextWithCharacterLimit/index.js +0 -29
  721. package/inputs/Input/__stories__/TextWithCharacterLimit/package.json +0 -6
  722. package/inputs/Input/__stories__/TextWithCharacterLimit.d.ts +0 -3
  723. package/inputs/Input/index.mdx +0 -8
  724. package/inputs/Label/Label.stories/index.js +0 -7
  725. package/inputs/Label/Label.stories/package.json +0 -6
  726. package/inputs/Label/Label.stories.playwright.json +0 -40
  727. package/inputs/Label/__stories__/Default/index.js +0 -27
  728. package/inputs/Label/__stories__/Default/package.json +0 -6
  729. package/inputs/Label/index.mdx +0 -0
  730. package/inputs/OtpInput/OtpInput.stories/index.js +0 -7
  731. package/inputs/OtpInput/OtpInput.stories/package.json +0 -6
  732. package/inputs/OtpInput/__stories__/Default/index.js +0 -29
  733. package/inputs/OtpInput/__stories__/Default/package.json +0 -6
  734. package/inputs/Radio/Radio.stories/index.js +0 -9
  735. package/inputs/Radio/Radio.stories/package.json +0 -6
  736. package/inputs/Radio/Radio.stories.playwright.json +0 -73
  737. package/inputs/Radio/__stories__/Conditional/index.js +0 -92
  738. package/inputs/Radio/__stories__/Conditional/package.json +0 -6
  739. package/inputs/Radio/__stories__/Default/index.js +0 -45
  740. package/inputs/Radio/__stories__/Default/package.json +0 -6
  741. package/inputs/Radio/__stories__/WithDivider/index.js +0 -46
  742. package/inputs/Radio/__stories__/WithDivider/package.json +0 -6
  743. package/inputs/Radio/index.mdx +0 -0
  744. package/inputs/Select/Select.stories/index.js +0 -7
  745. package/inputs/Select/Select.stories/package.json +0 -6
  746. package/inputs/Select/Select.stories.playwright.json +0 -22
  747. package/inputs/Select/__stories__/Default/index.js +0 -51
  748. package/inputs/Select/__stories__/Default/package.json +0 -6
  749. package/installation.mdx +0 -68
  750. package/lazy.d.ts +0 -69
  751. package/registry.d.ts +0 -64
  752. package/src/Field/index.mdx +0 -6
  753. package/src/Field/utils.ts +0 -191
  754. package/src/FieldArray/FieldArray.stories.playwright.json +0 -353
  755. package/src/FormBuilder/FormBuilder.mdx +0 -256
  756. package/src/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  757. package/src/FormBuilder/FormBuilder.tsx +0 -166
  758. package/src/MultiplicityField/MultiplicityField.mdx +0 -590
  759. package/src/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  760. package/src/index.mdx +0 -51
  761. package/src/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  762. package/src/inputs/Checkboxes/index.mdx +0 -0
  763. package/src/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  764. package/src/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  765. package/src/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
  766. package/src/inputs/Input/Input.stories.playwright.json +0 -376
  767. package/src/inputs/Input/index.mdx +0 -8
  768. package/src/inputs/Label/Label.stories.playwright.json +0 -40
  769. package/src/inputs/Label/index.mdx +0 -0
  770. package/src/inputs/Radio/Radio.stories.playwright.json +0 -73
  771. package/src/inputs/Radio/index.mdx +0 -0
  772. package/src/inputs/Select/Select.stories.playwright.json +0 -22
  773. package/validators/validators.spec/index.js +0 -85
  774. /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
+ }