@flipdish/ui-library 0.50.0 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (409) hide show
  1. package/README.md +17 -16
  2. package/dist/components/atoms/Checkbox/index.cjs +11 -3
  3. package/dist/components/atoms/Checkbox/index.cjs.map +1 -1
  4. package/dist/components/atoms/Checkbox/index.d.ts.map +1 -1
  5. package/dist/components/atoms/Checkbox/index.js +12 -4
  6. package/dist/components/atoms/Checkbox/index.js.map +1 -1
  7. package/dist/components/atoms/Slider/index.cjs +2 -2
  8. package/dist/components/atoms/Slider/index.cjs.map +1 -1
  9. package/dist/components/atoms/Slider/index.d.ts +3 -1
  10. package/dist/components/atoms/Slider/index.d.ts.map +1 -1
  11. package/dist/components/atoms/Slider/index.js +2 -2
  12. package/dist/components/atoms/Slider/index.js.map +1 -1
  13. package/dist/components/forms/Form/hooks/useForm.cjs +26 -0
  14. package/dist/components/forms/Form/hooks/useForm.cjs.map +1 -0
  15. package/dist/components/forms/Form/hooks/useForm.d.ts +13 -0
  16. package/dist/components/forms/Form/hooks/useForm.d.ts.map +1 -0
  17. package/dist/components/forms/Form/hooks/useForm.js +24 -0
  18. package/dist/components/forms/Form/hooks/useForm.js.map +1 -0
  19. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.cjs +28 -0
  20. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.cjs.map +1 -0
  21. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.d.ts +10 -0
  22. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.d.ts.map +1 -0
  23. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.js +26 -0
  24. package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.js.map +1 -0
  25. package/dist/components/forms/Form/index.cjs +43 -0
  26. package/dist/components/forms/Form/index.cjs.map +1 -0
  27. package/dist/components/forms/Form/index.d.ts +30 -0
  28. package/dist/components/forms/Form/index.d.ts.map +1 -0
  29. package/dist/components/forms/Form/index.js +40 -0
  30. package/dist/components/forms/Form/index.js.map +1 -0
  31. package/dist/components/forms/Form/utilities/formSubmit.utils.cjs +23 -0
  32. package/dist/components/forms/Form/utilities/formSubmit.utils.cjs.map +1 -0
  33. package/dist/components/forms/Form/utilities/formSubmit.utils.d.ts +14 -0
  34. package/dist/components/forms/Form/utilities/formSubmit.utils.d.ts.map +1 -0
  35. package/dist/components/forms/Form/utilities/formSubmit.utils.js +21 -0
  36. package/dist/components/forms/Form/utilities/formSubmit.utils.js.map +1 -0
  37. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.cjs +39 -0
  38. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.cjs.map +1 -0
  39. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.d.ts +17 -0
  40. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.d.ts.map +1 -0
  41. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.js +37 -0
  42. package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.js.map +1 -0
  43. package/dist/components/forms/FormFooter/hooks/useHasFieldError.cjs +26 -0
  44. package/dist/components/forms/FormFooter/hooks/useHasFieldError.cjs.map +1 -0
  45. package/dist/components/forms/FormFooter/hooks/useHasFieldError.d.ts +9 -0
  46. package/dist/components/forms/FormFooter/hooks/useHasFieldError.d.ts.map +1 -0
  47. package/dist/components/forms/FormFooter/hooks/useHasFieldError.js +24 -0
  48. package/dist/components/forms/FormFooter/hooks/useHasFieldError.js.map +1 -0
  49. package/dist/components/forms/FormFooter/index.cjs +41 -0
  50. package/dist/components/forms/FormFooter/index.cjs.map +1 -0
  51. package/dist/components/forms/FormFooter/index.d.ts +52 -0
  52. package/dist/components/forms/FormFooter/index.d.ts.map +1 -0
  53. package/dist/components/forms/FormFooter/index.js +39 -0
  54. package/dist/components/forms/FormFooter/index.js.map +1 -0
  55. package/dist/components/forms/FormFooter/utilities/formFooter.utils.cjs +21 -0
  56. package/dist/components/forms/FormFooter/utilities/formFooter.utils.cjs.map +1 -0
  57. package/dist/components/forms/FormFooter/utilities/formFooter.utils.d.ts +12 -0
  58. package/dist/components/forms/FormFooter/utilities/formFooter.utils.d.ts.map +1 -0
  59. package/dist/components/forms/FormFooter/utilities/formFooter.utils.js +19 -0
  60. package/dist/components/forms/FormFooter/utilities/formFooter.utils.js.map +1 -0
  61. package/dist/components/forms/FormSection/FormSection.styles.cjs +15 -0
  62. package/dist/components/forms/FormSection/FormSection.styles.cjs.map +1 -0
  63. package/dist/components/forms/FormSection/FormSection.styles.d.ts +9 -0
  64. package/dist/components/forms/FormSection/FormSection.styles.d.ts.map +1 -0
  65. package/dist/components/forms/FormSection/FormSection.styles.js +13 -0
  66. package/dist/components/forms/FormSection/FormSection.styles.js.map +1 -0
  67. package/dist/components/forms/FormSection/index.cjs +43 -0
  68. package/dist/components/forms/FormSection/index.cjs.map +1 -0
  69. package/dist/components/forms/FormSection/index.d.ts +41 -0
  70. package/dist/components/forms/FormSection/index.d.ts.map +1 -0
  71. package/dist/components/forms/FormSection/index.js +41 -0
  72. package/dist/components/forms/FormSection/index.js.map +1 -0
  73. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.cjs +28 -0
  74. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.cjs.map +1 -0
  75. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.d.ts +12 -0
  76. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.d.ts.map +1 -0
  77. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.js +26 -0
  78. package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.js.map +1 -0
  79. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.cjs +68 -0
  80. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.cjs.map +1 -0
  81. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.d.ts +26 -0
  82. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.d.ts.map +1 -0
  83. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.js +66 -0
  84. package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.js.map +1 -0
  85. package/dist/components/forms/__internal__/formField/hooks/useFormField.cjs +142 -0
  86. package/dist/components/forms/__internal__/formField/hooks/useFormField.cjs.map +1 -0
  87. package/dist/components/forms/__internal__/formField/hooks/useFormField.d.ts +35 -0
  88. package/dist/components/forms/__internal__/formField/hooks/useFormField.d.ts.map +1 -0
  89. package/dist/components/forms/__internal__/formField/hooks/useFormField.js +140 -0
  90. package/dist/components/forms/__internal__/formField/hooks/useFormField.js.map +1 -0
  91. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.cjs +12 -0
  92. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.cjs.map +1 -0
  93. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.d.ts +7 -0
  94. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.d.ts.map +1 -0
  95. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.js +10 -0
  96. package/dist/components/forms/__internal__/formField/providers/FieldElements.context.js.map +1 -0
  97. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.cjs +39 -0
  98. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.cjs.map +1 -0
  99. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.d.ts +21 -0
  100. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.d.ts.map +1 -0
  101. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.js +37 -0
  102. package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.js.map +1 -0
  103. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.cjs +40 -0
  104. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.cjs.map +1 -0
  105. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.d.ts +18 -0
  106. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.d.ts.map +1 -0
  107. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.js +37 -0
  108. package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.js.map +1 -0
  109. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.cjs +21 -0
  110. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.cjs.map +1 -0
  111. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.d.ts +11 -0
  112. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.d.ts.map +1 -0
  113. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.js +19 -0
  114. package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.js.map +1 -0
  115. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.cjs +128 -0
  116. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.cjs.map +1 -0
  117. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.d.ts +72 -0
  118. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.d.ts.map +1 -0
  119. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.js +121 -0
  120. package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.js.map +1 -0
  121. package/dist/components/forms/fields/FormCheckbox/index.cjs +34 -0
  122. package/dist/components/forms/fields/FormCheckbox/index.cjs.map +1 -0
  123. package/dist/components/forms/fields/FormCheckbox/index.d.ts +16 -0
  124. package/dist/components/forms/fields/FormCheckbox/index.d.ts.map +1 -0
  125. package/dist/components/forms/fields/FormCheckbox/index.js +32 -0
  126. package/dist/components/forms/fields/FormCheckbox/index.js.map +1 -0
  127. package/dist/components/forms/fields/FormCheckboxGroup/index.cjs +33 -0
  128. package/dist/components/forms/fields/FormCheckboxGroup/index.cjs.map +1 -0
  129. package/dist/components/forms/fields/FormCheckboxGroup/index.d.ts +16 -0
  130. package/dist/components/forms/fields/FormCheckboxGroup/index.d.ts.map +1 -0
  131. package/dist/components/forms/fields/FormCheckboxGroup/index.js +31 -0
  132. package/dist/components/forms/fields/FormCheckboxGroup/index.js.map +1 -0
  133. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.cjs +26 -0
  134. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.cjs.map +1 -0
  135. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.d.ts +11 -0
  136. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.d.ts.map +1 -0
  137. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.js +24 -0
  138. package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.js.map +1 -0
  139. package/dist/components/forms/fields/FormColorPicker/index.cjs +33 -0
  140. package/dist/components/forms/fields/FormColorPicker/index.cjs.map +1 -0
  141. package/dist/components/forms/fields/FormColorPicker/index.d.ts +21 -0
  142. package/dist/components/forms/fields/FormColorPicker/index.d.ts.map +1 -0
  143. package/dist/components/forms/fields/FormColorPicker/index.js +31 -0
  144. package/dist/components/forms/fields/FormColorPicker/index.js.map +1 -0
  145. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.cjs +20 -0
  146. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.cjs.map +1 -0
  147. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.d.ts +17 -0
  148. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.d.ts.map +1 -0
  149. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.js +18 -0
  150. package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.js.map +1 -0
  151. package/dist/components/forms/fields/FormDatePicker/index.cjs +35 -0
  152. package/dist/components/forms/fields/FormDatePicker/index.cjs.map +1 -0
  153. package/dist/components/forms/fields/FormDatePicker/index.d.ts +17 -0
  154. package/dist/components/forms/fields/FormDatePicker/index.d.ts.map +1 -0
  155. package/dist/components/forms/fields/FormDatePicker/index.js +33 -0
  156. package/dist/components/forms/fields/FormDatePicker/index.js.map +1 -0
  157. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.cjs +23 -0
  158. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.cjs.map +1 -0
  159. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.d.ts +9 -0
  160. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.d.ts.map +1 -0
  161. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.js +21 -0
  162. package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.js.map +1 -0
  163. package/dist/components/forms/fields/FormInput/index.cjs +27 -0
  164. package/dist/components/forms/fields/FormInput/index.cjs.map +1 -0
  165. package/dist/components/forms/fields/FormInput/index.d.ts +16 -0
  166. package/dist/components/forms/fields/FormInput/index.d.ts.map +1 -0
  167. package/dist/components/forms/fields/FormInput/index.js +25 -0
  168. package/dist/components/forms/fields/FormInput/index.js.map +1 -0
  169. package/dist/components/forms/fields/FormMultiSelect/index.cjs +44 -0
  170. package/dist/components/forms/fields/FormMultiSelect/index.cjs.map +1 -0
  171. package/dist/components/forms/fields/FormMultiSelect/index.d.ts +17 -0
  172. package/dist/components/forms/fields/FormMultiSelect/index.d.ts.map +1 -0
  173. package/dist/components/forms/fields/FormMultiSelect/index.js +42 -0
  174. package/dist/components/forms/fields/FormMultiSelect/index.js.map +1 -0
  175. package/dist/components/forms/fields/FormRadioCardGroup/index.cjs +36 -0
  176. package/dist/components/forms/fields/FormRadioCardGroup/index.cjs.map +1 -0
  177. package/dist/components/forms/fields/FormRadioCardGroup/index.d.ts +29 -0
  178. package/dist/components/forms/fields/FormRadioCardGroup/index.d.ts.map +1 -0
  179. package/dist/components/forms/fields/FormRadioCardGroup/index.js +34 -0
  180. package/dist/components/forms/fields/FormRadioCardGroup/index.js.map +1 -0
  181. package/dist/components/forms/fields/FormRadioGroup/index.cjs +31 -0
  182. package/dist/components/forms/fields/FormRadioGroup/index.cjs.map +1 -0
  183. package/dist/components/forms/fields/FormRadioGroup/index.d.ts +17 -0
  184. package/dist/components/forms/fields/FormRadioGroup/index.d.ts.map +1 -0
  185. package/dist/components/forms/fields/FormRadioGroup/index.js +29 -0
  186. package/dist/components/forms/fields/FormRadioGroup/index.js.map +1 -0
  187. package/dist/components/forms/fields/FormSelect/index.cjs +30 -0
  188. package/dist/components/forms/fields/FormSelect/index.cjs.map +1 -0
  189. package/dist/components/forms/fields/FormSelect/index.d.ts +16 -0
  190. package/dist/components/forms/fields/FormSelect/index.d.ts.map +1 -0
  191. package/dist/components/forms/fields/FormSelect/index.js +28 -0
  192. package/dist/components/forms/fields/FormSelect/index.js.map +1 -0
  193. package/dist/components/forms/fields/FormSlider/index.cjs +43 -0
  194. package/dist/components/forms/fields/FormSlider/index.cjs.map +1 -0
  195. package/dist/components/forms/fields/FormSlider/index.d.ts +17 -0
  196. package/dist/components/forms/fields/FormSlider/index.d.ts.map +1 -0
  197. package/dist/components/forms/fields/FormSlider/index.js +41 -0
  198. package/dist/components/forms/fields/FormSlider/index.js.map +1 -0
  199. package/dist/components/forms/fields/FormTextArea/index.cjs +27 -0
  200. package/dist/components/forms/fields/FormTextArea/index.cjs.map +1 -0
  201. package/dist/components/forms/fields/FormTextArea/index.d.ts +16 -0
  202. package/dist/components/forms/fields/FormTextArea/index.d.ts.map +1 -0
  203. package/dist/components/forms/fields/FormTextArea/index.js +25 -0
  204. package/dist/components/forms/fields/FormTextArea/index.js.map +1 -0
  205. package/dist/components/forms/fields/FormToggle/index.cjs +32 -0
  206. package/dist/components/forms/fields/FormToggle/index.cjs.map +1 -0
  207. package/dist/components/forms/fields/FormToggle/index.d.ts +16 -0
  208. package/dist/components/forms/fields/FormToggle/index.d.ts.map +1 -0
  209. package/dist/components/forms/fields/FormToggle/index.js +30 -0
  210. package/dist/components/forms/fields/FormToggle/index.js.map +1 -0
  211. package/dist/components/forms/validation/hooks/useSchemaResolver.cjs +39 -0
  212. package/dist/components/forms/validation/hooks/useSchemaResolver.cjs.map +1 -0
  213. package/dist/components/forms/validation/hooks/useSchemaResolver.d.ts +15 -0
  214. package/dist/components/forms/validation/hooks/useSchemaResolver.d.ts.map +1 -0
  215. package/dist/components/forms/validation/hooks/useSchemaResolver.js +37 -0
  216. package/dist/components/forms/validation/hooks/useSchemaResolver.js.map +1 -0
  217. package/dist/components/forms/validation/index.cjs +309 -0
  218. package/dist/components/forms/validation/index.cjs.map +1 -0
  219. package/dist/components/forms/validation/index.d.ts +214 -0
  220. package/dist/components/forms/validation/index.d.ts.map +1 -0
  221. package/dist/components/forms/validation/index.js +293 -0
  222. package/dist/components/forms/validation/index.js.map +1 -0
  223. package/dist/components/forms/validation/utilities/validation.utils.cjs +42 -0
  224. package/dist/components/forms/validation/utilities/validation.utils.cjs.map +1 -0
  225. package/dist/components/forms/validation/utilities/validation.utils.d.ts +20 -0
  226. package/dist/components/forms/validation/utilities/validation.utils.d.ts.map +1 -0
  227. package/dist/components/forms/validation/utilities/validation.utils.js +39 -0
  228. package/dist/components/forms/validation/utilities/validation.utils.js.map +1 -0
  229. package/dist/components/forms/validation/validation.types.d.ts +8 -0
  230. package/dist/components/forms/validation/validation.types.d.ts.map +1 -0
  231. package/dist/components/molecules/Alert/index.cjs +5 -25
  232. package/dist/components/molecules/Alert/index.cjs.map +1 -1
  233. package/dist/components/molecules/Alert/index.d.ts +9 -94
  234. package/dist/components/molecules/Alert/index.d.ts.map +1 -1
  235. package/dist/components/molecules/Alert/index.js +5 -25
  236. package/dist/components/molecules/Alert/index.js.map +1 -1
  237. package/dist/components/molecules/Alerts/components/Alert.cjs +39 -0
  238. package/dist/components/molecules/Alerts/components/Alert.cjs.map +1 -0
  239. package/dist/components/molecules/Alerts/components/Alert.d.ts +104 -0
  240. package/dist/components/molecules/Alerts/components/Alert.d.ts.map +1 -0
  241. package/dist/components/molecules/Alerts/components/Alert.js +36 -0
  242. package/dist/components/molecules/Alerts/components/Alert.js.map +1 -0
  243. package/dist/components/molecules/Alerts/components/SaveErrorAlert.cjs +26 -0
  244. package/dist/components/molecules/Alerts/components/SaveErrorAlert.cjs.map +1 -0
  245. package/dist/components/molecules/Alerts/components/SaveErrorAlert.d.ts +25 -0
  246. package/dist/components/molecules/Alerts/components/SaveErrorAlert.d.ts.map +1 -0
  247. package/dist/components/molecules/Alerts/components/SaveErrorAlert.js +24 -0
  248. package/dist/components/molecules/Alerts/components/SaveErrorAlert.js.map +1 -0
  249. package/dist/components/molecules/Alerts/hooks/useAlertActions.cjs +26 -0
  250. package/dist/components/molecules/Alerts/hooks/useAlertActions.cjs.map +1 -0
  251. package/dist/components/molecules/Alerts/hooks/useAlertActions.d.ts +13 -0
  252. package/dist/components/molecules/Alerts/hooks/useAlertActions.d.ts.map +1 -0
  253. package/dist/components/molecules/Alerts/hooks/useAlertActions.js +24 -0
  254. package/dist/components/molecules/Alerts/hooks/useAlertActions.js.map +1 -0
  255. package/dist/components/molecules/Alerts/index.cjs +11 -0
  256. package/dist/components/molecules/Alerts/index.cjs.map +1 -0
  257. package/dist/components/molecules/Alerts/index.d.ts +12 -0
  258. package/dist/components/molecules/Alerts/index.d.ts.map +1 -0
  259. package/dist/components/molecules/Alerts/index.js +3 -0
  260. package/dist/components/molecules/Alerts/index.js.map +1 -0
  261. package/dist/components/molecules/Modal/index.cjs +9 -39
  262. package/dist/components/molecules/Modal/index.cjs.map +1 -1
  263. package/dist/components/molecules/Modal/index.d.ts +13 -36
  264. package/dist/components/molecules/Modal/index.d.ts.map +1 -1
  265. package/dist/components/molecules/Modal/index.js +8 -38
  266. package/dist/components/molecules/Modal/index.js.map +1 -1
  267. package/dist/components/molecules/Modals/components/ConfirmationModal.cjs +32 -0
  268. package/dist/components/molecules/Modals/components/ConfirmationModal.cjs.map +1 -0
  269. package/dist/components/molecules/Modals/components/ConfirmationModal.d.ts +28 -0
  270. package/dist/components/molecules/Modals/components/ConfirmationModal.d.ts.map +1 -0
  271. package/dist/components/molecules/Modals/components/ConfirmationModal.js +30 -0
  272. package/dist/components/molecules/Modals/components/ConfirmationModal.js.map +1 -0
  273. package/dist/components/molecules/Modals/components/Modal.cjs +48 -0
  274. package/dist/components/molecules/Modals/components/Modal.cjs.map +1 -0
  275. package/dist/components/molecules/Modals/components/Modal.d.ts +37 -0
  276. package/dist/components/molecules/Modals/components/Modal.d.ts.map +1 -0
  277. package/dist/components/molecules/Modals/components/Modal.js +43 -0
  278. package/dist/components/molecules/Modals/components/Modal.js.map +1 -0
  279. package/dist/components/molecules/Modals/components/UnsavedChangesModal.cjs +30 -0
  280. package/dist/components/molecules/Modals/components/UnsavedChangesModal.cjs.map +1 -0
  281. package/dist/components/molecules/Modals/components/UnsavedChangesModal.d.ts +14 -0
  282. package/dist/components/molecules/Modals/components/UnsavedChangesModal.d.ts.map +1 -0
  283. package/dist/components/molecules/Modals/components/UnsavedChangesModal.js +28 -0
  284. package/dist/components/molecules/Modals/components/UnsavedChangesModal.js.map +1 -0
  285. package/dist/components/molecules/Modals/index.cjs +15 -0
  286. package/dist/components/molecules/Modals/index.cjs.map +1 -0
  287. package/dist/components/molecules/Modals/index.d.ts +14 -0
  288. package/dist/components/molecules/Modals/index.d.ts.map +1 -0
  289. package/dist/components/molecules/Modals/index.js +4 -0
  290. package/dist/components/molecules/Modals/index.js.map +1 -0
  291. package/dist/components/organisms/ColorPicker/components/ColorPickerField.cjs +13 -3
  292. package/dist/components/organisms/ColorPicker/components/ColorPickerField.cjs.map +1 -1
  293. package/dist/components/organisms/ColorPicker/components/ColorPickerField.d.ts +1 -1
  294. package/dist/components/organisms/ColorPicker/components/ColorPickerField.d.ts.map +1 -1
  295. package/dist/components/organisms/ColorPicker/components/ColorPickerField.js +13 -3
  296. package/dist/components/organisms/ColorPicker/components/ColorPickerField.js.map +1 -1
  297. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.cjs +2 -2
  298. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.cjs.map +1 -1
  299. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.d.ts +1 -0
  300. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.d.ts.map +1 -1
  301. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.js +2 -2
  302. package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.js.map +1 -1
  303. package/dist/components/organisms/ColorPicker/hooks/useCssColorField.cjs +1 -1
  304. package/dist/components/organisms/ColorPicker/hooks/useCssColorField.js +1 -1
  305. package/dist/components/organisms/ColorPicker/index.cjs +1 -1
  306. package/dist/components/organisms/ColorPicker/index.d.ts.map +1 -1
  307. package/dist/components/organisms/ColorPicker/index.js +1 -1
  308. package/dist/components/organisms/ColorPicker/providers/ColorPicker.provider.d.ts +1 -1
  309. package/dist/components/organisms/ColorPicker/providers/ColorPicker.provider.d.ts.map +1 -1
  310. package/dist/components/organisms/ColorPicker/utilities/colorPicker.utils.cjs.map +1 -0
  311. package/dist/components/organisms/ColorPicker/utilities/colorPicker.utils.d.ts.map +1 -0
  312. package/dist/components/organisms/ColorPicker/utilities/colorPicker.utils.js.map +1 -0
  313. package/dist/components/organisms/DatePicker/components/CalendarOverlay.cjs +2 -2
  314. package/dist/components/organisms/DatePicker/components/CalendarOverlay.cjs.map +1 -1
  315. package/dist/components/organisms/DatePicker/components/CalendarOverlay.js +1 -1
  316. package/dist/components/organisms/DatePicker/components/DateRangePicker.cjs +4 -1
  317. package/dist/components/organisms/DatePicker/components/DateRangePicker.cjs.map +1 -1
  318. package/dist/components/organisms/DatePicker/components/DateRangePicker.d.ts.map +1 -1
  319. package/dist/components/organisms/DatePicker/components/DateRangePicker.js +5 -2
  320. package/dist/components/organisms/DatePicker/components/DateRangePicker.js.map +1 -1
  321. package/dist/components/organisms/GradientPicker/components/GradientStopRow.cjs +1 -1
  322. package/dist/components/organisms/GradientPicker/components/GradientStopRow.js +1 -1
  323. package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.cjs +48 -0
  324. package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.cjs.map +1 -0
  325. package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.d.ts +23 -0
  326. package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.d.ts.map +1 -0
  327. package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.js +45 -0
  328. package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.js.map +1 -0
  329. package/dist/hooks/useUnsavedChangesGuard/index.cjs +28 -0
  330. package/dist/hooks/useUnsavedChangesGuard/index.cjs.map +1 -0
  331. package/dist/hooks/useUnsavedChangesGuard/index.d.ts +18 -0
  332. package/dist/hooks/useUnsavedChangesGuard/index.d.ts.map +1 -0
  333. package/dist/hooks/useUnsavedChangesGuard/index.js +26 -0
  334. package/dist/hooks/useUnsavedChangesGuard/index.js.map +1 -0
  335. package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.cjs +8 -0
  336. package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.cjs.map +1 -0
  337. package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.d.ts +13 -0
  338. package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.d.ts.map +1 -0
  339. package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.js +6 -0
  340. package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.js.map +1 -0
  341. package/dist/localization/en.json.cjs +98 -0
  342. package/dist/localization/en.json.cjs.map +1 -0
  343. package/dist/localization/en.json.js +81 -0
  344. package/dist/localization/en.json.js.map +1 -0
  345. package/dist/native/components/forms/Form/index.d.ts +12 -0
  346. package/dist/native/components/forms/FormFooter/index.d.ts +12 -0
  347. package/dist/native/components/forms/FormSection/index.d.ts +12 -0
  348. package/dist/native/components/forms/fields/FormCheckbox/index.d.ts +12 -0
  349. package/dist/native/components/forms/fields/FormCheckboxGroup/index.d.ts +12 -0
  350. package/dist/native/components/forms/fields/FormColorPicker/index.d.ts +12 -0
  351. package/dist/native/components/forms/fields/FormDatePicker/index.d.ts +12 -0
  352. package/dist/native/components/forms/fields/FormInput/index.d.ts +12 -0
  353. package/dist/native/components/forms/fields/FormMultiSelect/index.d.ts +12 -0
  354. package/dist/native/components/forms/fields/FormRadioCardGroup/index.d.ts +12 -0
  355. package/dist/native/components/forms/fields/FormRadioGroup/index.d.ts +12 -0
  356. package/dist/native/components/forms/fields/FormSelect/index.d.ts +12 -0
  357. package/dist/native/components/forms/fields/FormSlider/index.d.ts +12 -0
  358. package/dist/native/components/forms/fields/FormTextArea/index.d.ts +12 -0
  359. package/dist/native/components/forms/fields/FormToggle/index.d.ts +12 -0
  360. package/dist/native/components/forms/validation/index.d.ts +12 -0
  361. package/dist/native/components/molecules/Alerts/index.d.ts +12 -0
  362. package/dist/native/components/molecules/Modals/index.d.ts +12 -0
  363. package/dist/native/hooks/useUnsavedChangesGuard/index.d.ts +12 -0
  364. package/dist/native/providers/UnsavedChangesGuardProvider/index.d.ts +12 -0
  365. package/dist/providers/UIProvider/hooks/useBrowserRouter.cjs +70 -0
  366. package/dist/providers/UIProvider/hooks/useBrowserRouter.cjs.map +1 -0
  367. package/dist/providers/UIProvider/hooks/useBrowserRouter.d.ts +12 -0
  368. package/dist/providers/UIProvider/hooks/useBrowserRouter.d.ts.map +1 -0
  369. package/dist/providers/UIProvider/hooks/useBrowserRouter.js +68 -0
  370. package/dist/providers/UIProvider/hooks/useBrowserRouter.js.map +1 -0
  371. package/dist/providers/UIProvider/index.cjs +19 -6
  372. package/dist/providers/UIProvider/index.cjs.map +1 -1
  373. package/dist/providers/UIProvider/index.d.ts +2 -2
  374. package/dist/providers/UIProvider/index.d.ts.map +1 -1
  375. package/dist/providers/UIProvider/index.js +20 -7
  376. package/dist/providers/UIProvider/index.js.map +1 -1
  377. package/dist/providers/UnsavedChangesGuardProvider/index.cjs +191 -0
  378. package/dist/providers/UnsavedChangesGuardProvider/index.cjs.map +1 -0
  379. package/dist/providers/UnsavedChangesGuardProvider/index.d.ts +10 -0
  380. package/dist/providers/UnsavedChangesGuardProvider/index.d.ts.map +1 -0
  381. package/dist/providers/UnsavedChangesGuardProvider/index.js +189 -0
  382. package/dist/providers/UnsavedChangesGuardProvider/index.js.map +1 -0
  383. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.cjs +7 -0
  384. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.cjs.map +1 -0
  385. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.d.ts +3 -0
  386. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.d.ts.map +1 -0
  387. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.js +5 -0
  388. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.js.map +1 -0
  389. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.types.d.ts +21 -0
  390. package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.types.d.ts.map +1 -0
  391. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.cjs +97 -0
  392. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.cjs.map +1 -0
  393. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.d.ts +62 -0
  394. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.d.ts.map +1 -0
  395. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.js +88 -0
  396. package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.js.map +1 -0
  397. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.cjs +74 -0
  398. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.cjs.map +1 -0
  399. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.d.ts +51 -0
  400. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.d.ts.map +1 -0
  401. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.js +68 -0
  402. package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.js.map +1 -0
  403. package/package.json +41 -6
  404. package/dist/components/organisms/ColorPicker/colorPicker.utils.cjs.map +0 -1
  405. package/dist/components/organisms/ColorPicker/colorPicker.utils.d.ts.map +0 -1
  406. package/dist/components/organisms/ColorPicker/colorPicker.utils.js.map +0 -1
  407. /package/dist/components/organisms/ColorPicker/{colorPicker.utils.cjs → utilities/colorPicker.utils.cjs} +0 -0
  408. /package/dist/components/organisms/ColorPicker/{colorPicker.utils.d.ts → utilities/colorPicker.utils.d.ts} +0 -0
  409. /package/dist/components/organisms/ColorPicker/{colorPicker.utils.js → utilities/colorPicker.utils.js} +0 -0
@@ -0,0 +1,189 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useContext, useState, useRef, useCallback, useEffect, useMemo } from 'react';
3
+ import { UNSAFE_DataRouterContext, useHref, useLocation, useBlocker } from 'react-router';
4
+ import { UnsavedChangesGuardContext } from '../../hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.js';
5
+ import { HOST_APPROVAL_MS } from './unsavedChangesGuard.constants.js';
6
+ import { browserEntry, isInside, hasLeftFrom, canRewind, historyPosition, historyIndex, watchLeftPosition, hostGuard } from './utilities/unsavedChangesGuard.utils.js';
7
+
8
+ /** Registers the router's blocker. Rendered only while it is needed: react-router warns on every host navigation while one exists. */
9
+ const NavigationHold = ({ shouldBlock, onChange }) => {
10
+ const blocker = useBlocker(shouldBlock);
11
+ useEffect(() => onChange(blocker), [blocker, onChange]);
12
+ useEffect(() => () => onChange(null), [onChange]);
13
+ return null;
14
+ };
15
+ /**
16
+ * Holds the one navigation blocker a router allows and shares it between every `useUnsavedChangesGuard` beneath it, so
17
+ * several forms on a page are all protected. `UIProvider` renders it; add it yourself only inside your own data router.
18
+ *
19
+ * @summary shares one unsaved-changes navigation blocker with the tree
20
+ */
21
+ const UnsavedChangesGuardProvider = ({ children }) => {
22
+ // Said at mount: react-router's own error for this only comes with the first unsaved change, when the blocker is registered.
23
+ if (!useContext(UNSAFE_DataRouterContext)) {
24
+ throw new Error('UnsavedChangesGuardProvider needs a react-router data router above it (createBrowserRouter with RouterProvider), or use UIProvider.');
25
+ }
26
+ const [dirtyIds, setDirtyIds] = useState([]);
27
+ const hasUnsavedChanges = dirtyIds.length > 0;
28
+ // The blocker reads this, not the state, so it never holds for a form saved since the last render.
29
+ const dirtyCount = useRef(0);
30
+ const basePath = useHref('/');
31
+ const location = useLocation();
32
+ const { pathname } = location;
33
+ const currentPlace = useRef({ idx: undefined, position: undefined });
34
+ // The entry the latest navigation left, by the browser's count: it shows when another router has moved the user on.
35
+ const leftPosition = useRef(undefined);
36
+ const isHostMove = useRef(false);
37
+ const [blocker, setBlocker] = useState(null);
38
+ // The blocker last answered. The copy in state can outlive the navigation it held, and react-router throws on a second answer.
39
+ const settledBlocker = useRef(null);
40
+ const [answerHost, setAnswerHost] = useState(null);
41
+ // Set when the user lets a host navigate, so the navigation they just approved is not held or prompted a second time.
42
+ const isHostApproved = useRef(false);
43
+ const hostApprovalTimer = useRef(undefined);
44
+ const endHostApproval = useCallback(() => {
45
+ isHostApproved.current = false;
46
+ clearTimeout(hostApprovalTimer.current);
47
+ }, []);
48
+ /** Whether the host's approved navigation is the one happening now; the approval covers one navigation only. */
49
+ const takeHostApproval = useCallback(() => {
50
+ const isApproved = isHostApproved.current;
51
+ endHostApproval();
52
+ return isApproved;
53
+ }, [endHostApproval]);
54
+ // A change of search params or hash keeps the page, and the form on it, so only a change of path is held.
55
+ const shouldBlock = useCallback(({ currentLocation, nextLocation, historyAction }) => {
56
+ if (dirtyCount.current === 0 || currentLocation.pathname === nextLocation.pathname)
57
+ return false;
58
+ if (historyAction === 'POP') {
59
+ // A host asks before it navigates, through the bridge, so its own push or replace is never held or undone here.
60
+ if (isHostMove.current)
61
+ return false;
62
+ const entry = browserEntry(nextLocation.key);
63
+ // Outside the app the host is already switching apps, so holding the move here would only bring back an empty form.
64
+ if (entry && !isInside(window.location.pathname, basePath))
65
+ return false;
66
+ // Another router on the page has pushed since: this one would rewind by its own stale count, onto the wrong entry.
67
+ if (entry && !hasLeftFrom(currentPlace.current, leftPosition.current))
68
+ return false;
69
+ if (entry && !canRewind(currentPlace.current, { idx: entry.idx, position: historyPosition() }))
70
+ return false;
71
+ }
72
+ return !takeHostApproval();
73
+ }, [takeHostApproval, basePath]);
74
+ // biome-ignore lint/correctness/useExhaustiveDependencies: read again on every navigation, which gives a new location
75
+ useEffect(() => {
76
+ currentPlace.current = { idx: historyIndex(), position: historyPosition() };
77
+ }, [location]);
78
+ useEffect(() => watchLeftPosition((position) => {
79
+ leftPosition.current = position;
80
+ }), []);
81
+ useEffect(() => {
82
+ // A host tells its apps it has navigated by dispatching `popstate` itself, which the browser marks as not trusted.
83
+ const noteHostMove = (event) => {
84
+ if (event.isTrusted)
85
+ return;
86
+ isHostMove.current = true;
87
+ // Only while this event is handled: the router's own listener runs in the same dispatch.
88
+ queueMicrotask(() => {
89
+ isHostMove.current = false;
90
+ });
91
+ };
92
+ window.addEventListener('popstate', noteHostMove, true);
93
+ return () => window.removeEventListener('popstate', noteHostMove, true);
94
+ }, []);
95
+ // biome-ignore lint/correctness/useExhaustiveDependencies: a new path or a new set of unsaved forms ends the host's approval
96
+ useEffect(() => endHostApproval, [pathname, dirtyIds, endHostApproval]);
97
+ useEffect(() => {
98
+ if (!hasUnsavedChanges)
99
+ return;
100
+ const warn = (event) => {
101
+ if (takeHostApproval())
102
+ return;
103
+ event.preventDefault();
104
+ // Chromium before 119 only prompts when `returnValue` is set.
105
+ event.returnValue = true;
106
+ };
107
+ window.addEventListener('beforeunload', warn);
108
+ return () => window.removeEventListener('beforeunload', warn);
109
+ }, [hasUnsavedChanges, takeHostApproval]);
110
+ useEffect(() => {
111
+ const guard = hasUnsavedChanges ? hostGuard() : undefined;
112
+ if (!guard)
113
+ return;
114
+ let pending = null;
115
+ let isRegistered = true;
116
+ const canLeave = () => new Promise((resolve) => {
117
+ // A host holding a registration that has since gone has nothing left to wait for.
118
+ if (!isRegistered)
119
+ return resolve(true);
120
+ // A second request replaces the first, which is answered "stay" so the host is never left waiting.
121
+ pending?.(false);
122
+ pending = resolve;
123
+ setAnswerHost(() => resolve);
124
+ });
125
+ let unregister;
126
+ try {
127
+ unregister = guard.register({ basePath, canLeave });
128
+ }
129
+ catch {
130
+ // A bridge that throws is treated as no bridge: this runs outside the app's error boundary, so it would take the page down.
131
+ return;
132
+ }
133
+ return () => {
134
+ isRegistered = false;
135
+ try {
136
+ unregister();
137
+ }
138
+ catch {
139
+ // Ignored, as a `register` that throws is: this cleanup runs outside the app's error boundary too.
140
+ }
141
+ // Nothing is left to lose once the changes are saved or the form is gone, so a waiting host may go.
142
+ pending?.(true);
143
+ setAnswerHost(null);
144
+ };
145
+ }, [hasUnsavedChanges, basePath]);
146
+ /** Answers a held navigation, once: lets it go ahead, or puts the user back where they were. */
147
+ const settle = useCallback((held, leave) => {
148
+ if (held?.state !== 'blocked' || settledBlocker.current === held)
149
+ return;
150
+ settledBlocker.current = held;
151
+ if (leave)
152
+ held.proceed();
153
+ else
154
+ held.reset();
155
+ }, []);
156
+ // A navigation held while a save was in flight has nothing left to protect once the save lands.
157
+ useEffect(() => {
158
+ if (!hasUnsavedChanges)
159
+ settle(blocker, true);
160
+ }, [hasUnsavedChanges, blocker, settle]);
161
+ const register = useCallback((id) => {
162
+ dirtyCount.current += 1;
163
+ setDirtyIds((ids) => [...ids, id]);
164
+ return () => {
165
+ dirtyCount.current -= 1;
166
+ setDirtyIds((ids) => ids.filter((current) => current !== id));
167
+ };
168
+ }, []);
169
+ const answer = useCallback((leave) => {
170
+ settle(blocker, leave);
171
+ if (answerHost) {
172
+ endHostApproval();
173
+ if (leave) {
174
+ isHostApproved.current = true;
175
+ // A host that then does not navigate (another app said stay) must not leave the form unguarded.
176
+ hostApprovalTimer.current = setTimeout(endHostApproval, HOST_APPROVAL_MS);
177
+ }
178
+ answerHost(leave);
179
+ setAnswerHost(null);
180
+ }
181
+ }, [blocker, answerHost, endHostApproval, settle]);
182
+ const value = useMemo(() => ({ register, promptOwner: dirtyIds[0], isPromptOpen: blocker?.state === 'blocked' || answerHost !== null, answer }), [register, dirtyIds, blocker?.state, answerHost, answer]);
183
+ // Kept until a held navigation has finished, so one let go by a save is not dropped with the blocker.
184
+ const isBlockerNeeded = hasUnsavedChanges || (blocker !== null && blocker.state !== 'unblocked');
185
+ return (jsxs(UnsavedChangesGuardContext, { value: value, children: [isBlockerNeeded && jsx(NavigationHold, { shouldBlock: shouldBlock, onChange: setBlocker }), children] }));
186
+ };
187
+
188
+ export { UnsavedChangesGuardProvider };
189
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/providers/UnsavedChangesGuardProvider/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;AA4BA;AACA,MAAM,cAAc,GAAG,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAuB,KAAI;AACxE,IAAA,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC;AACvC,IAAA,SAAS,CAAC,MAAM,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACvD,IAAA,SAAS,CAAC,MAAM,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;AACjD,IAAA,OAAO,IAAI;AACb,CAAC;AAED;;;;;AAKG;MACU,2BAA2B,GAAG,CAAC,EAAE,QAAQ,EAAqB,KAAI;;AAE7E,IAAA,IAAI,CAAC,UAAU,CAAC,wBAAwB,CAAC,EAAE;AACzC,QAAA,MAAM,IAAI,KAAK,CACb,qIAAqI,CACtI;IACH;IACA,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAW,EAAE,CAAC;AAC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,QAAQ,EAAE,UAAU,EAAA,CAAI,EACrF,QAAQ,CAAA,EAAA,CACkB;AAEjC;;"}
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ /** How long a host has to make the navigation the user approved; Portal pushes within a frame of the answer. */
4
+ const HOST_APPROVAL_MS = 1000;
5
+
6
+ exports.HOST_APPROVAL_MS = HOST_APPROVAL_MS;
7
+ //# sourceMappingURL=unsavedChangesGuard.constants.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsavedChangesGuard.constants.cjs","sources":["../../../src/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACO,MAAM,gBAAgB,GAAG;;"}
@@ -0,0 +1,3 @@
1
+ /** How long a host has to make the navigation the user approved; Portal pushes within a frame of the answer. */
2
+ export declare const HOST_APPROVAL_MS = 1000;
3
+ //# sourceMappingURL=unsavedChangesGuard.constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsavedChangesGuard.constants.d.ts","sourceRoot":"","sources":["../../../src/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,eAAO,MAAM,gBAAgB,OAAO,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** How long a host has to make the navigation the user approved; Portal pushes within a frame of the answer. */
2
+ const HOST_APPROVAL_MS = 1000;
3
+
4
+ export { HOST_APPROVAL_MS };
5
+ //# sourceMappingURL=unsavedChangesGuard.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsavedChangesGuard.constants.js","sources":["../../../src/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACO,MAAM,gBAAgB,GAAG;;"}
@@ -0,0 +1,21 @@
1
+ /** What an app registers with its host so the host asks before navigating away from it. */
2
+ export interface FdNavigationGuardRegistration {
3
+ /** The app's router base path, so the host can leave back and forward moves inside it to the app. */
4
+ basePath?: string;
5
+ /**
6
+ * Resolves `true` to let the host navigate, `false` to stay. The app shows its own prompt. Navigate straight after a
7
+ * `true`, by a push followed by a `popstate` event: the approval covers the next navigation for one second only.
8
+ */
9
+ canLeave: () => Promise<boolean>;
10
+ }
11
+ /** The bridge a host such as Portal puts on `window.fdNavigationGuard` for the apps it mounts. */
12
+ export interface FdNavigationGuard {
13
+ /** Registers a check the host awaits before leaving the app; returns the function that removes it. */
14
+ register: (registration: FdNavigationGuardRegistration) => () => void;
15
+ }
16
+ /** Where a history entry sits: by react-router's own index and, where the browser has the Navigation API, by the browser's count. */
17
+ export interface HistoryPlace {
18
+ idx: unknown;
19
+ position: number | undefined;
20
+ }
21
+ //# sourceMappingURL=unsavedChangesGuard.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsavedChangesGuard.types.d.ts","sourceRoot":"","sources":["../../../src/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.types.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,MAAM,WAAW,6BAA6B;IAC5C,qGAAqG;IACrG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,QAAQ,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAClC;AAED,kGAAkG;AAClG,MAAM,WAAW,iBAAiB;IAChC,sGAAsG;IACtG,QAAQ,EAAE,CAAC,YAAY,EAAE,6BAA6B,KAAK,MAAM,IAAI,CAAC;CACvE;AAED,qIAAqI;AACrI,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B"}
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Reads the bridge a host such as Portal puts on the window for the apps it mounts.
5
+ *
6
+ * @returns The host's guard, or `undefined` when the app runs on its own.
7
+ */
8
+ const hostGuard = () => window.fdNavigationGuard;
9
+ /**
10
+ * Reads the index react-router stores on the current history entry.
11
+ *
12
+ * @returns The index; missing or `NaN` on and after an entry a host pushed itself.
13
+ */
14
+ const historyIndex = () => window.history.state?.idx;
15
+ /**
16
+ * Reads the browser's own count for the current history entry.
17
+ *
18
+ * @returns The entry's index in the Navigation API, or `undefined` where the browser has none.
19
+ */
20
+ const historyPosition = () => window.navigation?.currentEntry?.index;
21
+ /**
22
+ * Reports the browser's own count for the entry each navigation leaves, where the browser has the Navigation API.
23
+ *
24
+ * @param onLeave Called on every push, replace and back or forward move with the count of the entry left, before any `popstate` listener runs.
25
+ * @returns The function that stops it.
26
+ */
27
+ const watchLeftPosition = (onLeave) => {
28
+ const { navigation } = window;
29
+ if (!navigation)
30
+ return () => { };
31
+ // A polyfill or a test double may call the listener with no event: the entry left is then unknown, not an error.
32
+ const note = (event) => onLeave(event?.from?.index);
33
+ navigation.addEventListener('currententrychange', note);
34
+ return () => navigation.removeEventListener('currententrychange', note);
35
+ };
36
+ /**
37
+ * Whether the entry the user has just left is the one this router last saw them on. Another router on the page pushes
38
+ * entries this one never hears of; its own count is then stale, and a rewind by it would land on the wrong entry.
39
+ *
40
+ * @param place Where this router last saw the user.
41
+ * @param leftPosition The browser's count for the entry the move left, or `undefined` where the browser gives none.
42
+ * @returns `false` only when the browser's count shows the user had moved on from `place`.
43
+ */
44
+ const hasLeftFrom = (place, leftPosition) => place.position === undefined || leftPosition === undefined || place.position === leftPosition;
45
+ /**
46
+ * Whether react-router can put the user back after a back or forward move it holds. It rewinds by the difference of the
47
+ * two entries' indexes, so a difference that is missing or zero reloads the page, and a wrong one lands on another entry.
48
+ *
49
+ * @param from The entry the user was on.
50
+ * @param to The entry the move has landed on.
51
+ * @returns `true` when the indexes give a distance, and the browser's own count, where it has one, agrees with it.
52
+ */
53
+ const canRewind = (from, to) => {
54
+ const distance = typeof from.idx === 'number' && typeof to.idx === 'number' ? to.idx - from.idx : Number.NaN;
55
+ if (!Number.isFinite(distance) || distance === 0)
56
+ return false;
57
+ // Two routers on one page can number the entries differently; the browser's count is the real distance.
58
+ if (from.position === undefined || to.position === undefined)
59
+ return true;
60
+ return to.position - from.position === distance;
61
+ };
62
+ /**
63
+ * The browser history entry a back or forward move has landed on, when the router is a browser router.
64
+ *
65
+ * @param nextKey The key of the location the router is moving to.
66
+ * @returns The entry's index, or `undefined` under a memory router, which keeps nothing in `window.history`.
67
+ */
68
+ const browserEntry = (nextKey) => {
69
+ const state = window.history.state;
70
+ if (typeof state !== 'object' || state === null || !('idx' in state))
71
+ return undefined;
72
+ // A browser router's entry carries the location's key, or none when the router did not push it, whose key is `'default'`.
73
+ const key = 'key' in state ? state.key : 'default';
74
+ return key === nextKey ? { idx: state.idx } : undefined;
75
+ };
76
+ /**
77
+ * Whether a path is the app's base path or beneath it. Case does not matter, as it does not to react-router when it matches the base path.
78
+ *
79
+ * @param pathname The path to test, such as `window.location.pathname`.
80
+ * @param basePath The app's router base path; trailing slashes are ignored.
81
+ * @returns `true` when the path is inside the app.
82
+ */
83
+ const isInside = (pathname, basePath) => {
84
+ const base = basePath.replace(/\/+$/, '').toLowerCase();
85
+ const path = pathname.toLowerCase();
86
+ return path === base || path.startsWith(`${base}/`);
87
+ };
88
+
89
+ exports.browserEntry = browserEntry;
90
+ exports.canRewind = canRewind;
91
+ exports.hasLeftFrom = hasLeftFrom;
92
+ exports.historyIndex = historyIndex;
93
+ exports.historyPosition = historyPosition;
94
+ exports.hostGuard = hostGuard;
95
+ exports.isInside = isInside;
96
+ exports.watchLeftPosition = watchLeftPosition;
97
+ //# sourceMappingURL=unsavedChangesGuard.utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsavedChangesGuard.utils.cjs","sources":["../../../../src/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;AAIG;AACI,MAAM,SAAS,GAAG,MAAsC,MAA6D,CAAC;AAE7H;;;;AAIG;AACI,MAAM,YAAY,GAAG,MAAgB,MAAM,CAAC,O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D;AAEA;;;;;AAKG;AACI,MAAM,YAAY,GAAG,CAAC,OAAe,KAAkC;AAC5E,IAAA,MAAM,KAAK,GAAY,MAAM,CAAC,OAAO,CAAC,KAAK;AAC3C,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,KAAK,CAAC;AAAE,QAAA,OAAO,SAAS;;AAEtF,IAAA,MAAM,GAAG,GAAG,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC,GAAG,GAAG,SAAS;AAClD,IAAA,OAAO,GAAG,KAAK,OAAO,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,SAAS;AACzD;AAEA;;;;;;AAMG;MACU,QAAQ,GAAG,CAAC,QAAgB,EAAE,QAAgB,KAAI;AAC7D,IAAA,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE;AACvD,IAAA,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,EAAE;AACnC,IAAA,OAAO,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,CAAA,EAAG,IAAI,CAAA,CAAA,CAAG,CAAC;AACrD;;;;;;;;;"}
@@ -0,0 +1,62 @@
1
+ import type { FdNavigationGuard, HistoryPlace } from '../unsavedChangesGuard.types';
2
+ /**
3
+ * Reads the bridge a host such as Portal puts on the window for the apps it mounts.
4
+ *
5
+ * @returns The host's guard, or `undefined` when the app runs on its own.
6
+ */
7
+ export declare const hostGuard: () => FdNavigationGuard | undefined;
8
+ /**
9
+ * Reads the index react-router stores on the current history entry.
10
+ *
11
+ * @returns The index; missing or `NaN` on and after an entry a host pushed itself.
12
+ */
13
+ export declare const historyIndex: () => unknown;
14
+ /**
15
+ * Reads the browser's own count for the current history entry.
16
+ *
17
+ * @returns The entry's index in the Navigation API, or `undefined` where the browser has none.
18
+ */
19
+ export declare const historyPosition: () => number | undefined;
20
+ /**
21
+ * Reports the browser's own count for the entry each navigation leaves, where the browser has the Navigation API.
22
+ *
23
+ * @param onLeave Called on every push, replace and back or forward move with the count of the entry left, before any `popstate` listener runs.
24
+ * @returns The function that stops it.
25
+ */
26
+ export declare const watchLeftPosition: (onLeave: (position: number | undefined) => void) => (() => void);
27
+ /**
28
+ * Whether the entry the user has just left is the one this router last saw them on. Another router on the page pushes
29
+ * entries this one never hears of; its own count is then stale, and a rewind by it would land on the wrong entry.
30
+ *
31
+ * @param place Where this router last saw the user.
32
+ * @param leftPosition The browser's count for the entry the move left, or `undefined` where the browser gives none.
33
+ * @returns `false` only when the browser's count shows the user had moved on from `place`.
34
+ */
35
+ export declare const hasLeftFrom: (place: HistoryPlace, leftPosition: number | undefined) => boolean;
36
+ /**
37
+ * Whether react-router can put the user back after a back or forward move it holds. It rewinds by the difference of the
38
+ * two entries' indexes, so a difference that is missing or zero reloads the page, and a wrong one lands on another entry.
39
+ *
40
+ * @param from The entry the user was on.
41
+ * @param to The entry the move has landed on.
42
+ * @returns `true` when the indexes give a distance, and the browser's own count, where it has one, agrees with it.
43
+ */
44
+ export declare const canRewind: (from: HistoryPlace, to: HistoryPlace) => boolean;
45
+ /**
46
+ * The browser history entry a back or forward move has landed on, when the router is a browser router.
47
+ *
48
+ * @param nextKey The key of the location the router is moving to.
49
+ * @returns The entry's index, or `undefined` under a memory router, which keeps nothing in `window.history`.
50
+ */
51
+ export declare const browserEntry: (nextKey: string) => {
52
+ idx: unknown;
53
+ } | undefined;
54
+ /**
55
+ * Whether a path is the app's base path or beneath it. Case does not matter, as it does not to react-router when it matches the base path.
56
+ *
57
+ * @param pathname The path to test, such as `window.location.pathname`.
58
+ * @param basePath The app's router base path; trailing slashes are ignored.
59
+ * @returns `true` when the path is inside the app.
60
+ */
61
+ export declare const isInside: (pathname: string, basePath: string) => boolean;
62
+ //# sourceMappingURL=unsavedChangesGuard.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsavedChangesGuard.utils.d.ts","sourceRoot":"","sources":["../../../../src/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEpF;;;;GAIG;AACH,eAAO,MAAM,SAAS,QAAO,iBAAiB,GAAG,SAA6F,CAAC;AAE/I;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAO,OAAkE,CAAC;AAEnG;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAO,MAAM,GAAG,SAAgG,CAAC;AAS7I;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,KAAG,CAAC,MAAM,IAAI,CAO9F,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,YAAY,EAAE,cAAc,MAAM,GAAG,SAAS,YACc,CAAC;AAEhG;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,YAAY,EAAE,IAAI,YAAY,YAM7D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,GAAG,SAMjE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,UAAU,MAAM,EAAE,UAAU,MAAM,YAI1D,CAAC"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Reads the bridge a host such as Portal puts on the window for the apps it mounts.
3
+ *
4
+ * @returns The host's guard, or `undefined` when the app runs on its own.
5
+ */
6
+ const hostGuard = () => window.fdNavigationGuard;
7
+ /**
8
+ * Reads the index react-router stores on the current history entry.
9
+ *
10
+ * @returns The index; missing or `NaN` on and after an entry a host pushed itself.
11
+ */
12
+ const historyIndex = () => window.history.state?.idx;
13
+ /**
14
+ * Reads the browser's own count for the current history entry.
15
+ *
16
+ * @returns The entry's index in the Navigation API, or `undefined` where the browser has none.
17
+ */
18
+ const historyPosition = () => window.navigation?.currentEntry?.index;
19
+ /**
20
+ * Reports the browser's own count for the entry each navigation leaves, where the browser has the Navigation API.
21
+ *
22
+ * @param onLeave Called on every push, replace and back or forward move with the count of the entry left, before any `popstate` listener runs.
23
+ * @returns The function that stops it.
24
+ */
25
+ const watchLeftPosition = (onLeave) => {
26
+ const { navigation } = window;
27
+ if (!navigation)
28
+ return () => { };
29
+ // A polyfill or a test double may call the listener with no event: the entry left is then unknown, not an error.
30
+ const note = (event) => onLeave(event?.from?.index);
31
+ navigation.addEventListener('currententrychange', note);
32
+ return () => navigation.removeEventListener('currententrychange', note);
33
+ };
34
+ /**
35
+ * Whether the entry the user has just left is the one this router last saw them on. Another router on the page pushes
36
+ * entries this one never hears of; its own count is then stale, and a rewind by it would land on the wrong entry.
37
+ *
38
+ * @param place Where this router last saw the user.
39
+ * @param leftPosition The browser's count for the entry the move left, or `undefined` where the browser gives none.
40
+ * @returns `false` only when the browser's count shows the user had moved on from `place`.
41
+ */
42
+ const hasLeftFrom = (place, leftPosition) => place.position === undefined || leftPosition === undefined || place.position === leftPosition;
43
+ /**
44
+ * Whether react-router can put the user back after a back or forward move it holds. It rewinds by the difference of the
45
+ * two entries' indexes, so a difference that is missing or zero reloads the page, and a wrong one lands on another entry.
46
+ *
47
+ * @param from The entry the user was on.
48
+ * @param to The entry the move has landed on.
49
+ * @returns `true` when the indexes give a distance, and the browser's own count, where it has one, agrees with it.
50
+ */
51
+ const canRewind = (from, to) => {
52
+ const distance = typeof from.idx === 'number' && typeof to.idx === 'number' ? to.idx - from.idx : Number.NaN;
53
+ if (!Number.isFinite(distance) || distance === 0)
54
+ return false;
55
+ // Two routers on one page can number the entries differently; the browser's count is the real distance.
56
+ if (from.position === undefined || to.position === undefined)
57
+ return true;
58
+ return to.position - from.position === distance;
59
+ };
60
+ /**
61
+ * The browser history entry a back or forward move has landed on, when the router is a browser router.
62
+ *
63
+ * @param nextKey The key of the location the router is moving to.
64
+ * @returns The entry's index, or `undefined` under a memory router, which keeps nothing in `window.history`.
65
+ */
66
+ const browserEntry = (nextKey) => {
67
+ const state = window.history.state;
68
+ if (typeof state !== 'object' || state === null || !('idx' in state))
69
+ return undefined;
70
+ // A browser router's entry carries the location's key, or none when the router did not push it, whose key is `'default'`.
71
+ const key = 'key' in state ? state.key : 'default';
72
+ return key === nextKey ? { idx: state.idx } : undefined;
73
+ };
74
+ /**
75
+ * Whether a path is the app's base path or beneath it. Case does not matter, as it does not to react-router when it matches the base path.
76
+ *
77
+ * @param pathname The path to test, such as `window.location.pathname`.
78
+ * @param basePath The app's router base path; trailing slashes are ignored.
79
+ * @returns `true` when the path is inside the app.
80
+ */
81
+ const isInside = (pathname, basePath) => {
82
+ const base = basePath.replace(/\/+$/, '').toLowerCase();
83
+ const path = pathname.toLowerCase();
84
+ return path === base || path.startsWith(`${base}/`);
85
+ };
86
+
87
+ export { browserEntry, canRewind, hasLeftFrom, historyIndex, historyPosition, hostGuard, isInside, watchLeftPosition };
88
+ //# sourceMappingURL=unsavedChangesGuard.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsavedChangesGuard.utils.js","sources":["../../../../src/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;;;;AAIG;AACI,MAAM,SAAS,GAAG,MAAsC,MAA6D,CAAC;AAE7H;;;;AAIG;AACI,MAAM,YAAY,GAAG,MAAgB,MAAM,CAAC,OAAO,CAAC,KAAkC,EAAE;AAE/F;;;;AAIG;AACI,MAAM,eAAe,GAAG,MAA2B,MAAkD,CAAC,UAAU,EAAE,YAAY,EAAE;AASvI;;;;;AAKG;AACI,MAAM,iBAAiB,GAAG,CAAC,OAA+C,KAAkB;AACjG,IAAA,MAAM,EAAE,UAAU,EAAE,GAAG,MAAiD;AACxE,IAAA,IAAI,CAAC,UAAU;AAAE,QAAA,OAAO,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AM,GAAG,GAAG,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC,GAAG,GAAG,SAAS;AAClD,IAAA,OAAO,GAAG,KAAK,OAAO,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,SAAS;AACzD;AAEA;;;;;;AAMG;MACU,QAAQ,GAAG,CAAC,QAAgB,EAAE,QAAgB,KAAI;AAC7D,IAAA,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE;AACvD,IAAA,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,EAAE;AACnC,IAAA,OAAO,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,CAAA,EAAG,IAAI,CAAA,CAAA,CAAG,CAAC;AACrD;;"}
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ var en = require('../../../localization/en.json.cjs');
4
+
5
+ /**
6
+ * The library's own text, read from the language files `scripts/sync-localization.mjs` copies in from the repo's
7
+ * `localization/` folder. INTERNAL: import as `#internal/utilities/builtInTextUtils/builtInText.utils`.
8
+ */
9
+ const FALLBACK_LANGUAGE = 'en';
10
+ // `en` alone formats a date the American way; Portal's `en` is British and Irish English, and `en-US` is its own file.
11
+ const DATE_LOCALES = { en: 'en-GB' };
12
+ const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
13
+ /**
14
+ * Fills a message's `{name}` placeholders.
15
+ *
16
+ * @param message The message, with a `{name}` placeholder wherever a value belongs.
17
+ * @param values The value for each placeholder; one with no value is left as written.
18
+ * @returns The message with its placeholders filled.
19
+ */
20
+ const fillPlaceholders = (message, values = {}) => message.replace(/\{(\w+)\}/g, (placeholder, name) => (name in values ? String(values[name]) : placeholder));
21
+ /**
22
+ * Writes an ISO date the way the language's readers do, such as `13 Nov 2026`, and passes any other value through.
23
+ *
24
+ * @param value A placeholder's value.
25
+ * @param language The language the message is shown in.
26
+ * @returns The date as text, or the value unchanged when it is not an ISO date.
27
+ */
28
+ const readable = (value, language) => {
29
+ if (typeof value !== 'string' || !ISO_DATE.test(value))
30
+ return value;
31
+ try {
32
+ return new Intl.DateTimeFormat(DATE_LOCALES[language] ?? language, { dateStyle: 'medium', timeZone: 'UTC' }).format(new Date(`${value}T00:00:00Z`));
33
+ }
34
+ catch {
35
+ // A language tag or option this runtime's `Intl` does not know: the ISO date still reads.
36
+ return value;
37
+ }
38
+ };
39
+ /**
40
+ * Builds the lookup for one package's messages.
41
+ *
42
+ * @param languages The package's language files, keyed by language.
43
+ * @returns A function from a message id, its placeholder values and a language to the text to show. A message or a
44
+ * language the files do not hold is shown in English, and a date among the values is written for the language.
45
+ */
46
+ const createBuiltInText = (languages) => (id, values = {}, language = FALLBACK_LANGUAGE) => {
47
+ const message = languages[language]?.[id]?.value ?? languages.en[id].value;
48
+ const readableValues = Object.fromEntries(Object.entries(values).map(([name, value]) => [name, readable(value, language)]));
49
+ return fillPlaceholders(message, readableValues);
50
+ };
51
+ /** The text of one of the library's own messages. English until the `TranslationProvider` supplies the language. */
52
+ const builtInText = createBuiltInText({ en: en.default });
53
+ /**
54
+ * The English wording of one of the library's messages, with its placeholders unfilled.
55
+ *
56
+ * @param id The message's id.
57
+ * @returns The message as `localization/en.json` holds it.
58
+ */
59
+ const builtInTextTemplate = (id) => en.default[id].value;
60
+ const ID_BY_TEMPLATE = new Map(Object.entries(en.default).map(([id, { value }]) => [value, id]));
61
+ /**
62
+ * Finds the id behind a message that is one of the library's own, so it can be shown in the reader's language.
63
+ *
64
+ * @param template A message as written, with its placeholders unfilled.
65
+ * @returns The message's id, or `undefined` for text the library does not ship.
66
+ */
67
+ const builtInTextIdOf = (template) => ID_BY_TEMPLATE.get(template);
68
+
69
+ exports.builtInText = builtInText;
70
+ exports.builtInTextIdOf = builtInTextIdOf;
71
+ exports.builtInTextTemplate = builtInTextTemplate;
72
+ exports.createBuiltInText = createBuiltInText;
73
+ exports.fillPlaceholders = fillPlaceholders;
74
+ //# sourceMappingURL=builtInText.utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtInText.utils.cjs","sources":["../../../../src/utilities/__internal__/builtInTextUtils/builtInText.utils.ts"],"sourcesContent":[null],"names":["en"],"mappings":";;;;AAAA;;;AAGG;AAiBH,MAAM,iBAAiB,GAAG,IAAI;AAC9B;AACA,MAAM,YAAY,GAA2B,EAAE,EAAE,EAAE,OAAO,EAAE;AAC5D,MAAM,QAAQ,GAAG,qBAAqB;AAEtC;;;;;;AAMG;MACU,gBAAgB,GAAG,CAAC,OAAe,EAAE,SAAqB,EAAE,KACvE,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,WAAW,EAAE,IAAY,MAAM,IAAI,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,WAAW,CAAC;AAEpH;;;;;;AAMG;AACH,MAAM,QAAQ,GAAG,CAAC,KAAsB,EAAE,QAAgB,KAAqB;IAC7E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK;AACpE,IAAA,IAAI;AACF,QAAA,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,QAAQ,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CACjH,IAAI,IAAI,CAAC,CAAA,EAAG,KAAK,CAAA,UAAA,CAAY,CAAC,CAC/B;IACH;AAAE,IAAA,MAAM;;AAEN,QAAA,OAAO,KAAK;IACd;AACF,CAAC;AAED;;;;;;AAMG;AACI,MAAM,iBAAiB,GAC5B,CAAqB,SAAyB,KAC9C,CAAC,EAAO,EAAE,MAAA,GAAqB,EAAE,EAAE,QAAA,GAAmB,iBAAiB,KAAY;IACjF,MAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,EA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