@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
+ const e=require("./ProductsPage.cjs"),t=require("./inventory/InventoryPage.cjs"),n=require("./attributes/AttributeManagementPage.cjs"),r=require("./new/NewProductPage.cjs"),i=require("./[id]/edit/EditProductPage.cjs"),a=require("./components/CopyProductFromLanguage.cjs"),o=require("./categories/CategoryManagementPage.cjs");exports.AttributeManagementPage=n.AttributeManagementPage,exports.CategoryManagementPage=o.CategoryManagementPage,exports.CopyProductFromLanguage=a.CopyProductFromLanguage,exports.EditProductPage=i.EditProductPage,exports.InventoryPage=t.InventoryPage,exports.NewProductPage=r.NewProductPage,exports.ProductsPage=e.ProductsPage;
@@ -0,0 +1,8 @@
1
+ import { ProductsPage as e } from "./ProductsPage.es.js";
2
+ import { InventoryPage as t } from "./inventory/InventoryPage.es.js";
3
+ import { AttributeManagementPage as n } from "./attributes/AttributeManagementPage.es.js";
4
+ import { NewProductPage as r } from "./new/NewProductPage.es.js";
5
+ import { EditProductPage as i } from "./[id]/edit/EditProductPage.es.js";
6
+ import { CopyProductFromLanguage as a } from "./components/CopyProductFromLanguage.es.js";
7
+ import { CategoryManagementPage as o } from "./categories/CategoryManagementPage.es.js";
8
+ export { n as AttributeManagementPage, o as CategoryManagementPage, a as CopyProductFromLanguage, i as EditProductPage, t as InventoryPage, r as NewProductPage, e as ProductsPage };
@@ -0,0 +1 @@
1
+ const e=require("../../../../shared-inventory.cjs"),t=require("./InventoryTableClient.cjs");let n=require("react/jsx-runtime");async function r(){let r=await e.getInventoryItems();return(0,n.jsxs)(`div`,{className:`p-8 space-y-6`,children:[(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(`h1`,{className:`text-3xl font-bold`,children:`Inventory`}),(0,n.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:`Manage source-of-truth stock for every sellable SKU in one place. Matching SKUs share the same quantity across products, translations, and variants, and you can update those shared quantities inline or in bulk through CSV import and export.`})]}),(0,n.jsx)(t.InventoryTableClient,{initialItems:r})]})}exports.InventoryPage=r;
@@ -1 +1 @@
1
- export declare function InventoryPage(): Promise<import("react").JSX.Element>;
1
+ export declare function InventoryPage(): Promise<import('react').JSX.Element>;
@@ -1,16 +1,22 @@
1
- import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
- import { getInventoryItems as a } from "../../../../shared-inventory.es.js";
3
- import { InventoryTableClient as r } from "./InventoryTableClient.es.js";
4
- async function l() {
5
- const n = await a();
6
- return /* @__PURE__ */ t("div", { className: "p-8 space-y-6", children: [
7
- /* @__PURE__ */ t("div", { className: "space-y-2", children: [
8
- /* @__PURE__ */ e("h1", { className: "text-3xl font-bold", children: "Inventory" }),
9
- /* @__PURE__ */ e("p", { className: "max-w-3xl text-sm text-muted-foreground", children: "Manage source-of-truth stock for every sellable SKU in one place. Matching SKUs share the same quantity across products, translations, and variants, and you can update those shared quantities inline or in bulk through CSV import and export." })
10
- ] }),
11
- /* @__PURE__ */ e(r, { initialItems: n })
12
- ] });
1
+ import { getInventoryItems as e } from "../../../../shared-inventory.es.js";
2
+ import { InventoryTableClient as t } from "./InventoryTableClient.es.js";
3
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
+ //#region src/lib/pages/cms/products/inventory/InventoryPage.tsx
5
+ async function i() {
6
+ let i = await e();
7
+ return /* @__PURE__ */ r("div", {
8
+ className: "p-8 space-y-6",
9
+ children: [/* @__PURE__ */ r("div", {
10
+ className: "space-y-2",
11
+ children: [/* @__PURE__ */ n("h1", {
12
+ className: "text-3xl font-bold",
13
+ children: "Inventory"
14
+ }), /* @__PURE__ */ n("p", {
15
+ className: "max-w-3xl text-sm text-muted-foreground",
16
+ children: "Manage source-of-truth stock for every sellable SKU in one place. Matching SKUs share the same quantity across products, translations, and variants, and you can update those shared quantities inline or in bulk through CSV import and export."
17
+ })]
18
+ }), /* @__PURE__ */ n(t, { initialItems: i })]
19
+ });
13
20
  }
14
- export {
15
- l as InventoryPage
16
- };
21
+ //#endregion
22
+ export { i as InventoryPage };
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("./actions.cjs");let t=require("react"),n=require("lucide-react"),r=require("react/jsx-runtime"),i=require("sonner"),a=require("@nextblock-cms/ui");function o(e){let t=String(e??``);return/[",\n]/.test(t)?`"${t.replace(/"/g,`""`)}"`:t}function s(e){return[[`sku`,`stock`,`usage_type`,`product_titles`,`languages`,`statuses`,`parent_product_skus`],...e.map(e=>[e.sku,e.stock,e.usageType,e.productTitles.join(`|`),e.languages.join(`|`),e.statuses.join(`|`),e.parentProductSkus.join(`|`)])].map(e=>e.map(e=>o(e)).join(`,`)).join(`
2
+ `)}function c(e){return e.usageType===`mixed`?`Shared SKU`:e.usageType===`variant`?`Variant SKU ${e.sku}`:`Simple Product`}function l(e){return e.usageType===`variant`?`secondary`:`outline`}function u({initialItems:o}){let[u,d]=(0,t.useState)(o),[f,p]=(0,t.useState)(()=>o.reduce((e,t)=>(e[t.key]=String(t.stock),e),{})),[m,h]=(0,t.useState)(``),[g,_]=(0,t.useTransition)(),[v,y]=(0,t.useState)(null),b=(0,t.useRef)(null),x=(0,t.useMemo)(()=>{let e=m.trim().toLowerCase();return e?u.filter(t=>t.sku.toLowerCase().includes(e)||t.productTitles.join(` `).toLowerCase().includes(e)||t.parentProductSkus.join(` `).toLowerCase().includes(e)||t.languages.join(` `).toLowerCase().includes(e)):u},[u,m]),S=()=>{let e=s(u),t=new Blob([e],{type:`text/csv;charset=utf-8;`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`inventory-export.csv`,r.click(),URL.revokeObjectURL(n)},C=t=>{let n=f[t.key]??String(t.stock),r=Number.parseInt(n,10);if(!Number.isFinite(r)||r<0){i.toast.error(`Stock must be a non-negative whole number.`);return}y(t.key),_(async()=>{let n=await e.updateInventoryQuantityAction({sku:t.sku,stock:r});if(!n.success){i.toast.error(n.error||`Failed to update inventory.`),y(null);return}let a=typeof n.stock==`number`?n.stock:r;d(e=>e.map(e=>e.key===t.key?{...e,stock:a}:e)),p(e=>({...e,[t.key]:String(a)})),y(null),i.toast.success(`Inventory updated for ${t.sku}.`)})},w=()=>{b.current?.click()},T=async t=>{let n=await t.text();y(`import`),_(async()=>{let t=await e.importInventoryCsvAction(n);if(!t.success){i.toast.error(t.error||`Failed to import inventory CSV.`),y(null);return}let r=t.items||[];d(r),p(r.reduce((e,t)=>(e[t.key]=String(t.stock),e),{})),y(null),i.toast.success(`Imported ${t.updatedCount||0} inventory updates.`)})};return(0,r.jsxs)(`div`,{className:`space-y-4`,children:[(0,r.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border bg-card p-4`,children:[(0,r.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,r.jsxs)(`div`,{className:`relative w-full lg:max-w-md`,children:[(0,r.jsx)(n.Search,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,r.jsx)(a.Input,{value:m,onChange:e=>h(e.target.value),placeholder:`Search by SKU, product title, parent SKU, or language...`,className:`pl-9`})]}),(0,r.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,r.jsx)(`input`,{ref:b,type:`file`,accept:`.csv,text/csv`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&T(t),e.currentTarget.value=``}}),(0,r.jsxs)(a.Button,{type:`button`,variant:`outline`,onClick:w,disabled:g,children:[(0,r.jsx)(n.Upload,{className:`mr-2 h-4 w-4`}),`Import CSV`]}),(0,r.jsxs)(a.Button,{type:`button`,variant:`outline`,onClick:S,disabled:g,children:[(0,r.jsx)(n.Download,{className:`mr-2 h-4 w-4`}),`Export CSV`]})]})]}),(0,r.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Inventory is keyed by sellable SKU. Any product or variant using the same SKU shares the same quantity, and CSV imports can update those shared SKU quantities in bulk.`})]}),(0,r.jsx)(`div`,{className:`rounded-xl border bg-card`,children:(0,r.jsxs)(a.Table,{children:[(0,r.jsx)(a.TableHeader,{children:(0,r.jsxs)(a.TableRow,{children:[(0,r.jsx)(a.TableHead,{children:`SKU`}),(0,r.jsx)(a.TableHead,{children:`Usage`}),(0,r.jsx)(a.TableHead,{children:`Linked Products`}),(0,r.jsx)(a.TableHead,{children:`Languages`}),(0,r.jsx)(a.TableHead,{children:`Status`}),(0,r.jsx)(a.TableHead,{className:`w-[160px]`,children:`Quantity`}),(0,r.jsx)(a.TableHead,{className:`text-right`,children:`Actions`})]})}),(0,r.jsx)(a.TableBody,{children:x.length>0?x.map(e=>{let t=f[e.key]??String(e.stock),i=Number.parseInt(t,10),o=Number.isFinite(i)&&i!==e.stock,s=v===e.key;return(0,r.jsxs)(a.TableRow,{children:[(0,r.jsx)(a.TableCell,{className:`font-mono text-sm`,children:e.sku}),(0,r.jsx)(a.TableCell,{children:(0,r.jsx)(a.Badge,{variant:l(e),children:c(e)})}),(0,r.jsx)(a.TableCell,{children:(0,r.jsxs)(`div`,{className:`space-y-1`,children:[(0,r.jsx)(`p`,{className:`font-medium`,children:e.productTitles.join(`, `)}),e.usageType===`product`?null:(0,r.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Parent SKU`,e.parentProductSkus.length>1?`s`:``,`:`,` `,(0,r.jsx)(`span`,{className:`font-mono`,children:e.parentProductSkus.join(`, `)})]})]})}),(0,r.jsx)(a.TableCell,{children:(0,r.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.languages.map(t=>(0,r.jsx)(a.Badge,{variant:`outline`,children:t},`${e.key}:${t}`))})}),(0,r.jsx)(a.TableCell,{children:(0,r.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.statuses.map(t=>(0,r.jsx)(a.Badge,{variant:`outline`,children:t},`${e.key}:${t}`))})}),(0,r.jsx)(a.TableCell,{children:(0,r.jsx)(a.Input,{type:`number`,min:0,step:1,value:t,disabled:g,onChange:t=>p(n=>({...n,[e.key]:t.target.value})),className:`w-28`})}),(0,r.jsx)(a.TableCell,{className:`text-right`,children:(0,r.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,r.jsxs)(a.Button,{type:`button`,size:`sm`,variant:`ghost`,disabled:!o||g,onClick:()=>p(t=>({...t,[e.key]:String(e.stock)})),children:[(0,r.jsx)(n.RotateCcw,{className:`mr-2 h-4 w-4`}),`Reset`]}),(0,r.jsxs)(a.Button,{type:`button`,size:`sm`,disabled:!o||g,onClick:()=>C(e),children:[(0,r.jsx)(n.Save,{className:`mr-2 h-4 w-4`}),s?`Saving...`:`Save`]})]})})]},e.key)}):(0,r.jsx)(a.TableRow,{children:(0,r.jsx)(a.TableCell,{colSpan:7,className:`py-10 text-center text-muted-foreground`,children:`No inventory rows matched your search.`})})})]})})]})}exports.InventoryTableClient=u;
@@ -2,5 +2,5 @@ import { InventoryItem } from '../../../../shared-inventory';
2
2
  interface InventoryTableClientProps {
3
3
  initialItems: InventoryItem[];
4
4
  }
5
- export declare function InventoryTableClient({ initialItems }: InventoryTableClientProps): import("react").JSX.Element;
5
+ export declare function InventoryTableClient({ initialItems }: InventoryTableClientProps): import('react').JSX.Element;
6
6
  export {};
@@ -1,214 +1,235 @@
1
- 'use client';
2
- import { jsxs as a, jsx as t } from "react/jsx-runtime";
3
- import { useState as v, useTransition as V, useRef as $, useMemo as B } from "react";
4
- import { Input as j, Button as b, Table as D, TableHeader as F, TableRow as x, TableHead as p, TableBody as z, TableCell as u, Badge as w } from "@nextblock-cms/ui";
5
- import { Search as A, Upload as _, Download as q, RotateCcw as E, Save as H } from "lucide-react";
6
- import { toast as m } from "sonner";
7
- import { importInventoryCsvAction as O, updateInventoryQuantityAction as Q } from "./actions.es.js";
8
- function M(c) {
9
- const i = String(c ?? "");
10
- return /[",\n]/.test(i) ? `"${i.replace(/"/g, '""')}"` : i;
1
+ "use client";
2
+ import { importInventoryCsvAction as e, updateInventoryQuantityAction as t } from "./actions.es.js";
3
+ import { useMemo as n, useRef as r, useState as i, useTransition as a } from "react";
4
+ import { Download as o, RotateCcw as s, Save as c, Search as l, Upload as u } from "lucide-react";
5
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
6
+ import { toast as p } from "sonner";
7
+ import { Badge as m, Button as h, Input as g, Table as _, TableBody as v, TableCell as y, TableHead as b, TableHeader as x, TableRow as S } from "@nextblock-cms/ui";
8
+ //#region src/lib/pages/cms/products/inventory/InventoryTableClient.tsx
9
+ function C(e) {
10
+ let t = String(e ?? "");
11
+ return /[",\n]/.test(t) ? `"${t.replace(/"/g, "\"\"")}"` : t;
11
12
  }
12
- function G(c) {
13
- const i = [
14
- "sku",
15
- "stock",
16
- "usage_type",
17
- "product_titles",
18
- "languages",
19
- "statuses",
20
- "parent_product_skus"
21
- ], k = c.map((l) => [
22
- l.sku,
23
- l.stock,
24
- l.usageType,
25
- l.productTitles.join("|"),
26
- l.languages.join("|"),
27
- l.statuses.join("|"),
28
- l.parentProductSkus.join("|")
29
- ]);
30
- return [i, ...k].map((l) => l.map((h) => M(h)).join(",")).join(`
31
- `);
13
+ function w(e) {
14
+ return [[
15
+ "sku",
16
+ "stock",
17
+ "usage_type",
18
+ "product_titles",
19
+ "languages",
20
+ "statuses",
21
+ "parent_product_skus"
22
+ ], ...e.map((e) => [
23
+ e.sku,
24
+ e.stock,
25
+ e.usageType,
26
+ e.productTitles.join("|"),
27
+ e.languages.join("|"),
28
+ e.statuses.join("|"),
29
+ e.parentProductSkus.join("|")
30
+ ])].map((e) => e.map((e) => C(e)).join(",")).join("\n");
32
31
  }
33
- function J(c) {
34
- return c.usageType === "mixed" ? "Shared SKU" : c.usageType === "variant" ? `Variant SKU ${c.sku}` : "Simple Product";
32
+ function T(e) {
33
+ return e.usageType === "mixed" ? "Shared SKU" : e.usageType === "variant" ? `Variant SKU ${e.sku}` : "Simple Product";
35
34
  }
36
- function W(c) {
37
- return c.usageType === "variant" ? "secondary" : "outline";
35
+ function E(e) {
36
+ return e.usageType === "variant" ? "secondary" : "outline";
38
37
  }
39
- function re({ initialItems: c }) {
40
- const [i, k] = v(c), [l, h] = v(
41
- () => c.reduce((e, n) => (e[n.key] = String(n.stock), e), {})
42
- ), [S, I] = v(""), [y, N] = V(), [U, g] = v(null), C = $(null), T = B(() => {
43
- const e = S.trim().toLowerCase();
44
- return e ? i.filter((n) => n.sku.toLowerCase().includes(e) || n.productTitles.join(" ").toLowerCase().includes(e) || n.parentProductSkus.join(" ").toLowerCase().includes(e) || n.languages.join(" ").toLowerCase().includes(e)) : i;
45
- }, [i, S]), K = () => {
46
- const e = G(i), n = new Blob([e], { type: "text/csv;charset=utf-8;" }), s = URL.createObjectURL(n), o = document.createElement("a");
47
- o.href = s, o.download = "inventory-export.csv", o.click(), URL.revokeObjectURL(s);
48
- }, L = (e) => {
49
- const n = l[e.key] ?? String(e.stock), s = Number.parseInt(n, 10);
50
- if (!Number.isFinite(s) || s < 0) {
51
- m.error("Stock must be a non-negative whole number.");
52
- return;
53
- }
54
- g(e.key), N(async () => {
55
- const o = await Q({
56
- sku: e.sku,
57
- stock: s
58
- });
59
- if (!o.success) {
60
- m.error(o.error || "Failed to update inventory."), g(null);
61
- return;
62
- }
63
- const d = typeof o.stock == "number" ? o.stock : s;
64
- k(
65
- (r) => r.map(
66
- (f) => f.key === e.key ? {
67
- ...f,
68
- stock: d
69
- } : f
70
- )
71
- ), h((r) => ({
72
- ...r,
73
- [e.key]: String(d)
74
- })), g(null), m.success(`Inventory updated for ${e.sku}.`);
75
- });
76
- }, P = () => {
77
- C.current?.click();
78
- }, R = async (e) => {
79
- const n = await e.text();
80
- g("import"), N(async () => {
81
- const s = await O(n);
82
- if (!s.success) {
83
- m.error(s.error || "Failed to import inventory CSV."), g(null);
84
- return;
85
- }
86
- const o = s.items || [];
87
- k(o), h(
88
- o.reduce((d, r) => (d[r.key] = String(r.stock), d), {})
89
- ), g(null), m.success(`Imported ${s.updatedCount || 0} inventory updates.`);
90
- });
91
- };
92
- return /* @__PURE__ */ a("div", { className: "space-y-4", children: [
93
- /* @__PURE__ */ a("div", { className: "flex flex-col gap-3 rounded-xl border bg-card p-4", children: [
94
- /* @__PURE__ */ a("div", { className: "flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between", children: [
95
- /* @__PURE__ */ a("div", { className: "relative w-full lg:max-w-md", children: [
96
- /* @__PURE__ */ t(A, { className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
97
- /* @__PURE__ */ t(
98
- j,
99
- {
100
- value: S,
101
- onChange: (e) => I(e.target.value),
102
- placeholder: "Search by SKU, product title, parent SKU, or language...",
103
- className: "pl-9"
104
- }
105
- )
106
- ] }),
107
- /* @__PURE__ */ a("div", { className: "flex flex-wrap gap-2", children: [
108
- /* @__PURE__ */ t(
109
- "input",
110
- {
111
- ref: C,
112
- type: "file",
113
- accept: ".csv,text/csv",
114
- className: "hidden",
115
- onChange: (e) => {
116
- const n = e.target.files?.[0];
117
- n && R(n), e.currentTarget.value = "";
118
- }
119
- }
120
- ),
121
- /* @__PURE__ */ a(b, { type: "button", variant: "outline", onClick: P, disabled: y, children: [
122
- /* @__PURE__ */ t(_, { className: "mr-2 h-4 w-4" }),
123
- "Import CSV"
124
- ] }),
125
- /* @__PURE__ */ a(b, { type: "button", variant: "outline", onClick: K, disabled: y, children: [
126
- /* @__PURE__ */ t(q, { className: "mr-2 h-4 w-4" }),
127
- "Export CSV"
128
- ] })
129
- ] })
130
- ] }),
131
- /* @__PURE__ */ t("p", { className: "text-sm text-muted-foreground", children: "Inventory is keyed by sellable SKU. Any product or variant using the same SKU shares the same quantity, and CSV imports can update those shared SKU quantities in bulk." })
132
- ] }),
133
- /* @__PURE__ */ t("div", { className: "rounded-xl border bg-card", children: /* @__PURE__ */ a(D, { children: [
134
- /* @__PURE__ */ t(F, { children: /* @__PURE__ */ a(x, { children: [
135
- /* @__PURE__ */ t(p, { children: "SKU" }),
136
- /* @__PURE__ */ t(p, { children: "Usage" }),
137
- /* @__PURE__ */ t(p, { children: "Linked Products" }),
138
- /* @__PURE__ */ t(p, { children: "Languages" }),
139
- /* @__PURE__ */ t(p, { children: "Status" }),
140
- /* @__PURE__ */ t(p, { className: "w-[160px]", children: "Quantity" }),
141
- /* @__PURE__ */ t(p, { className: "text-right", children: "Actions" })
142
- ] }) }),
143
- /* @__PURE__ */ t(z, { children: T.length > 0 ? T.map((e) => {
144
- const n = l[e.key] ?? String(e.stock), s = Number.parseInt(n, 10), o = Number.isFinite(s) && s !== e.stock, d = U === e.key;
145
- return /* @__PURE__ */ a(x, { children: [
146
- /* @__PURE__ */ t(u, { className: "font-mono text-sm", children: e.sku }),
147
- /* @__PURE__ */ t(u, { children: /* @__PURE__ */ t(w, { variant: W(e), children: J(e) }) }),
148
- /* @__PURE__ */ t(u, { children: /* @__PURE__ */ a("div", { className: "space-y-1", children: [
149
- /* @__PURE__ */ t("p", { className: "font-medium", children: e.productTitles.join(", ") }),
150
- e.usageType !== "product" ? /* @__PURE__ */ a("p", { className: "text-xs text-muted-foreground", children: [
151
- "Parent SKU",
152
- e.parentProductSkus.length > 1 ? "s" : "",
153
- ":",
154
- " ",
155
- /* @__PURE__ */ t("span", { className: "font-mono", children: e.parentProductSkus.join(", ") })
156
- ] }) : null
157
- ] }) }),
158
- /* @__PURE__ */ t(u, { children: /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: e.languages.map((r) => /* @__PURE__ */ t(w, { variant: "outline", children: r }, `${e.key}:${r}`)) }) }),
159
- /* @__PURE__ */ t(u, { children: /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: e.statuses.map((r) => /* @__PURE__ */ t(w, { variant: "outline", children: r }, `${e.key}:${r}`)) }) }),
160
- /* @__PURE__ */ t(u, { children: /* @__PURE__ */ t(
161
- j,
162
- {
163
- type: "number",
164
- min: 0,
165
- step: 1,
166
- value: n,
167
- disabled: y,
168
- onChange: (r) => h((f) => ({
169
- ...f,
170
- [e.key]: r.target.value
171
- })),
172
- className: "w-28"
173
- }
174
- ) }),
175
- /* @__PURE__ */ t(u, { className: "text-right", children: /* @__PURE__ */ a("div", { className: "flex justify-end gap-2", children: [
176
- /* @__PURE__ */ a(
177
- b,
178
- {
179
- type: "button",
180
- size: "sm",
181
- variant: "ghost",
182
- disabled: !o || y,
183
- onClick: () => h((r) => ({
184
- ...r,
185
- [e.key]: String(e.stock)
186
- })),
187
- children: [
188
- /* @__PURE__ */ t(E, { className: "mr-2 h-4 w-4" }),
189
- "Reset"
190
- ]
191
- }
192
- ),
193
- /* @__PURE__ */ a(
194
- b,
195
- {
196
- type: "button",
197
- size: "sm",
198
- disabled: !o || y,
199
- onClick: () => L(e),
200
- children: [
201
- /* @__PURE__ */ t(H, { className: "mr-2 h-4 w-4" }),
202
- d ? "Saving..." : "Save"
203
- ]
204
- }
205
- )
206
- ] }) })
207
- ] }, e.key);
208
- }) : /* @__PURE__ */ t(x, { children: /* @__PURE__ */ t(u, { colSpan: 7, className: "py-10 text-center text-muted-foreground", children: "No inventory rows matched your search." }) }) })
209
- ] }) })
210
- ] });
38
+ function D({ initialItems: C }) {
39
+ let [D, O] = i(C), [k, A] = i(() => C.reduce((e, t) => (e[t.key] = String(t.stock), e), {})), [j, M] = i(""), [N, P] = a(), [F, I] = i(null), L = r(null), R = n(() => {
40
+ let e = j.trim().toLowerCase();
41
+ return e ? D.filter((t) => t.sku.toLowerCase().includes(e) || t.productTitles.join(" ").toLowerCase().includes(e) || t.parentProductSkus.join(" ").toLowerCase().includes(e) || t.languages.join(" ").toLowerCase().includes(e)) : D;
42
+ }, [D, j]), z = () => {
43
+ let e = w(D), t = new Blob([e], { type: "text/csv;charset=utf-8;" }), n = URL.createObjectURL(t), r = document.createElement("a");
44
+ r.href = n, r.download = "inventory-export.csv", r.click(), URL.revokeObjectURL(n);
45
+ }, B = (e) => {
46
+ let n = k[e.key] ?? String(e.stock), r = Number.parseInt(n, 10);
47
+ if (!Number.isFinite(r) || r < 0) {
48
+ p.error("Stock must be a non-negative whole number.");
49
+ return;
50
+ }
51
+ I(e.key), P(async () => {
52
+ let n = await t({
53
+ sku: e.sku,
54
+ stock: r
55
+ });
56
+ if (!n.success) {
57
+ p.error(n.error || "Failed to update inventory."), I(null);
58
+ return;
59
+ }
60
+ let i = typeof n.stock == "number" ? n.stock : r;
61
+ O((t) => t.map((t) => t.key === e.key ? {
62
+ ...t,
63
+ stock: i
64
+ } : t)), A((t) => ({
65
+ ...t,
66
+ [e.key]: String(i)
67
+ })), I(null), p.success(`Inventory updated for ${e.sku}.`);
68
+ });
69
+ }, V = () => {
70
+ L.current?.click();
71
+ }, H = async (t) => {
72
+ let n = await t.text();
73
+ I("import"), P(async () => {
74
+ let t = await e(n);
75
+ if (!t.success) {
76
+ p.error(t.error || "Failed to import inventory CSV."), I(null);
77
+ return;
78
+ }
79
+ let r = t.items || [];
80
+ O(r), A(r.reduce((e, t) => (e[t.key] = String(t.stock), e), {})), I(null), p.success(`Imported ${t.updatedCount || 0} inventory updates.`);
81
+ });
82
+ };
83
+ return /* @__PURE__ */ f("div", {
84
+ className: "space-y-4",
85
+ children: [/* @__PURE__ */ f("div", {
86
+ className: "flex flex-col gap-3 rounded-xl border bg-card p-4",
87
+ children: [/* @__PURE__ */ f("div", {
88
+ className: "flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",
89
+ children: [/* @__PURE__ */ f("div", {
90
+ className: "relative w-full lg:max-w-md",
91
+ children: [/* @__PURE__ */ d(l, { className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }), /* @__PURE__ */ d(g, {
92
+ value: j,
93
+ onChange: (e) => M(e.target.value),
94
+ placeholder: "Search by SKU, product title, parent SKU, or language...",
95
+ className: "pl-9"
96
+ })]
97
+ }), /* @__PURE__ */ f("div", {
98
+ className: "flex flex-wrap gap-2",
99
+ children: [
100
+ /* @__PURE__ */ d("input", {
101
+ ref: L,
102
+ type: "file",
103
+ accept: ".csv,text/csv",
104
+ className: "hidden",
105
+ onChange: (e) => {
106
+ let t = e.target.files?.[0];
107
+ t && H(t), e.currentTarget.value = "";
108
+ }
109
+ }),
110
+ /* @__PURE__ */ f(h, {
111
+ type: "button",
112
+ variant: "outline",
113
+ onClick: V,
114
+ disabled: N,
115
+ children: [/* @__PURE__ */ d(u, { className: "mr-2 h-4 w-4" }), "Import CSV"]
116
+ }),
117
+ /* @__PURE__ */ f(h, {
118
+ type: "button",
119
+ variant: "outline",
120
+ onClick: z,
121
+ disabled: N,
122
+ children: [/* @__PURE__ */ d(o, { className: "mr-2 h-4 w-4" }), "Export CSV"]
123
+ })
124
+ ]
125
+ })]
126
+ }), /* @__PURE__ */ d("p", {
127
+ className: "text-sm text-muted-foreground",
128
+ children: "Inventory is keyed by sellable SKU. Any product or variant using the same SKU shares the same quantity, and CSV imports can update those shared SKU quantities in bulk."
129
+ })]
130
+ }), /* @__PURE__ */ d("div", {
131
+ className: "rounded-xl border bg-card",
132
+ children: /* @__PURE__ */ f(_, { children: [/* @__PURE__ */ d(x, { children: /* @__PURE__ */ f(S, { children: [
133
+ /* @__PURE__ */ d(b, { children: "SKU" }),
134
+ /* @__PURE__ */ d(b, { children: "Usage" }),
135
+ /* @__PURE__ */ d(b, { children: "Linked Products" }),
136
+ /* @__PURE__ */ d(b, { children: "Languages" }),
137
+ /* @__PURE__ */ d(b, { children: "Status" }),
138
+ /* @__PURE__ */ d(b, {
139
+ className: "w-[160px]",
140
+ children: "Quantity"
141
+ }),
142
+ /* @__PURE__ */ d(b, {
143
+ className: "text-right",
144
+ children: "Actions"
145
+ })
146
+ ] }) }), /* @__PURE__ */ d(v, { children: R.length > 0 ? R.map((e) => {
147
+ let t = k[e.key] ?? String(e.stock), n = Number.parseInt(t, 10), r = Number.isFinite(n) && n !== e.stock, i = F === e.key;
148
+ return /* @__PURE__ */ f(S, { children: [
149
+ /* @__PURE__ */ d(y, {
150
+ className: "font-mono text-sm",
151
+ children: e.sku
152
+ }),
153
+ /* @__PURE__ */ d(y, { children: /* @__PURE__ */ d(m, {
154
+ variant: E(e),
155
+ children: T(e)
156
+ }) }),
157
+ /* @__PURE__ */ d(y, { children: /* @__PURE__ */ f("div", {
158
+ className: "space-y-1",
159
+ children: [/* @__PURE__ */ d("p", {
160
+ className: "font-medium",
161
+ children: e.productTitles.join(", ")
162
+ }), e.usageType === "product" ? null : /* @__PURE__ */ f("p", {
163
+ className: "text-xs text-muted-foreground",
164
+ children: [
165
+ "Parent SKU",
166
+ e.parentProductSkus.length > 1 ? "s" : "",
167
+ ":",
168
+ " ",
169
+ /* @__PURE__ */ d("span", {
170
+ className: "font-mono",
171
+ children: e.parentProductSkus.join(", ")
172
+ })
173
+ ]
174
+ })]
175
+ }) }),
176
+ /* @__PURE__ */ d(y, { children: /* @__PURE__ */ d("div", {
177
+ className: "flex flex-wrap gap-1",
178
+ children: e.languages.map((t) => /* @__PURE__ */ d(m, {
179
+ variant: "outline",
180
+ children: t
181
+ }, `${e.key}:${t}`))
182
+ }) }),
183
+ /* @__PURE__ */ d(y, { children: /* @__PURE__ */ d("div", {
184
+ className: "flex flex-wrap gap-1",
185
+ children: e.statuses.map((t) => /* @__PURE__ */ d(m, {
186
+ variant: "outline",
187
+ children: t
188
+ }, `${e.key}:${t}`))
189
+ }) }),
190
+ /* @__PURE__ */ d(y, { children: /* @__PURE__ */ d(g, {
191
+ type: "number",
192
+ min: 0,
193
+ step: 1,
194
+ value: t,
195
+ disabled: N,
196
+ onChange: (t) => A((n) => ({
197
+ ...n,
198
+ [e.key]: t.target.value
199
+ })),
200
+ className: "w-28"
201
+ }) }),
202
+ /* @__PURE__ */ d(y, {
203
+ className: "text-right",
204
+ children: /* @__PURE__ */ f("div", {
205
+ className: "flex justify-end gap-2",
206
+ children: [/* @__PURE__ */ f(h, {
207
+ type: "button",
208
+ size: "sm",
209
+ variant: "ghost",
210
+ disabled: !r || N,
211
+ onClick: () => A((t) => ({
212
+ ...t,
213
+ [e.key]: String(e.stock)
214
+ })),
215
+ children: [/* @__PURE__ */ d(s, { className: "mr-2 h-4 w-4" }), "Reset"]
216
+ }), /* @__PURE__ */ f(h, {
217
+ type: "button",
218
+ size: "sm",
219
+ disabled: !r || N,
220
+ onClick: () => B(e),
221
+ children: [/* @__PURE__ */ d(c, { className: "mr-2 h-4 w-4" }), i ? "Saving..." : "Save"]
222
+ })]
223
+ })
224
+ })
225
+ ] }, e.key);
226
+ }) : /* @__PURE__ */ d(S, { children: /* @__PURE__ */ d(y, {
227
+ colSpan: 7,
228
+ className: "py-10 text-center text-muted-foreground",
229
+ children: "No inventory rows matched your search."
230
+ }) }) })] })
231
+ })]
232
+ });
211
233
  }
212
- export {
213
- re as InventoryTableClient
214
- };
234
+ //#endregion
235
+ export { D as InventoryTableClient };
@@ -0,0 +1,3 @@
1
+ "use server";const e=require("../../../../shared-inventory.cjs");let t=require("@nextblock-cms/db/server"),n=require("next/cache");function r(e){let t=[],n=[],r=``,i=!1;for(let a=0;a<e.length;a+=1){let o=e[a],s=e[a+1];if(o===`"`){i&&s===`"`?(r+=`"`,a+=1):i=!i;continue}if(o===`,`&&!i){n.push(r),r=``;continue}if((o===`
2
+ `||o===`\r`)&&!i){o===`\r`&&s===`
3
+ `&&(a+=1),(r.length>0||n.length>0)&&(n.push(r),t.push(n)),n=[],r=``;continue}r+=o}return(r.length>0||n.length>0)&&(n.push(r),t.push(n)),t.filter(e=>e.some(e=>e.trim().length>0))}function i(e){return e.sku}async function a(t){try{let r=Math.max(0,Math.trunc(t.stock));return await e.setSharedInventoryQuantity({sku:t.sku,stock:r}),(0,n.revalidatePath)(`/cms/products`),(0,n.revalidatePath)(`/cms/products/inventory`),{success:!0,itemKey:i(t),stock:r}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Failed to update inventory.`}}}async function o(i){try{let a=r(i);if(a.length<2)return{success:!1,error:`The CSV file is empty.`};let[o,...s]=a,c=o.map(e=>e.trim().toLowerCase()),l=c.indexOf(`sku`),u=c.indexOf(`stock`);if(l===-1||u===-1)return{success:!1,error:`The CSV format is invalid. Please import a file exported from the Inventory page.`};let d=(0,t.getServiceRoleSupabaseClient)(),f=0;for(let t of s){let n=(t[l]||``).trim(),r=Number.parseInt((t[u]||``).trim(),10);if(n){if(!Number.isFinite(r)||r<0)return{success:!1,error:`Invalid stock value for SKU "${n}".`};await e.setSharedInventoryQuantity({sku:n,stock:r},d),f+=1}}let p=await e.getInventoryItems(d);return(0,n.revalidatePath)(`/cms/products`),(0,n.revalidatePath)(`/cms/products/inventory`),{success:!0,updatedCount:f,items:p}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Failed to import inventory CSV.`}}}exports.importInventoryCsvAction=o,exports.updateInventoryQuantityAction=a;