@stokr/components-library 3.0.72-beta.6 → 3.0.72-beta.7
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/Payment/PaymentDetailsCard.js +7 -3
- package/dist/components/Payment/PaymentDisplay.js +11 -3
- package/dist/components/Payment/PaymentPendingCard.js +3 -0
- package/dist/components/Payment/PaymentSuccessCard.js +5 -2
- package/dist/utils/formatCurrencyValue.js +10 -0
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import styled from "styled-components";
|
|
|
4
4
|
import { colors } from "../../styles/colors.js";
|
|
5
5
|
import { InfoIcon } from "../InfoIcon/InfoIcon.js";
|
|
6
6
|
import { ArrowSimple } from "../icons/ArrowSimple.js";
|
|
7
|
-
import { getCurrencyConfig, getCurrencyIcon } from "../../utils/formatCurrencyValue.js";
|
|
7
|
+
import { getCurrencyConfig, getCurrencyIcon, formatAmountForDisplay } from "../../utils/formatCurrencyValue.js";
|
|
8
8
|
import externalLinkIcon from "../../static/images/external-link-icon.svg.js";
|
|
9
9
|
const CardContainer = styled.div`
|
|
10
10
|
background: ${colors.white};
|
|
@@ -48,11 +48,13 @@ const AmountSubtitle = styled.div`
|
|
|
48
48
|
const AmountDisplay = styled.div`
|
|
49
49
|
display: flex;
|
|
50
50
|
align-items: center;
|
|
51
|
+
flex-wrap: wrap;
|
|
51
52
|
gap: 16px;
|
|
52
53
|
`;
|
|
53
54
|
const AmountLeft = styled.div`
|
|
54
55
|
display: flex;
|
|
55
56
|
align-items: center;
|
|
57
|
+
flex-wrap: wrap;
|
|
56
58
|
gap: 12px;
|
|
57
59
|
flex: 1;
|
|
58
60
|
min-width: 0;
|
|
@@ -94,7 +96,9 @@ const AmountValue = styled.div`
|
|
|
94
96
|
text-transform: uppercase;
|
|
95
97
|
line-height: 40px;
|
|
96
98
|
letter-spacing: 1.5px;
|
|
97
|
-
|
|
99
|
+
max-width: 100%;
|
|
100
|
+
overflow-wrap: break-word;
|
|
101
|
+
word-break: break-word;
|
|
98
102
|
color: ${colors.futureBlack};
|
|
99
103
|
`;
|
|
100
104
|
const Separator = styled.hr`
|
|
@@ -282,7 +286,7 @@ const AmountBlock = ({ config }) => {
|
|
|
282
286
|
/* @__PURE__ */ jsxs(AmountDisplay, { children: [
|
|
283
287
|
/* @__PURE__ */ jsxs(AmountLeft, { children: [
|
|
284
288
|
renderCurrencyLogo(),
|
|
285
|
-
/* @__PURE__ */ jsx(AmountValue, { children: displayValue !== null ? displayValue : "-" })
|
|
289
|
+
/* @__PURE__ */ jsx(AmountValue, { children: displayValue !== null ? formatAmountForDisplay(displayValue) : "-" })
|
|
286
290
|
] }),
|
|
287
291
|
ticker && /* @__PURE__ */ jsx(CurrencyTicker, { children: ticker })
|
|
288
292
|
] }),
|
|
@@ -9,7 +9,7 @@ import { CopyToClipboardButton } from "../CryptoAddress/CryptoAddress.styles.js"
|
|
|
9
9
|
import stdin_default from "../QRCode/QRCode.js";
|
|
10
10
|
import { SectionTitle } from "../SectionTitle/SectionTitle.styles.js";
|
|
11
11
|
import { StatusDot } from "../StatusDot/StatusDot.js";
|
|
12
|
-
import { getCurrencyIcon } from "../../utils/formatCurrencyValue.js";
|
|
12
|
+
import { getCurrencyIcon, formatAmountForDisplay } from "../../utils/formatCurrencyValue.js";
|
|
13
13
|
const CodeWrapper = styled.div.withConfig({
|
|
14
14
|
shouldForwardProp: (props) => !["maxWidth"].includes(props)
|
|
15
15
|
})`
|
|
@@ -35,12 +35,18 @@ const AmountBlock = styled.div`
|
|
|
35
35
|
const AmountRow = styled.div`
|
|
36
36
|
display: flex;
|
|
37
37
|
align-items: center;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
flex-wrap: wrap;
|
|
38
40
|
gap: 10px;
|
|
41
|
+
width: 100%;
|
|
39
42
|
`;
|
|
40
43
|
const AmountValueGroup = styled.div`
|
|
41
44
|
display: flex;
|
|
42
45
|
align-items: center;
|
|
46
|
+
flex-wrap: wrap;
|
|
47
|
+
justify-content: center;
|
|
43
48
|
gap: 8px;
|
|
49
|
+
min-width: 0;
|
|
44
50
|
`;
|
|
45
51
|
const AmountValue = styled.p`
|
|
46
52
|
margin: 0;
|
|
@@ -50,7 +56,9 @@ const AmountValue = styled.p`
|
|
|
50
56
|
line-height: 40px;
|
|
51
57
|
letter-spacing: 1.5px;
|
|
52
58
|
color: ${colors.black};
|
|
53
|
-
|
|
59
|
+
max-width: 100%;
|
|
60
|
+
overflow-wrap: break-word;
|
|
61
|
+
word-break: break-word;
|
|
54
62
|
`;
|
|
55
63
|
const AmountCurrency = styled.p`
|
|
56
64
|
margin: 0;
|
|
@@ -169,7 +177,7 @@ const PaymentDisplay = ({
|
|
|
169
177
|
/* @__PURE__ */ jsxs(AmountRow, { style: amountSectionStyle, children: [
|
|
170
178
|
/* @__PURE__ */ jsxs(AmountValueGroup, { children: [
|
|
171
179
|
/* @__PURE__ */ jsx(AmountIcon, { src: getCurrencyIcon(currency, customCurrencyIcon), style: amountIconStyle, alt: currency }),
|
|
172
|
-
/* @__PURE__ */ jsx(AmountValue, { style: amountTextStyle, children: amount }),
|
|
180
|
+
/* @__PURE__ */ jsx(AmountValue, { style: amountTextStyle, children: formatAmountForDisplay(amount) }),
|
|
173
181
|
/* @__PURE__ */ jsx(AmountCurrency, { style: amountTextStyle, children: currency })
|
|
174
182
|
] }),
|
|
175
183
|
showCopyIcons && /* @__PURE__ */ jsx(
|
|
@@ -28,6 +28,7 @@ const TextBlock = styled.div`
|
|
|
28
28
|
`;
|
|
29
29
|
const Title = styled.h2`
|
|
30
30
|
margin: 0;
|
|
31
|
+
font-family: 'Open Sans', sans-serif;
|
|
31
32
|
font-size: 22px;
|
|
32
33
|
font-weight: 800;
|
|
33
34
|
line-height: 28px;
|
|
@@ -37,6 +38,7 @@ const Title = styled.h2`
|
|
|
37
38
|
`;
|
|
38
39
|
const Description = styled.p`
|
|
39
40
|
margin: 0;
|
|
41
|
+
font-family: 'Open Sans', sans-serif;
|
|
40
42
|
font-size: 16px;
|
|
41
43
|
font-weight: 300;
|
|
42
44
|
line-height: 24px;
|
|
@@ -45,6 +47,7 @@ const Description = styled.p`
|
|
|
45
47
|
`;
|
|
46
48
|
const FooterNote = styled.p`
|
|
47
49
|
margin: 0;
|
|
50
|
+
font-family: 'Open Sans', sans-serif;
|
|
48
51
|
font-size: 12px;
|
|
49
52
|
font-weight: 400;
|
|
50
53
|
line-height: 18px;
|
|
@@ -7,7 +7,7 @@ import { Button } from "../Button/Button.styles.js";
|
|
|
7
7
|
import { CodeWrapper, AmountIcon, AmountValue, AmountCurrency } from "./PaymentDisplay.js";
|
|
8
8
|
import { DetailsToggle } from "./DetailsToggle.js";
|
|
9
9
|
import { LottieAnimation } from "../Lottie/LottieAnimation.js";
|
|
10
|
-
import { getCurrencyIcon } from "../../utils/formatCurrencyValue.js";
|
|
10
|
+
import { getCurrencyIcon, formatAmountForDisplay } from "../../utils/formatCurrencyValue.js";
|
|
11
11
|
import externalLinkIcon from "../../static/images/external-link-icon.svg.js";
|
|
12
12
|
const IconCircle = styled.div`
|
|
13
13
|
flex-shrink: 0;
|
|
@@ -47,7 +47,10 @@ const Description = styled.p`
|
|
|
47
47
|
const AmountRow = styled.div`
|
|
48
48
|
display: flex;
|
|
49
49
|
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
flex-wrap: wrap;
|
|
50
52
|
gap: 8px;
|
|
53
|
+
max-width: 100%;
|
|
51
54
|
`;
|
|
52
55
|
const ActionsRow = styled.div`
|
|
53
56
|
display: flex;
|
|
@@ -102,7 +105,7 @@ const PaymentSuccessCard = ({
|
|
|
102
105
|
] }),
|
|
103
106
|
hasAmount && /* @__PURE__ */ jsxs(AmountRow, { children: [
|
|
104
107
|
currency && /* @__PURE__ */ jsx(AmountIcon, { src: getCurrencyIcon(currency, customCurrencyIcon), alt: currency }),
|
|
105
|
-
/* @__PURE__ */ jsx(AmountValue, { children: amount }),
|
|
108
|
+
/* @__PURE__ */ jsx(AmountValue, { children: formatAmountForDisplay(amount) }),
|
|
106
109
|
currency && /* @__PURE__ */ jsx(AmountCurrency, { children: currency })
|
|
107
110
|
] }),
|
|
108
111
|
rows.length > 0 && /* @__PURE__ */ jsx(DetailsToggle, { rows, defaultOpen: detailsDefaultOpen, showLabel: showDetailsLabel, hideLabel: hideDetailsLabel }),
|
|
@@ -4,6 +4,7 @@ import BitcoinLogo from "../static/images/currency/bitcoin-logo.png.js";
|
|
|
4
4
|
import BMN2Logo from "../static/images/currency/bmn2-logo.png.js";
|
|
5
5
|
import ETHLogo from "../static/images/currency/eth_logo.svg.js";
|
|
6
6
|
import USDTLogo from "../static/images/currency/usdt-logo.png.js";
|
|
7
|
+
import { formatDisplayNumber } from "./fix-decimals.js";
|
|
7
8
|
const CURRENCY_CONFIG = {
|
|
8
9
|
tether: ["USDT", 2],
|
|
9
10
|
gemini: ["GUSD", 2],
|
|
@@ -46,6 +47,14 @@ const formatCurrencyValue = (currency, value, tokenDecimals = 2, options = {}) =
|
|
|
46
47
|
const formattedValue = parseFloat(Math.abs(value)).toFixed(decimals);
|
|
47
48
|
return valueFirst ? `${formattedValue} ${symbol}` : `${symbol} ${formattedValue}`;
|
|
48
49
|
};
|
|
50
|
+
const formatAmountForDisplay = (amount) => {
|
|
51
|
+
if (amount === void 0 || amount === null || amount === "") return amount;
|
|
52
|
+
const plain = String(amount).replace(/,/g, "");
|
|
53
|
+
const decimalPart = plain.split(".")[1];
|
|
54
|
+
const digits = decimalPart ? decimalPart.length : 0;
|
|
55
|
+
const formatted = formatDisplayNumber(plain, { minimumFractionDigits: digits, maximumFractionDigits: digits });
|
|
56
|
+
return formatted || amount;
|
|
57
|
+
};
|
|
49
58
|
const getCurrencySymbol = (currencySelected) => {
|
|
50
59
|
const config = CURRENCY_CONFIG[currencySelected];
|
|
51
60
|
if (config) {
|
|
@@ -94,6 +103,7 @@ const getLiquidAssetIcon = async (assetId) => {
|
|
|
94
103
|
};
|
|
95
104
|
export {
|
|
96
105
|
CURRENCY_CONFIG,
|
|
106
|
+
formatAmountForDisplay,
|
|
97
107
|
formatCurrencyValue,
|
|
98
108
|
getCurrencyConfig,
|
|
99
109
|
getCurrencyIcon,
|