@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,5 @@
1
+ @telus-uds/components-base:build: cache hit, replaying output 00426a473859b487
2
+ @telus-uds/components-base:build: $ yarn build:code && yarn build:docs
3
+ @telus-uds/components-base:build: $ babel src -d lib
4
+ @telus-uds/components-base:build: Successfully compiled 214 files with Babel (15991ms).
5
+ @telus-uds/components-base:build: $ babel-node --plugins=react-docgen-alpha generate-component-docs.js
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [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)
6
+
7
+ ### Features
8
+
9
+ - **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))
10
+ - **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))
11
+
12
+ ### Bug Fixes
13
+
14
+ - **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))
15
+ - **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))
16
+
5
17
  ## [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)
6
18
 
7
19
  ### Features
@@ -48,7 +48,6 @@ describe('FlexGrid.Col offsets', () => {
48
48
  )
49
49
  const expectIfOffsetExpected = (propViewport) => {
50
50
  const target = getByText(`${propViewport}Offset`).parent
51
- // eslint-disable-next-line jest/valid-expect
52
51
  return expected[propViewport] ? expect(target) : expect(target).not
53
52
  }
54
53
  expectIfOffsetExpected('xs').toHaveStyle(getOffsetStyle('xs'))
@@ -104,7 +103,6 @@ describe('FlexGrid.Col sizes', () => {
104
103
 
105
104
  const expectIfSizeExpected = (propViewport) => {
106
105
  const target = getByText(propViewport).parent
107
- // eslint-disable-next-line jest/valid-expect
108
106
  return expected[propViewport] ? expect(target) : expect(target).not
109
107
  }
110
108
  expectIfSizeExpected('xs').toHaveStyle(getNumericSizeStyle('xs'))
@@ -154,7 +152,6 @@ describe('FlexGrid.Col sizes', () => {
154
152
 
155
153
  const expectIfSizeExpected = (text) => {
156
154
  const target = getByText(text).parent
157
- // eslint-disable-next-line jest/valid-expect
158
155
  return expected[text] ? expect(target) : expect(target).not
159
156
  }
160
157
  expectIfSizeExpected('xs-md').toHaveStyle(getNumericSizeStyle('xs'))
@@ -166,16 +163,17 @@ describe('FlexGrid.Col sizes', () => {
166
163
  })
167
164
 
168
165
  // Testing special "hiding" case on passing xs, sm, md, lg, xl props as 0.
169
- // Doesn't inherit like other values for these props, only applies to the given prop
166
+ // Should inherit like other values for these props, confirmed in:
167
+ // https://github.com/telus/universal-design-system/pull/364#discussion_r671382300
170
168
  it.each(
171
169
  // true here indicates hiding styles should apply
172
170
  // Align expected results like a table so they're easier to read
173
171
  /* prettier-ignore */ [
174
172
  ['xs', { xs: true, sm: false, md: false, lg: false, xl: false }],
175
- ['sm', { xs: false, sm: true, md: false, lg: false, xl: false }],
176
- ['md', { xs: false, sm: false, md: true, lg: false, xl: false }],
177
- ['lg', { xs: false, sm: false, md: false, lg: true, xl: false }],
178
- ['xl', { xs: false, sm: false, md: false, lg: false, xl: true }]
173
+ ['sm', { xs: true, sm: true, md: false, lg: false, xl: false }],
174
+ ['md', { xs: true, sm: true, md: true, lg: false, xl: false }],
175
+ ['lg', { xs: true, sm: true, md: true, lg: true, xl: false }],
176
+ ['xl', { xs: true, sm: true, md: true, lg: true, xl: true }]
179
177
  ]
180
178
  )('applies hiding styles from one prop at viewport "%s"', (viewport, expected) => {
181
179
  const hidingStyle = { display: 'none' }
@@ -199,7 +197,6 @@ describe('FlexGrid.Col sizes', () => {
199
197
  )
200
198
  const expectIfHidingExpected = (propViewport) => {
201
199
  const target = getByText(propViewport).parent
202
- // eslint-disable-next-line jest/valid-expect
203
200
  return expected[propViewport] ? expect(target) : expect(target).not
204
201
  }
205
202
  expectIfHidingExpected('xs').toHaveStyle(hidingStyle)
@@ -248,7 +245,6 @@ describe('FlexGrid.Col horizontalAlign', () => {
248
245
 
249
246
  const expectIfAlignExpected = (propViewport) => {
250
247
  const target = getByText(propViewport).parent
251
- // eslint-disable-next-line jest/valid-expect
252
248
  return expected[propViewport] ? expect(target) : expect(target).not
253
249
  }
254
250
  expectIfAlignExpected('xs').toHaveStyle(alignRightStyle)
@@ -0,0 +1,36 @@
1
+ import { selectSystemProps } from '../../src/utils'
2
+
3
+ describe('selectSystemProps', () => {
4
+ it('reduces the selectors and the types correctly', () => {
5
+ const somePropNames = ['a', 'b']
6
+ const someTypes = { a: 1, b: 2 }
7
+ const someOtherPropNames = ['c', 'd']
8
+ const someOtherTypes = { c: 3, d: 4 }
9
+ const reducer = (props) => (acc, allowedPropName) =>
10
+ allowedPropName in props ? { ...acc, [allowedPropName]: props[allowedPropName] } : acc
11
+ const exampleProps = { a: 'a', c: 'c', e: 'e' }
12
+ const [selectProps, selectedPropTypes] = selectSystemProps([
13
+ { select: (props) => somePropNames.reduce(reducer(props), {}), types: someTypes },
14
+ { select: (props) => someOtherPropNames.reduce(reducer(props), {}), types: someOtherTypes }
15
+ ])
16
+ expect(selectProps(exampleProps)).toEqual({ a: 'a', c: 'c' })
17
+ expect(selectedPropTypes).toEqual({ a: 1, b: 2, c: 3, d: 4 })
18
+ })
19
+
20
+ it('returns selector throwing if one of the prop helpers does not have any valid prop selectors', () => {
21
+ const [selectProps] = selectSystemProps([{ types: {} }])
22
+ expect(() => {
23
+ selectProps({ someProp: 'some value' })
24
+ }).toThrowError(
25
+ "An invalid system prop helper has been passed to 'selectSystemProps': prop selector ('.select') is missing in"
26
+ )
27
+ })
28
+
29
+ it('throws if one of the prop helpers does not have any valid prop types selectors', () => {
30
+ expect(() => {
31
+ selectSystemProps([{ select: () => {} }])
32
+ }).toThrowError(
33
+ "An invalid system prop helper has been passed to 'selectSystemProps': types selector ('.types') is missing in"
34
+ )
35
+ })
36
+ })
@@ -1,6 +1,6 @@
1
1
  import { Platform } from 'react-native'
2
2
 
3
- import { getA11yPropsFromHtmlTag, tagsToRoles, supportedTags } from '../../src'
3
+ import { getA11yPropsFromHtmlTag, supportedTags } from '../../src'
4
4
 
5
5
  // Note that currently all tests run as ios so only native logic can be tested here
6
6
  // until cross-platform tests are set up. See issue:
@@ -8,16 +8,7 @@ import { getA11yPropsFromHtmlTag, tagsToRoles, supportedTags } from '../../src'
8
8
 
9
9
  // As a temporary measure, there are tests on web-context HTML output for Box component
10
10
  // in @telus-uds/ds-allium which test the actual output when the tags are rendered.
11
-
12
- // These tests will therefore just test the values returned in a native context.
13
11
  describe('getA11yPropsFromHtmlTag', () => {
14
- it.each(Object.entries(tagsToRoles))(
15
- 'responds to tag "%s" with accessibilityRole "%s"',
16
- (tag, role) => {
17
- expect(getA11yPropsFromHtmlTag(tag)).toEqual({ accessibilityRole: role })
18
- }
19
- )
20
-
21
12
  it.each([
22
13
  [1, 'h1'],
23
14
  [2, 'h2'],
@@ -3027,59 +3027,6 @@
3027
3027
  "required": false,
3028
3028
  "description": "Whether or not to include gutter at the ends to the left and right of the FlexGrid"
3029
3029
  },
3030
- "pointerEvents": {
3031
- "type": {
3032
- "name": "enum",
3033
- "value": [
3034
- {
3035
- "value": "'all'",
3036
- "computed": false
3037
- },
3038
- {
3039
- "value": "'none'",
3040
- "computed": false
3041
- },
3042
- {
3043
- "value": "'box-only'",
3044
- "computed": false
3045
- },
3046
- {
3047
- "value": "'box-none'",
3048
- "computed": false
3049
- }
3050
- ]
3051
- },
3052
- "required": false,
3053
- "description": ""
3054
- },
3055
- "onLayout": {
3056
- "type": {
3057
- "name": "func"
3058
- },
3059
- "required": false,
3060
- "description": ""
3061
- },
3062
- "nativeID": {
3063
- "type": {
3064
- "name": "string"
3065
- },
3066
- "required": false,
3067
- "description": ""
3068
- },
3069
- "testID": {
3070
- "type": {
3071
- "name": "string"
3072
- },
3073
- "required": false,
3074
- "description": ""
3075
- },
3076
- "dataSet": {
3077
- "type": {
3078
- "name": "object"
3079
- },
3080
- "required": false,
3081
- "description": ""
3082
- },
3083
3030
  "xsReverse": {
3084
3031
  "type": {
3085
3032
  "name": "bool"
@@ -7850,6 +7797,38 @@
7850
7797
  "docs": {
7851
7798
  "description": "",
7852
7799
  "props": {
7800
+ "tokens": {
7801
+ "type": {
7802
+ "name": "custom",
7803
+ "raw": {
7804
+ "borderColor": "color",
7805
+ "borderWidth": "border",
7806
+ "borderRadius": "radius",
7807
+ "shadow": "shadow",
7808
+ "fontSize": "fontSize",
7809
+ "color": "color",
7810
+ "lineHeight": "lineHeight",
7811
+ "textAlign": "flexJustifyContent",
7812
+ "alignSelf": "flexAlign",
7813
+ "fontName": "fontName",
7814
+ "fontWeight": "fontWeight",
7815
+ "backgroundColor": "color",
7816
+ "opacity": "opacity",
7817
+ "paddingLeft": "size",
7818
+ "paddingRight": "size",
7819
+ "paddingTop": "size",
7820
+ "paddingBottom": "size",
7821
+ "width": "size",
7822
+ "minWidth": "size",
7823
+ "outerBorderColor": "color",
7824
+ "outerBorderWidth": "border",
7825
+ "outerBorderGap": "size",
7826
+ "outerBackgroundColor": "color"
7827
+ }
7828
+ },
7829
+ "required": false,
7830
+ "description": ""
7831
+ },
7853
7832
  "inactive": {
7854
7833
  "type": {
7855
7834
  "name": "bool"
@@ -7910,6 +7889,38 @@
7910
7889
  "docs": {
7911
7890
  "description": "`ButtonLink` is a component with the semantics and behaviour of a link, but with the visual appearance of a button.\nButtonLink is a block-level component and should not be used inline.",
7912
7891
  "props": {
7892
+ "tokens": {
7893
+ "type": {
7894
+ "name": "custom",
7895
+ "raw": {
7896
+ "borderColor": "color",
7897
+ "borderWidth": "border",
7898
+ "borderRadius": "radius",
7899
+ "shadow": "shadow",
7900
+ "fontSize": "fontSize",
7901
+ "color": "color",
7902
+ "lineHeight": "lineHeight",
7903
+ "textAlign": "flexJustifyContent",
7904
+ "alignSelf": "flexAlign",
7905
+ "fontName": "fontName",
7906
+ "fontWeight": "fontWeight",
7907
+ "backgroundColor": "color",
7908
+ "opacity": "opacity",
7909
+ "paddingLeft": "size",
7910
+ "paddingRight": "size",
7911
+ "paddingTop": "size",
7912
+ "paddingBottom": "size",
7913
+ "width": "size",
7914
+ "minWidth": "size",
7915
+ "outerBorderColor": "color",
7916
+ "outerBorderWidth": "border",
7917
+ "outerBorderGap": "size",
7918
+ "outerBackgroundColor": "color"
7919
+ }
7920
+ },
7921
+ "required": false,
7922
+ "description": ""
7923
+ },
7913
7924
  "inactive": {
7914
7925
  "type": {
7915
7926
  "name": "bool"
@@ -40,6 +40,9 @@ const parseComponentDocs = (name, generated) => {
40
40
  const components = {}
41
41
 
42
42
  Object.entries(allExports).forEach(([name, exp]) => {
43
+ // fail fast with meaningful error on typos, missing exports, etc
44
+ if (!exp) throw new Error(`components-base export "${name}" is ${exp} (typeof ${typeof exp})`)
45
+
43
46
  if (exp.__docgenInfo) {
44
47
  // populated by babel-plugin-react-docgen
45
48
  components[name] = parseComponentDocs(name, exp.__docgenInfo)
@@ -15,7 +15,7 @@ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Vi
15
15
 
16
16
  var _propTypes = _interopRequireDefault(require("prop-types"));
17
17
 
18
- var _propTypes2 = require("../utils/propTypes");
18
+ var _props = require("../utils/props");
19
19
 
20
20
  var _jsxRuntime = require("react/jsx-runtime");
21
21
 
@@ -36,7 +36,7 @@ const A11yText = /*#__PURE__*/(0, _react.forwardRef)(({
36
36
  heading,
37
37
  ...rest
38
38
  }, ref) => {
39
- const a11y = _propTypes2.a11yProps.select({
39
+ const a11y = _props.a11yProps.select({
40
40
  // On iOS, needs `accessible` to be true to be focusable without non-a11y content.
41
41
  // On Web, `accessible` causes RNW to set attributes that may make the element be treated as a group.
42
42
  // On Android, may cause this to be skipped when with `<Text>` siblings in an `accessible` View,
@@ -11,7 +11,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  var _ThemeProvider = require("../ThemeProvider");
13
13
 
14
- var _propTypes2 = require("../utils/propTypes");
14
+ var _props = require("../utils/props");
15
15
 
16
16
  var _Spinner = _interopRequireDefault(require("./Spinner"));
17
17
 
@@ -42,8 +42,8 @@ const ActivityIndicator = ({
42
42
  };
43
43
 
44
44
  ActivityIndicator.propTypes = {
45
- variant: _propTypes2.variantProp.propType,
46
- tokens: (0, _propTypes2.getTokensPropType)('ActivityIndicator'),
45
+ variant: _props.variantProp.propType,
46
+ tokens: (0, _props.getTokensPropType)('ActivityIndicator'),
47
47
 
48
48
  /**
49
49
  * A visually hidden accessible label describing the action taking place
package/lib/Box/Box.js CHANGED
@@ -26,10 +26,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
26
26
  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; }
27
27
 
28
28
  /**
29
- * @typedef {import('../utils/propTypes.js').SpacingValue} SpacingValue
30
- * @typedef {import('../utils/propTypes.js').SpacingIndex} SpacingIndex
31
- * @typedef {import('../utils/propTypes.js').SpacingObject} SpacingObject
32
- * @typedef {import('../utils/propTypes.js').SpacingOptions} SpacingOptions
29
+ * @typedef {import('../utils/props/spacingProps.js').SpacingValue} SpacingValue
30
+ * @typedef {import('../utils/props/spacingProps.js').SpacingIndex} SpacingIndex
31
+ * @typedef {import('../utils/props/spacingProps.js').SpacingObject} SpacingObject
32
+ * @typedef {import('../utils/props/spacingProps.js').SpacingOptions} SpacingOptions
33
33
  */
34
34
  const selectBoxStyles = tokens => {
35
35
  const styles = {
@@ -13,7 +13,7 @@ var _propTypes = _interopRequireWildcard(require("./propTypes"));
13
13
 
14
14
  var _ThemeProvider = require("../ThemeProvider");
15
15
 
16
- var _propTypes2 = require("../utils/propTypes");
16
+ var _props = require("../utils/props");
17
17
 
18
18
  var _jsxRuntime = require("react/jsx-runtime");
19
19
 
@@ -37,7 +37,7 @@ const Button = /*#__PURE__*/(0, _react.forwardRef)(({
37
37
  });
38
38
  });
39
39
  Button.displayName = 'Button';
40
- Button.propTypes = { ..._propTypes2.a11yProps.types,
40
+ Button.propTypes = { ..._props.a11yProps.types,
41
41
  ..._propTypes.default,
42
42
  children: _propTypes.textAndA11yText
43
43
  };
@@ -21,7 +21,7 @@ var _ViewportProvider = require("../ViewportProvider");
21
21
 
22
22
  var _ThemeProvider = require("../ThemeProvider");
23
23
 
24
- var _propTypes2 = require("../utils/propTypes");
24
+ var _props = require("../utils/props");
25
25
 
26
26
  var _input = require("../utils/input");
27
27
 
@@ -35,6 +35,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
35
35
 
36
36
  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; }
37
37
 
38
+ const [selectProps, selectedSystemPropTypes] = (0, _props.selectSystemProps)([_props.a11yProps, _props.pressProps, _props.viewProps]);
38
39
  const ButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
39
40
  variant,
40
41
  tokens,
@@ -56,7 +57,7 @@ const ButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
56
57
  const themeTokens = (0, _ThemeProvider.useThemeTokens)('ButtonGroup', tokens, variant, {
57
58
  viewport
58
59
  });
59
- const stackTokens = (0, _propTypes2.selectTokens)('StackView', themeTokens);
60
+ const stackTokens = (0, _props.selectTokens)('StackView', themeTokens);
60
61
  const {
61
62
  direction,
62
63
  space
@@ -72,14 +73,12 @@ const ButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
72
73
  onChange,
73
74
  readOnly
74
75
  });
75
-
76
- const a11y = _propTypes2.a11yProps.select({
76
+ const systemProps = selectProps({
77
77
  accessibilityRole,
78
78
  ...rest
79
79
  });
80
-
81
- const itemA11yRole = a11y.accessibilityRole === 'radiogroup' ? 'radio' : 'checkbox';
82
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.StackWrap, { ...a11y,
80
+ const itemA11yRole = systemProps.accessibilityRole === 'radiogroup' ? 'radio' : 'checkbox';
81
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.StackWrap, { ...systemProps,
83
82
  space: space,
84
83
  direction: direction,
85
84
  tokens: stackTokens,
@@ -109,7 +108,7 @@ const ButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
109
108
  },
110
109
  accessibilityRole: itemA11yRole,
111
110
  accessibilityLabel,
112
- ..._propTypes2.a11yProps.getPositionInSet(items.length, index)
111
+ ..._props.a11yProps.getPositionInSet(items.length, index)
113
112
  }; // Ensure button is direct child of group as MacOS voiceover only applies "X of Y" to
114
113
  // "radio" if it's a direct child of "radiogroup", even if aria-posinset etc exists
115
114
 
@@ -127,10 +126,9 @@ const ButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
127
126
  });
128
127
  });
129
128
  ButtonGroup.displayName = 'ButtonGroup';
130
- ButtonGroup.propTypes = { ..._propTypes2.a11yProps.propTypes,
131
- ..._propTypes2.pressProps.propTypes,
132
- tokens: (0, _propTypes2.getTokensPropType)('ButtonGroup'),
133
- variant: _propTypes2.variantProp.propType,
129
+ ButtonGroup.propTypes = { ...selectedSystemPropTypes,
130
+ tokens: (0, _props.getTokensPropType)('ButtonGroup'),
131
+ variant: _props.variantProp.propType,
134
132
 
135
133
  /**
136
134
  * The maximum number of items a user may select at once. Defaults to 1 and behaves
@@ -11,7 +11,7 @@ var _ButtonBase = _interopRequireDefault(require("./ButtonBase"));
11
11
 
12
12
  var _propTypes = _interopRequireWildcard(require("./propTypes"));
13
13
 
14
- var _propTypes2 = require("../utils/propTypes");
14
+ var _props = require("../utils/props");
15
15
 
16
16
  var _ThemeProvider = require("../ThemeProvider");
17
17
 
@@ -37,7 +37,7 @@ const ButtonLink = /*#__PURE__*/(0, _react.forwardRef)(({
37
37
  const {
38
38
  hrefAttrs,
39
39
  rest
40
- } = _propTypes2.hrefAttrsProp.bundle(props);
40
+ } = _props.hrefAttrsProp.bundle(props);
41
41
 
42
42
  const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('Button', tokens, variant);
43
43
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, {
@@ -50,9 +50,9 @@ const ButtonLink = /*#__PURE__*/(0, _react.forwardRef)(({
50
50
  });
51
51
  });
52
52
  ButtonLink.displayName = 'ButtonLink';
53
- ButtonLink.propTypes = { ..._propTypes2.a11yProps.types,
53
+ ButtonLink.propTypes = { ..._props.a11yProps.types,
54
54
  ..._propTypes.default,
55
- ..._propTypes2.linkProps.types,
55
+ ..._props.linkProps.types,
56
56
  children: _propTypes.textAndA11yText
57
57
  };
58
58
  var _default = ButtonLink;
@@ -9,7 +9,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
 
10
10
  var _airbnbPropTypes = _interopRequireDefault(require("airbnb-prop-types"));
11
11
 
12
- var _propTypes2 = require("../utils/propTypes");
12
+ var _props = require("../utils/props");
13
13
 
14
14
  var _A11yText = _interopRequireDefault(require("../A11yText"));
15
15
 
@@ -19,6 +19,8 @@ const textAndA11yText = _airbnbPropTypes.default.childrenOf(_propTypes.default.o
19
19
 
20
20
  exports.textAndA11yText = textAndA11yText;
21
21
  const buttonPropTypes = {
22
+ tokens: (0, _props.getTokensPropType)('Button'),
23
+
22
24
  /**
23
25
  * If true, prevents the button from being pressed, changes the cursor (on web) and accessibility
24
26
  * attributes to communicate this to the user, and applies `inactive: true` appearances from the theme
@@ -44,7 +46,7 @@ const buttonPropTypes = {
44
46
  * Function called when the button is pressed. Required unless the button has a href.
45
47
  */
46
48
  onPress: _propTypes.default.func,
47
- variant: _propTypes2.variantProp.propType
49
+ variant: _props.variantProp.propType
48
50
  };
49
51
  var _default = buttonPropTypes;
50
52
  exports.default = _default;
package/lib/Card/Card.js CHANGED
@@ -15,7 +15,7 @@ var _utils = require("../utils");
15
15
 
16
16
  var _ViewportProvider = require("../ViewportProvider");
17
17
 
18
- var _propTypes2 = require("../utils/propTypes");
18
+ var _props = require("../utils/props");
19
19
 
20
20
  var _CardBase = _interopRequireDefault(require("./CardBase"));
21
21
 
@@ -94,7 +94,7 @@ Card.propTypes = {
94
94
  children: _propTypes.default.node,
95
95
  tokens: (0, _utils.getTokensPropType)('Card'),
96
96
  variant: _utils.variantProp.propType,
97
- ..._propTypes2.a11yProps.types
97
+ ..._props.a11yProps.types
98
98
  };
99
99
  var _default = Card;
100
100
  exports.default = _default;
@@ -15,7 +15,7 @@ var _ThemeProvider = require("../ThemeProvider");
15
15
 
16
16
  var _utils = require("../utils");
17
17
 
18
- var _propTypes2 = require("../utils/propTypes");
18
+ var _props = require("../utils/props");
19
19
 
20
20
  var _jsxRuntime = require("react/jsx-runtime");
21
21
 
@@ -25,7 +25,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
25
25
 
26
26
  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; }
27
27
 
28
- // Ensure explicit selection of tokens
28
+ const [selectProps, selectedSystemPropTypes] = (0, _props.selectSystemProps)([_props.a11yProps, _props.viewProps]); // Ensure explicit selection of tokens
29
+
29
30
  const selectStyles = ({
30
31
  flex,
31
32
  backgroundColor,
@@ -64,9 +65,7 @@ const CardBase = /*#__PURE__*/(0, _react.forwardRef)(({
64
65
  ...rest
65
66
  }, ref) => {
66
67
  const cardStyle = selectStyles(typeof tokens === 'function' ? tokens() : tokens);
67
- const props = { ..._propTypes2.a11yProps.select(rest),
68
- ..._propTypes2.viewProps.select(rest)
69
- };
68
+ const props = selectProps(rest);
70
69
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
71
70
  style: cardStyle,
72
71
  dataSet: dataSet,
@@ -76,11 +75,9 @@ const CardBase = /*#__PURE__*/(0, _react.forwardRef)(({
76
75
  });
77
76
  });
78
77
  CardBase.displayName = 'CardBase';
79
- CardBase.propTypes = {
78
+ CardBase.propTypes = { ...selectedSystemPropTypes,
80
79
  children: _propTypes.default.node,
81
- tokens: (0, _utils.getTokensPropType)('Card'),
82
- ..._propTypes2.viewProps.types,
83
- ..._propTypes2.a11yProps.types
80
+ tokens: (0, _utils.getTokensPropType)('Card')
84
81
  };
85
82
  var _default = CardBase;
86
83
  exports.default = _default;
@@ -19,7 +19,7 @@ var _ThemeProvider = require("../ThemeProvider");
19
19
 
20
20
  var _utils = require("../utils");
21
21
 
22
- var _propTypes2 = require("../utils/propTypes");
22
+ var _props = require("../utils/props");
23
23
 
24
24
  var _CardBase = _interopRequireDefault(require("./CardBase"));
25
25
 
@@ -62,7 +62,7 @@ const PressableCardBase = /*#__PURE__*/(0, _react.forwardRef)(({
62
62
 
63
63
  const viewport = (0, _ViewportProvider.useViewport)();
64
64
 
65
- const a11y = _propTypes2.a11yProps.select({ ...rest,
65
+ const a11y = _props.a11yProps.select({ ...rest,
66
66
  accessibilityRole
67
67
  });
68
68
 
@@ -139,7 +139,7 @@ PressableCardBase.propTypes = {
139
139
  allowFunction: true
140
140
  }),
141
141
  variant: _utils.variantProp.propType,
142
- ..._propTypes2.a11yProps.types
142
+ ..._props.a11yProps.types
143
143
  };
144
144
 
145
145
  var _default = (0, _utils.withLinkRouter)(PressableCardBase);
@@ -31,7 +31,7 @@ var _ThemeProvider = require("../ThemeProvider");
31
31
 
32
32
  var _utils = require("../utils");
33
33
 
34
- var _propTypes2 = require("../utils/propTypes");
34
+ var _props = require("../utils/props");
35
35
 
36
36
  var _useUniqueId = _interopRequireDefault(require("../utils/useUniqueId"));
37
37
 
@@ -200,7 +200,7 @@ const Checkbox = /*#__PURE__*/(0, _react.forwardRef)(({
200
200
  if ((event === null || event === void 0 ? void 0 : event.key) === ' ') handleChange(event);
201
201
  };
202
202
 
203
- const accessibilityProps = _propTypes2.a11yProps.select(rest);
203
+ const accessibilityProps = _props.a11yProps.select(rest);
204
204
 
205
205
  const uniqueId = (0, _useUniqueId.default)('checkbox');
206
206
  const inputId = id ?? uniqueId;
@@ -273,7 +273,7 @@ const Checkbox = /*#__PURE__*/(0, _react.forwardRef)(({
273
273
  });
274
274
  });
275
275
  Checkbox.displayName = 'Checkbox';
276
- Checkbox.propTypes = { ..._propTypes2.a11yProps.propTypes,
276
+ Checkbox.propTypes = { ..._props.a11yProps.propTypes,
277
277
 
278
278
  /**
279
279
  * Use `checked` for controlled Checkbox. For uncontrolled Checkbox, use the `defaultChecked` prop.
@@ -30,8 +30,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
30
30
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
31
 
32
32
  /**
33
- * @typedef {import('../utils/propTypes.js').SpacingIndex} SpacingIndex
34
- * @typedef {import('../utils/propTypes.js').SpacingObject} SpacingObject
33
+ * @typedef {import('../utils/props/spacingProps.js').SpacingIndex} SpacingIndex
34
+ * @typedef {import('../utils/props/spacingProps.js').SpacingObject} SpacingObject
35
35
  */
36
36
 
37
37
  /**