@digigov/form 2.0.0-7d9a8d86 → 2.0.0-85c27c19

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 (688) hide show
  1. package/Field/FieldBase/index.js +72 -51
  2. package/Field/FieldBase.js.map +2 -2
  3. package/Field/FieldBaseContainer/index.js +4 -18
  4. package/Field/FieldBaseContainer.js.map +1 -1
  5. package/Field/FieldConditional/index.js +55 -40
  6. package/Field/FieldConditional.js.map +2 -2
  7. package/Field/index.js +67 -36
  8. package/Field/index.js.map +2 -2
  9. package/Field/types.d.ts +36 -3
  10. package/Field/utils/calculateField/index.js +27 -0
  11. package/{inputs/Input/__stories__/Default → Field/utils/calculateField}/package.json +1 -1
  12. package/Field/utils/calculateField.d.ts +2 -0
  13. package/Field/utils/calculateField.js.map +7 -0
  14. package/Field/utils/evaluateFieldWithConditions/index.js +26 -0
  15. package/Field/utils/evaluateFieldWithConditions/package.json +6 -0
  16. package/Field/utils/evaluateFieldWithConditions.d.ts +2 -0
  17. package/Field/utils/evaluateFieldWithConditions.js.map +7 -0
  18. package/Field/utils/index.d.ts +3 -0
  19. package/Field/utils/index.js +4 -95
  20. package/Field/utils/index.js.map +7 -0
  21. package/Field/utils/useField/index.js +51 -0
  22. package/{FormBuilder/FormBuilder → Field/utils/useField}/package.json +1 -1
  23. package/Field/utils/useField.d.ts +2 -0
  24. package/Field/utils/useField.js.map +7 -0
  25. package/FieldArray/FieldArray.stories/index.js +4 -2
  26. package/FieldArray/FieldArray.stories.d.ts +2 -2
  27. package/FieldArray/FieldArray.stories.js.map +2 -2
  28. package/FieldArray/__stories__/Default/index.js +15 -17
  29. package/FieldArray/__stories__/Default.d.ts +2 -2
  30. package/FieldArray/__stories__/Default.js.map +1 -1
  31. package/FieldArray/__stories__/WithExactLength/index.js +15 -17
  32. package/FieldArray/__stories__/WithExactLength.d.ts +2 -2
  33. package/FieldArray/__stories__/WithExactLength.js.map +1 -1
  34. package/FieldArray/index.js +50 -32
  35. package/FieldArray/index.js.map +2 -2
  36. package/FieldArray/index.test.d.ts +1 -0
  37. package/FieldObject/index.d.ts +1 -0
  38. package/FieldObject/index.js +41 -29
  39. package/FieldObject/index.js.map +2 -2
  40. package/Fieldset/FieldsetWithContext/index.js +12 -13
  41. package/Fieldset/FieldsetWithContext.js.map +1 -1
  42. package/Fieldset/index.js +4 -13
  43. package/Fieldset/index.js.map +1 -1
  44. package/Fieldset/types.d.ts +2 -0
  45. package/Form.stories.js.map +1 -1
  46. package/FormBuilder/FormBuilder.stories/index.js +2 -1
  47. package/FormBuilder/FormBuilder.stories.d.ts +1 -1
  48. package/FormBuilder/FormBuilder.stories.js.map +2 -2
  49. package/FormBuilder/__stories__/Default/index.js +21 -15
  50. package/FormBuilder/__stories__/Default.d.ts +2 -2
  51. package/FormBuilder/__stories__/Default.js.map +1 -1
  52. package/FormBuilder/index.d.ts +2 -1
  53. package/FormBuilder/index.js +10 -2
  54. package/FormBuilder/index.js.map +2 -2
  55. package/FormBuilder/index.test.d.ts +1 -0
  56. package/FormBuilder/scenarios.test.d.ts +88 -0
  57. package/FormContext/index.js +1 -1
  58. package/FormContext.js.map +1 -1
  59. package/MultiplicityField/MultiplicityField.stories/index.js +12 -6
  60. package/MultiplicityField/MultiplicityField.stories.d.ts +6 -6
  61. package/MultiplicityField/MultiplicityField.stories.js.map +2 -2
  62. package/MultiplicityField/__stories__/Default/index.js +15 -19
  63. package/MultiplicityField/__stories__/Default.d.ts +2 -2
  64. package/MultiplicityField/__stories__/Default.js.map +1 -1
  65. package/MultiplicityField/__stories__/PreviewDisplay/index.js +6 -27
  66. package/MultiplicityField/__stories__/PreviewDisplay.d.ts +2 -2
  67. package/MultiplicityField/__stories__/PreviewDisplay.js.map +2 -2
  68. package/MultiplicityField/__stories__/WithExactLength/index.js +15 -19
  69. package/MultiplicityField/__stories__/WithExactLength.d.ts +2 -2
  70. package/MultiplicityField/__stories__/WithExactLength.js.map +2 -2
  71. package/MultiplicityField/__stories__/WithMaxLength/index.js +15 -19
  72. package/MultiplicityField/__stories__/WithMaxLength.d.ts +2 -2
  73. package/MultiplicityField/__stories__/WithMaxLength.js.map +2 -2
  74. package/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +15 -19
  75. package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +2 -2
  76. package/MultiplicityField/__stories__/WithMinAndMaxLength.js.map +2 -2
  77. package/MultiplicityField/__stories__/WithMinLength/index.js +15 -19
  78. package/MultiplicityField/__stories__/WithMinLength.d.ts +2 -2
  79. package/MultiplicityField/__stories__/WithMinLength.js.map +2 -2
  80. package/MultiplicityField/add-objects/index.js +71 -39
  81. package/MultiplicityField/add-objects.d.ts +2 -1
  82. package/MultiplicityField/add-objects.js.map +2 -2
  83. package/MultiplicityField/index.d.ts +2 -19
  84. package/MultiplicityField/index.js +66 -59
  85. package/MultiplicityField/index.js.map +2 -2
  86. package/MultiplicityField/index.test.d.ts +1 -0
  87. package/MultiplicityField/types/index.js +1 -0
  88. package/{validators/validators.spec → MultiplicityField/types}/package.json +1 -1
  89. package/MultiplicityField/types.d.ts +19 -0
  90. package/MultiplicityField/types.js.map +7 -0
  91. package/Questions/Questions/index.js +21 -15
  92. package/Questions/Questions.js.map +2 -2
  93. package/Questions/Questions.stories/index.js +2 -1
  94. package/Questions/Questions.stories.d.ts +1 -1
  95. package/Questions/Questions.stories.js.map +2 -2
  96. package/Questions/QuestionsContext/index.js +2 -2
  97. package/Questions/QuestionsContext.js.map +1 -1
  98. package/Questions/Step/ReviewStep/index.js +20 -26
  99. package/Questions/Step/ReviewStep.js.map +1 -1
  100. package/Questions/Step/Step/index.js +24 -18
  101. package/Questions/Step/Step.js.map +2 -2
  102. package/Questions/Step/StepArrayReview/index.js +20 -25
  103. package/Questions/Step/StepArrayReview.js.map +1 -1
  104. package/Questions/Step/StepContext/index.js +3 -3
  105. package/Questions/Step/StepContext.js.map +1 -1
  106. package/Questions/Step/StepDescription/index.js +7 -12
  107. package/Questions/Step/StepDescription.js.map +1 -1
  108. package/Questions/Step/StepForm/index.js +16 -19
  109. package/Questions/Step/StepForm.js.map +1 -1
  110. package/Questions/Step/StepQuote/index.js +2 -4
  111. package/Questions/Step/StepQuote.js.map +1 -1
  112. package/Questions/Step/StepTitle/index.js +17 -15
  113. package/Questions/Step/StepTitle.d.ts +1 -0
  114. package/Questions/Step/StepTitle.js.map +2 -2
  115. package/Questions/Step/getAddMoreFields.js.map +1 -1
  116. package/Questions/Step/index.d.ts +0 -1
  117. package/Questions/Step/index.js +0 -1
  118. package/Questions/Step/index.js.map +2 -2
  119. package/Questions/Step/types.d.ts +2 -0
  120. package/Questions/__stories__/Default/index.js +31 -38
  121. package/Questions/__stories__/Default.d.ts +2 -2
  122. package/Questions/__stories__/Default.js.map +1 -1
  123. package/Questions/getNextStep/index.js +3 -1
  124. package/Questions/getNextStep.js.map +1 -1
  125. package/Questions/index.js +1 -1
  126. package/Questions/index.js.map +1 -1
  127. package/Questions/index.test.d.ts +1 -0
  128. package/Questions/types.d.ts +2 -0
  129. package/cjs/Field/FieldBase/index.js +95 -68
  130. package/cjs/Field/FieldBase.js.map +3 -3
  131. package/cjs/Field/FieldBaseContainer/index.js +33 -41
  132. package/cjs/Field/FieldBaseContainer.js.map +2 -2
  133. package/cjs/Field/FieldConditional/index.js +77 -56
  134. package/cjs/Field/FieldConditional.js.map +3 -3
  135. package/cjs/Field/index.js +89 -55
  136. package/cjs/Field/index.js.map +3 -3
  137. package/cjs/Field/types/index.js +14 -2
  138. package/cjs/Field/types.js.map +2 -2
  139. package/cjs/Field/utils/calculateField/index.js +50 -0
  140. package/cjs/Field/utils/calculateField.js.map +7 -0
  141. package/cjs/Field/utils/evaluateFieldWithConditions/index.js +49 -0
  142. package/cjs/Field/utils/evaluateFieldWithConditions.js.map +7 -0
  143. package/cjs/Field/utils/index.js +35 -121
  144. package/cjs/Field/utils/index.js.map +7 -0
  145. package/cjs/Field/utils/useField/index.js +74 -0
  146. package/cjs/Field/utils/useField.js.map +7 -0
  147. package/cjs/FieldArray/FieldArray.stories/index.js +30 -19
  148. package/cjs/FieldArray/FieldArray.stories.js.map +3 -3
  149. package/cjs/FieldArray/__stories__/Default/index.js +37 -33
  150. package/cjs/FieldArray/__stories__/Default.js.map +2 -2
  151. package/cjs/FieldArray/__stories__/WithExactLength/index.js +37 -33
  152. package/cjs/FieldArray/__stories__/WithExactLength.js.map +2 -2
  153. package/cjs/FieldArray/index.js +75 -51
  154. package/cjs/FieldArray/index.js.map +3 -3
  155. package/cjs/FieldObject/index.js +59 -44
  156. package/cjs/FieldObject/index.js.map +3 -3
  157. package/cjs/Fieldset/FieldsetWithContext/index.js +35 -30
  158. package/cjs/Fieldset/FieldsetWithContext.js.map +2 -2
  159. package/cjs/Fieldset/index.js +31 -34
  160. package/cjs/Fieldset/index.js.map +2 -2
  161. package/cjs/Fieldset/types/index.js +14 -2
  162. package/cjs/Fieldset/types.js.map +2 -2
  163. package/cjs/Form.stories/index.js +16 -6
  164. package/cjs/Form.stories.js.map +1 -1
  165. package/cjs/FormBuilder/FormBuilder.stories/index.js +27 -18
  166. package/cjs/FormBuilder/FormBuilder.stories.js.map +3 -3
  167. package/cjs/FormBuilder/__stories__/Default/index.js +43 -31
  168. package/cjs/FormBuilder/__stories__/Default.js.map +2 -2
  169. package/cjs/FormBuilder/index.js +24 -21
  170. package/cjs/FormBuilder/index.js.map +2 -2
  171. package/cjs/FormContext/index.js +14 -18
  172. package/cjs/FormContext.js.map +2 -2
  173. package/cjs/MultiplicityField/MultiplicityField.stories/index.js +42 -23
  174. package/cjs/MultiplicityField/MultiplicityField.stories.js.map +3 -3
  175. package/cjs/MultiplicityField/__stories__/Default/index.js +37 -35
  176. package/cjs/MultiplicityField/__stories__/Default.js.map +2 -2
  177. package/cjs/MultiplicityField/__stories__/PreviewDisplay/index.js +32 -47
  178. package/cjs/MultiplicityField/__stories__/PreviewDisplay.js.map +3 -3
  179. package/cjs/MultiplicityField/__stories__/WithExactLength/index.js +37 -35
  180. package/cjs/MultiplicityField/__stories__/WithExactLength.js.map +3 -3
  181. package/cjs/MultiplicityField/__stories__/WithMaxLength/index.js +37 -35
  182. package/cjs/MultiplicityField/__stories__/WithMaxLength.js.map +3 -3
  183. package/cjs/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +37 -35
  184. package/cjs/MultiplicityField/__stories__/WithMinAndMaxLength.js.map +3 -3
  185. package/cjs/MultiplicityField/__stories__/WithMinLength/index.js +37 -35
  186. package/cjs/MultiplicityField/__stories__/WithMinLength.js.map +3 -3
  187. package/cjs/MultiplicityField/add-objects/index.js +94 -59
  188. package/cjs/MultiplicityField/add-objects.js.map +3 -3
  189. package/cjs/MultiplicityField/index.js +90 -77
  190. package/cjs/MultiplicityField/index.js.map +3 -3
  191. package/cjs/MultiplicityField/types/index.js +16 -0
  192. package/cjs/MultiplicityField/types.js.map +7 -0
  193. package/cjs/Questions/Questions/index.js +42 -30
  194. package/cjs/Questions/Questions.js.map +2 -2
  195. package/cjs/Questions/Questions.stories/index.js +27 -18
  196. package/cjs/Questions/Questions.stories.js.map +3 -3
  197. package/cjs/Questions/QuestionsContext/index.js +15 -19
  198. package/cjs/Questions/QuestionsContext.js.map +1 -1
  199. package/cjs/Questions/Step/ReviewStep/index.js +43 -43
  200. package/cjs/Questions/Step/ReviewStep.js.map +2 -2
  201. package/cjs/Questions/Step/Step/index.js +45 -33
  202. package/cjs/Questions/Step/Step.js.map +2 -2
  203. package/cjs/Questions/Step/StepArrayReview/index.js +46 -45
  204. package/cjs/Questions/Step/StepArrayReview.js.map +2 -2
  205. package/cjs/Questions/Step/StepContext/index.js +16 -20
  206. package/cjs/Questions/Step/StepContext.js.map +1 -1
  207. package/cjs/Questions/Step/StepDescription/index.js +29 -28
  208. package/cjs/Questions/Step/StepDescription.js.map +2 -2
  209. package/cjs/Questions/Step/StepForm/index.js +41 -38
  210. package/cjs/Questions/Step/StepForm.js.map +2 -2
  211. package/cjs/Questions/Step/StepQuote/index.js +25 -21
  212. package/cjs/Questions/Step/StepQuote.js.map +2 -2
  213. package/cjs/Questions/Step/StepTitle/index.js +41 -33
  214. package/cjs/Questions/Step/StepTitle.js.map +3 -3
  215. package/cjs/Questions/Step/getAddMoreFields/index.js +16 -4
  216. package/cjs/Questions/Step/getAddMoreFields.js.map +1 -1
  217. package/cjs/Questions/Step/index.js +45 -28
  218. package/cjs/Questions/Step/index.js.map +3 -3
  219. package/cjs/Questions/Step/types/index.js +14 -2
  220. package/cjs/Questions/Step/types.js.map +2 -2
  221. package/cjs/Questions/__stories__/Default/index.js +59 -60
  222. package/cjs/Questions/__stories__/Default.js.map +2 -2
  223. package/cjs/Questions/getNextStep/index.js +19 -5
  224. package/cjs/Questions/getNextStep.js.map +1 -1
  225. package/cjs/Questions/index.js +19 -20
  226. package/cjs/Questions/index.js.map +1 -1
  227. package/cjs/Questions/types/index.js +14 -2
  228. package/cjs/Questions/types.js.map +2 -2
  229. package/cjs/index.js +180 -19
  230. package/cjs/index.js.map +4 -4
  231. package/cjs/inputs/AutoCompleteInput/AutoComplete.stories/index.js +30 -19
  232. package/cjs/inputs/AutoCompleteInput/AutoComplete.stories.js.map +3 -3
  233. package/cjs/inputs/AutoCompleteInput/__stories__/Default/index.js +46 -36
  234. package/cjs/inputs/AutoCompleteInput/__stories__/Default.js.map +3 -3
  235. package/cjs/inputs/AutoCompleteInput/__stories__/Multiple/index.js +50 -38
  236. package/cjs/inputs/AutoCompleteInput/__stories__/Multiple.js.map +3 -3
  237. package/cjs/inputs/AutoCompleteInput/index.js +67 -42
  238. package/cjs/inputs/AutoCompleteInput/index.js.map +3 -3
  239. package/cjs/inputs/Checkboxes/Checkboxes.stories/index.js +33 -20
  240. package/cjs/inputs/Checkboxes/Checkboxes.stories.js.map +3 -3
  241. package/cjs/inputs/Checkboxes/__stories__/Conditional/index.js +35 -29
  242. package/cjs/inputs/Checkboxes/__stories__/Conditional.js.map +2 -2
  243. package/cjs/inputs/Checkboxes/__stories__/Default/index.js +58 -46
  244. package/cjs/inputs/Checkboxes/__stories__/Default.js.map +2 -2
  245. package/cjs/inputs/Checkboxes/__stories__/WithDivider/index.js +59 -47
  246. package/cjs/inputs/Checkboxes/__stories__/WithDivider.js.map +2 -2
  247. package/cjs/inputs/Checkboxes/index.js +70 -62
  248. package/cjs/inputs/Checkboxes/index.js.map +3 -3
  249. package/cjs/inputs/DateInput/DateInput.stories/index.js +27 -18
  250. package/cjs/inputs/DateInput/DateInput.stories.js.map +3 -3
  251. package/cjs/inputs/DateInput/__stories__/Default/index.js +41 -32
  252. package/cjs/inputs/DateInput/__stories__/Default.js.map +3 -3
  253. package/cjs/inputs/DateInput/index.js +73 -60
  254. package/cjs/inputs/DateInput/index.js.map +3 -3
  255. package/cjs/inputs/FileInput/FileInput.stories/index.js +27 -18
  256. package/cjs/inputs/FileInput/FileInput.stories.js.map +3 -3
  257. package/cjs/inputs/FileInput/__stories__/Default/index.js +43 -29
  258. package/cjs/inputs/FileInput/__stories__/Default.js.map +2 -2
  259. package/cjs/inputs/FileInput/index.js +56 -42
  260. package/cjs/inputs/FileInput/index.js.map +2 -2
  261. package/cjs/inputs/ImageInput/ImageInput.stories/index.js +33 -20
  262. package/cjs/inputs/ImageInput/ImageInput.stories.js.map +3 -3
  263. package/cjs/inputs/ImageInput/__stories__/Default/index.js +35 -29
  264. package/cjs/inputs/ImageInput/__stories__/Default.js.map +2 -2
  265. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +35 -29
  266. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +2 -2
  267. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +35 -29
  268. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageSize.js.map +2 -2
  269. package/cjs/inputs/ImageInput/index.js +72 -66
  270. package/cjs/inputs/ImageInput/index.js.map +2 -2
  271. package/cjs/inputs/Input/Input.stories/index.js +54 -27
  272. package/cjs/inputs/Input/Input.stories.js.map +3 -3
  273. package/cjs/inputs/Input/__stories__/AFM/index.js +44 -32
  274. package/cjs/inputs/Input/__stories__/AFM.js.map +2 -2
  275. package/cjs/inputs/Input/__stories__/Boolean/index.js +45 -33
  276. package/cjs/inputs/Input/__stories__/Boolean.js.map +2 -2
  277. package/cjs/inputs/Input/__stories__/IBAN/index.js +45 -33
  278. package/cjs/inputs/Input/__stories__/IBAN.js.map +2 -2
  279. package/cjs/inputs/Input/__stories__/Integer/index.js +57 -41
  280. package/cjs/inputs/Input/__stories__/Integer.js.map +2 -2
  281. package/cjs/inputs/Input/__stories__/LandlineNumber/index.js +48 -36
  282. package/cjs/inputs/Input/__stories__/LandlineNumber.js.map +2 -2
  283. package/cjs/inputs/Input/__stories__/MobilePhone/index.js +48 -36
  284. package/cjs/inputs/Input/__stories__/MobilePhone.js.map +2 -2
  285. package/cjs/inputs/Input/__stories__/PhoneNumber/index.js +47 -35
  286. package/cjs/inputs/Input/__stories__/PhoneNumber.js.map +2 -2
  287. package/cjs/inputs/Input/__stories__/PostalCode/index.js +45 -33
  288. package/cjs/inputs/Input/__stories__/PostalCode.js.map +2 -2
  289. package/cjs/inputs/Input/__stories__/String/index.js +64 -0
  290. package/cjs/inputs/Input/__stories__/String.js.map +7 -0
  291. package/cjs/inputs/Input/__stories__/TextWithLimit/index.js +64 -0
  292. package/cjs/inputs/Input/__stories__/TextWithLimit.js.map +7 -0
  293. package/cjs/inputs/Input/index.js +65 -53
  294. package/cjs/inputs/Input/index.js.map +2 -2
  295. package/cjs/inputs/Input/inputsInputScenarios/index.js +439 -0
  296. package/cjs/inputs/Input/inputsInputScenarios.js.map +7 -0
  297. package/cjs/inputs/Label/Label.stories/index.js +27 -18
  298. package/cjs/inputs/Label/Label.stories.js.map +3 -3
  299. package/cjs/inputs/Label/__stories__/Default/index.js +54 -36
  300. package/cjs/inputs/Label/__stories__/Default.js.map +3 -3
  301. package/cjs/inputs/Label/index.js +28 -28
  302. package/cjs/inputs/Label/index.js.map +3 -3
  303. package/cjs/inputs/OtpInput/OtpInput.stories/index.js +27 -18
  304. package/cjs/inputs/OtpInput/OtpInput.stories.js.map +3 -3
  305. package/cjs/inputs/OtpInput/__stories__/Default/index.js +35 -29
  306. package/cjs/inputs/OtpInput/__stories__/Default.js.map +2 -2
  307. package/cjs/inputs/OtpInput/index.js +118 -94
  308. package/cjs/inputs/OtpInput/index.js.map +3 -3
  309. package/cjs/inputs/Radio/Radio.stories/index.js +33 -20
  310. package/cjs/inputs/Radio/Radio.stories.js.map +3 -3
  311. package/cjs/inputs/Radio/__stories__/Conditional/index.js +35 -29
  312. package/cjs/inputs/Radio/__stories__/Conditional.js.map +2 -2
  313. package/cjs/inputs/Radio/__stories__/Default/index.js +62 -50
  314. package/cjs/inputs/Radio/__stories__/Default.js.map +2 -2
  315. package/cjs/inputs/Radio/__stories__/WithDivider/index.js +63 -51
  316. package/cjs/inputs/Radio/__stories__/WithDivider.js.map +2 -2
  317. package/cjs/inputs/Radio/index.js +61 -55
  318. package/cjs/inputs/Radio/index.js.map +3 -3
  319. package/cjs/inputs/Select/Select.stories/index.js +27 -18
  320. package/cjs/inputs/Select/Select.stories.js.map +3 -3
  321. package/cjs/inputs/Select/__stories__/Default/index.js +67 -55
  322. package/cjs/inputs/Select/__stories__/Default.js.map +2 -2
  323. package/cjs/inputs/Select/index.js +39 -30
  324. package/cjs/inputs/Select/index.js.map +2 -2
  325. package/cjs/inputs/index.js +30 -24
  326. package/cjs/inputs/index.js.map +1 -1
  327. package/cjs/inputs/inputsScenarios/index.js +540 -0
  328. package/cjs/inputs/inputsScenarios.js.map +7 -0
  329. package/cjs/internal/index.js +24 -77
  330. package/cjs/internal.js.map +2 -2
  331. package/cjs/lazy/index.js +81 -74
  332. package/cjs/lazy.js.map +3 -3
  333. package/cjs/locales/el/index.js +35 -0
  334. package/cjs/locales/el.js.map +7 -0
  335. package/cjs/registry/index.js +107 -88
  336. package/cjs/registry.js.map +2 -2
  337. package/cjs/types/index.js +20 -2
  338. package/cjs/types.js.map +2 -2
  339. package/cjs/utils/index.js +47 -34
  340. package/cjs/utils.js.map +3 -3
  341. package/cjs/validators/index.js +34 -30
  342. package/cjs/validators/index.js.map +3 -3
  343. package/cjs/validators/types/index.js +14 -2
  344. package/cjs/validators/types.js.map +1 -1
  345. package/cjs/validators/utils/afm/index.js +16 -4
  346. package/cjs/validators/utils/afm.js.map +1 -1
  347. package/cjs/validators/utils/file/index.js +25 -13
  348. package/cjs/validators/utils/file.js.map +2 -2
  349. package/cjs/validators/utils/iban/index.js +16 -4
  350. package/cjs/validators/utils/iban.js.map +1 -1
  351. package/cjs/validators/utils/image/index.js +18 -6
  352. package/cjs/validators/utils/image.js.map +1 -1
  353. package/cjs/validators/utils/index.js +52 -28
  354. package/cjs/validators/utils/index.js.map +1 -1
  355. package/cjs/validators/utils/int/index.js +16 -4
  356. package/cjs/validators/utils/int.js.map +1 -1
  357. package/cjs/validators/utils/number/index.js +16 -4
  358. package/cjs/validators/utils/number.js.map +1 -1
  359. package/cjs/validators/utils/otp/index.js +16 -4
  360. package/cjs/validators/utils/otp.js.map +1 -1
  361. package/cjs/validators/utils/phone/index.js +25 -6
  362. package/cjs/validators/utils/phone.js.map +2 -2
  363. package/cjs/validators/utils/postal_code/index.js +16 -4
  364. package/cjs/validators/utils/postal_code.js.map +1 -1
  365. package/cjs/validators/utils/text_limit/index.js +18 -6
  366. package/cjs/validators/utils/text_limit.js.map +1 -1
  367. package/cjs/validators/utils/uuid4/index.js +16 -4
  368. package/cjs/validators/utils/uuid4.js.map +1 -1
  369. package/index.d.ts +7 -1
  370. package/index.js +151 -3
  371. package/index.js.map +4 -4
  372. package/inputs/AutoCompleteInput/AutoComplete.stories/index.js +4 -2
  373. package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +2 -2
  374. package/inputs/AutoCompleteInput/AutoComplete.stories.js.map +2 -2
  375. package/inputs/AutoCompleteInput/__stories__/Default/index.js +22 -18
  376. package/inputs/AutoCompleteInput/__stories__/Default.d.ts +2 -2
  377. package/inputs/AutoCompleteInput/__stories__/Default.js.map +2 -2
  378. package/inputs/AutoCompleteInput/__stories__/Multiple/index.js +26 -20
  379. package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +3 -2
  380. package/inputs/AutoCompleteInput/__stories__/Multiple.js.map +2 -2
  381. package/inputs/AutoCompleteInput/index.d.ts +1 -1
  382. package/inputs/AutoCompleteInput/index.js +45 -26
  383. package/inputs/AutoCompleteInput/index.js.map +3 -3
  384. package/inputs/AutoCompleteInput/index.test.d.ts +1 -0
  385. package/inputs/Checkboxes/Checkboxes.stories/index.js +6 -3
  386. package/inputs/Checkboxes/Checkboxes.stories.d.ts +3 -3
  387. package/inputs/Checkboxes/Checkboxes.stories.js.map +2 -2
  388. package/inputs/Checkboxes/__stories__/Conditional/index.js +13 -13
  389. package/inputs/Checkboxes/__stories__/Conditional.d.ts +2 -2
  390. package/inputs/Checkboxes/__stories__/Conditional.js.map +1 -1
  391. package/inputs/Checkboxes/__stories__/Default/index.js +36 -30
  392. package/inputs/Checkboxes/__stories__/Default.d.ts +2 -2
  393. package/inputs/Checkboxes/__stories__/Default.js.map +1 -1
  394. package/inputs/Checkboxes/__stories__/WithDivider/index.js +37 -31
  395. package/inputs/Checkboxes/__stories__/WithDivider.d.ts +2 -2
  396. package/inputs/Checkboxes/__stories__/WithDivider.js.map +1 -1
  397. package/inputs/Checkboxes/index.d.ts +1 -0
  398. package/inputs/Checkboxes/index.js +46 -44
  399. package/inputs/Checkboxes/index.js.map +2 -2
  400. package/inputs/Checkboxes/index.test.d.ts +1 -0
  401. package/inputs/DateInput/DateInput.stories/index.js +2 -1
  402. package/inputs/DateInput/DateInput.stories.d.ts +1 -1
  403. package/inputs/DateInput/DateInput.stories.js.map +2 -2
  404. package/inputs/DateInput/__stories__/Default/index.js +19 -16
  405. package/inputs/DateInput/__stories__/Default.d.ts +2 -2
  406. package/inputs/DateInput/__stories__/Default.js.map +2 -2
  407. package/inputs/DateInput/index.d.ts +2 -2
  408. package/inputs/DateInput/index.js +48 -41
  409. package/inputs/DateInput/index.js.map +3 -3
  410. package/inputs/DateInput/index.test.d.ts +1 -0
  411. package/inputs/FileInput/FileInput.stories/index.js +2 -1
  412. package/inputs/FileInput/FileInput.stories.d.ts +1 -1
  413. package/inputs/FileInput/FileInput.stories.js.map +2 -2
  414. package/inputs/FileInput/__stories__/Default/index.js +21 -13
  415. package/inputs/FileInput/__stories__/Default.d.ts +2 -2
  416. package/inputs/FileInput/__stories__/Default.js.map +1 -1
  417. package/inputs/FileInput/index.js +30 -22
  418. package/inputs/FileInput/index.js.map +2 -2
  419. package/inputs/FileInput/index.test.d.ts +1 -0
  420. package/inputs/ImageInput/ImageInput.stories/index.js +6 -3
  421. package/inputs/ImageInput/ImageInput.stories.d.ts +3 -3
  422. package/inputs/ImageInput/ImageInput.stories.js.map +2 -2
  423. package/inputs/ImageInput/__stories__/Default/index.js +13 -13
  424. package/inputs/ImageInput/__stories__/Default.d.ts +2 -2
  425. package/inputs/ImageInput/__stories__/Default.js.map +1 -1
  426. package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +13 -13
  427. package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +2 -2
  428. package/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +1 -1
  429. package/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +13 -13
  430. package/inputs/ImageInput/__stories__/WithInvalidImageSize.d.ts +2 -2
  431. package/inputs/ImageInput/__stories__/WithInvalidImageSize.js.map +1 -1
  432. package/inputs/ImageInput/index.js +47 -47
  433. package/inputs/ImageInput/index.js.map +2 -2
  434. package/inputs/ImageInput/index.test.d.ts +1 -0
  435. package/inputs/Input/Input.stories/index.js +20 -10
  436. package/inputs/Input/Input.stories.d.ts +10 -10
  437. package/inputs/Input/Input.stories.js.map +2 -2
  438. package/inputs/Input/__stories__/AFM/index.js +22 -16
  439. package/inputs/Input/__stories__/AFM.d.ts +2 -2
  440. package/inputs/Input/__stories__/AFM.js.map +1 -1
  441. package/inputs/Input/__stories__/Boolean/index.js +23 -17
  442. package/inputs/Input/__stories__/Boolean.d.ts +2 -2
  443. package/inputs/Input/__stories__/Boolean.js.map +1 -1
  444. package/inputs/Input/__stories__/IBAN/index.js +23 -17
  445. package/inputs/Input/__stories__/IBAN.d.ts +2 -2
  446. package/inputs/Input/__stories__/IBAN.js.map +1 -1
  447. package/inputs/Input/__stories__/Integer/index.js +35 -25
  448. package/inputs/Input/__stories__/Integer.d.ts +2 -2
  449. package/inputs/Input/__stories__/Integer.js.map +1 -1
  450. package/inputs/Input/__stories__/LandlineNumber/index.js +26 -20
  451. package/inputs/Input/__stories__/LandlineNumber.d.ts +2 -2
  452. package/inputs/Input/__stories__/LandlineNumber.js.map +1 -1
  453. package/inputs/Input/__stories__/MobilePhone/index.js +26 -20
  454. package/inputs/Input/__stories__/MobilePhone.d.ts +2 -2
  455. package/inputs/Input/__stories__/MobilePhone.js.map +1 -1
  456. package/inputs/Input/__stories__/PhoneNumber/index.js +25 -19
  457. package/inputs/Input/__stories__/PhoneNumber.d.ts +2 -2
  458. package/inputs/Input/__stories__/PhoneNumber.js.map +1 -1
  459. package/inputs/Input/__stories__/PostalCode/index.js +23 -17
  460. package/inputs/Input/__stories__/PostalCode.d.ts +2 -2
  461. package/inputs/Input/__stories__/PostalCode.js.map +1 -1
  462. package/inputs/Input/__stories__/String/index.js +31 -0
  463. package/inputs/Input/__stories__/String/package.json +6 -0
  464. package/inputs/Input/__stories__/String.d.ts +3 -0
  465. package/inputs/Input/__stories__/String.js.map +7 -0
  466. package/inputs/Input/__stories__/TextWithLimit/index.js +31 -0
  467. package/inputs/Input/__stories__/TextWithLimit/package.json +6 -0
  468. package/inputs/Input/__stories__/TextWithLimit.d.ts +3 -0
  469. package/inputs/Input/__stories__/TextWithLimit.js.map +7 -0
  470. package/inputs/Input/index.js +41 -35
  471. package/inputs/Input/index.js.map +1 -1
  472. package/inputs/Input/index.test.d.ts +1 -0
  473. package/inputs/Input/inputsInputScenarios/index.js +406 -0
  474. package/inputs/Input/inputsInputScenarios/package.json +6 -0
  475. package/inputs/Input/inputsInputScenarios.d.ts +57 -0
  476. package/inputs/Input/inputsInputScenarios.js.map +7 -0
  477. package/inputs/Label/Label.stories/index.js +2 -1
  478. package/inputs/Label/Label.stories.d.ts +1 -1
  479. package/inputs/Label/Label.stories.js.map +2 -2
  480. package/inputs/Label/__stories__/Default/index.js +32 -20
  481. package/inputs/Label/__stories__/Default.d.ts +2 -2
  482. package/inputs/Label/__stories__/Default.js.map +2 -2
  483. package/inputs/Label/index.d.ts +1 -1
  484. package/inputs/Label/index.js +4 -10
  485. package/inputs/Label/index.js.map +2 -2
  486. package/inputs/Label/index.test.d.ts +1 -0
  487. package/inputs/OtpInput/OtpInput.stories/index.js +2 -1
  488. package/inputs/OtpInput/OtpInput.stories.d.ts +1 -1
  489. package/inputs/OtpInput/OtpInput.stories.js.map +2 -2
  490. package/inputs/OtpInput/__stories__/Default/index.js +13 -13
  491. package/inputs/OtpInput/__stories__/Default.d.ts +2 -2
  492. package/inputs/OtpInput/__stories__/Default.js.map +1 -1
  493. package/inputs/OtpInput/index.d.ts +9 -2
  494. package/inputs/OtpInput/index.js +94 -77
  495. package/inputs/OtpInput/index.js.map +2 -2
  496. package/inputs/OtpInput/index.test.d.ts +1 -0
  497. package/inputs/Radio/Radio.stories/index.js +6 -3
  498. package/inputs/Radio/Radio.stories.d.ts +3 -3
  499. package/inputs/Radio/Radio.stories.js.map +2 -2
  500. package/inputs/Radio/__stories__/Conditional/index.js +13 -13
  501. package/inputs/Radio/__stories__/Conditional.d.ts +2 -2
  502. package/inputs/Radio/__stories__/Conditional.js.map +1 -1
  503. package/inputs/Radio/__stories__/Default/index.js +40 -34
  504. package/inputs/Radio/__stories__/Default.d.ts +2 -2
  505. package/inputs/Radio/__stories__/Default.js.map +1 -1
  506. package/inputs/Radio/__stories__/WithDivider/index.js +41 -35
  507. package/inputs/Radio/__stories__/WithDivider.d.ts +2 -2
  508. package/inputs/Radio/__stories__/WithDivider.js.map +1 -1
  509. package/inputs/Radio/index.d.ts +1 -0
  510. package/inputs/Radio/index.js +36 -36
  511. package/inputs/Radio/index.js.map +2 -2
  512. package/inputs/Radio/index.test.d.ts +1 -0
  513. package/inputs/Select/Select.stories/index.js +2 -1
  514. package/inputs/Select/Select.stories.d.ts +1 -1
  515. package/inputs/Select/Select.stories.js.map +2 -2
  516. package/inputs/Select/__stories__/Default/index.js +45 -39
  517. package/inputs/Select/__stories__/Default.d.ts +2 -2
  518. package/inputs/Select/__stories__/Default.js.map +1 -1
  519. package/inputs/Select/index.js +15 -12
  520. package/inputs/Select/index.js.map +1 -1
  521. package/inputs/Select/index.test.d.ts +1 -0
  522. package/inputs/index.js +9 -9
  523. package/inputs/index.js.map +2 -2
  524. package/inputs/inputsScenarios/index.js +506 -0
  525. package/inputs/inputsScenarios/package.json +6 -0
  526. package/inputs/inputsScenarios.d.ts +338 -0
  527. package/inputs/inputsScenarios.js.map +7 -0
  528. package/internal/index.js +4 -45
  529. package/internal.d.ts +2 -31
  530. package/internal.js.map +2 -2
  531. package/lazy/index.js +60 -57
  532. package/lazy.d.ts +33 -30
  533. package/lazy.js.map +2 -2
  534. package/locales/el/index.js +6 -0
  535. package/{Questions/index.spec → locales/el}/package.json +1 -1
  536. package/locales/el.d.ts +2 -0
  537. package/locales/el.js.map +7 -0
  538. package/package.json +7 -7
  539. package/registry/index.js +26 -11
  540. package/registry.d.ts +7 -1
  541. package/registry.js.map +2 -2
  542. package/src/Field/FieldBase.tsx +1 -0
  543. package/src/Field/FieldConditional.tsx +1 -1
  544. package/src/Field/index.tsx +19 -3
  545. package/src/Field/types.tsx +64 -3
  546. package/src/Field/utils/calculateField.ts +49 -0
  547. package/src/Field/utils/evaluateFieldWithConditions.ts +30 -0
  548. package/src/Field/utils/index.ts +59 -0
  549. package/src/Field/utils/useField.ts +54 -0
  550. package/src/FieldArray/FieldArray.stories.js +2 -2
  551. package/src/FieldArray/index.test.tsx +24 -0
  552. package/src/FieldArray/index.tsx +11 -3
  553. package/src/FieldObject/index.tsx +10 -3
  554. package/src/Fieldset/types.tsx +3 -1
  555. package/src/FormBuilder/FormBuilder.stories.js +1 -1
  556. package/src/FormBuilder/index.test.tsx +20 -0
  557. package/src/FormBuilder/index.tsx +7 -2
  558. package/src/FormBuilder/scenarios.test.tsx +1864 -0
  559. package/src/MultiplicityField/MultiplicityField.stories.js +6 -6
  560. package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +2 -2
  561. package/src/MultiplicityField/__stories__/WithExactLength.tsx +1 -1
  562. package/src/MultiplicityField/__stories__/WithMaxLength.tsx +1 -1
  563. package/src/MultiplicityField/__stories__/WithMinAndMaxLength.tsx +1 -1
  564. package/src/MultiplicityField/__stories__/WithMinLength.tsx +1 -1
  565. package/src/MultiplicityField/add-objects.tsx +23 -9
  566. package/src/MultiplicityField/index.test.tsx +40 -0
  567. package/src/MultiplicityField/index.tsx +9 -26
  568. package/src/MultiplicityField/types.ts +22 -0
  569. package/src/Questions/Questions.stories.js +1 -1
  570. package/src/Questions/Step/StepTitle.tsx +1 -0
  571. package/src/Questions/Step/index.ts +0 -1
  572. package/src/Questions/Step/types.tsx +1 -0
  573. package/src/Questions/__snapshots__/index.spec.tsx.snap +67 -586
  574. package/src/Questions/index.mdx +4 -4
  575. package/src/Questions/index.spec.tsx +3 -3
  576. package/src/Questions/index.test.tsx +20 -0
  577. package/src/Questions/types.tsx +1 -0
  578. package/src/{FormBuilder/FormBuilder.tsx → index.tsx} +21 -9
  579. package/src/inputs/AutoCompleteInput/AutoComplete.stories.js +2 -2
  580. package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +26 -18
  581. package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +27 -19
  582. package/src/inputs/AutoCompleteInput/index.mdx +8 -2
  583. package/src/inputs/AutoCompleteInput/index.test.tsx +24 -0
  584. package/src/inputs/AutoCompleteInput/index.tsx +22 -12
  585. package/src/inputs/Checkboxes/Checkboxes.stories.js +3 -3
  586. package/src/inputs/Checkboxes/index.test.tsx +28 -0
  587. package/src/inputs/Checkboxes/index.tsx +28 -25
  588. package/src/inputs/DateInput/DateInput.stories.js +1 -1
  589. package/src/inputs/DateInput/__stories__/Default.tsx +21 -15
  590. package/src/inputs/DateInput/index.test.tsx +20 -0
  591. package/src/inputs/DateInput/index.tsx +2 -2
  592. package/src/inputs/FileInput/FileInput.stories.js +1 -1
  593. package/src/inputs/FileInput/index.test.tsx +20 -0
  594. package/src/inputs/ImageInput/ImageInput.stories.js +3 -3
  595. package/src/inputs/ImageInput/index.test.tsx +28 -0
  596. package/src/inputs/Input/Input.stories.js +10 -10
  597. package/src/inputs/Input/__stories__/{Default.tsx → String.tsx} +2 -2
  598. package/src/inputs/Input/__stories__/{TextWithCharacterLimit.tsx → TextWithLimit.tsx} +2 -2
  599. package/src/inputs/Input/index.mdx +4 -4
  600. package/src/inputs/Input/index.test.tsx +56 -0
  601. package/src/inputs/Input/inputsInputScenarios.ts +405 -0
  602. package/src/inputs/Label/Label.stories.js +1 -1
  603. package/src/inputs/Label/__stories__/Default.tsx +3 -1
  604. package/src/inputs/Label/index.test.tsx +20 -0
  605. package/src/inputs/Label/index.tsx +1 -4
  606. package/src/inputs/OtpInput/OtpInput.stories.js +1 -1
  607. package/src/inputs/OtpInput/index.test.tsx +20 -0
  608. package/src/inputs/OtpInput/index.tsx +1 -1
  609. package/src/inputs/Radio/Radio.stories.js +3 -3
  610. package/src/inputs/Radio/index.test.tsx +28 -0
  611. package/src/inputs/Radio/index.tsx +6 -3
  612. package/src/inputs/Select/Select.stories.js +1 -1
  613. package/src/inputs/Select/index.test.tsx +20 -0
  614. package/src/inputs/inputsScenarios.ts +503 -0
  615. package/src/internal.ts +2 -31
  616. package/src/lazy.js +18 -15
  617. package/src/locales/el.ts +3 -0
  618. package/src/registry.js +14 -2
  619. package/src/types.tsx +9 -63
  620. package/src/utils.ts +34 -33
  621. package/src/validators/index.ts +5 -0
  622. package/src/validators/utils/file.ts +9 -9
  623. package/src/validators/utils/phone.ts +62 -71
  624. package/src/validators/validators.spec.ts +3 -37
  625. package/types/index.js +1 -0
  626. package/types.d.ts +4 -33
  627. package/types.js.map +3 -3
  628. package/utils/index.js +34 -17
  629. package/utils.js.map +3 -3
  630. package/validators/index.js +9 -11
  631. package/validators/index.js.map +2 -2
  632. package/validators/utils/afm.js.map +1 -1
  633. package/validators/utils/file/index.js +9 -9
  634. package/validators/utils/file.js.map +2 -2
  635. package/validators/utils/iban.js.map +1 -1
  636. package/validators/utils/image/index.js +2 -2
  637. package/validators/utils/image.js.map +1 -1
  638. package/validators/utils/index.js +10 -2
  639. package/validators/utils/index.js.map +1 -1
  640. package/validators/utils/int.js.map +1 -1
  641. package/validators/utils/number.js.map +1 -1
  642. package/validators/utils/otp.js.map +1 -1
  643. package/validators/utils/phone/index.js +9 -2
  644. package/validators/utils/phone.js.map +2 -2
  645. package/validators/utils/postal_code.js.map +1 -1
  646. package/validators/utils/text_limit/index.js +2 -2
  647. package/validators/utils/text_limit.js.map +1 -1
  648. package/validators/utils/uuid4.js.map +1 -1
  649. package/Field/utils.d.ts +0 -5
  650. package/Field/utils.js.map +0 -7
  651. package/FormBuilder/FormBuilder/index.js +0 -138
  652. package/FormBuilder/FormBuilder.d.ts +0 -5
  653. package/FormBuilder/FormBuilder.js.map +0 -7
  654. package/Questions/index.spec/index.js +0 -65
  655. package/Questions/index.spec.js.map +0 -7
  656. package/cjs/Field/utils.js.map +0 -7
  657. package/cjs/FormBuilder/FormBuilder/index.js +0 -166
  658. package/cjs/FormBuilder/FormBuilder.js.map +0 -7
  659. package/cjs/Questions/index.spec/index.js +0 -83
  660. package/cjs/Questions/index.spec.js.map +0 -7
  661. package/cjs/inputs/Input/__stories__/Default/index.js +0 -52
  662. package/cjs/inputs/Input/__stories__/Default.js.map +0 -7
  663. package/cjs/inputs/Input/__stories__/TextWithCharacterLimit/index.js +0 -52
  664. package/cjs/inputs/Input/__stories__/TextWithCharacterLimit.js.map +0 -7
  665. package/cjs/validators/validators.spec/index.js +0 -104
  666. package/cjs/validators/validators.spec.js.map +0 -7
  667. package/inputs/Input/__stories__/Default/index.js +0 -25
  668. package/inputs/Input/__stories__/Default.d.ts +0 -3
  669. package/inputs/Input/__stories__/Default.js.map +0 -7
  670. package/inputs/Input/__stories__/TextWithCharacterLimit/index.js +0 -25
  671. package/inputs/Input/__stories__/TextWithCharacterLimit/package.json +0 -6
  672. package/inputs/Input/__stories__/TextWithCharacterLimit.d.ts +0 -3
  673. package/inputs/Input/__stories__/TextWithCharacterLimit.js.map +0 -7
  674. package/src/Field/utils.ts +0 -191
  675. package/src/FieldArray/FieldArray.stories.playwright.json +0 -353
  676. package/src/FormBuilder/FormBuilder.stories.playwright.json +0 -52
  677. package/src/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
  678. package/src/index.ts +0 -3
  679. package/src/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
  680. package/src/inputs/DateInput/DateInput.stories.playwright.json +0 -72
  681. package/src/inputs/FileInput/FileInput.stories.playwright.json +0 -75
  682. package/src/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
  683. package/src/inputs/Input/Input.stories.playwright.json +0 -376
  684. package/src/inputs/Label/Label.stories.playwright.json +0 -40
  685. package/src/inputs/Radio/Radio.stories.playwright.json +0 -73
  686. package/src/inputs/Select/Select.stories.playwright.json +0 -22
  687. package/validators/validators.spec/index.js +0 -91
  688. package/validators/validators.spec.js.map +0 -7
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import {Controller} from "react-hook-form";
2
+ import { Controller } from "react-hook-form";
3
3
  import FieldBaseContainer from "@digigov/form/Field/FieldBaseContainer";
4
4
  const FieldBase = (props) => {
5
5
  const {
@@ -24,62 +24,83 @@ const FieldBase = (props) => {
24
24
  return null;
25
25
  }
26
26
  if (controlled) {
27
- return /* @__PURE__ */ React.createElement(FieldBaseContainer, {
27
+ return /* @__PURE__ */ React.createElement(
28
+ FieldBaseContainer,
29
+ {
30
+ label,
31
+ layout,
32
+ error,
33
+ wrapper,
34
+ name
35
+ },
36
+ /* @__PURE__ */ React.createElement(
37
+ Controller,
38
+ {
39
+ control,
40
+ name,
41
+ render: ({ field }) => {
42
+ return /* @__PURE__ */ React.createElement(
43
+ Component,
44
+ {
45
+ ...field,
46
+ ref: void 0,
47
+ defaultValue,
48
+ extra,
49
+ error: !!error,
50
+ type,
51
+ "aria-required": !!required,
52
+ "aria-describedby": error && `${name}-error`,
53
+ required,
54
+ disabled: editable === false,
55
+ ...componentProps
56
+ }
57
+ );
58
+ }
59
+ }
60
+ )
61
+ );
62
+ }
63
+ return /* @__PURE__ */ React.createElement(
64
+ FieldBaseContainer,
65
+ {
28
66
  label,
29
67
  layout,
30
68
  error,
31
69
  wrapper,
32
70
  name
33
- }, /* @__PURE__ */ React.createElement(Controller, {
34
- control,
35
- name,
36
- render: ({field}) => {
37
- return /* @__PURE__ */ React.createElement(Component, {
38
- ...field,
39
- ref: void 0,
40
- defaultValue,
41
- extra,
42
- error: !!error,
43
- type,
44
- "aria-required": !!required,
45
- "aria-describedby": error && `${name}-error`,
46
- required,
47
- disabled: editable === false,
48
- ...componentProps
49
- });
71
+ },
72
+ Component?.render ? /* @__PURE__ */ React.createElement(
73
+ Component,
74
+ {
75
+ ...register(name),
76
+ control,
77
+ error: !!error,
78
+ extra,
79
+ type,
80
+ "aria-required": !!required,
81
+ "aria-describedby": error && `${name}-error`,
82
+ required,
83
+ disabled: editable === false,
84
+ ...componentProps
50
85
  }
51
- }));
52
- }
53
- return /* @__PURE__ */ React.createElement(FieldBaseContainer, {
54
- label,
55
- layout,
56
- error,
57
- wrapper,
58
- name
59
- }, Component?.render ? /* @__PURE__ */ React.createElement(Component, {
60
- ...register(name),
61
- control,
62
- error: !!error,
63
- extra,
64
- type,
65
- "aria-required": !!required,
66
- "aria-describedby": error && `${name}-error`,
67
- required,
68
- disabled: editable === false,
69
- ...componentProps
70
- }) : /* @__PURE__ */ React.createElement(Component, {
71
- ...register(name),
72
- register,
73
- control,
74
- error: !!error,
75
- extra,
76
- type,
77
- "aria-required": !!required,
78
- "aria-describedby": error && `${name}-error`,
79
- required,
80
- disabled: editable === false,
81
- ...componentProps
82
- }));
86
+ ) : /* @__PURE__ */ React.createElement(
87
+ Component,
88
+ {
89
+ ...register(name),
90
+ register,
91
+ control,
92
+ error: !!error,
93
+ extra,
94
+ type,
95
+ "aria-required": !!required,
96
+ "aria-describedby": error && `${name}-error`,
97
+ required,
98
+ disabled: editable === false,
99
+ ref: void 0,
100
+ ...componentProps
101
+ }
102
+ )
103
+ );
83
104
  };
84
105
  export {
85
106
  FieldBase
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Field/FieldBase.tsx"],
4
- "sourcesContent": ["import React from 'react';\nimport { Controller } from 'react-hook-form';\nimport FieldBaseContainer from '@digigov/form/Field/FieldBaseContainer';\nimport { FieldBaseProps } from '@digigov/form/Field/types';\n\nexport const FieldBase: React.FC<FieldBaseProps> = (props) => {\n const {\n required,\n name,\n component: Component,\n wrapper,\n control,\n type,\n controlled = false,\n enabled = true,\n editable,\n defaultValue,\n label,\n extra = {},\n layout,\n error,\n register,\n ...componentProps\n } = props;\n if (!enabled) {\n return null;\n }\n if (controlled) {\n return (\n <FieldBaseContainer\n label={label}\n layout={layout}\n error={error}\n wrapper={wrapper}\n name={name}\n >\n <Controller\n control={control}\n name={name}\n render={({ field }) => {\n return (\n <Component\n {...field}\n ref={undefined}\n defaultValue={defaultValue}\n extra={extra}\n error={!!error}\n type={type}\n aria-required={!!required}\n aria-describedby={error && `${name}-error`}\n required={required}\n disabled={editable === false}\n {...componentProps}\n />\n );\n }}\n />\n </FieldBaseContainer>\n );\n }\n\n return (\n <FieldBaseContainer\n label={label}\n layout={layout}\n error={error}\n wrapper={wrapper}\n name={name}\n >\n {Component?.render ? (\n <Component\n {...register(name)}\n control={control}\n error={!!error}\n extra={extra}\n type={type}\n aria-required={!!required}\n aria-describedby={error && `${name}-error`}\n required={required}\n disabled={editable === false}\n {...componentProps}\n />\n ) : (\n <Component\n {...register(name)}\n register={register}\n control={control}\n error={!!error}\n extra={extra}\n type={type}\n aria-required={!!required}\n aria-describedby={error && `${name}-error`}\n required={required}\n disabled={editable === false}\n {...componentProps}\n />\n )}\n </FieldBaseContainer>\n );\n};\n"],
5
- "mappings": "AAAA;AACA;AACA;AAGO,MAAM,YAAsC,CAAC,UAAU;AAC5D,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,OACG;AAAA,MACD;AACJ,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA;AAET,MAAI,YAAY;AACd,WACE,oCAAC,oBAAD;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,OAEA,oCAAC,YAAD;AAAA,MACE;AAAA,MACA;AAAA,MACA,QAAQ,CAAC,CAAE,WAAY;AACrB,eACE,oCAAC,WAAD;AAAA,aACM;AAAA,UACJ,KAAK;AAAA,UACL;AAAA,UACA;AAAA,UACA,OAAO,CAAC,CAAC;AAAA,UACT;AAAA,UACA,iBAAe,CAAC,CAAC;AAAA,UACjB,oBAAkB,SAAS,GAAG;AAAA,UAC9B;AAAA,UACA,UAAU,aAAa;AAAA,aACnB;AAAA;AAAA;AAAA;AAAA;AASlB,SACE,oCAAC,oBAAD;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KAEC,WAAW,SACV,oCAAC,WAAD;AAAA,OACM,SAAS;AAAA,IACb;AAAA,IACA,OAAO,CAAC,CAAC;AAAA,IACT;AAAA,IACA;AAAA,IACA,iBAAe,CAAC,CAAC;AAAA,IACjB,oBAAkB,SAAS,GAAG;AAAA,IAC9B;AAAA,IACA,UAAU,aAAa;AAAA,OACnB;AAAA,OAGN,oCAAC,WAAD;AAAA,OACM,SAAS;AAAA,IACb;AAAA,IACA;AAAA,IACA,OAAO,CAAC,CAAC;AAAA,IACT;AAAA,IACA;AAAA,IACA,iBAAe,CAAC,CAAC;AAAA,IACjB,oBAAkB,SAAS,GAAG;AAAA,IAC9B;AAAA,IACA,UAAU,aAAa;AAAA,OACnB;AAAA;AAAA;",
4
+ "sourcesContent": ["import React from 'react';\nimport { Controller } from 'react-hook-form';\nimport FieldBaseContainer from '@digigov/form/Field/FieldBaseContainer';\nimport { FieldBaseProps } from '@digigov/form/Field/types';\n\nexport const FieldBase: React.FC<FieldBaseProps> = (props) => {\n const {\n required,\n name,\n component: Component,\n wrapper,\n control,\n type,\n controlled = false,\n enabled = true,\n editable,\n defaultValue,\n label,\n extra = {},\n layout,\n error,\n register,\n ...componentProps\n } = props;\n if (!enabled) {\n return null;\n }\n if (controlled) {\n return (\n <FieldBaseContainer\n label={label}\n layout={layout}\n error={error}\n wrapper={wrapper}\n name={name}\n >\n <Controller\n control={control}\n name={name}\n render={({ field }) => {\n return (\n <Component\n {...field}\n ref={undefined}\n defaultValue={defaultValue}\n extra={extra}\n error={!!error}\n type={type}\n aria-required={!!required}\n aria-describedby={error && `${name}-error`}\n required={required}\n disabled={editable === false}\n {...componentProps}\n />\n );\n }}\n />\n </FieldBaseContainer>\n );\n }\n\n return (\n <FieldBaseContainer\n label={label}\n layout={layout}\n error={error}\n wrapper={wrapper}\n name={name}\n >\n {Component?.render ? (\n <Component\n {...register(name)}\n control={control}\n error={!!error}\n extra={extra}\n type={type}\n aria-required={!!required}\n aria-describedby={error && `${name}-error`}\n required={required}\n disabled={editable === false}\n {...componentProps}\n />\n ) : (\n <Component\n {...register(name)}\n register={register}\n control={control}\n error={!!error}\n extra={extra}\n type={type}\n aria-required={!!required}\n aria-describedby={error && `${name}-error`}\n required={required}\n disabled={editable === false}\n ref={undefined}\n {...componentProps}\n />\n )}\n </FieldBaseContainer>\n );\n};\n"],
5
+ "mappings": "AAAA,OAAO,WAAW;AAClB,SAAS,kBAAkB;AAC3B,OAAO,wBAAwB;AAGxB,MAAM,YAAsC,CAAC,UAAU;AAC5D,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ,CAAC;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AACA,MAAI,YAAY;AACd,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA,QAAQ,CAAC,EAAE,MAAM,MAAM;AACrB,mBACE;AAAA,cAAC;AAAA;AAAA,gBACE,GAAG;AAAA,gBACJ,KAAK;AAAA,gBACL;AAAA,gBACA;AAAA,gBACA,OAAO,CAAC,CAAC;AAAA,gBACT;AAAA,gBACA,iBAAe,CAAC,CAAC;AAAA,gBACjB,oBAAkB,SAAS,GAAG,IAAI;AAAA,gBAClC;AAAA,gBACA,UAAU,aAAa;AAAA,gBACtB,GAAG;AAAA;AAAA,YACN;AAAA,UAEJ;AAAA;AAAA,MACF;AAAA,IACF;AAAA,EAEJ;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,IAEC,WAAW,SACV;AAAA,MAAC;AAAA;AAAA,QACE,GAAG,SAAS,IAAI;AAAA,QACjB;AAAA,QACA,OAAO,CAAC,CAAC;AAAA,QACT;AAAA,QACA;AAAA,QACA,iBAAe,CAAC,CAAC;AAAA,QACjB,oBAAkB,SAAS,GAAG,IAAI;AAAA,QAClC;AAAA,QACA,UAAU,aAAa;AAAA,QACtB,GAAG;AAAA;AAAA,IACN,IAEA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG,SAAS,IAAI;AAAA,QACjB;AAAA,QACA;AAAA,QACA,OAAO,CAAC,CAAC;AAAA,QACT;AAAA,QACA;AAAA,QACA,iBAAe,CAAC,CAAC;AAAA,QACjB,oBAAkB,SAAS,GAAG,IAAI;AAAA,QAClC;AAAA,QACA,UAAU,aAAa;AAAA,QACvB,KAAK;AAAA,QACJ,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -6,7 +6,7 @@ import CoreFieldset from "@digigov/react-core/Fieldset";
6
6
  import FieldsetLegend from "@digigov/react-core/FieldsetLegend";
7
7
  import Hint from "@digigov/react-core/Hint";
8
8
  import LabelContainer from "@digigov/react-core/LabelContainer";
9
- import {useTranslation} from "@digigov/ui/i18n";
9
+ import { useTranslation } from "@digigov/ui/i18n";
10
10
  const FieldBaseContainer = ({
11
11
  name,
12
12
  wrapper,
@@ -15,27 +15,13 @@ const FieldBaseContainer = ({
15
15
  error,
16
16
  layout
17
17
  }) => {
18
- const {t} = useTranslation();
18
+ const { t } = useTranslation();
19
19
  const errorMessage = error?.message.key ? error.message.key : error?.message || "";
20
20
  const errorContext = error?.message.context || {};
21
21
  if (wrapper === "fieldset") {
22
- return /* @__PURE__ */ React.createElement(FieldContainer, {
23
- error: !!error,
24
- ...layout
25
- }, /* @__PURE__ */ React.createElement(CoreFieldset, null, /* @__PURE__ */ React.createElement(FieldsetLegend, {
26
- size: "sm"
27
- }, label && label.primary), label && label.secondary && /* @__PURE__ */ React.createElement(Hint, null, t(label.secondary)), error && /* @__PURE__ */ React.createElement(ErrorMessage, {
28
- id: `${name}-error`
29
- }, t(errorMessage, errorContext)), children));
22
+ return /* @__PURE__ */ React.createElement(FieldContainer, { error: !!error, ...layout }, /* @__PURE__ */ React.createElement(CoreFieldset, null, /* @__PURE__ */ React.createElement(FieldsetLegend, { size: "sm" }, label && label.primary), label && label.secondary && /* @__PURE__ */ React.createElement(Hint, null, t(label.secondary)), error && /* @__PURE__ */ React.createElement(ErrorMessage, { id: `${name}-error` }, t(errorMessage, errorContext)), children));
30
23
  } else {
31
- return /* @__PURE__ */ React.createElement(FieldContainer, {
32
- error: !!error,
33
- ...layout
34
- }, /* @__PURE__ */ React.createElement(LabelContainer, null, label && /* @__PURE__ */ React.createElement(Label, {
35
- label
36
- }), error && /* @__PURE__ */ React.createElement(ErrorMessage, {
37
- id: `${name}-error`
38
- }, t(errorMessage, errorContext)), children));
24
+ return /* @__PURE__ */ React.createElement(FieldContainer, { error: !!error, ...layout }, /* @__PURE__ */ React.createElement(LabelContainer, null, label && /* @__PURE__ */ React.createElement(Label, { label }), error && /* @__PURE__ */ React.createElement(ErrorMessage, { id: `${name}-error` }, t(errorMessage, errorContext)), children));
39
25
  }
40
26
  };
41
27
  var FieldBaseContainer_default = FieldBaseContainer;
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/Field/FieldBaseContainer.tsx"],
4
4
  "sourcesContent": ["import React from 'react';\nimport { FieldContainerProps } from '@digigov/form/Field/types';\nimport Label from '@digigov/form/inputs/Label';\nimport ErrorMessage from '@digigov/react-core/ErrorMessage';\nimport FieldContainer from '@digigov/react-core/FieldContainer';\nimport CoreFieldset from '@digigov/react-core/Fieldset';\nimport FieldsetLegend from '@digigov/react-core/FieldsetLegend';\nimport Hint from '@digigov/react-core/Hint';\nimport LabelContainer from '@digigov/react-core/LabelContainer';\nimport { useTranslation } from '@digigov/ui/i18n';\n\nexport const FieldBaseContainer: React.FC<FieldContainerProps> = ({\n name,\n wrapper,\n label,\n children,\n error,\n layout,\n}) => {\n const { t } = useTranslation();\n const errorMessage = error?.message.key\n ? error.message.key\n : error?.message || '';\n const errorContext = error?.message.context || {};\n if (wrapper === 'fieldset') {\n return (\n <FieldContainer error={!!error} {...layout}>\n <CoreFieldset>\n <FieldsetLegend size=\"sm\">{label && label.primary}</FieldsetLegend>\n {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}\n {error && (\n <ErrorMessage id={`${name}-error`}>\n {t(errorMessage, errorContext)}\n </ErrorMessage>\n )}\n {children}\n </CoreFieldset>\n </FieldContainer>\n );\n } else {\n return (\n <FieldContainer error={!!error} {...layout}>\n <LabelContainer>\n {label && <Label label={label} />}\n {error && (\n <ErrorMessage id={`${name}-error`}>\n {t(errorMessage, errorContext)}\n </ErrorMessage>\n )}\n {children}\n </LabelContainer>\n </FieldContainer>\n );\n }\n};\n\nexport default FieldBaseContainer;\n"],
5
- "mappings": "AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAM,qBAAoD,CAAC;AAAA,EAChE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACI;AACJ,QAAM,CAAE,KAAM;AACd,QAAM,eAAe,OAAO,QAAQ,MAChC,MAAM,QAAQ,MACd,OAAO,WAAW;AACtB,QAAM,eAAe,OAAO,QAAQ,WAAW;AAC/C,MAAI,YAAY,YAAY;AAC1B,WACE,oCAAC,gBAAD;AAAA,MAAgB,OAAO,CAAC,CAAC;AAAA,SAAW;AAAA,OAClC,oCAAC,cAAD,MACE,oCAAC,gBAAD;AAAA,MAAgB,MAAK;AAAA,OAAM,SAAS,MAAM,UACzC,SAAS,MAAM,aAAa,oCAAC,MAAD,MAAO,EAAE,MAAM,aAC3C,SACC,oCAAC,cAAD;AAAA,MAAc,IAAI,GAAG;AAAA,OAClB,EAAE,cAAc,gBAGpB;AAAA,SAIF;AACL,WACE,oCAAC,gBAAD;AAAA,MAAgB,OAAO,CAAC,CAAC;AAAA,SAAW;AAAA,OAClC,oCAAC,gBAAD,MACG,SAAS,oCAAC,OAAD;AAAA,MAAO;AAAA,QAChB,SACC,oCAAC,cAAD;AAAA,MAAc,IAAI,GAAG;AAAA,OAClB,EAAE,cAAc,gBAGpB;AAAA;AAAA;AAOX,IAAO,6BAAQ;",
5
+ "mappings": "AAAA,OAAO,WAAW;AAElB,OAAO,WAAW;AAClB,OAAO,kBAAkB;AACzB,OAAO,oBAAoB;AAC3B,OAAO,kBAAkB;AACzB,OAAO,oBAAoB;AAC3B,OAAO,UAAU;AACjB,OAAO,oBAAoB;AAC3B,SAAS,sBAAsB;AAExB,MAAM,qBAAoD,CAAC;AAAA,EAChE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,EAAE,IAAI,eAAe;AAC7B,QAAM,eAAe,OAAO,QAAQ,MAChC,MAAM,QAAQ,MACd,OAAO,WAAW;AACtB,QAAM,eAAe,OAAO,QAAQ,WAAW,CAAC;AAChD,MAAI,YAAY,YAAY;AAC1B,WACE,oCAAC,kBAAe,OAAO,CAAC,CAAC,OAAQ,GAAG,UAClC,oCAAC,oBACC,oCAAC,kBAAe,MAAK,QAAM,SAAS,MAAM,OAAQ,GACjD,SAAS,MAAM,aAAa,oCAAC,YAAM,EAAE,MAAM,SAAS,CAAE,GACtD,SACC,oCAAC,gBAAa,IAAI,GAAG,IAAI,YACtB,EAAE,cAAc,YAAY,CAC/B,GAED,QACH,CACF;AAAA,EAEJ,OAAO;AACL,WACE,oCAAC,kBAAe,OAAO,CAAC,CAAC,OAAQ,GAAG,UAClC,oCAAC,sBACE,SAAS,oCAAC,SAAM,OAAc,GAC9B,SACC,oCAAC,gBAAa,IAAI,GAAG,IAAI,YACtB,EAAE,cAAc,YAAY,CAC/B,GAED,QACH,CACF;AAAA,EAEJ;AACF;AAEA,IAAO,6BAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,38 +1,47 @@
1
1
  import React from "react";
2
- import {useWatch} from "react-hook-form";
3
- import {FieldBase} from "@digigov/form/Field/FieldBase";
4
- import {evaluateFieldWithConditions} from "@digigov/form/Field/utils";
5
- const ChildFieldMemo = React.memo(function ChildField({
6
- dependencies,
7
- field,
8
- control,
9
- reset,
10
- register,
11
- error
12
- }) {
13
- const newField = evaluateFieldWithConditions(field, dependencies);
14
- return /* @__PURE__ */ React.createElement(FieldBase, {
15
- ...newField,
16
- name: newField.key,
17
- reset,
2
+ import { useWatch } from "react-hook-form";
3
+ import { FieldBase } from "@digigov/form/Field/FieldBase";
4
+ import { evaluateFieldWithConditions } from "@digigov/form/Field/utils/evaluateFieldWithConditions";
5
+ const ChildFieldMemo = React.memo(
6
+ function ChildField({
7
+ dependencies,
8
+ field,
18
9
  control,
10
+ reset,
19
11
  register,
20
12
  error
21
- });
22
- }, (prev, next) => {
23
- if (!prev || !prev.dependencies) {
24
- return false;
25
- }
26
- if (prev.error !== next.error) {
27
- return false;
28
- }
29
- for (const dep in next.dependencies) {
30
- if (next.dependencies[dep] !== prev.dependencies[dep]) {
13
+ }) {
14
+ const newField = evaluateFieldWithConditions(
15
+ field,
16
+ dependencies
17
+ );
18
+ return /* @__PURE__ */ React.createElement(
19
+ FieldBase,
20
+ {
21
+ ...newField,
22
+ name: newField.key,
23
+ reset,
24
+ control,
25
+ register,
26
+ error
27
+ }
28
+ );
29
+ },
30
+ (prev, next) => {
31
+ if (!prev || !prev.dependencies) {
31
32
  return false;
32
33
  }
34
+ if (prev.error !== next.error) {
35
+ return false;
36
+ }
37
+ for (const dep in next.dependencies) {
38
+ if (next.dependencies[dep] !== prev.dependencies[dep]) {
39
+ return false;
40
+ }
41
+ }
42
+ return true;
33
43
  }
34
- return true;
35
- });
44
+ );
36
45
  const FieldConditional = ({
37
46
  control,
38
47
  field,
@@ -45,18 +54,24 @@ const FieldConditional = ({
45
54
  name: dependencyKeys,
46
55
  control
47
56
  });
48
- const variables = dependencyKeys.reduce((data, fieldKey, index) => ({
49
- ...data,
50
- [fieldKey]: dependencyValues[index]
51
- }), {});
52
- return /* @__PURE__ */ React.createElement(ChildFieldMemo, {
53
- dependencies: variables,
54
- field,
55
- control,
56
- register,
57
- reset,
58
- error
59
- });
57
+ const variables = dependencyKeys.reduce(
58
+ (data, fieldKey, index) => ({
59
+ ...data,
60
+ [fieldKey]: dependencyValues[index]
61
+ }),
62
+ {}
63
+ );
64
+ return /* @__PURE__ */ React.createElement(
65
+ ChildFieldMemo,
66
+ {
67
+ dependencies: variables,
68
+ field,
69
+ control,
70
+ register,
71
+ reset,
72
+ error
73
+ }
74
+ );
60
75
  };
61
76
  var FieldConditional_default = FieldConditional;
62
77
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Field/FieldConditional.tsx"],
4
- "sourcesContent": ["import React from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { FieldBase } from '@digigov/form/Field/FieldBase';\nimport {\n ChildFieldMemoProps,\n FieldConditionalProps,\n} from '@digigov/form/Field/types';\nimport { evaluateFieldWithConditions } from '@digigov/form/Field/utils';\n\nconst ChildFieldMemo = React.memo(\n function ChildField({\n dependencies,\n field,\n control,\n reset,\n register,\n error,\n }: ChildFieldMemoProps) {\n const newField = evaluateFieldWithConditions(\n field,\n dependencies as FormData\n );\n return (\n <FieldBase\n {...newField}\n name={newField.key}\n reset={reset}\n control={control}\n register={register}\n error={error}\n />\n );\n },\n (prev, next) => {\n if (!prev || !prev.dependencies) {\n return false;\n }\n if (prev.error !== next.error) {\n return false;\n }\n for (const dep in next.dependencies) {\n if (next.dependencies[dep] !== prev.dependencies[dep]) {\n return false;\n }\n }\n return true;\n }\n);\n\nexport const FieldConditional: React.FC<FieldConditionalProps> = ({\n control,\n field,\n register,\n reset,\n error,\n}) => {\n const dependencyKeys = Object.keys(field.condition);\n const dependencyValues = useWatch({\n name: dependencyKeys,\n control,\n });\n const variables = dependencyKeys.reduce(\n (data, fieldKey, index) => ({\n ...data,\n [fieldKey]: dependencyValues[index],\n }),\n {}\n );\n return (\n <ChildFieldMemo\n dependencies={variables}\n field={field}\n control={control}\n register={register}\n reset={reset}\n error={error}\n />\n );\n};\n\nexport default FieldConditional;\n"],
5
- "mappings": "AAAA;AACA;AACA;AAKA;AAEA,MAAM,iBAAiB,MAAM,KAC3B,oBAAoB;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,GACsB;AACtB,QAAM,WAAW,4BACf,OACA;AAEF,SACE,oCAAC,WAAD;AAAA,OACM;AAAA,IACJ,MAAM,SAAS;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,GAIN,CAAC,MAAM,SAAS;AACd,MAAI,CAAC,QAAQ,CAAC,KAAK,cAAc;AAC/B,WAAO;AAAA;AAET,MAAI,KAAK,UAAU,KAAK,OAAO;AAC7B,WAAO;AAAA;AAET,aAAW,OAAO,KAAK,cAAc;AACnC,QAAI,KAAK,aAAa,SAAS,KAAK,aAAa,MAAM;AACrD,aAAO;AAAA;AAAA;AAGX,SAAO;AAAA;AAIJ,MAAM,mBAAoD,CAAC;AAAA,EAChE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACI;AACJ,QAAM,iBAAiB,OAAO,KAAK,MAAM;AACzC,QAAM,mBAAmB,SAAS;AAAA,IAChC,MAAM;AAAA,IACN;AAAA;AAEF,QAAM,YAAY,eAAe,OAC/B,CAAC,MAAM,UAAU,UAAW;AAAA,OACvB;AAAA,KACF,WAAW,iBAAiB;AAAA,MAE/B;AAEF,SACE,oCAAC,gBAAD;AAAA,IACE,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAKN,IAAO,2BAAQ;",
4
+ "sourcesContent": ["import React from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { FieldBase } from '@digigov/form/Field/FieldBase';\nimport {\n ChildFieldMemoProps,\n FieldConditionalProps,\n} from '@digigov/form/Field/types';\nimport { evaluateFieldWithConditions } from '@digigov/form/Field/utils/evaluateFieldWithConditions';\n\nconst ChildFieldMemo = React.memo(\n function ChildField({\n dependencies,\n field,\n control,\n reset,\n register,\n error,\n }: ChildFieldMemoProps) {\n const newField = evaluateFieldWithConditions(\n field,\n dependencies as FormData\n );\n return (\n <FieldBase\n {...newField}\n name={newField.key}\n reset={reset}\n control={control}\n register={register}\n error={error}\n />\n );\n },\n (prev, next) => {\n if (!prev || !prev.dependencies) {\n return false;\n }\n if (prev.error !== next.error) {\n return false;\n }\n for (const dep in next.dependencies) {\n if (next.dependencies[dep] !== prev.dependencies[dep]) {\n return false;\n }\n }\n return true;\n }\n);\n\nexport const FieldConditional: React.FC<FieldConditionalProps> = ({\n control,\n field,\n register,\n reset,\n error,\n}) => {\n const dependencyKeys = Object.keys(field.condition);\n const dependencyValues = useWatch({\n name: dependencyKeys,\n control,\n });\n const variables = dependencyKeys.reduce(\n (data, fieldKey, index) => ({\n ...data,\n [fieldKey]: dependencyValues[index],\n }),\n {}\n );\n return (\n <ChildFieldMemo\n dependencies={variables}\n field={field}\n control={control}\n register={register}\n reset={reset}\n error={error}\n />\n );\n};\n\nexport default FieldConditional;\n"],
5
+ "mappings": "AAAA,OAAO,WAAW;AAClB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAK1B,SAAS,mCAAmC;AAE5C,MAAM,iBAAiB,MAAM;AAAA,EAC3B,SAAS,WAAW;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAAwB;AACtB,UAAM,WAAW;AAAA,MACf;AAAA,MACA;AAAA,IACF;AACA,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ,MAAM,SAAS;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF;AAAA,EAEJ;AAAA,EACA,CAAC,MAAM,SAAS;AACd,QAAI,CAAC,QAAQ,CAAC,KAAK,cAAc;AAC/B,aAAO;AAAA,IACT;AACA,QAAI,KAAK,UAAU,KAAK,OAAO;AAC7B,aAAO;AAAA,IACT;AACA,eAAW,OAAO,KAAK,cAAc;AACnC,UAAI,KAAK,aAAa,GAAG,MAAM,KAAK,aAAa,GAAG,GAAG;AACrD,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;AAEO,MAAM,mBAAoD,CAAC;AAAA,EAChE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,iBAAiB,OAAO,KAAK,MAAM,SAAS;AAClD,QAAM,mBAAmB,SAAS;AAAA,IAChC,MAAM;AAAA,IACN;AAAA,EACF,CAAC;AACD,QAAM,YAAY,eAAe;AAAA,IAC/B,CAAC,MAAM,UAAU,WAAW;AAAA,MAC1B,GAAG;AAAA,MACH,CAAC,QAAQ,GAAG,iBAAiB,KAAK;AAAA,IACpC;AAAA,IACA,CAAC;AAAA,EACH;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,cAAc;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,2BAAQ;",
6
6
  "names": []
7
7
  }
package/Field/index.js CHANGED
@@ -1,11 +1,17 @@
1
- import React, {useMemo} from "react";
2
- import {FieldBase} from "@digigov/form/Field/FieldBase";
1
+ import React, { useMemo } from "react";
2
+ import { FieldBase } from "@digigov/form/Field/FieldBase";
3
3
  import FieldConditional from "@digigov/form/Field/FieldConditional";
4
- import {useField, calculateField} from "@digigov/form/Field/utils";
4
+ import {
5
+ FIELD_COMPONENTS,
6
+ ALTERNATIVE_COMPONENTS
7
+ } from "@digigov/form/Field/utils";
8
+ import { calculateField } from "@digigov/form/Field/utils/calculateField";
9
+ import { useField } from "@digigov/form/Field/utils/useField";
5
10
  import FieldArray from "@digigov/form/FieldArray";
6
11
  import Multiplicity from "@digigov/form/MultiplicityField";
7
12
  const Field = ({
8
13
  name,
14
+ disabled,
9
15
  children,
10
16
  ...customField
11
17
  }) => {
@@ -23,49 +29,74 @@ const Field = ({
23
29
  trigger,
24
30
  clearErrors
25
31
  } = useField(name, customField?.type ? customField : null);
26
- const calculatedField = useMemo(() => calculateField(children, field, componentRegistry), [field]);
32
+ const calculatedField = useMemo(
33
+ () => calculateField(
34
+ children,
35
+ field,
36
+ {
37
+ ...FIELD_COMPONENTS,
38
+ ...componentRegistry
39
+ },
40
+ ALTERNATIVE_COMPONENTS
41
+ ),
42
+ [field]
43
+ );
27
44
  if (calculatedField.condition) {
28
- return /* @__PURE__ */ React.createElement(FieldConditional, {
29
- control,
30
- reset,
31
- register,
32
- field: calculatedField,
33
- error
34
- });
45
+ return /* @__PURE__ */ React.createElement(
46
+ FieldConditional,
47
+ {
48
+ control,
49
+ reset,
50
+ register,
51
+ field: calculatedField,
52
+ error
53
+ }
54
+ );
35
55
  }
36
56
  if (calculatedField.type === "array" && !calculatedField.multiplicity) {
37
57
  calculatedField.name = name;
38
- return /* @__PURE__ */ React.createElement(FieldArray, {
39
- control,
40
- register,
41
- error,
42
- formState,
43
- ...calculatedField
44
- });
58
+ return /* @__PURE__ */ React.createElement(
59
+ FieldArray,
60
+ {
61
+ control,
62
+ register,
63
+ error,
64
+ formState,
65
+ ...calculatedField
66
+ }
67
+ );
45
68
  }
46
69
  if (calculatedField.type === "array" && calculatedField.multiplicity === true) {
47
70
  calculatedField.name = name;
48
- return /* @__PURE__ */ React.createElement(Multiplicity, {
71
+ return /* @__PURE__ */ React.createElement(
72
+ Multiplicity,
73
+ {
74
+ control,
75
+ register,
76
+ trigger,
77
+ clearErrors,
78
+ error,
79
+ formState,
80
+ setValue,
81
+ getValues,
82
+ unregister,
83
+ ...calculatedField
84
+ }
85
+ );
86
+ }
87
+ return /* @__PURE__ */ React.createElement(
88
+ FieldBase,
89
+ {
90
+ ...calculatedField,
91
+ name,
92
+ disabled,
49
93
  control,
50
94
  register,
51
- trigger,
52
- clearErrors,
95
+ reset,
53
96
  error,
54
- formState,
55
- setValue,
56
- getValues,
57
- unregister,
58
- ...calculatedField
59
- });
60
- }
61
- return /* @__PURE__ */ React.createElement(FieldBase, {
62
- ...calculatedField,
63
- name,
64
- control,
65
- register,
66
- reset,
67
- error
68
- });
97
+ fieldComponent: Field
98
+ }
99
+ );
69
100
  };
70
101
  var Field_default = Field;
71
102
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Field/index.tsx"],
4
- "sourcesContent": ["import React, { useMemo } from 'react';\nimport { FieldBase } from '@digigov/form/Field/FieldBase';\nimport FieldConditional from '@digigov/form/Field/FieldConditional';\nimport {\n FieldWithCondition,\n CalculatedField,\n FieldProps,\n} from '@digigov/form/Field/types';\nimport { useField, calculateField } from '@digigov/form/Field/utils';\nimport FieldArray from '@digigov/form/FieldArray';\nimport Multiplicity from '@digigov/form/MultiplicityField';\n\nexport const Field: React.FC<FieldProps> = ({\n name,\n children,\n ...customField\n}) => {\n const {\n field,\n control,\n register,\n reset,\n error,\n componentRegistry,\n formState,\n setValue,\n getValues,\n unregister,\n trigger,\n clearErrors,\n } = useField(name, customField?.type ? customField : null);\n const calculatedField: CalculatedField = useMemo(\n () => calculateField(children, field, componentRegistry),\n [field]\n );\n\n if (calculatedField.condition) {\n return (\n <FieldConditional\n control={control}\n reset={reset}\n register={register}\n field={calculatedField as FieldWithCondition}\n error={error}\n />\n );\n }\n if (calculatedField.type === 'array' && !calculatedField.multiplicity) {\n calculatedField.name = name;\n return (\n <FieldArray\n control={control}\n register={register}\n error={error}\n formState={formState}\n {...calculatedField}\n />\n );\n }\n if (\n calculatedField.type === 'array' &&\n calculatedField.multiplicity === true\n ) {\n calculatedField.name = name;\n return (\n <Multiplicity\n control={control}\n register={register}\n trigger={trigger}\n clearErrors={clearErrors}\n error={error}\n formState={formState}\n setValue={setValue}\n getValues={getValues}\n unregister={unregister}\n {...calculatedField}\n />\n );\n }\n return (\n <FieldBase\n {...calculatedField}\n name={name}\n control={control}\n register={register}\n reset={reset}\n error={error}\n />\n );\n};\n\nexport default Field;\n"],
5
- "mappings": "AAAA;AACA;AACA;AAMA;AACA;AACA;AAEO,MAAM,QAA8B,CAAC;AAAA,EAC1C;AAAA,EACA;AAAA,KACG;AAAA,MACC;AACJ,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,SAAS,MAAM,aAAa,OAAO,cAAc;AACrD,QAAM,kBAAmC,QACvC,MAAM,eAAe,UAAU,OAAO,oBACtC,CAAC;AAGH,MAAI,gBAAgB,WAAW;AAC7B,WACE,oCAAC,kBAAD;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP;AAAA;AAAA;AAIN,MAAI,gBAAgB,SAAS,WAAW,CAAC,gBAAgB,cAAc;AACrE,oBAAgB,OAAO;AACvB,WACE,oCAAC,YAAD;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,SACI;AAAA;AAAA;AAIV,MACE,gBAAgB,SAAS,WACzB,gBAAgB,iBAAiB,MACjC;AACA,oBAAgB,OAAO;AACvB,WACE,oCAAC,cAAD;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,SACI;AAAA;AAAA;AAIV,SACE,oCAAC,WAAD;AAAA,OACM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAKN,IAAO,gBAAQ;",
4
+ "sourcesContent": ["import React, { useMemo } from 'react';\nimport { FieldBase } from '@digigov/form/Field/FieldBase';\nimport FieldConditional from '@digigov/form/Field/FieldConditional';\nimport {\n FieldWithCondition,\n CalculatedField,\n FieldProps,\n} from '@digigov/form/Field/types';\nimport {\n FIELD_COMPONENTS,\n ALTERNATIVE_COMPONENTS,\n} from '@digigov/form/Field/utils';\nimport { calculateField } from '@digigov/form/Field/utils/calculateField';\nimport { useField } from '@digigov/form/Field/utils/useField';\nimport FieldArray from '@digigov/form/FieldArray';\nimport Multiplicity from '@digigov/form/MultiplicityField';\nexport const Field: React.FC<FieldProps> = ({\n name,\n disabled,\n children,\n ...customField\n}) => {\n const {\n field,\n control,\n register,\n reset,\n error,\n componentRegistry,\n formState,\n setValue,\n getValues,\n unregister,\n trigger,\n clearErrors,\n } = useField(name, customField?.type ? customField : null);\n const calculatedField: CalculatedField = useMemo(\n () =>\n calculateField(\n children,\n field,\n {\n ...FIELD_COMPONENTS,\n ...componentRegistry,\n },\n ALTERNATIVE_COMPONENTS\n ),\n [field]\n );\n\n if (calculatedField.condition) {\n return (\n <FieldConditional\n control={control}\n reset={reset}\n register={register}\n field={calculatedField as FieldWithCondition}\n error={error}\n />\n );\n }\n if (calculatedField.type === 'array' && !calculatedField.multiplicity) {\n calculatedField.name = name;\n return (\n <FieldArray\n control={control}\n register={register}\n error={error}\n formState={formState}\n {...calculatedField}\n />\n );\n }\n if (\n calculatedField.type === 'array' &&\n calculatedField.multiplicity === true\n ) {\n calculatedField.name = name;\n return (\n <Multiplicity\n control={control}\n register={register}\n trigger={trigger}\n clearErrors={clearErrors}\n error={error}\n formState={formState}\n setValue={setValue}\n getValues={getValues}\n unregister={unregister}\n {...calculatedField}\n />\n );\n }\n return (\n <FieldBase\n {...calculatedField}\n name={name}\n disabled={disabled}\n control={control}\n register={register}\n reset={reset}\n error={error}\n fieldComponent={Field}\n />\n );\n};\n\nexport default Field;\n"],
5
+ "mappings": "AAAA,OAAO,SAAS,eAAe;AAC/B,SAAS,iBAAiB;AAC1B,OAAO,sBAAsB;AAM7B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AACzB,OAAO,gBAAgB;AACvB,OAAO,kBAAkB;AAClB,MAAM,QAA8B,CAAC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,SAAS,MAAM,aAAa,OAAO,cAAc,IAAI;AACzD,QAAM,kBAAmC;AAAA,IACvC,MACE;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,GAAG;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,IACF,CAAC,KAAK;AAAA,EACR;AAEA,MAAI,gBAAgB,WAAW;AAC7B,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO;AAAA,QACP;AAAA;AAAA,IACF;AAAA,EAEJ;AACA,MAAI,gBAAgB,SAAS,WAAW,CAAC,gBAAgB,cAAc;AACrE,oBAAgB,OAAO;AACvB,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACA,MACE,gBAAgB,SAAS,WACzB,gBAAgB,iBAAiB,MACjC;AACA,oBAAgB,OAAO;AACvB,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA;AAAA,EAClB;AAEJ;AAEA,IAAO,gBAAQ;",
6
6
  "names": []
7
7
  }
package/Field/types.d.ts CHANGED
@@ -1,10 +1,42 @@
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
+ export type FieldLabelProps = {
6
+ primary?: string;
7
+ secondary?: string;
8
+ };
9
+ export interface FieldSpec {
10
+ key: string;
11
+ 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';
12
+ component?: any;
13
+ maxLength?: number;
14
+ condition?: Record<string, FieldCondition>;
15
+ controlled?: boolean;
16
+ label?: FieldLabelProps;
17
+ extra?: {
18
+ [key: string]: any;
19
+ };
20
+ editable?: boolean;
21
+ required?: boolean;
22
+ enabled?: boolean;
23
+ disabled?: boolean;
24
+ layout?: Record<string, GridProps['xs'] | GridProps['sm'] | GridProps['md'] | GridProps['lg'] | GridProps['xl']>;
25
+ validators?: ValidatorSchema[];
26
+ wrapper?: 'label' | 'fieldset';
27
+ maxWidth?: string;
28
+ maxHeight?: string;
29
+ width?: string;
30
+ }
31
+ export interface FieldCondition {
32
+ is: string | string[] | number | number[] | boolean | boolean[];
33
+ then?: Partial<FieldSpec>;
34
+ else?: Partial<FieldSpec>;
35
+ }
5
36
  export interface ChildFieldMemoProps extends FieldConditionalProps {
6
37
  dependencies: FormData;
7
38
  }
39
+ export type FormData = UseFormProps['defaultValues'];
8
40
  export interface FieldWithCondition extends Omit<CalculatedField, 'condition'> {
9
41
  condition: Record<string, FieldCondition>;
10
42
  }
@@ -63,6 +95,7 @@ export interface FieldBaseProps extends CalculatedField {
63
95
  control: UseFormReturn['control'];
64
96
  register: UseFormReturn['register'];
65
97
  reset: UseFormReturn['reset'];
98
+ fieldComponent?: React.FC<FieldBaseProps>;
66
99
  }
67
100
  export interface FieldProps extends FieldSpec {
68
101
  name: string;
@@ -0,0 +1,27 @@
1
+ function calculateField(children, field, fieldComponentRegistry, alternativeComponents) {
2
+ const calculatedField = { ...field };
3
+ if (children) {
4
+ calculatedField.component = children;
5
+ calculatedField.controlled = true;
6
+ } else if (typeof field.component === "function") {
7
+ } else if (!field.component && !field.type) {
8
+ calculatedField.component = fieldComponentRegistry.string.component;
9
+ calculatedField.controlled = fieldComponentRegistry.string?.controlled || false;
10
+ } else if (typeof field?.extra?.component === "string" && alternativeComponents[field.extra.component]) {
11
+ calculatedField.controlled = alternativeComponents[field.extra.component]?.controlled || false;
12
+ calculatedField.component = alternativeComponents[field.extra.component].component;
13
+ calculatedField.wrapper = alternativeComponents[field.extra.component].wrapper;
14
+ } else if (!field.component && field.type && fieldComponentRegistry[field.type]) {
15
+ calculatedField.component = fieldComponentRegistry[field.type].component;
16
+ calculatedField.wrapper = fieldComponentRegistry[field.type].wrapper;
17
+ calculatedField.controlled = fieldComponentRegistry[field.type]?.controlled || false;
18
+ } else {
19
+ calculatedField.component = fieldComponentRegistry.string.component;
20
+ calculatedField.controlled = fieldComponentRegistry.string?.controlled || false;
21
+ }
22
+ return calculatedField;
23
+ }
24
+ export {
25
+ calculateField
26
+ };
27
+ //# sourceMappingURL=calculateField.js.map
@@ -2,5 +2,5 @@
2
2
  "sideEffects": false,
3
3
  "module": "./index.js",
4
4
  "types": "./index.d.ts",
5
- "main": "../../../../cjs/inputs/Input/__stories__/Default/index.js"
5
+ "main": "../../../cjs/Field/utils/calculateField/index.js"
6
6
  }
@@ -0,0 +1,2 @@
1
+ import { FieldProps, FieldSpec, FieldComponentRegistry, CalculatedField } from '@digigov/form/Field/types';
2
+ export declare function calculateField(children: FieldProps['children'], field: FieldSpec, fieldComponentRegistry: FieldComponentRegistry, alternativeComponents: FieldComponentRegistry): CalculatedField;
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/Field/utils/calculateField.ts"],
4
+ "sourcesContent": ["import {\n FieldProps,\n FieldSpec,\n FieldComponentRegistry,\n CalculatedField,\n} from '@digigov/form/Field/types';\n\nexport function calculateField(\n children: FieldProps['children'],\n field: FieldSpec,\n fieldComponentRegistry: FieldComponentRegistry,\n alternativeComponents: FieldComponentRegistry\n): CalculatedField {\n const calculatedField = { ...field };\n if (children) {\n calculatedField.component = children;\n calculatedField.controlled = true;\n } else if (typeof field.component === 'function') {\n // leave as is\n } else if (!field.component && !field.type) {\n calculatedField.component = fieldComponentRegistry.string.component;\n calculatedField.controlled =\n fieldComponentRegistry.string?.controlled || false;\n } else if (\n typeof field?.extra?.component === 'string' &&\n alternativeComponents[field.extra.component]\n ) {\n calculatedField.controlled =\n alternativeComponents[field.extra.component]?.controlled || false;\n calculatedField.component =\n alternativeComponents[field.extra.component].component;\n calculatedField.wrapper =\n alternativeComponents[field.extra.component].wrapper;\n } else if (\n !field.component &&\n field.type &&\n fieldComponentRegistry[field.type]\n ) {\n calculatedField.component = fieldComponentRegistry[field.type].component;\n calculatedField.wrapper = fieldComponentRegistry[field.type].wrapper;\n calculatedField.controlled =\n fieldComponentRegistry[field.type]?.controlled || false;\n } else {\n calculatedField.component = fieldComponentRegistry.string.component;\n calculatedField.controlled =\n fieldComponentRegistry.string?.controlled || false;\n }\n return calculatedField as CalculatedField;\n}\n"],
5
+ "mappings": "AAOO,SAAS,eACd,UACA,OACA,wBACA,uBACiB;AACjB,QAAM,kBAAkB,EAAE,GAAG,MAAM;AACnC,MAAI,UAAU;AACZ,oBAAgB,YAAY;AAC5B,oBAAgB,aAAa;AAAA,EAC/B,WAAW,OAAO,MAAM,cAAc,YAAY;AAAA,EAElD,WAAW,CAAC,MAAM,aAAa,CAAC,MAAM,MAAM;AAC1C,oBAAgB,YAAY,uBAAuB,OAAO;AAC1D,oBAAgB,aACd,uBAAuB,QAAQ,cAAc;AAAA,EACjD,WACE,OAAO,OAAO,OAAO,cAAc,YACnC,sBAAsB,MAAM,MAAM,SAAS,GAC3C;AACA,oBAAgB,aACd,sBAAsB,MAAM,MAAM,SAAS,GAAG,cAAc;AAC9D,oBAAgB,YACd,sBAAsB,MAAM,MAAM,SAAS,EAAE;AAC/C,oBAAgB,UACd,sBAAsB,MAAM,MAAM,SAAS,EAAE;AAAA,EACjD,WACE,CAAC,MAAM,aACP,MAAM,QACN,uBAAuB,MAAM,IAAI,GACjC;AACA,oBAAgB,YAAY,uBAAuB,MAAM,IAAI,EAAE;AAC/D,oBAAgB,UAAU,uBAAuB,MAAM,IAAI,EAAE;AAC7D,oBAAgB,aACd,uBAAuB,MAAM,IAAI,GAAG,cAAc;AAAA,EACtD,OAAO;AACL,oBAAgB,YAAY,uBAAuB,OAAO;AAC1D,oBAAgB,aACd,uBAAuB,QAAQ,cAAc;AAAA,EACjD;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }