@blocklet/payment-react 1.25.10 → 1.26.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/es/checkout-v2/checkout-v2.d.ts +2 -0
- package/es/checkout-v2/checkout-v2.js +121 -0
- package/es/checkout-v2/components/dialogs/checkout-dialogs.d.ts +1 -0
- package/es/checkout-v2/components/dialogs/checkout-dialogs.js +106 -0
- package/es/checkout-v2/components/left/billing-toggle.d.ts +6 -0
- package/es/checkout-v2/components/left/billing-toggle.js +118 -0
- package/es/checkout-v2/components/left/cross-sell-card.d.ts +10 -0
- package/es/checkout-v2/components/left/cross-sell-card.js +167 -0
- package/es/checkout-v2/components/left/product-item-card.d.ts +26 -0
- package/es/checkout-v2/components/left/product-item-card.js +571 -0
- package/es/checkout-v2/components/left/promotion-input.d.ts +19 -0
- package/es/checkout-v2/components/left/promotion-input.js +178 -0
- package/es/checkout-v2/components/left/staking-breakdown.d.ts +9 -0
- package/es/checkout-v2/components/left/staking-breakdown.js +48 -0
- package/es/checkout-v2/components/left/trial-info.d.ts +13 -0
- package/es/checkout-v2/components/left/trial-info.js +48 -0
- package/es/checkout-v2/components/right/currency-grid.d.ts +8 -0
- package/es/checkout-v2/components/right/currency-grid.js +48 -0
- package/es/checkout-v2/components/right/customer-info-card.d.ts +17 -0
- package/es/checkout-v2/components/right/customer-info-card.js +156 -0
- package/es/checkout-v2/components/right/status-feedback.d.ts +7 -0
- package/es/checkout-v2/components/right/status-feedback.js +17 -0
- package/es/checkout-v2/components/right/submit-button.d.ts +10 -0
- package/es/checkout-v2/components/right/submit-button.js +29 -0
- package/es/checkout-v2/components/right/subscription-disclaimer.d.ts +11 -0
- package/es/checkout-v2/components/right/subscription-disclaimer.js +8 -0
- package/es/checkout-v2/components/shared/exchange-rate-footer.d.ts +23 -0
- package/es/checkout-v2/components/shared/exchange-rate-footer.js +182 -0
- package/es/checkout-v2/components/shared/scenario-badge.d.ts +6 -0
- package/es/checkout-v2/components/shared/scenario-badge.js +47 -0
- package/es/checkout-v2/components/shared/total-display.d.ts +7 -0
- package/es/checkout-v2/components/shared/total-display.js +84 -0
- package/es/checkout-v2/index.d.ts +2 -0
- package/es/checkout-v2/index.js +1 -0
- package/es/checkout-v2/layouts/checkout-layout.d.ts +7 -0
- package/es/checkout-v2/layouts/checkout-layout.js +226 -0
- package/es/checkout-v2/panels/left/composite-panel.d.ts +1 -0
- package/es/checkout-v2/panels/left/composite-panel.js +423 -0
- package/es/checkout-v2/panels/left/credit-topup-panel.d.ts +1 -0
- package/es/checkout-v2/panels/left/credit-topup-panel.js +615 -0
- package/es/checkout-v2/panels/left/scenario-router.d.ts +1 -0
- package/es/checkout-v2/panels/left/scenario-router.js +19 -0
- package/es/checkout-v2/panels/right/payment-panel.d.ts +1 -0
- package/es/checkout-v2/panels/right/payment-panel.js +644 -0
- package/es/checkout-v2/types.d.ts +15 -0
- package/es/checkout-v2/types.js +0 -0
- package/es/checkout-v2/utils/format.d.ts +59 -0
- package/es/checkout-v2/utils/format.js +125 -0
- package/es/checkout-v2/utils/scenario-detector.d.ts +3 -0
- package/es/checkout-v2/utils/scenario-detector.js +17 -0
- package/es/checkout-v2/views/error-view.d.ts +7 -0
- package/es/checkout-v2/views/error-view.js +269 -0
- package/es/checkout-v2/views/loading-view.d.ts +5 -0
- package/es/checkout-v2/views/loading-view.js +158 -0
- package/es/checkout-v2/views/success-view.d.ts +29 -0
- package/es/checkout-v2/views/success-view.js +614 -0
- package/es/components/phone-field.d.ts +14 -0
- package/es/components/phone-field.js +96 -0
- package/es/index.d.ts +3 -1
- package/es/index.js +3 -1
- package/es/locales/en.js +45 -6
- package/es/locales/zh.js +45 -6
- package/es/payment/form/index.js +10 -1
- package/lib/checkout-v2/checkout-v2.d.ts +2 -0
- package/lib/checkout-v2/checkout-v2.js +151 -0
- package/lib/checkout-v2/components/dialogs/checkout-dialogs.d.ts +1 -0
- package/lib/checkout-v2/components/dialogs/checkout-dialogs.js +131 -0
- package/lib/checkout-v2/components/left/billing-toggle.d.ts +6 -0
- package/lib/checkout-v2/components/left/billing-toggle.js +126 -0
- package/lib/checkout-v2/components/left/cross-sell-card.d.ts +10 -0
- package/lib/checkout-v2/components/left/cross-sell-card.js +257 -0
- package/lib/checkout-v2/components/left/product-item-card.d.ts +26 -0
- package/lib/checkout-v2/components/left/product-item-card.js +738 -0
- package/lib/checkout-v2/components/left/promotion-input.d.ts +19 -0
- package/lib/checkout-v2/components/left/promotion-input.js +220 -0
- package/lib/checkout-v2/components/left/staking-breakdown.d.ts +9 -0
- package/lib/checkout-v2/components/left/staking-breakdown.js +96 -0
- package/lib/checkout-v2/components/left/trial-info.d.ts +13 -0
- package/lib/checkout-v2/components/left/trial-info.js +82 -0
- package/lib/checkout-v2/components/right/currency-grid.d.ts +8 -0
- package/lib/checkout-v2/components/right/currency-grid.js +96 -0
- package/lib/checkout-v2/components/right/customer-info-card.d.ts +17 -0
- package/lib/checkout-v2/components/right/customer-info-card.js +246 -0
- package/lib/checkout-v2/components/right/status-feedback.d.ts +7 -0
- package/lib/checkout-v2/components/right/status-feedback.js +30 -0
- package/lib/checkout-v2/components/right/submit-button.d.ts +10 -0
- package/lib/checkout-v2/components/right/submit-button.js +35 -0
- package/lib/checkout-v2/components/right/subscription-disclaimer.d.ts +11 -0
- package/lib/checkout-v2/components/right/subscription-disclaimer.js +33 -0
- package/lib/checkout-v2/components/shared/exchange-rate-footer.d.ts +23 -0
- package/lib/checkout-v2/components/shared/exchange-rate-footer.js +282 -0
- package/lib/checkout-v2/components/shared/scenario-badge.d.ts +6 -0
- package/lib/checkout-v2/components/shared/scenario-badge.js +57 -0
- package/lib/checkout-v2/components/shared/total-display.d.ts +7 -0
- package/lib/checkout-v2/components/shared/total-display.js +154 -0
- package/lib/checkout-v2/index.d.ts +2 -0
- package/lib/checkout-v2/index.js +13 -0
- package/lib/checkout-v2/layouts/checkout-layout.d.ts +7 -0
- package/lib/checkout-v2/layouts/checkout-layout.js +308 -0
- package/lib/checkout-v2/panels/left/composite-panel.d.ts +1 -0
- package/lib/checkout-v2/panels/left/composite-panel.js +515 -0
- package/lib/checkout-v2/panels/left/credit-topup-panel.d.ts +1 -0
- package/lib/checkout-v2/panels/left/credit-topup-panel.js +799 -0
- package/lib/checkout-v2/panels/left/scenario-router.d.ts +1 -0
- package/lib/checkout-v2/panels/left/scenario-router.js +29 -0
- package/lib/checkout-v2/panels/right/payment-panel.d.ts +1 -0
- package/lib/checkout-v2/panels/right/payment-panel.js +906 -0
- package/lib/checkout-v2/types.d.ts +15 -0
- package/lib/checkout-v2/types.js +1 -0
- package/lib/checkout-v2/utils/format.d.ts +59 -0
- package/lib/checkout-v2/utils/format.js +158 -0
- package/lib/checkout-v2/utils/scenario-detector.d.ts +3 -0
- package/lib/checkout-v2/utils/scenario-detector.js +23 -0
- package/lib/checkout-v2/views/error-view.d.ts +7 -0
- package/lib/checkout-v2/views/error-view.js +321 -0
- package/lib/checkout-v2/views/loading-view.d.ts +5 -0
- package/lib/checkout-v2/views/loading-view.js +168 -0
- package/lib/checkout-v2/views/success-view.d.ts +29 -0
- package/lib/checkout-v2/views/success-view.js +735 -0
- package/lib/components/phone-field.d.ts +14 -0
- package/lib/components/phone-field.js +130 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +8 -0
- package/lib/locales/en.js +45 -6
- package/lib/locales/zh.js +45 -6
- package/lib/payment/form/index.js +10 -1
- package/package.json +4 -3
- package/src/checkout-v2/checkout-v2.tsx +155 -0
- package/src/checkout-v2/components/dialogs/checkout-dialogs.tsx +134 -0
- package/src/checkout-v2/components/left/billing-toggle.tsx +122 -0
- package/src/checkout-v2/components/left/cross-sell-card.tsx +170 -0
- package/src/checkout-v2/components/left/product-item-card.tsx +634 -0
- package/src/checkout-v2/components/left/promotion-input.tsx +207 -0
- package/src/checkout-v2/components/left/staking-breakdown.tsx +57 -0
- package/src/checkout-v2/components/left/trial-info.tsx +63 -0
- package/src/checkout-v2/components/right/currency-grid.tsx +59 -0
- package/src/checkout-v2/components/right/customer-info-card.tsx +214 -0
- package/src/checkout-v2/components/right/status-feedback.tsx +35 -0
- package/src/checkout-v2/components/right/submit-button.tsx +37 -0
- package/src/checkout-v2/components/right/subscription-disclaimer.tsx +27 -0
- package/src/checkout-v2/components/shared/exchange-rate-footer.tsx +221 -0
- package/src/checkout-v2/components/shared/scenario-badge.tsx +51 -0
- package/src/checkout-v2/components/shared/total-display.tsx +112 -0
- package/src/checkout-v2/index.ts +2 -0
- package/src/checkout-v2/layouts/checkout-layout.tsx +232 -0
- package/src/checkout-v2/panels/left/composite-panel.tsx +465 -0
- package/src/checkout-v2/panels/left/credit-topup-panel.tsx +681 -0
- package/src/checkout-v2/panels/left/scenario-router.tsx +22 -0
- package/src/checkout-v2/panels/right/payment-panel.tsx +703 -0
- package/src/checkout-v2/types.ts +18 -0
- package/src/checkout-v2/utils/format.ts +204 -0
- package/src/checkout-v2/utils/scenario-detector.ts +30 -0
- package/src/checkout-v2/views/error-view.tsx +293 -0
- package/src/checkout-v2/views/loading-view.tsx +162 -0
- package/src/checkout-v2/views/success-view.tsx +770 -0
- package/src/components/phone-field.tsx +119 -0
- package/src/index.ts +3 -0
- package/src/locales/en.tsx +45 -4
- package/src/locales/zh.tsx +43 -4
- package/src/payment/form/index.tsx +16 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import TuneIcon from "@mui/icons-material/Tune";
|
|
4
|
+
import { Box, Dialog, DialogContent, DialogTitle, Fade, Stack, Tooltip, Typography, keyframes } from "@mui/material";
|
|
5
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
6
|
+
import SlippageConfig from "../../../components/slippage-config.js";
|
|
7
|
+
import { whiteTooltipSx } from "../../utils/format.js";
|
|
8
|
+
const ping = keyframes`
|
|
9
|
+
75%, 100% { transform: scale(2); opacity: 0; }
|
|
10
|
+
`;
|
|
11
|
+
function formatDateTime(ts) {
|
|
12
|
+
if (!ts) return "\u2014";
|
|
13
|
+
const d = new Date(ts);
|
|
14
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
15
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
16
|
+
}
|
|
17
|
+
export default function ExchangeRateFooter({
|
|
18
|
+
hasDynamicPricing,
|
|
19
|
+
rate,
|
|
20
|
+
slippage,
|
|
21
|
+
currencySymbol,
|
|
22
|
+
isSubscription
|
|
23
|
+
}) {
|
|
24
|
+
const { t } = useLocaleContext();
|
|
25
|
+
const [dialogOpen, setDialogOpen] = useState(false);
|
|
26
|
+
const [pendingConfig, setPendingConfig] = useState(null);
|
|
27
|
+
const [submitting, setSubmitting] = useState(false);
|
|
28
|
+
const [localSlippage, setLocalSlippage] = useState(slippage?.percent ?? 0.5);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
setLocalSlippage(slippage?.percent ?? 0.5);
|
|
31
|
+
}, [slippage?.percent]);
|
|
32
|
+
if (!hasDynamicPricing || !rate.value || rate.status === "unavailable") return null;
|
|
33
|
+
const rateDisplay = rate.display || `$${Number(rate.value).toFixed(2)}`;
|
|
34
|
+
const showSlippage = isSubscription && typeof slippage?.set === "function";
|
|
35
|
+
const handleOpenDialog = () => {
|
|
36
|
+
setPendingConfig({ mode: "percent", percent: localSlippage });
|
|
37
|
+
setDialogOpen(true);
|
|
38
|
+
};
|
|
39
|
+
const handleCloseDialog = () => {
|
|
40
|
+
setDialogOpen(false);
|
|
41
|
+
setPendingConfig(null);
|
|
42
|
+
};
|
|
43
|
+
const handleSlippageChange = (value) => {
|
|
44
|
+
setPendingConfig((prev) => prev ? { ...prev, percent: value } : { mode: "percent", percent: value });
|
|
45
|
+
};
|
|
46
|
+
const handleConfigChange = (config) => {
|
|
47
|
+
setPendingConfig(config);
|
|
48
|
+
};
|
|
49
|
+
const handleSubmit = async () => {
|
|
50
|
+
if (!pendingConfig || !slippage?.set) return;
|
|
51
|
+
setSubmitting(true);
|
|
52
|
+
try {
|
|
53
|
+
setLocalSlippage(pendingConfig.percent);
|
|
54
|
+
await slippage.set({ ...pendingConfig, base_currency: "USD" });
|
|
55
|
+
setDialogOpen(false);
|
|
56
|
+
setPendingConfig(null);
|
|
57
|
+
} catch (err) {
|
|
58
|
+
setLocalSlippage(slippage?.percent ?? 0.5);
|
|
59
|
+
console.error("Failed to update slippage", err);
|
|
60
|
+
} finally {
|
|
61
|
+
setSubmitting(false);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const labelSx = {
|
|
65
|
+
fontSize: 11,
|
|
66
|
+
fontWeight: 700,
|
|
67
|
+
color: "primary.main",
|
|
68
|
+
letterSpacing: "0.02em"
|
|
69
|
+
};
|
|
70
|
+
const providerName = rate.providerDisplay || rate.provider || "\u2014";
|
|
71
|
+
const updatedAt = formatDateTime(rate.fetchedAt);
|
|
72
|
+
const fullRate = `$${rate.value}`;
|
|
73
|
+
const tooltipSx = whiteTooltipSx;
|
|
74
|
+
const rowSx = { fontSize: 12, color: "text.secondary", lineHeight: 1.4 };
|
|
75
|
+
const valSx = { fontSize: 12, fontWeight: 600, color: "text.primary", lineHeight: 1.4 };
|
|
76
|
+
const tooltipContent = /* @__PURE__ */ jsxs(Stack, { spacing: 0.75, children: [
|
|
77
|
+
/* @__PURE__ */ jsxs(Typography, { sx: { fontSize: 13, fontWeight: 700, color: "text.primary", mb: 0.25 }, children: [
|
|
78
|
+
"1 ",
|
|
79
|
+
currencySymbol,
|
|
80
|
+
" = ",
|
|
81
|
+
fullRate
|
|
82
|
+
] }),
|
|
83
|
+
/* @__PURE__ */ jsx(Box, { sx: { borderTop: "1px solid", borderColor: "divider", pt: 0.75 }, children: /* @__PURE__ */ jsxs(Stack, { spacing: 0.5, children: [
|
|
84
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "space-between", spacing: 2, children: [
|
|
85
|
+
/* @__PURE__ */ jsx(Typography, { sx: rowSx, children: t("payment.checkout.quote.detailProvider") }),
|
|
86
|
+
/* @__PURE__ */ jsx(Typography, { sx: valSx, children: providerName })
|
|
87
|
+
] }),
|
|
88
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "space-between", spacing: 2, children: [
|
|
89
|
+
/* @__PURE__ */ jsx(Typography, { sx: rowSx, children: t("payment.checkout.quote.detailUpdatedAt") }),
|
|
90
|
+
/* @__PURE__ */ jsx(Typography, { sx: valSx, children: updatedAt })
|
|
91
|
+
] })
|
|
92
|
+
] }) })
|
|
93
|
+
] });
|
|
94
|
+
const slippageTooltip = t("payment.checkout.quote.slippage.tooltip");
|
|
95
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
96
|
+
/* @__PURE__ */ jsx(Box, { sx: { width: "100%", pt: 3, pb: 1, borderTop: "1px solid", borderColor: "divider" }, children: /* @__PURE__ */ jsx(Fade, { in: true, timeout: 300, children: /* @__PURE__ */ jsxs(Stack, { direction: "row", sx: { alignItems: "center", justifyContent: "space-between" }, children: [
|
|
97
|
+
/* @__PURE__ */ jsx(Tooltip, { title: tooltipContent, placement: "top", arrow: true, slotProps: { popper: { sx: tooltipSx } }, children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, sx: { cursor: "default" }, children: [
|
|
98
|
+
/* @__PURE__ */ jsxs(Box, { sx: { position: "relative", width: 8, height: 8, flexShrink: 0 }, children: [
|
|
99
|
+
/* @__PURE__ */ jsx(
|
|
100
|
+
Box,
|
|
101
|
+
{
|
|
102
|
+
sx: {
|
|
103
|
+
position: "absolute",
|
|
104
|
+
inset: 0,
|
|
105
|
+
borderRadius: "50%",
|
|
106
|
+
bgcolor: "#60a5fa",
|
|
107
|
+
opacity: 0.6,
|
|
108
|
+
animation: `${ping} 1s cubic-bezier(0, 0, 0.2, 1) infinite`
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
/* @__PURE__ */ jsx(
|
|
113
|
+
Box,
|
|
114
|
+
{
|
|
115
|
+
sx: {
|
|
116
|
+
position: "relative",
|
|
117
|
+
width: 8,
|
|
118
|
+
height: 8,
|
|
119
|
+
borderRadius: "50%",
|
|
120
|
+
bgcolor: "primary.main"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
] }),
|
|
125
|
+
/* @__PURE__ */ jsxs(Typography, { sx: labelSx, children: [
|
|
126
|
+
"1 ",
|
|
127
|
+
currencySymbol,
|
|
128
|
+
" \u2248 ",
|
|
129
|
+
rateDisplay
|
|
130
|
+
] })
|
|
131
|
+
] }) }),
|
|
132
|
+
showSlippage && /* @__PURE__ */ jsx(Tooltip, { title: slippageTooltip, placement: "top", arrow: true, slotProps: { popper: { sx: whiteTooltipSx } }, children: /* @__PURE__ */ jsxs(
|
|
133
|
+
Stack,
|
|
134
|
+
{
|
|
135
|
+
direction: "row",
|
|
136
|
+
alignItems: "center",
|
|
137
|
+
spacing: 0.75,
|
|
138
|
+
onClick: handleOpenDialog,
|
|
139
|
+
sx: {
|
|
140
|
+
cursor: "pointer",
|
|
141
|
+
"&:hover": { opacity: 1 },
|
|
142
|
+
"&:hover .tune-icon": { transform: "rotate(90deg)" },
|
|
143
|
+
transition: "opacity 0.2s"
|
|
144
|
+
},
|
|
145
|
+
children: [
|
|
146
|
+
/* @__PURE__ */ jsx(
|
|
147
|
+
TuneIcon,
|
|
148
|
+
{
|
|
149
|
+
className: "tune-icon",
|
|
150
|
+
sx: { fontSize: 16, color: "primary.main", transition: "transform 0.5s" }
|
|
151
|
+
}
|
|
152
|
+
),
|
|
153
|
+
/* @__PURE__ */ jsxs(Typography, { sx: labelSx, children: [
|
|
154
|
+
t("payment.checkout.quote.detailSlippage"),
|
|
155
|
+
" ",
|
|
156
|
+
localSlippage,
|
|
157
|
+
"%"
|
|
158
|
+
] })
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
) })
|
|
162
|
+
] }) }) }),
|
|
163
|
+
/* @__PURE__ */ jsxs(Dialog, { open: dialogOpen, onClose: handleCloseDialog, maxWidth: "sm", fullWidth: true, children: [
|
|
164
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: t("payment.checkout.quote.slippage.title") }),
|
|
165
|
+
/* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(
|
|
166
|
+
SlippageConfig,
|
|
167
|
+
{
|
|
168
|
+
value: pendingConfig?.percent ?? localSlippage,
|
|
169
|
+
onChange: handleSlippageChange,
|
|
170
|
+
config: pendingConfig || { mode: "percent", percent: localSlippage },
|
|
171
|
+
onConfigChange: handleConfigChange,
|
|
172
|
+
exchangeRate: rate.value ? String(rate.value) : null,
|
|
173
|
+
baseCurrency: "USD",
|
|
174
|
+
disabled: submitting,
|
|
175
|
+
sx: { mt: 1 },
|
|
176
|
+
onCancel: handleCloseDialog,
|
|
177
|
+
onSave: handleSubmit
|
|
178
|
+
}
|
|
179
|
+
) })
|
|
180
|
+
] })
|
|
181
|
+
] });
|
|
182
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Stack, Typography } from "@mui/material";
|
|
3
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
4
|
+
import { tSafe } from "../../utils/format.js";
|
|
5
|
+
export default function ScenarioBadge({ livemode, label = void 0 }) {
|
|
6
|
+
const { t } = useLocaleContext();
|
|
7
|
+
return /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, sx: { mb: 1.5 }, children: [
|
|
8
|
+
/* @__PURE__ */ jsx(
|
|
9
|
+
Typography,
|
|
10
|
+
{
|
|
11
|
+
component: "span",
|
|
12
|
+
sx: {
|
|
13
|
+
fontSize: 10,
|
|
14
|
+
fontWeight: 700,
|
|
15
|
+
letterSpacing: "0.1em",
|
|
16
|
+
lineHeight: 1,
|
|
17
|
+
textTransform: "uppercase",
|
|
18
|
+
color: "primary.main",
|
|
19
|
+
bgcolor: (theme) => theme.palette.mode === "dark" ? `${theme.palette.primary.main}1A` : `${theme.palette.primary.main}0D`,
|
|
20
|
+
px: 1,
|
|
21
|
+
py: 0.5,
|
|
22
|
+
borderRadius: "4px"
|
|
23
|
+
},
|
|
24
|
+
children: label || tSafe(t, "payment.checkout.orderSummary", "Order Summary")
|
|
25
|
+
}
|
|
26
|
+
),
|
|
27
|
+
!livemode && /* @__PURE__ */ jsx(
|
|
28
|
+
Typography,
|
|
29
|
+
{
|
|
30
|
+
component: "span",
|
|
31
|
+
sx: {
|
|
32
|
+
fontSize: 10,
|
|
33
|
+
fontWeight: 700,
|
|
34
|
+
letterSpacing: "0.1em",
|
|
35
|
+
lineHeight: 1,
|
|
36
|
+
textTransform: "uppercase",
|
|
37
|
+
color: (theme) => theme.palette.mode === "dark" ? theme.palette.grey[500] : theme.palette.grey[400],
|
|
38
|
+
bgcolor: (theme) => theme.palette.mode === "dark" ? "rgba(255,255,255,0.06)" : theme.palette.grey[100],
|
|
39
|
+
px: 1,
|
|
40
|
+
py: 0.5,
|
|
41
|
+
borderRadius: "4px"
|
|
42
|
+
},
|
|
43
|
+
children: t("common.livemode")
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
] });
|
|
47
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Stack, Typography } from "@mui/material";
|
|
3
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
4
|
+
import { tSafe } from "../../utils/format.js";
|
|
5
|
+
function splitPrice(total) {
|
|
6
|
+
if (!total) return { prefix: "", integer: "0", decimal: "", suffix: "" };
|
|
7
|
+
const trimmed = total.trim();
|
|
8
|
+
if (trimmed.startsWith("$")) {
|
|
9
|
+
const numPart = trimmed.slice(1).trim();
|
|
10
|
+
const dotIdx2 = numPart.indexOf(".");
|
|
11
|
+
if (dotIdx2 >= 0) {
|
|
12
|
+
return {
|
|
13
|
+
prefix: "$",
|
|
14
|
+
integer: numPart.slice(0, dotIdx2),
|
|
15
|
+
decimal: `.${numPart.slice(dotIdx2 + 1)}`,
|
|
16
|
+
suffix: ""
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return { prefix: "$", integer: numPart, decimal: "", suffix: "" };
|
|
20
|
+
}
|
|
21
|
+
const parts = trimmed.split(/\s+/);
|
|
22
|
+
const numStr = parts[0] || "0";
|
|
23
|
+
const unit = parts.slice(1).join(" ");
|
|
24
|
+
const dotIdx = numStr.indexOf(".");
|
|
25
|
+
if (dotIdx >= 0) {
|
|
26
|
+
return {
|
|
27
|
+
prefix: "",
|
|
28
|
+
integer: numStr.slice(0, dotIdx),
|
|
29
|
+
decimal: `.${numStr.slice(dotIdx + 1)}`,
|
|
30
|
+
suffix: unit
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return { prefix: "", integer: numStr, decimal: "", suffix: unit };
|
|
34
|
+
}
|
|
35
|
+
export default function TotalDisplay({ label = void 0, total, usdEquivalent = void 0 }) {
|
|
36
|
+
const { t } = useLocaleContext();
|
|
37
|
+
const { prefix, integer, decimal, suffix } = splitPrice(total);
|
|
38
|
+
return /* @__PURE__ */ jsxs(Box, { sx: { pt: 4, borderTop: "1px solid", borderColor: "divider" }, children: [
|
|
39
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "flex-end", children: [
|
|
40
|
+
/* @__PURE__ */ jsx(Stack, { spacing: 0.5, sx: { pb: 1 }, children: /* @__PURE__ */ jsx(
|
|
41
|
+
Typography,
|
|
42
|
+
{
|
|
43
|
+
sx: {
|
|
44
|
+
fontSize: 12,
|
|
45
|
+
fontWeight: 700,
|
|
46
|
+
letterSpacing: "0.02em",
|
|
47
|
+
color: "text.disabled"
|
|
48
|
+
},
|
|
49
|
+
children: label || tSafe(t, "payment.checkout.totalDueToday", "Total due today")
|
|
50
|
+
}
|
|
51
|
+
) }),
|
|
52
|
+
/* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "baseline", lineHeight: 1 }, children: [
|
|
53
|
+
prefix && /* @__PURE__ */ jsx(Typography, { component: "span", sx: { fontSize: 36, fontWeight: 500, color: "text.primary", opacity: 0.4 }, children: prefix }),
|
|
54
|
+
/* @__PURE__ */ jsx(
|
|
55
|
+
Typography,
|
|
56
|
+
{
|
|
57
|
+
component: "span",
|
|
58
|
+
sx: {
|
|
59
|
+
fontSize: { xs: 54, md: 72 },
|
|
60
|
+
fontWeight: 800,
|
|
61
|
+
lineHeight: 1,
|
|
62
|
+
letterSpacing: "-0.04em",
|
|
63
|
+
color: "text.primary"
|
|
64
|
+
},
|
|
65
|
+
children: integer
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
decimal && /* @__PURE__ */ jsx(Typography, { component: "span", sx: { fontSize: 36, fontWeight: 300, color: "text.primary", opacity: 0.3 }, children: decimal }),
|
|
69
|
+
suffix && /* @__PURE__ */ jsx(
|
|
70
|
+
Typography,
|
|
71
|
+
{
|
|
72
|
+
component: "span",
|
|
73
|
+
sx: { fontSize: 20, fontWeight: 700, color: "text.disabled", ml: 1, textTransform: "uppercase" },
|
|
74
|
+
children: suffix
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
] })
|
|
78
|
+
] }),
|
|
79
|
+
usdEquivalent && /* @__PURE__ */ jsxs(Typography, { sx: { fontSize: 12, color: "text.disabled", textAlign: "right", mt: 0.5, fontWeight: 500 }, children: [
|
|
80
|
+
"\u2248 ",
|
|
81
|
+
usdEquivalent
|
|
82
|
+
] })
|
|
83
|
+
] });
|
|
84
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CheckoutV2 } from "./checkout-v2.js";
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from "@mui/material";
|
|
3
|
+
import { alpha, useTheme } from "@mui/material/styles";
|
|
4
|
+
import Header from "@blocklet/ui-react/lib/Header";
|
|
5
|
+
import { useMobile } from "../../hooks/mobile.js";
|
|
6
|
+
const hiddenScrollbar = {
|
|
7
|
+
overflowY: "auto",
|
|
8
|
+
"&::-webkit-scrollbar": { display: "none" },
|
|
9
|
+
scrollbarWidth: "none"
|
|
10
|
+
};
|
|
11
|
+
const mobileFadeIn = {
|
|
12
|
+
"@keyframes mobileFadeIn": {
|
|
13
|
+
from: { opacity: 0 },
|
|
14
|
+
to: { opacity: 1 }
|
|
15
|
+
},
|
|
16
|
+
animation: { xs: "mobileFadeIn 0.4s ease both", md: "none" }
|
|
17
|
+
};
|
|
18
|
+
const fadeIn = {
|
|
19
|
+
"@keyframes fadeIn": {
|
|
20
|
+
from: { opacity: 0, transform: "translateY(12px)" },
|
|
21
|
+
to: { opacity: 1, transform: "translateY(0)" }
|
|
22
|
+
},
|
|
23
|
+
animation: { xs: "none", md: "fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both" }
|
|
24
|
+
};
|
|
25
|
+
const slideInFromRight = {
|
|
26
|
+
"@keyframes slideInRight": {
|
|
27
|
+
from: { transform: "translateX(100%)" },
|
|
28
|
+
to: { transform: "translateX(0)" }
|
|
29
|
+
},
|
|
30
|
+
animation: { xs: "none", md: "slideInRight 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards" }
|
|
31
|
+
};
|
|
32
|
+
export default function CheckoutLayout({ left, right, mode = "inline" }) {
|
|
33
|
+
const isFullScreen = mode === "standalone";
|
|
34
|
+
const { isMobile } = useMobile();
|
|
35
|
+
const theme = useTheme();
|
|
36
|
+
const isDark = theme.palette.mode === "dark";
|
|
37
|
+
const hideLeft = left === null;
|
|
38
|
+
const mobileSubmitBarSx = {};
|
|
39
|
+
if (isMobile && !hideLeft) {
|
|
40
|
+
mobileSubmitBarSx["& .cko-v2-submit-btn"] = {
|
|
41
|
+
position: "fixed",
|
|
42
|
+
bottom: 0,
|
|
43
|
+
left: 0,
|
|
44
|
+
right: 0,
|
|
45
|
+
zIndex: 999,
|
|
46
|
+
bgcolor: isDark ? "rgba(30,30,30,0.82)" : "background.paper",
|
|
47
|
+
backdropFilter: isDark ? "blur(12px)" : "none",
|
|
48
|
+
p: 1.5,
|
|
49
|
+
borderTop: "1px solid",
|
|
50
|
+
borderColor: "divider",
|
|
51
|
+
boxShadow: isDark ? "0 -4px 20px rgba(0,0,0,0.4)" : "0 -2px 10px rgba(0,0,0,0.08)"
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (!isFullScreen) {
|
|
55
|
+
return /* @__PURE__ */ jsxs(
|
|
56
|
+
Box,
|
|
57
|
+
{
|
|
58
|
+
sx: {
|
|
59
|
+
display: "flex",
|
|
60
|
+
flexDirection: { xs: "column", md: "row" },
|
|
61
|
+
width: "100%",
|
|
62
|
+
minHeight: { md: 640 },
|
|
63
|
+
maxWidth: 1120,
|
|
64
|
+
mx: "auto",
|
|
65
|
+
borderRadius: "16px",
|
|
66
|
+
overflow: "hidden",
|
|
67
|
+
boxShadow: 1,
|
|
68
|
+
border: 1,
|
|
69
|
+
borderColor: "divider",
|
|
70
|
+
borderLeft: "4px solid",
|
|
71
|
+
borderLeftColor: "primary.main",
|
|
72
|
+
// Same bg as left panel so slide-in reveals white over gradient
|
|
73
|
+
bgcolor: (t) => t.palette.mode === "dark" ? "background.default" : "#f8faff",
|
|
74
|
+
...mobileFadeIn
|
|
75
|
+
},
|
|
76
|
+
children: [
|
|
77
|
+
!hideLeft && /* @__PURE__ */ jsx(
|
|
78
|
+
Box,
|
|
79
|
+
{
|
|
80
|
+
sx: {
|
|
81
|
+
flex: 1,
|
|
82
|
+
bgcolor: (t) => t.palette.mode === "dark" ? "background.default" : "#f8faff",
|
|
83
|
+
p: { xs: 3, md: 5 },
|
|
84
|
+
pt: { xs: 3, md: 4 },
|
|
85
|
+
display: "flex",
|
|
86
|
+
flexDirection: "column",
|
|
87
|
+
...fadeIn
|
|
88
|
+
},
|
|
89
|
+
children: left
|
|
90
|
+
}
|
|
91
|
+
),
|
|
92
|
+
/* @__PURE__ */ jsx(
|
|
93
|
+
Box,
|
|
94
|
+
{
|
|
95
|
+
sx: {
|
|
96
|
+
width: hideLeft ? "100%" : { xs: "100%", md: 480 },
|
|
97
|
+
flexShrink: 0,
|
|
98
|
+
bgcolor: "background.paper",
|
|
99
|
+
p: { xs: 3, md: 4 },
|
|
100
|
+
pt: { xs: 3, md: 4 },
|
|
101
|
+
display: "flex",
|
|
102
|
+
flexDirection: "column",
|
|
103
|
+
overflow: { md: "hidden" },
|
|
104
|
+
...hideLeft ? {} : slideInFromRight
|
|
105
|
+
},
|
|
106
|
+
children: right
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
const mobileBg = isDark ? theme.palette.background.default : theme.palette.grey[100];
|
|
114
|
+
const desktopBg = isDark ? theme.palette.background.default : "#f8faff";
|
|
115
|
+
return /* @__PURE__ */ jsxs(
|
|
116
|
+
Box,
|
|
117
|
+
{
|
|
118
|
+
sx: {
|
|
119
|
+
width: "100%",
|
|
120
|
+
height: { xs: "auto", md: "100vh" },
|
|
121
|
+
minHeight: { xs: "100vh" },
|
|
122
|
+
overflow: { md: "hidden" },
|
|
123
|
+
display: "flex",
|
|
124
|
+
flexDirection: { xs: "column", md: "row" },
|
|
125
|
+
position: "relative",
|
|
126
|
+
// Mobile: solid gray bg; Desktop: gradient over light blue
|
|
127
|
+
background: isMobile ? mobileBg : `linear-gradient(160deg, ${alpha(theme.palette.primary.main, 0.03)} 0%, ${alpha(theme.palette.primary.main, 0.07)} 50%, ${alpha(theme.palette.primary.main, 0.04)} 100%)`,
|
|
128
|
+
bgcolor: desktopBg,
|
|
129
|
+
...mobileFadeIn
|
|
130
|
+
},
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ jsx(
|
|
133
|
+
Header,
|
|
134
|
+
{
|
|
135
|
+
sx: {
|
|
136
|
+
position: "absolute",
|
|
137
|
+
top: 20,
|
|
138
|
+
left: 0,
|
|
139
|
+
right: 0,
|
|
140
|
+
zIndex: 10,
|
|
141
|
+
background: "transparent",
|
|
142
|
+
"& .header-container": { height: "auto" }
|
|
143
|
+
},
|
|
144
|
+
hideNavMenu: true,
|
|
145
|
+
brand: null,
|
|
146
|
+
description: null,
|
|
147
|
+
addons: (buildIns) => {
|
|
148
|
+
const addons = buildIns.filter(
|
|
149
|
+
(addon) => ["locale-selector", "theme-mode-toggle", "session-user"].includes(addon.key)
|
|
150
|
+
);
|
|
151
|
+
return addons;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
),
|
|
155
|
+
!hideLeft && /* @__PURE__ */ jsx(
|
|
156
|
+
Box,
|
|
157
|
+
{
|
|
158
|
+
sx: {
|
|
159
|
+
width: { xs: "100%", md: "50%" },
|
|
160
|
+
height: { xs: "auto", md: "100vh" },
|
|
161
|
+
display: "flex",
|
|
162
|
+
justifyContent: { md: "center" },
|
|
163
|
+
...isMobile ? { bgcolor: "background.paper", mt: 9 } : {},
|
|
164
|
+
...hiddenScrollbar
|
|
165
|
+
},
|
|
166
|
+
children: /* @__PURE__ */ jsx(
|
|
167
|
+
Box,
|
|
168
|
+
{
|
|
169
|
+
sx: {
|
|
170
|
+
width: "100%",
|
|
171
|
+
maxWidth: { md: 640 },
|
|
172
|
+
p: { xs: 3, md: 5 },
|
|
173
|
+
pt: { xs: 3, md: 10 },
|
|
174
|
+
display: "flex",
|
|
175
|
+
flexDirection: "column",
|
|
176
|
+
flex: 1,
|
|
177
|
+
...fadeIn
|
|
178
|
+
},
|
|
179
|
+
children: left
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
/* @__PURE__ */ jsx(
|
|
185
|
+
Box,
|
|
186
|
+
{
|
|
187
|
+
sx: {
|
|
188
|
+
width: hideLeft ? "100%" : { xs: "100%", md: "50%" },
|
|
189
|
+
height: hideLeft ? "100vh" : { xs: "auto", md: "100vh" },
|
|
190
|
+
bgcolor: "background.paper",
|
|
191
|
+
boxShadow: hideLeft ? "none" : { md: "-4px 0 16px rgba(0,0,0,0.04)" },
|
|
192
|
+
position: "relative",
|
|
193
|
+
display: "flex",
|
|
194
|
+
flexDirection: "column",
|
|
195
|
+
...hideLeft ? {} : slideInFromRight,
|
|
196
|
+
...isMobile && !hideLeft ? { pb: "180px", mt: 2 } : {},
|
|
197
|
+
// Mobile: scroll entire panel; Desktop: let PaymentPanel handle internal scroll
|
|
198
|
+
overflowY: { xs: "auto", md: "hidden" },
|
|
199
|
+
"&::-webkit-scrollbar": { display: "none" },
|
|
200
|
+
scrollbarWidth: "none",
|
|
201
|
+
...mobileSubmitBarSx
|
|
202
|
+
},
|
|
203
|
+
children: /* @__PURE__ */ jsx(
|
|
204
|
+
Box,
|
|
205
|
+
{
|
|
206
|
+
sx: {
|
|
207
|
+
width: "100%",
|
|
208
|
+
maxWidth: { md: 600 },
|
|
209
|
+
mx: "auto",
|
|
210
|
+
p: { xs: 3, md: 4 },
|
|
211
|
+
pt: hideLeft ? { xs: 10, md: "10vh" } : { xs: 3, md: "10vh" },
|
|
212
|
+
display: "flex",
|
|
213
|
+
flexDirection: "column",
|
|
214
|
+
flex: 1,
|
|
215
|
+
minHeight: 0,
|
|
216
|
+
justifyContent: hideLeft ? "center" : void 0
|
|
217
|
+
},
|
|
218
|
+
children: right
|
|
219
|
+
}
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function CompositePanel(): import("react").JSX.Element;
|