@telus-uds/components-base 1.0.0 → 1.2.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 (121) hide show
  1. package/.storybook/main.js +4 -0
  2. package/.storybook/preview.js +37 -0
  3. package/.ultra.cache.json +1 -1
  4. package/CHANGELOG.md +26 -0
  5. package/README.md +1 -1
  6. package/__fixtures__/Accessible.js +4 -2
  7. package/__fixtures__/Accessible.native.js +5 -2
  8. package/__fixtures__/testTheme.js +9 -0
  9. package/__tests__/HorizontalScroll/HorizontalScroll.test.jsx +1 -0
  10. package/__tests__/ToggleSwitch/ToggleSwitch.test.jsx +10 -0
  11. package/__tests__/ToggleSwitch/ToggleSwitchGroup.test.jsx +192 -0
  12. package/babel.config.js +9 -16
  13. package/component-docs.json +10131 -0
  14. package/generate-component-docs.js +56 -0
  15. package/lib/Box/Box.js +1 -0
  16. package/lib/Button/ButtonBase.js +20 -6
  17. package/lib/Card/CardBase.js +1 -0
  18. package/lib/Card/PressableCardBase.js +9 -3
  19. package/lib/Checkbox/Checkbox.js +0 -2
  20. package/lib/FlexGrid/FlexGrid.js +1 -1
  21. package/lib/IconButton/IconButton.js +8 -3
  22. package/lib/Link/LinkBase.js +10 -3
  23. package/lib/List/List.js +1 -2
  24. package/lib/List/ListItem.js +14 -27
  25. package/lib/List/index.js +15 -0
  26. package/lib/Pagination/PageButton.js +4 -8
  27. package/lib/Pagination/Pagination.js +16 -4
  28. package/lib/Pagination/SideButton.js +3 -1
  29. package/lib/Radio/Radio.js +0 -2
  30. package/lib/StackView/StackView.js +1 -0
  31. package/lib/StackView/StackWrap.js +9 -5
  32. package/lib/StackView/StackWrapBox.js +1 -0
  33. package/lib/Tabs/Tabs.js +12 -4
  34. package/lib/Tabs/TabsItem.js +12 -6
  35. package/lib/ToggleSwitch/ToggleSwitch.js +99 -37
  36. package/lib/ToggleSwitch/ToggleSwitchGroup.js +230 -0
  37. package/lib/ToggleSwitch/index.js +14 -4
  38. package/lib/index.js +28 -9
  39. package/lib/utils/a11y/propTypes.js +61 -0
  40. package/lib/utils/a11y/propTypes.native.js +47 -0
  41. package/lib/utils/index.js +10 -1
  42. package/lib/utils/propTypes.js +35 -91
  43. package/lib/utils/withLinkRouter.js +98 -0
  44. package/package.json +10 -6
  45. package/release-context.json +4 -4
  46. package/src/Box/Box.jsx +1 -0
  47. package/src/Button/ButtonBase.jsx +11 -4
  48. package/src/Card/CardBase.jsx +1 -0
  49. package/src/Card/PressableCardBase.jsx +6 -4
  50. package/src/Checkbox/Checkbox.jsx +0 -2
  51. package/src/FlexGrid/FlexGrid.jsx +1 -1
  52. package/src/IconButton/IconButton.jsx +6 -4
  53. package/src/Link/LinkBase.jsx +6 -4
  54. package/src/List/List.jsx +1 -3
  55. package/src/List/ListItem.jsx +11 -26
  56. package/src/List/index.js +5 -0
  57. package/src/Pagination/PageButton.jsx +5 -8
  58. package/src/Pagination/Pagination.jsx +29 -2
  59. package/src/Pagination/SideButton.jsx +2 -2
  60. package/src/Radio/Radio.jsx +0 -2
  61. package/src/StackView/StackView.jsx +1 -0
  62. package/src/StackView/StackWrap.jsx +7 -6
  63. package/src/StackView/StackWrapBox.jsx +1 -0
  64. package/src/Tabs/Tabs.jsx +49 -22
  65. package/src/Tabs/TabsItem.jsx +11 -7
  66. package/src/ToggleSwitch/ToggleSwitch.jsx +92 -34
  67. package/src/ToggleSwitch/ToggleSwitchGroup.jsx +203 -0
  68. package/src/ToggleSwitch/index.js +2 -1
  69. package/src/index.js +2 -2
  70. package/src/utils/a11y/propTypes.js +61 -0
  71. package/src/utils/a11y/propTypes.native.js +39 -0
  72. package/src/utils/index.js +1 -0
  73. package/src/utils/propTypes.js +33 -111
  74. package/src/utils/withLinkRouter.jsx +68 -0
  75. package/stories/A11yText/A11yText.stories.jsx +1 -1
  76. package/stories/ActivityIndicator/ActivityIndicator.stories.jsx +1 -1
  77. package/stories/Box/Box.stories.jsx +1 -1
  78. package/stories/Button/Button.stories.jsx +1 -1
  79. package/stories/Button/ButtonGroup.stories.jsx +1 -1
  80. package/stories/Button/ButtonLink.stories.jsx +1 -1
  81. package/stories/Card/Card.stories.jsx +1 -1
  82. package/stories/Checkbox/Checkbox.stories.jsx +1 -1
  83. package/stories/Divider/Divider.stories.jsx +1 -1
  84. package/stories/ExpandCollapse/ExpandCollapse.stories.jsx +1 -1
  85. package/stories/Feedback/Feedback.stories.jsx +1 -1
  86. package/stories/FlexGrid/01 FlexGrid.stories.jsx +1 -1
  87. package/stories/FlexGrid/02 Row.stories.jsx +1 -1
  88. package/stories/FlexGrid/03 Col.stories.jsx +1 -1
  89. package/stories/Icon/Icon.stories.jsx +1 -1
  90. package/stories/IconButton/IconButton.stories.jsx +1 -1
  91. package/stories/InputLabel/InputLabel.stories.jsx +1 -1
  92. package/stories/Link/ChevronLink.stories.jsx +1 -1
  93. package/stories/Link/Link.stories.jsx +1 -1
  94. package/stories/Link/TextButton.stories.jsx +1 -1
  95. package/stories/List/List.stories.jsx +1 -1
  96. package/stories/Modal/Modal.stories.jsx +1 -1
  97. package/stories/Notification/Notification.stories.jsx +1 -1
  98. package/stories/Pagination/Pagination.stories.jsx +1 -1
  99. package/stories/Progress/Progress.stories.jsx +1 -1
  100. package/stories/Radio/Radio.stories.jsx +1 -1
  101. package/stories/RadioCard/RadioCard.stories.jsx +1 -1
  102. package/stories/Search/Search.stories.jsx +1 -1
  103. package/stories/Select/Select.stories.jsx +1 -1
  104. package/stories/SideNav/SideNav.stories.jsx +1 -1
  105. package/stories/SideNav/SideNavItem.stories.jsx +1 -1
  106. package/stories/SideNav/SideNavItemsGroup.stories.jsx +1 -1
  107. package/stories/Skeleton/Skeleton.stories.jsx +1 -1
  108. package/stories/Spacer/Spacer.stories.jsx +1 -1
  109. package/stories/StackView/StackView.stories.jsx +1 -1
  110. package/stories/StackView/StackWrap.stories.jsx +1 -1
  111. package/stories/StepTracker/StepTracker.stories.jsx +1 -1
  112. package/stories/Tabs/Tabs.stories.jsx +1 -1
  113. package/stories/Tags/Tags.stories.jsx +1 -1
  114. package/stories/TextInput/TextArea.stories.jsx +2 -1
  115. package/stories/TextInput/TextInput.stories.jsx +1 -1
  116. package/stories/ToggleSwitch/ToggleSwitch.stories.jsx +6 -2
  117. package/stories/ToggleSwitch/ToggleSwitchGroup.stories.jsx +81 -0
  118. package/stories/Tooltip/Tooltip.stories.jsx +1 -1
  119. package/stories/TooltipButton/TooltipButton.stories.jsx +1 -1
  120. package/stories/Typography/Typography.stories.jsx +1 -1
  121. package/stories/supports.jsx +2 -3
@@ -0,0 +1,56 @@
1
+ const fs = require('fs')
2
+ const schema = require('@telus-uds/system-theme-tokens')
3
+ const allExports = require('./src')
4
+
5
+ const { a11yProps } = allExports
6
+ const a11yPropTypes = Object.keys(a11yProps.types)
7
+
8
+ const parseComponentDocs = (name, generated) => {
9
+ const { description } = generated // TODO parse markdown and split by heading
10
+ const props = {} // store derived prop data
11
+ const attributes = {
12
+ // any other computed attributes
13
+ acceptsRNA11yProps: a11yPropTypes.every((key) => key in generated.props)
14
+ }
15
+
16
+ Object.entries(generated.props).forEach(([propName, prop]) => {
17
+ if (prop.description?.includes('@ignore')) {
18
+ return // remove ignored props
19
+ }
20
+ if (attributes.acceptsRNA11yProps && a11yPropTypes.includes(propName)) {
21
+ return // remove a11y props if all supported (there are 30+, instead we have the above attribute to show this)
22
+ }
23
+
24
+ const out = { ...prop }
25
+
26
+ // check if this prop references the tokens schema
27
+ const tokensProp = out.type?.raw?.match(/getTokensPropType\('([A-z]+)'\)/)?.[1]
28
+ if (tokensProp) {
29
+ if (!schema.components[tokensProp]) {
30
+ throw new Error(`Unknown schema component reference: ${tokensProp} from component: ${name}`)
31
+ }
32
+ out.type = { ...out.type, raw: schema.components[tokensProp] }
33
+ }
34
+ props[propName] = out
35
+ })
36
+
37
+ return { docs: { description, props, attributes } }
38
+ }
39
+
40
+ const components = {}
41
+
42
+ Object.entries(allExports).forEach(([name, exp]) => {
43
+ if (exp.__docgenInfo) {
44
+ // populated by babel-plugin-react-docgen
45
+ components[name] = parseComponentDocs(name, exp.__docgenInfo)
46
+
47
+ // check for second-level components e.g List.Item (can only be on a component)
48
+ Object.entries(exp).forEach(([subComponentName, prop]) => {
49
+ if (prop.__docgenInfo) {
50
+ components[name][subComponentName] = parseComponentDocs(subComponentName, prop.__docgenInfo)
51
+ }
52
+ })
53
+ }
54
+ }, {})
55
+
56
+ fs.writeFileSync('./component-docs.json', JSON.stringify({ schema, components }, null, 2))
package/lib/Box/Box.js CHANGED
@@ -166,6 +166,7 @@ const Box = /*#__PURE__*/(0, _react.forwardRef)(({
166
166
  });
167
167
  Box.displayName = 'Box';
168
168
  Box.propTypes = { ..._utils.a11yProps.propTypes,
169
+ ..._utils.viewProps.types,
169
170
  variant: _utils.variantProp.propType,
170
171
  tokens: (0, _utils.getTokensPropType)('Box'),
171
172
 
@@ -7,6 +7,8 @@ exports.default = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
10
12
  var _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Pressable"));
11
13
 
12
14
  var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
@@ -17,7 +19,7 @@ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/export
17
19
 
18
20
  var _utils = require("../ThemeProvider/utils");
19
21
 
20
- var _propTypes = _interopRequireDefault(require("./propTypes"));
22
+ var _propTypes2 = _interopRequireDefault(require("./propTypes"));
21
23
 
22
24
  var _utils2 = require("../utils");
23
25
 
@@ -170,18 +172,23 @@ const selectWebOnlyStyles = (inactive, themeTokens, {
170
172
  };
171
173
 
172
174
  const ButtonBase = /*#__PURE__*/(0, _react.forwardRef)(({
175
+ id,
173
176
  href,
174
177
  hrefAttrs,
175
178
  children,
176
- onPress,
177
179
  tokens = {},
178
180
  disabled = false,
179
181
  // alias for inactive
180
182
  inactive = disabled,
181
183
  selected = false,
182
184
  dataSet,
183
- ...rest
185
+ ...rawRest
184
186
  }, ref) => {
187
+ const {
188
+ onPress,
189
+ ...rest
190
+ } = _utils2.clickProps.toPressProps(rawRest);
191
+
185
192
  const extraButtonState = {
186
193
  inactive,
187
194
  selected
@@ -217,6 +224,7 @@ const ButtonBase = /*#__PURE__*/(0, _react.forwardRef)(({
217
224
 
218
225
  const stretchStyles = themeTokens.width ? staticStyles.stretch : staticStyles.align;
219
226
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
227
+ id: id,
220
228
  style: [containerStyles, borderStyles, stretchStyles, staticStyles.row, _Platform.default.select({
221
229
  web: {
222
230
  maxWidth: '100%',
@@ -235,10 +243,15 @@ const ButtonBase = /*#__PURE__*/(0, _react.forwardRef)(({
235
243
  });
236
244
  });
237
245
  ButtonBase.displayName = 'ButtonBase';
238
- ButtonBase.propTypes = { ..._utils2.a11yProps.types,
239
- ..._propTypes.default,
246
+ ButtonBase.propTypes = {
247
+ id: _propTypes.default.string,
248
+ ..._utils2.a11yProps.types,
249
+ ..._propTypes2.default,
240
250
  ..._utils2.linkProps.types
241
251
  };
252
+ ButtonBase.defaultProps = {
253
+ id: undefined
254
+ };
242
255
 
243
256
  const staticStyles = _StyleSheet.default.create({
244
257
  row: {
@@ -265,5 +278,6 @@ const staticStyles = _StyleSheet.default.create({
265
278
  }
266
279
  });
267
280
 
268
- var _default = ButtonBase;
281
+ var _default = (0, _utils2.withLinkRouter)(ButtonBase);
282
+
269
283
  exports.default = _default;
@@ -79,6 +79,7 @@ CardBase.displayName = 'CardBase';
79
79
  CardBase.propTypes = {
80
80
  children: _propTypes.default.node,
81
81
  tokens: (0, _utils.getTokensPropType)('Card'),
82
+ ..._propTypes2.viewProps.types,
82
83
  ..._propTypes2.a11yProps.types
83
84
  };
84
85
  var _default = CardBase;
@@ -52,10 +52,14 @@ const PressableCardBase = /*#__PURE__*/(0, _react.forwardRef)(({
52
52
  inactive,
53
53
  href,
54
54
  hrefAttrs,
55
- onPress,
56
55
  accessibilityRole = href ? 'link' : undefined,
57
- ...rest
56
+ ...rawRest
58
57
  }, ref) => {
58
+ const {
59
+ onPress,
60
+ ...rest
61
+ } = _utils.clickProps.toPressProps(rawRest);
62
+
59
63
  const viewport = (0, _ViewportProvider.useViewport)();
60
64
 
61
65
  const a11y = _propTypes2.a11yProps.select({ ...rest,
@@ -137,5 +141,7 @@ PressableCardBase.propTypes = {
137
141
  variant: _utils.variantProp.propType,
138
142
  ..._propTypes2.a11yProps.types
139
143
  };
140
- var _default = PressableCardBase;
144
+
145
+ var _default = (0, _utils.withLinkRouter)(PressableCardBase);
146
+
141
147
  exports.default = _default;
@@ -43,8 +43,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
43
43
 
44
44
  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; }
45
45
 
46
- // @todo move `LabelContent` outside of the `InputLabel` and fix
47
- // the issue with the cursor not being pointer on Web
48
46
  const selectInputStyles = ({
49
47
  iconBackgroundColor,
50
48
  inputBorderColor,
@@ -114,7 +114,7 @@ const styles = _StyleSheet.default.create({
114
114
  });
115
115
 
116
116
  FlexGrid.propTypes = { ..._utils.a11yProps.propTypes,
117
- ..._utils.viewProps.propTypes,
117
+ ..._utils.viewProps.types,
118
118
 
119
119
  /**
120
120
  * Whether or not to give the grid a fixed width. This also centres the grid horizontally.
@@ -83,10 +83,14 @@ const IconButton = /*#__PURE__*/(0, _react.forwardRef)(({
83
83
  icon: IconComponent,
84
84
  href,
85
85
  hrefAttrs,
86
- onPress,
87
86
  accessibilityRole = href ? 'link' : 'button',
88
- ...rest
87
+ ...rawRest
89
88
  }, ref) => {
89
+ const {
90
+ onPress,
91
+ ...rest
92
+ } = _utils.clickProps.toPressProps(rawRest);
93
+
90
94
  const a11y = _propTypes2.a11yProps.select({ ...rest,
91
95
  accessibilityRole
92
96
  });
@@ -136,5 +140,6 @@ const staticStyles = _StyleSheet.default.create({
136
140
  }
137
141
  });
138
142
 
139
- var _default = IconButton;
143
+ var _default = (0, _utils.withLinkRouter)(IconButton);
144
+
140
145
  exports.default = _default;
@@ -19,6 +19,8 @@ var _propTypes2 = require("../utils/propTypes");
19
19
 
20
20
  var _pressability = require("../utils/pressability");
21
21
 
22
+ var _utils = require("../utils");
23
+
22
24
  var _InlinePressable = _interopRequireDefault(require("./InlinePressable"));
23
25
 
24
26
  var _ThemeProvider = require("../ThemeProvider");
@@ -120,7 +122,6 @@ const selectIconTokens = ({
120
122
 
121
123
  const LinkBase = /*#__PURE__*/(0, _react.forwardRef)(({
122
124
  href,
123
- onPress,
124
125
  icon,
125
126
  iconPosition = icon ? 'left' : undefined,
126
127
  iconProps,
@@ -129,8 +130,13 @@ const LinkBase = /*#__PURE__*/(0, _react.forwardRef)(({
129
130
  children,
130
131
  accessibilityRole = 'link',
131
132
  dataSet,
132
- ...props
133
+ ...rawRest
133
134
  }, ref) => {
135
+ const {
136
+ onPress,
137
+ ...props
138
+ } = _propTypes2.clickProps.toPressProps(rawRest);
139
+
134
140
  const {
135
141
  hrefAttrs,
136
142
  rest
@@ -231,5 +237,6 @@ const staticStyles = _StyleSheet.default.create({
231
237
  }
232
238
  });
233
239
 
234
- var _default = LinkBase;
240
+ var _default = (0, _utils.withLinkRouter)(LinkBase);
241
+
235
242
  exports.default = _default;
package/lib/List/List.js CHANGED
@@ -28,7 +28,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
28
28
  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; }
29
29
 
30
30
  /**
31
- * A Unordered List component has a child a ListItem that
31
+ * An unordered List component has a child a ListItem that
32
32
  * allows icon, dividers and customized typography
33
33
  */
34
34
  const List = /*#__PURE__*/(0, _react.forwardRef)(({
@@ -66,7 +66,6 @@ const List = /*#__PURE__*/(0, _react.forwardRef)(({
66
66
  });
67
67
  });
68
68
  List.displayName = 'List';
69
- List.Item = _ListItem.default;
70
69
  List.propTypes = { ..._propTypes2.a11yProps.types,
71
70
  tokens: (0, _utils.getTokensPropType)('List'),
72
71
  variant: _utils.variantProp.propType,
@@ -11,8 +11,6 @@ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Vi
11
11
 
12
12
  var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
13
13
 
14
- var _Text = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Text"));
15
-
16
14
  var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
17
15
 
18
16
  var _propTypes = _interopRequireDefault(require("prop-types"));
@@ -57,6 +55,12 @@ const selectItemIconTokens = ({
57
55
  color: itemIconColor
58
56
  });
59
57
 
58
+ const selectCommonIconStyles = ({
59
+ iconMarginTop
60
+ }) => ({
61
+ marginTop: iconMarginTop
62
+ });
63
+
60
64
  const selectSideItemContainerStyles = ({
61
65
  listGutter
62
66
  }) => ({
@@ -113,6 +117,7 @@ const ListItem = /*#__PURE__*/(0, _react.forwardRef)(({
113
117
  const itemBulletContainerStyles = selectBulletContainerStyles(themeTokens);
114
118
  const itemBulletStyles = selectBulletStyles(themeTokens);
115
119
  const iconTokens = selectItemIconTokens(themeTokens);
120
+ const commonIconStyles = selectCommonIconStyles(themeTokens);
116
121
  const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens);
117
122
 
118
123
  const accessibilityRole = _Platform.default.select({
@@ -120,27 +125,12 @@ const ListItem = /*#__PURE__*/(0, _react.forwardRef)(({
120
125
  default: 'item'
121
126
  });
122
127
 
123
- const areChildrenStrings = () => {
124
- if (Array.isArray(children)) {
125
- return children.every(child => typeof child === 'string');
126
- }
127
-
128
- return typeof children === 'string';
129
- };
130
-
131
- const renderItem = () => {
132
- if (areChildrenStrings()) {
133
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
134
- style: itemStyles,
135
- children: children
136
- });
137
- }
138
-
139
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
140
- style: staticStyles.wrap,
141
- children: children
142
- });
143
- };
128
+ const renderItem = () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
129
+ style: staticStyles.wrap,
130
+ children: (0, _utils.wrapStringsInText)(children, {
131
+ style: itemStyles
132
+ })
133
+ });
144
134
  /**
145
135
  * Function responsible returning styling, in case the item is the last shouldn't
146
136
  * add extra margin on the bottom, if "showDivider" is true it should add a divider
@@ -171,7 +161,7 @@ const ListItem = /*#__PURE__*/(0, _react.forwardRef)(({
171
161
 
172
162
  if (icon) {
173
163
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
174
- style: [sideItemContainerStyles, areChildrenStrings() ? staticStyles.centeredIcons : undefined],
164
+ style: [sideItemContainerStyles, commonIconStyles],
175
165
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(IconComponent, {
176
166
  size: iconSize || iconTokens.size,
177
167
  color: iconColor || iconTokens.color
@@ -201,9 +191,6 @@ const staticStyles = _StyleSheet.default.create({
201
191
  itemContainer: {
202
192
  flexDirection: 'row'
203
193
  },
204
- centeredIcons: {
205
- justifyContent: 'center'
206
- },
207
194
  wrap: {
208
195
  flex: 1
209
196
  }
package/lib/List/index.js CHANGED
@@ -3,11 +3,26 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "ListBase", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _List.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ListItem", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _ListItem.default;
16
+ }
17
+ });
6
18
  exports.default = void 0;
7
19
 
8
20
  var _List = _interopRequireDefault(require("./List"));
9
21
 
22
+ var _ListItem = _interopRequireDefault(require("./ListItem"));
23
+
10
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
25
 
26
+ _List.default.Item = _ListItem.default;
12
27
  var _default = _List.default;
13
28
  exports.default = _default;
@@ -78,18 +78,14 @@ const PageButton = /*#__PURE__*/(0, _react.forwardRef)(({
78
78
  });
79
79
  });
80
80
  PageButton.displayName = 'PageButton';
81
- PageButton.propTypes = {
82
- // Spreading any props into a secondary component accessed like Pagination.PageButton
83
- // crashes a Docusaurus props table, but only in production, not in development
84
- onPress: _propTypes.default.func,
85
- href: _propTypes.default.string,
86
- // If the above is fixed, the above can be replaced with this which includes full a11y etc:
87
- // ...linkProps.types,
81
+ PageButton.propTypes = { ..._utils.linkProps.types,
88
82
  label: _propTypes.default.string,
89
83
  isActive: _propTypes.default.bool,
90
84
  copy: _utils.copyPropTypes,
91
85
  variant: _utils.variantProp.propType,
92
86
  tokens: (0, _utils.getTokensPropType)('PaginationPageButton')
93
87
  };
94
- var _default = PageButton;
88
+
89
+ var _default = (0, _utils.withLinkRouter)(PageButton);
90
+
95
91
  exports.default = _default;
@@ -55,7 +55,9 @@ const Pagination = /*#__PURE__*/(0, _react.forwardRef)(({
55
55
  variant,
56
56
  tokens,
57
57
  sideButtonVariant,
58
- sideButtonTokens
58
+ sideButtonTokens,
59
+ LinkRouter,
60
+ linkRouterProps
59
61
  }, ref) => {
60
62
  const viewport = (0, _ViewportProvider.useViewport)();
61
63
  const {
@@ -93,13 +95,21 @@ const Pagination = /*#__PURE__*/(0, _react.forwardRef)(({
93
95
  direction: "previous",
94
96
  copy: copy,
95
97
  variant: sideButtonVariant,
96
- tokens: sideButtonTokens
98
+ tokens: sideButtonTokens,
99
+ LinkRouter: LinkRouter,
100
+ linkRouterProps: linkRouterProps
97
101
  }), ...items.map((child, itemIndex) => {
98
102
  const buttonLabel = `${itemIndex + 1}`;
99
103
  const itemProps = getItemProps(itemIndex);
104
+ const ItemLinkRouter = itemProps.LinkRouter ?? LinkRouter;
105
+ const itemLinkRouterProps = { ...linkRouterProps,
106
+ ...itemProps.linkRouterProps
107
+ };
100
108
 
101
109
  if (shouldRenderButton(itemIndex)) {
102
110
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PageButton.default, { ...itemProps,
111
+ LinkRouter: ItemLinkRouter,
112
+ linkRouterProps: itemLinkRouterProps,
103
113
  label: buttonLabel,
104
114
  copy: copy,
105
115
  isActive: isItemActive(itemIndex)
@@ -118,7 +128,9 @@ const Pagination = /*#__PURE__*/(0, _react.forwardRef)(({
118
128
  direction: "next",
119
129
  copy: copy,
120
130
  variant: sideButtonVariant,
121
- tokens: sideButtonTokens
131
+ tokens: sideButtonTokens,
132
+ LinkRouter: LinkRouter,
133
+ linkRouterProps: linkRouterProps
122
134
  })];
123
135
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
124
136
  style: staticStyles.container,
@@ -132,7 +144,7 @@ const Pagination = /*#__PURE__*/(0, _react.forwardRef)(({
132
144
  });
133
145
  _PageButton.default.displayName = 'PageButton';
134
146
  Pagination.PageButton = _PageButton.default;
135
- Pagination.propTypes = {
147
+ Pagination.propTypes = { ..._utils.withLinkRouter.propTypes,
136
148
  children: (0, _utils.componentPropType)('PageButton'),
137
149
  copy: _utils.copyPropTypes,
138
150
  variant: _utils.variantProp.propType,
@@ -125,5 +125,7 @@ SideButton.propTypes = {
125
125
  copy: _utils.copyPropTypes,
126
126
  ..._utils.linkProps.types
127
127
  };
128
- var _default = SideButton;
128
+
129
+ var _default = (0, _utils.withLinkRouter)(SideButton);
130
+
129
131
  exports.default = _default;
@@ -37,8 +37,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
37
37
 
38
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
39
 
40
- // @todo move `LabelContent` outside of the `InputLabel` and fix
41
- // the issue with the cursor not being pointer on Web
42
40
  const selectContainerStyles = ({
43
41
  containerBackgroundColor,
44
42
  containerBorderRadius,
@@ -108,6 +108,7 @@ const StackView = /*#__PURE__*/(0, _react.forwardRef)(({
108
108
  });
109
109
  StackView.displayName = 'StackView';
110
110
  StackView.propTypes = { ..._utils.a11yProps.propTypes,
111
+ ..._utils.viewProps.types,
111
112
  tokens: (0, _utils.getTokensPropType)('StackView'),
112
113
  variant: _utils.variantProp.propType,
113
114
 
@@ -21,8 +21,15 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
21
21
 
22
22
  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; }
23
23
 
24
- // CSS.supports needs an example of the type of value you intend to use.
24
+ // In Jest/CI/SSR, global CSS isn't always available and doesn't always have .supports method
25
+ const cssSupports = (...args) => {
26
+ var _window$CSS;
27
+
28
+ return typeof window !== 'undefined' && typeof ((_window$CSS = window.CSS) === null || _window$CSS === void 0 ? void 0 : _window$CSS.supports) === 'function' && window.CSS.supports(...args);
29
+ }; // CSS.supports needs an example of the type of value you intend to use.
25
30
  // Will be an integer appended `px` after hooks and JSX styles are resolved.
31
+
32
+
26
33
  const exampleGapValue = '1px';
27
34
  /**
28
35
  * StackWrap is an alternative to StackView where the spaced items are allowed to wrap.
@@ -33,15 +40,12 @@ const exampleGapValue = '1px';
33
40
  */
34
41
 
35
42
  const StackWrap = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
36
- var _CSS;
37
-
38
43
  const {
39
44
  space
40
45
  } = props; // Don't apply separate gap if `null` or `undefined`, so can be unset in Storybook etc
41
46
 
42
47
  const gap = props.gap ?? space;
43
- const canUseCSSGap = _Platform.default.OS === 'web' && gap === space && // In Jest/CI, global CSS isn't always available and doesn't always have .supports method
44
- typeof ((_CSS = CSS) === null || _CSS === void 0 ? void 0 : _CSS.supports) === 'function' && CSS.supports('gap', exampleGapValue);
48
+ const canUseCSSGap = _Platform.default.OS === 'web' && gap === space && cssSupports('gap', exampleGapValue);
45
49
  return canUseCSSGap ?
46
50
  /*#__PURE__*/
47
51
  // If possible, use the cleaner implementation that applies CSS `gap` styles to the container.
@@ -98,6 +98,7 @@ const StackWrapBox = /*#__PURE__*/(0, _react.forwardRef)(({
98
98
  });
99
99
  StackWrapBox.displayName = 'StackWrapBox';
100
100
  StackWrapBox.propTypes = { ..._utils.a11yProps.propTypes,
101
+ ..._utils.viewProps.types,
101
102
  tokens: (0, _utils.getTokensPropType)('StackView'),
102
103
 
103
104
  /**
package/lib/Tabs/Tabs.js CHANGED
@@ -46,7 +46,9 @@ const Tabs = /*#__PURE__*/(0, _react.forwardRef)(({
46
46
  value,
47
47
  initialValue,
48
48
  onChange,
49
- items = []
49
+ items = [],
50
+ LinkRouter,
51
+ linkRouterProps
50
52
  }, ref) => {
51
53
  const {
52
54
  space,
@@ -82,7 +84,9 @@ const Tabs = /*#__PURE__*/(0, _react.forwardRef)(({
82
84
  href,
83
85
  label,
84
86
  id,
85
- ref: itemRef
87
+ ref: itemRef,
88
+ LinkRouter: ItemLinkRouter = LinkRouter,
89
+ linkRouterProps: itemLinkRouterProps
86
90
  }, index) => {
87
91
  const itemId = id ?? label;
88
92
  const isSelected = Boolean(currentValue && currentValue === itemId);
@@ -98,6 +102,10 @@ const Tabs = /*#__PURE__*/(0, _react.forwardRef)(({
98
102
  selected: isSelected,
99
103
  itemPositions: itemPositions,
100
104
  index: index,
105
+ LinkRouter: ItemLinkRouter,
106
+ linkRouterProps: { ...linkRouterProps,
107
+ ...itemLinkRouterProps
108
+ },
101
109
  children: label
102
110
  }, itemId);
103
111
  })
@@ -105,8 +113,8 @@ const Tabs = /*#__PURE__*/(0, _react.forwardRef)(({
105
113
  });
106
114
  });
107
115
  Tabs.displayName = 'Tabs';
108
- Tabs.propTypes = {
109
- items: _propTypes.default.arrayOf(_propTypes.default.shape({
116
+ Tabs.propTypes = { ..._utils.withLinkRouter.PropTypes,
117
+ items: _propTypes.default.arrayOf(_propTypes.default.shape({ ..._utils.withLinkRouter.PropTypes,
110
118
  href: _propTypes.default.string,
111
119
  label: _propTypes.default.string,
112
120
  id: _propTypes.default.string,
@@ -99,7 +99,6 @@ const selectContainerStyles = ({
99
99
 
100
100
 
101
101
  const TabsItem = /*#__PURE__*/(0, _react.forwardRef)(({
102
- onPress,
103
102
  href,
104
103
  variant,
105
104
  tokens,
@@ -114,8 +113,14 @@ const TabsItem = /*#__PURE__*/(0, _react.forwardRef)(({
114
113
  } : {
115
114
  selected
116
115
  },
117
- ...rest
116
+ ...rawRest
118
117
  }, ref) => {
118
+ // Convert onClick etc to onPress etc if used in an integration
119
+ const {
120
+ onPress,
121
+ ...rest
122
+ } = _utils.clickProps.toPressProps(rawRest);
123
+
119
124
  const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('TabsItem', tokens, variant);
120
125
 
121
126
  const resolveTokens = pressableState => (0, _utils.resolvePressableTokens)(getTokens, pressableState, {
@@ -139,9 +144,9 @@ const TabsItem = /*#__PURE__*/(0, _react.forwardRef)(({
139
144
  href
140
145
  });
141
146
 
142
- const handlePress = onPress || openHref ? () => {
143
- if (onPress) onPress();
144
- if (openHref) openHref();
147
+ const handlePress = onPress || openHref ? (...args) => {
148
+ if (onPress) onPress(...args);
149
+ if (openHref) openHref(...args);
145
150
  } : undefined;
146
151
  const a11y = {
147
152
  accessibilityRole,
@@ -234,5 +239,6 @@ const staticStyles = _StyleSheet.default.create({
234
239
  }
235
240
  });
236
241
 
237
- var _default = TabsItem;
242
+ var _default = (0, _utils.withLinkRouter)(TabsItem);
243
+
238
244
  exports.default = _default;