@nextblock-cms/ecom 0.19.0 → 0.19.2
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/index.cjs.js +1 -1
- package/index.es.js +26 -25
- package/lib/CurrencyProvider.cjs.js +1 -1
- package/lib/CurrencyProvider.es.js +41 -45
- package/lib/PaymentReadinessProvider.cjs.js +1 -1
- package/lib/PaymentReadinessProvider.es.js +15 -19
- package/lib/cart-store.cjs.js +1 -1
- package/lib/cart-store.d.ts +4 -0
- package/lib/cart-store.es.js +77 -69
- package/lib/components/AccountNavigationMenu.cjs.js +1 -1
- package/lib/components/AccountNavigationMenu.es.js +44 -62
- package/lib/components/AddToCartButton.cjs.js +1 -1
- package/lib/components/AddToCartButton.es.js +50 -78
- package/lib/components/Cart.cjs.js +1 -1
- package/lib/components/Cart.es.js +154 -381
- package/lib/components/CartDrawer.cjs.js +1 -1
- package/lib/components/CartDrawer.es.js +143 -297
- package/lib/components/CartIcon.cjs.js +1 -1
- package/lib/components/CartIcon.es.js +21 -47
- package/lib/components/Checkout.cjs.js +1 -1
- package/lib/components/Checkout.es.js +814 -1614
- package/lib/components/CouponForm.cjs.js +1 -1
- package/lib/components/CouponForm.es.js +104 -155
- package/lib/components/CurrencySwitcher.cjs.js +1 -1
- package/lib/components/CurrencySwitcher.es.js +14 -33
- package/lib/components/CustomerProfileForm.cjs.js +1 -1
- package/lib/components/CustomerProfileForm.es.js +264 -672
- package/lib/components/FeaturedProduct.cjs.js +1 -1
- package/lib/components/FeaturedProduct.es.js +46 -125
- package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
- package/lib/components/FreemiusLicensePanel.es.js +45 -125
- package/lib/components/InvoiceDocument.cjs.js +1 -1
- package/lib/components/InvoiceDocument.es.js +148 -487
- package/lib/components/InvoiceViewerShell.cjs.js +2 -2
- package/lib/components/InvoiceViewerShell.d.ts +4 -1
- package/lib/components/InvoiceViewerShell.es.js +59 -142
- package/lib/components/ProductCard.cjs.js +1 -1
- package/lib/components/ProductCard.d.ts +3 -1
- package/lib/components/ProductCard.es.js +128 -242
- package/lib/components/ProductDetailsLayout.cjs.js +1 -1
- package/lib/components/ProductDetailsLayout.es.js +311 -652
- package/lib/components/ProductGallery.cjs.js +1 -1
- package/lib/components/ProductGallery.d.ts +2 -0
- package/lib/components/ProductGallery.es.js +37 -66
- package/lib/components/ProductGrid.cjs.js +1 -1
- package/lib/components/ProductGrid.es.js +23 -32
- package/lib/components/ShippingEstimator.cjs.js +1 -1
- package/lib/components/ShippingEstimator.es.js +118 -231
- package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
- package/lib/components/SimpleTiptapRenderer.es.js +111 -294
- package/lib/components/SubscriptionSelector.cjs.js +1 -1
- package/lib/components/SubscriptionSelector.es.js +120 -181
- package/lib/invoice.cjs.js +1 -1
- package/lib/invoice.d.ts +1 -1
- package/lib/invoice.es.js +6 -5
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +115 -375
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
- package/lib/pages/cms/coupons/CouponsPage.es.js +116 -368
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +26 -62
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.es.js +35 -71
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +72 -167
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +87 -247
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.es.js +95 -283
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.es.js +9 -21
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.es.js +46 -106
- package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrdersPage.es.js +78 -257
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsClient.es.js +192 -580
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsPage.es.js +14 -22
- package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
- package/lib/pages/cms/products/ProductsPage.es.js +47 -87
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +97 -177
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +40 -84
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +192 -455
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +28 -72
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +183 -490
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +69 -177
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +102 -213
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +25 -45
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +58 -202
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +89 -235
- package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductForm.es.js +526 -1110
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +63 -154
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +213 -544
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +91 -207
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +16 -28
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +25 -37
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.es.js +261 -492
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +12 -32
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +145 -365
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/new/NewProductPage.es.js +30 -42
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
- package/lib/pages/cms/shipping/ShippingPage.es.js +155 -507
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/RateForm.es.js +334 -717
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +158 -392
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
- package/lib/pages/cms/taxes/TaxesPage.es.js +119 -447
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +52 -156
- package/lib/product-context.cjs.js +1 -1
- package/lib/product-context.es.js +10 -14
- package/lib/trials.cjs.js +1 -1
- package/lib/trials.d.ts +10 -3
- package/lib/trials.es.js +28 -21
- package/lib/types.d.ts +2 -0
- package/lib/use-price-formatter.cjs.js +1 -0
- package/lib/use-price-formatter.d.ts +11 -0
- package/lib/use-price-formatter.es.js +13 -0
- package/lib/variation-utils.cjs.js +1 -1
- package/lib/variation-utils.d.ts +10 -0
- package/lib/variation-utils.es.js +139 -123
- package/package.json +4 -4
package/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./lib/components/CartDrawer.cjs.js"),g=require("./lib/components/Cart.cjs.js"),v=require("./lib/components/Checkout.cjs.js"),S=require("./lib/components/CartIcon.cjs.js"),b=require("./lib/components/CouponForm.cjs.js"),T=require("./lib/components/CurrencySwitcher.cjs.js"),p=require("./lib/components/AddToCartButton.cjs.js"),I=require("./lib/components/ProductCard.cjs.js"),D=require("./lib/components/ProductGrid.cjs.js"),R=require("./lib/components/ProductGallery.cjs.js"),_=require("./lib/components/FeaturedProduct.cjs.js"),q=require("./lib/components/CustomerProfileForm.cjs.js"),F=require("./lib/components/SubscriptionSelector.cjs.js"),A=require("./lib/components/InvoiceDocument.cjs.js"),E=require("./lib/components/InvoiceViewerShell.cjs.js"),L=require("./lib/components/FreemiusLicensePanel.cjs.js"),O=require("./lib/components/AccountNavigationMenu.cjs.js"),d=require("./lib/components/SimpleTiptapRenderer.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./lib/components/CartDrawer.cjs.js"),g=require("./lib/components/Cart.cjs.js"),v=require("./lib/components/Checkout.cjs.js"),S=require("./lib/components/CartIcon.cjs.js"),b=require("./lib/components/CouponForm.cjs.js"),T=require("./lib/components/CurrencySwitcher.cjs.js"),p=require("./lib/components/AddToCartButton.cjs.js"),I=require("./lib/components/ProductCard.cjs.js"),D=require("./lib/components/ProductGrid.cjs.js"),R=require("./lib/components/ProductGallery.cjs.js"),_=require("./lib/components/FeaturedProduct.cjs.js"),q=require("./lib/components/CustomerProfileForm.cjs.js"),F=require("./lib/components/SubscriptionSelector.cjs.js"),A=require("./lib/components/InvoiceDocument.cjs.js"),E=require("./lib/components/InvoiceViewerShell.cjs.js"),L=require("./lib/components/FreemiusLicensePanel.cjs.js"),O=require("./lib/components/AccountNavigationMenu.cjs.js"),d=require("./lib/components/SimpleTiptapRenderer.cjs.js"),V=require("./lib/pages/cms/products/components/ProductForm.cjs.js"),f=require("./lib/pages/cms/products/components/ProductCategorySelector.cjs.js"),u=require("./lib/cart-store.cjs.js"),s=require("./lib/coupons.cjs.js"),m=require("./lib/CurrencyProvider.cjs.js"),l=require("./lib/PaymentReadinessProvider.cjs.js"),e=require("./lib/currency.cjs.js"),h=require("./lib/currency-store.cjs.js"),C=require("./lib/use-cart.cjs.js"),a=require("./lib/customer.cjs.js"),i=require("./lib/types.cjs.js"),n=require("./lib/trials.cjs.js"),t=require("./lib/order-tax-details.cjs.js"),o=require("./lib/invoice.cjs.js"),c=require("./lib/invoice-ui.cjs.js"),z=require("./lib/product-schema.cjs.js"),P=require("./lib/product-context.cjs.js"),N=require("./lib/components/ProductDetailsLayout.cjs.js"),r=require("./lib/variation-utils.cjs.js");exports.CartDrawer=y.CartDrawer;exports.Cart=g.Cart;exports.Checkout=v.Checkout;exports.CartIcon=S.CartIcon;exports.CouponForm=b.CouponForm;exports.CurrencySwitcher=T.CurrencySwitcher;exports.AddToCartButton=p.AddToCartButton;exports.ProductCard=I.ProductCard;exports.ProductGrid=D.ProductGrid;exports.ProductGallery=R.ProductGallery;exports.FeaturedProduct=_.FeaturedProduct;exports.CustomerProfileForm=q.CustomerProfileForm;exports.SubscriptionSelector=F.SubscriptionSelector;exports.InvoiceDocument=A.InvoiceDocument;exports.InvoiceViewerShell=E.InvoiceViewerShell;exports.FreemiusLicensePanel=L.FreemiusLicensePanel;exports.AccountNavigationMenu=O.AccountNavigationMenu;exports.SimpleTiptapRenderer=d.SimpleTiptapRenderer;exports.toNoCookieEmbedSrc=d.toNoCookieEmbedSrc;exports.ProductForm=V.ProductForm;exports.ProductCategorySelector=f.ProductCategorySelector;exports.getCartItemActivePrice=u.getCartItemActivePrice;exports.useCartStore=u.useCartStore;exports.useCartSubtotal=u.useCartSubtotal;exports.useCartTotalItems=u.useCartTotalItems;exports.emptyProviderDiscounts=s.emptyProviderDiscounts;exports.getCartLineCouponKey=s.getCartLineCouponKey;exports.normalizeCouponCode=s.normalizeCouponCode;exports.CurrencyProvider=m.CurrencyProvider;exports.useCurrency=m.useCurrency;exports.PaymentReadinessProvider=l.PaymentReadinessProvider;exports.useCanPurchase=l.useCanPurchase;exports.usePaymentReadiness=l.usePaymentReadiness;exports.CURRENCY_ROUNDING_MODES=e.CURRENCY_ROUNDING_MODES;exports.applyCurrencyRounding=e.applyCurrencyRounding;exports.convertMinorUnitAmount=e.convertMinorUnitAmount;exports.describeCurrencyRoundingRule=e.describeCurrencyRoundingRule;exports.getCurrencyLookup=e.getCurrencyLookup;exports.getDefaultCurrency=e.getDefaultCurrency;exports.getExchangeRateForCurrency=e.getExchangeRateForCurrency;exports.inferCurrencyCodeFromLocale=e.inferCurrencyCodeFromLocale;exports.isSaleWindowActive=e.isSaleWindowActive;exports.isScheduledPriceDue=e.isScheduledPriceDue;exports.normalizeCurrencyRecord=e.normalizeCurrencyRecord;exports.normalizeCurrencyRoundingMode=e.normalizeCurrencyRoundingMode;exports.normalizePriceMap=e.normalizePriceMap;exports.normalizeSalePriceMap=e.normalizeSalePriceMap;exports.resolveEffectivePriceForCurrency=e.resolveEffectivePriceForCurrency;exports.resolvePriceForCurrency=e.resolvePriceForCurrency;exports.resolvePriceRangeForCurrency=e.resolvePriceRangeForCurrency;exports.sortCurrencies=e.sortCurrencies;exports.useCurrencyPreferenceStore=h.useCurrencyPreferenceStore;exports.useCart=C.useCart;exports.useIsCartHydrated=C.useIsCartHydrated;exports.addressesMatch=a.addressesMatch;exports.emptyCustomerAddress=a.emptyCustomerAddress;exports.isCustomerAddressComplete=a.isCustomerAddressComplete;exports.normalizeCustomerAddress=a.normalizeCustomerAddress;exports.normalizeOrderCustomerDetails=a.normalizeOrderCustomerDetails;exports.DEFAULT_ENABLED_PAYMENT_PROVIDERS=i.DEFAULT_ENABLED_PAYMENT_PROVIDERS;exports.derivePaymentProviderFromProductType=i.derivePaymentProviderFromProductType;exports.getProductPaymentProvider=i.getProductPaymentProvider;exports.isDigitalItem=i.isDigitalItem;exports.isDigitalProduct=i.isDigitalProduct;exports.normalizeEnabledPaymentProviders=i.normalizeEnabledPaymentProviders;exports.getTrialCheckoutMode=n.getTrialCheckoutMode;exports.getTrialLabel=n.getTrialLabel;exports.getTrialPaymentRequirementLabel=n.getTrialPaymentRequirementLabel;exports.getTrialPeriodDays=n.getTrialPeriodDays;exports.getTrialSummary=n.getTrialSummary;exports.aggregateOrderTaxLines=t.aggregateOrderTaxLines;exports.buildOrderTaxDetailsFromCalculation=t.buildOrderTaxDetailsFromCalculation;exports.buildOrderTaxDetailsFromStripeSession=t.buildOrderTaxDetailsFromStripeSession;exports.getOrderTaxRateJurisdiction=t.getOrderTaxRateJurisdiction;exports.getOrderTaxRateLabel=t.getOrderTaxRateLabel;exports.getOrderTaxRatePercentage=t.getOrderTaxRatePercentage;exports.normalizeOrderTaxDetails=t.normalizeOrderTaxDetails;exports.DEFAULT_INVOICE_SETTINGS=o.DEFAULT_INVOICE_SETTINGS;exports.INVOICE_SETTINGS_KEY=o.INVOICE_SETTINGS_KEY;exports.formatInvoiceCurrency=o.formatInvoiceCurrency;exports.formatInvoiceDate=o.formatInvoiceDate;exports.getInvoiceAddressLines=o.getInvoiceAddressLines;exports.normalizeInvoiceSettings=o.normalizeInvoiceSettings;exports.serializeInvoiceSettings=o.serializeInvoiceSettings;exports.buildInvoiceDocumentLabels=c.buildInvoiceDocumentLabels;exports.getInvoiceLocale=c.getInvoiceLocale;exports.localizeInvoicePresentationData=c.localizeInvoicePresentationData;exports.translateOrFallback=c.translateOrFallback;exports.translateOrderStatus=c.translateOrderStatus;exports.productSchema=z.productSchema;exports.ProductProvider=P.ProductProvider;exports.useProduct=P.useProduct;exports.ProductDetailsLayout=N.ProductDetailsLayout;exports.applyVariantSelection=r.applyVariantSelection;exports.buildCombinationKey=r.buildCombinationKey;exports.buildVariantLabel=r.buildVariantLabel;exports.chooseInitialVariantSelections=r.chooseInitialVariantSelections;exports.extractSelectedTermsByAttribute=r.extractSelectedTermsByAttribute;exports.findMatchingVariant=r.findMatchingVariant;exports.generateVariantDrafts=r.generateVariantDrafts;exports.getAvailableTermIdsForAttribute=r.getAvailableTermIdsForAttribute;exports.getVariantEffectivePriceRange=r.getVariantEffectivePriceRange;exports.mapRawVariantRelations=r.mapRawVariantRelations;exports.normalizeSelectionsToAvailableVariants=r.normalizeSelectionsToAvailableVariants;exports.resolveAttributeName=r.resolveAttributeName;exports.resolveTermValue=r.resolveTermValue;exports.resolveTranslatedText=r.resolveTranslatedText;
|
package/index.es.js
CHANGED
|
@@ -2,7 +2,7 @@ import { CartDrawer as o } from "./lib/components/CartDrawer.es.js";
|
|
|
2
2
|
import { Cart as a } from "./lib/components/Cart.es.js";
|
|
3
3
|
import { Checkout as n } from "./lib/components/Checkout.es.js";
|
|
4
4
|
import { CartIcon as c } from "./lib/components/CartIcon.es.js";
|
|
5
|
-
import { CouponForm as
|
|
5
|
+
import { CouponForm as l } from "./lib/components/CouponForm.es.js";
|
|
6
6
|
import { CurrencySwitcher as d } from "./lib/components/CurrencySwitcher.es.js";
|
|
7
7
|
import { AddToCartButton as C } from "./lib/components/AddToCartButton.es.js";
|
|
8
8
|
import { ProductCard as x } from "./lib/components/ProductCard.es.js";
|
|
@@ -14,7 +14,7 @@ import { SubscriptionSelector as R } from "./lib/components/SubscriptionSelector
|
|
|
14
14
|
import { InvoiceDocument as E } from "./lib/components/InvoiceDocument.es.js";
|
|
15
15
|
import { InvoiceViewerShell as L } from "./lib/components/InvoiceViewerShell.es.js";
|
|
16
16
|
import { FreemiusLicensePanel as z } from "./lib/components/FreemiusLicensePanel.es.js";
|
|
17
|
-
import { AccountNavigationMenu as
|
|
17
|
+
import { AccountNavigationMenu as N } from "./lib/components/AccountNavigationMenu.es.js";
|
|
18
18
|
import { SimpleTiptapRenderer as M, toNoCookieEmbedSrc as _ } from "./lib/components/SimpleTiptapRenderer.es.js";
|
|
19
19
|
import { ProductForm as w } from "./lib/pages/cms/products/components/ProductForm.es.js";
|
|
20
20
|
import { ProductCategorySelector as U } from "./lib/pages/cms/products/components/ProductCategorySelector.es.js";
|
|
@@ -22,28 +22,28 @@ import { getCartItemActivePrice as K, useCartStore as Y, useCartSubtotal as q, u
|
|
|
22
22
|
import { emptyProviderDiscounts as W, getCartLineCouponKey as j, normalizeCouponCode as Q } from "./lib/coupons.es.js";
|
|
23
23
|
import { CurrencyProvider as Z, useCurrency as $ } from "./lib/CurrencyProvider.es.js";
|
|
24
24
|
import { PaymentReadinessProvider as re, useCanPurchase as oe, usePaymentReadiness as te } from "./lib/PaymentReadinessProvider.es.js";
|
|
25
|
-
import { CURRENCY_ROUNDING_MODES as ie, applyCurrencyRounding as ne, convertMinorUnitAmount as me, describeCurrencyRoundingRule as ce, getCurrencyLookup as ue, getDefaultCurrency as
|
|
25
|
+
import { CURRENCY_ROUNDING_MODES as ie, applyCurrencyRounding as ne, convertMinorUnitAmount as me, describeCurrencyRoundingRule as ce, getCurrencyLookup as ue, getDefaultCurrency as le, getExchangeRateForCurrency as se, inferCurrencyCodeFromLocale as de, isSaleWindowActive as pe, isScheduledPriceDue as Ce, normalizeCurrencyRecord as fe, normalizeCurrencyRoundingMode as xe, normalizePriceMap as Pe, normalizeSalePriceMap as ge, resolveEffectivePriceForCurrency as ye, resolvePriceForCurrency as ve, resolvePriceRangeForCurrency as Se, sortCurrencies as Te } from "./lib/currency.es.js";
|
|
26
26
|
import { useCurrencyPreferenceStore as De } from "./lib/currency-store.es.js";
|
|
27
27
|
import { useCart as Re, useIsCartHydrated as Ae } from "./lib/use-cart.es.js";
|
|
28
|
-
import { addressesMatch as Fe, emptyCustomerAddress as Le, isCustomerAddressComplete as Oe, normalizeCustomerAddress as ze, normalizeOrderCustomerDetails as
|
|
28
|
+
import { addressesMatch as Fe, emptyCustomerAddress as Le, isCustomerAddressComplete as Oe, normalizeCustomerAddress as ze, normalizeOrderCustomerDetails as Ve } from "./lib/customer.es.js";
|
|
29
29
|
import { DEFAULT_ENABLED_PAYMENT_PROVIDERS as he, derivePaymentProviderFromProductType as Me, getProductPaymentProvider as _e, isDigitalItem as ke, isDigitalProduct as we, normalizeEnabledPaymentProviders as Ge } from "./lib/types.es.js";
|
|
30
30
|
import { getTrialCheckoutMode as Be, getTrialLabel as Ke, getTrialPaymentRequirementLabel as Ye, getTrialPeriodDays as qe, getTrialSummary as He } from "./lib/trials.es.js";
|
|
31
31
|
import { aggregateOrderTaxLines as We, buildOrderTaxDetailsFromCalculation as je, buildOrderTaxDetailsFromStripeSession as Qe, getOrderTaxRateJurisdiction as Xe, getOrderTaxRateLabel as Ze, getOrderTaxRatePercentage as $e, normalizeOrderTaxDetails as er } from "./lib/order-tax-details.es.js";
|
|
32
32
|
import { DEFAULT_INVOICE_SETTINGS as or, INVOICE_SETTINGS_KEY as tr, formatInvoiceCurrency as ar, formatInvoiceDate as ir, getInvoiceAddressLines as nr, normalizeInvoiceSettings as mr, serializeInvoiceSettings as cr } from "./lib/invoice.es.js";
|
|
33
|
-
import { buildInvoiceDocumentLabels as
|
|
33
|
+
import { buildInvoiceDocumentLabels as lr, getInvoiceLocale as sr, localizeInvoicePresentationData as dr, translateOrFallback as pr, translateOrderStatus as Cr } from "./lib/invoice-ui.es.js";
|
|
34
34
|
import { productSchema as xr } from "./lib/product-schema.es.js";
|
|
35
35
|
import { ProductProvider as gr, useProduct as yr } from "./lib/product-context.es.js";
|
|
36
36
|
import { ProductDetailsLayout as Sr } from "./lib/components/ProductDetailsLayout.es.js";
|
|
37
|
-
import {
|
|
37
|
+
import { applyVariantSelection as Ir, buildCombinationKey as Dr, buildVariantLabel as br, chooseInitialVariantSelections as Rr, extractSelectedTermsByAttribute as Ar, findMatchingVariant as Er, generateVariantDrafts as Fr, getAvailableTermIdsForAttribute as Lr, getVariantEffectivePriceRange as Or, mapRawVariantRelations as zr, normalizeSelectionsToAvailableVariants as Vr, resolveAttributeName as Nr, resolveTermValue as hr, resolveTranslatedText as Mr } from "./lib/variation-utils.es.js";
|
|
38
38
|
export {
|
|
39
|
-
|
|
39
|
+
N as AccountNavigationMenu,
|
|
40
40
|
C as AddToCartButton,
|
|
41
41
|
ie as CURRENCY_ROUNDING_MODES,
|
|
42
42
|
a as Cart,
|
|
43
43
|
o as CartDrawer,
|
|
44
44
|
c as CartIcon,
|
|
45
45
|
n as Checkout,
|
|
46
|
-
|
|
46
|
+
l as CouponForm,
|
|
47
47
|
Z as CurrencyProvider,
|
|
48
48
|
d as CurrencySwitcher,
|
|
49
49
|
D as CustomerProfileForm,
|
|
@@ -67,30 +67,31 @@ export {
|
|
|
67
67
|
Fe as addressesMatch,
|
|
68
68
|
We as aggregateOrderTaxLines,
|
|
69
69
|
ne as applyCurrencyRounding,
|
|
70
|
-
Ir as
|
|
71
|
-
|
|
70
|
+
Ir as applyVariantSelection,
|
|
71
|
+
Dr as buildCombinationKey,
|
|
72
|
+
lr as buildInvoiceDocumentLabels,
|
|
72
73
|
je as buildOrderTaxDetailsFromCalculation,
|
|
73
74
|
Qe as buildOrderTaxDetailsFromStripeSession,
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
br as buildVariantLabel,
|
|
76
|
+
Rr as chooseInitialVariantSelections,
|
|
76
77
|
me as convertMinorUnitAmount,
|
|
77
78
|
Me as derivePaymentProviderFromProductType,
|
|
78
79
|
ce as describeCurrencyRoundingRule,
|
|
79
80
|
Le as emptyCustomerAddress,
|
|
80
81
|
W as emptyProviderDiscounts,
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
Ar as extractSelectedTermsByAttribute,
|
|
83
|
+
Er as findMatchingVariant,
|
|
83
84
|
ar as formatInvoiceCurrency,
|
|
84
85
|
ir as formatInvoiceDate,
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
Fr as generateVariantDrafts,
|
|
87
|
+
Lr as getAvailableTermIdsForAttribute,
|
|
87
88
|
K as getCartItemActivePrice,
|
|
88
89
|
j as getCartLineCouponKey,
|
|
89
90
|
ue as getCurrencyLookup,
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
le as getDefaultCurrency,
|
|
92
|
+
se as getExchangeRateForCurrency,
|
|
92
93
|
nr as getInvoiceAddressLines,
|
|
93
|
-
|
|
94
|
+
sr as getInvoiceLocale,
|
|
94
95
|
Xe as getOrderTaxRateJurisdiction,
|
|
95
96
|
Ze as getOrderTaxRateLabel,
|
|
96
97
|
$e as getOrderTaxRatePercentage,
|
|
@@ -100,7 +101,7 @@ export {
|
|
|
100
101
|
Ye as getTrialPaymentRequirementLabel,
|
|
101
102
|
qe as getTrialPeriodDays,
|
|
102
103
|
He as getTrialSummary,
|
|
103
|
-
|
|
104
|
+
Or as getVariantEffectivePriceRange,
|
|
104
105
|
de as inferCurrencyCodeFromLocale,
|
|
105
106
|
Oe as isCustomerAddressComplete,
|
|
106
107
|
ke as isDigitalItem,
|
|
@@ -108,25 +109,25 @@ export {
|
|
|
108
109
|
pe as isSaleWindowActive,
|
|
109
110
|
Ce as isScheduledPriceDue,
|
|
110
111
|
dr as localizeInvoicePresentationData,
|
|
111
|
-
|
|
112
|
+
zr as mapRawVariantRelations,
|
|
112
113
|
Q as normalizeCouponCode,
|
|
113
114
|
fe as normalizeCurrencyRecord,
|
|
114
115
|
xe as normalizeCurrencyRoundingMode,
|
|
115
116
|
ze as normalizeCustomerAddress,
|
|
116
117
|
Ge as normalizeEnabledPaymentProviders,
|
|
117
118
|
mr as normalizeInvoiceSettings,
|
|
118
|
-
|
|
119
|
+
Ve as normalizeOrderCustomerDetails,
|
|
119
120
|
er as normalizeOrderTaxDetails,
|
|
120
121
|
Pe as normalizePriceMap,
|
|
121
122
|
ge as normalizeSalePriceMap,
|
|
122
|
-
|
|
123
|
+
Vr as normalizeSelectionsToAvailableVariants,
|
|
123
124
|
xr as productSchema,
|
|
124
125
|
Nr as resolveAttributeName,
|
|
125
126
|
ye as resolveEffectivePriceForCurrency,
|
|
126
127
|
ve as resolvePriceForCurrency,
|
|
127
128
|
Se as resolvePriceRangeForCurrency,
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
hr as resolveTermValue,
|
|
130
|
+
Mr as resolveTranslatedText,
|
|
130
131
|
cr as serializeInvoiceSettings,
|
|
131
132
|
Te as sortCurrencies,
|
|
132
133
|
_ as toNoCookieEmbedSrc,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),n=require("react"),h=require("@nextblock-cms/utils"),f=require("./currency.cjs.js"),v=require("./currency-store.cjs.js"),z=require("./currency-constants.cjs.js"),g=n.createContext(null);function x(o){return f.sortCurrencies(o.filter(r=>r.is_active!==!1))}function M(o){const{currencies:r,storedCurrencyCode:C,hasHydrated:y,initialCurrencyCode:t,locale:l}=o,u=new Set(r.map(a=>h.normalizeCurrencyCode(a.code))),s=f.getDefaultCurrency(r),d=t?h.normalizeCurrencyCode(t):null,e=C?h.normalizeCurrencyCode(C):null;if(y&&e&&u.has(e))return e;if(d&&u.has(d))return d;const i=f.inferCurrencyCodeFromLocale(l,r);return u.has(i)?i:s.code}function p({children:o,initialCurrencies:r,initialCurrencyCode:C,locale:y}){const[t,l]=n.useState(()=>x(r)),u=v.useCurrencyPreferenceStore(c=>c.activeCurrencyCode),s=v.useCurrencyPreferenceStore(c=>c.hasHydrated),d=v.useCurrencyPreferenceStore(c=>c.setActiveCurrencyCode);n.useEffect(()=>{v.useCurrencyPreferenceStore.persist.rehydrate()},[]),n.useEffect(()=>{r.length>0&&l(x(r))},[r]),n.useEffect(()=>{if(r.length>0)return;async function c(){const{fetchActiveCurrenciesFromRest:m}=await Promise.resolve().then(()=>require("./currency-rest-client.cjs.js")),S=await m();S.length>0&&l(x(S.map(P=>f.normalizeCurrencyRecord(P))))}c()},[r.length]);const e=n.useMemo(()=>M({currencies:t,storedCurrencyCode:u,hasHydrated:s,initialCurrencyCode:C,locale:y}),[t,u,s,C,y]);n.useEffect(()=>{!s||!e||u!==e&&d(e)},[s,e,d,u]),n.useEffect(()=>{!e||typeof document>"u"||(document.cookie=`${z.CURRENCY_COOKIE_NAME}=${e}; Path=/; Max-Age=31536000; SameSite=Lax`)},[e]);const i=n.useMemo(()=>f.getDefaultCurrency(t),[t]),a=n.useMemo(()=>t.find(c=>c.code===e)??i,[t,i,e]),E=n.useMemo(()=>({currencies:t,defaultCurrency:i,activeCurrency:a,activeCurrencyCode:a.code,isHydrated:s,setActiveCurrencyCode:c=>{const m=h.normalizeCurrencyCode(c);t.some(P=>P.code===m)&&d(m)}}),[a,t,i,s,d]);return q.jsx(g.Provider,{value:E,children:o})}function A(){const o=n.useContext(g);if(!o)throw new Error("useCurrency must be used inside a CurrencyProvider");return o}exports.CurrencyProvider=p;exports.useCurrency=A;
|
|
@@ -1,103 +1,99 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import { createContext as E, useState as
|
|
2
|
+
import { jsx as w } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as E, useState as z, useEffect as a, useMemo as l, useContext as H } from "react";
|
|
4
4
|
import { normalizeCurrencyCode as h } from "@nextblock-cms/utils";
|
|
5
|
-
import { getDefaultCurrency as
|
|
5
|
+
import { getDefaultCurrency as S, sortCurrencies as R, normalizeCurrencyRecord as M, inferCurrencyCodeFromLocale as _ } from "./currency.es.js";
|
|
6
6
|
import { useCurrencyPreferenceStore as v } from "./currency-store.es.js";
|
|
7
|
-
import { CURRENCY_COOKIE_NAME as
|
|
8
|
-
const
|
|
7
|
+
import { CURRENCY_COOKIE_NAME as F } from "./currency-constants.es.js";
|
|
8
|
+
const A = E(null);
|
|
9
9
|
function g(n) {
|
|
10
|
-
return
|
|
10
|
+
return R(
|
|
11
11
|
n.filter((r) => r.is_active !== !1)
|
|
12
12
|
);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const { currencies: r, storedCurrencyCode: i, hasHydrated: f, initialCurrencyCode: t, locale:
|
|
14
|
+
function L(n) {
|
|
15
|
+
const { currencies: r, storedCurrencyCode: i, hasHydrated: f, initialCurrencyCode: t, locale: y } = n, c = new Set(
|
|
16
16
|
r.map((C) => h(C.code))
|
|
17
|
-
),
|
|
17
|
+
), s = S(r), u = t ? h(t) : null, e = i ? h(i) : null;
|
|
18
18
|
if (f && e && c.has(e))
|
|
19
19
|
return e;
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
22
|
-
const
|
|
23
|
-
return c.has(
|
|
20
|
+
if (u && c.has(u))
|
|
21
|
+
return u;
|
|
22
|
+
const d = _(y, r);
|
|
23
|
+
return c.has(d) ? d : s.code;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function D({
|
|
26
26
|
children: n,
|
|
27
27
|
initialCurrencies: r,
|
|
28
28
|
initialCurrencyCode: i,
|
|
29
29
|
locale: f
|
|
30
30
|
}) {
|
|
31
|
-
const [t,
|
|
31
|
+
const [t, y] = z(
|
|
32
32
|
() => g(r)
|
|
33
33
|
), c = v(
|
|
34
34
|
(o) => o.activeCurrencyCode
|
|
35
|
-
),
|
|
35
|
+
), s = v((o) => o.hasHydrated), u = v(
|
|
36
36
|
(o) => o.setActiveCurrencyCode
|
|
37
37
|
);
|
|
38
38
|
a(() => {
|
|
39
39
|
v.persist.rehydrate();
|
|
40
40
|
}, []), a(() => {
|
|
41
|
-
r.length > 0 &&
|
|
41
|
+
r.length > 0 && y(g(r));
|
|
42
42
|
}, [r]), a(() => {
|
|
43
43
|
if (r.length > 0)
|
|
44
44
|
return;
|
|
45
45
|
async function o() {
|
|
46
|
-
const { fetchActiveCurrenciesFromRest:
|
|
47
|
-
p.length > 0 &&
|
|
48
|
-
g(p.map((x) =>
|
|
46
|
+
const { fetchActiveCurrenciesFromRest: m } = await import("./currency-rest-client.es.js"), p = await m();
|
|
47
|
+
p.length > 0 && y(
|
|
48
|
+
g(p.map((x) => M(x)))
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
o();
|
|
52
52
|
}, [r.length]);
|
|
53
53
|
const e = l(
|
|
54
|
-
() =>
|
|
54
|
+
() => L({
|
|
55
55
|
currencies: t,
|
|
56
56
|
storedCurrencyCode: c,
|
|
57
|
-
hasHydrated:
|
|
57
|
+
hasHydrated: s,
|
|
58
58
|
initialCurrencyCode: i,
|
|
59
59
|
locale: f
|
|
60
60
|
}),
|
|
61
|
-
[t, c,
|
|
61
|
+
[t, c, s, i, f]
|
|
62
62
|
);
|
|
63
63
|
a(() => {
|
|
64
|
-
e
|
|
65
|
-
}, [e,
|
|
66
|
-
!e || typeof document > "u" || (document.cookie = `${
|
|
64
|
+
!s || !e || c !== e && u(e);
|
|
65
|
+
}, [s, e, u, c]), a(() => {
|
|
66
|
+
!e || typeof document > "u" || (document.cookie = `${F}=${e}; Path=/; Max-Age=31536000; SameSite=Lax`);
|
|
67
67
|
}, [e]);
|
|
68
|
-
const
|
|
69
|
-
() =>
|
|
68
|
+
const d = l(
|
|
69
|
+
() => S(t),
|
|
70
70
|
[t]
|
|
71
71
|
), C = l(
|
|
72
|
-
() => t.find((o) => o.code === e) ??
|
|
73
|
-
[t,
|
|
74
|
-
),
|
|
72
|
+
() => t.find((o) => o.code === e) ?? d,
|
|
73
|
+
[t, d, e]
|
|
74
|
+
), P = l(
|
|
75
75
|
() => ({
|
|
76
76
|
currencies: t,
|
|
77
|
-
defaultCurrency:
|
|
77
|
+
defaultCurrency: d,
|
|
78
78
|
activeCurrency: C,
|
|
79
79
|
activeCurrencyCode: C.code,
|
|
80
|
-
isHydrated:
|
|
80
|
+
isHydrated: s,
|
|
81
81
|
setActiveCurrencyCode: (o) => {
|
|
82
|
-
const
|
|
83
|
-
t.some((x) => x.code ===
|
|
82
|
+
const m = h(o);
|
|
83
|
+
t.some((x) => x.code === m) && u(m);
|
|
84
84
|
}
|
|
85
85
|
}),
|
|
86
|
-
[C, t,
|
|
86
|
+
[C, t, d, s, u]
|
|
87
87
|
);
|
|
88
|
-
return /* @__PURE__ */ A
|
|
89
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/CurrencyProvider.tsx",
|
|
90
|
-
lineNumber: 192,
|
|
91
|
-
columnNumber: 5
|
|
92
|
-
}, this);
|
|
88
|
+
return /* @__PURE__ */ w(A.Provider, { value: P, children: n });
|
|
93
89
|
}
|
|
94
|
-
function
|
|
95
|
-
const n =
|
|
90
|
+
function I() {
|
|
91
|
+
const n = H(A);
|
|
96
92
|
if (!n)
|
|
97
93
|
throw new Error("useCurrency must be used inside a CurrencyProvider");
|
|
98
94
|
return n;
|
|
99
95
|
}
|
|
100
96
|
export {
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
D as CurrencyProvider,
|
|
98
|
+
I as useCurrency
|
|
103
99
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),s=require("react"),o=require("./types.cjs.js"),a={stripe:!0,freemius:!0},n=s.createContext(a);function c({readiness:e,children:t}){const r=s.useMemo(()=>({stripe:e?.stripe??!0,freemius:e?.freemius??!0}),[e?.stripe,e?.freemius]);return i.jsx(n.Provider,{value:r,children:t})}function u(){return s.useContext(n)}function P(e){const t=u(),r=o.getProductPaymentProvider(e)??"stripe";return t[r]??!0}exports.PaymentReadinessProvider=c;exports.useCanPurchase=P;exports.usePaymentReadiness=u;
|
|
@@ -1,34 +1,30 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import { createContext as
|
|
2
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as s, useMemo as u, useContext as i } from "react";
|
|
4
4
|
import { getProductPaymentProvider as m } from "./types.es.js";
|
|
5
|
-
const c = { stripe: !0, freemius: !0 },
|
|
6
|
-
function
|
|
5
|
+
const c = { stripe: !0, freemius: !0 }, o = s(c);
|
|
6
|
+
function d({
|
|
7
7
|
readiness: e,
|
|
8
|
-
children:
|
|
8
|
+
children: t
|
|
9
9
|
}) {
|
|
10
|
-
const
|
|
10
|
+
const r = u(
|
|
11
11
|
() => ({
|
|
12
12
|
stripe: e?.stripe ?? !0,
|
|
13
13
|
freemius: e?.freemius ?? !0
|
|
14
14
|
}),
|
|
15
15
|
[e?.stripe, e?.freemius]
|
|
16
16
|
);
|
|
17
|
-
return /* @__PURE__ */ o
|
|
18
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/PaymentReadinessProvider.tsx",
|
|
19
|
-
lineNumber: 51,
|
|
20
|
-
columnNumber: 5
|
|
21
|
-
}, this);
|
|
17
|
+
return /* @__PURE__ */ n(o.Provider, { value: r, children: t });
|
|
22
18
|
}
|
|
23
|
-
function
|
|
24
|
-
return
|
|
19
|
+
function f() {
|
|
20
|
+
return i(o);
|
|
25
21
|
}
|
|
26
|
-
function
|
|
27
|
-
const
|
|
28
|
-
return r
|
|
22
|
+
function v(e) {
|
|
23
|
+
const t = f(), r = m(e) ?? "stripe";
|
|
24
|
+
return t[r] ?? !0;
|
|
29
25
|
}
|
|
30
26
|
export {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
d as PaymentReadinessProvider,
|
|
28
|
+
v as useCanPurchase,
|
|
29
|
+
f as usePaymentReadiness
|
|
34
30
|
};
|
package/lib/cart-store.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("zustand"),p=require("zustand/middleware"),a=require("./types.cjs.js"),_=require("./CurrencyProvider.cjs.js"),k=require("./currency.cjs.js");function n(r,c,e){return r.reduce((t,s)=>a.isDigitalItem(s)||s.sku!==c||e&&s.id===e?t:t+s.quantity,0)}const l=C.create()(p.persist((r,c)=>({items:[],appliedCoupon:null,isOpen:!1,addItem:e=>{const{items:t}=c(),s=e.quantity??1,i=typeof e.stock=="number"?e.stock:null,o=i!==null?n(t,e.sku):0;if(a.isDigitalItem(e))return t.find(d=>d.product_id===e.product_id&&a.isDigitalItem(d))?{success:!1,error:"This software license is already in your cart.",errorKey:"ecommerce.cart_error_license_in_cart"}:(r({items:[...t,{...e,quantity:1}],isOpen:!0}),{success:!0});const y=t.find(u=>u.id===e.id);return i!==null&&i<=0?{success:!1,error:"This item is out of stock.",errorKey:"ecommerce.cart_error_out_of_stock"}:i!==null&&o+s>i?{success:!1,error:`Only ${i} available for this SKU.`,errorKey:"ecommerce.cart_error_stock_limit",errorParams:{count:i}}:(r(y?{items:t.map(u=>u.id===e.id?{...u,...e,quantity:u.quantity+s}:u),isOpen:!0}:{items:[...t,{...e,quantity:s}],isOpen:!0}),{success:!0})},removeItem:e=>{const{items:t}=c();r({items:t.filter(s=>s.id!==e)})},updateQuantity:(e,t)=>{const{items:s}=c(),i=s.find(o=>o.id===e);i&&a.isDigitalItem(i)||(i&&typeof i.stock=="number"&&t+n(s,i.sku,e)>i.stock&&(t=Math.max(i.stock-n(s,i.sku,e),0)),t<=0?r({items:s.filter(o=>o.id!==e)}):r({items:s.map(o=>o.id===e?{...o,quantity:t}:o)}))},setAppliedCoupon:e=>{const t=c().appliedCoupon;t?.code===e?.code&&t?.couponId===e?.couponId||r({appliedCoupon:e})},removeCoupon:()=>{c().appliedCoupon&&r({appliedCoupon:null})},clearCart:()=>r({items:[],appliedCoupon:null}),toggleCart:()=>r(e=>({isOpen:!e.isOpen})),setIsOpen:e=>r({isOpen:e}),setItems:e=>r({items:e})}),{name:"cart-storage",storage:p.createJSONStorage(()=>localStorage),skipHydration:!0,partialize:r=>({items:r.items,appliedCoupon:r.appliedCoupon})})),m=()=>l(c=>c.items).reduce((c,e)=>c+e.quantity,0);function f(r,c){return k.resolveEffectivePriceForCurrency({prices:r.prices,salePrices:r.sale_prices,fallbackPrice:r.price,fallbackSalePrice:r.sale_price,saleStartAt:r.sale_start_at,saleEndAt:r.sale_end_at,scheduledPrice:r.scheduled_price,scheduledPrices:r.scheduled_prices,scheduledPriceAt:r.scheduled_price_at,currencyCode:c.currencyCode,currencies:c.currencies})}const S=()=>{const r=l(t=>t.items),{activeCurrencyCode:c,currencies:e}=_.useCurrency();return r.reduce((t,s)=>{const{price:i,sale_price:o}=f(s,{currencyCode:c,currencies:e});return t+(o??i)*s.quantity},0)};exports.getCartItemActivePrice=f;exports.useCartStore=l;exports.useCartSubtotal=S;exports.useCartTotalItems=m;
|
package/lib/cart-store.d.ts
CHANGED
|
@@ -3,7 +3,11 @@ import { useCurrency } from './CurrencyProvider';
|
|
|
3
3
|
import { AppliedCouponState } from './coupons';
|
|
4
4
|
export interface AddItemResult {
|
|
5
5
|
success: boolean;
|
|
6
|
+
/** English text, kept for callers that only log it. */
|
|
6
7
|
error?: string;
|
|
8
|
+
/** Translation key for the same failure, so the UI can answer in the visitor's language. */
|
|
9
|
+
errorKey?: string;
|
|
10
|
+
errorParams?: Record<string, string | number>;
|
|
7
11
|
}
|
|
8
12
|
interface CartState {
|
|
9
13
|
items: CartItem[];
|
package/lib/cart-store.es.js
CHANGED
|
@@ -1,115 +1,123 @@
|
|
|
1
1
|
import { create as f } from "zustand";
|
|
2
|
-
import { persist as
|
|
2
|
+
import { persist as y, createJSONStorage as C } from "zustand/middleware";
|
|
3
3
|
import { isDigitalItem as n } from "./types.es.js";
|
|
4
|
-
import { useCurrency as
|
|
5
|
-
import { resolveEffectivePriceForCurrency as
|
|
6
|
-
function a(
|
|
7
|
-
return
|
|
4
|
+
import { useCurrency as _ } from "./CurrencyProvider.es.js";
|
|
5
|
+
import { resolveEffectivePriceForCurrency as k } from "./currency.es.js";
|
|
6
|
+
function a(e, o, r) {
|
|
7
|
+
return e.reduce((t, s) => n(s) || s.sku !== o || r && s.id === r ? t : t + s.quantity, 0);
|
|
8
8
|
}
|
|
9
9
|
const p = f()(
|
|
10
|
-
|
|
11
|
-
(
|
|
10
|
+
y(
|
|
11
|
+
(e, o) => ({
|
|
12
12
|
items: [],
|
|
13
13
|
appliedCoupon: null,
|
|
14
14
|
isOpen: !1,
|
|
15
|
-
addItem: (
|
|
16
|
-
const { items:
|
|
17
|
-
if (n(
|
|
18
|
-
return
|
|
19
|
-
(l) => l.product_id ===
|
|
15
|
+
addItem: (r) => {
|
|
16
|
+
const { items: t } = o(), s = r.quantity ?? 1, c = typeof r.stock == "number" ? r.stock : null, i = c !== null ? a(t, r.sku) : 0;
|
|
17
|
+
if (n(r))
|
|
18
|
+
return t.find(
|
|
19
|
+
(l) => l.product_id === r.product_id && n(l)
|
|
20
20
|
) ? {
|
|
21
21
|
success: !1,
|
|
22
|
-
error: "This software license is already in your cart."
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
error: "This software license is already in your cart.",
|
|
23
|
+
errorKey: "ecommerce.cart_error_license_in_cart"
|
|
24
|
+
} : (e({
|
|
25
|
+
items: [...t, { ...r, quantity: 1 }],
|
|
25
26
|
isOpen: !0
|
|
26
27
|
}), { success: !0 });
|
|
27
|
-
const d =
|
|
28
|
+
const d = t.find((u) => u.id === r.id);
|
|
28
29
|
return c !== null && c <= 0 ? {
|
|
29
30
|
success: !1,
|
|
30
|
-
error: "This item is out of stock."
|
|
31
|
-
|
|
31
|
+
error: "This item is out of stock.",
|
|
32
|
+
errorKey: "ecommerce.cart_error_out_of_stock"
|
|
33
|
+
} : c !== null && i + s > c ? {
|
|
32
34
|
success: !1,
|
|
33
|
-
error: `Only ${c} available for this SKU
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
error: `Only ${c} available for this SKU.`,
|
|
36
|
+
errorKey: "ecommerce.cart_error_stock_limit",
|
|
37
|
+
errorParams: { count: c }
|
|
38
|
+
} : (e(d ? {
|
|
39
|
+
items: t.map(
|
|
40
|
+
(u) => u.id === r.id ? {
|
|
37
41
|
...u,
|
|
38
|
-
...
|
|
39
|
-
quantity: u.quantity +
|
|
42
|
+
...r,
|
|
43
|
+
quantity: u.quantity + s
|
|
40
44
|
} : u
|
|
41
45
|
),
|
|
42
46
|
isOpen: !0
|
|
43
47
|
} : {
|
|
44
|
-
items: [...
|
|
48
|
+
items: [...t, { ...r, quantity: s }],
|
|
45
49
|
isOpen: !0
|
|
46
50
|
}), { success: !0 });
|
|
47
51
|
},
|
|
48
|
-
removeItem: (
|
|
49
|
-
const { items:
|
|
50
|
-
|
|
51
|
-
items:
|
|
52
|
+
removeItem: (r) => {
|
|
53
|
+
const { items: t } = o();
|
|
54
|
+
e({
|
|
55
|
+
items: t.filter((s) => s.id !== r)
|
|
52
56
|
});
|
|
53
57
|
},
|
|
54
|
-
updateQuantity: (
|
|
55
|
-
const { items:
|
|
56
|
-
c && n(c) || (c && typeof c.stock == "number" &&
|
|
57
|
-
c.stock - a(
|
|
58
|
+
updateQuantity: (r, t) => {
|
|
59
|
+
const { items: s } = o(), c = s.find((i) => i.id === r);
|
|
60
|
+
c && n(c) || (c && typeof c.stock == "number" && t + a(s, c.sku, r) > c.stock && (t = Math.max(
|
|
61
|
+
c.stock - a(s, c.sku, r),
|
|
58
62
|
0
|
|
59
|
-
)),
|
|
60
|
-
items:
|
|
61
|
-
}) :
|
|
62
|
-
items:
|
|
63
|
-
(
|
|
63
|
+
)), t <= 0 ? e({
|
|
64
|
+
items: s.filter((i) => i.id !== r)
|
|
65
|
+
}) : e({
|
|
66
|
+
items: s.map(
|
|
67
|
+
(i) => i.id === r ? { ...i, quantity: t } : i
|
|
64
68
|
)
|
|
65
69
|
}));
|
|
66
70
|
},
|
|
67
|
-
setAppliedCoupon: (
|
|
68
|
-
const
|
|
69
|
-
|
|
71
|
+
setAppliedCoupon: (r) => {
|
|
72
|
+
const t = o().appliedCoupon;
|
|
73
|
+
t?.code === r?.code && t?.couponId === r?.couponId || e({ appliedCoupon: r });
|
|
70
74
|
},
|
|
71
75
|
removeCoupon: () => {
|
|
72
|
-
|
|
76
|
+
o().appliedCoupon && e({ appliedCoupon: null });
|
|
73
77
|
},
|
|
74
|
-
clearCart: () =>
|
|
75
|
-
toggleCart: () =>
|
|
76
|
-
setIsOpen: (
|
|
77
|
-
setItems: (
|
|
78
|
+
clearCart: () => e({ items: [], appliedCoupon: null }),
|
|
79
|
+
toggleCart: () => e((r) => ({ isOpen: !r.isOpen })),
|
|
80
|
+
setIsOpen: (r) => e({ isOpen: r }),
|
|
81
|
+
setItems: (r) => e({ items: r })
|
|
78
82
|
}),
|
|
79
83
|
{
|
|
80
84
|
name: "cart-storage",
|
|
81
|
-
storage:
|
|
82
|
-
skipHydration: !0
|
|
85
|
+
storage: C(() => localStorage),
|
|
86
|
+
skipHydration: !0,
|
|
87
|
+
// Persist the cart, not the UI. `isOpen` used to be stored too, so a visitor who left
|
|
88
|
+
// with the drawer open got it thrown open again (stealing focus) on the next page load
|
|
89
|
+
// and in every new tab.
|
|
90
|
+
partialize: (e) => ({ items: e.items, appliedCoupon: e.appliedCoupon })
|
|
83
91
|
}
|
|
84
92
|
)
|
|
85
|
-
), b = () => p((
|
|
86
|
-
function
|
|
87
|
-
return
|
|
88
|
-
prices:
|
|
89
|
-
salePrices:
|
|
90
|
-
fallbackPrice:
|
|
91
|
-
fallbackSalePrice:
|
|
92
|
-
saleStartAt:
|
|
93
|
-
saleEndAt:
|
|
94
|
-
scheduledPrice:
|
|
95
|
-
scheduledPrices:
|
|
96
|
-
scheduledPriceAt:
|
|
97
|
-
currencyCode:
|
|
98
|
-
currencies:
|
|
93
|
+
), b = () => p((o) => o.items).reduce((o, r) => o + r.quantity, 0);
|
|
94
|
+
function m(e, o) {
|
|
95
|
+
return k({
|
|
96
|
+
prices: e.prices,
|
|
97
|
+
salePrices: e.sale_prices,
|
|
98
|
+
fallbackPrice: e.price,
|
|
99
|
+
fallbackSalePrice: e.sale_price,
|
|
100
|
+
saleStartAt: e.sale_start_at,
|
|
101
|
+
saleEndAt: e.sale_end_at,
|
|
102
|
+
scheduledPrice: e.scheduled_price,
|
|
103
|
+
scheduledPrices: e.scheduled_prices,
|
|
104
|
+
scheduledPriceAt: e.scheduled_price_at,
|
|
105
|
+
currencyCode: o.currencyCode,
|
|
106
|
+
currencies: o.currencies
|
|
99
107
|
});
|
|
100
108
|
}
|
|
101
109
|
const g = () => {
|
|
102
|
-
const
|
|
103
|
-
return
|
|
104
|
-
const { price: c, sale_price:
|
|
105
|
-
currencyCode:
|
|
106
|
-
currencies:
|
|
110
|
+
const e = p((t) => t.items), { activeCurrencyCode: o, currencies: r } = _();
|
|
111
|
+
return e.reduce((t, s) => {
|
|
112
|
+
const { price: c, sale_price: i } = m(s, {
|
|
113
|
+
currencyCode: o,
|
|
114
|
+
currencies: r
|
|
107
115
|
});
|
|
108
|
-
return
|
|
116
|
+
return t + (i ?? c) * s.quantity;
|
|
109
117
|
}, 0);
|
|
110
118
|
};
|
|
111
119
|
export {
|
|
112
|
-
|
|
120
|
+
m as getCartItemActivePrice,
|
|
113
121
|
p as useCartStore,
|
|
114
122
|
g as useCartSubtotal,
|
|
115
123
|
b as useCartTotalItems
|