@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
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { Calendar } from '@flipdish/ui-icons';
|
|
3
3
|
import { Button } from '@flipdish/ui-library/components/atoms/Button';
|
|
4
|
+
import { Label, HintText } from '@flipdish/ui-library/components/atoms/Input';
|
|
5
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
4
6
|
import { useResolvedTestId, TestIdProvider, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
5
7
|
import { today, getLocalTimeZone, endOfMonth, startOfMonth, endOfWeek, startOfWeek } from '@internationalized/date';
|
|
6
8
|
import { useDateFormatter } from '@react-aria/i18n';
|
|
7
9
|
import { useControlledState } from '@react-stately/utils';
|
|
8
|
-
import { useState, useMemo } from 'react';
|
|
10
|
+
import { useState, useMemo, useRef } from 'react';
|
|
9
11
|
import { useLocale, DateRangePicker as DateRangePicker$1, Group } from 'react-aria-components';
|
|
10
12
|
import { CalendarOverlay } from './CalendarOverlay.js';
|
|
11
13
|
import { InputDateBase } from './InputDate.js';
|
|
@@ -19,7 +21,7 @@ const highlightedDates = [today(getLocalTimeZone())];
|
|
|
19
21
|
*
|
|
20
22
|
* @summary popover calendar for selecting a date range
|
|
21
23
|
*/
|
|
22
|
-
const DateRangePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCancel, onOpenChange, size = 'sm', presets: presetsProp, placeholder = 'Select dates', 'data-testid': dataTestId, ...props }) => {
|
|
24
|
+
const DateRangePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCancel, onOpenChange, size = 'sm', presets: presetsProp, placeholder = 'Select dates', label, hint, className, ref, 'data-testid': dataTestId, ...props }) => {
|
|
23
25
|
const { locale } = useLocale();
|
|
24
26
|
const formatter = useDateFormatter({
|
|
25
27
|
month: 'short',
|
|
@@ -73,7 +75,12 @@ const DateRangePicker = ({ value: valueProp, defaultValue, onChange, onApply, on
|
|
|
73
75
|
}), [locale]);
|
|
74
76
|
const presets = presetsProp ?? defaultPresets;
|
|
75
77
|
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'date-range-picker', rootName: 'date-range-picker' });
|
|
76
|
-
|
|
78
|
+
const triggerGroupRef = useRef(null);
|
|
79
|
+
// react-aria sends a label click to the first date field and skips the trigger, the only control a closed picker has.
|
|
80
|
+
const focusTrigger = () => triggerGroupRef.current?.querySelector('button')?.focus();
|
|
81
|
+
return (jsx(TestIdProvider, { value: rootTestId, children: jsx(DateRangePicker$1
|
|
82
|
+
// A visible label names the picker; without one this default does, unless `aria-label` is passed.
|
|
83
|
+
, { "aria-label": label ? undefined : 'Date range picker', shouldCloseOnSelect: false, ...props, ref: ref, className: (state) => cx('flex flex-col items-start gap-1.5', typeof className === 'function' ? className(state) : className), value: draftValue, onChange: setDraftValue, onOpenChange: (isOpen) => {
|
|
77
84
|
// Re-seed the draft from the latest committed value every time the popover opens, so
|
|
78
85
|
// a stale in-progress edit from a previous Cancel/dismiss never leaks in, and a
|
|
79
86
|
// controlled `value` that changed while closed is always the starting point.
|
|
@@ -82,17 +89,17 @@ const DateRangePicker = ({ value: valueProp, defaultValue, onChange, onApply, on
|
|
|
82
89
|
setFocusedValue(value?.start ?? null);
|
|
83
90
|
}
|
|
84
91
|
onOpenChange?.(isOpen);
|
|
85
|
-
}, "data-testid": rootTestId, children: [jsx(Group, { children: jsx(Button, { size: size, color: "secondary", iconLeading: Calendar, "data-testid": joinTestId(rootTestId, 'trigger'), children: formattedRange ?? jsx("span", { className: "text-placeholder", children: placeholder }) }) }), jsx(CalendarOverlay, { "aria-label": props['aria-label'] ?? 'Date range picker', "data-testid": joinTestId(rootTestId, 'popover'), className: "flex focus:outline-hidden", children: ({ close }) => (jsxs(Fragment, { children: [jsx("div", { className: "hidden w-38 flex-col gap-0.5 border-r border-solid border-secondary p-3 lg:flex", children: Object.values(presets).map((preset) => (jsx(RangePresetButton, { value: preset.value, onClick: () => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
}, "data-testid": rootTestId, children: ({ isInvalid, isRequired }) => (jsxs(Fragment, { children: [label && (jsx(Label, { isRequired: isRequired, onClick: focusTrigger, children: label })), jsx(Group, { ref: triggerGroupRef, children: jsx(Button, { size: size, color: "secondary", iconLeading: Calendar, className: cx(isInvalid && 'ring-error_subtle'), "aria-label": `Calendar, ${formattedRange ?? placeholder}`, "data-testid": joinTestId(rootTestId, 'trigger'), children: formattedRange ?? jsx("span", { className: "text-placeholder", children: placeholder }) }) }), hint && jsx(HintText, { isInvalid: isInvalid, children: hint }), jsx(CalendarOverlay, { "aria-label": props['aria-label'] ?? label ?? 'Date range picker', "data-testid": joinTestId(rootTestId, 'popover'), className: "flex focus:outline-hidden", children: ({ close }) => (jsxs(Fragment, { children: [jsx("div", { className: "hidden w-38 flex-col gap-0.5 border-r border-solid border-secondary p-3 lg:flex", children: Object.values(presets).map((preset) => (jsx(RangePresetButton, { value: preset.value, onClick: () => {
|
|
93
|
+
setDraftValue(preset.value);
|
|
94
|
+
setFocusedValue(preset.value.start);
|
|
95
|
+
}, children: preset.label }, preset.label))) }), jsxs("div", { className: "flex flex-col max-md:w-full", children: [jsx(RangeCalendar, { focusedValue: focusedValue, onFocusChange: setFocusedValue, highlightedDates: highlightedDates, presets: presets, className: "max-md:w-full max-md:self-center max-sm:max-w-78 sm:max-md:max-w-82" }), jsxs("div", { className: "sticky bottom-0 flex justify-between gap-3 border-t border-secondary bg-primary px-4 pt-4 pb-[calc(1rem+env(safe-area-inset-bottom))]", children: [jsxs("div", { className: "hidden items-center gap-2 md:flex", children: [jsx(InputDateBase, { slot: "start", size: "sm" }), jsx("div", { className: "text-md text-quaternary", children: "\u2013" }), jsx(InputDateBase, { slot: "end", size: "sm" })] }), jsxs("div", { className: "grid w-full grid-cols-2 gap-3 md:flex md:w-auto", children: [jsx(Button, { size: "sm", color: "secondary", "data-testid": joinTestId(rootTestId, 'cancel'), onClick: () => {
|
|
96
|
+
onCancel?.();
|
|
97
|
+
close();
|
|
98
|
+
}, children: "Cancel" }), jsx(Button, { size: "sm", color: "primary", "data-testid": joinTestId(rootTestId, 'apply'), onClick: () => {
|
|
99
|
+
setValue(draftValue);
|
|
100
|
+
onApply?.();
|
|
101
|
+
close();
|
|
102
|
+
}, children: "Apply" })] })] })] })] })) })] })) }) }));
|
|
96
103
|
};
|
|
97
104
|
|
|
98
105
|
export { DateRangePicker };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangePicker.js","sources":["../../../../../src/components/organisms/DatePicker/components/DateRangePicker.tsx"],"sourcesContent":[null],"names":["_jsx","
|
|
1
|
+
{"version":3,"file":"DateRangePicker.js","sources":["../../../../../src/components/organisms/DatePicker/components/DateRangePicker.tsx"],"sourcesContent":[null],"names":["_jsx","AriaDateRangePicker","_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3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var uiIcons = require('@flipdish/ui-icons');
|
|
5
5
|
var Button = require('@flipdish/ui-library/components/atoms/Button');
|
|
6
|
+
var Input = require('@flipdish/ui-library/components/atoms/Input');
|
|
7
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
6
8
|
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
7
9
|
var date = require('@internationalized/date');
|
|
8
10
|
var i18n = require('@react-aria/i18n');
|
|
@@ -21,7 +23,7 @@ const highlightedDates = [date.today(date.getLocalTimeZone())];
|
|
|
21
23
|
*
|
|
22
24
|
* @summary popover calendar for selecting a single date
|
|
23
25
|
*/
|
|
24
|
-
const DatePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCancel, onOpenChange, size = 'sm', placeholder = 'Select date', 'data-testid': dataTestId, ...props }) => {
|
|
26
|
+
const DatePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCancel, onOpenChange, size = 'sm', placeholder = 'Select date', label, hint, className, ref, 'data-testid': dataTestId, ...props }) => {
|
|
25
27
|
const formatter = i18n.useDateFormatter({
|
|
26
28
|
month: 'short',
|
|
27
29
|
day: 'numeric',
|
|
@@ -35,7 +37,9 @@ const DatePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCance
|
|
|
35
37
|
const [draftValue, setDraftValue] = React.useState(value);
|
|
36
38
|
const formattedDate = value ? formatter.format(value.toDate(date.getLocalTimeZone())) : placeholder;
|
|
37
39
|
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'date-picker', rootName: 'date-picker' });
|
|
38
|
-
return (jsxRuntime.jsx(testIdUtils.TestIdProvider, { value: rootTestId, children: jsxRuntime.
|
|
40
|
+
return (jsxRuntime.jsx(testIdUtils.TestIdProvider, { value: rootTestId, children: jsxRuntime.jsx(reactAriaComponents.DatePicker
|
|
41
|
+
// A visible label names the picker; without one this default does, unless `aria-label` is passed.
|
|
42
|
+
, { "aria-label": label ? undefined : 'Date picker', shouldCloseOnSelect: false, ...props, ref: ref, className: (state) => cx.cx('flex flex-col items-start gap-1.5', typeof className === 'function' ? className(state) : className), value: draftValue, onChange: setDraftValue, onOpenChange: (isOpen) => {
|
|
39
43
|
// Re-seed the draft from the latest committed value every time the popover opens, so
|
|
40
44
|
// a stale in-progress edit from a previous Cancel/dismiss never leaks in, and a
|
|
41
45
|
// controlled `value` that changed while closed is always the starting point.
|
|
@@ -43,14 +47,14 @@ const DatePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCance
|
|
|
43
47
|
setDraftValue(value);
|
|
44
48
|
}
|
|
45
49
|
onOpenChange?.(isOpen);
|
|
46
|
-
}, "data-testid": rootTestId, children: [jsxRuntime.jsx(reactAriaComponents.Group, { children: jsxRuntime.jsx(Button.Button, { size: size, color: "secondary", iconLeading: uiIcons.Calendar, "data-testid": testIdUtils.joinTestId(rootTestId, 'trigger'), children: formattedDate }) }), jsxRuntime.jsx(CalendarOverlay.CalendarOverlay, { "aria-label": props['aria-label'] ?? 'Date picker', "data-testid": testIdUtils.joinTestId(rootTestId, 'popover'), children: ({ close }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "flex w-full max-w-78 px-4 py-5 sm:max-w-82 sm:px-6", children: jsxRuntime.jsx(Calendar.Calendar, { highlightedDates: highlightedDates }) }), jsxRuntime.jsxs("div", { className: "sticky bottom-0 grid w-full grid-cols-2 gap-3 border-t border-secondary bg-primary px-4 pt-4 pb-[calc(1rem+env(safe-area-inset-bottom))]", children: [jsxRuntime.jsx(Button.Button, { size: "md", color: "secondary", "data-testid": testIdUtils.joinTestId(rootTestId, 'cancel'), onClick: () => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
}, "data-testid": rootTestId, children: ({ isInvalid, isRequired }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [label && jsxRuntime.jsx(Input.Label, { isRequired: isRequired, children: label }), jsxRuntime.jsx(reactAriaComponents.Group, { children: jsxRuntime.jsx(Button.Button, { size: size, color: "secondary", iconLeading: uiIcons.Calendar, className: cx.cx(isInvalid && 'ring-error_subtle'), "aria-label": `Calendar, ${formattedDate}`, "data-testid": testIdUtils.joinTestId(rootTestId, 'trigger'), children: formattedDate }) }), hint && jsxRuntime.jsx(Input.HintText, { isInvalid: isInvalid, children: hint }), jsxRuntime.jsx(CalendarOverlay.CalendarOverlay, { "aria-label": props['aria-label'] ?? label ?? 'Date picker', "data-testid": testIdUtils.joinTestId(rootTestId, 'popover'), children: ({ close }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "flex w-full max-w-78 px-4 py-5 sm:max-w-82 sm:px-6", children: jsxRuntime.jsx(Calendar.Calendar, { highlightedDates: highlightedDates }) }), jsxRuntime.jsxs("div", { className: "sticky bottom-0 grid w-full grid-cols-2 gap-3 border-t border-secondary bg-primary px-4 pt-4 pb-[calc(1rem+env(safe-area-inset-bottom))]", children: [jsxRuntime.jsx(Button.Button, { size: "md", color: "secondary", "data-testid": testIdUtils.joinTestId(rootTestId, 'cancel'), onClick: () => {
|
|
51
|
+
onCancel?.();
|
|
52
|
+
close();
|
|
53
|
+
}, children: "Cancel" }), jsxRuntime.jsx(Button.Button, { size: "md", color: "primary", "data-testid": testIdUtils.joinTestId(rootTestId, 'apply'), onClick: () => {
|
|
54
|
+
setValue(draftValue);
|
|
55
|
+
onApply?.();
|
|
56
|
+
close();
|
|
57
|
+
}, children: "Apply" })] })] })) })] })) }) }));
|
|
54
58
|
};
|
|
55
59
|
|
|
56
60
|
exports.DateRangePicker = DateRangePicker.DateRangePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/organisms/DatePicker/index.tsx"],"sourcesContent":[null],"names":["today","getLocalTimeZone","useDateFormatter","useControlledState","useState","useResolvedTestId","_jsx","TestIdProvider","_jsxs","
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/organisms/DatePicker/index.tsx"],"sourcesContent":[null],"names":["today","getLocalTimeZone","useDateFormatter","useControlledState","useState","useResolvedTestId","_jsx","TestIdProvider","AriaDatePicker","cx","_jsxs","_Fragment","Label","AriaGroup","Button","CalendarIcon","joinTestId","HintText","CalendarOverlay","Calendar"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAM,gBAAgB,GAAG,CAACA,UAAK,CAACC,qBAAgB,EAAE,CAAC,CAAC;AAqBpD;;;;;AAKG;MACU,UAAU,GAAG,CAAC,EACzB,KAAK,EAAE,SAAS,EAChB,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,IAAI,GAAG,IAAI,EACX,WAAW,GAAG,aAAa,EAC3B,KAAK,EACL,IAAI,EACJ,SAAS,EACT,GAAG,EACH,aAAa,EAAE,UAAU,EACzB,GAAG,KAAK,EACQ,KAAI;IACpB,MAAM,SAAS,GAAGC,qBAAgB,CAAC;AACjC,QAAA,KAAK,EAAE,OAAO;AACd,QAAA,GAAG,EAAE,SAAS;AACd,QAAA,IAAI,EAAE,SAAS;AAChB,KAAA,CAAC;;;;;AAKF,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAGC,wBAAkB,CAAC,SAAS,EAAE,YAAY,IAAI,IAAI,EAAE,QAAQ,CAAC;IACvF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAGC,cAAQ,CAAmB,KAAK,CAAC;IAErE,MAAM,aAAa,GAAG,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAACH,qBAAgB,EAAE,CAAC,CAAC,GAAG,WAAW;AAE9F,IAAA,MAAM,UAAU,GAAGI,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;IAE7G,QAC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Y,+BAAe,EAAA,EAAA,YAAA,EAAa,KAAK,CAAC,YAAY,CAAC,IAAI,KAAK,IAAI,aAAa,EAAA,aAAA,EAAeF,sBAAU,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,QAAA,EACvH,CAAC,EAAE,KAAK,EAAE,MACTN,eAAA,CAAAC,mBAAA,EAAA,EAAA,QAAA,EAAA,CAEEL,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,oDAAoD,EAAA,QAAA,EACjEA,cAAA,CAACa,iBAAQ,EAAA,EAAC,gBAAgB,EAAE,gBAAgB,EAAA,CAAI,EAAA,CAC5C,EACNT,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,0IAA0I,EAAA,QAAA,EAAA,CACvJJ,cAAA,CAACQ,aAAM,EAAA,EACL,IAAI,EAAC,IAAI,EACT,KAAK,EAAC,WAAW,iBACJE,sBAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,EAC7C,OAAO,EAAE,MAAK;gDACZ,QAAQ,IAAI;AACZ,gDAAA,KAAK,EAAE;4CACT,CAAC,EAAA,QAAA,EAAA,QAAA,EAAA,CAGM,EACTV,cAAA,CAACQ,aAAM,IACL,IAAI,EAAC,IAAI,EACT,KAAK,EAAC,SAAS,EAAA,aAAA,EACFE,sBAAU,CAAC,UAAU,EAAE,OAAO,CAAC,EAC5C,OAAO,EAAE,MAAK;gDACZ,QAAQ,CAAC,UAAU,CAAC;gDACpB,OAAO,IAAI;AACX,gDAAA,KAAK,EAAE;4CACT,CAAC,EAAA,QAAA,EAAA,OAAA,EAAA,CAGM,CAAA,EAAA,CACL,CAAA,EAAA,CACL,CACJ,EAAA,CACe,IACjB,CACJ,EAAA,CACc,EAAA,CACF;AAErB;;;;"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { type ButtonProps } from '@flipdish/ui-library/components/atoms/Button';
|
|
2
|
+
import { type ReactNode, type Ref } from 'react';
|
|
2
3
|
import type { DatePickerProps as AriaDatePickerProps, DateValue } from 'react-aria-components';
|
|
3
4
|
export { DateRangePicker, type DateRangePickerProps } from './components/DateRangePicker';
|
|
4
5
|
export { RangeCalendar, type RangeCalendarProps } from './components/RangeCalendar';
|
|
5
6
|
export interface DatePickerProps extends AriaDatePickerProps<DateValue> {
|
|
7
|
+
/** Visible label above the trigger; it names the trigger and the calendar. When omitted, pass `aria-label`. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Helper text beneath the trigger, read out as its description; shown as an error while `isInvalid` is set. */
|
|
10
|
+
hint?: ReactNode;
|
|
11
|
+
/** Ref forwarded to the root element, which holds the label, trigger and hint. */
|
|
12
|
+
ref?: Ref<HTMLDivElement>;
|
|
6
13
|
/** The function to call when the apply button is clicked. */
|
|
7
14
|
onApply?: () => void;
|
|
8
15
|
/** The function to call when the cancel button is clicked. */
|
|
@@ -20,5 +27,5 @@ export interface DatePickerProps extends AriaDatePickerProps<DateValue> {
|
|
|
20
27
|
*
|
|
21
28
|
* @summary popover calendar for selecting a single date
|
|
22
29
|
*/
|
|
23
|
-
export declare const DatePicker: ({ value: valueProp, defaultValue, onChange, onApply, onCancel, onOpenChange, size, placeholder, "data-testid": dataTestId, ...props }: DatePickerProps) => import("react").JSX.Element;
|
|
30
|
+
export declare const DatePicker: ({ value: valueProp, defaultValue, onChange, onApply, onCancel, onOpenChange, size, placeholder, label, hint, className, ref, "data-testid": dataTestId, ...props }: DatePickerProps) => import("react").JSX.Element;
|
|
24
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/DatePicker/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/DatePicker/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,8CAA8C,CAAC;AAOxF,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,GAAG,EAAY,MAAM,OAAO,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,IAAI,mBAAmB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAK/F,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAIpF,MAAM,WAAW,eAAgB,SAAQ,mBAAmB,CAAC,SAAS,CAAC;IACrE,+GAA+G;IAC/G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gHAAgH;IAChH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,kFAAkF;IAClF,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1B,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sHAAsH;IACtH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,oKAexB,eAAe,gCAiGjB,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { Calendar } from '@flipdish/ui-icons';
|
|
3
3
|
import { Button } from '@flipdish/ui-library/components/atoms/Button';
|
|
4
|
+
import { Label, HintText } from '@flipdish/ui-library/components/atoms/Input';
|
|
5
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
4
6
|
import { useResolvedTestId, TestIdProvider, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
5
7
|
import { today, getLocalTimeZone } from '@internationalized/date';
|
|
6
8
|
import { useDateFormatter } from '@react-aria/i18n';
|
|
@@ -19,7 +21,7 @@ const highlightedDates = [today(getLocalTimeZone())];
|
|
|
19
21
|
*
|
|
20
22
|
* @summary popover calendar for selecting a single date
|
|
21
23
|
*/
|
|
22
|
-
const DatePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCancel, onOpenChange, size = 'sm', placeholder = 'Select date', 'data-testid': dataTestId, ...props }) => {
|
|
24
|
+
const DatePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCancel, onOpenChange, size = 'sm', placeholder = 'Select date', label, hint, className, ref, 'data-testid': dataTestId, ...props }) => {
|
|
23
25
|
const formatter = useDateFormatter({
|
|
24
26
|
month: 'short',
|
|
25
27
|
day: 'numeric',
|
|
@@ -33,7 +35,9 @@ const DatePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCance
|
|
|
33
35
|
const [draftValue, setDraftValue] = useState(value);
|
|
34
36
|
const formattedDate = value ? formatter.format(value.toDate(getLocalTimeZone())) : placeholder;
|
|
35
37
|
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'date-picker', rootName: 'date-picker' });
|
|
36
|
-
return (jsx(TestIdProvider, { value: rootTestId, children:
|
|
38
|
+
return (jsx(TestIdProvider, { value: rootTestId, children: jsx(DatePicker$1
|
|
39
|
+
// A visible label names the picker; without one this default does, unless `aria-label` is passed.
|
|
40
|
+
, { "aria-label": label ? undefined : 'Date picker', shouldCloseOnSelect: false, ...props, ref: ref, className: (state) => cx('flex flex-col items-start gap-1.5', typeof className === 'function' ? className(state) : className), value: draftValue, onChange: setDraftValue, onOpenChange: (isOpen) => {
|
|
37
41
|
// Re-seed the draft from the latest committed value every time the popover opens, so
|
|
38
42
|
// a stale in-progress edit from a previous Cancel/dismiss never leaks in, and a
|
|
39
43
|
// controlled `value` that changed while closed is always the starting point.
|
|
@@ -41,14 +45,14 @@ const DatePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCance
|
|
|
41
45
|
setDraftValue(value);
|
|
42
46
|
}
|
|
43
47
|
onOpenChange?.(isOpen);
|
|
44
|
-
}, "data-testid": rootTestId, children: [jsx(Group, { children: jsx(Button, { size: size, color: "secondary", iconLeading: Calendar, "data-testid": joinTestId(rootTestId, 'trigger'), children: formattedDate }) }), jsx(CalendarOverlay, { "aria-label": props['aria-label'] ?? 'Date picker', "data-testid": joinTestId(rootTestId, 'popover'), children: ({ close }) => (jsxs(Fragment, { children: [jsx("div", { className: "flex w-full max-w-78 px-4 py-5 sm:max-w-82 sm:px-6", children: jsx(Calendar$1, { highlightedDates: highlightedDates }) }), jsxs("div", { className: "sticky bottom-0 grid w-full grid-cols-2 gap-3 border-t border-secondary bg-primary px-4 pt-4 pb-[calc(1rem+env(safe-area-inset-bottom))]", children: [jsx(Button, { size: "md", color: "secondary", "data-testid": joinTestId(rootTestId, 'cancel'), onClick: () => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
}, "data-testid": rootTestId, children: ({ isInvalid, isRequired }) => (jsxs(Fragment, { children: [label && jsx(Label, { isRequired: isRequired, children: label }), jsx(Group, { children: jsx(Button, { size: size, color: "secondary", iconLeading: Calendar, className: cx(isInvalid && 'ring-error_subtle'), "aria-label": `Calendar, ${formattedDate}`, "data-testid": joinTestId(rootTestId, 'trigger'), children: formattedDate }) }), hint && jsx(HintText, { isInvalid: isInvalid, children: hint }), jsx(CalendarOverlay, { "aria-label": props['aria-label'] ?? label ?? 'Date picker', "data-testid": joinTestId(rootTestId, 'popover'), children: ({ close }) => (jsxs(Fragment, { children: [jsx("div", { className: "flex w-full max-w-78 px-4 py-5 sm:max-w-82 sm:px-6", children: jsx(Calendar$1, { highlightedDates: highlightedDates }) }), jsxs("div", { className: "sticky bottom-0 grid w-full grid-cols-2 gap-3 border-t border-secondary bg-primary px-4 pt-4 pb-[calc(1rem+env(safe-area-inset-bottom))]", children: [jsx(Button, { size: "md", color: "secondary", "data-testid": joinTestId(rootTestId, 'cancel'), onClick: () => {
|
|
49
|
+
onCancel?.();
|
|
50
|
+
close();
|
|
51
|
+
}, children: "Cancel" }), jsx(Button, { size: "md", color: "primary", "data-testid": joinTestId(rootTestId, 'apply'), onClick: () => {
|
|
52
|
+
setValue(draftValue);
|
|
53
|
+
onApply?.();
|
|
54
|
+
close();
|
|
55
|
+
}, children: "Apply" })] })] })) })] })) }) }));
|
|
52
56
|
};
|
|
53
57
|
|
|
54
58
|
export { DatePicker };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/organisms/DatePicker/index.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/organisms/DatePicker/index.tsx"],"sourcesContent":[null],"names":["_jsx","AriaDatePicker","_jsxs","_Fragment","AriaGroup","CalendarIcon","Calendar"],"mappings":";;;;;;;;;;;;;;;;AAmBA,MAAM,gBAAgB,GAAG,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,CAAC;AAqBpD;;;;;AAKG;MACU,UAAU,GAAG,CAAC,EACzB,KAAK,EAAE,SAAS,EAChB,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,IAAI,GAAG,IAAI,EACX,WAAW,GAAG,aAAa,EAC3B,KAAK,EACL,IAAI,EACJ,SAAS,EACT,GAAG,EACH,aAAa,EAAE,UAAU,EACzB,GAAG,KAAK,EACQ,KAAI;IACpB,MAAM,SAAS,GAAG,gBAAgB,CAAC;AACjC,QAAA,KAAK,EAAE,OAAO;AACd,QAAA,GAAG,EAAE,SAAS;AACd,QAAA,IAAI,EAAE,SAAS;AAChB,KAAA,CAAC;;;;;AAKF,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,kBAAkB,CAAC,SAAS,EAAE,YAAY,IA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AAC;gDACpB,OAAO,IAAI;AACX,gDAAA,KAAK,EAAE;4CACT,CAAC,EAAA,QAAA,EAAA,OAAA,EAAA,CAGM,CAAA,EAAA,CACL,CAAA,EAAA,CACL,CACJ,EAAA,CACe,IACjB,CACJ,EAAA,CACc,EAAA,CACF;AAErB;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Moves focus off an element that is about to unmount or switch itself off, so it does not fall back to the top of the page.
|
|
7
|
+
*
|
|
8
|
+
* @param origin The element focus is leaving, or any element beside it; the search starts from its nearest container.
|
|
9
|
+
* @param targetSelector A CSS selector for the control that should take focus, looked up inside each container in turn.
|
|
10
|
+
* @param containerSelector A CSS selector for the containers, matched against `origin` and its ancestors, nearest first.
|
|
11
|
+
* @returns The element that took focus: the first target that can, in the nearest container that holds one, else the nearest
|
|
12
|
+
* container that can take focus itself (it needs `tabIndex={-1}`), else `null` when nothing could.
|
|
13
|
+
*/
|
|
14
|
+
const moveFocusWithin = (origin, targetSelector, containerSelector) => {
|
|
15
|
+
const containers = [];
|
|
16
|
+
// Nearest first: a section inside a form is searched before the form around it.
|
|
17
|
+
for (let container = origin?.closest(containerSelector); container; container = container.parentElement?.closest(containerSelector))
|
|
18
|
+
containers.push(container);
|
|
19
|
+
const takesFocus = (element) => {
|
|
20
|
+
element?.focus();
|
|
21
|
+
return Boolean(element) && element?.ownerDocument.activeElement === element;
|
|
22
|
+
};
|
|
23
|
+
for (const container of containers) {
|
|
24
|
+
// Every match is tried: a disabled one must not hide an enabled one after it.
|
|
25
|
+
const target = [...container.querySelectorAll(targetSelector)].find(takesFocus);
|
|
26
|
+
if (target)
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
// A disabled or missing control cannot take focus, so the nearest container that can does.
|
|
30
|
+
return containers.find(takesFocus) ?? null;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Hands focus to a named control before the element holding it goes away, such as an alert that both of its buttons
|
|
34
|
+
* remove. Call `returnFocus` first, then run the action that unmounts or disables the focused element.
|
|
35
|
+
*
|
|
36
|
+
* @param targetSelector A CSS selector for the control that takes focus, found inside the nearest container that holds one; with none, `returnFocus` does nothing.
|
|
37
|
+
* @param containerSelector A CSS selector for that container; it takes focus itself when the target cannot, so give it `tabIndex={-1}`.
|
|
38
|
+
* @returns `originRef` for an element inside the container, and `returnFocus`, which moves focus and reports where it landed.
|
|
39
|
+
*/
|
|
40
|
+
const useReturnFocus = (targetSelector, containerSelector = 'form, section') => {
|
|
41
|
+
const originRef = React.useRef(null);
|
|
42
|
+
const returnFocus = () => (targetSelector ? moveFocusWithin(originRef.current, targetSelector, containerSelector) : null);
|
|
43
|
+
return { originRef, returnFocus };
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.moveFocusWithin = moveFocusWithin;
|
|
47
|
+
exports.useReturnFocus = useReturnFocus;
|
|
48
|
+
//# sourceMappingURL=useReturnFocus.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReturnFocus.cjs","sources":["../../../../src/hooks/__internal__/useReturnFocus/useReturnFocus.ts"],"sourcesContent":[null],"names":["useRef"],"mappings":";;;;AAIA;;;;;;;;AAQG;AACI,MAAM,eAAe,GAAG,CAAC,MAAsB,EAAE,cAAsB,EAAE,iBAAyB,KAAwB;IAC/H,MAAM,UAAU,GAAkB,EAAE;;IAEpC,KACE,IAAI,SAAS,GAAG,MAAM,EAAE,OAAO,CAAc,iBAAiB,CAAC,EAC/D,SAAS,EACT,SAAS,GAAG,SAAS,CAAC,aAAa,EAAE,OAAO,CAAc,iBAAiB,CAAC;AAE5E,QAAA,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC;AAE5B,IAAA,MAAM,UAAU,GAAG,CAAC,OAAuC,KAA4B;QACrF,OAAO,EAAE,KAAK,EAAE;AAChB,QAAA,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,EAAE,aAAa,CAAC,aAAa,KAAK,OAAO;AAC7E,IAAA,CAAC;AAED,IAAA,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;;AAElC,QAAA,MAAM,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,gBAAgB,CAAc,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;AAC5F,QAAA,IAAI,MAAM;AAAE,YAAA,OAAO,MAAM;IAC3B;;IAGA,OAAO,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI;AAC5C;AAEA;;;;;;;AAOG;AACI,MAAM,cAAc,GAAG,CAC5B,cAAkC,EAClC,iBAAiB,GAAG,eAAe,KACjC;AACF,IAAA,MAAM,SAAS,GAAGA,YAAM,CAAU,IAAI,CAAC;IACvC,MAAM,WAAW,GAAG,OAAO,cAAc,GAAG,eAAe,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAI,CAAC;AAEzH,IAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE;AACnC;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Moves focus off an element that is about to unmount or switch itself off, so it does not fall back to the top of the page.
|
|
3
|
+
*
|
|
4
|
+
* @param origin The element focus is leaving, or any element beside it; the search starts from its nearest container.
|
|
5
|
+
* @param targetSelector A CSS selector for the control that should take focus, looked up inside each container in turn.
|
|
6
|
+
* @param containerSelector A CSS selector for the containers, matched against `origin` and its ancestors, nearest first.
|
|
7
|
+
* @returns The element that took focus: the first target that can, in the nearest container that holds one, else the nearest
|
|
8
|
+
* container that can take focus itself (it needs `tabIndex={-1}`), else `null` when nothing could.
|
|
9
|
+
*/
|
|
10
|
+
export declare const moveFocusWithin: (origin: Element | null, targetSelector: string, containerSelector: string) => HTMLElement | null;
|
|
11
|
+
/**
|
|
12
|
+
* Hands focus to a named control before the element holding it goes away, such as an alert that both of its buttons
|
|
13
|
+
* remove. Call `returnFocus` first, then run the action that unmounts or disables the focused element.
|
|
14
|
+
*
|
|
15
|
+
* @param targetSelector A CSS selector for the control that takes focus, found inside the nearest container that holds one; with none, `returnFocus` does nothing.
|
|
16
|
+
* @param containerSelector A CSS selector for that container; it takes focus itself when the target cannot, so give it `tabIndex={-1}`.
|
|
17
|
+
* @returns `originRef` for an element inside the container, and `returnFocus`, which moves focus and reports where it landed.
|
|
18
|
+
*/
|
|
19
|
+
export declare const useReturnFocus: <TOrigin extends HTMLElement = HTMLElement>(targetSelector: string | undefined, containerSelector?: string) => {
|
|
20
|
+
originRef: import("react").RefObject<TOrigin | null>;
|
|
21
|
+
returnFocus: () => HTMLElement | null;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=useReturnFocus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReturnFocus.d.ts","sourceRoot":"","sources":["../../../../src/hooks/__internal__/useReturnFocus/useReturnFocus.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,OAAO,GAAG,IAAI,EAAE,gBAAgB,MAAM,EAAE,mBAAmB,MAAM,KAAG,WAAW,GAAG,IAuBzH,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,SAAS,WAAW,GAAG,WAAW,EACtE,gBAAgB,MAAM,GAAG,SAAS,EAClC,0BAAmC;;;CAMpC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Moves focus off an element that is about to unmount or switch itself off, so it does not fall back to the top of the page.
|
|
5
|
+
*
|
|
6
|
+
* @param origin The element focus is leaving, or any element beside it; the search starts from its nearest container.
|
|
7
|
+
* @param targetSelector A CSS selector for the control that should take focus, looked up inside each container in turn.
|
|
8
|
+
* @param containerSelector A CSS selector for the containers, matched against `origin` and its ancestors, nearest first.
|
|
9
|
+
* @returns The element that took focus: the first target that can, in the nearest container that holds one, else the nearest
|
|
10
|
+
* container that can take focus itself (it needs `tabIndex={-1}`), else `null` when nothing could.
|
|
11
|
+
*/
|
|
12
|
+
const moveFocusWithin = (origin, targetSelector, containerSelector) => {
|
|
13
|
+
const containers = [];
|
|
14
|
+
// Nearest first: a section inside a form is searched before the form around it.
|
|
15
|
+
for (let container = origin?.closest(containerSelector); container; container = container.parentElement?.closest(containerSelector))
|
|
16
|
+
containers.push(container);
|
|
17
|
+
const takesFocus = (element) => {
|
|
18
|
+
element?.focus();
|
|
19
|
+
return Boolean(element) && element?.ownerDocument.activeElement === element;
|
|
20
|
+
};
|
|
21
|
+
for (const container of containers) {
|
|
22
|
+
// Every match is tried: a disabled one must not hide an enabled one after it.
|
|
23
|
+
const target = [...container.querySelectorAll(targetSelector)].find(takesFocus);
|
|
24
|
+
if (target)
|
|
25
|
+
return target;
|
|
26
|
+
}
|
|
27
|
+
// A disabled or missing control cannot take focus, so the nearest container that can does.
|
|
28
|
+
return containers.find(takesFocus) ?? null;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Hands focus to a named control before the element holding it goes away, such as an alert that both of its buttons
|
|
32
|
+
* remove. Call `returnFocus` first, then run the action that unmounts or disables the focused element.
|
|
33
|
+
*
|
|
34
|
+
* @param targetSelector A CSS selector for the control that takes focus, found inside the nearest container that holds one; with none, `returnFocus` does nothing.
|
|
35
|
+
* @param containerSelector A CSS selector for that container; it takes focus itself when the target cannot, so give it `tabIndex={-1}`.
|
|
36
|
+
* @returns `originRef` for an element inside the container, and `returnFocus`, which moves focus and reports where it landed.
|
|
37
|
+
*/
|
|
38
|
+
const useReturnFocus = (targetSelector, containerSelector = 'form, section') => {
|
|
39
|
+
const originRef = useRef(null);
|
|
40
|
+
const returnFocus = () => (targetSelector ? moveFocusWithin(originRef.current, targetSelector, containerSelector) : null);
|
|
41
|
+
return { originRef, returnFocus };
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { moveFocusWithin, useReturnFocus };
|
|
45
|
+
//# sourceMappingURL=useReturnFocus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReturnFocus.js","sources":["../../../../src/hooks/__internal__/useReturnFocus/useReturnFocus.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;;;;;;;;AAQG;AACI,MAAM,eAAe,GAAG,CAAC,MAAsB,EAAE,cAAsB,EAAE,iBAAyB,KAAwB;IAC/H,MAAM,UAAU,GAAkB,EAAE;;IAEpC,KACE,IAAI,SAAS,GAAG,MAAM,EAAE,OAAO,CAAc,iBAAiB,CAAC,EAC/D,SAAS,EACT,SAAS,GAAG,SAAS,CAAC,aAAa,EAAE,OAAO,CAAc,iBAAiB,CAAC;AAE5E,QAAA,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC;AAE5B,IAAA,MAAM,UAAU,GAAG,CAAC,OAAuC,KAA4B;QACrF,OAAO,EAAE,KAAK,EAAE;AAChB,QAAA,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,EAAE,aAAa,CAAC,aAAa,KAAK,OAAO;AAC7E,IAAA,CAAC;AAED,IAAA,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;;AAElC,QAAA,MAAM,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,gBAAgB,CAAc,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;AAC5F,QAAA,IAAI,MAAM;AAAE,YAAA,OAAO,MAAM;IAC3B;;IAGA,OAAO,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI;AAC5C;AAEA;;;;;;;AAOG;AACI,MAAM,cAAc,GAAG,CAC5B,cAAkC,EAClC,iBAAiB,GAAG,eAAe,KACjC;AACF,IAAA,MAAM,SAAS,GAAG,MAAM,CAAU,IAAI,CAAC;IACvC,MAAM,WAAW,GAAG,OAAO,cAAc,GAAG,eAAe,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAI,CAAC;AAEzH,IAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE;AACnC;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Keeps keyboard focus in place across a retry. A "Try again" button unmounts once the data arrives, and focus would
|
|
7
|
+
* otherwise fall back to the top of the page; use it wherever a load error is replaced by the content it failed to load.
|
|
8
|
+
*
|
|
9
|
+
* @param retry Starts the failed request again.
|
|
10
|
+
* @returns `retryLoad` for the retry button, and `contentRef` for the element that replaces the error. That element takes
|
|
11
|
+
* focus when it mounts after a retry, unless the user has moved focus elsewhere, and must be focusable (`tabIndex={-1}`).
|
|
12
|
+
*/
|
|
13
|
+
const useFocusAfterRetry = (retry) => {
|
|
14
|
+
const hasRetried = React.useRef(false);
|
|
15
|
+
const retryLoad = () => {
|
|
16
|
+
hasRetried.current = true;
|
|
17
|
+
retry();
|
|
18
|
+
};
|
|
19
|
+
const contentRef = (content) => {
|
|
20
|
+
if (!content || !hasRetried.current)
|
|
21
|
+
return;
|
|
22
|
+
hasRetried.current = false;
|
|
23
|
+
// Focus sits on `<body>` only when the button it was on is gone; anywhere else, the user chose it.
|
|
24
|
+
if (content.ownerDocument.activeElement === content.ownerDocument.body)
|
|
25
|
+
content.focus();
|
|
26
|
+
};
|
|
27
|
+
return { retryLoad, contentRef };
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.useFocusAfterRetry = useFocusAfterRetry;
|
|
31
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"sourcesContent":[null],"names":["useRef"],"mappings":";;;;AAIA;;;;;;;AAOG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAoB,KAAI;AACzD,IAAA,MAAM,UAAU,GAAGA,YAAM,CAAC,KAAK,CAAC;IAEhC,MAAM,SAAS,GAAG,MAAK;AACrB,QAAA,UAAU,CAAC,OAAO,GAAG,IAAI;AACzB,QAAA,KAAK,EAAE;AACT,IAAA,CAAC;AAED,IAAA,MAAM,UAAU,GAAG,CAAC,OAA2B,KAAI;AACjD,QAAA,IAAI,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO;YAAE;AACrC,QAAA,UAAU,CAAC,OAAO,GAAG,KAAK;;QAE1B,IAAI,OAAO,CAAC,aAAa,CAAC,aAAa,KAAK,OAAO,CAAC,aAAa,CAAC,IAAI;YAAE,OAAO,CAAC,KAAK,EAAE;AACzF,IAAA,CAAC;AAED,IAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE;AAClC;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps keyboard focus in place across a retry. A "Try again" button unmounts once the data arrives, and focus would
|
|
3
|
+
* otherwise fall back to the top of the page; use it wherever a load error is replaced by the content it failed to load.
|
|
4
|
+
*
|
|
5
|
+
* @param retry Starts the failed request again.
|
|
6
|
+
* @returns `retryLoad` for the retry button, and `contentRef` for the element that replaces the error. That element takes
|
|
7
|
+
* focus when it mounts after a retry, unless the user has moved focus elsewhere, and must be focusable (`tabIndex={-1}`).
|
|
8
|
+
*/
|
|
9
|
+
export declare const useFocusAfterRetry: (retry: () => unknown) => {
|
|
10
|
+
retryLoad: () => void;
|
|
11
|
+
contentRef: (content: HTMLElement | null) => void;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,OAAO;;0BAQxB,WAAW,GAAG,IAAI;CAQhD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Keeps keyboard focus in place across a retry. A "Try again" button unmounts once the data arrives, and focus would
|
|
5
|
+
* otherwise fall back to the top of the page; use it wherever a load error is replaced by the content it failed to load.
|
|
6
|
+
*
|
|
7
|
+
* @param retry Starts the failed request again.
|
|
8
|
+
* @returns `retryLoad` for the retry button, and `contentRef` for the element that replaces the error. That element takes
|
|
9
|
+
* focus when it mounts after a retry, unless the user has moved focus elsewhere, and must be focusable (`tabIndex={-1}`).
|
|
10
|
+
*/
|
|
11
|
+
const useFocusAfterRetry = (retry) => {
|
|
12
|
+
const hasRetried = useRef(false);
|
|
13
|
+
const retryLoad = () => {
|
|
14
|
+
hasRetried.current = true;
|
|
15
|
+
retry();
|
|
16
|
+
};
|
|
17
|
+
const contentRef = (content) => {
|
|
18
|
+
if (!content || !hasRetried.current)
|
|
19
|
+
return;
|
|
20
|
+
hasRetried.current = false;
|
|
21
|
+
// Focus sits on `<body>` only when the button it was on is gone; anywhere else, the user chose it.
|
|
22
|
+
if (content.ownerDocument.activeElement === content.ownerDocument.body)
|
|
23
|
+
content.focus();
|
|
24
|
+
};
|
|
25
|
+
return { retryLoad, contentRef };
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { useFocusAfterRetry };
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;;;;;;;AAOG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAoB,KAAI;AACzD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC;IAEhC,MAAM,SAAS,GAAG,MAAK;AACrB,QAAA,UAAU,CAAC,OAAO,GAAG,IAAI;AACzB,QAAA,KAAK,EAAE;AACT,IAAA,CAAC;AAED,IAAA,MAAM,UAAU,GAAG,CAAC,OAA2B,KAAI;AACjD,QAAA,IAAI,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO;YAAE;AACrC,QAAA,UAAU,CAAC,OAAO,GAAG,KAAK;;QAE1B,IAAI,OAAO,CAAC,aAAa,CAAC,aAAa,KAAK,OAAO,CAAC,aAAa,CAAC,IAAI;YAAE,OAAO,CAAC,KAAK,EAAE;AACzF,IAAA,CAAC;AAED,IAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE;AAClC;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var UnsavedChangesGuard_context = require('./providers/UnsavedChangesGuard.context.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Stops unsaved changes being lost to navigation: it holds router navigation and the back button, makes the browser
|
|
8
|
+
* prompt on refresh or tab close, and has a host such as Portal ask before it navigates away. Render a confirm dialog
|
|
9
|
+
* from the result, or use `UnsavedChangesModal`, which does that for you; needs `UIProvider` above it.
|
|
10
|
+
*
|
|
11
|
+
* @param options What to guard: `hasUnsavedChanges` says whether there is anything to lose.
|
|
12
|
+
* @returns `isPromptOpen` while a navigation is waiting on the user, with `stay` to cancel it and `discard` to let it go.
|
|
13
|
+
*/
|
|
14
|
+
const useUnsavedChangesGuard = ({ hasUnsavedChanges }) => {
|
|
15
|
+
const guard = React.useContext(UnsavedChangesGuard_context.UnsavedChangesGuardContext);
|
|
16
|
+
if (!guard)
|
|
17
|
+
throw new Error('useUnsavedChangesGuard needs UIProvider above it, or UnsavedChangesGuardProvider inside your own data router.');
|
|
18
|
+
const { register, promptOwner, isPromptOpen, answer } = guard;
|
|
19
|
+
const id = React.useId();
|
|
20
|
+
// A layout effect, so the provider counts the changes before the browser paints the edit that made them.
|
|
21
|
+
React.useLayoutEffect(() => (hasUnsavedChanges ? register(id) : undefined), [hasUnsavedChanges, register, id]);
|
|
22
|
+
const stay = React.useCallback(() => answer(false), [answer]);
|
|
23
|
+
const discard = React.useCallback(() => answer(true), [answer]);
|
|
24
|
+
return { isPromptOpen: isPromptOpen && promptOwner === id, stay, discard };
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.useUnsavedChangesGuard = useUnsavedChangesGuard;
|
|
28
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/hooks/useUnsavedChangesGuard/index.ts"],"sourcesContent":[null],"names":["useContext","UnsavedChangesGuardContext","useId","useLayoutEffect","useCallback"],"mappings":";;;;;AAUA;;;;;;;AAOG;MACU,sBAAsB,GAAG,CAAC,EAAE,iBAAiB,EAAiC,KAAI;AAC7F,IAAA,MAAM,KAAK,GAAGA,gBAAU,CAACC,sDAA0B,CAAC;AACpD,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,+GAA+G,CAAC;IAC5I,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,KAAK;AAC7D,IAAA,MAAM,EAAE,GAAGC,WAAK,EAAE;;IAGlBC,qBAAe,CAAC,OAAO,iBAAiB,GAAG,QAAQ,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC,iBAAiB,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;AAExG,IAAA,MAAM,IAAI,GAAGC,iBAAW,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;AACvD,IAAA,MAAM,OAAO,GAAGA,iBAAW,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;AAEzD,IAAA,OAAO,EAAE,YAAY,EAAE,YAAY,IAAI,WAAW,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;AAC5E;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface UseUnsavedChangesGuardOptions {
|
|
2
|
+
/** Whether there is anything to lose, such as a form's dirty flag; nothing is held while `false`. */
|
|
3
|
+
hasUnsavedChanges: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Stops unsaved changes being lost to navigation: it holds router navigation and the back button, makes the browser
|
|
7
|
+
* prompt on refresh or tab close, and has a host such as Portal ask before it navigates away. Render a confirm dialog
|
|
8
|
+
* from the result, or use `UnsavedChangesModal`, which does that for you; needs `UIProvider` above it.
|
|
9
|
+
*
|
|
10
|
+
* @param options What to guard: `hasUnsavedChanges` says whether there is anything to lose.
|
|
11
|
+
* @returns `isPromptOpen` while a navigation is waiting on the user, with `stay` to cancel it and `discard` to let it go.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useUnsavedChangesGuard: ({ hasUnsavedChanges }: UseUnsavedChangesGuardOptions) => {
|
|
14
|
+
isPromptOpen: boolean;
|
|
15
|
+
stay: () => void;
|
|
16
|
+
discard: () => void;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useUnsavedChangesGuard/index.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,6BAA6B;IAC5C,qGAAqG;IACrG,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAI,uBAAuB,6BAA6B;;;;CAa1F,CAAC"}
|