@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.
- package/README.md +17 -16
- package/dist/components/atoms/Checkbox/index.cjs +11 -3
- package/dist/components/atoms/Checkbox/index.cjs.map +1 -1
- package/dist/components/atoms/Checkbox/index.d.ts.map +1 -1
- package/dist/components/atoms/Checkbox/index.js +12 -4
- package/dist/components/atoms/Checkbox/index.js.map +1 -1
- package/dist/components/atoms/Slider/index.cjs +2 -2
- package/dist/components/atoms/Slider/index.cjs.map +1 -1
- package/dist/components/atoms/Slider/index.d.ts +3 -1
- package/dist/components/atoms/Slider/index.d.ts.map +1 -1
- package/dist/components/atoms/Slider/index.js +2 -2
- package/dist/components/atoms/Slider/index.js.map +1 -1
- package/dist/components/forms/Form/hooks/useForm.cjs +26 -0
- package/dist/components/forms/Form/hooks/useForm.cjs.map +1 -0
- package/dist/components/forms/Form/hooks/useForm.d.ts +13 -0
- package/dist/components/forms/Form/hooks/useForm.d.ts.map +1 -0
- package/dist/components/forms/Form/hooks/useForm.js +24 -0
- package/dist/components/forms/Form/hooks/useForm.js.map +1 -0
- package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.cjs +28 -0
- package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.cjs.map +1 -0
- package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.d.ts +10 -0
- package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.d.ts.map +1 -0
- package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.js +26 -0
- package/dist/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.js.map +1 -0
- package/dist/components/forms/Form/index.cjs +43 -0
- package/dist/components/forms/Form/index.cjs.map +1 -0
- package/dist/components/forms/Form/index.d.ts +30 -0
- package/dist/components/forms/Form/index.d.ts.map +1 -0
- package/dist/components/forms/Form/index.js +40 -0
- package/dist/components/forms/Form/index.js.map +1 -0
- package/dist/components/forms/Form/utilities/formSubmit.utils.cjs +23 -0
- package/dist/components/forms/Form/utilities/formSubmit.utils.cjs.map +1 -0
- package/dist/components/forms/Form/utilities/formSubmit.utils.d.ts +14 -0
- package/dist/components/forms/Form/utilities/formSubmit.utils.d.ts.map +1 -0
- package/dist/components/forms/Form/utilities/formSubmit.utils.js +21 -0
- package/dist/components/forms/Form/utilities/formSubmit.utils.js.map +1 -0
- package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.cjs +39 -0
- package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.cjs.map +1 -0
- package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.d.ts +17 -0
- package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.d.ts.map +1 -0
- package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.js +37 -0
- package/dist/components/forms/FormFooter/hooks/useDestructiveConfirmation.js.map +1 -0
- package/dist/components/forms/FormFooter/hooks/useHasFieldError.cjs +26 -0
- package/dist/components/forms/FormFooter/hooks/useHasFieldError.cjs.map +1 -0
- package/dist/components/forms/FormFooter/hooks/useHasFieldError.d.ts +9 -0
- package/dist/components/forms/FormFooter/hooks/useHasFieldError.d.ts.map +1 -0
- package/dist/components/forms/FormFooter/hooks/useHasFieldError.js +24 -0
- package/dist/components/forms/FormFooter/hooks/useHasFieldError.js.map +1 -0
- package/dist/components/forms/FormFooter/index.cjs +41 -0
- package/dist/components/forms/FormFooter/index.cjs.map +1 -0
- package/dist/components/forms/FormFooter/index.d.ts +52 -0
- package/dist/components/forms/FormFooter/index.d.ts.map +1 -0
- package/dist/components/forms/FormFooter/index.js +39 -0
- package/dist/components/forms/FormFooter/index.js.map +1 -0
- package/dist/components/forms/FormFooter/utilities/formFooter.utils.cjs +21 -0
- package/dist/components/forms/FormFooter/utilities/formFooter.utils.cjs.map +1 -0
- package/dist/components/forms/FormFooter/utilities/formFooter.utils.d.ts +12 -0
- package/dist/components/forms/FormFooter/utilities/formFooter.utils.d.ts.map +1 -0
- package/dist/components/forms/FormFooter/utilities/formFooter.utils.js +19 -0
- package/dist/components/forms/FormFooter/utilities/formFooter.utils.js.map +1 -0
- package/dist/components/forms/FormSection/FormSection.styles.cjs +15 -0
- package/dist/components/forms/FormSection/FormSection.styles.cjs.map +1 -0
- package/dist/components/forms/FormSection/FormSection.styles.d.ts +9 -0
- package/dist/components/forms/FormSection/FormSection.styles.d.ts.map +1 -0
- package/dist/components/forms/FormSection/FormSection.styles.js +13 -0
- package/dist/components/forms/FormSection/FormSection.styles.js.map +1 -0
- package/dist/components/forms/FormSection/index.cjs +43 -0
- package/dist/components/forms/FormSection/index.cjs.map +1 -0
- package/dist/components/forms/FormSection/index.d.ts +41 -0
- package/dist/components/forms/FormSection/index.d.ts.map +1 -0
- package/dist/components/forms/FormSection/index.js +41 -0
- package/dist/components/forms/FormSection/index.js.map +1 -0
- package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.cjs +28 -0
- package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.cjs.map +1 -0
- package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.d.ts +12 -0
- package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.d.ts.map +1 -0
- package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.js +26 -0
- package/dist/components/forms/__internal__/formField/hooks/useFocusTarget.js.map +1 -0
- package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.cjs +68 -0
- package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.cjs.map +1 -0
- package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.d.ts +26 -0
- package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.d.ts.map +1 -0
- package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.js +66 -0
- package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.js.map +1 -0
- package/dist/components/forms/__internal__/formField/hooks/useFormField.cjs +142 -0
- package/dist/components/forms/__internal__/formField/hooks/useFormField.cjs.map +1 -0
- package/dist/components/forms/__internal__/formField/hooks/useFormField.d.ts +35 -0
- package/dist/components/forms/__internal__/formField/hooks/useFormField.d.ts.map +1 -0
- package/dist/components/forms/__internal__/formField/hooks/useFormField.js +140 -0
- package/dist/components/forms/__internal__/formField/hooks/useFormField.js.map +1 -0
- package/dist/components/forms/__internal__/formField/providers/FieldElements.context.cjs +12 -0
- package/dist/components/forms/__internal__/formField/providers/FieldElements.context.cjs.map +1 -0
- package/dist/components/forms/__internal__/formField/providers/FieldElements.context.d.ts +7 -0
- package/dist/components/forms/__internal__/formField/providers/FieldElements.context.d.ts.map +1 -0
- package/dist/components/forms/__internal__/formField/providers/FieldElements.context.js +10 -0
- package/dist/components/forms/__internal__/formField/providers/FieldElements.context.js.map +1 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.cjs +39 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.cjs.map +1 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.d.ts +21 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.d.ts.map +1 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.js +37 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldElements.utils.js.map +1 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.cjs +40 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.cjs.map +1 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.d.ts +18 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.d.ts.map +1 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.js +37 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldValue.utils.js.map +1 -0
- package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.cjs +21 -0
- package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.cjs.map +1 -0
- package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.d.ts +11 -0
- package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.d.ts.map +1 -0
- package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.js +19 -0
- package/dist/components/forms/__internal__/formField/utilities/formFocus.utils.js.map +1 -0
- package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.cjs +128 -0
- package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.cjs.map +1 -0
- package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.d.ts +72 -0
- package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.d.ts.map +1 -0
- package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.js +121 -0
- package/dist/components/forms/__internal__/formField/utilities/validationQueue.utils.js.map +1 -0
- package/dist/components/forms/fields/FormCheckbox/index.cjs +34 -0
- package/dist/components/forms/fields/FormCheckbox/index.cjs.map +1 -0
- package/dist/components/forms/fields/FormCheckbox/index.d.ts +16 -0
- package/dist/components/forms/fields/FormCheckbox/index.d.ts.map +1 -0
- package/dist/components/forms/fields/FormCheckbox/index.js +32 -0
- package/dist/components/forms/fields/FormCheckbox/index.js.map +1 -0
- package/dist/components/forms/fields/FormCheckboxGroup/index.cjs +33 -0
- package/dist/components/forms/fields/FormCheckboxGroup/index.cjs.map +1 -0
- package/dist/components/forms/fields/FormCheckboxGroup/index.d.ts +16 -0
- package/dist/components/forms/fields/FormCheckboxGroup/index.d.ts.map +1 -0
- package/dist/components/forms/fields/FormCheckboxGroup/index.js +31 -0
- package/dist/components/forms/fields/FormCheckboxGroup/index.js.map +1 -0
- package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.cjs +26 -0
- package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.cjs.map +1 -0
- package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.d.ts +11 -0
- package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.d.ts.map +1 -0
- package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.js +24 -0
- package/dist/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.js.map +1 -0
- package/dist/components/forms/fields/FormColorPicker/index.cjs +33 -0
- package/dist/components/forms/fields/FormColorPicker/index.cjs.map +1 -0
- package/dist/components/forms/fields/FormColorPicker/index.d.ts +21 -0
- package/dist/components/forms/fields/FormColorPicker/index.d.ts.map +1 -0
- package/dist/components/forms/fields/FormColorPicker/index.js +31 -0
- package/dist/components/forms/fields/FormColorPicker/index.js.map +1 -0
- package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.cjs +20 -0
- package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.cjs.map +1 -0
- package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.d.ts +17 -0
- package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.d.ts.map +1 -0
- package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.js +18 -0
- package/dist/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.js.map +1 -0
- package/dist/components/forms/fields/FormDatePicker/index.cjs +35 -0
- package/dist/components/forms/fields/FormDatePicker/index.cjs.map +1 -0
- package/dist/components/forms/fields/FormDatePicker/index.d.ts +17 -0
- package/dist/components/forms/fields/FormDatePicker/index.d.ts.map +1 -0
- package/dist/components/forms/fields/FormDatePicker/index.js +33 -0
- package/dist/components/forms/fields/FormDatePicker/index.js.map +1 -0
- package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.cjs +23 -0
- package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.cjs.map +1 -0
- package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.d.ts +9 -0
- package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.d.ts.map +1 -0
- package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.js +21 -0
- package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.js.map +1 -0
- package/dist/components/forms/fields/FormInput/index.cjs +27 -0
- package/dist/components/forms/fields/FormInput/index.cjs.map +1 -0
- package/dist/components/forms/fields/FormInput/index.d.ts +16 -0
- package/dist/components/forms/fields/FormInput/index.d.ts.map +1 -0
- package/dist/components/forms/fields/FormInput/index.js +25 -0
- package/dist/components/forms/fields/FormInput/index.js.map +1 -0
- package/dist/components/forms/fields/FormMultiSelect/index.cjs +44 -0
- package/dist/components/forms/fields/FormMultiSelect/index.cjs.map +1 -0
- package/dist/components/forms/fields/FormMultiSelect/index.d.ts +17 -0
- package/dist/components/forms/fields/FormMultiSelect/index.d.ts.map +1 -0
- package/dist/components/forms/fields/FormMultiSelect/index.js +42 -0
- package/dist/components/forms/fields/FormMultiSelect/index.js.map +1 -0
- package/dist/components/forms/fields/FormRadioCardGroup/index.cjs +36 -0
- package/dist/components/forms/fields/FormRadioCardGroup/index.cjs.map +1 -0
- package/dist/components/forms/fields/FormRadioCardGroup/index.d.ts +29 -0
- package/dist/components/forms/fields/FormRadioCardGroup/index.d.ts.map +1 -0
- package/dist/components/forms/fields/FormRadioCardGroup/index.js +34 -0
- package/dist/components/forms/fields/FormRadioCardGroup/index.js.map +1 -0
- package/dist/components/forms/fields/FormRadioGroup/index.cjs +31 -0
- package/dist/components/forms/fields/FormRadioGroup/index.cjs.map +1 -0
- package/dist/components/forms/fields/FormRadioGroup/index.d.ts +17 -0
- package/dist/components/forms/fields/FormRadioGroup/index.d.ts.map +1 -0
- package/dist/components/forms/fields/FormRadioGroup/index.js +29 -0
- package/dist/components/forms/fields/FormRadioGroup/index.js.map +1 -0
- package/dist/components/forms/fields/FormSelect/index.cjs +30 -0
- package/dist/components/forms/fields/FormSelect/index.cjs.map +1 -0
- package/dist/components/forms/fields/FormSelect/index.d.ts +16 -0
- package/dist/components/forms/fields/FormSelect/index.d.ts.map +1 -0
- package/dist/components/forms/fields/FormSelect/index.js +28 -0
- package/dist/components/forms/fields/FormSelect/index.js.map +1 -0
- package/dist/components/forms/fields/FormSlider/index.cjs +43 -0
- package/dist/components/forms/fields/FormSlider/index.cjs.map +1 -0
- package/dist/components/forms/fields/FormSlider/index.d.ts +17 -0
- package/dist/components/forms/fields/FormSlider/index.d.ts.map +1 -0
- package/dist/components/forms/fields/FormSlider/index.js +41 -0
- package/dist/components/forms/fields/FormSlider/index.js.map +1 -0
- package/dist/components/forms/fields/FormTextArea/index.cjs +27 -0
- package/dist/components/forms/fields/FormTextArea/index.cjs.map +1 -0
- package/dist/components/forms/fields/FormTextArea/index.d.ts +16 -0
- package/dist/components/forms/fields/FormTextArea/index.d.ts.map +1 -0
- package/dist/components/forms/fields/FormTextArea/index.js +25 -0
- package/dist/components/forms/fields/FormTextArea/index.js.map +1 -0
- package/dist/components/forms/fields/FormToggle/index.cjs +32 -0
- package/dist/components/forms/fields/FormToggle/index.cjs.map +1 -0
- package/dist/components/forms/fields/FormToggle/index.d.ts +16 -0
- package/dist/components/forms/fields/FormToggle/index.d.ts.map +1 -0
- package/dist/components/forms/fields/FormToggle/index.js +30 -0
- package/dist/components/forms/fields/FormToggle/index.js.map +1 -0
- package/dist/components/forms/validation/hooks/useSchemaResolver.cjs +39 -0
- package/dist/components/forms/validation/hooks/useSchemaResolver.cjs.map +1 -0
- package/dist/components/forms/validation/hooks/useSchemaResolver.d.ts +15 -0
- package/dist/components/forms/validation/hooks/useSchemaResolver.d.ts.map +1 -0
- package/dist/components/forms/validation/hooks/useSchemaResolver.js +37 -0
- package/dist/components/forms/validation/hooks/useSchemaResolver.js.map +1 -0
- package/dist/components/forms/validation/index.cjs +309 -0
- package/dist/components/forms/validation/index.cjs.map +1 -0
- package/dist/components/forms/validation/index.d.ts +214 -0
- package/dist/components/forms/validation/index.d.ts.map +1 -0
- package/dist/components/forms/validation/index.js +293 -0
- package/dist/components/forms/validation/index.js.map +1 -0
- package/dist/components/forms/validation/utilities/validation.utils.cjs +42 -0
- package/dist/components/forms/validation/utilities/validation.utils.cjs.map +1 -0
- package/dist/components/forms/validation/utilities/validation.utils.d.ts +20 -0
- package/dist/components/forms/validation/utilities/validation.utils.d.ts.map +1 -0
- package/dist/components/forms/validation/utilities/validation.utils.js +39 -0
- package/dist/components/forms/validation/utilities/validation.utils.js.map +1 -0
- package/dist/components/forms/validation/validation.types.d.ts +8 -0
- package/dist/components/forms/validation/validation.types.d.ts.map +1 -0
- package/dist/components/molecules/Alert/index.cjs +5 -25
- package/dist/components/molecules/Alert/index.cjs.map +1 -1
- package/dist/components/molecules/Alert/index.d.ts +9 -94
- package/dist/components/molecules/Alert/index.d.ts.map +1 -1
- package/dist/components/molecules/Alert/index.js +5 -25
- package/dist/components/molecules/Alert/index.js.map +1 -1
- package/dist/components/molecules/Alerts/components/Alert.cjs +39 -0
- package/dist/components/molecules/Alerts/components/Alert.cjs.map +1 -0
- package/dist/components/molecules/Alerts/components/Alert.d.ts +104 -0
- package/dist/components/molecules/Alerts/components/Alert.d.ts.map +1 -0
- package/dist/components/molecules/Alerts/components/Alert.js +36 -0
- package/dist/components/molecules/Alerts/components/Alert.js.map +1 -0
- package/dist/components/molecules/Alerts/components/SaveErrorAlert.cjs +26 -0
- package/dist/components/molecules/Alerts/components/SaveErrorAlert.cjs.map +1 -0
- package/dist/components/molecules/Alerts/components/SaveErrorAlert.d.ts +25 -0
- package/dist/components/molecules/Alerts/components/SaveErrorAlert.d.ts.map +1 -0
- package/dist/components/molecules/Alerts/components/SaveErrorAlert.js +24 -0
- package/dist/components/molecules/Alerts/components/SaveErrorAlert.js.map +1 -0
- package/dist/components/molecules/Alerts/hooks/useAlertActions.cjs +26 -0
- package/dist/components/molecules/Alerts/hooks/useAlertActions.cjs.map +1 -0
- package/dist/components/molecules/Alerts/hooks/useAlertActions.d.ts +13 -0
- package/dist/components/molecules/Alerts/hooks/useAlertActions.d.ts.map +1 -0
- package/dist/components/molecules/Alerts/hooks/useAlertActions.js +24 -0
- package/dist/components/molecules/Alerts/hooks/useAlertActions.js.map +1 -0
- package/dist/components/molecules/Alerts/index.cjs +11 -0
- package/dist/components/molecules/Alerts/index.cjs.map +1 -0
- package/dist/components/molecules/Alerts/index.d.ts +12 -0
- package/dist/components/molecules/Alerts/index.d.ts.map +1 -0
- package/dist/components/molecules/Alerts/index.js +3 -0
- package/dist/components/molecules/Alerts/index.js.map +1 -0
- package/dist/components/molecules/Modal/index.cjs +9 -39
- package/dist/components/molecules/Modal/index.cjs.map +1 -1
- package/dist/components/molecules/Modal/index.d.ts +13 -36
- package/dist/components/molecules/Modal/index.d.ts.map +1 -1
- package/dist/components/molecules/Modal/index.js +8 -38
- package/dist/components/molecules/Modal/index.js.map +1 -1
- package/dist/components/molecules/Modals/components/ConfirmationModal.cjs +32 -0
- package/dist/components/molecules/Modals/components/ConfirmationModal.cjs.map +1 -0
- package/dist/components/molecules/Modals/components/ConfirmationModal.d.ts +28 -0
- package/dist/components/molecules/Modals/components/ConfirmationModal.d.ts.map +1 -0
- package/dist/components/molecules/Modals/components/ConfirmationModal.js +30 -0
- package/dist/components/molecules/Modals/components/ConfirmationModal.js.map +1 -0
- package/dist/components/molecules/Modals/components/Modal.cjs +48 -0
- package/dist/components/molecules/Modals/components/Modal.cjs.map +1 -0
- package/dist/components/molecules/Modals/components/Modal.d.ts +37 -0
- package/dist/components/molecules/Modals/components/Modal.d.ts.map +1 -0
- package/dist/components/molecules/Modals/components/Modal.js +43 -0
- package/dist/components/molecules/Modals/components/Modal.js.map +1 -0
- package/dist/components/molecules/Modals/components/UnsavedChangesModal.cjs +30 -0
- package/dist/components/molecules/Modals/components/UnsavedChangesModal.cjs.map +1 -0
- package/dist/components/molecules/Modals/components/UnsavedChangesModal.d.ts +14 -0
- package/dist/components/molecules/Modals/components/UnsavedChangesModal.d.ts.map +1 -0
- package/dist/components/molecules/Modals/components/UnsavedChangesModal.js +28 -0
- package/dist/components/molecules/Modals/components/UnsavedChangesModal.js.map +1 -0
- package/dist/components/molecules/Modals/index.cjs +15 -0
- package/dist/components/molecules/Modals/index.cjs.map +1 -0
- package/dist/components/molecules/Modals/index.d.ts +14 -0
- package/dist/components/molecules/Modals/index.d.ts.map +1 -0
- package/dist/components/molecules/Modals/index.js +4 -0
- package/dist/components/molecules/Modals/index.js.map +1 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.cjs +13 -3
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.cjs.map +1 -1
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.d.ts +1 -1
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.d.ts.map +1 -1
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.js +13 -3
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.js.map +1 -1
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.cjs +2 -2
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.cjs.map +1 -1
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.d.ts +1 -0
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.d.ts.map +1 -1
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.js +2 -2
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.js.map +1 -1
- package/dist/components/organisms/ColorPicker/hooks/useCssColorField.cjs +1 -1
- package/dist/components/organisms/ColorPicker/hooks/useCssColorField.js +1 -1
- package/dist/components/organisms/ColorPicker/index.cjs +1 -1
- package/dist/components/organisms/ColorPicker/index.d.ts.map +1 -1
- package/dist/components/organisms/ColorPicker/index.js +1 -1
- package/dist/components/organisms/ColorPicker/providers/ColorPicker.provider.d.ts +1 -1
- package/dist/components/organisms/ColorPicker/providers/ColorPicker.provider.d.ts.map +1 -1
- package/dist/components/organisms/ColorPicker/utilities/colorPicker.utils.cjs.map +1 -0
- package/dist/components/organisms/ColorPicker/utilities/colorPicker.utils.d.ts.map +1 -0
- package/dist/components/organisms/ColorPicker/utilities/colorPicker.utils.js.map +1 -0
- package/dist/components/organisms/DatePicker/components/CalendarOverlay.cjs +2 -2
- package/dist/components/organisms/DatePicker/components/CalendarOverlay.cjs.map +1 -1
- package/dist/components/organisms/DatePicker/components/CalendarOverlay.js +1 -1
- package/dist/components/organisms/DatePicker/components/DateRangePicker.cjs +4 -1
- package/dist/components/organisms/DatePicker/components/DateRangePicker.cjs.map +1 -1
- package/dist/components/organisms/DatePicker/components/DateRangePicker.d.ts.map +1 -1
- package/dist/components/organisms/DatePicker/components/DateRangePicker.js +5 -2
- package/dist/components/organisms/DatePicker/components/DateRangePicker.js.map +1 -1
- package/dist/components/organisms/GradientPicker/components/GradientStopRow.cjs +1 -1
- package/dist/components/organisms/GradientPicker/components/GradientStopRow.js +1 -1
- package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.cjs +48 -0
- package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.cjs.map +1 -0
- package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.d.ts +23 -0
- package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.d.ts.map +1 -0
- package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.js +45 -0
- package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.js.map +1 -0
- package/dist/hooks/useUnsavedChangesGuard/index.cjs +28 -0
- package/dist/hooks/useUnsavedChangesGuard/index.cjs.map +1 -0
- package/dist/hooks/useUnsavedChangesGuard/index.d.ts +18 -0
- package/dist/hooks/useUnsavedChangesGuard/index.d.ts.map +1 -0
- package/dist/hooks/useUnsavedChangesGuard/index.js +26 -0
- package/dist/hooks/useUnsavedChangesGuard/index.js.map +1 -0
- package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.cjs +8 -0
- package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.cjs.map +1 -0
- package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.d.ts +13 -0
- package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.d.ts.map +1 -0
- package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.js +6 -0
- package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.js.map +1 -0
- package/dist/localization/en.json.cjs +98 -0
- package/dist/localization/en.json.cjs.map +1 -0
- package/dist/localization/en.json.js +81 -0
- package/dist/localization/en.json.js.map +1 -0
- package/dist/native/components/forms/Form/index.d.ts +12 -0
- package/dist/native/components/forms/FormFooter/index.d.ts +12 -0
- package/dist/native/components/forms/FormSection/index.d.ts +12 -0
- package/dist/native/components/forms/fields/FormCheckbox/index.d.ts +12 -0
- package/dist/native/components/forms/fields/FormCheckboxGroup/index.d.ts +12 -0
- package/dist/native/components/forms/fields/FormColorPicker/index.d.ts +12 -0
- package/dist/native/components/forms/fields/FormDatePicker/index.d.ts +12 -0
- package/dist/native/components/forms/fields/FormInput/index.d.ts +12 -0
- package/dist/native/components/forms/fields/FormMultiSelect/index.d.ts +12 -0
- package/dist/native/components/forms/fields/FormRadioCardGroup/index.d.ts +12 -0
- package/dist/native/components/forms/fields/FormRadioGroup/index.d.ts +12 -0
- package/dist/native/components/forms/fields/FormSelect/index.d.ts +12 -0
- package/dist/native/components/forms/fields/FormSlider/index.d.ts +12 -0
- package/dist/native/components/forms/fields/FormTextArea/index.d.ts +12 -0
- package/dist/native/components/forms/fields/FormToggle/index.d.ts +12 -0
- package/dist/native/components/forms/validation/index.d.ts +12 -0
- package/dist/native/components/molecules/Alerts/index.d.ts +12 -0
- package/dist/native/components/molecules/Modals/index.d.ts +12 -0
- package/dist/native/hooks/useUnsavedChangesGuard/index.d.ts +12 -0
- package/dist/native/providers/UnsavedChangesGuardProvider/index.d.ts +12 -0
- package/dist/providers/UIProvider/hooks/useBrowserRouter.cjs +70 -0
- package/dist/providers/UIProvider/hooks/useBrowserRouter.cjs.map +1 -0
- package/dist/providers/UIProvider/hooks/useBrowserRouter.d.ts +12 -0
- package/dist/providers/UIProvider/hooks/useBrowserRouter.d.ts.map +1 -0
- package/dist/providers/UIProvider/hooks/useBrowserRouter.js +68 -0
- package/dist/providers/UIProvider/hooks/useBrowserRouter.js.map +1 -0
- package/dist/providers/UIProvider/index.cjs +19 -6
- package/dist/providers/UIProvider/index.cjs.map +1 -1
- package/dist/providers/UIProvider/index.d.ts +2 -2
- package/dist/providers/UIProvider/index.d.ts.map +1 -1
- package/dist/providers/UIProvider/index.js +20 -7
- package/dist/providers/UIProvider/index.js.map +1 -1
- package/dist/providers/UnsavedChangesGuardProvider/index.cjs +191 -0
- package/dist/providers/UnsavedChangesGuardProvider/index.cjs.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/index.d.ts +10 -0
- package/dist/providers/UnsavedChangesGuardProvider/index.d.ts.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/index.js +189 -0
- package/dist/providers/UnsavedChangesGuardProvider/index.js.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.cjs +7 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.cjs.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.d.ts +3 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.d.ts.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.js +5 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.js.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.types.d.ts +21 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.types.d.ts.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.cjs +97 -0
- package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.cjs.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.d.ts +62 -0
- package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.d.ts.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.js +88 -0
- package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.js.map +1 -0
- package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.cjs +74 -0
- package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.cjs.map +1 -0
- package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.d.ts +51 -0
- package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.d.ts.map +1 -0
- package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.js +68 -0
- package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.js.map +1 -0
- package/package.json +41 -6
- package/dist/components/organisms/ColorPicker/colorPicker.utils.cjs.map +0 -1
- package/dist/components/organisms/ColorPicker/colorPicker.utils.d.ts.map +0 -1
- package/dist/components/organisms/ColorPicker/colorPicker.utils.js.map +0 -1
- /package/dist/components/organisms/ColorPicker/{colorPicker.utils.cjs → utilities/colorPicker.utils.cjs} +0 -0
- /package/dist/components/organisms/ColorPicker/{colorPicker.utils.d.ts → utilities/colorPicker.utils.d.ts} +0 -0
- /package/dist/components/organisms/ColorPicker/{colorPicker.utils.js → utilities/colorPicker.utils.js} +0 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var reactRouter = require('react-router');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Gives every history entry the app lands on the index react-router expects there. A host such as Portal pushes entries
|
|
8
|
+
* without one, and react-router then cannot tell how far a back or forward move went, so it could not hold one.
|
|
9
|
+
*
|
|
10
|
+
* @returns The function that stops it.
|
|
11
|
+
*/
|
|
12
|
+
const keepHistoryIndex = () => {
|
|
13
|
+
const { navigation } = window;
|
|
14
|
+
if (!navigation)
|
|
15
|
+
return () => { };
|
|
16
|
+
// The last entry seen with an index, and where the browser says it sits: the next one is numbered from it.
|
|
17
|
+
let known;
|
|
18
|
+
const number = () => {
|
|
19
|
+
const position = navigation.currentEntry?.index ?? -1;
|
|
20
|
+
const state = window.history.state;
|
|
21
|
+
// Only a plain object can take one more field and stay what it was; anything else is the host's own to keep.
|
|
22
|
+
const isPlainObject = typeof state === 'object' && state !== null && Object.getPrototypeOf(state) === Object.prototype;
|
|
23
|
+
if (position < 0 || !(state === null || isPlainObject))
|
|
24
|
+
return;
|
|
25
|
+
const idx = state?.idx;
|
|
26
|
+
// An index already there is never changed: another router on the page may count from it, and a `NaN`, which
|
|
27
|
+
// react-router writes after an entry it could not count from, marks a move it cannot rewind.
|
|
28
|
+
if (idx !== undefined && idx !== null) {
|
|
29
|
+
if (typeof idx === 'number' && Number.isFinite(idx))
|
|
30
|
+
known = { idx, position };
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const next = known ? known.idx + position - known.position : position;
|
|
34
|
+
known = { idx: next, position };
|
|
35
|
+
window.history.replaceState({ ...state, idx: next }, '');
|
|
36
|
+
};
|
|
37
|
+
// Fires for every push, replace and back or forward move, before any `popstate` listener reads the entry.
|
|
38
|
+
navigation.addEventListener('currententrychange', number);
|
|
39
|
+
number();
|
|
40
|
+
return () => navigation.removeEventListener('currententrychange', number);
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Owns a react-router data router for the lifetime of the component: created on mount and whenever `basename` changes,
|
|
44
|
+
* disposed on unmount so a StrictMode or host re-mount never leaves a `popstate` listener behind. A new `basename` is a
|
|
45
|
+
* new router, so the tree beneath it mounts again.
|
|
46
|
+
*
|
|
47
|
+
* @param routes The route table; pass a module-level constant, since the router reads it once when it is created.
|
|
48
|
+
* @param basename The path the app is mounted under, such as a micro-frontend's Portal base URL.
|
|
49
|
+
* @returns The router, or `null` until the layout effect has built the one for this `basename`, which is still before the paint.
|
|
50
|
+
*/
|
|
51
|
+
const useBrowserRouter = (routes, basename) => {
|
|
52
|
+
const [current, setCurrent] = React.useState(null);
|
|
53
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: the route table is read once per router, so a new array must not rebuild it
|
|
54
|
+
React.useLayoutEffect(() => {
|
|
55
|
+
// Started first, so the router reads an index on the entry it mounts on.
|
|
56
|
+
const stopKeepingIndex = keepHistoryIndex();
|
|
57
|
+
const created = reactRouter.createBrowserRouter(routes, { basename });
|
|
58
|
+
setCurrent({ router: created, basename });
|
|
59
|
+
return () => {
|
|
60
|
+
created.dispose();
|
|
61
|
+
stopKeepingIndex();
|
|
62
|
+
};
|
|
63
|
+
}, [basename]);
|
|
64
|
+
// `RouterProvider` keeps the state of the first router it is given, so a router built for another basename is never
|
|
65
|
+
// handed over: the provider unmounts for that render and mounts again with the new router's own state.
|
|
66
|
+
return current && current.basename === basename ? current.router : null;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
exports.useBrowserRouter = useBrowserRouter;
|
|
70
|
+
//# sourceMappingURL=useBrowserRouter.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBrowserRouter.cjs","sources":["../../../../src/providers/UIProvider/hooks/useBrowserRouter.ts"],"sourcesContent":[null],"names":["useState","useLayoutEffect","createBrowserRouter"],"mappings":";;;;;AAYA;;;;;AAKG;AACH,MAAM,gBAAgB,GAAG,MAAmB;AAC1C,IAAA,MAAM,EAAE,UAAU,EAAE,GAAG,MAAiD;AACxE,IAAA,IAAI,CAAC,UAAU;AAAE,QAAA,OAAO,MAAK,EAAE,CAAC;;AAEhC,IAAA,IAAI,KAAoD;IAExD,MAAM,MAAM,GAAG,MAAK;QAClB,MAAM,QAAQ,GAAG,UAAU,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;AACrD,QAAA,MAAM,KAAK,GAAY,MAAM,CAAC,OAAO,CAAC,KAAK;;QAE3C,MAAM,aAAa,GAAG,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,SAAS;QACtH,IAAI,QAAQ,GAAG,CAAC,IAAI,EAAE,KAAK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AACpB,QAAA,CAAC;AACH,IAAA,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;;;AAId,IAAA,OAAO,OAAO,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI;AACzE;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type DataRouter, type RouteObject } from 'react-router';
|
|
2
|
+
/**
|
|
3
|
+
* Owns a react-router data router for the lifetime of the component: created on mount and whenever `basename` changes,
|
|
4
|
+
* disposed on unmount so a StrictMode or host re-mount never leaves a `popstate` listener behind. A new `basename` is a
|
|
5
|
+
* new router, so the tree beneath it mounts again.
|
|
6
|
+
*
|
|
7
|
+
* @param routes The route table; pass a module-level constant, since the router reads it once when it is created.
|
|
8
|
+
* @param basename The path the app is mounted under, such as a micro-frontend's Portal base URL.
|
|
9
|
+
* @returns The router, or `null` until the layout effect has built the one for this `basename`, which is still before the paint.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useBrowserRouter: (routes: RouteObject[], basename?: string) => DataRouter | null;
|
|
12
|
+
//# sourceMappingURL=useBrowserRouter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBrowserRouter.d.ts","sourceRoot":"","sources":["../../../../src/providers/UIProvider/hooks/useBrowserRouter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuB,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AA6CtF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,WAAW,EAAE,EAAE,WAAW,MAAM,KAAG,UAAU,GAAG,IAkBxF,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useState, useLayoutEffect } from 'react';
|
|
2
|
+
import { createBrowserRouter } from 'react-router';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Gives every history entry the app lands on the index react-router expects there. A host such as Portal pushes entries
|
|
6
|
+
* without one, and react-router then cannot tell how far a back or forward move went, so it could not hold one.
|
|
7
|
+
*
|
|
8
|
+
* @returns The function that stops it.
|
|
9
|
+
*/
|
|
10
|
+
const keepHistoryIndex = () => {
|
|
11
|
+
const { navigation } = window;
|
|
12
|
+
if (!navigation)
|
|
13
|
+
return () => { };
|
|
14
|
+
// The last entry seen with an index, and where the browser says it sits: the next one is numbered from it.
|
|
15
|
+
let known;
|
|
16
|
+
const number = () => {
|
|
17
|
+
const position = navigation.currentEntry?.index ?? -1;
|
|
18
|
+
const state = window.history.state;
|
|
19
|
+
// Only a plain object can take one more field and stay what it was; anything else is the host's own to keep.
|
|
20
|
+
const isPlainObject = typeof state === 'object' && state !== null && Object.getPrototypeOf(state) === Object.prototype;
|
|
21
|
+
if (position < 0 || !(state === null || isPlainObject))
|
|
22
|
+
return;
|
|
23
|
+
const idx = state?.idx;
|
|
24
|
+
// An index already there is never changed: another router on the page may count from it, and a `NaN`, which
|
|
25
|
+
// react-router writes after an entry it could not count from, marks a move it cannot rewind.
|
|
26
|
+
if (idx !== undefined && idx !== null) {
|
|
27
|
+
if (typeof idx === 'number' && Number.isFinite(idx))
|
|
28
|
+
known = { idx, position };
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const next = known ? known.idx + position - known.position : position;
|
|
32
|
+
known = { idx: next, position };
|
|
33
|
+
window.history.replaceState({ ...state, idx: next }, '');
|
|
34
|
+
};
|
|
35
|
+
// Fires for every push, replace and back or forward move, before any `popstate` listener reads the entry.
|
|
36
|
+
navigation.addEventListener('currententrychange', number);
|
|
37
|
+
number();
|
|
38
|
+
return () => navigation.removeEventListener('currententrychange', number);
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Owns a react-router data router for the lifetime of the component: created on mount and whenever `basename` changes,
|
|
42
|
+
* disposed on unmount so a StrictMode or host re-mount never leaves a `popstate` listener behind. A new `basename` is a
|
|
43
|
+
* new router, so the tree beneath it mounts again.
|
|
44
|
+
*
|
|
45
|
+
* @param routes The route table; pass a module-level constant, since the router reads it once when it is created.
|
|
46
|
+
* @param basename The path the app is mounted under, such as a micro-frontend's Portal base URL.
|
|
47
|
+
* @returns The router, or `null` until the layout effect has built the one for this `basename`, which is still before the paint.
|
|
48
|
+
*/
|
|
49
|
+
const useBrowserRouter = (routes, basename) => {
|
|
50
|
+
const [current, setCurrent] = useState(null);
|
|
51
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: the route table is read once per router, so a new array must not rebuild it
|
|
52
|
+
useLayoutEffect(() => {
|
|
53
|
+
// Started first, so the router reads an index on the entry it mounts on.
|
|
54
|
+
const stopKeepingIndex = keepHistoryIndex();
|
|
55
|
+
const created = createBrowserRouter(routes, { basename });
|
|
56
|
+
setCurrent({ router: created, basename });
|
|
57
|
+
return () => {
|
|
58
|
+
created.dispose();
|
|
59
|
+
stopKeepingIndex();
|
|
60
|
+
};
|
|
61
|
+
}, [basename]);
|
|
62
|
+
// `RouterProvider` keeps the state of the first router it is given, so a router built for another basename is never
|
|
63
|
+
// handed over: the provider unmounts for that render and mounts again with the new router's own state.
|
|
64
|
+
return current && current.basename === basename ? current.router : null;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export { useBrowserRouter };
|
|
68
|
+
//# sourceMappingURL=useBrowserRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBrowserRouter.js","sources":["../../../../src/providers/UIProvider/hooks/useBrowserRouter.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAYA;;;;;AAKG;AACH,MAAM,gBAAgB,GAAG,MAAmB;AAC1C,IAAA,MAAM,EAAE,UAAU,EAAE,GAAG,MAAiD;AACxE,IAAA,IAAI,CAAC,UAAU;AAAE,QAAA,OAAO,MAAK,EAAE,CAAC;;AAEhC,IAAA,IAAI,KAAoD;IAExD,MAAM,MAAM,GAAG,MAAK;QAClB,MAAM,QAAQ,GAAG,UAAU,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;AACrD,QAAA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AgB,EAAE;QAC3C,MAAM,OAAO,GAAG,mBAAmB,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC;QACzD,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AACzC,QAAA,OAAO,MAAK;YACV,OAAO,CAAC,OAAO,EAAE;AACjB,YAAA,gBAAgB,EAAE;AACpB,QAAA,CAAC;AACH,IAAA,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;;;AAId,IAAA,OAAO,OAAO,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI;AACzE;;"}
|
|
@@ -5,26 +5,39 @@ var ErrorBoundary = require('@flipdish/ui-library/providers/ErrorBoundary');
|
|
|
5
5
|
var PortalContainer = require('@flipdish/ui-library/providers/PortalContainer');
|
|
6
6
|
var RouteProvider = require('@flipdish/ui-library/providers/RouteProvider');
|
|
7
7
|
var ThemeProvider = require('@flipdish/ui-library/providers/ThemeProvider');
|
|
8
|
+
var UnsavedChangesGuardProvider = require('@flipdish/ui-library/providers/UnsavedChangesGuardProvider');
|
|
9
|
+
var React = require('react');
|
|
8
10
|
var reactRouter = require('react-router');
|
|
11
|
+
var useBrowserRouter = require('./hooks/useBrowserRouter.cjs');
|
|
9
12
|
var usePortalAnchor = require('./hooks/usePortalAnchor.cjs');
|
|
10
13
|
|
|
14
|
+
// A data router takes a static route table, so the app's tree reaches the catch-all route through context.
|
|
15
|
+
const RoutedTreeContext = React.createContext(null);
|
|
16
|
+
// What `BrowserRouter` gives its children: no matched route, so a relative link outside the app's `<Routes>` resolves from
|
|
17
|
+
// the base path and not from the current URL, as it would beneath the catch-all route.
|
|
18
|
+
const NO_MATCHED_ROUTE = { outlet: null, matches: [], isDataRoute: false };
|
|
19
|
+
const RoutedTree = () => (jsxRuntime.jsx(reactRouter.UNSAFE_RouteContext, { value: NO_MATCHED_ROUTE, children: jsxRuntime.jsx(RouteProvider.RouteProvider, { children: jsxRuntime.jsx(UnsavedChangesGuardProvider.UnsavedChangesGuardProvider, { children: React.useContext(RoutedTreeContext) }) }) }));
|
|
20
|
+
// One catch-all route: the app's own `<Routes>` match beneath it as before, and `useBlocker` works for the whole tree.
|
|
21
|
+
const ROUTES = [{ path: '*', Component: RoutedTree }];
|
|
11
22
|
const UIProviderInner = ({ children, baseUrl, errorBoundary, scopeId, portalContainer, }) => {
|
|
12
23
|
const { themeRoot, resolvedMode } = ThemeProvider.useTheme();
|
|
13
24
|
const getContainer = usePortalAnchor.usePortalAnchor({ portalContainer, scopeId, themeRoot, resolvedMode });
|
|
14
|
-
|
|
25
|
+
const router = useBrowserRouter.useBrowserRouter(ROUTES, baseUrl);
|
|
26
|
+
const tree = (jsxRuntime.jsx(ErrorBoundary.ErrorBoundary, { ...errorBoundary, children: jsxRuntime.jsx(PortalContainer.PortalContainer, { getContainer: getContainer, children: children }) }));
|
|
27
|
+
if (!router)
|
|
28
|
+
return null;
|
|
29
|
+
return (jsxRuntime.jsx(RoutedTreeContext, { value: tree, children: jsxRuntime.jsx(reactRouter.RouterProvider, { router: router }) }));
|
|
15
30
|
};
|
|
16
31
|
/**
|
|
17
|
-
* Single entry-point provider that composes `ThemeProvider`, `RouteProvider`, `ErrorBoundary
|
|
32
|
+
* Single entry-point provider that composes `ThemeProvider`, `RouteProvider`, `ErrorBoundary`,
|
|
18
33
|
* and overlay portalling for a consuming app. Wire it once at the root and pass `scopeId` when the
|
|
19
34
|
* app ships CSS scoped to `[data-mfe-scope]`; overlays then portal into a scoped anchor on `body`.
|
|
20
35
|
*
|
|
21
36
|
* @summary root provider composing theme, routing, errors and portals
|
|
22
37
|
*/
|
|
23
38
|
const UIProvider = ({ children, themeModeOverride, scopeId, ...rest }) => {
|
|
24
|
-
// TODO(i18n): add an internal
|
|
25
|
-
//
|
|
26
|
-
// consuming app needing to pass text props. This is purely internal — consuming apps
|
|
27
|
-
// own their own translation layer and wrap their content inside UIProvider as usual.
|
|
39
|
+
// TODO(i18n): add an internal translation context so components source their own built-in text ("Discard", "Rows per
|
|
40
|
+
// page") in the host's language. Apps keep their own translation layer; form messages reach it through `useSchemaResolver`.
|
|
28
41
|
return (jsxRuntime.jsx(ThemeProvider.ThemeProvider, { themeModeOverride: themeModeOverride, scopeId: scopeId, children: jsxRuntime.jsx(UIProviderInner, { scopeId: scopeId, ...rest, children: children }) }));
|
|
29
42
|
};
|
|
30
43
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/providers/UIProvider/index.tsx"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/providers/UIProvider/index.tsx"],"sourcesContent":[null],"names":["createContext","_jsx","UNSAFE_RouteContext","RouteProvider","UnsavedChangesGuardProvider","useContext","useTheme","usePortalAnchor","useBrowserRouter","ErrorBoundary","PortalContainer","DataRouterProvider","ThemeProvider"],"mappings":";;;;;;;;;;;;;AAmDA;AACA,MAAM,iBAAiB,GAAGA,mBAAa,CAAY,IAAI,CAAC;AACxD;AACA;AACA,MAAM,gBAAgB,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE;AAC1E,MAAM,UAAU,GAAG,OACjBC,cAAA,CAACC,+BAAmB,EAAA,EAAC,KAAK,EAAE,gBAAgB,EAAA,QAAA,EAC1CD,cAAA,CAACE,2BAAa,EAAA,EAAA,QAAA,EACZF,cAAA,CAACG,uDAA2B,EAAA,EAAA,QAAA,EAAEC,gBAAU,CAAC,iBAAiB,CAAC,EAAA,CAA+B,EAAA,CAC5E,EAAA,CACI,CACvB;AACD;AACA,MAAM,MAAM,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AAErD,MAAM,eAAe,GAAG,CAAC,EACvB,QAAQ,EACR,OAAO,EACP,aAAa,EACb,OAAO,EACP,eAAe,GAC+C,KAAI;IAClE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,GAAGC,sBAAQ,EAAE;AAC9C,IAAA,MAAM,YAAY,GAAGC,+BAAe,CAAC,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;IAE3F,MAAM,MAAM,GAAGC,iCAAgB,CAAC,MAAM,EAAE,OAAO,CAAC;AAEhD,IAAA,MAAM,IAAI,IACRP,eAACQ,2BAAa,EAAA,EAAA,GAAK,aAAa,EAAA,QAAA,EAC9BR,cAAA,CAACS,+BAAe,EAAA,EAAC,YAAY,EAAE,YAAY,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAmB,EAAA,CAC3D,CACjB;AAED,IAAA,IAAI,CAAC,MAAM;AAAE,QAAA,OAAO,IAAI;AACxB,IAAA,QACET,cAAA,CAAC,iBAAiB,EAAA,EAAC,KAAK,EAAE,IAAI,EAAA,QAAA,EAC5BA,cAAA,CAACU,0BAAkB,IAAC,MAAM,EAAE,MAAM,EAAA,CAAI,EAAA,CACpB;AAExB,CAAC;AAED;;;;;;AAMG;AACI,MAAM,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,IAAI,EAAsC,KAAI;;;IAGlH,QACEV,cAAA,CAACW,2BAAa,EAAA,EAAC,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,EAAA,QAAA,EACnEX,eAAC,eAAe,EAAA,EAAC,OAAO,EAAE,OAAO,EAAA,GAAM,IAAI,EAAA,QAAA,EACxC,QAAQ,EAAA,CACO,EAAA,CACJ;AAEpB;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ErrorBoundaryProps } from '@flipdish/ui-library/providers/ErrorBoundary';
|
|
2
|
-
import type
|
|
2
|
+
import { type PropsWithChildren } from 'react';
|
|
3
3
|
export interface UIProviderProps {
|
|
4
4
|
/**
|
|
5
5
|
* Controlled theme override. When set, the tree renders in this mode and theme
|
|
@@ -39,7 +39,7 @@ export interface UIProviderProps {
|
|
|
39
39
|
portalContainer?: (() => HTMLElement | null) | null;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* Single entry-point provider that composes `ThemeProvider`, `RouteProvider`, `ErrorBoundary
|
|
42
|
+
* Single entry-point provider that composes `ThemeProvider`, `RouteProvider`, `ErrorBoundary`,
|
|
43
43
|
* and overlay portalling for a consuming app. Wire it once at the root and pass `scopeId` when the
|
|
44
44
|
* app ships CSS scoped to `[data-mfe-scope]`; overlays then portal into a scoped anchor on `body`.
|
|
45
45
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/UIProvider/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/UIProvider/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAKtG,OAAO,EAAiB,KAAK,iBAAiB,EAA8B,MAAM,OAAO,CAAC;AAK1F,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACrC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,aAAa,EAAE,IAAI,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;IACpD;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;CACrD;AA2CD;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,mDAAmD,iBAAiB,CAAC,eAAe,CAAC,gCAU/G,CAAC"}
|
|
@@ -3,26 +3,39 @@ import { ErrorBoundary } from '@flipdish/ui-library/providers/ErrorBoundary';
|
|
|
3
3
|
import { PortalContainer } from '@flipdish/ui-library/providers/PortalContainer';
|
|
4
4
|
import { RouteProvider } from '@flipdish/ui-library/providers/RouteProvider';
|
|
5
5
|
import { ThemeProvider, useTheme } from '@flipdish/ui-library/providers/ThemeProvider';
|
|
6
|
-
import {
|
|
6
|
+
import { UnsavedChangesGuardProvider } from '@flipdish/ui-library/providers/UnsavedChangesGuardProvider';
|
|
7
|
+
import { createContext, useContext } from 'react';
|
|
8
|
+
import { RouterProvider, UNSAFE_RouteContext } from 'react-router';
|
|
9
|
+
import { useBrowserRouter } from './hooks/useBrowserRouter.js';
|
|
7
10
|
import { usePortalAnchor } from './hooks/usePortalAnchor.js';
|
|
8
11
|
|
|
12
|
+
// A data router takes a static route table, so the app's tree reaches the catch-all route through context.
|
|
13
|
+
const RoutedTreeContext = createContext(null);
|
|
14
|
+
// What `BrowserRouter` gives its children: no matched route, so a relative link outside the app's `<Routes>` resolves from
|
|
15
|
+
// the base path and not from the current URL, as it would beneath the catch-all route.
|
|
16
|
+
const NO_MATCHED_ROUTE = { outlet: null, matches: [], isDataRoute: false };
|
|
17
|
+
const RoutedTree = () => (jsx(UNSAFE_RouteContext, { value: NO_MATCHED_ROUTE, children: jsx(RouteProvider, { children: jsx(UnsavedChangesGuardProvider, { children: useContext(RoutedTreeContext) }) }) }));
|
|
18
|
+
// One catch-all route: the app's own `<Routes>` match beneath it as before, and `useBlocker` works for the whole tree.
|
|
19
|
+
const ROUTES = [{ path: '*', Component: RoutedTree }];
|
|
9
20
|
const UIProviderInner = ({ children, baseUrl, errorBoundary, scopeId, portalContainer, }) => {
|
|
10
21
|
const { themeRoot, resolvedMode } = useTheme();
|
|
11
22
|
const getContainer = usePortalAnchor({ portalContainer, scopeId, themeRoot, resolvedMode });
|
|
12
|
-
|
|
23
|
+
const router = useBrowserRouter(ROUTES, baseUrl);
|
|
24
|
+
const tree = (jsx(ErrorBoundary, { ...errorBoundary, children: jsx(PortalContainer, { getContainer: getContainer, children: children }) }));
|
|
25
|
+
if (!router)
|
|
26
|
+
return null;
|
|
27
|
+
return (jsx(RoutedTreeContext, { value: tree, children: jsx(RouterProvider, { router: router }) }));
|
|
13
28
|
};
|
|
14
29
|
/**
|
|
15
|
-
* Single entry-point provider that composes `ThemeProvider`, `RouteProvider`, `ErrorBoundary
|
|
30
|
+
* Single entry-point provider that composes `ThemeProvider`, `RouteProvider`, `ErrorBoundary`,
|
|
16
31
|
* and overlay portalling for a consuming app. Wire it once at the root and pass `scopeId` when the
|
|
17
32
|
* app ships CSS scoped to `[data-mfe-scope]`; overlays then portal into a scoped anchor on `body`.
|
|
18
33
|
*
|
|
19
34
|
* @summary root provider composing theme, routing, errors and portals
|
|
20
35
|
*/
|
|
21
36
|
const UIProvider = ({ children, themeModeOverride, scopeId, ...rest }) => {
|
|
22
|
-
// TODO(i18n): add an internal
|
|
23
|
-
//
|
|
24
|
-
// consuming app needing to pass text props. This is purely internal — consuming apps
|
|
25
|
-
// own their own translation layer and wrap their content inside UIProvider as usual.
|
|
37
|
+
// TODO(i18n): add an internal translation context so components source their own built-in text ("Discard", "Rows per
|
|
38
|
+
// page") in the host's language. Apps keep their own translation layer; form messages reach it through `useSchemaResolver`.
|
|
26
39
|
return (jsx(ThemeProvider, { themeModeOverride: themeModeOverride, scopeId: scopeId, children: jsx(UIProviderInner, { scopeId: scopeId, ...rest, children: children }) }));
|
|
27
40
|
};
|
|
28
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/providers/UIProvider/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/providers/UIProvider/index.tsx"],"sourcesContent":[null],"names":["_jsx","DataRouterProvider"],"mappings":";;;;;;;;;;;AAmDA;AACA,MAAM,iBAAiB,GAAG,aAAa,CAAY,IAAI,CAAC;AACxD;AACA;AACA,MAAM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,CAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,IAAI,EAAsC,KAAI;;;IAGlH,QACED,GAAA,CAAC,aAAa,EAAA,EAAC,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,EAAA,QAAA,EACnEA,IAAC,eAAe,EAAA,EAAC,OAAO,EAAE,OAAO,EAAA,GAAM,IAAI,EAAA,QAAA,EACxC,QAAQ,EAAA,CACO,EAAA,CACJ;AAEpB;;"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var reactRouter = require('react-router');
|
|
6
|
+
var UnsavedChangesGuard_context = require('../../hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.cjs');
|
|
7
|
+
var unsavedChangesGuard_constants = require('./unsavedChangesGuard.constants.cjs');
|
|
8
|
+
var unsavedChangesGuard_utils = require('./utilities/unsavedChangesGuard.utils.cjs');
|
|
9
|
+
|
|
10
|
+
/** Registers the router's blocker. Rendered only while it is needed: react-router warns on every host navigation while one exists. */
|
|
11
|
+
const NavigationHold = ({ shouldBlock, onChange }) => {
|
|
12
|
+
const blocker = reactRouter.useBlocker(shouldBlock);
|
|
13
|
+
React.useEffect(() => onChange(blocker), [blocker, onChange]);
|
|
14
|
+
React.useEffect(() => () => onChange(null), [onChange]);
|
|
15
|
+
return null;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Holds the one navigation blocker a router allows and shares it between every `useUnsavedChangesGuard` beneath it, so
|
|
19
|
+
* several forms on a page are all protected. `UIProvider` renders it; add it yourself only inside your own data router.
|
|
20
|
+
*
|
|
21
|
+
* @summary shares one unsaved-changes navigation blocker with the tree
|
|
22
|
+
*/
|
|
23
|
+
const UnsavedChangesGuardProvider = ({ children }) => {
|
|
24
|
+
// Said at mount: react-router's own error for this only comes with the first unsaved change, when the blocker is registered.
|
|
25
|
+
if (!React.useContext(reactRouter.UNSAFE_DataRouterContext)) {
|
|
26
|
+
throw new Error('UnsavedChangesGuardProvider needs a react-router data router above it (createBrowserRouter with RouterProvider), or use UIProvider.');
|
|
27
|
+
}
|
|
28
|
+
const [dirtyIds, setDirtyIds] = React.useState([]);
|
|
29
|
+
const hasUnsavedChanges = dirtyIds.length > 0;
|
|
30
|
+
// The blocker reads this, not the state, so it never holds for a form saved since the last render.
|
|
31
|
+
const dirtyCount = React.useRef(0);
|
|
32
|
+
const basePath = reactRouter.useHref('/');
|
|
33
|
+
const location = reactRouter.useLocation();
|
|
34
|
+
const { pathname } = location;
|
|
35
|
+
const currentPlace = React.useRef({ idx: undefined, position: undefined });
|
|
36
|
+
// The entry the latest navigation left, by the browser's count: it shows when another router has moved the user on.
|
|
37
|
+
const leftPosition = React.useRef(undefined);
|
|
38
|
+
const isHostMove = React.useRef(false);
|
|
39
|
+
const [blocker, setBlocker] = React.useState(null);
|
|
40
|
+
// The blocker last answered. The copy in state can outlive the navigation it held, and react-router throws on a second answer.
|
|
41
|
+
const settledBlocker = React.useRef(null);
|
|
42
|
+
const [answerHost, setAnswerHost] = React.useState(null);
|
|
43
|
+
// Set when the user lets a host navigate, so the navigation they just approved is not held or prompted a second time.
|
|
44
|
+
const isHostApproved = React.useRef(false);
|
|
45
|
+
const hostApprovalTimer = React.useRef(undefined);
|
|
46
|
+
const endHostApproval = React.useCallback(() => {
|
|
47
|
+
isHostApproved.current = false;
|
|
48
|
+
clearTimeout(hostApprovalTimer.current);
|
|
49
|
+
}, []);
|
|
50
|
+
/** Whether the host's approved navigation is the one happening now; the approval covers one navigation only. */
|
|
51
|
+
const takeHostApproval = React.useCallback(() => {
|
|
52
|
+
const isApproved = isHostApproved.current;
|
|
53
|
+
endHostApproval();
|
|
54
|
+
return isApproved;
|
|
55
|
+
}, [endHostApproval]);
|
|
56
|
+
// A change of search params or hash keeps the page, and the form on it, so only a change of path is held.
|
|
57
|
+
const shouldBlock = React.useCallback(({ currentLocation, nextLocation, historyAction }) => {
|
|
58
|
+
if (dirtyCount.current === 0 || currentLocation.pathname === nextLocation.pathname)
|
|
59
|
+
return false;
|
|
60
|
+
if (historyAction === 'POP') {
|
|
61
|
+
// A host asks before it navigates, through the bridge, so its own push or replace is never held or undone here.
|
|
62
|
+
if (isHostMove.current)
|
|
63
|
+
return false;
|
|
64
|
+
const entry = unsavedChangesGuard_utils.browserEntry(nextLocation.key);
|
|
65
|
+
// Outside the app the host is already switching apps, so holding the move here would only bring back an empty form.
|
|
66
|
+
if (entry && !unsavedChangesGuard_utils.isInside(window.location.pathname, basePath))
|
|
67
|
+
return false;
|
|
68
|
+
// Another router on the page has pushed since: this one would rewind by its own stale count, onto the wrong entry.
|
|
69
|
+
if (entry && !unsavedChangesGuard_utils.hasLeftFrom(currentPlace.current, leftPosition.current))
|
|
70
|
+
return false;
|
|
71
|
+
if (entry && !unsavedChangesGuard_utils.canRewind(currentPlace.current, { idx: entry.idx, position: unsavedChangesGuard_utils.historyPosition() }))
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return !takeHostApproval();
|
|
75
|
+
}, [takeHostApproval, basePath]);
|
|
76
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: read again on every navigation, which gives a new location
|
|
77
|
+
React.useEffect(() => {
|
|
78
|
+
currentPlace.current = { idx: unsavedChangesGuard_utils.historyIndex(), position: unsavedChangesGuard_utils.historyPosition() };
|
|
79
|
+
}, [location]);
|
|
80
|
+
React.useEffect(() => unsavedChangesGuard_utils.watchLeftPosition((position) => {
|
|
81
|
+
leftPosition.current = position;
|
|
82
|
+
}), []);
|
|
83
|
+
React.useEffect(() => {
|
|
84
|
+
// A host tells its apps it has navigated by dispatching `popstate` itself, which the browser marks as not trusted.
|
|
85
|
+
const noteHostMove = (event) => {
|
|
86
|
+
if (event.isTrusted)
|
|
87
|
+
return;
|
|
88
|
+
isHostMove.current = true;
|
|
89
|
+
// Only while this event is handled: the router's own listener runs in the same dispatch.
|
|
90
|
+
queueMicrotask(() => {
|
|
91
|
+
isHostMove.current = false;
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
window.addEventListener('popstate', noteHostMove, true);
|
|
95
|
+
return () => window.removeEventListener('popstate', noteHostMove, true);
|
|
96
|
+
}, []);
|
|
97
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: a new path or a new set of unsaved forms ends the host's approval
|
|
98
|
+
React.useEffect(() => endHostApproval, [pathname, dirtyIds, endHostApproval]);
|
|
99
|
+
React.useEffect(() => {
|
|
100
|
+
if (!hasUnsavedChanges)
|
|
101
|
+
return;
|
|
102
|
+
const warn = (event) => {
|
|
103
|
+
if (takeHostApproval())
|
|
104
|
+
return;
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
// Chromium before 119 only prompts when `returnValue` is set.
|
|
107
|
+
event.returnValue = true;
|
|
108
|
+
};
|
|
109
|
+
window.addEventListener('beforeunload', warn);
|
|
110
|
+
return () => window.removeEventListener('beforeunload', warn);
|
|
111
|
+
}, [hasUnsavedChanges, takeHostApproval]);
|
|
112
|
+
React.useEffect(() => {
|
|
113
|
+
const guard = hasUnsavedChanges ? unsavedChangesGuard_utils.hostGuard() : undefined;
|
|
114
|
+
if (!guard)
|
|
115
|
+
return;
|
|
116
|
+
let pending = null;
|
|
117
|
+
let isRegistered = true;
|
|
118
|
+
const canLeave = () => new Promise((resolve) => {
|
|
119
|
+
// A host holding a registration that has since gone has nothing left to wait for.
|
|
120
|
+
if (!isRegistered)
|
|
121
|
+
return resolve(true);
|
|
122
|
+
// A second request replaces the first, which is answered "stay" so the host is never left waiting.
|
|
123
|
+
pending?.(false);
|
|
124
|
+
pending = resolve;
|
|
125
|
+
setAnswerHost(() => resolve);
|
|
126
|
+
});
|
|
127
|
+
let unregister;
|
|
128
|
+
try {
|
|
129
|
+
unregister = guard.register({ basePath, canLeave });
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
// A bridge that throws is treated as no bridge: this runs outside the app's error boundary, so it would take the page down.
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
return () => {
|
|
136
|
+
isRegistered = false;
|
|
137
|
+
try {
|
|
138
|
+
unregister();
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
// Ignored, as a `register` that throws is: this cleanup runs outside the app's error boundary too.
|
|
142
|
+
}
|
|
143
|
+
// Nothing is left to lose once the changes are saved or the form is gone, so a waiting host may go.
|
|
144
|
+
pending?.(true);
|
|
145
|
+
setAnswerHost(null);
|
|
146
|
+
};
|
|
147
|
+
}, [hasUnsavedChanges, basePath]);
|
|
148
|
+
/** Answers a held navigation, once: lets it go ahead, or puts the user back where they were. */
|
|
149
|
+
const settle = React.useCallback((held, leave) => {
|
|
150
|
+
if (held?.state !== 'blocked' || settledBlocker.current === held)
|
|
151
|
+
return;
|
|
152
|
+
settledBlocker.current = held;
|
|
153
|
+
if (leave)
|
|
154
|
+
held.proceed();
|
|
155
|
+
else
|
|
156
|
+
held.reset();
|
|
157
|
+
}, []);
|
|
158
|
+
// A navigation held while a save was in flight has nothing left to protect once the save lands.
|
|
159
|
+
React.useEffect(() => {
|
|
160
|
+
if (!hasUnsavedChanges)
|
|
161
|
+
settle(blocker, true);
|
|
162
|
+
}, [hasUnsavedChanges, blocker, settle]);
|
|
163
|
+
const register = React.useCallback((id) => {
|
|
164
|
+
dirtyCount.current += 1;
|
|
165
|
+
setDirtyIds((ids) => [...ids, id]);
|
|
166
|
+
return () => {
|
|
167
|
+
dirtyCount.current -= 1;
|
|
168
|
+
setDirtyIds((ids) => ids.filter((current) => current !== id));
|
|
169
|
+
};
|
|
170
|
+
}, []);
|
|
171
|
+
const answer = React.useCallback((leave) => {
|
|
172
|
+
settle(blocker, leave);
|
|
173
|
+
if (answerHost) {
|
|
174
|
+
endHostApproval();
|
|
175
|
+
if (leave) {
|
|
176
|
+
isHostApproved.current = true;
|
|
177
|
+
// A host that then does not navigate (another app said stay) must not leave the form unguarded.
|
|
178
|
+
hostApprovalTimer.current = setTimeout(endHostApproval, unsavedChangesGuard_constants.HOST_APPROVAL_MS);
|
|
179
|
+
}
|
|
180
|
+
answerHost(leave);
|
|
181
|
+
setAnswerHost(null);
|
|
182
|
+
}
|
|
183
|
+
}, [blocker, answerHost, endHostApproval, settle]);
|
|
184
|
+
const value = React.useMemo(() => ({ register, promptOwner: dirtyIds[0], isPromptOpen: blocker?.state === 'blocked' || answerHost !== null, answer }), [register, dirtyIds, blocker?.state, answerHost, answer]);
|
|
185
|
+
// Kept until a held navigation has finished, so one let go by a save is not dropped with the blocker.
|
|
186
|
+
const isBlockerNeeded = hasUnsavedChanges || (blocker !== null && blocker.state !== 'unblocked');
|
|
187
|
+
return (jsxRuntime.jsxs(UnsavedChangesGuard_context.UnsavedChangesGuardContext, { value: value, children: [isBlockerNeeded && jsxRuntime.jsx(NavigationHold, { shouldBlock: shouldBlock, onChange: setBlocker }), children] }));
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
exports.UnsavedChangesGuardProvider = UnsavedChangesGuardProvider;
|
|
191
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/providers/UnsavedChangesGuardProvider/index.tsx"],"sourcesContent":[null],"names":["useBlocker","useEffect","useContext","UNSAFE_DataRouterContext","useState","useRef","useHref","useLocation","useCallback","browserEntry","isInside","hasLeftFrom","canRewind","historyPosition","historyIndex","watchLeftPosition","hostGuard","HOST_APPROVAL_MS","useMemo","_jsxs","UnsavedChangesGuardContext","_jsx"],"mappings":";;;;;;;;;AA4BA;AACA,MAAM,cAAc,GAAG,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAuB,KAAI;AACxE,IAAA,MAAM,OAAO,GAAGA,sBAAU,CAAC,WAAW,CAAC;AACvC,IAAAC,eAAS,CAAC,MAAM,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC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C,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,KAAK,SAAS,IAAI,UAAU,KAAK,IAAI,EAAE,MAAM,EAAE,CAAC,EACzH,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,CACzD;;AAED,IAAA,MAAM,eAAe,GAAG,iBAAiB,KAAK,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,KAAK,WAAW,CAAC;IAEhG,QACEC,eAAA,CAACC,sDAA0B,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,QAAA,EAAA,CACrC,eAAe,IAAIC,cAAA,CAAC,cAAc,IAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAA,CAAI,EACrF,QAAQ,CAAA,EAAA,CACkB;AAEjC;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PropsWithChildren } from 'react';
|
|
2
|
+
export type { FdNavigationGuard, FdNavigationGuardRegistration } from './unsavedChangesGuard.types';
|
|
3
|
+
/**
|
|
4
|
+
* Holds the one navigation blocker a router allows and shares it between every `useUnsavedChangesGuard` beneath it, so
|
|
5
|
+
* several forms on a page are all protected. `UIProvider` renders it; add it yourself only inside your own data router.
|
|
6
|
+
*
|
|
7
|
+
* @summary shares one unsaved-changes navigation blocker with the tree
|
|
8
|
+
*/
|
|
9
|
+
export declare const UnsavedChangesGuardProvider: ({ children }: PropsWithChildren) => import("react").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/UnsavedChangesGuardProvider/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,iBAAiB,EAAiE,MAAM,OAAO,CAAC;AAiB9G,YAAY,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAiBpG;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,GAAI,cAAc,iBAAiB,gCAwL1E,CAAC"}
|