@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"),s=require("@nextblock-cms/ui"),h=require("@nextblock-cms/utils"),c=t=>String(t).padStart(2,"0");function d(t){if(!t)return"";const a=new Date(t);return Number.isNaN(a.getTime())?"":`${a.getFullYear()}-${c(a.getMonth()+1)}-${c(a.getDate())}T${c(a.getHours())}:${c(a.getMinutes())}`}function o(t){if(!t)return null;const a=new Date(t);return Number.isNaN(a.getTime())?null:a.toISOString()}function f({idPrefix:t="product",startAt:a,endAt:x,onChange:n,error:r,disabled:u,description:m,dense:i,bare:p}){const N=Intl.DateTimeFormat().resolvedOptions().timeZone,g=h.cn("h-7 text-xs",i||p?"w-[150px]":"w-[160px] sm:w-[180px]"),j=e.jsxs(e.Fragment,{children:[e.jsx(s.Label,{htmlFor:`${t}-sale-start-at`,className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Starts"}),e.jsx(s.Input,{id:`${t}-sale-start-at`,type:"datetime-local",value:d(a),disabled:u,onChange:l=>n("sale_start_at",o(l.target.value)),className:g}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"→"}),e.jsx(s.Label,{htmlFor:`${t}-sale-end-at`,className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Ends"}),e.jsx(s.Input,{id:`${t}-sale-end-at`,type:"datetime-local",value:d(x),disabled:u,onChange:l=>n("sale_end_at",o(l.target.value)),className:g})]});return p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx(s.Label,{htmlFor:`${t}-sale-start-at`,className:"block text-[10px] uppercase font-bold tracking-widest text-muted-foreground",children:"Starts"}),e.jsx(s.Input,{id:`${t}-sale-start-at`,type:"datetime-local",value:d(a),disabled:u,onChange:l=>n("sale_start_at",o(l.target.value)),className:"h-8 w-full text-xs"})]}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx(s.Label,{htmlFor:`${t}-sale-end-at`,className:"block text-[10px] uppercase font-bold tracking-widest text-muted-foreground",children:"Ends"}),e.jsx(s.Input,{id:`${t}-sale-end-at`,type:"datetime-local",value:d(x),disabled:u,onChange:l=>n("sale_end_at",o(l.target.value)),className:"h-8 w-full text-xs"}),r?e.jsx("p",{className:"mt-0.5 text-[10px] text-destructive",children:r}):null]})]}):e.jsxs("div",{className:h.cn("rounded border border-dashed bg-muted/5 space-y-1",i?"p-1.5":"p-2"),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5",children:[e.jsx("span",{className:"shrink-0 text-[11px] font-bold uppercase tracking-wider text-muted-foreground",children:"Sale window"}),j,e.jsxs("span",{className:"ml-auto text-[10px] text-muted-foreground",children:[N||"local time"," · empty = always on"]})]}),m&&!i?e.jsx("p",{className:"text-[10px] leading-snug text-muted-foreground",children:m}):null,r?e.jsx("p",{className:"text-[11px] text-destructive",children:r}):null]})}exports.SaleScheduleFields=f;
1
+ "use client";let e=require("@nextblock-cms/utils"),t=require("react/jsx-runtime"),n=require("@nextblock-cms/ui");var r=e=>String(e).padStart(2,`0`);function i(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:`${t.getFullYear()}-${r(t.getMonth()+1)}-${r(t.getDate())}T${r(t.getHours())}:${r(t.getMinutes())}`}function a(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString()}function o({idPrefix:r=`product`,startAt:o,endAt:s,onChange:c,error:l,disabled:u,description:d,dense:f,bare:p}){let m=Intl.DateTimeFormat().resolvedOptions().timeZone,h=(0,e.cn)(`h-7 text-xs`,f||p?`w-[150px]`:`w-[160px] sm:w-[180px]`),g=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.Label,{htmlFor:`${r}-sale-start-at`,className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:`Starts`}),(0,t.jsx)(n.Input,{id:`${r}-sale-start-at`,type:`datetime-local`,value:i(o),disabled:u,onChange:e=>c(`sale_start_at`,a(e.target.value)),className:h}),(0,t.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`→`}),(0,t.jsx)(n.Label,{htmlFor:`${r}-sale-end-at`,className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:`Ends`}),(0,t.jsx)(n.Input,{id:`${r}-sale-end-at`,type:`datetime-local`,value:i(s),disabled:u,onChange:e=>c(`sale_end_at`,a(e.target.value)),className:h})]});return p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,t.jsx)(n.Label,{htmlFor:`${r}-sale-start-at`,className:`block text-[10px] uppercase font-bold tracking-widest text-muted-foreground`,children:`Starts`}),(0,t.jsx)(n.Input,{id:`${r}-sale-start-at`,type:`datetime-local`,value:i(o),disabled:u,onChange:e=>c(`sale_start_at`,a(e.target.value)),className:`h-8 w-full text-xs`})]}),(0,t.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,t.jsx)(n.Label,{htmlFor:`${r}-sale-end-at`,className:`block text-[10px] uppercase font-bold tracking-widest text-muted-foreground`,children:`Ends`}),(0,t.jsx)(n.Input,{id:`${r}-sale-end-at`,type:`datetime-local`,value:i(s),disabled:u,onChange:e=>c(`sale_end_at`,a(e.target.value)),className:`h-8 w-full text-xs`}),l?(0,t.jsx)(`p`,{className:`mt-0.5 text-[10px] text-destructive`,children:l}):null]})]}):(0,t.jsxs)(`div`,{className:(0,e.cn)(`rounded border border-dashed bg-muted/5 space-y-1`,f?`p-1.5`:`p-2`),children:[(0,t.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,t.jsx)(`span`,{className:`shrink-0 text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Sale window`}),g,(0,t.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:[m||`local time`,` · empty = always on`]})]}),d&&!f?(0,t.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:d}):null,l?(0,t.jsx)(`p`,{className:`text-[11px] text-destructive`,children:l}):null]})}exports.SaleScheduleFields=o;
@@ -12,5 +12,5 @@ interface SaleScheduleFieldsProps {
12
12
  /** Inline STARTS → ENDS only, no box / heading (e.g. inside a variant row). */
13
13
  bare?: boolean;
14
14
  }
15
- export declare function SaleScheduleFields({ idPrefix, startAt, endAt, onChange, error, disabled, description, dense, bare, }: SaleScheduleFieldsProps): import("react").JSX.Element;
15
+ export declare function SaleScheduleFields({ idPrefix, startAt, endAt, onChange, error, disabled, description, dense, bare, }: SaleScheduleFieldsProps): import('react').JSX.Element;
16
16
  export {};
@@ -1,137 +1,114 @@
1
- 'use client';
2
- import { jsxs as s, Fragment as f, jsx as t } from "react/jsx-runtime";
3
- import { Label as o, Input as u } from "@nextblock-cms/ui";
4
- import { cn as w } from "@nextblock-cms/utils";
5
- const d = (e) => String(e).padStart(2, "0");
6
- function m(e) {
7
- if (!e)
8
- return "";
9
- const a = new Date(e);
10
- return Number.isNaN(a.getTime()) ? "" : `${a.getFullYear()}-${d(a.getMonth() + 1)}-${d(
11
- a.getDate()
12
- )}T${d(a.getHours())}:${d(a.getMinutes())}`;
1
+ "use client";
2
+ import { cn as e } from "@nextblock-cms/utils";
3
+ import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
4
+ import { Input as i, Label as a } from "@nextblock-cms/ui";
5
+ //#region libs/ecommerce/src/lib/pages/cms/products/components/SaleScheduleFields.tsx
6
+ var o = (e) => String(e).padStart(2, "0");
7
+ function s(e) {
8
+ if (!e) return "";
9
+ let t = new Date(e);
10
+ return Number.isNaN(t.getTime()) ? "" : `${t.getFullYear()}-${o(t.getMonth() + 1)}-${o(t.getDate())}T${o(t.getHours())}:${o(t.getMinutes())}`;
13
11
  }
14
- function i(e) {
15
- if (!e)
16
- return null;
17
- const a = new Date(e);
18
- return Number.isNaN(a.getTime()) ? null : a.toISOString();
12
+ function c(e) {
13
+ if (!e) return null;
14
+ let t = new Date(e);
15
+ return Number.isNaN(t.getTime()) ? null : t.toISOString();
19
16
  }
20
- function k({
21
- idPrefix: e = "product",
22
- startAt: a,
23
- endAt: x,
24
- onChange: n,
25
- error: r,
26
- disabled: c,
27
- description: g,
28
- dense: p,
29
- bare: h
30
- }) {
31
- const v = Intl.DateTimeFormat().resolvedOptions().timeZone, N = w("h-7 text-xs", p || h ? "w-[150px]" : "w-[160px] sm:w-[180px]"), $ = /* @__PURE__ */ s(f, { children: [
32
- /* @__PURE__ */ t(
33
- o,
34
- {
35
- htmlFor: `${e}-sale-start-at`,
36
- className: "text-[10px] uppercase tracking-wider text-muted-foreground",
37
- children: "Starts"
38
- }
39
- ),
40
- /* @__PURE__ */ t(
41
- u,
42
- {
43
- id: `${e}-sale-start-at`,
44
- type: "datetime-local",
45
- value: m(a),
46
- disabled: c,
47
- onChange: (l) => n("sale_start_at", i(l.target.value)),
48
- className: N
49
- }
50
- ),
51
- /* @__PURE__ */ t("span", { className: "text-xs text-muted-foreground", children: "→" }),
52
- /* @__PURE__ */ t(
53
- o,
54
- {
55
- htmlFor: `${e}-sale-end-at`,
56
- className: "text-[10px] uppercase tracking-wider text-muted-foreground",
57
- children: "Ends"
58
- }
59
- ),
60
- /* @__PURE__ */ t(
61
- u,
62
- {
63
- id: `${e}-sale-end-at`,
64
- type: "datetime-local",
65
- value: m(x),
66
- disabled: c,
67
- onChange: (l) => n("sale_end_at", i(l.target.value)),
68
- className: N
69
- }
70
- )
71
- ] });
72
- return h ? /* @__PURE__ */ s(f, { children: [
73
- /* @__PURE__ */ s("div", { className: "min-w-0 space-y-1", children: [
74
- /* @__PURE__ */ t(
75
- o,
76
- {
77
- htmlFor: `${e}-sale-start-at`,
78
- className: "block text-[10px] uppercase font-bold tracking-widest text-muted-foreground",
79
- children: "Starts"
80
- }
81
- ),
82
- /* @__PURE__ */ t(
83
- u,
84
- {
85
- id: `${e}-sale-start-at`,
86
- type: "datetime-local",
87
- value: m(a),
88
- disabled: c,
89
- onChange: (l) => n("sale_start_at", i(l.target.value)),
90
- className: "h-8 w-full text-xs"
91
- }
92
- )
93
- ] }),
94
- /* @__PURE__ */ s("div", { className: "min-w-0 space-y-1", children: [
95
- /* @__PURE__ */ t(
96
- o,
97
- {
98
- htmlFor: `${e}-sale-end-at`,
99
- className: "block text-[10px] uppercase font-bold tracking-widest text-muted-foreground",
100
- children: "Ends"
101
- }
102
- ),
103
- /* @__PURE__ */ t(
104
- u,
105
- {
106
- id: `${e}-sale-end-at`,
107
- type: "datetime-local",
108
- value: m(x),
109
- disabled: c,
110
- onChange: (l) => n("sale_end_at", i(l.target.value)),
111
- className: "h-8 w-full text-xs"
112
- }
113
- ),
114
- r ? /* @__PURE__ */ t("p", { className: "mt-0.5 text-[10px] text-destructive", children: r }) : null
115
- ] })
116
- ] }) : /* @__PURE__ */ s(
117
- "div",
118
- {
119
- className: w("rounded border border-dashed bg-muted/5 space-y-1", p ? "p-1.5" : "p-2"),
120
- children: [
121
- /* @__PURE__ */ s("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1.5", children: [
122
- /* @__PURE__ */ t("span", { className: "shrink-0 text-[11px] font-bold uppercase tracking-wider text-muted-foreground", children: "Sale window" }),
123
- $,
124
- /* @__PURE__ */ s("span", { className: "ml-auto text-[10px] text-muted-foreground", children: [
125
- v || "local time",
126
- " · empty = always on"
127
- ] })
128
- ] }),
129
- g && !p ? /* @__PURE__ */ t("p", { className: "text-[10px] leading-snug text-muted-foreground", children: g }) : null,
130
- r ? /* @__PURE__ */ t("p", { className: "text-[11px] text-destructive", children: r }) : null
131
- ]
132
- }
133
- );
17
+ function l({ idPrefix: o = "product", startAt: l, endAt: u, onChange: d, error: f, disabled: p, description: m, dense: h, bare: g }) {
18
+ let _ = Intl.DateTimeFormat().resolvedOptions().timeZone, v = e("h-7 text-xs", h || g ? "w-[150px]" : "w-[160px] sm:w-[180px]"), y = /* @__PURE__ */ r(t, { children: [
19
+ /* @__PURE__ */ n(a, {
20
+ htmlFor: `${o}-sale-start-at`,
21
+ className: "text-[10px] uppercase tracking-wider text-muted-foreground",
22
+ children: "Starts"
23
+ }),
24
+ /* @__PURE__ */ n(i, {
25
+ id: `${o}-sale-start-at`,
26
+ type: "datetime-local",
27
+ value: s(l),
28
+ disabled: p,
29
+ onChange: (e) => d("sale_start_at", c(e.target.value)),
30
+ className: v
31
+ }),
32
+ /* @__PURE__ */ n("span", {
33
+ className: "text-xs text-muted-foreground",
34
+ children: "→"
35
+ }),
36
+ /* @__PURE__ */ n(a, {
37
+ htmlFor: `${o}-sale-end-at`,
38
+ className: "text-[10px] uppercase tracking-wider text-muted-foreground",
39
+ children: "Ends"
40
+ }),
41
+ /* @__PURE__ */ n(i, {
42
+ id: `${o}-sale-end-at`,
43
+ type: "datetime-local",
44
+ value: s(u),
45
+ disabled: p,
46
+ onChange: (e) => d("sale_end_at", c(e.target.value)),
47
+ className: v
48
+ })
49
+ ] });
50
+ return g ? /* @__PURE__ */ r(t, { children: [/* @__PURE__ */ r("div", {
51
+ className: "min-w-0 space-y-1",
52
+ children: [/* @__PURE__ */ n(a, {
53
+ htmlFor: `${o}-sale-start-at`,
54
+ className: "block text-[10px] uppercase font-bold tracking-widest text-muted-foreground",
55
+ children: "Starts"
56
+ }), /* @__PURE__ */ n(i, {
57
+ id: `${o}-sale-start-at`,
58
+ type: "datetime-local",
59
+ value: s(l),
60
+ disabled: p,
61
+ onChange: (e) => d("sale_start_at", c(e.target.value)),
62
+ className: "h-8 w-full text-xs"
63
+ })]
64
+ }), /* @__PURE__ */ r("div", {
65
+ className: "min-w-0 space-y-1",
66
+ children: [
67
+ /* @__PURE__ */ n(a, {
68
+ htmlFor: `${o}-sale-end-at`,
69
+ className: "block text-[10px] uppercase font-bold tracking-widest text-muted-foreground",
70
+ children: "Ends"
71
+ }),
72
+ /* @__PURE__ */ n(i, {
73
+ id: `${o}-sale-end-at`,
74
+ type: "datetime-local",
75
+ value: s(u),
76
+ disabled: p,
77
+ onChange: (e) => d("sale_end_at", c(e.target.value)),
78
+ className: "h-8 w-full text-xs"
79
+ }),
80
+ f ? /* @__PURE__ */ n("p", {
81
+ className: "mt-0.5 text-[10px] text-destructive",
82
+ children: f
83
+ }) : null
84
+ ]
85
+ })] }) : /* @__PURE__ */ r("div", {
86
+ className: e("rounded border border-dashed bg-muted/5 space-y-1", h ? "p-1.5" : "p-2"),
87
+ children: [
88
+ /* @__PURE__ */ r("div", {
89
+ className: "flex flex-wrap items-center gap-x-3 gap-y-1.5",
90
+ children: [
91
+ /* @__PURE__ */ n("span", {
92
+ className: "shrink-0 text-[11px] font-bold uppercase tracking-wider text-muted-foreground",
93
+ children: "Sale window"
94
+ }),
95
+ y,
96
+ /* @__PURE__ */ r("span", {
97
+ className: "ml-auto text-[10px] text-muted-foreground",
98
+ children: [_ || "local time", " · empty = always on"]
99
+ })
100
+ ]
101
+ }),
102
+ m && !h ? /* @__PURE__ */ n("p", {
103
+ className: "text-[10px] leading-snug text-muted-foreground",
104
+ children: m
105
+ }) : null,
106
+ f ? /* @__PURE__ */ n("p", {
107
+ className: "text-[11px] text-destructive",
108
+ children: f
109
+ }) : null
110
+ ]
111
+ });
134
112
  }
135
- export {
136
- k as SaleScheduleFields
137
- };
113
+ //#endregion
114
+ export { l as SaleScheduleFields };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),i=require("react"),u=require("@nextblock-cms/ui"),a=require("lucide-react"),t=require("sonner"),l=require("../actions.cjs.js");function d({title:c="Sync Full Store"}){const[r,s]=i.useState(!1),o=async()=>{s(!0);try{const e=await l.triggerFreemiusSync();e.error?t.toast.error(e.error):t.toast.success(`Full store sync complete! Found ${e.data?.count||0} products.`)}catch(e){t.toast.error(e.message||"An unexpected error occurred during sync")}finally{s(!1)}};return n.jsxs(u.Button,{variant:"secondary",onClick:o,disabled:r,className:"gap-2",children:[n.jsx(a.RefreshCw,{className:`w-4 h-4 ${r?"animate-spin":""}`}),r?"Syncing...":c]})}exports.SyncFreemiusButton=d;
1
+ "use client";const e=require("../actions.cjs.js");let t=require("react"),n=require("lucide-react"),r=require("react/jsx-runtime"),i=require("sonner"),a=require("@nextblock-cms/ui");function o({title:o=`Sync Full Store`}){let[s,c]=(0,t.useState)(!1);return(0,r.jsxs)(a.Button,{variant:`secondary`,onClick:async()=>{c(!0);try{let t=await e.triggerFreemiusSync();t.error?i.toast.error(t.error):i.toast.success(`Full store sync complete! Found ${t.data?.count||0} products.`)}catch(e){i.toast.error(e.message||`An unexpected error occurred during sync`)}finally{c(!1)}},disabled:s,className:`gap-2`,children:[(0,r.jsx)(n.RefreshCw,{className:`w-4 h-4 ${s?`animate-spin`:``}`}),s?`Syncing...`:o]})}exports.SyncFreemiusButton=o;
@@ -1,3 +1,3 @@
1
1
  export declare function SyncFreemiusButton({ title }: {
2
2
  title?: string;
3
- }): import("react").JSX.Element;
3
+ }): import('react').JSX.Element;
@@ -1,36 +1,30 @@
1
- 'use client';
2
- import { jsxs as o, jsx as c } from "react/jsx-runtime";
3
- import { useState as a } from "react";
4
- import { Button as i } from "@nextblock-cms/ui";
5
- import { RefreshCw as m } from "lucide-react";
6
- import { toast as n } from "sonner";
7
- import { triggerFreemiusSync as l } from "../actions.es.js";
8
- function h({ title: s = "Sync Full Store" }) {
9
- const [e, t] = a(!1);
10
- return /* @__PURE__ */ o(
11
- i,
12
- {
13
- variant: "secondary",
14
- onClick: async () => {
15
- t(!0);
16
- try {
17
- const r = await l();
18
- r.error ? n.error(r.error) : n.success(`Full store sync complete! Found ${r.data?.count || 0} products.`);
19
- } catch (r) {
20
- n.error(r.message || "An unexpected error occurred during sync");
21
- } finally {
22
- t(!1);
23
- }
24
- },
25
- disabled: e,
26
- className: "gap-2",
27
- children: [
28
- /* @__PURE__ */ c(m, { className: `w-4 h-4 ${e ? "animate-spin" : ""}` }),
29
- e ? "Syncing..." : s
30
- ]
31
- }
32
- );
1
+ "use client";
2
+ import { triggerFreemiusSync as e } from "../actions.es.js";
3
+ import { useState as t } from "react";
4
+ import { RefreshCw as n } from "lucide-react";
5
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
6
+ import { toast as a } from "sonner";
7
+ import { Button as o } from "@nextblock-cms/ui";
8
+ //#region libs/ecommerce/src/lib/pages/cms/products/components/SyncFreemiusButton.tsx
9
+ function s({ title: s = "Sync Full Store" }) {
10
+ let [c, l] = t(!1);
11
+ return /* @__PURE__ */ i(o, {
12
+ variant: "secondary",
13
+ onClick: async () => {
14
+ l(!0);
15
+ try {
16
+ let t = await e();
17
+ t.error ? a.error(t.error) : a.success(`Full store sync complete! Found ${t.data?.count || 0} products.`);
18
+ } catch (e) {
19
+ a.error(e.message || "An unexpected error occurred during sync");
20
+ } finally {
21
+ l(!1);
22
+ }
23
+ },
24
+ disabled: c,
25
+ className: "gap-2",
26
+ children: [/* @__PURE__ */ r(n, { className: `w-4 h-4 ${c ? "animate-spin" : ""}` }), c ? "Syncing..." : s]
27
+ });
33
28
  }
34
- export {
35
- h as SyncFreemiusButton
36
- };
29
+ //#endregion
30
+ export { s as SyncFreemiusButton };
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),u=require("react"),l=require("next/navigation"),d=require("@nextblock-cms/ui"),f=require("lucide-react"),r=require("sonner"),g=require("../actions.cjs.js");function y({productId:t,hasOpenDraft:c=!1}){const o=l.useRouter(),[n,i]=u.useState(!1),a=async()=>{if(!t){r.toast.error("Product ID is missing");return}if(!(c&&!window.confirm(`You have unpublished draft changes for this product.
1
+ "use client";const e=require("../actions.cjs.js");let t=require("react"),n=require("lucide-react"),r=require("react/jsx-runtime"),i=require("sonner"),a=require("next/navigation"),o=require("@nextblock-cms/ui");function s({productId:s,hasOpenDraft:c=!1}){let l=(0,a.useRouter)(),[u,d]=(0,t.useState)(!1);return(0,r.jsxs)(o.Button,{variant:`outline`,onClick:async()=>{if(!s){i.toast.error(`Product ID is missing`);return}if(!c||window.confirm(`You have unpublished draft changes for this product.
2
2
 
3
3
  Syncing updates the live pricing now, but publishing your draft afterward will overwrite it with the draft’s older values. Publish or discard your draft first to keep the synced prices.
4
4
 
5
- Sync anyway?`))){i(!0);try{const e=await g.triggerSingleProductSync(t);e.error?r.toast.error(e.error):(r.toast.success("Pricing sync complete!"),o.refresh())}catch(e){r.toast.error(e.message||"An unexpected error occurred during sync")}finally{i(!1)}}};return s.jsxs(d.Button,{variant:"outline",onClick:a,disabled:n,className:"gap-2",children:[s.jsx(f.RefreshCw,{className:`w-4 h-4 ${n?"animate-spin":""}`}),n?"Syncing...":"Sync Plans & Pricing from Freemius"]})}exports.SyncFreemiusPricingButton=y;
5
+ Sync anyway?`)){d(!0);try{let t=await e.triggerSingleProductSync(s);t.error?i.toast.error(t.error):(i.toast.success(`Pricing sync complete!`),l.refresh())}catch(e){i.toast.error(e.message||`An unexpected error occurred during sync`)}finally{d(!1)}}},disabled:u,className:`gap-2`,children:[(0,r.jsx)(n.RefreshCw,{className:`w-4 h-4 ${u?`animate-spin`:``}`}),u?`Syncing...`:`Sync Plans & Pricing from Freemius`]})}exports.SyncFreemiusPricingButton=s;
@@ -3,5 +3,5 @@ interface SyncFreemiusPricingButtonProps {
3
3
  /** True when an unpublished product draft is open — publishing it later would revert the synced pricing. */
4
4
  hasOpenDraft?: boolean;
5
5
  }
6
- export declare function SyncFreemiusPricingButton({ productId, hasOpenDraft }: SyncFreemiusPricingButtonProps): import("react").JSX.Element;
6
+ export declare function SyncFreemiusPricingButton({ productId, hasOpenDraft }: SyncFreemiusPricingButtonProps): import('react').JSX.Element;
7
7
  export {};
@@ -1,49 +1,37 @@
1
- 'use client';
2
- import { jsxs as c, jsx as a } from "react/jsx-runtime";
3
- import { useState as u } from "react";
4
- import { useRouter as f } from "next/navigation";
5
- import { Button as l } from "@nextblock-cms/ui";
6
- import { RefreshCw as d } from "lucide-react";
7
- import { toast as e } from "sonner";
8
- import { triggerSingleProductSync as m } from "../actions.es.js";
9
- function v({ productId: i, hasOpenDraft: s = !1 }) {
10
- const o = f(), [n, t] = u(!1);
11
- return /* @__PURE__ */ c(
12
- l,
13
- {
14
- variant: "outline",
15
- onClick: async () => {
16
- if (!i) {
17
- e.error("Product ID is missing");
18
- return;
19
- }
20
- if (!(s && !window.confirm(
21
- `You have unpublished draft changes for this product.
22
-
23
- Syncing updates the live pricing now, but publishing your draft afterward will overwrite it with the draft’s older values. Publish or discard your draft first to keep the synced prices.
24
-
25
- Sync anyway?`
26
- ))) {
27
- t(!0);
28
- try {
29
- const r = await m(i);
30
- r.error ? e.error(r.error) : (e.success("Pricing sync complete!"), o.refresh());
31
- } catch (r) {
32
- e.error(r.message || "An unexpected error occurred during sync");
33
- } finally {
34
- t(!1);
35
- }
36
- }
37
- },
38
- disabled: n,
39
- className: "gap-2",
40
- children: [
41
- /* @__PURE__ */ a(d, { className: `w-4 h-4 ${n ? "animate-spin" : ""}` }),
42
- n ? "Syncing..." : "Sync Plans & Pricing from Freemius"
43
- ]
44
- }
45
- );
1
+ "use client";
2
+ import { triggerSingleProductSync as e } from "../actions.es.js";
3
+ import { useState as t } from "react";
4
+ import { RefreshCw as n } from "lucide-react";
5
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
6
+ import { toast as a } from "sonner";
7
+ import { useRouter as o } from "next/navigation";
8
+ import { Button as s } from "@nextblock-cms/ui";
9
+ //#region libs/ecommerce/src/lib/pages/cms/products/components/SyncFreemiusPricingButton.tsx
10
+ function c({ productId: c, hasOpenDraft: l = !1 }) {
11
+ let u = o(), [d, f] = t(!1);
12
+ return /* @__PURE__ */ i(s, {
13
+ variant: "outline",
14
+ onClick: async () => {
15
+ if (!c) {
16
+ a.error("Product ID is missing");
17
+ return;
18
+ }
19
+ if (!l || window.confirm("You have unpublished draft changes for this product.\n\nSyncing updates the live pricing now, but publishing your draft afterward will overwrite it with the draft’s older values. Publish or discard your draft first to keep the synced prices.\n\nSync anyway?")) {
20
+ f(!0);
21
+ try {
22
+ let t = await e(c);
23
+ t.error ? a.error(t.error) : (a.success("Pricing sync complete!"), u.refresh());
24
+ } catch (e) {
25
+ a.error(e.message || "An unexpected error occurred during sync");
26
+ } finally {
27
+ f(!1);
28
+ }
29
+ }
30
+ },
31
+ disabled: d,
32
+ className: "gap-2",
33
+ children: [/* @__PURE__ */ r(n, { className: `w-4 h-4 ${d ? "animate-spin" : ""}` }), d ? "Syncing..." : "Sync Plans & Pricing from Freemius"]
34
+ });
46
35
  }
47
- export {
48
- v as SyncFreemiusPricingButton
49
- };
36
+ //#endregion
37
+ export { c as SyncFreemiusPricingButton };
@@ -1 +1 @@
1
- export declare function SyncProductForm(): import("react").JSX.Element;
1
+ export declare function SyncProductForm(): import('react').JSX.Element;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),R=require("next/link"),f=require("react"),p=require("@nextblock-cms/ui"),g=require("../../../../variation-utils.cjs.js"),Q=require("./CurrencyPriceFields.cjs.js"),W=require("./SaleScheduleFields.cjs.js"),y=require("../../../../currency.cjs.js"),j=require("../product-price-sync.cjs.js"),k=require("@nextblock-cms/utils"),E=process.env.NEXT_PUBLIC_R2_BASE_URL||"",D=process.env.NEXT_PUBLIC_SUPABASE_URL||"",H=c=>c.startsWith("http")?c:E?`${E.replace(/\/+$/,"")}/${c.replace(/^\/+/,"")}`:D?`${D.replace(/\/+$/,"")}/storage/v1/object/public/media/${c.replace(/^\/+/,"")}`:c;function L(c,a="USD"){return new Intl.NumberFormat("en-US",{style:"currency",currency:a}).format(c)}function J(c){return Object.entries(c).filter(([,a])=>a.length>0).map(([a,b])=>({attribute_id:a,term_ids:b}))}function Y({globalAttributes:c,currentLanguageCode:a,baseSku:b,basePrice:$,basePrices:w,baseSalePrice:T,baseSalePrices:B,currencies:o,availableVariantImages:N=[],initialVariationAttributes:C,initialVariants:V,onChange:q}){const[_,z]=f.useState(()=>C&&C.length>0?C.reduce((e,r)=>(e[r.attribute_id]=r.term_ids,e),{}):g.extractSelectedTermsByAttribute(V||[])),[h,x]=f.useState(j.sanitizeVariantDraftsForStoreManagedCurrencies(V||[],o)),S=f.useMemo(()=>c.map(e=>({attribute_id:e.id,attribute_name:g.resolveAttributeName(e,a),terms:e.terms.filter(r=>(_[e.id]||[]).includes(r.id)).map(r=>({...r,value:g.resolveTermValue(r,a)}))})).filter(e=>e.terms.length>0),[a,c,_]);f.useEffect(()=>{if(S.length===0){x([]);return}x(e=>j.sanitizeVariantDraftsForStoreManagedCurrencies(g.generateVariantDrafts({baseSku:b,basePrice:$,basePrices:y.normalizePriceMap(w),baseSalePrice:T,baseSalePrices:y.normalizeSalePriceMap(B),selectedAttributes:S,previousVariants:e}),o))},[$,w,T,B,b,o,S]),f.useEffect(()=>{q({variationAttributes:J(_),variants:h})},[q,_,h]);const I=h.reduce((e,r)=>e+(r.stock_quantity||0),0),P=o.find(e=>e.is_default)??o[0],U=f.useMemo(()=>j.getStoreManagedPriceCurrencyCodes(o),[o]),K=(e,r)=>{z(t=>{const n=new Set(t[e]||[]);return n.has(r)?n.delete(r):n.add(r),{...t,[e]:[...n]}})},M=(e,r,t)=>{x(n=>n.map(i=>{if(i.combination_key!==e)return i;if(r==="sku")return{...i,sku:t};if(r==="upc")return{...i,upc:t};if(r==="sale_price"&&t==="")return{...i,sale_price:null};if(r==="prices"||r==="sale_prices")return i;const d=t===""?0:Number(t);return{...i,[r]:Number.isFinite(d)?d:0}}))},O=(e,r,t)=>{x(n=>n.map(i=>i.combination_key===e?{...i,[r]:t}:i))},F=(e,r,t,n)=>{const i=o.find(d=>d.is_default)??o[0];x(d=>d.map(m=>{if(m.combination_key!==e)return m;const u={...t==="prices"?m.prices:m.sale_prices,[r]:n};return{...m,[t]:u,...r===i?.code?t==="prices"?{price:n??0}:{sale_price:n}:{}}}))},X=e=>{const r=o.find(n=>n.is_default)??o[0],t=new Set(U);r&&x(n=>n.map(i=>{if(i.combination_key!==e)return i;const d=o.reduce((u,l)=>{if(l.code!==r.code&&t.has(l.code))return u;const A=y.convertMinorUnitAmount({amount:k.majorUnitAmountToMinor(i.price,r.code),fromCurrencyCode:r.code,toCurrencyCode:l.code,currencies:o,applyRounding:!0});return u[l.code]=k.minorUnitAmountToMajor(A,l.code),u},{}),m=o.reduce((u,l)=>{if(l.code!==r.code&&t.has(l.code))return u;if(typeof i.sale_price!="number")return u[l.code]=null,u;const A=y.convertMinorUnitAmount({amount:k.majorUnitAmountToMinor(i.sale_price,r.code),fromCurrencyCode:r.code,toCurrencyCode:l.code,currencies:o,applyRounding:!0});return u[l.code]=k.minorUnitAmountToMajor(A,l.code),u},{});return{...i,prices:d,sale_prices:m}}))},G=(e,r)=>{const t=N.find(d=>d.media_id===r);if(!t)return;const n=t.file_path,i=H(n);x(d=>d.map(m=>m.combination_key===e?{...m,main_media_id:t.media_id,main_image_url:i}:m))},v=e=>{x(r=>r.map(t=>t.combination_key===e?{...t,main_media_id:null,main_image_url:null}:t))};return c.length===0?s.jsxs("div",{className:"rounded-lg border border-dashed p-6 text-sm text-muted-foreground",children:["No global attributes have been created yet. Create them first in"," ",s.jsx(R,{href:"/cms/products/attributes",className:"font-medium text-primary underline-offset-4 hover:underline",children:"Attribute Management"}),"."]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Attributes"}),s.jsxs(p.Badge,{variant:"outline",className:"text-[10px] px-1.5 h-4",children:[h.length," variants"]}),s.jsxs(p.Badge,{variant:"secondary",className:"text-[10px] px-1.5 h-4",children:["Stock: ",I]})]}),s.jsx(p.Button,{asChild:!0,variant:"outline",size:"sm",className:"h-7 text-xs px-3",children:s.jsx(R,{href:"/cms/products/attributes",children:"Manage"})})]}),s.jsx("div",{className:"grid gap-2 lg:grid-cols-2",children:c.map(e=>{const r=_[e.id]||[];return s.jsxs("div",{className:"flex items-center gap-3 rounded border p-2.5",children:[s.jsxs("div",{className:"shrink-0 w-[100px]",children:[s.jsx("span",{className:"text-sm font-bold block leading-tight",children:g.resolveAttributeName(e,a)}),s.jsxs("span",{className:"text-[10px] text-muted-foreground leading-none",children:[r.length," selected"]})]}),s.jsx("div",{className:"flex flex-wrap gap-1.5 flex-1",children:e.terms.map(t=>{const n=r.includes(t.id);return s.jsx("button",{type:"button",onClick:()=>K(e.id,t.id),className:`rounded-full border px-2.5 py-0.5 text-[11px] font-medium transition-colors ${n?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground hover:border-primary/40"}`,children:g.resolveTermValue(t,a)},t.id)})})]},e.id)})})]}),h.length===0?s.jsx("div",{className:"rounded border border-dashed p-3 text-xs text-muted-foreground text-center",children:"Select terms above to generate variations."}):s.jsx("div",{className:"space-y-2",children:h.map(e=>{const r=j.resolveEditorCurrencyPriceMaps({currencies:o,prices:e.prices||{},salePrices:e.sale_prices||{},fallbackPrice:e.price,fallbackSalePrice:e.sale_price});return s.jsxs("div",{className:"rounded border p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-bold",children:e.label}),s.jsx("span",{className:"text-xs text-muted-foreground",children:e.selected_options.map(t=>`${t.attribute_name}: ${t.term_value}`).join(" · ")})]}),s.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[s.jsxs("span",{children:["Reg: ",L(e.price,P?.code||"USD")]}),s.jsxs("span",{children:["Sale:"," ",e.sale_price!==null&&e.sale_price!==void 0?L(e.sale_price,P?.code||"USD"):"—"]})]})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(p.Label,{htmlFor:`variant-sku-${e.combination_key}`,className:"text-xs uppercase font-bold text-muted-foreground tracking-wider shrink-0",children:"SKU"}),s.jsx(p.Input,{id:`variant-sku-${e.combination_key}`,value:e.sku,onChange:t=>M(e.combination_key,"sku",t.target.value),placeholder:"SKU",className:"h-8 text-sm font-mono"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(p.Label,{htmlFor:`variant-upc-${e.combination_key}`,className:"text-xs uppercase font-bold text-muted-foreground tracking-wider shrink-0",children:"UPC"}),s.jsx(p.Input,{id:`variant-upc-${e.combination_key}`,value:e.upc??"",onChange:t=>M(e.combination_key,"upc",t.target.value),placeholder:"—",className:"h-8 text-sm font-mono"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(p.Label,{htmlFor:`variant-stock-${e.combination_key}`,className:"text-xs uppercase font-bold text-muted-foreground tracking-wider shrink-0",children:"Qty"}),s.jsx(p.Input,{id:`variant-stock-${e.combination_key}`,type:"number",min:"0",value:e.stock_quantity,onChange:t=>M(e.combination_key,"stock_quantity",t.target.value),className:"h-8 text-sm font-mono w-20"})]})]}),s.jsx(Q.CurrencyPriceFields,{idPrefix:`variant-${e.combination_key}`,currencies:o,prices:r.prices,salePrices:r.salePrices,managedCurrencyCodes:U,onPriceChange:(t,n)=>F(e.combination_key,t,"prices",n),onSalePriceChange:(t,n)=>F(e.combination_key,t,"sale_prices",n),onAutoFill:()=>X(e.combination_key),helperText:U.length>0?`Store-managed currencies derive from ${P?.code||"the base currency"}.`:void 0,trailing:s.jsx(W.SaleScheduleFields,{idPrefix:`variant-${e.combination_key}`,startAt:e.sale_start_at,endAt:e.sale_end_at,onChange:(t,n)=>O(e.combination_key,t,n),bare:!0})}),s.jsxs("div",{className:"flex items-center gap-3 pt-1.5 border-t border-muted/30",children:[e.main_image_url&&s.jsx("div",{className:"h-9 w-9 overflow-hidden rounded border bg-background shrink-0",children:s.jsx("img",{src:e.main_image_url,alt:`${e.label} image`,className:"h-full w-full object-cover"})}),s.jsx("span",{className:"text-xs uppercase font-bold text-muted-foreground tracking-wider shrink-0",children:"Image"}),N.length>0?s.jsxs("select",{className:"flex h-8 rounded-md border border-input bg-background px-2 py-1 text-sm min-w-[180px]",value:e.main_media_id??"",onChange:t=>{if(!t.target.value){v(e.combination_key);return}G(e.combination_key,t.target.value)},children:[s.jsx("option",{value:"",children:"Use parent image"}),N.map((t,n)=>s.jsx("option",{value:t.media_id,children:t.alt?.trim()||`Gallery image ${n+1}`},t.media_id))]}):s.jsx("span",{className:"text-xs text-muted-foreground",children:"Add gallery images first."}),e.main_media_id&&s.jsx(p.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-xs px-2 text-muted-foreground hover:text-destructive",onClick:()=>v(e.combination_key),children:"Remove"})]})]},e.combination_key)})})]})}exports.VariationsEditor=Y;
1
+ "use client";const e=require("../../../../../_virtual/_rolldown/runtime.cjs.js"),t=require("../../../../currency.cjs.js"),n=require("../../../../variation-utils.cjs.js"),r=require("./CurrencyPriceFields.cjs.js"),i=require("./SaleScheduleFields.cjs.js"),a=require("../product-price-sync.cjs.js");let o=require("next/link");o=e.__toESM(o,1);let s=require("react"),c=require("@nextblock-cms/utils"),l=require("react/jsx-runtime"),u=require("@nextblock-cms/ui");var d=process.env.NEXT_PUBLIC_R2_BASE_URL||``,f=process.env.NEXT_PUBLIC_SUPABASE_URL||``,p=e=>e.startsWith(`http`)?e:d?`${d.replace(/\/+$/,``)}/${e.replace(/^\/+/,``)}`:f?`${f.replace(/\/+$/,``)}/storage/v1/object/public/media/${e.replace(/^\/+/,``)}`:e;function m(e,t=`USD`){return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t}).format(e)}function h(e){return Object.entries(e).filter(([,e])=>e.length>0).map(([e,t])=>({attribute_id:e,term_ids:t}))}function g({globalAttributes:e,currentLanguageCode:d,baseSku:f,basePrice:g,basePrices:_,baseSalePrice:v,baseSalePrices:y,currencies:b,availableVariantImages:x=[],initialVariationAttributes:S,initialVariants:C,onChange:w}){let[T,E]=(0,s.useState)(()=>S&&S.length>0?S.reduce((e,t)=>(e[t.attribute_id]=t.term_ids,e),{}):n.extractSelectedTermsByAttribute(C||[])),[D,O]=(0,s.useState)(a.sanitizeVariantDraftsForStoreManagedCurrencies(C||[],b)),k=(0,s.useMemo)(()=>e.map(e=>({attribute_id:e.id,attribute_name:n.resolveAttributeName(e,d),terms:e.terms.filter(t=>(T[e.id]||[]).includes(t.id)).map(e=>({...e,value:n.resolveTermValue(e,d)}))})).filter(e=>e.terms.length>0),[d,e,T]);(0,s.useEffect)(()=>{if(k.length===0){O([]);return}O(e=>a.sanitizeVariantDraftsForStoreManagedCurrencies(n.generateVariantDrafts({baseSku:f,basePrice:g,basePrices:t.normalizePriceMap(_),baseSalePrice:v,baseSalePrices:t.normalizeSalePriceMap(y),selectedAttributes:k,previousVariants:e}),b))},[g,_,v,y,f,b,k]),(0,s.useEffect)(()=>{w({variationAttributes:h(T),variants:D})},[w,T,D]);let A=D.reduce((e,t)=>e+(t.stock_quantity||0),0),j=b.find(e=>e.is_default)??b[0],M=(0,s.useMemo)(()=>a.getStoreManagedPriceCurrencyCodes(b),[b]),N=(e,t)=>{E(n=>{let r=new Set(n[e]||[]);return r.has(t)?r.delete(t):r.add(t),{...n,[e]:[...r]}})},P=(e,t,n)=>{O(r=>r.map(r=>{if(r.combination_key!==e)return r;if(t===`sku`)return{...r,sku:n};if(t===`upc`)return{...r,upc:n};if(t===`sale_price`&&n===``)return{...r,sale_price:null};if(t===`prices`||t===`sale_prices`)return r;let i=n===``?0:Number(n);return{...r,[t]:Number.isFinite(i)?i:0}}))},F=(e,t,n)=>{O(r=>r.map(r=>r.combination_key===e?{...r,[t]:n}:r))},I=(e,t,n,r)=>{let i=b.find(e=>e.is_default)??b[0];O(a=>a.map(a=>{if(a.combination_key!==e)return a;let o={...n===`prices`?a.prices:a.sale_prices,[t]:r};return{...a,[n]:o,...t===i?.code?n===`prices`?{price:r??0}:{sale_price:r}:{}}}))},L=e=>{let n=b.find(e=>e.is_default)??b[0],r=new Set(M);n&&O(i=>i.map(i=>{if(i.combination_key!==e)return i;let a=b.reduce((e,a)=>{if(a.code!==n.code&&r.has(a.code))return e;let o=t.convertMinorUnitAmount({amount:(0,c.majorUnitAmountToMinor)(i.price,n.code),fromCurrencyCode:n.code,toCurrencyCode:a.code,currencies:b,applyRounding:!0});return e[a.code]=(0,c.minorUnitAmountToMajor)(o,a.code),e},{}),o=b.reduce((e,a)=>{if(a.code!==n.code&&r.has(a.code))return e;if(typeof i.sale_price!=`number`)return e[a.code]=null,e;let o=t.convertMinorUnitAmount({amount:(0,c.majorUnitAmountToMinor)(i.sale_price,n.code),fromCurrencyCode:n.code,toCurrencyCode:a.code,currencies:b,applyRounding:!0});return e[a.code]=(0,c.minorUnitAmountToMajor)(o,a.code),e},{});return{...i,prices:a,sale_prices:o}}))},R=(e,t)=>{let n=x.find(e=>e.media_id===t);if(!n)return;let r=n.file_path,i=p(r);O(t=>t.map(t=>t.combination_key===e?{...t,main_media_id:n.media_id,main_image_url:i}:t))},z=e=>{O(t=>t.map(t=>t.combination_key===e?{...t,main_media_id:null,main_image_url:null}:t))};return e.length===0?(0,l.jsxs)(`div`,{className:`rounded-lg border border-dashed p-6 text-sm text-muted-foreground`,children:[`No global attributes have been created yet. Create them first in`,` `,(0,l.jsx)(o.default,{href:`/cms/products/attributes`,className:`font-medium text-primary underline-offset-4 hover:underline`,children:`Attribute Management`}),`.`]}):(0,l.jsxs)(`div`,{className:`space-y-3`,children:[(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,l.jsx)(`span`,{className:`text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none`,children:`Attributes`}),(0,l.jsxs)(u.Badge,{variant:`outline`,className:`text-[10px] px-1.5 h-4`,children:[D.length,` variants`]}),(0,l.jsxs)(u.Badge,{variant:`secondary`,className:`text-[10px] px-1.5 h-4`,children:[`Stock: `,A]})]}),(0,l.jsx)(u.Button,{asChild:!0,variant:`outline`,size:`sm`,className:`h-7 text-xs px-3`,children:(0,l.jsx)(o.default,{href:`/cms/products/attributes`,children:`Manage`})})]}),(0,l.jsx)(`div`,{className:`grid gap-2 lg:grid-cols-2`,children:e.map(e=>{let t=T[e.id]||[];return(0,l.jsxs)(`div`,{className:`flex items-center gap-3 rounded border p-2.5`,children:[(0,l.jsxs)(`div`,{className:`shrink-0 w-[100px]`,children:[(0,l.jsx)(`span`,{className:`text-sm font-bold block leading-tight`,children:n.resolveAttributeName(e,d)}),(0,l.jsxs)(`span`,{className:`text-[10px] text-muted-foreground leading-none`,children:[t.length,` selected`]})]}),(0,l.jsx)(`div`,{className:`flex flex-wrap gap-1.5 flex-1`,children:e.terms.map(r=>{let i=t.includes(r.id);return(0,l.jsx)(`button`,{type:`button`,onClick:()=>N(e.id,r.id),className:`rounded-full border px-2.5 py-0.5 text-[11px] font-medium transition-colors ${i?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground hover:border-primary/40`}`,children:n.resolveTermValue(r,d)},r.id)})})]},e.id)})})]}),D.length===0?(0,l.jsx)(`div`,{className:`rounded border border-dashed p-3 text-xs text-muted-foreground text-center`,children:`Select terms above to generate variations.`}):(0,l.jsx)(`div`,{className:`space-y-2`,children:D.map(e=>{let t=a.resolveEditorCurrencyPriceMaps({currencies:b,prices:e.prices||{},salePrices:e.sale_prices||{},fallbackPrice:e.price,fallbackSalePrice:e.sale_price});return(0,l.jsxs)(`div`,{className:`rounded border p-3 space-y-2`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`text-sm font-bold`,children:e.label}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.selected_options.map(e=>`${e.attribute_name}: ${e.term_value}`).join(` · `)})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,l.jsxs)(`span`,{children:[`Reg: `,m(e.price,j?.code||`USD`)]}),(0,l.jsxs)(`span`,{children:[`Sale:`,` `,e.sale_price!==null&&e.sale_price!==void 0?m(e.sale_price,j?.code||`USD`):`—`]})]})]}),(0,l.jsxs)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(u.Label,{htmlFor:`variant-sku-${e.combination_key}`,className:`text-xs uppercase font-bold text-muted-foreground tracking-wider shrink-0`,children:`SKU`}),(0,l.jsx)(u.Input,{id:`variant-sku-${e.combination_key}`,value:e.sku,onChange:t=>P(e.combination_key,`sku`,t.target.value),placeholder:`SKU`,className:`h-8 text-sm font-mono`})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(u.Label,{htmlFor:`variant-upc-${e.combination_key}`,className:`text-xs uppercase font-bold text-muted-foreground tracking-wider shrink-0`,children:`UPC`}),(0,l.jsx)(u.Input,{id:`variant-upc-${e.combination_key}`,value:e.upc??``,onChange:t=>P(e.combination_key,`upc`,t.target.value),placeholder:`—`,className:`h-8 text-sm font-mono`})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(u.Label,{htmlFor:`variant-stock-${e.combination_key}`,className:`text-xs uppercase font-bold text-muted-foreground tracking-wider shrink-0`,children:`Qty`}),(0,l.jsx)(u.Input,{id:`variant-stock-${e.combination_key}`,type:`number`,min:`0`,value:e.stock_quantity,onChange:t=>P(e.combination_key,`stock_quantity`,t.target.value),className:`h-8 text-sm font-mono w-20`})]})]}),(0,l.jsx)(r.CurrencyPriceFields,{idPrefix:`variant-${e.combination_key}`,currencies:b,prices:t.prices,salePrices:t.salePrices,managedCurrencyCodes:M,onPriceChange:(t,n)=>I(e.combination_key,t,`prices`,n),onSalePriceChange:(t,n)=>I(e.combination_key,t,`sale_prices`,n),onAutoFill:()=>L(e.combination_key),helperText:M.length>0?`Store-managed currencies derive from ${j?.code||`the base currency`}.`:void 0,trailing:(0,l.jsx)(i.SaleScheduleFields,{idPrefix:`variant-${e.combination_key}`,startAt:e.sale_start_at,endAt:e.sale_end_at,onChange:(t,n)=>F(e.combination_key,t,n),bare:!0})}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 pt-1.5 border-t border-muted/30`,children:[e.main_image_url&&(0,l.jsx)(`div`,{className:`h-9 w-9 overflow-hidden rounded border bg-background shrink-0`,children:(0,l.jsx)(`img`,{src:e.main_image_url,alt:`${e.label} image`,className:`h-full w-full object-cover`})}),(0,l.jsx)(`span`,{className:`text-xs uppercase font-bold text-muted-foreground tracking-wider shrink-0`,children:`Image`}),x.length>0?(0,l.jsxs)(`select`,{className:`flex h-8 rounded-md border border-input bg-background px-2 py-1 text-sm min-w-[180px]`,value:e.main_media_id??``,onChange:t=>{if(!t.target.value){z(e.combination_key);return}R(e.combination_key,t.target.value)},children:[(0,l.jsx)(`option`,{value:``,children:`Use parent image`}),x.map((e,t)=>(0,l.jsx)(`option`,{value:e.media_id,children:e.alt?.trim()||`Gallery image ${t+1}`},e.media_id))]}):(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Add gallery images first.`}),e.main_media_id&&(0,l.jsx)(u.Button,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 text-xs px-2 text-muted-foreground hover:text-destructive`,onClick:()=>z(e.combination_key),children:`Remove`})]})]},e.combination_key)})})]})}exports.VariationsEditor=g;
@@ -22,5 +22,5 @@ interface VariationsEditorProps {
22
22
  variants: ProductFormValues['variants'];
23
23
  }) => void;
24
24
  }
25
- export declare function VariationsEditor({ globalAttributes, currentLanguageCode, baseSku, basePrice, basePrices, baseSalePrice, baseSalePrices, currencies, availableVariantImages, initialVariationAttributes, initialVariants, onChange, }: VariationsEditorProps): import("react").JSX.Element;
25
+ export declare function VariationsEditor({ globalAttributes, currentLanguageCode, baseSku, basePrice, basePrices, baseSalePrice, baseSalePrices, currencies, availableVariantImages, initialVariationAttributes, initialVariants, onChange, }: VariationsEditorProps): import('react').JSX.Element;
26
26
  export {};