@ledgerhq/native-ui 0.7.8 → 0.7.11

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,12 +1,30 @@
1
- import React from "react";
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";
2
13
  import styled from "styled-components/native";
3
14
  import Input, { InputRenderLeftContainer } from "../BaseInput";
4
15
  import SearchMedium from "@ledgerhq/icons-ui/native/SearchMedium";
16
+ import Button from "../../../cta/Button";
5
17
  const Icon = styled(SearchMedium).attrs((p) => ({
6
18
  color: p.theme.colors.neutral.c70,
7
19
  })) ``;
8
- function SearchInput(props, ref) {
9
- return (React.createElement(Input, Object.assign({ ref: ref }, props, { renderLeft: React.createElement(InputRenderLeftContainer, null,
10
- React.createElement(Icon, null)) })));
20
+ function SearchInput(_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, null)), renderRight: value ? React.createElement(Button, { iconName: "Close", onPress: onClear }) : null })));
11
29
  }
12
30
  export default React.forwardRef(SearchInput);
@@ -1,11 +1,20 @@
1
- import React from "react";
2
- import { Switch as NativeSwitch } from "react-native";
1
+ import React, { useCallback } from "react";
2
+ import { Pressable as BasePressable, Switch as NativeSwitch } from "react-native";
3
3
  import { useTheme } from "styled-components/native";
4
4
  import Text from "../../Text";
5
- import Flex from "../../Layout/Flex";
5
+ import proxyStyled from "../../../components/styled";
6
+ const Pressable = proxyStyled(BasePressable).attrs({
7
+ flexDirection: "row",
8
+ alignItems: "center",
9
+ }) ``;
6
10
  const Switch = ({ checked, onChange, disabled, label }) => {
7
11
  const { colors, space } = useTheme();
8
- return (React.createElement(Flex, { flexDirection: "row", alignItems: "center" },
12
+ const handlePress = useCallback(() => {
13
+ if (disabled)
14
+ return;
15
+ onChange && onChange(!checked);
16
+ }, [checked, disabled, onChange]);
17
+ return (React.createElement(Pressable, { onPress: handlePress },
9
18
  React.createElement(NativeSwitch, { trackColor: {
10
19
  false: colors.neutral.c50,
11
20
  true: colors.primary.c80,
@@ -18,6 +18,7 @@ import CloseMedium from "@ledgerhq/icons-ui/native/CloseMedium";
18
18
  import Text from "../../../Text";
19
19
  import { BoxedIcon } from "../../../Icon";
20
20
  import { Flex } from "../../index";
21
+ import { space } from "styled-system";
21
22
  const { width, height } = sizes;
22
23
  const Container = styled.View `
23
24
  background-color: ${(p) => p.theme.colors.background.main};
@@ -34,6 +35,12 @@ const CloseContainer = styled.View `
34
35
  align-items: flex-end;
35
36
  margin-bottom: ${(p) => p.theme.space[7]}px;
36
37
  `;
38
+ const ClosePressableExtendedBounds = styled.TouchableOpacity.attrs({
39
+ p: 5,
40
+ m: -5,
41
+ }) `
42
+ ${space};
43
+ `;
37
44
  const StyledTitle = styled(Text).attrs({ variant: "h2" }) `
38
45
  text-transform: uppercase;
39
46
  `;
@@ -70,7 +77,8 @@ export default function BaseModal(_a) {
70
77
  return (React.createElement(ReactNativeModal, Object.assign({}, rest, backDropProps, { isVisible: isOpen, deviceWidth: width, deviceHeight: height, useNativeDriver: true, useNativeDriverForBackdrop: true, hideModalContentWhileAnimating: true, onModalHide: onClose, style: [defaultModalStyle, modalStyle] }),
71
78
  React.createElement(Container, { style: containerStyle },
72
79
  !noCloseButton && (React.createElement(CloseContainer, null,
73
- React.createElement(Link, { Icon: CloseMedium, onPress: onClose }))),
80
+ React.createElement(ClosePressableExtendedBounds, { onPress: onClose },
81
+ React.createElement(Link, { Icon: CloseMedium, onPress: onClose })))),
74
82
  React.createElement(ModalHeader, { Icon: Icon, iconColor: iconColor, title: title, description: description, subtitle: subtitle }),
75
83
  React.createElement(ContentContainer, null, children))));
76
84
  }
@@ -15,6 +15,8 @@ export declare type ButtonProps = TouchableOpacityProps & BaseStyledProps & {
15
15
  disabled?: boolean;
16
16
  pressed?: boolean;
17
17
  children?: React.ReactNode;
18
+ pending?: boolean;
19
+ displayContentWhenPending?: boolean;
18
20
  };
19
21
  export declare const Base: import("styled-components").StyledComponent<typeof TouchableOpacity, import("styled-components").DefaultTheme, {
20
22
  iconButton?: boolean | undefined;
@@ -45,7 +45,7 @@ const Container = styled.View `
45
45
  opacity: ${(p) => (p.hide ? 0 : 1)};
46
46
  `;
47
47
  const SpinnerContainer = styled.View `
48
- position: absolute;
48
+ position: ${(p) => (p.displayContentWhenPending ? "relative" : "absolute")};
49
49
  top: 0;
50
50
  left: 0;
51
51
  right: 0;
@@ -55,20 +55,26 @@ const SpinnerContainer = styled.View `
55
55
  justify-content: center;
56
56
  `;
57
57
  const ButtonContainer = (props) => {
58
- const { Icon, iconPosition = "right", children, hide = false, size = "medium", iconName } = props;
58
+ const { Icon, iconPosition = "right", children, hide = false, size = "medium", iconName, pending, displayContentWhenPending, } = props;
59
59
  const theme = useTheme();
60
60
  const { text } = getButtonColorStyle(theme.colors, props);
61
61
  const IconNode = useMemo(() => (iconName && React.createElement(IconComponent, { name: iconName, size: ctaIconSize[size], color: text.color })) ||
62
62
  (Icon && React.createElement(Icon, { size: ctaIconSize[size], color: text.color })), [iconName, size, Icon, text.color]);
63
+ const textColor = useMemo(() => (pending ? theme.colors.neutral.c50 : text.color), [pending, theme.colors.neutral.c50, text.color]);
63
64
  return (React.createElement(Container, { hide: hide },
64
- iconPosition === "right" && children ? (React.createElement(Text, { variant: ctaTextType[size], fontWeight: "semiBold", color: text.color }, children)) : null,
65
- IconNode && (React.createElement(IconContainer, { iconButton: !children, iconPosition: iconPosition }, IconNode)),
66
- iconPosition === "left" && children ? (React.createElement(Text, { variant: ctaTextType[size], fontWeight: "semiBold", color: text.color }, children)) : null));
65
+ iconPosition === "right" && children ? (React.createElement(Text, { variant: ctaTextType[size], fontWeight: "semiBold", color: textColor }, children)) : null,
66
+ pending && displayContentWhenPending ? (React.createElement(IconContainer, { iconPosition: iconPosition },
67
+ React.createElement(SpinnerContainer, { displayContentWhenPending: true },
68
+ React.createElement(ActivityIndicator, { color: theme.colors.neutral.c50, animating: true })))) : IconNode ? (React.createElement(IconContainer, { iconButton: !children, iconPosition: iconPosition }, IconNode)) : null,
69
+ iconPosition === "left" && children ? (React.createElement(Text, { variant: ctaTextType[size], fontWeight: "semiBold", color: textColor }, children)) : null));
67
70
  };
68
71
  const Button = (props) => {
69
- const { Icon, children, type = "default", iconName } = props;
70
- return (React.createElement(Base, Object.assign({}, props, { type: type, iconButton: (!!Icon || !!iconName) && !children, activeOpacity: 0.5 }),
71
- React.createElement(ButtonContainer, Object.assign({}, props, { type: type }))));
72
+ const { Icon, children, type = "default", iconName, disabled = false, pending = false, displayContentWhenPending = false, } = props;
73
+ const theme = useTheme();
74
+ return (React.createElement(Base, Object.assign({}, props, { type: type, iconButton: (!!Icon || !!iconName) && !children, activeOpacity: 0.5, disabled: disabled || pending }),
75
+ React.createElement(ButtonContainer, Object.assign({}, props, { type: type, hide: pending && !displayContentWhenPending })),
76
+ pending && !displayContentWhenPending ? (React.createElement(SpinnerContainer, { displayContentWhenPending: displayContentWhenPending },
77
+ React.createElement(ActivityIndicator, { color: theme.colors.neutral.c50, animating: true }))) : null));
72
78
  };
73
79
  export const PromisableButton = (props) => {
74
80
  const { Icon, children, onPress, type = "main", disabled = false, iconName } = props;
@@ -5,6 +5,7 @@ import { TouchableOpacity } from "react-native";
5
5
  import Text from "../../Text";
6
6
  import CloseMedium from "@ledgerhq/icons-ui/native/CloseMedium";
7
7
  import { Flex } from "../../Layout";
8
+ import { space } from "styled-system";
8
9
  const NotificationContainer = styled.View `
9
10
  display: flex;
10
11
  width: 100%;
@@ -17,6 +18,12 @@ const NotificationContainer = styled.View `
17
18
  background-color: ${(p) => p.variant === "primary" ? p.theme.colors.primary.c90 : "transparent"};
18
19
  border-radius: ${(p) => `${p.theme.radii[1]}px`};
19
20
  `;
21
+ const ClosePressableExtendedBounds = styled.TouchableOpacity.attrs({
22
+ p: 5,
23
+ m: -5,
24
+ }) `
25
+ ${space};
26
+ `;
20
27
  export default function Notification({ Icon, iconColor, variant = "primary", numberOfLines, title, subtitle, onClose, linkText, onLinkPress, }) {
21
28
  const { colors } = useTheme();
22
29
  const textColor = variant === "primary" ? colors.neutral.c00 : colors.neutral.c100;
@@ -30,6 +37,6 @@ export default function Notification({ Icon, iconColor, variant = "primary", num
30
37
  React.createElement(TouchableOpacity, { onPress: onLinkPress },
31
38
  React.createElement(Text, { variant: "body", fontWeight: "semiBold", color: textColor }, linkText))))),
32
39
  onClose && (React.createElement(FlexBox, { marginLeft: "auto", pl: 16 },
33
- React.createElement(TouchableOpacity, { onPress: onClose },
40
+ React.createElement(ClosePressableExtendedBounds, { onPress: onClose },
34
41
  React.createElement(CloseMedium, { size: 14, color: textColor }))))));
35
42
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ledgerhq/native-ui",
3
- "version": "0.7.8",
4
- "description": "Ledger Live - Desktop UI",
3
+ "version": "0.7.11",
4
+ "description": "Ledger Live - React Native UI",
5
5
  "repository": "https://github.com/LedgerHQ/ui",
6
6
  "license": "MIT",
7
7
  "author": "Ledger Live Team <team-live@ledger.fr>",