@coinbase/cds-mobile 8.43.2 → 8.44.1
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 +14 -0
- package/dts/alpha/__figma__/Select.figma.d.ts +2 -0
- package/dts/alpha/__figma__/Select.figma.d.ts.map +1 -0
- package/dts/alpha/combobox/Combobox.d.ts.map +1 -1
- package/dts/alpha/data-card/DataCard.d.ts +2 -0
- package/dts/alpha/data-card/DataCard.d.ts.map +1 -1
- package/dts/alpha/data-card/DataCardLayout.d.ts +4 -0
- package/dts/alpha/data-card/DataCardLayout.d.ts.map +1 -1
- package/dts/alpha/select/DefaultSelectControl.d.ts.map +1 -1
- package/dts/alpha/select/types.d.ts +57 -57
- package/dts/alpha/select/types.d.ts.map +1 -1
- package/dts/alpha/tabbed-chips/TabbedChips.d.ts +2 -6
- package/dts/alpha/tabbed-chips/TabbedChips.d.ts.map +1 -1
- package/dts/buttons/SlideButton.d.ts +8 -24
- package/dts/buttons/SlideButton.d.ts.map +1 -1
- package/dts/cards/ContentCard/ContentCardBody.d.ts +8 -24
- package/dts/cards/ContentCard/ContentCardBody.d.ts.map +1 -1
- package/dts/cards/ContentCard/ContentCardHeader.d.ts +6 -18
- package/dts/cards/ContentCard/ContentCardHeader.d.ts.map +1 -1
- package/dts/cards/MediaCard/MediaCardLayout.d.ts +5 -0
- package/dts/cards/MediaCard/MediaCardLayout.d.ts.map +1 -1
- package/dts/cards/MediaCard/index.d.ts +2 -0
- package/dts/cards/MediaCard/index.d.ts.map +1 -1
- package/dts/cards/MessagingCard/MessagingCardLayout.d.ts +5 -0
- package/dts/cards/MessagingCard/MessagingCardLayout.d.ts.map +1 -1
- package/dts/cards/MessagingCard/index.d.ts +2 -0
- package/dts/cards/MessagingCard/index.d.ts.map +1 -1
- package/dts/cells/Cell.d.ts +11 -3
- package/dts/cells/Cell.d.ts.map +1 -1
- package/dts/cells/ContentCell.d.ts +12 -3
- package/dts/cells/ContentCell.d.ts.map +1 -1
- package/dts/cells/ListCell.d.ts +15 -5
- package/dts/cells/ListCell.d.ts.map +1 -1
- package/dts/chips/Chip.d.ts.map +1 -1
- package/dts/chips/ChipProps.d.ts +3 -1
- package/dts/chips/ChipProps.d.ts.map +1 -1
- package/dts/chips/InputChip.d.ts.map +1 -1
- package/dts/chips/MediaChip.d.ts.map +1 -1
- package/dts/controls/CheckboxCell.d.ts +5 -0
- package/dts/controls/CheckboxCell.d.ts.map +1 -1
- package/dts/controls/RadioCell.d.ts +5 -0
- package/dts/controls/RadioCell.d.ts.map +1 -1
- package/dts/dots/DotCount.d.ts +4 -15
- package/dts/dots/DotCount.d.ts.map +1 -1
- package/dts/icons/Icon.d.ts +3 -0
- package/dts/icons/Icon.d.ts.map +1 -1
- package/dts/numbers/RollingNumber/RollingNumber.d.ts +30 -90
- package/dts/numbers/RollingNumber/RollingNumber.d.ts.map +1 -1
- package/dts/overlays/drawer/Drawer.d.ts +56 -13
- package/dts/overlays/drawer/Drawer.d.ts.map +1 -1
- package/dts/overlays/handlebar/HandleBar.d.ts +26 -2
- package/dts/overlays/handlebar/HandleBar.d.ts.map +1 -1
- package/dts/overlays/tray/Tray.d.ts +48 -13
- package/dts/overlays/tray/Tray.d.ts.map +1 -1
- package/dts/page/PageHeader.d.ts +10 -30
- package/dts/page/PageHeader.d.ts.map +1 -1
- package/dts/stepper/Stepper.d.ts +9 -9
- package/dts/stepper/Stepper.d.ts.map +1 -1
- package/dts/visualizations/ProgressBar.d.ts +6 -24
- package/dts/visualizations/ProgressBar.d.ts.map +1 -1
- package/dts/visualizations/ProgressBarWithFixedLabels.d.ts +5 -18
- package/dts/visualizations/ProgressBarWithFixedLabels.d.ts.map +1 -1
- package/dts/visualizations/ProgressBarWithFloatLabel.d.ts +4 -15
- package/dts/visualizations/ProgressBarWithFloatLabel.d.ts.map +1 -1
- package/dts/visualizations/ProgressCircle.d.ts +14 -48
- package/dts/visualizations/ProgressCircle.d.ts.map +1 -1
- package/esm/alpha/__figma__/Select.figma.js +63 -0
- package/esm/alpha/combobox/Combobox.js +29 -24
- package/esm/carousel/__stories__/Carousel.stories.js +7 -7
- package/esm/overlays/__stories__/TrayRedesign.stories.js +1070 -0
- package/esm/overlays/drawer/Drawer.js +64 -37
- package/esm/overlays/handlebar/HandleBar.js +48 -25
- package/esm/overlays/tray/Tray.js +61 -26
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const _excluded = ["children", "pin", "onCloseComplete", "preventDismissGestures", "preventHardwareBackBehaviorAndroid", "hideHandleBar", "disableCapturePanGestureToDismiss", "onBlur", "verticalDrawerPercentageOfView", "handleBarAccessibilityLabel"];
|
|
1
|
+
const _excluded = ["children", "pin", "onCloseComplete", "preventDismissGestures", "preventHardwareBackBehaviorAndroid", "handleBarVariant", "hideHandleBar", "disableCapturePanGestureToDismiss", "onBlur", "verticalDrawerPercentageOfView", "handleBarAccessibilityLabel", "accessibilityLabel", "accessibilityLabelledBy", "style", "styles", "accessibilityRole", "animationType"];
|
|
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, { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
5
|
-
import { Animated, Keyboard, Modal, Platform,
|
|
5
|
+
import { Animated, Keyboard, Modal, Platform, useWindowDimensions, View } 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';
|
|
@@ -19,23 +19,32 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
19
19
|
const overlayContentContextValue = {
|
|
20
20
|
isDrawer: true
|
|
21
21
|
};
|
|
22
|
+
const overflowStyle = {
|
|
23
|
+
overflow: 'hidden',
|
|
24
|
+
maxHeight: '100%'
|
|
25
|
+
};
|
|
22
26
|
export const Drawer = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Drawer(_ref, ref) {
|
|
23
27
|
let {
|
|
24
28
|
children,
|
|
25
29
|
pin = 'bottom',
|
|
26
30
|
onCloseComplete,
|
|
27
|
-
preventDismissGestures
|
|
28
|
-
preventHardwareBackBehaviorAndroid
|
|
29
|
-
|
|
31
|
+
preventDismissGestures,
|
|
32
|
+
preventHardwareBackBehaviorAndroid,
|
|
33
|
+
handleBarVariant = 'outside',
|
|
34
|
+
hideHandleBar,
|
|
30
35
|
disableCapturePanGestureToDismiss = false,
|
|
31
36
|
onBlur,
|
|
32
37
|
verticalDrawerPercentageOfView = defaultVerticalDrawerPercentageOfView,
|
|
33
|
-
handleBarAccessibilityLabel = 'Dismiss'
|
|
38
|
+
handleBarAccessibilityLabel = 'Dismiss',
|
|
39
|
+
accessibilityLabel,
|
|
40
|
+
accessibilityLabelledBy,
|
|
41
|
+
style,
|
|
42
|
+
styles,
|
|
43
|
+
accessibilityRole = 'alert',
|
|
44
|
+
animationType = 'none'
|
|
34
45
|
} = _ref,
|
|
35
46
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
36
|
-
const
|
|
37
|
-
activeColorScheme
|
|
38
|
-
} = useTheme();
|
|
47
|
+
const theme = useTheme();
|
|
39
48
|
const {
|
|
40
49
|
width,
|
|
41
50
|
height
|
|
@@ -49,7 +58,7 @@ export const Drawer = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Drawer(
|
|
|
49
58
|
animateSwipeToClose
|
|
50
59
|
} = useDrawerAnimation(pin, verticalDrawerPercentageOfView);
|
|
51
60
|
const [opacityAnimation, animateOverlayIn, animateOverlayOut] = useOverlayAnimation(drawerAnimationDefaultDuration);
|
|
52
|
-
const
|
|
61
|
+
const paddingStyles = useDrawerSpacing(pin);
|
|
53
62
|
const isMounted = useRef(false);
|
|
54
63
|
const handleClose = useCallback(() => {
|
|
55
64
|
Animated.parallel([animateDrawerOut, animateOverlayOut]).start(_ref2 => {
|
|
@@ -98,8 +107,10 @@ export const Drawer = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Drawer(
|
|
|
98
107
|
opacityAnimation,
|
|
99
108
|
verticalDrawerPercentageOfView
|
|
100
109
|
});
|
|
101
|
-
const
|
|
102
|
-
const
|
|
110
|
+
const isSideDrawer = pin === 'left' || pin === 'right';
|
|
111
|
+
const showHandleBar = !hideHandleBar && pin === 'bottom';
|
|
112
|
+
const showHandleBarOutside = showHandleBar && handleBarVariant === 'outside';
|
|
113
|
+
const showHandleBarInside = showHandleBar && handleBarVariant === 'inside';
|
|
103
114
|
|
|
104
115
|
// leave 15% of the screenwidth as open area for menu drawer
|
|
105
116
|
const horizontalDrawerWidth = useMemo(() => width * horizontalDrawerPercentageOfView + MAX_OVER_DRAG, [width]);
|
|
@@ -116,33 +127,47 @@ export const Drawer = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Drawer(
|
|
|
116
127
|
|
|
117
128
|
// drawer will automatically size itself based on content, but will cap at 75% of viewport height (can override)
|
|
118
129
|
const verticalDrawerMaxHeight = useMemo(() => height * verticalDrawerPercentageOfView + MAX_OVER_DRAG - keyboardInset, [height, verticalDrawerPercentageOfView, keyboardInset]);
|
|
119
|
-
|
|
130
|
+
|
|
131
|
+
// For inside variant, pan handlers go on handlebar, for outside variant, on container
|
|
132
|
+
const getContainerPanHandlers = !preventDismissGestures && !showHandleBarInside ? panGestureHandlers.panHandlers : undefined;
|
|
133
|
+
const getHandleBarPanHandlers = !preventDismissGestures && showHandleBarInside ? panGestureHandlers.panHandlers : undefined;
|
|
120
134
|
const handleOverlayPress = useCallback(() => {
|
|
121
135
|
if (!preventDismissGestures) {
|
|
122
136
|
onBlur == null || onBlur();
|
|
123
137
|
handleClose();
|
|
124
138
|
}
|
|
125
139
|
}, [handleClose, preventDismissGestures, onBlur]);
|
|
126
|
-
const cardStyles = StyleSheet.create({
|
|
127
|
-
spacing: _extends({}, spacingStyles),
|
|
128
|
-
overflowStyles: {
|
|
129
|
-
overflow: 'hidden'
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
140
|
useImperativeHandle(ref, () => ({
|
|
133
141
|
handleClose
|
|
134
142
|
}), [handleClose]);
|
|
135
143
|
const content = useMemo(() => typeof children === 'function' ? children({
|
|
136
144
|
handleClose
|
|
137
145
|
}) : children, [children, handleClose]);
|
|
146
|
+
const rootStyle = useMemo(() => [style, styles == null ? void 0 : styles.root], [style, styles == null ? void 0 : styles.root]);
|
|
147
|
+
const containerStyle = useMemo(() => [drawerAnimationStyles, styles == null ? void 0 : styles.container], [drawerAnimationStyles, styles == null ? void 0 : styles.container]);
|
|
148
|
+
const drawerStyle = useMemo(() => [paddingStyles, {
|
|
149
|
+
overflow: showHandleBarOutside ? 'visible' : 'hidden'
|
|
150
|
+
}, styles == null ? void 0 : styles.drawer], [paddingStyles, showHandleBarOutside, styles == null ? void 0 : styles.drawer]);
|
|
151
|
+
const handleBar = useMemo(() => /*#__PURE__*/_jsx(HandleBar, {
|
|
152
|
+
accessibilityLabel: handleBarAccessibilityLabel,
|
|
153
|
+
accessibilityRole: "button",
|
|
154
|
+
onAccessibilityPress: handleClose,
|
|
155
|
+
panHandlers: getHandleBarPanHandlers,
|
|
156
|
+
styles: {
|
|
157
|
+
root: styles == null ? void 0 : styles.handleBar,
|
|
158
|
+
handle: styles == null ? void 0 : styles.handleBarHandle
|
|
159
|
+
},
|
|
160
|
+
variant: handleBarVariant
|
|
161
|
+
}), [handleBarAccessibilityLabel, handleClose, getHandleBarPanHandlers, styles == null ? void 0 : styles.handleBar, styles == null ? void 0 : styles.handleBarHandle, handleBarVariant]);
|
|
138
162
|
return /*#__PURE__*/_jsx(Modal, _extends({
|
|
139
163
|
hardwareAccelerated: true,
|
|
140
164
|
transparent: true,
|
|
141
165
|
visible: true,
|
|
142
|
-
|
|
143
|
-
|
|
166
|
+
accessibilityRole: accessibilityRole,
|
|
167
|
+
animationType: animationType,
|
|
168
|
+
onRequestClose: handleRequestClose,
|
|
169
|
+
style: rootStyle
|
|
144
170
|
}, props, {
|
|
145
|
-
accessibilityRole: "alert",
|
|
146
171
|
children: /*#__PURE__*/_jsxs(OverlayContentContext.Provider, {
|
|
147
172
|
value: overlayContentContextValue,
|
|
148
173
|
children: [/*#__PURE__*/_jsx(DrawerStatusBar, {
|
|
@@ -151,27 +176,29 @@ export const Drawer = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Drawer(
|
|
|
151
176
|
}), /*#__PURE__*/_jsx(Overlay, {
|
|
152
177
|
onTouchStart: handleOverlayPress,
|
|
153
178
|
opacity: opacityAnimation,
|
|
179
|
+
style: styles == null ? void 0 : styles.overlay,
|
|
154
180
|
testID: "drawer-overlay"
|
|
155
|
-
}), /*#__PURE__*/_jsxs(Box, _extends({},
|
|
156
|
-
animated: true
|
|
157
|
-
onAccessibilityEscape: handleClose
|
|
181
|
+
}), /*#__PURE__*/_jsxs(Box, _extends({}, getContainerPanHandlers, {
|
|
182
|
+
animated: true
|
|
158
183
|
// close modal when user performs the "escape" accessibility gesture
|
|
159
184
|
// https://reactnative.dev/docs/accessibility#onaccessibilityescape-ios
|
|
160
185
|
,
|
|
186
|
+
onAccessibilityEscape: handleClose,
|
|
161
187
|
pin: pin,
|
|
162
|
-
style:
|
|
163
|
-
width:
|
|
164
|
-
children: [
|
|
165
|
-
accessibilityLabel:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
borderRadius: isPinHorizontal ? 0 : 400,
|
|
170
|
-
bordered: activeColorScheme === 'dark',
|
|
188
|
+
style: containerStyle,
|
|
189
|
+
width: isSideDrawer ? horizontalDrawerWidth : '100%',
|
|
190
|
+
children: [showHandleBarOutside && handleBar, /*#__PURE__*/_jsxs(Box, {
|
|
191
|
+
accessibilityLabel: accessibilityLabel,
|
|
192
|
+
accessibilityLabelledBy: accessibilityLabelledBy,
|
|
193
|
+
borderRadius: isSideDrawer ? 0 : 600,
|
|
194
|
+
bordered: theme.activeColorScheme === 'dark',
|
|
171
195
|
elevation: 2,
|
|
172
|
-
maxHeight: !
|
|
173
|
-
style:
|
|
174
|
-
children:
|
|
196
|
+
maxHeight: !isSideDrawer ? verticalDrawerMaxHeight : '100%',
|
|
197
|
+
style: drawerStyle,
|
|
198
|
+
children: [showHandleBarInside && handleBar, /*#__PURE__*/_jsx(View, {
|
|
199
|
+
style: overflowStyle,
|
|
200
|
+
children: content
|
|
201
|
+
})]
|
|
175
202
|
})]
|
|
176
203
|
}))]
|
|
177
204
|
})
|
|
@@ -1,52 +1,75 @@
|
|
|
1
|
-
const _excluded = ["onAccessibilityPress"];
|
|
1
|
+
const _excluded = ["onAccessibilityPress", "variant", "panHandlers", "style", "styles"];
|
|
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 { useCallback } from 'react';
|
|
5
|
-
import { Pressable,
|
|
4
|
+
import { useCallback, useMemo } from 'react';
|
|
5
|
+
import { Pressable, View } from 'react-native';
|
|
6
6
|
import { handleBarHeight } from '@coinbase/cds-common/tokens/drawer';
|
|
7
7
|
import { useTheme } from '../../hooks/useTheme';
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
// Fixed pixel values used intentionally — handle size should not scale with theme density.
|
|
10
|
+
const HANDLE_WIDTH_OUTSIDE = 64;
|
|
11
|
+
const HANDLE_WIDTH_INSIDE = 32;
|
|
12
|
+
const HANDLE_OPACITY_INSIDE = 0.4;
|
|
9
13
|
export const HandleBar = _ref => {
|
|
10
14
|
let {
|
|
11
|
-
onAccessibilityPress
|
|
15
|
+
onAccessibilityPress,
|
|
16
|
+
variant = 'outside',
|
|
17
|
+
panHandlers,
|
|
18
|
+
style,
|
|
19
|
+
styles
|
|
12
20
|
} = _ref,
|
|
13
21
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
14
22
|
const theme = useTheme();
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
const touchableAreaStyles = {
|
|
20
|
-
paddingBottom: theme.space[2],
|
|
21
|
-
paddingTop: theme.space[2]
|
|
22
|
-
};
|
|
23
|
+
const paddingY = theme.space[2];
|
|
24
|
+
const isInside = variant === 'inside';
|
|
25
|
+
const handleBarBackgroundColor = theme.color[isInside ? 'bgInverse' : 'bgSecondary'];
|
|
23
26
|
const handleAccessibilityAction = useCallback(event => {
|
|
24
27
|
if (event.nativeEvent.actionName === 'activate') {
|
|
25
28
|
onAccessibilityPress == null || onAccessibilityPress();
|
|
26
29
|
}
|
|
27
30
|
}, [onAccessibilityPress]);
|
|
31
|
+
const pressableStyle = useCallback(state => [{
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
paddingBottom: paddingY,
|
|
34
|
+
paddingTop: paddingY
|
|
35
|
+
}, style, typeof (styles == null ? void 0 : styles.root) === 'function' ? styles == null ? void 0 : styles.root(state) : styles == null ? void 0 : styles.root], [paddingY, style, styles]);
|
|
36
|
+
const handleBarStyle = useMemo(() => [{
|
|
37
|
+
width: isInside ? HANDLE_WIDTH_INSIDE : HANDLE_WIDTH_OUTSIDE,
|
|
38
|
+
height: handleBarHeight,
|
|
39
|
+
backgroundColor: handleBarBackgroundColor,
|
|
40
|
+
borderRadius: 4,
|
|
41
|
+
opacity: isInside ? HANDLE_OPACITY_INSIDE : 1
|
|
42
|
+
}, styles == null ? void 0 : styles.handle], [isInside, handleBarBackgroundColor, styles == null ? void 0 : styles.handle]);
|
|
43
|
+
if (isInside) {
|
|
44
|
+
return /*#__PURE__*/_jsx(View, _extends({
|
|
45
|
+
accessible: true,
|
|
46
|
+
accessibilityActions: onAccessibilityPress ? [{
|
|
47
|
+
name: 'activate'
|
|
48
|
+
}] : undefined,
|
|
49
|
+
accessibilityRole: "button",
|
|
50
|
+
onAccessibilityAction: handleAccessibilityAction,
|
|
51
|
+
style: pressableStyle({
|
|
52
|
+
pressed: false
|
|
53
|
+
}),
|
|
54
|
+
testID: "handleBar"
|
|
55
|
+
}, panHandlers, props, {
|
|
56
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
57
|
+
style: handleBarStyle
|
|
58
|
+
})
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
28
61
|
return /*#__PURE__*/_jsx(Pressable, _extends({
|
|
29
62
|
accessible: true,
|
|
30
63
|
accessibilityActions: onAccessibilityPress ? [{
|
|
31
64
|
name: 'activate'
|
|
32
65
|
}] : undefined,
|
|
33
66
|
onAccessibilityAction: handleAccessibilityAction,
|
|
34
|
-
style:
|
|
67
|
+
style: pressableStyle,
|
|
35
68
|
testID: "handleBar"
|
|
36
|
-
}, props, {
|
|
69
|
+
}, panHandlers, props, {
|
|
37
70
|
children: /*#__PURE__*/_jsx(View, {
|
|
38
|
-
style:
|
|
71
|
+
style: handleBarStyle
|
|
39
72
|
})
|
|
40
73
|
}));
|
|
41
74
|
};
|
|
42
|
-
const styles = StyleSheet.create({
|
|
43
|
-
touchableArea: {
|
|
44
|
-
alignItems: 'center'
|
|
45
|
-
},
|
|
46
|
-
handleBar: {
|
|
47
|
-
width: 64,
|
|
48
|
-
height: handleBarHeight,
|
|
49
|
-
borderRadius: 4
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
75
|
HandleBar.displayName = 'HandleBar';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
const _excluded = ["children", "header", "
|
|
1
|
+
const _excluded = ["children", "title", "header", "headerElevation", "footer", "onVisibilityChange", "handleBarVariant", "verticalDrawerPercentageOfView", "styles"],
|
|
2
|
+
_excluded2 = ["content", "header", "title"];
|
|
2
3
|
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
4
|
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
5
|
import React, { createContext, forwardRef, memo, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
5
6
|
import { useWindowDimensions } from 'react-native';
|
|
6
7
|
import { MAX_OVER_DRAG } from '@coinbase/cds-common/animation/drawer';
|
|
7
8
|
import { verticalDrawerPercentageOfView as defaultVerticalDrawerPercentageOfView } from '@coinbase/cds-common/tokens/drawer';
|
|
8
|
-
import { Box,
|
|
9
|
+
import { Box, VStack } from '../../layout';
|
|
9
10
|
import { Text } from '../../typography/Text';
|
|
10
11
|
import { Drawer } from '../drawer/Drawer';
|
|
11
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -16,52 +17,85 @@ export const TrayContext = /*#__PURE__*/createContext({
|
|
|
16
17
|
export const Tray = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Tray(_ref, ref) {
|
|
17
18
|
let {
|
|
18
19
|
children,
|
|
20
|
+
title,
|
|
19
21
|
header,
|
|
22
|
+
headerElevation,
|
|
20
23
|
footer,
|
|
21
|
-
title,
|
|
22
24
|
onVisibilityChange,
|
|
23
|
-
|
|
25
|
+
handleBarVariant = 'outside',
|
|
26
|
+
verticalDrawerPercentageOfView = defaultVerticalDrawerPercentageOfView,
|
|
27
|
+
styles
|
|
24
28
|
} = _ref,
|
|
25
29
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
26
30
|
const [titleHeight, setTitleHeight] = useState(0);
|
|
31
|
+
const isInsideHandleBar = handleBarVariant === 'inside';
|
|
32
|
+
const {
|
|
33
|
+
contentStyle,
|
|
34
|
+
headerStyle,
|
|
35
|
+
titleStyle,
|
|
36
|
+
drawerStyles
|
|
37
|
+
} = useMemo(() => {
|
|
38
|
+
const _ref2 = styles != null ? styles : {},
|
|
39
|
+
{
|
|
40
|
+
content: contentStyle,
|
|
41
|
+
header: headerStyle,
|
|
42
|
+
title: titleStyle
|
|
43
|
+
} = _ref2,
|
|
44
|
+
drawerStyles = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
45
|
+
return {
|
|
46
|
+
contentStyle,
|
|
47
|
+
headerStyle,
|
|
48
|
+
titleStyle,
|
|
49
|
+
drawerStyles
|
|
50
|
+
};
|
|
51
|
+
}, [styles]);
|
|
27
52
|
const onTitleLayout = useCallback(event => {
|
|
28
53
|
if (!title) return;
|
|
29
54
|
setTitleHeight(event.nativeEvent.layout.height);
|
|
30
55
|
}, [title]);
|
|
31
|
-
const renderChildren = useCallback(
|
|
56
|
+
const renderChildren = useCallback(_ref3 => {
|
|
32
57
|
let {
|
|
33
58
|
handleClose
|
|
34
|
-
} =
|
|
59
|
+
} = _ref3;
|
|
35
60
|
const content = typeof children === 'function' ? children({
|
|
36
61
|
handleClose
|
|
37
62
|
}) : children;
|
|
63
|
+
const headerContent = typeof header === 'function' ? header({
|
|
64
|
+
handleClose
|
|
65
|
+
}) : header;
|
|
66
|
+
const footerContent = typeof footer === 'function' ? footer({
|
|
67
|
+
handleClose
|
|
68
|
+
}) : footer;
|
|
38
69
|
return /*#__PURE__*/_jsxs(VStack, {
|
|
39
70
|
flexGrow: 1,
|
|
40
71
|
flexShrink: 1,
|
|
41
72
|
minHeight: 0,
|
|
42
73
|
paddingTop: title ? 0 : 2,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
74
|
+
style: contentStyle,
|
|
75
|
+
children: [(title || headerContent) && /*#__PURE__*/_jsxs(Box, {
|
|
76
|
+
elevation: headerElevation,
|
|
77
|
+
style: headerStyle,
|
|
78
|
+
children: [title && /*#__PURE__*/_jsx(Box, {
|
|
79
|
+
justifyContent: "center",
|
|
80
|
+
onLayout: onTitleLayout,
|
|
81
|
+
paddingBottom: isInsideHandleBar ? 0.75 : 2,
|
|
82
|
+
paddingTop: isInsideHandleBar ? 0 : 3,
|
|
83
|
+
paddingX: 3,
|
|
84
|
+
children: typeof title === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
85
|
+
font: "title3",
|
|
86
|
+
style: titleStyle,
|
|
87
|
+
children: title
|
|
88
|
+
}) : title
|
|
89
|
+
}), headerContent]
|
|
90
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
57
91
|
flexGrow: 1,
|
|
58
92
|
flexShrink: 1,
|
|
59
93
|
minHeight: 0,
|
|
60
94
|
width: "100%",
|
|
61
95
|
children: content
|
|
62
|
-
}),
|
|
96
|
+
}), footerContent]
|
|
63
97
|
});
|
|
64
|
-
}, [
|
|
98
|
+
}, [title, contentStyle, onTitleLayout, isInsideHandleBar, headerElevation, headerStyle, titleStyle, header, children, footer]);
|
|
65
99
|
useEffect(() => {
|
|
66
100
|
onVisibilityChange == null || onVisibilityChange('visible');
|
|
67
101
|
return () => {
|
|
@@ -75,18 +109,19 @@ export const Tray = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Tray(_ref
|
|
|
75
109
|
return /*#__PURE__*/_jsx(TrayContext.Provider, {
|
|
76
110
|
value: trayContextValue,
|
|
77
111
|
children: /*#__PURE__*/_jsx(Drawer, _extends({
|
|
78
|
-
|
|
112
|
+
ref: ref,
|
|
113
|
+
handleBarVariant: handleBarVariant,
|
|
114
|
+
styles: drawerStyles,
|
|
79
115
|
verticalDrawerPercentageOfView: trayContextValue.verticalDrawerPercentageOfView
|
|
80
116
|
}, props, {
|
|
81
|
-
ref: ref,
|
|
82
117
|
children: renderChildren
|
|
83
118
|
}))
|
|
84
119
|
});
|
|
85
120
|
}));
|
|
86
|
-
export const TrayStickyFooter =
|
|
121
|
+
export const TrayStickyFooter = _ref4 => {
|
|
87
122
|
let {
|
|
88
123
|
children
|
|
89
|
-
} =
|
|
124
|
+
} = _ref4;
|
|
90
125
|
const {
|
|
91
126
|
verticalDrawerPercentageOfView,
|
|
92
127
|
titleHeight
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cds-mobile",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.44.1",
|
|
4
4
|
"description": "Coinbase Design System - Mobile",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
"react-native-svg": "^14.1.0"
|
|
199
199
|
},
|
|
200
200
|
"dependencies": {
|
|
201
|
-
"@coinbase/cds-common": "^8.
|
|
201
|
+
"@coinbase/cds-common": "^8.44.1",
|
|
202
202
|
"@coinbase/cds-icons": "^5.11.0",
|
|
203
203
|
"@coinbase/cds-illustrations": "^4.31.0",
|
|
204
204
|
"@coinbase/cds-lottie-files": "^3.3.4",
|