@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.
- package/.turbo/turbo-build.log +5 -0
- package/CHANGELOG.md +12 -0
- package/__tests__/FlexGrid/Col.test.jsx +6 -10
- package/__tests__/utils/props.test.js +36 -0
- package/__tests__/utils/semantics.test.jsx +1 -10
- package/component-docs.json +64 -53
- package/generate-component-docs.js +3 -0
- package/lib/A11yText/index.js +2 -2
- package/lib/ActivityIndicator/index.js +3 -3
- package/lib/Box/Box.js +4 -4
- package/lib/Button/Button.js +2 -2
- package/lib/Button/ButtonGroup.js +10 -12
- package/lib/Button/ButtonLink.js +4 -4
- package/lib/Button/propTypes.js +4 -2
- package/lib/Card/Card.js +2 -2
- package/lib/Card/CardBase.js +6 -9
- package/lib/Card/PressableCardBase.js +3 -3
- package/lib/Checkbox/Checkbox.js +3 -3
- package/lib/Divider/Divider.js +2 -2
- package/lib/FlexGrid/FlexGrid.js +4 -4
- package/lib/FlexGrid/helpers/index.js +1 -4
- package/lib/IconButton/IconButton.js +3 -3
- package/lib/Link/LinkBase.js +10 -10
- package/lib/List/List.js +3 -3
- package/lib/Progress/Progress.js +2 -2
- package/lib/Progress/ProgressBar.js +2 -2
- package/lib/Radio/Radio.js +3 -3
- package/lib/Spacer/Spacer.js +2 -2
- package/lib/StackView/getStackedContent.js +1 -1
- package/lib/StepTracker/StepTracker.js +2 -2
- package/lib/Tags/Tags.js +9 -9
- package/lib/ThemeProvider/useThemeTokens.js +3 -3
- package/lib/ThemeProvider/utils/theme-tokens.js +3 -3
- package/lib/ToggleSwitch/ToggleSwitch.js +6 -6
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +8 -8
- package/lib/utils/a11y/semantics.js +4 -3
- package/lib/utils/index.js +4 -4
- package/lib/utils/pressability.js +2 -2
- package/lib/utils/props/a11yProps.js +153 -0
- package/lib/utils/props/clickProps.js +36 -0
- package/lib/utils/props/componentPropType.js +70 -0
- package/lib/utils/props/copyPropTypes.js +14 -0
- package/lib/utils/props/getPropSelector.js +13 -0
- package/lib/utils/props/hrefAttrsProp.js +41 -0
- package/lib/utils/props/index.js +149 -0
- package/lib/utils/props/linkProps.js +64 -0
- package/lib/utils/props/paddingProp.js +20 -0
- package/lib/utils/props/pressProps.js +57 -0
- package/lib/utils/props/rectProp.js +20 -0
- package/lib/utils/props/responsiveProps.js +40 -0
- package/lib/utils/props/selectSystemProps.js +31 -0
- package/lib/utils/props/spacingProps.js +71 -0
- package/lib/utils/props/tokens.js +145 -0
- package/lib/utils/props/variantProp.js +28 -0
- package/lib/utils/props/viewProps.js +34 -0
- package/lib/utils/useResponsiveProp.js +1 -1
- package/lib/utils/useSpacingScale.js +4 -4
- package/package.json +3 -3
- package/release-context.json +4 -4
- package/src/A11yText/index.jsx +1 -1
- package/src/ActivityIndicator/index.jsx +1 -1
- package/src/Box/Box.jsx +5 -4
- package/src/Button/Button.jsx +1 -1
- package/src/Button/ButtonGroup.jsx +17 -8
- package/src/Button/ButtonLink.jsx +1 -1
- package/src/Button/propTypes.js +2 -1
- package/src/Card/Card.jsx +1 -1
- package/src/Card/CardBase.jsx +6 -5
- package/src/Card/PressableCardBase.jsx +1 -1
- package/src/Checkbox/Checkbox.jsx +1 -1
- package/src/Divider/Divider.jsx +2 -2
- package/src/FlexGrid/FlexGrid.jsx +11 -5
- package/src/FlexGrid/helpers/index.js +1 -3
- package/src/IconButton/IconButton.jsx +1 -1
- package/src/Link/LinkBase.jsx +1 -1
- package/src/List/List.jsx +1 -1
- package/src/Progress/Progress.jsx +1 -1
- package/src/Progress/ProgressBar.jsx +1 -1
- package/src/Radio/Radio.jsx +1 -1
- package/src/Spacer/Spacer.jsx +2 -2
- package/src/StackView/getStackedContent.jsx +1 -1
- package/src/StepTracker/StepTracker.jsx +1 -1
- package/src/Tags/Tags.jsx +1 -7
- package/src/ThemeProvider/useThemeTokens.js +3 -3
- package/src/ThemeProvider/utils/theme-tokens.js +3 -3
- package/src/ToggleSwitch/ToggleSwitch.jsx +1 -7
- package/src/ToggleSwitch/ToggleSwitchGroup.jsx +1 -1
- package/src/utils/a11y/semantics.js +3 -2
- package/src/utils/index.js +1 -1
- package/src/utils/pressability.js +1 -1
- package/src/utils/props/a11yProps.js +151 -0
- package/src/utils/props/clickProps.js +31 -0
- package/src/utils/props/componentPropType.js +67 -0
- package/src/utils/props/copyPropTypes.js +3 -0
- package/src/utils/props/getPropSelector.js +14 -0
- package/src/utils/props/hrefAttrsProp.js +25 -0
- package/src/utils/props/index.js +15 -0
- package/src/utils/props/linkProps.js +43 -0
- package/src/utils/props/paddingProp.js +10 -0
- package/src/utils/props/pressProps.js +45 -0
- package/src/utils/props/rectProp.js +10 -0
- package/src/utils/props/responsiveProps.js +30 -0
- package/src/utils/props/selectSystemProps.js +25 -0
- package/src/utils/props/spacingProps.js +58 -0
- package/src/utils/props/tokens.js +150 -0
- package/src/utils/props/variantProp.js +20 -0
- package/src/utils/props/viewProps.js +23 -0
- package/src/utils/useResponsiveProp.js +1 -1
- package/src/utils/useSpacingScale.js +4 -4
- package/.ultra.cache.json +0 -1
- package/lib/utils/a11y/propTypes.js +0 -61
- package/lib/utils/a11y/propTypes.native.js +0 -47
- package/lib/utils/propTypes.js +0 -566
- package/src/utils/a11y/propTypes.js +0 -61
- package/src/utils/a11y/propTypes.native.js +0 -39
- package/src/utils/propTypes.js +0 -561
package/lib/FlexGrid/FlexGrid.js
CHANGED
|
@@ -35,9 +35,11 @@ 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, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
38
39
|
/**
|
|
39
40
|
* A mobile-first flexbox grid.
|
|
40
41
|
*/
|
|
42
|
+
|
|
41
43
|
const FlexGrid = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
42
44
|
limitWidth = true,
|
|
43
45
|
gutter = true,
|
|
@@ -86,8 +88,7 @@ const FlexGrid = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
const props = { ...(0, _utils.getA11yPropsFromHtmlTag)(tag, accessibilityRole),
|
|
89
|
-
...
|
|
90
|
-
..._utils.viewProps.select(rest)
|
|
91
|
+
...selectProps(rest)
|
|
91
92
|
};
|
|
92
93
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GutterContext.default.Provider, {
|
|
93
94
|
value: gutter,
|
|
@@ -113,8 +114,7 @@ const styles = _StyleSheet.default.create({
|
|
|
113
114
|
}
|
|
114
115
|
});
|
|
115
116
|
|
|
116
|
-
FlexGrid.propTypes = { ...
|
|
117
|
-
..._utils.viewProps.types,
|
|
117
|
+
FlexGrid.propTypes = { ...selectedSystemPropTypes,
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* Whether or not to give the grid a fixed width. This also centres the grid horizontally.
|
|
@@ -21,7 +21,7 @@ var _ThemeProvider = require("../ThemeProvider");
|
|
|
21
21
|
|
|
22
22
|
var _utils = require("../utils");
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _props = require("../utils/props");
|
|
25
25
|
|
|
26
26
|
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
27
27
|
|
|
@@ -91,7 +91,7 @@ const IconButton = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
91
91
|
...rest
|
|
92
92
|
} = _utils.clickProps.toPressProps(rawRest);
|
|
93
93
|
|
|
94
|
-
const a11y =
|
|
94
|
+
const a11y = _props.a11yProps.select({ ...rest,
|
|
95
95
|
accessibilityRole
|
|
96
96
|
});
|
|
97
97
|
|
|
@@ -125,7 +125,7 @@ const IconButton = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
IconButton.displayName = 'IconButton';
|
|
128
|
-
IconButton.propTypes = { ...
|
|
128
|
+
IconButton.propTypes = { ..._props.a11yProps.types,
|
|
129
129
|
variant: _utils.variantProp.propType,
|
|
130
130
|
tokens: (0, _utils.getTokensPropType)('IconButton'),
|
|
131
131
|
icon: _propTypes.default.elementType.isRequired,
|
package/lib/Link/LinkBase.js
CHANGED
|
@@ -15,7 +15,7 @@ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/export
|
|
|
15
15
|
|
|
16
16
|
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _props = require("../utils/props");
|
|
19
19
|
|
|
20
20
|
var _pressability = require("../utils/pressability");
|
|
21
21
|
|
|
@@ -135,17 +135,17 @@ const LinkBase = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
135
135
|
const {
|
|
136
136
|
onPress,
|
|
137
137
|
...props
|
|
138
|
-
} =
|
|
138
|
+
} = _props.clickProps.toPressProps(rawRest);
|
|
139
139
|
|
|
140
140
|
const {
|
|
141
141
|
hrefAttrs,
|
|
142
142
|
rest
|
|
143
|
-
} =
|
|
143
|
+
} = _props.hrefAttrsProp.bundle(props);
|
|
144
144
|
|
|
145
|
-
const linkPropSet =
|
|
145
|
+
const linkPropSet = _props.linkProps.select({
|
|
146
146
|
accessibilityRole,
|
|
147
147
|
href,
|
|
148
|
-
onPress:
|
|
148
|
+
onPress: _props.linkProps.handleHref({
|
|
149
149
|
href,
|
|
150
150
|
onPress
|
|
151
151
|
}),
|
|
@@ -195,10 +195,10 @@ const LinkBase = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
195
195
|
});
|
|
196
196
|
});
|
|
197
197
|
LinkBase.displayName = 'LinkBase';
|
|
198
|
-
LinkBase.propTypes = { ...
|
|
199
|
-
...
|
|
200
|
-
tokens: (0,
|
|
201
|
-
variant:
|
|
198
|
+
LinkBase.propTypes = { ..._props.a11yProps.types,
|
|
199
|
+
..._props.linkProps.types,
|
|
200
|
+
tokens: (0, _props.getTokensPropType)('Link'),
|
|
201
|
+
variant: _props.variantProp.propType,
|
|
202
202
|
|
|
203
203
|
/**
|
|
204
204
|
* Optional variant that may be passed down to the link's icon if there is one
|
|
@@ -220,7 +220,7 @@ LinkBase.propTypes = { ..._propTypes2.a11yProps.types,
|
|
|
220
220
|
* On Web if href is passed, React Native Web maps this object's props to
|
|
221
221
|
* `rel`, `target` and `download` attrs.
|
|
222
222
|
*/
|
|
223
|
-
hrefAttrs: _propTypes.default.shape(
|
|
223
|
+
hrefAttrs: _propTypes.default.shape(_props.hrefAttrsProp.types)
|
|
224
224
|
};
|
|
225
225
|
|
|
226
226
|
const staticStyles = _StyleSheet.default.create({
|
package/lib/List/List.js
CHANGED
|
@@ -15,7 +15,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
15
15
|
|
|
16
16
|
var _utils = require("../utils");
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _props = require("../utils/props");
|
|
19
19
|
|
|
20
20
|
var _ListItem = _interopRequireDefault(require("./ListItem"));
|
|
21
21
|
|
|
@@ -43,7 +43,7 @@ const List = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
43
43
|
default: 'none'
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
const a11y =
|
|
46
|
+
const a11y = _props.a11yProps.select(rest);
|
|
47
47
|
|
|
48
48
|
const items = _react.Children.map(children, (child, index) => {
|
|
49
49
|
if (child.type.name === _ListItem.default.name) {
|
|
@@ -66,7 +66,7 @@ const List = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
66
66
|
});
|
|
67
67
|
});
|
|
68
68
|
List.displayName = 'List';
|
|
69
|
-
List.propTypes = { ...
|
|
69
|
+
List.propTypes = { ..._props.a11yProps.types,
|
|
70
70
|
tokens: (0, _utils.getTokensPropType)('List'),
|
|
71
71
|
variant: _utils.variantProp.propType,
|
|
72
72
|
children: (0, _utils.componentPropType)('ListItem'),
|
package/lib/Progress/Progress.js
CHANGED
|
@@ -11,7 +11,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
11
11
|
|
|
12
12
|
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _props = require("../utils/props");
|
|
15
15
|
|
|
16
16
|
var _ThemeProvider = require("../ThemeProvider");
|
|
17
17
|
|
|
@@ -79,7 +79,7 @@ const Progress = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
79
79
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
80
80
|
ref: ref,
|
|
81
81
|
style: selectProgressStyles(themeTokens),
|
|
82
|
-
...
|
|
82
|
+
..._props.a11yProps.select(rest),
|
|
83
83
|
children: children
|
|
84
84
|
});
|
|
85
85
|
});
|
|
@@ -17,7 +17,7 @@ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Vi
|
|
|
17
17
|
|
|
18
18
|
var _ProgressBarBackground = _interopRequireDefault(require("./ProgressBarBackground"));
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _props = require("../utils/props");
|
|
21
21
|
|
|
22
22
|
var _ThemeProvider = require("../ThemeProvider");
|
|
23
23
|
|
|
@@ -102,7 +102,7 @@ const ProgressBar = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
102
102
|
now: percentage,
|
|
103
103
|
text: `${percentage}%`
|
|
104
104
|
},
|
|
105
|
-
...
|
|
105
|
+
..._props.a11yProps.select(rest)
|
|
106
106
|
};
|
|
107
107
|
return percentage > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
108
108
|
ref: ref,
|
package/lib/Radio/Radio.js
CHANGED
|
@@ -25,7 +25,7 @@ var _ThemeProvider = require("../ThemeProvider");
|
|
|
25
25
|
|
|
26
26
|
var _utils = require("../utils");
|
|
27
27
|
|
|
28
|
-
var
|
|
28
|
+
var _props = require("../utils/props");
|
|
29
29
|
|
|
30
30
|
var _StackView = _interopRequireDefault(require("../StackView"));
|
|
31
31
|
|
|
@@ -163,7 +163,7 @@ const Radio = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
163
163
|
if ((event === null || event === void 0 ? void 0 : event.key) === ' ') handleChange(event);
|
|
164
164
|
};
|
|
165
165
|
|
|
166
|
-
const accessibilityProps =
|
|
166
|
+
const accessibilityProps = _props.a11yProps.select(rest);
|
|
167
167
|
|
|
168
168
|
const uniqueId = (0, _utils.useUniqueId)('radio');
|
|
169
169
|
const inputId = id ?? uniqueId;
|
|
@@ -218,7 +218,7 @@ const Radio = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
218
218
|
});
|
|
219
219
|
});
|
|
220
220
|
Radio.displayName = 'Radio';
|
|
221
|
-
Radio.propTypes = { ...
|
|
221
|
+
Radio.propTypes = { ..._props.a11yProps.propTypes,
|
|
222
222
|
|
|
223
223
|
/**
|
|
224
224
|
* Use `checked` for controlled Radio. For uncontrolled Radio, use the `defaultChecked` prop.
|
package/lib/Spacer/Spacer.js
CHANGED
|
@@ -24,8 +24,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
24
24
|
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; }
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* @typedef {import('../utils/
|
|
28
|
-
* @typedef {import('../utils/
|
|
27
|
+
* @typedef {import('../utils/props/spacingProps.js').SpacingValue} SpacingValue
|
|
28
|
+
* @typedef {import('../utils/props/spacingProps.js').SpacingObject} SpacingObject
|
|
29
29
|
*/
|
|
30
30
|
const selectSizeStyle = (size, direction) => ({
|
|
31
31
|
// Only apply space in one direction at a time, else large spacers will increase the
|
|
@@ -24,7 +24,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
24
24
|
/**
|
|
25
25
|
* @typedef {import('react').ReactChildren} ReactChildren
|
|
26
26
|
* @typedef {import('react').ReactElement} ReactElement
|
|
27
|
-
* @typedef {import('../utils/
|
|
27
|
+
* @typedef {import('../utils/props/spacingProps.js').SpacingValue} SpacingValue
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
/**
|
|
@@ -21,7 +21,7 @@ var _ThemeProvider = require("../ThemeProvider");
|
|
|
21
21
|
|
|
22
22
|
var _utils = require("../utils");
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _props = require("../utils/props");
|
|
25
25
|
|
|
26
26
|
var _ViewportProvider = require("../ViewportProvider");
|
|
27
27
|
|
|
@@ -136,7 +136,7 @@ const StepTracker = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
136
136
|
now: current,
|
|
137
137
|
text: steps[current]
|
|
138
138
|
},
|
|
139
|
-
...
|
|
139
|
+
..._props.a11yProps.select(rest)
|
|
140
140
|
};
|
|
141
141
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
142
142
|
ref: ref,
|
package/lib/Tags/Tags.js
CHANGED
|
@@ -27,7 +27,7 @@ var _ViewportProvider = require("../ViewportProvider");
|
|
|
27
27
|
|
|
28
28
|
var _ThemeProvider = require("../ThemeProvider");
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _props = require("../utils/props");
|
|
31
31
|
|
|
32
32
|
var _input = require("../utils/input");
|
|
33
33
|
|
|
@@ -97,14 +97,14 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
97
97
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Tags', tokens, variant, {
|
|
98
98
|
viewport
|
|
99
99
|
});
|
|
100
|
-
const stackTokens = (0,
|
|
100
|
+
const stackTokens = (0, _props.selectTokens)('StackView', themeTokens);
|
|
101
101
|
const {
|
|
102
102
|
direction,
|
|
103
103
|
space
|
|
104
104
|
} = themeTokens;
|
|
105
105
|
const getItemTokens = (0, _ThemeProvider.useThemeTokensCallback)('TagsItem', tokens, variant);
|
|
106
106
|
|
|
107
|
-
const getButtonTokens = buttonState => (0,
|
|
107
|
+
const getButtonTokens = buttonState => (0, _props.selectTokens)('Button', getItemTokens(buttonState));
|
|
108
108
|
|
|
109
109
|
const {
|
|
110
110
|
currentValues,
|
|
@@ -117,7 +117,7 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
117
117
|
readOnly
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
-
const a11y =
|
|
120
|
+
const a11y = _props.a11yProps.select({
|
|
121
121
|
accessibilityRole,
|
|
122
122
|
...rest
|
|
123
123
|
});
|
|
@@ -154,7 +154,7 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
154
154
|
},
|
|
155
155
|
accessibilityRole: itemA11yRole,
|
|
156
156
|
accessibilityLabel,
|
|
157
|
-
...
|
|
157
|
+
..._props.a11yProps.getPositionInSet(items.length, index)
|
|
158
158
|
};
|
|
159
159
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, {
|
|
160
160
|
ref: itemRef,
|
|
@@ -202,10 +202,10 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
202
202
|
});
|
|
203
203
|
});
|
|
204
204
|
Tags.displayName = 'Tags';
|
|
205
|
-
Tags.propTypes = { ...
|
|
206
|
-
...
|
|
207
|
-
tokens: (0,
|
|
208
|
-
variant:
|
|
205
|
+
Tags.propTypes = { ..._props.a11yProps.propTypes,
|
|
206
|
+
..._props.pressProps.propTypes,
|
|
207
|
+
tokens: (0, _props.getTokensPropType)('Tags'),
|
|
208
|
+
variant: _props.variantProp.propType,
|
|
209
209
|
|
|
210
210
|
/**
|
|
211
211
|
* If provided, sets a maximum number of items a user may select at once.
|
|
@@ -14,9 +14,9 @@ var _utils = require("./utils");
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* @typedef {import('../utils/
|
|
18
|
-
* @typedef {import('../utils/
|
|
19
|
-
* @typedef {import('../utils/
|
|
17
|
+
* @typedef {import('../utils/props/variantProp.js').AppearanceSet} AppearanceSet
|
|
18
|
+
* @typedef {import('../utils/props/tokens.js').TokensProp} TokensProp
|
|
19
|
+
* @typedef {import('../utils/props/tokens.js').TokensSet} TokensSet
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -14,9 +14,9 @@ var _package = _interopRequireDefault(require("../../../package.json"));
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* @typedef {import('../../utils/
|
|
18
|
-
* @typedef {import('../../utils/
|
|
19
|
-
* @typedef {import('../../utils/
|
|
17
|
+
* @typedef {import('../../utils/props/variantProp.js').AppearanceSet} AppearanceSet
|
|
18
|
+
* @typedef {import('../../utils/props/tokens.js').TokensProp} TokensProp
|
|
19
|
+
* @typedef {import('../../utils/props/tokens.js').TokensSet} TokensSet
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -23,7 +23,7 @@ var _StackView = _interopRequireDefault(require("../StackView"));
|
|
|
23
23
|
|
|
24
24
|
var _ThemeProvider = require("../ThemeProvider");
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _props = require("../utils/props");
|
|
27
27
|
|
|
28
28
|
var _input = require("../utils/input");
|
|
29
29
|
|
|
@@ -37,7 +37,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
37
37
|
|
|
38
38
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
39
|
|
|
40
|
-
const selectButtonTokens = tokens => (0,
|
|
40
|
+
const selectButtonTokens = tokens => (0, _props.selectTokens)('Button', { ...tokens,
|
|
41
41
|
// Width tokens are applied to our inner track. Disable Button width token so it wraps our track width.
|
|
42
42
|
width: null
|
|
43
43
|
}); // Map and rename icon-specific tokens to name used within Icon
|
|
@@ -188,10 +188,10 @@ const ToggleSwitch = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
188
188
|
});
|
|
189
189
|
});
|
|
190
190
|
ToggleSwitch.displayName = 'ToggleSwitch';
|
|
191
|
-
ToggleSwitch.propTypes = { ...
|
|
192
|
-
...
|
|
193
|
-
tokens: (0,
|
|
194
|
-
variant:
|
|
191
|
+
ToggleSwitch.propTypes = { ..._props.a11yProps.propTypes,
|
|
192
|
+
..._props.pressProps.propTypes,
|
|
193
|
+
tokens: (0, _props.getTokensPropType)('ToggleSwitch'),
|
|
194
|
+
variant: _props.variantProp.propType,
|
|
195
195
|
|
|
196
196
|
/**
|
|
197
197
|
* If this is a "controlled" component and a parent handles its selected state,
|
|
@@ -23,7 +23,7 @@ var _ViewportProvider = require("../ViewportProvider");
|
|
|
23
23
|
|
|
24
24
|
var _ThemeProvider = require("../ThemeProvider");
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _props = require("../utils/props");
|
|
27
27
|
|
|
28
28
|
var _input = require("../utils/input");
|
|
29
29
|
|
|
@@ -77,7 +77,7 @@ const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
77
77
|
readOnly
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
const a11y =
|
|
80
|
+
const a11y = _props.a11yProps.select({
|
|
81
81
|
accessibilityRole,
|
|
82
82
|
...rest
|
|
83
83
|
});
|
|
@@ -104,7 +104,7 @@ const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
104
104
|
},
|
|
105
105
|
accessibilityRole: itemA11yRole,
|
|
106
106
|
accessibilityLabel,
|
|
107
|
-
...
|
|
107
|
+
..._props.a11yProps.getPositionInSet(items.length, index)
|
|
108
108
|
};
|
|
109
109
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleSwitch.default, {
|
|
110
110
|
id: id,
|
|
@@ -136,10 +136,10 @@ const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
136
136
|
});
|
|
137
137
|
});
|
|
138
138
|
ToggleSwitchGroup.displayName = 'ToggleSwitchGroup';
|
|
139
|
-
ToggleSwitchGroup.propTypes = { ...
|
|
140
|
-
...
|
|
141
|
-
tokens: (0,
|
|
142
|
-
variant:
|
|
139
|
+
ToggleSwitchGroup.propTypes = { ..._props.a11yProps.propTypes,
|
|
140
|
+
..._props.pressProps.propTypes,
|
|
141
|
+
tokens: (0, _props.getTokensPropType)('ToggleSwitchGroup'),
|
|
142
|
+
variant: _props.variantProp.propType,
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* The maximum number of items a user may select at once. Defaults to 1 and behaves
|
|
@@ -219,7 +219,7 @@ ToggleSwitchGroup.propTypes = { ..._propTypes2.a11yProps.propTypes,
|
|
|
219
219
|
/**
|
|
220
220
|
* Toggle switch token overrides.
|
|
221
221
|
*/
|
|
222
|
-
toggleSwitchTokens: (0,
|
|
222
|
+
toggleSwitchTokens: (0, _props.getTokensPropType)('ToggleSwitch'),
|
|
223
223
|
|
|
224
224
|
/**
|
|
225
225
|
* Current validation status of the group, passed to the feedback element if there is one.
|
|
@@ -154,9 +154,10 @@ const getA11yPropsFromHtmlTag = (tag, nativeRole) => {
|
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
if (tag) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
// aria roles don't have native counterparts and RN may throw an error if an unrecognised role is passed
|
|
158
|
+
const ariaRole = _Platform.default.OS === 'web' && tagsToRoles[tag];
|
|
159
|
+
if (ariaRole) return {
|
|
160
|
+
accessibilityRole: ariaRole
|
|
160
161
|
};
|
|
161
162
|
const accessibilityLevel = getHeadingLevel(tag);
|
|
162
163
|
if (accessibilityLevel) return {
|
package/lib/utils/index.js
CHANGED
|
@@ -125,16 +125,16 @@ Object.keys(_pressability).forEach(function (key) {
|
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
-
var
|
|
128
|
+
var _props = require("./props");
|
|
129
129
|
|
|
130
|
-
Object.keys(
|
|
130
|
+
Object.keys(_props).forEach(function (key) {
|
|
131
131
|
if (key === "default" || key === "__esModule") return;
|
|
132
132
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
133
|
-
if (key in exports && exports[key] ===
|
|
133
|
+
if (key in exports && exports[key] === _props[key]) return;
|
|
134
134
|
Object.defineProperty(exports, key, {
|
|
135
135
|
enumerable: true,
|
|
136
136
|
get: function () {
|
|
137
|
-
return
|
|
137
|
+
return _props[key];
|
|
138
138
|
}
|
|
139
139
|
});
|
|
140
140
|
});
|
|
@@ -9,7 +9,7 @@ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/export
|
|
|
9
9
|
|
|
10
10
|
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _pressProps = _interopRequireDefault(require("./props/pressProps"));
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
@@ -108,7 +108,7 @@ const staticStyles = _StyleSheet.default.create(_Platform.default.select({
|
|
|
108
108
|
|
|
109
109
|
const getPressHandlersWithArgs = (pressableProps = {}, args = []) => {
|
|
110
110
|
// Allow handlers to be passed down for blur, hover, focus, pressIn, etc
|
|
111
|
-
const pressHandlers = Object.fromEntries(Object.entries(
|
|
111
|
+
const pressHandlers = Object.fromEntries(Object.entries(_pressProps.default.selectHandlers(pressableProps)).map(([key, handler]) => ({
|
|
112
112
|
[key]: (...defaultArgs) => {
|
|
113
113
|
// Pass each handler data on this button and current selection
|
|
114
114
|
handler(...args, ...defaultArgs);
|
|
@@ -0,0 +1,153 @@
|
|
|
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 _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
11
|
+
|
|
12
|
+
var _getPropSelector = _interopRequireDefault(require("./getPropSelector"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
// React Native exports a11y prop definitions as TypeScript Interfaces, but no longer exports PropTypes
|
|
17
|
+
// so we have to define them ourselves.
|
|
18
|
+
const nativeA11yPropTypes = {
|
|
19
|
+
accessible: _propTypes.default.bool,
|
|
20
|
+
focusable: _propTypes.default.bool,
|
|
21
|
+
accessibilityElementsHidden: _propTypes.default.bool,
|
|
22
|
+
accessibilityHint: _propTypes.default.string,
|
|
23
|
+
// react-native-web ignores `accessibilityHint`
|
|
24
|
+
accessibilityIgnoresInvertColors: _propTypes.default.bool,
|
|
25
|
+
accessibilityLabel: _propTypes.default.string,
|
|
26
|
+
accessibilityRole: _propTypes.default.string,
|
|
27
|
+
accessibilityActions: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
28
|
+
name: _propTypes.default.string.isRequired,
|
|
29
|
+
label: _propTypes.default.string
|
|
30
|
+
})),
|
|
31
|
+
accessibilityLiveRegion: _propTypes.default.oneOf(['none', 'polite', 'assertive']),
|
|
32
|
+
accessibilityState: _propTypes.default.shape({
|
|
33
|
+
disabled: _propTypes.default.bool,
|
|
34
|
+
selected: _propTypes.default.bool,
|
|
35
|
+
checked: _propTypes.default.oneOf([true, false, 'mixed']),
|
|
36
|
+
busy: _propTypes.default.bool,
|
|
37
|
+
expanded: _propTypes.default.bool
|
|
38
|
+
}),
|
|
39
|
+
accessibilityValue: _propTypes.default.shape({
|
|
40
|
+
min: _propTypes.default.number,
|
|
41
|
+
max: _propTypes.default.number,
|
|
42
|
+
now: _propTypes.default.number,
|
|
43
|
+
text: _propTypes.default.string
|
|
44
|
+
}),
|
|
45
|
+
accessibilityViewIsModal: _propTypes.default.bool,
|
|
46
|
+
importantForAccessibility: _propTypes.default.oneOf(['auto', 'yes', 'no', 'no-hide-descendants']),
|
|
47
|
+
onAccessibilityAction: _propTypes.default.func,
|
|
48
|
+
onAccessibilityEscape: _propTypes.default.func,
|
|
49
|
+
onAccessibilityTap: _propTypes.default.func
|
|
50
|
+
};
|
|
51
|
+
const a11yPropTypes = { ...nativeA11yPropTypes,
|
|
52
|
+
// React Native Web adds many a11y props that alias aria-* attributes
|
|
53
|
+
// Types based on https://necolas.github.io/react-native-web/docs/accessibility/
|
|
54
|
+
accessibilityActiveDescendant: _propTypes.default.string,
|
|
55
|
+
accessibilityAtomic: _propTypes.default.bool,
|
|
56
|
+
accessibilityAutoComplete: _propTypes.default.string,
|
|
57
|
+
accessibilityBusy: _propTypes.default.bool,
|
|
58
|
+
accessibilityChecked: _propTypes.default.oneOf([true, false, 'mixed']),
|
|
59
|
+
accessibilityColumnCount: _propTypes.default.number,
|
|
60
|
+
accessibilityColumnIndex: _propTypes.default.number,
|
|
61
|
+
accessibilityColumnSpan: _propTypes.default.number,
|
|
62
|
+
accessibilityControls: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
63
|
+
accessibilityCurrent: _propTypes.default.oneOf([true, false, 'page', 'step', 'location', 'date', 'time']),
|
|
64
|
+
accessibilityDescribedBy: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
65
|
+
accessibilityDetails: _propTypes.default.string,
|
|
66
|
+
accessibilityDisabled: _propTypes.default.bool,
|
|
67
|
+
accessibilityErrorMessage: _propTypes.default.string,
|
|
68
|
+
accessibilityExpanded: _propTypes.default.bool,
|
|
69
|
+
accessibilityFlowTo: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
70
|
+
accessibilityHasPopup: _propTypes.default.string,
|
|
71
|
+
accessibilityHidden: _propTypes.default.bool,
|
|
72
|
+
accessibilityInvalid: _propTypes.default.bool,
|
|
73
|
+
accessibilityKeyShortcuts: _propTypes.default.string,
|
|
74
|
+
accessibilityLabelledBy: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
75
|
+
accessibilityLevel: _propTypes.default.number,
|
|
76
|
+
accessibilityModal: _propTypes.default.bool,
|
|
77
|
+
accessibilityMultiline: _propTypes.default.bool,
|
|
78
|
+
accessibilityMultiSelectable: _propTypes.default.bool,
|
|
79
|
+
accessibilityOrientation: _propTypes.default.oneOf(['horizontal', 'vertical']),
|
|
80
|
+
accessibilityOwns: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
81
|
+
accessibilityPlaceholder: _propTypes.default.string,
|
|
82
|
+
accessibilityPosInSet: _propTypes.default.number,
|
|
83
|
+
accessibilityPressed: _propTypes.default.bool,
|
|
84
|
+
accessibilityReadOnly: _propTypes.default.bool,
|
|
85
|
+
accessibilityRequired: _propTypes.default.bool,
|
|
86
|
+
accessibilityRoleDescription: _propTypes.default.string,
|
|
87
|
+
accessibilityRowCount: _propTypes.default.number,
|
|
88
|
+
accessibilityRowIndex: _propTypes.default.number,
|
|
89
|
+
accessibilityRowSpan: _propTypes.default.number,
|
|
90
|
+
accessibilitySelected: _propTypes.default.bool,
|
|
91
|
+
accessibilitySetSize: _propTypes.default.number,
|
|
92
|
+
accessibilitySort: _propTypes.default.oneOf(['ascending', 'descending', 'none', 'other']),
|
|
93
|
+
accessibilityValueMax: _propTypes.default.number,
|
|
94
|
+
accessibilityValueMin: _propTypes.default.number,
|
|
95
|
+
accessibilityValueNow: _propTypes.default.number,
|
|
96
|
+
accessibilityValueText: _propTypes.default.string
|
|
97
|
+
};
|
|
98
|
+
var _default = {
|
|
99
|
+
/**
|
|
100
|
+
* Proptypes for recognised React Native accessiblity (a11y) props.
|
|
101
|
+
* Spread this in the propTypes of components that accept React Native a11y props.
|
|
102
|
+
*/
|
|
103
|
+
types: a11yPropTypes,
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Filters a props object, returning only recognised React Native accessiblity (a11y) props.
|
|
107
|
+
*
|
|
108
|
+
* Where components accept React Native a11y props, pass { ...rest } from its props to this,
|
|
109
|
+
* then spread the returned object into the component's props (usually its outer container).
|
|
110
|
+
*/
|
|
111
|
+
select: (0, _getPropSelector.default)(a11yPropTypes, /^aria-/),
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Use this to disable focus for elements which are visually hidden but still rendered.
|
|
115
|
+
*/
|
|
116
|
+
nonFocusableProps: {
|
|
117
|
+
focusable: false,
|
|
118
|
+
// for android, and for keyboard nav in web
|
|
119
|
+
..._Platform.default.select({
|
|
120
|
+
web: {
|
|
121
|
+
accessibilityHidden: true // web screenreaders
|
|
122
|
+
|
|
123
|
+
},
|
|
124
|
+
android: {
|
|
125
|
+
importantForAccessibility: 'no-hide-descendants'
|
|
126
|
+
},
|
|
127
|
+
ios: {
|
|
128
|
+
accessibilityElementsHidden: true
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Generates an object of platform-appropriate a11y props describing an item that has an
|
|
135
|
+
* ordered position in a set. Examples of usage by accessibility tools includes screenreaders
|
|
136
|
+
* saying "Item X of Y" when this item is select.
|
|
137
|
+
*
|
|
138
|
+
* @param {number} itemsCount - the number of items in the set
|
|
139
|
+
* @param {number} index - the current item's index in the set
|
|
140
|
+
* @returns {object} - platform-applicable a11y props describing this position (if available)
|
|
141
|
+
*/
|
|
142
|
+
getPositionInSet: (itemsCount, index) => _Platform.default.select({
|
|
143
|
+
web: {
|
|
144
|
+
// accessibilityPosInSet etc exists in React Native Web main branch
|
|
145
|
+
// but not in a release compatible with Expo etc; just use `aria-*`
|
|
146
|
+
'aria-setsize': itemsCount,
|
|
147
|
+
'aria-posinset': index + 1
|
|
148
|
+
},
|
|
149
|
+
// No equivalents exist on the native side
|
|
150
|
+
default: {}
|
|
151
|
+
})
|
|
152
|
+
};
|
|
153
|
+
exports.default = _default;
|