@telus-uds/components-web 3.3.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +7 -1
- package/CHANGELOG.md +38 -2
- package/jest.config.cjs +1 -1
- package/lib/cjs/Badge/Badge.js +128 -0
- package/lib/cjs/Badge/index.js +9 -0
- package/lib/cjs/BlockQuote/BlockQuote.js +256 -0
- package/lib/cjs/BlockQuote/index.js +9 -0
- package/lib/cjs/Breadcrumbs/Breadcrumbs.js +264 -0
- package/lib/cjs/Breadcrumbs/Item/Item.js +180 -0
- package/lib/cjs/Breadcrumbs/index.js +13 -0
- package/lib/cjs/Callout/Callout.js +141 -0
- package/lib/cjs/Callout/index.js +9 -0
- package/lib/cjs/Card/Card.js +257 -0
- package/lib/cjs/Card/CardContent.js +97 -0
- package/lib/cjs/Card/CardFooter.js +85 -0
- package/lib/cjs/Card/index.js +9 -0
- package/lib/cjs/Countdown/Countdown.js +268 -0
- package/lib/cjs/Countdown/Segment.js +108 -0
- package/lib/cjs/Countdown/constants.js +10 -0
- package/lib/cjs/Countdown/dictionary.js +28 -0
- package/lib/cjs/Countdown/index.js +9 -0
- package/lib/cjs/Countdown/types.js +31 -0
- package/lib/cjs/Countdown/useCountdown.js +32 -0
- package/lib/cjs/DatePicker/CalendarContainer.js +214 -0
- package/lib/cjs/DatePicker/DatePicker.js +525 -0
- package/lib/cjs/DatePicker/dictionary.js +125 -0
- package/lib/cjs/DatePicker/index.js +9 -0
- package/lib/cjs/DatePicker/reactDatesCss.js +9 -0
- package/lib/cjs/Disclaimer/Disclaimer.js +61 -0
- package/lib/cjs/Disclaimer/index.js +13 -0
- package/lib/cjs/Footnote/Footnote.js +637 -0
- package/lib/cjs/Footnote/FootnoteLink.js +125 -0
- package/lib/cjs/Footnote/dictionary.js +18 -0
- package/lib/cjs/Footnote/index.js +11 -0
- package/lib/cjs/IconButton/IconButton.js +62 -0
- package/lib/cjs/IconButton/index.js +9 -0
- package/lib/cjs/Image/Image.js +90 -0
- package/lib/cjs/Image/index.js +20 -0
- package/lib/cjs/Image/server.js +11 -0
- package/lib/cjs/List/List.js +8 -0
- package/lib/cjs/List/ListItem.js +34 -0
- package/lib/cjs/List/index.js +11 -0
- package/lib/cjs/NavigationBar/NavigationBar.js +282 -0
- package/lib/cjs/NavigationBar/NavigationItem.js +94 -0
- package/lib/cjs/NavigationBar/NavigationSubMenu.js +164 -0
- package/lib/{NavigationBar → cjs/NavigationBar}/collapseItems.js +9 -4
- package/lib/cjs/NavigationBar/index.js +11 -0
- package/lib/cjs/NavigationBar/resolveItemSelection.js +22 -0
- package/lib/cjs/OptimizeImage/OptimizeImage.js +99 -0
- package/lib/cjs/OptimizeImage/index.js +9 -0
- package/lib/cjs/OptimizeImage/utils/getFallbackUrl.js +14 -0
- package/lib/cjs/OptimizeImage/utils/getImageUrls.js +19 -0
- package/lib/cjs/OptimizeImage/utils/getOptimizedUrl.js +24 -0
- package/lib/cjs/OptimizeImage/utils/hasWebpSupport.js +34 -0
- package/lib/cjs/OptimizeImage/utils/index.js +34 -0
- package/lib/cjs/OptimizeImage/utils/isSvgUrl.js +9 -0
- package/lib/cjs/OrderedList/Item.js +151 -0
- package/lib/cjs/OrderedList/ItemBase.js +34 -0
- package/lib/cjs/OrderedList/OrderedList.js +92 -0
- package/lib/cjs/OrderedList/OrderedListBase.js +52 -0
- package/lib/cjs/OrderedList/constants.js +8 -0
- package/lib/cjs/OrderedList/index.js +11 -0
- package/lib/cjs/Paragraph/Paragraph.js +97 -0
- package/lib/cjs/Paragraph/index.js +9 -0
- package/lib/cjs/PreviewCard/AuthorDate.js +63 -0
- package/lib/cjs/PreviewCard/PreviewCard.js +215 -0
- package/lib/cjs/PreviewCard/index.js +9 -0
- package/lib/cjs/PriceLockup/PriceLockup.js +356 -0
- package/lib/cjs/PriceLockup/index.js +9 -0
- package/lib/cjs/PriceLockup/tokens.js +66 -0
- package/lib/cjs/Progress/ProgressBar.js +99 -0
- package/lib/cjs/Progress/index.js +11 -0
- package/lib/cjs/QuantitySelector/QuantitySelector.js +267 -0
- package/lib/cjs/QuantitySelector/SideButton.js +77 -0
- package/lib/cjs/QuantitySelector/dictionary.js +32 -0
- package/lib/cjs/QuantitySelector/index.js +9 -0
- package/lib/cjs/QuantitySelector/styles.js +16 -0
- package/lib/cjs/ResponsiveImage/ResponsiveImage.js +107 -0
- package/lib/cjs/ResponsiveImage/index.js +9 -0
- package/lib/cjs/Ribbon/Ribbon.js +222 -0
- package/lib/cjs/Ribbon/index.js +9 -0
- package/lib/cjs/SkeletonProvider/SkeletonImage.js +45 -0
- package/lib/cjs/SkeletonProvider/SkeletonProvider.js +63 -0
- package/lib/cjs/SkeletonProvider/SkeletonTypography.js +44 -0
- package/lib/cjs/SkeletonProvider/index.js +9 -0
- package/lib/cjs/Span/Span.js +79 -0
- package/lib/cjs/Span/index.js +9 -0
- package/lib/cjs/Spinner/Spinner.js +221 -0
- package/lib/cjs/Spinner/SpinnerContent.js +100 -0
- package/lib/cjs/Spinner/constants.js +10 -0
- package/lib/cjs/Spinner/index.js +9 -0
- package/lib/cjs/StoryCard/StoryCard.js +219 -0
- package/lib/cjs/StoryCard/index.js +9 -0
- package/lib/cjs/Table/Body.js +24 -0
- package/lib/cjs/Table/Cell.js +187 -0
- package/lib/cjs/Table/Header.js +32 -0
- package/lib/cjs/Table/Row.js +41 -0
- package/lib/cjs/Table/SubHeading.js +30 -0
- package/lib/cjs/Table/Table.js +124 -0
- package/lib/cjs/Table/index.js +19 -0
- package/lib/cjs/TermsAndConditions/ExpandCollapse.js +160 -0
- package/lib/cjs/TermsAndConditions/TermsAndConditions.js +283 -0
- package/lib/cjs/TermsAndConditions/dictionary.js +22 -0
- package/lib/cjs/TermsAndConditions/index.js +13 -0
- package/lib/cjs/Testimonial/Testimonial.js +240 -0
- package/lib/cjs/Testimonial/index.js +9 -0
- package/lib/cjs/Toast/Toast.js +165 -0
- package/lib/cjs/Toast/index.js +9 -0
- package/lib/cjs/Video/ControlBar/ControlBar.js +294 -0
- package/lib/cjs/Video/ControlBar/Controls/VideoButton/VideoButton.js +76 -0
- package/lib/cjs/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +169 -0
- package/lib/cjs/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +211 -0
- package/lib/cjs/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +197 -0
- package/lib/cjs/Video/MiddleControlButton/MiddleControlButton.js +78 -0
- package/lib/cjs/Video/Video.js +964 -0
- package/lib/cjs/Video/index.js +9 -0
- package/lib/cjs/Video/videoText.js +61 -0
- package/lib/cjs/VideoPicker/VideoPicker.js +197 -0
- package/lib/cjs/VideoPicker/VideoPickerPlayer.js +54 -0
- package/lib/cjs/VideoPicker/VideoPickerThumbnail.js +223 -0
- package/lib/cjs/VideoPicker/VideoSlider.js +88 -0
- package/lib/cjs/VideoPicker/index.js +9 -0
- package/lib/cjs/VideoPicker/videoPropType.js +17 -0
- package/lib/cjs/WaffleGrid/WaffleGrid.js +164 -0
- package/lib/cjs/WaffleGrid/index.js +9 -0
- package/lib/cjs/WebVideo/WebVideo.js +197 -0
- package/lib/cjs/WebVideo/index.js +9 -0
- package/lib/cjs/WebVideo/utils/index.js +57 -0
- package/lib/cjs/baseExports.js +438 -0
- package/lib/cjs/index.js +317 -0
- package/lib/cjs/server.js +13 -0
- package/lib/cjs/shared/ConditionalWrapper/ConditionalWrapper.js +29 -0
- package/lib/cjs/shared/ConditionalWrapper/index.js +9 -0
- package/lib/cjs/shared/FullBleedContent/FullBleedContent.js +108 -0
- package/lib/cjs/shared/FullBleedContent/getFullBleedBorderRadius.js +61 -0
- package/lib/cjs/shared/FullBleedContent/index.js +23 -0
- package/lib/cjs/shared/FullBleedContent/useFullBleedContentProps.js +61 -0
- package/lib/cjs/shared/VideoSplash/SplashButton/SplashButton.js +91 -0
- package/lib/cjs/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +229 -0
- package/lib/cjs/shared/VideoSplash/VideoSplash.js +72 -0
- package/lib/cjs/shared/VideoSplash/helpers.js +32 -0
- package/lib/cjs/utils/index.js +88 -0
- package/lib/cjs/utils/isElementFocusable.js +14 -0
- package/lib/cjs/utils/logger.js +24 -0
- package/lib/cjs/utils/media.js +45 -0
- package/lib/cjs/utils/renderStructuredContent.js +71 -0
- package/lib/cjs/utils/scrollToAnchor.js +25 -0
- package/lib/cjs/utils/ssr.js +50 -0
- package/lib/cjs/utils/theming/get-theme-from-server.js +24 -0
- package/lib/cjs/utils/theming/with-client-theme.js +31 -0
- package/lib/cjs/utils/theming/with-server-theme.js +33 -0
- package/lib/cjs/utils/transforms.js +11 -0
- package/lib/cjs/utils/useOverlaidPosition.js +222 -0
- package/lib/cjs/utils/useTypographyTheme.js +30 -0
- package/lib/{Badge → esm/Badge}/Badge.js +11 -19
- package/lib/{BlockQuote → esm/BlockQuote}/BlockQuote.js +17 -31
- package/lib/{Breadcrumbs → esm/Breadcrumbs}/Breadcrumbs.js +6 -5
- package/lib/{Breadcrumbs → esm/Breadcrumbs}/Item/Item.js +10 -6
- package/lib/{Callout → esm/Callout}/Callout.js +6 -5
- package/lib/{Card → esm/Card}/Card.js +10 -10
- package/lib/{Card → esm/Card}/CardContent.js +6 -5
- package/lib/{Card → esm/Card}/CardFooter.js +6 -5
- package/lib/{Countdown → esm/Countdown}/Countdown.js +53 -32
- package/lib/{Countdown → esm/Countdown}/Segment.js +6 -6
- package/lib/{DatePicker → esm/DatePicker}/CalendarContainer.js +5 -5
- package/lib/{DatePicker → esm/DatePicker}/DatePicker.js +24 -20
- package/lib/esm/DatePicker/reactDatesCss.js +3 -0
- package/lib/{Disclaimer → esm/Disclaimer}/Disclaimer.js +6 -5
- package/lib/{Footnote → esm/Footnote}/Footnote.js +43 -22
- package/lib/{Footnote → esm/Footnote}/FootnoteLink.js +6 -5
- package/lib/{NavigationBar → esm/NavigationBar}/NavigationBar.js +19 -20
- package/lib/{NavigationBar → esm/NavigationBar}/NavigationItem.js +6 -5
- package/lib/{NavigationBar → esm/NavigationBar}/NavigationSubMenu.js +1 -2
- package/lib/esm/NavigationBar/collapseItems.js +37 -0
- package/lib/{NavigationBar → esm/NavigationBar}/resolveItemSelection.js +1 -1
- package/lib/{OrderedList → esm/OrderedList}/Item.js +10 -6
- package/lib/{OrderedList → esm/OrderedList}/ItemBase.js +5 -5
- package/lib/{OrderedList → esm/OrderedList}/OrderedList.js +8 -8
- package/lib/{OrderedList → esm/OrderedList}/OrderedListBase.js +5 -5
- package/lib/{Paragraph → esm/Paragraph}/Paragraph.js +8 -16
- package/lib/{PreviewCard → esm/PreviewCard}/PreviewCard.js +10 -7
- package/lib/{PriceLockup → esm/PriceLockup}/PriceLockup.js +59 -69
- package/lib/{Progress → esm/Progress}/ProgressBar.js +6 -6
- package/lib/esm/QuantitySelector/styles.js +9 -0
- package/lib/{Ribbon → esm/Ribbon}/Ribbon.js +31 -57
- package/lib/{SkeletonProvider → esm/SkeletonProvider}/SkeletonImage.js +3 -4
- package/lib/esm/SkeletonProvider/SkeletonTypography.js +37 -0
- package/lib/{Span → esm/Span}/Span.js +7 -6
- package/lib/{Spinner → esm/Spinner}/Spinner.js +18 -8
- package/lib/{Spinner → esm/Spinner}/SpinnerContent.js +6 -5
- package/lib/{StoryCard → esm/StoryCard}/StoryCard.js +10 -7
- package/lib/{Table → esm/Table}/Cell.js +16 -45
- package/lib/esm/Table/Row.js +34 -0
- package/lib/{Table → esm/Table}/Table.js +18 -20
- package/lib/{TermsAndConditions → esm/TermsAndConditions}/ExpandCollapse.js +15 -8
- package/lib/{TermsAndConditions → esm/TermsAndConditions}/TermsAndConditions.js +22 -9
- package/lib/{Testimonial → esm/Testimonial}/Testimonial.js +26 -10
- package/lib/{Toast → esm/Toast}/Toast.js +15 -67
- package/lib/{Video → esm/Video}/ControlBar/ControlBar.js +18 -8
- package/lib/{Video → esm/Video}/ControlBar/Controls/VideoButton/VideoButton.js +7 -7
- package/lib/{Video → esm/Video}/ControlBar/Controls/VideoMenu/VideoMenu.js +14 -7
- package/lib/{Video → esm/Video}/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +14 -7
- package/lib/{Video → esm/Video}/ControlBar/Controls/VolumeSlider/VolumeSlider.js +10 -6
- package/lib/{Video → esm/Video}/MiddleControlButton/MiddleControlButton.js +6 -5
- package/lib/{Video → esm/Video}/Video.js +28 -12
- package/lib/{VideoPicker → esm/VideoPicker}/VideoPicker.js +21 -46
- package/lib/{VideoPicker → esm/VideoPicker}/VideoPickerThumbnail.js +19 -54
- package/lib/{WaffleGrid → esm/WaffleGrid}/WaffleGrid.js +14 -7
- package/lib/{WebVideo → esm/WebVideo}/WebVideo.js +14 -9
- package/lib/{baseExports.js → esm/baseExports.js} +1 -1
- package/lib/{index.js → esm/index.js} +1 -2
- package/lib/{shared → esm/shared}/FullBleedContent/FullBleedContent.js +5 -5
- package/lib/{shared → esm/shared}/VideoSplash/SplashButton/SplashButton.js +9 -6
- package/lib/{shared → esm/shared}/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +17 -8
- package/lib/{shared → esm/shared}/VideoSplash/VideoSplash.js +6 -5
- package/lib/{utils → esm/utils}/index.js +1 -2
- package/lib/{utils → esm/utils}/scrollToAnchor.js +2 -2
- package/lib/{utils → esm/utils}/ssr.js +8 -4
- package/lib/{utils → esm/utils}/useOverlaidPosition.js +2 -4
- package/package.json +17 -16
- package/src/Badge/Badge.jsx +4 -3
- package/src/BlockQuote/BlockQuote.jsx +2 -3
- package/src/Breadcrumbs/Breadcrumbs.jsx +2 -3
- package/src/Breadcrumbs/Item/Item.jsx +2 -3
- package/src/Callout/Callout.jsx +2 -4
- package/src/Card/Card.jsx +1 -3
- package/src/Card/CardContent.jsx +2 -3
- package/src/Card/CardFooter.jsx +2 -3
- package/src/Countdown/Countdown.jsx +62 -36
- package/src/Countdown/Segment.jsx +1 -3
- package/src/DatePicker/CalendarContainer.jsx +1 -3
- package/src/DatePicker/DatePicker.jsx +2 -3
- package/src/DatePicker/reactDatesCss.js +1 -3
- package/src/Disclaimer/Disclaimer.jsx +2 -3
- package/src/Footnote/Footnote.jsx +2 -10
- package/src/Footnote/FootnoteLink.jsx +2 -3
- package/src/NavigationBar/NavigationBar.jsx +2 -3
- package/src/NavigationBar/NavigationItem.jsx +2 -3
- package/src/OrderedList/Item.jsx +2 -3
- package/src/OrderedList/ItemBase.jsx +1 -3
- package/src/OrderedList/OrderedList.jsx +2 -3
- package/src/OrderedList/OrderedListBase.jsx +1 -3
- package/src/Paragraph/Paragraph.jsx +2 -4
- package/src/PreviewCard/PreviewCard.jsx +1 -3
- package/src/PriceLockup/PriceLockup.jsx +2 -3
- package/src/Progress/ProgressBar.jsx +1 -3
- package/src/QuantitySelector/styles.js +1 -3
- package/src/Ribbon/Ribbon.jsx +2 -3
- package/src/Span/Span.jsx +2 -4
- package/src/Spinner/Spinner.jsx +2 -3
- package/src/Spinner/SpinnerContent.jsx +2 -3
- package/src/StoryCard/StoryCard.jsx +1 -3
- package/src/Table/Cell.jsx +4 -5
- package/src/Table/Row.jsx +13 -2
- package/src/Table/Table.jsx +14 -5
- package/src/TermsAndConditions/ExpandCollapse.jsx +6 -4
- package/src/TermsAndConditions/TermsAndConditions.jsx +2 -3
- package/src/Testimonial/Testimonial.jsx +2 -3
- package/src/Toast/Toast.jsx +2 -3
- package/src/Video/ControlBar/ControlBar.jsx +2 -4
- package/src/Video/ControlBar/Controls/VideoButton/VideoButton.jsx +2 -4
- package/src/Video/ControlBar/Controls/VideoMenu/VideoMenu.jsx +2 -4
- package/src/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.jsx +2 -4
- package/src/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.jsx +2 -4
- package/src/Video/MiddleControlButton/MiddleControlButton.jsx +2 -4
- package/src/Video/Video.jsx +2 -4
- package/src/VideoPicker/VideoPicker.jsx +2 -4
- package/src/VideoPicker/VideoPickerThumbnail.jsx +1 -3
- package/src/WaffleGrid/WaffleGrid.jsx +2 -3
- package/src/WebVideo/WebVideo.jsx +3 -4
- package/src/baseExports.js +1 -0
- package/src/index.js +1 -2
- package/src/shared/FullBleedContent/FullBleedContent.jsx +1 -3
- package/src/shared/VideoSplash/SplashButton/SplashButton.jsx +1 -3
- package/src/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.jsx +1 -4
- package/src/shared/VideoSplash/VideoSplash.jsx +2 -3
- package/src/utils/index.js +1 -3
- package/src/utils/ssr.js +10 -3
- package/types/Callout.d.ts +2 -1
- package/types/Tooltip.d.ts +1 -0
- package/lib/DatePicker/reactDatesCss.js +0 -830
- package/lib/ExpandCollapseMini/ExpandCollapseMini.js +0 -73
- package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +0 -116
- package/lib/ExpandCollapseMini/index.js +0 -2
- package/lib/QuantitySelector/styles.js +0 -18
- package/lib/SkeletonProvider/SkeletonTypography.js +0 -38
- package/lib/Table/Row.js +0 -19
- package/lib/utils/theming/styled-components.js +0 -26
- package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +0 -72
- package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +0 -104
- package/src/ExpandCollapseMini/index.js +0 -3
- package/src/utils/theming/styled-components.js +0 -23
- /package/lib/{Badge → esm/Badge}/index.js +0 -0
- /package/lib/{BlockQuote → esm/BlockQuote}/index.js +0 -0
- /package/lib/{Breadcrumbs → esm/Breadcrumbs}/index.js +0 -0
- /package/lib/{Callout → esm/Callout}/index.js +0 -0
- /package/lib/{Card → esm/Card}/index.js +0 -0
- /package/lib/{Countdown → esm/Countdown}/constants.js +0 -0
- /package/lib/{Countdown → esm/Countdown}/dictionary.js +0 -0
- /package/lib/{Countdown → esm/Countdown}/index.js +0 -0
- /package/lib/{Countdown → esm/Countdown}/types.js +0 -0
- /package/lib/{Countdown → esm/Countdown}/useCountdown.js +0 -0
- /package/lib/{DatePicker → esm/DatePicker}/dictionary.js +0 -0
- /package/lib/{DatePicker → esm/DatePicker}/index.js +0 -0
- /package/lib/{Disclaimer → esm/Disclaimer}/index.js +0 -0
- /package/lib/{Footnote → esm/Footnote}/dictionary.js +0 -0
- /package/lib/{Footnote → esm/Footnote}/index.js +0 -0
- /package/lib/{IconButton → esm/IconButton}/IconButton.js +0 -0
- /package/lib/{IconButton → esm/IconButton}/index.js +0 -0
- /package/lib/{Image → esm/Image}/Image.js +0 -0
- /package/lib/{Image → esm/Image}/index.js +0 -0
- /package/lib/{Image → esm/Image}/server.js +0 -0
- /package/lib/{List → esm/List}/List.js +0 -0
- /package/lib/{List → esm/List}/ListItem.js +0 -0
- /package/lib/{List → esm/List}/index.js +0 -0
- /package/lib/{NavigationBar → esm/NavigationBar}/index.js +0 -0
- /package/lib/{OptimizeImage → esm/OptimizeImage}/OptimizeImage.js +0 -0
- /package/lib/{OptimizeImage → esm/OptimizeImage}/index.js +0 -0
- /package/lib/{OptimizeImage → esm/OptimizeImage}/utils/getFallbackUrl.js +0 -0
- /package/lib/{OptimizeImage → esm/OptimizeImage}/utils/getImageUrls.js +0 -0
- /package/lib/{OptimizeImage → esm/OptimizeImage}/utils/getOptimizedUrl.js +0 -0
- /package/lib/{OptimizeImage → esm/OptimizeImage}/utils/hasWebpSupport.js +0 -0
- /package/lib/{OptimizeImage → esm/OptimizeImage}/utils/index.js +0 -0
- /package/lib/{OptimizeImage → esm/OptimizeImage}/utils/isSvgUrl.js +0 -0
- /package/lib/{OrderedList → esm/OrderedList}/constants.js +0 -0
- /package/lib/{OrderedList → esm/OrderedList}/index.js +0 -0
- /package/lib/{Paragraph → esm/Paragraph}/index.js +0 -0
- /package/lib/{PreviewCard → esm/PreviewCard}/AuthorDate.js +0 -0
- /package/lib/{PreviewCard → esm/PreviewCard}/index.js +0 -0
- /package/lib/{PriceLockup → esm/PriceLockup}/index.js +0 -0
- /package/lib/{PriceLockup → esm/PriceLockup}/tokens.js +0 -0
- /package/lib/{Progress → esm/Progress}/index.js +0 -0
- /package/lib/{QuantitySelector → esm/QuantitySelector}/QuantitySelector.js +0 -0
- /package/lib/{QuantitySelector → esm/QuantitySelector}/SideButton.js +0 -0
- /package/lib/{QuantitySelector → esm/QuantitySelector}/dictionary.js +0 -0
- /package/lib/{QuantitySelector → esm/QuantitySelector}/index.js +0 -0
- /package/lib/{ResponsiveImage → esm/ResponsiveImage}/ResponsiveImage.js +0 -0
- /package/lib/{ResponsiveImage → esm/ResponsiveImage}/index.js +0 -0
- /package/lib/{Ribbon → esm/Ribbon}/index.js +0 -0
- /package/lib/{SkeletonProvider → esm/SkeletonProvider}/SkeletonProvider.js +0 -0
- /package/lib/{SkeletonProvider → esm/SkeletonProvider}/index.js +0 -0
- /package/lib/{Span → esm/Span}/index.js +0 -0
- /package/lib/{Spinner → esm/Spinner}/constants.js +0 -0
- /package/lib/{Spinner → esm/Spinner}/index.js +0 -0
- /package/lib/{StoryCard → esm/StoryCard}/index.js +0 -0
- /package/lib/{Table → esm/Table}/Body.js +0 -0
- /package/lib/{Table → esm/Table}/Header.js +0 -0
- /package/lib/{Table → esm/Table}/SubHeading.js +0 -0
- /package/lib/{Table → esm/Table}/index.js +0 -0
- /package/lib/{TermsAndConditions → esm/TermsAndConditions}/dictionary.js +0 -0
- /package/lib/{TermsAndConditions → esm/TermsAndConditions}/index.js +0 -0
- /package/lib/{Testimonial → esm/Testimonial}/index.js +0 -0
- /package/lib/{Toast → esm/Toast}/index.js +0 -0
- /package/lib/{Video → esm/Video}/index.js +0 -0
- /package/lib/{Video → esm/Video}/videoText.js +0 -0
- /package/lib/{VideoPicker → esm/VideoPicker}/VideoPickerPlayer.js +0 -0
- /package/lib/{VideoPicker → esm/VideoPicker}/VideoSlider.js +0 -0
- /package/lib/{VideoPicker → esm/VideoPicker}/index.js +0 -0
- /package/lib/{VideoPicker → esm/VideoPicker}/videoPropType.js +0 -0
- /package/lib/{WaffleGrid → esm/WaffleGrid}/index.js +0 -0
- /package/lib/{WebVideo → esm/WebVideo}/index.js +0 -0
- /package/lib/{WebVideo → esm/WebVideo}/utils/index.js +0 -0
- /package/lib/{server.js → esm/server.js} +0 -0
- /package/lib/{shared → esm/shared}/ConditionalWrapper/ConditionalWrapper.js +0 -0
- /package/lib/{shared → esm/shared}/ConditionalWrapper/index.js +0 -0
- /package/lib/{shared → esm/shared}/FullBleedContent/getFullBleedBorderRadius.js +0 -0
- /package/lib/{shared → esm/shared}/FullBleedContent/index.js +0 -0
- /package/lib/{shared → esm/shared}/FullBleedContent/useFullBleedContentProps.js +0 -0
- /package/lib/{shared → esm/shared}/VideoSplash/helpers.js +0 -0
- /package/lib/{utils → esm/utils}/isElementFocusable.js +0 -0
- /package/lib/{utils → esm/utils}/logger.js +0 -0
- /package/lib/{utils → esm/utils}/media.js +0 -0
- /package/lib/{utils → esm/utils}/renderStructuredContent.js +0 -0
- /package/lib/{utils → esm/utils}/theming/get-theme-from-server.js +0 -0
- /package/lib/{utils → esm/utils}/theming/with-client-theme.js +0 -0
- /package/lib/{utils → esm/utils}/theming/with-server-theme.js +0 -0
- /package/lib/{utils → esm/utils}/transforms.js +0 -0
- /package/lib/{utils → esm/utils}/useTypographyTheme.js +0 -0
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _componentsBase = require("@telus-uds/components-base");
|
|
10
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
11
|
+
var _OrderedListBase = _interopRequireDefault(require("../OrderedList/OrderedListBase"));
|
|
12
|
+
var _utils = require("../utils");
|
|
13
|
+
var _dictionary = _interopRequireDefault(require("./dictionary"));
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
+
const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
|
|
19
|
+
const viewportBreakpoint = 1440;
|
|
20
|
+
const GlobalBodyScrollLock = /*#__PURE__*/(0, _styledComponents.createGlobalStyle)({
|
|
21
|
+
'html, body': (0, _utils.media)().until('md').css({
|
|
22
|
+
overflow: 'hidden'
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
const StyledFootnote = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
26
|
+
displayName: "Footnote__StyledFootnote",
|
|
27
|
+
componentId: "components-web__sc-1563bo5-0"
|
|
28
|
+
})(_ref => {
|
|
29
|
+
let {
|
|
30
|
+
footnoteBackground,
|
|
31
|
+
isVisible,
|
|
32
|
+
footnoteBorderTop,
|
|
33
|
+
isScrollable,
|
|
34
|
+
isMobileFullScreen
|
|
35
|
+
} = _ref;
|
|
36
|
+
return {
|
|
37
|
+
position: 'fixed',
|
|
38
|
+
overflowY: isVisible && isScrollable ? 'scroll' : 'hidden',
|
|
39
|
+
top: 0,
|
|
40
|
+
left: window.innerWidth >= viewportBreakpoint ? '50%' : 0,
|
|
41
|
+
height: '100vh',
|
|
42
|
+
width: '100vw',
|
|
43
|
+
backgroundColor: footnoteBackground,
|
|
44
|
+
display: 'block',
|
|
45
|
+
transform: 'translateY(100%)',
|
|
46
|
+
translate: window.innerWidth >= viewportBreakpoint ? '-50%' : '',
|
|
47
|
+
transition: 'transform 500ms ease-out',
|
|
48
|
+
'@media() (prefers-reduced-motion: reduce)': {
|
|
49
|
+
transition: 'none'
|
|
50
|
+
},
|
|
51
|
+
zIndex: 99999,
|
|
52
|
+
visibility: isVisible ? 'visible' : 'hidden',
|
|
53
|
+
...(0, _utils.media)().from(isMobileFullScreen ? 'md' : 'xs').css({
|
|
54
|
+
top: 'auto',
|
|
55
|
+
bottom: 0,
|
|
56
|
+
height: 'auto',
|
|
57
|
+
maxHeight: '50vh',
|
|
58
|
+
borderTop: footnoteBorderTop
|
|
59
|
+
})
|
|
60
|
+
};
|
|
61
|
+
}, _ref2 => {
|
|
62
|
+
let {
|
|
63
|
+
isOpen
|
|
64
|
+
} = _ref2;
|
|
65
|
+
if (isOpen) {
|
|
66
|
+
return {
|
|
67
|
+
transform: 'translateY(0)'
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {};
|
|
71
|
+
});
|
|
72
|
+
const StyledFootnoteHeader = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
73
|
+
displayName: "Footnote__StyledFootnoteHeader",
|
|
74
|
+
componentId: "components-web__sc-1563bo5-1"
|
|
75
|
+
})(() => ({
|
|
76
|
+
position: 'relative',
|
|
77
|
+
width: '100%'
|
|
78
|
+
}));
|
|
79
|
+
const StyledHeader = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
80
|
+
displayName: "Footnote__StyledHeader",
|
|
81
|
+
componentId: "components-web__sc-1563bo5-2"
|
|
82
|
+
})(_ref3 => {
|
|
83
|
+
let {
|
|
84
|
+
footnoteHeaderPaddingLeft,
|
|
85
|
+
footnoteHeaderPaddingRight,
|
|
86
|
+
footnoteHeaderPaddingTop,
|
|
87
|
+
footnoteHeaderPaddingBottom
|
|
88
|
+
} = _ref3;
|
|
89
|
+
return {
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
display: 'flex',
|
|
92
|
+
flexDirection: 'row',
|
|
93
|
+
justifyContent: 'space-between',
|
|
94
|
+
paddingTop: footnoteHeaderPaddingTop,
|
|
95
|
+
paddingBottom: footnoteHeaderPaddingBottom,
|
|
96
|
+
paddingRight: footnoteHeaderPaddingRight,
|
|
97
|
+
paddingLeft: footnoteHeaderPaddingLeft
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
const StyledFootnoteBody = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
101
|
+
displayName: "Footnote__StyledFootnoteBody",
|
|
102
|
+
componentId: "components-web__sc-1563bo5-3"
|
|
103
|
+
})(_ref4 => {
|
|
104
|
+
let {
|
|
105
|
+
footnoteBodyBackground,
|
|
106
|
+
footnoteBodyPadding,
|
|
107
|
+
headerHeight,
|
|
108
|
+
bodyHeight,
|
|
109
|
+
isTextVisible
|
|
110
|
+
} = _ref4;
|
|
111
|
+
return {
|
|
112
|
+
overflow: 'auto',
|
|
113
|
+
transition: 'height 300ms ease-out, opacity 200ms ease-out',
|
|
114
|
+
transform: 'translateZ(0)',
|
|
115
|
+
'@media() (prefers-reduced-motion: reduce)': {
|
|
116
|
+
transition: 'height 1ms ease-out, opacity 1ms ease-out'
|
|
117
|
+
},
|
|
118
|
+
backgroundColor: footnoteBodyBackground,
|
|
119
|
+
padding: footnoteBodyPadding,
|
|
120
|
+
maxHeight: `calc(100vh - ${headerHeight}px)`,
|
|
121
|
+
...(0, _utils.media)().from('md').css({
|
|
122
|
+
maxHeight: `calc(50vh - ${headerHeight}px)`
|
|
123
|
+
}),
|
|
124
|
+
height: bodyHeight,
|
|
125
|
+
opacity: isTextVisible ? 1 : 0
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
const List = /*#__PURE__*/(0, _styledComponents.default)(_OrderedListBase.default).withConfig({
|
|
129
|
+
displayName: "Footnote__List",
|
|
130
|
+
componentId: "components-web__sc-1563bo5-4"
|
|
131
|
+
})(_ref5 => {
|
|
132
|
+
let {
|
|
133
|
+
listPaddingLeft
|
|
134
|
+
} = _ref5;
|
|
135
|
+
return {
|
|
136
|
+
listStylePosition: 'outside',
|
|
137
|
+
paddingLeft: listPaddingLeft
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
const ListItem = /*#__PURE__*/(0, _styledComponents.default)(_OrderedListBase.default.Item).withConfig({
|
|
141
|
+
displayName: "Footnote__ListItem",
|
|
142
|
+
componentId: "components-web__sc-1563bo5-5"
|
|
143
|
+
})(_ref6 => {
|
|
144
|
+
let {
|
|
145
|
+
listItemMarkerFontSize,
|
|
146
|
+
listItemMarkerLineHeight,
|
|
147
|
+
listItemColor,
|
|
148
|
+
listItemFontSize,
|
|
149
|
+
listItemLineHeight,
|
|
150
|
+
listItemPaddingLeft
|
|
151
|
+
} = _ref6;
|
|
152
|
+
return {
|
|
153
|
+
display: 'list-item',
|
|
154
|
+
'&::marker': {
|
|
155
|
+
fontFamily: 'HNforTELUSSA400normal',
|
|
156
|
+
fontSize: listItemMarkerFontSize,
|
|
157
|
+
lineHeight: listItemMarkerLineHeight,
|
|
158
|
+
textAlign: 'end !important'
|
|
159
|
+
},
|
|
160
|
+
color: listItemColor,
|
|
161
|
+
fontFamily: 'HNforTELUSSA400normal',
|
|
162
|
+
fontSize: listItemFontSize,
|
|
163
|
+
lineHeight: listItemLineHeight,
|
|
164
|
+
paddingLeft: listItemPaddingLeft
|
|
165
|
+
};
|
|
166
|
+
});
|
|
167
|
+
const CloseButton = /*#__PURE__*/_styledComponents.default.button.withConfig({
|
|
168
|
+
displayName: "Footnote__CloseButton",
|
|
169
|
+
componentId: "components-web__sc-1563bo5-6"
|
|
170
|
+
})(_ref7 => {
|
|
171
|
+
let {
|
|
172
|
+
closeButtonBorder,
|
|
173
|
+
closeButtonHeight,
|
|
174
|
+
closeButtonBackgroundColor,
|
|
175
|
+
closeButtonMargin,
|
|
176
|
+
closeButtonWidth
|
|
177
|
+
} = _ref7;
|
|
178
|
+
return {
|
|
179
|
+
alignItems: 'center',
|
|
180
|
+
borderRadius: '50%',
|
|
181
|
+
cursor: 'pointer',
|
|
182
|
+
display: 'flex',
|
|
183
|
+
justifyContent: 'center',
|
|
184
|
+
backgroundColor: closeButtonBackgroundColor,
|
|
185
|
+
border: closeButtonBorder,
|
|
186
|
+
height: closeButtonHeight,
|
|
187
|
+
margin: closeButtonMargin,
|
|
188
|
+
width: closeButtonWidth
|
|
189
|
+
};
|
|
190
|
+
});
|
|
191
|
+
const ContentContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
192
|
+
displayName: "Footnote__ContentContainer",
|
|
193
|
+
componentId: "components-web__sc-1563bo5-7"
|
|
194
|
+
})({
|
|
195
|
+
'margin-left': 'auto',
|
|
196
|
+
'margin-right': 'auto',
|
|
197
|
+
left: 0,
|
|
198
|
+
right: 0,
|
|
199
|
+
maxWidth: '1200px'
|
|
200
|
+
}, _ref8 => {
|
|
201
|
+
let {
|
|
202
|
+
maxWidth
|
|
203
|
+
} = _ref8;
|
|
204
|
+
return {
|
|
205
|
+
width: maxWidth
|
|
206
|
+
};
|
|
207
|
+
});
|
|
208
|
+
const StyledCustomContentContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
209
|
+
displayName: "Footnote__StyledCustomContentContainer",
|
|
210
|
+
componentId: "components-web__sc-1563bo5-8"
|
|
211
|
+
})(_ref9 => {
|
|
212
|
+
let {
|
|
213
|
+
listItemColor,
|
|
214
|
+
listItemFontSize,
|
|
215
|
+
listItemLineHeight,
|
|
216
|
+
listItemPaddingLeft
|
|
217
|
+
} = _ref9;
|
|
218
|
+
return {
|
|
219
|
+
fontSize: listItemFontSize,
|
|
220
|
+
lineHeight: listItemLineHeight,
|
|
221
|
+
paddingLeft: listItemPaddingLeft,
|
|
222
|
+
color: listItemColor,
|
|
223
|
+
fontFamily: 'HNforTELUSSA400normal'
|
|
224
|
+
};
|
|
225
|
+
});
|
|
226
|
+
const usePrevious = value => {
|
|
227
|
+
const ref = _react.default.useRef();
|
|
228
|
+
_react.default.useEffect(() => {
|
|
229
|
+
ref.current = value;
|
|
230
|
+
});
|
|
231
|
+
if (ref.current) {
|
|
232
|
+
return ref.current;
|
|
233
|
+
}
|
|
234
|
+
return {};
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Use `Footnote` to display a single legal content.
|
|
239
|
+
*
|
|
240
|
+
* ## Usage Criteria
|
|
241
|
+
*
|
|
242
|
+
* - Use `Footnote` to display a single legal statement
|
|
243
|
+
* - Display on top of all UI, including other sticky elements such as Cart Summary
|
|
244
|
+
* - Dismiss by clicking on the close button, clicking anywhere outside of the `Footnote`, or by pressing the ESC key
|
|
245
|
+
* - Responsive display based on breakpoints
|
|
246
|
+
* - Use copy to set language, ‘en’ for English or ‘fr’ for French
|
|
247
|
+
*
|
|
248
|
+
* ## Accessibility requirements
|
|
249
|
+
*
|
|
250
|
+
* - Only one instance of `Footnote` should display at a time
|
|
251
|
+
* - Place `Footnote` as the last element in the body or main
|
|
252
|
+
* - When `Footnote` is open, the inert prop must be set on all children of body excluding the Footnote
|
|
253
|
+
* - When `Footnote` is closed, focus must return to the initiating element
|
|
254
|
+
*/
|
|
255
|
+
const Footnote = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
256
|
+
const {
|
|
257
|
+
copy = 'en',
|
|
258
|
+
number,
|
|
259
|
+
content,
|
|
260
|
+
onClose,
|
|
261
|
+
isOpen = false,
|
|
262
|
+
tokens,
|
|
263
|
+
variant = {},
|
|
264
|
+
isMobileFullScreen = true,
|
|
265
|
+
dictionary = _dictionary.default,
|
|
266
|
+
...rest
|
|
267
|
+
} = props;
|
|
268
|
+
const viewport = (0, _componentsBase.useViewport)();
|
|
269
|
+
const {
|
|
270
|
+
footnoteBackground,
|
|
271
|
+
footnoteBorderTopSizeMd,
|
|
272
|
+
footnoteBorderColorMd,
|
|
273
|
+
headerMargin,
|
|
274
|
+
footnoteBodyBackground,
|
|
275
|
+
footnoteBodyPaddingLeft,
|
|
276
|
+
footnoteBodyPaddingRight,
|
|
277
|
+
footnoteBodyPaddingTop,
|
|
278
|
+
footnoteBodyPaddingBottom,
|
|
279
|
+
footnoteHeaderPaddingLeft,
|
|
280
|
+
footnoteHeaderPaddingRight,
|
|
281
|
+
footnoteHeaderPaddingTop,
|
|
282
|
+
footnoteHeaderPaddingBottom,
|
|
283
|
+
headerLineHeight,
|
|
284
|
+
headerFontSize,
|
|
285
|
+
listPaddingLeft,
|
|
286
|
+
listItemMarkerFontSize,
|
|
287
|
+
listItemMarkerLineHeight,
|
|
288
|
+
listItemColor,
|
|
289
|
+
listItemFontSize,
|
|
290
|
+
listItemLineHeight,
|
|
291
|
+
listItemPaddingLeft,
|
|
292
|
+
closeButtonBorderSize,
|
|
293
|
+
closeButtonBorderColor,
|
|
294
|
+
closeButtonBackgroundColor,
|
|
295
|
+
closeButtonHeight,
|
|
296
|
+
closeButtonMarginTop,
|
|
297
|
+
closeButtonMarginLeft,
|
|
298
|
+
closeButtonMarginRight,
|
|
299
|
+
closeButtonMarginBottom,
|
|
300
|
+
closeButtonWidth,
|
|
301
|
+
closeButtonIconSize,
|
|
302
|
+
closeIcon
|
|
303
|
+
} = (0, _componentsBase.useThemeTokens)('Footnote', tokens, variant, {
|
|
304
|
+
viewport
|
|
305
|
+
});
|
|
306
|
+
const footnoteRef = _react.default.useRef(null);
|
|
307
|
+
const headerRef = _react.default.useRef(null);
|
|
308
|
+
const bodyRef = _react.default.useRef(null);
|
|
309
|
+
const contentRef = _react.default.useRef(null);
|
|
310
|
+
const closeButtonRef = _react.default.useRef(null);
|
|
311
|
+
const [data, setData] = _react.default.useState({
|
|
312
|
+
content: null,
|
|
313
|
+
number: null
|
|
314
|
+
});
|
|
315
|
+
const [headerHeight, setHeaderHeight] = _react.default.useState('auto');
|
|
316
|
+
const [bodyHeight, setBodyHeight] = _react.default.useState('auto');
|
|
317
|
+
const [isVisible, setIsVisible] = _react.default.useState(false);
|
|
318
|
+
const [isTextVisible, setIsTextVisible] = _react.default.useState(true);
|
|
319
|
+
const getCopy = (0, _componentsBase.useCopy)({
|
|
320
|
+
dictionary,
|
|
321
|
+
copy
|
|
322
|
+
});
|
|
323
|
+
const prevProps = usePrevious(props);
|
|
324
|
+
const theme = (0, _componentsBase.useTheme)();
|
|
325
|
+
const maxWidth = (0, _componentsBase.useResponsiveProp)(theme.themeOptions?.contentMaxWidth);
|
|
326
|
+
const [isScrollable, setIsScrollable] = _react.default.useState(false);
|
|
327
|
+
const closeFootnote = _react.default.useCallback((event, options) => {
|
|
328
|
+
onClose(event, options);
|
|
329
|
+
}, [onClose]);
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* When listen for ESCAPE, close button clicks, and clicks outside of the Footnote. Call onClose.
|
|
333
|
+
* When the event type is a 'keydonw' and the event key is a 'Tab', using a 'querySelectorAll we obtain all
|
|
334
|
+
* the interactive elements within the footnote, we order and save the first and the last,
|
|
335
|
+
* if the footnote is active the focus will be inside the footnote until it is closed,
|
|
336
|
+
* if there are no interactive elements the focus will remain inside the close button.
|
|
337
|
+
*/
|
|
338
|
+
const manageFootnoteFocusAndClose = _react.default.useCallback(event => {
|
|
339
|
+
if (!isVisible) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
if (event.type === 'keydown') {
|
|
343
|
+
if (event.key === 'Escape' || event.key === 27) {
|
|
344
|
+
closeFootnote(event, {
|
|
345
|
+
returnFocus: true
|
|
346
|
+
});
|
|
347
|
+
} else if (event.key === 'Tab') {
|
|
348
|
+
const focusableElements = Array.from(footnoteRef.current.querySelectorAll('*')).filter(_utils.isElementFocusable);
|
|
349
|
+
const firstElement = focusableElements[0];
|
|
350
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
351
|
+
if (event.shiftKey && document.activeElement === firstElement) {
|
|
352
|
+
event.preventDefault();
|
|
353
|
+
lastElement.focus();
|
|
354
|
+
} else if (!event.shiftKey && document.activeElement === lastElement) {
|
|
355
|
+
event.preventDefault();
|
|
356
|
+
firstElement.focus();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
} else if ((event.type === 'click' || event.type === 'mousedown') && footnoteRef?.current && event.target && !footnoteRef?.current?.contains(event.target) && event.target.getAttribute('data-tds-id') !== 'footnote-link') {
|
|
360
|
+
closeFootnote(event, {
|
|
361
|
+
returnFocus: false
|
|
362
|
+
});
|
|
363
|
+
} else if (event.type === 'touchstart' && footnoteRef?.current && event.touches[0].target && !footnoteRef?.current?.contains(event.touches[0].target) && event.touches[0].target.getAttribute('data-tds-id') !== 'footnote-link') {
|
|
364
|
+
closeFootnote(event, {
|
|
365
|
+
returnFocus: false
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}, [closeFootnote, isVisible]);
|
|
369
|
+
const saveCurrentHeight = () => {
|
|
370
|
+
const oldHeight = contentRef.current.offsetHeight;
|
|
371
|
+
setBodyHeight(oldHeight);
|
|
372
|
+
};
|
|
373
|
+
const focusHeading = () => {
|
|
374
|
+
if (Boolean(content) && isVisible && closeButtonRef && closeButtonRef.current !== null) {
|
|
375
|
+
closeButtonRef.current.focus();
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
const handleStyledFootnoteTransitionEnd = event => {
|
|
379
|
+
if (event.propertyName === 'transform' && !isOpen) {
|
|
380
|
+
setIsVisible(false);
|
|
381
|
+
} else {
|
|
382
|
+
focusHeading();
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
const handleTransitionEnd = event => {
|
|
386
|
+
event.persist();
|
|
387
|
+
if (event.propertyName === 'opacity' && !isTextVisible) {
|
|
388
|
+
setData({
|
|
389
|
+
content,
|
|
390
|
+
number
|
|
391
|
+
});
|
|
392
|
+
if (bodyHeight !== contentRef.current.offsetHeight) {
|
|
393
|
+
// Set new height
|
|
394
|
+
setBodyHeight(contentRef.current.offsetHeight);
|
|
395
|
+
} else {
|
|
396
|
+
setIsTextVisible(true);
|
|
397
|
+
}
|
|
398
|
+
} else {
|
|
399
|
+
setBodyHeight(contentRef.current.offsetHeight);
|
|
400
|
+
}
|
|
401
|
+
if (event.propertyName === 'height' && !isTextVisible) {
|
|
402
|
+
setIsTextVisible(true);
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
const resetFootnote = () => {
|
|
406
|
+
// Reset footnote state if closed
|
|
407
|
+
if (!isOpen) {
|
|
408
|
+
setBodyHeight('auto');
|
|
409
|
+
setIsTextVisible(true);
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
// Set height of header on mount
|
|
414
|
+
_react.default.useEffect(() => {
|
|
415
|
+
setHeaderHeight(headerRef.current?.offsetHeight);
|
|
416
|
+
}, []);
|
|
417
|
+
const preventDefault = event => {
|
|
418
|
+
if (!bodyRef.current.contains(event.touches[0].target)) {
|
|
419
|
+
event.preventDefault();
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
// Add listeners for mouse clicks outside of Footnote and for ESCAPE key presses
|
|
424
|
+
_react.default.useEffect(() => {
|
|
425
|
+
if (isOpen) {
|
|
426
|
+
setIsVisible(true);
|
|
427
|
+
document.addEventListener('mousedown', manageFootnoteFocusAndClose);
|
|
428
|
+
window.addEventListener('click', manageFootnoteFocusAndClose);
|
|
429
|
+
window.addEventListener('keydown', manageFootnoteFocusAndClose);
|
|
430
|
+
window.addEventListener('touchstart', manageFootnoteFocusAndClose);
|
|
431
|
+
window.addEventListener('touchmove', preventDefault, {
|
|
432
|
+
passive: false
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
return () => {
|
|
436
|
+
if (isOpen) {
|
|
437
|
+
document.removeEventListener('mousedown', manageFootnoteFocusAndClose);
|
|
438
|
+
window.removeEventListener('click', manageFootnoteFocusAndClose);
|
|
439
|
+
window.removeEventListener('keydown', manageFootnoteFocusAndClose);
|
|
440
|
+
window.removeEventListener('touchstart', manageFootnoteFocusAndClose);
|
|
441
|
+
window.removeEventListener('touchmove', preventDefault);
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
}, [manageFootnoteFocusAndClose, isOpen]);
|
|
445
|
+
|
|
446
|
+
// Set data if opening a new footnote
|
|
447
|
+
_react.default.useEffect(() => {
|
|
448
|
+
if (isOpen && !prevProps.isOpen) {
|
|
449
|
+
setData({
|
|
450
|
+
content,
|
|
451
|
+
number
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
}, [isOpen, prevProps.isOpen, content, number]);
|
|
455
|
+
_react.default.useEffect(() => {
|
|
456
|
+
if (isOpen && prevProps.isOpen && number !== prevProps.number) {
|
|
457
|
+
saveCurrentHeight();
|
|
458
|
+
setIsTextVisible(false);
|
|
459
|
+
}
|
|
460
|
+
}, [number, isOpen, prevProps.isOpen, prevProps.number]);
|
|
461
|
+
|
|
462
|
+
// Reset footnote on close
|
|
463
|
+
_react.default.useEffect(resetFootnote, [isOpen]);
|
|
464
|
+
const getFootnoteBodyContent = _react.default.useCallback(() => {
|
|
465
|
+
if (!data.number || !data.content) {
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
468
|
+
if (/*#__PURE__*/_react.default.isValidElement(data.content)) {
|
|
469
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledCustomContentContainer, {
|
|
470
|
+
listItemColor: listItemColor,
|
|
471
|
+
listItemFontSize: listItemFontSize,
|
|
472
|
+
listItemLineHeight: listItemLineHeight,
|
|
473
|
+
listItemPaddingLeft: listItemPaddingLeft,
|
|
474
|
+
ref: contentRef,
|
|
475
|
+
children: data.content
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(List, {
|
|
479
|
+
start: data.number,
|
|
480
|
+
ref: contentRef,
|
|
481
|
+
listPaddingLeft: listPaddingLeft,
|
|
482
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ListItem, {
|
|
483
|
+
listItemMarkerFontSize: listItemMarkerFontSize,
|
|
484
|
+
listItemMarkerLineHeight: listItemMarkerLineHeight,
|
|
485
|
+
listItemColor: listItemColor,
|
|
486
|
+
listItemFontSize: listItemFontSize,
|
|
487
|
+
listItemLineHeight: listItemLineHeight,
|
|
488
|
+
listItemPaddingLeft: listItemPaddingLeft,
|
|
489
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
490
|
+
tokens: {
|
|
491
|
+
fontSize: listItemFontSize,
|
|
492
|
+
lineHeight: listItemLineHeight
|
|
493
|
+
},
|
|
494
|
+
children: (0, _utils.renderStructuredContent)(data.content)
|
|
495
|
+
})
|
|
496
|
+
})
|
|
497
|
+
});
|
|
498
|
+
}, [data.content, data.number, listItemColor, listItemFontSize, listItemLineHeight, listItemMarkerFontSize, listItemMarkerLineHeight, listItemPaddingLeft, listPaddingLeft]);
|
|
499
|
+
const checkIfScrollable = _react.default.useCallback(() => {
|
|
500
|
+
const footnoteElement = footnoteRef.current;
|
|
501
|
+
if (footnoteElement) {
|
|
502
|
+
const footnoteViewportHeight = footnoteElement.clientHeight ? footnoteElement.clientHeight : 0;
|
|
503
|
+
const contentHeight = contentRef.current ? contentRef.current.offsetHeight : 0;
|
|
504
|
+
setIsScrollable(contentHeight > footnoteViewportHeight * 0.5);
|
|
505
|
+
}
|
|
506
|
+
}, [contentRef, setIsScrollable]);
|
|
507
|
+
_react.default.useEffect(() => {
|
|
508
|
+
if (isOpen) {
|
|
509
|
+
setTimeout(() => {
|
|
510
|
+
checkIfScrollable();
|
|
511
|
+
}, 100);
|
|
512
|
+
}
|
|
513
|
+
}, [isOpen, checkIfScrollable]);
|
|
514
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Portal, {
|
|
515
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
516
|
+
...selectProps(rest),
|
|
517
|
+
ref: ref,
|
|
518
|
+
children: [isOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(GlobalBodyScrollLock, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledFootnote, {
|
|
519
|
+
ref: footnoteRef,
|
|
520
|
+
isOpen: isOpen,
|
|
521
|
+
isVisible: isVisible,
|
|
522
|
+
onTransitionEnd: handleStyledFootnoteTransitionEnd,
|
|
523
|
+
tabIndex: 0,
|
|
524
|
+
footnoteBackground: footnoteBackground,
|
|
525
|
+
footnoteBorderTop: `${footnoteBorderTopSizeMd}px solid ${footnoteBorderColorMd}`,
|
|
526
|
+
isScrollable: isScrollable,
|
|
527
|
+
isMobileFullScreen: isMobileFullScreen,
|
|
528
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(ContentContainer, {
|
|
529
|
+
maxWidth: maxWidth,
|
|
530
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(StyledFootnoteHeader, {
|
|
531
|
+
ref: headerRef,
|
|
532
|
+
viewport: viewport,
|
|
533
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(StyledHeader, {
|
|
534
|
+
footnoteHeaderPaddingLeft: footnoteHeaderPaddingLeft,
|
|
535
|
+
footnoteHeaderPaddingRight: footnoteHeaderPaddingRight,
|
|
536
|
+
footnoteHeaderPaddingTop: footnoteHeaderPaddingTop,
|
|
537
|
+
footnoteHeaderPaddingBottom: footnoteHeaderPaddingBottom,
|
|
538
|
+
headerMargin: headerMargin,
|
|
539
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
540
|
+
tokens: {
|
|
541
|
+
fontSize: headerFontSize,
|
|
542
|
+
lineHeight: headerLineHeight
|
|
543
|
+
},
|
|
544
|
+
variant: {
|
|
545
|
+
size: 'h4'
|
|
546
|
+
},
|
|
547
|
+
children: getCopy('heading')
|
|
548
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(CloseButton, {
|
|
549
|
+
ref: closeButtonRef,
|
|
550
|
+
closeButtonBorder: `${closeButtonBorderSize} solid ${closeButtonBorderColor}`,
|
|
551
|
+
closeButtonWidth: `${closeButtonWidth}px`,
|
|
552
|
+
closeButtonHeight: `${closeButtonHeight}px`,
|
|
553
|
+
closeButtonBackgroundColor: closeButtonBackgroundColor,
|
|
554
|
+
closeButtonMargin: `${closeButtonMarginTop}px ${closeButtonMarginRight}px ${closeButtonMarginBottom}px ${closeButtonMarginLeft}px`,
|
|
555
|
+
onClick: event => {
|
|
556
|
+
closeFootnote(event, {
|
|
557
|
+
returnFocus: true
|
|
558
|
+
});
|
|
559
|
+
},
|
|
560
|
+
"aria-label": getCopy('close'),
|
|
561
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Icon, {
|
|
562
|
+
icon: closeIcon,
|
|
563
|
+
tokens: {
|
|
564
|
+
size: `${closeButtonIconSize}px`
|
|
565
|
+
}
|
|
566
|
+
})
|
|
567
|
+
})]
|
|
568
|
+
})
|
|
569
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledFootnoteBody, {
|
|
570
|
+
ref: bodyRef,
|
|
571
|
+
bodyHeight: bodyHeight,
|
|
572
|
+
headerHeight: headerHeight,
|
|
573
|
+
isTextVisible: isTextVisible,
|
|
574
|
+
onTransitionEnd: handleTransitionEnd,
|
|
575
|
+
maxWidth: theme.contentMaxWidth,
|
|
576
|
+
footnoteBodyBackground: footnoteBodyBackground,
|
|
577
|
+
footnoteBodyPadding: `${footnoteBodyPaddingTop}px ${footnoteBodyPaddingRight}px ${footnoteBodyPaddingBottom}px ${footnoteBodyPaddingLeft}px`,
|
|
578
|
+
children: getFootnoteBodyContent()
|
|
579
|
+
})]
|
|
580
|
+
})
|
|
581
|
+
})]
|
|
582
|
+
})
|
|
583
|
+
});
|
|
584
|
+
});
|
|
585
|
+
Footnote.displayName = 'Footnote';
|
|
586
|
+
const copyShape = _propTypes.default.shape({
|
|
587
|
+
close: _propTypes.default.string.isRequired,
|
|
588
|
+
heading: _propTypes.default.string.isRequired
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
// If a language dictionary entry is provided, it must contain every key
|
|
592
|
+
const dictionaryContentShape = _propTypes.default.shape({
|
|
593
|
+
a11yLabel: _propTypes.default.string.isRequired,
|
|
594
|
+
close: _propTypes.default.string.isRequired,
|
|
595
|
+
heading: _propTypes.default.string.isRequired
|
|
596
|
+
});
|
|
597
|
+
Footnote.propTypes = {
|
|
598
|
+
...selectedSystemPropTypes,
|
|
599
|
+
tokens: (0, _componentsBase.getTokensPropType)('Footnote'),
|
|
600
|
+
/**
|
|
601
|
+
* The content.
|
|
602
|
+
*/
|
|
603
|
+
content: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]),
|
|
604
|
+
/**
|
|
605
|
+
* Use the `copy` prop to either select provided English or French copy by passing 'en' or 'fr' respectively.
|
|
606
|
+
* To provide your own, pass a JSON object with the keys `heading` and `close`.
|
|
607
|
+
*/
|
|
608
|
+
copy: _propTypes.default.oneOfType([_propTypes.default.oneOf(['en', 'fr']), copyShape]),
|
|
609
|
+
/**
|
|
610
|
+
* A boolean flag used hide or show the `Footnote`. Set to `true` to open the `Footnote`.
|
|
611
|
+
*/
|
|
612
|
+
isOpen: _propTypes.default.bool,
|
|
613
|
+
/**
|
|
614
|
+
* The number, must match the number of the `FootnoteLink` that initiated the `Footnote`.
|
|
615
|
+
*/
|
|
616
|
+
number: _propTypes.default.number,
|
|
617
|
+
/**
|
|
618
|
+
* A callback function to handle the closing of the footnote.
|
|
619
|
+
*
|
|
620
|
+
* @param {SyntheticEvent} event The React `SyntheticEvent`
|
|
621
|
+
* @param {Object} options Custom options
|
|
622
|
+
* @param {boolean} options.returnFocus Should the `Footnote` return focus on close
|
|
623
|
+
*/
|
|
624
|
+
onClose: _propTypes.default.func.isRequired,
|
|
625
|
+
/**
|
|
626
|
+
* Override the default dictionary, by passing the complete dictionary object for `en` and `fr`
|
|
627
|
+
*/
|
|
628
|
+
dictionary: _propTypes.default.shape({
|
|
629
|
+
en: dictionaryContentShape,
|
|
630
|
+
fr: dictionaryContentShape
|
|
631
|
+
}),
|
|
632
|
+
/**
|
|
633
|
+
* A boolean flag used to disable isMobileFullScreen of Footnote for mobile view
|
|
634
|
+
*/
|
|
635
|
+
isMobileFullScreen: _propTypes.default.bool
|
|
636
|
+
};
|
|
637
|
+
var _default = exports.default = Footnote;
|