@nextblock-cms/ecom 0.20.3 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/_virtual/_rolldown/runtime.cjs.js +1 -0
  2. package/index.cjs.js +1 -1
  3. package/index.es.js +38 -146
  4. package/lib/CurrencyProvider.cjs.js +1 -1
  5. package/lib/CurrencyProvider.d.ts +1 -1
  6. package/lib/CurrencyProvider.es.js +85 -95
  7. package/lib/PaymentReadinessProvider.cjs.js +1 -1
  8. package/lib/PaymentReadinessProvider.d.ts +1 -1
  9. package/lib/PaymentReadinessProvider.es.js +24 -27
  10. package/lib/cart-store.cjs.js +1 -1
  11. package/lib/cart-store.es.js +109 -121
  12. package/lib/components/AccountNavigationMenu.cjs.js +1 -1
  13. package/lib/components/AccountNavigationMenu.d.ts +1 -1
  14. package/lib/components/AccountNavigationMenu.es.js +36 -50
  15. package/lib/components/AddToCartButton.cjs.js +1 -1
  16. package/lib/components/AddToCartButton.d.ts +1 -1
  17. package/lib/components/AddToCartButton.es.js +94 -89
  18. package/lib/components/Cart.cjs.js +1 -1
  19. package/lib/components/Cart.d.ts +1 -1
  20. package/lib/components/Cart.es.js +261 -180
  21. package/lib/components/CartDrawer.cjs.js +1 -1
  22. package/lib/components/CartDrawer.d.ts +1 -1
  23. package/lib/components/CartDrawer.es.js +218 -148
  24. package/lib/components/CartIcon.cjs.js +1 -1
  25. package/lib/components/CartIcon.d.ts +1 -1
  26. package/lib/components/CartIcon.es.js +33 -35
  27. package/lib/components/Checkout.cjs.js +1 -1
  28. package/lib/components/Checkout.d.ts +1 -1
  29. package/lib/components/Checkout.es.js +1092 -1108
  30. package/lib/components/CouponForm.cjs.js +1 -1
  31. package/lib/components/CouponForm.d.ts +1 -1
  32. package/lib/components/CouponForm.es.js +136 -148
  33. package/lib/components/CurrencySwitcher.cjs.js +1 -1
  34. package/lib/components/CurrencySwitcher.d.ts +1 -1
  35. package/lib/components/CurrencySwitcher.es.js +22 -18
  36. package/lib/components/CustomerProfileForm.cjs.js +1 -1
  37. package/lib/components/CustomerProfileForm.es.js +454 -313
  38. package/lib/components/FeaturedProduct.cjs.js +1 -1
  39. package/lib/components/FeaturedProduct.d.ts +1 -1
  40. package/lib/components/FeaturedProduct.es.js +98 -83
  41. package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
  42. package/lib/components/FreemiusLicensePanel.d.ts +1 -1
  43. package/lib/components/FreemiusLicensePanel.es.js +70 -65
  44. package/lib/components/InvoiceDocument.cjs.js +1 -1
  45. package/lib/components/InvoiceDocument.es.js +256 -192
  46. package/lib/components/InvoiceViewerShell.cjs.js +2 -2
  47. package/lib/components/InvoiceViewerShell.d.ts +1 -1
  48. package/lib/components/InvoiceViewerShell.es.js +75 -106
  49. package/lib/components/ProductCard.cjs.js +1 -1
  50. package/lib/components/ProductCard.d.ts +1 -1
  51. package/lib/components/ProductCard.es.js +186 -171
  52. package/lib/components/ProductDetailsLayout.cjs.js +1 -1
  53. package/lib/components/ProductDetailsLayout.es.js +405 -404
  54. package/lib/components/ProductGallery.cjs.js +1 -1
  55. package/lib/components/ProductGallery.d.ts +1 -1
  56. package/lib/components/ProductGallery.es.js +51 -54
  57. package/lib/components/ProductGrid.cjs.js +1 -1
  58. package/lib/components/ProductGrid.d.ts +1 -1
  59. package/lib/components/ProductGrid.es.js +23 -25
  60. package/lib/components/ShippingEstimator.cjs.js +1 -1
  61. package/lib/components/ShippingEstimator.d.ts +1 -1
  62. package/lib/components/ShippingEstimator.es.js +158 -153
  63. package/lib/components/ShortDescription.cjs.js +1 -1
  64. package/lib/components/ShortDescription.es.js +17 -17
  65. package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
  66. package/lib/components/SimpleTiptapRenderer.es.js +238 -211
  67. package/lib/components/SubscriptionSelector.cjs.js +1 -1
  68. package/lib/components/SubscriptionSelector.es.js +159 -154
  69. package/lib/countries.cjs.js +1 -1
  70. package/lib/countries.es.js +232 -75
  71. package/lib/coupon-server.cjs.js +1 -1
  72. package/lib/coupon-server.es.js +180 -224
  73. package/lib/coupons.cjs.js +1 -1
  74. package/lib/coupons.es.js +12 -14
  75. package/lib/currency-constants.cjs.js +1 -1
  76. package/lib/currency-constants.es.js +4 -4
  77. package/lib/currency-rest-client.cjs.js +1 -1
  78. package/lib/currency-rest-client.es.js +15 -22
  79. package/lib/currency-store.cjs.js +1 -1
  80. package/lib/currency-store.es.js +20 -27
  81. package/lib/currency-sync.cjs.js +1 -1
  82. package/lib/currency-sync.es.js +124 -170
  83. package/lib/currency.cjs.js +1 -1
  84. package/lib/currency.es.js +242 -310
  85. package/lib/customer-addresses.cjs.js +1 -1
  86. package/lib/customer-addresses.es.js +80 -109
  87. package/lib/customer-orders.cjs.js +1 -1
  88. package/lib/customer-orders.es.js +31 -43
  89. package/lib/customer.cjs.js +1 -1
  90. package/lib/customer.es.js +43 -52
  91. package/lib/export-helpers.cjs.js +1 -1
  92. package/lib/export-helpers.es.js +53 -52
  93. package/lib/factory.cjs.js +1 -1
  94. package/lib/factory.es.js +10 -7
  95. package/lib/freemius-coupons.cjs.js +1 -1
  96. package/lib/freemius-coupons.es.js +245 -262
  97. package/lib/freemius-license-claim.cjs.js +1 -1
  98. package/lib/freemius-license-claim.es.js +87 -71
  99. package/lib/freemius-license.cjs.js +1 -1
  100. package/lib/freemius-license.es.js +32 -39
  101. package/lib/freemius-order-sync.cjs.js +1 -1
  102. package/lib/freemius-order-sync.es.js +226 -290
  103. package/lib/freemius-trial-provision.cjs.js +1 -1
  104. package/lib/freemius-trial-provision.es.js +136 -130
  105. package/lib/inventory-settings.cjs.js +1 -1
  106. package/lib/inventory-settings.es.js +69 -77
  107. package/lib/invoice-server.cjs.js +3 -3
  108. package/lib/invoice-server.es.js +94 -141
  109. package/lib/invoice-ui.cjs.js +1 -1
  110. package/lib/invoice-ui.es.js +50 -66
  111. package/lib/invoice.cjs.js +1 -1
  112. package/lib/invoice.es.js +85 -94
  113. package/lib/order-inventory.cjs.js +25 -25
  114. package/lib/order-inventory.es.js +67 -79
  115. package/lib/order-tax-details.cjs.js +1 -1
  116. package/lib/order-tax-details.es.js +142 -153
  117. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
  118. package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
  119. package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
  120. package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
  121. package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
  122. package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
  123. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
  124. package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
  125. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
  126. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
  127. package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
  128. package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
  129. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
  130. package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
  131. package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
  132. package/lib/pages/cms/coupons/actions.cjs.js +1 -1
  133. package/lib/pages/cms/coupons/actions.es.js +112 -115
  134. package/lib/pages/cms/coupons/index.cjs.js +1 -0
  135. package/lib/pages/cms/coupons/index.es.js +3 -0
  136. package/lib/pages/cms/coupons/product-options.cjs.js +1 -1
  137. package/lib/pages/cms/coupons/product-options.es.js +21 -23
  138. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
  139. package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
  140. package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
  141. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
  142. package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
  143. package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
  144. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
  145. package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
  146. package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
  147. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
  148. package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
  149. package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
  150. package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
  151. package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
  152. package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
  153. package/lib/pages/cms/orders/actions.cjs.js +3 -3
  154. package/lib/pages/cms/orders/actions.es.js +53 -69
  155. package/lib/pages/cms/orders/export-actions.cjs.js +1 -1
  156. package/lib/pages/cms/orders/export-actions.es.js +23 -26
  157. package/lib/pages/cms/orders/index.cjs.js +1 -0
  158. package/lib/pages/cms/orders/index.es.js +6 -0
  159. package/lib/pages/cms/orders/server-actions.cjs.js +1 -1
  160. package/lib/pages/cms/orders/server-actions.es.js +60 -51
  161. package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
  162. package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
  163. package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
  164. package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
  165. package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
  166. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
  167. package/lib/pages/cms/payments/actions.cjs.js +1 -1
  168. package/lib/pages/cms/payments/actions.es.js +38 -48
  169. package/lib/pages/cms/payments/index.cjs.js +1 -0
  170. package/lib/pages/cms/payments/index.es.js +3 -0
  171. package/lib/pages/cms/payments/queries.cjs.js +1 -1
  172. package/lib/pages/cms/payments/queries.es.js +38 -48
  173. package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
  174. package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
  175. package/lib/pages/cms/products/ProductsPage.es.js +63 -66
  176. package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
  177. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
  178. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +138 -155
  179. package/lib/pages/cms/products/actions.cjs.js +4 -4
  180. package/lib/pages/cms/products/actions.es.js +121 -162
  181. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
  182. package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
  183. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
  184. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
  185. package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
  186. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
  187. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
  188. package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
  189. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
  190. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
  191. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
  192. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
  193. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
  194. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
  195. package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
  196. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
  197. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
  198. package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
  199. package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
  200. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
  201. package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
  202. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
  203. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
  204. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
  205. package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
  206. package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
  207. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
  208. package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
  209. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
  210. package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
  211. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
  212. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
  213. package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
  214. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
  215. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
  216. package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
  217. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
  218. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
  219. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
  220. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
  221. package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
  222. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
  223. package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
  224. package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
  225. package/lib/pages/cms/products/index.cjs.js +1 -0
  226. package/lib/pages/cms/products/index.es.js +8 -0
  227. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
  228. package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
  229. package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
  230. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
  231. package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
  232. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
  233. package/lib/pages/cms/products/inventory/actions.cjs.js +3 -3
  234. package/lib/pages/cms/products/inventory/actions.es.js +83 -91
  235. package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
  236. package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
  237. package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
  238. package/lib/pages/cms/products/product-price-sync.cjs.js +1 -1
  239. package/lib/pages/cms/products/product-price-sync.es.js +74 -89
  240. package/lib/pages/cms/products/server-actions.cjs.js +1 -1
  241. package/lib/pages/cms/products/server-actions.es.js +250 -233
  242. package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
  243. package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
  244. package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
  245. package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
  246. package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
  247. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
  248. package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
  249. package/lib/pages/cms/shipping/index.cjs.js +1 -0
  250. package/lib/pages/cms/shipping/index.es.js +3 -0
  251. package/lib/pages/cms/shipping/server-actions.cjs.js +1 -1
  252. package/lib/pages/cms/shipping/server-actions.es.js +131 -149
  253. package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
  254. package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
  255. package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
  256. package/lib/pages/cms/taxes/actions.cjs.js +1 -1
  257. package/lib/pages/cms/taxes/actions.es.js +41 -53
  258. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
  259. package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
  260. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
  261. package/lib/pages/cms/taxes/index.cjs.js +1 -0
  262. package/lib/pages/cms/taxes/index.es.js +3 -0
  263. package/lib/payment-config.cjs.js +1 -1
  264. package/lib/payment-config.es.js +110 -126
  265. package/lib/product-actions.cjs.js +4 -4
  266. package/lib/product-actions.es.js +289 -544
  267. package/lib/product-context.cjs.js +1 -1
  268. package/lib/product-context.es.js +13 -15
  269. package/lib/product-schema.cjs.js +1 -1
  270. package/lib/product-schema.es.js +99 -134
  271. package/lib/providers/freemius.cjs.js +1 -5
  272. package/lib/providers/freemius.es.js +446 -530
  273. package/lib/providers/stripe.cjs.js +1 -1
  274. package/lib/providers/stripe.es.js +417 -477
  275. package/lib/server-actions/coupon-actions.cjs.js +1 -1
  276. package/lib/server-actions/coupon-actions.es.js +22 -22
  277. package/lib/server-actions/customer-actions.cjs.js +1 -1
  278. package/lib/server-actions/customer-actions.es.js +26 -28
  279. package/lib/server-actions/product-actions.cjs.js +1 -1
  280. package/lib/server-actions/product-actions.es.js +9 -15
  281. package/lib/server-actions/shipping-actions.cjs.js +1 -1
  282. package/lib/server-actions/shipping-actions.es.js +27 -24
  283. package/lib/server-actions/tax-actions.cjs.js +1 -1
  284. package/lib/server-actions/tax-actions.es.js +33 -39
  285. package/lib/shared-inventory.cjs.js +2 -2
  286. package/lib/shared-inventory.es.js +111 -160
  287. package/lib/shipping/resolver.cjs.js +2 -2
  288. package/lib/shipping/resolver.es.js +44 -61
  289. package/lib/shipping-rate-currency.cjs.js +1 -1
  290. package/lib/shipping-rate-currency.es.js +52 -67
  291. package/lib/states.cjs.js +1 -1
  292. package/lib/states.es.js +333 -154
  293. package/lib/stripe/checkout.cjs.js +1 -1
  294. package/lib/stripe/checkout.es.js +125 -181
  295. package/lib/stripe/client.cjs.js +1 -1
  296. package/lib/stripe/client.es.js +14 -19
  297. package/lib/stripe/order-sync.cjs.js +1 -1
  298. package/lib/stripe/order-sync.es.js +106 -126
  299. package/lib/stripe/webhooks.cjs.js +1 -1
  300. package/lib/stripe/webhooks.es.js +37 -31
  301. package/lib/tax-calculation.cjs.js +1 -1
  302. package/lib/tax-calculation.es.js +84 -98
  303. package/lib/trials.cjs.js +1 -1
  304. package/lib/trials.es.js +24 -30
  305. package/lib/types.cjs.js +1 -1
  306. package/lib/types.es.js +21 -27
  307. package/lib/use-cart.cjs.js +1 -1
  308. package/lib/use-cart.es.js +38 -40
  309. package/lib/use-price-formatter.cjs.js +1 -1
  310. package/lib/use-price-formatter.es.js +10 -11
  311. package/lib/variation-utils.cjs.js +1 -1
  312. package/lib/variation-utils.es.js +199 -261
  313. package/lib/zod-config.cjs.js +1 -1
  314. package/lib/zod-config.es.js +5 -6
  315. package/package.json +16 -16
  316. package/server.cjs.js +1 -1
  317. package/server.es.js +56 -211
@@ -1 +1 @@
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
+ "use client";const e=require("../invoice-ui.cjs.js");let t=require("react"),n=require("@nextblock-cms/utils"),r=require("react/jsx-runtime");var i=({images:i=[],className:a})=>{let{t:o}=(0,n.useTranslations)(),[s,c]=(0,t.useState)(0);if(!i.length)return(0,r.jsx)(`div`,{className:(0,n.cn)(`relative aspect-square w-full overflow-hidden rounded-lg bg-secondary`,a),children:(0,r.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:e.translateOrFallback(o,`ecommerce.no_image`,`No image`)})});let l=s<i.length?s:0,u=i[l];return(0,r.jsxs)(`div`,{className:(0,n.cn)(`flex flex-col gap-4`,a),children:[(0,r.jsx)(`div`,{className:`relative aspect-square w-full overflow-hidden rounded-lg border bg-white`,children:(0,r.jsx)(`img`,{src:u.url,alt:u.alt??``,width:u.width??1e3,height:u.height??1e3,fetchPriority:`high`,decoding:`async`,className:`h-full w-full object-cover object-center`})}),i.length>1&&(0,r.jsx)(`div`,{className:`flex gap-4 overflow-x-auto p-1 pb-2`,children:i.map((t,a)=>(0,r.jsx)(`button`,{type:`button`,onClick:()=>c(a),"aria-current":l===a?`true`:void 0,"aria-label":e.translateOrFallback(o,`ecommerce.gallery_show_image`,`Show image {index} of {total}`).replace(`{index}`,String(a+1)).replace(`{total}`,String(i.length)),className:(0,n.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`,l===a?`ring-2 ring-primary`:`ring-1 ring-transparent hover:ring-primary/50`),children:(0,r.jsx)(`img`,{src:t.url,alt:``,width:80,height:80,loading:`lazy`,decoding:`async`,className:`h-full w-full object-cover object-center`})},a))})]})};exports.ProductGallery=i;
@@ -7,5 +7,5 @@ interface ProductGalleryProps {
7
7
  }[];
8
8
  className?: string;
9
9
  }
10
- export declare const ProductGallery: ({ images, className }: ProductGalleryProps) => import("react").JSX.Element;
10
+ export declare const ProductGallery: ({ images, className }: ProductGalleryProps) => import('react').JSX.Element;
11
11
  export {};
@@ -1,55 +1,52 @@
1
- 'use client';
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: [
12
- /* @__PURE__ */ e("div", { className: "relative aspect-square w-full overflow-hidden rounded-lg border bg-white", children: /* @__PURE__ */ e(
13
- "img",
14
- {
15
- src: l.url,
16
- alt: l.alt ?? "",
17
- width: l.width ?? 1e3,
18
- height: l.height ?? 1e3,
19
- fetchPriority: "high",
20
- decoding: "async",
21
- className: "h-full w-full object-cover object-center"
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(
26
- "button",
27
- {
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)),
32
- className: o(
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"
35
- ),
36
- children: /* @__PURE__ */ e(
37
- "img",
38
- {
39
- src: h.url,
40
- alt: "",
41
- width: 80,
42
- height: 80,
43
- loading: "lazy",
44
- decoding: "async",
45
- className: "h-full w-full object-cover object-center"
46
- }
47
- )
48
- },
49
- t
50
- )) })
51
- ] });
52
- };
53
- export {
54
- w as ProductGallery
1
+ "use client";
2
+ import { translateOrFallback as e } from "../invoice-ui.es.js";
3
+ import { useState as t } from "react";
4
+ import { cn as n, useTranslations as r } from "@nextblock-cms/utils";
5
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
+ //#region libs/ecommerce/src/lib/components/ProductGallery.tsx
7
+ var o = ({ images: o = [], className: s }) => {
8
+ let { t: c } = r(), [l, u] = t(0);
9
+ if (!o.length) return /* @__PURE__ */ i("div", {
10
+ className: n("relative aspect-square w-full overflow-hidden rounded-lg bg-secondary", s),
11
+ children: /* @__PURE__ */ i("div", {
12
+ className: "flex h-full items-center justify-center text-muted-foreground",
13
+ children: e(c, "ecommerce.no_image", "No image")
14
+ })
15
+ });
16
+ let d = l < o.length ? l : 0, f = o[d];
17
+ return /* @__PURE__ */ a("div", {
18
+ className: n("flex flex-col gap-4", s),
19
+ children: [/* @__PURE__ */ i("div", {
20
+ className: "relative aspect-square w-full overflow-hidden rounded-lg border bg-white",
21
+ children: /* @__PURE__ */ i("img", {
22
+ src: f.url,
23
+ alt: f.alt ?? "",
24
+ width: f.width ?? 1e3,
25
+ height: f.height ?? 1e3,
26
+ fetchPriority: "high",
27
+ decoding: "async",
28
+ className: "h-full w-full object-cover object-center"
29
+ })
30
+ }), o.length > 1 && /* @__PURE__ */ i("div", {
31
+ className: "flex gap-4 overflow-x-auto p-1 pb-2",
32
+ children: o.map((t, r) => /* @__PURE__ */ i("button", {
33
+ type: "button",
34
+ onClick: () => u(r),
35
+ "aria-current": d === r ? "true" : void 0,
36
+ "aria-label": e(c, "ecommerce.gallery_show_image", "Show image {index} of {total}").replace("{index}", String(r + 1)).replace("{total}", String(o.length)),
37
+ className: n("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", d === r ? "ring-2 ring-primary" : "ring-1 ring-transparent hover:ring-primary/50"),
38
+ children: /* @__PURE__ */ i("img", {
39
+ src: t.url,
40
+ alt: "",
41
+ width: 80,
42
+ height: 80,
43
+ loading: "lazy",
44
+ decoding: "async",
45
+ className: "h-full w-full object-cover object-center"
46
+ })
47
+ }, r))
48
+ })]
49
+ });
55
50
  };
51
+ //#endregion
52
+ export { o as ProductGallery };
@@ -1 +1 @@
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
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./ProductCard.cjs.js");let t=require("@nextblock-cms/utils"),n=require("react/jsx-runtime");var r=({products:r,columns:i=3,className:a})=>{let{t:o}=(0,t.useTranslations)();if(!r.length){let e=o(`ecommerce.no_products_found`);return(0,n.jsx)(`div`,{className:`py-12 text-center text-muted-foreground`,children:e===`ecommerce.no_products_found`?`No products found.`:e})}return(0,n.jsx)(`div`,{className:(0,t.cn)(`grid gap-6 sm:grid-cols-2`,i===3&&`lg:grid-cols-3`,i===4&&`lg:grid-cols-4`,a),children:r.map((t,r)=>(0,n.jsx)(e.ProductCard,{product:t,priority:r<i},t.id))})};exports.ProductGrid=r;
@@ -4,5 +4,5 @@ interface ProductGridProps {
4
4
  columns?: 2 | 3 | 4;
5
5
  className?: string;
6
6
  }
7
- export declare const ProductGrid: ({ products, columns, className }: ProductGridProps) => import("react").JSX.Element;
7
+ export declare const ProductGrid: ({ products, columns, className }: ProductGridProps) => import('react').JSX.Element;
8
8
  export {};
@@ -1,26 +1,24 @@
1
- 'use client';
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
- };
24
- export {
25
- g as ProductGrid
1
+ "use client";
2
+ import { ProductCard as e } from "./ProductCard.es.js";
3
+ import { cn as t, useTranslations as n } from "@nextblock-cms/utils";
4
+ import { jsx as r } from "react/jsx-runtime";
5
+ //#region libs/ecommerce/src/lib/components/ProductGrid.tsx
6
+ var i = ({ products: i, columns: a = 3, className: o }) => {
7
+ let { t: s } = n();
8
+ if (!i.length) {
9
+ let e = s("ecommerce.no_products_found");
10
+ return /* @__PURE__ */ r("div", {
11
+ className: "py-12 text-center text-muted-foreground",
12
+ children: e === "ecommerce.no_products_found" ? "No products found." : e
13
+ });
14
+ }
15
+ return /* @__PURE__ */ r("div", {
16
+ className: t("grid gap-6 sm:grid-cols-2", a === 3 && "lg:grid-cols-3", a === 4 && "lg:grid-cols-4", o),
17
+ children: i.map((t, n) => /* @__PURE__ */ r(e, {
18
+ product: t,
19
+ priority: n < a
20
+ }, t.id))
21
+ });
26
22
  };
23
+ //#endregion
24
+ export { i as ProductGrid };
@@ -1 +1 @@
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
+ "use client";const e=require("../CurrencyProvider.cjs.js"),t=require("../use-price-formatter.cjs.js"),n=require("../countries.cjs.js"),r=require("../states.cjs.js"),i=require("../server-actions/shipping-actions.cjs.js");let a=require("@nextblock-cms/ui/button"),o=require("react"),s=require("lucide-react"),c=require("@nextblock-cms/utils"),l=require("react/jsx-runtime"),u=require("@nextblock-cms/ui/input"),d=require("@nextblock-cms/ui/label");var f=({physicalSubtotal:f})=>{let p=t.usePriceFormatter(),[m,h]=(0,o.useState)(`CA`),[g,_]=(0,o.useState)(``),[v,y]=(0,o.useState)(``),[b,x]=(0,o.useState)(!1),[S,C]=(0,o.useState)(null),[w,T]=(0,o.useState)(null),{t:E,lang:D}=(0,c.useTranslations)(),{activeCurrencyCode:O}=e.useCurrency(),k=(e,t)=>{let n=E(e);return n===e?t:n},A=r.getStatesForCountry(m),j=r.countryUsesStructuredStates(m),M=(0,o.useMemo)(()=>{try{return new Intl.DisplayNames([D],{type:`region`})}catch{return null}},[D]),N=k(`select_an_option`,`Select an option`),P=k(`state_province`,`State / Province`),F=async()=>{x(!0),T(null),C(null);try{let e=await i.getShippingEstimates(f,{country:m,state:g||void 0,postal_code:v},D,O);e.success&&e.methods?C(e.methods):T(e.errorKey?k(e.errorKey,e.error||E(`ecommerce.no_rates_found`)):e.error||E(`ecommerce.no_rates_found`))}catch(e){console.error(`[ShippingEstimator] Failed to load rates:`,e),T(k(`ecommerce.shipping_calculation_failed`,`We couldn't calculate shipping right now. Please try again.`))}finally{x(!1)}};return(0,l.jsxs)(`div`,{className:`space-y-4 rounded-lg border bg-muted/30 p-4 mt-6`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 font-semibold text-sm`,children:[(0,l.jsx)(s.Truck,{className:`h-4 w-4`}),(0,l.jsx)(`span`,{children:E(`ecommerce.estimate_shipping`)})]}),(0,l.jsxs)(`div`,{className:`grid gap-3`,children:[(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,l.jsx)(d.Label,{htmlFor:`estimate-country`,className:`text-xs uppercase tracking-wider text-muted-foreground`,children:E(`ecommerce.country`)}),(0,l.jsx)(`select`,{id:`estimate-country`,name:`estimate-country`,autoComplete:`shipping country`,value:m,onChange:e=>{let t=e.target.value,n=r.getStatesForCountry(t);h(t),_(n.some(e=>e.code===g)?g:``)},className:`flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,children:n.countries.map(e=>(0,l.jsx)(`option`,{value:e.code,children:M?.of(e.code)??e.name},e.code))})]}),j&&(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,l.jsx)(d.Label,{htmlFor:`estimate-state`,className:`text-xs uppercase tracking-wider text-muted-foreground`,children:E(`state_province`)}),(0,l.jsxs)(`select`,{id:`estimate-state`,name:`estimate-state`,autoComplete:`shipping address-level1`,value:g,onChange:e=>_(e.target.value),className:`flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,children:[(0,l.jsx)(`option`,{value:``,children:`${N}: ${P}`}),A.map(e=>(0,l.jsx)(`option`,{value:e.code,children:r.getSubdivisionLabel(m,e,D)},e.code))]})]}),(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,l.jsx)(d.Label,{htmlFor:`estimate-postal`,className:`text-xs uppercase tracking-wider text-muted-foreground`,children:E(`ecommerce.postal_code`)}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(u.Input,{id:`estimate-postal`,name:`estimate-postal`,autoComplete:`shipping postal-code`,placeholder:m===`CA`?`A1A 1A1`:void 0,value:v,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!b&&(e.preventDefault(),F())},className:`h-9 text-sm bg-background`}),(0,l.jsxs)(a.Button,{size:`sm`,variant:`secondary`,onClick:F,disabled:b,className:`shrink-0`,children:[b?(0,l.jsx)(s.Loader2,{className:`h-4 w-4 mr-1.5 animate-spin`}):(0,l.jsx)(s.Calculator,{className:`h-4 w-4 mr-1.5`}),E(`ecommerce.calculate`)]})]})]})]}),w&&(0,l.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive mt-2`,children:w}),(0,l.jsxs)(`div`,{"aria-live":`polite`,children:[S&&S.length>0&&(0,l.jsxs)(`div`,{className:`mt-4 space-y-2 border-t pt-3`,children:[(0,l.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground uppercase`,children:[E(`ecommerce.available_rates`),`:`]}),S.map(e=>(0,l.jsxs)(`div`,{className:`flex justify-between items-center p-3 border rounded-lg bg-muted/30`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(s.Truck,{className:`h-4 w-4 text-muted-foreground`}),(0,l.jsx)(`span`,{className:`text-sm font-medium`,children:e.name})]}),(0,l.jsx)(`span`,{className:`text-sm font-bold tabular-nums`,children:e.amount===0?E(`ecommerce.free`):p(e.amount,O)})]},e.id))]}),S&&S.length===0&&!w&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground mt-2 italic`,children:E(`ecommerce.no_rates_found`)})]})]})};exports.ShippingEstimator=f;
@@ -1,5 +1,5 @@
1
1
  interface ShippingEstimatorProps {
2
2
  physicalSubtotal: number;
3
3
  }
4
- export declare const ShippingEstimator: ({ physicalSubtotal }: ShippingEstimatorProps) => import("react").JSX.Element;
4
+ export declare const ShippingEstimator: ({ physicalSubtotal }: ShippingEstimatorProps) => import('react').JSX.Element;
5
5
  export {};
@@ -1,154 +1,159 @@
1
- 'use client';
2
- import { jsxs as a, jsx as t } from "react/jsx-runtime";
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(() => {
19
- try {
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,
29
- {
30
- country: s,
31
- state: c || void 0,
32
- postal_code: x
33
- },
34
- l,
35
- N
36
- );
37
- e.success && e.methods ? y(e.methods) : h(
38
- e.errorKey ? i(
39
- e.errorKey,
40
- e.error || r("ecommerce.no_rates_found")
41
- ) : e.error || r("ecommerce.no_rates_found")
42
- );
43
- } catch (e) {
44
- console.error("[ShippingEstimator] Failed to load rates:", e), h(
45
- i(
46
- "ecommerce.shipping_calculation_failed",
47
- "We couldn't calculate shipping right now. Please try again."
48
- )
49
- );
50
- } finally {
51
- v(!1);
52
- }
53
- };
54
- return /* @__PURE__ */ a("div", { className: "space-y-4 rounded-lg border bg-muted/30 p-4 mt-6", children: [
55
- /* @__PURE__ */ a("div", { className: "flex items-center gap-2 font-semibold text-sm", children: [
56
- /* @__PURE__ */ t(C, { className: "h-4 w-4" }),
57
- /* @__PURE__ */ t("span", { children: r("ecommerce.estimate_shipping") })
58
- ] }),
59
- /* @__PURE__ */ a("div", { className: "grid gap-3", children: [
60
- /* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
61
- /* @__PURE__ */ t(g, { htmlFor: "estimate-country", className: "text-xs uppercase tracking-wider text-muted-foreground", children: r("ecommerce.country") }),
62
- /* @__PURE__ */ t(
63
- "select",
64
- {
65
- id: "estimate-country",
66
- name: "estimate-country",
67
- autoComplete: "shipping country",
68
- value: s,
69
- onChange: (e) => {
70
- const m = e.target.value, d = _(m);
71
- k(m), f(
72
- d.some((D) => D.code === c) ? c : ""
73
- );
74
- },
75
- className: "flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
76
- children: z.map((e) => /* @__PURE__ */ t("option", { value: e.code, children: A?.of(e.code) ?? e.name }, e.code))
77
- }
78
- )
79
- ] }),
80
- P && /* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
81
- /* @__PURE__ */ t(g, { htmlFor: "estimate-state", className: "text-xs uppercase tracking-wider text-muted-foreground", children: r("state_province") }),
82
- /* @__PURE__ */ a(
83
- "select",
84
- {
85
- id: "estimate-state",
86
- name: "estimate-state",
87
- autoComplete: "shipping address-level1",
88
- value: c,
89
- onChange: (e) => f(e.target.value),
90
- className: "flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
91
- children: [
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))
94
- ]
95
- }
96
- )
97
- ] }),
98
- /* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
99
- /* @__PURE__ */ t(g, { htmlFor: "estimate-postal", className: "text-xs uppercase tracking-wider text-muted-foreground", children: r("ecommerce.postal_code") }),
100
- /* @__PURE__ */ a("div", { className: "flex gap-2", children: [
101
- /* @__PURE__ */ t(
102
- O,
103
- {
104
- id: "estimate-postal",
105
- name: "estimate-postal",
106
- autoComplete: "shipping postal-code",
107
- placeholder: s === "CA" ? "A1A 1A1" : void 0,
108
- value: x,
109
- onChange: (e) => F(e.target.value),
110
- onKeyDown: (e) => {
111
- e.key === "Enter" && !u && (e.preventDefault(), b());
112
- },
113
- className: "h-9 text-sm bg-background"
114
- }
115
- ),
116
- /* @__PURE__ */ a(
117
- K,
118
- {
119
- size: "sm",
120
- variant: "secondary",
121
- onClick: b,
122
- disabled: u,
123
- className: "shrink-0",
124
- children: [
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" }),
126
- r("ecommerce.calculate")
127
- ]
128
- }
129
- )
130
- ] })
131
- ] })
132
- ] }),
133
- p && /* @__PURE__ */ t("p", { role: "alert", className: "text-xs text-destructive mt-2", children: p }),
134
- /* @__PURE__ */ a("div", { "aria-live": "polite", children: [
135
- n && n.length > 0 && /* @__PURE__ */ a("div", { className: "mt-4 space-y-2 border-t pt-3", children: [
136
- /* @__PURE__ */ a("p", { className: "text-xs font-medium text-muted-foreground uppercase", children: [
137
- r("ecommerce.available_rates"),
138
- ":"
139
- ] }),
140
- n.map((e) => /* @__PURE__ */ a("div", { className: "flex justify-between items-center p-3 border rounded-lg bg-muted/30", children: [
141
- /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
142
- /* @__PURE__ */ t(C, { className: "h-4 w-4 text-muted-foreground" }),
143
- /* @__PURE__ */ t("span", { className: "text-sm font-medium", children: e.name })
144
- ] }),
145
- /* @__PURE__ */ t("span", { className: "text-sm font-bold tabular-nums", children: e.amount === 0 ? r("ecommerce.free") : w(e.amount, N) })
146
- ] }, e.id))
147
- ] }),
148
- n && n.length === 0 && !p && /* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground mt-2 italic", children: r("ecommerce.no_rates_found") })
149
- ] })
150
- ] });
151
- };
152
- export {
153
- se as ShippingEstimator
1
+ "use client";
2
+ import { useCurrency as e } from "../CurrencyProvider.es.js";
3
+ import { usePriceFormatter as t } from "../use-price-formatter.es.js";
4
+ import { countries as n } from "../countries.es.js";
5
+ import { countryUsesStructuredStates as r, getStatesForCountry as i, getSubdivisionLabel as a } from "../states.es.js";
6
+ import { getShippingEstimates as o } from "../server-actions/shipping-actions.es.js";
7
+ import { Button as s } from "@nextblock-cms/ui/button";
8
+ import { useMemo as c, useState as l } from "react";
9
+ import { Calculator as u, Loader2 as d, Truck as f } from "lucide-react";
10
+ import { useTranslations as p } from "@nextblock-cms/utils";
11
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
12
+ import { Input as g } from "@nextblock-cms/ui/input";
13
+ import { Label as _ } from "@nextblock-cms/ui/label";
14
+ //#region libs/ecommerce/src/lib/components/ShippingEstimator.tsx
15
+ var v = ({ physicalSubtotal: v }) => {
16
+ let y = t(), [b, x] = l("CA"), [S, C] = l(""), [w, T] = l(""), [E, D] = l(!1), [O, k] = l(null), [A, j] = l(null), { t: M, lang: N } = p(), { activeCurrencyCode: P } = e(), F = (e, t) => {
17
+ let n = M(e);
18
+ return n === e ? t : n;
19
+ }, I = i(b), L = r(b), R = c(() => {
20
+ try {
21
+ return new Intl.DisplayNames([N], { type: "region" });
22
+ } catch {
23
+ return null;
24
+ }
25
+ }, [N]), z = F("select_an_option", "Select an option"), B = F("state_province", "State / Province"), V = async () => {
26
+ D(!0), j(null), k(null);
27
+ try {
28
+ let e = await o(v, {
29
+ country: b,
30
+ state: S || void 0,
31
+ postal_code: w
32
+ }, N, P);
33
+ e.success && e.methods ? k(e.methods) : j(e.errorKey ? F(e.errorKey, e.error || M("ecommerce.no_rates_found")) : e.error || M("ecommerce.no_rates_found"));
34
+ } catch (e) {
35
+ console.error("[ShippingEstimator] Failed to load rates:", e), j(F("ecommerce.shipping_calculation_failed", "We couldn't calculate shipping right now. Please try again."));
36
+ } finally {
37
+ D(!1);
38
+ }
39
+ };
40
+ return /* @__PURE__ */ h("div", {
41
+ className: "space-y-4 rounded-lg border bg-muted/30 p-4 mt-6",
42
+ children: [
43
+ /* @__PURE__ */ h("div", {
44
+ className: "flex items-center gap-2 font-semibold text-sm",
45
+ children: [/* @__PURE__ */ m(f, { className: "h-4 w-4" }), /* @__PURE__ */ m("span", { children: M("ecommerce.estimate_shipping") })]
46
+ }),
47
+ /* @__PURE__ */ h("div", {
48
+ className: "grid gap-3",
49
+ children: [
50
+ /* @__PURE__ */ h("div", {
51
+ className: "space-y-1.5",
52
+ children: [/* @__PURE__ */ m(_, {
53
+ htmlFor: "estimate-country",
54
+ className: "text-xs uppercase tracking-wider text-muted-foreground",
55
+ children: M("ecommerce.country")
56
+ }), /* @__PURE__ */ m("select", {
57
+ id: "estimate-country",
58
+ name: "estimate-country",
59
+ autoComplete: "shipping country",
60
+ value: b,
61
+ onChange: (e) => {
62
+ let t = e.target.value, n = i(t);
63
+ x(t), C(n.some((e) => e.code === S) ? S : "");
64
+ },
65
+ className: "flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
66
+ children: n.map((e) => /* @__PURE__ */ m("option", {
67
+ value: e.code,
68
+ children: R?.of(e.code) ?? e.name
69
+ }, e.code))
70
+ })]
71
+ }),
72
+ L && /* @__PURE__ */ h("div", {
73
+ className: "space-y-1.5",
74
+ children: [/* @__PURE__ */ m(_, {
75
+ htmlFor: "estimate-state",
76
+ className: "text-xs uppercase tracking-wider text-muted-foreground",
77
+ children: M("state_province")
78
+ }), /* @__PURE__ */ h("select", {
79
+ id: "estimate-state",
80
+ name: "estimate-state",
81
+ autoComplete: "shipping address-level1",
82
+ value: S,
83
+ onChange: (e) => C(e.target.value),
84
+ className: "flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
85
+ children: [/* @__PURE__ */ m("option", {
86
+ value: "",
87
+ children: `${z}: ${B}`
88
+ }), I.map((e) => /* @__PURE__ */ m("option", {
89
+ value: e.code,
90
+ children: a(b, e, N)
91
+ }, e.code))]
92
+ })]
93
+ }),
94
+ /* @__PURE__ */ h("div", {
95
+ className: "space-y-1.5",
96
+ children: [/* @__PURE__ */ m(_, {
97
+ htmlFor: "estimate-postal",
98
+ className: "text-xs uppercase tracking-wider text-muted-foreground",
99
+ children: M("ecommerce.postal_code")
100
+ }), /* @__PURE__ */ h("div", {
101
+ className: "flex gap-2",
102
+ children: [/* @__PURE__ */ m(g, {
103
+ id: "estimate-postal",
104
+ name: "estimate-postal",
105
+ autoComplete: "shipping postal-code",
106
+ placeholder: b === "CA" ? "A1A 1A1" : void 0,
107
+ value: w,
108
+ onChange: (e) => T(e.target.value),
109
+ onKeyDown: (e) => {
110
+ e.key === "Enter" && !E && (e.preventDefault(), V());
111
+ },
112
+ className: "h-9 text-sm bg-background"
113
+ }), /* @__PURE__ */ h(s, {
114
+ size: "sm",
115
+ variant: "secondary",
116
+ onClick: V,
117
+ disabled: E,
118
+ className: "shrink-0",
119
+ children: [E ? /* @__PURE__ */ m(d, { className: "h-4 w-4 mr-1.5 animate-spin" }) : /* @__PURE__ */ m(u, { className: "h-4 w-4 mr-1.5" }), M("ecommerce.calculate")]
120
+ })]
121
+ })]
122
+ })
123
+ ]
124
+ }),
125
+ A && /* @__PURE__ */ m("p", {
126
+ role: "alert",
127
+ className: "text-xs text-destructive mt-2",
128
+ children: A
129
+ }),
130
+ /* @__PURE__ */ h("div", {
131
+ "aria-live": "polite",
132
+ children: [O && O.length > 0 && /* @__PURE__ */ h("div", {
133
+ className: "mt-4 space-y-2 border-t pt-3",
134
+ children: [/* @__PURE__ */ h("p", {
135
+ className: "text-xs font-medium text-muted-foreground uppercase",
136
+ children: [M("ecommerce.available_rates"), ":"]
137
+ }), O.map((e) => /* @__PURE__ */ h("div", {
138
+ className: "flex justify-between items-center p-3 border rounded-lg bg-muted/30",
139
+ children: [/* @__PURE__ */ h("div", {
140
+ className: "flex items-center gap-2",
141
+ children: [/* @__PURE__ */ m(f, { className: "h-4 w-4 text-muted-foreground" }), /* @__PURE__ */ m("span", {
142
+ className: "text-sm font-medium",
143
+ children: e.name
144
+ })]
145
+ }), /* @__PURE__ */ m("span", {
146
+ className: "text-sm font-bold tabular-nums",
147
+ children: e.amount === 0 ? M("ecommerce.free") : y(e.amount, P)
148
+ })]
149
+ }, e.id))]
150
+ }), O && O.length === 0 && !A && /* @__PURE__ */ m("p", {
151
+ className: "text-xs text-muted-foreground mt-2 italic",
152
+ children: M("ecommerce.no_rates_found")
153
+ })]
154
+ })
155
+ ]
156
+ });
154
157
  };
158
+ //#endregion
159
+ export { v as ShippingEstimator };
@@ -1 +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;
1
+ const e=require("../../_virtual/_rolldown/runtime.cjs.js"),t=require("./SimpleTiptapRenderer.cjs.js");let n=require("react");n=e.__toESM(n,1);let r=require("@nextblock-cms/utils"),i=require("react/jsx-runtime");var a=/<\/?[a-z][^>]*>/i,o=e=>a.test(e);function s({value:e,className:n}){let a=e?.trim();return a?o(a)?(0,i.jsx)(`div`,{className:n,dangerouslySetInnerHTML:{__html:t.toNoCookieEmbedSrc(a)??a}}):(0,i.jsx)(`p`,{className:(0,r.cn)(`whitespace-pre-line`,n),children:a}):null}exports.ShortDescription=s,exports.isHtmlShortDescription=o;