@storepecker/storefront-core 1.2.0 → 2.1.0

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 (74) hide show
  1. package/dist/api/index.cjs +76 -75
  2. package/dist/api/index.d.cts +5 -3
  3. package/dist/api/index.d.ts +5 -3
  4. package/dist/api/index.js +9 -8
  5. package/dist/{booking-CegE1cje.d.ts → booking-BgZoXUBv.d.cts} +2 -41
  6. package/dist/{booking-B21s0inO.d.cts → booking-CZ59BXk3.d.ts} +2 -41
  7. package/dist/cart-BY8D8w-s.d.cts +90 -0
  8. package/dist/cart-GuhgeBBt.d.ts +90 -0
  9. package/dist/checkout/index.cjs +38 -37
  10. package/dist/checkout/index.d.cts +2 -1
  11. package/dist/checkout/index.d.ts +2 -1
  12. package/dist/checkout/index.js +6 -5
  13. package/dist/{chunk-34KV265H.cjs → chunk-26A3EBZI.cjs} +20 -20
  14. package/dist/chunk-2AHH3XBW.cjs +47 -0
  15. package/dist/{chunk-K5B62JZO.cjs → chunk-47XTPPII.cjs} +4 -4
  16. package/dist/chunk-4C4NTH6O.js +41 -0
  17. package/dist/{chunk-UM24VDYB.js → chunk-7R2V4C7Q.js} +2 -2
  18. package/dist/{chunk-CSISWBZZ.js → chunk-B7FOXIZN.js} +1 -1
  19. package/dist/chunk-BBRB475I.cjs +43 -0
  20. package/dist/chunk-BBRXE57K.cjs +50 -0
  21. package/dist/{chunk-QCQCFYYR.js → chunk-BHOXJGIE.js} +1 -1
  22. package/dist/chunk-BQ256JKN.js +39 -0
  23. package/dist/{chunk-7UH6REGV.js → chunk-C7ZJZEEN.js} +1 -1
  24. package/dist/{chunk-A6IO3HIN.cjs → chunk-FMHR5ABF.cjs} +28 -28
  25. package/dist/{chunk-JHGXIIBZ.cjs → chunk-G3R7ZVAG.cjs} +7 -7
  26. package/dist/{chunk-4MJMNIAB.js → chunk-GHABOHLA.js} +1 -1
  27. package/dist/chunk-GTV42PDK.cjs +46 -0
  28. package/dist/chunk-HEFA67WK.js +42 -0
  29. package/dist/chunk-HSF2D56O.js +40 -0
  30. package/dist/{chunk-GB3HW6DM.js → chunk-JWKDXFS4.js} +1 -1
  31. package/dist/{chunk-KWKHHRRJ.cjs → chunk-KKQKHG26.cjs} +3 -3
  32. package/dist/{chunk-QM73PI5L.cjs → chunk-N3ZCCKXV.cjs} +10 -10
  33. package/dist/{chunk-GQTO5ZE2.cjs → chunk-NE3ZHELZ.cjs} +0 -46
  34. package/dist/chunk-PWYWNRVO.cjs +150 -0
  35. package/dist/{chunk-E7WPE3PV.js → chunk-QAC72HKO.js} +1 -1
  36. package/dist/{chunk-CFF632IQ.cjs → chunk-SMHJRNCR.cjs} +4 -4
  37. package/dist/chunk-UOFTDL4D.js +146 -0
  38. package/dist/chunk-WEMNXIRS.js +47 -0
  39. package/dist/{chunk-LC5ZAUKL.cjs → chunk-XLQAALMU.cjs} +10 -10
  40. package/dist/{chunk-Z7LHRD3V.js → chunk-Y6NFUWTH.js} +3 -3
  41. package/dist/{chunk-LBGIUNM6.js → chunk-YY77CUWX.js} +1 -1
  42. package/dist/{chunk-UXLUE3HW.cjs → chunk-ZO2HREQL.cjs} +2 -2
  43. package/dist/collections-CenI9AlQ.d.cts +40 -0
  44. package/dist/collections-CenI9AlQ.d.ts +40 -0
  45. package/dist/components/index.cjs +126 -7
  46. package/dist/components/index.d.cts +35 -8
  47. package/dist/components/index.d.ts +35 -8
  48. package/dist/components/index.js +122 -7
  49. package/dist/hooks/index.cjs +368 -27
  50. package/dist/hooks/index.d.cts +83 -3
  51. package/dist/hooks/index.d.ts +83 -3
  52. package/dist/hooks/index.js +352 -14
  53. package/dist/middleware/index.cjs +47 -0
  54. package/dist/middleware/index.d.cts +8 -0
  55. package/dist/middleware/index.d.ts +8 -0
  56. package/dist/middleware/index.js +44 -0
  57. package/dist/models/index.d.cts +5 -3
  58. package/dist/models/index.d.ts +5 -3
  59. package/dist/{cart-VaCKkJ1C.d.cts → product-Dfi0ke-4.d.cts} +1 -88
  60. package/dist/{cart-VaCKkJ1C.d.ts → product-Dfi0ke-4.d.ts} +1 -88
  61. package/dist/store/index.cjs +17 -85
  62. package/dist/store/index.d.cts +22 -2
  63. package/dist/store/index.d.ts +22 -2
  64. package/dist/store/index.js +7 -82
  65. package/dist/utils/index.cjs +80 -65
  66. package/dist/utils/index.d.cts +72 -7
  67. package/dist/utils/index.d.ts +72 -7
  68. package/dist/utils/index.js +20 -43
  69. package/dist/{wishlist-FG8tgn76.d.ts → wishlist-DHOvXmJj.d.cts} +1 -1
  70. package/dist/{wishlist-CkAhLpbI.d.cts → wishlist-LfdFxddw.d.ts} +1 -1
  71. package/package.json +24 -5
  72. package/dist/chunk-7DQIKSGY.js +0 -40
  73. package/dist/chunk-FLBJKM6G.js +0 -83
  74. package/dist/chunk-S3WIGYDS.cjs +0 -42
@@ -1,9 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkCFF632IQ_cjs = require('../chunk-CFF632IQ.cjs');
3
+ var chunkGTV42PDK_cjs = require('../chunk-GTV42PDK.cjs');
4
+ var chunk2AHH3XBW_cjs = require('../chunk-2AHH3XBW.cjs');
5
+ var chunkSMHJRNCR_cjs = require('../chunk-SMHJRNCR.cjs');
4
6
  var chunkK44JZ5NL_cjs = require('../chunk-K44JZ5NL.cjs');
7
+ var chunkBBRB475I_cjs = require('../chunk-BBRB475I.cjs');
5
8
  var chunk4CVKE6CC_cjs = require('../chunk-4CVKE6CC.cjs');
6
- var chunkGQTO5ZE2_cjs = require('../chunk-GQTO5ZE2.cjs');
9
+ var chunkBBRXE57K_cjs = require('../chunk-BBRXE57K.cjs');
10
+ var chunkNE3ZHELZ_cjs = require('../chunk-NE3ZHELZ.cjs');
7
11
  var chunkN3CTXRFT_cjs = require('../chunk-N3CTXRFT.cjs');
8
12
  var axios = require('axios');
9
13
  var typescriptCookie = require('typescript-cookie');
@@ -167,46 +171,6 @@ var PhonepePayment = class {
167
171
  }
168
172
  };
169
173
  var phonepe_default = PhonepePayment;
170
-
171
- // src/utils/routes.ts
172
- var protectedRoutes = [
173
- "/my/profile",
174
- "/my/orders",
175
- "/my/delete-account",
176
- "/my/addresses",
177
- "/my/dashboard"
178
- ];
179
- var authRoutes = ["/login", "/signup"];
180
- var publicRoutes = ["/about", "/"];
181
- var urls = {
182
- dashboard: "/my/dashboard",
183
- profile: "/my/profile",
184
- orders: "/my/orders",
185
- orderDetail: "/my/orders/:id",
186
- deleteAccount: "/my/delete-account",
187
- addresses: "/my/addresses",
188
- bookings: "/my/bookings",
189
- login: "/login",
190
- signup: "/signup",
191
- about: "/about",
192
- home: "/",
193
- searchProducts: "/search-products",
194
- shop: "/shop",
195
- shopDetails: "/shop/:id",
196
- cart: "/checkout/cart",
197
- address: "/checkout/address",
198
- payment: "/checkout/payment",
199
- wishlist: "/wishlist",
200
- privacyPolicy: "/privacy-policy",
201
- faq: "/faq",
202
- contactUs: "/contact-us",
203
- services: "/services",
204
- storeReview: "/store-review",
205
- returnAndRefund: "/return-and-refund",
206
- shippingPolicy: "/shipping-policy",
207
- termsOfService: "/terms-of-service"
208
- };
209
- var routes_default = urls;
210
174
  var getUniqueId = () => {
211
175
  const uniqueId = typescriptCookie.Cookies.get("__spa_id");
212
176
  if (!uniqueId) {
@@ -343,14 +307,67 @@ var formatBookingDateTime = (date, time) => {
343
307
  return bookingDate.toISOString();
344
308
  };
345
309
 
310
+ // src/utils/cart-helpers.ts
311
+ function calculateDiscountPercent(actualPrice, sellingPrice) {
312
+ const actual = Number(actualPrice);
313
+ const selling = Number(sellingPrice);
314
+ if (!actual || actual <= 0) return 0;
315
+ return Math.round((actual - selling) / actual * 100);
316
+ }
317
+ function isProductCustomized(customizationInputs, productId) {
318
+ return customizationInputs?.some(
319
+ (input) => input.product_variant === productId
320
+ ) ?? false;
321
+ }
322
+
323
+ Object.defineProperty(exports, "authRoutes", {
324
+ enumerable: true,
325
+ get: function () { return chunkGTV42PDK_cjs.authRoutes; }
326
+ });
327
+ Object.defineProperty(exports, "protectedRoutes", {
328
+ enumerable: true,
329
+ get: function () { return chunkGTV42PDK_cjs.protectedRoutes; }
330
+ });
331
+ Object.defineProperty(exports, "publicRoutes", {
332
+ enumerable: true,
333
+ get: function () { return chunkGTV42PDK_cjs.publicRoutes; }
334
+ });
335
+ Object.defineProperty(exports, "urls", {
336
+ enumerable: true,
337
+ get: function () { return chunkGTV42PDK_cjs.routes_default; }
338
+ });
339
+ Object.defineProperty(exports, "findMatchingVariant", {
340
+ enumerable: true,
341
+ get: function () { return chunk2AHH3XBW_cjs.findMatchingVariant; }
342
+ });
343
+ Object.defineProperty(exports, "findSimilarVariant", {
344
+ enumerable: true,
345
+ get: function () { return chunk2AHH3XBW_cjs.findSimilarVariant; }
346
+ });
347
+ Object.defineProperty(exports, "isColorVariantType", {
348
+ enumerable: true,
349
+ get: function () { return chunk2AHH3XBW_cjs.isColorVariantType; }
350
+ });
351
+ Object.defineProperty(exports, "isVariantCombinationAvailable", {
352
+ enumerable: true,
353
+ get: function () { return chunk2AHH3XBW_cjs.isVariantCombinationAvailable; }
354
+ });
346
355
  Object.defineProperty(exports, "LocalCart", {
347
356
  enumerable: true,
348
- get: function () { return chunkCFF632IQ_cjs.cart_default; }
357
+ get: function () { return chunkSMHJRNCR_cjs.cart_default; }
349
358
  });
350
359
  Object.defineProperty(exports, "pixelEvents", {
351
360
  enumerable: true,
352
361
  get: function () { return chunkK44JZ5NL_cjs.pixelEvents; }
353
362
  });
363
+ Object.defineProperty(exports, "isExpired", {
364
+ enumerable: true,
365
+ get: function () { return chunkBBRB475I_cjs.isExpired; }
366
+ });
367
+ Object.defineProperty(exports, "timeFromNow", {
368
+ enumerable: true,
369
+ get: function () { return chunkBBRB475I_cjs.timeFromNow; }
370
+ });
354
371
  Object.defineProperty(exports, "CacheManager", {
355
372
  enumerable: true,
356
373
  get: function () { return chunk4CVKE6CC_cjs.CacheManager; }
@@ -439,53 +456,53 @@ Object.defineProperty(exports, "shareLink", {
439
456
  enumerable: true,
440
457
  get: function () { return chunk4CVKE6CC_cjs.shareLink; }
441
458
  });
442
- Object.defineProperty(exports, "ADDRESS_FORM_SESSION_KEY", {
459
+ Object.defineProperty(exports, "Auth", {
443
460
  enumerable: true,
444
- get: function () { return chunkGQTO5ZE2_cjs.ADDRESS_FORM_SESSION_KEY; }
461
+ get: function () { return chunkBBRXE57K_cjs.auth_default; }
445
462
  });
446
- Object.defineProperty(exports, "ALLOWED_COUNTRIES", {
463
+ Object.defineProperty(exports, "setAuthTokenChangeCallback", {
447
464
  enumerable: true,
448
- get: function () { return chunkGQTO5ZE2_cjs.ALLOWED_COUNTRIES; }
465
+ get: function () { return chunkBBRXE57K_cjs.setAuthTokenChangeCallback; }
449
466
  });
450
- Object.defineProperty(exports, "Auth", {
467
+ Object.defineProperty(exports, "ADDRESS_FORM_SESSION_KEY", {
451
468
  enumerable: true,
452
- get: function () { return chunkGQTO5ZE2_cjs.auth_default; }
469
+ get: function () { return chunkNE3ZHELZ_cjs.ADDRESS_FORM_SESSION_KEY; }
470
+ });
471
+ Object.defineProperty(exports, "ALLOWED_COUNTRIES", {
472
+ enumerable: true,
473
+ get: function () { return chunkNE3ZHELZ_cjs.ALLOWED_COUNTRIES; }
453
474
  });
454
475
  Object.defineProperty(exports, "DEFAULT_TOAST_CONFIG", {
455
476
  enumerable: true,
456
- get: function () { return chunkGQTO5ZE2_cjs.DEFAULT_TOAST_CONFIG; }
477
+ get: function () { return chunkNE3ZHELZ_cjs.DEFAULT_TOAST_CONFIG; }
457
478
  });
458
479
  Object.defineProperty(exports, "PRODUCT_STATUSES", {
459
480
  enumerable: true,
460
- get: function () { return chunkGQTO5ZE2_cjs.PRODUCT_STATUSES; }
481
+ get: function () { return chunkNE3ZHELZ_cjs.PRODUCT_STATUSES; }
461
482
  });
462
483
  Object.defineProperty(exports, "SLICE_STATUS", {
463
484
  enumerable: true,
464
- get: function () { return chunkGQTO5ZE2_cjs.SLICE_STATUS; }
485
+ get: function () { return chunkNE3ZHELZ_cjs.SLICE_STATUS; }
465
486
  });
466
487
  Object.defineProperty(exports, "USER_CART", {
467
488
  enumerable: true,
468
- get: function () { return chunkGQTO5ZE2_cjs.USER_CART; }
489
+ get: function () { return chunkNE3ZHELZ_cjs.USER_CART; }
469
490
  });
470
491
  Object.defineProperty(exports, "USER_CREDENTIALS", {
471
492
  enumerable: true,
472
- get: function () { return chunkGQTO5ZE2_cjs.USER_CREDENTIALS; }
493
+ get: function () { return chunkNE3ZHELZ_cjs.USER_CREDENTIALS; }
473
494
  });
474
495
  Object.defineProperty(exports, "USER_CRED_REFRESH_TOKEN", {
475
496
  enumerable: true,
476
- get: function () { return chunkGQTO5ZE2_cjs.USER_CRED_REFRESH_TOKEN; }
497
+ get: function () { return chunkNE3ZHELZ_cjs.USER_CRED_REFRESH_TOKEN; }
477
498
  });
478
499
  Object.defineProperty(exports, "USER_CRED_TOKEN", {
479
500
  enumerable: true,
480
- get: function () { return chunkGQTO5ZE2_cjs.USER_CRED_TOKEN; }
501
+ get: function () { return chunkNE3ZHELZ_cjs.USER_CRED_TOKEN; }
481
502
  });
482
503
  Object.defineProperty(exports, "pathNameMap", {
483
504
  enumerable: true,
484
- get: function () { return chunkGQTO5ZE2_cjs.pathNameMap; }
485
- });
486
- Object.defineProperty(exports, "setAuthTokenChangeCallback", {
487
- enumerable: true,
488
- get: function () { return chunkGQTO5ZE2_cjs.setAuthTokenChangeCallback; }
505
+ get: function () { return chunkNE3ZHELZ_cjs.pathNameMap; }
489
506
  });
490
507
  Object.defineProperty(exports, "getApiEndpoint", {
491
508
  enumerable: true,
@@ -520,7 +537,7 @@ Object.defineProperty(exports, "initConfig", {
520
537
  get: function () { return chunkN3CTXRFT_cjs.initConfig; }
521
538
  });
522
539
  exports.PhonepePayment = phonepe_default;
523
- exports.authRoutes = authRoutes;
540
+ exports.calculateDiscountPercent = calculateDiscountPercent;
524
541
  exports.cropImage = cropImage;
525
542
  exports.debounce = debounce;
526
543
  exports.formatBookingDateTime = formatBookingDateTime;
@@ -530,6 +547,4 @@ exports.getNextAvailableDate = getNextAvailableDate;
530
547
  exports.getTimeConstraints = getTimeConstraints;
531
548
  exports.getUniqueId = getUniqueId;
532
549
  exports.isAvailableDay = isAvailableDay;
533
- exports.protectedRoutes = protectedRoutes;
534
- exports.publicRoutes = publicRoutes;
535
- exports.urls = routes_default;
550
+ exports.isProductCustomized = isProductCustomized;
@@ -1,6 +1,8 @@
1
- import { C as Cart, k as ProductDetail, d as Category$1, j as Product, O as OperatingHours, T as TimeSlot } from '../cart-VaCKkJ1C.cjs';
2
- export { m as ADDRESS_FORM_SESSION_KEY, n as ALLOWED_COUNTRIES, o as DEFAULT_TOAST_CONFIG, p as PRODUCT_STATUSES, l as SLICE_STATUS, U as USER_CART, q as USER_CREDENTIALS, r as USER_CRED_REFRESH_TOKEN, s as USER_CRED_TOKEN, t as pathNameMap } from '../cart-VaCKkJ1C.cjs';
1
+ import { c as ProductDetail, b as Product, O as OperatingHours, T as TimeSlot, A as Attributes } from '../product-Dfi0ke-4.cjs';
2
+ export { e as ADDRESS_FORM_SESSION_KEY, f as ALLOWED_COUNTRIES, D as DEFAULT_TOAST_CONFIG, g as PRODUCT_STATUSES, d as SLICE_STATUS, U as USER_CART, h as USER_CREDENTIALS, i as USER_CRED_REFRESH_TOKEN, j as USER_CRED_TOKEN, p as pathNameMap } from '../product-Dfi0ke-4.cjs';
3
+ import { C as Cart, b as Category$1 } from '../cart-BY8D8w-s.cjs';
3
4
  export { S as SnapstoreConfig, g as getApiEndpoint, a as getCloudFront, b as getConfig, c as getPhonePeApiEndpoint, d as getPublicApiEndpoint, e as getSecretKey, f as getStoreId, i as initConfig } from '../index-DTyIuLuI.cjs';
5
+ import { C as CollectionResponse } from '../collections-CenI9AlQ.cjs';
4
6
  import { AxiosResponse } from 'axios';
5
7
  import { a as PhonePe } from '../phonepe-D7vn-9SR.cjs';
6
8
  import { O as Order } from '../orders-DHJhJ3xz.cjs';
@@ -350,12 +352,25 @@ interface ImageWithText {
350
352
  interface Collections {
351
353
  type: "collections";
352
354
  id: string;
353
- title: string;
354
355
  slug: string;
355
- items: string[];
356
+ title?: string;
357
+ description?: string;
358
+ variants?: CollectionResponse[];
356
359
  }
357
- type SectionType = "product-collection" | "categories" | "banner" | "sub-categories" | "pre-footer" | "category-highlights" | "store-review" | "product-highlight" | "image-with-text" | "collections";
358
- type Section = ProductCollection | Category | Banner | PreFooter | StoreReview | CategoryHighlights | SubCategorySection | ProductHighlight | ImageWithText | Collections;
360
+ interface ValueHighlights {
361
+ type: "value-highlights";
362
+ id: string;
363
+ title: string;
364
+ description: string;
365
+ highlights: {
366
+ value: string;
367
+ label: string;
368
+ image: string;
369
+ social: null | string;
370
+ }[];
371
+ }
372
+ type SectionType = "product-collection" | "categories" | "banner" | "sub-categories" | "pre-footer" | "category-highlights" | "store-review" | "product-highlight" | "image-with-text" | "collections" | "value-highlights";
373
+ type Section = ProductCollection | Category | Banner | PreFooter | StoreReview | CategoryHighlights | SubCategorySection | ProductHighlight | ImageWithText | Collections | ValueHighlights;
359
374
  interface Footer {
360
375
  showSocialLinks: boolean;
361
376
  showContactDetails: boolean;
@@ -504,4 +519,54 @@ declare const generateTimeOptions: (minTime: string, maxTime: string) => string[
504
519
  declare const getNextAvailableDate: (availableDays: string[], advanceBookingWindow: number) => Date | null;
505
520
  declare const formatBookingDateTime: (date: Date | null, time: string) => string;
506
521
 
507
- export { Auth, type AvailableFilter, type Banner, CacheManager, type Category, type CategoryHighlights, type Collections, type ColorScheme, type FilterOption, type FilterType, type Footer, type HeaderCategory, type Hero, type HomePageContents, type ImageWithText, LocalCart, type LocationData, type Logo, type Menuitem, type NavBar, type NavElement, type NavElementOld, type PageHeaderProps, type PageMeta, type PageProps, type PagePropsFull, PhonepePayment, type PreFooter, type ProductCollection, type ProductHighlight, type RibbonBar, type RibbonMessage, type Section, type SectionFilters, type SectionType, type SliderSettings, type SocialLinks, type SocialMedia, type StoreReview, type SubCategory, type SubCategorySection, type TemplateTheme, type Theme, authRoutes, cache, clearCache, constructFilter, convertObjectToParams, convertToCurrency, cropImage, debounce, deleteCache, digestMessage, formatBookingDateTime, formatDateTime, formatPostalLabel, generateCacheKey, generateTimeOptions, getAddressMeta, getAvailableDaysText, getCache, getDelayInMilliseconds, getNextAvailableDate, getParamsFromURL, getQueryParams, getTimeConstraints, getUniqueId, hasCache, invalidateCache, isAvailableDay, pixelEvents, pluralize, type preFooterContent, protectedRoutes, publicRoutes, pushParamsToURL, setAuthTokenChangeCallback, setCache, shareLink, urls };
522
+ /**
523
+ * Finds a variant that exactly matches all attribute keys in the new selection.
524
+ * Uses the provided attribute keys to compare (more robust than iterating selectedVariant keys).
525
+ */
526
+ declare const findMatchingVariant: (variantAttributes: ProductDetail.VariantAttribute[], attributeKeys: string[], newSelectedVariant: Record<string, {
527
+ name: string;
528
+ value: string;
529
+ }>) => ProductDetail.VariantAttribute | undefined;
530
+ /**
531
+ * Finds a variant that shares the same value for a specific attribute type.
532
+ * Used as a fallback when no exact match is found.
533
+ */
534
+ declare const findSimilarVariant: (variantAttributes: ProductDetail.VariantAttribute[], variantType: string, variant: {
535
+ name: string;
536
+ value: string;
537
+ }) => ProductDetail.VariantAttribute | undefined;
538
+ /**
539
+ * Checks if a variant combination is available (exists in the product's variant attributes).
540
+ * Builds a full selection from the current state + candidate, then checks for a match.
541
+ */
542
+ declare const isVariantCombinationAvailable: (variantAttributes: ProductDetail.VariantAttribute[], attributeKeys: string[], currentSelection: Attributes, variantType: string, candidate: {
543
+ name: string;
544
+ value: string;
545
+ }) => boolean;
546
+ /**
547
+ * Checks if a variant type represents a color attribute.
548
+ */
549
+ declare const isColorVariantType: (variantType: string) => boolean;
550
+
551
+ /**
552
+ * Returns a human-readable relative time string (e.g. "in 3 days", "2 hours ago").
553
+ */
554
+ declare function timeFromNow(date: string | Date): string;
555
+ /**
556
+ * Checks if a date is in the past.
557
+ */
558
+ declare function isExpired(date: string | Date): boolean;
559
+
560
+ /**
561
+ * Calculate the discount percentage between actual and selling price.
562
+ */
563
+ declare function calculateDiscountPercent(actualPrice: number | string, sellingPrice: number | string): number;
564
+ /**
565
+ * Check if a product variant has customization inputs.
566
+ */
567
+ declare function isProductCustomized(customizationInputs: Array<{
568
+ product_variant: number;
569
+ [key: string]: any;
570
+ }> | undefined, productId: number): boolean;
571
+
572
+ export { Auth, type AvailableFilter, type Banner, CacheManager, type Category, type CategoryHighlights, type Collections, type ColorScheme, type FilterOption, type FilterType, type Footer, type HeaderCategory, type Hero, type HomePageContents, type ImageWithText, LocalCart, type LocationData, type Logo, type Menuitem, type NavBar, type NavElement, type NavElementOld, type PageHeaderProps, type PageMeta, type PageProps, type PagePropsFull, PhonepePayment, type PreFooter, type ProductCollection, type ProductHighlight, type RibbonBar, type RibbonMessage, type Section, type SectionFilters, type SectionType, type SliderSettings, type SocialLinks, type SocialMedia, type StoreReview, type SubCategory, type SubCategorySection, type TemplateTheme, type Theme, type ValueHighlights, authRoutes, cache, calculateDiscountPercent, clearCache, constructFilter, convertObjectToParams, convertToCurrency, cropImage, debounce, deleteCache, digestMessage, findMatchingVariant, findSimilarVariant, formatBookingDateTime, formatDateTime, formatPostalLabel, generateCacheKey, generateTimeOptions, getAddressMeta, getAvailableDaysText, getCache, getDelayInMilliseconds, getNextAvailableDate, getParamsFromURL, getQueryParams, getTimeConstraints, getUniqueId, hasCache, invalidateCache, isAvailableDay, isColorVariantType, isExpired, isProductCustomized, isVariantCombinationAvailable, pixelEvents, pluralize, type preFooterContent, protectedRoutes, publicRoutes, pushParamsToURL, setAuthTokenChangeCallback, setCache, shareLink, timeFromNow, urls };
@@ -1,6 +1,8 @@
1
- import { C as Cart, k as ProductDetail, d as Category$1, j as Product, O as OperatingHours, T as TimeSlot } from '../cart-VaCKkJ1C.js';
2
- export { m as ADDRESS_FORM_SESSION_KEY, n as ALLOWED_COUNTRIES, o as DEFAULT_TOAST_CONFIG, p as PRODUCT_STATUSES, l as SLICE_STATUS, U as USER_CART, q as USER_CREDENTIALS, r as USER_CRED_REFRESH_TOKEN, s as USER_CRED_TOKEN, t as pathNameMap } from '../cart-VaCKkJ1C.js';
1
+ import { c as ProductDetail, b as Product, O as OperatingHours, T as TimeSlot, A as Attributes } from '../product-Dfi0ke-4.js';
2
+ export { e as ADDRESS_FORM_SESSION_KEY, f as ALLOWED_COUNTRIES, D as DEFAULT_TOAST_CONFIG, g as PRODUCT_STATUSES, d as SLICE_STATUS, U as USER_CART, h as USER_CREDENTIALS, i as USER_CRED_REFRESH_TOKEN, j as USER_CRED_TOKEN, p as pathNameMap } from '../product-Dfi0ke-4.js';
3
+ import { C as Cart, b as Category$1 } from '../cart-GuhgeBBt.js';
3
4
  export { S as SnapstoreConfig, g as getApiEndpoint, a as getCloudFront, b as getConfig, c as getPhonePeApiEndpoint, d as getPublicApiEndpoint, e as getSecretKey, f as getStoreId, i as initConfig } from '../index-DTyIuLuI.js';
5
+ import { C as CollectionResponse } from '../collections-CenI9AlQ.js';
4
6
  import { AxiosResponse } from 'axios';
5
7
  import { a as PhonePe } from '../phonepe-D7vn-9SR.js';
6
8
  import { O as Order } from '../orders-DHJhJ3xz.js';
@@ -350,12 +352,25 @@ interface ImageWithText {
350
352
  interface Collections {
351
353
  type: "collections";
352
354
  id: string;
353
- title: string;
354
355
  slug: string;
355
- items: string[];
356
+ title?: string;
357
+ description?: string;
358
+ variants?: CollectionResponse[];
356
359
  }
357
- type SectionType = "product-collection" | "categories" | "banner" | "sub-categories" | "pre-footer" | "category-highlights" | "store-review" | "product-highlight" | "image-with-text" | "collections";
358
- type Section = ProductCollection | Category | Banner | PreFooter | StoreReview | CategoryHighlights | SubCategorySection | ProductHighlight | ImageWithText | Collections;
360
+ interface ValueHighlights {
361
+ type: "value-highlights";
362
+ id: string;
363
+ title: string;
364
+ description: string;
365
+ highlights: {
366
+ value: string;
367
+ label: string;
368
+ image: string;
369
+ social: null | string;
370
+ }[];
371
+ }
372
+ type SectionType = "product-collection" | "categories" | "banner" | "sub-categories" | "pre-footer" | "category-highlights" | "store-review" | "product-highlight" | "image-with-text" | "collections" | "value-highlights";
373
+ type Section = ProductCollection | Category | Banner | PreFooter | StoreReview | CategoryHighlights | SubCategorySection | ProductHighlight | ImageWithText | Collections | ValueHighlights;
359
374
  interface Footer {
360
375
  showSocialLinks: boolean;
361
376
  showContactDetails: boolean;
@@ -504,4 +519,54 @@ declare const generateTimeOptions: (minTime: string, maxTime: string) => string[
504
519
  declare const getNextAvailableDate: (availableDays: string[], advanceBookingWindow: number) => Date | null;
505
520
  declare const formatBookingDateTime: (date: Date | null, time: string) => string;
506
521
 
507
- export { Auth, type AvailableFilter, type Banner, CacheManager, type Category, type CategoryHighlights, type Collections, type ColorScheme, type FilterOption, type FilterType, type Footer, type HeaderCategory, type Hero, type HomePageContents, type ImageWithText, LocalCart, type LocationData, type Logo, type Menuitem, type NavBar, type NavElement, type NavElementOld, type PageHeaderProps, type PageMeta, type PageProps, type PagePropsFull, PhonepePayment, type PreFooter, type ProductCollection, type ProductHighlight, type RibbonBar, type RibbonMessage, type Section, type SectionFilters, type SectionType, type SliderSettings, type SocialLinks, type SocialMedia, type StoreReview, type SubCategory, type SubCategorySection, type TemplateTheme, type Theme, authRoutes, cache, clearCache, constructFilter, convertObjectToParams, convertToCurrency, cropImage, debounce, deleteCache, digestMessage, formatBookingDateTime, formatDateTime, formatPostalLabel, generateCacheKey, generateTimeOptions, getAddressMeta, getAvailableDaysText, getCache, getDelayInMilliseconds, getNextAvailableDate, getParamsFromURL, getQueryParams, getTimeConstraints, getUniqueId, hasCache, invalidateCache, isAvailableDay, pixelEvents, pluralize, type preFooterContent, protectedRoutes, publicRoutes, pushParamsToURL, setAuthTokenChangeCallback, setCache, shareLink, urls };
522
+ /**
523
+ * Finds a variant that exactly matches all attribute keys in the new selection.
524
+ * Uses the provided attribute keys to compare (more robust than iterating selectedVariant keys).
525
+ */
526
+ declare const findMatchingVariant: (variantAttributes: ProductDetail.VariantAttribute[], attributeKeys: string[], newSelectedVariant: Record<string, {
527
+ name: string;
528
+ value: string;
529
+ }>) => ProductDetail.VariantAttribute | undefined;
530
+ /**
531
+ * Finds a variant that shares the same value for a specific attribute type.
532
+ * Used as a fallback when no exact match is found.
533
+ */
534
+ declare const findSimilarVariant: (variantAttributes: ProductDetail.VariantAttribute[], variantType: string, variant: {
535
+ name: string;
536
+ value: string;
537
+ }) => ProductDetail.VariantAttribute | undefined;
538
+ /**
539
+ * Checks if a variant combination is available (exists in the product's variant attributes).
540
+ * Builds a full selection from the current state + candidate, then checks for a match.
541
+ */
542
+ declare const isVariantCombinationAvailable: (variantAttributes: ProductDetail.VariantAttribute[], attributeKeys: string[], currentSelection: Attributes, variantType: string, candidate: {
543
+ name: string;
544
+ value: string;
545
+ }) => boolean;
546
+ /**
547
+ * Checks if a variant type represents a color attribute.
548
+ */
549
+ declare const isColorVariantType: (variantType: string) => boolean;
550
+
551
+ /**
552
+ * Returns a human-readable relative time string (e.g. "in 3 days", "2 hours ago").
553
+ */
554
+ declare function timeFromNow(date: string | Date): string;
555
+ /**
556
+ * Checks if a date is in the past.
557
+ */
558
+ declare function isExpired(date: string | Date): boolean;
559
+
560
+ /**
561
+ * Calculate the discount percentage between actual and selling price.
562
+ */
563
+ declare function calculateDiscountPercent(actualPrice: number | string, sellingPrice: number | string): number;
564
+ /**
565
+ * Check if a product variant has customization inputs.
566
+ */
567
+ declare function isProductCustomized(customizationInputs: Array<{
568
+ product_variant: number;
569
+ [key: string]: any;
570
+ }> | undefined, productId: number): boolean;
571
+
572
+ export { Auth, type AvailableFilter, type Banner, CacheManager, type Category, type CategoryHighlights, type Collections, type ColorScheme, type FilterOption, type FilterType, type Footer, type HeaderCategory, type Hero, type HomePageContents, type ImageWithText, LocalCart, type LocationData, type Logo, type Menuitem, type NavBar, type NavElement, type NavElementOld, type PageHeaderProps, type PageMeta, type PageProps, type PagePropsFull, PhonepePayment, type PreFooter, type ProductCollection, type ProductHighlight, type RibbonBar, type RibbonMessage, type Section, type SectionFilters, type SectionType, type SliderSettings, type SocialLinks, type SocialMedia, type StoreReview, type SubCategory, type SubCategorySection, type TemplateTheme, type Theme, type ValueHighlights, authRoutes, cache, calculateDiscountPercent, clearCache, constructFilter, convertObjectToParams, convertToCurrency, cropImage, debounce, deleteCache, digestMessage, findMatchingVariant, findSimilarVariant, formatBookingDateTime, formatDateTime, formatPostalLabel, generateCacheKey, generateTimeOptions, getAddressMeta, getAvailableDaysText, getCache, getDelayInMilliseconds, getNextAvailableDate, getParamsFromURL, getQueryParams, getTimeConstraints, getUniqueId, hasCache, invalidateCache, isAvailableDay, isColorVariantType, isExpired, isProductCustomized, isVariantCombinationAvailable, pixelEvents, pluralize, type preFooterContent, protectedRoutes, publicRoutes, pushParamsToURL, setAuthTokenChangeCallback, setCache, shareLink, timeFromNow, urls };
@@ -1,8 +1,12 @@
1
- export { cart_default as LocalCart } from '../chunk-E7WPE3PV.js';
1
+ export { authRoutes, protectedRoutes, publicRoutes, routes_default as urls } from '../chunk-4C4NTH6O.js';
2
+ export { findMatchingVariant, findSimilarVariant, isColorVariantType, isVariantCombinationAvailable } from '../chunk-HEFA67WK.js';
3
+ export { cart_default as LocalCart } from '../chunk-QAC72HKO.js';
2
4
  export { pixelEvents } from '../chunk-WFDKKOO7.js';
5
+ export { isExpired, timeFromNow } from '../chunk-HSF2D56O.js';
3
6
  import { digestMessage } from '../chunk-YUPBTD4M.js';
4
7
  export { CacheManager, cache, clearCache, constructFilter, convertObjectToParams, convertToCurrency, deleteCache, digestMessage, formatDateTime, formatPostalLabel, generateCacheKey, getAddressMeta, getCache, getDelayInMilliseconds, getParamsFromURL, getQueryParams, hasCache, invalidateCache, pluralize, pushParamsToURL, setCache, shareLink } from '../chunk-YUPBTD4M.js';
5
- export { ADDRESS_FORM_SESSION_KEY, ALLOWED_COUNTRIES, auth_default as Auth, DEFAULT_TOAST_CONFIG, PRODUCT_STATUSES, SLICE_STATUS, USER_CART, USER_CREDENTIALS, USER_CRED_REFRESH_TOKEN, USER_CRED_TOKEN, pathNameMap, setAuthTokenChangeCallback } from '../chunk-FLBJKM6G.js';
8
+ export { auth_default as Auth, setAuthTokenChangeCallback } from '../chunk-WEMNXIRS.js';
9
+ export { ADDRESS_FORM_SESSION_KEY, ALLOWED_COUNTRIES, DEFAULT_TOAST_CONFIG, PRODUCT_STATUSES, SLICE_STATUS, USER_CART, USER_CREDENTIALS, USER_CRED_REFRESH_TOKEN, USER_CRED_TOKEN, pathNameMap } from '../chunk-BQ256JKN.js';
6
10
  import { getPhonePeApiEndpoint, getPublicApiEndpoint } from '../chunk-JQMLHRWL.js';
7
11
  export { getApiEndpoint, getCloudFront, getConfig, getPhonePeApiEndpoint, getPublicApiEndpoint, getSecretKey, getStoreId, initConfig } from '../chunk-JQMLHRWL.js';
8
12
  import axios from 'axios';
@@ -163,46 +167,6 @@ var PhonepePayment = class {
163
167
  }
164
168
  };
165
169
  var phonepe_default = PhonepePayment;
166
-
167
- // src/utils/routes.ts
168
- var protectedRoutes = [
169
- "/my/profile",
170
- "/my/orders",
171
- "/my/delete-account",
172
- "/my/addresses",
173
- "/my/dashboard"
174
- ];
175
- var authRoutes = ["/login", "/signup"];
176
- var publicRoutes = ["/about", "/"];
177
- var urls = {
178
- dashboard: "/my/dashboard",
179
- profile: "/my/profile",
180
- orders: "/my/orders",
181
- orderDetail: "/my/orders/:id",
182
- deleteAccount: "/my/delete-account",
183
- addresses: "/my/addresses",
184
- bookings: "/my/bookings",
185
- login: "/login",
186
- signup: "/signup",
187
- about: "/about",
188
- home: "/",
189
- searchProducts: "/search-products",
190
- shop: "/shop",
191
- shopDetails: "/shop/:id",
192
- cart: "/checkout/cart",
193
- address: "/checkout/address",
194
- payment: "/checkout/payment",
195
- wishlist: "/wishlist",
196
- privacyPolicy: "/privacy-policy",
197
- faq: "/faq",
198
- contactUs: "/contact-us",
199
- services: "/services",
200
- storeReview: "/store-review",
201
- returnAndRefund: "/return-and-refund",
202
- shippingPolicy: "/shipping-policy",
203
- termsOfService: "/terms-of-service"
204
- };
205
- var routes_default = urls;
206
170
  var getUniqueId = () => {
207
171
  const uniqueId = Cookies.get("__spa_id");
208
172
  if (!uniqueId) {
@@ -339,4 +303,17 @@ var formatBookingDateTime = (date, time) => {
339
303
  return bookingDate.toISOString();
340
304
  };
341
305
 
342
- export { phonepe_default as PhonepePayment, authRoutes, cropImage, debounce, formatBookingDateTime, generateTimeOptions, getAvailableDaysText, getNextAvailableDate, getTimeConstraints, getUniqueId, isAvailableDay, protectedRoutes, publicRoutes, routes_default as urls };
306
+ // src/utils/cart-helpers.ts
307
+ function calculateDiscountPercent(actualPrice, sellingPrice) {
308
+ const actual = Number(actualPrice);
309
+ const selling = Number(sellingPrice);
310
+ if (!actual || actual <= 0) return 0;
311
+ return Math.round((actual - selling) / actual * 100);
312
+ }
313
+ function isProductCustomized(customizationInputs, productId) {
314
+ return customizationInputs?.some(
315
+ (input) => input.product_variant === productId
316
+ ) ?? false;
317
+ }
318
+
319
+ export { phonepe_default as PhonepePayment, calculateDiscountPercent, cropImage, debounce, formatBookingDateTime, generateTimeOptions, getAvailableDaysText, getNextAvailableDate, getTimeConstraints, getUniqueId, isAvailableDay, isProductCustomized };
@@ -1,4 +1,4 @@
1
- import { l as SLICE_STATUS, k as ProductDetail } from './cart-VaCKkJ1C.js';
1
+ import { d as SLICE_STATUS, c as ProductDetail } from './product-Dfi0ke-4.cjs';
2
2
 
3
3
  declare namespace User {
4
4
  interface Root {
@@ -1,4 +1,4 @@
1
- import { l as SLICE_STATUS, k as ProductDetail } from './cart-VaCKkJ1C.cjs';
1
+ import { d as SLICE_STATUS, c as ProductDetail } from './product-Dfi0ke-4.js';
2
2
 
3
3
  declare namespace User {
4
4
  interface Root {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storepecker/storefront-core",
3
- "version": "1.2.0",
3
+ "version": "2.1.0",
4
4
  "description": "Shared logic and utilities for Snapstore themes",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -46,7 +46,12 @@
46
46
  "import": "./dist/components/index.js",
47
47
  "require": "./dist/components/index.cjs"
48
48
  },
49
- "./components/styles": "./dist/components/index.css"
49
+ "./components/styles": "./dist/components/index.css",
50
+ "./middleware": {
51
+ "types": "./dist/middleware/index.d.ts",
52
+ "import": "./dist/middleware/index.js",
53
+ "require": "./dist/middleware/index.cjs"
54
+ }
50
55
  },
51
56
  "typesVersions": {
52
57
  "*": {
@@ -70,6 +75,9 @@
70
75
  ],
71
76
  "components": [
72
77
  "./dist/components/index.d.ts"
78
+ ],
79
+ "middleware": [
80
+ "./dist/middleware/index.d.ts"
73
81
  ]
74
82
  }
75
83
  },
@@ -81,17 +89,19 @@
81
89
  "lint": "tsc --noEmit",
82
90
  "prepublishOnly": "npm run build",
83
91
  "release": "npm run build && npm publish --access public",
84
- "release:patch": "npm version patch && npm run release",
85
- "release:minor": "npm version minor && npm run release",
86
- "release:major": "npm version major && npm run release"
92
+ "release:patch": "npm version patch --no-git-tag-version && npm run release",
93
+ "release:minor": "npm version minor --no-git-tag-version && npm run release",
94
+ "release:major": "npm version major --no-git-tag-version && npm run release"
87
95
  },
88
96
  "peerDependencies": {
89
97
  "axios": "^1.0.0",
90
98
  "clsx": "^2.0.0",
91
99
  "formik": "^2.0.0",
100
+ "jwt-decode": "^4.0.0",
92
101
  "libphonenumber-js": "^1.10.0",
93
102
  "react": "^18.0.0 || ^19.0.0",
94
103
  "react-dom": "^18.0.0 || ^19.0.0",
104
+ "react-responsive-modal": "^6.0.0",
95
105
  "typescript-cookie": "^1.0.0",
96
106
  "yup": "^1.0.0",
97
107
  "zustand": "^5.0.0"
@@ -108,6 +118,12 @@
108
118
  },
109
119
  "libphonenumber-js": {
110
120
  "optional": true
121
+ },
122
+ "jwt-decode": {
123
+ "optional": true
124
+ },
125
+ "react-responsive-modal": {
126
+ "optional": true
111
127
  }
112
128
  },
113
129
  "devDependencies": {
@@ -119,10 +135,13 @@
119
135
  "esbuild-css-modules-plugin": "^3.1.5",
120
136
  "formik": "^2.4.6",
121
137
  "happy-dom": "^20.8.3",
138
+ "jwt-decode": "^4.0.0",
122
139
  "libphonenumber-js": "^1.11.0",
140
+ "next": "^16.1.6",
123
141
  "react": "^18.3.1",
124
142
  "react-dom": "^18.3.1",
125
143
  "react-easy-crop": "^5.5.6",
144
+ "react-responsive-modal": "^6.4.0",
126
145
  "react-toastify": "^11.0.5",
127
146
  "sass": "^1.97.3",
128
147
  "tsup": "^8.0.0",
@@ -1,40 +0,0 @@
1
- import { getCart } from './chunk-Z7LHRD3V.js';
2
- import { create } from 'zustand';
3
-
4
- var initialState = {
5
- cart: null,
6
- status: "idle" /* IDLE */
7
- };
8
- var useCartStore = create((set) => ({
9
- ...initialState,
10
- setCart: (cart) => set({ cart, status: "idle" /* IDLE */ }),
11
- resetCart: () => set(initialState),
12
- resetCartCount: () => set((state) => {
13
- if (!state.cart) return state;
14
- return { cart: { ...state.cart, total_quantity: 0 } };
15
- }),
16
- syncCart: async (addressId) => {
17
- set({ status: "loading" /* LOADING */ });
18
- try {
19
- const response = await getCart("/customer/cart/", addressId);
20
- if (response) {
21
- set({ cart: response, status: "idle" /* IDLE */ });
22
- }
23
- } catch {
24
- set({ status: "idle" /* IDLE */ });
25
- }
26
- },
27
- fetchCart: async (addressId) => {
28
- set({ status: "loading" /* LOADING */ });
29
- try {
30
- const response = await getCart("/customer/cart/", addressId);
31
- if (response) {
32
- set({ cart: response, status: "idle" /* IDLE */ });
33
- }
34
- } catch {
35
- set({ status: "idle" /* IDLE */ });
36
- }
37
- }
38
- }));
39
-
40
- export { useCartStore };