@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
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.copyPropTypes = exports.componentPropType = exports.spacingProps = exports.responsiveProps = exports.viewProps = exports.linkProps = exports.pressProps = exports.hrefAttrsProp = exports.a11yProps = exports.getTokensSetPropType = exports.getTokensPropType = exports.selectTokens = exports.getTokenNames = exports.variantProp = exports.rectProp = exports.paddingProp = void 0;
6
+ exports.copyPropTypes = exports.componentPropType = exports.spacingProps = exports.responsiveProps = exports.viewProps = exports.linkProps = exports.clickProps = exports.pressProps = exports.hrefAttrsProp = exports.a11yProps = exports.getTokensSetPropType = exports.getTokensPropType = exports.selectTokens = exports.getTokenNames = exports.variantProp = exports.rectProp = exports.paddingProp = void 0;
7
7
 
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
 
@@ -13,6 +13,8 @@ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/export
13
13
 
14
14
  var _systemThemeTokens = require("@telus-uds/system-theme-tokens");
15
15
 
16
+ var _propTypes2 = _interopRequireDefault(require("./a11y/propTypes"));
17
+
16
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
19
 
18
20
  const paddingProp = {
@@ -190,98 +192,14 @@ function getPropSelector(propTypes, regexp) {
190
192
  return props => Object.entries(props).reduce((items, [key, value]) => keys.includes(key) || regexp && regexp.test(key) ? { ...items,
191
193
  [key]: value
192
194
  } : items, {});
193
- } // React Native exports a11y prop definitions as TypeScript Interfaces, but no longer exports PropTypes
194
- // so we have to define them ourselves.
195
-
196
-
197
- const a11yPropTypes = {
198
- accessible: _propTypes.default.bool,
199
- focusable: _propTypes.default.bool,
200
- accessibilityElementsHidden: _propTypes.default.bool,
201
- accessibilityHint: _propTypes.default.string,
202
- // react-native-web ignores `accessibilityHint`
203
- accessibilityIgnoresInvertColors: _propTypes.default.bool,
204
- accessibilityLabel: _propTypes.default.string,
205
- accessibilityRole: _propTypes.default.string,
206
- accessibilityActions: _propTypes.default.arrayOf(_propTypes.default.shape({
207
- name: _propTypes.default.string.isRequired,
208
- label: _propTypes.default.string
209
- })),
210
- accessibilityLiveRegion: _propTypes.default.oneOf(['none', 'polite', 'assertive']),
211
- accessibilityState: _propTypes.default.shape({
212
- disabled: _propTypes.default.bool,
213
- selected: _propTypes.default.bool,
214
- checked: _propTypes.default.oneOf([true, false, 'mixed']),
215
- busy: _propTypes.default.bool,
216
- expanded: _propTypes.default.bool
217
- }),
218
- accessibilityValue: _propTypes.default.shape({
219
- min: _propTypes.default.number,
220
- max: _propTypes.default.number,
221
- now: _propTypes.default.number,
222
- text: _propTypes.default.string
223
- }),
224
- accessibilityViewIsModal: _propTypes.default.bool,
225
- importantForAccessibility: _propTypes.default.oneOf(['auto', 'yes', 'no', 'no-hide-descendants']),
226
- onAccessibilityAction: _propTypes.default.func,
227
- onAccessibilityEscape: _propTypes.default.func,
228
- onAccessibilityTap: _propTypes.default.func,
229
- ..._Platform.default.select({
230
- web: {
231
- // React Native Web adds many a11y props that alias aria-* attributes
232
- // Types based on https://necolas.github.io/react-native-web/docs/accessibility/
233
- accessibilityActiveDescendant: _propTypes.default.string,
234
- accessibilityAtomic: _propTypes.default.bool,
235
- accessibilityAutoComplete: _propTypes.default.string,
236
- accessibilityBusy: _propTypes.default.bool,
237
- accessibilityChecked: _propTypes.default.oneOf([true, false, 'mixed']),
238
- accessibilityColumnCount: _propTypes.default.number,
239
- accessibilityColumnIndex: _propTypes.default.number,
240
- accessibilityColumnSpan: _propTypes.default.number,
241
- accessibilityControls: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
242
- accessibilityCurrent: _propTypes.default.oneOf([true, false, 'page', 'step', 'location', 'date', 'time']),
243
- accessibilityDescribedBy: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
244
- accessibilityDetails: _propTypes.default.string,
245
- accessibilityDisabled: _propTypes.default.bool,
246
- accessibilityErrorMessage: _propTypes.default.string,
247
- accessibilityExpanded: _propTypes.default.bool,
248
- accessibilityFlowTo: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
249
- accessibilityHasPopup: _propTypes.default.string,
250
- accessibilityHidden: _propTypes.default.bool,
251
- accessibilityInvalid: _propTypes.default.bool,
252
- accessibilityKeyShortcuts: _propTypes.default.string,
253
- accessibilityLabelledBy: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
254
- accessibilityLevel: _propTypes.default.number,
255
- accessibilityModal: _propTypes.default.bool,
256
- accessibilityMultiline: _propTypes.default.bool,
257
- accessibilityMultiSelectable: _propTypes.default.bool,
258
- accessibilityOrientation: _propTypes.default.oneOf(['horizontal', 'vertical']),
259
- accessibilityOwns: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
260
- accessibilityPlaceholder: _propTypes.default.string,
261
- accessibilityPosInSet: _propTypes.default.number,
262
- accessibilityPressed: _propTypes.default.bool,
263
- accessibilityReadOnly: _propTypes.default.bool,
264
- accessibilityRequired: _propTypes.default.bool,
265
- accessibilityRoleDescription: _propTypes.default.string,
266
- accessibilityRowCount: _propTypes.default.number,
267
- accessibilityRowIndex: _propTypes.default.number,
268
- accessibilityRowSpan: _propTypes.default.number,
269
- accessibilitySelected: _propTypes.default.bool,
270
- accessibilitySetSize: _propTypes.default.number,
271
- accessibilitySort: _propTypes.default.oneOf(['ascending', 'descending', 'none', 'other']),
272
- accessibilityValueMax: _propTypes.default.number,
273
- accessibilityValueMin: _propTypes.default.number,
274
- accessibilityValueNow: _propTypes.default.number,
275
- accessibilityValueText: _propTypes.default.string
276
- }
277
- })
278
- };
195
+ }
196
+
279
197
  const a11yProps = {
280
198
  /**
281
199
  * Proptypes for recognised React Native accessiblity (a11y) props.
282
200
  * Spread this in the propTypes of components that accept React Native a11y props.
283
201
  */
284
- types: a11yPropTypes,
202
+ types: _propTypes2.default,
285
203
 
286
204
  /**
287
205
  * Filters a props object, returning only recognised React Native accessiblity (a11y) props.
@@ -289,7 +207,7 @@ const a11yProps = {
289
207
  * Where components accept React Native a11y props, pass { ...rest } from its props to this,
290
208
  * then spread the returned object into the component's props (usually its outer container).
291
209
  */
292
- select: getPropSelector(a11yPropTypes, /^aria-/),
210
+ select: getPropSelector(_propTypes2.default, /^aria-/),
293
211
 
294
212
  /**
295
213
  * Use this to disable focus for elements which are visually hidden but still rendered.
@@ -401,10 +319,35 @@ const pressProps = {
401
319
  selectHandlers: getPropSelector(pressHandlerPropTypes)
402
320
  };
403
321
  exports.pressProps = pressProps;
322
+ const clickHandlerMapping = {
323
+ onClick: 'onPress',
324
+ mouseDown: 'onPressIn',
325
+ mouseUp: 'onPressOut'
326
+ };
327
+ const clickProps = {
328
+ /**
329
+ * Web-oriented HTML click handlers that may be mapped to React Native press handlers
330
+ */
331
+ types: Object.fromEntries(Object.keys(clickHandlerMapping).map(mouseName => [mouseName, _propTypes.default.func])),
332
+
333
+ /**
334
+ * Takes a set of props and converts HTML mouse click oriented event handlers to closest
335
+ * equivalent React Native press event handler.
336
+ *
337
+ * Use this when a component that expects press-oriented props may need to support third-party
338
+ * web-oriented tooling that injects web-oriented event handlers directly. For example, for
339
+ * to support use with NextJS's 'next/link' component, which injects `onClick` prop into its child.
340
+ */
341
+ toPressProps: props => Object.fromEntries(Object.entries(props).map(([originalName, value]) => {
342
+ const translatedName = clickHandlerMapping[originalName];
343
+ return translatedName ? [translatedName, value] : [originalName, value];
344
+ }))
345
+ };
346
+ exports.clickProps = clickProps;
404
347
  const linkPropTypes = { ...pressPropTypes,
405
348
  href: _propTypes.default.string,
406
349
  hrefAttrs: _propTypes.default.shape(hrefAttrsProp.types),
407
- ...a11yPropTypes
350
+ ..._propTypes2.default
408
351
  };
409
352
  const linkProps = {
410
353
  /**
@@ -446,7 +389,8 @@ const viewPropTypes = {
446
389
  pointerEvents: _propTypes.default.oneOf(['all', 'none', 'box-only', 'box-none']),
447
390
  onLayout: _propTypes.default.func,
448
391
  nativeID: _propTypes.default.string,
449
- testID: _propTypes.default.string
392
+ testID: _propTypes.default.string,
393
+ dataSet: _propTypes.default.object
450
394
  };
451
395
  const viewProps = {
452
396
  /**
@@ -0,0 +1,98 @@
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 _jsxRuntime = require("react/jsx-runtime");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ 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); }
17
+
18
+ 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; }
19
+
20
+ // Prototype-safe alternative to (linter-forbidden) someObject.hasOwnProperty()
21
+ const hasOwnProperty = (object, prop) => Object.prototype.hasOwnProperty.call(object, prop);
22
+ /**
23
+ * Higher-order component that has no effect unless an additional prop `LinkRouter` is passed.
24
+ * This may be used to provide custom wrappers for integrations with third party libraries.
25
+ *
26
+ * If LinkRouter is passed, LinkRouter is rendered in place of the main component and is passed:
27
+ *
28
+ * - `linkRouterProps`: an optional object passed alongside LinkRouter, for props needed by the wrapper
29
+ * that are not valid props for the wrapped component.
30
+ * - `Component`: automatically provided, the original component to render inside the wrapper.
31
+ * - `ref`: forwarded `ref` passed down to `Component`
32
+ * - All other props passed to the outer component
33
+ *
34
+ * @example A LinkRouter component to be used with link-like components might look like:
35
+ *
36
+ * ```jsx
37
+ * const LinkLinkRouter = forwardRef(({ Component, linkRouterProps: { to, options }, href, ...rest }, ref) => {
38
+ * const { href: resolvedHref, onClick } = useSomeRouterHook({ to, href, options })
39
+ * return <Component href={resolvedHref} onPress={onClick} {...rest} />
40
+ * })
41
+ * ```
42
+ *
43
+ * Any component that takes href and onPress props may then use this wrapper:
44
+ *
45
+ * ```jsx
46
+ * <Link href={href} LinkRouter={LinkLinkRouter} linkRouterProps={{ to, options }}>Some link</Link>
47
+ * <IconButton icon={SomeIcon} LinkRouter={LinkLinkRouter} linkRouterProps={{ to, options }} ref={iconRef} />
48
+ * ```
49
+ */
50
+
51
+
52
+ const withLinkRouter = Component => {
53
+ const wrappedComponent = /*#__PURE__*/(0, _react.forwardRef)(({
54
+ LinkRouter,
55
+ linkRouterProps,
56
+ ...props
57
+ }, ref) => {
58
+ if (!LinkRouter) return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, { ...props,
59
+ ref: ref
60
+ });
61
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(LinkRouter, {
62
+ linkRouterProps: linkRouterProps,
63
+ Component: Component,
64
+ ref: ref,
65
+ ...props
66
+ });
67
+ }); // Ensure the returned component has appropriate outer properties set:
68
+
69
+ /* eslint-disable-next-line react/forbid-foreign-prop-types */
70
+
71
+ const {
72
+ displayName,
73
+ name,
74
+ propTypes,
75
+ ...otherProperties
76
+ } = Component; // Apply unique component name as a displayName
77
+
78
+ wrappedComponent.displayName = Component.displayName || Component.name; // Apply proptypes including wrapper props - is safely { ...undefined, ...undefined } in prod
79
+
80
+ wrappedComponent.propTypes = { ...Component.propTypes,
81
+ ...withLinkRouter.propTypes
82
+ }; // Forward any other properties explicitly set e.g. Component.SubComponent
83
+
84
+ Object.keys(otherProperties).forEach(key => {
85
+ // Skip internal React properties from wrappedComponent's forwardRef (render, $$typeof, etc)
86
+ if (hasOwnProperty(Component, key) && !hasOwnProperty(wrappedComponent, key)) {
87
+ wrappedComponent[key] = Component[key];
88
+ }
89
+ });
90
+ return wrappedComponent;
91
+ };
92
+
93
+ withLinkRouter.propTypes = {
94
+ LinkRouter: _propTypes.default.elementType,
95
+ linkRouterProps: _propTypes.default.object
96
+ };
97
+ var _default = withLinkRouter;
98
+ exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telus-uds/components-base",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Base components",
5
5
  "keywords": [
6
6
  "base"
@@ -23,9 +23,12 @@
23
23
  "lint": "telus-standard",
24
24
  "lint:fix": "telus-standard --fix",
25
25
  "format": "prettier --write .",
26
- "build": "babel src -d lib",
27
- "dev": "yarn build --watch",
28
- "release": "standard-version --release-as major"
26
+ "build": "yarn build:code && yarn build:docs",
27
+ "build:code": "babel src -d lib",
28
+ "build:docs": "babel-node --plugins=react-docgen-alpha generate-component-docs.js",
29
+ "storybook": "start-storybook",
30
+ "dev": "yarn build:code --watch",
31
+ "release": "standard-version"
29
32
  },
30
33
  "bugs": {
31
34
  "url": "https://github.com/telus/universal-design-system/issues"
@@ -43,6 +46,7 @@
43
46
  "react-native-web": "^0.17.0"
44
47
  },
45
48
  "devDependencies": {
49
+ "@telus-uds/browserslist-config": "^1.0.0",
46
50
  "@testing-library/jest-native": "^4.0.1",
47
51
  "@testing-library/react-hooks": "^7.0.1",
48
52
  "@testing-library/react-native": "^7.2.0",
@@ -50,8 +54,8 @@
50
54
  },
51
55
  "dependencies": {
52
56
  "airbnb-prop-types": "^2.16.0",
53
- "@telus-uds/system-constants": "^1.0.0",
54
- "@telus-uds/system-theme-tokens": "^1.0.0",
57
+ "@telus-uds/system-constants": "^1.0.1-prerelease.0",
58
+ "@telus-uds/system-theme-tokens": "^1.2.0",
55
59
  "lodash.debounce": "^4.0.8",
56
60
  "lodash.merge": "^4.6.2",
57
61
  "prop-types": "^15.7.2",
@@ -1,7 +1,7 @@
1
1
  {
2
- "previousReleaseTag": "@telus-uds/components-base/v0.0.2-prerelease.10",
3
- "changelog": "## [1.0.0](https://github.com/telus/universal-design-system/compare/@telus-uds/components-base/v0.0.2-prerelease.10...@telus-uds/components-base/v1.0.0) (2022-02-03)\n\n\n### Features\n\n* add dataSet prop ([#1156](https://github.com/telus/universal-design-system/issues/1156)) ([21f49f6](https://github.com/telus/universal-design-system/commit/21f49f6c898118bb94c45f07a52c163b61e4cbaa))\n* **base:** add forwardRef to remaining components ([#1218](https://github.com/telus/universal-design-system/issues/1218)) ([49ccc42](https://github.com/telus/universal-design-system/commit/49ccc4217a68613f23dd7a23dd99e0f61fd6f121))\n* **base:** add tag prop for semantic HTML ([#1222](https://github.com/telus/universal-design-system/issues/1222)) ([581d070](https://github.com/telus/universal-design-system/commit/581d070782dfe569ffcf20c34de6e4409cdd8dfa))\n* **themes:** validate theme token types ([#1221](https://github.com/telus/universal-design-system/issues/1221)) ([dae382d](https://github.com/telus/universal-design-system/commit/dae382d19f86b88cd5de9df8c94f8200aee5b33f))\n\n\n### Bug Fixes\n\n* **base:** avoid errors in apps and update demo app ([#1215](https://github.com/telus/universal-design-system/issues/1215)) ([df6897a](https://github.com/telus/universal-design-system/commit/df6897a4918342e9859e596b9578bcdefc1a5702))\n",
4
- "releaseTag": "@telus-uds/components-base/v1.0.0",
5
- "newVersion": "1.0.0",
2
+ "previousReleaseTag": "@telus-uds/components-base/v1.1.0",
3
+ "changelog": "## [1.2.0](https://github.com/telus/universal-design-system/compare/@telus-uds/components-base/v1.1.0...@telus-uds/components-base/v1.2.0) (2022-03-02)\n\n\n### Features\n\n* add withLinkRouter to support router integration ([#1324](https://github.com/telus/universal-design-system/issues/1324)) ([e56f491](https://github.com/telus/universal-design-system/commit/e56f491ac088a005f364330cfc70901532df7cea))\n* **component-base:** refactor ToggleSwitch to use input label and add tooltip support ([#1341](https://github.com/telus/universal-design-system/issues/1341)) ([979da1a](https://github.com/telus/universal-design-system/commit/979da1afb5b319df51026f44299d363f50f1be7d))\n* **components-base:** add ToggleSwitchGroup ([#1307](https://github.com/telus/universal-design-system/issues/1307)) ([402630a](https://github.com/telus/universal-design-system/commit/402630ad04c2d81c4f882fed564cf4ae33096cea))\n",
4
+ "releaseTag": "@telus-uds/components-base/v1.2.0",
5
+ "newVersion": "1.2.0",
6
6
  "packageName": "@telus-uds/components-base"
7
7
  }
package/src/Box/Box.jsx CHANGED
@@ -155,6 +155,7 @@ Box.displayName = 'Box'
155
155
 
156
156
  Box.propTypes = {
157
157
  ...a11yProps.propTypes,
158
+ ...viewProps.types,
158
159
  variant: variantProp.propType,
159
160
  tokens: getTokensPropType('Box'),
160
161
  /**
@@ -1,4 +1,5 @@
1
1
  import React, { forwardRef } from 'react'
2
+ import PropTypes from 'prop-types'
2
3
  import { Pressable, View, StyleSheet, Platform } from 'react-native'
3
4
 
4
5
  import { applyTextStyles, applyShadowToken, applyOuterBorder } from '../ThemeProvider/utils'
@@ -6,10 +7,12 @@ import buttonPropTypes from './propTypes'
6
7
  import {
7
8
  a11yProps,
8
9
  getCursorStyle,
10
+ clickProps,
9
11
  linkProps,
10
12
  resolvePressableState,
11
13
  resolvePressableTokens,
12
- wrapStringsInText
14
+ wrapStringsInText,
15
+ withLinkRouter
13
16
  } from '../utils'
14
17
 
15
18
  const getOuterBorderOffset = ({ outerBorderGap = 0, outerBorderWidth = 0 }) =>
@@ -133,19 +136,20 @@ const selectWebOnlyStyles = (inactive, themeTokens, { accessibilityRole }) => {
133
136
  const ButtonBase = forwardRef(
134
137
  (
135
138
  {
139
+ id,
136
140
  href,
137
141
  hrefAttrs,
138
142
  children,
139
- onPress,
140
143
  tokens = {},
141
144
  disabled = false, // alias for inactive
142
145
  inactive = disabled,
143
146
  selected = false,
144
147
  dataSet,
145
- ...rest
148
+ ...rawRest
146
149
  },
147
150
  ref
148
151
  ) => {
152
+ const { onPress, ...rest } = clickProps.toPressProps(rawRest)
149
153
  const extraButtonState = { inactive, selected }
150
154
  const resolveButtonTokens = (pressableState) =>
151
155
  resolvePressableTokens(tokens, pressableState, extraButtonState)
@@ -185,6 +189,7 @@ const ButtonBase = forwardRef(
185
189
 
186
190
  return (
187
191
  <View
192
+ id={id}
188
193
  style={[
189
194
  containerStyles,
190
195
  borderStyles,
@@ -218,10 +223,12 @@ const ButtonBase = forwardRef(
218
223
  ButtonBase.displayName = 'ButtonBase'
219
224
 
220
225
  ButtonBase.propTypes = {
226
+ id: PropTypes.string,
221
227
  ...a11yProps.types,
222
228
  ...buttonPropTypes,
223
229
  ...linkProps.types
224
230
  }
231
+ ButtonBase.defaultProps = { id: undefined }
225
232
 
226
233
  const staticStyles = StyleSheet.create({
227
234
  row: {
@@ -245,4 +252,4 @@ const staticStyles = StyleSheet.create({
245
252
  }
246
253
  })
247
254
 
248
- export default ButtonBase
255
+ export default withLinkRouter(ButtonBase)
@@ -52,6 +52,7 @@ CardBase.displayName = 'CardBase'
52
52
  CardBase.propTypes = {
53
53
  children: PropTypes.node,
54
54
  tokens: getTokensPropType('Card'),
55
+ ...viewProps.types,
55
56
  ...a11yProps.types
56
57
  }
57
58
 
@@ -11,7 +11,9 @@ import {
11
11
  getTokenNames,
12
12
  getTokensSetPropType,
13
13
  variantProp,
14
- linkProps
14
+ linkProps,
15
+ clickProps,
16
+ withLinkRouter
15
17
  } from '../utils'
16
18
  import { a11yProps } from '../utils/propTypes'
17
19
  import CardBase from './CardBase'
@@ -43,12 +45,12 @@ const PressableCardBase = forwardRef(
43
45
  inactive,
44
46
  href,
45
47
  hrefAttrs,
46
- onPress,
47
48
  accessibilityRole = href ? 'link' : undefined,
48
- ...rest
49
+ ...rawRest
49
50
  },
50
51
  ref
51
52
  ) => {
53
+ const { onPress, ...rest } = clickProps.toPressProps(rawRest)
52
54
  const viewport = useViewport()
53
55
  const a11y = a11yProps.select({
54
56
  ...rest,
@@ -116,4 +118,4 @@ PressableCardBase.propTypes = {
116
118
  ...a11yProps.types
117
119
  }
118
120
 
119
- export default PressableCardBase
121
+ export default withLinkRouter(PressableCardBase)
@@ -3,8 +3,6 @@ import PropTypes from 'prop-types'
3
3
  import { Platform, Pressable, StyleSheet, Text, View } from 'react-native'
4
4
 
5
5
  import CheckboxInput from './CheckboxInput'
6
- // @todo move `LabelContent` outside of the `InputLabel` and fix
7
- // the issue with the cursor not being pointer on Web
8
6
  import CheckboxLabel from '../InputLabel/LabelContent'
9
7
  import Feedback from '../Feedback'
10
8
  import StackView from '../StackView'
@@ -92,7 +92,7 @@ const styles = StyleSheet.create({
92
92
 
93
93
  FlexGrid.propTypes = {
94
94
  ...a11yProps.propTypes,
95
- ...viewProps.propTypes,
95
+ ...viewProps.types,
96
96
  /**
97
97
  * Whether or not to give the grid a fixed width. This also centres the grid horizontally.
98
98
  */
@@ -5,11 +5,13 @@ import { Pressable, Platform, StyleSheet, View } from 'react-native'
5
5
  import { applyOuterBorder, useThemeTokensCallback, applyShadowToken } from '../ThemeProvider'
6
6
  import {
7
7
  variantProp,
8
+ clickProps,
8
9
  linkProps,
9
10
  resolvePressableState,
10
11
  hrefAttrsProp,
11
12
  getTokensPropType,
12
- selectTokens
13
+ selectTokens,
14
+ withLinkRouter
13
15
  } from '../utils'
14
16
  import { a11yProps } from '../utils/propTypes'
15
17
  import Icon from '../Icon'
@@ -52,12 +54,12 @@ const IconButton = forwardRef(
52
54
  icon: IconComponent,
53
55
  href,
54
56
  hrefAttrs,
55
- onPress,
56
57
  accessibilityRole = href ? 'link' : 'button',
57
- ...rest
58
+ ...rawRest
58
59
  },
59
60
  ref
60
61
  ) => {
62
+ const { onPress, ...rest } = clickProps.toPressProps(rawRest)
61
63
  const a11y = a11yProps.select({
62
64
  ...rest,
63
65
  accessibilityRole
@@ -111,4 +113,4 @@ const staticStyles = StyleSheet.create({
111
113
  }
112
114
  })
113
115
 
114
- export default IconButton
116
+ export default withLinkRouter(IconButton)
@@ -6,9 +6,11 @@ import {
6
6
  hrefAttrsProp,
7
7
  variantProp,
8
8
  linkProps,
9
- getTokensPropType
9
+ getTokensPropType,
10
+ clickProps
10
11
  } from '../utils/propTypes'
11
12
  import { resolvePressableTokens } from '../utils/pressability'
13
+ import { withLinkRouter } from '../utils'
12
14
 
13
15
  import InlinePressable from './InlinePressable'
14
16
  import { applyTextStyles, applyOuterBorder } from '../ThemeProvider'
@@ -92,7 +94,6 @@ const LinkBase = forwardRef(
92
94
  (
93
95
  {
94
96
  href,
95
- onPress,
96
97
  icon,
97
98
  iconPosition = icon ? 'left' : undefined,
98
99
  iconProps,
@@ -101,10 +102,11 @@ const LinkBase = forwardRef(
101
102
  children,
102
103
  accessibilityRole = 'link',
103
104
  dataSet,
104
- ...props
105
+ ...rawRest
105
106
  },
106
107
  ref
107
108
  ) => {
109
+ const { onPress, ...props } = clickProps.toPressProps(rawRest)
108
110
  const { hrefAttrs, rest } = hrefAttrsProp.bundle(props)
109
111
  const linkPropSet = linkProps.select({
110
112
  accessibilityRole,
@@ -200,4 +202,4 @@ const staticStyles = StyleSheet.create({
200
202
  }
201
203
  })
202
204
 
203
- export default LinkBase
205
+ export default withLinkRouter(LinkBase)
package/src/List/List.jsx CHANGED
@@ -6,7 +6,7 @@ import { a11yProps } from '../utils/propTypes'
6
6
  import ListItem from './ListItem'
7
7
 
8
8
  /**
9
- * A Unordered List component has a child a ListItem that
9
+ * An unordered List component has a child a ListItem that
10
10
  * allows icon, dividers and customized typography
11
11
  */
12
12
  const List = forwardRef(({ children, showDivider, tokens, variant, ...rest }, ref) => {
@@ -32,8 +32,6 @@ const List = forwardRef(({ children, showDivider, tokens, variant, ...rest }, re
32
32
  })
33
33
  List.displayName = 'List'
34
34
 
35
- List.Item = ListItem
36
-
37
35
  List.propTypes = {
38
36
  ...a11yProps.types,
39
37
  tokens: getTokensPropType('List'),
@@ -1,8 +1,8 @@
1
1
  import React, { forwardRef } from 'react'
2
- import { View, Platform, Text, StyleSheet } from 'react-native'
2
+ import { View, Platform, StyleSheet } from 'react-native'
3
3
  import PropTypes from 'prop-types'
4
4
  import { useThemeTokens, applyTextStyles } from '../ThemeProvider'
5
- import { getTokensPropType, variantProp } from '../utils'
5
+ import { getTokensPropType, variantProp, wrapStringsInText } from '../utils'
6
6
 
7
7
  const selectBulletStyles = ({ itemBulletWidth, itemBulletHeight, itemBulletColor }) => ({
8
8
  width: itemBulletWidth,
@@ -22,6 +22,10 @@ const selectItemIconTokens = ({ itemIconSize, itemIconColor }) => ({
22
22
  color: itemIconColor
23
23
  })
24
24
 
25
+ const selectCommonIconStyles = ({ iconMarginTop }) => ({
26
+ marginTop: iconMarginTop
27
+ })
28
+
25
29
  const selectSideItemContainerStyles = ({ listGutter }) => ({
26
30
  marginRight: listGutter
27
31
  })
@@ -58,24 +62,13 @@ const ListItem = forwardRef(
58
62
  const itemBulletContainerStyles = selectBulletContainerStyles(themeTokens)
59
63
  const itemBulletStyles = selectBulletStyles(themeTokens)
60
64
  const iconTokens = selectItemIconTokens(themeTokens)
65
+ const commonIconStyles = selectCommonIconStyles(themeTokens)
61
66
  const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens)
62
67
  const accessibilityRole = Platform.select({ web: 'listitem', default: 'item' })
63
68
 
64
- const areChildrenStrings = () => {
65
- if (Array.isArray(children)) {
66
- return children.every((child) => typeof child === 'string')
67
- }
68
-
69
- return typeof children === 'string'
70
- }
71
-
72
- const renderItem = () => {
73
- if (areChildrenStrings()) {
74
- return <Text style={itemStyles}>{children}</Text>
75
- }
76
-
77
- return <View style={staticStyles.wrap}>{children}</View>
78
- }
69
+ const renderItem = () => (
70
+ <View style={staticStyles.wrap}>{wrapStringsInText(children, { style: itemStyles })}</View>
71
+ )
79
72
 
80
73
  /**
81
74
  * Function responsible returning styling, in case the item is the last shouldn't
@@ -104,12 +97,7 @@ const ListItem = forwardRef(
104
97
 
105
98
  if (icon) {
106
99
  return (
107
- <View
108
- style={[
109
- sideItemContainerStyles,
110
- areChildrenStrings() ? staticStyles.centeredIcons : undefined
111
- ]}
112
- >
100
+ <View style={[sideItemContainerStyles, commonIconStyles]}>
113
101
  <IconComponent
114
102
  size={iconSize || iconTokens.size}
115
103
  color={iconColor || iconTokens.color}
@@ -143,9 +131,6 @@ const staticStyles = StyleSheet.create({
143
131
  itemContainer: {
144
132
  flexDirection: 'row'
145
133
  },
146
- centeredIcons: {
147
- justifyContent: 'center'
148
- },
149
134
  wrap: {
150
135
  flex: 1
151
136
  }
package/src/List/index.js CHANGED
@@ -1,3 +1,8 @@
1
1
  import List from './List'
2
+ import ListItem from './ListItem'
3
+
4
+ List.Item = ListItem
5
+
6
+ export { List as ListBase, ListItem }
2
7
 
3
8
  export default List