@arc-ui/components 12.0.0-beta.5 → 12.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Alert/Alert.cjs.js +9 -10
- package/dist/Alert/Alert.esm.js +4 -5
- package/dist/Alert/styles.css +1 -0
- package/dist/Align/Align.cjs.js +7 -8
- package/dist/Align/Align.esm.js +1 -2
- package/dist/Align/styles.css +1 -0
- package/dist/AppButton/AppButton.cjs.js +4 -3
- package/dist/AppButton/AppButton.esm.js +4 -3
- package/dist/AppButton/styles.css +1 -0
- package/dist/Avatar/Avatar.cjs.js +7 -8
- package/dist/Avatar/Avatar.esm.js +7 -8
- package/dist/Avatar/styles.css +1 -0
- package/dist/AvatarGroup/AvatarGroup.cjs.js +14 -15
- package/dist/AvatarGroup/AvatarGroup.esm.js +7 -8
- package/dist/AvatarGroup/styles.css +1 -0
- package/dist/Badge/Badge.cjs.js +5 -13
- package/dist/Badge/Badge.esm.js +4 -12
- package/dist/Badge/styles.css +1 -0
- package/dist/Box/Box.cjs.js +6 -24
- package/dist/Box/Box.esm.js +5 -23
- package/dist/Box/styles.css +1 -0
- package/dist/BrandLogo/BrandLogo.cjs.js +3 -4
- package/dist/BrandLogo/BrandLogo.esm.js +3 -4
- package/dist/BrandLogo/styles.css +1 -0
- package/dist/Breadcrumbs/Breadcrumbs.cjs.js +5 -5
- package/dist/Breadcrumbs/Breadcrumbs.esm.js +5 -5
- package/dist/Breadcrumbs/styles.css +1 -0
- package/dist/Button/Button.cjs.js +5 -6
- package/dist/Button/Button.esm.js +5 -6
- package/dist/Button/styles.css +1 -0
- package/dist/ButtonV2/ButtonV2.cjs.js +5 -6
- package/dist/ButtonV2/ButtonV2.esm.js +5 -6
- package/dist/ButtonV2/styles.css +1 -0
- package/dist/Calendar/Calendar.cjs.js +10 -11
- package/dist/Calendar/Calendar.esm.js +10 -11
- package/dist/Calendar/styles.css +1 -0
- package/dist/CardFooter/CardFooter.cjs.js +17 -0
- package/dist/CardFooter/CardFooter.esm.js +9 -0
- package/dist/CardFooter/package.json +7 -0
- package/dist/CardFooter/styles.css +1 -0
- package/dist/CardHeading/CardHeading.cjs.js +14 -0
- package/dist/CardHeading/CardHeading.esm.js +6 -0
- package/dist/CardHeading/package.json +7 -0
- package/dist/CardHeading/styles.css +1 -0
- package/dist/Carousel/Carousel.cjs.js +1921 -0
- package/dist/Carousel/Carousel.esm.js +1913 -0
- package/dist/Carousel/package.json +7 -0
- package/dist/Carousel/styles.css +1 -0
- package/dist/Checkbox/Checkbox.cjs.js +8 -9
- package/dist/Checkbox/Checkbox.esm.js +8 -9
- package/dist/Checkbox/styles.css +1 -0
- package/dist/Columns/Columns.cjs.js +2 -3
- package/dist/Columns/Columns.esm.js +2 -3
- package/dist/Columns/styles.css +1 -0
- package/dist/ConditionalWrapper/ConditionalWrapper.cjs.js +10 -0
- package/dist/ConditionalWrapper/ConditionalWrapper.esm.js +2 -0
- package/dist/ConditionalWrapper/package.json +7 -0
- package/dist/ContentSwitcher/ContentSwitcher.cjs.js +20 -0
- package/dist/ContentSwitcher/ContentSwitcher.esm.js +12 -0
- package/dist/ContentSwitcher/package.json +7 -0
- package/dist/ContentSwitcher/styles.css +1 -0
- package/dist/ContentSwitcherDropdown/ContentSwitcherDropdown.cjs.js +23 -0
- package/dist/ContentSwitcherDropdown/ContentSwitcherDropdown.esm.js +15 -0
- package/dist/ContentSwitcherDropdown/package.json +7 -0
- package/dist/ContentSwitcherDropdown/styles.css +1 -0
- package/dist/DatePicker/DatePicker.cjs.js +19 -23
- package/dist/DatePicker/DatePicker.esm.js +19 -23
- package/dist/DatePicker/styles.css +1 -0
- package/dist/Disclosure/Disclosure.cjs.js +8 -9
- package/dist/Disclosure/Disclosure.esm.js +4 -5
- package/dist/Disclosure/styles.css +1 -0
- package/dist/DisclosureMini/DisclosureMini.cjs.js +5 -6
- package/dist/DisclosureMini/DisclosureMini.esm.js +5 -6
- package/dist/DisclosureMini/styles.css +1 -0
- package/dist/Download/Download.cjs.js +16 -0
- package/dist/Download/Download.esm.js +8 -0
- package/dist/Download/package.json +7 -0
- package/dist/Download/styles.css +1 -0
- package/dist/Elevation/Elevation.cjs.js +5 -5
- package/dist/Elevation/Elevation.esm.js +1 -1
- package/dist/Elevation/styles.css +1 -0
- package/dist/Filter/Filter.cjs.js +4 -4
- package/dist/Filter/Filter.esm.js +4 -4
- package/dist/Filter/styles.css +1 -0
- package/dist/FormControl/FormControl.cjs.js +7 -8
- package/dist/FormControl/FormControl.esm.js +7 -8
- package/dist/FormControl/styles.css +1 -0
- package/dist/Grid/Grid.cjs.js +2 -3
- package/dist/Grid/Grid.esm.js +2 -3
- package/dist/Grid/styles.css +1 -0
- package/dist/Group/Group.cjs.js +3 -3
- package/dist/Group/Group.esm.js +3 -3
- package/dist/Group/styles.css +1 -0
- package/dist/Heading/Heading.cjs.js +3 -4
- package/dist/Heading/Heading.esm.js +3 -4
- package/dist/Heading/styles.css +1 -0
- package/dist/HeroBanner/HeroBanner.cjs.js +63 -0
- package/dist/HeroBanner/HeroBanner.esm.js +55 -0
- package/dist/HeroBanner/package.json +7 -0
- package/dist/HeroBanner/styles.css +1 -0
- package/dist/HeroButton/HeroButton.cjs.js +5 -6
- package/dist/HeroButton/HeroButton.esm.js +5 -6
- package/dist/HeroButton/styles.css +1 -0
- package/dist/Hidden/Hidden.cjs.js +5 -5
- package/dist/Hidden/Hidden.esm.js +1 -1
- package/dist/Hidden/styles.css +1 -0
- package/dist/Icon/Icon.cjs.js +3 -4
- package/dist/Icon/Icon.esm.js +3 -4
- package/dist/Icon/styles.css +1 -0
- package/dist/Image/Image.cjs.js +2 -3
- package/dist/Image/Image.esm.js +2 -3
- package/dist/Image/styles.css +1 -0
- package/dist/ImpactCard/ImpactCard.cjs.js +17 -18
- package/dist/ImpactCard/ImpactCard.esm.js +11 -12
- package/dist/ImpactCard/styles.css +1 -0
- package/dist/InformationCard/InformationCard.cjs.js +37 -51
- package/dist/InformationCard/InformationCard.esm.js +34 -48
- package/dist/InformationCard/styles.css +1 -0
- package/dist/Link/Link.cjs.js +15 -16
- package/dist/Link/Link.esm.js +8 -9
- package/dist/Link/styles.css +1 -0
- package/dist/Markup/Markup.cjs.js +6 -6
- package/dist/Markup/Markup.esm.js +2 -2
- package/dist/Markup/styles.css +1 -0
- package/dist/MediaCard/MediaCard.cjs.js +15 -15
- package/dist/MediaCard/MediaCard.esm.js +15 -15
- package/dist/MediaCard/styles.css +1 -0
- package/dist/Modal/Modal.cjs.js +44 -1201
- package/dist/Modal/Modal.esm.js +13 -1169
- package/dist/Modal/styles.css +1 -0
- package/dist/Pagination/Pagination.cjs.js +12 -13
- package/dist/Pagination/Pagination.esm.js +3 -4
- package/dist/Pagination/styles.css +1 -0
- package/dist/PaginationSimple/PaginationSimple.cjs.js +85 -17
- package/dist/PaginationSimple/PaginationSimple.esm.js +82 -14
- package/dist/PaginationSimple/styles.css +1 -0
- package/dist/Poster/Poster.cjs.js +4 -5
- package/dist/Poster/Poster.esm.js +4 -5
- package/dist/Poster/styles.css +1 -0
- package/dist/ProgressBar/ProgressBar.cjs.js +12 -13
- package/dist/ProgressBar/ProgressBar.esm.js +6 -7
- package/dist/ProgressBar/styles.css +1 -0
- package/dist/ProgressStepper/ProgressStepper.cjs.js +5 -6
- package/dist/ProgressStepper/ProgressStepper.esm.js +5 -6
- package/dist/ProgressStepper/styles.css +1 -0
- package/dist/RadioGroup/RadioGroup.cjs.js +8 -9
- package/dist/RadioGroup/RadioGroup.esm.js +8 -9
- package/dist/RadioGroup/styles.css +1 -0
- package/dist/Rule/Rule.cjs.js +5 -5
- package/dist/Rule/Rule.esm.js +2 -2
- package/dist/Rule/styles.css +1 -0
- package/dist/ScrollToTop/ScrollToTop.cjs.js +26 -10
- package/dist/ScrollToTop/ScrollToTop.esm.js +21 -5
- package/dist/ScrollToTop/styles.css +1 -0
- package/dist/Section/Section.cjs.js +2 -2
- package/dist/Section/Section.esm.js +2 -2
- package/dist/Section/styles.css +1 -0
- package/dist/Select/Select.cjs.js +31 -1132
- package/dist/Select/Select.esm.js +18 -1119
- package/dist/Select/styles.css +1 -0
- package/dist/SiteFooter/SiteFooter.cjs.js +7 -8
- package/dist/SiteFooter/SiteFooter.esm.js +7 -8
- package/dist/SiteFooter/styles.css +1 -0
- package/dist/SiteHeaderV2/SiteHeaderV2.cjs.js +12 -13
- package/dist/SiteHeaderV2/SiteHeaderV2.esm.js +12 -13
- package/dist/SiteHeaderV2/styles.css +1 -0
- package/dist/SkipLink/SkipLink.cjs.js +4 -4
- package/dist/SkipLink/SkipLink.esm.js +3 -3
- package/dist/SkipLink/styles.css +1 -0
- package/dist/Spinner/Spinner.cjs.js +12 -0
- package/dist/Spinner/Spinner.esm.js +4 -0
- package/dist/Spinner/package.json +7 -0
- package/dist/Spinner/styles.css +1 -0
- package/dist/Surface/Surface.cjs.js +2 -2
- package/dist/Surface/Surface.esm.js +2 -2
- package/dist/Surface/styles.css +1 -0
- package/dist/Switch/Switch.cjs.js +16 -18
- package/dist/Switch/Switch.esm.js +12 -14
- package/dist/Switch/styles.css +1 -0
- package/dist/Tabs/Tabs.cjs.js +9 -11
- package/dist/Tabs/Tabs.esm.js +9 -11
- package/dist/Tabs/styles.css +1 -0
- package/dist/Tag/Tag.cjs.js +77 -9
- package/dist/Tag/Tag.esm.js +76 -8
- package/dist/Tag/styles.css +1 -0
- package/dist/Text/Text.cjs.js +3 -4
- package/dist/Text/Text.esm.js +3 -4
- package/dist/Text/styles.css +1 -0
- package/dist/TextArea/TextArea.cjs.js +64 -59
- package/dist/TextArea/TextArea.esm.js +60 -55
- package/dist/TextArea/styles.css +1 -0
- package/dist/TextInput/TextInput.cjs.js +8 -10
- package/dist/TextInput/TextInput.esm.js +8 -10
- package/dist/TextInput/styles.css +1 -0
- package/dist/Theme/Theme.cjs.js +7 -6
- package/dist/Theme/Theme.esm.js +5 -4
- package/dist/Theme/styles.css +1 -0
- package/dist/ThemeIcon/ThemeIcon.cjs.js +3 -4
- package/dist/ThemeIcon/ThemeIcon.esm.js +3 -4
- package/dist/ThemeIcon/styles.css +1 -0
- package/dist/Toast/Toast.cjs.js +8 -10
- package/dist/Toast/Toast.esm.js +8 -10
- package/dist/Toast/styles.css +1 -0
- package/dist/Truncate/Truncate.cjs.js +3 -3
- package/dist/Truncate/Truncate.esm.js +3 -3
- package/dist/Truncate/styles.css +1 -0
- package/dist/TypographyCard/TypographyCard.cjs.js +15 -16
- package/dist/TypographyCard/TypographyCard.esm.js +10 -11
- package/dist/TypographyCard/styles.css +1 -0
- package/dist/UniversalHeader/UniversalHeader.cjs.js +3 -3
- package/dist/UniversalHeader/UniversalHeader.esm.js +3 -3
- package/dist/UniversalHeader/styles.css +1 -0
- package/dist/VerticalSpace/VerticalSpace.cjs.js +2 -2
- package/dist/VerticalSpace/VerticalSpace.esm.js +2 -2
- package/dist/VerticalSpace/styles.css +1 -0
- package/dist/VideoPlayer/VideoPlayer.cjs.js +38 -26
- package/dist/VideoPlayer/VideoPlayer.esm.js +37 -25
- package/dist/VideoPlayer/styles.css +1 -0
- package/dist/Visible/Visible.cjs.js +5 -5
- package/dist/Visible/Visible.esm.js +1 -1
- package/dist/Visible/styles.css +1 -0
- package/dist/VisuallyHidden/VisuallyHidden.cjs.js +2 -1
- package/dist/VisuallyHidden/VisuallyHidden.esm.js +2 -1
- package/dist/VisuallyHidden/styles.css +1 -0
- package/dist/_shared/cjs/{Avatar-fc0d9b8b.js → Avatar-7478d063.js} +11 -12
- package/dist/_shared/cjs/Badge-ca986033.js +17 -0
- package/dist/_shared/cjs/Box-e225b4a4.js +29 -0
- package/dist/_shared/cjs/{BrandLogo-1d2ca2c7.js → BrandLogo-bf632f2b.js} +7 -8
- package/dist/_shared/cjs/{Breadcrumbs-7af0af2c.js → Breadcrumbs-bb292a9e.js} +15 -14
- package/dist/_shared/cjs/BtIconArrowRight.esm-c78e3c11.js +30 -0
- package/dist/_shared/cjs/BtIconChevronRight2Px.esm-e8329e34.js +44 -0
- package/dist/_shared/cjs/BtIconChevronRightMid.esm-745faaca.js +28 -0
- package/dist/_shared/cjs/BtIconPlayFill.esm-7e848bd9.js +30 -0
- package/dist/_shared/cjs/{Button-7d891a89.js → Button-76215474.js} +12 -13
- package/dist/_shared/cjs/{ButtonV2-b2db3f46.js → ButtonV2-320f74b2.js} +21 -16
- package/dist/_shared/cjs/{Calendar-649cc139.js → Calendar-16ed5bec.js} +915 -915
- package/dist/_shared/cjs/CardFooter-6aa9a280.js +79 -0
- package/dist/_shared/cjs/CardHeading-30ef8abc.js +16 -0
- package/dist/_shared/cjs/{Checkbox-0e423653.js → Checkbox-4dbaac21.js} +17 -12
- package/dist/_shared/cjs/{Columns-1224bdff.js → Columns-ff4977f8.js} +9 -10
- package/dist/_shared/cjs/Combination-d19b4dc6.js +1203 -0
- package/dist/_shared/cjs/ContentSwitcher-1b789e2f.js +98 -0
- package/dist/_shared/cjs/ContentSwitcherDropdown-0de9f7e4.js +47 -0
- package/dist/_shared/cjs/DatePicker-a0f14025.js +939 -0
- package/dist/_shared/cjs/{DisclosureMini-c01ecce0.js → DisclosureMini-09ee2d12.js} +10 -10
- package/dist/_shared/cjs/Download-08d71049.js +43 -0
- package/dist/_shared/cjs/{Filter-3b897d92.js → Filter-60b0dd96.js} +14 -14
- package/dist/_shared/cjs/{FormControl-88d48f42.js → FormControl-fa7bb586.js} +12 -12
- package/dist/_shared/cjs/{Grid-9e91fb3d.js → Grid-a50fb206.js} +10 -11
- package/dist/_shared/cjs/{Group-3d5ea240.js → Group-1aba9855.js} +9 -9
- package/dist/_shared/cjs/{Heading-fb63844f.js → Heading-cb321adf.js} +9 -9
- package/dist/_shared/cjs/{HeroButton-0586a7c4.js → HeroButton-75e1ab78.js} +20 -20
- package/dist/_shared/cjs/Icon-859c6c00.js +47 -0
- package/dist/_shared/cjs/{Image-e9a5a326.js → Image-b807e951.js} +9 -10
- package/dist/_shared/cjs/{MediaCard-8f41b411.js → MediaCard-8101ae8b.js} +18 -18
- package/dist/_shared/cjs/{Poster-b7242b37.js → Poster-46b6803e.js} +13 -14
- package/dist/_shared/cjs/{ProgressStepper-fb8405c2.js → ProgressStepper-5fb2e7ac.js} +18 -42
- package/dist/_shared/cjs/{RadioGroup-a4186267.js → RadioGroup-f8963bd2.js} +14 -14
- package/dist/_shared/cjs/{Section-ecfc659b.js → Section-bee4a090.js} +5 -5
- package/dist/_shared/cjs/{SiteFooter-7c4072b5.js → SiteFooter-3fee99ae.js} +11 -11
- package/dist/_shared/cjs/{SiteHeaderV2-94687999.js → SiteHeaderV2-0f072158.js} +71 -106
- package/dist/_shared/cjs/Spinner-2a1d9f20.js +24 -0
- package/dist/_shared/cjs/{index-df60851b.js → Surface-4bc47dcb.js} +53 -65
- package/dist/_shared/cjs/Tabs-ba44ea49.js +90 -0
- package/dist/_shared/cjs/{Text-1c1110a4.js → Text-f6be8fdd.js} +8 -8
- package/dist/_shared/cjs/{TextInput-762e2309.js → TextInput-9d9a53ac.js} +13 -13
- package/dist/_shared/cjs/{ThemeIcon-ee814862.js → ThemeIcon-6b10d20a.js} +8 -9
- package/dist/_shared/cjs/{Toast-d06a89e0.js → Toast-a33b5a2e.js} +16 -17
- package/dist/_shared/cjs/{UniversalHeader-f6d9c63a.js → UniversalHeader-114ac8f5.js} +6 -6
- package/dist/_shared/cjs/{VerticalSpace-e128ec68.js → VerticalSpace-3908ae62.js} +5 -5
- package/dist/_shared/cjs/{VisuallyHidden-b0de4c7b.js → VisuallyHidden-821078c9.js} +3 -2
- package/dist/_shared/cjs/{component-df82bc05.js → component-ae4b7058.js} +4 -4
- package/dist/_shared/cjs/{Combination-3a639f6d.js → floating-ui.react-dom-08b8b87c.js} +37 -1103
- package/dist/_shared/cjs/{Tabs-75c34f43.js → index-1e7a1fce.js} +11 -96
- package/dist/_shared/cjs/{index-3d629205.js → index-2bf59363.js} +19 -1
- package/dist/_shared/cjs/{index-996dec94.js → index-527f962b.js} +1 -1
- package/dist/_shared/cjs/index-6b0bf2cc.js +2204 -0
- package/dist/_shared/cjs/{index-7aa7f96a.js → index-879e71ee.js} +8 -1
- package/dist/_shared/cjs/{index-41b09e85.js → index-ba3141f5.js} +20 -1
- package/dist/_shared/cjs/{index-0c6319ec.js → index-dbc843d3.js} +1 -1
- package/dist/_shared/cjs/{index.es-16759329.js → index.es-11fc5df7.js} +2 -2
- package/dist/_shared/cjs/index.es-b404d2c5.js +324 -0
- package/dist/_shared/esm/{Avatar-38cc0595.js → Avatar-b2fde5c6.js} +5 -6
- package/dist/_shared/esm/Badge-a6bda4a7.js +11 -0
- package/dist/_shared/esm/Box-2a1645ed.js +23 -0
- package/dist/_shared/esm/{BrandLogo-7ed8aeda.js → BrandLogo-3424eb79.js} +2 -3
- package/dist/_shared/esm/{Breadcrumbs-9078b68e.js → Breadcrumbs-7de7bfa5.js} +11 -10
- package/dist/_shared/esm/BtIconArrowRight.esm-8bcaa8ad.js +24 -0
- package/dist/_shared/esm/BtIconChevronRight2Px.esm-84262845.js +37 -0
- package/dist/_shared/esm/BtIconChevronRightMid.esm-f67f0ca3.js +22 -0
- package/dist/_shared/esm/BtIconPlayFill.esm-ec2797a0.js +24 -0
- package/dist/_shared/esm/{Button-dde2b46a.js → Button-9cab8eec.js} +4 -5
- package/dist/_shared/esm/{ButtonV2-49cd0615.js → ButtonV2-4dc8830e.js} +13 -8
- package/dist/_shared/esm/{Calendar-60591442.js → Calendar-e3f8c4f0.js} +893 -893
- package/dist/_shared/esm/CardFooter-2902bd84.js +73 -0
- package/dist/_shared/esm/CardHeading-6d3dbfad.js +10 -0
- package/dist/_shared/esm/{Checkbox-0baca464.js → Checkbox-f40de2e9.js} +12 -7
- package/dist/_shared/esm/{Columns-6a8f6fbb.js → Columns-5e02e601.js} +1 -2
- package/dist/_shared/esm/Combination-a063f96d.js +1163 -0
- package/dist/_shared/esm/ContentSwitcher-e0bd73a7.js +92 -0
- package/dist/_shared/esm/ContentSwitcherDropdown-306b4660.js +41 -0
- package/dist/_shared/esm/DatePicker-3f82e2c4.js +910 -0
- package/dist/_shared/esm/{DisclosureMini-38f4c459.js → DisclosureMini-60cb2a6c.js} +4 -4
- package/dist/_shared/esm/Download-a5443778.js +37 -0
- package/dist/_shared/esm/{Filter-49dcf5ce.js → Filter-bc821cbc.js} +11 -11
- package/dist/_shared/esm/{FormControl-d873f7fa.js → FormControl-7ff0a178.js} +5 -5
- package/dist/_shared/esm/{Grid-fb9fc522.js → Grid-75251350.js} +1 -2
- package/dist/_shared/esm/{Group-66196f07.js → Group-b4e10621.js} +2 -2
- package/dist/_shared/esm/{Heading-906c7c7c.js → Heading-14df0c64.js} +5 -5
- package/dist/_shared/esm/{HeroButton-7ea692bf.js → HeroButton-1221bd94.js} +12 -12
- package/dist/_shared/esm/{Icon-512f834f.js → Icon-3e813b34.js} +16 -6
- package/dist/_shared/esm/{Image-57d08939.js → Image-85c39506.js} +1 -2
- package/dist/_shared/esm/{MediaCard-c12d89ea.js → MediaCard-387c8f11.js} +10 -10
- package/dist/_shared/esm/{Poster-e05a8b45.js → Poster-adcd3ba3.js} +4 -5
- package/dist/_shared/esm/{ProgressStepper-189ed0f9.js → ProgressStepper-72b070a8.js} +9 -33
- package/dist/_shared/esm/{RadioGroup-8ff17cbb.js → RadioGroup-6e657cee.js} +7 -7
- package/dist/_shared/esm/{Section-1acbc06a.js → Section-b9caea45.js} +1 -1
- package/dist/_shared/esm/{SiteFooter-b65497e8.js → SiteFooter-61b4ae63.js} +6 -6
- package/dist/_shared/esm/{SiteHeaderV2-784b3bf8.js → SiteHeaderV2-1fde7d20.js} +10 -45
- package/dist/_shared/esm/Spinner-9d28043d.js +18 -0
- package/dist/_shared/esm/{index-288c66b5.js → Surface-56d329b0.js} +48 -65
- package/dist/_shared/esm/Tabs-276a0836.js +84 -0
- package/dist/_shared/esm/{Text-a46fb76b.js → Text-98ad2e78.js} +5 -5
- package/dist/_shared/esm/{TextInput-94c7b1a4.js → TextInput-eccd0140.js} +6 -6
- package/dist/_shared/esm/{ThemeIcon-c2dc41a6.js → ThemeIcon-810de4bc.js} +2 -3
- package/dist/_shared/esm/{Toast-de6ca2f3.js → Toast-62932e3b.js} +6 -7
- package/dist/_shared/esm/{UniversalHeader-456ad60c.js → UniversalHeader-370d7fa4.js} +3 -3
- package/dist/_shared/esm/{VerticalSpace-b07cd8e6.js → VerticalSpace-549fbdc8.js} +1 -1
- package/dist/_shared/esm/VisuallyHidden-fee374a8.js +12 -0
- package/dist/_shared/esm/{component-d0a555cf.js → component-94b3dbfe.js} +1 -1
- package/dist/_shared/esm/{Combination-ae3a3f08.js → floating-ui.react-dom-1bb71aae.js} +15 -1079
- package/dist/_shared/esm/{index-f97466e9.js → index-14c7f4da.js} +1 -1
- package/dist/_shared/esm/index-24509173.js +2169 -0
- package/dist/_shared/esm/{index-cace3545.js → index-57d4cb34.js} +33 -33
- package/dist/_shared/esm/{Tabs-21ac7dfe.js → index-89a7c31c.js} +6 -90
- package/dist/_shared/esm/{index-4e58de24.js → index-ac50b180.js} +21 -3
- package/dist/_shared/esm/{index-7740883c.js → index-b9923ee4.js} +9 -2
- package/dist/_shared/esm/{index-605031ca.js → index-ce6dee84.js} +53 -53
- package/dist/_shared/esm/index-e969452b.js +41 -0
- package/dist/_shared/esm/{index-fa93ec97.js → index-f2ddcbe2.js} +1 -1
- package/dist/_shared/esm/index.es-4921e8dd.js +318 -0
- package/dist/_shared/esm/{index.es-1b6d33c2.js → index.es-52a3bcff.js} +2 -2
- package/dist/index.es.js +14634 -13762
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +14637 -13761
- package/dist/index.js.map +1 -1
- package/dist/styles.css +9 -7
- package/dist/types/components/Avatar/index.d.ts +1 -1
- package/dist/types/components/Box/Box.d.ts +4 -0
- package/dist/types/components/ButtonV2/ButtonV2.d.ts +2 -2
- package/dist/types/components/CardHeading/index.d.ts +1 -0
- package/dist/types/components/Carousel/Carousel.d.ts +34 -0
- package/dist/types/components/Carousel/components/DotButton.d.ts +10 -0
- package/dist/types/components/Carousel/constants/breakpoints.d.ts +5 -0
- package/dist/types/components/Carousel/helpers/get-options.d.ts +3 -0
- package/dist/types/components/Carousel/helpers/get-slide-width.d.ts +12 -0
- package/dist/types/components/Carousel/index.d.ts +1 -0
- package/dist/types/components/Carousel/types/breakpoints.d.ts +1 -0
- package/dist/types/components/Carousel/types/keynames.d.ts +5 -0
- package/dist/types/components/Carousel/types/responsive.d.ts +3 -0
- package/dist/types/components/Carousel/types/screen-sizes.d.ts +2 -0
- package/dist/types/components/Carousel/types/slide-config.d.ts +5 -0
- package/dist/types/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/types/components/ContentSwitcher/ContentSwitcher.d.ts +28 -0
- package/dist/types/components/ContentSwitcher/ContentSwitcherContent/ContentSwitcherContent.d.ts +12 -0
- package/dist/types/components/ContentSwitcher/ContentSwitcherContent/index.d.ts +1 -0
- package/dist/types/components/ContentSwitcher/ContentSwitcherList/ContentSwitcherList.d.ts +24 -0
- package/dist/types/components/ContentSwitcher/ContentSwitcherList/index.d.ts +1 -0
- package/dist/types/components/ContentSwitcher/ContentSwitcherTab/ContentSwitcherTab.d.ts +17 -0
- package/dist/types/components/ContentSwitcher/ContentSwitcherTab/index.d.ts +1 -0
- package/dist/types/components/ContentSwitcher/index.d.ts +1 -0
- package/dist/types/components/ContentSwitcherDropdown/ContentSwitcherDropdown.d.ts +37 -0
- package/dist/types/components/ContentSwitcherDropdown/index.d.ts +1 -0
- package/dist/types/components/Disclosure/index.d.ts +1 -1
- package/dist/types/components/Download/Download.d.ts +41 -0
- package/dist/types/components/Download/index.d.ts +1 -0
- package/dist/types/components/Heading/Heading.d.ts +4 -0
- package/dist/types/components/Heading/index.d.ts +1 -1
- package/dist/types/components/HeroBanner/HeroBanner.d.ts +52 -0
- package/dist/types/components/HeroBanner/index.d.ts +1 -0
- package/dist/types/components/Icon/Icon.d.ts +2 -2
- package/dist/types/components/ImpactCard/ImpactCard.d.ts +2 -2
- package/dist/types/components/ImpactCard/index.d.ts +1 -1
- package/dist/types/components/InformationCard/InformationCard.d.ts +2 -2
- package/dist/types/components/InformationCard/index.d.ts +1 -1
- package/dist/types/components/MediaCard/MediaCard.d.ts +1 -1
- package/dist/types/components/MediaCard/index.d.ts +1 -1
- package/dist/types/components/PaginationSimple/PaginationSimple.d.ts +24 -16
- package/dist/types/components/Spinner/Spinner.d.ts +16 -0
- package/dist/types/components/Spinner/index.d.ts +1 -0
- package/dist/types/components/Surface/Surface.d.ts +4 -0
- package/dist/types/components/Switch/Switch.d.ts +4 -0
- package/dist/types/components/Tabs/TabsList/TabsList.d.ts +5 -0
- package/dist/types/components/Text/Text.d.ts +4 -0
- package/dist/types/components/TextInput/TextInput.d.ts +2 -2
- package/dist/types/components/ThemeIcon/icon-names.d.ts +1 -1
- package/dist/types/components/Truncate/Truncate.d.ts +1 -1
- package/dist/types/components/TypographyCard/TypographyCard.d.ts +2 -2
- package/dist/types/components/TypographyCard/index.d.ts +1 -1
- package/dist/types/components/VideoPlayer/VideoPlayer.d.ts +9 -0
- package/dist/types/components/index.d.ts +4 -0
- package/dist/types/helpers/index.d.ts +0 -2
- package/dist/types/styles.d.ts +9 -4
- package/package.json +24 -16
- package/dist/_shared/cjs/ArcIconEclipse.esm-ac777a76.js +0 -28
- package/dist/_shared/cjs/BtIconArrowRight.esm-5989f2ca.js +0 -38
- package/dist/_shared/cjs/BtIconChevronRightMid.esm-3e8d18a9.js +0 -28
- package/dist/_shared/cjs/BtIconPlayFill.esm-b8997cfc.js +0 -30
- package/dist/_shared/cjs/CardFooter-5414bc4f.js +0 -79
- package/dist/_shared/cjs/DatePicker-2417e55b.js +0 -550
- package/dist/_shared/cjs/Icon-0ec0c1fb.js +0 -37
- package/dist/_shared/cjs/Surface-8599dbe4.js +0 -57
- package/dist/_shared/cjs/Tag-452048f6.js +0 -44
- package/dist/_shared/cjs/index-039a9d35.js +0 -23
- package/dist/_shared/cjs/index-28447df0.js +0 -23
- package/dist/_shared/cjs/index-dcfdd5da.js +0 -11
- package/dist/_shared/cjs/suffix-modifier-c8a34402.js +0 -19
- package/dist/_shared/esm/ArcIconEclipse.esm-bb48b82a.js +0 -22
- package/dist/_shared/esm/BtIconArrowRight.esm-6a17d0ce.js +0 -31
- package/dist/_shared/esm/BtIconChevronRightMid.esm-4764708f.js +0 -22
- package/dist/_shared/esm/BtIconPlayFill.esm-05fc0344.js +0 -24
- package/dist/_shared/esm/CardFooter-c79fb2db.js +0 -73
- package/dist/_shared/esm/DatePicker-c7bb178e.js +0 -539
- package/dist/_shared/esm/Surface-71d21a9e.js +0 -48
- package/dist/_shared/esm/Tag-2513c185.js +0 -38
- package/dist/_shared/esm/VisuallyHidden-06692fd3.js +0 -11
- package/dist/_shared/esm/index-5113ed53.js +0 -24
- package/dist/_shared/esm/index-6028d797.js +0 -21
- package/dist/_shared/esm/index-69089474.js +0 -21
- package/dist/_shared/esm/index-a624de47.js +0 -9
- package/dist/_shared/esm/suffix-modifier-1ce05abe.js +0 -17
- package/dist/types/components/ProgressStepper/ProgressStepperItem/icons/Todo.d.ts +0 -2
- package/dist/types/helpers/filter-data-attrs.d.ts +0 -1
- package/dist/types/helpers/suffix-modifier.d.ts +0 -9
- package/dist/types/private-components/CardHeading/index.d.ts +0 -1
- package/dist/types/private-components/index.d.ts +0 -3
- package/dist/_shared/cjs/{ConditionalWrapper-be3b2625.js → ConditionalWrapper-bf944594.js} +0 -0
- package/dist/_shared/cjs/{index-7e31a45b.js → index-28fbfd5b.js} +52 -52
- package/dist/_shared/cjs/{index-3dd54df1.js → index-76f7dd53.js} +31 -31
- /package/dist/_shared/esm/{ConditionalWrapper-59be8f35.js → ConditionalWrapper-b85979de.js} +0 -0
- /package/dist/types/{private-components → components}/CardFooter/CardFooter.d.ts +0 -0
- /package/dist/types/{private-components → components}/CardFooter/index.d.ts +0 -0
- /package/dist/types/{private-components → components}/CardHeading/CardHeading.d.ts +0 -0
- /package/dist/types/{private-components → components}/ConditionalWrapper/ConditionalWrapper.d.ts +0 -0
- /package/dist/types/{private-components → components}/ConditionalWrapper/index.d.ts +0 -0
|
@@ -1,48 +1,15 @@
|
|
|
1
|
+
import { b as __spreadArray, a as __assign, _ as __rest, f as filterDataAttrs } from './index.es-4921e8dd.js';
|
|
1
2
|
import React__default, { createContext, forwardRef, useContext, useCallback, useRef, useState, useReducer, useEffect } from 'react';
|
|
2
|
-
import { r as requiredArgs, t as toDate, a as toInteger,
|
|
3
|
-
import { S as SemSizeBreakpointsM } from './index.es-
|
|
3
|
+
import { r as requiredArgs, t as toDate, a as toInteger, _ as _typeof, g as getDefaultOptions, f as format } from './index-ce6dee84.js';
|
|
4
|
+
import { S as SemSizeBreakpointsM } from './index.es-52a3bcff.js';
|
|
4
5
|
import { u as useMediaQuery } from './use-media-query-d3622da8.js';
|
|
5
|
-
import { b as __spreadArray, a as __assign } from './index-288c66b5.js';
|
|
6
6
|
import { c as classNames } from './index-2e73c2e9.js';
|
|
7
|
-
import { T as Text } from './Text-
|
|
8
|
-
import { V as VisuallyHidden } from './VisuallyHidden-
|
|
9
|
-
import { S as Surface } from './Surface-
|
|
10
|
-
import { H as Heading } from './Heading-
|
|
11
|
-
import { B as BtIconChevronRightMid } from './BtIconChevronRightMid.esm-
|
|
12
|
-
import { I as Icon } from './Icon-
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @name addDays
|
|
16
|
-
* @category Day Helpers
|
|
17
|
-
* @summary Add the specified number of days to the given date.
|
|
18
|
-
*
|
|
19
|
-
* @description
|
|
20
|
-
* Add the specified number of days to the given date.
|
|
21
|
-
*
|
|
22
|
-
* @param {Date|Number} date - the date to be changed
|
|
23
|
-
* @param {Number} amount - the amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
|
|
24
|
-
* @returns {Date} - the new date with the days added
|
|
25
|
-
* @throws {TypeError} - 2 arguments required
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* // Add 10 days to 1 September 2014:
|
|
29
|
-
* const result = addDays(new Date(2014, 8, 1), 10)
|
|
30
|
-
* //=> Thu Sep 11 2014 00:00:00
|
|
31
|
-
*/
|
|
32
|
-
function addDays(dirtyDate, dirtyAmount) {
|
|
33
|
-
requiredArgs(2, arguments);
|
|
34
|
-
var date = toDate(dirtyDate);
|
|
35
|
-
var amount = toInteger(dirtyAmount);
|
|
36
|
-
if (isNaN(amount)) {
|
|
37
|
-
return new Date(NaN);
|
|
38
|
-
}
|
|
39
|
-
if (!amount) {
|
|
40
|
-
// If 0 days, no-op to avoid changing times in the hour before end of DST
|
|
41
|
-
return date;
|
|
42
|
-
}
|
|
43
|
-
date.setDate(date.getDate() + amount);
|
|
44
|
-
return date;
|
|
45
|
-
}
|
|
7
|
+
import { T as Text } from './Text-98ad2e78.js';
|
|
8
|
+
import { V as VisuallyHidden } from './VisuallyHidden-fee374a8.js';
|
|
9
|
+
import { S as Surface } from './Surface-56d329b0.js';
|
|
10
|
+
import { H as Heading } from './Heading-14df0c64.js';
|
|
11
|
+
import { B as BtIconChevronRightMid } from './BtIconChevronRightMid.esm-f67f0ca3.js';
|
|
12
|
+
import { I as Icon } from './Icon-3e813b34.js';
|
|
46
13
|
|
|
47
14
|
/**
|
|
48
15
|
* @name addMonths
|
|
@@ -104,532 +71,339 @@ function addMonths(dirtyDate, dirtyAmount) {
|
|
|
104
71
|
}
|
|
105
72
|
|
|
106
73
|
/**
|
|
107
|
-
* @name
|
|
108
|
-
* @category
|
|
109
|
-
* @summary
|
|
110
|
-
*
|
|
111
|
-
* @description
|
|
112
|
-
* Return the start of a week for the given date.
|
|
113
|
-
* The result will be in the local timezone.
|
|
114
|
-
*
|
|
115
|
-
* @param {Date|Number} date - the original date
|
|
116
|
-
* @param {Object} [options] - an object with options.
|
|
117
|
-
* @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
|
|
118
|
-
* @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
|
|
119
|
-
* @returns {Date} the start of a week
|
|
120
|
-
* @throws {TypeError} 1 argument required
|
|
121
|
-
* @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* // The start of a week for 2 September 2014 11:55:00:
|
|
125
|
-
* const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0))
|
|
126
|
-
* //=> Sun Aug 31 2014 00:00:00
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* // If the week starts on Monday, the start of the week for 2 September 2014 11:55:00:
|
|
130
|
-
* const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
|
|
131
|
-
* //=> Mon Sep 01 2014 00:00:00
|
|
132
|
-
*/
|
|
133
|
-
function startOfWeek(dirtyDate, options) {
|
|
134
|
-
var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
|
|
135
|
-
requiredArgs(1, arguments);
|
|
136
|
-
var defaultOptions = getDefaultOptions();
|
|
137
|
-
var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);
|
|
138
|
-
|
|
139
|
-
// Test if weekStartsOn is between 0 and 6 _and_ is not NaN
|
|
140
|
-
if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
|
|
141
|
-
throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
|
|
142
|
-
}
|
|
143
|
-
var date = toDate(dirtyDate);
|
|
144
|
-
var day = date.getDay();
|
|
145
|
-
var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
|
|
146
|
-
date.setDate(date.getDate() - diff);
|
|
147
|
-
date.setHours(0, 0, 0, 0);
|
|
148
|
-
return date;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* @name addWeeks
|
|
153
|
-
* @category Week Helpers
|
|
154
|
-
* @summary Add the specified number of weeks to the given date.
|
|
74
|
+
* @name subMonths
|
|
75
|
+
* @category Month Helpers
|
|
76
|
+
* @summary Subtract the specified number of months from the given date.
|
|
155
77
|
*
|
|
156
78
|
* @description
|
|
157
|
-
*
|
|
79
|
+
* Subtract the specified number of months from the given date.
|
|
158
80
|
*
|
|
159
81
|
* @param {Date|Number} date - the date to be changed
|
|
160
|
-
* @param {Number} amount - the amount of
|
|
161
|
-
* @returns {Date} the new date with the
|
|
82
|
+
* @param {Number} amount - the amount of months to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
|
|
83
|
+
* @returns {Date} the new date with the months subtracted
|
|
162
84
|
* @throws {TypeError} 2 arguments required
|
|
163
85
|
*
|
|
164
86
|
* @example
|
|
165
|
-
* //
|
|
166
|
-
* const result =
|
|
167
|
-
* //=> Mon Sep
|
|
87
|
+
* // Subtract 5 months from 1 February 2015:
|
|
88
|
+
* const result = subMonths(new Date(2015, 1, 1), 5)
|
|
89
|
+
* //=> Mon Sep 01 2014 00:00:00
|
|
168
90
|
*/
|
|
169
|
-
function
|
|
91
|
+
function subMonths(dirtyDate, dirtyAmount) {
|
|
170
92
|
requiredArgs(2, arguments);
|
|
171
93
|
var amount = toInteger(dirtyAmount);
|
|
172
|
-
|
|
173
|
-
return addDays(dirtyDate, days);
|
|
94
|
+
return addMonths(dirtyDate, -amount);
|
|
174
95
|
}
|
|
175
96
|
|
|
176
97
|
/**
|
|
177
|
-
* @name
|
|
178
|
-
* @category
|
|
179
|
-
* @summary
|
|
98
|
+
* @name startOfMonth
|
|
99
|
+
* @category Month Helpers
|
|
100
|
+
* @summary Return the start of a month for the given date.
|
|
180
101
|
*
|
|
181
102
|
* @description
|
|
182
|
-
*
|
|
103
|
+
* Return the start of a month for the given date.
|
|
104
|
+
* The result will be in the local timezone.
|
|
183
105
|
*
|
|
184
|
-
* @param {Date|Number} date - the date
|
|
185
|
-
* @
|
|
186
|
-
* @
|
|
187
|
-
* @throws {TypeError} 2 arguments required
|
|
106
|
+
* @param {Date|Number} date - the original date
|
|
107
|
+
* @returns {Date} the start of a month
|
|
108
|
+
* @throws {TypeError} 1 argument required
|
|
188
109
|
*
|
|
189
110
|
* @example
|
|
190
|
-
* //
|
|
191
|
-
* const result =
|
|
192
|
-
* //=>
|
|
111
|
+
* // The start of a month for 2 September 2014 11:55:00:
|
|
112
|
+
* const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0))
|
|
113
|
+
* //=> Mon Sep 01 2014 00:00:00
|
|
193
114
|
*/
|
|
194
|
-
function
|
|
195
|
-
requiredArgs(
|
|
196
|
-
var
|
|
197
|
-
|
|
115
|
+
function startOfMonth(dirtyDate) {
|
|
116
|
+
requiredArgs(1, arguments);
|
|
117
|
+
var date = toDate(dirtyDate);
|
|
118
|
+
date.setDate(1);
|
|
119
|
+
date.setHours(0, 0, 0, 0);
|
|
120
|
+
return date;
|
|
198
121
|
}
|
|
199
122
|
|
|
123
|
+
var containsDate = function (dates, compareDate) {
|
|
124
|
+
return dates.map(function (date) { return date.getTime(); }).includes(compareDate.getTime());
|
|
125
|
+
};
|
|
126
|
+
|
|
200
127
|
/**
|
|
201
|
-
* @name
|
|
202
|
-
* @category
|
|
203
|
-
* @summary
|
|
128
|
+
* @name getMonth
|
|
129
|
+
* @category Month Helpers
|
|
130
|
+
* @summary Get the month of the given date.
|
|
204
131
|
*
|
|
205
132
|
* @description
|
|
206
|
-
*
|
|
207
|
-
* -1 if the first date is before the second or 0 if dates are equal.
|
|
208
|
-
*
|
|
209
|
-
* @param {Date|Number} dateLeft - the first date to compare
|
|
210
|
-
* @param {Date|Number} dateRight - the second date to compare
|
|
211
|
-
* @returns {Number} the result of the comparison
|
|
212
|
-
* @throws {TypeError} 2 arguments required
|
|
133
|
+
* Get the month of the given date.
|
|
213
134
|
*
|
|
214
|
-
* @
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* //=> -1
|
|
135
|
+
* @param {Date|Number} date - the given date
|
|
136
|
+
* @returns {Number} the month
|
|
137
|
+
* @throws {TypeError} 1 argument required
|
|
218
138
|
*
|
|
219
139
|
* @example
|
|
220
|
-
* //
|
|
221
|
-
* const result =
|
|
222
|
-
*
|
|
223
|
-
* new Date(1987, 1, 11),
|
|
224
|
-
* new Date(1989, 6, 10)
|
|
225
|
-
* ].sort(compareAsc)
|
|
226
|
-
* //=> [
|
|
227
|
-
* // Wed Feb 11 1987 00:00:00,
|
|
228
|
-
* // Mon Jul 10 1989 00:00:00,
|
|
229
|
-
* // Sun Jul 02 1995 00:00:00
|
|
230
|
-
* // ]
|
|
140
|
+
* // Which month is 29 February 2012?
|
|
141
|
+
* const result = getMonth(new Date(2012, 1, 29))
|
|
142
|
+
* //=> 1
|
|
231
143
|
*/
|
|
232
|
-
function
|
|
233
|
-
requiredArgs(
|
|
234
|
-
var
|
|
235
|
-
var
|
|
236
|
-
|
|
237
|
-
if (diff < 0) {
|
|
238
|
-
return -1;
|
|
239
|
-
} else if (diff > 0) {
|
|
240
|
-
return 1;
|
|
241
|
-
// Return 0 if diff is 0; return NaN if diff is NaN
|
|
242
|
-
} else {
|
|
243
|
-
return diff;
|
|
244
|
-
}
|
|
144
|
+
function getMonth(dirtyDate) {
|
|
145
|
+
requiredArgs(1, arguments);
|
|
146
|
+
var date = toDate(dirtyDate);
|
|
147
|
+
var month = date.getMonth();
|
|
148
|
+
return month;
|
|
245
149
|
}
|
|
246
150
|
|
|
247
151
|
/**
|
|
248
|
-
* @name
|
|
249
|
-
* @category
|
|
250
|
-
* @summary
|
|
152
|
+
* @name getYear
|
|
153
|
+
* @category Year Helpers
|
|
154
|
+
* @summary Get the year of the given date.
|
|
251
155
|
*
|
|
252
156
|
* @description
|
|
253
|
-
*
|
|
254
|
-
* The result will be in the local timezone.
|
|
157
|
+
* Get the year of the given date.
|
|
255
158
|
*
|
|
256
|
-
* @param {Date|Number} date - the
|
|
257
|
-
* @returns {
|
|
159
|
+
* @param {Date|Number} date - the given date
|
|
160
|
+
* @returns {Number} the year
|
|
258
161
|
* @throws {TypeError} 1 argument required
|
|
259
162
|
*
|
|
260
163
|
* @example
|
|
261
|
-
* //
|
|
262
|
-
* const result =
|
|
263
|
-
* //=>
|
|
164
|
+
* // Which year is 2 July 2014?
|
|
165
|
+
* const result = getYear(new Date(2014, 6, 2))
|
|
166
|
+
* //=> 2014
|
|
264
167
|
*/
|
|
265
|
-
function
|
|
168
|
+
function getYear(dirtyDate) {
|
|
266
169
|
requiredArgs(1, arguments);
|
|
267
|
-
|
|
268
|
-
date.setHours(23, 59, 59, 999);
|
|
269
|
-
return date;
|
|
170
|
+
return toDate(dirtyDate).getFullYear();
|
|
270
171
|
}
|
|
271
172
|
|
|
272
173
|
/**
|
|
273
|
-
* @name
|
|
174
|
+
* @name getDaysInMonth
|
|
274
175
|
* @category Month Helpers
|
|
275
|
-
* @summary
|
|
176
|
+
* @summary Get the number of days in a month of the given date.
|
|
276
177
|
*
|
|
277
178
|
* @description
|
|
278
|
-
*
|
|
279
|
-
* The result will be in the local timezone.
|
|
179
|
+
* Get the number of days in a month of the given date.
|
|
280
180
|
*
|
|
281
|
-
* @param {Date|Number} date - the
|
|
282
|
-
* @returns {
|
|
181
|
+
* @param {Date|Number} date - the given date
|
|
182
|
+
* @returns {Number} the number of days in a month
|
|
283
183
|
* @throws {TypeError} 1 argument required
|
|
284
184
|
*
|
|
285
185
|
* @example
|
|
286
|
-
* //
|
|
287
|
-
* const result =
|
|
288
|
-
* //=>
|
|
186
|
+
* // How many days are in February 2000?
|
|
187
|
+
* const result = getDaysInMonth(new Date(2000, 1))
|
|
188
|
+
* //=> 29
|
|
289
189
|
*/
|
|
290
|
-
function
|
|
190
|
+
function getDaysInMonth(dirtyDate) {
|
|
291
191
|
requiredArgs(1, arguments);
|
|
292
192
|
var date = toDate(dirtyDate);
|
|
293
|
-
var
|
|
294
|
-
date.
|
|
295
|
-
|
|
296
|
-
|
|
193
|
+
var year = date.getFullYear();
|
|
194
|
+
var monthIndex = date.getMonth();
|
|
195
|
+
var lastDayOfMonth = new Date(0);
|
|
196
|
+
lastDayOfMonth.setFullYear(year, monthIndex + 1, 0);
|
|
197
|
+
lastDayOfMonth.setHours(0, 0, 0, 0);
|
|
198
|
+
return lastDayOfMonth.getDate();
|
|
297
199
|
}
|
|
298
200
|
|
|
299
201
|
/**
|
|
300
|
-
* @name
|
|
202
|
+
* @name setMonth
|
|
301
203
|
* @category Month Helpers
|
|
302
|
-
* @summary
|
|
204
|
+
* @summary Set the month to the given date.
|
|
303
205
|
*
|
|
304
206
|
* @description
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
* @param {Date|Number} date - the date to check
|
|
308
|
-
* @returns {Boolean} the date is the last day of a month
|
|
309
|
-
* @throws {TypeError} 1 argument required
|
|
207
|
+
* Set the month to the given date.
|
|
310
208
|
*
|
|
311
|
-
* @
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
209
|
+
* @param {Date|Number} date - the date to be changed
|
|
210
|
+
* @param {Number} month - the month of the new date
|
|
211
|
+
* @returns {Date} the new date with the month set
|
|
212
|
+
* @throws {TypeError} 2 arguments required
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* // Set February to 1 September 2014:
|
|
216
|
+
* const result = setMonth(new Date(2014, 8, 1), 1)
|
|
217
|
+
* //=> Sat Feb 01 2014 00:00:00
|
|
315
218
|
*/
|
|
316
|
-
function
|
|
317
|
-
requiredArgs(
|
|
219
|
+
function setMonth(dirtyDate, dirtyMonth) {
|
|
220
|
+
requiredArgs(2, arguments);
|
|
318
221
|
var date = toDate(dirtyDate);
|
|
319
|
-
|
|
222
|
+
var month = toInteger(dirtyMonth);
|
|
223
|
+
var year = date.getFullYear();
|
|
224
|
+
var day = date.getDate();
|
|
225
|
+
var dateWithDesiredMonth = new Date(0);
|
|
226
|
+
dateWithDesiredMonth.setFullYear(year, month, 15);
|
|
227
|
+
dateWithDesiredMonth.setHours(0, 0, 0, 0);
|
|
228
|
+
var daysInMonth = getDaysInMonth(dateWithDesiredMonth);
|
|
229
|
+
// Set the last day of the new month
|
|
230
|
+
// if the original date was the last day of the longer month
|
|
231
|
+
date.setMonth(month, Math.min(day, daysInMonth));
|
|
232
|
+
return date;
|
|
320
233
|
}
|
|
321
234
|
|
|
322
235
|
/**
|
|
323
|
-
* @name
|
|
324
|
-
* @category
|
|
325
|
-
* @summary
|
|
236
|
+
* @name set
|
|
237
|
+
* @category Common Helpers
|
|
238
|
+
* @summary Set date values to a given date.
|
|
326
239
|
*
|
|
327
240
|
* @description
|
|
328
|
-
*
|
|
241
|
+
* Set date values to a given date.
|
|
329
242
|
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
* @param {Number} [options.step=1] - the step to increment by. The value should be more than 1.
|
|
333
|
-
* @returns {Date[]} the array with starts of days from the day of the interval start to the day of the interval end
|
|
334
|
-
* @throws {TypeError} 1 argument required
|
|
335
|
-
* @throws {RangeError} `options.step` must be a number greater than 1
|
|
336
|
-
* @throws {RangeError} The start of an interval cannot be after its end
|
|
337
|
-
* @throws {RangeError} Date in interval cannot be `Invalid Date`
|
|
243
|
+
* Sets time values to date from object `values`.
|
|
244
|
+
* A value is not set if it is undefined or null or doesn't exist in `values`.
|
|
338
245
|
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
* start: new Date(2014, 9, 6),
|
|
343
|
-
* end: new Date(2014, 9, 10)
|
|
344
|
-
* })
|
|
345
|
-
* //=> [
|
|
346
|
-
* // Mon Oct 06 2014 00:00:00,
|
|
347
|
-
* // Tue Oct 07 2014 00:00:00,
|
|
348
|
-
* // Wed Oct 08 2014 00:00:00,
|
|
349
|
-
* // Thu Oct 09 2014 00:00:00,
|
|
350
|
-
* // Fri Oct 10 2014 00:00:00
|
|
351
|
-
* // ]
|
|
352
|
-
*/
|
|
353
|
-
function eachDayOfInterval(dirtyInterval, options) {
|
|
354
|
-
var _options$step;
|
|
355
|
-
requiredArgs(1, arguments);
|
|
356
|
-
var interval = dirtyInterval || {};
|
|
357
|
-
var startDate = toDate(interval.start);
|
|
358
|
-
var endDate = toDate(interval.end);
|
|
359
|
-
var endTime = endDate.getTime();
|
|
360
|
-
|
|
361
|
-
// Throw an exception if start date is after end date or if any date is `Invalid Date`
|
|
362
|
-
if (!(startDate.getTime() <= endTime)) {
|
|
363
|
-
throw new RangeError('Invalid interval');
|
|
364
|
-
}
|
|
365
|
-
var dates = [];
|
|
366
|
-
var currentDate = startDate;
|
|
367
|
-
currentDate.setHours(0, 0, 0, 0);
|
|
368
|
-
var step = Number((_options$step = options === null || options === void 0 ? void 0 : options.step) !== null && _options$step !== void 0 ? _options$step : 1);
|
|
369
|
-
if (step < 1 || isNaN(step)) throw new RangeError('`options.step` must be a number greater than 1');
|
|
370
|
-
while (currentDate.getTime() <= endTime) {
|
|
371
|
-
dates.push(toDate(currentDate));
|
|
372
|
-
currentDate.setDate(currentDate.getDate() + step);
|
|
373
|
-
currentDate.setHours(0, 0, 0, 0);
|
|
374
|
-
}
|
|
375
|
-
return dates;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* @name eachWeekOfInterval
|
|
380
|
-
* @category Interval Helpers
|
|
381
|
-
* @summary Return the array of weeks within the specified time interval.
|
|
246
|
+
* Note about bundle size: `set` does not internally use `setX` functions from date-fns but instead opts
|
|
247
|
+
* to use native `Date#setX` methods. If you use this function, you may not want to include the
|
|
248
|
+
* other `setX` functions that date-fns provides if you are concerned about the bundle size.
|
|
382
249
|
*
|
|
383
|
-
* @
|
|
384
|
-
*
|
|
250
|
+
* @param {Date|Number} date - the date to be changed
|
|
251
|
+
* @param {Object} values - an object with options
|
|
252
|
+
* @param {Number} [values.year] - the number of years to be set
|
|
253
|
+
* @param {Number} [values.month] - the number of months to be set
|
|
254
|
+
* @param {Number} [values.date] - the number of days to be set
|
|
255
|
+
* @param {Number} [values.hours] - the number of hours to be set
|
|
256
|
+
* @param {Number} [values.minutes] - the number of minutes to be set
|
|
257
|
+
* @param {Number} [values.seconds] - the number of seconds to be set
|
|
258
|
+
* @param {Number} [values.milliseconds] - the number of milliseconds to be set
|
|
259
|
+
* @returns {Date} the new date with options set
|
|
260
|
+
* @throws {TypeError} 2 arguments required
|
|
261
|
+
* @throws {RangeError} `values` must be an object
|
|
385
262
|
*
|
|
386
|
-
* @
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
* @returns {Date[]} the array with starts of weeks from the week of the interval start to the week of the interval end
|
|
391
|
-
* @throws {TypeError} 1 argument required
|
|
392
|
-
* @throws {RangeError} `options.weekStartsOn` must be 0, 1, ..., 6
|
|
393
|
-
* @throws {RangeError} The start of an interval cannot be after its end
|
|
394
|
-
* @throws {RangeError} Date in interval cannot be `Invalid Date`
|
|
263
|
+
* @example
|
|
264
|
+
* // Transform 1 September 2014 into 20 October 2015 in a single line:
|
|
265
|
+
* const result = set(new Date(2014, 8, 20), { year: 2015, month: 9, date: 20 })
|
|
266
|
+
* //=> Tue Oct 20 2015 00:00:00
|
|
395
267
|
*
|
|
396
268
|
* @example
|
|
397
|
-
* //
|
|
398
|
-
* const result =
|
|
399
|
-
*
|
|
400
|
-
* end: new Date(2014, 10, 23)
|
|
401
|
-
* })
|
|
402
|
-
* //=> [
|
|
403
|
-
* // Sun Oct 05 2014 00:00:00,
|
|
404
|
-
* // Sun Oct 12 2014 00:00:00,
|
|
405
|
-
* // Sun Oct 19 2014 00:00:00,
|
|
406
|
-
* // Sun Oct 26 2014 00:00:00,
|
|
407
|
-
* // Sun Nov 02 2014 00:00:00,
|
|
408
|
-
* // Sun Nov 09 2014 00:00:00,
|
|
409
|
-
* // Sun Nov 16 2014 00:00:00,
|
|
410
|
-
* // Sun Nov 23 2014 00:00:00
|
|
411
|
-
* // ]
|
|
269
|
+
* // Set 12 PM to 1 September 2014 01:23:45 to 1 September 2014 12:00:00:
|
|
270
|
+
* const result = set(new Date(2014, 8, 1, 1, 23, 45), { hours: 12 })
|
|
271
|
+
* //=> Mon Sep 01 2014 12:23:45
|
|
412
272
|
*/
|
|
413
|
-
function
|
|
414
|
-
requiredArgs(
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
var endDate = toDate(interval.end);
|
|
418
|
-
var endTime = endDate.getTime();
|
|
419
|
-
|
|
420
|
-
// Throw an exception if start date is after end date or if any date is `Invalid Date`
|
|
421
|
-
if (!(startDate.getTime() <= endTime)) {
|
|
422
|
-
throw new RangeError('Invalid interval');
|
|
273
|
+
function set(dirtyDate, values) {
|
|
274
|
+
requiredArgs(2, arguments);
|
|
275
|
+
if (_typeof(values) !== 'object' || values === null) {
|
|
276
|
+
throw new RangeError('values parameter must be an object');
|
|
423
277
|
}
|
|
424
|
-
var
|
|
425
|
-
var endDateWeek = startOfWeek(endDate, options);
|
|
278
|
+
var date = toDate(dirtyDate);
|
|
426
279
|
|
|
427
|
-
//
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
endTime = endDateWeek.getTime();
|
|
431
|
-
var weeks = [];
|
|
432
|
-
var currentWeek = startDateWeek;
|
|
433
|
-
while (currentWeek.getTime() <= endTime) {
|
|
434
|
-
currentWeek.setHours(0);
|
|
435
|
-
weeks.push(toDate(currentWeek));
|
|
436
|
-
currentWeek = addWeeks(currentWeek, 1);
|
|
437
|
-
currentWeek.setHours(15);
|
|
280
|
+
// Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date
|
|
281
|
+
if (isNaN(date.getTime())) {
|
|
282
|
+
return new Date(NaN);
|
|
438
283
|
}
|
|
439
|
-
|
|
284
|
+
if (values.year != null) {
|
|
285
|
+
date.setFullYear(values.year);
|
|
286
|
+
}
|
|
287
|
+
if (values.month != null) {
|
|
288
|
+
date = setMonth(date, values.month);
|
|
289
|
+
}
|
|
290
|
+
if (values.date != null) {
|
|
291
|
+
date.setDate(toInteger(values.date));
|
|
292
|
+
}
|
|
293
|
+
if (values.hours != null) {
|
|
294
|
+
date.setHours(toInteger(values.hours));
|
|
295
|
+
}
|
|
296
|
+
if (values.minutes != null) {
|
|
297
|
+
date.setMinutes(toInteger(values.minutes));
|
|
298
|
+
}
|
|
299
|
+
if (values.seconds != null) {
|
|
300
|
+
date.setSeconds(toInteger(values.seconds));
|
|
301
|
+
}
|
|
302
|
+
if (values.milliseconds != null) {
|
|
303
|
+
date.setMilliseconds(toInteger(values.milliseconds));
|
|
304
|
+
}
|
|
305
|
+
return date;
|
|
440
306
|
}
|
|
441
307
|
|
|
308
|
+
var dateWithoutTime = function (date) {
|
|
309
|
+
return set(new Date(date), {
|
|
310
|
+
hours: 0,
|
|
311
|
+
minutes: 0,
|
|
312
|
+
milliseconds: 0,
|
|
313
|
+
seconds: 0
|
|
314
|
+
});
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
var getDatesInMonth = function (date) {
|
|
318
|
+
var dateYear = getYear(date);
|
|
319
|
+
var dateMonth = getMonth(date);
|
|
320
|
+
return Array.from({ length: getDaysInMonth(date) }, function (_, i) {
|
|
321
|
+
return dateWithoutTime(new Date(dateYear, dateMonth, i + 1));
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
|
|
442
325
|
/**
|
|
443
|
-
* @name
|
|
444
|
-
* @category
|
|
445
|
-
* @summary
|
|
326
|
+
* @name getDay
|
|
327
|
+
* @category Weekday Helpers
|
|
328
|
+
* @summary Get the day of the week of the given date.
|
|
446
329
|
*
|
|
447
330
|
* @description
|
|
448
|
-
*
|
|
449
|
-
* The result will be in the local timezone.
|
|
331
|
+
* Get the day of the week of the given date.
|
|
450
332
|
*
|
|
451
|
-
* @param {Date|Number} date - the
|
|
452
|
-
* @returns {
|
|
333
|
+
* @param {Date|Number} date - the given date
|
|
334
|
+
* @returns {0|1|2|3|4|5|6} the day of week, 0 represents Sunday
|
|
453
335
|
* @throws {TypeError} 1 argument required
|
|
454
336
|
*
|
|
455
337
|
* @example
|
|
456
|
-
* //
|
|
457
|
-
* const result =
|
|
458
|
-
* //=>
|
|
338
|
+
* // Which day of the week is 29 February 2012?
|
|
339
|
+
* const result = getDay(new Date(2012, 1, 29))
|
|
340
|
+
* //=> 3
|
|
459
341
|
*/
|
|
460
|
-
function
|
|
342
|
+
function getDay(dirtyDate) {
|
|
461
343
|
requiredArgs(1, arguments);
|
|
462
344
|
var date = toDate(dirtyDate);
|
|
463
|
-
date.
|
|
464
|
-
|
|
465
|
-
return date;
|
|
345
|
+
var day = date.getDay();
|
|
346
|
+
return day;
|
|
466
347
|
}
|
|
467
348
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
* //=> Sat Sep 06 2014 23:59:59.999
|
|
489
|
-
*
|
|
490
|
-
* @example
|
|
491
|
-
* // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00:
|
|
492
|
-
* const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
|
|
493
|
-
* //=> Sun Sep 07 2014 23:59:59.999
|
|
494
|
-
*/
|
|
495
|
-
function endOfWeek(dirtyDate, options) {
|
|
496
|
-
var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
|
|
497
|
-
requiredArgs(1, arguments);
|
|
498
|
-
var defaultOptions = getDefaultOptions();
|
|
499
|
-
var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);
|
|
500
|
-
|
|
501
|
-
// Test if weekStartsOn is between 0 and 6 _and_ is not NaN
|
|
502
|
-
if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
|
|
503
|
-
throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
|
|
504
|
-
}
|
|
505
|
-
var date = toDate(dirtyDate);
|
|
506
|
-
var day = date.getDay();
|
|
507
|
-
var diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn);
|
|
508
|
-
date.setDate(date.getDate() + diff);
|
|
509
|
-
date.setHours(23, 59, 59, 999);
|
|
510
|
-
return date;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
/**
|
|
514
|
-
* @name getDate
|
|
515
|
-
* @category Day Helpers
|
|
516
|
-
* @summary Get the day of the month of the given date.
|
|
517
|
-
*
|
|
518
|
-
* @description
|
|
519
|
-
* Get the day of the month of the given date.
|
|
520
|
-
*
|
|
521
|
-
* @param {Date|Number} date - the given date
|
|
522
|
-
* @returns {Number} the day of month
|
|
523
|
-
* @throws {TypeError} 1 argument required
|
|
524
|
-
*
|
|
525
|
-
* @example
|
|
526
|
-
* // Which day of the month is 29 February 2012?
|
|
527
|
-
* const result = getDate(new Date(2012, 1, 29))
|
|
528
|
-
* //=> 29
|
|
529
|
-
*/
|
|
530
|
-
function getDate(dirtyDate) {
|
|
531
|
-
requiredArgs(1, arguments);
|
|
532
|
-
var date = toDate(dirtyDate);
|
|
533
|
-
var dayOfMonth = date.getDate();
|
|
534
|
-
return dayOfMonth;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
/**
|
|
538
|
-
* @name getDay
|
|
539
|
-
* @category Weekday Helpers
|
|
540
|
-
* @summary Get the day of the week of the given date.
|
|
541
|
-
*
|
|
542
|
-
* @description
|
|
543
|
-
* Get the day of the week of the given date.
|
|
544
|
-
*
|
|
545
|
-
* @param {Date|Number} date - the given date
|
|
546
|
-
* @returns {0|1|2|3|4|5|6} the day of week, 0 represents Sunday
|
|
547
|
-
* @throws {TypeError} 1 argument required
|
|
548
|
-
*
|
|
549
|
-
* @example
|
|
550
|
-
* // Which day of the week is 29 February 2012?
|
|
551
|
-
* const result = getDay(new Date(2012, 1, 29))
|
|
552
|
-
* //=> 3
|
|
553
|
-
*/
|
|
554
|
-
function getDay(dirtyDate) {
|
|
555
|
-
requiredArgs(1, arguments);
|
|
556
|
-
var date = toDate(dirtyDate);
|
|
557
|
-
var day = date.getDay();
|
|
558
|
-
return day;
|
|
559
|
-
}
|
|
349
|
+
var WeekDaysAbbr;
|
|
350
|
+
(function (WeekDaysAbbr) {
|
|
351
|
+
WeekDaysAbbr["MON"] = "Mon";
|
|
352
|
+
WeekDaysAbbr["TUE"] = "Tue";
|
|
353
|
+
WeekDaysAbbr["WED"] = "Wed";
|
|
354
|
+
WeekDaysAbbr["THUR"] = "Thur";
|
|
355
|
+
WeekDaysAbbr["FRI"] = "Fri";
|
|
356
|
+
WeekDaysAbbr["SAT"] = "Sat";
|
|
357
|
+
WeekDaysAbbr["SUN"] = "Sun";
|
|
358
|
+
})(WeekDaysAbbr || (WeekDaysAbbr = {}));
|
|
359
|
+
var WeekDays;
|
|
360
|
+
(function (WeekDays) {
|
|
361
|
+
WeekDays["MONDAY"] = "Monday";
|
|
362
|
+
WeekDays["TUESDAY"] = "Tuesday";
|
|
363
|
+
WeekDays["WEDNESDAY"] = "Wednesday";
|
|
364
|
+
WeekDays["THURSDAY"] = "Thursday";
|
|
365
|
+
WeekDays["FRIDAY"] = "Friday";
|
|
366
|
+
WeekDays["SATURDAY"] = "Saturday";
|
|
367
|
+
WeekDays["SUNDAY"] = "Sunday";
|
|
368
|
+
})(WeekDays || (WeekDays = {}));
|
|
560
369
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
* // How many days are in February 2000?
|
|
575
|
-
* const result = getDaysInMonth(new Date(2000, 1))
|
|
576
|
-
* //=> 29
|
|
577
|
-
*/
|
|
578
|
-
function getDaysInMonth(dirtyDate) {
|
|
579
|
-
requiredArgs(1, arguments);
|
|
580
|
-
var date = toDate(dirtyDate);
|
|
581
|
-
var year = date.getFullYear();
|
|
582
|
-
var monthIndex = date.getMonth();
|
|
583
|
-
var lastDayOfMonth = new Date(0);
|
|
584
|
-
lastDayOfMonth.setFullYear(year, monthIndex + 1, 0);
|
|
585
|
-
lastDayOfMonth.setHours(0, 0, 0, 0);
|
|
586
|
-
return lastDayOfMonth.getDate();
|
|
587
|
-
}
|
|
370
|
+
var isDay = function (date, day) {
|
|
371
|
+
var _a;
|
|
372
|
+
var dayMap = (_a = {},
|
|
373
|
+
_a[WeekDays.MONDAY] = 1,
|
|
374
|
+
_a[WeekDays.TUESDAY] = 2,
|
|
375
|
+
_a[WeekDays.WEDNESDAY] = 3,
|
|
376
|
+
_a[WeekDays.THURSDAY] = 4,
|
|
377
|
+
_a[WeekDays.FRIDAY] = 5,
|
|
378
|
+
_a[WeekDays.SATURDAY] = 6,
|
|
379
|
+
_a[WeekDays.SUNDAY] = 0,
|
|
380
|
+
_a);
|
|
381
|
+
return getDay(date) === dayMap[day];
|
|
382
|
+
};
|
|
588
383
|
|
|
589
384
|
/**
|
|
590
|
-
* @name
|
|
591
|
-
* @category
|
|
592
|
-
* @summary
|
|
385
|
+
* @name isBefore
|
|
386
|
+
* @category Common Helpers
|
|
387
|
+
* @summary Is the first date before the second one?
|
|
593
388
|
*
|
|
594
389
|
* @description
|
|
595
|
-
*
|
|
390
|
+
* Is the first date before the second one?
|
|
596
391
|
*
|
|
597
|
-
* @param {Date|Number} date - the
|
|
598
|
-
* @
|
|
599
|
-
* @
|
|
392
|
+
* @param {Date|Number} date - the date that should be before the other one to return true
|
|
393
|
+
* @param {Date|Number} dateToCompare - the date to compare with
|
|
394
|
+
* @returns {Boolean} the first date is before the second date
|
|
395
|
+
* @throws {TypeError} 2 arguments required
|
|
600
396
|
*
|
|
601
397
|
* @example
|
|
602
|
-
* //
|
|
603
|
-
* const result =
|
|
604
|
-
* //=>
|
|
398
|
+
* // Is 10 July 1989 before 11 February 1987?
|
|
399
|
+
* const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
|
|
400
|
+
* //=> false
|
|
605
401
|
*/
|
|
606
|
-
function
|
|
607
|
-
requiredArgs(
|
|
402
|
+
function isBefore(dirtyDate, dirtyDateToCompare) {
|
|
403
|
+
requiredArgs(2, arguments);
|
|
608
404
|
var date = toDate(dirtyDate);
|
|
609
|
-
var
|
|
610
|
-
return
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
/**
|
|
614
|
-
* @name getYear
|
|
615
|
-
* @category Year Helpers
|
|
616
|
-
* @summary Get the year of the given date.
|
|
617
|
-
*
|
|
618
|
-
* @description
|
|
619
|
-
* Get the year of the given date.
|
|
620
|
-
*
|
|
621
|
-
* @param {Date|Number} date - the given date
|
|
622
|
-
* @returns {Number} the year
|
|
623
|
-
* @throws {TypeError} 1 argument required
|
|
624
|
-
*
|
|
625
|
-
* @example
|
|
626
|
-
* // Which year is 2 July 2014?
|
|
627
|
-
* const result = getYear(new Date(2014, 6, 2))
|
|
628
|
-
* //=> 2014
|
|
629
|
-
*/
|
|
630
|
-
function getYear(dirtyDate) {
|
|
631
|
-
requiredArgs(1, arguments);
|
|
632
|
-
return toDate(dirtyDate).getFullYear();
|
|
405
|
+
var dateToCompare = toDate(dirtyDateToCompare);
|
|
406
|
+
return date.getTime() < dateToCompare.getTime();
|
|
633
407
|
}
|
|
634
408
|
|
|
635
409
|
/**
|
|
@@ -657,161 +431,258 @@ function isAfter(dirtyDate, dirtyDateToCompare) {
|
|
|
657
431
|
return date.getTime() > dateToCompare.getTime();
|
|
658
432
|
}
|
|
659
433
|
|
|
434
|
+
var isDisabledDate = function (date, disabledDates, minDate, maxDate) {
|
|
435
|
+
return ((minDate && isBefore(date, minDate)) ||
|
|
436
|
+
(maxDate && isAfter(date, maxDate)) ||
|
|
437
|
+
(disabledDates && containsDate(disabledDates, date)));
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
var isMonthBeforeMinDate = function (month, minDate) {
|
|
441
|
+
return getDatesInMonth(month).every(function (date) {
|
|
442
|
+
return isBefore(date, minDate);
|
|
443
|
+
});
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
var isMonthAfterMaxDate = function (date, maxDate) {
|
|
447
|
+
return getDatesInMonth(date).every(function (date) {
|
|
448
|
+
return isAfter(date, maxDate);
|
|
449
|
+
});
|
|
450
|
+
};
|
|
451
|
+
|
|
660
452
|
/**
|
|
661
|
-
* @name
|
|
453
|
+
* @name compareAsc
|
|
662
454
|
* @category Common Helpers
|
|
663
|
-
* @summary
|
|
455
|
+
* @summary Compare the two dates and return -1, 0 or 1.
|
|
664
456
|
*
|
|
665
457
|
* @description
|
|
666
|
-
*
|
|
458
|
+
* Compare the two dates and return 1 if the first date is after the second,
|
|
459
|
+
* -1 if the first date is before the second or 0 if dates are equal.
|
|
667
460
|
*
|
|
668
|
-
* @param {Date|Number}
|
|
669
|
-
* @param {Date|Number}
|
|
670
|
-
* @returns {
|
|
461
|
+
* @param {Date|Number} dateLeft - the first date to compare
|
|
462
|
+
* @param {Date|Number} dateRight - the second date to compare
|
|
463
|
+
* @returns {Number} the result of the comparison
|
|
671
464
|
* @throws {TypeError} 2 arguments required
|
|
672
465
|
*
|
|
673
466
|
* @example
|
|
674
|
-
* //
|
|
675
|
-
* const result =
|
|
676
|
-
* //=>
|
|
467
|
+
* // Compare 11 February 1987 and 10 July 1989:
|
|
468
|
+
* const result = compareAsc(new Date(1987, 1, 11), new Date(1989, 6, 10))
|
|
469
|
+
* //=> -1
|
|
470
|
+
*
|
|
471
|
+
* @example
|
|
472
|
+
* // Sort the array of dates:
|
|
473
|
+
* const result = [
|
|
474
|
+
* new Date(1995, 6, 2),
|
|
475
|
+
* new Date(1987, 1, 11),
|
|
476
|
+
* new Date(1989, 6, 10)
|
|
477
|
+
* ].sort(compareAsc)
|
|
478
|
+
* //=> [
|
|
479
|
+
* // Wed Feb 11 1987 00:00:00,
|
|
480
|
+
* // Mon Jul 10 1989 00:00:00,
|
|
481
|
+
* // Sun Jul 02 1995 00:00:00
|
|
482
|
+
* // ]
|
|
677
483
|
*/
|
|
678
|
-
function
|
|
484
|
+
function compareAsc(dirtyDateLeft, dirtyDateRight) {
|
|
679
485
|
requiredArgs(2, arguments);
|
|
680
|
-
var
|
|
681
|
-
var
|
|
682
|
-
|
|
486
|
+
var dateLeft = toDate(dirtyDateLeft);
|
|
487
|
+
var dateRight = toDate(dirtyDateRight);
|
|
488
|
+
var diff = dateLeft.getTime() - dateRight.getTime();
|
|
489
|
+
if (diff < 0) {
|
|
490
|
+
return -1;
|
|
491
|
+
} else if (diff > 0) {
|
|
492
|
+
return 1;
|
|
493
|
+
// Return 0 if diff is 0; return NaN if diff is NaN
|
|
494
|
+
} else {
|
|
495
|
+
return diff;
|
|
496
|
+
}
|
|
683
497
|
}
|
|
684
498
|
|
|
685
499
|
/**
|
|
686
|
-
* @name
|
|
687
|
-
* @category
|
|
688
|
-
* @summary
|
|
500
|
+
* @name eachDayOfInterval
|
|
501
|
+
* @category Interval Helpers
|
|
502
|
+
* @summary Return the array of dates within the specified time interval.
|
|
689
503
|
*
|
|
690
504
|
* @description
|
|
691
|
-
*
|
|
505
|
+
* Return the array of dates within the specified time interval.
|
|
692
506
|
*
|
|
693
|
-
* @param {
|
|
694
|
-
* @param {
|
|
695
|
-
* @
|
|
696
|
-
* @
|
|
697
|
-
*
|
|
698
|
-
* @example
|
|
699
|
-
* // Are 2 July 2014 06:30:45.000 and 2 July 2014 06:30:45.500 equal?
|
|
700
|
-
* const result = isEqual(
|
|
701
|
-
* new Date(2014, 6, 2, 6, 30, 45, 0),
|
|
702
|
-
* new Date(2014, 6, 2, 6, 30, 45, 500)
|
|
703
|
-
* )
|
|
704
|
-
* //=> false
|
|
705
|
-
*/
|
|
706
|
-
function isEqual(dirtyLeftDate, dirtyRightDate) {
|
|
707
|
-
requiredArgs(2, arguments);
|
|
708
|
-
var dateLeft = toDate(dirtyLeftDate);
|
|
709
|
-
var dateRight = toDate(dirtyRightDate);
|
|
710
|
-
return dateLeft.getTime() === dateRight.getTime();
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
/**
|
|
714
|
-
* @name isFirstDayOfMonth
|
|
715
|
-
* @category Month Helpers
|
|
716
|
-
* @summary Is the given date the first day of a month?
|
|
717
|
-
*
|
|
718
|
-
* @description
|
|
719
|
-
* Is the given date the first day of a month?
|
|
720
|
-
*
|
|
721
|
-
* @param {Date|Number} date - the date to check
|
|
722
|
-
* @returns {Boolean} the date is the first day of a month
|
|
507
|
+
* @param {Interval} interval - the interval. See [Interval]{@link https://date-fns.org/docs/Interval}
|
|
508
|
+
* @param {Object} [options] - an object with options.
|
|
509
|
+
* @param {Number} [options.step=1] - the step to increment by. The value should be more than 1.
|
|
510
|
+
* @returns {Date[]} the array with starts of days from the day of the interval start to the day of the interval end
|
|
723
511
|
* @throws {TypeError} 1 argument required
|
|
512
|
+
* @throws {RangeError} `options.step` must be a number greater than 1
|
|
513
|
+
* @throws {RangeError} The start of an interval cannot be after its end
|
|
514
|
+
* @throws {RangeError} Date in interval cannot be `Invalid Date`
|
|
724
515
|
*
|
|
725
516
|
* @example
|
|
726
|
-
* //
|
|
727
|
-
* const result =
|
|
728
|
-
*
|
|
517
|
+
* // Each day between 6 October 2014 and 10 October 2014:
|
|
518
|
+
* const result = eachDayOfInterval({
|
|
519
|
+
* start: new Date(2014, 9, 6),
|
|
520
|
+
* end: new Date(2014, 9, 10)
|
|
521
|
+
* })
|
|
522
|
+
* //=> [
|
|
523
|
+
* // Mon Oct 06 2014 00:00:00,
|
|
524
|
+
* // Tue Oct 07 2014 00:00:00,
|
|
525
|
+
* // Wed Oct 08 2014 00:00:00,
|
|
526
|
+
* // Thu Oct 09 2014 00:00:00,
|
|
527
|
+
* // Fri Oct 10 2014 00:00:00
|
|
528
|
+
* // ]
|
|
729
529
|
*/
|
|
730
|
-
function
|
|
530
|
+
function eachDayOfInterval(dirtyInterval, options) {
|
|
531
|
+
var _options$step;
|
|
731
532
|
requiredArgs(1, arguments);
|
|
732
|
-
|
|
533
|
+
var interval = dirtyInterval || {};
|
|
534
|
+
var startDate = toDate(interval.start);
|
|
535
|
+
var endDate = toDate(interval.end);
|
|
536
|
+
var endTime = endDate.getTime();
|
|
537
|
+
|
|
538
|
+
// Throw an exception if start date is after end date or if any date is `Invalid Date`
|
|
539
|
+
if (!(startDate.getTime() <= endTime)) {
|
|
540
|
+
throw new RangeError('Invalid interval');
|
|
541
|
+
}
|
|
542
|
+
var dates = [];
|
|
543
|
+
var currentDate = startDate;
|
|
544
|
+
currentDate.setHours(0, 0, 0, 0);
|
|
545
|
+
var step = Number((_options$step = options === null || options === void 0 ? void 0 : options.step) !== null && _options$step !== void 0 ? _options$step : 1);
|
|
546
|
+
if (step < 1 || isNaN(step)) throw new RangeError('`options.step` must be a number greater than 1');
|
|
547
|
+
while (currentDate.getTime() <= endTime) {
|
|
548
|
+
dates.push(toDate(currentDate));
|
|
549
|
+
currentDate.setDate(currentDate.getDate() + step);
|
|
550
|
+
currentDate.setHours(0, 0, 0, 0);
|
|
551
|
+
}
|
|
552
|
+
return dates;
|
|
733
553
|
}
|
|
734
554
|
|
|
555
|
+
var processSelectedRange = function (_a) {
|
|
556
|
+
var range = _a.range, value = _a.value, disabledDates = _a.disabledDates;
|
|
557
|
+
var exisitingRange = range.filter(function (date) { return Boolean(date); });
|
|
558
|
+
var newRange = __spreadArray(__spreadArray([], (exisitingRange.length === 2 ? [] : exisitingRange), true), [
|
|
559
|
+
value,
|
|
560
|
+
], false).sort(compareAsc);
|
|
561
|
+
var isSelectionComplete = newRange.length === 2;
|
|
562
|
+
var allDaysInRange = isSelectionComplete
|
|
563
|
+
? eachDayOfInterval({
|
|
564
|
+
start: newRange[0],
|
|
565
|
+
end: newRange[1]
|
|
566
|
+
})
|
|
567
|
+
: [];
|
|
568
|
+
var rangeOnChangeValue = {
|
|
569
|
+
dates: allDaysInRange.map(function (date) { return ({
|
|
570
|
+
value: date,
|
|
571
|
+
disabled: disabledDates ? containsDate(disabledDates, date) : false
|
|
572
|
+
}); }),
|
|
573
|
+
selectedDate: value,
|
|
574
|
+
start: newRange[0],
|
|
575
|
+
end: newRange[1],
|
|
576
|
+
isSelectionComplete: isSelectionComplete
|
|
577
|
+
};
|
|
578
|
+
return {
|
|
579
|
+
rangeValue: newRange,
|
|
580
|
+
rangeOnChangeValue: rangeOnChangeValue
|
|
581
|
+
};
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
var getCalendarType = function (type, isDesktop) {
|
|
585
|
+
if (type === "double" && !isDesktop) {
|
|
586
|
+
return "month";
|
|
587
|
+
}
|
|
588
|
+
if (type === "double" && isDesktop) {
|
|
589
|
+
return "double";
|
|
590
|
+
}
|
|
591
|
+
return type;
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
var getDoubleMonthDisplayRange = function (date) {
|
|
595
|
+
var firstMonth = getMonth(date) % 2 !== 0 ? subMonths(date, 1) : date;
|
|
596
|
+
var secondMonth = addMonths(firstMonth, 1);
|
|
597
|
+
return [firstMonth, secondMonth];
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
var getFocusDate = function (_a) {
|
|
601
|
+
var minDate = _a.minDate, maxDate = _a.maxDate, date = _a.date;
|
|
602
|
+
var isFocusDateBeforeMinDate = minDate && isBefore(date, minDate);
|
|
603
|
+
var isFocusDateAfterMaxDate = maxDate && isAfter(date, maxDate);
|
|
604
|
+
if (isFocusDateBeforeMinDate) {
|
|
605
|
+
return minDate;
|
|
606
|
+
}
|
|
607
|
+
if (isFocusDateAfterMaxDate) {
|
|
608
|
+
return maxDate;
|
|
609
|
+
}
|
|
610
|
+
return date;
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
var getHighlightRange = function (_a) {
|
|
614
|
+
var date = _a.date, minDate = _a.minDate, maxDate = _a.maxDate, range = _a.range;
|
|
615
|
+
var existingRange = range.filter(function (date) { return Boolean(date); });
|
|
616
|
+
if (existingRange.filter(function (date) { return Boolean(date); }).length === 1) {
|
|
617
|
+
var isDateBeforeMinDate = minDate && isBefore(date, minDate);
|
|
618
|
+
var isDateAfterMaxDate = maxDate && isAfter(date, maxDate);
|
|
619
|
+
if (isDateBeforeMinDate) {
|
|
620
|
+
return [minDate, existingRange[0]].sort(compareAsc);
|
|
621
|
+
}
|
|
622
|
+
if (isDateAfterMaxDate) {
|
|
623
|
+
return [maxDate, existingRange[0]].sort(compareAsc);
|
|
624
|
+
}
|
|
625
|
+
return [date, existingRange[0]].sort(compareAsc);
|
|
626
|
+
}
|
|
627
|
+
return existingRange;
|
|
628
|
+
};
|
|
629
|
+
|
|
735
630
|
/**
|
|
736
|
-
* @name
|
|
737
|
-
* @category
|
|
738
|
-
* @summary
|
|
631
|
+
* @name addDays
|
|
632
|
+
* @category Day Helpers
|
|
633
|
+
* @summary Add the specified number of days to the given date.
|
|
739
634
|
*
|
|
740
635
|
* @description
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
* @param {Date|Number} dateLeft - the first date to check
|
|
744
|
-
* @param {Date|Number} dateRight - the second date to check
|
|
745
|
-
* @returns {Boolean} the dates are in the same month (and year)
|
|
746
|
-
* @throws {TypeError} 2 arguments required
|
|
636
|
+
* Add the specified number of days to the given date.
|
|
747
637
|
*
|
|
748
|
-
* @
|
|
749
|
-
*
|
|
750
|
-
*
|
|
751
|
-
*
|
|
638
|
+
* @param {Date|Number} date - the date to be changed
|
|
639
|
+
* @param {Number} amount - the amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
|
|
640
|
+
* @returns {Date} - the new date with the days added
|
|
641
|
+
* @throws {TypeError} - 2 arguments required
|
|
752
642
|
*
|
|
753
643
|
* @example
|
|
754
|
-
* //
|
|
755
|
-
* const result =
|
|
756
|
-
* //=>
|
|
644
|
+
* // Add 10 days to 1 September 2014:
|
|
645
|
+
* const result = addDays(new Date(2014, 8, 1), 10)
|
|
646
|
+
* //=> Thu Sep 11 2014 00:00:00
|
|
757
647
|
*/
|
|
758
|
-
function
|
|
648
|
+
function addDays(dirtyDate, dirtyAmount) {
|
|
759
649
|
requiredArgs(2, arguments);
|
|
760
|
-
var
|
|
761
|
-
var
|
|
762
|
-
|
|
650
|
+
var date = toDate(dirtyDate);
|
|
651
|
+
var amount = toInteger(dirtyAmount);
|
|
652
|
+
if (isNaN(amount)) {
|
|
653
|
+
return new Date(NaN);
|
|
654
|
+
}
|
|
655
|
+
if (!amount) {
|
|
656
|
+
// If 0 days, no-op to avoid changing times in the hour before end of DST
|
|
657
|
+
return date;
|
|
658
|
+
}
|
|
659
|
+
date.setDate(date.getDate() + amount);
|
|
660
|
+
return date;
|
|
763
661
|
}
|
|
764
662
|
|
|
765
663
|
/**
|
|
766
|
-
* @name
|
|
767
|
-
* @category
|
|
768
|
-
* @summary
|
|
664
|
+
* @name addWeeks
|
|
665
|
+
* @category Week Helpers
|
|
666
|
+
* @summary Add the specified number of weeks to the given date.
|
|
769
667
|
*
|
|
770
668
|
* @description
|
|
771
|
-
*
|
|
669
|
+
* Add the specified number of week to the given date.
|
|
772
670
|
*
|
|
773
|
-
* @param {Date|Number} date - the date to
|
|
774
|
-
* @param {
|
|
775
|
-
* @returns {
|
|
671
|
+
* @param {Date|Number} date - the date to be changed
|
|
672
|
+
* @param {Number} amount - the amount of weeks to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
|
|
673
|
+
* @returns {Date} the new date with the weeks added
|
|
776
674
|
* @throws {TypeError} 2 arguments required
|
|
777
|
-
* @throws {RangeError} The start of an interval cannot be after its end
|
|
778
|
-
* @throws {RangeError} Date in interval cannot be `Invalid Date`
|
|
779
|
-
*
|
|
780
|
-
* @example
|
|
781
|
-
* // For the date within the interval:
|
|
782
|
-
* isWithinInterval(new Date(2014, 0, 3), {
|
|
783
|
-
* start: new Date(2014, 0, 1),
|
|
784
|
-
* end: new Date(2014, 0, 7)
|
|
785
|
-
* })
|
|
786
|
-
* //=> true
|
|
787
|
-
*
|
|
788
|
-
* @example
|
|
789
|
-
* // For the date outside of the interval:
|
|
790
|
-
* isWithinInterval(new Date(2014, 0, 10), {
|
|
791
|
-
* start: new Date(2014, 0, 1),
|
|
792
|
-
* end: new Date(2014, 0, 7)
|
|
793
|
-
* })
|
|
794
|
-
* //=> false
|
|
795
675
|
*
|
|
796
676
|
* @example
|
|
797
|
-
* //
|
|
798
|
-
*
|
|
799
|
-
*
|
|
800
|
-
* @example
|
|
801
|
-
* // For date equal to interval end:
|
|
802
|
-
* isWithinInterval(date, { start: date, end }) // => true
|
|
677
|
+
* // Add 4 weeks to 1 September 2014:
|
|
678
|
+
* const result = addWeeks(new Date(2014, 8, 1), 4)
|
|
679
|
+
* //=> Mon Sep 29 2014 00:00:00
|
|
803
680
|
*/
|
|
804
|
-
function
|
|
681
|
+
function addWeeks(dirtyDate, dirtyAmount) {
|
|
805
682
|
requiredArgs(2, arguments);
|
|
806
|
-
var
|
|
807
|
-
var
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
// Throw an exception if start date is after end date or if any date is `Invalid Date`
|
|
811
|
-
if (!(startTime <= endTime)) {
|
|
812
|
-
throw new RangeError('Invalid interval');
|
|
813
|
-
}
|
|
814
|
-
return time >= startTime && time <= endTime;
|
|
683
|
+
var amount = toInteger(dirtyAmount);
|
|
684
|
+
var days = amount * 7;
|
|
685
|
+
return addDays(dirtyDate, days);
|
|
815
686
|
}
|
|
816
687
|
|
|
817
688
|
/**
|
|
@@ -839,189 +710,141 @@ function subDays(dirtyDate, dirtyAmount) {
|
|
|
839
710
|
}
|
|
840
711
|
|
|
841
712
|
/**
|
|
842
|
-
* @name
|
|
843
|
-
* @category
|
|
844
|
-
* @summary
|
|
713
|
+
* @name startOfWeek
|
|
714
|
+
* @category Week Helpers
|
|
715
|
+
* @summary Return the start of a week for the given date.
|
|
845
716
|
*
|
|
846
717
|
* @description
|
|
847
|
-
*
|
|
718
|
+
* Return the start of a week for the given date.
|
|
719
|
+
* The result will be in the local timezone.
|
|
848
720
|
*
|
|
849
|
-
* @param {Date|Number} date - the date
|
|
850
|
-
* @param {
|
|
851
|
-
* @
|
|
852
|
-
* @
|
|
853
|
-
*
|
|
854
|
-
* @
|
|
855
|
-
*
|
|
856
|
-
* const result = setMonth(new Date(2014, 8, 1), 1)
|
|
857
|
-
* //=> Sat Feb 01 2014 00:00:00
|
|
858
|
-
*/
|
|
859
|
-
function setMonth(dirtyDate, dirtyMonth) {
|
|
860
|
-
requiredArgs(2, arguments);
|
|
861
|
-
var date = toDate(dirtyDate);
|
|
862
|
-
var month = toInteger(dirtyMonth);
|
|
863
|
-
var year = date.getFullYear();
|
|
864
|
-
var day = date.getDate();
|
|
865
|
-
var dateWithDesiredMonth = new Date(0);
|
|
866
|
-
dateWithDesiredMonth.setFullYear(year, month, 15);
|
|
867
|
-
dateWithDesiredMonth.setHours(0, 0, 0, 0);
|
|
868
|
-
var daysInMonth = getDaysInMonth(dateWithDesiredMonth);
|
|
869
|
-
// Set the last day of the new month
|
|
870
|
-
// if the original date was the last day of the longer month
|
|
871
|
-
date.setMonth(month, Math.min(day, daysInMonth));
|
|
872
|
-
return date;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
/**
|
|
876
|
-
* @name set
|
|
877
|
-
* @category Common Helpers
|
|
878
|
-
* @summary Set date values to a given date.
|
|
879
|
-
*
|
|
880
|
-
* @description
|
|
881
|
-
* Set date values to a given date.
|
|
882
|
-
*
|
|
883
|
-
* Sets time values to date from object `values`.
|
|
884
|
-
* A value is not set if it is undefined or null or doesn't exist in `values`.
|
|
885
|
-
*
|
|
886
|
-
* Note about bundle size: `set` does not internally use `setX` functions from date-fns but instead opts
|
|
887
|
-
* to use native `Date#setX` methods. If you use this function, you may not want to include the
|
|
888
|
-
* other `setX` functions that date-fns provides if you are concerned about the bundle size.
|
|
889
|
-
*
|
|
890
|
-
* @param {Date|Number} date - the date to be changed
|
|
891
|
-
* @param {Object} values - an object with options
|
|
892
|
-
* @param {Number} [values.year] - the number of years to be set
|
|
893
|
-
* @param {Number} [values.month] - the number of months to be set
|
|
894
|
-
* @param {Number} [values.date] - the number of days to be set
|
|
895
|
-
* @param {Number} [values.hours] - the number of hours to be set
|
|
896
|
-
* @param {Number} [values.minutes] - the number of minutes to be set
|
|
897
|
-
* @param {Number} [values.seconds] - the number of seconds to be set
|
|
898
|
-
* @param {Number} [values.milliseconds] - the number of milliseconds to be set
|
|
899
|
-
* @returns {Date} the new date with options set
|
|
900
|
-
* @throws {TypeError} 2 arguments required
|
|
901
|
-
* @throws {RangeError} `values` must be an object
|
|
721
|
+
* @param {Date|Number} date - the original date
|
|
722
|
+
* @param {Object} [options] - an object with options.
|
|
723
|
+
* @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
|
|
724
|
+
* @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
|
|
725
|
+
* @returns {Date} the start of a week
|
|
726
|
+
* @throws {TypeError} 1 argument required
|
|
727
|
+
* @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
|
|
902
728
|
*
|
|
903
729
|
* @example
|
|
904
|
-
* //
|
|
905
|
-
* const result =
|
|
906
|
-
* //=>
|
|
730
|
+
* // The start of a week for 2 September 2014 11:55:00:
|
|
731
|
+
* const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0))
|
|
732
|
+
* //=> Sun Aug 31 2014 00:00:00
|
|
907
733
|
*
|
|
908
734
|
* @example
|
|
909
|
-
* //
|
|
910
|
-
* const result =
|
|
911
|
-
* //=> Mon Sep 01 2014
|
|
735
|
+
* // If the week starts on Monday, the start of the week for 2 September 2014 11:55:00:
|
|
736
|
+
* const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
|
|
737
|
+
* //=> Mon Sep 01 2014 00:00:00
|
|
912
738
|
*/
|
|
913
|
-
function
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
var date = toDate(dirtyDate);
|
|
739
|
+
function startOfWeek(dirtyDate, options) {
|
|
740
|
+
var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
|
|
741
|
+
requiredArgs(1, arguments);
|
|
742
|
+
var defaultOptions = getDefaultOptions();
|
|
743
|
+
var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);
|
|
919
744
|
|
|
920
|
-
//
|
|
921
|
-
if (
|
|
922
|
-
|
|
923
|
-
}
|
|
924
|
-
if (values.year != null) {
|
|
925
|
-
date.setFullYear(values.year);
|
|
926
|
-
}
|
|
927
|
-
if (values.month != null) {
|
|
928
|
-
date = setMonth(date, values.month);
|
|
929
|
-
}
|
|
930
|
-
if (values.date != null) {
|
|
931
|
-
date.setDate(toInteger(values.date));
|
|
932
|
-
}
|
|
933
|
-
if (values.hours != null) {
|
|
934
|
-
date.setHours(toInteger(values.hours));
|
|
935
|
-
}
|
|
936
|
-
if (values.minutes != null) {
|
|
937
|
-
date.setMinutes(toInteger(values.minutes));
|
|
938
|
-
}
|
|
939
|
-
if (values.seconds != null) {
|
|
940
|
-
date.setSeconds(toInteger(values.seconds));
|
|
941
|
-
}
|
|
942
|
-
if (values.milliseconds != null) {
|
|
943
|
-
date.setMilliseconds(toInteger(values.milliseconds));
|
|
745
|
+
// Test if weekStartsOn is between 0 and 6 _and_ is not NaN
|
|
746
|
+
if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
|
|
747
|
+
throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
|
|
944
748
|
}
|
|
749
|
+
var date = toDate(dirtyDate);
|
|
750
|
+
var day = date.getDay();
|
|
751
|
+
var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
|
|
752
|
+
date.setDate(date.getDate() - diff);
|
|
753
|
+
date.setHours(0, 0, 0, 0);
|
|
945
754
|
return date;
|
|
946
755
|
}
|
|
947
756
|
|
|
948
757
|
/**
|
|
949
|
-
* @name
|
|
950
|
-
* @category
|
|
951
|
-
* @summary
|
|
758
|
+
* @name endOfWeek
|
|
759
|
+
* @category Week Helpers
|
|
760
|
+
* @summary Return the end of a week for the given date.
|
|
952
761
|
*
|
|
953
762
|
* @description
|
|
954
|
-
*
|
|
763
|
+
* Return the end of a week for the given date.
|
|
764
|
+
* The result will be in the local timezone.
|
|
955
765
|
*
|
|
956
|
-
* @param {Date|Number} date - the date
|
|
957
|
-
* @param {
|
|
958
|
-
* @
|
|
959
|
-
* @
|
|
766
|
+
* @param {Date|Number} date - the original date
|
|
767
|
+
* @param {Object} [options] - an object with options.
|
|
768
|
+
* @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
|
|
769
|
+
* @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
|
|
770
|
+
* @returns {Date} the end of a week
|
|
771
|
+
* @throws {TypeError} 1 argument required
|
|
772
|
+
* @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
|
|
960
773
|
*
|
|
961
774
|
* @example
|
|
962
|
-
* //
|
|
963
|
-
* const result =
|
|
964
|
-
* //=>
|
|
775
|
+
* // The end of a week for 2 September 2014 11:55:00:
|
|
776
|
+
* const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0))
|
|
777
|
+
* //=> Sat Sep 06 2014 23:59:59.999
|
|
778
|
+
*
|
|
779
|
+
* @example
|
|
780
|
+
* // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00:
|
|
781
|
+
* const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
|
|
782
|
+
* //=> Sun Sep 07 2014 23:59:59.999
|
|
965
783
|
*/
|
|
966
|
-
function
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
var
|
|
784
|
+
function endOfWeek(dirtyDate, options) {
|
|
785
|
+
var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
|
|
786
|
+
requiredArgs(1, arguments);
|
|
787
|
+
var defaultOptions = getDefaultOptions();
|
|
788
|
+
var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);
|
|
970
789
|
|
|
971
|
-
//
|
|
972
|
-
if (
|
|
973
|
-
|
|
790
|
+
// Test if weekStartsOn is between 0 and 6 _and_ is not NaN
|
|
791
|
+
if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
|
|
792
|
+
throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
|
|
974
793
|
}
|
|
975
|
-
date
|
|
794
|
+
var date = toDate(dirtyDate);
|
|
795
|
+
var day = date.getDay();
|
|
796
|
+
var diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn);
|
|
797
|
+
date.setDate(date.getDate() + diff);
|
|
798
|
+
date.setHours(23, 59, 59, 999);
|
|
976
799
|
return date;
|
|
977
800
|
}
|
|
978
801
|
|
|
979
802
|
/**
|
|
980
|
-
* @name
|
|
981
|
-
* @category
|
|
982
|
-
* @summary Subtract the specified number of
|
|
803
|
+
* @name subWeeks
|
|
804
|
+
* @category Week Helpers
|
|
805
|
+
* @summary Subtract the specified number of weeks from the given date.
|
|
983
806
|
*
|
|
984
807
|
* @description
|
|
985
|
-
* Subtract the specified number of
|
|
808
|
+
* Subtract the specified number of weeks from the given date.
|
|
986
809
|
*
|
|
987
810
|
* @param {Date|Number} date - the date to be changed
|
|
988
|
-
* @param {Number} amount - the amount of
|
|
989
|
-
* @returns {Date} the new date with the
|
|
811
|
+
* @param {Number} amount - the amount of weeks to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
|
|
812
|
+
* @returns {Date} the new date with the weeks subtracted
|
|
990
813
|
* @throws {TypeError} 2 arguments required
|
|
991
814
|
*
|
|
992
815
|
* @example
|
|
993
|
-
* // Subtract
|
|
994
|
-
* const result =
|
|
995
|
-
* //=> Mon
|
|
816
|
+
* // Subtract 4 weeks from 1 September 2014:
|
|
817
|
+
* const result = subWeeks(new Date(2014, 8, 1), 4)
|
|
818
|
+
* //=> Mon Aug 04 2014 00:00:00
|
|
996
819
|
*/
|
|
997
|
-
function
|
|
820
|
+
function subWeeks(dirtyDate, dirtyAmount) {
|
|
998
821
|
requiredArgs(2, arguments);
|
|
999
822
|
var amount = toInteger(dirtyAmount);
|
|
1000
|
-
return
|
|
823
|
+
return addWeeks(dirtyDate, -amount);
|
|
1001
824
|
}
|
|
1002
825
|
|
|
1003
826
|
/**
|
|
1004
|
-
* @name
|
|
1005
|
-
* @category
|
|
1006
|
-
* @summary
|
|
827
|
+
* @name addYears
|
|
828
|
+
* @category Year Helpers
|
|
829
|
+
* @summary Add the specified number of years to the given date.
|
|
1007
830
|
*
|
|
1008
831
|
* @description
|
|
1009
|
-
*
|
|
832
|
+
* Add the specified number of years to the given date.
|
|
1010
833
|
*
|
|
1011
834
|
* @param {Date|Number} date - the date to be changed
|
|
1012
|
-
* @param {Number} amount - the amount of
|
|
1013
|
-
* @returns {Date} the new date with the
|
|
835
|
+
* @param {Number} amount - the amount of years to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
|
|
836
|
+
* @returns {Date} the new date with the years added
|
|
1014
837
|
* @throws {TypeError} 2 arguments required
|
|
1015
838
|
*
|
|
1016
839
|
* @example
|
|
1017
|
-
* //
|
|
1018
|
-
* const result =
|
|
1019
|
-
* //=>
|
|
840
|
+
* // Add 5 years to 1 September 2014:
|
|
841
|
+
* const result = addYears(new Date(2014, 8, 1), 5)
|
|
842
|
+
* //=> Sun Sep 01 2019 00:00:00
|
|
1020
843
|
*/
|
|
1021
|
-
function
|
|
844
|
+
function addYears(dirtyDate, dirtyAmount) {
|
|
1022
845
|
requiredArgs(2, arguments);
|
|
1023
846
|
var amount = toInteger(dirtyAmount);
|
|
1024
|
-
return
|
|
847
|
+
return addMonths(dirtyDate, amount * 12);
|
|
1025
848
|
}
|
|
1026
849
|
|
|
1027
850
|
/**
|
|
@@ -1048,155 +871,6 @@ function subYears(dirtyDate, dirtyAmount) {
|
|
|
1048
871
|
return addYears(dirtyDate, -amount);
|
|
1049
872
|
}
|
|
1050
873
|
|
|
1051
|
-
var containsDate = function (dates, compareDate) {
|
|
1052
|
-
return dates.map(function (date) { return date.getTime(); }).includes(compareDate.getTime());
|
|
1053
|
-
};
|
|
1054
|
-
|
|
1055
|
-
var dateWithoutTime = function (date) {
|
|
1056
|
-
return set(new Date(date), {
|
|
1057
|
-
hours: 0,
|
|
1058
|
-
minutes: 0,
|
|
1059
|
-
milliseconds: 0,
|
|
1060
|
-
seconds: 0
|
|
1061
|
-
});
|
|
1062
|
-
};
|
|
1063
|
-
|
|
1064
|
-
var getDatesInMonth = function (date) {
|
|
1065
|
-
var dateYear = getYear(date);
|
|
1066
|
-
var dateMonth = getMonth(date);
|
|
1067
|
-
return Array.from({ length: getDaysInMonth(date) }, function (_, i) {
|
|
1068
|
-
return dateWithoutTime(new Date(dateYear, dateMonth, i + 1));
|
|
1069
|
-
});
|
|
1070
|
-
};
|
|
1071
|
-
|
|
1072
|
-
var WeekDaysAbbr;
|
|
1073
|
-
(function (WeekDaysAbbr) {
|
|
1074
|
-
WeekDaysAbbr["MON"] = "Mon";
|
|
1075
|
-
WeekDaysAbbr["TUE"] = "Tue";
|
|
1076
|
-
WeekDaysAbbr["WED"] = "Wed";
|
|
1077
|
-
WeekDaysAbbr["THUR"] = "Thur";
|
|
1078
|
-
WeekDaysAbbr["FRI"] = "Fri";
|
|
1079
|
-
WeekDaysAbbr["SAT"] = "Sat";
|
|
1080
|
-
WeekDaysAbbr["SUN"] = "Sun";
|
|
1081
|
-
})(WeekDaysAbbr || (WeekDaysAbbr = {}));
|
|
1082
|
-
var WeekDays;
|
|
1083
|
-
(function (WeekDays) {
|
|
1084
|
-
WeekDays["MONDAY"] = "Monday";
|
|
1085
|
-
WeekDays["TUESDAY"] = "Tuesday";
|
|
1086
|
-
WeekDays["WEDNESDAY"] = "Wednesday";
|
|
1087
|
-
WeekDays["THURSDAY"] = "Thursday";
|
|
1088
|
-
WeekDays["FRIDAY"] = "Friday";
|
|
1089
|
-
WeekDays["SATURDAY"] = "Saturday";
|
|
1090
|
-
WeekDays["SUNDAY"] = "Sunday";
|
|
1091
|
-
})(WeekDays || (WeekDays = {}));
|
|
1092
|
-
|
|
1093
|
-
var isDay = function (date, day) {
|
|
1094
|
-
var _a;
|
|
1095
|
-
var dayMap = (_a = {},
|
|
1096
|
-
_a[WeekDays.MONDAY] = 1,
|
|
1097
|
-
_a[WeekDays.TUESDAY] = 2,
|
|
1098
|
-
_a[WeekDays.WEDNESDAY] = 3,
|
|
1099
|
-
_a[WeekDays.THURSDAY] = 4,
|
|
1100
|
-
_a[WeekDays.FRIDAY] = 5,
|
|
1101
|
-
_a[WeekDays.SATURDAY] = 6,
|
|
1102
|
-
_a[WeekDays.SUNDAY] = 0,
|
|
1103
|
-
_a);
|
|
1104
|
-
return getDay(date) === dayMap[day];
|
|
1105
|
-
};
|
|
1106
|
-
|
|
1107
|
-
var isDisabledDate = function (date, disabledDates, minDate, maxDate) {
|
|
1108
|
-
return ((minDate && isBefore(date, minDate)) ||
|
|
1109
|
-
(maxDate && isAfter(date, maxDate)) ||
|
|
1110
|
-
(disabledDates && containsDate(disabledDates, date)));
|
|
1111
|
-
};
|
|
1112
|
-
|
|
1113
|
-
var isMonthBeforeMinDate = function (month, minDate) {
|
|
1114
|
-
return getDatesInMonth(month).every(function (date) {
|
|
1115
|
-
return isBefore(date, minDate);
|
|
1116
|
-
});
|
|
1117
|
-
};
|
|
1118
|
-
|
|
1119
|
-
var isMonthAfterMaxDate = function (date, maxDate) {
|
|
1120
|
-
return getDatesInMonth(date).every(function (date) {
|
|
1121
|
-
return isAfter(date, maxDate);
|
|
1122
|
-
});
|
|
1123
|
-
};
|
|
1124
|
-
|
|
1125
|
-
var processSelectedRange = function (_a) {
|
|
1126
|
-
var range = _a.range, value = _a.value, disabledDates = _a.disabledDates;
|
|
1127
|
-
var exisitingRange = range.filter(function (date) { return Boolean(date); });
|
|
1128
|
-
var newRange = __spreadArray(__spreadArray([], (exisitingRange.length === 2 ? [] : exisitingRange), true), [
|
|
1129
|
-
value,
|
|
1130
|
-
], false).sort(compareAsc);
|
|
1131
|
-
var isSelectionComplete = newRange.length === 2;
|
|
1132
|
-
var allDaysInRange = isSelectionComplete
|
|
1133
|
-
? eachDayOfInterval({
|
|
1134
|
-
start: newRange[0],
|
|
1135
|
-
end: newRange[1]
|
|
1136
|
-
})
|
|
1137
|
-
: [];
|
|
1138
|
-
var rangeOnChangeValue = {
|
|
1139
|
-
dates: allDaysInRange.map(function (date) { return ({
|
|
1140
|
-
value: date,
|
|
1141
|
-
disabled: disabledDates ? containsDate(disabledDates, date) : false
|
|
1142
|
-
}); }),
|
|
1143
|
-
selectedDate: value,
|
|
1144
|
-
start: newRange[0],
|
|
1145
|
-
end: newRange[1],
|
|
1146
|
-
isSelectionComplete: isSelectionComplete
|
|
1147
|
-
};
|
|
1148
|
-
return {
|
|
1149
|
-
rangeValue: newRange,
|
|
1150
|
-
rangeOnChangeValue: rangeOnChangeValue
|
|
1151
|
-
};
|
|
1152
|
-
};
|
|
1153
|
-
|
|
1154
|
-
var getCalendarType = function (type, isDesktop) {
|
|
1155
|
-
if (type === "double" && !isDesktop) {
|
|
1156
|
-
return "month";
|
|
1157
|
-
}
|
|
1158
|
-
if (type === "double" && isDesktop) {
|
|
1159
|
-
return "double";
|
|
1160
|
-
}
|
|
1161
|
-
return type;
|
|
1162
|
-
};
|
|
1163
|
-
|
|
1164
|
-
var getDoubleMonthDisplayRange = function (date) {
|
|
1165
|
-
var firstMonth = getMonth(date) % 2 !== 0 ? subMonths(date, 1) : date;
|
|
1166
|
-
var secondMonth = addMonths(firstMonth, 1);
|
|
1167
|
-
return [firstMonth, secondMonth];
|
|
1168
|
-
};
|
|
1169
|
-
|
|
1170
|
-
var getFocusDate = function (_a) {
|
|
1171
|
-
var minDate = _a.minDate, maxDate = _a.maxDate, date = _a.date;
|
|
1172
|
-
var isFocusDateBeforeMinDate = minDate && isBefore(date, minDate);
|
|
1173
|
-
var isFocusDateAfterMaxDate = maxDate && isAfter(date, maxDate);
|
|
1174
|
-
if (isFocusDateBeforeMinDate) {
|
|
1175
|
-
return minDate;
|
|
1176
|
-
}
|
|
1177
|
-
if (isFocusDateAfterMaxDate) {
|
|
1178
|
-
return maxDate;
|
|
1179
|
-
}
|
|
1180
|
-
return date;
|
|
1181
|
-
};
|
|
1182
|
-
|
|
1183
|
-
var getHighlightRange = function (_a) {
|
|
1184
|
-
var date = _a.date, minDate = _a.minDate, maxDate = _a.maxDate, range = _a.range;
|
|
1185
|
-
var existingRange = range.filter(function (date) { return Boolean(date); });
|
|
1186
|
-
if (existingRange.filter(function (date) { return Boolean(date); }).length === 1) {
|
|
1187
|
-
var isDateBeforeMinDate = minDate && isBefore(date, minDate);
|
|
1188
|
-
var isDateAfterMaxDate = maxDate && isAfter(date, maxDate);
|
|
1189
|
-
if (isDateBeforeMinDate) {
|
|
1190
|
-
return [minDate, existingRange[0]].sort(compareAsc);
|
|
1191
|
-
}
|
|
1192
|
-
if (isDateAfterMaxDate) {
|
|
1193
|
-
return [maxDate, existingRange[0]].sort(compareAsc);
|
|
1194
|
-
}
|
|
1195
|
-
return [date, existingRange[0]].sort(compareAsc);
|
|
1196
|
-
}
|
|
1197
|
-
return existingRange;
|
|
1198
|
-
};
|
|
1199
|
-
|
|
1200
874
|
var KeyNames;
|
|
1201
875
|
(function (KeyNames) {
|
|
1202
876
|
KeyNames["ArrowUp"] = "ArrowUp";
|
|
@@ -1212,29 +886,178 @@ var KeyNames;
|
|
|
1212
886
|
KeyNames["Space"] = " ";
|
|
1213
887
|
})(KeyNames || (KeyNames = {}));
|
|
1214
888
|
|
|
1215
|
-
var getKeyDownDate = function (_a) {
|
|
1216
|
-
var key = _a.key, shiftKey = _a.shiftKey, focusDate = _a.focusDate;
|
|
1217
|
-
switch (key) {
|
|
1218
|
-
case KeyNames.ArrowDown:
|
|
1219
|
-
return addWeeks(focusDate, 1);
|
|
1220
|
-
case KeyNames.ArrowLeft:
|
|
1221
|
-
return subDays(focusDate, 1);
|
|
1222
|
-
case KeyNames.ArrowRight:
|
|
1223
|
-
return addDays(focusDate, 1);
|
|
1224
|
-
case KeyNames.ArrowUp:
|
|
1225
|
-
return subWeeks(focusDate, 1);
|
|
1226
|
-
case KeyNames.Home:
|
|
1227
|
-
return dateWithoutTime(startOfWeek(focusDate, { weekStartsOn: 1 }));
|
|
1228
|
-
case KeyNames.End:
|
|
1229
|
-
return dateWithoutTime(endOfWeek(focusDate, { weekStartsOn: 1 }));
|
|
1230
|
-
case KeyNames.PageUp:
|
|
1231
|
-
return shiftKey ? subYears(focusDate, 1) : subMonths(focusDate, 1);
|
|
1232
|
-
case KeyNames.PageDown:
|
|
1233
|
-
return shiftKey ? addYears(focusDate, 1) : addMonths(focusDate, 1);
|
|
1234
|
-
default:
|
|
1235
|
-
return focusDate;
|
|
1236
|
-
}
|
|
1237
|
-
};
|
|
889
|
+
var getKeyDownDate = function (_a) {
|
|
890
|
+
var key = _a.key, shiftKey = _a.shiftKey, focusDate = _a.focusDate;
|
|
891
|
+
switch (key) {
|
|
892
|
+
case KeyNames.ArrowDown:
|
|
893
|
+
return addWeeks(focusDate, 1);
|
|
894
|
+
case KeyNames.ArrowLeft:
|
|
895
|
+
return subDays(focusDate, 1);
|
|
896
|
+
case KeyNames.ArrowRight:
|
|
897
|
+
return addDays(focusDate, 1);
|
|
898
|
+
case KeyNames.ArrowUp:
|
|
899
|
+
return subWeeks(focusDate, 1);
|
|
900
|
+
case KeyNames.Home:
|
|
901
|
+
return dateWithoutTime(startOfWeek(focusDate, { weekStartsOn: 1 }));
|
|
902
|
+
case KeyNames.End:
|
|
903
|
+
return dateWithoutTime(endOfWeek(focusDate, { weekStartsOn: 1 }));
|
|
904
|
+
case KeyNames.PageUp:
|
|
905
|
+
return shiftKey ? subYears(focusDate, 1) : subMonths(focusDate, 1);
|
|
906
|
+
case KeyNames.PageDown:
|
|
907
|
+
return shiftKey ? addYears(focusDate, 1) : addMonths(focusDate, 1);
|
|
908
|
+
default:
|
|
909
|
+
return focusDate;
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* @name endOfDay
|
|
915
|
+
* @category Day Helpers
|
|
916
|
+
* @summary Return the end of a day for the given date.
|
|
917
|
+
*
|
|
918
|
+
* @description
|
|
919
|
+
* Return the end of a day for the given date.
|
|
920
|
+
* The result will be in the local timezone.
|
|
921
|
+
*
|
|
922
|
+
* @param {Date|Number} date - the original date
|
|
923
|
+
* @returns {Date} the end of a day
|
|
924
|
+
* @throws {TypeError} 1 argument required
|
|
925
|
+
*
|
|
926
|
+
* @example
|
|
927
|
+
* // The end of a day for 2 September 2014 11:55:00:
|
|
928
|
+
* const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0))
|
|
929
|
+
* //=> Tue Sep 02 2014 23:59:59.999
|
|
930
|
+
*/
|
|
931
|
+
function endOfDay(dirtyDate) {
|
|
932
|
+
requiredArgs(1, arguments);
|
|
933
|
+
var date = toDate(dirtyDate);
|
|
934
|
+
date.setHours(23, 59, 59, 999);
|
|
935
|
+
return date;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* @name endOfMonth
|
|
940
|
+
* @category Month Helpers
|
|
941
|
+
* @summary Return the end of a month for the given date.
|
|
942
|
+
*
|
|
943
|
+
* @description
|
|
944
|
+
* Return the end of a month for the given date.
|
|
945
|
+
* The result will be in the local timezone.
|
|
946
|
+
*
|
|
947
|
+
* @param {Date|Number} date - the original date
|
|
948
|
+
* @returns {Date} the end of a month
|
|
949
|
+
* @throws {TypeError} 1 argument required
|
|
950
|
+
*
|
|
951
|
+
* @example
|
|
952
|
+
* // The end of a month for 2 September 2014 11:55:00:
|
|
953
|
+
* const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))
|
|
954
|
+
* //=> Tue Sep 30 2014 23:59:59.999
|
|
955
|
+
*/
|
|
956
|
+
function endOfMonth(dirtyDate) {
|
|
957
|
+
requiredArgs(1, arguments);
|
|
958
|
+
var date = toDate(dirtyDate);
|
|
959
|
+
var month = date.getMonth();
|
|
960
|
+
date.setFullYear(date.getFullYear(), month + 1, 0);
|
|
961
|
+
date.setHours(23, 59, 59, 999);
|
|
962
|
+
return date;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* @name isLastDayOfMonth
|
|
967
|
+
* @category Month Helpers
|
|
968
|
+
* @summary Is the given date the last day of a month?
|
|
969
|
+
*
|
|
970
|
+
* @description
|
|
971
|
+
* Is the given date the last day of a month?
|
|
972
|
+
*
|
|
973
|
+
* @param {Date|Number} date - the date to check
|
|
974
|
+
* @returns {Boolean} the date is the last day of a month
|
|
975
|
+
* @throws {TypeError} 1 argument required
|
|
976
|
+
*
|
|
977
|
+
* @example
|
|
978
|
+
* // Is 28 February 2014 the last day of a month?
|
|
979
|
+
* const result = isLastDayOfMonth(new Date(2014, 1, 28))
|
|
980
|
+
* //=> true
|
|
981
|
+
*/
|
|
982
|
+
function isLastDayOfMonth(dirtyDate) {
|
|
983
|
+
requiredArgs(1, arguments);
|
|
984
|
+
var date = toDate(dirtyDate);
|
|
985
|
+
return endOfDay(date).getTime() === endOfMonth(date).getTime();
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* @name isFirstDayOfMonth
|
|
990
|
+
* @category Month Helpers
|
|
991
|
+
* @summary Is the given date the first day of a month?
|
|
992
|
+
*
|
|
993
|
+
* @description
|
|
994
|
+
* Is the given date the first day of a month?
|
|
995
|
+
*
|
|
996
|
+
* @param {Date|Number} date - the date to check
|
|
997
|
+
* @returns {Boolean} the date is the first day of a month
|
|
998
|
+
* @throws {TypeError} 1 argument required
|
|
999
|
+
*
|
|
1000
|
+
* @example
|
|
1001
|
+
* // Is 1 September 2014 the first day of a month?
|
|
1002
|
+
* const result = isFirstDayOfMonth(new Date(2014, 8, 1))
|
|
1003
|
+
* //=> true
|
|
1004
|
+
*/
|
|
1005
|
+
function isFirstDayOfMonth(dirtyDate) {
|
|
1006
|
+
requiredArgs(1, arguments);
|
|
1007
|
+
return toDate(dirtyDate).getDate() === 1;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
/**
|
|
1011
|
+
* @name getDate
|
|
1012
|
+
* @category Day Helpers
|
|
1013
|
+
* @summary Get the day of the month of the given date.
|
|
1014
|
+
*
|
|
1015
|
+
* @description
|
|
1016
|
+
* Get the day of the month of the given date.
|
|
1017
|
+
*
|
|
1018
|
+
* @param {Date|Number} date - the given date
|
|
1019
|
+
* @returns {Number} the day of month
|
|
1020
|
+
* @throws {TypeError} 1 argument required
|
|
1021
|
+
*
|
|
1022
|
+
* @example
|
|
1023
|
+
* // Which day of the month is 29 February 2012?
|
|
1024
|
+
* const result = getDate(new Date(2012, 1, 29))
|
|
1025
|
+
* //=> 29
|
|
1026
|
+
*/
|
|
1027
|
+
function getDate(dirtyDate) {
|
|
1028
|
+
requiredArgs(1, arguments);
|
|
1029
|
+
var date = toDate(dirtyDate);
|
|
1030
|
+
var dayOfMonth = date.getDate();
|
|
1031
|
+
return dayOfMonth;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
/**
|
|
1035
|
+
* @name isEqual
|
|
1036
|
+
* @category Common Helpers
|
|
1037
|
+
* @summary Are the given dates equal?
|
|
1038
|
+
*
|
|
1039
|
+
* @description
|
|
1040
|
+
* Are the given dates equal?
|
|
1041
|
+
*
|
|
1042
|
+
* @param {Date|Number} dateLeft - the first date to compare
|
|
1043
|
+
* @param {Date|Number} dateRight - the second date to compare
|
|
1044
|
+
* @returns {Boolean} the dates are equal
|
|
1045
|
+
* @throws {TypeError} 2 arguments required
|
|
1046
|
+
*
|
|
1047
|
+
* @example
|
|
1048
|
+
* // Are 2 July 2014 06:30:45.000 and 2 July 2014 06:30:45.500 equal?
|
|
1049
|
+
* const result = isEqual(
|
|
1050
|
+
* new Date(2014, 6, 2, 6, 30, 45, 0),
|
|
1051
|
+
* new Date(2014, 6, 2, 6, 30, 45, 500)
|
|
1052
|
+
* )
|
|
1053
|
+
* //=> false
|
|
1054
|
+
*/
|
|
1055
|
+
function isEqual(dirtyLeftDate, dirtyRightDate) {
|
|
1056
|
+
requiredArgs(2, arguments);
|
|
1057
|
+
var dateLeft = toDate(dirtyLeftDate);
|
|
1058
|
+
var dateRight = toDate(dirtyRightDate);
|
|
1059
|
+
return dateLeft.getTime() === dateRight.getTime();
|
|
1060
|
+
}
|
|
1238
1061
|
|
|
1239
1062
|
var ArcCalendarContext = createContext(null);
|
|
1240
1063
|
|
|
@@ -1294,7 +1117,7 @@ var CalendarDayNumber = forwardRef(function (_a, autoFocusRef) {
|
|
|
1294
1117
|
onClick: onDayNumberClick(date),
|
|
1295
1118
|
onMouseEnter: onDayNumberHover(date)
|
|
1296
1119
|
};
|
|
1297
|
-
return (React__default.createElement("td", __assign({ ref: handleRefs, "data-date": date.getTime() }, (shouldRender ? tableCellProps : {})), shouldRender && (React__default.createElement(React__default.Fragment, null,
|
|
1120
|
+
return (React__default.createElement("td", __assign({ ref: handleRefs, "data-date": date.getTime() }, (shouldRender ? tableCellProps : {}), { role: "gridcell" }), shouldRender && (React__default.createElement(React__default.Fragment, null,
|
|
1298
1121
|
React__default.createElement(VisuallyHidden, null, format(date, "MMMM do, yyyy")),
|
|
1299
1122
|
React__default.createElement("div", { className: "arc-CalendarDayNumber-buttonOuter" },
|
|
1300
1123
|
React__default.createElement("div", { className: "arc-CalendarDayNumber-buttonInner" },
|
|
@@ -1334,6 +1157,100 @@ var CalendarDateSelect = function (_a) {
|
|
|
1334
1157
|
React__default.createElement(Icon, { size: 24, icon: BtIconChevronDownMid })))));
|
|
1335
1158
|
};
|
|
1336
1159
|
|
|
1160
|
+
/**
|
|
1161
|
+
* @name isSameMonth
|
|
1162
|
+
* @category Month Helpers
|
|
1163
|
+
* @summary Are the given dates in the same month (and year)?
|
|
1164
|
+
*
|
|
1165
|
+
* @description
|
|
1166
|
+
* Are the given dates in the same month (and year)?
|
|
1167
|
+
*
|
|
1168
|
+
* @param {Date|Number} dateLeft - the first date to check
|
|
1169
|
+
* @param {Date|Number} dateRight - the second date to check
|
|
1170
|
+
* @returns {Boolean} the dates are in the same month (and year)
|
|
1171
|
+
* @throws {TypeError} 2 arguments required
|
|
1172
|
+
*
|
|
1173
|
+
* @example
|
|
1174
|
+
* // Are 2 September 2014 and 25 September 2014 in the same month?
|
|
1175
|
+
* const result = isSameMonth(new Date(2014, 8, 2), new Date(2014, 8, 25))
|
|
1176
|
+
* //=> true
|
|
1177
|
+
*
|
|
1178
|
+
* @example
|
|
1179
|
+
* // Are 2 September 2014 and 25 September 2015 in the same month?
|
|
1180
|
+
* const result = isSameMonth(new Date(2014, 8, 2), new Date(2015, 8, 25))
|
|
1181
|
+
* //=> false
|
|
1182
|
+
*/
|
|
1183
|
+
function isSameMonth(dirtyDateLeft, dirtyDateRight) {
|
|
1184
|
+
requiredArgs(2, arguments);
|
|
1185
|
+
var dateLeft = toDate(dirtyDateLeft);
|
|
1186
|
+
var dateRight = toDate(dirtyDateRight);
|
|
1187
|
+
return dateLeft.getFullYear() === dateRight.getFullYear() && dateLeft.getMonth() === dateRight.getMonth();
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
/**
|
|
1191
|
+
* @name eachWeekOfInterval
|
|
1192
|
+
* @category Interval Helpers
|
|
1193
|
+
* @summary Return the array of weeks within the specified time interval.
|
|
1194
|
+
*
|
|
1195
|
+
* @description
|
|
1196
|
+
* Return the array of weeks within the specified time interval.
|
|
1197
|
+
*
|
|
1198
|
+
* @param {Interval} interval - the interval. See [Interval]{@link https://date-fns.org/docs/Interval}
|
|
1199
|
+
* @param {Object} [options] - an object with options.
|
|
1200
|
+
* @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
|
|
1201
|
+
* @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
|
|
1202
|
+
* @returns {Date[]} the array with starts of weeks from the week of the interval start to the week of the interval end
|
|
1203
|
+
* @throws {TypeError} 1 argument required
|
|
1204
|
+
* @throws {RangeError} `options.weekStartsOn` must be 0, 1, ..., 6
|
|
1205
|
+
* @throws {RangeError} The start of an interval cannot be after its end
|
|
1206
|
+
* @throws {RangeError} Date in interval cannot be `Invalid Date`
|
|
1207
|
+
*
|
|
1208
|
+
* @example
|
|
1209
|
+
* // Each week within interval 6 October 2014 - 23 November 2014:
|
|
1210
|
+
* const result = eachWeekOfInterval({
|
|
1211
|
+
* start: new Date(2014, 9, 6),
|
|
1212
|
+
* end: new Date(2014, 10, 23)
|
|
1213
|
+
* })
|
|
1214
|
+
* //=> [
|
|
1215
|
+
* // Sun Oct 05 2014 00:00:00,
|
|
1216
|
+
* // Sun Oct 12 2014 00:00:00,
|
|
1217
|
+
* // Sun Oct 19 2014 00:00:00,
|
|
1218
|
+
* // Sun Oct 26 2014 00:00:00,
|
|
1219
|
+
* // Sun Nov 02 2014 00:00:00,
|
|
1220
|
+
* // Sun Nov 09 2014 00:00:00,
|
|
1221
|
+
* // Sun Nov 16 2014 00:00:00,
|
|
1222
|
+
* // Sun Nov 23 2014 00:00:00
|
|
1223
|
+
* // ]
|
|
1224
|
+
*/
|
|
1225
|
+
function eachWeekOfInterval(dirtyInterval, options) {
|
|
1226
|
+
requiredArgs(1, arguments);
|
|
1227
|
+
var interval = dirtyInterval || {};
|
|
1228
|
+
var startDate = toDate(interval.start);
|
|
1229
|
+
var endDate = toDate(interval.end);
|
|
1230
|
+
var endTime = endDate.getTime();
|
|
1231
|
+
|
|
1232
|
+
// Throw an exception if start date is after end date or if any date is `Invalid Date`
|
|
1233
|
+
if (!(startDate.getTime() <= endTime)) {
|
|
1234
|
+
throw new RangeError('Invalid interval');
|
|
1235
|
+
}
|
|
1236
|
+
var startDateWeek = startOfWeek(startDate, options);
|
|
1237
|
+
var endDateWeek = startOfWeek(endDate, options);
|
|
1238
|
+
|
|
1239
|
+
// Some timezones switch DST at midnight, making start of day unreliable in these timezones, 3pm is a safe bet
|
|
1240
|
+
startDateWeek.setHours(15);
|
|
1241
|
+
endDateWeek.setHours(15);
|
|
1242
|
+
endTime = endDateWeek.getTime();
|
|
1243
|
+
var weeks = [];
|
|
1244
|
+
var currentWeek = startDateWeek;
|
|
1245
|
+
while (currentWeek.getTime() <= endTime) {
|
|
1246
|
+
currentWeek.setHours(0);
|
|
1247
|
+
weeks.push(toDate(currentWeek));
|
|
1248
|
+
currentWeek = addWeeks(currentWeek, 1);
|
|
1249
|
+
currentWeek.setHours(15);
|
|
1250
|
+
}
|
|
1251
|
+
return weeks;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1337
1254
|
var DAY_NAMES = [
|
|
1338
1255
|
{
|
|
1339
1256
|
value: WeekDays.MONDAY,
|
|
@@ -1424,7 +1341,7 @@ const BtIconChevronLeftMid = (props) =>
|
|
|
1424
1341
|
"svg",
|
|
1425
1342
|
Object.assign(
|
|
1426
1343
|
{
|
|
1427
|
-
viewBox: "0 0
|
|
1344
|
+
viewBox: "0 0 32 32",
|
|
1428
1345
|
fill: "none",
|
|
1429
1346
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1430
1347
|
},
|
|
@@ -1433,7 +1350,7 @@ const BtIconChevronLeftMid = (props) =>
|
|
|
1433
1350
|
/*#__PURE__*/ React__default.createElement("path", {
|
|
1434
1351
|
fillRule: "evenodd",
|
|
1435
1352
|
clipRule: "evenodd",
|
|
1436
|
-
d: "
|
|
1353
|
+
d: "M13.9091 16.0002L19.6065 21.7042C19.8585 21.9567 20 22.2988 20 22.6555C20 23.0123 19.8585 23.3544 19.6065 23.6069C19.4819 23.7317 19.3339 23.8307 19.171 23.8983C19.0081 23.9658 18.8335 24.0006 18.6571 24.0006C18.4808 24.0006 18.3062 23.9658 18.1433 23.8983C17.9804 23.8307 17.8324 23.7317 17.7078 23.6069L11.0598 16.9509C10.8082 16.6985 10.6669 16.3566 10.6669 16.0002C10.6669 15.6438 10.8082 15.302 11.0598 15.0495L17.7078 8.39354C17.8324 8.26873 17.9804 8.16971 18.1433 8.10215C18.3062 8.03458 18.4808 7.99981 18.6571 7.99981C18.8335 7.99981 19.0081 8.03458 19.171 8.10215C19.3339 8.16971 19.4819 8.26873 19.6065 8.39354C19.8585 8.64602 20 8.98816 20 9.34487C20 9.70159 19.8585 10.0437 19.6065 10.2962L13.9091 16.0002Z",
|
|
1437
1354
|
fill: "currentColor",
|
|
1438
1355
|
}),
|
|
1439
1356
|
);
|
|
@@ -1635,6 +1552,89 @@ var dropDownChangeMonthHandler = function (payload, state) {
|
|
|
1635
1552
|
}), displayDate: setMonth(state.displayDate, payload.month) });
|
|
1636
1553
|
};
|
|
1637
1554
|
|
|
1555
|
+
/**
|
|
1556
|
+
* @name isWithinInterval
|
|
1557
|
+
* @category Interval Helpers
|
|
1558
|
+
* @summary Is the given date within the interval?
|
|
1559
|
+
*
|
|
1560
|
+
* @description
|
|
1561
|
+
* Is the given date within the interval? (Including start and end.)
|
|
1562
|
+
*
|
|
1563
|
+
* @param {Date|Number} date - the date to check
|
|
1564
|
+
* @param {Interval} interval - the interval to check
|
|
1565
|
+
* @returns {Boolean} the date is within the interval
|
|
1566
|
+
* @throws {TypeError} 2 arguments required
|
|
1567
|
+
* @throws {RangeError} The start of an interval cannot be after its end
|
|
1568
|
+
* @throws {RangeError} Date in interval cannot be `Invalid Date`
|
|
1569
|
+
*
|
|
1570
|
+
* @example
|
|
1571
|
+
* // For the date within the interval:
|
|
1572
|
+
* isWithinInterval(new Date(2014, 0, 3), {
|
|
1573
|
+
* start: new Date(2014, 0, 1),
|
|
1574
|
+
* end: new Date(2014, 0, 7)
|
|
1575
|
+
* })
|
|
1576
|
+
* //=> true
|
|
1577
|
+
*
|
|
1578
|
+
* @example
|
|
1579
|
+
* // For the date outside of the interval:
|
|
1580
|
+
* isWithinInterval(new Date(2014, 0, 10), {
|
|
1581
|
+
* start: new Date(2014, 0, 1),
|
|
1582
|
+
* end: new Date(2014, 0, 7)
|
|
1583
|
+
* })
|
|
1584
|
+
* //=> false
|
|
1585
|
+
*
|
|
1586
|
+
* @example
|
|
1587
|
+
* // For date equal to interval start:
|
|
1588
|
+
* isWithinInterval(date, { start, end: date }) // => true
|
|
1589
|
+
*
|
|
1590
|
+
* @example
|
|
1591
|
+
* // For date equal to interval end:
|
|
1592
|
+
* isWithinInterval(date, { start: date, end }) // => true
|
|
1593
|
+
*/
|
|
1594
|
+
function isWithinInterval(dirtyDate, interval) {
|
|
1595
|
+
requiredArgs(2, arguments);
|
|
1596
|
+
var time = toDate(dirtyDate).getTime();
|
|
1597
|
+
var startTime = toDate(interval.start).getTime();
|
|
1598
|
+
var endTime = toDate(interval.end).getTime();
|
|
1599
|
+
|
|
1600
|
+
// Throw an exception if start date is after end date or if any date is `Invalid Date`
|
|
1601
|
+
if (!(startTime <= endTime)) {
|
|
1602
|
+
throw new RangeError('Invalid interval');
|
|
1603
|
+
}
|
|
1604
|
+
return time >= startTime && time <= endTime;
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
/**
|
|
1608
|
+
* @name setYear
|
|
1609
|
+
* @category Year Helpers
|
|
1610
|
+
* @summary Set the year to the given date.
|
|
1611
|
+
*
|
|
1612
|
+
* @description
|
|
1613
|
+
* Set the year to the given date.
|
|
1614
|
+
*
|
|
1615
|
+
* @param {Date|Number} date - the date to be changed
|
|
1616
|
+
* @param {Number} year - the year of the new date
|
|
1617
|
+
* @returns {Date} the new date with the year set
|
|
1618
|
+
* @throws {TypeError} 2 arguments required
|
|
1619
|
+
*
|
|
1620
|
+
* @example
|
|
1621
|
+
* // Set year 2013 to 1 September 2014:
|
|
1622
|
+
* const result = setYear(new Date(2014, 8, 1), 2013)
|
|
1623
|
+
* //=> Sun Sep 01 2013 00:00:00
|
|
1624
|
+
*/
|
|
1625
|
+
function setYear(dirtyDate, dirtyYear) {
|
|
1626
|
+
requiredArgs(2, arguments);
|
|
1627
|
+
var date = toDate(dirtyDate);
|
|
1628
|
+
var year = toInteger(dirtyYear);
|
|
1629
|
+
|
|
1630
|
+
// Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date
|
|
1631
|
+
if (isNaN(date.getTime())) {
|
|
1632
|
+
return new Date(NaN);
|
|
1633
|
+
}
|
|
1634
|
+
date.setFullYear(year);
|
|
1635
|
+
return date;
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
1638
|
var calendarKeydownHandler = function (payload, state) {
|
|
1639
1639
|
var displayDate = state.displayDate, focusDate = state.focusDate, highlightedRange = state.highlightedRange;
|
|
1640
1640
|
var minDate = payload.minDate, maxDate = payload.maxDate, calendarType = payload.calendarType, key = payload.key, shiftKey = payload.shiftKey, range = payload.range, selectionType = payload.selectionType;
|
|
@@ -1732,7 +1732,7 @@ var CalendarWrapper = function (_a) {
|
|
|
1732
1732
|
|
|
1733
1733
|
/** Use `Calendar` to clearly present available dates and allowing users to choose a way to enter information. */
|
|
1734
1734
|
var Calendar = function (_a) {
|
|
1735
|
-
var _b = _a.type, type = _b === void 0 ? "month" : _b, _c = _a.selectionType, selectionType = _c === void 0 ? "single" : _c, _d = _a.autoFocusOnMount, autoFocusOnMount = _d === void 0 ? false : _d, _e = _a.selectedRange, rawSelectedRange = _e === void 0 ? [] : _e, _f = _a.selectedDate, rawSelectedDate = _f === void 0 ? new Date() : _f, rawDisabledDates = _a.disabledDates, rawMinDate = _a.minDate, rawMaxDate = _a.maxDate, onCancelClick = _a.onCancelClick, onDateSelect = _a.onDateSelect, onRangeSelect = _a.onRangeSelect;
|
|
1735
|
+
var _b = _a.type, type = _b === void 0 ? "month" : _b, _c = _a.selectionType, selectionType = _c === void 0 ? "single" : _c, _d = _a.autoFocusOnMount, autoFocusOnMount = _d === void 0 ? false : _d, _e = _a.selectedRange, rawSelectedRange = _e === void 0 ? [] : _e, _f = _a.selectedDate, rawSelectedDate = _f === void 0 ? new Date() : _f, rawDisabledDates = _a.disabledDates, rawMinDate = _a.minDate, rawMaxDate = _a.maxDate, onCancelClick = _a.onCancelClick, onDateSelect = _a.onDateSelect, onRangeSelect = _a.onRangeSelect, props = __rest(_a, ["type", "selectionType", "autoFocusOnMount", "selectedRange", "selectedDate", "disabledDates", "minDate", "maxDate", "onCancelClick", "onDateSelect", "onRangeSelect"]);
|
|
1736
1736
|
var todayDate = dateWithoutTime(new Date());
|
|
1737
1737
|
var selectedDate = dateWithoutTime(rawSelectedDate);
|
|
1738
1738
|
var selectedRange = rawSelectedRange
|
|
@@ -1890,7 +1890,7 @@ var Calendar = function (_a) {
|
|
|
1890
1890
|
}
|
|
1891
1891
|
});
|
|
1892
1892
|
};
|
|
1893
|
-
return (React__default.createElement(ArcCalendarContext.Provider, { value: {
|
|
1893
|
+
return (React__default.createElement(ArcCalendarContext.Provider, __assign({ value: {
|
|
1894
1894
|
minDate: minDate,
|
|
1895
1895
|
maxDate: maxDate,
|
|
1896
1896
|
focusDate: focusDate,
|
|
@@ -1906,7 +1906,7 @@ var Calendar = function (_a) {
|
|
|
1906
1906
|
onDayNumberHover: onDayNumberHover,
|
|
1907
1907
|
onKeyboardNavigate: onKeyboardNavigate,
|
|
1908
1908
|
autoFocusOnMount: autoFocusOnMount
|
|
1909
|
-
} },
|
|
1909
|
+
} }, filterDataAttrs(props)),
|
|
1910
1910
|
React__default.createElement("div", { style: { display: isClientLoaded ? "block" : "none" } },
|
|
1911
1911
|
React__default.createElement(CalendarWrapper, null,
|
|
1912
1912
|
calendarType === "year" && (React__default.createElement(CalendarMonthYearView, { isPreviousMonthDisabled: isPreviousMonthDisabled, isNextMonthDisabled: isNextMonthDisabled, onPreviousMonthClick: onPreviousMonthClick, onNextMonthClick: onNextMonthClick, onMonthChange: onMonthChange, onYearChange: onYearChange })),
|