@nextblock-cms/ecom 0.19.0 → 0.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +1 -1
- package/index.es.js +26 -25
- package/lib/CurrencyProvider.cjs.js +1 -1
- package/lib/CurrencyProvider.es.js +41 -45
- package/lib/PaymentReadinessProvider.cjs.js +1 -1
- package/lib/PaymentReadinessProvider.es.js +15 -19
- package/lib/cart-store.cjs.js +1 -1
- package/lib/cart-store.d.ts +4 -0
- package/lib/cart-store.es.js +77 -69
- package/lib/components/AccountNavigationMenu.cjs.js +1 -1
- package/lib/components/AccountNavigationMenu.es.js +44 -62
- package/lib/components/AddToCartButton.cjs.js +1 -1
- package/lib/components/AddToCartButton.es.js +50 -78
- package/lib/components/Cart.cjs.js +1 -1
- package/lib/components/Cart.es.js +154 -381
- package/lib/components/CartDrawer.cjs.js +1 -1
- package/lib/components/CartDrawer.es.js +143 -297
- package/lib/components/CartIcon.cjs.js +1 -1
- package/lib/components/CartIcon.es.js +21 -47
- package/lib/components/Checkout.cjs.js +1 -1
- package/lib/components/Checkout.es.js +814 -1614
- package/lib/components/CouponForm.cjs.js +1 -1
- package/lib/components/CouponForm.es.js +104 -155
- package/lib/components/CurrencySwitcher.cjs.js +1 -1
- package/lib/components/CurrencySwitcher.es.js +14 -33
- package/lib/components/CustomerProfileForm.cjs.js +1 -1
- package/lib/components/CustomerProfileForm.es.js +264 -672
- package/lib/components/FeaturedProduct.cjs.js +1 -1
- package/lib/components/FeaturedProduct.es.js +46 -125
- package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
- package/lib/components/FreemiusLicensePanel.es.js +45 -125
- package/lib/components/InvoiceDocument.cjs.js +1 -1
- package/lib/components/InvoiceDocument.es.js +148 -487
- package/lib/components/InvoiceViewerShell.cjs.js +2 -2
- package/lib/components/InvoiceViewerShell.d.ts +4 -1
- package/lib/components/InvoiceViewerShell.es.js +59 -142
- package/lib/components/ProductCard.cjs.js +1 -1
- package/lib/components/ProductCard.d.ts +3 -1
- package/lib/components/ProductCard.es.js +128 -242
- package/lib/components/ProductDetailsLayout.cjs.js +1 -1
- package/lib/components/ProductDetailsLayout.es.js +311 -652
- package/lib/components/ProductGallery.cjs.js +1 -1
- package/lib/components/ProductGallery.d.ts +2 -0
- package/lib/components/ProductGallery.es.js +37 -66
- package/lib/components/ProductGrid.cjs.js +1 -1
- package/lib/components/ProductGrid.es.js +23 -32
- package/lib/components/ShippingEstimator.cjs.js +1 -1
- package/lib/components/ShippingEstimator.es.js +118 -231
- package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
- package/lib/components/SimpleTiptapRenderer.es.js +111 -294
- package/lib/components/SubscriptionSelector.cjs.js +1 -1
- package/lib/components/SubscriptionSelector.es.js +120 -181
- package/lib/invoice.cjs.js +1 -1
- package/lib/invoice.d.ts +1 -1
- package/lib/invoice.es.js +6 -5
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +115 -375
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
- package/lib/pages/cms/coupons/CouponsPage.es.js +116 -368
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +26 -62
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.es.js +35 -71
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +72 -167
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +87 -247
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.es.js +95 -283
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.es.js +9 -21
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.es.js +46 -106
- package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrdersPage.es.js +78 -257
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsClient.es.js +192 -580
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsPage.es.js +14 -22
- package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
- package/lib/pages/cms/products/ProductsPage.es.js +47 -87
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +97 -177
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +40 -84
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +192 -455
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +28 -72
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +183 -490
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +69 -177
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +102 -213
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +25 -45
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +58 -202
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +89 -235
- package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductForm.es.js +526 -1110
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +63 -154
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +213 -544
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +91 -207
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +16 -28
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +25 -37
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.es.js +261 -492
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +12 -32
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +145 -365
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/new/NewProductPage.es.js +30 -42
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
- package/lib/pages/cms/shipping/ShippingPage.es.js +155 -507
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/RateForm.es.js +334 -717
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +158 -392
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
- package/lib/pages/cms/taxes/TaxesPage.es.js +119 -447
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +52 -156
- package/lib/product-context.cjs.js +1 -1
- package/lib/product-context.es.js +10 -14
- package/lib/trials.cjs.js +1 -1
- package/lib/trials.d.ts +10 -3
- package/lib/trials.es.js +28 -21
- package/lib/types.d.ts +2 -0
- package/lib/use-price-formatter.cjs.js +1 -0
- package/lib/use-price-formatter.d.ts +11 -0
- package/lib/use-price-formatter.es.js +13 -0
- package/lib/variation-utils.cjs.js +1 -1
- package/lib/variation-utils.d.ts +10 -0
- package/lib/variation-utils.es.js +139 -123
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("@nextblock-cms/utils"),h=require("react"),s=require("../invoice-ui.cjs.js"),g=({images:r=[],className:n})=>{const{t:a}=i.useTranslations(),[o,d]=h.useState(0);if(!r.length)return e.jsx("div",{className:i.cn("relative aspect-square w-full overflow-hidden rounded-lg bg-secondary",n),children:e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:s.translateOrFallback(a,"ecommerce.no_image","No image")})});const c=o<r.length?o:0,l=r[c];return e.jsxs("div",{className:i.cn("flex flex-col gap-4",n),children:[e.jsx("div",{className:"relative aspect-square w-full overflow-hidden rounded-lg border bg-white",children:e.jsx("img",{src:l.url,alt:l.alt??"",width:l.width??1e3,height:l.height??1e3,fetchPriority:"high",decoding:"async",className:"h-full w-full object-cover object-center"})}),r.length>1&&e.jsx("div",{className:"flex gap-4 overflow-x-auto p-1 pb-2",children:r.map((u,t)=>e.jsx("button",{type:"button",onClick:()=>d(t),"aria-current":c===t?"true":void 0,"aria-label":s.translateOrFallback(a,"ecommerce.gallery_show_image","Show image {index} of {total}").replace("{index}",String(t+1)).replace("{total}",String(r.length)),className:i.cn("relative aspect-square w-20 flex-shrink-0 overflow-hidden rounded-md border focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",c===t?"ring-2 ring-primary":"ring-1 ring-transparent hover:ring-primary/50"),children:e.jsx("img",{src:u.url,alt:"",width:80,height:80,loading:"lazy",decoding:"async",className:"h-full w-full object-cover object-center"})},t))})]})};exports.ProductGallery=g;
|
|
@@ -1,84 +1,55 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import { cn as o } from "@nextblock-cms/utils";
|
|
4
|
-
import { useState as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { jsx as e, jsxs as u } from "react/jsx-runtime";
|
|
3
|
+
import { useTranslations as g, cn as o } from "@nextblock-cms/utils";
|
|
4
|
+
import { useState as f } from "react";
|
|
5
|
+
import { translateOrFallback as s } from "../invoice-ui.es.js";
|
|
6
|
+
const w = ({ images: r = [], className: n }) => {
|
|
7
|
+
const { t: a } = g(), [c, d] = f(0);
|
|
8
|
+
if (!r.length)
|
|
9
|
+
return /* @__PURE__ */ e("div", { className: o("relative aspect-square w-full overflow-hidden rounded-lg bg-secondary", n), children: /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center text-muted-foreground", children: s(a, "ecommerce.no_image", "No image") }) });
|
|
10
|
+
const i = c < r.length ? c : 0, l = r[i];
|
|
11
|
+
return /* @__PURE__ */ u("div", { className: o("flex flex-col gap-4", n), children: [
|
|
10
12
|
/* @__PURE__ */ e("div", { className: "relative aspect-square w-full overflow-hidden rounded-lg border bg-white", children: /* @__PURE__ */ e(
|
|
11
13
|
"img",
|
|
12
14
|
{
|
|
13
|
-
src:
|
|
14
|
-
alt:
|
|
15
|
+
src: l.url,
|
|
16
|
+
alt: l.alt ?? "",
|
|
17
|
+
width: l.width ?? 1e3,
|
|
18
|
+
height: l.height ?? 1e3,
|
|
19
|
+
fetchPriority: "high",
|
|
20
|
+
decoding: "async",
|
|
15
21
|
className: "h-full w-full object-cover object-center"
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/ProductGallery.tsx",
|
|
21
|
-
lineNumber: 32,
|
|
22
|
-
columnNumber: 9
|
|
23
|
-
},
|
|
24
|
-
void 0
|
|
25
|
-
) }, void 0, !1, {
|
|
26
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/ProductGallery.tsx",
|
|
27
|
-
lineNumber: 31,
|
|
28
|
-
columnNumber: 7
|
|
29
|
-
}, void 0),
|
|
30
|
-
r.length > 1 && /* @__PURE__ */ e("div", { className: "flex gap-4 overflow-x-auto pb-2", children: r.map((t, s) => /* @__PURE__ */ e(
|
|
22
|
+
}
|
|
23
|
+
) }),
|
|
24
|
+
r.length > 1 && // p-1: `overflow-x-auto` also clips vertically, which cut off the selection ring.
|
|
25
|
+
/* @__PURE__ */ e("div", { className: "flex gap-4 overflow-x-auto p-1 pb-2", children: r.map((h, t) => /* @__PURE__ */ e(
|
|
31
26
|
"button",
|
|
32
27
|
{
|
|
33
|
-
|
|
28
|
+
type: "button",
|
|
29
|
+
onClick: () => d(t),
|
|
30
|
+
"aria-current": i === t ? "true" : void 0,
|
|
31
|
+
"aria-label": s(a, "ecommerce.gallery_show_image", "Show image {index} of {total}").replace("{index}", String(t + 1)).replace("{total}", String(r.length)),
|
|
34
32
|
className: o(
|
|
35
|
-
"relative aspect-square w-20 flex-shrink-0 overflow-hidden rounded-md border",
|
|
36
|
-
|
|
33
|
+
"relative aspect-square w-20 flex-shrink-0 overflow-hidden rounded-md border focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",
|
|
34
|
+
i === t ? "ring-2 ring-primary" : "ring-1 ring-transparent hover:ring-primary/50"
|
|
37
35
|
),
|
|
38
36
|
children: /* @__PURE__ */ e(
|
|
39
37
|
"img",
|
|
40
38
|
{
|
|
41
|
-
src:
|
|
42
|
-
alt:
|
|
39
|
+
src: h.url,
|
|
40
|
+
alt: "",
|
|
41
|
+
width: 80,
|
|
42
|
+
height: 80,
|
|
43
|
+
loading: "lazy",
|
|
44
|
+
decoding: "async",
|
|
43
45
|
className: "h-full w-full object-cover object-center"
|
|
44
|
-
}
|
|
45
|
-
void 0,
|
|
46
|
-
!1,
|
|
47
|
-
{
|
|
48
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/ProductGallery.tsx",
|
|
49
|
-
lineNumber: 50,
|
|
50
|
-
columnNumber: 15
|
|
51
|
-
},
|
|
52
|
-
void 0
|
|
46
|
+
}
|
|
53
47
|
)
|
|
54
48
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/ProductGallery.tsx",
|
|
59
|
-
lineNumber: 42,
|
|
60
|
-
columnNumber: 13
|
|
61
|
-
},
|
|
62
|
-
void 0
|
|
63
|
-
)) }, void 0, !1, {
|
|
64
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/ProductGallery.tsx",
|
|
65
|
-
lineNumber: 40,
|
|
66
|
-
columnNumber: 9
|
|
67
|
-
}, void 0)
|
|
68
|
-
] }, void 0, !0, {
|
|
69
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/ProductGallery.tsx",
|
|
70
|
-
lineNumber: 30,
|
|
71
|
-
columnNumber: 5
|
|
72
|
-
}, void 0) : /* @__PURE__ */ e("div", { className: o("relative aspect-square w-full overflow-hidden rounded-lg bg-secondary", n), children: /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center text-muted-foreground", children: "No Image" }, void 0, !1, {
|
|
73
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/ProductGallery.tsx",
|
|
74
|
-
lineNumber: 22,
|
|
75
|
-
columnNumber: 9
|
|
76
|
-
}, void 0) }, void 0, !1, {
|
|
77
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/ProductGallery.tsx",
|
|
78
|
-
lineNumber: 21,
|
|
79
|
-
columnNumber: 7
|
|
80
|
-
}, void 0);
|
|
49
|
+
t
|
|
50
|
+
)) })
|
|
51
|
+
] });
|
|
81
52
|
};
|
|
82
53
|
export {
|
|
83
|
-
|
|
54
|
+
w as ProductGallery
|
|
84
55
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),n=require("./ProductCard.cjs.js"),d=require("@nextblock-cms/utils"),u=({products:o,columns:e=3,className:c})=>{const{t:s}=d.useTranslations();if(!o.length){const r=s("ecommerce.no_products_found");return t.jsx("div",{className:"py-12 text-center text-muted-foreground",children:r==="ecommerce.no_products_found"?"No products found.":r})}return t.jsx("div",{className:d.cn("grid gap-6 sm:grid-cols-2",e===3&&"lg:grid-cols-3",e===4&&"lg:grid-cols-4",c),children:o.map((r,i)=>t.jsx(n.ProductCard,{product:r,priority:i<e},r.id))})};exports.ProductGrid=u;
|
|
@@ -1,35 +1,26 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import { ProductCard as
|
|
4
|
-
import { cn as
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
lineNumber: 19,
|
|
25
|
-
columnNumber: 5
|
|
26
|
-
},
|
|
27
|
-
void 0
|
|
28
|
-
) : /* @__PURE__ */ e("div", { className: "py-12 text-center text-muted-foreground", children: "No products found." }, void 0, !1, {
|
|
29
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/ProductGrid.tsx",
|
|
30
|
-
lineNumber: 15,
|
|
31
|
-
columnNumber: 12
|
|
32
|
-
}, void 0);
|
|
2
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { ProductCard as n } from "./ProductCard.es.js";
|
|
4
|
+
import { useTranslations as s, cn as m } from "@nextblock-cms/utils";
|
|
5
|
+
const g = ({ products: t, columns: o = 3, className: d }) => {
|
|
6
|
+
const { t: c } = s();
|
|
7
|
+
if (!t.length) {
|
|
8
|
+
const r = c("ecommerce.no_products_found");
|
|
9
|
+
return /* @__PURE__ */ e("div", { className: "py-12 text-center text-muted-foreground", children: r === "ecommerce.no_products_found" ? "No products found." : r });
|
|
10
|
+
}
|
|
11
|
+
return /* @__PURE__ */ e(
|
|
12
|
+
"div",
|
|
13
|
+
{
|
|
14
|
+
className: m(
|
|
15
|
+
"grid gap-6 sm:grid-cols-2",
|
|
16
|
+
o === 3 && "lg:grid-cols-3",
|
|
17
|
+
o === 4 && "lg:grid-cols-4",
|
|
18
|
+
d
|
|
19
|
+
),
|
|
20
|
+
children: t.map((r, i) => /* @__PURE__ */ e(n, { product: r, priority: i < o }, r.id))
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
};
|
|
33
24
|
export {
|
|
34
|
-
|
|
25
|
+
g as ProductGrid
|
|
35
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),A=require("@nextblock-cms/ui/button"),L=require("@nextblock-cms/ui/input"),x=require("@nextblock-cms/ui/label"),u=require("lucide-react"),R=require("../countries.cjs.js"),T=require("../server-actions/shipping-actions.cjs.js"),K=require("@nextblock-cms/utils"),O=require("../use-price-formatter.cjs.js"),h=require("../states.cjs.js"),D=require("../CurrencyProvider.cjs.js"),I=({physicalSubtotal:N})=>{const C=O.usePriceFormatter(),[r,S]=a.useState("CA"),[c,g]=a.useState(""),[v,_]=a.useState(""),[d,j]=a.useState(!1),[o,b]=a.useState(null),[m,p]=a.useState(null),{t:s,lang:w}=K.useTranslations(),{activeCurrencyCode:f}=D.useCurrency(),n=(e,l)=>{const i=s(e);return i===e?l:i},q=h.getStatesForCountry(r),k=h.countryUsesStructuredStates(r),F=n("select_an_option","Select an option"),P=n("state_province","State / Province"),y=async()=>{j(!0),p(null),b(null);try{const e=await T.getShippingEstimates(N,{country:r,state:c||void 0,postal_code:v},w,f);e.success&&e.methods?b(e.methods):p(e.errorKey?n(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),p(n("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(u.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(x.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 l=e.target.value,i=h.getStatesForCountry(l);S(l),g(i.some(E=>E.code===c)?c:"")},className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:R.countries.map(e=>t.jsx("option",{value:e.code,children:e.name},e.code))})]}),k&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(x.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:c,onChange:e=>g(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:`${F}: ${P}`}),q.map(e=>t.jsx("option",{value:e.code,children:e.name},e.code))]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(x.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(L.Input,{id:"estimate-postal",name:"estimate-postal",autoComplete:"shipping postal-code",placeholder:r==="CA"?"A1A 1A1":void 0,value:v,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key==="Enter"&&!d&&(e.preventDefault(),y())},className:"h-9 text-sm bg-background"}),t.jsxs(A.Button,{size:"sm",variant:"secondary",onClick:y,disabled:d,className:"shrink-0",children:[d?t.jsx(u.Loader2,{className:"h-4 w-4 mr-1.5 animate-spin"}):t.jsx(u.Calculator,{className:"h-4 w-4 mr-1.5"}),s("ecommerce.calculate")]})]})]})]}),m&&t.jsx("p",{role:"alert",className:"text-xs text-destructive mt-2",children:m}),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(u.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,f)})]},e.id))]}),o&&o.length===0&&!m&&t.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:s("ecommerce.no_rates_found")})]})]})};exports.ShippingEstimator=I;
|