@ledgerhq/native-ui 0.15.1-next.0 → 0.16.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,11 @@
1
+ /// <reference types="react" />
2
+ import { Item } from "../types";
3
+ export type Props = {
4
+ item: Item;
5
+ progress?: number;
6
+ nested?: boolean;
7
+ isLastItem?: boolean;
8
+ setActiveIndex?: (_: number) => void;
9
+ index: number;
10
+ };
11
+ export default function StepperItem({ item, progress, nested, isLastItem, setActiveIndex, index, }: Props): JSX.Element;
@@ -0,0 +1,52 @@
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 { CheckAloneMedium } from "@ledgerhq/icons-ui/native";
6
+ import { Flex } from "../..";
7
+ import { Text, ProgressLoader } from "../../..";
8
+ const Container = styled(Flex) `
9
+ flex: 1;
10
+ border-bottom-width: ${(p) => (p.nested ? 0 : 1)}px;
11
+ border-bottom-color: ${(p) => p.isLastItem && p.status !== "inactive" ? "transparent" : p.theme.colors.neutral.c40};
12
+ `;
13
+ export default function StepperItem({ item, progress, nested, isLastItem, setActiveIndex, index, }) {
14
+ var _a;
15
+ /**
16
+ * Having an initial value of null will prevent having "height: 0" before the
17
+ * initial call of onLayout.
18
+ * The component will just layout normally without an animation which is ok
19
+ * since this will happen only on the first step.
20
+ * Without this default behavior, there are issues on iOS where sometimes the
21
+ * height is stuck at 0.
22
+ */
23
+ const sharedHeight = useSharedValue(null);
24
+ const handleLayout = useCallback(({ nativeEvent: { layout } }) => {
25
+ sharedHeight.value = withTiming(layout.height, { duration: 300 });
26
+ }, [sharedHeight]);
27
+ const animatedStyle = useAnimatedStyle(() => {
28
+ var _a;
29
+ return ({
30
+ /**
31
+ * If it's null the component still renders normally at its full height
32
+ * without its height being derived from an animated value.
33
+ */
34
+ height: (_a = sharedHeight.value) !== null && _a !== void 0 ? _a : undefined,
35
+ });
36
+ }, []);
37
+ const handlePress = useCallback(() => {
38
+ setActiveIndex && setActiveIndex(index);
39
+ }, [setActiveIndex, index]);
40
+ return (React.createElement(Pressable, { onPress: handlePress },
41
+ React.createElement(Flex, { flexDirection: "row" },
42
+ React.createElement(Container, { nested: nested, status: item.status, isLastItem: isLastItem },
43
+ React.createElement(Flex, { px: nested ? 0 : 4, py: nested ? 4 : 7, flexDirection: nested ? "row-reverse" : "row", justifyContent: nested ? "space-between" : "flex-start" },
44
+ React.createElement(Flex, { width: "28px", alignItems: "center" },
45
+ item.status === "completed" && React.createElement(CheckAloneMedium, { size: 20, color: "success.c100" }),
46
+ item.status === "active" && (React.createElement(ProgressLoader, { progress: progress, infinite: !progress, radius: 10, strokeWidth: 2 }))),
47
+ React.createElement(Flex, { flex: 1, ml: nested ? 0 : 4, mr: nested ? 0 : 2 },
48
+ React.createElement(Flex, { pb: item.status === "active" && item.renderBody ? 4 : undefined },
49
+ React.createElement(Text, { variant: "body", color: item.status === "active" || nested ? "neutral.c100" : "neutral.c80" }, item.status === "completed" ? (_a = item.doneTitle) !== null && _a !== void 0 ? _a : item.title : item.title)),
50
+ React.createElement(Animated.ScrollView, { style: animatedStyle, showsVerticalScrollIndicator: false },
51
+ React.createElement(Animated.View, { onLayout: handleLayout }, item.renderBody && item.status === "active" ? item.renderBody(true) : null))))))));
52
+ }
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { BaseStyledProps } from "src/components/styled";
3
+ import { Item } from "../types";
4
+ export type Props = BaseStyledProps & {
5
+ steps?: Item[];
6
+ setActiveIndex?: (arg0: number) => void;
7
+ nested?: boolean;
8
+ };
9
+ declare function VerticalStepper({ steps, setActiveIndex, nested, ...props }: Props): JSX.Element;
10
+ declare namespace VerticalStepper {
11
+ var ItemStatus: typeof import("../types").ItemStatus;
12
+ }
13
+ export default VerticalStepper;
@@ -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 from "react";
13
+ import StepperItem from "./StepperItem";
14
+ import { Flex } from "../..";
15
+ import { ItemStatus } from "../types";
16
+ export default function VerticalStepper(_a) {
17
+ var { steps, setActiveIndex, nested } = _a, props = __rest(_a, ["steps", "setActiveIndex", "nested"]);
18
+ return (React.createElement(Flex, Object.assign({}, props, { flexDirection: "column" }),
19
+ nested && React.createElement(Flex, { mt: 7, mb: 4, borderBottomWidth: 1, borderBottomColor: "neutral.c40" }), steps === null || steps === void 0 ? void 0 :
20
+ steps.map((step, index) => (React.createElement(StepperItem, { key: step.title, item: step, progress: step.progress, nested: nested, isLastItem: index === steps.length - 1, setActiveIndex: setActiveIndex, index: index })))));
21
+ }
22
+ VerticalStepper.ItemStatus = ItemStatus;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { Props as FlexProps } from "../../Flex";
3
- import { ItemStatus } from ".";
3
+ import { ItemStatus } from "../types";
4
4
  export type Props = FlexProps & {
5
5
  status: ItemStatus;
6
6
  isFirstItem?: boolean;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { Item } from ".";
2
+ import { Item } from "../types";
3
3
  export type Props = {
4
4
  item: Item;
5
5
  formatEstimatedTime?: (_: number) => string;
@@ -1,17 +1,6 @@
1
- import { ReactNode } from "react";
1
+ /// <reference types="react" />
2
2
  import { BaseStyledProps } from "src/components/styled";
3
- export declare enum ItemStatus {
4
- inactive = "inactive",
5
- active = "active",
6
- completed = "completed"
7
- }
8
- export type Item = {
9
- status: ItemStatus;
10
- title: string;
11
- doneTitle?: string;
12
- estimatedTime?: number;
13
- renderBody?: (isDisplayed?: boolean) => ReactNode;
14
- };
3
+ import { Item } from "../types";
15
4
  export type Props = BaseStyledProps & {
16
5
  steps?: Item[];
17
6
  formatEstimatedTime?: (_: number) => string;
@@ -19,6 +8,6 @@ export type Props = BaseStyledProps & {
19
8
  };
20
9
  declare function VerticalTimeline({ steps, formatEstimatedTime, setActiveIndex, ...props }: Props): JSX.Element;
21
10
  declare namespace VerticalTimeline {
22
- var ItemStatus: typeof import(".").ItemStatus;
11
+ var ItemStatus: typeof import("../types").ItemStatus;
23
12
  }
24
13
  export default VerticalTimeline;
@@ -12,12 +12,7 @@ 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
+ import { ItemStatus } from "../types";
21
16
  export default function VerticalTimeline(_a) {
22
17
  var { steps, formatEstimatedTime, setActiveIndex } = _a, props = __rest(_a, ["steps", "formatEstimatedTime", "setActiveIndex"]);
23
18
  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 })))));
@@ -3,3 +3,4 @@ export { default as IconBoxList } from "./IconBoxList";
3
3
  export { default as TipList } from "./TipList";
4
4
  export { default as NumberedList } from "./NumberedList";
5
5
  export { default as VerticalTimeline } from "./VerticalTimeline";
6
+ export { default as VerticalStepper } from "./VerticalStepper";
@@ -3,3 +3,4 @@ export { default as IconBoxList } from "./IconBoxList";
3
3
  export { default as TipList } from "./TipList";
4
4
  export { default as NumberedList } from "./NumberedList";
5
5
  export { default as VerticalTimeline } from "./VerticalTimeline";
6
+ export { default as VerticalStepper } from "./VerticalStepper";
@@ -0,0 +1,14 @@
1
+ import { ReactNode } from "react";
2
+ export declare enum ItemStatus {
3
+ inactive = "inactive",
4
+ active = "active",
5
+ completed = "completed"
6
+ }
7
+ export type Item = {
8
+ status: ItemStatus;
9
+ title: string;
10
+ doneTitle?: string;
11
+ estimatedTime?: number;
12
+ progress?: number;
13
+ renderBody?: (isDisplayed?: boolean) => ReactNode;
14
+ };
@@ -0,0 +1,6 @@
1
+ export var ItemStatus;
2
+ (function (ItemStatus) {
3
+ ItemStatus["inactive"] = "inactive";
4
+ ItemStatus["active"] = "active";
5
+ ItemStatus["completed"] = "completed";
6
+ })(ItemStatus || (ItemStatus = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/native-ui",
3
- "version": "0.15.1-next.0",
3
+ "version": "0.16.0-nightly.0",
4
4
  "description": "Ledger Live - Mobile UI",
5
5
  "repository": {
6
6
  "type": "git",