@telus-uds/components-base 3.2.0 → 3.4.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 (51) hide show
  1. package/CHANGELOG.md +29 -2
  2. package/lib/cjs/Button/ButtonBase.js +1 -1
  3. package/lib/cjs/Button/ButtonLink.js +1 -0
  4. package/lib/cjs/Card/CardBase.js +2 -1
  5. package/lib/cjs/Carousel/Carousel.js +202 -51
  6. package/lib/cjs/Carousel/CarouselItem/CarouselItem.js +1 -15
  7. package/lib/cjs/Carousel/CarouselStepTracker/CarouselStepTracker.js +6 -6
  8. package/lib/cjs/ExpandCollapse/Control.js +3 -1
  9. package/lib/cjs/ExpandCollapse/ExpandCollapse.js +3 -1
  10. package/lib/cjs/ExpandCollapseMini/ExpandCollapseMini.js +11 -2
  11. package/lib/cjs/Link/Link.js +8 -1
  12. package/lib/cjs/Link/LinkBase.js +2 -0
  13. package/lib/cjs/List/ListItemBase.js +1 -2
  14. package/lib/cjs/MultiSelectFilter/MultiSelectFilter.js +2 -2
  15. package/lib/cjs/TextInput/TextArea.js +10 -1
  16. package/lib/cjs/Typography/Typography.js +8 -2
  17. package/lib/cjs/utils/useUniqueId.js +2 -6
  18. package/lib/esm/Button/ButtonBase.js +2 -2
  19. package/lib/esm/Button/ButtonLink.js +2 -1
  20. package/lib/esm/Card/CardBase.js +2 -1
  21. package/lib/esm/Carousel/Carousel.js +203 -52
  22. package/lib/esm/Carousel/CarouselItem/CarouselItem.js +2 -16
  23. package/lib/esm/Carousel/CarouselStepTracker/CarouselStepTracker.js +6 -6
  24. package/lib/esm/ExpandCollapse/Control.js +3 -1
  25. package/lib/esm/ExpandCollapse/ExpandCollapse.js +4 -2
  26. package/lib/esm/ExpandCollapseMini/ExpandCollapseMini.js +12 -3
  27. package/lib/esm/Link/Link.js +8 -1
  28. package/lib/esm/Link/LinkBase.js +2 -0
  29. package/lib/esm/List/ListItemBase.js +1 -2
  30. package/lib/esm/MultiSelectFilter/MultiSelectFilter.js +2 -2
  31. package/lib/esm/TextInput/TextArea.js +10 -1
  32. package/lib/esm/Typography/Typography.js +8 -2
  33. package/lib/esm/utils/useUniqueId.js +3 -7
  34. package/lib/package.json +1 -1
  35. package/package.json +1 -1
  36. package/src/Button/ButtonBase.jsx +4 -2
  37. package/src/Button/ButtonLink.jsx +3 -1
  38. package/src/Card/CardBase.jsx +2 -1
  39. package/src/Carousel/Carousel.jsx +200 -55
  40. package/src/Carousel/CarouselItem/CarouselItem.jsx +1 -7
  41. package/src/Carousel/CarouselStepTracker/CarouselStepTracker.jsx +5 -4
  42. package/src/ExpandCollapse/Control.jsx +3 -1
  43. package/src/ExpandCollapse/ExpandCollapse.jsx +9 -4
  44. package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +16 -4
  45. package/src/Link/Link.jsx +8 -1
  46. package/src/Link/LinkBase.jsx +2 -0
  47. package/src/List/ListItemBase.jsx +1 -2
  48. package/src/MultiSelectFilter/MultiSelectFilter.jsx +1 -1
  49. package/src/TextInput/TextArea.jsx +11 -1
  50. package/src/Typography/Typography.jsx +8 -2
  51. package/src/utils/useUniqueId.js +3 -8
@@ -12,7 +12,7 @@ var _ThemeProvider = require("../ThemeProvider");
12
12
  var _utils = require("../utils");
13
13
  var _jsxRuntime = require("react/jsx-runtime");
14
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
15
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps, _utils.contentfulProps]);
16
16
  function selectBorderStyles(tokens) {
17
17
  return {
18
18
  borderBottomWidth: tokens.borderWidth,
@@ -37,6 +37,7 @@ const ExpandCollapse = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
37
37
  open,
38
38
  initialOpen,
39
39
  onChange,
40
+ dataSet,
40
41
  ...rest
41
42
  } = _ref;
42
43
  const {
@@ -56,6 +57,7 @@ const ExpandCollapse = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
56
57
  style: staticStyles.container,
57
58
  ref: ref,
58
59
  ...selectProps(rest),
60
+ dataSet: dataSet,
59
61
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
60
62
  style: selectBorderStyles(themeTokens),
61
63
  children: typeof children === 'function' ? children({
@@ -11,6 +11,7 @@ var _utils = require("../utils");
11
11
  var _ExpandCollapseMiniControl = _interopRequireDefault(require("./ExpandCollapseMiniControl"));
12
12
  var _jsxRuntime = require("react/jsx-runtime");
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ const [selectContainerProps, selectedContainerPropTypes] = (0, _utils.selectSystemProps)([_utils.contentfulProps]);
14
15
  const ExpandCollapseMini = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
15
16
  let {
16
17
  children,
@@ -18,6 +19,7 @@ const ExpandCollapseMini = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
18
19
  tokens = {},
19
20
  nativeID,
20
21
  initialOpen = false,
22
+ dataSet,
21
23
  ...rest
22
24
  } = _ref;
23
25
  const expandCollapeMiniPanelId = 'ExpandCollapseMiniPanel';
@@ -31,6 +33,8 @@ const ExpandCollapseMini = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
31
33
  onChange: handleChange,
32
34
  tokens: tokens,
33
35
  initialOpen: initialOpen ? [expandCollapeMiniPanelId] : [],
36
+ ...selectContainerProps(rest),
37
+ dataSet: dataSet,
34
38
  children: expandProps => /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandCollapse.default.Panel, {
35
39
  ...expandProps,
36
40
  panelId: expandCollapeMiniPanelId,
@@ -41,7 +45,7 @@ const ExpandCollapseMini = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
41
45
  // Remove unwanted look and feel from ExpandCollapse(background pressed, focus border and text underline)
42
46
  icon: null,
43
47
  borderColor: 'transparent',
44
- textLine: 'none',
48
+ textLine: tokens.textLine ?? 'none',
45
49
  backgroundColor: 'transparent'
46
50
  }
47
51
  // TODO refactor
@@ -60,6 +64,7 @@ const ExpandCollapseMini = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
60
64
  ExpandCollapseMini.displayName = 'ExpandCollapseMini';
61
65
  ExpandCollapseMini.propTypes = {
62
66
  ..._ExpandCollapseMiniControl.default.propTypes,
67
+ ...selectedContainerPropTypes,
63
68
  /**
64
69
  * Function to call on pressing the panel's control, which should open or close the panel.
65
70
  */
@@ -79,6 +84,10 @@ ExpandCollapseMini.propTypes = {
79
84
  /**
80
85
  * Optional variant object to override the default theme tokens
81
86
  */
82
- tokens: (0, _utils.getTokensPropType)('ExpandCollapseMini')
87
+ tokens: (0, _utils.getTokensPropType)('ExpandCollapseMini'),
88
+ /**
89
+ * The dataSet prop allows to pass data-* attributes element to the component.
90
+ */
91
+ dataSet: _propTypes.default.object
83
92
  };
84
93
  var _default = exports.default = ExpandCollapseMini;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
8
9
  var _ThemeProvider = require("../ThemeProvider");
9
10
  var _LinkBase = _interopRequireDefault(require("./LinkBase"));
10
11
  var _jsxRuntime = require("react/jsx-runtime");
@@ -31,5 +32,11 @@ const Link = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
31
32
  });
32
33
  });
33
34
  Link.displayName = 'Link';
34
- Link.propTypes = _LinkBase.default.propTypes;
35
+ Link.propTypes = {
36
+ ..._LinkBase.default.propTypes,
37
+ /**
38
+ * The dataSet prop allows to pass data-* attributes element to the component.
39
+ */
40
+ dataSet: _propTypes.default.object
41
+ };
35
42
  var _default = exports.default = Link;
@@ -143,6 +143,7 @@ const LinkBase = /*#__PURE__*/_react.default.forwardRef((_ref6, ref) => {
143
143
  variant,
144
144
  tokens = {},
145
145
  children,
146
+ dataSet,
146
147
  accessibilityRole = 'link',
147
148
  ...rawRest
148
149
  } = _ref6;
@@ -177,6 +178,7 @@ const LinkBase = /*#__PURE__*/_react.default.forwardRef((_ref6, ref) => {
177
178
  } = (0, _ThemeProvider.useTheme)();
178
179
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InlinePressable.default, {
179
180
  ...selectedProps,
181
+ dataSet: dataSet,
180
182
  inlineFlex: hasIcon
181
183
  // assuming links without icons should be inline (even if they are long)
182
184
  ,
@@ -136,8 +136,7 @@ const staticStyles = _StyleSheet.default.create({
136
136
  titleAndContentContainer: {
137
137
  flexDirection: 'column',
138
138
  flexShrink: 1,
139
- flexGrow: 1,
140
- textAlign: 'justify'
139
+ flexGrow: 1
141
140
  }
142
141
  });
143
142
  ListItemBase.propTypes = {
@@ -293,9 +293,9 @@ const MultiSelectFilter = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) =>
293
293
  },
294
294
  children: subtitle
295
295
  })
296
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spacer.default, {
297
- space: 4
298
296
  })]
297
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spacer.default, {
298
+ space: 4
299
299
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
300
300
  style: styles.options,
301
301
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScrollView.default, {
@@ -47,6 +47,7 @@ const TextArea = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
47
47
  } = _ref;
48
48
  const themeTokens = (0, _ThemeProvider.useThemeTokens)('TextArea', tokens, variant);
49
49
  const [inputHeight, setInputHeight] = _react.default.useState();
50
+ const isUpdatingHeight = _react.default.useRef(false);
50
51
 
51
52
  // adjust the text area's height as new lines are added to the content
52
53
  const onHeightChange = _ref2 => {
@@ -58,8 +59,16 @@ const TextArea = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
58
59
  }
59
60
  } = _ref2;
60
61
  // on native this is happens out of the box
61
- if (_Platform.default.OS === 'web') {
62
+ if (_Platform.default.OS === 'web' && !isUpdatingHeight.current) {
63
+ isUpdatingHeight.current = true;
62
64
  setInputHeight(height);
65
+ // setTimeout is used to “wait” for the next update cycle before allowing a new height adjustment,
66
+ // avoiding multiple updates in the same render and preventing a possible infinite loop or constant re-renders.
67
+ setTimeout(() => {
68
+ isUpdatingHeight.current = false;
69
+ }, 0);
70
+ } else {
71
+ setInputHeight(null);
63
72
  }
64
73
  };
65
74
  const {
@@ -118,13 +118,19 @@ const Typography = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
118
118
  backgroundClip: 'text'
119
119
  } : styles;
120
120
  };
121
+
122
+ /**
123
+ * Added to maintain previous behavior, as the 'auto' value for the 'align' prop now defaults to 'inherit' on the web,
124
+ * maintaining the previous behavior that was changed in the Text component of react-native.
125
+ */
126
+ const resolvedAlign = _Platform.default.OS === 'web' && align === 'auto' ? 'inherit' : align;
121
127
  let textStyles;
122
128
  let mediaIds;
123
129
  if (enableMediaQueryStyleSheet) {
124
130
  const transformedThemeTokens = Object.entries(themeTokens).reduce((acc, _ref4) => {
125
131
  let [vp, viewportTokens] = _ref4;
126
132
  acc[vp] = selectTextStyles({
127
- textAlign: align,
133
+ textAlign: resolvedAlign,
128
134
  textDecorationLine,
129
135
  ...viewportTokens
130
136
  }, themeOptions);
@@ -153,7 +159,7 @@ const Typography = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
153
159
  mediaIds = ids.text;
154
160
  } else {
155
161
  textStyles = selectTextStyles({
156
- textAlign: align,
162
+ textAlign: resolvedAlign,
157
163
  textDecorationLine,
158
164
  ...themeTokens
159
165
  }, themeOptions);
@@ -5,13 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = require("react");
8
- let id = 0;
9
8
  function useUniqueId() {
10
9
  let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
11
- const [uniqueId] = (0, _react.useState)(() => {
12
- id += 1;
13
- return `${prefix}-${id}`;
14
- });
15
- return uniqueId;
10
+ const id = (0, _react.useId)();
11
+ return `${prefix ? `${prefix}-` : ''}${id}`;
16
12
  }
17
13
  var _default = exports.default = useUniqueId;
@@ -6,10 +6,10 @@ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
6
6
  import Platform from "react-native-web/dist/exports/Platform";
7
7
  import { applyTextStyles, applyShadowToken, applyOuterBorder, useTheme } from '../ThemeProvider';
8
8
  import buttonPropTypes from './propTypes';
9
- import { a11yProps, clickProps, focusHandlerProps, getCursorStyle, linkProps, resolvePressableState, resolvePressableTokens, selectSystemProps, viewProps, wrapStringsInText, withLinkRouter } from '../utils';
9
+ import { a11yProps, clickProps, focusHandlerProps, getCursorStyle, linkProps, resolvePressableState, resolvePressableTokens, selectSystemProps, viewProps, wrapStringsInText, withLinkRouter, contentfulProps } from '../utils';
10
10
  import { IconText } from '../Icon';
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
- const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, linkProps, viewProps]);
12
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, linkProps, viewProps, contentfulProps]);
13
13
  const getOuterBorderOffset = _ref => {
14
14
  let {
15
15
  outerBorderGap = 0,
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import ButtonBase from './ButtonBase';
4
4
  import buttonPropTypes, { textAndA11yText } from './propTypes';
5
- import { a11yProps, hrefAttrsProp, linkProps } from '../utils/props';
5
+ import { a11yProps, hrefAttrsProp, linkProps, contentfulProps } from '../utils/props';
6
6
  import { useThemeTokensCallback } from '../ThemeProvider';
7
7
  import { useViewport } from '../ViewportProvider';
8
8
 
@@ -43,6 +43,7 @@ ButtonLink.propTypes = {
43
43
  ...a11yProps.types,
44
44
  ...buttonPropTypes,
45
45
  ...linkProps.types,
46
+ ...contentfulProps.types,
46
47
  children: textAndA11yText,
47
48
  dataSet: PropTypes.object,
48
49
  accessibilityRole: PropTypes.string
@@ -84,13 +84,14 @@ const CardBase = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
84
84
  ref: ref,
85
85
  ...props,
86
86
  children: src ? /*#__PURE__*/_jsx(ImageBackground, {
87
- alt: alt,
88
87
  source: imageSourceViewport,
89
88
  imageStyle: {
90
89
  borderRadius: cardStyle?.borderRadius - cardStyle?.borderWidth
91
90
  },
92
91
  resizeMode: backgroundImageResizeMode,
93
92
  style: styles.imageBackground,
93
+ accessible: true,
94
+ accessibilityLabel: alt,
94
95
  children: children
95
96
  }) : children
96
97
  });