@telus-uds/components-base 1.12.0 → 1.14.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 (132) hide show
  1. package/CHANGELOG.md +41 -2
  2. package/component-docs.json +933 -55
  3. package/lib/BaseProvider/index.js +7 -2
  4. package/lib/Button/ButtonBase.js +52 -19
  5. package/lib/Button/ButtonGroup.js +7 -0
  6. package/lib/Button/propTypes.js +18 -0
  7. package/lib/Carousel/Carousel.js +83 -58
  8. package/lib/Carousel/CarouselContext.js +22 -8
  9. package/lib/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +73 -0
  10. package/lib/Carousel/CarouselStepTracker/CarouselStepTracker.js +56 -0
  11. package/lib/Carousel/CarouselStepTracker/index.js +13 -0
  12. package/lib/Carousel/CarouselTabs/CarouselTabs.js +70 -0
  13. package/lib/Carousel/CarouselTabs/CarouselTabsPanel.js +95 -0
  14. package/lib/Carousel/CarouselTabs/CarouselTabsPanelItem.js +148 -0
  15. package/lib/Carousel/CarouselTabs/index.js +13 -0
  16. package/lib/Carousel/CarouselThumbnail.js +99 -0
  17. package/lib/Carousel/CarouselThumbnailNavigation.js +87 -0
  18. package/lib/Carousel/dictionary.js +4 -2
  19. package/lib/Carousel/index.js +10 -1
  20. package/lib/Checkbox/Checkbox.js +7 -3
  21. package/lib/Checkbox/CheckboxGroup.js +8 -1
  22. package/lib/Feedback/Feedback.js +18 -10
  23. package/lib/Icon/IconText.js +6 -1
  24. package/lib/InputLabel/InputLabel.js +11 -5
  25. package/lib/Link/InlinePressable.js +1 -8
  26. package/lib/Link/LinkBase.js +13 -10
  27. package/lib/List/ListItem.js +8 -4
  28. package/lib/Notification/Notification.js +44 -24
  29. package/lib/Pagination/Pagination.js +7 -3
  30. package/lib/Radio/RadioGroup.js +8 -0
  31. package/lib/RadioCard/RadioCard.js +6 -1
  32. package/lib/RadioCard/RadioCardGroup.js +7 -0
  33. package/lib/Select/Select.js +7 -3
  34. package/lib/SkipLink/SkipLink.js +216 -0
  35. package/lib/SkipLink/index.js +13 -0
  36. package/lib/StepTracker/Step.js +8 -4
  37. package/lib/StepTracker/StepTracker.js +7 -3
  38. package/lib/Tabs/TabsItem.js +4 -0
  39. package/lib/TextInput/TextInputBase.js +7 -3
  40. package/lib/ThemeProvider/ThemeProvider.js +25 -3
  41. package/lib/ThemeProvider/utils/styles.js +8 -1
  42. package/lib/ThemeProvider/utils/theme-tokens.js +1 -1
  43. package/lib/ToggleSwitch/ToggleSwitchGroup.js +7 -0
  44. package/lib/Typography/Typography.js +6 -2
  45. package/lib/index.js +9 -0
  46. package/lib-module/BaseProvider/index.js +7 -2
  47. package/lib-module/Button/ButtonBase.js +41 -9
  48. package/lib-module/Button/ButtonGroup.js +7 -0
  49. package/lib-module/Button/propTypes.js +17 -0
  50. package/lib-module/Carousel/Carousel.js +80 -57
  51. package/lib-module/Carousel/CarouselContext.js +21 -8
  52. package/lib-module/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +51 -0
  53. package/lib-module/Carousel/CarouselStepTracker/CarouselStepTracker.js +42 -0
  54. package/lib-module/Carousel/CarouselStepTracker/index.js +2 -0
  55. package/lib-module/Carousel/CarouselTabs/CarouselTabs.js +50 -0
  56. package/lib-module/Carousel/CarouselTabs/CarouselTabsPanel.js +76 -0
  57. package/lib-module/Carousel/CarouselTabs/CarouselTabsPanelItem.js +126 -0
  58. package/lib-module/Carousel/CarouselTabs/index.js +2 -0
  59. package/lib-module/Carousel/CarouselThumbnail.js +85 -0
  60. package/lib-module/Carousel/CarouselThumbnailNavigation.js +66 -0
  61. package/lib-module/Carousel/dictionary.js +4 -2
  62. package/lib-module/Carousel/index.js +2 -1
  63. package/lib-module/Checkbox/Checkbox.js +8 -4
  64. package/lib-module/Checkbox/CheckboxGroup.js +8 -1
  65. package/lib-module/Feedback/Feedback.js +19 -11
  66. package/lib-module/Icon/IconText.js +6 -1
  67. package/lib-module/InputLabel/InputLabel.js +12 -6
  68. package/lib-module/Link/InlinePressable.js +1 -8
  69. package/lib-module/Link/LinkBase.js +14 -11
  70. package/lib-module/List/ListItem.js +9 -5
  71. package/lib-module/Notification/Notification.js +46 -26
  72. package/lib-module/Pagination/Pagination.js +8 -4
  73. package/lib-module/Radio/RadioGroup.js +8 -0
  74. package/lib-module/RadioCard/RadioCard.js +7 -2
  75. package/lib-module/RadioCard/RadioCardGroup.js +7 -0
  76. package/lib-module/Select/Select.js +8 -4
  77. package/lib-module/SkipLink/SkipLink.js +188 -0
  78. package/lib-module/SkipLink/index.js +2 -0
  79. package/lib-module/StepTracker/Step.js +9 -5
  80. package/lib-module/StepTracker/StepTracker.js +8 -4
  81. package/lib-module/Tabs/TabsItem.js +5 -1
  82. package/lib-module/TextInput/TextInputBase.js +8 -4
  83. package/lib-module/ThemeProvider/ThemeProvider.js +24 -3
  84. package/lib-module/ThemeProvider/utils/styles.js +8 -1
  85. package/lib-module/ThemeProvider/utils/theme-tokens.js +1 -1
  86. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +7 -0
  87. package/lib-module/Typography/Typography.js +7 -3
  88. package/lib-module/index.js +1 -0
  89. package/package.json +46 -47
  90. package/src/BaseProvider/index.jsx +6 -3
  91. package/src/Button/ButtonBase.jsx +36 -12
  92. package/src/Button/ButtonGroup.jsx +6 -0
  93. package/src/Button/propTypes.js +14 -0
  94. package/src/Carousel/Carousel.jsx +91 -64
  95. package/src/Carousel/CarouselContext.jsx +29 -5
  96. package/src/Carousel/CarouselFirstFocus/CarouselFirstFocus.jsx +49 -0
  97. package/src/Carousel/CarouselStepTracker/CarouselStepTracker.jsx +36 -0
  98. package/src/Carousel/CarouselStepTracker/index.js +3 -0
  99. package/src/Carousel/CarouselTabs/CarouselTabs.jsx +37 -0
  100. package/src/Carousel/CarouselTabs/CarouselTabsPanel.jsx +69 -0
  101. package/src/Carousel/CarouselTabs/CarouselTabsPanelItem.jsx +119 -0
  102. package/src/Carousel/CarouselTabs/index.js +3 -0
  103. package/src/Carousel/CarouselThumbnail.jsx +77 -0
  104. package/src/Carousel/CarouselThumbnailNavigation.jsx +53 -0
  105. package/src/Carousel/dictionary.js +4 -2
  106. package/src/Carousel/index.js +1 -0
  107. package/src/Checkbox/Checkbox.jsx +14 -11
  108. package/src/Checkbox/CheckboxGroup.jsx +8 -1
  109. package/src/Feedback/Feedback.jsx +14 -7
  110. package/src/Icon/IconText.jsx +3 -1
  111. package/src/InputLabel/InputLabel.jsx +13 -12
  112. package/src/Link/InlinePressable.jsx +2 -8
  113. package/src/Link/LinkBase.jsx +18 -21
  114. package/src/List/ListItem.jsx +10 -5
  115. package/src/Notification/Notification.jsx +40 -23
  116. package/src/Pagination/Pagination.jsx +6 -4
  117. package/src/Radio/RadioGroup.jsx +7 -0
  118. package/src/RadioCard/RadioCard.jsx +3 -2
  119. package/src/RadioCard/RadioCardGroup.jsx +6 -0
  120. package/src/Select/Select.jsx +12 -3
  121. package/src/SkipLink/SkipLink.jsx +179 -0
  122. package/src/SkipLink/index.js +3 -0
  123. package/src/StepTracker/Step.jsx +12 -4
  124. package/src/StepTracker/StepTracker.jsx +11 -10
  125. package/src/Tabs/TabsItem.jsx +3 -2
  126. package/src/TextInput/TextInputBase.jsx +11 -3
  127. package/src/ThemeProvider/ThemeProvider.jsx +22 -3
  128. package/src/ThemeProvider/utils/styles.js +9 -1
  129. package/src/ThemeProvider/utils/theme-tokens.js +1 -1
  130. package/src/ToggleSwitch/ToggleSwitchGroup.jsx +6 -0
  131. package/src/Typography/Typography.jsx +11 -12
  132. package/src/index.js +1 -0
@@ -4,13 +4,13 @@ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
4
4
  import NativeTextInput from "react-native-web/dist/exports/TextInput";
5
5
  import View from "react-native-web/dist/exports/View";
6
6
  import PropTypes from 'prop-types';
7
- import { applyTextStyles, useThemeTokens, applyOuterBorder } from '../ThemeProvider';
7
+ import { applyTextStyles, useTheme, useThemeTokens, applyOuterBorder } from '../ThemeProvider';
8
8
  import { a11yProps, getTokensPropType, selectSystemProps, textInputHandlerProps, textInputProps, useInputValue, variantProp, viewProps } from '../utils';
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
  import { jsxs as _jsxs } from "react/jsx-runtime";
11
11
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, textInputHandlerProps, textInputProps, viewProps]);
12
12
 
13
- const selectInputStyles = (_ref, inactive) => {
13
+ const selectInputStyles = (_ref, themeOptions, inactive) => {
14
14
  let {
15
15
  backgroundColor,
16
16
  color,
@@ -41,7 +41,8 @@ const selectInputStyles = (_ref, inactive) => {
41
41
  fontName,
42
42
  fontSize,
43
43
  lineHeight,
44
- fontWeight
44
+ fontWeight,
45
+ themeOptions
45
46
  });
46
47
 
47
48
  function linesToHeight(lines) {
@@ -210,9 +211,12 @@ const TextInputBase = /*#__PURE__*/forwardRef((_ref5, ref) => {
210
211
  // Input could lead to changing its state from uncontrolled to controlled
211
212
  value: isControlled ? currentValue : undefined
212
213
  };
214
+ const {
215
+ themeOptions
216
+ } = useTheme();
213
217
  const nativeInputStyle = selectInputStyles({ ...themeTokens,
214
218
  height
215
- }, inactive);
219
+ }, themeOptions, inactive);
216
220
  return /*#__PURE__*/_jsxs(View, {
217
221
  style: selectOuterBorderStyles(themeTokens),
218
222
  children: [/*#__PURE__*/_jsx(NativeTextInput, {
@@ -1,6 +1,7 @@
1
1
  import React, { createContext, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { validateThemeTokensVersion } from './utils';
4
+ import responsiveProps from '../utils/props/responsiveProps';
4
5
  import { jsx as _jsx } from "react/jsx-runtime";
5
6
  export const uninitialisedError = new Error('Theme context used outside of ThemeProvider');
6
7
  export const ThemeContext = /*#__PURE__*/createContext(uninitialisedError);
@@ -9,7 +10,11 @@ export const ThemeSetterContext = /*#__PURE__*/createContext(uninitialisedError)
9
10
  const ThemeProvider = _ref => {
10
11
  let {
11
12
  children,
12
- defaultTheme
13
+ defaultTheme,
14
+ // TODO: switch `forceAbsoluteFontSizing` to be false by default in the next major version
15
+ themeOptions = {
16
+ forceAbsoluteFontSizing: true
17
+ }
13
18
  } = _ref;
14
19
  const [theme, setTheme] = useState(defaultTheme); // Validate the theme tokens version on every render.
15
20
  // This will intentionally break the application when attempting to use an invalid theme.
@@ -19,7 +24,9 @@ const ThemeProvider = _ref => {
19
24
  return /*#__PURE__*/_jsx(ThemeSetterContext.Provider, {
20
25
  value: setTheme,
21
26
  children: /*#__PURE__*/_jsx(ThemeContext.Provider, {
22
- value: theme,
27
+ value: { ...theme,
28
+ themeOptions
29
+ },
23
30
  children: children
24
31
  })
25
32
  });
@@ -31,6 +38,20 @@ ThemeProvider.propTypes = {
31
38
  metadata: PropTypes.shape({
32
39
  themeTokensVersion: PropTypes.string.isRequired
33
40
  }).isRequired
34
- }).isRequired
41
+ }).isRequired,
42
+
43
+ /**
44
+ * An object containing options allowing to customize the theming experience:
45
+ *
46
+ * - `forceAbsoluteFontSizing`: available on web only; when set to true, allows
47
+ * using absolute font sizing (in pixels, doesn't scale) instead of the
48
+ * relative sizing (in `rem`, scales depending on the browser settings)
49
+ * - `contentMaxWidth`: allows configuration of the content max width to be used in components
50
+ * such as Footnote and Notification to avoid content to stretch width more then the page's width
51
+ */
52
+ themeOptions: PropTypes.shape({
53
+ forceAbsoluteFontSizing: PropTypes.bool,
54
+ contentMaxWidth: responsiveProps.getTypeOptionallyByViewport(PropTypes.number)
55
+ })
35
56
  };
36
57
  export default ThemeProvider;
@@ -14,14 +14,21 @@ export function applyTextStyles(_ref) {
14
14
  fontWeight = '400',
15
15
  fontName,
16
16
  fontStyle = 'normal',
17
+ themeOptions = {
18
+ // TODO: switch `forceAbsoluteFontSizing` to be false by default in the next major version
19
+ forceAbsoluteFontSizing: true
20
+ },
17
21
  ...rest
18
22
  } = _ref;
19
23
  const styles = { ...rest
20
24
  };
25
+ const {
26
+ forceAbsoluteFontSizing
27
+ } = themeOptions;
21
28
 
22
29
  if (fontSize) {
23
30
  // If relative font sizes are needed, catch and calculate them here
24
- styles.fontSize = fontSize;
31
+ styles.fontSize = Platform.OS === 'web' && !forceAbsoluteFontSizing ? "".concat(fontSize / fontBasePixels, "rem") : fontSize;
25
32
  }
26
33
 
27
34
  if (typeof lineHeight === 'number') {
@@ -158,6 +158,6 @@ export const validateThemeTokensVersion = theme => {
158
158
  const actualThemeTokensVersion = theme === null || theme === void 0 ? void 0 : (_theme$metadata2 = theme.metadata) === null || _theme$metadata2 === void 0 ? void 0 : _theme$metadata2.themeTokensVersion;
159
159
 
160
160
  if (!semVerSatisfies(actualThemeTokensVersion, expectedThemeTokensVersion)) {
161
- throw new Error("Invalid UDS token schema version detected.\n\nThe UDS base components ".concat(pkg.name, " v").concat(pkg.version, " are only compatible with UDS themes that are built with @telus-uds/system-theme-tokens version that is semver compatible with ").concat(expectedThemeTokensVersion, ". The current theme was built with @telus-uds/system-theme-tokens v").concat(actualThemeTokensVersion, ".\n\nIf you see this error than most likely you have attempted to install ").concat(pkg.name, " and a UDS theme manually because you are building a multi-brand application. If you are building a single brand application, consider installing the brand specific design system package such as @telus-uds/ds-allium. For more information, see https://github.com/telus/universal-design-system/blob/main/packages/docs-uds/docs/multi-brand-usage.md"));
161
+ throw new Error("Invalid UDS token schema version detected.\n\nThe UDS base components ".concat(pkg.name, " v").concat(pkg.version, " are only compatible with UDS themes that are built with @telus-uds/system-theme-tokens version that is semver compatible with ").concat(expectedThemeTokensVersion, ". The current theme was built with @telus-uds/system-theme-tokens v").concat(actualThemeTokensVersion, ".\n\nIf you see this error than most likely you have attempted to install ").concat(pkg.name, " and a UDS theme manually because you are building a multi-brand application. If you are building a single brand application, consider installing the brand specific design system package such as @telus-uds/ds-allium. For more information, see https://github.com/telus/universal-design-system/blob/main/docs/docs/multi-brand-usage.md"));
162
162
  }
163
163
  };
@@ -25,6 +25,7 @@ const ToggleSwitchGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
25
25
  inactive = false,
26
26
  feedback,
27
27
  hint,
28
+ hintPosition = 'inline',
28
29
  tooltip,
29
30
  legend,
30
31
  name: inputGroupName,
@@ -110,6 +111,7 @@ const ToggleSwitchGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
110
111
  legend: legend,
111
112
  tooltip: tooltip,
112
113
  hint: hint,
114
+ hintPosition: hintPosition,
113
115
  space: fieldSpace,
114
116
  feedback: feedback,
115
117
  inactive: inactive,
@@ -192,6 +194,11 @@ ToggleSwitchGroup.propTypes = { ...selectedSystemPropTypes,
192
194
  */
193
195
  hint: PropTypes.string,
194
196
 
197
+ /**
198
+ * Position of the hint relative to label. Use `below` to display a larger hint below the label.
199
+ */
200
+ hintPosition: PropTypes.oneOf(['inline', 'below']),
201
+
195
202
  /**
196
203
  * Optional tooltip text content to include alongside the legend and hint.
197
204
  */
@@ -2,7 +2,7 @@ import React, { forwardRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Text from "react-native-web/dist/exports/Text";
4
4
  import View from "react-native-web/dist/exports/View";
5
- import { useThemeTokens } from '../ThemeProvider';
5
+ import { useTheme, useThemeTokens } from '../ThemeProvider';
6
6
  import { useViewport } from '../ViewportProvider';
7
7
  import { applyTextStyles } from '../ThemeProvider/utils';
8
8
  import { a11yProps, variantProp, getTokensPropType, getMaxFontMultiplier, headingTags, selectSystemProps, textTags, textProps, viewProps, getA11yPropsFromHtmlTag } from '../utils';
@@ -14,7 +14,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
14
14
  const [selectContainerProps, selectedContainerPropTypes] = selectSystemProps([a11yProps, viewProps]);
15
15
  const [selectTextProps, selectedTextPropTypes] = selectSystemProps([textProps]);
16
16
 
17
- const selectTextStyles = _ref => {
17
+ const selectTextStyles = (_ref, themeOptions) => {
18
18
  let {
19
19
  fontWeight,
20
20
  fontSize,
@@ -31,6 +31,7 @@ const selectTextStyles = _ref => {
31
31
  color,
32
32
  lineHeight,
33
33
  fontName,
34
+ themeOptions,
34
35
  textAlign,
35
36
  textTransform,
36
37
  letterSpacing
@@ -55,10 +56,13 @@ const Typography = /*#__PURE__*/forwardRef((_ref2, ref) => {
55
56
  const themeTokens = useThemeTokens('Typography', tokens, variant, {
56
57
  viewport
57
58
  });
59
+ const {
60
+ themeOptions
61
+ } = useTheme();
58
62
  const resolvedTextProps = { ...selectTextProps(rest),
59
63
  style: selectTextStyles(align ? { ...themeTokens,
60
64
  textAlign: align
61
- } : themeTokens),
65
+ } : themeTokens, themeOptions),
62
66
  dataSet,
63
67
  maxFontSizeMultiplier: getMaxFontMultiplier(themeTokens)
64
68
  };
@@ -32,6 +32,7 @@ export { default as Search } from './Search';
32
32
  export { default as Select } from './Select';
33
33
  export { default as SideNav } from './SideNav';
34
34
  export { default as Skeleton } from './Skeleton';
35
+ export { default as SkipLink } from './SkipLink';
35
36
  export { default as Spacer } from './Spacer';
36
37
  export { default as StackView } from './StackView';
37
38
  export * from './StackView';
package/package.json CHANGED
@@ -1,21 +1,55 @@
1
1
  {
2
- "name": "@telus-uds/components-base",
3
- "version": "1.12.0",
2
+ "author": "TELUS Digital",
3
+ "browserslist": [
4
+ "extends @telus-uds/browserslist-config"
5
+ ],
6
+ "bugs": {
7
+ "url": "https://github.com/telus/universal-design-system/issues"
8
+ },
9
+ "dependencies": {
10
+ "airbnb-prop-types": "^2.16.0",
11
+ "@telus-uds/system-constants": "^1.0.4",
12
+ "@telus-uds/system-theme-tokens": "^2.2.0",
13
+ "lodash.debounce": "^4.0.8",
14
+ "lodash.merge": "^4.6.2",
15
+ "prop-types": "^15.7.2",
16
+ "react-native-picker-select": "^8.0.4",
17
+ "semver": "^7.3.5"
18
+ },
4
19
  "description": "Base components",
20
+ "devDependencies": {
21
+ "@storybook/addon-a11y": "^6.5.6",
22
+ "@storybook/addon-essentials": "^6.5.6",
23
+ "@storybook/cli": "^6.5.6",
24
+ "@storybook/react": "^6.5.6",
25
+ "@storybook/builder-webpack5": "^6.5.6",
26
+ "@storybook/manager-webpack5": "^6.5.6",
27
+ "@telus-uds/browserslist-config": "^1.0.4",
28
+ "@testing-library/jest-native": "^4.0.1",
29
+ "@testing-library/react-hooks": "^7.0.1",
30
+ "@testing-library/react-native": "^7.2.0",
31
+ "react-test-renderer": "^16.3.2",
32
+ "webpack": "5.x"
33
+ },
34
+ "directories": {
35
+ "lib": "lib",
36
+ "test": "__tests__"
37
+ },
38
+ "homepage": "https://github.com/telus/universal-design-system#readme",
5
39
  "keywords": [
6
40
  "base"
7
41
  ],
8
- "author": "TELUS Digital",
9
- "homepage": "https://github.com/telus/universal-design-system#readme",
10
42
  "license": "UNLICENSED",
11
43
  "main": "lib/index.js",
12
44
  "module": "lib-module/index.js",
13
- "react-native": "src/index.js",
14
- "sideEffects": false,
15
- "directories": {
16
- "lib": "lib",
17
- "test": "__tests__"
45
+ "name": "@telus-uds/components-base",
46
+ "peerDependencies": {
47
+ "react": "^17.0.2",
48
+ "react-dom": "^17.0.2",
49
+ "react-native": "*",
50
+ "react-native-web": "~0.17.5"
18
51
  },
52
+ "react-native": "src/index.js",
19
53
  "repository": {
20
54
  "type": "git",
21
55
  "url": "git+https://github.com/telus/universal-design-system.git"
@@ -31,46 +65,11 @@
31
65
  "build:code": "npm run build:main && npm run build:module",
32
66
  "build:docs": "babel-node --plugins=@nearform/babel-plugin-react-docgen generate-component-docs.js",
33
67
  "storybook": "start-storybook",
34
- "build-storybook": "build-storybook",
35
- "dev": "npm run build:code --watch"
36
- },
37
- "bugs": {
38
- "url": "https://github.com/telus/universal-design-system/issues"
68
+ "build-storybook": "build-storybook"
39
69
  },
70
+ "sideEffects": false,
40
71
  "standard-engine": {
41
72
  "skip": true
42
73
  },
43
- "browserslist": [
44
- "extends @telus-uds/browserslist-config"
45
- ],
46
- "peerDependencies": {
47
- "react": "^17.0.2",
48
- "react-dom": "^17.0.2",
49
- "react-native": "*",
50
- "react-native-web": "~0.17.5"
51
- },
52
- "devDependencies": {
53
- "@storybook/addon-a11y": "^6.5.6",
54
- "@storybook/addon-essentials": "^6.5.6",
55
- "@storybook/cli": "^6.5.6",
56
- "@storybook/react": "^6.5.6",
57
- "@storybook/builder-webpack5": "^6.5.6",
58
- "@storybook/manager-webpack5": "^6.5.6",
59
- "@telus-uds/browserslist-config": "^1.0.4",
60
- "@testing-library/jest-native": "^4.0.1",
61
- "@testing-library/react-hooks": "^7.0.1",
62
- "@testing-library/react-native": "^7.2.0",
63
- "react-test-renderer": "^16.3.2",
64
- "webpack": "5.x"
65
- },
66
- "dependencies": {
67
- "airbnb-prop-types": "^2.16.0",
68
- "@telus-uds/system-constants": "^1.0.4",
69
- "@telus-uds/system-theme-tokens": "^2.1.0",
70
- "lodash.debounce": "^4.0.8",
71
- "lodash.merge": "^4.6.2",
72
- "prop-types": "^15.7.2",
73
- "react-native-picker-select": "^8.0.4",
74
- "semver": "^7.3.5"
75
- }
74
+ "version": "1.14.0"
76
75
  }
@@ -4,17 +4,20 @@ import A11yInfoProvider from '../A11yInfoProvider'
4
4
  import ViewportProvider from '../ViewportProvider'
5
5
  import ThemeProvider from '../ThemeProvider'
6
6
 
7
- const BaseProvider = ({ defaultTheme, children }) => (
7
+ const BaseProvider = ({ defaultTheme, children, themeOptions }) => (
8
8
  <A11yInfoProvider>
9
9
  <ViewportProvider>
10
- <ThemeProvider defaultTheme={defaultTheme}>{children}</ThemeProvider>
10
+ <ThemeProvider defaultTheme={defaultTheme} themeOptions={themeOptions}>
11
+ {children}
12
+ </ThemeProvider>
11
13
  </ViewportProvider>
12
14
  </A11yInfoProvider>
13
15
  )
14
16
 
15
17
  BaseProvider.propTypes = {
18
+ children: PropTypes.node.isRequired,
16
19
  defaultTheme: ThemeProvider.propTypes?.defaultTheme,
17
- children: PropTypes.node.isRequired
20
+ themeOptions: PropTypes.shape({ forceAbsoluteFontSizing: PropTypes.bool })
18
21
  }
19
22
 
20
23
  export default BaseProvider
@@ -2,7 +2,7 @@ import React, { forwardRef } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import { Pressable, View, StyleSheet, Platform } from 'react-native'
4
4
 
5
- import { applyTextStyles, applyShadowToken, applyOuterBorder } from '../ThemeProvider/utils'
5
+ import { applyTextStyles, applyShadowToken, applyOuterBorder, useTheme } from '../ThemeProvider'
6
6
  import buttonPropTypes from './propTypes'
7
7
  import {
8
8
  a11yProps,
@@ -17,6 +17,7 @@ import {
17
17
  wrapStringsInText,
18
18
  withLinkRouter
19
19
  } from '../utils'
20
+ import { IconText } from '../Icon'
20
21
 
21
22
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([
22
23
  a11yProps,
@@ -121,13 +122,17 @@ const selectBorderStyles = ({ borderColor, borderWidth, borderRadius }) => ({
121
122
  borderRadius
122
123
  })
123
124
 
124
- const selectTextStyles = ({ fontSize, color, lineHeight, fontName, fontWeight, textAlign }) =>
125
+ const selectTextStyles = (
126
+ { fontSize, color, lineHeight, fontName, fontWeight, textAlign },
127
+ themeOptions
128
+ ) =>
125
129
  applyTextStyles({
126
130
  fontSize,
127
131
  color,
128
132
  lineHeight,
129
133
  fontName,
130
134
  fontWeight,
135
+ themeOptions,
131
136
  textAlign
132
137
  })
133
138
 
@@ -143,6 +148,11 @@ const selectWebOnlyStyles = (inactive, themeTokens, { accessibilityRole }) => {
143
148
  })
144
149
  }
145
150
 
151
+ const selectItemIconTokens = ({ color, iconSize }) => ({
152
+ size: iconSize,
153
+ color
154
+ })
155
+
146
156
  const ButtonBase = forwardRef(
147
157
  (
148
158
  {
@@ -154,6 +164,9 @@ const ButtonBase = forwardRef(
154
164
  disabled = false, // alias for inactive
155
165
  inactive = disabled,
156
166
  selected = false,
167
+ icon,
168
+ iconPosition = icon ? 'left' : undefined,
169
+ iconProps,
157
170
  ...rawRest
158
171
  },
159
172
  ref
@@ -174,6 +187,7 @@ const ButtonBase = forwardRef(
174
187
  selectOuterWidthStyles(themeTokens)
175
188
  ]
176
189
  }
190
+ const { themeOptions } = useTheme()
177
191
 
178
192
  return (
179
193
  <Pressable
@@ -189,11 +203,14 @@ const ButtonBase = forwardRef(
189
203
  const themeTokens = resolveButtonTokens(pressableState)
190
204
  const containerStyles = selectInnerContainerStyles(themeTokens)
191
205
  const borderStyles = selectBorderStyles(themeTokens)
192
- const textStyles = [selectTextStyles(themeTokens), staticStyles.text]
206
+ const textStyles = [selectTextStyles(themeTokens, themeOptions), staticStyles.text]
207
+ const iconTokens = selectItemIconTokens(themeTokens)
208
+ const { iconSpace } = themeTokens
193
209
 
194
210
  // If the container has a width set, fill it instead of sizing from content.
195
211
  // If in future we support text alignments other than center, add here.
196
212
  const stretchStyles = themeTokens.width ? staticStyles.stretch : staticStyles.align
213
+ const IconComponent = icon || themeTokens.icon
197
214
 
198
215
  return (
199
216
  <View
@@ -212,15 +229,22 @@ const ButtonBase = forwardRef(
212
229
  })
213
230
  ]}
214
231
  >
215
- {wrapStringsInText(
216
- typeof children === 'function'
217
- ? children({
218
- ...resolvePressableState(pressableState, extraButtonState),
219
- textStyles
220
- })
221
- : children,
222
- { style: textStyles }
223
- )}
232
+ <IconText
233
+ icon={IconComponent}
234
+ iconPosition={iconPosition}
235
+ space={iconSpace}
236
+ iconProps={{ ...iconProps, tokens: iconTokens }}
237
+ >
238
+ {wrapStringsInText(
239
+ typeof children === 'function'
240
+ ? children({
241
+ ...resolvePressableState(pressableState, extraButtonState),
242
+ textStyles
243
+ })
244
+ : children,
245
+ { style: textStyles }
246
+ )}
247
+ </IconText>
224
248
  </View>
225
249
  )
226
250
  }}
@@ -45,6 +45,7 @@ const ButtonGroup = forwardRef(
45
45
  legend,
46
46
  tooltip,
47
47
  hint,
48
+ hintPosition = 'inline',
48
49
  validation,
49
50
  feedback,
50
51
  name: inputGroupName,
@@ -94,6 +95,7 @@ const ButtonGroup = forwardRef(
94
95
  legend={legend}
95
96
  tooltip={tooltip}
96
97
  hint={hint}
98
+ hintPosition={hintPosition}
97
99
  space={fieldSpace}
98
100
  feedback={feedback}
99
101
  readOnly={readOnly}
@@ -217,6 +219,10 @@ ButtonGroup.propTypes = {
217
219
  * Optional additional text giving more detail to help a user make a choice.
218
220
  */
219
221
  hint: PropTypes.string,
222
+ /**
223
+ * Position of the hint relative to label. Use `below` to display a larger hint below the label.
224
+ */
225
+ hintPosition: PropTypes.oneOf(['inline', 'below']),
220
226
  /**
221
227
  * Optional tooltip text content to include alongside the legend and hint.
222
228
  */
@@ -2,6 +2,7 @@ import PropTypes from 'prop-types'
2
2
  import ABBPropTypes from 'airbnb-prop-types'
3
3
  import { variantProp, getTokensPropType } from '../utils/props'
4
4
  import A11yText from '../A11yText'
5
+ import { iconComponentPropTypes } from '../Icon'
5
6
 
6
7
  export const textAndA11yText = ABBPropTypes.childrenOf(
7
8
  PropTypes.oneOfType([ABBPropTypes.elementType(A11yText), PropTypes.string])
@@ -31,6 +32,19 @@ const buttonPropTypes = {
31
32
  * Function called when the button is pressed. Required unless the button has a href.
32
33
  */
33
34
  onPress: PropTypes.func,
35
+ /**
36
+ * Optional variant that may be passed down to the link's icon if there is one
37
+ */
38
+ iconProps: PropTypes.exact(iconComponentPropTypes),
39
+ /**
40
+ * When `icon` is provided, use `iconPosition` to place the Icon to the left or right side of the button.
41
+ */
42
+ iconPosition: PropTypes.oneOf(['left', 'right']),
43
+ /**
44
+ * A function component for an SVG icon to render inside the link. Inherits size and color from
45
+ * the link and any Typography the link is nested inside.
46
+ */
47
+ icon: PropTypes.func,
34
48
  variant: variantProp.propType
35
49
  }
36
50
  export default buttonPropTypes