@digigov/form 2.0.0-13876dba → 2.0.0-16fbe090

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 (722) hide show
  1. package/Field/ErrorGroup.d.ts +4 -4
  2. package/Field/ErrorGroup.js +53 -0
  3. package/Field/FieldBase.d.ts +1 -1
  4. package/Field/FieldBase.js +77 -0
  5. package/Field/FieldBaseContainer.d.ts +2 -2
  6. package/Field/FieldBaseContainer.js +43 -0
  7. package/Field/FieldConditional.d.ts +1 -1
  8. package/Field/FieldConditional.js +45 -0
  9. package/Field/index.d.ts +1 -1
  10. package/Field/index.js +70 -112
  11. package/Field/types.d.ts +22 -12
  12. package/Field/types.js +0 -0
  13. package/Field/utils/evaluateFieldWithConditions.d.ts +2 -2
  14. package/Field/utils/evaluateFieldWithConditions.js +19 -0
  15. package/Field/utils/resolveField.d.ts +3 -0
  16. package/Field/utils/resolveField.js +32 -0
  17. package/Field/utils/useField.d.ts +1 -1
  18. package/Field/utils/useField.js +47 -0
  19. package/FieldArray/BaseFieldArray.d.ts +5 -0
  20. package/FieldArray/BaseFieldArray.js +46 -0
  21. package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.d.ts +9 -0
  22. package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js +13 -0
  23. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.d.ts +26 -0
  24. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js +117 -0
  25. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.d.ts +5 -0
  26. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js +6 -0
  27. package/FieldArray/FormDialog/ArrayDisplay/index.d.ts +15 -0
  28. package/FieldArray/FormDialog/ArrayDisplay/index.js +32 -0
  29. package/FieldArray/FormDialog/ArrayEditModal.d.ts +24 -0
  30. package/FieldArray/FormDialog/ArrayEditModal.js +138 -0
  31. package/FieldArray/FormDialog/index.d.ts +19 -0
  32. package/FieldArray/FormDialog/index.js +191 -271
  33. package/FieldArray/index.d.ts +5 -2
  34. package/FieldArray/index.js +62 -106
  35. package/FieldObject/index.d.ts +7 -4
  36. package/FieldObject/index.js +51 -72
  37. package/Fieldset/FieldsetWithContext.js +27 -0
  38. package/Fieldset/index.d.ts +1 -1
  39. package/Fieldset/index.js +18 -30
  40. package/Fieldset/types.d.ts +2 -2
  41. package/Fieldset/types.js +0 -0
  42. package/FormBuilder/index.d.ts +2 -2
  43. package/FormBuilder/index.js +233 -231
  44. package/FormContext.d.ts +3 -2
  45. package/FormContext.js +7 -0
  46. package/MultiplicityField/add-objects.d.ts +2 -2
  47. package/MultiplicityField/add-objects.js +107 -0
  48. package/MultiplicityField/index.d.ts +2 -2
  49. package/MultiplicityField/index.js +81 -116
  50. package/MultiplicityField/types.d.ts +3 -2
  51. package/MultiplicityField/types.js +0 -0
  52. package/Questions/Questions.d.ts +1 -1
  53. package/Questions/Questions.js +48 -0
  54. package/Questions/QuestionsContext.d.ts +1 -1
  55. package/Questions/QuestionsContext.js +10 -0
  56. package/Questions/Step/ReviewStep.js +32 -0
  57. package/Questions/Step/Step.d.ts +1 -1
  58. package/Questions/Step/Step.js +39 -0
  59. package/Questions/Step/StepArrayReview.d.ts +1 -1
  60. package/Questions/Step/StepArrayReview.js +35 -0
  61. package/Questions/Step/StepContext.d.ts +1 -1
  62. package/Questions/Step/StepContext.js +28 -0
  63. package/Questions/Step/StepDescription.d.ts +1 -1
  64. package/Questions/Step/StepDescription.js +18 -0
  65. package/Questions/Step/StepForm.d.ts +2 -2
  66. package/Questions/Step/StepForm.js +29 -0
  67. package/Questions/Step/StepQuote.d.ts +1 -1
  68. package/Questions/Step/StepQuote.js +5 -0
  69. package/Questions/Step/StepTitle.d.ts +1 -1
  70. package/Questions/Step/StepTitle.js +25 -0
  71. package/Questions/Step/getAddMoreFields.d.ts +2 -2
  72. package/Questions/Step/getAddMoreFields.js +24 -0
  73. package/Questions/Step/index.d.ts +11 -11
  74. package/Questions/Step/index.js +13 -16
  75. package/Questions/Step/types.d.ts +1 -1
  76. package/Questions/Step/types.js +0 -0
  77. package/Questions/getNextStep.d.ts +1 -1
  78. package/Questions/getNextStep.js +13 -0
  79. package/Questions/index.d.ts +2 -2
  80. package/Questions/index.js +4 -7
  81. package/Questions/types.d.ts +1 -1
  82. package/Questions/types.js +0 -0
  83. package/hooks/useFieldFocusManager.d.ts +25 -0
  84. package/hooks/useFieldFocusManager.js +83 -0
  85. package/hooks/utils.d.ts +18 -0
  86. package/hooks/utils.js +60 -0
  87. package/index.d.ts +5 -5
  88. package/index.js +8 -13
  89. package/inputs/AutoCompleteInput/index.d.ts +3 -3
  90. package/inputs/AutoCompleteInput/index.js +38 -62
  91. package/inputs/Checkboxes/index.d.ts +5 -3
  92. package/inputs/Checkboxes/index.js +50 -78
  93. package/inputs/DateInput/index.d.ts +2 -5
  94. package/inputs/DateInput/index.js +125 -117
  95. package/inputs/DateTimeInput/index.d.ts +2 -5
  96. package/inputs/DateTimeInput/index.js +179 -170
  97. package/inputs/FileInput/index.d.ts +12 -5
  98. package/inputs/FileInput/index.js +58 -59
  99. package/inputs/ImageInput/index.d.ts +10 -2
  100. package/inputs/ImageInput/index.js +84 -53
  101. package/inputs/Input/index.d.ts +5 -2
  102. package/inputs/Input/index.js +60 -69
  103. package/inputs/Label/index.d.ts +1 -1
  104. package/inputs/Label/index.js +13 -16
  105. package/inputs/OtpInput/index.d.ts +1 -5
  106. package/inputs/OtpInput/index.js +117 -141
  107. package/inputs/Radio/index.d.ts +6 -4
  108. package/inputs/Radio/index.js +71 -102
  109. package/inputs/Select/index.d.ts +6 -3
  110. package/inputs/Select/index.js +23 -31
  111. package/inputs/index.d.ts +9 -9
  112. package/inputs/index.js +10 -21
  113. package/{Field/utils/index.d.ts → inputs/registry.d.ts} +2 -1
  114. package/inputs/registry.js +80 -0
  115. package/internal.d.ts +5 -5
  116. package/internal.js +6 -0
  117. package/lazy.d.ts +97 -0
  118. package/lazy.js +163 -0
  119. package/package.json +12 -12
  120. package/registry.d.ts +82 -0
  121. package/registry.js +170 -0
  122. package/src/Field/ErrorGroup.tsx +4 -4
  123. package/src/Field/FieldBase.tsx +9 -4
  124. package/src/Field/FieldBaseContainer.tsx +69 -48
  125. package/src/Field/FieldConditional.tsx +5 -1
  126. package/src/Field/index.tsx +27 -37
  127. package/src/Field/types.tsx +24 -14
  128. package/src/Field/utils/evaluateFieldWithConditions.ts +5 -2
  129. package/src/Field/utils/resolveField.ts +58 -0
  130. package/src/Field/utils/useField.ts +12 -2
  131. package/src/FieldArray/BaseFieldArray.tsx +97 -0
  132. package/src/FieldArray/FieldArray.stories.js +1 -0
  133. package/src/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.tsx +45 -0
  134. package/src/FieldArray/FormDialog/ArrayDisplay/ArrayDisplay.stories.js +14 -0
  135. package/src/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.tsx +337 -0
  136. package/src/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.tsx +15 -0
  137. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Cards.tsx +88 -0
  138. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Default.tsx +93 -0
  139. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnly.tsx +79 -0
  140. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnlyCards.tsx +75 -0
  141. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Sortable.tsx +93 -0
  142. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/SortableCards.tsx +88 -0
  143. package/src/FieldArray/FormDialog/ArrayDisplay/index.test.tsx +44 -0
  144. package/src/FieldArray/FormDialog/ArrayDisplay/index.tsx +67 -0
  145. package/src/FieldArray/FormDialog/ArrayEditModal.tsx +241 -0
  146. package/src/FieldArray/FormDialog/index.tsx +302 -0
  147. package/src/FieldArray/__stories__/CardsWithError.tsx +124 -0
  148. package/src/FieldArray/__stories__/WithModal.tsx +3 -2
  149. package/src/FieldArray/__tests__/fieldset-multiplicity.spec.tsx +271 -0
  150. package/src/FieldArray/__tests__/multiplicity-attachment.spec.tsx +280 -0
  151. package/src/FieldArray/__tests__/multiplicity-optional.spec.tsx +232 -0
  152. package/src/FieldArray/__tests__/multiplicity-required.spec.tsx +170 -0
  153. package/src/FieldArray/__tests__/nested-fieldset-multiplicity.spec.tsx +627 -0
  154. package/src/FieldArray/__tests__/preference-multiple-choice.spec.tsx +222 -0
  155. package/src/FieldArray/index.spec.tsx +355 -0
  156. package/src/FieldArray/index.test.tsx +4 -0
  157. package/src/FieldArray/index.tsx +49 -73
  158. package/src/FieldObject/index.tsx +36 -31
  159. package/src/Fieldset/FieldsetWithContext.tsx +1 -1
  160. package/src/Fieldset/index.tsx +1 -1
  161. package/src/Fieldset/types.tsx +2 -2
  162. package/src/FormBuilder/doc.mdx +1 -1
  163. package/src/FormBuilder/index.tsx +197 -146
  164. package/src/FormBuilder/scenarios.test.tsx +806 -9
  165. package/src/FormContext.tsx +7 -2
  166. package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +1 -3
  167. package/src/MultiplicityField/add-objects.tsx +14 -21
  168. package/src/MultiplicityField/index.tsx +6 -2
  169. package/src/MultiplicityField/types.ts +6 -2
  170. package/src/Questions/Questions.tsx +2 -2
  171. package/src/Questions/QuestionsContext.tsx +1 -1
  172. package/src/Questions/Step/Step.tsx +1 -1
  173. package/src/Questions/Step/StepArrayReview.tsx +2 -2
  174. package/src/Questions/Step/StepContext.tsx +1 -1
  175. package/src/Questions/Step/StepDescription.tsx +2 -1
  176. package/src/Questions/Step/StepForm.tsx +2 -2
  177. package/src/Questions/Step/StepQuote.tsx +2 -1
  178. package/src/Questions/Step/StepTitle.tsx +2 -1
  179. package/src/Questions/Step/getAddMoreFields.tsx +2 -2
  180. package/src/Questions/Step/types.tsx +1 -1
  181. package/src/Questions/getNextStep.tsx +1 -1
  182. package/src/Questions/types.tsx +1 -1
  183. package/src/hooks/__tests__/useFieldFocusManager.spec.tsx +1079 -0
  184. package/src/hooks/__tests__/utils.spec.ts +568 -0
  185. package/src/hooks/useFieldFocusManager.ts +162 -0
  186. package/src/hooks/utils.ts +122 -0
  187. package/src/inputs/AutoCompleteInput/doc.mdx +2 -2
  188. package/src/inputs/AutoCompleteInput/index.tsx +4 -6
  189. package/src/inputs/Checkboxes/doc.mdx +3 -3
  190. package/src/inputs/Checkboxes/index.tsx +98 -91
  191. package/src/inputs/DateInput/DateInput.stories.js +4 -0
  192. package/src/inputs/DateInput/__stories__/WithDefaultValue.tsx +26 -0
  193. package/src/inputs/DateInput/__stories__/WithInitialValue.tsx +28 -0
  194. package/src/inputs/DateInput/__stories__/WithWrongDefaultValue.tsx +26 -0
  195. package/src/inputs/DateInput/__stories__/WithWrongInitialValue.tsx +28 -0
  196. package/src/inputs/DateInput/doc.mdx +1 -1
  197. package/src/inputs/DateInput/index.test.tsx +16 -0
  198. package/src/inputs/DateInput/index.tsx +65 -20
  199. package/src/inputs/DateTimeInput/DateTimeInput.stories.js +9 -6
  200. package/src/inputs/DateTimeInput/__stories__/WithDefaultValue.tsx +26 -0
  201. package/src/inputs/DateTimeInput/__stories__/WithInitialValue.tsx +28 -0
  202. package/src/inputs/DateTimeInput/__stories__/WithWrongDefaultValue.tsx +26 -0
  203. package/src/inputs/DateTimeInput/__stories__/WithWrongInitialValue.tsx +28 -0
  204. package/src/inputs/DateTimeInput/doc.mdx +1 -1
  205. package/src/inputs/DateTimeInput/index.test.tsx +16 -0
  206. package/src/inputs/DateTimeInput/index.tsx +92 -40
  207. package/src/inputs/FileInput/FileInput.stories.js +1 -0
  208. package/src/inputs/FileInput/__stories__/WithBorderAndLink.tsx +34 -0
  209. package/src/inputs/FileInput/doc.mdx +1 -1
  210. package/src/inputs/FileInput/index.test.tsx +4 -0
  211. package/src/inputs/FileInput/index.tsx +83 -47
  212. package/src/inputs/ImageInput/ImageInput.stories.js +2 -1
  213. package/src/inputs/ImageInput/__stories__/MaxSize.tsx +2 -1
  214. package/src/inputs/ImageInput/__stories__/WithInitialValues.tsx +45 -0
  215. package/src/inputs/ImageInput/__stories__/logo.d.ts +4 -0
  216. package/src/inputs/ImageInput/__stories__/logo.png +0 -0
  217. package/src/inputs/ImageInput/doc.mdx +3 -3
  218. package/src/inputs/ImageInput/index.test.tsx +21 -17
  219. package/src/inputs/ImageInput/index.tsx +102 -50
  220. package/src/inputs/Input/Input.stories.js +3 -0
  221. package/src/inputs/Input/__stories__/AMKA.tsx +23 -0
  222. package/src/inputs/Input/__stories__/Email.tsx +23 -0
  223. package/src/inputs/Input/__stories__/Rate.tsx +25 -0
  224. package/src/inputs/Input/doc.mdx +10 -10
  225. package/src/inputs/Input/index.test.tsx +12 -0
  226. package/src/inputs/Input/index.tsx +19 -10
  227. package/src/inputs/Label/doc.mdx +1 -1
  228. package/src/inputs/Label/index.tsx +1 -1
  229. package/src/inputs/OtpInput/doc.mdx +1 -1
  230. package/src/inputs/OtpInput/index.tsx +43 -34
  231. package/src/inputs/Radio/doc.mdx +3 -3
  232. package/src/inputs/Radio/index.tsx +33 -22
  233. package/src/inputs/Select/doc.mdx +1 -1
  234. package/src/inputs/Select/index.tsx +12 -7
  235. package/src/{Field/utils/index.ts → inputs/registry.ts} +5 -1
  236. package/{lazy/index.js → src/lazy.ts} +8 -29
  237. package/{registry/index.js → src/registry.ts} +33 -19
  238. package/src/types.tsx +14 -5
  239. package/src/utils.ts +41 -8
  240. package/src/validators/index.ts +50 -17
  241. package/src/validators/types.ts +1 -1
  242. package/src/validators/utils/amka.ts +39 -0
  243. package/src/validators/utils/date.ts +30 -6
  244. package/src/validators/utils/datetime.ts +123 -31
  245. package/src/validators/utils/email.ts +11 -0
  246. package/src/validators/utils/file.ts +35 -21
  247. package/src/validators/utils/iban.ts +2 -2
  248. package/src/validators/utils/image.ts +2 -2
  249. package/src/validators/utils/index.ts +13 -6
  250. package/src/validators/utils/int.ts +1 -1
  251. package/src/validators/utils/number.ts +1 -1
  252. package/src/validators/utils/otp.ts +2 -2
  253. package/src/validators/utils/phone.ts +2 -2
  254. package/src/validators/utils/postal_code.ts +2 -2
  255. package/src/validators/utils/text_limit.ts +2 -2
  256. package/types.d.ts +11 -5
  257. package/types.js +1 -0
  258. package/utils.d.ts +4 -1
  259. package/utils.js +56 -0
  260. package/validators/index.d.ts +6 -6
  261. package/validators/index.js +112 -139
  262. package/validators/types.d.ts +1 -1
  263. package/validators/types.js +0 -0
  264. package/validators/utils/afm.js +19 -0
  265. package/validators/utils/amka.d.ts +6 -0
  266. package/validators/utils/amka.js +27 -0
  267. package/validators/utils/date.d.ts +3 -3
  268. package/validators/utils/date.js +95 -0
  269. package/validators/utils/datetime.d.ts +3 -3
  270. package/validators/utils/datetime.js +121 -0
  271. package/validators/utils/email.d.ts +5 -0
  272. package/validators/utils/email.js +10 -0
  273. package/validators/utils/file.d.ts +2 -2
  274. package/validators/utils/file.js +31 -0
  275. package/validators/utils/iban.d.ts +2 -2
  276. package/validators/utils/iban.js +104 -0
  277. package/validators/utils/image.d.ts +2 -2
  278. package/validators/utils/image.js +65 -0
  279. package/validators/utils/index.d.ts +14 -13
  280. package/validators/utils/index.js +59 -90
  281. package/validators/utils/int.d.ts +1 -1
  282. package/validators/utils/int.js +13 -0
  283. package/validators/utils/number.d.ts +1 -1
  284. package/validators/utils/number.js +12 -0
  285. package/validators/utils/otp.d.ts +2 -2
  286. package/validators/utils/otp.js +21 -0
  287. package/validators/utils/phone.d.ts +2 -2
  288. package/validators/utils/phone.js +198 -0
  289. package/validators/utils/postal_code.d.ts +2 -2
  290. package/validators/utils/postal_code.js +18 -0
  291. package/validators/utils/text_limit.d.ts +2 -2
  292. package/validators/utils/text_limit.js +34 -0
  293. package/validators/utils/uuid4.js +14 -0
  294. package/Field/ErrorGroup/index.js +0 -48
  295. package/Field/ErrorGroup/package.json +0 -6
  296. package/Field/ErrorGroup.js.map +0 -7
  297. package/Field/FieldBase/index.js +0 -117
  298. package/Field/FieldBase/package.json +0 -6
  299. package/Field/FieldBase.js.map +0 -7
  300. package/Field/FieldBaseContainer/index.js +0 -33
  301. package/Field/FieldBaseContainer/package.json +0 -6
  302. package/Field/FieldBaseContainer.js.map +0 -7
  303. package/Field/FieldConditional/index.js +0 -85
  304. package/Field/FieldConditional/package.json +0 -6
  305. package/Field/FieldConditional.js.map +0 -7
  306. package/Field/index.js.map +0 -7
  307. package/Field/package.json +0 -6
  308. package/Field/types/index.js +0 -1
  309. package/Field/types/package.json +0 -6
  310. package/Field/types.js.map +0 -7
  311. package/Field/utils/calculateField/index.js +0 -27
  312. package/Field/utils/calculateField/package.json +0 -6
  313. package/Field/utils/calculateField.d.ts +0 -2
  314. package/Field/utils/calculateField.js.map +0 -7
  315. package/Field/utils/evaluateFieldWithConditions/index.js +0 -26
  316. package/Field/utils/evaluateFieldWithConditions/package.json +0 -6
  317. package/Field/utils/evaluateFieldWithConditions.js.map +0 -7
  318. package/Field/utils/index.js +0 -84
  319. package/Field/utils/index.js.map +0 -7
  320. package/Field/utils/package.json +0 -6
  321. package/Field/utils/useField/index.js +0 -57
  322. package/Field/utils/useField/package.json +0 -6
  323. package/Field/utils/useField.js.map +0 -7
  324. package/FieldArray/FieldArray.stories.d.ts +0 -10
  325. package/FieldArray/FormDialog/package.json +0 -6
  326. package/FieldArray/FormDialog.d.ts +0 -53
  327. package/FieldArray/FormDialog.js.map +0 -7
  328. package/FieldArray/__stories__/Default.d.ts +0 -2
  329. package/FieldArray/__stories__/WithExactLength.d.ts +0 -2
  330. package/FieldArray/__stories__/WithModal.d.ts +0 -2
  331. package/FieldArray/index.js.map +0 -7
  332. package/FieldArray/index.test.d.ts +0 -1
  333. package/FieldArray/package.json +0 -6
  334. package/FieldObject/index.js.map +0 -7
  335. package/FieldObject/package.json +0 -6
  336. package/Fieldset/FieldsetWithContext/index.js +0 -31
  337. package/Fieldset/FieldsetWithContext/package.json +0 -6
  338. package/Fieldset/FieldsetWithContext.js.map +0 -7
  339. package/Fieldset/index.js.map +0 -7
  340. package/Fieldset/package.json +0 -6
  341. package/Fieldset/types/index.js +0 -1
  342. package/Fieldset/types/package.json +0 -6
  343. package/Fieldset/types.js.map +0 -7
  344. package/Form.stories.d.ts +0 -4
  345. package/FormBuilder/FormBuilder.stories.d.ts +0 -12
  346. package/FormBuilder/__stories__/AutoErrorGrouping.d.ts +0 -3
  347. package/FormBuilder/__stories__/Default.d.ts +0 -3
  348. package/FormBuilder/__stories__/ErrorGrouping.d.ts +0 -3
  349. package/FormBuilder/index.js.map +0 -7
  350. package/FormBuilder/index.test.d.ts +0 -1
  351. package/FormBuilder/interaction.test.d.ts +0 -1
  352. package/FormBuilder/package.json +0 -6
  353. package/FormBuilder/scenarios.test.d.ts +0 -88
  354. package/FormContext/index.js +0 -9
  355. package/FormContext/package.json +0 -6
  356. package/FormContext.js.map +0 -7
  357. package/MultiplicityField/MultiplicityField.stories.d.ts +0 -15
  358. package/MultiplicityField/__stories__/Default.d.ts +0 -2
  359. package/MultiplicityField/__stories__/PreviewDisplay.d.ts +0 -2
  360. package/MultiplicityField/__stories__/WithExactLength.d.ts +0 -2
  361. package/MultiplicityField/__stories__/WithMaxLength.d.ts +0 -2
  362. package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +0 -2
  363. package/MultiplicityField/__stories__/WithMinLength.d.ts +0 -2
  364. package/MultiplicityField/add-objects/index.js +0 -153
  365. package/MultiplicityField/add-objects/package.json +0 -6
  366. package/MultiplicityField/add-objects.js.map +0 -7
  367. package/MultiplicityField/index.js.map +0 -7
  368. package/MultiplicityField/index.test.d.ts +0 -1
  369. package/MultiplicityField/package.json +0 -6
  370. package/MultiplicityField/types/index.js +0 -1
  371. package/MultiplicityField/types/package.json +0 -6
  372. package/MultiplicityField/types.js.map +0 -7
  373. package/Questions/Questions/index.js +0 -67
  374. package/Questions/Questions/package.json +0 -6
  375. package/Questions/Questions.js.map +0 -7
  376. package/Questions/Questions.stories.d.ts +0 -10
  377. package/Questions/QuestionsContext/index.js +0 -11
  378. package/Questions/QuestionsContext/package.json +0 -6
  379. package/Questions/QuestionsContext.js.map +0 -7
  380. package/Questions/Step/ReviewStep/index.js +0 -38
  381. package/Questions/Step/ReviewStep/package.json +0 -6
  382. package/Questions/Step/ReviewStep.js.map +0 -7
  383. package/Questions/Step/Step/index.js +0 -54
  384. package/Questions/Step/Step/package.json +0 -6
  385. package/Questions/Step/Step.js.map +0 -7
  386. package/Questions/Step/StepArrayReview/index.js +0 -42
  387. package/Questions/Step/StepArrayReview/package.json +0 -6
  388. package/Questions/Step/StepArrayReview.js.map +0 -7
  389. package/Questions/Step/StepContext/index.js +0 -23
  390. package/Questions/Step/StepContext/package.json +0 -6
  391. package/Questions/Step/StepContext.js.map +0 -7
  392. package/Questions/Step/StepDescription/index.js +0 -24
  393. package/Questions/Step/StepDescription/package.json +0 -6
  394. package/Questions/Step/StepDescription.js.map +0 -7
  395. package/Questions/Step/StepForm/index.js +0 -34
  396. package/Questions/Step/StepForm/package.json +0 -6
  397. package/Questions/Step/StepForm.js.map +0 -7
  398. package/Questions/Step/StepQuote/index.js +0 -11
  399. package/Questions/Step/StepQuote/package.json +0 -6
  400. package/Questions/Step/StepQuote.js.map +0 -7
  401. package/Questions/Step/StepTitle/index.js +0 -44
  402. package/Questions/Step/StepTitle/package.json +0 -6
  403. package/Questions/Step/StepTitle.js.map +0 -7
  404. package/Questions/Step/getAddMoreFields/index.js +0 -29
  405. package/Questions/Step/getAddMoreFields/package.json +0 -6
  406. package/Questions/Step/getAddMoreFields.js.map +0 -7
  407. package/Questions/Step/index.js.map +0 -7
  408. package/Questions/Step/package.json +0 -6
  409. package/Questions/Step/types/index.js +0 -1
  410. package/Questions/Step/types/package.json +0 -6
  411. package/Questions/Step/types.js.map +0 -7
  412. package/Questions/__stories__/Default.d.ts +0 -3
  413. package/Questions/getNextStep/index.js +0 -22
  414. package/Questions/getNextStep/package.json +0 -6
  415. package/Questions/getNextStep.js.map +0 -7
  416. package/Questions/index.js.map +0 -7
  417. package/Questions/index.spec.d.ts +0 -1
  418. package/Questions/index.test.d.ts +0 -1
  419. package/Questions/package.json +0 -6
  420. package/Questions/types/index.js +0 -1
  421. package/Questions/types/package.json +0 -6
  422. package/Questions/types.js.map +0 -7
  423. package/cjs/Field/ErrorGroup/index.js +0 -82
  424. package/cjs/Field/ErrorGroup.js.map +0 -7
  425. package/cjs/Field/FieldBase/index.js +0 -150
  426. package/cjs/Field/FieldBase.js.map +0 -7
  427. package/cjs/Field/FieldBaseContainer/index.js +0 -66
  428. package/cjs/Field/FieldBaseContainer.js.map +0 -7
  429. package/cjs/Field/FieldConditional/index.js +0 -118
  430. package/cjs/Field/FieldConditional.js.map +0 -7
  431. package/cjs/Field/index.js +0 -144
  432. package/cjs/Field/index.js.map +0 -7
  433. package/cjs/Field/types/index.js +0 -16
  434. package/cjs/Field/types.js.map +0 -7
  435. package/cjs/Field/utils/calculateField/index.js +0 -50
  436. package/cjs/Field/utils/calculateField.js.map +0 -7
  437. package/cjs/Field/utils/evaluateFieldWithConditions/index.js +0 -49
  438. package/cjs/Field/utils/evaluateFieldWithConditions.js.map +0 -7
  439. package/cjs/Field/utils/index.js +0 -119
  440. package/cjs/Field/utils/index.js.map +0 -7
  441. package/cjs/Field/utils/useField/index.js +0 -80
  442. package/cjs/Field/utils/useField.js.map +0 -7
  443. package/cjs/FieldArray/FormDialog/index.js +0 -301
  444. package/cjs/FieldArray/FormDialog.js.map +0 -7
  445. package/cjs/FieldArray/index.js +0 -143
  446. package/cjs/FieldArray/index.js.map +0 -7
  447. package/cjs/FieldObject/index.js +0 -106
  448. package/cjs/FieldObject/index.js.map +0 -7
  449. package/cjs/Fieldset/FieldsetWithContext/index.js +0 -59
  450. package/cjs/Fieldset/FieldsetWithContext.js.map +0 -7
  451. package/cjs/Fieldset/index.js +0 -66
  452. package/cjs/Fieldset/index.js.map +0 -7
  453. package/cjs/Fieldset/types/index.js +0 -16
  454. package/cjs/Fieldset/types.js.map +0 -7
  455. package/cjs/FormBuilder/index.js +0 -273
  456. package/cjs/FormBuilder/index.js.map +0 -7
  457. package/cjs/FormContext/index.js +0 -32
  458. package/cjs/FormContext.js.map +0 -7
  459. package/cjs/MultiplicityField/add-objects/index.js +0 -181
  460. package/cjs/MultiplicityField/add-objects.js.map +0 -7
  461. package/cjs/MultiplicityField/index.js +0 -150
  462. package/cjs/MultiplicityField/index.js.map +0 -7
  463. package/cjs/MultiplicityField/types/index.js +0 -16
  464. package/cjs/MultiplicityField/types.js.map +0 -7
  465. package/cjs/Questions/Questions/index.js +0 -100
  466. package/cjs/Questions/Questions.js.map +0 -7
  467. package/cjs/Questions/QuestionsContext/index.js +0 -34
  468. package/cjs/Questions/QuestionsContext.js.map +0 -7
  469. package/cjs/Questions/Step/ReviewStep/index.js +0 -65
  470. package/cjs/Questions/Step/ReviewStep.js.map +0 -7
  471. package/cjs/Questions/Step/Step/index.js +0 -87
  472. package/cjs/Questions/Step/Step.js.map +0 -7
  473. package/cjs/Questions/Step/StepArrayReview/index.js +0 -67
  474. package/cjs/Questions/Step/StepArrayReview.js.map +0 -7
  475. package/cjs/Questions/Step/StepContext/index.js +0 -46
  476. package/cjs/Questions/Step/StepContext.js.map +0 -7
  477. package/cjs/Questions/Step/StepDescription/index.js +0 -58
  478. package/cjs/Questions/Step/StepDescription.js.map +0 -7
  479. package/cjs/Questions/Step/StepForm/index.js +0 -67
  480. package/cjs/Questions/Step/StepForm.js.map +0 -7
  481. package/cjs/Questions/Step/StepQuote/index.js +0 -44
  482. package/cjs/Questions/Step/StepQuote.js.map +0 -7
  483. package/cjs/Questions/Step/StepTitle/index.js +0 -76
  484. package/cjs/Questions/Step/StepTitle.js.map +0 -7
  485. package/cjs/Questions/Step/getAddMoreFields/index.js +0 -52
  486. package/cjs/Questions/Step/getAddMoreFields.js.map +0 -7
  487. package/cjs/Questions/Step/index.js +0 -59
  488. package/cjs/Questions/Step/index.js.map +0 -7
  489. package/cjs/Questions/Step/types/index.js +0 -16
  490. package/cjs/Questions/Step/types.js.map +0 -7
  491. package/cjs/Questions/getNextStep/index.js +0 -45
  492. package/cjs/Questions/getNextStep.js.map +0 -7
  493. package/cjs/Questions/index.js +0 -31
  494. package/cjs/Questions/index.js.map +0 -7
  495. package/cjs/Questions/types/index.js +0 -16
  496. package/cjs/Questions/types.js.map +0 -7
  497. package/cjs/index.js +0 -49
  498. package/cjs/index.js.map +0 -7
  499. package/cjs/inputs/AutoCompleteInput/index.js +0 -98
  500. package/cjs/inputs/AutoCompleteInput/index.js.map +0 -7
  501. package/cjs/inputs/Checkboxes/index.js +0 -107
  502. package/cjs/inputs/Checkboxes/index.js.map +0 -7
  503. package/cjs/inputs/DateInput/index.js +0 -156
  504. package/cjs/inputs/DateInput/index.js.map +0 -7
  505. package/cjs/inputs/DateTimeInput/index.js +0 -211
  506. package/cjs/inputs/DateTimeInput/index.js.map +0 -7
  507. package/cjs/inputs/FileInput/index.js +0 -95
  508. package/cjs/inputs/FileInput/index.js.map +0 -7
  509. package/cjs/inputs/ImageInput/index.js +0 -99
  510. package/cjs/inputs/ImageInput/index.js.map +0 -7
  511. package/cjs/inputs/Input/index.js +0 -111
  512. package/cjs/inputs/Input/index.js.map +0 -7
  513. package/cjs/inputs/Input/inputsInputScenarios/index.js +0 -439
  514. package/cjs/inputs/Input/inputsInputScenarios.js.map +0 -7
  515. package/cjs/inputs/Label/index.js +0 -50
  516. package/cjs/inputs/Label/index.js.map +0 -7
  517. package/cjs/inputs/OtpInput/index.js +0 -181
  518. package/cjs/inputs/OtpInput/index.js.map +0 -7
  519. package/cjs/inputs/Radio/index.js +0 -134
  520. package/cjs/inputs/Radio/index.js.map +0 -7
  521. package/cjs/inputs/Select/index.js +0 -62
  522. package/cjs/inputs/Select/index.js.map +0 -7
  523. package/cjs/inputs/index.js +0 -62
  524. package/cjs/inputs/index.js.map +0 -7
  525. package/cjs/inputs/inputsScenarios/index.js +0 -533
  526. package/cjs/inputs/inputsScenarios.js.map +0 -7
  527. package/cjs/internal/index.js +0 -38
  528. package/cjs/internal.js.map +0 -7
  529. package/cjs/lazy/index.js +0 -110
  530. package/cjs/lazy.js.map +0 -7
  531. package/cjs/locales/el/index.js +0 -35
  532. package/cjs/locales/el.js.map +0 -7
  533. package/cjs/registry/index.js +0 -195
  534. package/cjs/registry.js.map +0 -7
  535. package/cjs/types/index.js +0 -22
  536. package/cjs/types.js.map +0 -7
  537. package/cjs/utils/index.js +0 -83
  538. package/cjs/utils.js.map +0 -7
  539. package/cjs/validators/index.js +0 -160
  540. package/cjs/validators/index.js.map +0 -7
  541. package/cjs/validators/types/index.js +0 -16
  542. package/cjs/validators/types.js.map +0 -7
  543. package/cjs/validators/utils/afm/index.js +0 -55
  544. package/cjs/validators/utils/afm.js.map +0 -7
  545. package/cjs/validators/utils/date/index.js +0 -138
  546. package/cjs/validators/utils/date.js.map +0 -7
  547. package/cjs/validators/utils/datetime/index.js +0 -151
  548. package/cjs/validators/utils/datetime.js.map +0 -7
  549. package/cjs/validators/utils/file/index.js +0 -48
  550. package/cjs/validators/utils/file.js.map +0 -7
  551. package/cjs/validators/utils/iban/index.js +0 -142
  552. package/cjs/validators/utils/iban.js.map +0 -7
  553. package/cjs/validators/utils/image/index.js +0 -102
  554. package/cjs/validators/utils/image.js.map +0 -7
  555. package/cjs/validators/utils/index.js +0 -144
  556. package/cjs/validators/utils/index.js.map +0 -7
  557. package/cjs/validators/utils/int/index.js +0 -48
  558. package/cjs/validators/utils/int.js.map +0 -7
  559. package/cjs/validators/utils/number/index.js +0 -44
  560. package/cjs/validators/utils/number.js.map +0 -7
  561. package/cjs/validators/utils/otp/index.js +0 -54
  562. package/cjs/validators/utils/otp.js.map +0 -7
  563. package/cjs/validators/utils/phone/index.js +0 -198
  564. package/cjs/validators/utils/phone.js.map +0 -7
  565. package/cjs/validators/utils/postal_code/index.js +0 -54
  566. package/cjs/validators/utils/postal_code.js.map +0 -7
  567. package/cjs/validators/utils/text_limit/index.js +0 -69
  568. package/cjs/validators/utils/text_limit.js.map +0 -7
  569. package/cjs/validators/utils/uuid4/index.js +0 -46
  570. package/cjs/validators/utils/uuid4.js.map +0 -7
  571. package/index.js.map +0 -7
  572. package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +0 -11
  573. package/inputs/AutoCompleteInput/__stories__/Default.d.ts +0 -3
  574. package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +0 -3
  575. package/inputs/AutoCompleteInput/index.js.map +0 -7
  576. package/inputs/AutoCompleteInput/index.test.d.ts +0 -1
  577. package/inputs/AutoCompleteInput/package.json +0 -6
  578. package/inputs/Checkboxes/Checkboxes.stories.d.ts +0 -12
  579. package/inputs/Checkboxes/__stories__/Conditional.d.ts +0 -3
  580. package/inputs/Checkboxes/__stories__/Default.d.ts +0 -3
  581. package/inputs/Checkboxes/__stories__/WithDivider.d.ts +0 -3
  582. package/inputs/Checkboxes/index.js.map +0 -7
  583. package/inputs/Checkboxes/index.test.d.ts +0 -1
  584. package/inputs/Checkboxes/package.json +0 -6
  585. package/inputs/DateInput/DateInput.stories.d.ts +0 -10
  586. package/inputs/DateInput/__stories__/Default.d.ts +0 -3
  587. package/inputs/DateInput/index.js.map +0 -7
  588. package/inputs/DateInput/index.test.d.ts +0 -1
  589. package/inputs/DateInput/package.json +0 -6
  590. package/inputs/DateTimeInput/DateTimeInput.stories.d.ts +0 -9
  591. package/inputs/DateTimeInput/__stories__/Default.d.ts +0 -3
  592. package/inputs/DateTimeInput/index.js.map +0 -7
  593. package/inputs/DateTimeInput/index.test.d.ts +0 -1
  594. package/inputs/DateTimeInput/package.json +0 -6
  595. package/inputs/FileInput/FileInput.stories.d.ts +0 -10
  596. package/inputs/FileInput/__stories__/Default.d.ts +0 -3
  597. package/inputs/FileInput/index.js.map +0 -7
  598. package/inputs/FileInput/index.test.d.ts +0 -1
  599. package/inputs/FileInput/package.json +0 -6
  600. package/inputs/ImageInput/ImageInput.stories.d.ts +0 -12
  601. package/inputs/ImageInput/__stories__/Default.d.ts +0 -3
  602. package/inputs/ImageInput/__stories__/MaxSize.d.ts +0 -3
  603. package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +0 -3
  604. package/inputs/ImageInput/index.js.map +0 -7
  605. package/inputs/ImageInput/index.test.d.ts +0 -1
  606. package/inputs/ImageInput/package.json +0 -6
  607. package/inputs/Input/Input.stories.d.ts +0 -20
  608. package/inputs/Input/__stories__/AFM.d.ts +0 -3
  609. package/inputs/Input/__stories__/Boolean.d.ts +0 -3
  610. package/inputs/Input/__stories__/IBAN.d.ts +0 -3
  611. package/inputs/Input/__stories__/Integer.d.ts +0 -3
  612. package/inputs/Input/__stories__/LandlineNumber.d.ts +0 -3
  613. package/inputs/Input/__stories__/MobilePhone.d.ts +0 -3
  614. package/inputs/Input/__stories__/PhoneNumber.d.ts +0 -3
  615. package/inputs/Input/__stories__/PostalCode.d.ts +0 -3
  616. package/inputs/Input/__stories__/String.d.ts +0 -3
  617. package/inputs/Input/__stories__/StringWithTrimValidation.d.ts +0 -3
  618. package/inputs/Input/__stories__/TextWithLimit.d.ts +0 -3
  619. package/inputs/Input/index.js.map +0 -7
  620. package/inputs/Input/index.test.d.ts +0 -1
  621. package/inputs/Input/inputsInputScenarios/index.js +0 -406
  622. package/inputs/Input/inputsInputScenarios/package.json +0 -6
  623. package/inputs/Input/inputsInputScenarios.d.ts +0 -57
  624. package/inputs/Input/inputsInputScenarios.js.map +0 -7
  625. package/inputs/Input/package.json +0 -6
  626. package/inputs/Label/Label.stories.d.ts +0 -10
  627. package/inputs/Label/__stories__/Default.d.ts +0 -3
  628. package/inputs/Label/index.js.map +0 -7
  629. package/inputs/Label/index.test.d.ts +0 -1
  630. package/inputs/Label/package.json +0 -6
  631. package/inputs/OtpInput/OtpInput.stories.d.ts +0 -10
  632. package/inputs/OtpInput/__stories__/Default.d.ts +0 -3
  633. package/inputs/OtpInput/index.js.map +0 -7
  634. package/inputs/OtpInput/index.test.d.ts +0 -1
  635. package/inputs/OtpInput/package.json +0 -6
  636. package/inputs/Radio/Radio.stories.d.ts +0 -12
  637. package/inputs/Radio/__stories__/Conditional.d.ts +0 -3
  638. package/inputs/Radio/__stories__/Default.d.ts +0 -3
  639. package/inputs/Radio/__stories__/WithDivider.d.ts +0 -3
  640. package/inputs/Radio/index.js.map +0 -7
  641. package/inputs/Radio/index.test.d.ts +0 -1
  642. package/inputs/Radio/package.json +0 -6
  643. package/inputs/Select/Select.stories.d.ts +0 -10
  644. package/inputs/Select/__stories__/Default.d.ts +0 -3
  645. package/inputs/Select/index.js.map +0 -7
  646. package/inputs/Select/index.test.d.ts +0 -1
  647. package/inputs/Select/package.json +0 -6
  648. package/inputs/index.js.map +0 -7
  649. package/inputs/inputsScenarios/index.js +0 -499
  650. package/inputs/inputsScenarios/package.json +0 -6
  651. package/inputs/inputsScenarios.d.ts +0 -296
  652. package/inputs/inputsScenarios.js.map +0 -7
  653. package/inputs/package.json +0 -6
  654. package/internal/index.js +0 -10
  655. package/internal/package.json +0 -6
  656. package/internal.js.map +0 -7
  657. package/lazy/package.json +0 -6
  658. package/locales/el/index.js +0 -6
  659. package/locales/el/package.json +0 -6
  660. package/locales/el.d.ts +0 -2
  661. package/locales/el.js.map +0 -7
  662. package/registry/package.json +0 -6
  663. package/src/Field/utils/calculateField.ts +0 -49
  664. package/src/FieldArray/FormDialog.tsx +0 -378
  665. package/src/inputs/Input/inputsInputScenarios.ts +0 -404
  666. package/src/inputs/inputsScenarios.ts +0 -496
  667. package/src/lazy.js +0 -77
  668. package/src/locales/el.ts +0 -3
  669. package/src/registry.js +0 -165
  670. package/types/index.js +0 -2
  671. package/types/package.json +0 -6
  672. package/types.js.map +0 -7
  673. package/utils/index.js +0 -60
  674. package/utils/package.json +0 -6
  675. package/utils.js.map +0 -7
  676. package/validators/index.js.map +0 -7
  677. package/validators/package.json +0 -6
  678. package/validators/types/index.js +0 -1
  679. package/validators/types/package.json +0 -6
  680. package/validators/types.js.map +0 -7
  681. package/validators/utils/afm/index.js +0 -31
  682. package/validators/utils/afm/package.json +0 -6
  683. package/validators/utils/afm.js.map +0 -7
  684. package/validators/utils/date/index.js +0 -103
  685. package/validators/utils/date/package.json +0 -6
  686. package/validators/utils/date.js.map +0 -7
  687. package/validators/utils/datetime/index.js +0 -116
  688. package/validators/utils/datetime/package.json +0 -6
  689. package/validators/utils/datetime.js.map +0 -7
  690. package/validators/utils/file/index.js +0 -25
  691. package/validators/utils/file/package.json +0 -6
  692. package/validators/utils/file.js.map +0 -7
  693. package/validators/utils/iban/index.js +0 -118
  694. package/validators/utils/iban/package.json +0 -6
  695. package/validators/utils/iban.js.map +0 -7
  696. package/validators/utils/image/index.js +0 -79
  697. package/validators/utils/image/package.json +0 -6
  698. package/validators/utils/image.js.map +0 -7
  699. package/validators/utils/index.js.map +0 -7
  700. package/validators/utils/int/index.js +0 -24
  701. package/validators/utils/int/package.json +0 -6
  702. package/validators/utils/int.js.map +0 -7
  703. package/validators/utils/number/index.js +0 -20
  704. package/validators/utils/number/package.json +0 -6
  705. package/validators/utils/number.js.map +0 -7
  706. package/validators/utils/otp/index.js +0 -30
  707. package/validators/utils/otp/package.json +0 -6
  708. package/validators/utils/otp.js.map +0 -7
  709. package/validators/utils/package.json +0 -6
  710. package/validators/utils/phone/index.js +0 -172
  711. package/validators/utils/phone/package.json +0 -6
  712. package/validators/utils/phone.js.map +0 -7
  713. package/validators/utils/postal_code/index.js +0 -30
  714. package/validators/utils/postal_code/package.json +0 -6
  715. package/validators/utils/postal_code.js.map +0 -7
  716. package/validators/utils/text_limit/index.js +0 -45
  717. package/validators/utils/text_limit/package.json +0 -6
  718. package/validators/utils/text_limit.js.map +0 -7
  719. package/validators/utils/uuid4/index.js +0 -22
  720. package/validators/utils/uuid4/package.json +0 -6
  721. package/validators/utils/uuid4.js.map +0 -7
  722. package/validators/validators.spec.d.ts +0 -1
@@ -1,4 +1,4 @@
1
- import { FieldSpec } from '@digigov/form/types';
2
- import { ValidatorSchema } from '@digigov/form/validators/types';
1
+ import type { FieldSpec } from '../../types.js';
2
+ import type { ValidatorSchema } from '../types.js';
3
3
  export declare function validateText(value: string, min: number, max: number): boolean;
4
4
  export declare const TEXT_LIMIT_VALIDATOR: (field: FieldSpec) => ValidatorSchema;
@@ -0,0 +1,34 @@
1
+ function validateText(value, min, max) {
2
+ let validator;
3
+ if (min || max) if (value.length < min || value.length > max) return false;
4
+ else return true;
5
+ return validator;
6
+ }
7
+ const TEXT_LIMIT_VALIDATOR = (field)=>{
8
+ const min = field?.extra?.limit?.min;
9
+ const max = field?.extra?.limit?.max;
10
+ return {
11
+ name: 'text-limit-validator',
12
+ message: (v)=>{
13
+ if (min || max) {
14
+ if (v.value.length < min) return {
15
+ key: 'form.error.text.less_than',
16
+ context: {
17
+ min: field?.extra?.limit?.min
18
+ }
19
+ };
20
+ if (v.value.length > max) return {
21
+ key: 'form.error.text.more_than',
22
+ context: {
23
+ max: field?.extra?.limit?.max
24
+ }
25
+ };
26
+ }
27
+ },
28
+ test: (value)=>{
29
+ if (!value) return true;
30
+ return validateText(value, min, max);
31
+ }
32
+ };
33
+ };
34
+ export { TEXT_LIMIT_VALIDATOR, validateText };
@@ -0,0 +1,14 @@
1
+ const UUID4_PATTERN = /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
2
+ function validateUUID4(uuid4) {
3
+ if (36 !== uuid4.length) return false;
4
+ return UUID4_PATTERN.test(uuid4);
5
+ }
6
+ const UUID4_VALIDATOR = {
7
+ name: 'uuid4-validator',
8
+ message: 'form.error.uuid4',
9
+ test: (value)=>{
10
+ if (value) return validateUUID4(value);
11
+ return true;
12
+ }
13
+ };
14
+ export { UUID4_VALIDATOR, validateUUID4 };
@@ -1,48 +0,0 @@
1
- import React, { createContext, useEffect, useState } from "react";
2
- import { List, ListItem } from "@digigov/ui/content/List";
3
- import { ErrorSummary } from "@digigov/ui/feedback/ErrorSummary";
4
- import { useTranslation } from "@digigov/ui/i18n";
5
- import { Link } from "@digigov/ui/navigation/Link";
6
- import { Heading } from "@digigov/ui/typography/Heading";
7
- import { Base } from "@digigov/ui/utils/Base";
8
- const ErrorGroupContext = createContext(
9
- null
10
- );
11
- const ErrorGroup = ({
12
- children,
13
- screenSize,
14
- fieldOrder
15
- }) => {
16
- const [errors, setErrors] = useState({});
17
- const { t } = useTranslation();
18
- const setError = (name, label, error) => {
19
- if (errors[name] !== error && errors[name]?.message !== error?.message) {
20
- if (!error?.message) {
21
- const updatedErrors = { ...errors };
22
- delete updatedErrors[name];
23
- setErrors(updatedErrors);
24
- } else {
25
- setErrors({
26
- ...errors,
27
- [name]: {
28
- ...error,
29
- label: label.primary
30
- }
31
- });
32
- }
33
- }
34
- };
35
- useEffect(() => {
36
- setErrors({});
37
- }, [screenSize]);
38
- return /* @__PURE__ */ React.createElement(ErrorGroupContext.Provider, { value: { setError } }, Object.keys(errors).length !== 0 && /* @__PURE__ */ React.createElement(ErrorSummary, { variant: "error-group" }, /* @__PURE__ */ React.createElement(Heading, { size: "sm" }, "\u03A4\u03B1 \u03C0\u03B1\u03C1\u03B1\u03BA\u03AC\u03C4\u03C9 \u03C0\u03B5\u03B4\u03AF\u03B1 \u03C4\u03B7\u03C2 \u03C6\u03CC\u03C1\u03BC\u03B1\u03C2 \u03B5\u03B9\u03BD\u03B1\u03B9 \u03BB\u03AC\u03B8\u03BF\u03C2.", " "), /* @__PURE__ */ React.createElement(List, { listStyle: "bullet" }, (fieldOrder || Object.keys(errors).reverse()).filter((fieldName) => errors[fieldName]).map((fieldName, index) => {
39
- return /* @__PURE__ */ React.createElement(ListItem, { key: index, id: `${fieldName}-error` }, /* @__PURE__ */ React.createElement(Base, { as: "b" }, t(errors[fieldName]?.label), ":"), " ", /* @__PURE__ */ React.createElement(Link, { href: `#${fieldName}` }, t(errors[fieldName]?.message)));
40
- }))), children);
41
- };
42
- var ErrorGroup_default = ErrorGroup;
43
- export {
44
- ErrorGroup,
45
- ErrorGroupContext,
46
- ErrorGroup_default as default
47
- };
48
- //# sourceMappingURL=ErrorGroup.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "module": "./index.js",
4
- "types": "./index.d.ts",
5
- "main": "../../cjs/Field/ErrorGroup/index.js"
6
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/Field/ErrorGroup.tsx"],
4
- "sourcesContent": ["import React, { createContext, useEffect, useState } from 'react';\nimport { ErrorOption } from 'react-hook-form';\nimport { FieldLabelProps } from '@digigov/form/Field/types';\nimport { List, ListItem } from '@digigov/ui/content/List';\nimport { ErrorSummary } from '@digigov/ui/feedback/ErrorSummary';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Link } from '@digigov/ui/navigation/Link';\nimport { Heading } from '@digigov/ui/typography/Heading';\nimport { Base } from '@digigov/ui/utils/Base';\nimport { Breakpoints } from '@digigov/ui/utils/hooks/useScreen';\ninterface ErrorGroupContextType {\n setError: (\n name?: string,\n label?: FieldLabelProps,\n error?: ErrorOption\n ) => void;\n}\nexport const ErrorGroupContext = createContext<ErrorGroupContextType | null>(\n null\n);\n\nexport interface ErrorGroupProps {\n children: React.ReactNode;\n screenSize?: Breakpoints | undefined;\n fieldOrder?: any[];\n}\n\nexport const ErrorGroup: React.FC<ErrorGroupProps> = ({\n children,\n screenSize,\n fieldOrder,\n}) => {\n const [errors, setErrors] = useState<ErrorOption>({});\n const { t } = useTranslation();\n const setError = (name, label, error) => {\n if (errors[name] !== error && errors[name]?.message !== error?.message) {\n if (!error?.message) {\n const updatedErrors = { ...errors };\n delete updatedErrors[name];\n setErrors(updatedErrors);\n } else {\n setErrors({\n ...errors,\n [name]: {\n ...error,\n label: label.primary,\n },\n });\n }\n }\n };\n\n useEffect(() => {\n setErrors({});\n }, [screenSize]);\n return (\n <ErrorGroupContext.Provider value={{ setError }}>\n {Object.keys(errors).length !== 0 && (\n <ErrorSummary variant=\"error-group\">\n <Heading size=\"sm\">\n \u03A4\u03B1 \u03C0\u03B1\u03C1\u03B1\u03BA\u03AC\u03C4\u03C9 \u03C0\u03B5\u03B4\u03AF\u03B1 \u03C4\u03B7\u03C2 \u03C6\u03CC\u03C1\u03BC\u03B1\u03C2 \u03B5\u03B9\u03BD\u03B1\u03B9 \u03BB\u03AC\u03B8\u03BF\u03C2.{' '}\n </Heading>\n <List listStyle=\"bullet\">\n {(fieldOrder || Object.keys(errors).reverse())\n .filter((fieldName) => errors[fieldName])\n .map((fieldName, index) => {\n return (\n <ListItem key={index} id={`${fieldName}-error`}>\n <Base as=\"b\">{t(errors[fieldName]?.label)}:</Base>{' '}\n <Link href={`#${fieldName}`}>\n {t(errors[fieldName]?.message)}\n </Link>\n </ListItem>\n );\n })}\n </List>\n </ErrorSummary>\n )}\n {children}\n </ErrorGroupContext.Provider>\n );\n};\n\nexport default ErrorGroup;\n"],
5
- "mappings": "AAAA,OAAO,SAAS,eAAe,WAAW,gBAAgB;AAG1D,SAAS,MAAM,gBAAgB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,YAAY;AASd,MAAM,oBAAoB;AAAA,EAC/B;AACF;AAQO,MAAM,aAAwC,CAAC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAsB,CAAC,CAAC;AACpD,QAAM,EAAE,EAAE,IAAI,eAAe;AAC7B,QAAM,WAAW,CAAC,MAAM,OAAO,UAAU;AACvC,QAAI,OAAO,IAAI,MAAM,SAAS,OAAO,IAAI,GAAG,YAAY,OAAO,SAAS;AACtE,UAAI,CAAC,OAAO,SAAS;AACnB,cAAM,gBAAgB,EAAE,GAAG,OAAO;AAClC,eAAO,cAAc,IAAI;AACzB,kBAAU,aAAa;AAAA,MACzB,OAAO;AACL,kBAAU;AAAA,UACR,GAAG;AAAA,UACH,CAAC,IAAI,GAAG;AAAA,YACN,GAAG;AAAA,YACH,OAAO,MAAM;AAAA,UACf;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,YAAU,MAAM;AACd,cAAU,CAAC,CAAC;AAAA,EACd,GAAG,CAAC,UAAU,CAAC;AACf,SACE,oCAAC,kBAAkB,UAAlB,EAA2B,OAAO,EAAE,SAAS,KAC3C,OAAO,KAAK,MAAM,EAAE,WAAW,KAC9B,oCAAC,gBAAa,SAAQ,iBACpB,oCAAC,WAAQ,MAAK,QAAK,uNACyB,GAC5C,GACA,oCAAC,QAAK,WAAU,aACZ,cAAc,OAAO,KAAK,MAAM,EAAE,QAAQ,GACzC,OAAO,CAAC,cAAc,OAAO,SAAS,CAAC,EACvC,IAAI,CAAC,WAAW,UAAU;AACzB,WACE,oCAAC,YAAS,KAAK,OAAO,IAAI,GAAG,SAAS,YACpC,oCAAC,QAAK,IAAG,OAAK,EAAE,OAAO,SAAS,GAAG,KAAK,GAAE,GAAC,GAAQ,KACnD,oCAAC,QAAK,MAAM,IAAI,SAAS,MACtB,EAAE,OAAO,SAAS,GAAG,OAAO,CAC/B,CACF;AAAA,EAEJ,CAAC,CACL,CACF,GAED,QACH;AAEJ;AAEA,IAAO,qBAAQ;",
6
- "names": []
7
- }
@@ -1,117 +0,0 @@
1
- import React, { useContext, useEffect } from "react";
2
- import { Controller } from "react-hook-form";
3
- import { ErrorGroupContext } from "@digigov/form/Field/ErrorGroup";
4
- import FieldBaseContainer from "@digigov/form/Field/FieldBaseContainer";
5
- const FieldBase = ({
6
- required,
7
- name,
8
- component: Component,
9
- wrapper,
10
- control,
11
- type,
12
- controlled = false,
13
- enabled = true,
14
- editable,
15
- defaultValue,
16
- label,
17
- extra = {},
18
- layout,
19
- error,
20
- register,
21
- ...componentProps
22
- }) => {
23
- const errorGroupContext = useContext(ErrorGroupContext);
24
- useEffect(() => {
25
- if (errorGroupContext) {
26
- errorGroupContext.setError(name, label, error);
27
- }
28
- }, [error, name, errorGroupContext?.setError]);
29
- if (!enabled) {
30
- return null;
31
- }
32
- if (controlled) {
33
- return /* @__PURE__ */ React.createElement(
34
- FieldBaseContainer,
35
- {
36
- label,
37
- layout,
38
- error: errorGroupContext ? void 0 : error,
39
- hasError: !!error,
40
- wrapper,
41
- name
42
- },
43
- /* @__PURE__ */ React.createElement(
44
- Controller,
45
- {
46
- control,
47
- name,
48
- render: ({ field }) => {
49
- return /* @__PURE__ */ React.createElement(
50
- Component,
51
- {
52
- ...field,
53
- control,
54
- ref: void 0,
55
- defaultValue,
56
- extra,
57
- error: !!error,
58
- type,
59
- "aria-required": !!required,
60
- "aria-describedby": error && `${name}-error`,
61
- required,
62
- disabled: editable === false,
63
- ...componentProps
64
- }
65
- );
66
- }
67
- }
68
- )
69
- );
70
- }
71
- return /* @__PURE__ */ React.createElement(
72
- FieldBaseContainer,
73
- {
74
- label,
75
- layout,
76
- error: errorGroupContext ? void 0 : error,
77
- hasError: !!error,
78
- wrapper,
79
- name
80
- },
81
- Component?.render ? /* @__PURE__ */ React.createElement(
82
- Component,
83
- {
84
- ...register(name),
85
- control,
86
- error: !!error,
87
- extra,
88
- type,
89
- "aria-required": !!required,
90
- "aria-describedby": error && `${name}-error`,
91
- required,
92
- disabled: editable === false,
93
- ...componentProps
94
- }
95
- ) : /* @__PURE__ */ React.createElement(
96
- Component,
97
- {
98
- ...register(name),
99
- register,
100
- control,
101
- error: !!error,
102
- extra,
103
- type,
104
- "aria-required": !!required,
105
- "aria-describedby": error && `${name}-error`,
106
- required,
107
- disabled: editable === false,
108
- ref: void 0,
109
- ...componentProps
110
- }
111
- )
112
- );
113
- };
114
- export {
115
- FieldBase
116
- };
117
- //# sourceMappingURL=FieldBase.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "module": "./index.js",
4
- "types": "./index.d.ts",
5
- "main": "../../cjs/Field/FieldBase/index.js"
6
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/Field/FieldBase.tsx"],
4
- "sourcesContent": ["import React, { useContext, useEffect } from 'react';\nimport { Controller } from 'react-hook-form';\nimport { ErrorGroupContext } from '@digigov/form/Field/ErrorGroup';\nimport FieldBaseContainer from '@digigov/form/Field/FieldBaseContainer';\nimport { FieldBaseProps } from '@digigov/form/Field/types';\n\nexport const FieldBase: React.FC<FieldBaseProps> = ({\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}) => {\n const errorGroupContext = useContext(ErrorGroupContext);\n\n useEffect(() => {\n if (errorGroupContext) {\n errorGroupContext.setError(name, label, error);\n }\n }, [error, name, errorGroupContext?.setError]);\n\n if (!enabled) {\n return null;\n }\n\n if (controlled) {\n return (\n <FieldBaseContainer\n label={label}\n layout={layout}\n error={errorGroupContext ? undefined : error}\n hasError={!!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 control={control}\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={errorGroupContext ? undefined : error}\n hasError={!!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,SAAS,YAAY,iBAAiB;AAC7C,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB;AAClC,OAAO,wBAAwB;AAGxB,MAAM,YAAsC,CAAC;AAAA,EAClD;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ,CAAC;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,oBAAoB,WAAW,iBAAiB;AAEtD,YAAU,MAAM;AACd,QAAI,mBAAmB;AACrB,wBAAkB,SAAS,MAAM,OAAO,KAAK;AAAA,IAC/C;AAAA,EACF,GAAG,CAAC,OAAO,MAAM,mBAAmB,QAAQ,CAAC;AAE7C,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AAEA,MAAI,YAAY;AACd,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA,OAAO,oBAAoB,SAAY;AAAA,QACvC,UAAU,CAAC,CAAC;AAAA,QACZ;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;AAAA,gBACA,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,OAAO,oBAAoB,SAAY;AAAA,MACvC,UAAU,CAAC,CAAC;AAAA,MACZ;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
- "names": []
7
- }
@@ -1,33 +0,0 @@
1
- import React from "react";
2
- import Label from "@digigov/form/inputs/Label";
3
- import { ErrorMessage } from "@digigov/react-core/ErrorMessage";
4
- import FieldContainer from "@digigov/react-core/FieldContainer";
5
- import CoreFieldset from "@digigov/react-core/Fieldset";
6
- import FieldsetLegend from "@digigov/react-core/FieldsetLegend";
7
- import LabelContainer from "@digigov/react-core/LabelContainer";
8
- import { useTranslation } from "@digigov/ui/i18n";
9
- import { Hint } from "@digigov/ui/typography/Hint";
10
- const FieldBaseContainer = ({
11
- name,
12
- wrapper,
13
- label,
14
- children,
15
- error,
16
- hasError,
17
- layout
18
- }) => {
19
- const { t } = useTranslation();
20
- const errorMessage = error?.message.key ? error.message.key : error?.message || "";
21
- const errorContext = error?.message.context || {};
22
- if (wrapper === "fieldset") {
23
- return /* @__PURE__ */ React.createElement(FieldContainer, { error: hasError, ...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, label && label.hint && /* @__PURE__ */ React.createElement(Hint, { size: "sm" }, label.hint)));
24
- } else {
25
- return /* @__PURE__ */ React.createElement(FieldContainer, { error: hasError, ...layout }, /* @__PURE__ */ React.createElement(LabelContainer, null, label && /* @__PURE__ */ React.createElement(Label, { label }), error && /* @__PURE__ */ React.createElement(ErrorMessage, { id: `${name}-error` }, t(errorMessage, errorContext)), children, label && label.hint && /* @__PURE__ */ React.createElement(Hint, { size: "sm" }, label.hint)));
26
- }
27
- };
28
- var FieldBaseContainer_default = FieldBaseContainer;
29
- export {
30
- FieldBaseContainer,
31
- FieldBaseContainer_default as default
32
- };
33
- //# sourceMappingURL=FieldBaseContainer.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "module": "./index.js",
4
- "types": "./index.d.ts",
5
- "main": "../../cjs/Field/FieldBaseContainer/index.js"
6
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/Field/FieldBaseContainer.tsx"],
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 LabelContainer from '@digigov/react-core/LabelContainer';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\n\nexport const FieldBaseContainer: React.FC<FieldContainerProps> = ({\n name,\n wrapper,\n label,\n children,\n error,\n hasError,\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={hasError} {...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 {label && label.hint && <Hint size=\"sm\">{label.hint}</Hint>}\n </CoreFieldset>\n </FieldContainer>\n );\n } else {\n return (\n <FieldContainer error={hasError} {...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 {label && label.hint && <Hint size=\"sm\">{label.hint}</Hint>}\n </LabelContainer>\n </FieldContainer>\n );\n }\n};\n\nexport default FieldBaseContainer;\n"],
5
- "mappings": "AAAA,OAAO,WAAW;AAElB,OAAO,WAAW;AAClB,SAAS,oBAAoB;AAC7B,OAAO,oBAAoB;AAC3B,OAAO,kBAAkB;AACzB,OAAO,oBAAoB;AAC3B,OAAO,oBAAoB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,YAAY;AAEd,MAAM,qBAAoD,CAAC;AAAA,EAChE;AAAA,EACA;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,UAAW,GAAG,UACnC,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,UACA,SAAS,MAAM,QAAQ,oCAAC,QAAK,MAAK,QAAM,MAAM,IAAK,CACtD,CACF;AAAA,EAEJ,OAAO;AACL,WACE,oCAAC,kBAAe,OAAO,UAAW,GAAG,UACnC,oCAAC,sBACE,SAAS,oCAAC,SAAM,OAAc,GAC9B,SACC,oCAAC,gBAAa,IAAI,GAAG,IAAI,YACtB,EAAE,cAAc,YAAY,CAC/B,GAED,UACA,SAAS,MAAM,QAAQ,oCAAC,QAAK,MAAK,QAAM,MAAM,IAAK,CACtD,CACF;AAAA,EAEJ;AACF;AAEA,IAAO,6BAAQ;",
6
- "names": []
7
- }
@@ -1,85 +0,0 @@
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/evaluateFieldWithConditions";
5
- const ChildFieldMemo = React.memo(
6
- function ChildField({
7
- dependencies,
8
- field,
9
- control,
10
- reset,
11
- register,
12
- error,
13
- Field
14
- }) {
15
- const newField = evaluateFieldWithConditions(
16
- field,
17
- dependencies
18
- );
19
- return /* @__PURE__ */ React.createElement(
20
- FieldBase,
21
- {
22
- ...newField,
23
- Field,
24
- name: newField.key,
25
- reset,
26
- control,
27
- register,
28
- error
29
- }
30
- );
31
- },
32
- (prev, next) => {
33
- if (!prev || !prev.dependencies) {
34
- return false;
35
- }
36
- if (prev.error !== next.error) {
37
- return false;
38
- }
39
- for (const dep in next.dependencies) {
40
- if (next.dependencies[dep] !== prev.dependencies[dep]) {
41
- return false;
42
- }
43
- }
44
- return true;
45
- }
46
- );
47
- const FieldConditional = ({
48
- control,
49
- field,
50
- register,
51
- reset,
52
- error,
53
- Field
54
- }) => {
55
- const dependencyKeys = Object.keys(field.condition);
56
- const dependencyValues = useWatch({
57
- name: dependencyKeys,
58
- control
59
- });
60
- const variables = dependencyKeys.reduce(
61
- (data, fieldKey, index) => ({
62
- ...data,
63
- [fieldKey]: dependencyValues[index]
64
- }),
65
- {}
66
- );
67
- return /* @__PURE__ */ React.createElement(
68
- ChildFieldMemo,
69
- {
70
- dependencies: variables,
71
- field,
72
- control,
73
- register,
74
- reset,
75
- error,
76
- Field
77
- }
78
- );
79
- };
80
- var FieldConditional_default = FieldConditional;
81
- export {
82
- FieldConditional,
83
- FieldConditional_default as default
84
- };
85
- //# sourceMappingURL=FieldConditional.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "module": "./index.js",
4
- "types": "./index.d.ts",
5
- "main": "../../cjs/Field/FieldConditional/index.js"
6
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 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/evaluateFieldWithConditions';\n\nconst ChildFieldMemo = React.memo(\n function ChildField({\n dependencies,\n field,\n control,\n reset,\n register,\n error,\n Field,\n }: ChildFieldMemoProps) {\n const newField = evaluateFieldWithConditions(\n field,\n dependencies as FormData\n );\n return (\n <FieldBase\n {...newField}\n Field={Field}\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 Field,\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 Field={Field}\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,IACA;AAAA,EACF,GAAwB;AACtB,UAAM,WAAW;AAAA,MACf;AAAA,MACA;AAAA,IACF;AACA,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,QACA,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;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,MACA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,2BAAQ;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 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 {\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 Field={Field}\n />\n );\n }\n if (calculatedField.type === 'array' && !calculatedField.multiplicity) {\n calculatedField.name = name;\n return (\n <FieldArray\n control={control}\n trigger={trigger}\n register={register}\n clearErrors={clearErrors}\n error={error}\n getValues={getValues}\n setValue={setValue}\n formState={formState}\n Field={Field}\n reset={reset}\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 Field={Field}\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 Field={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,QACA;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,QACA;AAAA,QACA;AAAA,QACA;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,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;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,gBAAQ;",
6
- "names": []
7
- }
@@ -1,6 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "module": "./index.js",
4
- "types": "./index.d.ts",
5
- "main": "../cjs/Field/index.js"
6
- }
@@ -1 +0,0 @@
1
- //# sourceMappingURL=types.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "module": "./index.js",
4
- "types": "./index.d.ts",
5
- "main": "../../cjs/Field/types/index.js"
6
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }
@@ -1,27 +0,0 @@
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
@@ -1,6 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "module": "./index.js",
4
- "types": "./index.d.ts",
5
- "main": "../../../cjs/Field/utils/calculateField/index.js"
6
- }
@@ -1,2 +0,0 @@
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;
@@ -1,7 +0,0 @@
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
- }
@@ -1,26 +0,0 @@
1
- function evaluateFieldWithConditions(field, variables) {
2
- const newField = { ...field };
3
- if (variables) {
4
- for (const key in variables) {
5
- if (field.condition[key] && field.condition[key].is) {
6
- const is = field.condition[key].is;
7
- if (is === variables[key] || Array.isArray(variables[key]) && variables[key].includes(is)) {
8
- const then = field.condition[key].then || {};
9
- for (const attr in then) {
10
- newField[attr] = then[attr];
11
- }
12
- }
13
- } else if (field.condition[key]) {
14
- const otherwise = field.condition[key].else || {};
15
- for (const attr in otherwise) {
16
- newField[attr] = otherwise[attr];
17
- }
18
- }
19
- }
20
- }
21
- return newField;
22
- }
23
- export {
24
- evaluateFieldWithConditions
25
- };
26
- //# sourceMappingURL=evaluateFieldWithConditions.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "module": "./index.js",
4
- "types": "./index.d.ts",
5
- "main": "../../../cjs/Field/utils/evaluateFieldWithConditions/index.js"
6
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/Field/utils/evaluateFieldWithConditions.ts"],
4
- "sourcesContent": ["import { FieldWithCondition, CalculatedField } from '@digigov/form/Field/types';\n\nexport function evaluateFieldWithConditions(\n field: FieldWithCondition,\n variables: FormData\n): CalculatedField {\n const newField = { ...field };\n if (variables) {\n for (const key in variables) {\n if (field.condition[key] && field.condition[key].is) {\n const is = field.condition[key].is;\n if (\n is === variables[key] ||\n (Array.isArray(variables[key]) && variables[key].includes(is))\n ) {\n const then = field.condition[key].then || {};\n for (const attr in then) {\n newField[attr] = then[attr];\n }\n }\n } else if (field.condition[key]) {\n const otherwise = field.condition[key].else || {};\n for (const attr in otherwise) {\n newField[attr] = otherwise[attr];\n }\n }\n }\n }\n return newField;\n}\n"],
5
- "mappings": "AAEO,SAAS,4BACd,OACA,WACiB;AACjB,QAAM,WAAW,EAAE,GAAG,MAAM;AAC5B,MAAI,WAAW;AACb,eAAW,OAAO,WAAW;AAC3B,UAAI,MAAM,UAAU,GAAG,KAAK,MAAM,UAAU,GAAG,EAAE,IAAI;AACnD,cAAM,KAAK,MAAM,UAAU,GAAG,EAAE;AAChC,YACE,OAAO,UAAU,GAAG,KACnB,MAAM,QAAQ,UAAU,GAAG,CAAC,KAAK,UAAU,GAAG,EAAE,SAAS,EAAE,GAC5D;AACA,gBAAM,OAAO,MAAM,UAAU,GAAG,EAAE,QAAQ,CAAC;AAC3C,qBAAW,QAAQ,MAAM;AACvB,qBAAS,IAAI,IAAI,KAAK,IAAI;AAAA,UAC5B;AAAA,QACF;AAAA,MACF,WAAW,MAAM,UAAU,GAAG,GAAG;AAC/B,cAAM,YAAY,MAAM,UAAU,GAAG,EAAE,QAAQ,CAAC;AAChD,mBAAW,QAAQ,WAAW;AAC5B,mBAAS,IAAI,IAAI,UAAU,IAAI;AAAA,QACjC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
6
- "names": []
7
- }