@instockng/storefront-ui 1.0.7 → 1.0.9

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,EAAe,MAAM,OAAO,CAAC;AAC/F,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,2CA0LxG;AAED;;GAEG;AACH,wBAAgB,OAAO,qBAMtB"}
package/dist/index105.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import a from "./index93.mjs";
2
+ import a from "./index95.mjs";
3
3
  const e = typeof URLSearchParams < "u" ? URLSearchParams : a;
4
4
  export {
5
5
  e as default
package/dist/index3.mjs CHANGED
@@ -1,133 +1,131 @@
1
1
  'use client';
2
- import { jsxs as F, jsx as G } from "react/jsx-runtime";
3
- import { createContext as K, useState as l, useEffect as d, useCallback as o, useContext as T } from "react";
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";
4
4
  import "./index18.mjs";
5
- import { useCreateCart as Y, useGetCart as q, useAddCartItem as z, useUpdateCartItem as B, useRemoveCartItem as H, useApplyDiscount as J, useRemoveDiscount as Q, useUpdateCart as V, useCheckoutCart as W } from "./index29.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";
6
6
  import "@tanstack/react-query";
7
7
  import { ShoppingCart as X } from "./index8.mjs";
8
- const i = "oms_cart_id", y = K(null);
9
- function nt({ children: a, brandSlug: w, initialCartId: s, shoppingCartProps: h }) {
10
- const [t, m] = l(() => {
11
- if (s) return s;
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(() => {
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(i);
14
+ return n || localStorage.getItem(s);
15
15
  }
16
16
  return null;
17
- }), [p, C] = l(!1), [f, c] = l(!1), S = Y({
17
+ }), [m, f] = p(!1), d = G(!1), h = T({
18
18
  onSuccess: (e) => {
19
19
  if ("error" in e) {
20
- c(!1);
20
+ console.error("Failed to create cart:", e.error);
21
21
  return;
22
22
  }
23
- m(e.id), c(!1);
23
+ i(e.id);
24
24
  },
25
- onError: () => {
26
- c(!1);
25
+ onError: (e) => {
26
+ console.error("Failed to create cart:", e);
27
27
  }
28
- });
29
- d(() => {
30
- !t && !s && !f && (c(!0), S.mutate(w));
31
- }, [t, s, w]);
32
- const { data: v, isLoading: D, error: u, refetch: r } = q(t || "", {
28
+ }), { data: S, isLoading: v, error: c, refetch: o } = Y(t || "", {
33
29
  enabled: !!t,
34
30
  retry: !1
35
31
  // Don't retry on failure - cart might be invalid/expired
36
32
  });
37
- d(() => {
38
- u && t && !f && (console.warn("Cart fetch failed, will create new cart:", u), m(null), typeof window < "u" && localStorage.removeItem(i));
39
- }, [u, t, f]);
40
- const g = z(t || "", {
41
- onSuccess: () => r()
42
- }), E = B(t || "", {
43
- onSuccess: () => r()
44
- }), A = H(t || "", {
45
- onSuccess: () => r()
46
- }), M = J(t || "", {
47
- onSuccess: () => r()
48
- }), x = Q(t || "", {
49
- onSuccess: () => r()
50
- }), P = V(t || "", {
51
- onSuccess: () => r()
52
- }), N = W(t || "");
53
- d(() => {
54
- t && typeof window < "u" && localStorage.setItem(i, t);
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 || "", {
39
+ onSuccess: () => o()
40
+ }), g = B(t || "", {
41
+ onSuccess: () => o()
42
+ }), E = H(t || "", {
43
+ onSuccess: () => o()
44
+ }), A = J(t || "", {
45
+ onSuccess: () => o()
46
+ }), M = Q(t || "", {
47
+ onSuccess: () => o()
48
+ }), x = V(t || "", {
49
+ onSuccess: () => o()
50
+ }), P = W(t || "");
51
+ l(() => {
52
+ t && typeof window < "u" && localStorage.setItem(s, t);
55
53
  }, [t]);
56
- const R = o(
54
+ const R = r(
57
55
  async (e, n) => {
58
56
  if (!t) throw new Error("No cart ID");
59
- await g.mutateAsync({ sku: e, quantity: n });
57
+ await D.mutateAsync({ sku: e, quantity: n });
60
58
  },
61
59
  // eslint-disable-next-line react-hooks/exhaustive-deps
62
60
  [t]
63
- ), U = o(
61
+ ), N = r(
64
62
  async (e, n) => {
65
63
  if (!t) throw new Error("No cart ID");
66
- await E.mutateAsync({ itemId: e, quantity: n });
64
+ await g.mutateAsync({ itemId: e, quantity: n });
67
65
  },
68
66
  // eslint-disable-next-line react-hooks/exhaustive-deps
69
67
  [t]
70
- ), _ = o(
68
+ ), U = r(
71
69
  async (e) => {
72
70
  if (!t) throw new Error("No cart ID");
73
- await A.mutateAsync(e);
71
+ await E.mutateAsync(e);
74
72
  },
75
73
  // eslint-disable-next-line react-hooks/exhaustive-deps
76
74
  [t]
77
- ), k = o(
75
+ ), _ = r(
78
76
  async (e) => {
79
77
  if (!t) throw new Error("No cart ID");
80
- await M.mutateAsync({ code: e });
78
+ await A.mutateAsync({ code: e });
81
79
  },
82
80
  // eslint-disable-next-line react-hooks/exhaustive-deps
83
81
  [t]
84
- ), b = o(async () => {
82
+ ), b = r(async () => {
85
83
  if (!t) throw new Error("No cart ID");
86
- await x.mutateAsync();
87
- }, [t]), j = o(() => {
88
- m(null), typeof window < "u" && localStorage.removeItem(i);
89
- }, []), L = o(() => {
90
- C(!0);
91
- }, []), I = o(() => {
92
- C(!1);
93
- }, []), O = {
94
- cart: v || null,
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 = {
92
+ cart: S || null,
95
93
  cartId: t,
96
- isLoading: D,
97
- error: u,
98
- updateCartMutation: P,
99
- checkoutMutation: N,
94
+ isLoading: v,
95
+ error: c,
96
+ updateCartMutation: x,
97
+ checkoutMutation: P,
100
98
  addItem: R,
101
- updateItem: U,
102
- removeItem: _,
103
- applyDiscount: k,
99
+ updateItem: N,
100
+ removeItem: U,
101
+ applyDiscount: _,
104
102
  removeDiscount: b,
105
- clearCart: j,
106
- refetch: r,
107
- isOpen: p,
108
- open: L,
109
- close: I
103
+ clearCart: k,
104
+ refetch: o,
105
+ isOpen: m,
106
+ open: F,
107
+ close: w
110
108
  };
111
- return /* @__PURE__ */ F(y.Provider, { value: O, children: [
109
+ return /* @__PURE__ */ L(C.Provider, { value: j, children: [
112
110
  a,
113
- /* @__PURE__ */ G(
111
+ /* @__PURE__ */ O(
114
112
  X,
115
113
  {
116
- isOpen: p,
117
- onClose: I,
118
- ...h
114
+ isOpen: m,
115
+ onClose: w,
116
+ ...y
119
117
  }
120
118
  )
121
119
  ] });
122
120
  }
123
121
  function at() {
124
- const a = T(y);
122
+ const a = K(C);
125
123
  if (!a)
126
124
  throw new Error("useCart must be used within CartProvider");
127
125
  return a;
128
126
  }
129
127
  export {
130
- y as CartContext,
128
+ C as CartContext,
131
129
  nt as CartProvider,
132
130
  at as useCart
133
131
  };
package/dist/index81.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import f from "./index62.mjs";
3
- import d from "./index93.mjs";
3
+ import d from "./index95.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 "./index94.mjs";
2
+ import r from "./index96.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 "./index95.mjs";
3
- import f from "./index96.mjs";
2
+ import r from "./index97.mjs";
3
+ import f from "./index98.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 "./index97.mjs";
3
- import * as t from "./index98.mjs";
2
+ import o from "./index93.mjs";
3
+ import * as t from "./index94.mjs";
4
4
  const m = {
5
5
  ...t,
6
6
  ...o
package/dist/index93.mjs CHANGED
@@ -1,34 +1,16 @@
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
- });
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("&");
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"]
31
13
  };
32
14
  export {
33
- a as default
15
+ l as default
34
16
  };
package/dist/index94.mjs CHANGED
@@ -1,14 +1,10 @@
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;
11
- }
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";
12
4
  export {
13
- h as default
5
+ e as hasBrowserEnv,
6
+ n as hasStandardBrowserEnv,
7
+ t as hasStandardBrowserWebWorkerEnv,
8
+ o as navigator,
9
+ r as origin
14
10
  };
package/dist/index95.mjs CHANGED
@@ -1,7 +1,34 @@
1
1
  'use client';
2
- function e(t) {
3
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);
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
+ });
4
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("&");
31
+ };
5
32
  export {
6
- e as default
33
+ a as default
7
34
  };
package/dist/index96.mjs CHANGED
@@ -1,7 +1,14 @@
1
1
  'use client';
2
- function n(e, c) {
3
- return c ? e.replace(/\/?\/$/, "") + "/" + c.replace(/^\/+/, "") : e;
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;
4
11
  }
5
12
  export {
6
- n as default
13
+ h as default
7
14
  };
package/dist/index97.mjs CHANGED
@@ -1,16 +1,7 @@
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"]
13
- };
2
+ function e(t) {
3
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);
4
+ }
14
5
  export {
15
- l as default
6
+ e as default
16
7
  };
package/dist/index98.mjs CHANGED
@@ -1,10 +1,7 @@
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
+ function n(e, c) {
3
+ return c ? e.replace(/\/?\/$/, "") + "/" + c.replace(/^\/+/, "") : e;
4
+ }
4
5
  export {
5
- e as hasBrowserEnv,
6
- n as hasStandardBrowserEnv,
7
- t as hasStandardBrowserWebWorkerEnv,
8
- o as navigator,
9
- r as origin
6
+ n as default
10
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instockng/storefront-ui",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
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",