@ledgerhq/native-ui 0.20.5-nightly.2 → 0.20.6-hotfix.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/lib/components/Cards/index.d.ts +0 -1
- package/lib/components/Cards/index.js +0 -1
- package/lib/components/Form/Input/index.d.ts +0 -1
- package/lib/components/Form/Input/index.js +0 -1
- package/lib/components/Form/SelectableList.d.ts +0 -1
- package/lib/components/Form/SelectableList.js +2 -2
- package/package.json +9 -9
- package/lib/components/Cards/BannerCard/index.d.ts +0 -25
- package/lib/components/Cards/BannerCard/index.js +0 -50
- package/lib/components/Form/Input/SquaredInput/index.d.ts +0 -119
- package/lib/components/Form/Input/SquaredInput/index.js +0 -107
- package/lib/components/Form/Input/SquaredSearchBar/index.d.ts +0 -14
- package/lib/components/Form/Input/SquaredSearchBar/index.js +0 -30
|
@@ -2,4 +2,3 @@ export { default as FullBackgroundCard } from "./FullBackgroundCard";
|
|
|
2
2
|
export { default as SideImageCard } from "./SideImageCard";
|
|
3
3
|
export { default as NotificationCard } from "./NotificationCard";
|
|
4
4
|
export { default as InformativeCard } from "./InformativeCard";
|
|
5
|
-
export { default as BannerCard } from "./BannerCard";
|
|
@@ -2,4 +2,3 @@ export { default as FullBackgroundCard } from "./FullBackgroundCard";
|
|
|
2
2
|
export { default as SideImageCard } from "./SideImageCard";
|
|
3
3
|
export { default as NotificationCard } from "./NotificationCard";
|
|
4
4
|
export { default as InformativeCard } from "./InformativeCard";
|
|
5
|
-
export { default as BannerCard } from "./BannerCard";
|
|
@@ -3,4 +3,3 @@ export { default as LegendInput } from "./LegendInput";
|
|
|
3
3
|
export { default as NumberInput } from "./NumberInput";
|
|
4
4
|
export { default as QrCodeInput } from "./QrCodeInput";
|
|
5
5
|
export { default as SearchInput } from "./SearchInput";
|
|
6
|
-
export { default as SquaredSearchBar } from "./SquaredSearchBar";
|
|
@@ -3,4 +3,3 @@ export { default as LegendInput } from "./LegendInput";
|
|
|
3
3
|
export { default as NumberInput } from "./NumberInput";
|
|
4
4
|
export { default as QrCodeInput } from "./QrCodeInput";
|
|
5
5
|
export { default as SearchInput } from "./SearchInput";
|
|
6
|
-
export { default as SquaredSearchBar } from "./SquaredSearchBar";
|
|
@@ -8,8 +8,8 @@ const ElementContainer = styled(Flex).attrs({
|
|
|
8
8
|
accessibilityRole: "radio",
|
|
9
9
|
}) ``;
|
|
10
10
|
function Element(props) {
|
|
11
|
-
const { first, value, selected, disabled, onPress, children, Icon, renderRight: RenderRight,
|
|
12
|
-
return (React.createElement(TouchableOpacity, { onPress: onPress, disabled: disabled
|
|
11
|
+
const { first, value, selected, disabled, onPress, children, Icon, renderRight: RenderRight, } = props;
|
|
12
|
+
return (React.createElement(TouchableOpacity, { onPress: onPress, disabled: disabled },
|
|
13
13
|
React.createElement(ElementContainer, { p: 6, mt: first ? 0 : 4, backgroundColor: selected ? "primary.c20" : "transparent", border: "1px solid", borderColor: selected ? "primary.c50" : "neutral.c40", borderRadius: 1, flexDirection: "row", alignItems: "center" },
|
|
14
14
|
Icon && (React.createElement(Flex, { mr: 6, flexShrink: 0 },
|
|
15
15
|
React.createElement(Icon, { size: 24, color: disabled ? "neutral.c50" : selected ? "primary.c90" : "neutral.c100" }))),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/native-ui",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.6-hotfix.0",
|
|
4
4
|
"description": "Ledger Live - Mobile UI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"styled-system": "^5.1.5",
|
|
48
48
|
"victory-native": "^35.5.5",
|
|
49
49
|
"@ledgerhq/crypto-icons-ui": "^0.5.1",
|
|
50
|
-
"@ledgerhq/icons-ui": "^0.
|
|
50
|
+
"@ledgerhq/icons-ui": "^0.5.0-hotfix.0",
|
|
51
51
|
"@ledgerhq/ui-shared": "^0.2.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
@@ -84,16 +84,16 @@
|
|
|
84
84
|
"@storybook/addon-controls": "^6.5.16",
|
|
85
85
|
"@storybook/addon-essentials": "^6.5.16",
|
|
86
86
|
"@storybook/addon-links": "^6.5.16",
|
|
87
|
-
"@storybook/addon-ondevice-actions": "6.5.
|
|
88
|
-
"@storybook/addon-ondevice-backgrounds": "6.5.
|
|
89
|
-
"@storybook/addon-ondevice-controls": "6.5.
|
|
90
|
-
"@storybook/addon-ondevice-notes": "6.5.
|
|
87
|
+
"@storybook/addon-ondevice-actions": "6.5.5",
|
|
88
|
+
"@storybook/addon-ondevice-backgrounds": "6.5.5",
|
|
89
|
+
"@storybook/addon-ondevice-controls": "6.5.5",
|
|
90
|
+
"@storybook/addon-ondevice-notes": "6.5.5",
|
|
91
91
|
"@storybook/addon-react-native-web": "^0.0.19",
|
|
92
92
|
"@storybook/builder-webpack5": "^6.5.14",
|
|
93
93
|
"@storybook/docs-tools": "^6.5.16",
|
|
94
94
|
"@storybook/manager-webpack5": "^6.5.14",
|
|
95
95
|
"@storybook/react": "^6.5.16",
|
|
96
|
-
"@storybook/react-native": "6.5.
|
|
96
|
+
"@storybook/react-native": "6.5.5",
|
|
97
97
|
"@svgr/core": "^5.5.0",
|
|
98
98
|
"@svgr/plugin-jsx": "^5.5.0",
|
|
99
99
|
"@svgr/plugin-svgo": "^5.5.0",
|
|
@@ -139,8 +139,8 @@
|
|
|
139
139
|
"react-native": "0.71.6",
|
|
140
140
|
"react-native-reanimated": "^3.1.0",
|
|
141
141
|
"react-native-safe-area-context": "^4.5.0",
|
|
142
|
-
"react-native-web": "~0.
|
|
143
|
-
"regenerator-runtime": "^0.
|
|
142
|
+
"react-native-web": "~0.18.12",
|
|
143
|
+
"regenerator-runtime": "^0.13.9",
|
|
144
144
|
"rimraf": "^4.4.1",
|
|
145
145
|
"styled-components": "^5.3.3",
|
|
146
146
|
"stylelint": "^14.9.1",
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/// <reference types="styled-components-react-native" />
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { TouchableOpacityProps, TouchableOpacity } from "react-native";
|
|
4
|
-
export type CardProps = TouchableOpacityProps & {
|
|
5
|
-
title?: string;
|
|
6
|
-
onPressDismiss?: () => void;
|
|
7
|
-
LeftElement?: JSX.Element;
|
|
8
|
-
typeOfRightIcon: "arrow" | "close";
|
|
9
|
-
};
|
|
10
|
-
type CloseProps = {
|
|
11
|
-
onPressDismiss?: () => void;
|
|
12
|
-
};
|
|
13
|
-
export declare const Container: import("styled-components").StyledComponent<typeof TouchableOpacity, import("styled-components").DefaultTheme, {}, never>;
|
|
14
|
-
export declare const CloseContainer: import("styled-components").StyledComponent<typeof TouchableOpacity, import("styled-components").DefaultTheme, {}, never>;
|
|
15
|
-
export declare const ChevronContainer: import("styled-components").StyledComponent<typeof import("react-native").View, import("styled-components").DefaultTheme, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").OverflowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & {
|
|
16
|
-
columnGap?: string | number | undefined;
|
|
17
|
-
rowGap?: string | number | undefined;
|
|
18
|
-
color?: string | undefined;
|
|
19
|
-
display?: string | undefined;
|
|
20
|
-
position?: string | undefined;
|
|
21
|
-
maxHeight?: string | number | undefined;
|
|
22
|
-
}, never>;
|
|
23
|
-
export declare const CloseButton: ({ onPressDismiss }: CloseProps) => JSX.Element;
|
|
24
|
-
declare const BannerCard: (props: CardProps) => React.ReactElement;
|
|
25
|
-
export default BannerCard;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ChevronRightMedium, CloseMedium } from "@ledgerhq/icons-ui/nativeLegacy";
|
|
3
|
-
import { TouchableOpacity } from "react-native";
|
|
4
|
-
import styled, { useTheme } from "styled-components/native";
|
|
5
|
-
import Text from "../../Text";
|
|
6
|
-
import Flex from "../../Layout/Flex";
|
|
7
|
-
export const Container = styled(TouchableOpacity) `
|
|
8
|
-
background: ${(p) => p.theme.colors.opacityDefault.c05};
|
|
9
|
-
flex-direction: row;
|
|
10
|
-
backdrop-filter: blur(62px);
|
|
11
|
-
border-radius: 12px;
|
|
12
|
-
height: 72px;
|
|
13
|
-
padding: ${(p) => p.theme.space[6]}px;
|
|
14
|
-
align-items: center;
|
|
15
|
-
justify-content: space-between;
|
|
16
|
-
z-index: 5;
|
|
17
|
-
`;
|
|
18
|
-
export const CloseContainer = styled(TouchableOpacity) `
|
|
19
|
-
background-color: ${(p) => p.theme.colors.opacityDefault.c05};
|
|
20
|
-
border-radius: 50;
|
|
21
|
-
height: 24px;
|
|
22
|
-
width: 24px;
|
|
23
|
-
display: flex;
|
|
24
|
-
align-items: center;
|
|
25
|
-
justify-content: center;
|
|
26
|
-
`;
|
|
27
|
-
export const ChevronContainer = styled(Flex) `
|
|
28
|
-
height: 24px;
|
|
29
|
-
width: 24px;
|
|
30
|
-
display: flex;
|
|
31
|
-
align-items: center;
|
|
32
|
-
justify-content: center;
|
|
33
|
-
`;
|
|
34
|
-
export const CloseButton = ({ onPressDismiss }) => {
|
|
35
|
-
const { colors } = useTheme();
|
|
36
|
-
return (React.createElement(CloseContainer, { onPress: onPressDismiss },
|
|
37
|
-
React.createElement(CloseMedium, { size: 14, color: colors.neutral.c100 })));
|
|
38
|
-
};
|
|
39
|
-
const CardContainer = (props) => {
|
|
40
|
-
const { onPressDismiss, LeftElement, title, typeOfRightIcon } = props;
|
|
41
|
-
return (React.createElement(Container, Object.assign({}, props),
|
|
42
|
-
React.createElement(Flex, { borderRadius: 50, height: 40, width: 40, alignItems: "center", justifyContent: "center", bg: "opacityDefault.c05" }, LeftElement),
|
|
43
|
-
React.createElement(Text, { mx: 4, variant: "large", fontWeight: "medium", numberOfLines: 3, maxWidth: "70%", color: "neutral.c100" }, title),
|
|
44
|
-
typeOfRightIcon === "close" ? (React.createElement(CloseButton, { onPressDismiss: onPressDismiss })) : (React.createElement(ChevronContainer, null,
|
|
45
|
-
React.createElement(ChevronRightMedium, { size: 24 })))));
|
|
46
|
-
};
|
|
47
|
-
const BannerCard = (props) => {
|
|
48
|
-
return React.createElement(CardContainer, Object.assign({}, props, { activeOpacity: 0.5 }));
|
|
49
|
-
};
|
|
50
|
-
export default BannerCard;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/// <reference types="styled-components-react-native" />
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { TextInput, TextInputProps, StyleProp, ViewStyle } from "react-native";
|
|
4
|
-
export type CommonProps = TextInputProps & {
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
error?: string;
|
|
7
|
-
};
|
|
8
|
-
export type InputProps<T = string> = Omit<CommonProps, "value" | "onChange"> & {
|
|
9
|
-
/**
|
|
10
|
-
* The value of the input.
|
|
11
|
-
*/
|
|
12
|
-
value: T;
|
|
13
|
-
/**
|
|
14
|
-
* A function that will render some content on the left side of the input.
|
|
15
|
-
*/
|
|
16
|
-
renderLeft?: ((props: InputProps<T>) => React.ReactNode) | React.ReactNode;
|
|
17
|
-
/**
|
|
18
|
-
* A function that will render some content on the right side of the input.
|
|
19
|
-
*/
|
|
20
|
-
renderRight?: ((props: InputProps<T>) => React.ReactNode) | React.ReactNode;
|
|
21
|
-
/**
|
|
22
|
-
* Triggered when the input value is updated.
|
|
23
|
-
*/
|
|
24
|
-
onChange?: (value: T) => void;
|
|
25
|
-
/**
|
|
26
|
-
* Same as onChange but preserves the native event passed as the callback argument.
|
|
27
|
-
*/
|
|
28
|
-
onChangeEvent?: TextInputProps["onChange"];
|
|
29
|
-
/**
|
|
30
|
-
* A function can be provided to serialize a value of any type to a string.
|
|
31
|
-
*
|
|
32
|
-
* This can be useful to wrap the `<SquaredInput />` component (which expects a string)
|
|
33
|
-
* and create higher-level components that will automatically perform the input/output
|
|
34
|
-
* conversion to other types.
|
|
35
|
-
*
|
|
36
|
-
* *A serializer function should always be used in conjunction with a deserializer function.*
|
|
37
|
-
*/
|
|
38
|
-
serialize?: (value: T) => string;
|
|
39
|
-
/**
|
|
40
|
-
* A deserializer can be provided to convert the html input value from a string to any other type.
|
|
41
|
-
*
|
|
42
|
-
* *A deserializer function should always be used in conjunction with a serializer function.*
|
|
43
|
-
*/
|
|
44
|
-
deserialize?: (value: string) => T;
|
|
45
|
-
/**
|
|
46
|
-
* Additional style for the container element.
|
|
47
|
-
*/
|
|
48
|
-
containerStyle?: StyleProp<ViewStyle>;
|
|
49
|
-
};
|
|
50
|
-
export declare const InputRenderLeftContainer: import("styled-components").StyledComponent<typeof import("react-native").View, import("styled-components").DefaultTheme, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").OverflowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & {
|
|
51
|
-
columnGap?: string | number | undefined;
|
|
52
|
-
rowGap?: string | number | undefined;
|
|
53
|
-
color?: string | undefined;
|
|
54
|
-
display?: string | undefined;
|
|
55
|
-
position?: string | undefined;
|
|
56
|
-
maxHeight?: string | number | undefined;
|
|
57
|
-
} & {
|
|
58
|
-
alignItems: string;
|
|
59
|
-
flexDirection: string;
|
|
60
|
-
pl: string;
|
|
61
|
-
}, "alignItems" | "flexDirection" | "pl">;
|
|
62
|
-
export declare const InputRenderRightContainer: import("styled-components").StyledComponent<typeof import("react-native").View, import("styled-components").DefaultTheme, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").OverflowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & {
|
|
63
|
-
columnGap?: string | number | undefined;
|
|
64
|
-
rowGap?: string | number | undefined;
|
|
65
|
-
color?: string | undefined;
|
|
66
|
-
display?: string | undefined;
|
|
67
|
-
position?: string | undefined;
|
|
68
|
-
maxHeight?: string | number | undefined;
|
|
69
|
-
} & {
|
|
70
|
-
alignItems: string;
|
|
71
|
-
flexDirection: string;
|
|
72
|
-
pr: string;
|
|
73
|
-
}, "alignItems" | "flexDirection" | "pr">;
|
|
74
|
-
declare function Input<T = string>(props: InputProps<T>, ref?: any): JSX.Element;
|
|
75
|
-
declare const _default: <T>(props: Omit<CommonProps, "onChange" | "value"> & {
|
|
76
|
-
/**
|
|
77
|
-
* The value of the input.
|
|
78
|
-
*/
|
|
79
|
-
value: T;
|
|
80
|
-
/**
|
|
81
|
-
* A function that will render some content on the left side of the input.
|
|
82
|
-
*/
|
|
83
|
-
renderLeft?: React.ReactNode | ((props: InputProps<T>) => React.ReactNode);
|
|
84
|
-
/**
|
|
85
|
-
* A function that will render some content on the right side of the input.
|
|
86
|
-
*/
|
|
87
|
-
renderRight?: React.ReactNode | ((props: InputProps<T>) => React.ReactNode);
|
|
88
|
-
/**
|
|
89
|
-
* Triggered when the input value is updated.
|
|
90
|
-
*/
|
|
91
|
-
onChange?: ((value: T) => void) | undefined;
|
|
92
|
-
/**
|
|
93
|
-
* Same as onChange but preserves the native event passed as the callback argument.
|
|
94
|
-
*/
|
|
95
|
-
onChangeEvent?: ((e: import("react-native").NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
|
|
96
|
-
/**
|
|
97
|
-
* A function can be provided to serialize a value of any type to a string.
|
|
98
|
-
*
|
|
99
|
-
* This can be useful to wrap the `<SquaredInput />` component (which expects a string)
|
|
100
|
-
* and create higher-level components that will automatically perform the input/output
|
|
101
|
-
* conversion to other types.
|
|
102
|
-
*
|
|
103
|
-
* *A serializer function should always be used in conjunction with a deserializer function.*
|
|
104
|
-
*/
|
|
105
|
-
serialize?: ((value: T) => string) | undefined;
|
|
106
|
-
/**
|
|
107
|
-
* A deserializer can be provided to convert the html input value from a string to any other type.
|
|
108
|
-
*
|
|
109
|
-
* *A deserializer function should always be used in conjunction with a serializer function.*
|
|
110
|
-
*/
|
|
111
|
-
deserialize?: ((value: string) => T) | undefined;
|
|
112
|
-
/**
|
|
113
|
-
* Additional style for the container element.
|
|
114
|
-
*/
|
|
115
|
-
containerStyle?: StyleProp<ViewStyle>;
|
|
116
|
-
} & {
|
|
117
|
-
ref?: React.ForwardedRef<TextInput> | undefined;
|
|
118
|
-
}) => ReturnType<typeof Input>;
|
|
119
|
-
export default _default;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import React, { useMemo, useCallback, useEffect, useImperativeHandle, useRef } from "react";
|
|
13
|
-
import styled, { css } from "styled-components/native";
|
|
14
|
-
import Text from "../../../Text";
|
|
15
|
-
import FlexBox from "../../../Layout/Flex";
|
|
16
|
-
const InputContainer = styled.View `
|
|
17
|
-
display: flex;
|
|
18
|
-
flex-direction: row;
|
|
19
|
-
width: 100%;
|
|
20
|
-
background: ${(p) => p.theme.colors.opacityDefault.c05};
|
|
21
|
-
height: 48px;
|
|
22
|
-
border-radius: 8px;
|
|
23
|
-
color: ${(p) => p.theme.colors.neutral.c100};
|
|
24
|
-
|
|
25
|
-
${(p) => p.disabled &&
|
|
26
|
-
css `
|
|
27
|
-
color: ${p.theme.colors.neutral.c60};
|
|
28
|
-
background: ${(p) => p.theme.colors.neutral.c30};
|
|
29
|
-
`};
|
|
30
|
-
|
|
31
|
-
${(p) => p.focus &&
|
|
32
|
-
!p.error &&
|
|
33
|
-
css `
|
|
34
|
-
border: 1px solid ${p.theme.colors.primary.c80};
|
|
35
|
-
`};
|
|
36
|
-
|
|
37
|
-
${(p) => p.error &&
|
|
38
|
-
!p.disabled &&
|
|
39
|
-
css `
|
|
40
|
-
border: 1px solid ${p.theme.colors.error.c50};
|
|
41
|
-
`};
|
|
42
|
-
|
|
43
|
-
${(p) => p.disabled &&
|
|
44
|
-
css `
|
|
45
|
-
color: ${p.theme.colors.neutral.c60};
|
|
46
|
-
background: ${(p) => p.theme.colors.neutral.c30};
|
|
47
|
-
`};
|
|
48
|
-
`;
|
|
49
|
-
const SquaredInput = styled.TextInput.attrs((p) => ({
|
|
50
|
-
selectionColor: p.theme.colors.primary.c80,
|
|
51
|
-
color: p.theme.colors.neutral.c100,
|
|
52
|
-
placeholderTextColor: p.theme.colors.neutral.c70,
|
|
53
|
-
})) `
|
|
54
|
-
height: 100%;
|
|
55
|
-
width: 100%;
|
|
56
|
-
border: 0;
|
|
57
|
-
flex-shrink: 1;
|
|
58
|
-
padding-top: 14px;
|
|
59
|
-
padding-bottom: 14px;
|
|
60
|
-
padding-left: 8px;
|
|
61
|
-
padding-right: 8px;
|
|
62
|
-
`;
|
|
63
|
-
const InputErrorContainer = styled(Text) `
|
|
64
|
-
color: ${(p) => p.theme.colors.error.c50};
|
|
65
|
-
margin-left: 12px;
|
|
66
|
-
`;
|
|
67
|
-
export const InputRenderLeftContainer = styled(FlexBox).attrs(() => ({
|
|
68
|
-
alignItems: "center",
|
|
69
|
-
flexDirection: "row",
|
|
70
|
-
pl: "16px",
|
|
71
|
-
})) ``;
|
|
72
|
-
export const InputRenderRightContainer = styled(FlexBox).attrs(() => ({
|
|
73
|
-
alignItems: "center",
|
|
74
|
-
flexDirection: "row",
|
|
75
|
-
pr: "16px",
|
|
76
|
-
})) ``;
|
|
77
|
-
// Yes, this is dirty. If you can figure out a better way please change the code :).
|
|
78
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
-
const IDENTITY = (_) => _;
|
|
80
|
-
function Input(props, ref) {
|
|
81
|
-
const { value, onChange, onChangeText, onChangeEvent, disabled, error, renderLeft, renderRight, serialize = IDENTITY, deserialize = IDENTITY, containerStyle, autoFocus, onFocus, onBlur } = props, textInputProps = __rest(props, ["value", "onChange", "onChangeText", "onChangeEvent", "disabled", "error", "renderLeft", "renderRight", "serialize", "deserialize", "containerStyle", "autoFocus", "onFocus", "onBlur"]);
|
|
82
|
-
const inputRef = useRef();
|
|
83
|
-
useImperativeHandle(ref, () => inputRef.current, [inputRef]);
|
|
84
|
-
const inputValue = useMemo(() => serialize(value), [serialize, value]);
|
|
85
|
-
const handleChange = useCallback((value) => {
|
|
86
|
-
onChange && onChange(deserialize(value));
|
|
87
|
-
onChangeText && onChangeText(value);
|
|
88
|
-
}, [onChange, onChangeText, deserialize]);
|
|
89
|
-
useEffect(() => {
|
|
90
|
-
if (autoFocus && inputRef && inputRef.current && inputRef.current.focus)
|
|
91
|
-
inputRef.current.focus();
|
|
92
|
-
}, [inputRef, autoFocus]);
|
|
93
|
-
const [focus, setFocus] = React.useState(false);
|
|
94
|
-
return (React.createElement(FlexBox, { width: "100%", style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
|
|
95
|
-
React.createElement(InputContainer, { disabled: disabled, focus: focus, error: error },
|
|
96
|
-
typeof renderLeft === "function" ? renderLeft(props) : renderLeft,
|
|
97
|
-
React.createElement(SquaredInput, Object.assign({ ref: inputRef }, textInputProps, { value: inputValue, onChange: onChangeEvent, onChangeText: handleChange, editable: !disabled, disabled: disabled, error: error, onFocus: (e) => {
|
|
98
|
-
setFocus(true);
|
|
99
|
-
typeof onFocus === "function" && onFocus(e);
|
|
100
|
-
}, onBlur: (e) => {
|
|
101
|
-
setFocus(false);
|
|
102
|
-
typeof onBlur === "function" && onBlur(e);
|
|
103
|
-
} })),
|
|
104
|
-
typeof renderRight === "function" ? renderRight(props) : renderRight),
|
|
105
|
-
!!error && !disabled && React.createElement(InputErrorContainer, null, error)));
|
|
106
|
-
}
|
|
107
|
-
export default React.forwardRef(Input);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { TextInput } from "react-native";
|
|
3
|
-
import { InputProps } from "../SquaredInput";
|
|
4
|
-
declare const _default: React.ForwardRefExoticComponent<Omit<import("../SquaredInput").CommonProps, "onChange" | "value"> & {
|
|
5
|
-
value: string;
|
|
6
|
-
renderLeft?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
|
|
7
|
-
renderRight?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
|
|
8
|
-
onChange?: ((value: string) => void) | undefined;
|
|
9
|
-
onChangeEvent?: ((e: import("react-native").NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
|
|
10
|
-
serialize?: ((value: string) => string) | undefined;
|
|
11
|
-
deserialize?: ((value: string) => string) | undefined;
|
|
12
|
-
containerStyle?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
13
|
-
} & React.RefAttributes<TextInput>>;
|
|
14
|
-
export default _default;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import React, { useCallback } from "react";
|
|
13
|
-
import styled from "styled-components/native";
|
|
14
|
-
import Input, { InputRenderLeftContainer } from "../SquaredInput";
|
|
15
|
-
import SearchMedium from "@ledgerhq/icons-ui/nativeLegacy/SearchMedium";
|
|
16
|
-
import Button from "../../../cta/Button";
|
|
17
|
-
const Icon = styled(SearchMedium).attrs((p) => ({
|
|
18
|
-
color: p.theme.colors.neutral.c70,
|
|
19
|
-
})) ``;
|
|
20
|
-
function SquaredSearchBar(_a, ref) {
|
|
21
|
-
var { onChange, value } = _a, props = __rest(_a, ["onChange", "value"]);
|
|
22
|
-
const onClear = useCallback(() => {
|
|
23
|
-
if (onChange) {
|
|
24
|
-
onChange("");
|
|
25
|
-
}
|
|
26
|
-
}, [onChange]);
|
|
27
|
-
return (React.createElement(Input, Object.assign({ ref: ref, onChange: onChange, value: value }, props, { renderLeft: React.createElement(InputRenderLeftContainer, null,
|
|
28
|
-
React.createElement(Icon, { size: 20 })), renderRight: value ? React.createElement(Button, { iconName: "Close", onPress: onClear }) : null })));
|
|
29
|
-
}
|
|
30
|
-
export default React.forwardRef(SquaredSearchBar);
|