@pega/cosmos-react-core 4.0.0-dev.12.1 → 4.0.0-dev.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/components/AppShell/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js +2 -1
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.styles.js +10 -12
- package/lib/components/AppShell/AppShell.styles.js.map +1 -1
- package/lib/components/AppShell/AppShell.types.d.ts +6 -6
- package/lib/components/AppShell/AppShell.types.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.types.js.map +1 -1
- package/lib/components/AppShell/AppShellContext.d.ts +1 -1
- package/lib/components/AppShell/AppShellContext.d.ts.map +1 -1
- package/lib/components/AppShell/AppShellContext.js.map +1 -1
- package/lib/components/AppShell/AppShellList.styles.js +1 -1
- package/lib/components/AppShell/AppShellList.styles.js.map +1 -1
- package/lib/components/AppShell/NavigationList.d.ts.map +1 -1
- package/lib/components/AppShell/NavigationList.js +2 -2
- package/lib/components/AppShell/NavigationList.js.map +1 -1
- package/lib/components/Banner/Banner.d.ts.map +1 -1
- package/lib/components/Banner/Banner.js +3 -3
- package/lib/components/Banner/Banner.js.map +1 -1
- package/lib/components/Boolean/BooleanDisplay.js +2 -2
- package/lib/components/Boolean/BooleanDisplay.js.map +1 -1
- package/lib/components/Button/Button.d.ts +3 -1
- package/lib/components/Button/Button.d.ts.map +1 -1
- package/lib/components/Button/Button.js +168 -142
- package/lib/components/Button/Button.js.map +1 -1
- package/lib/components/ColorPicker/ColorPicker.d.ts +2 -2
- package/lib/components/ColorPicker/ColorPicker.d.ts.map +1 -1
- package/lib/components/ColorPicker/ColorPicker.js +5 -3
- package/lib/components/ColorPicker/ColorPicker.js.map +1 -1
- package/lib/components/ColorPicker/ColorPicker.test-ids.d.ts +2 -0
- package/lib/components/ColorPicker/ColorPicker.test-ids.d.ts.map +1 -0
- package/lib/components/ColorPicker/ColorPicker.test-ids.js +7 -0
- package/lib/components/ColorPicker/ColorPicker.test-ids.js.map +1 -0
- package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBox.js +7 -12
- package/lib/components/ComboBox/ComboBox.js.map +1 -1
- package/lib/components/ComboBox/ComboBox.types.d.ts +2 -2
- package/lib/components/ComboBox/ComboBox.types.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBox.types.js.map +1 -1
- package/lib/components/ComboBox/ComboxBox.test-ids.d.ts +2 -0
- package/lib/components/ComboBox/ComboxBox.test-ids.d.ts.map +1 -0
- package/lib/components/ComboBox/ComboxBox.test-ids.js +4 -0
- package/lib/components/ComboBox/ComboxBox.test-ids.js.map +1 -0
- package/lib/components/CompositeInput/CompositeInput.d.ts.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.js +24 -13
- package/lib/components/CompositeInput/CompositeInput.js.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.test-ids.d.ts +2 -0
- package/lib/components/CompositeInput/CompositeInput.test-ids.d.ts.map +1 -0
- package/lib/components/CompositeInput/CompositeInput.test-ids.js +7 -0
- package/lib/components/CompositeInput/CompositeInput.test-ids.js.map +1 -0
- package/lib/components/CompositeInput/CompositeInput.types.d.ts +2 -2
- package/lib/components/CompositeInput/CompositeInput.types.d.ts.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.types.js.map +1 -1
- package/lib/components/Configuration/Configuration.d.ts +6 -0
- package/lib/components/Configuration/Configuration.d.ts.map +1 -1
- package/lib/components/Configuration/Configuration.js +8 -2
- package/lib/components/Configuration/Configuration.js.map +1 -1
- package/lib/components/Currency/Currency.test-ids.d.ts +2 -0
- package/lib/components/Currency/Currency.test-ids.d.ts.map +1 -0
- package/lib/components/Currency/Currency.test-ids.js +7 -0
- package/lib/components/Currency/Currency.test-ids.js.map +1 -0
- package/lib/components/Currency/CurrencyInput.d.ts.map +1 -1
- package/lib/components/Currency/CurrencyInput.js +6 -3
- package/lib/components/Currency/CurrencyInput.js.map +1 -1
- package/lib/components/Currency/CurrencyInput.types.d.ts +2 -2
- package/lib/components/Currency/CurrencyInput.types.d.ts.map +1 -1
- package/lib/components/Currency/CurrencyInput.types.js.map +1 -1
- package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateInput.js +25 -32
- package/lib/components/DateTime/Input/DateInput.js.map +1 -1
- package/lib/components/DateTime/Input/DateTime.styles.d.ts +1 -0
- package/lib/components/DateTime/Input/DateTime.styles.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateTime.styles.js +3 -0
- package/lib/components/DateTime/Input/DateTime.styles.js.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.js +20 -27
- package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
- package/lib/components/DateTime/Input/TimeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/TimeInput.js +1 -9
- package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
- package/lib/components/DateTime/Input/WeekInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/WeekInput.js +11 -17
- package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.js +1 -1
- package/lib/components/DateTime/Picker/Calendar.js.map +1 -1
- package/lib/components/DateTime/Picker/Weeks.js +1 -1
- package/lib/components/DateTime/Picker/Weeks.js.map +1 -1
- package/lib/components/DateTime/utils.d.ts.map +1 -1
- package/lib/components/DateTime/utils.js +69 -7
- package/lib/components/DateTime/utils.js.map +1 -1
- package/lib/components/Dialog/Dialog.d.ts.map +1 -1
- package/lib/components/Dialog/Dialog.js +2 -2
- package/lib/components/Dialog/Dialog.js.map +1 -1
- package/lib/components/Dialog/Dialog.styles.d.ts +3 -0
- package/lib/components/Dialog/Dialog.styles.d.ts.map +1 -1
- package/lib/components/Dialog/Dialog.styles.js +29 -2
- package/lib/components/Dialog/Dialog.styles.js.map +1 -1
- package/lib/components/Dialog/Dialog.types.d.ts +36 -14
- package/lib/components/Dialog/Dialog.types.d.ts.map +1 -1
- package/lib/components/Dialog/Dialog.types.js +0 -1
- package/lib/components/Dialog/Dialog.types.js.map +1 -1
- package/lib/components/Dialog/FormDialog.d.ts +4 -1
- package/lib/components/Dialog/FormDialog.d.ts.map +1 -1
- package/lib/components/Dialog/FormDialog.js +4 -5
- package/lib/components/Dialog/FormDialog.js.map +1 -1
- package/lib/components/Dialog/InfoDialog.d.ts +0 -1
- package/lib/components/Dialog/InfoDialog.d.ts.map +1 -1
- package/lib/components/Dialog/InfoDialog.js +15 -13
- package/lib/components/Dialog/InfoDialog.js.map +1 -1
- package/lib/components/Dialog/InfoDialog.styles.d.ts +6 -0
- package/lib/components/Dialog/InfoDialog.styles.d.ts.map +1 -0
- package/lib/components/Dialog/InfoDialog.styles.js +18 -0
- package/lib/components/Dialog/InfoDialog.styles.js.map +1 -0
- package/lib/components/EmojiPicker/EmojiPicker.styles.js +1 -1
- package/lib/components/EmojiPicker/EmojiPicker.styles.js.map +1 -1
- package/lib/components/FieldGroup/FieldGroup.js +1 -1
- package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
- package/lib/components/FieldValueList/FieldValueList.d.ts +8 -6
- package/lib/components/FieldValueList/FieldValueList.d.ts.map +1 -1
- package/lib/components/FieldValueList/FieldValueList.js +11 -9
- package/lib/components/FieldValueList/FieldValueList.js.map +1 -1
- package/lib/components/FieldValueList/FieldValueList.test-ids.d.ts +3 -0
- package/lib/components/FieldValueList/FieldValueList.test-ids.d.ts.map +1 -0
- package/lib/components/FieldValueList/FieldValueList.test-ids.js +7 -0
- package/lib/components/FieldValueList/FieldValueList.test-ids.js.map +1 -0
- package/lib/components/FieldValueList/index.d.ts +1 -1
- package/lib/components/FieldValueList/index.d.ts.map +1 -1
- package/lib/components/FieldValueList/index.js.map +1 -1
- package/lib/components/File/File.test-ids.d.ts +2 -0
- package/lib/components/File/File.test-ids.d.ts.map +1 -0
- package/lib/components/File/File.test-ids.js +8 -0
- package/lib/components/File/File.test-ids.js.map +1 -0
- package/lib/components/File/FileInput.d.ts +2 -2
- package/lib/components/File/FileInput.d.ts.map +1 -1
- package/lib/components/File/FileInput.js +15 -4
- package/lib/components/File/FileInput.js.map +1 -1
- package/lib/components/Flex/Flex.d.ts +7 -1
- package/lib/components/Flex/Flex.d.ts.map +1 -1
- package/lib/components/Flex/Flex.js +37 -10
- package/lib/components/Flex/Flex.js.map +1 -1
- package/lib/components/FormField/FormField.d.ts +3 -2
- package/lib/components/FormField/FormField.d.ts.map +1 -1
- package/lib/components/FormField/FormField.js +15 -10
- package/lib/components/FormField/FormField.js.map +1 -1
- package/lib/components/FormField/FormField.test-ids.d.ts +3 -0
- package/lib/components/FormField/FormField.test-ids.d.ts.map +1 -0
- package/lib/components/FormField/FormField.test-ids.js +10 -0
- package/lib/components/FormField/FormField.test-ids.js.map +1 -0
- package/lib/components/Icon/iconNames.d.ts +2 -2
- package/lib/components/Icon/iconNames.d.ts.map +1 -1
- package/lib/components/Icon/iconNames.js +2 -0
- package/lib/components/Icon/iconNames.js.map +1 -1
- package/lib/components/Icon/icons/phone-merge-solid.icon.d.ts +4 -0
- package/lib/components/Icon/icons/phone-merge-solid.icon.d.ts.map +1 -0
- package/lib/components/Icon/icons/phone-merge-solid.icon.js +6 -0
- package/lib/components/Icon/icons/phone-merge-solid.icon.js.map +1 -0
- package/lib/components/Icon/icons/phone-merge.icon.d.ts +4 -0
- package/lib/components/Icon/icons/phone-merge.icon.d.ts.map +1 -0
- package/lib/components/Icon/icons/phone-merge.icon.js +6 -0
- package/lib/components/Icon/icons/phone-merge.icon.js.map +1 -0
- package/lib/components/IconPicker/IconPicker.js +2 -2
- package/lib/components/IconPicker/IconPicker.js.map +1 -1
- package/lib/components/Input/Input.d.ts +2 -2
- package/lib/components/Input/Input.d.ts.map +1 -1
- package/lib/components/Input/Input.js +6 -2
- package/lib/components/Input/Input.js.map +1 -1
- package/lib/components/Input/Input.test-ids.d.ts +2 -0
- package/lib/components/Input/Input.test-ids.d.ts.map +1 -0
- package/lib/components/Input/Input.test-ids.js +4 -0
- package/lib/components/Input/Input.test-ids.js.map +1 -0
- package/lib/components/List/List.d.ts.map +1 -1
- package/lib/components/List/List.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.d.ts +1 -1
- package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.js +51 -19
- package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.styles.d.ts +3 -1
- package/lib/components/ListToolbar/ListToolbar.styles.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.styles.js +2 -3
- package/lib/components/ListToolbar/ListToolbar.styles.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.test-ids.d.ts +2 -0
- package/lib/components/ListToolbar/ListToolbar.test-ids.d.ts.map +1 -0
- package/lib/components/ListToolbar/ListToolbar.test-ids.js +7 -0
- package/lib/components/ListToolbar/ListToolbar.test-ids.js.map +1 -0
- package/lib/components/ListToolbar/ListToolbar.types.d.ts +31 -8
- package/lib/components/ListToolbar/ListToolbar.types.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.types.js.map +1 -1
- package/lib/components/ListToolbar/helpers.d.ts +10 -0
- package/lib/components/ListToolbar/helpers.d.ts.map +1 -0
- package/lib/components/ListToolbar/helpers.js +46 -0
- package/lib/components/ListToolbar/helpers.js.map +1 -0
- package/lib/components/ListToolbar/index.d.ts +1 -0
- package/lib/components/ListToolbar/index.d.ts.map +1 -1
- package/lib/components/ListToolbar/index.js +1 -0
- package/lib/components/ListToolbar/index.js.map +1 -1
- package/lib/components/LiveLog/LiveLog.d.ts.map +1 -1
- package/lib/components/LiveLog/LiveLog.js +17 -16
- package/lib/components/LiveLog/LiveLog.js.map +1 -1
- package/lib/components/Location/Location.test-ids.d.ts +2 -0
- package/lib/components/Location/Location.test-ids.d.ts.map +1 -0
- package/lib/components/Location/Location.test-ids.js +7 -0
- package/lib/components/Location/Location.test-ids.js.map +1 -0
- package/lib/components/Location/LocationInput.d.ts +2 -2
- package/lib/components/Location/LocationInput.d.ts.map +1 -1
- package/lib/components/Location/LocationInput.js +17 -4
- package/lib/components/Location/LocationInput.js.map +1 -1
- package/lib/components/Menu/Menu.d.ts.map +1 -1
- package/lib/components/Menu/Menu.js +7 -5
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/Menu/Menu.styles.d.ts +5 -1
- package/lib/components/Menu/Menu.styles.d.ts.map +1 -1
- package/lib/components/Menu/Menu.styles.js +80 -88
- package/lib/components/Menu/Menu.styles.js.map +1 -1
- package/lib/components/Menu/Menu.test-ids.d.ts +3 -0
- package/lib/components/Menu/Menu.test-ids.d.ts.map +1 -0
- package/lib/components/Menu/Menu.test-ids.js +4 -0
- package/lib/components/Menu/Menu.test-ids.js.map +1 -0
- package/lib/components/Menu/Menu.types.d.ts +3 -3
- package/lib/components/Menu/Menu.types.d.ts.map +1 -1
- package/lib/components/Menu/Menu.types.js.map +1 -1
- package/lib/components/Menu/MenuItem.d.ts.map +1 -1
- package/lib/components/Menu/MenuItem.js +70 -73
- package/lib/components/Menu/MenuItem.js.map +1 -1
- package/lib/components/Menu/MenuList.d.ts.map +1 -1
- package/lib/components/Menu/MenuList.js +3 -3
- package/lib/components/Menu/MenuList.js.map +1 -1
- package/lib/components/Menu/MenuListHeader.d.ts.map +1 -1
- package/lib/components/Menu/MenuListHeader.js +3 -4
- package/lib/components/Menu/MenuListHeader.js.map +1 -1
- package/lib/components/Menu/NavItemsList.d.ts.map +1 -1
- package/lib/components/Menu/NavItemsList.js +2 -0
- package/lib/components/Menu/NavItemsList.js.map +1 -1
- package/lib/components/MenuButton/MenuButton.d.ts +2 -2
- package/lib/components/MenuButton/MenuButton.d.ts.map +1 -1
- package/lib/components/MenuButton/MenuButton.js +6 -4
- package/lib/components/MenuButton/MenuButton.js.map +1 -1
- package/lib/components/MenuButton/MenuButton.test-ids.d.ts +2 -0
- package/lib/components/MenuButton/MenuButton.test-ids.d.ts.map +1 -0
- package/lib/components/MenuButton/MenuButton.test-ids.js +3 -0
- package/lib/components/MenuButton/MenuButton.test-ids.js.map +1 -0
- package/lib/components/MetaList/MetaList.d.ts +2 -2
- package/lib/components/MetaList/MetaList.d.ts.map +1 -1
- package/lib/components/MetaList/MetaList.js +5 -3
- package/lib/components/MetaList/MetaList.js.map +1 -1
- package/lib/components/MetaList/MetaList.test-ids.d.ts +2 -0
- package/lib/components/MetaList/MetaList.test-ids.d.ts.map +1 -0
- package/lib/components/MetaList/MetaList.test-ids.js +3 -0
- package/lib/components/MetaList/MetaList.test-ids.js.map +1 -0
- package/lib/components/Modal/Modal.styles.js +1 -1
- package/lib/components/Modal/Modal.styles.js.map +1 -1
- package/lib/components/Modal/ModalManager.d.ts.map +1 -1
- package/lib/components/Modal/ModalManager.js +5 -2
- package/lib/components/Modal/ModalManager.js.map +1 -1
- package/lib/components/Number/Number.test-ids.d.ts +3 -0
- package/lib/components/Number/Number.test-ids.d.ts.map +1 -0
- package/lib/components/Number/Number.test-ids.js +14 -0
- package/lib/components/Number/Number.test-ids.js.map +1 -0
- package/lib/components/Number/NumberInput.d.ts.map +1 -1
- package/lib/components/Number/NumberInput.js +9 -6
- package/lib/components/Number/NumberInput.js.map +1 -1
- package/lib/components/Number/NumberInput.types.d.ts +2 -2
- package/lib/components/Number/NumberInput.types.d.ts.map +1 -1
- package/lib/components/Number/NumberInput.types.js.map +1 -1
- package/lib/components/Number/NumberRangeInput.d.ts.map +1 -1
- package/lib/components/Number/NumberRangeInput.js +6 -4
- package/lib/components/Number/NumberRangeInput.js.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.js +2 -2
- package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
- package/lib/components/Phone/Phone.test-ids.d.ts +2 -0
- package/lib/components/Phone/Phone.test-ids.d.ts.map +1 -0
- package/lib/components/Phone/Phone.test-ids.js +8 -0
- package/lib/components/Phone/Phone.test-ids.js.map +1 -0
- package/lib/components/Phone/PhoneInput.d.ts +2 -2
- package/lib/components/Phone/PhoneInput.d.ts.map +1 -1
- package/lib/components/Phone/PhoneInput.js +6 -3
- package/lib/components/Phone/PhoneInput.js.map +1 -1
- package/lib/components/Popover/Popover.d.ts +1 -0
- package/lib/components/Popover/Popover.d.ts.map +1 -1
- package/lib/components/Popover/Popover.js +37 -40
- package/lib/components/Popover/Popover.js.map +1 -1
- package/lib/components/Popover/PopoverManager.d.ts.map +1 -1
- package/lib/components/Popover/PopoverManager.js +11 -10
- package/lib/components/Popover/PopoverManager.js.map +1 -1
- package/lib/components/Popover/modifiers.d.ts +1 -0
- package/lib/components/Popover/modifiers.d.ts.map +1 -1
- package/lib/components/Popover/modifiers.js +97 -1
- package/lib/components/Popover/modifiers.js.map +1 -1
- package/lib/components/Progress/Progress.styles.d.ts.map +1 -1
- package/lib/components/Progress/Progress.styles.js +25 -20
- package/lib/components/Progress/Progress.styles.js.map +1 -1
- package/lib/components/RadioCheck/RadioCheck.d.ts +2 -0
- package/lib/components/RadioCheck/RadioCheck.d.ts.map +1 -1
- package/lib/components/RadioCheck/RadioCheck.js +4 -4
- package/lib/components/RadioCheck/RadioCheck.js.map +1 -1
- package/lib/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/lib/components/SearchInput/SearchInput.js +1 -9
- package/lib/components/SearchInput/SearchInput.js.map +1 -1
- package/lib/components/Select/Select.d.ts +2 -2
- package/lib/components/Select/Select.d.ts.map +1 -1
- package/lib/components/Select/Select.js +7 -4
- package/lib/components/Select/Select.js.map +1 -1
- package/lib/components/Select/Select.test-ids.d.ts +2 -0
- package/lib/components/Select/Select.test-ids.d.ts.map +1 -0
- package/lib/components/Select/Select.test-ids.js +4 -0
- package/lib/components/Select/Select.test-ids.js.map +1 -0
- package/lib/components/Slider/Slider.d.ts.map +1 -1
- package/lib/components/Slider/Slider.js +7 -5
- package/lib/components/Slider/Slider.js.map +1 -1
- package/lib/components/Slider/Slider.styles.d.ts.map +1 -1
- package/lib/components/Slider/Slider.styles.js +114 -128
- package/lib/components/Slider/Slider.styles.js.map +1 -1
- package/lib/components/Slider/Slider.test-ids.d.ts +2 -0
- package/lib/components/Slider/Slider.test-ids.d.ts.map +1 -0
- package/lib/components/Slider/Slider.test-ids.js +4 -0
- package/lib/components/Slider/Slider.test-ids.js.map +1 -0
- package/lib/components/Slider/Slider.types.d.ts +2 -2
- package/lib/components/Slider/Slider.types.d.ts.map +1 -1
- package/lib/components/Slider/Slider.types.js.map +1 -1
- package/lib/components/Slider/utils.d.ts.map +1 -1
- package/lib/components/Slider/utils.js +0 -1
- package/lib/components/Slider/utils.js.map +1 -1
- package/lib/components/SummaryItem/SummaryItem.d.ts +2 -2
- package/lib/components/SummaryItem/SummaryItem.d.ts.map +1 -1
- package/lib/components/SummaryItem/SummaryItem.js +6 -3
- package/lib/components/SummaryItem/SummaryItem.js.map +1 -1
- package/lib/components/SummaryItem/SummaryItem.test-ids.d.ts +2 -0
- package/lib/components/SummaryItem/SummaryItem.test-ids.d.ts.map +1 -0
- package/lib/components/SummaryItem/SummaryItem.test-ids.js +8 -0
- package/lib/components/SummaryItem/SummaryItem.test-ids.js.map +1 -0
- package/lib/components/Tabs/Tab.d.ts.map +1 -1
- package/lib/components/Tabs/Tab.js +21 -18
- package/lib/components/Tabs/Tab.js.map +1 -1
- package/lib/components/TextArea/TextArea.d.ts +2 -2
- package/lib/components/TextArea/TextArea.d.ts.map +1 -1
- package/lib/components/TextArea/TextArea.js +6 -2
- package/lib/components/TextArea/TextArea.js.map +1 -1
- package/lib/components/TextArea/TextArea.test-ids.d.ts +2 -0
- package/lib/components/TextArea/TextArea.test-ids.d.ts.map +1 -0
- package/lib/components/TextArea/TextArea.test-ids.js +4 -0
- package/lib/components/TextArea/TextArea.test-ids.js.map +1 -0
- package/lib/hooks/index.d.ts +2 -0
- package/lib/hooks/index.d.ts.map +1 -1
- package/lib/hooks/index.js +2 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useActiveDescendant.d.ts.map +1 -1
- package/lib/hooks/useActiveDescendant.js +3 -2
- package/lib/hooks/useActiveDescendant.js.map +1 -1
- package/lib/hooks/useBreakpoint.d.ts.map +1 -1
- package/lib/hooks/useBreakpoint.js +4 -1
- package/lib/hooks/useBreakpoint.js.map +1 -1
- package/lib/hooks/useChToPxConversionFactor.d.ts +3 -0
- package/lib/hooks/useChToPxConversionFactor.d.ts.map +1 -0
- package/lib/hooks/useChToPxConversionFactor.js +13 -0
- package/lib/hooks/useChToPxConversionFactor.js.map +1 -0
- package/lib/hooks/useElement.d.ts +1 -1
- package/lib/hooks/useElement.d.ts.map +1 -1
- package/lib/hooks/useI18n.d.ts +28 -9
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/hooks/useScrollToggle.d.ts.map +1 -1
- package/lib/hooks/useScrollToggle.js +0 -1
- package/lib/hooks/useScrollToggle.js.map +1 -1
- package/lib/hooks/useTestIds.d.ts +10 -0
- package/lib/hooks/useTestIds.d.ts.map +1 -0
- package/lib/hooks/useTestIds.js +21 -0
- package/lib/hooks/useTestIds.js.map +1 -0
- package/lib/i18n/default.d.ts +28 -9
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +34 -14
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +28 -9
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/styles/gradients.d.ts.map +1 -1
- package/lib/styles/gradients.js.map +1 -1
- package/lib/theme/ThemeMachine.js.map +1 -1
- package/lib/theme/theme.d.ts +16 -16
- package/lib/types/types.d.ts +14 -0
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js.map +1 -1
- package/lib/utils/createTestIds.d.ts +4 -0
- package/lib/utils/createTestIds.d.ts.map +1 -0
- package/lib/utils/createTestIds.js +8 -0
- package/lib/utils/createTestIds.js.map +1 -0
- package/lib/utils/debounce.d.ts +2 -2
- package/lib/utils/debounce.d.ts.map +1 -1
- package/lib/utils/debounce.js +9 -10
- package/lib/utils/debounce.js.map +1 -1
- package/lib/utils/getEdge.d.ts +7 -0
- package/lib/utils/getEdge.d.ts.map +1 -0
- package/lib/utils/getEdge.js +9 -0
- package/lib/utils/getEdge.js.map +1 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +4 -0
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/kebabToCamel.d.ts +7 -0
- package/lib/utils/kebabToCamel.d.ts.map +1 -0
- package/lib/utils/kebabToCamel.js +10 -0
- package/lib/utils/kebabToCamel.js.map +1 -0
- package/lib/utils/throttle.d.ts +4 -0
- package/lib/utils/throttle.d.ts.map +1 -0
- package/lib/utils/throttle.js +15 -0
- package/lib/utils/throttle.js.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhoneInput.d.ts","sourceRoot":"","sources":["../../../src/components/Phone/PhoneInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAEjB,GAAG,EAGJ,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PhoneInput.d.ts","sourceRoot":"","sources":["../../../src/components/Phone/PhoneInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAEjB,GAAG,EAGJ,MAAM,OAAO,CAAC;AAWf,OAAO,EACL,SAAS,EACT,YAAY,EACZ,cAAc,EAEd,UAAU,EACX,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,gBAAgB,EAAqB,MAAM,gBAAgB,CAAC;AAWrE,MAAM,WAAW,eAAgB,SAAQ,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU;IAC9F;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,+CAA+C;IAC/C,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,oDAAoD;IACpD,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,oDAAoD;IACpD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;CAC7B;AAuBD,QAAA,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,GAAG,YAAY,CAwIjE,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useCallback, useRef } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
-
import { useConsolidatedRef, useFocusWithin, useI18n, useInputFormatter } from '../../hooks';
|
|
4
|
+
import { useConsolidatedRef, useFocusWithin, useI18n, useInputFormatter, useTestIds } from '../../hooks';
|
|
5
5
|
import { defaultThemeProp } from '../../theme';
|
|
6
6
|
import FormField from '../FormField';
|
|
7
7
|
import { StyledFormControl } from '../FormControl';
|
|
@@ -12,6 +12,7 @@ import { StyledSelect } from '../Select/Select';
|
|
|
12
12
|
import Flex from '../Flex';
|
|
13
13
|
import callingCodes from './callingCodes';
|
|
14
14
|
import { convertToCallbackParameter, formatPhoneNumber, getPhoneNumberParts } from './utils';
|
|
15
|
+
import { getPhoneInputTestIds } from './Phone.test-ids';
|
|
15
16
|
const StyledPhoneInput = styled.div(() => {
|
|
16
17
|
return css `
|
|
17
18
|
border: 0;
|
|
@@ -30,7 +31,8 @@ const StyledPhoneInput = styled.div(() => {
|
|
|
30
31
|
});
|
|
31
32
|
StyledPhoneInput.defaultProps = defaultThemeProp;
|
|
32
33
|
const PhoneInput = forwardRef((props, ref) => {
|
|
33
|
-
const { value, id, label, labelHidden, info, status, required, readOnly, disabled, showCountryCode = false, callingCodesList = callingCodes, onChange, onBlur, onFocus, onResolveSuggestion, additionalInfo, ...restProps } = props;
|
|
34
|
+
const { testId, value, id, label, labelHidden, info, status, required, readOnly, disabled, showCountryCode = false, callingCodesList = callingCodes, onChange, onBlur, onFocus, onResolveSuggestion, additionalInfo, ...restProps } = props;
|
|
35
|
+
const testIds = useTestIds(testId, getPhoneInputTestIds);
|
|
34
36
|
const t = useI18n();
|
|
35
37
|
const [countryCode = callingCodesList[0], subscriberNumber = ''] = value
|
|
36
38
|
? getPhoneNumberParts(value, callingCodesList)
|
|
@@ -56,8 +58,9 @@ const PhoneInput = forwardRef((props, ref) => {
|
|
|
56
58
|
}, [countryCode]);
|
|
57
59
|
const formatted = useInputFormatter(inputRef, subscriberNumber, formatter);
|
|
58
60
|
const codesOptions = (_jsx(_Fragment, { children: callingCodesList.map(code => (_jsx(Option, { value: code, children: code }, code))) }));
|
|
59
|
-
const Comp = (_jsxs(StyledPhoneInput, { as: StyledFormControl, forwardedAs: Flex, container: { alignItems: 'center', wrap: 'nowrap' }, ref: containerRef, status: status, readOnly: readOnly, disabled: disabled, children: [showCountryCode && (_jsx(Select, { value: countryCode, "aria-label": t('select_country_code'), onChange: onSelectChange, required: required, status: status, readOnly: readOnly, disabled: disabled, autoComplete: 'tel-country-code', hasSuggestion: status === 'pending' && !!onResolveSuggestion, children: codesOptions })), _jsx(Input, { ...restProps, inputMode: 'tel', ref: inputRef, value: formatted, "aria-label": t('enter_a_number'), onChange: onInputChange, required: required, status: status, readOnly: readOnly, disabled: disabled, autoComplete: 'tel-national', hasSuggestion: status === 'pending' && !!onResolveSuggestion })] }));
|
|
61
|
+
const Comp = (_jsxs(StyledPhoneInput, { "data-testid": testIds.root, as: StyledFormControl, forwardedAs: Flex, container: { alignItems: 'center', wrap: 'nowrap' }, ref: containerRef, status: status, readOnly: readOnly, disabled: disabled, children: [showCountryCode && (_jsx(Select, { "data-testid": testIds.countryCode, value: countryCode, "aria-label": t('select_country_code'), onChange: onSelectChange, required: required, status: status, readOnly: readOnly, disabled: disabled, autoComplete: 'tel-country-code', hasSuggestion: status === 'pending' && !!onResolveSuggestion, children: codesOptions })), _jsx(Input, { "data-testid": testIds.control, ...restProps, inputMode: 'tel', ref: inputRef, value: formatted, "aria-label": t('enter_a_number'), onChange: onInputChange, required: required, status: status, readOnly: readOnly, disabled: disabled, autoComplete: 'tel-national', hasSuggestion: status === 'pending' && !!onResolveSuggestion })] }));
|
|
60
62
|
return label ? (_jsx(FormField, { as: 'fieldset', labelAs: 'legend', ...{
|
|
63
|
+
testId: testIds,
|
|
61
64
|
additionalInfo,
|
|
62
65
|
label,
|
|
63
66
|
labelHidden,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhoneInput.js","sourceRoot":"","sources":["../../../src/components/Phone/PhoneInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EAIV,WAAW,EACX,MAAM,EACP,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,
|
|
1
|
+
{"version":3,"file":"PhoneInput.js","sourceRoot":"","sources":["../../../src/components/Phone/PhoneInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EAIV,WAAW,EACX,MAAM,EACP,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,iBAAiB,EACjB,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAQ/C,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAoB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,WA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;YACL,WAAW;YACX,EAAE;YACF,IAAI;YACJ,MAAM;YACN,QAAQ;YACR,QAAQ;YACR,mBAAmB;SACpB,YAEA,IAAI,GACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import {\n ChangeEvent,\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n useCallback,\n useRef\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n useConsolidatedRef,\n useFocusWithin,\n useI18n,\n useInputFormatter,\n useTestIds\n} from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport {\n BaseProps,\n ForwardProps,\n NoChildrenProp,\n PropsWithDefaults,\n TestIdProp\n} from '../../types';\nimport FormField from '../FormField';\nimport { FormControlProps, StyledFormControl } from '../FormControl';\nimport StyledInput from '../Input/Input.styles';\nimport Select, { Option } from '../Select';\nimport Input from '../Input';\nimport { StyledSelect } from '../Select/Select';\nimport Flex from '../Flex';\n\nimport callingCodes from './callingCodes';\nimport { convertToCallbackParameter, formatPhoneNumber, getPhoneNumberParts } from './utils';\nimport { getPhoneInputTestIds } from './Phone.test-ids';\n\nexport interface PhoneInputProps extends FormControlProps, BaseProps, NoChildrenProp, TestIdProp {\n /**\n * Display select with countries calling codes\n * @default false\n */\n showCountryCode?: boolean;\n /** Changes lists of countries calling codes */\n callingCodesList?: string[];\n /** Callback fired on input value change */\n onChange?: (value: string) => void;\n /** Callback fired when the component loses focus */\n onBlur?: (value: string) => void;\n /** CCallback fired when the component gets focus */\n onFocus?: (value: string) => void;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLInputElement>;\n}\n\ntype PhoneInputPropsWithDefaults = PropsWithDefaults<PhoneInputProps>;\n\nconst StyledPhoneInput = styled.div<PhoneInputPropsWithDefaults>(() => {\n return css`\n border: 0;\n > ${StyledSelect} {\n max-width: max-content;\n border-inline-end: none;\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n }\n\n > ${StyledSelect} + ${StyledInput} {\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n }\n `;\n});\n\nStyledPhoneInput.defaultProps = defaultThemeProp;\n\nconst PhoneInput: FunctionComponent<PhoneInputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<PhoneInputProps>, ref: PhoneInputProps['ref']) => {\n const {\n testId,\n value,\n id,\n label,\n labelHidden,\n info,\n status,\n required,\n readOnly,\n disabled,\n showCountryCode = false,\n callingCodesList = callingCodes,\n onChange,\n onBlur,\n onFocus,\n onResolveSuggestion,\n additionalInfo,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getPhoneInputTestIds);\n\n const t = useI18n();\n\n const [countryCode = callingCodesList[0], subscriberNumber = ''] = value\n ? getPhoneNumberParts(value, callingCodesList)\n : [];\n\n const onFocusChange = (focused: boolean) => {\n const callbackParam = convertToCallbackParameter(countryCode, subscriberNumber);\n if (focused) onFocus?.(callbackParam);\n else onBlur?.(callbackParam);\n };\n\n const onInputChange = (e: ChangeEvent<HTMLInputElement>) => {\n onChange?.(convertToCallbackParameter(countryCode, e.target.value));\n };\n\n const onSelectChange = (e: ChangeEvent<HTMLSelectElement>) => {\n onChange?.(convertToCallbackParameter(e.target.value, subscriberNumber));\n };\n\n const inputRef = useConsolidatedRef<HTMLInputElement>(ref);\n const containerRef = useRef<HTMLElement>(null);\n useFocusWithin([containerRef], onFocusChange);\n\n const formatter = useCallback(\n number => {\n return formatPhoneNumber(number.replace(/\\D+/g, ''), countryCode);\n },\n [countryCode]\n );\n\n const formatted = useInputFormatter(inputRef, subscriberNumber, formatter);\n\n const codesOptions = (\n <>\n {callingCodesList.map(code => (\n <Option key={code} value={code}>\n {code}\n </Option>\n ))}\n </>\n );\n\n const Comp = (\n <StyledPhoneInput\n data-testid={testIds.root}\n as={StyledFormControl}\n forwardedAs={Flex as any}\n container={{ alignItems: 'center', wrap: 'nowrap' }}\n ref={containerRef}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n >\n {showCountryCode && (\n <Select\n data-testid={testIds.countryCode}\n value={countryCode}\n aria-label={t('select_country_code')}\n onChange={onSelectChange}\n required={required}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n autoComplete='tel-country-code'\n hasSuggestion={status === 'pending' && !!onResolveSuggestion}\n >\n {codesOptions}\n </Select>\n )}\n <Input\n data-testid={testIds.control}\n {...restProps}\n inputMode='tel'\n ref={inputRef}\n value={formatted}\n aria-label={t('enter_a_number')}\n onChange={onInputChange}\n required={required}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n autoComplete='tel-national'\n hasSuggestion={status === 'pending' && !!onResolveSuggestion}\n />\n </StyledPhoneInput>\n );\n\n return label ? (\n <FormField\n as='fieldset'\n labelAs='legend'\n {...{\n testId: testIds,\n additionalInfo,\n label,\n labelHidden,\n id,\n info,\n status,\n required,\n disabled,\n onResolveSuggestion\n }}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default PhoneInput;\n"]}
|
|
@@ -29,6 +29,7 @@ export interface PopoverProps<Modifiers extends string = string> extends BasePro
|
|
|
29
29
|
hideDelay?: Delay;
|
|
30
30
|
/**
|
|
31
31
|
* [React Popper Placement](https://popper.js.org/react-popper/v2/render-props/#placement)
|
|
32
|
+
* @default "bottom"
|
|
32
33
|
*/
|
|
33
34
|
placement?: PopperProps<Modifiers>['placement'];
|
|
34
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,GAAG,EAEH,YAAY,EAEZ,SAAS,EAIV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAa,WAAW,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAStD,OA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;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,kCAAkC;IAClC,QAAQ,EAAE,SAAS,CAAC;IACpB,uCAAuC;IACvC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAQD,QAAA,MAAM,OAAO,EAAE,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,EAC/C,KAAK,EAAE,YAAY,CAAC,SAAS,CAAC,GAAG,YAAY,KAC1C,YAAY,GAAG,IAiInB,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -6,45 +6,56 @@ import { useAfterInitialEffect, useConfiguration, useConsolidatedRef, useElement
|
|
|
6
6
|
import { windowIsAvailable } from '../../utils';
|
|
7
7
|
import { PopoverManagerContext } from './PopoverContext';
|
|
8
8
|
import { StyledPopover, StyledPopoverArrow } from './Popover.styles';
|
|
9
|
+
import { placeAndContain } from './modifiers';
|
|
9
10
|
const delays = {
|
|
10
11
|
none: 0,
|
|
11
12
|
short: 500,
|
|
12
13
|
long: 1000
|
|
13
14
|
};
|
|
14
|
-
const Popover = forwardRef(({ show = true, portal = false, target, placement, strategy = 'fixed', style, modifiers = [], arrow = false, groupId, showDelay = 'none', hideDelay = 'none', hideOnTargetHidden = false, children, onHide, ...restProps }, ref) => {
|
|
15
|
+
const Popover = forwardRef(({ show = true, portal = false, target, placement = 'bottom', strategy = 'fixed', style, modifiers = [], arrow = false, groupId, showDelay = 'none', hideDelay = 'none', hideOnTargetHidden = false, children, onHide, ...restProps }, ref) => {
|
|
15
16
|
const { portalTarget: configurationPortal } = useConfiguration();
|
|
16
17
|
const { checkActive, setActive, popovers } = useContext(PopoverManagerContext);
|
|
17
18
|
const [, setPopperEl] = useElement();
|
|
18
19
|
const popperRef = useConsolidatedRef(ref, setPopperEl);
|
|
19
20
|
const arrowRef = useRef(null);
|
|
20
|
-
const forceUpdateRef = useRef();
|
|
21
21
|
const [showPopover, setShowPopover] = useState(show);
|
|
22
22
|
const timeout = useRef();
|
|
23
23
|
const uid = useUID();
|
|
24
24
|
const portalTarget = typeof portal === 'boolean' ? configurationPortal : portal;
|
|
25
|
-
const memoedModifiers = useMemo(() =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
25
|
+
const memoedModifiers = useMemo(() => {
|
|
26
|
+
const flipEnabled = !!modifiers
|
|
27
|
+
.slice()
|
|
28
|
+
.reverse()
|
|
29
|
+
.find(modifier => modifier.name === 'flip' && modifier.enabled !== undefined)?.enabled;
|
|
30
|
+
return [
|
|
31
|
+
{
|
|
32
|
+
name: 'computeStyles',
|
|
33
|
+
options: {
|
|
34
|
+
gpuAcceleration: false
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'offset',
|
|
39
|
+
options: {
|
|
40
|
+
offset: [0, arrow ? 5.5 : 2]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{ name: 'hide', enabled: hideOnTargetHidden },
|
|
44
|
+
{ name: 'arrow', enabled: arrow, options: { element: arrowRef.current } },
|
|
45
|
+
{
|
|
46
|
+
name: 'preventOverflow',
|
|
47
|
+
options: {
|
|
48
|
+
tether: !modifiers.find(m => m.name === 'sameWidth'),
|
|
49
|
+
padding: 16
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
...placeAndContain,
|
|
54
|
+
enabled: !flipEnabled
|
|
55
|
+
},
|
|
56
|
+
...modifiers
|
|
57
|
+
];
|
|
58
|
+
}, [arrow, hideOnTargetHidden, modifiers]);
|
|
48
59
|
const offset = useMemo(() => {
|
|
49
60
|
const offsetModifier = [...memoedModifiers]
|
|
50
61
|
.reverse()
|
|
@@ -53,25 +64,11 @@ const Popover = forwardRef(({ show = true, portal = false, target, placement, st
|
|
|
53
64
|
? offsetModifier?.options?.offset[1] ?? 0
|
|
54
65
|
: 0;
|
|
55
66
|
}, [memoedModifiers]);
|
|
56
|
-
const { styles, attributes
|
|
67
|
+
const { styles, attributes } = usePopper(target, popperRef.current, {
|
|
57
68
|
placement,
|
|
58
69
|
strategy,
|
|
59
70
|
modifiers: memoedModifiers
|
|
60
71
|
});
|
|
61
|
-
if (forceUpdate)
|
|
62
|
-
forceUpdateRef.current = forceUpdate;
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
const observer = new ResizeObserver(() => {
|
|
65
|
-
forceUpdateRef.current?.();
|
|
66
|
-
});
|
|
67
|
-
if (popperRef.current)
|
|
68
|
-
observer.observe(popperRef.current);
|
|
69
|
-
if (target instanceof Element)
|
|
70
|
-
observer.observe(target);
|
|
71
|
-
return () => {
|
|
72
|
-
observer.disconnect();
|
|
73
|
-
};
|
|
74
|
-
}, [forceUpdate, popperRef.current, target]);
|
|
75
72
|
useEffect(() => {
|
|
76
73
|
if (groupId && show)
|
|
77
74
|
setActive(uid, groupId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,UAAU,EAKV,MAAM,EAEN,SAAS,EACT,OAAO,EACP,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,SAAS,EAAe,MAAM,cAAc,CAAC;AAKtD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,MAAM,EACP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAA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":["import {\n forwardRef,\n useContext,\n PropsWithoutRef,\n Ref,\n CSSProperties,\n ReactElement,\n useRef,\n ReactNode,\n useEffect,\n useMemo,\n useState\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { usePopper, PopperProps } from 'react-popper';\nimport { VirtualElement } from '@popperjs/core';\nimport { OffsetModifier } from '@popperjs/core/lib/modifiers/offset';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport {\n useAfterInitialEffect,\n useConfiguration,\n useConsolidatedRef,\n useElement,\n useUID\n} from '../../hooks';\nimport { windowIsAvailable } from '../../utils';\nimport { ConfigurationProps } from '../Configuration';\n\nimport { PopoverManagerContext } from './PopoverContext';\nimport { StyledPopover, StyledPopoverArrow } from './Popover.styles';\n\nexport type Delay = 'none' | 'short' | 'long';\nexport interface PopoverProps<Modifiers extends string = string> extends BaseProps {\n /** The DOM element or [virtual element](https://popper.js.org/docs/v2/virtual-elements) that the Popover is positioned in reference to. */\n target: Element | VirtualElement | null;\n /**\n * If true, the Popover will be visible.\n * @default true\n */\n show?: boolean;\n /**\n * If true, the Popover will render outside of the current DOM hierarchy in a [portal](https://reactjs.org/docs/portals.html).\n * @default false\n */\n portal?: boolean | ConfigurationProps['portalTarget'];\n /**\n * Delay on showing the Popover.\n * @default \"none\"\n */\n showDelay?: Delay;\n /**\n * Delay on hiding the Popover.\n * @default \"none\"\n */\n hideDelay?: Delay;\n /**\n * [React Popper Placement](https://popper.js.org/react-popper/v2/render-props/#placement)\n */\n placement?: PopperProps<Modifiers>['placement'];\n /**\n * [React Popper Strategy](https://popper.js.org/react-popper/v2/render-props/#strategy)\n * @default \"absolute\"\n */\n strategy?: PopperProps<Modifiers>['strategy'];\n /**\n * [React Popper Modifiers](https://popper.js.org/react-popper/v2/render-props/#modifiers)\n * @default []\n */\n modifiers?: PopperProps<Modifiers>['modifiers'];\n /**\n * If true, an arrow will visually identify from which element the Popover is rendered.\n * @default false\n */\n arrow?: boolean;\n /** The group that the Popover belongs to. Popovers in the same group will be closed when others open. */\n groupId?: string;\n /**\n * If true, the Popover will be visibly hidden when its target leaves the viewport.\n * @default false\n */\n hideOnTargetHidden?: boolean;\n /** Callback that runs when the popover is hidden */\n onHide?: () => void;\n /** The content of the Popover. */\n children: ReactNode;\n /** The ref of the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst delays = {\n none: 0,\n short: 500,\n long: 1000\n};\n\nconst Popover: <Modifiers extends string = string>(\n props: PopoverProps<Modifiers> & ForwardProps\n) => ReactElement | null = forwardRef(\n (\n {\n show = true,\n portal = false,\n target,\n placement,\n strategy = 'fixed',\n style,\n modifiers = [],\n arrow = false,\n groupId,\n showDelay = 'none',\n hideDelay = 'none',\n hideOnTargetHidden = false,\n children,\n onHide,\n ...restProps\n }: PropsWithoutRef<PopoverProps> & { style?: CSSProperties },\n ref: PopoverProps['ref']\n ) => {\n const { portalTarget: configurationPortal } = useConfiguration();\n const { checkActive, setActive, popovers } = useContext(PopoverManagerContext);\n const [, setPopperEl] = useElement<HTMLDivElement>();\n const popperRef = useConsolidatedRef<HTMLDivElement>(ref, setPopperEl);\n const arrowRef = useRef<HTMLDivElement>(null);\n const forceUpdateRef = useRef<() => void>();\n const [showPopover, setShowPopover] = useState(show);\n const timeout = useRef<number>();\n const uid = useUID();\n\n const portalTarget = typeof portal === 'boolean' ? configurationPortal : portal;\n\n const memoedModifiers = useMemo(\n () => [\n {\n name: 'computeStyles',\n options: {\n gpuAcceleration: false\n }\n },\n {\n name: 'offset',\n options: {\n offset: [0, arrow ? 5.5 : 2]\n }\n },\n { name: 'hide', enabled: hideOnTargetHidden },\n { name: 'arrow', enabled: arrow, options: { element: arrowRef.current } },\n {\n name: 'preventOverflow',\n options: {\n tether: !modifiers.find(m => m.name === 'sameWidth')\n }\n },\n ...modifiers\n ],\n [modifiers, arrow, hideOnTargetHidden]\n );\n\n const offset = useMemo(() => {\n const offsetModifier = [...memoedModifiers]\n .reverse()\n .find(m => m.name === 'offset' && m.enabled !== false) as OffsetModifier | undefined;\n return Array.isArray(offsetModifier?.options?.offset)\n ? offsetModifier?.options?.offset[1] ?? 0\n : 0;\n }, [memoedModifiers]);\n\n const { styles, attributes, forceUpdate } = usePopper(target, popperRef.current, {\n placement,\n strategy,\n modifiers: memoedModifiers\n });\n\n if (forceUpdate) forceUpdateRef.current = forceUpdate;\n\n useEffect(() => {\n const observer = new ResizeObserver(() => {\n forceUpdateRef.current?.();\n });\n\n if (popperRef.current) observer.observe(popperRef.current);\n if (target instanceof Element) observer.observe(target);\n\n return () => {\n observer.disconnect();\n };\n }, [forceUpdate, popperRef.current, target]);\n\n useEffect(() => {\n if (groupId && show) setActive(uid, groupId);\n\n if (windowIsAvailable) {\n if (timeout.current) clearTimeout(timeout.current);\n timeout.current = window.setTimeout(() => {\n setShowPopover(show);\n }, delays[show ? showDelay : hideDelay]);\n } else {\n setShowPopover(show);\n }\n }, [show]);\n\n useEffect(() => {\n return () => clearTimeout(timeout.current);\n }, []);\n\n useAfterInitialEffect(() => {\n if (!showPopover) {\n onHide?.();\n }\n }, [showPopover]);\n\n useEffect(() => {\n if (groupId && popovers[groupId] && popovers[groupId] !== uid) {\n setShowPopover(false);\n }\n }, [groupId ? popovers[groupId] : undefined]);\n\n const content = (\n <StyledPopover\n {...restProps}\n offset={offset}\n ref={popperRef}\n style={{ ...style, ...styles.popper }}\n {...attributes.popper}\n >\n {arrow && <StyledPopoverArrow ref={arrowRef} style={{ ...styles.arrow }} />}\n {children}\n </StyledPopover>\n );\n\n if (!target || !showPopover || (groupId && !checkActive(uid, groupId))) return null;\n\n return portal && portalTarget ? createPortal(content, portalTarget) : content;\n }\n);\n\nexport default Popover;\n"]}
|
|
1
|
+
{"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,UAAU,EAKV,MAAM,EAEN,SAAS,EACT,OAAO,EACP,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE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\n forwardRef,\n useContext,\n PropsWithoutRef,\n Ref,\n CSSProperties,\n ReactElement,\n useRef,\n ReactNode,\n useEffect,\n useMemo,\n useState\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { usePopper, PopperProps } from 'react-popper';\nimport { VirtualElement } from '@popperjs/core';\nimport { OffsetModifier } from '@popperjs/core/lib/modifiers/offset';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport {\n useAfterInitialEffect,\n useConfiguration,\n useConsolidatedRef,\n useElement,\n useUID\n} from '../../hooks';\nimport { windowIsAvailable } from '../../utils';\nimport { ConfigurationProps } from '../Configuration';\n\nimport { PopoverManagerContext } from './PopoverContext';\nimport { StyledPopover, StyledPopoverArrow } from './Popover.styles';\nimport { placeAndContain } from './modifiers';\n\nexport type Delay = 'none' | 'short' | 'long';\nexport interface PopoverProps<Modifiers extends string = string> extends BaseProps {\n /** The DOM element or [virtual element](https://popper.js.org/docs/v2/virtual-elements) that the Popover is positioned in reference to. */\n target: Element | VirtualElement | null;\n /**\n * If true, the Popover will be visible.\n * @default true\n */\n show?: boolean;\n /**\n * If true, the Popover will render outside of the current DOM hierarchy in a [portal](https://reactjs.org/docs/portals.html).\n * @default false\n */\n portal?: boolean | ConfigurationProps['portalTarget'];\n /**\n * Delay on showing the Popover.\n * @default \"none\"\n */\n showDelay?: Delay;\n /**\n * Delay on hiding the Popover.\n * @default \"none\"\n */\n hideDelay?: Delay;\n /**\n * [React Popper Placement](https://popper.js.org/react-popper/v2/render-props/#placement)\n * @default \"bottom\"\n */\n placement?: PopperProps<Modifiers>['placement'];\n /**\n * [React Popper Strategy](https://popper.js.org/react-popper/v2/render-props/#strategy)\n * @default \"absolute\"\n */\n strategy?: PopperProps<Modifiers>['strategy'];\n /**\n * [React Popper Modifiers](https://popper.js.org/react-popper/v2/render-props/#modifiers)\n * @default []\n */\n modifiers?: PopperProps<Modifiers>['modifiers'];\n /**\n * If true, an arrow will visually identify from which element the Popover is rendered.\n * @default false\n */\n arrow?: boolean;\n /** The group that the Popover belongs to. Popovers in the same group will be closed when others open. */\n groupId?: string;\n /**\n * If true, the Popover will be visibly hidden when its target leaves the viewport.\n * @default false\n */\n hideOnTargetHidden?: boolean;\n /** Callback that runs when the popover is hidden */\n onHide?: () => void;\n /** The content of the Popover. */\n children: ReactNode;\n /** The ref of the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst delays = {\n none: 0,\n short: 500,\n long: 1000\n};\n\nconst Popover: <Modifiers extends string = string>(\n props: PopoverProps<Modifiers> & ForwardProps\n) => ReactElement | null = forwardRef(\n (\n {\n show = true,\n portal = false,\n target,\n placement = 'bottom',\n strategy = 'fixed',\n style,\n modifiers = [],\n arrow = false,\n groupId,\n showDelay = 'none',\n hideDelay = 'none',\n hideOnTargetHidden = false,\n children,\n onHide,\n ...restProps\n }: PropsWithoutRef<PopoverProps> & { style?: CSSProperties },\n ref: PopoverProps['ref']\n ) => {\n const { portalTarget: configurationPortal } = useConfiguration();\n const { checkActive, setActive, popovers } = useContext(PopoverManagerContext);\n const [, setPopperEl] = useElement<HTMLDivElement>();\n const popperRef = useConsolidatedRef<HTMLDivElement>(ref, setPopperEl);\n const arrowRef = useRef<HTMLDivElement>(null);\n const [showPopover, setShowPopover] = useState(show);\n const timeout = useRef<number>();\n const uid = useUID();\n\n const portalTarget = typeof portal === 'boolean' ? configurationPortal : portal;\n\n const memoedModifiers = useMemo(() => {\n const flipEnabled = !!modifiers\n .slice()\n .reverse()\n .find(modifier => modifier.name === 'flip' && modifier.enabled !== undefined)?.enabled;\n\n return [\n {\n name: 'computeStyles',\n options: {\n gpuAcceleration: false\n }\n },\n {\n name: 'offset',\n options: {\n offset: [0, arrow ? 5.5 : 2]\n }\n },\n { name: 'hide', enabled: hideOnTargetHidden },\n { name: 'arrow', enabled: arrow, options: { element: arrowRef.current } },\n {\n name: 'preventOverflow',\n options: {\n tether: !modifiers.find(m => m.name === 'sameWidth'),\n padding: 16\n }\n },\n {\n ...placeAndContain,\n enabled: !flipEnabled\n },\n ...modifiers\n ];\n }, [arrow, hideOnTargetHidden, modifiers]);\n\n const offset = useMemo(() => {\n const offsetModifier = [...memoedModifiers]\n .reverse()\n .find(m => m.name === 'offset' && m.enabled !== false) as OffsetModifier | undefined;\n return Array.isArray(offsetModifier?.options?.offset)\n ? offsetModifier?.options?.offset[1] ?? 0\n : 0;\n }, [memoedModifiers]);\n\n const { styles, attributes } = usePopper(target, popperRef.current, {\n placement,\n strategy,\n modifiers: memoedModifiers\n });\n\n useEffect(() => {\n if (groupId && show) setActive(uid, groupId);\n\n if (windowIsAvailable) {\n if (timeout.current) clearTimeout(timeout.current);\n timeout.current = window.setTimeout(() => {\n setShowPopover(show);\n }, delays[show ? showDelay : hideDelay]);\n } else {\n setShowPopover(show);\n }\n }, [show]);\n\n useEffect(() => {\n return () => clearTimeout(timeout.current);\n }, []);\n\n useAfterInitialEffect(() => {\n if (!showPopover) {\n onHide?.();\n }\n }, [showPopover]);\n\n useEffect(() => {\n if (groupId && popovers[groupId] && popovers[groupId] !== uid) {\n setShowPopover(false);\n }\n }, [groupId ? popovers[groupId] : undefined]);\n\n const content = (\n <StyledPopover\n {...restProps}\n offset={offset}\n ref={popperRef}\n style={{ ...style, ...styles.popper }}\n {...attributes.popper}\n >\n {arrow && <StyledPopoverArrow ref={arrowRef} style={{ ...styles.arrow }} />}\n {children}\n </StyledPopover>\n );\n\n if (!target || !showPopover || (groupId && !checkActive(uid, groupId))) return null;\n\n return portal && portalTarget ? createPortal(content, portalTarget) : content;\n }\n);\n\nexport default Popover;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverManager.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/PopoverManager.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"PopoverManager.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/PopoverManager.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAkC,MAAM,OAAO,CAAC;AAIrF,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,CA0B9D,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from 'react';
|
|
2
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
3
3
|
import { PopoverManagerContext } from './PopoverContext';
|
|
4
4
|
const PopoverManager = ({ children }) => {
|
|
5
5
|
const [popovers, setPopovers] = useState({});
|
|
6
|
-
const checkActive = (id, groupId) => {
|
|
6
|
+
const checkActive = useCallback((id, groupId) => {
|
|
7
7
|
return popovers[groupId] === id;
|
|
8
|
-
};
|
|
9
|
-
const setActive = (id, groupId) => {
|
|
8
|
+
}, [popovers]);
|
|
9
|
+
const setActive = useCallback((id, groupId) => {
|
|
10
10
|
setPopovers(curr => {
|
|
11
11
|
return { ...curr, [groupId]: id };
|
|
12
12
|
});
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
}, []);
|
|
14
|
+
const ctx = useMemo(() => ({
|
|
15
|
+
checkActive,
|
|
16
|
+
setActive,
|
|
17
|
+
popovers
|
|
18
|
+
}), [checkActive, setActive, popovers]);
|
|
19
|
+
return _jsx(PopoverManagerContext.Provider, { value: ctx, children: children });
|
|
19
20
|
};
|
|
20
21
|
export default PopoverManager;
|
|
21
22
|
//# sourceMappingURL=PopoverManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverManager.js","sourceRoot":"","sources":["../../../src/components/Popover/PopoverManager.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAgC,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PopoverManager.js","sourceRoot":"","sources":["../../../src/components/Popover/PopoverManager.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAgC,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,cAAc,GAA+C,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IAClF,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAyB,EAAE,CAAC,CAAC;IAErE,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,EAAU,EAAE,OAAe,EAAW,EAAE;QACvC,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,EAAU,EAAE,OAAe,EAAE,EAAE;QAC5D,WAAW,CAAC,IAAI,CAAC,EAAE;YACjB,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,GAAG,GAAG,OAAO,CACjB,GAAG,EAAE,CAAC,CAAC;QACL,WAAW;QACX,SAAS;QACT,QAAQ;KACT,CAAC,EACF,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC,CACnC,CAAC;IAEF,OAAO,KAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,GAAG,YAAG,QAAQ,GAAkC,CAAC;AACjG,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { FunctionComponent, ReactNode, useCallback, useMemo, useState } from 'react';\n\nimport { PopoverManagerContext } from './PopoverContext';\n\nconst PopoverManager: FunctionComponent<{ children: ReactNode }> = ({ children }) => {\n const [popovers, setPopovers] = useState<Record<string, string>>({});\n\n const checkActive = useCallback(\n (id: string, groupId: string): boolean => {\n return popovers[groupId] === id;\n },\n [popovers]\n );\n\n const setActive = useCallback((id: string, groupId: string) => {\n setPopovers(curr => {\n return { ...curr, [groupId]: id };\n });\n }, []);\n\n const ctx = useMemo(\n () => ({\n checkActive,\n setActive,\n popovers\n }),\n [checkActive, setActive, popovers]\n );\n\n return <PopoverManagerContext.Provider value={ctx}>{children}</PopoverManagerContext.Provider>;\n};\n\nexport default PopoverManager;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modifiers.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/modifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"modifiers.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/modifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAQlD,CAAC;AAKH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAwI9D,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { getScrollbarWidth, testElForOverflow } from '../../utils';
|
|
2
2
|
export const sameWidth = Object.freeze({
|
|
3
3
|
name: 'sameWidth',
|
|
4
4
|
enabled: true,
|
|
@@ -8,4 +8,100 @@ export const sameWidth = Object.freeze({
|
|
|
8
8
|
},
|
|
9
9
|
requires: ['computeStyles']
|
|
10
10
|
});
|
|
11
|
+
const scrollbarSize = getScrollbarWidth();
|
|
12
|
+
const paddingFromViewport = 16;
|
|
13
|
+
export const placeAndContain = Object.freeze({
|
|
14
|
+
name: 'placeAndContain',
|
|
15
|
+
enabled: true,
|
|
16
|
+
phase: 'beforeWrite',
|
|
17
|
+
requires: ['computeStyles', 'offset'],
|
|
18
|
+
fn: ({ state }) => {
|
|
19
|
+
const [requestedPrimaryPlacement, requestedSecondaryPlacement] = state.placement.split('-');
|
|
20
|
+
const vw = document.documentElement.clientWidth;
|
|
21
|
+
const vh = document.documentElement.clientHeight;
|
|
22
|
+
const targetRect = state.rects.reference;
|
|
23
|
+
const targetRectXStart = targetRect.x;
|
|
24
|
+
const targetRectXEnd = targetRectXStart + targetRect.width;
|
|
25
|
+
const targetRectYStart = targetRect.y;
|
|
26
|
+
const targetRectYEnd = targetRectYStart + targetRect.height;
|
|
27
|
+
const targetXMid = (targetRectXStart + targetRectXEnd) / 2;
|
|
28
|
+
const targetYMid = (targetRectYStart + targetRectYEnd) / 2;
|
|
29
|
+
const targetIsInLeftHalfOfViewport = targetXMid < vw / 2;
|
|
30
|
+
const targetIsInTopHalfOfViewport = targetYMid < vh / 2;
|
|
31
|
+
const offsetFromTargetX = state.modifiersData.offset?.[state.placement]?.x ?? 0;
|
|
32
|
+
const offsetFromTargetY = state.modifiersData.offset?.[state.placement]?.y ?? 0;
|
|
33
|
+
let popoverMaxWidth = null;
|
|
34
|
+
let popoverMaxHeight = null;
|
|
35
|
+
const totalScrollableChildHeight = Array.from(state.elements.popper.children).reduce((sum, el) => {
|
|
36
|
+
if (el === state.elements.arrow) {
|
|
37
|
+
return sum;
|
|
38
|
+
}
|
|
39
|
+
if (testElForOverflow(el)[0]) {
|
|
40
|
+
return sum + el.scrollHeight + scrollbarSize;
|
|
41
|
+
}
|
|
42
|
+
return sum + el.scrollHeight;
|
|
43
|
+
}, 0);
|
|
44
|
+
const naturalPopoverHeight = Math.max(state.elements.popper.scrollHeight, totalScrollableChildHeight);
|
|
45
|
+
const naturalPopoverWidth = Math.max(state.elements.popper.scrollWidth, ...Array.from(state.elements.popper.children).map(el => {
|
|
46
|
+
if (el === state.elements.arrow) {
|
|
47
|
+
return -Infinity;
|
|
48
|
+
}
|
|
49
|
+
if (testElForOverflow(el)[1]) {
|
|
50
|
+
return el.scrollWidth + scrollbarSize;
|
|
51
|
+
}
|
|
52
|
+
return el.scrollWidth;
|
|
53
|
+
}));
|
|
54
|
+
let resolvedPlacement = requestedPrimaryPlacement;
|
|
55
|
+
if (requestedPrimaryPlacement === 'bottom') {
|
|
56
|
+
popoverMaxHeight = vh - targetRectYEnd - offsetFromTargetY - paddingFromViewport;
|
|
57
|
+
if (
|
|
58
|
+
// If the popover will overflow the viewport bottom
|
|
59
|
+
targetRectYEnd + offsetFromTargetY + naturalPopoverHeight >
|
|
60
|
+
vh) {
|
|
61
|
+
// Choose the side with most allowance
|
|
62
|
+
resolvedPlacement = targetIsInTopHalfOfViewport ? 'bottom' : 'top';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if (requestedPrimaryPlacement === 'top') {
|
|
66
|
+
popoverMaxHeight = targetRectYStart + offsetFromTargetY - paddingFromViewport;
|
|
67
|
+
if (
|
|
68
|
+
// If the popover will overflow the viewport top
|
|
69
|
+
targetRectYStart + offsetFromTargetY - naturalPopoverHeight <
|
|
70
|
+
0) {
|
|
71
|
+
// Choose the side with most allowance
|
|
72
|
+
resolvedPlacement = targetIsInTopHalfOfViewport ? 'bottom' : 'top';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (requestedPrimaryPlacement === 'left') {
|
|
76
|
+
popoverMaxWidth = targetRectXStart + offsetFromTargetX - paddingFromViewport;
|
|
77
|
+
if (
|
|
78
|
+
// If the popover will overflow the viewport left
|
|
79
|
+
targetRectXStart + offsetFromTargetX - naturalPopoverWidth <
|
|
80
|
+
0) {
|
|
81
|
+
// Choose the side with most allowance
|
|
82
|
+
resolvedPlacement = targetIsInLeftHalfOfViewport ? 'right' : 'left';
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else if (requestedPrimaryPlacement === 'right') {
|
|
86
|
+
popoverMaxWidth = vw - targetRectXEnd - offsetFromTargetX - paddingFromViewport;
|
|
87
|
+
if (
|
|
88
|
+
// If the popover will overflow the viewport right
|
|
89
|
+
targetRectXEnd + offsetFromTargetX + naturalPopoverWidth >
|
|
90
|
+
vw) {
|
|
91
|
+
// Choose the side with most allowance
|
|
92
|
+
resolvedPlacement = targetIsInLeftHalfOfViewport ? 'right' : 'left';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (resolvedPlacement === 'left' || resolvedPlacement === 'right') {
|
|
96
|
+
popoverMaxHeight = vh - paddingFromViewport;
|
|
97
|
+
}
|
|
98
|
+
state.elements.popper.style.maxHeight = `${popoverMaxHeight}px`;
|
|
99
|
+
state.elements.popper.style.maxWidth = popoverMaxWidth !== null ? `${popoverMaxWidth}px` : '';
|
|
100
|
+
resolvedPlacement = `${resolvedPlacement}${(requestedSecondaryPlacement ? `-${requestedSecondaryPlacement}` : '')}`;
|
|
101
|
+
if (state.placement !== resolvedPlacement) {
|
|
102
|
+
state.placement = resolvedPlacement;
|
|
103
|
+
state.reset = true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
11
107
|
//# sourceMappingURL=modifiers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modifiers.js","sourceRoot":"","sources":["../../../src/components/Popover/modifiers.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"modifiers.js","sourceRoot":"","sources":["../../../src/components/Popover/modifiers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEnE,MAAM,CAAC,MAAM,SAAS,GAAkC,MAAM,CAAC,MAAM,CAAC;IACpE,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,aAAa;IACpB,EAAE,CAAC,EAAE,KAAK,EAAE;QACV,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;IACjE,CAAC;IACD,QAAQ,EAAE,CAAC,eAAe,CAAC;CAC5B,CAAC,CAAC;AAEH,MAA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,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;aACrE;SACF;QAED,IAAI,iBAAiB,KAAK,MAAM,IAAI,iBAAiB,KAAK,OAAO,EAAE;YACjE,gBAAgB,GAAG,EAAE,GAAG,mBAAmB,CAAC;SAC7C;QAED,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,GAAG,GAAG,gBAAgB,IAAI,CAAC;QAEhE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,GAAG,eAAe,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,eAAe,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAE9F,iBAAiB,GAAG,GAAG,iBAAiB,GACtC,CAAC,2BAA2B,CAAC,CAAC,CAAC,IAAI,2BAA2B,EAAE,CAAC,CAAC,CAAC,EAAE,CAIvE,EAAE,CAAC;QAEH,IAAI,KAAK,CAAC,SAAS,KAAK,iBAAiB,EAAE;YACzC,KAAK,CAAC,SAAS,GAAG,iBAAiB,CAAC;YACpC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC;SACpB;IACH,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { Modifier } from '@popperjs/core';\n\nimport { getScrollbarWidth, testElForOverflow } from '../../utils';\n\nexport const sameWidth: Modifier<'sameWidth', object> = Object.freeze({\n name: 'sameWidth',\n enabled: true,\n phase: 'beforeWrite',\n fn({ state }) {\n state.styles.popper.width = `${state.rects.reference.width}px`;\n },\n requires: ['computeStyles']\n});\n\nconst scrollbarSize = getScrollbarWidth();\nconst paddingFromViewport = 16;\n\nexport const placeAndContain: Modifier<'placeAndContain', object> = Object.freeze({\n name: 'placeAndContain',\n enabled: true,\n phase: 'beforeWrite',\n requires: ['computeStyles', 'offset'],\n fn: ({ state }) => {\n const [requestedPrimaryPlacement, requestedSecondaryPlacement] = state.placement.split('-') as [\n primaryPlacement: 'top' | 'bottom' | 'left' | 'right' | 'auto',\n secondaryPlacement?: 'start' | 'end' | undefined\n ];\n\n const vw = document.documentElement.clientWidth;\n const vh = document.documentElement.clientHeight;\n\n const targetRect = state.rects.reference;\n const targetRectXStart = targetRect.x;\n const targetRectXEnd = targetRectXStart + targetRect.width;\n const targetRectYStart = targetRect.y;\n const targetRectYEnd = targetRectYStart + targetRect.height;\n const targetXMid = (targetRectXStart + targetRectXEnd) / 2;\n const targetYMid = (targetRectYStart + targetRectYEnd) / 2;\n const targetIsInLeftHalfOfViewport = targetXMid < vw / 2;\n const targetIsInTopHalfOfViewport = targetYMid < vh / 2;\n\n const offsetFromTargetX = state.modifiersData.offset?.[state.placement]?.x ?? 0;\n const offsetFromTargetY = state.modifiersData.offset?.[state.placement]?.y ?? 0;\n\n let popoverMaxWidth: null | number = null;\n let popoverMaxHeight: null | number = null;\n\n const totalScrollableChildHeight = Array.from(state.elements.popper.children).reduce(\n (sum, el) => {\n if (el === state.elements.arrow) {\n return sum;\n }\n\n if (testElForOverflow(el)[0]) {\n return sum + el.scrollHeight + scrollbarSize;\n }\n\n return sum + el.scrollHeight;\n },\n 0\n );\n\n const naturalPopoverHeight = Math.max(\n state.elements.popper.scrollHeight,\n totalScrollableChildHeight\n );\n\n const naturalPopoverWidth = Math.max(\n state.elements.popper.scrollWidth,\n ...Array.from(state.elements.popper.children).map(el => {\n if (el === state.elements.arrow) {\n return -Infinity;\n }\n\n if (testElForOverflow(el)[1]) {\n return el.scrollWidth + scrollbarSize;\n }\n\n return el.scrollWidth;\n })\n );\n\n let resolvedPlacement: `${'top' | 'bottom' | 'left' | 'right' | 'auto'}${\n | ''\n | '-start'\n | '-end'}` = requestedPrimaryPlacement;\n\n if (requestedPrimaryPlacement === 'bottom') {\n popoverMaxHeight = vh - targetRectYEnd - offsetFromTargetY - paddingFromViewport;\n\n if (\n // If the popover will overflow the viewport bottom\n targetRectYEnd + offsetFromTargetY + naturalPopoverHeight >\n vh\n ) {\n // Choose the side with most allowance\n resolvedPlacement = targetIsInTopHalfOfViewport ? 'bottom' : 'top';\n }\n } else if (requestedPrimaryPlacement === 'top') {\n popoverMaxHeight = targetRectYStart + offsetFromTargetY - paddingFromViewport;\n\n if (\n // If the popover will overflow the viewport top\n targetRectYStart + offsetFromTargetY - naturalPopoverHeight <\n 0\n ) {\n // Choose the side with most allowance\n resolvedPlacement = targetIsInTopHalfOfViewport ? 'bottom' : 'top';\n }\n } else if (requestedPrimaryPlacement === 'left') {\n popoverMaxWidth = targetRectXStart + offsetFromTargetX - paddingFromViewport;\n\n if (\n // If the popover will overflow the viewport left\n targetRectXStart + offsetFromTargetX - naturalPopoverWidth <\n 0\n ) {\n // Choose the side with most allowance\n resolvedPlacement = targetIsInLeftHalfOfViewport ? 'right' : 'left';\n }\n } else if (requestedPrimaryPlacement === 'right') {\n popoverMaxWidth = vw - targetRectXEnd - offsetFromTargetX - paddingFromViewport;\n\n if (\n // If the popover will overflow the viewport right\n targetRectXEnd + offsetFromTargetX + naturalPopoverWidth >\n vw\n ) {\n // Choose the side with most allowance\n resolvedPlacement = targetIsInLeftHalfOfViewport ? 'right' : 'left';\n }\n }\n\n if (resolvedPlacement === 'left' || resolvedPlacement === 'right') {\n popoverMaxHeight = vh - paddingFromViewport;\n }\n\n state.elements.popper.style.maxHeight = `${popoverMaxHeight}px`;\n\n state.elements.popper.style.maxWidth = popoverMaxWidth !== null ? `${popoverMaxWidth}px` : '';\n\n resolvedPlacement = `${resolvedPlacement}${\n (requestedSecondaryPlacement ? `-${requestedSecondaryPlacement}` : '') as\n | ''\n | '-start'\n | '-end'\n }`;\n\n if (state.placement !== resolvedPlacement) {\n state.placement = resolvedPlacement;\n state.reset = true;\n }\n }\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Progress.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Progress/Progress.styles.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,eAAO,MAAM,sBAAsB,yMAAqB,CAAC;AAczD,eAAO,MAAM,kBAAkB;iBACqB,OAAO;SAkDzD,CAAC;AAIH,eAAO,MAAM,iBAAiB;iBACG,OAAO;
|
|
1
|
+
{"version":3,"file":"Progress.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Progress/Progress.styles.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,eAAO,MAAM,sBAAsB,yMAAqB,CAAC;AAczD,eAAO,MAAM,kBAAkB;iBACqB,OAAO;SAkDzD,CAAC;AAIH,eAAO,MAAM,iBAAiB;iBACG,OAAO;SAwDtC,CAAC;AAIH,eAAO,MAAM,sBAAsB,uIAsEjC,CAAC;AAIH,eAAO,MAAM,aAAa,0GAexB,CAAC;AAIH,eAAO,MAAM,cAAc,+NAc1B,CAAC"}
|
|
@@ -19,15 +19,6 @@ StyledProgressVisual.defaultProps = defaultThemeProp;
|
|
|
19
19
|
export const StyledProgressRing = styled(StyledProgressVisual)(({ theme, placement, determinate }) => {
|
|
20
20
|
const size = placement === 'inline' ? '1em' : '2rem';
|
|
21
21
|
return css `
|
|
22
|
-
@keyframes LoadingRing {
|
|
23
|
-
0% {
|
|
24
|
-
transform: rotate(0deg);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
100% {
|
|
28
|
-
transform: rotate(360deg);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
22
|
position: relative;
|
|
32
23
|
|
|
33
24
|
svg {
|
|
@@ -52,6 +43,15 @@ export const StyledProgressRing = styled(StyledProgressVisual)(({ theme, placeme
|
|
|
52
43
|
|
|
53
44
|
${!determinate &&
|
|
54
45
|
css `
|
|
46
|
+
@keyframes LoadingRing {
|
|
47
|
+
0% {
|
|
48
|
+
transform: rotate(0deg);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
100% {
|
|
52
|
+
transform: rotate(360deg);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
55
|
animation: LoadingRing calc(4 * ${theme.base.animation.speed}) linear infinite;
|
|
56
56
|
`}
|
|
57
57
|
}
|
|
@@ -70,22 +70,18 @@ export const StyledProgressBar = styled(StyledProgressVisual)(({ theme, placemen
|
|
|
70
70
|
return css `
|
|
71
71
|
background-color: ${theme.base.colors.gray['extra-light']};
|
|
72
72
|
border-radius: ${theme.base['border-radius']};
|
|
73
|
-
|
|
73
|
+
${placement === 'local'
|
|
74
|
+
? css `
|
|
75
|
+
width: calc(100% - 4 * ${theme.base.spacing});
|
|
76
|
+
`
|
|
77
|
+
: css `
|
|
78
|
+
width: 100%;
|
|
79
|
+
`}
|
|
74
80
|
height: 0.375rem;
|
|
75
81
|
min-width: 2rem;
|
|
76
82
|
max-width: min(calc(100vw - 4 * ${theme.base.spacing}), ${theme.base['content-width'].lg});
|
|
77
83
|
overflow: hidden;
|
|
78
84
|
|
|
79
|
-
@keyframes LoadingBar {
|
|
80
|
-
0% {
|
|
81
|
-
transform: translateX(-100%);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
100% {
|
|
85
|
-
transform: translateX(200%);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
85
|
::before {
|
|
90
86
|
content: '';
|
|
91
87
|
display: block;
|
|
@@ -104,6 +100,15 @@ export const StyledProgressBar = styled(StyledProgressVisual)(({ theme, placemen
|
|
|
104
100
|
|
|
105
101
|
${!determinate &&
|
|
106
102
|
css `
|
|
103
|
+
@keyframes LoadingBar {
|
|
104
|
+
0% {
|
|
105
|
+
transform: translateX(-100%);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
100% {
|
|
109
|
+
transform: translateX(200%);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
107
112
|
animation: LoadingBar calc(8 * ${theme.base.animation.speed}) linear infinite;
|
|
108
113
|
width: 50%;
|
|
109
114
|
`}
|