@ledgerhq/react-ui 0.6.0 → 0.7.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/components/asorted/Icon/BoxedIcon.js +6 -2
- package/components/layout/Drawer/index.d.ts +8 -2
- package/components/layout/Drawer/index.js +24 -16
- package/components/layout/Popin/index.d.ts +2 -1
- package/components/layout/Popin/index.js +10 -5
- package/components/navigation/FlowStepper/index.d.ts +76 -0
- package/components/navigation/FlowStepper/index.js +35 -0
- package/components/navigation/index.d.ts +1 -0
- package/components/navigation/index.js +1 -0
- package/components/navigation/progress/Stepper/index.d.ts +25 -9
- package/components/navigation/progress/Stepper/index.js +37 -18
- package/components/navigation/sideBar/SideBar/SideBar.js +9 -7
- package/package.json +1 -1
|
@@ -15,6 +15,9 @@ import Flex from "../../layout/Flex";
|
|
|
15
15
|
export const DEFAULT_BOX_SIZE = 40;
|
|
16
16
|
export const DEFAULT_ICON_SIZE = 16;
|
|
17
17
|
export const DEFAULT_BADGE_SIZE = 20;
|
|
18
|
+
function getClipRectangleSize(badgeSize) {
|
|
19
|
+
return (3 / 4) * badgeSize;
|
|
20
|
+
}
|
|
18
21
|
const getTopRightSquareClippedPolygon = (boxSize, rectangleSize) => {
|
|
19
22
|
// clipping path that hides top right square of size `${rectangleSize}px`
|
|
20
23
|
const diff = boxSize - rectangleSize;
|
|
@@ -32,7 +35,8 @@ const IconBoxBackground = styled(Flex) `
|
|
|
32
35
|
height: ${(p) => p.size}px;
|
|
33
36
|
width: ${(p) => p.size}px;
|
|
34
37
|
${(p) => {
|
|
35
|
-
return p.hasBadge &&
|
|
38
|
+
return (p.hasBadge &&
|
|
39
|
+
`clip-path: ${getTopRightSquareClippedPolygon(p.size, getClipRectangleSize(p.badgeSize))};`);
|
|
36
40
|
}};
|
|
37
41
|
border-radius: ${(p) => p.theme.radii[2]}px;
|
|
38
42
|
`;
|
|
@@ -45,7 +49,7 @@ const BadgeContainer = styled.div `
|
|
|
45
49
|
export const IconBox = ({ Badge, size = DEFAULT_BOX_SIZE, children, borderColor = "neutral.c40", badgeColor, badgeSize = DEFAULT_BADGE_SIZE, }) => {
|
|
46
50
|
const hasBadge = !!Badge;
|
|
47
51
|
return (React.createElement(Container, { size: size },
|
|
48
|
-
React.createElement(IconBoxBackground, { size: size, hasBadge: hasBadge, border: "1px solid", borderColor: borderColor }),
|
|
52
|
+
React.createElement(IconBoxBackground, { size: size, badgeSize: badgeSize, hasBadge: hasBadge, border: "1px solid", borderColor: borderColor }),
|
|
49
53
|
children,
|
|
50
54
|
hasBadge && (React.createElement(BadgeContainer, { badgeSize: badgeSize },
|
|
51
55
|
React.createElement(Badge, { size: badgeSize, color: badgeColor })))));
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
export declare enum Direction {
|
|
3
|
+
Left = "left",
|
|
4
|
+
Right = "right"
|
|
5
|
+
}
|
|
2
6
|
export interface DrawerProps {
|
|
3
7
|
isOpen: boolean;
|
|
4
8
|
children: React.ReactNode;
|
|
@@ -11,6 +15,8 @@ export interface DrawerProps {
|
|
|
11
15
|
onBack?: () => void;
|
|
12
16
|
setTransitionsEnabled?: (arg0: boolean) => void;
|
|
13
17
|
hideNavigation?: boolean;
|
|
18
|
+
menuPortalTarget?: Element | null;
|
|
19
|
+
direction?: Direction;
|
|
14
20
|
}
|
|
15
|
-
declare const
|
|
16
|
-
export default
|
|
21
|
+
declare const _default: React.ForwardRefExoticComponent<DrawerProps & React.RefAttributes<HTMLDivElement>>;
|
|
22
|
+
export default _default;
|
|
@@ -19,6 +19,11 @@ import ArrowLeft from "@ledgerhq/icons-ui/react/ArrowLeftRegular";
|
|
|
19
19
|
import TransitionSlide from "../../transitions/TransitionSlide";
|
|
20
20
|
import TransitionInOut from "../../transitions/TransitionInOut";
|
|
21
21
|
import Text from "../../asorted/Text";
|
|
22
|
+
export var Direction;
|
|
23
|
+
(function (Direction) {
|
|
24
|
+
Direction["Left"] = "left";
|
|
25
|
+
Direction["Right"] = "right";
|
|
26
|
+
})(Direction || (Direction = {}));
|
|
22
27
|
const Container = styled(FlexBox) `
|
|
23
28
|
width: 100%;
|
|
24
29
|
height: 100%;
|
|
@@ -34,11 +39,9 @@ const Footer = styled(FlexBox) `
|
|
|
34
39
|
align-items: center;
|
|
35
40
|
padding: ${(p) => p.theme.space[8]}px ${(p) => p.theme.space[12]}px;
|
|
36
41
|
`;
|
|
37
|
-
const Wrapper = styled
|
|
42
|
+
const Wrapper = styled(FlexBox) `
|
|
38
43
|
height: 100%;
|
|
39
44
|
width: ${(p) => p.big ? p.theme.sizes.drawer.side.big.width : p.theme.sizes.drawer.side.small.width}px;
|
|
40
|
-
background-color: ${(p) => { var _a; return (_a = p.backgroundColor) !== null && _a !== void 0 ? _a : p.theme.colors.neutral.c00; }};
|
|
41
|
-
display: flex;
|
|
42
45
|
flex-direction: column;
|
|
43
46
|
align-items: stretch;
|
|
44
47
|
justify-content: space-between;
|
|
@@ -47,7 +50,7 @@ const Wrapper = styled.div `
|
|
|
47
50
|
const Overlay = styled.div `
|
|
48
51
|
display: flex;
|
|
49
52
|
position: fixed;
|
|
50
|
-
justify-content: flex-end;
|
|
53
|
+
justify-content: ${(p) => (p.direction === Direction.Left ? "flex-end" : "flex-start")};
|
|
51
54
|
top: 0;
|
|
52
55
|
left: 0;
|
|
53
56
|
width: 100vw;
|
|
@@ -75,7 +78,7 @@ const Button = styled.button `
|
|
|
75
78
|
cursor: pointer;
|
|
76
79
|
color: ${(p) => p.theme.colors.neutral.c100};
|
|
77
80
|
`;
|
|
78
|
-
const DrawerContent = ({ isOpen, title, children, footer, big, onClose, backgroundColor, setTransitionsEnabled = () => 0, onBack, ignoreBackdropClick = false, hideNavigation = true, }) => {
|
|
81
|
+
const DrawerContent = React.forwardRef(({ isOpen, title, children, footer, big, onClose, backgroundColor, setTransitionsEnabled = () => 0, onBack, ignoreBackdropClick = false, hideNavigation = true, direction = Direction.Left, }, ref) => {
|
|
79
82
|
const disableChildAnimations = useCallback(() => setTransitionsEnabled(false), [setTransitionsEnabled]);
|
|
80
83
|
const enableChildAnimations = useCallback(() => setTransitionsEnabled(true), [setTransitionsEnabled]);
|
|
81
84
|
const handleBackdropClick = useCallback(() => {
|
|
@@ -87,9 +90,9 @@ const DrawerContent = ({ isOpen, title, children, footer, big, onClose, backgrou
|
|
|
87
90
|
e.stopPropagation();
|
|
88
91
|
}, []);
|
|
89
92
|
return (React.createElement(TransitionInOut, { in: isOpen, appear: true, mountOnEnter: true, unmountOnExit: true, onEntering: disableChildAnimations, onEntered: enableChildAnimations, onExiting: disableChildAnimations },
|
|
90
|
-
React.createElement(Overlay, { onClick: handleBackdropClick },
|
|
91
|
-
React.createElement(TransitionSlide, { in: isOpen, fixed: true, reverseExit: true, appear: true, mountOnEnter: true, unmountOnExit: true },
|
|
92
|
-
React.createElement(Wrapper, { big: big, onClick: stopClickPropagation, backgroundColor: backgroundColor },
|
|
93
|
+
React.createElement(Overlay, { direction: direction, onClick: handleBackdropClick, ref: ref },
|
|
94
|
+
React.createElement(TransitionSlide, { in: isOpen, direction: direction, fixed: true, reverseExit: true, appear: true, mountOnEnter: true, unmountOnExit: true },
|
|
95
|
+
React.createElement(Wrapper, { big: big, onClick: stopClickPropagation, backgroundColor: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : "neutral.c00" },
|
|
93
96
|
React.createElement(Container, null,
|
|
94
97
|
React.createElement(Header, null,
|
|
95
98
|
!hideNavigation && (React.createElement(React.Fragment, null, onBack != null ? (React.createElement(Button, { onClick: onBack },
|
|
@@ -102,12 +105,17 @@ const DrawerContent = ({ isOpen, title, children, footer, big, onClose, backgrou
|
|
|
102
105
|
footer && (React.createElement(React.Fragment, null,
|
|
103
106
|
React.createElement(Divider, { variant: "light" }),
|
|
104
107
|
React.createElement(Footer, null, footer)))))))));
|
|
108
|
+
});
|
|
109
|
+
const Drawer = (_a, ref) => {
|
|
110
|
+
var { children, menuPortalTarget } = _a, sideProps = __rest(_a, ["children", "menuPortalTarget"]);
|
|
111
|
+
const $root = React.useMemo(() => menuPortalTarget === undefined && typeof document !== undefined
|
|
112
|
+
? document.querySelector("body")
|
|
113
|
+
: menuPortalTarget, [menuPortalTarget]);
|
|
114
|
+
if (!$root) {
|
|
115
|
+
return (React.createElement(DrawerContent, Object.assign({ ref: ref }, sideProps), children));
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return ReactDOM.createPortal(React.createElement(DrawerContent, Object.assign({ ref: ref }, sideProps), children), $root);
|
|
119
|
+
}
|
|
105
120
|
};
|
|
106
|
-
|
|
107
|
-
var { children } = _a, sideProps = __rest(_a, ["children"]);
|
|
108
|
-
const $root = React.useMemo(() => document.querySelector("#ll-side-root"), []);
|
|
109
|
-
if ($root === null)
|
|
110
|
-
throw new Error("side root cannot be found");
|
|
111
|
-
return ReactDOM.createPortal(React.createElement(DrawerContent, Object.assign({}, sideProps), children), $root);
|
|
112
|
-
};
|
|
113
|
-
export default Drawer;
|
|
121
|
+
export default React.forwardRef(Drawer);
|
|
@@ -3,6 +3,7 @@ import { BaseStyledProps } from "../../styled";
|
|
|
3
3
|
export interface PopinProps extends BaseStyledProps {
|
|
4
4
|
isOpen: boolean;
|
|
5
5
|
children: React.ReactNode;
|
|
6
|
+
menuPortalTarget?: Element | null;
|
|
6
7
|
}
|
|
7
8
|
export declare type PopinHeaderProps = BaseStyledProps & {
|
|
8
9
|
onClose?: () => void;
|
|
@@ -10,7 +11,7 @@ export declare type PopinHeaderProps = BaseStyledProps & {
|
|
|
10
11
|
children: React.ReactNode;
|
|
11
12
|
};
|
|
12
13
|
declare const PopinWrapper: {
|
|
13
|
-
({ children, ...popinProps }: PopinProps): React.ReactElement;
|
|
14
|
+
({ children, menuPortalTarget, ...popinProps }: PopinProps): React.ReactElement;
|
|
14
15
|
Header: ({ children, onClose, onBack, ...props }: PopinHeaderProps) => JSX.Element;
|
|
15
16
|
Body: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").OverflowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & {
|
|
16
17
|
columnGap?: string | number | undefined;
|
|
@@ -82,11 +82,16 @@ const Popin = (_a) => {
|
|
|
82
82
|
React.createElement(Wrapper, Object.assign({ width: width, height: height }, props), children)))));
|
|
83
83
|
};
|
|
84
84
|
const PopinWrapper = (_a) => {
|
|
85
|
-
var { children } = _a, popinProps = __rest(_a, ["children"]);
|
|
86
|
-
const $root = React.useMemo(() => document
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
var { children, menuPortalTarget } = _a, popinProps = __rest(_a, ["children", "menuPortalTarget"]);
|
|
86
|
+
const $root = React.useMemo(() => menuPortalTarget === undefined && typeof document !== undefined
|
|
87
|
+
? document.querySelector("body")
|
|
88
|
+
: menuPortalTarget, [menuPortalTarget]);
|
|
89
|
+
if (!$root) {
|
|
90
|
+
return React.createElement(Popin, Object.assign({}, popinProps), children);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
return ReactDOM.createPortal(React.createElement(Popin, Object.assign({}, popinProps), children), $root);
|
|
94
|
+
}
|
|
90
95
|
};
|
|
91
96
|
PopinWrapper.Header = PopinHeader;
|
|
92
97
|
PopinWrapper.Body = PopinBody;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FlexBoxProps as FlexProps } from "../../layout/Flex";
|
|
3
|
+
export declare type StepProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The label of the step.
|
|
6
|
+
*/
|
|
7
|
+
label: string;
|
|
8
|
+
/**
|
|
9
|
+
* A specific index, can be used to explicitely order steps.
|
|
10
|
+
*/
|
|
11
|
+
index?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Hides the step from the progress stepper.
|
|
14
|
+
*/
|
|
15
|
+
hidden?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The step contents.
|
|
18
|
+
*/
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
};
|
|
21
|
+
interface InnerProps {
|
|
22
|
+
/**
|
|
23
|
+
* The active index.
|
|
24
|
+
*/
|
|
25
|
+
activeIndex: number;
|
|
26
|
+
/**
|
|
27
|
+
* The total number of steps.
|
|
28
|
+
*/
|
|
29
|
+
stepsLength: number;
|
|
30
|
+
}
|
|
31
|
+
export interface Props<ExtraProps> {
|
|
32
|
+
/**
|
|
33
|
+
* The index of the active step.
|
|
34
|
+
*/
|
|
35
|
+
activeIndex: number;
|
|
36
|
+
/**
|
|
37
|
+
* An optional header displayed above the stepper.
|
|
38
|
+
*/
|
|
39
|
+
header?: (props: InnerProps & ExtraProps) => React.ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* An optional footer displayed below the body.
|
|
42
|
+
*/
|
|
43
|
+
footer?: (props: InnerProps & ExtraProps) => React.ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* Extra props that are passed to the header and footer render functions.
|
|
46
|
+
*/
|
|
47
|
+
extraProps?: ExtraProps;
|
|
48
|
+
/**
|
|
49
|
+
* Extra props that are passed to the container `Flex` element.
|
|
50
|
+
*/
|
|
51
|
+
extraContainerProps?: FlexProps;
|
|
52
|
+
/**
|
|
53
|
+
* Extra props that are passed to the stepper component.
|
|
54
|
+
*/
|
|
55
|
+
extraStepperProps?: FlexProps;
|
|
56
|
+
/**
|
|
57
|
+
* Extra props that are passed to the stepper `Flex` wrapper.
|
|
58
|
+
*/
|
|
59
|
+
extraStepperContainerProps?: FlexProps;
|
|
60
|
+
/**
|
|
61
|
+
* Custom rendering function to wrap children.
|
|
62
|
+
*/
|
|
63
|
+
renderChildren?: (args: {
|
|
64
|
+
children: React.ReactNode;
|
|
65
|
+
}) => React.ReactNode;
|
|
66
|
+
/**
|
|
67
|
+
/**
|
|
68
|
+
* A list of children representing each step of the flow.
|
|
69
|
+
*/
|
|
70
|
+
children: React.ReactElement<StepProps> | React.ReactElement<StepProps>[];
|
|
71
|
+
}
|
|
72
|
+
declare function FlowStepper<ExtraProps>({ activeIndex, header, footer, extraProps, extraContainerProps, extraStepperProps, extraStepperContainerProps, renderChildren, children, }: Props<ExtraProps>): JSX.Element;
|
|
73
|
+
declare namespace FlowStepper {
|
|
74
|
+
var Step: ({ children }: StepProps) => JSX.Element;
|
|
75
|
+
}
|
|
76
|
+
export default FlowStepper;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { isElement } from "react-is";
|
|
3
|
+
import Flex from "../../layout/Flex";
|
|
4
|
+
import { Stepper } from "..";
|
|
5
|
+
function FlowStepper({ activeIndex, header, footer, extraProps, extraContainerProps, extraStepperProps, extraStepperContainerProps, renderChildren, children, }) {
|
|
6
|
+
const { steps, innerContents } = React.Children.toArray(children).reduce((acc, child, idx) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const index = (_a = (isElement(child) && child.props.index)) !== null && _a !== void 0 ? _a : idx;
|
|
9
|
+
const label = isElement(child) && child.props.label;
|
|
10
|
+
const hidden = isElement(child) && child.props.hidden;
|
|
11
|
+
if (label && !hidden) {
|
|
12
|
+
acc.steps[index] = label;
|
|
13
|
+
}
|
|
14
|
+
if (index === activeIndex) {
|
|
15
|
+
acc.innerContents = child;
|
|
16
|
+
}
|
|
17
|
+
return acc;
|
|
18
|
+
}, {
|
|
19
|
+
steps: [],
|
|
20
|
+
innerContents: null,
|
|
21
|
+
});
|
|
22
|
+
return (React.createElement(Flex, Object.assign({ flex: 1, flexDirection: "column" }, extraContainerProps),
|
|
23
|
+
header &&
|
|
24
|
+
header(Object.assign(Object.assign({}, extraProps), { activeIndex, stepsLength: steps.length })),
|
|
25
|
+
React.createElement(Flex, Object.assign({ my: 8, justifyContent: "center" }, extraStepperContainerProps),
|
|
26
|
+
React.createElement(Stepper, Object.assign({ activeIndex: activeIndex, steps: steps, flex: 1 }, extraStepperProps))),
|
|
27
|
+
React.createElement(Flex, { flex: 1, flexDirection: "column", position: "relative" }, renderChildren ? renderChildren({ children: innerContents }) : innerContents),
|
|
28
|
+
footer &&
|
|
29
|
+
footer(Object.assign(Object.assign({}, extraProps), { activeIndex, stepsLength: steps.length }))));
|
|
30
|
+
}
|
|
31
|
+
function Step({ children }) {
|
|
32
|
+
return React.createElement(React.Fragment, null, children);
|
|
33
|
+
}
|
|
34
|
+
FlowStepper.Step = Step;
|
|
35
|
+
export default FlowStepper;
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { BorderProps, ColorProps, SpaceProps } from "styled-system";
|
|
3
|
+
/**
|
|
4
|
+
* The state of a progress bar step.
|
|
5
|
+
*/
|
|
6
|
+
export declare type StepState = "pending" | "current" | "completed" | "errored" | "disabled";
|
|
7
|
+
declare type LabelType = string | React.ComponentType<{
|
|
8
|
+
state: StepState;
|
|
9
|
+
}>;
|
|
3
10
|
export interface Props {
|
|
4
11
|
/**
|
|
5
12
|
* An array of labels that will determine the progress bar steps.
|
|
13
|
+
* A label is either a string or a component that will be rendered with the
|
|
14
|
+
* prop `state: "pending" | "current" | "completed" | "errored"`.
|
|
15
|
+
* A styled StepText component is exported to allow easy styling of such a custom label.
|
|
6
16
|
*/
|
|
7
|
-
steps:
|
|
17
|
+
steps: LabelType[];
|
|
8
18
|
/**
|
|
9
19
|
* Index of the active step, starting at zero and defaulting to 0 if omitted.
|
|
10
20
|
*/
|
|
@@ -13,20 +23,22 @@ export interface Props {
|
|
|
13
23
|
* If true the current step is considered as a failure.
|
|
14
24
|
*/
|
|
15
25
|
errored?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Steps with indexes contained inside the array will be shown as disabled.
|
|
28
|
+
*/
|
|
29
|
+
disabledIndexes?: number[];
|
|
16
30
|
}
|
|
17
|
-
/**
|
|
18
|
-
* The state of a progress bar step.
|
|
19
|
-
*/
|
|
20
|
-
declare type StepState = "pending" | "current" | "completed" | "errored";
|
|
21
31
|
export declare type StepProps = {
|
|
22
32
|
/**
|
|
23
33
|
* State of the step.
|
|
24
34
|
*/
|
|
25
35
|
state: StepState;
|
|
26
36
|
/**
|
|
27
|
-
* The label to display.
|
|
37
|
+
* The label to display. To display more than text, this can be a component that will be rendered with the
|
|
38
|
+
* prop `state: "pending" | "current" | "completed" | "errored" | "disabled"`.
|
|
39
|
+
* A styled StepText component is exported to allow easy styling of such a custom Label
|
|
28
40
|
*/
|
|
29
|
-
label:
|
|
41
|
+
label: LabelType;
|
|
30
42
|
/**
|
|
31
43
|
* If true, hides the left "separator" bar that bridges the gap between the wider separator and the item.
|
|
32
44
|
*/
|
|
@@ -48,9 +60,13 @@ export declare const Item: {
|
|
|
48
60
|
backgroundColor: string;
|
|
49
61
|
} & ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, "backgroundColor">;
|
|
50
62
|
Completed: () => JSX.Element;
|
|
63
|
+
Disabled: () => JSX.Element;
|
|
51
64
|
Errored: () => JSX.Element;
|
|
52
65
|
};
|
|
66
|
+
export declare const StepText: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, import("../../../asorted/Text").TextProps & {
|
|
67
|
+
state: StepState;
|
|
68
|
+
}, keyof import("../../../asorted/Text").TextProps>;
|
|
53
69
|
export declare const Step: React.NamedExoticComponent<StepProps>;
|
|
54
|
-
declare function
|
|
55
|
-
declare const _default: React.MemoExoticComponent<typeof
|
|
70
|
+
declare function Stepper({ steps, activeIndex, errored, disabledIndexes, ...extraProps }: Props): JSX.Element;
|
|
71
|
+
declare const _default: React.MemoExoticComponent<typeof Stepper>;
|
|
56
72
|
export default _default;
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
|
|
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, { memo, Fragment } from "react";
|
|
2
13
|
import styled from "styled-components";
|
|
3
14
|
import { border, color, space } from "styled-system";
|
|
4
|
-
import
|
|
5
|
-
import CloseMedium from "@ledgerhq/icons-ui/react/CloseMedium";
|
|
15
|
+
import { Icons } from "../../../../index";
|
|
6
16
|
import Text from "../../../asorted/Text";
|
|
7
17
|
import Flex from "../../../layout/Flex";
|
|
8
18
|
export const Item = {
|
|
@@ -39,15 +49,19 @@ export const Item = {
|
|
|
39
49
|
border-radius: ${(p) => p.theme.space[2]}px;
|
|
40
50
|
${color}
|
|
41
51
|
`,
|
|
42
|
-
Completed: () => React.createElement(
|
|
43
|
-
|
|
52
|
+
Completed: () => React.createElement(Icons.CheckAloneMedium, { size: 16 }),
|
|
53
|
+
Disabled: () => React.createElement(Icons.CloseMedium, { size: 16 }),
|
|
54
|
+
Errored: () => React.createElement(Icons.CloseMedium, { size: 16 }),
|
|
44
55
|
};
|
|
45
|
-
const StepText = styled(Text) `
|
|
56
|
+
export const StepText = styled(Text) `
|
|
46
57
|
color: ${(p) => {
|
|
47
|
-
if (p.errored) {
|
|
58
|
+
if (p.state === "errored") {
|
|
48
59
|
return p.theme.colors.error.c100;
|
|
49
60
|
}
|
|
50
|
-
if (p.
|
|
61
|
+
if (p.state === "disabled") {
|
|
62
|
+
return p.theme.colors.neutral.c50;
|
|
63
|
+
}
|
|
64
|
+
if (p.state === "pending") {
|
|
51
65
|
return p.theme.colors.neutral.c70;
|
|
52
66
|
}
|
|
53
67
|
return p.theme.colors.neutral.c100;
|
|
@@ -74,19 +88,23 @@ const stepContentsByState = {
|
|
|
74
88
|
React.createElement(Item.Completed, null))),
|
|
75
89
|
errored: (React.createElement(Item.Container, { color: "error.c100", backgroundColor: "warning.c30", borderRadius: "8px" },
|
|
76
90
|
React.createElement(Item.Errored, null))),
|
|
91
|
+
disabled: (React.createElement(Item.Container, { color: "neutral.c50" },
|
|
92
|
+
React.createElement(Item.Disabled, null))),
|
|
77
93
|
};
|
|
78
|
-
export const Step = memo(function Step({ state, label, hideLeftSeparator, nextState, }) {
|
|
94
|
+
export const Step = memo(function Step({ state, label: Label, hideLeftSeparator, nextState, }) {
|
|
79
95
|
const inactive = state === "pending";
|
|
80
|
-
const nextInactive =
|
|
81
|
-
const errored = state === "errored";
|
|
96
|
+
const nextInactive = state === "pending";
|
|
82
97
|
return (React.createElement(Flex, { flexDirection: "column", alignItems: "center" },
|
|
83
98
|
React.createElement(Item.Spacer, { mb: 5 },
|
|
84
99
|
(!hideLeftSeparator && React.createElement(Separator.Item, { inactive: inactive, position: "left" })) || (React.createElement(Flex, { flex: "1" })),
|
|
85
100
|
stepContentsByState[state],
|
|
86
101
|
(nextState && React.createElement(Separator.Item, { inactive: nextInactive, position: "right" })) || (React.createElement(Flex, { flex: "1" }))),
|
|
87
|
-
React.createElement(StepText, {
|
|
102
|
+
typeof Label === "string" ? (React.createElement(StepText, { state: state, variant: "small" }, Label)) : (React.createElement(Label, { state: state }))));
|
|
88
103
|
});
|
|
89
|
-
function getState(activeIndex, index, errored) {
|
|
104
|
+
function getState(activeIndex, index, errored, disabled) {
|
|
105
|
+
if (disabled) {
|
|
106
|
+
return "disabled";
|
|
107
|
+
}
|
|
90
108
|
if (activeIndex < index) {
|
|
91
109
|
return "pending";
|
|
92
110
|
}
|
|
@@ -95,13 +113,14 @@ function getState(activeIndex, index, errored) {
|
|
|
95
113
|
}
|
|
96
114
|
return "completed";
|
|
97
115
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
100
|
-
|
|
116
|
+
function Stepper(_a) {
|
|
117
|
+
var { steps, activeIndex = 0, errored, disabledIndexes } = _a, extraProps = __rest(_a, ["steps", "activeIndex", "errored", "disabledIndexes"]);
|
|
118
|
+
return (React.createElement(Flex, Object.assign({ flexWrap: "nowrap", justifyContent: "space-between" }, extraProps), steps.map((step, idx) => {
|
|
119
|
+
const state = getState(activeIndex, idx, errored, disabledIndexes === null || disabledIndexes === void 0 ? void 0 : disabledIndexes.includes(idx));
|
|
101
120
|
const nextState = idx < steps.length - 1 ? getState(activeIndex, idx + 1) : undefined;
|
|
102
|
-
return (React.createElement(
|
|
121
|
+
return (React.createElement(Fragment, { key: idx },
|
|
103
122
|
idx > 0 && React.createElement(Separator.Step, { inactive: state === "pending" }),
|
|
104
123
|
React.createElement(Step, { label: step, state: state, nextState: nextState, hideLeftSeparator: idx === 0 })));
|
|
105
124
|
})));
|
|
106
125
|
}
|
|
107
|
-
export default memo(
|
|
126
|
+
export default memo(Stepper);
|
|
@@ -11,24 +11,26 @@ const Nav = styled(Flex) `
|
|
|
11
11
|
padding: ${(p) => `${p.theme.space[19]}px ${p.theme.space[5]}px 0`};
|
|
12
12
|
row-gap: 1.5rem;
|
|
13
13
|
height: 100vh;
|
|
14
|
-
|
|
14
|
+
width: 14.875rem;
|
|
15
15
|
color: ${(props) => props.theme.colors.neutral.c100};
|
|
16
16
|
border-right: 1px solid ${(props) => props.theme.colors.neutral.c40};
|
|
17
17
|
background-color: ${(props) => props.theme.colors.background.main};
|
|
18
|
-
transition:
|
|
19
|
-
will-change:
|
|
18
|
+
transition: width 200ms;
|
|
19
|
+
will-change: width;
|
|
20
|
+
flex-shrink: 0;
|
|
21
|
+
z-index: ${(p) => p.theme.zIndexes[2]};
|
|
20
22
|
|
|
21
23
|
&.nav-enter {
|
|
22
|
-
|
|
24
|
+
width: ${(p) => p.theme.space[19]}px;
|
|
23
25
|
}
|
|
24
26
|
&.nav-enter-done {
|
|
25
|
-
|
|
27
|
+
width: 14.875rem;
|
|
26
28
|
}
|
|
27
29
|
&.nav-exit {
|
|
28
|
-
|
|
30
|
+
width: 14.875rem;
|
|
29
31
|
}
|
|
30
32
|
&.nav-exit-done {
|
|
31
|
-
|
|
33
|
+
width: ${(p) => `${p.theme.space[19]}px`};
|
|
32
34
|
}
|
|
33
35
|
`;
|
|
34
36
|
const TransparentMouseZone = styled.div `
|
package/package.json
CHANGED