@instockng/storefront-ui 1.0.22 → 1.0.23
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/Checkout.d.ts.map +1 -1
- package/dist/components/ShoppingCart.d.ts.map +1 -1
- package/dist/contexts/CartContext.d.ts.map +1 -1
- package/dist/index10.mjs +53 -59
- package/dist/index100.mjs +3 -3
- package/dist/index101.mjs +1 -1
- package/dist/index102.mjs +1 -1
- package/dist/index103.mjs +1 -1
- package/dist/index104.mjs +2 -2
- package/dist/index105.mjs +2 -2
- package/dist/index106.mjs +3 -3
- package/dist/index107.mjs +1 -1
- package/dist/index108.mjs +3 -3
- package/dist/index109.mjs +2 -2
- package/dist/index110.mjs +2 -2
- package/dist/index111.mjs +1 -1
- package/dist/index112.mjs +3 -3
- package/dist/index113.mjs +1 -1
- package/dist/index114.mjs +1 -1
- package/dist/index115.mjs +3 -3
- package/dist/index116.mjs +2 -2
- package/dist/index117.mjs +4 -4
- package/dist/index118.mjs +1 -1
- package/dist/index119.mjs +3 -3
- package/dist/index12.mjs +456 -438
- package/dist/index120.mjs +4 -4
- package/dist/index121.mjs +1 -1
- package/dist/index122.mjs +1 -1
- package/dist/index123.mjs +1 -1
- package/dist/index124.mjs +1 -1
- package/dist/index125.mjs +1 -1
- package/dist/index126.mjs +1 -1
- package/dist/index127.mjs +1 -1
- package/dist/index128.mjs +2 -2
- package/dist/index129.mjs +3 -3
- package/dist/index132.mjs +1 -1
- package/dist/index134.mjs +2 -21
- package/dist/index135.mjs +2 -56
- package/dist/index136.mjs +2 -29
- package/dist/index137.mjs +2 -7
- package/dist/index138.mjs +16 -50
- package/dist/index139.mjs +32 -6
- package/dist/index140.mjs +37 -11
- package/dist/index141.mjs +18 -7
- package/dist/index142.mjs +18 -28
- package/dist/index143.mjs +2 -2
- package/dist/index144.mjs +20 -70
- package/dist/index145.mjs +42 -163
- package/dist/index147.mjs +30 -2
- package/dist/index148.mjs +18 -2
- package/dist/index149.mjs +2 -2
- package/dist/index150.mjs +2 -18
- package/dist/index151.mjs +2 -32
- package/dist/index152.mjs +2 -38
- package/dist/index153.mjs +67 -13
- package/dist/index154.mjs +2 -18
- package/dist/index155.mjs +53 -2
- package/dist/index156.mjs +2 -20
- package/dist/index157.mjs +29 -39
- package/dist/index158.mjs +152 -2
- package/dist/index159.mjs +2 -30
- package/dist/index160.mjs +2 -18
- package/dist/index161.mjs +19 -2
- package/dist/index162.mjs +2 -2
- package/dist/index163.mjs +2 -2
- package/dist/index164.mjs +26 -2
- package/dist/index165.mjs +2 -72
- package/dist/index166.mjs +2 -2
- package/dist/index167.mjs +20 -49
- package/dist/index168.mjs +23 -2
- package/dist/index169.mjs +2 -36
- package/dist/index170.mjs +2 -152
- package/dist/index171.mjs +2 -2
- package/dist/index172.mjs +23 -2
- package/dist/index173.mjs +2 -19
- package/dist/index174.mjs +23 -2
- package/dist/index176.mjs +2 -26
- package/dist/index177.mjs +2 -2
- package/dist/index178.mjs +23 -2
- package/dist/index179.mjs +2 -24
- package/dist/index180.mjs +15 -15
- package/dist/index181.mjs +2 -2
- package/dist/index182.mjs +2 -2
- package/dist/index183.mjs +2 -2
- package/dist/index184.mjs +2 -23
- package/dist/index185.mjs +2 -2
- package/dist/index186.mjs +2 -23
- package/dist/index187.mjs +2 -2
- package/dist/index188.mjs +2 -2
- package/dist/index189.mjs +127 -2
- package/dist/index190.mjs +2 -23
- package/dist/index191.mjs +74 -2
- package/dist/index192.mjs +71 -20
- package/dist/index193.mjs +21 -2
- package/dist/index194.mjs +56 -2
- package/dist/index195.mjs +29 -2
- package/dist/index196.mjs +7 -2
- package/dist/index197.mjs +52 -2
- package/dist/index198.mjs +6 -2
- package/dist/index199.mjs +12 -2
- package/dist/index2.mjs +10 -10
- package/dist/index20.mjs +2 -2
- package/dist/index200.mjs +7 -2
- package/dist/index201.mjs +28 -127
- package/dist/index202.mjs +2 -2
- package/dist/index203.mjs +69 -73
- package/dist/index204.mjs +164 -71
- package/dist/index205.mjs +2 -2
- package/dist/index206.mjs +2 -2
- package/dist/index208.mjs +2 -2
- package/dist/index209.mjs +2 -2
- package/dist/index21.mjs +2 -2
- package/dist/index210.mjs +2 -2
- package/dist/index211.mjs +108 -2
- package/dist/index212.mjs +2 -2
- package/dist/index213.mjs +2 -108
- package/dist/index214.mjs +2 -2
- package/dist/index215.mjs +2 -2
- package/dist/index216.mjs +243 -36
- package/dist/index217.mjs +2 -2
- package/dist/index218.mjs +32 -243
- package/dist/index219.mjs +65 -2
- package/dist/index220.mjs +16 -24
- package/dist/index221.mjs +2 -65
- package/dist/index222.mjs +31 -19
- package/dist/index230.mjs +2 -2
- package/dist/index231.mjs +2 -2
- package/dist/index245.mjs +3 -3
- package/dist/index248.mjs +2 -2
- package/dist/index249.mjs +2 -18
- package/dist/index25.mjs +5 -0
- package/dist/index250.mjs +13 -42
- package/dist/index251.mjs +47 -2
- package/dist/index252.mjs +2 -2
- package/dist/index253.mjs +2 -2
- package/dist/index254.mjs +2 -2
- package/dist/index255.mjs +2 -91
- package/dist/index256.mjs +91 -2
- package/dist/index263.mjs +1 -1
- package/dist/index264.mjs +1 -1
- package/dist/index3.mjs +82 -82
- package/dist/index38.mjs +1 -1
- package/dist/index42.mjs +1 -1
- package/dist/index49.mjs +59 -59
- package/dist/index50.mjs +50 -50
- package/dist/index51.mjs +48 -48
- package/dist/index52.mjs +56 -56
- package/dist/index53.mjs +39 -39
- package/dist/index54.mjs +55 -55
- package/dist/index55.mjs +15 -15
- package/dist/index56.mjs +10 -10
- package/dist/index57.mjs +23 -23
- package/dist/index58.mjs +64 -64
- package/dist/index59.mjs +73 -73
- package/dist/index62.mjs +149 -19
- package/dist/index63.mjs +19 -149
- package/dist/index73.mjs +1 -1
- package/dist/index78.mjs +5 -5
- package/dist/index80.mjs +3 -3
- package/dist/index90.mjs +1 -1
- package/dist/index91.mjs +3 -3
- package/dist/index96.mjs +1 -1
- package/dist/index97.mjs +1 -1
- package/dist/index98.mjs +6 -6
- package/dist/index99.mjs +4 -4
- package/dist/providers/StorefrontProvider.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +12 -11
- package/src/components/CartItem.stories.tsx +5 -5
- package/src/components/Checkout.stories.tsx +16 -15
- package/src/components/Checkout.tsx +42 -0
- package/src/components/ShoppingCart.stories.tsx +17 -16
- package/src/components/ShoppingCart.tsx +3 -11
- package/src/contexts/CartContext.tsx +2 -1
- package/src/providers/StorefrontProvider.tsx +4 -1
- package/src/test-utils/MockCartProvider.tsx +31 -25
package/dist/index250.mjs
CHANGED
|
@@ -1,50 +1,21 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { __exports as
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
return
|
|
6
|
-
Object.defineProperty(
|
|
2
|
+
import { __exports as r } from "./index265.mjs";
|
|
3
|
+
var u;
|
|
4
|
+
function s() {
|
|
5
|
+
return u ? r : (u = 1, function(n) {
|
|
6
|
+
Object.defineProperty(n, "__esModule", {
|
|
7
7
|
value: !0
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
get: n[t]
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
a(i, {
|
|
16
|
-
DEFAULT_SEGMENT_KEY: function() {
|
|
17
|
-
return E;
|
|
18
|
-
},
|
|
19
|
-
PAGE_SEGMENT_KEY: function() {
|
|
20
|
-
return r;
|
|
21
|
-
},
|
|
22
|
-
addSearchParamsIfPageSegment: function() {
|
|
23
|
-
return s;
|
|
24
|
-
},
|
|
25
|
-
isGroupSegment: function() {
|
|
26
|
-
return c;
|
|
27
|
-
},
|
|
28
|
-
isParallelRouteSegment: function() {
|
|
29
|
-
return f;
|
|
8
|
+
}), Object.defineProperty(n, "ensureLeadingSlash", {
|
|
9
|
+
enumerable: !0,
|
|
10
|
+
get: function() {
|
|
11
|
+
return t;
|
|
30
12
|
}
|
|
31
13
|
});
|
|
32
|
-
function
|
|
33
|
-
return e
|
|
34
|
-
}
|
|
35
|
-
function f(e) {
|
|
36
|
-
return e.startsWith("@") && e !== "@children";
|
|
37
|
-
}
|
|
38
|
-
function s(e, n) {
|
|
39
|
-
if (e.includes(r)) {
|
|
40
|
-
const o = JSON.stringify(n);
|
|
41
|
-
return o !== "{}" ? r + "?" + o : r;
|
|
42
|
-
}
|
|
43
|
-
return e;
|
|
14
|
+
function t(e) {
|
|
15
|
+
return e.startsWith("/") ? e : "/" + e;
|
|
44
16
|
}
|
|
45
|
-
|
|
46
|
-
}(u), u);
|
|
17
|
+
}(r), r);
|
|
47
18
|
}
|
|
48
19
|
export {
|
|
49
|
-
|
|
20
|
+
s as __require
|
|
50
21
|
};
|
package/dist/index251.mjs
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
2
|
+
import { __exports as u } from "./index266.mjs";
|
|
3
|
+
var _;
|
|
4
|
+
function g() {
|
|
5
|
+
return _ ? u : (_ = 1, function(i) {
|
|
6
|
+
Object.defineProperty(i, "__esModule", {
|
|
7
|
+
value: !0
|
|
8
|
+
});
|
|
9
|
+
function a(e, n) {
|
|
10
|
+
for (var t in n) Object.defineProperty(e, t, {
|
|
11
|
+
enumerable: !0,
|
|
12
|
+
get: n[t]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
a(i, {
|
|
16
|
+
DEFAULT_SEGMENT_KEY: function() {
|
|
17
|
+
return E;
|
|
18
|
+
},
|
|
19
|
+
PAGE_SEGMENT_KEY: function() {
|
|
20
|
+
return r;
|
|
21
|
+
},
|
|
22
|
+
addSearchParamsIfPageSegment: function() {
|
|
23
|
+
return s;
|
|
24
|
+
},
|
|
25
|
+
isGroupSegment: function() {
|
|
26
|
+
return c;
|
|
27
|
+
},
|
|
28
|
+
isParallelRouteSegment: function() {
|
|
29
|
+
return f;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
function c(e) {
|
|
33
|
+
return e[0] === "(" && e.endsWith(")");
|
|
34
|
+
}
|
|
35
|
+
function f(e) {
|
|
36
|
+
return e.startsWith("@") && e !== "@children";
|
|
37
|
+
}
|
|
38
|
+
function s(e, n) {
|
|
39
|
+
if (e.includes(r)) {
|
|
40
|
+
const o = JSON.stringify(n);
|
|
41
|
+
return o !== "{}" ? r + "?" + o : r;
|
|
42
|
+
}
|
|
43
|
+
return e;
|
|
44
|
+
}
|
|
45
|
+
const r = "__PAGE__", E = "__DEFAULT__";
|
|
46
|
+
}(u), u);
|
|
47
|
+
}
|
|
3
48
|
export {
|
|
4
|
-
|
|
49
|
+
g as __require
|
|
5
50
|
};
|
package/dist/index252.mjs
CHANGED
package/dist/index253.mjs
CHANGED
package/dist/index254.mjs
CHANGED
package/dist/index255.mjs
CHANGED
|
@@ -1,94 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
var l;
|
|
4
|
-
function T() {
|
|
5
|
-
return l ? c.exports : (l = 1, (() => {
|
|
6
|
-
typeof __nccwpck_require__ < "u" && (__nccwpck_require__.ab = __dirname + "/");
|
|
7
|
-
var m = {};
|
|
8
|
-
(() => {
|
|
9
|
-
var v = m;
|
|
10
|
-
/*!
|
|
11
|
-
* cookie
|
|
12
|
-
* Copyright(c) 2012-2014 Roman Shtylman
|
|
13
|
-
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
14
|
-
* MIT Licensed
|
|
15
|
-
*/
|
|
16
|
-
v.parse = S, v.serialize = x;
|
|
17
|
-
var w = decodeURIComponent, h = encodeURIComponent, y = /; */, f = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
18
|
-
function S(i, n) {
|
|
19
|
-
if (typeof i != "string")
|
|
20
|
-
throw new TypeError("argument str must be a string");
|
|
21
|
-
for (var a = {}, e = n || {}, o = i.split(y), s = e.decode || w, r = 0; r < o.length; r++) {
|
|
22
|
-
var t = o[r], p = t.indexOf("=");
|
|
23
|
-
if (!(p < 0)) {
|
|
24
|
-
var d = t.substr(0, p).trim(), u = t.substr(++p, t.length).trim();
|
|
25
|
-
u[0] == '"' && (u = u.slice(1, -1)), a[d] == null && (a[d] = _(u, s));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return a;
|
|
29
|
-
}
|
|
30
|
-
function x(i, n, a) {
|
|
31
|
-
var e = a || {}, o = e.encode || h;
|
|
32
|
-
if (typeof o != "function")
|
|
33
|
-
throw new TypeError("option encode is invalid");
|
|
34
|
-
if (!f.test(i))
|
|
35
|
-
throw new TypeError("argument name is invalid");
|
|
36
|
-
var s = o(n);
|
|
37
|
-
if (s && !f.test(s))
|
|
38
|
-
throw new TypeError("argument val is invalid");
|
|
39
|
-
var r = i + "=" + s;
|
|
40
|
-
if (e.maxAge != null) {
|
|
41
|
-
var t = e.maxAge - 0;
|
|
42
|
-
if (isNaN(t) || !isFinite(t))
|
|
43
|
-
throw new TypeError("option maxAge is invalid");
|
|
44
|
-
r += "; Max-Age=" + Math.floor(t);
|
|
45
|
-
}
|
|
46
|
-
if (e.domain) {
|
|
47
|
-
if (!f.test(e.domain))
|
|
48
|
-
throw new TypeError("option domain is invalid");
|
|
49
|
-
r += "; Domain=" + e.domain;
|
|
50
|
-
}
|
|
51
|
-
if (e.path) {
|
|
52
|
-
if (!f.test(e.path))
|
|
53
|
-
throw new TypeError("option path is invalid");
|
|
54
|
-
r += "; Path=" + e.path;
|
|
55
|
-
}
|
|
56
|
-
if (e.expires) {
|
|
57
|
-
if (typeof e.expires.toUTCString != "function")
|
|
58
|
-
throw new TypeError("option expires is invalid");
|
|
59
|
-
r += "; Expires=" + e.expires.toUTCString();
|
|
60
|
-
}
|
|
61
|
-
if (e.httpOnly && (r += "; HttpOnly"), e.secure && (r += "; Secure"), e.sameSite) {
|
|
62
|
-
var p = typeof e.sameSite == "string" ? e.sameSite.toLowerCase() : e.sameSite;
|
|
63
|
-
switch (p) {
|
|
64
|
-
case !0:
|
|
65
|
-
r += "; SameSite=Strict";
|
|
66
|
-
break;
|
|
67
|
-
case "lax":
|
|
68
|
-
r += "; SameSite=Lax";
|
|
69
|
-
break;
|
|
70
|
-
case "strict":
|
|
71
|
-
r += "; SameSite=Strict";
|
|
72
|
-
break;
|
|
73
|
-
case "none":
|
|
74
|
-
r += "; SameSite=None";
|
|
75
|
-
break;
|
|
76
|
-
default:
|
|
77
|
-
throw new TypeError("option sameSite is invalid");
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return r;
|
|
81
|
-
}
|
|
82
|
-
function _(i, n) {
|
|
83
|
-
try {
|
|
84
|
-
return n(i);
|
|
85
|
-
} catch {
|
|
86
|
-
return i;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
})(), c.exports = m;
|
|
90
|
-
})(), c.exports);
|
|
91
|
-
}
|
|
2
|
+
var e = {};
|
|
92
3
|
export {
|
|
93
|
-
|
|
4
|
+
e as __exports
|
|
94
5
|
};
|
package/dist/index256.mjs
CHANGED
|
@@ -1,5 +1,94 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
2
|
+
import { __module as c } from "./index267.mjs";
|
|
3
|
+
var l;
|
|
4
|
+
function T() {
|
|
5
|
+
return l ? c.exports : (l = 1, (() => {
|
|
6
|
+
typeof __nccwpck_require__ < "u" && (__nccwpck_require__.ab = __dirname + "/");
|
|
7
|
+
var m = {};
|
|
8
|
+
(() => {
|
|
9
|
+
var v = m;
|
|
10
|
+
/*!
|
|
11
|
+
* cookie
|
|
12
|
+
* Copyright(c) 2012-2014 Roman Shtylman
|
|
13
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
14
|
+
* MIT Licensed
|
|
15
|
+
*/
|
|
16
|
+
v.parse = S, v.serialize = x;
|
|
17
|
+
var w = decodeURIComponent, h = encodeURIComponent, y = /; */, f = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
18
|
+
function S(i, n) {
|
|
19
|
+
if (typeof i != "string")
|
|
20
|
+
throw new TypeError("argument str must be a string");
|
|
21
|
+
for (var a = {}, e = n || {}, o = i.split(y), s = e.decode || w, r = 0; r < o.length; r++) {
|
|
22
|
+
var t = o[r], p = t.indexOf("=");
|
|
23
|
+
if (!(p < 0)) {
|
|
24
|
+
var d = t.substr(0, p).trim(), u = t.substr(++p, t.length).trim();
|
|
25
|
+
u[0] == '"' && (u = u.slice(1, -1)), a[d] == null && (a[d] = _(u, s));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return a;
|
|
29
|
+
}
|
|
30
|
+
function x(i, n, a) {
|
|
31
|
+
var e = a || {}, o = e.encode || h;
|
|
32
|
+
if (typeof o != "function")
|
|
33
|
+
throw new TypeError("option encode is invalid");
|
|
34
|
+
if (!f.test(i))
|
|
35
|
+
throw new TypeError("argument name is invalid");
|
|
36
|
+
var s = o(n);
|
|
37
|
+
if (s && !f.test(s))
|
|
38
|
+
throw new TypeError("argument val is invalid");
|
|
39
|
+
var r = i + "=" + s;
|
|
40
|
+
if (e.maxAge != null) {
|
|
41
|
+
var t = e.maxAge - 0;
|
|
42
|
+
if (isNaN(t) || !isFinite(t))
|
|
43
|
+
throw new TypeError("option maxAge is invalid");
|
|
44
|
+
r += "; Max-Age=" + Math.floor(t);
|
|
45
|
+
}
|
|
46
|
+
if (e.domain) {
|
|
47
|
+
if (!f.test(e.domain))
|
|
48
|
+
throw new TypeError("option domain is invalid");
|
|
49
|
+
r += "; Domain=" + e.domain;
|
|
50
|
+
}
|
|
51
|
+
if (e.path) {
|
|
52
|
+
if (!f.test(e.path))
|
|
53
|
+
throw new TypeError("option path is invalid");
|
|
54
|
+
r += "; Path=" + e.path;
|
|
55
|
+
}
|
|
56
|
+
if (e.expires) {
|
|
57
|
+
if (typeof e.expires.toUTCString != "function")
|
|
58
|
+
throw new TypeError("option expires is invalid");
|
|
59
|
+
r += "; Expires=" + e.expires.toUTCString();
|
|
60
|
+
}
|
|
61
|
+
if (e.httpOnly && (r += "; HttpOnly"), e.secure && (r += "; Secure"), e.sameSite) {
|
|
62
|
+
var p = typeof e.sameSite == "string" ? e.sameSite.toLowerCase() : e.sameSite;
|
|
63
|
+
switch (p) {
|
|
64
|
+
case !0:
|
|
65
|
+
r += "; SameSite=Strict";
|
|
66
|
+
break;
|
|
67
|
+
case "lax":
|
|
68
|
+
r += "; SameSite=Lax";
|
|
69
|
+
break;
|
|
70
|
+
case "strict":
|
|
71
|
+
r += "; SameSite=Strict";
|
|
72
|
+
break;
|
|
73
|
+
case "none":
|
|
74
|
+
r += "; SameSite=None";
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
throw new TypeError("option sameSite is invalid");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return r;
|
|
81
|
+
}
|
|
82
|
+
function _(i, n) {
|
|
83
|
+
try {
|
|
84
|
+
return n(i);
|
|
85
|
+
} catch {
|
|
86
|
+
return i;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
})(), c.exports = m;
|
|
90
|
+
})(), c.exports);
|
|
91
|
+
}
|
|
3
92
|
export {
|
|
4
|
-
|
|
93
|
+
T as __require
|
|
5
94
|
};
|
package/dist/index263.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import o from "./
|
|
2
|
+
import o from "./index200.mjs";
|
|
3
3
|
const n = o.hasStandardBrowserEnv ? /* @__PURE__ */ ((r, e) => (t) => (t = new URL(t, o.origin), r.protocol === t.protocol && r.host === t.host && (e || r.port === t.port)))(
|
|
4
4
|
new URL(o.origin),
|
|
5
5
|
o.navigator && /(msie|trident)/i.test(o.navigator.userAgent)
|
package/dist/index264.mjs
CHANGED
package/dist/index3.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { createContext as
|
|
2
|
+
import { jsxs as ct, jsx as st } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as at, useState as _, useRef as g, useCallback as c, useEffect as d, useContext as ut } from "react";
|
|
4
4
|
import "./index20.mjs";
|
|
5
|
-
import { useGetCart as
|
|
5
|
+
import { useGetCart as it, useCreateCart as ft, useAddCartItem as mt, useUpdateCartItem as dt, useRemoveCartItem as lt, useApplyDiscount as pt, useRemoveDiscount as Ct, useUpdateCart as wt, useCheckoutCart as It } from "./index32.mjs";
|
|
6
6
|
import "@tanstack/react-query";
|
|
7
|
-
import { ShoppingCart as
|
|
8
|
-
import { useMetaPixel as
|
|
9
|
-
const l = "oms_cart_id",
|
|
10
|
-
function
|
|
11
|
-
const [t, f] =
|
|
7
|
+
import { ShoppingCart as ht } from "./index10.mjs";
|
|
8
|
+
import { useMetaPixel as vt } from "./index4.mjs";
|
|
9
|
+
const l = "oms_cart_id", U = at(null);
|
|
10
|
+
function bt({ children: p, brandSlug: i, initialCartId: C, shoppingCartProps: L }) {
|
|
11
|
+
const [t, f] = _(C || null), [A, S] = _(!1), [j, G] = _(!1), b = g(!1), M = g(!1), h = g(!1), { trackAddToCart: v, trackInitiateCheckout: E, trackPurchase: O } = vt(), N = c(() => {
|
|
12
12
|
if (typeof document > "u") return { fbc: void 0, fbp: void 0 };
|
|
13
13
|
const e = (r) => {
|
|
14
14
|
var o;
|
|
@@ -21,10 +21,10 @@ function St({ children: p, brandSlug: i, initialCartId: C, shoppingCartProps: L
|
|
|
21
21
|
};
|
|
22
22
|
}, []);
|
|
23
23
|
d(() => {
|
|
24
|
-
|
|
24
|
+
G(!0);
|
|
25
25
|
}, []), d(() => {
|
|
26
|
-
if (C ||
|
|
27
|
-
|
|
26
|
+
if (C || b.current) return;
|
|
27
|
+
b.current = !0;
|
|
28
28
|
const r = new URLSearchParams(window.location.search).get("cartId");
|
|
29
29
|
if (r) {
|
|
30
30
|
f(r);
|
|
@@ -33,11 +33,11 @@ function St({ children: p, brandSlug: i, initialCartId: C, shoppingCartProps: L
|
|
|
33
33
|
const s = localStorage.getItem(l);
|
|
34
34
|
s && f(s);
|
|
35
35
|
}, [C]);
|
|
36
|
-
const { data: m, isLoading:
|
|
36
|
+
const { data: m, isLoading: q, error: w, refetch: a } = it(t || "", {
|
|
37
37
|
enabled: !!t,
|
|
38
38
|
retry: !1
|
|
39
39
|
// Don't retry on failure - cart might be invalid/expired
|
|
40
|
-
}),
|
|
40
|
+
}), y = ft({
|
|
41
41
|
onSuccess: (e) => {
|
|
42
42
|
if ("error" in e) {
|
|
43
43
|
console.error("Failed to create cart:", e.error);
|
|
@@ -51,20 +51,18 @@ function St({ children: p, brandSlug: i, initialCartId: C, shoppingCartProps: L
|
|
|
51
51
|
retry: 10
|
|
52
52
|
});
|
|
53
53
|
d(() => {
|
|
54
|
-
if (
|
|
55
|
-
|
|
54
|
+
if (M.current) return;
|
|
55
|
+
M.current = !0;
|
|
56
56
|
const e = setTimeout(() => {
|
|
57
|
-
!(typeof window < "u" ? localStorage.getItem(l) : null) && !C &&
|
|
57
|
+
!(typeof window < "u" ? localStorage.getItem(l) : null) && !C && y.mutate(i);
|
|
58
58
|
}, 150);
|
|
59
59
|
return () => clearTimeout(e);
|
|
60
60
|
}, []), d(() => {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
w && t && !h.current && (h.current = !0, console.warn("Cart fetch failed, creating new cart:", w), f(null), typeof window < "u" && localStorage.removeItem(l), setTimeout(() => {
|
|
62
|
+
y.mutate(i), h.current = !1;
|
|
63
63
|
}, 100));
|
|
64
|
-
}, [
|
|
65
|
-
const
|
|
66
|
-
onSuccess: () => a()
|
|
67
|
-
}), H = mt(t || "", {
|
|
64
|
+
}, [w, t, i]);
|
|
65
|
+
const H = mt(t || "", {
|
|
68
66
|
onSuccess: () => a()
|
|
69
67
|
}), K = dt(t || "", {
|
|
70
68
|
onSuccess: () => a()
|
|
@@ -73,9 +71,11 @@ function St({ children: p, brandSlug: i, initialCartId: C, shoppingCartProps: L
|
|
|
73
71
|
}), z = pt(t || "", {
|
|
74
72
|
onSuccess: () => a()
|
|
75
73
|
}), B = Ct(t || "", {
|
|
74
|
+
onSuccess: () => a()
|
|
75
|
+
}), J = wt(t || "", {
|
|
76
76
|
onSuccess: () => a(),
|
|
77
77
|
retry: 3
|
|
78
|
-
}),
|
|
78
|
+
}), Q = It(t || "", {
|
|
79
79
|
onSuccess: (e) => {
|
|
80
80
|
var n;
|
|
81
81
|
if ("error" in e) return;
|
|
@@ -87,7 +87,7 @@ function St({ children: p, brandSlug: i, initialCartId: C, shoppingCartProps: L
|
|
|
87
87
|
item_price: Number(o.priceAtPurchase)
|
|
88
88
|
};
|
|
89
89
|
})) || [], s = `order_${e.id}`;
|
|
90
|
-
|
|
90
|
+
O(
|
|
91
91
|
Number(e.totalPrice),
|
|
92
92
|
"NGN",
|
|
93
93
|
e.id,
|
|
@@ -99,103 +99,103 @@ function St({ children: p, brandSlug: i, initialCartId: C, shoppingCartProps: L
|
|
|
99
99
|
d(() => {
|
|
100
100
|
t && typeof window < "u" && localStorage.setItem(l, t);
|
|
101
101
|
}, [t]);
|
|
102
|
-
const
|
|
102
|
+
const V = c(
|
|
103
103
|
async (e, r, s, n, o) => {
|
|
104
|
-
var
|
|
104
|
+
var $;
|
|
105
105
|
if (!t) throw new Error("No cart ID");
|
|
106
|
-
const { fbc: u, fbp:
|
|
107
|
-
if ("error" in
|
|
108
|
-
const
|
|
109
|
-
(
|
|
110
|
-
var
|
|
111
|
-
return ((
|
|
106
|
+
const { fbc: u, fbp: D } = N(), R = await H.mutateAsync({ sku: n, quantity: o, fbc: u, fbp: D });
|
|
107
|
+
if ("error" in R) return;
|
|
108
|
+
const I = ($ = R.items) == null ? void 0 : $.filter(
|
|
109
|
+
(k) => {
|
|
110
|
+
var F;
|
|
111
|
+
return ((F = k.variant) == null ? void 0 : F.sku) === n;
|
|
112
112
|
}
|
|
113
|
-
);
|
|
114
|
-
if (
|
|
115
|
-
const
|
|
116
|
-
|
|
113
|
+
), T = I == null ? void 0 : I[I.length - 1];
|
|
114
|
+
if (T) {
|
|
115
|
+
const k = `cart_${t}_item_${T.id}`;
|
|
116
|
+
v(e, r, s, o, k);
|
|
117
117
|
} else
|
|
118
|
-
|
|
118
|
+
v(e, r, s, o);
|
|
119
119
|
},
|
|
120
120
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
121
|
-
[t,
|
|
122
|
-
),
|
|
121
|
+
[t, v, N]
|
|
122
|
+
), W = c(
|
|
123
123
|
async (e, r) => {
|
|
124
124
|
if (!t) throw new Error("No cart ID");
|
|
125
|
-
await
|
|
125
|
+
await K.mutateAsync({ itemId: e, quantity: r });
|
|
126
126
|
},
|
|
127
127
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
128
128
|
[t]
|
|
129
|
-
),
|
|
129
|
+
), X = c(
|
|
130
130
|
async (e) => {
|
|
131
131
|
if (!t) throw new Error("No cart ID");
|
|
132
|
-
await
|
|
132
|
+
await Y.mutateAsync(e);
|
|
133
133
|
},
|
|
134
134
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
135
135
|
[t]
|
|
136
|
-
),
|
|
136
|
+
), Z = c(
|
|
137
137
|
async (e) => {
|
|
138
138
|
if (!t) throw new Error("No cart ID");
|
|
139
|
-
await
|
|
139
|
+
await z.mutateAsync({ code: e });
|
|
140
140
|
},
|
|
141
141
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
142
142
|
[t]
|
|
143
|
-
),
|
|
143
|
+
), tt = c(async () => {
|
|
144
144
|
if (!t) throw new Error("No cart ID");
|
|
145
|
-
await
|
|
146
|
-
}, [t]),
|
|
145
|
+
await B.mutateAsync();
|
|
146
|
+
}, [t]), P = c(() => {
|
|
147
147
|
f(null), typeof window < "u" && localStorage.removeItem(l);
|
|
148
|
-
}, []),
|
|
149
|
-
|
|
150
|
-
}, [i]),
|
|
151
|
-
|
|
152
|
-
}, []),
|
|
153
|
-
|
|
154
|
-
}, []),
|
|
148
|
+
}, []), et = c(() => {
|
|
149
|
+
P(), y.mutate(i);
|
|
150
|
+
}, [i]), rt = c(() => {
|
|
151
|
+
S(!0);
|
|
152
|
+
}, []), x = c(() => {
|
|
153
|
+
S(!1);
|
|
154
|
+
}, []), ot = c(() => {
|
|
155
155
|
var n, o;
|
|
156
156
|
if (!m || !t) return;
|
|
157
|
-
const e = Number(((n = m.pricing) == null ? void 0 : n.total) || 0), r = ((o = m.items) == null ? void 0 : o.reduce((u,
|
|
158
|
-
|
|
159
|
-
}, [m, t,
|
|
157
|
+
const e = Number(((n = m.pricing) == null ? void 0 : n.total) || 0), r = ((o = m.items) == null ? void 0 : o.reduce((u, D) => u + D.quantity, 0)) || 0, s = `cart_${t}_checkout`;
|
|
158
|
+
E(e, r, s);
|
|
159
|
+
}, [m, t, E]), nt = {
|
|
160
160
|
cart: m || null,
|
|
161
161
|
cartId: t,
|
|
162
|
-
isLoading:
|
|
163
|
-
error:
|
|
164
|
-
updateCartMutation:
|
|
165
|
-
checkoutMutation:
|
|
166
|
-
addItem:
|
|
167
|
-
updateItem:
|
|
168
|
-
removeItem:
|
|
169
|
-
applyDiscount:
|
|
170
|
-
removeDiscount:
|
|
171
|
-
trackCheckoutInitiated:
|
|
172
|
-
clearCart:
|
|
173
|
-
clearAndCreateNewCart:
|
|
162
|
+
isLoading: q,
|
|
163
|
+
error: w,
|
|
164
|
+
updateCartMutation: J,
|
|
165
|
+
checkoutMutation: Q,
|
|
166
|
+
addItem: V,
|
|
167
|
+
updateItem: W,
|
|
168
|
+
removeItem: X,
|
|
169
|
+
applyDiscount: Z,
|
|
170
|
+
removeDiscount: tt,
|
|
171
|
+
trackCheckoutInitiated: ot,
|
|
172
|
+
clearCart: P,
|
|
173
|
+
clearAndCreateNewCart: et,
|
|
174
174
|
refetch: a,
|
|
175
|
-
isOpen:
|
|
176
|
-
open:
|
|
177
|
-
close:
|
|
175
|
+
isOpen: A,
|
|
176
|
+
open: rt,
|
|
177
|
+
close: x
|
|
178
178
|
};
|
|
179
|
-
return /* @__PURE__ */
|
|
179
|
+
return /* @__PURE__ */ ct(U.Provider, { value: nt, children: [
|
|
180
180
|
p,
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
j && /* @__PURE__ */ st(
|
|
182
|
+
ht,
|
|
183
183
|
{
|
|
184
|
-
isOpen:
|
|
185
|
-
onClose:
|
|
184
|
+
isOpen: A,
|
|
185
|
+
onClose: x,
|
|
186
186
|
...L
|
|
187
187
|
}
|
|
188
188
|
)
|
|
189
189
|
] });
|
|
190
190
|
}
|
|
191
|
-
function
|
|
192
|
-
const p =
|
|
191
|
+
function Mt() {
|
|
192
|
+
const p = ut(U);
|
|
193
193
|
if (!p)
|
|
194
194
|
throw new Error("useCart must be used within CartProvider");
|
|
195
195
|
return p;
|
|
196
196
|
}
|
|
197
197
|
export {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
U as CartContext,
|
|
199
|
+
bt as CartProvider,
|
|
200
|
+
Mt as useCart
|
|
201
201
|
};
|
package/dist/index38.mjs
CHANGED
package/dist/index42.mjs
CHANGED