@digigov/form 2.0.0-a594a958 → 2.0.0-a64dc016

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 (622) hide show
  1. package/Field/ErrorGroup.d.ts +2 -2
  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 +1 -1
  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 +69 -107
  11. package/Field/types.d.ts +3 -3
  12. package/Field/types.js +0 -0
  13. package/Field/utils/evaluateFieldWithConditions.d.ts +1 -1
  14. package/Field/utils/evaluateFieldWithConditions.js +19 -0
  15. package/Field/utils/resolveField.d.ts +2 -2
  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 +1 -1
  20. package/FieldArray/BaseFieldArray.js +46 -0
  21. package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js +13 -0
  22. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js +117 -0
  23. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js +6 -0
  24. package/FieldArray/FormDialog/ArrayDisplay/index.js +32 -57
  25. package/FieldArray/FormDialog/ArrayEditModal.d.ts +1 -1
  26. package/FieldArray/FormDialog/ArrayEditModal.js +138 -0
  27. package/FieldArray/FormDialog/index.d.ts +1 -1
  28. package/FieldArray/FormDialog/index.js +142 -177
  29. package/FieldArray/index.d.ts +2 -2
  30. package/FieldArray/index.js +59 -86
  31. package/FieldObject/index.d.ts +2 -2
  32. package/FieldObject/index.js +52 -77
  33. package/Fieldset/FieldsetWithContext.js +27 -0
  34. package/Fieldset/index.d.ts +1 -1
  35. package/Fieldset/index.js +18 -30
  36. package/Fieldset/types.js +0 -0
  37. package/FormBuilder/index.d.ts +2 -2
  38. package/FormBuilder/index.js +226 -254
  39. package/FormContext.d.ts +1 -1
  40. package/FormContext.js +7 -0
  41. package/MultiplicityField/add-objects.d.ts +1 -1
  42. package/MultiplicityField/add-objects.js +107 -0
  43. package/MultiplicityField/index.d.ts +1 -1
  44. package/MultiplicityField/index.js +81 -119
  45. package/MultiplicityField/types.d.ts +1 -1
  46. package/MultiplicityField/types.js +0 -0
  47. package/Questions/Questions.d.ts +1 -1
  48. package/Questions/Questions.js +48 -0
  49. package/Questions/QuestionsContext.d.ts +1 -1
  50. package/Questions/QuestionsContext.js +10 -0
  51. package/Questions/Step/ReviewStep.js +32 -0
  52. package/Questions/Step/Step.d.ts +1 -1
  53. package/Questions/Step/Step.js +39 -0
  54. package/Questions/Step/StepArrayReview.d.ts +1 -1
  55. package/Questions/Step/StepArrayReview.js +35 -0
  56. package/Questions/Step/StepContext.d.ts +1 -1
  57. package/Questions/Step/StepContext.js +28 -0
  58. package/Questions/Step/StepDescription.js +18 -0
  59. package/Questions/Step/StepForm.d.ts +2 -2
  60. package/Questions/Step/StepForm.js +29 -0
  61. package/Questions/Step/StepQuote.js +5 -0
  62. package/Questions/Step/StepTitle.js +25 -0
  63. package/Questions/Step/getAddMoreFields.d.ts +2 -2
  64. package/Questions/Step/getAddMoreFields.js +24 -0
  65. package/Questions/Step/index.d.ts +11 -11
  66. package/Questions/Step/index.js +13 -16
  67. package/Questions/Step/types.d.ts +1 -1
  68. package/Questions/Step/types.js +0 -0
  69. package/Questions/getNextStep.d.ts +1 -1
  70. package/Questions/getNextStep.js +13 -0
  71. package/Questions/index.d.ts +2 -2
  72. package/Questions/index.js +4 -7
  73. package/Questions/types.d.ts +1 -1
  74. package/Questions/types.js +0 -0
  75. package/hooks/useFieldFocusManager.js +83 -0
  76. package/hooks/utils.js +60 -0
  77. package/index.d.ts +5 -5
  78. package/index.js +8 -13
  79. package/inputs/AutoCompleteInput/index.d.ts +2 -2
  80. package/inputs/AutoCompleteInput/index.js +38 -60
  81. package/inputs/Checkboxes/index.d.ts +2 -2
  82. package/inputs/Checkboxes/index.js +43 -76
  83. package/inputs/DateInput/index.d.ts +1 -1
  84. package/inputs/DateInput/index.js +123 -147
  85. package/inputs/DateTimeInput/index.d.ts +1 -1
  86. package/inputs/DateTimeInput/index.js +177 -207
  87. package/inputs/FileInput/index.d.ts +1 -1
  88. package/inputs/FileInput/index.js +54 -70
  89. package/inputs/ImageInput/index.d.ts +1 -1
  90. package/inputs/ImageInput/index.js +74 -74
  91. package/inputs/Input/index.d.ts +1 -1
  92. package/inputs/Input/index.js +60 -73
  93. package/inputs/Label/index.d.ts +1 -1
  94. package/inputs/Label/index.js +13 -16
  95. package/inputs/OtpInput/index.js +116 -145
  96. package/inputs/Radio/index.d.ts +2 -2
  97. package/inputs/Radio/index.js +70 -103
  98. package/inputs/Select/index.d.ts +2 -2
  99. package/inputs/Select/index.js +23 -32
  100. package/inputs/index.d.ts +9 -9
  101. package/inputs/index.js +10 -21
  102. package/inputs/registry.d.ts +1 -1
  103. package/inputs/registry.js +80 -0
  104. package/internal.d.ts +5 -5
  105. package/internal.js +6 -0
  106. package/lazy.d.ts +97 -0
  107. package/lazy.js +163 -0
  108. package/package.json +8 -8
  109. package/registry.d.ts +82 -0
  110. package/registry.js +170 -0
  111. package/src/Field/ErrorGroup.tsx +1 -1
  112. package/src/FieldArray/FormDialog/index.tsx +1 -1
  113. package/src/FormBuilder/doc.mdx +1 -1
  114. package/src/inputs/AutoCompleteInput/doc.mdx +2 -2
  115. package/src/inputs/Checkboxes/doc.mdx +3 -3
  116. package/src/inputs/DateInput/doc.mdx +1 -1
  117. package/src/inputs/DateTimeInput/doc.mdx +1 -1
  118. package/src/inputs/FileInput/doc.mdx +1 -1
  119. package/src/inputs/ImageInput/doc.mdx +3 -3
  120. package/src/inputs/Input/doc.mdx +10 -10
  121. package/src/inputs/Label/doc.mdx +1 -1
  122. package/src/inputs/OtpInput/doc.mdx +1 -1
  123. package/src/inputs/Radio/doc.mdx +3 -3
  124. package/src/inputs/Select/doc.mdx +1 -1
  125. package/{lazy/index.js → src/lazy.ts} +1 -26
  126. package/types.d.ts +4 -4
  127. package/types.js +1 -0
  128. package/utils.js +56 -0
  129. package/validators/index.d.ts +2 -2
  130. package/validators/index.js +112 -159
  131. package/validators/types.js +0 -0
  132. package/validators/utils/afm.js +19 -0
  133. package/validators/utils/amka.js +27 -0
  134. package/validators/utils/date.d.ts +2 -2
  135. package/validators/utils/date.js +95 -0
  136. package/validators/utils/datetime.d.ts +2 -2
  137. package/validators/utils/datetime.js +121 -0
  138. package/validators/utils/email.js +10 -0
  139. package/validators/utils/file.d.ts +2 -2
  140. package/validators/utils/file.js +31 -0
  141. package/validators/utils/iban.d.ts +2 -2
  142. package/validators/utils/iban.js +104 -0
  143. package/validators/utils/image.d.ts +2 -2
  144. package/validators/utils/image.js +65 -0
  145. package/validators/utils/index.d.ts +14 -14
  146. package/validators/utils/index.js +58 -96
  147. package/validators/utils/int.d.ts +1 -1
  148. package/validators/utils/int.js +13 -0
  149. package/validators/utils/number.d.ts +1 -1
  150. package/validators/utils/number.js +12 -0
  151. package/validators/utils/otp.d.ts +2 -2
  152. package/validators/utils/otp.js +21 -0
  153. package/validators/utils/phone.d.ts +2 -2
  154. package/validators/utils/phone.js +198 -0
  155. package/validators/utils/postal_code.d.ts +2 -2
  156. package/validators/utils/postal_code.js +18 -0
  157. package/validators/utils/text_limit.d.ts +2 -2
  158. package/validators/utils/text_limit.js +34 -0
  159. package/validators/utils/uuid4.js +14 -0
  160. package/Field/ErrorGroup/index.js +0 -48
  161. package/Field/ErrorGroup/package.json +0 -6
  162. package/Field/ErrorGroup.js.map +0 -7
  163. package/Field/FieldBase/index.js +0 -122
  164. package/Field/FieldBase/package.json +0 -6
  165. package/Field/FieldBase.js.map +0 -7
  166. package/Field/FieldBaseContainer/index.js +0 -52
  167. package/Field/FieldBaseContainer/package.json +0 -6
  168. package/Field/FieldBaseContainer.js.map +0 -7
  169. package/Field/FieldConditional/index.js +0 -89
  170. package/Field/FieldConditional/package.json +0 -6
  171. package/Field/FieldConditional.js.map +0 -7
  172. package/Field/index.js.map +0 -7
  173. package/Field/package.json +0 -6
  174. package/Field/types/index.js +0 -1
  175. package/Field/types/package.json +0 -6
  176. package/Field/types.js.map +0 -7
  177. package/Field/utils/evaluateFieldWithConditions/index.js +0 -26
  178. package/Field/utils/evaluateFieldWithConditions/package.json +0 -6
  179. package/Field/utils/evaluateFieldWithConditions.js.map +0 -7
  180. package/Field/utils/resolveField/index.js +0 -35
  181. package/Field/utils/resolveField/package.json +0 -6
  182. package/Field/utils/resolveField.js.map +0 -7
  183. package/Field/utils/useField/index.js +0 -66
  184. package/Field/utils/useField/package.json +0 -6
  185. package/Field/utils/useField.js.map +0 -7
  186. package/FieldArray/BaseFieldArray/index.js +0 -76
  187. package/FieldArray/BaseFieldArray/package.json +0 -6
  188. package/FieldArray/BaseFieldArray.js.map +0 -7
  189. package/FieldArray/FieldArray.stories.d.ts +0 -11
  190. package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/index.js +0 -23
  191. package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/package.json +0 -6
  192. package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js.map +0 -7
  193. package/FieldArray/FormDialog/ArrayDisplay/ArrayDisplay.stories.d.ts +0 -13
  194. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/index.js +0 -184
  195. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/package.json +0 -6
  196. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js.map +0 -7
  197. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/index.js +0 -11
  198. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/package.json +0 -6
  199. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js.map +0 -7
  200. package/FieldArray/FormDialog/ArrayDisplay/__stories__/Cards.d.ts +0 -2
  201. package/FieldArray/FormDialog/ArrayDisplay/__stories__/Default.d.ts +0 -2
  202. package/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnly.d.ts +0 -2
  203. package/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnlyCards.d.ts +0 -2
  204. package/FieldArray/FormDialog/ArrayDisplay/__stories__/Sortable.d.ts +0 -2
  205. package/FieldArray/FormDialog/ArrayDisplay/__stories__/SortableCards.d.ts +0 -2
  206. package/FieldArray/FormDialog/ArrayDisplay/index.js.map +0 -7
  207. package/FieldArray/FormDialog/ArrayDisplay/package.json +0 -6
  208. package/FieldArray/FormDialog/ArrayEditModal/index.js +0 -158
  209. package/FieldArray/FormDialog/ArrayEditModal/package.json +0 -6
  210. package/FieldArray/FormDialog/ArrayEditModal.js.map +0 -7
  211. package/FieldArray/FormDialog/index.js.map +0 -7
  212. package/FieldArray/FormDialog/package.json +0 -6
  213. package/FieldArray/__stories__/CardsWithError.d.ts +0 -15
  214. package/FieldArray/__stories__/Default.d.ts +0 -2
  215. package/FieldArray/__stories__/WithExactLength.d.ts +0 -2
  216. package/FieldArray/__stories__/WithModal.d.ts +0 -2
  217. package/FieldArray/index.js.map +0 -7
  218. package/FieldArray/package.json +0 -6
  219. package/FieldObject/index.js.map +0 -7
  220. package/FieldObject/package.json +0 -6
  221. package/Fieldset/FieldsetWithContext/index.js +0 -31
  222. package/Fieldset/FieldsetWithContext/package.json +0 -6
  223. package/Fieldset/FieldsetWithContext.js.map +0 -7
  224. package/Fieldset/index.js.map +0 -7
  225. package/Fieldset/package.json +0 -6
  226. package/Fieldset/types/index.js +0 -1
  227. package/Fieldset/types/package.json +0 -6
  228. package/Fieldset/types.js.map +0 -7
  229. package/Form.stories.d.ts +0 -4
  230. package/FormBuilder/FormBuilder.stories.d.ts +0 -12
  231. package/FormBuilder/__stories__/AutoErrorGrouping.d.ts +0 -3
  232. package/FormBuilder/__stories__/Default.d.ts +0 -3
  233. package/FormBuilder/__stories__/ErrorGrouping.d.ts +0 -3
  234. package/FormBuilder/index.js.map +0 -7
  235. package/FormBuilder/package.json +0 -6
  236. package/FormContext/index.js +0 -13
  237. package/FormContext/package.json +0 -6
  238. package/FormContext.js.map +0 -7
  239. package/MultiplicityField/MultiplicityField.stories.d.ts +0 -15
  240. package/MultiplicityField/__stories__/Default.d.ts +0 -2
  241. package/MultiplicityField/__stories__/PreviewDisplay.d.ts +0 -2
  242. package/MultiplicityField/__stories__/WithExactLength.d.ts +0 -2
  243. package/MultiplicityField/__stories__/WithMaxLength.d.ts +0 -2
  244. package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +0 -2
  245. package/MultiplicityField/__stories__/WithMinLength.d.ts +0 -2
  246. package/MultiplicityField/add-objects/index.js +0 -146
  247. package/MultiplicityField/add-objects/package.json +0 -6
  248. package/MultiplicityField/add-objects.js.map +0 -7
  249. package/MultiplicityField/index.js.map +0 -7
  250. package/MultiplicityField/package.json +0 -6
  251. package/MultiplicityField/types/index.js +0 -1
  252. package/MultiplicityField/types/package.json +0 -6
  253. package/MultiplicityField/types.js.map +0 -7
  254. package/Questions/Questions/index.js +0 -67
  255. package/Questions/Questions/package.json +0 -6
  256. package/Questions/Questions.js.map +0 -7
  257. package/Questions/Questions.stories.d.ts +0 -10
  258. package/Questions/QuestionsContext/index.js +0 -11
  259. package/Questions/QuestionsContext/package.json +0 -6
  260. package/Questions/QuestionsContext.js.map +0 -7
  261. package/Questions/Step/ReviewStep/index.js +0 -38
  262. package/Questions/Step/ReviewStep/package.json +0 -6
  263. package/Questions/Step/ReviewStep.js.map +0 -7
  264. package/Questions/Step/Step/index.js +0 -54
  265. package/Questions/Step/Step/package.json +0 -6
  266. package/Questions/Step/Step.js.map +0 -7
  267. package/Questions/Step/StepArrayReview/index.js +0 -42
  268. package/Questions/Step/StepArrayReview/package.json +0 -6
  269. package/Questions/Step/StepArrayReview.js.map +0 -7
  270. package/Questions/Step/StepContext/index.js +0 -23
  271. package/Questions/Step/StepContext/package.json +0 -6
  272. package/Questions/Step/StepContext.js.map +0 -7
  273. package/Questions/Step/StepDescription/index.js +0 -24
  274. package/Questions/Step/StepDescription/package.json +0 -6
  275. package/Questions/Step/StepDescription.js.map +0 -7
  276. package/Questions/Step/StepForm/index.js +0 -34
  277. package/Questions/Step/StepForm/package.json +0 -6
  278. package/Questions/Step/StepForm.js.map +0 -7
  279. package/Questions/Step/StepQuote/index.js +0 -11
  280. package/Questions/Step/StepQuote/package.json +0 -6
  281. package/Questions/Step/StepQuote.js.map +0 -7
  282. package/Questions/Step/StepTitle/index.js +0 -44
  283. package/Questions/Step/StepTitle/package.json +0 -6
  284. package/Questions/Step/StepTitle.js.map +0 -7
  285. package/Questions/Step/getAddMoreFields/index.js +0 -29
  286. package/Questions/Step/getAddMoreFields/package.json +0 -6
  287. package/Questions/Step/getAddMoreFields.js.map +0 -7
  288. package/Questions/Step/index.js.map +0 -7
  289. package/Questions/Step/package.json +0 -6
  290. package/Questions/Step/types/index.js +0 -1
  291. package/Questions/Step/types/package.json +0 -6
  292. package/Questions/Step/types.js.map +0 -7
  293. package/Questions/__stories__/Default.d.ts +0 -3
  294. package/Questions/getNextStep/index.js +0 -22
  295. package/Questions/getNextStep/package.json +0 -6
  296. package/Questions/getNextStep.js.map +0 -7
  297. package/Questions/index.js.map +0 -7
  298. package/Questions/package.json +0 -6
  299. package/Questions/types/index.js +0 -1
  300. package/Questions/types/package.json +0 -6
  301. package/Questions/types.js.map +0 -7
  302. package/cjs/Field/ErrorGroup/index.js +0 -82
  303. package/cjs/Field/ErrorGroup.js.map +0 -7
  304. package/cjs/Field/FieldBase/index.js +0 -155
  305. package/cjs/Field/FieldBase.js.map +0 -7
  306. package/cjs/Field/FieldBaseContainer/index.js +0 -85
  307. package/cjs/Field/FieldBaseContainer.js.map +0 -7
  308. package/cjs/Field/FieldConditional/index.js +0 -122
  309. package/cjs/Field/FieldConditional.js.map +0 -7
  310. package/cjs/Field/index.js +0 -143
  311. package/cjs/Field/index.js.map +0 -7
  312. package/cjs/Field/types/index.js +0 -16
  313. package/cjs/Field/types.js.map +0 -7
  314. package/cjs/Field/utils/evaluateFieldWithConditions/index.js +0 -49
  315. package/cjs/Field/utils/evaluateFieldWithConditions.js.map +0 -7
  316. package/cjs/Field/utils/resolveField/index.js +0 -55
  317. package/cjs/Field/utils/resolveField.js.map +0 -7
  318. package/cjs/Field/utils/useField/index.js +0 -89
  319. package/cjs/Field/utils/useField.js.map +0 -7
  320. package/cjs/FieldArray/BaseFieldArray/index.js +0 -109
  321. package/cjs/FieldArray/BaseFieldArray.js.map +0 -7
  322. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/index.js +0 -56
  323. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js.map +0 -7
  324. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/index.js +0 -209
  325. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js.map +0 -7
  326. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/index.js +0 -44
  327. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js.map +0 -7
  328. package/cjs/FieldArray/FormDialog/ArrayDisplay/index.js +0 -90
  329. package/cjs/FieldArray/FormDialog/ArrayDisplay/index.js.map +0 -7
  330. package/cjs/FieldArray/FormDialog/ArrayEditModal/index.js +0 -186
  331. package/cjs/FieldArray/FormDialog/ArrayEditModal.js.map +0 -7
  332. package/cjs/FieldArray/FormDialog/index.js +0 -261
  333. package/cjs/FieldArray/FormDialog/index.js.map +0 -7
  334. package/cjs/FieldArray/index.js +0 -126
  335. package/cjs/FieldArray/index.js.map +0 -7
  336. package/cjs/FieldObject/index.js +0 -113
  337. package/cjs/FieldObject/index.js.map +0 -7
  338. package/cjs/Fieldset/FieldsetWithContext/index.js +0 -59
  339. package/cjs/Fieldset/FieldsetWithContext.js.map +0 -7
  340. package/cjs/Fieldset/index.js +0 -66
  341. package/cjs/Fieldset/index.js.map +0 -7
  342. package/cjs/Fieldset/types/index.js +0 -16
  343. package/cjs/Fieldset/types.js.map +0 -7
  344. package/cjs/FormBuilder/index.js +0 -303
  345. package/cjs/FormBuilder/index.js.map +0 -7
  346. package/cjs/FormContext/index.js +0 -37
  347. package/cjs/FormContext.js.map +0 -7
  348. package/cjs/MultiplicityField/add-objects/index.js +0 -179
  349. package/cjs/MultiplicityField/add-objects.js.map +0 -7
  350. package/cjs/MultiplicityField/index.js +0 -153
  351. package/cjs/MultiplicityField/index.js.map +0 -7
  352. package/cjs/MultiplicityField/types/index.js +0 -16
  353. package/cjs/MultiplicityField/types.js.map +0 -7
  354. package/cjs/Questions/Questions/index.js +0 -100
  355. package/cjs/Questions/Questions.js.map +0 -7
  356. package/cjs/Questions/QuestionsContext/index.js +0 -34
  357. package/cjs/Questions/QuestionsContext.js.map +0 -7
  358. package/cjs/Questions/Step/ReviewStep/index.js +0 -65
  359. package/cjs/Questions/Step/ReviewStep.js.map +0 -7
  360. package/cjs/Questions/Step/Step/index.js +0 -87
  361. package/cjs/Questions/Step/Step.js.map +0 -7
  362. package/cjs/Questions/Step/StepArrayReview/index.js +0 -67
  363. package/cjs/Questions/Step/StepArrayReview.js.map +0 -7
  364. package/cjs/Questions/Step/StepContext/index.js +0 -46
  365. package/cjs/Questions/Step/StepContext.js.map +0 -7
  366. package/cjs/Questions/Step/StepDescription/index.js +0 -58
  367. package/cjs/Questions/Step/StepDescription.js.map +0 -7
  368. package/cjs/Questions/Step/StepForm/index.js +0 -67
  369. package/cjs/Questions/Step/StepForm.js.map +0 -7
  370. package/cjs/Questions/Step/StepQuote/index.js +0 -44
  371. package/cjs/Questions/Step/StepQuote.js.map +0 -7
  372. package/cjs/Questions/Step/StepTitle/index.js +0 -76
  373. package/cjs/Questions/Step/StepTitle.js.map +0 -7
  374. package/cjs/Questions/Step/getAddMoreFields/index.js +0 -52
  375. package/cjs/Questions/Step/getAddMoreFields.js.map +0 -7
  376. package/cjs/Questions/Step/index.js +0 -59
  377. package/cjs/Questions/Step/index.js.map +0 -7
  378. package/cjs/Questions/Step/types/index.js +0 -16
  379. package/cjs/Questions/Step/types.js.map +0 -7
  380. package/cjs/Questions/getNextStep/index.js +0 -45
  381. package/cjs/Questions/getNextStep.js.map +0 -7
  382. package/cjs/Questions/index.js +0 -31
  383. package/cjs/Questions/index.js.map +0 -7
  384. package/cjs/Questions/types/index.js +0 -16
  385. package/cjs/Questions/types.js.map +0 -7
  386. package/cjs/hooks/useFieldFocusManager/index.js +0 -135
  387. package/cjs/hooks/useFieldFocusManager.js.map +0 -7
  388. package/cjs/hooks/utils/index.js +0 -98
  389. package/cjs/hooks/utils.js.map +0 -7
  390. package/cjs/index.js +0 -49
  391. package/cjs/index.js.map +0 -7
  392. package/cjs/inputs/AutoCompleteInput/index.js +0 -98
  393. package/cjs/inputs/AutoCompleteInput/index.js.map +0 -7
  394. package/cjs/inputs/Checkboxes/index.js +0 -112
  395. package/cjs/inputs/Checkboxes/index.js.map +0 -7
  396. package/cjs/inputs/DateInput/index.js +0 -188
  397. package/cjs/inputs/DateInput/index.js.map +0 -7
  398. package/cjs/inputs/DateTimeInput/index.js +0 -250
  399. package/cjs/inputs/DateTimeInput/index.js.map +0 -7
  400. package/cjs/inputs/FileInput/index.js +0 -110
  401. package/cjs/inputs/FileInput/index.js.map +0 -7
  402. package/cjs/inputs/ImageInput/__stories__/logo.d/index.js +0 -1
  403. package/cjs/inputs/ImageInput/__stories__/logo.d.js.map +0 -7
  404. package/cjs/inputs/ImageInput/index.js +0 -130
  405. package/cjs/inputs/ImageInput/index.js.map +0 -7
  406. package/cjs/inputs/Input/index.js +0 -115
  407. package/cjs/inputs/Input/index.js.map +0 -7
  408. package/cjs/inputs/Label/index.js +0 -50
  409. package/cjs/inputs/Label/index.js.map +0 -7
  410. package/cjs/inputs/OtpInput/index.js +0 -186
  411. package/cjs/inputs/OtpInput/index.js.map +0 -7
  412. package/cjs/inputs/Radio/index.js +0 -136
  413. package/cjs/inputs/Radio/index.js.map +0 -7
  414. package/cjs/inputs/Select/index.js +0 -63
  415. package/cjs/inputs/Select/index.js.map +0 -7
  416. package/cjs/inputs/index.js +0 -62
  417. package/cjs/inputs/index.js.map +0 -7
  418. package/cjs/inputs/registry/index.js +0 -121
  419. package/cjs/inputs/registry.js.map +0 -7
  420. package/cjs/internal/index.js +0 -38
  421. package/cjs/internal.js.map +0 -7
  422. package/cjs/lazy/index.js +0 -114
  423. package/cjs/lazy.js.map +0 -7
  424. package/cjs/registry/index.js +0 -209
  425. package/cjs/registry.js.map +0 -7
  426. package/cjs/types/index.js +0 -22
  427. package/cjs/types.js.map +0 -7
  428. package/cjs/utils/index.js +0 -106
  429. package/cjs/utils.js.map +0 -7
  430. package/cjs/validators/index.js +0 -179
  431. package/cjs/validators/index.js.map +0 -7
  432. package/cjs/validators/types/index.js +0 -16
  433. package/cjs/validators/types.js.map +0 -7
  434. package/cjs/validators/utils/afm/index.js +0 -55
  435. package/cjs/validators/utils/afm.js.map +0 -7
  436. package/cjs/validators/utils/amka/index.js +0 -60
  437. package/cjs/validators/utils/amka.js.map +0 -7
  438. package/cjs/validators/utils/date/index.js +0 -161
  439. package/cjs/validators/utils/date.js.map +0 -7
  440. package/cjs/validators/utils/datetime/index.js +0 -245
  441. package/cjs/validators/utils/datetime.js.map +0 -7
  442. package/cjs/validators/utils/email/index.js +0 -39
  443. package/cjs/validators/utils/email.js.map +0 -7
  444. package/cjs/validators/utils/file/index.js +0 -61
  445. package/cjs/validators/utils/file.js.map +0 -7
  446. package/cjs/validators/utils/iban/index.js +0 -142
  447. package/cjs/validators/utils/iban.js.map +0 -7
  448. package/cjs/validators/utils/image/index.js +0 -102
  449. package/cjs/validators/utils/image.js.map +0 -7
  450. package/cjs/validators/utils/index.js +0 -152
  451. package/cjs/validators/utils/index.js.map +0 -7
  452. package/cjs/validators/utils/int/index.js +0 -48
  453. package/cjs/validators/utils/int.js.map +0 -7
  454. package/cjs/validators/utils/number/index.js +0 -44
  455. package/cjs/validators/utils/number.js.map +0 -7
  456. package/cjs/validators/utils/otp/index.js +0 -54
  457. package/cjs/validators/utils/otp.js.map +0 -7
  458. package/cjs/validators/utils/phone/index.js +0 -198
  459. package/cjs/validators/utils/phone.js.map +0 -7
  460. package/cjs/validators/utils/postal_code/index.js +0 -54
  461. package/cjs/validators/utils/postal_code.js.map +0 -7
  462. package/cjs/validators/utils/text_limit/index.js +0 -69
  463. package/cjs/validators/utils/text_limit.js.map +0 -7
  464. package/cjs/validators/utils/uuid4/index.js +0 -46
  465. package/cjs/validators/utils/uuid4.js.map +0 -7
  466. package/hooks/__tests__/utils.spec.d.ts +0 -1
  467. package/hooks/useFieldFocusManager/index.js +0 -116
  468. package/hooks/useFieldFocusManager/package.json +0 -6
  469. package/hooks/useFieldFocusManager.js.map +0 -7
  470. package/hooks/utils/index.js +0 -73
  471. package/hooks/utils/package.json +0 -6
  472. package/hooks/utils.js.map +0 -7
  473. package/index.js.map +0 -7
  474. package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +0 -11
  475. package/inputs/AutoCompleteInput/__stories__/Default.d.ts +0 -3
  476. package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +0 -3
  477. package/inputs/AutoCompleteInput/index.js.map +0 -7
  478. package/inputs/AutoCompleteInput/package.json +0 -6
  479. package/inputs/Checkboxes/Checkboxes.stories.d.ts +0 -12
  480. package/inputs/Checkboxes/__stories__/Conditional.d.ts +0 -3
  481. package/inputs/Checkboxes/__stories__/Default.d.ts +0 -3
  482. package/inputs/Checkboxes/__stories__/WithDivider.d.ts +0 -3
  483. package/inputs/Checkboxes/index.js.map +0 -7
  484. package/inputs/Checkboxes/package.json +0 -6
  485. package/inputs/DateInput/DateInput.stories.d.ts +0 -14
  486. package/inputs/DateInput/__stories__/Default.d.ts +0 -3
  487. package/inputs/DateInput/__stories__/WithDefaultValue.d.ts +0 -3
  488. package/inputs/DateInput/__stories__/WithInitialValue.d.ts +0 -3
  489. package/inputs/DateInput/__stories__/WithWrongDefaultValue.d.ts +0 -3
  490. package/inputs/DateInput/__stories__/WithWrongInitialValue.d.ts +0 -3
  491. package/inputs/DateInput/index.js.map +0 -7
  492. package/inputs/DateInput/package.json +0 -6
  493. package/inputs/DateTimeInput/DateTimeInput.stories.d.ts +0 -14
  494. package/inputs/DateTimeInput/__stories__/Default.d.ts +0 -3
  495. package/inputs/DateTimeInput/__stories__/WithDefaultValue.d.ts +0 -3
  496. package/inputs/DateTimeInput/__stories__/WithInitialValue.d.ts +0 -3
  497. package/inputs/DateTimeInput/__stories__/WithWrongDefaultValue.d.ts +0 -3
  498. package/inputs/DateTimeInput/__stories__/WithWrongInitialValue.d.ts +0 -3
  499. package/inputs/DateTimeInput/index.js.map +0 -7
  500. package/inputs/DateTimeInput/package.json +0 -6
  501. package/inputs/FileInput/FileInput.stories.d.ts +0 -11
  502. package/inputs/FileInput/__stories__/Default.d.ts +0 -3
  503. package/inputs/FileInput/__stories__/WithBorderAndLink.d.ts +0 -3
  504. package/inputs/FileInput/index.js.map +0 -7
  505. package/inputs/FileInput/package.json +0 -6
  506. package/inputs/ImageInput/ImageInput.stories.d.ts +0 -13
  507. package/inputs/ImageInput/__stories__/Default.d.ts +0 -3
  508. package/inputs/ImageInput/__stories__/MaxSize.d.ts +0 -3
  509. package/inputs/ImageInput/__stories__/WithInitialValues.d.ts +0 -3
  510. package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +0 -3
  511. package/inputs/ImageInput/__stories__/logo.d/index.js +0 -1
  512. package/inputs/ImageInput/__stories__/logo.d/package.json +0 -6
  513. package/inputs/ImageInput/__stories__/logo.d.js.map +0 -7
  514. package/inputs/ImageInput/index.js.map +0 -7
  515. package/inputs/ImageInput/package.json +0 -6
  516. package/inputs/Input/Input.stories.d.ts +0 -23
  517. package/inputs/Input/__stories__/AFM.d.ts +0 -3
  518. package/inputs/Input/__stories__/AMKA.d.ts +0 -3
  519. package/inputs/Input/__stories__/Boolean.d.ts +0 -3
  520. package/inputs/Input/__stories__/Email.d.ts +0 -3
  521. package/inputs/Input/__stories__/IBAN.d.ts +0 -3
  522. package/inputs/Input/__stories__/Integer.d.ts +0 -3
  523. package/inputs/Input/__stories__/LandlineNumber.d.ts +0 -3
  524. package/inputs/Input/__stories__/MobilePhone.d.ts +0 -3
  525. package/inputs/Input/__stories__/PhoneNumber.d.ts +0 -3
  526. package/inputs/Input/__stories__/PostalCode.d.ts +0 -3
  527. package/inputs/Input/__stories__/Rate.d.ts +0 -3
  528. package/inputs/Input/__stories__/String.d.ts +0 -3
  529. package/inputs/Input/__stories__/StringWithTrimValidation.d.ts +0 -3
  530. package/inputs/Input/__stories__/TextWithLimit.d.ts +0 -3
  531. package/inputs/Input/index.js.map +0 -7
  532. package/inputs/Input/package.json +0 -6
  533. package/inputs/Label/Label.stories.d.ts +0 -10
  534. package/inputs/Label/__stories__/Default.d.ts +0 -3
  535. package/inputs/Label/index.js.map +0 -7
  536. package/inputs/Label/package.json +0 -6
  537. package/inputs/OtpInput/OtpInput.stories.d.ts +0 -10
  538. package/inputs/OtpInput/__stories__/Default.d.ts +0 -3
  539. package/inputs/OtpInput/index.js.map +0 -7
  540. package/inputs/OtpInput/package.json +0 -6
  541. package/inputs/Radio/Radio.stories.d.ts +0 -12
  542. package/inputs/Radio/__stories__/Conditional.d.ts +0 -3
  543. package/inputs/Radio/__stories__/Default.d.ts +0 -3
  544. package/inputs/Radio/__stories__/WithDivider.d.ts +0 -3
  545. package/inputs/Radio/index.js.map +0 -7
  546. package/inputs/Radio/package.json +0 -6
  547. package/inputs/Select/Select.stories.d.ts +0 -10
  548. package/inputs/Select/__stories__/Default.d.ts +0 -3
  549. package/inputs/Select/index.js.map +0 -7
  550. package/inputs/Select/package.json +0 -6
  551. package/inputs/index.js.map +0 -7
  552. package/inputs/package.json +0 -6
  553. package/inputs/registry/index.js +0 -86
  554. package/inputs/registry/package.json +0 -6
  555. package/inputs/registry.js.map +0 -7
  556. package/internal/index.js +0 -10
  557. package/internal/package.json +0 -6
  558. package/internal.js.map +0 -7
  559. package/lazy/package.json +0 -6
  560. package/registry/index.js +0 -179
  561. package/registry/package.json +0 -6
  562. package/src/lazy.js +0 -81
  563. package/types/index.js +0 -2
  564. package/types/package.json +0 -6
  565. package/types.js.map +0 -7
  566. package/utils/index.js +0 -82
  567. package/utils/package.json +0 -6
  568. package/utils.js.map +0 -7
  569. package/validators/index.js.map +0 -7
  570. package/validators/package.json +0 -6
  571. package/validators/types/index.js +0 -1
  572. package/validators/types/package.json +0 -6
  573. package/validators/types.js.map +0 -7
  574. package/validators/utils/afm/index.js +0 -31
  575. package/validators/utils/afm/package.json +0 -6
  576. package/validators/utils/afm.js.map +0 -7
  577. package/validators/utils/amka/index.js +0 -36
  578. package/validators/utils/amka/package.json +0 -6
  579. package/validators/utils/amka.js.map +0 -7
  580. package/validators/utils/date/index.js +0 -126
  581. package/validators/utils/date/package.json +0 -6
  582. package/validators/utils/date.js.map +0 -7
  583. package/validators/utils/datetime/index.js +0 -210
  584. package/validators/utils/datetime/package.json +0 -6
  585. package/validators/utils/datetime.js.map +0 -7
  586. package/validators/utils/email/index.js +0 -16
  587. package/validators/utils/email/package.json +0 -6
  588. package/validators/utils/email.js.map +0 -7
  589. package/validators/utils/file/index.js +0 -38
  590. package/validators/utils/file/package.json +0 -6
  591. package/validators/utils/file.js.map +0 -7
  592. package/validators/utils/iban/index.js +0 -118
  593. package/validators/utils/iban/package.json +0 -6
  594. package/validators/utils/iban.js.map +0 -7
  595. package/validators/utils/image/index.js +0 -79
  596. package/validators/utils/image/package.json +0 -6
  597. package/validators/utils/image.js.map +0 -7
  598. package/validators/utils/index.js.map +0 -7
  599. package/validators/utils/int/index.js +0 -24
  600. package/validators/utils/int/package.json +0 -6
  601. package/validators/utils/int.js.map +0 -7
  602. package/validators/utils/number/index.js +0 -20
  603. package/validators/utils/number/package.json +0 -6
  604. package/validators/utils/number.js.map +0 -7
  605. package/validators/utils/otp/index.js +0 -30
  606. package/validators/utils/otp/package.json +0 -6
  607. package/validators/utils/otp.js.map +0 -7
  608. package/validators/utils/package.json +0 -6
  609. package/validators/utils/phone/index.js +0 -172
  610. package/validators/utils/phone/package.json +0 -6
  611. package/validators/utils/phone.js.map +0 -7
  612. package/validators/utils/postal_code/index.js +0 -30
  613. package/validators/utils/postal_code/package.json +0 -6
  614. package/validators/utils/postal_code.js.map +0 -7
  615. package/validators/utils/text_limit/index.js +0 -45
  616. package/validators/utils/text_limit/package.json +0 -6
  617. package/validators/utils/text_limit.js.map +0 -7
  618. package/validators/utils/uuid4/index.js +0 -22
  619. package/validators/utils/uuid4/package.json +0 -6
  620. package/validators/utils/uuid4.js.map +0 -7
  621. package/validators/validators.spec.d.ts +0 -1
  622. package/src/{registry.js → registry.ts} +6 -6
@@ -1,135 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var useFieldFocusManager_exports = {};
19
- __export(useFieldFocusManager_exports, {
20
- default: () => useFieldFocusManager_default,
21
- useFieldFocusManager: () => useFieldFocusManager
22
- });
23
- module.exports = __toCommonJS(useFieldFocusManager_exports);
24
- var import_react = require("react");
25
- var import_utils = require("@digigov/form/hooks/utils");
26
- function useFieldFocusManager({
27
- enabled = true,
28
- control,
29
- subscribe,
30
- setFocus
31
- }) {
32
- const customFocusableElements = (0, import_react.useRef)(/* @__PURE__ */ new Map());
33
- const focusableElements = (0, import_react.useRef)(/* @__PURE__ */ new Map());
34
- (0, import_react.useEffect)(() => {
35
- if (!enabled) {
36
- customFocusableElements.current.clear();
37
- focusableElements.current.clear();
38
- return;
39
- }
40
- }, [enabled]);
41
- const updateFocusableElements = (0, import_react.useCallback)(() => {
42
- focusableElements.current.clear();
43
- const formElements = (0, import_utils.extractFieldEntries)(control._fields);
44
- const customFieldRefs = (0, import_utils.mapElementsToFields)(
45
- customFocusableElements.current
46
- );
47
- const customElements = (0, import_utils.extractFieldEntries)(customFieldRefs);
48
- const combinedElements = new Map(formElements);
49
- customElements.forEach((element, fieldName) => {
50
- combinedElements.set(fieldName, element);
51
- });
52
- focusableElements.current = (0, import_utils.sortElementsByPosition)(combinedElements);
53
- }, [control._fields]);
54
- const registerCustomFocusableElement = (0, import_react.useCallback)(
55
- (fieldName, element) => {
56
- if (fieldName && element) {
57
- customFocusableElements.current.set(fieldName, element);
58
- updateFocusableElements();
59
- }
60
- return function unregister() {
61
- customFocusableElements.current.delete(fieldName);
62
- updateFocusableElements();
63
- };
64
- },
65
- [updateFocusableElements]
66
- );
67
- (0, import_react.useEffect)(() => {
68
- if (!enabled || !subscribe) return;
69
- const callback = subscribe({
70
- formState: {
71
- errors: true
72
- // Subscribe to any form state change that might indicate field structure changes
73
- },
74
- callback: () => {
75
- setTimeout(updateFocusableElements, 0);
76
- }
77
- });
78
- updateFocusableElements();
79
- return () => callback();
80
- }, [enabled, updateFocusableElements, subscribe]);
81
- const focusOnError = (0, import_react.useCallback)(
82
- (errors) => {
83
- if (!enabled) return;
84
- if (!errors || Object.keys(errors).length === 0) return;
85
- for (const [fieldName, element] of Array.from(
86
- focusableElements.current
87
- )) {
88
- if (hasFieldError(errors, fieldName)) {
89
- if (element && typeof element.focus === "function") {
90
- element.focus();
91
- return;
92
- } else if (element && element.name) {
93
- setFocus(fieldName);
94
- return;
95
- }
96
- }
97
- }
98
- },
99
- [enabled, setFocus]
100
- );
101
- return {
102
- /**
103
- * Registers a custom focusable element with the given field name.
104
- *
105
- * Returns a callback function to unregister the element by field name.
106
- *
107
- * @param fieldName - The name of the field to associate with the element.
108
- * @param element - The HTML element to register as focusable.
109
- */
110
- registerCustomFocusableElement,
111
- focusOnError
112
- };
113
- }
114
- function hasFieldError(errors, fieldName) {
115
- if (!errors || typeof errors !== "object") return false;
116
- if (errors[fieldName]) {
117
- return true;
118
- }
119
- const keys = fieldName.split(/[.[\]]+/).filter(Boolean);
120
- let current = errors;
121
- for (const key of keys) {
122
- if (current && typeof current === "object") {
123
- current = current[key];
124
- } else {
125
- return false;
126
- }
127
- }
128
- return !!current;
129
- }
130
- var useFieldFocusManager_default = useFieldFocusManager;
131
- // Annotate the CommonJS export names for ESM import in node:
132
- 0 && (module.exports = {
133
- useFieldFocusManager
134
- });
135
- //# sourceMappingURL=useFieldFocusManager.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/hooks/useFieldFocusManager.ts"],
4
- "sourcesContent": ["import { useCallback, useEffect, useRef } from 'react';\nimport type { Control, FieldValues, Ref, UseFormReturn } from 'react-hook-form';\nimport {\n extractFieldEntries,\n mapElementsToFields,\n sortElementsByPosition,\n} from '@digigov/form/hooks/utils';\n\nexport interface UseFieldFocusManagerProps<T extends FieldValues> {\n enabled?: boolean;\n control: Control<T>;\n subscribe: UseFormReturn['subscribe'];\n setFocus: UseFormReturn['setFocus'];\n}\n\n/**\n * Custom hook to manage focus on form fields.\n *\n * It collects all focusable elements from the form fields and sorts them according to their position in the DOM.\n */\nexport function useFieldFocusManager<T extends FieldValues>({\n enabled = true,\n control,\n subscribe,\n setFocus,\n}: UseFieldFocusManagerProps<T>) {\n /** Array to hold any external focusable elements registered by the user */\n const customFocusableElements = useRef(new Map<string, HTMLElement>());\n /** Map to hold focusable elements by field name */\n const focusableElements = useRef(new Map<string, Ref>());\n\n // When disabled, clear custom focusable elements and focusable elements map\n useEffect(() => {\n if (!enabled) {\n customFocusableElements.current.clear();\n focusableElements.current.clear();\n return;\n }\n }, [enabled]);\n\n const updateFocusableElements = useCallback(() => {\n // Clear existing focusable elements\n focusableElements.current.clear();\n // Extract from form fields\n const formElements = extractFieldEntries(control._fields);\n // Extract from custom elements (convert to FieldRefs format first)\n const customFieldRefs = mapElementsToFields(\n customFocusableElements.current\n );\n const customElements = extractFieldEntries(customFieldRefs);\n\n // Combine both maps\n const combinedElements = new Map(formElements);\n customElements.forEach((element, fieldName) => {\n combinedElements.set(fieldName, element);\n });\n\n // Sort once by DOM position\n focusableElements.current = sortElementsByPosition(combinedElements);\n }, [control._fields]);\n\n // Register / unregister custom focusable elements\n const registerCustomFocusableElement = useCallback(\n (fieldName: string, element: HTMLElement) => {\n if (fieldName && element) {\n customFocusableElements.current.set(fieldName, element);\n updateFocusableElements();\n }\n\n return function unregister() {\n customFocusableElements.current.delete(fieldName);\n updateFocusableElements();\n };\n },\n [updateFocusableElements]\n );\n\n // Collect focusable elements when fields change\n useEffect(() => {\n if (!enabled || !subscribe) return;\n const callback = subscribe({\n formState: {\n errors: true,\n // Subscribe to any form state change that might indicate field structure changes\n },\n callback: () => {\n // Defer to next tick to ensure DOM is updated\n setTimeout(updateFocusableElements, 0);\n },\n });\n\n // Initial update\n updateFocusableElements();\n\n return () => callback();\n }, [enabled, updateFocusableElements, subscribe]);\n\n // Subscribe to errors and focus the first field (according to the DOM) with an error\n const focusOnError = useCallback(\n (errors: Record<string, any>) => {\n if (!enabled) return;\n if (!errors || Object.keys(errors).length === 0) return;\n for (const [fieldName, element] of Array.from(\n focusableElements.current\n )) {\n if (hasFieldError(errors, fieldName)) {\n if (element && typeof element.focus === 'function') {\n element.focus(); // Focus the element directly\n return;\n } else if (element && element.name) {\n setFocus(fieldName); // Field is registered with react-hook-form\n return;\n }\n }\n }\n },\n [enabled, setFocus]\n );\n\n return {\n /**\n * Registers a custom focusable element with the given field name.\n *\n * Returns a callback function to unregister the element by field name.\n *\n * @param fieldName - The name of the field to associate with the element.\n * @param element - The HTML element to register as focusable.\n */\n registerCustomFocusableElement,\n focusOnError,\n };\n}\n\n// Helper function to check for nested field errors\nfunction hasFieldError(\n errors: Record<string, any>,\n fieldName: string\n): boolean {\n if (!errors || typeof errors !== 'object') return false;\n\n // Handle direct field names first\n if (errors[fieldName]) {\n return true;\n }\n\n // Split the field name and traverse the error object\n const keys = fieldName.split(/[.[\\]]+/).filter(Boolean);\n let current = errors;\n\n for (const key of keys) {\n if (current && typeof current === 'object') {\n current = current[key];\n } else {\n return false;\n }\n }\n\n // Check if we found a truthy error value\n return !!current;\n}\n\nexport default useFieldFocusManager;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+C;AAE/C,mBAIO;AAcA,SAAS,qBAA4C;AAAA,EAC1D,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AACF,GAAiC;AAE/B,QAAM,8BAA0B,qBAAO,oBAAI,IAAyB,CAAC;AAErE,QAAM,wBAAoB,qBAAO,oBAAI,IAAiB,CAAC;AAGvD,8BAAU,MAAM;AACd,QAAI,CAAC,SAAS;AACZ,8BAAwB,QAAQ,MAAM;AACtC,wBAAkB,QAAQ,MAAM;AAChC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AAEZ,QAAM,8BAA0B,0BAAY,MAAM;AAEhD,sBAAkB,QAAQ,MAAM;AAEhC,UAAM,mBAAe,kCAAoB,QAAQ,OAAO;AAExD,UAAM,sBAAkB;AAAA,MACtB,wBAAwB;AAAA,IAC1B;AACA,UAAM,qBAAiB,kCAAoB,eAAe;AAG1D,UAAM,mBAAmB,IAAI,IAAI,YAAY;AAC7C,mBAAe,QAAQ,CAAC,SAAS,cAAc;AAC7C,uBAAiB,IAAI,WAAW,OAAO;AAAA,IACzC,CAAC;AAGD,sBAAkB,cAAU,qCAAuB,gBAAgB;AA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AU,OAAO,WAAW,SAAU,QAAO;AAGlD,MAAI,OAAO,SAAS,GAAG;AACrB,WAAO;AAAA,EACT;AAGA,QAAM,OAAO,UAAU,MAAM,SAAS,EAAE,OAAO,OAAO;AACtD,MAAI,UAAU;AAEd,aAAW,OAAO,MAAM;AACtB,QAAI,WAAW,OAAO,YAAY,UAAU;AAC1C,gBAAU,QAAQ,GAAG;AAAA,IACvB,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF;AAGA,SAAO,CAAC,CAAC;AACX;AAEA,IAAO,+BAAQ;",
6
- "names": []
7
- }
@@ -1,98 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var utils_exports = {};
19
- __export(utils_exports, {
20
- extractFieldEntries: () => extractFieldEntries,
21
- mapElementsToFields: () => mapElementsToFields,
22
- sortElementsByPosition: () => sortElementsByPosition
23
- });
24
- module.exports = __toCommonJS(utils_exports);
25
- function extractFieldEntries(fields, prefix = "") {
26
- const elementMap = /* @__PURE__ */ new Map();
27
- const fieldEntries = Object.entries(fields);
28
- if (fieldEntries.length === 0) return elementMap;
29
- Object.entries(fields).forEach(([fieldName, field]) => {
30
- if (!field) return;
31
- const fullFieldName = prefix ? `${prefix}.${fieldName}` : fieldName;
32
- if (isField(field)) {
33
- const element = field._f.ref;
34
- if (element) {
35
- elementMap.set(fullFieldName, element);
36
- }
37
- } else if (isFieldRefs(field)) {
38
- const keys = Object.keys(field);
39
- const numericKeys = keys.filter((key) => /^\d+$/.test(key));
40
- const hasNumericKeys = numericKeys.length > 0;
41
- if (hasNumericKeys) {
42
- numericKeys.forEach((index) => {
43
- const arrayItem = field[index];
44
- if (arrayItem && isFieldRefs(arrayItem)) {
45
- const nestedEntries = extractFieldEntries(
46
- arrayItem,
47
- `${fullFieldName}.${index}`
48
- );
49
- nestedEntries.forEach((element, fieldName2) => {
50
- elementMap.set(fieldName2, element);
51
- });
52
- }
53
- });
54
- } else {
55
- const nestedEntries = extractFieldEntries(field, fullFieldName);
56
- nestedEntries.forEach((element, fieldName2) => {
57
- elementMap.set(fieldName2, element);
58
- });
59
- }
60
- }
61
- });
62
- return elementMap;
63
- }
64
- const isField = (fieldRef) => Boolean(
65
- fieldRef && typeof fieldRef === "object" && "_f" in fieldRef && fieldRef._f && "ref" in fieldRef._f
66
- );
67
- const isFieldRefs = (fieldRef) => Boolean(fieldRef && typeof fieldRef === "object" && !isField(fieldRef));
68
- function sortElementsByPosition(elements) {
69
- const sortedEntries = Array.from(elements.entries()).sort(([, a], [, b]) => {
70
- if (isActualHTMLElement(a) && isActualHTMLElement(b)) {
71
- const aPosition = a.compareDocumentPosition(b);
72
- if (aPosition & Node.DOCUMENT_POSITION_FOLLOWING) return -1;
73
- if (aPosition & Node.DOCUMENT_POSITION_PRECEDING) return 1;
74
- }
75
- return 0;
76
- });
77
- return new Map(sortedEntries);
78
- }
79
- const isActualHTMLElement = (ref) => ref instanceof HTMLElement && typeof ref.focus === "function";
80
- function mapElementsToFields(elements) {
81
- const fields = {};
82
- elements.forEach((element, fieldName) => {
83
- fields[fieldName] = {
84
- _f: {
85
- ref: element,
86
- name: fieldName
87
- }
88
- };
89
- });
90
- return fields;
91
- }
92
- // Annotate the CommonJS export names for ESM import in node:
93
- 0 && (module.exports = {
94
- extractFieldEntries,
95
- mapElementsToFields,
96
- sortElementsByPosition
97
- });
98
- //# sourceMappingURL=utils.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/hooks/utils.ts"],
4
- "sourcesContent": ["import type { Field, FieldRefs, Ref } from 'react-hook-form';\n\n/**\n * Recursively extracts field entries from nested form field structure.\n * Handles both regular nested objects and array-like structures.\n */\nexport function extractFieldEntries(\n fields: FieldRefs,\n prefix = ''\n): Map<string, Ref> {\n const elementMap = new Map<string, Ref>();\n\n const fieldEntries = Object.entries(fields);\n if (fieldEntries.length === 0) return elementMap;\n\n Object.entries(fields).forEach(([fieldName, field]) => {\n if (!field) return;\n const fullFieldName = prefix ? `${prefix}.${fieldName}` : fieldName;\n\n // Handle direct field with ref\n if (isField(field)) {\n const element = field._f.ref;\n if (element) {\n elementMap.set(fullFieldName, element);\n }\n }\n\n // Handle array fields (numeric keys indicate array indices)\n else if (isFieldRefs(field)) {\n // Check if any keys are numeric (indicating an array structure)\n // Filter out non-numeric keys like '_f' which contains field metadata\n const keys = Object.keys(field);\n const numericKeys = keys.filter((key) => /^\\d+$/.test(key));\n const hasNumericKeys = numericKeys.length > 0;\n\n if (hasNumericKeys) {\n // Process only the numeric array indices, ignore metadata keys like '_f'\n numericKeys.forEach((index) => {\n const arrayItem = field[index];\n if (arrayItem && isFieldRefs(arrayItem)) {\n const nestedEntries = extractFieldEntries(\n arrayItem,\n `${fullFieldName}.${index}`\n );\n // Merge nested entries into main map\n nestedEntries.forEach((element, fieldName) => {\n elementMap.set(fieldName, element);\n });\n }\n });\n } else {\n // Handle regular nested objects\n const nestedEntries = extractFieldEntries(field, fullFieldName);\n // Merge nested entries into main map\n nestedEntries.forEach((element, fieldName) => {\n elementMap.set(fieldName, element);\n });\n }\n }\n });\n\n return elementMap;\n}\n\n/** Type guard to check if a ref is a Field object */\nconst isField = (fieldRef: FieldRefs[keyof FieldRefs]): fieldRef is Field =>\n Boolean(\n fieldRef &&\n typeof fieldRef === 'object' &&\n '_f' in fieldRef &&\n fieldRef._f &&\n 'ref' in fieldRef._f\n );\n\n/** Type guard to check if a ref is a FieldRefs object (nested fields) */\nconst isFieldRefs = (\n fieldRef: FieldRefs[keyof FieldRefs]\n): fieldRef is FieldRefs =>\n Boolean(fieldRef && typeof fieldRef === 'object' && !isField(fieldRef));\n\n/**\n * Sorts a map of HTML elements by their position in the DOM.\n * Elements appearing earlier in the document order come first.\n */\nexport function sortElementsByPosition(\n elements: Map<string, Ref>\n): Map<string, Ref> {\n const sortedEntries = Array.from(elements.entries()).sort(([, a], [, b]) => {\n if (isActualHTMLElement(a) && isActualHTMLElement(b)) {\n const aPosition = a.compareDocumentPosition(b);\n if (aPosition & Node.DOCUMENT_POSITION_FOLLOWING) return -1;\n if (aPosition & Node.DOCUMENT_POSITION_PRECEDING) return 1;\n }\n return 0; // keep original order\n });\n return new Map(sortedEntries);\n}\n\n/** Type guard to check if a ref is an actual HTML element */\nconst isActualHTMLElement = (ref: Ref): ref is Ref & HTMLElement =>\n ref instanceof HTMLElement && typeof ref.focus === 'function';\n\n/**\n * Maps a collection of HTML elements to a FieldRefs structure.\n *\n * It's not a direct conversion, but rather a way to create a simple FieldRefs\n * structure that can be used with React Hook Form.\n */\nexport function mapElementsToFields(\n elements: Map<string, HTMLElement>\n): Record<string, Field> {\n const fields = {};\n elements.forEach((element, fieldName) => {\n fields[fieldName] = {\n _f: {\n ref: element,\n name: fieldName,\n },\n };\n });\n return fields;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,SAAS,oBACd,QACA,SAAS,IACS;AAClB,QAAM,aAAa,oBAAI,IAAiB;AAExC,QAAM,eAAe,OAAO,QAAQ,MAAM;AAC1C,MAAI,aAAa,WAAW,EAAG,QAAO;AAEtC,SAAO,QAAQ,MAAM,EAAE,QAAQ,CAAC,CAAC,WAAW,KAAK,MAAM;AACrD,QAAI,CAAC,MAAO;AACZ,UAAM,gBAAgB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BAAoB,CAAC,GAAG;AACpD,YAAM,YAAY,EAAE,wBAAwB,CAAC;AAC7C,UAAI,YAAY,KAAK,4BAA6B,QAAO;AACzD,UAAI,YAAY,KAAK,4BAA6B,QAAO;AAAA,IAC3D;AACA,WAAO;AAAA,EACT,CAAC;AACD,SAAO,IAAI,IAAI,aAAa;AAC9B;AAGA,MAAM,sBAAsB,CAAC,QAC3B,eAAe,eAAe,OAAO,IAAI,UAAU;AAQ9C,SAAS,oBACd,UACuB;AACvB,QAAM,SAAS,CAAC;AAChB,WAAS,QAAQ,CAAC,SAAS,cAAc;AACvC,WAAO,SAAS,IAAI;AAAA,MAClB,IAAI;AAAA,QACF,KAAK;AAAA,QACL,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
6
- "names": ["fieldName"]
7
- }
package/cjs/index.js DELETED
@@ -1,49 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var src_exports = {};
30
- __export(src_exports, {
31
- Field: () => import_Field.default,
32
- Fieldset: () => import_Fieldset.default,
33
- default: () => src_default
34
- });
35
- module.exports = __toCommonJS(src_exports);
36
- var import_Field = __toESM(require("@digigov/form/Field"));
37
- var import_Fieldset = __toESM(require("@digigov/form/Fieldset"));
38
- __reExport(src_exports, require("@digigov/form/inputs/Label"), module.exports);
39
- var import_FormBuilder = __toESM(require("@digigov/form/FormBuilder"));
40
- __reExport(src_exports, require("@digigov/form/types"), module.exports);
41
- var src_default = import_FormBuilder.default;
42
- // Annotate the CommonJS export names for ESM import in node:
43
- 0 && (module.exports = {
44
- Field,
45
- Fieldset,
46
- ...require("@digigov/form/inputs/Label"),
47
- ...require("@digigov/form/types")
48
- });
49
- //# sourceMappingURL=index.js.map
package/cjs/index.js.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export { default as Field } from '@digigov/form/Field';\nexport { default as Fieldset } from '@digigov/form/Fieldset';\nexport * from '@digigov/form/inputs/Label';\nimport FormBuilder from '@digigov/form/FormBuilder';\nexport * from '@digigov/form/types';\nexport default FormBuilder;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiC;AACjC,sBAAoC;AACpC,wBAAc,uCAFd;AAGA,yBAAwB;AACxB,wBAAc,gCAJd;AAKA,IAAO,cAAQ,mBAAAA;",
6
- "names": ["FormBuilder"]
7
- }
@@ -1,98 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var AutoCompleteInput_exports = {};
29
- __export(AutoCompleteInput_exports, {
30
- AutoCompleteInput: () => AutoCompleteInput,
31
- default: () => AutoCompleteInput_default
32
- });
33
- module.exports = __toCommonJS(AutoCompleteInput_exports);
34
- var import_react = __toESM(require("react"));
35
- var import_AutoComplete = require("@digigov/ui/form/AutoComplete");
36
- var import_Hint = require("@digigov/ui/typography/Hint");
37
- var import_Base = require("@digigov/ui/utils/Base");
38
- const AutoCompleteInput = ({
39
- name,
40
- type,
41
- extra: { options },
42
- onChange,
43
- value,
44
- ...props
45
- }) => {
46
- const suggest = (0, import_react.useCallback)(
47
- function suggest2(query, syncResults) {
48
- syncResults(
49
- query ? options.filter(function(option) {
50
- return `${option.value} ${option.label?.primary || ""} ${option.label?.secondary || ""}`.toLowerCase().indexOf(query.toLowerCase()) !== -1;
51
- }) : options
52
- );
53
- },
54
- [options]
55
- );
56
- return /* @__PURE__ */ import_react.default.createElement(
57
- import_AutoComplete.AutoComplete,
58
- {
59
- multiple: type === "choice:multiple" ? true : false,
60
- source: suggest,
61
- onConfirm: (value2) => {
62
- if (Array.isArray(value2)) {
63
- const selectedValues = value2.map((item) => item.value);
64
- if (selectedValues.length > 0) onChange(selectedValues);
65
- else onChange(void 0);
66
- } else {
67
- onChange(value2.value);
68
- }
69
- },
70
- templates: {
71
- suggestion({ label, value: value2 }) {
72
- return /* @__PURE__ */ import_react.default.createElement(import_Base.Base, { as: "div" }, label && label.primary && label.primary || value2, label && label.secondary && /* @__PURE__ */ import_react.default.createElement(import_Hint.Hint, null, label.secondary));
73
- },
74
- inputValue: (option) => {
75
- if (!option) {
76
- return "";
77
- }
78
- return option.label.primary || option.value;
79
- }
80
- },
81
- ...{
82
- ...props,
83
- reset: void 0,
84
- required: void 0,
85
- Field: void 0
86
- },
87
- name,
88
- id: `${name}-id`,
89
- defaultValue: value
90
- }
91
- );
92
- };
93
- var AutoCompleteInput_default = AutoCompleteInput;
94
- // Annotate the CommonJS export names for ESM import in node:
95
- 0 && (module.exports = {
96
- AutoCompleteInput
97
- });
98
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/inputs/AutoCompleteInput/index.tsx"],
4
- "sourcesContent": ["import React, { useCallback } from 'react';\nimport type { ControlledFieldProps } from '@digigov/form/Field/types';\nimport type { FieldOptionProps } from '@digigov/form/inputs/Label';\nimport type { AutoCompleteProps as UIAutoCompleteProps } from '@digigov/ui/form/AutoComplete';\nimport { AutoComplete } from '@digigov/ui/form/AutoComplete';\nimport { Hint } from '@digigov/ui/typography/Hint';\nimport { Base } from '@digigov/ui/utils/Base';\nexport interface AutoCompleteInputExtra\n extends Omit<\n UIAutoCompleteProps,\n | 'source'\n | 'id'\n | 'templates'\n | 'defaultValue'\n | 'onConfirm'\n | 'dropdownArrow'\n > {\n options: FieldOptionProps[];\n}\n\nexport interface AutoCompleteInputProps\n extends Omit<ControlledFieldProps, 'value' | 'onChange' | 'extra'> {\n extra: AutoCompleteInputExtra;\n value: string;\n onChange: (v: string | string[] | undefined) => void;\n}\n\nexport const AutoCompleteInput: React.FC<AutoCompleteInputProps> = ({\n name,\n type,\n extra: { options },\n onChange,\n value,\n ...props\n}) => {\n const suggest = useCallback(\n function suggest(\n query: string,\n syncResults: (options: any[]) => void\n ): void {\n syncResults(\n query\n ? options.filter(function (option) {\n return (\n `${option.value} ${option.label?.primary || ''} ${\n option.label?.secondary || ''\n }`\n .toLowerCase()\n .indexOf(query.toLowerCase()) !== -1\n );\n })\n : options\n );\n },\n [options]\n );\n\n return (\n <AutoComplete\n multiple={type === 'choice:multiple' ? true : false}\n source={suggest}\n onConfirm={(value) => {\n if (Array.isArray(value)) {\n const selectedValues = value.map((item) => item.value);\n if (selectedValues.length > 0) onChange(selectedValues);\n else onChange(undefined);\n } else {\n onChange(value.value);\n }\n }}\n templates={{\n suggestion({ label, value }) {\n return (\n <Base as=\"div\">\n {(label && label.primary && label.primary) || value}\n {label && label.secondary && <Hint>{label.secondary}</Hint>}\n </Base>\n );\n },\n inputValue: (option) => {\n if (!option) {\n return '';\n }\n return option.label.primary || option.value;\n },\n }}\n {...{\n ...props,\n reset: undefined,\n required: undefined,\n Field: undefined,\n }}\n name={name}\n id={`${name}-id`}\n defaultValue={value}\n />\n );\n};\n\nexport default AutoCompleteInput;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAmC;AAInC,0BAA6B;AAC7B,kBAAqB;AACrB,kBAAqB;AAqBd,MAAM,oBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AAAA,EACA,OAAO,EAAE,QAAQ;AAAA,EACjB;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,cAAU;AAAA,I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React", "value"]
7
- }
@@ -1,112 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var Checkboxes_exports = {};
29
- __export(Checkboxes_exports, {
30
- Checkboxes: () => Checkboxes,
31
- default: () => Checkboxes_default
32
- });
33
- module.exports = __toCommonJS(Checkboxes_exports);
34
- var import_react = __toESM(require("react"));
35
- var import_utils = require("@digigov/form/utils");
36
- var import_Checkbox = require("@digigov/ui/form/Checkbox");
37
- var import_i18n = require("@digigov/ui/i18n");
38
- var import_Hint = require("@digigov/ui/typography/Hint");
39
- const Checkboxes = import_react.default.forwardRef(
40
- ({
41
- name,
42
- onChange,
43
- value,
44
- extra: { options, className },
45
- disabled,
46
- Field,
47
- ...props
48
- }, ref) => {
49
- if (!value) value = [];
50
- const handleChange = (optionValue, idx, show) => (evt) => {
51
- let newValue = [];
52
- if (evt.currentTarget.checked) {
53
- newValue = value.concat([optionValue]);
54
- } else {
55
- newValue = value.filter((val) => val !== optionValue);
56
- }
57
- if (show && show.length > 0) {
58
- setChecked(
59
- (items) => items.map((item, index) => index === idx ? !item : item)
60
- );
61
- }
62
- if (newValue.length === 0) newValue = void 0;
63
- onChange(newValue);
64
- };
65
- const { t } = (0, import_i18n.useTranslation)();
66
- const [checked, setChecked] = (0, import_react.useState)(
67
- Array(options.length).fill(false)
68
- );
69
- return /* @__PURE__ */ import_react.default.createElement(import_Checkbox.Checkbox, { className }, options.map(
70
- ({
71
- label,
72
- value: v,
73
- show,
74
- disabled: optionDisabled,
75
- selected,
76
- ...option
77
- }, index) => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, { key: index }, /* @__PURE__ */ import_react.default.createElement(
78
- import_Checkbox.CheckboxItem,
79
- {
80
- ref: index === 0 ? ref : void 0,
81
- key: `${name}.${index}`,
82
- name: `${name}.${v}`,
83
- id: `${name}.${v}`,
84
- value: v,
85
- disabled: disabled || optionDisabled,
86
- checked: value?.includes(v),
87
- onChange: handleChange(v, index, show),
88
- ...option,
89
- ...{
90
- ...(0, import_utils.omit)(props, ["resetField"]),
91
- reset: void 0,
92
- defaultValue: void 0,
93
- error: void 0,
94
- onBlur: void 0,
95
- required: void 0,
96
- "aria-describedby": void 0,
97
- type: "checkbox"
98
- }
99
- },
100
- label && label.primary && t(label.primary) || value,
101
- label && label.secondary && /* @__PURE__ */ import_react.default.createElement(import_Hint.Hint, null, t(label.secondary))
102
- ), !!checked[index] && show && Field && /* @__PURE__ */ import_react.default.createElement(import_Checkbox.CheckboxConditional, null, show.map((fieldName) => /* @__PURE__ */ import_react.default.createElement(Field, { name: fieldName, key: fieldName }))), selected && selected())
103
- ));
104
- }
105
- );
106
- Checkboxes.displayName = "Checkboxes";
107
- var Checkboxes_default = Checkboxes;
108
- // Annotate the CommonJS export names for ESM import in node:
109
- 0 && (module.exports = {
110
- Checkboxes
111
- });
112
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/inputs/Checkboxes/index.tsx"],
4
- "sourcesContent": ["import React, { useState } from 'react';\nimport type { UseFormReturn } from 'react-hook-form';\nimport type { ControlledFieldProps } from '@digigov/form/Field/types';\nimport type { FieldOptionProps } from '@digigov/form/inputs/Label';\nimport { omit } from '@digigov/form/utils';\nimport {\n Checkbox,\n CheckboxItem,\n CheckboxConditional,\n} from '@digigov/ui/form/Checkbox';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\n\nexport interface CheckboxesProps\n extends Omit<ControlledFieldProps, 'extra' | 'value'> {\n value?: string[];\n extra: {\n className?: string;\n options: FieldOptionProps[];\n };\n fieldComponent: React.FC<Omit<ControlledFieldProps, 'value' | 'onChange'>>;\n resetField: UseFormReturn['resetField'];\n}\n\nexport const Checkboxes = React.forwardRef<HTMLInputElement, CheckboxesProps>(\n (\n {\n name,\n onChange,\n value,\n extra: { options, className },\n disabled,\n Field,\n ...props\n },\n ref\n ) => {\n if (!value) value = [];\n const handleChange =\n (optionValue, idx, show) =>\n (evt): void => {\n let newValue: any = [];\n if (evt.currentTarget.checked) {\n newValue = value.concat([optionValue]);\n } else {\n newValue = value.filter((val) => val !== optionValue);\n }\n if (show && show.length > 0) {\n setChecked((items) =>\n items.map((item, index) => (index === idx ? !item : item))\n );\n }\n\n // reset value to undefined instead of an empty array\n // so the error state mechanism can throw validation errors\n if (newValue.length === 0) newValue = undefined;\n onChange(newValue);\n };\n const { t } = useTranslation();\n const [checked, setChecked] = useState(\n Array<boolean>(options.length).fill(false)\n );\n return (\n <Checkbox className={className}>\n {options.map(\n (\n {\n label,\n value: v,\n show,\n disabled: optionDisabled,\n selected,\n ...option\n },\n index\n ) => (\n <React.Fragment key={index}>\n <CheckboxItem\n ref={index === 0 ? ref : undefined}\n key={`${name}.${index}`}\n name={`${name}.${v}`}\n id={`${name}.${v}`}\n value={v}\n disabled={disabled || optionDisabled}\n checked={value?.includes(v)}\n onChange={handleChange(v, index, show)}\n {...option}\n {...{\n ...omit(props, ['resetField']),\n reset: undefined,\n defaultValue: undefined,\n error: undefined,\n onBlur: undefined,\n required: undefined,\n 'aria-describedby': undefined,\n type: 'checkbox',\n }}\n >\n {(label && label.primary && t(label.primary)) || value}\n {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}\n </CheckboxItem>\n\n {!!checked[index] && show && Field && (\n <CheckboxConditional>\n {show.map((fieldName) => (\n <Field name={fieldName} key={fieldName} />\n ))}\n </CheckboxConditional>\n )}\n {selected && selected()}\n </React.Fragment>\n )\n )}\n </Checkbox>\n );\n }\n);\n\nCheckboxes.displayName = 'Checkboxes';\n\nexport default Checkboxes;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgC;AAIhC,mBAAqB;AACrB,sBAIO;AACP,kBAA+B;AAC/B,kBAAqB;AAad,MAAM,aAAa,aAAAA,QAAM;AAAA,EAC9B,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,SAAS,UAAU;AAAA,IAC5B;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,QAAI,CAAC,MAAO,SAAQ,CAAC;AACrB,UAAM,eACJ,CAAC,aAAa,KAAK,SACnB,CAAC,QAAc;AACb,UAAI,WAAgB,CAAC;AACrB,UAAI,IAAI,cAAc,SAAS;AAC7B,mBAAW,MAAM,OAAO,CAAC,WAAW,CAAC;AAAA,MACvC,OAAO;AACL,mBAAW,MAAM,OAAO,CAAC,QAAQ,QAAQ,WAAW;AAAA,MACtD;AACA,UAAI,QAAQ,KAAK,SAAS,GAAG;AAC3B;AAAA,UAAW,CAAC,UACV,MAAM,IAAI,CAAC,MAAM,UAAW,UAAU,MAAM,CAAC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