@telus-uds/components-base 1.14.1 → 1.15.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 (149) hide show
  1. package/CHANGELOG.md +33 -2
  2. package/__tests17__/A11yText/A11yText.test.jsx +34 -0
  3. package/__tests17__/ActivityIndicator/ActivityIndicator.test.jsx +68 -0
  4. package/__tests17__/ActivityIndicator/__snapshots__/ActivityIndicator.test.jsx.snap +299 -0
  5. package/__tests17__/Box/Box.test.jsx +111 -0
  6. package/__tests17__/Button/Button.test.jsx +86 -0
  7. package/__tests17__/Button/ButtonBase.test.jsx +82 -0
  8. package/__tests17__/Button/ButtonGroup.test.jsx +347 -0
  9. package/__tests17__/Button/ButtonLink.test.jsx +61 -0
  10. package/__tests17__/Card/Card.test.jsx +63 -0
  11. package/__tests17__/Carousel/Carousel.test.jsx +128 -0
  12. package/__tests17__/Carousel/CarouselTabs.test.jsx +142 -0
  13. package/__tests17__/Checkbox/Checkbox.test.jsx +94 -0
  14. package/__tests17__/Checkbox/CheckboxGroup.test.jsx +246 -0
  15. package/__tests17__/Divider/Divider.test.jsx +91 -0
  16. package/__tests17__/ExpandCollapse/ExpandCollapse.test.jsx +109 -0
  17. package/__tests17__/Feedback/Feedback.test.jsx +42 -0
  18. package/__tests17__/FlexGrid/Col.test.jsx +261 -0
  19. package/__tests17__/FlexGrid/FlexGrid.test.jsx +136 -0
  20. package/__tests17__/FlexGrid/Row.test.jsx +273 -0
  21. package/__tests17__/HorizontalScroll/HorizontalScroll.test.jsx +165 -0
  22. package/__tests17__/Icon/Icon.test.jsx +61 -0
  23. package/__tests17__/IconButton/IconButton.test.jsx +52 -0
  24. package/__tests17__/InputLabel/InputLabel.test.jsx +28 -0
  25. package/__tests17__/InputLabel/__snapshots__/InputLabel.test.jsx.snap +3 -0
  26. package/__tests17__/InputSupports/InputSupports.test.jsx +60 -0
  27. package/__tests17__/Link/Link.test.jsx +63 -0
  28. package/__tests17__/Link/TextButton.test.jsx +35 -0
  29. package/__tests17__/List/List.test.jsx +82 -0
  30. package/__tests17__/Modal/Modal.test.jsx +47 -0
  31. package/__tests17__/Notification/Notification.test.jsx +20 -0
  32. package/__tests17__/Pagination/Pagination.test.jsx +160 -0
  33. package/__tests17__/Progress/Progress.test.jsx +79 -0
  34. package/__tests17__/Radio/Radio.test.jsx +87 -0
  35. package/__tests17__/Radio/RadioGroup.test.jsx +220 -0
  36. package/__tests17__/RadioCard/RadioCard.test.jsx +87 -0
  37. package/__tests17__/RadioCard/RadioCardGroup.test.jsx +246 -0
  38. package/__tests17__/Search/Search.test.jsx +87 -0
  39. package/__tests17__/Select/Select.test.jsx +94 -0
  40. package/__tests17__/SideNav/SideNav.test.jsx +110 -0
  41. package/__tests17__/Skeleton/Skeleton.test.jsx +61 -0
  42. package/__tests17__/SkipLink/SkipLink.test.jsx +61 -0
  43. package/__tests17__/Spacer/Spacer.test.jsx +63 -0
  44. package/__tests17__/StackView/StackView.test.jsx +211 -0
  45. package/__tests17__/StackView/StackWrap.test.jsx +47 -0
  46. package/__tests17__/StackView/getStackedContent.test.jsx +295 -0
  47. package/__tests17__/StepTracker/StepTracker.test.jsx +108 -0
  48. package/__tests17__/Tabs/Tabs.test.jsx +49 -0
  49. package/__tests17__/Tags/Tags.test.jsx +327 -0
  50. package/__tests17__/TextInput/TextArea.test.jsx +35 -0
  51. package/__tests17__/TextInput/TextInputBase.test.jsx +125 -0
  52. package/__tests17__/ThemeProvider/ThemeProvider.test.jsx +80 -0
  53. package/__tests17__/ThemeProvider/useThemeTokens.test.jsx +514 -0
  54. package/__tests17__/ThemeProvider/utils/theme-tokens.test.js +41 -0
  55. package/__tests17__/ToggleSwitch/ToggleSwitch.test.jsx +82 -0
  56. package/__tests17__/ToggleSwitch/ToggleSwitchGroup.test.jsx +192 -0
  57. package/__tests17__/Tooltip/Tooltip.test.jsx +65 -0
  58. package/__tests17__/Tooltip/getTooltipPosition.test.js +79 -0
  59. package/__tests17__/Typography/typography.test.jsx +90 -0
  60. package/__tests17__/utils/children.test.jsx +128 -0
  61. package/__tests17__/utils/containUniqueFields.test.js +25 -0
  62. package/__tests17__/utils/input.test.js +375 -0
  63. package/__tests17__/utils/props.test.js +36 -0
  64. package/__tests17__/utils/semantics.test.jsx +34 -0
  65. package/__tests17__/utils/useCopy.test.js +42 -0
  66. package/__tests17__/utils/useResponsiveProp.test.jsx +202 -0
  67. package/__tests17__/utils/useSpacingScale.test.jsx +273 -0
  68. package/__tests17__/utils/useUniqueId.test.js +31 -0
  69. package/component-docs.json +95 -438
  70. package/lib/A11yInfoProvider/index.js +14 -5
  71. package/lib/Button/ButtonGroup.js +3 -2
  72. package/lib/Checkbox/Checkbox.js +9 -6
  73. package/lib/ExpandCollapse/Control.js +6 -5
  74. package/lib/ExpandCollapse/Panel.js +5 -4
  75. package/lib/List/ListItem.js +10 -236
  76. package/lib/List/ListItemBase.js +162 -0
  77. package/lib/List/ListItemContent.js +85 -0
  78. package/lib/List/ListItemMark.js +158 -0
  79. package/lib/List/PressableListItemBase.js +147 -0
  80. package/lib/Notification/Notification.js +2 -1
  81. package/lib/Pagination/Pagination.js +4 -3
  82. package/lib/Pagination/SideButton.js +17 -7
  83. package/lib/Radio/Radio.js +9 -6
  84. package/lib/RadioCard/RadioCard.js +9 -6
  85. package/lib/Select/Select.js +1 -0
  86. package/lib/Tabs/Tabs.js +12 -3
  87. package/lib/Tags/Tags.js +3 -3
  88. package/lib/TextInput/TextInput.js +5 -4
  89. package/lib/ViewportProvider/useViewportListener.js +11 -5
  90. package/lib/utils/hasOwnProperty.js +18 -0
  91. package/lib/utils/props/a11yProps.js +212 -45
  92. package/lib/utils/props/getPropSelector.js +47 -5
  93. package/lib/utils/ssr.js +116 -1
  94. package/lib/utils/useResponsiveProp.js +5 -3
  95. package/lib/utils/withLinkRouter.js +3 -5
  96. package/lib-module/A11yInfoProvider/index.js +14 -4
  97. package/lib-module/Button/ButtonGroup.js +3 -2
  98. package/lib-module/Checkbox/Checkbox.js +9 -6
  99. package/lib-module/ExpandCollapse/Control.js +6 -5
  100. package/lib-module/ExpandCollapse/Panel.js +5 -4
  101. package/lib-module/List/ListItem.js +13 -235
  102. package/lib-module/List/ListItemBase.js +139 -0
  103. package/lib-module/List/ListItemContent.js +66 -0
  104. package/lib-module/List/ListItemMark.js +143 -0
  105. package/lib-module/List/PressableListItemBase.js +117 -0
  106. package/lib-module/Notification/Notification.js +2 -1
  107. package/lib-module/Pagination/Pagination.js +5 -3
  108. package/lib-module/Pagination/SideButton.js +18 -8
  109. package/lib-module/Radio/Radio.js +9 -6
  110. package/lib-module/RadioCard/RadioCard.js +9 -6
  111. package/lib-module/Select/Select.js +1 -0
  112. package/lib-module/Tabs/Tabs.js +13 -4
  113. package/lib-module/Tags/Tags.js +3 -3
  114. package/lib-module/TextInput/TextInput.js +5 -4
  115. package/lib-module/ViewportProvider/useViewportListener.js +10 -4
  116. package/lib-module/utils/hasOwnProperty.js +11 -0
  117. package/lib-module/utils/props/a11yProps.js +210 -45
  118. package/lib-module/utils/props/getPropSelector.js +44 -5
  119. package/lib-module/utils/ssr.js +106 -0
  120. package/lib-module/utils/useResponsiveProp.js +3 -4
  121. package/lib-module/utils/withLinkRouter.js +3 -5
  122. package/package.json +12 -17
  123. package/src/A11yInfoProvider/index.jsx +20 -4
  124. package/src/Button/ButtonGroup.jsx +4 -2
  125. package/src/Checkbox/Checkbox.jsx +7 -3
  126. package/src/ExpandCollapse/Control.jsx +8 -5
  127. package/src/ExpandCollapse/Panel.jsx +7 -5
  128. package/src/List/ListItem.jsx +12 -191
  129. package/src/List/ListItemBase.jsx +118 -0
  130. package/src/List/ListItemContent.jsx +52 -0
  131. package/src/List/ListItemMark.jsx +99 -0
  132. package/src/List/PressableListItemBase.jsx +102 -0
  133. package/src/Notification/Notification.jsx +1 -1
  134. package/src/Pagination/Pagination.jsx +6 -1
  135. package/src/Pagination/SideButton.jsx +4 -1
  136. package/src/Radio/Radio.jsx +7 -3
  137. package/src/RadioCard/RadioCard.jsx +7 -3
  138. package/src/Select/Select.jsx +1 -1
  139. package/src/Tabs/Tabs.jsx +19 -2
  140. package/src/Tags/Tags.jsx +3 -3
  141. package/src/TextInput/TextInput.jsx +4 -4
  142. package/src/ViewportProvider/useViewportListener.js +10 -5
  143. package/src/utils/hasOwnProperty.js +11 -0
  144. package/src/utils/props/a11yProps.js +168 -55
  145. package/src/utils/props/getPropSelector.js +45 -4
  146. package/src/utils/ssr.jsx +124 -0
  147. package/src/utils/useResponsiveProp.js +3 -3
  148. package/src/utils/withLinkRouter.jsx +1 -3
  149. package/src/utils/ssr.js +0 -35
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.tokenTypes = exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
13
+
14
+ var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
15
+
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ const tokenTypes = {
21
+ itemIconSize: _propTypes.default.number.isRequired,
22
+ itemIconColor: _propTypes.default.string.isRequired,
23
+ listGutter: _propTypes.default.number.isRequired,
24
+ iconMarginTop: _propTypes.default.number.isRequired
25
+ };
26
+ exports.tokenTypes = tokenTypes;
27
+
28
+ const selectItemIconTokens = _ref => {
29
+ let {
30
+ itemIconSize,
31
+ itemIconColor
32
+ } = _ref;
33
+ return {
34
+ size: itemIconSize,
35
+ color: itemIconColor
36
+ };
37
+ };
38
+
39
+ const selectSideItemContainerStyles = _ref2 => {
40
+ let {
41
+ listGutter,
42
+ iconMarginTop
43
+ } = _ref2;
44
+ return {
45
+ marginTop: iconMarginTop,
46
+ marginRight: listGutter
47
+ };
48
+ }; // Align bullets with the top line of text the same way icons are aligned
49
+
50
+
51
+ const selectBulletPositioningStyles = _ref3 => {
52
+ let {
53
+ itemIconSize
54
+ } = _ref3;
55
+ return {
56
+ width: itemIconSize,
57
+ height: itemIconSize
58
+ };
59
+ };
60
+
61
+ const selectBulletStyles = _ref4 => {
62
+ let {
63
+ itemBulletWidth,
64
+ itemBulletHeight,
65
+ itemBulletColor
66
+ } = _ref4;
67
+ return {
68
+ width: itemBulletWidth,
69
+ height: itemBulletHeight,
70
+ borderRadius: itemBulletHeight / 2,
71
+ backgroundColor: itemBulletColor
72
+ };
73
+ };
74
+
75
+ const selectBulletContainerStyles = _ref5 => {
76
+ let {
77
+ itemBulletContainerWidth,
78
+ itemBulletContainerAlign
79
+ } = _ref5;
80
+ return {
81
+ width: itemBulletContainerWidth,
82
+ alignItems: itemBulletContainerAlign
83
+ };
84
+ };
85
+ /**
86
+ * Subcomponent used within ListItem and similar components for rendering bullets or icons
87
+ * that sit alongside a ListIconContent in a { flexDirection: row } container.
88
+ *
89
+ * It's the responsibility of themes to make sure that the supplied tokens align the
90
+ * icon or bullet nicely against the first line of text in a ListIconContent.
91
+ */
92
+
93
+
94
+ const ListItemMark = _ref6 => {
95
+ let {
96
+ icon,
97
+ iconColor,
98
+ iconSize,
99
+ tokens = {}
100
+ } = _ref6;
101
+ const IconComponent = icon || /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
102
+ const themeTokens = typeof tokens === 'function' ? tokens() : tokens;
103
+ const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens);
104
+
105
+ if (icon) {
106
+ const iconTokens = selectItemIconTokens(themeTokens);
107
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
108
+ style: sideItemContainerStyles,
109
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(IconComponent, {
110
+ size: iconSize || iconTokens.size,
111
+ color: iconColor || iconTokens.color
112
+ })
113
+ });
114
+ }
115
+
116
+ const itemBulletContainerStyles = selectBulletContainerStyles(themeTokens);
117
+ const itemBulletStyles = selectBulletStyles(themeTokens);
118
+ const itemBulletPositioningStyles = selectBulletPositioningStyles(themeTokens);
119
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
120
+ style: [sideItemContainerStyles, itemBulletContainerStyles],
121
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
122
+ style: [staticStyles.bulletPositioning, itemBulletPositioningStyles],
123
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
124
+ style: itemBulletStyles,
125
+ testID: "unordered-item-bullet"
126
+ })
127
+ })
128
+ });
129
+ };
130
+
131
+ ListItemMark.propTypes = {
132
+ tokens: _propTypes.default.shape(tokenTypes).isRequired,
133
+
134
+ /**
135
+ * Renders side item icon
136
+ */
137
+ icon: _propTypes.default.elementType,
138
+
139
+ /**
140
+ * Will set display icon color
141
+ */
142
+ iconColor: _propTypes.default.string,
143
+
144
+ /**
145
+ * Allow the user define the icon size
146
+ */
147
+ iconSize: _propTypes.default.number
148
+ };
149
+
150
+ const staticStyles = _StyleSheet.default.create({
151
+ bulletPositioning: {
152
+ alignItems: 'center',
153
+ justifyContent: 'center'
154
+ }
155
+ });
156
+
157
+ var _default = ListItemMark;
158
+ exports.default = _default;
@@ -0,0 +1,147 @@
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 _airbnbPropTypes = _interopRequireDefault(require("airbnb-prop-types"));
13
+
14
+ var _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Pressable"));
15
+
16
+ var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
17
+
18
+ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
19
+
20
+ var _utils = require("../utils");
21
+
22
+ var _ListItemBase = _interopRequireDefault(require("./ListItemBase"));
23
+
24
+ var _ListItemContent = _interopRequireWildcard(require("./ListItemContent"));
25
+
26
+ var _ListItemMark = _interopRequireWildcard(require("./ListItemMark"));
27
+
28
+ var _jsxRuntime = require("react/jsx-runtime");
29
+
30
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
+
32
+ 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); }
33
+
34
+ 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; }
35
+
36
+ const selectPressableStyles = _ref => {
37
+ let {
38
+ backgroundColor,
39
+ paddingLeft,
40
+ paddingRight,
41
+ paddingTop,
42
+ paddingBottom,
43
+ interItemMargin
44
+ } = _ref;
45
+ return {
46
+ backgroundColor,
47
+ paddingLeft,
48
+ paddingRight,
49
+ paddingTop,
50
+ paddingBottom,
51
+ marginBottom: interItemMargin,
52
+ ..._Platform.default.select({
53
+ web: {
54
+ outline: 'none'
55
+ }
56
+ })
57
+ };
58
+ };
59
+
60
+ const PressableListItemBase = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
61
+ let {
62
+ href,
63
+ tokens,
64
+ icon,
65
+ children,
66
+ listItemRef,
67
+ ...rest
68
+ } = _ref2;
69
+
70
+ const {
71
+ onPress,
72
+ ...props
73
+ } = _utils.clickProps.toPressProps(rest);
74
+
75
+ const {
76
+ hrefAttrs,
77
+ rest: listItemProps
78
+ } = _utils.hrefAttrsProp.bundle(props);
79
+
80
+ const handlePress = _utils.linkProps.handleHref({
81
+ href,
82
+ onPress
83
+ });
84
+
85
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemBase.default, {
86
+ ref: listItemRef,
87
+ tokens: tokens(),
88
+ ...listItemProps,
89
+ children: _ref3 => {
90
+ let {
91
+ isLastItem
92
+ } = _ref3;
93
+
94
+ const getTokens = pressableState => (0, _utils.resolvePressableTokens)(tokens, pressableState, {
95
+ last: isLastItem
96
+ });
97
+
98
+ const getPressableStyle = pressableState => [staticStyles.itemContainer, selectPressableStyles(getTokens(pressableState))];
99
+
100
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
101
+ onPress: handlePress,
102
+ href: href,
103
+ hrefAttrs: hrefAttrs,
104
+ style: getPressableStyle,
105
+ ref: ref,
106
+ children: pressableState => {
107
+ const themeTokens = getTokens(pressableState);
108
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
109
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemMark.default, {
110
+ icon: icon,
111
+ tokens: themeTokens
112
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemContent.default, {
113
+ tokens: themeTokens,
114
+ children: typeof children === 'function' ? children(pressableState) : children
115
+ })]
116
+ });
117
+ }
118
+ });
119
+ }
120
+ });
121
+ });
122
+ PressableListItemBase.displayName = 'PressableListItemBase';
123
+
124
+ const staticStyles = _StyleSheet.default.create({
125
+ itemContainer: {
126
+ flexDirection: 'row',
127
+ flex: 1
128
+ },
129
+ tokens: { ..._ListItemContent.tokenTypes,
130
+ ..._ListItemMark.tokenTypes
131
+ }
132
+ });
133
+
134
+ PressableListItemBase.propTypes = {
135
+ href: _propTypes.default.string,
136
+ onPress: _propTypes.default.func,
137
+ // TODO - type this better, maybe import the subcomponent token types and run it through util
138
+ // eslint-disable-next-line react/forbid-prop-types
139
+ tokens: _propTypes.default.any,
140
+ icon: _propTypes.default.elementType,
141
+ children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
142
+ listItemRef: _airbnbPropTypes.default.ref()
143
+ };
144
+
145
+ var _default = (0, _utils.withLinkRouter)(PressableListItemBase);
146
+
147
+ exports.default = _default;
@@ -165,7 +165,8 @@ const Notification = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
165
165
 
166
166
  const textStyles = selectTextStyles(themeTokens, themeOptions);
167
167
  const content = (0, _utils.wrapStringsInText)(typeof children === 'function' ? children({
168
- textStyles
168
+ textStyles,
169
+ variant
169
170
  }) : children, {
170
171
  style: textStyles
171
172
  });
@@ -120,12 +120,13 @@ const Pagination = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
120
120
  };
121
121
 
122
122
  if (shouldRenderButton(itemIndex)) {
123
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PageButton.default, { ...itemProps,
123
+ return /*#__PURE__*/(0, _react.createElement)(_PageButton.default, { ...itemProps,
124
124
  LinkRouter: ItemLinkRouter,
125
125
  linkRouterProps: itemLinkRouterProps,
126
126
  label: buttonLabel,
127
127
  copy: copy,
128
- isActive: isItemActive(itemIndex)
128
+ isActive: isItemActive(itemIndex),
129
+ key: buttonLabel
129
130
  });
130
131
  }
131
132
 
@@ -133,7 +134,7 @@ const Pagination = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
133
134
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
134
135
  style: ellipsisTextStyles,
135
136
  children: "..."
136
- });
137
+ }, "...");
137
138
  }
138
139
 
139
140
  return null;
@@ -33,12 +33,22 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
33
33
 
34
34
  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; }
35
35
 
36
- const selectIconTokens = (_ref, direction) => {
36
+ // We need to drop the icon here since it gets rendered via children and not
37
+ // `ButtonBase` in order to tap into the state of the button
38
+ const selectButtonTokens = _ref => {
39
+ let {
40
+ icon: _,
41
+ ...rest
42
+ } = _ref;
43
+ return (0, _utils.selectTokens)('Button', rest);
44
+ };
45
+
46
+ const selectIconTokens = (_ref2, direction) => {
37
47
  let {
38
48
  color,
39
49
  iconSize,
40
50
  iconDisplace
41
- } = _ref;
51
+ } = _ref2;
42
52
  return {
43
53
  color,
44
54
  size: iconSize,
@@ -50,7 +60,7 @@ const directionToSide = {
50
60
  previous: 'left',
51
61
  next: 'right'
52
62
  };
53
- const SideButton = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
63
+ const SideButton = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
54
64
  let {
55
65
  direction = 'previous',
56
66
  onPress,
@@ -59,7 +69,7 @@ const SideButton = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
59
69
  variant,
60
70
  tokens,
61
71
  ...props
62
- } = _ref2;
72
+ } = _ref3;
63
73
  const viewport = (0, _ViewportProvider.useViewport)();
64
74
  const buttonVariant = {
65
75
  direction,
@@ -75,7 +85,7 @@ const SideButton = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
75
85
  icon
76
86
  } = getTokens(tokens, buttonVariant);
77
87
 
78
- const getButtonTokens = buttonState => (0, _utils.selectTokens)('Button', getTokens(buttonState));
88
+ const getButtonTokens = buttonState => selectButtonTokens(getTokens(buttonState));
79
89
 
80
90
  const getIconTokens = buttonState => selectIconTokens(getTokens(buttonState), direction);
81
91
 
@@ -101,11 +111,11 @@ const SideButton = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
101
111
  ref: ref,
102
112
  ...buttonProps,
103
113
  tokens: getButtonTokens,
104
- children: _ref3 => {
114
+ children: _ref4 => {
105
115
  let {
106
116
  textStyles,
107
117
  ...buttonState
108
- } = _ref3;
118
+ } = _ref4;
109
119
  const iconProps = {
110
120
  tokens: getIconTokens(buttonState)
111
121
  };
@@ -175,17 +175,20 @@ const Radio = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
175
175
 
176
176
  const uniqueId = (0, _utils.useUniqueId)('radio');
177
177
  const inputId = id !== null && id !== void 0 ? id : uniqueId;
178
+ const selectedProps = selectProps({
179
+ accessibilityRole: 'radio',
180
+ accessibilityState: {
181
+ checked: isChecked,
182
+ disabled: inactive
183
+ },
184
+ ...rest
185
+ });
178
186
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
179
187
  ref: ref,
180
188
  disabled: inactive,
181
189
  onKeyDown: handleKeyDown,
182
190
  onPress: handleChange,
183
- accessibilityRole: "radio",
184
- accessibilityState: {
185
- checked: isChecked,
186
- disabled: inactive
187
- },
188
- ...selectProps(rest),
191
+ ...selectedProps,
189
192
  children: _ref5 => {
190
193
  let {
191
194
  focused: focus,
@@ -110,18 +110,21 @@ const RadioCard = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
110
110
  const {
111
111
  themeOptions
112
112
  } = (0, _ThemeProvider.useTheme)();
113
+ const selectedProps = selectProps({
114
+ accessibilityRole: 'radio',
115
+ accessibilityState: {
116
+ checked: isChecked,
117
+ disabled: inactive
118
+ },
119
+ ...rest
120
+ });
113
121
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Card.PressableCardBase, {
114
122
  ref: ref,
115
123
  inactive: inactive,
116
124
  checked: isChecked,
117
125
  tokens: getCardTokens,
118
126
  onPress: handleChange,
119
- accessibilityRole: "radio",
120
- accessibilityState: {
121
- checked: isChecked,
122
- disabled: inactive
123
- },
124
- ...selectProps(rest),
127
+ ...selectedProps,
125
128
  children: cardState => {
126
129
  const {
127
130
  radioSpace,
@@ -258,6 +258,7 @@ const Select = /*#__PURE__*/(0, _react.forwardRef)((_ref7, ref) => {
258
258
  } = (0, _ThemeProvider.useTheme)();
259
259
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputSupports.default, { ...supportsProps,
260
260
  ...selectedProps,
261
+ validation: validation,
261
262
  children: _ref8 => {
262
263
  let {
263
264
  inputId,
package/lib/Tabs/Tabs.js CHANGED
@@ -30,6 +30,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
30
30
  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; }
31
31
 
32
32
  const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
33
+ const [selectItemProps, selectedItemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.pressProps, _utils.viewProps]);
33
34
  const {
34
35
  selectHorizontalScrollTokens,
35
36
  useItemPositions
@@ -116,15 +117,21 @@ const Tabs = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
116
117
  label,
117
118
  id,
118
119
  accessibilityRole = defaultTabItemAccessibiltyRole,
120
+ onPress,
119
121
  ref: itemRef,
120
122
  LinkRouter: ItemLinkRouter = LinkRouter,
121
- linkRouterProps: itemLinkRouterProps
123
+ linkRouterProps: itemLinkRouterProps,
124
+ ...itemRest
122
125
  } = _ref3;
123
126
  const itemId = id !== null && id !== void 0 ? id : label;
124
127
  const isSelected = Boolean(currentValue && currentValue === itemId);
125
128
 
126
- const handlePress = event => setValue(itemId, event);
129
+ const handlePress = event => {
130
+ if (typeof onPress === 'function') onPress(event);
131
+ setValue(itemId, event);
132
+ };
127
133
 
134
+ const itemProps = selectItemProps(itemRest);
128
135
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TabsItem.default, {
129
136
  ref: itemRef,
130
137
  href: href,
@@ -139,6 +146,7 @@ const Tabs = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
139
146
  linkRouterProps: { ...linkRouterProps,
140
147
  ...itemLinkRouterProps
141
148
  },
149
+ ...itemProps,
142
150
  children: label
143
151
  }, itemId);
144
152
  })
@@ -148,7 +156,8 @@ const Tabs = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
148
156
  Tabs.displayName = 'Tabs';
149
157
  Tabs.propTypes = { ...selectedSystemPropTypes,
150
158
  ..._utils.withLinkRouter.PropTypes,
151
- items: _propTypes.default.arrayOf(_propTypes.default.shape({ ..._utils.withLinkRouter.PropTypes,
159
+ items: _propTypes.default.arrayOf(_propTypes.default.shape({ ...selectedItemPropTypes,
160
+ ..._utils.withLinkRouter.PropTypes,
152
161
  href: _propTypes.default.string,
153
162
  label: _propTypes.default.string,
154
163
  id: _propTypes.default.string,
package/lib/Tags/Tags.js CHANGED
@@ -158,14 +158,14 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
158
158
  toggleOneValue(id, event);
159
159
  };
160
160
 
161
- const itemProps = {
161
+ const itemProps = selectItemProps({
162
162
  accessibilityState: {
163
163
  checked: isSelected
164
164
  },
165
165
  accessibilityRole: itemA11yRole,
166
166
  ..._utils.a11yProps.getPositionInSet(items.length, index),
167
- ...selectItemProps(itemRest)
168
- };
167
+ ...itemRest
168
+ });
169
169
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, {
170
170
  ref: itemRef,
171
171
  ...pressHandlers,
@@ -46,6 +46,7 @@ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_u
46
46
  const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
47
47
  let {
48
48
  tokens,
49
+ nativeID,
49
50
  variant = {},
50
51
  ...rest
51
52
  } = _ref;
@@ -60,18 +61,18 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
60
61
  }
61
62
  };
62
63
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputSupports.default, {
63
- nativeID: selectedProps.nativeID,
64
+ nativeID: nativeID,
64
65
  ...supportsProps,
65
66
  children: _ref2 => {
66
67
  let {
67
68
  inputId,
68
- ...props
69
+ ...propsFromInputSupports
69
70
  } = _ref2;
70
71
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInputBase.default, {
71
72
  ref: ref,
72
- ...inputProps,
73
73
  nativeID: inputId,
74
- ...props
74
+ ...propsFromInputSupports,
75
+ ...inputProps
75
76
  });
76
77
  }
77
78
  });
@@ -45,11 +45,17 @@ const useViewportListenerCSR = setViewport => {
45
45
  return setViewport(_systemConstants.viewports.select(window.width));
46
46
  };
47
47
 
48
- const listener = _Dimensions.default.addEventListener('change', onChange); // From RN 0.65.0, Dimensions.removeEventListener is deprecated for `remove` on addEventListener return value;
49
- // however, that is not available in RN <=0.64.X, therefore not in any Expo release as of 2021 (Expo SDK 43).
50
-
51
-
52
- return (listener === null || listener === void 0 ? void 0 : listener.remove) || (() => _Dimensions.default.removeEventListener('change', onChange)); // setViewport is a function from `useState` so it is stable and won't make the effect re-run
48
+ const listener = _Dimensions.default.addEventListener('change', onChange);
49
+
50
+ return () => {
51
+ if (typeof (listener === null || listener === void 0 ? void 0 : listener.remove) === 'function') {
52
+ // Can't just return listener.remove because listener.emitter disappears, causing an internal error.
53
+ // See https://github.com/facebook/react-native/issues/34508
54
+ listener.remove(); // From RN 0.65.0, Dimensions.removeEventListener is deprecated for `remove` on addEventListener return value
55
+ } else if (typeof _Dimensions.default.removeEventListener === 'function') {
56
+ _Dimensions.default.removeEventListener('change', onChange);
57
+ }
58
+ };
53
59
  }, [setViewport]);
54
60
  }; // Window is a defined global object in both Web and Native client-side, and undefined in SSR
55
61
 
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = hasOwnProperty;
7
+
8
+ /**
9
+ * Linter disallows object instance prototype methods like someObject.hasOwnProperty(key),
10
+ * but we can use this instead.
11
+ *
12
+ * @param {object} object
13
+ * @param {String} key
14
+ * @returns {Boolean}
15
+ */
16
+ function hasOwnProperty(object, key) {
17
+ return Object.prototype.hasOwnProperty.call(object, key);
18
+ }