@ledgerhq/react-ui 0.7.0 → 0.7.1
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/Divider/index.d.ts +1 -1
- package/components/cta/Button/index.d.ts +3 -2
- package/components/cta/Button/index.js +20 -14
- package/components/form/Dropdown/index.js +7 -7
- package/components/form/DropdownGeneric/index.d.ts +36 -0
- package/components/form/DropdownGeneric/index.js +95 -0
- package/components/form/SelectInput/MenuList.js +2 -1
- package/components/form/index.d.ts +1 -0
- package/components/form/index.js +1 -0
- package/components/layout/Drawer/index.d.ts +6 -0
- package/components/layout/Drawer/index.js +7 -23
- package/components/message/Log/index.d.ts +5 -2
- package/components/message/Log/index.js +3 -4
- package/components/navigation/FlowStepper/index.d.ts +2 -1
- package/components/navigation/progress/Stepper/index.d.ts +2 -1
- package/package.json +4 -3
- package/styles/InvertTheme.d.ts +4 -1
- package/styles/InvertTheme.js +4 -4
|
@@ -15,6 +15,7 @@ interface BaseProps extends BaseStyledProps, BordersProps {
|
|
|
15
15
|
disabled?: boolean;
|
|
16
16
|
}
|
|
17
17
|
export interface ButtonProps extends BaseProps, React.RefAttributes<HTMLButtonElement> {
|
|
18
|
+
iconName?: string;
|
|
18
19
|
Icon?: React.ComponentType<{
|
|
19
20
|
size: number;
|
|
20
21
|
color?: string;
|
|
@@ -30,11 +31,11 @@ export declare const Base: import("styled-components").StyledComponent<"button",
|
|
|
30
31
|
fontSize: number;
|
|
31
32
|
} & BaseProps, "fontFamily" | "fontSize">;
|
|
32
33
|
declare const ButtonWithRef: {
|
|
33
|
-
({ Icon, iconPosition, iconSize, children, onClick, ...props }: ButtonProps, ref?: React.ForwardedRef<HTMLButtonElement> | undefined): React.ReactElement;
|
|
34
|
+
({ Icon, iconPosition, iconSize, children, onClick, iconName, ...props }: ButtonProps, ref?: React.ForwardedRef<HTMLButtonElement> | undefined): React.ReactElement;
|
|
34
35
|
Unstyled: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
|
|
35
36
|
Expand: React.ForwardRefExoticComponent<Pick<ButtonProps & {
|
|
36
37
|
onToggle?: ((arg0: boolean) => void) | undefined;
|
|
37
|
-
}, "overflow" | "p" | "style" | "key" | "color" | "children" | "onClick" | "variant" | "size" | "rowGap" | "alignContent" | "alignItems" | "alignSelf" | "backgroundColor" | "borderBottomColor" | "borderBottomLeftRadius" | "borderBottomRightRadius" | "borderBottomStyle" | "borderBottomWidth" | "borderLeftColor" | "borderLeftStyle" | "borderLeftWidth" | "borderRightColor" | "borderRightStyle" | "borderRightWidth" | "borderTopColor" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopStyle" | "borderTopWidth" | "bottom" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontSize" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "opacity" | "order" | "overflowX" | "overflowY" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "top" | "verticalAlign" | "width" | "zIndex" | "border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderStyle" | "borderTop" | "borderWidth" | "flex" | "margin" | "outline" | "padding" | "disabled" | "onToggle" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "bg" | "borderX" | "borderY" | "Icon" | "iconSize" | "ff" | "iconPosition" | "iconButton"> & React.RefAttributes<HTMLButtonElement>>;
|
|
38
|
+
}, "overflow" | "p" | "style" | "key" | "color" | "children" | "onClick" | "variant" | "size" | "rowGap" | "alignContent" | "alignItems" | "alignSelf" | "backgroundColor" | "borderBottomColor" | "borderBottomLeftRadius" | "borderBottomRightRadius" | "borderBottomStyle" | "borderBottomWidth" | "borderLeftColor" | "borderLeftStyle" | "borderLeftWidth" | "borderRightColor" | "borderRightStyle" | "borderRightWidth" | "borderTopColor" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopStyle" | "borderTopWidth" | "bottom" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontSize" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "opacity" | "order" | "overflowX" | "overflowY" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "top" | "verticalAlign" | "width" | "zIndex" | "border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderStyle" | "borderTop" | "borderWidth" | "flex" | "margin" | "outline" | "padding" | "disabled" | "onToggle" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "bg" | "borderX" | "borderY" | "Icon" | "iconSize" | "ff" | "iconPosition" | "iconButton" | "iconName"> & React.RefAttributes<HTMLButtonElement>>;
|
|
38
39
|
};
|
|
39
40
|
export declare type ButtonExpandProps = React.PropsWithChildren<ButtonProps & {
|
|
40
41
|
onToggle?: (arg0: boolean) => void;
|
|
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React, { useState } from "react";
|
|
12
|
+
import React, { useState, useMemo } from "react";
|
|
13
13
|
import styled, { css } from "styled-components";
|
|
14
14
|
import baseStyled from "../../styled";
|
|
15
15
|
import { fontSize, border, compose } from "styled-system";
|
|
@@ -17,6 +17,7 @@ import fontFamily from "../../../styles/styled/fontFamily";
|
|
|
17
17
|
import { fontSizes } from "../../../styles/theme";
|
|
18
18
|
import { rgba } from "../../../styles/helpers";
|
|
19
19
|
import ChevronBottom from "@ledgerhq/icons-ui/react/ChevronBottomRegular";
|
|
20
|
+
import IconComponent from "../../asorted/Icon";
|
|
20
21
|
const IconContainer = styled.div `
|
|
21
22
|
display: inline-block;
|
|
22
23
|
${(p) => `${p.iconPosition === "left" ? "margin-right" : "margin-left"}: ${p.theme.space[4]}px;`}
|
|
@@ -27,12 +28,12 @@ const getVariantColors = (p) => ({
|
|
|
27
28
|
outline: `
|
|
28
29
|
border-color: ${p.theme.colors.neutral.c100};
|
|
29
30
|
color: ${p.theme.colors.neutral.c100};
|
|
30
|
-
background-color:
|
|
31
|
+
background-color: transparent;
|
|
31
32
|
&:hover, &:focus {
|
|
32
|
-
background-color: ${p.theme.colors.neutral.
|
|
33
|
+
background-color: ${rgba(p.theme.colors.neutral.c100, 0.03)};
|
|
33
34
|
}
|
|
34
35
|
&:active {
|
|
35
|
-
background-color: ${p.theme.colors.neutral.
|
|
36
|
+
background-color: ${rgba(p.theme.colors.neutral.c100, 0.05)};
|
|
36
37
|
}
|
|
37
38
|
`,
|
|
38
39
|
filled: `
|
|
@@ -63,12 +64,12 @@ const getVariantColors = (p) => ({
|
|
|
63
64
|
outline: `
|
|
64
65
|
border-color: ${p.theme.colors.error.c100};
|
|
65
66
|
color: ${p.theme.colors.error.c100};
|
|
66
|
-
background-color:
|
|
67
|
+
background-color: transparent;
|
|
67
68
|
&:hover {
|
|
68
|
-
background-color: ${p.theme.colors.error.
|
|
69
|
+
background-color: ${rgba(p.theme.colors.error.c100, 0.02)};
|
|
69
70
|
}
|
|
70
71
|
&:active {
|
|
71
|
-
background-color: ${p.theme.colors.error.
|
|
72
|
+
background-color: ${rgba(p.theme.colors.error.c100, 0.05)};
|
|
72
73
|
}
|
|
73
74
|
`,
|
|
74
75
|
filled: `
|
|
@@ -83,12 +84,12 @@ const getVariantColors = (p) => ({
|
|
|
83
84
|
outline: `
|
|
84
85
|
border-color: ${p.theme.colors.primary.c80};
|
|
85
86
|
color: ${p.theme.colors.primary.c80};
|
|
86
|
-
background-color:
|
|
87
|
+
background-color: transparent;
|
|
87
88
|
&:hover {
|
|
88
|
-
background-color: ${p.theme.colors.primary.
|
|
89
|
+
background-color: ${rgba(p.theme.colors.primary.c100, 0.02)};
|
|
89
90
|
}
|
|
90
91
|
&:active {
|
|
91
|
-
background-color: ${p.theme.colors.primary.
|
|
92
|
+
background-color: ${rgba(p.theme.colors.primary.c100, 0.05)};
|
|
92
93
|
}
|
|
93
94
|
`,
|
|
94
95
|
filled: `
|
|
@@ -103,7 +104,7 @@ const getVariantColors = (p) => ({
|
|
|
103
104
|
outline: `
|
|
104
105
|
border-color: ${p.theme.colors.neutral.c50};
|
|
105
106
|
color: ${p.theme.colors.neutral.c50};
|
|
106
|
-
background-color:
|
|
107
|
+
background-color: transparent;
|
|
107
108
|
`,
|
|
108
109
|
filled: `
|
|
109
110
|
color: ${p.theme.colors.neutral.c50};
|
|
@@ -156,6 +157,9 @@ export const Base = baseStyled.button.attrs((p) => {
|
|
|
156
157
|
&:active {
|
|
157
158
|
box-shadow: 0 0 0 4px ${(p) => rgba(p.theme.colors.primary.c60, 0.4)};
|
|
158
159
|
}
|
|
160
|
+
&:focus {
|
|
161
|
+
box-shadow: 0 0 0 2px ${(p) => rgba(p.theme.colors.primary.c60, 0.4)};
|
|
162
|
+
}
|
|
159
163
|
|
|
160
164
|
${(p) => {
|
|
161
165
|
var _a;
|
|
@@ -194,11 +198,13 @@ export const Base = baseStyled.button.attrs((p) => {
|
|
|
194
198
|
const ContentContainer = styled.div ``;
|
|
195
199
|
const Button = (_a, ref) => {
|
|
196
200
|
var _b;
|
|
197
|
-
var { Icon, iconPosition = "right", iconSize = 16, children, onClick } = _a, props = __rest(_a, ["Icon", "iconPosition", "iconSize", "children", "onClick"]);
|
|
201
|
+
var { Icon, iconPosition = "right", iconSize = 16, children, onClick, iconName } = _a, props = __rest(_a, ["Icon", "iconPosition", "iconSize", "children", "onClick", "iconName"]);
|
|
202
|
+
const iconNodeSize = iconSize || fontSizes[(_b = props.fontSize) !== null && _b !== void 0 ? _b : 4];
|
|
203
|
+
const IconNode = useMemo(() => (iconName && React.createElement(IconComponent, { name: iconName, size: iconNodeSize })) ||
|
|
204
|
+
(Icon && React.createElement(Icon, { size: iconNodeSize })), [iconName, iconNodeSize, Icon]);
|
|
198
205
|
return (React.createElement(Base, Object.assign({}, props, { ref: ref, iconButton: !(Icon == null) && !children, onClick: onClick }),
|
|
199
206
|
iconPosition === "right" ? React.createElement(ContentContainer, null, children) : null,
|
|
200
|
-
|
|
201
|
-
React.createElement(Icon, { size: iconSize || fontSizes[(_b = props.fontSize) !== null && _b !== void 0 ? _b : 4] }))) : null,
|
|
207
|
+
IconNode && React.createElement(IconContainer, { iconPosition: iconPosition }, IconNode),
|
|
202
208
|
iconPosition === "left" ? React.createElement(ContentContainer, null, children) : null));
|
|
203
209
|
};
|
|
204
210
|
const ButtonWithRef = React.forwardRef(Button);
|
|
@@ -14,23 +14,23 @@ import { components } from "react-select";
|
|
|
14
14
|
import { useTheme } from "styled-components";
|
|
15
15
|
import SelectInput from "../../form/SelectInput";
|
|
16
16
|
import Text from "../../asorted/Text";
|
|
17
|
+
import { Icons } from "../../../";
|
|
17
18
|
import { ValueContainer } from "../../form/SelectInput/ValueContainer";
|
|
18
|
-
import { ChevronBottomMedium, ChevronTopMedium } from "@ledgerhq/icons-ui/react";
|
|
19
19
|
import FlexBox from "../../layout/Flex";
|
|
20
20
|
function DropdownControl(props) {
|
|
21
21
|
const { selectProps, children } = props;
|
|
22
22
|
const { label } = selectProps;
|
|
23
23
|
return (React.createElement(components.Control, Object.assign({}, props),
|
|
24
|
-
React.createElement(Text, {
|
|
24
|
+
React.createElement(Text, { variant: "paragraph", fontWeight: "medium", color: "neutral.c80", mr: 2 }, label),
|
|
25
25
|
children));
|
|
26
26
|
}
|
|
27
27
|
function DropdownValueContainer(props) {
|
|
28
|
-
const
|
|
29
|
-
return (React.createElement(ValueContainer, Object.assign({}, props, { render: () => (React.createElement(FlexBox,
|
|
30
|
-
React.createElement(Text, {
|
|
28
|
+
const isOpen = props.selectProps.menuIsOpen;
|
|
29
|
+
return (React.createElement(ValueContainer, Object.assign({}, props, { render: () => (React.createElement(FlexBox, { alignItems: "center" },
|
|
30
|
+
React.createElement(Text, { variant: "paragraph", fontWeight: "medium", mr: 2 },
|
|
31
31
|
React.createElement(FlexBox, null, props.children)),
|
|
32
|
-
React.createElement(FlexBox, { alignItems: "center" },
|
|
33
|
-
React.createElement(
|
|
32
|
+
React.createElement(FlexBox, { alignItems: "center", style: { transform: isOpen ? "rotate(180deg)" : "" } },
|
|
33
|
+
React.createElement(Icons.DropdownMedium, { size: 20 })))) })));
|
|
34
34
|
}
|
|
35
35
|
function DropdownIndicatorsContainer() {
|
|
36
36
|
return null;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare const placements: readonly ["bottom-start", "bottom", "bottom-end"];
|
|
3
|
+
declare type Placement = typeof placements[number];
|
|
4
|
+
export declare type Props = {
|
|
5
|
+
/**
|
|
6
|
+
* Label of the dropdown button, displayed before the dropdown icon.
|
|
7
|
+
*/
|
|
8
|
+
label: string | React.ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Controls whether the dropdown can be open.
|
|
11
|
+
* Defaults to false.
|
|
12
|
+
*/
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Controls whether the dropdown will close on a click event happening outside of this component.
|
|
16
|
+
* Defaults to true.
|
|
17
|
+
*/
|
|
18
|
+
closeOnClickOutside?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Controls whether the dropdown will close on a click event happening inside the dropdown.
|
|
21
|
+
* Defaults to false.
|
|
22
|
+
*/
|
|
23
|
+
closeOnClickInside?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Content of the dropdown.
|
|
26
|
+
*/
|
|
27
|
+
children: React.ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* Horizontal position of the dropdown relative to the dropdown button.
|
|
30
|
+
* Will automatically adjust to the document to avoid overflowing.
|
|
31
|
+
* Defaults to "bottom".
|
|
32
|
+
*/
|
|
33
|
+
placement?: Placement;
|
|
34
|
+
};
|
|
35
|
+
declare const DropdownGeneric: ({ label, closeOnClickOutside, closeOnClickInside, disabled, placement, children, }: Props) => JSX.Element;
|
|
36
|
+
export default DropdownGeneric;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { useFloating, getScrollParents, shift, flip } from "@floating-ui/react-dom";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { Icons } from "../../../";
|
|
5
|
+
import Flex from "../../layout/Flex";
|
|
6
|
+
import Box from "../../layout/Flex";
|
|
7
|
+
import Text from "../../asorted/Text";
|
|
8
|
+
const ButtonContainer = styled(Box).attrs({
|
|
9
|
+
flexDirection: "row",
|
|
10
|
+
width: "auto",
|
|
11
|
+
alignItems: "center",
|
|
12
|
+
height: "36px",
|
|
13
|
+
}) `
|
|
14
|
+
cursor: ${(p) => !p.disabled && "pointer"};
|
|
15
|
+
> :last-child {
|
|
16
|
+
/* targeting the dropdown icon */
|
|
17
|
+
${(p) => p.opened && "transform: rotate(180deg);"}
|
|
18
|
+
margin: 0px ${(p) => p.theme.space[3]}px;
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
const DropdownContainer = styled(Flex).attrs(({ theme }) => {
|
|
22
|
+
const isLight = theme.colors.type === "light";
|
|
23
|
+
return {
|
|
24
|
+
display: "flex",
|
|
25
|
+
flexDirection: "column",
|
|
26
|
+
padding: 3,
|
|
27
|
+
border: `1px solid ${theme.colors.neutral[isLight ? "c20" : "c30"]}`,
|
|
28
|
+
borderRadius: "8px",
|
|
29
|
+
backgroundColor: isLight ? "neutral.c00" : "neutral.c20",
|
|
30
|
+
color: theme.colors.neutral.c80,
|
|
31
|
+
};
|
|
32
|
+
}) `
|
|
33
|
+
box-shadow: 0px 6px 12px rgba(0, 0, 0, ${(p) => (p.theme.colors.type === "light" ? 0.04 : 0.08)});
|
|
34
|
+
`;
|
|
35
|
+
export const placements = ["bottom-start", "bottom", "bottom-end"];
|
|
36
|
+
const DropdownGeneric = ({ label, closeOnClickOutside = true, closeOnClickInside = false, disabled = false, placement = "bottom", children, }) => {
|
|
37
|
+
const divRef = useRef(null);
|
|
38
|
+
const [opened, setOpened] = useState(false);
|
|
39
|
+
const handleClickButton = useCallback(() => {
|
|
40
|
+
if (!disabled)
|
|
41
|
+
setOpened(!opened);
|
|
42
|
+
}, [opened, disabled]);
|
|
43
|
+
const handleClickInside = useCallback(() => {
|
|
44
|
+
if (closeOnClickInside)
|
|
45
|
+
setOpened(false);
|
|
46
|
+
}, [setOpened, closeOnClickInside]);
|
|
47
|
+
const { x, y, reference, floating, strategy, update, refs } = useFloating({
|
|
48
|
+
placement: placements.includes(placement) ? placement : "bottom",
|
|
49
|
+
middleware: [shift(), flip()],
|
|
50
|
+
});
|
|
51
|
+
const handleResizeOrScroll = useCallback(() => {
|
|
52
|
+
if (opened && !disabled)
|
|
53
|
+
update();
|
|
54
|
+
}, [opened, disabled, update]);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (!refs.reference.current || !refs.floating.current) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const parents = [
|
|
60
|
+
...getScrollParents(refs.reference.current),
|
|
61
|
+
...getScrollParents(refs.floating.current),
|
|
62
|
+
];
|
|
63
|
+
parents.forEach((parent) => {
|
|
64
|
+
parent.addEventListener("scroll", handleResizeOrScroll);
|
|
65
|
+
parent.addEventListener("resize", handleResizeOrScroll);
|
|
66
|
+
});
|
|
67
|
+
return () => {
|
|
68
|
+
parents.forEach((parent) => {
|
|
69
|
+
parent.removeEventListener("scroll", handleResizeOrScroll);
|
|
70
|
+
parent.removeEventListener("resize", handleResizeOrScroll);
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
}, [opened, disabled, refs.reference, refs.floating, handleResizeOrScroll]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
function handleClickOutside(event) {
|
|
76
|
+
if (closeOnClickOutside &&
|
|
77
|
+
opened &&
|
|
78
|
+
divRef.current &&
|
|
79
|
+
!divRef.current.contains(event.target)) {
|
|
80
|
+
setOpened(false);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
84
|
+
return () => {
|
|
85
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
86
|
+
};
|
|
87
|
+
}, [closeOnClickOutside, opened, setOpened, divRef]);
|
|
88
|
+
const color = disabled ? "neutral.c50" : "neutral.c100";
|
|
89
|
+
return (React.createElement("div", { ref: divRef },
|
|
90
|
+
React.createElement(ButtonContainer, { ref: reference, onClick: handleClickButton, disabled: disabled, opened: opened && !disabled },
|
|
91
|
+
React.createElement(Text, { variant: "paragraph", fontWeight: "medium", color: color }, label),
|
|
92
|
+
React.createElement(Icons.DropdownMedium, { size: 20, color: color })),
|
|
93
|
+
opened && !disabled && (React.createElement(DropdownContainer, { ref: floating, style: { overflow: "visible", position: strategy, top: y !== null && y !== void 0 ? y : "", left: x !== null && x !== void 0 ? x : "" }, onClick: handleClickInside }, children))));
|
|
94
|
+
};
|
|
95
|
+
export default DropdownGeneric;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { components } from "react-select";
|
|
3
3
|
export function getStyles(theme) {
|
|
4
|
-
|
|
4
|
+
const isLight = theme.colors.type === "light";
|
|
5
|
+
return (provided) => (Object.assign(Object.assign({}, provided), { display: "flex", flexDirection: "column", gap: theme.space[2], padding: theme.space[3], border: `1px solid ${theme.colors.neutral[isLight ? "c20" : "c30"]}`, borderRadius: "8px", boxShadow: `0px 6px 12px rgba(0, 0, 0, ${isLight ? 0.04 : 0.08})`, background: theme.colors.neutral[isLight ? "c00" : "c20"], color: theme.colors.neutral.c80 }));
|
|
5
6
|
}
|
|
6
7
|
export function MenuList(props) {
|
|
7
8
|
return React.createElement(components.MenuList, Object.assign({}, props), props.children);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as Input } from "./BaseInput";
|
|
2
2
|
export { default as Checkbox } from "./Checkbox";
|
|
3
3
|
export { default as Dropdown } from "./Dropdown";
|
|
4
|
+
export { default as DropdownGeneric } from "./DropdownGeneric";
|
|
4
5
|
export { default as LegendInput } from "./LegendInput";
|
|
5
6
|
export { default as NumberInput } from "./NumberInput";
|
|
6
7
|
export { default as QrCodeInput } from "./QrCodeInput";
|
package/components/form/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as Input } from "./BaseInput";
|
|
2
2
|
export { default as Checkbox } from "./Checkbox";
|
|
3
3
|
export { default as Dropdown } from "./Dropdown";
|
|
4
|
+
export { default as DropdownGeneric } from "./DropdownGeneric";
|
|
4
5
|
export { default as LegendInput } from "./LegendInput";
|
|
5
6
|
export { default as NumberInput } from "./NumberInput";
|
|
6
7
|
export { default as QrCodeInput } from "./QrCodeInput";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { FlexBoxProps } from "../Flex";
|
|
3
|
+
import { Props as DividerProps } from "../../asorted/Divider";
|
|
2
4
|
export declare enum Direction {
|
|
3
5
|
Left = "left",
|
|
4
6
|
Right = "right"
|
|
@@ -17,6 +19,10 @@ export interface DrawerProps {
|
|
|
17
19
|
hideNavigation?: boolean;
|
|
18
20
|
menuPortalTarget?: Element | null;
|
|
19
21
|
direction?: Direction;
|
|
22
|
+
extraContainerProps?: Partial<FlexBoxProps>;
|
|
23
|
+
extraHeaderProps?: Partial<FlexBoxProps>;
|
|
24
|
+
extraFooterProps?: Partial<FlexBoxProps>;
|
|
25
|
+
extraFooterDividerProps?: Partial<DividerProps>;
|
|
20
26
|
}
|
|
21
27
|
declare const _default: React.ForwardRefExoticComponent<DrawerProps & React.RefAttributes<HTMLDivElement>>;
|
|
22
28
|
export default _default;
|
|
@@ -29,16 +29,6 @@ const Container = styled(FlexBox) `
|
|
|
29
29
|
height: 100%;
|
|
30
30
|
flex-direction: column;
|
|
31
31
|
`;
|
|
32
|
-
const Header = styled(FlexBox) `
|
|
33
|
-
justify-content: space-between;
|
|
34
|
-
align-items: center;
|
|
35
|
-
padding: ${(p) => p.theme.space[12]}px;
|
|
36
|
-
padding-bottom: ${(p) => p.theme.space[10]}px;
|
|
37
|
-
`;
|
|
38
|
-
const Footer = styled(FlexBox) `
|
|
39
|
-
align-items: center;
|
|
40
|
-
padding: ${(p) => p.theme.space[8]}px ${(p) => p.theme.space[12]}px;
|
|
41
|
-
`;
|
|
42
32
|
const Wrapper = styled(FlexBox) `
|
|
43
33
|
height: 100%;
|
|
44
34
|
width: ${(p) => p.big ? p.theme.sizes.drawer.side.big.width : p.theme.sizes.drawer.side.small.width}px;
|
|
@@ -56,15 +46,9 @@ const Overlay = styled.div `
|
|
|
56
46
|
width: 100vw;
|
|
57
47
|
height: 100vh;
|
|
58
48
|
z-index: 999;
|
|
59
|
-
background-color: ${(p) => p.theme.colors.
|
|
49
|
+
background-color: ${(p) => p.theme.colors.constant.overlay};
|
|
60
50
|
`;
|
|
61
|
-
const ScrollWrapper = styled
|
|
62
|
-
overflow: scroll;
|
|
63
|
-
position: relative;
|
|
64
|
-
padding: ${(p) => p.theme.space[12]}px;
|
|
65
|
-
padding-top: 0px;
|
|
66
|
-
flex: 1;
|
|
67
|
-
|
|
51
|
+
const ScrollWrapper = styled(FlexBox) `
|
|
68
52
|
&::-webkit-scrollbar {
|
|
69
53
|
display: none;
|
|
70
54
|
}
|
|
@@ -78,7 +62,7 @@ const Button = styled.button `
|
|
|
78
62
|
cursor: pointer;
|
|
79
63
|
color: ${(p) => p.theme.colors.neutral.c100};
|
|
80
64
|
`;
|
|
81
|
-
const DrawerContent = React.forwardRef(({ isOpen, title, children, footer, big, onClose, backgroundColor, setTransitionsEnabled = () => 0, onBack, ignoreBackdropClick = false, hideNavigation = true, direction = Direction.Left, }, ref) => {
|
|
65
|
+
const DrawerContent = React.forwardRef(({ isOpen, title, children, footer, big, onClose, backgroundColor, setTransitionsEnabled = () => 0, onBack, extraContainerProps, extraHeaderProps, extraFooterProps, extraFooterDividerProps, ignoreBackdropClick = false, hideNavigation = true, direction = Direction.Left, }, ref) => {
|
|
82
66
|
const disableChildAnimations = useCallback(() => setTransitionsEnabled(false), [setTransitionsEnabled]);
|
|
83
67
|
const enableChildAnimations = useCallback(() => setTransitionsEnabled(true), [setTransitionsEnabled]);
|
|
84
68
|
const handleBackdropClick = useCallback(() => {
|
|
@@ -94,17 +78,17 @@ const DrawerContent = React.forwardRef(({ isOpen, title, children, footer, big,
|
|
|
94
78
|
React.createElement(TransitionSlide, { in: isOpen, direction: direction, fixed: true, reverseExit: true, appear: true, mountOnEnter: true, unmountOnExit: true },
|
|
95
79
|
React.createElement(Wrapper, { big: big, onClick: stopClickPropagation, backgroundColor: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : "neutral.c00" },
|
|
96
80
|
React.createElement(Container, null,
|
|
97
|
-
React.createElement(
|
|
81
|
+
React.createElement(FlexBox, Object.assign({ justifyContent: "space-between", alignItems: "center", p: 12, pb: 10 }, extraHeaderProps),
|
|
98
82
|
!hideNavigation && (React.createElement(React.Fragment, null, onBack != null ? (React.createElement(Button, { onClick: onBack },
|
|
99
83
|
React.createElement(ArrowLeft, { size: 21 }))) : (React.createElement(ButtonPlaceholder, null)))),
|
|
100
84
|
(React.createElement(Text, { variant: "h3", flex: 1, textAlign: "center" }, title)) || React.createElement("div", null),
|
|
101
85
|
React.createElement(FlexBox, { alignSelf: "flex-start" },
|
|
102
86
|
React.createElement(Button, { onClick: onClose },
|
|
103
87
|
React.createElement(Close, null)))),
|
|
104
|
-
React.createElement(ScrollWrapper,
|
|
88
|
+
React.createElement(ScrollWrapper, Object.assign({ flexDirection: "column", alignItems: "stretch", overflow: "scroll", position: "relative", p: 12, pt: 0, flex: 1 }, extraContainerProps), children),
|
|
105
89
|
footer && (React.createElement(React.Fragment, null,
|
|
106
|
-
React.createElement(Divider, { variant: "light" }),
|
|
107
|
-
React.createElement(
|
|
90
|
+
React.createElement(Divider, Object.assign({ variant: "light" }, extraFooterDividerProps)),
|
|
91
|
+
React.createElement(FlexBox, Object.assign({ alignItems: "center", py: 8, px: 12 }, extraFooterProps), footer)))))))));
|
|
108
92
|
});
|
|
109
93
|
const Drawer = (_a, ref) => {
|
|
110
94
|
var { children, menuPortalTarget } = _a, sideProps = __rest(_a, ["children", "menuPortalTarget"]);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { TextProps } from "../../asorted/Text";
|
|
2
3
|
import { FlexBoxProps } from "../../layout/Flex";
|
|
3
|
-
export declare type Props = React.PropsWithChildren<FlexBoxProps
|
|
4
|
-
|
|
4
|
+
export declare type Props = React.PropsWithChildren<FlexBoxProps & {
|
|
5
|
+
extraTextProps?: TextProps;
|
|
6
|
+
}>;
|
|
7
|
+
declare function Log({ children, extraTextProps, ...props }: Props): JSX.Element;
|
|
5
8
|
declare const _default: React.MemoExoticComponent<typeof Log>;
|
|
6
9
|
export default _default;
|
|
@@ -19,7 +19,6 @@ const Container = styled(FlexBox) `
|
|
|
19
19
|
flex-wrap: wrap;
|
|
20
20
|
align-items: stretch;
|
|
21
21
|
min-height: ${(p) => p.theme.space[12]}px;
|
|
22
|
-
color: ${(p) => p.theme.colors.neutral.c100};
|
|
23
22
|
`;
|
|
24
23
|
const TextContainer = styled(FlexBox).attrs(() => ({
|
|
25
24
|
flex: "1",
|
|
@@ -31,11 +30,11 @@ const TextContainer = styled(FlexBox).attrs(() => ({
|
|
|
31
30
|
}
|
|
32
31
|
`;
|
|
33
32
|
function Log(_a) {
|
|
34
|
-
var { children } = _a, props = __rest(_a, ["children"]);
|
|
35
|
-
return (React.createElement(Container, Object.assign({}, props),
|
|
33
|
+
var { children, extraTextProps } = _a, props = __rest(_a, ["children", "extraTextProps"]);
|
|
34
|
+
return (React.createElement(Container, Object.assign({ color: "neutral.c100" }, props),
|
|
36
35
|
React.createElement(BracketLeft, null),
|
|
37
36
|
React.createElement(TextContainer, { flex: "1", alignItems: "center", justifyContent: "center" },
|
|
38
|
-
React.createElement(Text, { variant: "h3", textTransform: "uppercase", textAlign: "center" }, children)),
|
|
37
|
+
React.createElement(Text, Object.assign({ variant: "h3", textTransform: "uppercase", textAlign: "center", color: "inherit" }, extraTextProps), children)),
|
|
39
38
|
React.createElement(BracketRight, null)));
|
|
40
39
|
}
|
|
41
40
|
export default memo(Log);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { Props as StepperProps } from "../progress/Stepper";
|
|
2
3
|
import { FlexBoxProps as FlexProps } from "../../layout/Flex";
|
|
3
4
|
export declare type StepProps = {
|
|
4
5
|
/**
|
|
@@ -52,7 +53,7 @@ export interface Props<ExtraProps> {
|
|
|
52
53
|
/**
|
|
53
54
|
* Extra props that are passed to the stepper component.
|
|
54
55
|
*/
|
|
55
|
-
extraStepperProps?:
|
|
56
|
+
extraStepperProps?: Partial<StepperProps>;
|
|
56
57
|
/**
|
|
57
58
|
* Extra props that are passed to the stepper `Flex` wrapper.
|
|
58
59
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { BorderProps, ColorProps, SpaceProps } from "styled-system";
|
|
3
|
+
import { FlexBoxProps } from "../../../layout/Flex";
|
|
3
4
|
/**
|
|
4
5
|
* The state of a progress bar step.
|
|
5
6
|
*/
|
|
@@ -7,7 +8,7 @@ export declare type StepState = "pending" | "current" | "completed" | "errored"
|
|
|
7
8
|
declare type LabelType = string | React.ComponentType<{
|
|
8
9
|
state: StepState;
|
|
9
10
|
}>;
|
|
10
|
-
export interface Props {
|
|
11
|
+
export interface Props extends FlexBoxProps {
|
|
11
12
|
/**
|
|
12
13
|
* An array of labels that will determine the progress bar steps.
|
|
13
14
|
* A label is either a string or a component that will be rendered with the
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/react-ui",
|
|
3
3
|
"description": "Ledger Live - Desktop UI",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.1",
|
|
5
5
|
"author": "Ledger Live Team <team-live@ledger.fr>",
|
|
6
6
|
"repository": "https://github.com/LedgerHQ/ui",
|
|
7
7
|
"license": "MIT",
|
|
@@ -27,8 +27,9 @@
|
|
|
27
27
|
"index.js"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"@ledgerhq/ui
|
|
30
|
+
"@floating-ui/react-dom": "^0.4.0",
|
|
31
|
+
"@ledgerhq/icons-ui": "^0.2.2",
|
|
32
|
+
"@ledgerhq/ui-shared": "^0.1.5",
|
|
32
33
|
"@tippyjs/react": "^4.2.6",
|
|
33
34
|
"@types/color": "^3.0.2",
|
|
34
35
|
"@types/react": "~17.0.37",
|
package/styles/InvertTheme.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare
|
|
2
|
+
export declare type Props = {
|
|
3
|
+
if?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const InvertTheme: ({ if: condition, children, }: React.PropsWithChildren<Props>) => React.ReactElement;
|
package/styles/InvertTheme.js
CHANGED
|
@@ -2,9 +2,9 @@ import React, { useMemo } from "react";
|
|
|
2
2
|
import { ThemeProvider, useTheme } from "styled-components";
|
|
3
3
|
import { defaultTheme } from ".";
|
|
4
4
|
import { palettes } from "@ledgerhq/ui-shared";
|
|
5
|
-
export const InvertTheme = ({ children }) => {
|
|
6
|
-
const
|
|
7
|
-
const revertTheme = theme === "light" ? "dark" : "light";
|
|
5
|
+
export const InvertTheme = ({ if: condition, children, }) => {
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
const revertTheme = theme.theme === "light" ? "dark" : "light";
|
|
8
8
|
const newTheme = useMemo(() => (Object.assign(Object.assign({}, defaultTheme), { colors: Object.assign(Object.assign({}, palettes[revertTheme]), { palette: palettes[revertTheme] }), theme: revertTheme })), [revertTheme]);
|
|
9
|
-
return React.createElement(ThemeProvider, { theme: newTheme }, children);
|
|
9
|
+
return React.createElement(ThemeProvider, { theme: condition ? newTheme : theme }, children);
|
|
10
10
|
};
|