@coinbase/cds-mobile 8.48.3 → 8.49.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/DefaultSlideButtonBackground.d.ts +11 -10
- package/dts/buttons/DefaultSlideButtonBackground.d.ts.map +1 -1
- package/dts/buttons/DefaultSlideButtonHandle.d.ts.map +1 -1
- package/dts/buttons/SlideButton.d.ts +10 -1
- package/dts/buttons/SlideButton.d.ts.map +1 -1
- package/dts/tabs/SegmentedTabs.d.ts +12 -2
- package/dts/tabs/SegmentedTabs.d.ts.map +1 -1
- package/dts/tabs/Tabs.d.ts +15 -2
- package/dts/tabs/Tabs.d.ts.map +1 -1
- package/esm/buttons/DefaultSlideButtonBackground.js +18 -18
- package/esm/buttons/DefaultSlideButtonHandle.js +10 -2
- package/esm/buttons/SlideButton.js +13 -1
- package/esm/buttons/__stories__/SlideButton.stories.js +5 -0
- package/esm/tabs/SegmentedTabs.js +1 -1
- package/esm/tabs/Tabs.js +30 -8
- package/esm/tabs/__stories__/SegmentedTabs.stories.js +94 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,12 @@ All notable changes to this project will be documented in this file.
|
|
|
8
8
|
|
|
9
9
|
<!-- template-start -->
|
|
10
10
|
|
|
11
|
+
## 8.49.0 (2/26/2026 PST)
|
|
12
|
+
|
|
13
|
+
#### 🚀 Updates
|
|
14
|
+
|
|
15
|
+
- Add styles props to Tab components. [[#438](https://github.com/coinbase/cds/pull/438)]
|
|
16
|
+
|
|
11
17
|
## 8.48.3 ((2/25/2026, 08:36 PM PST))
|
|
12
18
|
|
|
13
19
|
This is an artificial version bump with no new change.
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
export declare const styles: {
|
|
4
|
-
base: {
|
|
5
|
-
width: '100%';
|
|
6
|
-
height: '100%';
|
|
7
|
-
alignItems: 'center';
|
|
8
|
-
justifyContent: 'center';
|
|
9
|
-
};
|
|
10
|
-
};
|
|
2
|
+
import type { View } from 'react-native';
|
|
11
3
|
export declare const DefaultSlideButtonBackground: React.MemoExoticComponent<
|
|
12
4
|
React.ForwardRefExoticComponent<
|
|
13
5
|
Pick<
|
|
14
6
|
import('./SlideButton').SlideButtonBaseProps,
|
|
15
|
-
|
|
7
|
+
| 'borderRadius'
|
|
8
|
+
| 'borderTopLeftRadius'
|
|
9
|
+
| 'borderTopRightRadius'
|
|
10
|
+
| 'borderBottomLeftRadius'
|
|
11
|
+
| 'borderBottomRightRadius'
|
|
12
|
+
| 'disabled'
|
|
13
|
+
| 'checked'
|
|
14
|
+
| 'variant'
|
|
15
|
+
| 'compact'
|
|
16
|
+
| 'uncheckedLabel'
|
|
16
17
|
> & {
|
|
17
18
|
progress: import('@react-spring/core').SpringValue<number>;
|
|
18
19
|
style?: import('react-native').StyleProp<import('react-native').ViewStyle>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultSlideButtonBackground.d.ts","sourceRoot":"","sources":["../../src/buttons/DefaultSlideButtonBackground.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"DefaultSlideButtonBackground.d.ts","sourceRoot":"","sources":["../../src/buttons/DefaultSlideButtonBackground.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAQzC,eAAO,MAAM,4BAA4B;;;+BAyDxC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultSlideButtonHandle.d.ts","sourceRoot":"","sources":["../../src/buttons/DefaultSlideButtonHandle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EAAE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;AAElF,eAAO,MAAM,eAAe;;;CAAgE,CAAC;AAE7F,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,SAAS,CAAC,GAAG;IAC9F,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG,CAC9C,KAAK,EAAE,6BAA6B,KACjC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;AAE/B,MAAM,MAAM,+BAA+B,GAAG,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,SAAS,CAAC,GAAG;IAChG,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,CAChD,KAAK,EAAE,+BAA+B,KACnC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;AAE/B,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;CAgBjB,CAAC;AAEH,eAAO,MAAM,wBAAwB,sDACT,6BAA6B,6CAmBxD,CAAC;AAEF,eAAO,MAAM,0BAA0B,iDAChB,+BAA+B,6CAgBrD,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;+BAuFpC,CAAC"}
|
|
@@ -6,7 +6,16 @@ import type { PressableProps } from '../system/Pressable';
|
|
|
6
6
|
export declare const slideButtonTestID = 'slide-button';
|
|
7
7
|
export type SlideButtonBackgroundProps = Pick<
|
|
8
8
|
SlideButtonBaseProps,
|
|
9
|
-
|
|
9
|
+
| 'borderBottomLeftRadius'
|
|
10
|
+
| 'borderBottomRightRadius'
|
|
11
|
+
| 'borderRadius'
|
|
12
|
+
| 'borderTopLeftRadius'
|
|
13
|
+
| 'borderTopRightRadius'
|
|
14
|
+
| 'checked'
|
|
15
|
+
| 'compact'
|
|
16
|
+
| 'disabled'
|
|
17
|
+
| 'uncheckedLabel'
|
|
18
|
+
| 'variant'
|
|
10
19
|
> & {
|
|
11
20
|
progress: SpringValue<number>;
|
|
12
21
|
style?: StyleProp<ViewStyle>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SlideButton.d.ts","sourceRoot":"","sources":["../../src/buttons/SlideButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwD,MAAM,OAAO,CAAC;AAC7E,OAAO,EAAiC,KAAK,SAAS,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAInG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK1D,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,oBAAoB,
|
|
1
|
+
{"version":3,"file":"SlideButton.d.ts","sourceRoot":"","sources":["../../src/buttons/SlideButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwD,MAAM,OAAO,CAAC;AAC7E,OAAO,EAAiC,KAAK,SAAS,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAInG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK1D,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,oBAAoB,EAClB,wBAAwB,GACxB,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,sBAAsB,GACtB,SAAS,GAC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ACO,OAAO,CAAC,aAAa,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;IACrE;;;OAGG;iCAC0B,0BAA0B;IACvD;;;OAGG;qCAC8B,8BAA8B;IAC/D;;;;OAIG;qBACc,MAAM;IACvB;;;OAGG;sCAC+B,OAAO;IACzC,yEAAyE;aAChE;QACP,wBAAwB;QACxB,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QACjC,yBAAyB;QACzB,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QAClC,qBAAqB;QACrB,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;KAC/B;IACD;;;OAGG;yBACkB,KAAK,CAAC,SAAS;IACpC;;;OAGG;qBACc,KAAK,CAAC,SAAS;+BAkMjC,CAAC"}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { View } from 'react-native';
|
|
2
|
+
import type { StyleProp, View, ViewStyle } from 'react-native';
|
|
3
3
|
import { type TabsProps } from './Tabs';
|
|
4
4
|
export type SegmentedTabsProps<TabId extends string = string> = Partial<
|
|
5
5
|
Pick<TabsProps<TabId>, 'TabComponent' | 'TabsActiveIndicatorComponent'>
|
|
6
6
|
> &
|
|
7
|
-
Omit<TabsProps<TabId>, 'TabComponent' | 'TabsActiveIndicatorComponent'
|
|
7
|
+
Omit<TabsProps<TabId>, 'TabComponent' | 'TabsActiveIndicatorComponent' | 'styles'> & {
|
|
8
|
+
/** Custom styles for individual elements of the SegmentedTabs component */
|
|
9
|
+
styles?: {
|
|
10
|
+
/** Root container element */
|
|
11
|
+
root?: StyleProp<ViewStyle>;
|
|
12
|
+
/** Tab element */
|
|
13
|
+
tab?: StyleProp<ViewStyle>;
|
|
14
|
+
/** Active indicator element */
|
|
15
|
+
activeIndicator?: StyleProp<ViewStyle>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
8
18
|
type SegmentedTabsFC = <TabId extends string = string>(
|
|
9
19
|
props: SegmentedTabsProps<TabId> & {
|
|
10
20
|
ref?: React.ForwardedRef<View>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedTabs.d.ts","sourceRoot":"","sources":["../../src/tabs/SegmentedTabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"SegmentedTabs.d.ts","sourceRoot":"","sources":["../../src/tabs/SegmentedTabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAI/D,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE9C,MAAM,MAAM,kBAAkB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,IAAI,OAAO,CACrE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,cAAc,GAAG,8BAA8B,CAAC,CACxE,GACC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,cAAc,GAAG,8BAA8B,GAAG,QAAQ,CAAC,GAAG;IACnF,2EAA2E;IAC3E,MAAM,CAAC,EAAE;QACP,6BAA6B;QAC7B,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QAC5B,kBAAkB;QAClB,GAAG,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QAC3B,+BAA+B;QAC/B,eAAe,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;KACxC,CAAC;CACH,CAAC;AAEJ,KAAK,eAAe,GAAG,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EACnD,KAAK,EAAE,kBAAkB,CAAC,KAAK,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;CAAE,KAClE,KAAK,CAAC,YAAY,CAAC;AA8BxB,eAAO,MAAM,aAAa,EAA6B,eAAe,CAAC"}
|
package/dts/tabs/Tabs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
2
|
+
import { type StyleProp, View, type ViewStyle } from 'react-native';
|
|
3
3
|
import type { ThemeVars } from '@coinbase/cds-common/core/theme';
|
|
4
4
|
import { type TabsOptions, type TabValue } from '@coinbase/cds-common/tabs/useTabs';
|
|
5
5
|
import { type Rect } from '@coinbase/cds-common/types/Rect';
|
|
@@ -13,7 +13,10 @@ export declare const tabsSpringConfig: {
|
|
|
13
13
|
export type TabsActiveIndicatorProps = {
|
|
14
14
|
activeTabRect: Rect;
|
|
15
15
|
} & BoxProps;
|
|
16
|
-
export type
|
|
16
|
+
export type TabComponentProps<TabId extends string = string> = TabValue<TabId> & {
|
|
17
|
+
style?: StyleProp<ViewStyle>;
|
|
18
|
+
};
|
|
19
|
+
export type TabComponent<TabId extends string = string> = React.FC<TabComponentProps<TabId>>;
|
|
17
20
|
export type TabsActiveIndicatorComponent = React.FC<TabsActiveIndicatorProps>;
|
|
18
21
|
export type TabsBaseProps<TabId extends string = string> = {
|
|
19
22
|
/** The array of tabs data. Each tab may optionally define a custom Component to render. */
|
|
@@ -28,6 +31,15 @@ export type TabsBaseProps<TabId extends string = string> = {
|
|
|
28
31
|
activeBackground?: ThemeVars.Color;
|
|
29
32
|
/** Optional callback to receive the active tab element. */
|
|
30
33
|
onActiveTabElementChange?: (element: View | null) => void;
|
|
34
|
+
/** Custom styles for individual elements of the Tabs component */
|
|
35
|
+
styles?: {
|
|
36
|
+
/** Root container element */
|
|
37
|
+
root?: StyleProp<ViewStyle>;
|
|
38
|
+
/** Tab element */
|
|
39
|
+
tab?: StyleProp<ViewStyle>;
|
|
40
|
+
/** Active indicator element */
|
|
41
|
+
activeIndicator?: StyleProp<ViewStyle>;
|
|
42
|
+
};
|
|
31
43
|
} & Omit<TabsOptions<TabId>, 'tabs'>;
|
|
32
44
|
export type TabsProps<TabId extends string = string> = TabsBaseProps<TabId> &
|
|
33
45
|
Omit<HStackProps, 'onChange'>;
|
|
@@ -40,6 +52,7 @@ export declare const Tabs: TabsFC;
|
|
|
40
52
|
export declare const TabsActiveIndicator: ({
|
|
41
53
|
activeTabRect,
|
|
42
54
|
position,
|
|
55
|
+
style,
|
|
43
56
|
...props
|
|
44
57
|
}: TabsActiveIndicatorProps) => import('react/jsx-runtime').JSX.Element;
|
|
45
58
|
export {};
|
package/dts/tabs/Tabs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../src/tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+E,MAAM,OAAO,CAAC;AACpG,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../src/tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+E,MAAM,OAAO,CAAC;AACpG,OAAO,EAAE,KAAK,SAAS,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAOpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,QAAQ,EAEd,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAe,KAAK,IAAI,EAAE,MAAM,iCAAiC,CAAC;AAEzE,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAmBvD,eAAO,MAAM,gBAAgB;;;;;CAKQ,CAAC;AAEtC,MAAM,MAAM,wBAAwB,GAAG;IACrC,aAAa,EAAE,IAAI,CAAC;CACrB,GAAG,QAAQ,CAAC;AAEb,MAAM,MAAM,iBAAiB,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IAAI,aAAa,CAAC,KAAK,CAAC,GACzE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAEhC,KAAK,MAAM,GAAG,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EAC1C,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;CAAE,KACzD,KAAK,CAAC,YAAY,CAAC;AAyGxB,eAAO,MAAM,IAAI,EAAoB,MAAM,CAAC;AAE5C,eAAO,MAAM,mBAAmB,GAAI,8CAKjC,wBAAwB,4CAiC1B,CAAC"}
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import React, { forwardRef, memo, useMemo } from 'react';
|
|
2
|
-
import { StyleSheet, View } from 'react-native';
|
|
3
2
|
import { animated, to } from '@react-spring/native';
|
|
4
|
-
import {
|
|
3
|
+
import { Box } from '../layout/Box';
|
|
5
4
|
import { TextHeadline } from '../typography/TextHeadline';
|
|
6
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
export const styles = StyleSheet.create({
|
|
8
|
-
base: {
|
|
9
|
-
width: '100%',
|
|
10
|
-
height: '100%',
|
|
11
|
-
alignItems: 'center',
|
|
12
|
-
justifyContent: 'center'
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
6
|
export const DefaultSlideButtonBackground = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
16
7
|
let {
|
|
17
8
|
progress,
|
|
@@ -19,21 +10,30 @@ export const DefaultSlideButtonBackground = /*#__PURE__*/memo(/*#__PURE__*/forwa
|
|
|
19
10
|
disabled,
|
|
20
11
|
compact,
|
|
21
12
|
style,
|
|
22
|
-
borderRadius
|
|
13
|
+
borderRadius,
|
|
14
|
+
borderTopLeftRadius,
|
|
15
|
+
borderTopRightRadius,
|
|
16
|
+
borderBottomLeftRadius,
|
|
17
|
+
borderBottomRightRadius
|
|
23
18
|
} = _ref;
|
|
24
|
-
const theme = useTheme();
|
|
25
19
|
const horizontalPadding = compact ? 7 : 9;
|
|
26
|
-
const containerStyle = useMemo(() => [styles.base, {
|
|
27
|
-
backgroundColor: theme.color.bgSecondary,
|
|
28
|
-
borderRadius
|
|
29
|
-
}, style], [theme.color.bgSecondary, style, borderRadius]);
|
|
30
20
|
const animatedStyle = useMemo(() => ({
|
|
31
21
|
opacity: disabled ? 0.5 : to(progress, value => 1 - value)
|
|
32
22
|
}), [progress, disabled]);
|
|
33
|
-
return /*#__PURE__*/_jsx(
|
|
23
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
34
24
|
ref: ref,
|
|
35
25
|
"aria-hidden": true,
|
|
36
|
-
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
background: "bgSecondary",
|
|
28
|
+
borderBottomLeftRadius: borderBottomLeftRadius,
|
|
29
|
+
borderBottomRightRadius: borderBottomRightRadius,
|
|
30
|
+
borderRadius: borderRadius,
|
|
31
|
+
borderTopLeftRadius: borderTopLeftRadius,
|
|
32
|
+
borderTopRightRadius: borderTopRightRadius,
|
|
33
|
+
height: "100%",
|
|
34
|
+
justifyContent: "center",
|
|
35
|
+
style: style,
|
|
36
|
+
width: "100%",
|
|
37
37
|
children: /*#__PURE__*/_jsx(animated.View, {
|
|
38
38
|
style: animatedStyle,
|
|
39
39
|
children: typeof uncheckedLabel !== 'string' ? uncheckedLabel : /*#__PURE__*/_jsx(TextHeadline, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["checked", "compact", "disabled", "style", "variant", "startUncheckedNode", "endCheckedNode", "checkedLabel", "borderRadius"];
|
|
1
|
+
const _excluded = ["checked", "compact", "disabled", "style", "variant", "startUncheckedNode", "endCheckedNode", "checkedLabel", "borderRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderBottomRightRadius"];
|
|
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, useMemo } from 'react';
|
|
@@ -92,7 +92,11 @@ export const DefaultSlideButtonHandle = /*#__PURE__*/memo(/*#__PURE__*/forwardRe
|
|
|
92
92
|
startUncheckedNode,
|
|
93
93
|
endCheckedNode,
|
|
94
94
|
checkedLabel,
|
|
95
|
-
borderRadius
|
|
95
|
+
borderRadius,
|
|
96
|
+
borderTopLeftRadius,
|
|
97
|
+
borderTopRightRadius,
|
|
98
|
+
borderBottomLeftRadius,
|
|
99
|
+
borderBottomRightRadius
|
|
96
100
|
} = _ref3,
|
|
97
101
|
props = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
98
102
|
const backgroundColor = variants[variant].background;
|
|
@@ -121,7 +125,11 @@ export const DefaultSlideButtonHandle = /*#__PURE__*/memo(/*#__PURE__*/forwardRe
|
|
|
121
125
|
ref: ref,
|
|
122
126
|
noScaleOnPress: true,
|
|
123
127
|
background: backgroundColor,
|
|
128
|
+
borderBottomLeftRadius: borderBottomLeftRadius,
|
|
129
|
+
borderBottomRightRadius: borderBottomRightRadius,
|
|
124
130
|
borderRadius: borderRadius,
|
|
131
|
+
borderTopLeftRadius: borderTopLeftRadius,
|
|
132
|
+
borderTopRightRadius: borderTopRightRadius,
|
|
125
133
|
contentStyle: containerStyle,
|
|
126
134
|
disabled: disabled,
|
|
127
135
|
loading: checked
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["checked", "compact", "borderRadius", "uncheckedLabel", "checkedLabel", "onSlideStart", "onSlideCancel", "onSlideEnd", "onSlideComplete", "onChange", "disabled", "height", "checkThreshold", "SlideButtonHandleComponent", "SlideButtonBackgroundComponent", "styles", "testID", "autoCompleteSlideOnThresholdMet", "variant", "startUncheckedNode", "endCheckedNode"];
|
|
1
|
+
const _excluded = ["checked", "compact", "borderRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderBottomRightRadius", "uncheckedLabel", "checkedLabel", "onSlideStart", "onSlideCancel", "onSlideEnd", "onSlideComplete", "onChange", "disabled", "height", "checkThreshold", "SlideButtonHandleComponent", "SlideButtonBackgroundComponent", "styles", "testID", "autoCompleteSlideOnThresholdMet", "variant", "startUncheckedNode", "endCheckedNode"];
|
|
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, useId, useMemo } from 'react';
|
|
@@ -16,6 +16,10 @@ export const SlideButton = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref)
|
|
|
16
16
|
checked,
|
|
17
17
|
compact,
|
|
18
18
|
borderRadius = compact ? 700 : 900,
|
|
19
|
+
borderTopLeftRadius,
|
|
20
|
+
borderTopRightRadius,
|
|
21
|
+
borderBottomLeftRadius,
|
|
22
|
+
borderBottomRightRadius,
|
|
19
23
|
uncheckedLabel,
|
|
20
24
|
checkedLabel,
|
|
21
25
|
onSlideStart,
|
|
@@ -109,7 +113,11 @@ export const SlideButton = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref)
|
|
|
109
113
|
style: containerStyle,
|
|
110
114
|
testID: testID,
|
|
111
115
|
children: [/*#__PURE__*/_jsx(SlideButtonBackgroundComponent, {
|
|
116
|
+
borderBottomLeftRadius: borderBottomLeftRadius,
|
|
117
|
+
borderBottomRightRadius: borderBottomRightRadius,
|
|
112
118
|
borderRadius: borderRadius,
|
|
119
|
+
borderTopLeftRadius: borderTopLeftRadius,
|
|
120
|
+
borderTopRightRadius: borderTopRightRadius,
|
|
113
121
|
checked: checked,
|
|
114
122
|
compact: compact,
|
|
115
123
|
disabled: disabled,
|
|
@@ -129,7 +137,11 @@ export const SlideButton = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref)
|
|
|
129
137
|
} : {
|
|
130
138
|
accessibilityLabelledBy: labelId
|
|
131
139
|
}, {
|
|
140
|
+
borderBottomLeftRadius: borderBottomLeftRadius,
|
|
141
|
+
borderBottomRightRadius: borderBottomRightRadius,
|
|
132
142
|
borderRadius: borderRadius,
|
|
143
|
+
borderTopLeftRadius: borderTopLeftRadius,
|
|
144
|
+
borderTopRightRadius: borderTopRightRadius,
|
|
133
145
|
checked: checked,
|
|
134
146
|
checkedLabel: checkedLabel,
|
|
135
147
|
compact: compact,
|
|
@@ -185,6 +185,11 @@ export const SlideButtonStories = () => {
|
|
|
185
185
|
SlideButtonHandleComponent: CustomHandle,
|
|
186
186
|
height: 50
|
|
187
187
|
})
|
|
188
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
189
|
+
title: "Custom border radius",
|
|
190
|
+
children: /*#__PURE__*/_jsx(SlideButtonExample, {
|
|
191
|
+
borderRadius: 200
|
|
192
|
+
})
|
|
188
193
|
})]
|
|
189
194
|
});
|
|
190
195
|
};
|
|
@@ -12,7 +12,7 @@ const SegmentedTabsComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref,
|
|
|
12
12
|
TabsActiveIndicatorComponent = SegmentedTabsActiveIndicator,
|
|
13
13
|
activeBackground = 'bgInverse',
|
|
14
14
|
background = 'bgSecondary',
|
|
15
|
-
borderRadius =
|
|
15
|
+
borderRadius = 700
|
|
16
16
|
} = _ref,
|
|
17
17
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
18
18
|
return /*#__PURE__*/_jsx(Tabs, _extends({
|
package/esm/tabs/Tabs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const _excluded = ["id", "registerRef"],
|
|
2
|
-
_excluded2 = ["tabs", "TabComponent", "TabsActiveIndicatorComponent", "activeBackground", "activeTab", "disabled", "onChange", "role", "position", "alignSelf", "opacity", "onActiveTabElementChange"],
|
|
2
|
+
_excluded2 = ["tabs", "TabComponent", "TabsActiveIndicatorComponent", "activeBackground", "activeTab", "disabled", "onChange", "styles", "style", "role", "position", "alignSelf", "opacity", "onActiveTabElementChange", "borderRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderBottomRightRadius"],
|
|
3
3
|
_excluded3 = ["id", "Component", "disabled"],
|
|
4
|
-
_excluded4 = ["activeTabRect", "position"];
|
|
4
|
+
_excluded4 = ["activeTabRect", "position", "style"];
|
|
5
5
|
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); }
|
|
6
6
|
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; }
|
|
7
7
|
import React, { forwardRef, memo, useCallback, useImperativeHandle, useRef, useState } from 'react';
|
|
@@ -41,11 +41,18 @@ const TabsComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2, ref) =>
|
|
|
41
41
|
activeTab,
|
|
42
42
|
disabled,
|
|
43
43
|
onChange,
|
|
44
|
+
styles,
|
|
45
|
+
style,
|
|
44
46
|
role = 'tablist',
|
|
45
47
|
position = 'relative',
|
|
46
48
|
alignSelf = 'flex-start',
|
|
47
49
|
opacity,
|
|
48
|
-
onActiveTabElementChange
|
|
50
|
+
onActiveTabElementChange,
|
|
51
|
+
borderRadius,
|
|
52
|
+
borderTopLeftRadius,
|
|
53
|
+
borderTopRightRadius,
|
|
54
|
+
borderBottomLeftRadius,
|
|
55
|
+
borderBottomRightRadius
|
|
49
56
|
} = _ref2,
|
|
50
57
|
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
51
58
|
const tabsContainerRef = useRef(null);
|
|
@@ -83,16 +90,28 @@ const TabsComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2, ref) =>
|
|
|
83
90
|
return /*#__PURE__*/_jsx(HStack, _extends({
|
|
84
91
|
ref: tabsContainerRef,
|
|
85
92
|
alignSelf: alignSelf,
|
|
93
|
+
borderBottomLeftRadius: borderBottomLeftRadius,
|
|
94
|
+
borderBottomRightRadius: borderBottomRightRadius,
|
|
95
|
+
borderRadius: borderRadius,
|
|
96
|
+
borderTopLeftRadius: borderTopLeftRadius,
|
|
97
|
+
borderTopRightRadius: borderTopRightRadius,
|
|
86
98
|
onLayout: updateActiveTabRect,
|
|
87
99
|
opacity: opacity != null ? opacity : disabled ? accessibleOpacityDisabled : 1,
|
|
88
100
|
position: position,
|
|
89
|
-
role: role
|
|
101
|
+
role: role,
|
|
102
|
+
style: styles != null && styles.root ? [style, styles.root] : style
|
|
90
103
|
}, props, {
|
|
91
104
|
children: /*#__PURE__*/_jsxs(TabsContext.Provider, {
|
|
92
105
|
value: api,
|
|
93
106
|
children: [/*#__PURE__*/_jsx(TabsActiveIndicatorComponent, {
|
|
94
107
|
activeTabRect: activeTabRect,
|
|
95
|
-
background: activeBackground
|
|
108
|
+
background: activeBackground,
|
|
109
|
+
borderBottomLeftRadius: borderBottomLeftRadius,
|
|
110
|
+
borderBottomRightRadius: borderBottomRightRadius,
|
|
111
|
+
borderRadius: borderRadius,
|
|
112
|
+
borderTopLeftRadius: borderTopLeftRadius,
|
|
113
|
+
borderTopRightRadius: borderTopRightRadius,
|
|
114
|
+
style: styles == null ? void 0 : styles.activeIndicator
|
|
96
115
|
}), tabs.map(_ref3 => {
|
|
97
116
|
let {
|
|
98
117
|
id,
|
|
@@ -107,7 +126,9 @@ const TabsComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2, ref) =>
|
|
|
107
126
|
children: /*#__PURE__*/_jsx(RenderedTab, _extends({
|
|
108
127
|
disabled: tabDisabled,
|
|
109
128
|
id: id
|
|
110
|
-
}, props
|
|
129
|
+
}, props, {
|
|
130
|
+
style: styles == null ? void 0 : styles.tab
|
|
131
|
+
}))
|
|
111
132
|
}, id);
|
|
112
133
|
})]
|
|
113
134
|
})
|
|
@@ -118,7 +139,8 @@ export const Tabs = TabsComponent;
|
|
|
118
139
|
export const TabsActiveIndicator = _ref4 => {
|
|
119
140
|
let {
|
|
120
141
|
activeTabRect,
|
|
121
|
-
position = 'absolute'
|
|
142
|
+
position = 'absolute',
|
|
143
|
+
style
|
|
122
144
|
} = _ref4,
|
|
123
145
|
props = _objectWithoutPropertiesLoose(_ref4, _excluded4);
|
|
124
146
|
const previousActiveTabRect = useRef(activeTabRect);
|
|
@@ -146,7 +168,7 @@ export const TabsActiveIndicator = _ref4 => {
|
|
|
146
168
|
height: activeTabRect.height,
|
|
147
169
|
position: position,
|
|
148
170
|
role: "none",
|
|
149
|
-
style: animatedBoxStyle,
|
|
171
|
+
style: [animatedBoxStyle, style],
|
|
150
172
|
testID: "tabs-active-indicator"
|
|
151
173
|
}, props));
|
|
152
174
|
};
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
const _excluded = ["title", "defaultActiveTab"];
|
|
2
2
|
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; }
|
|
3
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); }
|
|
4
|
-
import React, { useCallback, useState } from 'react';
|
|
4
|
+
import React, { memo, useCallback, useEffect, useState } from 'react';
|
|
5
5
|
import { Pressable, ScrollView } from 'react-native';
|
|
6
|
+
import { interpolateColor, runOnJS, useAnimatedReaction, useSharedValue, withSpring } from 'react-native-reanimated';
|
|
6
7
|
import { useTabsContext } from '@coinbase/cds-common/tabs/TabsContext';
|
|
7
8
|
import { Example, ExampleScreen } from '../../examples/ExampleScreen';
|
|
9
|
+
import { useTheme } from '../../hooks/useTheme';
|
|
10
|
+
import { Icon } from '../../icons/Icon';
|
|
8
11
|
import { Box } from '../../layout';
|
|
9
12
|
import { Text } from '../../typography/Text';
|
|
10
13
|
import { SegmentedTab } from '../SegmentedTab';
|
|
11
14
|
import { SegmentedTabs } from '../SegmentedTabs';
|
|
12
|
-
import { TabsActiveIndicator } from '../Tabs';
|
|
15
|
+
import { TabsActiveIndicator, tabsSpringConfig } from '../Tabs';
|
|
13
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
17
|
const CustomActiveIndicator = _ref => {
|
|
15
18
|
let {
|
|
@@ -65,6 +68,54 @@ const CustomSegmentedTabColor = props => /*#__PURE__*/_jsx(SegmentedTab, _extend
|
|
|
65
68
|
const CustomSegmentedTabFont = props => /*#__PURE__*/_jsx(SegmentedTab, _extends({}, props, {
|
|
66
69
|
font: "label2"
|
|
67
70
|
}));
|
|
71
|
+
const ColoredIcon = /*#__PURE__*/memo(_ref3 => {
|
|
72
|
+
let {
|
|
73
|
+
tabId,
|
|
74
|
+
name
|
|
75
|
+
} = _ref3;
|
|
76
|
+
const {
|
|
77
|
+
activeTab
|
|
78
|
+
} = useTabsContext();
|
|
79
|
+
const isActive = (activeTab == null ? void 0 : activeTab.id) === tabId;
|
|
80
|
+
const theme = useTheme();
|
|
81
|
+
const progress = useSharedValue(isActive ? 1 : 0);
|
|
82
|
+
const [color, setColor] = useState(isActive ? theme.color.fgInverse : theme.color.fg);
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
progress.value = withSpring(isActive ? 1 : 0, tabsSpringConfig);
|
|
85
|
+
}, [isActive, progress]);
|
|
86
|
+
useAnimatedReaction(() => interpolateColor(progress.value, [0, 1], [theme.color.fg, theme.color.fgInverse]), newColor => {
|
|
87
|
+
runOnJS(setColor)(newColor);
|
|
88
|
+
});
|
|
89
|
+
return /*#__PURE__*/_jsx(Icon, {
|
|
90
|
+
active: true,
|
|
91
|
+
name: name,
|
|
92
|
+
size: "s",
|
|
93
|
+
styles: {
|
|
94
|
+
icon: {
|
|
95
|
+
color
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
const iconSegments = [{
|
|
101
|
+
id: 'buy',
|
|
102
|
+
label: /*#__PURE__*/_jsx(ColoredIcon, {
|
|
103
|
+
name: "chartLine",
|
|
104
|
+
tabId: "buy"
|
|
105
|
+
})
|
|
106
|
+
}, {
|
|
107
|
+
id: 'sell',
|
|
108
|
+
label: /*#__PURE__*/_jsx(ColoredIcon, {
|
|
109
|
+
name: "chartCandles",
|
|
110
|
+
tabId: "sell"
|
|
111
|
+
})
|
|
112
|
+
}, {
|
|
113
|
+
id: 'convert',
|
|
114
|
+
label: /*#__PURE__*/_jsx(ColoredIcon, {
|
|
115
|
+
name: "chartBar",
|
|
116
|
+
tabId: "convert"
|
|
117
|
+
})
|
|
118
|
+
}];
|
|
68
119
|
const basicSegments = [{
|
|
69
120
|
id: 'buy',
|
|
70
121
|
label: 'Buy'
|
|
@@ -145,12 +196,12 @@ const mixedCustomSegments = [{
|
|
|
145
196
|
label: 'Convert',
|
|
146
197
|
Component: CustomSegmentedTabColor
|
|
147
198
|
}];
|
|
148
|
-
const SegmentedTabsExample =
|
|
199
|
+
const SegmentedTabsExample = _ref4 => {
|
|
149
200
|
let {
|
|
150
201
|
title,
|
|
151
202
|
defaultActiveTab
|
|
152
|
-
} =
|
|
153
|
-
props = _objectWithoutPropertiesLoose(
|
|
203
|
+
} = _ref4,
|
|
204
|
+
props = _objectWithoutPropertiesLoose(_ref4, _excluded);
|
|
154
205
|
const [activeTab, updateActiveTab] = useState(defaultActiveTab);
|
|
155
206
|
const handleChange = useCallback(activeTab => updateActiveTab(activeTab), []);
|
|
156
207
|
return /*#__PURE__*/_jsx(Example, {
|
|
@@ -236,6 +287,43 @@ const SegmentedTabsScreen = () => /*#__PURE__*/_jsxs(ExampleScreen, {
|
|
|
236
287
|
tabs: basicSegments,
|
|
237
288
|
title: "With Padding",
|
|
238
289
|
width: "fit-content"
|
|
239
|
-
})
|
|
290
|
+
}), /*#__PURE__*/_jsx(SegmentedTabsExample, {
|
|
291
|
+
borderRadius: 300,
|
|
292
|
+
defaultActiveTab: basicSegments[0],
|
|
293
|
+
tabs: basicSegments,
|
|
294
|
+
title: "Border Radius"
|
|
295
|
+
}), /*#__PURE__*/_jsx(CustomStylesExample, {}), /*#__PURE__*/_jsx(IconLabelsExample, {})]
|
|
240
296
|
});
|
|
297
|
+
const CustomStylesExample = () => {
|
|
298
|
+
const theme = useTheme();
|
|
299
|
+
return /*#__PURE__*/_jsx(SegmentedTabsExample, {
|
|
300
|
+
borderRadius: 300,
|
|
301
|
+
defaultActiveTab: basicSegments[0],
|
|
302
|
+
padding: 0.5,
|
|
303
|
+
styles: {
|
|
304
|
+
activeIndicator: {
|
|
305
|
+
borderRadius: theme.borderRadius[200]
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
tabs: basicSegments,
|
|
309
|
+
title: "Custom Padding with Inner Border Radius"
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
const IconLabelsExample = () => {
|
|
313
|
+
const theme = useTheme();
|
|
314
|
+
return /*#__PURE__*/_jsx(SegmentedTabsExample, {
|
|
315
|
+
borderRadius: 300,
|
|
316
|
+
defaultActiveTab: iconSegments[0],
|
|
317
|
+
gap: 0.5,
|
|
318
|
+
padding: 0.5,
|
|
319
|
+
styles: {
|
|
320
|
+
activeIndicator: {
|
|
321
|
+
borderRadius: theme.borderRadius[200]
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
tabs: iconSegments,
|
|
325
|
+
title: "Icon Labels",
|
|
326
|
+
width: "fit-content"
|
|
327
|
+
});
|
|
328
|
+
};
|
|
241
329
|
export default SegmentedTabsScreen;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cds-mobile",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.49.0",
|
|
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.49.0",
|
|
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",
|