@stokr/components-library 3.0.23 → 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.
Files changed (34) hide show
  1. package/dist/index.js +34 -36
  2. package/dist/static/images/background3.png +0 -0
  3. package/dist/static/images/background3.png.js +1 -1
  4. package/dist/static/images/currency/bitcoin-logo.png +0 -0
  5. package/dist/static/images/currency/bitcoin-logo.png.js +4 -0
  6. package/dist/static/images/currency/bmn2-logo.png +0 -0
  7. package/dist/static/images/currency/bmn2-logo.png.js +4 -0
  8. package/dist/static/images/currency/usdt-logo.png +0 -0
  9. package/dist/static/images/currency/usdt-logo.png.js +4 -0
  10. package/dist/static/images/social/Facebook_Logo.png +0 -0
  11. package/dist/static/images/social/Facebook_Logo.png.js +1 -1
  12. package/dist/static/images/social/Telegram-Logo.png +0 -0
  13. package/dist/static/images/social/Telegram-Logo.png.js +1 -1
  14. package/dist/static/images/social/X-logo-black.png +0 -0
  15. package/dist/static/images/social/X-logo-black.png.js +1 -1
  16. package/dist/utils/fix-decimals.js +0 -1
  17. package/dist/utils/formatCurrencyValue.js +8 -5
  18. package/package.json +3 -4
  19. package/dist/components/InvestCalculator/InvestCalculator.js +0 -283
  20. package/dist/components/InvestCalculator/InvestCalculator.styles.js +0 -94
  21. package/dist/static/images/background.png +0 -0
  22. package/dist/static/images/bitcoin-logo.svg +0 -9
  23. package/dist/static/images/bitcoin-logo.svg.js +0 -4
  24. package/dist/static/images/bmn2-logo.svg +0 -18
  25. package/dist/static/images/bmn2-logo.svg.js +0 -4
  26. package/dist/static/images/face-scan-icon.svg +0 -1
  27. /package/dist/static/images/{eth.svg → currency/eth.svg} +0 -0
  28. /package/dist/static/images/{eth_logo.svg → currency/eth_logo.svg} +0 -0
  29. /package/dist/static/images/{eth_logo.svg.js → currency/eth_logo.svg.js} +0 -0
  30. /package/dist/static/images/{eur.svg → currency/eur.svg} +0 -0
  31. /package/dist/static/images/{usdc-logo.svg → currency/usdc-logo.svg} +0 -0
  32. /package/dist/static/images/{usdc-logo.svg.js → currency/usdc-logo.svg.js} +0 -0
  33. /package/dist/static/images/{usdq-logo.png → currency/usdq-logo.png} +0 -0
  34. /package/dist/static/images/{usdq-logo.png.js → currency/usdq-logo.png.js} +0 -0
@@ -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