@storepecker/storefront-core 2.9.1 → 2.10.1

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.
Files changed (91) hide show
  1. package/dist/address-BdIB6IuI.d.cts +42 -0
  2. package/dist/address-BdIB6IuI.d.ts +42 -0
  3. package/dist/api/index.cjs +36 -32
  4. package/dist/api/index.d.cts +20 -17
  5. package/dist/api/index.d.ts +20 -17
  6. package/dist/api/index.js +4 -4
  7. package/dist/{buy-now-BqVWXyy8.d.cts → buy-now-CDug6LJ_.d.ts} +2 -2
  8. package/dist/{buy-now-DFdnuLjO.d.ts → buy-now-DrKY5_9R.d.cts} +2 -2
  9. package/dist/checkout/index.cjs +163 -76
  10. package/dist/checkout/index.d.cts +37 -26
  11. package/dist/checkout/index.d.ts +37 -26
  12. package/dist/checkout/index.js +50 -64
  13. package/dist/checkout-totals-CbmXM9L7.d.cts +220 -0
  14. package/dist/checkout-totals-DU8l-Wyb.d.ts +220 -0
  15. package/dist/{chunk-IG4BW3ZB.cjs → chunk-32X4SWN4.cjs} +3 -3
  16. package/dist/{chunk-NQZ5GUOG.cjs → chunk-3YPE6UPC.cjs} +24 -16
  17. package/dist/{chunk-RDUT4W3B.cjs → chunk-6APRQ2ED.cjs} +4 -1
  18. package/dist/{chunk-ICKTXS6B.js → chunk-6IXTFZFS.js} +3 -3
  19. package/dist/{chunk-7M5CVYZJ.js → chunk-A7EI7XLU.js} +8 -1
  20. package/dist/chunk-DZPK7GPG.js +601 -0
  21. package/dist/{chunk-TH7OAMGC.js → chunk-E4D4XOAE.js} +24 -16
  22. package/dist/{chunk-NRPK5GCJ.cjs → chunk-EFYAFXIS.cjs} +3 -3
  23. package/dist/{chunk-CBKJ3Y2I.js → chunk-EWZ7TGI7.js} +11 -1
  24. package/dist/{chunk-5XVHYPOC.js → chunk-FF5N7PTB.js} +1 -1
  25. package/dist/{chunk-NOT6VKXA.cjs → chunk-H6UZTS5O.cjs} +67 -23
  26. package/dist/{chunk-XFOUNOKO.cjs → chunk-KNG4OMS5.cjs} +8 -0
  27. package/dist/{chunk-ZAWZ3RB6.js → chunk-NNE42NMP.js} +1 -1
  28. package/dist/chunk-PN6KH5PX.cjs +661 -0
  29. package/dist/{chunk-QQHQTBAM.js → chunk-QSRVMOXT.js} +48 -6
  30. package/dist/{chunk-W6BDMNSU.js → chunk-QVO56X4E.js} +1 -1
  31. package/dist/{chunk-6LS5F4R3.cjs → chunk-SGJUMI3M.cjs} +11 -0
  32. package/dist/{chunk-YLLAP3H2.cjs → chunk-SGKLMS7W.cjs} +2 -2
  33. package/dist/{chunk-ZGMLOLTC.js → chunk-VRZRV2BR.js} +4 -1
  34. package/dist/{chunk-IVKJJLG7.cjs → chunk-WWJAPKRQ.cjs} +8 -8
  35. package/dist/{collections-CXgOv5_G.d.cts → collections-CKNFcE2d.d.cts} +1 -1
  36. package/dist/{collections-CNh2OGbl.d.ts → collections-CtRKsWVx.d.ts} +1 -1
  37. package/dist/components/address-form.cjs +6 -6
  38. package/dist/components/address-form.d.cts +10 -6
  39. package/dist/components/address-form.d.ts +10 -6
  40. package/dist/components/address-form.js +5 -5
  41. package/dist/components/digital-product-download-modal.d.cts +2 -2
  42. package/dist/components/digital-product-download-modal.d.ts +2 -2
  43. package/dist/components/index.cjs +8 -8
  44. package/dist/components/index.d.cts +6 -7
  45. package/dist/components/index.d.ts +6 -7
  46. package/dist/components/index.js +6 -6
  47. package/dist/components/search-dropdown.d.cts +4 -4
  48. package/dist/components/search-dropdown.d.ts +4 -4
  49. package/dist/components/share-button.cjs +3 -3
  50. package/dist/components/share-button.d.cts +1 -1
  51. package/dist/components/share-button.d.ts +1 -1
  52. package/dist/components/share-button.js +2 -2
  53. package/dist/components/theme-data-initializer.d.cts +4 -5
  54. package/dist/components/theme-data-initializer.d.ts +4 -5
  55. package/dist/hooks/index.cjs +672 -44
  56. package/dist/hooks/index.d.cts +239 -13
  57. package/dist/hooks/index.d.ts +239 -13
  58. package/dist/hooks/index.js +630 -11
  59. package/dist/{instagram-DalreBu6.d.cts → instagram-CSzrxk10.d.cts} +8 -2
  60. package/dist/{instagram-BADLnNQ3.d.ts → instagram-CagTLmyq.d.ts} +8 -2
  61. package/dist/models/index.d.cts +8 -8
  62. package/dist/models/index.d.ts +8 -8
  63. package/dist/orders-B6BmHCJN.d.ts +337 -0
  64. package/dist/orders-ZKP0lqRN.d.cts +337 -0
  65. package/dist/pincode-8u7yWLpQ.d.cts +29 -0
  66. package/dist/pincode-8u7yWLpQ.d.ts +29 -0
  67. package/dist/{pixelEvents-LsealscG.d.ts → pixelEvents-DqJ_CEEr.d.ts} +4 -4
  68. package/dist/{pixelEvents-BtEO5QAR.d.cts → pixelEvents-bahgVW4_.d.cts} +4 -4
  69. package/dist/{product-D9liEtl4.d.cts → product-D4kol-Z-.d.cts} +26 -2
  70. package/dist/{product-D9liEtl4.d.ts → product-D4kol-Z-.d.ts} +26 -2
  71. package/dist/store/index.cjs +20 -30
  72. package/dist/store/index.d.cts +21 -7
  73. package/dist/store/index.d.ts +21 -7
  74. package/dist/store/index.js +9 -26
  75. package/dist/{useAddressForm-DGbEn91-.d.cts → useAddressForm-fMOb5Z-a.d.ts} +6 -1
  76. package/dist/{useAddressForm-cO3Au33k.d.ts → useAddressForm-wleIo78M.d.cts} +6 -1
  77. package/dist/utils/index.cjs +60 -56
  78. package/dist/utils/index.d.cts +24 -9
  79. package/dist/utils/index.d.ts +24 -9
  80. package/dist/utils/index.js +4 -4
  81. package/dist/{wishlist-Cj0sQxiY.d.ts → wishlist-L3fM5-ie.d.ts} +1 -1
  82. package/dist/{wishlist-BakHvIFN.d.cts → wishlist-_0x0r1jt.d.cts} +1 -1
  83. package/package.json +1 -1
  84. package/dist/address-DwBZHzbI.d.cts +0 -19
  85. package/dist/address-DwBZHzbI.d.ts +0 -19
  86. package/dist/cart-DZq1ZEnE.d.ts +0 -153
  87. package/dist/cart-DwMFBmpC.d.cts +0 -153
  88. package/dist/chunk-34Y7Y5FU.cjs +0 -246
  89. package/dist/chunk-VPTN4YXD.js +0 -232
  90. package/dist/orders-B3G4CyhH.d.cts +0 -166
  91. package/dist/orders-Bl-Slh72.d.ts +0 -166
@@ -226,5 +226,15 @@ function getOrderStatus(order) {
226
226
  };
227
227
  }
228
228
  }
229
+ function focusFirstInvalidField(errors, root) {
230
+ if (typeof document === "undefined") return;
231
+ const invalid = Object.keys(errors);
232
+ if (invalid.length === 0) return;
233
+ const controls = (root ?? document).querySelectorAll("input[name], select[name], textarea[name]");
234
+ const target = Array.from(controls).find((el) => invalid.includes(el.getAttribute("name") ?? ""));
235
+ if (!target) return;
236
+ target.scrollIntoView({ behavior: "smooth", block: "center" });
237
+ target.focus({ preventScroll: true });
238
+ }
229
239
 
230
- export { constructFilter, convertObjectToParams, convertToCurrency, digestMessage, formatDateTime, formatPostalLabel, getAddressMeta, getDelayInMilliseconds, getOrderStatus, getParamsFromURL, getQueryParams, pluralize, pushParamsToURL, shareLink };
240
+ export { constructFilter, convertObjectToParams, convertToCurrency, digestMessage, focusFirstInvalidField, formatDateTime, formatPostalLabel, getAddressMeta, getDelayInMilliseconds, getOrderStatus, getParamsFromURL, getQueryParams, pluralize, pushParamsToURL, shareLink };
@@ -1,5 +1,5 @@
1
1
  import { ShareIcon } from './chunk-U7EXLQCT.js';
2
- import { shareLink, convertToCurrency } from './chunk-CBKJ3Y2I.js';
2
+ import { shareLink, convertToCurrency } from './chunk-EWZ7TGI7.js';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
5
5
  var ShareButton = ({
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkNRPK5GCJ_cjs = require('./chunk-NRPK5GCJ.cjs');
4
- var chunkNQZ5GUOG_cjs = require('./chunk-NQZ5GUOG.cjs');
3
+ var chunkEFYAFXIS_cjs = require('./chunk-EFYAFXIS.cjs');
4
+ var chunk3YPE6UPC_cjs = require('./chunk-3YPE6UPC.cjs');
5
5
  var chunkH6FJYRO3_cjs = require('./chunk-H6FJYRO3.cjs');
6
6
  var chunkBBRXE57K_cjs = require('./chunk-BBRXE57K.cjs');
7
7
  var chunkNE3ZHELZ_cjs = require('./chunk-NE3ZHELZ.cjs');
@@ -9,21 +9,62 @@ var zustand = require('zustand');
9
9
  var typescriptCookie = require('typescript-cookie');
10
10
 
11
11
  var initialState = {
12
+ wishlist_count: 0,
13
+ product_variants: []
14
+ };
15
+ var useWishlistStore = zustand.create((set, get) => ({
16
+ ...initialState,
17
+ loaded: false,
18
+ setWishlist: (wishlist) => set({ ...wishlist, loaded: true }),
19
+ resetWishlist: () => set({ ...initialState, loaded: false }),
20
+ syncWishlist: async () => {
21
+ try {
22
+ const response = await chunkEFYAFXIS_cjs.getWishlist("/customer/wishlist/");
23
+ if (response.data) {
24
+ set({
25
+ wishlist_count: response.data.wishlist_count,
26
+ product_variants: response.data.product_variants,
27
+ loaded: true
28
+ });
29
+ }
30
+ } catch {
31
+ }
32
+ },
33
+ removeAddedFromWishlist: async (variantIds) => {
34
+ if (!chunkBBRXE57K_cjs.auth_default.getUserDetails() || variantIds.length === 0) return true;
35
+ try {
36
+ if (!get().loaded) await get().syncWishlist();
37
+ const ids = get().product_variants.filter((item) => variantIds.includes(item.id)).map((item) => item.id);
38
+ if (ids.length === 0) return true;
39
+ const response = await chunkEFYAFXIS_cjs.removeFromWishlist(ids);
40
+ if (response.data) get().setWishlist(response.data);
41
+ return true;
42
+ } catch {
43
+ return false;
44
+ }
45
+ }
46
+ }));
47
+ function useIsWishlisted(variantId, initial) {
48
+ return useWishlistStore(
49
+ (s) => s.loaded && variantId !== void 0 ? s.product_variants.some((item) => item.id === variantId) : !!initial
50
+ );
51
+ }
52
+ var initialState2 = {
12
53
  cart: null,
13
54
  total_quantity: 0,
14
55
  status: "idle" /* IDLE */
15
56
  };
16
57
  var useCartStore = zustand.create((set) => ({
17
- ...initialState,
58
+ ...initialState2,
18
59
  setCart: (cart) => set({ cart, total_quantity: cart.total_quantity, status: "idle" /* IDLE */ }),
19
- resetCart: () => set(initialState),
60
+ resetCart: () => set(initialState2),
20
61
  resetCartCount: () => set((state) => {
21
62
  if (!state.cart) return { ...state, total_quantity: 0 };
22
63
  return { cart: { ...state.cart, total_quantity: 0 }, total_quantity: 0 };
23
64
  }),
24
65
  fetchCartItemQuantity: async () => {
25
66
  try {
26
- const { total_quantity } = await chunkNRPK5GCJ_cjs.getCartItemQuantity();
67
+ const { total_quantity } = await chunkEFYAFXIS_cjs.getCartItemQuantity();
27
68
  set({ total_quantity });
28
69
  } catch (error) {
29
70
  console.error("Failed to fetch cart item quantity", error);
@@ -32,7 +73,7 @@ var useCartStore = zustand.create((set) => ({
32
73
  syncCart: async (addressId, shippingOptionId) => {
33
74
  set({ status: "loading" /* LOADING */ });
34
75
  try {
35
- const response = await chunkNRPK5GCJ_cjs.getCart("/customer/cart/", addressId, shippingOptionId);
76
+ const response = await chunkEFYAFXIS_cjs.getCart("/customer/cart/", addressId, shippingOptionId);
36
77
  if (response) {
37
78
  set({ cart: response, total_quantity: response.total_quantity, status: "idle" /* IDLE */ });
38
79
  }
@@ -43,7 +84,7 @@ var useCartStore = zustand.create((set) => ({
43
84
  fetchCart: async (addressId, shippingOptionId) => {
44
85
  set({ status: "loading" /* LOADING */ });
45
86
  try {
46
- const response = await chunkNRPK5GCJ_cjs.getCart("/customer/cart/", addressId, shippingOptionId);
87
+ const response = await chunkEFYAFXIS_cjs.getCart("/customer/cart/", addressId, shippingOptionId);
47
88
  if (response) {
48
89
  set({ cart: response, total_quantity: response.total_quantity, status: "idle" /* IDLE */ });
49
90
  }
@@ -55,16 +96,17 @@ var useCartStore = zustand.create((set) => ({
55
96
  set({ status: "loading" /* LOADING */ });
56
97
  try {
57
98
  if (chunkBBRXE57K_cjs.auth_default.getUserDetails()) {
58
- await chunkNRPK5GCJ_cjs.addToCart(items, customizationInputs);
99
+ await chunkEFYAFXIS_cjs.addToCart(items, customizationInputs);
59
100
  await useCartStore.getState().syncCart(addressId);
101
+ await useWishlistStore.getState().removeAddedFromWishlist(items.map((item) => item.variant_id));
60
102
  } else {
61
- const cart = chunkNQZ5GUOG_cjs.cart_default.get();
103
+ const cart = chunk3YPE6UPC_cjs.cart_default.get();
62
104
  items.forEach((item) => {
63
105
  const product = products?.find((p) => p.id === item.variant_id) || cart?.product_variants?.find((p) => p.id === item.variant_id);
64
106
  if (!product) return;
65
- chunkNQZ5GUOG_cjs.cart_default.add(product, item.quantity);
107
+ chunk3YPE6UPC_cjs.cart_default.add(product, item.quantity);
66
108
  });
67
- const updatedCart = chunkNQZ5GUOG_cjs.cart_default.get();
109
+ const updatedCart = chunk3YPE6UPC_cjs.cart_default.get();
68
110
  if (updatedCart) {
69
111
  set({ cart: updatedCart, total_quantity: updatedCart.total_quantity });
70
112
  }
@@ -78,26 +120,26 @@ var useCartStore = zustand.create((set) => ({
78
120
  set({ status: "loading" /* LOADING */ });
79
121
  try {
80
122
  if (chunkBBRXE57K_cjs.auth_default.getUserDetails()) {
81
- await chunkNRPK5GCJ_cjs.removeFromCart(items);
123
+ await chunkEFYAFXIS_cjs.removeFromCart(items);
82
124
  await useCartStore.getState().syncCart(addressId);
83
125
  } else {
84
- const cart = chunkNQZ5GUOG_cjs.cart_default.get();
126
+ const cart = chunk3YPE6UPC_cjs.cart_default.get();
85
127
  if (cart) {
86
128
  items.forEach((item) => {
87
129
  const product = cart.product_variants.find(
88
130
  (p) => p.id === item.variant_id
89
131
  );
90
- if (product) chunkNQZ5GUOG_cjs.cart_default.remove(product);
132
+ if (product) chunk3YPE6UPC_cjs.cart_default.remove(product);
91
133
  });
92
134
  }
93
- const updatedCart = chunkNQZ5GUOG_cjs.cart_default.get();
135
+ const updatedCart = chunk3YPE6UPC_cjs.cart_default.get();
94
136
  if (updatedCart) {
95
137
  set({
96
138
  cart: updatedCart,
97
139
  total_quantity: updatedCart.total_quantity
98
140
  });
99
141
  } else {
100
- set(initialState);
142
+ set(initialState2);
101
143
  }
102
144
  }
103
145
  } catch {
@@ -109,19 +151,19 @@ var useCartStore = zustand.create((set) => ({
109
151
  set({ status: "loading" /* LOADING */ });
110
152
  try {
111
153
  if (chunkBBRXE57K_cjs.auth_default.getUserDetails()) {
112
- await chunkNRPK5GCJ_cjs.updateCart(items);
154
+ await chunkEFYAFXIS_cjs.updateCart(items);
113
155
  await useCartStore.getState().syncCart(addressId);
114
156
  } else {
115
- const cart = chunkNQZ5GUOG_cjs.cart_default.get();
157
+ const cart = chunk3YPE6UPC_cjs.cart_default.get();
116
158
  if (cart) {
117
159
  items.forEach((item) => {
118
160
  const product = cart.product_variants.find(
119
161
  (p) => p.id === item.variant_id
120
162
  );
121
- if (product) chunkNQZ5GUOG_cjs.cart_default.updateQuantity(product, item.quantity);
163
+ if (product) chunk3YPE6UPC_cjs.cart_default.updateQuantity(product, item.quantity);
122
164
  });
123
165
  }
124
- const updatedCart = chunkNQZ5GUOG_cjs.cart_default.get();
166
+ const updatedCart = chunk3YPE6UPC_cjs.cart_default.get();
125
167
  if (updatedCart) {
126
168
  set({
127
169
  cart: updatedCart,
@@ -169,10 +211,10 @@ var useAuthStore = zustand.create((set, get) => ({
169
211
  setTimeout(async () => {
170
212
  try {
171
213
  set({ user, status: "success" /* SUCCESS */, isAuthenticated: true });
172
- const localCartItems = chunkNQZ5GUOG_cjs.cart_default.get();
214
+ const localCartItems = chunk3YPE6UPC_cjs.cart_default.get();
173
215
  if (localCartItems) {
174
216
  await mergeLocalCart(localCartItems);
175
- chunkNQZ5GUOG_cjs.cart_default.clear();
217
+ chunk3YPE6UPC_cjs.cart_default.clear();
176
218
  await useCartStore.getState().fetchCart();
177
219
  setTimeout(() => {
178
220
  if (!preventRefreshAfterLogin) {
@@ -211,7 +253,7 @@ async function mergeLocalCart(localCart) {
211
253
  (item) => !Number.isNaN(item.variant_id) && Number.isInteger(item.quantity) && item.quantity >= 1
212
254
  );
213
255
  if (cartItems.length === 0) return;
214
- await chunkNRPK5GCJ_cjs.mergeCart(cartItems, localCart.customization_inputs);
256
+ await chunkEFYAFXIS_cjs.mergeCart(cartItems, localCart.customization_inputs);
215
257
  }
216
258
  var loginUser = async (user) => {
217
259
  const { access, refresh, ...userData } = user;
@@ -223,3 +265,5 @@ var loginUser = async (user) => {
223
265
  exports.loginUser = loginUser;
224
266
  exports.useAuthStore = useAuthStore;
225
267
  exports.useCartStore = useCartStore;
268
+ exports.useIsWishlisted = useIsWishlisted;
269
+ exports.useWishlistStore = useWishlistStore;
@@ -16,7 +16,15 @@ async function removeCoupon(couponCode) {
16
16
  return chunkECHV2JSY_cjs.http_service_default.delete("/coupon/use/");
17
17
  }
18
18
 
19
+ // src/api/pincode.ts
20
+ var getPincodeDetails = async (pincode, country) => {
21
+ return chunkECHV2JSY_cjs.http_service_default.get("utils/pincode/", {
22
+ params: country ? { pincode, country } : { pincode }
23
+ });
24
+ };
25
+
19
26
  exports.applyCoupon = applyCoupon;
20
27
  exports.getAppliedCoupon = getAppliedCoupon;
21
28
  exports.getCoupons = getCoupons;
29
+ exports.getPincodeDetails = getPincodeDetails;
22
30
  exports.removeCoupon = removeCoupon;
@@ -1,4 +1,4 @@
1
- import { cart_default } from './chunk-TH7OAMGC.js';
1
+ import { cart_default } from './chunk-E4D4XOAE.js';
2
2
  import { http_service_default } from './chunk-3SYYP3XV.js';
3
3
  import { auth_default } from './chunk-WEMNXIRS.js';
4
4