@ledgerhq/native-ui 0.10.0-nightly.2 → 0.11.0-next.0

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.
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { Props as FlexProps } from "../../Flex";
3
+ import { ItemStatus } from ".";
4
+ export declare type Props = FlexProps & {
5
+ status: ItemStatus;
6
+ isFirstItem?: boolean;
7
+ isLastItem?: boolean;
8
+ };
9
+ export default function TimelineIndicator({ status, isFirstItem, isLastItem, ...props }: Props): JSX.Element;
@@ -0,0 +1,67 @@
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 from "react";
13
+ import { CircledCheckSolidMedium } from "@ledgerhq/icons-ui/native";
14
+ import styled, { useTheme } from "styled-components/native";
15
+ import Flex from "../../Flex";
16
+ const TopSegment = styled(Flex) `
17
+ height: 20px;
18
+ border-width: ${(p) => (p.hidden ? 0 : 1)}px;
19
+ border-style: solid;
20
+ border-color: ${(p) => p.status === "inactive" ? p.theme.colors.neutral.c50 : p.theme.colors.primary.c80};
21
+ background: ${(p) => p.status === "inactive" ? p.theme.colors.neutral.c50 : p.theme.colors.primary.c80};
22
+ `;
23
+ const BottomSegment = styled(Flex) `
24
+ flex: 1;
25
+ border-width: ${(p) => (p.hidden ? 0 : 1)}px;
26
+ border-style: solid;
27
+ border-color: ${(p) => p.status === "completed" ? p.theme.colors.primary.c80 : p.theme.colors.neutral.c50};
28
+ background: ${(p) => p.status === "completed" ? p.theme.colors.primary.c80 : p.theme.colors.neutral.c50};
29
+ `;
30
+ const getIconBackground = (theme, status, isLastItem) => {
31
+ if (status === "completed") {
32
+ return "transparent";
33
+ }
34
+ else if (isLastItem) {
35
+ return theme.colors.success.c10;
36
+ }
37
+ else if (status === "active") {
38
+ return theme.colors.neutral.c40;
39
+ }
40
+ return theme.colors.background.main;
41
+ };
42
+ const getIconBorder = (theme, status, isLastItem) => {
43
+ if (isLastItem) {
44
+ return theme.colors.success.c100;
45
+ }
46
+ else if (status === "inactive") {
47
+ return theme.colors.neutral.c50;
48
+ }
49
+ return theme.colors.primary.c80;
50
+ };
51
+ const CenterSegment = styled(Flex) `
52
+ border-radius: 9999px;
53
+ width: 20px;
54
+ height: 20px;
55
+ background: ${(p) => getIconBackground(p.theme, p.status, p.isLastItem)};
56
+ border: 2px solid ${(p) => getIconBorder(p.theme, p.status, p.isLastItem)};
57
+ align-items: center;
58
+ justify-content: center;
59
+ `;
60
+ export default function TimelineIndicator(_a) {
61
+ var { status, isFirstItem, isLastItem } = _a, props = __rest(_a, ["status", "isFirstItem", "isLastItem"]);
62
+ const { colors } = useTheme();
63
+ return (React.createElement(Flex, Object.assign({ flexDirection: "column", alignItems: "center" }, props),
64
+ React.createElement(TopSegment, { status: status, hidden: isFirstItem }),
65
+ React.createElement(CenterSegment, { status: status, isLastItem: isLastItem }, status === "completed" && (React.createElement(CircledCheckSolidMedium, { color: isLastItem ? colors.success.c100 : colors.primary.c80, size: 24 }))),
66
+ React.createElement(BottomSegment, { status: status, hidden: isLastItem })));
67
+ }
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { Item } from ".";
3
+ export declare type Props = {
4
+ item: Item;
5
+ formatEstimatedTime?: (_: number) => string;
6
+ isFirstItem?: boolean;
7
+ isLastItem?: boolean;
8
+ setActiveIndex?: (_: number) => void;
9
+ index: number;
10
+ };
11
+ export default function TimelineItem({ item, formatEstimatedTime, isFirstItem, isLastItem, setActiveIndex, index, }: Props): JSX.Element;
@@ -0,0 +1,83 @@
1
+ import React, { useCallback } from "react";
2
+ import { Pressable } from "react-native";
3
+ import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
4
+ import styled from "styled-components/native";
5
+ import { Flex } from "../..";
6
+ import { Text, Tag } from "../../..";
7
+ import TimelineIndicator from "./TimelineIndicator";
8
+ const getContainerBackground = (theme, status, isLastItem) => {
9
+ if (isLastItem && status === "completed") {
10
+ return theme.colors.success.c30;
11
+ }
12
+ else if (status === "completed") {
13
+ return theme.colors.primary.c20;
14
+ }
15
+ else if (status === "active") {
16
+ return theme.colors.neutral.c20;
17
+ }
18
+ return theme.colors.neutral.c30;
19
+ };
20
+ const getContainerBorder = (theme, status, isLastItem) => {
21
+ if (isLastItem && status === "completed") {
22
+ return theme.colors.success.c30;
23
+ }
24
+ else if (isLastItem && status === "active") {
25
+ return theme.colors.success.c100;
26
+ }
27
+ else if (status === "completed") {
28
+ return theme.colors.primary.c20;
29
+ }
30
+ else if (status === "active") {
31
+ return theme.colors.primary.c80;
32
+ }
33
+ return theme.colors.neutral.c30;
34
+ };
35
+ const Container = styled(Flex) `
36
+ flex: 1;
37
+ border-radius: ${(p) => p.theme.radii[2]}px;
38
+ background: ${(p) => getContainerBackground(p.theme, p.status, p.isLastItem)};
39
+ border: 1px solid ${(p) => getContainerBorder(p.theme, p.status, p.isLastItem)};
40
+ padding: 20px 16px;
41
+ `;
42
+ export default function TimelineItem({ item, formatEstimatedTime, isFirstItem, isLastItem, setActiveIndex, index, }) {
43
+ /**
44
+ * Having an initial value of null will prevent having "height: 0" before the
45
+ * initial call of onLayout.
46
+ * The component will just layout normally without an animation which is ok
47
+ * since this will happen only on the first step.
48
+ * Without this default behavior, there are issues on iOS where sometimes the
49
+ * height is stuck at 0.
50
+ */
51
+ const sharedHeight = useSharedValue(null);
52
+ const handleLayout = useCallback(({ nativeEvent: { layout } }) => {
53
+ sharedHeight.value = withTiming(layout.height, { duration: 300 });
54
+ }, [sharedHeight]);
55
+ const animatedStyle = useAnimatedStyle(() => {
56
+ var _a;
57
+ return ({
58
+ /**
59
+ * If it's null the component still renders normally at its full height
60
+ * without its height being derived from an animated value.
61
+ */
62
+ height: (_a = sharedHeight.value) !== null && _a !== void 0 ? _a : undefined,
63
+ });
64
+ }, []);
65
+ const handlePress = useCallback(() => {
66
+ setActiveIndex && setActiveIndex(index);
67
+ }, [setActiveIndex, index]);
68
+ return (React.createElement(Pressable, { onPress: handlePress },
69
+ React.createElement(Flex, { flexDirection: "row" },
70
+ React.createElement(TimelineIndicator, { status: item.status, isFirstItem: isFirstItem, isLastItem: isLastItem, mr: 4 }),
71
+ React.createElement(Container, { status: item.status, isLastItem: isLastItem, mb: 4 },
72
+ React.createElement(Flex, { flexDirection: "row", justifyContent: "space-between" },
73
+ React.createElement(Text, { variant: "body", color: item.status === "inactive"
74
+ ? "neutral.c80"
75
+ : isLastItem
76
+ ? "success.c100"
77
+ : "primary.c90" }, item.title),
78
+ (item === null || item === void 0 ? void 0 : item.estimatedTime) && item.status === "active" && (React.createElement(Tag, null, formatEstimatedTime
79
+ ? formatEstimatedTime(item.estimatedTime)
80
+ : `${item.estimatedTime / 60} min`))),
81
+ React.createElement(Animated.ScrollView, { style: animatedStyle },
82
+ React.createElement(Animated.View, { onLayout: handleLayout }, item.renderBody && item.status === "active" ? (React.createElement(Flex, { pt: 6 }, item.renderBody(true))) : null))))));
83
+ }
@@ -0,0 +1,23 @@
1
+ import { ReactNode } from "react";
2
+ import { BaseStyledProps } from "src/components/styled";
3
+ export declare enum ItemStatus {
4
+ inactive = "inactive",
5
+ active = "active",
6
+ completed = "completed"
7
+ }
8
+ export declare type Item = {
9
+ status: ItemStatus;
10
+ title: string;
11
+ estimatedTime?: number;
12
+ renderBody?: (isDisplayed?: boolean) => ReactNode;
13
+ };
14
+ export declare type Props = BaseStyledProps & {
15
+ steps?: Item[];
16
+ formatEstimatedTime?: (_: number) => string;
17
+ setActiveIndex?: (arg0: number) => void;
18
+ };
19
+ declare function VerticalTimeline({ steps, formatEstimatedTime, setActiveIndex, ...props }: Props): JSX.Element;
20
+ declare namespace VerticalTimeline {
21
+ var ItemStatus: typeof import(".").ItemStatus;
22
+ }
23
+ export default VerticalTimeline;
@@ -0,0 +1,25 @@
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 from "react";
13
+ import TimelineItem from "./TimelineItem";
14
+ import { Flex } from "../..";
15
+ export var ItemStatus;
16
+ (function (ItemStatus) {
17
+ ItemStatus["inactive"] = "inactive";
18
+ ItemStatus["active"] = "active";
19
+ ItemStatus["completed"] = "completed";
20
+ })(ItemStatus || (ItemStatus = {}));
21
+ export default function VerticalTimeline(_a) {
22
+ var { steps, formatEstimatedTime, setActiveIndex } = _a, props = __rest(_a, ["steps", "formatEstimatedTime", "setActiveIndex"]);
23
+ return (React.createElement(Flex, Object.assign({}, props, { flexDirection: "column" }), steps === null || steps === void 0 ? void 0 : steps.map((step, index) => (React.createElement(TimelineItem, { key: step.title, item: step, formatEstimatedTime: formatEstimatedTime, isFirstItem: index === 0, isLastItem: index === steps.length - 1, setActiveIndex: setActiveIndex, index: index })))));
24
+ }
25
+ VerticalTimeline.ItemStatus = ItemStatus;
@@ -2,3 +2,4 @@ export { default as List } from "./List";
2
2
  export { default as IconBoxList } from "./IconBoxList";
3
3
  export { default as TipList } from "./TipList";
4
4
  export { default as NumberedList } from "./NumberedList";
5
+ export { default as VerticalTimeline } from "./VerticalTimeline";
@@ -2,3 +2,4 @@ export { default as List } from "./List";
2
2
  export { default as IconBoxList } from "./IconBoxList";
3
3
  export { default as TipList } from "./TipList";
4
4
  export { default as NumberedList } from "./NumberedList";
5
+ export { default as VerticalTimeline } from "./VerticalTimeline";
@@ -4,26 +4,25 @@ import Text from "../../Text";
4
4
  import TemplateTabs from "../TemplateTabs";
5
5
  const TabBox = styled.TouchableOpacity `
6
6
  text-align: center;
7
- margin: auto;
8
- flex: 1;
9
- border-radius: 48px;
7
+ border-radius: 4px;
8
+ box-sizing: border-box;
10
9
  overflow: hidden;
10
+ margin-left: 2px;
11
11
  `;
12
12
  const TabText = styled(Text).attrs((p) => ({
13
13
  // Avoid conflict with styled-system's size property by nulling size and renaming it
14
14
  size: undefined,
15
- lineHeight: p.size === "medium" ? "36px" : "26px",
15
+ lineHeight: p.size === "medium" ? "40px" : "26px",
16
16
  textAlign: "center",
17
- px: 4,
18
- height: p.size === "medium" ? "36px" : "26px",
17
+ height: p.size === "medium" ? "40px" : "26px",
18
+ width: 40,
19
19
  })) ``;
20
20
  const StyledTabs = styled(TemplateTabs) `
21
- border: ${(p) => `1px solid ${p.theme.colors.neutral.c40}`};
22
- border-radius: 35px;
23
- padding: ${(p) => `${p.theme.space[p.size === "medium" ? 2 : 1]}px`};
21
+ display: flex;
22
+ justify-content: center;
24
23
  `;
25
- export const GraphTab = ({ onPress, isActive, label, activeColor = "neutral.c100", activeBg = "primary.c20", size = "medium", disabled, }) => {
26
- return (React.createElement(TabBox, { onPress: onPress, disabled: disabled }, isActive ? (React.createElement(TabText, { variant: "small", size: size, bg: activeBg, color: disabled ? "neutral.c70" : activeColor, fontWeight: "semiBold" }, label)) : (React.createElement(TabText, { variant: "small", size: size, color: disabled ? "neutral.c70" : "neutral.c90" }, label))));
24
+ export const GraphTab = ({ onPress, isActive, label, activeColor = "neutral.c100", activeBg = "neutral.c30", size = "medium", disabled, }) => {
25
+ return (React.createElement(TabBox, { onPress: onPress, disabled: disabled }, isActive ? (React.createElement(TabText, { variant: "small", size: size, bg: activeBg, color: disabled ? "neutral.c70" : activeColor, fontWeight: "semiBold", uppercase: true }, label)) : (React.createElement(TabText, { variant: "small", size: size, color: disabled ? "neutral.c70" : "neutral.c90", uppercase: true }, label))));
27
26
  };
28
27
  const GraphTabs = (props) => (React.createElement(StyledTabs, Object.assign({}, props, { Item: GraphTab })));
29
28
  export default GraphTabs;
@@ -2,11 +2,9 @@
2
2
  import React from "react";
3
3
  import { TouchableOpacity, TouchableOpacityProps } from "react-native";
4
4
  import { BaseStyledProps } from "../../styled";
5
+ import { IconType } from "../../Icon/type";
5
6
  export declare type ButtonProps = TouchableOpacityProps & BaseStyledProps & {
6
- Icon?: React.ComponentType<{
7
- size: number;
8
- color: string;
9
- }> | null;
7
+ Icon?: IconType;
10
8
  iconName?: string;
11
9
  type?: "main" | "shade" | "error" | "color" | "default";
12
10
  size?: "small" | "medium" | "large";
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { TouchableOpacity, TouchableOpacityProps } from "react-native";
3
+ import { IconType } from "src/components/Icon/type";
4
+ import { BaseStyledProps } from "../../../styled";
5
+ export declare type QuickActionButtonProps = TouchableOpacityProps & BaseStyledProps & {
6
+ Icon: IconType;
7
+ disabled?: boolean;
8
+ onPressWhenDisabled?: TouchableOpacityProps["onPress"];
9
+ };
10
+ export declare const Base: import("styled-components").StyledComponent<typeof TouchableOpacity, import("styled-components").DefaultTheme, TouchableOpacityProps & {
11
+ visuallyDisabled?: boolean | undefined;
12
+ }, never>;
13
+ declare const QuickActionButton: ({ Icon, children, disabled, onPress, onPressWhenDisabled, ...otherProps }: QuickActionButtonProps) => React.ReactElement;
14
+ export default QuickActionButton;
@@ -0,0 +1,34 @@
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 from "react";
13
+ import { TouchableOpacity } from "react-native";
14
+ import Text from "../../../Text";
15
+ import baseStyled from "../../../styled";
16
+ export const Base = baseStyled(TouchableOpacity) `
17
+ height: 80px;
18
+ flex-direction: column;
19
+ text-align: center;
20
+ align-items: center;
21
+ justify-content: center;
22
+ border-radius: ${(p) => p.theme.radii[2]}px;
23
+ padding: 0 ${(p) => p.theme.space[6]}px;
24
+ ${({ visuallyDisabled, theme }) => visuallyDisabled
25
+ ? `border: 1px solid ${theme.colors.neutral.c30};`
26
+ : `background-color: ${theme.colors.neutral.c20};`}
27
+ `;
28
+ const QuickActionButton = (_a) => {
29
+ var { Icon, children, disabled, onPress, onPressWhenDisabled } = _a, otherProps = __rest(_a, ["Icon", "children", "disabled", "onPress", "onPressWhenDisabled"]);
30
+ return (React.createElement(Base, Object.assign({ disabled: onPressWhenDisabled ? false : disabled, onPress: disabled ? onPressWhenDisabled : onPress, visuallyDisabled: disabled }, otherProps),
31
+ React.createElement(Icon, { size: 24, color: disabled ? "neutral.c50" : "neutral.c100" }),
32
+ React.createElement(Text, { variant: "body", fontWeight: "semiBold", color: disabled ? "neutral.c50" : "neutral.c100", mt: 2 }, children)));
33
+ };
34
+ export default QuickActionButton;
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ import { FlatListProps } from "react-native";
3
+ import { QuickActionButtonProps } from "../QuickActionButton";
4
+ export declare type QuickActionListProps = Omit<FlatListProps<QuickActionButtonProps>, "renderItem">;
5
+ declare const QuickActionList: ({ numColumns, data, ...otherProps }: QuickActionListProps) => React.ReactElement;
6
+ export default QuickActionList;
@@ -0,0 +1,22 @@
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 { FlatList } from "react-native";
14
+ import QuickActionButton from "../QuickActionButton";
15
+ const QuickActionList = (_a) => {
16
+ var { numColumns = 3, data } = _a, otherProps = __rest(_a, ["numColumns", "data"]);
17
+ const renderItem = useCallback(({ item, index }) => {
18
+ return (React.createElement(QuickActionButton, Object.assign({}, item, { flex: 1, mr: (index + 1) % numColumns > 0 && data && index !== data.length - 1 ? 4 : 0, mb: (data === null || data === void 0 ? void 0 : data.length) && index + numColumns < data.length ? 4 : 0 })));
19
+ }, []);
20
+ return (React.createElement(FlatList, Object.assign({}, otherProps, { data: data, horizontal: false, renderItem: renderItem, numColumns: numColumns, style: { width: "100%" } })));
21
+ };
22
+ export default QuickActionList;
@@ -0,0 +1,2 @@
1
+ export { default as QuickActionList } from "./QuickActionList";
2
+ export { default as QuickActionButton } from "./QuickActionButton";
@@ -0,0 +1,2 @@
1
+ export { default as QuickActionList } from "./QuickActionList";
2
+ export { default as QuickActionButton } from "./QuickActionButton";
@@ -1,2 +1,3 @@
1
1
  export { default as Button } from "./Button";
2
2
  export { default as Link } from "./Link";
3
+ export * from "./QuickAction";
@@ -1,2 +1,3 @@
1
1
  export { default as Button } from "./Button";
2
2
  export { default as Link } from "./Link";
3
+ export * from "./QuickAction";
@@ -7,5 +7,7 @@ export interface TagProps extends FlexBoxProps {
7
7
  Icon?: IconType;
8
8
  uppercase?: boolean;
9
9
  children?: React.ReactNode;
10
+ numberOfLines?: number;
11
+ ellipsizeMode?: "head" | "middle" | "tail" | "clip";
10
12
  }
11
- export default function Tag({ type, size, uppercase, Icon, children, ...props }: TagProps): JSX.Element;
13
+ export default function Tag({ type, size, uppercase, Icon, children, numberOfLines, ellipsizeMode, ...props }: TagProps): JSX.Element;
@@ -19,9 +19,9 @@ const typeColor = {
19
19
  warning: "warning.c100",
20
20
  };
21
21
  export default function Tag(_a) {
22
- var { type = "shade", size = "small", uppercase, Icon, children } = _a, props = __rest(_a, ["type", "size", "uppercase", "Icon", "children"]);
22
+ var { type = "shade", size = "small", uppercase, Icon, children, numberOfLines, ellipsizeMode } = _a, props = __rest(_a, ["type", "size", "uppercase", "Icon", "children", "numberOfLines", "ellipsizeMode"]);
23
23
  return (React.createElement(Flex, Object.assign({ px: size === "small" ? "6px" : 3, alignItems: "center", justifyContent: "center", flexDirection: "row", borderRadius: 6, bg: typeColor[type], height: size === "small" ? "18px" : "28px" }, props),
24
24
  Icon && (React.createElement(Box, { pr: 2 },
25
25
  React.createElement(Icon, { size: size === "small" ? 16 : 20, color: type === "shade" ? "neutral.c90" : "neutral.c00" }))),
26
- React.createElement(Text, { variant: size === "small" ? "subtitle" : "small", fontWeight: "bold", uppercase: uppercase !== false, textAlign: "center", color: type === "shade" ? "neutral.c90" : "neutral.c00" }, children)));
26
+ React.createElement(Text, { variant: size === "small" ? "subtitle" : "small", fontWeight: "bold", uppercase: uppercase !== false, textAlign: "center", color: type === "shade" ? "neutral.c90" : "neutral.c00", numberOfLines: numberOfLines, ellipsizeMode: ellipsizeMode }, children)));
27
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/native-ui",
3
- "version": "0.10.0-nightly.2",
3
+ "version": "0.11.0-next.0",
4
4
  "description": "Ledger Live - Mobile UI",
5
5
  "repository": {
6
6
  "type": "git",