@springmicro/cart 0.7.24 → 0.7.26
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/index.js +7262 -6743
- package/dist/index.umd.cjs +69 -61
- package/package.json +5 -5
- package/src/checkout/ReviewCartAndCalculateTaxes.css +1 -0
- package/src/checkout/ReviewCartAndCalculateTaxes.tsx +12 -9
- package/src/checkout/components/AddCard.tsx +17 -11
- package/src/checkout/components/CartList.tsx +17 -21
- package/src/checkout/components/CartProductCard.css +1 -1
- package/src/checkout/components/CartProductCard.tsx +7 -0
- package/src/checkout/components/StatusBar.tsx +175 -24
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@springmicro/cart",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.26",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"@nanostores/persistent": "^0.10.1",
|
|
25
25
|
"@nanostores/query": "^0.3.3",
|
|
26
26
|
"@nanostores/react": "^0.7.2",
|
|
27
|
-
"@springmicro/utils": "^0.7.
|
|
27
|
+
"@springmicro/utils": "^0.7.26",
|
|
28
28
|
"dotenv": "^16.4.5",
|
|
29
29
|
"nanostores": "^0.10.3",
|
|
30
|
-
"react": "
|
|
30
|
+
"react": "18.3.1",
|
|
31
31
|
"react-credit-cards-2": "^1.0.2",
|
|
32
|
-
"react-dom": "
|
|
32
|
+
"react-dom": "18.3.1",
|
|
33
33
|
"unstorage": "^1.10.2",
|
|
34
34
|
"vite-plugin-dts": "^3.9.0"
|
|
35
35
|
},
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"vite-plugin-css-injected-by-js": "^3.5.1",
|
|
50
50
|
"yup": "^1.4.0"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "fb10f8c2a5f1bdc81700ba962f1e8cac0168247f"
|
|
53
53
|
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
Fade,
|
|
11
11
|
Typography,
|
|
12
12
|
IconButton,
|
|
13
|
+
Container,
|
|
13
14
|
} from "@mui/material";
|
|
14
15
|
import { setOrder as cartSetOrder } from "../utils/storage";
|
|
15
16
|
import { AddCard, CCFocus, CreditCardValues } from "./components/AddCard";
|
|
@@ -450,14 +451,16 @@ export default function ReviewAndCalculateTaxes({
|
|
|
450
451
|
gap: 2,
|
|
451
452
|
}}
|
|
452
453
|
>
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
454
|
+
<Container>
|
|
455
|
+
{CollectExtraInfo && <CollectExtraInfo formik={formik} />}
|
|
456
|
+
<CheckoutActionFields
|
|
457
|
+
formik={formik}
|
|
458
|
+
prices={prices}
|
|
459
|
+
products={products}
|
|
460
|
+
hideFields={hideFields}
|
|
461
|
+
disableFields={disableFields}
|
|
462
|
+
/>
|
|
463
|
+
</Container>
|
|
461
464
|
<AddCard
|
|
462
465
|
cardRequired={cardRequired}
|
|
463
466
|
onSubmit={createOrderAndGetTaxes}
|
|
@@ -519,7 +522,7 @@ function CheckoutActionFields({
|
|
|
519
522
|
};
|
|
520
523
|
// console.log({ checkoutFields });
|
|
521
524
|
return (
|
|
522
|
-
<Box sx={{ display: "flex", flexDirection: "column",
|
|
525
|
+
<Box sx={{ display: "flex", flexDirection: "column", gap: 2 }}>
|
|
523
526
|
{Object.keys(checkoutFields)
|
|
524
527
|
.filter(
|
|
525
528
|
(key) =>
|
|
@@ -295,18 +295,24 @@ export const AddCard = ({
|
|
|
295
295
|
payment information.
|
|
296
296
|
</Typography>
|
|
297
297
|
)}
|
|
298
|
-
<
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
298
|
+
<Box
|
|
299
|
+
sx={{
|
|
300
|
+
display: "flex",
|
|
301
|
+
flexDirection: "row",
|
|
302
|
+
justifyContent: "space-between",
|
|
303
|
+
mt: 1,
|
|
304
|
+
mb: 4,
|
|
305
|
+
}}
|
|
306
306
|
>
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
307
|
+
<Button
|
|
308
|
+
size="large"
|
|
309
|
+
variant="contained"
|
|
310
|
+
type="submit"
|
|
311
|
+
disabled={formDisabled}
|
|
312
|
+
color={formError ? "error" : undefined}
|
|
313
|
+
>
|
|
314
|
+
Review
|
|
315
|
+
</Button>
|
|
310
316
|
<StripeLogoLink />
|
|
311
317
|
</Box>
|
|
312
318
|
</form>
|
|
@@ -46,7 +46,7 @@ export function CartList({
|
|
|
46
46
|
sx={{
|
|
47
47
|
display: "flex",
|
|
48
48
|
flexDirection: "column",
|
|
49
|
-
maxWidth: 650,
|
|
49
|
+
maxWidth: { xs: 300, sm: 650 },
|
|
50
50
|
alignItems: "center",
|
|
51
51
|
boxShadow: "0px 2px 5px 2px #dfdfdfff",
|
|
52
52
|
margin: "4px",
|
|
@@ -58,36 +58,32 @@ export function CartList({
|
|
|
58
58
|
<Typography style={{ fontSize: "30px", fontWeight: "bold" }}>
|
|
59
59
|
Checkout
|
|
60
60
|
</Typography>
|
|
61
|
+
|
|
61
62
|
<Box
|
|
62
63
|
sx={{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
display: "grid",
|
|
65
|
+
gridTemplateColumns: { xs: "1fr", sm: "1fr 1fr" },
|
|
66
|
+
gap: { sm: 2 },
|
|
67
|
+
mt: { xs: 2, sm: 1 },
|
|
66
68
|
}}
|
|
67
69
|
>
|
|
68
|
-
<Typography sx={{ fontSize: "20px"
|
|
70
|
+
<Typography sx={{ fontSize: "20px" }}>
|
|
69
71
|
Subtotal: {formatPrice(subtotal)}
|
|
70
72
|
</Typography>
|
|
71
|
-
<Typography sx={{ fontSize: "20px"
|
|
73
|
+
<Typography sx={{ fontSize: "20px" }}>
|
|
72
74
|
Taxes: {formatPrice(taxes)}
|
|
73
75
|
</Typography>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
sx={{
|
|
78
|
-
width: "50%",
|
|
79
|
-
display: "flex",
|
|
80
|
-
justifyContent: "space-between",
|
|
81
|
-
}}
|
|
82
|
-
>
|
|
83
|
-
<Typography sx={{ fontSize: "20px", p: 1 }}>
|
|
84
|
-
{shipping && <>Shipping: {formatPrice(shipping)}</>}
|
|
76
|
+
{!!shipping && (
|
|
77
|
+
<Typography sx={{ fontSize: "20px" }}>
|
|
78
|
+
Shipping: {formatPrice(shipping)}
|
|
85
79
|
</Typography>
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
)}
|
|
81
|
+
{!!discount && (
|
|
82
|
+
<Typography sx={{ fontSize: "20px" }}>
|
|
83
|
+
Discount: {formatPrice(discount)}
|
|
88
84
|
</Typography>
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
)}
|
|
86
|
+
</Box>
|
|
91
87
|
<Box>
|
|
92
88
|
<Typography style={{ fontSize: "26px" }}>
|
|
93
89
|
Total:{" "}
|
|
@@ -82,6 +82,13 @@ export function CartProductCard({
|
|
|
82
82
|
>
|
|
83
83
|
<IconButton
|
|
84
84
|
className="remove-button"
|
|
85
|
+
sx={{
|
|
86
|
+
color: { xs: "red !important", md: "#ff000040 !important" },
|
|
87
|
+
transition: "all 0.2s !important",
|
|
88
|
+
":hover": {
|
|
89
|
+
color: "red !important",
|
|
90
|
+
},
|
|
91
|
+
}}
|
|
85
92
|
onClick={() => {
|
|
86
93
|
removeFromCart(i);
|
|
87
94
|
}}
|
|
@@ -1,40 +1,191 @@
|
|
|
1
|
-
import { Box, IconButton,
|
|
2
|
-
import
|
|
1
|
+
import { Box, IconButton, Tooltip, Typography } from "@mui/material";
|
|
2
|
+
import CheckIcon from "@mui/icons-material/Check";
|
|
3
|
+
import CloseIcon from "@mui/icons-material/Close";
|
|
4
|
+
|
|
5
|
+
const BLUE = "rgb(40, 130, 213)";
|
|
6
|
+
const STEPS = ["PAYMENT DETAILS", "CONFIRMATION", "ORDER PLACED"];
|
|
7
|
+
|
|
8
|
+
function ProgressDots({ status }) {
|
|
9
|
+
return (
|
|
10
|
+
<Box sx={{ display: "flex", gap: "5px", alignItems: "center", ml: "14px" }}>
|
|
11
|
+
{STEPS.map((_, i) => {
|
|
12
|
+
const isCurrent = i === status;
|
|
13
|
+
const isDone = i < status;
|
|
14
|
+
return (
|
|
15
|
+
<Box
|
|
16
|
+
key={i}
|
|
17
|
+
sx={{
|
|
18
|
+
height: 6,
|
|
19
|
+
width: isCurrent ? 18 : 6,
|
|
20
|
+
borderRadius: isCurrent ? "3px" : "50%",
|
|
21
|
+
background:
|
|
22
|
+
isDone || isCurrent
|
|
23
|
+
? BLUE
|
|
24
|
+
: "var(--color-border-tertiary, lightgrey)",
|
|
25
|
+
transition:
|
|
26
|
+
"width 0.3s ease, border-radius 0.3s ease, background 0.3s ease",
|
|
27
|
+
flexShrink: 0,
|
|
28
|
+
}}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
})}
|
|
32
|
+
</Box>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
3
35
|
|
|
4
36
|
export function StatusBar({ status, backlink = "" }) {
|
|
37
|
+
const isLast = status >= STEPS.length - 1;
|
|
38
|
+
|
|
5
39
|
return (
|
|
6
40
|
<Box
|
|
7
|
-
|
|
41
|
+
sx={{
|
|
8
42
|
display: "flex",
|
|
9
|
-
|
|
10
|
-
|
|
43
|
+
alignItems: "center",
|
|
44
|
+
width: "100%",
|
|
45
|
+
py: 1.5,
|
|
46
|
+
boxSizing: "border-box",
|
|
11
47
|
}}
|
|
12
48
|
>
|
|
13
|
-
|
|
49
|
+
{/* Back button */}
|
|
50
|
+
<Box
|
|
51
|
+
sx={{
|
|
52
|
+
flexShrink: 0,
|
|
53
|
+
width: 30,
|
|
54
|
+
position: "absolute",
|
|
55
|
+
top: { xs: 8, md: 20 },
|
|
56
|
+
left: { xs: 8, md: 20 },
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
14
59
|
<Tooltip title="Exit checkout">
|
|
15
|
-
<IconButton href={`/${backlink}`}>
|
|
16
|
-
<
|
|
60
|
+
<IconButton href={`/${backlink}`} size="small">
|
|
61
|
+
<CloseIcon fontSize="small" />
|
|
17
62
|
</IconButton>
|
|
18
63
|
</Tooltip>
|
|
19
64
|
</Box>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
65
|
+
|
|
66
|
+
{/* Center content */}
|
|
67
|
+
<Box
|
|
68
|
+
sx={{
|
|
69
|
+
flex: 1,
|
|
70
|
+
display: "flex",
|
|
71
|
+
alignItems: "center",
|
|
72
|
+
justifyContent: "center",
|
|
73
|
+
flexDirection: "column",
|
|
74
|
+
gap: "12px",
|
|
75
|
+
minWidth: 0,
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
29
78
|
<Box
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
79
|
+
sx={{
|
|
80
|
+
flex: 1,
|
|
81
|
+
display: "flex",
|
|
82
|
+
alignItems: "center",
|
|
83
|
+
justifyContent: "center",
|
|
84
|
+
gap: "12px",
|
|
85
|
+
minWidth: 0,
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
{isLast ? (
|
|
89
|
+
/* Order placed — done state */
|
|
90
|
+
<Box sx={{ display: "flex", alignItems: "center", gap: "8px" }}>
|
|
91
|
+
<Box
|
|
92
|
+
sx={{
|
|
93
|
+
width: 22,
|
|
94
|
+
height: 22,
|
|
95
|
+
borderRadius: "50%",
|
|
96
|
+
background: BLUE,
|
|
97
|
+
display: "flex",
|
|
98
|
+
alignItems: "center",
|
|
99
|
+
justifyContent: "center",
|
|
100
|
+
flexShrink: 0,
|
|
101
|
+
}}
|
|
102
|
+
>
|
|
103
|
+
<CheckIcon sx={{ fontSize: 13, color: "white" }} />
|
|
104
|
+
</Box>
|
|
105
|
+
<Typography
|
|
106
|
+
sx={{
|
|
107
|
+
fontSize: "15px",
|
|
108
|
+
fontWeight: 600,
|
|
109
|
+
color: BLUE,
|
|
110
|
+
letterSpacing: "0.03em",
|
|
111
|
+
}}
|
|
112
|
+
>
|
|
113
|
+
ORDER PLACED
|
|
114
|
+
</Typography>
|
|
115
|
+
</Box>
|
|
116
|
+
) : (
|
|
117
|
+
<>
|
|
118
|
+
{/* Current step */}
|
|
119
|
+
<Box
|
|
120
|
+
sx={{ display: "flex", flexDirection: "column", gap: "2px" }}
|
|
121
|
+
>
|
|
122
|
+
<Typography
|
|
123
|
+
sx={{
|
|
124
|
+
fontSize: "10px",
|
|
125
|
+
fontWeight: 600,
|
|
126
|
+
letterSpacing: "0.09em",
|
|
127
|
+
color: "text.disabled",
|
|
128
|
+
textTransform: "uppercase",
|
|
129
|
+
}}
|
|
130
|
+
>
|
|
131
|
+
Current
|
|
132
|
+
</Typography>
|
|
133
|
+
<Typography
|
|
134
|
+
sx={{
|
|
135
|
+
fontSize: "15px",
|
|
136
|
+
fontWeight: 600,
|
|
137
|
+
color: BLUE,
|
|
138
|
+
letterSpacing: "0.03em",
|
|
139
|
+
whiteSpace: "nowrap",
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
{STEPS[status]}
|
|
143
|
+
</Typography>
|
|
144
|
+
</Box>
|
|
145
|
+
|
|
146
|
+
{/* Divider */}
|
|
147
|
+
<Box
|
|
148
|
+
sx={{
|
|
149
|
+
width: "1px",
|
|
150
|
+
height: 28,
|
|
151
|
+
background: "divider",
|
|
152
|
+
flexShrink: 0,
|
|
153
|
+
}}
|
|
154
|
+
/>
|
|
155
|
+
|
|
156
|
+
{/* Next step */}
|
|
157
|
+
<Box
|
|
158
|
+
sx={{ display: "flex", flexDirection: "column", gap: "2px" }}
|
|
159
|
+
>
|
|
160
|
+
<Typography
|
|
161
|
+
sx={{
|
|
162
|
+
fontSize: "10px",
|
|
163
|
+
fontWeight: 600,
|
|
164
|
+
letterSpacing: "0.09em",
|
|
165
|
+
color: "text.disabled",
|
|
166
|
+
textTransform: "uppercase",
|
|
167
|
+
}}
|
|
168
|
+
>
|
|
169
|
+
Next
|
|
170
|
+
</Typography>
|
|
171
|
+
<Typography
|
|
172
|
+
sx={{
|
|
173
|
+
fontSize: "13px",
|
|
174
|
+
fontWeight: 500,
|
|
175
|
+
color: "text.secondary",
|
|
176
|
+
whiteSpace: "nowrap",
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
{STEPS[status + 1]}
|
|
180
|
+
</Typography>
|
|
181
|
+
</Box>
|
|
182
|
+
|
|
183
|
+
{/* Progress dots */}
|
|
184
|
+
</>
|
|
185
|
+
)}
|
|
186
|
+
</Box>
|
|
187
|
+
{!isLast && <ProgressDots status={status} />}
|
|
36
188
|
</Box>
|
|
37
|
-
<Box sx={{ flex: "1 1" }} />
|
|
38
189
|
</Box>
|
|
39
190
|
);
|
|
40
191
|
}
|