@telus-uds/components-base 1.67.1 → 1.69.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,37 @@
1
1
  # Change Log - @telus-uds/components-base
2
2
 
3
- This log was last generated on Fri, 10 Nov 2023 22:28:25 GMT and should not be manually modified.
3
+ This log was last generated on Sat, 18 Nov 2023 02:25:11 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.69.0
8
+
9
+ Sat, 18 Nov 2023 02:25:11 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - updating notification stories (srikanthkhari@gmail.com)
14
+ - Bump @telus-uds/system-theme-tokens to v2.46.0
15
+
16
+ ### Patches
17
+
18
+ - `TermsAndConditions`: Fix unexpected state handling in `ExpandCollapse.Panel` (shahzaibkhalidmalik@outlook.com)
19
+ - fixes to getIcon method for card variant in TextInput (email not defined)
20
+ - removing koodo rebrand iconset from supports (srikanthkhari@gmail.com)
21
+
22
+ ## 1.68.0
23
+
24
+ Wed, 15 Nov 2023 18:45:58 GMT
25
+
26
+ ### Minor changes
27
+
28
+ - refactor badge component for multiplatform (guillermo.peitzner@telus.com)
29
+ - Changes to improve alignment and icon sizing (35577399+JoshHC@users.noreply.github.com)
30
+ - Bump @telus-uds/system-theme-tokens to v2.45.0
31
+
7
32
  ## 1.67.1
8
33
 
9
- Fri, 10 Nov 2023 22:28:25 GMT
34
+ Fri, 10 Nov 2023 22:37:27 GMT
10
35
 
11
36
  ### Patches
12
37
 
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
9
+ var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
10
+ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
11
+ var _propTypes = _interopRequireDefault(require("prop-types"));
12
+ var _ThemeProvider = require("../ThemeProvider");
13
+ var _Typography = _interopRequireDefault(require("../Typography"));
14
+ var _utils = require("../utils");
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+ 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); }
18
+ 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; }
19
+ const fontSizeMapping = {
20
+ 12: 'micro',
21
+ 14: 'small',
22
+ 16: 'h6'
23
+ };
24
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.htmlAttrs, _utils.viewProps]);
25
+ const selectContainerBackground = _ref => {
26
+ let {
27
+ backgroundColor
28
+ } = _ref;
29
+ return {
30
+ backgroundColor
31
+ };
32
+ };
33
+ const selectContainerBorder = _ref2 => {
34
+ let {
35
+ borderWidth,
36
+ borderColor,
37
+ borderRadius
38
+ } = _ref2;
39
+ return {
40
+ borderWidth,
41
+ borderColor,
42
+ borderRadius
43
+ };
44
+ };
45
+ const selectContainerPadding = _ref3 => {
46
+ let {
47
+ paddingTop,
48
+ paddingRight,
49
+ paddingBottom,
50
+ paddingLeft
51
+ } = _ref3;
52
+ return {
53
+ paddingTop,
54
+ paddingRight,
55
+ paddingBottom,
56
+ paddingLeft
57
+ };
58
+ };
59
+ const getTypographyTokens = _ref4 => {
60
+ let {
61
+ fontName,
62
+ fontWeight,
63
+ color
64
+ } = _ref4;
65
+ return {
66
+ fontName,
67
+ fontWeight,
68
+ color
69
+ };
70
+ };
71
+ const getTypographyVariant = _ref5 => {
72
+ let {
73
+ fontSize
74
+ } = _ref5;
75
+ return {
76
+ size: fontSizeMapping[fontSize]
77
+ };
78
+ };
79
+ const Badge = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
80
+ let {
81
+ children,
82
+ tokens,
83
+ variant = {},
84
+ ...rest
85
+ } = _ref6;
86
+ const themeTokens = (0, _ThemeProvider.useThemeTokens)('Badge', tokens, variant);
87
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
88
+ ref: ref,
89
+ style: _Platform.default.select({
90
+ native: {
91
+ ...staticStyles.container,
92
+ ...selectContainerBackground(themeTokens),
93
+ ...selectContainerBorder(themeTokens),
94
+ ...selectContainerPadding(themeTokens)
95
+ },
96
+ web: {}
97
+ }),
98
+ ...selectProps(rest),
99
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
100
+ tokens: getTypographyTokens(themeTokens),
101
+ variant: getTypographyVariant(themeTokens),
102
+ children: children
103
+ })
104
+ });
105
+ });
106
+ Badge.propTypes = {
107
+ ...selectedSystemPropTypes,
108
+ children: _propTypes.default.node,
109
+ tokens: (0, _utils.getTokensPropType)('Badge'),
110
+ variant: _utils.variantProp.propType
111
+ };
112
+ Badge.displayName = 'Badge';
113
+ var _default = Badge;
114
+ exports.default = _default;
115
+ const staticStyles = _StyleSheet.default.create({
116
+ container: {
117
+ display: 'flex',
118
+ justifyContent: 'center',
119
+ alignSelf: 'flex-start'
120
+ }
121
+ });
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _Badge = _interopRequireDefault(require("./Badge"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ var _default = _Badge.default;
10
+ exports.default = _default;
@@ -174,7 +174,7 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) =>
174
174
  },
175
175
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
176
176
  style: selectContainerStyles(themeTokens),
177
- children: children
177
+ children: isExpanded ? children : null
178
178
  })
179
179
  })
180
180
  })]
@@ -67,7 +67,8 @@ const ListItemContent = _ref2 => {
67
67
  };
68
68
  const staticStyles = _StyleSheet.default.create({
69
69
  wrap: {
70
- flex: 1
70
+ flex: 1,
71
+ justifyContent: 'center'
71
72
  }
72
73
  });
73
74
  ListItemContent.propTypes = {
@@ -8,6 +8,7 @@ var _react = _interopRequireDefault(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
10
10
  var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
11
+ var _Icon = _interopRequireDefault(require("../Icon"));
11
12
  var _jsxRuntime = require("react/jsx-runtime");
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14
  const tokenTypes = {
@@ -48,24 +49,11 @@ const selectBulletPositioningStyles = _ref3 => {
48
49
  height: itemIconSize
49
50
  };
50
51
  };
51
- const selectBulletStyles = _ref4 => {
52
- let {
53
- itemBulletWidth,
54
- itemBulletHeight,
55
- itemBulletColor
56
- } = _ref4;
57
- return {
58
- width: itemBulletWidth,
59
- height: itemBulletHeight,
60
- borderRadius: itemBulletHeight / 2,
61
- backgroundColor: itemBulletColor
62
- };
63
- };
64
- const selectBulletContainerStyles = _ref5 => {
52
+ const selectBulletContainerStyles = _ref4 => {
65
53
  let {
66
54
  itemBulletContainerWidth,
67
55
  itemBulletContainerAlign
68
- } = _ref5;
56
+ } = _ref4;
69
57
  return {
70
58
  width: itemBulletContainerWidth,
71
59
  alignItems: itemBulletContainerAlign
@@ -79,13 +67,13 @@ const selectBulletContainerStyles = _ref5 => {
79
67
  * It's the responsibility of themes to make sure that the supplied tokens align the
80
68
  * icon or bullet nicely against the first line of text in a ListIconContent.
81
69
  */
82
- const ListItemMark = _ref6 => {
70
+ const ListItemMark = _ref5 => {
83
71
  let {
84
72
  icon,
85
73
  iconColor,
86
74
  iconSize,
87
75
  tokens = {}
88
- } = _ref6;
76
+ } = _ref5;
89
77
  const IconComponent = icon || /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
90
78
  const themeTokens = typeof tokens === 'function' ? tokens() : tokens;
91
79
  const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens);
@@ -99,16 +87,22 @@ const ListItemMark = _ref6 => {
99
87
  })
100
88
  });
101
89
  }
90
+ const bulletColor = themeTokens.itemBulletColor;
91
+ const {
92
+ bulletIcon
93
+ } = themeTokens;
102
94
  const itemBulletContainerStyles = selectBulletContainerStyles(themeTokens);
103
- const itemBulletStyles = selectBulletStyles(themeTokens);
104
95
  const itemBulletPositioningStyles = selectBulletPositioningStyles(themeTokens);
105
96
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
106
97
  style: [sideItemContainerStyles, itemBulletContainerStyles],
107
98
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
108
99
  style: [staticStyles.bulletPositioning, itemBulletPositioningStyles],
109
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
110
- style: itemBulletStyles,
111
- testID: "unordered-item-bullet"
100
+ testID: "unordered-item-bullet",
101
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
102
+ icon: bulletIcon,
103
+ tokens: {
104
+ color: bulletColor
105
+ }
112
106
  })
113
107
  })
114
108
  });
@@ -152,26 +152,29 @@ const getIcon = function () {
152
152
  visaIcon,
153
153
  masterCardIcon
154
154
  } = arguments.length > 1 ? arguments[1] : undefined;
155
- const cardType = {
156
- 1: {
157
- icon: visaIcon,
158
- testID: 'visa'
159
- },
160
- 2: {
161
- icon: amexIcon,
162
- testID: 'amex'
163
- },
164
- 4: {
165
- icon: masterCardIcon,
166
- testID: 'mastercard'
167
- }
168
- };
169
- const firstDigit = cardNumber ? cardNumber[0] : '';
170
- const defaultIcon = {
155
+ const sanitizedCardNumber = cardNumber.replace(/[^0-9]/g, '');
156
+ const firstFourDigits = sanitizedCardNumber.slice(0, 4);
157
+ const number = Number(firstFourDigits);
158
+ const visaRange = number >= 4000 && number <= 4999;
159
+ const amexRange = number >= 3400 && number <= 3499 || number >= 3700 && number <= 3799;
160
+ const masterCardRange = number >= 5100 && number <= 5599 || number >= 2221 && number <= 2720;
161
+ let selectedIcon = {
171
162
  icon: defaultCreditIcon,
172
163
  testID: 'default'
173
164
  };
174
- const selectedIcon = cardNumber.length > 4 ? cardType[firstDigit] || defaultIcon : defaultIcon;
165
+ const objVisaIcon = {
166
+ icon: visaIcon,
167
+ testID: 'visa'
168
+ };
169
+ const objAmexIcon = {
170
+ icon: amexIcon,
171
+ testID: 'amex'
172
+ };
173
+ const objMasterCardIcon = {
174
+ icon: masterCardIcon,
175
+ testID: 'mastercard'
176
+ };
177
+ if (visaRange) selectedIcon = objVisaIcon;else if (amexRange) selectedIcon = objAmexIcon;else if (masterCardRange) selectedIcon = objMasterCardIcon;
175
178
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
176
179
  icon: selectedIcon.icon,
177
180
  variant: {
package/lib/index.js CHANGED
@@ -8,6 +8,7 @@ var _exportNames = {
8
8
  ActivityIndicator: true,
9
9
  Autocomplete: true,
10
10
  Box: true,
11
+ Badge: true,
11
12
  Card: true,
12
13
  PressableCardBase: true,
13
14
  Listbox: true,
@@ -101,6 +102,12 @@ Object.defineProperty(exports, "Autocomplete", {
101
102
  return _Autocomplete.default;
102
103
  }
103
104
  });
105
+ Object.defineProperty(exports, "Badge", {
106
+ enumerable: true,
107
+ get: function () {
108
+ return _Badge.default;
109
+ }
110
+ });
104
111
  Object.defineProperty(exports, "BaseProvider", {
105
112
  enumerable: true,
106
113
  get: function () {
@@ -471,6 +478,7 @@ var _A11yText = _interopRequireDefault(require("./A11yText"));
471
478
  var _ActivityIndicator = _interopRequireDefault(require("./ActivityIndicator"));
472
479
  var _Autocomplete = _interopRequireDefault(require("./Autocomplete"));
473
480
  var _Box = _interopRequireDefault(require("./Box"));
481
+ var _Badge = _interopRequireDefault(require("./Badge"));
474
482
  var _Button = require("./Button");
475
483
  Object.keys(_Button).forEach(function (key) {
476
484
  if (key === "default" || key === "__esModule") return;
@@ -0,0 +1,111 @@
1
+ import React, { forwardRef } from 'react';
2
+ import View from "react-native-web/dist/exports/View";
3
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
4
+ import Platform from "react-native-web/dist/exports/Platform";
5
+ import PropTypes from 'prop-types';
6
+ import { useThemeTokens } from '../ThemeProvider';
7
+ import Typography from '../Typography';
8
+ import { htmlAttrs, selectSystemProps, getTokensPropType, variantProp, viewProps } from '../utils';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ const fontSizeMapping = {
11
+ 12: 'micro',
12
+ 14: 'small',
13
+ 16: 'h6'
14
+ };
15
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs, viewProps]);
16
+ const selectContainerBackground = _ref => {
17
+ let {
18
+ backgroundColor
19
+ } = _ref;
20
+ return {
21
+ backgroundColor
22
+ };
23
+ };
24
+ const selectContainerBorder = _ref2 => {
25
+ let {
26
+ borderWidth,
27
+ borderColor,
28
+ borderRadius
29
+ } = _ref2;
30
+ return {
31
+ borderWidth,
32
+ borderColor,
33
+ borderRadius
34
+ };
35
+ };
36
+ const selectContainerPadding = _ref3 => {
37
+ let {
38
+ paddingTop,
39
+ paddingRight,
40
+ paddingBottom,
41
+ paddingLeft
42
+ } = _ref3;
43
+ return {
44
+ paddingTop,
45
+ paddingRight,
46
+ paddingBottom,
47
+ paddingLeft
48
+ };
49
+ };
50
+ const getTypographyTokens = _ref4 => {
51
+ let {
52
+ fontName,
53
+ fontWeight,
54
+ color
55
+ } = _ref4;
56
+ return {
57
+ fontName,
58
+ fontWeight,
59
+ color
60
+ };
61
+ };
62
+ const getTypographyVariant = _ref5 => {
63
+ let {
64
+ fontSize
65
+ } = _ref5;
66
+ return {
67
+ size: fontSizeMapping[fontSize]
68
+ };
69
+ };
70
+ const Badge = /*#__PURE__*/forwardRef((_ref6, ref) => {
71
+ let {
72
+ children,
73
+ tokens,
74
+ variant = {},
75
+ ...rest
76
+ } = _ref6;
77
+ const themeTokens = useThemeTokens('Badge', tokens, variant);
78
+ return /*#__PURE__*/_jsx(View, {
79
+ ref: ref,
80
+ style: Platform.select({
81
+ native: {
82
+ ...staticStyles.container,
83
+ ...selectContainerBackground(themeTokens),
84
+ ...selectContainerBorder(themeTokens),
85
+ ...selectContainerPadding(themeTokens)
86
+ },
87
+ web: {}
88
+ }),
89
+ ...selectProps(rest),
90
+ children: /*#__PURE__*/_jsx(Typography, {
91
+ tokens: getTypographyTokens(themeTokens),
92
+ variant: getTypographyVariant(themeTokens),
93
+ children: children
94
+ })
95
+ });
96
+ });
97
+ Badge.propTypes = {
98
+ ...selectedSystemPropTypes,
99
+ children: PropTypes.node,
100
+ tokens: getTokensPropType('Badge'),
101
+ variant: variantProp.propType
102
+ };
103
+ Badge.displayName = 'Badge';
104
+ export default Badge;
105
+ const staticStyles = StyleSheet.create({
106
+ container: {
107
+ display: 'flex',
108
+ justifyContent: 'center',
109
+ alignSelf: 'flex-start'
110
+ }
111
+ });
@@ -0,0 +1,2 @@
1
+ import Badge from './Badge';
2
+ export default Badge;
@@ -166,7 +166,7 @@ const ExpandCollapsePanel = /*#__PURE__*/forwardRef((_ref4, ref) => {
166
166
  },
167
167
  children: /*#__PURE__*/_jsx(View, {
168
168
  style: selectContainerStyles(themeTokens),
169
- children: children
169
+ children: isExpanded ? children : null
170
170
  })
171
171
  })
172
172
  })]
@@ -59,7 +59,8 @@ const ListItemContent = _ref2 => {
59
59
  };
60
60
  const staticStyles = StyleSheet.create({
61
61
  wrap: {
62
- flex: 1
62
+ flex: 1,
63
+ justifyContent: 'center'
63
64
  }
64
65
  });
65
66
  ListItemContent.propTypes = {
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import View from "react-native-web/dist/exports/View";
4
4
  import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
+ import Icon from '../Icon';
5
6
  import { Fragment as _Fragment } from "react/jsx-runtime";
6
7
  import { jsx as _jsx } from "react/jsx-runtime";
7
8
  export const tokenTypes = {
@@ -41,24 +42,11 @@ const selectBulletPositioningStyles = _ref3 => {
41
42
  height: itemIconSize
42
43
  };
43
44
  };
44
- const selectBulletStyles = _ref4 => {
45
- let {
46
- itemBulletWidth,
47
- itemBulletHeight,
48
- itemBulletColor
49
- } = _ref4;
50
- return {
51
- width: itemBulletWidth,
52
- height: itemBulletHeight,
53
- borderRadius: itemBulletHeight / 2,
54
- backgroundColor: itemBulletColor
55
- };
56
- };
57
- const selectBulletContainerStyles = _ref5 => {
45
+ const selectBulletContainerStyles = _ref4 => {
58
46
  let {
59
47
  itemBulletContainerWidth,
60
48
  itemBulletContainerAlign
61
- } = _ref5;
49
+ } = _ref4;
62
50
  return {
63
51
  width: itemBulletContainerWidth,
64
52
  alignItems: itemBulletContainerAlign
@@ -72,13 +60,13 @@ const selectBulletContainerStyles = _ref5 => {
72
60
  * It's the responsibility of themes to make sure that the supplied tokens align the
73
61
  * icon or bullet nicely against the first line of text in a ListIconContent.
74
62
  */
75
- const ListItemMark = _ref6 => {
63
+ const ListItemMark = _ref5 => {
76
64
  let {
77
65
  icon,
78
66
  iconColor,
79
67
  iconSize,
80
68
  tokens = {}
81
- } = _ref6;
69
+ } = _ref5;
82
70
  const IconComponent = icon || /*#__PURE__*/_jsx(_Fragment, {});
83
71
  const themeTokens = typeof tokens === 'function' ? tokens() : tokens;
84
72
  const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens);
@@ -92,16 +80,22 @@ const ListItemMark = _ref6 => {
92
80
  })
93
81
  });
94
82
  }
83
+ const bulletColor = themeTokens.itemBulletColor;
84
+ const {
85
+ bulletIcon
86
+ } = themeTokens;
95
87
  const itemBulletContainerStyles = selectBulletContainerStyles(themeTokens);
96
- const itemBulletStyles = selectBulletStyles(themeTokens);
97
88
  const itemBulletPositioningStyles = selectBulletPositioningStyles(themeTokens);
98
89
  return /*#__PURE__*/_jsx(View, {
99
90
  style: [sideItemContainerStyles, itemBulletContainerStyles],
100
91
  children: /*#__PURE__*/_jsx(View, {
101
92
  style: [staticStyles.bulletPositioning, itemBulletPositioningStyles],
102
- children: /*#__PURE__*/_jsx(View, {
103
- style: itemBulletStyles,
104
- testID: "unordered-item-bullet"
93
+ testID: "unordered-item-bullet",
94
+ children: /*#__PURE__*/_jsx(Icon, {
95
+ icon: bulletIcon,
96
+ tokens: {
97
+ color: bulletColor
98
+ }
105
99
  })
106
100
  })
107
101
  });
@@ -144,26 +144,29 @@ const getIcon = function () {
144
144
  visaIcon,
145
145
  masterCardIcon
146
146
  } = arguments.length > 1 ? arguments[1] : undefined;
147
- const cardType = {
148
- 1: {
149
- icon: visaIcon,
150
- testID: 'visa'
151
- },
152
- 2: {
153
- icon: amexIcon,
154
- testID: 'amex'
155
- },
156
- 4: {
157
- icon: masterCardIcon,
158
- testID: 'mastercard'
159
- }
160
- };
161
- const firstDigit = cardNumber ? cardNumber[0] : '';
162
- const defaultIcon = {
147
+ const sanitizedCardNumber = cardNumber.replace(/[^0-9]/g, '');
148
+ const firstFourDigits = sanitizedCardNumber.slice(0, 4);
149
+ const number = Number(firstFourDigits);
150
+ const visaRange = number >= 4000 && number <= 4999;
151
+ const amexRange = number >= 3400 && number <= 3499 || number >= 3700 && number <= 3799;
152
+ const masterCardRange = number >= 5100 && number <= 5599 || number >= 2221 && number <= 2720;
153
+ let selectedIcon = {
163
154
  icon: defaultCreditIcon,
164
155
  testID: 'default'
165
156
  };
166
- const selectedIcon = cardNumber.length > 4 ? cardType[firstDigit] || defaultIcon : defaultIcon;
157
+ const objVisaIcon = {
158
+ icon: visaIcon,
159
+ testID: 'visa'
160
+ };
161
+ const objAmexIcon = {
162
+ icon: amexIcon,
163
+ testID: 'amex'
164
+ };
165
+ const objMasterCardIcon = {
166
+ icon: masterCardIcon,
167
+ testID: 'mastercard'
168
+ };
169
+ if (visaRange) selectedIcon = objVisaIcon;else if (amexRange) selectedIcon = objAmexIcon;else if (masterCardRange) selectedIcon = objMasterCardIcon;
167
170
  return /*#__PURE__*/_jsx(Icon, {
168
171
  icon: selectedIcon.icon,
169
172
  variant: {
@@ -2,6 +2,7 @@ export { default as A11yText } from './A11yText';
2
2
  export { default as ActivityIndicator } from './ActivityIndicator';
3
3
  export { default as Autocomplete } from './Autocomplete';
4
4
  export { default as Box } from './Box';
5
+ export { default as Badge } from './Badge';
5
6
  export * from './Button';
6
7
  export { default as Card, PressableCardBase } from './Card';
7
8
  export * from './Carousel';
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "@floating-ui/react-native": "^0.8.1",
12
12
  "@gorhom/portal": "^1.0.14",
13
13
  "@telus-uds/system-constants": "^1.3.0",
14
- "@telus-uds/system-theme-tokens": "^2.44.1",
14
+ "@telus-uds/system-theme-tokens": "^2.46.0",
15
15
  "airbnb-prop-types": "^2.16.0",
16
16
  "lodash.debounce": "^4.0.8",
17
17
  "lodash.merge": "^4.6.2",
@@ -73,5 +73,5 @@
73
73
  "standard-engine": {
74
74
  "skip": true
75
75
  },
76
- "version": "1.67.1"
76
+ "version": "1.69.0"
77
77
  }
@@ -0,0 +1,79 @@
1
+ import React, { forwardRef } from 'react'
2
+ import { View, StyleSheet, Platform } from 'react-native'
3
+ import PropTypes from 'prop-types'
4
+ import { useThemeTokens } from '../ThemeProvider'
5
+ import Typography from '../Typography'
6
+ import { htmlAttrs, selectSystemProps, getTokensPropType, variantProp, viewProps } from '../utils'
7
+
8
+ const fontSizeMapping = {
9
+ 12: 'micro',
10
+ 14: 'small',
11
+ 16: 'h6'
12
+ }
13
+
14
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs, viewProps])
15
+
16
+ const selectContainerBackground = ({ backgroundColor }) => ({ backgroundColor })
17
+
18
+ const selectContainerBorder = ({ borderWidth, borderColor, borderRadius }) => ({
19
+ borderWidth,
20
+ borderColor,
21
+ borderRadius
22
+ })
23
+
24
+ const selectContainerPadding = ({ paddingTop, paddingRight, paddingBottom, paddingLeft }) => ({
25
+ paddingTop,
26
+ paddingRight,
27
+ paddingBottom,
28
+ paddingLeft
29
+ })
30
+
31
+ const getTypographyTokens = ({ fontName, fontWeight, color }) => ({ fontName, fontWeight, color })
32
+
33
+ const getTypographyVariant = ({ fontSize }) => ({ size: fontSizeMapping[fontSize] })
34
+
35
+ const Badge = forwardRef(({ children, tokens, variant = {}, ...rest }, ref) => {
36
+ const themeTokens = useThemeTokens('Badge', tokens, variant)
37
+
38
+ return (
39
+ <View
40
+ ref={ref}
41
+ style={Platform.select({
42
+ native: {
43
+ ...staticStyles.container,
44
+ ...selectContainerBackground(themeTokens),
45
+ ...selectContainerBorder(themeTokens),
46
+ ...selectContainerPadding(themeTokens)
47
+ },
48
+ web: {}
49
+ })}
50
+ {...selectProps(rest)}
51
+ >
52
+ <Typography
53
+ tokens={getTypographyTokens(themeTokens)}
54
+ variant={getTypographyVariant(themeTokens)}
55
+ >
56
+ {children}
57
+ </Typography>
58
+ </View>
59
+ )
60
+ })
61
+
62
+ Badge.propTypes = {
63
+ ...selectedSystemPropTypes,
64
+ children: PropTypes.node,
65
+ tokens: getTokensPropType('Badge'),
66
+ variant: variantProp.propType
67
+ }
68
+
69
+ Badge.displayName = 'Badge'
70
+
71
+ export default Badge
72
+
73
+ const staticStyles = StyleSheet.create({
74
+ container: {
75
+ display: 'flex',
76
+ justifyContent: 'center',
77
+ alignSelf: 'flex-start'
78
+ }
79
+ })
@@ -0,0 +1,3 @@
1
+ import Badge from './Badge'
2
+
3
+ export default Badge
@@ -168,7 +168,7 @@ const ExpandCollapsePanel = forwardRef(
168
168
  })
169
169
  }}
170
170
  >
171
- <View style={selectContainerStyles(themeTokens)}>{children}</View>
171
+ <View style={selectContainerStyles(themeTokens)}>{isExpanded ? children : null}</View>
172
172
  </View>
173
173
  </Animated.View>
174
174
  </View>
@@ -54,7 +54,8 @@ const ListItemContent = ({ tokens, children }) => {
54
54
 
55
55
  const staticStyles = StyleSheet.create({
56
56
  wrap: {
57
- flex: 1
57
+ flex: 1,
58
+ justifyContent: 'center'
58
59
  }
59
60
  })
60
61
 
@@ -2,6 +2,7 @@ import React from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
 
4
4
  import { View, StyleSheet } from 'react-native'
5
+ import Icon from '../Icon'
5
6
 
6
7
  export const tokenTypes = {
7
8
  itemIconSize: PropTypes.number.isRequired,
@@ -26,13 +27,6 @@ const selectBulletPositioningStyles = ({ itemIconSize }) => ({
26
27
  height: itemIconSize
27
28
  })
28
29
 
29
- const selectBulletStyles = ({ itemBulletWidth, itemBulletHeight, itemBulletColor }) => ({
30
- width: itemBulletWidth,
31
- height: itemBulletHeight,
32
- borderRadius: itemBulletHeight / 2,
33
- backgroundColor: itemBulletColor
34
- })
35
-
36
30
  const selectBulletContainerStyles = ({ itemBulletContainerWidth, itemBulletContainerAlign }) => ({
37
31
  width: itemBulletContainerWidth,
38
32
  alignItems: itemBulletContainerAlign
@@ -61,13 +55,18 @@ const ListItemMark = ({ icon, iconColor, iconSize, tokens = {} }) => {
61
55
  )
62
56
  }
63
57
 
58
+ const bulletColor = themeTokens.itemBulletColor
59
+ const { bulletIcon } = themeTokens
64
60
  const itemBulletContainerStyles = selectBulletContainerStyles(themeTokens)
65
- const itemBulletStyles = selectBulletStyles(themeTokens)
66
61
  const itemBulletPositioningStyles = selectBulletPositioningStyles(themeTokens)
62
+
67
63
  return (
68
64
  <View style={[sideItemContainerStyles, itemBulletContainerStyles]}>
69
- <View style={[staticStyles.bulletPositioning, itemBulletPositioningStyles]}>
70
- <View style={itemBulletStyles} testID="unordered-item-bullet" />
65
+ <View
66
+ style={[staticStyles.bulletPositioning, itemBulletPositioningStyles]}
67
+ testID="unordered-item-bullet"
68
+ >
69
+ <Icon icon={bulletIcon} tokens={{ color: bulletColor }} />
71
70
  </View>
72
71
  </View>
73
72
  )
@@ -141,15 +141,23 @@ const selectButtonsContainerStyle = ({ buttonsPaddingRight }) => ({
141
141
  })
142
142
 
143
143
  const getIcon = (cardNumber = '', { defaultCreditIcon, amexIcon, visaIcon, masterCardIcon }) => {
144
- const cardType = {
145
- 1: { icon: visaIcon, testID: 'visa' },
146
- 2: { icon: amexIcon, testID: 'amex' },
147
- 4: { icon: masterCardIcon, testID: 'mastercard' }
148
- }
144
+ const sanitizedCardNumber = cardNumber.replace(/[^0-9]/g, '')
145
+ const firstFourDigits = sanitizedCardNumber.slice(0, 4)
146
+ const number = Number(firstFourDigits)
147
+
148
+ const visaRange = number >= 4000 && number <= 4999
149
+ const amexRange = (number >= 3400 && number <= 3499) || (number >= 3700 && number <= 3799)
150
+ const masterCardRange = (number >= 5100 && number <= 5599) || (number >= 2221 && number <= 2720)
151
+
152
+ let selectedIcon = { icon: defaultCreditIcon, testID: 'default' }
153
+ const objVisaIcon = { icon: visaIcon, testID: 'visa' }
154
+ const objAmexIcon = { icon: amexIcon, testID: 'amex' }
155
+ const objMasterCardIcon = { icon: masterCardIcon, testID: 'mastercard' }
156
+
157
+ if (visaRange) selectedIcon = objVisaIcon
158
+ else if (amexRange) selectedIcon = objAmexIcon
159
+ else if (masterCardRange) selectedIcon = objMasterCardIcon
149
160
 
150
- const firstDigit = cardNumber ? cardNumber[0] : ''
151
- const defaultIcon = { icon: defaultCreditIcon, testID: 'default' }
152
- const selectedIcon = cardNumber.length > 4 ? cardType[firstDigit] || defaultIcon : defaultIcon
153
161
  return <Icon icon={selectedIcon.icon} variant={{ size: 'large' }} testID={selectedIcon.testID} />
154
162
  }
155
163
 
package/src/index.js CHANGED
@@ -2,6 +2,7 @@ export { default as A11yText } from './A11yText'
2
2
  export { default as ActivityIndicator } from './ActivityIndicator'
3
3
  export { default as Autocomplete } from './Autocomplete'
4
4
  export { default as Box } from './Box'
5
+ export { default as Badge } from './Badge'
5
6
  export * from './Button'
6
7
  export { default as Card, PressableCardBase } from './Card'
7
8
  export * from './Carousel'