@flipdish/ui-library 0.51.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 +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/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/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/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/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/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,72 @@
|
|
|
1
|
+
/** Whether a validation that was asked for is still wanted, read when its turn comes. */
|
|
2
|
+
type IsStillWanted = () => boolean;
|
|
3
|
+
/** A form's validations in the order they were asked for, so no answer for an older value lands after a newer one. */
|
|
4
|
+
export interface ValidationQueue {
|
|
5
|
+
/** The fields being validated now. */
|
|
6
|
+
running: string[] | null;
|
|
7
|
+
/** The fields asked for meanwhile, each with whether it is still wanted once the running validation has answered. */
|
|
8
|
+
waiting: Map<string, IsStillWanted>;
|
|
9
|
+
/** Whether the queue is being worked through, so a second ask joins the turn in hand and starts none of its own. */
|
|
10
|
+
isBusy: boolean;
|
|
11
|
+
/** A validation of a field started outside the queue, such as react-hook-form's own when the field is left, until it has answered. */
|
|
12
|
+
leaving: Map<string, Promise<unknown>>;
|
|
13
|
+
/** The answer of the validation running now, for whatever waits for the queue to go quiet. */
|
|
14
|
+
answering?: Promise<unknown> | null;
|
|
15
|
+
/** Validates the fields of one turn: the form's `trigger`, kept from the last ask. */
|
|
16
|
+
validate?: (names: string[]) => Promise<unknown>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Gives a form its validation queue, one for the whole form however many fields ask.
|
|
20
|
+
*
|
|
21
|
+
* @param control The form's `control`, which the queue is kept by and dropped with.
|
|
22
|
+
* @returns The form's queue, created on the first ask.
|
|
23
|
+
*/
|
|
24
|
+
export declare const validationQueueOf: (control: object) => ValidationQueue;
|
|
25
|
+
/**
|
|
26
|
+
* Tells whether a validation of the field is running or waiting, so an answer is still to land for a value that may be old.
|
|
27
|
+
*
|
|
28
|
+
* @param queue The form's queue.
|
|
29
|
+
* @param name The field asked about.
|
|
30
|
+
* @returns `true` while the queue has yet to answer for the field.
|
|
31
|
+
*/
|
|
32
|
+
export declare const isAwaitingAnswer: (queue: ValidationQueue, name: string) => boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Asks for fields to be validated, one validation at a time across the form. Fields asked for while one runs wait and
|
|
35
|
+
* go together in the next. Each is validated only if still wanted when its turn comes: the answer before it, or a
|
|
36
|
+
* reset, may have settled it, and validating then would put an error on a field the user is typing in or has discarded.
|
|
37
|
+
*
|
|
38
|
+
* @param queue The form's queue.
|
|
39
|
+
* @param names The fields to validate.
|
|
40
|
+
* @param isStillWanted Read for each field when its turn comes; a field asked for twice is validated if either ask still wants it.
|
|
41
|
+
* @param validate Validates the fields of a turn, as the form's `trigger` does. One that rejects leaves the errors as they were.
|
|
42
|
+
* @returns A promise that settles once the queue has nothing left it can run.
|
|
43
|
+
*/
|
|
44
|
+
export declare const runInTurn: <TName extends string>(queue: ValidationQueue, names: TName[], isStillWanted: (name: TName) => boolean, validate: (names: TName[]) => Promise<unknown>) => Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Records a validation of a field that runs outside the queue, as react-hook-form's own does when the field is left.
|
|
47
|
+
* A check waiting for that field is held back until it has answered, then taken up; no other field waits for it.
|
|
48
|
+
*
|
|
49
|
+
* @param queue The form's queue.
|
|
50
|
+
* @param name The field being validated outside the queue.
|
|
51
|
+
* @param answer That validation's promise. Anything else, or one that rejects, holds nothing back for longer than a moment.
|
|
52
|
+
*/
|
|
53
|
+
export declare const holdTurnsUntil: (queue: ValidationQueue, name: string, answer: unknown) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Withdraws what is waiting on a field whose value the user has just changed by typing. A check another field asked
|
|
56
|
+
* of it that has not begun could only raise an error mid-word, and react-hook-form drops an outside answer for the old
|
|
57
|
+
* value, so nothing is left to hold a check back for. A check already running is not stopped.
|
|
58
|
+
*
|
|
59
|
+
* @param queue The form's queue.
|
|
60
|
+
* @param name The field typed into.
|
|
61
|
+
*/
|
|
62
|
+
export declare const withdrawAsks: (queue: ValidationQueue, name: string) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Waits until no validation of the form is out: none running or waiting in the queue, and none that began outside it
|
|
65
|
+
* when a field was left. A submit waits for this, so no older answer lands after the submit's own validation.
|
|
66
|
+
*
|
|
67
|
+
* @param queue The form's queue.
|
|
68
|
+
* @returns A promise that settles once every such validation has answered; at once when none is out.
|
|
69
|
+
*/
|
|
70
|
+
export declare const whenAnswered: (queue: ValidationQueue) => Promise<void>;
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=validationQueue.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validationQueue.utils.d.ts","sourceRoot":"","sources":["../../../../../../src/components/forms/__internal__/formField/utilities/validationQueue.utils.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,KAAK,aAAa,GAAG,MAAM,OAAO,CAAC;AAEnC,sHAAsH;AACtH,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACzB,qHAAqH;IACrH,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACpC,oHAAoH;IACpH,MAAM,EAAE,OAAO,CAAC;IAChB,sIAAsI;IACtI,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACvC,8FAA8F;IAC9F,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IACpC,sFAAsF;IACtF,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAClD;AAMD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,KAAG,eASnD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,eAAe,EAAE,MAAM,MAAM,KAAG,OAA4E,CAAC;AA8BrJ;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,SAAS,MAAM,EAC5C,OAAO,eAAe,EACtB,OAAO,KAAK,EAAE,EACd,eAAe,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,EACvC,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,KAC7C,OAAO,CAAC,IAAI,CAQd,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,eAAe,EAAE,MAAM,MAAM,EAAE,QAAQ,OAAO,KAAG,IAOtF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,eAAe,EAAE,MAAM,MAAM,KAAG,IAGnE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAU,OAAO,eAAe,KAAG,OAAO,CAAC,IAAI,CAGvE,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// Kept by the form's `control`: a field's own validation and one asked for by a field that re-validates it would
|
|
2
|
+
// otherwise run side by side, and the answer for the older value could land last.
|
|
3
|
+
const queues = new WeakMap();
|
|
4
|
+
/**
|
|
5
|
+
* Gives a form its validation queue, one for the whole form however many fields ask.
|
|
6
|
+
*
|
|
7
|
+
* @param control The form's `control`, which the queue is kept by and dropped with.
|
|
8
|
+
* @returns The form's queue, created on the first ask.
|
|
9
|
+
*/
|
|
10
|
+
const validationQueueOf = (control) => {
|
|
11
|
+
const queue = queues.get(control) ?? {
|
|
12
|
+
running: null,
|
|
13
|
+
waiting: new Map(),
|
|
14
|
+
isBusy: false,
|
|
15
|
+
leaving: new Map(),
|
|
16
|
+
};
|
|
17
|
+
queues.set(control, queue);
|
|
18
|
+
return queue;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Tells whether a validation of the field is running or waiting, so an answer is still to land for a value that may be old.
|
|
22
|
+
*
|
|
23
|
+
* @param queue The form's queue.
|
|
24
|
+
* @param name The field asked about.
|
|
25
|
+
* @returns `true` while the queue has yet to answer for the field.
|
|
26
|
+
*/
|
|
27
|
+
const isAwaitingAnswer = (queue, name) => Boolean(queue.running?.includes(name) || queue.waiting.has(name));
|
|
28
|
+
// One validation at a time: with an async schema, an older answer landing last would leave a stale error on a newer value.
|
|
29
|
+
const workThrough = async (queue) => {
|
|
30
|
+
if (queue.isBusy)
|
|
31
|
+
return;
|
|
32
|
+
queue.isBusy = true;
|
|
33
|
+
try {
|
|
34
|
+
// A field is held back while an answer from outside the queue is out for it: that answer is for an older value, and
|
|
35
|
+
// landing last it would be the last word. Only that field waits, so an answer that never comes holds up no other.
|
|
36
|
+
const takeReady = () => [...queue.waiting].filter(([name]) => !queue.leaving.has(name));
|
|
37
|
+
for (let ready = takeReady(); ready.length > 0; ready = takeReady()) {
|
|
38
|
+
for (const [name] of ready)
|
|
39
|
+
queue.waiting.delete(name);
|
|
40
|
+
const due = ready.filter(([, isWanted]) => isWanted()).map(([name]) => name);
|
|
41
|
+
if (due.length > 0) {
|
|
42
|
+
queue.running = due;
|
|
43
|
+
// A resolver that throws, such as an async check whose request failed, leaves the errors as they were, and the
|
|
44
|
+
// batch waiting behind it still runs: one failed validation must not stop the field re-validating.
|
|
45
|
+
queue.answering = queue.validate?.(due).catch(() => { });
|
|
46
|
+
await queue.answering;
|
|
47
|
+
queue.running = null;
|
|
48
|
+
queue.answering = null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
queue.running = null;
|
|
54
|
+
queue.answering = null;
|
|
55
|
+
queue.isBusy = false;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Asks for fields to be validated, one validation at a time across the form. Fields asked for while one runs wait and
|
|
60
|
+
* go together in the next. Each is validated only if still wanted when its turn comes: the answer before it, or a
|
|
61
|
+
* reset, may have settled it, and validating then would put an error on a field the user is typing in or has discarded.
|
|
62
|
+
*
|
|
63
|
+
* @param queue The form's queue.
|
|
64
|
+
* @param names The fields to validate.
|
|
65
|
+
* @param isStillWanted Read for each field when its turn comes; a field asked for twice is validated if either ask still wants it.
|
|
66
|
+
* @param validate Validates the fields of a turn, as the form's `trigger` does. One that rejects leaves the errors as they were.
|
|
67
|
+
* @returns A promise that settles once the queue has nothing left it can run.
|
|
68
|
+
*/
|
|
69
|
+
const runInTurn = (queue, names, isStillWanted, validate) => {
|
|
70
|
+
for (const name of names) {
|
|
71
|
+
const earlier = queue.waiting.get(name);
|
|
72
|
+
const wanted = () => isStillWanted(name);
|
|
73
|
+
queue.waiting.set(name, earlier ? () => earlier() || wanted() : wanted);
|
|
74
|
+
}
|
|
75
|
+
queue.validate = validate;
|
|
76
|
+
return workThrough(queue);
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Records a validation of a field that runs outside the queue, as react-hook-form's own does when the field is left.
|
|
80
|
+
* A check waiting for that field is held back until it has answered, then taken up; no other field waits for it.
|
|
81
|
+
*
|
|
82
|
+
* @param queue The form's queue.
|
|
83
|
+
* @param name The field being validated outside the queue.
|
|
84
|
+
* @param answer That validation's promise. Anything else, or one that rejects, holds nothing back for longer than a moment.
|
|
85
|
+
*/
|
|
86
|
+
const holdTurnsUntil = (queue, name, answer) => {
|
|
87
|
+
const release = () => {
|
|
88
|
+
if (queue.leaving.get(name) === answered)
|
|
89
|
+
queue.leaving.delete(name);
|
|
90
|
+
void workThrough(queue);
|
|
91
|
+
};
|
|
92
|
+
const answered = Promise.allSettled([queue.leaving.get(name), answer]).then(release);
|
|
93
|
+
queue.leaving.set(name, answered);
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Withdraws what is waiting on a field whose value the user has just changed by typing. A check another field asked
|
|
97
|
+
* of it that has not begun could only raise an error mid-word, and react-hook-form drops an outside answer for the old
|
|
98
|
+
* value, so nothing is left to hold a check back for. A check already running is not stopped.
|
|
99
|
+
*
|
|
100
|
+
* @param queue The form's queue.
|
|
101
|
+
* @param name The field typed into.
|
|
102
|
+
*/
|
|
103
|
+
const withdrawAsks = (queue, name) => {
|
|
104
|
+
queue.waiting.delete(name);
|
|
105
|
+
queue.leaving.delete(name);
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Waits until no validation of the form is out: none running or waiting in the queue, and none that began outside it
|
|
109
|
+
* when a field was left. A submit waits for this, so no older answer lands after the submit's own validation.
|
|
110
|
+
*
|
|
111
|
+
* @param queue The form's queue.
|
|
112
|
+
* @returns A promise that settles once every such validation has answered; at once when none is out.
|
|
113
|
+
*/
|
|
114
|
+
const whenAnswered = async (queue) => {
|
|
115
|
+
// Each answer may let a check that was held back begin, so it looks again until nothing is out.
|
|
116
|
+
while (queue.answering || queue.leaving.size > 0)
|
|
117
|
+
await Promise.allSettled([queue.answering, ...queue.leaving.values()]);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export { holdTurnsUntil, isAwaitingAnswer, runInTurn, validationQueueOf, whenAnswered, withdrawAsks };
|
|
121
|
+
//# sourceMappingURL=validationQueue.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validationQueue.utils.js","sources":["../../../../../../src/components/forms/__internal__/formField/utilities/validationQueue.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAmBA;AACA;AACA,MAAM,MAAM,GAAG,IAAI,OAAO,EAA2B;AAErD;;;;;AAKG;AACI,MAAM,iBAAiB,GAAG,CAAC,OAAe,KAAqB;IACpE,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI;AACnC,QAAA,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,IAAI,GAAG,EAAyB;AACzC,QAAA,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,IAAI,GAAG,EAA4B;KAC7C;AACD,IAAA,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC;AAC1B,IAAA,OAAO,KAAK;AACd;AAEA;;;;;;AAMG;AACI,MAAM,gBAAgB,GAAG,CAAC,KAAsB,EAAE,IAAY,KAAc,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;AAEnJ;AACA,MAAM,WAAW,GAAG,OAAO,KAAsB,KAAI;IACnD,IAAI,KAAK,CAAC,MAAM;QAAE;AAClB,IAAA,KAAK,CAAC,MAAM,GAAG,IAAI;AACnB,IAAA,IAAI;;;AAGF,QAAA,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACvF,QAAA,KAAK,IAAI,KAAK,GAAG,SAAS,EAAE,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,EAAE,EAAE;AACnE,YAAA,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK;AAAE,gBAAA,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;AACtD,YAAA,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;AAC5E,YAAA,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE;AAClB,gBAAA,KAAK,CAAC,OAAO,GAAG,GAAG;;;AAGnB,gBAAA,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,MAAK,EAAE,CAAC,CAAC;gBACvD,MAAM,KAAK,CAAC,SAAS;AACrB,gBAAA,KAAK,CAAC,OAAO,GAAG,IAAI;AACpB,gBAAA,KAAK,CAAC,SAAS,GAAG,IAAI;YACxB;QACF;IACF;YAAU;AACR,QAAA,KAAK,CAAC,OAAO,GAAG,IAAI;AACpB,QAAA,KAAK,CAAC,SAAS,GAAG,IAAI;AACtB,QAAA,KAAK,CAAC,MAAM,GAAG,KAAK;IACtB;AACF,CAAC;AAED;;;;;;;;;;AAUG;AACI,MAAM,SAAS,GAAG,CACvB,KAAsB,EACtB,KAAc,EACd,aAAuC,EACvC,QAA8C,KAC7B;AACjB,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;QACvC,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC;QACxC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,OAAO,EAAE,IAAI,MAAM,EAAE,GAAG,MAAM,CAAC;IACzE;AACA,IAAA,KAAK,CAAC,QAAQ,GAAG,QAAiD;AAClE,IAAA,OAAO,WAAW,CAAC,KAAK,CAAC;AAC3B;AAEA;;;;;;;AAOG;AACI,MAAM,cAAc,GAAG,CAAC,KAAsB,EAAE,IAAY,EAAE,MAAe,KAAU;IAC5F,MAAM,OAAO,GAAG,MAAK;QACnB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,QAAQ;AAAE,YAAA,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;AACpE,QAAA,KAAK,WAAW,CAAC,KAAK,CAAC;AACzB,IAAA,CAAC;IACD,MAAM,QAAQ,GAAqB,OAAO,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IACtG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC;AACnC;AAEA;;;;;;;AAOG;MACU,YAAY,GAAG,CAAC,KAAsB,EAAE,IAAY,KAAU;AACzE,IAAA,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;AAC1B,IAAA,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;AAC5B;AAEA;;;;;;AAMG;MACU,YAAY,GAAG,OAAO,KAAsB,KAAmB;;IAE1E,OAAO,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC;AAAE,QAAA,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAC1H;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var Checkbox = require('@flipdish/ui-library/components/atoms/Checkbox');
|
|
5
|
+
var useFocusTarget = require('../../__internal__/formField/hooks/useFocusTarget.cjs');
|
|
6
|
+
var useFormField = require('../../__internal__/formField/hooks/useFormField.cjs');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A `Checkbox` bound to a react-hook-form field: ticking it writes a boolean to the form and validates it at once, and
|
|
10
|
+
* the field's error shows in place of `hint`. Use it for a single yes or no choice in a form built with react-hook-form.
|
|
11
|
+
*
|
|
12
|
+
* @summary checkbox bound to a react-hook-form field
|
|
13
|
+
*/
|
|
14
|
+
const FormCheckbox = ({ name, revalidates, hint, ...checkboxProps }) => {
|
|
15
|
+
const { value, ref, onCommit, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField.useFormField(name, revalidates);
|
|
16
|
+
// `Checkbox`'s ref is its `<label>`, which cannot take focus, so the form is handed the input inside it.
|
|
17
|
+
const focusRef = useFocusTarget.useFocusTarget(ref, 'input');
|
|
18
|
+
return (jsxRuntime.jsx(Checkbox.Checkbox
|
|
19
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
20
|
+
, {
|
|
21
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
22
|
+
validationBehavior: "aria", ...checkboxProps, ref: focusRef, name: name,
|
|
23
|
+
// An unset field is `undefined`, which would flip the checkbox between uncontrolled and controlled.
|
|
24
|
+
isSelected: value ?? false, onChange: onCommit, onBlur: onBlur, isInvalid: isInvalid, isDisabled: checkboxProps.isDisabled || isDisabled,
|
|
25
|
+
// Read-only while the form submits: the field keeps its focus and its value, and nothing typed meanwhile is lost to the save.
|
|
26
|
+
isReadOnly: checkboxProps.isReadOnly || isLocked,
|
|
27
|
+
// The control gives its hint no error colour, so the message brings its own.
|
|
28
|
+
hint: errorMessage ? (
|
|
29
|
+
// An alert, since the error can appear while focus stays on the control, where a changed label is not announced.
|
|
30
|
+
jsxRuntime.jsx("span", { role: "alert", className: "text-error-primary", children: errorMessage })) : (hint) }));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.FormCheckbox = FormCheckbox;
|
|
34
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../../src/components/forms/fields/FormCheckbox/index.tsx"],"sourcesContent":[null],"names":["useFormField","useFocusTarget","_jsx","Checkbox"],"mappings":";;;;;;;AAeA;;;;;AAKG;AACI,MAAM,YAAY,GAAG,CAA4C,EACtE,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,GAAG,aAAa,EACW,KAAI;IAC/B,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAGA,yBAAY,CAAmB,IAAI,EAAE,WAAW,CAAC;;IAEzI,MAAM,QAAQ,GAAGC,6BAAc,CAAC,GAAG,EAAE,OAAO,CAAC;IAE7C,QACEC,eAACC;;;;QAEC,kBAAkB,EAAC,MAAM,EAAA,GACrB,aAAa,EACjB,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,IAAI;;QAEV,UAAU,EAAE,KAAK,IAAI,KAAK,EAC1B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,aAAa,CAAC,UAAU,IAAI,UAAU;;AAElD,QAAA,UAAU,EAAE,aAAa,CAAC,UAAU,IAAI,QAAQ;;AAEhD,QAAA,IAAI,EACF,YAAY;;AAEV,QAAAD,cAAA,CAAA,MAAA,EAAA,EAAM,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAC9C,YAAY,GACR,KAEP,IAAI,CACL,EAAA,CAEH;AAEN;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type CheckboxProps } from '@flipdish/ui-library/components/atoms/Checkbox';
|
|
2
|
+
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
3
|
+
export interface FormCheckboxProps<TValues extends FieldValues = FieldValues> extends Omit<CheckboxProps, 'name' | 'isSelected' | 'defaultSelected' | 'onChange' | 'onBlur' | 'isInvalid' | 'ref'> {
|
|
4
|
+
/** The field's path in the form values, such as `acceptTerms` or `marketing.email`. */
|
|
5
|
+
name: FieldPath<TValues>;
|
|
6
|
+
/** Other fields whose rule reads this one, such as a postcode that depends on this country; they re-validate when this changes. */
|
|
7
|
+
revalidates?: FieldPath<TValues> | FieldPath<TValues>[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A `Checkbox` bound to a react-hook-form field: ticking it writes a boolean to the form and validates it at once, and
|
|
11
|
+
* the field's error shows in place of `hint`. Use it for a single yes or no choice in a form built with react-hook-form.
|
|
12
|
+
*
|
|
13
|
+
* @summary checkbox bound to a react-hook-form field
|
|
14
|
+
*/
|
|
15
|
+
export declare const FormCheckbox: <TValues extends FieldValues = FieldValues>({ name, revalidates, hint, ...checkboxProps }: FormCheckboxProps<TValues>) => import("react").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/fields/FormCheckbox/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAC9F,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAI9D,MAAM,WAAW,iBAAiB,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,CAC1E,SAAQ,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,YAAY,GAAG,iBAAiB,GAAG,UAAU,GAAG,QAAQ,GAAG,WAAW,GAAG,KAAK,CAAC;IACpH,uFAAuF;IACvF,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACzB,mIAAmI;IACnI,WAAW,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;CACzD;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,SAAS,WAAW,GAAG,WAAW,EAAE,+CAKrE,iBAAiB,CAAC,OAAO,CAAC,gCAiC5B,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Checkbox } from '@flipdish/ui-library/components/atoms/Checkbox';
|
|
3
|
+
import { useFocusTarget } from '../../__internal__/formField/hooks/useFocusTarget.js';
|
|
4
|
+
import { useFormField } from '../../__internal__/formField/hooks/useFormField.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A `Checkbox` bound to a react-hook-form field: ticking it writes a boolean to the form and validates it at once, and
|
|
8
|
+
* the field's error shows in place of `hint`. Use it for a single yes or no choice in a form built with react-hook-form.
|
|
9
|
+
*
|
|
10
|
+
* @summary checkbox bound to a react-hook-form field
|
|
11
|
+
*/
|
|
12
|
+
const FormCheckbox = ({ name, revalidates, hint, ...checkboxProps }) => {
|
|
13
|
+
const { value, ref, onCommit, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField(name, revalidates);
|
|
14
|
+
// `Checkbox`'s ref is its `<label>`, which cannot take focus, so the form is handed the input inside it.
|
|
15
|
+
const focusRef = useFocusTarget(ref, 'input');
|
|
16
|
+
return (jsx(Checkbox
|
|
17
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
18
|
+
, {
|
|
19
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
20
|
+
validationBehavior: "aria", ...checkboxProps, ref: focusRef, name: name,
|
|
21
|
+
// An unset field is `undefined`, which would flip the checkbox between uncontrolled and controlled.
|
|
22
|
+
isSelected: value ?? false, onChange: onCommit, onBlur: onBlur, isInvalid: isInvalid, isDisabled: checkboxProps.isDisabled || isDisabled,
|
|
23
|
+
// Read-only while the form submits: the field keeps its focus and its value, and nothing typed meanwhile is lost to the save.
|
|
24
|
+
isReadOnly: checkboxProps.isReadOnly || isLocked,
|
|
25
|
+
// The control gives its hint no error colour, so the message brings its own.
|
|
26
|
+
hint: errorMessage ? (
|
|
27
|
+
// An alert, since the error can appear while focus stays on the control, where a changed label is not announced.
|
|
28
|
+
jsx("span", { role: "alert", className: "text-error-primary", children: errorMessage })) : (hint) }));
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { FormCheckbox };
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/components/forms/fields/FormCheckbox/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;AAeA;;;;;AAKG;AACI,MAAM,YAAY,GAAG,CAA4C,EACtE,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,GAAG,aAAa,EACW,KAAI;IAC/B,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,YAAY,CAAmB,IAAI,EAAE,WAAW,CAAC;;IAEzI,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC;IAE7C,QACEA,IAAC;;;;QAEC,kBAAkB,EAAC,MAAM,EAAA,GACrB,aAAa,EACjB,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,IAAI;;QAEV,UAAU,EAAE,KAAK,IAAI,KAAK,EAC1B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,aAAa,CAAC,UAAU,IAAI,UAAU;;AAElD,QAAA,UAAU,EAAE,aAAa,CAAC,UAAU,IAAI,QAAQ;;AAEhD,QAAA,IAAI,EACF,YAAY;;AAEV,QAAAA,GAAA,CAAA,MAAA,EAAA,EAAM,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAC9C,YAAY,GACR,KAEP,IAAI,CACL,EAAA,CAEH;AAEN;;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var Checkbox = require('@flipdish/ui-library/components/atoms/Checkbox');
|
|
5
|
+
var useFocusTarget = require('../../__internal__/formField/hooks/useFocusTarget.cjs');
|
|
6
|
+
var useFormField = require('../../__internal__/formField/hooks/useFormField.cjs');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A `CheckboxGroup` bound to a react-hook-form field: ticking a box writes the list of ticked values to the form and
|
|
10
|
+
* validates it at once, and the field's error shows in place of `hint`. Use it when the user ticks any number of a few visible options.
|
|
11
|
+
*
|
|
12
|
+
* @summary checkbox group bound to a react-hook-form list field
|
|
13
|
+
*/
|
|
14
|
+
const FormCheckboxGroup = ({ name, revalidates, hint, children, ...groupProps }) => {
|
|
15
|
+
const { value, ref, onCommit, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField.useFormField(name, revalidates);
|
|
16
|
+
// `CheckboxGroup` takes no ref, so a layout-neutral wrapper hands the form the first box.
|
|
17
|
+
const focusRef = useFocusTarget.useFocusTarget(ref, 'input:not(:disabled)');
|
|
18
|
+
return (jsxRuntime.jsx("div", { ref: focusRef, className: "contents", children: jsxRuntime.jsx(Checkbox.CheckboxGroup
|
|
19
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
20
|
+
, {
|
|
21
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
22
|
+
validationBehavior: "aria", ...groupProps, name: name,
|
|
23
|
+
// An unset field is `undefined`, which would flip the group between uncontrolled and controlled.
|
|
24
|
+
value: value ?? [], onChange: onCommit, onBlur: onBlur, isInvalid: isInvalid, isDisabled: groupProps.isDisabled || isDisabled,
|
|
25
|
+
// Read-only while the form submits: the boxes keep their focus and their ticks, and nothing changed meanwhile is lost to the save.
|
|
26
|
+
isReadOnly: groupProps.isReadOnly || isLocked,
|
|
27
|
+
// Linked to every box, so it is read wherever a failed submit lands focus; an alert too, since unticking the last box
|
|
28
|
+
// shows it while focus stays on that box, where a changed description is not announced.
|
|
29
|
+
hint: errorMessage ? jsxRuntime.jsx("span", { role: "alert", children: errorMessage }) : hint, children: children }) }));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.FormCheckboxGroup = FormCheckboxGroup;
|
|
33
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../../src/components/forms/fields/FormCheckboxGroup/index.tsx"],"sourcesContent":[null],"names":["useFormField","useFocusTarget","_jsx","CheckboxGroup"],"mappings":";;;;;;;AAeA;;;;;AAKG;AACI,MAAM,iBAAiB,GAAG,CAA4C,EAC3E,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,GAAG,UAAU,EACmB,KAAI;IACpC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAGA,yBAAY,CAAoB,IAAI,EAAE,WAAW,CAAC;;IAE1I,MAAM,QAAQ,GAAGC,6BAAc,CAAC,GAAG,EAAE,sBAAsB,CAAC;IAE5D,QACEC,cAAA,CAAA,KAAA,EAAA,EAAK,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAC,UAAU,EAAA,QAAA,EACtCA,cAAA,CAACC;;;;AAEC,YAAA,kBAAkB,EAAC,MAAM,EAAA,GACrB,UAAU,EACd,IAAI,EAAE,IAAI;;YAEV,KAAK,EAAE,KAAK,IAAI,EAAE,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,UAAU;;AAE/C,YAAA,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,QAAQ;;;YAG7C,IAAI,EAAE,YAAY,GAAGD,cAAA,CAAA,MAAA,EAAA,EAAM,IAAI,EAAC,OAAO,EAAA,QAAA,EAAE,YAAY,EAAA,CAAQ,GAAG,IAAI,YAEnE,QAAQ,EAAA,CACK,EAAA,CACZ;AAEV;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type CheckboxGroupProps } from '@flipdish/ui-library/components/atoms/Checkbox';
|
|
2
|
+
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
3
|
+
export interface FormCheckboxGroupProps<TValues extends FieldValues = FieldValues> extends Omit<CheckboxGroupProps, 'name' | 'value' | 'defaultValue' | 'onChange' | 'onBlur' | 'isInvalid'> {
|
|
4
|
+
/** The field's path in the form values, such as `orderTypes` or `delivery.days`; the field holds a list of the ticked values. */
|
|
5
|
+
name: FieldPath<TValues>;
|
|
6
|
+
/** Other fields whose rule reads this one, such as a postcode that depends on this country; they re-validate when this changes. */
|
|
7
|
+
revalidates?: FieldPath<TValues> | FieldPath<TValues>[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A `CheckboxGroup` bound to a react-hook-form field: ticking a box writes the list of ticked values to the form and
|
|
11
|
+
* validates it at once, and the field's error shows in place of `hint`. Use it when the user ticks any number of a few visible options.
|
|
12
|
+
*
|
|
13
|
+
* @summary checkbox group bound to a react-hook-form list field
|
|
14
|
+
*/
|
|
15
|
+
export declare const FormCheckboxGroup: <TValues extends FieldValues = FieldValues>({ name, revalidates, hint, children, ...groupProps }: FormCheckboxGroupProps<TValues>) => import("react").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/fields/FormCheckboxGroup/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AACxG,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAI9D,MAAM,WAAW,sBAAsB,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,CAC/E,SAAQ,IAAI,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,WAAW,CAAC;IACzG,iIAAiI;IACjI,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACzB,mIAAmI;IACnI,WAAW,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;CACzD;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,SAAS,WAAW,GAAG,WAAW,EAAE,sDAM1E,sBAAsB,CAAC,OAAO,CAAC,gCA4BjC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { CheckboxGroup } from '@flipdish/ui-library/components/atoms/Checkbox';
|
|
3
|
+
import { useFocusTarget } from '../../__internal__/formField/hooks/useFocusTarget.js';
|
|
4
|
+
import { useFormField } from '../../__internal__/formField/hooks/useFormField.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A `CheckboxGroup` bound to a react-hook-form field: ticking a box writes the list of ticked values to the form and
|
|
8
|
+
* validates it at once, and the field's error shows in place of `hint`. Use it when the user ticks any number of a few visible options.
|
|
9
|
+
*
|
|
10
|
+
* @summary checkbox group bound to a react-hook-form list field
|
|
11
|
+
*/
|
|
12
|
+
const FormCheckboxGroup = ({ name, revalidates, hint, children, ...groupProps }) => {
|
|
13
|
+
const { value, ref, onCommit, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField(name, revalidates);
|
|
14
|
+
// `CheckboxGroup` takes no ref, so a layout-neutral wrapper hands the form the first box.
|
|
15
|
+
const focusRef = useFocusTarget(ref, 'input:not(:disabled)');
|
|
16
|
+
return (jsx("div", { ref: focusRef, className: "contents", children: jsx(CheckboxGroup
|
|
17
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
18
|
+
, {
|
|
19
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
20
|
+
validationBehavior: "aria", ...groupProps, name: name,
|
|
21
|
+
// An unset field is `undefined`, which would flip the group between uncontrolled and controlled.
|
|
22
|
+
value: value ?? [], onChange: onCommit, onBlur: onBlur, isInvalid: isInvalid, isDisabled: groupProps.isDisabled || isDisabled,
|
|
23
|
+
// Read-only while the form submits: the boxes keep their focus and their ticks, and nothing changed meanwhile is lost to the save.
|
|
24
|
+
isReadOnly: groupProps.isReadOnly || isLocked,
|
|
25
|
+
// Linked to every box, so it is read wherever a failed submit lands focus; an alert too, since unticking the last box
|
|
26
|
+
// shows it while focus stays on that box, where a changed description is not announced.
|
|
27
|
+
hint: errorMessage ? jsx("span", { role: "alert", children: errorMessage }) : hint, children: children }) }));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { FormCheckboxGroup };
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/components/forms/fields/FormCheckboxGroup/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;AAeA;;;;;AAKG;AACI,MAAM,iBAAiB,GAAG,CAA4C,EAC3E,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,GAAG,UAAU,EACmB,KAAI;IACpC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,YAAY,CAAoB,IAAI,EAAE,WAAW,CAAC;;IAE1I,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,EAAE,sBAAsB,CAAC;IAE5D,QACEA,GAAA,CAAA,KAAA,EAAA,EAAK,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAC,UAAU,EAAA,QAAA,EACtCA,GAAA,CAAC;;;;AAEC,YAAA,kBAAkB,EAAC,MAAM,EAAA,GACrB,UAAU,EACd,IAAI,EAAE,IAAI;;YAEV,KAAK,EAAE,KAAK,IAAI,EAAE,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,UAAU;;AAE/C,YAAA,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,QAAQ;;;YAG7C,IAAI,EAAE,YAAY,GAAGA,GAAA,CAAA,MAAA,EAAA,EAAM,IAAI,EAAC,OAAO,EAAA,QAAA,EAAE,YAAY,EAAA,CAAQ,GAAG,IAAI,YAEnE,QAAQ,EAAA,CACK,EAAA,CACZ;AAEV;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var formColorPicker_utils = require('../utilities/formColorPicker.utils.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Gives a colour field the value to write when it is emptied: the empty value the form itself uses for it, such as
|
|
8
|
+
* `undefined` for a field with no default or `''` for one an API sends empty. The picker reports an emptied field as
|
|
9
|
+
* `null`, which would leave a field the user put back as it was looking edited.
|
|
10
|
+
*
|
|
11
|
+
* @param name The field's name. A change of name starts again, so one field's empty value is never written to another.
|
|
12
|
+
* @param value The field's current value.
|
|
13
|
+
* @returns A function from the value the picker reports to the value the field should hold.
|
|
14
|
+
*/
|
|
15
|
+
const useEmptyFieldValue = (name, value) => {
|
|
16
|
+
const remembered = React.useRef({ name, value: null });
|
|
17
|
+
// Noted whenever the value changes, not only on a pick: the app may fill an empty field itself, and Remove must
|
|
18
|
+
// still write what empty was.
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
remembered.current = formColorPicker_utils.rememberEmptyValue(remembered.current, name, value);
|
|
21
|
+
}, [name, value]);
|
|
22
|
+
return React.useCallback((next) => next ?? formColorPicker_utils.rememberEmptyValue(remembered.current, name, value).value, [name, value]);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.useEmptyFieldValue = useEmptyFieldValue;
|
|
26
|
+
//# sourceMappingURL=useEmptyFieldValue.cjs.map
|
|
@@ -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":";;;;;;;;;AAwBA;;;;;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,21 @@
|
|
|
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
|
+
/** Other fields whose rule reads this one, such as a second colour that must differ from this one; they re-validate when this changes. */
|
|
8
|
+
revalidates?: FieldPath<TValues> | FieldPath<TValues>[];
|
|
9
|
+
/** Overrides the root `data-testid` (defaults to `fd-form-color-picker`); the trigger, Remove button and picker derive from it. */
|
|
10
|
+
'data-testid'?: string;
|
|
11
|
+
}
|
|
12
|
+
export type FormColorPickerProps<TValues extends FieldValues = FieldValues> = FormColorPickerBindingProps<TValues> & OmitFromEach<ColorPickerFieldProps, 'value' | 'onChange' | 'onChangeEnd' | 'onBlur' | 'isInvalid' | 'ref' | 'data-testid'>;
|
|
13
|
+
/**
|
|
14
|
+
* `ColorPicker.Field` bound to a react-hook-form field: the trigger shows the field's colour and opens the picker, the field
|
|
15
|
+
* 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.
|
|
16
|
+
*
|
|
17
|
+
* @summary colour picker bound to a react-hook-form field
|
|
18
|
+
*/
|
|
19
|
+
export declare const FormColorPicker: <TValues extends FieldValues = FieldValues>({ name, revalidates, hint, "data-testid": dataTestId, ...fieldProps }: FormColorPickerProps<TValues>) => import("react").JSX.Element;
|
|
20
|
+
export {};
|
|
21
|
+
//# 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,0IAA0I;IAC1I,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":";;;;;;;AAwBA;;;;;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
|