@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":"useEmptyFieldValue.cjs","sources":["../../../../../../src/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.ts"],"sourcesContent":[null],"names":["useRef","useEffect","rememberEmptyValue","useCallback"],"mappings":";;;;;AAGA;;;;;;;;AAQG;MACU,kBAAkB,GAAG,CAAC,IAAY,EAAE,KAAgC,KAAI;AACnF,IAAA,MAAM,UAAU,GAAGA,YAAM,CAAkB,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;;IAGjEC,eAAS,CAAC,MAAK;AACb,QAAA,UAAU,CAAC,OAAO,GAAGC,wCAAkB,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC;AAC1E,IAAA,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAEjB,IAAA,OAAOC,iBAAW,CAAC,CAAC,IAAmB,KAAK,IAAI,IAAID,wCAAkB,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC/H;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gives a colour field the value to write when it is emptied: the empty value the form itself uses for it, such as
|
|
3
|
+
* `undefined` for a field with no default or `''` for one an API sends empty. The picker reports an emptied field as
|
|
4
|
+
* `null`, which would leave a field the user put back as it was looking edited.
|
|
5
|
+
*
|
|
6
|
+
* @param name The field's name. A change of name starts again, so one field's empty value is never written to another.
|
|
7
|
+
* @param value The field's current value.
|
|
8
|
+
* @returns A function from the value the picker reports to the value the field should hold.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useEmptyFieldValue: (name: string, value: string | null | undefined) => (next: string | null) => string | null | undefined;
|
|
11
|
+
//# sourceMappingURL=useEmptyFieldValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEmptyFieldValue.d.ts","sourceRoot":"","sources":["../../../../../../src/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,YAQrD,MAAM,GAAG,IAAI,8BACxC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useRef, useEffect, useCallback } from 'react';
|
|
2
|
+
import { rememberEmptyValue } from '../utilities/formColorPicker.utils.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Gives a colour field the value to write when it is emptied: the empty value the form itself uses for it, such as
|
|
6
|
+
* `undefined` for a field with no default or `''` for one an API sends empty. The picker reports an emptied field as
|
|
7
|
+
* `null`, which would leave a field the user put back as it was looking edited.
|
|
8
|
+
*
|
|
9
|
+
* @param name The field's name. A change of name starts again, so one field's empty value is never written to another.
|
|
10
|
+
* @param value The field's current value.
|
|
11
|
+
* @returns A function from the value the picker reports to the value the field should hold.
|
|
12
|
+
*/
|
|
13
|
+
const useEmptyFieldValue = (name, value) => {
|
|
14
|
+
const remembered = useRef({ name, value: null });
|
|
15
|
+
// Noted whenever the value changes, not only on a pick: the app may fill an empty field itself, and Remove must
|
|
16
|
+
// still write what empty was.
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
remembered.current = rememberEmptyValue(remembered.current, name, value);
|
|
19
|
+
}, [name, value]);
|
|
20
|
+
return useCallback((next) => next ?? rememberEmptyValue(remembered.current, name, value).value, [name, value]);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { useEmptyFieldValue };
|
|
24
|
+
//# sourceMappingURL=useEmptyFieldValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEmptyFieldValue.js","sources":["../../../../../../src/components/forms/fields/FormColorPicker/hooks/useEmptyFieldValue.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAGA;;;;;;;;AAQG;MACU,kBAAkB,GAAG,CAAC,IAAY,EAAE,KAAgC,KAAI;AACnF,IAAA,MAAM,UAAU,GAAG,MAAM,CAAkB,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;;IAGjE,SAAS,CAAC,MAAK;AACb,QAAA,UAAU,CAAC,OAAO,GAAG,kBAAkB,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC;AAC1E,IAAA,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAEjB,IAAA,OAAO,WAAW,CAAC,CAAC,IAAmB,KAAK,IAAI,IAAI,kBAAkB,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC/H;;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var ColorPicker = require('@flipdish/ui-library/components/organisms/ColorPicker');
|
|
5
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
6
|
+
var useFocusTarget = require('../../__internal__/formField/hooks/useFocusTarget.cjs');
|
|
7
|
+
var useFormField = require('../../__internal__/formField/hooks/useFormField.cjs');
|
|
8
|
+
var useEmptyFieldValue = require('./hooks/useEmptyFieldValue.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* `ColorPicker.Field` bound to a react-hook-form field: the trigger shows the field's colour and opens the picker, the field
|
|
12
|
+
* follows the picker as a hex string, and closing it validates. Use it when the user picks a single solid colour in a react-hook-form form.
|
|
13
|
+
*
|
|
14
|
+
* @summary colour picker bound to a react-hook-form field
|
|
15
|
+
*/
|
|
16
|
+
const FormColorPicker = ({ name, revalidates, hint, 'data-testid': dataTestId, ...fieldProps }) => {
|
|
17
|
+
const { value, ref, onChange, onCommit, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField.useFormField(name, revalidates);
|
|
18
|
+
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'form-color-picker', rootName: 'form-color-picker' });
|
|
19
|
+
// The field's ref is its root element, so the form is handed the first button inside it, which is the trigger.
|
|
20
|
+
const focusRef = useFocusTarget.useFocusTarget(ref, 'button');
|
|
21
|
+
const toFieldValue = useEmptyFieldValue.useEmptyFieldValue(name, value);
|
|
22
|
+
// Dragging in the picker is like typing: it validates nothing new, but clears an error as soon as the colour is one the form accepts.
|
|
23
|
+
const draft = (next) => onChange(toFieldValue(next));
|
|
24
|
+
const commit = (next) => onCommit(toFieldValue(next));
|
|
25
|
+
return (jsxRuntime.jsx(ColorPicker.ColorPicker.Field, { ...fieldProps, ref: focusRef, value: value,
|
|
26
|
+
// The form validates once the edit is over, which is when the picker closes.
|
|
27
|
+
onChange: draft, onChangeEnd: commit, onBlur: onBlur, isInvalid: isInvalid, hint: errorMessage ?? hint,
|
|
28
|
+
// Disabled while the form submits, having no read-only mode: a change made meanwhile would be lost to the save.
|
|
29
|
+
isDisabled: fieldProps.isDisabled || isDisabled || isLocked, "data-testid": rootTestId }));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.FormColorPicker = FormColorPicker;
|
|
33
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../../src/components/forms/fields/FormColorPicker/index.tsx"],"sourcesContent":[null],"names":["useFormField","useResolvedTestId","useFocusTarget","useEmptyFieldValue","_jsx","ColorPicker"],"mappings":";;;;;;;;;AA2BA;;;;;AAKG;MACU,eAAe,GAAG,CAA4C,EACzE,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,aAAa,EAAE,UAAU,EACzB,GAAG,UAAU,EACiB,KAAI;IAClC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAGA,yBAAY,CAC5G,IAAI,EACJ,WAAW,CACZ;AACD,IAAA,MAAM,UAAU,GAAGC,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC;;IAEzH,MAAM,QAAQ,GAAGC,6BAAc,CAAC,GAAG,EAAE,QAAQ,CAAC;IAC9C,MAAM,YAAY,GAAGC,qCAAkB,CAAC,IAAI,EAAE,KAAK,CAAC;;AAEpD,IAAA,MAAM,KAAK,GAAG,CAAC,IAAmB,KAAK,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AACnE,IAAA,MAAM,MAAM,GAAG,CAAC,IAAmB,KAAK,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AAEpE,IAAA,QACEC,cAAA,CAACC,uBAAW,CAAC,KAAK,EAAA,EAAA,GACZ,UAAU,EACd,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,KAAK;;AAEZ,QAAA,QAAQ,EAAE,KAAK,EACf,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,YAAY,IAAI,IAAI;;AAE1B,QAAA,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,UAAU,IAAI,QAAQ,EAAA,aAAA,EAC9C,UAAU,EAAA,CACvB;AAEN;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ColorPickerFieldProps } from '@flipdish/ui-library/components/organisms/ColorPicker';
|
|
2
|
+
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
3
|
+
type OmitFromEach<TProps, TKeys extends PropertyKey> = TProps extends unknown ? Omit<TProps, TKeys> : never;
|
|
4
|
+
interface FormColorPickerBindingProps<TValues extends FieldValues = FieldValues> {
|
|
5
|
+
/** The field's path in the form values, such as `primaryColor` or `theme.accent`. */
|
|
6
|
+
name: FieldPath<TValues>;
|
|
7
|
+
/**
|
|
8
|
+
* Other fields to re-validate when this changes. A `crossFieldRules` rule validated through `useSchemaResolver` names them
|
|
9
|
+
* itself, so pass this only for a rule written another way, such as a zod `superRefine` in the same schema, or for a nested field.
|
|
10
|
+
*/
|
|
11
|
+
revalidates?: FieldPath<TValues> | FieldPath<TValues>[];
|
|
12
|
+
/** Overrides the root `data-testid` (defaults to `fd-form-color-picker`); the trigger, Remove button and picker derive from it. */
|
|
13
|
+
'data-testid'?: string;
|
|
14
|
+
}
|
|
15
|
+
export type FormColorPickerProps<TValues extends FieldValues = FieldValues> = FormColorPickerBindingProps<TValues> & OmitFromEach<ColorPickerFieldProps, 'value' | 'onChange' | 'onChangeEnd' | 'onBlur' | 'isInvalid' | 'ref' | 'data-testid'>;
|
|
16
|
+
/**
|
|
17
|
+
* `ColorPicker.Field` bound to a react-hook-form field: the trigger shows the field's colour and opens the picker, the field
|
|
18
|
+
* follows the picker as a hex string, and closing it validates. Use it when the user picks a single solid colour in a react-hook-form form.
|
|
19
|
+
*
|
|
20
|
+
* @summary colour picker bound to a react-hook-form field
|
|
21
|
+
*/
|
|
22
|
+
export declare const FormColorPicker: <TValues extends FieldValues = FieldValues>({ name, revalidates, hint, "data-testid": dataTestId, ...fieldProps }: FormColorPickerProps<TValues>) => import("react").JSX.Element;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/fields/FormColorPicker/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAe,KAAK,qBAAqB,EAAE,MAAM,uDAAuD,CAAC;AAEhH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAM9D,KAAK,YAAY,CAAC,MAAM,EAAE,KAAK,SAAS,WAAW,IAAI,MAAM,SAAS,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC;AAE5G,UAAU,2BAA2B,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW;IAC7E,qFAAqF;IACrF,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACzB;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;IACxD,mIAAmI;IACnI,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,IAAI,2BAA2B,CAAC,OAAO,CAAC,GAChH,YAAY,CAAC,qBAAqB,EAAE,OAAO,GAAG,UAAU,GAAG,aAAa,GAAG,QAAQ,GAAG,WAAW,GAAG,KAAK,GAAG,aAAa,CAAC,CAAC;AAE7H;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,SAAS,WAAW,GAAG,WAAW,EAAE,uEAMxE,oBAAoB,CAAC,OAAO,CAAC,gCA6B/B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { ColorPicker } from '@flipdish/ui-library/components/organisms/ColorPicker';
|
|
3
|
+
import { useResolvedTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
4
|
+
import { useFocusTarget } from '../../__internal__/formField/hooks/useFocusTarget.js';
|
|
5
|
+
import { useFormField } from '../../__internal__/formField/hooks/useFormField.js';
|
|
6
|
+
import { useEmptyFieldValue } from './hooks/useEmptyFieldValue.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `ColorPicker.Field` bound to a react-hook-form field: the trigger shows the field's colour and opens the picker, the field
|
|
10
|
+
* follows the picker as a hex string, and closing it validates. Use it when the user picks a single solid colour in a react-hook-form form.
|
|
11
|
+
*
|
|
12
|
+
* @summary colour picker bound to a react-hook-form field
|
|
13
|
+
*/
|
|
14
|
+
const FormColorPicker = ({ name, revalidates, hint, 'data-testid': dataTestId, ...fieldProps }) => {
|
|
15
|
+
const { value, ref, onChange, onCommit, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField(name, revalidates);
|
|
16
|
+
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'form-color-picker', rootName: 'form-color-picker' });
|
|
17
|
+
// The field's ref is its root element, so the form is handed the first button inside it, which is the trigger.
|
|
18
|
+
const focusRef = useFocusTarget(ref, 'button');
|
|
19
|
+
const toFieldValue = useEmptyFieldValue(name, value);
|
|
20
|
+
// Dragging in the picker is like typing: it validates nothing new, but clears an error as soon as the colour is one the form accepts.
|
|
21
|
+
const draft = (next) => onChange(toFieldValue(next));
|
|
22
|
+
const commit = (next) => onCommit(toFieldValue(next));
|
|
23
|
+
return (jsx(ColorPicker.Field, { ...fieldProps, ref: focusRef, value: value,
|
|
24
|
+
// The form validates once the edit is over, which is when the picker closes.
|
|
25
|
+
onChange: draft, onChangeEnd: commit, onBlur: onBlur, isInvalid: isInvalid, hint: errorMessage ?? hint,
|
|
26
|
+
// Disabled while the form submits, having no read-only mode: a change made meanwhile would be lost to the save.
|
|
27
|
+
isDisabled: fieldProps.isDisabled || isDisabled || isLocked, "data-testid": rootTestId }));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { FormColorPicker };
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/components/forms/fields/FormColorPicker/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;AA2BA;;;;;AAKG;MACU,eAAe,GAAG,CAA4C,EACzE,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,aAAa,EAAE,UAAU,EACzB,GAAG,UAAU,EACiB,KAAI;IAClC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,YAAY,CAC5G,IAAI,EACJ,WAAW,CACZ;AACD,IAAA,MAAM,UAAU,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC;;IAEzH,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,EAAE,QAAQ,CAAC;IAC9C,MAAM,YAAY,GAAG,kBAAkB,CAAC,IAAI,EAAE,KAAK,CAAC;;AAEpD,IAAA,MAAM,KAAK,GAAG,CAAC,IAAmB,KAAK,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AACnE,IAAA,MAAM,MAAM,GAAG,CAAC,IAAmB,KAAK,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AAEpE,IAAA,QACEA,GAAA,CAAC,WAAW,CAAC,KAAK,EAAA,EAAA,GACZ,UAAU,EACd,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,KAAK;;AAEZ,QAAA,QAAQ,EAAE,KAAK,EACf,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,YAAY,IAAI,IAAI;;AAE1B,QAAA,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,UAAU,IAAI,QAAQ,EAAA,aAAA,EAC9C,UAAU,EAAA,CACvB;AAEN;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Keeps track of the empty value a colour field itself uses, such as `undefined` for a field with no default or `''`
|
|
5
|
+
* for one an API sends empty. The picker reports an emptied field as `null`; writing the field's own empty value back
|
|
6
|
+
* lets a field the user put back as it was count as unchanged.
|
|
7
|
+
*
|
|
8
|
+
* @param remembered What was kept from the last render.
|
|
9
|
+
* @param name The field being rendered now. A change of name starts again: one field's empty value is never written to another.
|
|
10
|
+
* @param value The field's current value.
|
|
11
|
+
* @returns What to keep: the current value while the field is empty, else what was kept, or `null` for a field never seen empty.
|
|
12
|
+
*/
|
|
13
|
+
const rememberEmptyValue = (remembered, name, value) => {
|
|
14
|
+
if (!value)
|
|
15
|
+
return { name, value };
|
|
16
|
+
return remembered.name === name ? remembered : { name, value: null };
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.rememberEmptyValue = rememberEmptyValue;
|
|
20
|
+
//# sourceMappingURL=formColorPicker.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formColorPicker.utils.cjs","sources":["../../../../../../src/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAMA;;;;;;;;;AASG;AACI,MAAM,kBAAkB,GAAG,CAAC,UAA2B,EAAE,IAAY,EAAE,KAAgC,KAAqB;AACjI,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE;AAClC,IAAA,OAAO,UAAU,CAAC,IAAI,KAAK,IAAI,GAAG,UAAU,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;AACtE;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** The empty value a field was last seen to hold, kept with the field's name. */
|
|
2
|
+
export interface EmptyFieldValue {
|
|
3
|
+
name: string;
|
|
4
|
+
value: string | null | undefined;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Keeps track of the empty value a colour field itself uses, such as `undefined` for a field with no default or `''`
|
|
8
|
+
* for one an API sends empty. The picker reports an emptied field as `null`; writing the field's own empty value back
|
|
9
|
+
* lets a field the user put back as it was count as unchanged.
|
|
10
|
+
*
|
|
11
|
+
* @param remembered What was kept from the last render.
|
|
12
|
+
* @param name The field being rendered now. A change of name starts again: one field's empty value is never written to another.
|
|
13
|
+
* @param value The field's current value.
|
|
14
|
+
* @returns What to keep: the current value while the field is empty, else what was kept, or `null` for a field never seen empty.
|
|
15
|
+
*/
|
|
16
|
+
export declare const rememberEmptyValue: (remembered: EmptyFieldValue, name: string, value: string | null | undefined) => EmptyFieldValue;
|
|
17
|
+
//# sourceMappingURL=formColorPicker.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formColorPicker.utils.d.ts","sourceRoot":"","sources":["../../../../../../src/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAClC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAI,YAAY,eAAe,EAAE,MAAM,MAAM,EAAE,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,eAGhH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps track of the empty value a colour field itself uses, such as `undefined` for a field with no default or `''`
|
|
3
|
+
* for one an API sends empty. The picker reports an emptied field as `null`; writing the field's own empty value back
|
|
4
|
+
* lets a field the user put back as it was count as unchanged.
|
|
5
|
+
*
|
|
6
|
+
* @param remembered What was kept from the last render.
|
|
7
|
+
* @param name The field being rendered now. A change of name starts again: one field's empty value is never written to another.
|
|
8
|
+
* @param value The field's current value.
|
|
9
|
+
* @returns What to keep: the current value while the field is empty, else what was kept, or `null` for a field never seen empty.
|
|
10
|
+
*/
|
|
11
|
+
const rememberEmptyValue = (remembered, name, value) => {
|
|
12
|
+
if (!value)
|
|
13
|
+
return { name, value };
|
|
14
|
+
return remembered.name === name ? remembered : { name, value: null };
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { rememberEmptyValue };
|
|
18
|
+
//# sourceMappingURL=formColorPicker.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formColorPicker.utils.js","sources":["../../../../../../src/components/forms/fields/FormColorPicker/utilities/formColorPicker.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAMA;;;;;;;;;AASG;AACI,MAAM,kBAAkB,GAAG,CAAC,UAA2B,EAAE,IAAY,EAAE,KAAgC,KAAqB;AACjI,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE;AAClC,IAAA,OAAO,UAAU,CAAC,IAAI,KAAK,IAAI,GAAG,UAAU,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;AACtE;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var DatePicker = require('@flipdish/ui-library/components/organisms/DatePicker');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var useFocusTarget = require('../../__internal__/formField/hooks/useFocusTarget.cjs');
|
|
7
|
+
var useFormField = require('../../__internal__/formField/hooks/useFormField.cjs');
|
|
8
|
+
var formDatePicker_utils = require('./utilities/formDatePicker.utils.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A `DatePicker` bound to a react-hook-form field: pressing Apply writes the date to the form as an ISO string
|
|
12
|
+
* (`YYYY-MM-DD`) and validates it at once, and the field's error shows in place of `hint`. Use it when the user picks
|
|
13
|
+
* a single date in a react-hook-form form.
|
|
14
|
+
*
|
|
15
|
+
* @summary date picker bound to a react-hook-form field
|
|
16
|
+
*/
|
|
17
|
+
const FormDatePicker = ({ name, revalidates, hint, ...datePickerProps }) => {
|
|
18
|
+
const { value, ref, onCommit, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField.useFormField(name, revalidates);
|
|
19
|
+
// An unset, empty or unreadable field is no date; `null` keeps the picker controlled, and a stable date keeps its draft intact.
|
|
20
|
+
const date = React.useMemo(() => formDatePicker_utils.toCalendarDate(value), [value]);
|
|
21
|
+
// `DatePicker` reports a change only when Apply is pressed, so the draft the user is browsing never reaches the form.
|
|
22
|
+
const handleChange = (next) => onCommit(next ? next.toString() : null);
|
|
23
|
+
// `DatePicker`'s ref is its root div; the trigger is the only button in it, the calendar being portalled.
|
|
24
|
+
const focusRef = useFocusTarget.useFocusTarget(ref, 'button');
|
|
25
|
+
return (jsxRuntime.jsx(DatePicker.DatePicker
|
|
26
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
27
|
+
, {
|
|
28
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
29
|
+
validationBehavior: "aria", ...datePickerProps, ref: focusRef, name: name, value: date, onChange: handleChange, onBlur: onBlur, isInvalid: isInvalid, hint: errorMessage ?? hint,
|
|
30
|
+
// Disabled while the form submits: read-only would disable the trigger all the same, without looking it.
|
|
31
|
+
isDisabled: datePickerProps.isDisabled || isDisabled || isLocked }));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.FormDatePicker = FormDatePicker;
|
|
35
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../../src/components/forms/fields/FormDatePicker/index.tsx"],"sourcesContent":[null],"names":["useFormField","useMemo","toCalendarDate","useFocusTarget","_jsx","DatePicker"],"mappings":";;;;;;;;;AAqBA;;;;;;AAMG;AACI,MAAM,cAAc,GAAG,CAA4C,EACxE,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,GAAG,eAAe,EACW,KAAI;IACjC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAGA,yBAAY,CAAyB,IAAI,EAAE,WAAW,CAAC;;AAE/I,IAAA,MAAM,IAAI,GAAGC,aAAO,CAAC,MAAMC,mCAAc,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;;IAE1D,MAAM,YAAY,GAAG,CAAC,IAAsB,KAAK,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC;;IAGxF,MAAM,QAAQ,GAAGC,6BAAc,CAAC,GAAG,EAAE,QAAQ,CAAC;IAE9C,QACEC,eAACC;;;;AAEC,QAAA,kBAAkB,EAAC,MAAM,EAAA,GACrB,eAAe,EACnB,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,YAAY,IAAI,IAAI;;QAE1B,UAAU,EAAE,eAAe,CAAC,UAAU,IAAI,UAAU,IAAI,QAAQ,EAAA,CAChE;AAEN;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type DatePickerProps } from '@flipdish/ui-library/components/organisms/DatePicker';
|
|
2
|
+
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
3
|
+
export interface FormDatePickerProps<TValues extends FieldValues = FieldValues> extends Omit<DatePickerProps, 'name' | 'value' | 'defaultValue' | 'onChange' | 'onBlur' | 'isInvalid' | 'ref'> {
|
|
4
|
+
/** The field's path in the form values, such as `deliveryDate` or `promotion.endDate`. */
|
|
5
|
+
name: FieldPath<TValues>;
|
|
6
|
+
/**
|
|
7
|
+
* Other fields to re-validate when this changes. A `crossFieldRules` rule validated through `useSchemaResolver` names them
|
|
8
|
+
* itself, so pass this only for a rule written another way, such as a zod `superRefine` in the same schema, or for a nested field.
|
|
9
|
+
*/
|
|
10
|
+
revalidates?: FieldPath<TValues> | FieldPath<TValues>[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A `DatePicker` bound to a react-hook-form field: pressing Apply writes the date to the form as an ISO string
|
|
14
|
+
* (`YYYY-MM-DD`) and validates it at once, and the field's error shows in place of `hint`. Use it when the user picks
|
|
15
|
+
* a single date in a react-hook-form form.
|
|
16
|
+
*
|
|
17
|
+
* @summary date picker bound to a react-hook-form field
|
|
18
|
+
*/
|
|
19
|
+
export declare const FormDatePicker: <TValues extends FieldValues = FieldValues>({ name, revalidates, hint, ...datePickerProps }: FormDatePickerProps<TValues>) => import("react").JSX.Element;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/fields/FormDatePicker/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,sDAAsD,CAAC;AAGxG,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAK9D,MAAM,WAAW,mBAAmB,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,CAC5E,SAAQ,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,WAAW,GAAG,KAAK,CAAC;IAC9G,0FAA0F;IAC1F,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACzB;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;CACzD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,SAAS,WAAW,GAAG,WAAW,EAAE,iDAKvE,mBAAmB,CAAC,OAAO,CAAC,gCA0B9B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { DatePicker } from '@flipdish/ui-library/components/organisms/DatePicker';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { useFocusTarget } from '../../__internal__/formField/hooks/useFocusTarget.js';
|
|
5
|
+
import { useFormField } from '../../__internal__/formField/hooks/useFormField.js';
|
|
6
|
+
import { toCalendarDate } from './utilities/formDatePicker.utils.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A `DatePicker` bound to a react-hook-form field: pressing Apply writes the date to the form as an ISO string
|
|
10
|
+
* (`YYYY-MM-DD`) and validates it at once, and the field's error shows in place of `hint`. Use it when the user picks
|
|
11
|
+
* a single date in a react-hook-form form.
|
|
12
|
+
*
|
|
13
|
+
* @summary date picker bound to a react-hook-form field
|
|
14
|
+
*/
|
|
15
|
+
const FormDatePicker = ({ name, revalidates, hint, ...datePickerProps }) => {
|
|
16
|
+
const { value, ref, onCommit, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField(name, revalidates);
|
|
17
|
+
// An unset, empty or unreadable field is no date; `null` keeps the picker controlled, and a stable date keeps its draft intact.
|
|
18
|
+
const date = useMemo(() => toCalendarDate(value), [value]);
|
|
19
|
+
// `DatePicker` reports a change only when Apply is pressed, so the draft the user is browsing never reaches the form.
|
|
20
|
+
const handleChange = (next) => onCommit(next ? next.toString() : null);
|
|
21
|
+
// `DatePicker`'s ref is its root div; the trigger is the only button in it, the calendar being portalled.
|
|
22
|
+
const focusRef = useFocusTarget(ref, 'button');
|
|
23
|
+
return (jsx(DatePicker
|
|
24
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
25
|
+
, {
|
|
26
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
27
|
+
validationBehavior: "aria", ...datePickerProps, ref: focusRef, name: name, value: date, onChange: handleChange, onBlur: onBlur, isInvalid: isInvalid, hint: errorMessage ?? hint,
|
|
28
|
+
// Disabled while the form submits: read-only would disable the trigger all the same, without looking it.
|
|
29
|
+
isDisabled: datePickerProps.isDisabled || isDisabled || isLocked }));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { FormDatePicker };
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/components/forms/fields/FormDatePicker/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;AAqBA;;;;;;AAMG;AACI,MAAM,cAAc,GAAG,CAA4C,EACxE,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,GAAG,eAAe,EACW,KAAI;IACjC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,YAAY,CAAyB,IAAI,EAAE,WAAW,CAAC;;AAE/I,IAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;;IAE1D,MAAM,YAAY,GAAG,CAAC,IAAsB,KAAK,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC;;IAGxF,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,EAAE,QAAQ,CAAC;IAE9C,QACEA,IAAC;;;;AAEC,QAAA,kBAAkB,EAAC,MAAM,EAAA,GACrB,eAAe,EACnB,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,YAAY,IAAI,IAAI;;QAE1B,UAAU,EAAE,eAAe,CAAC,UAAU,IAAI,UAAU,IAAI,QAAQ,EAAA,CAChE;AAEN;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var date = require('@internationalized/date');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Reads a form value as a calendar date without throwing, since a default value may come from an API in another shape.
|
|
7
|
+
*
|
|
8
|
+
* @param value The field's value: an ISO date (`2026-03-01`), or an ISO date-time whose date part is used.
|
|
9
|
+
* @returns The date, or `null` for an empty value or one that is not an ISO date.
|
|
10
|
+
*/
|
|
11
|
+
const toCalendarDate = (value) => {
|
|
12
|
+
if (typeof value !== 'string')
|
|
13
|
+
return null;
|
|
14
|
+
try {
|
|
15
|
+
return date.parseDate(value.slice(0, 10));
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.toCalendarDate = toCalendarDate;
|
|
23
|
+
//# sourceMappingURL=formDatePicker.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formDatePicker.utils.cjs","sources":["../../../../../../src/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.ts"],"sourcesContent":[null],"names":["parseDate"],"mappings":";;;;AAEA;;;;;AAKG;AACI,MAAM,cAAc,GAAG,CAAC,KAAgC,KAAyB;IACtF,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,IAAI;AAC1C,IAAA,IAAI;QACF,OAAOA,cAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACtC;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type CalendarDate } from '@internationalized/date';
|
|
2
|
+
/**
|
|
3
|
+
* Reads a form value as a calendar date without throwing, since a default value may come from an API in another shape.
|
|
4
|
+
*
|
|
5
|
+
* @param value The field's value: an ISO date (`2026-03-01`), or an ISO date-time whose date part is used.
|
|
6
|
+
* @returns The date, or `null` for an empty value or one that is not an ISO date.
|
|
7
|
+
*/
|
|
8
|
+
export declare const toCalendarDate: (value: string | null | undefined) => CalendarDate | null;
|
|
9
|
+
//# sourceMappingURL=formDatePicker.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formDatePicker.utils.d.ts","sourceRoot":"","sources":["../../../../../../src/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,yBAAyB,CAAC;AAEvE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,YAAY,GAAG,IAOhF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { parseDate } from '@internationalized/date';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Reads a form value as a calendar date without throwing, since a default value may come from an API in another shape.
|
|
5
|
+
*
|
|
6
|
+
* @param value The field's value: an ISO date (`2026-03-01`), or an ISO date-time whose date part is used.
|
|
7
|
+
* @returns The date, or `null` for an empty value or one that is not an ISO date.
|
|
8
|
+
*/
|
|
9
|
+
const toCalendarDate = (value) => {
|
|
10
|
+
if (typeof value !== 'string')
|
|
11
|
+
return null;
|
|
12
|
+
try {
|
|
13
|
+
return parseDate(value.slice(0, 10));
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { toCalendarDate };
|
|
21
|
+
//# sourceMappingURL=formDatePicker.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formDatePicker.utils.js","sources":["../../../../../../src/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;AAKG;AACI,MAAM,cAAc,GAAG,CAAC,KAAgC,KAAyB;IACtF,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,IAAI;AAC1C,IAAA,IAAI;QACF,OAAO,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACtC;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var Input = require('@flipdish/ui-library/components/atoms/Input');
|
|
5
|
+
var useFormField = require('../../__internal__/formField/hooks/useFormField.cjs');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* An `Input` bound to a react-hook-form field: it reads and writes the field's value, marks itself invalid and shows
|
|
9
|
+
* the field's error in place of `hint`. Use it for every text field in a form built with react-hook-form.
|
|
10
|
+
*
|
|
11
|
+
* @summary text input bound to a react-hook-form field
|
|
12
|
+
*/
|
|
13
|
+
const FormInput = ({ name, revalidates, hint, ...inputProps }) => {
|
|
14
|
+
const { value, ref, onChange, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField.useFormField(name, revalidates);
|
|
15
|
+
return (jsxRuntime.jsx(Input.Input
|
|
16
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
17
|
+
, {
|
|
18
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
19
|
+
validationBehavior: "aria", ...inputProps, ref: ref, name: name, onChange: onChange, onBlur: onBlur,
|
|
20
|
+
// An unset field is `undefined`, which would flip the input between uncontrolled and controlled.
|
|
21
|
+
value: value ?? '', isInvalid: isInvalid, hint: errorMessage ?? hint, isDisabled: inputProps.isDisabled || isDisabled,
|
|
22
|
+
// Read-only while the form submits: the field keeps its focus and its value, and nothing typed meanwhile is lost to the save.
|
|
23
|
+
isReadOnly: inputProps.isReadOnly || isLocked }));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.FormInput = FormInput;
|
|
27
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../../src/components/forms/fields/FormInput/index.tsx"],"sourcesContent":[null],"names":["useFormField","_jsx","Input"],"mappings":";;;;;;AAiBA;;;;;AAKG;AACI,MAAM,SAAS,GAAG,CAA4C,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,UAAU,EAA2B,KAAI;IAC1I,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAGA,yBAAY,CAAkB,IAAI,EAAE,WAAW,CAAC;IAExI,QACEC,eAACC;;;;AAEC,QAAA,kBAAkB,EAAC,MAAM,EAAA,GACrB,UAAU,EACd,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM;;QAEd,KAAK,EAAE,KAAK,IAAI,EAAE,EAClB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,YAAY,IAAI,IAAI,EAC1B,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,UAAU;;QAE/C,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,QAAQ,EAAA,CAC7C;AAEN;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type InputProps } from '@flipdish/ui-library/components/atoms/Input';
|
|
2
|
+
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
3
|
+
export interface FormInputProps<TValues extends FieldValues = FieldValues> extends Omit<InputProps, 'name' | 'value' | 'defaultValue' | 'onChange' | 'onBlur' | 'isInvalid' | 'ref'> {
|
|
4
|
+
/** The field's path in the form values, such as `email` or `address.city`. */
|
|
5
|
+
name: FieldPath<TValues>;
|
|
6
|
+
/**
|
|
7
|
+
* Other fields to re-validate when this changes. A `crossFieldRules` rule validated through `useSchemaResolver` names them
|
|
8
|
+
* itself, so pass this only for a rule written another way, such as a zod `superRefine` in the same schema, or for a nested field.
|
|
9
|
+
*/
|
|
10
|
+
revalidates?: FieldPath<TValues> | FieldPath<TValues>[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* An `Input` bound to a react-hook-form field: it reads and writes the field's value, marks itself invalid and shows
|
|
14
|
+
* the field's error in place of `hint`. Use it for every text field in a form built with react-hook-form.
|
|
15
|
+
*
|
|
16
|
+
* @summary text input bound to a react-hook-form field
|
|
17
|
+
*/
|
|
18
|
+
export declare const FormInput: <TValues extends FieldValues = FieldValues>({ name, revalidates, hint, ...inputProps }: FormInputProps<TValues>) => import("react").JSX.Element;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/fields/FormInput/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9D,MAAM,WAAW,cAAc,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,CACvE,SAAQ,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,WAAW,GAAG,KAAK,CAAC;IACzG,8EAA8E;IAC9E,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACzB;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;CACzD;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,SAAS,WAAW,GAAG,WAAW,EAAE,4CAA4C,cAAc,CAAC,OAAO,CAAC,gCAqBvI,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Input } from '@flipdish/ui-library/components/atoms/Input';
|
|
3
|
+
import { useFormField } from '../../__internal__/formField/hooks/useFormField.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* An `Input` bound to a react-hook-form field: it reads and writes the field's value, marks itself invalid and shows
|
|
7
|
+
* the field's error in place of `hint`. Use it for every text field in a form built with react-hook-form.
|
|
8
|
+
*
|
|
9
|
+
* @summary text input bound to a react-hook-form field
|
|
10
|
+
*/
|
|
11
|
+
const FormInput = ({ name, revalidates, hint, ...inputProps }) => {
|
|
12
|
+
const { value, ref, onChange, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField(name, revalidates);
|
|
13
|
+
return (jsx(Input
|
|
14
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
15
|
+
, {
|
|
16
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
17
|
+
validationBehavior: "aria", ...inputProps, ref: ref, name: name, onChange: onChange, onBlur: onBlur,
|
|
18
|
+
// An unset field is `undefined`, which would flip the input between uncontrolled and controlled.
|
|
19
|
+
value: value ?? '', isInvalid: isInvalid, hint: errorMessage ?? hint, isDisabled: inputProps.isDisabled || isDisabled,
|
|
20
|
+
// Read-only while the form submits: the field keeps its focus and its value, and nothing typed meanwhile is lost to the save.
|
|
21
|
+
isReadOnly: inputProps.isReadOnly || isLocked }));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { FormInput };
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/components/forms/fields/FormInput/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;AAiBA;;;;;AAKG;AACI,MAAM,SAAS,GAAG,CAA4C,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,UAAU,EAA2B,KAAI;IAC1I,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,YAAY,CAAkB,IAAI,EAAE,WAAW,CAAC;IAExI,QACEA,IAAC;;;;AAEC,QAAA,kBAAkB,EAAC,MAAM,EAAA,GACrB,UAAU,EACd,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM;;QAEd,KAAK,EAAE,KAAK,IAAI,EAAE,EAClB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,YAAY,IAAI,IAAI,EAC1B,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,UAAU;;QAE/C,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,QAAQ,EAAA,CAC7C;AAEN;;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var Select = require('@flipdish/ui-library/components/molecules/Select');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var useFocusTarget = require('../../__internal__/formField/hooks/useFocusTarget.cjs');
|
|
7
|
+
var useFormField = require('../../__internal__/formField/hooks/useFormField.cjs');
|
|
8
|
+
var multiSelect_utils = require('../../../molecules/Select/multiSelect.utils.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A `MultiSelect` bound to a react-hook-form field: every tick, Reset and Select all writes the chosen `id`s to the form
|
|
12
|
+
* as an array and validates it at once, and the field's error shows in place of `hint`. Use it when the user picks
|
|
13
|
+
* several options from a list in a react-hook-form form.
|
|
14
|
+
*
|
|
15
|
+
* @summary multi-option select bound to a react-hook-form field
|
|
16
|
+
*/
|
|
17
|
+
const FormMultiSelect = ({ name, revalidates, hint, items, children, onReset, onSelectAll, ...multiSelectProps }) => {
|
|
18
|
+
const { value, ref, onCommit, isInvalid, errorMessage, isDisabled, isLocked } = useFormField.useFormField(name, revalidates);
|
|
19
|
+
// An unset field is `undefined`, which would leave the list uncontrolled; a stable set avoids re-rendering every option.
|
|
20
|
+
const selectedKeys = React.useMemo(() => new Set(value ?? []), [value]);
|
|
21
|
+
// The same ids `MultiSelect`'s own Select all uses: from `items`, else from the static `MultiSelect.Item` children.
|
|
22
|
+
const allKeys = () => [
|
|
23
|
+
...multiSelect_utils.collectSelectableKeys(items?.map((item) => item.id), children),
|
|
24
|
+
];
|
|
25
|
+
// A react-aria `Selection` may be `'all'`, which a schema cannot validate, so it becomes the ids.
|
|
26
|
+
const handleSelectionChange = (keys) => onCommit(keys === 'all' ? allKeys() : [...keys]);
|
|
27
|
+
// A controlled `MultiSelect` leaves Reset and Select all to its parent.
|
|
28
|
+
const handleReset = () => {
|
|
29
|
+
onCommit([]);
|
|
30
|
+
onReset?.();
|
|
31
|
+
};
|
|
32
|
+
const handleSelectAll = () => {
|
|
33
|
+
onCommit(allKeys());
|
|
34
|
+
onSelectAll?.();
|
|
35
|
+
};
|
|
36
|
+
// `MultiSelect`'s ref is its wrapper div; the trigger is its only direct button child (the label's tooltip is nested).
|
|
37
|
+
const focusRef = useFocusTarget.useFocusTarget(ref, ':scope > button');
|
|
38
|
+
return (jsxRuntime.jsx(Select.MultiSelect, { ...multiSelectProps, ref: focusRef, items: items, selectedKeys: selectedKeys, onSelectionChange: handleSelectionChange, onReset: handleReset, onSelectAll: handleSelectAll, isInvalid: isInvalid, hint: errorMessage ?? hint,
|
|
39
|
+
// Disabled while the form submits, having no read-only mode: a change made meanwhile would be lost to the save.
|
|
40
|
+
isDisabled: multiSelectProps.isDisabled || isDisabled || isLocked, children: children }));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
exports.FormMultiSelect = FormMultiSelect;
|
|
44
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../../src/components/forms/fields/FormMultiSelect/index.tsx"],"sourcesContent":[null],"names":["useFormField","useMemo","collectSelectableKeys","useFocusTarget","_jsx","MultiSelect"],"mappings":";;;;;;;;;AAqBA;;;;;;AAMG;AACI,MAAM,eAAe,GAAG,CAA4C,EACzE,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,OAAO,EACP,WAAW,EACX,GAAG,gBAAgB,EACW,KAAI;IAClC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAGA,yBAAY,CAAiB,IAAI,EAAE,WAAW,CAAC;;AAE/H,IAAA,MAAM,YAAY,GAAGC,aAAO,CAAC,MAAM,IAAI,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;;AAEjE,IAAA,MAAM,OAAO,GAAG,MAAM;AACpB,QAAA,GAAGC,uCAAqB,CACtB,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC,EAC7B,QAAQ,CACT;KACF;;IAGD,MAAM,qBAAqB,GAAG,CAAC,IAAe,KAAK,QAAQ,CAAC,IAAI,KAAK,KAAK,GAAG,OAAO,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;;IAEnG,MAAM,WAAW,GAAG,MAAK;QACvB,QAAQ,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI;AACb,IAAA,CAAC;IACD,MAAM,eAAe,GAAG,MAAK;AAC3B,QAAA,QAAQ,CAAC,OAAO,EAAE,CAAC;QACnB,WAAW,IAAI;AACjB,IAAA,CAAC;;IAGD,MAAM,QAAQ,GAAGC,6BAAc,CAAC,GAAG,EAAE,iBAAiB,CAAC;AAEvD,IAAA,QACEC,cAAA,CAACC,kBAAW,EAAA,EAAA,GACN,gBAAgB,EACpB,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,EAC1B,iBAAiB,EAAE,qBAAqB,EACxC,OAAO,EAAE,WAAW,EACpB,WAAW,EAAE,eAAe,EAC5B,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,YAAY,IAAI,IAAI;;AAE1B,QAAA,UAAU,EAAE,gBAAgB,CAAC,UAAU,IAAI,UAAU,IAAI,QAAQ,EAAA,QAAA,EAEhE,QAAQ,EAAA,CACG;AAElB;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type MultiSelectProps } from '@flipdish/ui-library/components/molecules/Select';
|
|
2
|
+
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
3
|
+
export interface FormMultiSelectProps<TValues extends FieldValues = FieldValues> extends Omit<MultiSelectProps, 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'isInvalid' | 'ref'> {
|
|
4
|
+
/** The field's path in the form values, such as `cuisines` or `menu.tags`. */
|
|
5
|
+
name: FieldPath<TValues>;
|
|
6
|
+
/**
|
|
7
|
+
* Other fields to re-validate when this changes. A `crossFieldRules` rule validated through `useSchemaResolver` names them
|
|
8
|
+
* itself, so pass this only for a rule written another way, such as a zod `superRefine` in the same schema, or for a nested field.
|
|
9
|
+
*/
|
|
10
|
+
revalidates?: FieldPath<TValues> | FieldPath<TValues>[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A `MultiSelect` bound to a react-hook-form field: every tick, Reset and Select all writes the chosen `id`s to the form
|
|
14
|
+
* as an array and validates it at once, and the field's error shows in place of `hint`. Use it when the user picks
|
|
15
|
+
* several options from a list in a react-hook-form form.
|
|
16
|
+
*
|
|
17
|
+
* @summary multi-option select bound to a react-hook-form field
|
|
18
|
+
*/
|
|
19
|
+
export declare const FormMultiSelect: <TValues extends FieldValues = FieldValues>({ name, revalidates, hint, items, children, onReset, onSelectAll, ...multiSelectProps }: FormMultiSelectProps<TValues>) => import("react").JSX.Element;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/fields/FormMultiSelect/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AAGtG,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAK9D,MAAM,WAAW,oBAAoB,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,CAC7E,SAAQ,IAAI,CAAC,gBAAgB,EAAE,cAAc,GAAG,qBAAqB,GAAG,mBAAmB,GAAG,WAAW,GAAG,KAAK,CAAC;IAClH,8EAA8E;IAC9E,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACzB;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;CACzD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,SAAS,WAAW,GAAG,WAAW,EAAE,yFASxE,oBAAoB,CAAC,OAAO,CAAC,gCA4C/B,CAAC"}
|