@stokr/components-library 3.0.24 → 3.0.25
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/dist/components/VerifyEmailModal/VerifyEmailModal.js +0 -2
- package/dist/components/headerHo/HeaderHo.js +0 -2
- package/dist/index.js +34 -36
- package/dist/static/fonts/Ionicons/Ionicons.ttf.js +1 -3
- package/dist/static/fonts/Ionicons/Ionicons.woff.js +1 -3
- package/dist/static/fonts/Ionicons/Ionicons.woff2.js +1 -3
- package/dist/static/fonts/OpenSans/OpenSans-Bold.ttf.js +1 -3
- package/dist/static/fonts/OpenSans/OpenSans-Bold.woff.js +1 -3
- package/dist/static/fonts/OpenSans/OpenSans-Bold.woff2.js +1 -3
- package/dist/static/fonts/OpenSans/OpenSans-ExtraBold.ttf.js +1 -3
- package/dist/static/fonts/OpenSans/OpenSans-ExtraBold.woff.js +1 -3
- package/dist/static/fonts/OpenSans/OpenSans-ExtraBold.woff2.js +1 -3
- package/dist/static/fonts/OpenSans/OpenSans-Light.ttf.js +1 -3
- package/dist/static/fonts/OpenSans/OpenSans-Light.woff.js +1 -3
- package/dist/static/fonts/OpenSans/OpenSans-Light.woff2.js +1 -3
- package/dist/static/fonts/OpenSans/OpenSans-Regular.ttf.js +1 -3
- package/dist/static/fonts/OpenSans/OpenSans-Regular.woff.js +1 -3
- package/dist/static/fonts/OpenSans/OpenSans-Regular.woff2.js +1 -3
- package/dist/static/fonts/OpenSans/OpenSans-SemiBold.ttf.js +1 -3
- package/dist/static/fonts/OpenSans/OpenSans-SemiBold.woff.js +1 -3
- package/dist/static/fonts/OpenSans/OpenSans-SemiBold.woff2.js +1 -3
- package/dist/static/fonts/icomoon/icomoon.eot.js +1 -3
- package/dist/static/fonts/icomoon/icomoon.svg.js +1 -3
- package/dist/static/fonts/icomoon/icomoon.ttf.js +1 -3
- package/dist/static/fonts/icomoon/icomoon.woff.js +1 -3
- package/dist/static/images/address-refreshing.gif.js +1 -3
- package/dist/static/images/arrow-down-black.svg.js +1 -3
- package/dist/static/images/avatar-placeholder.png.js +1 -3
- package/dist/static/images/background3.png +0 -0
- package/dist/static/images/background3.png.js +1 -3
- package/dist/static/images/currency/bitcoin-logo.png +0 -0
- package/dist/static/images/currency/bitcoin-logo.png.js +4 -0
- package/dist/static/images/currency/bmn2-logo.png +0 -0
- package/dist/static/images/currency/bmn2-logo.png.js +4 -0
- package/dist/static/images/currency/eth_logo.svg.js +4 -0
- package/dist/static/images/currency/usdc-logo.svg.js +4 -0
- package/dist/static/images/currency/usdq-logo.png.js +4 -0
- package/dist/static/images/currency/usdt-logo.png +0 -0
- package/dist/static/images/currency/usdt-logo.png.js +4 -0
- package/dist/static/images/early-adopter.png.js +1 -3
- package/dist/static/images/external-link-icon.svg.js +1 -3
- package/dist/static/images/google_auth.png.js +1 -3
- package/dist/static/images/graduation.png.js +1 -3
- package/dist/static/images/mangopay.svg.js +1 -3
- package/dist/static/images/process-waiting.gif.js +1 -3
- package/dist/static/images/social/Facebook_Logo.png +0 -0
- package/dist/static/images/social/Facebook_Logo.png.js +1 -3
- package/dist/static/images/social/LI-In-Bug.png.js +1 -3
- package/dist/static/images/social/Telegram-Logo.png +0 -0
- package/dist/static/images/social/Telegram-Logo.png.js +1 -3
- package/dist/static/images/social/X-logo-black.png +0 -0
- package/dist/static/images/social/X-logo-black.png.js +1 -3
- package/dist/static/images/social/youtube_social_circle_red.png.js +1 -3
- package/dist/utils/fix-decimals.js +0 -1
- package/dist/utils/formatCurrencyValue.js +8 -5
- package/package.json +3 -4
- package/dist/components/InvestCalculator/InvestCalculator.js +0 -283
- package/dist/components/InvestCalculator/InvestCalculator.styles.js +0 -94
- package/dist/static/images/background.png +0 -0
- package/dist/static/images/bitcoin-logo.svg +0 -9
- package/dist/static/images/bitcoin-logo.svg.js +0 -6
- package/dist/static/images/bmn2-logo.svg +0 -18
- package/dist/static/images/bmn2-logo.svg.js +0 -6
- package/dist/static/images/eth_logo.svg.js +0 -6
- package/dist/static/images/face-scan-icon.svg +0 -1
- package/dist/static/images/usdc-logo.svg.js +0 -6
- package/dist/static/images/usdq-logo.png.js +0 -6
- /package/dist/static/images/{eth.svg → currency/eth.svg} +0 -0
- /package/dist/static/images/{eth_logo.svg → currency/eth_logo.svg} +0 -0
- /package/dist/static/images/{eur.svg → currency/eur.svg} +0 -0
- /package/dist/static/images/{usdc-logo.svg → currency/usdc-logo.svg} +0 -0
- /package/dist/static/images/{usdq-logo.png → currency/usdq-logo.png} +0 -0
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
const __assetBase = import.meta.url;
|
|
3
|
-
const YtLogo = new URL(__assetPath, __assetBase).href;
|
|
1
|
+
const YtLogo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA25pVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTM4IDc5LjE1OTgyNCwgMjAxNi8wOS8xNC0wMTowOTowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLz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/usdc-logo.svg.js";
|
|
2
|
-
import USDQIcon from "../static/images/usdq-logo.png.js";
|
|
3
|
-
import BitcoinLogo from "../static/images/bitcoin-logo.
|
|
4
|
-
import BMN2Logo from "../static/images/bmn2-logo.
|
|
5
|
-
import ETHLogo from "../static/images/eth_logo.svg.js";
|
|
1
|
+
import USDCICon from "../static/images/currency/usdc-logo.svg.js";
|
|
2
|
+
import USDQIcon from "../static/images/currency/usdq-logo.png.js";
|
|
3
|
+
import BitcoinLogo from "../static/images/currency/bitcoin-logo.png.js";
|
|
4
|
+
import BMN2Logo from "../static/images/currency/bmn2-logo.png.js";
|
|
5
|
+
import ETHLogo from "../static/images/currency/eth_logo.svg.js";
|
|
6
|
+
import USDTLogo from "../static/images/currency/usdt-logo.png.js";
|
|
6
7
|
const formatCurrencyValue = (currency, value, tokenDecimals = 2, options = {}) => {
|
|
7
8
|
const { valueFirst = false } = options;
|
|
8
9
|
const [symbol, decimals] = {
|
|
@@ -69,6 +70,8 @@ const getCurrencyIcon = (currency, customIcon) => {
|
|
|
69
70
|
case "usdq":
|
|
70
71
|
case "usdq-fb":
|
|
71
72
|
return USDQIcon;
|
|
73
|
+
case "usdt":
|
|
74
|
+
return USDTLogo;
|
|
72
75
|
case "bmn2":
|
|
73
76
|
return BMN2Logo;
|
|
74
77
|
case "eth":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stokr/components-library",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.25",
|
|
4
4
|
"description": "STOKR - Components Library",
|
|
5
5
|
"author": "Bilal Hodzic <bilal@stokr.io>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,7 +51,6 @@
|
|
|
51
51
|
"ajv": "^8.18.0",
|
|
52
52
|
"axios": "^1.13.5",
|
|
53
53
|
"bignumber.js": "^9.1.1",
|
|
54
|
-
"d3": "^7.8.3",
|
|
55
54
|
"date-fns": "^4.1.0",
|
|
56
55
|
"date-fns-tz": "^3.2.0",
|
|
57
56
|
"dompurify": "^3.2.4",
|
|
@@ -96,8 +95,6 @@
|
|
|
96
95
|
},
|
|
97
96
|
"devDependencies": {
|
|
98
97
|
"@chromatic-com/storybook": "^5.0.0",
|
|
99
|
-
"cross-env": "^10.1.0",
|
|
100
|
-
"depcheck": "^1.4.7",
|
|
101
98
|
"@eslint-react/eslint-plugin": "^1.53.1",
|
|
102
99
|
"@eslint/js": "^9.39.2",
|
|
103
100
|
"@storybook/addon-docs": "^10.2.0",
|
|
@@ -110,6 +107,8 @@
|
|
|
110
107
|
"@typescript-eslint/eslint-plugin": "^8.53.1",
|
|
111
108
|
"@typescript-eslint/parser": "^8.53.1",
|
|
112
109
|
"@vitejs/plugin-react": "^5.1.2",
|
|
110
|
+
"cross-env": "^10.1.0",
|
|
111
|
+
"depcheck": "^1.4.7",
|
|
113
112
|
"eslint": "^9.39.2",
|
|
114
113
|
"eslint-config-prettier": "^10.1.8",
|
|
115
114
|
"eslint-plugin-prettier": "^5.5.5",
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { PureComponent } from "react";
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import { yupToFormErrors } from "formik";
|
|
5
|
-
import * as Yup from "yup";
|
|
6
|
-
import { Input } from "../Input/Input.js";
|
|
7
|
-
import { Wrapper, Container, Title, InputWrap, Caption, StyledFormError, EqualSign } from "./InvestCalculator.styles.js";
|
|
8
|
-
import fixDecimals from "../../utils/fix-decimals.js";
|
|
9
|
-
import { BigNumber } from "bignumber.js";
|
|
10
|
-
const InvestCalculatorCurrencies = {
|
|
11
|
-
EUR: "eur",
|
|
12
|
-
GUSD: "gusd",
|
|
13
|
-
USDT: "usdt",
|
|
14
|
-
CRYPTO: "crypto"
|
|
15
|
-
};
|
|
16
|
-
const getNumericPart = (input) => {
|
|
17
|
-
let match = input.replace(/,/, ".").match(/[1-9]\d*(\.\d*)?|\.\d*/);
|
|
18
|
-
return match ? match[0].replace(/^\./, "0.") : "0";
|
|
19
|
-
};
|
|
20
|
-
class InvestCalculator extends PureComponent {
|
|
21
|
-
state = {
|
|
22
|
-
tokens: 0,
|
|
23
|
-
currencyValue: 0,
|
|
24
|
-
selectedCurrencyValue: 0,
|
|
25
|
-
selectedCurrency: this.props.userSelectedCurrency === "gemini" ? InvestCalculatorCurrencies.GUSD : InvestCalculatorCurrencies.USDT,
|
|
26
|
-
// selectedCurrency: InvestCalculatorCurrencies.ETH,
|
|
27
|
-
errors: {}
|
|
28
|
-
};
|
|
29
|
-
componentDidMount() {
|
|
30
|
-
const { isIban } = this.props;
|
|
31
|
-
if (isIban) {
|
|
32
|
-
this.setState({
|
|
33
|
-
selectedCurrency: InvestCalculatorCurrencies.EUR
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
normalizeCurrencySelected = (currencySelected) => {
|
|
38
|
-
if (currencySelected === "euro") return "eur";
|
|
39
|
-
if (currencySelected === "gemini") return "gusd";
|
|
40
|
-
if (currencySelected === "tether") return "usdt";
|
|
41
|
-
};
|
|
42
|
-
// onFocus = (e, field) => {
|
|
43
|
-
// const { onFocus: onFocusProp = () => {} } = this.props
|
|
44
|
-
// onFocusProp(e, field)
|
|
45
|
-
// }
|
|
46
|
-
// onBlur = (e, field) => {
|
|
47
|
-
// const { onBlur: onBlurProp = () => {} } = this.props
|
|
48
|
-
// onBlurProp(e, field)
|
|
49
|
-
// }
|
|
50
|
-
onChange = (e, field) => {
|
|
51
|
-
const { onChange: onChangeProp = () => {
|
|
52
|
-
} } = this.props;
|
|
53
|
-
onChangeProp(e, field);
|
|
54
|
-
};
|
|
55
|
-
onErrors = (e, field) => {
|
|
56
|
-
const { onErrors: onErrorsProp = () => {
|
|
57
|
-
} } = this.props;
|
|
58
|
-
onErrorsProp(e, field);
|
|
59
|
-
};
|
|
60
|
-
changeTokens = (e, field) => {
|
|
61
|
-
const { exchangeRate, available, name, userSelectedCurrency } = this.props;
|
|
62
|
-
const { selectedCurrency } = this.state;
|
|
63
|
-
let tokensInput = getNumericPart(e.target.value);
|
|
64
|
-
let tokens = BigNumber(tokensInput);
|
|
65
|
-
if (tokens.gt(available)) {
|
|
66
|
-
tokens = BigNumber(available);
|
|
67
|
-
tokensInput = tokens.toFixed(4);
|
|
68
|
-
}
|
|
69
|
-
const currencyValue = tokens.times(exchangeRate[selectedCurrency]);
|
|
70
|
-
const selectedCurrencyValue = tokens * exchangeRate[this.normalizeCurrencySelected(userSelectedCurrency)];
|
|
71
|
-
this.validate({
|
|
72
|
-
tokens: tokens.toNumber(),
|
|
73
|
-
currencyValue: currencyValue.toNumber(),
|
|
74
|
-
selectedCurrency
|
|
75
|
-
});
|
|
76
|
-
this.setState(
|
|
77
|
-
{
|
|
78
|
-
tokens: tokensInput,
|
|
79
|
-
currencyValue: currencyValue.toFixed(4),
|
|
80
|
-
selectedCurrencyValue
|
|
81
|
-
},
|
|
82
|
-
() => {
|
|
83
|
-
this.onChange(
|
|
84
|
-
{
|
|
85
|
-
target: {
|
|
86
|
-
name,
|
|
87
|
-
value: tokens,
|
|
88
|
-
currencyValue,
|
|
89
|
-
currencyName: selectedCurrency,
|
|
90
|
-
selectedCurrencyValue
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
field
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
// changeCurrency = (e) => {
|
|
99
|
-
// const { exchangeRate, name, userSelectedCurrency } = this.props
|
|
100
|
-
// const { tokens } = this.state
|
|
101
|
-
// const selectedCurrency = e.value
|
|
102
|
-
// const currencyValue = tokens * exchangeRate[selectedCurrency]
|
|
103
|
-
// const selectedCurrencyValue = tokens * exchangeRate[this.normalizeCurrencySelected(userSelectedCurrency)]
|
|
104
|
-
// this.validate({
|
|
105
|
-
// tokens,
|
|
106
|
-
// currencyValue,
|
|
107
|
-
// selectedCurrency,
|
|
108
|
-
// })
|
|
109
|
-
// this.setState(
|
|
110
|
-
// {
|
|
111
|
-
// currencyValue,
|
|
112
|
-
// selectedCurrency,
|
|
113
|
-
// selectedCurrencyValue,
|
|
114
|
-
// },
|
|
115
|
-
// () => {
|
|
116
|
-
// this.onChange({
|
|
117
|
-
// target: {
|
|
118
|
-
// name,
|
|
119
|
-
// value: tokens,
|
|
120
|
-
// currencyValue,
|
|
121
|
-
// currencyName: selectedCurrency,
|
|
122
|
-
// selectedCurrencyValue,
|
|
123
|
-
// },
|
|
124
|
-
// })
|
|
125
|
-
// },
|
|
126
|
-
// )
|
|
127
|
-
// }
|
|
128
|
-
changeCurrencyValue = (e, field) => {
|
|
129
|
-
const { exchangeRate, name, available, userSelectedCurrency } = this.props;
|
|
130
|
-
const { selectedCurrency } = this.state;
|
|
131
|
-
let currencyValueInput = getNumericPart(e.target.value);
|
|
132
|
-
let currencyValue = BigNumber(currencyValueInput);
|
|
133
|
-
let tokens = currencyValue.div(exchangeRate[selectedCurrency]);
|
|
134
|
-
const selectedCurrencyValue = tokens * exchangeRate[this.normalizeCurrencySelected(userSelectedCurrency)];
|
|
135
|
-
if (tokens.gt(available)) {
|
|
136
|
-
tokens = BigNumber(available);
|
|
137
|
-
currencyValue = tokens.times(exchangeRate[selectedCurrency]);
|
|
138
|
-
currencyValueInput = currencyValue.toFixed(4);
|
|
139
|
-
}
|
|
140
|
-
this.validate({
|
|
141
|
-
tokens: tokens.toNumber(),
|
|
142
|
-
currencyValue: currencyValue.toNumber(),
|
|
143
|
-
selectedCurrency
|
|
144
|
-
});
|
|
145
|
-
this.setState(
|
|
146
|
-
{
|
|
147
|
-
tokens: tokens.toFixed(4),
|
|
148
|
-
currencyValue: currencyValueInput,
|
|
149
|
-
selectedCurrencyValue
|
|
150
|
-
},
|
|
151
|
-
() => {
|
|
152
|
-
this.onChange(
|
|
153
|
-
{
|
|
154
|
-
target: {
|
|
155
|
-
name,
|
|
156
|
-
value: tokens,
|
|
157
|
-
currencyValue,
|
|
158
|
-
currencyName: selectedCurrency,
|
|
159
|
-
selectedCurrencyValue
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
field
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
);
|
|
166
|
-
};
|
|
167
|
-
validate = (values) => {
|
|
168
|
-
const { minTokensCount = 0, available, maxFunds, name, tokenName, userSelectedCurrency } = this.props;
|
|
169
|
-
const validationSchema = Yup.object().shape({
|
|
170
|
-
tokens: Yup.number().min(minTokensCount, `Minimum investment: ${minTokensCount}`).max(
|
|
171
|
-
available,
|
|
172
|
-
`Unfortunately there are less ${tokenName} TOKENS available as you wish to buy. Please choose a smaller amount.`
|
|
173
|
-
),
|
|
174
|
-
currencyValue: Yup.number().when("selectedCurrency", {
|
|
175
|
-
is: InvestCalculatorCurrencies.EUR,
|
|
176
|
-
then: Yup.number().max(
|
|
177
|
-
2,
|
|
178
|
-
// `Credit card limit of €${Config.euroLimit} reached`, // Config.euroLimit,
|
|
179
|
-
""
|
|
180
|
-
),
|
|
181
|
-
otherwise: Yup.number().max(
|
|
182
|
-
maxFunds[InvestCalculatorCurrencies.CRYPTO],
|
|
183
|
-
`Unfortunately there are not sufficient ${userSelectedCurrency} available on your chosen Ethereum address.`
|
|
184
|
-
)
|
|
185
|
-
})
|
|
186
|
-
});
|
|
187
|
-
const callback = () => {
|
|
188
|
-
const { errors } = this.state;
|
|
189
|
-
this.onErrors({
|
|
190
|
-
target: {
|
|
191
|
-
name,
|
|
192
|
-
errors
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
};
|
|
196
|
-
try {
|
|
197
|
-
validationSchema.validateSync(values);
|
|
198
|
-
this.setState(
|
|
199
|
-
{
|
|
200
|
-
errors: {}
|
|
201
|
-
},
|
|
202
|
-
callback
|
|
203
|
-
);
|
|
204
|
-
} catch (e) {
|
|
205
|
-
this.setState(
|
|
206
|
-
{
|
|
207
|
-
errors: yupToFormErrors(e)
|
|
208
|
-
},
|
|
209
|
-
callback
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
render() {
|
|
214
|
-
const { available, tokenName, id, name, isIban, userSelectedCurrency } = this.props;
|
|
215
|
-
const { errors, tokens, currencyValue, selectedCurrency } = this.state;
|
|
216
|
-
return /* @__PURE__ */ jsxs(Wrapper, { children: [
|
|
217
|
-
/* @__PURE__ */ jsxs(Container, { children: [
|
|
218
|
-
/* @__PURE__ */ jsx(Title, { error: !!errors.tokens, children: `${tokenName} tokens` }),
|
|
219
|
-
/* @__PURE__ */ jsx(InputWrap, { children: /* @__PURE__ */ jsx(
|
|
220
|
-
Input,
|
|
221
|
-
{
|
|
222
|
-
id,
|
|
223
|
-
name,
|
|
224
|
-
value: tokens.toString(),
|
|
225
|
-
onChange: this.changeTokens,
|
|
226
|
-
onBlur: this.handleBlur
|
|
227
|
-
}
|
|
228
|
-
) }),
|
|
229
|
-
/* @__PURE__ */ jsx(Caption, { children: `Still available: ${fixDecimals(
|
|
230
|
-
available,
|
|
231
|
-
//tokenDecimals,
|
|
232
|
-
2
|
|
233
|
-
)} ${tokenName}` }),
|
|
234
|
-
/* @__PURE__ */ jsx(StyledFormError, { show: !!errors.tokens, children: errors.tokens })
|
|
235
|
-
] }),
|
|
236
|
-
/* @__PURE__ */ jsx(EqualSign, { children: "=" }),
|
|
237
|
-
/* @__PURE__ */ jsxs(Container, { children: [
|
|
238
|
-
isIban ? /* @__PURE__ */ jsx(Title, { error: !!errors.tokens, children: "€ value" }) : /* @__PURE__ */ jsx(
|
|
239
|
-
Title,
|
|
240
|
-
{
|
|
241
|
-
error: selectedCurrency === InvestCalculatorCurrencies.GUSD && !!errors.currencyValue || selectedCurrency === InvestCalculatorCurrencies.USDT && !!errors.currencyValue,
|
|
242
|
-
children: userSelectedCurrency === "ether" ? "ETH VALUE" : userSelectedCurrency === "gemini" ? "GUSD VALUE" : "USDT VALUE"
|
|
243
|
-
}
|
|
244
|
-
),
|
|
245
|
-
/* @__PURE__ */ jsx(InputWrap, { children: /* @__PURE__ */ jsx(
|
|
246
|
-
Input,
|
|
247
|
-
{
|
|
248
|
-
id: `${id}-valueInput`,
|
|
249
|
-
name: `${id}-valueInput`,
|
|
250
|
-
value: currencyValue.toString(),
|
|
251
|
-
onChange: this.changeCurrencyValue,
|
|
252
|
-
onBlur: () => {
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
) }),
|
|
256
|
-
/* @__PURE__ */ jsx(StyledFormError, { paddingTop: true, show: !!errors.currencyValue, children: errors.currencyValue })
|
|
257
|
-
] })
|
|
258
|
-
] });
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
InvestCalculator.propTypes = {
|
|
262
|
-
exchangeRate: PropTypes.shape({
|
|
263
|
-
[InvestCalculatorCurrencies.ETH]: PropTypes.number.isRequired,
|
|
264
|
-
[InvestCalculatorCurrencies.EUR]: PropTypes.number.isRequired
|
|
265
|
-
}).isRequired,
|
|
266
|
-
maxFunds: PropTypes.shape({
|
|
267
|
-
[InvestCalculatorCurrencies.CRYPTO]: PropTypes.number,
|
|
268
|
-
[InvestCalculatorCurrencies.EUR]: PropTypes.number
|
|
269
|
-
}).isRequired,
|
|
270
|
-
minTokensCount: PropTypes.number,
|
|
271
|
-
available: PropTypes.number.isRequired,
|
|
272
|
-
tokenName: PropTypes.string.isRequired,
|
|
273
|
-
id: PropTypes.string.isRequired,
|
|
274
|
-
name: PropTypes.string.isRequired,
|
|
275
|
-
onChange: PropTypes.func,
|
|
276
|
-
onBlur: PropTypes.func,
|
|
277
|
-
onFocus: PropTypes.func,
|
|
278
|
-
onErrors: PropTypes.func
|
|
279
|
-
};
|
|
280
|
-
export {
|
|
281
|
-
InvestCalculator,
|
|
282
|
-
InvestCalculatorCurrencies
|
|
283
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import styled from "styled-components";
|
|
2
|
-
import { SelectControl } from "../Input/Select.styles.js";
|
|
3
|
-
import "../Form/Form.js";
|
|
4
|
-
import theme from "../../styles/theme.js";
|
|
5
|
-
import { FormError } from "../Form/Form.styles.js";
|
|
6
|
-
const Wrapper = styled.div`
|
|
7
|
-
display: flex;
|
|
8
|
-
justify-content: space-between;
|
|
9
|
-
`;
|
|
10
|
-
const Container = styled.div``;
|
|
11
|
-
const Title = styled.div.withConfig({
|
|
12
|
-
shouldForwardProp: (props) => !["error"].includes(props)
|
|
13
|
-
})`
|
|
14
|
-
font-size: 12px;
|
|
15
|
-
font-weight: 700;
|
|
16
|
-
line-height: 24px;
|
|
17
|
-
letter-spacing: 2px;
|
|
18
|
-
color: ${() => theme.cBlack};
|
|
19
|
-
text-transform: uppercase;
|
|
20
|
-
|
|
21
|
-
${(props) => props.error && `color: ${theme.cWarning};`}
|
|
22
|
-
`;
|
|
23
|
-
const InputWrap = styled.div`
|
|
24
|
-
padding-top: 9px;
|
|
25
|
-
|
|
26
|
-
input {
|
|
27
|
-
font-size: 22px;
|
|
28
|
-
font-weight: 300;
|
|
29
|
-
line-height: 28px;
|
|
30
|
-
padding-bottom: 11px;
|
|
31
|
-
padding-top: 0;
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
34
|
-
const StyledFormError = styled(FormError).withConfig({
|
|
35
|
-
shouldForwardProp: (props) => !["paddingTop"].includes(props)
|
|
36
|
-
})`
|
|
37
|
-
font-size: 13px;
|
|
38
|
-
font-weight: 300;
|
|
39
|
-
line-height: 16px;
|
|
40
|
-
letter-spacing: 0.4px;
|
|
41
|
-
font-style: italic;
|
|
42
|
-
top: 0;
|
|
43
|
-
|
|
44
|
-
width: min-content;
|
|
45
|
-
min-width: 100%;
|
|
46
|
-
|
|
47
|
-
${(props) => props.paddingTop && "padding-top: 12px;"}
|
|
48
|
-
`;
|
|
49
|
-
const Caption = styled.div`
|
|
50
|
-
// font-size: 9px;
|
|
51
|
-
font-size: 13px;
|
|
52
|
-
font-weight: 300;
|
|
53
|
-
line-height: 16px;
|
|
54
|
-
padding-top: 12px;
|
|
55
|
-
letter-spacing: 0.4px;
|
|
56
|
-
font-style: italic;
|
|
57
|
-
`;
|
|
58
|
-
const EqualSign = styled.div`
|
|
59
|
-
margin: auto;
|
|
60
|
-
font-size: 34px;
|
|
61
|
-
font-weight: 300;
|
|
62
|
-
color: ${() => theme.cBlack};
|
|
63
|
-
opacity: 0.5;
|
|
64
|
-
padding: 0px 30px;
|
|
65
|
-
`;
|
|
66
|
-
styled.div`
|
|
67
|
-
padding-bottom: 2px;
|
|
68
|
-
|
|
69
|
-
${SelectControl}${SelectControl}${SelectControl} {
|
|
70
|
-
padding: 0;
|
|
71
|
-
border: 0;
|
|
72
|
-
height: 24px;
|
|
73
|
-
min-height: 24px;
|
|
74
|
-
font-size: 12px;
|
|
75
|
-
font-weight: 700;
|
|
76
|
-
line-height: 24px;
|
|
77
|
-
letter-spacing: 2px;
|
|
78
|
-
margin-top: -2px;
|
|
79
|
-
}
|
|
80
|
-
`;
|
|
81
|
-
styled.div.withConfig({
|
|
82
|
-
shouldForwardProp: (props) => !["error"].includes(props)
|
|
83
|
-
})`
|
|
84
|
-
${(props) => props.error && `color: ${theme.cWarning};`}
|
|
85
|
-
`;
|
|
86
|
-
export {
|
|
87
|
-
Caption,
|
|
88
|
-
Container,
|
|
89
|
-
EqualSign,
|
|
90
|
-
InputWrap,
|
|
91
|
-
StyledFormError,
|
|
92
|
-
Title,
|
|
93
|
-
Wrapper
|
|
94
|
-
};
|
|
Binary file
|