@digigov/form 2.0.0-87b6232d → 2.0.0-8bbad051

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 (585) hide show
  1. package/Field/ErrorGroup.d.ts +3 -3
  2. package/Field/ErrorGroup.js.map +1 -1
  3. package/Field/FieldBase/index.js +5 -5
  4. package/Field/FieldBase.d.ts +1 -1
  5. package/Field/FieldBase.js.map +2 -2
  6. package/Field/FieldBaseContainer/index.js +37 -19
  7. package/Field/FieldBaseContainer.d.ts +2 -2
  8. package/Field/FieldBaseContainer.js.map +2 -2
  9. package/Field/FieldConditional/index.js +1 -1
  10. package/Field/FieldConditional.d.ts +1 -1
  11. package/Field/FieldConditional.js.map +1 -1
  12. package/Field/index.d.ts +1 -1
  13. package/Field/index.js +18 -27
  14. package/Field/index.js.map +2 -2
  15. package/Field/types.d.ts +13 -12
  16. package/Field/utils/evaluateFieldWithConditions.d.ts +2 -2
  17. package/Field/utils/evaluateFieldWithConditions.js.map +2 -2
  18. package/Field/utils/resolveField/index.js +35 -0
  19. package/Field/utils/{calculateField → resolveField}/package.json +1 -1
  20. package/Field/utils/resolveField.d.ts +3 -0
  21. package/Field/utils/resolveField.js.map +7 -0
  22. package/Field/utils/useField/index.js +4 -2
  23. package/Field/utils/useField.d.ts +1 -1
  24. package/Field/utils/useField.js.map +2 -2
  25. package/FieldArray/BaseFieldArray/index.js +76 -0
  26. package/{inputs/inputsScenarios → FieldArray/BaseFieldArray}/package.json +1 -1
  27. package/FieldArray/BaseFieldArray.d.ts +5 -0
  28. package/FieldArray/BaseFieldArray.js.map +7 -0
  29. package/FieldArray/FieldArray.stories.d.ts +1 -0
  30. package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/index.js +23 -0
  31. package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/package.json +6 -0
  32. package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.d.ts +9 -0
  33. package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js.map +7 -0
  34. package/FieldArray/FormDialog/ArrayDisplay/ArrayDisplay.stories.d.ts +13 -0
  35. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/index.js +184 -0
  36. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/package.json +6 -0
  37. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.d.ts +26 -0
  38. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js.map +7 -0
  39. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/index.js +11 -0
  40. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/package.json +6 -0
  41. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.d.ts +5 -0
  42. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js.map +7 -0
  43. package/FieldArray/FormDialog/ArrayDisplay/__stories__/Cards.d.ts +2 -0
  44. package/FieldArray/FormDialog/ArrayDisplay/__stories__/Default.d.ts +2 -0
  45. package/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnly.d.ts +2 -0
  46. package/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnlyCards.d.ts +2 -0
  47. package/FieldArray/FormDialog/ArrayDisplay/__stories__/Sortable.d.ts +2 -0
  48. package/FieldArray/FormDialog/ArrayDisplay/__stories__/SortableCards.d.ts +2 -0
  49. package/FieldArray/FormDialog/ArrayDisplay/index.d.ts +15 -0
  50. package/FieldArray/FormDialog/ArrayDisplay/index.js +57 -0
  51. package/FieldArray/FormDialog/ArrayDisplay/index.js.map +7 -0
  52. package/{inputs/Input/inputsInputScenarios → FieldArray/FormDialog/ArrayDisplay}/package.json +1 -1
  53. package/FieldArray/FormDialog/ArrayEditModal/index.js +158 -0
  54. package/FieldArray/FormDialog/ArrayEditModal/package.json +6 -0
  55. package/FieldArray/FormDialog/ArrayEditModal.d.ts +24 -0
  56. package/FieldArray/FormDialog/ArrayEditModal.js.map +7 -0
  57. package/FieldArray/FormDialog/index.d.ts +19 -0
  58. package/FieldArray/FormDialog/index.js +183 -351
  59. package/FieldArray/FormDialog/index.js.map +7 -0
  60. package/FieldArray/__stories__/CardsWithError.d.ts +15 -0
  61. package/FieldArray/__stories__/Default.d.ts +1 -1
  62. package/FieldArray/__stories__/WithExactLength.d.ts +1 -1
  63. package/FieldArray/__stories__/WithModal.d.ts +1 -1
  64. package/FieldArray/index.d.ts +5 -3
  65. package/FieldArray/index.js +64 -98
  66. package/FieldArray/index.js.map +3 -3
  67. package/FieldObject/index.d.ts +4 -4
  68. package/FieldObject/index.js +5 -12
  69. package/FieldObject/index.js.map +2 -2
  70. package/Fieldset/FieldsetWithContext.js.map +1 -1
  71. package/Fieldset/index.d.ts +1 -1
  72. package/Fieldset/index.js.map +1 -1
  73. package/Fieldset/types.d.ts +2 -2
  74. package/FormBuilder/FormBuilder.stories.d.ts +2 -0
  75. package/FormBuilder/__stories__/AutoErrorGrouping.d.ts +1 -1
  76. package/FormBuilder/__stories__/Default.d.ts +1 -1
  77. package/FormBuilder/__stories__/ErrorGrouping.d.ts +1 -1
  78. package/FormBuilder/index.d.ts +2 -2
  79. package/FormBuilder/index.js +159 -137
  80. package/FormBuilder/index.js.map +2 -2
  81. package/FormContext/index.js +6 -2
  82. package/FormContext.d.ts +3 -2
  83. package/FormContext.js.map +2 -2
  84. package/MultiplicityField/MultiplicityField.stories.d.ts +2 -0
  85. package/MultiplicityField/__stories__/Default.d.ts +1 -1
  86. package/MultiplicityField/__stories__/PreviewDisplay.d.ts +1 -1
  87. package/MultiplicityField/__stories__/WithExactLength.d.ts +1 -1
  88. package/MultiplicityField/__stories__/WithMaxLength.d.ts +1 -1
  89. package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +1 -1
  90. package/MultiplicityField/__stories__/WithMinLength.d.ts +1 -1
  91. package/MultiplicityField/add-objects/index.js +11 -20
  92. package/MultiplicityField/add-objects.d.ts +1 -1
  93. package/MultiplicityField/add-objects.js.map +2 -2
  94. package/MultiplicityField/index.d.ts +2 -2
  95. package/MultiplicityField/index.js +4 -2
  96. package/MultiplicityField/index.js.map +2 -2
  97. package/MultiplicityField/types.d.ts +3 -2
  98. package/Questions/Questions.d.ts +1 -1
  99. package/Questions/Questions.js.map +1 -1
  100. package/Questions/Questions.stories.d.ts +2 -0
  101. package/Questions/QuestionsContext.d.ts +1 -1
  102. package/Questions/QuestionsContext.js.map +1 -1
  103. package/Questions/Step/Step.d.ts +1 -1
  104. package/Questions/Step/Step.js.map +1 -1
  105. package/Questions/Step/StepArrayReview.d.ts +1 -1
  106. package/Questions/Step/StepArrayReview.js.map +1 -1
  107. package/Questions/Step/StepContext.d.ts +1 -1
  108. package/Questions/Step/StepContext.js.map +1 -1
  109. package/Questions/Step/StepDescription.d.ts +1 -1
  110. package/Questions/Step/StepDescription.js.map +2 -2
  111. package/Questions/Step/StepForm.d.ts +2 -2
  112. package/Questions/Step/StepForm.js.map +1 -1
  113. package/Questions/Step/StepQuote.d.ts +1 -1
  114. package/Questions/Step/StepQuote.js.map +2 -2
  115. package/Questions/Step/StepTitle.d.ts +1 -1
  116. package/Questions/Step/StepTitle.js.map +2 -2
  117. package/Questions/Step/getAddMoreFields.d.ts +2 -2
  118. package/Questions/Step/getAddMoreFields.js.map +1 -1
  119. package/Questions/Step/types.d.ts +1 -1
  120. package/Questions/__stories__/Default.d.ts +1 -1
  121. package/Questions/getNextStep.d.ts +1 -1
  122. package/Questions/getNextStep.js.map +1 -1
  123. package/Questions/types.d.ts +1 -1
  124. package/cjs/Field/ErrorGroup.js.map +1 -1
  125. package/cjs/Field/FieldBase/index.js +5 -5
  126. package/cjs/Field/FieldBase.js.map +2 -2
  127. package/cjs/Field/FieldBaseContainer/index.js +36 -18
  128. package/cjs/Field/FieldBaseContainer.js.map +3 -3
  129. package/cjs/Field/FieldConditional/index.js +1 -1
  130. package/cjs/Field/FieldConditional.js.map +1 -1
  131. package/cjs/Field/index.js +18 -24
  132. package/cjs/Field/index.js.map +2 -2
  133. package/cjs/Field/types.js.map +1 -1
  134. package/cjs/Field/utils/evaluateFieldWithConditions.js.map +2 -2
  135. package/cjs/Field/utils/resolveField/index.js +55 -0
  136. package/cjs/Field/utils/resolveField.js.map +7 -0
  137. package/cjs/Field/utils/useField/index.js +4 -2
  138. package/cjs/Field/utils/useField.js.map +2 -2
  139. package/cjs/FieldArray/BaseFieldArray/index.js +109 -0
  140. package/cjs/FieldArray/BaseFieldArray.js.map +7 -0
  141. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/index.js +56 -0
  142. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js.map +7 -0
  143. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/index.js +209 -0
  144. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js.map +7 -0
  145. package/cjs/{locales/el → FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader}/index.js +16 -7
  146. package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js.map +7 -0
  147. package/cjs/FieldArray/FormDialog/ArrayDisplay/index.js +90 -0
  148. package/cjs/FieldArray/FormDialog/ArrayDisplay/index.js.map +7 -0
  149. package/cjs/FieldArray/FormDialog/ArrayEditModal/index.js +186 -0
  150. package/cjs/FieldArray/FormDialog/ArrayEditModal.js.map +7 -0
  151. package/cjs/FieldArray/FormDialog/index.js +174 -334
  152. package/cjs/FieldArray/FormDialog/index.js.map +7 -0
  153. package/cjs/FieldArray/index.js +63 -94
  154. package/cjs/FieldArray/index.js.map +3 -3
  155. package/cjs/FieldObject/index.js +5 -9
  156. package/cjs/FieldObject/index.js.map +2 -2
  157. package/cjs/Fieldset/FieldsetWithContext.js.map +1 -1
  158. package/cjs/Fieldset/index.js.map +1 -1
  159. package/cjs/Fieldset/types.js.map +1 -1
  160. package/cjs/FormBuilder/index.js +160 -138
  161. package/cjs/FormBuilder/index.js.map +3 -3
  162. package/cjs/FormContext/index.js +7 -2
  163. package/cjs/FormContext.js.map +2 -2
  164. package/cjs/MultiplicityField/add-objects/index.js +10 -14
  165. package/cjs/MultiplicityField/add-objects.js.map +2 -2
  166. package/cjs/MultiplicityField/index.js +4 -2
  167. package/cjs/MultiplicityField/index.js.map +2 -2
  168. package/cjs/MultiplicityField/types.js.map +1 -1
  169. package/cjs/Questions/Questions.js.map +1 -1
  170. package/cjs/Questions/QuestionsContext.js.map +1 -1
  171. package/cjs/Questions/Step/Step.js.map +1 -1
  172. package/cjs/Questions/Step/StepArrayReview.js.map +1 -1
  173. package/cjs/Questions/Step/StepContext.js.map +1 -1
  174. package/cjs/Questions/Step/StepDescription.js.map +2 -2
  175. package/cjs/Questions/Step/StepForm.js.map +1 -1
  176. package/cjs/Questions/Step/StepQuote.js.map +2 -2
  177. package/cjs/Questions/Step/StepTitle.js.map +2 -2
  178. package/cjs/Questions/Step/getAddMoreFields.js.map +1 -1
  179. package/cjs/Questions/Step/types.js.map +1 -1
  180. package/cjs/Questions/getNextStep.js.map +1 -1
  181. package/cjs/Questions/types.js.map +1 -1
  182. package/cjs/hooks/useFieldFocusManager/index.js +135 -0
  183. package/cjs/hooks/useFieldFocusManager.js.map +7 -0
  184. package/cjs/hooks/utils/index.js +98 -0
  185. package/cjs/hooks/utils.js.map +7 -0
  186. package/cjs/inputs/AutoCompleteInput/index.js.map +2 -2
  187. package/cjs/inputs/Checkboxes/index.js +68 -62
  188. package/cjs/inputs/Checkboxes/index.js.map +2 -2
  189. package/cjs/inputs/DateInput/index.js +37 -17
  190. package/cjs/inputs/DateInput/index.js.map +2 -2
  191. package/cjs/inputs/DateTimeInput/index.js +65 -39
  192. package/cjs/inputs/DateTimeInput/index.js.map +2 -2
  193. package/cjs/inputs/FileInput/index.js +35 -24
  194. package/cjs/inputs/FileInput/index.js.map +2 -2
  195. package/cjs/inputs/ImageInput/__stories__/logo.d/index.js +1 -0
  196. package/cjs/inputs/ImageInput/__stories__/logo.d.js.map +7 -0
  197. package/cjs/inputs/ImageInput/index.js +44 -13
  198. package/cjs/inputs/ImageInput/index.js.map +2 -2
  199. package/cjs/inputs/Input/index.js +6 -4
  200. package/cjs/inputs/Input/index.js.map +2 -2
  201. package/cjs/inputs/Label/index.js.map +1 -1
  202. package/cjs/inputs/OtpInput/index.js +36 -31
  203. package/cjs/inputs/OtpInput/index.js.map +2 -2
  204. package/cjs/inputs/Radio/index.js +7 -5
  205. package/cjs/inputs/Radio/index.js.map +3 -3
  206. package/cjs/inputs/Select/index.js +2 -2
  207. package/cjs/inputs/Select/index.js.map +2 -2
  208. package/cjs/{Field/utils → inputs/registry}/index.js +8 -7
  209. package/cjs/inputs/registry.js.map +7 -0
  210. package/cjs/lazy/index.js +12 -9
  211. package/cjs/lazy.js.map +2 -2
  212. package/cjs/registry/index.js +27 -15
  213. package/cjs/registry.js.map +2 -2
  214. package/cjs/types.js.map +1 -1
  215. package/cjs/utils/index.js +9 -0
  216. package/cjs/utils.js.map +2 -2
  217. package/cjs/validators/index.js +13 -12
  218. package/cjs/validators/index.js.map +2 -2
  219. package/cjs/validators/types.js.map +1 -1
  220. package/cjs/validators/utils/date/index.js +26 -3
  221. package/cjs/validators/utils/date.js.map +2 -2
  222. package/cjs/validators/utils/datetime/index.js +118 -24
  223. package/cjs/validators/utils/datetime.js.map +2 -2
  224. package/cjs/validators/utils/email/index.js +39 -0
  225. package/cjs/validators/utils/email.js.map +7 -0
  226. package/cjs/validators/utils/file.js.map +1 -1
  227. package/cjs/validators/utils/iban.js.map +1 -1
  228. package/cjs/validators/utils/image.js.map +1 -1
  229. package/cjs/validators/utils/index.js.map +1 -1
  230. package/cjs/validators/utils/int.js.map +1 -1
  231. package/cjs/validators/utils/number.js.map +1 -1
  232. package/cjs/validators/utils/otp.js.map +1 -1
  233. package/cjs/validators/utils/phone.js.map +1 -1
  234. package/cjs/validators/utils/postal_code.js.map +1 -1
  235. package/cjs/validators/utils/text_limit.js.map +1 -1
  236. package/hooks/useFieldFocusManager/index.js +116 -0
  237. package/hooks/useFieldFocusManager/package.json +6 -0
  238. package/hooks/useFieldFocusManager.d.ts +25 -0
  239. package/hooks/useFieldFocusManager.js.map +7 -0
  240. package/hooks/utils/index.js +73 -0
  241. package/{Field → hooks}/utils/package.json +1 -1
  242. package/hooks/utils.d.ts +18 -0
  243. package/hooks/utils.js.map +7 -0
  244. package/index.js +1 -1
  245. package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +2 -0
  246. package/inputs/AutoCompleteInput/__stories__/Default.d.ts +1 -1
  247. package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +1 -1
  248. package/inputs/AutoCompleteInput/index.d.ts +3 -3
  249. package/inputs/AutoCompleteInput/index.js +1 -3
  250. package/inputs/AutoCompleteInput/index.js.map +2 -2
  251. package/inputs/Checkboxes/Checkboxes.stories.d.ts +2 -0
  252. package/inputs/Checkboxes/__stories__/Conditional.d.ts +1 -1
  253. package/inputs/Checkboxes/__stories__/Default.d.ts +1 -1
  254. package/inputs/Checkboxes/__stories__/WithDivider.d.ts +1 -1
  255. package/inputs/Checkboxes/index.d.ts +5 -3
  256. package/inputs/Checkboxes/index.js +68 -62
  257. package/inputs/Checkboxes/index.js.map +2 -2
  258. package/inputs/DateInput/DateInput.stories.d.ts +6 -0
  259. package/inputs/DateInput/__stories__/Default.d.ts +1 -1
  260. package/inputs/DateInput/__stories__/WithDefaultValue.d.ts +3 -0
  261. package/inputs/DateInput/__stories__/WithInitialValue.d.ts +3 -0
  262. package/inputs/DateInput/__stories__/WithWrongDefaultValue.d.ts +3 -0
  263. package/inputs/DateInput/__stories__/WithWrongInitialValue.d.ts +3 -0
  264. package/inputs/DateInput/index.d.ts +2 -5
  265. package/inputs/DateInput/index.js +38 -18
  266. package/inputs/DateInput/index.js.map +2 -2
  267. package/inputs/DateTimeInput/DateTimeInput.stories.d.ts +10 -3
  268. package/inputs/DateTimeInput/__stories__/Default.d.ts +1 -1
  269. package/inputs/DateTimeInput/__stories__/WithDefaultValue.d.ts +3 -0
  270. package/inputs/DateTimeInput/__stories__/WithInitialValue.d.ts +3 -0
  271. package/inputs/DateTimeInput/__stories__/WithWrongDefaultValue.d.ts +3 -0
  272. package/inputs/DateTimeInput/__stories__/WithWrongInitialValue.d.ts +3 -0
  273. package/inputs/DateTimeInput/index.d.ts +2 -5
  274. package/inputs/DateTimeInput/index.js +66 -40
  275. package/inputs/DateTimeInput/index.js.map +2 -2
  276. package/inputs/FileInput/FileInput.stories.d.ts +2 -0
  277. package/inputs/FileInput/__stories__/Default.d.ts +1 -1
  278. package/inputs/FileInput/index.d.ts +8 -4
  279. package/inputs/FileInput/index.js +37 -29
  280. package/inputs/FileInput/index.js.map +2 -2
  281. package/inputs/ImageInput/ImageInput.stories.d.ts +4 -1
  282. package/inputs/ImageInput/__stories__/Default.d.ts +1 -1
  283. package/inputs/ImageInput/__stories__/MaxSize.d.ts +1 -1
  284. package/inputs/ImageInput/__stories__/WithInitialValues.d.ts +3 -0
  285. package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +1 -1
  286. package/inputs/ImageInput/__stories__/logo.d/index.js +1 -0
  287. package/inputs/ImageInput/__stories__/logo.d/package.json +6 -0
  288. package/inputs/ImageInput/__stories__/logo.d.js.map +7 -0
  289. package/inputs/ImageInput/index.d.ts +10 -2
  290. package/inputs/ImageInput/index.js +45 -14
  291. package/inputs/ImageInput/index.js.map +2 -2
  292. package/inputs/Input/Input.stories.d.ts +3 -0
  293. package/inputs/Input/__stories__/AFM.d.ts +1 -1
  294. package/inputs/Input/__stories__/Boolean.d.ts +1 -1
  295. package/inputs/Input/__stories__/Email.d.ts +3 -0
  296. package/inputs/Input/__stories__/IBAN.d.ts +1 -1
  297. package/inputs/Input/__stories__/Integer.d.ts +1 -1
  298. package/inputs/Input/__stories__/LandlineNumber.d.ts +1 -1
  299. package/inputs/Input/__stories__/MobilePhone.d.ts +1 -1
  300. package/inputs/Input/__stories__/PhoneNumber.d.ts +1 -1
  301. package/inputs/Input/__stories__/PostalCode.d.ts +1 -1
  302. package/inputs/Input/__stories__/String.d.ts +1 -1
  303. package/inputs/Input/__stories__/StringWithTrimValidation.d.ts +1 -1
  304. package/inputs/Input/__stories__/TextWithLimit.d.ts +1 -1
  305. package/inputs/Input/index.d.ts +3 -1
  306. package/inputs/Input/index.js +6 -4
  307. package/inputs/Input/index.js.map +2 -2
  308. package/inputs/Label/Label.stories.d.ts +2 -0
  309. package/inputs/Label/__stories__/Default.d.ts +1 -1
  310. package/inputs/Label/index.d.ts +1 -1
  311. package/inputs/Label/index.js.map +1 -1
  312. package/inputs/OtpInput/OtpInput.stories.d.ts +2 -0
  313. package/inputs/OtpInput/__stories__/Default.d.ts +1 -1
  314. package/inputs/OtpInput/index.d.ts +1 -5
  315. package/inputs/OtpInput/index.js +36 -31
  316. package/inputs/OtpInput/index.js.map +2 -2
  317. package/inputs/Radio/Radio.stories.d.ts +2 -0
  318. package/inputs/Radio/__stories__/Conditional.d.ts +1 -1
  319. package/inputs/Radio/__stories__/Default.d.ts +1 -1
  320. package/inputs/Radio/__stories__/WithDivider.d.ts +1 -1
  321. package/inputs/Radio/index.d.ts +6 -4
  322. package/inputs/Radio/index.js +7 -5
  323. package/inputs/Radio/index.js.map +3 -3
  324. package/inputs/Select/Select.stories.d.ts +2 -0
  325. package/inputs/Select/__stories__/Default.d.ts +1 -1
  326. package/inputs/Select/index.d.ts +4 -2
  327. package/inputs/Select/index.js +2 -2
  328. package/inputs/Select/index.js.map +2 -2
  329. package/{Field/utils → inputs/registry}/index.js +5 -4
  330. package/{locales/el → inputs/registry}/package.json +1 -1
  331. package/{Field/utils/index.d.ts → inputs/registry.d.ts} +2 -1
  332. package/inputs/registry.js.map +7 -0
  333. package/lazy/index.js +12 -9
  334. package/package.json +8 -8
  335. package/registry/index.js +27 -15
  336. package/src/Field/ErrorGroup.tsx +3 -3
  337. package/src/Field/FieldBase.tsx +16 -19
  338. package/src/Field/FieldBaseContainer.tsx +69 -51
  339. package/src/Field/FieldConditional.tsx +2 -2
  340. package/src/Field/index.tsx +18 -37
  341. package/src/Field/types.tsx +13 -14
  342. package/src/Field/utils/evaluateFieldWithConditions.ts +5 -2
  343. package/src/Field/utils/resolveField.ts +58 -0
  344. package/src/Field/utils/useField.ts +3 -1
  345. package/src/FieldArray/BaseFieldArray.tsx +97 -0
  346. package/src/FieldArray/FieldArray.stories.js +1 -0
  347. package/src/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.tsx +45 -0
  348. package/src/FieldArray/FormDialog/ArrayDisplay/ArrayDisplay.stories.js +14 -0
  349. package/src/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.tsx +337 -0
  350. package/src/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.tsx +15 -0
  351. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Cards.tsx +88 -0
  352. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Default.tsx +93 -0
  353. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnly.tsx +79 -0
  354. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnlyCards.tsx +75 -0
  355. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Sortable.tsx +93 -0
  356. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/SortableCards.tsx +88 -0
  357. package/src/FieldArray/FormDialog/ArrayDisplay/index.test.tsx +44 -0
  358. package/src/FieldArray/FormDialog/ArrayDisplay/index.tsx +67 -0
  359. package/src/FieldArray/FormDialog/ArrayEditModal.tsx +241 -0
  360. package/src/FieldArray/FormDialog/index.tsx +302 -0
  361. package/src/FieldArray/__stories__/CardsWithError.tsx +124 -0
  362. package/src/FieldArray/__stories__/Default.tsx +1 -1
  363. package/src/FieldArray/__stories__/WithExactLength.tsx +1 -1
  364. package/src/FieldArray/__stories__/WithModal.tsx +1 -1
  365. package/src/FieldArray/__tests__/fieldset-multiplicity.spec.tsx +271 -0
  366. package/src/FieldArray/__tests__/multiplicity-attachment.spec.tsx +280 -0
  367. package/src/FieldArray/__tests__/multiplicity-optional.spec.tsx +232 -0
  368. package/src/FieldArray/__tests__/multiplicity-required.spec.tsx +170 -0
  369. package/src/FieldArray/__tests__/nested-fieldset-multiplicity.spec.tsx +627 -0
  370. package/src/FieldArray/__tests__/preference-multiple-choice.spec.tsx +222 -0
  371. package/src/FieldArray/index.spec.tsx +355 -0
  372. package/src/FieldArray/index.test.tsx +4 -0
  373. package/src/FieldArray/index.tsx +73 -112
  374. package/src/FieldObject/index.tsx +9 -17
  375. package/src/Fieldset/FieldsetWithContext.tsx +1 -1
  376. package/src/Fieldset/index.tsx +1 -1
  377. package/src/Fieldset/types.tsx +2 -2
  378. package/src/FormBuilder/FormBuilder.stories.js +3 -0
  379. package/src/FormBuilder/__stories__/AutoErrorGrouping.tsx +1 -1
  380. package/src/FormBuilder/__stories__/Default.tsx +1 -1
  381. package/src/FormBuilder/__stories__/ErrorGrouping.tsx +1 -1
  382. package/src/FormBuilder/index.tsx +191 -149
  383. package/src/FormBuilder/scenarios.test.tsx +761 -2
  384. package/src/FormContext.tsx +7 -2
  385. package/src/MultiplicityField/MultiplicityField.stories.js +3 -0
  386. package/src/MultiplicityField/__stories__/Default.tsx +1 -1
  387. package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +2 -4
  388. package/src/MultiplicityField/__stories__/WithExactLength.tsx +1 -1
  389. package/src/MultiplicityField/__stories__/WithMaxLength.tsx +1 -1
  390. package/src/MultiplicityField/__stories__/WithMinAndMaxLength.tsx +1 -1
  391. package/src/MultiplicityField/__stories__/WithMinLength.tsx +1 -1
  392. package/src/MultiplicityField/add-objects.tsx +13 -22
  393. package/src/MultiplicityField/index.tsx +6 -3
  394. package/src/MultiplicityField/types.ts +6 -2
  395. package/src/Questions/Questions.stories.js +3 -0
  396. package/src/Questions/Questions.tsx +2 -2
  397. package/src/Questions/QuestionsContext.tsx +1 -1
  398. package/src/Questions/Step/Step.tsx +1 -1
  399. package/src/Questions/Step/StepArrayReview.tsx +2 -2
  400. package/src/Questions/Step/StepContext.tsx +1 -1
  401. package/src/Questions/Step/StepDescription.tsx +2 -1
  402. package/src/Questions/Step/StepForm.tsx +2 -2
  403. package/src/Questions/Step/StepQuote.tsx +2 -1
  404. package/src/Questions/Step/StepTitle.tsx +2 -1
  405. package/src/Questions/Step/getAddMoreFields.tsx +2 -2
  406. package/src/Questions/Step/types.tsx +1 -1
  407. package/src/Questions/__stories__/Default.tsx +1 -1
  408. package/src/Questions/getNextStep.tsx +1 -1
  409. package/src/Questions/types.tsx +1 -1
  410. package/src/hooks/__tests__/useFieldFocusManager.spec.tsx +1079 -0
  411. package/src/hooks/__tests__/utils.spec.ts +568 -0
  412. package/src/hooks/useFieldFocusManager.ts +162 -0
  413. package/src/hooks/utils.ts +122 -0
  414. package/src/inputs/AutoCompleteInput/AutoComplete.stories.js +3 -0
  415. package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +1 -1
  416. package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +1 -1
  417. package/src/inputs/AutoCompleteInput/index.tsx +4 -6
  418. package/src/inputs/Checkboxes/Checkboxes.stories.js +3 -0
  419. package/src/inputs/Checkboxes/__stories__/Conditional.tsx +1 -1
  420. package/src/inputs/Checkboxes/__stories__/Default.tsx +1 -1
  421. package/src/inputs/Checkboxes/__stories__/WithDivider.tsx +1 -1
  422. package/src/inputs/Checkboxes/index.tsx +98 -88
  423. package/src/inputs/DateInput/DateInput.stories.js +7 -0
  424. package/src/inputs/DateInput/__stories__/Default.tsx +1 -1
  425. package/src/inputs/DateInput/__stories__/WithDefaultValue.tsx +26 -0
  426. package/src/inputs/DateInput/__stories__/WithInitialValue.tsx +28 -0
  427. package/src/inputs/DateInput/__stories__/WithWrongDefaultValue.tsx +26 -0
  428. package/src/inputs/DateInput/__stories__/WithWrongInitialValue.tsx +28 -0
  429. package/src/inputs/DateInput/index.test.tsx +16 -0
  430. package/src/inputs/DateInput/index.tsx +50 -19
  431. package/src/inputs/DateTimeInput/DateTimeInput.stories.js +12 -6
  432. package/src/inputs/DateTimeInput/__stories__/Default.tsx +1 -1
  433. package/src/inputs/DateTimeInput/__stories__/WithDefaultValue.tsx +26 -0
  434. package/src/inputs/DateTimeInput/__stories__/WithInitialValue.tsx +28 -0
  435. package/src/inputs/DateTimeInput/__stories__/WithWrongDefaultValue.tsx +26 -0
  436. package/src/inputs/DateTimeInput/__stories__/WithWrongInitialValue.tsx +28 -0
  437. package/src/inputs/DateTimeInput/index.test.tsx +16 -0
  438. package/src/inputs/DateTimeInput/index.tsx +78 -41
  439. package/src/inputs/FileInput/FileInput.stories.js +3 -0
  440. package/src/inputs/FileInput/__stories__/Default.tsx +1 -1
  441. package/src/inputs/FileInput/index.tsx +68 -41
  442. package/src/inputs/ImageInput/ImageInput.stories.js +5 -1
  443. package/src/inputs/ImageInput/__stories__/Default.tsx +1 -1
  444. package/src/inputs/ImageInput/__stories__/MaxSize.tsx +3 -2
  445. package/src/inputs/ImageInput/__stories__/WithInitialValues.tsx +45 -0
  446. package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +1 -1
  447. package/src/inputs/ImageInput/__stories__/logo.d.ts +4 -0
  448. package/src/inputs/ImageInput/__stories__/logo.png +0 -0
  449. package/src/inputs/ImageInput/index.test.tsx +4 -0
  450. package/src/inputs/ImageInput/index.tsx +102 -50
  451. package/src/inputs/Input/Input.stories.js +4 -0
  452. package/src/inputs/Input/__stories__/AFM.tsx +1 -1
  453. package/src/inputs/Input/__stories__/Boolean.tsx +1 -1
  454. package/src/inputs/Input/__stories__/Email.tsx +23 -0
  455. package/src/inputs/Input/__stories__/IBAN.tsx +1 -1
  456. package/src/inputs/Input/__stories__/Integer.tsx +1 -1
  457. package/src/inputs/Input/__stories__/LandlineNumber.tsx +1 -1
  458. package/src/inputs/Input/__stories__/MobilePhone.tsx +1 -1
  459. package/src/inputs/Input/__stories__/PhoneNumber.tsx +1 -1
  460. package/src/inputs/Input/__stories__/PostalCode.tsx +1 -1
  461. package/src/inputs/Input/__stories__/String.tsx +1 -1
  462. package/src/inputs/Input/__stories__/StringWithTrimValidation.tsx +1 -1
  463. package/src/inputs/Input/__stories__/TextWithLimit.tsx +1 -1
  464. package/src/inputs/Input/index.test.tsx +8 -0
  465. package/src/inputs/Input/index.tsx +13 -8
  466. package/src/inputs/Label/Label.stories.js +3 -0
  467. package/src/inputs/Label/__stories__/Default.tsx +1 -1
  468. package/src/inputs/Label/index.tsx +1 -1
  469. package/src/inputs/OtpInput/OtpInput.stories.js +3 -0
  470. package/src/inputs/OtpInput/__stories__/Default.tsx +1 -1
  471. package/src/inputs/OtpInput/index.tsx +43 -34
  472. package/src/inputs/Radio/Radio.stories.js +3 -0
  473. package/src/inputs/Radio/__stories__/Conditional.tsx +1 -1
  474. package/src/inputs/Radio/__stories__/Default.tsx +1 -1
  475. package/src/inputs/Radio/__stories__/WithDivider.tsx +1 -1
  476. package/src/inputs/Radio/index.tsx +33 -22
  477. package/src/inputs/Select/Select.stories.js +3 -0
  478. package/src/inputs/Select/__stories__/Default.tsx +1 -1
  479. package/src/inputs/Select/index.tsx +6 -4
  480. package/src/{Field/utils/index.ts → inputs/registry.ts} +5 -2
  481. package/src/lazy.js +12 -9
  482. package/src/registry.js +27 -15
  483. package/src/types.tsx +13 -5
  484. package/src/utils.ts +14 -2
  485. package/src/validators/index.ts +28 -24
  486. package/src/validators/types.ts +1 -1
  487. package/src/validators/utils/date.ts +30 -6
  488. package/src/validators/utils/datetime.ts +123 -31
  489. package/src/validators/utils/email.ts +11 -0
  490. package/src/validators/utils/file.ts +2 -2
  491. package/src/validators/utils/iban.ts +2 -2
  492. package/src/validators/utils/image.ts +2 -2
  493. package/src/validators/utils/index.ts +2 -2
  494. package/src/validators/utils/int.ts +1 -1
  495. package/src/validators/utils/number.ts +1 -1
  496. package/src/validators/utils/otp.ts +2 -2
  497. package/src/validators/utils/phone.ts +2 -2
  498. package/src/validators/utils/postal_code.ts +2 -2
  499. package/src/validators/utils/text_limit.ts +2 -2
  500. package/types.d.ts +9 -4
  501. package/types.js.map +1 -1
  502. package/utils/index.js +8 -0
  503. package/utils.d.ts +2 -1
  504. package/utils.js.map +2 -2
  505. package/validators/index.d.ts +5 -5
  506. package/validators/index.js +13 -12
  507. package/validators/index.js.map +2 -2
  508. package/validators/types.d.ts +1 -1
  509. package/validators/utils/date/index.js +26 -3
  510. package/validators/utils/date.d.ts +3 -3
  511. package/validators/utils/date.js.map +2 -2
  512. package/validators/utils/datetime/index.js +118 -24
  513. package/validators/utils/datetime.d.ts +3 -3
  514. package/validators/utils/datetime.js.map +2 -2
  515. package/validators/utils/email/index.js +16 -0
  516. package/validators/utils/email/package.json +6 -0
  517. package/validators/utils/email.d.ts +5 -0
  518. package/validators/utils/email.js.map +7 -0
  519. package/validators/utils/file.d.ts +2 -2
  520. package/validators/utils/file.js.map +1 -1
  521. package/validators/utils/iban.d.ts +2 -2
  522. package/validators/utils/iban.js.map +1 -1
  523. package/validators/utils/image.d.ts +2 -2
  524. package/validators/utils/image.js.map +1 -1
  525. package/validators/utils/index.d.ts +2 -2
  526. package/validators/utils/index.js.map +1 -1
  527. package/validators/utils/int.d.ts +1 -1
  528. package/validators/utils/int.js.map +1 -1
  529. package/validators/utils/number.d.ts +1 -1
  530. package/validators/utils/number.js.map +1 -1
  531. package/validators/utils/otp.d.ts +2 -2
  532. package/validators/utils/otp.js.map +1 -1
  533. package/validators/utils/phone.d.ts +2 -2
  534. package/validators/utils/phone.js.map +1 -1
  535. package/validators/utils/postal_code.d.ts +2 -2
  536. package/validators/utils/postal_code.js.map +1 -1
  537. package/validators/utils/text_limit.d.ts +2 -2
  538. package/validators/utils/text_limit.js.map +1 -1
  539. package/Field/utils/calculateField/index.js +0 -27
  540. package/Field/utils/calculateField.d.ts +0 -2
  541. package/Field/utils/calculateField.js.map +0 -7
  542. package/Field/utils/index.js.map +0 -7
  543. package/FieldArray/FormDialog.d.ts +0 -67
  544. package/FieldArray/FormDialog.js.map +0 -7
  545. package/FormBuilder/index.test.d.ts +0 -1
  546. package/FormBuilder/interaction.test.d.ts +0 -1
  547. package/FormBuilder/scenarios.test.d.ts +0 -88
  548. package/MultiplicityField/index.test.d.ts +0 -1
  549. package/Questions/index.spec.d.ts +0 -1
  550. package/Questions/index.test.d.ts +0 -1
  551. package/cjs/Field/utils/calculateField/index.js +0 -50
  552. package/cjs/Field/utils/calculateField.js.map +0 -7
  553. package/cjs/Field/utils/index.js.map +0 -7
  554. package/cjs/FieldArray/FormDialog.js.map +0 -7
  555. package/cjs/inputs/Input/inputsInputScenarios/index.js +0 -439
  556. package/cjs/inputs/Input/inputsInputScenarios.js.map +0 -7
  557. package/cjs/inputs/inputsScenarios/index.js +0 -533
  558. package/cjs/inputs/inputsScenarios.js.map +0 -7
  559. package/cjs/locales/el.js.map +0 -7
  560. package/inputs/AutoCompleteInput/index.test.d.ts +0 -1
  561. package/inputs/Checkboxes/index.test.d.ts +0 -1
  562. package/inputs/DateInput/index.test.d.ts +0 -1
  563. package/inputs/DateTimeInput/index.test.d.ts +0 -1
  564. package/inputs/FileInput/index.test.d.ts +0 -1
  565. package/inputs/ImageInput/index.test.d.ts +0 -1
  566. package/inputs/Input/index.test.d.ts +0 -1
  567. package/inputs/Input/inputsInputScenarios/index.js +0 -406
  568. package/inputs/Input/inputsInputScenarios.d.ts +0 -57
  569. package/inputs/Input/inputsInputScenarios.js.map +0 -7
  570. package/inputs/Label/index.test.d.ts +0 -1
  571. package/inputs/OtpInput/index.test.d.ts +0 -1
  572. package/inputs/Radio/index.test.d.ts +0 -1
  573. package/inputs/Select/index.test.d.ts +0 -1
  574. package/inputs/inputsScenarios/index.js +0 -499
  575. package/inputs/inputsScenarios.d.ts +0 -296
  576. package/inputs/inputsScenarios.js.map +0 -7
  577. package/locales/el/index.js +0 -6
  578. package/locales/el.d.ts +0 -2
  579. package/locales/el.js.map +0 -7
  580. package/src/Field/utils/calculateField.ts +0 -49
  581. package/src/FieldArray/FormDialog.tsx +0 -574
  582. package/src/inputs/Input/inputsInputScenarios.ts +0 -404
  583. package/src/inputs/inputsScenarios.ts +0 -496
  584. package/src/locales/el.ts +0 -3
  585. /package/{FieldArray/index.test.d.ts → hooks/__tests__/utils.spec.d.ts} +0 -0
@@ -1,18 +1,19 @@
1
1
  import React from "react";
2
2
  import { useWatch } from "react-hook-form";
3
+ import { omit } from "@digigov/form/utils";
3
4
  import { TextArea } from "@digigov/ui/form/TextArea";
4
5
  import { TextInput } from "@digigov/ui/form/TextInput";
5
6
  import { useTranslation } from "@digigov/ui/i18n";
6
7
  import { Hint } from "@digigov/ui/typography/Hint";
7
8
  const TYPES_MAP = {
8
9
  string: "text",
10
+ password: "password",
9
11
  int: "text",
10
12
  text: "text",
11
13
  date: "date"
12
14
  };
13
15
  const Input = React.forwardRef(
14
16
  function WrappedInput({ name, control, type, extra, ...props }, ref) {
15
- delete props["Field"];
16
17
  let { multiline = false, rows, limit } = extra || {};
17
18
  const { className } = extra || {};
18
19
  multiline = multiline === true || type === "text";
@@ -32,6 +33,7 @@ const Input = React.forwardRef(
32
33
  remainingText += remainingChars > 0 ? ` ${t("form.info.text.remaining")}.` : ` ${t("form.info.text.too_many")}.`;
33
34
  return remainingText;
34
35
  };
36
+ const transformedProps = omit(props, ["Field", "resetField"]);
35
37
  if (multiline === true) {
36
38
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
37
39
  TextArea,
@@ -42,13 +44,13 @@ const Input = React.forwardRef(
42
44
  ref,
43
45
  id: name,
44
46
  ...{
45
- ...props,
47
+ ...transformedProps,
46
48
  reset: void 0,
47
49
  required: void 0,
48
50
  type: fieldType
49
51
  }
50
52
  }
51
- ), limit?.max && /* @__PURE__ */ React.createElement(Hint, { display: "flex" }, t("form.info.text.you_have"), /* @__PURE__ */ React.createElement(Hint, { fontWeight: "bold" }, "\xA0", `${Math.abs(getRemainingChars(currentValue, limit))}`, "\xA0"), constructRemainingText(currentValue, limit)));
53
+ ), limit?.max && /* @__PURE__ */ React.createElement(Hint, { display: "flex" }, t("form.info.text.you_have"), /* @__PURE__ */ React.createElement("strong", null, "\xA0", `${Math.abs(getRemainingChars(currentValue, limit))}`, "\xA0"), constructRemainingText(currentValue, limit)));
52
54
  } else {
53
55
  return /* @__PURE__ */ React.createElement(
54
56
  TextInput,
@@ -60,7 +62,7 @@ const Input = React.forwardRef(
60
62
  className,
61
63
  ref,
62
64
  ...{
63
- ...props,
65
+ ...transformedProps,
64
66
  reset: void 0,
65
67
  required: void 0
66
68
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/inputs/Input/index.tsx"],
4
- "sourcesContent": ["import React from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { UncontrolledFieldProps } from '@digigov/form/Field/types';\nimport { TextArea } from '@digigov/ui/form/TextArea';\nimport { TextInput } from '@digigov/ui/form/TextInput';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\n\nconst TYPES_MAP = {\n string: 'text',\n int: 'text',\n text: 'text',\n date: 'date',\n};\n\nexport interface InputProps\n extends Omit<UncontrolledFieldProps, 'extra' | 'Field'> {\n extra?: {\n fullWidth?: boolean;\n multiline?: boolean;\n className?: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n rows?: any;\n limit: {\n min?: number;\n max?: number;\n };\n };\n Field?: UncontrolledFieldProps['Field'];\n}\n\nexport const Input: React.ExoticComponent<InputProps> = React.forwardRef(\n function WrappedInput({ name, control, type, extra, ...props }, ref: never) {\n delete props['Field'];\n // eslint-disable-next-line prefer-const\n let { multiline = false, rows, limit } = extra || {};\n const { className } = extra || {};\n // if enforced to multiline use true. Derive from type otherwise.\n multiline = multiline === true || type === 'text';\n // use explicit rows value if set. Derive from multiline otherwise.\n rows = rows || (multiline ? 4 : 1);\n // translate dilosi type to HTML Input type\n const fieldType = TYPES_MAP[type || 'text'] || 'text';\n const { t } = useTranslation();\n const currentValue: string | '' = useWatch({ control, name });\n\n const getRemainingChars = (currentValue, limit) => {\n if (currentValue) {\n return limit?.max - currentValue.length;\n }\n return limit?.max;\n };\n\n const constructRemainingText = (currentValue, limit) => {\n const remainingChars = getRemainingChars(currentValue, limit);\n let remainingText =\n Math.abs(remainingChars) === 1\n ? t('form.info.text.character')\n : t('form.info.text.characters');\n remainingText +=\n remainingChars > 0\n ? ` ${t('form.info.text.remaining')}.`\n : ` ${t('form.info.text.too_many')}.`;\n return remainingText;\n };\n\n if (multiline === true) {\n return (\n <>\n <TextArea\n name={name}\n className={className}\n rows={rows}\n ref={ref}\n id={name}\n {...{\n ...props,\n reset: undefined,\n required: undefined,\n type: fieldType,\n }}\n />\n {limit?.max && (\n <Hint display={'flex'}>\n {t('form.info.text.you_have')}\n <Hint fontWeight=\"bold\">\n &nbsp;{`${Math.abs(getRemainingChars(currentValue, limit))}`}\n &nbsp;\n </Hint>\n {constructRemainingText(currentValue, limit)}\n </Hint>\n )}\n </>\n );\n } else {\n return (\n <TextInput\n name={name}\n id={name}\n type={fieldType}\n data-type={type}\n className={className}\n ref={ref}\n {...{\n ...props,\n reset: undefined,\n required: undefined,\n }}\n />\n );\n }\n }\n);\n\nexport default Input;\n"],
5
- "mappings": "AAAA,OAAO,WAAW;AAClB,SAAS,gBAAgB;AAEzB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,YAAY;AAErB,MAAM,YAAY;AAAA,EAChB,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AACR;AAkBO,MAAM,QAA2C,MAAM;AAAA,EAC5D,SAAS,aAAa,EAAE,MAAM,SAAS,MAAM,OAAO,GAAG,MAAM,GAAG,KAAY;AAC1E,WAAO,MAAM,OAAO;AAEpB,QAAI,EAAE,YAAY,OAAO,MAAM,MAAM,IAAI,SAAS,CAAC;AACnD,UAAM,EAAE,UAAU,IAAI,SAAS,CAAC;AAEhC,gBAAY,cAAc,QAAQ,SAAS;AAE3C,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;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;",
4
+ "sourcesContent": ["import React from 'react';\nimport type { UseFormReturn } from 'react-hook-form';\nimport { useWatch } from 'react-hook-form';\nimport type { UncontrolledFieldProps } from '@digigov/form/Field/types';\nimport { omit } from '@digigov/form/utils';\nimport { TextArea } from '@digigov/ui/form/TextArea';\nimport { TextInput } from '@digigov/ui/form/TextInput';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\n\nconst TYPES_MAP = {\n string: 'text',\n password: 'password',\n int: 'text',\n text: 'text',\n date: 'date',\n};\n\nexport interface InputProps\n extends Omit<UncontrolledFieldProps, 'extra' | 'Field'> {\n extra?: {\n fullWidth?: boolean;\n multiline?: boolean;\n className?: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n rows?: any;\n limit: {\n min?: number;\n max?: number;\n };\n };\n Field?: UncontrolledFieldProps['Field'];\n resetField: UseFormReturn['resetField'];\n}\n\nexport const Input: React.ExoticComponent<InputProps> = React.forwardRef(\n function WrappedInput({ name, control, type, extra, ...props }, ref: never) {\n // eslint-disable-next-line prefer-const\n let { multiline = false, rows, limit } = extra || {};\n const { className } = extra || {};\n // if enforced to multiline use true. Derive from type otherwise.\n multiline = multiline === true || type === 'text';\n // use explicit rows value if set. Derive from multiline otherwise.\n rows = rows || (multiline ? 4 : 1);\n // translate dilosi type to HTML Input type\n const fieldType = TYPES_MAP[type || 'text'] || 'text';\n const { t } = useTranslation();\n const currentValue: string | '' = useWatch({ control, name });\n\n const getRemainingChars = (currentValue, limit) => {\n if (currentValue) {\n return limit?.max - currentValue.length;\n }\n return limit?.max;\n };\n\n const constructRemainingText = (currentValue, limit) => {\n const remainingChars = getRemainingChars(currentValue, limit);\n let remainingText =\n Math.abs(remainingChars) === 1\n ? t('form.info.text.character')\n : t('form.info.text.characters');\n remainingText +=\n remainingChars > 0\n ? ` ${t('form.info.text.remaining')}.`\n : ` ${t('form.info.text.too_many')}.`;\n return remainingText;\n };\n\n const transformedProps = omit(props, ['Field', 'resetField']);\n\n if (multiline === true) {\n return (\n <>\n <TextArea\n name={name}\n className={className}\n rows={rows}\n ref={ref as React.RefObject<HTMLTextAreaElement>}\n id={name}\n {...{\n ...transformedProps,\n reset: undefined,\n required: undefined,\n type: fieldType,\n }}\n />\n {limit?.max && (\n <Hint display={'flex'}>\n {t('form.info.text.you_have')}\n <strong>\n &nbsp;{`${Math.abs(getRemainingChars(currentValue, limit))}`}\n &nbsp;\n </strong>\n {constructRemainingText(currentValue, limit)}\n </Hint>\n )}\n </>\n );\n } else {\n return (\n <TextInput\n name={name}\n id={name}\n type={fieldType}\n data-type={type}\n className={className}\n ref={ref as React.RefObject<HTMLInputElement>}\n {...{\n ...transformedProps,\n reset: undefined,\n required: undefined,\n }}\n />\n );\n }\n }\n);\n\nexport default Input;\n"],
5
+ "mappings": "AAAA,OAAO,WAAW;AAElB,SAAS,gBAAgB;AAEzB,SAAS,YAAY;AACrB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,YAAY;AAErB,MAAM,YAAY;AAAA,EAChB,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AACR;AAmBO,MAAM,QAA2C,MAAM;AAAA,EAC5D,SAAS,aAAa,EAAE,MAAM,SAAS,MAAM,OAAO,GAAG,MAAM,GAAG,KAAY;AAE1E,QAAI,EAAE,YAAY,OAAO,MAAM,MAAM,IAAI,SAAS,CAAC;AACnD,UAAM,EAAE,UAAU,IAAI,SAAS,CAAC;AAEhC,gBAAY,cAAc,QAAQ,SAAS;AAE3C,WAAO,SAAS,YAAY,IAAI;AAEhC,UAAM,YAAY,UAAU,QAAQ,MAAM,KAAK;AAC/C,UAAM,EAAE,EAAE,IAAI,eAAe;AAC7B,UAAM,eAA4B,SAAS,EAAE,SAAS,KAAK,CAAC;AAE5D,UAAM,oBAAoB,CAACA,eAAcC,WAAU;AACjD,UAAID,eAAc;AAChB,eAAOC,QAAO,MAAMD,cAAa;AAAA,MACnC;AACA,aAAOC,QAAO;AAAA,IAChB;AAEA,UAAM,yBAAyB,CAACD,eAAcC,WAAU;AACtD,YAAM,iBAAiB,kBAAkBD,eAAcC,MAAK;AAC5D,UAAI,gBACF,KAAK,IAAI,cAAc,MAAM,IACzB,EAAE,0BAA0B,IAC5B,EAAE,2BAA2B;AACnC,uBACE,iBAAiB,IACb,IAAI,EAAE,0BAA0B,CAAC,MACjC,IAAI,EAAE,yBAAyB,CAAC;AACtC,aAAO;AAAA,IACT;AAEA,UAAM,mBAAmB,KAAK,OAAO,CAAC,SAAS,YAAY,CAAC;AAE5D,QAAI,cAAc,MAAM;AACtB,aACE,0DACE;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,IAAI;AAAA,UACH,GAAG;AAAA,YACF,GAAG;AAAA,YACH,OAAO;AAAA,YACP,UAAU;AAAA,YACV,MAAM;AAAA,UACR;AAAA;AAAA,MACF,GACC,OAAO,OACN,oCAAC,QAAK,SAAS,UACZ,EAAE,yBAAyB,GAC5B,oCAAC,gBAAO,QACC,GAAG,KAAK,IAAI,kBAAkB,cAAc,KAAK,CAAC,CAAC,IAAG,MAE/D,GACC,uBAAuB,cAAc,KAAK,CAC7C,CAEJ;AAAA,IAEJ,OAAO;AACL,aACE;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,IAAI;AAAA,UACJ,MAAM;AAAA,UACN,aAAW;AAAA,UACX;AAAA,UACA;AAAA,UACC,GAAG;AAAA,YACF,GAAG;AAAA,YACH,OAAO;AAAA,YACP,UAAU;AAAA,UACZ;AAAA;AAAA,MACF;AAAA,IAEJ;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;",
6
6
  "names": ["currentValue", "limit"]
7
7
  }
@@ -1,6 +1,8 @@
1
1
  declare namespace _default {
2
2
  export let title: string;
3
3
  export { Label as component };
4
+ export let tags: string[];
5
+ export { doc as markdown };
4
6
  export let displayName: string;
5
7
  }
6
8
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
- export declare const Default: () => React.JSX.Element;
2
+ export declare const Default: (_: any) => React.JSX.Element;
3
3
  export default Default;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { FieldLabelProps } from '@digigov/form/types';
2
+ import type { FieldLabelProps } from '@digigov/form/types';
3
3
  export interface FieldOptionProps {
4
4
  label?: FieldLabelProps;
5
5
  value: string;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/inputs/Label/index.tsx"],
4
- "sourcesContent": ["import React from 'react';\nimport { FieldLabelProps } from '@digigov/form/types';\nimport { LabelTitle } from '@digigov/ui/form/LabelContainer';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\n\nexport interface FieldOptionProps {\n label?: FieldLabelProps;\n value: string;\n show?: string[];\n disabled?: boolean;\n selected?: () => React.ReactNode;\n divider?: string;\n}\n\nexport interface LabelProps {\n primary?: string;\n secondary?: string;\n className?: string;\n value?: string;\n label?: FieldLabelProps;\n}\n\nexport const Label: React.FC<LabelProps> = ({ className, label, value }) => {\n const { t } = useTranslation();\n if ((!label || (label && !label.primary && !label.secondary)) && !value) {\n return null;\n }\n return (\n <>\n <LabelTitle className={className} size=\"sm\">\n {(label && label.primary && t(label.primary)) || value}\n </LabelTitle>\n {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}\n </>\n );\n};\n\nexport default Label;\n"],
4
+ "sourcesContent": ["import React from 'react';\nimport type { FieldLabelProps } from '@digigov/form/types';\nimport { LabelTitle } from '@digigov/ui/form/LabelContainer';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\n\nexport interface FieldOptionProps {\n label?: FieldLabelProps;\n value: string;\n show?: string[];\n disabled?: boolean;\n selected?: () => React.ReactNode;\n divider?: string;\n}\n\nexport interface LabelProps {\n primary?: string;\n secondary?: string;\n className?: string;\n value?: string;\n label?: FieldLabelProps;\n}\n\nexport const Label: React.FC<LabelProps> = ({ className, label, value }) => {\n const { t } = useTranslation();\n if ((!label || (label && !label.primary && !label.secondary)) && !value) {\n return null;\n }\n return (\n <>\n <LabelTitle className={className} size=\"sm\">\n {(label && label.primary && t(label.primary)) || value}\n </LabelTitle>\n {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}\n </>\n );\n};\n\nexport default Label;\n"],
5
5
  "mappings": "AAAA,OAAO,WAAW;AAElB,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,YAAY;AAmBd,MAAM,QAA8B,CAAC,EAAE,WAAW,OAAO,MAAM,MAAM;AAC1E,QAAM,EAAE,EAAE,IAAI,eAAe;AAC7B,OAAK,CAAC,SAAU,SAAS,CAAC,MAAM,WAAW,CAAC,MAAM,cAAe,CAAC,OAAO;AACvE,WAAO;AAAA,EACT;AACA,SACE,0DACE,oCAAC,cAAW,WAAsB,MAAK,QACnC,SAAS,MAAM,WAAW,EAAE,MAAM,OAAO,KAAM,KACnD,GACC,SAAS,MAAM,aAAa,oCAAC,YAAM,EAAE,MAAM,SAAS,CAAE,CACzD;AAEJ;AAEA,IAAO,gBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,8 @@
1
1
  declare namespace _default {
2
2
  export let title: string;
3
3
  export { OtpInput as component };
4
+ export let tags: string[];
5
+ export { doc as markdown };
4
6
  export let displayName: string;
5
7
  }
6
8
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
- export declare const Default: () => React.JSX.Element;
2
+ export declare const Default: (_: any) => React.JSX.Element;
3
3
  export default Default;
@@ -8,9 +8,5 @@ export declare function useOtp(onChange: any, maxLength: any): {
8
8
  handleFocus: (e: React.FocusEvent<HTMLInputElement>) => void;
9
9
  handlePaste: (e: React.ClipboardEvent<HTMLInputElement>) => void;
10
10
  };
11
- export declare const OtpInput: ({ name, maxLength, ...props }: {
12
- [x: string]: any;
13
- name: any;
14
- maxLength?: number | undefined;
15
- }) => React.JSX.Element;
11
+ export declare const OtpInput: React.ForwardRefExoticComponent<Omit<Record<string, any>, "ref"> & React.RefAttributes<HTMLInputElement>>;
16
12
  export default OtpInput;
@@ -105,37 +105,42 @@ function useOtp(onChange, maxLength) {
105
105
  handlePaste
106
106
  };
107
107
  }
108
- const SingleCharacterInputPart = ({ ...props }) => {
109
- return /* @__PURE__ */ React.createElement(SingleCharacterInput, { ...props });
110
- };
111
- const OtpInput = ({ name, maxLength = 6, ...props }) => {
112
- const otp = useOtp(props.onChange, maxLength);
113
- return /* @__PURE__ */ React.createElement(SingleCharacterInputs, null, otp.otpValues.map((digit, idx) => /* @__PURE__ */ React.createElement(
114
- SingleCharacterInputPart,
115
- {
116
- name: `${name}-${idx}`,
117
- id: `${name}-${idx}`,
118
- type: "text",
119
- key: idx,
120
- autoComplete: "one-time-code",
121
- pattern: "\\d{1}",
122
- maxLength,
123
- value: digit,
124
- disabled: props.disabled,
125
- "aria-required": props["aria-required"],
126
- onChange: (e) => otp.handleOtpChange(e, idx),
127
- onInput: (e) => {
128
- if (e.target.value === digit) {
129
- otp.handleOtpChange(e, idx);
130
- }
131
- },
132
- onKeyDown: (e) => otp.handleKeyDown(e, idx),
133
- onFocus: otp.handleFocus,
134
- onPaste: otp.handlePaste,
135
- error: !digit ? props.error : false
136
- }
137
- )));
138
- };
108
+ const SingleCharacterInputPart = React.forwardRef(({ ...props }, ref) => {
109
+ return /* @__PURE__ */ React.createElement(SingleCharacterInput, { ...props, ref });
110
+ });
111
+ SingleCharacterInputPart.displayName = "SingleCharacterInputPart";
112
+ const OtpInput = React.forwardRef(
113
+ ({ name, maxLength = 6, ...props }, ref) => {
114
+ const otp = useOtp(props.onChange, maxLength);
115
+ return /* @__PURE__ */ React.createElement(SingleCharacterInputs, null, otp.otpValues.map((digit, idx) => /* @__PURE__ */ React.createElement(
116
+ SingleCharacterInputPart,
117
+ {
118
+ ref: idx === 0 ? ref : null,
119
+ name: `${name}-${idx}`,
120
+ id: `${name}-${idx}`,
121
+ type: "text",
122
+ key: idx,
123
+ autoComplete: "one-time-code",
124
+ pattern: "\\d{1}",
125
+ maxLength,
126
+ value: digit,
127
+ disabled: props.disabled,
128
+ "aria-required": props["aria-required"],
129
+ onChange: (e) => otp.handleOtpChange(e, idx),
130
+ onInput: (e) => {
131
+ if (e.target.value === digit) {
132
+ otp.handleOtpChange(e, idx);
133
+ }
134
+ },
135
+ onKeyDown: (e) => otp.handleKeyDown(e, idx),
136
+ onFocus: otp.handleFocus,
137
+ onPaste: otp.handlePaste,
138
+ error: !digit ? props.error : false
139
+ }
140
+ )));
141
+ }
142
+ );
143
+ OtpInput.displayName = "OtpInput";
139
144
  var OtpInput_default = OtpInput;
140
145
  export {
141
146
  OtpInput,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/inputs/OtpInput/index.tsx"],
4
- "sourcesContent": ["import React, { useState, useCallback } from 'react';\nimport SingleCharacterInputs, {\n SingleCharacterInput,\n} from '@digigov/ui/form/SingleCharacterInputs';\n\nexport const RE_DIGIT = new RegExp(/^\\d+$/);\nexport const REMOVE_SPACES = new RegExp(/\\s+/g);\n\nexport function useOtp(onChange, maxLength) {\n const [otpValues, setOtpValues] = useState(Array<string>(maxLength).fill(''));\n const handleChange = useCallback(\n (otp: string[]) => {\n setOtpValues(otp);\n const otpValue = otp.join('');\n onChange(otpValue);\n },\n [onChange]\n );\n\n const setOtp = (item: string, idx) => {\n const updatedOTPValues = [...otpValues];\n if (item.length === 1 || item.length === 0) {\n updatedOTPValues[idx] = item[0] || '';\n handleChange(updatedOTPValues);\n } else if (item.length === maxLength) {\n const valueArray = item.split('').slice(0, maxLength);\n handleChange(valueArray);\n }\n };\n\n const setSelectionRange = useCallback((target) => {\n return target.setSelectionRange(0, target.value.length);\n }, []);\n\n const focusToNextInput = useCallback((target: HTMLElement) => {\n const nextElement = target.nextElementSibling as HTMLInputElement | null;\n if (nextElement) {\n nextElement.focus();\n }\n }, []);\n\n const focusToPrevInput = useCallback((target: HTMLElement) => {\n const previousElement =\n target.previousElementSibling as HTMLInputElement | null;\n if (previousElement) {\n previousElement.focus();\n }\n }, []);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>, idx: number) => {\n const { key } = e;\n const target = e.target as HTMLInputElement;\n let targetValue = target.value;\n setSelectionRange(target);\n if (key === 'ArrowRight' || key === 'ArrowDown') {\n e.preventDefault();\n return focusToNextInput(target);\n }\n if (key === 'ArrowLeft' || key === 'ArrowUp') {\n e.preventDefault();\n return focusToPrevInput(target);\n }\n if (e.key === 'Backspace' || e.key === 'Delete') {\n if (targetValue !== '') {\n targetValue = '';\n } else {\n focusToPrevInput(target);\n }\n setOtp(targetValue, idx);\n return e.preventDefault();\n }\n },\n [setOtp, focusToPrevInput, focusToNextInput]\n );\n\n const handleFocus = useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n const { target } = e;\n setSelectionRange(target);\n },\n [setSelectionRange]\n );\n const handleOtpChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>, idx: number) => {\n const target = e.target;\n const targetValue = target.value;\n const isTargetValueDigit = RE_DIGIT.test(targetValue);\n // We want to pass the empty string when the value is deleted\n // emptry string replaces the deleted value\n if (isTargetValueDigit || targetValue === '') {\n setOtp(targetValue, idx);\n if (target.value.length > 1) {\n target.blur();\n }\n focusToNextInput(target);\n }\n },\n [setOtp, handleKeyDown, handleFocus]\n );\n\n const handlePaste = useCallback(\n (e: React.ClipboardEvent<HTMLInputElement>) => {\n e.preventDefault();\n const pastedData = e.clipboardData\n .getData('text/plain')\n .replace(REMOVE_SPACES, '');\n if (pastedData) {\n setOtp(pastedData, 0);\n }\n },\n []\n );\n return {\n otpValues,\n handleOtpChange,\n handleKeyDown,\n handleFocus,\n handlePaste,\n };\n}\n\nconst SingleCharacterInputPart = ({ ...props }) => {\n return <SingleCharacterInput {...props} />;\n};\n\nexport const OtpInput = ({ name, maxLength = 6, ...props }) => {\n const otp = useOtp(props.onChange, maxLength);\n return (\n <SingleCharacterInputs>\n {otp.otpValues.map((digit, idx) => (\n <SingleCharacterInputPart\n name={`${name}-${idx}`}\n id={`${name}-${idx}`}\n type=\"text\"\n key={idx}\n autoComplete=\"one-time-code\"\n pattern=\"\\d{1}\"\n maxLength={maxLength}\n value={digit}\n disabled={props.disabled}\n aria-required={props['aria-required']}\n onChange={(e) => otp.handleOtpChange(e, idx)}\n onInput={(e) => {\n if (e.target.value === digit) {\n otp.handleOtpChange(e, idx);\n }\n }}\n onKeyDown={(e) => otp.handleKeyDown(e, idx)}\n onFocus={otp.handleFocus}\n onPaste={otp.handlePaste}\n error={!digit ? props.error : false}\n />\n ))}\n </SingleCharacterInputs>\n );\n};\n\nexport default OtpInput;\n"],
5
- "mappings": "AAAA,OAAO,SAAS,UAAU,mBAAmB;AAC7C,OAAO;AAAA,EACL;AAAA,OACK;AAEA,MAAM,WAAW,IAAI,OAAO,OAAO;AACnC,MAAM,gBAAgB,IAAI,OAAO,MAAM;AAEvC,SAAS,OAAO,UAAU,WAAW;AAC1C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,MAAc,SAAS,EAAE,KAAK,EAAE,CAAC;AAC5E,QAAM,eAAe;AAAA,IACnB,CAAC,QAAkB;AACjB,mBAAa,GAAG;AAChB,YAAM,WAAW,IAAI,KAAK,EAAE;AAC5B,eAAS,QAAQ;AAAA,IACnB;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,QAAM,SAAS,CAAC,MAAc,QAAQ;AACpC,UAAM,mBAAmB,CAAC,GAAG,SAAS;AACtC,QAAI,KAAK,WAAW,KAAK,KAAK,WAAW,GAAG;AAC1C,uBAAiB,GAAG,IAAI,KAAK,CAAC,KAAK;AACnC,mBAAa,gBAAgB;AAAA,IAC/B,WAAW,KAAK,WAAW,WAAW;AACpC,YAAM,aAAa,KAAK,MAA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B,GAAG,GAAG;AAAA,MAC3C,SAAS,CAAC,MAAM;AACd,YAAI,EAAE,OAAO,UAAU,OAAO;AAC5B,cAAI,gBAAgB,GAAG,GAAG;AAAA,QAC5B;AAAA,MACF;AAAA,MACA,WAAW,CAAC,MAAM,IAAI,cAAc,GAAG,GAAG;AAAA,MAC1C,SAAS,IAAI;AAAA,MACb,SAAS,IAAI;AAAA,MACb,OAAO,CAAC,QAAQ,MAAM,QAAQ;AAAA;AAAA,EAChC,CACD,CACH;AAEJ;AAEA,IAAO,mBAAQ;",
4
+ "sourcesContent": ["import React, { useState, useCallback } from 'react';\nimport SingleCharacterInputs, {\n SingleCharacterInput,\n} from '@digigov/ui/form/SingleCharacterInputs';\n\nexport const RE_DIGIT = new RegExp(/^\\d+$/);\nexport const REMOVE_SPACES = new RegExp(/\\s+/g);\n\nexport function useOtp(onChange, maxLength) {\n const [otpValues, setOtpValues] = useState(Array<string>(maxLength).fill(''));\n const handleChange = useCallback(\n (otp: string[]) => {\n setOtpValues(otp);\n const otpValue = otp.join('');\n onChange(otpValue);\n },\n [onChange]\n );\n\n const setOtp = (item: string, idx) => {\n const updatedOTPValues = [...otpValues];\n if (item.length === 1 || item.length === 0) {\n updatedOTPValues[idx] = item[0] || '';\n handleChange(updatedOTPValues);\n } else if (item.length === maxLength) {\n const valueArray = item.split('').slice(0, maxLength);\n handleChange(valueArray);\n }\n };\n\n const setSelectionRange = useCallback((target) => {\n return target.setSelectionRange(0, target.value.length);\n }, []);\n\n const focusToNextInput = useCallback((target: HTMLElement) => {\n const nextElement = target.nextElementSibling as HTMLInputElement | null;\n if (nextElement) {\n nextElement.focus();\n }\n }, []);\n\n const focusToPrevInput = useCallback((target: HTMLElement) => {\n const previousElement =\n target.previousElementSibling as HTMLInputElement | null;\n if (previousElement) {\n previousElement.focus();\n }\n }, []);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>, idx: number) => {\n const { key } = e;\n const target = e.target as HTMLInputElement;\n let targetValue = target.value;\n setSelectionRange(target);\n if (key === 'ArrowRight' || key === 'ArrowDown') {\n e.preventDefault();\n return focusToNextInput(target);\n }\n if (key === 'ArrowLeft' || key === 'ArrowUp') {\n e.preventDefault();\n return focusToPrevInput(target);\n }\n if (e.key === 'Backspace' || e.key === 'Delete') {\n if (targetValue !== '') {\n targetValue = '';\n } else {\n focusToPrevInput(target);\n }\n setOtp(targetValue, idx);\n return e.preventDefault();\n }\n },\n [setOtp, focusToPrevInput, focusToNextInput]\n );\n\n const handleFocus = useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n const { target } = e;\n setSelectionRange(target);\n },\n [setSelectionRange]\n );\n const handleOtpChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>, idx: number) => {\n const target = e.target;\n const targetValue = target.value;\n const isTargetValueDigit = RE_DIGIT.test(targetValue);\n // We want to pass the empty string when the value is deleted\n // emptry string replaces the deleted value\n if (isTargetValueDigit || targetValue === '') {\n setOtp(targetValue, idx);\n if (target.value.length > 1) {\n target.blur();\n }\n focusToNextInput(target);\n }\n },\n [setOtp, handleKeyDown, handleFocus]\n );\n\n const handlePaste = useCallback(\n (e: React.ClipboardEvent<HTMLInputElement>) => {\n e.preventDefault();\n const pastedData = e.clipboardData\n .getData('text/plain')\n .replace(REMOVE_SPACES, '');\n if (pastedData) {\n setOtp(pastedData, 0);\n }\n },\n []\n );\n return {\n otpValues,\n handleOtpChange,\n handleKeyDown,\n handleFocus,\n handlePaste,\n };\n}\n\nconst SingleCharacterInputPart = React.forwardRef<\n HTMLInputElement,\n Record<string, any>\n>(({ ...props }, ref) => {\n return <SingleCharacterInput {...props} ref={ref} />;\n});\nSingleCharacterInputPart.displayName = 'SingleCharacterInputPart';\n\nexport const OtpInput = React.forwardRef<HTMLInputElement, Record<string, any>>(\n ({ name, maxLength = 6, ...props }, ref) => {\n const otp = useOtp(props.onChange, maxLength);\n return (\n <SingleCharacterInputs>\n {otp.otpValues.map((digit, idx) => (\n <SingleCharacterInputPart\n ref={idx === 0 ? ref : null}\n name={`${name}-${idx}`}\n id={`${name}-${idx}`}\n type=\"text\"\n key={idx}\n autoComplete=\"one-time-code\"\n pattern=\"\\d{1}\"\n maxLength={maxLength}\n value={digit}\n disabled={props.disabled}\n aria-required={props['aria-required']}\n onChange={(e) => otp.handleOtpChange(e, idx)}\n onInput={(e) => {\n if (e.target.value === digit) {\n otp.handleOtpChange(e, idx);\n }\n }}\n onKeyDown={(e) => otp.handleKeyDown(e, idx)}\n onFocus={otp.handleFocus}\n onPaste={otp.handlePaste}\n error={!digit ? props.error : false}\n />\n ))}\n </SingleCharacterInputs>\n );\n }\n);\n\nOtpInput.displayName = 'OtpInput';\n\nexport default OtpInput;\n"],
5
+ "mappings": "AAAA,OAAO,SAAS,UAAU,mBAAmB;AAC7C,OAAO;AAAA,EACL;AAAA,OACK;AAEA,MAAM,WAAW,IAAI,OAAO,OAAO;AACnC,MAAM,gBAAgB,IAAI,OAAO,MAAM;AAEvC,SAAS,OAAO,UAAU,WAAW;AAC1C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,MAAc,SAAS,EAAE,KAAK,EAAE,CAAC;AAC5E,QAAM,eAAe;AAAA,IACnB,CAAC,QAAkB;AACjB,mBAAa,GAAG;AAChB,YAAM,WAAW,IAAI,KAAK,EAAE;AAC5B,eAAS,QAAQ;AAAA,IACnB;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,QAAM,SAAS,CAAC,MAAc,QAAQ;AACpC,UAAM,mBAAmB,CAAC,GAAG,SAAS;AACtC,QAAI,KAAK,WAAW,KAAK,KAAK,WAAW,GAAG;AAC1C,uBAAiB,GAAG,IAAI,KAAK,CAAC,KAAK;AACnC,mBAAa,gBAAgB;AAAA,IAC/B,WAAW,KAAK,WAAW,WAAW;AACpC,YAAM,aAAa,KAAK,MAAM,EAAE,EAAE,MAAM,GAAG,SAAS;AACpD,mBAAa,UAAU;AAAA,IACzB;AAAA,EACF;AAEA,QAAM,oBAAoB,YAA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AAM,IAAI,gBAAgB,GAAG,GAAG;AAAA,QAC3C,SAAS,CAAC,MAAM;AACd,cAAI,EAAE,OAAO,UAAU,OAAO;AAC5B,gBAAI,gBAAgB,GAAG,GAAG;AAAA,UAC5B;AAAA,QACF;AAAA,QACA,WAAW,CAAC,MAAM,IAAI,cAAc,GAAG,GAAG;AAAA,QAC1C,SAAS,IAAI;AAAA,QACb,SAAS,IAAI;AAAA,QACb,OAAO,CAAC,QAAQ,MAAM,QAAQ;AAAA;AAAA,IAChC,CACD,CACH;AAAA,EAEJ;AACF;AAEA,SAAS,cAAc;AAEvB,IAAO,mBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,8 @@
1
1
  declare namespace _default {
2
2
  export let title: string;
3
3
  export { Radio as component };
4
+ export let tags: string[];
5
+ export { doc as markdown };
4
6
  export let displayName: string;
5
7
  }
6
8
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
- export declare const Conditional: () => React.JSX.Element;
2
+ export declare const Conditional: (_: any) => React.JSX.Element;
3
3
  export default Conditional;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
- export declare const Default: () => React.JSX.Element;
2
+ export declare const Default: (_: any) => React.JSX.Element;
3
3
  export default Default;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
- export declare const WithDivider: () => React.JSX.Element;
2
+ export declare const WithDivider: (_: any) => React.JSX.Element;
3
3
  export default WithDivider;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
- import { UncontrolledFieldProps } from '@digigov/form/Field/types';
3
- import { FieldOptionProps } from '@digigov/form/inputs/Label';
2
+ import type { UseFormReturn } from 'react-hook-form';
3
+ import type { UncontrolledFieldProps } from '@digigov/form/Field/types';
4
+ import type { FieldOptionProps } from '@digigov/form/inputs/Label';
4
5
  export interface RadioButtonsGroupProps extends Omit<UncontrolledFieldProps, 'extra'> {
5
6
  extra: {
6
7
  className?: string;
@@ -8,10 +9,11 @@ export interface RadioButtonsGroupProps extends Omit<UncontrolledFieldProps, 'ex
8
9
  dense?: boolean;
9
10
  };
10
11
  fieldComponent?: React.FC<Omit<UncontrolledFieldProps, 'register'>>;
12
+ resetField: UseFormReturn['resetField'];
11
13
  }
12
14
  export declare const RadioButtonsGroup: React.FC<RadioButtonsGroupProps>;
13
- export declare const ControlledRadioButtonsGroup: React.FC<RadioButtonsGroupProps & {
15
+ export declare const ControlledRadioButtonsGroup: React.ForwardRefExoticComponent<RadioButtonsGroupProps & {
14
16
  onChange: (e: any) => void;
15
17
  value: any;
16
- }>;
18
+ } & React.RefAttributes<HTMLInputElement>>;
17
19
  export default RadioButtonsGroup;
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { useWatch } from "react-hook-form";
3
+ import { omit } from "@digigov/form/utils";
3
4
  import {
4
5
  RadioContainer,
5
6
  RadioItem,
@@ -36,7 +37,7 @@ const RadioButtonsGroup = ({
36
37
  disabled: disabled || optionDisabled,
37
38
  ...option,
38
39
  ...{
39
- ...props,
40
+ ...omit(props, ["resetField"]),
40
41
  reset: void 0,
41
42
  required: void 0,
42
43
  error: void 0,
@@ -49,7 +50,7 @@ const RadioButtonsGroup = ({
49
50
  ), selected && selected(), currentValue === v && show && Field && /* @__PURE__ */ React.createElement(RadioConditional, null, show.map((fieldName) => /* @__PURE__ */ React.createElement(Field, { name: fieldName, key: fieldName }))))
50
51
  ));
51
52
  };
52
- const ControlledRadioButtonsGroup = ({
53
+ const ControlledRadioButtonsGroup = React.forwardRef(function ControlledRadioButtonsGroup2({
53
54
  name,
54
55
  extra: { options, className },
55
56
  disabled,
@@ -57,7 +58,7 @@ const ControlledRadioButtonsGroup = ({
57
58
  value,
58
59
  Field,
59
60
  ...props
60
- }) => {
61
+ }, ref) {
61
62
  const currentValue = value;
62
63
  const { t } = useTranslation();
63
64
  return /* @__PURE__ */ React.createElement(RadioContainer, { className, id: name }, options.map(
@@ -68,9 +69,10 @@ const ControlledRadioButtonsGroup = ({
68
69
  disabled: optionDisabled,
69
70
  selected,
70
71
  ...option
71
- }) => /* @__PURE__ */ React.createElement(React.Fragment, { key: `${name}.${v}` }, /* @__PURE__ */ React.createElement(
72
+ }, index) => /* @__PURE__ */ React.createElement(React.Fragment, { key: `${name}.${v}` }, /* @__PURE__ */ React.createElement(
72
73
  RadioItem,
73
74
  {
75
+ ref: index === 0 ? ref : void 0,
74
76
  onChange: (e) => {
75
77
  console.log(e);
76
78
  onChange(e);
@@ -94,7 +96,7 @@ const ControlledRadioButtonsGroup = ({
94
96
  label && label.secondary && /* @__PURE__ */ React.createElement(Hint, null, t(label.secondary))
95
97
  ), selected && selected(), currentValue === v && show && /* @__PURE__ */ React.createElement(RadioConditional, null, show.map((fieldName) => /* @__PURE__ */ React.createElement(Field, { name: fieldName, key: fieldName }))))
96
98
  ));
97
- };
99
+ });
98
100
  var Radio_default = RadioButtonsGroup;
99
101
  export {
100
102
  ControlledRadioButtonsGroup,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/inputs/Radio/index.tsx"],
4
- "sourcesContent": ["import React from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { UncontrolledFieldProps } from '@digigov/form/Field/types';\nimport { FieldOptionProps } from '@digigov/form/inputs/Label';\nimport {\n RadioContainer,\n RadioItem,\n RadioConditional,\n} from '@digigov/ui/form/RadioContainer';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\nimport { Base } from '@digigov/ui/utils/Base';\n\nexport interface RadioButtonsGroupProps\n extends Omit<UncontrolledFieldProps, 'extra'> {\n extra: {\n className?: string;\n options: FieldOptionProps[];\n dense?: boolean;\n };\n fieldComponent?: React.FC<Omit<UncontrolledFieldProps, 'register'>>;\n}\n\nexport const RadioButtonsGroup: React.FC<RadioButtonsGroupProps> = ({\n name,\n control,\n register,\n extra: { options, className },\n disabled,\n Field,\n ...props\n}) => {\n const currentValue: string | undefined = useWatch({ control, name });\n const { t } = useTranslation();\n return (\n <RadioContainer className={className} id={name}>\n {options.map(\n ({\n label,\n value: v,\n show,\n disabled: optionDisabled,\n selected,\n ...option\n }) => (\n <Base as=\"div\" key={`${name}.${v}`}>\n <RadioItem\n {...register(name)}\n id={`${name}.${v}`}\n value={v}\n disabled={disabled || optionDisabled}\n {...option}\n {...{\n ...props,\n reset: undefined,\n required: undefined,\n error: undefined,\n 'aria-describedby': undefined,\n type: 'radio',\n }}\n >\n {label && label.primary && (\n <Base as=\"span\">{t(label.primary) || v}</Base>\n )}\n {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}\n </RadioItem>\n {selected && selected()}\n {currentValue === v && show && Field && (\n <RadioConditional>\n {show.map((fieldName) => (\n <Field name={fieldName} key={fieldName} />\n ))}\n </RadioConditional>\n )}\n </Base>\n )\n )}\n </RadioContainer>\n );\n};\nexport const ControlledRadioButtonsGroup: React.FC<\n RadioButtonsGroupProps & { onChange: (e: any) => void; value: any }\n> = ({\n name,\n extra: { options, className },\n disabled,\n onChange,\n value,\n Field,\n ...props\n}) => {\n const currentValue: string | undefined = value;\n const { t } = useTranslation();\n return (\n <RadioContainer className={className} id={name}>\n {options.map(\n ({\n label,\n value: v,\n show,\n disabled: optionDisabled,\n selected,\n ...option\n }) => (\n <React.Fragment key={`${name}.${v}`}>\n <RadioItem\n onChange={(e) => {\n console.log(e);\n onChange(e);\n }}\n id={`${name}.${v}`}\n value={v}\n checked={currentValue === v}\n disabled={disabled || optionDisabled}\n {...option}\n {...{\n ...props,\n reset: undefined,\n required: undefined,\n error: undefined,\n Field: undefined,\n 'aria-describedby': undefined,\n type: 'radio',\n }}\n >\n {(label && label.primary && t(label.primary)) || v}\n {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}\n </RadioItem>\n {selected && selected()}\n {currentValue === v && show && (\n <RadioConditional>\n {show.map((fieldName) => (\n <Field name={fieldName} key={fieldName} />\n ))}\n </RadioConditional>\n )}\n </React.Fragment>\n )\n )}\n </RadioContainer>\n );\n};\n\nexport default RadioButtonsGroup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,CACF;AAEJ;AACO,MAAM,8BAET,CAAC;AAAA,EACH;AAAA,EACA,OAAO,EAAE,SAAS,UAAU;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,eAAmC;AACzC,QAAM,EAAE,EAAE,IAAI,eAAe;AAC7B,SACE,oCAAC,kBAAe,WAAsB,IAAI,QACvC,QAAQ;AAAA,IACP,CAAC;AAAA,MACC;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA,GAAG;AAAA,IACL,MACE,oCAAC,MAAM,UAAN,EAAe,KAAK,GAAG,IAAI,IAAI,CAAC,MAC/B;AAAA,MAAC;AAAA;AAAA,QACC,UAAU,CAAC,MAAM;AACf,kBAAQ,IAAI,CAAC;AACb,mBAAS,CAAC;AAAA,QACZ;AAAA,QACA,IAAI,GAAG,IAAI,IAAI,CAAC;AAAA,QAChB,OAAO;AAAA,QACP,SAAS,iBAAiB;AAAA,QAC1B,UAAU,YAAY;AAAA,QACrB,GAAG;AAAA,QACH,GAAG;AAAA,UACF,GAAG;AAAA,UACH,OAAO;AAAA,UACP,UAAU;AAAA,UACV,OAAO;AAAA,UACP,OAAO;AAAA,UACP,oBAAoB;AAAA,UACpB,MAAM;AAAA,QACR;AAAA;AAAA,MAEE,SAAS,MAAM,WAAW,EAAE,MAAM,OAAO,KAAM;AAAA,MAChD,SAAS,MAAM,aAAa,oCAAC,YAAM,EAAE,MAAM,SAAS,CAAE;AAAA,IACzD,GACC,YAAY,SAAS,GACrB,iBAAiB,KAAK,QACrB,oCAAC,wBACE,KAAK,IAAI,CAAC,cACT,oCAAC,SAAM,MAAM,WAAW,KAAK,WAAW,CACzC,CACH,CAEJ;AAAA,EAEJ,CACF;AAEJ;AAEA,IAAO,gBAAQ;",
6
- "names": []
4
+ "sourcesContent": ["import React from 'react';\nimport type { UseFormReturn } from 'react-hook-form';\nimport { useWatch } from 'react-hook-form';\nimport type { UncontrolledFieldProps } from '@digigov/form/Field/types';\nimport type { FieldOptionProps } from '@digigov/form/inputs/Label';\nimport { omit } from '@digigov/form/utils';\nimport {\n RadioContainer,\n RadioItem,\n RadioConditional,\n} from '@digigov/ui/form/RadioContainer';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\nimport { Base } from '@digigov/ui/utils/Base';\n\nexport interface RadioButtonsGroupProps\n extends Omit<UncontrolledFieldProps, 'extra'> {\n extra: {\n className?: string;\n options: FieldOptionProps[];\n dense?: boolean;\n };\n fieldComponent?: React.FC<Omit<UncontrolledFieldProps, 'register'>>;\n resetField: UseFormReturn['resetField'];\n}\n\nexport const RadioButtonsGroup: React.FC<RadioButtonsGroupProps> = ({\n name,\n control,\n register,\n extra: { options, className },\n disabled,\n Field,\n ...props\n}) => {\n const currentValue: string | undefined = useWatch({ control, name });\n const { t } = useTranslation();\n return (\n <RadioContainer className={className} id={name}>\n {options.map(\n ({\n label,\n value: v,\n show,\n disabled: optionDisabled,\n selected,\n ...option\n }) => (\n <Base as=\"div\" key={`${name}.${v}`}>\n <RadioItem\n {...register(name)}\n id={`${name}.${v}`}\n value={v}\n disabled={disabled || optionDisabled}\n {...option}\n {...{\n ...omit(props, ['resetField']),\n reset: undefined,\n required: undefined,\n error: undefined,\n 'aria-describedby': undefined,\n type: 'radio',\n }}\n >\n {label && label.primary && (\n <Base as=\"span\">{t(label.primary) || v}</Base>\n )}\n {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}\n </RadioItem>\n {selected && selected()}\n {currentValue === v && show && Field && (\n <RadioConditional>\n {show.map((fieldName) => (\n <Field name={fieldName} key={fieldName} />\n ))}\n </RadioConditional>\n )}\n </Base>\n )\n )}\n </RadioContainer>\n );\n};\nexport const ControlledRadioButtonsGroup = React.forwardRef<\n HTMLInputElement,\n RadioButtonsGroupProps & { onChange: (e: any) => void; value: any }\n>(function ControlledRadioButtonsGroup(\n {\n name,\n extra: { options, className },\n disabled,\n onChange,\n value,\n Field,\n ...props\n },\n ref\n) {\n const currentValue: string | undefined = value;\n const { t } = useTranslation();\n return (\n <RadioContainer className={className} id={name}>\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={`${name}.${v}`}>\n <RadioItem\n ref={index === 0 ? ref : undefined}\n onChange={(e) => {\n console.log(e);\n onChange(e);\n }}\n id={`${name}.${v}`}\n value={v}\n checked={currentValue === v}\n disabled={disabled || optionDisabled}\n {...option}\n {...{\n ...props,\n reset: undefined,\n required: undefined,\n error: undefined,\n Field: undefined,\n 'aria-describedby': undefined,\n type: 'radio',\n }}\n >\n {(label && label.primary && t(label.primary)) || v}\n {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}\n </RadioItem>\n {selected && selected()}\n {currentValue === v && show && (\n <RadioConditional>\n {show.map((fieldName) => (\n <Field name={fieldName} key={fieldName} />\n ))}\n </RadioConditional>\n )}\n </React.Fragment>\n )\n )}\n </RadioContainer>\n );\n});\n\nexport default RadioButtonsGroup;\n"],
5
+ "mappings": "AAAA,OAAO,WAAW;AAElB,SAAS,gBAAgB;AAGzB,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,YAAY;AACrB,SAAS,YAAY;AAad,MAAM,oBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO,EAAE,SAAS,UAAU;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,eAAmC,SAAS,EAAE,SAAS,KAAK,CAAC;AACnE,QAAM,EAAE,EAAE,IAAI,eAAe;AAC7B,SACE,oCAAC,kBAAe,WAAsB,IAAI,QACvC,QAAQ;AAAA,IACP,CAAC;AAAA,MACC;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA,UAAU;AAAA,MACV;AAAA,M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UAAU,IAAI,MAAM;AAAA,QACzB,UAAU,CAAC,MAAM;AACf,kBAAQ,IAAI,CAAC;AACb,mBAAS,CAAC;AAAA,QACZ;AAAA,QACA,IAAI,GAAG,IAAI,IAAI,CAAC;AAAA,QAChB,OAAO;AAAA,QACP,SAAS,iBAAiB;AAAA,QAC1B,UAAU,YAAY;AAAA,QACrB,GAAG;AAAA,QACH,GAAG;AAAA,UACF,GAAG;AAAA,UACH,OAAO;AAAA,UACP,UAAU;AAAA,UACV,OAAO;AAAA,UACP,OAAO;AAAA,UACP,oBAAoB;AAAA,UACpB,MAAM;AAAA,QACR;AAAA;AAAA,MAEE,SAAS,MAAM,WAAW,EAAE,MAAM,OAAO,KAAM;AAAA,MAChD,SAAS,MAAM,aAAa,oCAAC,YAAM,EAAE,MAAM,SAAS,CAAE;AAAA,IACzD,GACC,YAAY,SAAS,GACrB,iBAAiB,KAAK,QACrB,oCAAC,wBACE,KAAK,IAAI,CAAC,cACT,oCAAC,SAAM,MAAM,WAAW,KAAK,WAAW,CACzC,CACH,CAEJ;AAAA,EAEJ,CACF;AAEJ,CAAC;AAED,IAAO,gBAAQ;",
6
+ "names": ["ControlledRadioButtonsGroup"]
7
7
  }
@@ -1,6 +1,8 @@
1
1
  declare namespace _default {
2
2
  export let title: string;
3
3
  export { Select as component };
4
+ export let tags: string[];
5
+ export { doc as markdown };
4
6
  export let displayName: string;
5
7
  }
6
8
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
- export declare const Default: () => React.JSX.Element;
2
+ export declare const Default: (_: any) => React.JSX.Element;
3
3
  export default Default;
@@ -1,12 +1,14 @@
1
1
  import React from 'react';
2
- import { UncontrolledFieldProps } from '@digigov/form/Field/types';
3
- import { FieldOptionProps } from '@digigov/form/inputs/Label';
2
+ import type { UseFormReturn } from 'react-hook-form';
3
+ import type { UncontrolledFieldProps } from '@digigov/form/Field/types';
4
+ import type { FieldOptionProps } from '@digigov/form/inputs/Label';
4
5
  export interface SelectProps extends Omit<UncontrolledFieldProps, 'extra' | 'Field'> {
5
6
  extra: {
6
7
  className?: string;
7
8
  options: FieldOptionProps[];
8
9
  };
9
10
  Field?: UncontrolledFieldProps['Field'];
11
+ resetField: UseFormReturn['resetField'];
10
12
  }
11
13
  export declare const Select: React.ExoticComponent<SelectProps>;
12
14
  export default Select;
@@ -1,11 +1,11 @@
1
1
  import React from "react";
2
+ import { omit } from "@digigov/form/utils";
2
3
  import {
3
4
  SelectContainer,
4
5
  SelectOption
5
6
  } from "@digigov/ui/form/SelectContainer";
6
7
  const Select = React.forwardRef(
7
8
  function WrappedSelect({ name, extra: { options, className }, disabled, ...props }, ref) {
8
- delete props.Field;
9
9
  return /* @__PURE__ */ React.createElement(
10
10
  SelectContainer,
11
11
  {
@@ -15,7 +15,7 @@ const Select = React.forwardRef(
15
15
  id: name,
16
16
  disabled,
17
17
  ...{
18
- ...props,
18
+ ...omit(props, ["Field", "resetField"]),
19
19
  reset: void 0,
20
20
  error: void 0,
21
21
  required: void 0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/inputs/Select/index.tsx"],
4
- "sourcesContent": ["import React from 'react';\nimport { UncontrolledFieldProps } from '@digigov/form/Field/types';\nimport { FieldOptionProps } from '@digigov/form/inputs/Label';\nimport {\n SelectContainer,\n SelectOption,\n} from '@digigov/ui/form/SelectContainer';\n\nexport interface SelectProps\n extends Omit<UncontrolledFieldProps, 'extra' | 'Field'> {\n extra: {\n className?: string;\n options: FieldOptionProps[];\n };\n Field?: UncontrolledFieldProps['Field'];\n}\n\nexport const Select: React.ExoticComponent<SelectProps> = React.forwardRef(\n function WrappedSelect(\n { name, extra: { options, className }, disabled, ...props },\n ref: never\n ) {\n delete props.Field;\n return (\n <SelectContainer\n className={className}\n ref={ref}\n name={name}\n id={name}\n disabled={disabled}\n {...{\n ...props,\n reset: undefined,\n error: undefined,\n required: undefined,\n }}\n >\n {options.map(({ value, label }, index) => (\n <SelectOption key={index} value={value}>\n {label && label.primary ? label.primary : value}\n </SelectOption>\n ))}\n </SelectContainer>\n );\n }\n);\n\nexport default Select;\n"],
5
- "mappings": "AAAA,OAAO,WAAW;AAGlB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAWA,MAAM,SAA6C,MAAM;AAAA,EAC9D,SAAS,cACP,EAAE,MAAM,OAAO,EAAE,SAAS,UAAU,GAAG,UAAU,GAAG,MAAM,GAC1D,KACA;AACA,WAAO,MAAM;AACb,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA,IAAI;AAAA,QACJ;AAAA,QACC,GAAG;AAAA,UACF,GAAG;AAAA,UACH,OAAO;AAAA,UACP,OAAO;AAAA,UACP,UAAU;AAAA,QACZ;AAAA;AAAA,MAEC,QAAQ,IAAI,CAAC,EAAE,OAAO,MAAM,GAAG,UAC9B,oCAAC,gBAAa,KAAK,OAAO,SACvB,SAAS,MAAM,UAAU,MAAM,UAAU,KAC5C,CACD;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,IAAO,iBAAQ;",
4
+ "sourcesContent": ["import React from 'react';\nimport type { UseFormReturn } from 'react-hook-form';\nimport type { UncontrolledFieldProps } from '@digigov/form/Field/types';\nimport type { FieldOptionProps } from '@digigov/form/inputs/Label';\nimport { omit } from '@digigov/form/utils';\nimport {\n SelectContainer,\n SelectOption,\n} from '@digigov/ui/form/SelectContainer';\n\nexport interface SelectProps\n extends Omit<UncontrolledFieldProps, 'extra' | 'Field'> {\n extra: {\n className?: string;\n options: FieldOptionProps[];\n };\n Field?: UncontrolledFieldProps['Field'];\n resetField: UseFormReturn['resetField'];\n}\n\nexport const Select: React.ExoticComponent<SelectProps> = React.forwardRef(\n function WrappedSelect(\n { name, extra: { options, className }, disabled, ...props },\n ref: never\n ) {\n return (\n <SelectContainer\n className={className}\n ref={ref}\n name={name}\n id={name}\n disabled={disabled}\n {...{\n ...omit(props, ['Field', 'resetField']),\n reset: undefined,\n error: undefined,\n required: undefined,\n }}\n >\n {options.map(({ value, label }, index) => (\n <SelectOption key={index} value={value}>\n {label && label.primary ? label.primary : value}\n </SelectOption>\n ))}\n </SelectContainer>\n );\n }\n);\n\nexport default Select;\n"],
5
+ "mappings": "AAAA,OAAO,WAAW;AAIlB,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAYA,MAAM,SAA6C,MAAM;AAAA,EAC9D,SAAS,cACP,EAAE,MAAM,OAAO,EAAE,SAAS,UAAU,GAAG,UAAU,GAAG,MAAM,GAC1D,KACA;AACA,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA,IAAI;AAAA,QACJ;AAAA,QACC,GAAG;AAAA,UACF,GAAG,KAAK,OAAO,CAAC,SAAS,YAAY,CAAC;AAAA,UACtC,OAAO;AAAA,UACP,OAAO;AAAA,UACP,UAAU;AAAA,QACZ;AAAA;AAAA,MAEC,QAAQ,IAAI,CAAC,EAAE,OAAO,MAAM,GAAG,UAC9B,oCAAC,gBAAa,KAAK,OAAO,SACvB,SAAS,MAAM,UAAU,MAAM,UAAU,KAC5C,CACD;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,IAAO,iBAAQ;",
6
6
  "names": []
7
7
  }
@@ -17,12 +17,13 @@ const FIELD_COMPONENTS = {
17
17
  },
18
18
  file: {
19
19
  wrapper: "fieldset",
20
- component: FileInput,
21
- controlled: true
20
+ component: FileInput
21
+ // controlled: true,
22
22
  },
23
23
  image: {
24
24
  wrapper: "fieldset",
25
- component: ImageInput
25
+ component: ImageInput,
26
+ controlled: true
26
27
  },
27
28
  date: {
28
29
  wrapper: "fieldset",
@@ -82,4 +83,4 @@ export {
82
83
  CONTROLLED_FIELD_COMPONENTS,
83
84
  FIELD_COMPONENTS
84
85
  };
85
- //# sourceMappingURL=index.js.map
86
+ //# sourceMappingURL=registry.js.map
@@ -2,5 +2,5 @@
2
2
  "sideEffects": false,
3
3
  "module": "./index.js",
4
4
  "types": "./index.d.ts",
5
- "main": "../../cjs/locales/el/index.js"
5
+ "main": "../../cjs/inputs/registry/index.js"
6
6
  }
@@ -1,4 +1,5 @@
1
- import { FieldComponentRegistry } from '@digigov/form/Field/types';
1
+ import { type FieldComponentItem } from '@digigov/form/Field/types';
2
+ export type FieldComponentRegistry = Record<string, FieldComponentItem>;
2
3
  export declare const FIELD_COMPONENTS: FieldComponentRegistry;
3
4
  export declare const ALTERNATIVE_COMPONENTS: FieldComponentRegistry;
4
5
  export declare const CONTROLLED_FIELD_COMPONENTS: FieldComponentRegistry;
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/inputs/registry.ts"],
4
+ "sourcesContent": ["import { type FieldComponentItem } from '@digigov/form/Field/types';\nimport AutoCompleteInput from '@digigov/form/inputs/AutoCompleteInput';\nimport Checkboxes from '@digigov/form/inputs/Checkboxes';\nimport DateInput from '@digigov/form/inputs/DateInput';\nimport DateTimeInput from '@digigov/form/inputs/DateTimeInput';\nimport FileInput from '@digigov/form/inputs/FileInput';\nimport ImageInput from '@digigov/form/inputs/ImageInput';\nimport Input from '@digigov/form/inputs/Input';\nimport OtpInput from '@digigov/form/inputs/OtpInput';\nimport Radio, { ControlledRadioButtonsGroup } from '@digigov/form/inputs/Radio';\nimport Select from '@digigov/form/inputs/Select';\n\nexport type FieldComponentRegistry = Record<string, FieldComponentItem>;\n\nexport const FIELD_COMPONENTS: FieldComponentRegistry = {\n text: {\n component: Input,\n },\n string: {\n component: Input,\n },\n file: {\n wrapper: 'fieldset',\n component: FileInput,\n // controlled: true,\n },\n image: {\n wrapper: 'fieldset',\n component: ImageInput,\n controlled: true,\n },\n date: {\n wrapper: 'fieldset',\n controlled: true,\n component: DateInput,\n },\n datetime: {\n wrapper: 'fieldset',\n controlled: true,\n component: DateTimeInput,\n },\n otp: {\n wrapper: 'fieldset',\n controlled: true,\n component: OtpInput,\n },\n 'choice:multiple': {\n wrapper: 'fieldset',\n controlled: true,\n component: Checkboxes,\n },\n 'choice:single': {\n wrapper: 'fieldset',\n controlled: false,\n component: Radio,\n },\n};\n\nexport const ALTERNATIVE_COMPONENTS: FieldComponentRegistry = {\n Select: {\n component: Select,\n controlled: false,\n },\n AutoComplete: {\n component: AutoCompleteInput,\n controlled: true,\n wrapper: 'fieldset',\n },\n};\n\nexport const CONTROLLED_FIELD_COMPONENTS: FieldComponentRegistry = {\n ...FIELD_COMPONENTS,\n 'choice:single': {\n wrapper: 'fieldset',\n controlled: true,\n component: ControlledRadioButtonsGroup,\n },\n text: {\n component: Input,\n controlled: true,\n },\n string: {\n component: Input,\n controlled: true,\n },\n};\n"],
5
+ "mappings": "AACA,OAAO,uBAAuB;AAC9B,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,mBAAmB;AAC1B,OAAO,eAAe;AACtB,OAAO,gBAAgB;AACvB,OAAO,WAAW;AAClB,OAAO,cAAc;AACrB,OAAO,SAAS,mCAAmC;AACnD,OAAO,YAAY;AAIZ,MAAM,mBAA2C;AAAA,EACtD,MAAM;AAAA,IACJ,WAAW;AAAA,EACb;AAAA,EACA,QAAQ;AAAA,IACN,WAAW;AAAA,EACb;AAAA,EACA,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,WAAW;AAAA;AAAA,EAEb;AAAA,EACA,OAAO;AAAA,IACL,SAAS;AAAA,IACT,WAAW;AAAA,IACX,YAAY;AAAA,EACd;AAAA,EACA,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,UAAU;AAAA,IACR,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,KAAK;AAAA,IACH,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,mBAAmB;AAAA,IACjB,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,iBAAiB;AAAA,IACf,SAAS;AAA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