@digigov/form 2.0.0-0edebf87 → 2.0.0-13876dba

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 (807) 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 -77
  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 +45 -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 +46 -115
  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 +3 -2
  32. package/FieldArray/FormDialog/index.js +279 -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/__stories__/WithModal.d.ts +2 -0
  39. package/FieldArray/index.d.ts +6 -0
  40. package/FieldArray/index.js +108 -59
  41. package/FieldArray/index.js.map +7 -0
  42. package/FieldArray/index.test.d.ts +1 -0
  43. package/FieldObject/index.d.ts +5 -0
  44. package/FieldObject/index.js +74 -52
  45. package/FieldObject/index.js.map +7 -0
  46. package/Fieldset/FieldsetWithContext/index.js +27 -31
  47. package/Fieldset/FieldsetWithContext.js.map +7 -0
  48. package/Fieldset/index.d.ts +1 -1
  49. package/Fieldset/index.js +27 -29
  50. package/Fieldset/index.js.map +7 -0
  51. package/Fieldset/types/index.js +1 -1
  52. package/Fieldset/types.d.ts +3 -2
  53. package/Fieldset/types.js.map +7 -0
  54. package/FormBuilder/FormBuilder.stories.d.ts +5 -1
  55. package/FormBuilder/__stories__/AutoErrorGrouping.d.ts +3 -0
  56. package/FormBuilder/__stories__/Default.d.ts +2 -2
  57. package/FormBuilder/__stories__/ErrorGrouping.d.ts +3 -0
  58. package/FormBuilder/index.d.ts +8 -1
  59. package/FormBuilder/index.js +237 -2
  60. package/FormBuilder/index.js.map +7 -0
  61. package/FormBuilder/index.test.d.ts +1 -0
  62. package/FormBuilder/interaction.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.d.ts +8 -6
  67. package/MultiplicityField/__stories__/Default.d.ts +2 -2
  68. package/MultiplicityField/__stories__/PreviewDisplay.d.ts +2 -2
  69. package/MultiplicityField/__stories__/WithExactLength.d.ts +2 -2
  70. package/MultiplicityField/__stories__/WithMaxLength.d.ts +2 -2
  71. package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +2 -2
  72. package/MultiplicityField/__stories__/WithMinLength.d.ts +2 -2
  73. package/MultiplicityField/add-objects/index.js +137 -132
  74. package/MultiplicityField/add-objects.d.ts +2 -1
  75. package/MultiplicityField/add-objects.js.map +7 -0
  76. package/MultiplicityField/index.d.ts +2 -19
  77. package/MultiplicityField/index.js +114 -106
  78. package/MultiplicityField/index.js.map +7 -0
  79. package/MultiplicityField/index.test.d.ts +1 -0
  80. package/MultiplicityField/types/index.js +1 -0
  81. package/MultiplicityField/types/package.json +6 -0
  82. package/MultiplicityField/types.d.ts +18 -0
  83. package/MultiplicityField/types.js.map +7 -0
  84. package/Questions/Questions/index.js +48 -56
  85. package/Questions/Questions.js.map +7 -0
  86. package/Questions/Questions.stories.d.ts +3 -1
  87. package/Questions/QuestionsContext/index.js +9 -9
  88. package/Questions/QuestionsContext.d.ts +0 -1
  89. package/Questions/QuestionsContext.js.map +7 -0
  90. package/Questions/Step/ReviewStep/index.js +35 -47
  91. package/Questions/Step/ReviewStep.js.map +7 -0
  92. package/Questions/Step/Step/index.js +39 -47
  93. package/Questions/Step/Step.js.map +7 -0
  94. package/Questions/Step/StepArrayReview/index.js +41 -45
  95. package/Questions/Step/StepArrayReview.js.map +7 -0
  96. package/Questions/Step/StepContext/index.js +15 -19
  97. package/Questions/Step/StepContext.d.ts +0 -1
  98. package/Questions/Step/StepContext.js.map +7 -0
  99. package/Questions/Step/StepDescription/index.js +22 -22
  100. package/Questions/Step/StepDescription.js.map +7 -0
  101. package/Questions/Step/StepForm/index.js +33 -43
  102. package/Questions/Step/StepForm.js.map +7 -0
  103. package/Questions/Step/StepQuote/index.js +10 -9
  104. package/Questions/Step/StepQuote.js.map +7 -0
  105. package/Questions/Step/StepTitle/index.js +41 -38
  106. package/Questions/Step/StepTitle.d.ts +2 -1
  107. package/Questions/Step/StepTitle.js.map +7 -0
  108. package/Questions/Step/getAddMoreFields/index.js +28 -20
  109. package/Questions/Step/getAddMoreFields.js.map +7 -0
  110. package/Questions/Step/index.d.ts +0 -1
  111. package/Questions/Step/index.js +16 -13
  112. package/Questions/Step/index.js.map +7 -0
  113. package/Questions/Step/types/index.js +1 -1
  114. package/Questions/Step/types.d.ts +1 -0
  115. package/Questions/Step/types.js.map +7 -0
  116. package/Questions/__stories__/Default.d.ts +2 -2
  117. package/Questions/getNextStep/index.js +12 -10
  118. package/Questions/getNextStep.js.map +7 -0
  119. package/Questions/index.js +7 -3
  120. package/Questions/index.js.map +7 -0
  121. package/Questions/index.test.d.ts +1 -0
  122. package/Questions/types/index.js +1 -1
  123. package/Questions/types.d.ts +1 -0
  124. package/Questions/types.js.map +7 -0
  125. package/cjs/Field/ErrorGroup/index.js +82 -0
  126. package/cjs/Field/ErrorGroup.js.map +7 -0
  127. package/cjs/Field/FieldBase/index.js +144 -83
  128. package/cjs/Field/FieldBase.js.map +7 -0
  129. package/cjs/Field/FieldBaseContainer/index.js +62 -43
  130. package/cjs/Field/FieldBaseContainer.js.map +7 -0
  131. package/cjs/Field/FieldConditional/index.js +111 -59
  132. package/cjs/Field/FieldConditional.js.map +7 -0
  133. package/cjs/Field/index.js +136 -72
  134. package/cjs/Field/index.js.map +7 -0
  135. package/cjs/Field/types/index.js +16 -5
  136. package/cjs/Field/types.js.map +7 -0
  137. package/cjs/Field/utils/calculateField/index.js +50 -0
  138. package/cjs/Field/utils/calculateField.js.map +7 -0
  139. package/cjs/Field/utils/evaluateFieldWithConditions/index.js +49 -0
  140. package/cjs/Field/utils/evaluateFieldWithConditions.js.map +7 -0
  141. package/cjs/Field/utils/index.js +90 -133
  142. package/cjs/Field/utils/index.js.map +7 -0
  143. package/cjs/Field/utils/useField/index.js +80 -0
  144. package/cjs/Field/utils/useField.js.map +7 -0
  145. package/cjs/FieldArray/FormDialog/index.js +301 -0
  146. package/cjs/FieldArray/FormDialog.js.map +7 -0
  147. package/cjs/FieldArray/index.js +140 -65
  148. package/cjs/FieldArray/index.js.map +7 -0
  149. package/cjs/FieldObject/index.js +103 -61
  150. package/cjs/FieldObject/index.js.map +7 -0
  151. package/cjs/Fieldset/FieldsetWithContext/index.js +54 -40
  152. package/cjs/Fieldset/FieldsetWithContext.js.map +7 -0
  153. package/cjs/Fieldset/index.js +61 -39
  154. package/cjs/Fieldset/index.js.map +7 -0
  155. package/cjs/Fieldset/types/index.js +16 -5
  156. package/cjs/Fieldset/types.js.map +7 -0
  157. package/cjs/FormBuilder/index.js +273 -8
  158. package/cjs/FormBuilder/index.js.map +7 -0
  159. package/cjs/FormContext/index.js +29 -8
  160. package/cjs/FormContext.js.map +7 -0
  161. package/cjs/MultiplicityField/add-objects/index.js +164 -138
  162. package/cjs/MultiplicityField/add-objects.js.map +7 -0
  163. package/cjs/MultiplicityField/index.js +142 -115
  164. package/cjs/MultiplicityField/index.js.map +7 -0
  165. package/cjs/MultiplicityField/types/index.js +16 -0
  166. package/cjs/MultiplicityField/types.js.map +7 -0
  167. package/cjs/Questions/Questions/index.js +80 -65
  168. package/cjs/Questions/Questions.js.map +7 -0
  169. package/cjs/Questions/QuestionsContext/index.js +31 -14
  170. package/cjs/Questions/QuestionsContext.js.map +7 -0
  171. package/cjs/Questions/Step/ReviewStep/index.js +61 -56
  172. package/cjs/Questions/Step/ReviewStep.js.map +7 -0
  173. package/cjs/Questions/Step/Step/index.js +71 -56
  174. package/cjs/Questions/Step/Step.js.map +7 -0
  175. package/cjs/Questions/Step/StepArrayReview/index.js +65 -54
  176. package/cjs/Questions/Step/StepArrayReview.js.map +7 -0
  177. package/cjs/Questions/Step/StepContext/index.js +37 -24
  178. package/cjs/Questions/Step/StepContext.js.map +7 -0
  179. package/cjs/Questions/Step/StepDescription/index.js +55 -31
  180. package/cjs/Questions/Step/StepDescription.js.map +7 -0
  181. package/cjs/Questions/Step/StepForm/index.js +65 -52
  182. package/cjs/Questions/Step/StepForm.js.map +7 -0
  183. package/cjs/Questions/Step/StepQuote/index.js +42 -15
  184. package/cjs/Questions/Step/StepQuote.js.map +7 -0
  185. package/cjs/Questions/Step/StepTitle/index.js +72 -47
  186. package/cjs/Questions/Step/StepTitle.js.map +7 -0
  187. package/cjs/Questions/Step/getAddMoreFields/index.js +50 -25
  188. package/cjs/Questions/Step/getAddMoreFields.js.map +7 -0
  189. package/cjs/Questions/Step/index.js +59 -143
  190. package/cjs/Questions/Step/index.js.map +7 -0
  191. package/cjs/Questions/Step/types/index.js +16 -5
  192. package/cjs/Questions/Step/types.js.map +7 -0
  193. package/cjs/Questions/getNextStep/index.js +33 -14
  194. package/cjs/Questions/getNextStep.js.map +7 -0
  195. package/cjs/Questions/index.js +29 -19
  196. package/cjs/Questions/index.js.map +7 -0
  197. package/cjs/Questions/types/index.js +16 -5
  198. package/cjs/Questions/types.js.map +7 -0
  199. package/cjs/index.js +47 -20
  200. package/cjs/index.js.map +7 -0
  201. package/cjs/inputs/AutoCompleteInput/index.js +92 -60
  202. package/cjs/inputs/AutoCompleteInput/index.js.map +7 -0
  203. package/cjs/inputs/Checkboxes/index.js +102 -96
  204. package/cjs/inputs/Checkboxes/index.js.map +7 -0
  205. package/cjs/inputs/DateInput/index.js +124 -109
  206. package/cjs/inputs/DateInput/index.js.map +7 -0
  207. package/cjs/inputs/DateTimeInput/index.js +211 -0
  208. package/cjs/inputs/DateTimeInput/index.js.map +7 -0
  209. package/cjs/inputs/FileInput/index.js +90 -63
  210. package/cjs/inputs/FileInput/index.js.map +7 -0
  211. package/cjs/inputs/ImageInput/index.js +96 -83
  212. package/cjs/inputs/ImageInput/index.js.map +7 -0
  213. package/cjs/inputs/Input/index.js +106 -71
  214. package/cjs/inputs/Input/index.js.map +7 -0
  215. package/cjs/inputs/Input/inputsInputScenarios/index.js +439 -0
  216. package/cjs/inputs/Input/inputsInputScenarios.js.map +7 -0
  217. package/cjs/inputs/Label/index.js +45 -24
  218. package/cjs/inputs/Label/index.js.map +7 -0
  219. package/cjs/inputs/OtpInput/index.js +143 -113
  220. package/cjs/inputs/OtpInput/index.js.map +7 -0
  221. package/cjs/inputs/Radio/index.js +131 -61
  222. package/cjs/inputs/Radio/index.js.map +7 -0
  223. package/cjs/inputs/Select/index.js +60 -36
  224. package/cjs/inputs/Select/index.js.map +7 -0
  225. package/cjs/inputs/index.js +62 -69
  226. package/cjs/inputs/index.js.map +7 -0
  227. package/cjs/inputs/inputsScenarios/index.js +533 -0
  228. package/cjs/inputs/inputsScenarios.js.map +7 -0
  229. package/cjs/internal/index.js +36 -346
  230. package/cjs/internal.js.map +7 -0
  231. package/cjs/lazy/index.js +109 -516
  232. package/cjs/lazy.js.map +7 -0
  233. package/cjs/locales/el/index.js +35 -0
  234. package/cjs/locales/el.js.map +7 -0
  235. package/cjs/registry/index.js +190 -142
  236. package/cjs/registry.js.map +7 -0
  237. package/cjs/types/index.js +22 -5
  238. package/cjs/types.js.map +7 -0
  239. package/cjs/utils/index.js +79 -83
  240. package/cjs/utils.js.map +7 -0
  241. package/cjs/validators/index.js +131 -164
  242. package/cjs/validators/index.js.map +7 -0
  243. package/cjs/validators/types/index.js +16 -5
  244. package/cjs/validators/types.js.map +7 -0
  245. package/cjs/validators/utils/afm/index.js +38 -21
  246. package/cjs/validators/utils/afm.js.map +7 -0
  247. package/cjs/validators/utils/date/index.js +138 -0
  248. package/cjs/validators/utils/date.js.map +7 -0
  249. package/cjs/validators/utils/datetime/index.js +151 -0
  250. package/cjs/validators/utils/datetime.js.map +7 -0
  251. package/cjs/validators/utils/file/index.js +44 -39
  252. package/cjs/validators/utils/file.js.map +7 -0
  253. package/cjs/validators/utils/iban/index.js +36 -17
  254. package/cjs/validators/utils/iban.js.map +7 -0
  255. package/cjs/validators/utils/image/index.js +88 -112
  256. package/cjs/validators/utils/image.js.map +7 -0
  257. package/cjs/validators/utils/index.js +99 -159
  258. package/cjs/validators/utils/index.js.map +7 -0
  259. package/cjs/validators/utils/int/index.js +35 -13
  260. package/cjs/validators/utils/int.js.map +7 -0
  261. package/cjs/validators/utils/number/index.js +34 -12
  262. package/cjs/validators/utils/number.js.map +7 -0
  263. package/cjs/validators/utils/otp/index.js +35 -13
  264. package/cjs/validators/utils/otp.js.map +7 -0
  265. package/cjs/validators/utils/phone/index.js +113 -58
  266. package/cjs/validators/utils/phone.js.map +7 -0
  267. package/cjs/validators/utils/postal_code/index.js +36 -16
  268. package/cjs/validators/utils/postal_code.js.map +7 -0
  269. package/cjs/validators/utils/text_limit/index.js +40 -25
  270. package/cjs/validators/utils/text_limit.js.map +7 -0
  271. package/cjs/validators/utils/uuid4/index.js +34 -13
  272. package/cjs/validators/utils/uuid4.js.map +7 -0
  273. package/index.d.ts +4 -1
  274. package/index.js +13 -4
  275. package/index.js.map +7 -0
  276. package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +4 -2
  277. package/inputs/AutoCompleteInput/__stories__/Default.d.ts +2 -2
  278. package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +2 -2
  279. package/inputs/AutoCompleteInput/index.d.ts +1 -1
  280. package/inputs/AutoCompleteInput/index.js +62 -51
  281. package/inputs/AutoCompleteInput/index.js.map +7 -0
  282. package/inputs/AutoCompleteInput/index.test.d.ts +1 -0
  283. package/inputs/Checkboxes/Checkboxes.stories.d.ts +5 -3
  284. package/inputs/Checkboxes/__stories__/Conditional.d.ts +2 -2
  285. package/inputs/Checkboxes/__stories__/Default.d.ts +2 -2
  286. package/inputs/Checkboxes/__stories__/WithDivider.d.ts +2 -2
  287. package/inputs/Checkboxes/index.d.ts +2 -1
  288. package/inputs/Checkboxes/index.js +74 -87
  289. package/inputs/Checkboxes/index.js.map +7 -0
  290. package/inputs/Checkboxes/index.test.d.ts +1 -0
  291. package/inputs/DateInput/DateInput.stories.d.ts +3 -1
  292. package/inputs/DateInput/__stories__/Default.d.ts +2 -2
  293. package/inputs/DateInput/index.d.ts +3 -4
  294. package/inputs/DateInput/index.js +94 -99
  295. package/inputs/DateInput/index.js.map +7 -0
  296. package/inputs/DateInput/index.test.d.ts +1 -0
  297. package/inputs/DateTimeInput/DateTimeInput.stories.d.ts +9 -0
  298. package/inputs/DateTimeInput/__stories__/Default.d.ts +3 -0
  299. package/inputs/DateTimeInput/index.d.ts +13 -0
  300. package/inputs/DateTimeInput/index.js +181 -0
  301. package/inputs/DateTimeInput/index.js.map +7 -0
  302. package/inputs/DateTimeInput/index.test.d.ts +1 -0
  303. package/inputs/DateTimeInput/package.json +6 -0
  304. package/inputs/FileInput/FileInput.stories.d.ts +3 -1
  305. package/inputs/FileInput/__stories__/Default.d.ts +2 -2
  306. package/inputs/FileInput/index.d.ts +9 -0
  307. package/inputs/FileInput/index.js +58 -54
  308. package/inputs/FileInput/index.js.map +7 -0
  309. package/inputs/FileInput/index.test.d.ts +1 -0
  310. package/inputs/ImageInput/ImageInput.stories.d.ts +5 -3
  311. package/inputs/ImageInput/__stories__/Default.d.ts +2 -2
  312. package/inputs/ImageInput/__stories__/MaxSize.d.ts +3 -0
  313. package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +2 -2
  314. package/inputs/ImageInput/index.js +64 -75
  315. package/inputs/ImageInput/index.js.map +7 -0
  316. package/inputs/ImageInput/index.test.d.ts +1 -0
  317. package/inputs/Input/Input.stories.d.ts +13 -10
  318. package/inputs/Input/__stories__/AFM.d.ts +2 -2
  319. package/inputs/Input/__stories__/Boolean.d.ts +2 -2
  320. package/inputs/Input/__stories__/IBAN.d.ts +2 -2
  321. package/inputs/Input/__stories__/Integer.d.ts +2 -2
  322. package/inputs/Input/__stories__/LandlineNumber.d.ts +2 -2
  323. package/inputs/Input/__stories__/MobilePhone.d.ts +2 -2
  324. package/inputs/Input/__stories__/PhoneNumber.d.ts +2 -2
  325. package/inputs/Input/__stories__/PostalCode.d.ts +2 -2
  326. package/inputs/Input/__stories__/String.d.ts +3 -0
  327. package/inputs/Input/__stories__/StringWithTrimValidation.d.ts +3 -0
  328. package/inputs/Input/__stories__/TextWithLimit.d.ts +3 -0
  329. package/inputs/Input/index.js +75 -66
  330. package/inputs/Input/index.js.map +7 -0
  331. package/inputs/Input/index.test.d.ts +1 -0
  332. package/inputs/Input/inputsInputScenarios/index.js +406 -0
  333. package/{FieldArray/__stories__/Default → inputs/Input/inputsInputScenarios}/package.json +1 -1
  334. package/inputs/Input/inputsInputScenarios.d.ts +57 -0
  335. package/inputs/Input/inputsInputScenarios.js.map +7 -0
  336. package/inputs/Label/Label.stories.d.ts +3 -1
  337. package/inputs/Label/__stories__/Default.d.ts +2 -2
  338. package/inputs/Label/index.d.ts +1 -3
  339. package/inputs/Label/index.js +12 -17
  340. package/inputs/Label/index.js.map +7 -0
  341. package/inputs/Label/index.test.d.ts +1 -0
  342. package/inputs/OtpInput/OtpInput.stories.d.ts +3 -1
  343. package/inputs/OtpInput/__stories__/Default.d.ts +2 -2
  344. package/inputs/OtpInput/index.d.ts +1 -1
  345. package/inputs/OtpInput/index.js +111 -104
  346. package/inputs/OtpInput/index.js.map +7 -0
  347. package/inputs/OtpInput/index.test.d.ts +1 -0
  348. package/inputs/Radio/Radio.stories.d.ts +5 -3
  349. package/inputs/Radio/__stories__/Conditional.d.ts +2 -2
  350. package/inputs/Radio/__stories__/Default.d.ts +2 -2
  351. package/inputs/Radio/__stories__/WithDivider.d.ts +2 -2
  352. package/inputs/Radio/index.d.ts +6 -1
  353. package/inputs/Radio/index.js +102 -55
  354. package/inputs/Radio/index.js.map +7 -0
  355. package/inputs/Radio/index.test.d.ts +1 -0
  356. package/inputs/Select/Select.stories.d.ts +3 -1
  357. package/inputs/Select/__stories__/Default.d.ts +2 -2
  358. package/inputs/Select/index.d.ts +1 -1
  359. package/inputs/Select/index.js +32 -31
  360. package/inputs/Select/index.js.map +7 -0
  361. package/inputs/Select/index.test.d.ts +1 -0
  362. package/inputs/index.js +21 -9
  363. package/inputs/index.js.map +7 -0
  364. package/inputs/inputsScenarios/index.js +499 -0
  365. package/inputs/inputsScenarios/package.json +6 -0
  366. package/inputs/inputsScenarios.d.ts +296 -0
  367. package/inputs/inputsScenarios.js.map +7 -0
  368. package/internal/index.js +10 -34
  369. package/internal.d.ts +2 -31
  370. package/internal.js.map +7 -0
  371. package/lazy/index.js +75 -393
  372. package/locales/el/index.js +6 -0
  373. package/{Form.stories → locales/el}/package.json +1 -1
  374. package/locales/el.d.ts +2 -0
  375. package/locales/el.js.map +7 -0
  376. package/package.json +7 -8
  377. package/registry/index.js +126 -99
  378. package/src/Field/ErrorGroup.tsx +84 -0
  379. package/src/Field/FieldBase.tsx +35 -22
  380. package/src/Field/FieldBaseContainer.tsx +7 -4
  381. package/src/Field/FieldConditional.tsx +5 -1
  382. package/src/Field/doc.mdx +207 -0
  383. package/src/Field/index.tsx +27 -3
  384. package/src/Field/types.tsx +74 -5
  385. package/src/Field/utils/calculateField.ts +49 -0
  386. package/src/Field/utils/evaluateFieldWithConditions.ts +30 -0
  387. package/src/Field/utils/index.ts +82 -0
  388. package/src/Field/utils/useField.ts +58 -0
  389. package/src/FieldArray/FieldArray.stories.js +3 -2
  390. package/src/FieldArray/FormDialog.tsx +378 -0
  391. package/src/FieldArray/__stories__/Default.tsx +2 -1
  392. package/src/FieldArray/__stories__/WithExactLength.tsx +2 -1
  393. package/src/FieldArray/__stories__/WithModal.tsx +159 -0
  394. package/src/FieldArray/index.test.tsx +32 -0
  395. package/src/FieldArray/index.tsx +92 -39
  396. package/src/FieldObject/index.tsx +31 -10
  397. package/src/Fieldset/index.tsx +5 -5
  398. package/src/Fieldset/types.tsx +5 -3
  399. package/src/FormBuilder/FormBuilder.stories.js +6 -1
  400. package/src/FormBuilder/__stories__/AutoErrorGrouping.tsx +63 -0
  401. package/src/FormBuilder/__stories__/Default.tsx +1 -1
  402. package/src/FormBuilder/__stories__/ErrorGrouping.tsx +43 -0
  403. package/{FormBuilder/FormBuilder.mdx → src/FormBuilder/doc.mdx} +27 -35
  404. package/src/FormBuilder/index.test.tsx +32 -0
  405. package/src/FormBuilder/index.tsx +263 -1
  406. package/src/FormBuilder/interaction.test.tsx +40 -0
  407. package/src/FormBuilder/scenarios.test.tsx +1978 -0
  408. package/src/FormContext.tsx +1 -2
  409. package/src/MultiplicityField/MultiplicityField.stories.js +9 -6
  410. package/src/MultiplicityField/__stories__/Default.tsx +1 -1
  411. package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +1 -1
  412. package/src/MultiplicityField/__stories__/WithExactLength.tsx +2 -2
  413. package/src/MultiplicityField/__stories__/WithMaxLength.tsx +2 -2
  414. package/src/MultiplicityField/__stories__/WithMinAndMaxLength.tsx +2 -2
  415. package/src/MultiplicityField/__stories__/WithMinLength.tsx +2 -2
  416. package/src/MultiplicityField/add-objects.tsx +31 -15
  417. package/{MultiplicityField/MultiplicityField.mdx → src/MultiplicityField/doc.mdx} +112 -98
  418. package/src/MultiplicityField/index.test.tsx +44 -0
  419. package/src/MultiplicityField/index.tsx +21 -34
  420. package/src/MultiplicityField/types.ts +21 -0
  421. package/src/Questions/Questions.stories.js +4 -1
  422. package/src/Questions/Questions.tsx +4 -4
  423. package/src/Questions/Step/StepArrayReview.tsx +1 -1
  424. package/src/Questions/Step/StepTitle.tsx +5 -3
  425. package/src/Questions/Step/index.ts +0 -1
  426. package/src/Questions/Step/types.tsx +1 -0
  427. package/src/Questions/__snapshots__/index.spec.tsx.snap +74 -587
  428. package/src/Questions/__stories__/Default.tsx +1 -1
  429. package/src/Questions/{index.mdx → doc.mdx} +34 -57
  430. package/src/Questions/index.spec.tsx +17 -5
  431. package/src/Questions/index.test.tsx +24 -0
  432. package/src/Questions/types.tsx +1 -0
  433. package/src/create-simple-form.mdx +2 -6
  434. package/{index.mdx → src/doc.mdx} +29 -18
  435. package/src/index.ts +4 -1
  436. package/src/inputs/AutoCompleteInput/AutoComplete.stories.js +5 -2
  437. package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +3 -11
  438. package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +2 -9
  439. package/{inputs/AutoCompleteInput/index.mdx → src/inputs/AutoCompleteInput/doc.mdx} +2 -13
  440. package/src/inputs/AutoCompleteInput/index.test.tsx +28 -0
  441. package/src/inputs/AutoCompleteInput/index.tsx +38 -31
  442. package/src/inputs/Checkboxes/Checkboxes.stories.js +6 -3
  443. package/src/inputs/Checkboxes/__stories__/Conditional.tsx +1 -1
  444. package/src/inputs/Checkboxes/__stories__/Default.tsx +1 -1
  445. package/src/inputs/Checkboxes/__stories__/WithDivider.tsx +1 -1
  446. package/src/inputs/Checkboxes/{index.mdx → doc.mdx} +5 -15
  447. package/src/inputs/Checkboxes/index.test.tsx +32 -0
  448. package/src/inputs/Checkboxes/index.tsx +38 -31
  449. package/src/inputs/DateInput/DateInput.stories.js +4 -1
  450. package/src/inputs/DateInput/__stories__/Default.tsx +17 -16
  451. package/src/inputs/DateInput/{index.mdx → doc.mdx} +1 -8
  452. package/src/inputs/DateInput/index.test.tsx +24 -0
  453. package/src/inputs/DateInput/index.tsx +14 -9
  454. package/src/inputs/DateTimeInput/DateTimeInput.stories.js +11 -0
  455. package/src/inputs/DateTimeInput/__stories__/Default.tsx +25 -0
  456. package/src/inputs/DateTimeInput/doc.mdx +16 -0
  457. package/src/inputs/DateTimeInput/index.test.tsx +24 -0
  458. package/src/inputs/DateTimeInput/index.tsx +194 -0
  459. package/src/inputs/FileInput/FileInput.stories.js +4 -1
  460. package/src/inputs/FileInput/__stories__/Default.tsx +1 -1
  461. package/src/inputs/FileInput/{index.mdx → doc.mdx} +1 -5
  462. package/src/inputs/FileInput/index.test.tsx +24 -0
  463. package/src/inputs/FileInput/index.tsx +33 -10
  464. package/src/inputs/ImageInput/ImageInput.stories.js +6 -3
  465. package/src/inputs/ImageInput/__stories__/Default.tsx +1 -1
  466. package/src/inputs/ImageInput/__stories__/{WithInvalidImageSize.tsx → MaxSize.tsx} +4 -3
  467. package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +3 -1
  468. package/src/inputs/ImageInput/doc.mdx +23 -0
  469. package/src/inputs/ImageInput/index.test.tsx +32 -0
  470. package/src/inputs/ImageInput/index.tsx +17 -16
  471. package/src/inputs/Input/Input.stories.js +14 -10
  472. package/src/inputs/Input/__stories__/AFM.tsx +1 -1
  473. package/src/inputs/Input/__stories__/Boolean.tsx +1 -1
  474. package/src/inputs/Input/__stories__/IBAN.tsx +1 -1
  475. package/src/inputs/Input/__stories__/Integer.tsx +1 -1
  476. package/src/inputs/Input/__stories__/LandlineNumber.tsx +3 -2
  477. package/src/inputs/Input/__stories__/MobilePhone.tsx +2 -1
  478. package/src/inputs/Input/__stories__/PhoneNumber.tsx +2 -1
  479. package/src/inputs/Input/__stories__/PostalCode.tsx +2 -1
  480. package/src/inputs/Input/__stories__/{Default.tsx → String.tsx} +2 -2
  481. package/src/inputs/Input/__stories__/StringWithTrimValidation.tsx +26 -0
  482. package/src/inputs/Input/__stories__/{TextWithCharacterLimit.tsx → TextWithLimit.tsx} +3 -2
  483. package/src/inputs/Input/doc.mdx +56 -0
  484. package/src/inputs/Input/index.test.tsx +64 -0
  485. package/src/inputs/Input/index.tsx +41 -30
  486. package/src/inputs/Input/inputsInputScenarios.ts +404 -0
  487. package/src/inputs/Label/Label.stories.js +4 -1
  488. package/src/inputs/Label/__stories__/Default.tsx +4 -2
  489. package/src/inputs/Label/doc.mdx +14 -0
  490. package/src/inputs/Label/index.test.tsx +24 -0
  491. package/src/inputs/Label/index.tsx +3 -10
  492. package/src/inputs/OtpInput/OtpInput.stories.js +4 -1
  493. package/src/inputs/OtpInput/__stories__/Default.tsx +1 -1
  494. package/{inputs/OtpInput/index.mdx → src/inputs/OtpInput/doc.mdx} +1 -8
  495. package/src/inputs/OtpInput/index.test.tsx +24 -0
  496. package/src/inputs/OtpInput/index.tsx +3 -1
  497. package/src/inputs/Radio/Radio.stories.js +6 -3
  498. package/src/inputs/Radio/__stories__/Conditional.tsx +3 -2
  499. package/src/inputs/Radio/__stories__/Default.tsx +1 -1
  500. package/src/inputs/Radio/__stories__/WithDivider.tsx +1 -1
  501. package/{cjs/inputs/Radio/index.mdx → src/inputs/Radio/doc.mdx} +5 -15
  502. package/src/inputs/Radio/index.test.tsx +32 -0
  503. package/src/inputs/Radio/index.tsx +79 -9
  504. package/src/inputs/Select/Select.stories.js +4 -1
  505. package/src/inputs/Select/__stories__/Default.tsx +1 -1
  506. package/{inputs/Select/index.mdx → src/inputs/Select/doc.mdx} +1 -5
  507. package/src/inputs/Select/index.test.tsx +24 -0
  508. package/src/inputs/Select/index.tsx +12 -4
  509. package/src/inputs/inputsScenarios.ts +496 -0
  510. package/src/installation.mdx +2 -5
  511. package/src/internal.ts +2 -31
  512. package/src/lazy.js +76 -59
  513. package/src/locales/el.ts +3 -0
  514. package/src/registry.js +109 -89
  515. package/src/types.tsx +11 -64
  516. package/src/utils.ts +34 -33
  517. package/src/validators/index.ts +90 -84
  518. package/src/validators/utils/date.ts +107 -0
  519. package/src/validators/utils/datetime.ts +130 -0
  520. package/src/validators/utils/file.ts +5 -3
  521. package/src/validators/utils/index.ts +2 -0
  522. package/src/validators/utils/int.ts +1 -1
  523. package/src/validators/utils/number.ts +1 -1
  524. package/src/validators/utils/phone.ts +63 -72
  525. package/src/validators/utils/postal_code.ts +1 -1
  526. package/src/validators/utils/uuid4.ts +2 -1
  527. package/src/validators/validators.spec.ts +6 -40
  528. package/types/index.js +2 -1
  529. package/types.d.ts +6 -35
  530. package/types.js.map +7 -0
  531. package/utils/index.js +57 -77
  532. package/utils.js.map +7 -0
  533. package/validators/index.js +112 -150
  534. package/validators/index.js.map +7 -0
  535. package/validators/types/index.js +1 -1
  536. package/validators/types.js.map +7 -0
  537. package/validators/utils/afm/index.js +16 -16
  538. package/validators/utils/afm.js.map +7 -0
  539. package/validators/utils/date/index.js +103 -0
  540. package/validators/utils/date/package.json +6 -0
  541. package/validators/utils/date.d.ts +9 -0
  542. package/validators/utils/date.js.map +7 -0
  543. package/validators/utils/datetime/index.js +116 -0
  544. package/{Questions/Questions.stories → validators/utils/datetime}/package.json +1 -1
  545. package/validators/utils/datetime.d.ts +9 -0
  546. package/validators/utils/datetime.js.map +7 -0
  547. package/validators/utils/file/index.js +22 -34
  548. package/validators/utils/file.js.map +7 -0
  549. package/validators/utils/iban/index.js +14 -12
  550. package/validators/utils/iban.js.map +7 -0
  551. package/validators/utils/image/index.js +66 -106
  552. package/validators/utils/image.js.map +7 -0
  553. package/validators/utils/index.d.ts +2 -0
  554. package/validators/utils/index.js +56 -48
  555. package/validators/utils/index.js.map +7 -0
  556. package/validators/utils/int/index.js +13 -8
  557. package/validators/utils/int.js.map +7 -0
  558. package/validators/utils/number/index.js +12 -7
  559. package/validators/utils/number.js.map +7 -0
  560. package/validators/utils/otp/index.js +13 -8
  561. package/validators/utils/otp.js.map +7 -0
  562. package/validators/utils/phone/index.js +89 -51
  563. package/validators/utils/phone.d.ts +1 -1
  564. package/validators/utils/phone.js.map +7 -0
  565. package/validators/utils/postal_code/index.js +14 -11
  566. package/validators/utils/postal_code.d.ts +1 -1
  567. package/validators/utils/postal_code.js.map +7 -0
  568. package/validators/utils/text_limit/index.js +18 -20
  569. package/validators/utils/text_limit.js.map +7 -0
  570. package/validators/utils/uuid4/index.js +12 -8
  571. package/validators/utils/uuid4.js.map +7 -0
  572. package/Field/index.mdx +0 -6
  573. package/Field/utils.d.ts +0 -5
  574. package/FieldArray/FieldArray.stories/index.js +0 -8
  575. package/FieldArray/FieldArray.stories.playwright.json +0 -353
  576. package/FieldArray/__stories__/Default/index.js +0 -88
  577. package/FieldArray/__stories__/WithExactLength/index.js +0 -88
  578. package/FieldArray/__stories__/WithExactLength/package.json +0 -6
  579. package/Form.stories/index.js +0 -3
  580. package/FormBuilder/FormBuilder/index.js +0 -152
  581. package/FormBuilder/FormBuilder.d.ts +0 -5
  582. package/FormBuilder/FormBuilder.stories/index.js +0 -7
  583. package/FormBuilder/FormBuilder.stories/package.json +0 -6
  584. package/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  585. package/FormBuilder/__stories__/Default/index.js +0 -26
  586. package/FormBuilder/__stories__/Default/package.json +0 -6
  587. package/MultiplicityField/MultiplicityField.stories/index.js +0 -12
  588. package/MultiplicityField/MultiplicityField.stories/package.json +0 -6
  589. package/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  590. package/MultiplicityField/__stories__/Default/index.js +0 -95
  591. package/MultiplicityField/__stories__/Default/package.json +0 -6
  592. package/MultiplicityField/__stories__/PreviewDisplay/index.js +0 -78
  593. package/MultiplicityField/__stories__/PreviewDisplay/package.json +0 -6
  594. package/MultiplicityField/__stories__/WithExactLength/index.js +0 -90
  595. package/MultiplicityField/__stories__/WithExactLength/package.json +0 -6
  596. package/MultiplicityField/__stories__/WithMaxLength/index.js +0 -93
  597. package/MultiplicityField/__stories__/WithMaxLength/package.json +0 -6
  598. package/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +0 -94
  599. package/MultiplicityField/__stories__/WithMinAndMaxLength/package.json +0 -6
  600. package/MultiplicityField/__stories__/WithMinLength/index.js +0 -93
  601. package/MultiplicityField/__stories__/WithMinLength/package.json +0 -6
  602. package/Questions/Questions.stories/index.js +0 -7
  603. package/Questions/__snapshots__/index.spec.tsx.snap +0 -596
  604. package/Questions/__stories__/Default/index.js +0 -102
  605. package/Questions/__stories__/Default/package.json +0 -6
  606. package/Questions/index.mdx +0 -415
  607. package/Questions/index.spec/index.js +0 -59
  608. package/cjs/Field/index.mdx +0 -6
  609. package/cjs/FieldArray/FieldArray.stories/index.js +0 -38
  610. package/cjs/FieldArray/FieldArray.stories.playwright.json +0 -353
  611. package/cjs/FieldArray/__stories__/Default/index.js +0 -98
  612. package/cjs/FieldArray/__stories__/WithExactLength/index.js +0 -98
  613. package/cjs/Form.stories/index.js +0 -9
  614. package/cjs/FormBuilder/FormBuilder/index.js +0 -162
  615. package/cjs/FormBuilder/FormBuilder.mdx +0 -256
  616. package/cjs/FormBuilder/FormBuilder.stories/index.js +0 -26
  617. package/cjs/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  618. package/cjs/FormBuilder/__stories__/Default/index.js +0 -36
  619. package/cjs/MultiplicityField/MultiplicityField.mdx +0 -590
  620. package/cjs/MultiplicityField/MultiplicityField.stories/index.js +0 -86
  621. package/cjs/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  622. package/cjs/MultiplicityField/__stories__/Default/index.js +0 -105
  623. package/cjs/MultiplicityField/__stories__/PreviewDisplay/index.js +0 -88
  624. package/cjs/MultiplicityField/__stories__/WithExactLength/index.js +0 -100
  625. package/cjs/MultiplicityField/__stories__/WithMaxLength/index.js +0 -103
  626. package/cjs/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +0 -104
  627. package/cjs/MultiplicityField/__stories__/WithMinLength/index.js +0 -103
  628. package/cjs/Questions/Questions.stories/index.js +0 -26
  629. package/cjs/Questions/__snapshots__/index.spec.tsx.snap +0 -596
  630. package/cjs/Questions/__stories__/Default/index.js +0 -113
  631. package/cjs/Questions/index.mdx +0 -415
  632. package/cjs/Questions/index.spec/index.js +0 -63
  633. package/cjs/create-simple-form.mdx +0 -539
  634. package/cjs/index.mdx +0 -51
  635. package/cjs/inputs/AutoCompleteInput/AutoComplete.stories/index.js +0 -38
  636. package/cjs/inputs/AutoCompleteInput/__stories__/Default/index.js +0 -51
  637. package/cjs/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -52
  638. package/cjs/inputs/AutoCompleteInput/index.mdx +0 -29
  639. package/cjs/inputs/Checkboxes/Checkboxes.stories/index.js +0 -50
  640. package/cjs/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  641. package/cjs/inputs/Checkboxes/__stories__/Conditional/index.js +0 -103
  642. package/cjs/inputs/Checkboxes/__stories__/Default/index.js +0 -50
  643. package/cjs/inputs/Checkboxes/__stories__/WithDivider/index.js +0 -51
  644. package/cjs/inputs/Checkboxes/index.mdx +0 -33
  645. package/cjs/inputs/DateInput/DateInput.stories/index.js +0 -26
  646. package/cjs/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  647. package/cjs/inputs/DateInput/__stories__/Default/index.js +0 -33
  648. package/cjs/inputs/DateInput/index.mdx +0 -23
  649. package/cjs/inputs/FileInput/FileInput.stories/index.js +0 -26
  650. package/cjs/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  651. package/cjs/inputs/FileInput/__stories__/Default/index.js +0 -30
  652. package/cjs/inputs/FileInput/index.mdx +0 -19
  653. package/cjs/inputs/ImageInput/ImageInput.stories/index.js +0 -50
  654. package/cjs/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
  655. package/cjs/inputs/ImageInput/__stories__/Default/index.js +0 -38
  656. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +0 -46
  657. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +0 -43
  658. package/cjs/inputs/ImageInput/index.mdx +0 -19
  659. package/cjs/inputs/Input/Input.stories/index.js +0 -134
  660. package/cjs/inputs/Input/Input.stories.playwright.json +0 -376
  661. package/cjs/inputs/Input/__stories__/AFM/index.js +0 -32
  662. package/cjs/inputs/Input/__stories__/Boolean/index.js +0 -33
  663. package/cjs/inputs/Input/__stories__/Default/index.js +0 -33
  664. package/cjs/inputs/Input/__stories__/IBAN/index.js +0 -33
  665. package/cjs/inputs/Input/__stories__/Integer/index.js +0 -41
  666. package/cjs/inputs/Input/__stories__/LandlineNumber/index.js +0 -36
  667. package/cjs/inputs/Input/__stories__/MobilePhone/index.js +0 -36
  668. package/cjs/inputs/Input/__stories__/PhoneNumber/index.js +0 -35
  669. package/cjs/inputs/Input/__stories__/PostalCode/index.js +0 -35
  670. package/cjs/inputs/Input/__stories__/TextWithCharacterLimit/index.js +0 -39
  671. package/cjs/inputs/Input/index.mdx +0 -95
  672. package/cjs/inputs/Label/Label.stories/index.js +0 -26
  673. package/cjs/inputs/Label/Label.stories.playwright.json +0 -40
  674. package/cjs/inputs/Label/__stories__/Default/index.js +0 -37
  675. package/cjs/inputs/Label/index.mdx +0 -0
  676. package/cjs/inputs/OtpInput/OtpInput.stories/index.js +0 -26
  677. package/cjs/inputs/OtpInput/__stories__/Default/index.js +0 -39
  678. package/cjs/inputs/OtpInput/index.mdx +0 -23
  679. package/cjs/inputs/Radio/Radio.stories/index.js +0 -50
  680. package/cjs/inputs/Radio/Radio.stories.playwright.json +0 -73
  681. package/cjs/inputs/Radio/__stories__/Conditional/index.js +0 -103
  682. package/cjs/inputs/Radio/__stories__/Default/index.js +0 -55
  683. package/cjs/inputs/Radio/__stories__/WithDivider/index.js +0 -56
  684. package/cjs/inputs/Select/Select.stories/index.js +0 -26
  685. package/cjs/inputs/Select/Select.stories.playwright.json +0 -22
  686. package/cjs/inputs/Select/__stories__/Default/index.js +0 -61
  687. package/cjs/inputs/Select/index.mdx +0 -17
  688. package/cjs/installation.mdx +0 -68
  689. package/cjs/validators/validators.spec/index.js +0 -87
  690. package/create-simple-form.mdx +0 -539
  691. package/inputs/AutoCompleteInput/AutoComplete.stories/index.js +0 -8
  692. package/inputs/AutoCompleteInput/AutoComplete.stories/package.json +0 -6
  693. package/inputs/AutoCompleteInput/__stories__/Default/index.js +0 -44
  694. package/inputs/AutoCompleteInput/__stories__/Default/package.json +0 -6
  695. package/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -45
  696. package/inputs/AutoCompleteInput/__stories__/Multiple/package.json +0 -6
  697. package/inputs/Checkboxes/Checkboxes.stories/index.js +0 -9
  698. package/inputs/Checkboxes/Checkboxes.stories/package.json +0 -6
  699. package/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  700. package/inputs/Checkboxes/__stories__/Conditional/index.js +0 -93
  701. package/inputs/Checkboxes/__stories__/Conditional/package.json +0 -6
  702. package/inputs/Checkboxes/__stories__/Default/index.js +0 -40
  703. package/inputs/Checkboxes/__stories__/Default/package.json +0 -6
  704. package/inputs/Checkboxes/__stories__/WithDivider/index.js +0 -41
  705. package/inputs/Checkboxes/__stories__/WithDivider/package.json +0 -6
  706. package/inputs/Checkboxes/index.mdx +0 -33
  707. package/inputs/DateInput/DateInput.stories/index.js +0 -7
  708. package/inputs/DateInput/DateInput.stories/package.json +0 -6
  709. package/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  710. package/inputs/DateInput/__stories__/Default/index.js +0 -23
  711. package/inputs/DateInput/index.mdx +0 -23
  712. package/inputs/FileInput/FileInput.stories/index.js +0 -7
  713. package/inputs/FileInput/FileInput.stories/package.json +0 -6
  714. package/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  715. package/inputs/FileInput/__stories__/Default/index.js +0 -20
  716. package/inputs/FileInput/__stories__/Default/package.json +0 -6
  717. package/inputs/FileInput/index.mdx +0 -19
  718. package/inputs/ImageInput/ImageInput.stories/index.js +0 -9
  719. package/inputs/ImageInput/ImageInput.stories/package.json +0 -6
  720. package/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
  721. package/inputs/ImageInput/__stories__/Default/index.js +0 -28
  722. package/inputs/ImageInput/__stories__/Default/package.json +0 -6
  723. package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +0 -36
  724. package/inputs/ImageInput/__stories__/WithInvalidImageDimension/package.json +0 -6
  725. package/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +0 -33
  726. package/inputs/ImageInput/__stories__/WithInvalidImageSize/package.json +0 -6
  727. package/inputs/ImageInput/__stories__/WithInvalidImageSize.d.ts +0 -3
  728. package/inputs/ImageInput/index.mdx +0 -19
  729. package/inputs/Input/Input.stories/index.js +0 -16
  730. package/inputs/Input/Input.stories/package.json +0 -6
  731. package/inputs/Input/Input.stories.playwright.json +0 -376
  732. package/inputs/Input/__stories__/AFM/index.js +0 -22
  733. package/inputs/Input/__stories__/AFM/package.json +0 -6
  734. package/inputs/Input/__stories__/Boolean/index.js +0 -23
  735. package/inputs/Input/__stories__/Boolean/package.json +0 -6
  736. package/inputs/Input/__stories__/Default/index.js +0 -23
  737. package/inputs/Input/__stories__/Default/package.json +0 -6
  738. package/inputs/Input/__stories__/Default.d.ts +0 -3
  739. package/inputs/Input/__stories__/IBAN/index.js +0 -23
  740. package/inputs/Input/__stories__/IBAN/package.json +0 -6
  741. package/inputs/Input/__stories__/Integer/index.js +0 -31
  742. package/inputs/Input/__stories__/Integer/package.json +0 -6
  743. package/inputs/Input/__stories__/LandlineNumber/index.js +0 -26
  744. package/inputs/Input/__stories__/LandlineNumber/package.json +0 -6
  745. package/inputs/Input/__stories__/MobilePhone/index.js +0 -26
  746. package/inputs/Input/__stories__/MobilePhone/package.json +0 -6
  747. package/inputs/Input/__stories__/PhoneNumber/index.js +0 -25
  748. package/inputs/Input/__stories__/PhoneNumber/package.json +0 -6
  749. package/inputs/Input/__stories__/PostalCode/index.js +0 -25
  750. package/inputs/Input/__stories__/PostalCode/package.json +0 -6
  751. package/inputs/Input/__stories__/TextWithCharacterLimit/index.js +0 -29
  752. package/inputs/Input/__stories__/TextWithCharacterLimit/package.json +0 -6
  753. package/inputs/Input/__stories__/TextWithCharacterLimit.d.ts +0 -3
  754. package/inputs/Input/index.mdx +0 -95
  755. package/inputs/Label/Label.stories/index.js +0 -7
  756. package/inputs/Label/Label.stories/package.json +0 -6
  757. package/inputs/Label/Label.stories.playwright.json +0 -40
  758. package/inputs/Label/__stories__/Default/index.js +0 -27
  759. package/inputs/Label/__stories__/Default/package.json +0 -6
  760. package/inputs/Label/index.mdx +0 -0
  761. package/inputs/OtpInput/OtpInput.stories/index.js +0 -7
  762. package/inputs/OtpInput/OtpInput.stories/package.json +0 -6
  763. package/inputs/OtpInput/__stories__/Default/index.js +0 -29
  764. package/inputs/OtpInput/__stories__/Default/package.json +0 -6
  765. package/inputs/Radio/Radio.stories/index.js +0 -9
  766. package/inputs/Radio/Radio.stories/package.json +0 -6
  767. package/inputs/Radio/Radio.stories.playwright.json +0 -73
  768. package/inputs/Radio/__stories__/Conditional/index.js +0 -93
  769. package/inputs/Radio/__stories__/Conditional/package.json +0 -6
  770. package/inputs/Radio/__stories__/Default/index.js +0 -45
  771. package/inputs/Radio/__stories__/Default/package.json +0 -6
  772. package/inputs/Radio/__stories__/WithDivider/index.js +0 -46
  773. package/inputs/Radio/__stories__/WithDivider/package.json +0 -6
  774. package/inputs/Radio/index.mdx +0 -33
  775. package/inputs/Select/Select.stories/index.js +0 -7
  776. package/inputs/Select/Select.stories/package.json +0 -6
  777. package/inputs/Select/Select.stories.playwright.json +0 -22
  778. package/inputs/Select/__stories__/Default/index.js +0 -51
  779. package/inputs/Select/__stories__/Default/package.json +0 -6
  780. package/installation.mdx +0 -68
  781. package/lazy.d.ts +0 -69
  782. package/registry.d.ts +0 -64
  783. package/src/Field/index.mdx +0 -6
  784. package/src/Field/utils.ts +0 -191
  785. package/src/FieldArray/FieldArray.stories.playwright.json +0 -353
  786. package/src/FormBuilder/FormBuilder.mdx +0 -256
  787. package/src/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  788. package/src/FormBuilder/FormBuilder.tsx +0 -166
  789. package/src/MultiplicityField/MultiplicityField.mdx +0 -590
  790. package/src/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  791. package/src/index.mdx +0 -51
  792. package/src/inputs/AutoCompleteInput/index.mdx +0 -29
  793. package/src/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  794. package/src/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  795. package/src/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  796. package/src/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
  797. package/src/inputs/ImageInput/index.mdx +0 -19
  798. package/src/inputs/Input/Input.stories.playwright.json +0 -376
  799. package/src/inputs/Input/index.mdx +0 -95
  800. package/src/inputs/Label/Label.stories.playwright.json +0 -40
  801. package/src/inputs/Label/index.mdx +0 -0
  802. package/src/inputs/OtpInput/index.mdx +0 -23
  803. package/src/inputs/Radio/Radio.stories.playwright.json +0 -73
  804. package/src/inputs/Radio/index.mdx +0 -33
  805. package/src/inputs/Select/Select.stories.playwright.json +0 -22
  806. package/src/inputs/Select/index.mdx +0 -17
  807. package/validators/validators.spec/index.js +0 -85
@@ -0,0 +1,207 @@
1
+ ---
2
+ title: Form
3
+ parent: docs/form/components
4
+ ---
5
+
6
+ # Field
7
+
8
+ Field allow users to create different types of inputs based on data that is described by a particular config schema.
9
+
10
+ ```jsx
11
+ import React from 'react';
12
+ import FormBuilder, { Field } from '@digigov/form';
13
+ import { Button } from '@digigov/ui/form/Button';
14
+
15
+ const fields = [
16
+ {
17
+ key: 'first_name',
18
+ type: 'string',
19
+ required: true,
20
+ label: {
21
+ primary: 'Ποιo είναι το όνομά σας;',
22
+ },
23
+ },
24
+ ];
25
+
26
+ export const MyComponent = () => (
27
+ <FormBuilder onSubmit={(data) => console.log(data)}>
28
+ {fields.map(({ key, ...field }) => {
29
+ return <Field {...field} name={key} key={key} />;
30
+ })}
31
+ <Button type="submit">Συνέχεια</Button>
32
+ </FormBuilder>
33
+ );
34
+ export default MyComponent;
35
+ ```
36
+
37
+ ## Accessibility & Usability
38
+
39
+ Our goal is to create semantically correct and valid forms, which means
40
+ we must avoid mixing form-related HTML elements (like form, input, label) with generic
41
+ ones (such as div, cards, or custom components). For instance, if a paragraph element is
42
+ placed inside a form, React will display warnings in the console. Rather than building overly
43
+ complex interfaces that attempt to accomplish too much too quickly, Digigov Form encourages
44
+ using forms in their intended way—filling out and validating inputs, and then submitting the form
45
+ as a whole.
46
+
47
+ Additionally, we must ensure our interfaces are fully accessible to screen readers and other
48
+ assistive technologies. This is why we designed the flow to be as guided and recoverable as possible.
49
+ Forms and fields should be clear and logical, reading like well-written text for the users.
50
+ If validation fails, the system provides users with meaningful error messages and clear instructions on how to correct the errors.
51
+ Once validation is successful, the data can be submitted. It is crucial to provide helpful information to users at each step.
52
+ Therefore, we should avoid relying on flashy “magic” UX solutions that assume users have advanced digital skills,
53
+ as these are often intended for expert use cases.
54
+
55
+ ## Introducing the Field component
56
+
57
+ Field is a component that creates `form` inputs dynamically based on a `data config` schema.
58
+ The config structure is a `key-value` pair of data that describes the input fields and its usage.
59
+ In order to create an input, we need to provide a specific type of input for each field,
60
+ and we can use the `type` property for this.
61
+
62
+ ## Field types
63
+
64
+ The `type` property determines the type of input field to be rendered. Below are the available types and their descriptions.
65
+
66
+ | Type | Input Description |
67
+ | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
68
+ | `int` | A whole number. |
69
+ | `string` | A text string (e.g., name, address). |
70
+ | `text` | A larger text input, suitable for paragraphs or multiline text. |
71
+ | `boolean` | A binary value, typically a checkbox or toggle (true/false). |
72
+ | `email` | An email address (e.g., example@example.com). |
73
+ | `uuid4` | A universally unique identifier (UUID) in version 4 format. |
74
+ | `choice:multiple` | A selection of multiple options from a list (e.g., checkboxes). |
75
+ | `choice:single` | A single selection from a list (e.g., radio buttons). |
76
+ | `mobile_phone` | A phone number, typically with country code (e.g., +1-234-567-890). |
77
+ | `date` | A date input, typically in the format YYYY-MM-DD. |
78
+ | `datetime` | A date and time input, typically in the format YYYY-MM-DD HH:MM:SS. |
79
+ | `otp` | A one-time password, typically a short numeric or alphanumeric string. |
80
+ | `afm` | A Greek Tax Identification Number (AFM). |
81
+ | `iban` | An International Bank Account Number (IBAN). |
82
+ | `file` | A file upload input (e.g., for documents, images). |
83
+ | `image` | A file input that specifically handles images. |
84
+ | `postal_code` | A postal code input (e.g., ZIP code, postcode). |
85
+ | `phone_number` | A phone number input (e.g., with or without country code). |
86
+ | `array` | A list of values, typically displayed as multiple inputs ([MultiplicityField](/components/@digigov/form/MultiplicityField.html)). |
87
+ | `object` | A structured data object, often used for more complex or nested forms. |
88
+
89
+ ## Field properties
90
+
91
+ The Field component accepts several properties, that describes the input fields and its usage.
92
+
93
+ | Property | Type | Description |
94
+ | -------------- | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
95
+ | `key` | `string` | The name of the field (TODO: rename to `name`). |
96
+ | `type` | Describes the format of each field, e.g., `type: 'string'` is a simple input format field | The type of input field. Defines the kind of value it accepts. |
97
+ | `trim` | `boolean` | If `true`, trims the input value. |
98
+ | `component` | `any` | A custom React component for the input field. |
99
+ | `autoComplete` | `string` | The `autocomplete` attribute value for the input field (e.g., 'on', 'off'). |
100
+ | `maxLength` | `number` | The maximum number of characters the input can accept. |
101
+ | `condition` | `Record<string, FieldCondition>` | Conditions for when the field should be shown, enabled, or validated. |
102
+ | `controlled` | `boolean` | If `true`, the input value is controlled by React state. |
103
+ | `label` | `FieldLabelProps` | The label associated with the input field. |
104
+ | `extra` | `Record<string, any>` | Extra custom attributes or settings for the field. |
105
+ | `editable` | `boolean` | If `false`, the field cannot be edited. |
106
+ | `variant` | `'inline' \| 'dialog'` | Defines the display variant of the field (e.g., inline or in a dialog). |
107
+ | `required` | `boolean` | If `true`, the field is required to be filled. |
108
+ | `enabled` | `boolean` | If `false`, the field is disabled and cannot be interacted with. |
109
+ | `disabled` | `boolean` | If `true`, the field is disabled. |
110
+ | `layout` | `Record<string, GridProps['xs' \| 'sm' \| 'md' \| 'lg' \| 'xl']>` | Defines the layout settings for the field (grid system). |
111
+ | `validators` | `ValidatorSchema[]` | Array of validators to be applied to the input field. |
112
+ | `wrapper` | `'label' \| 'fieldset'` | Defines the wrapping element for the field (label or fieldset). |
113
+ | `maxWidth` | `string` | The maximum width of the field. |
114
+ | `maxHeight` | `string` | The maximum height of the field. |
115
+ | `width` | `string` | The width of the field. |
116
+
117
+ ### How to use it
118
+
119
+ The `Field` component is a fundamental building block of the `form`.
120
+ We can implement a `Field` by using the `data config` or we can fill the `Field` directly with its properties.
121
+
122
+ First, we need to import the `FormBuilder` component from the `@digigov/form` path.
123
+
124
+ ```jsx pure
125
+ import React from 'react';
126
+ import FormBuilder from '@digigov/form';
127
+ import Button from '@digigov/ui/form/Button';
128
+
129
+ export default function MyFieldComponent() {
130
+ return (
131
+ <FormBuilder>
132
+ {/* this is where all fields will eventually be rendered */}
133
+ <Button type="submit">Συνέχεια</Button>
134
+ </FormBuilder>
135
+ );
136
+ }
137
+ ```
138
+
139
+ #### Data config
140
+
141
+ The `data config` is an array of objects that contains the configuration for each field.
142
+
143
+ ```jsx pure
144
+ const fields = [
145
+ {
146
+ key: 'first_name',
147
+ type: 'string',
148
+ required: true,
149
+ label: {
150
+ primary: 'Ποιo είναι το όνομά σας;',
151
+ },
152
+ },
153
+ ];
154
+ ```
155
+
156
+ Then we can use the `fields` array to render the Field(s).
157
+
158
+ ```jsx pure
159
+ import React from 'react';
160
+ import FormBuilder, { Field } from '@digigov/form';
161
+ import { Button } from '@digigov/ui/form/Button';
162
+
163
+ const fields = [
164
+ {
165
+ key: 'first_name',
166
+ type: 'string',
167
+ required: true,
168
+ label: {
169
+ primary: 'Ποιo είναι το όνομά σας;',
170
+ },
171
+ },
172
+ ];
173
+
174
+ export const MyComponent = () => (
175
+ <FormBuilder onSubmit={(data) => console.log(data)}>
176
+ {fields.map(({ key, ...field }) => {
177
+ return <Field {...field} name={key} key={key} />;
178
+ })}
179
+ <Button type="submit">Συνέχεια</Button>
180
+ </FormBuilder>
181
+ );
182
+ export default MyComponent;
183
+ ```
184
+
185
+ #### Directly
186
+
187
+ We can also use the `Field` component directly and pass the properties to it.
188
+
189
+ ```jsx pure
190
+ import React from 'react';
191
+ import FormBuilder, { Field } from '@digigov/form';
192
+ import { Button } from '@digigov/ui/form/Button';
193
+
194
+ export const MyComponent = () => (
195
+ <FormBuilder onSubmit={(data) => console.log(data)}>
196
+ <Field
197
+ key="first_name"
198
+ name="first_name"
199
+ label={{ primary: 'Οχήματα' }}
200
+ type="sting"
201
+ required
202
+ />
203
+ <Button type="submit">Συνέχεια</Button>
204
+ </FormBuilder>
205
+ );
206
+ export default MyComponent;
207
+ ```
@@ -6,12 +6,17 @@ import {
6
6
  CalculatedField,
7
7
  FieldProps,
8
8
  } from '@digigov/form/Field/types';
9
- import { useField, calculateField } from '@digigov/form/Field/utils';
9
+ import {
10
+ FIELD_COMPONENTS,
11
+ ALTERNATIVE_COMPONENTS,
12
+ } from '@digigov/form/Field/utils';
13
+ import { calculateField } from '@digigov/form/Field/utils/calculateField';
14
+ import { useField } from '@digigov/form/Field/utils/useField';
10
15
  import FieldArray from '@digigov/form/FieldArray';
11
16
  import Multiplicity from '@digigov/form/MultiplicityField';
12
-
13
17
  export const Field: React.FC<FieldProps> = ({
14
18
  name,
19
+ disabled,
15
20
  children,
16
21
  ...customField
17
22
  }) => {
@@ -30,7 +35,16 @@ export const Field: React.FC<FieldProps> = ({
30
35
  clearErrors,
31
36
  } = useField(name, customField?.type ? customField : null);
32
37
  const calculatedField: CalculatedField = useMemo(
33
- () => calculateField(children, field, componentRegistry),
38
+ () =>
39
+ calculateField(
40
+ children,
41
+ field,
42
+ {
43
+ ...FIELD_COMPONENTS,
44
+ ...componentRegistry,
45
+ },
46
+ ALTERNATIVE_COMPONENTS
47
+ ),
34
48
  [field]
35
49
  );
36
50
 
@@ -42,6 +56,7 @@ export const Field: React.FC<FieldProps> = ({
42
56
  register={register}
43
57
  field={calculatedField as FieldWithCondition}
44
58
  error={error}
59
+ Field={Field}
45
60
  />
46
61
  );
47
62
  }
@@ -50,9 +65,15 @@ export const Field: React.FC<FieldProps> = ({
50
65
  return (
51
66
  <FieldArray
52
67
  control={control}
68
+ trigger={trigger}
53
69
  register={register}
70
+ clearErrors={clearErrors}
54
71
  error={error}
72
+ getValues={getValues}
73
+ setValue={setValue}
55
74
  formState={formState}
75
+ Field={Field}
76
+ reset={reset}
56
77
  {...calculatedField}
57
78
  />
58
79
  );
@@ -73,6 +94,7 @@ export const Field: React.FC<FieldProps> = ({
73
94
  setValue={setValue}
74
95
  getValues={getValues}
75
96
  unregister={unregister}
97
+ Field={Field}
76
98
  {...calculatedField}
77
99
  />
78
100
  );
@@ -81,10 +103,12 @@ export const Field: React.FC<FieldProps> = ({
81
103
  <FieldBase
82
104
  {...calculatedField}
83
105
  name={name}
106
+ disabled={disabled}
84
107
  control={control}
85
108
  register={register}
86
109
  reset={reset}
87
110
  error={error}
111
+ Field={Field}
88
112
  />
89
113
  );
90
114
  };
@@ -1,11 +1,75 @@
1
1
  import React from 'react';
2
- import { ErrorOption, UseFormReturn } from 'react-hook-form';
3
- import { FieldSpec } from '@digigov/form/types';
4
- import { FieldCondition, FormData } from '@digigov/form/types';
2
+ import { ErrorOption, UseFormReturn, UseFormProps } from 'react-hook-form';
3
+ import { ValidatorSchema } from '@digigov/form/validators/types';
4
+ import { GridProps } from '@digigov/ui/layouts/Grid';
5
5
 
6
+ export interface FieldLabelProps {
7
+ primary?: string;
8
+ secondary?: string;
9
+ hint?: string;
10
+ }
11
+
12
+ export interface FieldSpec {
13
+ key: string; // !TODO rename key to name;
14
+ type?:
15
+ | 'int'
16
+ | 'string'
17
+ | 'text'
18
+ | 'boolean'
19
+ | 'email'
20
+ | 'uuid4'
21
+ | 'choice:multiple'
22
+ | 'choice:single'
23
+ | 'mobile_phone'
24
+ | 'date'
25
+ | 'datetime'
26
+ | 'otp'
27
+ | 'afm'
28
+ | 'iban'
29
+ | 'file'
30
+ | 'image'
31
+ | 'postal_code'
32
+ | 'phone_number'
33
+ | 'array'
34
+ | 'object';
35
+ trim?: boolean;
36
+ component?: any;
37
+ autoComplete?: string;
38
+ placeholder?: string;
39
+ maxLength?: number;
40
+ condition?: Record<string, FieldCondition>;
41
+ controlled?: boolean;
42
+ label?: FieldLabelProps;
43
+ extra?: Record<string, any>;
44
+ editable?: boolean;
45
+ variant?: 'inline' | 'dialog';
46
+ required?: boolean;
47
+ enabled?: boolean;
48
+ disabled?: boolean;
49
+ layout?: Record<
50
+ string,
51
+ | GridProps['xs']
52
+ | GridProps['sm']
53
+ | GridProps['md']
54
+ | GridProps['lg']
55
+ | GridProps['xl']
56
+ >;
57
+ validators?: ValidatorSchema[];
58
+ wrapper?: 'label' | 'fieldset';
59
+ maxWidth?: string;
60
+ maxHeight?: string;
61
+ width?: string;
62
+ }
63
+
64
+ export interface FieldCondition {
65
+ is: string | string[] | number | number[] | boolean | boolean[];
66
+ then?: Partial<FieldSpec>;
67
+ else?: Partial<FieldSpec>;
68
+ }
6
69
  export interface ChildFieldMemoProps extends FieldConditionalProps {
7
70
  dependencies: FormData;
8
71
  }
72
+ export type FormData = UseFormProps['defaultValues'];
9
73
 
10
74
  export interface FieldWithCondition extends Omit<CalculatedField, 'condition'> {
11
75
  condition: Record<string, FieldCondition>;
@@ -17,20 +81,22 @@ export interface FieldConditionalProps {
17
81
  register: UseFormReturn['register'];
18
82
  reset: UseFormReturn['reset'];
19
83
  error?: ErrorOption;
84
+ Field: React.FC<FieldProps>;
20
85
  }
21
86
 
22
- export type FieldComponentItem = {
87
+ export interface FieldComponentItem {
23
88
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
89
  component: any;
25
90
  controlled?: boolean;
26
91
  wrapper?: FieldSpec['wrapper'];
27
- };
92
+ }
28
93
 
29
94
  export interface FieldContainerProps {
30
95
  name?: FieldSpec['key'];
31
96
  layout?: FieldSpec['layout'];
32
97
  label?: FieldSpec['label'];
33
98
  error?: ErrorOption | Record<string, any>;
99
+ hasError?: boolean;
34
100
  children?: React.ReactNode;
35
101
  wrapper?: FieldSpec['wrapper'];
36
102
  }
@@ -51,6 +117,7 @@ export interface ControlledFieldProps {
51
117
  error?: boolean;
52
118
  name?: string;
53
119
  disabled?: boolean;
120
+ Field: React.FC<FieldProps>;
54
121
  }
55
122
 
56
123
  export interface UncontrolledFieldProps {
@@ -61,6 +128,7 @@ export interface UncontrolledFieldProps {
61
128
  extra?: Record<string, never>;
62
129
  type?: string;
63
130
  disabled?: boolean;
131
+ Field: React.FC<FieldProps>;
64
132
  }
65
133
 
66
134
  export interface CalculatedField extends OmittedFieldSpec {
@@ -77,6 +145,7 @@ export interface FieldBaseProps extends CalculatedField {
77
145
  control: UseFormReturn['control'];
78
146
  register: UseFormReturn['register'];
79
147
  reset: UseFormReturn['reset'];
148
+ Field: React.FC<FieldProps>;
80
149
  }
81
150
 
82
151
  export interface FieldProps extends FieldSpec {
@@ -0,0 +1,49 @@
1
+ import {
2
+ FieldProps,
3
+ FieldSpec,
4
+ FieldComponentRegistry,
5
+ CalculatedField,
6
+ } from '@digigov/form/Field/types';
7
+
8
+ export function calculateField(
9
+ children: FieldProps['children'],
10
+ field: FieldSpec,
11
+ fieldComponentRegistry: FieldComponentRegistry,
12
+ alternativeComponents: FieldComponentRegistry
13
+ ): CalculatedField {
14
+ const calculatedField = { ...field };
15
+ if (children) {
16
+ calculatedField.component = children;
17
+ calculatedField.controlled = true;
18
+ } else if (typeof field.component === 'function') {
19
+ // leave as is
20
+ } else if (!field.component && !field.type) {
21
+ calculatedField.component = fieldComponentRegistry.string.component;
22
+ calculatedField.controlled =
23
+ fieldComponentRegistry.string?.controlled || false;
24
+ } else if (
25
+ typeof field?.extra?.component === 'string' &&
26
+ alternativeComponents[field.extra.component]
27
+ ) {
28
+ calculatedField.controlled =
29
+ alternativeComponents[field.extra.component]?.controlled || false;
30
+ calculatedField.component =
31
+ alternativeComponents[field.extra.component].component;
32
+ calculatedField.wrapper =
33
+ alternativeComponents[field.extra.component].wrapper;
34
+ } else if (
35
+ !field.component &&
36
+ field.type &&
37
+ fieldComponentRegistry[field.type]
38
+ ) {
39
+ calculatedField.component = fieldComponentRegistry[field.type].component;
40
+ calculatedField.wrapper = fieldComponentRegistry[field.type].wrapper;
41
+ calculatedField.controlled =
42
+ fieldComponentRegistry[field.type]?.controlled || false;
43
+ } else {
44
+ calculatedField.component = fieldComponentRegistry.string.component;
45
+ calculatedField.controlled =
46
+ fieldComponentRegistry.string?.controlled || false;
47
+ }
48
+ return calculatedField as CalculatedField;
49
+ }
@@ -0,0 +1,30 @@
1
+ import { FieldWithCondition, CalculatedField } from '@digigov/form/Field/types';
2
+
3
+ export function evaluateFieldWithConditions(
4
+ field: FieldWithCondition,
5
+ variables: FormData
6
+ ): CalculatedField {
7
+ const newField = { ...field };
8
+ if (variables) {
9
+ for (const key in variables) {
10
+ if (field.condition[key] && field.condition[key].is) {
11
+ const is = field.condition[key].is;
12
+ if (
13
+ is === variables[key] ||
14
+ (Array.isArray(variables[key]) && variables[key].includes(is))
15
+ ) {
16
+ const then = field.condition[key].then || {};
17
+ for (const attr in then) {
18
+ newField[attr] = then[attr];
19
+ }
20
+ }
21
+ } else if (field.condition[key]) {
22
+ const otherwise = field.condition[key].else || {};
23
+ for (const attr in otherwise) {
24
+ newField[attr] = otherwise[attr];
25
+ }
26
+ }
27
+ }
28
+ }
29
+ return newField;
30
+ }
@@ -0,0 +1,82 @@
1
+ import { FieldComponentRegistry } from '@digigov/form/Field/types';
2
+ import AutoCompleteInput from '@digigov/form/inputs/AutoCompleteInput';
3
+ import Checkboxes from '@digigov/form/inputs/Checkboxes';
4
+ import DateInput from '@digigov/form/inputs/DateInput';
5
+ import DateTimeInput from '@digigov/form/inputs/DateTimeInput';
6
+ import FileInput from '@digigov/form/inputs/FileInput';
7
+ import ImageInput from '@digigov/form/inputs/ImageInput';
8
+ import Input from '@digigov/form/inputs/Input';
9
+ import OtpInput from '@digigov/form/inputs/OtpInput';
10
+ import Radio, { ControlledRadioButtonsGroup } from '@digigov/form/inputs/Radio';
11
+ import Select from '@digigov/form/inputs/Select';
12
+
13
+ export const FIELD_COMPONENTS: FieldComponentRegistry = {
14
+ text: {
15
+ component: Input,
16
+ },
17
+ string: {
18
+ component: Input,
19
+ },
20
+ file: {
21
+ wrapper: 'fieldset',
22
+ component: FileInput,
23
+ },
24
+ image: {
25
+ wrapper: 'fieldset',
26
+ component: ImageInput,
27
+ },
28
+ date: {
29
+ wrapper: 'fieldset',
30
+ controlled: true,
31
+ component: DateInput,
32
+ },
33
+ datetime: {
34
+ wrapper: 'fieldset',
35
+ controlled: true,
36
+ component: DateTimeInput,
37
+ },
38
+ otp: {
39
+ wrapper: 'fieldset',
40
+ controlled: true,
41
+ component: OtpInput,
42
+ },
43
+ 'choice:multiple': {
44
+ wrapper: 'fieldset',
45
+ controlled: true,
46
+ component: Checkboxes,
47
+ },
48
+ 'choice:single': {
49
+ wrapper: 'fieldset',
50
+ controlled: false,
51
+ component: Radio,
52
+ },
53
+ };
54
+
55
+ export const ALTERNATIVE_COMPONENTS: FieldComponentRegistry = {
56
+ Select: {
57
+ component: Select,
58
+ controlled: false,
59
+ },
60
+ AutoComplete: {
61
+ component: AutoCompleteInput,
62
+ controlled: true,
63
+ wrapper: 'fieldset',
64
+ },
65
+ };
66
+
67
+ export const CONTROLLED_FIELD_COMPONENTS: FieldComponentRegistry = {
68
+ ...FIELD_COMPONENTS,
69
+ 'choice:single': {
70
+ wrapper: 'fieldset',
71
+ controlled: true,
72
+ component: ControlledRadioButtonsGroup,
73
+ },
74
+ text: {
75
+ component: Input,
76
+ controlled: true,
77
+ },
78
+ string: {
79
+ component: Input,
80
+ controlled: true,
81
+ },
82
+ };
@@ -0,0 +1,58 @@
1
+ import { useContext, useMemo } from 'react';
2
+ import { FieldSpec, UseFieldProps } from '@digigov/form/Field/types';
3
+ import { FormContext } from '@digigov/form/FormContext';
4
+
5
+ export const useField = (
6
+ name: string,
7
+ customField: FieldSpec | null
8
+ ): UseFieldProps => {
9
+ const {
10
+ fieldsMap,
11
+ control,
12
+ register,
13
+ reset,
14
+ trigger,
15
+ clearErrors,
16
+ errors,
17
+ registerField,
18
+ watch,
19
+ componentRegistry,
20
+ getFieldState,
21
+ setValue,
22
+ getValues,
23
+ unregister,
24
+ formState,
25
+ } = useContext(FormContext);
26
+ if (!registerField) {
27
+ throw new Error(`
28
+ You can't use the Field component without wrapping it in FormBuilder.
29
+ https://devs.pages.grnet.gr/digigov/digigov-sdk/sdk-docs/forms/create-simple-form/
30
+ `);
31
+ }
32
+ let error = errors[name];
33
+ const nameIndexRegex = name.match(/^(.*?)\.(\d+)$/);
34
+ if (nameIndexRegex) {
35
+ const [, fieldArrayName, indexStr] = nameIndexRegex;
36
+ error = errors[fieldArrayName]?.[Number(indexStr)];
37
+ }
38
+ useMemo(
39
+ () => customField?.type && registerField({ ...customField, key: name }),
40
+ [customField, name, registerField]
41
+ );
42
+ return {
43
+ field: customField || fieldsMap[name],
44
+ control,
45
+ register,
46
+ reset,
47
+ trigger,
48
+ watch,
49
+ componentRegistry,
50
+ getFieldState,
51
+ setValue,
52
+ clearErrors,
53
+ getValues,
54
+ unregister,
55
+ formState,
56
+ error,
57
+ };
58
+ };
@@ -4,5 +4,6 @@ export default {
4
4
  component: FieldArray,
5
5
  displayName: 'FieldArray',
6
6
  };
7
- export * from '@digigov/form/FieldArray/__stories__/Default';
8
- export * from '@digigov/form/FieldArray/__stories__/WithExactLength';
7
+ export { Default } from '@digigov/form/FieldArray/__stories__/Default';
8
+ export { WithModal } from '@digigov/form/FieldArray/__stories__/WithModal';
9
+ export { WithExactLength } from '@digigov/form/FieldArray/__stories__/WithExactLength';