@telus-uds/components-web 4.19.0 → 5.0.0-alpha.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 (477) hide show
  1. package/.eslintrc.cjs +12 -0
  2. package/CHANGELOG.md +24 -1
  3. package/lib/cjs/Badge/Badge.js +26 -27
  4. package/lib/cjs/BlockQuote/BlockQuote.js +24 -25
  5. package/lib/cjs/Breadcrumbs/{Item/Item.js → BreadcrumbItem.js} +36 -37
  6. package/lib/cjs/Breadcrumbs/Breadcrumbs.js +8 -10
  7. package/lib/cjs/Callout/Callout.js +24 -25
  8. package/lib/cjs/Card/Card.js +79 -89
  9. package/lib/cjs/Card/CardContent.js +53 -29
  10. package/lib/cjs/Card/CardFooter.js +28 -18
  11. package/lib/cjs/Countdown/Countdown.js +7 -8
  12. package/lib/cjs/Countdown/Segment.js +10 -11
  13. package/lib/cjs/Countdown/dictionary.js +2 -2
  14. package/lib/cjs/Countdown/types.js +2 -6
  15. package/lib/cjs/Countdown/useCountdown.js +2 -2
  16. package/lib/cjs/DatePicker/CalendarContainer.js +66 -67
  17. package/lib/cjs/DatePicker/DatePicker.js +27 -28
  18. package/lib/cjs/DatePicker/dictionary.js +3 -4
  19. package/lib/cjs/DatePicker/reactDatesCss.js +2 -3
  20. package/lib/cjs/Disclaimer/Disclaimer.js +28 -13
  21. package/lib/cjs/Footnote/Footnote.js +108 -109
  22. package/lib/cjs/Footnote/FootnoteLink.js +28 -19
  23. package/lib/cjs/Footnote/dictionary.js +2 -2
  24. package/lib/cjs/IconButton/IconButton.js +3 -4
  25. package/lib/cjs/Image/Image.js +9 -3
  26. package/lib/cjs/Image/server.js +4 -6
  27. package/lib/cjs/List/List.js +7 -3
  28. package/lib/cjs/List/ListItem.js +3 -4
  29. package/lib/cjs/NavigationBar/NavigationBar.js +8 -9
  30. package/lib/cjs/NavigationBar/NavigationItem.js +10 -11
  31. package/lib/cjs/NavigationBar/NavigationSubMenu.js +10 -11
  32. package/lib/cjs/NavigationBar/collapseItems.js +2 -2
  33. package/lib/cjs/NavigationBar/resolveItemSelection.js +2 -2
  34. package/lib/cjs/OptimizeImage/OptimizeImage.js +6 -8
  35. package/lib/cjs/OptimizeImage/utils/getFallbackUrl.js +3 -4
  36. package/lib/cjs/OptimizeImage/utils/getImageUrls.js +9 -10
  37. package/lib/cjs/OptimizeImage/utils/getOptimizedUrl.js +3 -4
  38. package/lib/cjs/OptimizeImage/utils/hasWebpSupport.js +1 -1
  39. package/lib/cjs/OptimizeImage/utils/index.js +8 -9
  40. package/lib/cjs/OptimizeImage/utils/isSvgUrl.js +1 -1
  41. package/lib/cjs/OrderedList/OrderedList.js +6 -9
  42. package/lib/cjs/OrderedList/OrderedListBase.js +4 -7
  43. package/lib/cjs/OrderedList/{Item.js → OrderedListItem.js} +46 -39
  44. package/lib/cjs/OrderedList/{ItemBase.js → OrderedListItemBase.js} +7 -7
  45. package/lib/cjs/OrderedList/constants.js +0 -1
  46. package/lib/cjs/Paragraph/Paragraph.js +10 -11
  47. package/lib/cjs/PreviewCard/PreviewCard.js +18 -27
  48. package/lib/cjs/PreviewCard/{AuthorDate.js → PreviewCardAuthorDate.js} +6 -6
  49. package/lib/cjs/PriceLockup/PriceLockup.js +61 -60
  50. package/lib/cjs/PriceLockup/dictionary.js +2 -2
  51. package/lib/cjs/PriceLockup/tokens.js +3 -3
  52. package/lib/cjs/Progress/ProgressBar.js +14 -17
  53. package/lib/cjs/QuantitySelector/QuantitySelector.js +8 -9
  54. package/lib/cjs/QuantitySelector/{SideButton.js → QuantitySelectorSideButton.js} +5 -6
  55. package/lib/cjs/QuantitySelector/dictionary.js +2 -2
  56. package/lib/cjs/ResponsiveImage/ResponsiveImage.js +3 -4
  57. package/lib/cjs/Ribbon/Ribbon.js +56 -65
  58. package/lib/cjs/SkeletonProvider/SkeletonImage.js +3 -4
  59. package/lib/cjs/SkeletonProvider/SkeletonProvider.js +10 -10
  60. package/lib/cjs/SkeletonProvider/SkeletonTypography.js +3 -4
  61. package/lib/cjs/Span/Span.js +6 -7
  62. package/lib/cjs/Spinner/Spinner.js +29 -29
  63. package/lib/cjs/Spinner/SpinnerContent.js +6 -7
  64. package/lib/cjs/StoryCard/StoryCard.js +17 -22
  65. package/lib/cjs/Table/Table.js +32 -25
  66. package/lib/cjs/Table/{Body.js → TableBody.js} +5 -6
  67. package/lib/cjs/Table/{Cell.js → TableCell.js} +59 -61
  68. package/lib/cjs/Table/{Header.js → TableHeader.js} +7 -8
  69. package/lib/cjs/Table/{Row.js → TableRow.js} +18 -19
  70. package/lib/cjs/Table/{SubHeading.js → TableSubHeading.js} +7 -8
  71. package/lib/cjs/TermsAndConditions/ExpandCollapse.js +18 -19
  72. package/lib/cjs/TermsAndConditions/TermsAndConditions.js +44 -44
  73. package/lib/cjs/TermsAndConditions/dictionary.js +2 -2
  74. package/lib/cjs/Testimonial/Testimonial.js +24 -31
  75. package/lib/cjs/Toast/Toast.js +28 -30
  76. package/lib/cjs/Video/ControlBar/ControlBar.js +48 -47
  77. package/lib/cjs/Video/ControlBar/Controls/VideoButton/VideoButton.js +6 -6
  78. package/lib/cjs/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +30 -32
  79. package/lib/cjs/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +35 -35
  80. package/lib/cjs/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +42 -42
  81. package/lib/cjs/Video/MiddleControlButton/MiddleControlButton.js +15 -15
  82. package/lib/cjs/Video/Video.js +27 -29
  83. package/lib/cjs/Video/videoText.js +3 -4
  84. package/lib/cjs/VideoPicker/VideoPicker.js +37 -33
  85. package/lib/cjs/VideoPicker/VideoPickerPlayer.js +5 -6
  86. package/lib/cjs/VideoPicker/VideoPickerThumbnail.js +28 -25
  87. package/lib/cjs/VideoPicker/VideoSlider.js +3 -4
  88. package/lib/cjs/WaffleGrid/WaffleGrid.js +51 -50
  89. package/lib/cjs/WebVideo/WebVideo.js +7 -8
  90. package/lib/cjs/baseExports.js +84 -0
  91. package/lib/cjs/index.js +179 -105
  92. package/lib/cjs/server.js +2 -3
  93. package/lib/cjs/shared/ConditionalWrapper/ConditionalWrapper.js +3 -3
  94. package/lib/cjs/shared/FullBleedContent/FullBleedContent.js +28 -22
  95. package/lib/cjs/shared/FullBleedContent/getFullBleedBorderRadius.js +2 -2
  96. package/lib/cjs/shared/FullBleedContent/index.js +11 -10
  97. package/lib/cjs/shared/FullBleedContent/useFullBleedContentProps.js +2 -2
  98. package/lib/cjs/shared/VideoSplash/SplashButton/SplashButton.js +9 -9
  99. package/lib/cjs/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +50 -50
  100. package/lib/cjs/shared/VideoSplash/VideoSplash.js +12 -12
  101. package/lib/cjs/shared/VideoSplash/helpers.js +2 -3
  102. package/lib/cjs/utils/index.js +14 -15
  103. package/lib/cjs/utils/isElementFocusable.js +2 -2
  104. package/lib/cjs/utils/logger.js +2 -6
  105. package/lib/cjs/utils/media.js +1 -1
  106. package/lib/cjs/utils/renderStructuredContent.js +3 -4
  107. package/lib/cjs/utils/scrollToAnchor.js +2 -2
  108. package/lib/cjs/utils/ssr.js +2 -2
  109. package/lib/cjs/utils/theming/get-theme-from-server.js +2 -3
  110. package/lib/cjs/utils/theming/with-client-theme.js +2 -2
  111. package/lib/cjs/utils/theming/with-server-theme.js +4 -4
  112. package/lib/cjs/utils/transforms.js +2 -5
  113. package/lib/cjs/utils/useOverlaidPosition.js +2 -2
  114. package/lib/cjs/utils/useTypographyTheme.js +2 -2
  115. package/lib/esm/Badge/Badge.js +25 -26
  116. package/lib/esm/BlockQuote/BlockQuote.js +23 -24
  117. package/lib/esm/Breadcrumbs/{Item/Item.js → BreadcrumbItem.js} +35 -36
  118. package/lib/esm/Breadcrumbs/Breadcrumbs.js +6 -7
  119. package/lib/esm/Callout/Callout.js +23 -24
  120. package/lib/esm/Card/Card.js +63 -71
  121. package/lib/esm/Card/CardContent.js +52 -28
  122. package/lib/esm/Card/CardFooter.js +27 -18
  123. package/lib/esm/Countdown/Countdown.js +4 -5
  124. package/lib/esm/Countdown/Segment.js +8 -9
  125. package/lib/esm/Countdown/dictionary.js +1 -1
  126. package/lib/esm/Countdown/types.js +1 -5
  127. package/lib/esm/Countdown/useCountdown.js +2 -3
  128. package/lib/esm/DatePicker/CalendarContainer.js +64 -65
  129. package/lib/esm/DatePicker/DatePicker.js +18 -19
  130. package/lib/esm/DatePicker/dictionary.js +2 -3
  131. package/lib/esm/DatePicker/reactDatesCss.js +1 -2
  132. package/lib/esm/Disclaimer/Disclaimer.js +27 -12
  133. package/lib/esm/Footnote/Footnote.js +104 -104
  134. package/lib/esm/Footnote/FootnoteLink.js +26 -17
  135. package/lib/esm/Footnote/dictionary.js +1 -1
  136. package/lib/esm/IconButton/IconButton.js +2 -3
  137. package/lib/esm/Image/Image.js +10 -1
  138. package/lib/esm/Image/server.js +4 -4
  139. package/lib/esm/List/List.js +2 -2
  140. package/lib/esm/List/ListItem.js +2 -3
  141. package/lib/esm/NavigationBar/NavigationBar.js +5 -6
  142. package/lib/esm/NavigationBar/NavigationItem.js +9 -10
  143. package/lib/esm/NavigationBar/NavigationSubMenu.js +7 -8
  144. package/lib/esm/NavigationBar/collapseItems.js +2 -3
  145. package/lib/esm/NavigationBar/resolveItemSelection.js +2 -3
  146. package/lib/esm/OptimizeImage/OptimizeImage.js +4 -6
  147. package/lib/esm/OptimizeImage/utils/getFallbackUrl.js +2 -2
  148. package/lib/esm/OptimizeImage/utils/getImageUrls.js +3 -3
  149. package/lib/esm/OptimizeImage/utils/getOptimizedUrl.js +2 -2
  150. package/lib/esm/OptimizeImage/utils/hasWebpSupport.js +1 -1
  151. package/lib/esm/OptimizeImage/utils/index.js +4 -4
  152. package/lib/esm/OptimizeImage/utils/isSvgUrl.js +1 -1
  153. package/lib/esm/OrderedList/OrderedList.js +4 -7
  154. package/lib/esm/OrderedList/OrderedListBase.js +3 -6
  155. package/lib/esm/OrderedList/{Item.js → OrderedListItem.js} +45 -38
  156. package/lib/esm/OrderedList/{ItemBase.js → OrderedListItemBase.js} +5 -6
  157. package/lib/esm/OrderedList/constants.js +0 -1
  158. package/lib/esm/Paragraph/Paragraph.js +9 -10
  159. package/lib/esm/PreviewCard/PreviewCard.js +16 -21
  160. package/lib/esm/PreviewCard/{AuthorDate.js → PreviewCardAuthorDate.js} +4 -5
  161. package/lib/esm/PriceLockup/PriceLockup.js +57 -56
  162. package/lib/esm/PriceLockup/dictionary.js +1 -1
  163. package/lib/esm/PriceLockup/tokens.js +1 -1
  164. package/lib/esm/Progress/ProgressBar.js +13 -16
  165. package/lib/esm/QuantitySelector/QuantitySelector.js +6 -7
  166. package/lib/esm/QuantitySelector/{SideButton.js → QuantitySelectorSideButton.js} +4 -5
  167. package/lib/esm/QuantitySelector/dictionary.js +1 -1
  168. package/lib/esm/ResponsiveImage/ResponsiveImage.js +2 -3
  169. package/lib/esm/Ribbon/Ribbon.js +55 -64
  170. package/lib/esm/SkeletonProvider/SkeletonImage.js +2 -3
  171. package/lib/esm/SkeletonProvider/SkeletonProvider.js +6 -7
  172. package/lib/esm/SkeletonProvider/SkeletonTypography.js +2 -3
  173. package/lib/esm/Span/Span.js +5 -6
  174. package/lib/esm/Spinner/Spinner.js +24 -24
  175. package/lib/esm/Spinner/SpinnerContent.js +5 -6
  176. package/lib/esm/StoryCard/StoryCard.js +15 -16
  177. package/lib/esm/Table/Table.js +31 -24
  178. package/lib/esm/Table/{Body.js → TableBody.js} +4 -5
  179. package/lib/esm/Table/{Cell.js → TableCell.js} +57 -58
  180. package/lib/esm/Table/{Header.js → TableHeader.js} +6 -7
  181. package/lib/esm/Table/{Row.js → TableRow.js} +17 -18
  182. package/lib/esm/Table/{SubHeading.js → TableSubHeading.js} +6 -7
  183. package/lib/esm/TermsAndConditions/ExpandCollapse.js +18 -19
  184. package/lib/esm/TermsAndConditions/TermsAndConditions.js +40 -40
  185. package/lib/esm/TermsAndConditions/dictionary.js +1 -1
  186. package/lib/esm/Testimonial/Testimonial.js +22 -29
  187. package/lib/esm/Toast/Toast.js +26 -27
  188. package/lib/esm/Video/ControlBar/ControlBar.js +33 -33
  189. package/lib/esm/Video/ControlBar/Controls/VideoButton/VideoButton.js +5 -6
  190. package/lib/esm/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +28 -31
  191. package/lib/esm/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +33 -34
  192. package/lib/esm/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +38 -39
  193. package/lib/esm/Video/MiddleControlButton/MiddleControlButton.js +14 -15
  194. package/lib/esm/Video/Video.js +19 -21
  195. package/lib/esm/Video/videoText.js +2 -3
  196. package/lib/esm/VideoPicker/VideoPicker.js +32 -27
  197. package/lib/esm/VideoPicker/VideoPickerPlayer.js +3 -4
  198. package/lib/esm/VideoPicker/VideoPickerThumbnail.js +26 -23
  199. package/lib/esm/VideoPicker/VideoSlider.js +2 -3
  200. package/lib/esm/WaffleGrid/WaffleGrid.js +49 -46
  201. package/lib/esm/WebVideo/WebVideo.js +5 -6
  202. package/lib/esm/baseExports.js +1 -1
  203. package/lib/esm/index.js +46 -37
  204. package/lib/esm/server.js +1 -2
  205. package/lib/esm/shared/ConditionalWrapper/ConditionalWrapper.js +2 -3
  206. package/lib/esm/shared/FullBleedContent/FullBleedContent.js +25 -20
  207. package/lib/esm/shared/FullBleedContent/getFullBleedBorderRadius.js +2 -3
  208. package/lib/esm/shared/FullBleedContent/index.js +3 -4
  209. package/lib/esm/shared/FullBleedContent/useFullBleedContentProps.js +3 -5
  210. package/lib/esm/shared/VideoSplash/SplashButton/SplashButton.js +8 -9
  211. package/lib/esm/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +48 -49
  212. package/lib/esm/shared/VideoSplash/VideoSplash.js +8 -9
  213. package/lib/esm/shared/VideoSplash/helpers.js +1 -1
  214. package/lib/esm/utils/index.js +7 -7
  215. package/lib/esm/utils/isElementFocusable.js +2 -3
  216. package/lib/esm/utils/logger.js +0 -4
  217. package/lib/esm/utils/media.js +1 -1
  218. package/lib/esm/utils/renderStructuredContent.js +2 -3
  219. package/lib/esm/utils/scrollToAnchor.js +2 -3
  220. package/lib/esm/utils/ssr.js +2 -3
  221. package/lib/esm/utils/theming/get-theme-from-server.js +1 -1
  222. package/lib/esm/utils/theming/with-client-theme.js +2 -3
  223. package/lib/esm/utils/theming/with-server-theme.js +3 -4
  224. package/lib/esm/utils/transforms.js +1 -4
  225. package/lib/esm/utils/useOverlaidPosition.js +2 -3
  226. package/lib/esm/utils/useTypographyTheme.js +2 -3
  227. package/package.json +13 -22
  228. package/src/Badge/Badge.jsx +18 -20
  229. package/src/BlockQuote/BlockQuote.jsx +16 -18
  230. package/src/Breadcrumbs/{Item/Item.jsx → BreadcrumbItem.jsx} +20 -21
  231. package/src/Breadcrumbs/Breadcrumbs.jsx +6 -9
  232. package/src/Callout/Callout.jsx +16 -18
  233. package/src/Card/Card.jsx +59 -80
  234. package/src/Card/CardContent.jsx +52 -28
  235. package/src/Card/CardFooter.jsx +26 -12
  236. package/src/Countdown/Countdown.jsx +3 -5
  237. package/src/Countdown/Segment.jsx +6 -8
  238. package/src/Countdown/dictionary.js +1 -1
  239. package/src/Countdown/types.js +0 -2
  240. package/src/Countdown/useCountdown.js +1 -3
  241. package/src/DatePicker/CalendarContainer.jsx +65 -67
  242. package/src/DatePicker/DatePicker.jsx +17 -19
  243. package/src/DatePicker/dictionary.js +1 -3
  244. package/src/DatePicker/reactDatesCss.js +1 -3
  245. package/src/Disclaimer/Disclaimer.jsx +15 -8
  246. package/src/Footnote/Footnote.jsx +104 -93
  247. package/src/Footnote/FootnoteLink.jsx +16 -13
  248. package/src/Footnote/dictionary.js +1 -1
  249. package/src/IconButton/IconButton.jsx +1 -3
  250. package/src/Image/Image.jsx +9 -1
  251. package/src/Image/server.js +4 -4
  252. package/src/List/List.jsx +2 -2
  253. package/src/List/ListItem.jsx +1 -3
  254. package/src/NavigationBar/NavigationBar.jsx +4 -6
  255. package/src/NavigationBar/NavigationItem.jsx +6 -8
  256. package/src/NavigationBar/NavigationSubMenu.jsx +7 -8
  257. package/src/NavigationBar/collapseItems.js +1 -3
  258. package/src/NavigationBar/resolveItemSelection.js +1 -3
  259. package/src/OptimizeImage/OptimizeImage.jsx +3 -6
  260. package/src/OptimizeImage/utils/getFallbackUrl.js +2 -2
  261. package/src/OptimizeImage/utils/getImageUrls.js +3 -3
  262. package/src/OptimizeImage/utils/getOptimizedUrl.js +2 -9
  263. package/src/OptimizeImage/utils/hasWebpSupport.js +1 -1
  264. package/src/OptimizeImage/utils/index.js +4 -4
  265. package/src/OptimizeImage/utils/isSvgUrl.js +1 -1
  266. package/src/OrderedList/OrderedList.jsx +3 -8
  267. package/src/OrderedList/OrderedListBase.jsx +2 -7
  268. package/src/OrderedList/{Item.jsx → OrderedListItem.jsx} +44 -32
  269. package/src/OrderedList/{ItemBase.jsx → OrderedListItemBase.jsx} +4 -4
  270. package/src/OrderedList/constants.js +0 -1
  271. package/src/Paragraph/Paragraph.jsx +7 -9
  272. package/src/PreviewCard/PreviewCard.jsx +16 -32
  273. package/src/PreviewCard/{AuthorDate.jsx → PreviewCardAuthorDate.jsx} +3 -5
  274. package/src/PriceLockup/PriceLockup.jsx +33 -31
  275. package/src/PriceLockup/dictionary.js +1 -1
  276. package/src/PriceLockup/tokens.js +1 -1
  277. package/src/Progress/ProgressBar.jsx +33 -30
  278. package/src/QuantitySelector/QuantitySelector.jsx +5 -7
  279. package/src/QuantitySelector/{SideButton.jsx → QuantitySelectorSideButton.jsx} +3 -4
  280. package/src/QuantitySelector/dictionary.js +1 -1
  281. package/src/ResponsiveImage/ResponsiveImage.jsx +1 -3
  282. package/src/Ribbon/Ribbon.jsx +35 -44
  283. package/src/SkeletonProvider/SkeletonImage.jsx +1 -3
  284. package/src/SkeletonProvider/SkeletonProvider.jsx +5 -9
  285. package/src/SkeletonProvider/SkeletonTypography.jsx +1 -3
  286. package/src/Span/Span.jsx +11 -11
  287. package/src/Spinner/Spinner.jsx +17 -19
  288. package/src/Spinner/SpinnerContent.jsx +4 -6
  289. package/src/StoryCard/StoryCard.jsx +15 -16
  290. package/src/Table/Table.jsx +81 -75
  291. package/src/Table/{Body.jsx → TableBody.jsx} +3 -5
  292. package/src/Table/{Cell.jsx → TableCell.jsx} +69 -65
  293. package/src/Table/{Header.jsx → TableHeader.jsx} +6 -8
  294. package/src/Table/{Row.jsx → TableRow.jsx} +11 -12
  295. package/src/Table/{SubHeading.jsx → TableSubHeading.jsx} +6 -8
  296. package/src/TermsAndConditions/ExpandCollapse.jsx +18 -19
  297. package/src/TermsAndConditions/TermsAndConditions.jsx +37 -37
  298. package/src/TermsAndConditions/dictionary.js +1 -1
  299. package/src/Testimonial/Testimonial.jsx +20 -28
  300. package/src/Toast/Toast.jsx +36 -35
  301. package/src/Video/ControlBar/ControlBar.jsx +28 -25
  302. package/src/Video/ControlBar/Controls/VideoButton/VideoButton.jsx +4 -6
  303. package/src/Video/ControlBar/Controls/VideoMenu/VideoMenu.jsx +26 -30
  304. package/src/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.jsx +31 -33
  305. package/src/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.jsx +40 -40
  306. package/src/Video/MiddleControlButton/MiddleControlButton.jsx +10 -12
  307. package/src/Video/Video.jsx +697 -683
  308. package/src/Video/videoText.js +1 -3
  309. package/src/VideoPicker/VideoPicker.jsx +37 -25
  310. package/src/VideoPicker/VideoPickerPlayer.jsx +2 -4
  311. package/src/VideoPicker/VideoPickerThumbnail.jsx +26 -15
  312. package/src/VideoPicker/VideoSlider.jsx +1 -3
  313. package/src/WaffleGrid/WaffleGrid.jsx +31 -27
  314. package/src/WebVideo/WebVideo.jsx +4 -6
  315. package/src/baseExports.js +27 -13
  316. package/src/index.js +46 -37
  317. package/src/server.js +1 -2
  318. package/src/shared/ConditionalWrapper/ConditionalWrapper.jsx +1 -3
  319. package/src/shared/FullBleedContent/FullBleedContent.jsx +26 -19
  320. package/src/shared/FullBleedContent/getFullBleedBorderRadius.js +1 -3
  321. package/src/shared/FullBleedContent/index.js +3 -8
  322. package/src/shared/FullBleedContent/useFullBleedContentProps.js +2 -5
  323. package/src/shared/VideoSplash/SplashButton/SplashButton.jsx +5 -7
  324. package/src/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.jsx +25 -25
  325. package/src/shared/VideoSplash/VideoSplash.jsx +7 -9
  326. package/src/shared/VideoSplash/helpers.js +1 -1
  327. package/src/utils/index.js +7 -7
  328. package/src/utils/isElementFocusable.js +1 -3
  329. package/src/utils/logger.js +0 -5
  330. package/src/utils/media.js +1 -1
  331. package/src/utils/renderStructuredContent.jsx +1 -3
  332. package/src/utils/scrollToAnchor.js +1 -3
  333. package/src/utils/ssr.js +1 -3
  334. package/src/utils/theming/get-theme-from-server.js +1 -1
  335. package/src/utils/theming/with-client-theme.jsx +1 -3
  336. package/src/utils/theming/with-server-theme.jsx +2 -4
  337. package/src/utils/transforms.js +0 -2
  338. package/src/utils/useOverlaidPosition.js +1 -3
  339. package/src/utils/useTypographyTheme.js +1 -3
  340. package/types/Autocomplete.d.ts +1 -3
  341. package/types/Badge.d.ts +1 -3
  342. package/types/BaseProvider.d.ts +1 -3
  343. package/types/BlockQuote.d.ts +1 -3
  344. package/types/Box.d.ts +1 -3
  345. package/types/BreadcrumbItem.d.ts +1 -3
  346. package/types/Breadcrumbs.d.ts +2 -4
  347. package/types/Callout.d.ts +1 -3
  348. package/types/Card.d.ts +1 -3
  349. package/types/Cell.d.ts +1 -3
  350. package/types/ControlBar.d.ts +1 -3
  351. package/types/Countdown.d.ts +1 -3
  352. package/types/DatePicker.d.ts +1 -3
  353. package/types/FileUpload.d.ts +1 -3
  354. package/types/Footnote.d.ts +1 -3
  355. package/types/FootnoteLink.d.ts +1 -3
  356. package/types/Listbox.d.ts +1 -3
  357. package/types/MiddleControlButton.d.ts +1 -3
  358. package/types/MultiSelectFilter.d.ts +1 -3
  359. package/types/PriceLockup.d.ts +1 -3
  360. package/types/QuantitySelector.d.ts +1 -3
  361. package/types/Ribbon.d.ts +1 -3
  362. package/types/Spinner.d.ts +1 -3
  363. package/types/Table.d.ts +1 -3
  364. package/types/Tooltip.d.ts +1 -3
  365. package/types/TooltipButton.d.ts +1 -3
  366. package/types/Typography.d.ts +1 -3
  367. package/types/Video.d.ts +1 -3
  368. package/types/VideoButton.d.ts +1 -3
  369. package/types/VideoMenu.d.ts +1 -3
  370. package/types/VideoProgressBar.d.ts +1 -3
  371. package/types/VolumeSlider.d.ts +1 -3
  372. package/types/WebVideo.d.ts +1 -3
  373. package/lib/cjs/Badge/index.js +0 -9
  374. package/lib/cjs/BlockQuote/index.js +0 -9
  375. package/lib/cjs/Breadcrumbs/index.js +0 -13
  376. package/lib/cjs/Callout/index.js +0 -9
  377. package/lib/cjs/Card/index.js +0 -9
  378. package/lib/cjs/Countdown/index.js +0 -9
  379. package/lib/cjs/DatePicker/index.js +0 -9
  380. package/lib/cjs/Disclaimer/index.js +0 -13
  381. package/lib/cjs/Footnote/index.js +0 -11
  382. package/lib/cjs/IconButton/index.js +0 -9
  383. package/lib/cjs/Image/index.js +0 -20
  384. package/lib/cjs/List/index.js +0 -17
  385. package/lib/cjs/NavigationBar/index.js +0 -11
  386. package/lib/cjs/OptimizeImage/index.js +0 -9
  387. package/lib/cjs/OrderedList/index.js +0 -17
  388. package/lib/cjs/Paragraph/index.js +0 -9
  389. package/lib/cjs/PreviewCard/index.js +0 -9
  390. package/lib/cjs/PriceLockup/index.js +0 -9
  391. package/lib/cjs/Progress/index.js +0 -11
  392. package/lib/cjs/QuantitySelector/index.js +0 -9
  393. package/lib/cjs/ResponsiveImage/index.js +0 -9
  394. package/lib/cjs/Ribbon/index.js +0 -9
  395. package/lib/cjs/SkeletonProvider/index.js +0 -9
  396. package/lib/cjs/Span/index.js +0 -9
  397. package/lib/cjs/Spinner/index.js +0 -9
  398. package/lib/cjs/StoryCard/index.js +0 -9
  399. package/lib/cjs/Table/index.js +0 -24
  400. package/lib/cjs/TermsAndConditions/index.js +0 -13
  401. package/lib/cjs/Testimonial/index.js +0 -9
  402. package/lib/cjs/Toast/index.js +0 -9
  403. package/lib/cjs/Video/index.js +0 -9
  404. package/lib/cjs/VideoPicker/index.js +0 -9
  405. package/lib/cjs/WaffleGrid/index.js +0 -9
  406. package/lib/cjs/WebVideo/index.js +0 -9
  407. package/lib/cjs/shared/ConditionalWrapper/index.js +0 -9
  408. package/lib/esm/Badge/index.js +0 -2
  409. package/lib/esm/BlockQuote/index.js +0 -2
  410. package/lib/esm/Breadcrumbs/index.js +0 -1
  411. package/lib/esm/Callout/index.js +0 -2
  412. package/lib/esm/Card/index.js +0 -2
  413. package/lib/esm/Countdown/index.js +0 -2
  414. package/lib/esm/DatePicker/index.js +0 -2
  415. package/lib/esm/Disclaimer/index.js +0 -1
  416. package/lib/esm/Footnote/index.js +0 -4
  417. package/lib/esm/IconButton/index.js +0 -2
  418. package/lib/esm/Image/index.js +0 -9
  419. package/lib/esm/List/index.js +0 -5
  420. package/lib/esm/NavigationBar/index.js +0 -4
  421. package/lib/esm/OptimizeImage/index.js +0 -2
  422. package/lib/esm/OrderedList/index.js +0 -5
  423. package/lib/esm/Paragraph/index.js +0 -2
  424. package/lib/esm/PreviewCard/index.js +0 -2
  425. package/lib/esm/PriceLockup/index.js +0 -2
  426. package/lib/esm/Progress/index.js +0 -4
  427. package/lib/esm/QuantitySelector/index.js +0 -2
  428. package/lib/esm/ResponsiveImage/index.js +0 -2
  429. package/lib/esm/Ribbon/index.js +0 -2
  430. package/lib/esm/SkeletonProvider/index.js +0 -2
  431. package/lib/esm/Span/index.js +0 -2
  432. package/lib/esm/Spinner/index.js +0 -2
  433. package/lib/esm/StoryCard/index.js +0 -2
  434. package/lib/esm/Table/index.js +0 -17
  435. package/lib/esm/TermsAndConditions/index.js +0 -1
  436. package/lib/esm/Testimonial/index.js +0 -2
  437. package/lib/esm/Toast/index.js +0 -2
  438. package/lib/esm/Video/index.js +0 -2
  439. package/lib/esm/VideoPicker/index.js +0 -2
  440. package/lib/esm/WaffleGrid/index.js +0 -2
  441. package/lib/esm/WebVideo/index.js +0 -2
  442. package/lib/esm/shared/ConditionalWrapper/index.js +0 -2
  443. package/src/Badge/index.js +0 -3
  444. package/src/BlockQuote/index.js +0 -3
  445. package/src/Breadcrumbs/index.js +0 -1
  446. package/src/Callout/index.js +0 -3
  447. package/src/Card/index.js +0 -3
  448. package/src/Countdown/index.js +0 -3
  449. package/src/DatePicker/index.js +0 -3
  450. package/src/Disclaimer/index.js +0 -1
  451. package/src/Footnote/index.js +0 -6
  452. package/src/IconButton/index.js +0 -3
  453. package/src/Image/index.js +0 -10
  454. package/src/List/index.js +0 -8
  455. package/src/NavigationBar/index.js +0 -6
  456. package/src/OptimizeImage/index.js +0 -3
  457. package/src/OrderedList/index.js +0 -8
  458. package/src/Paragraph/index.js +0 -3
  459. package/src/PreviewCard/index.js +0 -3
  460. package/src/PriceLockup/index.js +0 -3
  461. package/src/Progress/index.js +0 -6
  462. package/src/QuantitySelector/index.js +0 -3
  463. package/src/ResponsiveImage/index.js +0 -3
  464. package/src/Ribbon/index.js +0 -3
  465. package/src/SkeletonProvider/index.js +0 -3
  466. package/src/Span/index.js +0 -3
  467. package/src/Spinner/index.js +0 -3
  468. package/src/StoryCard/index.js +0 -3
  469. package/src/Table/index.js +0 -20
  470. package/src/TermsAndConditions/index.js +0 -1
  471. package/src/Testimonial/index.js +0 -3
  472. package/src/Toast/index.js +0 -3
  473. package/src/Video/index.js +0 -3
  474. package/src/VideoPicker/index.js +0 -3
  475. package/src/WaffleGrid/index.js +0 -3
  476. package/src/WebVideo/index.js +0 -3
  477. package/src/shared/ConditionalWrapper/index.js +0 -3
@@ -8,21 +8,21 @@ import {
8
8
  getTokensPropType,
9
9
  variantProp
10
10
  } from '@telus-uds/components-base'
11
- import Spinner from '../Spinner'
11
+ import { Spinner } from '../Spinner/Spinner'
12
12
  import { warn, htmlAttrs } from '../utils'
13
- import VideoSplash from '../shared/VideoSplash/VideoSplash'
14
- import MiddleControlButton from './MiddleControlButton/MiddleControlButton'
15
- import ControlBar from './ControlBar/ControlBar'
16
- import videoText from './videoText'
13
+ import { VideoSplash } from '../shared/VideoSplash/VideoSplash'
14
+ import { MiddleControlButton } from './MiddleControlButton/MiddleControlButton'
15
+ import { ControlBar } from './ControlBar/ControlBar'
16
+ import { videoText } from './videoText'
17
17
 
18
18
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
19
19
 
20
20
  // TODO: replace with the actual spinner component from UDS
21
- const VideoPlayerContainer = styled.div(({ videoBorder, borderColor }) => ({
21
+ const VideoPlayerContainer = styled.div(({ $videoBorder, $borderColor }) => ({
22
22
  width: '100%',
23
23
  outline: 'none',
24
24
  position: 'relative',
25
- border: videoBorder ? `20px solid ${borderColor}` : undefined
25
+ border: $videoBorder ? `20px solid ${$borderColor}` : undefined
26
26
  }))
27
27
 
28
28
  const VideoElementContainer = styled.div({
@@ -37,11 +37,11 @@ const VideoPlayer = styled.video({
37
37
  height: '100%'
38
38
  })
39
39
 
40
- const VideoOverlayContainer = styled.div(({ mouseInactive }) => ({
40
+ const VideoOverlayContainer = styled.div(({ $mouseInactive }) => ({
41
41
  width: '100%',
42
42
  height: '100%',
43
43
  position: 'absolute',
44
- cursor: mouseInactive ? 'none' : 'pointer'
44
+ cursor: $mouseInactive ? 'none' : 'pointer'
45
45
  }))
46
46
 
47
47
  const VideoSplashContainer = styled.div({
@@ -61,819 +61,835 @@ const VideoOverlayElementContainer = styled.div({
61
61
  height: '100%'
62
62
  })
63
63
 
64
- const Video = ({
65
- analyticsTracking,
66
- videoTitle,
67
- videoBorder = false,
68
- simpleMode = false,
69
- copy,
70
- posterSrc,
71
- crossOrigin,
72
- defaultVolume = 100,
73
- beginMuted = false,
74
- sources,
75
- tracks,
76
- defaultDesktopQuality = 1,
77
- defaultMobileQuality = 1,
78
- tokens,
79
- variant = {},
80
- ...rest
81
- }) => {
82
- const refVideoPlayer = React.useRef({})
83
- const refVideoPlayerContainer = React.useRef({})
84
- const refKeyboardInstructions = React.useRef({})
85
-
86
- let inactivityTimer = null
87
-
88
- const { borderColor, pauseIcon, playIcon, replayIcon } = useThemeTokens('Video', tokens, variant)
89
-
90
- const playerOptions = {
91
- mouseTimeout: simpleMode ? 750 : 1500, // defined in ms
92
- keyboardSeekIncrement: 5, // defined in s
93
- keyboardVolumeIncrement: 0.1, // from 0 to 1
94
- compactModeThreshold: 700 // in px
95
- }
96
-
97
- const [videoPlayerState, setVideoPlayerState] = React.useState({
98
- loadedSources: null,
99
- loadedTracks: null,
100
- videoLength: 0,
101
- videoCurrentTime: -1,
102
- videoBufferEnd: 0,
103
- videoUnplayed: true,
104
- videoIsBuffering: false,
105
- videoCurrentVolume: 1,
106
- videoIsPlaying: false,
107
- videoIsMuted: false,
108
- videoIsFullscreen: false,
109
- mouseInactive: false,
110
- videoEnded: false,
111
- videoQuality: defaultDesktopQuality,
112
- videoQualityChanged: false,
113
- selectedTextTrack: -1,
114
- mouseOnControlBar: false,
115
- qualityMenuOpen: false,
116
- captionsMenuOpen: false,
117
- isMobile: false,
118
- videoPlayerWidth: 0,
119
- percentageWatched: 'watched 0%'
120
- })
121
-
122
- const generateSources = (videoQuality) => {
123
- return sources.map((source) => {
124
- if (source.qualityRank === videoQuality) {
125
- return React.createElement('source', {
126
- src: source.source,
127
- type: source.mediaType,
128
- key: source.source
129
- })
130
- }
64
+ export const Video = React.forwardRef(
65
+ (
66
+ {
67
+ analyticsTracking,
68
+ videoTitle,
69
+ videoBorder = false,
70
+ simpleMode = false,
71
+ copy,
72
+ posterSrc,
73
+ crossOrigin,
74
+ defaultVolume = 100,
75
+ beginMuted = false,
76
+ sources,
77
+ tracks,
78
+ defaultDesktopQuality = 1,
79
+ defaultMobileQuality = 1,
80
+ tokens,
81
+ variant = {},
82
+ ...rest
83
+ },
84
+ ref
85
+ ) => {
86
+ const refVideoPlayer = React.useRef({})
87
+ const refVideoPlayerContainer = React.useRef({})
88
+ const refKeyboardInstructions = React.useRef({})
89
+
90
+ let inactivityTimer = null
91
+
92
+ const { borderColor, pauseIcon, playIcon, replayIcon } = useThemeTokens(
93
+ 'Video',
94
+ tokens,
95
+ variant
96
+ )
97
+
98
+ const playerOptions = {
99
+ mouseTimeout: simpleMode ? 750 : 1500, // defined in ms
100
+ keyboardSeekIncrement: 5, // defined in s
101
+ keyboardVolumeIncrement: 0.1, // from 0 to 1
102
+ compactModeThreshold: 700 // in px
103
+ }
131
104
 
132
- return undefined
105
+ const [videoPlayerState, setVideoPlayerState] = React.useState({
106
+ loadedSources: null,
107
+ loadedTracks: null,
108
+ videoLength: 0,
109
+ videoCurrentTime: -1,
110
+ videoBufferEnd: 0,
111
+ videoUnplayed: true,
112
+ videoIsBuffering: false,
113
+ videoCurrentVolume: 1,
114
+ videoIsPlaying: false,
115
+ videoIsMuted: false,
116
+ videoIsFullscreen: false,
117
+ mouseInactive: false,
118
+ videoEnded: false,
119
+ videoQuality: defaultDesktopQuality,
120
+ videoQualityChanged: false,
121
+ selectedTextTrack: -1,
122
+ mouseOnControlBar: false,
123
+ qualityMenuOpen: false,
124
+ captionsMenuOpen: false,
125
+ isMobile: false,
126
+ videoPlayerWidth: 0,
127
+ percentageWatched: 'watched 0%'
133
128
  })
134
- }
135
129
 
136
- const generateTracks = () => {
137
- return tracks.map((track) => {
138
- return React.createElement('track', {
139
- label: track.label,
140
- kind: track.kind,
141
- srcLang: track.language,
142
- src: track.source,
143
- default: track.isDefault,
144
- key: track.source
130
+ const generateSources = (videoQuality) => {
131
+ return sources.map((source) => {
132
+ if (source.qualityRank === videoQuality) {
133
+ return React.createElement('source', {
134
+ src: source.source,
135
+ type: source.mediaType,
136
+ key: source.source
137
+ })
138
+ }
139
+
140
+ return undefined
145
141
  })
146
- })
147
- }
142
+ }
148
143
 
149
- const refreshMedia = () => {
150
- const { videoUnplayed } = videoPlayerState
144
+ const generateTracks = () => {
145
+ return tracks.map((track) => {
146
+ return React.createElement('track', {
147
+ label: track.label,
148
+ kind: track.kind,
149
+ srcLang: track.language,
150
+ src: track.source,
151
+ default: track.isDefault,
152
+ key: track.source
153
+ })
154
+ })
155
+ }
156
+
157
+ const refreshMedia = () => {
158
+ const { videoUnplayed } = videoPlayerState
159
+
160
+ // Handle mobile check
161
+ const isMobile = navigator && navigator.userAgent.indexOf('Mobi') >= 0
162
+ if (videoUnplayed && isMobile) {
163
+ setVideoPlayerState((prevState) => ({
164
+ ...prevState,
165
+ isMobile,
166
+ videoQuality: isMobile ? defaultMobileQuality : defaultDesktopQuality
167
+ }))
168
+ }
151
169
 
152
- // Handle mobile check
153
- const isMobile = navigator && navigator.userAgent.indexOf('Mobi') >= 0
154
- if (videoUnplayed && isMobile) {
170
+ // Load media
155
171
  setVideoPlayerState((prevState) => ({
156
172
  ...prevState,
157
- isMobile,
158
- videoQuality: isMobile ? defaultMobileQuality : defaultDesktopQuality
173
+ loadedSources: generateSources(prevState.videoQuality),
174
+ loadedTracks: tracks && generateTracks()
159
175
  }))
160
176
  }
161
177
 
162
- // Load media
163
- setVideoPlayerState((prevState) => ({
164
- ...prevState,
165
- loadedSources: generateSources(prevState.videoQuality),
166
- loadedTracks: tracks && generateTracks()
167
- }))
168
- }
169
-
170
- const percentageBucket = (percentValue) => {
171
- if (percentValue < 25) {
172
- return setVideoPlayerState((prevState) => {
173
- if (prevState !== 'watched 0%') {
174
- return { ...prevState, percentageWatched: 'watched 0%' }
175
- }
176
- return false
177
- })
178
- }
179
- if (percentValue < 50) {
180
- return setVideoPlayerState((prevState) => {
181
- if (prevState !== 'watched 25%') {
182
- return { ...prevState, percentageWatched: 'watched 25%' }
183
- }
184
- return false
185
- })
186
- }
187
- if (percentValue < 75) {
188
- return setVideoPlayerState((prevState) => {
189
- if (prevState !== 'watched 50%') {
190
- return { ...prevState, percentageWatched: 'watched 50%' }
191
- }
192
- return false
193
- })
194
- }
195
- if (percentValue < 100) {
196
- return setVideoPlayerState((prevState) => {
197
- if (prevState !== 'watched 75%') {
198
- return { ...prevState, percentageWatched: 'watched 75%' }
199
- }
200
- return false
201
- })
202
- }
203
- if (percentValue === 100) {
204
- return setVideoPlayerState((prevState) => {
205
- if (prevState !== 'watched 100%') {
206
- return { ...prevState, percentageWatched: 'watched 100%' }
207
- }
208
- return false
209
- })
178
+ const percentageBucket = (percentValue) => {
179
+ if (percentValue < 25) {
180
+ return setVideoPlayerState((prevState) => {
181
+ if (prevState !== 'watched 0%') {
182
+ return { ...prevState, percentageWatched: 'watched 0%' }
183
+ }
184
+ return false
185
+ })
186
+ }
187
+ if (percentValue < 50) {
188
+ return setVideoPlayerState((prevState) => {
189
+ if (prevState !== 'watched 25%') {
190
+ return { ...prevState, percentageWatched: 'watched 25%' }
191
+ }
192
+ return false
193
+ })
194
+ }
195
+ if (percentValue < 75) {
196
+ return setVideoPlayerState((prevState) => {
197
+ if (prevState !== 'watched 50%') {
198
+ return { ...prevState, percentageWatched: 'watched 50%' }
199
+ }
200
+ return false
201
+ })
202
+ }
203
+ if (percentValue < 100) {
204
+ return setVideoPlayerState((prevState) => {
205
+ if (prevState !== 'watched 75%') {
206
+ return { ...prevState, percentageWatched: 'watched 75%' }
207
+ }
208
+ return false
209
+ })
210
+ }
211
+ if (percentValue === 100) {
212
+ return setVideoPlayerState((prevState) => {
213
+ if (prevState !== 'watched 100%') {
214
+ return { ...prevState, percentageWatched: 'watched 100%' }
215
+ }
216
+ return false
217
+ })
218
+ }
219
+ return false
210
220
  }
211
- return false
212
- }
213
221
 
214
- // required for analytics
215
- const calculatePercentageWatched = () => {
216
- const { videoCurrentTime, videoLength, percentageWatched } = videoPlayerState
222
+ // required for analytics
223
+ const calculatePercentageWatched = () => {
224
+ const { videoCurrentTime, videoLength, percentageWatched } = videoPlayerState
217
225
 
218
- let percentValue = (videoCurrentTime / videoLength) * 100
219
- percentValue = Math.round(percentValue)
226
+ let percentValue = (videoCurrentTime / videoLength) * 100
227
+ percentValue = Math.round(percentValue)
220
228
 
221
- const previousValue = percentageWatched
222
- percentageBucket(percentValue)
229
+ const previousValue = percentageWatched
230
+ percentageBucket(percentValue)
223
231
 
224
- if (previousValue !== percentageWatched) {
225
- const analyticsObject = { name: 'video tracking', details: videoTitle }
226
- analyticsObject.action = percentageWatched
227
- analyticsTracking(analyticsObject)
232
+ if (previousValue !== percentageWatched) {
233
+ const analyticsObject = { name: 'video tracking', details: videoTitle }
234
+ analyticsObject.action = percentageWatched
235
+ analyticsTracking(analyticsObject)
236
+ }
228
237
  }
229
- }
230
238
 
231
- const setPlaying = async (isPlaying) => {
232
- const videoPlayer = refVideoPlayer.current
239
+ const setPlaying = async (isPlaying) => {
240
+ const videoPlayer = refVideoPlayer.current
233
241
 
234
- if (isPlaying) {
235
- await videoPlayer.play()
242
+ if (isPlaying) {
243
+ await videoPlayer.play()
236
244
 
237
- if (analyticsTracking !== undefined && videoTitle) {
238
- const intervalId = setInterval(calculatePercentageWatched, 300)
239
- setVideoPlayerState((prevState) => ({ ...prevState, intervalId }))
240
- }
241
- } else {
242
- const { intervalId } = videoPlayerState
245
+ if (analyticsTracking !== undefined && videoTitle) {
246
+ const intervalId = setInterval(calculatePercentageWatched, 300)
247
+ setVideoPlayerState((prevState) => ({ ...prevState, intervalId }))
248
+ }
249
+ } else {
250
+ const { intervalId } = videoPlayerState
243
251
 
244
- videoPlayer.pause()
245
- clearInterval(intervalId)
252
+ videoPlayer.pause()
253
+ clearInterval(intervalId)
254
+ }
246
255
  }
247
- }
248
256
 
249
- const updateAnalyticsData = () => {
250
- const { videoIsPlaying, percentageWatched } = videoPlayerState
257
+ const updateAnalyticsData = () => {
258
+ const { videoIsPlaying, percentageWatched } = videoPlayerState
251
259
 
252
- const analyticsObject = { name: 'video tracking', details: videoTitle }
253
- analyticsObject.action = videoIsPlaying ? 'play' : 'pause'
254
- if (percentageWatched !== 'watched 100%') {
255
- analyticsTracking(analyticsObject)
260
+ const analyticsObject = { name: 'video tracking', details: videoTitle }
261
+ analyticsObject.action = videoIsPlaying ? 'play' : 'pause'
262
+ if (percentageWatched !== 'watched 100%') {
263
+ analyticsTracking(analyticsObject)
264
+ }
256
265
  }
257
- }
258
-
259
- const setSeek = (seconds) => {
260
- refVideoPlayer.current.currentTime = seconds
261
- }
262
266
 
263
- const qualitySwitchSeek = () => {
264
- const { videoCurrentTime } = videoPlayerState
265
-
266
- // The following setState gets the video length on the splash screen in iOS
267
- setVideoPlayerState((prevState) => ({
268
- ...prevState,
269
- videoLength: refVideoPlayer.current.duration
270
- }))
271
-
272
- if (videoCurrentTime > -1) {
273
- setSeek(videoCurrentTime)
267
+ const setSeek = (seconds) => {
268
+ refVideoPlayer.current.currentTime = seconds
274
269
  }
275
- }
276
270
 
277
- const updateVideoTimestamp = () => {
278
- setVideoPlayerState((prevState) => ({
279
- ...prevState,
280
- videoCurrentTime: refVideoPlayer.current.currentTime
281
- }))
282
- }
271
+ const qualitySwitchSeek = () => {
272
+ const { videoCurrentTime } = videoPlayerState
283
273
 
284
- const initializeVideoDuration = () => {
285
- // This will run on every load() call, meaning it will also run when video quality is changed.
286
- setVideoPlayerState((prevState) => {
287
- return {
274
+ // The following setState gets the video length on the splash screen in iOS
275
+ setVideoPlayerState((prevState) => ({
288
276
  ...prevState,
289
- videoLength: refVideoPlayer.current.duration,
290
- videoBufferEnd:
291
- refVideoPlayer.current.buffered.length === 0
292
- ? 0
293
- : refVideoPlayer.current.buffered.end(refVideoPlayer.current.buffered.length - 1),
294
- videoUnplayed: refVideoPlayer.current.played.length === 0 && !prevState.videoQualityChanged
295
- }
296
- })
297
-
298
- const { videoQualityChanged, videoIsPlaying } = videoPlayerState
277
+ videoLength: refVideoPlayer.current.duration
278
+ }))
299
279
 
300
- // Prevents an IE 11 bug where the video will not continue playing after a quality switch
301
- if (videoQualityChanged && videoIsPlaying) {
302
- setPlaying(true)
280
+ if (videoCurrentTime > -1) {
281
+ setSeek(videoCurrentTime)
282
+ }
303
283
  }
304
- }
305
284
 
306
- const clearInactivityTimer = () => {
307
- setVideoPlayerState((prevState) => ({ ...prevState, mouseInactive: false }))
308
- clearTimeout(inactivityTimer)
309
- }
310
-
311
- const setAsBuffering = () => {
312
- // Prevent IE infinite buffer bug with readyState
313
- if (refVideoPlayer.current.readyState < 4) {
314
- clearInactivityTimer()
285
+ const updateVideoTimestamp = () => {
315
286
  setVideoPlayerState((prevState) => ({
316
287
  ...prevState,
317
- videoIsPlaying: false,
318
- videoIsBuffering: true,
319
- mouseInactive: true
288
+ videoCurrentTime: refVideoPlayer.current.currentTime
320
289
  }))
321
- setPlaying(false)
322
290
  }
323
- }
324
291
 
325
- const playAfterBuffer = () => {
326
- const { videoIsBuffering, videoCurrentTime, videoQualityChanged } = videoPlayerState
292
+ const initializeVideoDuration = () => {
293
+ // This will run on every load() call, meaning it will also run when video quality is changed.
294
+ setVideoPlayerState((prevState) => {
295
+ return {
296
+ ...prevState,
297
+ videoLength: refVideoPlayer.current.duration,
298
+ videoBufferEnd:
299
+ refVideoPlayer.current.buffered.length === 0
300
+ ? 0
301
+ : refVideoPlayer.current.buffered.end(refVideoPlayer.current.buffered.length - 1),
302
+ videoUnplayed:
303
+ refVideoPlayer.current.played.length === 0 && !prevState.videoQualityChanged
304
+ }
305
+ })
327
306
 
328
- if (videoIsBuffering && videoCurrentTime !== -1 && !videoQualityChanged) {
329
- setPlaying(true)
330
- setVideoPlayerState((prevState) => ({ ...prevState, videoIsBuffering: false }))
331
- }
332
- }
307
+ const { videoQualityChanged, videoIsPlaying } = videoPlayerState
333
308
 
334
- const resetInactivityTimer = () => {
335
- clearInactivityTimer()
309
+ // Prevents an IE 11 bug where the video will not continue playing after a quality switch
310
+ if (videoQualityChanged && videoIsPlaying) {
311
+ setPlaying(true)
312
+ }
313
+ }
336
314
 
337
- const { videoQualityChanged, videoIsPlaying, mouseOnControlBar } = videoPlayerState
315
+ const clearInactivityTimer = () => {
316
+ setVideoPlayerState((prevState) => ({ ...prevState, mouseInactive: false }))
317
+ clearTimeout(inactivityTimer)
318
+ }
338
319
 
339
- if (!videoQualityChanged && videoIsPlaying) {
340
- inactivityTimer = setTimeout(() => {
341
- if (!mouseOnControlBar) {
342
- setVideoPlayerState((prevState) => ({ ...prevState, mouseInactive: true }))
343
- }
344
- }, playerOptions.mouseTimeout)
320
+ const setAsBuffering = () => {
321
+ // Prevent IE infinite buffer bug with readyState
322
+ if (refVideoPlayer.current.readyState < 4) {
323
+ clearInactivityTimer()
324
+ setVideoPlayerState((prevState) => ({
325
+ ...prevState,
326
+ videoIsPlaying: false,
327
+ videoIsBuffering: true,
328
+ mouseInactive: true
329
+ }))
330
+ setPlaying(false)
331
+ }
345
332
  }
346
- }
347
333
 
348
- const setAsPlaying = () => {
349
- setVideoPlayerState((prevState) => ({
350
- ...prevState,
351
- videoIsPlaying: true,
352
- videoIsBuffering: false,
353
- videoEnded: false,
354
- videoUnplayed: false,
355
- videoQualityChanged: false
356
- }))
334
+ const playAfterBuffer = () => {
335
+ const { videoIsBuffering, videoCurrentTime, videoQualityChanged } = videoPlayerState
357
336
 
358
- if (analyticsTracking) {
359
- updateAnalyticsData()
337
+ if (videoIsBuffering && videoCurrentTime !== -1 && !videoQualityChanged) {
338
+ setPlaying(true)
339
+ setVideoPlayerState((prevState) => ({ ...prevState, videoIsBuffering: false }))
340
+ }
360
341
  }
361
342
 
362
- resetInactivityTimer()
363
- }
343
+ const resetInactivityTimer = () => {
344
+ clearInactivityTimer()
364
345
 
365
- const setAsPaused = () => {
366
- clearInactivityTimer()
367
- setVideoPlayerState((prevState) => ({ ...prevState, videoIsPlaying: false }))
346
+ const { videoQualityChanged, videoIsPlaying, mouseOnControlBar } = videoPlayerState
368
347
 
369
- if (analyticsTracking) {
370
- updateAnalyticsData()
348
+ if (!videoQualityChanged && videoIsPlaying) {
349
+ inactivityTimer = setTimeout(() => {
350
+ if (!mouseOnControlBar) {
351
+ setVideoPlayerState((prevState) => ({ ...prevState, mouseInactive: true }))
352
+ }
353
+ }, playerOptions.mouseTimeout)
354
+ }
371
355
  }
372
- }
373
-
374
- const returnFromEndState = () => {
375
- resetInactivityTimer()
376
- setVideoPlayerState((prevState) => ({ ...prevState, videoEnded: false }))
377
- }
378
356
 
379
- const setAsEnded = () => {
380
- setVideoPlayerState((prevState) => ({ ...prevState, videoIsPlaying: false, videoEnded: true }))
381
- clearInactivityTimer()
382
- }
383
-
384
- const updateBufferProgress = () => {
385
- const { videoCurrentTime, videoQualityChanged } = videoPlayerState
386
- const videoPlayer = refVideoPlayer.current
387
- if (videoPlayer && videoPlayer.readyState >= 2) {
388
- const { buffered } = videoPlayer
357
+ const setAsPlaying = () => {
389
358
  setVideoPlayerState((prevState) => ({
390
359
  ...prevState,
391
- videoBufferEnd: buffered.length === 0 ? 0 : buffered.end(buffered.length - 1)
360
+ videoIsPlaying: true,
361
+ videoIsBuffering: false,
362
+ videoEnded: false,
363
+ videoUnplayed: false,
364
+ videoQualityChanged: false
392
365
  }))
393
- } else if (videoCurrentTime !== -1 && !videoQualityChanged && !videoPlayer) {
366
+
367
+ if (analyticsTracking) {
368
+ updateAnalyticsData()
369
+ }
370
+
371
+ resetInactivityTimer()
372
+ }
373
+
374
+ const setAsPaused = () => {
375
+ clearInactivityTimer()
376
+ setVideoPlayerState((prevState) => ({ ...prevState, videoIsPlaying: false }))
377
+
378
+ if (analyticsTracking) {
379
+ updateAnalyticsData()
380
+ }
381
+ }
382
+
383
+ const returnFromEndState = () => {
384
+ resetInactivityTimer()
385
+ setVideoPlayerState((prevState) => ({ ...prevState, videoEnded: false }))
386
+ }
387
+
388
+ const setAsEnded = () => {
394
389
  setVideoPlayerState((prevState) => ({
395
390
  ...prevState,
396
391
  videoIsPlaying: false,
397
- videoIsBuffering: true
392
+ videoEnded: true
398
393
  }))
394
+ clearInactivityTimer()
399
395
  }
400
- }
401
396
 
402
- const updateVolumeState = () => {
403
- resetInactivityTimer()
397
+ const updateBufferProgress = () => {
398
+ const { videoCurrentTime, videoQualityChanged } = videoPlayerState
399
+ const videoPlayer = refVideoPlayer.current
400
+ if (videoPlayer && videoPlayer.readyState >= 2) {
401
+ const { buffered } = videoPlayer
402
+ setVideoPlayerState((prevState) => ({
403
+ ...prevState,
404
+ videoBufferEnd: buffered.length === 0 ? 0 : buffered.end(buffered.length - 1)
405
+ }))
406
+ } else if (videoCurrentTime !== -1 && !videoQualityChanged && !videoPlayer) {
407
+ setVideoPlayerState((prevState) => ({
408
+ ...prevState,
409
+ videoIsPlaying: false,
410
+ videoIsBuffering: true
411
+ }))
412
+ }
413
+ }
404
414
 
405
- const videoPlayer = refVideoPlayer.current
415
+ const updateVolumeState = () => {
416
+ resetInactivityTimer()
406
417
 
407
- setVideoPlayerState((prevState) => ({
408
- ...prevState,
409
- videoCurrentVolume: videoPlayer.volume,
410
- videoIsMuted: videoPlayer.muted
411
- }))
412
- }
418
+ const videoPlayer = refVideoPlayer.current
413
419
 
414
- const getPlayerWidth = () => {
415
- setVideoPlayerState((prevState) => ({
416
- ...prevState,
417
- videoPlayerWidth: refVideoPlayerContainer.current.offsetWidth
418
- }))
419
- }
420
+ setVideoPlayerState((prevState) => ({
421
+ ...prevState,
422
+ videoCurrentVolume: videoPlayer.volume,
423
+ videoIsMuted: videoPlayer.muted
424
+ }))
425
+ }
420
426
 
421
- const setMouseOnControlBar = (isOver) => {
422
- setVideoPlayerState((prevState) => ({ ...prevState, mouseOnControlBar: isOver }))
423
- }
427
+ const getPlayerWidth = () => {
428
+ setVideoPlayerState((prevState) => ({
429
+ ...prevState,
430
+ videoPlayerWidth: refVideoPlayerContainer.current.offsetWidth
431
+ }))
432
+ }
433
+
434
+ const setMouseOnControlBar = (isOver) => {
435
+ setVideoPlayerState((prevState) => ({ ...prevState, mouseOnControlBar: isOver }))
436
+ }
424
437
 
425
- const togglePlayPause = () => {
426
- const { videoIsPlaying } = videoPlayerState
438
+ const togglePlayPause = () => {
439
+ const { videoIsPlaying } = videoPlayerState
427
440
 
428
- setPlaying(!videoIsPlaying)
429
- }
441
+ setPlaying(!videoIsPlaying)
442
+ }
430
443
 
431
- const setTextTracks = (trackNumber) => {
432
- const { textTracks } = refVideoPlayer.current
444
+ const setTextTracks = (trackNumber) => {
445
+ const { textTracks } = refVideoPlayer.current
433
446
 
434
- for (let i = 0; i < textTracks.length; i += 1) {
435
- textTracks[i].mode = i === trackNumber ? 'showing' : 'hidden'
447
+ for (let i = 0; i < textTracks.length; i += 1) {
448
+ textTracks[i].mode = i === trackNumber ? 'showing' : 'hidden'
449
+ }
450
+ setVideoPlayerState((prevState) => ({ ...prevState, selectedTextTrack: trackNumber }))
436
451
  }
437
- setVideoPlayerState((prevState) => ({ ...prevState, selectedTextTrack: trackNumber }))
438
- }
439
452
 
440
- const beginVideo = () => {
441
- setTextTracks(-1)
442
- setPlaying(true)
443
- refVideoPlayerContainer.current.focus()
444
- }
453
+ const beginVideo = () => {
454
+ setTextTracks(-1)
455
+ setPlaying(true)
456
+ refVideoPlayerContainer.current.focus()
457
+ }
445
458
 
446
- const closeSubMenus = () => {
447
- setVideoPlayerState((prevState) => ({
448
- ...prevState,
449
- qualityMenuOpen: false,
450
- captionsMenuOpen: false
451
- }))
452
- }
459
+ const closeSubMenus = () => {
460
+ setVideoPlayerState((prevState) => ({
461
+ ...prevState,
462
+ qualityMenuOpen: false,
463
+ captionsMenuOpen: false
464
+ }))
465
+ }
453
466
 
454
- const incrementSeek = (seconds) => {
455
- refVideoPlayer.current.currentTime += seconds
456
- }
467
+ const incrementSeek = (seconds) => {
468
+ refVideoPlayer.current.currentTime += seconds
469
+ }
457
470
 
458
- const replayVideo = async () => {
459
- setSeek(0)
460
- togglePlayPause()
461
- }
471
+ const replayVideo = async () => {
472
+ setSeek(0)
473
+ togglePlayPause()
474
+ }
462
475
 
463
- const incrementVolume = (amount) => {
464
- refVideoPlayer.current.volume += amount
465
- }
476
+ const incrementVolume = (amount) => {
477
+ refVideoPlayer.current.volume += amount
478
+ }
466
479
 
467
- const setVolume = (amount) => {
468
- refVideoPlayer.current.volume = amount
469
- }
480
+ const setVolume = (amount) => {
481
+ refVideoPlayer.current.volume = amount
482
+ }
470
483
 
471
- const toggleMute = () => {
472
- refVideoPlayer.current.muted = !refVideoPlayer.current.muted
473
- }
484
+ const toggleMute = () => {
485
+ refVideoPlayer.current.muted = !refVideoPlayer.current.muted
486
+ }
474
487
 
475
- const setCaptionsMenuOpen = (isOpen) => {
476
- setVideoPlayerState((prevState) => ({ ...prevState, captionsMenuOpen: isOpen }))
477
- }
488
+ const setCaptionsMenuOpen = (isOpen) => {
489
+ setVideoPlayerState((prevState) => ({ ...prevState, captionsMenuOpen: isOpen }))
490
+ }
478
491
 
479
- const toggleFullscreen = () => {
480
- if (fscreen.fullscreenEnabled) {
481
- if (fscreen.fullscreenElement === null) {
482
- fscreen.requestFullscreen(refVideoPlayerContainer.current)
483
- } else {
484
- fscreen.exitFullscreen()
492
+ const toggleFullscreen = () => {
493
+ if (fscreen.fullscreenEnabled) {
494
+ if (fscreen.fullscreenElement === null) {
495
+ fscreen.requestFullscreen(refVideoPlayerContainer.current)
496
+ } else {
497
+ fscreen.exitFullscreen()
498
+ }
499
+ setVideoPlayerState((prevState) => {
500
+ return { ...prevState, videoIsFullscreen: !prevState.videoIsFullscreen }
501
+ })
485
502
  }
486
- setVideoPlayerState((prevState) => {
487
- return { ...prevState, videoIsFullscreen: !prevState.videoIsFullscreen }
488
- })
489
503
  }
490
- }
491
504
 
492
- const setVideoQuality = async (newVideoQuality) => {
493
- await setPlaying(false)
494
- setVideoPlayerState((prevState) => ({
495
- ...prevState,
496
- videoLength: 0,
497
- videoBufferEnd: 0,
498
- videoQuality: newVideoQuality,
499
- loadedSources: generateSources(newVideoQuality),
500
- loadedTracks: tracks && generateTracks(),
501
- videoQualityChanged: true
502
- }))
503
- await refVideoPlayer.current.load()
504
- resetInactivityTimer()
505
- setSeek(videoPlayerState.videoCurrentTime)
506
- }
507
-
508
- const setQualityMenuOpen = (isOpen) => {
509
- setVideoPlayerState((prevState) => ({ ...prevState, qualityMenuOpen: isOpen }))
510
- }
505
+ const setVideoQuality = async (newVideoQuality) => {
506
+ await setPlaying(false)
507
+ setVideoPlayerState((prevState) => ({
508
+ ...prevState,
509
+ videoLength: 0,
510
+ videoBufferEnd: 0,
511
+ videoQuality: newVideoQuality,
512
+ loadedSources: generateSources(newVideoQuality),
513
+ loadedTracks: tracks && generateTracks(),
514
+ videoQualityChanged: true
515
+ }))
516
+ await refVideoPlayer.current.load()
517
+ resetInactivityTimer()
518
+ setSeek(videoPlayerState.videoCurrentTime)
519
+ }
511
520
 
512
- const handleClick = (event) => {
513
- resetInactivityTimer()
521
+ const setQualityMenuOpen = (isOpen) => {
522
+ setVideoPlayerState((prevState) => ({ ...prevState, qualityMenuOpen: isOpen }))
523
+ }
514
524
 
515
- // This allows playing videos within components that act like
516
- // links, e.g. `PreviewCard`, `StoryCard`, etc.
517
- event?.preventDefault()
518
- event?.stopPropagation()
519
- }
525
+ const handleClick = (event) => {
526
+ resetInactivityTimer()
520
527
 
521
- const handleKeyboard = (event) => {
522
- const { videoLength, videoCurrentVolume } = videoPlayerState
528
+ // This allows playing videos within components that act like
529
+ // links, e.g. `PreviewCard`, `StoryCard`, etc.
530
+ event?.preventDefault()
531
+ event?.stopPropagation()
532
+ }
523
533
 
524
- const key = event.key || event.keyCode
534
+ const handleKeyboard = (event) => {
535
+ const { videoLength, videoCurrentVolume } = videoPlayerState
525
536
 
526
- // *** Begin Seek & Play Control ****
527
- if (key === ' ' || key === 32 || key === 'k' || key === 75) {
528
- event.preventDefault()
529
- resetInactivityTimer()
530
- togglePlayPause()
531
- }
537
+ const key = event.key || event.keyCode
532
538
 
533
- // Disables all keys except for play/pause when in simpleMode
534
- if (!simpleMode) {
535
- if (key === 'ArrowRight' || key === 39 || key === '.' || key === 190) {
539
+ // *** Begin Seek & Play Control ****
540
+ if (key === ' ' || key === 32 || key === 'k' || key === 75) {
541
+ event.preventDefault()
536
542
  resetInactivityTimer()
537
-
538
- incrementSeek(playerOptions.keyboardSeekIncrement)
543
+ togglePlayPause()
539
544
  }
540
545
 
541
- if (key === 'ArrowLeft' || key === 37 || key === ',' || key === 188) {
542
- resetInactivityTimer()
546
+ // Disables all keys except for play/pause when in simpleMode
547
+ if (!simpleMode) {
548
+ if (key === 'ArrowRight' || key === 39 || key === '.' || key === 190) {
549
+ resetInactivityTimer()
543
550
 
544
- incrementSeek(-playerOptions.keyboardSeekIncrement)
545
- }
551
+ incrementSeek(playerOptions.keyboardSeekIncrement)
552
+ }
546
553
 
547
- if (key === '0' || key === 48 || key === 'numpad 0' || key === 96) {
548
- setSeek(0)
549
- }
554
+ if (key === 'ArrowLeft' || key === 37 || key === ',' || key === 188) {
555
+ resetInactivityTimer()
550
556
 
551
- if (key === '1' || key === 49 || key === 'numpad 1' || key === 97) {
552
- setSeek(videoLength * 0.1)
553
- }
557
+ incrementSeek(-playerOptions.keyboardSeekIncrement)
558
+ }
554
559
 
555
- if (key === '2' || key === 50 || key === 'numpad 2' || key === 98) {
556
- setSeek(videoLength * 0.2)
557
- }
560
+ if (key === '0' || key === 48 || key === 'numpad 0' || key === 96) {
561
+ setSeek(0)
562
+ }
558
563
 
559
- if (key === '3' || key === 51 || key === 'numpad 3' || key === 99) {
560
- setSeek(videoLength * 0.3)
561
- }
564
+ if (key === '1' || key === 49 || key === 'numpad 1' || key === 97) {
565
+ setSeek(videoLength * 0.1)
566
+ }
562
567
 
563
- if (key === '4' || key === 52 || key === 'numpad 4' || key === 100) {
564
- setSeek(videoLength * 0.4)
565
- }
568
+ if (key === '2' || key === 50 || key === 'numpad 2' || key === 98) {
569
+ setSeek(videoLength * 0.2)
570
+ }
566
571
 
567
- if (key === '5' || key === 53 || key === 'numpad 5' || key === 101) {
568
- setSeek(videoLength * 0.5)
569
- }
572
+ if (key === '3' || key === 51 || key === 'numpad 3' || key === 99) {
573
+ setSeek(videoLength * 0.3)
574
+ }
570
575
 
571
- if (key === '6' || key === 54 || key === 'numpad 6' || key === 102) {
572
- setSeek(videoLength * 0.6)
573
- }
576
+ if (key === '4' || key === 52 || key === 'numpad 4' || key === 100) {
577
+ setSeek(videoLength * 0.4)
578
+ }
574
579
 
575
- if (key === '7' || key === 55 || key === 'numpad 7' || key === 103) {
576
- setSeek(videoLength * 0.7)
577
- }
580
+ if (key === '5' || key === 53 || key === 'numpad 5' || key === 101) {
581
+ setSeek(videoLength * 0.5)
582
+ }
578
583
 
579
- if (key === '8' || key === 56 || key === 'numpad 8' || key === 104) {
580
- setSeek(videoLength * 0.8)
581
- }
584
+ if (key === '6' || key === 54 || key === 'numpad 6' || key === 102) {
585
+ setSeek(videoLength * 0.6)
586
+ }
582
587
 
583
- if (key === '9' || key === 57 || key === 'numpad 9' || key === 105) {
584
- setSeek(videoLength * 0.9)
585
- }
588
+ if (key === '7' || key === 55 || key === 'numpad 7' || key === 103) {
589
+ setSeek(videoLength * 0.7)
590
+ }
586
591
 
587
- // **** End Seek & Play Control ****
592
+ if (key === '8' || key === 56 || key === 'numpad 8' || key === 104) {
593
+ setSeek(videoLength * 0.8)
594
+ }
588
595
 
589
- // **** Begin Volume Control ****
596
+ if (key === '9' || key === 57 || key === 'numpad 9' || key === 105) {
597
+ setSeek(videoLength * 0.9)
598
+ }
590
599
 
591
- const { keyboardVolumeIncrement } = playerOptions
600
+ // **** End Seek & Play Control ****
592
601
 
593
- if (
594
- key === 'ArrowUp' ||
595
- key === 38 ||
596
- key === '=' ||
597
- key === 187 ||
598
- key === 'add' ||
599
- key === 107
600
- ) {
601
- resetInactivityTimer()
602
+ // **** Begin Volume Control ****
602
603
 
603
- if (videoCurrentVolume + keyboardVolumeIncrement < 1) {
604
- incrementVolume(keyboardVolumeIncrement)
605
- } else {
606
- setVolume(1)
607
- }
608
- }
604
+ const { keyboardVolumeIncrement } = playerOptions
609
605
 
610
- if (
611
- key === 'ArrowDown' ||
612
- key === 40 ||
613
- key === '-' ||
614
- key === 189 ||
615
- key === 'subtract' ||
616
- key === 109
617
- ) {
618
- resetInactivityTimer()
606
+ if (
607
+ key === 'ArrowUp' ||
608
+ key === 38 ||
609
+ key === '=' ||
610
+ key === 187 ||
611
+ key === 'add' ||
612
+ key === 107
613
+ ) {
614
+ resetInactivityTimer()
619
615
 
620
- if (videoCurrentVolume - keyboardVolumeIncrement > 0) {
621
- incrementVolume(-keyboardVolumeIncrement)
622
- } else {
623
- setVolume(0)
616
+ if (videoCurrentVolume + keyboardVolumeIncrement < 1) {
617
+ incrementVolume(keyboardVolumeIncrement)
618
+ } else {
619
+ setVolume(1)
620
+ }
624
621
  }
625
- }
626
622
 
627
- if (key === 'm' || key === 77) {
628
- resetInactivityTimer()
623
+ if (
624
+ key === 'ArrowDown' ||
625
+ key === 40 ||
626
+ key === '-' ||
627
+ key === 189 ||
628
+ key === 'subtract' ||
629
+ key === 109
630
+ ) {
631
+ resetInactivityTimer()
632
+
633
+ if (videoCurrentVolume - keyboardVolumeIncrement > 0) {
634
+ incrementVolume(-keyboardVolumeIncrement)
635
+ } else {
636
+ setVolume(0)
637
+ }
638
+ }
629
639
 
630
- toggleMute()
631
- }
640
+ if (key === 'm' || key === 77) {
641
+ resetInactivityTimer()
632
642
 
633
- if (key === 'f' || key === 70) {
634
- resetInactivityTimer()
643
+ toggleMute()
644
+ }
635
645
 
636
- toggleFullscreen()
637
- }
646
+ if (key === 'f' || key === 70) {
647
+ resetInactivityTimer()
638
648
 
639
- if (key === 'Escape' || key === 27) {
640
- // Resets focus back to container if user is focused on ControlBar button
641
- refVideoPlayerContainer.current.focus()
642
- closeSubMenus()
643
- }
649
+ toggleFullscreen()
650
+ }
651
+
652
+ if (key === 'Escape' || key === 27) {
653
+ // Resets focus back to container if user is focused on ControlBar button
654
+ refVideoPlayerContainer.current.focus()
655
+ closeSubMenus()
656
+ }
644
657
 
645
- if (key === 'q' || key === 81) {
646
- refKeyboardInstructions.current.focus()
658
+ if (key === 'q' || key === 81) {
659
+ refKeyboardInstructions.current.focus()
660
+ }
647
661
  }
648
662
  }
649
- }
650
663
 
651
- // Prepares video and caption files
652
- React.useEffect(() => {
653
- refreshMedia()
654
- // eslint-disable-next-line react-hooks/exhaustive-deps
655
- }, [])
664
+ // Prepares video and caption files
665
+ React.useEffect(() => {
666
+ refreshMedia()
667
+ // eslint-disable-next-line react-hooks/exhaustive-deps
668
+ }, [])
656
669
 
657
- // Initial Setup after loading sources
658
- React.useEffect(() => {
659
- const { loadedSources, loadedTracks } = videoPlayerState
670
+ // Initial Setup after loading sources
671
+ React.useEffect(() => {
672
+ const { loadedSources, loadedTracks } = videoPlayerState
660
673
 
661
- if (loadedSources && loadedTracks) {
662
- const videoPlayer = refVideoPlayer.current
674
+ if (loadedSources && loadedTracks) {
675
+ const videoPlayer = refVideoPlayer.current
663
676
 
664
- // Initializes Settings
665
- videoPlayer.volume = defaultVolume / 100
666
- videoPlayer.muted = beginMuted || simpleMode
677
+ // Initializes Settings
678
+ videoPlayer.volume = defaultVolume / 100
679
+ videoPlayer.muted = beginMuted || simpleMode
667
680
 
668
- getPlayerWidth()
681
+ getPlayerWidth()
669
682
 
670
- // Reports when the video has completed loading metadata (used for seeking after quality switch)
671
- videoPlayer.onloadedmetadata = qualitySwitchSeek
683
+ // Reports when the video has completed loading metadata (used for seeking after quality switch)
684
+ videoPlayer.onloadedmetadata = qualitySwitchSeek
672
685
 
673
- // Reports the video's duration when the video player is ready to play
674
- videoPlayer.oncanplay = initializeVideoDuration
686
+ // Reports the video's duration when the video player is ready to play
687
+ videoPlayer.oncanplay = initializeVideoDuration
675
688
 
676
- // Reports the video's width on resize
677
- window.addEventListener('resize', getPlayerWidth)
689
+ // Reports the video's width on resize
690
+ window.addEventListener('resize', getPlayerWidth)
678
691
 
679
- // Reports the current video timestamp
680
- videoPlayer.ontimeupdate = updateVideoTimestamp
692
+ // Reports the current video timestamp
693
+ videoPlayer.ontimeupdate = updateVideoTimestamp
681
694
 
682
- // Reports when the video has paused due to buffering
683
- videoPlayer.onwaiting = setAsBuffering
695
+ // Reports when the video has paused due to buffering
696
+ videoPlayer.onwaiting = setAsBuffering
684
697
 
685
- // Reports the video's latest buffering progress if video player is properly initialized
686
- videoPlayer.onprogress = updateBufferProgress
698
+ // Reports the video's latest buffering progress if video player is properly initialized
699
+ videoPlayer.onprogress = updateBufferProgress
687
700
 
688
- // Reports when the video has recovered from buffering
689
- videoPlayer.oncanplaythrough = playAfterBuffer
701
+ // Reports when the video has recovered from buffering
702
+ videoPlayer.oncanplaythrough = playAfterBuffer
690
703
 
691
- // Reports when the video has ended
692
- videoPlayer.onended = setAsEnded
704
+ // Reports when the video has ended
705
+ videoPlayer.onended = setAsEnded
693
706
 
694
- // Reports when the video is playing and disables the buffer spinner (even if buffering is still needed)
695
- videoPlayer.onplay = setAsPlaying
707
+ // Reports when the video is playing and disables the buffer spinner (even if buffering is still needed)
708
+ videoPlayer.onplay = setAsPlaying
696
709
 
697
- // Reports when the video has been paused
698
- videoPlayer.onpause = setAsPaused
710
+ // Reports when the video has been paused
711
+ videoPlayer.onpause = setAsPaused
699
712
 
700
- // Reports when the video has been seeked
701
- videoPlayer.onseeked = returnFromEndState
713
+ // Reports when the video has been seeked
714
+ videoPlayer.onseeked = returnFromEndState
702
715
 
703
- // Reports when the video's volume has been changed, or if the video has been muted
704
- videoPlayer.onvolumechange = updateVolumeState
716
+ // Reports when the video's volume has been changed, or if the video has been muted
717
+ videoPlayer.onvolumechange = updateVolumeState
705
718
 
706
- // Video Analytics
707
- if (
708
- (analyticsTracking !== undefined && videoTitle === undefined) ||
709
- (analyticsTracking === undefined && videoTitle !== undefined)
710
- ) {
711
- warn(
712
- 'Video',
713
- 'Both the `analyticsTracking` and `videoTitle` props must be defined in order to return a proper analytics object.'
714
- )
715
- }
719
+ // Video Analytics
720
+ if (
721
+ (analyticsTracking !== undefined && videoTitle === undefined) ||
722
+ (analyticsTracking === undefined && videoTitle !== undefined)
723
+ ) {
724
+ warn(
725
+ 'Video',
726
+ 'Both the `analyticsTracking` and `videoTitle` props must be defined in order to return a proper analytics object.'
727
+ )
728
+ }
716
729
 
717
- return () => {
718
- clearInactivityTimer()
719
- window.removeEventListener('resize', getPlayerWidth)
720
- clearInterval(videoPlayerState.intervalId)
730
+ return () => {
731
+ clearInactivityTimer()
732
+ window.removeEventListener('resize', getPlayerWidth)
733
+ clearInterval(videoPlayerState.intervalId)
734
+ }
721
735
  }
722
- }
723
736
 
724
- return () => {} // returning a noop for sake of consistency
725
- // eslint-disable-next-line react-hooks/exhaustive-deps
726
- }, [videoPlayerState.loadedSources, videoPlayerState.loadedTracks])
727
-
728
- const {
729
- loadedSources,
730
- loadedTracks,
731
- isMobile,
732
- mouseInactive,
733
- selectedTextTrack,
734
- qualityMenuOpen,
735
- captionsMenuOpen,
736
- videoUnplayed,
737
- videoEnded,
738
- videoIsBuffering,
739
- videoIsPlaying,
740
- videoIsFullscreen,
741
- videoIsMuted,
742
- videoQualityChanged,
743
- videoLength,
744
- videoBufferEnd,
745
- videoCurrentTime,
746
- videoCurrentVolume,
747
- videoQuality,
748
- videoPlayerWidth
749
- } = videoPlayerState
750
- const { style, className, as, ...safeRest } = rest
751
-
752
- return (
753
- <VideoPlayerContainer
754
- {...safeRest}
755
- ref={refVideoPlayerContainer}
756
- videoBorder={videoBorder}
757
- borderColor={borderColor}
758
- onMouseMove={resetInactivityTimer}
759
- onClick={handleClick}
760
- onKeyDown={handleKeyboard}
761
- tabIndex="0"
762
- aria-label={simpleMode ? videoText[copy].videoSelectedSimple : videoText[copy].videoSelected}
763
- data-testid="videoPlayer"
764
- {...selectProps(rest)}
765
- >
766
- <VideoOverlayContainer
767
- mouseInactive={mouseInactive}
768
- onClick={() => {
769
- closeSubMenus()
770
- togglePlayPause()
771
- }}
737
+ return () => {} // returning a noop for sake of consistency
738
+ // eslint-disable-next-line react-hooks/exhaustive-deps
739
+ }, [videoPlayerState.loadedSources, videoPlayerState.loadedTracks])
740
+
741
+ const {
742
+ loadedSources,
743
+ loadedTracks,
744
+ isMobile,
745
+ mouseInactive,
746
+ selectedTextTrack,
747
+ qualityMenuOpen,
748
+ captionsMenuOpen,
749
+ videoUnplayed,
750
+ videoEnded,
751
+ videoIsBuffering,
752
+ videoIsPlaying,
753
+ videoIsFullscreen,
754
+ videoIsMuted,
755
+ videoQualityChanged,
756
+ videoLength,
757
+ videoBufferEnd,
758
+ videoCurrentTime,
759
+ videoCurrentVolume,
760
+ videoQuality,
761
+ videoPlayerWidth
762
+ } = videoPlayerState
763
+ const { style, className, as, ...safeRest } = rest
764
+
765
+ return (
766
+ <VideoPlayerContainer
767
+ {...safeRest}
768
+ ref={refVideoPlayerContainer}
769
+ $videoBorder={videoBorder}
770
+ $borderColor={borderColor}
771
+ onMouseMove={resetInactivityTimer}
772
+ onClick={handleClick}
773
+ onKeyDown={handleKeyboard}
774
+ tabIndex="0"
775
+ aria-label={
776
+ simpleMode ? videoText[copy].videoSelectedSimple : videoText[copy].videoSelected
777
+ }
778
+ data-testid="videoPlayer"
779
+ {...selectProps(rest)}
772
780
  >
773
- {/* ======== Video Splash Screen ======== */}
774
- {videoUnplayed && !videoQualityChanged && (
775
- <VideoSplashContainer>
776
- <VideoSplash
777
- poster={posterSrc}
778
- copy={copy}
779
- videoLength={videoLength}
780
- simpleMode={simpleMode}
781
- iconLeftOffsetPx={2}
782
- onClick={beginVideo}
783
- />
784
- </VideoSplashContainer>
785
- )}
786
- {/* =================================== */}
787
- <VideoOverlayElementContainer>
788
- {/* ======== Replay Button ======== */}
789
- {videoEnded && <MiddleControlButton icon={replayIcon} onClick={replayVideo} />}
790
- {/* ================================ */}
791
- {/* ======== Middle Play/Pause Button ======= */}
792
- {!videoUnplayed && !videoIsBuffering && !videoEnded && !isMobile && (
793
- <MiddleControlButton
794
- icon={videoIsPlaying ? pauseIcon : playIcon}
795
- isHidden={mouseInactive}
796
- onClick={togglePlayPause}
797
- onFocus={resetInactivityTimer}
798
- />
799
- )}
800
- {/* ========================================== */}
801
-
802
- {/* ======== Spinner Display ======= */}
803
- {videoIsBuffering && !isMobile && <Spinner show />}
804
- {/* ================================ */}
805
- </VideoOverlayElementContainer>
806
- </VideoOverlayContainer>
807
-
808
- {/* ======== Video Element ======= */}
809
- <VideoElementContainer videoIsFullscreen={videoIsFullscreen} mouseInactive={mouseInactive}>
810
- <VideoPlayer
811
- ref={refVideoPlayer}
812
- controls={isMobile}
813
- videoIsFullscreen={videoIsFullscreen}
814
- crossOrigin={crossOrigin}
815
- playsinline
781
+ <VideoOverlayContainer
782
+ $mouseInactive={mouseInactive}
783
+ onClick={() => {
784
+ closeSubMenus()
785
+ togglePlayPause()
786
+ }}
816
787
  >
817
- {loadedSources}
818
- {loadedTracks}
819
- Your browser does not support the video tag.
820
- </VideoPlayer>
821
- </VideoElementContainer>
822
- {/* ============================== */}
823
-
824
- {!simpleMode && (
825
- <ControlBar
826
- videoPlayer={refVideoPlayer}
827
- videoPlayerContainer={refVideoPlayerContainer}
828
- sources={sources}
829
- tracks={tracks}
830
- videoLength={videoLength}
831
- videoBufferEnd={videoBufferEnd}
832
- videoCurrentTime={videoCurrentTime}
833
- videoPlaying={refVideoPlayer.current !== null ? !refVideoPlayer.current.paused : false}
834
- videoUnplayed={videoUnplayed}
835
- videoCurrentVolume={videoCurrentVolume}
836
- videoIsMuted={videoIsMuted}
837
- setVolume={setVolume}
838
- isHidden={(mouseInactive || videoUnplayed) && !videoEnded}
839
- isMobile={isMobile}
840
- tracksAvailable={tracks !== undefined}
841
- togglePlayPause={togglePlayPause}
842
- setSeek={setSeek}
843
- toggleMute={toggleMute}
844
- toggleFullscreen={toggleFullscreen}
845
- videoIsFullscreen={videoIsFullscreen}
846
- setTextTracks={setTextTracks}
847
- selectedTextTrack={selectedTextTrack}
848
- resetInactivityTimer={resetInactivityTimer}
849
- videoQuality={videoQuality}
850
- setVideoQuality={setVideoQuality}
851
- qualityMenuOpen={qualityMenuOpen}
852
- setQualityMenuOpen={setQualityMenuOpen}
853
- captionsMenuOpen={captionsMenuOpen}
854
- setCaptionsMenuOpen={setCaptionsMenuOpen}
855
- clearInactivityTimer={clearInactivityTimer}
856
- copy={copy}
857
- compactModeThreshold={playerOptions.compactModeThreshold}
858
- videoPlayerWidth={videoPlayerWidth}
859
- onMouseOver={() => setMouseOnControlBar(true)}
860
- onMouseOut={() => setMouseOnControlBar(false)}
861
- onFocus={() => {}}
862
- onBlur={() => {}}
788
+ {/* ======== Video Splash Screen ======== */}
789
+ {videoUnplayed && !videoQualityChanged && (
790
+ <VideoSplashContainer>
791
+ <VideoSplash
792
+ poster={posterSrc}
793
+ copy={copy}
794
+ videoLength={videoLength}
795
+ simpleMode={simpleMode}
796
+ iconLeftOffsetPx={2}
797
+ onClick={beginVideo}
798
+ />
799
+ </VideoSplashContainer>
800
+ )}
801
+ {/* =================================== */}
802
+ <VideoOverlayElementContainer>
803
+ {/* ======== Replay Button ======== */}
804
+ {videoEnded && <MiddleControlButton icon={replayIcon} onClick={replayVideo} />}
805
+ {/* ================================ */}
806
+ {/* ======== Middle Play/Pause Button ======= */}
807
+ {!videoUnplayed && !videoIsBuffering && !videoEnded && !isMobile && (
808
+ <MiddleControlButton
809
+ icon={videoIsPlaying ? pauseIcon : playIcon}
810
+ isHidden={mouseInactive}
811
+ onClick={togglePlayPause}
812
+ onFocus={resetInactivityTimer}
813
+ />
814
+ )}
815
+ {/* ========================================== */}
816
+
817
+ {/* ======== Spinner Display ======= */}
818
+ {videoIsBuffering && !isMobile && <Spinner show />}
819
+ {/* ================================ */}
820
+ </VideoOverlayElementContainer>
821
+ </VideoOverlayContainer>
822
+
823
+ {/* ======== Video Element ======= */}
824
+ <VideoElementContainer ref={ref}>
825
+ <VideoPlayer
826
+ ref={refVideoPlayer}
827
+ controls={isMobile}
828
+ crossOrigin={crossOrigin}
829
+ playsInline
830
+ >
831
+ {loadedSources}
832
+ {loadedTracks}
833
+ Your browser does not support the video tag.
834
+ </VideoPlayer>
835
+ </VideoElementContainer>
836
+ {/* ============================== */}
837
+
838
+ {!simpleMode && (
839
+ <ControlBar
840
+ videoPlayer={refVideoPlayer}
841
+ videoPlayerContainer={refVideoPlayerContainer}
842
+ sources={sources}
843
+ tracks={tracks}
844
+ videoLength={videoLength}
845
+ videoBufferEnd={videoBufferEnd}
846
+ videoCurrentTime={videoCurrentTime}
847
+ videoPlaying={refVideoPlayer.current !== null ? !refVideoPlayer.current.paused : false}
848
+ videoUnplayed={videoUnplayed}
849
+ videoCurrentVolume={videoCurrentVolume}
850
+ videoIsMuted={videoIsMuted}
851
+ setVolume={setVolume}
852
+ isHidden={(mouseInactive || videoUnplayed) && !videoEnded}
853
+ isMobile={isMobile}
854
+ tracksAvailable={tracks !== undefined}
855
+ togglePlayPause={togglePlayPause}
856
+ setSeek={setSeek}
857
+ toggleMute={toggleMute}
858
+ toggleFullscreen={toggleFullscreen}
859
+ videoIsFullscreen={videoIsFullscreen}
860
+ setTextTracks={setTextTracks}
861
+ selectedTextTrack={selectedTextTrack}
862
+ resetInactivityTimer={resetInactivityTimer}
863
+ videoQuality={videoQuality}
864
+ setVideoQuality={setVideoQuality}
865
+ qualityMenuOpen={qualityMenuOpen}
866
+ setQualityMenuOpen={setQualityMenuOpen}
867
+ captionsMenuOpen={captionsMenuOpen}
868
+ setCaptionsMenuOpen={setCaptionsMenuOpen}
869
+ clearInactivityTimer={clearInactivityTimer}
870
+ copy={copy}
871
+ compactModeThreshold={playerOptions.compactModeThreshold}
872
+ videoPlayerWidth={videoPlayerWidth}
873
+ onMouseOver={() => setMouseOnControlBar(true)}
874
+ onMouseOut={() => setMouseOnControlBar(false)}
875
+ onFocus={() => {}}
876
+ onBlur={() => {}}
877
+ />
878
+ )}
879
+
880
+ {/* ======== Screen Reader Keyboard Instructions ======= */}
881
+ <span
882
+ tabIndex="-1"
883
+ ref={refKeyboardInstructions}
884
+ aria-label={videoText[copy].videoPlayer}
885
+ role="note"
863
886
  />
864
- )}
865
-
866
- {/* ======== Screen Reader Keyboard Instructions ======= */}
867
- <span
868
- tabIndex="-1"
869
- ref={refKeyboardInstructions}
870
- aria-label={videoText[copy].videoPlayer}
871
- role="note"
872
- />
873
- {/* ==================================================== */}
874
- </VideoPlayerContainer>
875
- )
876
- }
887
+ {/* ==================================================== */}
888
+ </VideoPlayerContainer>
889
+ )
890
+ }
891
+ )
892
+ Video.displayName = 'Video'
877
893
 
878
894
  Video.propTypes = {
879
895
  ...selectedSystemPropTypes,
@@ -970,5 +986,3 @@ Video.propTypes = {
970
986
  tokens: getTokensPropType('Video'),
971
987
  variant: variantProp.propType
972
988
  }
973
-
974
- export default Video