@ledgerhq/native-ui 0.23.3-nightly.2 → 0.23.3
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/lib/components/Form/index.d.ts +0 -1
- package/lib/components/Form/index.js +0 -1
- package/lib/components/Layout/Modals/BaseModal/index.d.ts +1 -4
- package/lib/components/Layout/Modals/BaseModal/index.js +3 -20
- package/package.json +3 -3
- package/lib/components/Form/TabSelector/index.d.ts +0 -11
- package/lib/components/Form/TabSelector/index.js +0 -55
|
@@ -5,7 +5,6 @@ import { IconOrElementType } from "../../../Icon/type";
|
|
|
5
5
|
export type BaseModalProps = {
|
|
6
6
|
isOpen?: boolean;
|
|
7
7
|
onClose?: () => void;
|
|
8
|
-
onBack?: () => void;
|
|
9
8
|
modalStyle?: StyleProp<ViewStyle>;
|
|
10
9
|
safeContainerStyle?: StyleProp<ViewStyle>;
|
|
11
10
|
containerStyle?: StyleProp<ViewStyle>;
|
|
@@ -17,12 +16,10 @@ export type BaseModalProps = {
|
|
|
17
16
|
subtitle?: string;
|
|
18
17
|
children?: React.ReactNode;
|
|
19
18
|
noCloseButton?: boolean;
|
|
20
|
-
hasBackButton?: boolean;
|
|
21
19
|
CustomHeader?: React.ComponentType<{
|
|
22
20
|
children?: ReactNode;
|
|
23
21
|
}>;
|
|
24
22
|
} & Partial<ModalProps>;
|
|
25
23
|
export declare function ModalHeader({ Icon, iconColor, title, description, subtitle, }: Pick<BaseModalProps, "Icon" | "iconColor" | "title" | "description" | "subtitle">): React.ReactElement | null;
|
|
26
24
|
export declare function ModalHeaderCloseButton({ onClose, }: Pick<BaseModalProps, "onClose">): React.ReactElement;
|
|
27
|
-
export
|
|
28
|
-
export default function BaseModal({ isOpen, onClose, onBack, noCloseButton, hasBackButton, safeContainerStyle, containerStyle, modalStyle, preventBackdropClick, Icon, iconColor, title, description, subtitle, children, onModalHide, CustomHeader, ...rest }: BaseModalProps): React.ReactElement;
|
|
25
|
+
export default function BaseModal({ isOpen, onClose, noCloseButton, safeContainerStyle, containerStyle, modalStyle, preventBackdropClick, Icon, iconColor, title, description, subtitle, children, onModalHide, CustomHeader, ...rest }: BaseModalProps): React.ReactElement;
|
|
@@ -12,13 +12,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import React, { useCallback } from "react";
|
|
13
13
|
import ReactNativeModal from "react-native-modal";
|
|
14
14
|
import styled from "styled-components/native";
|
|
15
|
-
import { TouchableOpacity } from "react-native";
|
|
16
15
|
import sizes from "../../../../helpers/getDeviceSize";
|
|
17
16
|
import Text from "../../../Text";
|
|
18
17
|
import { BoxedIcon } from "../../../Icon";
|
|
19
18
|
import { Flex } from "../../index";
|
|
20
19
|
import { space } from "styled-system";
|
|
21
|
-
import { Close
|
|
20
|
+
import { Close } from "@ledgerhq/icons-ui/native";
|
|
22
21
|
import { useTheme } from "styled-components/native";
|
|
23
22
|
const { width, height } = sizes;
|
|
24
23
|
const SafeContainer = styled.SafeAreaView `
|
|
@@ -40,12 +39,6 @@ const CloseContainer = styled.View `
|
|
|
40
39
|
margin-bottom: ${(p) => p.theme.space[6]}px;
|
|
41
40
|
z-index: 10;
|
|
42
41
|
`;
|
|
43
|
-
const BackContainer = styled.View `
|
|
44
|
-
display: flex;
|
|
45
|
-
align-items: flex-start;
|
|
46
|
-
margin-bottom: ${(p) => p.theme.space[6]}px;
|
|
47
|
-
z-index: 10;
|
|
48
|
-
`;
|
|
49
42
|
const ClosePressableExtendedBounds = styled.TouchableOpacity.attrs({
|
|
50
43
|
p: 3,
|
|
51
44
|
}) `
|
|
@@ -83,14 +76,8 @@ export function ModalHeaderCloseButton({ onClose, }) {
|
|
|
83
76
|
React.createElement(ClosePressableExtendedBounds, { onPress: onClose, testID: "modal-close-button" },
|
|
84
77
|
React.createElement(Close, { color: colors.neutral.c100, size: "XS" }))));
|
|
85
78
|
}
|
|
86
|
-
export function ModalHeaderBackButton({ onBack, }) {
|
|
87
|
-
const { colors } = useTheme();
|
|
88
|
-
return (React.createElement(BackContainer, null,
|
|
89
|
-
React.createElement(TouchableOpacity, { onPress: onBack, testID: "modal-back-button" },
|
|
90
|
-
React.createElement(ArrowLeft, { color: colors.neutral.c100, size: "XS" }))));
|
|
91
|
-
}
|
|
92
79
|
export default function BaseModal(_a) {
|
|
93
|
-
var { isOpen, onClose = () => { },
|
|
80
|
+
var { isOpen, onClose = () => { }, noCloseButton, safeContainerStyle = {}, containerStyle = {}, modalStyle = {}, preventBackdropClick, Icon, iconColor, title, description, subtitle, children, onModalHide, CustomHeader } = _a, rest = __rest(_a, ["isOpen", "onClose", "noCloseButton", "safeContainerStyle", "containerStyle", "modalStyle", "preventBackdropClick", "Icon", "iconColor", "title", "description", "subtitle", "children", "onModalHide", "CustomHeader"]);
|
|
94
81
|
const backDropProps = preventBackdropClick
|
|
95
82
|
? {}
|
|
96
83
|
: {
|
|
@@ -109,11 +96,7 @@ export default function BaseModal(_a) {
|
|
|
109
96
|
React.createElement(SafeContainer, { style: safeContainerStyle },
|
|
110
97
|
CustomHeader && (React.createElement(CustomHeader, null, !noCloseButton && React.createElement(ModalHeaderCloseButton, { onClose: onClose }))),
|
|
111
98
|
React.createElement(Container, { style: containerStyle },
|
|
112
|
-
React.createElement(
|
|
113
|
-
!CustomHeader && onBack && hasBackButton && (React.createElement(Flex, { flex: 1, justifyContent: "flex-start" },
|
|
114
|
-
React.createElement(ModalHeaderBackButton, { onBack: onBack }))),
|
|
115
|
-
!CustomHeader && !noCloseButton && (React.createElement(Flex, { flex: 1, justifyContent: "flex-end" },
|
|
116
|
-
React.createElement(ModalHeaderCloseButton, { onClose: onClose })))),
|
|
99
|
+
!CustomHeader && !noCloseButton && React.createElement(ModalHeaderCloseButton, { onClose: onClose }),
|
|
117
100
|
React.createElement(ModalHeader, { Icon: Icon, iconColor: iconColor, title: title, description: description, subtitle: subtitle }),
|
|
118
101
|
React.createElement(ContentContainer, null, children)))));
|
|
119
102
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/native-ui",
|
|
3
|
-
"version": "0.23.3
|
|
3
|
+
"version": "0.23.3",
|
|
4
4
|
"description": "Ledger Live - Mobile UI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"react-native-modal": "^13.0.0",
|
|
41
41
|
"rn-range-slider": "2.1.1",
|
|
42
42
|
"styled-system": "^5.1.5",
|
|
43
|
-
"@ledgerhq/crypto-icons-ui": "^1.4.0
|
|
44
|
-
"@ledgerhq/icons-ui": "^0.7.
|
|
43
|
+
"@ledgerhq/crypto-icons-ui": "^1.4.0",
|
|
44
|
+
"@ledgerhq/icons-ui": "^0.7.2",
|
|
45
45
|
"@ledgerhq/ui-shared": "^0.2.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
interface TabSelectorProps<T extends string | number> {
|
|
3
|
-
options: T[];
|
|
4
|
-
selectedOption: T;
|
|
5
|
-
handleSelectOption: (option: T) => void;
|
|
6
|
-
labels: {
|
|
7
|
-
[key in T]: string;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export default function TabSelector<T extends string | number>({ options, selectedOption, handleSelectOption, labels, }: TabSelectorProps<T>): JSX.Element;
|
|
11
|
-
export {};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from "react";
|
|
2
|
-
import Text from "../../Text";
|
|
3
|
-
import Flex from "../../Layout/Flex";
|
|
4
|
-
import styled, { useTheme } from "styled-components/native";
|
|
5
|
-
import { TouchableOpacity } from "react-native";
|
|
6
|
-
import Animated, { useSharedValue, useAnimatedStyle, withSpring } from "react-native-reanimated";
|
|
7
|
-
const StyledTouchableOpacity = styled(TouchableOpacity) `
|
|
8
|
-
flex: 1;
|
|
9
|
-
overflow: hidden;
|
|
10
|
-
`;
|
|
11
|
-
const StyledFlex = styled(Flex) `
|
|
12
|
-
width: 100%;
|
|
13
|
-
height: 100%;
|
|
14
|
-
justify-content: center;
|
|
15
|
-
align-items: center;
|
|
16
|
-
`;
|
|
17
|
-
const StyledText = styled(Text) `
|
|
18
|
-
line-height: 14.52px;
|
|
19
|
-
text-align: center;
|
|
20
|
-
font-size: 12px;
|
|
21
|
-
color: ${(p) => p.isSelected ? p.theme.colors.constant.black : p.theme.colors.opacityDefault.c50};
|
|
22
|
-
`;
|
|
23
|
-
const OptionButton = ({ option, selectedOption, handleSelectOption, label, }) => {
|
|
24
|
-
const isSelected = selectedOption === option;
|
|
25
|
-
return (React.createElement(StyledTouchableOpacity, { onPress: () => handleSelectOption(option) },
|
|
26
|
-
React.createElement(StyledFlex, { isSelected: isSelected },
|
|
27
|
-
React.createElement(StyledText, { fontWeight: "semiBold", isSelected: isSelected, ellipsizeMode: "tail", numberOfLines: 1 }, label))));
|
|
28
|
-
};
|
|
29
|
-
export default function TabSelector({ options, selectedOption, handleSelectOption, labels, }) {
|
|
30
|
-
const { colors } = useTheme();
|
|
31
|
-
const translateX = useSharedValue(-39);
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
translateX.value = withSpring(selectedOption === options[0] ? -40 : 40, {
|
|
34
|
-
damping: 30,
|
|
35
|
-
stiffness: 80,
|
|
36
|
-
});
|
|
37
|
-
}, [selectedOption, translateX, options]);
|
|
38
|
-
const animatedStyle = useAnimatedStyle(() => {
|
|
39
|
-
return {
|
|
40
|
-
transform: [{ translateX: translateX.value }],
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
return (React.createElement(Flex, { flexDirection: "row", justifyContent: "center", alignItems: "center", width: "157px", height: "35px", borderRadius: "40px", padding: "2px", bg: colors.opacityDefault.c05 },
|
|
44
|
-
React.createElement(Animated.View, { style: [
|
|
45
|
-
{
|
|
46
|
-
position: "absolute",
|
|
47
|
-
width: "48%",
|
|
48
|
-
height: "96%",
|
|
49
|
-
backgroundColor: colors.primary.c80,
|
|
50
|
-
borderRadius: 40,
|
|
51
|
-
},
|
|
52
|
-
animatedStyle,
|
|
53
|
-
] }),
|
|
54
|
-
options.map((option) => (React.createElement(OptionButton, { key: option, option: option, selectedOption: selectedOption, handleSelectOption: handleSelectOption, label: labels[option] })))));
|
|
55
|
-
}
|