@telus-uds/components-base 1.2.0 → 1.3.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 (116) hide show
  1. package/.turbo/turbo-build.log +5 -0
  2. package/CHANGELOG.md +12 -0
  3. package/__tests__/FlexGrid/Col.test.jsx +6 -10
  4. package/__tests__/utils/props.test.js +36 -0
  5. package/__tests__/utils/semantics.test.jsx +1 -10
  6. package/component-docs.json +64 -53
  7. package/generate-component-docs.js +3 -0
  8. package/lib/A11yText/index.js +2 -2
  9. package/lib/ActivityIndicator/index.js +3 -3
  10. package/lib/Box/Box.js +4 -4
  11. package/lib/Button/Button.js +2 -2
  12. package/lib/Button/ButtonGroup.js +10 -12
  13. package/lib/Button/ButtonLink.js +4 -4
  14. package/lib/Button/propTypes.js +4 -2
  15. package/lib/Card/Card.js +2 -2
  16. package/lib/Card/CardBase.js +6 -9
  17. package/lib/Card/PressableCardBase.js +3 -3
  18. package/lib/Checkbox/Checkbox.js +3 -3
  19. package/lib/Divider/Divider.js +2 -2
  20. package/lib/FlexGrid/FlexGrid.js +4 -4
  21. package/lib/FlexGrid/helpers/index.js +1 -4
  22. package/lib/IconButton/IconButton.js +3 -3
  23. package/lib/Link/LinkBase.js +10 -10
  24. package/lib/List/List.js +3 -3
  25. package/lib/Progress/Progress.js +2 -2
  26. package/lib/Progress/ProgressBar.js +2 -2
  27. package/lib/Radio/Radio.js +3 -3
  28. package/lib/Spacer/Spacer.js +2 -2
  29. package/lib/StackView/getStackedContent.js +1 -1
  30. package/lib/StepTracker/StepTracker.js +2 -2
  31. package/lib/Tags/Tags.js +9 -9
  32. package/lib/ThemeProvider/useThemeTokens.js +3 -3
  33. package/lib/ThemeProvider/utils/theme-tokens.js +3 -3
  34. package/lib/ToggleSwitch/ToggleSwitch.js +6 -6
  35. package/lib/ToggleSwitch/ToggleSwitchGroup.js +8 -8
  36. package/lib/utils/a11y/semantics.js +4 -3
  37. package/lib/utils/index.js +4 -4
  38. package/lib/utils/pressability.js +2 -2
  39. package/lib/utils/props/a11yProps.js +153 -0
  40. package/lib/utils/props/clickProps.js +36 -0
  41. package/lib/utils/props/componentPropType.js +70 -0
  42. package/lib/utils/props/copyPropTypes.js +14 -0
  43. package/lib/utils/props/getPropSelector.js +13 -0
  44. package/lib/utils/props/hrefAttrsProp.js +41 -0
  45. package/lib/utils/props/index.js +149 -0
  46. package/lib/utils/props/linkProps.js +64 -0
  47. package/lib/utils/props/paddingProp.js +20 -0
  48. package/lib/utils/props/pressProps.js +57 -0
  49. package/lib/utils/props/rectProp.js +20 -0
  50. package/lib/utils/props/responsiveProps.js +40 -0
  51. package/lib/utils/props/selectSystemProps.js +31 -0
  52. package/lib/utils/props/spacingProps.js +71 -0
  53. package/lib/utils/props/tokens.js +145 -0
  54. package/lib/utils/props/variantProp.js +28 -0
  55. package/lib/utils/props/viewProps.js +34 -0
  56. package/lib/utils/useResponsiveProp.js +1 -1
  57. package/lib/utils/useSpacingScale.js +4 -4
  58. package/package.json +3 -3
  59. package/release-context.json +4 -4
  60. package/src/A11yText/index.jsx +1 -1
  61. package/src/ActivityIndicator/index.jsx +1 -1
  62. package/src/Box/Box.jsx +5 -4
  63. package/src/Button/Button.jsx +1 -1
  64. package/src/Button/ButtonGroup.jsx +17 -8
  65. package/src/Button/ButtonLink.jsx +1 -1
  66. package/src/Button/propTypes.js +2 -1
  67. package/src/Card/Card.jsx +1 -1
  68. package/src/Card/CardBase.jsx +6 -5
  69. package/src/Card/PressableCardBase.jsx +1 -1
  70. package/src/Checkbox/Checkbox.jsx +1 -1
  71. package/src/Divider/Divider.jsx +2 -2
  72. package/src/FlexGrid/FlexGrid.jsx +11 -5
  73. package/src/FlexGrid/helpers/index.js +1 -3
  74. package/src/IconButton/IconButton.jsx +1 -1
  75. package/src/Link/LinkBase.jsx +1 -1
  76. package/src/List/List.jsx +1 -1
  77. package/src/Progress/Progress.jsx +1 -1
  78. package/src/Progress/ProgressBar.jsx +1 -1
  79. package/src/Radio/Radio.jsx +1 -1
  80. package/src/Spacer/Spacer.jsx +2 -2
  81. package/src/StackView/getStackedContent.jsx +1 -1
  82. package/src/StepTracker/StepTracker.jsx +1 -1
  83. package/src/Tags/Tags.jsx +1 -7
  84. package/src/ThemeProvider/useThemeTokens.js +3 -3
  85. package/src/ThemeProvider/utils/theme-tokens.js +3 -3
  86. package/src/ToggleSwitch/ToggleSwitch.jsx +1 -7
  87. package/src/ToggleSwitch/ToggleSwitchGroup.jsx +1 -1
  88. package/src/utils/a11y/semantics.js +3 -2
  89. package/src/utils/index.js +1 -1
  90. package/src/utils/pressability.js +1 -1
  91. package/src/utils/props/a11yProps.js +151 -0
  92. package/src/utils/props/clickProps.js +31 -0
  93. package/src/utils/props/componentPropType.js +67 -0
  94. package/src/utils/props/copyPropTypes.js +3 -0
  95. package/src/utils/props/getPropSelector.js +14 -0
  96. package/src/utils/props/hrefAttrsProp.js +25 -0
  97. package/src/utils/props/index.js +15 -0
  98. package/src/utils/props/linkProps.js +43 -0
  99. package/src/utils/props/paddingProp.js +10 -0
  100. package/src/utils/props/pressProps.js +45 -0
  101. package/src/utils/props/rectProp.js +10 -0
  102. package/src/utils/props/responsiveProps.js +30 -0
  103. package/src/utils/props/selectSystemProps.js +25 -0
  104. package/src/utils/props/spacingProps.js +58 -0
  105. package/src/utils/props/tokens.js +150 -0
  106. package/src/utils/props/variantProp.js +20 -0
  107. package/src/utils/props/viewProps.js +23 -0
  108. package/src/utils/useResponsiveProp.js +1 -1
  109. package/src/utils/useSpacingScale.js +4 -4
  110. package/.ultra.cache.json +0 -1
  111. package/lib/utils/a11y/propTypes.js +0 -61
  112. package/lib/utils/a11y/propTypes.native.js +0 -47
  113. package/lib/utils/propTypes.js +0 -566
  114. package/src/utils/a11y/propTypes.js +0 -61
  115. package/src/utils/a11y/propTypes.native.js +0 -39
  116. package/src/utils/propTypes.js +0 -561
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getTokensSetPropType = exports.getTokensPropType = exports.selectTokens = exports.getTokenNames = void 0;
7
+
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+
10
+ var _systemThemeTokens = require("@telus-uds/system-theme-tokens");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ // Tokens can be primitive values (e.g. `'rgba(0,0,0,0'`, `12`), or objects of such values,
15
+ // such as tokens that describe shadow (e.g. shadow: { inset: true, color: 'rgba(...)' ... }),
16
+ // or components (e.g. Icon tokens)
17
+ const tokenValue = _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number, _propTypes.default.bool, _propTypes.default.elementType]);
18
+
19
+ const tokenValueType = _propTypes.default.oneOfType([tokenValue, _propTypes.default.objectOf(tokenValue)]);
20
+
21
+ const getTokenNames = componentName => {
22
+ const componentTokenSchema = _systemThemeTokens.components[componentName];
23
+
24
+ if (!componentTokenSchema) {
25
+ throw new Error(`No "${componentName}" tokenKeys in @telus-uds/system-theme-tokens`);
26
+ }
27
+
28
+ return Object.keys(componentTokenSchema);
29
+ };
30
+ /**
31
+ * Returns the subset of a set of tokens that may be accepted by the `tokens` prop of a named component
32
+ * or by a provided array of tokens. A prefix may be provided, for example:
33
+ *
34
+ * @example
35
+ * ```jsx
36
+ * // returns tokens from `themeTokens` that exist in the theme schema for `Button`.
37
+ * selectTokens('Button', themeTokens)
38
+ * ```
39
+ *
40
+ * @example
41
+ * ```jsx
42
+ * // returns `{ backgroundColor, width }` where the values of those keys come from
43
+ * // the source object's `{ containerBackgroundColor, containerWidth }` properties.
44
+ * selectTokens(['backgroundColor', 'width'], themeTokens, 'container')
45
+ * ```
46
+ *
47
+ * @example
48
+ * ```jsx
49
+ * // returns tokens that are defined in the `Button` theme schema, from tokens with
50
+ * // a prefix `'button'` e.g. a token `buttonBorderWidth` outputs as `borderWidth`.
51
+ * selectTokens('Button', themeTokens, 'button')
52
+ * ```
53
+ *
54
+ * @param {string[]|string} specifier - a name of a component in the theme schema, or an array of token names
55
+ * @param {object} tokens - a source object of theme tokens
56
+ * @param {string} [prefix] - if provided, matches keys in the source object with this as the first camelCase item
57
+ * @returns {object} - subset of theme tokens
58
+ */
59
+
60
+
61
+ exports.getTokenNames = getTokenNames;
62
+
63
+ const selectTokens = (specifier, tokens, prefix) => {
64
+ const tokenNames = typeof specifier === 'string' ? getTokenNames(specifier) : specifier;
65
+ const filteredTokens = tokenNames.reduce((validTokens, key) => {
66
+ const prefixedKey = prefix ? `${prefix}${key[0].toUpperCase()}${key.slice(1)}` : key;
67
+ const token = tokens[prefixedKey];
68
+ return token !== undefined ? { ...validTokens,
69
+ [key]: token
70
+ } : validTokens;
71
+ }, {});
72
+ return filteredTokens;
73
+ };
74
+ /**
75
+ * @typedef {string|number|boolean|{[key: string]:string|number|boolean}} TokenValue
76
+ * @typedef {{[key: string]: TokenValue}} TokensSet
77
+ * @typedef {(AppearanceSet) => TokensSet} TokensGetter
78
+ * @typedef {TokensSet|TokensGetter} TokensProp
79
+ */
80
+
81
+ /**
82
+ * 'tokens' is an optional object prop on all themable components. Its keys must match the
83
+ * token keys in the component's theme schema.
84
+ *
85
+ * This prop is intended to be used as an 'escape hatch' for difficult or exceptional cases
86
+ * where the main theming system doesn't apply. It is intentionally permissive about values.
87
+ *
88
+ * @param {...string} componentsNames - one or more ComponentName, which tokens keys are accepted
89
+ * @return {function} - a custom PropTypes validator
90
+ *
91
+ * @example
92
+ * Component.propTypes = {
93
+ * // accepts all tokens keys defined in Component schema
94
+ * tokens: getTokensPropType('Component')
95
+ * }
96
+ *
97
+ * Component.propTypes = {
98
+ * // accepts all tokens keys defined in schemas for Component1 and Component2
99
+ * tokens: getTokensPropType('Component1', 'Component2')
100
+ * }
101
+ */
102
+
103
+
104
+ exports.selectTokens = selectTokens;
105
+
106
+ const getTokensPropType = (...componentsNames) => (props, propName, componentName) => {
107
+ _propTypes.default.checkPropTypes({
108
+ [propName]: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.func])
109
+ }, props, propName, componentName);
110
+
111
+ if (typeof props[propName] !== 'function') {
112
+ _propTypes.default.checkPropTypes({
113
+ [propName]: _propTypes.default.exact(Object.fromEntries(componentsNames.flatMap(component => getTokenNames(component).map(key => [key, tokenValueType]))))
114
+ }, props, propName, componentName);
115
+ }
116
+ };
117
+ /**
118
+ * Get a proptypes validator for a set of tokens that is not based on a component in the theme schema.
119
+ *
120
+ * For example, for a set of tokens used in a common style, or for a set of tokens required by
121
+ * a themeless component whose tokens are set by a parent but requires tokens of a certain shape.
122
+ *
123
+ * By default, requires an object with a complete set of tokens (allowing `null`, but not `undefined`).
124
+ *
125
+ * @param {string[]} componentTokenKeys - array of strings of token names
126
+ * @param {object} [options]
127
+ * @param {boolean} [options.partial] - if true, allows tokens to be undefined
128
+ * @param {boolean} [options.allowFunction] - if true, allows functions as well as tokens objects
129
+ * @returns
130
+ */
131
+
132
+
133
+ exports.getTokensPropType = getTokensPropType;
134
+
135
+ const getTokensSetPropType = (componentTokenKeys, {
136
+ partial = false,
137
+ allowFunction = false
138
+ } = {}) => {
139
+ const tokensObjectValidator = _propTypes.default.exact(Object.fromEntries(componentTokenKeys.map(key => [key, partial ? tokenValueType : // Some theme tokens can validly resolve to `null`, but .isRequired treats null as undefined
140
+ (props, propName, ...args) => props[propName] !== null && tokenValueType.isRequired(props, propName, ...args)])));
141
+
142
+ return allowFunction ? _propTypes.default.oneOfType([tokensObjectValidator, _propTypes.default.func]) : tokensObjectValidator;
143
+ };
144
+
145
+ exports.getTokensSetPropType = getTokensSetPropType;
@@ -0,0 +1,28 @@
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
+ /**
13
+ * @typedef {{[key: string]: string|number|boolean}} AppearanceSet
14
+ * @typedef {AppearanceSet} VariantProp
15
+ */
16
+ var _default = {
17
+ /**
18
+ * 'variant' is an optional object prop on all themable components.
19
+ *
20
+ * Contains an object with keys that correspond to the current component theme's allowed
21
+ * appearances and values that correspond to the allowed values of that component.
22
+ *
23
+ * Since the particular keys and values depend on which theme is currently active,
24
+ * the exact shape of variant props is not enforced using PropTypes.
25
+ */
26
+ propType: _propTypes.default.objectOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number, _propTypes.default.bool]))
27
+ };
28
+ exports.default = _default;
@@ -0,0 +1,34 @@
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 _getPropSelector = _interopRequireDefault(require("./getPropSelector"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ const viewPropTypes = {
15
+ pointerEvents: _propTypes.default.oneOf(['all', 'none', 'box-only', 'box-none']),
16
+ onLayout: _propTypes.default.func,
17
+ nativeID: _propTypes.default.string,
18
+ testID: _propTypes.default.string,
19
+ dataSet: _propTypes.default.object
20
+ };
21
+ var _default = {
22
+ /**
23
+ * Subset of `View` proptypes that could conceivably be needed on any component
24
+ * that renders a single View.
25
+ */
26
+ types: viewPropTypes,
27
+
28
+ /**
29
+ * Filters a props object, returning only cross-platform View props that are potentially
30
+ * relevant to any basic layout component that renders one View.
31
+ */
32
+ select: (0, _getPropSelector.default)(viewPropTypes)
33
+ };
34
+ exports.default = _default;
@@ -40,7 +40,7 @@ const resolveResponsiveProp = (prop, viewport, defaultValue) => {
40
40
  * For example, if passed `{ sm: 4, lg: 8 }`, it will return 8 on `xl` and `lg` viewports,
41
41
  * 4 on `md` and `sm` viewports, and `undefined` (or a provided `defaultValue`) on `xs` viewports.
42
42
  *
43
- * To generate propTypes for responsive props, see `responsiveProps` in `./utils/propTypes.js`.
43
+ * To generate propTypes for responsive props, see `responsiveProps` in `./utils/props/responsiveProps.js`.
44
44
  *
45
45
  * @param {*} prop - any value which may be an object with viewport keys
46
46
  * @param {*} [defaultValue] - default value to provide if no matches found for the current viewport
@@ -13,10 +13,10 @@ var _useResponsiveProp = require("./useResponsiveProp");
13
13
 
14
14
  /**
15
15
  * @typedef {import('@telus-uds/system-constants/viewports').Viewport} Viewport
16
- * @typedef {import('./propTypes.js').SpacingValue} SpacingValue
17
- * @typedef {import('./propTypes.js').SpacingIndex} SpacingIndex
18
- * @typedef {import('./propTypes.js').SpacingObject} SpacingObject
19
- * @typedef {import('./propTypes.js').SpacingOptions} SpacingOptions
16
+ * @typedef {import('./props/spacingProps.js').SpacingValue} SpacingValue
17
+ * @typedef {import('./props/spacingProps.js').SpacingIndex} SpacingIndex
18
+ * @typedef {import('./props/spacingProps.js').SpacingObject} SpacingObject
19
+ * @typedef {import('./props/spacingProps.js').SpacingOptions} SpacingOptions
20
20
  */
21
21
  const resolveSpacingOptions = space => {
22
22
  if (!(space !== null && space !== void 0 && space.options)) return {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telus-uds/components-base",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Base components",
5
5
  "keywords": [
6
6
  "base"
@@ -54,8 +54,8 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "airbnb-prop-types": "^2.16.0",
57
- "@telus-uds/system-constants": "^1.0.1-prerelease.0",
58
- "@telus-uds/system-theme-tokens": "^1.2.0",
57
+ "@telus-uds/system-constants": "^1.0.1",
58
+ "@telus-uds/system-theme-tokens": "^1.2.1",
59
59
  "lodash.debounce": "^4.0.8",
60
60
  "lodash.merge": "^4.6.2",
61
61
  "prop-types": "^15.7.2",
@@ -1,7 +1,7 @@
1
1
  {
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",
2
+ "previousReleaseTag": "@telus-uds/components-base/v1.2.0",
3
+ "changelog": "## [1.3.0](https://github.com/telus/universal-design-system/compare/@telus-uds/components-base/v1.2.0...@telus-uds/components-base/v1.3.0) (2022-03-21)\n\n\n### Features\n\n* **components-base:** add common system props handler and restructure props-related utils ([#1444](https://github.com/telus/universal-design-system/issues/1444)) ([ab655ec](https://github.com/telus/universal-design-system/commit/ab655ec61796b6a6d7094c2c42ceef8b5197c634))\n* **docs:** add tokens override documentation ([#1330](https://github.com/telus/universal-design-system/issues/1330)) ([49092e5](https://github.com/telus/universal-design-system/commit/49092e5d5f6c2d3a85de930a74a03afff8a60062))\n\n\n### Bug Fixes\n\n* **base:** inherit FlexGrid.Col responsive size if 0 ([#1419](https://github.com/telus/universal-design-system/issues/1419)) ([9defeb0](https://github.com/telus/universal-design-system/commit/9defeb0da08099afb83df9e7ee902f037cb4de02))\n* **ds-allium:** fix some errors in RN builds ([#1448](https://github.com/telus/universal-design-system/issues/1448)) ([8bc4778](https://github.com/telus/universal-design-system/commit/8bc477890f0183584fdc1009d7929b71d23820a3))\n",
4
+ "releaseTag": "@telus-uds/components-base/v1.3.0",
5
+ "newVersion": "1.3.0",
6
6
  "packageName": "@telus-uds/components-base"
7
7
  }
@@ -2,7 +2,7 @@ import React, { forwardRef } from 'react'
2
2
  import { Platform, StyleSheet, View } from 'react-native'
3
3
  import PropTypes from 'prop-types'
4
4
 
5
- import { a11yProps } from '../utils/propTypes'
5
+ import { a11yProps } from '../utils/props'
6
6
 
7
7
  /**
8
8
  * A11yText is a zero-size invisible element that adds text to be read by screen readers.
@@ -1,7 +1,7 @@
1
1
  import React from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import { useThemeTokens } from '../ThemeProvider'
4
- import { getTokensPropType, variantProp } from '../utils/propTypes'
4
+ import { getTokensPropType, variantProp } from '../utils/props'
5
5
 
6
6
  import Spinner from './Spinner'
7
7
 
package/src/Box/Box.jsx CHANGED
@@ -12,11 +12,12 @@ import {
12
12
  getA11yPropsFromHtmlTag,
13
13
  layoutTags
14
14
  } from '../utils'
15
+
15
16
  /**
16
- * @typedef {import('../utils/propTypes.js').SpacingValue} SpacingValue
17
- * @typedef {import('../utils/propTypes.js').SpacingIndex} SpacingIndex
18
- * @typedef {import('../utils/propTypes.js').SpacingObject} SpacingObject
19
- * @typedef {import('../utils/propTypes.js').SpacingOptions} SpacingOptions
17
+ * @typedef {import('../utils/props/spacingProps.js').SpacingValue} SpacingValue
18
+ * @typedef {import('../utils/props/spacingProps.js').SpacingIndex} SpacingIndex
19
+ * @typedef {import('../utils/props/spacingProps.js').SpacingObject} SpacingObject
20
+ * @typedef {import('../utils/props/spacingProps.js').SpacingOptions} SpacingOptions
20
21
  */
21
22
 
22
23
  const selectBoxStyles = (tokens) => {
@@ -3,7 +3,7 @@ import React, { forwardRef } from 'react'
3
3
  import ButtonBase from './ButtonBase'
4
4
  import buttonPropTypes, { textAndA11yText } from './propTypes'
5
5
  import { useThemeTokensCallback } from '../ThemeProvider'
6
- import { a11yProps } from '../utils/propTypes'
6
+ import { a11yProps } from '../utils/props'
7
7
 
8
8
  const Button = forwardRef(({ accessibilityRole = 'button', tokens, variant, ...props }, ref) => {
9
9
  const getTokens = useThemeTokensCallback('Button', tokens, variant)
@@ -10,13 +10,17 @@ import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider'
10
10
  import {
11
11
  a11yProps,
12
12
  pressProps,
13
- variantProp,
14
13
  getTokensPropType,
15
- selectTokens
16
- } from '../utils/propTypes'
14
+ selectSystemProps,
15
+ selectTokens,
16
+ variantProp,
17
+ viewProps
18
+ } from '../utils/props'
17
19
  import { useMultipleInputValues } from '../utils/input'
18
20
  import { getPressHandlersWithArgs } from '../utils/pressability'
19
21
 
22
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, pressProps, viewProps])
23
+
20
24
  const ButtonGroup = forwardRef(
21
25
  (
22
26
  {
@@ -51,14 +55,20 @@ const ButtonGroup = forwardRef(
51
55
  readOnly
52
56
  })
53
57
 
54
- const a11y = a11yProps.select({
58
+ const systemProps = selectProps({
55
59
  accessibilityRole,
56
60
  ...rest
57
61
  })
58
- const itemA11yRole = a11y.accessibilityRole === 'radiogroup' ? 'radio' : 'checkbox'
62
+ const itemA11yRole = systemProps.accessibilityRole === 'radiogroup' ? 'radio' : 'checkbox'
59
63
 
60
64
  return (
61
- <StackWrap {...a11y} space={space} direction={direction} tokens={stackTokens} ref={ref}>
65
+ <StackWrap
66
+ {...systemProps}
67
+ space={space}
68
+ direction={direction}
69
+ tokens={stackTokens}
70
+ ref={ref}
71
+ >
62
72
  {items.map(({ label, id = label, accessibilityLabel, ref: itemRef }, index) => {
63
73
  const isSelected = currentValues.includes(id)
64
74
 
@@ -101,8 +111,7 @@ const ButtonGroup = forwardRef(
101
111
  ButtonGroup.displayName = 'ButtonGroup'
102
112
 
103
113
  ButtonGroup.propTypes = {
104
- ...a11yProps.propTypes,
105
- ...pressProps.propTypes,
114
+ ...selectedSystemPropTypes,
106
115
  tokens: getTokensPropType('ButtonGroup'),
107
116
  variant: variantProp.propType,
108
117
  /**
@@ -1,7 +1,7 @@
1
1
  import React, { forwardRef } from 'react'
2
2
  import ButtonBase from './ButtonBase'
3
3
  import buttonPropTypes, { textAndA11yText } from './propTypes'
4
- import { a11yProps, hrefAttrsProp, linkProps } from '../utils/propTypes'
4
+ import { a11yProps, hrefAttrsProp, linkProps } from '../utils/props'
5
5
  import { useThemeTokensCallback } from '../ThemeProvider'
6
6
 
7
7
  /**
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types'
2
2
  import ABBPropTypes from 'airbnb-prop-types'
3
- import { variantProp } from '../utils/propTypes'
3
+ import { variantProp, getTokensPropType } from '../utils/props'
4
4
  import A11yText from '../A11yText'
5
5
 
6
6
  export const textAndA11yText = ABBPropTypes.childrenOf(
@@ -8,6 +8,7 @@ export const textAndA11yText = ABBPropTypes.childrenOf(
8
8
  )
9
9
 
10
10
  const buttonPropTypes = {
11
+ tokens: getTokensPropType('Button'),
11
12
  /**
12
13
  * If true, prevents the button from being pressed, changes the cursor (on web) and accessibility
13
14
  * attributes to communicate this to the user, and applies `inactive: true` appearances from the theme
package/src/Card/Card.jsx CHANGED
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
4
4
  import { useThemeTokens } from '../ThemeProvider'
5
5
  import { getTokensPropType, variantProp } from '../utils'
6
6
  import { useViewport } from '../ViewportProvider'
7
- import { a11yProps } from '../utils/propTypes'
7
+ import { a11yProps } from '../utils/props'
8
8
  import CardBase from './CardBase'
9
9
 
10
10
  /**
@@ -4,7 +4,9 @@ import { View } from 'react-native'
4
4
 
5
5
  import { applyShadowToken } from '../ThemeProvider'
6
6
  import { getTokensPropType } from '../utils'
7
- import { a11yProps, viewProps } from '../utils/propTypes'
7
+ import { a11yProps, viewProps, selectSystemProps } from '../utils/props'
8
+
9
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
8
10
 
9
11
  // Ensure explicit selection of tokens
10
12
  const selectStyles = ({
@@ -39,7 +41,7 @@ const selectStyles = ({
39
41
  */
40
42
  const CardBase = forwardRef(({ children, tokens, dataSet, ...rest }, ref) => {
41
43
  const cardStyle = selectStyles(typeof tokens === 'function' ? tokens() : tokens)
42
- const props = { ...a11yProps.select(rest), ...viewProps.select(rest) }
44
+ const props = selectProps(rest)
43
45
 
44
46
  return (
45
47
  <View style={cardStyle} dataSet={dataSet} ref={ref} {...props}>
@@ -50,10 +52,9 @@ const CardBase = forwardRef(({ children, tokens, dataSet, ...rest }, ref) => {
50
52
  CardBase.displayName = 'CardBase'
51
53
 
52
54
  CardBase.propTypes = {
55
+ ...selectedSystemPropTypes,
53
56
  children: PropTypes.node,
54
- tokens: getTokensPropType('Card'),
55
- ...viewProps.types,
56
- ...a11yProps.types
57
+ tokens: getTokensPropType('Card')
57
58
  }
58
59
 
59
60
  export default CardBase
@@ -15,7 +15,7 @@ import {
15
15
  clickProps,
16
16
  withLinkRouter
17
17
  } from '../utils'
18
- import { a11yProps } from '../utils/propTypes'
18
+ import { a11yProps } from '../utils/props'
19
19
  import CardBase from './CardBase'
20
20
 
21
21
  const tokenKeys = [
@@ -8,7 +8,7 @@ import Feedback from '../Feedback'
8
8
  import StackView from '../StackView'
9
9
  import { applyShadowToken, applyTextStyles, useThemeTokensCallback } from '../ThemeProvider'
10
10
  import { getTokensPropType, useInputValue, variantProp } from '../utils'
11
- import { a11yProps } from '../utils/propTypes'
11
+ import { a11yProps } from '../utils/props'
12
12
  import useUniqueId from '../utils/useUniqueId'
13
13
 
14
14
  const selectInputStyles = (
@@ -5,8 +5,8 @@ import { useThemeTokens } from '../ThemeProvider'
5
5
  import Spacer from '../Spacer'
6
6
  import { getTokensPropType, variantProp, spacingProps } from '../utils'
7
7
  /**
8
- * @typedef {import('../utils/propTypes.js').SpacingIndex} SpacingIndex
9
- * @typedef {import('../utils/propTypes.js').SpacingObject} SpacingObject
8
+ * @typedef {import('../utils/props/spacingProps.js').SpacingIndex} SpacingIndex
9
+ * @typedef {import('../utils/props/spacingProps.js').SpacingObject} SpacingObject
10
10
  */
11
11
 
12
12
  /**
@@ -8,7 +8,15 @@ import Col from './Col'
8
8
  import { useViewport } from '../ViewportProvider'
9
9
  import GutterContext from './providers/GutterContext'
10
10
  import applyInheritance from './helpers'
11
- import { a11yProps, viewProps, getA11yPropsFromHtmlTag, layoutTags } from '../utils'
11
+ import {
12
+ a11yProps,
13
+ viewProps,
14
+ getA11yPropsFromHtmlTag,
15
+ layoutTags,
16
+ selectSystemProps
17
+ } from '../utils'
18
+
19
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
12
20
 
13
21
  /**
14
22
  * A mobile-first flexbox grid.
@@ -62,8 +70,7 @@ const FlexGrid = forwardRef(
62
70
 
63
71
  const props = {
64
72
  ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
65
- ...a11yProps.select(rest),
66
- ...viewProps.select(rest)
73
+ ...selectProps(rest)
67
74
  }
68
75
 
69
76
  return (
@@ -91,8 +98,7 @@ const styles = StyleSheet.create({
91
98
  })
92
99
 
93
100
  FlexGrid.propTypes = {
94
- ...a11yProps.propTypes,
95
- ...viewProps.types,
101
+ ...selectedSystemPropTypes,
96
102
  /**
97
103
  * Whether or not to give the grid a fixed width. This also centres the grid horizontally.
98
104
  */
@@ -1,10 +1,8 @@
1
1
  const applyInheritance = (sizes) => {
2
2
  let prevSize
3
3
  return sizes.map((size, index) => {
4
- if (size) {
5
- prevSize = size
6
- }
7
4
  if (size !== undefined) {
5
+ prevSize = size
8
6
  return size
9
7
  }
10
8
  if (index) {
@@ -13,7 +13,7 @@ import {
13
13
  selectTokens,
14
14
  withLinkRouter
15
15
  } from '../utils'
16
- import { a11yProps } from '../utils/propTypes'
16
+ import { a11yProps } from '../utils/props'
17
17
  import Icon from '../Icon'
18
18
 
19
19
  const selectOuterStyle = ({
@@ -8,7 +8,7 @@ import {
8
8
  linkProps,
9
9
  getTokensPropType,
10
10
  clickProps
11
- } from '../utils/propTypes'
11
+ } from '../utils/props'
12
12
  import { resolvePressableTokens } from '../utils/pressability'
13
13
  import { withLinkRouter } from '../utils'
14
14
 
package/src/List/List.jsx CHANGED
@@ -2,7 +2,7 @@ import React, { cloneElement, forwardRef, Children } from 'react'
2
2
  import { View, Platform } from 'react-native'
3
3
  import PropTypes from 'prop-types'
4
4
  import { getTokensPropType, variantProp, componentPropType } from '../utils'
5
- import { a11yProps } from '../utils/propTypes'
5
+ import { a11yProps } from '../utils/props'
6
6
  import ListItem from './ListItem'
7
7
 
8
8
  /**
@@ -2,7 +2,7 @@ import React, { forwardRef } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import { View } from 'react-native'
4
4
 
5
- import { a11yProps } from '../utils/propTypes'
5
+ import { a11yProps } from '../utils/props'
6
6
  import { useThemeTokens } from '../ThemeProvider'
7
7
  import { getTokensPropType, variantProp } from '../utils'
8
8
 
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
3
3
  import { Platform, StyleSheet, View } from 'react-native'
4
4
 
5
5
  import ProgressBarBackground from './ProgressBarBackground'
6
- import { a11yProps } from '../utils/propTypes'
6
+ import { a11yProps } from '../utils/props'
7
7
  import { useThemeTokens } from '../ThemeProvider'
8
8
  import { getTokensPropType, variantProp } from '../utils'
9
9
 
@@ -6,7 +6,7 @@ import RadioLabel from '../InputLabel/LabelContent'
6
6
  import RadioButton, { selectRadioButtonTokens } from './RadioButton'
7
7
  import { applyShadowToken, applyTextStyles, useThemeTokensCallback } from '../ThemeProvider'
8
8
  import { getTokensPropType, useInputValue, useUniqueId, variantProp } from '../utils'
9
- import { a11yProps } from '../utils/propTypes'
9
+ import { a11yProps } from '../utils/props'
10
10
  import StackView from '../StackView'
11
11
 
12
12
  const selectContainerStyles = ({
@@ -4,8 +4,8 @@ import { StyleSheet, View } from 'react-native'
4
4
 
5
5
  import { useSpacingScale, spacingProps } from '../utils'
6
6
  /**
7
- * @typedef {import('../utils/propTypes.js').SpacingValue} SpacingValue
8
- * @typedef {import('../utils/propTypes.js').SpacingObject} SpacingObject
7
+ * @typedef {import('../utils/props/spacingProps.js').SpacingValue} SpacingValue
8
+ * @typedef {import('../utils/props/spacingProps.js').SpacingObject} SpacingObject
9
9
  */
10
10
 
11
11
  const selectSizeStyle = (size, direction) => ({
@@ -7,7 +7,7 @@ import Spacer from '../Spacer'
7
7
  /**
8
8
  * @typedef {import('react').ReactChildren} ReactChildren
9
9
  * @typedef {import('react').ReactElement} ReactElement
10
- * @typedef {import('../utils/propTypes.js').SpacingValue} SpacingValue
10
+ * @typedef {import('../utils/props/spacingProps.js').SpacingValue} SpacingValue
11
11
  */
12
12
 
13
13
  /**
@@ -5,7 +5,7 @@ import { StyleSheet, Text, View } from 'react-native'
5
5
  import StackView from '../StackView'
6
6
  import { applyTextStyles, useThemeTokens } from '../ThemeProvider'
7
7
  import { getTokensPropType, variantProp } from '../utils'
8
- import { a11yProps } from '../utils/propTypes'
8
+ import { a11yProps } from '../utils/props'
9
9
  import { useViewport } from '../ViewportProvider'
10
10
  import useCopy from '../utils/useCopy'
11
11
 
package/src/Tags/Tags.jsx CHANGED
@@ -8,13 +8,7 @@ import Icon from '../Icon'
8
8
  import { StackWrap, getStackedContent } from '../StackView'
9
9
  import { useViewport } from '../ViewportProvider'
10
10
  import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider'
11
- import {
12
- a11yProps,
13
- pressProps,
14
- variantProp,
15
- getTokensPropType,
16
- selectTokens
17
- } from '../utils/propTypes'
11
+ import { a11yProps, pressProps, variantProp, getTokensPropType, selectTokens } from '../utils/props'
18
12
  import { useMultipleInputValues } from '../utils/input'
19
13
  import { getPressHandlersWithArgs } from '../utils/pressability'
20
14