@telus-uds/components-web 1.7.0 → 1.9.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 (220) hide show
  1. package/.eslintignore +2 -0
  2. package/.vscode/settings.json +7 -0
  3. package/CHANGELOG.md +39 -2
  4. package/lib/Autocomplete/Autocomplete.js +393 -0
  5. package/lib/Autocomplete/Loading.js +51 -0
  6. package/lib/Autocomplete/Suggestions.js +81 -0
  7. package/lib/Autocomplete/constants.js +19 -0
  8. package/lib/Autocomplete/dictionary.js +19 -0
  9. package/lib/Autocomplete/index.js +13 -0
  10. package/lib/BlockQuote/BlockQuote.js +173 -0
  11. package/lib/BlockQuote/index.js +13 -0
  12. package/lib/Callout/Callout.js +3 -0
  13. package/lib/Card/Card.js +180 -0
  14. package/lib/Card/CardContent.js +110 -0
  15. package/lib/Card/CardFooter.js +98 -0
  16. package/lib/Card/index.js +13 -0
  17. package/lib/Countdown/Countdown.js +189 -0
  18. package/lib/Countdown/Segment.js +111 -0
  19. package/lib/Countdown/constants.js +14 -0
  20. package/lib/Countdown/dictionary.js +29 -0
  21. package/lib/Countdown/index.js +13 -0
  22. package/lib/Countdown/types.js +39 -0
  23. package/lib/Countdown/useCountdown.js +40 -0
  24. package/lib/IconButton/IconButton.js +70 -0
  25. package/lib/IconButton/index.js +13 -0
  26. package/lib/Listbox/GroupControl.js +94 -0
  27. package/lib/Listbox/Listbox.js +164 -0
  28. package/lib/Listbox/ListboxGroup.js +129 -0
  29. package/lib/Listbox/ListboxItem.js +137 -0
  30. package/lib/Listbox/ListboxOverlay.js +89 -0
  31. package/lib/Listbox/PressableItem.js +149 -0
  32. package/lib/Listbox/index.js +13 -0
  33. package/lib/Modal/ModalContent.js +11 -4
  34. package/lib/NavigationBar/resolveItemSelection.js +24 -0
  35. package/lib/OptimizeImage/OptimizeImage.js +127 -0
  36. package/lib/OptimizeImage/index.js +13 -0
  37. package/lib/OptimizeImage/utils/getFallbackUrl.js +18 -0
  38. package/lib/OptimizeImage/utils/getOptimizedUrl.js +32 -0
  39. package/lib/OptimizeImage/utils/hasWebpSupport.js +38 -0
  40. package/lib/OptimizeImage/utils/index.js +31 -0
  41. package/lib/OptimizeImage/utils/isSvgUrl.js +10 -0
  42. package/lib/QuantitySelector/QuantitySelector.js +253 -0
  43. package/lib/QuantitySelector/dictionary.js +33 -0
  44. package/lib/QuantitySelector/index.js +13 -0
  45. package/lib/QuantitySelector/styles.js +40 -0
  46. package/lib/StoryCard/StoryCard.js +244 -0
  47. package/lib/StoryCard/index.js +13 -0
  48. package/lib/TermsAndConditions/ExpandCollapse.js +141 -0
  49. package/lib/TermsAndConditions/TermsAndConditions.js +221 -0
  50. package/lib/TermsAndConditions/dictionary.js +19 -0
  51. package/lib/TermsAndConditions/index.js +15 -0
  52. package/lib/Testimonial/Testimonial.js +226 -0
  53. package/lib/Testimonial/index.js +13 -0
  54. package/lib/Video/ControlBar/ControlBar.js +315 -0
  55. package/lib/Video/ControlBar/Controls/VideoButton/VideoButton.js +91 -0
  56. package/lib/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +186 -0
  57. package/lib/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +221 -0
  58. package/lib/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +213 -0
  59. package/lib/Video/MiddleControlButton/MiddleControlButton.js +89 -0
  60. package/lib/Video/Video.js +1072 -0
  61. package/lib/Video/index.js +13 -0
  62. package/lib/Video/videoText.js +62 -0
  63. package/lib/WebVideo/WebVideo.js +170 -0
  64. package/lib/WebVideo/index.js +13 -0
  65. package/lib/baseExports.js +0 -12
  66. package/lib/index.js +118 -1
  67. package/lib/shared/VideoSplash/SplashButton/SplashButton.js +102 -0
  68. package/lib/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +234 -0
  69. package/lib/shared/VideoSplash/VideoSplash.js +86 -0
  70. package/lib/shared/VideoSplash/helpers.js +38 -0
  71. package/lib/utils/index.js +8 -0
  72. package/lib/utils/useOverlaidPosition.js +246 -0
  73. package/lib-module/Autocomplete/Autocomplete.js +369 -0
  74. package/lib-module/Autocomplete/Loading.js +38 -0
  75. package/lib-module/Autocomplete/Suggestions.js +64 -0
  76. package/lib-module/Autocomplete/constants.js +5 -0
  77. package/lib-module/Autocomplete/dictionary.js +12 -0
  78. package/lib-module/Autocomplete/index.js +2 -0
  79. package/lib-module/BlockQuote/BlockQuote.js +156 -0
  80. package/lib-module/BlockQuote/index.js +2 -0
  81. package/lib-module/Callout/Callout.js +3 -0
  82. package/lib-module/Card/Card.js +158 -0
  83. package/lib-module/Card/CardContent.js +92 -0
  84. package/lib-module/Card/CardFooter.js +80 -0
  85. package/lib-module/Card/index.js +2 -0
  86. package/lib-module/Countdown/Countdown.js +165 -0
  87. package/lib-module/Countdown/Segment.js +94 -0
  88. package/lib-module/Countdown/constants.js +4 -0
  89. package/lib-module/Countdown/dictionary.js +22 -0
  90. package/lib-module/Countdown/index.js +2 -0
  91. package/lib-module/Countdown/types.js +23 -0
  92. package/lib-module/Countdown/useCountdown.js +32 -0
  93. package/lib-module/IconButton/IconButton.js +52 -0
  94. package/lib-module/IconButton/index.js +2 -0
  95. package/lib-module/Listbox/GroupControl.js +80 -0
  96. package/lib-module/Listbox/Listbox.js +142 -0
  97. package/lib-module/Listbox/ListboxGroup.js +106 -0
  98. package/lib-module/Listbox/ListboxItem.js +112 -0
  99. package/lib-module/Listbox/ListboxOverlay.js +68 -0
  100. package/lib-module/Listbox/PressableItem.js +128 -0
  101. package/lib-module/Listbox/index.js +2 -0
  102. package/lib-module/Modal/ModalContent.js +10 -4
  103. package/lib-module/NavigationBar/resolveItemSelection.js +16 -0
  104. package/lib-module/OptimizeImage/OptimizeImage.js +106 -0
  105. package/lib-module/OptimizeImage/index.js +2 -0
  106. package/lib-module/OptimizeImage/utils/getFallbackUrl.js +8 -0
  107. package/lib-module/OptimizeImage/utils/getOptimizedUrl.js +22 -0
  108. package/lib-module/OptimizeImage/utils/hasWebpSupport.js +32 -0
  109. package/lib-module/OptimizeImage/utils/index.js +4 -0
  110. package/lib-module/OptimizeImage/utils/isSvgUrl.js +3 -0
  111. package/lib-module/QuantitySelector/QuantitySelector.js +232 -0
  112. package/lib-module/QuantitySelector/dictionary.js +26 -0
  113. package/lib-module/QuantitySelector/index.js +2 -0
  114. package/lib-module/QuantitySelector/styles.js +21 -0
  115. package/lib-module/StoryCard/StoryCard.js +220 -0
  116. package/lib-module/StoryCard/index.js +2 -0
  117. package/lib-module/TermsAndConditions/ExpandCollapse.js +120 -0
  118. package/lib-module/TermsAndConditions/TermsAndConditions.js +193 -0
  119. package/lib-module/TermsAndConditions/dictionary.js +12 -0
  120. package/lib-module/TermsAndConditions/index.js +1 -0
  121. package/lib-module/Testimonial/Testimonial.js +204 -0
  122. package/lib-module/Testimonial/index.js +2 -0
  123. package/lib-module/Video/ControlBar/ControlBar.js +292 -0
  124. package/lib-module/Video/ControlBar/Controls/VideoButton/VideoButton.js +74 -0
  125. package/lib-module/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +167 -0
  126. package/lib-module/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +201 -0
  127. package/lib-module/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +193 -0
  128. package/lib-module/Video/MiddleControlButton/MiddleControlButton.js +72 -0
  129. package/lib-module/Video/Video.js +1042 -0
  130. package/lib-module/Video/index.js +2 -0
  131. package/lib-module/Video/videoText.js +55 -0
  132. package/lib-module/WebVideo/WebVideo.js +144 -0
  133. package/lib-module/WebVideo/index.js +2 -0
  134. package/lib-module/baseExports.js +1 -1
  135. package/lib-module/index.js +13 -0
  136. package/lib-module/shared/VideoSplash/SplashButton/SplashButton.js +85 -0
  137. package/lib-module/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +216 -0
  138. package/lib-module/shared/VideoSplash/VideoSplash.js +65 -0
  139. package/lib-module/shared/VideoSplash/helpers.js +23 -0
  140. package/lib-module/utils/index.js +2 -1
  141. package/lib-module/utils/useOverlaidPosition.js +235 -0
  142. package/package.json +7 -5
  143. package/src/Autocomplete/Autocomplete.jsx +354 -0
  144. package/src/Autocomplete/Loading.jsx +18 -0
  145. package/src/Autocomplete/Suggestions.jsx +52 -0
  146. package/src/Autocomplete/constants.js +6 -0
  147. package/src/Autocomplete/dictionary.js +12 -0
  148. package/src/Autocomplete/index.js +3 -0
  149. package/src/BlockQuote/BlockQuote.jsx +130 -0
  150. package/src/BlockQuote/index.js +3 -0
  151. package/src/Callout/Callout.jsx +1 -1
  152. package/src/Card/Card.jsx +170 -0
  153. package/src/Card/CardContent.jsx +88 -0
  154. package/src/Card/CardFooter.jsx +70 -0
  155. package/src/Card/index.js +3 -0
  156. package/src/Countdown/Countdown.jsx +144 -0
  157. package/src/Countdown/Segment.jsx +69 -0
  158. package/src/Countdown/constants.js +4 -0
  159. package/src/Countdown/dictionary.js +22 -0
  160. package/src/Countdown/index.js +3 -0
  161. package/src/Countdown/types.js +23 -0
  162. package/src/Countdown/useCountdown.js +34 -0
  163. package/src/IconButton/IconButton.jsx +46 -0
  164. package/src/IconButton/index.js +3 -0
  165. package/src/Listbox/GroupControl.jsx +65 -0
  166. package/src/Listbox/Listbox.jsx +148 -0
  167. package/src/Listbox/ListboxGroup.jsx +110 -0
  168. package/src/Listbox/ListboxItem.jsx +101 -0
  169. package/src/Listbox/ListboxOverlay.jsx +71 -0
  170. package/src/Listbox/PressableItem.jsx +121 -0
  171. package/src/Listbox/index.js +3 -0
  172. package/src/Modal/ModalContent.jsx +8 -4
  173. package/src/NavigationBar/resolveItemSelection.js +11 -0
  174. package/src/OptimizeImage/OptimizeImage.jsx +131 -0
  175. package/src/OptimizeImage/index.js +3 -0
  176. package/src/OptimizeImage/utils/getFallbackUrl.js +9 -0
  177. package/src/OptimizeImage/utils/getOptimizedUrl.js +30 -0
  178. package/src/OptimizeImage/utils/hasWebpSupport.js +33 -0
  179. package/src/OptimizeImage/utils/index.js +5 -0
  180. package/src/OptimizeImage/utils/isSvgUrl.js +3 -0
  181. package/src/QuantitySelector/QuantitySelector.jsx +245 -0
  182. package/src/QuantitySelector/dictionary.js +27 -0
  183. package/src/QuantitySelector/index.js +3 -0
  184. package/src/QuantitySelector/styles.js +83 -0
  185. package/src/StoryCard/StoryCard.jsx +198 -0
  186. package/src/StoryCard/index.js +3 -0
  187. package/src/TermsAndConditions/ExpandCollapse.jsx +106 -0
  188. package/src/TermsAndConditions/TermsAndConditions.jsx +161 -0
  189. package/src/TermsAndConditions/dictionary.js +12 -0
  190. package/src/TermsAndConditions/index.js +1 -0
  191. package/src/Testimonial/Testimonial.jsx +169 -0
  192. package/src/Testimonial/index.js +3 -0
  193. package/src/Video/ControlBar/ControlBar.jsx +261 -0
  194. package/src/Video/ControlBar/Controls/VideoButton/VideoButton.jsx +61 -0
  195. package/src/Video/ControlBar/Controls/VideoMenu/VideoMenu.jsx +159 -0
  196. package/src/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.jsx +185 -0
  197. package/src/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.jsx +184 -0
  198. package/src/Video/MiddleControlButton/MiddleControlButton.jsx +64 -0
  199. package/src/Video/Video.jsx +988 -0
  200. package/src/Video/index.js +3 -0
  201. package/src/Video/videoText.js +58 -0
  202. package/src/WebVideo/WebVideo.jsx +131 -0
  203. package/src/WebVideo/index.js +3 -0
  204. package/src/baseExports.js +0 -2
  205. package/src/index.js +13 -0
  206. package/src/shared/VideoSplash/SplashButton/SplashButton.jsx +64 -0
  207. package/src/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.jsx +128 -0
  208. package/src/shared/VideoSplash/VideoSplash.jsx +50 -0
  209. package/src/shared/VideoSplash/helpers.js +27 -0
  210. package/src/utils/index.js +10 -1
  211. package/src/utils/useOverlaidPosition.js +226 -0
  212. package/types/Autocomplete.d.ts +32 -0
  213. package/types/Card.d.ts +45 -0
  214. package/types/ControlBar.d.ts +59 -0
  215. package/types/MiddleControlButton.d.ts +15 -0
  216. package/types/Video.d.ts +39 -0
  217. package/types/VideoButton.d.ts +14 -0
  218. package/types/VideoMenu.d.ts +16 -0
  219. package/types/VideoProgressBar.d.ts +17 -0
  220. package/types/VolumeSlider.d.ts +20 -0
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
13
+
14
+ var _componentsBase = require("@telus-uds/components-base");
15
+
16
+ var _helpers = require("../helpers");
17
+
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ const ButtonContainer = /*#__PURE__*/_styledComponents.default.button.withConfig({
23
+ displayName: "SplashButtonWithDetails__ButtonContainer",
24
+ componentId: "components-web__sc-1edwy9o-0"
25
+ })({
26
+ background: 'none',
27
+ border: 0,
28
+ position: 'absolute',
29
+ width: '100%',
30
+ height: '100%',
31
+ padding: 0,
32
+ cursor: 'pointer'
33
+ });
34
+
35
+ const ButtonContent = /*#__PURE__*/_styledComponents.default.div.withConfig({
36
+ displayName: "SplashButtonWithDetails__ButtonContent",
37
+ componentId: "components-web__sc-1edwy9o-1"
38
+ })({
39
+ background: _ref => {
40
+ let {
41
+ buttonBackground
42
+ } = _ref;
43
+ return buttonBackground;
44
+ },
45
+ border: _ref2 => {
46
+ let {
47
+ buttonBorderColor
48
+ } = _ref2;
49
+ return `1px solid ${buttonBorderColor}`;
50
+ },
51
+ borderRadius: _ref3 => {
52
+ let {
53
+ buttonRadius
54
+ } = _ref3;
55
+ return `${buttonRadius}px`;
56
+ },
57
+ position: 'absolute',
58
+ left: _ref4 => {
59
+ let {
60
+ buttonLeftPosition
61
+ } = _ref4;
62
+ return `${buttonLeftPosition}px`;
63
+ },
64
+ bottom: _ref5 => {
65
+ let {
66
+ buttonBottomPosition
67
+ } = _ref5;
68
+ return `${buttonBottomPosition}px`;
69
+ },
70
+ boxSizing: 'border-box',
71
+ display: 'flex',
72
+ alignItems: 'center',
73
+ minHeight: _ref6 => {
74
+ let {
75
+ buttonMinHeight
76
+ } = _ref6;
77
+ return `${buttonMinHeight}px`;
78
+ },
79
+ paddingRight: _ref7 => {
80
+ let {
81
+ buttonPaddingLeft
82
+ } = _ref7;
83
+ return `${buttonPaddingLeft}px`;
84
+ },
85
+ paddingLeft: _ref8 => {
86
+ let {
87
+ buttonPaddingRight
88
+ } = _ref8;
89
+ return `${buttonPaddingRight}px`;
90
+ },
91
+ transition: 'background 0.2s ease-in-out',
92
+ [`${ButtonContainer}:hover &`]: {
93
+ background: _ref9 => {
94
+ let {
95
+ buttonContentChildrenBackground
96
+ } = _ref9;
97
+ return buttonContentChildrenBackground;
98
+ }
99
+ }
100
+ });
101
+
102
+ const PlayIconContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
103
+ displayName: "SplashButtonWithDetails__PlayIconContainer",
104
+ componentId: "components-web__sc-1edwy9o-2"
105
+ })({
106
+ display: 'flex',
107
+ justifyContent: 'center',
108
+ alignItems: 'center',
109
+ width: 32,
110
+ height: 32,
111
+ background: _ref10 => {
112
+ let {
113
+ playIconContainerBackground
114
+ } = _ref10;
115
+ return playIconContainerBackground ?? 'none';
116
+ },
117
+ borderRadius: '100%',
118
+ transition: 'background 0.2s ease-in-out'
119
+ });
120
+
121
+ const DetailsContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
122
+ displayName: "SplashButtonWithDetails__DetailsContainer",
123
+ componentId: "components-web__sc-1edwy9o-3"
124
+ })({
125
+ display: 'flex',
126
+ flexDirection: 'column',
127
+ alignItems: 'flex-start',
128
+ paddingLeft: _ref11 => {
129
+ let {
130
+ detailsContainerPadding
131
+ } = _ref11;
132
+ return `${detailsContainerPadding}px`;
133
+ }
134
+ });
135
+
136
+ const selectPlayIconContainerTokens = _ref12 => {
137
+ let {
138
+ playIconContainerBackground
139
+ } = _ref12;
140
+ return {
141
+ playIconContainerBackground
142
+ };
143
+ };
144
+
145
+ const selectDetailsContainerTokens = _ref13 => {
146
+ let {
147
+ detailsContainerPadding
148
+ } = _ref13;
149
+ return {
150
+ detailsContainerPadding
151
+ };
152
+ };
153
+
154
+ const selectButtonContentTokens = _ref14 => {
155
+ let {
156
+ buttonBackground,
157
+ buttonBorderColor,
158
+ buttonRadius,
159
+ buttonLeftPosition,
160
+ buttonBottomPosition,
161
+ buttonMinHeight,
162
+ buttonPaddingLeft,
163
+ buttonPaddingRight
164
+ } = _ref14;
165
+ return {
166
+ buttonBackground,
167
+ buttonBorderColor,
168
+ buttonRadius,
169
+ buttonLeftPosition,
170
+ buttonBottomPosition,
171
+ buttonMinHeight,
172
+ buttonPaddingLeft,
173
+ buttonPaddingRight
174
+ };
175
+ };
176
+
177
+ const SplashButtonWithDetails = _ref15 => {
178
+ let {
179
+ label,
180
+ tokens,
181
+ variant,
182
+ copy,
183
+ videoLength
184
+ } = _ref15;
185
+ const {
186
+ buttonContentChildrenBackground
187
+ } = (0, _componentsBase.useThemeTokens)('SplashButtonWithDetails', tokens, variant, {
188
+ hover: true
189
+ });
190
+ const {
191
+ playIcon: PlayIcon,
192
+ playIconColor,
193
+ ...themeTokens
194
+ } = (0, _componentsBase.useThemeTokens)('SplashButtonWithDetails', tokens, variant);
195
+ const mappedVideoLength = (0, _helpers.getTimestamp)(videoLength, copy);
196
+ const ariaLabel = (0, _helpers.getAriaLabel)(mappedVideoLength, copy);
197
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(ButtonContainer, {
198
+ "aria-label": ariaLabel,
199
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(ButtonContent, { ...selectButtonContentTokens(themeTokens),
200
+ buttonContentChildrenBackground: buttonContentChildrenBackground,
201
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(PlayIconContainer, { ...selectPlayIconContainerTokens(themeTokens),
202
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(PlayIcon, {
203
+ size: 13,
204
+ color: playIconColor
205
+ })
206
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(DetailsContainer, { ...selectDetailsContainerTokens(themeTokens),
207
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
208
+ variant: {
209
+ bold: true
210
+ },
211
+ children: label
212
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
213
+ variant: {
214
+ colour: 'secondary'
215
+ /* TODO: this is not the same color as in designs */
216
+ ,
217
+ size: 'micro'
218
+ },
219
+ children: mappedVideoLength.timestamp
220
+ })]
221
+ })]
222
+ })
223
+ });
224
+ };
225
+
226
+ SplashButtonWithDetails.propTypes = {
227
+ label: _propTypes.default.string,
228
+ tokens: _propTypes.default.object,
229
+ variant: _propTypes.default.object,
230
+ videoLength: _propTypes.default.number,
231
+ copy: _propTypes.default.oneOf(['en', 'fr'])
232
+ };
233
+ var _default = SplashButtonWithDetails;
234
+ exports.default = _default;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
13
+
14
+ var _componentsBase = require("@telus-uds/components-base");
15
+
16
+ var _systemConstants = require("@telus-uds/system-constants");
17
+
18
+ var _SplashButton = _interopRequireDefault(require("./SplashButton/SplashButton"));
19
+
20
+ var _SplashButtonWithDetails = _interopRequireDefault(require("./SplashButtonWithDetails/SplashButtonWithDetails"));
21
+
22
+ var _videoText = _interopRequireDefault(require("../../Video/videoText"));
23
+
24
+ var _utils = require("../../utils");
25
+
26
+ var _jsxRuntime = require("react/jsx-runtime");
27
+
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+
30
+ const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
31
+
32
+ const SplashBackground = /*#__PURE__*/_styledComponents.default.div.withConfig({
33
+ displayName: "VideoSplash__SplashBackground",
34
+ componentId: "components-web__sc-1ejxt6-0"
35
+ })(_ref => {
36
+ let {
37
+ videoPoster
38
+ } = _ref;
39
+ return {
40
+ backgroundImage: `url(${videoPoster})`,
41
+ backgroundSize: 'cover',
42
+ backgroundPosition: 'center',
43
+ position: 'absolute',
44
+ top: 0,
45
+ width: '100%',
46
+ height: '100%',
47
+ // fixes vertical alignment on IE 11
48
+ cursor: 'pointer'
49
+ };
50
+ });
51
+
52
+ const VideoSplash = _ref2 => {
53
+ let {
54
+ poster,
55
+ videoLength,
56
+ simpleMode,
57
+ copy = 'en',
58
+ onClick,
59
+ ...rest
60
+ } = _ref2;
61
+ const viewport = (0, _componentsBase.useViewport)();
62
+ const showDetails = !simpleMode && viewport !== _systemConstants.viewports.xs;
63
+ const label = _videoText.default[copy].watch;
64
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(SplashBackground, { ...selectProps(rest),
65
+ onClick: onClick,
66
+ videoPoster: poster,
67
+ children: showDetails ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_SplashButtonWithDetails.default, {
68
+ videoLength: videoLength,
69
+ copy: copy,
70
+ label: label
71
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_SplashButton.default, {
72
+ videoLength: videoLength,
73
+ copy: copy
74
+ })
75
+ });
76
+ };
77
+
78
+ VideoSplash.propTypes = { ...selectedSystemPropTypes,
79
+ onClick: _propTypes.default.func,
80
+ poster: _propTypes.default.string,
81
+ videoLength: _propTypes.default.number.isRequired,
82
+ simpleMode: _propTypes.default.bool,
83
+ copy: _propTypes.default.oneOf(['en', 'fr'])
84
+ };
85
+ var _default = VideoSplash;
86
+ exports.default = _default;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getTimestamp = exports.getAriaLabel = void 0;
7
+
8
+ var _videoText = _interopRequireDefault(require("../../Video/videoText"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const getTimestamp = (videoLength, copy) => {
13
+ const minutes = Math.floor(videoLength / 60);
14
+ const seconds = Math.ceil(videoLength % 60);
15
+ const minutesText = minutes > 0 ? `${minutes}min ` : '';
16
+ const secondsText = `${seconds}${copy === 'fr' ? 's' : 'sec'}`;
17
+ const timestamp = `${minutesText}${secondsText}`;
18
+ return {
19
+ minutes,
20
+ seconds,
21
+ timestamp
22
+ };
23
+ };
24
+
25
+ exports.getTimestamp = getTimestamp;
26
+
27
+ const getAriaLabel = (timestamp, copy) => {
28
+ const {
29
+ minutes,
30
+ seconds
31
+ } = timestamp;
32
+ const text = _videoText.default[copy];
33
+ const minutesText = `${minutes} ${minutes !== 1 ? text.minutes : text.minute}`;
34
+ const secondsText = `${seconds} ${seconds !== 1 ? text.seconds : text.second}`;
35
+ return text.ariaLabel.replace('{minutes}', minutesText).replace('{seconds}', secondsText);
36
+ };
37
+
38
+ exports.getAriaLabel = getAriaLabel;
@@ -27,6 +27,12 @@ Object.defineProperty(exports, "transformGradient", {
27
27
  return _transforms.transformGradient;
28
28
  }
29
29
  });
30
+ Object.defineProperty(exports, "useOverlaidPosition", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _useOverlaidPosition.default;
34
+ }
35
+ });
30
36
  Object.defineProperty(exports, "useTypographyTheme", {
31
37
  enumerable: true,
32
38
  get: function () {
@@ -52,4 +58,6 @@ var _media = _interopRequireDefault(require("./media"));
52
58
 
53
59
  var _renderStructuredContent = _interopRequireDefault(require("./renderStructuredContent"));
54
60
 
61
+ var _useOverlaidPosition = _interopRequireDefault(require("./useOverlaidPosition"));
62
+
55
63
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,246 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var _Dimensions = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Dimensions"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ // TODO: add react-native as a peer dep and support native apps too.
15
+ // That requires some fiddling with Allium repo storybook config, babel, etc,
16
+ // unless ADS gets merged back into UDS monorepo.
17
+ const adjustHorizontalToFit = (initialOffset, windowWidth, sourceWidth) => {
18
+ const offset = Math.max(0, initialOffset);
19
+ const otherEdgeOverflow = Math.max(0, offset + sourceWidth - windowWidth);
20
+ const tooWideBy = Math.max(0, otherEdgeOverflow - offset);
21
+ const adjusted = {
22
+ offset: Math.max(0, offset - otherEdgeOverflow)
23
+ };
24
+ if (tooWideBy) adjusted.width = Math.max(0, sourceWidth - tooWideBy);
25
+ return adjusted;
26
+ };
27
+
28
+ const getPosition = _ref => {
29
+ let {
30
+ edge,
31
+ fromEdge,
32
+ sourceSize
33
+ } = _ref;
34
+
35
+ switch (edge) {
36
+ case 'near':
37
+ return fromEdge;
38
+
39
+ case 'mid':
40
+ return fromEdge + sourceSize / 2;
41
+
42
+ case 'far':
43
+ return fromEdge + sourceSize;
44
+
45
+ default:
46
+ return 0;
47
+ }
48
+ };
49
+
50
+ const getEdgeType = (align, alignSide) => {
51
+ const alignTo = align[alignSide];
52
+ const edge = ['center', 'middle'].includes(alignTo) && 'mid' || (alignSide === alignTo ? 'near' : 'far');
53
+ return edge;
54
+ };
55
+ /**
56
+ * Based on UDS's private getTooltipPosition but generalised.
57
+ *
58
+ * Used for absolute positioning of the tooltip. Since the tooltip is always centered relatively
59
+ * to the source (button) and we have a limited set of positions, an easy and consistent way
60
+ * of positioning it is to check all of the possible positions and pick one that will be rendered
61
+ * within the window bounds. This way we can also rely on the tooltip being actually rendered
62
+ * before it is shown, which makes it account for the width being limiting in styles, custom font
63
+ * rendering, etc.
64
+ */
65
+
66
+
67
+ function getOverlaidPosition(_ref2) {
68
+ let {
69
+ sourceLayout,
70
+ targetDimensions,
71
+ windowDimensions,
72
+ offsets = {},
73
+ align
74
+ } = _ref2;
75
+ // Web-only: this will be difficult to mimic on native because there's no global scroll position.
76
+ // TODO: wire something in e.g. a scroll ref accessible from a provider included in Allium provider
77
+ // that can be passed to the appropriate ScrollView?
78
+ const {
79
+ scrollX = 0,
80
+ scrollY = 0
81
+ } = typeof window === 'object' ? window : {}; // Will have top, bottom, left and/or right offsets depending on `align`
82
+
83
+ const positioning = {};
84
+ if (align.top) positioning.top = getPosition({
85
+ edge: getEdgeType(align, 'top'),
86
+ fromEdge: sourceLayout.y + scrollY + (offsets.vertical ?? 0),
87
+ sourceSize: sourceLayout.height
88
+ });
89
+ if (align.middle) positioning.top = getPosition({
90
+ edge: getEdgeType(align, 'middle'),
91
+ fromEdge: sourceLayout.y + scrollY + (offsets.vertical ?? 0) - targetDimensions.height / 2,
92
+ sourceSize: sourceLayout.height
93
+ });
94
+ if (align.bottom) positioning.bottom = getPosition({
95
+ edge: getEdgeType(align, 'bottom'),
96
+ fromEdge: windowDimensions.height - (sourceLayout.y + scrollY + sourceLayout.height - (offsets.vertical ?? 0)),
97
+ sourceSize: sourceLayout.height
98
+ });
99
+ if (align.left) positioning.left = getPosition({
100
+ edge: getEdgeType(align, 'left'),
101
+ fromEdge: sourceLayout.x + scrollX + (offsets.horizontal ?? 0),
102
+ sourceSize: sourceLayout.width
103
+ });
104
+ if (align.center) positioning.left = getPosition({
105
+ edge: getEdgeType(align, 'center'),
106
+ fromEdge: sourceLayout.x + scrollX + (offsets.horizontal ?? 0) - targetDimensions.width / 2,
107
+ sourceSize: sourceLayout.width
108
+ });
109
+ if (align.right) positioning.right = getPosition({
110
+ edge: getEdgeType(align, 'right'),
111
+ fromEdge: windowDimensions.width - (sourceLayout.x + scrollX + sourceLayout.width - (offsets.horizontal ?? 0)),
112
+ sourceSize: sourceLayout.width
113
+ });
114
+
115
+ if (!(align.left && align.right)) {
116
+ // Check if the position and/or width need adjusting to fit on the screen
117
+ const side = align.right ? 'right' : 'left';
118
+ const adjusted = adjustHorizontalToFit(positioning[side], windowDimensions.width, sourceLayout.width);
119
+ if (typeof adjusted.width === 'number') positioning.width = adjusted.width;
120
+
121
+ if (typeof adjusted.offset === 'number') {
122
+ positioning[side] = adjusted.offset;
123
+ }
124
+ }
125
+
126
+ return positioning;
127
+ }
128
+ /**
129
+ * Positions an element in a modal or portal so that it appears tooltip-like below the
130
+ * target element.
131
+ *
132
+ * @TODO - add support for positioning other than 'below' like UDS's tooltip (this is not
133
+ * a small task because UDS's tooltip logic only really works for short text - it might be
134
+ * better to use a third-party library).
135
+ */
136
+
137
+
138
+ const useOverlaidPosition = _ref3 => {
139
+ let {
140
+ isShown = false,
141
+ offsets,
142
+ // By default, align the overlaid target's `top` to the bottom of the source, and center horizontally.
143
+ align = {
144
+ center: 'center',
145
+ top: 'bottom'
146
+ }
147
+ } = _ref3;
148
+ // Element in main document flow that the targetRef element is positioned around
149
+ const sourceRef = (0, _react.useRef)(null);
150
+ const [sourceLayout, setSourceLayout] = (0, _react.useState)(null); // Element in a modal or portal overlay positioned to appear adjacent to sourceRef
151
+
152
+ const targetRef = (0, _react.useRef)(null);
153
+ const [targetDimensions, setTargetDimensions] = (0, _react.useState)(null);
154
+ const [windowDimensions, setWindowDimensions] = (0, _react.useState)(null);
155
+ const onTargetLayout = (0, _react.useCallback)(_ref4 => {
156
+ let {
157
+ nativeEvent: {
158
+ layout: {
159
+ width,
160
+ height
161
+ }
162
+ }
163
+ } = _ref4;
164
+ // NOTE: UDS's Tooltip logic injects some additional width to allow for antialiasing etc of text,
165
+ // avoiding adding unnecessary line breaks to text that is slightly wider than it thinks it is.
166
+ // That is probably something specific to text tooltips that doesn't belong in a generic hook.
167
+ setTargetDimensions(previousDimensions => {
168
+ // Re-render on first non-zero width / height: avoid infinite loops on changes, or mispositioning
169
+ // if user scrolls while a slidedown animation is changing the height and recalculating position.
170
+ if (!previousDimensions && width && height) {
171
+ return {
172
+ width,
173
+ height
174
+ };
175
+ }
176
+
177
+ return previousDimensions;
178
+ });
179
+ }, []);
180
+ const readyToShow = Boolean(isShown && sourceRef.current);
181
+ (0, _react.useEffect)(() => {
182
+ const handleDimensionsChange = _ref5 => {
183
+ var _sourceRef$current;
184
+
185
+ let {
186
+ window
187
+ } = _ref5;
188
+ (_sourceRef$current = sourceRef.current) === null || _sourceRef$current === void 0 ? void 0 : _sourceRef$current.measureInWindow((x, y, width, height) => {
189
+ // Could add a debouncer here if there's too many rerenders during gradual resizes
190
+ setWindowDimensions(window);
191
+ setSourceLayout({
192
+ x,
193
+ y,
194
+ width,
195
+ height
196
+ });
197
+ });
198
+ };
199
+
200
+ let subscription;
201
+
202
+ const unsubscribe = () => {
203
+ var _subscription;
204
+
205
+ if (typeof ((_subscription = subscription) === null || _subscription === void 0 ? void 0 : _subscription.remove) === 'function') {
206
+ // React Native >=0.65.0
207
+ subscription.remove();
208
+ } else if (typeof _Dimensions.default.removeEventListener === 'function') {
209
+ // React Native <0.65.0
210
+ _Dimensions.default.removeEventListener('change', handleDimensionsChange);
211
+ }
212
+
213
+ setSourceLayout(null);
214
+ setTargetDimensions(null);
215
+ };
216
+
217
+ if (readyToShow) {
218
+ subscription = _Dimensions.default.addEventListener('change', handleDimensionsChange);
219
+ handleDimensionsChange({
220
+ window: _Dimensions.default.get('window')
221
+ });
222
+ } else {
223
+ unsubscribe();
224
+ }
225
+
226
+ return unsubscribe;
227
+ }, [readyToShow]);
228
+ const isReady = Boolean(isShown && sourceLayout && windowDimensions && targetDimensions);
229
+ const overlaidPosition = isReady ? getOverlaidPosition({
230
+ sourceLayout,
231
+ targetDimensions,
232
+ windowDimensions,
233
+ offsets,
234
+ align
235
+ }) : {};
236
+ return {
237
+ overlaidPosition,
238
+ sourceRef,
239
+ targetRef,
240
+ onTargetLayout,
241
+ isReady
242
+ };
243
+ };
244
+
245
+ var _default = useOverlaidPosition;
246
+ exports.default = _default;