@telus-uds/components-web 2.15.0 → 2.16.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.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,27 @@
1
1
  # Change Log - @telus-uds/components-web
2
2
 
3
- This log was last generated on Fri, 21 Jul 2023 00:42:38 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 28 Jul 2023 18:10:45 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 2.16.0
8
+
9
+ Fri, 28 Jul 2023 18:10:45 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - Update Modal story (wlsdud194@hotmail.com)
14
+ - add ability to inherit results color in autocomplete from Search component (kyle.king2@telus.com)
15
+ - Bump @telus-uds/components-base to v1.57.0
16
+ - Bump @telus-uds/system-theme-tokens to v2.40.0
17
+
18
+ ### Patches
19
+
20
+ - verification in type of typography (mauricio.batresmontejo@telus.com)
21
+
7
22
  ## 2.15.0
8
23
 
9
- Fri, 21 Jul 2023 00:42:38 GMT
24
+ Fri, 21 Jul 2023 00:51:24 GMT
10
25
 
11
26
  ### Minor changes
12
27
 
@@ -6445,7 +6445,8 @@
6445
6445
  "labelFontSize": "fontSize",
6446
6446
  "labelFontWeight": "fontWeight",
6447
6447
  "labelLineHeight": "lineHeight",
6448
- "labelMarginLeft": "size"
6448
+ "labelMarginLeft": "size",
6449
+ "inputOutlineOffset": "size"
6449
6450
  }
6450
6451
  },
6451
6452
  "required": false,
@@ -6541,7 +6542,14 @@
6541
6542
  "name": "custom",
6542
6543
  "raw": {
6543
6544
  "space": "integer",
6544
- "fieldSpace": "integer"
6545
+ "fieldSpace": "integer",
6546
+ "showIcon": "show",
6547
+ "outlineWidth": "border",
6548
+ "borderBottomLeftRadius": "radius",
6549
+ "borderBottomRightRadius": "radius",
6550
+ "borderTopLeftRadius": "radius",
6551
+ "borderTopRightRadius": "radius",
6552
+ "outlineOffset": "size"
6545
6553
  }
6546
6554
  },
6547
6555
  "required": false,
@@ -6573,7 +6581,8 @@
6573
6581
  "labelFontSize": "fontSize",
6574
6582
  "labelFontWeight": "fontWeight",
6575
6583
  "labelLineHeight": "lineHeight",
6576
- "labelMarginLeft": "size"
6584
+ "labelMarginLeft": "size",
6585
+ "inputOutlineOffset": "size"
6577
6586
  }
6578
6587
  },
6579
6588
  "required": false,
@@ -9259,6 +9268,7 @@
9259
9268
  "itemIconSize": "size",
9260
9269
  "itemLineHeight": "lineHeight",
9261
9270
  "listGutter": "size",
9271
+ "itemUnderline": "textLine",
9262
9272
  "backgroundColor": "color",
9263
9273
  "paddingLeft": "size",
9264
9274
  "paddingRight": "size",
@@ -9342,6 +9352,7 @@
9342
9352
  "itemIconSize": "size",
9343
9353
  "itemLineHeight": "lineHeight",
9344
9354
  "listGutter": "size",
9355
+ "itemUnderline": "textLine",
9345
9356
  "backgroundColor": "color",
9346
9357
  "paddingLeft": "size",
9347
9358
  "paddingRight": "size",
@@ -40,6 +40,7 @@ const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemP
40
40
  const highlightAllMatches = function (str) {
41
41
  let substring = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
42
42
  let matchIndexes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
43
+ let resultsTextColor = arguments.length > 3 ? arguments[3] : undefined;
43
44
  return (
44
45
  /*#__PURE__*/
45
46
  // Wrapping all in bold
@@ -47,6 +48,9 @@ const highlightAllMatches = function (str) {
47
48
  variant: {
48
49
  bold: false
49
50
  },
51
+ tokens: {
52
+ color: resultsTextColor
53
+ },
50
54
  children: matchIndexes.reduce((acc, matchIndex, index) => [...acc, // Add a piece of the string up to the first occurrence of the substring
51
55
  index === 0 && (str.slice(0, matchIndex) ?? ''),
52
56
  /*#__PURE__*/
@@ -55,6 +59,9 @@ const highlightAllMatches = function (str) {
55
59
  variant: {
56
60
  bold: true
57
61
  },
62
+ tokens: {
63
+ color: resultsTextColor
64
+ },
58
65
  children: str.slice(matchIndex, matchIndex + substring.length)
59
66
  }, matchIndex), // Add the rest of the string until the next occurrence or the end of it
60
67
  str.slice(matchIndex + substring.length, matchIndexes[index + 1] ?? str.length)], [])
@@ -65,6 +72,7 @@ const highlightAllMatches = function (str) {
65
72
  const highlight = function () {
66
73
  let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
67
74
  let text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
75
+ let color = arguments.length > 2 ? arguments[2] : undefined;
68
76
  return items.reduce((acc, item) => {
69
77
  var _Array$from;
70
78
 
@@ -77,7 +85,7 @@ const highlight = function () {
77
85
 
78
86
  if (matches !== null && matches !== void 0 && matches.length) {
79
87
  return [...acc, { ...item,
80
- label: highlightAllMatches(item.label, text, matches)
88
+ label: highlightAllMatches(item.label, text, matches, color)
81
89
  }];
82
90
  }
83
91
 
@@ -107,11 +115,16 @@ const Autocomplete = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
107
115
  value,
108
116
  ...rest
109
117
  } = _ref2;
110
- // The wrapped input is mostly responsible for controlled vs uncontrolled handling,
118
+ const {
119
+ color: resultsTextColor
120
+ } = (0, _componentsBase.useThemeTokens)('Search', {}, {
121
+ focus: true
122
+ }); // The wrapped input is mostly responsible for controlled vs uncontrolled handling,
111
123
  // but we also need to adjust suggestions based on the mode:
112
124
  // - in controlled mode we rely entirely on the suggestions passed via the `items` prop,
113
125
  // - in uncontrolled mode we filter the suggestions ourselves based on the `initialItems`
114
126
  // prop and the text entered
127
+
115
128
  const isControlled = value !== undefined; // We need to store current items for uncontrolled usage
116
129
 
117
130
  const [currentItems, setCurrentItems] = (0, _react.useState)(initialItems); // We need to store the current value as well to be able to highlight it
@@ -284,7 +297,7 @@ const Autocomplete = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
284
297
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Suggestions.default, {
285
298
  hasResults: getCopy('hasResults'),
286
299
  id: "autocomplete",
287
- items: itemsToSuggest(highlight(isControlled ? items : currentItems, currentValue)),
300
+ items: itemsToSuggest(highlight(isControlled ? items : currentItems, currentValue, resultsTextColor)),
288
301
  noResults: noResults ?? getCopy('noResults'),
289
302
  onClose: handleClose,
290
303
  onSelect: handleSelect,
@@ -156,7 +156,11 @@ const Ribbon = _ref18 => {
156
156
  gradient,
157
157
  fontColor,
158
158
  borderRadiusBottomLeft,
159
- borderRadiusBottomRight
159
+ borderRadiusBottomRight,
160
+ fontName,
161
+ fontWeight,
162
+ fontSize,
163
+ lineHeight
160
164
  } = (0, _componentsBase.useThemeTokens)('Ribbon', tokens, { ...variant,
161
165
  wrap: shouldWrap
162
166
  });
@@ -187,12 +191,15 @@ const Ribbon = _ref18 => {
187
191
  borderRadiusBottomRight: `${borderRadiusBottomRight}px`,
188
192
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
189
193
  variant: {
190
- size: 'micro',
191
194
  bold: true,
192
195
  inverse: true
193
196
  },
194
197
  tokens: {
195
- color: fontColor
198
+ color: fontColor,
199
+ fontName,
200
+ fontWeight,
201
+ fontSize,
202
+ lineHeight
196
203
  },
197
204
  children: children
198
205
  })
@@ -2,7 +2,7 @@
2
2
  import React, { forwardRef, useRef, useState } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { throttle } from 'lodash';
5
- import { InputSupports, inputSupportsProps, selectSystemProps, TextInput, textInputProps, textInputHandlerProps, Typography, useCopy, useSafeLayoutEffect } from '@telus-uds/components-base';
5
+ import { InputSupports, inputSupportsProps, selectSystemProps, TextInput, textInputProps, textInputHandlerProps, Typography, useCopy, useSafeLayoutEffect, useThemeTokens } from '@telus-uds/components-base';
6
6
  import Listbox from '../Listbox';
7
7
  import { htmlAttrs, useOverlaidPosition } from '../utils';
8
8
  import Loading from './Loading';
@@ -18,6 +18,7 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs, inp
18
18
  const highlightAllMatches = function (str) {
19
19
  let substring = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
20
20
  let matchIndexes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
21
+ let resultsTextColor = arguments.length > 3 ? arguments[3] : undefined;
21
22
  return (
22
23
  /*#__PURE__*/
23
24
  // Wrapping all in bold
@@ -25,6 +26,9 @@ const highlightAllMatches = function (str) {
25
26
  variant: {
26
27
  bold: false
27
28
  },
29
+ tokens: {
30
+ color: resultsTextColor
31
+ },
28
32
  children: matchIndexes.reduce((acc, matchIndex, index) => [...acc, // Add a piece of the string up to the first occurrence of the substring
29
33
  index === 0 && (str.slice(0, matchIndex) ?? ''),
30
34
  /*#__PURE__*/
@@ -33,6 +37,9 @@ const highlightAllMatches = function (str) {
33
37
  variant: {
34
38
  bold: true
35
39
  },
40
+ tokens: {
41
+ color: resultsTextColor
42
+ },
36
43
  children: str.slice(matchIndex, matchIndex + substring.length)
37
44
  }, matchIndex), // Add the rest of the string until the next occurrence or the end of it
38
45
  str.slice(matchIndex + substring.length, matchIndexes[index + 1] ?? str.length)], [])
@@ -43,6 +50,7 @@ const highlightAllMatches = function (str) {
43
50
  const highlight = function () {
44
51
  let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
45
52
  let text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
53
+ let color = arguments.length > 2 ? arguments[2] : undefined;
46
54
  return items.reduce((acc, item) => {
47
55
  var _Array$from;
48
56
 
@@ -55,7 +63,7 @@ const highlight = function () {
55
63
 
56
64
  if (matches !== null && matches !== void 0 && matches.length) {
57
65
  return [...acc, { ...item,
58
- label: highlightAllMatches(item.label, text, matches)
66
+ label: highlightAllMatches(item.label, text, matches, color)
59
67
  }];
60
68
  }
61
69
 
@@ -85,11 +93,16 @@ const Autocomplete = /*#__PURE__*/forwardRef((_ref2, ref) => {
85
93
  value,
86
94
  ...rest
87
95
  } = _ref2;
88
- // The wrapped input is mostly responsible for controlled vs uncontrolled handling,
96
+ const {
97
+ color: resultsTextColor
98
+ } = useThemeTokens('Search', {}, {
99
+ focus: true
100
+ }); // The wrapped input is mostly responsible for controlled vs uncontrolled handling,
89
101
  // but we also need to adjust suggestions based on the mode:
90
102
  // - in controlled mode we rely entirely on the suggestions passed via the `items` prop,
91
103
  // - in uncontrolled mode we filter the suggestions ourselves based on the `initialItems`
92
104
  // prop and the text entered
105
+
93
106
  const isControlled = value !== undefined; // We need to store current items for uncontrolled usage
94
107
 
95
108
  const [currentItems, setCurrentItems] = useState(initialItems); // We need to store the current value as well to be able to highlight it
@@ -262,7 +275,7 @@ const Autocomplete = /*#__PURE__*/forwardRef((_ref2, ref) => {
262
275
  }) : /*#__PURE__*/_jsx(Suggestions, {
263
276
  hasResults: getCopy('hasResults'),
264
277
  id: "autocomplete",
265
- items: itemsToSuggest(highlight(isControlled ? items : currentItems, currentValue)),
278
+ items: itemsToSuggest(highlight(isControlled ? items : currentItems, currentValue, resultsTextColor)),
266
279
  noResults: noResults ?? getCopy('noResults'),
267
280
  onClose: handleClose,
268
281
  onSelect: handleSelect,
@@ -139,7 +139,11 @@ const Ribbon = _ref18 => {
139
139
  gradient,
140
140
  fontColor,
141
141
  borderRadiusBottomLeft,
142
- borderRadiusBottomRight
142
+ borderRadiusBottomRight,
143
+ fontName,
144
+ fontWeight,
145
+ fontSize,
146
+ lineHeight
143
147
  } = useThemeTokens('Ribbon', tokens, { ...variant,
144
148
  wrap: shouldWrap
145
149
  });
@@ -170,12 +174,15 @@ const Ribbon = _ref18 => {
170
174
  borderRadiusBottomRight: `${borderRadiusBottomRight}px`,
171
175
  children: /*#__PURE__*/_jsx(Typography, {
172
176
  variant: {
173
- size: 'micro',
174
177
  bold: true,
175
178
  inverse: true
176
179
  },
177
180
  tokens: {
178
- color: fontColor
181
+ color: fontColor,
182
+ fontName,
183
+ fontWeight,
184
+ fontSize,
185
+ lineHeight
179
186
  },
180
187
  children: children
181
188
  })
package/package.json CHANGED
@@ -5,14 +5,14 @@
5
5
  ],
6
6
  "dependencies": {
7
7
  "@gorhom/portal": "^1.0.14",
8
- "@telus-uds/components-base": "1.56.0",
8
+ "@telus-uds/components-base": "1.57.0",
9
9
  "@telus-uds/system-constants": "^1.3.0",
10
10
  "fscreen": "^1.2.0",
11
11
  "lodash.omit": "^4.5.0",
12
12
  "react-dates": "^21.8.0",
13
13
  "react-helmet-async": "^1.3.0",
14
14
  "react-moment-proptypes": "^1.8.1",
15
- "@telus-uds/system-theme-tokens": "^2.39.0",
15
+ "@telus-uds/system-theme-tokens": "^2.40.0",
16
16
  "prop-types": "^15.7.2",
17
17
  "lodash.throttle": "^4.1.1",
18
18
  "react-youtube": "^10.1.0",
@@ -63,5 +63,5 @@
63
63
  "skip": true
64
64
  },
65
65
  "types": "types/index.d.ts",
66
- "version": "2.15.0"
66
+ "version": "2.16.0"
67
67
  }
@@ -11,7 +11,8 @@ import {
11
11
  textInputHandlerProps,
12
12
  Typography,
13
13
  useCopy,
14
- useSafeLayoutEffect
14
+ useSafeLayoutEffect,
15
+ useThemeTokens
15
16
  } from '@telus-uds/components-base'
16
17
  import Listbox from '../Listbox'
17
18
  import { htmlAttrs, useOverlaidPosition } from '../utils'
@@ -34,16 +35,16 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([
34
35
 
35
36
  // Returns JSX to display a bold string `str` with unbolded occurrences of the
36
37
  // `substring` based in the array of `matchIndexes` provided
37
- const highlightAllMatches = (str, substring = '', matchIndexes = []) => (
38
+ const highlightAllMatches = (str, substring = '', matchIndexes = [], resultsTextColor) => (
38
39
  // Wrapping all in bold
39
- <Typography variant={{ bold: false }}>
40
+ <Typography variant={{ bold: false }} tokens={{ color: resultsTextColor }}>
40
41
  {matchIndexes.reduce(
41
42
  (acc, matchIndex, index) => [
42
43
  ...acc,
43
44
  // Add a piece of the string up to the first occurrence of the substring
44
45
  index === 0 && (str.slice(0, matchIndex) ?? ''),
45
46
  // Unbold the occurrence of the substring (while keeping the original casing)
46
- <Typography key={matchIndex} variant={{ bold: true }}>
47
+ <Typography key={matchIndex} variant={{ bold: true }} tokens={{ color: resultsTextColor }}>
47
48
  {str.slice(matchIndex, matchIndex + substring.length)}
48
49
  </Typography>,
49
50
  // Add the rest of the string until the next occurrence or the end of it
@@ -53,14 +54,14 @@ const highlightAllMatches = (str, substring = '', matchIndexes = []) => (
53
54
  )}
54
55
  </Typography>
55
56
  )
56
- const highlight = (items = [], text = '') =>
57
+ const highlight = (items = [], text = '', color) =>
57
58
  items.reduce((acc, item) => {
58
59
  const matches = Array.from(item.label.toLowerCase().matchAll(text.toLowerCase()))?.map(
59
60
  ({ index }) => index
60
61
  )
61
62
 
62
63
  if (matches?.length) {
63
- return [...acc, { ...item, label: highlightAllMatches(item.label, text, matches) }]
64
+ return [...acc, { ...item, label: highlightAllMatches(item.label, text, matches, color) }]
64
65
  }
65
66
 
66
67
  return [...acc, item]
@@ -89,6 +90,7 @@ const Autocomplete = forwardRef(
89
90
  },
90
91
  ref
91
92
  ) => {
93
+ const { color: resultsTextColor } = useThemeTokens('Search', {}, { focus: true })
92
94
  // The wrapped input is mostly responsible for controlled vs uncontrolled handling,
93
95
  // but we also need to adjust suggestions based on the mode:
94
96
  // - in controlled mode we rely entirely on the suggestions passed via the `items` prop,
@@ -254,7 +256,7 @@ const Autocomplete = forwardRef(
254
256
  hasResults={getCopy('hasResults')}
255
257
  id="autocomplete"
256
258
  items={itemsToSuggest(
257
- highlight(isControlled ? items : currentItems, currentValue)
259
+ highlight(isControlled ? items : currentItems, currentValue, resultsTextColor)
258
260
  )}
259
261
  noResults={noResults ?? getCopy('noResults')}
260
262
  onClose={handleClose}
@@ -76,7 +76,11 @@ const Ribbon = ({
76
76
  gradient,
77
77
  fontColor,
78
78
  borderRadiusBottomLeft,
79
- borderRadiusBottomRight
79
+ borderRadiusBottomRight,
80
+ fontName,
81
+ fontWeight,
82
+ fontSize,
83
+ lineHeight
80
84
  } = useThemeTokens('Ribbon', tokens, { ...variant, wrap: shouldWrap })
81
85
 
82
86
  let background = backgroundColor
@@ -97,8 +101,14 @@ const Ribbon = ({
97
101
  borderRadiusBottomRight={`${borderRadiusBottomRight}px`}
98
102
  >
99
103
  <Typography
100
- variant={{ size: 'micro', bold: true, inverse: true }}
101
- tokens={{ color: fontColor }}
104
+ variant={{ bold: true, inverse: true }}
105
+ tokens={{
106
+ color: fontColor,
107
+ fontName,
108
+ fontWeight,
109
+ fontSize,
110
+ lineHeight
111
+ }}
102
112
  >
103
113
  {children}
104
114
  </Typography>