@coinbase/cds-mobile 8.28.2 → 8.30.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 +15 -0
- package/dts/alpha/combobox/Combobox.d.ts +73 -0
- package/dts/alpha/combobox/Combobox.d.ts.map +1 -0
- package/dts/alpha/combobox/DefaultComboboxControl.d.ts +20 -0
- package/dts/alpha/combobox/DefaultComboboxControl.d.ts.map +1 -0
- package/dts/alpha/select/DefaultSelectControl.d.ts +1 -0
- package/dts/alpha/select/DefaultSelectControl.d.ts.map +1 -1
- package/dts/alpha/select/DefaultSelectDropdown.d.ts.map +1 -1
- package/dts/alpha/select/types.d.ts +4 -1
- package/dts/alpha/select/types.d.ts.map +1 -1
- package/dts/alpha/select-chip/SelectChip.d.ts +12 -6
- package/dts/alpha/select-chip/SelectChip.d.ts.map +1 -1
- package/dts/alpha/select-chip/SelectChipControl.d.ts +1 -0
- package/dts/alpha/select-chip/SelectChipControl.d.ts.map +1 -1
- package/dts/alpha/tabbed-chips/TabbedChips.d.ts +5 -0
- package/dts/alpha/tabbed-chips/TabbedChips.d.ts.map +1 -1
- package/dts/chips/Chip.d.ts +1 -1
- package/dts/chips/Chip.d.ts.map +1 -1
- package/dts/chips/ChipProps.d.ts +1 -1
- package/dts/chips/ChipProps.d.ts.map +1 -1
- package/dts/chips/InputChip.d.ts +1 -1
- package/dts/chips/InputChip.d.ts.map +1 -1
- package/dts/chips/MediaChip.d.ts +1 -1
- package/dts/chips/MediaChip.d.ts.map +1 -1
- package/dts/hooks/useHorizontalScrollToTarget.d.ts +10 -0
- package/dts/hooks/useHorizontalScrollToTarget.d.ts.map +1 -1
- package/dts/overlays/drawer/Drawer.d.ts.map +1 -1
- package/dts/overlays/tray/Tray.d.ts +8 -0
- package/dts/overlays/tray/Tray.d.ts.map +1 -1
- package/esm/alpha/combobox/Combobox.js +194 -0
- package/esm/alpha/combobox/DefaultComboboxControl.js +80 -0
- package/esm/alpha/combobox/__stories__/Combobox.stories.js +1019 -0
- package/esm/alpha/select/DefaultSelectControl.js +25 -23
- package/esm/alpha/select/DefaultSelectDropdown.js +80 -75
- package/esm/alpha/select/__stories__/AlphaSelect.stories.js +24 -4
- package/esm/alpha/select-chip/SelectChip.js +8 -5
- package/esm/alpha/select-chip/SelectChipControl.js +6 -2
- package/esm/alpha/select-chip/__stories__/{SelectChip.stories.js → AlphaSelectChip.stories.js} +42 -0
- package/esm/alpha/tabbed-chips/TabbedChips.js +12 -5
- package/esm/alpha/tabbed-chips/__stories__/AlphaTabbedChips.stories.js +9 -1
- package/esm/buttons/__stories__/SlideButton.stories.js +11 -6
- package/esm/carousel/__stories__/Carousel.stories.js +5 -4
- package/esm/hooks/useHorizontalScrollToTarget.js +16 -5
- package/esm/overlays/drawer/Drawer.js +14 -3
- package/esm/overlays/tray/Tray.js +17 -5
- package/esm/visualizations/__stories__/ProgressCircle.stories.js +3 -3
- package/package.json +2 -2
|
@@ -14,8 +14,7 @@ import { useTheme } from '../../hooks/useTheme';
|
|
|
14
14
|
import { Box, HStack, VStack } from '../../layout';
|
|
15
15
|
import { RemoteImage } from '../../media';
|
|
16
16
|
import { Pressable } from '../../system/Pressable';
|
|
17
|
-
import { Link,
|
|
18
|
-
import { Text } from '../../typography/Text';
|
|
17
|
+
import { Link, Text } from '../../typography';
|
|
19
18
|
import { Carousel } from '../Carousel';
|
|
20
19
|
import { CarouselItem } from '../CarouselItem';
|
|
21
20
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -92,7 +91,8 @@ const sampleItems = [/*#__PURE__*/_jsx(SampleCard, {
|
|
|
92
91
|
}, "9"), /*#__PURE__*/_jsx(SampleCard, {
|
|
93
92
|
text: "Slide 10"
|
|
94
93
|
}, "10")];
|
|
95
|
-
const SeeAllComponent = () => /*#__PURE__*/_jsx(
|
|
94
|
+
const SeeAllComponent = () => /*#__PURE__*/_jsx(Text, {
|
|
95
|
+
font: "headline",
|
|
96
96
|
children: /*#__PURE__*/_jsx(Link, {
|
|
97
97
|
to: "https://coinbase.com/",
|
|
98
98
|
children: "See all"
|
|
@@ -459,8 +459,9 @@ const AnimatedExample = () => {
|
|
|
459
459
|
return /*#__PURE__*/_jsx(Animated.View, {
|
|
460
460
|
style: animatedStyle,
|
|
461
461
|
children: /*#__PURE__*/_jsx(ContainedAssetCard, {
|
|
462
|
-
description: /*#__PURE__*/_jsx(
|
|
462
|
+
description: /*#__PURE__*/_jsx(Text, {
|
|
463
463
|
color: "fgPositive",
|
|
464
|
+
font: "label2",
|
|
464
465
|
numberOfLines: 2,
|
|
465
466
|
children: "\u21976.37%"
|
|
466
467
|
}),
|
|
@@ -4,11 +4,19 @@ import throttle from 'lodash/throttle';
|
|
|
4
4
|
* A hook for managing horizontal scrolling with overflow detection.
|
|
5
5
|
* Useful for horizontally scrollable content that needs to show overflow indicators.
|
|
6
6
|
* Optionally handles scrolling to an active target element.
|
|
7
|
+
*
|
|
8
|
+
* @param scrollThrottleWaitTime - Throttle time for scroll events (default: 200ms)
|
|
9
|
+
* @param activeTarget - The active element to scroll to when it's offscreen
|
|
10
|
+
* @param autoScrollOffset - X position offset when auto-scrolling to active target
|
|
11
|
+
* @param overflowThreshold - Threshold for detecting if content is offscreen (default: 1)
|
|
7
12
|
*/
|
|
13
|
+
|
|
8
14
|
export const useHorizontalScrollToTarget = function (_temp) {
|
|
9
15
|
let {
|
|
10
16
|
scrollThrottleWaitTime = 200,
|
|
11
|
-
activeTarget
|
|
17
|
+
activeTarget,
|
|
18
|
+
autoScrollOffset = 0,
|
|
19
|
+
overflowThreshold = 1
|
|
12
20
|
} = _temp === void 0 ? {} : _temp;
|
|
13
21
|
const scrollRef = useRef(null);
|
|
14
22
|
const scrollDetails = useRef({
|
|
@@ -18,6 +26,7 @@ export const useHorizontalScrollToTarget = function (_temp) {
|
|
|
18
26
|
});
|
|
19
27
|
const [isScrollContentOverflowing, setIsScrollContentOverflowing] = useState(false);
|
|
20
28
|
const [isScrollContentOffscreenRight, setIsScrollContentOffscreenRight] = useState(false);
|
|
29
|
+
const [isScrollContentOffscreenLeft, setIsScrollContentOffscreenLeft] = useState(false);
|
|
21
30
|
const checkScrollState = useCallback(() => {
|
|
22
31
|
const {
|
|
23
32
|
xPosition,
|
|
@@ -26,8 +35,9 @@ export const useHorizontalScrollToTarget = function (_temp) {
|
|
|
26
35
|
} = scrollDetails.current;
|
|
27
36
|
const maxScroll = contentWidth - containerWidth;
|
|
28
37
|
setIsScrollContentOverflowing(contentWidth > containerWidth);
|
|
29
|
-
setIsScrollContentOffscreenRight(xPosition < maxScroll -
|
|
30
|
-
|
|
38
|
+
setIsScrollContentOffscreenRight(xPosition < maxScroll - overflowThreshold); // -1 offset for fractional values
|
|
39
|
+
setIsScrollContentOffscreenLeft(xPosition > overflowThreshold); // 1 offset for fractional values
|
|
40
|
+
}, [overflowThreshold]);
|
|
31
41
|
const throttledHandleScroll = useRef(throttle(xPosition => {
|
|
32
42
|
scrollDetails.current.xPosition = xPosition;
|
|
33
43
|
checkScrollState();
|
|
@@ -56,7 +66,7 @@ export const useHorizontalScrollToTarget = function (_temp) {
|
|
|
56
66
|
if (isOffscreenLeft || isOffscreenRight) {
|
|
57
67
|
var _scrollRef$current;
|
|
58
68
|
(_scrollRef$current = scrollRef.current) == null || _scrollRef$current.scrollTo({
|
|
59
|
-
x,
|
|
69
|
+
x: x - autoScrollOffset,
|
|
60
70
|
y: 0,
|
|
61
71
|
animated: true
|
|
62
72
|
});
|
|
@@ -64,11 +74,12 @@ export const useHorizontalScrollToTarget = function (_temp) {
|
|
|
64
74
|
});
|
|
65
75
|
}
|
|
66
76
|
return () => throttledHandleScroll.cancel();
|
|
67
|
-
}, [activeTarget, throttledHandleScroll]);
|
|
77
|
+
}, [activeTarget, autoScrollOffset, throttledHandleScroll]);
|
|
68
78
|
return {
|
|
69
79
|
scrollRef,
|
|
70
80
|
isScrollContentOverflowing,
|
|
71
81
|
isScrollContentOffscreenRight,
|
|
82
|
+
isScrollContentOffscreenLeft,
|
|
72
83
|
handleScroll,
|
|
73
84
|
handleScrollContainerLayout,
|
|
74
85
|
handleScrollContentSizeChange
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const _excluded = ["children", "pin", "onCloseComplete", "preventDismissGestures", "preventHardwareBackBehaviorAndroid", "hideHandleBar", "disableCapturePanGestureToDismiss", "onBlur", "verticalDrawerPercentageOfView", "handleBarAccessibilityLabel"];
|
|
2
2
|
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); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
|
-
import React, { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
5
|
-
import { Animated, Modal, Platform, StyleSheet, useWindowDimensions } from 'react-native';
|
|
4
|
+
import React, { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
5
|
+
import { Animated, Keyboard, Modal, Platform, StyleSheet, useWindowDimensions } from 'react-native';
|
|
6
6
|
import { drawerAnimationDefaultDuration, MAX_OVER_DRAG } from '@coinbase/cds-common/animation/drawer';
|
|
7
7
|
import { OverlayContentContext } from '@coinbase/cds-common/overlays/OverlayContentContext';
|
|
8
8
|
import { horizontalDrawerPercentageOfView, verticalDrawerPercentageOfView as defaultVerticalDrawerPercentageOfView } from '@coinbase/cds-common/tokens/drawer';
|
|
@@ -103,8 +103,19 @@ export const Drawer = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Drawer(
|
|
|
103
103
|
|
|
104
104
|
// leave 15% of the screenwidth as open area for menu drawer
|
|
105
105
|
const horizontalDrawerWidth = useMemo(() => width * horizontalDrawerPercentageOfView + MAX_OVER_DRAG, [width]);
|
|
106
|
+
const [keyboardInset, setKeyboardInset] = useState(0);
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
if (Platform.OS !== 'android') return;
|
|
109
|
+
const show = Keyboard.addListener('keyboardDidShow', e => setKeyboardInset(e.endCoordinates.height));
|
|
110
|
+
const hide = Keyboard.addListener('keyboardDidHide', () => setKeyboardInset(0));
|
|
111
|
+
return () => {
|
|
112
|
+
show.remove();
|
|
113
|
+
hide.remove();
|
|
114
|
+
};
|
|
115
|
+
}, []);
|
|
116
|
+
|
|
106
117
|
// drawer will automatically size itself based on content, but will cap at 75% of viewport height (can override)
|
|
107
|
-
const verticalDrawerMaxHeight = useMemo(() => height * verticalDrawerPercentageOfView + MAX_OVER_DRAG, [height, verticalDrawerPercentageOfView]);
|
|
118
|
+
const verticalDrawerMaxHeight = useMemo(() => height * verticalDrawerPercentageOfView + MAX_OVER_DRAG - keyboardInset, [height, verticalDrawerPercentageOfView, keyboardInset]);
|
|
108
119
|
const getPanGestureHandlers = !preventDismissGestures ? panGestureHandlers.panHandlers : undefined;
|
|
109
120
|
const handleOverlayPress = useCallback(() => {
|
|
110
121
|
if (!preventDismissGestures) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["children", "title", "onVisibilityChange", "verticalDrawerPercentageOfView"];
|
|
1
|
+
const _excluded = ["children", "header", "footer", "title", "onVisibilityChange", "verticalDrawerPercentageOfView"];
|
|
2
2
|
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); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
4
|
import React, { createContext, forwardRef, memo, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
@@ -16,6 +16,8 @@ export const TrayContext = /*#__PURE__*/createContext({
|
|
|
16
16
|
export const Tray = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Tray(_ref, ref) {
|
|
17
17
|
let {
|
|
18
18
|
children,
|
|
19
|
+
header,
|
|
20
|
+
footer,
|
|
19
21
|
title,
|
|
20
22
|
onVisibilityChange,
|
|
21
23
|
verticalDrawerPercentageOfView = defaultVerticalDrawerPercentageOfView
|
|
@@ -30,7 +32,13 @@ export const Tray = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Tray(_ref
|
|
|
30
32
|
let {
|
|
31
33
|
handleClose
|
|
32
34
|
} = _ref2;
|
|
35
|
+
const content = typeof children === 'function' ? children({
|
|
36
|
+
handleClose
|
|
37
|
+
}) : children;
|
|
33
38
|
return /*#__PURE__*/_jsxs(VStack, {
|
|
39
|
+
flexGrow: 1,
|
|
40
|
+
flexShrink: 1,
|
|
41
|
+
minHeight: 0,
|
|
34
42
|
paddingTop: title ? 0 : 2,
|
|
35
43
|
children: [title && (typeof title === 'string' ? /*#__PURE__*/_jsx(HStack, {
|
|
36
44
|
alignItems: "center",
|
|
@@ -45,11 +53,15 @@ export const Tray = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Tray(_ref
|
|
|
45
53
|
}) : /*#__PURE__*/_jsx(Box, {
|
|
46
54
|
onLayout: onTitleLayout,
|
|
47
55
|
children: title
|
|
48
|
-
})),
|
|
49
|
-
|
|
50
|
-
|
|
56
|
+
})), header, /*#__PURE__*/_jsx(Box, {
|
|
57
|
+
flexGrow: 1,
|
|
58
|
+
flexShrink: 1,
|
|
59
|
+
minHeight: 0,
|
|
60
|
+
width: "100%",
|
|
61
|
+
children: content
|
|
62
|
+
}), footer]
|
|
51
63
|
});
|
|
52
|
-
}, [children, onTitleLayout, title]);
|
|
64
|
+
}, [children, footer, header, onTitleLayout, title]);
|
|
53
65
|
useEffect(() => {
|
|
54
66
|
onVisibilityChange == null || onVisibilityChange('visible');
|
|
55
67
|
return () => {
|
|
@@ -8,8 +8,7 @@ import { Icon } from '../../icons';
|
|
|
8
8
|
import { Box, HStack, VStack } from '../../layout';
|
|
9
9
|
import { RemoteImage } from '../../media';
|
|
10
10
|
import { defaultTheme } from '../../themes/defaultTheme';
|
|
11
|
-
import {
|
|
12
|
-
import { Text } from '../../typography/Text';
|
|
11
|
+
import { Text } from '../../typography';
|
|
13
12
|
import { theme } from '../../utils/testHelpers';
|
|
14
13
|
import { DefaultProgressCircleContent } from '../DefaultProgressCircleContent';
|
|
15
14
|
import { ProgressCircle } from '../ProgressCircle';
|
|
@@ -22,8 +21,9 @@ const CustomStyles = () => {
|
|
|
22
21
|
children: [/*#__PURE__*/_jsxs(HStack, {
|
|
23
22
|
gap: 2,
|
|
24
23
|
children: [/*#__PURE__*/_jsx(ProgressCircle, {
|
|
25
|
-
contentNode: /*#__PURE__*/_jsx(
|
|
24
|
+
contentNode: /*#__PURE__*/_jsx(Text, {
|
|
26
25
|
color: disabled ? 'fgMuted' : 'fgPrimary',
|
|
26
|
+
font: "title1",
|
|
27
27
|
children: "40%"
|
|
28
28
|
}),
|
|
29
29
|
disabled: disabled,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cds-mobile",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.30.0",
|
|
4
4
|
"description": "Coinbase Design System - Mobile",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"react-native-svg": "^14.1.0"
|
|
155
155
|
},
|
|
156
156
|
"dependencies": {
|
|
157
|
-
"@coinbase/cds-common": "^8.
|
|
157
|
+
"@coinbase/cds-common": "^8.30.0",
|
|
158
158
|
"@coinbase/cds-icons": "^5.8.0",
|
|
159
159
|
"@coinbase/cds-illustrations": "^4.29.0",
|
|
160
160
|
"@coinbase/cds-lottie-files": "^3.3.3",
|