@flipdish/ui-library 0.51.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 (298) hide show
  1. package/README.md +17 -16
  2. package/dist/components/atoms/Checkbox/index.cjs +4 -2
  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 +4 -2
  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/organisms/ColorPicker/components/ColorPickerField.cjs +13 -3
  232. package/dist/components/organisms/ColorPicker/components/ColorPickerField.cjs.map +1 -1
  233. package/dist/components/organisms/ColorPicker/components/ColorPickerField.d.ts +1 -1
  234. package/dist/components/organisms/ColorPicker/components/ColorPickerField.d.ts.map +1 -1
  235. package/dist/components/organisms/ColorPicker/components/ColorPickerField.js +13 -3
  236. package/dist/components/organisms/ColorPicker/components/ColorPickerField.js.map +1 -1
  237. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.cjs +2 -2
  238. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.cjs.map +1 -1
  239. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.d.ts +1 -0
  240. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.d.ts.map +1 -1
  241. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.js +2 -2
  242. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.js.map +1 -1
  243. package/dist/components/organisms/ColorPicker/hooks/useCssColorField.cjs +1 -1
  244. package/dist/components/organisms/ColorPicker/hooks/useCssColorField.js +1 -1
  245. package/dist/components/organisms/ColorPicker/index.cjs +1 -1
  246. package/dist/components/organisms/ColorPicker/index.d.ts.map +1 -1
  247. package/dist/components/organisms/ColorPicker/index.js +1 -1
  248. package/dist/components/organisms/ColorPicker/providers/ColorPicker.provider.d.ts +1 -1
  249. package/dist/components/organisms/ColorPicker/providers/ColorPicker.provider.d.ts.map +1 -1
  250. package/dist/components/organisms/ColorPicker/utilities/colorPicker.utils.cjs.map +1 -0
  251. package/dist/components/organisms/ColorPicker/utilities/colorPicker.utils.d.ts.map +1 -0
  252. package/dist/components/organisms/ColorPicker/utilities/colorPicker.utils.js.map +1 -0
  253. package/dist/components/organisms/GradientPicker/components/GradientStopRow.cjs +1 -1
  254. package/dist/components/organisms/GradientPicker/components/GradientStopRow.js +1 -1
  255. package/dist/localization/en.json.cjs +98 -0
  256. package/dist/localization/en.json.cjs.map +1 -0
  257. package/dist/localization/en.json.js +81 -0
  258. package/dist/localization/en.json.js.map +1 -0
  259. package/dist/native/components/forms/Form/index.d.ts +12 -0
  260. package/dist/native/components/forms/FormFooter/index.d.ts +12 -0
  261. package/dist/native/components/forms/FormSection/index.d.ts +12 -0
  262. package/dist/native/components/forms/fields/FormCheckbox/index.d.ts +12 -0
  263. package/dist/native/components/forms/fields/FormCheckboxGroup/index.d.ts +12 -0
  264. package/dist/native/components/forms/fields/FormColorPicker/index.d.ts +12 -0
  265. package/dist/native/components/forms/fields/FormDatePicker/index.d.ts +12 -0
  266. package/dist/native/components/forms/fields/FormInput/index.d.ts +12 -0
  267. package/dist/native/components/forms/fields/FormMultiSelect/index.d.ts +12 -0
  268. package/dist/native/components/forms/fields/FormRadioCardGroup/index.d.ts +12 -0
  269. package/dist/native/components/forms/fields/FormRadioGroup/index.d.ts +12 -0
  270. package/dist/native/components/forms/fields/FormSelect/index.d.ts +12 -0
  271. package/dist/native/components/forms/fields/FormSlider/index.d.ts +12 -0
  272. package/dist/native/components/forms/fields/FormTextArea/index.d.ts +12 -0
  273. package/dist/native/components/forms/fields/FormToggle/index.d.ts +12 -0
  274. package/dist/native/components/forms/validation/index.d.ts +12 -0
  275. package/dist/providers/UnsavedChangesGuardProvider/index.cjs +1 -1
  276. package/dist/providers/UnsavedChangesGuardProvider/index.js +1 -1
  277. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.cjs.map +1 -0
  278. package/dist/providers/UnsavedChangesGuardProvider/{unsavedChangesGuard.utils.d.ts → utilities/unsavedChangesGuard.utils.d.ts} +1 -1
  279. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.d.ts.map +1 -0
  280. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.js.map +1 -0
  281. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.cjs +74 -0
  282. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.cjs.map +1 -0
  283. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.d.ts +51 -0
  284. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.d.ts.map +1 -0
  285. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.js +68 -0
  286. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.js.map +1 -0
  287. package/package.json +41 -6
  288. package/dist/components/organisms/ColorPicker/colorPicker.utils.cjs.map +0 -1
  289. package/dist/components/organisms/ColorPicker/colorPicker.utils.d.ts.map +0 -1
  290. package/dist/components/organisms/ColorPicker/colorPicker.utils.js.map +0 -1
  291. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.utils.cjs.map +0 -1
  292. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.utils.d.ts.map +0 -1
  293. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.utils.js.map +0 -1
  294. /package/dist/components/organisms/ColorPicker/{colorPicker.utils.cjs → utilities/colorPicker.utils.cjs} +0 -0
  295. /package/dist/components/organisms/ColorPicker/{colorPicker.utils.d.ts → utilities/colorPicker.utils.d.ts} +0 -0
  296. /package/dist/components/organisms/ColorPicker/{colorPicker.utils.js → utilities/colorPicker.utils.js} +0 -0
  297. /package/dist/providers/UnsavedChangesGuardProvider/{unsavedChangesGuard.utils.cjs → utilities/unsavedChangesGuard.utils.cjs} +0 -0
  298. /package/dist/providers/UnsavedChangesGuardProvider/{unsavedChangesGuard.utils.js → utilities/unsavedChangesGuard.utils.js} +0 -0
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var validationQueue_utils = require('../../__internal__/formField/utilities/validationQueue.utils.cjs');
4
+
5
+ /**
6
+ * Builds a form's submit so it begins once the field validations still out have answered. react-hook-form validates a
7
+ * submit by itself, outside the fields' queue, so an older answer landing after it would clear an error the submit
8
+ * found, or one its handler set from the server.
9
+ *
10
+ * @param form The react-hook-form form whose fields are being validated.
11
+ * @param onValid Called with the validated values, as `handleSubmit`'s first handler is.
12
+ * @param onInvalid Called with the errors of a submit that failed validation.
13
+ * @returns The submit handler. Its promise lasts as long as the submit, the wait before it included.
14
+ */
15
+ const submitAfterValidations = (form, onValid, onInvalid) => async (event) => {
16
+ // `handleSubmit` cancels the browser's own submit, but only once it is called, which the wait would make too late.
17
+ event?.preventDefault();
18
+ await validationQueue_utils.whenAnswered(validationQueue_utils.validationQueueOf(form.control));
19
+ await form.handleSubmit(onValid, onInvalid)(event);
20
+ };
21
+
22
+ exports.submitAfterValidations = submitAfterValidations;
23
+ //# sourceMappingURL=formSubmit.utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formSubmit.utils.cjs","sources":["../../../../../src/components/forms/Form/utilities/formSubmit.utils.ts"],"sourcesContent":[null],"names":["whenAnswered","validationQueueOf"],"mappings":";;;;AAIA;;;;;;;;;AASG;AACI,MAAM,sBAAsB,GACjC,CACE,IAAqD,EACrD,OAAqC,EACrC,SAAuC,KAEzC,OAAO,KAAkC,KAAmB;;IAE1D,KAAK,EAAE,cAAc,EAAE;IACvB,MAAMA,kCAAY,CAACC,uCAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,KAAK,CAAC;AACpD;;"}
@@ -0,0 +1,14 @@
1
+ import type { FormEvent } from 'react';
2
+ import type { FieldValues, SubmitErrorHandler, SubmitHandler, UseFormReturn } from 'react-hook-form';
3
+ /**
4
+ * Builds a form's submit so it begins once the field validations still out have answered. react-hook-form validates a
5
+ * submit by itself, outside the fields' queue, so an older answer landing after it would clear an error the submit
6
+ * found, or one its handler set from the server.
7
+ *
8
+ * @param form The react-hook-form form whose fields are being validated.
9
+ * @param onValid Called with the validated values, as `handleSubmit`'s first handler is.
10
+ * @param onInvalid Called with the errors of a submit that failed validation.
11
+ * @returns The submit handler. Its promise lasts as long as the submit, the wait before it included.
12
+ */
13
+ export declare const submitAfterValidations: <TValues extends FieldValues, TContext, TSubmitValues>(form: UseFormReturn<TValues, TContext, TSubmitValues>, onValid: SubmitHandler<TSubmitValues>, onInvalid?: SubmitErrorHandler<TValues>) => (event?: FormEvent<HTMLFormElement>) => Promise<void>;
14
+ //# sourceMappingURL=formSubmit.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formSubmit.utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/Form/utilities/formSubmit.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrG;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,GAChC,OAAO,SAAS,WAAW,EAAE,QAAQ,EAAE,aAAa,EACnD,MAAM,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,CAAC,EACrD,SAAS,aAAa,CAAC,aAAa,CAAC,EACrC,YAAY,kBAAkB,CAAC,OAAO,CAAC,MAElC,QAAQ,SAAS,CAAC,eAAe,CAAC,KAAG,OAAO,CAAC,IAAI,CAKvD,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { whenAnswered, validationQueueOf } from '../../__internal__/formField/utilities/validationQueue.utils.js';
2
+
3
+ /**
4
+ * Builds a form's submit so it begins once the field validations still out have answered. react-hook-form validates a
5
+ * submit by itself, outside the fields' queue, so an older answer landing after it would clear an error the submit
6
+ * found, or one its handler set from the server.
7
+ *
8
+ * @param form The react-hook-form form whose fields are being validated.
9
+ * @param onValid Called with the validated values, as `handleSubmit`'s first handler is.
10
+ * @param onInvalid Called with the errors of a submit that failed validation.
11
+ * @returns The submit handler. Its promise lasts as long as the submit, the wait before it included.
12
+ */
13
+ const submitAfterValidations = (form, onValid, onInvalid) => async (event) => {
14
+ // `handleSubmit` cancels the browser's own submit, but only once it is called, which the wait would make too late.
15
+ event?.preventDefault();
16
+ await whenAnswered(validationQueueOf(form.control));
17
+ await form.handleSubmit(onValid, onInvalid)(event);
18
+ };
19
+
20
+ export { submitAfterValidations };
21
+ //# sourceMappingURL=formSubmit.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formSubmit.utils.js","sources":["../../../../../src/components/forms/Form/utilities/formSubmit.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;;;;;;;;;AASG;AACI,MAAM,sBAAsB,GACjC,CACE,IAAqD,EACrD,OAAqC,EACrC,SAAuC,KAEzC,OAAO,KAAkC,KAAmB;;IAE1D,KAAK,EAAE,cAAc,EAAE;IACvB,MAAM,YAAY,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,KAAK,CAAC;AACpD;;"}
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ /**
6
+ * Holds the state of the dialog that confirms a destructive action: whether it is open, and whether the action is
7
+ * running. The dialog closes once the action settles, whether it worked or not.
8
+ *
9
+ * @param onConfirm The action to run once the user confirms; a promise it returns keeps the dialog open and loading
10
+ * until it settles. A failure only closes the dialog, since the app shows its own error.
11
+ * @returns `isOpen` and `isConfirming` for the dialog, `open` for the button that asks, `onOpenChange` for the dialog's
12
+ * own requests to close, and `confirm` for its confirming button.
13
+ */
14
+ const useDestructiveConfirmation = (onConfirm) => {
15
+ const [isOpen, setIsOpen] = React.useState(false);
16
+ const [isConfirming, setIsConfirming] = React.useState(false);
17
+ const open = React.useCallback(() => setIsOpen(true), []);
18
+ const confirm = React.useCallback(async () => {
19
+ try {
20
+ const result = onConfirm?.();
21
+ // Only an action that takes time shows as loading; one that returns at once just closes the dialog.
22
+ if (result instanceof Promise) {
23
+ setIsConfirming(true);
24
+ await result;
25
+ }
26
+ }
27
+ catch {
28
+ // The app reports the failure where the user will see it; the dialog has nowhere to show one.
29
+ }
30
+ finally {
31
+ setIsConfirming(false);
32
+ setIsOpen(false);
33
+ }
34
+ }, [onConfirm]);
35
+ return { isOpen, isConfirming, open, onOpenChange: setIsOpen, confirm };
36
+ };
37
+
38
+ exports.useDestructiveConfirmation = useDestructiveConfirmation;
39
+ //# sourceMappingURL=useDestructiveConfirmation.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDestructiveConfirmation.cjs","sources":["../../../../../src/components/forms/FormFooter/hooks/useDestructiveConfirmation.ts"],"sourcesContent":[null],"names":["useState","useCallback"],"mappings":";;;;AAEA;;;;;;;;AAQG;AACI,MAAM,0BAA0B,GAAG,CAAC,SAAsC,KAAI;IACnF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;IAC3C,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;AAEvD,IAAA,MAAM,IAAI,GAAGC,iBAAW,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;AAEnD,IAAA,MAAM,OAAO,GAAGA,iBAAW,CAAC,YAAW;AACrC,QAAA,IAAI;AACF,YAAA,MAAM,MAAM,GAAG,SAAS,IAAI;;AAE5B,YAAA,IAAI,MAAM,YAAY,OAAO,EAAE;gBAC7B,eAAe,CAAC,IAAI,CAAC;AACrB,gBAAA,MAAM,MAAM;YACd;QACF;AAAE,QAAA,MAAM;;QAER;gBAAU;YACR,eAAe,CAAC,KAAK,CAAC;YACtB,SAAS,CAAC,KAAK,CAAC;QAClB;AACF,IAAA,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;AAEf,IAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE;AACzE;;"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Holds the state of the dialog that confirms a destructive action: whether it is open, and whether the action is
3
+ * running. The dialog closes once the action settles, whether it worked or not.
4
+ *
5
+ * @param onConfirm The action to run once the user confirms; a promise it returns keeps the dialog open and loading
6
+ * until it settles. A failure only closes the dialog, since the app shows its own error.
7
+ * @returns `isOpen` and `isConfirming` for the dialog, `open` for the button that asks, `onOpenChange` for the dialog's
8
+ * own requests to close, and `confirm` for its confirming button.
9
+ */
10
+ export declare const useDestructiveConfirmation: (onConfirm: (() => unknown) | undefined) => {
11
+ isOpen: boolean;
12
+ isConfirming: boolean;
13
+ open: () => void;
14
+ onOpenChange: import("react").Dispatch<import("react").SetStateAction<boolean>>;
15
+ confirm: () => Promise<void>;
16
+ };
17
+ //# sourceMappingURL=useDestructiveConfirmation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDestructiveConfirmation.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/FormFooter/hooks/useDestructiveConfirmation.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,GAAI,WAAW,CAAC,MAAM,OAAO,CAAC,GAAG,SAAS;;;;;;CAuBhF,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { useState, useCallback } from 'react';
2
+
3
+ /**
4
+ * Holds the state of the dialog that confirms a destructive action: whether it is open, and whether the action is
5
+ * running. The dialog closes once the action settles, whether it worked or not.
6
+ *
7
+ * @param onConfirm The action to run once the user confirms; a promise it returns keeps the dialog open and loading
8
+ * until it settles. A failure only closes the dialog, since the app shows its own error.
9
+ * @returns `isOpen` and `isConfirming` for the dialog, `open` for the button that asks, `onOpenChange` for the dialog's
10
+ * own requests to close, and `confirm` for its confirming button.
11
+ */
12
+ const useDestructiveConfirmation = (onConfirm) => {
13
+ const [isOpen, setIsOpen] = useState(false);
14
+ const [isConfirming, setIsConfirming] = useState(false);
15
+ const open = useCallback(() => setIsOpen(true), []);
16
+ const confirm = useCallback(async () => {
17
+ try {
18
+ const result = onConfirm?.();
19
+ // Only an action that takes time shows as loading; one that returns at once just closes the dialog.
20
+ if (result instanceof Promise) {
21
+ setIsConfirming(true);
22
+ await result;
23
+ }
24
+ }
25
+ catch {
26
+ // The app reports the failure where the user will see it; the dialog has nowhere to show one.
27
+ }
28
+ finally {
29
+ setIsConfirming(false);
30
+ setIsOpen(false);
31
+ }
32
+ }, [onConfirm]);
33
+ return { isOpen, isConfirming, open, onOpenChange: setIsOpen, confirm };
34
+ };
35
+
36
+ export { useDestructiveConfirmation };
37
+ //# sourceMappingURL=useDestructiveConfirmation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDestructiveConfirmation.js","sources":["../../../../../src/components/forms/FormFooter/hooks/useDestructiveConfirmation.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;;;AAQG;AACI,MAAM,0BAA0B,GAAG,CAAC,SAAsC,KAAI;IACnF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC3C,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AAEvD,IAAA,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;AAEnD,IAAA,MAAM,OAAO,GAAG,WAAW,CAAC,YAAW;AACrC,QAAA,IAAI;AACF,YAAA,MAAM,MAAM,GAAG,SAAS,IAAI;;AAE5B,YAAA,IAAI,MAAM,YAAY,OAAO,EAAE;gBAC7B,eAAe,CAAC,IAAI,CAAC;AACrB,gBAAA,MAAM,MAAM;YACd;QACF;AAAE,QAAA,MAAM;;QAER;gBAAU;YACR,eAAe,CAAC,KAAK,CAAC;YACtB,SAAS,CAAC,KAAK,CAAC;QAClB;AACF,IAAA,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;AAEf,IAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE;AACzE;;"}
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var reactHookForm = require('react-hook-form');
5
+ var FieldElements_context = require('../../__internal__/formField/providers/FieldElements.context.cjs');
6
+ var formFooter_utils = require('../utilities/formFooter.utils.cjs');
7
+
8
+ const subscribeToNothing = () => () => { };
9
+ const noVersion = () => 0;
10
+ /**
11
+ * Reports whether a field of the form shows an error, which is when the footer turns Save off. Inside `Form` it
12
+ * follows the fields on the page: a field that leaves takes its error out of the count, though react-hook-form keeps
13
+ * that error and changes nothing in the form's state to say the field has gone.
14
+ *
15
+ * @returns `true` while at least one field on the page has an error. The form's own error under `root` never counts.
16
+ */
17
+ const useHasFieldError = () => {
18
+ const { errors } = reactHookForm.useFormState();
19
+ const fieldElements = React.useContext(FieldElements_context.FieldElementsContext);
20
+ // Read only to render again when a field joins or leaves: by then its element is gone from the record.
21
+ React.useSyncExternalStore(fieldElements?.subscribe ?? subscribeToNothing, fieldElements?.getVersion ?? noVersion, fieldElements?.getVersion ?? noVersion);
22
+ return formFooter_utils.hasFieldError(errors, fieldElements?.elements);
23
+ };
24
+
25
+ exports.useHasFieldError = useHasFieldError;
26
+ //# sourceMappingURL=useHasFieldError.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHasFieldError.cjs","sources":["../../../../../src/components/forms/FormFooter/hooks/useHasFieldError.ts"],"sourcesContent":[null],"names":["useFormState","useContext","FieldElementsContext","useSyncExternalStore","hasFieldError"],"mappings":";;;;;;;AAKA,MAAM,kBAAkB,GAAG,MAAM,MAAK,EAAE,CAAC;AACzC,MAAM,SAAS,GAAG,MAAM,CAAC;AAEzB;;;;;;AAMG;AACI,MAAM,gBAAgB,GAAG,MAAc;AAC5C,IAAA,MAAM,EAAE,MAAM,EAAE,GAAGA,0BAAY,EAAE;AACjC,IAAA,MAAM,aAAa,GAAGC,gBAAU,CAACC,0CAAoB,CAAC;;AAEtD,IAAAC,0BAAoB,CAClB,aAAa,EAAE,SAAS,IAAI,kBAAkB,EAC9C,aAAa,EAAE,UAAU,IAAI,SAAS,EACtC,aAAa,EAAE,UAAU,IAAI,SAAS,CACvC;IACD,OAAOC,8BAAa,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,CAAC;AACvD;;"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Reports whether a field of the form shows an error, which is when the footer turns Save off. Inside `Form` it
3
+ * follows the fields on the page: a field that leaves takes its error out of the count, though react-hook-form keeps
4
+ * that error and changes nothing in the form's state to say the field has gone.
5
+ *
6
+ * @returns `true` while at least one field on the page has an error. The form's own error under `root` never counts.
7
+ */
8
+ export declare const useHasFieldError: () => boolean;
9
+ //# sourceMappingURL=useHasFieldError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHasFieldError.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/FormFooter/hooks/useHasFieldError.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,QAAO,OAUnC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { useContext, useSyncExternalStore } from 'react';
2
+ import { useFormState } from 'react-hook-form';
3
+ import { FieldElementsContext } from '../../__internal__/formField/providers/FieldElements.context.js';
4
+ import { hasFieldError } from '../utilities/formFooter.utils.js';
5
+
6
+ const subscribeToNothing = () => () => { };
7
+ const noVersion = () => 0;
8
+ /**
9
+ * Reports whether a field of the form shows an error, which is when the footer turns Save off. Inside `Form` it
10
+ * follows the fields on the page: a field that leaves takes its error out of the count, though react-hook-form keeps
11
+ * that error and changes nothing in the form's state to say the field has gone.
12
+ *
13
+ * @returns `true` while at least one field on the page has an error. The form's own error under `root` never counts.
14
+ */
15
+ const useHasFieldError = () => {
16
+ const { errors } = useFormState();
17
+ const fieldElements = useContext(FieldElementsContext);
18
+ // Read only to render again when a field joins or leaves: by then its element is gone from the record.
19
+ useSyncExternalStore(fieldElements?.subscribe ?? subscribeToNothing, fieldElements?.getVersion ?? noVersion, fieldElements?.getVersion ?? noVersion);
20
+ return hasFieldError(errors, fieldElements?.elements);
21
+ };
22
+
23
+ export { useHasFieldError };
24
+ //# sourceMappingURL=useHasFieldError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHasFieldError.js","sources":["../../../../../src/components/forms/FormFooter/hooks/useHasFieldError.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAKA,MAAM,kBAAkB,GAAG,MAAM,MAAK,EAAE,CAAC;AACzC,MAAM,SAAS,GAAG,MAAM,CAAC;AAEzB;;;;;;AAMG;AACI,MAAM,gBAAgB,GAAG,MAAc;AAC5C,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,YAAY,EAAE;AACjC,IAAA,MAAM,aAAa,GAAG,UAAU,CAAC,oBAAoB,CAAC;;AAEtD,IAAA,oBAAoB,CAClB,aAAa,EAAE,SAAS,IAAI,kBAAkB,EAC9C,aAAa,EAAE,UAAU,IAAI,SAAS,EACtC,aAAa,EAAE,UAAU,IAAI,SAAS,CACvC;IACD,OAAO,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,CAAC;AACvD;;"}
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var uiIcons = require('@flipdish/ui-icons');
5
+ var Button = require('@flipdish/ui-library/components/atoms/Button');
6
+ var Modals = require('@flipdish/ui-library/components/molecules/Modals');
7
+ var SectionFooter = require('@flipdish/ui-library/components/molecules/SectionFooter');
8
+ var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
9
+ var reactHookForm = require('react-hook-form');
10
+ var useReturnFocus = require('../../../hooks/__internal__/useReturnFocus/useReturnFocus.cjs');
11
+ var useDestructiveConfirmation = require('./hooks/useDestructiveConfirmation.cjs');
12
+ var useHasFieldError = require('./hooks/useHasFieldError.cjs');
13
+
14
+ /**
15
+ * The footer of a react-hook-form form that waits on Save: an optional destructive action on the left, Discard and Save
16
+ * on the right, driven by the form's own dirty, error and submitting state. Use one per form, as the last thing inside its `<form>`.
17
+ *
18
+ * @summary discard and save footer driven by a react-hook-form form
19
+ */
20
+ const FormFooter = ({ onDiscard, isSaved = false, destructiveAction, isDirty: isDirtyProp, hasErrors: hasErrorsProp, isSaving: isSavingProp, 'data-testid': dataTestId, }) => {
21
+ const formState = reactHookForm.useFormState();
22
+ const isDirty = isDirtyProp ?? formState.isDirty;
23
+ const hasFieldErrorNow = useHasFieldError.useHasFieldError();
24
+ const hasErrors = hasErrorsProp ?? hasFieldErrorNow;
25
+ const isSaving = isSavingProp ?? formState.isSubmitting;
26
+ const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'form-footer', rootName: 'form-footer' });
27
+ const { originRef, returnFocus } = useReturnFocus.useReturnFocus('button[type="submit"]', 'form');
28
+ const confirmation = useDestructiveConfirmation.useDestructiveConfirmation(destructiveAction?.onConfirm);
29
+ /** Discard turns itself off once the form is clean, which would drop focus to the top of the page, so Save takes it first. */
30
+ const discard = () => {
31
+ returnFocus();
32
+ onDiscard();
33
+ };
34
+ return (
35
+ // On a phone the buttons stack full width in the order they sit in a row on a wider screen: the destructive action,
36
+ // Discard, then Save last.
37
+ jsxRuntime.jsxs(SectionFooter.SectionFooter.Root, { ref: originRef, "data-testid": rootTestId, className: "flex-col items-stretch gap-3 sm:flex-row sm:flex-wrap sm:items-center sm:gap-5", children: [destructiveAction && (jsxRuntime.jsx(Button.Button, { color: "secondary-destructive", size: "md", iconLeading: uiIcons.Trash01, isDisabled: isSaving, onPress: destructiveAction.confirmation ? confirmation.open : destructiveAction.onPress, "data-testid": testIdUtils.joinTestId(rootTestId, 'destructive-action'), children: destructiveAction.label })), destructiveAction?.confirmation && (jsxRuntime.jsx(Modals.ConfirmationModal, { isOpen: confirmation.isOpen, onOpenChange: confirmation.onOpenChange, title: destructiveAction.confirmation.title, description: destructiveAction.confirmation.description, confirmLabel: destructiveAction.label, onConfirm: confirmation.confirm, isConfirming: confirmation.isConfirming, isDestructive: true, "data-testid": testIdUtils.joinTestId(rootTestId, 'destructive-confirmation') })), jsxRuntime.jsxs(SectionFooter.SectionFooter.Actions, { className: "flex-none flex-col items-stretch sm:flex-1 sm:flex-row sm:flex-wrap sm:items-center", children: [jsxRuntime.jsx("output", { className: "sr-only", children: isSaved && 'Changes saved' }), jsxRuntime.jsx(Button.Button, { color: "secondary", size: "md", iconLeading: uiIcons.ReverseLeft, isDisabled: !isDirty || isSaving, onPress: discard, "data-testid": testIdUtils.joinTestId(rootTestId, 'discard'), children: "Discard" }), jsxRuntime.jsx(Button.Button, { type: "submit", color: "primary", size: "md", iconLeading: uiIcons.Save01, isDisabled: hasErrors, isLoading: isSaving, showTextWhileLoading: true, isSuccess: isSaved, "data-testid": testIdUtils.joinTestId(rootTestId, 'save'), children: "Save" })] })] }));
38
+ };
39
+
40
+ exports.FormFooter = FormFooter;
41
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/components/forms/FormFooter/index.tsx"],"sourcesContent":[null],"names":["useFormState","useHasFieldError","useResolvedTestId","useReturnFocus","useDestructiveConfirmation","_jsxs","SectionFooter","_jsx","Button","Trash01","joinTestId","ConfirmationModal","ReverseLeft","Save01"],"mappings":";;;;;;;;;;;;;AA6DA;;;;;AAKG;AACI,MAAM,UAAU,GAAG,CAAC,EACzB,SAAS,EACT,OAAO,GAAG,KAAK,EACf,iBAAiB,EACjB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,aAAa,EACxB,QAAQ,EAAE,YAAY,EACtB,aAAa,EAAE,UAAU,GACT,KAAI;AACpB,IAAA,MAAM,SAAS,GAAGA,0BAAY,EAAE;AAChC,IAAA,MAAM,OAAO,GAAG,WAAW,IAAI,SAAS,CAAC,OAAO;AAChD,IAAA,MAAM,gBAAgB,GAAGC,iCAAgB,EAAE;AAC3C,IAAA,MAAM,SAAS,GAAG,aAAa,IAAI,gBAAgB;AACnD,IAAA,MAAM,QAAQ,GAAG,YAAY,IAAI,SAAS,CAAC,YAAY;AACvD,IAAA,MAAM,UAAU,GAAGC,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;AAC7G,IAAA,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAGC,6BAAc,CAAiB,uBAAuB,EAAE,MAAM,CAAC;IAClG,MAAM,YAAY,GAAGC,qDAA0B,CAAC,iBAAiB,EAAE,SAAS,CAAC;;IAG7E,MAAM,OAAO,GAAG,MAAK;AACnB,QAAA,WAAW,EAAE;AACb,QAAA,SAAS,EAAE;AACb,IAAA,CAAC;IAED;;;IAGEC,eAAA,CAACC,2BAAa,CAAC,IAAI,EAAA,EACjB,GAAG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EAAE,OAAO,EAAA,aAAA,EACHF,sBAAU,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,SAAA,EAAA,CAGvC,EAETH,cAAA,CAACC,aAAM,EAAA,EACL,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,SAAS,EACf,IAAI,EAAC,IAAI,EACT,WAAW,EAAEK,cAAM,EACnB,UAAU,EAAE,SAAS,EACrB,SAAS,EAAE,QAAQ,EACnB,oBAAoB,EAAA,IAAA,EACpB,SAAS,EAAE,OAAO,EAAA,aAAA,EACLH,sBAAU,CAAC,UAAU,EAAE,MAAM,CAAC,EAAA,QAAA,EAAA,MAAA,EAAA,CAGpC,CAAA,EAAA,CACa,CAAA,EAAA,CACL;AAEzB;;"}
@@ -0,0 +1,52 @@
1
+ /** The dialog that asks the user to confirm a destructive action. */
2
+ export interface FormFooterConfirmation {
3
+ /** The question being asked, such as "Remove this item?". */
4
+ title: string;
5
+ /** What confirming will do, beneath the title. */
6
+ description: string;
7
+ }
8
+ /** A destructive action the footer confirms itself: pressing the button opens a dialog, and confirming runs the action. */
9
+ export interface FormFooterConfirmedAction {
10
+ /** The button's text, such as "Remove" or "Remove property"; the dialog's confirming button repeats it. */
11
+ label: string;
12
+ /** The dialog shown before the action runs. */
13
+ confirmation: FormFooterConfirmation;
14
+ /** Runs once the user confirms. Return the action's promise and the dialog shows it loading, then closes when it settles. */
15
+ onConfirm: () => unknown;
16
+ onPress?: never;
17
+ }
18
+ /** A destructive action the app confirms itself, for a removal that needs more than a yes or no. */
19
+ export interface FormFooterOwnAction {
20
+ /** The button's text, such as "Remove" or "Remove property". */
21
+ label: string;
22
+ /** Runs on press; open your own dialog here, since the footer does not ask. */
23
+ onPress: () => void;
24
+ confirmation?: never;
25
+ onConfirm?: never;
26
+ }
27
+ /** A destructive action for the record the form edits, such as removing it. */
28
+ export type FormFooterDestructiveAction = FormFooterConfirmedAction | FormFooterOwnAction;
29
+ export interface FormFooterProps {
30
+ /** Puts the form back to what was loaded or last saved, such as `reset()` plus clearing a failed save. */
31
+ onDiscard: () => void;
32
+ /** Whether the last save succeeded and nothing has changed since: Save shows a check and "Changes saved" is announced. */
33
+ isSaved?: boolean;
34
+ /** Adds a destructive button for the record itself on the left, held while the form saves. With `confirmation` the footer asks before running `onConfirm`. */
35
+ destructiveAction?: FormFooterDestructiveAction;
36
+ /** Turns Discard on. Defaults to the form's `isDirty`. */
37
+ isDirty?: boolean;
38
+ /** Turns Save off until the last field error is fixed. Defaults to whether a field has an error; inside `Form`, only a `Form*` field still on the page counts. */
39
+ hasErrors?: boolean;
40
+ /** Shows Save's spinner and holds Discard. Defaults to the form's `isSubmitting`, so return the save's promise from the submit handler. */
41
+ isSaving?: boolean;
42
+ /** Overrides the root `data-testid` (defaults to `fd-form-footer`); the buttons derive theirs from it. */
43
+ 'data-testid'?: string;
44
+ }
45
+ /**
46
+ * The footer of a react-hook-form form that waits on Save: an optional destructive action on the left, Discard and Save
47
+ * on the right, driven by the form's own dirty, error and submitting state. Use one per form, as the last thing inside its `<form>`.
48
+ *
49
+ * @summary discard and save footer driven by a react-hook-form form
50
+ */
51
+ export declare const FormFooter: ({ onDiscard, isSaved, destructiveAction, isDirty: isDirtyProp, hasErrors: hasErrorsProp, isSaving: isSavingProp, "data-testid": dataTestId, }: FormFooterProps) => import("react").JSX.Element;
52
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/FormFooter/index.tsx"],"names":[],"mappings":"AAYA,qEAAqE;AACrE,MAAM,WAAW,sBAAsB;IACrC,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,2HAA2H;AAC3H,MAAM,WAAW,yBAAyB;IACxC,2GAA2G;IAC3G,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,YAAY,EAAE,sBAAsB,CAAC;IACrC,6HAA6H;IAC7H,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB;AAED,oGAAoG;AACpG,MAAM,WAAW,mBAAmB;IAClC,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB;AAED,+EAA+E;AAC/E,MAAM,MAAM,2BAA2B,GAAG,yBAAyB,GAAG,mBAAmB,CAAC;AAE1F,MAAM,WAAW,eAAe;IAC9B,0GAA0G;IAC1G,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,0HAA0H;IAC1H,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8JAA8J;IAC9J,iBAAiB,CAAC,EAAE,2BAA2B,CAAC;IAChD,0DAA0D;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kKAAkK;IAClK,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,2IAA2I;IAC3I,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0GAA0G;IAC1G,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,+IAQxB,eAAe,gCA+EjB,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { Trash01, ReverseLeft, Save01 } from '@flipdish/ui-icons';
3
+ import { Button } from '@flipdish/ui-library/components/atoms/Button';
4
+ import { ConfirmationModal } from '@flipdish/ui-library/components/molecules/Modals';
5
+ import { SectionFooter } from '@flipdish/ui-library/components/molecules/SectionFooter';
6
+ import { useResolvedTestId, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
7
+ import { useFormState } from 'react-hook-form';
8
+ import { useReturnFocus } from '../../../hooks/__internal__/useReturnFocus/useReturnFocus.js';
9
+ import { useDestructiveConfirmation } from './hooks/useDestructiveConfirmation.js';
10
+ import { useHasFieldError } from './hooks/useHasFieldError.js';
11
+
12
+ /**
13
+ * The footer of a react-hook-form form that waits on Save: an optional destructive action on the left, Discard and Save
14
+ * on the right, driven by the form's own dirty, error and submitting state. Use one per form, as the last thing inside its `<form>`.
15
+ *
16
+ * @summary discard and save footer driven by a react-hook-form form
17
+ */
18
+ const FormFooter = ({ onDiscard, isSaved = false, destructiveAction, isDirty: isDirtyProp, hasErrors: hasErrorsProp, isSaving: isSavingProp, 'data-testid': dataTestId, }) => {
19
+ const formState = useFormState();
20
+ const isDirty = isDirtyProp ?? formState.isDirty;
21
+ const hasFieldErrorNow = useHasFieldError();
22
+ const hasErrors = hasErrorsProp ?? hasFieldErrorNow;
23
+ const isSaving = isSavingProp ?? formState.isSubmitting;
24
+ const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'form-footer', rootName: 'form-footer' });
25
+ const { originRef, returnFocus } = useReturnFocus('button[type="submit"]', 'form');
26
+ const confirmation = useDestructiveConfirmation(destructiveAction?.onConfirm);
27
+ /** Discard turns itself off once the form is clean, which would drop focus to the top of the page, so Save takes it first. */
28
+ const discard = () => {
29
+ returnFocus();
30
+ onDiscard();
31
+ };
32
+ return (
33
+ // On a phone the buttons stack full width in the order they sit in a row on a wider screen: the destructive action,
34
+ // Discard, then Save last.
35
+ jsxs(SectionFooter.Root, { ref: originRef, "data-testid": rootTestId, className: "flex-col items-stretch gap-3 sm:flex-row sm:flex-wrap sm:items-center sm:gap-5", children: [destructiveAction && (jsx(Button, { color: "secondary-destructive", size: "md", iconLeading: Trash01, isDisabled: isSaving, onPress: destructiveAction.confirmation ? confirmation.open : destructiveAction.onPress, "data-testid": joinTestId(rootTestId, 'destructive-action'), children: destructiveAction.label })), destructiveAction?.confirmation && (jsx(ConfirmationModal, { isOpen: confirmation.isOpen, onOpenChange: confirmation.onOpenChange, title: destructiveAction.confirmation.title, description: destructiveAction.confirmation.description, confirmLabel: destructiveAction.label, onConfirm: confirmation.confirm, isConfirming: confirmation.isConfirming, isDestructive: true, "data-testid": joinTestId(rootTestId, 'destructive-confirmation') })), jsxs(SectionFooter.Actions, { className: "flex-none flex-col items-stretch sm:flex-1 sm:flex-row sm:flex-wrap sm:items-center", children: [jsx("output", { className: "sr-only", children: isSaved && 'Changes saved' }), jsx(Button, { color: "secondary", size: "md", iconLeading: ReverseLeft, isDisabled: !isDirty || isSaving, onPress: discard, "data-testid": joinTestId(rootTestId, 'discard'), children: "Discard" }), jsx(Button, { type: "submit", color: "primary", size: "md", iconLeading: Save01, isDisabled: hasErrors, isLoading: isSaving, showTextWhileLoading: true, isSuccess: isSaved, "data-testid": joinTestId(rootTestId, 'save'), children: "Save" })] })] }));
36
+ };
37
+
38
+ export { FormFooter };
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/forms/FormFooter/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;AA6DA;;;;;AAKG;AACI,MAAM,UAAU,GAAG,CAAC,EACzB,SAAS,EACT,OAAO,GAAG,KAAK,EACf,iBAAiB,EACjB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,aAAa,EACxB,QAAQ,EAAE,YAAY,EACtB,aAAa,EAAE,UAAU,GACT,KAAI;AACpB,IAAA,MAAM,SAAS,GAAG,YAAY,EAAE;AAChC,IAAA,MAAM,OAAO,GAAG,WAAW,IAAI,SAAS,CAAC,OAAO;AAChD,IAAA,MAAM,gBAAgB,GAAG,gBAAgB,EAAE;AAC3C,IAAA,MAAM,SAAS,GAAG,aAAa,IAAI,gBAAgB;AACnD,IAAA,MAAM,QAAQ,GAAG,YAAY,IAAI,SAAS,CAAC,YAAY;AACvD,IAAA,MAAM,UAAU,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;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,EAAC,SAAS,EAAC,qFAAqF,EAAA,QAAA,EAAA,CAEpHC,GAAA,CAAA,QAAA,EAAA,EAAQ,SAAS,EAAC,SAAS,EAAA,QAAA,EAAE,OAAO,IAAI,eAAe,EAAA,CAAU,EACjEA,GAAA,CAAC,MAAM,EAAA,EACL,KAAK,EAAC,WAAW,EACjB,IAAI,EAAC,IAAI,EACT,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,CAAC,OAAO,IAAI,QAAQ,EAChC,OAAO,EAAE,OAAO,EAAA,aAAA,EACH,UAAU,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,SAAA,EAAA,CAGvC,EAETA,GAAA,CAAC,MAAM,EAAA,EACL,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,SAAS,EACf,IAAI,EAAC,IAAI,EACT,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,SAAS,EACrB,SAAS,EAAE,QAAQ,EACnB,oBAAoB,EAAA,IAAA,EACpB,SAAS,EAAE,OAAO,EAAA,aAAA,EACL,UAAU,CAAC,UAAU,EAAE,MAAM,CAAC,EAAA,QAAA,EAAA,MAAA,EAAA,CAGpC,CAAA,EAAA,CACa,CAAA,EAAA,CACL;AAEzB;;"}
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ var formFocus_utils = require('../../__internal__/formField/utilities/formFocus.utils.cjs');
4
+
5
+ /**
6
+ * Whether a field of the form shows an error, which is when Save is off. The form's own error under `root`, such as a
7
+ * failed save, is left out: no field edit clears it, only another submit, so it must not hold Save off.
8
+ *
9
+ * @param errors The form's `formState.errors`.
10
+ * @param fieldElements Each mounted field's element by name, inside `Form`. With it, only an error on a field still on
11
+ * the page counts: react-hook-form keeps the error of a field that has left it, and nothing on screen says how to fix that one.
12
+ * @returns `true` while at least one field shows an error.
13
+ */
14
+ const hasFieldError = (errors, fieldElements) => {
15
+ if (fieldElements)
16
+ return formFocus_utils.firstInvalidFieldOnPage(errors, fieldElements) !== undefined;
17
+ return Object.keys(errors).some((key) => key !== 'root');
18
+ };
19
+
20
+ exports.hasFieldError = hasFieldError;
21
+ //# sourceMappingURL=formFooter.utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formFooter.utils.cjs","sources":["../../../../../src/components/forms/FormFooter/utilities/formFooter.utils.ts"],"sourcesContent":[null],"names":["firstInvalidFieldOnPage"],"mappings":";;;;AAGA;;;;;;;;AAQG;MACU,aAAa,GAAG,CAAC,MAAmB,EAAE,aAA2C,KAAa;AACzG,IAAA,IAAI,aAAa;QAAE,OAAOA,uCAAuB,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,SAAS;AACtF,IAAA,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,KAAK,MAAM,CAAC;AAC1D;;"}
@@ -0,0 +1,12 @@
1
+ import type { FieldErrors } from 'react-hook-form';
2
+ /**
3
+ * Whether a field of the form shows an error, which is when Save is off. The form's own error under `root`, such as a
4
+ * failed save, is left out: no field edit clears it, only another submit, so it must not hold Save off.
5
+ *
6
+ * @param errors The form's `formState.errors`.
7
+ * @param fieldElements Each mounted field's element by name, inside `Form`. With it, only an error on a field still on
8
+ * the page counts: react-hook-form keeps the error of a field that has left it, and nothing on screen says how to fix that one.
9
+ * @returns `true` while at least one field shows an error.
10
+ */
11
+ export declare const hasFieldError: (errors: FieldErrors, fieldElements?: Map<string, Element> | null) => boolean;
12
+ //# sourceMappingURL=formFooter.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formFooter.utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/FormFooter/utilities/formFooter.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGnD;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,WAAW,EAAE,gBAAgB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,KAAG,OAGhG,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { firstInvalidFieldOnPage } from '../../__internal__/formField/utilities/formFocus.utils.js';
2
+
3
+ /**
4
+ * Whether a field of the form shows an error, which is when Save is off. The form's own error under `root`, such as a
5
+ * failed save, is left out: no field edit clears it, only another submit, so it must not hold Save off.
6
+ *
7
+ * @param errors The form's `formState.errors`.
8
+ * @param fieldElements Each mounted field's element by name, inside `Form`. With it, only an error on a field still on
9
+ * the page counts: react-hook-form keeps the error of a field that has left it, and nothing on screen says how to fix that one.
10
+ * @returns `true` while at least one field shows an error.
11
+ */
12
+ const hasFieldError = (errors, fieldElements) => {
13
+ if (fieldElements)
14
+ return firstInvalidFieldOnPage(errors, fieldElements) !== undefined;
15
+ return Object.keys(errors).some((key) => key !== 'root');
16
+ };
17
+
18
+ export { hasFieldError };
19
+ //# sourceMappingURL=formFooter.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formFooter.utils.js","sources":["../../../../../src/components/forms/FormFooter/utilities/formFooter.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;;;;;;;;AAQG;MACU,aAAa,GAAG,CAAC,MAAmB,EAAE,aAA2C,KAAa;AACzG,IAAA,IAAI,aAAa;QAAE,OAAO,uBAAuB,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,SAAS;AACtF,IAAA,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,KAAK,MAAM,CAAC;AAC1D;;"}
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var cx = require('@flipdish/ui-library/utilities/cx');
4
+
5
+ /** Shared by the section and its skeleton, so the placeholder holds the columns the loaded form lands in. */
6
+ const styles = cx.sortCx({
7
+ root: 'flex flex-col gap-5 lg:flex-row lg:gap-8',
8
+ labelColumn: 'flex flex-col lg:w-70 lg:shrink-0',
9
+ fieldColumn: 'flex w-full max-w-128 min-w-0 flex-col gap-5',
10
+ row: 'flex flex-col gap-5 sm:flex-row sm:*:min-w-0 sm:*:flex-1',
11
+ stack: 'flex w-full flex-col gap-6',
12
+ });
13
+
14
+ exports.styles = styles;
15
+ //# sourceMappingURL=FormSection.styles.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormSection.styles.cjs","sources":["../../../../src/components/forms/FormSection/FormSection.styles.ts"],"sourcesContent":[null],"names":["sortCx"],"mappings":";;;;AAEA;AACO,MAAM,MAAM,GAAGA,SAAM,CAAC;AAC3B,IAAA,IAAI,EAAE,0CAA0C;AAChD,IAAA,WAAW,EAAE,mCAAmC;AAChD,IAAA,WAAW,EAAE,8CAA8C;AAC3D,IAAA,GAAG,EAAE,0DAA0D;AAC/D,IAAA,KAAK,EAAE,4BAA4B;AACpC,CAAA;;"}
@@ -0,0 +1,9 @@
1
+ /** Shared by the section and its skeleton, so the placeholder holds the columns the loaded form lands in. */
2
+ export declare const styles: {
3
+ root: string;
4
+ labelColumn: string;
5
+ fieldColumn: string;
6
+ row: string;
7
+ stack: string;
8
+ };
9
+ //# sourceMappingURL=FormSection.styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormSection.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/FormSection/FormSection.styles.ts"],"names":[],"mappings":"AAEA,6GAA6G;AAC7G,eAAO,MAAM,MAAM;;;;;;CAMjB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { sortCx } from '@flipdish/ui-library/utilities/cx';
2
+
3
+ /** Shared by the section and its skeleton, so the placeholder holds the columns the loaded form lands in. */
4
+ const styles = sortCx({
5
+ root: 'flex flex-col gap-5 lg:flex-row lg:gap-8',
6
+ labelColumn: 'flex flex-col lg:w-70 lg:shrink-0',
7
+ fieldColumn: 'flex w-full max-w-128 min-w-0 flex-col gap-5',
8
+ row: 'flex flex-col gap-5 sm:flex-row sm:*:min-w-0 sm:*:flex-1',
9
+ stack: 'flex w-full flex-col gap-6',
10
+ });
11
+
12
+ export { styles };
13
+ //# sourceMappingURL=FormSection.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormSection.styles.js","sources":["../../../../src/components/forms/FormSection/FormSection.styles.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;AACO,MAAM,MAAM,GAAG,MAAM,CAAC;AAC3B,IAAA,IAAI,EAAE,0CAA0C;AAChD,IAAA,WAAW,EAAE,mCAAmC;AAChD,IAAA,WAAW,EAAE,8CAA8C;AAC3D,IAAA,GAAG,EAAE,0DAA0D;AAC/D,IAAA,KAAK,EAAE,4BAA4B;AACpC,CAAA;;"}
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var Divider = require('@flipdish/ui-library/components/atoms/Divider');
5
+ var Skeleton = require('@flipdish/ui-library/components/atoms/Skeleton');
6
+ var SectionHeader = require('@flipdish/ui-library/components/molecules/SectionHeader');
7
+ var cx = require('@flipdish/ui-library/utilities/cx');
8
+ var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
9
+ var React = require('react');
10
+ var FormSection_styles = require('./FormSection.styles.cjs');
11
+
12
+ /** Upper bound on placeholder sections and fields, guarding against a malformed count. */
13
+ const MAX_SKELETON_COUNT = 12;
14
+ const toCount = (count) => (Number.isFinite(count) ? Math.min(Math.max(Math.trunc(count), 0), MAX_SKELETON_COUNT) : 0);
15
+ /** Puts two short fields on one line, such as a city and its postcode. */
16
+ const FormSectionRow = ({ children, className }) => jsxRuntime.jsx("div", { className: cx.cx(FormSection_styles.styles.row, className), children: children });
17
+ /** The placeholder a form shows while its values load, in the same two columns as its sections, so nothing shifts when they arrive. */
18
+ const FormSectionSkeleton = ({ label, sectionCount = 2, fieldCount = 3, 'data-testid': dataTestId }) => {
19
+ const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'form-section-skeleton', rootName: 'form-section-skeleton' });
20
+ const sections = Array.from({ length: toCount(sectionCount) }, (_, index) => index);
21
+ const fields = Array.from({ length: toCount(fieldCount) }, (_, index) => index);
22
+ // Filled in after it mounts, and kept outside the busy region: a status region that arrives already filled is not
23
+ // reliably announced, and a screen reader may hold back what changes inside a busy one.
24
+ const [announcement, setAnnouncement] = React.useState('');
25
+ React.useEffect(() => setAnnouncement(label), [label]);
26
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("output", { className: "sr-only", children: announcement }), jsxRuntime.jsx("div", { "aria-busy": "true", "data-testid": rootTestId, className: FormSection_styles.styles.stack, children: sections.map((section) => (jsxRuntime.jsxs(React.Fragment, { children: [section > 0 && jsxRuntime.jsx(Divider.Divider, {}), jsxRuntime.jsxs("div", { className: FormSection_styles.styles.root, children: [jsxRuntime.jsxs("div", { className: cx.cx(FormSection_styles.styles.labelColumn, 'gap-2'), children: [jsxRuntime.jsx(Skeleton.Skeleton, { width: "40%", height: 20 }), jsxRuntime.jsx(Skeleton.SkeletonText, { lines: 2 })] }), jsxRuntime.jsx("div", { className: FormSection_styles.styles.fieldColumn, children: fields.map((field) => (jsxRuntime.jsx(Skeleton.Skeleton, { height: 44 }, field))) })] })] }, section))) })] }));
27
+ };
28
+ /**
29
+ * One titled section of a form: its name and description in a column on the left, its fields on the right, stacked
30
+ * below `lg`. Use one per group of related fields, with a `Divider` between sections.
31
+ *
32
+ * @summary titled form section with a label column and a field column
33
+ */
34
+ const FormSection = ({ title, description, children, className, 'data-testid': dataTestId }) => {
35
+ const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'form-section', rootName: 'form-section' });
36
+ const headingId = React.useId();
37
+ return (jsxRuntime.jsxs("section", { "aria-labelledby": headingId, "data-testid": rootTestId, className: cx.cx(FormSection_styles.styles.root, className), children: [jsxRuntime.jsx(testIdUtils.TestIdProvider, { value: rootTestId, children: jsxRuntime.jsxs("div", { className: cx.cx(FormSection_styles.styles.labelColumn, 'gap-1'), children: [jsxRuntime.jsx(SectionHeader.SectionHeader.Heading, { id: headingId, children: title }), description && jsxRuntime.jsx(SectionHeader.SectionHeader.Subheading, { children: description })] }) }), jsxRuntime.jsx("div", { "data-testid": testIdUtils.joinTestId(rootTestId, 'fields'), className: FormSection_styles.styles.fieldColumn, children: children })] }));
38
+ };
39
+ FormSection.Row = FormSectionRow;
40
+ FormSection.Skeleton = FormSectionSkeleton;
41
+
42
+ exports.FormSection = FormSection;
43
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/components/forms/FormSection/index.tsx"],"sourcesContent":[null],"names":["_jsx","cx","styles","useResolvedTestId","useState","useEffect","_jsxs","_Fragment","Fragment","Divider","Skeleton","SkeletonText","useId","TestIdProvider","SectionHeader","joinTestId"],"mappings":";;;;;;;;;;;AAUA;AACA,MAAM,kBAAkB,GAAG,EAAE;AAE7B,MAAM,OAAO,GAAG,CAAC,KAAa,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC;AAsB9H;AACA,MAAM,cAAc,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAuB,KAAKA,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAEC,KAAE,CAACC,yBAAM,CAAC,GAAG,EAAE,SAAS,CAAC,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAO;AAapI;AACA,MAAM,mBAAmB,GAAG,CAAC,EAAE,KAAK,EAAE,YAAY,GAAG,CAAC,EAAE,UAAU,GAAG,CAAC,EAAE,aAAa,EAAE,UAAU,EAA4B,KAAI;AAC/H,IAAA,MAAM,UAAU,GAAGC,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,uBAAuB,EAAE,CAA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