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