@ledgerhq/react-ui 0.7.3 → 0.7.4

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.
@@ -57,65 +57,65 @@ export const fontStyles = css `
57
57
  `;
58
58
  export const textVariantStyle = {
59
59
  h1: {
60
- fontFamily: "Alpha",
60
+ fontFamily: "Alpha, Inter, Sans",
61
61
  fontWeight: 500,
62
62
  "text-transform": "uppercase",
63
63
  },
64
64
  h2: {
65
- fontFamily: "Alpha",
65
+ fontFamily: "Alpha, Inter, Sans",
66
66
  fontWeight: 500,
67
67
  "text-transform": "uppercase",
68
68
  },
69
69
  h3: {
70
- fontFamily: "Alpha",
70
+ fontFamily: "Alpha, Inter, Sans",
71
71
  fontWeight: 500,
72
72
  "text-transform": "uppercase",
73
73
  },
74
74
  h4: {
75
- fontFamily: "Alpha",
75
+ fontFamily: "Alpha, Inter, Sans",
76
76
  fontWeight: 500,
77
77
  "text-transform": "uppercase",
78
78
  },
79
79
  h5: {
80
- fontFamily: "Alpha",
80
+ fontFamily: "Alpha, Inter, Sans",
81
81
  fontWeight: 500,
82
82
  "text-transform": "uppercase",
83
83
  },
84
84
  large: {
85
- fontFamily: "Inter",
85
+ fontFamily: "Inter, Sans",
86
86
  },
87
87
  largeLineHeight: {
88
- fontFamily: "Inter",
88
+ fontFamily: "Inter, Sans",
89
89
  lineHeight: 1.7,
90
90
  },
91
91
  body: {
92
- fontFamily: "Inter",
92
+ fontFamily: "Inter, Sans",
93
93
  },
94
94
  bodyLineHeight: {
95
- fontFamily: "Inter",
95
+ fontFamily: "Inter, Sans",
96
96
  lineHeight: 1.7,
97
97
  },
98
98
  paragraph: {
99
- fontFamily: "Inter",
99
+ fontFamily: "Inter, Sans",
100
100
  },
101
101
  paragraphLineHeight: {
102
- fontFamily: "Inter",
102
+ fontFamily: "Inter, Sans",
103
103
  lineHeight: 1.7,
104
104
  },
105
105
  small: {
106
- fontFamily: "Inter",
106
+ fontFamily: "Inter, Sans",
107
107
  },
108
108
  extraSmall: {
109
- fontFamily: "Inter",
109
+ fontFamily: "Inter, Sans",
110
110
  },
111
111
  tiny: {
112
- fontFamily: "Inter",
112
+ fontFamily: "Inter, Sans",
113
113
  },
114
114
  micro: {
115
- fontFamily: "Inter",
115
+ fontFamily: "Inter, Sans",
116
116
  },
117
117
  subtitle: {
118
- fontFamily: "Inter",
118
+ fontFamily: "Inter, Sans",
119
119
  fontWeight: 600,
120
120
  "text-transform": "uppercase",
121
121
  },
@@ -119,7 +119,7 @@ const getVariantColors = (p) => ({
119
119
  }
120
120
  `,
121
121
  });
122
- export const ButtonUnstyled = styled.button `
122
+ export const ButtonUnstyled = baseStyled.button `
123
123
  all: unset;
124
124
  cursor: pointer;
125
125
 
@@ -14,6 +14,7 @@ export declare type InputProps<T = ValueType> = Omit<CommonProps, "value" | "onC
14
14
  renderRight?: ((props: InputProps<T>) => React.ReactNode) | React.ReactNode;
15
15
  unwrapped?: boolean;
16
16
  containerProps?: InputContainerProps;
17
+ clearable?: boolean;
17
18
  /**
18
19
  * A function can be provided to serialize a value of any type to a string.
19
20
  *
@@ -56,6 +57,7 @@ export declare const InputRenderRightContainer: import("styled-components").Styl
56
57
  alignItems: string;
57
58
  pr: string;
58
59
  }, "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">;
60
+ export declare const ClearableButtonUnstyled: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
59
61
  declare function Input<T = ValueType>(props: InputProps<T>, ref?: React.ForwardedRef<HTMLInputElement>): JSX.Element;
60
62
  declare const _default: <T>(props: Omit<CommonProps, "onChange" | "value"> & {
61
63
  value: T;
@@ -76,6 +78,7 @@ declare const _default: <T>(props: Omit<CommonProps, "onChange" | "value"> & {
76
78
  as?: string | import("react").ComponentType<any> | undefined;
77
79
  forwardedAs?: string | import("react").ComponentType<any> | undefined;
78
80
  }) | undefined;
81
+ clearable?: boolean | undefined;
79
82
  /**
80
83
  * A function can be provided to serialize a value of any type to a string.
81
84
  *
@@ -12,9 +12,11 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import styled, { css } from "styled-components";
13
13
  import { typography } from "styled-system";
14
14
  import React, { useState, useMemo, useCallback } from "react";
15
+ import CircledCrossSolidMedium from "@ledgerhq/icons-ui/react/CircledCrossSolidMedium";
15
16
  import FlexBox from "../../layout/Flex";
16
17
  import Text from "../../asorted/Text";
17
18
  import { rgba } from "../../../styles/helpers";
19
+ import { ButtonUnstyled } from "../../cta/Button";
18
20
  export const InputContainer = styled.div `
19
21
  display: flex;
20
22
  height: 48px;
@@ -109,17 +111,23 @@ export const InputRenderRightContainer = styled(FlexBox).attrs(() => ({
109
111
  alignItems: "center",
110
112
  pr: "16px",
111
113
  })) ``;
114
+ export const ClearableButtonUnstyled = styled(ButtonUnstyled) `
115
+ display: flex;
116
+ `;
112
117
  // Yes, this is dirty. If you can figure out a better way please change the code :).
113
118
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
114
119
  const IDENTITY = (_) => _;
115
120
  function Input(props, ref) {
116
- const { value, disabled, error, warning, onChange, onChangeEvent, renderLeft, renderRight, unwrapped, containerProps, serialize = IDENTITY, deserialize = IDENTITY } = props, htmlInputProps = __rest(props, ["value", "disabled", "error", "warning", "onChange", "onChangeEvent", "renderLeft", "renderRight", "unwrapped", "containerProps", "serialize", "deserialize"]);
121
+ const { value, disabled, error, warning, onChange, onChangeEvent, renderLeft, renderRight, unwrapped, containerProps, serialize = IDENTITY, deserialize = IDENTITY, clearable } = props, htmlInputProps = __rest(props, ["value", "disabled", "error", "warning", "onChange", "onChangeEvent", "renderLeft", "renderRight", "unwrapped", "containerProps", "serialize", "deserialize", "clearable"]);
117
122
  const [focus, setFocus] = useState(false);
118
123
  const inputValue = useMemo(() => serialize(value), [serialize, value]);
119
124
  const handleChange = useCallback((e) => {
120
125
  onChange && onChange(deserialize(e.target.value));
121
126
  onChangeEvent && onChangeEvent(e);
122
127
  }, [onChange, onChangeEvent, deserialize]);
128
+ const handleClear = useCallback(() => {
129
+ onChange && onChange(deserialize(""));
130
+ }, [onChange, deserialize]);
123
131
  const inner = (React.createElement(React.Fragment, null,
124
132
  typeof renderLeft === "function" ? renderLeft(props) : renderLeft,
125
133
  React.createElement(BaseInput, Object.assign({ ref: ref }, htmlInputProps, { disabled: disabled, error: error, warning: warning, onChange: handleChange, value: inputValue, onFocus: (event) => {
@@ -129,6 +137,9 @@ function Input(props, ref) {
129
137
  setFocus(false);
130
138
  htmlInputProps.onBlur && htmlInputProps.onBlur(event);
131
139
  } })),
140
+ clearable && inputValue && (React.createElement(FlexBox, { alignItems: "center", mr: 7 },
141
+ React.createElement(ClearableButtonUnstyled, { onClick: handleClear },
142
+ React.createElement(CircledCrossSolidMedium, { size: 18, color: "neutral.c50" })))),
132
143
  typeof renderRight === "function" ? renderRight(props) : renderRight));
133
144
  if (unwrapped) {
134
145
  return (React.createElement(FlexBox, { alignItems: "stretch", style: { height: "100%" } }, inner));
@@ -22,6 +22,7 @@ declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInpu
22
22
  as?: string | import("react").ComponentType<any> | undefined;
23
23
  forwardedAs?: string | import("react").ComponentType<any> | undefined;
24
24
  }) | undefined;
25
+ clearable?: boolean | undefined;
25
26
  serialize?: ((value: string) => string) | undefined;
26
27
  deserialize?: ((value: string) => string) | undefined;
27
28
  } & {
@@ -19,6 +19,7 @@ declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInpu
19
19
  as?: string | import("react").ComponentType<any> | undefined;
20
20
  forwardedAs?: string | import("react").ComponentType<any> | undefined;
21
21
  }) | undefined;
22
+ clearable?: boolean | undefined;
22
23
  serialize?: ((value: number | undefined) => string) | undefined;
23
24
  deserialize?: ((value: string) => number | undefined) | undefined;
24
25
  } & {
@@ -19,6 +19,7 @@ declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInpu
19
19
  as?: string | import("react").ComponentType<any> | undefined;
20
20
  forwardedAs?: string | import("react").ComponentType<any> | undefined;
21
21
  }) | undefined;
22
+ clearable?: boolean | undefined;
22
23
  serialize?: ((value: string) => string) | undefined;
23
24
  deserialize?: ((value: string) => string) | undefined;
24
25
  } & {
@@ -19,6 +19,7 @@ declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInpu
19
19
  as?: string | import("react").ComponentType<any> | undefined;
20
20
  forwardedAs?: string | import("react").ComponentType<any> | undefined;
21
21
  }) | undefined;
22
+ clearable?: boolean | undefined;
22
23
  serialize?: ((value: string) => string) | undefined;
23
24
  deserialize?: ((value: string) => string) | undefined;
24
25
  } & {
@@ -19,6 +19,7 @@ declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInpu
19
19
  as?: string | import("react").ComponentType<any> | undefined;
20
20
  forwardedAs?: string | import("react").ComponentType<any> | undefined;
21
21
  }) | undefined;
22
+ clearable?: boolean | undefined;
22
23
  serialize?: ((value: string) => string) | undefined;
23
24
  deserialize?: ((value: string) => string) | undefined;
24
25
  } & React.RefAttributes<HTMLInputElement>>;
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.3",
4
+ "version": "0.7.4",
5
5
  "author": "Ledger Live Team <team-live@ledger.fr>",
6
6
  "repository": "https://github.com/LedgerHQ/ui",
7
7
  "license": "MIT",