@flipdish/ui-library 0.51.0 → 0.53.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 (343) 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/useSaveForm/useSaveForm.cjs +93 -0
  20. package/dist/components/forms/Form/hooks/useSaveForm/useSaveForm.cjs.map +1 -0
  21. package/dist/components/forms/Form/hooks/useSaveForm/useSaveForm.d.ts +54 -0
  22. package/dist/components/forms/Form/hooks/useSaveForm/useSaveForm.d.ts.map +1 -0
  23. package/dist/components/forms/Form/hooks/useSaveForm/useSaveForm.js +91 -0
  24. package/dist/components/forms/Form/hooks/useSaveForm/useSaveForm.js.map +1 -0
  25. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.cjs +28 -0
  26. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.cjs.map +1 -0
  27. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.d.ts +10 -0
  28. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.d.ts.map +1 -0
  29. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.js +26 -0
  30. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.js.map +1 -0
  31. package/dist/components/forms/Form/index.cjs +63 -0
  32. package/dist/components/forms/Form/index.cjs.map +1 -0
  33. package/dist/components/forms/Form/index.d.ts +37 -0
  34. package/dist/components/forms/Form/index.d.ts.map +1 -0
  35. package/dist/components/forms/Form/index.js +59 -0
  36. package/dist/components/forms/Form/index.js.map +1 -0
  37. package/dist/components/forms/Form/utilities/formSubmit.utils.cjs +23 -0
  38. package/dist/components/forms/Form/utilities/formSubmit.utils.cjs.map +1 -0
  39. package/dist/components/forms/Form/utilities/formSubmit.utils.d.ts +14 -0
  40. package/dist/components/forms/Form/utilities/formSubmit.utils.d.ts.map +1 -0
  41. package/dist/components/forms/Form/utilities/formSubmit.utils.js +21 -0
  42. package/dist/components/forms/Form/utilities/formSubmit.utils.js.map +1 -0
  43. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.cjs +39 -0
  44. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.cjs.map +1 -0
  45. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.d.ts +17 -0
  46. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.d.ts.map +1 -0
  47. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.js +37 -0
  48. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.js.map +1 -0
  49. package/dist/components/forms/FormFooter/hooks/useHasFieldError.cjs +26 -0
  50. package/dist/components/forms/FormFooter/hooks/useHasFieldError.cjs.map +1 -0
  51. package/dist/components/forms/FormFooter/hooks/useHasFieldError.d.ts +9 -0
  52. package/dist/components/forms/FormFooter/hooks/useHasFieldError.d.ts.map +1 -0
  53. package/dist/components/forms/FormFooter/hooks/useHasFieldError.js +24 -0
  54. package/dist/components/forms/FormFooter/hooks/useHasFieldError.js.map +1 -0
  55. package/dist/components/forms/FormFooter/index.cjs +41 -0
  56. package/dist/components/forms/FormFooter/index.cjs.map +1 -0
  57. package/dist/components/forms/FormFooter/index.d.ts +56 -0
  58. package/dist/components/forms/FormFooter/index.d.ts.map +1 -0
  59. package/dist/components/forms/FormFooter/index.js +39 -0
  60. package/dist/components/forms/FormFooter/index.js.map +1 -0
  61. package/dist/components/forms/FormFooter/utilities/formFooter.utils.cjs +21 -0
  62. package/dist/components/forms/FormFooter/utilities/formFooter.utils.cjs.map +1 -0
  63. package/dist/components/forms/FormFooter/utilities/formFooter.utils.d.ts +12 -0
  64. package/dist/components/forms/FormFooter/utilities/formFooter.utils.d.ts.map +1 -0
  65. package/dist/components/forms/FormFooter/utilities/formFooter.utils.js +19 -0
  66. package/dist/components/forms/FormFooter/utilities/formFooter.utils.js.map +1 -0
  67. package/dist/components/forms/FormSaveErrorAlert/index.cjs +28 -0
  68. package/dist/components/forms/FormSaveErrorAlert/index.cjs.map +1 -0
  69. package/dist/components/forms/FormSaveErrorAlert/index.d.ts +18 -0
  70. package/dist/components/forms/FormSaveErrorAlert/index.d.ts.map +1 -0
  71. package/dist/components/forms/FormSaveErrorAlert/index.js +26 -0
  72. package/dist/components/forms/FormSaveErrorAlert/index.js.map +1 -0
  73. package/dist/components/forms/FormSection/FormSection.styles.cjs +15 -0
  74. package/dist/components/forms/FormSection/FormSection.styles.cjs.map +1 -0
  75. package/dist/components/forms/FormSection/FormSection.styles.d.ts +9 -0
  76. package/dist/components/forms/FormSection/FormSection.styles.d.ts.map +1 -0
  77. package/dist/components/forms/FormSection/FormSection.styles.js +13 -0
  78. package/dist/components/forms/FormSection/FormSection.styles.js.map +1 -0
  79. package/dist/components/forms/FormSection/index.cjs +43 -0
  80. package/dist/components/forms/FormSection/index.cjs.map +1 -0
  81. package/dist/components/forms/FormSection/index.d.ts +41 -0
  82. package/dist/components/forms/FormSection/index.d.ts.map +1 -0
  83. package/dist/components/forms/FormSection/index.js +41 -0
  84. package/dist/components/forms/FormSection/index.js.map +1 -0
  85. package/dist/components/forms/FormUnsavedChangesModal/index.cjs +24 -0
  86. package/dist/components/forms/FormUnsavedChangesModal/index.cjs.map +1 -0
  87. package/dist/components/forms/FormUnsavedChangesModal/index.d.ts +14 -0
  88. package/dist/components/forms/FormUnsavedChangesModal/index.d.ts.map +1 -0
  89. package/dist/components/forms/FormUnsavedChangesModal/index.js +22 -0
  90. package/dist/components/forms/FormUnsavedChangesModal/index.js.map +1 -0
  91. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.cjs +28 -0
  92. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.cjs.map +1 -0
  93. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.d.ts +12 -0
  94. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.d.ts.map +1 -0
  95. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.js +26 -0
  96. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.js.map +1 -0
  97. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.cjs +68 -0
  98. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.cjs.map +1 -0
  99. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.d.ts +26 -0
  100. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.d.ts.map +1 -0
  101. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.js +66 -0
  102. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.js.map +1 -0
  103. package/dist/components/forms/__internal__/formField/hooks/useFormField.cjs +147 -0
  104. package/dist/components/forms/__internal__/formField/hooks/useFormField.cjs.map +1 -0
  105. package/dist/components/forms/__internal__/formField/hooks/useFormField.d.ts +35 -0
  106. package/dist/components/forms/__internal__/formField/hooks/useFormField.d.ts.map +1 -0
  107. package/dist/components/forms/__internal__/formField/hooks/useFormField.js +145 -0
  108. package/dist/components/forms/__internal__/formField/hooks/useFormField.js.map +1 -0
  109. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.cjs +12 -0
  110. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.cjs.map +1 -0
  111. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.d.ts +7 -0
  112. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.d.ts.map +1 -0
  113. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.js +10 -0
  114. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.js.map +1 -0
  115. package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.cjs +47 -0
  116. package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.cjs.map +1 -0
  117. package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.d.ts +26 -0
  118. package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.d.ts.map +1 -0
  119. package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.js +43 -0
  120. package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.js.map +1 -0
  121. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.cjs +39 -0
  122. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.cjs.map +1 -0
  123. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.d.ts +21 -0
  124. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.d.ts.map +1 -0
  125. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.js +37 -0
  126. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.js.map +1 -0
  127. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.cjs +40 -0
  128. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.cjs.map +1 -0
  129. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.d.ts +18 -0
  130. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.d.ts.map +1 -0
  131. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.js +37 -0
  132. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.js.map +1 -0
  133. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.cjs +21 -0
  134. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.cjs.map +1 -0
  135. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.d.ts +11 -0
  136. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.d.ts.map +1 -0
  137. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.js +19 -0
  138. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.js.map +1 -0
  139. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.cjs +128 -0
  140. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.cjs.map +1 -0
  141. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.d.ts +72 -0
  142. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.d.ts.map +1 -0
  143. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.js +121 -0
  144. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.js.map +1 -0
  145. package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.cjs +12 -0
  146. package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.cjs.map +1 -0
  147. package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.d.ts +6 -0
  148. package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.d.ts.map +1 -0
  149. package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.js +10 -0
  150. package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.js.map +1 -0
  151. package/dist/components/forms/fields/FormCheckbox/index.cjs +34 -0
  152. package/dist/components/forms/fields/FormCheckbox/index.cjs.map +1 -0
  153. package/dist/components/forms/fields/FormCheckbox/index.d.ts +19 -0
  154. package/dist/components/forms/fields/FormCheckbox/index.d.ts.map +1 -0
  155. package/dist/components/forms/fields/FormCheckbox/index.js +32 -0
  156. package/dist/components/forms/fields/FormCheckbox/index.js.map +1 -0
  157. package/dist/components/forms/fields/FormCheckboxGroup/index.cjs +33 -0
  158. package/dist/components/forms/fields/FormCheckboxGroup/index.cjs.map +1 -0
  159. package/dist/components/forms/fields/FormCheckboxGroup/index.d.ts +19 -0
  160. package/dist/components/forms/fields/FormCheckboxGroup/index.d.ts.map +1 -0
  161. package/dist/components/forms/fields/FormCheckboxGroup/index.js +31 -0
  162. package/dist/components/forms/fields/FormCheckboxGroup/index.js.map +1 -0
  163. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.cjs +26 -0
  164. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.cjs.map +1 -0
  165. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.d.ts +11 -0
  166. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.d.ts.map +1 -0
  167. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.js +24 -0
  168. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.js.map +1 -0
  169. package/dist/components/forms/fields/FormColorPicker/index.cjs +33 -0
  170. package/dist/components/forms/fields/FormColorPicker/index.cjs.map +1 -0
  171. package/dist/components/forms/fields/FormColorPicker/index.d.ts +24 -0
  172. package/dist/components/forms/fields/FormColorPicker/index.d.ts.map +1 -0
  173. package/dist/components/forms/fields/FormColorPicker/index.js +31 -0
  174. package/dist/components/forms/fields/FormColorPicker/index.js.map +1 -0
  175. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.cjs +20 -0
  176. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.cjs.map +1 -0
  177. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.d.ts +17 -0
  178. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.d.ts.map +1 -0
  179. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.js +18 -0
  180. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.js.map +1 -0
  181. package/dist/components/forms/fields/FormDatePicker/index.cjs +35 -0
  182. package/dist/components/forms/fields/FormDatePicker/index.cjs.map +1 -0
  183. package/dist/components/forms/fields/FormDatePicker/index.d.ts +20 -0
  184. package/dist/components/forms/fields/FormDatePicker/index.d.ts.map +1 -0
  185. package/dist/components/forms/fields/FormDatePicker/index.js +33 -0
  186. package/dist/components/forms/fields/FormDatePicker/index.js.map +1 -0
  187. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.cjs +23 -0
  188. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.cjs.map +1 -0
  189. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.d.ts +9 -0
  190. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.d.ts.map +1 -0
  191. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.js +21 -0
  192. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.js.map +1 -0
  193. package/dist/components/forms/fields/FormInput/index.cjs +27 -0
  194. package/dist/components/forms/fields/FormInput/index.cjs.map +1 -0
  195. package/dist/components/forms/fields/FormInput/index.d.ts +19 -0
  196. package/dist/components/forms/fields/FormInput/index.d.ts.map +1 -0
  197. package/dist/components/forms/fields/FormInput/index.js +25 -0
  198. package/dist/components/forms/fields/FormInput/index.js.map +1 -0
  199. package/dist/components/forms/fields/FormMultiSelect/index.cjs +44 -0
  200. package/dist/components/forms/fields/FormMultiSelect/index.cjs.map +1 -0
  201. package/dist/components/forms/fields/FormMultiSelect/index.d.ts +20 -0
  202. package/dist/components/forms/fields/FormMultiSelect/index.d.ts.map +1 -0
  203. package/dist/components/forms/fields/FormMultiSelect/index.js +42 -0
  204. package/dist/components/forms/fields/FormMultiSelect/index.js.map +1 -0
  205. package/dist/components/forms/fields/FormRadioCardGroup/index.cjs +36 -0
  206. package/dist/components/forms/fields/FormRadioCardGroup/index.cjs.map +1 -0
  207. package/dist/components/forms/fields/FormRadioCardGroup/index.d.ts +32 -0
  208. package/dist/components/forms/fields/FormRadioCardGroup/index.d.ts.map +1 -0
  209. package/dist/components/forms/fields/FormRadioCardGroup/index.js +34 -0
  210. package/dist/components/forms/fields/FormRadioCardGroup/index.js.map +1 -0
  211. package/dist/components/forms/fields/FormRadioGroup/index.cjs +31 -0
  212. package/dist/components/forms/fields/FormRadioGroup/index.cjs.map +1 -0
  213. package/dist/components/forms/fields/FormRadioGroup/index.d.ts +20 -0
  214. package/dist/components/forms/fields/FormRadioGroup/index.d.ts.map +1 -0
  215. package/dist/components/forms/fields/FormRadioGroup/index.js +29 -0
  216. package/dist/components/forms/fields/FormRadioGroup/index.js.map +1 -0
  217. package/dist/components/forms/fields/FormSelect/index.cjs +30 -0
  218. package/dist/components/forms/fields/FormSelect/index.cjs.map +1 -0
  219. package/dist/components/forms/fields/FormSelect/index.d.ts +19 -0
  220. package/dist/components/forms/fields/FormSelect/index.d.ts.map +1 -0
  221. package/dist/components/forms/fields/FormSelect/index.js +28 -0
  222. package/dist/components/forms/fields/FormSelect/index.js.map +1 -0
  223. package/dist/components/forms/fields/FormSlider/index.cjs +43 -0
  224. package/dist/components/forms/fields/FormSlider/index.cjs.map +1 -0
  225. package/dist/components/forms/fields/FormSlider/index.d.ts +20 -0
  226. package/dist/components/forms/fields/FormSlider/index.d.ts.map +1 -0
  227. package/dist/components/forms/fields/FormSlider/index.js +41 -0
  228. package/dist/components/forms/fields/FormSlider/index.js.map +1 -0
  229. package/dist/components/forms/fields/FormTextArea/index.cjs +27 -0
  230. package/dist/components/forms/fields/FormTextArea/index.cjs.map +1 -0
  231. package/dist/components/forms/fields/FormTextArea/index.d.ts +19 -0
  232. package/dist/components/forms/fields/FormTextArea/index.d.ts.map +1 -0
  233. package/dist/components/forms/fields/FormTextArea/index.js +25 -0
  234. package/dist/components/forms/fields/FormTextArea/index.js.map +1 -0
  235. package/dist/components/forms/fields/FormToggle/index.cjs +32 -0
  236. package/dist/components/forms/fields/FormToggle/index.cjs.map +1 -0
  237. package/dist/components/forms/fields/FormToggle/index.d.ts +19 -0
  238. package/dist/components/forms/fields/FormToggle/index.d.ts.map +1 -0
  239. package/dist/components/forms/fields/FormToggle/index.js +30 -0
  240. package/dist/components/forms/fields/FormToggle/index.js.map +1 -0
  241. package/dist/components/forms/validation/hooks/useSchemaResolver.cjs +44 -0
  242. package/dist/components/forms/validation/hooks/useSchemaResolver.cjs.map +1 -0
  243. package/dist/components/forms/validation/hooks/useSchemaResolver.d.ts +16 -0
  244. package/dist/components/forms/validation/hooks/useSchemaResolver.d.ts.map +1 -0
  245. package/dist/components/forms/validation/hooks/useSchemaResolver.js +42 -0
  246. package/dist/components/forms/validation/hooks/useSchemaResolver.js.map +1 -0
  247. package/dist/components/forms/validation/index.cjs +413 -0
  248. package/dist/components/forms/validation/index.cjs.map +1 -0
  249. package/dist/components/forms/validation/index.d.ts +278 -0
  250. package/dist/components/forms/validation/index.d.ts.map +1 -0
  251. package/dist/components/forms/validation/index.js +394 -0
  252. package/dist/components/forms/validation/index.js.map +1 -0
  253. package/dist/components/forms/validation/utilities/validation.utils.cjs +72 -0
  254. package/dist/components/forms/validation/utilities/validation.utils.cjs.map +1 -0
  255. package/dist/components/forms/validation/utilities/validation.utils.d.ts +38 -0
  256. package/dist/components/forms/validation/utilities/validation.utils.d.ts.map +1 -0
  257. package/dist/components/forms/validation/utilities/validation.utils.js +67 -0
  258. package/dist/components/forms/validation/utilities/validation.utils.js.map +1 -0
  259. package/dist/components/forms/validation/validation.types.d.ts +8 -0
  260. package/dist/components/forms/validation/validation.types.d.ts.map +1 -0
  261. package/dist/components/organisms/ColorPicker/components/ColorPickerField.cjs +13 -3
  262. package/dist/components/organisms/ColorPicker/components/ColorPickerField.cjs.map +1 -1
  263. package/dist/components/organisms/ColorPicker/components/ColorPickerField.d.ts +1 -1
  264. package/dist/components/organisms/ColorPicker/components/ColorPickerField.d.ts.map +1 -1
  265. package/dist/components/organisms/ColorPicker/components/ColorPickerField.js +13 -3
  266. package/dist/components/organisms/ColorPicker/components/ColorPickerField.js.map +1 -1
  267. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.cjs +2 -2
  268. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.cjs.map +1 -1
  269. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.d.ts +1 -0
  270. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.d.ts.map +1 -1
  271. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.js +2 -2
  272. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.js.map +1 -1
  273. package/dist/components/organisms/ColorPicker/hooks/useCssColorField.cjs +1 -1
  274. package/dist/components/organisms/ColorPicker/hooks/useCssColorField.js +1 -1
  275. package/dist/components/organisms/ColorPicker/index.cjs +1 -1
  276. package/dist/components/organisms/ColorPicker/index.d.ts.map +1 -1
  277. package/dist/components/organisms/ColorPicker/index.js +1 -1
  278. package/dist/components/organisms/ColorPicker/providers/ColorPicker.provider.d.ts +1 -1
  279. package/dist/components/organisms/ColorPicker/providers/ColorPicker.provider.d.ts.map +1 -1
  280. package/dist/components/organisms/ColorPicker/utilities/colorPicker.utils.cjs.map +1 -0
  281. package/dist/components/organisms/ColorPicker/utilities/colorPicker.utils.d.ts.map +1 -0
  282. package/dist/components/organisms/ColorPicker/utilities/colorPicker.utils.js.map +1 -0
  283. package/dist/components/organisms/GradientPicker/components/GradientStopRow.cjs +1 -1
  284. package/dist/components/organisms/GradientPicker/components/GradientStopRow.js +1 -1
  285. package/dist/hooks/useFocusAfterRetry/index.cjs +7 -3
  286. package/dist/hooks/useFocusAfterRetry/index.cjs.map +1 -1
  287. package/dist/hooks/useFocusAfterRetry/index.d.ts +8 -2
  288. package/dist/hooks/useFocusAfterRetry/index.d.ts.map +1 -1
  289. package/dist/hooks/useFocusAfterRetry/index.js +7 -3
  290. package/dist/hooks/useFocusAfterRetry/index.js.map +1 -1
  291. package/dist/localization/en.json.cjs +117 -0
  292. package/dist/localization/en.json.cjs.map +1 -0
  293. package/dist/localization/en.json.js +98 -0
  294. package/dist/localization/en.json.js.map +1 -0
  295. package/dist/native/components/forms/Form/index.d.ts +12 -0
  296. package/dist/native/components/forms/FormFooter/index.d.ts +12 -0
  297. package/dist/native/components/forms/FormSaveErrorAlert/index.d.ts +12 -0
  298. package/dist/native/components/forms/FormSection/index.d.ts +12 -0
  299. package/dist/native/components/forms/FormUnsavedChangesModal/index.d.ts +12 -0
  300. package/dist/native/components/forms/fields/FormCheckbox/index.d.ts +12 -0
  301. package/dist/native/components/forms/fields/FormCheckboxGroup/index.d.ts +12 -0
  302. package/dist/native/components/forms/fields/FormColorPicker/index.d.ts +12 -0
  303. package/dist/native/components/forms/fields/FormDatePicker/index.d.ts +12 -0
  304. package/dist/native/components/forms/fields/FormInput/index.d.ts +12 -0
  305. package/dist/native/components/forms/fields/FormMultiSelect/index.d.ts +12 -0
  306. package/dist/native/components/forms/fields/FormRadioCardGroup/index.d.ts +12 -0
  307. package/dist/native/components/forms/fields/FormRadioGroup/index.d.ts +12 -0
  308. package/dist/native/components/forms/fields/FormSelect/index.d.ts +12 -0
  309. package/dist/native/components/forms/fields/FormSlider/index.d.ts +12 -0
  310. package/dist/native/components/forms/fields/FormTextArea/index.d.ts +12 -0
  311. package/dist/native/components/forms/fields/FormToggle/index.d.ts +12 -0
  312. package/dist/native/components/forms/validation/index.d.ts +12 -0
  313. package/dist/native/utilities/colorUtils/index.d.ts +12 -0
  314. package/dist/providers/UnsavedChangesGuardProvider/index.cjs +1 -1
  315. package/dist/providers/UnsavedChangesGuardProvider/index.js +1 -1
  316. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.cjs.map +1 -0
  317. package/dist/providers/UnsavedChangesGuardProvider/{unsavedChangesGuard.utils.d.ts → utilities/unsavedChangesGuard.utils.d.ts} +1 -1
  318. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.d.ts.map +1 -0
  319. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.js.map +1 -0
  320. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.cjs +74 -0
  321. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.cjs.map +1 -0
  322. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.d.ts +51 -0
  323. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.d.ts.map +1 -0
  324. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.js +68 -0
  325. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.js.map +1 -0
  326. package/dist/utilities/colorUtils/index.cjs +24 -0
  327. package/dist/utilities/colorUtils/index.cjs.map +1 -0
  328. package/dist/utilities/colorUtils/index.d.ts +8 -0
  329. package/dist/utilities/colorUtils/index.d.ts.map +1 -0
  330. package/dist/utilities/colorUtils/index.js +22 -0
  331. package/dist/utilities/colorUtils/index.js.map +1 -0
  332. package/package.json +41 -6
  333. package/dist/components/organisms/ColorPicker/colorPicker.utils.cjs.map +0 -1
  334. package/dist/components/organisms/ColorPicker/colorPicker.utils.d.ts.map +0 -1
  335. package/dist/components/organisms/ColorPicker/colorPicker.utils.js.map +0 -1
  336. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.utils.cjs.map +0 -1
  337. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.utils.d.ts.map +0 -1
  338. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.utils.js.map +0 -1
  339. /package/dist/components/organisms/ColorPicker/{colorPicker.utils.cjs → utilities/colorPicker.utils.cjs} +0 -0
  340. /package/dist/components/organisms/ColorPicker/{colorPicker.utils.d.ts → utilities/colorPicker.utils.d.ts} +0 -0
  341. /package/dist/components/organisms/ColorPicker/{colorPicker.utils.js → utilities/colorPicker.utils.js} +0 -0
  342. /package/dist/providers/UnsavedChangesGuardProvider/{unsavedChangesGuard.utils.cjs → utilities/unsavedChangesGuard.utils.cjs} +0 -0
  343. /package/dist/providers/UnsavedChangesGuardProvider/{unsavedChangesGuard.utils.js → utilities/unsavedChangesGuard.utils.js} +0 -0
@@ -0,0 +1,91 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { useForm } from '../useForm.js';
3
+
4
+ // A refetch brings newer values: the fields the user has edited keep the draft, the rest follow the server. The errors
5
+ // on screen and the dirty flag stay too, or a refetch would hide a rejection and switch Save off for a moment.
6
+ const FOLLOW_REFETCH = { keepDirtyValues: true, keepErrors: true, keepDirty: true };
7
+ // A save and Discard start the form again: `resetOptions` reaches each `reset` call, and would keep the edits and errors.
8
+ const START_AGAIN = { keepDirtyValues: false, keepErrors: false, keepDirty: false };
9
+ // A mapper written for the server's rejections may not expect a network failure, and one that threw would leave the save in flight for good.
10
+ const rejectedFieldOf = (fieldErrorOf, error) => {
11
+ try {
12
+ return fieldErrorOf?.(error);
13
+ }
14
+ catch {
15
+ return undefined;
16
+ }
17
+ };
18
+ /**
19
+ * Creates a form that waits on Save, and owns what happens around the save: it starts again from what was saved, keeps
20
+ * a draft through a refetch, holds a refetch that lands mid-save, and reports a failure beside Save or beneath the field
21
+ * the server rejected. Use it in place of `useForm` for a form with `FormFooter`, mounted once per record: give the
22
+ * form's component a `key` of the record's id, so another record never inherits this one's save.
23
+ *
24
+ * @param options Every option this module's `useForm` takes except `resetOptions`, with `save` and `fieldErrorOf`; see
25
+ * `UseSaveFormOptions`. Pass the loaded record as `values`, so the fields the user has not edited follow a refetch.
26
+ * @returns The form and its save state, with one handler per action; see `UseSaveFormReturn`. "Try again" has none:
27
+ * `FormSaveErrorAlert` submits the form itself, as Save does.
28
+ */
29
+ // biome-ignore lint/suspicious/noExplicitAny: mirrors react-hook-form's own `TContext = any`, so the two signatures stay interchangeable
30
+ const useSaveForm = ({ save, fieldErrorOf, values, ...options }) => {
31
+ const [saveState, setSaveState] = useState({ status: 'idle' });
32
+ const isSaving = saveState.status === 'saving';
33
+ const form = useForm({
34
+ ...options,
35
+ // Held while a save is in flight: a refetch landing then would reset the form, which ends the lock on its fields.
36
+ values: isSaving ? undefined : values,
37
+ resetOptions: FOLLOW_REFETCH,
38
+ });
39
+ const { reset, setError, getValues } = form;
40
+ const { isDirty, errors } = form.formState;
41
+ // The saved check ends with the next edit, for good: undoing that edit by hand must not bring it back with nothing saved.
42
+ const hasSaved = saveState.status === 'saved';
43
+ useEffect(() => {
44
+ if (isDirty && hasSaved)
45
+ setSaveState({ status: 'idle' });
46
+ }, [isDirty, hasSaved]);
47
+ const rejectedField = saveState.status === 'failed' ? saveState.rejectedField : undefined;
48
+ // Set once the save has settled, not as it fails: the fields are still locked then, and a locked control refuses focus.
49
+ useEffect(() => {
50
+ if (rejectedField)
51
+ setError(rejectedField.field, { type: 'server', message: rejectedField.message }, { shouldFocus: true });
52
+ }, [rejectedField, setError]);
53
+ // Awaited by `Form`, so the form counts as submitting until the save lands, which locks its fields.
54
+ const submit = async (submitted) => {
55
+ setSaveState({ status: 'saving' });
56
+ try {
57
+ await save(submitted);
58
+ }
59
+ catch (error) {
60
+ return setSaveState({ status: 'failed', error, rejectedField: rejectedFieldOf(fieldErrorOf, error) });
61
+ }
62
+ // What the form holds is what was sent: the resolved value may be any shape, and the saved record arrives through `values`.
63
+ reset(getValues(), START_AGAIN);
64
+ return setSaveState({ status: 'saved' });
65
+ };
66
+ const discard = () => {
67
+ // Mid-save it would end the hold on `values`, and a refetch landing then would unlock the fields.
68
+ if (isSaving)
69
+ return;
70
+ reset(undefined, START_AGAIN);
71
+ setSaveState({ status: 'idle' });
72
+ };
73
+ // Only a failure is dismissed: clearing a save in flight would end the hold on `values` too.
74
+ const dismissSaveError = () => setSaveState((current) => (current.status === 'failed' ? { status: 'idle' } : current));
75
+ const hasErrors = Object.keys(errors).length > 0;
76
+ const hasSaveError = saveState.status === 'failed' && !rejectedField;
77
+ return {
78
+ form,
79
+ submit,
80
+ discard,
81
+ isSaving,
82
+ // The saved check lasts until the next edit, or until an error shows.
83
+ isSaved: hasSaved && !isDirty && !hasErrors,
84
+ hasSaveError,
85
+ saveError: saveState.status === 'failed' && hasSaveError ? saveState.error : undefined,
86
+ dismissSaveError,
87
+ };
88
+ };
89
+
90
+ export { useSaveForm };
91
+ //# sourceMappingURL=useSaveForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSaveForm.js","sources":["../../../../../../src/components/forms/Form/hooks/useSaveForm/useSaveForm.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAsDA;AACA;AACA,MAAM,cAAc,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;AAEnF;AACA,MAAM,WAAW,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE;AAEnF;AACA,MAAM,eAAe,GAAG,CACtB,YAAyD,EACzD,KAAc,KACyB;AACvC,IAAA,IAAI;AACF,QAAA,OAAO,YAAY,GAAG,KAAK,CAAC;IAC9B;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,SAAS;IAClB;AACF,CAAC;AAED;;;;;;;;;;AAUG;AACH;AACO,MAAM,WAAW,GAAG,CAAqF,EAC9G,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,GAAG,OAAO,EAC2C,KAAyD;AAC9G,IAAA,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAqB,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAClF,IAAA,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,KAAK,QAAQ;IAE9C,MAAM,IAAI,GAAG,OAAO,CAAmC;AACrD,QAAA,GAAG,OAAO;;QAEV,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM;AACrC,QAAA,YAAY,EAAE,cAAc;AAC7B,KAAA,CAAC;IACF,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI;IAC3C,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS;;AAG1C,IAAA,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,KAAK,OAAO;IAC7C,SAAS,CAAC,MAAK;QACb,IAAI,OAAO,IAAI,QAAQ;AAAE,YAAA,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC3D,IAAA,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAEvB,IAAA,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,KAAK,QAAQ,GAAG,SAAS,CAAC,aAAa,GAAG,SAAS;;IAEzF,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,aAAa;YAAE,QAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AAC7H,IAAA,CAAC,EAAE,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;;AAG7B,IAAA,MAAM,MAAM,GAAiC,OAAO,SAAS,KAAI;AAC/D,QAAA,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAClC,QAAA,IAAI;AACF,YAAA,MAAM,IAAI,CAAC,SAAS,CAAC;QACvB;QAAE,OAAO,KAAK,EAAE;AACd,YAAA,OAAO,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,eAAe,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;QACvG;;AAEA,QAAA,KAAK,CAAC,SAAS,EAAE,EAAE,WAAW,CAAC;QAC/B,OAAO,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC1C,IAAA,CAAC;IACD,MAAM,OAAO,GAAG,MAAK;;AAEnB,QAAA,IAAI,QAAQ;YAAE;AACd,QAAA,KAAK,CAAC,SAAS,EAAE,WAAW,CAAC;AAC7B,QAAA,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAClC,IAAA,CAAC;;AAED,IAAA,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,CAAC,OAAO,MAAM,OAAO,CAAC,MAAM,KAAK,QAAQ,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;AAEtH,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC;IAChD,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,aAAa;IAEpE,OAAO;QACL,IAAI;QACJ,MAAM;QACN,OAAO;QACP,QAAQ;;AAER,QAAA,OAAO,EAAE,QAAQ,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS;QAC3C,YAAY;AACZ,QAAA,SAAS,EAAE,SAAS,CAAC,MAAM,KAAK,QAAQ,IAAI,YAAY,GAAG,SAAS,CAAC,KAAK,GAAG,SAAS;QACtF,gBAAgB;KACjB;AACH;;"}
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ /**
6
+ * Wraps a form's submit handler so a second submit is ignored while the first is still running, as Enter in a field
7
+ * can send one. The first to finish would otherwise unlock the fields for both, while the second save was still running.
8
+ *
9
+ * @param submit Runs the submit, such as react-hook-form's `handleSubmit(onSubmit)`; its promise is how long the submit lasts.
10
+ * @returns The handler for the form's `onSubmit`. It cancels the event of a submit it ignores, and returns the promise of one it runs, which rejects as `submit`'s does so a failed submit is still reported.
11
+ */
12
+ const useSubmitInTurn = (submit) => {
13
+ // A ref, not the form's state: Enter in a field can submit twice before the first submit has rendered as submitting.
14
+ const isSubmitting = React.useRef(false);
15
+ return React.useCallback((event) => {
16
+ if (isSubmitting.current) {
17
+ event.preventDefault();
18
+ return undefined;
19
+ }
20
+ isSubmitting.current = true;
21
+ return submit(event).finally(() => {
22
+ isSubmitting.current = false;
23
+ });
24
+ }, [submit]);
25
+ };
26
+
27
+ exports.useSubmitInTurn = useSubmitInTurn;
28
+ //# sourceMappingURL=useSubmitInTurn.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSubmitInTurn.cjs","sources":["../../../../../../src/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.ts"],"sourcesContent":[null],"names":["useRef","useCallback"],"mappings":";;;;AAEA;;;;;;AAMG;AACI,MAAM,eAAe,GAAG,CAAC,MAA+D,KAAI;;AAEjG,IAAA,MAAM,YAAY,GAAGA,YAAM,CAAC,KAAK,CAAC;AAElC,IAAA,OAAOC,iBAAW,CAChB,CAAC,KAAiC,KAAI;AACpC,QAAA,IAAI,YAAY,CAAC,OAAO,EAAE;YACxB,KAAK,CAAC,cAAc,EAAE;AACtB,YAAA,OAAO,SAAS;QAClB;AACA,QAAA,YAAY,CAAC,OAAO,GAAG,IAAI;QAC3B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAK;AAChC,YAAA,YAAY,CAAC,OAAO,GAAG,KAAK;AAC9B,QAAA,CAAC,CAAC;AACJ,IAAA,CAAC,EACD,CAAC,MAAM,CAAC,CACT;AACH;;"}
@@ -0,0 +1,10 @@
1
+ import { type FormEvent } from 'react';
2
+ /**
3
+ * Wraps a form's submit handler so a second submit is ignored while the first is still running, as Enter in a field
4
+ * can send one. The first to finish would otherwise unlock the fields for both, while the second save was still running.
5
+ *
6
+ * @param submit Runs the submit, such as react-hook-form's `handleSubmit(onSubmit)`; its promise is how long the submit lasts.
7
+ * @returns The handler for the form's `onSubmit`. It cancels the event of a submit it ignores, and returns the promise of one it runs, which rejects as `submit`'s does so a failed submit is still reported.
8
+ */
9
+ export declare const useSubmitInTurn: (submit: (event: FormEvent<HTMLFormElement>) => Promise<unknown>) => (event: FormEvent<HTMLFormElement>) => Promise<unknown> | undefined;
10
+ //# sourceMappingURL=useSubmitInTurn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSubmitInTurn.d.ts","sourceRoot":"","sources":["../../../../../../src/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAE5D;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,aAKnF,SAAS,CAAC,eAAe,CAAC,iCAYrC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { useRef, useCallback } from 'react';
2
+
3
+ /**
4
+ * Wraps a form's submit handler so a second submit is ignored while the first is still running, as Enter in a field
5
+ * can send one. The first to finish would otherwise unlock the fields for both, while the second save was still running.
6
+ *
7
+ * @param submit Runs the submit, such as react-hook-form's `handleSubmit(onSubmit)`; its promise is how long the submit lasts.
8
+ * @returns The handler for the form's `onSubmit`. It cancels the event of a submit it ignores, and returns the promise of one it runs, which rejects as `submit`'s does so a failed submit is still reported.
9
+ */
10
+ const useSubmitInTurn = (submit) => {
11
+ // A ref, not the form's state: Enter in a field can submit twice before the first submit has rendered as submitting.
12
+ const isSubmitting = useRef(false);
13
+ return useCallback((event) => {
14
+ if (isSubmitting.current) {
15
+ event.preventDefault();
16
+ return undefined;
17
+ }
18
+ isSubmitting.current = true;
19
+ return submit(event).finally(() => {
20
+ isSubmitting.current = false;
21
+ });
22
+ }, [submit]);
23
+ };
24
+
25
+ export { useSubmitInTurn };
26
+ //# sourceMappingURL=useSubmitInTurn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSubmitInTurn.js","sources":["../../../../../../src/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;AAMG;AACI,MAAM,eAAe,GAAG,CAAC,MAA+D,KAAI;;AAEjG,IAAA,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC;AAElC,IAAA,OAAO,WAAW,CAChB,CAAC,KAAiC,KAAI;AACpC,QAAA,IAAI,YAAY,CAAC,OAAO,EAAE;YACxB,KAAK,CAAC,cAAc,EAAE;AACtB,YAAA,OAAO,SAAS;QAClB;AACA,QAAA,YAAY,CAAC,OAAO,GAAG,IAAI;QAC3B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAK;AAChC,YAAA,YAAY,CAAC,OAAO,GAAG,KAAK;AAC9B,QAAA,CAAC,CAAC;AACJ,IAAA,CAAC,EACD,CAAC,MAAM,CAAC,CACT;AACH;;"}
@@ -0,0 +1,63 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var cx = require('@flipdish/ui-library/utilities/cx');
5
+ var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
6
+ var React = require('react');
7
+ var reactHookForm = require('react-hook-form');
8
+ var FieldElements_context = require('../__internal__/formField/providers/FieldElements.context.cjs');
9
+ var fieldElements_utils = require('../__internal__/formField/utilities/fieldElements.utils.cjs');
10
+ var formFocus_utils = require('../__internal__/formField/utilities/formFocus.utils.cjs');
11
+ var FormSubmit_context = require('../__internal__/formSubmit/providers/FormSubmit.context.cjs');
12
+ var useSubmitInTurn = require('./hooks/useSubmitInTurn/useSubmitInTurn.cjs');
13
+ var formSubmit_utils = require('./utilities/formSubmit.utils.cjs');
14
+ var useForm = require('./hooks/useForm.cjs');
15
+ var useSaveForm = require('./hooks/useSaveForm/useSaveForm.cjs');
16
+
17
+ /** Wraps a form's fields and marks them busy while the form submits, which is when they lock themselves. */
18
+ const FormFields = (props) => {
19
+ const { isSubmitting } = reactHookForm.useFormState();
20
+ return jsxRuntime.jsx("div", { ...props, "aria-busy": isSubmitting });
21
+ };
22
+ /**
23
+ * The `<form>` around `Form*` fields: it provides the react-hook-form form to them, leaves validation to the schema,
24
+ * focuses the first invalid field in page order after a failed submit, and ignores a second submit while one is running.
25
+ * Use one per form.
26
+ *
27
+ * @summary form element that provides a react-hook-form form to its fields
28
+ */
29
+ const Form = ({ form, onSubmit, onInvalid, ref, className, children, 'data-testid': dataTestId, ...formProps }) => {
30
+ const formTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'form', rootName: 'form' });
31
+ const [fieldElements] = React.useState(fieldElements_utils.createFieldElements);
32
+ // Kept beside the caller's ref: a retry inside the form submits this element, whether or not the caller holds one.
33
+ const formElement = React.useRef(null);
34
+ const setFormElement = React.useCallback((element) => {
35
+ formElement.current = element;
36
+ if (typeof ref === 'function')
37
+ return ref(element);
38
+ if (ref)
39
+ ref.current = element;
40
+ return undefined;
41
+ }, [ref]);
42
+ const requestSubmit = React.useCallback(() => formElement.current?.requestSubmit(), []);
43
+ // The focus lands once the submit is over: react-hook-form moves it on a timer, and a control the submit disabled
44
+ // takes it only when it is enabled again. `onInvalid` is therefore not told where focus is.
45
+ const focusFirstInvalid = (errors, event) => {
46
+ const first = formFocus_utils.firstInvalidFieldOnPage(errors, fieldElements.elements);
47
+ if (first)
48
+ form.setFocus(first);
49
+ return onInvalid?.(errors, event);
50
+ };
51
+ const submit = useSubmitInTurn.useSubmitInTurn(formSubmit_utils.submitAfterValidations(form, onSubmit, focusFirstInvalid));
52
+ return (jsxRuntime.jsx(reactHookForm.FormProvider, { ...form, children: jsxRuntime.jsx(FieldElements_context.FieldElementsContext, { value: fieldElements, children: jsxRuntime.jsx(FormSubmit_context.FormSubmitContext, { value: requestSubmit, children: jsxRuntime.jsx("form", { ...formProps, ref: setFormElement,
53
+ // The schema validates; the browser's own checks (`type="email"`, `required`) would block the submit before it runs.
54
+ noValidate: true,
55
+ // Focusable from code only: a control that turns itself off, such as Discard, hands focus here so it is not lost.
56
+ tabIndex: -1, onSubmit: submit, "data-testid": formTestId, className: cx.cx('outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2', className), children: children }) }) }) }));
57
+ };
58
+ Form.Fields = FormFields;
59
+
60
+ exports.useForm = useForm.useForm;
61
+ exports.useSaveForm = useSaveForm.useSaveForm;
62
+ exports.Form = Form;
63
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/components/forms/Form/index.tsx"],"sourcesContent":[null],"names":["useFormState","_jsx","useResolvedTestId","useState","createFieldElements","useRef","useCallback","firstInvalidFieldOnPage","useSubmitInTurn","submitAfterValidations","FormProvider","FieldElementsContext","FormSubmitContext","cx"],"mappings":";;;;;;;;;;;;;;;;AAgDA;AACA,MAAM,UAAU,GAAG,CAAC,KAAsB,KAAI;AAC5C,IAAA,MAAM,EAAE,YAAY,EAAE,GAAGA,0BAAY,EAAE;AAEvC,IAAA,OAAOC,cAAA,CAAA,KAAA,EAAA,EAAA,GAAS,KAAK,EAAA,WAAA,EAAa,YAAY,GAAI;AACpD,CAAC;AAED;;;;;;AAMG;AACI,MAAM,IAAI,GAAG,CAAqE,EACvF,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,GAAG,EACH,SAAS,EACT,QAAQ,EACR,aAAa,EAAE,UAAU,EACzB,GAAG,SAAS,EACsB,KAAI;AACtC,IAAA,MAAM,UAAU,GAAGC,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAC/F,MAAM,CAAC,aAAa,CAAC,GAAGC,cAAQ,CAACC,uCAAmB,CAAC;;AAGrD,IAAA,MAAM,WAAW,GAAGC,YAAM,CAAyB,IAAI,CAAC;AACxD,IAAA,MAAM,cAAc,GAAGC,iBAAW,CAChC,CAAC,OAA+B,KAAI;AAClC,QAAA,WAAW,CAAC,OAAO,GAAG,OAAO;QAC7B,IAAI,OAAO,GAAG,KAAK,UAAU;AAAE,YAAA,OAAO,GAAG,CAAC,OAAO,CAAC;AAClD,QAAA,IAAI,GAAG;AAAE,YAAA,GAAG,CAAC,OAAO,GAAG,OAAO;AAC9B,QAAA,OAAO,SAAS;AAClB,IAAA,CAAC,EACD,CAAC,GAAG,CAAC,CACN;AACD,IAAA,MAAM,aAAa,GAAGA,iBAAW,CAAC,MAAM,WAAW,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC;;;AAIjF,IAAA,MAAM,iBAAiB,GAAgC,CAAC,MAAM,EAAE,KAAK,KAAI;QACvE,MAAM,KAAK,GAAGC,uCAAuB,CAAC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC;AACrE,QAAA,IAAI,KAAK;AAAE,YAAA,IAAI,CAAC,QAAQ,CAAC,KAA2B,CAAC;AACrD,QAAA,OAAO,SAAS,GAAG,MAAM,EAAE,KAAK,CAAC;AACnC,IAAA,CAAC;AAED,IAAA,MAAM,MAAM,GAAGC,+BAAe,CAACC,uCAAsB,CAAC,IAAI,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IAEzF,QACER,cAAA,CAACS,0BAAY,EAAA,EAAA,GAAK,IAAI,YACpBT,cAAA,CAACU,0CAAoB,EAAA,EAAC,KAAK,EAAE,aAAa,YACxCV,cAAA,CAACW,oCAAiB,EAAA,EAAC,KAAK,EAAE,aAAa,EAAA,QAAA,EACrCX,cAAA,CAAA,MAAA,EAAA,EAAA,GACM,SAAS,EACb,GAAG,EAAE,cAAc;;oBAEnB,UAAU,EAAA,IAAA;;oBAEV,QAAQ,EAAE,EAAE,EACZ,QAAQ,EAAE,MAAM,EAAA,aAAA,EACH,UAAU,EACvB,SAAS,EAAEY,KAAE,CAAC,2EAA2E,EAAE,SAAS,CAAC,EAAA,QAAA,EAEpG,QAAQ,EAAA,CACJ,EAAA,CACW,EAAA,CACC,EAAA,CACV;AAEnB;AAEA,IAAI,CAAC,MAAM,GAAG,UAAU;;;;"}
@@ -0,0 +1,37 @@
1
+ import { type ComponentProps, type Ref } from 'react';
2
+ import { type FieldValues, type SubmitErrorHandler, type SubmitHandler, type UseFormReturn } from 'react-hook-form';
3
+ export { useForm } from './hooks/useForm';
4
+ export type { SaveFieldError, UseSaveFormOptions, UseSaveFormReturn } from './hooks/useSaveForm/useSaveForm';
5
+ export { useSaveForm } from './hooks/useSaveForm/useSaveForm';
6
+ export interface FormProps<TValues extends FieldValues = FieldValues, TSubmitValues = TValues> extends Omit<ComponentProps<'form'>, 'onSubmit' | 'onInvalid' | 'noValidate' | 'ref'> {
7
+ /**
8
+ * The form from this module's `useForm` or `useSaveForm`; every `Form*` field and `FormFooter` beneath reads it. One from
9
+ * react-hook-form's own `useForm` needs `mode` and `reValidateMode` set to `'onBlur'` and `shouldFocusError` to `false`.
10
+ */
11
+ form: UseFormReturn<TValues, any, TSubmitValues>;
12
+ /**
13
+ * Called with the values once they pass validation, as the schema gives them out, such as a number a field made from
14
+ * text. Return the save's promise, so the fields stay locked until it lands.
15
+ */
16
+ onSubmit: SubmitHandler<TSubmitValues>;
17
+ /** Called with the errors when validation fails. The first invalid field takes focus as the submit ends. */
18
+ onInvalid?: SubmitErrorHandler<TValues>;
19
+ /** Ref to the `<form>` element. */
20
+ ref?: Ref<HTMLFormElement>;
21
+ /** Overrides the `data-testid` (defaults to `fd-form`). */
22
+ 'data-testid'?: string;
23
+ }
24
+ export interface FormFieldsProps extends Omit<ComponentProps<'div'>, 'aria-busy'> {
25
+ }
26
+ /**
27
+ * The `<form>` around `Form*` fields: it provides the react-hook-form form to them, leaves validation to the schema,
28
+ * focuses the first invalid field in page order after a failed submit, and ignores a second submit while one is running.
29
+ * Use one per form.
30
+ *
31
+ * @summary form element that provides a react-hook-form form to its fields
32
+ */
33
+ export declare const Form: {
34
+ <TValues extends FieldValues = FieldValues, TSubmitValues = TValues>({ form, onSubmit, onInvalid, ref, className, children, "data-testid": dataTestId, ...formProps }: FormProps<TValues, TSubmitValues>): import("react").JSX.Element;
35
+ Fields: (props: FormFieldsProps) => import("react").JSX.Element;
36
+ };
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/Form/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,GAAG,EAAiC,MAAM,OAAO,CAAC;AACrF,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,aAAa,EAEnB,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAC7G,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,MAAM,WAAW,SAAS,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,EAAE,aAAa,GAAG,OAAO,CAC3F,SAAQ,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,YAAY,GAAG,KAAK,CAAC;IACrF;;;OAGG;IAEH,IAAI,EAAE,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC;IACjD;;;OAGG;IACH,QAAQ,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IACvC,4GAA4G;IAC5G,SAAS,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACxC,mCAAmC;IACnC,GAAG,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;IAC3B,2DAA2D;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;CAAG;AASpF;;;;;;GAMG;AACH,eAAO,MAAM,IAAI;KAAI,OAAO,SAAS,WAAW,gBAAgB,aAAa,8GAS1E,SAAS,CAAC,OAAO,EAAE,aAAa,CAAC;oBAtBT,eAAe;CAsEzC,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { cx } from '@flipdish/ui-library/utilities/cx';
3
+ import { useResolvedTestId } from '@flipdish/ui-library/utilities/testIdUtils';
4
+ import { useState, useRef, useCallback } from 'react';
5
+ import { FormProvider, useFormState } from 'react-hook-form';
6
+ import { FieldElementsContext } from '../__internal__/formField/providers/FieldElements.context.js';
7
+ import { createFieldElements } from '../__internal__/formField/utilities/fieldElements.utils.js';
8
+ import { firstInvalidFieldOnPage } from '../__internal__/formField/utilities/formFocus.utils.js';
9
+ import { FormSubmitContext } from '../__internal__/formSubmit/providers/FormSubmit.context.js';
10
+ import { useSubmitInTurn } from './hooks/useSubmitInTurn/useSubmitInTurn.js';
11
+ import { submitAfterValidations } from './utilities/formSubmit.utils.js';
12
+ export { useForm } from './hooks/useForm.js';
13
+ export { useSaveForm } from './hooks/useSaveForm/useSaveForm.js';
14
+
15
+ /** Wraps a form's fields and marks them busy while the form submits, which is when they lock themselves. */
16
+ const FormFields = (props) => {
17
+ const { isSubmitting } = useFormState();
18
+ return jsx("div", { ...props, "aria-busy": isSubmitting });
19
+ };
20
+ /**
21
+ * The `<form>` around `Form*` fields: it provides the react-hook-form form to them, leaves validation to the schema,
22
+ * focuses the first invalid field in page order after a failed submit, and ignores a second submit while one is running.
23
+ * Use one per form.
24
+ *
25
+ * @summary form element that provides a react-hook-form form to its fields
26
+ */
27
+ const Form = ({ form, onSubmit, onInvalid, ref, className, children, 'data-testid': dataTestId, ...formProps }) => {
28
+ const formTestId = useResolvedTestId({ testId: dataTestId, segment: 'form', rootName: 'form' });
29
+ const [fieldElements] = useState(createFieldElements);
30
+ // Kept beside the caller's ref: a retry inside the form submits this element, whether or not the caller holds one.
31
+ const formElement = useRef(null);
32
+ const setFormElement = useCallback((element) => {
33
+ formElement.current = element;
34
+ if (typeof ref === 'function')
35
+ return ref(element);
36
+ if (ref)
37
+ ref.current = element;
38
+ return undefined;
39
+ }, [ref]);
40
+ const requestSubmit = useCallback(() => formElement.current?.requestSubmit(), []);
41
+ // The focus lands once the submit is over: react-hook-form moves it on a timer, and a control the submit disabled
42
+ // takes it only when it is enabled again. `onInvalid` is therefore not told where focus is.
43
+ const focusFirstInvalid = (errors, event) => {
44
+ const first = firstInvalidFieldOnPage(errors, fieldElements.elements);
45
+ if (first)
46
+ form.setFocus(first);
47
+ return onInvalid?.(errors, event);
48
+ };
49
+ const submit = useSubmitInTurn(submitAfterValidations(form, onSubmit, focusFirstInvalid));
50
+ return (jsx(FormProvider, { ...form, children: jsx(FieldElementsContext, { value: fieldElements, children: jsx(FormSubmitContext, { value: requestSubmit, children: jsx("form", { ...formProps, ref: setFormElement,
51
+ // The schema validates; the browser's own checks (`type="email"`, `required`) would block the submit before it runs.
52
+ noValidate: true,
53
+ // Focusable from code only: a control that turns itself off, such as Discard, hands focus here so it is not lost.
54
+ tabIndex: -1, onSubmit: submit, "data-testid": formTestId, className: cx('outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2', className), children: children }) }) }) }));
55
+ };
56
+ Form.Fields = FormFields;
57
+
58
+ export { Form };
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/forms/Form/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;AAgDA;AACA,MAAM,UAAU,GAAG,CAAC,KAAsB,KAAI;AAC5C,IAAA,MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE;AAEvC,IAAA,OAAOA,GAAA,CAAA,KAAA,EAAA,EAAA,GAAS,KAAK,EAAA,WAAA,EAAa,YAAY,GAAI;AACpD,CAAC;AAED;;;;;;AAMG;AACI,MAAM,IAAI,GAAG,CAAqE,EACvF,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,GAAG,EACH,SAAS,EACT,QAAQ,EACR,aAAa,EAAE,UAAU,EACzB,GAAG,SAAS,EACsB,KAAI;AACtC,IAAA,MAAM,UAAU,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAC/F,MAAM,CAAC,aAAa,CAAC,GAAG,QAAQ,CAAC,mBAAmB,CAAC;;AAGrD,IAAA,MAAM,WAAW,GAAG,MAAM,CAAyB,IAAI,CAAC;AACxD,IAAA,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,OAA+B,KAAI;AAClC,QAAA,WAAW,CAAC,OAAO,GAAG,OAAO;QAC7B,IAAI,OAAO,GAAG,KAAK,UAAU;AAAE,YAAA,OAAO,GAAG,CAAC,OAAO,CAAC;AAClD,QAAA,IAAI,GAAG;AAAE,YAAA,GAAG,CAAC,OAAO,GAAG,OAAO;AAC9B,QAAA,OAAO,SAAS;AAClB,IAAA,CAAC,EACD,CAAC,GAAG,CAAC,CACN;AACD,IAAA,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,WAAW,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC;;;AAIjF,IAAA,MAAM,iBAAiB,GAAgC,CAAC,MAAM,EAAE,KAAK,KAAI;QACvE,MAAM,KAAK,GAAG,uBAAuB,CAAC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC;AACrE,QAAA,IAAI,KAAK;AAAE,YAAA,IAAI,CAAC,QAAQ,CAAC,KAA2B,CAAC;AACrD,QAAA,OAAO,SAAS,GAAG,MAAM,EAAE,KAAK,CAAC;AACnC,IAAA,CAAC;AAED,IAAA,MAAM,MAAM,GAAG,eAAe,CAAC,sBAAsB,CAAC,IAAI,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IAEzF,QACEA,GAAA,CAAC,YAAY,EAAA,EAAA,GAAK,IAAI,YACpBA,GAAA,CAAC,oBAAoB,EAAA,EAAC,KAAK,EAAE,aAAa,YACxCA,GAAA,CAAC,iBAAiB,EAAA,EAAC,KAAK,EAAE,aAAa,EAAA,QAAA,EACrCA,GAAA,CAAA,MAAA,EAAA,EAAA,GACM,SAAS,EACb,GAAG,EAAE,cAAc;;oBAEnB,UAAU,EAAA,IAAA;;oBAEV,QAAQ,EAAE,EAAE,EACZ,QAAQ,EAAE,MAAM,EAAA,aAAA,EACH,UAAU,EACvB,SAAS,EAAE,EAAE,CAAC,2EAA2E,EAAE,SAAS,CAAC,EAAA,QAAA,EAEpG,QAAQ,EAAA,CACJ,EAAA,CACW,EAAA,CACC,EAAA,CACV;AAEnB;AAEA,IAAI,CAAC,MAAM,GAAG,UAAU;;"}
@@ -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