@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"),n=require("react"),t=require("@nextblock-cms/ui"),j=require("../actions.cjs.js"),L=require("next/navigation"),h=require("lucide-react");function k({productId:i,currentLanguageId:C,translationGroupId:l,allSiteLanguages:x}){const[d,p]=n.useState(!1),[r,S]=n.useState(null),[y,v]=n.useState([]),[m,f]=n.useState(!1),[o,c]=n.useState(null),[u,b]=n.useTransition(),P=L.useRouter();n.useEffect(()=>{d&&l&&(async()=>{f(!0);try{const g=(await j.getProductTranslations(l)).filter(D=>D.id!==i);v(g)}catch(a){console.error("Error fetching translations:",a)}finally{f(!1)}})()},[d,l,i]);const T=async()=>{if(!r){c({type:"error",text:"Please select a source version to copy from."});return}c(null),b(async()=>{const s=await j.copyProductFromLanguageAction(i,r);s.success?(c({type:"success",text:"Content copied successfully. The page will now refresh."}),setTimeout(()=>{p(!1),P.refresh()},1500)):c({type:"error",text:s.error||"Failed to copy content."})})},w=x.find(s=>s.id===C);return e.jsxs(t.Dialog,{open:d,onOpenChange:p,children:[e.jsx(t.DialogTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"outline",title:"Copy content from another language",children:[e.jsx(h.Copy,{className:"h-4 w-4 mr-2"}),"Copy Content..."]})}),e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Copy Content from Another Language"}),e.jsxs(t.DialogDescription,{children:["Select a source version to copy from. This will replace the title, description, and media of the current product (",w?.name,"). This action cannot be undone."]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"sourceProduct",children:"Select Source Version"}),e.jsxs(t.Select,{onValueChange:s=>S(s),disabled:u||m,value:r||void 0,children:[e.jsx(t.SelectTrigger,{id:"sourceProduct",children:e.jsx(t.SelectValue,{placeholder:m?"Loading versions...":"Select a version..."})}),e.jsx(t.SelectContent,{children:y.length>0?y.map(s=>{const a=x.find(g=>g.id===s.language_id);return e.jsxs(t.SelectItem,{value:s.id,children:[s.title," (",a?.name||"Unknown Language",")"]},s.id)}):e.jsx(t.SelectItem,{value:"none",disabled:!0,children:"No other versions available"})})]})]}),o&&e.jsxs("div",{className:`p-3 rounded-md text-sm flex items-center gap-2 ${o.type==="success"?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"}`,children:[o.type==="success"?e.jsx(h.CheckCircle2,{className:"h-5 w-5"}):e.jsx(h.AlertCircle,{className:"h-5 w-5"}),o.text]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(t.DialogClose,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})}),e.jsx(t.Button,{onClick:T,disabled:u||!r||r==="none",children:u?"Copying...":"Copy Content & Replace"})]})]})]})}exports.CopyProductFromLanguage=k;
1
+ "use client";const e=require("../../../../../_virtual/_rolldown/runtime.cjs.js"),t=require("../actions.cjs.js");let n=require("react");n=e.__toESM(n,1);let r=require("lucide-react"),i=require("react/jsx-runtime"),a=require("next/navigation"),o=require("@nextblock-cms/ui");function s({productId:e,currentLanguageId:s,translationGroupId:c,allSiteLanguages:l}){let[u,d]=(0,n.useState)(!1),[f,p]=(0,n.useState)(null),[m,h]=(0,n.useState)([]),[g,_]=(0,n.useState)(!1),[v,y]=(0,n.useState)(null),[b,x]=(0,n.useTransition)(),S=(0,a.useRouter)();(0,n.useEffect)(()=>{u&&c&&(async()=>{_(!0);try{let n=(await t.getProductTranslations(c)).filter(t=>t.id!==e);h(n)}catch(e){console.error(`Error fetching translations:`,e)}finally{_(!1)}})()},[u,c,e]);let C=async()=>{if(!f){y({type:`error`,text:`Please select a source version to copy from.`});return}y(null),x(async()=>{let n=await t.copyProductFromLanguageAction(e,f);n.success?(y({type:`success`,text:`Content copied successfully. The page will now refresh.`}),setTimeout(()=>{d(!1),S.refresh()},1500)):y({type:`error`,text:n.error||`Failed to copy content.`})})},w=l.find(e=>e.id===s);return(0,i.jsxs)(o.Dialog,{open:u,onOpenChange:d,children:[(0,i.jsx)(o.DialogTrigger,{asChild:!0,children:(0,i.jsxs)(o.Button,{variant:`outline`,title:`Copy content from another language`,children:[(0,i.jsx)(r.Copy,{className:`h-4 w-4 mr-2`}),`Copy Content...`]})}),(0,i.jsxs)(o.DialogContent,{children:[(0,i.jsxs)(o.DialogHeader,{children:[(0,i.jsx)(o.DialogTitle,{children:`Copy Content from Another Language`}),(0,i.jsxs)(o.DialogDescription,{children:[`Select a source version to copy from. This will replace the title, description, and media of the current product (`,w?.name,`). This action cannot be undone.`]})]}),(0,i.jsxs)(`div`,{className:`space-y-4 py-4`,children:[(0,i.jsxs)(`div`,{className:`space-y-2`,children:[(0,i.jsx)(o.Label,{htmlFor:`sourceProduct`,children:`Select Source Version`}),(0,i.jsxs)(o.Select,{onValueChange:e=>p(e),disabled:b||g,value:f||void 0,children:[(0,i.jsx)(o.SelectTrigger,{id:`sourceProduct`,children:(0,i.jsx)(o.SelectValue,{placeholder:g?`Loading versions...`:`Select a version...`})}),(0,i.jsx)(o.SelectContent,{children:m.length>0?m.map(e=>{let t=l.find(t=>t.id===e.language_id);return(0,i.jsxs)(o.SelectItem,{value:e.id,children:[e.title,` (`,t?.name||`Unknown Language`,`)`]},e.id)}):(0,i.jsx)(o.SelectItem,{value:`none`,disabled:!0,children:`No other versions available`})})]})]}),v&&(0,i.jsxs)(`div`,{className:`p-3 rounded-md text-sm flex items-center gap-2 ${v.type===`success`?`bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400`:`bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400`}`,children:[v.type===`success`?(0,i.jsx)(r.CheckCircle2,{className:`h-5 w-5`}):(0,i.jsx)(r.AlertCircle,{className:`h-5 w-5`}),v.text]})]}),(0,i.jsxs)(o.DialogFooter,{children:[(0,i.jsx)(o.DialogClose,{asChild:!0,children:(0,i.jsx)(o.Button,{variant:`outline`,children:`Cancel`})}),(0,i.jsx)(o.Button,{onClick:C,disabled:b||!f||f===`none`,children:b?`Copying...`:`Copy Content & Replace`})]})]})]})}exports.CopyProductFromLanguage=s;
@@ -1,114 +1,116 @@
1
- 'use client';
2
- import { jsxs as r, jsx as e } from "react/jsx-runtime";
3
- import { useState as o, useTransition as k, useEffect as N } from "react";
4
- import { Dialog as F, DialogTrigger as A, Button as h, DialogContent as M, DialogHeader as O, DialogTitle as V, DialogDescription as j, Label as E, Select as R, SelectTrigger as B, SelectValue as H, SelectContent as I, SelectItem as S, DialogFooter as U, DialogClose as _ } from "@nextblock-cms/ui";
5
- import { getProductTranslations as $, copyProductFromLanguageAction as q } from "../actions.es.js";
6
- import { useRouter as z } from "next/navigation";
7
- import { Copy as J, CheckCircle2 as K, AlertCircle as Q } from "lucide-react";
8
- function te({
9
- productId: i,
10
- currentLanguageId: v,
11
- translationGroupId: l,
12
- allSiteLanguages: p
13
- }) {
14
- const [d, m] = o(!1), [n, x] = o(null), [f, b] = o([]), [y, C] = o(!1), [s, c] = o(null), [u, T] = k(), w = z();
15
- N(() => {
16
- d && l && (async () => {
17
- C(!0);
18
- try {
19
- const g = (await $(l)).filter((L) => L.id !== i);
20
- b(g);
21
- } catch (a) {
22
- console.error("Error fetching translations:", a);
23
- } finally {
24
- C(!1);
25
- }
26
- })();
27
- }, [d, l, i]);
28
- const D = async () => {
29
- if (!n) {
30
- c({
31
- type: "error",
32
- text: "Please select a source version to copy from."
33
- });
34
- return;
35
- }
36
- c(null), T(async () => {
37
- const t = await q(i, n);
38
- t.success ? (c({
39
- type: "success",
40
- text: "Content copied successfully. The page will now refresh."
41
- }), setTimeout(() => {
42
- m(!1), w.refresh();
43
- }, 1500)) : c({
44
- type: "error",
45
- text: t.error || "Failed to copy content."
46
- });
47
- });
48
- }, P = p.find((t) => t.id === v);
49
- return /* @__PURE__ */ r(F, { open: d, onOpenChange: m, children: [
50
- /* @__PURE__ */ e(A, { asChild: !0, children: /* @__PURE__ */ r(h, { variant: "outline", title: "Copy content from another language", children: [
51
- /* @__PURE__ */ e(J, { className: "h-4 w-4 mr-2" }),
52
- "Copy Content..."
53
- ] }) }),
54
- /* @__PURE__ */ r(M, { children: [
55
- /* @__PURE__ */ r(O, { children: [
56
- /* @__PURE__ */ e(V, { children: "Copy Content from Another Language" }),
57
- /* @__PURE__ */ r(j, { children: [
58
- "Select a source version to copy from. This will replace the title, description, and media of the current product (",
59
- P?.name,
60
- "). This action cannot be undone."
61
- ] })
62
- ] }),
63
- /* @__PURE__ */ r("div", { className: "space-y-4 py-4", children: [
64
- /* @__PURE__ */ r("div", { className: "space-y-2", children: [
65
- /* @__PURE__ */ e(E, { htmlFor: "sourceProduct", children: "Select Source Version" }),
66
- /* @__PURE__ */ r(
67
- R,
68
- {
69
- onValueChange: (t) => x(t),
70
- disabled: u || y,
71
- value: n || void 0,
72
- children: [
73
- /* @__PURE__ */ e(B, { id: "sourceProduct", children: /* @__PURE__ */ e(H, { placeholder: y ? "Loading versions..." : "Select a version..." }) }),
74
- /* @__PURE__ */ e(I, { children: f.length > 0 ? f.map((t) => {
75
- const a = p.find((g) => g.id === t.language_id);
76
- return /* @__PURE__ */ r(S, { value: t.id, children: [
77
- t.title,
78
- " (",
79
- a?.name || "Unknown Language",
80
- ")"
81
- ] }, t.id);
82
- }) : /* @__PURE__ */ e(S, { value: "none", disabled: !0, children: "No other versions available" }) })
83
- ]
84
- }
85
- )
86
- ] }),
87
- s && /* @__PURE__ */ r(
88
- "div",
89
- {
90
- className: `p-3 rounded-md text-sm flex items-center gap-2 ${s.type === "success" ? "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400" : "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"}`,
91
- children: [
92
- s.type === "success" ? /* @__PURE__ */ e(K, { className: "h-5 w-5" }) : /* @__PURE__ */ e(Q, { className: "h-5 w-5" }),
93
- s.text
94
- ]
95
- }
96
- )
97
- ] }),
98
- /* @__PURE__ */ r(U, { children: [
99
- /* @__PURE__ */ e(_, { asChild: !0, children: /* @__PURE__ */ e(h, { variant: "outline", children: "Cancel" }) }),
100
- /* @__PURE__ */ e(
101
- h,
102
- {
103
- onClick: D,
104
- disabled: u || !n || n === "none",
105
- children: u ? "Copying..." : "Copy Content & Replace"
106
- }
107
- )
108
- ] })
109
- ] })
110
- ] });
1
+ "use client";
2
+ import { copyProductFromLanguageAction as e, getProductTranslations as t } from "../actions.es.js";
3
+ import { useEffect as n, useState as r, useTransition as i } from "react";
4
+ import { AlertCircle as a, CheckCircle2 as o, Copy as s } from "lucide-react";
5
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
6
+ import { useRouter as u } from "next/navigation";
7
+ import { Button as d, Dialog as f, DialogClose as p, DialogContent as m, DialogDescription as h, DialogFooter as g, DialogHeader as _, DialogTitle as v, DialogTrigger as y, Label as b, Select as x, SelectContent as S, SelectItem as C, SelectTrigger as w, SelectValue as T } from "@nextblock-cms/ui";
8
+ //#region libs/ecommerce/src/lib/pages/cms/products/components/CopyProductFromLanguage.tsx
9
+ function E({ productId: E, currentLanguageId: D, translationGroupId: O, allSiteLanguages: k }) {
10
+ let [A, j] = r(!1), [M, N] = r(null), [P, F] = r([]), [I, L] = r(!1), [R, z] = r(null), [B, V] = i(), H = u();
11
+ n(() => {
12
+ A && O && (async () => {
13
+ L(!0);
14
+ try {
15
+ let e = (await t(O)).filter((e) => e.id !== E);
16
+ F(e);
17
+ } catch (e) {
18
+ console.error("Error fetching translations:", e);
19
+ } finally {
20
+ L(!1);
21
+ }
22
+ })();
23
+ }, [
24
+ A,
25
+ O,
26
+ E
27
+ ]);
28
+ let U = async () => {
29
+ if (!M) {
30
+ z({
31
+ type: "error",
32
+ text: "Please select a source version to copy from."
33
+ });
34
+ return;
35
+ }
36
+ z(null), V(async () => {
37
+ let t = await e(E, M);
38
+ t.success ? (z({
39
+ type: "success",
40
+ text: "Content copied successfully. The page will now refresh."
41
+ }), setTimeout(() => {
42
+ j(!1), H.refresh();
43
+ }, 1500)) : z({
44
+ type: "error",
45
+ text: t.error || "Failed to copy content."
46
+ });
47
+ });
48
+ }, W = k.find((e) => e.id === D);
49
+ return /* @__PURE__ */ l(f, {
50
+ open: A,
51
+ onOpenChange: j,
52
+ children: [/* @__PURE__ */ c(y, {
53
+ asChild: !0,
54
+ children: /* @__PURE__ */ l(d, {
55
+ variant: "outline",
56
+ title: "Copy content from another language",
57
+ children: [/* @__PURE__ */ c(s, { className: "h-4 w-4 mr-2" }), "Copy Content..."]
58
+ })
59
+ }), /* @__PURE__ */ l(m, { children: [
60
+ /* @__PURE__ */ l(_, { children: [/* @__PURE__ */ c(v, { children: "Copy Content from Another Language" }), /* @__PURE__ */ l(h, { children: [
61
+ "Select a source version to copy from. This will replace the title, description, and media of the current product (",
62
+ W?.name,
63
+ "). This action cannot be undone."
64
+ ] })] }),
65
+ /* @__PURE__ */ l("div", {
66
+ className: "space-y-4 py-4",
67
+ children: [/* @__PURE__ */ l("div", {
68
+ className: "space-y-2",
69
+ children: [/* @__PURE__ */ c(b, {
70
+ htmlFor: "sourceProduct",
71
+ children: "Select Source Version"
72
+ }), /* @__PURE__ */ l(x, {
73
+ onValueChange: (e) => N(e),
74
+ disabled: B || I,
75
+ value: M || void 0,
76
+ children: [/* @__PURE__ */ c(w, {
77
+ id: "sourceProduct",
78
+ children: /* @__PURE__ */ c(T, { placeholder: I ? "Loading versions..." : "Select a version..." })
79
+ }), /* @__PURE__ */ c(S, { children: P.length > 0 ? P.map((e) => {
80
+ let t = k.find((t) => t.id === e.language_id);
81
+ return /* @__PURE__ */ l(C, {
82
+ value: e.id,
83
+ children: [
84
+ e.title,
85
+ " (",
86
+ t?.name || "Unknown Language",
87
+ ")"
88
+ ]
89
+ }, e.id);
90
+ }) : /* @__PURE__ */ c(C, {
91
+ value: "none",
92
+ disabled: !0,
93
+ children: "No other versions available"
94
+ }) })]
95
+ })]
96
+ }), R && /* @__PURE__ */ l("div", {
97
+ className: `p-3 rounded-md text-sm flex items-center gap-2 ${R.type === "success" ? "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400" : "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"}`,
98
+ children: [R.type === "success" ? /* @__PURE__ */ c(o, { className: "h-5 w-5" }) : /* @__PURE__ */ c(a, { className: "h-5 w-5" }), R.text]
99
+ })]
100
+ }),
101
+ /* @__PURE__ */ l(g, { children: [/* @__PURE__ */ c(p, {
102
+ asChild: !0,
103
+ children: /* @__PURE__ */ c(d, {
104
+ variant: "outline",
105
+ children: "Cancel"
106
+ })
107
+ }), /* @__PURE__ */ c(d, {
108
+ onClick: U,
109
+ disabled: B || !M || M === "none",
110
+ children: B ? "Copying..." : "Copy Content & Replace"
111
+ })] })
112
+ ] })]
113
+ });
111
114
  }
112
- export {
113
- te as CopyProductFromLanguage
114
- };
115
+ //#endregion
116
+ export { E as CopyProductFromLanguage };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),N=require("react"),y=require("@nextblock-cms/ui"),w=require("@nextblock-cms/utils"),v=require("../../../../currency.cjs.js");function C(s){return w.getCurrencyMinorUnitFactor(s)===1?0:2}function h(s,d){return s==null||Number.isNaN(s)?"":s.toFixed(d)}function j({id:s,currencyCode:d,value:n,disabled:x,placeholder:p,className:f,allowEmpty:g=!1,onValueChange:i}){const c=C(d),[u,m]=N.useState(!1),[b,l]=N.useState(()=>h(n,c));return N.useEffect(()=>{u||l(h(n,c))},[n,c,u]),t.jsx(y.Input,{id:s,type:"text",inputMode:"decimal",value:b,disabled:x,placeholder:p,className:f,onFocus:()=>m(!0),onChange:e=>{let r=e.target.value.replace(/[^0-9.]/g,"");const o=r.indexOf(".");if(o!==-1&&(r=r.slice(0,o+1)+r.slice(o+1).replace(/\./g,"")),l(r),r===""||r==="."){i(g?null:0);return}const a=Number(r);Number.isNaN(a)||i(a)},onBlur:()=>{if(m(!1),n!=null&&!Number.isNaN(n)){const e=Number(n.toFixed(c));e!==n&&i(e)}}})}function k({idPrefix:s="currency",currencies:d,prices:n,salePrices:x,managedCurrencyCodes:p=[],onPriceChange:f,onSalePriceChange:g,readOnly:i=!1,helperText:c,trailing:u}){const m=d.find(l=>l.is_default)??d[0],b=new Set(p);return m?t.jsxs("div",{className:"flex flex-col gap-2",children:[c&&t.jsx("p",{className:"text-xs text-muted-foreground bg-muted/20 p-2 rounded-md border",children:c}),t.jsx("div",{className:"divide-y divide-muted/50",children:d.map(l=>{const e=v.normalizeCurrencyRecord(l),r=e.is_default!==!0&&b.has(e.code),o=i||r;return t.jsxs("div",{className:"flex flex-wrap items-stretch gap-4 py-3 first:pt-0 last:pb-0",children:[t.jsxs("div",{className:"flex items-center gap-2 w-[160px] shrink-0 self-stretch border-r border-border/50 pr-4",children:[t.jsx("span",{className:"text-sm font-black tracking-tighter text-foreground",children:e.code}),t.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:e.symbol}),e.is_default?t.jsx("span",{className:"text-[9px] uppercase font-bold bg-primary/10 text-primary px-1.5 py-0.5 rounded tracking-widest leading-none",children:"Default"}):r?t.jsx("span",{className:"text-[9px] uppercase font-bold bg-muted text-muted-foreground px-1.5 py-0.5 rounded tracking-widest leading-none",children:"Auto"}):null,!e.is_default&&t.jsxs("span",{className:"text-[9px] text-muted-foreground/80 font-medium tracking-wide leading-none ml-auto",children:["x",e.exchange_rate]})]}),t.jsxs("div",{className:"grid flex-1 grid-cols-2 items-end gap-3 sm:grid-cols-4",children:[t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsx(y.Label,{htmlFor:`${s}-price-${e.code}`,className:"block text-[10px] uppercase font-bold text-muted-foreground tracking-widest",children:"Price"}),t.jsxs("div",{className:"relative",children:[t.jsx("span",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-xs text-muted-foreground font-bold pointer-events-none",children:e.symbol}),t.jsx(j,{id:`${s}-price-${e.code}`,currencyCode:e.code,value:n[e.code],disabled:o,className:"h-8 w-full text-sm pl-6",onValueChange:a=>f(e.code,a??0)})]})]}),t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsx(y.Label,{htmlFor:`${s}-sale-price-${e.code}`,className:"block text-[10px] uppercase font-bold text-muted-foreground tracking-widest",children:"Sale"}),t.jsxs("div",{className:"relative",children:[t.jsx("span",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-xs text-muted-foreground font-bold pointer-events-none",children:e.symbol}),t.jsx(j,{id:`${s}-sale-price-${e.code}`,currencyCode:e.code,value:x[e.code],disabled:o,placeholder:r?"Auto":"—",allowEmpty:!0,className:"h-8 w-full text-sm pl-6",onValueChange:a=>g(e.code,a)})]})]}),u&&e.is_default?u:null]})]},e.code)})})]}):null}exports.CurrencyPriceFields=k;
1
+ "use client";const e=require("../../../../currency.cjs.js");let t=require("react"),n=require("@nextblock-cms/utils"),r=require("react/jsx-runtime"),i=require("@nextblock-cms/ui");function a(e){return(0,n.getCurrencyMinorUnitFactor)(e)===1?0:2}function o(e,t){return e==null||Number.isNaN(e)?``:e.toFixed(t)}function s({id:e,currencyCode:n,value:s,disabled:c,placeholder:l,className:u,allowEmpty:d=!1,onValueChange:f}){let p=a(n),[m,h]=(0,t.useState)(!1),[g,_]=(0,t.useState)(()=>o(s,p));return(0,t.useEffect)(()=>{m||_(o(s,p))},[s,p,m]),(0,r.jsx)(i.Input,{id:e,type:`text`,inputMode:`decimal`,value:g,disabled:c,placeholder:l,className:u,onFocus:()=>h(!0),onChange:e=>{let t=e.target.value.replace(/[^0-9.]/g,``),n=t.indexOf(`.`);if(n!==-1&&(t=t.slice(0,n+1)+t.slice(n+1).replace(/\./g,``)),_(t),t===``||t===`.`){f(d?null:0);return}let r=Number(t);Number.isNaN(r)||f(r)},onBlur:()=>{if(h(!1),s!=null&&!Number.isNaN(s)){let e=Number(s.toFixed(p));e!==s&&f(e)}}})}function c({idPrefix:t=`currency`,currencies:n,prices:a,salePrices:o,managedCurrencyCodes:c=[],onPriceChange:l,onSalePriceChange:u,readOnly:d=!1,helperText:f,trailing:p}){let m=n.find(e=>e.is_default)??n[0],h=new Set(c);return m?(0,r.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[f&&(0,r.jsx)(`p`,{className:`text-xs text-muted-foreground bg-muted/20 p-2 rounded-md border`,children:f}),(0,r.jsx)(`div`,{className:`divide-y divide-muted/50`,children:n.map(n=>{let c=e.normalizeCurrencyRecord(n),f=c.is_default!==!0&&h.has(c.code),m=d||f;return(0,r.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-4 py-3 first:pt-0 last:pb-0`,children:[(0,r.jsxs)(`div`,{className:`flex items-center gap-2 w-[160px] shrink-0 self-stretch border-r border-border/50 pr-4`,children:[(0,r.jsx)(`span`,{className:`text-sm font-black tracking-tighter text-foreground`,children:c.code}),(0,r.jsx)(`span`,{className:`text-[11px] text-muted-foreground font-medium`,children:c.symbol}),c.is_default?(0,r.jsx)(`span`,{className:`text-[9px] uppercase font-bold bg-primary/10 text-primary px-1.5 py-0.5 rounded tracking-widest leading-none`,children:`Default`}):f?(0,r.jsx)(`span`,{className:`text-[9px] uppercase font-bold bg-muted text-muted-foreground px-1.5 py-0.5 rounded tracking-widest leading-none`,children:`Auto`}):null,!c.is_default&&(0,r.jsxs)(`span`,{className:`text-[9px] text-muted-foreground/80 font-medium tracking-wide leading-none ml-auto`,children:[`x`,c.exchange_rate]})]}),(0,r.jsxs)(`div`,{className:`grid flex-1 grid-cols-2 items-end gap-3 sm:grid-cols-4`,children:[(0,r.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,r.jsx)(i.Label,{htmlFor:`${t}-price-${c.code}`,className:`block text-[10px] uppercase font-bold text-muted-foreground tracking-widest`,children:`Price`}),(0,r.jsxs)(`div`,{className:`relative`,children:[(0,r.jsx)(`span`,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 text-xs text-muted-foreground font-bold pointer-events-none`,children:c.symbol}),(0,r.jsx)(s,{id:`${t}-price-${c.code}`,currencyCode:c.code,value:a[c.code],disabled:m,className:`h-8 w-full text-sm pl-6`,onValueChange:e=>l(c.code,e??0)})]})]}),(0,r.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,r.jsx)(i.Label,{htmlFor:`${t}-sale-price-${c.code}`,className:`block text-[10px] uppercase font-bold text-muted-foreground tracking-widest`,children:`Sale`}),(0,r.jsxs)(`div`,{className:`relative`,children:[(0,r.jsx)(`span`,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 text-xs text-muted-foreground font-bold pointer-events-none`,children:c.symbol}),(0,r.jsx)(s,{id:`${t}-sale-price-${c.code}`,currencyCode:c.code,value:o[c.code],disabled:m,placeholder:f?`Auto`:`—`,allowEmpty:!0,className:`h-8 w-full text-sm pl-6`,onValueChange:e=>u(c.code,e)})]})]}),p&&c.is_default?p:null]})]},c.code)})})]}):null}exports.CurrencyPriceFields=c;
@@ -14,5 +14,5 @@ interface CurrencyPriceFieldsProps {
14
14
  /** Rendered inline at the end of the default-currency row (e.g. a sale schedule). */
15
15
  trailing?: ReactNode;
16
16
  }
17
- export declare function CurrencyPriceFields({ idPrefix, currencies, prices, salePrices, managedCurrencyCodes, onPriceChange, onSalePriceChange, readOnly, helperText, trailing, }: CurrencyPriceFieldsProps): import("react").JSX.Element | null;
17
+ export declare function CurrencyPriceFields({ idPrefix, currencies, prices, salePrices, managedCurrencyCodes, onPriceChange, onSalePriceChange, readOnly, helperText, trailing, }: CurrencyPriceFieldsProps): import('react').JSX.Element | null;
18
18
  export {};
@@ -1,149 +1,140 @@
1
- 'use client';
2
- import { jsxs as d, jsx as r } from "react/jsx-runtime";
3
- import { useState as h, useEffect as k } from "react";
4
- import { Label as y, Input as C } from "@nextblock-cms/ui";
5
- import { getCurrencyMinorUnitFactor as F } from "@nextblock-cms/utils";
6
- import { normalizeCurrencyRecord as $ } from "../../../../currency.es.js";
7
- function _(t) {
8
- return F(t) === 1 ? 0 : 2;
1
+ "use client";
2
+ import { normalizeCurrencyRecord as e } from "../../../../currency.es.js";
3
+ import { useEffect as t, useState as n } from "react";
4
+ import { getCurrencyMinorUnitFactor as r } from "@nextblock-cms/utils";
5
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
+ import { Input as o, Label as s } from "@nextblock-cms/ui";
7
+ //#region libs/ecommerce/src/lib/pages/cms/products/components/CurrencyPriceFields.tsx
8
+ function c(e) {
9
+ return r(e) === 1 ? 0 : 2;
9
10
  }
10
- function w(t, o) {
11
- return t == null || Number.isNaN(t) ? "" : t.toFixed(o);
11
+ function l(e, t) {
12
+ return e == null || Number.isNaN(e) ? "" : e.toFixed(t);
12
13
  }
13
- function v({
14
- id: t,
15
- currencyCode: o,
16
- value: s,
17
- disabled: f,
18
- placeholder: x,
19
- className: g,
20
- allowEmpty: N = !1,
21
- onValueChange: u
22
- }) {
23
- const a = _(o), [m, p] = h(!1), [b, l] = h(() => w(s, a));
24
- return k(() => {
25
- m || l(w(s, a));
26
- }, [s, a, m]), /* @__PURE__ */ r(
27
- C,
28
- {
29
- id: t,
30
- type: "text",
31
- inputMode: "decimal",
32
- value: b,
33
- disabled: f,
34
- placeholder: x,
35
- className: g,
36
- onFocus: () => p(!0),
37
- onChange: (e) => {
38
- let n = e.target.value.replace(/[^0-9.]/g, "");
39
- const c = n.indexOf(".");
40
- if (c !== -1 && (n = n.slice(0, c + 1) + n.slice(c + 1).replace(/\./g, "")), l(n), n === "" || n === ".") {
41
- u(N ? null : 0);
42
- return;
43
- }
44
- const i = Number(n);
45
- Number.isNaN(i) || u(i);
46
- },
47
- onBlur: () => {
48
- if (p(!1), s != null && !Number.isNaN(s)) {
49
- const e = Number(s.toFixed(a));
50
- e !== s && u(e);
51
- }
52
- }
53
- }
54
- );
14
+ function u({ id: e, currencyCode: r, value: a, disabled: s, placeholder: u, className: d, allowEmpty: f = !1, onValueChange: p }) {
15
+ let m = c(r), [h, g] = n(!1), [_, v] = n(() => l(a, m));
16
+ return t(() => {
17
+ h || v(l(a, m));
18
+ }, [
19
+ a,
20
+ m,
21
+ h
22
+ ]), /* @__PURE__ */ i(o, {
23
+ id: e,
24
+ type: "text",
25
+ inputMode: "decimal",
26
+ value: _,
27
+ disabled: s,
28
+ placeholder: u,
29
+ className: d,
30
+ onFocus: () => g(!0),
31
+ onChange: (e) => {
32
+ let t = e.target.value.replace(/[^0-9.]/g, ""), n = t.indexOf(".");
33
+ if (n !== -1 && (t = t.slice(0, n + 1) + t.slice(n + 1).replace(/\./g, "")), v(t), t === "" || t === ".") {
34
+ p(f ? null : 0);
35
+ return;
36
+ }
37
+ let r = Number(t);
38
+ Number.isNaN(r) || p(r);
39
+ },
40
+ onBlur: () => {
41
+ if (g(!1), a != null && !Number.isNaN(a)) {
42
+ let e = Number(a.toFixed(m));
43
+ e !== a && p(e);
44
+ }
45
+ }
46
+ });
55
47
  }
56
- function z({
57
- idPrefix: t = "currency",
58
- currencies: o,
59
- prices: s,
60
- salePrices: f,
61
- managedCurrencyCodes: x = [],
62
- onPriceChange: g,
63
- onSalePriceChange: N,
64
- readOnly: u = !1,
65
- helperText: a,
66
- trailing: m
67
- }) {
68
- const p = o.find((l) => l.is_default) ?? o[0], b = new Set(x);
69
- return p ? /* @__PURE__ */ d("div", { className: "flex flex-col gap-2", children: [
70
- a && /* @__PURE__ */ r("p", { className: "text-xs text-muted-foreground bg-muted/20 p-2 rounded-md border", children: a }),
71
- /* @__PURE__ */ r("div", { className: "divide-y divide-muted/50", children: o.map((l) => {
72
- const e = $(l), n = e.is_default !== !0 && b.has(e.code), c = u || n;
73
- return /* @__PURE__ */ d(
74
- "div",
75
- {
76
- className: "flex flex-wrap items-stretch gap-4 py-3 first:pt-0 last:pb-0",
77
- children: [
78
- /* @__PURE__ */ d("div", { className: "flex items-center gap-2 w-[160px] shrink-0 self-stretch border-r border-border/50 pr-4", children: [
79
- /* @__PURE__ */ r("span", { className: "text-sm font-black tracking-tighter text-foreground", children: e.code }),
80
- /* @__PURE__ */ r("span", { className: "text-[11px] text-muted-foreground font-medium", children: e.symbol }),
81
- e.is_default ? /* @__PURE__ */ r("span", { className: "text-[9px] uppercase font-bold bg-primary/10 text-primary px-1.5 py-0.5 rounded tracking-widest leading-none", children: "Default" }) : n ? /* @__PURE__ */ r("span", { className: "text-[9px] uppercase font-bold bg-muted text-muted-foreground px-1.5 py-0.5 rounded tracking-widest leading-none", children: "Auto" }) : null,
82
- !e.is_default && /* @__PURE__ */ d("span", { className: "text-[9px] text-muted-foreground/80 font-medium tracking-wide leading-none ml-auto", children: [
83
- "x",
84
- e.exchange_rate
85
- ] })
86
- ] }),
87
- /* @__PURE__ */ d("div", { className: "grid flex-1 grid-cols-2 items-end gap-3 sm:grid-cols-4", children: [
88
- /* @__PURE__ */ d("div", { className: "min-w-0 space-y-1", children: [
89
- /* @__PURE__ */ r(
90
- y,
91
- {
92
- htmlFor: `${t}-price-${e.code}`,
93
- className: "block text-[10px] uppercase font-bold text-muted-foreground tracking-widest",
94
- children: "Price"
95
- }
96
- ),
97
- /* @__PURE__ */ d("div", { className: "relative", children: [
98
- /* @__PURE__ */ r("span", { className: "absolute left-2.5 top-1/2 -translate-y-1/2 text-xs text-muted-foreground font-bold pointer-events-none", children: e.symbol }),
99
- /* @__PURE__ */ r(
100
- v,
101
- {
102
- id: `${t}-price-${e.code}`,
103
- currencyCode: e.code,
104
- value: s[e.code],
105
- disabled: c,
106
- className: "h-8 w-full text-sm pl-6",
107
- onValueChange: (i) => g(e.code, i ?? 0)
108
- }
109
- )
110
- ] })
111
- ] }),
112
- /* @__PURE__ */ d("div", { className: "min-w-0 space-y-1", children: [
113
- /* @__PURE__ */ r(
114
- y,
115
- {
116
- htmlFor: `${t}-sale-price-${e.code}`,
117
- className: "block text-[10px] uppercase font-bold text-muted-foreground tracking-widest",
118
- children: "Sale"
119
- }
120
- ),
121
- /* @__PURE__ */ d("div", { className: "relative", children: [
122
- /* @__PURE__ */ r("span", { className: "absolute left-2.5 top-1/2 -translate-y-1/2 text-xs text-muted-foreground font-bold pointer-events-none", children: e.symbol }),
123
- /* @__PURE__ */ r(
124
- v,
125
- {
126
- id: `${t}-sale-price-${e.code}`,
127
- currencyCode: e.code,
128
- value: f[e.code],
129
- disabled: c,
130
- placeholder: n ? "Auto" : "—",
131
- allowEmpty: !0,
132
- className: "h-8 w-full text-sm pl-6",
133
- onValueChange: (i) => N(e.code, i)
134
- }
135
- )
136
- ] })
137
- ] }),
138
- m && e.is_default ? m : null
139
- ] })
140
- ]
141
- },
142
- e.code
143
- );
144
- }) })
145
- ] }) : null;
48
+ function d({ idPrefix: t = "currency", currencies: n, prices: r, salePrices: o, managedCurrencyCodes: c = [], onPriceChange: l, onSalePriceChange: d, readOnly: f = !1, helperText: p, trailing: m }) {
49
+ let h = n.find((e) => e.is_default) ?? n[0], g = new Set(c);
50
+ return h ? /* @__PURE__ */ a("div", {
51
+ className: "flex flex-col gap-2",
52
+ children: [p && /* @__PURE__ */ i("p", {
53
+ className: "text-xs text-muted-foreground bg-muted/20 p-2 rounded-md border",
54
+ children: p
55
+ }), /* @__PURE__ */ i("div", {
56
+ className: "divide-y divide-muted/50",
57
+ children: n.map((n) => {
58
+ let c = e(n), p = c.is_default !== !0 && g.has(c.code), h = f || p;
59
+ return /* @__PURE__ */ a("div", {
60
+ className: "flex flex-wrap items-stretch gap-4 py-3 first:pt-0 last:pb-0",
61
+ children: [/* @__PURE__ */ a("div", {
62
+ className: "flex items-center gap-2 w-[160px] shrink-0 self-stretch border-r border-border/50 pr-4",
63
+ children: [
64
+ /* @__PURE__ */ i("span", {
65
+ className: "text-sm font-black tracking-tighter text-foreground",
66
+ children: c.code
67
+ }),
68
+ /* @__PURE__ */ i("span", {
69
+ className: "text-[11px] text-muted-foreground font-medium",
70
+ children: c.symbol
71
+ }),
72
+ c.is_default ? /* @__PURE__ */ i("span", {
73
+ className: "text-[9px] uppercase font-bold bg-primary/10 text-primary px-1.5 py-0.5 rounded tracking-widest leading-none",
74
+ children: "Default"
75
+ }) : p ? /* @__PURE__ */ i("span", {
76
+ className: "text-[9px] uppercase font-bold bg-muted text-muted-foreground px-1.5 py-0.5 rounded tracking-widest leading-none",
77
+ children: "Auto"
78
+ }) : null,
79
+ !c.is_default && /* @__PURE__ */ a("span", {
80
+ className: "text-[9px] text-muted-foreground/80 font-medium tracking-wide leading-none ml-auto",
81
+ children: ["x", c.exchange_rate]
82
+ })
83
+ ]
84
+ }), /* @__PURE__ */ a("div", {
85
+ className: "grid flex-1 grid-cols-2 items-end gap-3 sm:grid-cols-4",
86
+ children: [
87
+ /* @__PURE__ */ a("div", {
88
+ className: "min-w-0 space-y-1",
89
+ children: [/* @__PURE__ */ i(s, {
90
+ htmlFor: `${t}-price-${c.code}`,
91
+ className: "block text-[10px] uppercase font-bold text-muted-foreground tracking-widest",
92
+ children: "Price"
93
+ }), /* @__PURE__ */ a("div", {
94
+ className: "relative",
95
+ children: [/* @__PURE__ */ i("span", {
96
+ className: "absolute left-2.5 top-1/2 -translate-y-1/2 text-xs text-muted-foreground font-bold pointer-events-none",
97
+ children: c.symbol
98
+ }), /* @__PURE__ */ i(u, {
99
+ id: `${t}-price-${c.code}`,
100
+ currencyCode: c.code,
101
+ value: r[c.code],
102
+ disabled: h,
103
+ className: "h-8 w-full text-sm pl-6",
104
+ onValueChange: (e) => l(c.code, e ?? 0)
105
+ })]
106
+ })]
107
+ }),
108
+ /* @__PURE__ */ a("div", {
109
+ className: "min-w-0 space-y-1",
110
+ children: [/* @__PURE__ */ i(s, {
111
+ htmlFor: `${t}-sale-price-${c.code}`,
112
+ className: "block text-[10px] uppercase font-bold text-muted-foreground tracking-widest",
113
+ children: "Sale"
114
+ }), /* @__PURE__ */ a("div", {
115
+ className: "relative",
116
+ children: [/* @__PURE__ */ i("span", {
117
+ className: "absolute left-2.5 top-1/2 -translate-y-1/2 text-xs text-muted-foreground font-bold pointer-events-none",
118
+ children: c.symbol
119
+ }), /* @__PURE__ */ i(u, {
120
+ id: `${t}-sale-price-${c.code}`,
121
+ currencyCode: c.code,
122
+ value: o[c.code],
123
+ disabled: h,
124
+ placeholder: p ? "Auto" : "—",
125
+ allowEmpty: !0,
126
+ className: "h-8 w-full text-sm pl-6",
127
+ onValueChange: (e) => d(c.code, e)
128
+ })]
129
+ })]
130
+ }),
131
+ m && c.is_default ? m : null
132
+ ]
133
+ })]
134
+ }, c.code);
135
+ })
136
+ })]
137
+ }) : null;
146
138
  }
147
- export {
148
- z as CurrencyPriceFields
149
- };
139
+ //#endregion
140
+ export { d as CurrencyPriceFields };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("@nextblock-cms/ui"),f=require("react"),g=require("lucide-react"),y=require("next/navigation");function p({productName:u,isIcon:c=!1,className:r,redirectTo:n,deleteAction:l}){const[e,d]=f.useTransition(),o=y.useRouter(),i=async s=>{s.preventDefault(),s.stopPropagation(),window.confirm(`Are you sure you want to delete "${u}"? This action cannot be undone.`)&&d(async()=>{try{await l(),n?o.push(n):o.refresh()}catch(h){console.error("Failed to delete product:",h),alert("Failed to delete product. Please try again.")}})};return c?t.jsx(a.Button,{variant:"ghost",size:"icon",onClick:i,disabled:e,className:`text-red-500 hover:text-red-600 hover:bg-red-50 ${r}`,title:"Delete Product",children:t.jsx(g.Trash2,{className:"h-4 w-4"})}):t.jsx(a.Button,{variant:"destructive",onClick:i,disabled:e,className:r,type:"button",children:e?"Deleting...":"Delete Product"})}exports.DeleteProductButton=p;
1
+ "use client";let e=require("react"),t=require("lucide-react"),n=require("react/jsx-runtime"),r=require("next/navigation"),i=require("@nextblock-cms/ui");function a({productName:a,isIcon:o=!1,className:s,redirectTo:c,deleteAction:l}){let[u,d]=(0,e.useTransition)(),f=(0,r.useRouter)(),p=async e=>{e.preventDefault(),e.stopPropagation(),window.confirm(`Are you sure you want to delete "${a}"? This action cannot be undone.`)&&d(async()=>{try{await l(),c?f.push(c):f.refresh()}catch(e){console.error(`Failed to delete product:`,e),alert(`Failed to delete product. Please try again.`)}})};return o?(0,n.jsx)(i.Button,{variant:`ghost`,size:`icon`,onClick:p,disabled:u,className:`text-red-500 hover:text-red-600 hover:bg-red-50 ${s}`,title:`Delete Product`,children:(0,n.jsx)(t.Trash2,{className:`h-4 w-4`})}):(0,n.jsx)(i.Button,{variant:`destructive`,onClick:p,disabled:u,className:s,type:`button`,children:u?`Deleting...`:`Delete Product`})}exports.DeleteProductButton=a;