@telus-uds/components-web 1.8.0 → 1.10.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 (188) hide show
  1. package/CHANGELOG.md +41 -2
  2. package/lib/Autocomplete/Autocomplete.js +393 -0
  3. package/lib/Autocomplete/Loading.js +51 -0
  4. package/lib/Autocomplete/Suggestions.js +81 -0
  5. package/lib/Autocomplete/constants.js +19 -0
  6. package/lib/Autocomplete/dictionary.js +19 -0
  7. package/lib/Autocomplete/index.js +13 -0
  8. package/lib/Breadcrumbs/Breadcrumbs.js +8 -3
  9. package/lib/Callout/Callout.js +3 -0
  10. package/lib/Card/Card.js +180 -0
  11. package/lib/Card/CardContent.js +110 -0
  12. package/lib/Card/CardFooter.js +98 -0
  13. package/lib/Card/index.js +13 -0
  14. package/lib/Countdown/Countdown.js +189 -0
  15. package/lib/Countdown/Segment.js +111 -0
  16. package/lib/Countdown/constants.js +14 -0
  17. package/lib/Countdown/dictionary.js +29 -0
  18. package/lib/Countdown/index.js +13 -0
  19. package/lib/Countdown/types.js +39 -0
  20. package/lib/Countdown/useCountdown.js +40 -0
  21. package/lib/Footnote/Footnote.js +67 -24
  22. package/lib/Modal/ModalContent.js +11 -4
  23. package/lib/OptimizeImage/OptimizeImage.js +127 -0
  24. package/lib/OptimizeImage/index.js +13 -0
  25. package/lib/OptimizeImage/utils/getFallbackUrl.js +18 -0
  26. package/lib/OptimizeImage/utils/getOptimizedUrl.js +32 -0
  27. package/lib/OptimizeImage/utils/hasWebpSupport.js +38 -0
  28. package/lib/OptimizeImage/utils/index.js +31 -0
  29. package/lib/OptimizeImage/utils/isSvgUrl.js +10 -0
  30. package/lib/QuantitySelector/QuantitySelector.js +253 -0
  31. package/lib/QuantitySelector/dictionary.js +33 -0
  32. package/lib/QuantitySelector/index.js +13 -0
  33. package/lib/QuantitySelector/styles.js +40 -0
  34. package/lib/StoryCard/StoryCard.js +244 -0
  35. package/lib/StoryCard/index.js +13 -0
  36. package/lib/TermsAndConditions/ExpandCollapse.js +141 -0
  37. package/lib/TermsAndConditions/TermsAndConditions.js +221 -0
  38. package/lib/TermsAndConditions/dictionary.js +19 -0
  39. package/lib/TermsAndConditions/index.js +15 -0
  40. package/lib/Testimonial/Testimonial.js +226 -0
  41. package/lib/Testimonial/index.js +13 -0
  42. package/lib/Toast/Toast.js +15 -8
  43. package/lib/Video/ControlBar/ControlBar.js +315 -0
  44. package/lib/Video/ControlBar/Controls/VideoButton/VideoButton.js +91 -0
  45. package/lib/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +186 -0
  46. package/lib/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +221 -0
  47. package/lib/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +213 -0
  48. package/lib/Video/MiddleControlButton/MiddleControlButton.js +89 -0
  49. package/lib/Video/Video.js +1072 -0
  50. package/lib/Video/index.js +13 -0
  51. package/lib/Video/videoText.js +62 -0
  52. package/lib/WebVideo/WebVideo.js +170 -0
  53. package/lib/WebVideo/index.js +13 -0
  54. package/lib/baseExports.js +0 -6
  55. package/lib/index.js +91 -1
  56. package/lib/shared/VideoSplash/SplashButton/SplashButton.js +102 -0
  57. package/lib/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +234 -0
  58. package/lib/shared/VideoSplash/VideoSplash.js +86 -0
  59. package/lib/shared/VideoSplash/helpers.js +38 -0
  60. package/lib/utils/index.js +8 -0
  61. package/lib-module/Autocomplete/Autocomplete.js +369 -0
  62. package/lib-module/Autocomplete/Loading.js +38 -0
  63. package/lib-module/Autocomplete/Suggestions.js +64 -0
  64. package/lib-module/Autocomplete/constants.js +5 -0
  65. package/lib-module/Autocomplete/dictionary.js +12 -0
  66. package/lib-module/Autocomplete/index.js +2 -0
  67. package/lib-module/Breadcrumbs/Breadcrumbs.js +8 -3
  68. package/lib-module/Callout/Callout.js +3 -0
  69. package/lib-module/Card/Card.js +158 -0
  70. package/lib-module/Card/CardContent.js +92 -0
  71. package/lib-module/Card/CardFooter.js +80 -0
  72. package/lib-module/Card/index.js +2 -0
  73. package/lib-module/Countdown/Countdown.js +165 -0
  74. package/lib-module/Countdown/Segment.js +94 -0
  75. package/lib-module/Countdown/constants.js +4 -0
  76. package/lib-module/Countdown/dictionary.js +22 -0
  77. package/lib-module/Countdown/index.js +2 -0
  78. package/lib-module/Countdown/types.js +23 -0
  79. package/lib-module/Countdown/useCountdown.js +32 -0
  80. package/lib-module/Footnote/Footnote.js +65 -24
  81. package/lib-module/Modal/ModalContent.js +10 -4
  82. package/lib-module/OptimizeImage/OptimizeImage.js +106 -0
  83. package/lib-module/OptimizeImage/index.js +2 -0
  84. package/lib-module/OptimizeImage/utils/getFallbackUrl.js +8 -0
  85. package/lib-module/OptimizeImage/utils/getOptimizedUrl.js +22 -0
  86. package/lib-module/OptimizeImage/utils/hasWebpSupport.js +32 -0
  87. package/lib-module/OptimizeImage/utils/index.js +4 -0
  88. package/lib-module/OptimizeImage/utils/isSvgUrl.js +3 -0
  89. package/lib-module/QuantitySelector/QuantitySelector.js +232 -0
  90. package/lib-module/QuantitySelector/dictionary.js +26 -0
  91. package/lib-module/QuantitySelector/index.js +2 -0
  92. package/lib-module/QuantitySelector/styles.js +21 -0
  93. package/lib-module/StoryCard/StoryCard.js +220 -0
  94. package/lib-module/StoryCard/index.js +2 -0
  95. package/lib-module/TermsAndConditions/ExpandCollapse.js +120 -0
  96. package/lib-module/TermsAndConditions/TermsAndConditions.js +193 -0
  97. package/lib-module/TermsAndConditions/dictionary.js +12 -0
  98. package/lib-module/TermsAndConditions/index.js +1 -0
  99. package/lib-module/Testimonial/Testimonial.js +204 -0
  100. package/lib-module/Testimonial/index.js +2 -0
  101. package/lib-module/Toast/Toast.js +15 -8
  102. package/lib-module/Video/ControlBar/ControlBar.js +292 -0
  103. package/lib-module/Video/ControlBar/Controls/VideoButton/VideoButton.js +74 -0
  104. package/lib-module/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +167 -0
  105. package/lib-module/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +201 -0
  106. package/lib-module/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +193 -0
  107. package/lib-module/Video/MiddleControlButton/MiddleControlButton.js +72 -0
  108. package/lib-module/Video/Video.js +1042 -0
  109. package/lib-module/Video/index.js +2 -0
  110. package/lib-module/Video/videoText.js +55 -0
  111. package/lib-module/WebVideo/WebVideo.js +144 -0
  112. package/lib-module/WebVideo/index.js +2 -0
  113. package/lib-module/baseExports.js +1 -1
  114. package/lib-module/index.js +10 -0
  115. package/lib-module/shared/VideoSplash/SplashButton/SplashButton.js +85 -0
  116. package/lib-module/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +216 -0
  117. package/lib-module/shared/VideoSplash/VideoSplash.js +65 -0
  118. package/lib-module/shared/VideoSplash/helpers.js +23 -0
  119. package/lib-module/utils/index.js +2 -1
  120. package/package.json +7 -5
  121. package/src/Autocomplete/Autocomplete.jsx +354 -0
  122. package/src/Autocomplete/Loading.jsx +18 -0
  123. package/src/Autocomplete/Suggestions.jsx +52 -0
  124. package/src/Autocomplete/constants.js +6 -0
  125. package/src/Autocomplete/dictionary.js +12 -0
  126. package/src/Autocomplete/index.js +3 -0
  127. package/src/Breadcrumbs/Breadcrumbs.jsx +4 -3
  128. package/src/Callout/Callout.jsx +1 -1
  129. package/src/Card/Card.jsx +170 -0
  130. package/src/Card/CardContent.jsx +88 -0
  131. package/src/Card/CardFooter.jsx +70 -0
  132. package/src/Card/index.js +3 -0
  133. package/src/Countdown/Countdown.jsx +144 -0
  134. package/src/Countdown/Segment.jsx +69 -0
  135. package/src/Countdown/constants.js +4 -0
  136. package/src/Countdown/dictionary.js +22 -0
  137. package/src/Countdown/index.js +3 -0
  138. package/src/Countdown/types.js +23 -0
  139. package/src/Countdown/useCountdown.js +34 -0
  140. package/src/Footnote/Footnote.jsx +73 -23
  141. package/src/Modal/ModalContent.jsx +8 -4
  142. package/src/OptimizeImage/OptimizeImage.jsx +131 -0
  143. package/src/OptimizeImage/index.js +3 -0
  144. package/src/OptimizeImage/utils/getFallbackUrl.js +9 -0
  145. package/src/OptimizeImage/utils/getOptimizedUrl.js +30 -0
  146. package/src/OptimizeImage/utils/hasWebpSupport.js +33 -0
  147. package/src/OptimizeImage/utils/index.js +5 -0
  148. package/src/OptimizeImage/utils/isSvgUrl.js +3 -0
  149. package/src/QuantitySelector/QuantitySelector.jsx +245 -0
  150. package/src/QuantitySelector/dictionary.js +27 -0
  151. package/src/QuantitySelector/index.js +3 -0
  152. package/src/QuantitySelector/styles.js +83 -0
  153. package/src/StoryCard/StoryCard.jsx +198 -0
  154. package/src/StoryCard/index.js +3 -0
  155. package/src/TermsAndConditions/ExpandCollapse.jsx +106 -0
  156. package/src/TermsAndConditions/TermsAndConditions.jsx +161 -0
  157. package/src/TermsAndConditions/dictionary.js +12 -0
  158. package/src/TermsAndConditions/index.js +1 -0
  159. package/src/Testimonial/Testimonial.jsx +169 -0
  160. package/src/Testimonial/index.js +3 -0
  161. package/src/Toast/Toast.jsx +12 -5
  162. package/src/Video/ControlBar/ControlBar.jsx +261 -0
  163. package/src/Video/ControlBar/Controls/VideoButton/VideoButton.jsx +61 -0
  164. package/src/Video/ControlBar/Controls/VideoMenu/VideoMenu.jsx +159 -0
  165. package/src/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.jsx +185 -0
  166. package/src/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.jsx +184 -0
  167. package/src/Video/MiddleControlButton/MiddleControlButton.jsx +64 -0
  168. package/src/Video/Video.jsx +988 -0
  169. package/src/Video/index.js +3 -0
  170. package/src/Video/videoText.js +58 -0
  171. package/src/WebVideo/WebVideo.jsx +131 -0
  172. package/src/WebVideo/index.js +3 -0
  173. package/src/baseExports.js +0 -1
  174. package/src/index.js +10 -0
  175. package/src/shared/VideoSplash/SplashButton/SplashButton.jsx +64 -0
  176. package/src/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.jsx +128 -0
  177. package/src/shared/VideoSplash/VideoSplash.jsx +50 -0
  178. package/src/shared/VideoSplash/helpers.js +27 -0
  179. package/src/utils/index.js +10 -1
  180. package/types/Autocomplete.d.ts +32 -0
  181. package/types/Card.d.ts +45 -0
  182. package/types/ControlBar.d.ts +59 -0
  183. package/types/MiddleControlButton.d.ts +15 -0
  184. package/types/Video.d.ts +39 -0
  185. package/types/VideoButton.d.ts +14 -0
  186. package/types/VideoMenu.d.ts +16 -0
  187. package/types/VideoProgressBar.d.ts +17 -0
  188. package/types/VolumeSlider.d.ts +20 -0
package/CHANGELOG.md CHANGED
@@ -1,12 +1,51 @@
1
1
  # Change Log - @telus-uds/components-web
2
2
 
3
- This log was last generated on Mon, 24 Apr 2023 21:33:59 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 01 May 2023 22:02:12 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.10.0
8
+
9
+ Mon, 01 May 2023 22:02:12 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - `Footnote`: Allow `content` prop to take custom JSX, override copy with custom `dictionary` (shahzaibkhalidmalik@outlook.com)
14
+ - Set Item size to micro in Breadcrumbs (wlsdud194@hotmail.com)
15
+ - List Box merged with List changes (akshay.pandey1@telus.com)
16
+ - Added label to Breadcrumb component (wlsdud194@hotmail.com)
17
+ - update snapshots (kyle.king2@telus.com)
18
+ - Bump @telus-uds/components-base to v1.39.0
19
+ - Bump @telus-uds/system-theme-tokens to v2.24.0
20
+
21
+ ## 1.9.0
22
+
23
+ Thu, 27 Apr 2023 14:41:57 GMT
24
+
25
+ ### Minor changes
26
+
27
+ - Moved OptimizeImage to components-web from ds-allium (kyle.king2@telus.com)
28
+ - Countdown is now multibrand (akshay.pandey1@telus.com)
29
+ - added color token to Icon in Callout component (ignacio.cuyun@telus.com)
30
+ - Added Video components to componets.js and themes (wlsdud194@hotmail.com)
31
+ - make storycard component multibrand (mauricio.batresmontejo@telus.com)
32
+ - make Terms and Conditions multibrand (mauricio.batresmontejo@telus.com)
33
+ - Testimonial multi-brand (samuraix221@hotmail.com)
34
+ - Added Card component (wlsdud194@hotmail.com)
35
+ - move 'IconButton' to components-web (kyle.king2@telus.com)
36
+ - move 'WebVideo' & 'shared/SplashButton' to components-web (kyle.king2@telus.com)
37
+ - updated spinner snapshot (ignacio.cuyun@telus.com)
38
+ - move Autocomplete component to components web (evander.owusu@telus.com)
39
+ - Bump @telus-uds/components-base to v1.38.0
40
+ - Bump @telus-uds/system-theme-tokens to v2.23.0
41
+
42
+ ### Patches
43
+
44
+ - Fix where `Modal`'s cancel link may not render correctly on Firefox (shahzaibkhalidmalik@outlook.com)
45
+
7
46
  ## 1.8.0
8
47
 
9
- Mon, 24 Apr 2023 21:33:59 GMT
48
+ Mon, 24 Apr 2023 21:42:02 GMT
10
49
 
11
50
  ### Minor changes
12
51
 
@@ -0,0 +1,393 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _lodash = require("lodash");
13
+
14
+ var _componentsBase = require("@telus-uds/components-base");
15
+
16
+ var _Listbox = _interopRequireDefault(require("../Listbox"));
17
+
18
+ var _utils = require("../utils");
19
+
20
+ var _Loading = _interopRequireDefault(require("./Loading"));
21
+
22
+ var _Suggestions = _interopRequireDefault(require("./Suggestions"));
23
+
24
+ var _constants = require("./constants");
25
+
26
+ var _dictionary = _interopRequireDefault(require("./dictionary"));
27
+
28
+ var _jsxRuntime = require("react/jsx-runtime");
29
+
30
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
+
32
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
33
+
34
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
35
+
36
+ /* eslint-disable react/require-default-props */
37
+ const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs, _componentsBase.inputSupportsProps, _componentsBase.textInputHandlerProps, _componentsBase.textInputProps]);
38
+ const inputTokens = {
39
+ paddingLeft: _constants.INPUT_LEFT_PADDING
40
+ }; // Returns JSX to display a bold string `str` with unbolded occurrences of the
41
+ // `substring` based in the array of `matchIndexes` provided
42
+
43
+ const highlightAllMatches = function (str) {
44
+ let substring = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
45
+ let matchIndexes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
46
+ return (
47
+ /*#__PURE__*/
48
+ // Wrapping all in bold
49
+ (0, _jsxRuntime.jsx)(_componentsBase.Typography, {
50
+ variant: {
51
+ bold: false
52
+ },
53
+ children: matchIndexes.reduce((acc, matchIndex, index) => [...acc, // Add a piece of the string up to the first occurrence of the substring
54
+ index === 0 && (str.slice(0, matchIndex) ?? ''),
55
+ /*#__PURE__*/
56
+ // Unbold the occurrence of the substring (while keeping the original casing)
57
+ (0, _jsxRuntime.jsx)(_componentsBase.Typography, {
58
+ variant: {
59
+ bold: true
60
+ },
61
+ children: str.slice(matchIndex, matchIndex + substring.length)
62
+ }, matchIndex), // Add the rest of the string until the next occurrence or the end of it
63
+ str.slice(matchIndex + substring.length, matchIndexes[index + 1] ?? str.length)], [])
64
+ })
65
+ );
66
+ };
67
+
68
+ const highlight = function () {
69
+ let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
70
+ let text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
71
+ return items.reduce((acc, item) => {
72
+ var _Array$from;
73
+
74
+ const matches = (_Array$from = Array.from(item.label.toLowerCase().matchAll(text.toLowerCase()))) === null || _Array$from === void 0 ? void 0 : _Array$from.map(_ref => {
75
+ let {
76
+ index
77
+ } = _ref;
78
+ return index;
79
+ });
80
+
81
+ if (matches !== null && matches !== void 0 && matches.length) {
82
+ return [...acc, { ...item,
83
+ label: highlightAllMatches(item.label, text, matches)
84
+ }];
85
+ }
86
+
87
+ return [...acc, item];
88
+ }, []);
89
+ };
90
+
91
+ const Autocomplete = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
92
+ var _ref3;
93
+
94
+ let {
95
+ children,
96
+ copy = 'en',
97
+ fullWidth = true,
98
+ initialItems,
99
+ initialValue,
100
+ isLoading = false,
101
+ items,
102
+ maxSuggestions = _constants.DEFAULT_MAX_SUGGESTIONS,
103
+ minToSuggestion = _constants.DEFAULT_MIN_TO_SUGGESTION,
104
+ noResults,
105
+ onChange,
106
+ onClear,
107
+ onSelect,
108
+ readOnly,
109
+ validation,
110
+ value,
111
+ ...rest
112
+ } = _ref2;
113
+ // The wrapped input is mostly responsible for controlled vs uncontrolled handling,
114
+ // but we also need to adjust suggestions based on the mode:
115
+ // - in controlled mode we rely entirely on the suggestions passed via the `items` prop,
116
+ // - in uncontrolled mode we filter the suggestions ourselves based on the `initialItems`
117
+ // prop and the text entered
118
+ const isControlled = value !== undefined; // We need to store current items for uncontrolled usage
119
+
120
+ const [currentItems, setCurrentItems] = (0, _react.useState)(initialItems); // We need to store the current value as well to be able to highlight it
121
+
122
+ const [currentValue, setCurrentValue] = (0, _react.useState)(value ?? initialValue); // Setting up the overlay
123
+
124
+ const openOverlayRef = (0, _react.useRef)();
125
+ const [isExpanded, setIsExpanded] = (0, _react.useState)(((_ref3 = value ?? initialValue) === null || _ref3 === void 0 ? void 0 : _ref3.length) >= minToSuggestion);
126
+ const {
127
+ overlaidPosition,
128
+ sourceRef: inputRef,
129
+ targetRef,
130
+ onTargetLayout,
131
+ isReady
132
+ } = (0, _utils.useOverlaidPosition)({
133
+ isShown: isExpanded,
134
+ offsets: {
135
+ vertical: 4
136
+ }
137
+ }); // We limit the number of suggestions displayed to avoid huge lists
138
+ // TODO: add a way to make the `Listbox` occupy fixed height and be scrollable
139
+ // within that height, which will unlock similar behaviour for `AutoComplete` as well
140
+
141
+ const itemsToSuggest = function () {
142
+ let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
143
+ return maxSuggestions ? data.slice(0, maxSuggestions) : [...data];
144
+ };
145
+
146
+ const getCopy = (0, _componentsBase.useCopy)({
147
+ dictionary: _dictionary.default,
148
+ copy
149
+ }); // Tracking input width changes to resize the listbox overlay accordingly
150
+
151
+ const [inputWidth, setInputWidth] = (0, _react.useState)();
152
+ (0, _componentsBase.useSafeLayoutEffect)(() => {
153
+ const updateInputWidth = () => {
154
+ var _inputRef$current;
155
+
156
+ setInputWidth((inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.clientWidth) + 4); // adding back all the input borders / outlines
157
+
158
+ setIsExpanded(false); // close the suggestions while the input is changing
159
+ };
160
+
161
+ const throttledUpdateInputWidth = (0, _lodash.throttle)(updateInputWidth, 100, {
162
+ leading: false
163
+ });
164
+ updateInputWidth();
165
+ window.addEventListener('load', updateInputWidth);
166
+ window.addEventListener('resize', throttledUpdateInputWidth);
167
+ return () => {
168
+ window.removeEventListener('load', updateInputWidth);
169
+ window.removeEventListener('resize', throttledUpdateInputWidth);
170
+ };
171
+ }, [inputRef]);
172
+
173
+ const handleChange = newValue => {
174
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
175
+ setCurrentValue(newValue);
176
+ setIsExpanded((newValue === null || newValue === void 0 ? void 0 : newValue.length) >= minToSuggestion);
177
+
178
+ if (!isControlled && initialItems !== undefined) {
179
+ setCurrentItems(initialItems.filter(_ref4 => {
180
+ var _label$toLowerCase;
181
+
182
+ let {
183
+ label
184
+ } = _ref4;
185
+ return label === null || label === void 0 ? void 0 : (_label$toLowerCase = label.toLowerCase()) === null || _label$toLowerCase === void 0 ? void 0 : _label$toLowerCase.includes(newValue === null || newValue === void 0 ? void 0 : newValue.toLowerCase());
186
+ }));
187
+ }
188
+ };
189
+
190
+ const handleSelect = selectedId => {
191
+ var _ref5;
192
+
193
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect(selectedId);
194
+ const {
195
+ label: newValue
196
+ } = (_ref5 = isControlled ? items : currentItems) === null || _ref5 === void 0 ? void 0 : _ref5.find(_ref6 => {
197
+ let {
198
+ id
199
+ } = _ref6;
200
+ return id === selectedId;
201
+ });
202
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
203
+ setCurrentValue(newValue);
204
+ if (!isControlled && inputRef !== null && inputRef !== void 0 && inputRef.current) inputRef.current.value = newValue;
205
+ setIsExpanded(false);
206
+ };
207
+
208
+ const handleClose = event => {
209
+ var _openOverlayRef$curre, _openOverlayRef$curre2;
210
+
211
+ if (event.type === 'keydown') {
212
+ if (event.key === 'Escape' || event.key === 27) {
213
+ setIsExpanded(false);
214
+ } else if (event.key === 'ArrowDown' && isExpanded && !isLoading && targetRef !== null && targetRef !== void 0 && targetRef.current) {
215
+ targetRef.current.focus();
216
+ }
217
+ } else if (event.type === 'click' && openOverlayRef !== null && openOverlayRef !== void 0 && openOverlayRef.current && event.target && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre = openOverlayRef.current) !== null && _openOverlayRef$curre !== void 0 && _openOverlayRef$curre.contains(event.target))) {
218
+ setIsExpanded(false);
219
+ } else if (event.type === 'touchstart' && openOverlayRef !== null && openOverlayRef !== void 0 && openOverlayRef.current && event.touches[0].target && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre2 = openOverlayRef.current) !== null && _openOverlayRef$curre2 !== void 0 && _openOverlayRef$curre2.contains(event.touches[0].target))) {
220
+ setIsExpanded(false);
221
+ }
222
+ };
223
+
224
+ const {
225
+ supportsProps,
226
+ ...selectedProps
227
+ } = selectProps(rest);
228
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
229
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.InputSupports, { ...supportsProps,
230
+ accessibilityAutoComplete: "list",
231
+ accessibilityControls: "autocomplete",
232
+ accessibilityExpanded: isExpanded,
233
+ accessibilityRole: "combobox",
234
+ ...selectedProps,
235
+ validation: validation,
236
+ ref: ref,
237
+ children: _ref7 => {
238
+ let {
239
+ inputId,
240
+ ...props
241
+ } = _ref7;
242
+ if (typeof children === 'function') return children({
243
+ inputId,
244
+ inputRef,
245
+ onChange: handleChange,
246
+ onKeyPress: handleClose,
247
+ readOnly,
248
+ tokens: inputTokens,
249
+ ...selectedProps,
250
+ ...props,
251
+ ...(isControlled ? {
252
+ value
253
+ } : {
254
+ initialValue
255
+ })
256
+ });
257
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.TextInput, {
258
+ onChange: handleChange,
259
+ onClear: onClear,
260
+ onKeyPress: handleClose,
261
+ readOnly: readOnly,
262
+ ref: inputRef,
263
+ tokens: inputTokens,
264
+ ...selectedProps,
265
+ ...props,
266
+ ...(isControlled ? {
267
+ value
268
+ } : {
269
+ initialValue
270
+ })
271
+ });
272
+ }
273
+ }), isExpanded && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
274
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Listbox.default.Overlay, {
275
+ overlaidPosition: overlaidPosition,
276
+ isReady: isReady,
277
+ minWidth: fullWidth ? inputWidth : _constants.MIN_LISTBOX_WIDTH,
278
+ maxWidth: inputWidth,
279
+ onLayout: onTargetLayout,
280
+ ref: openOverlayRef,
281
+ children: isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loading.default, {
282
+ label: getCopy('loading')
283
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Suggestions.default, {
284
+ hasResults: getCopy('hasResults'),
285
+ id: "autocomplete",
286
+ items: itemsToSuggest(highlight(isControlled ? items : currentItems, currentValue)),
287
+ noResults: noResults ?? getCopy('noResults'),
288
+ onClose: handleClose,
289
+ onSelect: handleSelect,
290
+ parentRef: inputRef,
291
+ ref: targetRef
292
+ })
293
+ }), (targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
294
+ // This catches and shifts focus to other interactive elements.
295
+ onFocus: () => {
296
+ var _targetRef$current;
297
+
298
+ return targetRef === null || targetRef === void 0 ? void 0 : (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : _targetRef$current.focus();
299
+ } // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
300
+ ,
301
+ tabIndex: 0
302
+ })]
303
+ })]
304
+ });
305
+ });
306
+ Autocomplete.displayName = 'Autocomplete'; // If a language dictionary entry is provided, it must contain every key
307
+
308
+ const dictionaryContentShape = _propTypes.default.shape({
309
+ hasResults: _propTypes.default.string.isRequired,
310
+ loading: _propTypes.default.string.isRequired,
311
+ noResults: _propTypes.default.string.isRequired
312
+ });
313
+
314
+ Autocomplete.propTypes = { ...selectedSystemPropTypes,
315
+
316
+ /**
317
+ * Can be used to provide a function that renders a custom input:
318
+ * <Autocomplete items={items} value={currentValue}>
319
+ * {({ inputId, inputRef, onChange, onKeyPress, readOnly, tokens, value }) => (
320
+ * <Search
321
+ * nativeID={inputId}
322
+ * ref={inputRef}
323
+ * onChange={onChange}
324
+ * onKeyPress={onKeyPress}
325
+ * readOnly={readOnly}
326
+ * tokens={tokens}
327
+ * value={value}
328
+ * />
329
+ * )}
330
+ * </Autocomplete>
331
+ */
332
+ children: _propTypes.default.func,
333
+
334
+ /**
335
+ * Copy language identifier
336
+ */
337
+ copy: _propTypes.default.oneOfType([_propTypes.default.oneOf(['en', 'fr']), dictionaryContentShape]),
338
+
339
+ /**
340
+ * Set to true in order to display the loading indicator instead of results
341
+ */
342
+ isLoading: _propTypes.default.bool,
343
+
344
+ /**
345
+ * List of items to display as suggestions
346
+ */
347
+ items: _propTypes.default.arrayOf(_propTypes.default.shape({
348
+ id: _propTypes.default.string,
349
+ label: _propTypes.default.string
350
+ })),
351
+
352
+ /**
353
+ * Label to display alongside the spinner when in a loading state
354
+ */
355
+ loadingLabel: _propTypes.default.string,
356
+
357
+ /**
358
+ * Minimum number of characters typed for a list of suggestions to appear
359
+ */
360
+ minToSuggestion: _propTypes.default.number,
361
+
362
+ /**
363
+ * Maximum number of suggestions provided at the same time
364
+ */
365
+ maxSuggestions: _propTypes.default.number,
366
+
367
+ /**
368
+ * Text or JSX to render when no results are available
369
+ */
370
+ noResults: _propTypes.default.node,
371
+
372
+ /**
373
+ * Handler function to be called when the input value changes
374
+ */
375
+ onChange: _propTypes.default.func,
376
+
377
+ /**
378
+ * Handler function to be called when the clear button (appears if the handler is passed) is pressed
379
+ */
380
+ onClear: _propTypes.default.func,
381
+
382
+ /**
383
+ * Callback function to be called when an item is selected from the list
384
+ */
385
+ onSelect: _propTypes.default.func,
386
+
387
+ /**
388
+ * Input value for controlled usage
389
+ */
390
+ value: _propTypes.default.string
391
+ };
392
+ var _default = Autocomplete;
393
+ exports.default = _default;
@@ -0,0 +1,51 @@
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 _componentsBase = require("@telus-uds/components-base");
13
+
14
+ var _Spinner = _interopRequireDefault(require("../Spinner"));
15
+
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ const Loading = _ref => {
21
+ let {
22
+ label
23
+ } = _ref;
24
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Box, {
25
+ space: 3,
26
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_componentsBase.StackView, {
27
+ direction: "row",
28
+ space: 2,
29
+ tokens: {
30
+ alignItems: 'center'
31
+ },
32
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Spinner.default, {
33
+ inline: true,
34
+ show: true,
35
+ size: "small"
36
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
37
+ variant: {
38
+ size: 'small'
39
+ },
40
+ accessibilityLiveRegion: "polite",
41
+ children: label
42
+ })]
43
+ })
44
+ });
45
+ };
46
+
47
+ Loading.propTypes = {
48
+ label: _propTypes.default.string
49
+ };
50
+ var _default = Loading;
51
+ exports.default = _default;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _componentsBase = require("@telus-uds/components-base");
13
+
14
+ var _Listbox = _interopRequireDefault(require("../Listbox"));
15
+
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
24
+ const Suggestions = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
25
+ let {
26
+ hasResults,
27
+ items = [],
28
+ noResults,
29
+ onClose,
30
+ onSelect,
31
+ parentRef
32
+ } = _ref;
33
+ const pressableItems = items.map(_ref2 => {
34
+ let {
35
+ id,
36
+ ...rest
37
+ } = _ref2;
38
+ return {
39
+ id,
40
+ onPress: () => onSelect(id),
41
+ ...rest
42
+ };
43
+ });
44
+ if (items !== null && items !== void 0 && items.length) return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
45
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.A11yText, {
46
+ accessibilityLiveRegion: "polite",
47
+ text: hasResults
48
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Listbox.default, {
49
+ items: pressableItems,
50
+ firstItemRef: ref,
51
+ parentRef: parentRef,
52
+ onClose: onClose
53
+ })]
54
+ });
55
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Box, {
56
+ space: 3,
57
+ children: typeof noResults === 'string' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
58
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
59
+ accessibilityLiveRegion: "polite",
60
+ variant: {
61
+ size: 'small'
62
+ },
63
+ children: noResults
64
+ })
65
+ }) : noResults
66
+ });
67
+ });
68
+ Suggestions.displayName = 'Suggestions';
69
+ Suggestions.propTypes = {
70
+ hasResults: _propTypes.default.string.isRequired,
71
+ items: _propTypes.default.arrayOf(_propTypes.default.shape({
72
+ id: _propTypes.default.string,
73
+ label: _propTypes.default.node
74
+ })).isRequired,
75
+ noResults: _propTypes.default.node.isRequired,
76
+ onClose: _propTypes.default.func.isRequired,
77
+ onSelect: _propTypes.default.func.isRequired,
78
+ parentRef: _propTypes.default.object.isRequired
79
+ };
80
+ var _default = Suggestions;
81
+ exports.default = _default;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MIN_LISTBOX_WIDTH = exports.INPUT_LEFT_PADDING = exports.DEFAULT_MIN_TO_SUGGESTION = exports.DEFAULT_MAX_SUGGESTIONS = void 0;
7
+
8
+ var _palette = _interopRequireDefault(require("@telus-uds/palette-allium/build/web/palette"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const DEFAULT_MIN_TO_SUGGESTION = 1;
13
+ exports.DEFAULT_MIN_TO_SUGGESTION = DEFAULT_MIN_TO_SUGGESTION;
14
+ const DEFAULT_MAX_SUGGESTIONS = 5;
15
+ exports.DEFAULT_MAX_SUGGESTIONS = DEFAULT_MAX_SUGGESTIONS;
16
+ const INPUT_LEFT_PADDING = _palette.default.size.size16;
17
+ exports.INPUT_LEFT_PADDING = INPUT_LEFT_PADDING;
18
+ const MIN_LISTBOX_WIDTH = _palette.default.size.size288;
19
+ exports.MIN_LISTBOX_WIDTH = MIN_LISTBOX_WIDTH;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ en: {
9
+ hasResults: 'Some results are available',
10
+ loading: 'Loading suggestions...',
11
+ noResults: 'No results found'
12
+ },
13
+ fr: {
14
+ hasResults: 'Quelques suggestions sont disponible',
15
+ loading: 'Chargement en cours...',
16
+ noResults: 'Aucun résultat trouvé'
17
+ }
18
+ };
19
+ exports.default = _default;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _Autocomplete = _interopRequireDefault(require("./Autocomplete"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ var _default = _Autocomplete.default;
13
+ exports.default = _default;
@@ -39,7 +39,8 @@ const StyledList = /*#__PURE__*/_styledComponents.default.ol.withConfig({
39
39
  listStyle: 'none',
40
40
  listStylePosition: 'inside',
41
41
  margin: 0,
42
- padding: 0
42
+ padding: 0,
43
+ alignItems: 'baseline'
43
44
  });
44
45
 
45
46
  const omitProps = _ref => {
@@ -173,7 +174,9 @@ const Breadcrumbs = _ref2 => {
173
174
  })
174
175
  })
175
176
  });
176
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("nav", { ...selectProps(rest),
177
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("nav", {
178
+ "aria-label": "Breadcrumb",
179
+ ...selectProps(rest),
177
180
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(StyledList, {
178
181
  children: items.map(_ref4 => {
179
182
  let {
@@ -194,7 +197,9 @@ const Breadcrumbs = _ref2 => {
194
197
  itemLinkRouterProps
195
198
  },
196
199
  reactRouterLinkComponent: linkComponent,
197
- variant: variant,
200
+ variant: { ...variant,
201
+ size: 'micro'
202
+ },
198
203
  LinkRouter: ItemLinkRouter
199
204
  }, breadcrumbName);
200
205
  })
@@ -94,6 +94,9 @@ const Callout = _ref2 => {
94
94
  padding: `${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`,
95
95
  ...selectProps(rest),
96
96
  children: [icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Icon, {
97
+ tokens: {
98
+ color
99
+ },
97
100
  icon: icon,
98
101
  variant: {
99
102
  rank: 'primary',