@instockng/storefront-ui 1.0.9 → 1.0.10

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.
@@ -1 +1 @@
1
- {"version":3,"file":"CartContext.d.ts","sourceRoot":"","sources":["../../src/contexts/CartContext.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,EAAkD,SAAS,EAAuB,MAAM,OAAO,CAAC;AACvG,OAAO,EAGL,aAAa,EAMb,eAAe,EACf,KAAK,IAAI,EACV,MAAM,iBAAiB,CAAC;AAKzB,UAAU,gBAAgB;IACxB,wBAAwB;IACxB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,mDAAmD;IACnD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,oBAAoB;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,gDAAgD;IAChD,kBAAkB,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;IACrD,+CAA+C;IAC/C,gBAAgB,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;IACrD,8BAA8B;IAC9B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,2BAA2B;IAC3B,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,4BAA4B;IAC5B,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,0BAA0B;IAC1B,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,2BAA2B;IAC3B,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;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,iBAAiB,EAAE,EAAE,iBAAiB,2CAoMxG;AAED;;GAEG;AACH,wBAAgB,OAAO,qBAMtB"}
package/dist/index105.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import a from "./index95.mjs";
2
+ import a from "./index93.mjs";
3
3
  const e = typeof URLSearchParams < "u" ? URLSearchParams : a;
4
4
  export {
5
5
  e as default
package/dist/index3.mjs CHANGED
@@ -1,20 +1,24 @@
1
1
  'use client';
2
- import { jsxs as L, jsx as O } from "react/jsx-runtime";
3
- import { createContext as z, useState as p, useRef as G, useEffect as l, useCallback as r, useContext as K } from "react";
2
+ import { jsxs as T, jsx as z } from "react/jsx-runtime";
3
+ import { createContext as G, useState as C, useRef as I, useEffect as m, useCallback as r, useContext as H } from "react";
4
4
  import "./index18.mjs";
5
- import { useCreateCart as T, useGetCart as Y, useAddCartItem as q, useUpdateCartItem as B, useRemoveCartItem as H, useApplyDiscount as J, useRemoveDiscount as Q, useUpdateCart as V, useCheckoutCart as W } from "./index29.mjs";
5
+ import { useGetCart as K, useCreateCart as Y, useAddCartItem as q, useUpdateCartItem as B, useRemoveCartItem as J, useApplyDiscount as Q, useRemoveDiscount as V, useUpdateCart as W, useCheckoutCart as X } from "./index29.mjs";
6
6
  import "@tanstack/react-query";
7
- import { ShoppingCart as X } from "./index8.mjs";
8
- const s = "oms_cart_id", C = z(null);
9
- function nt({ children: a, brandSlug: I, initialCartId: u, shoppingCartProps: y }) {
10
- const [t, i] = p(() => {
7
+ import { ShoppingCart as Z } from "./index8.mjs";
8
+ const c = "oms_cart_id", y = G(null);
9
+ function at({ children: a, brandSlug: h, initialCartId: u, shoppingCartProps: v }) {
10
+ const [t, i] = C(() => {
11
11
  if (u) return u;
12
12
  if (typeof window < "u") {
13
13
  const n = new URLSearchParams(window.location.search).get("cartId");
14
- return n || localStorage.getItem(s);
14
+ return n || localStorage.getItem(c);
15
15
  }
16
16
  return null;
17
- }), [m, f] = p(!1), d = G(!1), h = T({
17
+ }), [f, d] = C(!1), { data: S, isLoading: D, error: s, refetch: o } = K(t || "", {
18
+ enabled: !!t,
19
+ retry: !1
20
+ // Don't retry on failure - cart might be invalid/expired
21
+ }), w = I(!1), l = I(!1), g = Y({
18
22
  onSuccess: (e) => {
19
23
  if ("error" in e) {
20
24
  console.error("Failed to create cart:", e.error);
@@ -25,107 +29,107 @@ function nt({ children: a, brandSlug: I, initialCartId: u, shoppingCartProps: y
25
29
  onError: (e) => {
26
30
  console.error("Failed to create cart:", e);
27
31
  }
28
- }), { data: S, isLoading: v, error: c, refetch: o } = Y(t || "", {
29
- enabled: !!t,
30
- retry: !1
31
- // Don't retry on failure - cart might be invalid/expired
32
32
  });
33
- l(() => {
34
- !d.current && !t && !u && (d.current = !0, h.mutate(I));
35
- }, []), l(() => {
36
- c && t && (console.warn("Cart fetch failed, clearing invalid cart:", c), i(null), typeof window < "u" && localStorage.removeItem(s));
37
- }, [c, t]);
38
- const D = q(t || "", {
33
+ m(() => {
34
+ !w.current && !t && !u && (w.current = !0, setTimeout(() => {
35
+ g.mutate(h);
36
+ }, 0));
37
+ }, []), m(() => {
38
+ s && t && !l.current && (l.current = !0, console.warn("Cart fetch failed, clearing invalid cart:", s), Promise.resolve().then(() => {
39
+ i(null), typeof window < "u" && localStorage.removeItem(c), l.current = !1;
40
+ }));
41
+ }, [s, t]);
42
+ const E = q(t || "", {
39
43
  onSuccess: () => o()
40
- }), g = B(t || "", {
44
+ }), A = B(t || "", {
41
45
  onSuccess: () => o()
42
- }), E = H(t || "", {
46
+ }), M = J(t || "", {
43
47
  onSuccess: () => o()
44
- }), A = J(t || "", {
48
+ }), x = Q(t || "", {
45
49
  onSuccess: () => o()
46
- }), M = Q(t || "", {
50
+ }), P = V(t || "", {
47
51
  onSuccess: () => o()
48
- }), x = V(t || "", {
52
+ }), R = W(t || "", {
49
53
  onSuccess: () => o()
50
- }), P = W(t || "");
51
- l(() => {
52
- t && typeof window < "u" && localStorage.setItem(s, t);
54
+ }), N = X(t || "");
55
+ m(() => {
56
+ t && typeof window < "u" && localStorage.setItem(c, t);
53
57
  }, [t]);
54
- const R = r(
58
+ const U = r(
55
59
  async (e, n) => {
56
60
  if (!t) throw new Error("No cart ID");
57
- await D.mutateAsync({ sku: e, quantity: n });
61
+ await E.mutateAsync({ sku: e, quantity: n });
58
62
  },
59
63
  // eslint-disable-next-line react-hooks/exhaustive-deps
60
64
  [t]
61
- ), N = r(
65
+ ), _ = r(
62
66
  async (e, n) => {
63
67
  if (!t) throw new Error("No cart ID");
64
- await g.mutateAsync({ itemId: e, quantity: n });
68
+ await A.mutateAsync({ itemId: e, quantity: n });
65
69
  },
66
70
  // eslint-disable-next-line react-hooks/exhaustive-deps
67
71
  [t]
68
- ), U = r(
72
+ ), b = r(
69
73
  async (e) => {
70
74
  if (!t) throw new Error("No cart ID");
71
- await E.mutateAsync(e);
75
+ await M.mutateAsync(e);
72
76
  },
73
77
  // eslint-disable-next-line react-hooks/exhaustive-deps
74
78
  [t]
75
- ), _ = r(
79
+ ), k = r(
76
80
  async (e) => {
77
81
  if (!t) throw new Error("No cart ID");
78
- await A.mutateAsync({ code: e });
82
+ await x.mutateAsync({ code: e });
79
83
  },
80
84
  // eslint-disable-next-line react-hooks/exhaustive-deps
81
85
  [t]
82
- ), b = r(async () => {
86
+ ), F = r(async () => {
83
87
  if (!t) throw new Error("No cart ID");
84
- await M.mutateAsync();
85
- }, [t]), k = r(() => {
86
- i(null), typeof window < "u" && localStorage.removeItem(s);
87
- }, []), F = r(() => {
88
- f(!0);
89
- }, []), w = r(() => {
90
- f(!1);
91
- }, []), j = {
88
+ await P.mutateAsync();
89
+ }, [t]), j = r(() => {
90
+ i(null), typeof window < "u" && localStorage.removeItem(c);
91
+ }, []), L = r(() => {
92
+ d(!0);
93
+ }, []), p = r(() => {
94
+ d(!1);
95
+ }, []), O = {
92
96
  cart: S || null,
93
97
  cartId: t,
94
- isLoading: v,
95
- error: c,
96
- updateCartMutation: x,
97
- checkoutMutation: P,
98
- addItem: R,
99
- updateItem: N,
100
- removeItem: U,
101
- applyDiscount: _,
102
- removeDiscount: b,
103
- clearCart: k,
98
+ isLoading: D,
99
+ error: s,
100
+ updateCartMutation: R,
101
+ checkoutMutation: N,
102
+ addItem: U,
103
+ updateItem: _,
104
+ removeItem: b,
105
+ applyDiscount: k,
106
+ removeDiscount: F,
107
+ clearCart: j,
104
108
  refetch: o,
105
- isOpen: m,
106
- open: F,
107
- close: w
109
+ isOpen: f,
110
+ open: L,
111
+ close: p
108
112
  };
109
- return /* @__PURE__ */ L(C.Provider, { value: j, children: [
113
+ return /* @__PURE__ */ T(y.Provider, { value: O, children: [
110
114
  a,
111
- /* @__PURE__ */ O(
112
- X,
115
+ /* @__PURE__ */ z(
116
+ Z,
113
117
  {
114
- isOpen: m,
115
- onClose: w,
116
- ...y
118
+ isOpen: f,
119
+ onClose: p,
120
+ ...v
117
121
  }
118
122
  )
119
123
  ] });
120
124
  }
121
- function at() {
122
- const a = K(C);
125
+ function st() {
126
+ const a = H(y);
123
127
  if (!a)
124
128
  throw new Error("useCart must be used within CartProvider");
125
129
  return a;
126
130
  }
127
131
  export {
128
- C as CartContext,
129
- nt as CartProvider,
130
- at as useCart
132
+ y as CartContext,
133
+ at as CartProvider,
134
+ st as useCart
131
135
  };
package/dist/index81.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import f from "./index62.mjs";
3
- import d from "./index95.mjs";
3
+ import d from "./index93.mjs";
4
4
  function l(e) {
5
5
  return encodeURIComponent(e).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+");
6
6
  }
package/dist/index83.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import r from "./index96.mjs";
2
+ import r from "./index94.mjs";
3
3
  import p from "./index70.mjs";
4
4
  import l from "./index66.mjs";
5
5
  import m from "./index68.mjs";
package/dist/index84.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
- import r from "./index97.mjs";
3
- import f from "./index98.mjs";
2
+ import r from "./index95.mjs";
3
+ import f from "./index96.mjs";
4
4
  function u(l, i, t) {
5
5
  let o = !r(i);
6
6
  return l && (o || t == !1) ? f(l, i) : i;
package/dist/index88.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
- import o from "./index93.mjs";
3
- import * as t from "./index94.mjs";
2
+ import o from "./index97.mjs";
3
+ import * as t from "./index98.mjs";
4
4
  const m = {
5
5
  ...t,
6
6
  ...o
package/dist/index93.mjs CHANGED
@@ -1,16 +1,34 @@
1
1
  'use client';
2
- import o from "./index105.mjs";
3
- import r from "./index106.mjs";
4
- import t from "./index107.mjs";
5
- const l = {
6
- isBrowser: !0,
7
- classes: {
8
- URLSearchParams: o,
9
- FormData: r,
10
- Blob: t
11
- },
12
- protocols: ["http", "https", "file", "blob", "url", "data"]
2
+ import p from "./index72.mjs";
3
+ function i(n) {
4
+ const t = {
5
+ "!": "%21",
6
+ "'": "%27",
7
+ "(": "%28",
8
+ ")": "%29",
9
+ "~": "%7E",
10
+ "%20": "+",
11
+ "%00": "\0"
12
+ };
13
+ return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g, function(r) {
14
+ return t[r];
15
+ });
16
+ }
17
+ function a(n, t) {
18
+ this._pairs = [], n && p(n, this, t);
19
+ }
20
+ const c = a.prototype;
21
+ c.append = function(t, o) {
22
+ this._pairs.push([t, o]);
23
+ };
24
+ c.toString = function(t) {
25
+ const o = t ? function(r) {
26
+ return t.call(this, r, i);
27
+ } : i;
28
+ return this._pairs.map(function(e) {
29
+ return o(e[0]) + "=" + o(e[1]);
30
+ }, "").join("&");
13
31
  };
14
32
  export {
15
- l as default
33
+ a as default
16
34
  };
package/dist/index94.mjs CHANGED
@@ -1,10 +1,14 @@
1
1
  'use client';
2
- const e = typeof window < "u" && typeof document < "u", o = typeof navigator == "object" && navigator || void 0, n = e && (!o || ["ReactNative", "NativeScript", "NS"].indexOf(o.product) < 0), t = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
3
- self instanceof WorkerGlobalScope && typeof self.importScripts == "function", r = e && window.location.href || "http://localhost";
2
+ import i from "./index62.mjs";
3
+ import m from "./index66.mjs";
4
+ import s from "./index76.mjs";
5
+ function h(f, t) {
6
+ const o = this || m, r = t || o, n = s.from(r.headers);
7
+ let a = r.data;
8
+ return i.forEach(f, function(e) {
9
+ a = e.call(o, a, n.normalize(), t ? t.status : void 0);
10
+ }), n.normalize(), a;
11
+ }
4
12
  export {
5
- e as hasBrowserEnv,
6
- n as hasStandardBrowserEnv,
7
- t as hasStandardBrowserWebWorkerEnv,
8
- o as navigator,
9
- r as origin
13
+ h as default
10
14
  };
package/dist/index95.mjs CHANGED
@@ -1,34 +1,7 @@
1
1
  'use client';
2
- import p from "./index72.mjs";
3
- function i(n) {
4
- const t = {
5
- "!": "%21",
6
- "'": "%27",
7
- "(": "%28",
8
- ")": "%29",
9
- "~": "%7E",
10
- "%20": "+",
11
- "%00": "\0"
12
- };
13
- return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g, function(r) {
14
- return t[r];
15
- });
2
+ function e(t) {
3
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);
16
4
  }
17
- function a(n, t) {
18
- this._pairs = [], n && p(n, this, t);
19
- }
20
- const c = a.prototype;
21
- c.append = function(t, o) {
22
- this._pairs.push([t, o]);
23
- };
24
- c.toString = function(t) {
25
- const o = t ? function(r) {
26
- return t.call(this, r, i);
27
- } : i;
28
- return this._pairs.map(function(e) {
29
- return o(e[0]) + "=" + o(e[1]);
30
- }, "").join("&");
31
- };
32
5
  export {
33
- a as default
6
+ e as default
34
7
  };
package/dist/index96.mjs CHANGED
@@ -1,14 +1,7 @@
1
1
  'use client';
2
- import i from "./index62.mjs";
3
- import m from "./index66.mjs";
4
- import s from "./index76.mjs";
5
- function h(f, t) {
6
- const o = this || m, r = t || o, n = s.from(r.headers);
7
- let a = r.data;
8
- return i.forEach(f, function(e) {
9
- a = e.call(o, a, n.normalize(), t ? t.status : void 0);
10
- }), n.normalize(), a;
2
+ function n(e, c) {
3
+ return c ? e.replace(/\/?\/$/, "") + "/" + c.replace(/^\/+/, "") : e;
11
4
  }
12
5
  export {
13
- h as default
6
+ n as default
14
7
  };
package/dist/index97.mjs CHANGED
@@ -1,7 +1,16 @@
1
1
  'use client';
2
- function e(t) {
3
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);
4
- }
2
+ import o from "./index105.mjs";
3
+ import r from "./index106.mjs";
4
+ import t from "./index107.mjs";
5
+ const l = {
6
+ isBrowser: !0,
7
+ classes: {
8
+ URLSearchParams: o,
9
+ FormData: r,
10
+ Blob: t
11
+ },
12
+ protocols: ["http", "https", "file", "blob", "url", "data"]
13
+ };
5
14
  export {
6
- e as default
15
+ l as default
7
16
  };
package/dist/index98.mjs CHANGED
@@ -1,7 +1,10 @@
1
1
  'use client';
2
- function n(e, c) {
3
- return c ? e.replace(/\/?\/$/, "") + "/" + c.replace(/^\/+/, "") : e;
4
- }
2
+ const e = typeof window < "u" && typeof document < "u", o = typeof navigator == "object" && navigator || void 0, n = e && (!o || ["ReactNative", "NativeScript", "NS"].indexOf(o.product) < 0), t = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
3
+ self instanceof WorkerGlobalScope && typeof self.importScripts == "function", r = e && window.location.href || "http://localhost";
5
4
  export {
6
- n as default
5
+ e as hasBrowserEnv,
6
+ n as hasStandardBrowserEnv,
7
+ t as hasStandardBrowserWebWorkerEnv,
8
+ o as navigator,
9
+ r as origin
7
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instockng/storefront-ui",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Pre-built UI components for OMS e-commerce sites",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",