@telus-uds/components-base 1.0.1 → 1.1.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 (74) 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 +12 -0
  5. package/README.md +1 -1
  6. package/babel.config.js +9 -16
  7. package/component-docs.json +10313 -0
  8. package/generate-component-docs.js +56 -0
  9. package/lib/List/List.js +1 -2
  10. package/lib/List/ListItem.js +14 -27
  11. package/lib/List/index.js +15 -0
  12. package/lib/Pagination/PageButton.js +1 -7
  13. package/lib/StackView/StackWrap.js +9 -5
  14. package/lib/index.js +15 -1
  15. package/lib/utils/a11y/propTypes.js +61 -0
  16. package/lib/utils/a11y/propTypes.native.js +47 -0
  17. package/lib/utils/propTypes.js +7 -89
  18. package/package.json +9 -5
  19. package/release-context.json +4 -4
  20. package/src/List/List.jsx +1 -3
  21. package/src/List/ListItem.jsx +11 -26
  22. package/src/List/index.js +5 -0
  23. package/src/Pagination/PageButton.jsx +2 -6
  24. package/src/StackView/StackWrap.jsx +7 -6
  25. package/src/index.js +1 -1
  26. package/src/utils/a11y/propTypes.js +61 -0
  27. package/src/utils/a11y/propTypes.native.js +39 -0
  28. package/src/utils/propTypes.js +1 -110
  29. package/stories/A11yText/A11yText.stories.jsx +1 -1
  30. package/stories/ActivityIndicator/ActivityIndicator.stories.jsx +1 -1
  31. package/stories/Box/Box.stories.jsx +1 -1
  32. package/stories/Button/Button.stories.jsx +1 -1
  33. package/stories/Button/ButtonGroup.stories.jsx +1 -1
  34. package/stories/Button/ButtonLink.stories.jsx +1 -1
  35. package/stories/Card/Card.stories.jsx +1 -1
  36. package/stories/Checkbox/Checkbox.stories.jsx +1 -1
  37. package/stories/Divider/Divider.stories.jsx +1 -1
  38. package/stories/ExpandCollapse/ExpandCollapse.stories.jsx +1 -1
  39. package/stories/Feedback/Feedback.stories.jsx +1 -1
  40. package/stories/FlexGrid/01 FlexGrid.stories.jsx +1 -1
  41. package/stories/FlexGrid/02 Row.stories.jsx +1 -1
  42. package/stories/FlexGrid/03 Col.stories.jsx +1 -1
  43. package/stories/Icon/Icon.stories.jsx +1 -1
  44. package/stories/IconButton/IconButton.stories.jsx +1 -1
  45. package/stories/InputLabel/InputLabel.stories.jsx +1 -1
  46. package/stories/Link/ChevronLink.stories.jsx +1 -1
  47. package/stories/Link/Link.stories.jsx +1 -1
  48. package/stories/Link/TextButton.stories.jsx +1 -1
  49. package/stories/List/List.stories.jsx +1 -1
  50. package/stories/Modal/Modal.stories.jsx +1 -1
  51. package/stories/Notification/Notification.stories.jsx +1 -1
  52. package/stories/Pagination/Pagination.stories.jsx +1 -1
  53. package/stories/Progress/Progress.stories.jsx +1 -1
  54. package/stories/Radio/Radio.stories.jsx +1 -1
  55. package/stories/RadioCard/RadioCard.stories.jsx +1 -1
  56. package/stories/Search/Search.stories.jsx +1 -1
  57. package/stories/Select/Select.stories.jsx +1 -1
  58. package/stories/SideNav/SideNav.stories.jsx +1 -1
  59. package/stories/SideNav/SideNavItem.stories.jsx +1 -1
  60. package/stories/SideNav/SideNavItemsGroup.stories.jsx +1 -1
  61. package/stories/Skeleton/Skeleton.stories.jsx +1 -1
  62. package/stories/Spacer/Spacer.stories.jsx +1 -1
  63. package/stories/StackView/StackView.stories.jsx +1 -1
  64. package/stories/StackView/StackWrap.stories.jsx +1 -1
  65. package/stories/StepTracker/StepTracker.stories.jsx +1 -1
  66. package/stories/Tabs/Tabs.stories.jsx +1 -1
  67. package/stories/Tags/Tags.stories.jsx +1 -1
  68. package/stories/TextInput/TextArea.stories.jsx +1 -1
  69. package/stories/TextInput/TextInput.stories.jsx +1 -1
  70. package/stories/ToggleSwitch/ToggleSwitch.stories.jsx +1 -1
  71. package/stories/Tooltip/Tooltip.stories.jsx +1 -1
  72. package/stories/TooltipButton/TooltipButton.stories.jsx +1 -1
  73. package/stories/Typography/Typography.stories.jsx +1 -1
  74. 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/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,13 +78,7 @@ 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,
@@ -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.
package/lib/index.js CHANGED
@@ -21,6 +21,8 @@ var _exportNames = {
21
21
  IconButton: true,
22
22
  InputLabel: true,
23
23
  List: true,
24
+ ListItem: true,
25
+ ListBase: true,
24
26
  Modal: true,
25
27
  Notification: true,
26
28
  Pagination: true,
@@ -153,6 +155,18 @@ Object.defineProperty(exports, "List", {
153
155
  return _List.default;
154
156
  }
155
157
  });
158
+ Object.defineProperty(exports, "ListItem", {
159
+ enumerable: true,
160
+ get: function () {
161
+ return _List.ListItem;
162
+ }
163
+ });
164
+ Object.defineProperty(exports, "ListBase", {
165
+ enumerable: true,
166
+ get: function () {
167
+ return _List.ListBase;
168
+ }
169
+ });
156
170
  Object.defineProperty(exports, "Modal", {
157
171
  enumerable: true,
158
172
  get: function () {
@@ -420,7 +434,7 @@ Object.keys(_Link).forEach(function (key) {
420
434
  });
421
435
  });
422
436
 
423
- var _List = _interopRequireDefault(require("./List"));
437
+ var _List = _interopRequireWildcard(require("./List"));
424
438
 
425
439
  var _Modal = _interopRequireDefault(require("./Modal"));
426
440
 
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+
10
+ var _propTypes2 = _interopRequireDefault(require("./propTypes.native"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ var _default = { ..._propTypes2.default,
15
+ // React Native Web adds many a11y props that alias aria-* attributes
16
+ // Types based on https://necolas.github.io/react-native-web/docs/accessibility/
17
+ accessibilityActiveDescendant: _propTypes.default.string,
18
+ accessibilityAtomic: _propTypes.default.bool,
19
+ accessibilityAutoComplete: _propTypes.default.string,
20
+ accessibilityBusy: _propTypes.default.bool,
21
+ accessibilityChecked: _propTypes.default.oneOf([true, false, 'mixed']),
22
+ accessibilityColumnCount: _propTypes.default.number,
23
+ accessibilityColumnIndex: _propTypes.default.number,
24
+ accessibilityColumnSpan: _propTypes.default.number,
25
+ accessibilityControls: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
26
+ accessibilityCurrent: _propTypes.default.oneOf([true, false, 'page', 'step', 'location', 'date', 'time']),
27
+ accessibilityDescribedBy: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
28
+ accessibilityDetails: _propTypes.default.string,
29
+ accessibilityDisabled: _propTypes.default.bool,
30
+ accessibilityErrorMessage: _propTypes.default.string,
31
+ accessibilityExpanded: _propTypes.default.bool,
32
+ accessibilityFlowTo: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
33
+ accessibilityHasPopup: _propTypes.default.string,
34
+ accessibilityHidden: _propTypes.default.bool,
35
+ accessibilityInvalid: _propTypes.default.bool,
36
+ accessibilityKeyShortcuts: _propTypes.default.string,
37
+ accessibilityLabelledBy: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
38
+ accessibilityLevel: _propTypes.default.number,
39
+ accessibilityModal: _propTypes.default.bool,
40
+ accessibilityMultiline: _propTypes.default.bool,
41
+ accessibilityMultiSelectable: _propTypes.default.bool,
42
+ accessibilityOrientation: _propTypes.default.oneOf(['horizontal', 'vertical']),
43
+ accessibilityOwns: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
44
+ accessibilityPlaceholder: _propTypes.default.string,
45
+ accessibilityPosInSet: _propTypes.default.number,
46
+ accessibilityPressed: _propTypes.default.bool,
47
+ accessibilityReadOnly: _propTypes.default.bool,
48
+ accessibilityRequired: _propTypes.default.bool,
49
+ accessibilityRoleDescription: _propTypes.default.string,
50
+ accessibilityRowCount: _propTypes.default.number,
51
+ accessibilityRowIndex: _propTypes.default.number,
52
+ accessibilityRowSpan: _propTypes.default.number,
53
+ accessibilitySelected: _propTypes.default.bool,
54
+ accessibilitySetSize: _propTypes.default.number,
55
+ accessibilitySort: _propTypes.default.oneOf(['ascending', 'descending', 'none', 'other']),
56
+ accessibilityValueMax: _propTypes.default.number,
57
+ accessibilityValueMin: _propTypes.default.number,
58
+ accessibilityValueNow: _propTypes.default.number,
59
+ accessibilityValueText: _propTypes.default.string
60
+ };
61
+ exports.default = _default;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ // React Native exports a11y prop definitions as TypeScript Interfaces, but no longer exports PropTypes
13
+ // so we have to define them ourselves.
14
+ var _default = {
15
+ accessible: _propTypes.default.bool,
16
+ focusable: _propTypes.default.bool,
17
+ accessibilityElementsHidden: _propTypes.default.bool,
18
+ accessibilityHint: _propTypes.default.string,
19
+ // react-native-web ignores `accessibilityHint`
20
+ accessibilityIgnoresInvertColors: _propTypes.default.bool,
21
+ accessibilityLabel: _propTypes.default.string,
22
+ accessibilityRole: _propTypes.default.string,
23
+ accessibilityActions: _propTypes.default.arrayOf(_propTypes.default.shape({
24
+ name: _propTypes.default.string.isRequired,
25
+ label: _propTypes.default.string
26
+ })),
27
+ accessibilityLiveRegion: _propTypes.default.oneOf(['none', 'polite', 'assertive']),
28
+ accessibilityState: _propTypes.default.shape({
29
+ disabled: _propTypes.default.bool,
30
+ selected: _propTypes.default.bool,
31
+ checked: _propTypes.default.oneOf([true, false, 'mixed']),
32
+ busy: _propTypes.default.bool,
33
+ expanded: _propTypes.default.bool
34
+ }),
35
+ accessibilityValue: _propTypes.default.shape({
36
+ min: _propTypes.default.number,
37
+ max: _propTypes.default.number,
38
+ now: _propTypes.default.number,
39
+ text: _propTypes.default.string
40
+ }),
41
+ accessibilityViewIsModal: _propTypes.default.bool,
42
+ importantForAccessibility: _propTypes.default.oneOf(['auto', 'yes', 'no', 'no-hide-descendants']),
43
+ onAccessibilityAction: _propTypes.default.func,
44
+ onAccessibilityEscape: _propTypes.default.func,
45
+ onAccessibilityTap: _propTypes.default.func
46
+ };
47
+ exports.default = _default;
@@ -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.
@@ -404,7 +322,7 @@ exports.pressProps = pressProps;
404
322
  const linkPropTypes = { ...pressPropTypes,
405
323
  href: _propTypes.default.string,
406
324
  hrefAttrs: _propTypes.default.shape(hrefAttrsProp.types),
407
- ...a11yPropTypes
325
+ ..._propTypes2.default
408
326
  };
409
327
  const linkProps = {
410
328
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telus-uds/components-base",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Base components",
5
5
  "keywords": [
6
6
  "base"
@@ -23,8 +23,11 @@
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",
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",
28
31
  "release": "standard-version"
29
32
  },
30
33
  "bugs": {
@@ -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.1.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/v1.0.0",
3
- "changelog": "### [1.0.1](https://github.com/telus/universal-design-system/compare/@telus-uds/components-base/v1.0.0...@telus-uds/components-base/v1.0.1) (2022-02-07)\n\n\n### Bug Fixes\n\n* **base:** add dataSet to FlexGrid (via viewProps) ([#1276](https://github.com/telus/universal-design-system/issues/1276)) ([dea06a1](https://github.com/telus/universal-design-system/commit/dea06a1393bd78147b0eebfde10f4d3365b518b4))\n",
4
- "releaseTag": "@telus-uds/components-base/v1.0.1",
5
- "newVersion": "1.0.1",
2
+ "previousReleaseTag": "@telus-uds/components-base/v1.0.1",
3
+ "changelog": "## [1.1.0](https://github.com/telus/universal-design-system/compare/@telus-uds/components-base/v1.0.1...@telus-uds/components-base/v1.1.0) (2022-02-28)\n\n\n### Features\n\n* **component-base:** add some fixes to the list component ([#1226](https://github.com/telus/universal-design-system/issues/1226)) ([35a42e0](https://github.com/telus/universal-design-system/commit/35a42e05e23630696286e7c8607e7a1e8da9d6c2))\n* **ds-allium:** add an Allium List ([#1304](https://github.com/telus/universal-design-system/issues/1304)) ([2f91c74](https://github.com/telus/universal-design-system/commit/2f91c74d6c0b30f09089e8f11beb3739e5be1887))\n* generate component docs ([#1292](https://github.com/telus/universal-design-system/issues/1292)) ([e0c03a5](https://github.com/telus/universal-design-system/commit/e0c03a5c4b5186e97d424c5b1c4594b1dda8201f))\n\n\n### Bug Fixes\n\n* **base:** no SSR crash on transpiled global CSS ([#1311](https://github.com/telus/universal-design-system/issues/1311)) ([7bc585c](https://github.com/telus/universal-design-system/commit/7bc585cc76bf7d760b1630a6f90f336f2be2abda))\n",
4
+ "releaseTag": "@telus-uds/components-base/v1.1.0",
5
+ "newVersion": "1.1.0",
6
6
  "packageName": "@telus-uds/components-base"
7
7
  }
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
  }