@telus-uds/components-base 1.22.0 → 1.24.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/CHANGELOG.md +22 -2
- package/component-docs.json +26 -0
- package/lib/ActivityIndicator/Spinner.js +6 -4
- package/lib/ActivityIndicator/Spinner.native.js +8 -6
- package/lib/ActivityIndicator/index.js +10 -3
- package/lib/ActivityIndicator/shared.js +2 -1
- package/lib/Checkbox/CheckboxGroup.js +2 -0
- package/lib/Feedback/Feedback.js +4 -3
- package/lib/Fieldset/Fieldset.js +1 -1
- package/lib/List/PressableListItemBase.js +1 -0
- package/lib/Radio/RadioGroup.js +5 -1
- package/lib-module/ActivityIndicator/Spinner.js +6 -4
- package/lib-module/ActivityIndicator/Spinner.native.js +8 -6
- package/lib-module/ActivityIndicator/index.js +10 -3
- package/lib-module/ActivityIndicator/shared.js +2 -1
- package/lib-module/Checkbox/CheckboxGroup.js +2 -0
- package/lib-module/Feedback/Feedback.js +4 -3
- package/lib-module/Fieldset/Fieldset.js +1 -1
- package/lib-module/List/PressableListItemBase.js +1 -0
- package/lib-module/Radio/RadioGroup.js +5 -1
- package/package.json +1 -1
- package/src/ActivityIndicator/Spinner.jsx +5 -6
- package/src/ActivityIndicator/Spinner.native.jsx +7 -6
- package/src/ActivityIndicator/index.jsx +9 -3
- package/src/ActivityIndicator/shared.js +2 -1
- package/src/Checkbox/CheckboxGroup.jsx +2 -0
- package/src/Feedback/Feedback.jsx +11 -3
- package/src/Fieldset/Fieldset.jsx +6 -1
- package/src/List/PressableListItemBase.jsx +1 -0
- package/src/Radio/RadioGroup.jsx +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-base
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 15 Dec 2022 23:06:31 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.24.0
|
|
8
|
+
|
|
9
|
+
Thu, 15 Dec 2022 23:06:31 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- Add `isStatic` prop to `ActivityIndicator` and `Spinner` (shahzaibkhalidmalik@outlook.com)
|
|
14
|
+
|
|
15
|
+
## 1.23.0
|
|
16
|
+
|
|
17
|
+
Wed, 14 Dec 2022 01:46:10 GMT
|
|
18
|
+
|
|
19
|
+
### Minor changes
|
|
20
|
+
|
|
21
|
+
- undefined (mauricio.batresmontejo@telus.com)
|
|
22
|
+
|
|
23
|
+
### Patches
|
|
24
|
+
|
|
25
|
+
- chore: new design to error feedback for radio group (mauricio.batresmontejo@telus.com)
|
|
26
|
+
|
|
7
27
|
## 1.22.0
|
|
8
28
|
|
|
9
|
-
Wed, 07 Dec 2022 15:
|
|
29
|
+
Wed, 07 Dec 2022 15:14:20 GMT
|
|
10
30
|
|
|
11
31
|
### Minor changes
|
|
12
32
|
|
package/component-docs.json
CHANGED
|
@@ -2541,6 +2541,17 @@
|
|
|
2541
2541
|
"docs": {
|
|
2542
2542
|
"description": "`ActivityIndicator` renders a visual loading state.\nIt does not handle positioning or layout of that visual loader.",
|
|
2543
2543
|
"props": {
|
|
2544
|
+
"isStatic": {
|
|
2545
|
+
"defaultValue": {
|
|
2546
|
+
"value": "false",
|
|
2547
|
+
"computed": false
|
|
2548
|
+
},
|
|
2549
|
+
"type": {
|
|
2550
|
+
"name": "bool"
|
|
2551
|
+
},
|
|
2552
|
+
"required": false,
|
|
2553
|
+
"description": "If true, it should render a static spinner"
|
|
2554
|
+
},
|
|
2544
2555
|
"variant": {
|
|
2545
2556
|
"type": {
|
|
2546
2557
|
"name": "objectOf",
|
|
@@ -3452,6 +3463,17 @@
|
|
|
3452
3463
|
"docs": {
|
|
3453
3464
|
"description": "A feedback box commonly used with form fields.\n\n### Standalone usage\nWhile its primary use is to facilitate feedback states for other form components such as `TextInput`,\nyou may use it standalone.\n\n### Complex content\nYou may pass any React tree as the children of this component, bear in mind that a render function\nis better suited for styling children based on Feedback's variant.\n\n### Using a render function\nWhen a function is passed for rendering content, it will receive the feedback text styles and\nvariant as arguments.\n\n### Accessibility\nAll accessibility props set on this component will be applied to the outer container.",
|
|
3454
3465
|
"props": {
|
|
3466
|
+
"showFeedbackIcon": {
|
|
3467
|
+
"defaultValue": {
|
|
3468
|
+
"value": "false",
|
|
3469
|
+
"computed": false
|
|
3470
|
+
},
|
|
3471
|
+
"type": {
|
|
3472
|
+
"name": "bool"
|
|
3473
|
+
},
|
|
3474
|
+
"required": false,
|
|
3475
|
+
"description": ""
|
|
3476
|
+
},
|
|
3455
3477
|
"title": {
|
|
3456
3478
|
"type": {
|
|
3457
3479
|
"name": "string"
|
|
@@ -12299,6 +12321,10 @@
|
|
|
12299
12321
|
"name": "func",
|
|
12300
12322
|
"required": false
|
|
12301
12323
|
},
|
|
12324
|
+
"description": {
|
|
12325
|
+
"name": "string",
|
|
12326
|
+
"required": false
|
|
12327
|
+
},
|
|
12302
12328
|
"ref": {
|
|
12303
12329
|
"name": "custom",
|
|
12304
12330
|
"raw": "ABBPropTypes.ref()",
|
|
@@ -39,11 +39,13 @@ const Spinner = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
39
39
|
size,
|
|
40
40
|
color,
|
|
41
41
|
thickness,
|
|
42
|
-
label
|
|
42
|
+
label,
|
|
43
|
+
isStatic = false
|
|
43
44
|
} = _ref;
|
|
44
45
|
const {
|
|
45
46
|
reduceMotionEnabled
|
|
46
47
|
} = (0, _A11yInfoProvider.useA11yInfo)();
|
|
48
|
+
const reduceMotion = reduceMotionEnabled || isStatic;
|
|
47
49
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
|
|
48
50
|
ref: ref,
|
|
49
51
|
width: "".concat(size, "px"),
|
|
@@ -53,7 +55,7 @@ const Spinner = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
53
55
|
role: "progressbar",
|
|
54
56
|
"aria-busy": true,
|
|
55
57
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
|
|
56
|
-
children: [
|
|
58
|
+
children: [reduceMotion ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)("animateTransform", {
|
|
57
59
|
attributeName: "transform",
|
|
58
60
|
type: "rotate",
|
|
59
61
|
values: "-180 24 24;".concat(360 + _shared.MIN_STROKE_ANGLE - 180, " 24 24"),
|
|
@@ -66,9 +68,9 @@ const Spinner = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
66
68
|
cx: "24",
|
|
67
69
|
cy: "24",
|
|
68
70
|
r: "20",
|
|
69
|
-
strokeDasharray:
|
|
71
|
+
strokeDasharray: reduceMotion ? MAX_SVG_LENGTH : [MIN_SVG_LENGTH, SVG_CIRCUMFERENCE],
|
|
70
72
|
strokeDashoffset: 0,
|
|
71
|
-
children:
|
|
73
|
+
children: reduceMotion ? null : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
72
74
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("animate", {
|
|
73
75
|
attributeName: "stroke-dashoffset",
|
|
74
76
|
values: "0;-10;".concat(MIN_SVG_LENGTH - SVG_CIRCUMFERENCE),
|
|
@@ -34,7 +34,8 @@ const Spinner = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
34
34
|
size,
|
|
35
35
|
color,
|
|
36
36
|
thickness,
|
|
37
|
-
label
|
|
37
|
+
label,
|
|
38
|
+
isStatic = false
|
|
38
39
|
} = _ref;
|
|
39
40
|
|
|
40
41
|
const {
|
|
@@ -44,6 +45,7 @@ const Spinner = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
44
45
|
const {
|
|
45
46
|
reduceMotionEnabled
|
|
46
47
|
} = (0, _A11yInfoProvider.useA11yInfo)();
|
|
48
|
+
const reduceMotion = reduceMotionEnabled || isStatic;
|
|
47
49
|
|
|
48
50
|
_react.default.useLayoutEffect(() => {
|
|
49
51
|
const loop = _Animated.default.timing(timer, {
|
|
@@ -55,8 +57,8 @@ const Spinner = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
55
57
|
isInteraction: false
|
|
56
58
|
});
|
|
57
59
|
|
|
58
|
-
if (!
|
|
59
|
-
}, [timer,
|
|
60
|
+
if (!reduceMotion) _Animated.default.loop(loop).start();else loop.stop();
|
|
61
|
+
}, [timer, reduceMotion]);
|
|
60
62
|
|
|
61
63
|
const frames = 60 * _shared.DURATION / 1000;
|
|
62
64
|
|
|
@@ -64,10 +66,10 @@ const Spinner = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
64
66
|
|
|
65
67
|
const containerStyle = {
|
|
66
68
|
width: size,
|
|
67
|
-
height: size / (
|
|
69
|
+
height: size / (reduceMotion ? 1.5 : 2),
|
|
68
70
|
overflow: 'hidden'
|
|
69
71
|
};
|
|
70
|
-
const animationFrequency =
|
|
72
|
+
const animationFrequency = reduceMotion ? [0] : [0, 1]; // Credit to https://github.com/n4kz/react-native-indicators and https://github.com/callstack/react-native-paper for this
|
|
71
73
|
|
|
72
74
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
73
75
|
ref: ref,
|
|
@@ -106,7 +108,7 @@ const Spinner = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
106
108
|
height: size
|
|
107
109
|
};
|
|
108
110
|
|
|
109
|
-
if (!
|
|
111
|
+
if (!reduceMotion) {
|
|
110
112
|
layerStyle.transform = [{
|
|
111
113
|
rotate: timer.interpolate({
|
|
112
114
|
inputRange: [0, 1],
|
|
@@ -27,7 +27,8 @@ const ActivityIndicator = _ref => {
|
|
|
27
27
|
let {
|
|
28
28
|
variant,
|
|
29
29
|
tokens,
|
|
30
|
-
label
|
|
30
|
+
label,
|
|
31
|
+
isStatic = false
|
|
31
32
|
} = _ref;
|
|
32
33
|
const {
|
|
33
34
|
size,
|
|
@@ -38,7 +39,8 @@ const ActivityIndicator = _ref => {
|
|
|
38
39
|
size: size,
|
|
39
40
|
color: color,
|
|
40
41
|
thickness: thickness,
|
|
41
|
-
label: label
|
|
42
|
+
label: label,
|
|
43
|
+
isStatic: isStatic
|
|
42
44
|
});
|
|
43
45
|
};
|
|
44
46
|
|
|
@@ -49,7 +51,12 @@ ActivityIndicator.propTypes = {
|
|
|
49
51
|
/**
|
|
50
52
|
* A visually hidden accessible label describing the action taking place
|
|
51
53
|
*/
|
|
52
|
-
label: _propTypes.default.string.isRequired
|
|
54
|
+
label: _propTypes.default.string.isRequired,
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* If true, it should render a static spinner
|
|
58
|
+
*/
|
|
59
|
+
isStatic: _propTypes.default.bool
|
|
53
60
|
};
|
|
54
61
|
var _default = ActivityIndicator;
|
|
55
62
|
exports.default = _default;
|
|
@@ -22,6 +22,7 @@ const propTypes = {
|
|
|
22
22
|
color: _propTypes.default.string.isRequired,
|
|
23
23
|
label: _propTypes.default.string.isRequired,
|
|
24
24
|
size: _propTypes.default.number.isRequired,
|
|
25
|
-
thickness: _propTypes.default.number.isRequired
|
|
25
|
+
thickness: _propTypes.default.number.isRequired,
|
|
26
|
+
isStatic: _propTypes.default.bool
|
|
26
27
|
};
|
|
27
28
|
exports.propTypes = propTypes;
|
|
@@ -162,6 +162,8 @@ const CheckboxGroup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
162
162
|
feedback: feedback,
|
|
163
163
|
inactive: inactive,
|
|
164
164
|
validation: validation,
|
|
165
|
+
showIcon: true,
|
|
166
|
+
showErrorBorder: true,
|
|
165
167
|
...selectProps(rest),
|
|
166
168
|
children: (0, _StackView.getStackedContent)(checkboxes, {
|
|
167
169
|
space,
|
package/lib/Feedback/Feedback.js
CHANGED
|
@@ -105,12 +105,12 @@ const Feedback = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
|
|
|
105
105
|
validation,
|
|
106
106
|
tokens,
|
|
107
107
|
variant,
|
|
108
|
-
|
|
108
|
+
showFeedbackIcon = false,
|
|
109
109
|
...rest
|
|
110
110
|
} = _ref5;
|
|
111
111
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Feedback', tokens, { ...variant,
|
|
112
112
|
validation,
|
|
113
|
-
icon
|
|
113
|
+
icon: showFeedbackIcon
|
|
114
114
|
});
|
|
115
115
|
const {
|
|
116
116
|
space
|
|
@@ -176,7 +176,8 @@ Feedback.propTypes = { ...selectedSystemPropTypes,
|
|
|
176
176
|
/** @ignore */
|
|
177
177
|
id: _propTypes.default.string,
|
|
178
178
|
tokens: (0, _utils.getTokensPropType)('Feedback'),
|
|
179
|
-
variant: _utils.variantProp.propType
|
|
179
|
+
variant: _utils.variantProp.propType,
|
|
180
|
+
showFeedbackIcon: _propTypes.default.bool
|
|
180
181
|
};
|
|
181
182
|
var _default = Feedback;
|
|
182
183
|
exports.default = _default;
|
package/lib/Fieldset/Fieldset.js
CHANGED
|
@@ -78,7 +78,7 @@ const Fieldset = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
78
78
|
id: feedbackId,
|
|
79
79
|
title: feedback,
|
|
80
80
|
validation: validation,
|
|
81
|
-
|
|
81
|
+
showFeedbackIcon: showIcon
|
|
82
82
|
}); // Some accessibility patterns depend on elements being direct children, e.g. fieldset -> legend,
|
|
83
83
|
// and on MacOS voiceover, radiogroup -> radio. To allow elements to be direct children of the
|
|
84
84
|
// fieldset as much as possible, but also allow different spacing within content and between
|
|
@@ -132,6 +132,7 @@ const staticStyles = _StyleSheet.default.create({
|
|
|
132
132
|
PressableListItemBase.propTypes = { ..._utils.withLinkRouter.propTypes,
|
|
133
133
|
href: _propTypes.default.string,
|
|
134
134
|
onPress: _propTypes.default.func,
|
|
135
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
135
136
|
tokens: _propTypes.default.any,
|
|
136
137
|
icon: _propTypes.default.elementType,
|
|
137
138
|
children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
package/lib/Radio/RadioGroup.js
CHANGED
|
@@ -131,6 +131,7 @@ const RadioGroup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
131
131
|
id,
|
|
132
132
|
onChange: itemOnChange,
|
|
133
133
|
ref: itemRef,
|
|
134
|
+
description,
|
|
134
135
|
...itemRest
|
|
135
136
|
} = _ref2;
|
|
136
137
|
const radioId = id || "Radio[".concat(index, "]");
|
|
@@ -142,7 +143,6 @@ const RadioGroup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
142
143
|
};
|
|
143
144
|
|
|
144
145
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Radio.default, {
|
|
145
|
-
error: validation === 'error',
|
|
146
146
|
ref: itemRef,
|
|
147
147
|
id: radioId,
|
|
148
148
|
checked: isChecked,
|
|
@@ -152,6 +152,7 @@ const RadioGroup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
152
152
|
name: inputGroupName,
|
|
153
153
|
tokens: radioTokens,
|
|
154
154
|
variant: variant,
|
|
155
|
+
description: description,
|
|
155
156
|
...selectItemProps(itemRest)
|
|
156
157
|
}, radioId);
|
|
157
158
|
});
|
|
@@ -167,6 +168,8 @@ const RadioGroup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
167
168
|
feedback: feedback,
|
|
168
169
|
inactive: inactive,
|
|
169
170
|
validation: validation,
|
|
171
|
+
showIcon: true,
|
|
172
|
+
showErrorBorder: true,
|
|
170
173
|
accessibilityRole: "radiogroup",
|
|
171
174
|
...selectProps(rest),
|
|
172
175
|
children: (0, _StackView.getStackedContent)(radios, {
|
|
@@ -205,6 +208,7 @@ RadioGroup.propTypes = { ...selectedSystemPropTypes,
|
|
|
205
208
|
label: _propTypes.default.string,
|
|
206
209
|
id: _propTypes.default.string,
|
|
207
210
|
onChange: _propTypes.default.func,
|
|
211
|
+
description: _propTypes.default.string,
|
|
208
212
|
ref: _airbnbPropTypes.default.ref()
|
|
209
213
|
})),
|
|
210
214
|
|
|
@@ -26,11 +26,13 @@ const Spinner = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
26
26
|
size,
|
|
27
27
|
color,
|
|
28
28
|
thickness,
|
|
29
|
-
label
|
|
29
|
+
label,
|
|
30
|
+
isStatic = false
|
|
30
31
|
} = _ref;
|
|
31
32
|
const {
|
|
32
33
|
reduceMotionEnabled
|
|
33
34
|
} = useA11yInfo();
|
|
35
|
+
const reduceMotion = reduceMotionEnabled || isStatic;
|
|
34
36
|
return /*#__PURE__*/_jsx("svg", {
|
|
35
37
|
ref: ref,
|
|
36
38
|
width: "".concat(size, "px"),
|
|
@@ -40,7 +42,7 @@ const Spinner = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
40
42
|
role: "progressbar",
|
|
41
43
|
"aria-busy": true,
|
|
42
44
|
children: /*#__PURE__*/_jsxs("g", {
|
|
43
|
-
children: [
|
|
45
|
+
children: [reduceMotion ? null : /*#__PURE__*/_jsx("animateTransform", {
|
|
44
46
|
attributeName: "transform",
|
|
45
47
|
type: "rotate",
|
|
46
48
|
values: "-180 24 24;".concat(360 + MIN_STROKE_ANGLE - 180, " 24 24"),
|
|
@@ -53,9 +55,9 @@ const Spinner = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
53
55
|
cx: "24",
|
|
54
56
|
cy: "24",
|
|
55
57
|
r: "20",
|
|
56
|
-
strokeDasharray:
|
|
58
|
+
strokeDasharray: reduceMotion ? MAX_SVG_LENGTH : [MIN_SVG_LENGTH, SVG_CIRCUMFERENCE],
|
|
57
59
|
strokeDashoffset: 0,
|
|
58
|
-
children:
|
|
60
|
+
children: reduceMotion ? null : /*#__PURE__*/_jsxs(_Fragment, {
|
|
59
61
|
children: [/*#__PURE__*/_jsx("animate", {
|
|
60
62
|
attributeName: "stroke-dashoffset",
|
|
61
63
|
values: "0;-10;".concat(MIN_SVG_LENGTH - SVG_CIRCUMFERENCE),
|
|
@@ -13,7 +13,8 @@ const Spinner = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
13
13
|
size,
|
|
14
14
|
color,
|
|
15
15
|
thickness,
|
|
16
|
-
label
|
|
16
|
+
label,
|
|
17
|
+
isStatic = false
|
|
17
18
|
} = _ref;
|
|
18
19
|
const {
|
|
19
20
|
current: timer
|
|
@@ -21,6 +22,7 @@ const Spinner = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
21
22
|
const {
|
|
22
23
|
reduceMotionEnabled
|
|
23
24
|
} = useA11yInfo();
|
|
25
|
+
const reduceMotion = reduceMotionEnabled || isStatic;
|
|
24
26
|
React.useLayoutEffect(() => {
|
|
25
27
|
const loop = Animated.timing(timer, {
|
|
26
28
|
duration: DURATION,
|
|
@@ -30,16 +32,16 @@ const Spinner = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
30
32
|
toValue: 1,
|
|
31
33
|
isInteraction: false
|
|
32
34
|
});
|
|
33
|
-
if (!
|
|
34
|
-
}, [timer,
|
|
35
|
+
if (!reduceMotion) Animated.loop(loop).start();else loop.stop();
|
|
36
|
+
}, [timer, reduceMotion]);
|
|
35
37
|
const frames = 60 * DURATION / 1000;
|
|
36
38
|
const easing = Easing.bezier(...BEZIER);
|
|
37
39
|
const containerStyle = {
|
|
38
40
|
width: size,
|
|
39
|
-
height: size / (
|
|
41
|
+
height: size / (reduceMotion ? 1.5 : 2),
|
|
40
42
|
overflow: 'hidden'
|
|
41
43
|
};
|
|
42
|
-
const animationFrequency =
|
|
44
|
+
const animationFrequency = reduceMotion ? [0] : [0, 1]; // Credit to https://github.com/n4kz/react-native-indicators and https://github.com/callstack/react-native-paper for this
|
|
43
45
|
|
|
44
46
|
return /*#__PURE__*/_jsx(View, {
|
|
45
47
|
ref: ref,
|
|
@@ -78,7 +80,7 @@ const Spinner = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
78
80
|
height: size
|
|
79
81
|
};
|
|
80
82
|
|
|
81
|
-
if (!
|
|
83
|
+
if (!reduceMotion) {
|
|
82
84
|
layerStyle.transform = [{
|
|
83
85
|
rotate: timer.interpolate({
|
|
84
86
|
inputRange: [0, 1],
|
|
@@ -14,7 +14,8 @@ const ActivityIndicator = _ref => {
|
|
|
14
14
|
let {
|
|
15
15
|
variant,
|
|
16
16
|
tokens,
|
|
17
|
-
label
|
|
17
|
+
label,
|
|
18
|
+
isStatic = false
|
|
18
19
|
} = _ref;
|
|
19
20
|
const {
|
|
20
21
|
size,
|
|
@@ -25,7 +26,8 @@ const ActivityIndicator = _ref => {
|
|
|
25
26
|
size: size,
|
|
26
27
|
color: color,
|
|
27
28
|
thickness: thickness,
|
|
28
|
-
label: label
|
|
29
|
+
label: label,
|
|
30
|
+
isStatic: isStatic
|
|
29
31
|
});
|
|
30
32
|
};
|
|
31
33
|
|
|
@@ -36,6 +38,11 @@ ActivityIndicator.propTypes = {
|
|
|
36
38
|
/**
|
|
37
39
|
* A visually hidden accessible label describing the action taking place
|
|
38
40
|
*/
|
|
39
|
-
label: PropTypes.string.isRequired
|
|
41
|
+
label: PropTypes.string.isRequired,
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* If true, it should render a static spinner
|
|
45
|
+
*/
|
|
46
|
+
isStatic: PropTypes.bool
|
|
40
47
|
};
|
|
41
48
|
export default ActivityIndicator;
|
|
@@ -139,6 +139,8 @@ const CheckboxGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
139
139
|
feedback: feedback,
|
|
140
140
|
inactive: inactive,
|
|
141
141
|
validation: validation,
|
|
142
|
+
showIcon: true,
|
|
143
|
+
showErrorBorder: true,
|
|
142
144
|
...selectProps(rest),
|
|
143
145
|
children: getStackedContent(checkboxes, {
|
|
144
146
|
space,
|
|
@@ -84,12 +84,12 @@ const Feedback = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
84
84
|
validation,
|
|
85
85
|
tokens,
|
|
86
86
|
variant,
|
|
87
|
-
|
|
87
|
+
showFeedbackIcon = false,
|
|
88
88
|
...rest
|
|
89
89
|
} = _ref5;
|
|
90
90
|
const themeTokens = useThemeTokens('Feedback', tokens, { ...variant,
|
|
91
91
|
validation,
|
|
92
|
-
icon
|
|
92
|
+
icon: showFeedbackIcon
|
|
93
93
|
});
|
|
94
94
|
const {
|
|
95
95
|
space
|
|
@@ -155,7 +155,8 @@ Feedback.propTypes = { ...selectedSystemPropTypes,
|
|
|
155
155
|
/** @ignore */
|
|
156
156
|
id: PropTypes.string,
|
|
157
157
|
tokens: getTokensPropType('Feedback'),
|
|
158
|
-
variant: variantProp.propType
|
|
158
|
+
variant: variantProp.propType,
|
|
159
|
+
showFeedbackIcon: PropTypes.bool
|
|
159
160
|
};
|
|
160
161
|
export default Feedback;
|
|
161
162
|
const staticStyles = StyleSheet.create({
|
|
@@ -59,7 +59,7 @@ const Fieldset = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
59
59
|
id: feedbackId,
|
|
60
60
|
title: feedback,
|
|
61
61
|
validation: validation,
|
|
62
|
-
|
|
62
|
+
showFeedbackIcon: showIcon
|
|
63
63
|
}); // Some accessibility patterns depend on elements being direct children, e.g. fieldset -> legend,
|
|
64
64
|
// and on MacOS voiceover, radiogroup -> radio. To allow elements to be direct children of the
|
|
65
65
|
// fieldset as much as possible, but also allow different spacing within content and between
|
|
@@ -105,6 +105,7 @@ const staticStyles = StyleSheet.create({
|
|
|
105
105
|
PressableListItemBase.propTypes = { ...withLinkRouter.propTypes,
|
|
106
106
|
href: PropTypes.string,
|
|
107
107
|
onPress: PropTypes.func,
|
|
108
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
108
109
|
tokens: PropTypes.any,
|
|
109
110
|
icon: PropTypes.elementType,
|
|
110
111
|
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
@@ -108,6 +108,7 @@ const RadioGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
108
108
|
id,
|
|
109
109
|
onChange: itemOnChange,
|
|
110
110
|
ref: itemRef,
|
|
111
|
+
description,
|
|
111
112
|
...itemRest
|
|
112
113
|
} = _ref2;
|
|
113
114
|
const radioId = id || "Radio[".concat(index, "]");
|
|
@@ -119,7 +120,6 @@ const RadioGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
119
120
|
};
|
|
120
121
|
|
|
121
122
|
return /*#__PURE__*/_jsx(Radio, {
|
|
122
|
-
error: validation === 'error',
|
|
123
123
|
ref: itemRef,
|
|
124
124
|
id: radioId,
|
|
125
125
|
checked: isChecked,
|
|
@@ -129,6 +129,7 @@ const RadioGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
129
129
|
name: inputGroupName,
|
|
130
130
|
tokens: radioTokens,
|
|
131
131
|
variant: variant,
|
|
132
|
+
description: description,
|
|
132
133
|
...selectItemProps(itemRest)
|
|
133
134
|
}, radioId);
|
|
134
135
|
});
|
|
@@ -144,6 +145,8 @@ const RadioGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
144
145
|
feedback: feedback,
|
|
145
146
|
inactive: inactive,
|
|
146
147
|
validation: validation,
|
|
148
|
+
showIcon: true,
|
|
149
|
+
showErrorBorder: true,
|
|
147
150
|
accessibilityRole: "radiogroup",
|
|
148
151
|
...selectProps(rest),
|
|
149
152
|
children: getStackedContent(radios, {
|
|
@@ -182,6 +185,7 @@ RadioGroup.propTypes = { ...selectedSystemPropTypes,
|
|
|
182
185
|
label: PropTypes.string,
|
|
183
186
|
id: PropTypes.string,
|
|
184
187
|
onChange: PropTypes.func,
|
|
188
|
+
description: PropTypes.string,
|
|
185
189
|
ref: ABBPropTypes.ref()
|
|
186
190
|
})),
|
|
187
191
|
|
package/package.json
CHANGED
|
@@ -21,8 +21,9 @@ const bezierProps = {
|
|
|
21
21
|
}
|
|
22
22
|
// We're using svg rather than css here to define the animation to avoid needing to introduce css injection mechanism
|
|
23
23
|
// It's possible to replicate this functionality with RNW animations, but it snags on chrome at least, see https://github.com/telus/universal-design-system/pull/477 for details.
|
|
24
|
-
const Spinner = forwardRef(({ size, color, thickness, label }, ref) => {
|
|
24
|
+
const Spinner = forwardRef(({ size, color, thickness, label, isStatic = false }, ref) => {
|
|
25
25
|
const { reduceMotionEnabled } = useA11yInfo()
|
|
26
|
+
const reduceMotion = reduceMotionEnabled || isStatic
|
|
26
27
|
return (
|
|
27
28
|
<svg
|
|
28
29
|
ref={ref}
|
|
@@ -34,7 +35,7 @@ const Spinner = forwardRef(({ size, color, thickness, label }, ref) => {
|
|
|
34
35
|
aria-busy={true}
|
|
35
36
|
>
|
|
36
37
|
<g>
|
|
37
|
-
{
|
|
38
|
+
{reduceMotion ? null : (
|
|
38
39
|
<animateTransform
|
|
39
40
|
attributeName="transform"
|
|
40
41
|
type="rotate"
|
|
@@ -50,12 +51,10 @@ const Spinner = forwardRef(({ size, color, thickness, label }, ref) => {
|
|
|
50
51
|
cx="24"
|
|
51
52
|
cy="24"
|
|
52
53
|
r="20"
|
|
53
|
-
strokeDasharray={
|
|
54
|
-
reduceMotionEnabled ? MAX_SVG_LENGTH : [MIN_SVG_LENGTH, SVG_CIRCUMFERENCE]
|
|
55
|
-
}
|
|
54
|
+
strokeDasharray={reduceMotion ? MAX_SVG_LENGTH : [MIN_SVG_LENGTH, SVG_CIRCUMFERENCE]}
|
|
56
55
|
strokeDashoffset={0}
|
|
57
56
|
>
|
|
58
|
-
{
|
|
57
|
+
{reduceMotion ? null : (
|
|
59
58
|
<>
|
|
60
59
|
<animate
|
|
61
60
|
attributeName="stroke-dashoffset"
|
|
@@ -6,9 +6,10 @@ import { useA11yInfo } from '../A11yInfoProvider'
|
|
|
6
6
|
const ea = MIN_EMPTY_ANGLE / 2
|
|
7
7
|
const sa = MIN_STROKE_ANGLE / 2
|
|
8
8
|
|
|
9
|
-
const Spinner = forwardRef(({ size, color, thickness, label }, ref) => {
|
|
9
|
+
const Spinner = forwardRef(({ size, color, thickness, label, isStatic = false }, ref) => {
|
|
10
10
|
const { current: timer } = React.useRef(new Animated.Value(0))
|
|
11
11
|
const { reduceMotionEnabled } = useA11yInfo()
|
|
12
|
+
const reduceMotion = reduceMotionEnabled || isStatic
|
|
12
13
|
|
|
13
14
|
React.useLayoutEffect(() => {
|
|
14
15
|
const loop = Animated.timing(timer, {
|
|
@@ -20,18 +21,18 @@ const Spinner = forwardRef(({ size, color, thickness, label }, ref) => {
|
|
|
20
21
|
isInteraction: false
|
|
21
22
|
})
|
|
22
23
|
|
|
23
|
-
if (!
|
|
24
|
+
if (!reduceMotion) Animated.loop(loop).start()
|
|
24
25
|
else loop.stop()
|
|
25
|
-
}, [timer,
|
|
26
|
+
}, [timer, reduceMotion])
|
|
26
27
|
|
|
27
28
|
const frames = (60 * DURATION) / 1000
|
|
28
29
|
const easing = Easing.bezier(...BEZIER)
|
|
29
30
|
const containerStyle = {
|
|
30
31
|
width: size,
|
|
31
|
-
height: size / (
|
|
32
|
+
height: size / (reduceMotion ? 1.5 : 2),
|
|
32
33
|
overflow: 'hidden'
|
|
33
34
|
}
|
|
34
|
-
const animationFrequency =
|
|
35
|
+
const animationFrequency = reduceMotion ? [0] : [0, 1]
|
|
35
36
|
|
|
36
37
|
// Credit to https://github.com/n4kz/react-native-indicators and https://github.com/callstack/react-native-paper for this
|
|
37
38
|
return (
|
|
@@ -72,7 +73,7 @@ const Spinner = forwardRef(({ size, color, thickness, label }, ref) => {
|
|
|
72
73
|
height: size
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
if (!
|
|
76
|
+
if (!reduceMotion) {
|
|
76
77
|
layerStyle.transform = [
|
|
77
78
|
{
|
|
78
79
|
rotate: timer.interpolate({
|
|
@@ -9,9 +9,11 @@ import Spinner from './Spinner'
|
|
|
9
9
|
* `ActivityIndicator` renders a visual loading state.
|
|
10
10
|
* It does not handle positioning or layout of that visual loader.
|
|
11
11
|
*/
|
|
12
|
-
const ActivityIndicator = ({ variant, tokens, label }) => {
|
|
12
|
+
const ActivityIndicator = ({ variant, tokens, label, isStatic = false }) => {
|
|
13
13
|
const { size, color, thickness } = useThemeTokens('ActivityIndicator', tokens, variant)
|
|
14
|
-
return
|
|
14
|
+
return (
|
|
15
|
+
<Spinner size={size} color={color} thickness={thickness} label={label} isStatic={isStatic} />
|
|
16
|
+
)
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
ActivityIndicator.propTypes = {
|
|
@@ -20,7 +22,11 @@ ActivityIndicator.propTypes = {
|
|
|
20
22
|
/**
|
|
21
23
|
* A visually hidden accessible label describing the action taking place
|
|
22
24
|
*/
|
|
23
|
-
label: PropTypes.string.isRequired
|
|
25
|
+
label: PropTypes.string.isRequired,
|
|
26
|
+
/**
|
|
27
|
+
* If true, it should render a static spinner
|
|
28
|
+
*/
|
|
29
|
+
isStatic: PropTypes.bool
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
export default ActivityIndicator
|
|
@@ -56,8 +56,15 @@ const selectIconContainerStyles = ({ iconGap }) => ({
|
|
|
56
56
|
* All accessibility props set on this component will be applied to the outer container.
|
|
57
57
|
*/
|
|
58
58
|
const Feedback = forwardRef(
|
|
59
|
-
(
|
|
60
|
-
|
|
59
|
+
(
|
|
60
|
+
{ title, children, id, validation, tokens, variant, showFeedbackIcon = false, ...rest },
|
|
61
|
+
ref
|
|
62
|
+
) => {
|
|
63
|
+
const themeTokens = useThemeTokens('Feedback', tokens, {
|
|
64
|
+
...variant,
|
|
65
|
+
validation,
|
|
66
|
+
icon: showFeedbackIcon
|
|
67
|
+
})
|
|
61
68
|
const { space } = themeTokens
|
|
62
69
|
|
|
63
70
|
const { icon: IconComponent } = themeTokens
|
|
@@ -114,7 +121,8 @@ Feedback.propTypes = {
|
|
|
114
121
|
/** @ignore */
|
|
115
122
|
id: PropTypes.string,
|
|
116
123
|
tokens: getTokensPropType('Feedback'),
|
|
117
|
-
variant: variantProp.propType
|
|
124
|
+
variant: variantProp.propType,
|
|
125
|
+
showFeedbackIcon: PropTypes.bool
|
|
118
126
|
}
|
|
119
127
|
|
|
120
128
|
export default Feedback
|
|
@@ -55,7 +55,12 @@ const Fieldset = forwardRef(
|
|
|
55
55
|
/>
|
|
56
56
|
)
|
|
57
57
|
const feedbackContent = feedback && (
|
|
58
|
-
<Feedback
|
|
58
|
+
<Feedback
|
|
59
|
+
id={feedbackId}
|
|
60
|
+
title={feedback}
|
|
61
|
+
validation={validation}
|
|
62
|
+
showFeedbackIcon={showIcon}
|
|
63
|
+
/>
|
|
59
64
|
)
|
|
60
65
|
|
|
61
66
|
// Some accessibility patterns depend on elements being direct children, e.g. fieldset -> legend,
|
|
@@ -91,6 +91,7 @@ PressableListItemBase.propTypes = {
|
|
|
91
91
|
...withLinkRouter.propTypes,
|
|
92
92
|
href: PropTypes.string,
|
|
93
93
|
onPress: PropTypes.func,
|
|
94
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
94
95
|
tokens: PropTypes.any,
|
|
95
96
|
icon: PropTypes.elementType,
|
|
96
97
|
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
package/src/Radio/RadioGroup.jsx
CHANGED
|
@@ -116,17 +116,15 @@ const RadioGroup = forwardRef(
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
const radios = items.map(
|
|
119
|
-
({ label, id, onChange: itemOnChange, ref: itemRef, ...itemRest }, index) => {
|
|
119
|
+
({ label, id, onChange: itemOnChange, ref: itemRef, description, ...itemRest }, index) => {
|
|
120
120
|
const radioId = id || `Radio[${index}]`
|
|
121
121
|
const isChecked = currentValue === radioId
|
|
122
122
|
const handleChange = (newCheckedState, event) => {
|
|
123
123
|
if (typeof itemOnChange === 'function') itemOnChange(newCheckedState, event)
|
|
124
124
|
if (newCheckedState) setValue(radioId, event)
|
|
125
125
|
}
|
|
126
|
-
|
|
127
126
|
return (
|
|
128
127
|
<Radio
|
|
129
|
-
error={validation === 'error'}
|
|
130
128
|
ref={itemRef}
|
|
131
129
|
key={radioId}
|
|
132
130
|
id={radioId}
|
|
@@ -137,6 +135,7 @@ const RadioGroup = forwardRef(
|
|
|
137
135
|
name={inputGroupName}
|
|
138
136
|
tokens={radioTokens}
|
|
139
137
|
variant={variant}
|
|
138
|
+
description={description}
|
|
140
139
|
{...selectItemProps(itemRest)}
|
|
141
140
|
/>
|
|
142
141
|
)
|
|
@@ -156,6 +155,8 @@ const RadioGroup = forwardRef(
|
|
|
156
155
|
feedback={feedback}
|
|
157
156
|
inactive={inactive}
|
|
158
157
|
validation={validation}
|
|
158
|
+
showIcon
|
|
159
|
+
showErrorBorder
|
|
159
160
|
accessibilityRole="radiogroup"
|
|
160
161
|
{...selectProps(rest)}
|
|
161
162
|
>
|
|
@@ -193,6 +194,7 @@ RadioGroup.propTypes = {
|
|
|
193
194
|
label: PropTypes.string,
|
|
194
195
|
id: PropTypes.string,
|
|
195
196
|
onChange: PropTypes.func,
|
|
197
|
+
description: PropTypes.string,
|
|
196
198
|
ref: ABBPropTypes.ref()
|
|
197
199
|
})
|
|
198
200
|
),
|