@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":"Calendar.js","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/Calendar.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,OAAO,EAGP,QAAQ,EACR,UAAU,EAGV,SAAS,EACT,WAAW,EACZ,MAAM,OAAO,CAAC;AAEf,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG/F,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EA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,IACb,GAAG,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,gBACnC,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE;oBACzC,KAAK,EAAE,MAAM;oBACb,IAAI,EAAE,SAAS;oBACf,QAAQ,EAAE,KAAK;iBAChB,CAAC,EACF,SAAS,EAAE,SAAS,iBACP,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EAC/C,IAAI,EAAC,MAAM,aAEX,0BACE,yBACG,aAAa,IAAI,uBAAK,SAAS,GAAM,EACrC,YAAY,IACV,GACC,EACR,0BAAQ,KAAK,GAAS,IACP,EACjB,KAAC,gBAAgB,iBAAW,QAAQ,EAAC,IAAI,EAAC,OAAO,YAC9C,CAAC,CAAC,iBAAiB,CAAC,GACJ,IAClB,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import {\n useMemo,\n FunctionComponent,\n KeyboardEvent,\n useState,\n forwardRef,\n PropsWithoutRef,\n Ref,\n useEffect,\n useCallback\n} from 'react';\n\nimport Text from '../../Text';\nimport { CALENDAR_TYPES } from '../Input/local';\nimport {\n getCalendarTypeFromLocale,\n getDateOfISOWeek,\n getWeek,\n parseToDate,\n toUTCDateString\n} from '../Input/utils';\nimport { useConfiguration, useConsolidatedRef, useFocusWithin, useI18n } from '../../../hooks';\nimport { ForwardProps } from '../../../types';\nimport { FormControlProps } from '../../FormControl';\nimport { cap } from '../../../utils';\n\nimport { getDaysOfMonth, getLocalizedDays, getWeeksOfMonth } from './utils';\nimport {\n StyledColumnLabel,\n ScreenReaderOnly,\n StyledPick,\n StyledDay,\n StyledCalendar,\n StyledWeekGrid,\n StyledWeekLabel,\n StyledWeekNumber\n} from './Calendar.styles';\n\nexport interface CalendarProps {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /**\n * Defines default date that will be selected initially when the Calendar is visible.\n */\n selected?: Date;\n /**\n * Defines currently visible month.\n * @default new Date()\n */\n current?: Date;\n /** Defines dates range with start date and end date that can be set by the user. */\n selectedRange?: { startDate: Date | undefined; endDate: Date | undefined };\n /** Defines if days should be highlighted for range selection */\n showHighlight?: boolean;\n /** Defines if week numbers should be displayed in calendar */\n showWeekNumber?: boolean;\n /**\n * The mode of the calendar that will be rendered, ie. whether single date or week are selectable.\n * @default \"date\"\n */\n mode?: 'date' | 'week';\n /** Callback fired when new day is selected. */\n onSelect?: (date: Date) => void;\n /** Callback fired when user focuses new day. */\n onFocus?: (date: Date) => void;\n /** Sets the type of calendar to be used. This will be determined by locale if no value is provided. */\n calendarType?: string;\n /** Defines minimum available value that can be selected by the user. */\n min?: string | number | Date;\n /** Defines maximum available value that can be selected by the user. */\n max?: string | number | Date;\n /** Set the calendar to disabled state, ie. non-interactive. */\n disabled?: boolean;\n}\n\nconst ariaOpts = { day: 'numeric', month: 'long', year: 'numeric' } as const;\n\nconst Calendar: FunctionComponent<CalendarProps & ForwardProps> = forwardRef(\n (\n {\n selected,\n current = selected ? new Date(selected.getTime()) : new Date(),\n selectedRange,\n showHighlight,\n mode = 'date',\n showWeekNumber,\n calendarType: calendar = CALENDAR_TYPES.ISO_8601,\n onSelect,\n onFocus,\n disabled,\n min: minProp,\n max: maxProp\n }: PropsWithoutRef<CalendarProps>,\n ref: Ref<HTMLTableElement>\n ) => {\n const { locale } = useConfiguration();\n\n const min = minProp ? parseToDate(minProp) : -Infinity;\n const max = maxProp ? parseToDate(maxProp) : Infinity;\n\n if (min instanceof Date) min.setUTCMinutes(min.getUTCMinutes() - min.getTimezoneOffset());\n if (max instanceof Date) max.setUTCMinutes(max.getUTCMinutes() - max.getTimezoneOffset());\n\n const showWeekLabel = mode === 'week' ? false : showWeekNumber;\n const [focusedDay, setFocusedDay] = useState(current);\n useEffect(() => {\n setFocusedDay(current);\n }, [current.getUTCFullYear(), current.getUTCMonth()]);\n\n const calendarType = useMemo(\n () => calendar ?? getCalendarTypeFromLocale(locale),\n [locale, calendar]\n );\n\n const [highlightBoundary, setHighlightBoundary] = useState<Date>();\n\n const onKeyDown = useCallback(\n (e: KeyboardEvent<HTMLElement>) => {\n if (\n (mode === 'date'\n ? ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']\n : ['ArrowUp', 'ArrowDown']\n ).includes(e.key)\n ) {\n e.preventDefault();\n const newFocused = new Date(focusedDay);\n switch (e.key) {\n case 'ArrowUp':\n newFocused.setUTCDate(focusedDay.getUTCDate() - 7);\n break;\n case 'ArrowDown':\n newFocused.setUTCDate(focusedDay.getUTCDate() + 7);\n break;\n case 'ArrowRight':\n newFocused.setUTCDate(focusedDay.getUTCDate() + 1);\n break;\n case 'ArrowLeft':\n newFocused.setUTCDate(focusedDay.getUTCDate() - 1);\n break;\n default:\n }\n if (newFocused < min || newFocused > max) return;\n setFocusedDay(newFocused);\n onFocus?.(newFocused);\n setHighlightBoundary(newFocused);\n }\n if (e.key === 'Enter') {\n e.preventDefault();\n onSelect?.(focusedDay);\n }\n },\n [mode, focusedDay, onFocus, onSelect]\n );\n\n const containerRef = useConsolidatedRef<HTMLTableElement>(ref);\n const hasFocus = useFocusWithin([containerRef]);\n\n const today = toUTCDateString(new Date());\n\n const isDisabled = (day: Date) => {\n const maxDate = new Date(max);\n maxDate.setUTCMinutes(maxDate.getUTCMinutes() - maxDate.getTimezoneOffset());\n\n return min > day.getTime() || day.getTime() > maxDate.getTime();\n };\n\n const isSelected = (day: Date) => {\n return [\n selected && toUTCDateString(selected),\n selectedRange?.startDate && toUTCDateString(selectedRange?.startDate),\n selectedRange?.endDate && toUTCDateString(selectedRange?.endDate)\n ].includes(toUTCDateString(day));\n };\n\n const isWeekSelected = (day: Date) => {\n return (\n selected &&\n toUTCDateString(day) ===\n toUTCDateString(getDateOfISOWeek(getWeek(selected, calendarType), selected.getFullYear()))\n );\n };\n\n const isFocused = (day: Date) => {\n return toUTCDateString(day) === toUTCDateString(focusedDay);\n };\n\n const isWeekFocused = (day: Date) => {\n return (\n toUTCDateString(day) ===\n toUTCDateString(\n getDateOfISOWeek(getWeek(focusedDay, calendarType), focusedDay.getFullYear())\n )\n );\n };\n\n const isInRange = (day: Date) => {\n return (\n selectedRange &&\n selectedRange.startDate &&\n selectedRange.endDate &&\n day >= selectedRange.startDate &&\n day <= selectedRange.endDate\n );\n };\n\n const isHighlighted = (day: Date) => {\n if (!selectedRange || !showHighlight || !highlightBoundary) return false;\n const betweenHighlightAndBoundary = (rangeBoundaryType: 'startDate' | 'endDate') => {\n const rangeBoundary = selectedRange[rangeBoundaryType];\n if (!rangeBoundary) return false;\n return !!(\n rangeBoundary &&\n ((day >= rangeBoundary && day <= highlightBoundary) ||\n (day <= rangeBoundary && day >= highlightBoundary))\n );\n };\n return betweenHighlightAndBoundary('startDate') || betweenHighlightAndBoundary('endDate');\n };\n\n useEffect(() => {\n if (hasFocus)\n containerRef.current?.querySelector<HTMLButtonElement>('button[tabindex=\"0\"]')?.focus();\n }, [hasFocus, focusedDay]);\n\n const days = getDaysOfMonth(current, calendarType ?? CALENDAR_TYPES.ISO_8601).map(day => {\n return (\n <StyledDay\n key={day.getTime()}\n tabIndex={isFocused(day) ? 0 : -1}\n disabled={disabled || mode === 'week' || isDisabled(day)}\n current={toUTCDateString(day) === today}\n highlighted={isInRange(day) || isHighlighted(day)}\n aria-selected={isSelected(day) || undefined}\n aria-current={isSelected(day) ? 'date' : undefined}\n dayInNexOrPrevMonth={day.getUTCMonth() !== current.getUTCMonth()}\n aria-label={toUTCDateString(day, Intl.DateTimeFormat(locale, ariaOpts))}\n onMouseOver={showHighlight ? () => setHighlightBoundary(day) : undefined}\n onMouseOut={showHighlight ? () => setHighlightBoundary(undefined) : undefined}\n onClick={() => {\n setFocusedDay(day);\n onFocus?.(day);\n onSelect?.(day);\n }}\n >\n {day.getUTCDate()}\n </StyledDay>\n );\n });\n\n const names = useMemo(() => getLocalizedDays(calendarType, locale), [locale, calendarType]);\n\n const t = useI18n();\n\n const displayNames = new Intl.DisplayNames(locale, {\n style: 'long',\n type: 'dateTimeField'\n }) as Intl.DateTimeDisplayNames;\n const displayNamesShort = new Intl.DisplayNames(locale, {\n style: 'short',\n type: 'dateTimeField'\n }) as Intl.DateTimeDisplayNames;\n\n const weeks = getWeeksOfMonth(current, calendarType).map(weekNo => {\n return (\n <>\n <Text as={StyledWeekNumber} key={weekNo} aria-hidden='true'>\n {weekNo.toString()}\n </Text>\n <ScreenReaderOnly>\n {`${displayNames.of('weekOfYear')} ${weekNo.toString()} ${current\n .getUTCFullYear()\n .toString()}`}\n </ScreenReaderOnly>\n </>\n );\n });\n\n const weeksButtons = getWeeksOfMonth(current, calendarType).map(weekNo => {\n const dateOfISOWeek = getDateOfISOWeek(weekNo, current.getUTCFullYear());\n const lastDayOfWeek = new Date(dateOfISOWeek);\n lastDayOfWeek.setDate(dateOfISOWeek.getDate() + 6);\n return (\n <StyledPick\n key={weekNo}\n tabIndex={isWeekFocused(dateOfISOWeek) ? 0 : -1}\n disabled={disabled || mode === 'date' || isDisabled(dateOfISOWeek)}\n aria-selected={isWeekSelected(dateOfISOWeek) || undefined}\n aria-label={`${displayNames.of('weekOfYear')} ${weekNo.toString()} ${toUTCDateString(\n dateOfISOWeek,\n Intl.DateTimeFormat(locale, ariaOpts)\n )} - ${toUTCDateString(lastDayOfWeek, Intl.DateTimeFormat(locale, ariaOpts))}`}\n aria-current={isWeekFocused(dateOfISOWeek) ? 'date' : undefined}\n onMouseDown={() => {\n setFocusedDay(dateOfISOWeek);\n onFocus?.(dateOfISOWeek);\n onSelect?.(dateOfISOWeek);\n }}\n >\n {`${cap(displayNames.of('weekOfYear'))} `}\n {weekNo.toString()}\n </StyledPick>\n );\n });\n\n const weekLabel =\n mode === 'date' ? (\n <>\n <Text\n as={StyledWeekLabel}\n forwardedAs='abbr'\n title={cap(displayNames.of('weekOfYear'))}\n aria-hidden='true'\n >\n {cap(displayNamesShort.of('weekOfYear'))}\n </Text>\n <ScreenReaderOnly>{displayNames.of('weekOfYear')}</ScreenReaderOnly>\n </>\n ) : (\n <Text as={StyledWeekLabel}>{cap(displayNames.of('weekOfYear'))}</Text>\n );\n\n const headerLabels = names.map(([name, abbr]) => (\n <th role='columnheader' key={name}>\n <Text as={StyledColumnLabel} forwardedAs='abbr' key={name} title={name} aria-hidden='true'>\n {abbr}\n </Text>\n <ScreenReaderOnly>{name}</ScreenReaderOnly>\n </th>\n ));\n\n const splitToWeeks = (resultArray: JSX.Element[][], item: JSX.Element, index: number) => {\n const chunkIndex = Math.floor(index / 7);\n\n if (!resultArray[chunkIndex]) {\n resultArray[chunkIndex] = [] as JSX.Element[];\n }\n\n resultArray[chunkIndex].push(item);\n return resultArray;\n };\n\n const cells = days.reduce(splitToWeeks, []).map((week, index) => {\n const rowHeader = mode === 'week' ? weeksButtons[index] : weeks[index];\n return (\n // eslint-disable-next-line react/no-array-index-key\n <tr key={`week-${index}`}>\n {showWeekLabel && <th scope='row'>{rowHeader}</th>}\n {week.map((day, dayIndex) => {\n // eslint-disable-next-line react/no-array-index-key\n return <td key={`day-${dayIndex}`}>{day}</td>;\n })}\n </tr>\n );\n });\n\n const weeksCells = weeksButtons.map((week, index) => {\n return (\n // eslint-disable-next-line react/no-array-index-key\n <tr key={`week-${index}`}>\n <td>{week}</td>\n </tr>\n );\n });\n\n const weeksGrid = (\n <StyledWeekGrid role='grid' onKeyDown={onKeyDown} ref={containerRef}>\n <thead>\n <tr>\n <th>{weekLabel}</th>\n </tr>\n </thead>\n <tbody>{weeksCells}</tbody>\n </StyledWeekGrid>\n );\n\n return (\n <>\n {mode === 'week' && weeksGrid}\n <StyledCalendar\n ref={mode === 'date' ? containerRef : undefined}\n aria-label={current.toLocaleString(locale, {\n month: 'long',\n year: 'numeric',\n timeZone: 'UTC'\n })}\n onKeyDown={onKeyDown}\n aria-hidden={mode === 'week' ? true : undefined}\n role='grid'\n >\n <thead>\n <tr>\n {showWeekLabel && <th>{weekLabel}</th>}\n {headerLabels}\n </tr>\n </thead>\n <tbody>{cells}</tbody>\n </StyledCalendar>\n <ScreenReaderOnly aria-live='polite' role='alert'>\n {t('calendar_assist')}\n </ScreenReaderOnly>\n </>\n );\n }\n);\n\nexport default Calendar;\n"]}
|
|
1
|
+
{"version":3,"file":"Calendar.js","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/Calendar.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,OAAO,EAGP,QAAQ,EACR,UAAU,EAGV,SAAS,EACT,WAAW,EACZ,MAAM,OAAO,CAAC;AAEf,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG/F,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AA0C3B,MAAM,QAAQ,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAW,CAAC;AAE7E,MAAM,QAAQ,GAAoD,UAAU,CAC1E,CACE,EACE,QAAQ,EACR,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,EAC9D,aAAa,EACb,aA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YAAY,IACV,GACC,EACR,0BAAQ,KAAK,GAAS,IACP,EACjB,KAAC,gBAAgB,iBAAW,QAAQ,EAAC,IAAI,EAAC,OAAO,YAC9C,CAAC,CAAC,iBAAiB,CAAC,GACJ,IAClB,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import {\n useMemo,\n FunctionComponent,\n KeyboardEvent,\n useState,\n forwardRef,\n PropsWithoutRef,\n Ref,\n useEffect,\n useCallback\n} from 'react';\n\nimport Text from '../../Text';\nimport { CALENDAR_TYPES } from '../Input/local';\nimport {\n getCalendarTypeFromLocale,\n getDateOfISOWeek,\n getWeek,\n parseToDate,\n toUTCDateString\n} from '../Input/utils';\nimport { useConfiguration, useConsolidatedRef, useFocusWithin, useI18n } from '../../../hooks';\nimport { ForwardProps } from '../../../types';\nimport { FormControlProps } from '../../FormControl';\nimport { cap } from '../../../utils';\n\nimport { getDaysOfMonth, getLocalizedDays, getWeeksOfMonth } from './utils';\nimport {\n StyledColumnLabel,\n ScreenReaderOnly,\n StyledPick,\n StyledDay,\n StyledCalendar,\n StyledWeekGrid,\n StyledWeekLabel,\n StyledWeekNumber\n} from './Calendar.styles';\n\nexport interface CalendarProps {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /**\n * Defines default date that will be selected initially when the Calendar is visible.\n */\n selected?: Date;\n /**\n * Defines currently visible month.\n * @default new Date()\n */\n current?: Date;\n /** Defines dates range with start date and end date that can be set by the user. */\n selectedRange?: { startDate: Date | undefined; endDate: Date | undefined };\n /** Defines if days should be highlighted for range selection */\n showHighlight?: boolean;\n /** Defines if week numbers should be displayed in calendar */\n showWeekNumber?: boolean;\n /**\n * The mode of the calendar that will be rendered, ie. whether single date or week are selectable.\n * @default \"date\"\n */\n mode?: 'date' | 'week';\n /** Callback fired when new day is selected. */\n onSelect?: (date: Date) => void;\n /** Callback fired when user focuses new day. */\n onFocus?: (date: Date) => void;\n /** Sets the type of calendar to be used. This will be determined by locale if no value is provided. */\n calendarType?: string;\n /** Defines minimum available value that can be selected by the user. */\n min?: string | number | Date;\n /** Defines maximum available value that can be selected by the user. */\n max?: string | number | Date;\n /** Set the calendar to disabled state, ie. non-interactive. */\n disabled?: boolean;\n}\n\nconst ariaOpts = { day: 'numeric', month: 'long', year: 'numeric' } as const;\n\nconst Calendar: FunctionComponent<CalendarProps & ForwardProps> = forwardRef(\n (\n {\n selected,\n current = selected ? new Date(selected.getTime()) : new Date(),\n selectedRange,\n showHighlight,\n mode = 'date',\n showWeekNumber,\n calendarType: calendar = CALENDAR_TYPES.ISO_8601,\n onSelect,\n onFocus,\n disabled,\n min: minProp,\n max: maxProp\n }: PropsWithoutRef<CalendarProps>,\n ref: Ref<HTMLTableElement>\n ) => {\n const { locale } = useConfiguration();\n\n const min = minProp ? parseToDate(minProp) : -Infinity;\n const max = maxProp ? parseToDate(maxProp) : Infinity;\n\n if (min instanceof Date) min.setUTCMinutes(min.getUTCMinutes() - min.getTimezoneOffset());\n if (max instanceof Date) max.setUTCMinutes(max.getUTCMinutes() - max.getTimezoneOffset());\n\n const showWeekLabel = mode === 'week' ? false : showWeekNumber;\n const [focusedDay, setFocusedDay] = useState(current);\n useEffect(() => {\n setFocusedDay(current);\n }, [current.getUTCFullYear(), current.getUTCMonth()]);\n\n const calendarType = useMemo(\n () => calendar ?? getCalendarTypeFromLocale(locale),\n [locale, calendar]\n );\n\n const [highlightBoundary, setHighlightBoundary] = useState<Date>();\n\n const onKeyDown = useCallback(\n (e: KeyboardEvent<HTMLElement>) => {\n if (\n (mode === 'date'\n ? ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']\n : ['ArrowUp', 'ArrowDown']\n ).includes(e.key)\n ) {\n e.preventDefault();\n const newFocused = new Date(focusedDay);\n switch (e.key) {\n case 'ArrowUp':\n newFocused.setUTCDate(focusedDay.getUTCDate() - 7);\n break;\n case 'ArrowDown':\n newFocused.setUTCDate(focusedDay.getUTCDate() + 7);\n break;\n case 'ArrowRight':\n newFocused.setUTCDate(focusedDay.getUTCDate() + 1);\n break;\n case 'ArrowLeft':\n newFocused.setUTCDate(focusedDay.getUTCDate() - 1);\n break;\n default:\n }\n if (newFocused < min || newFocused > max) return;\n setFocusedDay(newFocused);\n onFocus?.(newFocused);\n setHighlightBoundary(newFocused);\n }\n if (e.key === 'Enter') {\n e.preventDefault();\n onSelect?.(focusedDay);\n }\n },\n [mode, focusedDay, onFocus, onSelect]\n );\n\n const containerRef = useConsolidatedRef<HTMLTableElement>(ref);\n const hasFocus = useFocusWithin([containerRef]);\n\n const today = toUTCDateString(new Date());\n\n const isDisabled = (day: Date) => {\n const maxDate = new Date(max);\n maxDate.setUTCMinutes(maxDate.getUTCMinutes() - maxDate.getTimezoneOffset());\n\n return Number(min) > day.getTime() || day.getTime() > maxDate.getTime();\n };\n\n const isSelected = (day: Date) => {\n return [\n selected && toUTCDateString(selected),\n selectedRange?.startDate && toUTCDateString(selectedRange?.startDate),\n selectedRange?.endDate && toUTCDateString(selectedRange?.endDate)\n ].includes(toUTCDateString(day));\n };\n\n const isWeekSelected = (day: Date) => {\n return (\n selected &&\n toUTCDateString(day) ===\n toUTCDateString(getDateOfISOWeek(getWeek(selected, calendarType), selected.getFullYear()))\n );\n };\n\n const isFocused = (day: Date) => {\n return toUTCDateString(day) === toUTCDateString(focusedDay);\n };\n\n const isWeekFocused = (day: Date) => {\n return (\n toUTCDateString(day) ===\n toUTCDateString(\n getDateOfISOWeek(getWeek(focusedDay, calendarType), focusedDay.getFullYear())\n )\n );\n };\n\n const isInRange = (day: Date) => {\n return (\n selectedRange &&\n selectedRange.startDate &&\n selectedRange.endDate &&\n day >= selectedRange.startDate &&\n day <= selectedRange.endDate\n );\n };\n\n const isHighlighted = (day: Date) => {\n if (!selectedRange || !showHighlight || !highlightBoundary) return false;\n const betweenHighlightAndBoundary = (rangeBoundaryType: 'startDate' | 'endDate') => {\n const rangeBoundary = selectedRange[rangeBoundaryType];\n if (!rangeBoundary) return false;\n return !!(\n rangeBoundary &&\n ((day >= rangeBoundary && day <= highlightBoundary) ||\n (day <= rangeBoundary && day >= highlightBoundary))\n );\n };\n return betweenHighlightAndBoundary('startDate') || betweenHighlightAndBoundary('endDate');\n };\n\n useEffect(() => {\n if (hasFocus)\n containerRef.current?.querySelector<HTMLButtonElement>('button[tabindex=\"0\"]')?.focus();\n }, [hasFocus, focusedDay]);\n\n const days = getDaysOfMonth(current, calendarType ?? CALENDAR_TYPES.ISO_8601).map(day => {\n return (\n <StyledDay\n key={day.getTime()}\n tabIndex={isFocused(day) ? 0 : -1}\n disabled={disabled || mode === 'week' || isDisabled(day)}\n current={toUTCDateString(day) === today}\n highlighted={isInRange(day) || isHighlighted(day)}\n aria-selected={isSelected(day) || undefined}\n aria-current={isSelected(day) ? 'date' : undefined}\n dayInNexOrPrevMonth={day.getUTCMonth() !== current.getUTCMonth()}\n aria-label={toUTCDateString(day, Intl.DateTimeFormat(locale, ariaOpts))}\n onMouseOver={showHighlight ? () => setHighlightBoundary(day) : undefined}\n onMouseOut={showHighlight ? () => setHighlightBoundary(undefined) : undefined}\n onClick={() => {\n setFocusedDay(day);\n onFocus?.(day);\n onSelect?.(day);\n }}\n >\n {day.getUTCDate()}\n </StyledDay>\n );\n });\n\n const names = useMemo(() => getLocalizedDays(calendarType, locale), [locale, calendarType]);\n\n const t = useI18n();\n\n const displayNames = new Intl.DisplayNames(locale, {\n style: 'long',\n type: 'dateTimeField'\n }) as Intl.DateTimeDisplayNames;\n const displayNamesShort = new Intl.DisplayNames(locale, {\n style: 'short',\n type: 'dateTimeField'\n }) as Intl.DateTimeDisplayNames;\n\n const weeks = getWeeksOfMonth(current, calendarType).map(weekNo => {\n return (\n <>\n <Text as={StyledWeekNumber} key={weekNo} aria-hidden='true'>\n {weekNo.toString()}\n </Text>\n <ScreenReaderOnly>\n {`${displayNames.of('weekOfYear')} ${weekNo.toString()} ${current\n .getUTCFullYear()\n .toString()}`}\n </ScreenReaderOnly>\n </>\n );\n });\n\n const weeksButtons = getWeeksOfMonth(current, calendarType).map(weekNo => {\n const dateOfISOWeek = getDateOfISOWeek(weekNo, current.getUTCFullYear());\n const lastDayOfWeek = new Date(dateOfISOWeek);\n lastDayOfWeek.setDate(dateOfISOWeek.getDate() + 6);\n return (\n <StyledPick\n key={weekNo}\n tabIndex={isWeekFocused(dateOfISOWeek) ? 0 : -1}\n disabled={disabled || mode === 'date' || isDisabled(dateOfISOWeek)}\n aria-selected={isWeekSelected(dateOfISOWeek) || undefined}\n aria-label={`${displayNames.of('weekOfYear')} ${weekNo.toString()} ${toUTCDateString(\n dateOfISOWeek,\n Intl.DateTimeFormat(locale, ariaOpts)\n )} - ${toUTCDateString(lastDayOfWeek, Intl.DateTimeFormat(locale, ariaOpts))}`}\n aria-current={isWeekFocused(dateOfISOWeek) ? 'date' : undefined}\n onMouseDown={() => {\n setFocusedDay(dateOfISOWeek);\n onFocus?.(dateOfISOWeek);\n onSelect?.(dateOfISOWeek);\n }}\n >\n {`${cap(displayNames.of('weekOfYear'))} `}\n {weekNo.toString()}\n </StyledPick>\n );\n });\n\n const weekLabel =\n mode === 'date' ? (\n <>\n <Text\n as={StyledWeekLabel}\n forwardedAs='abbr'\n title={cap(displayNames.of('weekOfYear'))}\n aria-hidden='true'\n >\n {cap(displayNamesShort.of('weekOfYear'))}\n </Text>\n <ScreenReaderOnly>{displayNames.of('weekOfYear')}</ScreenReaderOnly>\n </>\n ) : (\n <Text as={StyledWeekLabel}>{cap(displayNames.of('weekOfYear'))}</Text>\n );\n\n const headerLabels = names.map(([name, abbr]) => (\n <th role='columnheader' key={name}>\n <Text as={StyledColumnLabel} forwardedAs='abbr' key={name} title={name} aria-hidden='true'>\n {abbr}\n </Text>\n <ScreenReaderOnly>{name}</ScreenReaderOnly>\n </th>\n ));\n\n const splitToWeeks = (resultArray: JSX.Element[][], item: JSX.Element, index: number) => {\n const chunkIndex = Math.floor(index / 7);\n\n if (!resultArray[chunkIndex]) {\n resultArray[chunkIndex] = [] as JSX.Element[];\n }\n\n resultArray[chunkIndex].push(item);\n return resultArray;\n };\n\n const cells = days.reduce(splitToWeeks, []).map((week, index) => {\n const rowHeader = mode === 'week' ? weeksButtons[index] : weeks[index];\n return (\n // eslint-disable-next-line react/no-array-index-key\n <tr key={`week-${index}`}>\n {showWeekLabel && <th scope='row'>{rowHeader}</th>}\n {week.map((day, dayIndex) => {\n // eslint-disable-next-line react/no-array-index-key\n return <td key={`day-${dayIndex}`}>{day}</td>;\n })}\n </tr>\n );\n });\n\n const weeksCells = weeksButtons.map((week, index) => {\n return (\n // eslint-disable-next-line react/no-array-index-key\n <tr key={`week-${index}`}>\n <td>{week}</td>\n </tr>\n );\n });\n\n const weeksGrid = (\n <StyledWeekGrid role='grid' onKeyDown={onKeyDown} ref={containerRef}>\n <thead>\n <tr>\n <th>{weekLabel}</th>\n </tr>\n </thead>\n <tbody>{weeksCells}</tbody>\n </StyledWeekGrid>\n );\n\n return (\n <>\n {mode === 'week' && weeksGrid}\n <StyledCalendar\n ref={mode === 'date' ? containerRef : undefined}\n aria-label={current.toLocaleString(locale, {\n month: 'long',\n year: 'numeric',\n timeZone: 'UTC'\n })}\n onKeyDown={onKeyDown}\n aria-hidden={mode === 'week' ? true : undefined}\n role='grid'\n >\n <thead>\n <tr>\n {showWeekLabel && <th>{weekLabel}</th>}\n {headerLabels}\n </tr>\n </thead>\n <tbody>{cells}</tbody>\n </StyledCalendar>\n <ScreenReaderOnly aria-live='polite' role='alert'>\n {t('calendar_assist')}\n </ScreenReaderOnly>\n </>\n );\n }\n);\n\nexport default Calendar;\n"]}
|
|
@@ -64,7 +64,7 @@ const Weeks = forwardRef((props, ref) => {
|
|
|
64
64
|
const min = props.min ? parseToDate(props.min) : -Infinity;
|
|
65
65
|
const max = props.max ? parseToDate(props.max) : Infinity;
|
|
66
66
|
const isDisabled = (day) => {
|
|
67
|
-
return disabled || min > day.getTime() || day.getTime() > max;
|
|
67
|
+
return disabled || Number(min) > day.getTime() || day.getTime() > Number(max);
|
|
68
68
|
};
|
|
69
69
|
const isChecked = (day) => {
|
|
70
70
|
return (selected &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Weeks.js","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/Weeks.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,eAAe,EAEf,QAAQ,EACR,UAAU,EAGX,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIhD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAiC1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;uBACpB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO;;CAEvD,CAAC;AAEF,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAElD,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,EAAE;IAClD,MAAM,EACJ,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,EACxC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BACxC,GAAG,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,MAAM,CAAC,QAAQ,EAAE,IAAI,OAAO;iBACzE,cAAc,EAAE;iBAChB,QAAQ,EAAE,EAAE,EACf,OAAO,EAAE,GAAG,EAAE;gBACZ,QAAQ,EAAE,CAAC,aAAa,CAAC,CAAC;YAC5B,CAAC,aAEA,IAAI,KAAK,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,GAAG,EAC3D,MAAM,CAAC,QAAQ,EAAE,KAvBb,MAAM,CAwBM,CACpB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,KAAK,GACT,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CACjB,KAAC,IAAI,IAAC,EAAE,EAAE,iBAAiB,EAAE,WAAW,EAAC,MAAM,EAAC,KAAK,EAAE,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,YACtF,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,GACnC,CACR,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,EAAE,EAAE,iBAAiB,YAAG,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,GAAQ,CACzE,CAAC;IAEJ,OAAO,CACL,MAAC,IAAI,IACH,EAAE,EAAE,iBAAiB,EACrB,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EAClC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,SAAS,aAEnB,KAAK,EACL,KAAK,IACD,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import {\n FC,\n useLayoutEffect,\n KeyboardEvent,\n useState,\n forwardRef,\n PropsWithoutRef,\n Ref\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Flex from '../../Flex';\nimport { defaultThemeProp } from '../../../theme';\nimport Text from '../../Text';\nimport { cap } from '../../../utils';\nimport { getDateOfISOWeek, getWeek, parseToDate, toUTCDateString } from '../Input/utils';\nimport { useConfiguration, useConsolidatedRef, useFocusWithin } from '../../../hooks';\nimport { CALENDAR_TYPES } from '../Input/local';\nimport { ForwardProps } from '../../../types';\nimport { FormControlProps } from '../../FormControl';\n\nimport { StyledColumnLabel, StyledPick } from './Calendar.styles';\nimport { getWeeksOfMonth } from './utils';\n\nexport interface WeeksProps {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /**\n * Defines default week that will be selected when the Date Picker is opened.\n */\n selected?: Date;\n /**\n * Defines default week that will be focused initially when the Date Picker is opened.\n * @default new Date()\n */\n current?: Date;\n /** Callback fired when user focuses new week. */\n onFocus?: (date: Date) => void;\n /** Callback fired when new week is selected. */\n onSelect?: (date: Date) => void;\n /** Sets the type of calendar to be used. This will be determined by locale if no value is provided. */\n calendarType?: string;\n /** Defines minimum available value that can be selected by the user. */\n min?: string | number | Date;\n /** Defines maximum available value that can be selected by the user. */\n max?: string | number | Date;\n /** Set the calendar to disabled state, ie. non-interactive. */\n disabled?: boolean;\n /** Should text be in long or short format (ie. only number). */\n size?: 'short' | 'long';\n}\n\nexport const StyledWeekNumbers = styled.div`\n margin-inline-end: ${props => props.theme.base.spacing};\n color: rgba(0, 0, 0, 0.75);\n`;\n\nStyledWeekNumbers.defaultProps = defaultThemeProp;\n\nconst StyledWeekNumber = styled(StyledPick)(props => {\n const {\n theme: {\n base: { 'border-radius': borderRadius }\n }\n } = props;\n\n return css`\n &:disabled {\n &:nth-child(2) {\n border-radius: calc(0.5 * ${borderRadius}) calc(0.5 * ${borderRadius}) 0 0;\n }\n &:last-child {\n border-radius: 0 0 calc(0.5 * ${borderRadius}) calc(0.5 * ${borderRadius});\n }\n }\n `;\n});\n\nStyledWeekNumber.defaultProps = defaultThemeProp;\n\nconst Weeks: FC<WeeksProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<WeeksProps>, ref: Ref<HTMLButtonElement>) => {\n const {\n selected,\n current = selected ? new Date(selected.getTime()) : new Date(),\n calendarType = CALENDAR_TYPES.ISO_8601,\n onSelect,\n onFocus,\n disabled = false,\n size = 'short'\n } = props;\n\n const { locale } = useConfiguration();\n\n const [focusedWeek, setFocusedWeek] = useState(current);\n useLayoutEffect(() => {\n setFocusedWeek(current);\n }, [current.getUTCFullYear(), current.getUTCMonth()]);\n\n let newFocused: Date;\n const onKeyDown = (ev: KeyboardEvent<HTMLElement>) => {\n if (['ArrowUp', 'ArrowDown', 'Enter'].includes(ev.key)) ev.preventDefault();\n switch (ev.key) {\n case 'ArrowUp':\n newFocused = new Date(focusedWeek);\n newFocused.setUTCDate(focusedWeek.getUTCDate() - 7);\n setFocusedWeek(newFocused);\n onFocus?.(newFocused);\n break;\n case 'ArrowDown':\n newFocused = new Date(focusedWeek);\n newFocused.setUTCDate(focusedWeek.getUTCDate() + 7);\n setFocusedWeek(newFocused);\n onFocus?.(newFocused);\n break;\n case 'Enter':\n onSelect?.(focusedWeek);\n break;\n default:\n }\n };\n\n const containerRef = useConsolidatedRef(ref);\n const hasFocus = useFocusWithin([containerRef]);\n\n const min = props.min ? parseToDate(props.min) : -Infinity;\n const max = props.max ? parseToDate(props.max) : Infinity;\n const isDisabled = (day: Date) => {\n return disabled || min > day.getTime() || day.getTime() > max;\n };\n\n const isChecked = (day: Date) => {\n return (\n selected &&\n toUTCDateString(day) ===\n toUTCDateString(getDateOfISOWeek(getWeek(selected, calendarType), selected.getFullYear()))\n );\n };\n\n const isFocused = (day: Date) => {\n return (\n toUTCDateString(day) ===\n toUTCDateString(\n getDateOfISOWeek(getWeek(focusedWeek, calendarType), focusedWeek.getFullYear())\n )\n );\n };\n\n const displayNames = new Intl.DisplayNames(locale, {\n style: 'long',\n type: 'dateTimeField'\n }) as Intl.DateTimeDisplayNames;\n const displayNamesShort = new Intl.DisplayNames(locale, {\n style: 'short',\n type: 'dateTimeField'\n }) as Intl.DateTimeDisplayNames;\n\n const weeks = getWeeksOfMonth(current, calendarType).map(weekNo => {\n const dateOfISOWeek = getDateOfISOWeek(weekNo, current.getUTCFullYear());\n return (\n <StyledWeekNumber\n key={weekNo}\n variant='simple'\n icon={false}\n type='button'\n loading={false}\n ref={\n isFocused(dateOfISOWeek)\n ? (focusedRef: HTMLButtonElement) => {\n if (hasFocus) focusedRef?.focus();\n }\n : undefined\n }\n tabIndex={isFocused(dateOfISOWeek) ? 0 : -1}\n disabled={isDisabled(dateOfISOWeek)}\n aria-selected={isChecked(dateOfISOWeek) || undefined}\n aria-label={`${displayNames.of('weekOfYear')} ${weekNo.toString()} ${current\n .getUTCFullYear()\n .toString()}`}\n onClick={() => {\n onSelect?.(dateOfISOWeek);\n }}\n >\n {size === 'long' && `${cap(displayNames.of('weekOfYear'))} `}\n {weekNo.toString()}\n </StyledWeekNumber>\n );\n });\n\n const label =\n size === 'short' ? (\n <Text as={StyledColumnLabel} forwardedAs='abbr' title={cap(displayNames.of('weekOfYear'))}>\n {cap(displayNamesShort.of('weekOfYear'))}\n </Text>\n ) : (\n <Text as={StyledColumnLabel}>{cap(displayNames.of('weekOfYear'))}</Text>\n );\n\n return (\n <Flex\n as={StyledWeekNumbers}\n container={{ direction: 'column' }}\n ref={containerRef}\n onKeyDown={onKeyDown}\n >\n {label}\n {weeks}\n </Flex>\n );\n }\n);\n\nexport default Weeks;\n"]}
|
|
1
|
+
{"version":3,"file":"Weeks.js","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/Weeks.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,eAAe,EAEf,QAAQ,EACR,UAAU,EAGX,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,IAAI,MAA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AK,OAAO,CAAC,CAAC,CAAC,CACjB,KAAC,IAAI,IAAC,EAAE,EAAE,iBAAiB,EAAE,WAAW,EAAC,MAAM,EAAC,KAAK,EAAE,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,YACtF,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,GACnC,CACR,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,EAAE,EAAE,iBAAiB,YAAG,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,GAAQ,CACzE,CAAC;IAEJ,OAAO,CACL,MAAC,IAAI,IACH,EAAE,EAAE,iBAAiB,EACrB,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EAClC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,SAAS,aAEnB,KAAK,EACL,KAAK,IACD,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import {\n FC,\n useLayoutEffect,\n KeyboardEvent,\n useState,\n forwardRef,\n PropsWithoutRef,\n Ref\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Flex from '../../Flex';\nimport { defaultThemeProp } from '../../../theme';\nimport Text from '../../Text';\nimport { cap } from '../../../utils';\nimport { getDateOfISOWeek, getWeek, parseToDate, toUTCDateString } from '../Input/utils';\nimport { useConfiguration, useConsolidatedRef, useFocusWithin } from '../../../hooks';\nimport { CALENDAR_TYPES } from '../Input/local';\nimport { ForwardProps } from '../../../types';\nimport { FormControlProps } from '../../FormControl';\n\nimport { StyledColumnLabel, StyledPick } from './Calendar.styles';\nimport { getWeeksOfMonth } from './utils';\n\nexport interface WeeksProps {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /**\n * Defines default week that will be selected when the Date Picker is opened.\n */\n selected?: Date;\n /**\n * Defines default week that will be focused initially when the Date Picker is opened.\n * @default new Date()\n */\n current?: Date;\n /** Callback fired when user focuses new week. */\n onFocus?: (date: Date) => void;\n /** Callback fired when new week is selected. */\n onSelect?: (date: Date) => void;\n /** Sets the type of calendar to be used. This will be determined by locale if no value is provided. */\n calendarType?: string;\n /** Defines minimum available value that can be selected by the user. */\n min?: string | number | Date;\n /** Defines maximum available value that can be selected by the user. */\n max?: string | number | Date;\n /** Set the calendar to disabled state, ie. non-interactive. */\n disabled?: boolean;\n /** Should text be in long or short format (ie. only number). */\n size?: 'short' | 'long';\n}\n\nexport const StyledWeekNumbers = styled.div`\n margin-inline-end: ${props => props.theme.base.spacing};\n color: rgba(0, 0, 0, 0.75);\n`;\n\nStyledWeekNumbers.defaultProps = defaultThemeProp;\n\nconst StyledWeekNumber = styled(StyledPick)(props => {\n const {\n theme: {\n base: { 'border-radius': borderRadius }\n }\n } = props;\n\n return css`\n &:disabled {\n &:nth-child(2) {\n border-radius: calc(0.5 * ${borderRadius}) calc(0.5 * ${borderRadius}) 0 0;\n }\n &:last-child {\n border-radius: 0 0 calc(0.5 * ${borderRadius}) calc(0.5 * ${borderRadius});\n }\n }\n `;\n});\n\nStyledWeekNumber.defaultProps = defaultThemeProp;\n\nconst Weeks: FC<WeeksProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<WeeksProps>, ref: Ref<HTMLButtonElement>) => {\n const {\n selected,\n current = selected ? new Date(selected.getTime()) : new Date(),\n calendarType = CALENDAR_TYPES.ISO_8601,\n onSelect,\n onFocus,\n disabled = false,\n size = 'short'\n } = props;\n\n const { locale } = useConfiguration();\n\n const [focusedWeek, setFocusedWeek] = useState(current);\n useLayoutEffect(() => {\n setFocusedWeek(current);\n }, [current.getUTCFullYear(), current.getUTCMonth()]);\n\n let newFocused: Date;\n const onKeyDown = (ev: KeyboardEvent<HTMLElement>) => {\n if (['ArrowUp', 'ArrowDown', 'Enter'].includes(ev.key)) ev.preventDefault();\n switch (ev.key) {\n case 'ArrowUp':\n newFocused = new Date(focusedWeek);\n newFocused.setUTCDate(focusedWeek.getUTCDate() - 7);\n setFocusedWeek(newFocused);\n onFocus?.(newFocused);\n break;\n case 'ArrowDown':\n newFocused = new Date(focusedWeek);\n newFocused.setUTCDate(focusedWeek.getUTCDate() + 7);\n setFocusedWeek(newFocused);\n onFocus?.(newFocused);\n break;\n case 'Enter':\n onSelect?.(focusedWeek);\n break;\n default:\n }\n };\n\n const containerRef = useConsolidatedRef(ref);\n const hasFocus = useFocusWithin([containerRef]);\n\n const min = props.min ? parseToDate(props.min) : -Infinity;\n const max = props.max ? parseToDate(props.max) : Infinity;\n const isDisabled = (day: Date) => {\n return disabled || Number(min) > day.getTime() || day.getTime() > Number(max);\n };\n\n const isChecked = (day: Date) => {\n return (\n selected &&\n toUTCDateString(day) ===\n toUTCDateString(getDateOfISOWeek(getWeek(selected, calendarType), selected.getFullYear()))\n );\n };\n\n const isFocused = (day: Date) => {\n return (\n toUTCDateString(day) ===\n toUTCDateString(\n getDateOfISOWeek(getWeek(focusedWeek, calendarType), focusedWeek.getFullYear())\n )\n );\n };\n\n const displayNames = new Intl.DisplayNames(locale, {\n style: 'long',\n type: 'dateTimeField'\n }) as Intl.DateTimeDisplayNames;\n const displayNamesShort = new Intl.DisplayNames(locale, {\n style: 'short',\n type: 'dateTimeField'\n }) as Intl.DateTimeDisplayNames;\n\n const weeks = getWeeksOfMonth(current, calendarType).map(weekNo => {\n const dateOfISOWeek = getDateOfISOWeek(weekNo, current.getUTCFullYear());\n return (\n <StyledWeekNumber\n key={weekNo}\n variant='simple'\n icon={false}\n type='button'\n loading={false}\n ref={\n isFocused(dateOfISOWeek)\n ? (focusedRef: HTMLButtonElement) => {\n if (hasFocus) focusedRef?.focus();\n }\n : undefined\n }\n tabIndex={isFocused(dateOfISOWeek) ? 0 : -1}\n disabled={isDisabled(dateOfISOWeek)}\n aria-selected={isChecked(dateOfISOWeek) || undefined}\n aria-label={`${displayNames.of('weekOfYear')} ${weekNo.toString()} ${current\n .getUTCFullYear()\n .toString()}`}\n onClick={() => {\n onSelect?.(dateOfISOWeek);\n }}\n >\n {size === 'long' && `${cap(displayNames.of('weekOfYear'))} `}\n {weekNo.toString()}\n </StyledWeekNumber>\n );\n });\n\n const label =\n size === 'short' ? (\n <Text as={StyledColumnLabel} forwardedAs='abbr' title={cap(displayNames.of('weekOfYear'))}>\n {cap(displayNamesShort.of('weekOfYear'))}\n </Text>\n ) : (\n <Text as={StyledColumnLabel}>{cap(displayNames.of('weekOfYear'))}</Text>\n );\n\n return (\n <Flex\n as={StyledWeekNumbers}\n container={{ direction: 'column' }}\n ref={containerRef}\n onKeyDown={onKeyDown}\n >\n {label}\n {weeks}\n </Flex>\n );\n }\n);\n\nexport default Weeks;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/DateTime/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlE,OAAO,EAAmB,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,WAAW,EAMZ,MAAM,eAAe,CAAC;AAsBvB,UAAU,qBAAqB;IAC7B,CAAC,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,eAAe,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,IAAI,EACX,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/DateTime/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlE,OAAO,EAAmB,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,WAAW,EAMZ,MAAM,eAAe,CAAC;AAsBvB,UAAU,qBAAqB;IAC7B,CAAC,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,eAAe,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,IAAI,EACX,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,qBAAqB,UA4K7E;AAOD,UAAU,qBAAqB;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CACjC;AAED,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,EAAE,MAAM,EAAE,gBAAgB,EAAE,EAAE,qBAAqB,UAiCpD"}
|
|
@@ -60,15 +60,74 @@ export function formatDateTime(value, { t, locale, format, variant, clockFormat,
|
|
|
60
60
|
numeric: { style: 'short', numeric: 'auto' }
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
|
-
const getFormattedDate = (date, dateVariant) => {
|
|
63
|
+
const getFormattedDate = (date, dateVariant, overrideTimeZone) => {
|
|
64
64
|
return new Intl.DateTimeFormat(locale, {
|
|
65
65
|
...formatMapping[dateVariant][format],
|
|
66
|
-
timeZone
|
|
66
|
+
timeZone: overrideTimeZone ?? timeZone
|
|
67
67
|
}).format(date);
|
|
68
68
|
};
|
|
69
69
|
const relativeTimeFormatter = (relativeValue, unit) => {
|
|
70
70
|
return new Intl.RelativeTimeFormat(locale, formatMapping.relative[format]).format(relativeValue, unit);
|
|
71
71
|
};
|
|
72
|
+
const getUnitsElapsed = (date, unit) => {
|
|
73
|
+
let amount;
|
|
74
|
+
const now = new Date();
|
|
75
|
+
switch (unit) {
|
|
76
|
+
case 'year':
|
|
77
|
+
amount = date.getUTCFullYear() - now.getUTCFullYear();
|
|
78
|
+
break;
|
|
79
|
+
case 'month':
|
|
80
|
+
if (date.getUTCFullYear() === now.getUTCFullYear()) {
|
|
81
|
+
amount = date.getUTCMonth() - now.getUTCMonth();
|
|
82
|
+
}
|
|
83
|
+
else if (date < now) {
|
|
84
|
+
amount = (11 - date.getUTCMonth() + now.getUTCMonth() + 1) * -1;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
amount = 11 - now.getUTCMonth() + date.getUTCMonth() + 1;
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
case 'day':
|
|
91
|
+
if (date.getUTCMonth() === now.getUTCMonth()) {
|
|
92
|
+
amount = date.getUTCDate() - now.getUTCDate();
|
|
93
|
+
}
|
|
94
|
+
else if (date < now) {
|
|
95
|
+
const maximalDayOfMonth = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + 1, 0)).getUTCDate();
|
|
96
|
+
amount = (maximalDayOfMonth - date.getUTCDate() + now.getUTCDate()) * -1;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
const maximalDayOfMonth = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 0)).getUTCDate();
|
|
100
|
+
amount = maximalDayOfMonth - now.getUTCDate() + date.getUTCDate() + 1;
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
case 'hour':
|
|
104
|
+
if (date.getUTCDate() === now.getUTCDate()) {
|
|
105
|
+
amount = date.getUTCHours() - now.getUTCHours();
|
|
106
|
+
}
|
|
107
|
+
else if (date < now) {
|
|
108
|
+
amount = (23 - date.getUTCHours() + now.getUTCHours() + 1) * -1;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
amount = 23 - now.getUTCHours() + date.getUTCHours() + 1;
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
case 'minute':
|
|
115
|
+
if (date.getUTCHours() === now.getUTCHours()) {
|
|
116
|
+
amount = date.getUTCMinutes() - now.getUTCMinutes();
|
|
117
|
+
}
|
|
118
|
+
else if (date < now) {
|
|
119
|
+
amount = (59 - date.getUTCMinutes() + now.getUTCMinutes() + 1) * -1;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
amount = 59 - now.getUTCMinutes() + date.getUTCMinutes() + 1;
|
|
123
|
+
}
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
amount = 0;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
return amount;
|
|
130
|
+
};
|
|
72
131
|
const getRelativeTime = (date) => {
|
|
73
132
|
let elapsed = date.getTime() - Date.now();
|
|
74
133
|
// Deliberately reduce precision to 1 minute
|
|
@@ -76,20 +135,23 @@ export function formatDateTime(value, { t, locale, format, variant, clockFormat,
|
|
|
76
135
|
elapsed = 0;
|
|
77
136
|
const unit = (Object.keys(unitsInMs).find(u => Math.abs(elapsed) >= unitsInMs[u]) ||
|
|
78
137
|
'second');
|
|
79
|
-
|
|
138
|
+
const amount = getUnitsElapsed(date, unit);
|
|
139
|
+
return relativeTimeFormatter(amount, unit);
|
|
80
140
|
};
|
|
81
141
|
const getFormattedWeek = (date) => {
|
|
82
142
|
const displayNames = new Intl.DisplayNames(locale, {
|
|
83
143
|
style: 'long',
|
|
84
144
|
type: 'dateTimeField'
|
|
85
145
|
});
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
|
|
146
|
+
const adjustedUTCDate = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
|
|
147
|
+
const startDate = getFormattedDate(getStartOfWeek(adjustedUTCDate), 'week', 'UTC');
|
|
148
|
+
const endDate = getFormattedDate(getEndOfWeek(adjustedUTCDate), 'week', 'UTC');
|
|
149
|
+
return `${cap(displayNames.of('weekOfYear'))} ${getWeek(adjustedUTCDate)}, ${getWeekYear(adjustedUTCDate)} (${startDate} - ${endDate})`;
|
|
89
150
|
};
|
|
90
151
|
const getFormattedQuarterYear = (date) => {
|
|
91
152
|
const formattedYear = getFormattedDate(date, 'year');
|
|
92
|
-
const
|
|
153
|
+
const adjustedUTCDate = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
|
|
154
|
+
const quarterNumber = getQuarter(adjustedUTCDate);
|
|
93
155
|
return `${t(`date_quarter_q${quarterNumber}`, [formattedYear])}`;
|
|
94
156
|
};
|
|
95
157
|
switch (variant) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/DateTime/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,OAAO,EAEL,YAAY,EACZ,UAAU,EACV,cAAc,EACd,OAAO,EACP,WAAW,EACZ,MAAM,eAAe,CAAC;AAEvB,MAAM,SAAS,GAAG;IAChB,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,GAAG;IAC/B,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,GAAG,CAAC,GAAG,EAAE;IACvC,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IACxB,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IACpB,MAAM,EAAE,EAAE,GAAG,IAAI;IACjB,MAAM,EAAE,IAAI;CACJ,CAAC;AAsBX,MAAM,UAAU,cAAc,CAC5B,KAAW,EACX,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAyB;IAE5E,MAAM,SAAS,GAAc;QAC3B,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;QACjB,MAAM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MAAM,aAAa,GAAG;QACpB,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC,EAAE;QACnD,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,QAAQ,CAAC,EAAE;QACjE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,QAAQ,CAAC,GAAG,UAAU,CAAC,EAAE;QACtE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,UAAU,CAAC,EAAE;KACzE,CAAC;IAEF,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,gBAAgB,IAAI,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACpF,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,EAAE;YAC9B,MAAM,CAAC,IAAI,CACT,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;gBAC5B,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI;gBAC3B,WAAW,EAAE,QAAQ;aACtB,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAClC,CAAC;SACH;KACF;IACD,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AACtC,CAAC","sourcesContent":["import { TranslationFunction, TranslationPack } from '../../i18n';\nimport { cap } from '../../utils';\n\nimport { AbsoluteVariant, DateTimeFormat, DateTimeVariant } from './DateTime.types';\nimport {\n ClockFormat,\n getEndOfWeek,\n getQuarter,\n getStartOfWeek,\n getWeek,\n getWeekYear\n} from './Input/utils';\n\nconst unitsInMs = {\n year: 24 * 60 * 60 * 1000 * 365,\n month: (24 * 60 * 60 * 1000 * 365) / 12,\n day: 24 * 60 * 60 * 1000,\n hour: 60 * 60 * 1000,\n minute: 60 * 1000,\n second: 1000\n} as const;\n\ntype TimeUnit = keyof typeof unitsInMs;\n\ninterface TimeShort {\n hour: 'numeric';\n minute: 'numeric';\n hour12: boolean | undefined;\n}\ninterface TimeLong extends TimeShort {\n second: 'numeric';\n}\n\ninterface DateTimeFormatOptions {\n t: TranslationFunction<TranslationPack>;\n locale: string;\n format: DateTimeFormat;\n variant: DateTimeVariant;\n timeZone?: string;\n clockFormat?: ClockFormat;\n}\n\nexport function formatDateTime(\n value: Date,\n { t, locale, format, variant, clockFormat, timeZone }: DateTimeFormatOptions\n) {\n const timeShort: TimeShort = {\n hour: 'numeric',\n minute: 'numeric',\n hour12: clockFormat ? clockFormat === 12 : undefined\n };\n\n const timeLong: TimeLong = {\n ...timeShort,\n second: 'numeric'\n };\n\n const formatMapping = {\n date: {\n short: { year: 'numeric', month: 'short', day: 'numeric' } as const,\n long: { year: 'numeric', month: 'long', day: 'numeric' } as const,\n numeric: { year: 'numeric', month: 'numeric', day: 'numeric' } as const\n },\n datetime: {\n short: { year: 'numeric', month: 'short', day: 'numeric', ...timeShort } as const,\n long: { year: 'numeric', month: 'long', day: 'numeric', ...timeLong } as const,\n numeric: { year: 'numeric', month: 'numeric', day: 'numeric', ...timeShort } as const\n },\n time: {\n short: timeShort,\n long: timeLong,\n numeric: timeShort\n },\n month: {\n short: { month: 'short' } as const,\n long: { month: 'long' } as const,\n numeric: { month: 'numeric' } as const\n },\n year: {\n short: { year: 'numeric' } as const,\n long: { year: 'numeric' } as const,\n numeric: { year: '2-digit' } as const\n },\n monthyear: {\n short: { year: 'numeric', month: 'short' } as const,\n long: { year: 'numeric', month: 'long' } as const,\n numeric: { year: 'numeric', month: 'numeric' } as const\n },\n week: {\n short: { month: 'short', day: 'numeric' } as const,\n long: { month: 'long', day: 'numeric' } as const,\n numeric: { month: 'numeric', day: 'numeric' } as const\n },\n relative: {\n short: { style: 'long', numeric: 'auto' } as const,\n long: { style: 'long', numeric: 'auto' } as const,\n numeric: { style: 'short', numeric: 'auto' } as const\n }\n };\n\n const getFormattedDate = (date: Date, dateVariant: Exclude<AbsoluteVariant, 'quarteryear'>) => {\n return new Intl.DateTimeFormat(locale, {\n ...formatMapping[dateVariant][format],\n timeZone\n }).format(date);\n };\n\n const relativeTimeFormatter = (relativeValue: number, unit: TimeUnit) => {\n return new Intl.RelativeTimeFormat(locale, formatMapping.relative[format]).format(\n relativeValue,\n unit\n );\n };\n\n const getRelativeTime = (date: Date) => {\n let elapsed = date.getTime() - Date.now();\n // Deliberately reduce precision to 1 minute\n if (Math.abs(elapsed) < 60000) elapsed = 0;\n const unit = (Object.keys(unitsInMs).find(u => Math.abs(elapsed) >= unitsInMs[u as TimeUnit]) ||\n 'second') as TimeUnit;\n return relativeTimeFormatter(Math.round(elapsed / unitsInMs[unit]), unit);\n };\n\n const getFormattedWeek = (date: Date) => {\n const displayNames = new Intl.DisplayNames(locale, {\n style: 'long',\n type: 'dateTimeField'\n }) as Intl.DateTimeDisplayNames;\n const startDate = getFormattedDate(getStartOfWeek(date), 'week');\n const endDate = getFormattedDate(getEndOfWeek(date), 'week');\n return `${cap(displayNames.of('weekOfYear'))} ${getWeek(date)}, ${getWeekYear(\n date\n )} (${startDate} - ${endDate})`;\n };\n\n const getFormattedQuarterYear = (date: Date) => {\n const formattedYear = getFormattedDate(date, 'year');\n const quarterNumber = getQuarter(date);\n return `${t(`date_quarter_q${quarterNumber}`, [formattedYear])}`;\n };\n\n switch (variant) {\n case 'relative':\n return getRelativeTime(value);\n case 'week':\n return getFormattedWeek(value);\n case 'quarteryear':\n return getFormattedQuarterYear(value);\n default:\n return getFormattedDate(value, variant);\n }\n}\n\nconst dayInMs = 24 * 60 * 60 * 1000;\nconst hourInMs = 60 * 60 * 1000;\nconst minuteInMs = 60 * 1000;\nconst secondInMs = 1000;\n\ninterface DurationFormatOptions {\n locale: string;\n significantUnits: 4 | 3 | 2 | 1;\n}\n\nexport function formatDuration(\n valueInMs: number,\n { locale, significantUnits }: DurationFormatOptions\n) {\n const numberFormatterSeconds = new Intl.NumberFormat(locale, {\n style: 'unit',\n unit: 'second',\n unitDisplay: 'narrow'\n });\n const sign = valueInMs < 0 ? '-' : '';\n const absMs = Math.abs(valueInMs);\n if (absMs < secondInMs) {\n return numberFormatterSeconds.format(0);\n }\n\n const durationParts = [\n { unit: 'day', value: Math.floor(absMs / dayInMs) },\n { unit: 'hour', value: Math.floor((absMs % dayInMs) / hourInMs) },\n { unit: 'minute', value: Math.floor((absMs % hourInMs) / minuteInMs) },\n { unit: 'second', value: Math.floor((absMs % minuteInMs) / secondInMs) }\n ];\n\n const result = [];\n for (let i = 0; result.length < significantUnits && i < durationParts.length; i += 1) {\n if (durationParts[i].value > 0) {\n result.push(\n new Intl.NumberFormat(locale, {\n style: 'unit',\n unit: durationParts[i].unit,\n unitDisplay: 'narrow'\n }).format(durationParts[i].value)\n );\n }\n }\n return `${sign}${result.join(' ')}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/DateTime/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,OAAO,EAEL,YAAY,EACZ,UAAU,EACV,cAAc,EACd,OAAO,EACP,WAAW,EACZ,MAAM,eAAe,CAAC;AAEvB,MAAM,SAAS,GAAG;IAChB,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,GAAG;IAC/B,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,GAAG,CAAC,GAAG,EAAE;IACvC,GAAG,EAAE,EAAE,GAAG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,EAAE;QACtE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,UAAU,CAAC,EAAE;KACzE,CAAC;IAEF,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,gBAAgB,IAAI,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACpF,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,EAAE;YAC9B,MAAM,CAAC,IAAI,CACT,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;gBAC5B,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI;gBAC3B,WAAW,EAAE,QAAQ;aACtB,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAClC,CAAC;SACH;KACF;IACD,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AACtC,CAAC","sourcesContent":["import { TranslationFunction, TranslationPack } from '../../i18n';\nimport { cap } from '../../utils';\n\nimport { AbsoluteVariant, DateTimeFormat, DateTimeVariant } from './DateTime.types';\nimport {\n ClockFormat,\n getEndOfWeek,\n getQuarter,\n getStartOfWeek,\n getWeek,\n getWeekYear\n} from './Input/utils';\n\nconst unitsInMs = {\n year: 24 * 60 * 60 * 1000 * 365,\n month: (24 * 60 * 60 * 1000 * 365) / 12,\n day: 24 * 60 * 60 * 1000,\n hour: 60 * 60 * 1000,\n minute: 60 * 1000,\n second: 1000\n} as const;\n\ntype TimeUnit = keyof typeof unitsInMs;\n\ninterface TimeShort {\n hour: 'numeric';\n minute: 'numeric';\n hour12: boolean | undefined;\n}\ninterface TimeLong extends TimeShort {\n second: 'numeric';\n}\n\ninterface DateTimeFormatOptions {\n t: TranslationFunction<TranslationPack>;\n locale: string;\n format: DateTimeFormat;\n variant: DateTimeVariant;\n timeZone?: string;\n clockFormat?: ClockFormat;\n}\n\nexport function formatDateTime(\n value: Date,\n { t, locale, format, variant, clockFormat, timeZone }: DateTimeFormatOptions\n) {\n const timeShort: TimeShort = {\n hour: 'numeric',\n minute: 'numeric',\n hour12: clockFormat ? clockFormat === 12 : undefined\n };\n\n const timeLong: TimeLong = {\n ...timeShort,\n second: 'numeric'\n };\n\n const formatMapping = {\n date: {\n short: { year: 'numeric', month: 'short', day: 'numeric' } as const,\n long: { year: 'numeric', month: 'long', day: 'numeric' } as const,\n numeric: { year: 'numeric', month: 'numeric', day: 'numeric' } as const\n },\n datetime: {\n short: { year: 'numeric', month: 'short', day: 'numeric', ...timeShort } as const,\n long: { year: 'numeric', month: 'long', day: 'numeric', ...timeLong } as const,\n numeric: { year: 'numeric', month: 'numeric', day: 'numeric', ...timeShort } as const\n },\n time: {\n short: timeShort,\n long: timeLong,\n numeric: timeShort\n },\n month: {\n short: { month: 'short' } as const,\n long: { month: 'long' } as const,\n numeric: { month: 'numeric' } as const\n },\n year: {\n short: { year: 'numeric' } as const,\n long: { year: 'numeric' } as const,\n numeric: { year: '2-digit' } as const\n },\n monthyear: {\n short: { year: 'numeric', month: 'short' } as const,\n long: { year: 'numeric', month: 'long' } as const,\n numeric: { year: 'numeric', month: 'numeric' } as const\n },\n week: {\n short: { month: 'short', day: 'numeric' } as const,\n long: { month: 'long', day: 'numeric' } as const,\n numeric: { month: 'numeric', day: 'numeric' } as const\n },\n relative: {\n short: { style: 'long', numeric: 'auto' } as const,\n long: { style: 'long', numeric: 'auto' } as const,\n numeric: { style: 'short', numeric: 'auto' } as const\n }\n };\n\n const getFormattedDate = (\n date: Date,\n dateVariant: Exclude<AbsoluteVariant, 'quarteryear'>,\n overrideTimeZone?: string\n ) => {\n return new Intl.DateTimeFormat(locale, {\n ...formatMapping[dateVariant][format],\n timeZone: overrideTimeZone ?? timeZone\n }).format(date);\n };\n\n const relativeTimeFormatter = (relativeValue: number, unit: TimeUnit) => {\n return new Intl.RelativeTimeFormat(locale, formatMapping.relative[format]).format(\n relativeValue,\n unit\n );\n };\n\n const getUnitsElapsed = (date: Date, unit: TimeUnit): number => {\n let amount: number;\n const now = new Date();\n\n switch (unit) {\n case 'year':\n amount = date.getUTCFullYear() - now.getUTCFullYear();\n break;\n case 'month':\n if (date.getUTCFullYear() === now.getUTCFullYear()) {\n amount = date.getUTCMonth() - now.getUTCMonth();\n } else if (date < now) {\n amount = (11 - date.getUTCMonth() + now.getUTCMonth() + 1) * -1;\n } else {\n amount = 11 - now.getUTCMonth() + date.getUTCMonth() + 1;\n }\n break;\n case 'day':\n if (date.getUTCMonth() === now.getUTCMonth()) {\n amount = date.getUTCDate() - now.getUTCDate();\n } else if (date < now) {\n const maximalDayOfMonth = new Date(\n Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + 1, 0)\n ).getUTCDate();\n amount = (maximalDayOfMonth - date.getUTCDate() + now.getUTCDate()) * -1;\n } else {\n const maximalDayOfMonth = new Date(\n Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 0)\n ).getUTCDate();\n amount = maximalDayOfMonth - now.getUTCDate() + date.getUTCDate() + 1;\n }\n break;\n case 'hour':\n if (date.getUTCDate() === now.getUTCDate()) {\n amount = date.getUTCHours() - now.getUTCHours();\n } else if (date < now) {\n amount = (23 - date.getUTCHours() + now.getUTCHours() + 1) * -1;\n } else {\n amount = 23 - now.getUTCHours() + date.getUTCHours() + 1;\n }\n break;\n case 'minute':\n if (date.getUTCHours() === now.getUTCHours()) {\n amount = date.getUTCMinutes() - now.getUTCMinutes();\n } else if (date < now) {\n amount = (59 - date.getUTCMinutes() + now.getUTCMinutes() + 1) * -1;\n } else {\n amount = 59 - now.getUTCMinutes() + date.getUTCMinutes() + 1;\n }\n break;\n default:\n amount = 0;\n break;\n }\n return amount;\n };\n\n const getRelativeTime = (date: Date) => {\n let elapsed = date.getTime() - Date.now();\n // Deliberately reduce precision to 1 minute\n if (Math.abs(elapsed) < 60000) elapsed = 0;\n const unit = (Object.keys(unitsInMs).find(u => Math.abs(elapsed) >= unitsInMs[u as TimeUnit]) ||\n 'second') as TimeUnit;\n const amount = getUnitsElapsed(date, unit);\n\n return relativeTimeFormatter(amount, unit);\n };\n\n const getFormattedWeek = (date: Date) => {\n const displayNames = new Intl.DisplayNames(locale, {\n style: 'long',\n type: 'dateTimeField'\n }) as Intl.DateTimeDisplayNames;\n const adjustedUTCDate = new Date(date.getTime() - date.getTimezoneOffset() * 60000);\n const startDate = getFormattedDate(getStartOfWeek(adjustedUTCDate), 'week', 'UTC');\n const endDate = getFormattedDate(getEndOfWeek(adjustedUTCDate), 'week', 'UTC');\n return `${cap(displayNames.of('weekOfYear'))} ${getWeek(adjustedUTCDate)}, ${getWeekYear(\n adjustedUTCDate\n )} (${startDate} - ${endDate})`;\n };\n\n const getFormattedQuarterYear = (date: Date) => {\n const formattedYear = getFormattedDate(date, 'year');\n const adjustedUTCDate = new Date(date.getTime() - date.getTimezoneOffset() * 60000);\n const quarterNumber = getQuarter(adjustedUTCDate);\n return `${t(`date_quarter_q${quarterNumber}`, [formattedYear])}`;\n };\n\n switch (variant) {\n case 'relative':\n return getRelativeTime(value);\n case 'week':\n return getFormattedWeek(value);\n case 'quarteryear':\n return getFormattedQuarterYear(value);\n default:\n return getFormattedDate(value, variant);\n }\n}\n\nconst dayInMs = 24 * 60 * 60 * 1000;\nconst hourInMs = 60 * 60 * 1000;\nconst minuteInMs = 60 * 1000;\nconst secondInMs = 1000;\n\ninterface DurationFormatOptions {\n locale: string;\n significantUnits: 4 | 3 | 2 | 1;\n}\n\nexport function formatDuration(\n valueInMs: number,\n { locale, significantUnits }: DurationFormatOptions\n) {\n const numberFormatterSeconds = new Intl.NumberFormat(locale, {\n style: 'unit',\n unit: 'second',\n unitDisplay: 'narrow'\n });\n const sign = valueInMs < 0 ? '-' : '';\n const absMs = Math.abs(valueInMs);\n if (absMs < secondInMs) {\n return numberFormatterSeconds.format(0);\n }\n\n const durationParts = [\n { unit: 'day', value: Math.floor(absMs / dayInMs) },\n { unit: 'hour', value: Math.floor((absMs % dayInMs) / hourInMs) },\n { unit: 'minute', value: Math.floor((absMs % hourInMs) / minuteInMs) },\n { unit: 'second', value: Math.floor((absMs % minuteInMs) / secondInMs) }\n ];\n\n const result = [];\n for (let i = 0; result.length < significantUnits && i < durationParts.length; i += 1) {\n if (durationParts[i].value > 0) {\n result.push(\n new Intl.NumberFormat(locale, {\n style: 'unit',\n unit: durationParts[i].unit,\n unitDisplay: 'narrow'\n }).format(durationParts[i].value)\n );\n }\n }\n return `${sign}${result.join(' ')}`;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAKxE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,QAAA,MAAM,MAAM,EAAE,EAAE,CAAC,WAAW,GAAG,cAAc,CAAC,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAKxE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,QAAA,MAAM,MAAM,EAAE,EAAE,CAAC,WAAW,GAAG,cAAc,CAAC,cAAc,CAAC,CAqC5D,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -2,9 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { useConsolidatedRef } from '../../hooks';
|
|
4
4
|
import { StyledDialog } from './Dialog.styles';
|
|
5
|
-
const Dialog = forwardRef(({ target, labelledbyId, portal, strategy, placement, children, progress, ...restProps }, ref) => {
|
|
5
|
+
const Dialog = forwardRef(({ arrow = true, target, labelledbyId, ariaLabel, portal, strategy, placement, children, progress, ...restProps }, ref) => {
|
|
6
6
|
const dialogRef = useConsolidatedRef(ref);
|
|
7
|
-
return (_jsx(StyledDialog, { ...restProps, role: 'dialog', "aria-modal": 'false', "aria-labelledby": labelledbyId, "aria-busy": progress ? 'true' : 'false', ref: dialogRef, target: target, portal: portal, strategy: strategy, placement: placement,
|
|
7
|
+
return (_jsx(StyledDialog, { ...restProps, role: 'dialog', arrow: arrow, "aria-modal": 'false', "aria-labelledby": labelledbyId, "aria-label": ariaLabel, "aria-busy": progress ? 'true' : 'false', ref: dialogRef, target: target, portal: portal, strategy: strategy, placement: placement, children: children }));
|
|
8
8
|
});
|
|
9
9
|
export default Dialog;
|
|
10
10
|
//# sourceMappingURL=Dialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAuC,MAAM,OAAO,CAAC;AAExE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,MAAM,MAAM,GAAqD,UAAU,CACzE,CACE,EACE,MAAM,EACN,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,GAAG,SAAS,EACiB,EAC/B,GAAuB,EACvB,EAAE;IACF,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAE1C,OAAO,CACL,KAAC,YAAY,OACP,SAAS,EACb,IAAI,EAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAuC,MAAM,OAAO,CAAC;AAExE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,MAAM,MAAM,GAAqD,UAAU,CACzE,CACE,EACE,KAAK,GAAG,IAAI,EACZ,MAAM,EACN,YAAY,EACZ,SAAS,EACT,MAAM,EACN,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,GAAG,SAAS,EACiB,EAC/B,GAAuB,EACvB,EAAE;IACF,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAE1C,OAAO,CACL,KAAC,YAAY,OACP,SAAS,EACb,IAAI,EAAC,QAAQ,EACb,KAAK,EAAE,KAAK,gBACD,OAAO,qBACD,YAAY,gBACjB,SAAS,eACV,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EACtC,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,YAEnB,QAAQ,GACI,CAChB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import { forwardRef, PropsWithoutRef, FC, HTMLAttributes } from 'react';\n\nimport { useConsolidatedRef } from '../../hooks';\n\nimport { StyledDialog } from './Dialog.styles';\nimport { DialogProps } from './Dialog.types';\n\nconst Dialog: FC<DialogProps & HTMLAttributes<HTMLDivElement>> = forwardRef(\n (\n {\n arrow = true,\n target,\n labelledbyId,\n ariaLabel,\n portal,\n strategy,\n placement,\n children,\n progress,\n ...restProps\n }: PropsWithoutRef<DialogProps>,\n ref: DialogProps['ref']\n ) => {\n const dialogRef = useConsolidatedRef(ref);\n\n return (\n <StyledDialog\n {...restProps}\n role='dialog'\n arrow={arrow}\n aria-modal='false'\n aria-labelledby={labelledbyId}\n aria-label={ariaLabel}\n aria-busy={progress ? 'true' : 'false'}\n ref={dialogRef}\n target={target}\n portal={portal}\n strategy={strategy}\n placement={placement}\n >\n {children}\n </StyledDialog>\n );\n }\n);\n\nexport default Dialog;\n"]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export declare const StyledChildrenWrap: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
2
|
+
export declare const StyledDialogHeader: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
3
|
+
export declare const StyledDialogContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
4
|
+
export declare const StyledDialogFooter: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
2
5
|
export declare const StyledDialog: import("styled-components").StyledComponent<(<Modifiers extends string = string>(props: import("../Popover").PopoverProps<Modifiers> & import("../..").ForwardProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null), import("styled-components").DefaultTheme, {}, never>;
|
|
3
6
|
//# sourceMappingURL=Dialog.styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,kBAAkB,yGAAe,CAAC;AAE/C,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"Dialog.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,kBAAkB,yGAAe,CAAC;AAE/C,eAAO,MAAM,kBAAkB,yGAAe,CAAC;AAE/C,eAAO,MAAM,mBAAmB,yGAe9B,CAAC;AAIH,eAAO,MAAM,kBAAkB,yGAAe,CAAC;AAE/C,eAAO,MAAM,YAAY,8TAmBvB,CAAC"}
|
|
@@ -2,10 +2,37 @@ import styled, { css } from 'styled-components';
|
|
|
2
2
|
import { defaultThemeProp } from '../../theme';
|
|
3
3
|
import Popover from '../Popover';
|
|
4
4
|
export const StyledChildrenWrap = styled.div ``;
|
|
5
|
+
export const StyledDialogHeader = styled.div ``;
|
|
6
|
+
export const StyledDialogContent = styled.div(({ theme }) => {
|
|
7
|
+
return css `
|
|
8
|
+
position: relative;
|
|
9
|
+
overflow: auto;
|
|
10
|
+
padding: calc(2 * ${theme.base.spacing});
|
|
11
|
+
|
|
12
|
+
/* Small amount of block padding accounts for focus ring clipping within overflow auto. */
|
|
13
|
+
${StyledDialogHeader} + & {
|
|
14
|
+
padding-block-start: calc(0.5 * ${theme.base.spacing});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&:not(:last-child) {
|
|
18
|
+
padding-block-end: calc(0.5 * ${theme.base.spacing});
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
});
|
|
22
|
+
StyledDialogContent.defaultProps = defaultThemeProp;
|
|
23
|
+
export const StyledDialogFooter = styled.div ``;
|
|
5
24
|
export const StyledDialog = styled(Popover)(({ theme }) => {
|
|
6
25
|
return css `
|
|
7
|
-
|
|
8
|
-
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
* For fixed position, which most popovers should be, 100% will be relative to viewport and avoid an annoying 100vw scrollbar nuance.
|
|
31
|
+
* https://stackoverflow.com/questions/29551606/why-does-vw-include-the-scrollbar-as-part-of-the-viewport
|
|
32
|
+
*/
|
|
33
|
+
min-width: min(${theme.base['content-width'].sm}, calc(100% - 2rem));
|
|
34
|
+
max-width: min(${theme.base['content-width'].lg}, calc(100% - 2rem));
|
|
35
|
+
max-height: calc(100% - 2rem);
|
|
9
36
|
|
|
10
37
|
&[aria-busy='true'] {
|
|
11
38
|
${StyledChildrenWrap} {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.styles.js","sourceRoot":"","sources":["../../../src/components/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,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACxD,OAAO,GAAG,CAAA;;;;;;;;qBAQS,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE;qBAC9B,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE;;;;QAI3C,kBAAkB;;;;GAIvB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,YAAY,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport Popover from '../Popover';\n\nexport const StyledChildrenWrap = styled.div``;\n\nexport const StyledDialogHeader = styled.div``;\n\nexport const StyledDialogContent = styled.div(({ theme }) => {\n return css`\n position: relative;\n overflow: auto;\n padding: calc(2 * ${theme.base.spacing});\n\n /* Small amount of block padding accounts for focus ring clipping within overflow auto. */\n ${StyledDialogHeader} + & {\n padding-block-start: calc(0.5 * ${theme.base.spacing});\n }\n\n &:not(:last-child) {\n padding-block-end: calc(0.5 * ${theme.base.spacing});\n }\n `;\n});\n\nStyledDialogContent.defaultProps = defaultThemeProp;\n\nexport const StyledDialogFooter = styled.div``;\n\nexport const StyledDialog = styled(Popover)(({ theme }) => {\n return css`\n display: flex;\n flex-direction: column;\n\n /*\n * For fixed position, which most popovers should be, 100% will be relative to viewport and avoid an annoying 100vw scrollbar nuance.\n * https://stackoverflow.com/questions/29551606/why-does-vw-include-the-scrollbar-as-part-of-the-viewport\n */\n min-width: min(${theme.base['content-width'].sm}, calc(100% - 2rem));\n max-width: min(${theme.base['content-width'].lg}, calc(100% - 2rem));\n max-height: calc(100% - 2rem);\n\n &[aria-busy='true'] {\n ${StyledChildrenWrap} {\n visibility: hidden;\n }\n }\n `;\n});\n\nStyledDialog.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { OmitStrict } from '../../types';
|
|
2
3
|
import { PopoverProps } from '../Popover';
|
|
3
4
|
import { ProgressProps } from '../Progress';
|
|
4
5
|
export interface BaseDialogProps {
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
+
* Certain uses of dialogs require a linear edge with an input like control.
|
|
8
|
+
* There an arrow is not desired.
|
|
9
|
+
* @default true
|
|
7
10
|
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* In specific circumstances the heading can be visually hidden.
|
|
11
|
-
* @default false
|
|
12
|
-
*/
|
|
13
|
-
headingHidden?: boolean;
|
|
11
|
+
arrow?: PopoverProps['arrow'];
|
|
14
12
|
/**
|
|
15
13
|
* An element the dialog is contextually and visually associated with. Normally a triggering button.
|
|
16
14
|
* Components rendering Dialog should mount and unmount instances based on this value.
|
|
@@ -38,12 +36,16 @@ export interface BaseDialogProps {
|
|
|
38
36
|
*/
|
|
39
37
|
ref?: PopoverProps['ref'];
|
|
40
38
|
}
|
|
41
|
-
export
|
|
39
|
+
export type DialogProps = BaseDialogProps & {
|
|
42
40
|
/**
|
|
43
|
-
* The DOM id for the dialog's labelling element.
|
|
41
|
+
* The DOM id for the dialog's visible labelling element.
|
|
44
42
|
*/
|
|
45
|
-
labelledbyId
|
|
46
|
-
|
|
43
|
+
labelledbyId?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Provide a contextually sufficient aria label if a visible labelling element is not present.
|
|
46
|
+
*/
|
|
47
|
+
ariaLabel?: string;
|
|
48
|
+
};
|
|
47
49
|
/**
|
|
48
50
|
* A simple callback or an object to customize a subset button properties.
|
|
49
51
|
*/
|
|
@@ -52,7 +54,7 @@ type FormAction = (() => void) | {
|
|
|
52
54
|
disabled?: boolean;
|
|
53
55
|
handler: () => void;
|
|
54
56
|
};
|
|
55
|
-
export
|
|
57
|
+
export type FormDialogProps = BaseDialogProps & {
|
|
56
58
|
/**
|
|
57
59
|
* Called when the user presses escape or clicks away.
|
|
58
60
|
*/
|
|
@@ -68,8 +70,28 @@ export interface FormDialogProps extends BaseDialogProps {
|
|
|
68
70
|
* Invocation of this indicates the user wishes to submit any changes and close the dialog. Please consider progress states after submit.
|
|
69
71
|
*/
|
|
70
72
|
onSubmit: FormAction;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
+
} & ({
|
|
74
|
+
/**
|
|
75
|
+
* A string to indicate context for the dialog. The dialog will be labelled by this value.
|
|
76
|
+
*/
|
|
77
|
+
heading: string;
|
|
78
|
+
ariaLabel?: never;
|
|
79
|
+
} | {
|
|
80
|
+
/**
|
|
81
|
+
* Provide a contextually sufficient aria label if a visible heading is not provided.
|
|
82
|
+
*/
|
|
83
|
+
heading?: never;
|
|
84
|
+
ariaLabel: string;
|
|
85
|
+
});
|
|
86
|
+
export interface InfoDialogProps extends OmitStrict<BaseDialogProps, 'arrow'> {
|
|
87
|
+
/**
|
|
88
|
+
* A string or summary item like props to indicate context for the dialog. The dialog will be labelled by either the heading element or primary property.
|
|
89
|
+
*/
|
|
90
|
+
heading?: string | {
|
|
91
|
+
primary: string;
|
|
92
|
+
secondary?: string;
|
|
93
|
+
visual?: ReactNode;
|
|
94
|
+
};
|
|
73
95
|
/**
|
|
74
96
|
* Renders a standard design system dismiss button to close the dialog when the user clicks this button, presses escape or clicks away.
|
|
75
97
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.types.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Dialog.types.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,eAA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S,EAAE,MAAM,CAAC;CACnB,CACJ,CAAC;AAEJ,MAAM,WAAW,eAAgB,SAAQ,UAAU,CAAC,eAAe,EAAE,OAAO,CAAC;IAC3E;;OAEG;IACH,OAAO,CAAC,EACJ,MAAM,GACN;QACE,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,SAAS,CAAC;KACpB,CAAC;IAEN;;OAEG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.types.js","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Dialog.types.js","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ReactNode } from 'react';\n\nimport { OmitStrict } from '../../types';\nimport { PopoverProps } from '../Popover';\nimport { ProgressProps } from '../Progress';\n\nexport interface BaseDialogProps {\n /**\n * Certain uses of dialogs require a linear edge with an input like control.\n * There an arrow is not desired.\n * @default true\n */\n arrow?: PopoverProps['arrow'];\n\n /**\n * An element the dialog is contextually and visually associated with. Normally a triggering button.\n * Components rendering Dialog should mount and unmount instances based on this value.\n */\n target: HTMLElement;\n\n /**\n * Content for the dialog. Avoid form control buttons within as those should be rendered by way of onCancel and onSubmit with FormDialog.\n */\n children: PopoverProps['children'];\n\n /**\n * If there is a progress state either on opening, or after submit, you must indicate as such. A custom message is supported as well.\n */\n progress?: boolean | ProgressProps['message'];\n\n /** Optionally render the dialog element at the end of the body or within a specified element. */\n portal?: PopoverProps['portal'];\n\n /** Positioning strategy for solving rendering scenarios. */\n strategy?: PopoverProps['strategy'];\n\n /**\n * Intended positioning placement for the dialog element.\n * Placement may auto adjust based on screen position and other layout variables.\n */\n placement?: PopoverProps['placement'];\n\n /**\n * Reference to the dialog's root element.\n */\n ref?: PopoverProps['ref'];\n}\n\nexport type DialogProps = BaseDialogProps & {\n /**\n * The DOM id for the dialog's visible labelling element.\n */\n labelledbyId?: string;\n\n /**\n * Provide a contextually sufficient aria label if a visible labelling element is not present.\n */\n ariaLabel?: string;\n};\n\n/**\n * A simple callback or an object to customize a subset button properties.\n */\ntype FormAction =\n | (() => void)\n | {\n text?: string;\n disabled?: boolean;\n handler: () => void;\n };\n\nexport type FormDialogProps = BaseDialogProps & {\n /**\n * Called when the user presses escape or clicks away.\n */\n onDismiss?: () => void;\n\n /**\n * Renders a standard design system cancel button.\n * If onDismiss is not provided, onCancel will be invoked when the user presses the Escape key or clicks outside of the dialog.\n * Invocation of this indicates the user wishes to cancel any changes and close the dialog.\n */\n onCancel: FormAction;\n\n /**\n * Renders a standard design system submit button.\n * Invocation of this indicates the user wishes to submit any changes and close the dialog. Please consider progress states after submit.\n */\n onSubmit: FormAction;\n} & (\n | {\n /**\n * A string to indicate context for the dialog. The dialog will be labelled by this value.\n */\n heading: string;\n ariaLabel?: never;\n }\n | {\n /**\n * Provide a contextually sufficient aria label if a visible heading is not provided.\n */\n heading?: never;\n ariaLabel: string;\n }\n );\n\nexport interface InfoDialogProps extends OmitStrict<BaseDialogProps, 'arrow'> {\n /**\n * A string or summary item like props to indicate context for the dialog. The dialog will be labelled by either the heading element or primary property.\n */\n heading?:\n | string\n | {\n primary: string;\n secondary?: string;\n visual?: ReactNode;\n };\n\n /**\n * Renders a standard design system dismiss button to close the dialog when the user clicks this button, presses escape or clicks away.\n */\n onDismiss: () => void;\n}\n\n/**\n * Components which render Dialog internally may need to offer some control to consuming components.\n * Use this interface to offer an imperative handle for shared control.\n */\nexport interface DialogHandleValue {\n open: () => void;\n close: () => void;\n}\n"]}
|