@ledgerhq/native-ui 0.22.8-nightly.0 → 0.22.8

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.
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import React from "react";
2
2
  import styled from "styled-components/native";
3
3
  import { Flex } from "../../../Layout";
4
4
  import { Text } from "react-native";
@@ -18,26 +18,27 @@ const labelFinalPositions = {
18
18
  const LabelContainer = styled(Animated.View) `
19
19
  position: absolute;
20
20
  padding: ${`0 ${labelPadding}px`};
21
- height: 15px;
21
+ display: inline-block;
22
+ height: 15;
22
23
  z-index: ${(p) => (p.notched ? 3 : 0)};
23
24
  `;
24
25
  const AnimatedText = Animated.createAnimatedComponent(Text);
25
26
  const LabelText = styled(AnimatedText) `
26
- height: 15px;
27
- line-height: 15px;
27
+ display: inline-block;
28
+ height: 15;
29
+ line-height: 15;
28
30
  vertical-align: top;
29
31
  color: ${(p) => p.status === "default" ? inputTextColor[p.status] : inputStatusColors[p.status]};
30
32
  `;
31
33
  const LineCutout = styled(Flex) `
32
34
  position: absolute;
33
- height: 1px;
34
- top: 7px;
35
- left: 0px;
36
- width: ${(p) => p.labelWidth}px;
35
+ height: 1;
36
+ top: 7;
37
+ left: 0;
38
+ width: 120%;
37
39
  background: ${(p) => inputBackgroundColor[p.status]};
38
40
  `;
39
41
  export const AnimatedNotchedLabel = ({ placeholder, inputStatus }) => {
40
- const [labelWidth, setLabelWidth] = useState(0);
41
42
  const notched = inputStatus !== "default";
42
43
  const labelTop = useSharedValue(notched ? labelFinalPositions.top : labelInitialPositions.top);
43
44
  const labelLeft = useSharedValue(notched ? labelFinalPositions.left : labelInitialPositions.left);
@@ -70,7 +71,7 @@ export const AnimatedNotchedLabel = ({ placeholder, inputStatus }) => {
70
71
  easing: Easing.inOut(Easing.quad),
71
72
  }));
72
73
  }, [notched]);
73
- return (React.createElement(LabelContainer, { onLayout: (event) => setLabelWidth(event.nativeEvent.layout.width), style: Object.assign(Object.assign({}, labelStyle), { elevation: notched ? 3 : 0 }), notched: notched },
74
- notched && React.createElement(LineCutout, { status: inputStatus, labelWidth: labelWidth }),
74
+ return (React.createElement(LabelContainer, { style: Object.assign(Object.assign({}, labelStyle), { elevation: notched ? 3 : 0 }), notched: notched },
75
+ notched && React.createElement(LineCutout, { status: inputStatus }),
75
76
  React.createElement(LabelText, { style: Object.assign({}, labelFontSize), status: inputStatus }, placeholder)));
76
77
  };
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
2
  import { type InputProps as BaseInputType } from "../BaseInput/index";
3
- import { StyleProp, ViewStyle, TextInput } from "react-native";
3
+ import { StyleProp, ViewStyle } from "react-native";
4
4
  export type InputStatus = "default" | "focused" | "filled" | "error";
5
5
  export interface AnimatedInputProps extends BaseInputType {
6
6
  style?: StyleProp<ViewStyle>;
7
7
  }
8
- declare const _default: React.ForwardRefExoticComponent<AnimatedInputProps & React.RefAttributes<TextInput>>;
9
- export default _default;
8
+ declare const AnimatedInput: ({ style, ...textInputProps }: AnimatedInputProps) => React.JSX.Element;
9
+ export default AnimatedInput;
@@ -19,8 +19,9 @@ import { AnimatedNotchedLabel } from "./AnimatedNotchedLabel";
19
19
  const InputContainer = styled(View) `
20
20
  position: relative;
21
21
  box-sizing: border-box;
22
+ height: fit-content;
22
23
  `;
23
- const AnimatedInput = (_a, ref) => {
24
+ const AnimatedInput = (_a) => {
24
25
  var { style = { width: "100%" } } = _a, textInputProps = __rest(_a, ["style"]);
25
26
  const { placeholder, onFocus: onFocusCallback, onBlur: onBlurCallback, error, value } = textInputProps, rest = __rest(textInputProps, ["placeholder", "onFocus", "onBlur", "error", "value"]);
26
27
  const theme = useTheme();
@@ -32,15 +33,20 @@ const AnimatedInput = (_a, ref) => {
32
33
  const displayClearCross = inputStatus === "error" || inputStatus === "focused";
33
34
  return (React.createElement(InputContainer, { status: inputStatus, style: style },
34
35
  placeholder && React.createElement(AnimatedNotchedLabel, { placeholder: placeholder, inputStatus: inputStatus }),
35
- React.createElement(BaseInput, Object.assign({ ref: ref, onFocus: onFocus, onBlur: onBlur, error: error, value: value, color: theme ? inputTextColor[inputStatus]({ theme }) : "neutral.c100", inputContainerStyle: {
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: {
36
39
  backgroundColor: "none",
37
40
  borderColor: theme ? inputStatusColors[inputStatus]({ theme }) : "neutral.c100",
38
41
  borderRadius: 8,
39
42
  height: inputStatus !== "error" ? 56 : 48,
40
43
  }, baseInputContainerStyle: {
44
+ paddingTop: 15,
45
+ paddingBottom: 15,
46
+ paddingLeft: 14,
41
47
  paddingRight: displayClearCross ? 8 : 14,
42
48
  }, inputErrorContainerStyles: {
43
49
  marginTop: 8,
44
50
  }, inputErrorColor: theme ? inputStatusColors[inputStatus]({ theme }) : "neutral.c100", showErrorIcon: true }, rest))));
45
51
  };
46
- export default React.forwardRef(AnimatedInput);
52
+ export default AnimatedInput;
@@ -64,7 +64,6 @@ export type InputProps<T = string> = Omit<CommonProps, "value" | "onChange"> & {
64
64
  inputErrorContainerStyles?: StyleProp<ViewStyle>;
65
65
  inputErrorColor?: string;
66
66
  showErrorIcon?: boolean;
67
- hasBorder?: boolean;
68
67
  /**
69
68
  * Optional text color parameter.
70
69
  */
@@ -80,8 +79,8 @@ export declare const InputRenderLeftContainer: import("styled-components").Style
80
79
  } & {
81
80
  alignItems: string;
82
81
  flexDirection: string;
83
- paddingRight: string;
84
- }, "alignItems" | "flexDirection" | "paddingRight">;
82
+ pl: number;
83
+ }, "alignItems" | "flexDirection" | "pl">;
85
84
  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>> & {
86
85
  columnGap?: string | number | undefined;
87
86
  rowGap?: string | number | undefined;
@@ -92,8 +91,8 @@ export declare const InputRenderRightContainer: import("styled-components").Styl
92
91
  } & {
93
92
  alignItems: string;
94
93
  flexDirection: string;
95
- paddingLeft: string;
96
- }, "alignItems" | "flexDirection" | "paddingLeft">;
94
+ pr: number;
95
+ }, "alignItems" | "flexDirection" | "pr">;
97
96
  declare function Input<T = string>(props: InputProps<T>, ref?: any): JSX.Element;
98
97
  declare const _default: <T>(props: Omit<CommonProps, "onChange" | "value"> & {
99
98
  /**
@@ -154,7 +153,6 @@ declare const _default: <T>(props: Omit<CommonProps, "onChange" | "value"> & {
154
153
  inputErrorContainerStyles?: StyleProp<ViewStyle>;
155
154
  inputErrorColor?: string | undefined;
156
155
  showErrorIcon?: boolean | undefined;
157
- hasBorder?: boolean | undefined;
158
156
  /**
159
157
  * Optional text color parameter.
160
158
  */
@@ -20,11 +20,9 @@ const InputContainer = styled.View `
20
20
  width: 100%;
21
21
  background: ${(p) => p.theme.colors.background.main};
22
22
  height: 48px;
23
- border: ${(p) => (p.hasBorder ? `1px solid ${p.theme.colors.opacityDefault.c20}` : "none")};
24
- border-radius: 8px;
23
+ border: ${(p) => `1px solid ${p.theme.colors.neutral.c40}`};
24
+ border-radius: 24px;
25
25
  color: ${(p) => p.theme.colors.neutral.c100};
26
- align-items: center;
27
- padding: 0px 16px;
28
26
 
29
27
  ${(p) => p.disabled &&
30
28
  css `
@@ -34,7 +32,6 @@ const InputContainer = styled.View `
34
32
 
35
33
  ${(p) => p.focus &&
36
34
  !p.error &&
37
- p.hasBorder &&
38
35
  css `
39
36
  border: 1px solid ${p.theme.colors.primary.c80};
40
37
  `};
@@ -42,59 +39,50 @@ const InputContainer = styled.View `
42
39
  ${(p) => p.error &&
43
40
  !p.disabled &&
44
41
  css `
45
- border: 1px solid ${p.theme.colors.error.c60};
42
+ border: 1px solid ${p.theme.colors.error.c50};
46
43
  `};
47
44
 
48
45
  ${(p) => p.disabled &&
49
- p.hasBorder &&
50
46
  css `
51
47
  color: ${p.theme.colors.neutral.c60};
52
48
  background: ${(p) => p.theme.colors.neutral.c30};
53
49
  `};
54
-
55
- ${(p) => p.disabled &&
56
- !p.hasBorder &&
57
- css `
58
- color: ${p.theme.colors.opacityDefault.c10};
59
- background: ${(p) => p.theme.colors.neutral.c30};
60
- `};
61
50
  `;
62
51
  const BaseInput = styled.TextInput.attrs((p) => ({
63
52
  selectionColor: p.theme.colors.primary.c80,
53
+ color: p.theme.colors.neutral.c100,
64
54
  placeholderTextColor: p.theme.colors.neutral.c80,
65
55
  })) `
66
56
  height: 100%;
67
57
  width: 100%;
68
58
  border: 0;
69
59
  flex-shrink: 1;
70
- display: flex;
71
- min-height: fit-content;
72
- color: ${(p) => p.theme.colors.neutral.c100};
60
+ padding: 14px 20px;
73
61
  `;
74
62
  const InputErrorText = styled(Text) `
75
- color: ${(p) => p.theme.colors.error.c60};
63
+ color: ${(p) => p.theme.colors.error.c50};
76
64
  `;
77
65
  export const InputRenderLeftContainer = styled(FlexBox).attrs(() => ({
78
66
  alignItems: "center",
79
67
  flexDirection: "row",
80
- paddingRight: "8px",
68
+ pl: 16,
81
69
  })) ``;
82
70
  export const InputRenderRightContainer = styled(FlexBox).attrs(() => ({
83
71
  alignItems: "center",
84
72
  flexDirection: "row",
85
- paddingLeft: "8px",
73
+ pr: 16,
86
74
  })) ``;
87
75
  // Yes, this is dirty. If you can figure out a better way please change the code :).
88
76
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
77
  const IDENTITY = (_) => _;
90
78
  function Input(props, ref) {
91
- const { value, onChange, onChangeText, onChangeEvent, disabled, error, renderLeft, renderRight, serialize = IDENTITY, deserialize = IDENTITY, containerStyle, hasBorder = true, inputContainerStyle, baseInputContainerStyle, inputErrorContainerStyles, autoFocus, onFocus, onBlur, color, inputErrorColor = "error.c50", showErrorIcon = false } = props, textInputProps = __rest(props, ["value", "onChange", "onChangeText", "onChangeEvent", "disabled", "error", "renderLeft", "renderRight", "serialize", "deserialize", "containerStyle", "hasBorder", "inputContainerStyle", "baseInputContainerStyle", "inputErrorContainerStyles", "autoFocus", "onFocus", "onBlur", "color", "inputErrorColor", "showErrorIcon"]);
79
+ const { value, onChange, onChangeText, onChangeEvent, disabled, error, renderLeft, renderRight, serialize = IDENTITY, deserialize = IDENTITY, containerStyle, inputContainerStyle, baseInputContainerStyle, inputErrorContainerStyles, autoFocus, onFocus, onBlur, color, inputErrorColor = "error.c50", showErrorIcon = false } = props, textInputProps = __rest(props, ["value", "onChange", "onChangeText", "onChangeEvent", "disabled", "error", "renderLeft", "renderRight", "serialize", "deserialize", "containerStyle", "inputContainerStyle", "baseInputContainerStyle", "inputErrorContainerStyles", "autoFocus", "onFocus", "onBlur", "color", "inputErrorColor", "showErrorIcon"]);
92
80
  const inputRef = useRef();
93
81
  useImperativeHandle(ref, () => inputRef.current, [inputRef]);
94
82
  const inputValue = useMemo(() => serialize(value), [serialize, value]);
95
83
  const handleChange = useCallback((value) => {
96
- onChange === null || onChange === void 0 ? void 0 : onChange(deserialize(value));
97
- onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(value);
84
+ onChange && onChange(deserialize(value));
85
+ onChangeText && onChangeText(value);
98
86
  }, [onChange, onChangeText, deserialize]);
99
87
  useEffect(() => {
100
88
  if (autoFocus && inputRef && inputRef.current && inputRef.current.focus)
@@ -102,18 +90,18 @@ function Input(props, ref) {
102
90
  }, [inputRef, autoFocus]);
103
91
  const [focus, setFocus] = React.useState(false);
104
92
  return (React.createElement(FlexBox, { width: "100%", style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
105
- React.createElement(InputContainer, { disabled: disabled, focus: focus, hasBorder: hasBorder, error: error, style: inputContainerStyle },
93
+ React.createElement(InputContainer, { disabled: disabled, focus: focus, error: error, style: inputContainerStyle },
106
94
  typeof renderLeft === "function" ? renderLeft(props, inputRef) : renderLeft,
107
95
  React.createElement(BaseInput, Object.assign({ ref: inputRef }, textInputProps, { value: inputValue, onChange: onChangeEvent, onChangeText: handleChange, editable: !disabled, disabled: disabled, error: error, onFocus: (e) => {
108
96
  setFocus(true);
109
- onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
97
+ typeof onFocus === "function" && onFocus(e);
110
98
  }, onBlur: (e) => {
111
99
  setFocus(false);
112
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
100
+ typeof onBlur === "function" && onBlur(e);
113
101
  }, style: Object.assign(Object.assign({}, (color ? { color: color } : {})), baseInputContainerStyle) })),
114
102
  typeof renderRight === "function" ? renderRight(props, inputRef) : renderRight),
115
- !!error && !disabled && (React.createElement(FlexBox, { flexDirection: "row", alignItems: "center", style: inputErrorContainerStyles },
103
+ !!error && !disabled && (React.createElement(FlexBox, { flexDirection: "row", alignItems: "center", style: inputErrorContainerStyles || { paddingLeft: "12px" } },
116
104
  showErrorIcon && React.createElement(DeleteCircleFill, { color: inputErrorColor, size: "S" }),
117
- React.createElement(InputErrorText, { color: inputErrorColor, variant: "small", mt: 3 }, error)))));
105
+ React.createElement(InputErrorText, { color: inputErrorColor, variant: "small", ml: 2 }, error)))));
118
106
  }
119
107
  export default React.forwardRef(Input);
@@ -19,7 +19,6 @@ declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInpu
19
19
  inputErrorContainerStyles?: import("react-native").StyleProp<import("react-native").ViewStyle>;
20
20
  inputErrorColor?: string | undefined;
21
21
  showErrorIcon?: boolean | undefined;
22
- hasBorder?: boolean | undefined;
23
22
  color?: string | undefined;
24
23
  } & {
25
24
  legend: string;
@@ -19,7 +19,6 @@ declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInpu
19
19
  inputErrorContainerStyles?: import("react-native").StyleProp<import("react-native").ViewStyle>;
20
20
  inputErrorColor?: string | undefined;
21
21
  showErrorIcon?: boolean | undefined;
22
- hasBorder?: boolean | undefined;
23
22
  color?: string | undefined;
24
23
  } & {
25
24
  onPercentClick: (percent: number) => void;
@@ -20,7 +20,6 @@ declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInpu
20
20
  inputErrorContainerStyles?: import("react-native").StyleProp<import("react-native").ViewStyle>;
21
21
  inputErrorColor?: string | undefined;
22
22
  showErrorIcon?: boolean | undefined;
23
- hasBorder?: boolean | undefined;
24
23
  color?: string | undefined;
25
24
  } & {
26
25
  onQrCodeClick?: ((event: GestureResponderEvent) => void) | undefined;
@@ -19,7 +19,6 @@ declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInpu
19
19
  inputErrorContainerStyles?: import("react-native").StyleProp<import("react-native").ViewStyle>;
20
20
  inputErrorColor?: string | undefined;
21
21
  showErrorIcon?: boolean | undefined;
22
- hasBorder?: boolean | undefined;
23
22
  color?: string | undefined;
24
23
  } & React.RefAttributes<TextInput>>;
25
24
  export default _default;
@@ -10,29 +10,21 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import React, { useCallback } from "react";
13
- import styled, { useTheme } from "styled-components/native";
13
+ import styled from "styled-components/native";
14
14
  import Input, { InputRenderLeftContainer } from "../BaseInput";
15
- import Search from "@ledgerhq/icons-ui/native/Search";
16
- import DeleteCircleFill from "@ledgerhq/icons-ui/native/DeleteCircleFill";
15
+ import SearchMedium from "@ledgerhq/icons-ui/nativeLegacy/SearchMedium";
17
16
  import Button from "../../../cta/Button";
18
- const Icon = styled(Search).attrs((p) => ({
17
+ const Icon = styled(SearchMedium).attrs((p) => ({
19
18
  color: p.theme.colors.neutral.c70,
20
19
  })) ``;
21
- const Delete = styled(DeleteCircleFill).attrs((p) => ({
22
- color: p.theme.colors.opacityDefault.c50,
23
- })) ``;
24
20
  function SearchInput(_a, ref) {
25
21
  var { onChange, value } = _a, props = __rest(_a, ["onChange", "value"]);
26
- const theme = useTheme();
27
22
  const onClear = useCallback(() => {
28
- onChange === null || onChange === void 0 ? void 0 : onChange("");
23
+ if (onChange) {
24
+ onChange("");
25
+ }
29
26
  }, [onChange]);
30
- return (React.createElement(Input, Object.assign({ ref: ref, onChange: onChange, value: value, hasBorder: false, inputContainerStyle: {
31
- backgroundColor: theme.colors.opacityDefault.c05,
32
- height: 40,
33
- paddingHorizontal: 12,
34
- paddingVertical: 0,
35
- }, baseInputContainerStyle: { height: 40 } }, props, { renderLeft: React.createElement(InputRenderLeftContainer, null,
36
- React.createElement(Icon, { size: "S" })), renderRight: value ? (React.createElement(Button, { Icon: React.createElement(Delete, { size: "S" }), isNewIcon: true, onPress: onClear, style: { width: "auto", marginLeft: 8 } })) : null })));
27
+ return (React.createElement(Input, Object.assign({ ref: ref, onChange: onChange, value: value }, props, { renderLeft: React.createElement(InputRenderLeftContainer, null,
28
+ React.createElement(Icon, null)), renderRight: value ? React.createElement(Button, { iconName: "Close", onPress: onClear }) : null })));
37
29
  }
38
30
  export default React.forwardRef(SearchInput);
@@ -0,0 +1,119 @@
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;
@@ -0,0 +1,107 @@
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);
@@ -0,0 +1,14 @@
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;
@@ -0,0 +1,30 @@
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);
@@ -3,4 +3,5 @@ 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";
6
7
  export { default as AnimatedInput } from "./AnimatedInput";
@@ -3,4 +3,5 @@ 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";
6
7
  export { default as AnimatedInput } from "./AnimatedInput";
@@ -74,7 +74,7 @@ export function ModalHeaderCloseButton({ onClose, }) {
74
74
  const { colors } = useTheme();
75
75
  return (React.createElement(CloseContainer, null,
76
76
  React.createElement(ClosePressableExtendedBounds, { onPress: onClose },
77
- React.createElement(Close, { color: colors.neutral.c100, size: "XS" }))));
77
+ React.createElement(Close, { color: colors.neutral.c100, size: "S" }))));
78
78
  }
79
79
  export default function BaseModal(_a) {
80
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"]);
@@ -25,10 +25,10 @@ const modalStyleOverrides = StyleSheet.create({
25
25
  },
26
26
  container: {
27
27
  minHeight: 0,
28
- paddingLeft: 16,
29
- paddingRight: 16,
30
- paddingTop: 16,
31
- paddingBottom: 16,
28
+ paddingLeft: 24,
29
+ paddingRight: 24,
30
+ paddingTop: 24,
31
+ paddingBottom: 24,
32
32
  maxHeight: "100%",
33
33
  borderTopLeftRadius: 24,
34
34
  borderTopRightRadius: 24,
@@ -4,6 +4,7 @@ import { TouchableOpacity, TouchableOpacityProps } from "react-native";
4
4
  import { BaseStyledProps } from "../../styled";
5
5
  import { IconType } from "../../Icon/type";
6
6
  export type ButtonProps = TouchableOpacityProps & BaseStyledProps & {
7
+ Icon?: IconType;
7
8
  onPressWhenDisabled?: TouchableOpacityProps["onPress"];
8
9
  iconName?: string;
9
10
  type?: "main" | "shade" | "error" | "color" | "default";
@@ -16,8 +17,6 @@ export type ButtonProps = TouchableOpacityProps & BaseStyledProps & {
16
17
  pending?: boolean;
17
18
  displayContentWhenPending?: boolean;
18
19
  buttonTestId?: string;
19
- isNewIcon?: boolean;
20
- Icon?: IconType | JSX.Element;
21
20
  };
22
21
  export declare const Base: import("styled-components").StyledComponent<typeof TouchableOpacity, import("styled-components").DefaultTheme, {
23
22
  iconButton?: boolean | undefined;
@@ -63,16 +63,11 @@ const SpinnerContainer = styled.View `
63
63
  justify-content: center;
64
64
  `;
65
65
  const ButtonContainer = (props) => {
66
- const { Icon, isNewIcon, iconPosition = "right", children, hide = false, size = "medium", iconName, pending, displayContentWhenPending, buttonTestId, } = props;
66
+ const { Icon, iconPosition = "right", children, hide = false, size = "medium", iconName, pending, displayContentWhenPending, buttonTestId, } = props;
67
67
  const theme = useTheme();
68
68
  const { text } = getButtonColorStyle(theme.colors, props);
69
- const IconNode = useMemo(() => {
70
- if (isNewIcon) {
71
- return Icon;
72
- }
73
- return ((iconName && React.createElement(IconComponent, { name: iconName, size: ctaIconSize[size], color: text.color })) ||
74
- (typeof Icon === "function" && React.createElement(Icon, { size: ctaIconSize[size], color: text.color })));
75
- }, [iconName, size, Icon, text.color, isNewIcon]);
69
+ const IconNode = useMemo(() => (iconName && React.createElement(IconComponent, { name: iconName, size: ctaIconSize[size], color: text.color })) ||
70
+ (Icon && React.createElement(Icon, { size: ctaIconSize[size], color: text.color })), [iconName, size, Icon, text.color]);
76
71
  const textColor = useMemo(() => (pending ? theme.colors.neutral.c50 : text.color), [pending, theme.colors.neutral.c50, text.color]);
77
72
  return (React.createElement(Container, { hide: hide },
78
73
  iconPosition === "right" && children ? (React.createElement(Text, { testID: buttonTestId, variant: ctaTextType[size], fontWeight: "semiBold", color: textColor }, children)) : null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/native-ui",
3
- "version": "0.22.8-nightly.0",
3
+ "version": "0.22.8",
4
4
  "description": "Ledger Live - Mobile UI",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,8 +42,8 @@
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": "^1.0.2",
46
- "@ledgerhq/icons-ui": "^0.6.3-nightly.1",
45
+ "@ledgerhq/crypto-icons-ui": "^1.1.0",
46
+ "@ledgerhq/icons-ui": "^0.6.3",
47
47
  "@ledgerhq/ui-shared": "^0.2.1"
48
48
  },
49
49
  "peerDependencies": {
@@ -81,9 +81,7 @@
81
81
  "@storybook/addon-ondevice-controls": "6.5.7",
82
82
  "@storybook/addon-ondevice-notes": "6.5.7",
83
83
  "@storybook/addon-react-native-web": "^0.0.21",
84
- "@storybook/blocks": "^7.5.3",
85
84
  "@storybook/docs-tools": "^7.5.3",
86
- "@storybook/manager-api": "7.5.3",
87
85
  "@storybook/react": "^7.5.3",
88
86
  "@storybook/react-native": "6.5.7",
89
87
  "@storybook/react-webpack5": "^7.5.3",
@@ -139,7 +137,6 @@
139
137
  "regenerator-runtime": "^0.14.0",
140
138
  "rimraf": "^4.4.1",
141
139
  "storybook": "^7.5.3",
142
- "storybook-dark-mode": "^3.0.3",
143
140
  "styled-components": "^5.3.3",
144
141
  "stylelint": "^14.9.1",
145
142
  "stylelint-config-recommended": "^13.0.0",