@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
package/README.md
CHANGED
|
@@ -73,6 +73,7 @@ A handful of components are backed by larger third-party libraries declared as *
|
|
|
73
73
|
| `VerificationCodeInput` | `input-otp` |
|
|
74
74
|
| `CommandMenu` | `react-hotkeys-hook` |
|
|
75
75
|
| `FileUpload`, `SidebarNavigation` | `motion` |
|
|
76
|
+
| `forms/*` (except `FormSection`) | `react-hook-form`; `forms/validation` needs `zod` and `@hookform/resolvers` as well |
|
|
76
77
|
|
|
77
78
|
## Tailwind setup
|
|
78
79
|
|
|
@@ -81,11 +82,11 @@ Import the library's shared runtime from your CSS entry **in this exact layer or
|
|
|
81
82
|
```css
|
|
82
83
|
@layer theme, base, components, utilities;
|
|
83
84
|
|
|
84
|
-
@import
|
|
85
|
-
@import
|
|
86
|
-
@import
|
|
87
|
-
@import
|
|
88
|
-
@import
|
|
85
|
+
@import 'tailwindcss/theme.css' layer(theme);
|
|
86
|
+
@import '@flipdish/ui-tokens/css' layer(theme);
|
|
87
|
+
@import 'tailwindcss/preflight.css' layer(base);
|
|
88
|
+
@import '@flipdish/ui-library/styles';
|
|
89
|
+
@import 'tailwindcss/utilities.css' layer(utilities);
|
|
89
90
|
```
|
|
90
91
|
|
|
91
92
|
## React Native
|
|
@@ -110,7 +111,7 @@ Import paths are identical across platforms — Metro picks the native build via
|
|
|
110
111
|
|
|
111
112
|
```tsx
|
|
112
113
|
// Resolves to the web build under Vite/webpack, the native build under Metro.
|
|
113
|
-
import { Avatar } from
|
|
114
|
+
import { Avatar } from '@flipdish/ui-library/components/atoms/Avatar';
|
|
114
115
|
```
|
|
115
116
|
|
|
116
117
|
> `react-native >= 0.81` is load-bearing, not just a version floor. Every public subpath of
|
|
@@ -128,15 +129,15 @@ In your app's `global.css` — the file you import from your root component and
|
|
|
128
129
|
[`withNativewind`](https://www.nativewind.dev/v5/api/with-nativewind) at in `metro.config.js`:
|
|
129
130
|
|
|
130
131
|
```css
|
|
131
|
-
@import
|
|
132
|
-
@import
|
|
133
|
-
@import
|
|
132
|
+
@import 'tailwindcss/theme.css' layer(theme);
|
|
133
|
+
@import '@flipdish/ui-tokens/css' layer(theme);
|
|
134
|
+
@import 'tailwindcss/preflight.css' layer(base);
|
|
134
135
|
|
|
135
136
|
/* NativeWind's own theme variables — required by its Metro transformer. */
|
|
136
|
-
@import
|
|
137
|
+
@import 'nativewind/theme';
|
|
137
138
|
|
|
138
|
-
@import
|
|
139
|
-
@import
|
|
139
|
+
@import '@flipdish/ui-library/styles.native';
|
|
140
|
+
@import 'tailwindcss/utilities.css';
|
|
140
141
|
```
|
|
141
142
|
|
|
142
143
|
`styles.native` contributes exactly one thing: `@source "./native"`, which tells Tailwind to
|
|
@@ -199,8 +200,8 @@ Then add it to your PostCSS config:
|
|
|
199
200
|
|
|
200
201
|
```js
|
|
201
202
|
// postcss.config.mjs
|
|
202
|
-
import prefixSelector from
|
|
203
|
-
import { createScopedPrefixTransform } from
|
|
203
|
+
import prefixSelector from 'postcss-prefix-selector';
|
|
204
|
+
import { createScopedPrefixTransform } from '@flipdish/ui-library/utilities/cssScopeUtils';
|
|
204
205
|
|
|
205
206
|
// Your Portal microFrontendWindowName; must match <UIProvider scopeId="sale-service">.
|
|
206
207
|
const SCOPE = '[data-mfe-scope="sale-service"]';
|
|
@@ -228,8 +229,8 @@ Tailwind's output becomes plain `[data-mfe-scope="sale-service"] .px-4 { … }`,
|
|
|
228
229
|
| `matchRootElement` | `boolean` | `true` | Also emit a compound selector so the scope root itself matches class and attribute selectors; `[data-theme="dark"]` on the themed root needs it. |
|
|
229
230
|
|
|
230
231
|
```js
|
|
231
|
-
createScopedPrefixTransform(
|
|
232
|
-
shouldScope: (file) => !file || !file.includes(
|
|
232
|
+
createScopedPrefixTransform('[data-tailwind]', {
|
|
233
|
+
shouldScope: (file) => !file || !file.includes('node_modules'),
|
|
233
234
|
scopeBody: true,
|
|
234
235
|
});
|
|
235
236
|
```
|
|
@@ -22,12 +22,20 @@ CheckboxBase.displayName = 'CheckboxBase';
|
|
|
22
22
|
*/
|
|
23
23
|
const Checkbox = ({ label, hint, size = 'sm', className, 'data-testid': dataTestId, ...ariaCheckboxProps }) => {
|
|
24
24
|
const group = React.useContext(CheckboxGroupContext);
|
|
25
|
+
const groupState = React.useContext(reactAriaComponents.CheckboxGroupStateContext);
|
|
25
26
|
size = group?.size ?? size;
|
|
26
27
|
const fallbackTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'checkbox', rootName: 'checkbox' });
|
|
27
28
|
const { value } = ariaCheckboxProps;
|
|
29
|
+
// A box with no `value` leaves the group's state below, so what the group forbids is carried over by hand.
|
|
30
|
+
const isStandaloneInGroup = Boolean(group) && value === undefined;
|
|
31
|
+
// The group's restriction first, else the prop as given: an explicit `false` still overrides a `CheckboxContext`.
|
|
32
|
+
const isDisabled = (isStandaloneInGroup && groupState?.isDisabled) || ariaCheckboxProps.isDisabled;
|
|
33
|
+
const isReadOnly = (isStandaloneInGroup && groupState?.isReadOnly) || ariaCheckboxProps.isReadOnly;
|
|
28
34
|
const isGroupOption = !dataTestId && group && value !== undefined;
|
|
29
35
|
const checkboxTestId = isGroupOption ? testIdUtils.joinTestId(group.testIdPrefix, `option-${testIdUtils.slugifyTestId(value)}`) : fallbackTestId;
|
|
30
|
-
const checkbox = (jsxRuntime.jsx(reactAriaComponents.Checkbox, { ...ariaCheckboxProps,
|
|
36
|
+
const checkbox = (jsxRuntime.jsx(reactAriaComponents.Checkbox, { ...ariaCheckboxProps,
|
|
37
|
+
// Each box resolves this by itself and would fall back to the browser's own check, whatever its group asked for (react-aria-components 1.19).
|
|
38
|
+
validationBehavior: ariaCheckboxProps.validationBehavior ?? group?.validationBehavior, isDisabled: isDisabled, isReadOnly: isReadOnly, "data-testid": checkboxTestId, className: (state) => cx.cx('relative flex items-start', state.isDisabled && 'cursor-not-allowed', selectionControl_styles.selectionControlSizes[size].root, typeof className === 'function' ? className(state) : className), children: ({ isSelected, isIndeterminate, isDisabled, isFocusVisible }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(CheckboxBase, { size: size, isSelected: isSelected, isIndeterminate: isIndeterminate, isDisabled: isDisabled, isFocusVisible: isFocusVisible, className: label || hint ? 'mt-0.5' : '' }), (label || hint) && (jsxRuntime.jsxs("div", { className: cx.cx('inline-flex flex-col', selectionControl_styles.selectionControlSizes[size].textWrapper), children: [label && jsxRuntime.jsx("p", { className: cx.cx('text-secondary select-none', selectionControl_styles.selectionControlSizes[size].label), children: label }), hint && (
|
|
31
39
|
// biome-ignore lint/a11y/noStaticElementInteractions: not independently interactive — only stops the click reaching outer React handlers, see below
|
|
32
40
|
// biome-ignore lint/a11y/useKeyWithClickEvents: same as above, no keyboard equivalent needed
|
|
33
41
|
jsxRuntime.jsx("span", { className: cx.cx('text-tertiary', selectionControl_styles.selectionControlSizes[size].hint), onClick: (event) => {
|
|
@@ -43,7 +51,7 @@ const Checkbox = ({ label, hint, size = 'sm', className, 'data-testid': dataTest
|
|
|
43
51
|
}, children: hint }))] }))] })) }));
|
|
44
52
|
// A box with no `value` is not one of the group's options: it keeps its own state, as it does on React Native,
|
|
45
53
|
// where react-aria would otherwise hand every box inside a group to that group.
|
|
46
|
-
if (
|
|
54
|
+
if (isStandaloneInGroup)
|
|
47
55
|
return jsxRuntime.jsx(reactAriaComponents.CheckboxGroupStateContext.Provider, { value: null, children: checkbox });
|
|
48
56
|
return checkbox;
|
|
49
57
|
};
|
|
@@ -51,7 +59,7 @@ Checkbox.displayName = 'Checkbox';
|
|
|
51
59
|
/** Wrapper around react-aria-components' `CheckboxGroup` that names a set of `Checkbox` children, holds their ticked values as a list, and shows one hint or error for the set. */
|
|
52
60
|
const CheckboxGroup = ({ children, label, hint, size = 'sm', className, 'data-testid': dataTestId, ...props }) => {
|
|
53
61
|
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'checkbox-group', rootName: 'checkbox-group' });
|
|
54
|
-
return (jsxRuntime.jsx(CheckboxGroupContext.Provider, { value: { size, testIdPrefix: rootTestId }, children: jsxRuntime.jsx(reactAriaComponents.CheckboxGroup, { ...props, "data-testid": rootTestId, className: cx.cx('flex flex-col gap-3', className), children: ({ isInvalid, isRequired }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [label && (jsxRuntime.jsx(Input.Label, { isRequired: isRequired, isInvalid: isInvalid, children: label })), children, hint && jsxRuntime.jsx(Input.HintText, { isInvalid: isInvalid, children: hint })] })) }) }));
|
|
62
|
+
return (jsxRuntime.jsx(CheckboxGroupContext.Provider, { value: { size, testIdPrefix: rootTestId, validationBehavior: props.validationBehavior }, children: jsxRuntime.jsx(reactAriaComponents.CheckboxGroup, { ...props, "data-testid": rootTestId, className: cx.cx('flex flex-col gap-3', className), children: ({ isInvalid, isRequired }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [label && (jsxRuntime.jsx(Input.Label, { isRequired: isRequired, isInvalid: isInvalid, children: label })), children, hint && jsxRuntime.jsx(Input.HintText, { isInvalid: isInvalid, children: hint })] })) }) }));
|
|
55
63
|
};
|
|
56
64
|
CheckboxGroup.displayName = 'CheckboxGroup';
|
|
57
65
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"sourcesContent":[null],"names":["createContext","_jsxs","cx","_jsx","useContext","useResolvedTestId","joinTestId","slugifyTestId","AriaCheckbox","selectionControlSizes","
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"sourcesContent":[null],"names":["createContext","_jsxs","cx","_jsx","useContext","CheckboxGroupStateContext","useResolvedTestId","joinTestId","slugifyTestId","AriaCheckbox","selectionControlSizes","_Fragment","AriaCheckboxGroup","Label","HintText"],"mappings":";;;;;;;;;;AAqBA,MAAM,oBAAoB,GAAGA,mBAAa,CAAkC,IAAI,CAAC;AAiBjF;MACa,YAAY,GAAG,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,GAAG,IAAI,EAAE,cAAc,GAAG,KAAK,EAAqB,KAAI;AAC7I,IAAA,QACEC,eAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAEC,KAAE,CACX,4IAA4I,EAC5I,IAAI,KAAK,IAAI,IAAI,mBAAmB,EACpC,CAAC,UAAU,IAAI,eAAe,KAAK,iCAAiC,EACpE,UAAU,IAAI,+BAA+B,EAC7C,UAAU,IAAI,EAAE,UAAU,IAAI,eAAe,CAAC,IAAI,aAAa,EAC/D,cAAc,IAAI,+CAA+C,EACjE,SAAS,CACV,EAAA,QAAA,EAAA,CAEDC,cAAA,CAAA,KAAA,EAAA,EAAA,aAAA,EACc,MAAM,EAClB,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,SAAS,EAAED,KAAE,CAC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AA,CAAC,oBAAoB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAAE,EAAA,QAAA,EACpHA,eAACS,iCAAiB,EAAA,EAAA,GAAK,KAAK,EAAA,aAAA,EAAe,UAAU,EAAE,SAAS,EAAEV,KAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,EAAA,QAAA,EACnG,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,MACzBD,eAAA,CAAAU,mBAAA,EAAA,EAAA,QAAA,EAAA,CACG,KAAK,KACJR,cAAA,CAACU,WAAK,EAAA,EAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAA,QAAA,EAChD,KAAK,EAAA,CACA,CACT,EACA,QAAQ,EAER,IAAI,IAAIV,cAAA,CAACW,cAAQ,EAAA,EAAC,SAAS,EAAE,SAAS,EAAA,QAAA,EAAG,IAAI,EAAA,CAAY,CAAA,EAAA,CACzD,CACJ,EAAA,CACiB,EAAA,CACU;AAEpC;AACA,aAAa,CAAC,WAAW,GAAG,eAAe;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAiB,KAAK,SAAS,EAAE,KAAK,GAAG,EAAc,MAAM,OAAO,CAAC;AAC5E,OAAO,EAGL,KAAK,kBAAkB,IAAI,sBAAsB,EACjD,KAAK,aAAa,IAAI,iBAAiB,EAExC,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAiB,KAAK,SAAS,EAAE,KAAK,GAAG,EAAc,MAAM,OAAO,CAAC;AAC5E,OAAO,EAGL,KAAK,kBAAkB,IAAI,sBAAsB,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IACnB,4HAA4H;IAC5H,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,mLAAmL;AACnL,eAAO,MAAM,aAAa;sFAA4F,kBAAkB;;CAqBvI,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { Label, HintText } from '@flipdish/ui-library/components/atoms/Input';
|
|
|
3
3
|
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
4
4
|
import { useResolvedTestId, joinTestId, slugifyTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
5
5
|
import { createContext, useContext } from 'react';
|
|
6
|
-
import { Checkbox as Checkbox$1,
|
|
6
|
+
import { CheckboxGroupStateContext, Checkbox as Checkbox$1, CheckboxGroup as CheckboxGroup$1 } from 'react-aria-components';
|
|
7
7
|
import { selectionControlSizes } from '../../__internal__/selectionControl/selectionControl.styles.js';
|
|
8
8
|
|
|
9
9
|
const CheckboxGroupContext = createContext(null);
|
|
@@ -20,12 +20,20 @@ CheckboxBase.displayName = 'CheckboxBase';
|
|
|
20
20
|
*/
|
|
21
21
|
const Checkbox = ({ label, hint, size = 'sm', className, 'data-testid': dataTestId, ...ariaCheckboxProps }) => {
|
|
22
22
|
const group = useContext(CheckboxGroupContext);
|
|
23
|
+
const groupState = useContext(CheckboxGroupStateContext);
|
|
23
24
|
size = group?.size ?? size;
|
|
24
25
|
const fallbackTestId = useResolvedTestId({ testId: dataTestId, segment: 'checkbox', rootName: 'checkbox' });
|
|
25
26
|
const { value } = ariaCheckboxProps;
|
|
27
|
+
// A box with no `value` leaves the group's state below, so what the group forbids is carried over by hand.
|
|
28
|
+
const isStandaloneInGroup = Boolean(group) && value === undefined;
|
|
29
|
+
// The group's restriction first, else the prop as given: an explicit `false` still overrides a `CheckboxContext`.
|
|
30
|
+
const isDisabled = (isStandaloneInGroup && groupState?.isDisabled) || ariaCheckboxProps.isDisabled;
|
|
31
|
+
const isReadOnly = (isStandaloneInGroup && groupState?.isReadOnly) || ariaCheckboxProps.isReadOnly;
|
|
26
32
|
const isGroupOption = !dataTestId && group && value !== undefined;
|
|
27
33
|
const checkboxTestId = isGroupOption ? joinTestId(group.testIdPrefix, `option-${slugifyTestId(value)}`) : fallbackTestId;
|
|
28
|
-
const checkbox = (jsx(Checkbox$1, { ...ariaCheckboxProps,
|
|
34
|
+
const checkbox = (jsx(Checkbox$1, { ...ariaCheckboxProps,
|
|
35
|
+
// Each box resolves this by itself and would fall back to the browser's own check, whatever its group asked for (react-aria-components 1.19).
|
|
36
|
+
validationBehavior: ariaCheckboxProps.validationBehavior ?? group?.validationBehavior, isDisabled: isDisabled, isReadOnly: isReadOnly, "data-testid": checkboxTestId, className: (state) => cx('relative flex items-start', state.isDisabled && 'cursor-not-allowed', selectionControlSizes[size].root, typeof className === 'function' ? className(state) : className), children: ({ isSelected, isIndeterminate, isDisabled, isFocusVisible }) => (jsxs(Fragment, { children: [jsx(CheckboxBase, { size: size, isSelected: isSelected, isIndeterminate: isIndeterminate, isDisabled: isDisabled, isFocusVisible: isFocusVisible, className: label || hint ? 'mt-0.5' : '' }), (label || hint) && (jsxs("div", { className: cx('inline-flex flex-col', selectionControlSizes[size].textWrapper), children: [label && jsx("p", { className: cx('text-secondary select-none', selectionControlSizes[size].label), children: label }), hint && (
|
|
29
37
|
// biome-ignore lint/a11y/noStaticElementInteractions: not independently interactive — only stops the click reaching outer React handlers, see below
|
|
30
38
|
// biome-ignore lint/a11y/useKeyWithClickEvents: same as above, no keyboard equivalent needed
|
|
31
39
|
jsx("span", { className: cx('text-tertiary', selectionControlSizes[size].hint), onClick: (event) => {
|
|
@@ -41,7 +49,7 @@ const Checkbox = ({ label, hint, size = 'sm', className, 'data-testid': dataTest
|
|
|
41
49
|
}, children: hint }))] }))] })) }));
|
|
42
50
|
// A box with no `value` is not one of the group's options: it keeps its own state, as it does on React Native,
|
|
43
51
|
// where react-aria would otherwise hand every box inside a group to that group.
|
|
44
|
-
if (
|
|
52
|
+
if (isStandaloneInGroup)
|
|
45
53
|
return jsx(CheckboxGroupStateContext.Provider, { value: null, children: checkbox });
|
|
46
54
|
return checkbox;
|
|
47
55
|
};
|
|
@@ -49,7 +57,7 @@ Checkbox.displayName = 'Checkbox';
|
|
|
49
57
|
/** Wrapper around react-aria-components' `CheckboxGroup` that names a set of `Checkbox` children, holds their ticked values as a list, and shows one hint or error for the set. */
|
|
50
58
|
const CheckboxGroup = ({ children, label, hint, size = 'sm', className, 'data-testid': dataTestId, ...props }) => {
|
|
51
59
|
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'checkbox-group', rootName: 'checkbox-group' });
|
|
52
|
-
return (jsx(CheckboxGroupContext.Provider, { value: { size, testIdPrefix: rootTestId }, children: jsx(CheckboxGroup$1, { ...props, "data-testid": rootTestId, className: cx('flex flex-col gap-3', className), children: ({ isInvalid, isRequired }) => (jsxs(Fragment, { children: [label && (jsx(Label, { isRequired: isRequired, isInvalid: isInvalid, children: label })), children, hint && jsx(HintText, { isInvalid: isInvalid, children: hint })] })) }) }));
|
|
60
|
+
return (jsx(CheckboxGroupContext.Provider, { value: { size, testIdPrefix: rootTestId, validationBehavior: props.validationBehavior }, children: jsx(CheckboxGroup$1, { ...props, "data-testid": rootTestId, className: cx('flex flex-col gap-3', className), children: ({ isInvalid, isRequired }) => (jsxs(Fragment, { children: [label && (jsx(Label, { isRequired: isRequired, isInvalid: isInvalid, children: label })), children, hint && jsx(HintText, { isInvalid: isInvalid, children: hint })] })) }) }));
|
|
53
61
|
};
|
|
54
62
|
CheckboxGroup.displayName = 'CheckboxGroup';
|
|
55
63
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx","AriaCheckbox","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx","AriaCheckbox","_Fragment","AriaCheckboxGroup"],"mappings":";;;;;;;;AAqBA,MAAM,o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ACzD,CACJ,EAAA,CACiB,EAAA,CACU;AAEpC;AACA,aAAa,CAAC,WAAW,GAAG,eAAe;;"}
|
|
@@ -19,7 +19,7 @@ const styles = cx.sortCx({
|
|
|
19
19
|
*
|
|
20
20
|
* @summary draggable range input for selecting a numeric value
|
|
21
21
|
*/
|
|
22
|
-
const Slider = ({ labelPosition = 'default', minValue = 0, maxValue = 100, label, hint, labelFormatter, formatOptions, className, 'aria-describedby': ariaDescribedBy, 'data-testid': dataTestId, ...rest }) => {
|
|
22
|
+
const Slider = ({ labelPosition = 'default', minValue = 0, maxValue = 100, label, hint, labelFormatter, isInvalid, formatOptions, className, 'aria-describedby': ariaDescribedBy, 'data-testid': dataTestId, ...rest }) => {
|
|
23
23
|
// Format thumb value as percentage by default.
|
|
24
24
|
const defaultFormatOptions = {
|
|
25
25
|
style: 'percent',
|
|
@@ -38,7 +38,7 @@ const Slider = ({ labelPosition = 'default', minValue = 0, maxValue = 100, label
|
|
|
38
38
|
} }), values.map((_, index) => {
|
|
39
39
|
return (jsxRuntime.jsx(reactAriaComponents.SliderThumb
|
|
40
40
|
// biome-ignore lint/suspicious/noArrayIndexKey: static, ordered list of thumbs
|
|
41
|
-
, { index: index, "data-testid": testIdUtils.joinTestId(sliderTestId, `thumb-${index}`), className: ({ isFocusVisible, isDragging }) => cx.cx('top-1/2 box-border size-6 cursor-grab rounded-full bg-slider-handle-bg shadow-md ring-2 ring-slider-handle-border ring-inset', isFocusVisible && 'outline-2 outline-offset-2 outline-focus-ring', isDragging && 'cursor-grabbing'), children: jsxRuntime.jsx(reactAriaComponents.SliderOutput, { className: cx.cx('whitespace-nowrap', styles[labelPosition]), "data-testid": testIdUtils.joinTestId(sliderTestId, `output-${index}`), children: labelFormatter ? labelFormatter(getThumbValue(index)) : getFormattedValue(getThumbValue(index) / 100) }) }, index));
|
|
41
|
+
, { index: index, isInvalid: isInvalid, "data-testid": testIdUtils.joinTestId(sliderTestId, `thumb-${index}`), className: ({ isFocusVisible, isDragging }) => cx.cx('top-1/2 box-border size-6 cursor-grab rounded-full bg-slider-handle-bg shadow-md ring-2 ring-slider-handle-border ring-inset', isFocusVisible && 'outline-2 outline-offset-2 outline-focus-ring', isDragging && 'cursor-grabbing'), children: jsxRuntime.jsx(reactAriaComponents.SliderOutput, { className: cx.cx('whitespace-nowrap', styles[labelPosition]), "data-testid": testIdUtils.joinTestId(sliderTestId, `output-${index}`), children: labelFormatter ? labelFormatter(getThumbValue(index)) : getFormattedValue(getThumbValue(index) / 100) }) }, index));
|
|
42
42
|
})] }));
|
|
43
43
|
} }), hint ? jsxRuntime.jsx(Input.HintText, { id: hintId, children: hint }) : null] }));
|
|
44
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/atoms/Slider/index.tsx"],"sourcesContent":[null],"names":["sortCx","useResolvedTestId","useId","joinIds","_jsxs","AriaSlider","cx","_jsx","Label","AriaSliderTrack","joinTestId","_Fragment","AriaSliderThumb","AriaSliderOutput","HintText"],"mappings":";;;;;;;;;;AAeA,MAAM,MAAM,GAAGA,SAAM,CAAC;AACpB,IAAA,OAAO,EAAE,QAAQ;AACjB,IAAA,MAAM,EAAE,4FAA4F;AACpG,IAAA,cAAc,EACZ,wKAAwK;AAC3K,CAAA,CAAC;
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/atoms/Slider/index.tsx"],"sourcesContent":[null],"names":["sortCx","useResolvedTestId","useId","joinIds","_jsxs","AriaSlider","cx","_jsx","Label","AriaSliderTrack","joinTestId","_Fragment","AriaSliderThumb","AriaSliderOutput","HintText"],"mappings":";;;;;;;;;;AAeA,MAAM,MAAM,GAAGA,SAAM,CAAC;AACpB,IAAA,OAAO,EAAE,QAAQ;AACjB,IAAA,MAAM,EAAE,4FAA4F;AACpG,IAAA,cAAc,EACZ,wKAAwK;AAC3K,CAAA,CAAC;AAiBF;;;;;AAKG;AACI,MAAM,MAAM,GAAG,CAAC,EACrB,aAAa,GA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AC,aAAa,CAAC,KAAK,CAAC,CAAC,GAAG,iBAAiB,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,EAAA,CACrF,IAjBd,KAAK,CAkBM;4BAEtB,CAAC,CAAC,CAAA,EAAA,CACD;gBAEP,CAAC,EAAA,CACe,EACjB,IAAI,GAAGH,cAAA,CAACO,cAAQ,EAAA,EAAC,EAAE,EAAE,MAAM,EAAA,QAAA,EAAG,IAAI,EAAA,CAAY,GAAG,IAAI,CAAA,EAAA,CAC3C;AAEjB;;"}
|
|
@@ -13,6 +13,8 @@ export interface SliderProps extends AriaSliderProps {
|
|
|
13
13
|
hint?: string;
|
|
14
14
|
/** Formats each thumb's value label, replacing the default whole-number percentage. */
|
|
15
15
|
labelFormatter?: (value: number) => string;
|
|
16
|
+
/** Marks each thumb `aria-invalid`, for a value a form has rejected; say why in `hint` or with `aria-describedby`. */
|
|
17
|
+
isInvalid?: boolean;
|
|
16
18
|
/** Overrides the `data-testid` (defaults to `fd-slider`); the track, thumb(s), and output derive their ids from it. */
|
|
17
19
|
'data-testid'?: string;
|
|
18
20
|
}
|
|
@@ -22,6 +24,6 @@ export interface SliderProps extends AriaSliderProps {
|
|
|
22
24
|
*
|
|
23
25
|
* @summary draggable range input for selecting a numeric value
|
|
24
26
|
*/
|
|
25
|
-
export declare const Slider: ({ labelPosition, minValue, maxValue, label, hint, labelFormatter, formatOptions, className, "aria-describedby": ariaDescribedBy, "data-testid": dataTestId, ...rest }: SliderProps) => import("react").JSX.Element;
|
|
27
|
+
export declare const Slider: ({ labelPosition, minValue, maxValue, label, hint, labelFormatter, isInvalid, formatOptions, className, "aria-describedby": ariaDescribedBy, "data-testid": dataTestId, ...rest }: SliderProps) => import("react").JSX.Element;
|
|
26
28
|
export {};
|
|
27
29
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Slider/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAS5E,QAAA,MAAM,MAAM;;;;CAKV,CAAC;AAEH,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD,qIAAqI;IACrI,aAAa,CAAC,EAAE,MAAM,OAAO,MAAM,CAAC;IACpC,iHAAiH;IACjH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yIAAyI;IACzI,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uFAAuF;IACvF,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3C,uHAAuH;IACvH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Slider/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAS5E,QAAA,MAAM,MAAM;;;;CAKV,CAAC;AAEH,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD,qIAAqI;IACrI,aAAa,CAAC,EAAE,MAAM,OAAO,MAAM,CAAC;IACpC,iHAAiH;IACjH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yIAAyI;IACzI,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uFAAuF;IACvF,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3C,sHAAsH;IACtH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uHAAuH;IACvH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAI,kLAapB,WAAW,gCAwEb,CAAC"}
|
|
@@ -17,7 +17,7 @@ const styles = sortCx({
|
|
|
17
17
|
*
|
|
18
18
|
* @summary draggable range input for selecting a numeric value
|
|
19
19
|
*/
|
|
20
|
-
const Slider = ({ labelPosition = 'default', minValue = 0, maxValue = 100, label, hint, labelFormatter, formatOptions, className, 'aria-describedby': ariaDescribedBy, 'data-testid': dataTestId, ...rest }) => {
|
|
20
|
+
const Slider = ({ labelPosition = 'default', minValue = 0, maxValue = 100, label, hint, labelFormatter, isInvalid, formatOptions, className, 'aria-describedby': ariaDescribedBy, 'data-testid': dataTestId, ...rest }) => {
|
|
21
21
|
// Format thumb value as percentage by default.
|
|
22
22
|
const defaultFormatOptions = {
|
|
23
23
|
style: 'percent',
|
|
@@ -36,7 +36,7 @@ const Slider = ({ labelPosition = 'default', minValue = 0, maxValue = 100, label
|
|
|
36
36
|
} }), values.map((_, index) => {
|
|
37
37
|
return (jsx(SliderThumb
|
|
38
38
|
// biome-ignore lint/suspicious/noArrayIndexKey: static, ordered list of thumbs
|
|
39
|
-
, { index: index, "data-testid": joinTestId(sliderTestId, `thumb-${index}`), className: ({ isFocusVisible, isDragging }) => cx('top-1/2 box-border size-6 cursor-grab rounded-full bg-slider-handle-bg shadow-md ring-2 ring-slider-handle-border ring-inset', isFocusVisible && 'outline-2 outline-offset-2 outline-focus-ring', isDragging && 'cursor-grabbing'), children: jsx(SliderOutput, { className: cx('whitespace-nowrap', styles[labelPosition]), "data-testid": joinTestId(sliderTestId, `output-${index}`), children: labelFormatter ? labelFormatter(getThumbValue(index)) : getFormattedValue(getThumbValue(index) / 100) }) }, index));
|
|
39
|
+
, { index: index, isInvalid: isInvalid, "data-testid": joinTestId(sliderTestId, `thumb-${index}`), className: ({ isFocusVisible, isDragging }) => cx('top-1/2 box-border size-6 cursor-grab rounded-full bg-slider-handle-bg shadow-md ring-2 ring-slider-handle-border ring-inset', isFocusVisible && 'outline-2 outline-offset-2 outline-focus-ring', isDragging && 'cursor-grabbing'), children: jsx(SliderOutput, { className: cx('whitespace-nowrap', styles[labelPosition]), "data-testid": joinTestId(sliderTestId, `output-${index}`), children: labelFormatter ? labelFormatter(getThumbValue(index)) : getFormattedValue(getThumbValue(index) / 100) }) }, index));
|
|
40
40
|
})] }));
|
|
41
41
|
} }), hint ? jsx(HintText, { id: hintId, children: hint }) : null] }));
|
|
42
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/Slider/index.tsx"],"sourcesContent":[null],"names":["_jsxs","AriaSlider","_jsx","AriaSliderTrack","_Fragment","AriaSliderThumb","AriaSliderOutput"],"mappings":";;;;;;;;AAeA,MAAM,MAAM,GAAG,MAAM,CAAC;AACpB,IAAA,OAAO,EAAE,QAAQ;AACjB,IAAA,MAAM,EAAE,4FAA4F;AACpG,IAAA,cAAc,EACZ,wKAAwK;AAC3K,CAAA,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/Slider/index.tsx"],"sourcesContent":[null],"names":["_jsxs","AriaSlider","_jsx","AriaSliderTrack","_Fragment","AriaSliderThumb","AriaSliderOutput"],"mappings":";;;;;;;;AAeA,MAAM,MAAM,GAAG,MAAM,CAAC;AACpB,IAAA,OAAO,EAAE,QAAQ;AACjB,IAAA,MAAM,EAAE,4FAA4F;AACpG,IAAA,cAAc,EACZ,wKAAwK;AAC3K,CAAA,CAAC;AAiBF;;;;;AAKG;AACI,MAAM,MAAM,GAAG,CAAC,EACrB,aAAa,GAAG,SAAS,EACzB,QAAQ,GAAG,CAAC,EACZ,QAAQ,GAAG,GAAG,EACd,KAAK,EACL,IAAI,EACJ,cAAc,EACd,SAAS,EACT,aAAa,EACb,SAAS,EACT,kBAAkB,EAAE,eAAe,EACnC,aAAa,EAAE,UAAU,EACzB,GAAG,IAAI,EACK,KAAI;;AAEhB,IAAA,MAAM,oBAAoB,GAA6B;AACrD,QAAA,KAAK,EAAE,SAAS;AAChB,QAAA,qBAAqB,EAAE,CAAC;KACzB;AACD,IAAA,MAAM,YAAY,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,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
3
|
+
var reactHookForm = require('react-hook-form');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* react-hook-form's `useForm` with the validation timing the `Form*` fields are built on: errors appear when the user
|
|
7
|
+
* leaves a field, and clear as they fix it. Use it for every form whose fields come from `components/forms`.
|
|
8
|
+
*
|
|
9
|
+
* @param options Every option react-hook-form's `useForm` takes. `mode` and `reValidateMode` default to `'onBlur'`;
|
|
10
|
+
* set either only for a form with none of the library's fields, since theirs validate twice per keystroke otherwise.
|
|
11
|
+
* `shouldFocusError` defaults to `false`: `Form` focuses the first invalid field in page order, where
|
|
12
|
+
* react-hook-form's own choice follows the order the fields mounted in.
|
|
13
|
+
* @returns The form, exactly as react-hook-form returns it, for `Form`'s `form` prop.
|
|
14
|
+
*/
|
|
15
|
+
// biome-ignore lint/suspicious/noExplicitAny: mirrors react-hook-form's own `TContext = any`, so the two signatures stay interchangeable
|
|
16
|
+
const useForm = (options) =>
|
|
17
|
+
// Read one by one, not spread over: an option passed as `undefined` would otherwise switch the default off.
|
|
18
|
+
reactHookForm.useForm({
|
|
19
|
+
...options,
|
|
20
|
+
mode: options?.mode ?? 'onBlur',
|
|
21
|
+
reValidateMode: options?.reValidateMode ?? 'onBlur',
|
|
22
|
+
shouldFocusError: options?.shouldFocusError ?? false,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
exports.useForm = useForm;
|
|
26
|
+
//# sourceMappingURL=useForm.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useForm.cjs","sources":["../../../../../src/components/forms/Form/hooks/useForm.ts"],"sourcesContent":[null],"names":["useReactHookForm"],"mappings":";;;;AAEA;;;;;;;;;AASG;AACH;AACO,MAAM,OAAO,GAAG,CACrB,OAA6D;AAE7D;AACAA,qBAAgB,CAAwC;AACtD,IAAA,GAAG,OAAO;AACV,IAAA,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,QAAQ;AAC/B,IAAA,cAAc,EAAE,OAAO,EAAE,cAAc,IAAI,QAAQ;AACnD,IAAA,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,IAAI,KAAK;AACrD,CAAA;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type FieldValues, type UseFormProps, type UseFormReturn } from 'react-hook-form';
|
|
2
|
+
/**
|
|
3
|
+
* react-hook-form's `useForm` with the validation timing the `Form*` fields are built on: errors appear when the user
|
|
4
|
+
* leaves a field, and clear as they fix it. Use it for every form whose fields come from `components/forms`.
|
|
5
|
+
*
|
|
6
|
+
* @param options Every option react-hook-form's `useForm` takes. `mode` and `reValidateMode` default to `'onBlur'`;
|
|
7
|
+
* set either only for a form with none of the library's fields, since theirs validate twice per keystroke otherwise.
|
|
8
|
+
* `shouldFocusError` defaults to `false`: `Form` focuses the first invalid field in page order, where
|
|
9
|
+
* react-hook-form's own choice follows the order the fields mounted in.
|
|
10
|
+
* @returns The form, exactly as react-hook-form returns it, for `Form`'s `form` prop.
|
|
11
|
+
*/
|
|
12
|
+
export declare const useForm: <TValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TValues>(options?: UseFormProps<TValues, TContext, TTransformedValues>) => UseFormReturn<TValues, TContext, TTransformedValues>;
|
|
13
|
+
//# sourceMappingURL=useForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/Form/hooks/useForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAA+B,MAAM,iBAAiB,CAAC;AAEvH;;;;;;;;;GASG;AAEH,eAAO,MAAM,OAAO,GAAI,OAAO,SAAS,WAAW,GAAG,WAAW,EAAE,QAAQ,GAAG,GAAG,EAAE,kBAAkB,GAAG,OAAO,EAC7G,UAAU,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,CAAC,KAC5D,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,CAOlD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useForm as useForm$1 } from 'react-hook-form';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* react-hook-form's `useForm` with the validation timing the `Form*` fields are built on: errors appear when the user
|
|
5
|
+
* leaves a field, and clear as they fix it. Use it for every form whose fields come from `components/forms`.
|
|
6
|
+
*
|
|
7
|
+
* @param options Every option react-hook-form's `useForm` takes. `mode` and `reValidateMode` default to `'onBlur'`;
|
|
8
|
+
* set either only for a form with none of the library's fields, since theirs validate twice per keystroke otherwise.
|
|
9
|
+
* `shouldFocusError` defaults to `false`: `Form` focuses the first invalid field in page order, where
|
|
10
|
+
* react-hook-form's own choice follows the order the fields mounted in.
|
|
11
|
+
* @returns The form, exactly as react-hook-form returns it, for `Form`'s `form` prop.
|
|
12
|
+
*/
|
|
13
|
+
// biome-ignore lint/suspicious/noExplicitAny: mirrors react-hook-form's own `TContext = any`, so the two signatures stay interchangeable
|
|
14
|
+
const useForm = (options) =>
|
|
15
|
+
// Read one by one, not spread over: an option passed as `undefined` would otherwise switch the default off.
|
|
16
|
+
useForm$1({
|
|
17
|
+
...options,
|
|
18
|
+
mode: options?.mode ?? 'onBlur',
|
|
19
|
+
reValidateMode: options?.reValidateMode ?? 'onBlur',
|
|
20
|
+
shouldFocusError: options?.shouldFocusError ?? false,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export { useForm };
|
|
24
|
+
//# sourceMappingURL=useForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useForm.js","sources":["../../../../../src/components/forms/Form/hooks/useForm.ts"],"sourcesContent":[null],"names":["useReactHookForm"],"mappings":";;AAEA;;;;;;;;;AASG;AACH;AACO,MAAM,OAAO,GAAG,CACrB,OAA6D;AAE7D;AACAA,SAAgB,CAAwC;AACtD,IAAA,GAAG,OAAO;AACV,IAAA,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,QAAQ;AAC/B,IAAA,cAAc,EAAE,OAAO,EAAE,cAAc,IAAI,QAAQ;AACnD,IAAA,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,IAAI,KAAK;AACrD,CAAA;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Wraps a form's submit handler so a second submit is ignored while the first is still running, as Enter in a field
|
|
7
|
+
* can send one. The first to finish would otherwise unlock the fields for both, while the second save was still running.
|
|
8
|
+
*
|
|
9
|
+
* @param submit Runs the submit, such as react-hook-form's `handleSubmit(onSubmit)`; its promise is how long the submit lasts.
|
|
10
|
+
* @returns The handler for the form's `onSubmit`. It cancels the event of a submit it ignores, and returns the promise of one it runs, which rejects as `submit`'s does so a failed submit is still reported.
|
|
11
|
+
*/
|
|
12
|
+
const useSubmitInTurn = (submit) => {
|
|
13
|
+
// A ref, not the form's state: Enter in a field can submit twice before the first submit has rendered as submitting.
|
|
14
|
+
const isSubmitting = React.useRef(false);
|
|
15
|
+
return React.useCallback((event) => {
|
|
16
|
+
if (isSubmitting.current) {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
isSubmitting.current = true;
|
|
21
|
+
return submit(event).finally(() => {
|
|
22
|
+
isSubmitting.current = false;
|
|
23
|
+
});
|
|
24
|
+
}, [submit]);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.useSubmitInTurn = useSubmitInTurn;
|
|
28
|
+
//# sourceMappingURL=useSubmitInTurn.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSubmitInTurn.cjs","sources":["../../../../../../src/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.ts"],"sourcesContent":[null],"names":["useRef","useCallback"],"mappings":";;;;AAEA;;;;;;AAMG;AACI,MAAM,eAAe,GAAG,CAAC,MAA+D,KAAI;;AAEjG,IAAA,MAAM,YAAY,GAAGA,YAAM,CAAC,KAAK,CAAC;AAElC,IAAA,OAAOC,iBAAW,CAChB,CAAC,KAAiC,KAAI;AACpC,QAAA,IAAI,YAAY,CAAC,OAAO,EAAE;YACxB,KAAK,CAAC,cAAc,EAAE;AACtB,YAAA,OAAO,SAAS;QAClB;AACA,QAAA,YAAY,CAAC,OAAO,GAAG,IAAI;QAC3B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAK;AAChC,YAAA,YAAY,CAAC,OAAO,GAAG,KAAK;AAC9B,QAAA,CAAC,CAAC;AACJ,IAAA,CAAC,EACD,CAAC,MAAM,CAAC,CACT;AACH;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type FormEvent } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a form's submit handler so a second submit is ignored while the first is still running, as Enter in a field
|
|
4
|
+
* can send one. The first to finish would otherwise unlock the fields for both, while the second save was still running.
|
|
5
|
+
*
|
|
6
|
+
* @param submit Runs the submit, such as react-hook-form's `handleSubmit(onSubmit)`; its promise is how long the submit lasts.
|
|
7
|
+
* @returns The handler for the form's `onSubmit`. It cancels the event of a submit it ignores, and returns the promise of one it runs, which rejects as `submit`'s does so a failed submit is still reported.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useSubmitInTurn: (submit: (event: FormEvent<HTMLFormElement>) => Promise<unknown>) => (event: FormEvent<HTMLFormElement>) => Promise<unknown> | undefined;
|
|
10
|
+
//# sourceMappingURL=useSubmitInTurn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSubmitInTurn.d.ts","sourceRoot":"","sources":["../../../../../../src/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAE5D;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,aAKnF,SAAS,CAAC,eAAe,CAAC,iCAYrC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useRef, useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a form's submit handler so a second submit is ignored while the first is still running, as Enter in a field
|
|
5
|
+
* can send one. The first to finish would otherwise unlock the fields for both, while the second save was still running.
|
|
6
|
+
*
|
|
7
|
+
* @param submit Runs the submit, such as react-hook-form's `handleSubmit(onSubmit)`; its promise is how long the submit lasts.
|
|
8
|
+
* @returns The handler for the form's `onSubmit`. It cancels the event of a submit it ignores, and returns the promise of one it runs, which rejects as `submit`'s does so a failed submit is still reported.
|
|
9
|
+
*/
|
|
10
|
+
const useSubmitInTurn = (submit) => {
|
|
11
|
+
// A ref, not the form's state: Enter in a field can submit twice before the first submit has rendered as submitting.
|
|
12
|
+
const isSubmitting = useRef(false);
|
|
13
|
+
return useCallback((event) => {
|
|
14
|
+
if (isSubmitting.current) {
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
isSubmitting.current = true;
|
|
19
|
+
return submit(event).finally(() => {
|
|
20
|
+
isSubmitting.current = false;
|
|
21
|
+
});
|
|
22
|
+
}, [submit]);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { useSubmitInTurn };
|
|
26
|
+
//# sourceMappingURL=useSubmitInTurn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSubmitInTurn.js","sources":["../../../../../../src/components/forms/Form/hooks/useSubmitInTurn/useSubmitInTurn.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;AAMG;AACI,MAAM,eAAe,GAAG,CAAC,MAA+D,KAAI;;AAEjG,IAAA,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC;AAElC,IAAA,OAAO,WAAW,CAChB,CAAC,KAAiC,KAAI;AACpC,QAAA,IAAI,YAAY,CAAC,OAAO,EAAE;YACxB,KAAK,CAAC,cAAc,EAAE;AACtB,YAAA,OAAO,SAAS;QAClB;AACA,QAAA,YAAY,CAAC,OAAO,GAAG,IAAI;QAC3B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAK;AAChC,YAAA,YAAY,CAAC,OAAO,GAAG,KAAK;AAC9B,QAAA,CAAC,CAAC;AACJ,IAAA,CAAC,EACD,CAAC,MAAM,CAAC,CACT;AACH;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
5
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var reactHookForm = require('react-hook-form');
|
|
8
|
+
var FieldElements_context = require('../__internal__/formField/providers/FieldElements.context.cjs');
|
|
9
|
+
var fieldElements_utils = require('../__internal__/formField/utilities/fieldElements.utils.cjs');
|
|
10
|
+
var formFocus_utils = require('../__internal__/formField/utilities/formFocus.utils.cjs');
|
|
11
|
+
var useSubmitInTurn = require('./hooks/useSubmitInTurn/useSubmitInTurn.cjs');
|
|
12
|
+
var formSubmit_utils = require('./utilities/formSubmit.utils.cjs');
|
|
13
|
+
var useForm = require('./hooks/useForm.cjs');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The `<form>` around `Form*` fields: it provides the react-hook-form form to them, leaves validation to the schema,
|
|
17
|
+
* focuses the first invalid field in page order after a failed submit, and ignores a second submit while one is running.
|
|
18
|
+
* Use one per form.
|
|
19
|
+
*
|
|
20
|
+
* @summary form element that provides a react-hook-form form to its fields
|
|
21
|
+
*/
|
|
22
|
+
const Form = ({ form, onSubmit, onInvalid, className, children, 'data-testid': dataTestId, ...formProps }) => {
|
|
23
|
+
const formTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'form', rootName: 'form' });
|
|
24
|
+
const [fieldElements] = React.useState(fieldElements_utils.createFieldElements);
|
|
25
|
+
// The focus lands once the submit is over: react-hook-form moves it on a timer, and a control the submit disabled
|
|
26
|
+
// takes it only when it is enabled again. `onInvalid` is therefore not told where focus is.
|
|
27
|
+
const focusFirstInvalid = (errors, event) => {
|
|
28
|
+
const first = formFocus_utils.firstInvalidFieldOnPage(errors, fieldElements.elements);
|
|
29
|
+
if (first)
|
|
30
|
+
form.setFocus(first);
|
|
31
|
+
return onInvalid?.(errors, event);
|
|
32
|
+
};
|
|
33
|
+
const submit = useSubmitInTurn.useSubmitInTurn(formSubmit_utils.submitAfterValidations(form, onSubmit, focusFirstInvalid));
|
|
34
|
+
return (jsxRuntime.jsx(reactHookForm.FormProvider, { ...form, children: jsxRuntime.jsx(FieldElements_context.FieldElementsContext, { value: fieldElements, children: jsxRuntime.jsx("form", { ...formProps,
|
|
35
|
+
// The schema validates; the browser's own checks (`type="email"`, `required`) would block the submit before it runs.
|
|
36
|
+
noValidate: true,
|
|
37
|
+
// Focusable from code only: a control that turns itself off, such as Discard, hands focus here so it is not lost.
|
|
38
|
+
tabIndex: -1, onSubmit: submit, "data-testid": formTestId, className: cx.cx('outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2', className), children: children }) }) }));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
exports.useForm = useForm.useForm;
|
|
42
|
+
exports.Form = Form;
|
|
43
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/forms/Form/index.tsx"],"sourcesContent":[null],"names":["useResolvedTestId","useState","createFieldElements","firstInvalidFieldOnPage","useSubmitInTurn","submitAfterValidations","_jsx","FormProvider","FieldElementsContext","cx"],"mappings":";;;;;;;;;;;;;;AAmCA;;;;;;AAMG;AACI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mitHandler, type UseFormReturn } from 'react-hook-form';
|
|
3
|
+
export { useForm } from './hooks/useForm';
|
|
4
|
+
export interface FormProps<TValues extends FieldValues = FieldValues, TSubmitValues = TValues> extends Omit<ComponentProps<'form'>, 'onSubmit' | 'onInvalid' | 'noValidate' | 'ref'> {
|
|
5
|
+
/**
|
|
6
|
+
* The form from this module's `useForm`; every `Form*` field and `FormFooter` beneath reads it. One from
|
|
7
|
+
* react-hook-form's own `useForm` needs `mode` and `reValidateMode` set to `'onBlur'` and `shouldFocusError` to `false`.
|
|
8
|
+
*/
|
|
9
|
+
form: UseFormReturn<TValues, any, TSubmitValues>;
|
|
10
|
+
/**
|
|
11
|
+
* Called with the values once they pass validation, as the schema gives them out, such as a number a field made from
|
|
12
|
+
* text. Return the save's promise, so the fields stay locked until it lands.
|
|
13
|
+
*/
|
|
14
|
+
onSubmit: SubmitHandler<TSubmitValues>;
|
|
15
|
+
/** Called with the errors when validation fails. The first invalid field takes focus as the submit ends. */
|
|
16
|
+
onInvalid?: SubmitErrorHandler<TValues>;
|
|
17
|
+
/** Ref to the `<form>` element. */
|
|
18
|
+
ref?: Ref<HTMLFormElement>;
|
|
19
|
+
/** Overrides the `data-testid` (defaults to `fd-form`). */
|
|
20
|
+
'data-testid'?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The `<form>` around `Form*` fields: it provides the react-hook-form form to them, leaves validation to the schema,
|
|
24
|
+
* focuses the first invalid field in page order after a failed submit, and ignores a second submit while one is running.
|
|
25
|
+
* Use one per form.
|
|
26
|
+
*
|
|
27
|
+
* @summary form element that provides a react-hook-form form to its fields
|
|
28
|
+
*/
|
|
29
|
+
export declare const Form: <TValues extends FieldValues = FieldValues, TSubmitValues = TValues>({ form, onSubmit, onInvalid, className, children, "data-testid": dataTestId, ...formProps }: FormProps<TValues, TSubmitValues>) => import("react").JSX.Element;
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/Form/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,GAAG,EAAY,MAAM,OAAO,CAAC;AAChE,OAAO,EAAkB,KAAK,WAAW,EAAgB,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAOlJ,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,WAAW,SAAS,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,EAAE,aAAa,GAAG,OAAO,CAC3F,SAAQ,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,YAAY,GAAG,KAAK,CAAC;IACrF;;;OAGG;IAEH,IAAI,EAAE,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC;IACjD;;;OAGG;IACH,QAAQ,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IACvC,4GAA4G;IAC5G,SAAS,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACxC,mCAAmC;IACnC,GAAG,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;IAC3B,2DAA2D;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,GAAI,OAAO,SAAS,WAAW,GAAG,WAAW,EAAE,aAAa,GAAG,OAAO,EAAE,6FAQtF,SAAS,CAAC,OAAO,EAAE,aAAa,CAAC,gCAgCnC,CAAC"}
|