@flipdish/ui-library 0.50.0 → 0.52.0

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 (409) hide show
  1. package/README.md +17 -16
  2. package/dist/components/atoms/Checkbox/index.cjs +11 -3
  3. package/dist/components/atoms/Checkbox/index.cjs.map +1 -1
  4. package/dist/components/atoms/Checkbox/index.d.ts.map +1 -1
  5. package/dist/components/atoms/Checkbox/index.js +12 -4
  6. package/dist/components/atoms/Checkbox/index.js.map +1 -1
  7. package/dist/components/atoms/Slider/index.cjs +2 -2
  8. package/dist/components/atoms/Slider/index.cjs.map +1 -1
  9. package/dist/components/atoms/Slider/index.d.ts +3 -1
  10. package/dist/components/atoms/Slider/index.d.ts.map +1 -1
  11. package/dist/components/atoms/Slider/index.js +2 -2
  12. package/dist/components/atoms/Slider/index.js.map +1 -1
  13. package/dist/components/forms/Form/hooks/useForm.cjs +26 -0
  14. package/dist/components/forms/Form/hooks/useForm.cjs.map +1 -0
  15. package/dist/components/forms/Form/hooks/useForm.d.ts +13 -0
  16. package/dist/components/forms/Form/hooks/useForm.d.ts.map +1 -0
  17. package/dist/components/forms/Form/hooks/useForm.js +24 -0
  18. package/dist/components/forms/Form/hooks/useForm.js.map +1 -0
  19. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.cjs +28 -0
  20. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.cjs.map +1 -0
  21. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.d.ts +10 -0
  22. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.d.ts.map +1 -0
  23. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.js +26 -0
  24. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.js.map +1 -0
  25. package/dist/components/forms/Form/index.cjs +43 -0
  26. package/dist/components/forms/Form/index.cjs.map +1 -0
  27. package/dist/components/forms/Form/index.d.ts +30 -0
  28. package/dist/components/forms/Form/index.d.ts.map +1 -0
  29. package/dist/components/forms/Form/index.js +40 -0
  30. package/dist/components/forms/Form/index.js.map +1 -0
  31. package/dist/components/forms/Form/utilities/formSubmit.utils.cjs +23 -0
  32. package/dist/components/forms/Form/utilities/formSubmit.utils.cjs.map +1 -0
  33. package/dist/components/forms/Form/utilities/formSubmit.utils.d.ts +14 -0
  34. package/dist/components/forms/Form/utilities/formSubmit.utils.d.ts.map +1 -0
  35. package/dist/components/forms/Form/utilities/formSubmit.utils.js +21 -0
  36. package/dist/components/forms/Form/utilities/formSubmit.utils.js.map +1 -0
  37. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.cjs +39 -0
  38. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.cjs.map +1 -0
  39. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.d.ts +17 -0
  40. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.d.ts.map +1 -0
  41. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.js +37 -0
  42. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.js.map +1 -0
  43. package/dist/components/forms/FormFooter/hooks/useHasFieldError.cjs +26 -0
  44. package/dist/components/forms/FormFooter/hooks/useHasFieldError.cjs.map +1 -0
  45. package/dist/components/forms/FormFooter/hooks/useHasFieldError.d.ts +9 -0
  46. package/dist/components/forms/FormFooter/hooks/useHasFieldError.d.ts.map +1 -0
  47. package/dist/components/forms/FormFooter/hooks/useHasFieldError.js +24 -0
  48. package/dist/components/forms/FormFooter/hooks/useHasFieldError.js.map +1 -0
  49. package/dist/components/forms/FormFooter/index.cjs +41 -0
  50. package/dist/components/forms/FormFooter/index.cjs.map +1 -0
  51. package/dist/components/forms/FormFooter/index.d.ts +52 -0
  52. package/dist/components/forms/FormFooter/index.d.ts.map +1 -0
  53. package/dist/components/forms/FormFooter/index.js +39 -0
  54. package/dist/components/forms/FormFooter/index.js.map +1 -0
  55. package/dist/components/forms/FormFooter/utilities/formFooter.utils.cjs +21 -0
  56. package/dist/components/forms/FormFooter/utilities/formFooter.utils.cjs.map +1 -0
  57. package/dist/components/forms/FormFooter/utilities/formFooter.utils.d.ts +12 -0
  58. package/dist/components/forms/FormFooter/utilities/formFooter.utils.d.ts.map +1 -0
  59. package/dist/components/forms/FormFooter/utilities/formFooter.utils.js +19 -0
  60. package/dist/components/forms/FormFooter/utilities/formFooter.utils.js.map +1 -0
  61. package/dist/components/forms/FormSection/FormSection.styles.cjs +15 -0
  62. package/dist/components/forms/FormSection/FormSection.styles.cjs.map +1 -0
  63. package/dist/components/forms/FormSection/FormSection.styles.d.ts +9 -0
  64. package/dist/components/forms/FormSection/FormSection.styles.d.ts.map +1 -0
  65. package/dist/components/forms/FormSection/FormSection.styles.js +13 -0
  66. package/dist/components/forms/FormSection/FormSection.styles.js.map +1 -0
  67. package/dist/components/forms/FormSection/index.cjs +43 -0
  68. package/dist/components/forms/FormSection/index.cjs.map +1 -0
  69. package/dist/components/forms/FormSection/index.d.ts +41 -0
  70. package/dist/components/forms/FormSection/index.d.ts.map +1 -0
  71. package/dist/components/forms/FormSection/index.js +41 -0
  72. package/dist/components/forms/FormSection/index.js.map +1 -0
  73. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.cjs +28 -0
  74. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.cjs.map +1 -0
  75. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.d.ts +12 -0
  76. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.d.ts.map +1 -0
  77. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.js +26 -0
  78. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.js.map +1 -0
  79. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.cjs +68 -0
  80. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.cjs.map +1 -0
  81. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.d.ts +26 -0
  82. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.d.ts.map +1 -0
  83. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.js +66 -0
  84. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.js.map +1 -0
  85. package/dist/components/forms/__internal__/formField/hooks/useFormField.cjs +142 -0
  86. package/dist/components/forms/__internal__/formField/hooks/useFormField.cjs.map +1 -0
  87. package/dist/components/forms/__internal__/formField/hooks/useFormField.d.ts +35 -0
  88. package/dist/components/forms/__internal__/formField/hooks/useFormField.d.ts.map +1 -0
  89. package/dist/components/forms/__internal__/formField/hooks/useFormField.js +140 -0
  90. package/dist/components/forms/__internal__/formField/hooks/useFormField.js.map +1 -0
  91. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.cjs +12 -0
  92. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.cjs.map +1 -0
  93. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.d.ts +7 -0
  94. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.d.ts.map +1 -0
  95. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.js +10 -0
  96. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.js.map +1 -0
  97. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.cjs +39 -0
  98. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.cjs.map +1 -0
  99. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.d.ts +21 -0
  100. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.d.ts.map +1 -0
  101. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.js +37 -0
  102. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.js.map +1 -0
  103. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.cjs +40 -0
  104. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.cjs.map +1 -0
  105. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.d.ts +18 -0
  106. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.d.ts.map +1 -0
  107. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.js +37 -0
  108. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.js.map +1 -0
  109. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.cjs +21 -0
  110. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.cjs.map +1 -0
  111. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.d.ts +11 -0
  112. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.d.ts.map +1 -0
  113. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.js +19 -0
  114. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.js.map +1 -0
  115. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.cjs +128 -0
  116. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.cjs.map +1 -0
  117. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.d.ts +72 -0
  118. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.d.ts.map +1 -0
  119. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.js +121 -0
  120. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.js.map +1 -0
  121. package/dist/components/forms/fields/FormCheckbox/index.cjs +34 -0
  122. package/dist/components/forms/fields/FormCheckbox/index.cjs.map +1 -0
  123. package/dist/components/forms/fields/FormCheckbox/index.d.ts +16 -0
  124. package/dist/components/forms/fields/FormCheckbox/index.d.ts.map +1 -0
  125. package/dist/components/forms/fields/FormCheckbox/index.js +32 -0
  126. package/dist/components/forms/fields/FormCheckbox/index.js.map +1 -0
  127. package/dist/components/forms/fields/FormCheckboxGroup/index.cjs +33 -0
  128. package/dist/components/forms/fields/FormCheckboxGroup/index.cjs.map +1 -0
  129. package/dist/components/forms/fields/FormCheckboxGroup/index.d.ts +16 -0
  130. package/dist/components/forms/fields/FormCheckboxGroup/index.d.ts.map +1 -0
  131. package/dist/components/forms/fields/FormCheckboxGroup/index.js +31 -0
  132. package/dist/components/forms/fields/FormCheckboxGroup/index.js.map +1 -0
  133. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.cjs +26 -0
  134. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.cjs.map +1 -0
  135. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.d.ts +11 -0
  136. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.d.ts.map +1 -0
  137. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.js +24 -0
  138. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.js.map +1 -0
  139. package/dist/components/forms/fields/FormColorPicker/index.cjs +33 -0
  140. package/dist/components/forms/fields/FormColorPicker/index.cjs.map +1 -0
  141. package/dist/components/forms/fields/FormColorPicker/index.d.ts +21 -0
  142. package/dist/components/forms/fields/FormColorPicker/index.d.ts.map +1 -0
  143. package/dist/components/forms/fields/FormColorPicker/index.js +31 -0
  144. package/dist/components/forms/fields/FormColorPicker/index.js.map +1 -0
  145. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.cjs +20 -0
  146. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.cjs.map +1 -0
  147. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.d.ts +17 -0
  148. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.d.ts.map +1 -0
  149. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.js +18 -0
  150. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.js.map +1 -0
  151. package/dist/components/forms/fields/FormDatePicker/index.cjs +35 -0
  152. package/dist/components/forms/fields/FormDatePicker/index.cjs.map +1 -0
  153. package/dist/components/forms/fields/FormDatePicker/index.d.ts +17 -0
  154. package/dist/components/forms/fields/FormDatePicker/index.d.ts.map +1 -0
  155. package/dist/components/forms/fields/FormDatePicker/index.js +33 -0
  156. package/dist/components/forms/fields/FormDatePicker/index.js.map +1 -0
  157. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.cjs +23 -0
  158. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.cjs.map +1 -0
  159. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.d.ts +9 -0
  160. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.d.ts.map +1 -0
  161. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.js +21 -0
  162. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.js.map +1 -0
  163. package/dist/components/forms/fields/FormInput/index.cjs +27 -0
  164. package/dist/components/forms/fields/FormInput/index.cjs.map +1 -0
  165. package/dist/components/forms/fields/FormInput/index.d.ts +16 -0
  166. package/dist/components/forms/fields/FormInput/index.d.ts.map +1 -0
  167. package/dist/components/forms/fields/FormInput/index.js +25 -0
  168. package/dist/components/forms/fields/FormInput/index.js.map +1 -0
  169. package/dist/components/forms/fields/FormMultiSelect/index.cjs +44 -0
  170. package/dist/components/forms/fields/FormMultiSelect/index.cjs.map +1 -0
  171. package/dist/components/forms/fields/FormMultiSelect/index.d.ts +17 -0
  172. package/dist/components/forms/fields/FormMultiSelect/index.d.ts.map +1 -0
  173. package/dist/components/forms/fields/FormMultiSelect/index.js +42 -0
  174. package/dist/components/forms/fields/FormMultiSelect/index.js.map +1 -0
  175. package/dist/components/forms/fields/FormRadioCardGroup/index.cjs +36 -0
  176. package/dist/components/forms/fields/FormRadioCardGroup/index.cjs.map +1 -0
  177. package/dist/components/forms/fields/FormRadioCardGroup/index.d.ts +29 -0
  178. package/dist/components/forms/fields/FormRadioCardGroup/index.d.ts.map +1 -0
  179. package/dist/components/forms/fields/FormRadioCardGroup/index.js +34 -0
  180. package/dist/components/forms/fields/FormRadioCardGroup/index.js.map +1 -0
  181. package/dist/components/forms/fields/FormRadioGroup/index.cjs +31 -0
  182. package/dist/components/forms/fields/FormRadioGroup/index.cjs.map +1 -0
  183. package/dist/components/forms/fields/FormRadioGroup/index.d.ts +17 -0
  184. package/dist/components/forms/fields/FormRadioGroup/index.d.ts.map +1 -0
  185. package/dist/components/forms/fields/FormRadioGroup/index.js +29 -0
  186. package/dist/components/forms/fields/FormRadioGroup/index.js.map +1 -0
  187. package/dist/components/forms/fields/FormSelect/index.cjs +30 -0
  188. package/dist/components/forms/fields/FormSelect/index.cjs.map +1 -0
  189. package/dist/components/forms/fields/FormSelect/index.d.ts +16 -0
  190. package/dist/components/forms/fields/FormSelect/index.d.ts.map +1 -0
  191. package/dist/components/forms/fields/FormSelect/index.js +28 -0
  192. package/dist/components/forms/fields/FormSelect/index.js.map +1 -0
  193. package/dist/components/forms/fields/FormSlider/index.cjs +43 -0
  194. package/dist/components/forms/fields/FormSlider/index.cjs.map +1 -0
  195. package/dist/components/forms/fields/FormSlider/index.d.ts +17 -0
  196. package/dist/components/forms/fields/FormSlider/index.d.ts.map +1 -0
  197. package/dist/components/forms/fields/FormSlider/index.js +41 -0
  198. package/dist/components/forms/fields/FormSlider/index.js.map +1 -0
  199. package/dist/components/forms/fields/FormTextArea/index.cjs +27 -0
  200. package/dist/components/forms/fields/FormTextArea/index.cjs.map +1 -0
  201. package/dist/components/forms/fields/FormTextArea/index.d.ts +16 -0
  202. package/dist/components/forms/fields/FormTextArea/index.d.ts.map +1 -0
  203. package/dist/components/forms/fields/FormTextArea/index.js +25 -0
  204. package/dist/components/forms/fields/FormTextArea/index.js.map +1 -0
  205. package/dist/components/forms/fields/FormToggle/index.cjs +32 -0
  206. package/dist/components/forms/fields/FormToggle/index.cjs.map +1 -0
  207. package/dist/components/forms/fields/FormToggle/index.d.ts +16 -0
  208. package/dist/components/forms/fields/FormToggle/index.d.ts.map +1 -0
  209. package/dist/components/forms/fields/FormToggle/index.js +30 -0
  210. package/dist/components/forms/fields/FormToggle/index.js.map +1 -0
  211. package/dist/components/forms/validation/hooks/useSchemaResolver.cjs +39 -0
  212. package/dist/components/forms/validation/hooks/useSchemaResolver.cjs.map +1 -0
  213. package/dist/components/forms/validation/hooks/useSchemaResolver.d.ts +15 -0
  214. package/dist/components/forms/validation/hooks/useSchemaResolver.d.ts.map +1 -0
  215. package/dist/components/forms/validation/hooks/useSchemaResolver.js +37 -0
  216. package/dist/components/forms/validation/hooks/useSchemaResolver.js.map +1 -0
  217. package/dist/components/forms/validation/index.cjs +309 -0
  218. package/dist/components/forms/validation/index.cjs.map +1 -0
  219. package/dist/components/forms/validation/index.d.ts +214 -0
  220. package/dist/components/forms/validation/index.d.ts.map +1 -0
  221. package/dist/components/forms/validation/index.js +293 -0
  222. package/dist/components/forms/validation/index.js.map +1 -0
  223. package/dist/components/forms/validation/utilities/validation.utils.cjs +42 -0
  224. package/dist/components/forms/validation/utilities/validation.utils.cjs.map +1 -0
  225. package/dist/components/forms/validation/utilities/validation.utils.d.ts +20 -0
  226. package/dist/components/forms/validation/utilities/validation.utils.d.ts.map +1 -0
  227. package/dist/components/forms/validation/utilities/validation.utils.js +39 -0
  228. package/dist/components/forms/validation/utilities/validation.utils.js.map +1 -0
  229. package/dist/components/forms/validation/validation.types.d.ts +8 -0
  230. package/dist/components/forms/validation/validation.types.d.ts.map +1 -0
  231. package/dist/components/molecules/Alert/index.cjs +5 -25
  232. package/dist/components/molecules/Alert/index.cjs.map +1 -1
  233. package/dist/components/molecules/Alert/index.d.ts +9 -94
  234. package/dist/components/molecules/Alert/index.d.ts.map +1 -1
  235. package/dist/components/molecules/Alert/index.js +5 -25
  236. package/dist/components/molecules/Alert/index.js.map +1 -1
  237. package/dist/components/molecules/Alerts/components/Alert.cjs +39 -0
  238. package/dist/components/molecules/Alerts/components/Alert.cjs.map +1 -0
  239. package/dist/components/molecules/Alerts/components/Alert.d.ts +104 -0
  240. package/dist/components/molecules/Alerts/components/Alert.d.ts.map +1 -0
  241. package/dist/components/molecules/Alerts/components/Alert.js +36 -0
  242. package/dist/components/molecules/Alerts/components/Alert.js.map +1 -0
  243. package/dist/components/molecules/Alerts/components/SaveErrorAlert.cjs +26 -0
  244. package/dist/components/molecules/Alerts/components/SaveErrorAlert.cjs.map +1 -0
  245. package/dist/components/molecules/Alerts/components/SaveErrorAlert.d.ts +25 -0
  246. package/dist/components/molecules/Alerts/components/SaveErrorAlert.d.ts.map +1 -0
  247. package/dist/components/molecules/Alerts/components/SaveErrorAlert.js +24 -0
  248. package/dist/components/molecules/Alerts/components/SaveErrorAlert.js.map +1 -0
  249. package/dist/components/molecules/Alerts/hooks/useAlertActions.cjs +26 -0
  250. package/dist/components/molecules/Alerts/hooks/useAlertActions.cjs.map +1 -0
  251. package/dist/components/molecules/Alerts/hooks/useAlertActions.d.ts +13 -0
  252. package/dist/components/molecules/Alerts/hooks/useAlertActions.d.ts.map +1 -0
  253. package/dist/components/molecules/Alerts/hooks/useAlertActions.js +24 -0
  254. package/dist/components/molecules/Alerts/hooks/useAlertActions.js.map +1 -0
  255. package/dist/components/molecules/Alerts/index.cjs +11 -0
  256. package/dist/components/molecules/Alerts/index.cjs.map +1 -0
  257. package/dist/components/molecules/Alerts/index.d.ts +12 -0
  258. package/dist/components/molecules/Alerts/index.d.ts.map +1 -0
  259. package/dist/components/molecules/Alerts/index.js +3 -0
  260. package/dist/components/molecules/Alerts/index.js.map +1 -0
  261. package/dist/components/molecules/Modal/index.cjs +9 -39
  262. package/dist/components/molecules/Modal/index.cjs.map +1 -1
  263. package/dist/components/molecules/Modal/index.d.ts +13 -36
  264. package/dist/components/molecules/Modal/index.d.ts.map +1 -1
  265. package/dist/components/molecules/Modal/index.js +8 -38
  266. package/dist/components/molecules/Modal/index.js.map +1 -1
  267. package/dist/components/molecules/Modals/components/ConfirmationModal.cjs +32 -0
  268. package/dist/components/molecules/Modals/components/ConfirmationModal.cjs.map +1 -0
  269. package/dist/components/molecules/Modals/components/ConfirmationModal.d.ts +28 -0
  270. package/dist/components/molecules/Modals/components/ConfirmationModal.d.ts.map +1 -0
  271. package/dist/components/molecules/Modals/components/ConfirmationModal.js +30 -0
  272. package/dist/components/molecules/Modals/components/ConfirmationModal.js.map +1 -0
  273. package/dist/components/molecules/Modals/components/Modal.cjs +48 -0
  274. package/dist/components/molecules/Modals/components/Modal.cjs.map +1 -0
  275. package/dist/components/molecules/Modals/components/Modal.d.ts +37 -0
  276. package/dist/components/molecules/Modals/components/Modal.d.ts.map +1 -0
  277. package/dist/components/molecules/Modals/components/Modal.js +43 -0
  278. package/dist/components/molecules/Modals/components/Modal.js.map +1 -0
  279. package/dist/components/molecules/Modals/components/UnsavedChangesModal.cjs +30 -0
  280. package/dist/components/molecules/Modals/components/UnsavedChangesModal.cjs.map +1 -0
  281. package/dist/components/molecules/Modals/components/UnsavedChangesModal.d.ts +14 -0
  282. package/dist/components/molecules/Modals/components/UnsavedChangesModal.d.ts.map +1 -0
  283. package/dist/components/molecules/Modals/components/UnsavedChangesModal.js +28 -0
  284. package/dist/components/molecules/Modals/components/UnsavedChangesModal.js.map +1 -0
  285. package/dist/components/molecules/Modals/index.cjs +15 -0
  286. package/dist/components/molecules/Modals/index.cjs.map +1 -0
  287. package/dist/components/molecules/Modals/index.d.ts +14 -0
  288. package/dist/components/molecules/Modals/index.d.ts.map +1 -0
  289. package/dist/components/molecules/Modals/index.js +4 -0
  290. package/dist/components/molecules/Modals/index.js.map +1 -0
  291. package/dist/components/organisms/ColorPicker/components/ColorPickerField.cjs +13 -3
  292. package/dist/components/organisms/ColorPicker/components/ColorPickerField.cjs.map +1 -1
  293. package/dist/components/organisms/ColorPicker/components/ColorPickerField.d.ts +1 -1
  294. package/dist/components/organisms/ColorPicker/components/ColorPickerField.d.ts.map +1 -1
  295. package/dist/components/organisms/ColorPicker/components/ColorPickerField.js +13 -3
  296. package/dist/components/organisms/ColorPicker/components/ColorPickerField.js.map +1 -1
  297. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.cjs +2 -2
  298. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.cjs.map +1 -1
  299. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.d.ts +1 -0
  300. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.d.ts.map +1 -1
  301. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.js +2 -2
  302. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.js.map +1 -1
  303. package/dist/components/organisms/ColorPicker/hooks/useCssColorField.cjs +1 -1
  304. package/dist/components/organisms/ColorPicker/hooks/useCssColorField.js +1 -1
  305. package/dist/components/organisms/ColorPicker/index.cjs +1 -1
  306. package/dist/components/organisms/ColorPicker/index.d.ts.map +1 -1
  307. package/dist/components/organisms/ColorPicker/index.js +1 -1
  308. package/dist/components/organisms/ColorPicker/providers/ColorPicker.provider.d.ts +1 -1
  309. package/dist/components/organisms/ColorPicker/providers/ColorPicker.provider.d.ts.map +1 -1
  310. package/dist/components/organisms/ColorPicker/utilities/colorPicker.utils.cjs.map +1 -0
  311. package/dist/components/organisms/ColorPicker/utilities/colorPicker.utils.d.ts.map +1 -0
  312. package/dist/components/organisms/ColorPicker/utilities/colorPicker.utils.js.map +1 -0
  313. package/dist/components/organisms/DatePicker/components/CalendarOverlay.cjs +2 -2
  314. package/dist/components/organisms/DatePicker/components/CalendarOverlay.cjs.map +1 -1
  315. package/dist/components/organisms/DatePicker/components/CalendarOverlay.js +1 -1
  316. package/dist/components/organisms/DatePicker/components/DateRangePicker.cjs +4 -1
  317. package/dist/components/organisms/DatePicker/components/DateRangePicker.cjs.map +1 -1
  318. package/dist/components/organisms/DatePicker/components/DateRangePicker.d.ts.map +1 -1
  319. package/dist/components/organisms/DatePicker/components/DateRangePicker.js +5 -2
  320. package/dist/components/organisms/DatePicker/components/DateRangePicker.js.map +1 -1
  321. package/dist/components/organisms/GradientPicker/components/GradientStopRow.cjs +1 -1
  322. package/dist/components/organisms/GradientPicker/components/GradientStopRow.js +1 -1
  323. package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.cjs +48 -0
  324. package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.cjs.map +1 -0
  325. package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.d.ts +23 -0
  326. package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.d.ts.map +1 -0
  327. package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.js +45 -0
  328. package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.js.map +1 -0
  329. package/dist/hooks/useUnsavedChangesGuard/index.cjs +28 -0
  330. package/dist/hooks/useUnsavedChangesGuard/index.cjs.map +1 -0
  331. package/dist/hooks/useUnsavedChangesGuard/index.d.ts +18 -0
  332. package/dist/hooks/useUnsavedChangesGuard/index.d.ts.map +1 -0
  333. package/dist/hooks/useUnsavedChangesGuard/index.js +26 -0
  334. package/dist/hooks/useUnsavedChangesGuard/index.js.map +1 -0
  335. package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.cjs +8 -0
  336. package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.cjs.map +1 -0
  337. package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.d.ts +13 -0
  338. package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.d.ts.map +1 -0
  339. package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.js +6 -0
  340. package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.js.map +1 -0
  341. package/dist/localization/en.json.cjs +98 -0
  342. package/dist/localization/en.json.cjs.map +1 -0
  343. package/dist/localization/en.json.js +81 -0
  344. package/dist/localization/en.json.js.map +1 -0
  345. package/dist/native/components/forms/Form/index.d.ts +12 -0
  346. package/dist/native/components/forms/FormFooter/index.d.ts +12 -0
  347. package/dist/native/components/forms/FormSection/index.d.ts +12 -0
  348. package/dist/native/components/forms/fields/FormCheckbox/index.d.ts +12 -0
  349. package/dist/native/components/forms/fields/FormCheckboxGroup/index.d.ts +12 -0
  350. package/dist/native/components/forms/fields/FormColorPicker/index.d.ts +12 -0
  351. package/dist/native/components/forms/fields/FormDatePicker/index.d.ts +12 -0
  352. package/dist/native/components/forms/fields/FormInput/index.d.ts +12 -0
  353. package/dist/native/components/forms/fields/FormMultiSelect/index.d.ts +12 -0
  354. package/dist/native/components/forms/fields/FormRadioCardGroup/index.d.ts +12 -0
  355. package/dist/native/components/forms/fields/FormRadioGroup/index.d.ts +12 -0
  356. package/dist/native/components/forms/fields/FormSelect/index.d.ts +12 -0
  357. package/dist/native/components/forms/fields/FormSlider/index.d.ts +12 -0
  358. package/dist/native/components/forms/fields/FormTextArea/index.d.ts +12 -0
  359. package/dist/native/components/forms/fields/FormToggle/index.d.ts +12 -0
  360. package/dist/native/components/forms/validation/index.d.ts +12 -0
  361. package/dist/native/components/molecules/Alerts/index.d.ts +12 -0
  362. package/dist/native/components/molecules/Modals/index.d.ts +12 -0
  363. package/dist/native/hooks/useUnsavedChangesGuard/index.d.ts +12 -0
  364. package/dist/native/providers/UnsavedChangesGuardProvider/index.d.ts +12 -0
  365. package/dist/providers/UIProvider/hooks/useBrowserRouter.cjs +70 -0
  366. package/dist/providers/UIProvider/hooks/useBrowserRouter.cjs.map +1 -0
  367. package/dist/providers/UIProvider/hooks/useBrowserRouter.d.ts +12 -0
  368. package/dist/providers/UIProvider/hooks/useBrowserRouter.d.ts.map +1 -0
  369. package/dist/providers/UIProvider/hooks/useBrowserRouter.js +68 -0
  370. package/dist/providers/UIProvider/hooks/useBrowserRouter.js.map +1 -0
  371. package/dist/providers/UIProvider/index.cjs +19 -6
  372. package/dist/providers/UIProvider/index.cjs.map +1 -1
  373. package/dist/providers/UIProvider/index.d.ts +2 -2
  374. package/dist/providers/UIProvider/index.d.ts.map +1 -1
  375. package/dist/providers/UIProvider/index.js +20 -7
  376. package/dist/providers/UIProvider/index.js.map +1 -1
  377. package/dist/providers/UnsavedChangesGuardProvider/index.cjs +191 -0
  378. package/dist/providers/UnsavedChangesGuardProvider/index.cjs.map +1 -0
  379. package/dist/providers/UnsavedChangesGuardProvider/index.d.ts +10 -0
  380. package/dist/providers/UnsavedChangesGuardProvider/index.d.ts.map +1 -0
  381. package/dist/providers/UnsavedChangesGuardProvider/index.js +189 -0
  382. package/dist/providers/UnsavedChangesGuardProvider/index.js.map +1 -0
  383. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.cjs +7 -0
  384. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.cjs.map +1 -0
  385. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.d.ts +3 -0
  386. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.d.ts.map +1 -0
  387. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.js +5 -0
  388. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.js.map +1 -0
  389. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.types.d.ts +21 -0
  390. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.types.d.ts.map +1 -0
  391. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.cjs +97 -0
  392. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.cjs.map +1 -0
  393. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.d.ts +62 -0
  394. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.d.ts.map +1 -0
  395. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.js +88 -0
  396. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.js.map +1 -0
  397. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.cjs +74 -0
  398. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.cjs.map +1 -0
  399. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.d.ts +51 -0
  400. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.d.ts.map +1 -0
  401. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.js +68 -0
  402. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.js.map +1 -0
  403. package/package.json +41 -6
  404. package/dist/components/organisms/ColorPicker/colorPicker.utils.cjs.map +0 -1
  405. package/dist/components/organisms/ColorPicker/colorPicker.utils.d.ts.map +0 -1
  406. package/dist/components/organisms/ColorPicker/colorPicker.utils.js.map +0 -1
  407. /package/dist/components/organisms/ColorPicker/{colorPicker.utils.cjs → utilities/colorPicker.utils.cjs} +0 -0
  408. /package/dist/components/organisms/ColorPicker/{colorPicker.utils.d.ts → utilities/colorPicker.utils.d.ts} +0 -0
  409. /package/dist/components/organisms/ColorPicker/{colorPicker.utils.js → utilities/colorPicker.utils.js} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formColorPicker.utils.cjs","sources":["../../../../../../src/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAMA;;;;;;;;;AASG;AACI,MAAM,kBAAkB,GAAG,CAAC,UAA2B,EAAE,IAAY,EAAE,KAAgC,KAAqB;AACjI,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE;AAClC,IAAA,OAAO,UAAU,CAAC,IAAI,KAAK,IAAI,GAAG,UAAU,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;AACtE;;"}
@@ -0,0 +1,17 @@
1
+ /** The empty value a field was last seen to hold, kept with the field's name. */
2
+ export interface EmptyFieldValue {
3
+ name: string;
4
+ value: string | null | undefined;
5
+ }
6
+ /**
7
+ * Keeps track of the empty value a colour field itself uses, such as `undefined` for a field with no default or `''`
8
+ * for one an API sends empty. The picker reports an emptied field as `null`; writing the field's own empty value back
9
+ * lets a field the user put back as it was count as unchanged.
10
+ *
11
+ * @param remembered What was kept from the last render.
12
+ * @param name The field being rendered now. A change of name starts again: one field's empty value is never written to another.
13
+ * @param value The field's current value.
14
+ * @returns What to keep: the current value while the field is empty, else what was kept, or `null` for a field never seen empty.
15
+ */
16
+ export declare const rememberEmptyValue: (remembered: EmptyFieldValue, name: string, value: string | null | undefined) => EmptyFieldValue;
17
+ //# sourceMappingURL=formColorPicker.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formColorPicker.utils.d.ts","sourceRoot":"","sources":["../../../../../../src/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAClC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAI,YAAY,eAAe,EAAE,MAAM,MAAM,EAAE,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,eAGhH,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Keeps track of the empty value a colour field itself uses, such as `undefined` for a field with no default or `''`
3
+ * for one an API sends empty. The picker reports an emptied field as `null`; writing the field's own empty value back
4
+ * lets a field the user put back as it was count as unchanged.
5
+ *
6
+ * @param remembered What was kept from the last render.
7
+ * @param name The field being rendered now. A change of name starts again: one field's empty value is never written to another.
8
+ * @param value The field's current value.
9
+ * @returns What to keep: the current value while the field is empty, else what was kept, or `null` for a field never seen empty.
10
+ */
11
+ const rememberEmptyValue = (remembered, name, value) => {
12
+ if (!value)
13
+ return { name, value };
14
+ return remembered.name === name ? remembered : { name, value: null };
15
+ };
16
+
17
+ export { rememberEmptyValue };
18
+ //# sourceMappingURL=formColorPicker.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formColorPicker.utils.js","sources":["../../../../../../src/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAMA;;;;;;;;;AASG;AACI,MAAM,kBAAkB,GAAG,CAAC,UAA2B,EAAE,IAAY,EAAE,KAAgC,KAAqB;AACjI,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE;AAClC,IAAA,OAAO,UAAU,CAAC,IAAI,KAAK,IAAI,GAAG,UAAU,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;AACtE;;"}
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var DatePicker = require('@flipdish/ui-library/components/organisms/DatePicker');
5
+ var React = require('react');
6
+ var useFocusTarget = require('../../__internal__/formField/hooks/useFocusTarget.cjs');
7
+ var useFormField = require('../../__internal__/formField/hooks/useFormField.cjs');
8
+ var formDatePicker_utils = require('./utilities/formDatePicker.utils.cjs');
9
+
10
+ /**
11
+ * A `DatePicker` bound to a react-hook-form field: pressing Apply writes the date to the form as an ISO string
12
+ * (`YYYY-MM-DD`) and validates it at once, and the field's error shows in place of `hint`. Use it when the user picks
13
+ * a single date in a react-hook-form form.
14
+ *
15
+ * @summary date picker bound to a react-hook-form field
16
+ */
17
+ const FormDatePicker = ({ name, revalidates, hint, ...datePickerProps }) => {
18
+ const { value, ref, onCommit, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField.useFormField(name, revalidates);
19
+ // An unset, empty or unreadable field is no date; `null` keeps the picker controlled, and a stable date keeps its draft intact.
20
+ const date = React.useMemo(() => formDatePicker_utils.toCalendarDate(value), [value]);
21
+ // `DatePicker` reports a change only when Apply is pressed, so the draft the user is browsing never reaches the form.
22
+ const handleChange = (next) => onCommit(next ? next.toString() : null);
23
+ // `DatePicker`'s ref is its root div; the trigger is the only button in it, the calendar being portalled.
24
+ const focusRef = useFocusTarget.useFocusTarget(ref, 'button');
25
+ return (jsxRuntime.jsx(DatePicker.DatePicker
26
+ // The form's schema validates; the browser's own `required` check would block the submit before it runs.
27
+ , {
28
+ // The form's schema validates; the browser's own `required` check would block the submit before it runs.
29
+ validationBehavior: "aria", ...datePickerProps, ref: focusRef, name: name, value: date, onChange: handleChange, onBlur: onBlur, isInvalid: isInvalid, hint: errorMessage ?? hint,
30
+ // Disabled while the form submits: read-only would disable the trigger all the same, without looking it.
31
+ isDisabled: datePickerProps.isDisabled || isDisabled || isLocked }));
32
+ };
33
+
34
+ exports.FormDatePicker = FormDatePicker;
35
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../../../../src/components/forms/fields/FormDatePicker/index.tsx"],"sourcesContent":[null],"names":["useFormField","useMemo","toCalendarDate","useFocusTarget","_jsx","DatePicker"],"mappings":";;;;;;;;;AAkBA;;;;;;AAMG;AACI,MAAM,cAAc,GAAG,CAA4C,EACxE,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,GAAG,eAAe,EACW,KAAI;IACjC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAGA,yBAAY,CAAyB,IAAI,EAAE,WAAW,CAAC;;AAE/I,IAAA,MAAM,IAAI,GAAGC,aAAO,CAAC,MAAMC,mCAAc,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;;IAE1D,MAAM,YAAY,GAAG,CAAC,IAAsB,KAAK,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC;;IAGxF,MAAM,QAAQ,GAAGC,6BAAc,CAAC,GAAG,EAAE,QAAQ,CAAC;IAE9C,QACEC,eAACC;;;;AAEC,QAAA,kBAAkB,EAAC,MAAM,EAAA,GACrB,eAAe,EACnB,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,YAAY,IAAI,IAAI;;QAE1B,UAAU,EAAE,eAAe,CAAC,UAAU,IAAI,UAAU,IAAI,QAAQ,EAAA,CAChE;AAEN;;"}
@@ -0,0 +1,17 @@
1
+ import { type DatePickerProps } from '@flipdish/ui-library/components/organisms/DatePicker';
2
+ import type { FieldPath, FieldValues } from 'react-hook-form';
3
+ export interface FormDatePickerProps<TValues extends FieldValues = FieldValues> extends Omit<DatePickerProps, 'name' | 'value' | 'defaultValue' | 'onChange' | 'onBlur' | 'isInvalid' | 'ref'> {
4
+ /** The field's path in the form values, such as `deliveryDate` or `promotion.endDate`. */
5
+ name: FieldPath<TValues>;
6
+ /** Other fields whose rule reads this one, such as a postcode that depends on this country; they re-validate when this changes. */
7
+ revalidates?: FieldPath<TValues> | FieldPath<TValues>[];
8
+ }
9
+ /**
10
+ * A `DatePicker` bound to a react-hook-form field: pressing Apply writes the date to the form as an ISO string
11
+ * (`YYYY-MM-DD`) and validates it at once, and the field's error shows in place of `hint`. Use it when the user picks
12
+ * a single date in a react-hook-form form.
13
+ *
14
+ * @summary date picker bound to a react-hook-form field
15
+ */
16
+ export declare const FormDatePicker: <TValues extends FieldValues = FieldValues>({ name, revalidates, hint, ...datePickerProps }: FormDatePickerProps<TValues>) => import("react").JSX.Element;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/fields/FormDatePicker/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,sDAAsD,CAAC;AAGxG,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAK9D,MAAM,WAAW,mBAAmB,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,CAC5E,SAAQ,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,WAAW,GAAG,KAAK,CAAC;IAC9G,0FAA0F;IAC1F,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACzB,mIAAmI;IACnI,WAAW,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;CACzD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,SAAS,WAAW,GAAG,WAAW,EAAE,iDAKvE,mBAAmB,CAAC,OAAO,CAAC,gCA0B9B,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { DatePicker } from '@flipdish/ui-library/components/organisms/DatePicker';
3
+ import { useMemo } from 'react';
4
+ import { useFocusTarget } from '../../__internal__/formField/hooks/useFocusTarget.js';
5
+ import { useFormField } from '../../__internal__/formField/hooks/useFormField.js';
6
+ import { toCalendarDate } from './utilities/formDatePicker.utils.js';
7
+
8
+ /**
9
+ * A `DatePicker` bound to a react-hook-form field: pressing Apply writes the date to the form as an ISO string
10
+ * (`YYYY-MM-DD`) and validates it at once, and the field's error shows in place of `hint`. Use it when the user picks
11
+ * a single date in a react-hook-form form.
12
+ *
13
+ * @summary date picker bound to a react-hook-form field
14
+ */
15
+ const FormDatePicker = ({ name, revalidates, hint, ...datePickerProps }) => {
16
+ const { value, ref, onCommit, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField(name, revalidates);
17
+ // An unset, empty or unreadable field is no date; `null` keeps the picker controlled, and a stable date keeps its draft intact.
18
+ const date = useMemo(() => toCalendarDate(value), [value]);
19
+ // `DatePicker` reports a change only when Apply is pressed, so the draft the user is browsing never reaches the form.
20
+ const handleChange = (next) => onCommit(next ? next.toString() : null);
21
+ // `DatePicker`'s ref is its root div; the trigger is the only button in it, the calendar being portalled.
22
+ const focusRef = useFocusTarget(ref, 'button');
23
+ return (jsx(DatePicker
24
+ // The form's schema validates; the browser's own `required` check would block the submit before it runs.
25
+ , {
26
+ // The form's schema validates; the browser's own `required` check would block the submit before it runs.
27
+ validationBehavior: "aria", ...datePickerProps, ref: focusRef, name: name, value: date, onChange: handleChange, onBlur: onBlur, isInvalid: isInvalid, hint: errorMessage ?? hint,
28
+ // Disabled while the form submits: read-only would disable the trigger all the same, without looking it.
29
+ isDisabled: datePickerProps.isDisabled || isDisabled || isLocked }));
30
+ };
31
+
32
+ export { FormDatePicker };
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/components/forms/fields/FormDatePicker/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;AAkBA;;;;;;AAMG;AACI,MAAM,cAAc,GAAG,CAA4C,EACxE,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,GAAG,eAAe,EACW,KAAI;IACjC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,YAAY,CAAyB,IAAI,EAAE,WAAW,CAAC;;AAE/I,IAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;;IAE1D,MAAM,YAAY,GAAG,CAAC,IAAsB,KAAK,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC;;IAGxF,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,EAAE,QAAQ,CAAC;IAE9C,QACEA,IAAC;;;;AAEC,QAAA,kBAAkB,EAAC,MAAM,EAAA,GACrB,eAAe,EACnB,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,YAAY,IAAI,IAAI;;QAE1B,UAAU,EAAE,eAAe,CAAC,UAAU,IAAI,UAAU,IAAI,QAAQ,EAAA,CAChE;AAEN;;"}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var date = require('@internationalized/date');
4
+
5
+ /**
6
+ * Reads a form value as a calendar date without throwing, since a default value may come from an API in another shape.
7
+ *
8
+ * @param value The field's value: an ISO date (`2026-03-01`), or an ISO date-time whose date part is used.
9
+ * @returns The date, or `null` for an empty value or one that is not an ISO date.
10
+ */
11
+ const toCalendarDate = (value) => {
12
+ if (typeof value !== 'string')
13
+ return null;
14
+ try {
15
+ return date.parseDate(value.slice(0, 10));
16
+ }
17
+ catch {
18
+ return null;
19
+ }
20
+ };
21
+
22
+ exports.toCalendarDate = toCalendarDate;
23
+ //# sourceMappingURL=formDatePicker.utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formDatePicker.utils.cjs","sources":["../../../../../../src/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.ts"],"sourcesContent":[null],"names":["parseDate"],"mappings":";;;;AAEA;;;;;AAKG;AACI,MAAM,cAAc,GAAG,CAAC,KAAgC,KAAyB;IACtF,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,IAAI;AAC1C,IAAA,IAAI;QACF,OAAOA,cAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACtC;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF;;"}
@@ -0,0 +1,9 @@
1
+ import { type CalendarDate } from '@internationalized/date';
2
+ /**
3
+ * Reads a form value as a calendar date without throwing, since a default value may come from an API in another shape.
4
+ *
5
+ * @param value The field's value: an ISO date (`2026-03-01`), or an ISO date-time whose date part is used.
6
+ * @returns The date, or `null` for an empty value or one that is not an ISO date.
7
+ */
8
+ export declare const toCalendarDate: (value: string | null | undefined) => CalendarDate | null;
9
+ //# sourceMappingURL=formDatePicker.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formDatePicker.utils.d.ts","sourceRoot":"","sources":["../../../../../../src/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,yBAAyB,CAAC;AAEvE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,YAAY,GAAG,IAOhF,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { parseDate } from '@internationalized/date';
2
+
3
+ /**
4
+ * Reads a form value as a calendar date without throwing, since a default value may come from an API in another shape.
5
+ *
6
+ * @param value The field's value: an ISO date (`2026-03-01`), or an ISO date-time whose date part is used.
7
+ * @returns The date, or `null` for an empty value or one that is not an ISO date.
8
+ */
9
+ const toCalendarDate = (value) => {
10
+ if (typeof value !== 'string')
11
+ return null;
12
+ try {
13
+ return parseDate(value.slice(0, 10));
14
+ }
15
+ catch {
16
+ return null;
17
+ }
18
+ };
19
+
20
+ export { toCalendarDate };
21
+ //# sourceMappingURL=formDatePicker.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formDatePicker.utils.js","sources":["../../../../../../src/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;AAKG;AACI,MAAM,cAAc,GAAG,CAAC,KAAgC,KAAyB;IACtF,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,IAAI;AAC1C,IAAA,IAAI;QACF,OAAO,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACtC;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF;;"}
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var Input = require('@flipdish/ui-library/components/atoms/Input');
5
+ var useFormField = require('../../__internal__/formField/hooks/useFormField.cjs');
6
+
7
+ /**
8
+ * An `Input` bound to a react-hook-form field: it reads and writes the field's value, marks itself invalid and shows
9
+ * the field's error in place of `hint`. Use it for every text field in a form built with react-hook-form.
10
+ *
11
+ * @summary text input bound to a react-hook-form field
12
+ */
13
+ const FormInput = ({ name, revalidates, hint, ...inputProps }) => {
14
+ const { value, ref, onChange, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField.useFormField(name, revalidates);
15
+ return (jsxRuntime.jsx(Input.Input
16
+ // The form's schema validates; the browser's own `required` check would block the submit before it runs.
17
+ , {
18
+ // The form's schema validates; the browser's own `required` check would block the submit before it runs.
19
+ validationBehavior: "aria", ...inputProps, ref: ref, name: name, onChange: onChange, onBlur: onBlur,
20
+ // An unset field is `undefined`, which would flip the input between uncontrolled and controlled.
21
+ value: value ?? '', isInvalid: isInvalid, hint: errorMessage ?? hint, isDisabled: inputProps.isDisabled || isDisabled,
22
+ // Read-only while the form submits: the field keeps its focus and its value, and nothing typed meanwhile is lost to the save.
23
+ isReadOnly: inputProps.isReadOnly || isLocked }));
24
+ };
25
+
26
+ exports.FormInput = FormInput;
27
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../../../../src/components/forms/fields/FormInput/index.tsx"],"sourcesContent":[null],"names":["useFormField","_jsx","Input"],"mappings":";;;;;;AAcA;;;;;AAKG;AACI,MAAM,SAAS,GAAG,CAA4C,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,UAAU,EAA2B,KAAI;IAC1I,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAGA,yBAAY,CAAkB,IAAI,EAAE,WAAW,CAAC;IAExI,QACEC,eAACC;;;;AAEC,QAAA,kBAAkB,EAAC,MAAM,EAAA,GACrB,UAAU,EACd,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM;;QAEd,KAAK,EAAE,KAAK,IAAI,EAAE,EAClB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,YAAY,IAAI,IAAI,EAC1B,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,UAAU;;QAE/C,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,QAAQ,EAAA,CAC7C;AAEN;;"}
@@ -0,0 +1,16 @@
1
+ import { type InputProps } from '@flipdish/ui-library/components/atoms/Input';
2
+ import type { FieldPath, FieldValues } from 'react-hook-form';
3
+ export interface FormInputProps<TValues extends FieldValues = FieldValues> extends Omit<InputProps, 'name' | 'value' | 'defaultValue' | 'onChange' | 'onBlur' | 'isInvalid' | 'ref'> {
4
+ /** The field's path in the form values, such as `email` or `address.city`. */
5
+ name: FieldPath<TValues>;
6
+ /** Other fields whose rule reads this one, such as a postcode that depends on this country; they re-validate when this changes. */
7
+ revalidates?: FieldPath<TValues> | FieldPath<TValues>[];
8
+ }
9
+ /**
10
+ * An `Input` bound to a react-hook-form field: it reads and writes the field's value, marks itself invalid and shows
11
+ * the field's error in place of `hint`. Use it for every text field in a form built with react-hook-form.
12
+ *
13
+ * @summary text input bound to a react-hook-form field
14
+ */
15
+ export declare const FormInput: <TValues extends FieldValues = FieldValues>({ name, revalidates, hint, ...inputProps }: FormInputProps<TValues>) => import("react").JSX.Element;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/fields/FormInput/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9D,MAAM,WAAW,cAAc,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,CACvE,SAAQ,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,WAAW,GAAG,KAAK,CAAC;IACzG,8EAA8E;IAC9E,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACzB,mIAAmI;IACnI,WAAW,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;CACzD;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,SAAS,WAAW,GAAG,WAAW,EAAE,4CAA4C,cAAc,CAAC,OAAO,CAAC,gCAqBvI,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { Input } from '@flipdish/ui-library/components/atoms/Input';
3
+ import { useFormField } from '../../__internal__/formField/hooks/useFormField.js';
4
+
5
+ /**
6
+ * An `Input` bound to a react-hook-form field: it reads and writes the field's value, marks itself invalid and shows
7
+ * the field's error in place of `hint`. Use it for every text field in a form built with react-hook-form.
8
+ *
9
+ * @summary text input bound to a react-hook-form field
10
+ */
11
+ const FormInput = ({ name, revalidates, hint, ...inputProps }) => {
12
+ const { value, ref, onChange, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField(name, revalidates);
13
+ return (jsx(Input
14
+ // The form's schema validates; the browser's own `required` check would block the submit before it runs.
15
+ , {
16
+ // The form's schema validates; the browser's own `required` check would block the submit before it runs.
17
+ validationBehavior: "aria", ...inputProps, ref: ref, name: name, onChange: onChange, onBlur: onBlur,
18
+ // An unset field is `undefined`, which would flip the input between uncontrolled and controlled.
19
+ value: value ?? '', isInvalid: isInvalid, hint: errorMessage ?? hint, isDisabled: inputProps.isDisabled || isDisabled,
20
+ // Read-only while the form submits: the field keeps its focus and its value, and nothing typed meanwhile is lost to the save.
21
+ isReadOnly: inputProps.isReadOnly || isLocked }));
22
+ };
23
+
24
+ export { FormInput };
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/components/forms/fields/FormInput/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;AAcA;;;;;AAKG;AACI,MAAM,SAAS,GAAG,CAA4C,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,UAAU,EAA2B,KAAI;IAC1I,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,YAAY,CAAkB,IAAI,EAAE,WAAW,CAAC;IAExI,QACEA,IAAC;;;;AAEC,QAAA,kBAAkB,EAAC,MAAM,EAAA,GACrB,UAAU,EACd,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM;;QAEd,KAAK,EAAE,KAAK,IAAI,EAAE,EAClB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,YAAY,IAAI,IAAI,EAC1B,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,UAAU;;QAE/C,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,QAAQ,EAAA,CAC7C;AAEN;;"}
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var Select = require('@flipdish/ui-library/components/molecules/Select');
5
+ var React = require('react');
6
+ var useFocusTarget = require('../../__internal__/formField/hooks/useFocusTarget.cjs');
7
+ var useFormField = require('../../__internal__/formField/hooks/useFormField.cjs');
8
+ var multiSelect_utils = require('../../../molecules/Select/multiSelect.utils.cjs');
9
+
10
+ /**
11
+ * A `MultiSelect` bound to a react-hook-form field: every tick, Reset and Select all writes the chosen `id`s to the form
12
+ * as an array and validates it at once, and the field's error shows in place of `hint`. Use it when the user picks
13
+ * several options from a list in a react-hook-form form.
14
+ *
15
+ * @summary multi-option select bound to a react-hook-form field
16
+ */
17
+ const FormMultiSelect = ({ name, revalidates, hint, items, children, onReset, onSelectAll, ...multiSelectProps }) => {
18
+ const { value, ref, onCommit, isInvalid, errorMessage, isDisabled, isLocked } = useFormField.useFormField(name, revalidates);
19
+ // An unset field is `undefined`, which would leave the list uncontrolled; a stable set avoids re-rendering every option.
20
+ const selectedKeys = React.useMemo(() => new Set(value ?? []), [value]);
21
+ // The same ids `MultiSelect`'s own Select all uses: from `items`, else from the static `MultiSelect.Item` children.
22
+ const allKeys = () => [
23
+ ...multiSelect_utils.collectSelectableKeys(items?.map((item) => item.id), children),
24
+ ];
25
+ // A react-aria `Selection` may be `'all'`, which a schema cannot validate, so it becomes the ids.
26
+ const handleSelectionChange = (keys) => onCommit(keys === 'all' ? allKeys() : [...keys]);
27
+ // A controlled `MultiSelect` leaves Reset and Select all to its parent.
28
+ const handleReset = () => {
29
+ onCommit([]);
30
+ onReset?.();
31
+ };
32
+ const handleSelectAll = () => {
33
+ onCommit(allKeys());
34
+ onSelectAll?.();
35
+ };
36
+ // `MultiSelect`'s ref is its wrapper div; the trigger is its only direct button child (the label's tooltip is nested).
37
+ const focusRef = useFocusTarget.useFocusTarget(ref, ':scope > button');
38
+ return (jsxRuntime.jsx(Select.MultiSelect, { ...multiSelectProps, ref: focusRef, items: items, selectedKeys: selectedKeys, onSelectionChange: handleSelectionChange, onReset: handleReset, onSelectAll: handleSelectAll, isInvalid: isInvalid, hint: errorMessage ?? hint,
39
+ // Disabled while the form submits, having no read-only mode: a change made meanwhile would be lost to the save.
40
+ isDisabled: multiSelectProps.isDisabled || isDisabled || isLocked, children: children }));
41
+ };
42
+
43
+ exports.FormMultiSelect = FormMultiSelect;
44
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../../../../src/components/forms/fields/FormMultiSelect/index.tsx"],"sourcesContent":[null],"names":["useFormField","useMemo","collectSelectableKeys","useFocusTarget","_jsx","MultiSelect"],"mappings":";;;;;;;;;AAkBA;;;;;;AAMG;AACI,MAAM,eAAe,GAAG,CAA4C,EACzE,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,OAAO,EACP,WAAW,EACX,GAAG,gBAAgB,EACW,KAAI;IAClC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAGA,yBAAY,CAAiB,IAAI,EAAE,WAAW,CAAC;;AAE/H,IAAA,MAAM,YAAY,GAAGC,aAAO,CAAC,MAAM,IAAI,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;;AAEjE,IAAA,MAAM,OAAO,GAAG,MAAM;AACpB,QAAA,GAAGC,uCAAqB,CACtB,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC,EAC7B,QAAQ,CACT;KACF;;IAGD,MAAM,qBAAqB,GAAG,CAAC,IAAe,KAAK,QAAQ,CAAC,IAAI,KAAK,KAAK,GAAG,OAAO,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;;IAEnG,MAAM,WAAW,GAAG,MAAK;QACvB,QAAQ,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI;AACb,IAAA,CAAC;IACD,MAAM,eAAe,GAAG,MAAK;AAC3B,QAAA,QAAQ,CAAC,OAAO,EAAE,CAAC;QACnB,WAAW,IAAI;AACjB,IAAA,CAAC;;IAGD,MAAM,QAAQ,GAAGC,6BAAc,CAAC,GAAG,EAAE,iBAAiB,CAAC;AAEvD,IAAA,QACEC,cAAA,CAACC,kBAAW,EAAA,EAAA,GACN,gBAAgB,EACpB,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,EAC1B,iBAAiB,EAAE,qBAAqB,EACxC,OAAO,EAAE,WAAW,EACpB,WAAW,EAAE,eAAe,EAC5B,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,YAAY,IAAI,IAAI;;AAE1B,QAAA,UAAU,EAAE,gBAAgB,CAAC,UAAU,IAAI,UAAU,IAAI,QAAQ,EAAA,QAAA,EAEhE,QAAQ,EAAA,CACG;AAElB;;"}
@@ -0,0 +1,17 @@
1
+ import { type MultiSelectProps } from '@flipdish/ui-library/components/molecules/Select';
2
+ import type { FieldPath, FieldValues } from 'react-hook-form';
3
+ export interface FormMultiSelectProps<TValues extends FieldValues = FieldValues> extends Omit<MultiSelectProps, 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'isInvalid' | 'ref'> {
4
+ /** The field's path in the form values, such as `cuisines` or `menu.tags`. */
5
+ name: FieldPath<TValues>;
6
+ /** Other fields whose rule reads this one, such as a postcode that depends on this country; they re-validate when this changes. */
7
+ revalidates?: FieldPath<TValues> | FieldPath<TValues>[];
8
+ }
9
+ /**
10
+ * A `MultiSelect` bound to a react-hook-form field: every tick, Reset and Select all writes the chosen `id`s to the form
11
+ * as an array and validates it at once, and the field's error shows in place of `hint`. Use it when the user picks
12
+ * several options from a list in a react-hook-form form.
13
+ *
14
+ * @summary multi-option select bound to a react-hook-form field
15
+ */
16
+ export declare const FormMultiSelect: <TValues extends FieldValues = FieldValues>({ name, revalidates, hint, items, children, onReset, onSelectAll, ...multiSelectProps }: FormMultiSelectProps<TValues>) => import("react").JSX.Element;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/fields/FormMultiSelect/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AAGtG,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAK9D,MAAM,WAAW,oBAAoB,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,CAC7E,SAAQ,IAAI,CAAC,gBAAgB,EAAE,cAAc,GAAG,qBAAqB,GAAG,mBAAmB,GAAG,WAAW,GAAG,KAAK,CAAC;IAClH,8EAA8E;IAC9E,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACzB,mIAAmI;IACnI,WAAW,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;CACzD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,SAAS,WAAW,GAAG,WAAW,EAAE,yFASxE,oBAAoB,CAAC,OAAO,CAAC,gCA4C/B,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { MultiSelect } from '@flipdish/ui-library/components/molecules/Select';
3
+ import { useMemo } from 'react';
4
+ import { useFocusTarget } from '../../__internal__/formField/hooks/useFocusTarget.js';
5
+ import { useFormField } from '../../__internal__/formField/hooks/useFormField.js';
6
+ import { collectSelectableKeys } from '../../../molecules/Select/multiSelect.utils.js';
7
+
8
+ /**
9
+ * A `MultiSelect` bound to a react-hook-form field: every tick, Reset and Select all writes the chosen `id`s to the form
10
+ * as an array and validates it at once, and the field's error shows in place of `hint`. Use it when the user picks
11
+ * several options from a list in a react-hook-form form.
12
+ *
13
+ * @summary multi-option select bound to a react-hook-form field
14
+ */
15
+ const FormMultiSelect = ({ name, revalidates, hint, items, children, onReset, onSelectAll, ...multiSelectProps }) => {
16
+ const { value, ref, onCommit, isInvalid, errorMessage, isDisabled, isLocked } = useFormField(name, revalidates);
17
+ // An unset field is `undefined`, which would leave the list uncontrolled; a stable set avoids re-rendering every option.
18
+ const selectedKeys = useMemo(() => new Set(value ?? []), [value]);
19
+ // The same ids `MultiSelect`'s own Select all uses: from `items`, else from the static `MultiSelect.Item` children.
20
+ const allKeys = () => [
21
+ ...collectSelectableKeys(items?.map((item) => item.id), children),
22
+ ];
23
+ // A react-aria `Selection` may be `'all'`, which a schema cannot validate, so it becomes the ids.
24
+ const handleSelectionChange = (keys) => onCommit(keys === 'all' ? allKeys() : [...keys]);
25
+ // A controlled `MultiSelect` leaves Reset and Select all to its parent.
26
+ const handleReset = () => {
27
+ onCommit([]);
28
+ onReset?.();
29
+ };
30
+ const handleSelectAll = () => {
31
+ onCommit(allKeys());
32
+ onSelectAll?.();
33
+ };
34
+ // `MultiSelect`'s ref is its wrapper div; the trigger is its only direct button child (the label's tooltip is nested).
35
+ const focusRef = useFocusTarget(ref, ':scope > button');
36
+ return (jsx(MultiSelect, { ...multiSelectProps, ref: focusRef, items: items, selectedKeys: selectedKeys, onSelectionChange: handleSelectionChange, onReset: handleReset, onSelectAll: handleSelectAll, isInvalid: isInvalid, hint: errorMessage ?? hint,
37
+ // Disabled while the form submits, having no read-only mode: a change made meanwhile would be lost to the save.
38
+ isDisabled: multiSelectProps.isDisabled || isDisabled || isLocked, children: children }));
39
+ };
40
+
41
+ export { FormMultiSelect };
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/components/forms/fields/FormMultiSelect/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;AAkBA;;;;;;AAMG;AACI,MAAM,eAAe,GAAG,CAA4C,EACzE,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,OAAO,EACP,WAAW,EACX,GAAG,gBAAgB,EACW,KAAI;IAClC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,YAAY,CAAiB,IAAI,EAAE,WAAW,CAAC;;AAE/H,IAAA,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,IAAI,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;;AAEjE,IAAA,MAAM,OAAO,GAAG,MAAM;AACpB,QAAA,GAAG,qBAAqB,CACtB,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC,EAC7B,QAAQ,CACT;KACF;;IAGD,MAAM,qBAAqB,GAAG,CAAC,IAAe,KAAK,QAAQ,CAAC,IAAI,KAAK,KAAK,GAAG,OAAO,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;;IAEnG,MAAM,WAAW,GAAG,MAAK;QACvB,QAAQ,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI;AACb,IAAA,CAAC;IACD,MAAM,eAAe,GAAG,MAAK;AAC3B,QAAA,QAAQ,CAAC,OAAO,EAAE,CAAC;QACnB,WAAW,IAAI;AACjB,IAAA,CAAC;;IAGD,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,EAAE,iBAAiB,CAAC;AAEvD,IAAA,QACEA,GAAA,CAAC,WAAW,EAAA,EAAA,GACN,gBAAgB,EACpB,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,EAC1B,iBAAiB,EAAE,qBAAqB,EACxC,OAAO,EAAE,WAAW,EACpB,WAAW,EAAE,eAAe,EAC5B,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,YAAY,IAAI,IAAI;;AAE1B,QAAA,UAAU,EAAE,gBAAgB,CAAC,UAAU,IAAI,UAAU,IAAI,QAAQ,EAAA,QAAA,EAEhE,QAAQ,EAAA,CACG;AAElB;;"}
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var Input = require('@flipdish/ui-library/components/atoms/Input');
5
+ var RadioGroup = require('@flipdish/ui-library/components/molecules/RadioGroup');
6
+ var React = require('react');
7
+ var useFocusTarget = require('../../__internal__/formField/hooks/useFocusTarget.cjs');
8
+ var useFormField = require('../../__internal__/formField/hooks/useFormField.cjs');
9
+ var ariaIds_utils = require('../../../../utilities/__internal__/ariaIdsUtils/ariaIds.utils.cjs');
10
+
11
+ /**
12
+ * The card radio group, `RadioGroup.RadioButton`, bound to a react-hook-form field: choosing a card writes its value to
13
+ * the form and validates it at once, and the field's error shows beneath the cards. Use it when each option needs a line of description.
14
+ *
15
+ * @summary card radio group bound to a react-hook-form field
16
+ */
17
+ const FormRadioCardGroup = ({ name, revalidates, label, hint, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, ...radioGroupProps }) => {
18
+ const { value, ref, onCommit, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField.useFormField(name, revalidates);
19
+ // The group takes no ref, so the wrapper hands the form the chosen radio, or the first when none is.
20
+ const focusRef = useFocusTarget.useFocusTarget(ref, 'input:checked:not(:disabled)', 'input:not(:disabled)');
21
+ const labelId = React.useId();
22
+ const messageId = React.useId();
23
+ const message = errorMessage ?? hint;
24
+ return (jsxRuntime.jsxs("div", { ref: focusRef, className: "flex w-full flex-col gap-1.5", children: [label && (jsxRuntime.jsxs("span", { id: labelId, className: "flex items-center gap-0.5 text-sm font-medium text-secondary", children: [label, radioGroupProps.isRequired && (jsxRuntime.jsx("span", { "aria-hidden": "true", className: "text-brand-tertiary", children: "*" }))] })), jsxRuntime.jsx(RadioGroup.RadioButton
25
+ // The form's schema validates; the browser's own `required` check would block the submit before it runs.
26
+ , {
27
+ // The form's schema validates; the browser's own `required` check would block the submit before it runs.
28
+ validationBehavior: "aria", ...radioGroupProps, name: name,
29
+ // An unset field is `undefined`, which would flip the group between uncontrolled and controlled.
30
+ value: value ?? null, onChange: onCommit, onBlur: onBlur, isInvalid: isInvalid, isDisabled: radioGroupProps.isDisabled || isDisabled,
31
+ // Read-only while the form submits: the field keeps its focus and its value, and nothing typed meanwhile is lost to the save.
32
+ isReadOnly: radioGroupProps.isReadOnly || isLocked, "aria-labelledby": ariaIds_utils.joinIds(ariaLabelledBy, label && labelId), "aria-describedby": ariaIds_utils.joinIds(ariaDescribedBy, message && messageId) }), message && (jsxRuntime.jsx(Input.HintText, { id: messageId, isInvalid: Boolean(errorMessage), children: message }))] }));
33
+ };
34
+
35
+ exports.FormRadioCardGroup = FormRadioCardGroup;
36
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../../../../src/components/forms/fields/FormRadioCardGroup/index.tsx"],"sourcesContent":[null],"names":["useFormField","useFocusTarget","useId","_jsxs","_jsx","RadioButton","joinIds","HintText"],"mappings":";;;;;;;;;;AA0BA;;;;;AAKG;AACI,MAAM,kBAAkB,GAAG,CAA4C,EAC5E,IAAI,EACJ,WAAW,EACX,KAAK,EACL,IAAI,EACJ,iBAAiB,EAAE,cAAc,EACjC,kBAAkB,EAAE,eAAe,EACnC,GAAG,eAAe,EACe,KAAI;IACrC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAGA,yBAAY,CAAkB,IAAI,EAAE,WAAW,CAAC;;IAExI,MAAM,QAAQ,GAAGC,6BAAc,CAAC,GAAG,EAAE,8BAA8B,EAAE,sBAAsB,CAAC;AAC5F,IAAA,MAAM,OAAO,GAAGC,WAAK,EAAE;AACvB,IAAA,MAAM,SAAS,GAAGA,WAAK,EAAE;AACzB,IAAA,MAAM,OAAO,GAAG,YAAY,IAAI,IAAI;AAEpC,IAAA,QACEC,eAAA,CAAA,KAAA,EAAA,EAAK,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAC,8BAA8B,EAAA,QAAA,EAAA,CACzD,KAAK,KACJA,eAAA,CAAA,MAAA,EAAA,EAAM,EAAE,EAAE,OAAO,EAAE,SAAS,EAAC,8DAA8D,EAAA,QAAA,EAAA,CACxF,KAAK,EACL,eAAe,CAAC,UAAU,KACzBC,cAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAkB,MAAM,EAAC,SAAS,EAAC,qBAAqB,EAAA,QAAA,EAAA,GAAA,EAAA,CAEjD,CACR,IACI,CACR,EACDA,eAACC;;;;AAEC,gBAAA,kBAAkB,EAAC,MAAM,EAAA,GACrB,eAAe,EACnB,IAAI,EAAE,IAAI;;gBAEV,KAAK,EAAE,KAAK,IAAI,IAAI,EACpB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,eAAe,CAAC,UAAU,IAAI,UAAU;;gBAEpD,UAAU,EAAE,eAAe,CAAC,UAAU,IAAI,QAAQ,EAAA,iBAAA,EACjCC,qBAAO,CAAC,cAAc,EAAE,KAAK,IAAI,OAAO,CAAC,EAAA,kBAAA,EAExCA,qBAAO,CAAC,eAAe,EAAE,OAAO,IAAI,SAAS,CAAC,GAChE,EACD,OAAO,KACNF,cAAA,CAACG,cAAQ,EAAA,EAAC,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,YAAY,CAAC,EAAA,QAAA,EACtD,OAAO,EAAA,CACC,CACZ,CAAA,EAAA,CACG;AAEV;;"}
@@ -0,0 +1,29 @@
1
+ import { RadioButton } from '@flipdish/ui-library/components/molecules/RadioGroup';
2
+ import { type ComponentProps } from 'react';
3
+ import type { FieldPath, FieldValues } from 'react-hook-form';
4
+ interface FormRadioCardGroupBaseProps<TValues extends FieldValues = FieldValues> extends Omit<ComponentProps<typeof RadioButton>, 'name' | 'value' | 'defaultValue' | 'onChange' | 'onBlur' | 'isInvalid'> {
5
+ /** The field's path in the form values, such as `template` or `delivery.method`. */
6
+ name: FieldPath<TValues>;
7
+ /** Other fields whose rule reads this one, such as a postcode that depends on this country; they re-validate when this changes. */
8
+ revalidates?: FieldPath<TValues> | FieldPath<TValues>[];
9
+ /** Name of the group, shown above the cards; the types ask for this, `aria-label` or `aria-labelledby`. */
10
+ label?: string;
11
+ /** Help text beneath the cards; the field's error replaces it. */
12
+ hint?: string;
13
+ }
14
+ export type FormRadioCardGroupProps<TValues extends FieldValues = FieldValues> = FormRadioCardGroupBaseProps<TValues> & ({
15
+ label: string;
16
+ } | {
17
+ 'aria-label': string;
18
+ } | {
19
+ 'aria-labelledby': string;
20
+ });
21
+ /**
22
+ * The card radio group, `RadioGroup.RadioButton`, bound to a react-hook-form field: choosing a card writes its value to
23
+ * the form and validates it at once, and the field's error shows beneath the cards. Use it when each option needs a line of description.
24
+ *
25
+ * @summary card radio group bound to a react-hook-form field
26
+ */
27
+ export declare const FormRadioCardGroup: <TValues extends FieldValues = FieldValues>({ name, revalidates, label, hint, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...radioGroupProps }: FormRadioCardGroupProps<TValues>) => import("react").JSX.Element;
28
+ export {};
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/fields/FormRadioCardGroup/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAC;AACnF,OAAO,EAAE,KAAK,cAAc,EAAS,MAAM,OAAO,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAK9D,UAAU,2BAA2B,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,CAC7E,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,WAAW,CAAC;IACzH,oFAAoF;IACpF,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACzB,mIAAmI;IACnI,WAAW,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;IACxD,2GAA2G;IAC3G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,MAAM,uBAAuB,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,IAAI,2BAA2B,CAAC,OAAO,CAAC,GACnH,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEjF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,SAAS,WAAW,GAAG,WAAW,EAAE,gIAQ3E,uBAAuB,CAAC,OAAO,CAAC,gCA4ClC,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { HintText } from '@flipdish/ui-library/components/atoms/Input';
3
+ import { RadioButton } from '@flipdish/ui-library/components/molecules/RadioGroup';
4
+ import { useId } from 'react';
5
+ import { useFocusTarget } from '../../__internal__/formField/hooks/useFocusTarget.js';
6
+ import { useFormField } from '../../__internal__/formField/hooks/useFormField.js';
7
+ import { joinIds } from '../../../../utilities/__internal__/ariaIdsUtils/ariaIds.utils.js';
8
+
9
+ /**
10
+ * The card radio group, `RadioGroup.RadioButton`, bound to a react-hook-form field: choosing a card writes its value to
11
+ * the form and validates it at once, and the field's error shows beneath the cards. Use it when each option needs a line of description.
12
+ *
13
+ * @summary card radio group bound to a react-hook-form field
14
+ */
15
+ const FormRadioCardGroup = ({ name, revalidates, label, hint, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, ...radioGroupProps }) => {
16
+ const { value, ref, onCommit, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField(name, revalidates);
17
+ // The group takes no ref, so the wrapper hands the form the chosen radio, or the first when none is.
18
+ const focusRef = useFocusTarget(ref, 'input:checked:not(:disabled)', 'input:not(:disabled)');
19
+ const labelId = useId();
20
+ const messageId = useId();
21
+ const message = errorMessage ?? hint;
22
+ return (jsxs("div", { ref: focusRef, className: "flex w-full flex-col gap-1.5", children: [label && (jsxs("span", { id: labelId, className: "flex items-center gap-0.5 text-sm font-medium text-secondary", children: [label, radioGroupProps.isRequired && (jsx("span", { "aria-hidden": "true", className: "text-brand-tertiary", children: "*" }))] })), jsx(RadioButton
23
+ // The form's schema validates; the browser's own `required` check would block the submit before it runs.
24
+ , {
25
+ // The form's schema validates; the browser's own `required` check would block the submit before it runs.
26
+ validationBehavior: "aria", ...radioGroupProps, name: name,
27
+ // An unset field is `undefined`, which would flip the group between uncontrolled and controlled.
28
+ value: value ?? null, onChange: onCommit, onBlur: onBlur, isInvalid: isInvalid, isDisabled: radioGroupProps.isDisabled || isDisabled,
29
+ // Read-only while the form submits: the field keeps its focus and its value, and nothing typed meanwhile is lost to the save.
30
+ isReadOnly: radioGroupProps.isReadOnly || isLocked, "aria-labelledby": joinIds(ariaLabelledBy, label && labelId), "aria-describedby": joinIds(ariaDescribedBy, message && messageId) }), message && (jsx(HintText, { id: messageId, isInvalid: Boolean(errorMessage), children: message }))] }));
31
+ };
32
+
33
+ export { FormRadioCardGroup };
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/components/forms/fields/FormRadioCardGroup/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;AA0BA;;;;;AAKG;AACI,MAAM,kBAAkB,GAAG,CAA4C,EAC5E,IAAI,EACJ,WAAW,EACX,KAAK,EACL,IAAI,EACJ,iBAAiB,EAAE,cAAc,EACjC,kBAAkB,EAAE,eAAe,EACnC,GAAG,eAAe,EACe,KAAI;IACrC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,YAAY,CAAkB,IAAI,EAAE,WAAW,CAAC;;IAExI,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,EAAE,8BAA8B,EAAE,sBAAsB,CAAC;AAC5F,IAAA,MAAM,OAAO,GAAG,KAAK,EAAE;AACvB,IAAA,MAAM,SAAS,GAAG,KAAK,EAAE;AACzB,IAAA,MAAM,OAAO,GAAG,YAAY,IAAI,IAAI;AAEpC,IAAA,QACEA,IAAA,CAAA,KAAA,EAAA,EAAK,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAC,8BAA8B,EAAA,QAAA,EAAA,CACzD,KAAK,KACJA,IAAA,CAAA,MAAA,EAAA,EAAM,EAAE,EAAE,OAAO,EAAE,SAAS,EAAC,8DAA8D,EAAA,QAAA,EAAA,CACxF,KAAK,EACL,eAAe,CAAC,UAAU,KACzBC,GAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAkB,MAAM,EAAC,SAAS,EAAC,qBAAqB,EAAA,QAAA,EAAA,GAAA,EAAA,CAEjD,CACR,IACI,CACR,EACDA,IAAC;;;;AAEC,gBAAA,kBAAkB,EAAC,MAAM,EAAA,GACrB,eAAe,EACnB,IAAI,EAAE,IAAI;;gBAEV,KAAK,EAAE,KAAK,IAAI,IAAI,EACpB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,eAAe,CAAC,UAAU,IAAI,UAAU;;gBAEpD,UAAU,EAAE,eAAe,CAAC,UAAU,IAAI,QAAQ,EAAA,iBAAA,EACjC,OAAO,CAAC,cAAc,EAAE,KAAK,IAAI,OAAO,CAAC,EAAA,kBAAA,EAExC,OAAO,CAAC,eAAe,EAAE,OAAO,IAAI,SAAS,CAAC,GAChE,EACD,OAAO,KACNA,GAAA,CAAC,QAAQ,EAAA,EAAC,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,YAAY,CAAC,EAAA,QAAA,EACtD,OAAO,EAAA,CACC,CACZ,CAAA,EAAA,CACG;AAEV;;"}
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var Input = require('@flipdish/ui-library/components/atoms/Input');
5
+ var RadioButton = require('@flipdish/ui-library/components/atoms/RadioButton');
6
+ var useFocusTarget = require('../../__internal__/formField/hooks/useFocusTarget.cjs');
7
+ var useFormField = require('../../__internal__/formField/hooks/useFormField.cjs');
8
+
9
+ /**
10
+ * A `RadioGroup` bound to a react-hook-form field: choosing an option writes its value to the form and validates it
11
+ * at once, and the field's error shows beneath the group. Use it when the user picks one of a few visible options.
12
+ *
13
+ * @summary radio group bound to a react-hook-form field
14
+ */
15
+ const FormRadioGroup = ({ name, revalidates, children, ...radioGroupProps }) => {
16
+ const { value, ref, onCommit, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField.useFormField(name, revalidates);
17
+ // `RadioGroup` takes no ref, so a layout-neutral wrapper hands the form the chosen radio, or the first when none is.
18
+ const focusRef = useFocusTarget.useFocusTarget(ref, 'input:checked:not(:disabled)', 'input:not(:disabled)');
19
+ return (jsxRuntime.jsx("div", { ref: focusRef, className: "contents", children: jsxRuntime.jsxs(RadioButton.RadioGroup
20
+ // The form's schema validates; the browser's own `required` check would block the submit before it runs.
21
+ , {
22
+ // The form's schema validates; the browser's own `required` check would block the submit before it runs.
23
+ validationBehavior: "aria", ...radioGroupProps, name: name,
24
+ // An unset field is `undefined`, which would flip the group between uncontrolled and controlled.
25
+ value: value ?? null, onChange: onCommit, onBlur: onBlur, isInvalid: isInvalid, isDisabled: radioGroupProps.isDisabled || isDisabled,
26
+ // Read-only while the form submits: the field keeps its focus and its value, and nothing typed meanwhile is lost to the save.
27
+ isReadOnly: radioGroupProps.isReadOnly || isLocked, children: [children, isInvalid && errorMessage && (jsxRuntime.jsx(Input.HintText, { isInvalid: true, role: "alert", children: errorMessage }))] }) }));
28
+ };
29
+
30
+ exports.FormRadioGroup = FormRadioGroup;
31
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../../../../src/components/forms/fields/FormRadioGroup/index.tsx"],"sourcesContent":[null],"names":["useFormField","useFocusTarget","_jsx","_jsxs","RadioGroup","HintText"],"mappings":";;;;;;;;AAiBA;;;;;AAKG;AACI,MAAM,cAAc,GAAG,CAA4C,EACxE,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,GAAG,eAAe,EACW,KAAI;IACjC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAGA,yBAAY,CAAkB,IAAI,EAAE,WAAW,CAAC;;IAExI,MAAM,QAAQ,GAAGC,6BAAc,CAAC,GAAG,EAAE,8BAA8B,EAAE,sBAAsB,CAAC;IAE5F,QACEC,cAAA,CAAA,KAAA,EAAA,EAAK,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAC,UAAU,EAAA,QAAA,EACtCC,eAAA,CAACC;;;;AAEC,YAAA,kBAAkB,EAAC,MAAM,EAAA,GACrB,eAAe,EACnB,IAAI,EAAE,IAAI;;YAEV,KAAK,EAAE,KAAK,IAAI,IAAI,EACpB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,eAAe,CAAC,UAAU,IAAI,UAAU;;AAEpD,YAAA,UAAU,EAAE,eAAe,CAAC,UAAU,IAAI,QAAQ,EAAA,QAAA,EAAA,CAEjD,QAAQ,EAER,SAAS,IAAI,YAAY,KACxBF,cAAA,CAACG,cAAQ,EAAA,EAAC,SAAS,EAAA,IAAA,EAAC,IAAI,EAAC,OAAO,EAAA,QAAA,EAC7B,YAAY,EAAA,CACJ,CACZ,CAAA,EAAA,CACU,EAAA,CACT;AAEV;;"}