@telus-uds/components-base 1.18.1 → 1.20.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 (112) hide show
  1. package/CHANGELOG.md +42 -2
  2. package/__tests17__/ThemeProvider/ThemeProvider.test.jsx +2 -1
  3. package/component-docs.json +1035 -231
  4. package/jest.config-android.js +17 -0
  5. package/jest.config-ios.js +18 -0
  6. package/jest.config-web.js +31 -0
  7. package/lib/BaseProvider/index.js +2 -1
  8. package/lib/Box/Box.js +14 -1
  9. package/lib/Button/ButtonBase.js +6 -2
  10. package/lib/Button/ButtonDropdown.js +207 -0
  11. package/lib/Button/index.js +8 -0
  12. package/lib/Carousel/Carousel.js +34 -6
  13. package/lib/Carousel/CarouselItem/CarouselItem.js +7 -1
  14. package/lib/Carousel/CarouselTabs/CarouselTabsPanel.js +22 -14
  15. package/lib/FlexGrid/Col/Col.js +1 -3
  16. package/lib/FlexGrid/FlexGrid.js +3 -5
  17. package/lib/FlexGrid/Row/Row.js +3 -3
  18. package/lib/IconButton/IconButton.js +12 -4
  19. package/lib/MultiSelectFilter/MultiSelectFilter.js +276 -0
  20. package/lib/MultiSelectFilter/dictionary.js +19 -0
  21. package/lib/MultiSelectFilter/index.js +13 -0
  22. package/lib/Pagination/SideButton.js +6 -4
  23. package/lib/Responsive/Responsive.js +58 -0
  24. package/lib/Responsive/index.js +13 -0
  25. package/lib/Search/Search.js +33 -63
  26. package/lib/Select/Picker.native.js +16 -13
  27. package/lib/Select/Select.js +7 -1
  28. package/lib/Select/constants.js +15 -0
  29. package/lib/StepTracker/Step.js +2 -1
  30. package/lib/Tags/Tags.js +10 -4
  31. package/lib/TextInput/TextInput.js +9 -2
  32. package/lib/TextInput/TextInputBase.js +98 -20
  33. package/lib/TextInput/dictionary.js +15 -0
  34. package/lib/ThemeProvider/ThemeProvider.js +6 -1
  35. package/lib/index.js +18 -0
  36. package/lib/utils/BaseView/BaseView.js +64 -0
  37. package/lib/utils/BaseView/BaseView.native.js +16 -0
  38. package/lib/utils/BaseView/index.js +13 -0
  39. package/lib/utils/index.js +10 -1
  40. package/lib/utils/input.js +11 -3
  41. package/lib/utils/props/handlerProps.js +5 -0
  42. package/lib-module/BaseProvider/index.js +2 -1
  43. package/lib-module/Box/Box.js +14 -1
  44. package/lib-module/Button/ButtonBase.js +6 -2
  45. package/lib-module/Button/ButtonDropdown.js +181 -0
  46. package/lib-module/Button/index.js +2 -1
  47. package/lib-module/Carousel/Carousel.js +34 -6
  48. package/lib-module/Carousel/CarouselItem/CarouselItem.js +8 -2
  49. package/lib-module/Carousel/CarouselTabs/CarouselTabsPanel.js +24 -16
  50. package/lib-module/FlexGrid/Col/Col.js +2 -3
  51. package/lib-module/FlexGrid/FlexGrid.js +2 -3
  52. package/lib-module/FlexGrid/Row/Row.js +2 -2
  53. package/lib-module/IconButton/IconButton.js +14 -4
  54. package/lib-module/MultiSelectFilter/MultiSelectFilter.js +248 -0
  55. package/lib-module/MultiSelectFilter/dictionary.js +12 -0
  56. package/lib-module/MultiSelectFilter/index.js +2 -0
  57. package/lib-module/Pagination/SideButton.js +6 -4
  58. package/lib-module/Responsive/Responsive.js +45 -0
  59. package/lib-module/Responsive/index.js +2 -0
  60. package/lib-module/Search/Search.js +33 -61
  61. package/lib-module/Select/Picker.native.js +15 -13
  62. package/lib-module/Select/Select.js +6 -1
  63. package/lib-module/Select/constants.js +5 -0
  64. package/lib-module/StepTracker/Step.js +2 -1
  65. package/lib-module/Tags/Tags.js +10 -4
  66. package/lib-module/TextInput/TextInput.js +6 -0
  67. package/lib-module/TextInput/TextInputBase.js +96 -21
  68. package/lib-module/TextInput/dictionary.js +8 -0
  69. package/lib-module/ThemeProvider/ThemeProvider.js +6 -1
  70. package/lib-module/index.js +2 -0
  71. package/lib-module/utils/BaseView/BaseView.js +43 -0
  72. package/lib-module/utils/BaseView/BaseView.native.js +6 -0
  73. package/lib-module/utils/BaseView/index.js +2 -0
  74. package/lib-module/utils/index.js +2 -1
  75. package/lib-module/utils/input.js +11 -3
  76. package/lib-module/utils/props/handlerProps.js +5 -0
  77. package/package.json +6 -3
  78. package/src/BaseProvider/index.jsx +4 -1
  79. package/src/Box/Box.jsx +14 -1
  80. package/src/Button/ButtonBase.jsx +4 -2
  81. package/src/Button/ButtonDropdown.jsx +179 -0
  82. package/src/Button/index.js +2 -1
  83. package/src/Carousel/Carousel.jsx +48 -13
  84. package/src/Carousel/CarouselItem/CarouselItem.jsx +9 -2
  85. package/src/Carousel/CarouselTabs/CarouselTabsPanel.jsx +19 -15
  86. package/src/FlexGrid/Col/Col.jsx +4 -4
  87. package/src/FlexGrid/FlexGrid.jsx +11 -10
  88. package/src/FlexGrid/Row/Row.jsx +4 -3
  89. package/src/IconButton/IconButton.jsx +3 -1
  90. package/src/MultiSelectFilter/MultiSelectFilter.jsx +227 -0
  91. package/src/MultiSelectFilter/dictionary.js +12 -0
  92. package/src/MultiSelectFilter/index.js +3 -0
  93. package/src/Pagination/SideButton.jsx +5 -5
  94. package/src/Responsive/Responsive.jsx +33 -0
  95. package/src/Responsive/index.js +3 -0
  96. package/src/Search/Search.jsx +19 -33
  97. package/src/Select/Picker.native.jsx +29 -14
  98. package/src/Select/Select.jsx +7 -1
  99. package/src/Select/constants.js +5 -0
  100. package/src/StepTracker/Step.jsx +5 -1
  101. package/src/Tags/Tags.jsx +46 -33
  102. package/src/TextInput/TextInput.jsx +5 -0
  103. package/src/TextInput/TextInputBase.jsx +85 -20
  104. package/src/TextInput/dictionary.js +8 -0
  105. package/src/ThemeProvider/ThemeProvider.jsx +5 -1
  106. package/src/index.js +2 -0
  107. package/src/utils/BaseView/BaseView.jsx +38 -0
  108. package/src/utils/BaseView/BaseView.native.jsx +6 -0
  109. package/src/utils/BaseView/index.js +3 -0
  110. package/src/utils/index.js +1 -0
  111. package/src/utils/input.js +9 -4
  112. package/src/utils/props/handlerProps.js +4 -0
@@ -0,0 +1,17 @@
1
+ const defaultConfig = require('./jest.config')
2
+
3
+ const config = { ...defaultConfig }
4
+
5
+ // Run tests so React Native sees Platform as 'android'
6
+ config.haste.defaultPlatform = 'android'
7
+ // Save snapshots with `.android` in filename
8
+ config.snapshotResolver = './jest-snapshots/resolver-android.js'
9
+
10
+ // Ignore non-applicable test files
11
+ config.testPathIgnorePatterns = [
12
+ ...(config.testPathIgnorePatterns || []),
13
+ '\\.web\\.test\\.',
14
+ '\\.ios\\.test\\.'
15
+ ]
16
+
17
+ module.exports = config
@@ -0,0 +1,18 @@
1
+ const defaultConfig = require('./jest.config')
2
+
3
+ const config = { ...defaultConfig }
4
+
5
+ // ios is the React Native Jest default, but let's make it explicit:
6
+ // Run tests so React Native sees Platform as 'ios'
7
+ config.haste.defaultPlatform = 'ios'
8
+ // Save snapshots with `.ios` in filename
9
+ config.snapshotResolver = './jest-snapshots/resolver-ios.js'
10
+
11
+ // Ignore non-applicable test files
12
+ config.testPathIgnorePatterns = [
13
+ ...(config.testPathIgnorePatterns || []),
14
+ '\\.web\\.test\\.',
15
+ '\\.android\\.test\\.'
16
+ ]
17
+
18
+ module.exports = config
@@ -0,0 +1,31 @@
1
+ const defaultConfig = require('./jest.config')
2
+
3
+ const config = { ...defaultConfig }
4
+
5
+ // Run tests so React Native sees Platform as 'web'
6
+ config.haste.defaultPlatform = 'web'
7
+ config.haste.platforms = [...config.haste.platforms, 'web']
8
+
9
+ // Save snapshots with `.web` in filename
10
+ config.snapshotResolver = './jest-snapshots/resolver-web.js'
11
+ // Alias react-native to react-native-web
12
+ config.moduleNameMapper = {
13
+ '^react-native$': 'react-native-web',
14
+ ...config.moduleNameMapper
15
+ }
16
+
17
+ // Don't include the original react native setup file as it doesn't work with web
18
+ // React-native-web no longer has a matching file so it gets lost looking for `..\Libraries\...` etc
19
+ config.setupFiles = config.setupFiles.filter(
20
+ (file) => !file.match(/[\\/]react-native[\\/]jest[\\/]/)
21
+ )
22
+
23
+ // Ignore non-applicable test files
24
+ config.testPathIgnorePatterns = [
25
+ ...(config.testPathIgnorePatterns || []),
26
+ '\\.native\\.test\\.',
27
+ '\\.android\\.test\\.',
28
+ '\\.ios\\.test\\.'
29
+ ]
30
+
31
+ module.exports = config
@@ -50,7 +50,8 @@ BaseProvider.propTypes = {
50
50
  children: _propTypes.default.node.isRequired,
51
51
  defaultTheme: (_ThemeProvider$propTy = _ThemeProvider.default.propTypes) === null || _ThemeProvider$propTy === void 0 ? void 0 : _ThemeProvider$propTy.defaultTheme,
52
52
  themeOptions: _propTypes.default.shape({
53
- forceAbsoluteFontSizing: _propTypes.default.bool
53
+ forceAbsoluteFontSizing: _propTypes.default.bool,
54
+ forceZIndex: _propTypes.default.bool
54
55
  })
55
56
  };
56
57
  var _default = BaseProvider;
package/lib/Box/Box.js CHANGED
@@ -34,9 +34,22 @@ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_u
34
34
  */
35
35
 
36
36
  const selectBoxStyles = tokens => {
37
- const styles = {
37
+ let styles = {
38
38
  backgroundColor: tokens.backgroundColor
39
39
  };
40
+
41
+ if (tokens.gradient) {
42
+ const {
43
+ gradient: {
44
+ angle,
45
+ stops: [stopOne, stopTwo]
46
+ }
47
+ } = tokens;
48
+ styles = { ...styles,
49
+ backgroundImage: "linear-gradient(".concat(angle, "deg, ").concat(stopOne.color, ", 75% , ").concat(stopTwo.color, ")")
50
+ };
51
+ }
52
+
40
53
  const paddings = ['paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom']; // Only set on styles if token provided because we spread this object after the spacing scale values
41
54
 
42
55
  paddings.forEach(side => {
@@ -163,7 +163,9 @@ const selectTextStyles = (_ref6, themeOptions) => {
163
163
  lineHeight,
164
164
  fontName,
165
165
  fontWeight,
166
- textAlign
166
+ textAlign,
167
+ textLine,
168
+ textLineStyle
167
169
  } = _ref6;
168
170
  return (0, _ThemeProvider.applyTextStyles)({
169
171
  fontSize,
@@ -172,7 +174,9 @@ const selectTextStyles = (_ref6, themeOptions) => {
172
174
  fontName,
173
175
  fontWeight,
174
176
  themeOptions,
175
- textAlign
177
+ textAlign,
178
+ textDecorationLine: textLine,
179
+ textDecorationStyle: textLineStyle
176
180
  });
177
181
  };
178
182
 
@@ -0,0 +1,207 @@
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 _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
13
+
14
+ var _Text = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Text"));
15
+
16
+ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
17
+
18
+ var _propTypes2 = _interopRequireWildcard(require("./propTypes"));
19
+
20
+ var _ButtonBase = _interopRequireDefault(require("./ButtonBase"));
21
+
22
+ var _ThemeProvider = require("../ThemeProvider");
23
+
24
+ var _utils = require("../utils");
25
+
26
+ var _Icon = _interopRequireDefault(require("../Icon"));
27
+
28
+ var _StackView = require("../StackView");
29
+
30
+ var _pressability = require("../utils/pressability");
31
+
32
+ var _jsxRuntime = require("react/jsx-runtime");
33
+
34
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
+
36
+ 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); }
37
+
38
+ 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; }
39
+
40
+ const selectIconTokens = _ref => {
41
+ let {
42
+ icon,
43
+ iconPosition,
44
+ iconSpace,
45
+ iconSize,
46
+ iconColor,
47
+ iconBackground,
48
+ iconBorderRadius,
49
+ iconAlignSelf,
50
+ iconPadding,
51
+ iconTranslateX,
52
+ iconTranslateY
53
+ } = _ref;
54
+ return {
55
+ icon,
56
+ iconPosition,
57
+ iconSpace,
58
+ iconWrapperStyle: {
59
+ backgroundColor: iconBackground,
60
+ borderRadius: iconBorderRadius,
61
+ alignSelf: iconAlignSelf,
62
+ padding: iconPadding,
63
+ ..._Platform.default.select({
64
+ // TODO: https://github.com/telus/universal-design-system/issues/487
65
+ web: {
66
+ transition: 'color 200ms, background 200ms'
67
+ }
68
+ })
69
+ },
70
+ iconTokens: {
71
+ size: iconSize,
72
+ color: iconColor,
73
+ translateX: iconTranslateX,
74
+ translateY: iconTranslateY
75
+ }
76
+ };
77
+ };
78
+
79
+ const ButtonDropdown = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
80
+ let {
81
+ value,
82
+ initialValue,
83
+ onChange,
84
+ label,
85
+ tokens,
86
+ variant,
87
+ inactive = false,
88
+ readOnly = false,
89
+ children = null,
90
+ accessibilityRole = 'radio',
91
+ ...props
92
+ } = _ref2;
93
+ const {
94
+ currentValue: isOpen,
95
+ setValue: setIsOpen
96
+ } = (0, _utils.useInputValue)({
97
+ value,
98
+ initialValue,
99
+ onChange,
100
+ readOnly
101
+ }, 'useButtonDropdownValues');
102
+ const extraState = {
103
+ open: isOpen,
104
+ inactive,
105
+ ...variant
106
+ };
107
+ const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('ButtonDropdown', tokens, extraState);
108
+
109
+ const getButtonTokens = buttonState => (0, _utils.selectTokens)('Button', getTokens(buttonState)); // Pass an object of relevant component state as first argument for any passed-in press handlers
110
+
111
+
112
+ const pressHandlers = (0, _pressability.getPressHandlersWithArgs)(props, [{
113
+ label,
114
+ open: isOpen
115
+ }]);
116
+
117
+ const handlePress = event => {
118
+ if (!inactive) {
119
+ if (pressHandlers.onPress) pressHandlers === null || pressHandlers === void 0 ? void 0 : pressHandlers.onPress(event);
120
+ setIsOpen(!isOpen, event);
121
+ }
122
+ };
123
+
124
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, {
125
+ ref: ref,
126
+ ...pressHandlers,
127
+ onPress: handlePress,
128
+ tokens: getButtonTokens,
129
+ inactive: inactive,
130
+ icon: () => null,
131
+ accessibilityRole: accessibilityRole,
132
+ ...props,
133
+ children: _ref3 => {
134
+ let {
135
+ textStyles,
136
+ ...buttonState
137
+ } = _ref3;
138
+ // TODO: once Icon/IconButton designs are stable, see if this sort of styling around
139
+ // an icon should go in Icon itself, or possibly via an IconText token set. Related issues:
140
+ // - Icon: https://github.com/telus/universal-design-system/issues/327
141
+ // - IconButton: https://github.com/telus/universal-design-system/issues/281
142
+ // - Token sets: https://github.com/telus/universal-design-system/issues/782
143
+ const itemTokens = getTokens(buttonState);
144
+ const {
145
+ iconTokens,
146
+ iconPosition,
147
+ iconSpace,
148
+ iconWrapperStyle,
149
+ icon: IconComponent
150
+ } = selectIconTokens(itemTokens);
151
+ const iconContent = IconComponent ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
152
+ style: iconWrapperStyle,
153
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
154
+ icon: IconComponent,
155
+ tokens: iconTokens
156
+ })
157
+ }) : null;
158
+
159
+ const childrenContent = () => typeof children === 'function' ? children({ ...(0, _utils.resolvePressableState)(buttonState, extraState),
160
+ textStyles
161
+ }) : children;
162
+
163
+ const content = children ? childrenContent() : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
164
+ style: textStyles,
165
+ children: label
166
+ });
167
+ return (0, _StackView.getStackedContent)(iconPosition === 'left' ? [iconContent, content] : [content, iconContent], {
168
+ space: iconSpace,
169
+ direction: 'row'
170
+ });
171
+ }
172
+ });
173
+ });
174
+ ButtonDropdown.displayName = 'ButtonDropdown';
175
+ ButtonDropdown.propTypes = { ..._utils.a11yProps.types,
176
+ ..._utils.focusHandlerProps.types,
177
+ ..._propTypes2.default,
178
+ children: _propTypes2.textAndA11yText,
179
+
180
+ /**
181
+ * Callback called when a controlled ButtonDropdown gets interacted with.
182
+ */
183
+ onChange: _propTypes.default.func,
184
+
185
+ /**
186
+ * `value` prop is being used to set the 'open' state of ButtonDropdown. Use it for
187
+ * controlled ButtonDropdown. For uncontrolled ButtonDropdown, use `initialValue`.
188
+ */
189
+ value: _propTypes.default.bool,
190
+
191
+ /**
192
+ * Use `initialValue` to provide the initial value for an uncontrolled version.
193
+ */
194
+ initialValue: _propTypes.default.bool,
195
+
196
+ /**
197
+ * The label of ButtonDropdown.
198
+ */
199
+ label: _propTypes.default.string,
200
+
201
+ /**
202
+ * By default, `ButtonDropdown` is treated by accessibility tools as a radio button.
203
+ */
204
+ accessibilityRole: _propTypes.default.string
205
+ };
206
+ var _default = ButtonDropdown;
207
+ exports.default = _default;
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "Button", {
9
9
  return _Button.default;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "ButtonDropdown", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _ButtonDropdown.default;
16
+ }
17
+ });
12
18
  Object.defineProperty(exports, "ButtonGroup", {
13
19
  enumerable: true,
14
20
  get: function () {
@@ -28,4 +34,6 @@ var _ButtonLink = _interopRequireDefault(require("./ButtonLink"));
28
34
 
29
35
  var _ButtonGroup = _interopRequireDefault(require("./ButtonGroup"));
30
36
 
37
+ var _ButtonDropdown = _interopRequireDefault(require("./ButtonDropdown"));
38
+
31
39
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -157,6 +157,8 @@ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_u
157
157
  */
158
158
 
159
159
  const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
160
+ var _systemProps$accessib;
161
+
160
162
  let {
161
163
  tokens,
162
164
  variant,
@@ -180,7 +182,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
180
182
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_CarouselStepTracker.default, {}),
181
183
  tag = 'ul',
182
184
  accessibilityRole,
183
- accessibilityLabel = title,
185
+ accessibilityLabel,
184
186
  accessibilityLiveRegion = 'polite',
185
187
  copy,
186
188
  ...rest
@@ -340,7 +342,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
340
342
  setActiveIndex(index);
341
343
  toValue.x = containerLayout.width * -1 * calcDelta;
342
344
  animate(toValue, index);
343
- if (onIndexChanged) onIndexChanged(calcDelta);
345
+ if (onIndexChanged) onIndexChanged(calcDelta, index);
344
346
  return calcDelta;
345
347
  }, [containerLayout.width, activeIndex, animate, children.length, onIndexChanged]);
346
348
 
@@ -451,6 +453,33 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
451
453
  const activePanelNavigation = tabs && showPanelTabs ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_CarouselTabsPanel.default, {
452
454
  items: tabs
453
455
  }) : panelNavigation;
456
+ const isFirstFocusContainer = Boolean(refocus && !skipLinkHref);
457
+
458
+ const containerRef = element => {
459
+ // Apply both firstFocusRef to the container
460
+ firstFocusRef.current = element; // Also apply forwarded ref if there is one (which could be a function ref)
461
+
462
+ if (ref) {
463
+ if (typeof ref === 'object') {
464
+ // eslint-disable-next-line no-param-reassign
465
+ ref.current = element;
466
+ } else if (typeof ref === 'function') {
467
+ ref(element);
468
+ }
469
+ }
470
+ }; // If container isn't used for focus, give it a label of title if none is passed in,
471
+ // otherwise read the current position on focus
472
+
473
+
474
+ const containerAccessibilityLabel = ((_systemProps$accessib = systemProps.accessibilityLabel) !== null && _systemProps$accessib !== void 0 ? _systemProps$accessib : isFirstFocusContainer) ? "".concat(title ? "".concat(title, " ") : '').concat(getCopyWithPlaceholders('stepTrackerLabel')) : title;
475
+ const containerProps = {
476
+ accessibilityLabel: containerAccessibilityLabel,
477
+ // If used for focus, attach the ref and draw a focus box around the whole carousel
478
+ ...(isFirstFocusContainer && {
479
+ ref: containerRef,
480
+ focusable: true
481
+ })
482
+ };
454
483
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_CarouselContext.CarouselProvider, {
455
484
  activeIndex: activeIndex,
456
485
  goTo: goTo,
@@ -466,6 +495,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
466
495
  onLayout: onContainerLayout,
467
496
  ref: ref,
468
497
  ...systemProps,
498
+ ...containerProps,
469
499
  children: [showPreviousNextNavigation && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
470
500
  style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, true),
471
501
  testID: "previous-button-container",
@@ -480,12 +510,10 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
480
510
  ref: firstFocusRef,
481
511
  href: skipLinkHref,
482
512
  children: getCopyWithPlaceholders('skipLink')
483
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_A11yText.default // Read the current slide position to screen readers on slide.
513
+ }), !isFirstFocusContainer && /*#__PURE__*/(0, _jsxRuntime.jsx)(_A11yText.default // Read the current slide position to screen readers on slide.
484
514
  // If it's set to refocus and doesn't have a SkipLink to focus to, focus this.
485
515
  , {
486
- ref: !skipLinkHref && refocus ? firstFocusRef : null,
487
516
  accessibilityLiveRegion: !skipLinkHref && refocus ? undefined : 'polite',
488
- focusable: !skipLinkHref && refocus,
489
517
  text: getCopyWithPlaceholders('stepTrackerLabel')
490
518
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
491
519
  style: selectContainerStyles(containerLayout.width),
@@ -589,7 +617,7 @@ Carousel.propTypes = { ...selectedSystemPropTypes,
589
617
  * This function is also provided with a parameter indicating changed index (either 1, or -1)
590
618
  * Use it as follows:
591
619
  * ```js
592
- * const onIndexChangedCallback = React.useCallback((changedIndex) => {
620
+ * const onIndexChangedCallback = React.useCallback((changedIndex, currentActiveIndex) => {
593
621
  * console.log(changedIndex)
594
622
  * }, []) // pass local dependencies as per your component
595
623
  * <Carousel
@@ -61,6 +61,7 @@ const CarouselItem = _ref => {
61
61
  };
62
62
 
63
63
  CarouselItem.propTypes = { ...selectedSystemPropTypes,
64
+ variant: _utils.variantProp.propType,
64
65
 
65
66
  /**
66
67
  * Index of the current slide
@@ -85,7 +86,12 @@ CarouselItem.propTypes = { ...selectedSystemPropTypes,
85
86
  * Carousel's innermost container defaults to `'ul'` which can be overridden. If the tag of either
86
87
  * `Carousel` or `Carousel.Item` is overriden, the other should be too, to avoid producing invalid HTML.
87
88
  */
88
- tag: _propTypes.default.oneOf(_utils.layoutTags)
89
+ tag: _propTypes.default.oneOf(_utils.layoutTags),
90
+
91
+ /**
92
+ * Function to set carousel content background color when slide is being display
93
+ */
94
+ setContentBackgroundColor: _propTypes.default.func
89
95
  };
90
96
  CarouselItem.displayName = 'Carousel.Item';
91
97
  var _default = CarouselItem;
@@ -25,6 +25,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
25
25
 
26
26
  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; }
27
27
 
28
+ const selectTabPanelStyle = () => ({
29
+ backgroundColor: 'transparent'
30
+ });
31
+
28
32
  const CarouselTabsPanel = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
29
33
  let {
30
34
  items
@@ -34,25 +38,23 @@ const CarouselTabsPanel = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
34
38
  goTo
35
39
  } = (0, _CarouselContext.useCarousel)();
36
40
  const nextFocusRef = (0, _react.useRef)();
37
- const firstTabRef = (0, _react.useRef)(); // TODO: figure out a better cross-brand way to specify subcomponent variants.
41
+ const firstTabRef = (0, _react.useRef)();
42
+ const [isInverse, setIsInverse] = (0, _react.useState)(false); // TODO: figure out a better cross-brand way to specify subcomponent variants.
38
43
  // For now, this picks an Allium variant, and does nothing in brands that lack it.
39
44
  // See similar comment in Carousel and https://github.com/telus/universal-design-system/issues/1549
40
45
 
41
46
  const dividerVariant = {
42
47
  decorative: true
43
48
  };
44
- const lastTabSelected = activeIndex === items.length - 1;
45
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
46
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
47
- focusable: true,
48
- accessible: true,
49
- onFocus: event => {
50
- // When user forward-tabs into this section, focus the next tab; if they backwards-tab
51
- // (shift-tab) back into the carousel content, don't interfere.
52
- const previousWebFocus = event.relatedTarget;
53
- if (previousWebFocus !== firstTabRef.current) nextFocusRef.current.focus();
54
- }
55
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.default, {
49
+ const lastTabSelected = activeIndex === items.length - 1; // Get current select tab style
50
+
51
+ (0, _react.useEffect)(() => {
52
+ const [selectedVariantIsInverse] = items.filter((_, index) => index === activeIndex);
53
+ setIsInverse(selectedVariantIsInverse === null || selectedVariantIsInverse === void 0 ? void 0 : selectedVariantIsInverse.inverse);
54
+ }, [items, activeIndex]);
55
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
56
+ style: selectTabPanelStyle(),
57
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.default, {
56
58
  direction: "row",
57
59
  space: 3,
58
60
  divider: {
@@ -63,6 +65,7 @@ const CarouselTabsPanel = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
63
65
  let {
64
66
  title,
65
67
  onPress,
68
+ inverse,
66
69
  ...panelItemProps
67
70
  } = _ref2;
68
71
  const selected = index === activeIndex;
@@ -77,6 +80,9 @@ const CarouselTabsPanel = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
77
80
  title: title,
78
81
  selected: selected,
79
82
  onPress: handlePress,
83
+ variant: {
84
+ inverse: isInverse
85
+ },
80
86
  ...panelItemProps
81
87
  }, title);
82
88
  })
@@ -89,7 +95,9 @@ const CarouselTabsPanel = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
89
95
  });
90
96
  CarouselTabsPanel.displayName = 'CarouselTabsPanel';
91
97
  CarouselTabsPanel.propTypes = {
92
- items: _propTypes.default.arrayOf(_propTypes.default.shape(_CarouselTabsPanelItem.default.propTypes || {}))
98
+ items: _propTypes.default.arrayOf(_propTypes.default.shape(_CarouselTabsPanelItem.default.propTypes || {})),
99
+ // Color defined by `Carousel.item` variant otherwise fallback to transparent
100
+ contentBackgroundColor: _propTypes.default.string
93
101
  };
94
102
  var _default = CarouselTabsPanel;
95
103
  exports.default = _default;
@@ -13,8 +13,6 @@ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/export
13
13
 
14
14
  var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
15
15
 
16
- var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
17
-
18
16
  var _systemConstants = require("@telus-uds/system-constants");
19
17
 
20
18
  var _GutterContext = _interopRequireDefault(require("../providers/GutterContext"));
@@ -180,7 +178,7 @@ const Col = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
180
178
  lg: offsetsWithIheritance[3],
181
179
  xl: offsetsWithIheritance[4]
182
180
  };
183
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
181
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_utils.BaseView, {
184
182
  ref: ref,
185
183
  ...viewProps,
186
184
  style: [styles.col, gutterPadding, offsetStyles(offsets), sizeStyles(sizes), { ...hidingStyles
@@ -9,12 +9,12 @@ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
13
-
14
12
  var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
15
13
 
16
14
  var _systemConstants = require("@telus-uds/system-constants");
17
15
 
16
+ var _utils = require("../utils");
17
+
18
18
  var _Row = _interopRequireDefault(require("./Row"));
19
19
 
20
20
  var _Col = _interopRequireDefault(require("./Col"));
@@ -25,8 +25,6 @@ var _GutterContext = _interopRequireDefault(require("./providers/GutterContext")
25
25
 
26
26
  var _helpers = _interopRequireDefault(require("./helpers"));
27
27
 
28
- var _utils = require("../utils");
29
-
30
28
  var _jsxRuntime = require("react/jsx-runtime");
31
29
 
32
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -93,7 +91,7 @@ const FlexGrid = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
93
91
  };
94
92
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GutterContext.default.Provider, {
95
93
  value: gutter,
96
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
94
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_utils.BaseView, {
97
95
  ref: ref,
98
96
  ...props,
99
97
  style: [styles.grid, {
@@ -9,8 +9,6 @@ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
13
-
14
12
  var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
15
13
 
16
14
  var _systemConstants = require("@telus-uds/system-constants");
@@ -19,6 +17,8 @@ var _ViewportProvider = require("../../ViewportProvider");
19
17
 
20
18
  var _helpers = _interopRequireDefault(require("../helpers"));
21
19
 
20
+ var _utils = require("../../utils");
21
+
22
22
  var _jsxRuntime = require("react/jsx-runtime");
23
23
 
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -134,7 +134,7 @@ const Row = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
134
134
  flexWrap = reverseLevel[4] ? 'wrap-reverse' : 'wrap';
135
135
  }
136
136
 
137
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
137
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_utils.BaseView, {
138
138
  ref: ref,
139
139
  ...rest,
140
140
  style: [styles.row, {
@@ -103,10 +103,18 @@ const IconButton = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
103
103
  accessibilityRole
104
104
  });
105
105
 
106
- const handlePress = _utils.linkProps.handleHref({
107
- href,
108
- onPress
109
- });
106
+ const handlePress = () => {
107
+ var _ref$current;
108
+
109
+ _utils.linkProps.handleHref({
110
+ href,
111
+ onPress
112
+ })({
113
+ nativeEvent: {
114
+ target: ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.id
115
+ }
116
+ });
117
+ };
110
118
 
111
119
  const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('IconButton', tokens, variant);
112
120