@flipdish/ui-library 0.49.0 → 0.51.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/dist/components/atoms/Button/components/ButtonIcon.cjs +17 -0
- package/dist/components/atoms/Button/components/ButtonIcon.cjs.map +1 -0
- package/dist/components/atoms/Button/components/ButtonIcon.d.ts +14 -0
- package/dist/components/atoms/Button/components/ButtonIcon.d.ts.map +1 -0
- package/dist/components/atoms/Button/components/ButtonIcon.js +15 -0
- package/dist/components/atoms/Button/components/ButtonIcon.js.map +1 -0
- package/dist/components/atoms/Button/components/ButtonSpinner.cjs +11 -0
- package/dist/components/atoms/Button/components/ButtonSpinner.cjs.map +1 -0
- package/dist/components/atoms/Button/components/ButtonSpinner.d.ts +8 -0
- package/dist/components/atoms/Button/components/ButtonSpinner.d.ts.map +1 -0
- package/dist/components/atoms/Button/components/ButtonSpinner.js +9 -0
- package/dist/components/atoms/Button/components/ButtonSpinner.js.map +1 -0
- package/dist/components/atoms/Button/index.cjs +6 -6
- package/dist/components/atoms/Button/index.cjs.map +1 -1
- package/dist/components/atoms/Button/index.d.ts +2 -0
- package/dist/components/atoms/Button/index.d.ts.map +1 -1
- package/dist/components/atoms/Button/index.js +6 -6
- package/dist/components/atoms/Button/index.js.map +1 -1
- package/dist/components/atoms/Checkbox/index.cjs +28 -2
- package/dist/components/atoms/Checkbox/index.cjs.map +1 -1
- package/dist/components/atoms/Checkbox/index.d.ts +23 -4
- package/dist/components/atoms/Checkbox/index.d.ts.map +1 -1
- package/dist/components/atoms/Checkbox/index.js +30 -5
- package/dist/components/atoms/Checkbox/index.js.map +1 -1
- package/dist/components/atoms/Input/index.cjs +0 -1
- package/dist/components/atoms/Input/index.cjs.map +1 -1
- package/dist/components/atoms/Input/index.d.ts.map +1 -1
- package/dist/components/atoms/Input/index.js +0 -1
- package/dist/components/atoms/Input/index.js.map +1 -1
- package/dist/components/atoms/RadioButton/index.cjs.map +1 -1
- package/dist/components/atoms/RadioButton/index.d.ts +1 -0
- package/dist/components/atoms/RadioButton/index.d.ts.map +1 -1
- package/dist/components/atoms/RadioButton/index.js.map +1 -1
- package/dist/components/atoms/Slider/index.cjs +9 -3
- 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 +10 -4
- package/dist/components/atoms/Slider/index.js.map +1 -1
- package/dist/components/atoms/Toggle/index.cjs +6 -2
- package/dist/components/atoms/Toggle/index.cjs.map +1 -1
- package/dist/components/atoms/Toggle/index.d.ts.map +1 -1
- package/dist/components/atoms/Toggle/index.js +6 -2
- package/dist/components/atoms/Toggle/index.js.map +1 -1
- package/dist/components/molecules/Alert/index.cjs +5 -25
- package/dist/components/molecules/Alert/index.cjs.map +1 -1
- package/dist/components/molecules/Alert/index.d.ts +9 -94
- package/dist/components/molecules/Alert/index.d.ts.map +1 -1
- package/dist/components/molecules/Alert/index.js +5 -25
- package/dist/components/molecules/Alert/index.js.map +1 -1
- package/dist/components/molecules/Alerts/components/Alert.cjs +39 -0
- package/dist/components/molecules/Alerts/components/Alert.cjs.map +1 -0
- package/dist/components/molecules/Alerts/components/Alert.d.ts +104 -0
- package/dist/components/molecules/Alerts/components/Alert.d.ts.map +1 -0
- package/dist/components/molecules/Alerts/components/Alert.js +36 -0
- package/dist/components/molecules/Alerts/components/Alert.js.map +1 -0
- package/dist/components/molecules/Alerts/components/SaveErrorAlert.cjs +26 -0
- package/dist/components/molecules/Alerts/components/SaveErrorAlert.cjs.map +1 -0
- package/dist/components/molecules/Alerts/components/SaveErrorAlert.d.ts +25 -0
- package/dist/components/molecules/Alerts/components/SaveErrorAlert.d.ts.map +1 -0
- package/dist/components/molecules/Alerts/components/SaveErrorAlert.js +24 -0
- package/dist/components/molecules/Alerts/components/SaveErrorAlert.js.map +1 -0
- package/dist/components/molecules/Alerts/hooks/useAlertActions.cjs +26 -0
- package/dist/components/molecules/Alerts/hooks/useAlertActions.cjs.map +1 -0
- package/dist/components/molecules/Alerts/hooks/useAlertActions.d.ts +13 -0
- package/dist/components/molecules/Alerts/hooks/useAlertActions.d.ts.map +1 -0
- package/dist/components/molecules/Alerts/hooks/useAlertActions.js +24 -0
- package/dist/components/molecules/Alerts/hooks/useAlertActions.js.map +1 -0
- package/dist/components/molecules/Alerts/index.cjs +11 -0
- package/dist/components/molecules/Alerts/index.cjs.map +1 -0
- package/dist/components/molecules/Alerts/index.d.ts +12 -0
- package/dist/components/molecules/Alerts/index.d.ts.map +1 -0
- package/dist/components/molecules/Alerts/index.js +3 -0
- package/dist/components/molecules/Alerts/index.js.map +1 -0
- package/dist/components/molecules/EmptyState/index.cjs +8 -0
- package/dist/components/molecules/EmptyState/index.cjs.map +1 -1
- package/dist/components/molecules/EmptyState/index.d.ts +19 -0
- package/dist/components/molecules/EmptyState/index.d.ts.map +1 -1
- package/dist/components/molecules/EmptyState/index.js +10 -3
- package/dist/components/molecules/EmptyState/index.js.map +1 -1
- package/dist/components/molecules/Modal/index.cjs +9 -39
- package/dist/components/molecules/Modal/index.cjs.map +1 -1
- package/dist/components/molecules/Modal/index.d.ts +13 -36
- package/dist/components/molecules/Modal/index.d.ts.map +1 -1
- package/dist/components/molecules/Modal/index.js +8 -38
- package/dist/components/molecules/Modal/index.js.map +1 -1
- package/dist/components/molecules/Modals/components/ConfirmationModal.cjs +32 -0
- package/dist/components/molecules/Modals/components/ConfirmationModal.cjs.map +1 -0
- package/dist/components/molecules/Modals/components/ConfirmationModal.d.ts +28 -0
- package/dist/components/molecules/Modals/components/ConfirmationModal.d.ts.map +1 -0
- package/dist/components/molecules/Modals/components/ConfirmationModal.js +30 -0
- package/dist/components/molecules/Modals/components/ConfirmationModal.js.map +1 -0
- package/dist/components/molecules/Modals/components/Modal.cjs +48 -0
- package/dist/components/molecules/Modals/components/Modal.cjs.map +1 -0
- package/dist/components/molecules/Modals/components/Modal.d.ts +37 -0
- package/dist/components/molecules/Modals/components/Modal.d.ts.map +1 -0
- package/dist/components/molecules/Modals/components/Modal.js +43 -0
- package/dist/components/molecules/Modals/components/Modal.js.map +1 -0
- package/dist/components/molecules/Modals/components/UnsavedChangesModal.cjs +30 -0
- package/dist/components/molecules/Modals/components/UnsavedChangesModal.cjs.map +1 -0
- package/dist/components/molecules/Modals/components/UnsavedChangesModal.d.ts +14 -0
- package/dist/components/molecules/Modals/components/UnsavedChangesModal.d.ts.map +1 -0
- package/dist/components/molecules/Modals/components/UnsavedChangesModal.js +28 -0
- package/dist/components/molecules/Modals/components/UnsavedChangesModal.js.map +1 -0
- package/dist/components/molecules/Modals/index.cjs +15 -0
- package/dist/components/molecules/Modals/index.cjs.map +1 -0
- package/dist/components/molecules/Modals/index.d.ts +14 -0
- package/dist/components/molecules/Modals/index.d.ts.map +1 -0
- package/dist/components/molecules/Modals/index.js +4 -0
- package/dist/components/molecules/Modals/index.js.map +1 -0
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatar.cjs +7 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatar.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatar.d.ts.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatar.js +8 -2
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatar.js.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupCheckbox.cjs +7 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupCheckbox.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupCheckbox.d.ts.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupCheckbox.js +8 -2
- package/dist/components/molecules/RadioGroup/components/RadioGroupCheckbox.js.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconCard.cjs +13 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconCard.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconCard.d.ts.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconCard.js +13 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconCard.js.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconSimple.cjs +7 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconSimple.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconSimple.d.ts.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconSimple.js +8 -2
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconSimple.js.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupPaymentIcon.cjs +6 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupPaymentIcon.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupPaymentIcon.d.ts.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupPaymentIcon.js +7 -2
- package/dist/components/molecules/RadioGroup/components/RadioGroupPaymentIcon.js.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupRadioButton.cjs +10 -3
- package/dist/components/molecules/RadioGroup/components/RadioGroupRadioButton.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupRadioButton.d.ts +6 -4
- package/dist/components/molecules/RadioGroup/components/RadioGroupRadioButton.d.ts.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupRadioButton.js +11 -4
- package/dist/components/molecules/RadioGroup/components/RadioGroupRadioButton.js.map +1 -1
- package/dist/components/molecules/RadioGroup/hooks/useOptionIds.cjs +24 -0
- package/dist/components/molecules/RadioGroup/hooks/useOptionIds.cjs.map +1 -0
- package/dist/components/molecules/RadioGroup/hooks/useOptionIds.d.ts +10 -0
- package/dist/components/molecules/RadioGroup/hooks/useOptionIds.d.ts.map +1 -0
- package/dist/components/molecules/RadioGroup/hooks/useOptionIds.js +22 -0
- package/dist/components/molecules/RadioGroup/hooks/useOptionIds.js.map +1 -0
- package/dist/components/molecules/RadioGroup/index.d.ts +1 -1
- package/dist/components/molecules/RadioGroup/index.d.ts.map +1 -1
- package/dist/components/molecules/RadioGroup/radioGroup.types.d.ts +14 -0
- package/dist/components/molecules/RadioGroup/radioGroup.types.d.ts.map +1 -1
- package/dist/components/molecules/Select/components/Combobox.cjs +2 -1
- package/dist/components/molecules/Select/components/Combobox.cjs.map +1 -1
- package/dist/components/molecules/Select/components/Combobox.d.ts +2 -1
- package/dist/components/molecules/Select/components/Combobox.d.ts.map +1 -1
- package/dist/components/molecules/Select/components/Combobox.js +2 -1
- package/dist/components/molecules/Select/components/Combobox.js.map +1 -1
- package/dist/components/molecules/Select/components/MultiSelect.cjs +3 -2
- package/dist/components/molecules/Select/components/MultiSelect.cjs.map +1 -1
- package/dist/components/molecules/Select/components/MultiSelect.d.ts +3 -3
- package/dist/components/molecules/Select/components/MultiSelect.d.ts.map +1 -1
- package/dist/components/molecules/Select/components/MultiSelect.js +5 -4
- package/dist/components/molecules/Select/components/MultiSelect.js.map +1 -1
- package/dist/components/molecules/Select/components/SelectItem.cjs +8 -0
- package/dist/components/molecules/Select/components/SelectItem.cjs.map +1 -1
- package/dist/components/molecules/Select/components/SelectItem.d.ts +7 -0
- package/dist/components/molecules/Select/components/SelectItem.d.ts.map +1 -1
- package/dist/components/molecules/Select/components/SelectItem.js +8 -1
- package/dist/components/molecules/Select/components/SelectItem.js.map +1 -1
- package/dist/components/molecules/Select/index.cjs +1 -1
- package/dist/components/molecules/Select/index.cjs.map +1 -1
- package/dist/components/molecules/Select/index.d.ts +3 -3
- package/dist/components/molecules/Select/index.d.ts.map +1 -1
- package/dist/components/molecules/Select/index.js +2 -2
- package/dist/components/molecules/Select/index.js.map +1 -1
- package/dist/components/organisms/ColorPicker/colorPicker.utils.cjs +26 -0
- package/dist/components/organisms/ColorPicker/colorPicker.utils.cjs.map +1 -1
- package/dist/components/organisms/ColorPicker/colorPicker.utils.d.ts +15 -0
- package/dist/components/organisms/ColorPicker/colorPicker.utils.d.ts.map +1 -1
- package/dist/components/organisms/ColorPicker/colorPicker.utils.js +25 -1
- package/dist/components/organisms/ColorPicker/colorPicker.utils.js.map +1 -1
- package/dist/components/organisms/ColorPicker/components/ColorPickerDialog.cjs +15 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerDialog.cjs.map +1 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerDialog.d.ts +12 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerDialog.d.ts.map +1 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerDialog.js +13 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerDialog.js.map +1 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.cjs +51 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.cjs.map +1 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.d.ts +48 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.d.ts.map +1 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.js +49 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.js.map +1 -0
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.cjs +69 -0
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.cjs.map +1 -0
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.d.ts +29 -0
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.d.ts.map +1 -0
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.js +67 -0
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.js.map +1 -0
- package/dist/components/organisms/ColorPicker/index.cjs +6 -7
- package/dist/components/organisms/ColorPicker/index.cjs.map +1 -1
- package/dist/components/organisms/ColorPicker/index.d.ts +4 -6
- package/dist/components/organisms/ColorPicker/index.d.ts.map +1 -1
- package/dist/components/organisms/ColorPicker/index.js +6 -7
- package/dist/components/organisms/ColorPicker/index.js.map +1 -1
- package/dist/components/organisms/DatePicker/components/CalendarOverlay.cjs +2 -2
- package/dist/components/organisms/DatePicker/components/CalendarOverlay.cjs.map +1 -1
- package/dist/components/organisms/DatePicker/components/CalendarOverlay.js +1 -1
- package/dist/components/organisms/DatePicker/components/DateRangePicker.cjs +20 -13
- package/dist/components/organisms/DatePicker/components/DateRangePicker.cjs.map +1 -1
- package/dist/components/organisms/DatePicker/components/DateRangePicker.d.ts +8 -1
- package/dist/components/organisms/DatePicker/components/DateRangePicker.d.ts.map +1 -1
- package/dist/components/organisms/DatePicker/components/DateRangePicker.js +21 -14
- package/dist/components/organisms/DatePicker/components/DateRangePicker.js.map +1 -1
- package/dist/components/organisms/DatePicker/index.cjs +14 -10
- package/dist/components/organisms/DatePicker/index.cjs.map +1 -1
- package/dist/components/organisms/DatePicker/index.d.ts +8 -1
- package/dist/components/organisms/DatePicker/index.d.ts.map +1 -1
- package/dist/components/organisms/DatePicker/index.js +14 -10
- package/dist/components/organisms/DatePicker/index.js.map +1 -1
- package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.cjs +48 -0
- package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.cjs.map +1 -0
- package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.d.ts +23 -0
- package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.d.ts.map +1 -0
- package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.js +45 -0
- package/dist/hooks/__internal__/useReturnFocus/useReturnFocus.js.map +1 -0
- package/dist/hooks/useFocusAfterRetry/index.cjs +31 -0
- package/dist/hooks/useFocusAfterRetry/index.cjs.map +1 -0
- package/dist/hooks/useFocusAfterRetry/index.d.ts +13 -0
- package/dist/hooks/useFocusAfterRetry/index.d.ts.map +1 -0
- package/dist/hooks/useFocusAfterRetry/index.js +29 -0
- package/dist/hooks/useFocusAfterRetry/index.js.map +1 -0
- package/dist/hooks/useUnsavedChangesGuard/index.cjs +28 -0
- package/dist/hooks/useUnsavedChangesGuard/index.cjs.map +1 -0
- package/dist/hooks/useUnsavedChangesGuard/index.d.ts +18 -0
- package/dist/hooks/useUnsavedChangesGuard/index.d.ts.map +1 -0
- package/dist/hooks/useUnsavedChangesGuard/index.js +26 -0
- package/dist/hooks/useUnsavedChangesGuard/index.js.map +1 -0
- package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.cjs +8 -0
- package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.cjs.map +1 -0
- package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.d.ts +13 -0
- package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.d.ts.map +1 -0
- package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.js +6 -0
- package/dist/hooks/useUnsavedChangesGuard/providers/UnsavedChangesGuard.context.js.map +1 -0
- package/dist/native/components/atoms/Button/index.d.ts +2 -0
- package/dist/native/components/atoms/Button/index.d.ts.map +1 -1
- package/dist/native/components/atoms/Button/index.js +5 -3
- package/dist/native/components/atoms/Button/index.js.map +1 -1
- package/dist/native/components/atoms/Checkbox/index.d.ts +35 -3
- package/dist/native/components/atoms/Checkbox/index.d.ts.map +1 -1
- package/dist/native/components/atoms/Checkbox/index.js +47 -10
- package/dist/native/components/atoms/Checkbox/index.js.map +1 -1
- package/dist/native/components/molecules/Alerts/index.d.ts +12 -0
- package/dist/native/components/molecules/Modals/index.d.ts +12 -0
- package/dist/native/hooks/useFocusAfterRetry/index.d.ts +12 -0
- package/dist/native/hooks/useUnsavedChangesGuard/index.d.ts +12 -0
- package/dist/native/providers/UnsavedChangesGuardProvider/index.d.ts +12 -0
- package/dist/providers/UIProvider/hooks/useBrowserRouter.cjs +70 -0
- package/dist/providers/UIProvider/hooks/useBrowserRouter.cjs.map +1 -0
- package/dist/providers/UIProvider/hooks/useBrowserRouter.d.ts +12 -0
- package/dist/providers/UIProvider/hooks/useBrowserRouter.d.ts.map +1 -0
- package/dist/providers/UIProvider/hooks/useBrowserRouter.js +68 -0
- package/dist/providers/UIProvider/hooks/useBrowserRouter.js.map +1 -0
- package/dist/providers/UIProvider/index.cjs +19 -6
- package/dist/providers/UIProvider/index.cjs.map +1 -1
- package/dist/providers/UIProvider/index.d.ts +2 -2
- package/dist/providers/UIProvider/index.d.ts.map +1 -1
- package/dist/providers/UIProvider/index.js +20 -7
- package/dist/providers/UIProvider/index.js.map +1 -1
- package/dist/providers/UnsavedChangesGuardProvider/index.cjs +191 -0
- package/dist/providers/UnsavedChangesGuardProvider/index.cjs.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/index.d.ts +10 -0
- package/dist/providers/UnsavedChangesGuardProvider/index.d.ts.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/index.js +189 -0
- package/dist/providers/UnsavedChangesGuardProvider/index.js.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.cjs +7 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.cjs.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.d.ts +3 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.d.ts.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.js +5 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.constants.js.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.types.d.ts +21 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.types.d.ts.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.utils.cjs +97 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.utils.cjs.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.utils.d.ts +62 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.utils.d.ts.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.utils.js +88 -0
- package/dist/providers/UnsavedChangesGuardProvider/unsavedChangesGuard.utils.js.map +1 -0
- package/dist/utilities/__internal__/ariaIdsUtils/ariaIds.utils.cjs +12 -0
- package/dist/utilities/__internal__/ariaIdsUtils/ariaIds.utils.cjs.map +1 -0
- package/dist/utilities/__internal__/ariaIdsUtils/ariaIds.utils.d.ts +8 -0
- package/dist/utilities/__internal__/ariaIdsUtils/ariaIds.utils.d.ts.map +1 -0
- package/dist/utilities/__internal__/ariaIdsUtils/ariaIds.utils.js +10 -0
- package/dist/utilities/__internal__/ariaIdsUtils/ariaIds.utils.js.map +1 -0
- package/dist/utilities/__internal__/refUtils/ref.utils.cjs +22 -0
- package/dist/utilities/__internal__/refUtils/ref.utils.cjs.map +1 -0
- package/dist/utilities/__internal__/refUtils/ref.utils.d.ts +15 -0
- package/dist/utilities/__internal__/refUtils/ref.utils.d.ts.map +1 -0
- package/dist/utilities/__internal__/refUtils/ref.utils.js +20 -0
- package/dist/utilities/__internal__/refUtils/ref.utils.js.map +1 -0
- package/package.json +2 -2
|
@@ -34,6 +34,13 @@ const sizes = {
|
|
|
34
34
|
checkbox: 'md',
|
|
35
35
|
},
|
|
36
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Renders one `items` entry as a `SelectItem`; what a select draws when it is given `items` and no `children`.
|
|
39
|
+
*
|
|
40
|
+
* @param item The entry to draw; every field is passed to the item as a prop.
|
|
41
|
+
* @returns The option element for that entry.
|
|
42
|
+
*/
|
|
43
|
+
const renderSelectItem = (item) => jsxRuntime.jsx(SelectItem, { ...item });
|
|
37
44
|
const SelectItem = ({ label, id, value, avatarUrl, supportingText, isDisabled, icon: Icon, className, children, selectionIndicator = 'checkmark', selectionIndicatorAlign = 'right', 'data-testid': dataTestId, ...props }) => {
|
|
38
45
|
const { size, testIdPrefix } = React.useContext(SelectShared.SelectContext);
|
|
39
46
|
const labelOrChildren = label || (typeof children === 'string' ? children : '');
|
|
@@ -63,4 +70,5 @@ const SelectItem = ({ label, id, value, avatarUrl, supportingText, isDisabled, i
|
|
|
63
70
|
};
|
|
64
71
|
|
|
65
72
|
exports.SelectItem = SelectItem;
|
|
73
|
+
exports.renderSelectItem = renderSelectItem;
|
|
66
74
|
//# sourceMappingURL=SelectItem.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectItem.cjs","sources":["../../../../../src/components/molecules/Select/components/SelectItem.tsx"],"sourcesContent":[null],"names":["useContext","SelectContext","joinTestId","slugifyTestId","
|
|
1
|
+
{"version":3,"file":"SelectItem.cjs","sources":["../../../../../src/components/molecules/Select/components/SelectItem.tsx"],"sourcesContent":[null],"names":["_jsx","useContext","SelectContext","joinTestId","slugifyTestId","Avatar","cx","isReactComponent","isValidElement","AriaListBoxItem","_jsxs","CheckboxBase","AriaText","Check"],"mappings":";;;;;;;;;;;;;AAcA,MAAM,KAAK,GAAG;AACZ,IAAA,EAAE,EAAE;AACF,QAAA,IAAI,EAAE,iEAAiE;AACvE,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,aAAa,EAAE,WAAW;AAC1B,QAAA,KAAK,EAAE,wBAAwB;AAC/B,QAAA,QAAQ,EAAE,IAAa;AACxB,KAAA;AACD,IAAA,EAAE,EAAE;AACF,QAAA,IAAI,EAAE,qCAAqC;AAC3C,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,aAAa,EAAE,SAAS;AACxB,QAAA,KAAK,EAAE,QAAQ;AACf,QAAA,QAAQ,EAAE,IAAa;AACxB,KAAA;AACD,IAAA,EAAE,EAAE;AACF,QAAA,IAAI,EAAE,qCAAqC;AAC3C,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,aAAa,EAAE,SAAS;AACxB,QAAA,KAAK,EAAE,QAAQ;AACf,QAAA,QAAQ,EAAE,IAAa;AACxB,KAAA;CACF;AAWD;;;;;AAKG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAoB,KAAKA,cAAA,CAAC,UAAU,EAAA,EAAA,GAAK,IAAI;AAEv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AAE,KAAK,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,EAAA,QAAA,EAAA,CACnFN,cAAA,CAACY,wBAAQ,IAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAEN,KAAE,CAAC,qDAAqD,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAA,QAAA,EAC1G,KAAK,KAAK,OAAO,QAAQ,KAAK,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,EAAA,CAC9D,EAEV,cAAc,KACbN,cAAA,CAACY,wBAAQ,IAAC,IAAI,EAAC,aAAa,EAAC,SAAS,EAAEN,KAAE,CAAC,iCAAiC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAA,QAAA,EAC5F,cAAc,EAAA,CACN,CACZ,IACG,EAEL,KAAK,CAAC,UAAU,IAAI,kBAAkB,KAAK,WAAW,KACrDN,cAAA,CAACa,aAAK,mBAAa,MAAM,EAAC,SAAS,EAAEP,KAAE,CAAC,+BAA+B,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAI,CAChG,EAEA,CAAC,MAAM,IAAI,kBAAkB,KAAK,UAAU,KAC3CN,cAAA,CAACW,qBAAY,IAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,SAAS,EAAC,SAAS,EAAA,CAAG,CAC7H,CAAA,EAAA,CACG,CACP,EAAA,CACe;AAEtB;;;"}
|
|
@@ -8,6 +8,13 @@ interface SelectItemProps extends Omit<AriaListBoxItemProps<SelectItemType>, 'id
|
|
|
8
8
|
/** Overrides the derived `data-testid` for the option (defaults to `<root>--item-<id>`). */
|
|
9
9
|
'data-testid'?: string;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Renders one `items` entry as a `SelectItem`; what a select draws when it is given `items` and no `children`.
|
|
13
|
+
*
|
|
14
|
+
* @param item The entry to draw; every field is passed to the item as a prop.
|
|
15
|
+
* @returns The option element for that entry.
|
|
16
|
+
*/
|
|
17
|
+
export declare const renderSelectItem: (item: SelectItemType) => import("react").JSX.Element;
|
|
11
18
|
export declare const SelectItem: ({ label, id, value, avatarUrl, supportingText, isDisabled, icon: Icon, className, children, selectionIndicator, selectionIndicatorAlign, "data-testid": dataTestId, ...props }: SelectItemProps) => import("react").JSX.Element;
|
|
12
19
|
export {};
|
|
13
20
|
//# sourceMappingURL=SelectItem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectItem.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Select/components/SelectItem.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AA2BrD,UAAU,eAAgB,SAAQ,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,EAAE,cAAc;IAChG,2DAA2D;IAC3D,kBAAkB,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;IACvD,gDAAgD;IAChD,uBAAuB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3C,4FAA4F;IAC5F,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,UAAU,GAAI,gLAcxB,eAAe,gCAmFjB,CAAC"}
|
|
1
|
+
{"version":3,"file":"SelectItem.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Select/components/SelectItem.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AA2BrD,UAAU,eAAgB,SAAQ,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,EAAE,cAAc;IAChG,2DAA2D;IAC3D,kBAAkB,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;IACvD,gDAAgD;IAChD,uBAAuB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3C,4FAA4F;IAC5F,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,cAAc,gCAA6B,CAAC;AAEnF,eAAO,MAAM,UAAU,GAAI,gLAcxB,eAAe,gCAmFjB,CAAC"}
|
|
@@ -32,6 +32,13 @@ const sizes = {
|
|
|
32
32
|
checkbox: 'md',
|
|
33
33
|
},
|
|
34
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Renders one `items` entry as a `SelectItem`; what a select draws when it is given `items` and no `children`.
|
|
37
|
+
*
|
|
38
|
+
* @param item The entry to draw; every field is passed to the item as a prop.
|
|
39
|
+
* @returns The option element for that entry.
|
|
40
|
+
*/
|
|
41
|
+
const renderSelectItem = (item) => jsx(SelectItem, { ...item });
|
|
35
42
|
const SelectItem = ({ label, id, value, avatarUrl, supportingText, isDisabled, icon: Icon, className, children, selectionIndicator = 'checkmark', selectionIndicatorAlign = 'right', 'data-testid': dataTestId, ...props }) => {
|
|
36
43
|
const { size, testIdPrefix } = useContext(SelectContext);
|
|
37
44
|
const labelOrChildren = label || (typeof children === 'string' ? children : '');
|
|
@@ -60,5 +67,5 @@ const SelectItem = ({ label, id, value, avatarUrl, supportingText, isDisabled, i
|
|
|
60
67
|
'*:data-icon:shrink-0 *:data-icon:text-fg-quaternary', sizes[size].root), children: [isLeft && selectionIndicator === 'checkbox' && (jsx(CheckboxBase, { size: sizes[size].checkbox, isSelected: state.isSelected, isDisabled: state.isDisabled })), renderLeading(), jsxs("div", { className: cx('flex w-full min-w-0 flex-1 flex-wrap', sizes[size].textContainer), children: [jsx(Text, { slot: "label", className: cx('truncate font-medium whitespace-nowrap text-primary', sizes[size].text), children: label || (typeof children === 'function' ? children(state) : children) }), supportingText && (jsx(Text, { slot: "description", className: cx('whitespace-nowrap text-tertiary', sizes[size].text), children: supportingText }))] }), state.isSelected && selectionIndicator === 'checkmark' && (jsx(Check, { "aria-hidden": "true", className: cx('ml-auto text-fg-brand-primary', sizes[size].check) })), !isLeft && selectionIndicator === 'checkbox' && (jsx(CheckboxBase, { size: sizes[size].checkbox, isSelected: state.isSelected, isDisabled: state.isDisabled, className: "ml-auto" }))] })) }));
|
|
61
68
|
};
|
|
62
69
|
|
|
63
|
-
export { SelectItem };
|
|
70
|
+
export { SelectItem, renderSelectItem };
|
|
64
71
|
//# sourceMappingURL=SelectItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectItem.js","sources":["../../../../../src/components/molecules/Select/components/SelectItem.tsx"],"sourcesContent":[null],"names":["_jsx","AriaListBoxItem","_jsxs","AriaText"],"mappings":";;;;;;;;;;;AAcA,MAAM,KAAK,GAAG;AACZ,IAAA,EAAE,EAAE;AACF,QAAA,IAAI,EAAE,iEAAiE;AACvE,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,aAAa,EAAE,WAAW;AAC1B,QAAA,KAAK,EAAE,wBAAwB;AAC/B,QAAA,QAAQ,EAAE,IAAa;AACxB,KAAA;AACD,IAAA,EAAE,EAAE;AACF,QAAA,IAAI,EAAE,qCAAqC;AAC3C,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,aAAa,EAAE,SAAS;AACxB,QAAA,KAAK,EAAE,QAAQ;AACf,QAAA,QAAQ,EAAE,IAAa;AACxB,KAAA;AACD,IAAA,EAAE,EAAE;AACF,QAAA,IAAI,EAAE,qCAAqC;AAC3C,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,aAAa,EAAE,SAAS;AACxB,QAAA,KAAK,EAAE,QAAQ;AACf,QAAA,QAAQ,EAAE,IAAa;AACxB,KAAA;CACF;
|
|
1
|
+
{"version":3,"file":"SelectItem.js","sources":["../../../../../src/components/molecules/Select/components/SelectItem.tsx"],"sourcesContent":[null],"names":["_jsx","AriaListBoxItem","_jsxs","AriaText"],"mappings":";;;;;;;;;;;AAcA,MAAM,KAAK,GAAG;AACZ,IAAA,EAAE,EAAE;AACF,QAAA,IAAI,EAAE,iEAAiE;AACvE,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,aAAa,EAAE,WAAW;AAC1B,QAAA,KAAK,EAAE,wBAAwB;AAC/B,QAAA,QAAQ,EAAE,IAAa;AACxB,KAAA;AACD,IAAA,EAAE,EAAE;AACF,QAAA,IAAI,EAAE,qCAAqC;AAC3C,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,aAAa,EAAE,SAAS;AACxB,QAAA,KAAK,EAAE,QAAQ;AACf,QAAA,QAAQ,EAAE,IAAa;AACxB,KAAA;AACD,IAAA,EAAE,EAAE;AACF,QAAA,IAAI,EAAE,qCAAqC;AAC3C,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,aAAa,EAAE,SAAS;AACxB,QAAA,KAAK,EAAE,QAAQ;AACf,QAAA,QAAQ,EAAE,IAAa;AACxB,KAAA;CACF;AAWD;;;;;AAKG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAoB,KAAKA,GAAA,CAAC,UAAU,EAAA,EAAA,GAAK,IAAI;AAEvE,MAAM,UAAU,GAAG,CAAC,EACzB,KAAK,EACL,EAAE,EACF,KAAK,EACL,SAAS,EACT,cAAc,EACd,UAAU,EACV,IAAI,EAAE,IAAI,EACV,SAAS,EACT,QAAQ,EACR,kBAAkB,GAAG,WAAW,EAChC,uBAAuB,GAAG,OAAO,EACjC,aAAa,EAAE,UAAU,EACzB,GAAG,KAAK,EACQ,KAAI;IACpB,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC;AAExD,IAAA,MAAM,eAAe,GAAG,KAAK,KAAK,OAAO,QAAQ,KA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,EAAE,CAAC,iCAAiC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAA,QAAA,EAC5F,cAAc,EAAA,CACN,CACZ,IACG,EAEL,KAAK,CAAC,UAAU,IAAI,kBAAkB,KAAK,WAAW,KACrDH,GAAA,CAAC,KAAK,mBAAa,MAAM,EAAC,SAAS,EAAE,EAAE,CAAC,+BAA+B,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAI,CAChG,EAEA,CAAC,MAAM,IAAI,kBAAkB,KAAK,UAAU,KAC3CA,GAAA,CAAC,YAAY,IAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,SAAS,EAAC,SAAS,EAAA,CAAG,CAC7H,CAAA,EAAA,CACG,CACP,EAAA,CACe;AAEtB;;"}
|
|
@@ -38,7 +38,7 @@ const SelectValue = ({ isOpen, isFocused, isDisabled, size, placeholder, icon, r
|
|
|
38
38
|
};
|
|
39
39
|
const Select = ({ placeholder = 'Select', icon, size = 'md', children, items, popoverClassName, label, hint, tooltip, hideRequiredIndicator, className, 'data-testid': dataTestId, ...rest }) => {
|
|
40
40
|
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'select', rootName: 'select' });
|
|
41
|
-
return (jsxRuntime.jsx(SelectShared.SelectContext.Provider, { value: { size, testIdPrefix: rootTestId }, children: jsxRuntime.jsx(reactAriaComponents.Select, { ...rest, "data-testid": rootTestId, className: (state) => cx.cx('flex flex-col gap-1.5', typeof className === 'function' ? className(state) : className), children: (state) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [label && (jsxRuntime.jsx(Input.Label, { isRequired: hideRequiredIndicator ? false : state.isRequired, tooltip: tooltip, children: label })), jsxRuntime.jsx(SelectValue, { ...state, size, placeholder, icon: icon, "data-testid": testIdUtils.joinTestId(rootTestId, 'trigger') }), jsxRuntime.jsx(Popover.Popover, { size: size, className: popoverClassName, children: jsxRuntime.jsx(reactAriaComponents.ListBox, { items: items, className: "size-full outline-hidden", children: children }) }), hint && (jsxRuntime.jsx(Input.HintText, { isInvalid: state.isInvalid, className: cx.cx(size === 'sm' && 'text-xs'), children: hint }))] })) }) }));
|
|
41
|
+
return (jsxRuntime.jsx(SelectShared.SelectContext.Provider, { value: { size, testIdPrefix: rootTestId }, children: jsxRuntime.jsx(reactAriaComponents.Select, { ...rest, "data-testid": rootTestId, className: (state) => cx.cx('flex flex-col gap-1.5', typeof className === 'function' ? className(state) : className), children: (state) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [label && (jsxRuntime.jsx(Input.Label, { isRequired: hideRequiredIndicator ? false : state.isRequired, tooltip: tooltip, children: label })), jsxRuntime.jsx(SelectValue, { ...state, size, placeholder, icon: icon, "data-testid": testIdUtils.joinTestId(rootTestId, 'trigger') }), jsxRuntime.jsx(Popover.Popover, { size: size, className: popoverClassName, children: jsxRuntime.jsx(reactAriaComponents.ListBox, { items: items, className: "size-full outline-hidden", children: children ?? (items && SelectItem.renderSelectItem) }) }), hint && (jsxRuntime.jsx(Input.HintText, { isInvalid: state.isInvalid, className: cx.cx(size === 'sm' && 'text-xs'), children: hint }))] })) }) }));
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
44
|
* Dropdown select that lets the user choose one option from a list.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/molecules/Select/index.tsx"],"sourcesContent":[null],"names":["_jsx","AriaButton","cx","AriaSelectValue","sizes","Avatar","isReactComponent","isValidElement","_jsxs","_Fragment","ChevronDown","useResolvedTestId","SelectContext","AriaSelect","Label","joinTestId","Popover","AriaListBox","HintText","ComboBox","SelectItem"],"mappings":";;;;;;;;;;;;;;;;;AA2CA,MAAM,WAAW,GAAG,CAAC,EACnB,MAAM,EACN,SAAS,EACT,UAAU,EACV,IAAI,EACJ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AU,EACzB,GAAG,IAAI,EACK,KAAI;AAChB,IAAA,MAAM,UAAU,GAAGS,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAEnG,IAAA,QACEX,cAAA,CAACY,0BAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,EAAA,QAAA,EAC/DZ,eAACa,0BAAU,EAAA,EAAA,GACL,IAAI,EAAA,aAAA,EACK,UAAU,EACvB,SAAS,EAAE,CAAC,KAAK,KAAKX,KAAE,CAAC,uBAAuB,EAAE,OAAO,SAAS,KAAK,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,EAAA,QAAA,EAEhH,CAAC,KAAK,MACLM,
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/molecules/Select/index.tsx"],"sourcesContent":[null],"names":["_jsx","AriaButton","cx","AriaSelectValue","sizes","Avatar","isReactComponent","isValidElement","_jsxs","_Fragment","ChevronDown","useResolvedTestId","SelectContext","AriaSelect","Label","joinTestId","Popover","AriaListBox","renderSelectItem","HintText","ComboBox","SelectItem"],"mappings":";;;;;;;;;;;;;;;;;AA2CA,MAAM,WAAW,GAAG,CAAC,EACnB,MAAM,EACN,SAAS,EACT,UAAU,EACV,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,GAAG,EACH,aAAa,EAAE,UAAU,GACqB,KAAI;IAClD,QACEA,eAACC,0BAAU,EAAA,EACT,GAAG,EAAE,GAAG,EAAA,aAAA,EACK,UAAU,EACvB,SAAS,EAAEC,KAAE,CACX,oKAAoK,EACpK,CAAC,SAAS,IAAI,MAAM,KAAK,mBAAmB,EAC5C,UAAU,IAAI,+BAA+B,CAC9C,EAAA,QAAA,EAEDF,cAAA,CAACG,+BAAe,EAAA,EACd,SAAS,EAAE,CAAC,KAAK,KACfD,KAAE,CACA,8EA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|
|
8
8
|
export { type CommonProps, SelectContext, type SelectItemType, sizes } from './components/SelectShared';
|
|
9
9
|
export interface SelectProps extends Omit<AriaSelectProps<SelectItemType>, 'children' | 'items'>, RefAttributes<HTMLDivElement>, CommonProps {
|
|
10
|
-
/** Options passed to the list box;
|
|
10
|
+
/** Options passed to the list box; each renders as a `Select.Item` unless a render-function `children` draws it. */
|
|
11
11
|
items?: SelectItemType[];
|
|
12
12
|
/** Extra classes merged onto the dropdown popover. */
|
|
13
13
|
popoverClassName?: string;
|
|
14
14
|
/** Icon component or element shown before the value when the selected item has no icon or avatar of its own. */
|
|
15
15
|
icon?: FC | ReactNode;
|
|
16
|
-
/** `Select.Item` elements, or a function that renders one per entry in `items`. */
|
|
17
|
-
children
|
|
16
|
+
/** `Select.Item` elements, or a function that renders one per entry in `items`; omit it to render each entry as a `Select.Item`. */
|
|
17
|
+
children?: ReactNode | ((item: SelectItemType) => ReactNode);
|
|
18
18
|
}
|
|
19
19
|
declare const Select: ({ placeholder, icon, size, children, items, popoverClassName, label, hint, tooltip, hideRequiredIndicator, className, "data-testid": dataTestId, ...rest }: SelectProps) => import("react").JSX.Element;
|
|
20
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/Select/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAO,aAAa,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG5E,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/Select/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAO,aAAa,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,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__internal__/componentGuardUtils/componentGuard.utils.js';
|
|
10
10
|
import { ComboBox } from './components/Combobox.js';
|
|
11
11
|
import { Popover } from './components/Popover.js';
|
|
12
|
-
import { SelectItem } from './components/SelectItem.js';
|
|
12
|
+
import { renderSelectItem, SelectItem } from './components/SelectItem.js';
|
|
13
13
|
import { SelectContext, sizes } from './components/SelectShared.js';
|
|
14
14
|
export { MultiSelect } from './components/MultiSelect.js';
|
|
15
15
|
|
|
@@ -36,7 +36,7 @@ const SelectValue = ({ isOpen, isFocused, isDisabled, size, placeholder, icon, r
|
|
|
36
36
|
};
|
|
37
37
|
const Select = ({ placeholder = 'Select', icon, size = 'md', children, items, popoverClassName, label, hint, tooltip, hideRequiredIndicator, className, 'data-testid': dataTestId, ...rest }) => {
|
|
38
38
|
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'select', rootName: 'select' });
|
|
39
|
-
return (jsx(SelectContext.Provider, { value: { size, testIdPrefix: rootTestId }, children: jsx(Select$1, { ...rest, "data-testid": rootTestId, className: (state) => cx('flex flex-col gap-1.5', typeof className === 'function' ? className(state) : className), children: (state) => (jsxs(Fragment, { children: [label && (jsx(Label, { isRequired: hideRequiredIndicator ? false : state.isRequired, tooltip: tooltip, children: label })), jsx(SelectValue, { ...state, size, placeholder, icon: icon, "data-testid": joinTestId(rootTestId, 'trigger') }), jsx(Popover, { size: size, className: popoverClassName, children: jsx(ListBox, { items: items, className: "size-full outline-hidden", children: children }) }), hint && (jsx(HintText, { isInvalid: state.isInvalid, className: cx(size === 'sm' && 'text-xs'), children: hint }))] })) }) }));
|
|
39
|
+
return (jsx(SelectContext.Provider, { value: { size, testIdPrefix: rootTestId }, children: jsx(Select$1, { ...rest, "data-testid": rootTestId, className: (state) => cx('flex flex-col gap-1.5', typeof className === 'function' ? className(state) : className), children: (state) => (jsxs(Fragment, { children: [label && (jsx(Label, { isRequired: hideRequiredIndicator ? false : state.isRequired, tooltip: tooltip, children: label })), jsx(SelectValue, { ...state, size, placeholder, icon: icon, "data-testid": joinTestId(rootTestId, 'trigger') }), jsx(Popover, { size: size, className: popoverClassName, children: jsx(ListBox, { items: items, className: "size-full outline-hidden", children: children ?? (items && renderSelectItem) }) }), hint && (jsx(HintText, { isInvalid: state.isInvalid, className: cx(size === 'sm' && 'text-xs'), children: hint }))] })) }) }));
|
|
40
40
|
};
|
|
41
41
|
/**
|
|
42
42
|
* Dropdown select that lets the user choose one option from a list.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/molecules/Select/index.tsx"],"sourcesContent":[null],"names":["_jsx","AriaButton","AriaSelectValue","_jsxs","_Fragment","AriaSelect","AriaListBox"],"mappings":";;;;;;;;;;;;;;;AA2CA,MAAM,WAAW,GAAG,CAAC,EACnB,MAAM,EACN,SAAS,EACT,UAAU,EACV,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,GAAG,EACH,aAAa,EAAE,UAAU,GACqB,KAAI;IAClD,QACEA,IAACC,MAAU,EAAA,EACT,GAAG,EAAE,GAAG,EAAA,aAAA,EACK,UAAU,EACvB,SAAS,EAAE,EAAE,CACX,oKAAoK,EACpK,CAAC,SAAS,IAAI,MAAM,KAAK,mBAAmB,EAC5C,UAAU,IAAI,+BAA+B,CAC9C,EAAA,QAAA,EAEDD,GAAA,CAACE,aAAe,EAAA,EACd,SAAS,EAAE,CAAC,KAAK,KACf,EAAE,CACA,8EAA8E,EAE9E,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI;;AAGhB,YAAA,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ;;AAG9D,YAAA,qDAAqD,CACtD,EAAA,QAAA,EAGF,CAAC,KAAK,KAAI;gBACT,MAAM,YAAY,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;AAC3C,gBAAA,MAAM,IAAI,GAAG,YAAY,EAAE,IAAI,IAAI,IAA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AAC,CAAC,IAAI,CAAC,EAAA,QAAA,EAAG,WAAW,GAAK,CAC1E,EAEDA,GAAA,CAAC,WAAW,EAAA,EAAA,aAAA,EACE,MAAM,EAClB,SAAS,EAAE,EAAE,CAAC,qCAAqC,EAAE,IAAI,KAAK,IAAI,GAAG,QAAQ,GAAG,wBAAwB,CAAC,EAAA,CACzG,CAAA,EAAA,CACD;YAEP,CAAC,EAAA,CACe,EAAA,CACP;AAEjB,CAAC;AAED,MAAM,MAAM,GAAG,CAAC,EACd,WAAW,GAAG,QAAQ,EACtB,IAAI,EACJ,IAAI,GAAG,IAAI,EACX,QAAQ,EACR,KAAK,EACL,gBAAgB,EAChB,KAAK,EACL,IAAI,EACJ,OAAO,EACP,qBAAqB,EACrB,SAAS,EACT,aAAa,EAAE,UAAU,EACzB,GAAG,IAAI,EACK,KAAI;AAChB,IAAA,MAAM,UAAU,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAEnG,IAAA,QACEA,GAAA,CAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,EAAA,QAAA,EAC/DA,IAACK,QAAU,EAAA,EAAA,GACL,IAAI,EAAA,aAAA,EACK,UAAU,EACvB,SAAS,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC,uBAAuB,EAAE,OAAO,SAAS,KAAK,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,EAAA,QAAA,EAEhH,CAAC,KAAK,MACLF,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/molecules/Select/index.tsx"],"sourcesContent":[null],"names":["_jsx","AriaButton","AriaSelectValue","_jsxs","_Fragment","AriaSelect","AriaListBox"],"mappings":";;;;;;;;;;;;;;;AA2CA,MAAM,WAAW,GAAG,CAAC,EACnB,MAAM,EACN,SAAS,E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AAS,CAAC,EAAA,QAAA,EAC5E,IAAI,GACI,CACZ,CAAA,EAAA,CACA,CACJ,EAAA,CACU,EAAA,CACU;AAE7B,CAAC;AAED;;;;AAIG;AACH,MAAM,OAAO,GAAG;AAIhB,OAAO,CAAC,QAAQ,GAAG,QAAQ;AAC3B,OAAO,CAAC,IAAI,GAAG,UAAU;;"}
|
|
@@ -71,10 +71,36 @@ const dedupeColors = (colors) => {
|
|
|
71
71
|
return true;
|
|
72
72
|
});
|
|
73
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* Reads a stored value as a colour without throwing, since it may come from a form default or an API in another shape.
|
|
76
|
+
*
|
|
77
|
+
* @param value The stored value: a hex, `rgb()`, `hsl()` or `hsb()` colour string.
|
|
78
|
+
* @returns The colour, or `null` for an empty value or one that is not a colour, such as a CSS colour name.
|
|
79
|
+
*/
|
|
80
|
+
const toColor = (value) => {
|
|
81
|
+
if (typeof value !== 'string' || value === '')
|
|
82
|
+
return null;
|
|
83
|
+
try {
|
|
84
|
+
return reactAriaComponents.parseColor(value);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Writes a colour as `ColorPicker.Field` reports it.
|
|
92
|
+
*
|
|
93
|
+
* @param color The colour the picker holds.
|
|
94
|
+
* @returns `#RRGGBB`, or `#RRGGBBAA` when the colour is not fully opaque, so an opaque colour never carries a redundant alpha.
|
|
95
|
+
*/
|
|
96
|
+
// Compared as the byte hex writes: an alpha that rounds to `FF` is opaque, and would read as see-through with it on the end.
|
|
97
|
+
const toHexString = (color) => color.toString(Math.round(color.getChannelValue('alpha') * 255) < 255 ? 'hexa' : 'hex');
|
|
74
98
|
|
|
75
99
|
exports.cssChannelSelection = cssChannelSelection;
|
|
76
100
|
exports.dedupeColors = dedupeColors;
|
|
77
101
|
exports.formatRgbaCss = formatRgbaCss;
|
|
78
102
|
exports.isSolidColorList = isSolidColorList;
|
|
79
103
|
exports.selectAllOnFocus = selectAllOnFocus;
|
|
104
|
+
exports.toColor = toColor;
|
|
105
|
+
exports.toHexString = toHexString;
|
|
80
106
|
//# sourceMappingURL=colorPicker.utils.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorPicker.utils.cjs","sources":["../../../../src/components/organisms/ColorPicker/colorPicker.utils.ts"],"sourcesContent":[null],"names":["parseColor"],"mappings":";;;;AAKO,MAAM,gBAAgB,GAA8C,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM;AAEjG;;;;;;;;;AASG;MACU,aAAa,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,IAAY,EAAE,KAAa,KACnF,CAAA,KAAA,EAAQ,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA,EAAA,EAAK,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA,EAAA,EAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA,EAAA,EAAK,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAA,CAAA;AAEtG;;;;;AAKG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAAa,KAA2C;IAC1F,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IACpC,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;AAC9B,IAAA,IAAI,KAAK,GAAG,CAAC,IAAI,GAAG,GAAG,KAAK;AAAE,QAAA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE;AACnD,IAAA,OAAO,IAAI;AACb;AAEA;;;;;;AAMG;AACI,MAAM,gBAAgB,GAAG,CAAC,MAAyB,KAAa;AACrE,IAAA,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK;AACrC,IAAA,IAAI;AACF,QAAAA,8BAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACrB,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF;AAEA;;;;;;;;;AASG;AACI,MAAM,YAAY,GAAG,CAAC,MAAgB,KAAc;AACzD,IAAA,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU;AAC9B,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAI;AACzB,QAAA,IAAI,GAAW;AACf,QAAA,IAAI;YACF,GAAG,GAAGA,8BAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;QACtC;AAAE,QAAA,MAAM;YACN,GAAG,GAAG,CAAC;QACT;AACA,QAAA,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAAE,YAAA,OAAO,KAAK;AAC/B,QAAA,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AACb,QAAA,OAAO,IAAI;AACb,IAAA,CAAC,CAAC;AACJ
|
|
1
|
+
{"version":3,"file":"colorPicker.utils.cjs","sources":["../../../../src/components/organisms/ColorPicker/colorPicker.utils.ts"],"sourcesContent":[null],"names":["parseColor"],"mappings":";;;;AAKO,MAAM,gBAAgB,GAA8C,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM;AAEjG;;;;;;;;;AASG;MACU,aAAa,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,IAAY,EAAE,KAAa,KACnF,CAAA,KAAA,EAAQ,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA,EAAA,EAAK,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA,EAAA,EAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA,EAAA,EAAK,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAA,CAAA;AAEtG;;;;;AAKG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAAa,KAA2C;IAC1F,MAAM,KAAK,G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QAAA,OAAOA,8BAAU,CAAC,KAAK,CAAC;IAC1B;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF;AAEA;;;;;AAKG;AACH;AACO,MAAM,WAAW,GAAG,CAAC,KAAY,KAAa,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,MAAM,GAAG,KAAK;;;;;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
+
import { type Color } from 'react-aria-components';
|
|
2
3
|
export type ColorDisplayFormat = 'hex' | 'rgb' | 'css' | 'hsl' | 'hsb';
|
|
3
4
|
export declare const selectAllOnFocus: React.FocusEventHandler<HTMLInputElement>;
|
|
4
5
|
/**
|
|
@@ -41,4 +42,18 @@ export declare const isSolidColorList: (colors: readonly string[]) => boolean;
|
|
|
41
42
|
* list the caller passes in, de-duping defensively here is the only reliable prevention.
|
|
42
43
|
*/
|
|
43
44
|
export declare const dedupeColors: (colors: string[]) => string[];
|
|
45
|
+
/**
|
|
46
|
+
* Reads a stored value as a colour without throwing, since it may come from a form default or an API in another shape.
|
|
47
|
+
*
|
|
48
|
+
* @param value The stored value: a hex, `rgb()`, `hsl()` or `hsb()` colour string.
|
|
49
|
+
* @returns The colour, or `null` for an empty value or one that is not a colour, such as a CSS colour name.
|
|
50
|
+
*/
|
|
51
|
+
export declare const toColor: (value: string | null | undefined) => Color | null;
|
|
52
|
+
/**
|
|
53
|
+
* Writes a colour as `ColorPicker.Field` reports it.
|
|
54
|
+
*
|
|
55
|
+
* @param color The colour the picker holds.
|
|
56
|
+
* @returns `#RRGGBB`, or `#RRGGBBAA` when the colour is not fully opaque, so an opaque colour never carries a redundant alpha.
|
|
57
|
+
*/
|
|
58
|
+
export declare const toHexString: (color: Color) => string;
|
|
44
59
|
//# sourceMappingURL=colorPicker.utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorPicker.utils.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/ColorPicker/colorPicker.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"colorPicker.utils.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/ColorPicker/colorPicker.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,KAAK,EAAc,MAAM,uBAAuB,CAAC;AAE/D,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAEvE,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAA4B,CAAC;AAEpG;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,EAAE,OAAO,MAAM,EAAE,MAAM,MAAM,EAAE,OAAO,MAAM,KAAG,MACiB,CAAC;AAE1G;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,KAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAKpF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,SAAS,MAAM,EAAE,KAAG,OAQ5D,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,KAAG,MAAM,EAarD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,KAAK,GAAG,IAOlE,CAAC;AAEF;;;;;GAKG;AAEH,eAAO,MAAM,WAAW,GAAI,OAAO,KAAK,KAAG,MAAiG,CAAC"}
|
|
@@ -69,6 +69,30 @@ const dedupeColors = (colors) => {
|
|
|
69
69
|
return true;
|
|
70
70
|
});
|
|
71
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* Reads a stored value as a colour without throwing, since it may come from a form default or an API in another shape.
|
|
74
|
+
*
|
|
75
|
+
* @param value The stored value: a hex, `rgb()`, `hsl()` or `hsb()` colour string.
|
|
76
|
+
* @returns The colour, or `null` for an empty value or one that is not a colour, such as a CSS colour name.
|
|
77
|
+
*/
|
|
78
|
+
const toColor = (value) => {
|
|
79
|
+
if (typeof value !== 'string' || value === '')
|
|
80
|
+
return null;
|
|
81
|
+
try {
|
|
82
|
+
return parseColor(value);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Writes a colour as `ColorPicker.Field` reports it.
|
|
90
|
+
*
|
|
91
|
+
* @param color The colour the picker holds.
|
|
92
|
+
* @returns `#RRGGBB`, or `#RRGGBBAA` when the colour is not fully opaque, so an opaque colour never carries a redundant alpha.
|
|
93
|
+
*/
|
|
94
|
+
// Compared as the byte hex writes: an alpha that rounds to `FF` is opaque, and would read as see-through with it on the end.
|
|
95
|
+
const toHexString = (color) => color.toString(Math.round(color.getChannelValue('alpha') * 255) < 255 ? 'hexa' : 'hex');
|
|
72
96
|
|
|
73
|
-
export { cssChannelSelection, dedupeColors, formatRgbaCss, isSolidColorList, selectAllOnFocus };
|
|
97
|
+
export { cssChannelSelection, dedupeColors, formatRgbaCss, isSolidColorList, selectAllOnFocus, toColor, toHexString };
|
|
74
98
|
//# sourceMappingURL=colorPicker.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorPicker.utils.js","sources":["../../../../src/components/organisms/ColorPicker/colorPicker.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAKO,MAAM,gBAAgB,GAA8C,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM;AAEj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C,MAAM,CAAC;QACtC;AAAE,QAAA,MAAM;YACN,GAAG,GAAG,CAAC;QACT;AACA,QAAA,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAAE,YAAA,OAAO,KAAK;AAC/B,QAAA,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AACb,QAAA,OAAO,IAAI;AACb,IAAA,CAAC,CAAC;AACJ;;"}
|
|
1
|
+
{"version":3,"file":"colorPicker.utils.js","sources":["../../../../src/components/organisms/ColorPicker/colorPicker.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAKO,MAAM,gBAAgB,GAA8C,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM;AAEjG;;;;;;;;;AASG;MACU,aAAa,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,IAAY,EAAE,KAAa,KACnF,CAAA,KAAA,EAAQ,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA,EAAA,EAAK,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA,EAAA,EAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA,EAAA,EAAK,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAA,CAAA;AAEtG;;;;;AAKG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAAa,KAA2C;IAC1F,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IACpC,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;AAC9B,IAAA,IAAI,KAAK,GAAG,CAAC,IAAI,GAAG,GAAG,KAAK;AAAE,QAAA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE;AACnD,IAAA,OAAO,IAAI;AACb;AAEA;;;;;;AAMG;AACI,MAAM,gBAAgB,GAAG,CAAC,MAAyB,KAAa;AACrE,IAAA,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;AAAE,Q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xRuntime = require('react/jsx-runtime');
|
|
4
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
5
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
6
|
+
|
|
7
|
+
/** Card container for the color picker. */
|
|
8
|
+
const ColorPickerDialog = ({ className, children, 'data-testid': dataTestId, }) => {
|
|
9
|
+
const ambientPrefix = testIdUtils.useTestIdPrefix();
|
|
10
|
+
const dialogTestId = dataTestId ?? ambientPrefix ?? testIdUtils.rootTestId('color-picker');
|
|
11
|
+
return (jsxRuntime.jsx(testIdUtils.TestIdProvider, { value: dialogTestId, children: jsxRuntime.jsx("div", { "data-testid": dialogTestId, className: cx.cx('relative flex w-80 flex-col overflow-clip rounded-2xl bg-primary shadow-xl ring-1 ring-secondary_alt', className), children: children }) }));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.ColorPickerDialog = ColorPickerDialog;
|
|
15
|
+
//# sourceMappingURL=ColorPickerDialog.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPickerDialog.cjs","sources":["../../../../../src/components/organisms/ColorPicker/components/ColorPickerDialog.tsx"],"sourcesContent":[null],"names":["useTestIdPrefix","rootTestId","_jsx","TestIdProvider","cx"],"mappings":";;;;;;AAMA;AACO,MAAM,iBAAiB,GAAG,CAAC,EAChC,SAAS,EACT,QAAQ,EACR,aAAa,EAAE,UAAU,GAS1B,KAAI;AACH,IAAA,MAAM,aAAa,GAAGA,2BAAe,EAAE;IACvC,MAAM,YAAY,GAAG,UAAU,IAAI,aAAa,IAAIC,sBAAU,CAAC,cAAc,CAAC;IAE9E,QACEC,cAAA,CAACC,0BAAc,EAAA,EAAC,KAAK,EAAE,YAAY,EAAA,QAAA,EACjCD,cAAA,CAAA,KAAA,EAAA,EAAA,aAAA,EACe,YAAY,EACzB,SAAS,EAAEE,KAAE,CAAC,sGAAsG,EAAE,SAAS,CAAC,YAE/H,QAAQ,EAAA,CACL,EAAA,CACS;AAErB;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/** Card container for the color picker. */
|
|
3
|
+
export declare const ColorPickerDialog: ({ className, children, "data-testid": dataTestId, }: {
|
|
4
|
+
className?: string;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* Overrides the `data-testid` prefix used by every descendant control. Defaults to
|
|
8
|
+
* `fd-color-picker` when standalone, or to the ambient prefix from an ancestor when nested.
|
|
9
|
+
*/
|
|
10
|
+
"data-testid"?: string;
|
|
11
|
+
}) => import("react").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=ColorPickerDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPickerDialog.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/ColorPicker/components/ColorPickerDialog.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,2CAA2C;AAC3C,eAAO,MAAM,iBAAiB,GAAI,qDAI/B;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,gCAcA,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
3
|
+
import { useTestIdPrefix, rootTestId, TestIdProvider } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
4
|
+
|
|
5
|
+
/** Card container for the color picker. */
|
|
6
|
+
const ColorPickerDialog = ({ className, children, 'data-testid': dataTestId, }) => {
|
|
7
|
+
const ambientPrefix = useTestIdPrefix();
|
|
8
|
+
const dialogTestId = dataTestId ?? ambientPrefix ?? rootTestId('color-picker');
|
|
9
|
+
return (jsx(TestIdProvider, { value: dialogTestId, children: jsx("div", { "data-testid": dialogTestId, className: cx('relative flex w-80 flex-col overflow-clip rounded-2xl bg-primary shadow-xl ring-1 ring-secondary_alt', className), children: children }) }));
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { ColorPickerDialog };
|
|
13
|
+
//# sourceMappingURL=ColorPickerDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPickerDialog.js","sources":["../../../../../src/components/organisms/ColorPicker/components/ColorPickerDialog.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;AAMA;AACO,MAAM,iBAAiB,GAAG,CAAC,EAChC,SAAS,EACT,QAAQ,EACR,aAAa,EAAE,UAAU,GAS1B,KAAI;AACH,IAAA,MAAM,aAAa,GAAG,eAAe,EAAE;IACvC,MAAM,YAAY,GAAG,UAAU,IAAI,aAAa,IAAI,UAAU,CAAC,cAAc,CAAC;IAE9E,QACEA,GAAA,CAAC,cAAc,EAAA,EAAC,KAAK,EAAE,YAAY,EAAA,QAAA,EACjCA,GAAA,CAAA,KAAA,EAAA,EAAA,aAAA,EACe,YAAY,EACzB,SAAS,EAAE,EAAE,CAAC,sGAAsG,EAAE,SAAS,CAAC,YAE/H,QAAQ,EAAA,CACL,EAAA,CACS;AAErB;;"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var uiIcons = require('@flipdish/ui-icons');
|
|
5
|
+
var Button = require('@flipdish/ui-library/components/atoms/Button');
|
|
6
|
+
var Input = require('@flipdish/ui-library/components/atoms/Input');
|
|
7
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
8
|
+
var React = require('react');
|
|
9
|
+
var reactAriaComponents = require('react-aria-components');
|
|
10
|
+
var ScrollClosingPopover = require('../../../__internal__/popover/ScrollClosingPopover.cjs');
|
|
11
|
+
var ref_utils = require('../../../../utilities/__internal__/refUtils/ref.utils.cjs');
|
|
12
|
+
var colorPicker_utils = require('../colorPicker.utils.cjs');
|
|
13
|
+
var useColorFieldEdit = require('../hooks/useColorFieldEdit.cjs');
|
|
14
|
+
var ColorPicker_provider = require('../providers/ColorPicker.provider.cjs');
|
|
15
|
+
var ColorPickerDialog = require('./ColorPickerDialog.cjs');
|
|
16
|
+
|
|
17
|
+
const ColorPickerField = ({ children, ref, value, onChange, onChangeEnd, onBlur, label, hint, isInvalid, placeholder = 'Add colour', defaultColor, isClearable, isDisabled, isRequired, size = 'md', 'aria-label': ariaLabel, 'data-testid': dataTestId, }) => {
|
|
18
|
+
const fieldTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'color-picker-field', rootName: 'color-picker-field' });
|
|
19
|
+
const labelId = React.useId();
|
|
20
|
+
const triggerId = React.useId();
|
|
21
|
+
const hintId = React.useId();
|
|
22
|
+
const { color, startValue, onOpenChange, onPick, onRemove, onKeyDownCapture } = useColorFieldEdit.useColorFieldEdit({ value, defaultColor, onChange, onChangeEnd });
|
|
23
|
+
const triggerText = color ? colorPicker_utils.toHexString(color) : placeholder;
|
|
24
|
+
// A button cannot carry `aria-required`, so a name given by `aria-label` says it in words, as the visible label does,
|
|
25
|
+
// and ends with the trigger's own text, so the value is announced with the name here too.
|
|
26
|
+
const triggerName = ariaLabel && `${isRequired ? `${ariaLabel} (required)` : ariaLabel} ${triggerText}`;
|
|
27
|
+
const root = React.useRef(null);
|
|
28
|
+
// Stable, so React does not detach and re-attach the consumer's ref on every render.
|
|
29
|
+
const setRoot = React.useCallback((element) => {
|
|
30
|
+
root.current = element;
|
|
31
|
+
const cleanup = ref_utils.setRef(ref, element);
|
|
32
|
+
// A callback ref may return a cleanup, which React then runs in place of calling the ref with `null`; passing it on keeps that contract.
|
|
33
|
+
if (!cleanup)
|
|
34
|
+
return undefined;
|
|
35
|
+
return () => {
|
|
36
|
+
root.current = null;
|
|
37
|
+
cleanup();
|
|
38
|
+
};
|
|
39
|
+
}, [ref]);
|
|
40
|
+
const handleRemove = () => {
|
|
41
|
+
onRemove();
|
|
42
|
+
// The Remove button leaves the page with the colour, so focus moves to the trigger instead of being lost.
|
|
43
|
+
root.current?.querySelector('button')?.focus();
|
|
44
|
+
};
|
|
45
|
+
return (jsxRuntime.jsxs("div", { ref: setRoot, "data-testid": fieldTestId, className: "flex flex-col items-start gap-1.5", children: [label && (jsxRuntime.jsxs("span", { id: labelId, className: "flex items-center gap-0.5 text-sm font-medium text-secondary", children: [label, isRequired && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", { "aria-hidden": "true", className: "text-brand-tertiary", children: "*" }), jsxRuntime.jsx("span", { className: "sr-only", children: "(required)" })] }))] })), jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [jsxRuntime.jsxs(reactAriaComponents.DialogTrigger, { onOpenChange: onOpenChange, children: [jsxRuntime.jsx(Button.Button, { id: triggerId, size: size, color: "secondary", isDisabled: isDisabled, onBlur: onBlur,
|
|
46
|
+
// The picked colour is the user's data, not a token, so it can only be set inline.
|
|
47
|
+
iconLeading: color ? (jsxRuntime.jsx("span", { "aria-hidden": "true", className: "size-4 shrink-0 rounded-full ring-1 ring-alpha-black/10 ring-inset", style: { backgroundColor: colorPicker_utils.toHexString(color) } })) : (uiIcons.Plus), "aria-labelledby": label ? `${labelId} ${triggerId}` : undefined, "aria-label": label ? undefined : triggerName, "aria-describedby": hint ? hintId : undefined, "data-testid": testIdUtils.joinTestId(fieldTestId, 'trigger'), children: triggerText }), jsxRuntime.jsx(ScrollClosingPopover.ScrollClosingPopover, { placement: "bottom start", offset: 8, children: jsxRuntime.jsx("div", { className: "contents", onKeyDownCapture: onKeyDownCapture, children: jsxRuntime.jsx(reactAriaComponents.Dialog, { "aria-label": label ?? ariaLabel, className: "outline-hidden", children: jsxRuntime.jsx(ColorPickerDialog.ColorPickerDialog, { className: "p-4", "data-testid": testIdUtils.joinTestId(fieldTestId, 'picker'), children: jsxRuntime.jsx(ColorPicker_provider.Provider, { defaultValue: startValue, onChange: onPick, children: children }) }) }) }) })] }), isClearable && color && (jsxRuntime.jsx(Button.Button, { size: size, color: "link-gray", isDisabled: isDisabled, "aria-label": `Remove ${label ?? ariaLabel ?? 'colour'}`, onPress: handleRemove, "data-testid": testIdUtils.joinTestId(fieldTestId, 'remove'), children: "Remove" }))] }), hint && (jsxRuntime.jsx(Input.HintText, { id: hintId, isInvalid: isInvalid, children: hint }))] }));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
exports.ColorPickerField = ColorPickerField;
|
|
51
|
+
//# sourceMappingURL=ColorPickerField.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPickerField.cjs","sources":["../../../../../src/components/organisms/ColorPicker/components/ColorPickerField.tsx"],"sourcesContent":[null],"names":["useResolvedTestId","useId","useColorFieldEdit","toHexString","useRef","useCallback","setRef","_jsxs","_Fragment","_jsx","AriaDialogTrigger","Button","Plus","joinTestId","ScrollClosingPopover","AriaDialog","ColorPickerDialog","Provider","HintText"],"mappings":";;;;;;;;;;;;;;;;MA0Da,gBAAgB,GAAG,CAAC,EAC/B,QAAQ,EACR,GAAG,EACH,KAAK,EACL,QAAQ,EACR,WAAW,EACX,MAAM,EACN,KAAK,EACL,IAAI,EACJ,SAAS,EACT,WAAW,GAAG,YAAY,EAC1B,YAAY,EACZ,WAAW,EACX,UAAU,EACV,UAAU,EACV,IAAI,GAAG,IAAI,EACX,YAAY,EAAE,SAAS,EACvB,aAAa,EAAE,UAAU,GAC4B,KAAI;AACzD,IAAA,MAAM,WAAW,GAAGA,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,oBAAoB,EAAE,CAAC;AAC5H,IAAA,MAAM,OAAO,GAAGC,WAAK,EAAE;AACvB,IAAA,MAAM,SAAS,GAAGA,WAAK,EAAE;AACzB,IAAA,MAAM,MAAM,GAAGA,WAAK,E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EAAA,EAAA,YAAA,EAAa,KAAK,IAAI,SAAS,EAAE,SAAS,EAAC,gBAAgB,YACpEN,cAAA,CAACO,mCAAiB,IAAC,SAAS,EAAC,KAAK,EAAA,aAAA,EAAcH,sBAAU,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAA,QAAA,EAE/EJ,cAAA,CAACQ,6BAAQ,EAAA,EAAC,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YACjD,QAAQ,EAAA,CACA,EAAA,CACO,EAAA,CACT,EAAA,CACT,EAAA,CACe,IACL,EACnB,WAAW,IAAI,KAAK,KACnBR,cAAA,CAACE,aAAM,EAAA,EACL,IAAI,EAAE,IAAI,EACV,KAAK,EAAC,WAAW,EACjB,UAAU,EAAE,UAAU,EAAA,YAAA,EACV,CAAA,OAAA,EAAU,KAAK,IAAI,SAAS,IAAI,QAAQ,CAAA,CAAE,EACtD,OAAO,EAAE,YAAY,EAAA,aAAA,EACRE,sBAAU,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAA,QAAA,EAAA,QAAA,EAAA,CAGvC,CACV,IACG,EACL,IAAI,KACHJ,cAAA,CAACS,cAAQ,EAAA,EAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAA,QAAA,EACvC,IAAI,EAAA,CACI,CACZ,CAAA,EAAA,CACG;AAEV;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ButtonProps } from '@flipdish/ui-library/components/atoms/Button';
|
|
2
|
+
import { type ReactNode, type Ref } from 'react';
|
|
3
|
+
interface ColorPickerFieldBaseProps {
|
|
4
|
+
/** Ref to the field's root element, which holds the label, the trigger and the hint. */
|
|
5
|
+
ref?: Ref<HTMLDivElement>;
|
|
6
|
+
/** The colour as a string, such as `#DB3D5D`; `null`, an empty string or an unreadable value shows `placeholder`. */
|
|
7
|
+
value: string | null | undefined;
|
|
8
|
+
/** Called on every change with a hex string: each pick, the starting colour when an empty field opens, and `null` on Remove. */
|
|
9
|
+
onChange: (value: string | null) => void;
|
|
10
|
+
/** Called with the value once an edit is over: the picker has closed, or Remove was pressed. Validate here, not on every pick. */
|
|
11
|
+
onChangeEnd?: (value: string | null) => void;
|
|
12
|
+
/** Called when focus leaves the trigger. */
|
|
13
|
+
onBlur?: () => void;
|
|
14
|
+
/** Name of the field, shown above the trigger; the types ask for this or `aria-label`. */
|
|
15
|
+
label?: string;
|
|
16
|
+
/** Help text beneath the trigger, which is also the trigger's accessible description. */
|
|
17
|
+
hint?: string;
|
|
18
|
+
/** Shows `hint` in the error colour. */
|
|
19
|
+
isInvalid?: boolean;
|
|
20
|
+
/** Trigger text while the field holds no colour. */
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
/** The colour the picker opens on when the field holds none; opening it reports this colour through `onChange`. */
|
|
23
|
+
defaultColor?: string;
|
|
24
|
+
/** Shows a Remove button beside the trigger that empties the field, for a colour the user may leave out. */
|
|
25
|
+
isClearable?: boolean;
|
|
26
|
+
/** Blocks the trigger and the Remove button. */
|
|
27
|
+
isDisabled?: boolean;
|
|
28
|
+
/** Marks the label with an asterisk and adds "(required)" to the trigger's name. */
|
|
29
|
+
isRequired?: boolean;
|
|
30
|
+
/** Size of the trigger button. */
|
|
31
|
+
size?: ButtonProps['size'];
|
|
32
|
+
/** Names the trigger when there is no `label`. */
|
|
33
|
+
'aria-label'?: string;
|
|
34
|
+
/** Overrides the root `data-testid` (defaults to `fd-color-picker-field`); the trigger, Remove button and picker derive from it. */
|
|
35
|
+
'data-testid'?: string;
|
|
36
|
+
}
|
|
37
|
+
export type ColorPickerFieldProps = ColorPickerFieldBaseProps & ({
|
|
38
|
+
label: string;
|
|
39
|
+
} | {
|
|
40
|
+
'aria-label': string;
|
|
41
|
+
});
|
|
42
|
+
interface ColorPickerFieldPopoverProps {
|
|
43
|
+
/** The picker shown in the popover; `index.tsx` passes the all-in-one `ColorPicker`, which this file cannot import without a cycle. */
|
|
44
|
+
children: ReactNode;
|
|
45
|
+
}
|
|
46
|
+
export declare const ColorPickerField: ({ children, ref, value, onChange, onChangeEnd, onBlur, label, hint, isInvalid, placeholder, defaultColor, isClearable, isDisabled, isRequired, size, "aria-label": ariaLabel, "data-testid": dataTestId, }: ColorPickerFieldProps & ColorPickerFieldPopoverProps) => import("react").JSX.Element;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=ColorPickerField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPickerField.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/ColorPicker/components/ColorPickerField.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,8CAA8C,CAAC;AAGxF,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,GAAG,EAA8B,MAAM,OAAO,CAAC;AAS7E,UAAU,yBAAyB;IACjC,wFAAwF;IACxF,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1B,qHAAqH;IACrH,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjC,gIAAgI;IAChI,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,kIAAkI;IAClI,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7C,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,0FAA0F;IAC1F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yFAAyF;IACzF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mHAAmH;IACnH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4GAA4G;IAC5G,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gDAAgD;IAChD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oFAAoF;IACpF,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kCAAkC;IAClC,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,kDAAkD;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oIAAoI;IACpI,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAGD,MAAM,MAAM,qBAAqB,GAAG,yBAAyB,GAAG,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE/G,UAAU,4BAA4B;IACpC,uIAAuI;IACvI,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,gBAAgB,GAAI,4MAkB9B,qBAAqB,GAAG,4BAA4B,gCA+GtD,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Plus } from '@flipdish/ui-icons';
|
|
3
|
+
import { Button } from '@flipdish/ui-library/components/atoms/Button';
|
|
4
|
+
import { HintText } from '@flipdish/ui-library/components/atoms/Input';
|
|
5
|
+
import { useResolvedTestId, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
6
|
+
import { useId, useRef, useCallback } from 'react';
|
|
7
|
+
import { DialogTrigger, Dialog } from 'react-aria-components';
|
|
8
|
+
import { ScrollClosingPopover } from '../../../__internal__/popover/ScrollClosingPopover.js';
|
|
9
|
+
import { setRef } from '../../../../utilities/__internal__/refUtils/ref.utils.js';
|
|
10
|
+
import { toHexString } from '../colorPicker.utils.js';
|
|
11
|
+
import { useColorFieldEdit } from '../hooks/useColorFieldEdit.js';
|
|
12
|
+
import { Provider } from '../providers/ColorPicker.provider.js';
|
|
13
|
+
import { ColorPickerDialog } from './ColorPickerDialog.js';
|
|
14
|
+
|
|
15
|
+
const ColorPickerField = ({ children, ref, value, onChange, onChangeEnd, onBlur, label, hint, isInvalid, placeholder = 'Add colour', defaultColor, isClearable, isDisabled, isRequired, size = 'md', 'aria-label': ariaLabel, 'data-testid': dataTestId, }) => {
|
|
16
|
+
const fieldTestId = useResolvedTestId({ testId: dataTestId, segment: 'color-picker-field', rootName: 'color-picker-field' });
|
|
17
|
+
const labelId = useId();
|
|
18
|
+
const triggerId = useId();
|
|
19
|
+
const hintId = useId();
|
|
20
|
+
const { color, startValue, onOpenChange, onPick, onRemove, onKeyDownCapture } = useColorFieldEdit({ value, defaultColor, onChange, onChangeEnd });
|
|
21
|
+
const triggerText = color ? toHexString(color) : placeholder;
|
|
22
|
+
// A button cannot carry `aria-required`, so a name given by `aria-label` says it in words, as the visible label does,
|
|
23
|
+
// and ends with the trigger's own text, so the value is announced with the name here too.
|
|
24
|
+
const triggerName = ariaLabel && `${isRequired ? `${ariaLabel} (required)` : ariaLabel} ${triggerText}`;
|
|
25
|
+
const root = useRef(null);
|
|
26
|
+
// Stable, so React does not detach and re-attach the consumer's ref on every render.
|
|
27
|
+
const setRoot = useCallback((element) => {
|
|
28
|
+
root.current = element;
|
|
29
|
+
const cleanup = setRef(ref, element);
|
|
30
|
+
// A callback ref may return a cleanup, which React then runs in place of calling the ref with `null`; passing it on keeps that contract.
|
|
31
|
+
if (!cleanup)
|
|
32
|
+
return undefined;
|
|
33
|
+
return () => {
|
|
34
|
+
root.current = null;
|
|
35
|
+
cleanup();
|
|
36
|
+
};
|
|
37
|
+
}, [ref]);
|
|
38
|
+
const handleRemove = () => {
|
|
39
|
+
onRemove();
|
|
40
|
+
// The Remove button leaves the page with the colour, so focus moves to the trigger instead of being lost.
|
|
41
|
+
root.current?.querySelector('button')?.focus();
|
|
42
|
+
};
|
|
43
|
+
return (jsxs("div", { ref: setRoot, "data-testid": fieldTestId, className: "flex flex-col items-start gap-1.5", children: [label && (jsxs("span", { id: labelId, className: "flex items-center gap-0.5 text-sm font-medium text-secondary", children: [label, isRequired && (jsxs(Fragment, { children: [jsx("span", { "aria-hidden": "true", className: "text-brand-tertiary", children: "*" }), jsx("span", { className: "sr-only", children: "(required)" })] }))] })), jsxs("div", { className: "flex items-center gap-3", children: [jsxs(DialogTrigger, { onOpenChange: onOpenChange, children: [jsx(Button, { id: triggerId, size: size, color: "secondary", isDisabled: isDisabled, onBlur: onBlur,
|
|
44
|
+
// The picked colour is the user's data, not a token, so it can only be set inline.
|
|
45
|
+
iconLeading: color ? (jsx("span", { "aria-hidden": "true", className: "size-4 shrink-0 rounded-full ring-1 ring-alpha-black/10 ring-inset", style: { backgroundColor: toHexString(color) } })) : (Plus), "aria-labelledby": label ? `${labelId} ${triggerId}` : undefined, "aria-label": label ? undefined : triggerName, "aria-describedby": hint ? hintId : undefined, "data-testid": joinTestId(fieldTestId, 'trigger'), children: triggerText }), jsx(ScrollClosingPopover, { placement: "bottom start", offset: 8, children: jsx("div", { className: "contents", onKeyDownCapture: onKeyDownCapture, children: jsx(Dialog, { "aria-label": label ?? ariaLabel, className: "outline-hidden", children: jsx(ColorPickerDialog, { className: "p-4", "data-testid": joinTestId(fieldTestId, 'picker'), children: jsx(Provider, { defaultValue: startValue, onChange: onPick, children: children }) }) }) }) })] }), isClearable && color && (jsx(Button, { size: size, color: "link-gray", isDisabled: isDisabled, "aria-label": `Remove ${label ?? ariaLabel ?? 'colour'}`, onPress: handleRemove, "data-testid": joinTestId(fieldTestId, 'remove'), children: "Remove" }))] }), hint && (jsx(HintText, { id: hintId, isInvalid: isInvalid, children: hint }))] }));
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { ColorPickerField };
|
|
49
|
+
//# sourceMappingURL=ColorPickerField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPickerField.js","sources":["../../../../../src/components/organisms/ColorPicker/components/ColorPickerField.tsx"],"sourcesContent":[null],"names":["_jsxs","_Fragment","_jsx","AriaDialogTrigger","AriaDialog"],"mappings":";;;;;;;;;;;;;;MA0Da,gBAA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