@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,959 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import styled from 'styled-components';
4
- import fscreen from 'fscreen';
5
- import { useThemeTokens, selectSystemProps, getTokensPropType, variantProp } from '@telus-uds/components-base';
6
- import Spinner from '../Spinner';
7
- import { warn, htmlAttrs } from '../utils';
8
- import VideoSplash from '../shared/VideoSplash/VideoSplash';
9
- import MiddleControlButton from './MiddleControlButton/MiddleControlButton';
10
- import ControlBar from './ControlBar/ControlBar';
11
- import videoText from './videoText';
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { jsxs as _jsxs } from "react/jsx-runtime";
14
- const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
15
-
16
- // TODO: replace with the actual spinner component from UDS
17
- const VideoPlayerContainer = /*#__PURE__*/styled.div.withConfig({
18
- displayName: "Video__VideoPlayerContainer",
19
- componentId: "components-web__sc-12ltnuw-0"
20
- })(_ref => {
21
- let {
22
- videoBorder,
23
- borderColor
24
- } = _ref;
25
- return {
26
- width: '100%',
27
- outline: 'none',
28
- position: 'relative',
29
- border: videoBorder ? `20px solid ${borderColor}` : undefined
30
- };
31
- });
32
- const VideoElementContainer = /*#__PURE__*/styled.div.withConfig({
33
- displayName: "Video__VideoElementContainer",
34
- componentId: "components-web__sc-12ltnuw-1"
35
- })({
36
- outline: 'none',
37
- width: '100%',
38
- height: '100%',
39
- fontSize: 0
40
- });
41
- const VideoPlayer = /*#__PURE__*/styled.video.withConfig({
42
- displayName: "Video__VideoPlayer",
43
- componentId: "components-web__sc-12ltnuw-2"
44
- })({
45
- width: '100%',
46
- height: '100%'
47
- });
48
- const VideoOverlayContainer = /*#__PURE__*/styled.div.withConfig({
49
- displayName: "Video__VideoOverlayContainer",
50
- componentId: "components-web__sc-12ltnuw-3"
51
- })(_ref2 => {
52
- let {
53
- mouseInactive
54
- } = _ref2;
55
- return {
56
- width: '100%',
57
- height: '100%',
58
- position: 'absolute',
59
- cursor: mouseInactive ? 'none' : 'pointer'
60
- };
61
- });
62
- const VideoSplashContainer = /*#__PURE__*/styled.div.withConfig({
63
- displayName: "Video__VideoSplashContainer",
64
- componentId: "components-web__sc-12ltnuw-4"
65
- })({
66
- position: 'absolute',
67
- width: '100%',
68
- height: '100%',
69
- zIndex: 5
70
- });
71
- const VideoOverlayElementContainer = /*#__PURE__*/styled.div.withConfig({
72
- displayName: "Video__VideoOverlayElementContainer",
73
- componentId: "components-web__sc-12ltnuw-5"
74
- })({
75
- position: 'absolute',
76
- zIndex: 4,
77
- display: 'flex',
78
- justifyContent: 'center',
79
- alignItems: 'center',
80
- width: '100%',
81
- height: '100%'
82
- });
83
- const Video = _ref3 => {
84
- let {
85
- analyticsTracking,
86
- videoTitle,
87
- videoBorder = false,
88
- simpleMode = false,
89
- copy,
90
- posterSrc,
91
- crossOrigin,
92
- defaultVolume = 100,
93
- beginMuted = false,
94
- sources,
95
- tracks,
96
- defaultDesktopQuality = 1,
97
- defaultMobileQuality = 1,
98
- tokens,
99
- variant = {},
100
- ...rest
101
- } = _ref3;
102
- const refVideoPlayer = React.useRef({});
103
- const refVideoPlayerContainer = React.useRef({});
104
- const refKeyboardInstructions = React.useRef({});
105
- let inactivityTimer = null;
106
- const {
107
- borderColor,
108
- pauseIcon,
109
- playIcon,
110
- replayIcon
111
- } = useThemeTokens('Video', tokens, variant);
112
- const playerOptions = {
113
- mouseTimeout: simpleMode ? 750 : 1500,
114
- // defined in ms
115
- keyboardSeekIncrement: 5,
116
- // defined in s
117
- keyboardVolumeIncrement: 0.1,
118
- // from 0 to 1
119
- compactModeThreshold: 700 // in px
120
- };
121
-
122
- const [videoPlayerState, setVideoPlayerState] = React.useState({
123
- loadedSources: null,
124
- loadedTracks: null,
125
- videoLength: 0,
126
- videoCurrentTime: -1,
127
- videoBufferEnd: 0,
128
- videoUnplayed: true,
129
- videoIsBuffering: false,
130
- videoCurrentVolume: 1,
131
- videoIsPlaying: false,
132
- videoIsMuted: false,
133
- videoIsFullscreen: false,
134
- mouseInactive: false,
135
- videoEnded: false,
136
- videoQuality: defaultDesktopQuality,
137
- videoQualityChanged: false,
138
- selectedTextTrack: -1,
139
- mouseOnControlBar: false,
140
- qualityMenuOpen: false,
141
- captionsMenuOpen: false,
142
- isMobile: false,
143
- videoPlayerWidth: 0,
144
- percentageWatched: 'watched 0%'
145
- });
146
- const generateSources = videoQuality => {
147
- return sources.map(source => {
148
- if (source.qualityRank === videoQuality) {
149
- return /*#__PURE__*/React.createElement('source', {
150
- src: source.source,
151
- type: source.mediaType,
152
- key: source.source
153
- });
154
- }
155
- return undefined;
156
- });
157
- };
158
- const generateTracks = () => {
159
- return tracks.map(track => {
160
- return /*#__PURE__*/React.createElement('track', {
161
- label: track.label,
162
- kind: track.kind,
163
- srcLang: track.language,
164
- src: track.source,
165
- default: track.isDefault,
166
- key: track.source
167
- });
168
- });
169
- };
170
- const refreshMedia = () => {
171
- const {
172
- videoUnplayed
173
- } = videoPlayerState;
174
-
175
- // Handle mobile check
176
- const isMobile = navigator && navigator.userAgent.indexOf('Mobi') >= 0;
177
- if (videoUnplayed && isMobile) {
178
- setVideoPlayerState(prevState => ({
179
- ...prevState,
180
- isMobile,
181
- videoQuality: isMobile ? defaultMobileQuality : defaultDesktopQuality
182
- }));
183
- }
184
-
185
- // Load media
186
- setVideoPlayerState(prevState => ({
187
- ...prevState,
188
- loadedSources: generateSources(prevState.videoQuality),
189
- loadedTracks: tracks && generateTracks()
190
- }));
191
- };
192
- const percentageBucket = percentValue => {
193
- if (percentValue < 25) {
194
- return setVideoPlayerState(prevState => {
195
- if (prevState !== 'watched 0%') {
196
- return {
197
- ...prevState,
198
- percentageWatched: 'watched 0%'
199
- };
200
- }
201
- return false;
202
- });
203
- }
204
- if (percentValue < 50) {
205
- return setVideoPlayerState(prevState => {
206
- if (prevState !== 'watched 25%') {
207
- return {
208
- ...prevState,
209
- percentageWatched: 'watched 25%'
210
- };
211
- }
212
- return false;
213
- });
214
- }
215
- if (percentValue < 75) {
216
- return setVideoPlayerState(prevState => {
217
- if (prevState !== 'watched 50%') {
218
- return {
219
- ...prevState,
220
- percentageWatched: 'watched 50%'
221
- };
222
- }
223
- return false;
224
- });
225
- }
226
- if (percentValue < 100) {
227
- return setVideoPlayerState(prevState => {
228
- if (prevState !== 'watched 75%') {
229
- return {
230
- ...prevState,
231
- percentageWatched: 'watched 75%'
232
- };
233
- }
234
- return false;
235
- });
236
- }
237
- if (percentValue === 100) {
238
- return setVideoPlayerState(prevState => {
239
- if (prevState !== 'watched 100%') {
240
- return {
241
- ...prevState,
242
- percentageWatched: 'watched 100%'
243
- };
244
- }
245
- return false;
246
- });
247
- }
248
- return false;
249
- };
250
-
251
- // required for analytics
252
- const calculatePercentageWatched = () => {
253
- const {
254
- videoCurrentTime,
255
- videoLength,
256
- percentageWatched
257
- } = videoPlayerState;
258
- let percentValue = videoCurrentTime / videoLength * 100;
259
- percentValue = Math.round(percentValue);
260
- const previousValue = percentageWatched;
261
- percentageBucket(percentValue);
262
- if (previousValue !== percentageWatched) {
263
- const analyticsObject = {
264
- name: 'video tracking',
265
- details: videoTitle
266
- };
267
- analyticsObject.action = percentageWatched;
268
- analyticsTracking(analyticsObject);
269
- }
270
- };
271
- const setPlaying = async isPlaying => {
272
- const videoPlayer = refVideoPlayer.current;
273
- if (isPlaying) {
274
- await videoPlayer.play();
275
- if (analyticsTracking !== undefined && videoTitle) {
276
- const intervalId = setInterval(calculatePercentageWatched, 300);
277
- setVideoPlayerState(prevState => ({
278
- ...prevState,
279
- intervalId
280
- }));
281
- }
282
- } else {
283
- const {
284
- intervalId
285
- } = videoPlayerState;
286
- videoPlayer.pause();
287
- clearInterval(intervalId);
288
- }
289
- };
290
- const updateAnalyticsData = () => {
291
- const {
292
- videoIsPlaying,
293
- percentageWatched
294
- } = videoPlayerState;
295
- const analyticsObject = {
296
- name: 'video tracking',
297
- details: videoTitle
298
- };
299
- analyticsObject.action = videoIsPlaying ? 'play' : 'pause';
300
- if (percentageWatched !== 'watched 100%') {
301
- analyticsTracking(analyticsObject);
302
- }
303
- };
304
- const setSeek = seconds => {
305
- refVideoPlayer.current.currentTime = seconds;
306
- };
307
- const qualitySwitchSeek = () => {
308
- const {
309
- videoCurrentTime
310
- } = videoPlayerState;
311
-
312
- // The following setState gets the video length on the splash screen in iOS
313
- setVideoPlayerState(prevState => ({
314
- ...prevState,
315
- videoLength: refVideoPlayer.current.duration
316
- }));
317
- if (videoCurrentTime > -1) {
318
- setSeek(videoCurrentTime);
319
- }
320
- };
321
- const updateVideoTimestamp = () => {
322
- setVideoPlayerState(prevState => ({
323
- ...prevState,
324
- videoCurrentTime: refVideoPlayer.current.currentTime
325
- }));
326
- };
327
- const initializeVideoDuration = () => {
328
- // This will run on every load() call, meaning it will also run when video quality is changed.
329
- setVideoPlayerState(prevState => {
330
- return {
331
- ...prevState,
332
- videoLength: refVideoPlayer.current.duration,
333
- videoBufferEnd: refVideoPlayer.current.buffered.length === 0 ? 0 : refVideoPlayer.current.buffered.end(refVideoPlayer.current.buffered.length - 1),
334
- videoUnplayed: refVideoPlayer.current.played.length === 0 && !prevState.videoQualityChanged
335
- };
336
- });
337
- const {
338
- videoQualityChanged,
339
- videoIsPlaying
340
- } = videoPlayerState;
341
-
342
- // Prevents an IE 11 bug where the video will not continue playing after a quality switch
343
- if (videoQualityChanged && videoIsPlaying) {
344
- setPlaying(true);
345
- }
346
- };
347
- const clearInactivityTimer = () => {
348
- setVideoPlayerState(prevState => ({
349
- ...prevState,
350
- mouseInactive: false
351
- }));
352
- clearTimeout(inactivityTimer);
353
- };
354
- const setAsBuffering = () => {
355
- // Prevent IE infinite buffer bug with readyState
356
- if (refVideoPlayer.current.readyState < 4) {
357
- clearInactivityTimer();
358
- setVideoPlayerState(prevState => ({
359
- ...prevState,
360
- videoIsPlaying: false,
361
- videoIsBuffering: true,
362
- mouseInactive: true
363
- }));
364
- setPlaying(false);
365
- }
366
- };
367
- const playAfterBuffer = () => {
368
- const {
369
- videoIsBuffering,
370
- videoCurrentTime,
371
- videoQualityChanged
372
- } = videoPlayerState;
373
- if (videoIsBuffering && videoCurrentTime !== -1 && !videoQualityChanged) {
374
- setPlaying(true);
375
- setVideoPlayerState(prevState => ({
376
- ...prevState,
377
- videoIsBuffering: false
378
- }));
379
- }
380
- };
381
- const resetInactivityTimer = () => {
382
- clearInactivityTimer();
383
- const {
384
- videoQualityChanged,
385
- videoIsPlaying,
386
- mouseOnControlBar
387
- } = videoPlayerState;
388
- if (!videoQualityChanged && videoIsPlaying) {
389
- inactivityTimer = setTimeout(() => {
390
- if (!mouseOnControlBar) {
391
- setVideoPlayerState(prevState => ({
392
- ...prevState,
393
- mouseInactive: true
394
- }));
395
- }
396
- }, playerOptions.mouseTimeout);
397
- }
398
- };
399
- const setAsPlaying = () => {
400
- setVideoPlayerState(prevState => ({
401
- ...prevState,
402
- videoIsPlaying: true,
403
- videoIsBuffering: false,
404
- videoEnded: false,
405
- videoUnplayed: false,
406
- videoQualityChanged: false
407
- }));
408
- if (analyticsTracking) {
409
- updateAnalyticsData();
410
- }
411
- resetInactivityTimer();
412
- };
413
- const setAsPaused = () => {
414
- clearInactivityTimer();
415
- setVideoPlayerState(prevState => ({
416
- ...prevState,
417
- videoIsPlaying: false
418
- }));
419
- if (analyticsTracking) {
420
- updateAnalyticsData();
421
- }
422
- };
423
- const returnFromEndState = () => {
424
- resetInactivityTimer();
425
- setVideoPlayerState(prevState => ({
426
- ...prevState,
427
- videoEnded: false
428
- }));
429
- };
430
- const setAsEnded = () => {
431
- setVideoPlayerState(prevState => ({
432
- ...prevState,
433
- videoIsPlaying: false,
434
- videoEnded: true
435
- }));
436
- clearInactivityTimer();
437
- };
438
- const updateBufferProgress = () => {
439
- const {
440
- videoCurrentTime,
441
- videoQualityChanged
442
- } = videoPlayerState;
443
- const videoPlayer = refVideoPlayer.current;
444
- if (videoPlayer && videoPlayer.readyState >= 2) {
445
- const {
446
- buffered
447
- } = videoPlayer;
448
- setVideoPlayerState(prevState => ({
449
- ...prevState,
450
- videoBufferEnd: buffered.length === 0 ? 0 : buffered.end(buffered.length - 1)
451
- }));
452
- } else if (videoCurrentTime !== -1 && !videoQualityChanged && !videoPlayer) {
453
- setVideoPlayerState(prevState => ({
454
- ...prevState,
455
- videoIsPlaying: false,
456
- videoIsBuffering: true
457
- }));
458
- }
459
- };
460
- const updateVolumeState = () => {
461
- resetInactivityTimer();
462
- const videoPlayer = refVideoPlayer.current;
463
- setVideoPlayerState(prevState => ({
464
- ...prevState,
465
- videoCurrentVolume: videoPlayer.volume,
466
- videoIsMuted: videoPlayer.muted
467
- }));
468
- };
469
- const getPlayerWidth = () => {
470
- setVideoPlayerState(prevState => ({
471
- ...prevState,
472
- videoPlayerWidth: refVideoPlayerContainer.current.offsetWidth
473
- }));
474
- };
475
- const setMouseOnControlBar = isOver => {
476
- setVideoPlayerState(prevState => ({
477
- ...prevState,
478
- mouseOnControlBar: isOver
479
- }));
480
- };
481
- const togglePlayPause = () => {
482
- const {
483
- videoIsPlaying
484
- } = videoPlayerState;
485
- setPlaying(!videoIsPlaying);
486
- };
487
- const setTextTracks = trackNumber => {
488
- const {
489
- textTracks
490
- } = refVideoPlayer.current;
491
- for (let i = 0; i < textTracks.length; i += 1) {
492
- textTracks[i].mode = i === trackNumber ? 'showing' : 'hidden';
493
- }
494
- setVideoPlayerState(prevState => ({
495
- ...prevState,
496
- selectedTextTrack: trackNumber
497
- }));
498
- };
499
- const beginVideo = () => {
500
- setTextTracks(-1);
501
- setPlaying(true);
502
- refVideoPlayerContainer.current.focus();
503
- };
504
- const closeSubMenus = () => {
505
- setVideoPlayerState(prevState => ({
506
- ...prevState,
507
- qualityMenuOpen: false,
508
- captionsMenuOpen: false
509
- }));
510
- };
511
- const incrementSeek = seconds => {
512
- refVideoPlayer.current.currentTime += seconds;
513
- };
514
- const replayVideo = async () => {
515
- setSeek(0);
516
- togglePlayPause();
517
- };
518
- const incrementVolume = amount => {
519
- refVideoPlayer.current.volume += amount;
520
- };
521
- const setVolume = amount => {
522
- refVideoPlayer.current.volume = amount;
523
- };
524
- const toggleMute = () => {
525
- refVideoPlayer.current.muted = !refVideoPlayer.current.muted;
526
- };
527
- const setCaptionsMenuOpen = isOpen => {
528
- setVideoPlayerState(prevState => ({
529
- ...prevState,
530
- captionsMenuOpen: isOpen
531
- }));
532
- };
533
- const toggleFullscreen = () => {
534
- if (fscreen.fullscreenEnabled) {
535
- if (fscreen.fullscreenElement === null) {
536
- fscreen.requestFullscreen(refVideoPlayerContainer.current);
537
- } else {
538
- fscreen.exitFullscreen();
539
- }
540
- setVideoPlayerState(prevState => {
541
- return {
542
- ...prevState,
543
- videoIsFullscreen: !prevState.videoIsFullscreen
544
- };
545
- });
546
- }
547
- };
548
- const setVideoQuality = async newVideoQuality => {
549
- await setPlaying(false);
550
- setVideoPlayerState(prevState => ({
551
- ...prevState,
552
- videoLength: 0,
553
- videoBufferEnd: 0,
554
- videoQuality: newVideoQuality,
555
- loadedSources: generateSources(newVideoQuality),
556
- loadedTracks: tracks && generateTracks(),
557
- videoQualityChanged: true
558
- }));
559
- await refVideoPlayer.current.load();
560
- resetInactivityTimer();
561
- setSeek(videoPlayerState.videoCurrentTime);
562
- };
563
- const setQualityMenuOpen = isOpen => {
564
- setVideoPlayerState(prevState => ({
565
- ...prevState,
566
- qualityMenuOpen: isOpen
567
- }));
568
- };
569
- const handleClick = event => {
570
- resetInactivityTimer();
571
-
572
- // This allows playing videos within components that act like
573
- // links, e.g. `PreviewCard`, `StoryCard`, etc.
574
- event === null || event === void 0 ? void 0 : event.preventDefault();
575
- event === null || event === void 0 ? void 0 : event.stopPropagation();
576
- };
577
- const handleKeyboard = event => {
578
- const {
579
- videoLength,
580
- videoCurrentVolume
581
- } = videoPlayerState;
582
- const key = event.key || event.keyCode;
583
-
584
- // *** Begin Seek & Play Control ****
585
- if (key === ' ' || key === 32 || key === 'k' || key === 75) {
586
- event.preventDefault();
587
- resetInactivityTimer();
588
- togglePlayPause();
589
- }
590
-
591
- // Disables all keys except for play/pause when in simpleMode
592
- if (!simpleMode) {
593
- if (key === 'ArrowRight' || key === 39 || key === '.' || key === 190) {
594
- resetInactivityTimer();
595
- incrementSeek(playerOptions.keyboardSeekIncrement);
596
- }
597
- if (key === 'ArrowLeft' || key === 37 || key === ',' || key === 188) {
598
- resetInactivityTimer();
599
- incrementSeek(-playerOptions.keyboardSeekIncrement);
600
- }
601
- if (key === '0' || key === 48 || key === 'numpad 0' || key === 96) {
602
- setSeek(0);
603
- }
604
- if (key === '1' || key === 49 || key === 'numpad 1' || key === 97) {
605
- setSeek(videoLength * 0.1);
606
- }
607
- if (key === '2' || key === 50 || key === 'numpad 2' || key === 98) {
608
- setSeek(videoLength * 0.2);
609
- }
610
- if (key === '3' || key === 51 || key === 'numpad 3' || key === 99) {
611
- setSeek(videoLength * 0.3);
612
- }
613
- if (key === '4' || key === 52 || key === 'numpad 4' || key === 100) {
614
- setSeek(videoLength * 0.4);
615
- }
616
- if (key === '5' || key === 53 || key === 'numpad 5' || key === 101) {
617
- setSeek(videoLength * 0.5);
618
- }
619
- if (key === '6' || key === 54 || key === 'numpad 6' || key === 102) {
620
- setSeek(videoLength * 0.6);
621
- }
622
- if (key === '7' || key === 55 || key === 'numpad 7' || key === 103) {
623
- setSeek(videoLength * 0.7);
624
- }
625
- if (key === '8' || key === 56 || key === 'numpad 8' || key === 104) {
626
- setSeek(videoLength * 0.8);
627
- }
628
- if (key === '9' || key === 57 || key === 'numpad 9' || key === 105) {
629
- setSeek(videoLength * 0.9);
630
- }
631
-
632
- // **** End Seek & Play Control ****
633
-
634
- // **** Begin Volume Control ****
635
-
636
- const {
637
- keyboardVolumeIncrement
638
- } = playerOptions;
639
- if (key === 'ArrowUp' || key === 38 || key === '=' || key === 187 || key === 'add' || key === 107) {
640
- resetInactivityTimer();
641
- if (videoCurrentVolume + keyboardVolumeIncrement < 1) {
642
- incrementVolume(keyboardVolumeIncrement);
643
- } else {
644
- setVolume(1);
645
- }
646
- }
647
- if (key === 'ArrowDown' || key === 40 || key === '-' || key === 189 || key === 'subtract' || key === 109) {
648
- resetInactivityTimer();
649
- if (videoCurrentVolume - keyboardVolumeIncrement > 0) {
650
- incrementVolume(-keyboardVolumeIncrement);
651
- } else {
652
- setVolume(0);
653
- }
654
- }
655
- if (key === 'm' || key === 77) {
656
- resetInactivityTimer();
657
- toggleMute();
658
- }
659
- if (key === 'f' || key === 70) {
660
- resetInactivityTimer();
661
- toggleFullscreen();
662
- }
663
- if (key === 'Escape' || key === 27) {
664
- // Resets focus back to container if user is focused on ControlBar button
665
- refVideoPlayerContainer.current.focus();
666
- closeSubMenus();
667
- }
668
- if (key === 'q' || key === 81) {
669
- refKeyboardInstructions.current.focus();
670
- }
671
- }
672
- };
673
-
674
- // Prepares video and caption files
675
- React.useEffect(() => {
676
- refreshMedia();
677
- // eslint-disable-next-line react-hooks/exhaustive-deps
678
- }, []);
679
-
680
- // Initial Setup after loading sources
681
- React.useEffect(() => {
682
- const {
683
- loadedSources,
684
- loadedTracks
685
- } = videoPlayerState;
686
- if (loadedSources && loadedTracks) {
687
- const videoPlayer = refVideoPlayer.current;
688
-
689
- // Initializes Settings
690
- videoPlayer.volume = defaultVolume / 100;
691
- videoPlayer.muted = beginMuted || simpleMode;
692
- getPlayerWidth();
693
-
694
- // Reports when the video has completed loading metadata (used for seeking after quality switch)
695
- videoPlayer.onloadedmetadata = qualitySwitchSeek;
696
-
697
- // Reports the video's duration when the video player is ready to play
698
- videoPlayer.oncanplay = initializeVideoDuration;
699
-
700
- // Reports the video's width on resize
701
- window.addEventListener('resize', getPlayerWidth);
702
-
703
- // Reports the current video timestamp
704
- videoPlayer.ontimeupdate = updateVideoTimestamp;
705
-
706
- // Reports when the video has paused due to buffering
707
- videoPlayer.onwaiting = setAsBuffering;
708
-
709
- // Reports the video's latest buffering progress if video player is properly initialized
710
- videoPlayer.onprogress = updateBufferProgress;
711
-
712
- // Reports when the video has recovered from buffering
713
- videoPlayer.oncanplaythrough = playAfterBuffer;
714
-
715
- // Reports when the video has ended
716
- videoPlayer.onended = setAsEnded;
717
-
718
- // Reports when the video is playing and disables the buffer spinner (even if buffering is still needed)
719
- videoPlayer.onplay = setAsPlaying;
720
-
721
- // Reports when the video has been paused
722
- videoPlayer.onpause = setAsPaused;
723
-
724
- // Reports when the video has been seeked
725
- videoPlayer.onseeked = returnFromEndState;
726
-
727
- // Reports when the video's volume has been changed, or if the video has been muted
728
- videoPlayer.onvolumechange = updateVolumeState;
729
-
730
- // Video Analytics
731
- if (analyticsTracking !== undefined && videoTitle === undefined || analyticsTracking === undefined && videoTitle !== undefined) {
732
- warn('Video', 'Both the `analyticsTracking` and `videoTitle` props must be defined in order to return a proper analytics object.');
733
- }
734
- return () => {
735
- clearInactivityTimer();
736
- window.removeEventListener('resize', getPlayerWidth);
737
- clearInterval(videoPlayerState.intervalId);
738
- };
739
- }
740
- return () => {}; // returning a noop for sake of consistency
741
- // eslint-disable-next-line react-hooks/exhaustive-deps
742
- }, [videoPlayerState.loadedSources, videoPlayerState.loadedTracks]);
743
- const {
744
- loadedSources,
745
- loadedTracks,
746
- isMobile,
747
- mouseInactive,
748
- selectedTextTrack,
749
- qualityMenuOpen,
750
- captionsMenuOpen,
751
- videoUnplayed,
752
- videoEnded,
753
- videoIsBuffering,
754
- videoIsPlaying,
755
- videoIsFullscreen,
756
- videoIsMuted,
757
- videoQualityChanged,
758
- videoLength,
759
- videoBufferEnd,
760
- videoCurrentTime,
761
- videoCurrentVolume,
762
- videoQuality,
763
- videoPlayerWidth
764
- } = videoPlayerState;
765
- const {
766
- style,
767
- className,
768
- as,
769
- ...safeRest
770
- } = rest;
771
- return /*#__PURE__*/_jsxs(VideoPlayerContainer, {
772
- ...safeRest,
773
- ref: refVideoPlayerContainer,
774
- videoBorder: videoBorder,
775
- borderColor: borderColor,
776
- onMouseMove: resetInactivityTimer,
777
- onClick: handleClick,
778
- onKeyDown: handleKeyboard,
779
- tabIndex: "0",
780
- "aria-label": simpleMode ? videoText[copy].videoSelectedSimple : videoText[copy].videoSelected,
781
- "data-testid": "videoPlayer",
782
- ...selectProps(rest),
783
- children: [/*#__PURE__*/_jsxs(VideoOverlayContainer, {
784
- mouseInactive: mouseInactive,
785
- onClick: () => {
786
- closeSubMenus();
787
- togglePlayPause();
788
- },
789
- children: [videoUnplayed && !videoQualityChanged && /*#__PURE__*/_jsx(VideoSplashContainer, {
790
- children: /*#__PURE__*/_jsx(VideoSplash, {
791
- poster: posterSrc,
792
- copy: copy,
793
- videoLength: videoLength,
794
- simpleMode: simpleMode,
795
- iconLeftOffsetPx: 2,
796
- onClick: beginVideo
797
- })
798
- }), /*#__PURE__*/_jsxs(VideoOverlayElementContainer, {
799
- children: [videoEnded && /*#__PURE__*/_jsx(MiddleControlButton, {
800
- icon: replayIcon,
801
- onClick: replayVideo
802
- }), !videoUnplayed && !videoIsBuffering && !videoEnded && !isMobile && /*#__PURE__*/_jsx(MiddleControlButton, {
803
- icon: videoIsPlaying ? pauseIcon : playIcon,
804
- isHidden: mouseInactive,
805
- onClick: togglePlayPause,
806
- onFocus: resetInactivityTimer
807
- }), videoIsBuffering && !isMobile && /*#__PURE__*/_jsx(Spinner, {
808
- show: true
809
- })]
810
- })]
811
- }), /*#__PURE__*/_jsx(VideoElementContainer, {
812
- videoIsFullscreen: videoIsFullscreen,
813
- mouseInactive: mouseInactive,
814
- children: /*#__PURE__*/_jsxs(VideoPlayer, {
815
- ref: refVideoPlayer,
816
- controls: isMobile,
817
- videoIsFullscreen: videoIsFullscreen,
818
- crossOrigin: crossOrigin,
819
- playsinline: true,
820
- children: [loadedSources, loadedTracks, "Your browser does not support the video tag."]
821
- })
822
- }), !simpleMode && /*#__PURE__*/_jsx(ControlBar, {
823
- videoPlayer: refVideoPlayer,
824
- videoPlayerContainer: refVideoPlayerContainer,
825
- sources: sources,
826
- tracks: tracks,
827
- videoLength: videoLength,
828
- videoBufferEnd: videoBufferEnd,
829
- videoCurrentTime: videoCurrentTime,
830
- videoPlaying: refVideoPlayer.current !== null ? !refVideoPlayer.current.paused : false,
831
- videoUnplayed: videoUnplayed,
832
- videoCurrentVolume: videoCurrentVolume,
833
- videoIsMuted: videoIsMuted,
834
- setVolume: setVolume,
835
- isHidden: (mouseInactive || videoUnplayed) && !videoEnded,
836
- isMobile: isMobile,
837
- tracksAvailable: tracks !== undefined,
838
- togglePlayPause: togglePlayPause,
839
- setSeek: setSeek,
840
- toggleMute: toggleMute,
841
- toggleFullscreen: toggleFullscreen,
842
- videoIsFullscreen: videoIsFullscreen,
843
- setTextTracks: setTextTracks,
844
- selectedTextTrack: selectedTextTrack,
845
- resetInactivityTimer: resetInactivityTimer,
846
- videoQuality: videoQuality,
847
- setVideoQuality: setVideoQuality,
848
- qualityMenuOpen: qualityMenuOpen,
849
- setQualityMenuOpen: setQualityMenuOpen,
850
- captionsMenuOpen: captionsMenuOpen,
851
- setCaptionsMenuOpen: setCaptionsMenuOpen,
852
- clearInactivityTimer: clearInactivityTimer,
853
- copy: copy,
854
- compactModeThreshold: playerOptions.compactModeThreshold,
855
- videoPlayerWidth: videoPlayerWidth,
856
- onMouseOver: () => setMouseOnControlBar(true),
857
- onMouseOut: () => setMouseOnControlBar(false),
858
- onFocus: () => {},
859
- onBlur: () => {}
860
- }), /*#__PURE__*/_jsx("span", {
861
- tabIndex: "-1",
862
- ref: refKeyboardInstructions,
863
- "aria-label": videoText[copy].videoPlayer,
864
- role: "note"
865
- })]
866
- });
867
- };
868
- Video.propTypes = {
869
- ...selectedSystemPropTypes,
870
- /**
871
- * An array of objects that defines each video file. See the "Basic Usage" section for more information.
872
- */
873
- sources: PropTypes.arrayOf(PropTypes.shape({
874
- /** A path to a video file */
875
- source: PropTypes.string.isRequired,
876
- /** The video's MIME type (example: `video/mp4`) */
877
- mediaType: PropTypes.string.isRequired,
878
- /** The label to be given to this file in the quality selector (example: `1080p`) */
879
- qualityName: PropTypes.string.isRequired,
880
- /** A number indicating the video's quality, with 1 being the best, and the number increasing from there as quality degrades */
881
- qualityRank: PropTypes.number.isRequired,
882
- /** A boolean that defines its source as a fallback for another source with the same `qualityRank` */
883
- isFallback: PropTypes.bool
884
- })).isRequired,
885
- /**
886
- * A path of the image that will be displayed on the video's splash screen.
887
- */
888
- posterSrc: PropTypes.string.isRequired,
889
- /**
890
- * An array of objects that defines each caption file. See the "Basic Usage" section for more information.
891
- */
892
- tracks: PropTypes.arrayOf(PropTypes.shape({
893
- /** A path to the track file */
894
- source: PropTypes.string.isRequired,
895
- /** The name of the track file as it will appear in the "Captions" dialogue */
896
- label: PropTypes.string.isRequired,
897
- /** The track's file type, typically one of "subtitles", "captions", or "descriptions". See [MDN's documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/track#Attributes) for more information on these types */
898
- kind: PropTypes.string.isRequired,
899
- /** The language of the track file represented as a ISO 639-1 language code */
900
- language: PropTypes.string.isRequired
901
- })),
902
- /**
903
- * The video's default volume, defined from 1 to 100. Please use the `beginMuted` prop to have the video start silenced.
904
- */
905
- defaultVolume: PropTypes.number,
906
- /**
907
- * Defines if the video should start muted.
908
- */
909
- beginMuted: PropTypes.bool,
910
- /**
911
- * The default quality level if the user is on mobile. See the `sources` prop for available quality levels.
912
- */
913
- defaultMobileQuality: PropTypes.number,
914
- /**
915
- * The default quality level if the user is on desktop. See the `sources` prop for available quality levels.
916
- */
917
- defaultDesktopQuality: PropTypes.number,
918
- /**
919
- * The video player UI's language as an ISO language code. It currently supports English and French.
920
- */
921
- copy: PropTypes.oneOf(['en', 'fr']).isRequired,
922
- /**
923
- * Sets the `video` tag's `crossorigin` mode. Please note that content loaded without CORS approval may be insecure.
924
- * @since 1.1.0
925
- */
926
- crossOrigin: PropTypes.oneOf(['anonymous', 'use-credentials']),
927
- /**
928
- * Disables the control bar during playback and reduces the amount of time until the UI hides itself.
929
- * For special approved internal uses only.
930
- * @since 1.2.0
931
- */
932
- simpleMode: PropTypes.bool,
933
- /**
934
- * Renders a gainsboro coloured border around the video. Used to seperate the video from the rest of the page if the video's background is the same colour as the container's.
935
- * @since 1.2.0
936
- */
937
- videoBorder: PropTypes.bool,
938
- /**
939
- * A callback function that fires when a customer interacts with Video.
940
- * When using `analyticsTracking`, `videoTitle` must also be defined.
941
- *
942
- * When invoked, your callback function returns an object containing three keys (see below).
943
- * @since 1.3.0
944
- *
945
- * @param {Object} analyticsObject Contains video data based on customer interactions
946
- * @param {string} analyticsObject.name Always 'video tracking'
947
- * @param {string} analyticsObject.action Contains the latest customer action
948
- * @param {string} analyticsObject.details The name of the video based on the `videoTitle` prop
949
- */
950
- analyticsTracking: PropTypes.func,
951
- /**
952
- * The title of the video being rendered. This is used for analytics purposes in conjunction with `analyticsTracking`.
953
- * @since 1.3.0
954
- */
955
- videoTitle: PropTypes.string,
956
- tokens: getTokensPropType('Video'),
957
- variant: variantProp.propType
958
- };
959
- export default Video;