@nextblock-cms/ecom 0.20.3 → 0.21.1

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 (446) hide show
  1. package/README.md +43 -0
  2. package/_virtual/_rolldown/runtime.cjs +1 -0
  3. package/index.cjs +1 -0
  4. package/index.es.js +38 -146
  5. package/lib/CurrencyProvider.cjs +1 -0
  6. package/lib/CurrencyProvider.d.ts +1 -1
  7. package/lib/CurrencyProvider.es.js +85 -95
  8. package/lib/PaymentReadinessProvider.cjs +1 -0
  9. package/lib/PaymentReadinessProvider.d.ts +1 -1
  10. package/lib/PaymentReadinessProvider.es.js +24 -27
  11. package/lib/cart-store.cjs +1 -0
  12. package/lib/cart-store.es.js +109 -121
  13. package/lib/components/AccountNavigationMenu.cjs +1 -0
  14. package/lib/components/AccountNavigationMenu.d.ts +1 -1
  15. package/lib/components/AccountNavigationMenu.es.js +36 -50
  16. package/lib/components/AddToCartButton.cjs +1 -0
  17. package/lib/components/AddToCartButton.d.ts +1 -1
  18. package/lib/components/AddToCartButton.es.js +94 -89
  19. package/lib/components/Cart.cjs +1 -0
  20. package/lib/components/Cart.d.ts +1 -1
  21. package/lib/components/Cart.es.js +261 -180
  22. package/lib/components/CartDrawer.cjs +1 -0
  23. package/lib/components/CartDrawer.d.ts +1 -1
  24. package/lib/components/CartDrawer.es.js +218 -148
  25. package/lib/components/CartIcon.cjs +1 -0
  26. package/lib/components/CartIcon.d.ts +1 -1
  27. package/lib/components/CartIcon.es.js +33 -35
  28. package/lib/components/Checkout.cjs +1 -0
  29. package/lib/components/Checkout.d.ts +1 -1
  30. package/lib/components/Checkout.es.js +1092 -1108
  31. package/lib/components/CouponForm.cjs +1 -0
  32. package/lib/components/CouponForm.d.ts +1 -1
  33. package/lib/components/CouponForm.es.js +136 -148
  34. package/lib/components/CurrencySwitcher.cjs +1 -0
  35. package/lib/components/CurrencySwitcher.d.ts +1 -1
  36. package/lib/components/CurrencySwitcher.es.js +22 -18
  37. package/lib/components/CustomerProfileForm.cjs +1 -0
  38. package/lib/components/CustomerProfileForm.es.js +454 -313
  39. package/lib/components/FeaturedProduct.cjs +1 -0
  40. package/lib/components/FeaturedProduct.d.ts +1 -1
  41. package/lib/components/FeaturedProduct.es.js +98 -83
  42. package/lib/components/FreemiusLicensePanel.cjs +1 -0
  43. package/lib/components/FreemiusLicensePanel.d.ts +1 -1
  44. package/lib/components/FreemiusLicensePanel.es.js +70 -65
  45. package/lib/components/InvoiceDocument.cjs +1 -0
  46. package/lib/components/InvoiceDocument.es.js +256 -192
  47. package/lib/components/InvoiceViewerShell.cjs +29 -0
  48. package/lib/components/InvoiceViewerShell.d.ts +1 -1
  49. package/lib/components/InvoiceViewerShell.es.js +75 -106
  50. package/lib/components/ProductCard.cjs +1 -0
  51. package/lib/components/ProductCard.d.ts +1 -1
  52. package/lib/components/ProductCard.es.js +186 -171
  53. package/lib/components/ProductDetailsLayout.cjs +1 -0
  54. package/lib/components/ProductDetailsLayout.es.js +405 -404
  55. package/lib/components/ProductGallery.cjs +1 -0
  56. package/lib/components/ProductGallery.d.ts +1 -1
  57. package/lib/components/ProductGallery.es.js +51 -54
  58. package/lib/components/ProductGrid.cjs +1 -0
  59. package/lib/components/ProductGrid.d.ts +1 -1
  60. package/lib/components/ProductGrid.es.js +23 -25
  61. package/lib/components/ShippingEstimator.cjs +1 -0
  62. package/lib/components/ShippingEstimator.d.ts +1 -1
  63. package/lib/components/ShippingEstimator.es.js +158 -153
  64. package/lib/components/ShortDescription.cjs +1 -0
  65. package/lib/components/ShortDescription.es.js +17 -17
  66. package/lib/components/SimpleTiptapRenderer.cjs +1 -0
  67. package/lib/components/SimpleTiptapRenderer.es.js +238 -211
  68. package/lib/components/SubscriptionSelector.cjs +1 -0
  69. package/lib/components/SubscriptionSelector.es.js +159 -154
  70. package/lib/countries.cjs +1 -0
  71. package/lib/countries.es.js +232 -75
  72. package/lib/coupon-server.cjs +1 -0
  73. package/lib/coupon-server.es.js +180 -224
  74. package/lib/coupons.cjs +1 -0
  75. package/lib/coupons.es.js +12 -14
  76. package/lib/currency-constants.cjs +1 -0
  77. package/lib/currency-constants.es.js +4 -4
  78. package/lib/currency-rest-client.cjs +1 -0
  79. package/lib/currency-rest-client.es.js +15 -22
  80. package/lib/currency-store.cjs +1 -0
  81. package/lib/currency-store.es.js +20 -27
  82. package/lib/currency-sync.cjs +1 -0
  83. package/lib/currency-sync.es.js +124 -170
  84. package/lib/currency.cjs +1 -0
  85. package/lib/currency.es.js +242 -310
  86. package/lib/customer-addresses.cjs +1 -0
  87. package/lib/customer-addresses.es.js +80 -109
  88. package/lib/customer-orders.cjs +1 -0
  89. package/lib/customer-orders.es.js +31 -43
  90. package/lib/customer.cjs +1 -0
  91. package/lib/customer.es.js +43 -52
  92. package/lib/export-helpers.cjs +1 -0
  93. package/lib/export-helpers.es.js +53 -52
  94. package/lib/factory.cjs +1 -0
  95. package/lib/factory.es.js +10 -7
  96. package/lib/freemius-coupons.cjs +1 -0
  97. package/lib/freemius-coupons.es.js +245 -262
  98. package/lib/freemius-license-claim.cjs +1 -0
  99. package/lib/freemius-license-claim.es.js +87 -71
  100. package/lib/freemius-license.cjs +1 -0
  101. package/lib/freemius-license.es.js +32 -39
  102. package/lib/freemius-order-sync.cjs +1 -0
  103. package/lib/freemius-order-sync.es.js +226 -290
  104. package/lib/freemius-trial-provision.cjs +1 -0
  105. package/lib/freemius-trial-provision.es.js +136 -130
  106. package/lib/inventory-settings.cjs +1 -0
  107. package/lib/inventory-settings.es.js +69 -77
  108. package/lib/invoice-server.cjs +33 -0
  109. package/lib/invoice-server.es.js +94 -141
  110. package/lib/invoice-ui.cjs +1 -0
  111. package/lib/invoice-ui.es.js +50 -66
  112. package/lib/invoice.cjs +1 -0
  113. package/lib/invoice.es.js +85 -94
  114. package/lib/order-inventory.cjs +61 -0
  115. package/lib/order-inventory.es.js +67 -79
  116. package/lib/order-tax-details.cjs +1 -0
  117. package/lib/order-tax-details.es.js +142 -153
  118. package/lib/pages/cms/coupons/CouponEditorForm.cjs +1 -0
  119. package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
  120. package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
  121. package/lib/pages/cms/coupons/CouponsPage.cjs +5 -0
  122. package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
  123. package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
  124. package/lib/pages/cms/coupons/CreateCouponDialog.cjs +1 -0
  125. package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
  126. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
  127. package/lib/pages/cms/coupons/EditCouponPage.cjs +1 -0
  128. package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
  129. package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
  130. package/lib/pages/cms/coupons/ProductScopePicker.cjs +1 -0
  131. package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
  132. package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
  133. package/lib/pages/cms/coupons/actions.cjs +1 -0
  134. package/lib/pages/cms/coupons/actions.es.js +112 -115
  135. package/lib/pages/cms/coupons/index.cjs +1 -0
  136. package/lib/pages/cms/coupons/index.es.js +3 -0
  137. package/lib/pages/cms/coupons/product-options.cjs +1 -0
  138. package/lib/pages/cms/coupons/product-options.es.js +21 -23
  139. package/lib/pages/cms/orders/ExportReportsDialog.cjs +1 -0
  140. package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
  141. package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
  142. package/lib/pages/cms/orders/OrderDetailPage.cjs +1 -0
  143. package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
  144. package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
  145. package/lib/pages/cms/orders/OrderPrintButton.cjs +1 -0
  146. package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
  147. package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
  148. package/lib/pages/cms/orders/OrderStatusForm.cjs +1 -0
  149. package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
  150. package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
  151. package/lib/pages/cms/orders/OrdersPage.cjs +1 -0
  152. package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
  153. package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
  154. package/lib/pages/cms/orders/actions.cjs +7 -0
  155. package/lib/pages/cms/orders/actions.es.js +53 -69
  156. package/lib/pages/cms/orders/export-actions.cjs +1 -0
  157. package/lib/pages/cms/orders/export-actions.es.js +23 -26
  158. package/lib/pages/cms/orders/index.cjs +1 -0
  159. package/lib/pages/cms/orders/index.es.js +6 -0
  160. package/lib/pages/cms/orders/server-actions.cjs +1 -0
  161. package/lib/pages/cms/orders/server-actions.es.js +60 -51
  162. package/lib/pages/cms/payments/PaymentsClient.cjs +1 -0
  163. package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
  164. package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
  165. package/lib/pages/cms/payments/PaymentsPage.cjs +1 -0
  166. package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
  167. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
  168. package/lib/pages/cms/payments/actions.cjs +1 -0
  169. package/lib/pages/cms/payments/actions.es.js +38 -48
  170. package/lib/pages/cms/payments/index.cjs +1 -0
  171. package/lib/pages/cms/payments/index.es.js +3 -0
  172. package/lib/pages/cms/payments/queries.cjs +1 -0
  173. package/lib/pages/cms/payments/queries.es.js +38 -48
  174. package/lib/pages/cms/products/ProductsPage.cjs +1 -0
  175. package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
  176. package/lib/pages/cms/products/ProductsPage.es.js +63 -66
  177. package/lib/pages/cms/products/[id]/edit/EditProductPage.cjs +1 -0
  178. package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
  179. package/lib/pages/cms/products/[id]/edit/EditProductPage.es.js +139 -0
  180. package/lib/pages/cms/products/actions.cjs +44 -0
  181. package/lib/pages/cms/products/actions.es.js +121 -162
  182. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs +1 -0
  183. package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
  184. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
  185. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs +1 -0
  186. package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
  187. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
  188. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs +1 -0
  189. package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
  190. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
  191. package/lib/pages/cms/products/categories/components/CategoryManager.cjs +1 -0
  192. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
  193. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs +1 -0
  194. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
  195. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs +1 -0
  196. package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
  197. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
  198. package/lib/pages/cms/products/components/DeleteProductButton.cjs +1 -0
  199. package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
  200. package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
  201. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs +1 -0
  202. package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
  203. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
  204. package/lib/pages/cms/products/components/ProductCategorySelector.cjs +1 -0
  205. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
  206. package/lib/pages/cms/products/components/ProductForm.cjs +1 -0
  207. package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
  208. package/lib/pages/cms/products/components/ProductMediaManager.cjs +1 -0
  209. package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
  210. package/lib/pages/cms/products/components/ProductsBulkTable.cjs +1 -0
  211. package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
  212. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
  213. package/lib/pages/cms/products/components/SaleScheduleFields.cjs +1 -0
  214. package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
  215. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
  216. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs +1 -0
  217. package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
  218. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
  219. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs +5 -0
  220. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
  221. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
  222. package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
  223. package/lib/pages/cms/products/components/VariationsEditor.cjs +1 -0
  224. package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
  225. package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
  226. package/lib/pages/cms/products/index.cjs +1 -0
  227. package/lib/pages/cms/products/index.es.js +8 -0
  228. package/lib/pages/cms/products/inventory/InventoryPage.cjs +1 -0
  229. package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
  230. package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
  231. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs +2 -0
  232. package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
  233. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
  234. package/lib/pages/cms/products/inventory/actions.cjs +3 -0
  235. package/lib/pages/cms/products/inventory/actions.es.js +83 -91
  236. package/lib/pages/cms/products/new/NewProductPage.cjs +1 -0
  237. package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
  238. package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
  239. package/lib/pages/cms/products/product-price-sync.cjs +1 -0
  240. package/lib/pages/cms/products/product-price-sync.es.js +74 -89
  241. package/lib/pages/cms/products/server-actions.cjs +1 -0
  242. package/lib/pages/cms/products/server-actions.es.js +250 -233
  243. package/lib/pages/cms/shipping/ShippingPage.cjs +5 -0
  244. package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
  245. package/lib/pages/cms/shipping/components/RateForm.cjs +1 -0
  246. package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
  247. package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
  248. package/lib/pages/cms/shipping/components/ZoneForm.cjs +1 -0
  249. package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
  250. package/lib/pages/cms/shipping/index.cjs +1 -0
  251. package/lib/pages/cms/shipping/index.es.js +3 -0
  252. package/lib/pages/cms/shipping/server-actions.cjs +1 -0
  253. package/lib/pages/cms/shipping/server-actions.es.js +131 -149
  254. package/lib/pages/cms/taxes/TaxesPage.cjs +1 -0
  255. package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
  256. package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
  257. package/lib/pages/cms/taxes/actions.cjs +1 -0
  258. package/lib/pages/cms/taxes/actions.es.js +41 -53
  259. package/lib/pages/cms/taxes/components/TaxRateForm.cjs +1 -0
  260. package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
  261. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
  262. package/lib/pages/cms/taxes/index.cjs +1 -0
  263. package/lib/pages/cms/taxes/index.es.js +3 -0
  264. package/lib/payment-config.cjs +1 -0
  265. package/lib/payment-config.es.js +110 -126
  266. package/lib/product-actions.cjs +238 -0
  267. package/lib/product-actions.es.js +289 -544
  268. package/lib/product-context.cjs +1 -0
  269. package/lib/product-context.es.js +13 -15
  270. package/lib/product-schema.cjs +1 -0
  271. package/lib/product-schema.es.js +99 -134
  272. package/lib/providers/freemius.cjs +1 -0
  273. package/lib/providers/freemius.es.js +446 -530
  274. package/lib/providers/stripe.cjs +1 -0
  275. package/lib/providers/stripe.es.js +417 -477
  276. package/lib/server-actions/coupon-actions.cjs +1 -0
  277. package/lib/server-actions/coupon-actions.es.js +22 -22
  278. package/lib/server-actions/customer-actions.cjs +1 -0
  279. package/lib/server-actions/customer-actions.es.js +26 -28
  280. package/lib/server-actions/product-actions.cjs +1 -0
  281. package/lib/server-actions/product-actions.es.js +9 -15
  282. package/lib/server-actions/shipping-actions.cjs +1 -0
  283. package/lib/server-actions/shipping-actions.es.js +27 -24
  284. package/lib/server-actions/tax-actions.cjs +1 -0
  285. package/lib/server-actions/tax-actions.es.js +33 -39
  286. package/lib/shared-inventory.cjs +15 -0
  287. package/lib/shared-inventory.es.js +111 -160
  288. package/lib/shipping/resolver.cjs +7 -0
  289. package/lib/shipping/resolver.es.js +44 -61
  290. package/lib/shipping-rate-currency.cjs +1 -0
  291. package/lib/shipping-rate-currency.es.js +52 -67
  292. package/lib/states.cjs +1 -0
  293. package/lib/states.es.js +333 -154
  294. package/lib/stripe/checkout.cjs +1 -0
  295. package/lib/stripe/checkout.es.js +125 -181
  296. package/lib/stripe/client.cjs +1 -0
  297. package/lib/stripe/client.es.js +14 -19
  298. package/lib/stripe/order-sync.cjs +1 -0
  299. package/lib/stripe/order-sync.es.js +106 -126
  300. package/lib/stripe/webhooks.cjs +1 -0
  301. package/lib/stripe/webhooks.es.js +37 -31
  302. package/lib/tax-calculation.cjs +1 -0
  303. package/lib/tax-calculation.es.js +84 -98
  304. package/lib/trials.cjs +1 -0
  305. package/lib/trials.es.js +24 -30
  306. package/lib/types.cjs +1 -0
  307. package/lib/types.es.js +21 -27
  308. package/lib/use-cart.cjs +1 -0
  309. package/lib/use-cart.es.js +38 -40
  310. package/lib/use-price-formatter.cjs +1 -0
  311. package/lib/use-price-formatter.es.js +10 -11
  312. package/lib/variation-utils.cjs +1 -0
  313. package/lib/variation-utils.es.js +199 -261
  314. package/lib/zod-config.cjs +1 -0
  315. package/lib/zod-config.es.js +5 -6
  316. package/package.json +22 -21
  317. package/server.cjs +1 -0
  318. package/server.es.js +56 -211
  319. package/index.cjs.js +0 -1
  320. package/lib/CurrencyProvider.cjs.js +0 -1
  321. package/lib/PaymentReadinessProvider.cjs.js +0 -1
  322. package/lib/cart-store.cjs.js +0 -1
  323. package/lib/components/AccountNavigationMenu.cjs.js +0 -1
  324. package/lib/components/AddToCartButton.cjs.js +0 -1
  325. package/lib/components/Cart.cjs.js +0 -1
  326. package/lib/components/CartDrawer.cjs.js +0 -1
  327. package/lib/components/CartIcon.cjs.js +0 -1
  328. package/lib/components/Checkout.cjs.js +0 -1
  329. package/lib/components/CouponForm.cjs.js +0 -1
  330. package/lib/components/CurrencySwitcher.cjs.js +0 -1
  331. package/lib/components/CustomerProfileForm.cjs.js +0 -1
  332. package/lib/components/FeaturedProduct.cjs.js +0 -1
  333. package/lib/components/FreemiusLicensePanel.cjs.js +0 -1
  334. package/lib/components/InvoiceDocument.cjs.js +0 -1
  335. package/lib/components/InvoiceViewerShell.cjs.js +0 -29
  336. package/lib/components/ProductCard.cjs.js +0 -1
  337. package/lib/components/ProductDetailsLayout.cjs.js +0 -1
  338. package/lib/components/ProductGallery.cjs.js +0 -1
  339. package/lib/components/ProductGrid.cjs.js +0 -1
  340. package/lib/components/ShippingEstimator.cjs.js +0 -1
  341. package/lib/components/ShortDescription.cjs.js +0 -1
  342. package/lib/components/SimpleTiptapRenderer.cjs.js +0 -1
  343. package/lib/components/SubscriptionSelector.cjs.js +0 -1
  344. package/lib/countries.cjs.js +0 -1
  345. package/lib/coupon-server.cjs.js +0 -1
  346. package/lib/coupons.cjs.js +0 -1
  347. package/lib/currency-constants.cjs.js +0 -1
  348. package/lib/currency-rest-client.cjs.js +0 -1
  349. package/lib/currency-store.cjs.js +0 -1
  350. package/lib/currency-sync.cjs.js +0 -1
  351. package/lib/currency.cjs.js +0 -1
  352. package/lib/customer-addresses.cjs.js +0 -1
  353. package/lib/customer-orders.cjs.js +0 -1
  354. package/lib/customer.cjs.js +0 -1
  355. package/lib/export-helpers.cjs.js +0 -1
  356. package/lib/factory.cjs.js +0 -1
  357. package/lib/freemius-coupons.cjs.js +0 -1
  358. package/lib/freemius-license-claim.cjs.js +0 -1
  359. package/lib/freemius-license.cjs.js +0 -1
  360. package/lib/freemius-order-sync.cjs.js +0 -1
  361. package/lib/freemius-trial-provision.cjs.js +0 -1
  362. package/lib/inventory-settings.cjs.js +0 -1
  363. package/lib/invoice-server.cjs.js +0 -33
  364. package/lib/invoice-ui.cjs.js +0 -1
  365. package/lib/invoice.cjs.js +0 -1
  366. package/lib/order-inventory.cjs.js +0 -61
  367. package/lib/order-tax-details.cjs.js +0 -1
  368. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +0 -1
  369. package/lib/pages/cms/coupons/CouponsPage.cjs.js +0 -5
  370. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +0 -1
  371. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +0 -1
  372. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +0 -1
  373. package/lib/pages/cms/coupons/actions.cjs.js +0 -1
  374. package/lib/pages/cms/coupons/product-options.cjs.js +0 -1
  375. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +0 -1
  376. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +0 -1
  377. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +0 -1
  378. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +0 -1
  379. package/lib/pages/cms/orders/OrdersPage.cjs.js +0 -1
  380. package/lib/pages/cms/orders/actions.cjs.js +0 -7
  381. package/lib/pages/cms/orders/export-actions.cjs.js +0 -1
  382. package/lib/pages/cms/orders/server-actions.cjs.js +0 -1
  383. package/lib/pages/cms/payments/PaymentsClient.cjs.js +0 -1
  384. package/lib/pages/cms/payments/PaymentsPage.cjs.js +0 -1
  385. package/lib/pages/cms/payments/actions.cjs.js +0 -1
  386. package/lib/pages/cms/payments/queries.cjs.js +0 -1
  387. package/lib/pages/cms/products/ProductsPage.cjs.js +0 -1
  388. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +0 -1
  389. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +0 -156
  390. package/lib/pages/cms/products/actions.cjs.js +0 -44
  391. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +0 -1
  392. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +0 -1
  393. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +0 -1
  394. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +0 -1
  395. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +0 -1
  396. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +0 -1
  397. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +0 -1
  398. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +0 -1
  399. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +0 -1
  400. package/lib/pages/cms/products/components/ProductForm.cjs.js +0 -1
  401. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +0 -1
  402. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +0 -1
  403. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +0 -1
  404. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +0 -1
  405. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +0 -5
  406. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +0 -1
  407. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +0 -1
  408. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +0 -2
  409. package/lib/pages/cms/products/inventory/actions.cjs.js +0 -3
  410. package/lib/pages/cms/products/new/NewProductPage.cjs.js +0 -1
  411. package/lib/pages/cms/products/product-price-sync.cjs.js +0 -1
  412. package/lib/pages/cms/products/server-actions.cjs.js +0 -1
  413. package/lib/pages/cms/shipping/ShippingPage.cjs.js +0 -5
  414. package/lib/pages/cms/shipping/components/RateForm.cjs.js +0 -1
  415. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +0 -1
  416. package/lib/pages/cms/shipping/server-actions.cjs.js +0 -1
  417. package/lib/pages/cms/taxes/TaxesPage.cjs.js +0 -1
  418. package/lib/pages/cms/taxes/actions.cjs.js +0 -1
  419. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +0 -1
  420. package/lib/payment-config.cjs.js +0 -1
  421. package/lib/product-actions.cjs.js +0 -238
  422. package/lib/product-context.cjs.js +0 -1
  423. package/lib/product-schema.cjs.js +0 -1
  424. package/lib/providers/freemius.cjs.js +0 -5
  425. package/lib/providers/stripe.cjs.js +0 -1
  426. package/lib/server-actions/coupon-actions.cjs.js +0 -1
  427. package/lib/server-actions/customer-actions.cjs.js +0 -1
  428. package/lib/server-actions/product-actions.cjs.js +0 -1
  429. package/lib/server-actions/shipping-actions.cjs.js +0 -1
  430. package/lib/server-actions/tax-actions.cjs.js +0 -1
  431. package/lib/shared-inventory.cjs.js +0 -15
  432. package/lib/shipping/resolver.cjs.js +0 -7
  433. package/lib/shipping-rate-currency.cjs.js +0 -1
  434. package/lib/states.cjs.js +0 -1
  435. package/lib/stripe/checkout.cjs.js +0 -1
  436. package/lib/stripe/client.cjs.js +0 -1
  437. package/lib/stripe/order-sync.cjs.js +0 -1
  438. package/lib/stripe/webhooks.cjs.js +0 -1
  439. package/lib/tax-calculation.cjs.js +0 -1
  440. package/lib/trials.cjs.js +0 -1
  441. package/lib/types.cjs.js +0 -1
  442. package/lib/use-cart.cjs.js +0 -1
  443. package/lib/use-price-formatter.cjs.js +0 -1
  444. package/lib/variation-utils.cjs.js +0 -1
  445. package/lib/zod-config.cjs.js +0 -1
  446. package/server.cjs.js +0 -1
@@ -0,0 +1 @@
1
+ "use client";const e=require("../../../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../../countries.cjs"),n=require("../../../../states.cjs"),r=require("../server-actions.cjs");let i=require("react");i=e.__toESM(i,1);let a=require("lucide-react"),o=require("react/jsx-runtime"),s=require("@nextblock-cms/ui");function c(e=[]){return[...new Set(e.map(e=>e.country_code))]}function l(e=[]){return e.reduce((e,t)=>{if(!t.state_code)return e;let n=new Set(e[t.country_code]||[]);return n.add(t.state_code),e[t.country_code]=[...n],e},{})}function u(e,t){return e.flatMap(e=>{let n=t[e]||[];return n.length===0?[{country_code:e,state_code:null}]:n.map(t=>({country_code:e,state_code:t}))})}function d({mode:e=`create`,initialData:d}){let[f,p]=(0,i.useState)(!1),m=e===`edit`,[h,g]=(0,i.useState)(d?.name||``),[_,v]=(0,i.useState)(d?.priority_order||0),[y,b]=(0,i.useState)(c(d?.locations)),[x,S]=(0,i.useState)(l(d?.locations)),[C,w]=(0,i.useState)(``),[T,E]=(0,i.useState)(!1);(0,i.useEffect)(()=>{f&&(g(d?.name||``),v(d?.priority_order||0),b(c(d?.locations)),S(l(d?.locations)),w(``))},[d,f]);let D=(0,i.useMemo)(()=>{let e=C.trim().toLowerCase();return e?t.countries.filter(t=>t.name.toLowerCase().includes(e)||t.code.toLowerCase().includes(e)):t.countries},[C]),O=(0,i.useMemo)(()=>t.countries.filter(e=>y.includes(e.code)),[y]),k=e=>{b(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),S(t=>{if(t[e]){let n={...t};return delete n[e],n}return t})},A=(e,t)=>{S(n=>{let r=new Set(n[e]||[]);return r.has(t)?r.delete(t):r.add(t),{...n,[e]:[...r]}})};return(0,o.jsxs)(s.Dialog,{open:f,onOpenChange:p,children:[(0,o.jsx)(s.DialogTrigger,{asChild:!0,children:m?(0,o.jsx)(s.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-slate-400 hover:text-primary`,children:(0,o.jsx)(a.Edit2,{className:`h-4 w-4`})}):(0,o.jsxs)(s.Button,{className:`gap-2 shadow-sm`,children:[(0,o.jsx)(a.Plus,{className:`h-4 w-4`}),`New Zone`]})}),(0,o.jsx)(s.DialogContent,{className:`max-w-4xl max-h-[90vh] flex flex-col overflow-hidden`,children:(0,o.jsxs)(`form`,{onSubmit:async e=>{if(e.preventDefault(),!h||y.length===0)return;E(!0);let t=u(y,x),n=m&&d?.id?await r.updateShippingZone(d.id,h,_,t):await r.createShippingZone(h,_,t);E(!1),n.success?(p(!1),m||(g(``),v(0),b([]),S({}),w(``))):n.error&&alert(n.error)},className:`flex h-full flex-col overflow-hidden`,children:[(0,o.jsxs)(s.DialogHeader,{children:[(0,o.jsx)(s.DialogTitle,{children:m?`Edit Shipping Zone`:`Create Shipping Zone`}),(0,o.jsx)(s.DialogDescription,{children:`Select countries first, then optionally limit a zone to specific states or provinces. Leaving state selections empty keeps the whole country in the zone.`})]}),(0,o.jsxs)(`div`,{className:`grid gap-6 overflow-y-auto py-6 pr-2`,children:[(0,o.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,o.jsx)(s.Label,{htmlFor:`name`,className:`text-right`,children:`Zone Name`}),(0,o.jsx)(s.Input,{id:`name`,value:h,onChange:e=>g(e.target.value),placeholder:`e.g. North America, Canada East, US West`,className:`col-span-3`,required:!0})]}),(0,o.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,o.jsx)(s.Label,{htmlFor:`priority`,className:`text-right`,children:`Priority Order`}),(0,o.jsx)(s.Input,{id:`priority`,type:`number`,value:_,onChange:e=>v(Number(e.target.value)),className:`col-span-3`})]}),(0,o.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-[1.2fr_1fr]`,children:[(0,o.jsxs)(`div`,{className:`space-y-4`,children:[(0,o.jsxs)(`div`,{className:`flex items-end justify-between gap-3`,children:[(0,o.jsxs)(s.Label,{className:`text-sm font-semibold`,children:[`Countries (`,y.length,`)`]}),(0,o.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,o.jsx)(a.Search,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-slate-400`}),(0,o.jsx)(s.Input,{placeholder:`Search countries...`,className:`pl-9 h-9`,value:C,onChange:e=>w(e.target.value)})]})]}),(0,o.jsx)(s.Card,{className:`border-slate-200 bg-slate-50/30 p-4 dark:border-slate-800 dark:bg-slate-900/30`,children:(0,o.jsx)(`div`,{className:`grid max-h-[360px] grid-cols-1 gap-3 overflow-y-auto pr-1 sm:grid-cols-2`,children:D.map(e=>{let t=y.includes(e.code);return(0,o.jsxs)(`div`,{className:`flex items-center space-x-2 rounded-md border p-2 transition-colors ${t?`border-primary/30 bg-primary/5 text-primary`:`border-transparent hover:bg-slate-100 dark:hover:bg-slate-800/60`}`,children:[(0,o.jsx)(s.Checkbox,{id:`country-${e.code}`,checked:t,onCheckedChange:()=>k(e.code)}),(0,o.jsxs)(`label`,{htmlFor:`country-${e.code}`,className:`flex-1 cursor-pointer text-xs py-1`,children:[e.name,` (`,e.code,`)`]})]},e.code)})})})]}),(0,o.jsxs)(`div`,{className:`space-y-4`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(a.MapPin,{className:`h-4 w-4 text-slate-500`}),(0,o.jsx)(s.Label,{className:`text-sm font-semibold`,children:`States / Provinces`})]}),O.length===0?(0,o.jsx)(s.Card,{className:`border-dashed p-4 text-sm text-muted-foreground`,children:`Select one or more countries to optionally narrow the zone to specific states or provinces.`}):(0,o.jsx)(`div`,{className:`space-y-4`,children:O.map(e=>{let t=n.getStatesForCountry(e.code),r=x[e.code]||[];return(0,o.jsx)(s.Card,{className:`p-4`,children:(0,o.jsxs)(`div`,{className:`space-y-3`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(`p`,{className:`font-medium`,children:[e.name,` (`,e.code,`)`]}),(0,o.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.length>0?`Leave all unchecked to apply this zone to the whole country.`:`This country uses a country-level zone in the current UI.`})]}),(0,o.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.length>0?`${r.length} selected`:`Whole country`})]}),t.length>0?(0,o.jsx)(`div`,{className:`grid max-h-[220px] grid-cols-1 gap-2 overflow-y-auto pr-1 sm:grid-cols-2`,children:t.map(t=>{let n=r.includes(t.code);return(0,o.jsxs)(`div`,{className:`flex items-center space-x-2 rounded-md border p-2 transition-colors ${n?`border-primary/30 bg-primary/5 text-primary`:`border-transparent hover:bg-slate-50 dark:hover:bg-slate-800/60`}`,children:[(0,o.jsx)(s.Checkbox,{id:`${e.code}-${t.code}`,checked:n,onCheckedChange:()=>A(e.code,t.code)}),(0,o.jsxs)(`label`,{htmlFor:`${e.code}-${t.code}`,className:`flex-1 cursor-pointer text-xs py-1`,children:[t.name,` (`,t.code,`)`]})]},`${e.code}-${t.code}`)})}):null]})},e.code)})})]})]})]}),(0,o.jsxs)(s.DialogFooter,{className:`mt-auto border-t pt-4`,children:[(0,o.jsx)(s.Button,{type:`button`,variant:`ghost`,onClick:()=>p(!1),children:`Cancel`}),(0,o.jsx)(s.Button,{type:`submit`,disabled:T||!h||y.length===0,children:T?m?`Updating...`:`Creating...`:m?`Save Changes`:`Create Zone`})]})]})})]})}exports.ZoneForm=d;
@@ -1,228 +1,249 @@
1
- 'use client';
2
- import { jsxs as s, jsx as r } from "react/jsx-runtime";
3
- import { useState as h, useEffect as O, useMemo as z } from "react";
4
- import { Dialog as T, DialogTrigger as U, Button as u, DialogContent as q, DialogHeader as Q, DialogTitle as W, DialogDescription as A, Label as f, Input as w, Card as C, Checkbox as E, DialogFooter as H } from "@nextblock-cms/ui";
5
- import { Edit2 as G, Plus as J, Search as K, MapPin as R } from "lucide-react";
6
- import { countries as k } from "../../../../countries.es.js";
7
- import { getStatesForCountry as V } from "../../../../states.es.js";
8
- import { updateShippingZone as X, createShippingZone as Y } from "../server-actions.es.js";
9
- function P(d = []) {
10
- return [...new Set(d.map((o) => o.country_code))];
1
+ "use client";
2
+ import { countries as e } from "../../../../countries.es.js";
3
+ import { getStatesForCountry as t } from "../../../../states.es.js";
4
+ import { createShippingZone as n, updateShippingZone as r } from "../server-actions.es.js";
5
+ import { useEffect as i, useMemo as a, useState as o } from "react";
6
+ import { Edit2 as s, MapPin as c, Plus as l, Search as u } from "lucide-react";
7
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
8
+ import { Button as p, Card as m, Checkbox as h, Dialog as g, DialogContent as _, DialogDescription as v, DialogFooter as y, DialogHeader as b, DialogTitle as x, DialogTrigger as S, Input as C, Label as w } from "@nextblock-cms/ui";
9
+ //#region src/lib/pages/cms/shipping/components/ZoneForm.tsx
10
+ function T(e = []) {
11
+ return [...new Set(e.map((e) => e.country_code))];
11
12
  }
12
- function j(d = []) {
13
- return d.reduce((o, a) => {
14
- if (!a.state_code)
15
- return o;
16
- const c = new Set(o[a.country_code] || []);
17
- return c.add(a.state_code), o[a.country_code] = [...c], o;
18
- }, {});
13
+ function E(e = []) {
14
+ return e.reduce((e, t) => {
15
+ if (!t.state_code) return e;
16
+ let n = new Set(e[t.country_code] || []);
17
+ return n.add(t.state_code), e[t.country_code] = [...n], e;
18
+ }, {});
19
19
  }
20
- function D(d, o) {
21
- return d.flatMap((a) => {
22
- const c = o[a] || [];
23
- return c.length === 0 ? [{ country_code: a, state_code: null }] : c.map((i) => ({
24
- country_code: a,
25
- state_code: i
26
- }));
27
- });
20
+ function D(e, t) {
21
+ return e.flatMap((e) => {
22
+ let n = t[e] || [];
23
+ return n.length === 0 ? [{
24
+ country_code: e,
25
+ state_code: null
26
+ }] : n.map((t) => ({
27
+ country_code: e,
28
+ state_code: t
29
+ }));
30
+ });
28
31
  }
29
- function ce({ mode: d = "create", initialData: o }) {
30
- const [a, c] = h(!1), i = d === "edit", [p, x] = h(o?.name || ""), [v, N] = h(o?.priority_order || 0), [m, b] = h(
31
- P(o?.locations)
32
- ), [_, g] = h(
33
- j(o?.locations)
34
- ), [y, S] = h(""), [$, L] = h(!1);
35
- O(() => {
36
- a && (x(o?.name || ""), N(o?.priority_order || 0), b(P(o?.locations)), g(j(o?.locations)), S(""));
37
- }, [o, a]);
38
- const B = z(() => {
39
- const e = y.trim().toLowerCase();
40
- return e ? k.filter(
41
- (t) => t.name.toLowerCase().includes(e) || t.code.toLowerCase().includes(e)
42
- ) : k;
43
- }, [y]), Z = z(() => k.filter((e) => m.includes(e.code)), [m]), I = (e) => {
44
- b(
45
- (t) => t.includes(e) ? t.filter((l) => l !== e) : [...t, e]
46
- ), g((t) => {
47
- if (t[e]) {
48
- const l = { ...t };
49
- return delete l[e], l;
50
- }
51
- return t;
52
- });
53
- }, M = (e, t) => {
54
- g((l) => {
55
- const n = new Set(l[e] || []);
56
- return n.has(t) ? n.delete(t) : n.add(t), {
57
- ...l,
58
- [e]: [...n]
59
- };
60
- });
61
- };
62
- return /* @__PURE__ */ s(T, { open: a, onOpenChange: c, children: [
63
- /* @__PURE__ */ r(U, { asChild: !0, children: i ? /* @__PURE__ */ r(u, { variant: "ghost", size: "icon", className: "h-8 w-8 text-slate-400 hover:text-primary", children: /* @__PURE__ */ r(G, { className: "h-4 w-4" }) }) : /* @__PURE__ */ s(u, { className: "gap-2 shadow-sm", children: [
64
- /* @__PURE__ */ r(J, { className: "h-4 w-4" }),
65
- "New Zone"
66
- ] }) }),
67
- /* @__PURE__ */ r(q, { className: "max-w-4xl max-h-[90vh] flex flex-col overflow-hidden", children: /* @__PURE__ */ s("form", { onSubmit: async (e) => {
68
- if (e.preventDefault(), !p || m.length === 0)
69
- return;
70
- L(!0);
71
- const t = D(m, _), l = i && o?.id ? await X(o.id, p, v, t) : await Y(p, v, t);
72
- L(!1), l.success ? (c(!1), i || (x(""), N(0), b([]), g({}), S(""))) : l.error && alert(l.error);
73
- }, className: "flex h-full flex-col overflow-hidden", children: [
74
- /* @__PURE__ */ s(Q, { children: [
75
- /* @__PURE__ */ r(W, { children: i ? "Edit Shipping Zone" : "Create Shipping Zone" }),
76
- /* @__PURE__ */ r(A, { children: "Select countries first, then optionally limit a zone to specific states or provinces. Leaving state selections empty keeps the whole country in the zone." })
77
- ] }),
78
- /* @__PURE__ */ s("div", { className: "grid gap-6 overflow-y-auto py-6 pr-2", children: [
79
- /* @__PURE__ */ s("div", { className: "grid grid-cols-4 items-center gap-4", children: [
80
- /* @__PURE__ */ r(f, { htmlFor: "name", className: "text-right", children: "Zone Name" }),
81
- /* @__PURE__ */ r(
82
- w,
83
- {
84
- id: "name",
85
- value: p,
86
- onChange: (e) => x(e.target.value),
87
- placeholder: "e.g. North America, Canada East, US West",
88
- className: "col-span-3",
89
- required: !0
90
- }
91
- )
92
- ] }),
93
- /* @__PURE__ */ s("div", { className: "grid grid-cols-4 items-center gap-4", children: [
94
- /* @__PURE__ */ r(f, { htmlFor: "priority", className: "text-right", children: "Priority Order" }),
95
- /* @__PURE__ */ r(
96
- w,
97
- {
98
- id: "priority",
99
- type: "number",
100
- value: v,
101
- onChange: (e) => N(Number(e.target.value)),
102
- className: "col-span-3"
103
- }
104
- )
105
- ] }),
106
- /* @__PURE__ */ s("div", { className: "grid gap-6 lg:grid-cols-[1.2fr_1fr]", children: [
107
- /* @__PURE__ */ s("div", { className: "space-y-4", children: [
108
- /* @__PURE__ */ s("div", { className: "flex items-end justify-between gap-3", children: [
109
- /* @__PURE__ */ s(f, { className: "text-sm font-semibold", children: [
110
- "Countries (",
111
- m.length,
112
- ")"
113
- ] }),
114
- /* @__PURE__ */ s("div", { className: "relative w-full max-w-xs", children: [
115
- /* @__PURE__ */ r(K, { className: "absolute left-2.5 top-2.5 h-4 w-4 text-slate-400" }),
116
- /* @__PURE__ */ r(
117
- w,
118
- {
119
- placeholder: "Search countries...",
120
- className: "pl-9 h-9",
121
- value: y,
122
- onChange: (e) => S(e.target.value)
123
- }
124
- )
125
- ] })
126
- ] }),
127
- /* @__PURE__ */ r(C, { className: "border-slate-200 bg-slate-50/30 p-4 dark:border-slate-800 dark:bg-slate-900/30", children: /* @__PURE__ */ r("div", { className: "grid max-h-[360px] grid-cols-1 gap-3 overflow-y-auto pr-1 sm:grid-cols-2", children: B.map((e) => {
128
- const t = m.includes(e.code);
129
- return /* @__PURE__ */ s(
130
- "div",
131
- {
132
- className: `flex items-center space-x-2 rounded-md border p-2 transition-colors ${t ? "border-primary/30 bg-primary/5 text-primary" : "border-transparent hover:bg-slate-100 dark:hover:bg-slate-800/60"}`,
133
- children: [
134
- /* @__PURE__ */ r(
135
- E,
136
- {
137
- id: `country-${e.code}`,
138
- checked: t,
139
- onCheckedChange: () => I(e.code)
140
- }
141
- ),
142
- /* @__PURE__ */ s(
143
- "label",
144
- {
145
- htmlFor: `country-${e.code}`,
146
- className: "flex-1 cursor-pointer text-xs py-1",
147
- children: [
148
- e.name,
149
- " (",
150
- e.code,
151
- ")"
152
- ]
153
- }
154
- )
155
- ]
156
- },
157
- e.code
158
- );
159
- }) }) })
160
- ] }),
161
- /* @__PURE__ */ s("div", { className: "space-y-4", children: [
162
- /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
163
- /* @__PURE__ */ r(R, { className: "h-4 w-4 text-slate-500" }),
164
- /* @__PURE__ */ r(f, { className: "text-sm font-semibold", children: "States / Provinces" })
165
- ] }),
166
- Z.length === 0 ? /* @__PURE__ */ r(C, { className: "border-dashed p-4 text-sm text-muted-foreground", children: "Select one or more countries to optionally narrow the zone to specific states or provinces." }) : /* @__PURE__ */ r("div", { className: "space-y-4", children: Z.map((e) => {
167
- const t = V(e.code), l = _[e.code] || [];
168
- return /* @__PURE__ */ r(C, { className: "p-4", children: /* @__PURE__ */ s("div", { className: "space-y-3", children: [
169
- /* @__PURE__ */ s("div", { className: "flex items-center justify-between gap-3", children: [
170
- /* @__PURE__ */ s("div", { children: [
171
- /* @__PURE__ */ s("p", { className: "font-medium", children: [
172
- e.name,
173
- " (",
174
- e.code,
175
- ")"
176
- ] }),
177
- /* @__PURE__ */ r("p", { className: "text-xs text-muted-foreground", children: t.length > 0 ? "Leave all unchecked to apply this zone to the whole country." : "This country uses a country-level zone in the current UI." })
178
- ] }),
179
- /* @__PURE__ */ r("span", { className: "text-xs text-muted-foreground", children: l.length > 0 ? `${l.length} selected` : "Whole country" })
180
- ] }),
181
- t.length > 0 ? /* @__PURE__ */ r("div", { className: "grid max-h-[220px] grid-cols-1 gap-2 overflow-y-auto pr-1 sm:grid-cols-2", children: t.map((n) => {
182
- const F = l.includes(n.code);
183
- return /* @__PURE__ */ s(
184
- "div",
185
- {
186
- className: `flex items-center space-x-2 rounded-md border p-2 transition-colors ${F ? "border-primary/30 bg-primary/5 text-primary" : "border-transparent hover:bg-slate-50 dark:hover:bg-slate-800/60"}`,
187
- children: [
188
- /* @__PURE__ */ r(
189
- E,
190
- {
191
- id: `${e.code}-${n.code}`,
192
- checked: F,
193
- onCheckedChange: () => M(e.code, n.code)
194
- }
195
- ),
196
- /* @__PURE__ */ s(
197
- "label",
198
- {
199
- htmlFor: `${e.code}-${n.code}`,
200
- className: "flex-1 cursor-pointer text-xs py-1",
201
- children: [
202
- n.name,
203
- " (",
204
- n.code,
205
- ")"
206
- ]
207
- }
208
- )
209
- ]
210
- },
211
- `${e.code}-${n.code}`
212
- );
213
- }) }) : null
214
- ] }) }, e.code);
215
- }) })
216
- ] })
217
- ] })
218
- ] }),
219
- /* @__PURE__ */ s(H, { className: "mt-auto border-t pt-4", children: [
220
- /* @__PURE__ */ r(u, { type: "button", variant: "ghost", onClick: () => c(!1), children: "Cancel" }),
221
- /* @__PURE__ */ r(u, { type: "submit", disabled: $ || !p || m.length === 0, children: $ ? i ? "Updating..." : "Creating..." : i ? "Save Changes" : "Create Zone" })
222
- ] })
223
- ] }) })
224
- ] });
32
+ function O({ mode: O = "create", initialData: k }) {
33
+ let [A, j] = o(!1), M = O === "edit", [N, P] = o(k?.name || ""), [F, I] = o(k?.priority_order || 0), [L, R] = o(T(k?.locations)), [z, B] = o(E(k?.locations)), [V, H] = o(""), [U, W] = o(!1);
34
+ i(() => {
35
+ A && (P(k?.name || ""), I(k?.priority_order || 0), R(T(k?.locations)), B(E(k?.locations)), H(""));
36
+ }, [k, A]);
37
+ let G = a(() => {
38
+ let t = V.trim().toLowerCase();
39
+ return t ? e.filter((e) => e.name.toLowerCase().includes(t) || e.code.toLowerCase().includes(t)) : e;
40
+ }, [V]), K = a(() => e.filter((e) => L.includes(e.code)), [L]), q = (e) => {
41
+ R((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]), B((t) => {
42
+ if (t[e]) {
43
+ let n = { ...t };
44
+ return delete n[e], n;
45
+ }
46
+ return t;
47
+ });
48
+ }, J = (e, t) => {
49
+ B((n) => {
50
+ let r = new Set(n[e] || []);
51
+ return r.has(t) ? r.delete(t) : r.add(t), {
52
+ ...n,
53
+ [e]: [...r]
54
+ };
55
+ });
56
+ };
57
+ return /* @__PURE__ */ f(g, {
58
+ open: A,
59
+ onOpenChange: j,
60
+ children: [/* @__PURE__ */ d(S, {
61
+ asChild: !0,
62
+ children: M ? /* @__PURE__ */ d(p, {
63
+ variant: "ghost",
64
+ size: "icon",
65
+ className: "h-8 w-8 text-slate-400 hover:text-primary",
66
+ children: /* @__PURE__ */ d(s, { className: "h-4 w-4" })
67
+ }) : /* @__PURE__ */ f(p, {
68
+ className: "gap-2 shadow-sm",
69
+ children: [/* @__PURE__ */ d(l, { className: "h-4 w-4" }), "New Zone"]
70
+ })
71
+ }), /* @__PURE__ */ d(_, {
72
+ className: "max-w-4xl max-h-[90vh] flex flex-col overflow-hidden",
73
+ children: /* @__PURE__ */ f("form", {
74
+ onSubmit: async (e) => {
75
+ if (e.preventDefault(), !N || L.length === 0) return;
76
+ W(!0);
77
+ let t = D(L, z), i = M && k?.id ? await r(k.id, N, F, t) : await n(N, F, t);
78
+ W(!1), i.success ? (j(!1), M || (P(""), I(0), R([]), B({}), H(""))) : i.error && alert(i.error);
79
+ },
80
+ className: "flex h-full flex-col overflow-hidden",
81
+ children: [
82
+ /* @__PURE__ */ f(b, { children: [/* @__PURE__ */ d(x, { children: M ? "Edit Shipping Zone" : "Create Shipping Zone" }), /* @__PURE__ */ d(v, { children: "Select countries first, then optionally limit a zone to specific states or provinces. Leaving state selections empty keeps the whole country in the zone." })] }),
83
+ /* @__PURE__ */ f("div", {
84
+ className: "grid gap-6 overflow-y-auto py-6 pr-2",
85
+ children: [
86
+ /* @__PURE__ */ f("div", {
87
+ className: "grid grid-cols-4 items-center gap-4",
88
+ children: [/* @__PURE__ */ d(w, {
89
+ htmlFor: "name",
90
+ className: "text-right",
91
+ children: "Zone Name"
92
+ }), /* @__PURE__ */ d(C, {
93
+ id: "name",
94
+ value: N,
95
+ onChange: (e) => P(e.target.value),
96
+ placeholder: "e.g. North America, Canada East, US West",
97
+ className: "col-span-3",
98
+ required: !0
99
+ })]
100
+ }),
101
+ /* @__PURE__ */ f("div", {
102
+ className: "grid grid-cols-4 items-center gap-4",
103
+ children: [/* @__PURE__ */ d(w, {
104
+ htmlFor: "priority",
105
+ className: "text-right",
106
+ children: "Priority Order"
107
+ }), /* @__PURE__ */ d(C, {
108
+ id: "priority",
109
+ type: "number",
110
+ value: F,
111
+ onChange: (e) => I(Number(e.target.value)),
112
+ className: "col-span-3"
113
+ })]
114
+ }),
115
+ /* @__PURE__ */ f("div", {
116
+ className: "grid gap-6 lg:grid-cols-[1.2fr_1fr]",
117
+ children: [/* @__PURE__ */ f("div", {
118
+ className: "space-y-4",
119
+ children: [/* @__PURE__ */ f("div", {
120
+ className: "flex items-end justify-between gap-3",
121
+ children: [/* @__PURE__ */ f(w, {
122
+ className: "text-sm font-semibold",
123
+ children: [
124
+ "Countries (",
125
+ L.length,
126
+ ")"
127
+ ]
128
+ }), /* @__PURE__ */ f("div", {
129
+ className: "relative w-full max-w-xs",
130
+ children: [/* @__PURE__ */ d(u, { className: "absolute left-2.5 top-2.5 h-4 w-4 text-slate-400" }), /* @__PURE__ */ d(C, {
131
+ placeholder: "Search countries...",
132
+ className: "pl-9 h-9",
133
+ value: V,
134
+ onChange: (e) => H(e.target.value)
135
+ })]
136
+ })]
137
+ }), /* @__PURE__ */ d(m, {
138
+ className: "border-slate-200 bg-slate-50/30 p-4 dark:border-slate-800 dark:bg-slate-900/30",
139
+ children: /* @__PURE__ */ d("div", {
140
+ className: "grid max-h-[360px] grid-cols-1 gap-3 overflow-y-auto pr-1 sm:grid-cols-2",
141
+ children: G.map((e) => {
142
+ let t = L.includes(e.code);
143
+ return /* @__PURE__ */ f("div", {
144
+ className: `flex items-center space-x-2 rounded-md border p-2 transition-colors ${t ? "border-primary/30 bg-primary/5 text-primary" : "border-transparent hover:bg-slate-100 dark:hover:bg-slate-800/60"}`,
145
+ children: [/* @__PURE__ */ d(h, {
146
+ id: `country-${e.code}`,
147
+ checked: t,
148
+ onCheckedChange: () => q(e.code)
149
+ }), /* @__PURE__ */ f("label", {
150
+ htmlFor: `country-${e.code}`,
151
+ className: "flex-1 cursor-pointer text-xs py-1",
152
+ children: [
153
+ e.name,
154
+ " (",
155
+ e.code,
156
+ ")"
157
+ ]
158
+ })]
159
+ }, e.code);
160
+ })
161
+ })
162
+ })]
163
+ }), /* @__PURE__ */ f("div", {
164
+ className: "space-y-4",
165
+ children: [/* @__PURE__ */ f("div", {
166
+ className: "flex items-center gap-2",
167
+ children: [/* @__PURE__ */ d(c, { className: "h-4 w-4 text-slate-500" }), /* @__PURE__ */ d(w, {
168
+ className: "text-sm font-semibold",
169
+ children: "States / Provinces"
170
+ })]
171
+ }), K.length === 0 ? /* @__PURE__ */ d(m, {
172
+ className: "border-dashed p-4 text-sm text-muted-foreground",
173
+ children: "Select one or more countries to optionally narrow the zone to specific states or provinces."
174
+ }) : /* @__PURE__ */ d("div", {
175
+ className: "space-y-4",
176
+ children: K.map((e) => {
177
+ let n = t(e.code), r = z[e.code] || [];
178
+ return /* @__PURE__ */ d(m, {
179
+ className: "p-4",
180
+ children: /* @__PURE__ */ f("div", {
181
+ className: "space-y-3",
182
+ children: [/* @__PURE__ */ f("div", {
183
+ className: "flex items-center justify-between gap-3",
184
+ children: [/* @__PURE__ */ f("div", { children: [/* @__PURE__ */ f("p", {
185
+ className: "font-medium",
186
+ children: [
187
+ e.name,
188
+ " (",
189
+ e.code,
190
+ ")"
191
+ ]
192
+ }), /* @__PURE__ */ d("p", {
193
+ className: "text-xs text-muted-foreground",
194
+ children: n.length > 0 ? "Leave all unchecked to apply this zone to the whole country." : "This country uses a country-level zone in the current UI."
195
+ })] }), /* @__PURE__ */ d("span", {
196
+ className: "text-xs text-muted-foreground",
197
+ children: r.length > 0 ? `${r.length} selected` : "Whole country"
198
+ })]
199
+ }), n.length > 0 ? /* @__PURE__ */ d("div", {
200
+ className: "grid max-h-[220px] grid-cols-1 gap-2 overflow-y-auto pr-1 sm:grid-cols-2",
201
+ children: n.map((t) => {
202
+ let n = r.includes(t.code);
203
+ return /* @__PURE__ */ f("div", {
204
+ className: `flex items-center space-x-2 rounded-md border p-2 transition-colors ${n ? "border-primary/30 bg-primary/5 text-primary" : "border-transparent hover:bg-slate-50 dark:hover:bg-slate-800/60"}`,
205
+ children: [/* @__PURE__ */ d(h, {
206
+ id: `${e.code}-${t.code}`,
207
+ checked: n,
208
+ onCheckedChange: () => J(e.code, t.code)
209
+ }), /* @__PURE__ */ f("label", {
210
+ htmlFor: `${e.code}-${t.code}`,
211
+ className: "flex-1 cursor-pointer text-xs py-1",
212
+ children: [
213
+ t.name,
214
+ " (",
215
+ t.code,
216
+ ")"
217
+ ]
218
+ })]
219
+ }, `${e.code}-${t.code}`);
220
+ })
221
+ }) : null]
222
+ })
223
+ }, e.code);
224
+ })
225
+ })]
226
+ })]
227
+ })
228
+ ]
229
+ }),
230
+ /* @__PURE__ */ f(y, {
231
+ className: "mt-auto border-t pt-4",
232
+ children: [/* @__PURE__ */ d(p, {
233
+ type: "button",
234
+ variant: "ghost",
235
+ onClick: () => j(!1),
236
+ children: "Cancel"
237
+ }), /* @__PURE__ */ d(p, {
238
+ type: "submit",
239
+ disabled: U || !N || L.length === 0,
240
+ children: U ? M ? "Updating..." : "Creating..." : M ? "Save Changes" : "Create Zone"
241
+ })]
242
+ })
243
+ ]
244
+ })
245
+ })]
246
+ });
225
247
  }
226
- export {
227
- ce as ZoneForm
228
- };
248
+ //#endregion
249
+ export { O as ZoneForm };
@@ -0,0 +1 @@
1
+ const e=require("./server-actions.cjs"),t=require("./ShippingPage.cjs");exports.ShippingPage=t.ShippingPage,exports.createShippingRate=e.createShippingRate,exports.createShippingZone=e.createShippingZone,exports.deleteShippingRate=e.deleteShippingRate,exports.deleteShippingZone=e.deleteShippingZone,exports.updateInventoryTrackingAction=e.updateInventoryTrackingAction,exports.updateShippingRate=e.updateShippingRate,exports.updateShippingZone=e.updateShippingZone;
@@ -0,0 +1,3 @@
1
+ import { createShippingRate as e, createShippingZone as t, deleteShippingRate as n, deleteShippingZone as r, updateInventoryTrackingAction as i, updateShippingRate as a, updateShippingZone as o } from "./server-actions.es.js";
2
+ import { ShippingPage as s } from "./ShippingPage.es.js";
3
+ export { s as ShippingPage, e as createShippingRate, t as createShippingZone, n as deleteShippingRate, r as deleteShippingZone, i as updateInventoryTrackingAction, a as updateShippingRate, o as updateShippingZone };
@@ -0,0 +1 @@
1
+ "use server";const e=require("../../../currency.cjs"),t=require("../../../countries.cjs"),n=require("../../../shipping-rate-currency.cjs"),r=require("../../../states.cjs"),i=require("../../../inventory-settings.cjs");let a=require("@nextblock-cms/db/server"),o=require("next/navigation"),s=require("next/cache");function c(e){return Object.entries(e||{}).reduce((e,[t,n])=>{let r=t.trim().toLowerCase(),i=n.trim();return r&&i&&(e[r]=i),e},{})}async function l(e){let t=(0,a.createClient)(),{data:{user:n}}=await t.auth.getUser();if(!n)throw Error(`Unauthorized`);let{data:r}=await t.from(`profiles`).select(`role`).eq(`id`,n.id).single();if(!r||r.role!==`ADMIN`)throw Error(`Forbidden`);let c=e.getAll(`trackQuantities`).includes(`true`),l=await i.getEcommerceInventorySettings(t),{error:u}=await i.upsertEcommerceInventorySettings(t,{trackQuantities:c,enableTaxes:l.enableTaxes,taxCalculationMode:l.taxCalculationMode});if(u)throw Error(u.message);(0,s.revalidatePath)(`/cms/shipping`),(0,o.redirect)(`/cms/shipping?success=Inventory settings updated`)}function u(e){let n=new Map;for(let i of e){let e=t.normalizeCountryCode(i.country_code);if(!e)continue;let a=r.normalizeSubdivisionCode(e,i.state_code)||null,o=`${e}:${a??`*`}`;n.set(o,{country_code:e,state_code:a})}return[...n.values()]}async function d(e){let{data:t,error:n}=await e.from(`currencies`).select(`code, is_default`).eq(`is_active`,!0).order(`is_default`,{ascending:!1}).order(`code`,{ascending:!0});return n?{error:n.message}:{currencies:t||[]}}async function f(e,t,n){let r=(0,a.getServiceRoleSupabaseClient)(),i=u(n),{data:o,error:c}=await r.from(`shipping_zones`).insert({name:e,priority_order:t}).select().single();if(c||!o)return{error:c?.message||`Failed to create zone`};if(i.length>0){let e=i.map(e=>({zone_id:o.id,country_code:e.country_code,state_code:e.state_code??null})),{error:t}=await r.from(`shipping_zone_locations`).insert(e);if(t)return{error:t.message}}return(0,s.revalidatePath)(`/cms/shipping`),{success:!0}}async function p(e,t,n,r){let i=(0,a.getServiceRoleSupabaseClient)(),o=u(r),{error:c}=await i.from(`shipping_zones`).update({name:t,priority_order:n,updated_at:new Date().toISOString()}).eq(`id`,e);if(c)return{error:c.message||`Failed to update zone`};let{error:l}=await i.from(`shipping_zone_locations`).delete().eq(`zone_id`,e);if(l)return{error:`Failed to refresh locations`};if(o.length>0){let t=o.map(t=>({zone_id:e,country_code:t.country_code,state_code:t.state_code??null})),{error:n}=await i.from(`shipping_zone_locations`).insert(t);if(n)return{error:n.message}}return(0,s.revalidatePath)(`/cms/shipping`),{success:!0}}async function m(e){let{error:t}=await(0,a.getServiceRoleSupabaseClient)().from(`shipping_zones`).delete().eq(`id`,e);return t?{error:t.message}:((0,s.revalidatePath)(`/cms/shipping`),{success:!0})}async function h(t,r){let i=(0,a.getServiceRoleSupabaseClient)(),o=await d(i);if(`error`in o)return{error:o.error};let l=n.sanitizeShippingRateAmountMaps({currencies:o.currencies.map(t=>e.normalizeCurrencyRecord(t)),mode:r.currencyPricingMode,sourceCurrencyCode:r.sourceCurrencyCode,costAmounts:r.costAmounts,minOrderAmounts:r.minOrderAmounts,fallbackCostAmount:r.cost,fallbackMinOrderAmount:r.minOrderAmount}),{error:u}=await i.from(`shipping_zone_methods`).insert({zone_id:t,name:r.name.trim(),name_translations:c(r.nameTranslations),method_type:r.type,currency_pricing_mode:l.mode,cost_amount:l.costAmounts[l.sourceCurrencyCode],cost_amounts:l.costAmounts,cost_currency:l.sourceCurrencyCode,min_order_amount:l.minOrderAmounts[l.sourceCurrencyCode],min_order_amounts:l.minOrderAmounts});return u?{error:u.message}:((0,s.revalidatePath)(`/cms/shipping`),{success:!0})}async function g(t,r){let i=(0,a.getServiceRoleSupabaseClient)(),o=await d(i);if(`error`in o)return{error:o.error};let l=n.sanitizeShippingRateAmountMaps({currencies:o.currencies.map(t=>e.normalizeCurrencyRecord(t)),mode:r.currencyPricingMode,sourceCurrencyCode:r.sourceCurrencyCode,costAmounts:r.costAmounts,minOrderAmounts:r.minOrderAmounts,fallbackCostAmount:r.cost,fallbackMinOrderAmount:r.minOrderAmount}),{error:u}=await i.from(`shipping_zone_methods`).update({name:r.name.trim(),name_translations:c(r.nameTranslations),method_type:r.type,currency_pricing_mode:l.mode,cost_amount:l.costAmounts[l.sourceCurrencyCode],cost_amounts:l.costAmounts,cost_currency:l.sourceCurrencyCode,min_order_amount:l.minOrderAmounts[l.sourceCurrencyCode],min_order_amounts:l.minOrderAmounts,updated_at:new Date().toISOString()}).eq(`id`,t);return u?{error:u.message}:((0,s.revalidatePath)(`/cms/shipping`),{success:!0})}async function _(e){let{error:t}=await(0,a.getServiceRoleSupabaseClient)().from(`shipping_zone_methods`).delete().eq(`id`,e);return t?{error:t.message}:((0,s.revalidatePath)(`/cms/shipping`),{success:!0})}exports.createShippingRate=h,exports.createShippingZone=f,exports.deleteShippingRate=_,exports.deleteShippingZone=m,exports.updateInventoryTrackingAction=l,exports.updateShippingRate=g,exports.updateShippingZone=p;