@telus-uds/components-base 2.4.0 → 2.5.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 (82) hide show
  1. package/CHANGELOG.md +15 -2
  2. package/lib/A11yInfoProvider/index.js +2 -2
  3. package/lib/Autocomplete/Autocomplete.js +22 -32
  4. package/lib/Autocomplete/Suggestions.js +1 -1
  5. package/lib/BaseProvider/HydrationContext.js +1 -2
  6. package/lib/BaseProvider/index.js +1 -2
  7. package/lib/Button/ButtonDropdown.js +1 -1
  8. package/lib/Card/Card.js +12 -13
  9. package/lib/Card/CardBase.js +1 -1
  10. package/lib/Card/PressableCardBase.js +1 -1
  11. package/lib/CardGroup/CardGroup.js +3 -3
  12. package/lib/Carousel/Carousel.js +5 -6
  13. package/lib/Carousel/CarouselStepTracker/CarouselStepTracker.js +3 -0
  14. package/lib/Carousel/CarouselTabs/CarouselTabs.js +1 -2
  15. package/lib/Carousel/CarouselTabs/CarouselTabsPanel.js +1 -1
  16. package/lib/Carousel/CarouselTabs/CarouselTabsPanelItem.js +1 -1
  17. package/lib/Carousel/CarouselThumbnail.js +1 -1
  18. package/lib/Checkbox/Checkbox.js +1 -1
  19. package/lib/ColourToggle/ColourToggle.js +1 -1
  20. package/lib/ExpandCollapseMini/ExpandCollapseMini.js +77 -0
  21. package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +126 -0
  22. package/lib/ExpandCollapseMini/index.js +2 -0
  23. package/lib/Footnote/Footnote.js +4 -4
  24. package/lib/HorizontalScroll/HorizontalScroll.js +1 -2
  25. package/lib/Icon/Icon.js +1 -1
  26. package/lib/Icon/IconText.js +2 -3
  27. package/lib/IconButton/IconButton.js +1 -2
  28. package/lib/InputSupports/InputSupports.js +4 -4
  29. package/lib/Link/LinkBase.js +8 -3
  30. package/lib/List/List.js +1 -2
  31. package/lib/List/ListItemContent.js +1 -1
  32. package/lib/Listbox/Listbox.js +5 -8
  33. package/lib/Listbox/PressableItem.js +4 -4
  34. package/lib/Modal/Modal.js +4 -7
  35. package/lib/MultiSelectFilter/MultiSelectFilter.js +1 -1
  36. package/lib/Notification/Notification.js +10 -12
  37. package/lib/OrderedList/OrderedList.js +2 -3
  38. package/lib/Pagination/usePagination.js +1 -2
  39. package/lib/PriceLockup/utils/renderFootnoteContent.js +2 -2
  40. package/lib/PriceLockup/utils/renderFootnoteLinks.js +2 -2
  41. package/lib/PriceLockup/utils/renderPrice.js +2 -2
  42. package/lib/ProductCard/ProductCard.js +2 -3
  43. package/lib/Progress/ProgressBarBackground.js +2 -2
  44. package/lib/QuickLinksFeature/QuickLinksFeature.js +1 -2
  45. package/lib/Radio/Radio.js +1 -1
  46. package/lib/Search/Search.js +2 -3
  47. package/lib/Select/Picker.js +2 -2
  48. package/lib/StackView/StackWrap.js +1 -4
  49. package/lib/StackView/getStackedContent.js +1 -2
  50. package/lib/StepTracker/StepTracker.js +1 -2
  51. package/lib/TabBar/TabBar.js +1 -1
  52. package/lib/Tabs/Tabs.js +1 -1
  53. package/lib/Tabs/TabsItem.js +2 -2
  54. package/lib/TextInput/TextArea.js +1 -1
  55. package/lib/TextInput/TextInput.js +1 -1
  56. package/lib/TextInput/TextInputBase.js +10 -12
  57. package/lib/ThemeProvider/utils/theme-tokens.js +2 -4
  58. package/lib/Timeline/Timeline.js +1 -2
  59. package/lib/Tooltip/Tooltip.native.js +4 -4
  60. package/lib/Typography/Typography.js +4 -5
  61. package/lib/Validator/Validator.js +9 -14
  62. package/lib/ViewportProvider/useViewportListener.js +1 -1
  63. package/lib/index.js +1 -0
  64. package/lib/utils/children.js +2 -6
  65. package/lib/utils/input.js +1 -1
  66. package/lib/utils/props/componentPropType.js +1 -2
  67. package/lib/utils/props/selectSystemProps.js +2 -2
  68. package/lib/utils/ssr-media-query/create-stylesheet/create-stylesheet-mobile.js +1 -1
  69. package/lib/utils/ssr-media-query/create-stylesheet/index.js +2 -3
  70. package/lib/utils/ssr-media-query/utils/inject.js +3 -5
  71. package/lib/utils/useHash.js +1 -4
  72. package/lib/utils/useOverlaidPosition.js +25 -4
  73. package/lib/utils/useScrollBlocking.js +2 -4
  74. package/lib/utils/useSpacingScale.js +2 -2
  75. package/package.json +1 -1
  76. package/src/Carousel/CarouselStepTracker/CarouselStepTracker.jsx +3 -0
  77. package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +76 -0
  78. package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +119 -0
  79. package/src/ExpandCollapseMini/index.js +3 -0
  80. package/src/Link/LinkBase.jsx +8 -3
  81. package/src/index.js +1 -0
  82. package/src/utils/useOverlaidPosition.js +23 -0
@@ -0,0 +1,126 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Platform from "react-native-web/dist/exports/Platform";
4
+ import { Link } from '../Link';
5
+ import { useThemeTokens } from '../ThemeProvider';
6
+ import { htmlAttrs, viewProps, selectSystemProps } from '../utils';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs, viewProps]);
9
+
10
+ // The ExpandCollapseControl has all the appropriate role, a11y, press handling etc
11
+ // and a more appropriate press area, defer interaction handling to it.
12
+ const presentationOnly = {
13
+ accessibilityRole: null,
14
+ // Treat as regular flow content with the Control
15
+ pointerEvents: 'none',
16
+ // Stop RNW from stopping clicks from bubbling to Control
17
+ focusable: false // Stop RNW from setting tabIndex={0}: focus goes to Control only
18
+ };
19
+ const selectLinkTokens = _ref => {
20
+ let {
21
+ color,
22
+ textLine,
23
+ lineHeight,
24
+ fontSize
25
+ } = _ref;
26
+ return {
27
+ color,
28
+ textLine,
29
+ blockLineHeight: lineHeight,
30
+ blockFontSize: fontSize
31
+ };
32
+ };
33
+ const ExpandCollapseMiniControl = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
34
+ let {
35
+ pressableState,
36
+ collapseTitle,
37
+ expandTitle = collapseTitle,
38
+ iconPosition = 'right',
39
+ tokens,
40
+ variant = {},
41
+ ...rest
42
+ } = _ref2;
43
+ const {
44
+ expanded,
45
+ hover,
46
+ focus
47
+ } = pressableState || {};
48
+ // we only want focus outline when focusing, if user is pressing we don't want the border.
49
+ const {
50
+ outerBorderColor
51
+ } = useThemeTokens('Link', {}, {}, {
52
+ focus: Platform.OS !== 'web' ? expanded : focus
53
+ });
54
+ const {
55
+ size,
56
+ icon,
57
+ ...themeTokens
58
+ } = useThemeTokens('ExpandCollapseMiniControl', tokens, variant, {
59
+ expanded,
60
+ focus
61
+ });
62
+
63
+ // Choose hover styles when any part of Control is hoverred
64
+ const appearance = {
65
+ ...variant,
66
+ hover
67
+ };
68
+ const getTokens = linkState => {
69
+ const {
70
+ hover: linkHover
71
+ } = linkState || {};
72
+ const isHovered = hover || linkHover;
73
+ if (Platform.OS !== 'web') {
74
+ return {
75
+ iconTranslateY: -1
76
+ };
77
+ }
78
+ if (isHovered) {
79
+ // Include vertical icon animation on hover alongside built-in Link theme, the size is size4
80
+ return {
81
+ iconTranslateY: (expanded ? -1 : 1) * size
82
+ };
83
+ }
84
+ return {};
85
+ };
86
+ return /*#__PURE__*/_jsx(Link, {
87
+ variant: appearance,
88
+ icon: icon,
89
+ iconPosition: iconPosition,
90
+ tokens: linkState => ({
91
+ ...getTokens(linkState),
92
+ ...selectLinkTokens(themeTokens),
93
+ outerBorderColor
94
+ }),
95
+ ref: ref,
96
+ ...presentationOnly,
97
+ ...selectProps(rest),
98
+ children: expanded ? expandTitle : collapseTitle
99
+ });
100
+ });
101
+ ExpandCollapseMiniControl.displayName = 'ExpandCollapseMiniControl';
102
+ ExpandCollapseMiniControl.propTypes = {
103
+ ...selectedSystemPropTypes,
104
+ ...Link.propTypes,
105
+ /**
106
+ * Optional function to call on pressing the panel's control, in addition to opening or closing the panel
107
+ */
108
+ onPress: PropTypes.func,
109
+ /**
110
+ * ExpandCollapseMiniControl title when expanded
111
+ */
112
+ expandTitle: PropTypes.string.isRequired,
113
+ /**
114
+ * ExpandCollapseMiniControl title when collapsed
115
+ */
116
+ collapseTitle: PropTypes.string.isRequired,
117
+ /**
118
+ * React Native's `Pressable`'s state object
119
+ */
120
+ pressableState: PropTypes.object,
121
+ /**
122
+ * Optional variant object to override the default theme tokens
123
+ */
124
+ variant: PropTypes.object
125
+ };
126
+ export default ExpandCollapseMiniControl;
@@ -0,0 +1,2 @@
1
+ import ExpandCollapseMini from './ExpandCollapseMini';
2
+ export default ExpandCollapseMini;
@@ -206,8 +206,8 @@ const Footnote = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
206
206
  style: [selectFootnoteHeaderContentStyle(themeTokens), staticStyles.headerContent],
207
207
  children: [/*#__PURE__*/_jsx(Typography, {
208
208
  tokens: {
209
- fontSize: themeTokens === null || themeTokens === void 0 ? void 0 : themeTokens.headerFontSize,
210
- lineHeight: themeTokens === null || themeTokens === void 0 ? void 0 : themeTokens.headerLineHeight
209
+ fontSize: themeTokens?.headerFontSize,
210
+ lineHeight: themeTokens?.headerLineHeight
211
211
  },
212
212
  variant: {
213
213
  size: 'h4'
@@ -219,9 +219,9 @@ const Footnote = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
219
219
  children: /*#__PURE__*/_jsx(View, {
220
220
  style: [selectFootnoteCloseButtonStyle(themeTokens), staticStyles.closeButton],
221
221
  children: /*#__PURE__*/_jsx(Icon, {
222
- icon: themeTokens === null || themeTokens === void 0 ? void 0 : themeTokens.closeIcon,
222
+ icon: themeTokens?.closeIcon,
223
223
  tokens: {
224
- size: themeTokens === null || themeTokens === void 0 ? void 0 : themeTokens.closeButtonIconSize
224
+ size: themeTokens?.closeButtonIconSize
225
225
  }
226
226
  })
227
227
  })
@@ -74,8 +74,7 @@ const HorizontalScroll = /*#__PURE__*/React.forwardRef((_ref, ref) => {
74
74
  const showPreviousButton = scrollOffset > 0;
75
75
  const scrollRef = React.useRef(null);
76
76
  const scrollTo = targetX => {
77
- var _scrollRef$current;
78
- if (typeof ((_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.scrollTo) === 'function') {
77
+ if (typeof scrollRef.current?.scrollTo === 'function') {
79
78
  const x = getItemPositionScrollTarget(targetX, scrollMax, itemPositions.positions, buttonClearance);
80
79
  scrollRef.current.scrollTo({
81
80
  x,
package/lib/Icon/Icon.js CHANGED
@@ -22,7 +22,7 @@ const Icon = /*#__PURE__*/React.forwardRef((_ref, ref) => {
22
22
  size: size,
23
23
  color: themeTokens.color
24
24
  });
25
- const paddingStyles = variant !== null && variant !== void 0 && variant.padding ? {
25
+ const paddingStyles = variant?.padding ? {
26
26
  padding: themeTokens.width,
27
27
  width: themeTokens.size + themeTokens.width * 2,
28
28
  // sets the diameter of the circle which is the size of the icon plus twice the general padding established to obtain a perfect circle
@@ -18,7 +18,6 @@ import { spacingProps } from '../utils';
18
18
  */
19
19
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
20
  const IconText = /*#__PURE__*/React.forwardRef((_ref, ref) => {
21
- var _iconProps$tokens, _iconProps$tokens2;
22
21
  let {
23
22
  space,
24
23
  iconPosition = 'left',
@@ -35,8 +34,8 @@ const IconText = /*#__PURE__*/React.forwardRef((_ref, ref) => {
35
34
 
36
35
  // Inline images on Android are always baseline-aligned which makes them look misaligned - offset it.
37
36
  // See abandoned issue https://github.com/facebook/react-native/issues/6529
38
- const size = (iconProps === null || iconProps === void 0 || (_iconProps$tokens = iconProps.tokens) === null || _iconProps$tokens === void 0 ? void 0 : _iconProps$tokens.size) ?? 0;
39
- const valueTranslateY = iconProps === null || iconProps === void 0 || (_iconProps$tokens2 = iconProps.tokens) === null || _iconProps$tokens2 === void 0 ? void 0 : _iconProps$tokens2.translateY;
37
+ const size = iconProps?.tokens?.size ?? 0;
38
+ const valueTranslateY = iconProps?.tokens?.translateY;
40
39
  /**
41
40
  * These calculations were carried out using a set of linear equations to calculate that the
42
41
  * position of the icon "->"" is aligned to the first line of the tooltip text on IOS and Android.
@@ -134,13 +134,12 @@ const IconButton = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
134
134
  accessibilityRole
135
135
  });
136
136
  const handlePress = () => {
137
- var _ref$current;
138
137
  linkProps.handleHref({
139
138
  href,
140
139
  onPress
141
140
  })({
142
141
  nativeEvent: {
143
- target: ref === null || ref === void 0 || (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.id
142
+ target: ref?.current?.id
144
143
  }
145
144
  });
146
145
  };
@@ -31,8 +31,8 @@ const InputSupports = /*#__PURE__*/React.forwardRef((_ref, ref) => {
31
31
  dictionary,
32
32
  copy
33
33
  });
34
- const maxCharsReachedErrorMessage = (inputValue === null || inputValue === void 0 ? void 0 : inputValue.length) > maxCharacterAllowed ? getCopy('maxCharsMessage').replace(/%\{charCount\}/g, maxCharacterAllowed) : '';
35
- const feedbackValidation = (inputValue === null || inputValue === void 0 ? void 0 : inputValue.length) > maxCharacterAllowed ? 'error' : validation;
34
+ const maxCharsReachedErrorMessage = inputValue?.length > maxCharacterAllowed ? getCopy('maxCharsMessage').replace(/%\{charCount\}/g, maxCharacterAllowed) : '';
35
+ const feedbackValidation = inputValue?.length > maxCharacterAllowed ? 'error' : validation;
36
36
  const {
37
37
  inputId,
38
38
  hintId,
@@ -46,7 +46,7 @@ const InputSupports = /*#__PURE__*/React.forwardRef((_ref, ref) => {
46
46
  nativeID,
47
47
  copy,
48
48
  maxCharacterAllowed,
49
- charactersCount: maxCharacterAllowed - (inputValue === null || inputValue === void 0 ? void 0 : inputValue.length)
49
+ charactersCount: maxCharacterAllowed - inputValue?.length
50
50
  });
51
51
  return /*#__PURE__*/_jsxs(StackView, {
52
52
  space: space,
@@ -59,7 +59,7 @@ const InputSupports = /*#__PURE__*/React.forwardRef((_ref, ref) => {
59
59
  hintId: hintId,
60
60
  tooltip: tooltip,
61
61
  forId: inputId,
62
- characterCount: inputValue === null || inputValue === void 0 ? void 0 : inputValue.length,
62
+ characterCount: inputValue?.length,
63
63
  maxCharacterAllowed: maxCharacterAllowed
64
64
  }), typeof children === 'function' ? children({
65
65
  inputId,
@@ -87,7 +87,8 @@ const selectIconTokens = _ref5 => {
87
87
  color,
88
88
  iconSize,
89
89
  blockFontSize,
90
- iconTranslateX
90
+ iconTranslateX,
91
+ iconTranslateY
91
92
  } = _ref5;
92
93
  /**
93
94
  * These calculations were carried out using a set of linear equations to calculate that the
@@ -95,11 +96,11 @@ const selectIconTokens = _ref5 => {
95
96
  * The base equation is: X/4 + Y/4 - 4 - |X - Y| = Z
96
97
  * where X = blockFontSize, Y = iconSize and Z = translateY
97
98
  */
98
- const translateY = blockFontSize / 4 + iconSize / 4 - 4 - Math.abs(iconSize - blockFontSize);
99
+ const translateY = iconTranslateY ?? blockFontSize / 4 + iconSize / 4 - 4 - Math.abs(iconSize - blockFontSize);
99
100
  return {
100
101
  color,
101
102
  translateX: iconTranslateX,
102
- translateY: translateY < 0 ? 0 : translateY,
103
+ translateY,
103
104
  size: iconSize
104
105
  };
105
106
  };
@@ -265,6 +266,10 @@ const staticStyles = StyleSheet.create({
265
266
  margin: 0,
266
267
  marginHorizontal: 2,
267
268
  padding: 0
269
+ }),
270
+ ...(Platform.OS === 'android' && {
271
+ paddingHorizontal: 2,
272
+ paddingTop: 2
268
273
  })
269
274
  }
270
275
  });
package/lib/List/List.js CHANGED
@@ -7,8 +7,7 @@ import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
8
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
9
9
  const isListItem = element => {
10
- var _element$type, _element$type2;
11
- const elementName = (element === null || element === void 0 || (_element$type = element.type) === null || _element$type === void 0 ? void 0 : _element$type.displayName) || (element === null || element === void 0 || (_element$type2 = element.type) === null || _element$type2 === void 0 ? void 0 : _element$type2.name);
10
+ const elementName = element?.type?.displayName || element?.type?.name;
12
11
  // Match our own ListItem, and also, custom list items
13
12
  return Boolean(elementName.match(/Item/));
14
13
  };
@@ -49,7 +49,7 @@ const ListItemContent = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
49
49
  } = useTheme();
50
50
  const textStyles = selectItemTextStyles(tokens, themeOptions);
51
51
  return /*#__PURE__*/_jsx(View, {
52
- style: [staticStyles.wrap, (tokens === null || tokens === void 0 ? void 0 : tokens.itemUnderline) && {
52
+ style: [staticStyles.wrap, tokens?.itemUnderline && {
53
53
  textDecorationLine: tokens.itemUnderline,
54
54
  textDecorationColor: tokens.itemFontColor
55
55
  }],
@@ -42,36 +42,33 @@ const Listbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
42
42
  // We need to keep track of each item's ref in order to be able to
43
43
  // focus on a specific item via keyboard navigation
44
44
  const itemRefs = React.useRef([]);
45
- if (firstItemRef !== null && firstItemRef !== void 0 && firstItemRef.current) itemRefs.current[0] = firstItemRef.current;
45
+ if (firstItemRef?.current) itemRefs.current[0] = firstItemRef.current;
46
46
  const [focusedIndex, setFocusedIndex] = React.useState(0);
47
47
  const handleKeydown = React.useCallback(event => {
48
48
  const nextItemRef = itemRefs.current[focusedIndex + 1];
49
49
  const prevItemRef = itemRefs.current[focusedIndex - 1];
50
50
  if (event.key === 'ArrowUp' || event.shiftKey && event.key === 'Tab') {
51
- var _parentRef$current;
52
51
  // Move the focus to the previous item or to the parent one if on the first
53
52
  if (prevItemRef) {
54
53
  event.preventDefault();
55
54
  prevItemRef.focus();
56
- } else if (parentRef) (_parentRef$current = parentRef.current) === null || _parentRef$current === void 0 || _parentRef$current.focus();
55
+ } else if (parentRef) parentRef.current?.focus();
57
56
  setFocusedIndex(focusedIndex - 1);
58
57
  } else if ((event.key === 'ArrowDown' || event.key === 'Tab') && nextItemRef) {
59
58
  event.preventDefault();
60
59
  setFocusedIndex(focusedIndex + 1);
61
60
  nextItemRef.focus();
62
61
  } else if (event.key === 'Escape') {
63
- var _parentRef$current2, _parentRef$current3;
64
62
  // Close the dropdown
65
- parentRef === null || parentRef === void 0 || (_parentRef$current2 = parentRef.current) === null || _parentRef$current2 === void 0 || _parentRef$current2.click();
63
+ parentRef?.current?.click();
66
64
  // Return focus to the dropdown control after leaving the last item
67
- parentRef === null || parentRef === void 0 || (_parentRef$current3 = parentRef.current) === null || _parentRef$current3 === void 0 || _parentRef$current3.focus();
65
+ parentRef?.current?.focus();
68
66
  if (onClose) onClose(event);
69
67
  } else if (!nextItemRef && firstItemRef) {
70
- var _firstItemRef$current;
71
68
  // If the last item is focused, move the focus to the first one
72
69
  event.preventDefault();
73
70
  setFocusedIndex(0);
74
- (_firstItemRef$current = firstItemRef.current) === null || _firstItemRef$current === void 0 || _firstItemRef$current.focus();
71
+ firstItemRef.current?.focus();
75
72
  }
76
73
  }, [focusedIndex, onClose, parentRef, firstItemRef]);
77
74
 
@@ -90,11 +90,11 @@ const PressableItem = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
90
90
  return themeTokens;
91
91
  };
92
92
  const handleKeyPress = event => {
93
- if (['Enter', ' '].includes(event === null || event === void 0 ? void 0 : event.key)) {
94
- onPress === null || onPress === void 0 || onPress(event);
95
- } else if ((event === null || event === void 0 ? void 0 : event.key) === 'ArrowDown') {
93
+ if (['Enter', ' '].includes(event?.key)) {
94
+ onPress?.(event);
95
+ } else if (event?.key === 'ArrowDown') {
96
96
  nextItemRef.current.focus();
97
- } else if ((event === null || event === void 0 ? void 0 : event.key) === 'ArrowUp' && prevItemRef !== null && prevItemRef !== void 0 && prevItemRef.current) {
97
+ } else if (event?.key === 'ArrowUp' && prevItemRef?.current) {
98
98
  prevItemRef.current.focus();
99
99
  }
100
100
  };
@@ -100,7 +100,6 @@ const selectScrollViewStyles = () => ({
100
100
  * - Don’t use modals consecutively
101
101
  */
102
102
  const Modal = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
103
- var _modalContentRef$curr2;
104
103
  let {
105
104
  children,
106
105
  isOpen,
@@ -147,12 +146,11 @@ const Modal = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
147
146
  };
148
147
  const manageFocus = React.useCallback(event => {
149
148
  if (event.key === 'Tab') {
150
- var _modalBodyRef$current;
151
- const focusableElements = Array.from((modalBodyRef === null || modalBodyRef === void 0 || (_modalBodyRef$current = modalBodyRef.current) === null || _modalBodyRef$current === void 0 ? void 0 : _modalBodyRef$current.querySelectorAll(`
149
+ const focusableElements = Array.from(modalBodyRef?.current?.querySelectorAll(`
152
150
  a[href], button, textarea, input, select,
153
151
  [tabindex]:not([tabindex="-1"]),
154
152
  [contenteditable="true"]
155
- `)) || []);
153
+ `) || []);
156
154
  const firstElement = focusableElements[0];
157
155
  const lastElement = focusableElements[focusableElements.length - 1];
158
156
  if (event.shiftKey && document.activeElement === firstElement) {
@@ -184,10 +182,9 @@ const Modal = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
184
182
  }, [manageFocus]);
185
183
  React.useEffect(() => {
186
184
  if (isOpen) {
187
- var _modalContentRef$curr;
188
- modalContentRef === null || modalContentRef === void 0 || (_modalContentRef$curr = modalContentRef.current) === null || _modalContentRef$curr === void 0 || _modalContentRef$curr.focus();
185
+ modalContentRef?.current?.focus();
189
186
  }
190
- }, [isOpen, modalContentRef === null || modalContentRef === void 0 || (_modalContentRef$curr2 = modalContentRef.current) === null || _modalContentRef$curr2 === void 0 ? void 0 : _modalContentRef$curr2.focus]);
187
+ }, [isOpen, modalContentRef?.current?.focus]);
191
188
  if (!isOpen) {
192
189
  return null;
193
190
  }
@@ -177,7 +177,7 @@ const MultiSelectFilter = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
177
177
  currentValues
178
178
  }]);
179
179
  const handleChange = event => {
180
- if (pressHandlers.onPress) pressHandlers === null || pressHandlers === void 0 || pressHandlers.onPress(event);
180
+ if (pressHandlers.onPress) pressHandlers?.onPress(event);
181
181
  if (isOpen) onOpen();
182
182
  setIsOpen(!isOpen);
183
183
  };
@@ -66,11 +66,10 @@ const selectDismissButtonContainerStyles = _ref4 => {
66
66
  const selectContentContainerStyle = (themeTokens, maxWidth, viewport, system) => ({
67
67
  maxWidth: viewport === 'xl' && system === true ? maxWidth : 'auto',
68
68
  minWidth: viewport === 'xl' && system === true ? maxWidth : 'auto',
69
- paddingRight: themeTokens === null || themeTokens === void 0 ? void 0 : themeTokens.containerPaddingRight,
70
- paddingLeft: themeTokens === null || themeTokens === void 0 ? void 0 : themeTokens.containerPaddingLeft
69
+ paddingRight: themeTokens?.containerPaddingRight,
70
+ paddingLeft: themeTokens?.containerPaddingLeft
71
71
  });
72
72
  const getMediaQueryStyles = (themeTokens, themeOptions, mediaIdsRef, dismissible, viewport, system) => {
73
- var _themeOptions$content, _themeOptions$content2, _themeOptions$content3, _themeOptions$content4, _themeOptions$content5;
74
73
  const transformedSelectContainerStyles = Object.entries(themeTokens).reduce((acc, _ref5) => {
75
74
  let [vp, viewportTokens] = _ref5;
76
75
  acc[vp] = selectContainerStyles({
@@ -98,19 +97,19 @@ const getMediaQueryStyles = (themeTokens, themeOptions, mediaIdsRef, dismissible
98
97
  justifyContent: 'space-between',
99
98
  ...createMediaQueryStyles({
100
99
  xs: {
101
- maxWidth: (themeOptions === null || themeOptions === void 0 || (_themeOptions$content = themeOptions.contentMaxWidth) === null || _themeOptions$content === void 0 ? void 0 : _themeOptions$content.xs) || '100%'
100
+ maxWidth: themeOptions?.contentMaxWidth?.xs || '100%'
102
101
  },
103
102
  md: {
104
- maxWidth: (themeOptions === null || themeOptions === void 0 || (_themeOptions$content2 = themeOptions.contentMaxWidth) === null || _themeOptions$content2 === void 0 ? void 0 : _themeOptions$content2.md) || '100%'
103
+ maxWidth: themeOptions?.contentMaxWidth?.md || '100%'
105
104
  },
106
105
  lg: {
107
- maxWidth: (themeOptions === null || themeOptions === void 0 || (_themeOptions$content3 = themeOptions.contentMaxWidth) === null || _themeOptions$content3 === void 0 ? void 0 : _themeOptions$content3.lg) || '100%'
106
+ maxWidth: themeOptions?.contentMaxWidth?.lg || '100%'
108
107
  },
109
108
  sm: {
110
- maxWidth: (themeOptions === null || themeOptions === void 0 || (_themeOptions$content4 = themeOptions.contentMaxWidth) === null || _themeOptions$content4 === void 0 ? void 0 : _themeOptions$content4.sm) || '100%'
109
+ maxWidth: themeOptions?.contentMaxWidth?.sm || '100%'
111
110
  },
112
111
  xl: {
113
- maxWidth: (themeOptions === null || themeOptions === void 0 || (_themeOptions$content5 = themeOptions.contentMaxWidth) === null || _themeOptions$content5 === void 0 ? void 0 : _themeOptions$content5.xl) || '100%'
112
+ maxWidth: themeOptions?.contentMaxWidth?.xl || '100%'
114
113
  }
115
114
  })
116
115
  }
@@ -274,7 +273,6 @@ const getDefaultStyles = (themeTokens, themeOptions, maxWidth, dismissible, view
274
273
  * Show system notifications at the top of the page, below the navigation, and expands the full-width of the viewport
275
274
  */
276
275
  const Notification = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
277
- var _variant$style;
278
276
  let {
279
277
  children,
280
278
  system,
@@ -293,7 +291,7 @@ const Notification = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
293
291
  });
294
292
 
295
293
  // TODO: Remove this once the system style variant is deprecated
296
- const isSystemEnabled = system || (variant === null || variant === void 0 || (_variant$style = variant.style) === null || _variant$style === void 0 ? void 0 : _variant$style.includes('system'));
294
+ const isSystemEnabled = system || variant?.style?.includes('system');
297
295
  const {
298
296
  themeOptions
299
297
  } = useTheme();
@@ -305,7 +303,7 @@ const Notification = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
305
303
  system: isSystemEnabled,
306
304
  viewport
307
305
  });
308
- const maxWidth = useResponsiveProp(themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.contentMaxWidth);
306
+ const maxWidth = useResponsiveProp(themeOptions?.contentMaxWidth);
309
307
  const notificationComponentRef = React.useRef({
310
308
  containerStyles: {},
311
309
  contentContainerStyles: {},
@@ -347,7 +345,7 @@ const Notification = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
347
345
  } = enableMediaQueryStyleSheet === false ? themeTokens : themeTokens[viewport];
348
346
  const onDismissPress = () => {
349
347
  setIsDismissed(true);
350
- onDismiss === null || onDismiss === void 0 || onDismiss();
348
+ onDismiss?.();
351
349
  };
352
350
  return /*#__PURE__*/_jsx(View, {
353
351
  ref: ref,
@@ -16,9 +16,8 @@ const OrderedList = /*#__PURE__*/React.forwardRef((_ref, ref) => {
16
16
  // Pass any variants and tokens "OrderedList" receives down to the individual list items.
17
17
  const childrenWithParentVariants = React.useMemo(() => {
18
18
  const addVariantAndTokensToProps = (child, i, isLastChild) => {
19
- var _child$props, _child$props2;
20
- const existingChildVariants = ((_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.variant) ?? {};
21
- const existingChildTokens = ((_child$props2 = child.props) === null || _child$props2 === void 0 ? void 0 : _child$props2.tokens) ?? {};
19
+ const existingChildVariants = child.props?.variant ?? {};
20
+ const existingChildTokens = child.props?.tokens ?? {};
22
21
  return /*#__PURE__*/React.cloneElement(child, {
23
22
  index: start + i,
24
23
  isLastChild,
@@ -16,14 +16,13 @@ function usePagination(_ref) {
16
16
  const activeItemIndex = Math.max(items.findIndex(item => item.props.isActive), 0 // default to the first item if none is marked as active
17
17
  );
18
18
  const getItemProps = index => {
19
- var _items$index;
20
19
  const {
21
20
  onPress,
22
21
  href,
23
22
  hrefAttrs,
24
23
  variant,
25
24
  tokens
26
- } = ((_items$index = items[index]) === null || _items$index === void 0 ? void 0 : _items$index.props) ?? {};
25
+ } = items[index]?.props ?? {};
27
26
  return {
28
27
  onPress,
29
28
  href,
@@ -42,13 +42,13 @@ const renderFootnoteContent = (footnoteMarginTop, bottomTextMarginTop, bottomTex
42
42
  bottomTextMarginTop
43
43
  }),
44
44
  children: [renderTypography(bottomText, bottomTextTypographyTokens, undefined, fontColor), ' ']
45
- }), (footnoteLinks === null || footnoteLinks === void 0 ? void 0 : footnoteLinks.length) <= MAX_FOOTNOTE_LINKS_ALLOWED ? /*#__PURE__*/_jsx(View, {
45
+ }), footnoteLinks?.length <= MAX_FOOTNOTE_LINKS_ALLOWED ? /*#__PURE__*/_jsx(View, {
46
46
  style: [staticStyles.footnoteLinkContainer, selectFootnoteLinksStyles({
47
47
  bottomLinksMarginLeft
48
48
  })],
49
49
  children: renderFootnoteLinks(footnoteLinks, themeTokens, onClickFootnote)
50
50
  }) : null]
51
- }), (footnoteLinks === null || footnoteLinks === void 0 ? void 0 : footnoteLinks.length) > MAX_FOOTNOTE_LINKS_ALLOWED ? /*#__PURE__*/_jsx(View, {
51
+ }), footnoteLinks?.length > MAX_FOOTNOTE_LINKS_ALLOWED ? /*#__PURE__*/_jsx(View, {
52
52
  style: staticStyles.verticalFootnoteLinkContainer,
53
53
  children: renderFootnoteLinks(footnoteLinks, themeTokens, onClickFootnote)
54
54
  }) : null]
@@ -11,7 +11,7 @@ const selectFootnoteLinkStyles = (_ref, footnoteLinks) => {
11
11
  } = _ref;
12
12
  // This is used to apply the proper line height when there is 4 or more footnote links
13
13
  const MAX_FOOTNOTE_LINKS_ALLOWED = 3;
14
- const lineHeight = (footnoteLinks === null || footnoteLinks === void 0 ? void 0 : footnoteLinks.length) > MAX_FOOTNOTE_LINKS_ALLOWED ? footnoteLinkFontSize * footnoteLinkLineHeight : undefined;
14
+ const lineHeight = footnoteLinks?.length > MAX_FOOTNOTE_LINKS_ALLOWED ? footnoteLinkFontSize * footnoteLinkLineHeight : undefined;
15
15
  return {
16
16
  color: footnoteLinkColor,
17
17
  fontName: footnoteLinkFontName,
@@ -20,7 +20,7 @@ const selectFootnoteLinkStyles = (_ref, footnoteLinks) => {
20
20
  fontSize: footnoteLinkFontSize
21
21
  };
22
22
  };
23
- const renderFootnoteLinks = (footnoteLinks, themeTokens, onClickFootnote) => (footnoteLinks === null || footnoteLinks === void 0 ? void 0 : footnoteLinks.length) > 0 ? /*#__PURE__*/_jsx(FootnoteLink, {
23
+ const renderFootnoteLinks = (footnoteLinks, themeTokens, onClickFootnote) => footnoteLinks?.length > 0 ? /*#__PURE__*/_jsx(FootnoteLink, {
24
24
  tokens: selectFootnoteLinkStyles(themeTokens, footnoteLinks),
25
25
  content: footnoteLinks,
26
26
  onClick: onClickFootnote
@@ -66,13 +66,13 @@ const renderPrice = (price, rateText, ratePosition, signDirection, currencySymbo
66
66
  }), rateText ? /*#__PURE__*/_jsx(Text, {
67
67
  style: ratePosition === 'bottom' ? staticStyles.rateTextVerticalPosition : [staticStyles.rateTextPosition, staticStyles.rateTextVerticalPosition],
68
68
  children: renderTypography(rateText, rateTypographyTokens, ratePosition, fontColor)
69
- }) : null, !bottomText && (footnoteLinks === null || footnoteLinks === void 0 ? void 0 : footnoteLinks.length) <= MAX_FOOTNOTE_LINKS_ALLOWED ? /*#__PURE__*/_jsx(Text, {
69
+ }) : null, !bottomText && footnoteLinks?.length <= MAX_FOOTNOTE_LINKS_ALLOWED ? /*#__PURE__*/_jsx(Text, {
70
70
  style: [footnoteLinkPositionStyles, selectFootnoteLinksStyles({
71
71
  bottomLinksMarginLeft
72
72
  })],
73
73
  children: renderFootnoteLinks(footnoteLinks, themeTokens, onClickFootnote)
74
74
  }) : null]
75
- }), !bottomText && (footnoteLinks === null || footnoteLinks === void 0 ? void 0 : footnoteLinks.length) > MAX_FOOTNOTE_LINKS_ALLOWED ? /*#__PURE__*/_jsx(View, {
75
+ }), !bottomText && footnoteLinks?.length > MAX_FOOTNOTE_LINKS_ALLOWED ? /*#__PURE__*/_jsx(View, {
76
76
  style: staticStyles.verticalFootnoteLinkContainer,
77
77
  children: renderFootnoteLinks(footnoteLinks, themeTokens, onClickFootnote)
78
78
  }) : null]
@@ -35,7 +35,6 @@ const selectProductCardTokens = _ref => {
35
35
  };
36
36
  };
37
37
  const ProductCard = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
38
- var _getCopy;
39
38
  let {
40
39
  copy = 'en',
41
40
  dictionary = defaultDictionary,
@@ -102,7 +101,7 @@ const ProductCard = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
102
101
  ...selectProps(rest),
103
102
  style: [selectProductCardTokens(themeTokens), staticStyles.container],
104
103
  ref: ref,
105
- children: [image !== null && image !== void 0 && image.src ? /*#__PURE__*/_jsx(View, {
104
+ children: [image?.src ? /*#__PURE__*/_jsx(View, {
106
105
  style: staticStyles.imageContainer,
107
106
  children: /*#__PURE__*/_jsx(Image, {
108
107
  source: image.src,
@@ -146,7 +145,7 @@ const ProductCard = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
146
145
  ...getCopy('primaryPrice'),
147
146
  size: "small",
148
147
  ratePosition: "bottom"
149
- }), (_getCopy = getCopy('secondaryPrice')) !== null && _getCopy !== void 0 && _getCopy.price ? /*#__PURE__*/_jsx(PriceLockup, {
148
+ }), getCopy('secondaryPrice')?.price ? /*#__PURE__*/_jsx(PriceLockup, {
150
149
  ...getCopy('secondaryPrice'),
151
150
  size: "small",
152
151
  ratePosition: "bottom"
@@ -12,9 +12,9 @@ const ProgressBarBackground = /*#__PURE__*/React.forwardRef((_ref, ref) => {
12
12
  } = _ref;
13
13
  let source = null;
14
14
  // TODO: Remove the `variant?.inactive` & `variant?.negative` to complete the deprecation
15
- if (variant !== null && variant !== void 0 && variant.inactive || (variant === null || variant === void 0 ? void 0 : variant.style) === INACTIVE_VARIANT) {
15
+ if (variant?.inactive || variant?.style === INACTIVE_VARIANT) {
16
16
  source = inactiveBackground;
17
- } else if (variant !== null && variant !== void 0 && variant.negative || (variant === null || variant === void 0 ? void 0 : variant.style) === NEGATIVE_VARIANT) {
17
+ } else if (variant?.negative || variant?.style === NEGATIVE_VARIANT) {
18
18
  source = negativeBackground;
19
19
  } else {
20
20
  return null;
@@ -9,8 +9,7 @@ import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
11
11
  const isQuickListItem = element => {
12
- var _element$type, _element$type2;
13
- const elementName = (element === null || element === void 0 || (_element$type = element.type) === null || _element$type === void 0 ? void 0 : _element$type.displayName) || (element === null || element === void 0 || (_element$type2 = element.type) === null || _element$type2 === void 0 ? void 0 : _element$type2.name);
12
+ const elementName = element?.type?.displayName || element?.type?.name;
14
13
  return Boolean(elementName.match(/QuickLinksFeatureItem/));
15
14
  };
16
15
 
@@ -145,7 +145,7 @@ const Radio = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
145
145
  };
146
146
  const handleKeyDown = event => {
147
147
  // The expected keyboard shortcut for activating a radio is the Space key
148
- if ((event === null || event === void 0 ? void 0 : event.key) === ' ') handleChange(event);
148
+ if (event?.key === ' ') handleChange(event);
149
149
  };
150
150
  const uniqueId = useUniqueId('radio');
151
151
  const inputId = id ?? uniqueId;
@@ -135,10 +135,9 @@ const Search = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
135
135
  }
136
136
  };
137
137
  const handleClear = event => {
138
- var _ref$current;
139
138
  setValue('', event);
140
- onClear === null || onClear === void 0 || onClear('', event);
141
- ref === null || ref === void 0 || (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.focus();
139
+ onClear?.('', event);
140
+ ref?.current?.focus();
142
141
  };
143
142
  const handleFocus = event => {
144
143
  if (onFocus !== undefined) onFocus(event);