@coinbase/cds-mobile 8.59.0 → 8.60.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 +6 -0
- package/dts/buttons/Button.d.ts +8 -0
- package/dts/buttons/Button.d.ts.map +1 -1
- package/dts/buttons/DefaultSlideButtonHandle.d.ts.map +1 -1
- package/dts/buttons/IconButton.d.ts +12 -7
- package/dts/buttons/IconButton.d.ts.map +1 -1
- package/dts/controls/InputIconButton.d.ts +1 -1
- package/dts/loaders/Spinner.d.ts +4 -0
- package/dts/loaders/Spinner.d.ts.map +1 -1
- package/dts/visualizations/ProgressBar.d.ts +2 -2
- package/dts/visualizations/ProgressBar.d.ts.map +1 -1
- package/dts/visualizations/ProgressBarWithFloatLabel.d.ts.map +1 -1
- package/dts/visualizations/ProgressCircle.d.ts +9 -1
- package/dts/visualizations/ProgressCircle.d.ts.map +1 -1
- package/esm/alpha/select/__stories__/AlphaSelect.stories.js +13 -9
- package/esm/buttons/Button.js +10 -5
- package/esm/buttons/DefaultSlideButtonHandle.js +7 -6
- package/esm/buttons/IconButton.js +18 -8
- package/esm/buttons/__stories__/Button.stories.js +28 -0
- package/esm/buttons/__stories__/IconButton.stories.js +116 -1
- package/esm/loaders/Spinner.js +5 -0
- package/esm/overlays/__stories__/AlertBasic.stories.js +2 -2
- package/esm/overlays/__stories__/AlertLongTitle.stories.js +2 -2
- package/esm/overlays/__stories__/AlertOverModal.stories.js +2 -10
- package/esm/overlays/__stories__/AlertPortal.stories.js +2 -6
- package/esm/overlays/__stories__/AlertSingleAction.stories.js +2 -2
- package/esm/overlays/__stories__/AlertVerticalActions.stories.js +2 -2
- package/esm/overlays/__stories__/DrawerFallback.stories.js +20 -13
- package/esm/overlays/__stories__/DrawerScrollable.stories.js +8 -1
- package/esm/overlays/__stories__/Drawers.js +4 -4
- package/esm/overlays/__stories__/ModalBackButton.stories.js +2 -2
- package/esm/overlays/__stories__/ModalBasic.stories.js +2 -2
- package/esm/overlays/__stories__/ModalCustomPadding.stories.js +2 -2
- package/esm/overlays/__stories__/ModalLong.stories.js +2 -2
- package/esm/overlays/__stories__/ModalPortal.stories.js +2 -6
- package/esm/overlays/__stories__/Overlay.stories.js +2 -6
- package/esm/overlays/__stories__/TrayNavigation.stories.js +6 -2
- package/esm/overlays/__stories__/Trays.js +20 -11
- package/esm/sticky-footer/__stories__/StickyFooter.stories.js +2 -2
- package/esm/sticky-footer/__stories__/StickyFooterWithTray.stories.js +3 -3
- package/esm/visualizations/DefaultProgressCircleContent.js +1 -1
- package/esm/visualizations/ProgressBar.js +3 -3
- package/esm/visualizations/ProgressBarWithFloatLabel.js +19 -28
- package/esm/visualizations/ProgressCircle.js +80 -60
- package/esm/visualizations/__stories__/ProgressCircle.stories.js +63 -11
- package/package.json +2 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
2
|
import React, { forwardRef, memo, useEffect, useMemo, useRef } from 'react';
|
|
3
|
-
import { Animated } from 'react-native';
|
|
3
|
+
import { Animated, StyleSheet } from 'react-native';
|
|
4
4
|
import { Circle, G, Svg } from 'react-native-svg';
|
|
5
5
|
import { animateProgressBaseSpec } from '@coinbase/cds-common/animation/progress';
|
|
6
6
|
import { getCircumference, getRadius } from '@coinbase/cds-common/utils/circle';
|
|
7
7
|
import { getProgressCircleParams } from '@coinbase/cds-common/visualizations/getProgressCircleParams';
|
|
8
|
-
import {
|
|
8
|
+
import { getProgressSize } from '@coinbase/cds-common/visualizations/getProgressSize';
|
|
9
9
|
import { isTest } from '@coinbase/cds-utils';
|
|
10
10
|
import { convertMotionConfig } from '../animation/convertMotionConfig';
|
|
11
11
|
import { useTheme } from '../hooks/useTheme';
|
|
@@ -14,19 +14,19 @@ import { DefaultProgressCircleContent } from './DefaultProgressCircleContent';
|
|
|
14
14
|
import { VisualizationContainer } from './VisualizationContainer';
|
|
15
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
16
|
const AnimatedCircle = Animated.createAnimatedComponent(Circle);
|
|
17
|
+
const AnimatedSvg = Animated.createAnimatedComponent(Svg);
|
|
17
18
|
const ProgressCircleInner = /*#__PURE__*/memo(_ref => {
|
|
18
19
|
let {
|
|
19
20
|
size,
|
|
20
|
-
progress,
|
|
21
|
+
progress = 0,
|
|
21
22
|
color,
|
|
22
|
-
|
|
23
|
+
strokeWidth,
|
|
23
24
|
visuallyDisabled,
|
|
24
25
|
style,
|
|
25
26
|
onAnimationEnd,
|
|
26
27
|
onAnimationStart,
|
|
27
28
|
disableAnimateOnMount
|
|
28
29
|
} = _ref;
|
|
29
|
-
const strokeWidth = useProgressSize(weight);
|
|
30
30
|
const theme = useTheme();
|
|
31
31
|
const circleRef = useRef(null);
|
|
32
32
|
const circumference = getCircumference(getRadius(size, strokeWidth));
|
|
@@ -47,8 +47,7 @@ const ProgressCircleInner = /*#__PURE__*/memo(_ref => {
|
|
|
47
47
|
});
|
|
48
48
|
}, [circumference, progress, animatedStrokeDashOffset, onAnimationStart, onAnimationEnd]);
|
|
49
49
|
return /*#__PURE__*/_jsx(AnimatedCircle, _extends({
|
|
50
|
-
ref: !isTest() ? circleRef : undefined
|
|
51
|
-
,
|
|
50
|
+
ref: !isTest() ? circleRef : undefined,
|
|
52
51
|
strokeDasharray: circumference,
|
|
53
52
|
strokeDashoffset: animatedStrokeDashOffset.current,
|
|
54
53
|
strokeLinecap: progress > 0 ? 'round' : 'butt',
|
|
@@ -61,14 +60,15 @@ const ProgressCircleInner = /*#__PURE__*/memo(_ref => {
|
|
|
61
60
|
});
|
|
62
61
|
export const ProgressCircle = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref3, forwardedRef) => {
|
|
63
62
|
let {
|
|
63
|
+
indeterminate,
|
|
64
64
|
weight = 'normal',
|
|
65
|
-
progress,
|
|
65
|
+
progress = indeterminate ? 0.75 : 0,
|
|
66
66
|
// Default is empty string due to iOS VoiceOver repeating percentage multiple times when
|
|
67
67
|
// a11y label isn't specified
|
|
68
|
-
accessibilityLabel = '',
|
|
69
|
-
color = 'bgPrimary',
|
|
68
|
+
accessibilityLabel = indeterminate ? 'Loading' : '',
|
|
69
|
+
color = indeterminate ? 'fgMuted' : 'bgPrimary',
|
|
70
70
|
disabled,
|
|
71
|
-
disableAnimateOnMount,
|
|
71
|
+
disableAnimateOnMount = indeterminate ? true : false,
|
|
72
72
|
testID,
|
|
73
73
|
hideContent,
|
|
74
74
|
hideText,
|
|
@@ -80,12 +80,25 @@ export const ProgressCircle = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref3,
|
|
|
80
80
|
onAnimationStart
|
|
81
81
|
} = _ref3;
|
|
82
82
|
const theme = useTheme();
|
|
83
|
-
const strokeWidth =
|
|
83
|
+
const strokeWidth = getProgressSize(weight);
|
|
84
84
|
const visSize = size != null ? size : '100%';
|
|
85
85
|
const rootStyle = useMemo(() => [style, styles == null ? void 0 : styles.root], [style, styles == null ? void 0 : styles.root]);
|
|
86
86
|
const textContainerStyle = useMemo(() => [{
|
|
87
87
|
padding: strokeWidth
|
|
88
88
|
}, styles == null ? void 0 : styles.textContainer], [strokeWidth, styles == null ? void 0 : styles.textContainer]);
|
|
89
|
+
const animatedRotate = useRef(new Animated.Value(0));
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (!indeterminate) return;
|
|
92
|
+
// if indeterminate, animate the rotation of the svg
|
|
93
|
+
const animation = Animated.loop(Animated.timing(animatedRotate.current, convertMotionConfig({
|
|
94
|
+
toValue: 1,
|
|
95
|
+
duration: 'slow4',
|
|
96
|
+
easing: 'linear',
|
|
97
|
+
fromValue: 0
|
|
98
|
+
})));
|
|
99
|
+
animation.start();
|
|
100
|
+
return () => animation.stop();
|
|
101
|
+
}, [indeterminate]);
|
|
89
102
|
return /*#__PURE__*/_jsx(VisualizationContainer, {
|
|
90
103
|
height: visSize,
|
|
91
104
|
width: visSize,
|
|
@@ -95,12 +108,12 @@ export const ProgressCircle = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref3,
|
|
|
95
108
|
height,
|
|
96
109
|
circleSize
|
|
97
110
|
} = _ref4;
|
|
98
|
-
return /*#__PURE__*/
|
|
111
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
99
112
|
ref: forwardedRef,
|
|
100
113
|
accessible: true,
|
|
101
114
|
accessibilityLabel: accessibilityLabel,
|
|
102
115
|
accessibilityRole: "progressbar",
|
|
103
|
-
accessibilityValue: {
|
|
116
|
+
accessibilityValue: indeterminate ? undefined : {
|
|
104
117
|
min: 0,
|
|
105
118
|
max: 100,
|
|
106
119
|
now: Math.round(progress * 100)
|
|
@@ -111,57 +124,64 @@ export const ProgressCircle = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref3,
|
|
|
111
124
|
style: rootStyle,
|
|
112
125
|
testID: testID,
|
|
113
126
|
width: width,
|
|
114
|
-
children: /*#__PURE__*/
|
|
115
|
-
flexGrow: 0,
|
|
116
|
-
flexShrink: 0,
|
|
127
|
+
children: [/*#__PURE__*/_jsx(AnimatedSvg, {
|
|
117
128
|
height: circleSize,
|
|
118
|
-
style: styles == null ? void 0 : styles.
|
|
129
|
+
style: [styles == null ? void 0 : styles.svg, styleSheet.svg, {
|
|
130
|
+
transform: [{
|
|
131
|
+
rotate: animatedRotate.current.interpolate({
|
|
132
|
+
inputRange: [0, 1],
|
|
133
|
+
outputRange: ['0deg', '360deg']
|
|
134
|
+
})
|
|
135
|
+
}]
|
|
136
|
+
}],
|
|
137
|
+
viewBox: "0 0 " + circleSize + " " + circleSize,
|
|
119
138
|
width: circleSize,
|
|
120
|
-
children:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
139
|
+
children: /*#__PURE__*/_jsxs(G, {
|
|
140
|
+
origin: circleSize / 2 + ", " + circleSize / 2,
|
|
141
|
+
rotation: -90,
|
|
142
|
+
children: [/*#__PURE__*/_jsx(Circle, _extends({}, getProgressCircleParams({
|
|
143
|
+
size: circleSize,
|
|
144
|
+
strokeWidth,
|
|
145
|
+
stroke: theme.color.bgLine
|
|
146
|
+
}), (styles == null ? void 0 : styles.circle) || {})), /*#__PURE__*/_jsx(ProgressCircleInner, {
|
|
147
|
+
color: color,
|
|
148
|
+
disableAnimateOnMount: disableAnimateOnMount,
|
|
149
|
+
indeterminate: indeterminate,
|
|
150
|
+
onAnimationEnd: onAnimationEnd,
|
|
151
|
+
onAnimationStart: onAnimationStart,
|
|
152
|
+
progress: progress,
|
|
153
|
+
size: circleSize,
|
|
154
|
+
strokeWidth: strokeWidth,
|
|
155
|
+
style: styles == null ? void 0 : styles.progress,
|
|
156
|
+
visuallyDisabled: disabled
|
|
157
|
+
})]
|
|
158
|
+
})
|
|
159
|
+
}, circleSize), !hideText && !hideContent && /*#__PURE__*/_jsx(Box, {
|
|
160
|
+
height: "100%",
|
|
161
|
+
position: "absolute",
|
|
162
|
+
style: textContainerStyle,
|
|
163
|
+
width: "100%",
|
|
164
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
165
|
+
alignItems: "center",
|
|
166
|
+
borderRadius: 1000,
|
|
145
167
|
height: "100%",
|
|
146
|
-
|
|
147
|
-
|
|
168
|
+
justifyContent: "center",
|
|
169
|
+
overflow: "hidden",
|
|
148
170
|
width: "100%",
|
|
149
|
-
children: /*#__PURE__*/_jsx(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
justifyContent: "center",
|
|
154
|
-
overflow: "hidden",
|
|
155
|
-
width: "100%",
|
|
156
|
-
children: contentNode != null ? contentNode : /*#__PURE__*/_jsx(DefaultProgressCircleContent, {
|
|
157
|
-
disableAnimateOnMount: disableAnimateOnMount,
|
|
158
|
-
disabled: disabled,
|
|
159
|
-
progress: progress
|
|
160
|
-
})
|
|
171
|
+
children: contentNode != null ? contentNode : !indeterminate && /*#__PURE__*/_jsx(DefaultProgressCircleContent, {
|
|
172
|
+
disableAnimateOnMount: disableAnimateOnMount,
|
|
173
|
+
disabled: disabled,
|
|
174
|
+
progress: progress
|
|
161
175
|
})
|
|
162
|
-
})
|
|
163
|
-
})
|
|
176
|
+
})
|
|
177
|
+
})]
|
|
164
178
|
});
|
|
165
179
|
}
|
|
166
180
|
});
|
|
167
|
-
}));
|
|
181
|
+
}));
|
|
182
|
+
const styleSheet = StyleSheet.create({
|
|
183
|
+
svg: {
|
|
184
|
+
flexGrow: 0,
|
|
185
|
+
flexShrink: 0
|
|
186
|
+
}
|
|
187
|
+
});
|
|
@@ -111,12 +111,64 @@ const ProgressBarScreen = () => {
|
|
|
111
111
|
}
|
|
112
112
|
})
|
|
113
113
|
}), /*#__PURE__*/_jsx(Example, {
|
|
114
|
-
title: "
|
|
114
|
+
title: "Indeterminate",
|
|
115
115
|
children: /*#__PURE__*/_jsx(ProgressContainerWithButtons, {
|
|
116
116
|
children: _ref3 => {
|
|
117
117
|
let {
|
|
118
118
|
calculateProgress
|
|
119
119
|
} = _ref3;
|
|
120
|
+
return /*#__PURE__*/_jsxs(HStack, {
|
|
121
|
+
flexWrap: "wrap",
|
|
122
|
+
gap: 2,
|
|
123
|
+
children: [/*#__PURE__*/_jsx(ProgressCircle, {
|
|
124
|
+
indeterminate: true,
|
|
125
|
+
accessibilityLabel: "Loading",
|
|
126
|
+
color: "bgPositive",
|
|
127
|
+
progress: calculateProgress(0.75),
|
|
128
|
+
size: 30
|
|
129
|
+
}), /*#__PURE__*/_jsx(ProgressCircle, {
|
|
130
|
+
indeterminate: true,
|
|
131
|
+
accessibilityLabel: "Loading",
|
|
132
|
+
color: "bgSecondary",
|
|
133
|
+
progress: calculateProgress(0.75),
|
|
134
|
+
size: 30
|
|
135
|
+
}), /*#__PURE__*/_jsx(ProgressCircle, {
|
|
136
|
+
indeterminate: true,
|
|
137
|
+
accessibilityLabel: "Loading",
|
|
138
|
+
disableAnimateOnMount: false,
|
|
139
|
+
progress: calculateProgress(0.75),
|
|
140
|
+
size: 100,
|
|
141
|
+
weight: "thin"
|
|
142
|
+
}), /*#__PURE__*/_jsx(ProgressCircle, {
|
|
143
|
+
indeterminate: true,
|
|
144
|
+
accessibilityLabel: "Loading",
|
|
145
|
+
disableAnimateOnMount: false,
|
|
146
|
+
progress: calculateProgress(0.75),
|
|
147
|
+
size: 100,
|
|
148
|
+
weight: "normal"
|
|
149
|
+
}), /*#__PURE__*/_jsx(ProgressCircle, {
|
|
150
|
+
indeterminate: true,
|
|
151
|
+
accessibilityLabel: "Loading",
|
|
152
|
+
progress: calculateProgress(0.75),
|
|
153
|
+
size: 100,
|
|
154
|
+
weight: "semiheavy"
|
|
155
|
+
}), /*#__PURE__*/_jsx(ProgressCircle, {
|
|
156
|
+
indeterminate: true,
|
|
157
|
+
accessibilityLabel: "Loading",
|
|
158
|
+
progress: calculateProgress(0.75),
|
|
159
|
+
size: 100,
|
|
160
|
+
weight: "heavy"
|
|
161
|
+
})]
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
166
|
+
title: "Heavy",
|
|
167
|
+
children: /*#__PURE__*/_jsx(ProgressContainerWithButtons, {
|
|
168
|
+
children: _ref4 => {
|
|
169
|
+
let {
|
|
170
|
+
calculateProgress
|
|
171
|
+
} = _ref4;
|
|
120
172
|
return /*#__PURE__*/_jsxs(HStack, {
|
|
121
173
|
gap: 2,
|
|
122
174
|
children: [/*#__PURE__*/_jsx(ProgressCircle, {
|
|
@@ -134,10 +186,10 @@ const ProgressBarScreen = () => {
|
|
|
134
186
|
}), /*#__PURE__*/_jsx(Example, {
|
|
135
187
|
title: "NoText",
|
|
136
188
|
children: /*#__PURE__*/_jsx(ProgressContainerWithButtons, {
|
|
137
|
-
children:
|
|
189
|
+
children: _ref5 => {
|
|
138
190
|
let {
|
|
139
191
|
calculateProgress
|
|
140
|
-
} =
|
|
192
|
+
} = _ref5;
|
|
141
193
|
return /*#__PURE__*/_jsxs(HStack, {
|
|
142
194
|
gap: 2,
|
|
143
195
|
children: [/*#__PURE__*/_jsx(ProgressCircle, {
|
|
@@ -201,10 +253,10 @@ const ProgressBarScreen = () => {
|
|
|
201
253
|
}), /*#__PURE__*/_jsx(Example, {
|
|
202
254
|
title: "FillParent",
|
|
203
255
|
children: /*#__PURE__*/_jsx(ProgressContainerWithButtons, {
|
|
204
|
-
children:
|
|
256
|
+
children: _ref6 => {
|
|
205
257
|
let {
|
|
206
258
|
calculateProgress
|
|
207
|
-
} =
|
|
259
|
+
} = _ref6;
|
|
208
260
|
return /*#__PURE__*/_jsxs(HStack, {
|
|
209
261
|
flexWrap: "wrap",
|
|
210
262
|
gap: 2,
|
|
@@ -250,10 +302,10 @@ const ProgressBarScreen = () => {
|
|
|
250
302
|
}), /*#__PURE__*/_jsx(Example, {
|
|
251
303
|
title: "CustomTextColor",
|
|
252
304
|
children: /*#__PURE__*/_jsx(ProgressContainerWithButtons, {
|
|
253
|
-
children:
|
|
305
|
+
children: _ref7 => {
|
|
254
306
|
let {
|
|
255
307
|
calculateProgress
|
|
256
|
-
} =
|
|
308
|
+
} = _ref7;
|
|
257
309
|
return /*#__PURE__*/_jsxs(HStack, {
|
|
258
310
|
gap: 2,
|
|
259
311
|
children: [/*#__PURE__*/_jsx(ProgressCircle, {
|
|
@@ -429,10 +481,10 @@ const ProgressBarScreen = () => {
|
|
|
429
481
|
}), /*#__PURE__*/_jsx(Example, {
|
|
430
482
|
title: "Thin",
|
|
431
483
|
children: /*#__PURE__*/_jsx(ProgressContainerWithButtons, {
|
|
432
|
-
children:
|
|
484
|
+
children: _ref8 => {
|
|
433
485
|
let {
|
|
434
486
|
calculateProgress
|
|
435
|
-
} =
|
|
487
|
+
} = _ref8;
|
|
436
488
|
return /*#__PURE__*/_jsxs(HStack, {
|
|
437
489
|
gap: 2,
|
|
438
490
|
children: [/*#__PURE__*/_jsx(ProgressCircle, {
|
|
@@ -450,10 +502,10 @@ const ProgressBarScreen = () => {
|
|
|
450
502
|
}), /*#__PURE__*/_jsx(Example, {
|
|
451
503
|
title: "Disable Mount Animation",
|
|
452
504
|
children: /*#__PURE__*/_jsx(ProgressContainerWithButtons, {
|
|
453
|
-
children:
|
|
505
|
+
children: _ref9 => {
|
|
454
506
|
let {
|
|
455
507
|
calculateProgress
|
|
456
|
-
} =
|
|
508
|
+
} = _ref9;
|
|
457
509
|
return /*#__PURE__*/_jsx(ProgressCircle, {
|
|
458
510
|
disableAnimateOnMount: true,
|
|
459
511
|
progress: calculateProgress(0.8),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cds-mobile",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.60.0",
|
|
4
4
|
"description": "Coinbase Design System - Mobile",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -197,7 +197,7 @@
|
|
|
197
197
|
"react-native-svg": "^14.1.0"
|
|
198
198
|
},
|
|
199
199
|
"dependencies": {
|
|
200
|
-
"@coinbase/cds-common": "^8.
|
|
200
|
+
"@coinbase/cds-common": "^8.60.0",
|
|
201
201
|
"@coinbase/cds-icons": "^5.13.0",
|
|
202
202
|
"@coinbase/cds-illustrations": "^4.36.0",
|
|
203
203
|
"@coinbase/cds-lottie-files": "^3.3.4",
|