@ledgerhq/native-ui 0.22.3-nightly.0 → 0.22.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/Input/BaseInput/index.d.ts +7 -51
- package/lib/components/Form/Input/BaseInput/index.js +14 -13
- package/lib/components/Form/Input/LegendInput/index.d.ts +2 -12
- package/lib/components/Form/Input/NumberInput/index.d.ts +2 -12
- package/lib/components/Form/Input/QrCodeInput/index.d.ts +2 -12
- package/lib/components/Form/Input/SearchInput/index.d.ts +2 -12
- package/lib/components/Form/Input/index.d.ts +0 -1
- package/lib/components/Form/Input/index.js +0 -1
- package/package.json +2 -2
- package/lib/components/Form/Input/AnimatedInput/AnimatedNotchedLabel.d.ts +0 -8
- package/lib/components/Form/Input/AnimatedInput/AnimatedNotchedLabel.js +0 -77
- package/lib/components/Form/Input/AnimatedInput/index.d.ts +0 -9
- package/lib/components/Form/Input/AnimatedInput/index.js +0 -52
- package/lib/components/Form/Input/AnimatedInput/inputTextColor.d.ts +0 -29
- package/lib/components/Form/Input/AnimatedInput/inputTextColor.js +0 -27
- package/lib/components/Form/Input/AnimatedInput/useAnimatedInputFocus.d.ts +0 -11
- package/lib/components/Form/Input/AnimatedInput/useAnimatedInputFocus.js +0 -13
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="styled-components-react-native" />
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { TextInput, TextInputProps, StyleProp, ViewStyle
|
|
3
|
+
import { TextInput, TextInputProps, StyleProp, ViewStyle } from "react-native";
|
|
4
4
|
export type CommonProps = TextInputProps & {
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
error?: string;
|
|
@@ -13,15 +13,11 @@ export type InputProps<T = string> = Omit<CommonProps, "value" | "onChange"> & {
|
|
|
13
13
|
/**
|
|
14
14
|
* A function that will render some content on the left side of the input.
|
|
15
15
|
*/
|
|
16
|
-
renderLeft?: ((props: InputProps<T
|
|
17
|
-
clear: () => void;
|
|
18
|
-
}>) => React.ReactNode) | React.ReactNode;
|
|
16
|
+
renderLeft?: ((props: InputProps<T>) => React.ReactNode) | React.ReactNode;
|
|
19
17
|
/**
|
|
20
18
|
* A function that will render some content on the right side of the input.
|
|
21
19
|
*/
|
|
22
|
-
renderRight?: ((props: InputProps<T
|
|
23
|
-
clear: () => void;
|
|
24
|
-
}>) => React.ReactNode) | React.ReactNode;
|
|
20
|
+
renderRight?: ((props: InputProps<T>) => React.ReactNode) | React.ReactNode;
|
|
25
21
|
/**
|
|
26
22
|
* Triggered when the input value is updated.
|
|
27
23
|
*/
|
|
@@ -50,24 +46,6 @@ export type InputProps<T = string> = Omit<CommonProps, "value" | "onChange"> & {
|
|
|
50
46
|
* Additional style for the container element.
|
|
51
47
|
*/
|
|
52
48
|
containerStyle?: StyleProp<ViewStyle>;
|
|
53
|
-
/**
|
|
54
|
-
* Additional style for the input container element.
|
|
55
|
-
*/
|
|
56
|
-
inputContainerStyle?: StyleProp<ViewStyle> & TextStyle;
|
|
57
|
-
/**
|
|
58
|
-
* Additional style for the baseInput container element.
|
|
59
|
-
*/
|
|
60
|
-
baseInputContainerStyle?: TextStyle;
|
|
61
|
-
/**
|
|
62
|
-
* Additional style for the error container element.
|
|
63
|
-
*/
|
|
64
|
-
inputErrorContainerStyles?: StyleProp<ViewStyle>;
|
|
65
|
-
inputErrorColor?: string;
|
|
66
|
-
showErrorIcon?: boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Optional text color parameter.
|
|
69
|
-
*/
|
|
70
|
-
color?: string;
|
|
71
49
|
};
|
|
72
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>> & {
|
|
73
51
|
columnGap?: string | number | undefined;
|
|
@@ -79,7 +57,7 @@ export declare const InputRenderLeftContainer: import("styled-components").Style
|
|
|
79
57
|
} & {
|
|
80
58
|
alignItems: string;
|
|
81
59
|
flexDirection: string;
|
|
82
|
-
pl:
|
|
60
|
+
pl: string;
|
|
83
61
|
}, "alignItems" | "flexDirection" | "pl">;
|
|
84
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>> & {
|
|
85
63
|
columnGap?: string | number | undefined;
|
|
@@ -91,7 +69,7 @@ export declare const InputRenderRightContainer: import("styled-components").Styl
|
|
|
91
69
|
} & {
|
|
92
70
|
alignItems: string;
|
|
93
71
|
flexDirection: string;
|
|
94
|
-
pr:
|
|
72
|
+
pr: string;
|
|
95
73
|
}, "alignItems" | "flexDirection" | "pr">;
|
|
96
74
|
declare function Input<T = string>(props: InputProps<T>, ref?: any): JSX.Element;
|
|
97
75
|
declare const _default: <T>(props: Omit<CommonProps, "onChange" | "value"> & {
|
|
@@ -102,15 +80,11 @@ declare const _default: <T>(props: Omit<CommonProps, "onChange" | "value"> & {
|
|
|
102
80
|
/**
|
|
103
81
|
* A function that will render some content on the left side of the input.
|
|
104
82
|
*/
|
|
105
|
-
renderLeft?: React.ReactNode | ((props: InputProps<T
|
|
106
|
-
clear: () => void;
|
|
107
|
-
}>) => React.ReactNode);
|
|
83
|
+
renderLeft?: React.ReactNode | ((props: InputProps<T>) => React.ReactNode);
|
|
108
84
|
/**
|
|
109
85
|
* A function that will render some content on the right side of the input.
|
|
110
86
|
*/
|
|
111
|
-
renderRight?: React.ReactNode | ((props: InputProps<T
|
|
112
|
-
clear: () => void;
|
|
113
|
-
}>) => React.ReactNode);
|
|
87
|
+
renderRight?: React.ReactNode | ((props: InputProps<T>) => React.ReactNode);
|
|
114
88
|
/**
|
|
115
89
|
* Triggered when the input value is updated.
|
|
116
90
|
*/
|
|
@@ -139,24 +113,6 @@ declare const _default: <T>(props: Omit<CommonProps, "onChange" | "value"> & {
|
|
|
139
113
|
* Additional style for the container element.
|
|
140
114
|
*/
|
|
141
115
|
containerStyle?: StyleProp<ViewStyle>;
|
|
142
|
-
/**
|
|
143
|
-
* Additional style for the input container element.
|
|
144
|
-
*/
|
|
145
|
-
inputContainerStyle?: (StyleProp<ViewStyle> & TextStyle) | undefined;
|
|
146
|
-
/**
|
|
147
|
-
* Additional style for the baseInput container element.
|
|
148
|
-
*/
|
|
149
|
-
baseInputContainerStyle?: TextStyle | undefined;
|
|
150
|
-
/**
|
|
151
|
-
* Additional style for the error container element.
|
|
152
|
-
*/
|
|
153
|
-
inputErrorContainerStyles?: StyleProp<ViewStyle>;
|
|
154
|
-
inputErrorColor?: string | undefined;
|
|
155
|
-
showErrorIcon?: boolean | undefined;
|
|
156
|
-
/**
|
|
157
|
-
* Optional text color parameter.
|
|
158
|
-
*/
|
|
159
|
-
color?: string | undefined;
|
|
160
116
|
} & {
|
|
161
117
|
ref?: React.ForwardedRef<TextInput> | undefined;
|
|
162
118
|
}) => ReturnType<typeof Input>;
|
|
@@ -13,7 +13,6 @@ import React, { useMemo, useCallback, useEffect, useImperativeHandle, useRef } f
|
|
|
13
13
|
import styled, { css } from "styled-components/native";
|
|
14
14
|
import Text from "../../../Text";
|
|
15
15
|
import FlexBox from "../../../Layout/Flex";
|
|
16
|
-
import { DeleteCircleFill } from "@ledgerhq/icons-ui/native";
|
|
17
16
|
const InputContainer = styled.View `
|
|
18
17
|
display: flex;
|
|
19
18
|
flex-direction: row;
|
|
@@ -57,26 +56,30 @@ const BaseInput = styled.TextInput.attrs((p) => ({
|
|
|
57
56
|
width: 100%;
|
|
58
57
|
border: 0;
|
|
59
58
|
flex-shrink: 1;
|
|
60
|
-
padding: 14px
|
|
59
|
+
padding-top: 14px;
|
|
60
|
+
padding-bottom: 14px;
|
|
61
|
+
padding-left: 20px;
|
|
62
|
+
padding-right: 20px;
|
|
61
63
|
`;
|
|
62
|
-
const
|
|
64
|
+
const InputErrorContainer = styled(Text) `
|
|
63
65
|
color: ${(p) => p.theme.colors.error.c50};
|
|
66
|
+
margin-left: 12px;
|
|
64
67
|
`;
|
|
65
68
|
export const InputRenderLeftContainer = styled(FlexBox).attrs(() => ({
|
|
66
69
|
alignItems: "center",
|
|
67
70
|
flexDirection: "row",
|
|
68
|
-
pl:
|
|
71
|
+
pl: "16px",
|
|
69
72
|
})) ``;
|
|
70
73
|
export const InputRenderRightContainer = styled(FlexBox).attrs(() => ({
|
|
71
74
|
alignItems: "center",
|
|
72
75
|
flexDirection: "row",
|
|
73
|
-
pr:
|
|
76
|
+
pr: "16px",
|
|
74
77
|
})) ``;
|
|
75
78
|
// Yes, this is dirty. If you can figure out a better way please change the code :).
|
|
76
79
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
80
|
const IDENTITY = (_) => _;
|
|
78
81
|
function Input(props, ref) {
|
|
79
|
-
const { value, onChange, onChangeText, onChangeEvent, disabled, error, renderLeft, renderRight, serialize = IDENTITY, deserialize = IDENTITY, containerStyle,
|
|
82
|
+
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"]);
|
|
80
83
|
const inputRef = useRef();
|
|
81
84
|
useImperativeHandle(ref, () => inputRef.current, [inputRef]);
|
|
82
85
|
const inputValue = useMemo(() => serialize(value), [serialize, value]);
|
|
@@ -90,18 +93,16 @@ function Input(props, ref) {
|
|
|
90
93
|
}, [inputRef, autoFocus]);
|
|
91
94
|
const [focus, setFocus] = React.useState(false);
|
|
92
95
|
return (React.createElement(FlexBox, { width: "100%", style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
|
|
93
|
-
React.createElement(InputContainer, { disabled: disabled, focus: focus, error: error
|
|
94
|
-
typeof renderLeft === "function" ? renderLeft(props
|
|
96
|
+
React.createElement(InputContainer, { disabled: disabled, focus: focus, error: error },
|
|
97
|
+
typeof renderLeft === "function" ? renderLeft(props) : renderLeft,
|
|
95
98
|
React.createElement(BaseInput, Object.assign({ ref: inputRef }, textInputProps, { value: inputValue, onChange: onChangeEvent, onChangeText: handleChange, editable: !disabled, disabled: disabled, error: error, onFocus: (e) => {
|
|
96
99
|
setFocus(true);
|
|
97
100
|
typeof onFocus === "function" && onFocus(e);
|
|
98
101
|
}, onBlur: (e) => {
|
|
99
102
|
setFocus(false);
|
|
100
103
|
typeof onBlur === "function" && onBlur(e);
|
|
101
|
-
}
|
|
102
|
-
typeof renderRight === "function" ? renderRight(props
|
|
103
|
-
!!error && !disabled &&
|
|
104
|
-
showErrorIcon && React.createElement(DeleteCircleFill, { color: inputErrorColor, size: "S" }),
|
|
105
|
-
React.createElement(InputErrorText, { color: inputErrorColor, variant: "small", ml: 2 }, error)))));
|
|
104
|
+
} })),
|
|
105
|
+
typeof renderRight === "function" ? renderRight(props) : renderRight),
|
|
106
|
+
!!error && !disabled && React.createElement(InputErrorContainer, null, error)));
|
|
106
107
|
}
|
|
107
108
|
export default React.forwardRef(Input);
|
|
@@ -3,23 +3,13 @@ import { TextInput } from "react-native";
|
|
|
3
3
|
import { InputProps } from "../BaseInput";
|
|
4
4
|
declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInput").CommonProps, "onChange" | "value"> & {
|
|
5
5
|
value: string;
|
|
6
|
-
renderLeft?: React.ReactNode | ((props: InputProps<string
|
|
7
|
-
|
|
8
|
-
}>) => React.ReactNode);
|
|
9
|
-
renderRight?: React.ReactNode | ((props: InputProps<string>, ref: React.RefObject<{
|
|
10
|
-
clear: () => void;
|
|
11
|
-
}>) => React.ReactNode);
|
|
6
|
+
renderLeft?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
|
|
7
|
+
renderRight?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
|
|
12
8
|
onChange?: ((value: string) => void) | undefined;
|
|
13
9
|
onChangeEvent?: ((e: import("react-native").NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
|
|
14
10
|
serialize?: ((value: string) => string) | undefined;
|
|
15
11
|
deserialize?: ((value: string) => string) | undefined;
|
|
16
12
|
containerStyle?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
17
|
-
inputContainerStyle?: (import("react-native").StyleProp<import("react-native").ViewStyle> & import("react-native").TextStyle) | undefined;
|
|
18
|
-
baseInputContainerStyle?: import("react-native").TextStyle | undefined;
|
|
19
|
-
inputErrorContainerStyles?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
20
|
-
inputErrorColor?: string | undefined;
|
|
21
|
-
showErrorIcon?: boolean | undefined;
|
|
22
|
-
color?: string | undefined;
|
|
23
13
|
} & {
|
|
24
14
|
legend: string;
|
|
25
15
|
} & React.RefAttributes<TextInput>>;
|
|
@@ -3,23 +3,13 @@ import { TextInput } from "react-native";
|
|
|
3
3
|
import { InputProps } from "../BaseInput";
|
|
4
4
|
declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInput").CommonProps, "onChange" | "value"> & {
|
|
5
5
|
value: number | undefined;
|
|
6
|
-
renderLeft?: React.ReactNode | ((props: InputProps<number | undefined
|
|
7
|
-
|
|
8
|
-
}>) => React.ReactNode);
|
|
9
|
-
renderRight?: React.ReactNode | ((props: InputProps<number | undefined>, ref: React.RefObject<{
|
|
10
|
-
clear: () => void;
|
|
11
|
-
}>) => React.ReactNode);
|
|
6
|
+
renderLeft?: React.ReactNode | ((props: InputProps<number | undefined>) => React.ReactNode);
|
|
7
|
+
renderRight?: React.ReactNode | ((props: InputProps<number | undefined>) => React.ReactNode);
|
|
12
8
|
onChange?: ((value: number | undefined) => void) | undefined;
|
|
13
9
|
onChangeEvent?: ((e: import("react-native").NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
|
|
14
10
|
serialize?: ((value: number | undefined) => string) | undefined;
|
|
15
11
|
deserialize?: ((value: string) => number | undefined) | undefined;
|
|
16
12
|
containerStyle?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
17
|
-
inputContainerStyle?: (import("react-native").StyleProp<import("react-native").ViewStyle> & import("react-native").TextStyle) | undefined;
|
|
18
|
-
baseInputContainerStyle?: import("react-native").TextStyle | undefined;
|
|
19
|
-
inputErrorContainerStyles?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
20
|
-
inputErrorColor?: string | undefined;
|
|
21
|
-
showErrorIcon?: boolean | undefined;
|
|
22
|
-
color?: string | undefined;
|
|
23
13
|
} & {
|
|
24
14
|
onPercentClick: (percent: number) => void;
|
|
25
15
|
min?: number | undefined;
|
|
@@ -4,23 +4,13 @@ import { GestureResponderEvent } from "react-native";
|
|
|
4
4
|
import { InputProps } from "../BaseInput";
|
|
5
5
|
declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInput").CommonProps, "onChange" | "value"> & {
|
|
6
6
|
value: string;
|
|
7
|
-
renderLeft?: React.ReactNode | ((props: InputProps<string
|
|
8
|
-
|
|
9
|
-
}>) => React.ReactNode);
|
|
10
|
-
renderRight?: React.ReactNode | ((props: InputProps<string>, ref: React.RefObject<{
|
|
11
|
-
clear: () => void;
|
|
12
|
-
}>) => React.ReactNode);
|
|
7
|
+
renderLeft?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
|
|
8
|
+
renderRight?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
|
|
13
9
|
onChange?: ((value: string) => void) | undefined;
|
|
14
10
|
onChangeEvent?: ((e: import("react-native").NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
|
|
15
11
|
serialize?: ((value: string) => string) | undefined;
|
|
16
12
|
deserialize?: ((value: string) => string) | undefined;
|
|
17
13
|
containerStyle?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
18
|
-
inputContainerStyle?: (import("react-native").StyleProp<import("react-native").ViewStyle> & import("react-native").TextStyle) | undefined;
|
|
19
|
-
baseInputContainerStyle?: import("react-native").TextStyle | undefined;
|
|
20
|
-
inputErrorContainerStyles?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
21
|
-
inputErrorColor?: string | undefined;
|
|
22
|
-
showErrorIcon?: boolean | undefined;
|
|
23
|
-
color?: string | undefined;
|
|
24
14
|
} & {
|
|
25
15
|
onQrCodeClick?: ((event: GestureResponderEvent) => void) | undefined;
|
|
26
16
|
} & React.RefAttributes<TextInput>>;
|
|
@@ -3,22 +3,12 @@ import { TextInput } from "react-native";
|
|
|
3
3
|
import { InputProps } from "../BaseInput";
|
|
4
4
|
declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInput").CommonProps, "onChange" | "value"> & {
|
|
5
5
|
value: string;
|
|
6
|
-
renderLeft?: React.ReactNode | ((props: InputProps<string
|
|
7
|
-
|
|
8
|
-
}>) => React.ReactNode);
|
|
9
|
-
renderRight?: React.ReactNode | ((props: InputProps<string>, ref: React.RefObject<{
|
|
10
|
-
clear: () => void;
|
|
11
|
-
}>) => React.ReactNode);
|
|
6
|
+
renderLeft?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
|
|
7
|
+
renderRight?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
|
|
12
8
|
onChange?: ((value: string) => void) | undefined;
|
|
13
9
|
onChangeEvent?: ((e: import("react-native").NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
|
|
14
10
|
serialize?: ((value: string) => string) | undefined;
|
|
15
11
|
deserialize?: ((value: string) => string) | undefined;
|
|
16
12
|
containerStyle?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
17
|
-
inputContainerStyle?: (import("react-native").StyleProp<import("react-native").ViewStyle> & import("react-native").TextStyle) | undefined;
|
|
18
|
-
baseInputContainerStyle?: import("react-native").TextStyle | undefined;
|
|
19
|
-
inputErrorContainerStyles?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
20
|
-
inputErrorColor?: string | undefined;
|
|
21
|
-
showErrorIcon?: boolean | undefined;
|
|
22
|
-
color?: string | undefined;
|
|
23
13
|
} & React.RefAttributes<TextInput>>;
|
|
24
14
|
export default _default;
|
|
@@ -4,4 +4,3 @@ export { default as NumberInput } from "./NumberInput";
|
|
|
4
4
|
export { default as QrCodeInput } from "./QrCodeInput";
|
|
5
5
|
export { default as SearchInput } from "./SearchInput";
|
|
6
6
|
export { default as SquaredSearchBar } from "./SquaredSearchBar";
|
|
7
|
-
export { default as AnimatedInput } from "./AnimatedInput";
|
|
@@ -4,4 +4,3 @@ export { default as NumberInput } from "./NumberInput";
|
|
|
4
4
|
export { default as QrCodeInput } from "./QrCodeInput";
|
|
5
5
|
export { default as SearchInput } from "./SearchInput";
|
|
6
6
|
export { default as SquaredSearchBar } from "./SquaredSearchBar";
|
|
7
|
-
export { default as AnimatedInput } from "./AnimatedInput";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/native-ui",
|
|
3
|
-
"version": "0.22.3
|
|
3
|
+
"version": "0.22.3",
|
|
4
4
|
"description": "Ledger Live - Mobile UI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"rn-range-slider": "2.1.1",
|
|
43
43
|
"styled-system": "^5.1.5",
|
|
44
44
|
"victory-native": "^35.5.5",
|
|
45
|
-
"@ledgerhq/crypto-icons-ui": "^0.
|
|
45
|
+
"@ledgerhq/crypto-icons-ui": "^0.7.0",
|
|
46
46
|
"@ledgerhq/icons-ui": "^0.6.2",
|
|
47
47
|
"@ledgerhq/ui-shared": "^0.2.1"
|
|
48
48
|
},
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { InputStatus } from ".";
|
|
3
|
-
type AnimatedNotchedLabelProps = {
|
|
4
|
-
placeholder: string;
|
|
5
|
-
inputStatus: InputStatus;
|
|
6
|
-
};
|
|
7
|
-
export declare const AnimatedNotchedLabel: ({ placeholder, inputStatus }: AnimatedNotchedLabelProps) => React.JSX.Element;
|
|
8
|
-
export {};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import styled from "styled-components/native";
|
|
3
|
-
import { Flex } from "../../../Layout";
|
|
4
|
-
import { Text } from "react-native";
|
|
5
|
-
import Animated, { useSharedValue, withTiming, useAnimatedStyle, useAnimatedReaction, Easing, } from "react-native-reanimated";
|
|
6
|
-
import { inputTextColor, inputStatusColors, inputBackgroundColor } from "./inputTextColor";
|
|
7
|
-
const labelPadding = 4;
|
|
8
|
-
const labelInitialPositions = {
|
|
9
|
-
top: 20.5,
|
|
10
|
-
left: 16 - labelPadding,
|
|
11
|
-
fontSize: 16,
|
|
12
|
-
};
|
|
13
|
-
const labelFinalPositions = {
|
|
14
|
-
top: -7,
|
|
15
|
-
left: 16 - labelPadding,
|
|
16
|
-
fontSize: 12,
|
|
17
|
-
};
|
|
18
|
-
const LabelContainer = styled(Animated.View) `
|
|
19
|
-
position: absolute;
|
|
20
|
-
padding: ${`0 ${labelPadding}px`};
|
|
21
|
-
display: inline-block;
|
|
22
|
-
height: 15;
|
|
23
|
-
z-index: ${(p) => (p.notched ? 3 : 0)};
|
|
24
|
-
`;
|
|
25
|
-
const AnimatedText = Animated.createAnimatedComponent(Text);
|
|
26
|
-
const LabelText = styled(AnimatedText) `
|
|
27
|
-
display: inline-block;
|
|
28
|
-
height: 15;
|
|
29
|
-
line-height: 15;
|
|
30
|
-
vertical-align: top;
|
|
31
|
-
color: ${(p) => p.status === "default" ? inputTextColor[p.status] : inputStatusColors[p.status]};
|
|
32
|
-
`;
|
|
33
|
-
const LineCutout = styled(Flex) `
|
|
34
|
-
position: absolute;
|
|
35
|
-
height: 1;
|
|
36
|
-
top: 7;
|
|
37
|
-
left: 0;
|
|
38
|
-
width: 120%;
|
|
39
|
-
background: ${(p) => inputBackgroundColor[p.status]};
|
|
40
|
-
`;
|
|
41
|
-
export const AnimatedNotchedLabel = ({ placeholder, inputStatus }) => {
|
|
42
|
-
const notched = inputStatus !== "default";
|
|
43
|
-
const labelTop = useSharedValue(notched ? labelFinalPositions.top : labelInitialPositions.top);
|
|
44
|
-
const labelLeft = useSharedValue(notched ? labelFinalPositions.left : labelInitialPositions.left);
|
|
45
|
-
const fontSize = useSharedValue(notched ? labelFinalPositions.fontSize : labelInitialPositions.fontSize);
|
|
46
|
-
const labelStyle = useAnimatedStyle(() => {
|
|
47
|
-
return {
|
|
48
|
-
top: labelTop.value,
|
|
49
|
-
left: labelLeft.value,
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
const labelFontSize = useAnimatedStyle(() => {
|
|
53
|
-
return {
|
|
54
|
-
fontSize: fontSize.value,
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
useAnimatedReaction(() => notched, (isNotched) => {
|
|
58
|
-
const targetTop = isNotched ? labelFinalPositions.top : labelInitialPositions.top;
|
|
59
|
-
const targetLeft = isNotched ? labelFinalPositions.left : labelInitialPositions.left;
|
|
60
|
-
const targetSize = isNotched ? labelFinalPositions.fontSize : labelInitialPositions.fontSize;
|
|
61
|
-
labelTop.value = withTiming(targetTop, undefined, () => ({
|
|
62
|
-
duration: 200,
|
|
63
|
-
easing: Easing.inOut(Easing.quad),
|
|
64
|
-
}));
|
|
65
|
-
labelLeft.value = withTiming(targetLeft, undefined, () => ({
|
|
66
|
-
duration: 200,
|
|
67
|
-
easing: Easing.inOut(Easing.quad),
|
|
68
|
-
}));
|
|
69
|
-
fontSize.value = withTiming(targetSize, undefined, () => ({
|
|
70
|
-
duration: 100,
|
|
71
|
-
easing: Easing.inOut(Easing.quad),
|
|
72
|
-
}));
|
|
73
|
-
}, [notched]);
|
|
74
|
-
return (React.createElement(LabelContainer, { style: Object.assign(Object.assign({}, labelStyle), { elevation: notched ? 3 : 0 }), notched: notched },
|
|
75
|
-
notched && React.createElement(LineCutout, { status: inputStatus }),
|
|
76
|
-
React.createElement(LabelText, { style: Object.assign({}, labelFontSize), status: inputStatus }, placeholder)));
|
|
77
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { type InputProps as BaseInputType } from "../BaseInput/index";
|
|
3
|
-
import { StyleProp, ViewStyle } from "react-native";
|
|
4
|
-
export type InputStatus = "default" | "focused" | "filled" | "error";
|
|
5
|
-
export interface AnimatedInputProps extends BaseInputType {
|
|
6
|
-
style?: StyleProp<ViewStyle>;
|
|
7
|
-
}
|
|
8
|
-
declare const _default: React.ForwardRefExoticComponent<AnimatedInputProps & React.RefAttributes<unknown>>;
|
|
9
|
-
export default _default;
|
|
@@ -1,52 +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, { forwardRef } from "react";
|
|
13
|
-
import { BaseInput } from "..";
|
|
14
|
-
import styled, { useTheme } from "styled-components/native";
|
|
15
|
-
import { View } from "react-native";
|
|
16
|
-
import { inputTextColor, inputStatusColors, getInputStatus } from "./inputTextColor";
|
|
17
|
-
import { useAnimatedInputFocus } from "./useAnimatedInputFocus";
|
|
18
|
-
import { AnimatedNotchedLabel } from "./AnimatedNotchedLabel";
|
|
19
|
-
const InputContainer = styled(View) `
|
|
20
|
-
position: relative;
|
|
21
|
-
box-sizing: border-box;
|
|
22
|
-
height: fit-content;
|
|
23
|
-
`;
|
|
24
|
-
const AnimatedInput = (_a) => {
|
|
25
|
-
var { style = { width: "100%" } } = _a, textInputProps = __rest(_a, ["style"]);
|
|
26
|
-
const { placeholder, onFocus: onFocusCallback, onBlur: onBlurCallback, error, value } = textInputProps, rest = __rest(textInputProps, ["placeholder", "onFocus", "onBlur", "error", "value"]);
|
|
27
|
-
const theme = useTheme();
|
|
28
|
-
const { onFocus, onBlur, focused } = useAnimatedInputFocus({
|
|
29
|
-
onFocusCallback,
|
|
30
|
-
onBlurCallback,
|
|
31
|
-
});
|
|
32
|
-
const inputStatus = getInputStatus({ focused, hasError: !!error, hasValue: !!value });
|
|
33
|
-
const displayClearCross = inputStatus === "error" || inputStatus === "focused";
|
|
34
|
-
return (React.createElement(InputContainer, { status: inputStatus, style: style },
|
|
35
|
-
placeholder && React.createElement(AnimatedNotchedLabel, { placeholder: placeholder, inputStatus: inputStatus }),
|
|
36
|
-
React.createElement(BaseInput, Object.assign({ onFocus: onFocus, onBlur: onBlur, error: error, value: value, containerStyle: {
|
|
37
|
-
height: "100%",
|
|
38
|
-
}, color: theme ? inputTextColor[inputStatus]({ theme }) : "neutral.c100", inputContainerStyle: {
|
|
39
|
-
backgroundColor: "none",
|
|
40
|
-
borderColor: theme ? inputStatusColors[inputStatus]({ theme }) : "neutral.c100",
|
|
41
|
-
borderRadius: 8,
|
|
42
|
-
height: inputStatus !== "error" ? 56 : 48,
|
|
43
|
-
}, baseInputContainerStyle: {
|
|
44
|
-
paddingTop: 15,
|
|
45
|
-
paddingBottom: 15,
|
|
46
|
-
paddingLeft: 14,
|
|
47
|
-
paddingRight: displayClearCross ? 8 : 14,
|
|
48
|
-
}, inputErrorContainerStyles: {
|
|
49
|
-
marginTop: 8,
|
|
50
|
-
}, inputErrorColor: theme ? inputStatusColors[inputStatus]({ theme }) : "neutral.c100", showErrorIcon: true }, rest))));
|
|
51
|
-
};
|
|
52
|
-
export default forwardRef(AnimatedInput);
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Theme } from "src/styles/theme";
|
|
2
|
-
export type CbThemeType = {
|
|
3
|
-
theme: Theme;
|
|
4
|
-
};
|
|
5
|
-
export declare const inputStatusColors: {
|
|
6
|
-
default: ({ theme }: CbThemeType) => string;
|
|
7
|
-
focused: ({ theme }: CbThemeType) => string;
|
|
8
|
-
filled: ({ theme }: CbThemeType) => string;
|
|
9
|
-
error: ({ theme }: CbThemeType) => string;
|
|
10
|
-
};
|
|
11
|
-
export declare const inputTextColor: {
|
|
12
|
-
default: ({ theme }: CbThemeType) => string;
|
|
13
|
-
focused: ({ theme }: CbThemeType) => string;
|
|
14
|
-
filled: ({ theme }: CbThemeType) => string;
|
|
15
|
-
error: ({ theme }: CbThemeType) => string;
|
|
16
|
-
};
|
|
17
|
-
export declare const inputBackgroundColor: {
|
|
18
|
-
default: ({ theme }: CbThemeType) => string;
|
|
19
|
-
focused: ({ theme }: CbThemeType) => string;
|
|
20
|
-
filled: ({ theme }: CbThemeType) => string;
|
|
21
|
-
error: ({ theme }: CbThemeType) => string;
|
|
22
|
-
};
|
|
23
|
-
type getInputStatusProps = {
|
|
24
|
-
focused?: boolean;
|
|
25
|
-
hasValue?: boolean;
|
|
26
|
-
hasError?: boolean;
|
|
27
|
-
};
|
|
28
|
-
export declare const getInputStatus: ({ focused, hasValue, hasError }: getInputStatusProps) => "error" | "default" | "focused" | "filled";
|
|
29
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export const inputStatusColors = {
|
|
2
|
-
default: ({ theme }) => theme.colors.opacityDefault.c50,
|
|
3
|
-
focused: ({ theme }) => theme.colors.primary.c80,
|
|
4
|
-
filled: ({ theme }) => theme.colors.neutral.c60,
|
|
5
|
-
error: ({ theme }) => theme.colors.error.c50,
|
|
6
|
-
};
|
|
7
|
-
export const inputTextColor = {
|
|
8
|
-
default: ({ theme }) => theme.colors.opacityDefault.c70,
|
|
9
|
-
focused: ({ theme }) => theme.colors.neutral.c100,
|
|
10
|
-
filled: ({ theme }) => theme.colors.neutral.c100,
|
|
11
|
-
error: ({ theme }) => theme.colors.neutral.c100,
|
|
12
|
-
};
|
|
13
|
-
export const inputBackgroundColor = {
|
|
14
|
-
default: ({ theme }) => theme.colors.background.main,
|
|
15
|
-
focused: ({ theme }) => theme.colors.background.main,
|
|
16
|
-
filled: ({ theme }) => theme.colors.background.main,
|
|
17
|
-
error: ({ theme }) => theme.colors.background.main,
|
|
18
|
-
};
|
|
19
|
-
export const getInputStatus = ({ focused, hasValue, hasError }) => {
|
|
20
|
-
if (hasError)
|
|
21
|
-
return "error";
|
|
22
|
-
if (focused)
|
|
23
|
-
return "focused";
|
|
24
|
-
if (hasValue)
|
|
25
|
-
return "filled";
|
|
26
|
-
return "default";
|
|
27
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { NativeSyntheticEvent, TextInputFocusEventData } from "react-native";
|
|
2
|
-
type useAnimatedInputFocusProps = {
|
|
3
|
-
onFocusCallback?: (e: NativeSyntheticEvent<TextInputFocusEventData>) => TextInputFocusEventData | void;
|
|
4
|
-
onBlurCallback?: (e: NativeSyntheticEvent<TextInputFocusEventData>) => TextInputFocusEventData | void;
|
|
5
|
-
};
|
|
6
|
-
export declare const useAnimatedInputFocus: ({ onFocusCallback, onBlurCallback, }: useAnimatedInputFocusProps) => {
|
|
7
|
-
onFocus: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void;
|
|
8
|
-
onBlur: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void;
|
|
9
|
-
focused: boolean;
|
|
10
|
-
};
|
|
11
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
export const useAnimatedInputFocus = ({ onFocusCallback, onBlurCallback, }) => {
|
|
3
|
-
const [focused, setFocused] = useState(false);
|
|
4
|
-
const onFocus = (e) => {
|
|
5
|
-
setFocused(true);
|
|
6
|
-
onFocusCallback && onFocusCallback(e);
|
|
7
|
-
};
|
|
8
|
-
const onBlur = (e) => {
|
|
9
|
-
setFocused(false);
|
|
10
|
-
onBlurCallback && onBlurCallback(e);
|
|
11
|
-
};
|
|
12
|
-
return { onFocus, onBlur, focused };
|
|
13
|
-
};
|