@ledgerhq/react-ui 0.4.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.
Files changed (102) hide show
  1. package/assets/logos/LedgerLiveAltRegular.d.ts +0 -1
  2. package/assets/logos/LedgerLiveRegular.d.ts +0 -1
  3. package/components/Chart/index.d.ts +0 -1
  4. package/components/Table/Columns.d.ts +60 -11
  5. package/components/Table/Columns.js +6 -16
  6. package/components/Table/index.d.ts +44 -12
  7. package/components/Table/index.js +36 -16
  8. package/components/Table/stories.helper.js +13 -12
  9. package/components/animations/GlitchText/index.d.ts +0 -1
  10. package/components/asorted/Divider/index.d.ts +1 -2
  11. package/components/asorted/Icon/BoxedIcon.d.ts +48 -0
  12. package/components/asorted/Icon/BoxedIcon.js +62 -0
  13. package/components/asorted/Icon/Icon.d.ts +0 -2
  14. package/components/asorted/Icon/Icon.js +0 -7
  15. package/components/asorted/Icon/index.d.ts +3 -1
  16. package/components/asorted/Icon/index.js +3 -1
  17. package/components/asorted/index.d.ts +1 -1
  18. package/components/asorted/index.js +1 -1
  19. package/components/cta/Button/index.d.ts +11 -8
  20. package/components/cta/Button/index.js +34 -23
  21. package/components/cta/Link/index.d.ts +53 -4
  22. package/components/cta/Link/index.js +15 -11
  23. package/components/cta/Toggle/index.d.ts +0 -1
  24. package/components/form/BaseInput/index.d.ts +8 -14
  25. package/components/form/BaseInput/index.js +1 -1
  26. package/components/form/Dropdown/index.d.ts +3 -3
  27. package/components/form/Dropdown/index.js +9 -8
  28. package/components/form/DropdownGeneric/index.d.ts +36 -0
  29. package/components/form/DropdownGeneric/index.js +95 -0
  30. package/components/form/LegendInput/index.d.ts +26 -2
  31. package/components/form/LegendInput/index.js +3 -2
  32. package/components/form/NumberInput/index.d.ts +25 -3
  33. package/components/form/NumberInput/index.js +3 -2
  34. package/components/form/QrCodeInput/index.d.ts +25 -3
  35. package/components/form/QrCodeInput/index.js +3 -2
  36. package/components/form/QuantityInput/index.d.ts +26 -4
  37. package/components/form/QuantityInput/index.js +3 -2
  38. package/components/form/Radio/RadioElement.d.ts +3 -2
  39. package/components/form/Radio/RadioElement.js +72 -3
  40. package/components/form/Radio/index.d.ts +1 -1
  41. package/components/form/SearchInput/index.d.ts +24 -2
  42. package/components/form/SearchInput/index.js +3 -2
  43. package/components/form/SelectInput/Control.d.ts +4 -10
  44. package/components/form/SelectInput/Control.js +5 -8
  45. package/components/form/SelectInput/DropdownIndicator.d.ts +3 -10
  46. package/components/form/SelectInput/IndicatorsContainer.d.ts +2 -6
  47. package/components/form/SelectInput/IndicatorsContainer.js +1 -1
  48. package/components/form/SelectInput/MenuList.d.ts +3 -10
  49. package/components/form/SelectInput/MenuList.js +2 -1
  50. package/components/form/SelectInput/Option.d.ts +6 -18
  51. package/components/form/SelectInput/ValueContainer.d.ts +5 -14
  52. package/components/form/SelectInput/ValueContainer.js +1 -1
  53. package/components/form/SelectInput/VirtualMenuList.d.ts +2 -5
  54. package/components/form/SelectInput/VirtualMenuList.js +2 -1
  55. package/components/form/SelectInput/index.d.ts +7 -16
  56. package/components/form/SelectInput/index.js +10 -2
  57. package/components/form/index.d.ts +1 -0
  58. package/components/form/index.js +1 -0
  59. package/components/layout/Box/index.d.ts +1 -4
  60. package/components/layout/Drawer/index.d.ts +17 -2
  61. package/components/layout/Drawer/index.js +45 -36
  62. package/components/layout/Flex/index.d.ts +2 -5
  63. package/components/layout/Popin/index.d.ts +6 -11
  64. package/components/layout/Popin/index.js +10 -5
  65. package/components/layout/Side/index.d.ts +0 -1
  66. package/components/loaders/InfiniteLoader/index.d.ts +8 -7
  67. package/components/loaders/InfiniteLoader/index.js +35 -9
  68. package/components/loaders/ProgressLoader/index.d.ts +22 -2
  69. package/components/loaders/ProgressLoader/index.js +10 -12
  70. package/components/message/Alert/index.d.ts +31 -3
  71. package/components/message/Alert/index.js +30 -23
  72. package/components/message/Log/index.d.ts +5 -2
  73. package/components/message/Log/index.js +3 -4
  74. package/components/message/Tip/index.d.ts +0 -1
  75. package/components/message/Tooltip/index.d.ts +0 -1
  76. package/components/navigation/Aside/index.d.ts +2 -5
  77. package/components/navigation/Breadcrumb/index.js +1 -1
  78. package/components/navigation/FlowStepper/index.d.ts +77 -0
  79. package/components/navigation/FlowStepper/index.js +35 -0
  80. package/components/navigation/index.d.ts +1 -0
  81. package/components/navigation/index.js +1 -0
  82. package/components/navigation/progress/ProgressBar/Onboarding.d.ts +0 -1
  83. package/components/navigation/progress/Stepper/index.d.ts +27 -10
  84. package/components/navigation/progress/Stepper/index.js +37 -18
  85. package/components/navigation/sideBar/Item/Item.d.ts +0 -1
  86. package/components/navigation/sideBar/Logo/Logo.d.ts +0 -1
  87. package/components/navigation/sideBar/SideBar/SideBar.d.ts +0 -1
  88. package/components/navigation/sideBar/SideBar/SideBar.js +9 -7
  89. package/components/navigation/sideBar/Toggle/Toggle.d.ts +0 -1
  90. package/components/styled.d.ts +8 -5
  91. package/components/styled.js +2 -2
  92. package/index.d.ts +1 -1
  93. package/index.js +1 -1
  94. package/package.json +6 -6
  95. package/styles/InvertTheme.d.ts +4 -1
  96. package/styles/InvertTheme.js +5 -5
  97. package/styles/index.d.ts +1 -0
  98. package/styles/index.js +1 -0
  99. package/styles/theme.d.ts +1 -1
  100. package/styles/theme.js +8 -8
  101. package/components/loaders/InfiniteLoader/image.d.ts +0 -2
  102. package/components/loaders/InfiniteLoader/image.js +0 -1
@@ -9,13 +9,15 @@ 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";
16
16
  import fontFamily from "../../../styles/styled/fontFamily";
17
17
  import { fontSizes } from "../../../styles/theme";
18
+ import { rgba } from "../../../styles/helpers";
18
19
  import ChevronBottom from "@ledgerhq/icons-ui/react/ChevronBottomRegular";
20
+ import IconComponent from "../../asorted/Icon";
19
21
  const IconContainer = styled.div `
20
22
  display: inline-block;
21
23
  ${(p) => `${p.iconPosition === "left" ? "margin-right" : "margin-left"}: ${p.theme.space[4]}px;`}
@@ -26,12 +28,12 @@ const getVariantColors = (p) => ({
26
28
  outline: `
27
29
  border-color: ${p.theme.colors.neutral.c100};
28
30
  color: ${p.theme.colors.neutral.c100};
29
- background-color: ${p.theme.colors.neutral.c00};
31
+ background-color: transparent;
30
32
  &:hover, &:focus {
31
- background-color: ${p.theme.colors.neutral.c20};
33
+ background-color: ${rgba(p.theme.colors.neutral.c100, 0.03)};
32
34
  }
33
35
  &:active {
34
- background-color: ${p.theme.colors.neutral.c30};
36
+ background-color: ${rgba(p.theme.colors.neutral.c100, 0.05)};
35
37
  }
36
38
  `,
37
39
  filled: `
@@ -62,12 +64,12 @@ const getVariantColors = (p) => ({
62
64
  outline: `
63
65
  border-color: ${p.theme.colors.error.c100};
64
66
  color: ${p.theme.colors.error.c100};
65
- background-color: ${p.theme.colors.neutral.c00};
67
+ background-color: transparent;
66
68
  &:hover {
67
- background-color: ${p.theme.colors.error.c10};
69
+ background-color: ${rgba(p.theme.colors.error.c100, 0.02)};
68
70
  }
69
71
  &:active {
70
- background-color: ${p.theme.colors.error.c30};
72
+ background-color: ${rgba(p.theme.colors.error.c100, 0.05)};
71
73
  }
72
74
  `,
73
75
  filled: `
@@ -82,12 +84,12 @@ const getVariantColors = (p) => ({
82
84
  outline: `
83
85
  border-color: ${p.theme.colors.primary.c80};
84
86
  color: ${p.theme.colors.primary.c80};
85
- background-color: ${p.theme.colors.neutral.c00};
87
+ background-color: transparent;
86
88
  &:hover {
87
- background-color: ${p.theme.colors.primary.c10};
89
+ background-color: ${rgba(p.theme.colors.primary.c100, 0.02)};
88
90
  }
89
91
  &:active {
90
- background-color: ${p.theme.colors.primary.c20};
92
+ background-color: ${rgba(p.theme.colors.primary.c100, 0.05)};
91
93
  }
92
94
  `,
93
95
  filled: `
@@ -102,7 +104,7 @@ const getVariantColors = (p) => ({
102
104
  outline: `
103
105
  border-color: ${p.theme.colors.neutral.c50};
104
106
  color: ${p.theme.colors.neutral.c50};
105
- background-color: ${p.theme.colors.neutral.c00};
107
+ background-color: transparent;
106
108
  `,
107
109
  filled: `
108
110
  color: ${p.theme.colors.neutral.c50};
@@ -153,7 +155,10 @@ export const Base = baseStyled.button.attrs((p) => {
153
155
  position: relative;
154
156
  cursor: ${(p) => (p.disabled ? "default" : "pointer")};
155
157
  &:active {
156
- box-shadow: 0 0 0 4px ${(p) => p.theme.colors.primary.c60};
158
+ box-shadow: 0 0 0 4px ${(p) => rgba(p.theme.colors.primary.c60, 0.4)};
159
+ }
160
+ &:focus {
161
+ box-shadow: 0 0 0 2px ${(p) => rgba(p.theme.colors.primary.c60, 0.4)};
157
162
  }
158
163
 
159
164
  ${(p) => {
@@ -188,19 +193,22 @@ export const Base = baseStyled.button.attrs((p) => {
188
193
  }
189
194
  `
190
195
  : ""}
191
- ${(p) => p.theme.transition(["background-color", "color", "border-color"])}
196
+ ${(p) => p.theme.transition(["background-color", "color", "border-color", "box-shadow"], "0.2s")}
192
197
  `;
193
198
  const ContentContainer = styled.div ``;
194
- const Button = (_a) => {
199
+ const Button = (_a, ref) => {
195
200
  var _b;
196
- var { Icon, iconPosition = "right", iconSize = 16, children, onClick } = _a, props = __rest(_a, ["Icon", "iconPosition", "iconSize", "children", "onClick"]);
197
- return (React.createElement(Base, Object.assign({}, props, { iconButton: !(Icon == null) && !children, onClick: 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]);
205
+ return (React.createElement(Base, Object.assign({}, props, { ref: ref, iconButton: !(Icon == null) && !children, onClick: onClick }),
198
206
  iconPosition === "right" ? React.createElement(ContentContainer, null, children) : null,
199
- Icon != null ? (React.createElement(IconContainer, { iconPosition: iconPosition },
200
- React.createElement(Icon, { size: iconSize || fontSizes[(_b = props.fontSize) !== null && _b !== void 0 ? _b : 4] }))) : null,
207
+ IconNode && React.createElement(IconContainer, { iconPosition: iconPosition }, IconNode),
201
208
  iconPosition === "left" ? React.createElement(ContentContainer, null, children) : null));
202
209
  };
203
- const StyledExpandButton = styled(Button).attrs((props) => ({
210
+ const ButtonWithRef = React.forwardRef(Button);
211
+ const StyledButtonExpand = styled(ButtonWithRef).attrs((props) => ({
204
212
  Icon: props.Icon != null || ChevronBottom,
205
213
  iconPosition: props.iconPosition || "right",
206
214
  })) `
@@ -209,14 +217,17 @@ const StyledExpandButton = styled(Button).attrs((props) => ({
209
217
  ${(p) => (p.expanded ? "transform: rotate(180deg)" : "")}
210
218
  }
211
219
  `;
212
- export const ExpandButton = function ExpandButton(_a) {
220
+ export function ButtonExpand(_a, ref) {
213
221
  var { onToggle, onClick } = _a, props = __rest(_a, ["onToggle", "onClick"]);
214
222
  const [expanded, setExpanded] = useState(false);
215
- return (React.createElement(StyledExpandButton, Object.assign({}, props, { expanded: expanded, onClick: (event) => {
223
+ return (React.createElement(StyledButtonExpand, Object.assign({}, props, { ref: ref, expanded: expanded, onClick: (event) => {
216
224
  setExpanded((expanded) => !expanded);
217
225
  onToggle != null && onToggle(!expanded);
218
226
  onClick != null && onClick(event);
219
227
  } })));
220
- };
228
+ }
221
229
  Button.Unstyled = ButtonUnstyled;
222
- export default Button;
230
+ Button.Expand = React.forwardRef(ButtonExpand);
231
+ ButtonWithRef.Unstyled = Button.Unstyled;
232
+ ButtonWithRef.Expand = Button.Expand;
233
+ export default ButtonWithRef;
@@ -1,30 +1,79 @@
1
1
  import React from "react";
2
+ import { TextProps } from "../../asorted/Text";
2
3
  import { BaseStyledProps } from "../../styled";
3
4
  export declare type LinkProps = React.AnchorHTMLAttributes<HTMLAnchorElement> & BaseStyledProps & {
5
+ /**
6
+ * Component that takes `{size: number; color?: string}` as props
7
+ */
4
8
  Icon?: React.ComponentType<{
5
9
  size: number;
6
10
  color?: string;
7
11
  }>;
12
+ /**
13
+ * Affects the colors of the text, icon & underline, can be overriden by the `color` prop
14
+ */
8
15
  type?: "main" | "shade" | "color";
16
+ /**
17
+ * Affect the font variant & icon size
18
+ */
9
19
  size?: "small" | "medium" | "large";
20
+ /**
21
+ * Color of the link, overrides colors defined by the `type` prop
22
+ */
23
+ color?: string;
24
+ /**
25
+ * Props passed to the rendered text
26
+ */
27
+ textProps?: TextProps;
28
+ /**
29
+ * If true text will always be underlined, else it will be underlined only on hover
30
+ */
31
+ alwaysUnderline?: boolean;
32
+ /**
33
+ * Position of the icon relative to the text
34
+ */
10
35
  iconPosition?: "right" | "left";
11
36
  disabled?: boolean;
12
37
  children?: React.ReactNode;
13
38
  };
14
- export declare const Base: import("styled-components").StyledComponent<"a", import("styled-components").DefaultTheme, React.AnchorHTMLAttributes<HTMLAnchorElement> & 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").OverflowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & {
39
+ export declare const DEFAULT_ICON_POSITION = "right";
40
+ export declare const DEFAULT_SIZE = "medium";
41
+ export declare const DEFAULT_TYPE = "main";
42
+ export declare const Base: import("styled-components").StyledComponent<"a", import("styled-components").DefaultTheme, React.AnchorHTMLAttributes<HTMLAnchorElement> & 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>>> & {
15
43
  columnGap?: string | number | undefined;
16
44
  rowGap?: string | number | undefined;
17
45
  color?: string | undefined;
18
- display?: string | undefined;
19
- position?: string | undefined;
20
- maxHeight?: number | undefined;
21
46
  } & {
47
+ /**
48
+ * Component that takes `{size: number; color?: string}` as props
49
+ */
22
50
  Icon?: React.ComponentType<{
23
51
  size: number;
24
52
  color?: string | undefined;
25
53
  }> | undefined;
54
+ /**
55
+ * Affects the colors of the text, icon & underline, can be overriden by the `color` prop
56
+ */
26
57
  type?: "main" | "color" | "shade" | undefined;
58
+ /**
59
+ * Affect the font variant & icon size
60
+ */
27
61
  size?: "small" | "medium" | "large" | undefined;
62
+ /**
63
+ * Color of the link, overrides colors defined by the `type` prop
64
+ */
65
+ color?: string | undefined;
66
+ /**
67
+ * Props passed to the rendered text
68
+ */
69
+ textProps?: TextProps | undefined;
70
+ /**
71
+ * If true text will always be underlined, else it will be underlined only on hover
72
+ */
73
+ alwaysUnderline?: boolean | undefined;
74
+ /**
75
+ * Position of the icon relative to the text
76
+ */
28
77
  iconPosition?: "left" | "right" | undefined;
29
78
  disabled?: boolean | undefined;
30
79
  children?: React.ReactNode;
@@ -4,6 +4,9 @@ import { getLinkColors } from "./getLinkStyle";
4
4
  import { ctaIconSize, ctaTextType } from "../getCtaStyle";
5
5
  import { Text } from "../../asorted";
6
6
  import baseStyled from "../../styled";
7
+ export const DEFAULT_ICON_POSITION = "right";
8
+ export const DEFAULT_SIZE = "medium";
9
+ export const DEFAULT_TYPE = "main";
7
10
  const IconContainer = styled.div `
8
11
  ${(p) => p.iconLink ? "" : p.iconPosition === "left" ? `margin-right: 6px;` : `margin-left: 6px;`}
9
12
  display: flex;
@@ -11,7 +14,7 @@ const IconContainer = styled.div `
11
14
  justify-content: center;
12
15
  `;
13
16
  export const Base = baseStyled.a `
14
- color: ${({ theme, disabled, type = "main" }) => getLinkColors(theme.colors)[disabled ? "disabled" : type]["default"]};
17
+ color: ${({ color, theme, disabled, type = "main" }) => color || getLinkColors(theme.colors)[disabled ? "disabled" : type]["default"]};
15
18
  cursor: pointer;
16
19
  display: inline-flex;
17
20
  flex-direction: row;
@@ -19,27 +22,28 @@ export const Base = baseStyled.a `
19
22
  align-items: center;
20
23
  justify-content: center;
21
24
 
22
- text-decoration: none;
23
-
24
25
  :hover {
25
26
  text-decoration: underline;
26
27
  }
27
28
  :active {
28
- color: ${({ theme, type = "main" }) => getLinkColors(theme.colors)[type]["pressed"]};
29
+ color: ${({ color, theme, type = "main" }) => color || getLinkColors(theme.colors)[type]["pressed"]};
29
30
  text-decoration: underline;
30
31
  }
32
+
33
+ text-decoration: ${(p) => (p.alwaysUnderline ? "underline" : "none")};
34
+
31
35
  `;
32
- const LinkContainer = (props) => {
33
- const { Icon, iconPosition = "right", children, size = "medium" } = props;
36
+ const LinkContainer = ({ Icon, iconPosition = DEFAULT_ICON_POSITION, children, color, size = DEFAULT_SIZE, textProps, }) => {
37
+ const text = (React.createElement(Text, Object.assign({ variant: ctaTextType[size], fontWeight: "semiBold", color: color || "inherit" }, textProps), children));
34
38
  return (React.createElement(React.Fragment, null,
35
- iconPosition === "right" && children ? (React.createElement(Text, { variant: ctaTextType[size], fontWeight: "semiBold", color: "inherit" }, children)) : null,
39
+ iconPosition === "right" && children ? text : null,
36
40
  Icon ? (React.createElement(IconContainer, { iconLink: !children, iconPosition: iconPosition },
37
- React.createElement(Icon, { size: ctaIconSize[size], color: "currentcolor" }))) : null,
38
- iconPosition === "left" && children ? (React.createElement(Text, { variant: ctaTextType[size], fontWeight: "semiBold", color: "inherit" }, children)) : null));
41
+ React.createElement(Icon, { size: ctaIconSize[size], color: color || "currentcolor" }))) : null,
42
+ iconPosition === "left" && children ? text : null));
39
43
  };
40
44
  const Link = (props) => {
41
- const { type = "main", size = "medium" } = props;
42
- return (React.createElement(Base, Object.assign({}, props),
45
+ const { type = DEFAULT_TYPE, size = DEFAULT_SIZE, color } = props;
46
+ return (React.createElement(Base, Object.assign({ color: color }, props),
43
47
  React.createElement(LinkContainer, Object.assign({}, props, { type: type, size: size }))));
44
48
  };
45
49
  export default Link;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { ButtonProps } from "../Button";
3
2
  export interface ToggleProps extends Omit<ButtonProps, "type"> {
4
3
  checked?: boolean;
@@ -40,29 +40,23 @@ export declare const BaseInput: import("styled-components").StyledComponent<"inp
40
40
  } & TypographyProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>>, never>;
41
41
  export declare const InputErrorContainer: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, import("../../asorted/Text").TextProps, keyof import("../../asorted/Text").TextProps>;
42
42
  export declare const InputWarningContainer: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, import("../../asorted/Text").TextProps, keyof import("../../asorted/Text").TextProps>;
43
- export declare const InputRenderLeftContainer: 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").OverflowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & {
43
+ export declare const InputRenderLeftContainer: 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>>> & {
44
44
  columnGap?: string | number | undefined;
45
45
  rowGap?: string | number | undefined;
46
46
  color?: string | undefined;
47
- display?: string | undefined;
48
- position?: string | undefined;
49
- maxHeight?: number | undefined;
50
47
  } & {
51
48
  alignItems: string;
52
49
  pl: string;
53
- }, "overflow" | "p" | "color" | "left" | "right" | "bottom" | "top" | "size" | "flex" | "padding" | "rowGap" | "alignContent" | "alignItems" | "alignSelf" | "backgroundColor" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "opacity" | "order" | "overflowX" | "overflowY" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "verticalAlign" | "width" | "zIndex" | "margin" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "bg">;
54
- export declare const InputRenderRightContainer: 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").OverflowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & {
50
+ }, "overflow" | "p" | "color" | "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" | "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" | "padding" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "bg" | "borderX" | "borderY">;
51
+ export declare const InputRenderRightContainer: 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>>> & {
55
52
  columnGap?: string | number | undefined;
56
53
  rowGap?: string | number | undefined;
57
54
  color?: string | undefined;
58
- display?: string | undefined;
59
- position?: string | undefined;
60
- maxHeight?: number | undefined;
61
55
  } & {
62
56
  alignItems: string;
63
57
  pr: string;
64
- }, "overflow" | "p" | "color" | "left" | "right" | "bottom" | "top" | "size" | "flex" | "padding" | "rowGap" | "alignContent" | "alignItems" | "alignSelf" | "backgroundColor" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "opacity" | "order" | "overflowX" | "overflowY" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "verticalAlign" | "width" | "zIndex" | "margin" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "bg">;
65
- declare function Input<T = ValueType>(props: InputProps<T>, ref: React.ForwardedRef<HTMLInputElement>): JSX.Element;
58
+ }, "overflow" | "p" | "color" | "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" | "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" | "padding" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "bg" | "borderX" | "borderY">;
59
+ declare function Input<T = ValueType>(props: InputProps<T>, ref?: React.ForwardedRef<HTMLInputElement>): JSX.Element;
66
60
  declare const _default: <T>(props: Omit<CommonProps, "onChange" | "value"> & {
67
61
  value: T;
68
62
  onChange?: ((value: T) => void) | undefined;
@@ -77,10 +71,10 @@ declare const _default: <T>(props: Omit<CommonProps, "onChange" | "value"> & {
77
71
  } & {
78
72
  theme?: import("styled-components").DefaultTheme | undefined;
79
73
  } & ({} | {
80
- children?: React.ReactNode;
74
+ children?: import("react").ReactNode;
81
75
  })) & {
82
- as?: string | React.ComponentType<any> | undefined;
83
- forwardedAs?: string | React.ComponentType<any> | undefined;
76
+ as?: string | import("react").ComponentType<any> | undefined;
77
+ forwardedAs?: string | import("react").ComponentType<any> | undefined;
84
78
  }) | undefined;
85
79
  /**
86
80
  * A function can be provided to serialize a value of any type to a string.
@@ -28,7 +28,7 @@ export const InputContainer = styled.div `
28
28
  !p.warning &&
29
29
  css `
30
30
  border: 1px solid ${p.theme.colors.primary.c80};
31
- box-shadow: 0 0 0 4px ${rgba(p.theme.colors.primary.c60, 0.48)};
31
+ box-shadow: 0 0 0 4px ${rgba(p.theme.colors.primary.c60, 0.4)};
32
32
  `};
33
33
 
34
34
  ${(p) => p.error &&
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import { GroupBase } from "react-select";
2
2
  import { Props as SelectInputProps } from "../../form/SelectInput";
3
- export declare type Props = SelectInputProps & {
3
+ export declare type Props<O> = SelectInputProps<O, false, GroupBase<O>> & {
4
4
  label: string;
5
5
  };
6
- export default function Dropdown(props: Props): JSX.Element;
6
+ export default function Dropdown<O>(props: Props<O>): JSX.Element;
@@ -14,22 +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
- const { selectProps: { label }, children, } = props;
21
+ const { selectProps, children } = props;
22
+ const { label } = selectProps;
22
23
  return (React.createElement(components.Control, Object.assign({}, props),
23
- React.createElement(Text, { fontWeight: "semiBold", variant: "paragraph", color: "neutral.c80", mr: 2 }, label),
24
+ React.createElement(Text, { variant: "paragraph", fontWeight: "medium", color: "neutral.c80", mr: 2 }, label),
24
25
  children));
25
26
  }
26
27
  function DropdownValueContainer(props) {
27
- const ChevronIcon = props.selectProps.menuIsOpen ? ChevronTopMedium : ChevronBottomMedium;
28
- return (React.createElement(ValueContainer, Object.assign({}, props, { render: () => (React.createElement(FlexBox, null,
29
- React.createElement(Text, { fontWeight: "semiBold", variant: "paragraph", mr: 2 },
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 },
30
31
  React.createElement(FlexBox, null, props.children)),
31
- React.createElement(FlexBox, { alignItems: "center" },
32
- React.createElement(ChevronIcon, { size: 12 })))) })));
32
+ React.createElement(FlexBox, { alignItems: "center", style: { transform: isOpen ? "rotate(180deg)" : "" } },
33
+ React.createElement(Icons.DropdownMedium, { size: 20 })))) })));
33
34
  }
34
35
  function DropdownIndicatorsContainer() {
35
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,6 +1,30 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { InputProps } from "../BaseInput";
3
3
  export declare type Props = InputProps & {
4
4
  legend: string;
5
5
  };
6
- export default function LegendInput({ legend, ...inputProps }: Props): JSX.Element;
6
+ declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInput").CommonProps, "onChange" | "value"> & {
7
+ value: string;
8
+ onChange?: ((value: string) => void) | undefined;
9
+ onChangeEvent?: React.ChangeEventHandler<HTMLInputElement> | undefined;
10
+ renderLeft?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
11
+ renderRight?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
12
+ unwrapped?: boolean | undefined;
13
+ containerProps?: (({
14
+ [x: string]: any;
15
+ [x: number]: any;
16
+ [x: symbol]: any;
17
+ } & {
18
+ theme?: import("styled-components").DefaultTheme | undefined;
19
+ } & ({} | {
20
+ children?: import("react").ReactNode;
21
+ })) & {
22
+ as?: string | import("react").ComponentType<any> | undefined;
23
+ forwardedAs?: string | import("react").ComponentType<any> | undefined;
24
+ }) | undefined;
25
+ serialize?: ((value: string) => string) | undefined;
26
+ deserialize?: ((value: string) => string) | undefined;
27
+ } & {
28
+ legend: string;
29
+ } & React.RefAttributes<HTMLInputElement>>;
30
+ export default _default;
@@ -20,8 +20,9 @@ const Legend = styled(Text) `
20
20
  color: ${(props) => props.theme.colors.neutral.c50};
21
21
  }
22
22
  `;
23
- export default function LegendInput(_a) {
23
+ function LegendInput(_a, ref) {
24
24
  var { legend } = _a, inputProps = __rest(_a, ["legend"]);
25
- return (React.createElement(Input, Object.assign({}, inputProps, { renderRight: React.createElement(InputRenderRightContainer, null,
25
+ return (React.createElement(Input, Object.assign({ ref: ref }, inputProps, { renderRight: React.createElement(InputRenderRightContainer, null,
26
26
  React.createElement(Legend, { variant: "body", "data-disabled": inputProps.disabled }, legend)) })));
27
27
  }
28
+ export default React.forwardRef(LegendInput);
@@ -1,5 +1,27 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { InputProps } from "../BaseInput";
3
- export default function NumberInput({ value, onPercentClick, max, disabled, ...inputProps }: InputProps<number | undefined> & {
3
+ declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInput").CommonProps, "onChange" | "value"> & {
4
+ value: number | undefined;
5
+ onChange?: ((value: number | undefined) => void) | undefined;
6
+ onChangeEvent?: React.ChangeEventHandler<HTMLInputElement> | undefined;
7
+ renderLeft?: React.ReactNode | ((props: InputProps<number | undefined>) => React.ReactNode);
8
+ renderRight?: React.ReactNode | ((props: InputProps<number | undefined>) => React.ReactNode);
9
+ unwrapped?: boolean | undefined;
10
+ containerProps?: (({
11
+ [x: string]: any;
12
+ [x: number]: any;
13
+ [x: symbol]: any;
14
+ } & {
15
+ theme?: import("styled-components").DefaultTheme | undefined;
16
+ } & ({} | {
17
+ children?: import("react").ReactNode;
18
+ })) & {
19
+ as?: string | import("react").ComponentType<any> | undefined;
20
+ forwardedAs?: string | import("react").ComponentType<any> | undefined;
21
+ }) | undefined;
22
+ serialize?: ((value: number | undefined) => string) | undefined;
23
+ deserialize?: ((value: string) => number | undefined) | undefined;
24
+ } & {
4
25
  onPercentClick: (percent: number) => void;
5
- }): JSX.Element;
26
+ } & React.RefAttributes<HTMLInputElement>>;
27
+ export default _default;