@nextblock-cms/ecom 0.19.2 → 0.19.3
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/lib/components/Cart.cjs.js +1 -1
- package/lib/components/Cart.d.ts +1 -1
- package/lib/components/Cart.es.js +70 -62
- package/lib/components/Checkout.cjs.js +1 -1
- package/lib/components/Checkout.d.ts +1 -1
- package/lib/components/Checkout.es.js +224 -212
- package/lib/components/CustomerProfileForm.d.ts +1 -1
- package/lib/components/FeaturedProduct.cjs.js +1 -1
- package/lib/components/FeaturedProduct.es.js +29 -22
- package/lib/components/ProductDetailsLayout.cjs.js +1 -1
- package/lib/components/ProductDetailsLayout.es.js +27 -28
- package/lib/components/ShippingEstimator.cjs.js +1 -1
- package/lib/components/ShippingEstimator.es.js +64 -58
- package/lib/components/ShortDescription.cjs.js +1 -0
- package/lib/components/ShortDescription.d.ts +19 -0
- package/lib/components/ShortDescription.es.js +18 -0
- package/lib/components/media/MediaPickerDialog.d.ts +1 -1
- package/lib/components/media/MediaUploadForm.d.ts +1 -1
- package/lib/order-inventory.d.ts +1 -1
- package/lib/pages/cms/products/actions.d.ts +20 -20
- package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
- package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
- package/lib/product-actions.d.ts +31 -31
- package/lib/shared-inventory.d.ts +1 -1
- package/lib/states.cjs.js +1 -1
- package/lib/states.d.ts +2 -0
- package/lib/states.es.js +63 -29
- package/package.json +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { AccountNavigationLink } from './AccountNavigationMenu';
|
|
3
3
|
import { ProfileUpdateData } from '../server-actions/customer-actions';
|
|
4
|
-
import { Database } from '
|
|
4
|
+
import { Database } from '@nextblock-cms/db';
|
|
5
5
|
type UserRole = Database['public']['Enums']['user_role'];
|
|
6
6
|
export interface ExtendedProfileUpdateData extends ProfileUpdateData {
|
|
7
7
|
role?: UserRole;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),g=require("./AddToCartButton.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),g=require("./AddToCartButton.cjs.js"),v=require("./ShortDescription.cjs.js"),n=require("@nextblock-cms/utils"),b=require("../use-price-formatter.cjs.js"),m=require("next/link"),j=require("../CurrencyProvider.cjs.js"),x=require("../currency.cjs.js"),_=require("../trials.cjs.js"),y=({product:e,className:u,imagePosition:h="left"})=>{const t=b.usePriceFormatter(),{t:i}=n.useTranslations(),{activeCurrencyCode:s,currencies:o}=j.useCurrency(),l=x.resolvePriceRangeForCurrency({entries:e.variants?.length?e.variants:e.product_variants?.length?e.product_variants:[],currencyCode:s,currencies:o}),d=!!(e.has_variants&&l),a=x.resolveEffectivePriceForCurrency({prices:e.prices,salePrices:e.sale_prices,fallbackPrice:e.price,fallbackSalePrice:e.sale_price,saleStartAt:e.sale_start_at,saleEndAt:e.sale_end_at,scheduledPrice:e.scheduled_price,scheduledPrices:e.scheduled_prices,scheduledPriceAt:e.scheduled_price_at,currencyCode:s,currencies:o}),f=d&&l?l.min===l.max?t(l.min,s):`${t(l.min,s)} - ${t(l.max,s)}`:t(a.sale_price??a.price,s),c=_.getTrialSummary(e,i);return r.jsx("div",{className:n.cn("overflow-hidden rounded-xl border bg-card shadow-sm",u),children:r.jsxs("div",{className:n.cn("flex flex-col gap-8 md:flex-row",h==="right"&&"md:flex-row-reverse"),children:[r.jsx("div",{className:"relative aspect-square w-full md:w-1/2",children:e.image_url?r.jsx("img",{src:e.image_url,alt:e.title,width:800,height:800,loading:"lazy",decoding:"async",className:"h-full w-full object-cover"}):r.jsx("div",{className:"flex h-full w-full items-center justify-center bg-secondary text-muted-foreground",children:i("ecommerce.no_image")})}),r.jsxs("div",{className:"flex flex-1 flex-col justify-center p-6 md:p-12",children:[r.jsx(m,{href:`/product/${e.slug}`,children:r.jsx("h2",{className:"mb-4 text-3xl font-bold tracking-tight hover:underline md:text-4xl",children:e.title})}),r.jsxs("div",{className:"mb-6 flex items-baseline gap-3",children:[r.jsx("span",{className:"text-3xl font-bold text-primary",children:f}),!d&&a.sale_price&&r.jsx("span",{className:"text-lg text-muted-foreground line-through",children:t(a.price,s)})]}),c&&r.jsxs("div",{className:"mb-6 inline-flex w-fit flex-col rounded-md border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm text-emerald-900",children:[r.jsx("span",{className:"font-semibold",children:c.label}),r.jsx("span",{className:"text-emerald-700",children:c.paymentRequirementLabel})]}),r.jsx(v.ShortDescription,{value:e.short_description,className:"mb-8 text-lg text-muted-foreground"}),r.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row",children:[r.jsx(g.AddToCartButton,{product:e,className:"h-12 w-full px-8 text-lg sm:w-auto"}),r.jsx(m,{href:`/product/${e.slug}`,className:"inline-flex h-12 items-center justify-center rounded-md border border-input bg-background px-8 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground",children:i("ecommerce.view_details")})]})]})]})})};exports.FeaturedProduct=y;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as r, jsxs as
|
|
3
|
-
import { AddToCartButton as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { jsx as r, jsxs as s } from "react/jsx-runtime";
|
|
3
|
+
import { AddToCartButton as g } from "./AddToCartButton.es.js";
|
|
4
|
+
import { ShortDescription as v } from "./ShortDescription.es.js";
|
|
5
|
+
import { useTranslations as b, cn as d } from "@nextblock-cms/utils";
|
|
6
|
+
import { usePriceFormatter as p } from "../use-price-formatter.es.js";
|
|
6
7
|
import f from "next/link";
|
|
7
|
-
import { useCurrency as
|
|
8
|
-
import { resolvePriceRangeForCurrency as
|
|
9
|
-
import { getTrialSummary as
|
|
10
|
-
const
|
|
11
|
-
const
|
|
8
|
+
import { useCurrency as _ } from "../CurrencyProvider.es.js";
|
|
9
|
+
import { resolvePriceRangeForCurrency as y, resolveEffectivePriceForCurrency as N } from "../currency.es.js";
|
|
10
|
+
import { getTrialSummary as w } from "../trials.es.js";
|
|
11
|
+
const L = ({ product: e, className: h, imagePosition: x = "left" }) => {
|
|
12
|
+
const i = p(), { t: n } = b(), { activeCurrencyCode: l, currencies: m } = _(), a = y({
|
|
12
13
|
entries: e.variants?.length ? e.variants : e.product_variants?.length ? e.product_variants : [],
|
|
13
14
|
currencyCode: l,
|
|
14
15
|
currencies: m
|
|
15
|
-
}), o = !!(e.has_variants && a), t =
|
|
16
|
+
}), o = !!(e.has_variants && a), t = N({
|
|
16
17
|
prices: e.prices,
|
|
17
18
|
salePrices: e.sale_prices,
|
|
18
19
|
fallbackPrice: e.price,
|
|
@@ -24,11 +25,11 @@ const S = ({ product: e, className: h, imagePosition: x = "left" }) => {
|
|
|
24
25
|
scheduledPriceAt: e.scheduled_price_at,
|
|
25
26
|
currencyCode: l,
|
|
26
27
|
currencies: m
|
|
27
|
-
}),
|
|
28
|
+
}), u = o && a ? a.min === a.max ? i(a.min, l) : `${i(a.min, l)} - ${i(
|
|
28
29
|
a.max,
|
|
29
30
|
l
|
|
30
|
-
)}` :
|
|
31
|
-
return /* @__PURE__ */ r("div", { className: d("overflow-hidden rounded-xl border bg-card shadow-sm", h), children: /* @__PURE__ */
|
|
31
|
+
)}` : i(t.sale_price ?? t.price, l), c = w(e, n);
|
|
32
|
+
return /* @__PURE__ */ r("div", { className: d("overflow-hidden rounded-xl border bg-card shadow-sm", h), children: /* @__PURE__ */ s("div", { className: d("flex flex-col gap-8 md:flex-row", x === "right" && "md:flex-row-reverse"), children: [
|
|
32
33
|
/* @__PURE__ */ r("div", { className: "relative aspect-square w-full md:w-1/2", children: e.image_url ? /* @__PURE__ */ r(
|
|
33
34
|
"img",
|
|
34
35
|
{
|
|
@@ -41,20 +42,26 @@ const S = ({ product: e, className: h, imagePosition: x = "left" }) => {
|
|
|
41
42
|
className: "h-full w-full object-cover"
|
|
42
43
|
}
|
|
43
44
|
) : /* @__PURE__ */ r("div", { className: "flex h-full w-full items-center justify-center bg-secondary text-muted-foreground", children: n("ecommerce.no_image") }) }),
|
|
44
|
-
/* @__PURE__ */
|
|
45
|
+
/* @__PURE__ */ s("div", { className: "flex flex-1 flex-col justify-center p-6 md:p-12", children: [
|
|
45
46
|
/* @__PURE__ */ r(f, { href: `/product/${e.slug}`, children: /* @__PURE__ */ r("h2", { className: "mb-4 text-3xl font-bold tracking-tight hover:underline md:text-4xl", children: e.title }) }),
|
|
46
|
-
/* @__PURE__ */
|
|
47
|
-
/* @__PURE__ */ r("span", { className: "text-3xl font-bold text-primary", children:
|
|
48
|
-
!o && t.sale_price && /* @__PURE__ */ r("span", { className: "text-lg text-muted-foreground line-through", children:
|
|
47
|
+
/* @__PURE__ */ s("div", { className: "mb-6 flex items-baseline gap-3", children: [
|
|
48
|
+
/* @__PURE__ */ r("span", { className: "text-3xl font-bold text-primary", children: u }),
|
|
49
|
+
!o && t.sale_price && /* @__PURE__ */ r("span", { className: "text-lg text-muted-foreground line-through", children: i(t.price, l) })
|
|
49
50
|
] }),
|
|
50
|
-
c && /* @__PURE__ */
|
|
51
|
+
c && /* @__PURE__ */ s("div", { className: "mb-6 inline-flex w-fit flex-col rounded-md border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm text-emerald-900", children: [
|
|
51
52
|
/* @__PURE__ */ r("span", { className: "font-semibold", children: c.label }),
|
|
52
53
|
/* @__PURE__ */ r("span", { className: "text-emerald-700", children: c.paymentRequirementLabel })
|
|
53
54
|
] }),
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
/* @__PURE__ */ r(
|
|
56
|
+
v,
|
|
57
|
+
{
|
|
58
|
+
value: e.short_description,
|
|
59
|
+
className: "mb-8 text-lg text-muted-foreground"
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
/* @__PURE__ */ s("div", { className: "flex flex-col gap-4 sm:flex-row", children: [
|
|
56
63
|
/* @__PURE__ */ r(
|
|
57
|
-
|
|
64
|
+
g,
|
|
58
65
|
{
|
|
59
66
|
product: e,
|
|
60
67
|
className: "h-12 w-full px-8 text-lg sm:w-auto"
|
|
@@ -73,5 +80,5 @@ const S = ({ product: e, className: h, imagePosition: x = "left" }) => {
|
|
|
73
80
|
] }) });
|
|
74
81
|
};
|
|
75
82
|
export {
|
|
76
|
-
|
|
83
|
+
L as FeaturedProduct
|
|
77
84
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("react"),I=require("lucide-react"),A=require("@nextblock-cms/ui/badge"),te=require("@nextblock-cms/ui/button"),se=require("@nextblock-cms/ui/label"),re=require("@nextblock-cms/ui/separator"),$=require("@nextblock-cms/utils"),ae=require("../use-price-formatter.cjs.js"),ie=require("../product-context.cjs.js"),ce=require("./ProductGallery.cjs.js"),ne=require("./AddToCartButton.cjs.js"),le=require("./SubscriptionSelector.cjs.js"),D=require("./SimpleTiptapRenderer.cjs.js"),_=require("../variation-utils.cjs.js"),oe=require("../CurrencyProvider.cjs.js"),J=require("../currency.cjs.js"),de=require("../types.cjs.js"),ue=require("../trials.cjs.js");function V(o,v,P,q){const C={kind:"product-field",field:v,input:P,label:q},t=typeof window<"u"?window.location.origin:process.env.NEXT_PUBLIC_URL||process.env.TARGET_URL||(process.env.VERCEL_URL?`https://${process.env.VERCEL_URL}`:"")||"http://localhost:3000";let g=(typeof window<"u"?window.location.origin:process.env.NEXT_PUBLIC_URL||process.env.TARGET_URL||(process.env.VERCEL_URL?`https://${process.env.VERCEL_URL}`:"")||"http://localhost:3000").replace(/\/+$/,"");try{(g.startsWith("http://")||g.startsWith("https://"))&&(g=new URL(g).hostname)}catch{}const N=process.env.NEXTBLOCK_VERCEL_PROJECT_ID||process.env.VERCEL_PROJECT_ID,d=process.env.NEXTBLOCK_VERCEL_WORKSPACE_ID||process.env.VERCEL_ORG_ID,b={origin:g,editUrl:`${t}/cms/products/${o.id}/edit`,data:{parentType:"product",parentId:o.id,slug:o.slug,languageId:o.language_id,draftId:null,target:C}};return N&&(b.projectId=N),d&&(b.workspaceId=d),{"data-vercel-edit-info":JSON.stringify(b),"data-vercel-edit-target":JSON.stringify(C),"data-nextblock-visual-edit":`product:${v}`}}const me=({visualEditingEnabled:o=!1,descriptionNode:v,reviewsNode:P,canPurchase:q=!0,purchaseFallbackNode:C})=>{const t=ie.useProduct(),{t:c,lang:g}=$.useTranslations(),N=ae.usePriceFormatter(),{activeCurrencyCode:d,currencies:b}=oe.useCurrency(),G=o?V(t,"title","plain-text","Product title"):void 0,K=o?V(t,"short_description","plain-text","Short description"):void 0,X=o?V(t,"description_json","tiptap","Product description"):void 0,l=(r,n,m)=>{const p=c(r,m);return p===r?n:p},L=t.images&&t.images.length>0?t.images:t.image_url?[{url:t.image_url,alt:t.title}]:[],j=t.custom_props?.provider==="freemius"||de.isDigitalProduct(t),O=ue.getTrialSummary(t,c),i=!j&&!!(t.has_variants&&t.attributes?.length&&t.variants?.length),f=t.attributes||[],u=t.variants||[],[w,R]=x.useState(()=>_.chooseInitialVariantSelections(f,u)),[U,T]=x.useState(1);x.useEffect(()=>{T(1)},[t.id]),x.useEffect(()=>{i&&R(_.chooseInitialVariantSelections(f,u))},[f,i,t.id,u]);const y=x.useMemo(()=>i?_.normalizeSelectionsToAvailableVariants(f,u,w):w,[f,i,w,u]);x.useEffect(()=>{JSON.stringify(y)!==JSON.stringify(w)&&R(y)},[y,w]);const s=x.useMemo(()=>i?_.findMatchingVariant(u,y):null,[i,y,u]),B=J.resolveEffectivePriceForCurrency({prices:t.prices,salePrices:t.sale_prices,fallbackPrice:t.price,fallbackSalePrice:t.sale_price,saleStartAt:t.sale_start_at,saleEndAt:t.sale_end_at,scheduledPrice:t.scheduled_price,scheduledPrices:t.scheduled_prices,scheduledPriceAt:t.scheduled_price_at,currencyCode:d,currencies:b}),M=i&&s?J.resolveEffectivePriceForCurrency({prices:s.prices,salePrices:s.sale_prices,fallbackPrice:s.price,fallbackSalePrice:s.sale_price,saleStartAt:s.sale_start_at,saleEndAt:s.sale_end_at,scheduledPrice:s.scheduled_price,scheduledPrices:s.scheduled_prices,scheduledPriceAt:s.scheduled_price_at,currencyCode:d,currencies:b}):null,k=M?.price??B.price,S=M?.sale_price??B.sale_price,a=i?s?.stock_quantity??0:t.stock??null,E=a===null||a>0,h=a===null?U:Math.max(1,Math.min(U,Math.max(a,1))),z=x.useMemo(()=>{if(!s?.image_url)return L;const r={url:s.image_url,alt:`${t.title} ${s.label}`},n=L.filter(m=>m.url!==s.image_url);return[r,...n]},[L,t.title,s]),Q=typeof S=="number"&&k>0?Math.round((k-S)/k*100):0,W=i&&s?{...t,sku:s.sku,price:s.price,prices:s.prices,sale_price:typeof s.sale_price=="number"?s.sale_price:null,sale_prices:s.sale_prices,sale_start_at:s.sale_start_at,sale_end_at:s.sale_end_at,scheduled_price:s.scheduled_price,scheduled_prices:s.scheduled_prices,scheduled_price_at:s.scheduled_price_at,image_url:s.image_url||t.image_url,stock:s.stock_quantity,variant_id:s.id,variant_label:s.label,selected_options:s.selected_options,currency_code:d}:{...t,currency_code:d},H=(r,n)=>{R(m=>_.applyVariantSelection(f,u,m,r,n))},Y=a===null?l("ecommerce.in_stock_untracked","In stock"):l("ecommerce.in_stock",`${a} in stock`,{count:String(a)}),F=l("ecommerce.out_of_stock","Out of stock"),Z=l("ecommerce.select_options","Select Options"),ee=l("ecommerce.variant_selection_required","Select one term from every dropdown to resolve a variation.");return e.jsxs("div",{className:"w-full animate-in fade-in slide-in-from-bottom-4 duration-700 ease-out",children:[e.jsx("div",{className:"container mx-auto px-4 md:px-6 py-12",children:e.jsxs("div",{className:"grid gap-12 lg:grid-cols-[2fr_3fr] items-start",children:[e.jsx("div",{className:"w-full max-w-2xl mx-auto lg:max-w-none",children:e.jsx(ce.ProductGallery,{images:z,className:"w-full"})}),e.jsxs("div",{className:"flex flex-col gap-4 pb-2 max-w-xl mx-auto lg:mx-0 lg:max-w-none",children:[e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-3xl sm:text-4xl lg:text-5xl font-extrabold tracking-tight text-foreground leading-[1.1] lg:mt-0",...G,children:t.title}),e.jsx("div",{className:"flex items-center gap-2 mt-2",children:e.jsxs("a",{href:"#reviews-section",className:"flex items-center gap-1.5 group hover:opacity-85 transition-opacity",children:[e.jsx("div",{className:"flex items-center text-amber-500",children:Array.from({length:5}).map((r,n)=>e.jsx("svg",{className:$.cn("h-4 w-4 fill-current",n<Math.round(t.average_rating||0)?"text-amber-500":"text-slate-300 dark:text-slate-700"),viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})},n))}),t.total_reviews&&t.total_reviews>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-semibold text-slate-700 dark:text-slate-300",children:t.average_rating?.toFixed(1)}),e.jsxs("span",{className:"text-sm text-muted-foreground underline decoration-dotted group-hover:text-primary",children:["(",t.total_reviews===1?c("reviews.review_count_one",{count:t.total_reviews}):c("reviews.review_count_other",{count:t.total_reviews}),")"]})]}):e.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-primary underline decoration-dotted",children:c("reviews.be_the_first")})]})}),t.categories&&t.categories.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 text-xs font-bold uppercase tracking-widest text-amber-600 dark:text-amber-400",children:t.categories.map((r,n)=>{const m=_.resolveTranslatedText(r.name,r.name_translations,g);return e.jsxs(x.Fragment,{children:[n>0&&e.jsx("span",{className:"text-muted-foreground/30",children:"•"}),e.jsx("span",{children:m})]},r.id)})}),e.jsx("div",{className:"prose prose-neutral dark:prose-invert max-w-none text-muted-foreground leading-relaxed text-left",...K,children:t.short_description?e.jsx("div",{className:"text-lg mb-4 leading-relaxed",dangerouslySetInnerHTML:{__html:D.toNoCookieEmbedSrc(t.short_description)??t.short_description}}):o?e.jsx("p",{className:"text-lg mb-4 italic text-muted-foreground",children:"Add a short product description."}):null}),e.jsxs("div",{className:"flex items-center gap-3",children:[typeof S=="number"&&e.jsx(A.Badge,{variant:"destructive",className:"px-2.5 py-1 text-xs font-bold uppercase tracking-wide animate-pulse shadow-sm",children:c("ecommerce.sale_badge",{percent:String(Q)})}),!j&&a!==null&&a>0&&a<10&&e.jsx(A.Badge,{variant:"outline",className:"text-amber-600 border-amber-200 bg-amber-50",children:c("ecommerce.low_stock",{count:String(a)})}),O&&e.jsx(A.Badge,{variant:"secondary",className:"border border-emerald-200 bg-emerald-50 text-emerald-800",children:O.label})]})]})}),e.jsxs("div",{className:"p-5 rounded-2xl bg-card border border-border/80 shadow-md space-y-4",children:[q?j?e.jsx(le.SubscriptionSelector,{product:t}):e.jsxs("div",{className:"space-y-3.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-widest",children:l("ecommerce.price","Price")}),e.jsxs("div",{className:"flex items-baseline gap-2.5",children:[e.jsx("span",{className:"text-3xl font-extrabold text-foreground",children:N(S??k,d)}),typeof S=="number"&&e.jsx("span",{className:"text-lg text-muted-foreground line-through decoration-destructive/20 decoration-1",children:N(k,d)})]})]}),!j&&(s||!i)&&e.jsxs("div",{className:"text-right space-y-1",children:[e.jsxs("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-widest block",children:[!i&&t.sku&&e.jsxs("span",{className:"mr-2 font-normal lowercase normal-case text-muted-foreground/70",children:[l("ecommerce.sku","SKU"),": ",t.sku]}),l("ecommerce.status","Status")]}),e.jsx("div",{className:E?"text-emerald-600 dark:text-emerald-400 font-semibold text-sm":"text-destructive font-semibold text-sm",children:E?Y:F})]})]}),i&&e.jsx("div",{className:"space-y-3",children:e.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:f.map((r,n)=>{const m=_.getAvailableTermIdsForAttribute(u,r.id,{});return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(se.Label,{htmlFor:`attribute-${r.id}`,className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:r.name}),n===0&&s?.sku&&e.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:s.sku})]}),e.jsx("select",{id:`attribute-${r.id}`,className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",value:y[r.id]||"",onChange:p=>H(r.id,p.target.value),children:r.terms.map(p=>e.jsx("option",{value:p.id,disabled:!m.has(p.id),children:p.value},p.id))})]},r.id)})})}),i&&!s&&e.jsx("p",{className:"text-xs text-muted-foreground italic pt-1",children:ee}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[!j&&E&&e.jsxs("div",{role:"group","aria-label":l("ecommerce.quantity","Quantity"),className:"flex items-center border rounded-lg h-12 bg-background border-input select-none",children:[e.jsx("button",{type:"button",onClick:()=>T(Math.max(1,h-1)),"aria-label":l("ecommerce.decrease_quantity","Decrease quantity"),className:"px-3 h-full flex items-center justify-center rounded-l-lg text-muted-foreground hover:text-foreground active:scale-95 transition-colors text-lg font-medium focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",disabled:h<=1,children:e.jsx("span",{"aria-hidden":"true",children:"-"})}),e.jsx("span",{"aria-live":"polite","aria-atomic":"true",className:"w-8 text-center text-sm font-semibold tabular-nums",children:h}),e.jsx("button",{type:"button",onClick:()=>T(a!==null&&h>=a?h:h+1),"aria-label":l("ecommerce.increase_quantity","Increase quantity"),className:"px-3 h-full flex items-center justify-center rounded-r-lg text-muted-foreground hover:text-foreground active:scale-95 transition-colors text-lg font-medium focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",disabled:a!==null&&h>=a,children:e.jsx("span",{"aria-hidden":"true",children:"+"})})]}),i&&(!s||!E)?e.jsx(te.Button,{disabled:!0,className:"flex-1 h-12 text-md font-bold shadow-md",children:s?F:Z}):e.jsx(ne.AddToCartButton,{product:W,quantity:h,className:"flex-1 h-12 text-base font-bold shadow-md transition-shadow hover:shadow-lg active:scale-[0.98]"})]})]}):C,e.jsx(re.Separator,{className:"opacity-60 my-0.5"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-center text-[11px] font-medium text-muted-foreground pt-1",children:[e.jsx("div",{className:"flex items-center justify-center gap-2",children:j?e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(I.Download,{className:"h-3.5 w-3.5"}),c("ecommerce.instant_digital_delivery")]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(I.Package,{className:"h-3.5 w-3.5"}),c("ecommerce.free_shipping")]})}),e.jsx("div",{className:"flex items-center justify-center gap-2",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(I.ShieldCheck,{className:"h-3.5 w-3.5"}),c("ecommerce.secure_checkout")]})})]})]})]})]})}),e.jsx("div",{className:"min-w-0 w-full",...v?void 0:X,children:v||(t.description_json?e.jsx("div",{className:"container mx-auto px-4 md:px-6 pb-12 prose prose-neutral dark:prose-invert max-w-none leading-relaxed",children:e.jsx(D.SimpleTiptapRenderer,{content:t.description_json})}):e.jsx("div",{className:"container mx-auto px-4 md:px-6 pb-12",children:e.jsx("p",{className:"italic text-sm text-muted-foreground",children:c("ecommerce.no_description")})}))}),P&&e.jsx("div",{id:"reviews-section",className:"border-t border-border mt-12 pt-12",children:P})]})};exports.ProductDetailsLayout=me;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("react"),I=require("lucide-react"),A=require("@nextblock-cms/ui/badge"),ee=require("@nextblock-cms/ui/button"),te=require("@nextblock-cms/ui/label"),se=require("@nextblock-cms/ui/separator"),F=require("@nextblock-cms/utils"),re=require("../use-price-formatter.cjs.js"),ae=require("../product-context.cjs.js"),ie=require("./ProductGallery.cjs.js"),ce=require("./AddToCartButton.cjs.js"),ne=require("./SubscriptionSelector.cjs.js"),le=require("./SimpleTiptapRenderer.cjs.js"),oe=require("./ShortDescription.cjs.js"),v=require("../variation-utils.cjs.js"),de=require("../CurrencyProvider.cjs.js"),$=require("../currency.cjs.js"),ue=require("../types.cjs.js"),me=require("../trials.cjs.js");function V(o,_,P,E){const C={kind:"product-field",field:_,input:P,label:E},t=typeof window<"u"?window.location.origin:process.env.NEXT_PUBLIC_URL||process.env.TARGET_URL||(process.env.VERCEL_URL?`https://${process.env.VERCEL_URL}`:"")||"http://localhost:3000";let g=(typeof window<"u"?window.location.origin:process.env.NEXT_PUBLIC_URL||process.env.TARGET_URL||(process.env.VERCEL_URL?`https://${process.env.VERCEL_URL}`:"")||"http://localhost:3000").replace(/\/+$/,"");try{(g.startsWith("http://")||g.startsWith("https://"))&&(g=new URL(g).hostname)}catch{}const N=process.env.NEXTBLOCK_VERCEL_PROJECT_ID||process.env.VERCEL_PROJECT_ID,d=process.env.NEXTBLOCK_VERCEL_WORKSPACE_ID||process.env.VERCEL_ORG_ID,b={origin:g,editUrl:`${t}/cms/products/${o.id}/edit`,data:{parentType:"product",parentId:o.id,slug:o.slug,languageId:o.language_id,draftId:null,target:C}};return N&&(b.projectId=N),d&&(b.workspaceId=d),{"data-vercel-edit-info":JSON.stringify(b),"data-vercel-edit-target":JSON.stringify(C),"data-nextblock-visual-edit":`product:${_}`}}const pe=({visualEditingEnabled:o=!1,descriptionNode:_,reviewsNode:P,canPurchase:E=!0,purchaseFallbackNode:C})=>{const t=ae.useProduct(),{t:c,lang:g}=F.useTranslations(),N=re.usePriceFormatter(),{activeCurrencyCode:d,currencies:b}=de.useCurrency(),J=o?V(t,"title","plain-text","Product title"):void 0,G=o?V(t,"short_description","plain-text","Short description"):void 0,K=o?V(t,"description_json","tiptap","Product description"):void 0,l=(r,n,m)=>{const p=c(r,m);return p===r?n:p},L=t.images&&t.images.length>0?t.images:t.image_url?[{url:t.image_url,alt:t.title}]:[],j=t.custom_props?.provider==="freemius"||ue.isDigitalProduct(t),O=me.getTrialSummary(t,c),i=!j&&!!(t.has_variants&&t.attributes?.length&&t.variants?.length),f=t.attributes||[],u=t.variants||[],[w,R]=x.useState(()=>v.chooseInitialVariantSelections(f,u)),[U,T]=x.useState(1);x.useEffect(()=>{T(1)},[t.id]),x.useEffect(()=>{i&&R(v.chooseInitialVariantSelections(f,u))},[f,i,t.id,u]);const y=x.useMemo(()=>i?v.normalizeSelectionsToAvailableVariants(f,u,w):w,[f,i,w,u]);x.useEffect(()=>{JSON.stringify(y)!==JSON.stringify(w)&&R(y)},[y,w]);const s=x.useMemo(()=>i?v.findMatchingVariant(u,y):null,[i,y,u]),B=$.resolveEffectivePriceForCurrency({prices:t.prices,salePrices:t.sale_prices,fallbackPrice:t.price,fallbackSalePrice:t.sale_price,saleStartAt:t.sale_start_at,saleEndAt:t.sale_end_at,scheduledPrice:t.scheduled_price,scheduledPrices:t.scheduled_prices,scheduledPriceAt:t.scheduled_price_at,currencyCode:d,currencies:b}),D=i&&s?$.resolveEffectivePriceForCurrency({prices:s.prices,salePrices:s.sale_prices,fallbackPrice:s.price,fallbackSalePrice:s.sale_price,saleStartAt:s.sale_start_at,saleEndAt:s.sale_end_at,scheduledPrice:s.scheduled_price,scheduledPrices:s.scheduled_prices,scheduledPriceAt:s.scheduled_price_at,currencyCode:d,currencies:b}):null,k=D?.price??B.price,S=D?.sale_price??B.sale_price,a=i?s?.stock_quantity??0:t.stock??null,q=a===null||a>0,h=a===null?U:Math.max(1,Math.min(U,Math.max(a,1))),X=x.useMemo(()=>{if(!s?.image_url)return L;const r={url:s.image_url,alt:`${t.title} ${s.label}`},n=L.filter(m=>m.url!==s.image_url);return[r,...n]},[L,t.title,s]),z=typeof S=="number"&&k>0?Math.round((k-S)/k*100):0,Q=i&&s?{...t,sku:s.sku,price:s.price,prices:s.prices,sale_price:typeof s.sale_price=="number"?s.sale_price:null,sale_prices:s.sale_prices,sale_start_at:s.sale_start_at,sale_end_at:s.sale_end_at,scheduled_price:s.scheduled_price,scheduled_prices:s.scheduled_prices,scheduled_price_at:s.scheduled_price_at,image_url:s.image_url||t.image_url,stock:s.stock_quantity,variant_id:s.id,variant_label:s.label,selected_options:s.selected_options,currency_code:d}:{...t,currency_code:d},W=(r,n)=>{R(m=>v.applyVariantSelection(f,u,m,r,n))},H=a===null?l("ecommerce.in_stock_untracked","In stock"):l("ecommerce.in_stock",`${a} in stock`,{count:String(a)}),M=l("ecommerce.out_of_stock","Out of stock"),Y=l("ecommerce.select_options","Select Options"),Z=l("ecommerce.variant_selection_required","Select one term from every dropdown to resolve a variation.");return e.jsxs("div",{className:"w-full animate-in fade-in slide-in-from-bottom-4 duration-700 ease-out",children:[e.jsx("div",{className:"container mx-auto px-4 md:px-6 py-12",children:e.jsxs("div",{className:"grid gap-12 lg:grid-cols-[2fr_3fr] items-start",children:[e.jsx("div",{className:"w-full max-w-2xl mx-auto lg:max-w-none",children:e.jsx(ie.ProductGallery,{images:X,className:"w-full"})}),e.jsxs("div",{className:"flex flex-col gap-4 pb-2 max-w-xl mx-auto lg:mx-0 lg:max-w-none",children:[e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-3xl sm:text-4xl lg:text-5xl font-extrabold tracking-tight text-foreground leading-[1.1] lg:mt-0",...J,children:t.title}),e.jsx("div",{className:"flex items-center gap-2 mt-2",children:e.jsxs("a",{href:"#reviews-section",className:"flex items-center gap-1.5 group hover:opacity-85 transition-opacity",children:[e.jsx("div",{className:"flex items-center text-amber-500",children:Array.from({length:5}).map((r,n)=>e.jsx("svg",{className:F.cn("h-4 w-4 fill-current",n<Math.round(t.average_rating||0)?"text-amber-500":"text-slate-300 dark:text-slate-700"),viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})},n))}),t.total_reviews&&t.total_reviews>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-semibold text-slate-700 dark:text-slate-300",children:t.average_rating?.toFixed(1)}),e.jsxs("span",{className:"text-sm text-muted-foreground underline decoration-dotted group-hover:text-primary",children:["(",t.total_reviews===1?c("reviews.review_count_one",{count:t.total_reviews}):c("reviews.review_count_other",{count:t.total_reviews}),")"]})]}):e.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-primary underline decoration-dotted",children:c("reviews.be_the_first")})]})}),t.categories&&t.categories.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 text-xs font-bold uppercase tracking-widest text-amber-600 dark:text-amber-400",children:t.categories.map((r,n)=>{const m=v.resolveTranslatedText(r.name,r.name_translations,g);return e.jsxs(x.Fragment,{children:[n>0&&e.jsx("span",{className:"text-muted-foreground/30",children:"•"}),e.jsx("span",{children:m})]},r.id)})}),e.jsx("div",{className:"prose prose-neutral dark:prose-invert max-w-none text-muted-foreground leading-relaxed text-left",...G,children:t.short_description?e.jsx(oe.ShortDescription,{value:t.short_description,className:"text-lg mb-4 leading-relaxed"}):o?e.jsx("p",{className:"text-lg mb-4 italic text-muted-foreground",children:"Add a short product description."}):null}),e.jsxs("div",{className:"flex items-center gap-3",children:[typeof S=="number"&&e.jsx(A.Badge,{variant:"destructive",className:"px-2.5 py-1 text-xs font-bold uppercase tracking-wide animate-pulse shadow-sm",children:c("ecommerce.sale_badge",{percent:String(z)})}),!j&&a!==null&&a>0&&a<10&&e.jsx(A.Badge,{variant:"outline",className:"text-amber-600 border-amber-200 bg-amber-50",children:c("ecommerce.low_stock",{count:String(a)})}),O&&e.jsx(A.Badge,{variant:"secondary",className:"border border-emerald-200 bg-emerald-50 text-emerald-800",children:O.label})]})]})}),e.jsxs("div",{className:"p-5 rounded-2xl bg-card border border-border/80 shadow-md space-y-4",children:[E?j?e.jsx(ne.SubscriptionSelector,{product:t}):e.jsxs("div",{className:"space-y-3.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-widest",children:l("ecommerce.price","Price")}),e.jsxs("div",{className:"flex items-baseline gap-2.5",children:[e.jsx("span",{className:"text-3xl font-extrabold text-foreground",children:N(S??k,d)}),typeof S=="number"&&e.jsx("span",{className:"text-lg text-muted-foreground line-through decoration-destructive/20 decoration-1",children:N(k,d)})]})]}),!j&&(s||!i)&&e.jsxs("div",{className:"text-right space-y-1",children:[e.jsxs("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-widest block",children:[!i&&t.sku&&e.jsxs("span",{className:"mr-2 font-normal lowercase normal-case text-muted-foreground/70",children:[l("ecommerce.sku","SKU"),": ",t.sku]}),l("ecommerce.status","Status")]}),e.jsx("div",{className:q?"text-emerald-600 dark:text-emerald-400 font-semibold text-sm":"text-destructive font-semibold text-sm",children:q?H:M})]})]}),i&&e.jsx("div",{className:"space-y-3",children:e.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:f.map((r,n)=>{const m=v.getAvailableTermIdsForAttribute(u,r.id,{});return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(te.Label,{htmlFor:`attribute-${r.id}`,className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:r.name}),n===0&&s?.sku&&e.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:s.sku})]}),e.jsx("select",{id:`attribute-${r.id}`,className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",value:y[r.id]||"",onChange:p=>W(r.id,p.target.value),children:r.terms.map(p=>e.jsx("option",{value:p.id,disabled:!m.has(p.id),children:p.value},p.id))})]},r.id)})})}),i&&!s&&e.jsx("p",{className:"text-xs text-muted-foreground italic pt-1",children:Z}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[!j&&q&&e.jsxs("div",{role:"group","aria-label":l("ecommerce.quantity","Quantity"),className:"flex items-center border rounded-lg h-12 bg-background border-input select-none",children:[e.jsx("button",{type:"button",onClick:()=>T(Math.max(1,h-1)),"aria-label":l("ecommerce.decrease_quantity","Decrease quantity"),className:"px-3 h-full flex items-center justify-center rounded-l-lg text-muted-foreground hover:text-foreground active:scale-95 transition-colors text-lg font-medium focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",disabled:h<=1,children:e.jsx("span",{"aria-hidden":"true",children:"-"})}),e.jsx("span",{"aria-live":"polite","aria-atomic":"true",className:"w-8 text-center text-sm font-semibold tabular-nums",children:h}),e.jsx("button",{type:"button",onClick:()=>T(a!==null&&h>=a?h:h+1),"aria-label":l("ecommerce.increase_quantity","Increase quantity"),className:"px-3 h-full flex items-center justify-center rounded-r-lg text-muted-foreground hover:text-foreground active:scale-95 transition-colors text-lg font-medium focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",disabled:a!==null&&h>=a,children:e.jsx("span",{"aria-hidden":"true",children:"+"})})]}),i&&(!s||!q)?e.jsx(ee.Button,{disabled:!0,className:"flex-1 h-12 text-md font-bold shadow-md",children:s?M:Y}):e.jsx(ce.AddToCartButton,{product:Q,quantity:h,className:"flex-1 h-12 text-base font-bold shadow-md transition-shadow hover:shadow-lg active:scale-[0.98]"})]})]}):C,e.jsx(se.Separator,{className:"opacity-60 my-0.5"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-center text-[11px] font-medium text-muted-foreground pt-1",children:[e.jsx("div",{className:"flex items-center justify-center gap-2",children:j?e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(I.Download,{className:"h-3.5 w-3.5"}),c("ecommerce.instant_digital_delivery")]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(I.Package,{className:"h-3.5 w-3.5"}),c("ecommerce.free_shipping")]})}),e.jsx("div",{className:"flex items-center justify-center gap-2",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(I.ShieldCheck,{className:"h-3.5 w-3.5"}),c("ecommerce.secure_checkout")]})})]})]})]})]})}),e.jsx("div",{className:"min-w-0 w-full",..._?void 0:K,children:_||(t.description_json?e.jsx("div",{className:"container mx-auto px-4 md:px-6 pb-12 prose prose-neutral dark:prose-invert max-w-none leading-relaxed",children:e.jsx(le.SimpleTiptapRenderer,{content:t.description_json})}):e.jsx("div",{className:"container mx-auto px-4 md:px-6 pb-12",children:e.jsx("p",{className:"italic text-sm text-muted-foreground",children:c("ecommerce.no_description")})}))}),P&&e.jsx("div",{id:"reviews-section",className:"border-t border-border mt-12 pt-12",children:P})]})};exports.ProductDetailsLayout=pe;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsxs as a, jsx as t, Fragment as te } from "react/jsx-runtime";
|
|
3
|
-
import re, { useState as
|
|
3
|
+
import re, { useState as F, useEffect as A, useMemo as V } from "react";
|
|
4
4
|
import { Download as ae, Package as se, ShieldCheck as ie } from "lucide-react";
|
|
5
5
|
import { Badge as O } from "@nextblock-cms/ui/badge";
|
|
6
6
|
import { Button as ce } from "@nextblock-cms/ui/button";
|
|
@@ -12,16 +12,17 @@ import { useProduct as ue } from "../product-context.es.js";
|
|
|
12
12
|
import { ProductGallery as pe } from "./ProductGallery.es.js";
|
|
13
13
|
import { AddToCartButton as he } from "./AddToCartButton.es.js";
|
|
14
14
|
import { SubscriptionSelector as fe } from "./SubscriptionSelector.es.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import { SimpleTiptapRenderer as ge } from "./SimpleTiptapRenderer.es.js";
|
|
16
|
+
import { ShortDescription as xe } from "./ShortDescription.es.js";
|
|
17
|
+
import { chooseInitialVariantSelections as M, normalizeSelectionsToAvailableVariants as ve, findMatchingVariant as _e, resolveTranslatedText as be, getAvailableTermIdsForAttribute as Ne, applyVariantSelection as ye } from "../variation-utils.es.js";
|
|
17
18
|
import { useCurrency as we } from "../CurrencyProvider.es.js";
|
|
18
19
|
import { resolveEffectivePriceForCurrency as J } from "../currency.es.js";
|
|
19
20
|
import { isDigitalProduct as ke } from "../types.es.js";
|
|
20
21
|
import { getTrialSummary as Se } from "../trials.es.js";
|
|
21
|
-
function U(d,
|
|
22
|
+
function U(d, v, P, E) {
|
|
22
23
|
const C = {
|
|
23
24
|
kind: "product-field",
|
|
24
|
-
field:
|
|
25
|
+
field: v,
|
|
25
26
|
input: P,
|
|
26
27
|
label: E
|
|
27
28
|
}, e = typeof window < "u" ? window.location.origin : process.env.NEXT_PUBLIC_URL || process.env.TARGET_URL || (process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : "") || "http://localhost:3000";
|
|
@@ -30,7 +31,7 @@ function U(d, _, P, E) {
|
|
|
30
31
|
(g.startsWith("http://") || g.startsWith("https://")) && (g = new URL(g).hostname);
|
|
31
32
|
} catch {
|
|
32
33
|
}
|
|
33
|
-
const y = process.env.NEXTBLOCK_VERCEL_PROJECT_ID || process.env.VERCEL_PROJECT_ID, m = process.env.NEXTBLOCK_VERCEL_WORKSPACE_ID || process.env.VERCEL_ORG_ID,
|
|
34
|
+
const y = process.env.NEXTBLOCK_VERCEL_PROJECT_ID || process.env.VERCEL_PROJECT_ID, m = process.env.NEXTBLOCK_VERCEL_WORKSPACE_ID || process.env.VERCEL_ORG_ID, _ = {
|
|
34
35
|
origin: g,
|
|
35
36
|
editUrl: `${e}/cms/products/${d.id}/edit`,
|
|
36
37
|
data: {
|
|
@@ -42,20 +43,20 @@ function U(d, _, P, E) {
|
|
|
42
43
|
target: C
|
|
43
44
|
}
|
|
44
45
|
};
|
|
45
|
-
return y && (
|
|
46
|
-
"data-vercel-edit-info": JSON.stringify(
|
|
46
|
+
return y && (_.projectId = y), m && (_.workspaceId = m), {
|
|
47
|
+
"data-vercel-edit-info": JSON.stringify(_),
|
|
47
48
|
"data-vercel-edit-target": JSON.stringify(C),
|
|
48
|
-
"data-nextblock-visual-edit": `product:${
|
|
49
|
+
"data-nextblock-visual-edit": `product:${v}`
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
|
-
const
|
|
52
|
+
const Ke = ({
|
|
52
53
|
visualEditingEnabled: d = !1,
|
|
53
|
-
descriptionNode:
|
|
54
|
+
descriptionNode: v,
|
|
54
55
|
reviewsNode: P,
|
|
55
56
|
canPurchase: E = !0,
|
|
56
57
|
purchaseFallbackNode: C
|
|
57
58
|
}) => {
|
|
58
|
-
const e = ue(), { t: n, lang: g } = oe(), y = me(), { activeCurrencyCode: m, currencies:
|
|
59
|
+
const e = ue(), { t: n, lang: g } = oe(), y = me(), { activeCurrencyCode: m, currencies: _ } = we(), G = d ? U(
|
|
59
60
|
e,
|
|
60
61
|
"title",
|
|
61
62
|
"plain-text",
|
|
@@ -73,13 +74,13 @@ const Ge = ({
|
|
|
73
74
|
) : void 0, o = (s, l, p) => {
|
|
74
75
|
const h = n(s, p);
|
|
75
76
|
return h === s ? l : h;
|
|
76
|
-
}, R = e.images && e.images.length > 0 ? e.images : e.image_url ? [{ url: e.image_url, alt: e.title }] : [], b = e.custom_props?.provider === "freemius" || ke(e), j = Se(e, n), c = !b && !!(e.has_variants && e.attributes?.length && e.variants?.length), x = e.attributes || [], u = e.variants || [], [w, T] =
|
|
77
|
+
}, R = e.images && e.images.length > 0 ? e.images : e.image_url ? [{ url: e.image_url, alt: e.title }] : [], b = e.custom_props?.provider === "freemius" || ke(e), j = Se(e, n), c = !b && !!(e.has_variants && e.attributes?.length && e.variants?.length), x = e.attributes || [], u = e.variants || [], [w, T] = F(() => M(x, u)), [q, I] = F(1);
|
|
77
78
|
A(() => {
|
|
78
79
|
I(1);
|
|
79
80
|
}, [e.id]), A(() => {
|
|
80
|
-
c && T(
|
|
81
|
+
c && T(M(x, u));
|
|
81
82
|
}, [x, c, e.id, u]);
|
|
82
|
-
const N = V(() => c ?
|
|
83
|
+
const N = V(() => c ? ve(
|
|
83
84
|
x,
|
|
84
85
|
u,
|
|
85
86
|
w
|
|
@@ -87,7 +88,7 @@ const Ge = ({
|
|
|
87
88
|
A(() => {
|
|
88
89
|
JSON.stringify(N) !== JSON.stringify(w) && T(N);
|
|
89
90
|
}, [N, w]);
|
|
90
|
-
const r = V(() => c ?
|
|
91
|
+
const r = V(() => c ? _e(u, N) : null, [c, N, u]), $ = J({
|
|
91
92
|
prices: e.prices,
|
|
92
93
|
salePrices: e.sale_prices,
|
|
93
94
|
fallbackPrice: e.price,
|
|
@@ -98,7 +99,7 @@ const Ge = ({
|
|
|
98
99
|
scheduledPrices: e.scheduled_prices,
|
|
99
100
|
scheduledPriceAt: e.scheduled_price_at,
|
|
100
101
|
currencyCode: m,
|
|
101
|
-
currencies:
|
|
102
|
+
currencies: _
|
|
102
103
|
}), B = c && r ? J({
|
|
103
104
|
prices: r.prices,
|
|
104
105
|
salePrices: r.sale_prices,
|
|
@@ -110,7 +111,7 @@ const Ge = ({
|
|
|
110
111
|
scheduledPrices: r.scheduled_prices,
|
|
111
112
|
scheduledPriceAt: r.scheduled_price_at,
|
|
112
113
|
currencyCode: m,
|
|
113
|
-
currencies:
|
|
114
|
+
currencies: _
|
|
114
115
|
}) : null, k = B?.price ?? $.price, S = B?.sale_price ?? $.sale_price, i = c ? r?.stock_quantity ?? 0 : e.stock ?? null, L = i === null || i > 0, f = i === null ? q : Math.max(1, Math.min(q, Math.max(i, 1))), z = V(() => {
|
|
115
116
|
if (!r?.image_url)
|
|
116
117
|
return R;
|
|
@@ -151,7 +152,7 @@ const Ge = ({
|
|
|
151
152
|
);
|
|
152
153
|
}, Y = i === null ? o("ecommerce.in_stock_untracked", "In stock") : o("ecommerce.in_stock", `${i} in stock`, {
|
|
153
154
|
count: String(i)
|
|
154
|
-
}),
|
|
155
|
+
}), D = o(
|
|
155
156
|
"ecommerce.out_of_stock",
|
|
156
157
|
"Out of stock"
|
|
157
158
|
), Z = o(
|
|
@@ -221,12 +222,10 @@ const Ge = ({
|
|
|
221
222
|
className: "prose prose-neutral dark:prose-invert max-w-none text-muted-foreground leading-relaxed text-left",
|
|
222
223
|
...K,
|
|
223
224
|
children: e.short_description ? /* @__PURE__ */ t(
|
|
224
|
-
|
|
225
|
+
xe,
|
|
225
226
|
{
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
__html: ge(e.short_description) ?? e.short_description
|
|
229
|
-
}
|
|
227
|
+
value: e.short_description,
|
|
228
|
+
className: "text-lg mb-4 leading-relaxed"
|
|
230
229
|
}
|
|
231
230
|
) : d ? /* @__PURE__ */ t("p", { className: "text-lg mb-4 italic text-muted-foreground", children: "Add a short product description." }) : null
|
|
232
231
|
}
|
|
@@ -284,7 +283,7 @@ const Ge = ({
|
|
|
284
283
|
] }),
|
|
285
284
|
o("ecommerce.status", "Status")
|
|
286
285
|
] }),
|
|
287
|
-
/* @__PURE__ */ t("div", { className: L ? "text-emerald-600 dark:text-emerald-400 font-semibold text-sm" : "text-destructive font-semibold text-sm", children: L ? Y :
|
|
286
|
+
/* @__PURE__ */ t("div", { className: L ? "text-emerald-600 dark:text-emerald-400 font-semibold text-sm" : "text-destructive font-semibold text-sm", children: L ? Y : D })
|
|
288
287
|
] })
|
|
289
288
|
] }),
|
|
290
289
|
c && /* @__PURE__ */ t("div", { className: "space-y-3", children: /* @__PURE__ */ t("div", { className: "grid gap-3 sm:grid-cols-2", children: x.map((s, l) => {
|
|
@@ -370,7 +369,7 @@ const Ge = ({
|
|
|
370
369
|
{
|
|
371
370
|
disabled: !0,
|
|
372
371
|
className: "flex-1 h-12 text-md font-bold shadow-md",
|
|
373
|
-
children: r ?
|
|
372
|
+
children: r ? D : Z
|
|
374
373
|
}
|
|
375
374
|
) : /* @__PURE__ */ t(
|
|
376
375
|
he,
|
|
@@ -399,10 +398,10 @@ const Ge = ({
|
|
|
399
398
|
] })
|
|
400
399
|
] })
|
|
401
400
|
] }) }),
|
|
402
|
-
/* @__PURE__ */ t("div", { className: "min-w-0 w-full", ...
|
|
401
|
+
/* @__PURE__ */ t("div", { className: "min-w-0 w-full", ...v ? void 0 : X, children: v || (e.description_json ? /* @__PURE__ */ t("div", { className: "container mx-auto px-4 md:px-6 pb-12 prose prose-neutral dark:prose-invert max-w-none leading-relaxed", children: /* @__PURE__ */ t(ge, { content: e.description_json }) }) : /* @__PURE__ */ t("div", { className: "container mx-auto px-4 md:px-6 pb-12", children: /* @__PURE__ */ t("p", { className: "italic text-sm text-muted-foreground", children: n("ecommerce.no_description") }) })) }),
|
|
403
402
|
P && /* @__PURE__ */ t("div", { id: "reviews-section", className: "border-t border-border mt-12 pt-12", children: P })
|
|
404
403
|
] });
|
|
405
404
|
};
|
|
406
405
|
export {
|
|
407
|
-
|
|
406
|
+
Ke as ProductDetailsLayout
|
|
408
407
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),L=require("@nextblock-cms/ui/button"),R=require("@nextblock-cms/ui/input"),g=require("@nextblock-cms/ui/label"),d=require("lucide-react"),T=require("../countries.cjs.js"),D=require("../server-actions/shipping-actions.cjs.js"),I=require("@nextblock-cms/utils"),K=require("../use-price-formatter.cjs.js"),m=require("../states.cjs.js"),O=require("../CurrencyProvider.cjs.js"),M=({physicalSubtotal:S})=>{const C=K.usePriceFormatter(),[r,_]=a.useState("CA"),[n,v]=a.useState(""),[b,w]=a.useState(""),[p,j]=a.useState(!1),[o,f]=a.useState(null),[x,h]=a.useState(null),{t:s,lang:c}=I.useTranslations(),{activeCurrencyCode:y}=O.useCurrency(),l=(e,i)=>{const u=s(e);return u===e?i:u},q=m.getStatesForCountry(r),k=m.countryUsesStructuredStates(r),F=a.useMemo(()=>{try{return new Intl.DisplayNames([c],{type:"region"})}catch{return null}},[c]),P=l("select_an_option","Select an option"),E=l("state_province","State / Province"),N=async()=>{j(!0),h(null),f(null);try{const e=await D.getShippingEstimates(S,{country:r,state:n||void 0,postal_code:b},c,y);e.success&&e.methods?f(e.methods):h(e.errorKey?l(e.errorKey,e.error||s("ecommerce.no_rates_found")):e.error||s("ecommerce.no_rates_found"))}catch(e){console.error("[ShippingEstimator] Failed to load rates:",e),h(l("ecommerce.shipping_calculation_failed","We couldn't calculate shipping right now. Please try again."))}finally{j(!1)}};return t.jsxs("div",{className:"space-y-4 rounded-lg border bg-muted/30 p-4 mt-6",children:[t.jsxs("div",{className:"flex items-center gap-2 font-semibold text-sm",children:[t.jsx(d.Truck,{className:"h-4 w-4"}),t.jsx("span",{children:s("ecommerce.estimate_shipping")})]}),t.jsxs("div",{className:"grid gap-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(g.Label,{htmlFor:"estimate-country",className:"text-xs uppercase tracking-wider text-muted-foreground",children:s("ecommerce.country")}),t.jsx("select",{id:"estimate-country",name:"estimate-country",autoComplete:"shipping country",value:r,onChange:e=>{const i=e.target.value,u=m.getStatesForCountry(i);_(i),v(u.some(A=>A.code===n)?n:"")},className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:T.countries.map(e=>t.jsx("option",{value:e.code,children:F?.of(e.code)??e.name},e.code))})]}),k&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(g.Label,{htmlFor:"estimate-state",className:"text-xs uppercase tracking-wider text-muted-foreground",children:s("state_province")}),t.jsxs("select",{id:"estimate-state",name:"estimate-state",autoComplete:"shipping address-level1",value:n,onChange:e=>v(e.target.value),className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:[t.jsx("option",{value:"",children:`${P}: ${E}`}),q.map(e=>t.jsx("option",{value:e.code,children:m.getSubdivisionLabel(r,e,c)},e.code))]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(g.Label,{htmlFor:"estimate-postal",className:"text-xs uppercase tracking-wider text-muted-foreground",children:s("ecommerce.postal_code")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(R.Input,{id:"estimate-postal",name:"estimate-postal",autoComplete:"shipping postal-code",placeholder:r==="CA"?"A1A 1A1":void 0,value:b,onChange:e=>w(e.target.value),onKeyDown:e=>{e.key==="Enter"&&!p&&(e.preventDefault(),N())},className:"h-9 text-sm bg-background"}),t.jsxs(L.Button,{size:"sm",variant:"secondary",onClick:N,disabled:p,className:"shrink-0",children:[p?t.jsx(d.Loader2,{className:"h-4 w-4 mr-1.5 animate-spin"}):t.jsx(d.Calculator,{className:"h-4 w-4 mr-1.5"}),s("ecommerce.calculate")]})]})]})]}),x&&t.jsx("p",{role:"alert",className:"text-xs text-destructive mt-2",children:x}),t.jsxs("div",{"aria-live":"polite",children:[o&&o.length>0&&t.jsxs("div",{className:"mt-4 space-y-2 border-t pt-3",children:[t.jsxs("p",{className:"text-xs font-medium text-muted-foreground uppercase",children:[s("ecommerce.available_rates"),":"]}),o.map(e=>t.jsxs("div",{className:"flex justify-between items-center p-3 border rounded-lg bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(d.Truck,{className:"h-4 w-4 text-muted-foreground"}),t.jsx("span",{className:"text-sm font-medium",children:e.name})]}),t.jsx("span",{className:"text-sm font-bold tabular-nums",children:e.amount===0?s("ecommerce.free"):C(e.amount,y)})]},e.id))]}),o&&o.length===0&&!x&&t.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:s("ecommerce.no_rates_found")})]})]})};exports.ShippingEstimator=M;
|
|
@@ -1,122 +1,128 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsxs as a, jsx as t } from "react/jsx-runtime";
|
|
3
|
-
import { useState as
|
|
4
|
-
import { Button as
|
|
5
|
-
import { Input as
|
|
6
|
-
import { Label as
|
|
7
|
-
import { Truck as
|
|
8
|
-
import { countries as
|
|
9
|
-
import { getShippingEstimates as
|
|
10
|
-
import { useTranslations as
|
|
11
|
-
import { usePriceFormatter as
|
|
12
|
-
import { getStatesForCountry as
|
|
13
|
-
import { useCurrency as
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
return
|
|
18
|
-
}, E =
|
|
19
|
-
x(!0), p(null), v(null);
|
|
3
|
+
import { useState as o, useMemo as I } from "react";
|
|
4
|
+
import { Button as K } from "@nextblock-cms/ui/button";
|
|
5
|
+
import { Input as O } from "@nextblock-cms/ui/input";
|
|
6
|
+
import { Label as g } from "@nextblock-cms/ui/label";
|
|
7
|
+
import { Truck as C, Loader2 as T, Calculator as $ } from "lucide-react";
|
|
8
|
+
import { countries as z } from "../countries.es.js";
|
|
9
|
+
import { getShippingEstimates as B } from "../server-actions/shipping-actions.es.js";
|
|
10
|
+
import { useTranslations as M } from "@nextblock-cms/utils";
|
|
11
|
+
import { usePriceFormatter as R } from "../use-price-formatter.es.js";
|
|
12
|
+
import { getStatesForCountry as _, countryUsesStructuredStates as U, getSubdivisionLabel as W } from "../states.es.js";
|
|
13
|
+
import { useCurrency as q } from "../CurrencyProvider.es.js";
|
|
14
|
+
const se = ({ physicalSubtotal: S }) => {
|
|
15
|
+
const w = R(), [s, k] = o("CA"), [c, f] = o(""), [x, F] = o(""), [u, v] = o(!1), [n, y] = o(null), [p, h] = o(null), { t: r, lang: l } = M(), { activeCurrencyCode: N } = q(), i = (e, m) => {
|
|
16
|
+
const d = r(e);
|
|
17
|
+
return d === e ? m : d;
|
|
18
|
+
}, E = _(s), P = U(s), A = I(() => {
|
|
20
19
|
try {
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
return new Intl.DisplayNames([l], { type: "region" });
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}, [l]), L = i("select_an_option", "Select an option"), j = i("state_province", "State / Province"), b = async () => {
|
|
25
|
+
v(!0), h(null), y(null);
|
|
26
|
+
try {
|
|
27
|
+
const e = await B(
|
|
28
|
+
S,
|
|
23
29
|
{
|
|
24
|
-
country:
|
|
25
|
-
state:
|
|
26
|
-
postal_code:
|
|
30
|
+
country: s,
|
|
31
|
+
state: c || void 0,
|
|
32
|
+
postal_code: x
|
|
27
33
|
},
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
l,
|
|
35
|
+
N
|
|
30
36
|
);
|
|
31
|
-
e.success && e.methods ?
|
|
32
|
-
e.errorKey ?
|
|
37
|
+
e.success && e.methods ? y(e.methods) : h(
|
|
38
|
+
e.errorKey ? i(
|
|
33
39
|
e.errorKey,
|
|
34
40
|
e.error || r("ecommerce.no_rates_found")
|
|
35
41
|
) : e.error || r("ecommerce.no_rates_found")
|
|
36
42
|
);
|
|
37
43
|
} catch (e) {
|
|
38
|
-
console.error("[ShippingEstimator] Failed to load rates:", e),
|
|
39
|
-
|
|
44
|
+
console.error("[ShippingEstimator] Failed to load rates:", e), h(
|
|
45
|
+
i(
|
|
40
46
|
"ecommerce.shipping_calculation_failed",
|
|
41
47
|
"We couldn't calculate shipping right now. Please try again."
|
|
42
48
|
)
|
|
43
49
|
);
|
|
44
50
|
} finally {
|
|
45
|
-
|
|
51
|
+
v(!1);
|
|
46
52
|
}
|
|
47
53
|
};
|
|
48
54
|
return /* @__PURE__ */ a("div", { className: "space-y-4 rounded-lg border bg-muted/30 p-4 mt-6", children: [
|
|
49
55
|
/* @__PURE__ */ a("div", { className: "flex items-center gap-2 font-semibold text-sm", children: [
|
|
50
|
-
/* @__PURE__ */ t(
|
|
56
|
+
/* @__PURE__ */ t(C, { className: "h-4 w-4" }),
|
|
51
57
|
/* @__PURE__ */ t("span", { children: r("ecommerce.estimate_shipping") })
|
|
52
58
|
] }),
|
|
53
59
|
/* @__PURE__ */ a("div", { className: "grid gap-3", children: [
|
|
54
60
|
/* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
|
|
55
|
-
/* @__PURE__ */ t(
|
|
61
|
+
/* @__PURE__ */ t(g, { htmlFor: "estimate-country", className: "text-xs uppercase tracking-wider text-muted-foreground", children: r("ecommerce.country") }),
|
|
56
62
|
/* @__PURE__ */ t(
|
|
57
63
|
"select",
|
|
58
64
|
{
|
|
59
65
|
id: "estimate-country",
|
|
60
66
|
name: "estimate-country",
|
|
61
67
|
autoComplete: "shipping country",
|
|
62
|
-
value:
|
|
68
|
+
value: s,
|
|
63
69
|
onChange: (e) => {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
const m = e.target.value, d = _(m);
|
|
71
|
+
k(m), f(
|
|
72
|
+
d.some((D) => D.code === c) ? c : ""
|
|
67
73
|
);
|
|
68
74
|
},
|
|
69
75
|
className: "flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
|
|
70
|
-
children:
|
|
76
|
+
children: z.map((e) => /* @__PURE__ */ t("option", { value: e.code, children: A?.of(e.code) ?? e.name }, e.code))
|
|
71
77
|
}
|
|
72
78
|
)
|
|
73
79
|
] }),
|
|
74
80
|
P && /* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
|
|
75
|
-
/* @__PURE__ */ t(
|
|
81
|
+
/* @__PURE__ */ t(g, { htmlFor: "estimate-state", className: "text-xs uppercase tracking-wider text-muted-foreground", children: r("state_province") }),
|
|
76
82
|
/* @__PURE__ */ a(
|
|
77
83
|
"select",
|
|
78
84
|
{
|
|
79
85
|
id: "estimate-state",
|
|
80
86
|
name: "estimate-state",
|
|
81
87
|
autoComplete: "shipping address-level1",
|
|
82
|
-
value:
|
|
83
|
-
onChange: (e) =>
|
|
88
|
+
value: c,
|
|
89
|
+
onChange: (e) => f(e.target.value),
|
|
84
90
|
className: "flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
|
|
85
91
|
children: [
|
|
86
|
-
/* @__PURE__ */ t("option", { value: "", children: `${
|
|
87
|
-
E.map((e) => /* @__PURE__ */ t("option", { value: e.code, children: e
|
|
92
|
+
/* @__PURE__ */ t("option", { value: "", children: `${L}: ${j}` }),
|
|
93
|
+
E.map((e) => /* @__PURE__ */ t("option", { value: e.code, children: W(s, e, l) }, e.code))
|
|
88
94
|
]
|
|
89
95
|
}
|
|
90
96
|
)
|
|
91
97
|
] }),
|
|
92
98
|
/* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
|
|
93
|
-
/* @__PURE__ */ t(
|
|
99
|
+
/* @__PURE__ */ t(g, { htmlFor: "estimate-postal", className: "text-xs uppercase tracking-wider text-muted-foreground", children: r("ecommerce.postal_code") }),
|
|
94
100
|
/* @__PURE__ */ a("div", { className: "flex gap-2", children: [
|
|
95
101
|
/* @__PURE__ */ t(
|
|
96
|
-
|
|
102
|
+
O,
|
|
97
103
|
{
|
|
98
104
|
id: "estimate-postal",
|
|
99
105
|
name: "estimate-postal",
|
|
100
106
|
autoComplete: "shipping postal-code",
|
|
101
|
-
placeholder:
|
|
102
|
-
value:
|
|
103
|
-
onChange: (e) =>
|
|
107
|
+
placeholder: s === "CA" ? "A1A 1A1" : void 0,
|
|
108
|
+
value: x,
|
|
109
|
+
onChange: (e) => F(e.target.value),
|
|
104
110
|
onKeyDown: (e) => {
|
|
105
|
-
e.key === "Enter" && !
|
|
111
|
+
e.key === "Enter" && !u && (e.preventDefault(), b());
|
|
106
112
|
},
|
|
107
113
|
className: "h-9 text-sm bg-background"
|
|
108
114
|
}
|
|
109
115
|
),
|
|
110
116
|
/* @__PURE__ */ a(
|
|
111
|
-
|
|
117
|
+
K,
|
|
112
118
|
{
|
|
113
119
|
size: "sm",
|
|
114
120
|
variant: "secondary",
|
|
115
|
-
onClick:
|
|
116
|
-
disabled:
|
|
121
|
+
onClick: b,
|
|
122
|
+
disabled: u,
|
|
117
123
|
className: "shrink-0",
|
|
118
124
|
children: [
|
|
119
|
-
|
|
125
|
+
u ? /* @__PURE__ */ t(T, { className: "h-4 w-4 mr-1.5 animate-spin" }) : /* @__PURE__ */ t($, { className: "h-4 w-4 mr-1.5" }),
|
|
120
126
|
r("ecommerce.calculate")
|
|
121
127
|
]
|
|
122
128
|
}
|
|
@@ -124,25 +130,25 @@ const te = ({ physicalSubtotal: _ }) => {
|
|
|
124
130
|
] })
|
|
125
131
|
] })
|
|
126
132
|
] }),
|
|
127
|
-
|
|
133
|
+
p && /* @__PURE__ */ t("p", { role: "alert", className: "text-xs text-destructive mt-2", children: p }),
|
|
128
134
|
/* @__PURE__ */ a("div", { "aria-live": "polite", children: [
|
|
129
|
-
|
|
135
|
+
n && n.length > 0 && /* @__PURE__ */ a("div", { className: "mt-4 space-y-2 border-t pt-3", children: [
|
|
130
136
|
/* @__PURE__ */ a("p", { className: "text-xs font-medium text-muted-foreground uppercase", children: [
|
|
131
137
|
r("ecommerce.available_rates"),
|
|
132
138
|
":"
|
|
133
139
|
] }),
|
|
134
|
-
|
|
140
|
+
n.map((e) => /* @__PURE__ */ a("div", { className: "flex justify-between items-center p-3 border rounded-lg bg-muted/30", children: [
|
|
135
141
|
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
|
|
136
|
-
/* @__PURE__ */ t(
|
|
142
|
+
/* @__PURE__ */ t(C, { className: "h-4 w-4 text-muted-foreground" }),
|
|
137
143
|
/* @__PURE__ */ t("span", { className: "text-sm font-medium", children: e.name })
|
|
138
144
|
] }),
|
|
139
|
-
/* @__PURE__ */ t("span", { className: "text-sm font-bold tabular-nums", children: e.amount === 0 ? r("ecommerce.free") :
|
|
145
|
+
/* @__PURE__ */ t("span", { className: "text-sm font-bold tabular-nums", children: e.amount === 0 ? r("ecommerce.free") : w(e.amount, N) })
|
|
140
146
|
] }, e.id))
|
|
141
147
|
] }),
|
|
142
|
-
|
|
148
|
+
n && n.length === 0 && !p && /* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground mt-2 italic", children: r("ecommerce.no_rates_found") })
|
|
143
149
|
] })
|
|
144
150
|
] });
|
|
145
151
|
};
|
|
146
152
|
export {
|
|
147
|
-
|
|
153
|
+
se as ShippingEstimator
|
|
148
154
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),o=require("@nextblock-cms/utils"),s=require("./SimpleTiptapRenderer.cjs.js"),c=/<\/?[a-z][^>]*>/i,n=e=>c.test(e);function l({value:e,className:r}){const t=e?.trim();return t?n(t)?i.jsx("div",{className:r,dangerouslySetInnerHTML:{__html:s.toNoCookieEmbedSrc(t)??t}}):i.jsx("p",{className:o.cn("whitespace-pre-line",r),children:t}):null}exports.ShortDescription=l;exports.isHtmlShortDescription=n;
|