@ledgerhq/native-ui 0.10.0-nightly.2 → 0.11.0-nightly.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,8 @@
1
+ /// <reference types="react" />
2
+ import { Props as FlexProps } from "../../Flex";
3
+ export declare type Props = FlexProps & {
4
+ status: "inactive" | "active" | "completed";
5
+ isFirstItem?: boolean;
6
+ isLastItem?: boolean;
7
+ };
8
+ 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,9 @@
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
+ };
9
+ export default function TimelineItem({ item, formatEstimatedTime, isFirstItem, isLastItem, }: Props): JSX.Element;
@@ -0,0 +1,73 @@
1
+ import React, { useCallback, useState } from "react";
2
+ import Animated, { Easing, useAnimatedStyle, useDerivedValue, withTiming, } from "react-native-reanimated";
3
+ import styled from "styled-components/native";
4
+ import { Flex } from "../..";
5
+ import { Text, Tag } from "../../..";
6
+ import TimelineIndicator from "./TimelineIndicator";
7
+ const getContainerBackground = (theme, status, isLastItem) => {
8
+ if (isLastItem && status === "completed") {
9
+ return theme.colors.success.c30;
10
+ }
11
+ else if (status === "completed") {
12
+ return theme.colors.primary.c20;
13
+ }
14
+ else if (status === "active") {
15
+ return theme.colors.neutral.c20;
16
+ }
17
+ return theme.colors.neutral.c30;
18
+ };
19
+ const getContainerBorder = (theme, status, isLastItem) => {
20
+ if (isLastItem && status === "completed") {
21
+ return theme.colors.success.c30;
22
+ }
23
+ else if (isLastItem && status === "active") {
24
+ return theme.colors.success.c100;
25
+ }
26
+ else if (status === "completed") {
27
+ return theme.colors.primary.c20;
28
+ }
29
+ else if (status === "active") {
30
+ return theme.colors.primary.c80;
31
+ }
32
+ return theme.colors.neutral.c30;
33
+ };
34
+ const Container = styled(Flex) `
35
+ flex: 1;
36
+ border-radius: ${(p) => p.theme.radii[2]}px;
37
+ background: ${(p) => getContainerBackground(p.theme, p.status, p.isLastItem)};
38
+ border: 1px solid ${(p) => getContainerBorder(p.theme, p.status, p.isLastItem)};
39
+ padding: 20px 16px;
40
+ `;
41
+ export default function TimelineItem({ item, formatEstimatedTime, isFirstItem, isLastItem, }) {
42
+ const [height, setHeight] = useState(0);
43
+ const transition = useDerivedValue(() => {
44
+ return item.status === "active"
45
+ ? withTiming(1, { duration: 300, easing: Easing.out(Easing.linear) })
46
+ : withTiming(0, { duration: 300, easing: Easing.in(Easing.linear) });
47
+ }, [item.status]);
48
+ const handleLayoutChange = useCallback((event) => {
49
+ var _a, _b;
50
+ if (height === 0 && ((_b = (_a = event === null || event === void 0 ? void 0 : event.nativeEvent) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.height) > 0) {
51
+ setHeight(event.nativeEvent.layout.height);
52
+ }
53
+ }, [setHeight, height]);
54
+ const style = useAnimatedStyle(() => ({
55
+ height: transition.value * height + 1,
56
+ overflow: "hidden",
57
+ }), [height, transition.value]);
58
+ return (React.createElement(Flex, { flexDirection: "row" },
59
+ React.createElement(TimelineIndicator, { status: item.status, isFirstItem: isFirstItem, isLastItem: isLastItem, mr: 4 }),
60
+ React.createElement(Container, { status: item.status, isLastItem: isLastItem, mb: 4 },
61
+ React.createElement(Flex, { flexDirection: "row", justifyContent: "space-between" },
62
+ React.createElement(Text, { variant: "body", color: item.status === "inactive"
63
+ ? "neutral.c80"
64
+ : isLastItem
65
+ ? "success.c100"
66
+ : "primary.c90" }, item.title),
67
+ (item === null || item === void 0 ? void 0 : item.estimatedTime) && item.status === "active" && (React.createElement(Tag, null, formatEstimatedTime
68
+ ? formatEstimatedTime(item.estimatedTime)
69
+ : `${item.estimatedTime / 60} min`))),
70
+ React.createElement(Animated.View, { style: style }, item.renderBody && (React.createElement(Flex, { position: "relative" },
71
+ React.createElement(Flex, { onLayout: handleLayoutChange, pt: 6, position: "absolute", opacity: 0 }, item.renderBody(false)),
72
+ React.createElement(Flex, { pt: 6 }, item.renderBody(item.status === "active"))))))));
73
+ }
@@ -0,0 +1,14 @@
1
+ import { ReactNode } from "react";
2
+ import { BaseStyledProps } from "src/components/styled";
3
+ export declare type ItemStatus = "inactive" | "active" | "completed";
4
+ export declare type Item = {
5
+ status: ItemStatus;
6
+ title: string;
7
+ estimatedTime?: number;
8
+ renderBody?: (isDisplayed?: boolean) => ReactNode;
9
+ };
10
+ export declare type Props = BaseStyledProps & {
11
+ steps?: Item[];
12
+ formatEstimatedTime?: (_: number) => string;
13
+ };
14
+ export default function VerticalTimeline({ steps, formatEstimatedTime, ...props }: Props): JSX.Element;
@@ -0,0 +1,18 @@
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 default function VerticalTimeline(_a) {
16
+ var { steps, formatEstimatedTime } = _a, props = __rest(_a, ["steps", "formatEstimatedTime"]);
17
+ 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 })))));
18
+ }
@@ -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-nightly.0",
4
4
  "description": "Ledger Live - Mobile UI",
5
5
  "repository": {
6
6
  "type": "git",