@nextblock-cms/ecom 0.15.8 → 0.15.9
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.d.ts +1 -0
- package/index.es.js +94 -90
- package/lib/PaymentReadinessProvider.cjs.js +1 -0
- package/lib/PaymentReadinessProvider.d.ts +26 -0
- package/lib/PaymentReadinessProvider.es.js +34 -0
- package/lib/components/AddToCartButton.cjs.js +1 -1
- package/lib/components/AddToCartButton.es.js +51 -31
- package/lib/components/Checkout.cjs.js +1 -1
- package/lib/components/Checkout.es.js +369 -360
- package/lib/components/ProductDetailsLayout.cjs.js +1 -1
- package/lib/components/ProductDetailsLayout.d.ts +8 -0
- package/lib/components/ProductDetailsLayout.es.js +196 -194
- package/lib/pages/cms/payments/actions.cjs.js +1 -1
- package/lib/pages/cms/payments/actions.es.js +16 -16
- package/lib/pages/cms/payments/queries.cjs.js +1 -1
- package/lib/pages/cms/payments/queries.d.ts +32 -1
- package/lib/pages/cms/payments/queries.es.js +50 -13
- package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductForm.es.js +271 -267
- package/lib/payment-config.es.js +5 -5
- package/lib/providers/freemius.cjs.js +2 -2
- package/lib/providers/freemius.es.js +176 -169
- package/lib/providers/stripe.cjs.js +1 -1
- package/lib/providers/stripe.es.js +60 -51
- package/lib/stripe/client.cjs.js +1 -1
- package/lib/stripe/client.d.ts +9 -0
- package/lib/stripe/client.es.js +17 -7
- package/package.json +4 -4
- package/server.cjs.js +1 -1
- package/server.d.ts +1 -1
- package/server.es.js +184 -180
package/index.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 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"),f=require("./lib/pages/cms/products/components/ProductForm.cjs.js"),h=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"),z=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"),N=require("./lib/product-schema.cjs.js"),P=require("./lib/product-context.cjs.js"),V=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=f.ProductForm;exports.ProductCategorySelector=h.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=z.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=N.productSchema;exports.ProductProvider=P.ProductProvider;exports.useProduct=P.useProduct;exports.ProductDetailsLayout=V.ProductDetailsLayout;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.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export { ProductCategorySelector } from './lib/pages/cms/products/components/Pro
|
|
|
22
22
|
export * from './lib/cart-store';
|
|
23
23
|
export * from './lib/coupons';
|
|
24
24
|
export * from './lib/CurrencyProvider';
|
|
25
|
+
export * from './lib/PaymentReadinessProvider';
|
|
25
26
|
export * from './lib/currency';
|
|
26
27
|
export * from './lib/currency-store';
|
|
27
28
|
export * from './lib/use-cart';
|
package/index.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
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
|
-
import { CartIcon as
|
|
5
|
-
import { CouponForm as
|
|
4
|
+
import { CartIcon as c } from "./lib/components/CartIcon.es.js";
|
|
5
|
+
import { CouponForm as s } 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";
|
|
@@ -21,121 +21,125 @@ import { ProductCategorySelector as U } from "./lib/pages/cms/products/component
|
|
|
21
21
|
import { getCartItemActivePrice as K, useCartStore as Y, useCartSubtotal as q, useCartTotalItems as H } from "./lib/cart-store.es.js";
|
|
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
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
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 se, getExchangeRateForCurrency as le, 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
|
+
import { useCurrencyPreferenceStore as De } from "./lib/currency-store.es.js";
|
|
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 Ne } from "./lib/customer.es.js";
|
|
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
|
+
import { getTrialCheckoutMode as Be, getTrialLabel as Ke, getTrialPaymentRequirementLabel as Ye, getTrialPeriodDays as qe, getTrialSummary as He } from "./lib/trials.es.js";
|
|
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
|
+
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 sr, getInvoiceLocale as lr, localizeInvoicePresentationData as dr, translateOrFallback as pr, translateOrderStatus as Cr } from "./lib/invoice-ui.es.js";
|
|
34
|
+
import { productSchema as xr } from "./lib/product-schema.es.js";
|
|
35
|
+
import { ProductProvider as gr, useProduct as yr } from "./lib/product-context.es.js";
|
|
36
|
+
import { ProductDetailsLayout as Sr } from "./lib/components/ProductDetailsLayout.es.js";
|
|
37
|
+
import { buildCombinationKey as Ir, buildVariantLabel as Dr, chooseInitialVariantSelections as br, extractSelectedTermsByAttribute as Rr, findMatchingVariant as Ar, generateVariantDrafts as Er, getAvailableTermIdsForAttribute as Fr, getVariantEffectivePriceRange as Lr, mapRawVariantRelations as Or, normalizeSelectionsToAvailableVariants as zr, resolveAttributeName as Nr, resolveTermValue as Vr, resolveTranslatedText as hr } from "./lib/variation-utils.es.js";
|
|
37
38
|
export {
|
|
38
39
|
V as AccountNavigationMenu,
|
|
39
40
|
C as AddToCartButton,
|
|
40
|
-
|
|
41
|
+
ie as CURRENCY_ROUNDING_MODES,
|
|
41
42
|
a as Cart,
|
|
42
43
|
o as CartDrawer,
|
|
43
|
-
|
|
44
|
+
c as CartIcon,
|
|
44
45
|
n as Checkout,
|
|
45
|
-
|
|
46
|
+
s as CouponForm,
|
|
46
47
|
Z as CurrencyProvider,
|
|
47
48
|
d as CurrencySwitcher,
|
|
48
49
|
D as CustomerProfileForm,
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
he as DEFAULT_ENABLED_PAYMENT_PROVIDERS,
|
|
51
|
+
or as DEFAULT_INVOICE_SETTINGS,
|
|
51
52
|
T as FeaturedProduct,
|
|
52
53
|
z as FreemiusLicensePanel,
|
|
53
|
-
|
|
54
|
+
tr as INVOICE_SETTINGS_KEY,
|
|
54
55
|
E as InvoiceDocument,
|
|
55
56
|
L as InvoiceViewerShell,
|
|
57
|
+
re as PaymentReadinessProvider,
|
|
56
58
|
x as ProductCard,
|
|
57
59
|
U as ProductCategorySelector,
|
|
58
|
-
|
|
60
|
+
Sr as ProductDetailsLayout,
|
|
59
61
|
w as ProductForm,
|
|
60
62
|
v as ProductGallery,
|
|
61
63
|
g as ProductGrid,
|
|
62
|
-
|
|
64
|
+
gr as ProductProvider,
|
|
63
65
|
M as SimpleTiptapRenderer,
|
|
64
66
|
R as SubscriptionSelector,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
Fe as addressesMatch,
|
|
68
|
+
We as aggregateOrderTaxLines,
|
|
69
|
+
ne as applyCurrencyRounding,
|
|
70
|
+
Ir as buildCombinationKey,
|
|
71
|
+
sr as buildInvoiceDocumentLabels,
|
|
72
|
+
je as buildOrderTaxDetailsFromCalculation,
|
|
73
|
+
Qe as buildOrderTaxDetailsFromStripeSession,
|
|
74
|
+
Dr as buildVariantLabel,
|
|
75
|
+
br as chooseInitialVariantSelections,
|
|
76
|
+
me as convertMinorUnitAmount,
|
|
77
|
+
Me as derivePaymentProviderFromProductType,
|
|
78
|
+
ce as describeCurrencyRoundingRule,
|
|
79
|
+
Le as emptyCustomerAddress,
|
|
78
80
|
W as emptyProviderDiscounts,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
Rr as extractSelectedTermsByAttribute,
|
|
82
|
+
Ar as findMatchingVariant,
|
|
83
|
+
ar as formatInvoiceCurrency,
|
|
84
|
+
ir as formatInvoiceDate,
|
|
85
|
+
Er as generateVariantDrafts,
|
|
86
|
+
Fr as getAvailableTermIdsForAttribute,
|
|
85
87
|
K as getCartItemActivePrice,
|
|
86
88
|
j as getCartLineCouponKey,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
89
|
+
ue as getCurrencyLookup,
|
|
90
|
+
se as getDefaultCurrency,
|
|
91
|
+
le as getExchangeRateForCurrency,
|
|
92
|
+
nr as getInvoiceAddressLines,
|
|
93
|
+
lr as getInvoiceLocale,
|
|
94
|
+
Xe as getOrderTaxRateJurisdiction,
|
|
95
|
+
Ze as getOrderTaxRateLabel,
|
|
96
|
+
$e as getOrderTaxRatePercentage,
|
|
97
|
+
_e as getProductPaymentProvider,
|
|
98
|
+
Be as getTrialCheckoutMode,
|
|
99
|
+
Ke as getTrialLabel,
|
|
100
|
+
Ye as getTrialPaymentRequirementLabel,
|
|
101
|
+
qe as getTrialPeriodDays,
|
|
102
|
+
He as getTrialSummary,
|
|
103
|
+
Lr as getVariantEffectivePriceRange,
|
|
104
|
+
de as inferCurrencyCodeFromLocale,
|
|
105
|
+
Oe as isCustomerAddressComplete,
|
|
106
|
+
ke as isDigitalItem,
|
|
107
|
+
we as isDigitalProduct,
|
|
108
|
+
pe as isSaleWindowActive,
|
|
109
|
+
Ce as isScheduledPriceDue,
|
|
110
|
+
dr as localizeInvoicePresentationData,
|
|
111
|
+
Or as mapRawVariantRelations,
|
|
110
112
|
Q as normalizeCouponCode,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
113
|
+
fe as normalizeCurrencyRecord,
|
|
114
|
+
xe as normalizeCurrencyRoundingMode,
|
|
115
|
+
ze as normalizeCustomerAddress,
|
|
116
|
+
Ge as normalizeEnabledPaymentProviders,
|
|
117
|
+
mr as normalizeInvoiceSettings,
|
|
118
|
+
Ne as normalizeOrderCustomerDetails,
|
|
119
|
+
er as normalizeOrderTaxDetails,
|
|
120
|
+
Pe as normalizePriceMap,
|
|
121
|
+
ge as normalizeSalePriceMap,
|
|
122
|
+
zr as normalizeSelectionsToAvailableVariants,
|
|
123
|
+
xr as productSchema,
|
|
124
|
+
Nr as resolveAttributeName,
|
|
125
|
+
ye as resolveEffectivePriceForCurrency,
|
|
126
|
+
ve as resolvePriceForCurrency,
|
|
127
|
+
Se as resolvePriceRangeForCurrency,
|
|
128
|
+
Vr as resolveTermValue,
|
|
129
|
+
hr as resolveTranslatedText,
|
|
130
|
+
cr as serializeInvoiceSettings,
|
|
131
|
+
Te as sortCurrencies,
|
|
130
132
|
_ as toNoCookieEmbedSrc,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
pr as translateOrFallback,
|
|
134
|
+
Cr as translateOrderStatus,
|
|
135
|
+
oe as useCanPurchase,
|
|
136
|
+
Re as useCart,
|
|
134
137
|
Y as useCartStore,
|
|
135
138
|
q as useCartSubtotal,
|
|
136
139
|
H as useCartTotalItems,
|
|
137
140
|
$ as useCurrency,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
De as useCurrencyPreferenceStore,
|
|
142
|
+
Ae as useIsCartHydrated,
|
|
143
|
+
te as usePaymentReadiness,
|
|
144
|
+
yr as useProduct
|
|
141
145
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-dev-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 u.jsxDEV(n.Provider,{value:r,children:t},void 0,!1,{fileName:"C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/PaymentReadinessProvider.tsx",lineNumber:51,columnNumber:5},this)}function i(){return s.useContext(n)}function m(e){const t=i(),r=o.getProductPaymentProvider(e)??"stripe";return t[r]??!0}exports.PaymentReadinessProvider=c;exports.useCanPurchase=m;exports.usePaymentReadiness=i;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Product } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Which payment providers the store can actually charge through, shared with every
|
|
5
|
+
* client component that renders a buy control.
|
|
6
|
+
*
|
|
7
|
+
* This is a context rather than a prop threaded down from each block because the buy
|
|
8
|
+
* CTA appears in five unrelated places (detail page, grid card, featured block,
|
|
9
|
+
* subscription selector, quick add) and product grids re-fetch later pages through a
|
|
10
|
+
* server action — a prop passed with page one would not reach page two. It is
|
|
11
|
+
* store-level, not per-product, so pagination cannot invalidate it.
|
|
12
|
+
*
|
|
13
|
+
* Booleans only. Nothing here is sensitive: it says whether the shop can take money,
|
|
14
|
+
* never anything about the credentials that let it.
|
|
15
|
+
*/
|
|
16
|
+
export interface PaymentReadiness {
|
|
17
|
+
stripe: boolean;
|
|
18
|
+
freemius: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function PaymentReadinessProvider({ readiness, children, }: {
|
|
21
|
+
readiness?: PaymentReadiness | null;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
|
+
export declare function usePaymentReadiness(): PaymentReadiness;
|
|
25
|
+
/** Whether this specific product can be bought, given its provider. */
|
|
26
|
+
export declare function useCanPurchase(product: Pick<Product, 'payment_provider' | 'product_type' | 'freemius_product_id'>): boolean;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxDEV as o } from "react/jsx-dev-runtime";
|
|
3
|
+
import { createContext as i, useMemo as n, useContext as u } from "react";
|
|
4
|
+
import { getProductPaymentProvider as m } from "./types.es.js";
|
|
5
|
+
const c = { stripe: !0, freemius: !0 }, s = i(c);
|
|
6
|
+
function P({
|
|
7
|
+
readiness: e,
|
|
8
|
+
children: r
|
|
9
|
+
}) {
|
|
10
|
+
const t = n(
|
|
11
|
+
() => ({
|
|
12
|
+
stripe: e?.stripe ?? !0,
|
|
13
|
+
freemius: e?.freemius ?? !0
|
|
14
|
+
}),
|
|
15
|
+
[e?.stripe, e?.freemius]
|
|
16
|
+
);
|
|
17
|
+
return /* @__PURE__ */ o(s.Provider, { value: t, children: r }, void 0, !1, {
|
|
18
|
+
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/PaymentReadinessProvider.tsx",
|
|
19
|
+
lineNumber: 51,
|
|
20
|
+
columnNumber: 5
|
|
21
|
+
}, this);
|
|
22
|
+
}
|
|
23
|
+
function a() {
|
|
24
|
+
return u(s);
|
|
25
|
+
}
|
|
26
|
+
function l(e) {
|
|
27
|
+
const r = a(), t = m(e) ?? "stripe";
|
|
28
|
+
return r[t] ?? !0;
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
P as PaymentReadinessProvider,
|
|
32
|
+
l as useCanPurchase,
|
|
33
|
+
a as usePaymentReadiness
|
|
34
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-dev-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-dev-runtime"),i=require("@nextblock-cms/ui/button"),o=require("lucide-react"),c=require("sonner"),d=require("next/link"),v=require("../use-cart.cjs.js"),B=require("@nextblock-cms/utils"),m=require("../types.cjs.js"),h=require("../CurrencyProvider.cjs.js"),D=require("../PaymentReadinessProvider.cjs.js"),j=({product:e,className:n,quantity:u})=>{const a=v.useCart(t=>t),{t:r}=B.useTranslations(),{activeCurrencyCode:_}=h.useCurrency(),b=D.useCanPurchase(e),l=m.isDigitalProduct(e),N=!!e.has_variants&&!e.variant_id&&!l,f=!l&&typeof e.stock=="number"&&e.stock<=0;if(!b){const t=r("ecommerce.contact_seller");return s.jsxDEV(i.Button,{asChild:!0,variant:"outline",className:n,children:s.jsxDEV(d,{href:`/product/${e.slug}#contact-seller`,children:[s.jsxDEV(o.Mail,{className:"mr-2 h-4 w-4"},void 0,!1,{fileName:"C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:46,columnNumber:11},void 0),t==="ecommerce.contact_seller"?"Contact the seller":t]},void 0,!0,{fileName:"C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:45,columnNumber:9},void 0)},void 0,!1,{fileName:"C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:44,columnNumber:7},void 0)}if(N)return s.jsxDEV(i.Button,{asChild:!0,className:n,children:s.jsxDEV(d,{href:`/product/${e.slug}`,children:"Select Options"},void 0,!1,{fileName:"C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:56,columnNumber:9},void 0)},void 0,!1,{fileName:"C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:55,columnNumber:7},void 0);if(f){const t=r("ecommerce.out_of_stock");return s.jsxDEV(i.Button,{disabled:!0,className:n,children:[s.jsxDEV(o.ShoppingCart,{className:"mr-2 h-4 w-4"},void 0,!1,{fileName:"C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:66,columnNumber:9},void 0),t==="ecommerce.out_of_stock"?"Out of stock":t]},void 0,!0,{fileName:"C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:65,columnNumber:7},void 0)}if(!a)return s.jsxDEV(i.Button,{disabled:!0,className:n,children:[s.jsxDEV(o.ShoppingCart,{className:"mr-2 h-4 w-4"},void 0,!1,{fileName:"C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:77,columnNumber:9},void 0),r("ecommerce.add_to_cart")]},void 0,!0,{fileName:"C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:76,columnNumber:7},void 0);const{addItem:C}=a,x=()=>{const t=m.getProductPaymentProvider(e)??"stripe",{success:k,error:p}=C({id:e.variant_id||e.id,product_id:e.id,title:e.title,price:e.price,prices:e.prices,sale_price:e.sale_price,sale_prices:e.sale_prices,is_taxable:e.is_taxable,image_url:e.image_url,slug:e.slug,sku:e.sku,stock:e.stock,language_id:e.language_id,translation_group_id:e.translation_group_id,product_type:e.product_type,payment_provider:e.payment_provider??t,provider:t,freemius_product_id:e.freemius_product_id,freemius_plan_id:e.freemius_plan_id,trial_period_days:e.trial_period_days??0,trial_requires_payment_method:e.trial_requires_payment_method??!1,has_variants:e.has_variants,variant_id:e.variant_id,variant_label:e.variant_label,selected_options:e.selected_options,currency_code:_,quantity:u});k?c.toast.success(r("ecommerce.added_to_cart_success",{item:e.title})):c.toast.error(p||r("ecommerce.added_to_cart_error"))};return s.jsxDEV(i.Button,{onClick:x,className:n,children:[s.jsxDEV(o.ShoppingCart,{className:"mr-2 h-4 w-4"},void 0,!1,{fileName:"C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:127,columnNumber:7},void 0),r("ecommerce.add_to_cart")]},void 0,!0,{fileName:"C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:126,columnNumber:5},void 0)};exports.AddToCartButton=j;
|
|
@@ -1,56 +1,76 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsxDEV as s } from "react/jsx-dev-runtime";
|
|
3
3
|
import { Button as o } from "@nextblock-cms/ui/button";
|
|
4
|
-
import { ShoppingCart as n } from "lucide-react";
|
|
5
|
-
import { toast as
|
|
6
|
-
import
|
|
7
|
-
import { useCart as
|
|
8
|
-
import { useTranslations as
|
|
9
|
-
import { isDigitalProduct as
|
|
10
|
-
import { useCurrency as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
import { Mail as C, ShoppingCart as n } from "lucide-react";
|
|
5
|
+
import { toast as m } from "sonner";
|
|
6
|
+
import c from "next/link";
|
|
7
|
+
import { useCart as h } from "../use-cart.es.js";
|
|
8
|
+
import { useTranslations as v } from "@nextblock-cms/utils";
|
|
9
|
+
import { isDigitalProduct as x, getProductPaymentProvider as B } from "../types.es.js";
|
|
10
|
+
import { useCurrency as g } from "../CurrencyProvider.es.js";
|
|
11
|
+
import { useCanPurchase as T } from "../PaymentReadinessProvider.es.js";
|
|
12
|
+
const q = ({ product: e, className: i, quantity: d }) => {
|
|
13
|
+
const a = h((r) => r), { t } = v(), { activeCurrencyCode: u } = g(), _ = T(e), l = x(e), f = !!e.has_variants && !e.variant_id && !l, N = !l && typeof e.stock == "number" && e.stock <= 0;
|
|
14
|
+
if (!_) {
|
|
15
|
+
const r = t("ecommerce.contact_seller");
|
|
16
|
+
return /* @__PURE__ */ s(o, { asChild: !0, variant: "outline", className: i, children: /* @__PURE__ */ s(c, { href: `/product/${e.slug}#contact-seller`, children: [
|
|
17
|
+
/* @__PURE__ */ s(C, { className: "mr-2 h-4 w-4" }, void 0, !1, {
|
|
18
|
+
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
19
|
+
lineNumber: 46,
|
|
20
|
+
columnNumber: 11
|
|
21
|
+
}, void 0),
|
|
22
|
+
r === "ecommerce.contact_seller" ? "Contact the seller" : r
|
|
23
|
+
] }, void 0, !0, {
|
|
24
|
+
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
25
|
+
lineNumber: 45,
|
|
26
|
+
columnNumber: 9
|
|
27
|
+
}, void 0) }, void 0, !1, {
|
|
28
|
+
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
29
|
+
lineNumber: 44,
|
|
30
|
+
columnNumber: 7
|
|
31
|
+
}, void 0);
|
|
32
|
+
}
|
|
33
|
+
if (f)
|
|
34
|
+
return /* @__PURE__ */ s(o, { asChild: !0, className: i, children: /* @__PURE__ */ s(c, { href: `/product/${e.slug}`, children: "Select Options" }, void 0, !1, {
|
|
15
35
|
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
16
|
-
lineNumber:
|
|
36
|
+
lineNumber: 56,
|
|
17
37
|
columnNumber: 9
|
|
18
38
|
}, void 0) }, void 0, !1, {
|
|
19
39
|
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
20
|
-
lineNumber:
|
|
40
|
+
lineNumber: 55,
|
|
21
41
|
columnNumber: 7
|
|
22
42
|
}, void 0);
|
|
23
|
-
if (
|
|
24
|
-
const r =
|
|
25
|
-
return /* @__PURE__ */ s(o, { disabled: !0, className:
|
|
43
|
+
if (N) {
|
|
44
|
+
const r = t("ecommerce.out_of_stock");
|
|
45
|
+
return /* @__PURE__ */ s(o, { disabled: !0, className: i, children: [
|
|
26
46
|
/* @__PURE__ */ s(n, { className: "mr-2 h-4 w-4" }, void 0, !1, {
|
|
27
47
|
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
28
|
-
lineNumber:
|
|
48
|
+
lineNumber: 66,
|
|
29
49
|
columnNumber: 9
|
|
30
50
|
}, void 0),
|
|
31
51
|
r === "ecommerce.out_of_stock" ? "Out of stock" : r
|
|
32
52
|
] }, void 0, !0, {
|
|
33
53
|
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
34
|
-
lineNumber:
|
|
54
|
+
lineNumber: 65,
|
|
35
55
|
columnNumber: 7
|
|
36
56
|
}, void 0);
|
|
37
57
|
}
|
|
38
58
|
if (!a)
|
|
39
|
-
return /* @__PURE__ */ s(o, { disabled: !0, className:
|
|
59
|
+
return /* @__PURE__ */ s(o, { disabled: !0, className: i, children: [
|
|
40
60
|
/* @__PURE__ */ s(n, { className: "mr-2 h-4 w-4" }, void 0, !1, {
|
|
41
61
|
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
42
|
-
lineNumber:
|
|
62
|
+
lineNumber: 77,
|
|
43
63
|
columnNumber: 9
|
|
44
64
|
}, void 0),
|
|
45
|
-
|
|
65
|
+
t("ecommerce.add_to_cart")
|
|
46
66
|
] }, void 0, !0, {
|
|
47
67
|
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
48
|
-
lineNumber:
|
|
68
|
+
lineNumber: 76,
|
|
49
69
|
columnNumber: 7
|
|
50
70
|
}, void 0);
|
|
51
|
-
const { addItem:
|
|
71
|
+
const { addItem: b } = a;
|
|
52
72
|
return /* @__PURE__ */ s(o, { onClick: () => {
|
|
53
|
-
const r =
|
|
73
|
+
const r = B(e) ?? "stripe", { success: p, error: k } = b({
|
|
54
74
|
id: e.variant_id || e.id,
|
|
55
75
|
product_id: e.id,
|
|
56
76
|
title: e.title,
|
|
@@ -77,23 +97,23 @@ const O = ({ product: e, className: t, quantity: d }) => {
|
|
|
77
97
|
variant_id: e.variant_id,
|
|
78
98
|
variant_label: e.variant_label,
|
|
79
99
|
selected_options: e.selected_options,
|
|
80
|
-
currency_code:
|
|
100
|
+
currency_code: u,
|
|
81
101
|
quantity: d
|
|
82
102
|
});
|
|
83
|
-
|
|
84
|
-
}, className:
|
|
103
|
+
p ? m.success(t("ecommerce.added_to_cart_success", { item: e.title })) : m.error(k || t("ecommerce.added_to_cart_error"));
|
|
104
|
+
}, className: i, children: [
|
|
85
105
|
/* @__PURE__ */ s(n, { className: "mr-2 h-4 w-4" }, void 0, !1, {
|
|
86
106
|
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
87
|
-
lineNumber:
|
|
107
|
+
lineNumber: 127,
|
|
88
108
|
columnNumber: 7
|
|
89
109
|
}, void 0),
|
|
90
|
-
|
|
110
|
+
t("ecommerce.add_to_cart")
|
|
91
111
|
] }, void 0, !0, {
|
|
92
112
|
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
93
|
-
lineNumber:
|
|
113
|
+
lineNumber: 126,
|
|
94
114
|
columnNumber: 5
|
|
95
115
|
}, void 0);
|
|
96
116
|
};
|
|
97
117
|
export {
|
|
98
|
-
|
|
118
|
+
q as AddToCartButton
|
|
99
119
|
};
|