@nextblock-cms/ecom 0.20.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/_virtual/_rolldown/runtime.cjs.js +1 -0
  2. package/index.cjs.js +1 -1
  3. package/index.es.js +38 -146
  4. package/lib/CurrencyProvider.cjs.js +1 -1
  5. package/lib/CurrencyProvider.d.ts +1 -1
  6. package/lib/CurrencyProvider.es.js +85 -95
  7. package/lib/PaymentReadinessProvider.cjs.js +1 -1
  8. package/lib/PaymentReadinessProvider.d.ts +1 -1
  9. package/lib/PaymentReadinessProvider.es.js +24 -27
  10. package/lib/cart-store.cjs.js +1 -1
  11. package/lib/cart-store.es.js +109 -121
  12. package/lib/components/AccountNavigationMenu.cjs.js +1 -1
  13. package/lib/components/AccountNavigationMenu.d.ts +1 -1
  14. package/lib/components/AccountNavigationMenu.es.js +36 -50
  15. package/lib/components/AddToCartButton.cjs.js +1 -1
  16. package/lib/components/AddToCartButton.d.ts +1 -1
  17. package/lib/components/AddToCartButton.es.js +94 -89
  18. package/lib/components/Cart.cjs.js +1 -1
  19. package/lib/components/Cart.d.ts +1 -1
  20. package/lib/components/Cart.es.js +261 -180
  21. package/lib/components/CartDrawer.cjs.js +1 -1
  22. package/lib/components/CartDrawer.d.ts +1 -1
  23. package/lib/components/CartDrawer.es.js +218 -148
  24. package/lib/components/CartIcon.cjs.js +1 -1
  25. package/lib/components/CartIcon.d.ts +1 -1
  26. package/lib/components/CartIcon.es.js +33 -35
  27. package/lib/components/Checkout.cjs.js +1 -1
  28. package/lib/components/Checkout.d.ts +1 -1
  29. package/lib/components/Checkout.es.js +1092 -1108
  30. package/lib/components/CouponForm.cjs.js +1 -1
  31. package/lib/components/CouponForm.d.ts +1 -1
  32. package/lib/components/CouponForm.es.js +136 -148
  33. package/lib/components/CurrencySwitcher.cjs.js +1 -1
  34. package/lib/components/CurrencySwitcher.d.ts +1 -1
  35. package/lib/components/CurrencySwitcher.es.js +22 -18
  36. package/lib/components/CustomerProfileForm.cjs.js +1 -1
  37. package/lib/components/CustomerProfileForm.es.js +454 -313
  38. package/lib/components/FeaturedProduct.cjs.js +1 -1
  39. package/lib/components/FeaturedProduct.d.ts +1 -1
  40. package/lib/components/FeaturedProduct.es.js +98 -83
  41. package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
  42. package/lib/components/FreemiusLicensePanel.d.ts +1 -1
  43. package/lib/components/FreemiusLicensePanel.es.js +70 -65
  44. package/lib/components/InvoiceDocument.cjs.js +1 -1
  45. package/lib/components/InvoiceDocument.es.js +256 -192
  46. package/lib/components/InvoiceViewerShell.cjs.js +2 -2
  47. package/lib/components/InvoiceViewerShell.d.ts +1 -1
  48. package/lib/components/InvoiceViewerShell.es.js +75 -106
  49. package/lib/components/ProductCard.cjs.js +1 -1
  50. package/lib/components/ProductCard.d.ts +1 -1
  51. package/lib/components/ProductCard.es.js +186 -171
  52. package/lib/components/ProductDetailsLayout.cjs.js +1 -1
  53. package/lib/components/ProductDetailsLayout.es.js +405 -404
  54. package/lib/components/ProductGallery.cjs.js +1 -1
  55. package/lib/components/ProductGallery.d.ts +1 -1
  56. package/lib/components/ProductGallery.es.js +51 -54
  57. package/lib/components/ProductGrid.cjs.js +1 -1
  58. package/lib/components/ProductGrid.d.ts +1 -1
  59. package/lib/components/ProductGrid.es.js +23 -25
  60. package/lib/components/ShippingEstimator.cjs.js +1 -1
  61. package/lib/components/ShippingEstimator.d.ts +1 -1
  62. package/lib/components/ShippingEstimator.es.js +158 -153
  63. package/lib/components/ShortDescription.cjs.js +1 -1
  64. package/lib/components/ShortDescription.es.js +17 -17
  65. package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
  66. package/lib/components/SimpleTiptapRenderer.es.js +238 -211
  67. package/lib/components/SubscriptionSelector.cjs.js +1 -1
  68. package/lib/components/SubscriptionSelector.es.js +159 -154
  69. package/lib/countries.cjs.js +1 -1
  70. package/lib/countries.es.js +232 -75
  71. package/lib/coupon-server.cjs.js +1 -1
  72. package/lib/coupon-server.es.js +180 -224
  73. package/lib/coupons.cjs.js +1 -1
  74. package/lib/coupons.es.js +12 -14
  75. package/lib/currency-constants.cjs.js +1 -1
  76. package/lib/currency-constants.es.js +4 -4
  77. package/lib/currency-rest-client.cjs.js +1 -1
  78. package/lib/currency-rest-client.es.js +15 -22
  79. package/lib/currency-store.cjs.js +1 -1
  80. package/lib/currency-store.es.js +20 -27
  81. package/lib/currency-sync.cjs.js +1 -1
  82. package/lib/currency-sync.es.js +124 -170
  83. package/lib/currency.cjs.js +1 -1
  84. package/lib/currency.es.js +242 -310
  85. package/lib/customer-addresses.cjs.js +1 -1
  86. package/lib/customer-addresses.es.js +80 -109
  87. package/lib/customer-orders.cjs.js +1 -1
  88. package/lib/customer-orders.es.js +31 -43
  89. package/lib/customer.cjs.js +1 -1
  90. package/lib/customer.es.js +43 -52
  91. package/lib/export-helpers.cjs.js +1 -1
  92. package/lib/export-helpers.es.js +53 -52
  93. package/lib/factory.cjs.js +1 -1
  94. package/lib/factory.es.js +10 -7
  95. package/lib/freemius-coupons.cjs.js +1 -1
  96. package/lib/freemius-coupons.es.js +245 -262
  97. package/lib/freemius-license-claim.cjs.js +1 -1
  98. package/lib/freemius-license-claim.es.js +87 -71
  99. package/lib/freemius-license.cjs.js +1 -1
  100. package/lib/freemius-license.es.js +32 -39
  101. package/lib/freemius-order-sync.cjs.js +1 -1
  102. package/lib/freemius-order-sync.es.js +226 -290
  103. package/lib/freemius-trial-provision.cjs.js +1 -1
  104. package/lib/freemius-trial-provision.es.js +136 -130
  105. package/lib/inventory-settings.cjs.js +1 -1
  106. package/lib/inventory-settings.es.js +69 -77
  107. package/lib/invoice-server.cjs.js +3 -3
  108. package/lib/invoice-server.es.js +94 -141
  109. package/lib/invoice-ui.cjs.js +1 -1
  110. package/lib/invoice-ui.es.js +50 -66
  111. package/lib/invoice.cjs.js +1 -1
  112. package/lib/invoice.es.js +85 -94
  113. package/lib/order-inventory.cjs.js +25 -25
  114. package/lib/order-inventory.es.js +67 -79
  115. package/lib/order-tax-details.cjs.js +1 -1
  116. package/lib/order-tax-details.es.js +142 -153
  117. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
  118. package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
  119. package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
  120. package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
  121. package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
  122. package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
  123. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
  124. package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
  125. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
  126. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
  127. package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
  128. package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
  129. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
  130. package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
  131. package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
  132. package/lib/pages/cms/coupons/actions.cjs.js +1 -1
  133. package/lib/pages/cms/coupons/actions.es.js +112 -115
  134. package/lib/pages/cms/coupons/index.cjs.js +1 -0
  135. package/lib/pages/cms/coupons/index.es.js +3 -0
  136. package/lib/pages/cms/coupons/product-options.cjs.js +1 -1
  137. package/lib/pages/cms/coupons/product-options.es.js +21 -23
  138. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
  139. package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
  140. package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
  141. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
  142. package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
  143. package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
  144. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
  145. package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
  146. package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
  147. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
  148. package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
  149. package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
  150. package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
  151. package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
  152. package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
  153. package/lib/pages/cms/orders/actions.cjs.js +3 -3
  154. package/lib/pages/cms/orders/actions.es.js +53 -69
  155. package/lib/pages/cms/orders/export-actions.cjs.js +1 -1
  156. package/lib/pages/cms/orders/export-actions.es.js +23 -26
  157. package/lib/pages/cms/orders/index.cjs.js +1 -0
  158. package/lib/pages/cms/orders/index.es.js +6 -0
  159. package/lib/pages/cms/orders/server-actions.cjs.js +1 -1
  160. package/lib/pages/cms/orders/server-actions.es.js +60 -51
  161. package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
  162. package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
  163. package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
  164. package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
  165. package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
  166. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
  167. package/lib/pages/cms/payments/actions.cjs.js +1 -1
  168. package/lib/pages/cms/payments/actions.es.js +38 -48
  169. package/lib/pages/cms/payments/index.cjs.js +1 -0
  170. package/lib/pages/cms/payments/index.es.js +3 -0
  171. package/lib/pages/cms/payments/queries.cjs.js +1 -1
  172. package/lib/pages/cms/payments/queries.es.js +38 -48
  173. package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
  174. package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
  175. package/lib/pages/cms/products/ProductsPage.es.js +63 -66
  176. package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
  177. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
  178. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +138 -155
  179. package/lib/pages/cms/products/actions.cjs.js +4 -4
  180. package/lib/pages/cms/products/actions.es.js +121 -162
  181. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
  182. package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
  183. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
  184. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
  185. package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
  186. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
  187. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
  188. package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
  189. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
  190. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
  191. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
  192. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
  193. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
  194. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
  195. package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
  196. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
  197. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
  198. package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
  199. package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
  200. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
  201. package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
  202. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
  203. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
  204. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
  205. package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
  206. package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
  207. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
  208. package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
  209. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
  210. package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
  211. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
  212. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
  213. package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
  214. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
  215. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
  216. package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
  217. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
  218. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
  219. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
  220. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
  221. package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
  222. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
  223. package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
  224. package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
  225. package/lib/pages/cms/products/index.cjs.js +1 -0
  226. package/lib/pages/cms/products/index.es.js +8 -0
  227. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
  228. package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
  229. package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
  230. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
  231. package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
  232. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
  233. package/lib/pages/cms/products/inventory/actions.cjs.js +3 -3
  234. package/lib/pages/cms/products/inventory/actions.es.js +83 -91
  235. package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
  236. package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
  237. package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
  238. package/lib/pages/cms/products/product-price-sync.cjs.js +1 -1
  239. package/lib/pages/cms/products/product-price-sync.es.js +74 -89
  240. package/lib/pages/cms/products/server-actions.cjs.js +1 -1
  241. package/lib/pages/cms/products/server-actions.es.js +250 -233
  242. package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
  243. package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
  244. package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
  245. package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
  246. package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
  247. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
  248. package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
  249. package/lib/pages/cms/shipping/index.cjs.js +1 -0
  250. package/lib/pages/cms/shipping/index.es.js +3 -0
  251. package/lib/pages/cms/shipping/server-actions.cjs.js +1 -1
  252. package/lib/pages/cms/shipping/server-actions.es.js +131 -149
  253. package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
  254. package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
  255. package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
  256. package/lib/pages/cms/taxes/actions.cjs.js +1 -1
  257. package/lib/pages/cms/taxes/actions.es.js +41 -53
  258. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
  259. package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
  260. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
  261. package/lib/pages/cms/taxes/index.cjs.js +1 -0
  262. package/lib/pages/cms/taxes/index.es.js +3 -0
  263. package/lib/payment-config.cjs.js +1 -1
  264. package/lib/payment-config.es.js +110 -126
  265. package/lib/product-actions.cjs.js +4 -4
  266. package/lib/product-actions.es.js +289 -544
  267. package/lib/product-context.cjs.js +1 -1
  268. package/lib/product-context.es.js +13 -15
  269. package/lib/product-schema.cjs.js +1 -1
  270. package/lib/product-schema.es.js +99 -134
  271. package/lib/providers/freemius.cjs.js +1 -5
  272. package/lib/providers/freemius.es.js +446 -530
  273. package/lib/providers/stripe.cjs.js +1 -1
  274. package/lib/providers/stripe.es.js +417 -477
  275. package/lib/server-actions/coupon-actions.cjs.js +1 -1
  276. package/lib/server-actions/coupon-actions.es.js +22 -22
  277. package/lib/server-actions/customer-actions.cjs.js +1 -1
  278. package/lib/server-actions/customer-actions.es.js +26 -28
  279. package/lib/server-actions/product-actions.cjs.js +1 -1
  280. package/lib/server-actions/product-actions.es.js +9 -15
  281. package/lib/server-actions/shipping-actions.cjs.js +1 -1
  282. package/lib/server-actions/shipping-actions.es.js +27 -24
  283. package/lib/server-actions/tax-actions.cjs.js +1 -1
  284. package/lib/server-actions/tax-actions.es.js +33 -39
  285. package/lib/shared-inventory.cjs.js +2 -2
  286. package/lib/shared-inventory.es.js +111 -160
  287. package/lib/shipping/resolver.cjs.js +2 -2
  288. package/lib/shipping/resolver.es.js +44 -61
  289. package/lib/shipping-rate-currency.cjs.js +1 -1
  290. package/lib/shipping-rate-currency.es.js +52 -67
  291. package/lib/states.cjs.js +1 -1
  292. package/lib/states.es.js +333 -154
  293. package/lib/stripe/checkout.cjs.js +1 -1
  294. package/lib/stripe/checkout.es.js +125 -181
  295. package/lib/stripe/client.cjs.js +1 -1
  296. package/lib/stripe/client.es.js +14 -19
  297. package/lib/stripe/order-sync.cjs.js +1 -1
  298. package/lib/stripe/order-sync.es.js +106 -126
  299. package/lib/stripe/webhooks.cjs.js +1 -1
  300. package/lib/stripe/webhooks.es.js +37 -31
  301. package/lib/tax-calculation.cjs.js +1 -1
  302. package/lib/tax-calculation.es.js +84 -98
  303. package/lib/trials.cjs.js +1 -1
  304. package/lib/trials.es.js +24 -30
  305. package/lib/types.cjs.js +1 -1
  306. package/lib/types.es.js +21 -27
  307. package/lib/use-cart.cjs.js +1 -1
  308. package/lib/use-cart.es.js +38 -40
  309. package/lib/use-price-formatter.cjs.js +1 -1
  310. package/lib/use-price-formatter.es.js +10 -11
  311. package/lib/variation-utils.cjs.js +1 -1
  312. package/lib/variation-utils.es.js +199 -261
  313. package/lib/zod-config.cjs.js +1 -1
  314. package/lib/zod-config.es.js +5 -6
  315. package/package.json +16 -16
  316. package/server.cjs.js +1 -1
  317. package/server.es.js +56 -211
@@ -0,0 +1 @@
1
+ const e=require("./ProductsPage.cjs.js"),t=require("./inventory/InventoryPage.cjs.js"),n=require("./attributes/AttributeManagementPage.cjs.js"),r=require("./new/NewProductPage.cjs.js"),i=require("./_id_/edit/EditProductPage.cjs.js"),a=require("./components/CopyProductFromLanguage.cjs.js"),o=require("./categories/CategoryManagementPage.cjs.js");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 };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("../../../../shared-inventory.cjs.js"),s=require("./InventoryTableClient.cjs.js");async function a(){const t=await n.getInventoryItems();return e.jsxs("div",{className:"p-8 space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Inventory"}),e.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."})]}),e.jsx(s.InventoryTableClient,{initialItems:t})]})}exports.InventoryPage=a;
1
+ const e=require("../../../../shared-inventory.cjs.js"),t=require("./InventoryTableClient.cjs.js");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 libs/ecommerce/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 };
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("react"),t=require("@nextblock-cms/ui"),y=require("lucide-react"),j=require("sonner"),S=require("./actions.cjs.js");function R(o){const i=String(o??"");return/[",\n]/.test(i)?`"${i.replace(/"/g,'""')}"`:i}function K(o){const i=["sku","stock","usage_type","product_titles","languages","statuses","parent_product_skus"],b=o.map(c=>[c.sku,c.stock,c.usageType,c.productTitles.join("|"),c.languages.join("|"),c.statuses.join("|"),c.parentProductSkus.join("|")]);return[i,...b].map(c=>c.map(p=>R(p)).join(",")).join(`
2
- `)}function B(o){return o.usageType==="mixed"?"Shared SKU":o.usageType==="variant"?`Variant SKU ${o.sku}`:"Simple Product"}function L(o){return o.usageType==="variant"?"secondary":"outline"}function P({initialItems:o}){const[i,b]=d.useState(o),[c,p]=d.useState(()=>o.reduce((s,n)=>(s[n.key]=String(n.stock),s),{})),[k,T]=d.useState(""),[h,f]=d.useTransition(),[w,x]=d.useState(null),v=d.useRef(null),m=d.useMemo(()=>{const s=k.trim().toLowerCase();return s?i.filter(n=>n.sku.toLowerCase().includes(s)||n.productTitles.join(" ").toLowerCase().includes(s)||n.parentProductSkus.join(" ").toLowerCase().includes(s)||n.languages.join(" ").toLowerCase().includes(s)):i},[i,k]),C=()=>{const s=K(i),n=new Blob([s],{type:"text/csv;charset=utf-8;"}),r=URL.createObjectURL(n),l=document.createElement("a");l.href=r,l.download="inventory-export.csv",l.click(),URL.revokeObjectURL(r)},N=s=>{const n=c[s.key]??String(s.stock),r=Number.parseInt(n,10);if(!Number.isFinite(r)||r<0){j.toast.error("Stock must be a non-negative whole number.");return}x(s.key),f(async()=>{const l=await S.updateInventoryQuantityAction({sku:s.sku,stock:r});if(!l.success){j.toast.error(l.error||"Failed to update inventory."),x(null);return}const u=typeof l.stock=="number"?l.stock:r;b(a=>a.map(g=>g.key===s.key?{...g,stock:u}:g)),p(a=>({...a,[s.key]:String(u)})),x(null),j.toast.success(`Inventory updated for ${s.sku}.`)})},I=()=>{v.current?.click()},U=async s=>{const n=await s.text();x("import"),f(async()=>{const r=await S.importInventoryCsvAction(n);if(!r.success){j.toast.error(r.error||"Failed to import inventory CSV."),x(null);return}const l=r.items||[];b(l),p(l.reduce((u,a)=>(u[a.key]=String(a.stock),u),{})),x(null),j.toast.success(`Imported ${r.updatedCount||0} inventory updates.`)})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border bg-card p-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"relative w-full lg:max-w-md",children:[e.jsx(y.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(t.Input,{value:k,onChange:s=>T(s.target.value),placeholder:"Search by SKU, product title, parent SKU, or language...",className:"pl-9"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("input",{ref:v,type:"file",accept:".csv,text/csv",className:"hidden",onChange:s=>{const n=s.target.files?.[0];n&&U(n),s.currentTarget.value=""}}),e.jsxs(t.Button,{type:"button",variant:"outline",onClick:I,disabled:h,children:[e.jsx(y.Upload,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),e.jsxs(t.Button,{type:"button",variant:"outline",onClick:C,disabled:h,children:[e.jsx(y.Download,{className:"mr-2 h-4 w-4"}),"Export CSV"]})]})]}),e.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."})]}),e.jsx("div",{className:"rounded-xl border bg-card",children:e.jsxs(t.Table,{children:[e.jsx(t.TableHeader,{children:e.jsxs(t.TableRow,{children:[e.jsx(t.TableHead,{children:"SKU"}),e.jsx(t.TableHead,{children:"Usage"}),e.jsx(t.TableHead,{children:"Linked Products"}),e.jsx(t.TableHead,{children:"Languages"}),e.jsx(t.TableHead,{children:"Status"}),e.jsx(t.TableHead,{className:"w-[160px]",children:"Quantity"}),e.jsx(t.TableHead,{className:"text-right",children:"Actions"})]})}),e.jsx(t.TableBody,{children:m.length>0?m.map(s=>{const n=c[s.key]??String(s.stock),r=Number.parseInt(n,10),l=Number.isFinite(r)&&r!==s.stock,u=w===s.key;return e.jsxs(t.TableRow,{children:[e.jsx(t.TableCell,{className:"font-mono text-sm",children:s.sku}),e.jsx(t.TableCell,{children:e.jsx(t.Badge,{variant:L(s),children:B(s)})}),e.jsx(t.TableCell,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:s.productTitles.join(", ")}),s.usageType!=="product"?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Parent SKU",s.parentProductSkus.length>1?"s":"",":"," ",e.jsx("span",{className:"font-mono",children:s.parentProductSkus.join(", ")})]}):null]})}),e.jsx(t.TableCell,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:s.languages.map(a=>e.jsx(t.Badge,{variant:"outline",children:a},`${s.key}:${a}`))})}),e.jsx(t.TableCell,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:s.statuses.map(a=>e.jsx(t.Badge,{variant:"outline",children:a},`${s.key}:${a}`))})}),e.jsx(t.TableCell,{children:e.jsx(t.Input,{type:"number",min:0,step:1,value:n,disabled:h,onChange:a=>p(g=>({...g,[s.key]:a.target.value})),className:"w-28"})}),e.jsx(t.TableCell,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(t.Button,{type:"button",size:"sm",variant:"ghost",disabled:!l||h,onClick:()=>p(a=>({...a,[s.key]:String(s.stock)})),children:[e.jsx(y.RotateCcw,{className:"mr-2 h-4 w-4"}),"Reset"]}),e.jsxs(t.Button,{type:"button",size:"sm",disabled:!l||h,onClick:()=>N(s),children:[e.jsx(y.Save,{className:"mr-2 h-4 w-4"}),u?"Saving...":"Save"]})]})})]},s.key)}):e.jsx(t.TableRow,{children:e.jsx(t.TableCell,{colSpan:7,className:"py-10 text-center text-muted-foreground",children:"No inventory rows matched your search."})})})]})})]})}exports.InventoryTableClient=P;
1
+ "use client";const e=require("./actions.cjs.js");let t=require("react"),n=require("lucide-react"),r=require("react/jsx-runtime"),i=require("sonner"),a=require("@nextblock-cms/ui");function o(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 libs/ecommerce/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 };