@ledgerhq/react-ui 0.2.0 → 0.5.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/README.md +47 -4
- package/assets/logos/LedgerLiveAltRegular.d.ts +0 -1
- package/assets/logos/LedgerLiveRegular.d.ts +0 -1
- package/components/Chart/index.d.ts +0 -1
- package/components/Chart/index.js +1 -1
- package/components/Table/Columns.d.ts +62 -13
- package/components/Table/Columns.js +8 -18
- package/components/Table/index.d.ts +47 -14
- package/components/Table/index.js +37 -20
- package/components/Table/stories.helper.js +19 -18
- package/components/Tag/index.d.ts +18 -5
- package/components/Tag/index.js +54 -21
- package/components/animations/GlitchText/index.d.ts +6 -0
- package/components/animations/GlitchText/index.js +35 -0
- package/components/asorted/Divider/index.d.ts +0 -1
- package/components/asorted/Divider/index.js +2 -2
- package/components/asorted/Icon/BoxedIcon.d.ts +48 -0
- package/components/asorted/Icon/BoxedIcon.js +58 -0
- package/components/asorted/Icon/Icon.d.ts +0 -1
- package/components/asorted/Icon/index.d.ts +2 -0
- package/components/asorted/Icon/index.js +2 -0
- package/components/asorted/Text/index.d.ts +6 -22
- package/components/asorted/Text/index.js +7 -16
- package/components/asorted/Text/styles.d.ts +2 -1
- package/components/asorted/Text/styles.js +21 -9
- package/components/asorted/index.d.ts +1 -1
- package/components/asorted/index.js +1 -1
- package/components/cards/Carousel/Slide.js +3 -3
- package/components/cards/Carousel/index.js +8 -8
- package/components/cta/Button/index.d.ts +16 -8
- package/components/cta/Button/index.js +76 -65
- package/components/cta/Link/index.d.ts +59 -2
- package/components/cta/Link/index.js +17 -12
- package/components/cta/Toggle/index.d.ts +0 -1
- package/components/cta/Toggle/index.js +1 -1
- package/components/form/BaseInput/index.d.ts +81 -11
- package/components/form/BaseInput/index.js +42 -19
- package/components/form/Checkbox/Checkbox.js +12 -9
- package/components/form/Dropdown/index.d.ts +0 -1
- package/components/form/Dropdown/index.js +2 -2
- package/components/form/LegendInput/index.d.ts +26 -2
- package/components/form/LegendInput/index.js +5 -4
- package/components/form/NumberInput/index.d.ts +25 -3
- package/components/form/NumberInput/index.js +19 -7
- package/components/form/QrCodeInput/index.d.ts +25 -3
- package/components/form/QrCodeInput/index.js +7 -6
- package/components/form/QuantityInput/index.d.ts +26 -4
- package/components/form/QuantityInput/index.js +9 -8
- package/components/form/Radio/RadioElement.d.ts +5 -2
- package/components/form/Radio/RadioElement.js +15 -13
- package/components/form/Radio/RadioListElement.d.ts +22 -0
- package/components/form/Radio/RadioListElement.js +63 -0
- package/components/form/Radio/index.d.ts +8 -1
- package/components/form/Radio/index.js +2 -0
- package/components/form/SearchInput/index.d.ts +24 -2
- package/components/form/SearchInput/index.js +4 -3
- package/components/form/SelectInput/Control.d.ts +2 -2
- package/components/form/SelectInput/Control.js +3 -7
- package/components/form/SelectInput/DropdownIndicator.d.ts +0 -1
- package/components/form/SelectInput/DropdownIndicator.js +1 -1
- package/components/form/SelectInput/IndicatorsContainer.d.ts +0 -1
- package/components/form/SelectInput/MenuList.d.ts +0 -1
- package/components/form/SelectInput/MenuList.js +1 -1
- package/components/form/SelectInput/Option.js +11 -11
- package/components/form/SelectInput/ValueContainer.js +1 -1
- package/components/form/SelectInput/index.d.ts +3 -2
- package/components/form/SelectInput/index.js +5 -5
- package/components/form/SplitInput/index.js +5 -5
- package/components/form/Switch/Switch.js +8 -8
- package/components/helpers.d.ts +2 -2
- package/components/layout/Box/index.d.ts +8 -0
- package/components/layout/Box/index.js +3 -0
- package/components/layout/Drawer/index.d.ts +13 -0
- package/components/layout/{Side/Side.js → Drawer/index.js} +12 -12
- package/components/layout/Flex/index.d.ts +7 -7
- package/components/layout/Flex/index.js +2 -11
- package/components/layout/Grid/index.d.ts +3 -2
- package/components/layout/Grid/index.js +3 -6
- package/components/layout/Popin/index.d.ts +27 -6
- package/components/layout/Popin/index.js +65 -41
- package/components/layout/Side/index.d.ts +0 -1
- package/components/layout/Side/index.js +2 -2
- package/components/layout/index.d.ts +2 -0
- package/components/layout/index.js +2 -0
- package/components/loaders/ProgressLoader/index.d.ts +0 -1
- package/components/loaders/ProgressLoader/index.js +3 -3
- package/components/message/Alert/index.d.ts +22 -3
- package/components/message/Alert/index.js +31 -23
- package/components/message/Log/index.js +1 -1
- package/components/message/Notification/Badge.js +2 -2
- package/components/message/Notification/index.js +4 -6
- package/components/message/StatusNotification/index.d.ts +11 -0
- package/components/message/StatusNotification/index.js +33 -0
- package/components/message/Tip/index.d.ts +7 -0
- package/components/message/Tip/index.js +43 -0
- package/components/message/Tooltip/index.d.ts +3 -3
- package/components/message/Tooltip/index.js +1 -1
- package/components/message/Tooltip/styles.js +3 -3
- package/components/message/index.d.ts +3 -0
- package/components/message/index.js +3 -0
- package/components/navigation/Aside/index.d.ts +5 -1
- package/components/navigation/Breadcrumb/index.js +6 -6
- package/components/navigation/Header/index.d.ts +3 -3
- package/components/navigation/progress/ProgressBar/Onboarding.d.ts +0 -1
- package/components/navigation/progress/ProgressBar/Onboarding.js +6 -6
- package/components/navigation/progress/Stepper/index.js +9 -9
- package/components/navigation/sideBar/Item/Item.d.ts +4 -3
- package/components/navigation/sideBar/Item/Item.js +34 -16
- package/components/navigation/sideBar/Logo/Logo.d.ts +0 -1
- package/components/navigation/sideBar/SideBar/SideBar.d.ts +1 -2
- package/components/navigation/sideBar/SideBar/SideBar.js +14 -6
- package/components/navigation/sideBar/Toggle/Toggle.d.ts +0 -1
- package/components/navigation/sideBar/Toggle/Toggle.js +2 -2
- package/components/styled.d.ts +16 -0
- package/components/styled.js +13 -0
- package/components/tabs/Bar/index.js +4 -4
- package/components/tabs/Chip/index.d.ts +13 -0
- package/components/tabs/Chip/index.js +21 -0
- package/components/tabs/Pill/index.js +7 -7
- package/components/tabs/Tabs/index.js +8 -7
- package/components/tabs/index.d.ts +2 -0
- package/components/tabs/index.js +2 -0
- package/package.json +4 -4
- package/styles/InvertTheme.d.ts +1 -8
- package/styles/StyleProvider.d.ts +3 -3
- package/styles/StyleProvider.js +3 -3
- package/styles/global.d.ts +1 -0
- package/styles/global.js +15 -36
- package/styles/index.d.ts +0 -1
- package/styles/index.js +0 -1
- package/styles/theme.d.ts +5 -2
- package/styles/theme.js +7 -8
- package/components/layout/Side/Side.d.ts +0 -13
- package/styles/reset.d.ts +0 -2
- package/styles/reset.js +0 -62
|
@@ -11,43 +11,52 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import styled, { css } from "styled-components";
|
|
13
13
|
import { typography } from "styled-system";
|
|
14
|
-
import React, { useCallback } from "react";
|
|
14
|
+
import React, { useState, useMemo, useCallback } from "react";
|
|
15
15
|
import FlexBox from "../../layout/Flex";
|
|
16
16
|
import Text from "../../asorted/Text";
|
|
17
17
|
import { rgba } from "../../../styles/helpers";
|
|
18
18
|
export const InputContainer = styled.div `
|
|
19
19
|
display: flex;
|
|
20
20
|
height: 48px;
|
|
21
|
-
border: ${(p) => `1px solid ${p.theme.colors.
|
|
21
|
+
border: ${(p) => `1px solid ${p.theme.colors.neutral.c40}`};
|
|
22
22
|
border-radius: 24px;
|
|
23
23
|
transition: all 0.2s ease;
|
|
24
|
-
color: ${(p) => p.theme.colors.
|
|
24
|
+
color: ${(p) => p.theme.colors.neutral.c100};
|
|
25
25
|
|
|
26
26
|
${(p) => p.focus &&
|
|
27
27
|
!p.error &&
|
|
28
|
+
!p.warning &&
|
|
28
29
|
css `
|
|
29
|
-
border: 1px solid ${p.theme.colors.
|
|
30
|
-
box-shadow: 0 0 0 4px ${rgba(p.theme.colors.
|
|
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
32
|
`};
|
|
32
33
|
|
|
33
34
|
${(p) => p.error &&
|
|
34
35
|
!p.disabled &&
|
|
35
36
|
css `
|
|
36
|
-
border: 1px solid ${p.theme.colors.
|
|
37
|
+
border: 1px solid ${p.theme.colors.error.c100};
|
|
37
38
|
`};
|
|
38
39
|
|
|
39
40
|
${(p) => !p.error &&
|
|
41
|
+
p.warning &&
|
|
42
|
+
!p.disabled &&
|
|
43
|
+
css `
|
|
44
|
+
border: 1px solid ${p.theme.colors.warning.c80};
|
|
45
|
+
`};
|
|
46
|
+
|
|
47
|
+
${(p) => !p.error &&
|
|
48
|
+
!p.warning &&
|
|
40
49
|
!p.disabled &&
|
|
41
50
|
css `
|
|
42
51
|
&:hover {
|
|
43
|
-
border: ${!p.disabled && `1px solid ${p.theme.colors.
|
|
52
|
+
border: ${!p.disabled && `1px solid ${p.theme.colors.primary.c80}`};
|
|
44
53
|
}
|
|
45
54
|
`};
|
|
46
55
|
|
|
47
56
|
${(p) => p.disabled &&
|
|
48
57
|
css `
|
|
49
|
-
color: ${p.theme.colors.
|
|
50
|
-
background: ${(p) => p.theme.colors.
|
|
58
|
+
color: ${p.theme.colors.neutral.c60};
|
|
59
|
+
background: ${(p) => p.theme.colors.neutral.c20};
|
|
51
60
|
`};
|
|
52
61
|
`;
|
|
53
62
|
export const BaseInput = styled.input.attrs({
|
|
@@ -57,7 +66,7 @@ export const BaseInput = styled.input.attrs({
|
|
|
57
66
|
height: 100%;
|
|
58
67
|
width: 100%;
|
|
59
68
|
border: 0;
|
|
60
|
-
caret-color: ${(p) => p.error ? p.theme.colors.
|
|
69
|
+
caret-color: ${(p) => (p.error ? p.theme.colors.error.c100 : p.theme.colors.primary.c80)};
|
|
61
70
|
background: none;
|
|
62
71
|
outline: none;
|
|
63
72
|
cursor: ${(p) => (p.disabled ? "not-allowed" : "text")};
|
|
@@ -67,7 +76,7 @@ export const BaseInput = styled.input.attrs({
|
|
|
67
76
|
padding-left: 20px;
|
|
68
77
|
padding-right: 20px;
|
|
69
78
|
&::placeholder {
|
|
70
|
-
color: ${(p) => p.disabled ? p.theme.colors.
|
|
79
|
+
color: ${(p) => (p.disabled ? p.theme.colors.neutral.c50 : p.theme.colors.neutral.c70)};
|
|
71
80
|
}
|
|
72
81
|
|
|
73
82
|
/* Hide type=number arrow for Chrome, Safari, Edge, Opera */
|
|
@@ -85,7 +94,11 @@ export const BaseInput = styled.input.attrs({
|
|
|
85
94
|
${typography}
|
|
86
95
|
`;
|
|
87
96
|
export const InputErrorContainer = styled(Text) `
|
|
88
|
-
color: ${(p) => p.theme.colors.
|
|
97
|
+
color: ${(p) => p.theme.colors.error.c100};
|
|
98
|
+
margin-left: 12px;
|
|
99
|
+
`;
|
|
100
|
+
export const InputWarningContainer = styled(Text) `
|
|
101
|
+
color: ${(p) => p.theme.colors.warning.c80};
|
|
89
102
|
margin-left: 12px;
|
|
90
103
|
`;
|
|
91
104
|
export const InputRenderLeftContainer = styled(FlexBox).attrs(() => ({
|
|
@@ -96,13 +109,20 @@ export const InputRenderRightContainer = styled(FlexBox).attrs(() => ({
|
|
|
96
109
|
alignItems: "center",
|
|
97
110
|
pr: "16px",
|
|
98
111
|
})) ``;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
112
|
+
// Yes, this is dirty. If you can figure out a better way please change the code :).
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
|
+
const IDENTITY = (_) => _;
|
|
115
|
+
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"]);
|
|
117
|
+
const [focus, setFocus] = useState(false);
|
|
118
|
+
const inputValue = useMemo(() => serialize(value), [serialize, value]);
|
|
119
|
+
const handleChange = useCallback((e) => {
|
|
120
|
+
onChange && onChange(deserialize(e.target.value));
|
|
121
|
+
onChangeEvent && onChangeEvent(e);
|
|
122
|
+
}, [onChange, onChangeEvent, deserialize]);
|
|
103
123
|
const inner = (React.createElement(React.Fragment, null,
|
|
104
124
|
typeof renderLeft === "function" ? renderLeft(props) : renderLeft,
|
|
105
|
-
React.createElement(BaseInput, Object.assign({}, htmlInputProps, { disabled: disabled, error: error, onChange: handleChange, value:
|
|
125
|
+
React.createElement(BaseInput, Object.assign({ ref: ref }, htmlInputProps, { disabled: disabled, error: error, warning: warning, onChange: handleChange, value: inputValue, onFocus: (event) => {
|
|
106
126
|
setFocus(true);
|
|
107
127
|
htmlInputProps.onFocus && htmlInputProps.onFocus(event);
|
|
108
128
|
}, onBlur: (event) => {
|
|
@@ -114,6 +134,9 @@ export default function Input(props) {
|
|
|
114
134
|
return (React.createElement(FlexBox, { alignItems: "stretch", style: { height: "100%" } }, inner));
|
|
115
135
|
}
|
|
116
136
|
return (React.createElement("div", null,
|
|
117
|
-
React.createElement(InputContainer, { disabled: disabled, focus: focus, error: error }, inner),
|
|
118
|
-
error && !disabled && React.createElement(
|
|
137
|
+
React.createElement(InputContainer, Object.assign({ disabled: disabled, focus: focus, error: error, warning: warning }, containerProps), inner),
|
|
138
|
+
(error || warning) && !disabled && (React.createElement(FlexBox, { flexDirection: "column", rowGap: 2, mt: 2 },
|
|
139
|
+
error && React.createElement(InputErrorContainer, { variant: "small" }, error),
|
|
140
|
+
warning && React.createElement(InputWarningContainer, { variant: "small" }, warning)))));
|
|
119
141
|
}
|
|
142
|
+
export default React.forwardRef(Input);
|
|
@@ -3,7 +3,10 @@ import styled from "styled-components";
|
|
|
3
3
|
import Text from "../../asorted/Text";
|
|
4
4
|
import CheckAloneRegular from "@ledgerhq/icons-ui/react/CheckAloneRegular";
|
|
5
5
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
6
|
-
const Icon =
|
|
6
|
+
const Icon = () => React.cloneElement(CheckAloneRegular({ size: 13, color: "white" }), {
|
|
7
|
+
// the xmlns attribute is required to properly display the checkbox
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
9
|
+
});
|
|
7
10
|
const CheckMarkIcon = encodeURIComponent(renderToStaticMarkup(React.createElement(Icon, null)));
|
|
8
11
|
const Input = styled.input `
|
|
9
12
|
background-color: transparent;
|
|
@@ -14,7 +17,7 @@ const Input = styled.input `
|
|
|
14
17
|
width: ${(p) => p.theme.space[7]}px;
|
|
15
18
|
height: ${(p) => p.theme.space[7]}px;
|
|
16
19
|
appearance: none;
|
|
17
|
-
border: 1px solid ${(props) => props.theme.colors.
|
|
20
|
+
border: 1px solid ${(props) => props.theme.colors.neutral.c90};
|
|
18
21
|
box-shadow: none;
|
|
19
22
|
|
|
20
23
|
&:checked {
|
|
@@ -39,7 +42,7 @@ const Input = styled.input `
|
|
|
39
42
|
}
|
|
40
43
|
`;
|
|
41
44
|
const Label = styled(Text).attrs({ type: "body", fontWeight: "500" }) `
|
|
42
|
-
color: ${(props) => props.theme.colors.
|
|
45
|
+
color: ${(props) => props.theme.colors.neutral.c80};
|
|
43
46
|
|
|
44
47
|
/* Version when the input is checked */
|
|
45
48
|
${Input}:checked + & {
|
|
@@ -52,7 +55,7 @@ const Label = styled(Text).attrs({ type: "body", fontWeight: "500" }) `
|
|
|
52
55
|
`;
|
|
53
56
|
const Container = styled.div `
|
|
54
57
|
--ll-checkbox-color: unset;
|
|
55
|
-
color: var(--ll-checkbox-color, ${(props) => props.theme.colors.
|
|
58
|
+
color: var(--ll-checkbox-color, ${(props) => props.theme.colors.primary.c90});
|
|
56
59
|
|
|
57
60
|
display: inline-flex;
|
|
58
61
|
column-gap: ${(p) => p.theme.space[5]}px;
|
|
@@ -60,23 +63,23 @@ const Container = styled.div `
|
|
|
60
63
|
cursor: pointer;
|
|
61
64
|
|
|
62
65
|
&[data-variant="default"] {
|
|
63
|
-
--ll-checkbox-color: ${(props) => props.theme.colors.
|
|
66
|
+
--ll-checkbox-color: ${(props) => props.theme.colors.primary.c90};
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
&[data-variant="success"] {
|
|
67
|
-
--ll-checkbox-color: ${(props) => props.theme.colors.
|
|
70
|
+
--ll-checkbox-color: ${(props) => props.theme.colors.success.c100};
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
&[data-variant="error"] {
|
|
71
|
-
--ll-checkbox-color: ${(props) => props.theme.colors.
|
|
74
|
+
--ll-checkbox-color: ${(props) => props.theme.colors.error.c100};
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
&[data-disabled="true"] {
|
|
75
|
-
--ll-checkbox-color: ${(props) => props.theme.colors.
|
|
78
|
+
--ll-checkbox-color: ${(props) => props.theme.colors.neutral.c80};
|
|
76
79
|
cursor: unset;
|
|
77
80
|
}
|
|
78
81
|
`;
|
|
79
82
|
const Checkbox = ({ isDisabled = false, variant = "default", label, isChecked, name, onChange, }) => (React.createElement(Container, { "data-variant": variant, "data-disabled": isDisabled },
|
|
80
83
|
React.createElement(Input, { type: "checkbox", name: name, id: name, checked: isChecked, disabled: isDisabled, onChange: onChange }),
|
|
81
|
-
label ? (React.createElement(Label, {
|
|
84
|
+
label ? (React.createElement(Label, { as: "label", htmlFor: name }, label)) : null));
|
|
82
85
|
export default Checkbox;
|
|
@@ -20,7 +20,7 @@ import FlexBox from "../../layout/Flex";
|
|
|
20
20
|
function DropdownControl(props) {
|
|
21
21
|
const { selectProps: { label }, children, } = props;
|
|
22
22
|
return (React.createElement(components.Control, Object.assign({}, props),
|
|
23
|
-
React.createElement(Text, { fontWeight: "semiBold", variant: "paragraph", color: "
|
|
23
|
+
React.createElement(Text, { fontWeight: "semiBold", variant: "paragraph", color: "neutral.c80", mr: 2 }, label),
|
|
24
24
|
children));
|
|
25
25
|
}
|
|
26
26
|
function DropdownValueContainer(props) {
|
|
@@ -37,7 +37,7 @@ function DropdownIndicatorsContainer() {
|
|
|
37
37
|
export default function Dropdown(props) {
|
|
38
38
|
const theme = useTheme();
|
|
39
39
|
const { styles } = props, rest = __rest(props, ["styles"]);
|
|
40
|
-
return (React.createElement(SelectInput, Object.assign({ placeholder: "", isSearchable: false, styles: Object.assign({ singleValue: (provided) => (Object.assign(Object.assign({}, provided), { color: theme.colors.
|
|
40
|
+
return (React.createElement(SelectInput, Object.assign({ placeholder: "", isSearchable: false, styles: Object.assign({ singleValue: (provided) => (Object.assign(Object.assign({}, provided), { color: theme.colors.neutral.c100, margin: 0, top: undefined, position: undefined, overflow: undefined, maxWidth: undefined, transform: undefined })), input: () => ({ display: "none" }), menu: (provided) => (Object.assign(Object.assign({}, provided), { border: 0, boxShadow: "none", background: "none", width: "auto", minWidth: "200px" })) }, styles) }, rest, { components: {
|
|
41
41
|
Control: DropdownControl,
|
|
42
42
|
ValueContainer: DropdownValueContainer,
|
|
43
43
|
IndicatorsContainer: DropdownIndicatorsContainer,
|
|
@@ -1,6 +1,30 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -14,14 +14,15 @@ import Input, { InputRenderRightContainer } from "../BaseInput";
|
|
|
14
14
|
import Text from "../../asorted/Text";
|
|
15
15
|
import styled from "styled-components";
|
|
16
16
|
const Legend = styled(Text) `
|
|
17
|
-
color: ${(props) => props.theme.colors.
|
|
17
|
+
color: ${(props) => props.theme.colors.neutral.c70};
|
|
18
18
|
|
|
19
19
|
&[data-disabled="true"] {
|
|
20
|
-
color: ${(props) => props.theme.colors.
|
|
20
|
+
color: ${(props) => props.theme.colors.neutral.c50};
|
|
21
21
|
}
|
|
22
22
|
`;
|
|
23
|
-
|
|
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
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { InputProps } from "../BaseInput";
|
|
3
|
-
|
|
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
|
-
}
|
|
26
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
27
|
+
export default _default;
|
|
@@ -16,8 +16,8 @@ import Text from "../../asorted/Text";
|
|
|
16
16
|
import styled from "styled-components";
|
|
17
17
|
// TODO: Replace me with a real button as soon as they are designed
|
|
18
18
|
const MaxButton = styled.button `
|
|
19
|
-
color: ${(p) => p.active ? p.theme.colors.
|
|
20
|
-
background-color: ${(p) => p.active ? p.theme.colors.
|
|
19
|
+
color: ${(p) => (p.active ? p.theme.colors.neutral.c00 : p.theme.colors.neutral.c70)};
|
|
20
|
+
background-color: ${(p) => (p.active ? p.theme.colors.neutral.c100 : p.theme.colors.neutral.c00)};
|
|
21
21
|
border-radius: 100px;
|
|
22
22
|
border-width: 0;
|
|
23
23
|
height: 31px;
|
|
@@ -26,15 +26,27 @@ const MaxButton = styled.button `
|
|
|
26
26
|
cursor: pointer;
|
|
27
27
|
|
|
28
28
|
&:disabled {
|
|
29
|
-
color: ${(p) => p.theme.colors.
|
|
30
|
-
background-color: ${(p) => (p.active ? p.theme.colors.
|
|
29
|
+
color: ${(p) => p.theme.colors.neutral.c50};
|
|
30
|
+
background-color: ${(p) => (p.active ? p.theme.colors.neutral.c30 : "transparent")};
|
|
31
31
|
cursor: unset;
|
|
32
32
|
}
|
|
33
33
|
`;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
function serialize(value) {
|
|
35
|
+
return value ? "" + value : "";
|
|
36
|
+
}
|
|
37
|
+
function deserialize(value) {
|
|
38
|
+
try {
|
|
39
|
+
return parseFloat(value);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function NumberInput(_a, ref) {
|
|
46
|
+
var { value, onPercentClick, max, disabled } = _a, inputProps = __rest(_a, ["value", "onPercentClick", "max", "disabled"]);
|
|
47
|
+
return (React.createElement(Input, Object.assign({ ref: ref, serialize: serialize, deserialize: deserialize }, inputProps, { type: "number", value: value, max: max, disabled: disabled, renderRight: React.createElement(FlexBox, { alignItems: "center", justifyContent: "center", py: "3px", mr: "8px" }, [0.25, 0.5, 0.75, 1].map((percent) => (React.createElement(MaxButton, { key: percent, onClick: () => onPercentClick(percent), active: !!value && !!max && Number(value) === percent * Number(max), disabled: disabled },
|
|
37
48
|
React.createElement(Text, { variant: "tiny", color: "inherit" },
|
|
38
49
|
percent * 100,
|
|
39
50
|
"%"))))) })));
|
|
40
51
|
}
|
|
52
|
+
export default React.forwardRef(NumberInput);
|
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { InputProps } from "../BaseInput";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInput").CommonProps, "onChange" | "value"> & {
|
|
4
|
+
value: string;
|
|
5
|
+
onChange?: ((value: string) => void) | undefined;
|
|
6
|
+
onChangeEvent?: React.ChangeEventHandler<HTMLInputElement> | undefined;
|
|
7
|
+
renderLeft?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
|
|
8
|
+
renderRight?: React.ReactNode | ((props: InputProps<string>) => 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: string) => string) | undefined;
|
|
23
|
+
deserialize?: ((value: string) => string) | undefined;
|
|
24
|
+
} & {
|
|
25
|
+
onQrCodeClick?: ((e: React.FormEvent<HTMLButtonElement>) => void) | undefined;
|
|
26
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
27
|
+
export default _default;
|
|
@@ -22,19 +22,20 @@ const QrCodeButton = styled.button `
|
|
|
22
22
|
height: 32px;
|
|
23
23
|
border-radius: 50%;
|
|
24
24
|
border-width: 0;
|
|
25
|
-
color: ${(p) => p.theme.colors.
|
|
26
|
-
background-color: ${(p) => p.theme.colors.
|
|
25
|
+
color: ${(p) => p.theme.colors.neutral.c00};
|
|
26
|
+
background-color: ${(p) => p.theme.colors.neutral.c100};
|
|
27
27
|
cursor: pointer;
|
|
28
28
|
|
|
29
29
|
&:disabled {
|
|
30
|
-
background-color: ${(p) => p.theme.colors.
|
|
31
|
-
color: ${(p) => p.theme.colors.
|
|
30
|
+
background-color: ${(p) => p.theme.colors.neutral.c30};
|
|
31
|
+
color: ${(p) => p.theme.colors.neutral.c50};
|
|
32
32
|
cursor: unset;
|
|
33
33
|
}
|
|
34
34
|
`;
|
|
35
|
-
|
|
35
|
+
function QrCodeInput(_a, ref) {
|
|
36
36
|
var { onQrCodeClick } = _a, inputProps = __rest(_a, ["onQrCodeClick"]);
|
|
37
|
-
return (React.createElement(Input, Object.assign({}, inputProps, { renderRight: React.createElement(FlexBox, { alignItems: "center", justifyContent: "center", pr: "8px" },
|
|
37
|
+
return (React.createElement(Input, Object.assign({ ref: ref }, inputProps, { renderRight: React.createElement(FlexBox, { alignItems: "center", justifyContent: "center", pr: "8px" },
|
|
38
38
|
React.createElement(QrCodeButton, { onClick: onQrCodeClick, disabled: inputProps.disabled },
|
|
39
39
|
React.createElement(QrCodeMedium, { size: "20px" }))) })));
|
|
40
40
|
}
|
|
41
|
+
export default React.forwardRef(QrCodeInput);
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { InputProps } from "../BaseInput";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInput").CommonProps, "onChange" | "value"> & {
|
|
4
|
+
value: string;
|
|
5
|
+
onChange?: ((value: string) => void) | undefined;
|
|
6
|
+
onChangeEvent?: React.ChangeEventHandler<HTMLInputElement> | undefined;
|
|
7
|
+
renderLeft?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
|
|
8
|
+
renderRight?: React.ReactNode | ((props: InputProps<string>) => 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: string) => string) | undefined;
|
|
23
|
+
deserialize?: ((value: string) => string) | undefined;
|
|
24
|
+
} & {
|
|
25
|
+
onMaxClick?: ((e: React.FormEvent<HTMLButtonElement>) => void) | undefined;
|
|
26
|
+
price?: string | undefined;
|
|
27
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
28
|
+
export default _default;
|
|
@@ -15,8 +15,8 @@ import FlexBox from "../../layout/Flex";
|
|
|
15
15
|
import Text from "../../asorted/Text";
|
|
16
16
|
import styled from "styled-components";
|
|
17
17
|
const MaxButton = styled.button `
|
|
18
|
-
color: ${(p) => p.theme.colors.
|
|
19
|
-
background-color: ${(p) => p.theme.colors.
|
|
18
|
+
color: ${(p) => p.theme.colors.neutral.c00};
|
|
19
|
+
background-color: ${(p) => p.theme.colors.neutral.c100};
|
|
20
20
|
border-radius: 100px;
|
|
21
21
|
border-width: 0;
|
|
22
22
|
padding-left: 14px;
|
|
@@ -25,22 +25,23 @@ const MaxButton = styled.button `
|
|
|
25
25
|
cursor: pointer;
|
|
26
26
|
|
|
27
27
|
&:disabled {
|
|
28
|
-
background-color: ${(p) => p.theme.colors.
|
|
29
|
-
color: ${(p) => p.theme.colors.
|
|
28
|
+
background-color: ${(p) => p.theme.colors.neutral.c30};
|
|
29
|
+
color: ${(p) => p.theme.colors.neutral.c50};
|
|
30
30
|
cursor: unset;
|
|
31
31
|
}
|
|
32
32
|
`;
|
|
33
33
|
const Legend = styled(Text) `
|
|
34
|
-
color: ${(p) => p.theme.colors.
|
|
34
|
+
color: ${(p) => p.theme.colors.neutral.c70};
|
|
35
35
|
|
|
36
36
|
&[data-disabled="true"] {
|
|
37
|
-
color: ${(p) => p.theme.colors.
|
|
37
|
+
color: ${(p) => p.theme.colors.neutral.c50};
|
|
38
38
|
}
|
|
39
39
|
`;
|
|
40
|
-
|
|
40
|
+
function QuantityInput(_a, ref) {
|
|
41
41
|
var { onMaxClick, price } = _a, inputProps = __rest(_a, ["onMaxClick", "price"]);
|
|
42
|
-
return (React.createElement(Input, Object.assign({}, inputProps, { type: "number", renderRight: React.createElement(FlexBox, { alignItems: "center", justifyContent: "center", pr: "3px", py: "3px" },
|
|
42
|
+
return (React.createElement(Input, Object.assign({ ref: ref }, inputProps, { type: "number", renderRight: React.createElement(FlexBox, { alignItems: "center", justifyContent: "center", pr: "3px", py: "3px" },
|
|
43
43
|
price && (React.createElement(Legend, { variant: "body", pr: "12px", "data-disabled": inputProps.disabled }, price)),
|
|
44
44
|
React.createElement(MaxButton, { onClick: onMaxClick, disabled: inputProps.disabled },
|
|
45
45
|
React.createElement(Text, { variant: "tiny", color: "currentColor" }, "Max"))) })));
|
|
46
46
|
}
|
|
47
|
+
export default React.forwardRef(QuantityInput);
|
|
@@ -4,5 +4,8 @@ export declare type RadioElementProps = InputAttributes & {
|
|
|
4
4
|
variant?: "default" | "success" | "error";
|
|
5
5
|
label: string;
|
|
6
6
|
};
|
|
7
|
-
declare const
|
|
8
|
-
|
|
7
|
+
declare const Element: {
|
|
8
|
+
({ label, value, disabled, variant, ...props }: RadioElementProps): JSX.Element;
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|
|
11
|
+
export default Element;
|
|
@@ -15,10 +15,10 @@ import { rgba } from "../../../styles/helpers";
|
|
|
15
15
|
import Text from "../../asorted/Text";
|
|
16
16
|
import { RadioContext } from "./index";
|
|
17
17
|
const Label = styled(Text) `
|
|
18
|
-
color: var(--ledger-ui-checkbox-color, ${(p) => p.theme.colors.
|
|
18
|
+
color: var(--ledger-ui-checkbox-color, ${(p) => p.theme.colors.neutral.c100});
|
|
19
19
|
`;
|
|
20
20
|
const Input = styled.input `
|
|
21
|
-
--ledger-ui-checkbox-color: ${(p) => p.theme.colors.
|
|
21
|
+
--ledger-ui-checkbox-color: ${(p) => p.theme.colors.neutral.c50};
|
|
22
22
|
--ledger-ui-checkbox-size: 1.25rem;
|
|
23
23
|
|
|
24
24
|
position: relative;
|
|
@@ -46,17 +46,17 @@ const Input = styled.input `
|
|
|
46
46
|
|
|
47
47
|
&[data-variant="default"] {
|
|
48
48
|
:hover {
|
|
49
|
-
--ledger-ui-checkbox-color: ${(p) => p.theme.colors.
|
|
49
|
+
--ledger-ui-checkbox-color: ${(p) => p.theme.colors.primary.c90};
|
|
50
50
|
}
|
|
51
51
|
:active {
|
|
52
|
-
--ledger-ui-checkbox-color: ${(p) => p.theme.colors.
|
|
52
|
+
--ledger-ui-checkbox-color: ${(p) => p.theme.colors.primary.c100};
|
|
53
53
|
}
|
|
54
54
|
:checked,
|
|
55
55
|
:focus {
|
|
56
|
-
--ledger-ui-checkbox-color: ${(p) => p.theme.colors.
|
|
56
|
+
--ledger-ui-checkbox-color: ${(p) => p.theme.colors.primary.c80};
|
|
57
57
|
}
|
|
58
58
|
:focus {
|
|
59
|
-
box-shadow: 0px 0px 0px 4px ${(p) => rgba(p.theme.colors.
|
|
59
|
+
box-shadow: 0px 0px 0px 4px ${(p) => rgba(p.theme.colors.primary.c60, 0.48)};
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -64,10 +64,10 @@ const Input = styled.input `
|
|
|
64
64
|
:hover,
|
|
65
65
|
:checked:not([disabled]),
|
|
66
66
|
:checked:not([disabled]) + ${Label}, :focus {
|
|
67
|
-
--ledger-ui-checkbox-color: ${(p) => p.theme.colors.
|
|
67
|
+
--ledger-ui-checkbox-color: ${(p) => p.theme.colors.success.c100};
|
|
68
68
|
}
|
|
69
69
|
:focus {
|
|
70
|
-
box-shadow: 0px 0px 0px 4px ${(p) => rgba(p.theme.colors.
|
|
70
|
+
box-shadow: 0px 0px 0px 4px ${(p) => rgba(p.theme.colors.success.c100, 0.48)};
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -75,17 +75,17 @@ const Input = styled.input `
|
|
|
75
75
|
:hover,
|
|
76
76
|
:checked:not([disabled]),
|
|
77
77
|
:checked:not([disabled]) + ${Label}, :focus {
|
|
78
|
-
--ledger-ui-checkbox-color: ${(p) => p.theme.colors.
|
|
78
|
+
--ledger-ui-checkbox-color: ${(p) => p.theme.colors.error.c100};
|
|
79
79
|
}
|
|
80
80
|
:focus {
|
|
81
|
-
box-shadow: 0px 0px 0px 4px ${(p) => rgba(p.theme.colors.
|
|
81
|
+
box-shadow: 0px 0px 0px 4px ${(p) => rgba(p.theme.colors.error.c100, 0.48)};
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
&[data-variant]:disabled {
|
|
86
|
-
--ledger-ui-checkbox-color: ${(p) => p.theme.colors.
|
|
86
|
+
--ledger-ui-checkbox-color: ${(p) => p.theme.colors.neutral.c40};
|
|
87
87
|
cursor: unset;
|
|
88
|
-
background-color: ${(p) => p.theme.colors.
|
|
88
|
+
background-color: ${(p) => p.theme.colors.neutral.c30};
|
|
89
89
|
}
|
|
90
90
|
`;
|
|
91
91
|
const RadioElement = styled.label.attrs({ tabIndex: -1 }) `
|
|
@@ -93,7 +93,7 @@ const RadioElement = styled.label.attrs({ tabIndex: -1 }) `
|
|
|
93
93
|
column-gap: 0.75rem;
|
|
94
94
|
align-items: center;
|
|
95
95
|
`;
|
|
96
|
-
|
|
96
|
+
const Element = (_a) => {
|
|
97
97
|
var { label, value, disabled, variant = "default" } = _a, props = __rest(_a, ["label", "value", "disabled", "variant"]);
|
|
98
98
|
const context = useContext(RadioContext);
|
|
99
99
|
if (context === undefined)
|
|
@@ -107,3 +107,5 @@ export default (_a) => {
|
|
|
107
107
|
React.createElement(Input, Object.assign({ type: "radio", "data-variant": variant, checked: isChecked, disabled: disabled, onChange: handleChange, value: value, name: context.name }, props)),
|
|
108
108
|
React.createElement(Label, { variant: "paragraph" }, label)));
|
|
109
109
|
};
|
|
110
|
+
Element.displayName = "Radio.Element"; // For easy identification in the React devtools & in storybook
|
|
111
|
+
export default Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { InputHTMLAttributes } from "react";
|
|
2
|
+
import { FlexBoxProps } from "../../layout/Flex";
|
|
3
|
+
declare type ElementState = {
|
|
4
|
+
checked: boolean;
|
|
5
|
+
disabled: boolean | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare const Label: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, import("../../asorted/Text").TextProps & ElementState, keyof import("../../asorted/Text").TextProps>;
|
|
8
|
+
declare type InputAttributes = Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "onChange" | "name">;
|
|
9
|
+
export declare type RadioListElementProps = InputAttributes & {
|
|
10
|
+
/**
|
|
11
|
+
* The string or component that will be rendered as label of this radio element
|
|
12
|
+
* If it's a component, it's rendered with these props: { checked:boolean; disabled:boolean }
|
|
13
|
+
* */
|
|
14
|
+
label: string | React.ComponentType<ElementState> | ((arg1: ElementState) => JSX.Element);
|
|
15
|
+
/** Flex props to pass to the container */
|
|
16
|
+
containerProps?: FlexBoxProps;
|
|
17
|
+
};
|
|
18
|
+
declare const ListElement: {
|
|
19
|
+
({ label, value, disabled, containerProps, ...props }: RadioListElementProps): JSX.Element;
|
|
20
|
+
displayName: string;
|
|
21
|
+
};
|
|
22
|
+
export default ListElement;
|