@ledgerhq/native-ui 0.22.8 → 0.22.9

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