@flipdish/ui-library 0.51.0 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -16
- package/dist/components/atoms/Checkbox/index.cjs +4 -2
- 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 +4 -2
- 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/useSaveForm/useSaveForm.cjs +93 -0
- package/dist/components/forms/Form/hooks/useSaveForm/useSaveForm.cjs.map +1 -0
- package/dist/components/forms/Form/hooks/useSaveForm/useSaveForm.d.ts +54 -0
- package/dist/components/forms/Form/hooks/useSaveForm/useSaveForm.d.ts.map +1 -0
- package/dist/components/forms/Form/hooks/useSaveForm/useSaveForm.js +91 -0
- package/dist/components/forms/Form/hooks/useSaveForm/useSaveForm.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 +63 -0
- package/dist/components/forms/Form/index.cjs.map +1 -0
- package/dist/components/forms/Form/index.d.ts +37 -0
- package/dist/components/forms/Form/index.d.ts.map +1 -0
- package/dist/components/forms/Form/index.js +59 -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 +56 -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/FormSaveErrorAlert/index.cjs +28 -0
- package/dist/components/forms/FormSaveErrorAlert/index.cjs.map +1 -0
- package/dist/components/forms/FormSaveErrorAlert/index.d.ts +18 -0
- package/dist/components/forms/FormSaveErrorAlert/index.d.ts.map +1 -0
- package/dist/components/forms/FormSaveErrorAlert/index.js +26 -0
- package/dist/components/forms/FormSaveErrorAlert/index.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/FormUnsavedChangesModal/index.cjs +24 -0
- package/dist/components/forms/FormUnsavedChangesModal/index.cjs.map +1 -0
- package/dist/components/forms/FormUnsavedChangesModal/index.d.ts +14 -0
- package/dist/components/forms/FormUnsavedChangesModal/index.d.ts.map +1 -0
- package/dist/components/forms/FormUnsavedChangesModal/index.js +22 -0
- package/dist/components/forms/FormUnsavedChangesModal/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 +147 -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 +145 -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/fieldDependents.utils.cjs +47 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.cjs.map +1 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.d.ts +26 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.d.ts.map +1 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.js +43 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.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/__internal__/formSubmit/providers/FormSubmit.context.cjs +12 -0
- package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.cjs.map +1 -0
- package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.d.ts +6 -0
- package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.d.ts.map +1 -0
- package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.js +10 -0
- package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.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 +19 -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 +19 -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 +24 -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 +20 -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 +19 -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 +20 -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 +32 -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 +20 -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 +19 -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 +20 -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 +19 -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 +19 -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 +44 -0
- package/dist/components/forms/validation/hooks/useSchemaResolver.cjs.map +1 -0
- package/dist/components/forms/validation/hooks/useSchemaResolver.d.ts +16 -0
- package/dist/components/forms/validation/hooks/useSchemaResolver.d.ts.map +1 -0
- package/dist/components/forms/validation/hooks/useSchemaResolver.js +42 -0
- package/dist/components/forms/validation/hooks/useSchemaResolver.js.map +1 -0
- package/dist/components/forms/validation/index.cjs +413 -0
- package/dist/components/forms/validation/index.cjs.map +1 -0
- package/dist/components/forms/validation/index.d.ts +278 -0
- package/dist/components/forms/validation/index.d.ts.map +1 -0
- package/dist/components/forms/validation/index.js +394 -0
- package/dist/components/forms/validation/index.js.map +1 -0
- package/dist/components/forms/validation/utilities/validation.utils.cjs +72 -0
- package/dist/components/forms/validation/utilities/validation.utils.cjs.map +1 -0
- package/dist/components/forms/validation/utilities/validation.utils.d.ts +38 -0
- package/dist/components/forms/validation/utilities/validation.utils.d.ts.map +1 -0
- package/dist/components/forms/validation/utilities/validation.utils.js +67 -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/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/GradientPicker/components/GradientStopRow.cjs +1 -1
- package/dist/components/organisms/GradientPicker/components/GradientStopRow.js +1 -1
- package/dist/hooks/useFocusAfterRetry/index.cjs +7 -3
- package/dist/hooks/useFocusAfterRetry/index.cjs.map +1 -1
- package/dist/hooks/useFocusAfterRetry/index.d.ts +8 -2
- package/dist/hooks/useFocusAfterRetry/index.d.ts.map +1 -1
- package/dist/hooks/useFocusAfterRetry/index.js +7 -3
- package/dist/hooks/useFocusAfterRetry/index.js.map +1 -1
- package/dist/localization/en.json.cjs +117 -0
- package/dist/localization/en.json.cjs.map +1 -0
- package/dist/localization/en.json.js +98 -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/FormSaveErrorAlert/index.d.ts +12 -0
- package/dist/native/components/forms/FormSection/index.d.ts +12 -0
- package/dist/native/components/forms/FormUnsavedChangesModal/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/utilities/colorUtils/index.d.ts +12 -0
- package/dist/providers/UnsavedChangesGuardProvider/index.cjs +1 -1
- package/dist/providers/UnsavedChangesGuardProvider/index.js +1 -1
- package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.cjs.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/{unsavedChangesGuard.utils.d.ts → utilities/unsavedChangesGuard.utils.d.ts} +1 -1
- package/dist/providers/UnsavedChangesGuardProvider/utilities/unsavedChangesGuard.utils.d.ts.map +1 -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/dist/utilities/colorUtils/index.cjs +24 -0
- package/dist/utilities/colorUtils/index.cjs.map +1 -0
- package/dist/utilities/colorUtils/index.d.ts +8 -0
- package/dist/utilities/colorUtils/index.d.ts.map +1 -0
- package/dist/utilities/colorUtils/index.js +22 -0
- package/dist/utilities/colorUtils/index.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/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.utils.cjs.map +0 -1
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.utils.d.ts.map +0 -1
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.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
- /package/dist/providers/UnsavedChangesGuardProvider/{unsavedChangesGuard.utils.cjs → utilities/unsavedChangesGuard.utils.cjs} +0 -0
- /package/dist/providers/UnsavedChangesGuardProvider/{unsavedChangesGuard.utils.js → utilities/unsavedChangesGuard.utils.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHasFieldError.js","sources":["../../../../../src/components/forms/FormFooter/hooks/useHasFieldError.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAKA,MAAM,kBAAkB,GAAG,MAAM,MAAK,EAAE,CAAC;AACzC,MAAM,SAAS,GAAG,MAAM,CAAC;AAEzB;;;;;;AAMG;AACI,MAAM,gBAAgB,GAAG,MAAc;AAC5C,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,YAAY,EAAE;AACjC,IAAA,MAAM,aAAa,GAAG,UAAU,CAAC,oBAAoB,CAAC;;AAEtD,IAAA,oBAAoB,CAClB,aAAa,EAAE,SAAS,IAAI,kBAAkB,EAC9C,aAAa,EAAE,UAAU,IAAI,SAAS,EACtC,aAAa,EAAE,UAAU,IAAI,SAAS,CACvC;IACD,OAAO,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,CAAC;AACvD;;"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var uiIcons = require('@flipdish/ui-icons');
|
|
5
|
+
var Button = require('@flipdish/ui-library/components/atoms/Button');
|
|
6
|
+
var Modals = require('@flipdish/ui-library/components/molecules/Modals');
|
|
7
|
+
var SectionFooter = require('@flipdish/ui-library/components/molecules/SectionFooter');
|
|
8
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
9
|
+
var reactHookForm = require('react-hook-form');
|
|
10
|
+
var useReturnFocus = require('../../../hooks/__internal__/useReturnFocus/useReturnFocus.cjs');
|
|
11
|
+
var useDestructiveConfirmation = require('./hooks/useDestructiveConfirmation.cjs');
|
|
12
|
+
var useHasFieldError = require('./hooks/useHasFieldError.cjs');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The footer of a react-hook-form form that waits on Save: an optional destructive action on the left, Discard and Save
|
|
16
|
+
* on the right, driven by the form's own dirty, error and submitting state. Use one per form, as the last thing inside its `<form>`.
|
|
17
|
+
*
|
|
18
|
+
* @summary discard and save footer driven by a react-hook-form form
|
|
19
|
+
*/
|
|
20
|
+
const FormFooter = ({ onDiscard, isSaved = false, destructiveAction, isDirty: isDirtyProp, hasErrors: hasErrorsProp, isSaving: isSavingProp, 'data-testid': dataTestId, }) => {
|
|
21
|
+
const formState = reactHookForm.useFormState();
|
|
22
|
+
const isDirty = isDirtyProp ?? formState.isDirty;
|
|
23
|
+
const hasFieldErrorNow = useHasFieldError.useHasFieldError();
|
|
24
|
+
const hasErrors = hasErrorsProp ?? hasFieldErrorNow;
|
|
25
|
+
const isSaving = isSavingProp ?? formState.isSubmitting;
|
|
26
|
+
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'form-footer', rootName: 'form-footer' });
|
|
27
|
+
const { originRef, returnFocus } = useReturnFocus.useReturnFocus('button[type="submit"]', 'form');
|
|
28
|
+
const confirmation = useDestructiveConfirmation.useDestructiveConfirmation(destructiveAction?.onConfirm);
|
|
29
|
+
/** Discard turns itself off once the form is clean, which would drop focus to the top of the page, so Save takes it first. */
|
|
30
|
+
const discard = () => {
|
|
31
|
+
returnFocus();
|
|
32
|
+
onDiscard();
|
|
33
|
+
};
|
|
34
|
+
return (
|
|
35
|
+
// On a phone the buttons stack full width in the order they sit in a row on a wider screen: the destructive action,
|
|
36
|
+
// Discard, then Save last.
|
|
37
|
+
jsxRuntime.jsxs(SectionFooter.SectionFooter.Root, { ref: originRef, "data-testid": rootTestId, className: "flex-col items-stretch gap-3 sm:flex-row sm:flex-wrap sm:items-center sm:gap-5", children: [destructiveAction && (jsxRuntime.jsx(Button.Button, { color: "secondary-destructive", size: "md", iconLeading: uiIcons.Trash01, isDisabled: isSaving, isLoading: destructiveAction.isPending, showTextWhileLoading: true, onPress: destructiveAction.confirmation ? confirmation.open : destructiveAction.onPress, "data-testid": testIdUtils.joinTestId(rootTestId, 'destructive-action'), children: destructiveAction.label })), destructiveAction?.confirmation && (jsxRuntime.jsx(Modals.ConfirmationModal, { isOpen: confirmation.isOpen, onOpenChange: confirmation.onOpenChange, title: destructiveAction.confirmation.title, description: destructiveAction.confirmation.description, confirmLabel: destructiveAction.label, onConfirm: confirmation.confirm, isConfirming: confirmation.isConfirming, isDestructive: true, "data-testid": testIdUtils.joinTestId(rootTestId, 'destructive-confirmation') })), jsxRuntime.jsxs(SectionFooter.SectionFooter.Actions, { className: "flex-none flex-col items-stretch sm:flex-1 sm:flex-row sm:flex-wrap sm:items-center", children: [jsxRuntime.jsx("output", { className: "sr-only", children: isSaved && 'Changes saved' }), jsxRuntime.jsx(Button.Button, { color: "secondary", size: "md", iconLeading: uiIcons.ReverseLeft, isDisabled: !isDirty || isSaving, onPress: discard, "data-testid": testIdUtils.joinTestId(rootTestId, 'discard'), children: "Discard" }), jsxRuntime.jsx(Button.Button, { type: "submit", color: "primary", size: "md", iconLeading: uiIcons.Save01, isDisabled: hasErrors, isLoading: isSaving, showTextWhileLoading: true, isSuccess: isSaved, "data-testid": testIdUtils.joinTestId(rootTestId, 'save'), children: "Save" })] })] }));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
exports.FormFooter = FormFooter;
|
|
41
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/forms/FormFooter/index.tsx"],"sourcesContent":[null],"names":["useFormState","useHasFieldError","useResolvedTestId","useReturnFocus","useDestructiveConfirmation","_jsxs","SectionFooter","_jsx","Button","Trash01","joinTestId","ConfirmationModal","ReverseLeft","Save01"],"mappings":";;;;;;;;;;;;;AAiEA;;;;;AAKG;AACI,MAAM,UAAU,GAAG,CAAC,EACzB,SAAS,EACT,OAAO,GAAG,KAAK,EACf,iBAAiB,EACjB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,aAAa,EACxB,QAAQ,EAAE,YAAY,EACtB,aAAa,EAAE,UAAU,GACT,KAAI;AACpB,IAAA,MAAM,SAAS,GAAGA,0BAAY,EAAE;AAChC,IAAA,MAAM,OAAO,GAAG,WAAW,IAAI,SAAS,CAAC,OAAO;AAChD,IAAA,MAAM,gBAAgB,GAAGC,iCAAgB,EAAE;AAC3C,IAAA,MAAM,SAAS,GAAG,aAAa,IAAI,gBAAgB;AACnD,IAAA,MAAM,QAAQ,GAAG,YAAY,IAAI,SAAS,CAAC,YAAY;AACvD,IAAA,MAAM,UAAU,GAAGC,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;AAC7G,IAAA,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAGC,6BAAc,CAAiB,uBAAuB,EAAE,MAAM,CAAC;IAClG,MAAM,YAAY,GAAGC,qDAA0B,CAAC,iBAAiB,EAAE,SAAS,CAAC;;IAG7E,MAAM,OAAO,GAAG,MAAK;AACnB,QAAA,WAAW,EAAE;AACb,QAAA,SAAS,EAAE;AACb,IAAA,CAAC;IAED;;;IAGEC,eAA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BAAW,EACxB,UAAU,EAAE,CAAC,OAAO,IAAI,QAAQ,EAChC,OAAO,EAAE,OAAO,EAAA,aAAA,EACHF,sBAAU,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,SAAA,EAAA,CAGvC,EAETH,eAACC,aAAM,EAAA,EACL,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,SAAS,EACf,IAAI,EAAC,IAAI,EACT,WAAW,EAAEK,cAAM,EACnB,UAAU,EAAE,SAAS,EACrB,SAAS,EAAE,QAAQ,EACnB,oBAAoB,EAAA,IAAA,EACpB,SAAS,EAAE,OAAO,EAAA,aAAA,EACLH,sBAAU,CAAC,UAAU,EAAE,MAAM,CAAC,EAAA,QAAA,EAAA,MAAA,EAAA,CAGpC,CAAA,EAAA,CACa,CAAA,EAAA,CACL;AAEzB;;"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** The dialog that asks the user to confirm a destructive action. */
|
|
2
|
+
export interface FormFooterConfirmation {
|
|
3
|
+
/** The question being asked, such as "Remove this item?". */
|
|
4
|
+
title: string;
|
|
5
|
+
/** What confirming will do, beneath the title. */
|
|
6
|
+
description: string;
|
|
7
|
+
}
|
|
8
|
+
/** A destructive action the footer confirms itself: pressing the button opens a dialog, and confirming runs the action. */
|
|
9
|
+
export interface FormFooterConfirmedAction {
|
|
10
|
+
/** The button's text, such as "Remove" or "Remove property"; the dialog's confirming button repeats it. */
|
|
11
|
+
label: string;
|
|
12
|
+
/** The dialog shown before the action runs. */
|
|
13
|
+
confirmation: FormFooterConfirmation;
|
|
14
|
+
/** Runs once the user confirms. Return the action's promise and the dialog shows it loading, then closes when it settles. */
|
|
15
|
+
onConfirm: () => unknown;
|
|
16
|
+
/** Whether the action is running where the footer cannot see it, such as a retry from an alert: the button shows it loading and holds a second press. */
|
|
17
|
+
isPending?: boolean;
|
|
18
|
+
onPress?: never;
|
|
19
|
+
}
|
|
20
|
+
/** A destructive action the app confirms itself, for a removal that needs more than a yes or no. */
|
|
21
|
+
export interface FormFooterOwnAction {
|
|
22
|
+
/** The button's text, such as "Remove" or "Remove property". */
|
|
23
|
+
label: string;
|
|
24
|
+
/** Runs on press; open your own dialog here, since the footer does not ask. */
|
|
25
|
+
onPress: () => void;
|
|
26
|
+
/** Whether the action is running where the footer cannot see it, such as a retry from an alert: the button shows it loading and holds a second press. */
|
|
27
|
+
isPending?: boolean;
|
|
28
|
+
confirmation?: never;
|
|
29
|
+
onConfirm?: never;
|
|
30
|
+
}
|
|
31
|
+
/** A destructive action for the record the form edits, such as removing it. */
|
|
32
|
+
export type FormFooterDestructiveAction = FormFooterConfirmedAction | FormFooterOwnAction;
|
|
33
|
+
export interface FormFooterProps {
|
|
34
|
+
/** Puts the form back to what was loaded or last saved, such as `reset()` plus clearing a failed save. */
|
|
35
|
+
onDiscard: () => void;
|
|
36
|
+
/** Whether the last save succeeded and nothing has changed since: Save shows a check and "Changes saved" is announced. */
|
|
37
|
+
isSaved?: boolean;
|
|
38
|
+
/** Adds a destructive button for the record itself on the left, held while the form saves. With `confirmation` the footer asks before running `onConfirm`. */
|
|
39
|
+
destructiveAction?: FormFooterDestructiveAction;
|
|
40
|
+
/** Turns Discard on. Defaults to the form's `isDirty`. */
|
|
41
|
+
isDirty?: boolean;
|
|
42
|
+
/** Turns Save off until the last field error is fixed. Defaults to whether a field has an error; inside `Form`, only a `Form*` field still on the page counts. */
|
|
43
|
+
hasErrors?: boolean;
|
|
44
|
+
/** Shows Save's spinner and holds Discard. Defaults to the form's `isSubmitting`, so return the save's promise from the submit handler. */
|
|
45
|
+
isSaving?: boolean;
|
|
46
|
+
/** Overrides the root `data-testid` (defaults to `fd-form-footer`); the buttons derive theirs from it. */
|
|
47
|
+
'data-testid'?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The footer of a react-hook-form form that waits on Save: an optional destructive action on the left, Discard and Save
|
|
51
|
+
* on the right, driven by the form's own dirty, error and submitting state. Use one per form, as the last thing inside its `<form>`.
|
|
52
|
+
*
|
|
53
|
+
* @summary discard and save footer driven by a react-hook-form form
|
|
54
|
+
*/
|
|
55
|
+
export declare const FormFooter: ({ onDiscard, isSaved, destructiveAction, isDirty: isDirtyProp, hasErrors: hasErrorsProp, isSaving: isSavingProp, "data-testid": dataTestId, }: FormFooterProps) => import("react").JSX.Element;
|
|
56
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/FormFooter/index.tsx"],"names":[],"mappings":"AAYA,qEAAqE;AACrE,MAAM,WAAW,sBAAsB;IACrC,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,2HAA2H;AAC3H,MAAM,WAAW,yBAAyB;IACxC,2GAA2G;IAC3G,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,YAAY,EAAE,sBAAsB,CAAC;IACrC,6HAA6H;IAC7H,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,yJAAyJ;IACzJ,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB;AAED,oGAAoG;AACpG,MAAM,WAAW,mBAAmB;IAClC,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,yJAAyJ;IACzJ,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB;AAED,+EAA+E;AAC/E,MAAM,MAAM,2BAA2B,GAAG,yBAAyB,GAAG,mBAAmB,CAAC;AAE1F,MAAM,WAAW,eAAe;IAC9B,0GAA0G;IAC1G,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,0HAA0H;IAC1H,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8JAA8J;IAC9J,iBAAiB,CAAC,EAAE,2BAA2B,CAAC;IAChD,0DAA0D;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kKAAkK;IAClK,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,2IAA2I;IAC3I,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0GAA0G;IAC1G,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,+IAQxB,eAAe,gCAiFjB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Trash01, ReverseLeft, Save01 } from '@flipdish/ui-icons';
|
|
3
|
+
import { Button } from '@flipdish/ui-library/components/atoms/Button';
|
|
4
|
+
import { ConfirmationModal } from '@flipdish/ui-library/components/molecules/Modals';
|
|
5
|
+
import { SectionFooter } from '@flipdish/ui-library/components/molecules/SectionFooter';
|
|
6
|
+
import { useResolvedTestId, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
7
|
+
import { useFormState } from 'react-hook-form';
|
|
8
|
+
import { useReturnFocus } from '../../../hooks/__internal__/useReturnFocus/useReturnFocus.js';
|
|
9
|
+
import { useDestructiveConfirmation } from './hooks/useDestructiveConfirmation.js';
|
|
10
|
+
import { useHasFieldError } from './hooks/useHasFieldError.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The footer of a react-hook-form form that waits on Save: an optional destructive action on the left, Discard and Save
|
|
14
|
+
* on the right, driven by the form's own dirty, error and submitting state. Use one per form, as the last thing inside its `<form>`.
|
|
15
|
+
*
|
|
16
|
+
* @summary discard and save footer driven by a react-hook-form form
|
|
17
|
+
*/
|
|
18
|
+
const FormFooter = ({ onDiscard, isSaved = false, destructiveAction, isDirty: isDirtyProp, hasErrors: hasErrorsProp, isSaving: isSavingProp, 'data-testid': dataTestId, }) => {
|
|
19
|
+
const formState = useFormState();
|
|
20
|
+
const isDirty = isDirtyProp ?? formState.isDirty;
|
|
21
|
+
const hasFieldErrorNow = useHasFieldError();
|
|
22
|
+
const hasErrors = hasErrorsProp ?? hasFieldErrorNow;
|
|
23
|
+
const isSaving = isSavingProp ?? formState.isSubmitting;
|
|
24
|
+
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'form-footer', rootName: 'form-footer' });
|
|
25
|
+
const { originRef, returnFocus } = useReturnFocus('button[type="submit"]', 'form');
|
|
26
|
+
const confirmation = useDestructiveConfirmation(destructiveAction?.onConfirm);
|
|
27
|
+
/** Discard turns itself off once the form is clean, which would drop focus to the top of the page, so Save takes it first. */
|
|
28
|
+
const discard = () => {
|
|
29
|
+
returnFocus();
|
|
30
|
+
onDiscard();
|
|
31
|
+
};
|
|
32
|
+
return (
|
|
33
|
+
// On a phone the buttons stack full width in the order they sit in a row on a wider screen: the destructive action,
|
|
34
|
+
// Discard, then Save last.
|
|
35
|
+
jsxs(SectionFooter.Root, { ref: originRef, "data-testid": rootTestId, className: "flex-col items-stretch gap-3 sm:flex-row sm:flex-wrap sm:items-center sm:gap-5", children: [destructiveAction && (jsx(Button, { color: "secondary-destructive", size: "md", iconLeading: Trash01, isDisabled: isSaving, isLoading: destructiveAction.isPending, showTextWhileLoading: true, onPress: destructiveAction.confirmation ? confirmation.open : destructiveAction.onPress, "data-testid": joinTestId(rootTestId, 'destructive-action'), children: destructiveAction.label })), destructiveAction?.confirmation && (jsx(ConfirmationModal, { isOpen: confirmation.isOpen, onOpenChange: confirmation.onOpenChange, title: destructiveAction.confirmation.title, description: destructiveAction.confirmation.description, confirmLabel: destructiveAction.label, onConfirm: confirmation.confirm, isConfirming: confirmation.isConfirming, isDestructive: true, "data-testid": joinTestId(rootTestId, 'destructive-confirmation') })), jsxs(SectionFooter.Actions, { className: "flex-none flex-col items-stretch sm:flex-1 sm:flex-row sm:flex-wrap sm:items-center", children: [jsx("output", { className: "sr-only", children: isSaved && 'Changes saved' }), jsx(Button, { color: "secondary", size: "md", iconLeading: ReverseLeft, isDisabled: !isDirty || isSaving, onPress: discard, "data-testid": joinTestId(rootTestId, 'discard'), children: "Discard" }), jsx(Button, { type: "submit", color: "primary", size: "md", iconLeading: Save01, isDisabled: hasErrors, isLoading: isSaving, showTextWhileLoading: true, isSuccess: isSaved, "data-testid": joinTestId(rootTestId, 'save'), children: "Save" })] })] }));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { FormFooter };
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/forms/FormFooter/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;AAiEA;;;;;AAKG;AACI,MAAM,UAAU,GAAG,CAAC,EACzB,SAAS,EACT,OAAO,GAAG,KAAK,EACf,iBAAiB,EACjB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,aAAa,EACxB,QAAQ,EAAE,YAAY,EACtB,aAAa,EAAE,UAAU,GACT,KAAI;AACpB,IAAA,MAAM,SAAS,GAAG,YAAY,EAAE;AAChC,IAAA,MAAM,OAAO,GAAG,WAAW,IAAI,SAAS,CAAC,OAAO;AAChD,IAAA,MAAM,gBAAgB,GAAG,gBAAgB,EAAE;AAC3C,IAAA,MAAM,SAAS,GAAG,aAAa,IAAI,gBAAgB;AACnD,IAAA,MAAM,QAAQ,GAAG,YAAY,IAAI,SAAS,CAAC,YAAY;AACvD,IAAA,MAAM,UAAU,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;AAC7G,IAAA,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,cAAc,CAAiB,uBAAuB,EAAE,MAAM,CAAC;IAClG,MAAM,YAAY,GAAG,0BAA0B,CAAC,iBAAiB,EAAE,SAAS,C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,EAAA,CAAU,EACjEA,GAAA,CAAC,MAAM,EAAA,EACL,KAAK,EAAC,WAAW,EACjB,IAAI,EAAC,IAAI,EACT,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,CAAC,OAAO,IAAI,QAAQ,EAChC,OAAO,EAAE,OAAO,EAAA,aAAA,EACH,UAAU,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,SAAA,EAAA,CAGvC,EAETA,IAAC,MAAM,EAAA,EACL,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,SAAS,EACf,IAAI,EAAC,IAAI,EACT,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,SAAS,EACrB,SAAS,EAAE,QAAQ,EACnB,oBAAoB,EAAA,IAAA,EACpB,SAAS,EAAE,OAAO,EAAA,aAAA,EACL,UAAU,CAAC,UAAU,EAAE,MAAM,CAAC,EAAA,QAAA,EAAA,MAAA,EAAA,CAGpC,CAAA,EAAA,CACa,CAAA,EAAA,CACL;AAEzB;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var formFocus_utils = require('../../__internal__/formField/utilities/formFocus.utils.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Whether a field of the form shows an error, which is when Save is off. The form's own error under `root`, such as a
|
|
7
|
+
* failed save, is left out: no field edit clears it, only another submit, so it must not hold Save off.
|
|
8
|
+
*
|
|
9
|
+
* @param errors The form's `formState.errors`.
|
|
10
|
+
* @param fieldElements Each mounted field's element by name, inside `Form`. With it, only an error on a field still on
|
|
11
|
+
* the page counts: react-hook-form keeps the error of a field that has left it, and nothing on screen says how to fix that one.
|
|
12
|
+
* @returns `true` while at least one field shows an error.
|
|
13
|
+
*/
|
|
14
|
+
const hasFieldError = (errors, fieldElements) => {
|
|
15
|
+
if (fieldElements)
|
|
16
|
+
return formFocus_utils.firstInvalidFieldOnPage(errors, fieldElements) !== undefined;
|
|
17
|
+
return Object.keys(errors).some((key) => key !== 'root');
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.hasFieldError = hasFieldError;
|
|
21
|
+
//# sourceMappingURL=formFooter.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formFooter.utils.cjs","sources":["../../../../../src/components/forms/FormFooter/utilities/formFooter.utils.ts"],"sourcesContent":[null],"names":["firstInvalidFieldOnPage"],"mappings":";;;;AAGA;;;;;;;;AAQG;MACU,aAAa,GAAG,CAAC,MAAmB,EAAE,aAA2C,KAAa;AACzG,IAAA,IAAI,aAAa;QAAE,OAAOA,uCAAuB,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,SAAS;AACtF,IAAA,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,KAAK,MAAM,CAAC;AAC1D;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FieldErrors } from 'react-hook-form';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a field of the form shows an error, which is when Save is off. The form's own error under `root`, such as a
|
|
4
|
+
* failed save, is left out: no field edit clears it, only another submit, so it must not hold Save off.
|
|
5
|
+
*
|
|
6
|
+
* @param errors The form's `formState.errors`.
|
|
7
|
+
* @param fieldElements Each mounted field's element by name, inside `Form`. With it, only an error on a field still on
|
|
8
|
+
* the page counts: react-hook-form keeps the error of a field that has left it, and nothing on screen says how to fix that one.
|
|
9
|
+
* @returns `true` while at least one field shows an error.
|
|
10
|
+
*/
|
|
11
|
+
export declare const hasFieldError: (errors: FieldErrors, fieldElements?: Map<string, Element> | null) => boolean;
|
|
12
|
+
//# sourceMappingURL=formFooter.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formFooter.utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/FormFooter/utilities/formFooter.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGnD;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,WAAW,EAAE,gBAAgB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,KAAG,OAGhG,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { firstInvalidFieldOnPage } from '../../__internal__/formField/utilities/formFocus.utils.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Whether a field of the form shows an error, which is when Save is off. The form's own error under `root`, such as a
|
|
5
|
+
* failed save, is left out: no field edit clears it, only another submit, so it must not hold Save off.
|
|
6
|
+
*
|
|
7
|
+
* @param errors The form's `formState.errors`.
|
|
8
|
+
* @param fieldElements Each mounted field's element by name, inside `Form`. With it, only an error on a field still on
|
|
9
|
+
* the page counts: react-hook-form keeps the error of a field that has left it, and nothing on screen says how to fix that one.
|
|
10
|
+
* @returns `true` while at least one field shows an error.
|
|
11
|
+
*/
|
|
12
|
+
const hasFieldError = (errors, fieldElements) => {
|
|
13
|
+
if (fieldElements)
|
|
14
|
+
return firstInvalidFieldOnPage(errors, fieldElements) !== undefined;
|
|
15
|
+
return Object.keys(errors).some((key) => key !== 'root');
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { hasFieldError };
|
|
19
|
+
//# sourceMappingURL=formFooter.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formFooter.utils.js","sources":["../../../../../src/components/forms/FormFooter/utilities/formFooter.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;;;;;;;;AAQG;MACU,aAAa,GAAG,CAAC,MAAmB,EAAE,aAA2C,KAAa;AACzG,IAAA,IAAI,aAAa;QAAE,OAAO,uBAAuB,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,SAAS;AACtF,IAAA,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,KAAK,MAAM,CAAC;AAC1D;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var Alerts = require('@flipdish/ui-library/components/molecules/Alerts');
|
|
5
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var FormSubmit_context = require('../__internal__/formSubmit/providers/FormSubmit.context.cjs');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Reports a form's save that failed outright, and submits the form again on "Try again", so a retry takes the path
|
|
11
|
+
* Save does. Render it inside `Form`, above `FormFooter`, while the save has failed.
|
|
12
|
+
*
|
|
13
|
+
* @summary failed-save alert that retries by submitting its form
|
|
14
|
+
*/
|
|
15
|
+
const FormSaveErrorAlert = ({ title = 'Your changes could not be saved', message, onDismiss, 'data-testid': dataTestId, }) => {
|
|
16
|
+
const requestSubmit = React.useContext(FormSubmit_context.FormSubmitContext);
|
|
17
|
+
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'form-save-error-alert', rootName: 'form-save-error-alert' });
|
|
18
|
+
if (!requestSubmit)
|
|
19
|
+
throw new Error('FormSaveErrorAlert needs Form above it: "Try again" submits that form.');
|
|
20
|
+
// The page's own wording names no cause: the failure may be a lost connection or a refusal the server gave no reason for.
|
|
21
|
+
const description = message
|
|
22
|
+
? `${message} Your changes are still here.`
|
|
23
|
+
: 'Your changes are still here. Try again, or contact support if it keeps failing.';
|
|
24
|
+
return jsxRuntime.jsx(Alerts.SaveErrorAlert, { title: title, description: description, onRetry: requestSubmit, onDismiss: onDismiss, "data-testid": rootTestId });
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.FormSaveErrorAlert = FormSaveErrorAlert;
|
|
28
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/forms/FormSaveErrorAlert/index.tsx"],"sourcesContent":[null],"names":["useContext","FormSubmitContext","useResolvedTestId","_jsx","SaveErrorAlert"],"mappings":";;;;;;;;AAkBA;;;;;AAKG;AACI,MAAM,kBAAkB,GAAG,CAAC,EACjC,KAAK,GAAG,iCAAiC,EACzC,OAAO,EACP,SAAS,EACT,aAAa,EAAE,UAAU,GACD,KAAI;AAC5B,IAAA,MAAM,aAAa,GAAGA,gBAAU,CAACC,oCAAiB,CAAC;AACnD,IAAA,MAAM,UAAU,GAAGC,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,uBAAuB,EAAE,CAAC;AACjI,IAAA,IAAI,CAAC,aAAa;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC;;IAE7G,MAAM,WAAW,GAAG;UAChB,CAAA,EAAG,OAAO,CAAA,6BAAA;UACV,iFAAiF;IAErF,OAAOC,cAAA,CAACC,qBAAc,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAA,aAAA,EAAe,UAAU,EAAA,CAAI;AAC1I;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface FormSaveErrorAlertProps {
|
|
2
|
+
/** What failed. Name the part when a page has several forms, such as "Colours could not be saved". */
|
|
3
|
+
title?: string;
|
|
4
|
+
/** The server's own reason, when it gave one written for the user; shown ahead of the line saying the edits are kept. */
|
|
5
|
+
message?: string;
|
|
6
|
+
/** Hides the alert, such as `dismissSaveError` from `useSaveForm`; the caller stops rendering it. */
|
|
7
|
+
onDismiss: () => void;
|
|
8
|
+
/** Overrides the root `data-testid` (defaults to `fd-form-save-error-alert`); the retry, dismiss and close buttons derive theirs from it. */
|
|
9
|
+
'data-testid'?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Reports a form's save that failed outright, and submits the form again on "Try again", so a retry takes the path
|
|
13
|
+
* Save does. Render it inside `Form`, above `FormFooter`, while the save has failed.
|
|
14
|
+
*
|
|
15
|
+
* @summary failed-save alert that retries by submitting its form
|
|
16
|
+
*/
|
|
17
|
+
export declare const FormSaveErrorAlert: ({ title, message, onDismiss, "data-testid": dataTestId, }: FormSaveErrorAlertProps) => import("react").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/FormSaveErrorAlert/index.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,uBAAuB;IACtC,sGAAsG;IACtG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yHAAyH;IACzH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qGAAqG;IACrG,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,6IAA6I;IAC7I,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,2DAKhC,uBAAuB,gCAUzB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { SaveErrorAlert } from '@flipdish/ui-library/components/molecules/Alerts';
|
|
3
|
+
import { useResolvedTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
4
|
+
import { useContext } from 'react';
|
|
5
|
+
import { FormSubmitContext } from '../__internal__/formSubmit/providers/FormSubmit.context.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Reports a form's save that failed outright, and submits the form again on "Try again", so a retry takes the path
|
|
9
|
+
* Save does. Render it inside `Form`, above `FormFooter`, while the save has failed.
|
|
10
|
+
*
|
|
11
|
+
* @summary failed-save alert that retries by submitting its form
|
|
12
|
+
*/
|
|
13
|
+
const FormSaveErrorAlert = ({ title = 'Your changes could not be saved', message, onDismiss, 'data-testid': dataTestId, }) => {
|
|
14
|
+
const requestSubmit = useContext(FormSubmitContext);
|
|
15
|
+
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'form-save-error-alert', rootName: 'form-save-error-alert' });
|
|
16
|
+
if (!requestSubmit)
|
|
17
|
+
throw new Error('FormSaveErrorAlert needs Form above it: "Try again" submits that form.');
|
|
18
|
+
// The page's own wording names no cause: the failure may be a lost connection or a refusal the server gave no reason for.
|
|
19
|
+
const description = message
|
|
20
|
+
? `${message} Your changes are still here.`
|
|
21
|
+
: 'Your changes are still here. Try again, or contact support if it keeps failing.';
|
|
22
|
+
return jsx(SaveErrorAlert, { title: title, description: description, onRetry: requestSubmit, onDismiss: onDismiss, "data-testid": rootTestId });
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { FormSaveErrorAlert };
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/forms/FormSaveErrorAlert/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;AAkBA;;;;;AAKG;AACI,MAAM,kBAAkB,GAAG,CAAC,EACjC,KAAK,GAAG,iCAAiC,EACzC,OAAO,EACP,SAAS,EACT,aAAa,EAAE,UAAU,GACD,KAAI;AAC5B,IAAA,MAAM,aAAa,GAAG,UAAU,CAAC,iBAAiB,CAAC;AACnD,IAAA,MAAM,UAAU,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,uBAAuB,EAAE,CAAC;AACjI,IAAA,IAAI,CAAC,aAAa;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC;;IAE7G,MAAM,WAAW,GAAG;UAChB,CAAA,EAAG,OAAO,CAAA,6BAAA;UACV,iFAAiF;IAErF,OAAOA,GAAA,CAAC,cAAc,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAA,aAAA,EAAe,UAAU,EAAA,CAAI;AAC1I;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
4
|
+
|
|
5
|
+
/** Shared by the section and its skeleton, so the placeholder holds the columns the loaded form lands in. */
|
|
6
|
+
const styles = cx.sortCx({
|
|
7
|
+
root: 'flex flex-col gap-5 lg:flex-row lg:gap-8',
|
|
8
|
+
labelColumn: 'flex flex-col lg:w-70 lg:shrink-0',
|
|
9
|
+
fieldColumn: 'flex w-full max-w-128 min-w-0 flex-col gap-5',
|
|
10
|
+
row: 'flex flex-col gap-5 sm:flex-row sm:*:min-w-0 sm:*:flex-1',
|
|
11
|
+
stack: 'flex w-full flex-col gap-6',
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
exports.styles = styles;
|
|
15
|
+
//# sourceMappingURL=FormSection.styles.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormSection.styles.cjs","sources":["../../../../src/components/forms/FormSection/FormSection.styles.ts"],"sourcesContent":[null],"names":["sortCx"],"mappings":";;;;AAEA;AACO,MAAM,MAAM,GAAGA,SAAM,CAAC;AAC3B,IAAA,IAAI,EAAE,0CAA0C;AAChD,IAAA,WAAW,EAAE,mCAAmC;AAChD,IAAA,WAAW,EAAE,8CAA8C;AAC3D,IAAA,GAAG,EAAE,0DAA0D;AAC/D,IAAA,KAAK,EAAE,4BAA4B;AACpC,CAAA;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Shared by the section and its skeleton, so the placeholder holds the columns the loaded form lands in. */
|
|
2
|
+
export declare const styles: {
|
|
3
|
+
root: string;
|
|
4
|
+
labelColumn: string;
|
|
5
|
+
fieldColumn: string;
|
|
6
|
+
row: string;
|
|
7
|
+
stack: string;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=FormSection.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormSection.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/FormSection/FormSection.styles.ts"],"names":[],"mappings":"AAEA,6GAA6G;AAC7G,eAAO,MAAM,MAAM;;;;;;CAMjB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { sortCx } from '@flipdish/ui-library/utilities/cx';
|
|
2
|
+
|
|
3
|
+
/** Shared by the section and its skeleton, so the placeholder holds the columns the loaded form lands in. */
|
|
4
|
+
const styles = sortCx({
|
|
5
|
+
root: 'flex flex-col gap-5 lg:flex-row lg:gap-8',
|
|
6
|
+
labelColumn: 'flex flex-col lg:w-70 lg:shrink-0',
|
|
7
|
+
fieldColumn: 'flex w-full max-w-128 min-w-0 flex-col gap-5',
|
|
8
|
+
row: 'flex flex-col gap-5 sm:flex-row sm:*:min-w-0 sm:*:flex-1',
|
|
9
|
+
stack: 'flex w-full flex-col gap-6',
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export { styles };
|
|
13
|
+
//# sourceMappingURL=FormSection.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormSection.styles.js","sources":["../../../../src/components/forms/FormSection/FormSection.styles.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;AACO,MAAM,MAAM,GAAG,MAAM,CAAC;AAC3B,IAAA,IAAI,EAAE,0CAA0C;AAChD,IAAA,WAAW,EAAE,mCAAmC;AAChD,IAAA,WAAW,EAAE,8CAA8C;AAC3D,IAAA,GAAG,EAAE,0DAA0D;AAC/D,IAAA,KAAK,EAAE,4BAA4B;AACpC,CAAA;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var Divider = require('@flipdish/ui-library/components/atoms/Divider');
|
|
5
|
+
var Skeleton = require('@flipdish/ui-library/components/atoms/Skeleton');
|
|
6
|
+
var SectionHeader = require('@flipdish/ui-library/components/molecules/SectionHeader');
|
|
7
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
8
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
9
|
+
var React = require('react');
|
|
10
|
+
var FormSection_styles = require('./FormSection.styles.cjs');
|
|
11
|
+
|
|
12
|
+
/** Upper bound on placeholder sections and fields, guarding against a malformed count. */
|
|
13
|
+
const MAX_SKELETON_COUNT = 12;
|
|
14
|
+
const toCount = (count) => (Number.isFinite(count) ? Math.min(Math.max(Math.trunc(count), 0), MAX_SKELETON_COUNT) : 0);
|
|
15
|
+
/** Puts two short fields on one line, such as a city and its postcode. */
|
|
16
|
+
const FormSectionRow = ({ children, className }) => jsxRuntime.jsx("div", { className: cx.cx(FormSection_styles.styles.row, className), children: children });
|
|
17
|
+
/** The placeholder a form shows while its values load, in the same two columns as its sections, so nothing shifts when they arrive. */
|
|
18
|
+
const FormSectionSkeleton = ({ label, sectionCount = 2, fieldCount = 3, 'data-testid': dataTestId }) => {
|
|
19
|
+
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'form-section-skeleton', rootName: 'form-section-skeleton' });
|
|
20
|
+
const sections = Array.from({ length: toCount(sectionCount) }, (_, index) => index);
|
|
21
|
+
const fields = Array.from({ length: toCount(fieldCount) }, (_, index) => index);
|
|
22
|
+
// Filled in after it mounts, and kept outside the busy region: a status region that arrives already filled is not
|
|
23
|
+
// reliably announced, and a screen reader may hold back what changes inside a busy one.
|
|
24
|
+
const [announcement, setAnnouncement] = React.useState('');
|
|
25
|
+
React.useEffect(() => setAnnouncement(label), [label]);
|
|
26
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("output", { className: "sr-only", children: announcement }), jsxRuntime.jsx("div", { "aria-busy": "true", "data-testid": rootTestId, className: FormSection_styles.styles.stack, children: sections.map((section) => (jsxRuntime.jsxs(React.Fragment, { children: [section > 0 && jsxRuntime.jsx(Divider.Divider, {}), jsxRuntime.jsxs("div", { className: FormSection_styles.styles.root, children: [jsxRuntime.jsxs("div", { className: cx.cx(FormSection_styles.styles.labelColumn, 'gap-2'), children: [jsxRuntime.jsx(Skeleton.Skeleton, { width: "40%", height: 20 }), jsxRuntime.jsx(Skeleton.SkeletonText, { lines: 2 })] }), jsxRuntime.jsx("div", { className: FormSection_styles.styles.fieldColumn, children: fields.map((field) => (jsxRuntime.jsx(Skeleton.Skeleton, { height: 44 }, field))) })] })] }, section))) })] }));
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* One titled section of a form: its name and description in a column on the left, its fields on the right, stacked
|
|
30
|
+
* below `lg`. Use one per group of related fields, with a `Divider` between sections.
|
|
31
|
+
*
|
|
32
|
+
* @summary titled form section with a label column and a field column
|
|
33
|
+
*/
|
|
34
|
+
const FormSection = ({ title, description, children, className, 'data-testid': dataTestId }) => {
|
|
35
|
+
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'form-section', rootName: 'form-section' });
|
|
36
|
+
const headingId = React.useId();
|
|
37
|
+
return (jsxRuntime.jsxs("section", { "aria-labelledby": headingId, "data-testid": rootTestId, className: cx.cx(FormSection_styles.styles.root, className), children: [jsxRuntime.jsx(testIdUtils.TestIdProvider, { value: rootTestId, children: jsxRuntime.jsxs("div", { className: cx.cx(FormSection_styles.styles.labelColumn, 'gap-1'), children: [jsxRuntime.jsx(SectionHeader.SectionHeader.Heading, { id: headingId, children: title }), description && jsxRuntime.jsx(SectionHeader.SectionHeader.Subheading, { children: description })] }) }), jsxRuntime.jsx("div", { "data-testid": testIdUtils.joinTestId(rootTestId, 'fields'), className: FormSection_styles.styles.fieldColumn, children: children })] }));
|
|
38
|
+
};
|
|
39
|
+
FormSection.Row = FormSectionRow;
|
|
40
|
+
FormSection.Skeleton = FormSectionSkeleton;
|
|
41
|
+
|
|
42
|
+
exports.FormSection = FormSection;
|
|
43
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/forms/FormSection/index.tsx"],"sourcesContent":[null],"names":["_jsx","cx","styles","useResolvedTestId","useState","useEffect","_jsxs","_Fragment","Fragment","Divider","Skeleton","SkeletonText","useId","TestIdProvider","SectionHeader","joinTestId"],"mappings":";;;;;;;;;;;AAUA;AACA,MAAM,kBAAkB,GAAG,EAAE;AAE7B,MAAM,OAAO,GAAG,CAAC,KAAa,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC;AAsB9H;AACA,MAAM,cAAc,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAuB,KAAKA,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAEC,KAAE,CAACC,yBAAM,CAAC,GAAG,EAAE,SAAS,CAAC,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAO;AAapI;AACA,MAAM,mBAAmB,GAAG,CAAC,EAAE,KAAK,EAAE,YAAY,GAAG,CAAC,EAAE,UAAU,GAAG,CAAC,EAAE,aAAa,EAAE,UAAU,EAA4B,KAAI;AAC/H,IAAA,MAAM,UAAU,GAAGC,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,uBAAuB,EAAE,CAAC;IACjI,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,KAAK,CAAC;IACnF,MAAM,MAAM,GAAG,KAAK,CAAC,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L,CAAA,EAAA,CACE;AAEd;AAEA,WAAW,CAAC,GAAG,GAAG,cAAc;AAChC,WAAW,CAAC,QAAQ,GAAG,mBAAmB;;"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface FormSectionProps {
|
|
3
|
+
/** The section's name, rendered as its heading in the label column. */
|
|
4
|
+
title: string;
|
|
5
|
+
/** One line on what the section holds, beneath the title. */
|
|
6
|
+
description?: ReactNode;
|
|
7
|
+
/** The section's fields, stacked in the field column. */
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/** Extra classes merged onto the section element. */
|
|
10
|
+
className?: string;
|
|
11
|
+
/** Overrides the root `data-testid` (defaults to `fd-form-section`); the heading and description derive theirs from it. */
|
|
12
|
+
'data-testid'?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface FormSectionRowProps {
|
|
15
|
+
/** Two short fields, side by side from `sm` and stacked below it. */
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
/** Extra classes merged onto the row element. */
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface FormSectionSkeletonProps {
|
|
21
|
+
/** What is loading, announced to screen readers, such as "Loading general settings". */
|
|
22
|
+
label: string;
|
|
23
|
+
/** How many placeholder sections to show, with a divider between each. */
|
|
24
|
+
sectionCount?: number;
|
|
25
|
+
/** How many placeholder fields each section shows. */
|
|
26
|
+
fieldCount?: number;
|
|
27
|
+
/** Overrides the root `data-testid` (defaults to `fd-form-section-skeleton`). */
|
|
28
|
+
'data-testid'?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* One titled section of a form: its name and description in a column on the left, its fields on the right, stacked
|
|
32
|
+
* below `lg`. Use one per group of related fields, with a `Divider` between sections.
|
|
33
|
+
*
|
|
34
|
+
* @summary titled form section with a label column and a field column
|
|
35
|
+
*/
|
|
36
|
+
export declare const FormSection: {
|
|
37
|
+
({ title, description, children, className, "data-testid": dataTestId }: FormSectionProps): import("react").JSX.Element;
|
|
38
|
+
Row: ({ children, className }: FormSectionRowProps) => import("react").JSX.Element;
|
|
39
|
+
Skeleton: ({ label, sectionCount, fieldCount, "data-testid": dataTestId }: FormSectionSkeletonProps) => import("react").JSX.Element;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/FormSection/index.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAY,KAAK,SAAS,EAA8B,MAAM,OAAO,CAAC;AAQ7E,MAAM,WAAW,gBAAgB;IAC/B,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,yDAAyD;IACzD,QAAQ,EAAE,SAAS,CAAC;IACpB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2HAA2H;IAC3H,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,qEAAqE;IACrE,QAAQ,EAAE,SAAS,CAAC;IACpB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD,MAAM,WAAW,wBAAwB;IACvC,wFAAwF;IACxF,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAqCD;;;;;GAKG;AACH,eAAO,MAAM,WAAW;6EAA4E,gBAAgB;mCAtDnE,mBAAmB;+EAciC,wBAAwB;CA0D5H,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { Divider } from '@flipdish/ui-library/components/atoms/Divider';
|
|
3
|
+
import { Skeleton, SkeletonText } from '@flipdish/ui-library/components/atoms/Skeleton';
|
|
4
|
+
import { SectionHeader } from '@flipdish/ui-library/components/molecules/SectionHeader';
|
|
5
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
6
|
+
import { useResolvedTestId, TestIdProvider, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
7
|
+
import { useId, useState, useEffect, Fragment as Fragment$1 } from 'react';
|
|
8
|
+
import { styles } from './FormSection.styles.js';
|
|
9
|
+
|
|
10
|
+
/** Upper bound on placeholder sections and fields, guarding against a malformed count. */
|
|
11
|
+
const MAX_SKELETON_COUNT = 12;
|
|
12
|
+
const toCount = (count) => (Number.isFinite(count) ? Math.min(Math.max(Math.trunc(count), 0), MAX_SKELETON_COUNT) : 0);
|
|
13
|
+
/** Puts two short fields on one line, such as a city and its postcode. */
|
|
14
|
+
const FormSectionRow = ({ children, className }) => jsx("div", { className: cx(styles.row, className), children: children });
|
|
15
|
+
/** The placeholder a form shows while its values load, in the same two columns as its sections, so nothing shifts when they arrive. */
|
|
16
|
+
const FormSectionSkeleton = ({ label, sectionCount = 2, fieldCount = 3, 'data-testid': dataTestId }) => {
|
|
17
|
+
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'form-section-skeleton', rootName: 'form-section-skeleton' });
|
|
18
|
+
const sections = Array.from({ length: toCount(sectionCount) }, (_, index) => index);
|
|
19
|
+
const fields = Array.from({ length: toCount(fieldCount) }, (_, index) => index);
|
|
20
|
+
// Filled in after it mounts, and kept outside the busy region: a status region that arrives already filled is not
|
|
21
|
+
// reliably announced, and a screen reader may hold back what changes inside a busy one.
|
|
22
|
+
const [announcement, setAnnouncement] = useState('');
|
|
23
|
+
useEffect(() => setAnnouncement(label), [label]);
|
|
24
|
+
return (jsxs(Fragment, { children: [jsx("output", { className: "sr-only", children: announcement }), jsx("div", { "aria-busy": "true", "data-testid": rootTestId, className: styles.stack, children: sections.map((section) => (jsxs(Fragment$1, { children: [section > 0 && jsx(Divider, {}), jsxs("div", { className: styles.root, children: [jsxs("div", { className: cx(styles.labelColumn, 'gap-2'), children: [jsx(Skeleton, { width: "40%", height: 20 }), jsx(SkeletonText, { lines: 2 })] }), jsx("div", { className: styles.fieldColumn, children: fields.map((field) => (jsx(Skeleton, { height: 44 }, field))) })] })] }, section))) })] }));
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* One titled section of a form: its name and description in a column on the left, its fields on the right, stacked
|
|
28
|
+
* below `lg`. Use one per group of related fields, with a `Divider` between sections.
|
|
29
|
+
*
|
|
30
|
+
* @summary titled form section with a label column and a field column
|
|
31
|
+
*/
|
|
32
|
+
const FormSection = ({ title, description, children, className, 'data-testid': dataTestId }) => {
|
|
33
|
+
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'form-section', rootName: 'form-section' });
|
|
34
|
+
const headingId = useId();
|
|
35
|
+
return (jsxs("section", { "aria-labelledby": headingId, "data-testid": rootTestId, className: cx(styles.root, className), children: [jsx(TestIdProvider, { value: rootTestId, children: jsxs("div", { className: cx(styles.labelColumn, 'gap-1'), children: [jsx(SectionHeader.Heading, { id: headingId, children: title }), description && jsx(SectionHeader.Subheading, { children: description })] }) }), jsx("div", { "data-testid": joinTestId(rootTestId, 'fields'), className: styles.fieldColumn, children: children })] }));
|
|
36
|
+
};
|
|
37
|
+
FormSection.Row = FormSectionRow;
|
|
38
|
+
FormSection.Skeleton = FormSectionSkeleton;
|
|
39
|
+
|
|
40
|
+
export { FormSection };
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/forms/FormSection/index.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","_Fragment","Fragment"],"mappings":";;;;;;;;;AAUA;AACA,MAAM,kBAAkB,GAAG,EAAE;AAE7B,MAAM,OAAO,GAAG,CAAC,KAAa,MAAM,MAAM,CAAC,QAAQ,CAAC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E,CAAC;AAC/G,IAAA,MAAM,SAAS,GAAG,KAAK,EAAE;AAEzB,IAAA,QACEC,IAAA,CAAA,SAAA,EAAA,EAAA,iBAAA,EAA0B,SAAS,EAAA,aAAA,EAAe,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,CAEjGD,GAAA,CAAC,cAAc,EAAA,EAAC,KAAK,EAAE,UAAU,EAAA,QAAA,EAC/BC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,EAAA,QAAA,EAAA,CAC7CD,IAAC,aAAa,CAAC,OAAO,EAAA,EAAC,EAAE,EAAE,SAAS,EAAA,QAAA,EAAG,KAAK,GAAyB,EACpE,WAAW,IAAIA,GAAA,CAAC,aAAa,CAAC,UAAU,EAAA,EAAA,QAAA,EAAE,WAAW,GAA4B,CAAA,EAAA,CAC9E,EAAA,CACS,EACjBA,GAAA,CAAA,KAAA,EAAA,EAAA,aAAA,EAAkB,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,WAAW,EAAA,QAAA,EAC9E,QAAQ,EAAA,CACL,CAAA,EAAA,CACE;AAEd;AAEA,WAAW,CAAC,GAAG,GAAG,cAAc;AAChC,WAAW,CAAC,QAAQ,GAAG,mBAAmB;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var Modals = require('@flipdish/ui-library/components/molecules/Modals');
|
|
5
|
+
var reactHookForm = require('react-hook-form');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Asks before a form's unsaved edits are lost to navigation, reading the dirty flag from the form itself and standing
|
|
9
|
+
* down while a save is sending them. Render one inside each `Form` that waits on Save.
|
|
10
|
+
*
|
|
11
|
+
* @summary unsaved-changes modal driven by its form's own state
|
|
12
|
+
*/
|
|
13
|
+
const FormUnsavedChangesModal = ({ isDisabled = false, 'data-testid': dataTestId }) => {
|
|
14
|
+
const form = reactHookForm.useFormContext();
|
|
15
|
+
if (!form)
|
|
16
|
+
throw new Error("FormUnsavedChangesModal needs Form above it: it guards that form's unsaved edits.");
|
|
17
|
+
const { isDirty, isSubmitting } = reactHookForm.useFormState({ control: form.control });
|
|
18
|
+
// Edits a save is sending can no longer be discarded by leaving, so only a draft at rest is guarded.
|
|
19
|
+
const hasUnsavedChanges = isDirty && !isSubmitting && !isDisabled;
|
|
20
|
+
return jsxRuntime.jsx(Modals.UnsavedChangesModal, { hasUnsavedChanges: hasUnsavedChanges, "data-testid": dataTestId });
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.FormUnsavedChangesModal = FormUnsavedChangesModal;
|
|
24
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/forms/FormUnsavedChangesModal/index.tsx"],"sourcesContent":[null],"names":["useFormContext","useFormState","_jsx","UnsavedChangesModal"],"mappings":";;;;;;AAYA;;;;;AAKG;AACI,MAAM,uBAAuB,GAAG,CAAC,EAAE,UAAU,GAAG,KAAK,EAAE,aAAa,EAAE,UAAU,EAAgC,KAAI;AACzH,IAAA,MAAM,IAAI,GAAGA,4BAAc,EAAE;AAC7B,IAAA,IAAI,CAAC,IAAI;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,mFAAmF,CAAC;AAC/G,IAAA,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAGC,0BAAY,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;;IAEzE,MAAM,iBAAiB,GAAG,OAAO,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU;IAEjE,OAAOC,cAAA,CAACC,0BAAmB,EAAA,EAAC,iBAAiB,EAAE,iBAAiB,EAAA,aAAA,EAAe,UAAU,EAAA,CAAI;AAC/F;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface FormUnsavedChangesModalProps {
|
|
2
|
+
/** Switches the guard off while the edits are going anyway, such as while the record the form edits is being removed. */
|
|
3
|
+
isDisabled?: boolean;
|
|
4
|
+
/** Overrides the root `data-testid` (defaults to `fd-unsaved-changes-modal`); the buttons derive theirs from it. */
|
|
5
|
+
'data-testid'?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Asks before a form's unsaved edits are lost to navigation, reading the dirty flag from the form itself and standing
|
|
9
|
+
* down while a save is sending them. Render one inside each `Form` that waits on Save.
|
|
10
|
+
*
|
|
11
|
+
* @summary unsaved-changes modal driven by its form's own state
|
|
12
|
+
*/
|
|
13
|
+
export declare const FormUnsavedChangesModal: ({ isDisabled, "data-testid": dataTestId }: FormUnsavedChangesModalProps) => import("react").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/FormUnsavedChangesModal/index.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,4BAA4B;IAC3C,yHAAyH;IACzH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oHAAoH;IACpH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,2CAAmD,4BAA4B,gCAQtH,CAAC"}
|