@nextblock-cms/ecom 0.20.1 → 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,155 +1,160 @@
1
- 'use client';
2
- import { jsx as o, jsxs as m } from "react/jsx-runtime";
3
- import { useState as y, useEffect as B } from "react";
4
- import { Button as I } from "@nextblock-cms/ui/button";
5
- import { Skeleton as k } from "@nextblock-cms/ui/Skeleton";
6
- import { useCart as U } from "../use-cart.es.js";
7
- import { ShoppingCart as E } from "lucide-react";
8
- import { toast as P } from "sonner";
9
- import { getPublicFreemiusPricing as z } from "../pages/cms/products/actions.es.js";
10
- import { useTranslations as D, majorUnitAmountToMinor as d } from "@nextblock-cms/utils";
11
- import { usePriceFormatter as G } from "../use-price-formatter.es.js";
12
- import { useCurrency as H } from "../CurrencyProvider.es.js";
13
- import { convertMinorUnitAmount as _ } from "../currency.es.js";
14
- import { getTrialSummary as J } from "../trials.es.js";
15
- const oe = ({ product: e }) => {
16
- const S = G(), h = U((l) => l), { t } = D(), { activeCurrencyCode: c, currencies: u, defaultCurrency: n } = H(), [M, R] = y([]), [A, T] = y(!0), [i, f] = y("annual");
17
- if (B(() => {
18
- async function l() {
19
- try {
20
- if (!e.id) return;
21
- const s = await z(e.id);
22
- R(s);
23
- } catch (s) {
24
- console.error("Failed to load pricing:", s);
25
- } finally {
26
- T(!1);
27
- }
28
- }
29
- l();
30
- }, [e.id]), !h)
31
- return /* @__PURE__ */ o(k, { className: "h-14 w-full" });
32
- const { addItem: $ } = h, g = M[0], r = g?.pricing?.[0], j = () => {
33
- let l = e.price, s = e.freemius_plan_id;
34
- r && (i === "monthly" && r.monthly_price != null && (l = d(r.monthly_price, n.code)), i === "annual" && r.annual_price != null && (l = d(r.annual_price, n.code)), i === "lifetime" && r.lifetime_price != null && (l = d(r.lifetime_price, n.code)));
35
- const v = u.reduce((N, w) => (N[w.code] = _({
36
- amount: l,
37
- fromCurrencyCode: n.code,
38
- toCurrencyCode: w.code,
39
- currencies: u,
40
- applyRounding: !0
41
- }), N), {}), q = v[c] ?? l;
42
- g && g.id && (s = g.id);
43
- const { success: F, error: L } = $({
44
- id: e.id,
45
- product_id: e.id,
46
- title: e.title,
47
- price: q,
48
- prices: v,
49
- image_url: e.image_url,
50
- slug: e.slug,
51
- sku: e.sku,
52
- language_id: e.language_id,
53
- translation_group_id: e.translation_group_id,
54
- product_type: "digital",
55
- payment_provider: "freemius",
56
- provider: "freemius",
57
- billing_cycle: i,
58
- freemius_product_id: e.freemius_product_id,
59
- freemius_plan_id: s,
60
- // Overwrite if we got a real plan id
61
- trial_period_days: e.trial_period_days ?? 0,
62
- trial_requires_payment_method: e.trial_requires_payment_method ?? !1,
63
- is_taxable: e.is_taxable,
64
- currency_code: c
65
- });
66
- F ? P.success(t("ecommerce.added_to_cart_success", { item: e.title })) : P.error(L || t("ecommerce.added_to_cart_error"));
67
- };
68
- if (A)
69
- return /* @__PURE__ */ o(k, { className: "h-32 w-full" });
70
- if (!g || !r)
71
- return /* @__PURE__ */ o("div", { className: "p-4 border border-dashed rounded-lg text-center text-muted-foreground", children: t("ecommerce.pricing_unavailable") });
72
- const b = r.monthly_price != null, x = r.annual_price != null, C = r.lifetime_price != null;
73
- i === "annual" && !x && (b ? f("monthly") : C && f("lifetime"));
74
- const a = J(e, t);
75
- let p = e.price;
76
- return i === "monthly" && r.monthly_price != null && (p = _({
77
- amount: d(r.monthly_price, n.code),
78
- fromCurrencyCode: n.code,
79
- toCurrencyCode: c,
80
- currencies: u,
81
- applyRounding: !0
82
- })), i === "annual" && r.annual_price != null && (p = _({
83
- amount: d(r.annual_price, n.code),
84
- fromCurrencyCode: n.code,
85
- toCurrencyCode: c,
86
- currencies: u,
87
- applyRounding: !0
88
- })), i === "lifetime" && r.lifetime_price != null && (p = _({
89
- amount: d(r.lifetime_price, n.code),
90
- fromCurrencyCode: n.code,
91
- toCurrencyCode: c,
92
- currencies: u,
93
- applyRounding: !0
94
- })), /* @__PURE__ */ m("div", { className: "flex flex-col gap-4", children: [
95
- /* @__PURE__ */ m(
96
- "div",
97
- {
98
- role: "group",
99
- "aria-label": t("ecommerce.billing_cycle") === "ecommerce.billing_cycle" ? "Billing cycle" : t("ecommerce.billing_cycle"),
100
- className: "flex bg-secondary/35 p-1 rounded-lg w-full max-w-sm mx-auto shadow-inner",
101
- children: [
102
- b && /* @__PURE__ */ o(
103
- "button",
104
- {
105
- type: "button",
106
- "aria-pressed": i === "monthly",
107
- onClick: () => f("monthly"),
108
- className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${i === "monthly" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
109
- children: t("ecommerce.monthly")
110
- }
111
- ),
112
- x && /* @__PURE__ */ o(
113
- "button",
114
- {
115
- type: "button",
116
- "aria-pressed": i === "annual",
117
- onClick: () => f("annual"),
118
- className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${i === "annual" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
119
- children: t("ecommerce.annual")
120
- }
121
- ),
122
- C && /* @__PURE__ */ o(
123
- "button",
124
- {
125
- type: "button",
126
- "aria-pressed": i === "lifetime",
127
- onClick: () => f("lifetime"),
128
- className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${i === "lifetime" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
129
- children: t("ecommerce.lifetime")
130
- }
131
- )
132
- ]
133
- }
134
- ),
135
- /* @__PURE__ */ m("div", { className: "text-center", children: [
136
- /* @__PURE__ */ o("span", { className: "text-3xl font-extrabold text-foreground tabular-nums", children: S(p, c) }),
137
- i !== "lifetime" && /* @__PURE__ */ m("span", { className: "text-muted-foreground text-sm ml-1.5", children: [
138
- "/ ",
139
- t(i === "annual" ? "ecommerce.year" : "ecommerce.month")
140
- ] }),
141
- a && /* @__PURE__ */ m("div", { className: "mt-1 text-xs font-medium text-emerald-600 dark:text-emerald-400", children: [
142
- a.label,
143
- /* @__PURE__ */ o("span", { className: "mx-2 text-muted-foreground/50", children: "|" }),
144
- /* @__PURE__ */ o("span", { className: "text-muted-foreground", children: a.paymentRequirementLabel })
145
- ] })
146
- ] }),
147
- /* @__PURE__ */ m(I, { onClick: j, className: "w-full h-12 text-base font-bold shadow-md transition-shadow hover:shadow-lg active:scale-[0.98]", children: [
148
- /* @__PURE__ */ o(E, { className: "mr-2 h-4 w-4" }),
149
- a?.label ? t("ecommerce.start_trial", { trial: a.label }) === "ecommerce.start_trial" ? `Start ${a.label}` : t("ecommerce.start_trial", { trial: a.label }) : t("ecommerce.get_license")
150
- ] })
151
- ] });
152
- };
153
- export {
154
- oe as SubscriptionSelector
1
+ "use client";
2
+ import { convertMinorUnitAmount as e } from "../currency.es.js";
3
+ import { useCurrency as t } from "../CurrencyProvider.es.js";
4
+ import { useCart as n } from "../use-cart.es.js";
5
+ import { usePriceFormatter as r } from "../use-price-formatter.es.js";
6
+ import { getTrialSummary as i } from "../trials.es.js";
7
+ import { getPublicFreemiusPricing as a } from "../pages/cms/products/actions.es.js";
8
+ import { Button as o } from "@nextblock-cms/ui/button";
9
+ import { useEffect as s, useState as c } from "react";
10
+ import { ShoppingCart as l } from "lucide-react";
11
+ import { majorUnitAmountToMinor as u, useTranslations as d } from "@nextblock-cms/utils";
12
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
13
+ import { toast as m } from "sonner";
14
+ import { Skeleton as h } from "@nextblock-cms/ui/Skeleton";
15
+ //#region libs/ecommerce/src/lib/components/SubscriptionSelector.tsx
16
+ var g = ({ product: g }) => {
17
+ let _ = r(), v = n((e) => e), { t: y } = d(), { activeCurrencyCode: b, currencies: x, defaultCurrency: S } = t(), [C, w] = c([]), [T, E] = c(!0), [D, O] = c("annual");
18
+ if (s(() => {
19
+ async function e() {
20
+ try {
21
+ if (!g.id) return;
22
+ let e = await a(g.id);
23
+ w(e);
24
+ } catch (e) {
25
+ console.error("Failed to load pricing:", e);
26
+ } finally {
27
+ E(!1);
28
+ }
29
+ }
30
+ e();
31
+ }, [g.id]), !v) return /* @__PURE__ */ f(h, { className: "h-14 w-full" });
32
+ let { addItem: k } = v, A = C[0], j = A?.pricing?.[0], M = () => {
33
+ let t = g.price, n = g.freemius_plan_id;
34
+ j && (D === "monthly" && j.monthly_price != null && (t = u(j.monthly_price, S.code)), D === "annual" && j.annual_price != null && (t = u(j.annual_price, S.code)), D === "lifetime" && j.lifetime_price != null && (t = u(j.lifetime_price, S.code)));
35
+ let r = x.reduce((n, r) => (n[r.code] = e({
36
+ amount: t,
37
+ fromCurrencyCode: S.code,
38
+ toCurrencyCode: r.code,
39
+ currencies: x,
40
+ applyRounding: !0
41
+ }), n), {}), i = r[b] ?? t;
42
+ A && A.id && (n = A.id);
43
+ let { success: a, error: o } = k({
44
+ id: g.id,
45
+ product_id: g.id,
46
+ title: g.title,
47
+ price: i,
48
+ prices: r,
49
+ image_url: g.image_url,
50
+ slug: g.slug,
51
+ sku: g.sku,
52
+ language_id: g.language_id,
53
+ translation_group_id: g.translation_group_id,
54
+ product_type: "digital",
55
+ payment_provider: "freemius",
56
+ provider: "freemius",
57
+ billing_cycle: D,
58
+ freemius_product_id: g.freemius_product_id,
59
+ freemius_plan_id: n,
60
+ trial_period_days: g.trial_period_days ?? 0,
61
+ trial_requires_payment_method: g.trial_requires_payment_method ?? !1,
62
+ is_taxable: g.is_taxable,
63
+ currency_code: b
64
+ });
65
+ a ? m.success(y("ecommerce.added_to_cart_success", { item: g.title })) : m.error(o || y("ecommerce.added_to_cart_error"));
66
+ };
67
+ if (T) return /* @__PURE__ */ f(h, { className: "h-32 w-full" });
68
+ if (!A || !j) return /* @__PURE__ */ f("div", {
69
+ className: "p-4 border border-dashed rounded-lg text-center text-muted-foreground",
70
+ children: y("ecommerce.pricing_unavailable")
71
+ });
72
+ let N = j.monthly_price != null, P = j.annual_price != null, F = j.lifetime_price != null;
73
+ D === "annual" && !P && (N ? O("monthly") : F && O("lifetime"));
74
+ let I = i(g, y), L = g.price;
75
+ return D === "monthly" && j.monthly_price != null && (L = e({
76
+ amount: u(j.monthly_price, S.code),
77
+ fromCurrencyCode: S.code,
78
+ toCurrencyCode: b,
79
+ currencies: x,
80
+ applyRounding: !0
81
+ })), D === "annual" && j.annual_price != null && (L = e({
82
+ amount: u(j.annual_price, S.code),
83
+ fromCurrencyCode: S.code,
84
+ toCurrencyCode: b,
85
+ currencies: x,
86
+ applyRounding: !0
87
+ })), D === "lifetime" && j.lifetime_price != null && (L = e({
88
+ amount: u(j.lifetime_price, S.code),
89
+ fromCurrencyCode: S.code,
90
+ toCurrencyCode: b,
91
+ currencies: x,
92
+ applyRounding: !0
93
+ })), /* @__PURE__ */ p("div", {
94
+ className: "flex flex-col gap-4",
95
+ children: [
96
+ /* @__PURE__ */ p("div", {
97
+ role: "group",
98
+ "aria-label": y("ecommerce.billing_cycle") === "ecommerce.billing_cycle" ? "Billing cycle" : y("ecommerce.billing_cycle"),
99
+ className: "flex bg-secondary/35 p-1 rounded-lg w-full max-w-sm mx-auto shadow-inner",
100
+ children: [
101
+ N && /* @__PURE__ */ f("button", {
102
+ type: "button",
103
+ "aria-pressed": D === "monthly",
104
+ onClick: () => O("monthly"),
105
+ className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${D === "monthly" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
106
+ children: y("ecommerce.monthly")
107
+ }),
108
+ P && /* @__PURE__ */ f("button", {
109
+ type: "button",
110
+ "aria-pressed": D === "annual",
111
+ onClick: () => O("annual"),
112
+ className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${D === "annual" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
113
+ children: y("ecommerce.annual")
114
+ }),
115
+ F && /* @__PURE__ */ f("button", {
116
+ type: "button",
117
+ "aria-pressed": D === "lifetime",
118
+ onClick: () => O("lifetime"),
119
+ className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${D === "lifetime" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
120
+ children: y("ecommerce.lifetime")
121
+ })
122
+ ]
123
+ }),
124
+ /* @__PURE__ */ p("div", {
125
+ className: "text-center",
126
+ children: [
127
+ /* @__PURE__ */ f("span", {
128
+ className: "text-3xl font-extrabold text-foreground tabular-nums",
129
+ children: _(L, b)
130
+ }),
131
+ D !== "lifetime" && /* @__PURE__ */ p("span", {
132
+ className: "text-muted-foreground text-sm ml-1.5",
133
+ children: ["/ ", y(D === "annual" ? "ecommerce.year" : "ecommerce.month")]
134
+ }),
135
+ I && /* @__PURE__ */ p("div", {
136
+ className: "mt-1 text-xs font-medium text-emerald-600 dark:text-emerald-400",
137
+ children: [
138
+ I.label,
139
+ /* @__PURE__ */ f("span", {
140
+ className: "mx-2 text-muted-foreground/50",
141
+ children: "|"
142
+ }),
143
+ /* @__PURE__ */ f("span", {
144
+ className: "text-muted-foreground",
145
+ children: I.paymentRequirementLabel
146
+ })
147
+ ]
148
+ })
149
+ ]
150
+ }),
151
+ /* @__PURE__ */ p(o, {
152
+ onClick: M,
153
+ className: "w-full h-12 text-base font-bold shadow-md transition-shadow hover:shadow-lg active:scale-[0.98]",
154
+ children: [/* @__PURE__ */ f(l, { className: "mr-2 h-4 w-4" }), I?.label ? y("ecommerce.start_trial", { trial: I.label }) === "ecommerce.start_trial" ? `Start ${I.label}` : y("ecommerce.start_trial", { trial: I.label }) : y("ecommerce.get_license")]
155
+ })
156
+ ]
157
+ });
155
158
  };
159
+ //#endregion
160
+ export { g as SubscriptionSelector };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=[{code:"US",name:"United States"},{code:"CA",name:"Canada"},{code:"GB",name:"United Kingdom"},{code:"AU",name:"Australia"},{code:"NZ",name:"New Zealand"},{code:"IE",name:"Ireland"},{code:"FR",name:"France"},{code:"DE",name:"Germany"},{code:"IT",name:"Italy"},{code:"ES",name:"Spain"},{code:"MX",name:"Mexico"},{code:"BR",name:"Brazil"},{code:"AR",name:"Argentina"},{code:"CL",name:"Chile"},{code:"CO",name:"Colombia"},{code:"PE",name:"Peru"},{code:"ZA",name:"South Africa"},{code:"NG",name:"Nigeria"},{code:"KE",name:"Kenya"},{code:"IN",name:"India"},{code:"JP",name:"Japan"},{code:"KR",name:"South Korea"},{code:"CN",name:"China"},{code:"SG",name:"Singapore"},{code:"MY",name:"Malaysia"},{code:"PH",name:"Philippines"},{code:"TH",name:"Thailand"},{code:"VN",name:"Vietnam"},{code:"ID",name:"Indonesia"},{code:"AE",name:"United Arab Emirates"},{code:"SA",name:"Saudi Arabia"},{code:"EG",name:"Egypt"},{code:"MA",name:"Morocco"},{code:"DZ",name:"Algeria"},{code:"TN",name:"Tunisia"},{code:"PT",name:"Portugal"},{code:"NL",name:"Netherlands"},{code:"BE",name:"Belgium"},{code:"CH",name:"Switzerland"},{code:"AT",name:"Austria"},{code:"SE",name:"Sweden"},{code:"NO",name:"Norway"},{code:"DK",name:"Denmark"},{code:"FI",name:"Finland"},{code:"PL",name:"Poland"},{code:"CZ",name:"Czech Republic"},{code:"HU",name:"Hungary"},{code:"RO",name:"Romania"},{code:"BG",name:"Bulgaria"},{code:"GR",name:"Greece"},{code:"TR",name:"Turkey"},{code:"IL",name:"Israel"},{code:"CY",name:"Cyprus"},{code:"MT",name:"Malta"}],i={USA:"US","UNITED STATES OF AMERICA":"US",UK:"GB","GREAT BRITAIN":"GB"};function r(m){const o=m?.trim();if(!o)return null;const e=o.toUpperCase(),c=i[e];if(c)return c;const d=n.find(a=>a.code===e);return d?d.code:n.find(a=>a.name.toUpperCase()===e)?.code??null}exports.countries=n;exports.normalizeCountryCode=r;
1
+ var e=[{code:`US`,name:`United States`},{code:`CA`,name:`Canada`},{code:`GB`,name:`United Kingdom`},{code:`AU`,name:`Australia`},{code:`NZ`,name:`New Zealand`},{code:`IE`,name:`Ireland`},{code:`FR`,name:`France`},{code:`DE`,name:`Germany`},{code:`IT`,name:`Italy`},{code:`ES`,name:`Spain`},{code:`MX`,name:`Mexico`},{code:`BR`,name:`Brazil`},{code:`AR`,name:`Argentina`},{code:`CL`,name:`Chile`},{code:`CO`,name:`Colombia`},{code:`PE`,name:`Peru`},{code:`ZA`,name:`South Africa`},{code:`NG`,name:`Nigeria`},{code:`KE`,name:`Kenya`},{code:`IN`,name:`India`},{code:`JP`,name:`Japan`},{code:`KR`,name:`South Korea`},{code:`CN`,name:`China`},{code:`SG`,name:`Singapore`},{code:`MY`,name:`Malaysia`},{code:`PH`,name:`Philippines`},{code:`TH`,name:`Thailand`},{code:`VN`,name:`Vietnam`},{code:`ID`,name:`Indonesia`},{code:`AE`,name:`United Arab Emirates`},{code:`SA`,name:`Saudi Arabia`},{code:`EG`,name:`Egypt`},{code:`MA`,name:`Morocco`},{code:`DZ`,name:`Algeria`},{code:`TN`,name:`Tunisia`},{code:`PT`,name:`Portugal`},{code:`NL`,name:`Netherlands`},{code:`BE`,name:`Belgium`},{code:`CH`,name:`Switzerland`},{code:`AT`,name:`Austria`},{code:`SE`,name:`Sweden`},{code:`NO`,name:`Norway`},{code:`DK`,name:`Denmark`},{code:`FI`,name:`Finland`},{code:`PL`,name:`Poland`},{code:`CZ`,name:`Czech Republic`},{code:`HU`,name:`Hungary`},{code:`RO`,name:`Romania`},{code:`BG`,name:`Bulgaria`},{code:`GR`,name:`Greece`},{code:`TR`,name:`Turkey`},{code:`IL`,name:`Israel`},{code:`CY`,name:`Cyprus`},{code:`MT`,name:`Malta`}],t={USA:`US`,"UNITED STATES OF AMERICA":`US`,UK:`GB`,"GREAT BRITAIN":`GB`};function n(n){let r=n?.trim();if(!r)return null;let i=r.toUpperCase(),a=t[i];if(a)return a;let o=e.find(e=>e.code===i);return o?o.code:e.find(e=>e.name.toUpperCase()===i)?.code??null}exports.countries=e,exports.normalizeCountryCode=n;