@ledgerhq/native-ui 0.11.0-nightly.0 → 0.11.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.
- package/lib/components/Layout/List/VerticalTimeline/TimelineIndicator.d.ts +2 -1
- package/lib/components/Layout/List/VerticalTimeline/TimelineItem.d.ts +3 -1
- package/lib/components/Layout/List/VerticalTimeline/TimelineItem.js +44 -34
- package/lib/components/Layout/List/VerticalTimeline/index.d.ts +11 -2
- package/lib/components/Layout/List/VerticalTimeline/index.js +9 -2
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Props as FlexProps } from "../../Flex";
|
|
3
|
+
import { ItemStatus } from ".";
|
|
3
4
|
export declare type Props = FlexProps & {
|
|
4
|
-
status:
|
|
5
|
+
status: ItemStatus;
|
|
5
6
|
isFirstItem?: boolean;
|
|
6
7
|
isLastItem?: boolean;
|
|
7
8
|
};
|
|
@@ -5,5 +5,7 @@ export declare type Props = {
|
|
|
5
5
|
formatEstimatedTime?: (_: number) => string;
|
|
6
6
|
isFirstItem?: boolean;
|
|
7
7
|
isLastItem?: boolean;
|
|
8
|
+
setActiveIndex?: (_: number) => void;
|
|
9
|
+
index: number;
|
|
8
10
|
};
|
|
9
|
-
export default function TimelineItem({ item, formatEstimatedTime, isFirstItem, isLastItem, }: Props): JSX.Element;
|
|
11
|
+
export default function TimelineItem({ item, formatEstimatedTime, isFirstItem, isLastItem, setActiveIndex, index, }: Props): JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React, { useCallback
|
|
2
|
-
import
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import { Pressable } from "react-native";
|
|
3
|
+
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
3
4
|
import styled from "styled-components/native";
|
|
4
5
|
import { Flex } from "../..";
|
|
5
6
|
import { Text, Tag } from "../../..";
|
|
@@ -38,36 +39,45 @@ const Container = styled(Flex) `
|
|
|
38
39
|
border: 1px solid ${(p) => getContainerBorder(p.theme, p.status, p.isLastItem)};
|
|
39
40
|
padding: 20px 16px;
|
|
40
41
|
`;
|
|
41
|
-
export default function TimelineItem({ item, formatEstimatedTime, isFirstItem, isLastItem, }) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
}, [
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
React.createElement(
|
|
71
|
-
React.createElement(Flex, {
|
|
72
|
-
|
|
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))))));
|
|
73
83
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { BaseStyledProps } from "src/components/styled";
|
|
3
|
-
export declare
|
|
3
|
+
export declare enum ItemStatus {
|
|
4
|
+
inactive = "inactive",
|
|
5
|
+
active = "active",
|
|
6
|
+
completed = "completed"
|
|
7
|
+
}
|
|
4
8
|
export declare type Item = {
|
|
5
9
|
status: ItemStatus;
|
|
6
10
|
title: string;
|
|
@@ -10,5 +14,10 @@ export declare type Item = {
|
|
|
10
14
|
export declare type Props = BaseStyledProps & {
|
|
11
15
|
steps?: Item[];
|
|
12
16
|
formatEstimatedTime?: (_: number) => string;
|
|
17
|
+
setActiveIndex?: (arg0: number) => void;
|
|
13
18
|
};
|
|
14
|
-
|
|
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;
|
|
@@ -12,7 +12,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import React from "react";
|
|
13
13
|
import TimelineItem from "./TimelineItem";
|
|
14
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 = {}));
|
|
15
21
|
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 })))));
|
|
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 })))));
|
|
18
24
|
}
|
|
25
|
+
VerticalTimeline.ItemStatus = ItemStatus;
|