@ledgerhq/native-ui 0.6.2 → 0.6.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.
|
@@ -71,7 +71,7 @@ export declare const InputRenderRightContainer: import("styled-components").Styl
|
|
|
71
71
|
flexDirection: string;
|
|
72
72
|
pr: string;
|
|
73
73
|
}, "pr" | "alignItems" | "flexDirection">;
|
|
74
|
-
declare function Input<T = string>(props: InputProps<T>, ref?:
|
|
74
|
+
declare function Input<T = string>(props: InputProps<T>, ref?: any): JSX.Element;
|
|
75
75
|
declare const _default: <T>(props: Omit<CommonProps, "onChange" | "value"> & {
|
|
76
76
|
/**
|
|
77
77
|
* The value of the input.
|
|
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React, { useMemo, useCallback } from "react";
|
|
12
|
+
import React, { useMemo, useCallback, useEffect, useImperativeHandle, useRef } from "react";
|
|
13
13
|
import styled, { css } from "styled-components/native";
|
|
14
14
|
import Text from "../../../Text";
|
|
15
15
|
import FlexBox from "../../../Layout/Flex";
|
|
@@ -17,7 +17,7 @@ const InputContainer = styled.View `
|
|
|
17
17
|
display: flex;
|
|
18
18
|
flex-direction: row;
|
|
19
19
|
width: 100%;
|
|
20
|
-
background: ${(p) => p.theme.colors.
|
|
20
|
+
background: ${(p) => p.theme.colors.background.main};
|
|
21
21
|
height: 48px;
|
|
22
22
|
border: ${(p) => `1px solid ${p.theme.colors.neutral.c40}`};
|
|
23
23
|
border-radius: 24px;
|
|
@@ -49,6 +49,8 @@ const InputContainer = styled.View `
|
|
|
49
49
|
`;
|
|
50
50
|
const BaseInput = styled.TextInput.attrs((p) => ({
|
|
51
51
|
selectionColor: p.theme.colors.primary.c80,
|
|
52
|
+
color: p.theme.colors.neutral.c100,
|
|
53
|
+
placeholderTextColor: p.theme.colors.neutral.c80,
|
|
52
54
|
})) `
|
|
53
55
|
height: 100%;
|
|
54
56
|
width: 100%;
|
|
@@ -77,17 +79,29 @@ export const InputRenderRightContainer = styled(FlexBox).attrs(() => ({
|
|
|
77
79
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
80
|
const IDENTITY = (_) => _;
|
|
79
81
|
function Input(props, ref) {
|
|
80
|
-
const { value, onChange, onChangeText, onChangeEvent, disabled, error, renderLeft, renderRight, serialize = IDENTITY, deserialize = IDENTITY, containerStyle } = props, textInputProps = __rest(props, ["value", "onChange", "onChangeText", "onChangeEvent", "disabled", "error", "renderLeft", "renderRight", "serialize", "deserialize", "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"]);
|
|
83
|
+
const inputRef = useRef();
|
|
84
|
+
useImperativeHandle(ref, () => inputRef.current, [inputRef]);
|
|
81
85
|
const inputValue = useMemo(() => serialize(value), [serialize, value]);
|
|
82
86
|
const handleChange = useCallback((value) => {
|
|
83
87
|
onChange && onChange(deserialize(value));
|
|
84
88
|
onChangeText && onChangeText(value);
|
|
85
89
|
}, [onChange, onChangeText, deserialize]);
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (autoFocus && inputRef && inputRef.current && inputRef.current.focus)
|
|
92
|
+
inputRef.current.focus();
|
|
93
|
+
}, [inputRef, autoFocus]);
|
|
86
94
|
const [focus, setFocus] = React.useState(false);
|
|
87
95
|
return (React.createElement(FlexBox, { width: "100%", style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
|
|
88
96
|
React.createElement(InputContainer, { disabled: disabled, focus: focus, error: error },
|
|
89
97
|
typeof renderLeft === "function" ? renderLeft(props) : renderLeft,
|
|
90
|
-
React.createElement(BaseInput, Object.assign({ ref:
|
|
98
|
+
React.createElement(BaseInput, Object.assign({ ref: inputRef }, textInputProps, { value: inputValue, onChange: onChangeEvent, onChangeText: handleChange, editable: !disabled, disabled: disabled, error: error, onFocus: (e) => {
|
|
99
|
+
setFocus(true);
|
|
100
|
+
typeof onFocus === "function" && onFocus(e);
|
|
101
|
+
}, onBlur: (e) => {
|
|
102
|
+
setFocus(false);
|
|
103
|
+
typeof onBlur === "function" && onBlur(e);
|
|
104
|
+
} })),
|
|
91
105
|
typeof renderRight === "function" ? renderRight(props) : renderRight),
|
|
92
106
|
!!error && !disabled && React.createElement(InputErrorContainer, null, error)));
|
|
93
107
|
}
|
|
@@ -15,6 +15,9 @@ import { IconBox } from "../../../Icon";
|
|
|
15
15
|
import Text from "../../../Text";
|
|
16
16
|
export default function NumberedList(_a) {
|
|
17
17
|
var { items } = _a, props = __rest(_a, ["items"]);
|
|
18
|
-
const numberedItems = useMemo(() => items.map((item, index) =>
|
|
18
|
+
const numberedItems = useMemo(() => items.map((item, index) => {
|
|
19
|
+
var _a;
|
|
20
|
+
return (Object.assign(Object.assign({}, item), { bullet: (React.createElement(IconBox, { Icon: React.createElement(Text, { variant: "body", fontWeight: "medium", color: "neutral.c100" }, (_a = item.number) !== null && _a !== void 0 ? _a : index + 1), boxSize: 36 })) }));
|
|
21
|
+
}), [items]);
|
|
19
22
|
return React.createElement(List, Object.assign({ items: numberedItems }, props));
|
|
20
23
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { FlexBoxProps } from "../../Layout/Flex";
|
|
3
3
|
import { TransitionProps } from "../../transitions";
|
|
4
4
|
interface InnerProps {
|
|
5
5
|
/**
|
|
@@ -42,7 +42,7 @@ export interface Props<ExtraProps> {
|
|
|
42
42
|
* Additional props to pass to the progressbar component.
|
|
43
43
|
* This component is a Flex element.
|
|
44
44
|
*/
|
|
45
|
-
progressBarProps?:
|
|
45
|
+
progressBarProps?: FlexBoxProps;
|
|
46
46
|
/**
|
|
47
47
|
* **Use this prop in combination with `transitionDuration`.**
|
|
48
48
|
*
|