@telus-uds/components-base 1.23.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 +10 -2
- package/component-docs.json +11 -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-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/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/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
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
|
+
|
|
7
15
|
## 1.23.0
|
|
8
16
|
|
|
9
|
-
Wed, 14 Dec 2022 01:
|
|
17
|
+
Wed, 14 Dec 2022 01:46:10 GMT
|
|
10
18
|
|
|
11
19
|
### Minor changes
|
|
12
20
|
|
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",
|
|
@@ -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;
|
|
@@ -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;
|
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
|