@cimplify/sdk 0.17.0 → 0.19.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/advanced.d.mts +2 -2
- package/dist/advanced.d.ts +2 -2
- package/dist/advanced.js +21 -21
- package/dist/advanced.mjs +2 -2
- package/dist/{chunk-REPTMTQ4.js → chunk-6SRY4DPY.js} +65 -26
- package/dist/{chunk-GFKBH7R2.mjs → chunk-7ACYNCNM.mjs} +46 -7
- package/dist/{chunk-G6KNFYJD.mjs → chunk-AFEE43MQ.mjs} +2 -2
- package/dist/{chunk-OITG2SEN.js → chunk-B2RTVYJR.js} +35 -35
- package/dist/{chunk-OVM5YWM5.mjs → chunk-FTL2SXCG.mjs} +5 -5
- package/dist/{chunk-J65U5SED.js → chunk-RYQ5IPWX.js} +5 -5
- package/dist/{client-C59R79gx.d.ts → client-B3payjUV.d.mts} +23 -12
- package/dist/{client-BaolRdB4.d.mts → client-FNZzXO_v.d.ts} +23 -12
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +97 -97
- package/dist/index.mjs +3 -3
- package/dist/{payment-C6ULw3K-.d.mts → payment-CO2tRThu.d.mts} +76 -1
- package/dist/{payment-C6ULw3K-.d.ts → payment-CO2tRThu.d.ts} +76 -1
- package/dist/{price-Bd6JBV8W.d.ts → price-Bp6JlVzW.d.ts} +1 -1
- package/dist/{price-CbR6DCt0.d.mts → price-Dg7MJEsL.d.mts} +1 -1
- package/dist/react.d.mts +34 -7
- package/dist/react.d.ts +34 -7
- package/dist/react.js +228 -78
- package/dist/react.mjs +179 -29
- package/dist/styles.css +1 -1
- package/dist/utils.d.mts +5 -5
- package/dist/utils.d.ts +5 -5
- package/dist/utils.js +28 -28
- package/dist/utils.mjs +1 -1
- package/package.json +1 -1
- package/registry/catalogue-page.json +1 -1
package/dist/react.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
4
|
+
var chunkB2RTVYJR_js = require('./chunk-B2RTVYJR.js');
|
|
5
|
+
var chunk6SRY4DPY_js = require('./chunk-6SRY4DPY.js');
|
|
6
|
+
var chunkRYQ5IPWX_js = require('./chunk-RYQ5IPWX.js');
|
|
7
7
|
var React3 = require('react');
|
|
8
8
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
9
|
var numberField = require('@base-ui/react/number-field');
|
|
@@ -447,13 +447,13 @@ function buildLineKey(productId, options) {
|
|
|
447
447
|
return parts.join("|");
|
|
448
448
|
}
|
|
449
449
|
function calculateLineSubtotal(item) {
|
|
450
|
-
let unitPrice =
|
|
450
|
+
let unitPrice = chunkRYQ5IPWX_js.parsePrice(item.product.default_price);
|
|
451
451
|
if (item.variant?.price_adjustment) {
|
|
452
|
-
unitPrice +=
|
|
452
|
+
unitPrice += chunkRYQ5IPWX_js.parsePrice(item.variant.price_adjustment);
|
|
453
453
|
}
|
|
454
454
|
for (const option of item.addOnOptions || []) {
|
|
455
455
|
if (option.default_price) {
|
|
456
|
-
unitPrice +=
|
|
456
|
+
unitPrice += chunkRYQ5IPWX_js.parsePrice(option.default_price);
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
459
|
return roundMoney(unitPrice * item.quantity);
|
|
@@ -1011,7 +1011,7 @@ var DEFAULT_COUNTRY = "US";
|
|
|
1011
1011
|
function createDefaultClient() {
|
|
1012
1012
|
const processRef = globalThis.process;
|
|
1013
1013
|
const envPublicKey = processRef?.env?.NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY || "";
|
|
1014
|
-
return
|
|
1014
|
+
return chunkB2RTVYJR_js.createCimplifyClient({ publicKey: envPublicKey });
|
|
1015
1015
|
}
|
|
1016
1016
|
function getStoredLocationId() {
|
|
1017
1017
|
if (typeof window === "undefined" || !window.localStorage) {
|
|
@@ -1094,7 +1094,7 @@ function CimplifyProvider({
|
|
|
1094
1094
|
const setDisplayCurrency = React3.useCallback(
|
|
1095
1095
|
(currency) => {
|
|
1096
1096
|
const normalized = currency?.trim().toUpperCase() || null;
|
|
1097
|
-
if (normalized && !
|
|
1097
|
+
if (normalized && !chunkRYQ5IPWX_js.isSupportedCurrency(normalized)) {
|
|
1098
1098
|
return;
|
|
1099
1099
|
}
|
|
1100
1100
|
setDisplayCurrencyOverride(normalized);
|
|
@@ -1656,7 +1656,7 @@ function Price({ amount, className, prefix }) {
|
|
|
1656
1656
|
const { displayCurrency, convertPrice } = useCimplify();
|
|
1657
1657
|
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className, children: [
|
|
1658
1658
|
prefix,
|
|
1659
|
-
|
|
1659
|
+
chunkRYQ5IPWX_js.formatPrice(convertPrice(amount), displayCurrency)
|
|
1660
1660
|
] });
|
|
1661
1661
|
}
|
|
1662
1662
|
var productsCache = /* @__PURE__ */ new Map();
|
|
@@ -1666,7 +1666,6 @@ function buildProductsCacheKey(client, locationId, options) {
|
|
|
1666
1666
|
client.getPublicKey(),
|
|
1667
1667
|
locationId ?? "",
|
|
1668
1668
|
options.category ?? "",
|
|
1669
|
-
options.collection ?? "",
|
|
1670
1669
|
options.taxonomy ?? "",
|
|
1671
1670
|
options.search ?? "",
|
|
1672
1671
|
options.featured ?? "",
|
|
@@ -1677,7 +1676,8 @@ function buildProductsCacheKey(client, locationId, options) {
|
|
|
1677
1676
|
options.in_stock ?? "",
|
|
1678
1677
|
options.min_price ?? "",
|
|
1679
1678
|
options.max_price ?? "",
|
|
1680
|
-
options.page ?? ""
|
|
1679
|
+
options.page ?? "",
|
|
1680
|
+
options.properties ? JSON.stringify(options.properties) : ""
|
|
1681
1681
|
].join("|");
|
|
1682
1682
|
}
|
|
1683
1683
|
function useProducts(options = {}) {
|
|
@@ -1694,7 +1694,6 @@ function useProducts(options = {}) {
|
|
|
1694
1694
|
const queryOptions = React3.useMemo(
|
|
1695
1695
|
() => ({
|
|
1696
1696
|
category: options.category,
|
|
1697
|
-
collection: options.collection,
|
|
1698
1697
|
taxonomy: options.taxonomy,
|
|
1699
1698
|
search: options.search,
|
|
1700
1699
|
featured: options.featured,
|
|
@@ -1705,11 +1704,11 @@ function useProducts(options = {}) {
|
|
|
1705
1704
|
in_stock: options.in_stock,
|
|
1706
1705
|
min_price: options.min_price,
|
|
1707
1706
|
max_price: options.max_price,
|
|
1708
|
-
page: options.page
|
|
1707
|
+
page: options.page,
|
|
1708
|
+
properties: options.properties
|
|
1709
1709
|
}),
|
|
1710
1710
|
[
|
|
1711
1711
|
options.category,
|
|
1712
|
-
options.collection,
|
|
1713
1712
|
options.taxonomy,
|
|
1714
1713
|
options.search,
|
|
1715
1714
|
options.featured,
|
|
@@ -1720,7 +1719,8 @@ function useProducts(options = {}) {
|
|
|
1720
1719
|
options.in_stock,
|
|
1721
1720
|
options.min_price,
|
|
1722
1721
|
options.max_price,
|
|
1723
|
-
options.page
|
|
1722
|
+
options.page,
|
|
1723
|
+
options.properties
|
|
1724
1724
|
]
|
|
1725
1725
|
);
|
|
1726
1726
|
const cacheKey = React3.useMemo(
|
|
@@ -2421,6 +2421,7 @@ function useSearch(options = {}) {
|
|
|
2421
2421
|
const [error, setError] = React3.useState(null);
|
|
2422
2422
|
const requestIdRef = React3.useRef(0);
|
|
2423
2423
|
const timerRef = React3.useRef(null);
|
|
2424
|
+
const tagsSignature = options.tags?.join(",") ?? "";
|
|
2424
2425
|
React3.useEffect(() => {
|
|
2425
2426
|
if (timerRef.current) {
|
|
2426
2427
|
clearTimeout(timerRef.current);
|
|
@@ -2441,7 +2442,15 @@ function useSearch(options = {}) {
|
|
|
2441
2442
|
try {
|
|
2442
2443
|
const result = await client.catalogue.searchProducts(trimmedQuery, {
|
|
2443
2444
|
limit,
|
|
2444
|
-
category: options.category
|
|
2445
|
+
category: options.category,
|
|
2446
|
+
taxonomy: options.taxonomy,
|
|
2447
|
+
tags: options.tags,
|
|
2448
|
+
featured: options.featured,
|
|
2449
|
+
in_stock: options.in_stock,
|
|
2450
|
+
min_price: options.min_price,
|
|
2451
|
+
max_price: options.max_price,
|
|
2452
|
+
sort_by: options.sort_by,
|
|
2453
|
+
sort_order: options.sort_order
|
|
2445
2454
|
});
|
|
2446
2455
|
if (!result.ok) {
|
|
2447
2456
|
throw result.error;
|
|
@@ -2467,7 +2476,7 @@ function useSearch(options = {}) {
|
|
|
2467
2476
|
timerRef.current = null;
|
|
2468
2477
|
}
|
|
2469
2478
|
};
|
|
2470
|
-
}, [client, debounceMs, limit, minLength, options.category, query]);
|
|
2479
|
+
}, [client, debounceMs, limit, minLength, options.category, options.taxonomy, tagsSignature, options.featured, options.in_stock, options.min_price, options.max_price, options.sort_by, options.sort_order, query]);
|
|
2471
2480
|
const setQuery = React3.useCallback((nextQuery) => {
|
|
2472
2481
|
setQueryState(nextQuery);
|
|
2473
2482
|
}, []);
|
|
@@ -3490,16 +3499,16 @@ function useProductPrice(input) {
|
|
|
3490
3499
|
if (bundleTotalPrice != null) {
|
|
3491
3500
|
unitPrice = bundleTotalPrice;
|
|
3492
3501
|
} else if (compositePrice) {
|
|
3493
|
-
unitPrice =
|
|
3502
|
+
unitPrice = chunkRYQ5IPWX_js.parsePrice(compositePrice.final_price);
|
|
3494
3503
|
} else {
|
|
3495
|
-
unitPrice =
|
|
3504
|
+
unitPrice = chunkRYQ5IPWX_js.parsePrice(product.default_price);
|
|
3496
3505
|
if (variant?.price_adjustment) {
|
|
3497
|
-
unitPrice +=
|
|
3506
|
+
unitPrice += chunkRYQ5IPWX_js.parsePrice(variant.price_adjustment);
|
|
3498
3507
|
}
|
|
3499
3508
|
if (addOnOptions) {
|
|
3500
3509
|
for (const option of addOnOptions) {
|
|
3501
3510
|
if (option.default_price) {
|
|
3502
|
-
unitPrice +=
|
|
3511
|
+
unitPrice += chunkRYQ5IPWX_js.parsePrice(option.default_price);
|
|
3503
3512
|
}
|
|
3504
3513
|
}
|
|
3505
3514
|
}
|
|
@@ -4060,19 +4069,19 @@ function AuthElement({
|
|
|
4060
4069
|
}, [onReady, onAuthenticated, onRequiresOtp, onError]);
|
|
4061
4070
|
React3.useEffect(() => {
|
|
4062
4071
|
if (!elements || !containerRef.current) return;
|
|
4063
|
-
const element = elements.create(
|
|
4072
|
+
const element = elements.create(chunk6SRY4DPY_js.ELEMENT_TYPES.AUTH, { prefillEmail });
|
|
4064
4073
|
elementRef.current = element;
|
|
4065
|
-
element.on(
|
|
4074
|
+
element.on(chunk6SRY4DPY_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
4066
4075
|
element.on(
|
|
4067
|
-
|
|
4076
|
+
chunk6SRY4DPY_js.EVENT_TYPES.AUTHENTICATED,
|
|
4068
4077
|
(data) => onAuthenticatedRef.current?.(data)
|
|
4069
4078
|
);
|
|
4070
4079
|
element.on(
|
|
4071
|
-
|
|
4080
|
+
chunk6SRY4DPY_js.EVENT_TYPES.REQUIRES_OTP,
|
|
4072
4081
|
(data) => onRequiresOtpRef.current?.(data)
|
|
4073
4082
|
);
|
|
4074
4083
|
element.on(
|
|
4075
|
-
|
|
4084
|
+
chunk6SRY4DPY_js.EVENT_TYPES.ERROR,
|
|
4076
4085
|
(data) => onErrorRef.current?.(data)
|
|
4077
4086
|
);
|
|
4078
4087
|
element.mount(containerRef.current);
|
|
@@ -4101,15 +4110,15 @@ function AddressElement({
|
|
|
4101
4110
|
}, [onReady, onChange, onError]);
|
|
4102
4111
|
React3.useEffect(() => {
|
|
4103
4112
|
if (!elements || !containerRef.current) return;
|
|
4104
|
-
const element = elements.create(
|
|
4113
|
+
const element = elements.create(chunk6SRY4DPY_js.ELEMENT_TYPES.ADDRESS, { mode });
|
|
4105
4114
|
elementRef.current = element;
|
|
4106
|
-
element.on(
|
|
4115
|
+
element.on(chunk6SRY4DPY_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
4107
4116
|
element.on(
|
|
4108
|
-
|
|
4117
|
+
chunk6SRY4DPY_js.EVENT_TYPES.CHANGE,
|
|
4109
4118
|
(data) => onChangeRef.current?.(data)
|
|
4110
4119
|
);
|
|
4111
4120
|
element.on(
|
|
4112
|
-
|
|
4121
|
+
chunk6SRY4DPY_js.EVENT_TYPES.ERROR,
|
|
4113
4122
|
(data) => onErrorRef.current?.(data)
|
|
4114
4123
|
);
|
|
4115
4124
|
element.mount(containerRef.current);
|
|
@@ -4139,15 +4148,15 @@ function PaymentElement({
|
|
|
4139
4148
|
}, [onReady, onChange, onError]);
|
|
4140
4149
|
React3.useEffect(() => {
|
|
4141
4150
|
if (!elements || !containerRef.current) return;
|
|
4142
|
-
const element = elements.create(
|
|
4151
|
+
const element = elements.create(chunk6SRY4DPY_js.ELEMENT_TYPES.PAYMENT, { amount, currency });
|
|
4143
4152
|
elementRef.current = element;
|
|
4144
|
-
element.on(
|
|
4153
|
+
element.on(chunk6SRY4DPY_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
4145
4154
|
element.on(
|
|
4146
|
-
|
|
4155
|
+
chunk6SRY4DPY_js.EVENT_TYPES.CHANGE,
|
|
4147
4156
|
(data) => onChangeRef.current?.(data)
|
|
4148
4157
|
);
|
|
4149
4158
|
element.on(
|
|
4150
|
-
|
|
4159
|
+
chunk6SRY4DPY_js.EVENT_TYPES.ERROR,
|
|
4151
4160
|
(data) => onErrorRef.current?.(data)
|
|
4152
4161
|
);
|
|
4153
4162
|
element.mount(containerRef.current);
|
|
@@ -4306,7 +4315,7 @@ function VariantSelector({
|
|
|
4306
4315
|
if (!variants || variants.length <= 1) {
|
|
4307
4316
|
return null;
|
|
4308
4317
|
}
|
|
4309
|
-
basePrice != null ?
|
|
4318
|
+
basePrice != null ? chunkRYQ5IPWX_js.parsePrice(basePrice) : 0;
|
|
4310
4319
|
if (variantAxes && variantAxes.length > 0) {
|
|
4311
4320
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-variant-selector": true, className: cn("space-y-5", className, classNames?.root), children: variantAxes.map((axis) => {
|
|
4312
4321
|
const labelId = `${idPrefix}-axis-${axis.id}`;
|
|
@@ -4382,7 +4391,7 @@ function VariantSelector({
|
|
|
4382
4391
|
className: cn("divide-y divide-border", classNames?.list),
|
|
4383
4392
|
children: variants.map((variant) => {
|
|
4384
4393
|
const isSelected = selectedVariantId === variant.id;
|
|
4385
|
-
const adjustment =
|
|
4394
|
+
const adjustment = chunkRYQ5IPWX_js.parsePrice(variant.price_adjustment);
|
|
4386
4395
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4387
4396
|
radio.Radio.Root,
|
|
4388
4397
|
{
|
|
@@ -4410,7 +4419,7 @@ function VariantSelector({
|
|
|
4410
4419
|
{
|
|
4411
4420
|
"data-cimplify-variant-name": true,
|
|
4412
4421
|
className: cn("flex-1 min-w-0 text-sm", classNames?.name),
|
|
4413
|
-
children:
|
|
4422
|
+
children: chunkB2RTVYJR_js.getVariantDisplayName(variant, productName)
|
|
4414
4423
|
}
|
|
4415
4424
|
),
|
|
4416
4425
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-variant-pricing": true, className: cn("text-sm text-muted-foreground", classNames?.pricing), children: [
|
|
@@ -4648,16 +4657,16 @@ function BundleSelector({
|
|
|
4648
4657
|
}, [components, selections, onReady]);
|
|
4649
4658
|
const totalPrice = React3.useMemo(() => {
|
|
4650
4659
|
if (pricingType === "fixed" && bundlePrice) {
|
|
4651
|
-
return
|
|
4660
|
+
return chunkRYQ5IPWX_js.parsePrice(bundlePrice);
|
|
4652
4661
|
}
|
|
4653
4662
|
const componentsTotal = components.reduce((sum, comp) => {
|
|
4654
4663
|
return sum + getComponentPrice(comp, variantChoices[comp.id]) * comp.quantity;
|
|
4655
4664
|
}, 0);
|
|
4656
4665
|
if (pricingType === "percentage_discount" && discountValue) {
|
|
4657
|
-
return componentsTotal * (1 -
|
|
4666
|
+
return componentsTotal * (1 - chunkRYQ5IPWX_js.parsePrice(discountValue) / 100);
|
|
4658
4667
|
}
|
|
4659
4668
|
if (pricingType === "fixed_discount" && discountValue) {
|
|
4660
|
-
return componentsTotal -
|
|
4669
|
+
return componentsTotal - chunkRYQ5IPWX_js.parsePrice(discountValue);
|
|
4661
4670
|
}
|
|
4662
4671
|
return componentsTotal;
|
|
4663
4672
|
}, [components, variantChoices, pricingType, bundlePrice, discountValue]);
|
|
@@ -4718,15 +4727,15 @@ function BundleSelector({
|
|
|
4718
4727
|
}
|
|
4719
4728
|
function getComponentPrice(component, selectedVariantId) {
|
|
4720
4729
|
if (!selectedVariantId || component.available_variants.length === 0) {
|
|
4721
|
-
return
|
|
4730
|
+
return chunkRYQ5IPWX_js.parsePrice(component.effective_price);
|
|
4722
4731
|
}
|
|
4723
4732
|
if (selectedVariantId === component.variant_id) {
|
|
4724
|
-
return
|
|
4733
|
+
return chunkRYQ5IPWX_js.parsePrice(component.effective_price);
|
|
4725
4734
|
}
|
|
4726
4735
|
const bakedAdj = component.variant_id ? component.available_variants.find((v) => v.id === component.variant_id) : void 0;
|
|
4727
4736
|
const selectedAdj = component.available_variants.find((v) => v.id === selectedVariantId);
|
|
4728
|
-
if (!selectedAdj) return
|
|
4729
|
-
return
|
|
4737
|
+
if (!selectedAdj) return chunkRYQ5IPWX_js.parsePrice(component.effective_price);
|
|
4738
|
+
return chunkRYQ5IPWX_js.parsePrice(component.effective_price) - chunkRYQ5IPWX_js.parsePrice(bakedAdj?.price_adjustment ?? "0") + chunkRYQ5IPWX_js.parsePrice(selectedAdj.price_adjustment);
|
|
4730
4739
|
}
|
|
4731
4740
|
function BundleComponentCard({
|
|
4732
4741
|
component,
|
|
@@ -4791,7 +4800,7 @@ function BundleComponentCard({
|
|
|
4791
4800
|
className: cn("mt-3 divide-y divide-border", classNames?.variantPicker),
|
|
4792
4801
|
children: component.available_variants.map((variant) => {
|
|
4793
4802
|
const isSelected = selectedVariantId === variant.id;
|
|
4794
|
-
const adjustment =
|
|
4803
|
+
const adjustment = chunkRYQ5IPWX_js.parsePrice(variant.price_adjustment);
|
|
4795
4804
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4796
4805
|
radio.Radio.Root,
|
|
4797
4806
|
{
|
|
@@ -5204,7 +5213,7 @@ function CompositeSelector({
|
|
|
5204
5213
|
"data-cimplify-composite-summary": true,
|
|
5205
5214
|
className: cn("border-t border-border pt-4 space-y-1 text-sm", classNames?.summary),
|
|
5206
5215
|
children: [
|
|
5207
|
-
|
|
5216
|
+
chunkRYQ5IPWX_js.parsePrice(priceResult.base_price) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5208
5217
|
"div",
|
|
5209
5218
|
{
|
|
5210
5219
|
"data-cimplify-composite-summary-line": true,
|
|
@@ -5215,7 +5224,7 @@ function CompositeSelector({
|
|
|
5215
5224
|
]
|
|
5216
5225
|
}
|
|
5217
5226
|
),
|
|
5218
|
-
|
|
5227
|
+
chunkRYQ5IPWX_js.parsePrice(priceResult.components_total) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5219
5228
|
"div",
|
|
5220
5229
|
{
|
|
5221
5230
|
"data-cimplify-composite-summary-line": true,
|
|
@@ -5315,18 +5324,18 @@ function ProductCustomizer({
|
|
|
5315
5324
|
}, [selectedAddOnOptionIds]);
|
|
5316
5325
|
const localTotalPrice = React3.useMemo(() => {
|
|
5317
5326
|
if (isComposite && compositePrice) {
|
|
5318
|
-
return
|
|
5327
|
+
return chunkRYQ5IPWX_js.parsePrice(compositePrice.final_price) * quantity;
|
|
5319
5328
|
}
|
|
5320
5329
|
if (isBundle && bundleTotalPrice != null) {
|
|
5321
5330
|
return bundleTotalPrice * quantity;
|
|
5322
5331
|
}
|
|
5323
|
-
let price =
|
|
5332
|
+
let price = chunkRYQ5IPWX_js.parsePrice(product.default_price);
|
|
5324
5333
|
if (selectedVariant?.price_adjustment) {
|
|
5325
|
-
price +=
|
|
5334
|
+
price += chunkRYQ5IPWX_js.parsePrice(selectedVariant.price_adjustment);
|
|
5326
5335
|
}
|
|
5327
5336
|
for (const option of selectedAddOnOptions) {
|
|
5328
5337
|
if (option.default_price) {
|
|
5329
|
-
price +=
|
|
5338
|
+
price += chunkRYQ5IPWX_js.parsePrice(option.default_price);
|
|
5330
5339
|
}
|
|
5331
5340
|
}
|
|
5332
5341
|
return price * quantity;
|
|
@@ -5367,7 +5376,7 @@ function ProductCustomizer({
|
|
|
5367
5376
|
const priceInfo = quote.quoted_total_price_info ?? quote.final_price_info;
|
|
5368
5377
|
const perUnit = priceInfo.pre_tax_price;
|
|
5369
5378
|
if (perUnit === void 0 || perUnit === null) return void 0;
|
|
5370
|
-
return
|
|
5379
|
+
return chunkRYQ5IPWX_js.parsePrice(perUnit) * quantity;
|
|
5371
5380
|
}, [quote, quantity]);
|
|
5372
5381
|
const displayTotalPrice = quotedTotalPrice ?? localTotalPrice;
|
|
5373
5382
|
const handleVariantChange = React3.useCallback(
|
|
@@ -5599,7 +5608,7 @@ function CartLineItemRow({
|
|
|
5599
5608
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item": true, children: [
|
|
5600
5609
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item-info": true, children: [
|
|
5601
5610
|
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-name": true, children: item.product.name }),
|
|
5602
|
-
item.variant && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-variant": true, children:
|
|
5611
|
+
item.variant && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-variant": true, children: chunkB2RTVYJR_js.getVariantDisplayName(item.variant, item.product.name) }),
|
|
5603
5612
|
item.addOnOptions && item.addOnOptions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-cart-item-addons": true, children: [
|
|
5604
5613
|
"+ ",
|
|
5605
5614
|
item.addOnOptions.map((opt) => opt.name).join(", ")
|
|
@@ -5740,16 +5749,16 @@ function SaleBadge({
|
|
|
5740
5749
|
className,
|
|
5741
5750
|
classNames
|
|
5742
5751
|
}) {
|
|
5743
|
-
const onSale =
|
|
5752
|
+
const onSale = chunkRYQ5IPWX_js.isOnSale(product);
|
|
5744
5753
|
const hasDeal = dealInfo !== void 0;
|
|
5745
5754
|
if (!hasDeal && !onSale && !label) {
|
|
5746
5755
|
return null;
|
|
5747
5756
|
}
|
|
5748
5757
|
let percentage = null;
|
|
5749
5758
|
if (hasDeal && dealInfo.benefit_type === "percentage") {
|
|
5750
|
-
percentage =
|
|
5759
|
+
percentage = chunkRYQ5IPWX_js.parsePrice(dealInfo.value);
|
|
5751
5760
|
} else if (onSale) {
|
|
5752
|
-
percentage =
|
|
5761
|
+
percentage = chunkRYQ5IPWX_js.getDiscountPercentage(product);
|
|
5753
5762
|
}
|
|
5754
5763
|
const badgeText = label ?? dealInfo?.label ?? (percentage != null && percentage > 0 ? `${percentage}% off` : null);
|
|
5755
5764
|
if (!badgeText) {
|
|
@@ -5768,7 +5777,7 @@ function SaleBadge({
|
|
|
5768
5777
|
"%"
|
|
5769
5778
|
] }),
|
|
5770
5779
|
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-sale-label": true, className: classNames?.label, children: badgeText }),
|
|
5771
|
-
showOriginalPrice && onSale && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-sale-original-price": true, className: classNames?.originalPrice, children: /* @__PURE__ */ jsxRuntime.jsx(Price, { amount:
|
|
5780
|
+
showOriginalPrice && onSale && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-sale-original-price": true, className: classNames?.originalPrice, children: /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: chunkRYQ5IPWX_js.getBasePrice(product) }) })
|
|
5772
5781
|
]
|
|
5773
5782
|
}
|
|
5774
5783
|
);
|
|
@@ -6667,15 +6676,15 @@ function OrderSummary({
|
|
|
6667
6676
|
] }, item.id)
|
|
6668
6677
|
) }),
|
|
6669
6678
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-totals": true, className: classNames?.totals, children: [
|
|
6670
|
-
order.total_discount != null &&
|
|
6679
|
+
order.total_discount != null && chunkRYQ5IPWX_js.parsePrice(order.total_discount) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-discount": true, children: [
|
|
6671
6680
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Discount" }),
|
|
6672
6681
|
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: order.total_discount, prefix: "-" })
|
|
6673
6682
|
] }),
|
|
6674
|
-
order.service_charge != null &&
|
|
6683
|
+
order.service_charge != null && chunkRYQ5IPWX_js.parsePrice(order.service_charge) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-service-charge": true, children: [
|
|
6675
6684
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Service charge" }),
|
|
6676
6685
|
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: order.service_charge })
|
|
6677
6686
|
] }),
|
|
6678
|
-
order.tax != null &&
|
|
6687
|
+
order.tax != null && chunkRYQ5IPWX_js.parsePrice(order.tax) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-tax": true, children: [
|
|
6679
6688
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Tax" }),
|
|
6680
6689
|
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: order.tax })
|
|
6681
6690
|
] }),
|
|
@@ -7550,6 +7559,13 @@ function CataloguePage({
|
|
|
7550
7559
|
categories: categoriesProp,
|
|
7551
7560
|
showFilter = true,
|
|
7552
7561
|
showSearch = true,
|
|
7562
|
+
showSort = false,
|
|
7563
|
+
showInStockFilter = false,
|
|
7564
|
+
showPriceRange = false,
|
|
7565
|
+
showTagsFilter = false,
|
|
7566
|
+
availableTags,
|
|
7567
|
+
defaultSort,
|
|
7568
|
+
pageSize,
|
|
7553
7569
|
onProductClick,
|
|
7554
7570
|
onCategoryClick,
|
|
7555
7571
|
renderCard,
|
|
@@ -7560,30 +7576,36 @@ function CataloguePage({
|
|
|
7560
7576
|
}) {
|
|
7561
7577
|
const [selectedCategoryId, setSelectedCategoryId] = React3.useState(null);
|
|
7562
7578
|
const [searchQuery, setSearchQuery] = React3.useState("");
|
|
7563
|
-
const
|
|
7564
|
-
|
|
7579
|
+
const [sortBy, setSortBy] = React3.useState(defaultSort?.by ?? "name");
|
|
7580
|
+
const [sortOrder, setSortOrder] = React3.useState(defaultSort?.order ?? "asc");
|
|
7581
|
+
const [inStockOnly, setInStockOnly] = React3.useState(false);
|
|
7582
|
+
const [selectedTags, setSelectedTags] = React3.useState([]);
|
|
7583
|
+
const [minPrice, setMinPrice] = React3.useState("");
|
|
7584
|
+
const [maxPrice, setMaxPrice] = React3.useState("");
|
|
7585
|
+
const [page, setPage] = React3.useState(1);
|
|
7586
|
+
const debouncedSearch = useDebounce(searchQuery, 300);
|
|
7587
|
+
const { products: fetchedProducts, isLoading: productsLoading, pagination } = useProducts({
|
|
7588
|
+
enabled: productsProp === void 0,
|
|
7589
|
+
category: selectedCategoryId ?? void 0,
|
|
7590
|
+
search: debouncedSearch.length >= 2 ? debouncedSearch : void 0,
|
|
7591
|
+
sort_by: sortBy,
|
|
7592
|
+
sort_order: sortOrder,
|
|
7593
|
+
in_stock: inStockOnly || void 0,
|
|
7594
|
+
tags: selectedTags.length > 0 ? selectedTags : void 0,
|
|
7595
|
+
min_price: minPrice ? parseFloat(minPrice) : void 0,
|
|
7596
|
+
max_price: maxPrice ? parseFloat(maxPrice) : void 0,
|
|
7597
|
+
page,
|
|
7598
|
+
limit: pageSize
|
|
7565
7599
|
});
|
|
7566
7600
|
const { categories: fetchedCategories } = useCategories({
|
|
7567
7601
|
enabled: showFilter && categoriesProp === void 0
|
|
7568
7602
|
});
|
|
7569
7603
|
const allProducts = productsProp ?? fetchedProducts;
|
|
7570
7604
|
const categories = categoriesProp ?? fetchedCategories;
|
|
7571
|
-
const filteredProducts = React3.useMemo(() => {
|
|
7572
|
-
let result = allProducts;
|
|
7573
|
-
if (selectedCategoryId) {
|
|
7574
|
-
result = result.filter((p) => p.category_id === selectedCategoryId);
|
|
7575
|
-
}
|
|
7576
|
-
if (searchQuery.trim().length >= 2) {
|
|
7577
|
-
const q = searchQuery.trim().toLowerCase();
|
|
7578
|
-
result = result.filter(
|
|
7579
|
-
(p) => p.name.toLowerCase().includes(q) || p.description?.toLowerCase().includes(q)
|
|
7580
|
-
);
|
|
7581
|
-
}
|
|
7582
|
-
return result;
|
|
7583
|
-
}, [allProducts, selectedCategoryId, searchQuery]);
|
|
7584
7605
|
const handleCategorySelect = React3.useCallback(
|
|
7585
7606
|
(id) => {
|
|
7586
7607
|
setSelectedCategoryId(id);
|
|
7608
|
+
setPage(1);
|
|
7587
7609
|
if (id) {
|
|
7588
7610
|
const cat = categories.find((c) => c.id === id);
|
|
7589
7611
|
if (cat) onCategoryClick?.(cat);
|
|
@@ -7591,6 +7613,13 @@ function CataloguePage({
|
|
|
7591
7613
|
},
|
|
7592
7614
|
[categories, onCategoryClick]
|
|
7593
7615
|
);
|
|
7616
|
+
const handleTagToggle = React3.useCallback((tag) => {
|
|
7617
|
+
setSelectedTags(
|
|
7618
|
+
(prev) => prev.includes(tag) ? prev.filter((t) => t !== tag) : [...prev, tag]
|
|
7619
|
+
);
|
|
7620
|
+
setPage(1);
|
|
7621
|
+
}, []);
|
|
7622
|
+
const totalPages = pagination?.total_pages ?? 1;
|
|
7594
7623
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-catalogue-page": true, className: cn(className, classNames?.root), children: [
|
|
7595
7624
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-catalogue-header": true, className: classNames?.header, children: [
|
|
7596
7625
|
/* @__PURE__ */ jsxRuntime.jsx("h1", { "data-cimplify-catalogue-title": true, className: classNames?.title, children: title }),
|
|
@@ -7609,6 +7638,92 @@ function CataloguePage({
|
|
|
7609
7638
|
onSelect: handleCategorySelect
|
|
7610
7639
|
}
|
|
7611
7640
|
) }),
|
|
7641
|
+
(showSort || showInStockFilter || showPriceRange || showTagsFilter) && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-catalogue-toolbar": true, className: cn("flex flex-wrap items-center gap-3", classNames?.toolbar), children: [
|
|
7642
|
+
showSort && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7643
|
+
"select",
|
|
7644
|
+
{
|
|
7645
|
+
"data-cimplify-sort": true,
|
|
7646
|
+
value: `${sortBy}:${sortOrder}`,
|
|
7647
|
+
onChange: (e) => {
|
|
7648
|
+
const [by, order] = e.target.value.split(":");
|
|
7649
|
+
setSortBy(by);
|
|
7650
|
+
setSortOrder(order);
|
|
7651
|
+
setPage(1);
|
|
7652
|
+
},
|
|
7653
|
+
className: "rounded-md border border-input bg-background px-3 py-1.5 text-sm",
|
|
7654
|
+
children: [
|
|
7655
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "name:asc", children: "Name A\u2013Z" }),
|
|
7656
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "name:desc", children: "Name Z\u2013A" }),
|
|
7657
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "price:asc", children: "Price: Low to High" }),
|
|
7658
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "price:desc", children: "Price: High to Low" }),
|
|
7659
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "created_at:desc", children: "Newest" }),
|
|
7660
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "created_at:asc", children: "Oldest" }),
|
|
7661
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "updated_at:desc", children: "Recently Updated" })
|
|
7662
|
+
]
|
|
7663
|
+
}
|
|
7664
|
+
),
|
|
7665
|
+
showInStockFilter && /* @__PURE__ */ jsxRuntime.jsxs("label", { "data-cimplify-stock-filter": true, className: "flex items-center gap-1.5 text-sm cursor-pointer", children: [
|
|
7666
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7667
|
+
"input",
|
|
7668
|
+
{
|
|
7669
|
+
type: "checkbox",
|
|
7670
|
+
checked: inStockOnly,
|
|
7671
|
+
onChange: (e) => {
|
|
7672
|
+
setInStockOnly(e.target.checked);
|
|
7673
|
+
setPage(1);
|
|
7674
|
+
},
|
|
7675
|
+
className: "accent-primary"
|
|
7676
|
+
}
|
|
7677
|
+
),
|
|
7678
|
+
"In stock only"
|
|
7679
|
+
] }),
|
|
7680
|
+
showPriceRange && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-price-range": true, className: "flex items-center gap-1.5", children: [
|
|
7681
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7682
|
+
"input",
|
|
7683
|
+
{
|
|
7684
|
+
type: "number",
|
|
7685
|
+
placeholder: "Min",
|
|
7686
|
+
value: minPrice,
|
|
7687
|
+
onChange: (e) => {
|
|
7688
|
+
setMinPrice(e.target.value);
|
|
7689
|
+
setPage(1);
|
|
7690
|
+
},
|
|
7691
|
+
className: "w-20 rounded-md border border-input bg-background px-2 py-1.5 text-sm",
|
|
7692
|
+
min: 0,
|
|
7693
|
+
step: "0.01"
|
|
7694
|
+
}
|
|
7695
|
+
),
|
|
7696
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "\u2013" }),
|
|
7697
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7698
|
+
"input",
|
|
7699
|
+
{
|
|
7700
|
+
type: "number",
|
|
7701
|
+
placeholder: "Max",
|
|
7702
|
+
value: maxPrice,
|
|
7703
|
+
onChange: (e) => {
|
|
7704
|
+
setMaxPrice(e.target.value);
|
|
7705
|
+
setPage(1);
|
|
7706
|
+
},
|
|
7707
|
+
className: "w-20 rounded-md border border-input bg-background px-2 py-1.5 text-sm",
|
|
7708
|
+
min: 0,
|
|
7709
|
+
step: "0.01"
|
|
7710
|
+
}
|
|
7711
|
+
)
|
|
7712
|
+
] }),
|
|
7713
|
+
showTagsFilter && availableTags && availableTags.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-tags-filter": true, className: "flex flex-wrap gap-1.5", children: availableTags.map((tag) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7714
|
+
"button",
|
|
7715
|
+
{
|
|
7716
|
+
type: "button",
|
|
7717
|
+
onClick: () => handleTagToggle(tag),
|
|
7718
|
+
className: cn(
|
|
7719
|
+
"rounded-full px-3 py-1 text-xs font-medium border transition-colors",
|
|
7720
|
+
selectedTags.includes(tag) ? "bg-primary text-primary-foreground border-primary" : "bg-background text-foreground border-input hover:bg-muted"
|
|
7721
|
+
),
|
|
7722
|
+
children: tag
|
|
7723
|
+
},
|
|
7724
|
+
tag
|
|
7725
|
+
)) })
|
|
7726
|
+
] }),
|
|
7612
7727
|
/* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-catalogue-grid": true, className: classNames?.gridContainer, children: productsLoading && !productsProp ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
7613
7728
|
"div",
|
|
7614
7729
|
{
|
|
@@ -7619,15 +7734,50 @@ function CataloguePage({
|
|
|
7619
7734
|
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
7620
7735
|
ProductGrid,
|
|
7621
7736
|
{
|
|
7622
|
-
products:
|
|
7737
|
+
products: allProducts,
|
|
7623
7738
|
renderCard,
|
|
7624
7739
|
renderImage,
|
|
7625
7740
|
columns,
|
|
7626
7741
|
emptyMessage: "No products found"
|
|
7627
7742
|
}
|
|
7628
|
-
) })
|
|
7743
|
+
) }),
|
|
7744
|
+
totalPages > 1 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-catalogue-pagination": true, className: cn("flex items-center justify-center gap-2 pt-6", classNames?.pagination), children: [
|
|
7745
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7746
|
+
"button",
|
|
7747
|
+
{
|
|
7748
|
+
type: "button",
|
|
7749
|
+
disabled: page <= 1,
|
|
7750
|
+
onClick: () => setPage((p) => Math.max(1, p - 1)),
|
|
7751
|
+
className: "rounded-md border border-input bg-background px-3 py-1.5 text-sm disabled:opacity-40",
|
|
7752
|
+
children: "Previous"
|
|
7753
|
+
}
|
|
7754
|
+
),
|
|
7755
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm text-muted-foreground tabular-nums", children: [
|
|
7756
|
+
page,
|
|
7757
|
+
" / ",
|
|
7758
|
+
totalPages
|
|
7759
|
+
] }),
|
|
7760
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7761
|
+
"button",
|
|
7762
|
+
{
|
|
7763
|
+
type: "button",
|
|
7764
|
+
disabled: page >= totalPages,
|
|
7765
|
+
onClick: () => setPage((p) => p + 1),
|
|
7766
|
+
className: "rounded-md border border-input bg-background px-3 py-1.5 text-sm disabled:opacity-40",
|
|
7767
|
+
children: "Next"
|
|
7768
|
+
}
|
|
7769
|
+
)
|
|
7770
|
+
] })
|
|
7629
7771
|
] });
|
|
7630
7772
|
}
|
|
7773
|
+
function useDebounce(value, delay) {
|
|
7774
|
+
const [debounced, setDebounced] = React3__default.default.useState(value);
|
|
7775
|
+
React3__default.default.useEffect(() => {
|
|
7776
|
+
const timer = setTimeout(() => setDebounced(value), delay);
|
|
7777
|
+
return () => clearTimeout(timer);
|
|
7778
|
+
}, [value, delay]);
|
|
7779
|
+
return debounced;
|
|
7780
|
+
}
|
|
7631
7781
|
function ProductPage({
|
|
7632
7782
|
productId,
|
|
7633
7783
|
product: productProp,
|
|
@@ -8320,7 +8470,7 @@ function BookingsPage({
|
|
|
8320
8470
|
|
|
8321
8471
|
Object.defineProperty(exports, "getVariantDisplayName", {
|
|
8322
8472
|
enumerable: true,
|
|
8323
|
-
get: function () { return
|
|
8473
|
+
get: function () { return chunkB2RTVYJR_js.getVariantDisplayName; }
|
|
8324
8474
|
});
|
|
8325
8475
|
exports.Ad = Ad;
|
|
8326
8476
|
exports.AdProvider = AdProvider;
|