@storepecker/storefront-core 1.2.0 → 2.0.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.
- package/dist/api/index.cjs +76 -75
- package/dist/api/index.d.cts +4 -3
- package/dist/api/index.d.ts +4 -3
- package/dist/api/index.js +9 -8
- package/dist/{booking-B21s0inO.d.cts → booking-B39Ilxhg.d.ts} +1 -1
- package/dist/{booking-CegE1cje.d.ts → booking-Dk-BoHUB.d.cts} +1 -1
- package/dist/cart-BY8D8w-s.d.cts +90 -0
- package/dist/cart-GuhgeBBt.d.ts +90 -0
- package/dist/checkout/index.cjs +38 -37
- package/dist/checkout/index.d.cts +2 -1
- package/dist/checkout/index.d.ts +2 -1
- package/dist/checkout/index.js +6 -5
- package/dist/{chunk-34KV265H.cjs → chunk-26A3EBZI.cjs} +20 -20
- package/dist/chunk-2AHH3XBW.cjs +47 -0
- package/dist/{chunk-K5B62JZO.cjs → chunk-47XTPPII.cjs} +4 -4
- package/dist/chunk-4C4NTH6O.js +41 -0
- package/dist/{chunk-UM24VDYB.js → chunk-7R2V4C7Q.js} +2 -2
- package/dist/{chunk-CSISWBZZ.js → chunk-B7FOXIZN.js} +1 -1
- package/dist/chunk-BBRB475I.cjs +43 -0
- package/dist/chunk-BBRXE57K.cjs +50 -0
- package/dist/{chunk-QCQCFYYR.js → chunk-BHOXJGIE.js} +1 -1
- package/dist/chunk-BQ256JKN.js +39 -0
- package/dist/{chunk-7UH6REGV.js → chunk-C7ZJZEEN.js} +1 -1
- package/dist/{chunk-A6IO3HIN.cjs → chunk-FMHR5ABF.cjs} +28 -28
- package/dist/{chunk-JHGXIIBZ.cjs → chunk-G3R7ZVAG.cjs} +7 -7
- package/dist/{chunk-4MJMNIAB.js → chunk-GHABOHLA.js} +1 -1
- package/dist/chunk-GTV42PDK.cjs +46 -0
- package/dist/chunk-HEFA67WK.js +42 -0
- package/dist/chunk-HSF2D56O.js +40 -0
- package/dist/{chunk-GB3HW6DM.js → chunk-JWKDXFS4.js} +1 -1
- package/dist/{chunk-KWKHHRRJ.cjs → chunk-KKQKHG26.cjs} +3 -3
- package/dist/{chunk-QM73PI5L.cjs → chunk-N3ZCCKXV.cjs} +10 -10
- package/dist/{chunk-GQTO5ZE2.cjs → chunk-NE3ZHELZ.cjs} +0 -46
- package/dist/chunk-PWYWNRVO.cjs +150 -0
- package/dist/{chunk-E7WPE3PV.js → chunk-QAC72HKO.js} +1 -1
- package/dist/{chunk-CFF632IQ.cjs → chunk-SMHJRNCR.cjs} +4 -4
- package/dist/chunk-UOFTDL4D.js +146 -0
- package/dist/chunk-WEMNXIRS.js +47 -0
- package/dist/{chunk-LC5ZAUKL.cjs → chunk-XLQAALMU.cjs} +10 -10
- package/dist/{chunk-Z7LHRD3V.js → chunk-Y6NFUWTH.js} +3 -3
- package/dist/{chunk-LBGIUNM6.js → chunk-YY77CUWX.js} +1 -1
- package/dist/{chunk-UXLUE3HW.cjs → chunk-ZO2HREQL.cjs} +2 -2
- package/dist/components/index.cjs +126 -7
- package/dist/components/index.d.cts +35 -8
- package/dist/components/index.d.ts +35 -8
- package/dist/components/index.js +122 -7
- package/dist/hooks/index.cjs +368 -27
- package/dist/hooks/index.d.cts +83 -3
- package/dist/hooks/index.d.ts +83 -3
- package/dist/hooks/index.js +352 -14
- package/dist/middleware/index.cjs +47 -0
- package/dist/middleware/index.d.cts +8 -0
- package/dist/middleware/index.d.ts +8 -0
- package/dist/middleware/index.js +44 -0
- package/dist/models/index.d.cts +4 -3
- package/dist/models/index.d.ts +4 -3
- package/dist/{cart-VaCKkJ1C.d.cts → product-Dfi0ke-4.d.cts} +1 -88
- package/dist/{cart-VaCKkJ1C.d.ts → product-Dfi0ke-4.d.ts} +1 -88
- package/dist/store/index.cjs +17 -85
- package/dist/store/index.d.cts +22 -2
- package/dist/store/index.d.ts +22 -2
- package/dist/store/index.js +7 -82
- package/dist/utils/index.cjs +80 -65
- package/dist/utils/index.d.cts +54 -3
- package/dist/utils/index.d.ts +54 -3
- package/dist/utils/index.js +20 -43
- package/dist/{wishlist-FG8tgn76.d.ts → wishlist-DHOvXmJj.d.cts} +1 -1
- package/dist/{wishlist-CkAhLpbI.d.cts → wishlist-LfdFxddw.d.ts} +1 -1
- package/package.json +24 -5
- package/dist/chunk-7DQIKSGY.js +0 -40
- package/dist/chunk-FLBJKM6G.js +0 -83
- package/dist/chunk-S3WIGYDS.cjs +0 -42
package/dist/utils/index.cjs
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
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
|
|
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
|
|
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, "
|
|
459
|
+
Object.defineProperty(exports, "Auth", {
|
|
443
460
|
enumerable: true,
|
|
444
|
-
get: function () { return
|
|
461
|
+
get: function () { return chunkBBRXE57K_cjs.auth_default; }
|
|
445
462
|
});
|
|
446
|
-
Object.defineProperty(exports, "
|
|
463
|
+
Object.defineProperty(exports, "setAuthTokenChangeCallback", {
|
|
447
464
|
enumerable: true,
|
|
448
|
-
get: function () { return
|
|
465
|
+
get: function () { return chunkBBRXE57K_cjs.setAuthTokenChangeCallback; }
|
|
449
466
|
});
|
|
450
|
-
Object.defineProperty(exports, "
|
|
467
|
+
Object.defineProperty(exports, "ADDRESS_FORM_SESSION_KEY", {
|
|
451
468
|
enumerable: true,
|
|
452
|
-
get: function () { return
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
534
|
-
exports.publicRoutes = publicRoutes;
|
|
535
|
-
exports.urls = routes_default;
|
|
550
|
+
exports.isProductCustomized = isProductCustomized;
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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';
|
|
4
5
|
import { AxiosResponse } from 'axios';
|
|
5
6
|
import { a as PhonePe } from '../phonepe-D7vn-9SR.cjs';
|
|
@@ -504,4 +505,54 @@ declare const generateTimeOptions: (minTime: string, maxTime: string) => string[
|
|
|
504
505
|
declare const getNextAvailableDate: (availableDays: string[], advanceBookingWindow: number) => Date | null;
|
|
505
506
|
declare const formatBookingDateTime: (date: Date | null, time: string) => string;
|
|
506
507
|
|
|
507
|
-
|
|
508
|
+
/**
|
|
509
|
+
* Finds a variant that exactly matches all attribute keys in the new selection.
|
|
510
|
+
* Uses the provided attribute keys to compare (more robust than iterating selectedVariant keys).
|
|
511
|
+
*/
|
|
512
|
+
declare const findMatchingVariant: (variantAttributes: ProductDetail.VariantAttribute[], attributeKeys: string[], newSelectedVariant: Record<string, {
|
|
513
|
+
name: string;
|
|
514
|
+
value: string;
|
|
515
|
+
}>) => ProductDetail.VariantAttribute | undefined;
|
|
516
|
+
/**
|
|
517
|
+
* Finds a variant that shares the same value for a specific attribute type.
|
|
518
|
+
* Used as a fallback when no exact match is found.
|
|
519
|
+
*/
|
|
520
|
+
declare const findSimilarVariant: (variantAttributes: ProductDetail.VariantAttribute[], variantType: string, variant: {
|
|
521
|
+
name: string;
|
|
522
|
+
value: string;
|
|
523
|
+
}) => ProductDetail.VariantAttribute | undefined;
|
|
524
|
+
/**
|
|
525
|
+
* Checks if a variant combination is available (exists in the product's variant attributes).
|
|
526
|
+
* Builds a full selection from the current state + candidate, then checks for a match.
|
|
527
|
+
*/
|
|
528
|
+
declare const isVariantCombinationAvailable: (variantAttributes: ProductDetail.VariantAttribute[], attributeKeys: string[], currentSelection: Attributes, variantType: string, candidate: {
|
|
529
|
+
name: string;
|
|
530
|
+
value: string;
|
|
531
|
+
}) => boolean;
|
|
532
|
+
/**
|
|
533
|
+
* Checks if a variant type represents a color attribute.
|
|
534
|
+
*/
|
|
535
|
+
declare const isColorVariantType: (variantType: string) => boolean;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Returns a human-readable relative time string (e.g. "in 3 days", "2 hours ago").
|
|
539
|
+
*/
|
|
540
|
+
declare function timeFromNow(date: string | Date): string;
|
|
541
|
+
/**
|
|
542
|
+
* Checks if a date is in the past.
|
|
543
|
+
*/
|
|
544
|
+
declare function isExpired(date: string | Date): boolean;
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Calculate the discount percentage between actual and selling price.
|
|
548
|
+
*/
|
|
549
|
+
declare function calculateDiscountPercent(actualPrice: number | string, sellingPrice: number | string): number;
|
|
550
|
+
/**
|
|
551
|
+
* Check if a product variant has customization inputs.
|
|
552
|
+
*/
|
|
553
|
+
declare function isProductCustomized(customizationInputs: Array<{
|
|
554
|
+
product_variant: number;
|
|
555
|
+
[key: string]: any;
|
|
556
|
+
}> | undefined, productId: number): boolean;
|
|
557
|
+
|
|
558
|
+
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, 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 };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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';
|
|
4
5
|
import { AxiosResponse } from 'axios';
|
|
5
6
|
import { a as PhonePe } from '../phonepe-D7vn-9SR.js';
|
|
@@ -504,4 +505,54 @@ declare const generateTimeOptions: (minTime: string, maxTime: string) => string[
|
|
|
504
505
|
declare const getNextAvailableDate: (availableDays: string[], advanceBookingWindow: number) => Date | null;
|
|
505
506
|
declare const formatBookingDateTime: (date: Date | null, time: string) => string;
|
|
506
507
|
|
|
507
|
-
|
|
508
|
+
/**
|
|
509
|
+
* Finds a variant that exactly matches all attribute keys in the new selection.
|
|
510
|
+
* Uses the provided attribute keys to compare (more robust than iterating selectedVariant keys).
|
|
511
|
+
*/
|
|
512
|
+
declare const findMatchingVariant: (variantAttributes: ProductDetail.VariantAttribute[], attributeKeys: string[], newSelectedVariant: Record<string, {
|
|
513
|
+
name: string;
|
|
514
|
+
value: string;
|
|
515
|
+
}>) => ProductDetail.VariantAttribute | undefined;
|
|
516
|
+
/**
|
|
517
|
+
* Finds a variant that shares the same value for a specific attribute type.
|
|
518
|
+
* Used as a fallback when no exact match is found.
|
|
519
|
+
*/
|
|
520
|
+
declare const findSimilarVariant: (variantAttributes: ProductDetail.VariantAttribute[], variantType: string, variant: {
|
|
521
|
+
name: string;
|
|
522
|
+
value: string;
|
|
523
|
+
}) => ProductDetail.VariantAttribute | undefined;
|
|
524
|
+
/**
|
|
525
|
+
* Checks if a variant combination is available (exists in the product's variant attributes).
|
|
526
|
+
* Builds a full selection from the current state + candidate, then checks for a match.
|
|
527
|
+
*/
|
|
528
|
+
declare const isVariantCombinationAvailable: (variantAttributes: ProductDetail.VariantAttribute[], attributeKeys: string[], currentSelection: Attributes, variantType: string, candidate: {
|
|
529
|
+
name: string;
|
|
530
|
+
value: string;
|
|
531
|
+
}) => boolean;
|
|
532
|
+
/**
|
|
533
|
+
* Checks if a variant type represents a color attribute.
|
|
534
|
+
*/
|
|
535
|
+
declare const isColorVariantType: (variantType: string) => boolean;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Returns a human-readable relative time string (e.g. "in 3 days", "2 hours ago").
|
|
539
|
+
*/
|
|
540
|
+
declare function timeFromNow(date: string | Date): string;
|
|
541
|
+
/**
|
|
542
|
+
* Checks if a date is in the past.
|
|
543
|
+
*/
|
|
544
|
+
declare function isExpired(date: string | Date): boolean;
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Calculate the discount percentage between actual and selling price.
|
|
548
|
+
*/
|
|
549
|
+
declare function calculateDiscountPercent(actualPrice: number | string, sellingPrice: number | string): number;
|
|
550
|
+
/**
|
|
551
|
+
* Check if a product variant has customization inputs.
|
|
552
|
+
*/
|
|
553
|
+
declare function isProductCustomized(customizationInputs: Array<{
|
|
554
|
+
product_variant: number;
|
|
555
|
+
[key: string]: any;
|
|
556
|
+
}> | undefined, productId: number): boolean;
|
|
557
|
+
|
|
558
|
+
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, 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 };
|
package/dist/utils/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
export {
|
|
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 {
|
|
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
|
-
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storepecker/storefront-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.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",
|
package/dist/chunk-7DQIKSGY.js
DELETED
|
@@ -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 };
|
package/dist/chunk-FLBJKM6G.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { removeCookie, getCookie, setCookie } from 'typescript-cookie';
|
|
2
|
-
|
|
3
|
-
// src/utils/constants.ts
|
|
4
|
-
var SLICE_STATUS = /* @__PURE__ */ ((SLICE_STATUS2) => {
|
|
5
|
-
SLICE_STATUS2["IDLE"] = "idle";
|
|
6
|
-
SLICE_STATUS2["LOADING"] = "loading";
|
|
7
|
-
SLICE_STATUS2["SUCCESS"] = "success";
|
|
8
|
-
SLICE_STATUS2["FAILURE"] = "failure";
|
|
9
|
-
return SLICE_STATUS2;
|
|
10
|
-
})(SLICE_STATUS || {});
|
|
11
|
-
var pathNameMap = {
|
|
12
|
-
"/checkout/cart": "bag",
|
|
13
|
-
"/checkout/address": "address",
|
|
14
|
-
"/checkout/payment": "payment",
|
|
15
|
-
"/checkout/summary": "summary"
|
|
16
|
-
};
|
|
17
|
-
var USER_CREDENTIALS = "____user_cred_";
|
|
18
|
-
var USER_CART = "____user_cart_";
|
|
19
|
-
var USER_CRED_TOKEN = "____user_cst_";
|
|
20
|
-
var USER_CRED_REFRESH_TOKEN = "____user_csr_";
|
|
21
|
-
var PRODUCT_STATUSES = [
|
|
22
|
-
"confirm",
|
|
23
|
-
"packed",
|
|
24
|
-
"shipped",
|
|
25
|
-
"delivered",
|
|
26
|
-
"cancel",
|
|
27
|
-
" return",
|
|
28
|
-
"refund"
|
|
29
|
-
];
|
|
30
|
-
var DEFAULT_TOAST_CONFIG = {
|
|
31
|
-
position: "bottom-left",
|
|
32
|
-
autoClose: 3e3,
|
|
33
|
-
hideProgressBar: false,
|
|
34
|
-
closeOnClick: true,
|
|
35
|
-
theme: "light",
|
|
36
|
-
progressClassName: "bg-primary"
|
|
37
|
-
};
|
|
38
|
-
var ALLOWED_COUNTRIES = ["AE", "IN", "US"];
|
|
39
|
-
var ADDRESS_FORM_SESSION_KEY = "address_form_values";
|
|
40
|
-
var _onTokenChange = null;
|
|
41
|
-
function setAuthTokenChangeCallback(callback) {
|
|
42
|
-
_onTokenChange = callback;
|
|
43
|
-
}
|
|
44
|
-
var Auth = {
|
|
45
|
-
isAuthenticated: false,
|
|
46
|
-
getUserDetails() {
|
|
47
|
-
return typeof window === "undefined" ? false : getCookie(USER_CRED_TOKEN);
|
|
48
|
-
},
|
|
49
|
-
setUserDetails(data) {
|
|
50
|
-
setCookie(USER_CREDENTIALS, JSON.stringify(data), {
|
|
51
|
-
expires: 60,
|
|
52
|
-
path: "/"
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
setAccessToken(token) {
|
|
56
|
-
setCookie(USER_CRED_TOKEN, token, {
|
|
57
|
-
expires: 60,
|
|
58
|
-
path: "/"
|
|
59
|
-
});
|
|
60
|
-
_onTokenChange?.(token);
|
|
61
|
-
},
|
|
62
|
-
getAccessToken() {
|
|
63
|
-
return getCookie(USER_CRED_TOKEN);
|
|
64
|
-
},
|
|
65
|
-
setRefreshToken(token) {
|
|
66
|
-
setCookie(USER_CRED_REFRESH_TOKEN, token, {
|
|
67
|
-
expires: 60,
|
|
68
|
-
path: "/"
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
getRefreshToken() {
|
|
72
|
-
return getCookie(USER_CRED_REFRESH_TOKEN);
|
|
73
|
-
},
|
|
74
|
-
removeTokens() {
|
|
75
|
-
removeCookie(USER_CRED_TOKEN);
|
|
76
|
-
removeCookie(USER_CRED_REFRESH_TOKEN);
|
|
77
|
-
removeCookie(USER_CREDENTIALS);
|
|
78
|
-
_onTokenChange?.(void 0);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
var auth_default = Auth;
|
|
82
|
-
|
|
83
|
-
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, auth_default, pathNameMap, setAuthTokenChangeCallback };
|