@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
@@ -1,32 +1,38 @@
1
- import { getStripeClient as c } from "./client.es.js";
2
- import { resolveStripeWebhookSecret as a } from "../payment-config.es.js";
3
- import { syncStripeOrderFromSession as l } from "./order-sync.es.js";
4
- const S = async (s, i) => {
5
- const o = await a();
6
- if (!o)
7
- return console.error("Missing Stripe webhook secret (configure it in CMS or STRIPE_WEBHOOK_SECRET)"), { received: !1, error: "Server configuration error" };
8
- const n = await c();
9
- let e;
10
- try {
11
- e = n.webhooks.constructEvent(i, s, o);
12
- } catch (r) {
13
- return console.error(`Webhook signature verification failed: ${r.message}`), { received: !1, error: `Webhook Error: ${r.message}` };
14
- }
15
- switch (e.type) {
16
- case "checkout.session.completed": {
17
- const r = e.data.object;
18
- try {
19
- await l(r);
20
- } catch (t) {
21
- return console.error("[Stripe Webhook Error] Failed to sync completed session:", t), { received: !1, error: t.message || "Failed to sync Stripe session" };
22
- }
23
- break;
24
- }
25
- default:
26
- console.log(`Unhandled event type ${e.type}`);
27
- }
28
- return { received: !0 };
29
- };
30
- export {
31
- S as handleStripeWebhook
1
+ import { resolveStripeWebhookSecret as e } from "../payment-config.es.js";
2
+ import { getStripeClient as t } from "./client.es.js";
3
+ import { syncStripeOrderFromSession as n } from "./order-sync.es.js";
4
+ //#region src/lib/stripe/webhooks.ts
5
+ var r = async (r, i) => {
6
+ let a = await e();
7
+ if (!a) return console.error("Missing Stripe webhook secret (configure it in CMS or STRIPE_WEBHOOK_SECRET)"), {
8
+ received: !1,
9
+ error: "Server configuration error"
10
+ };
11
+ let o = await t(), s;
12
+ try {
13
+ s = o.webhooks.constructEvent(i, r, a);
14
+ } catch (e) {
15
+ return console.error(`Webhook signature verification failed: ${e.message}`), {
16
+ received: !1,
17
+ error: `Webhook Error: ${e.message}`
18
+ };
19
+ }
20
+ switch (s.type) {
21
+ case "checkout.session.completed": {
22
+ let e = s.data.object;
23
+ try {
24
+ await n(e);
25
+ } catch (e) {
26
+ return console.error("[Stripe Webhook Error] Failed to sync completed session:", e), {
27
+ received: !1,
28
+ error: e.message || "Failed to sync Stripe session"
29
+ };
30
+ }
31
+ break;
32
+ }
33
+ default: console.log(`Unhandled event type ${s.type}`);
34
+ }
35
+ return { received: !0 };
32
36
  };
37
+ //#endregion
38
+ export { r as handleStripeWebhook };
@@ -0,0 +1 @@
1
+ const e=require("./currency.cjs"),t=require("./coupons.cjs"),n=require("./countries.cjs"),r=require("./states.cjs"),i=require("./inventory-settings.cjs");var a=`txcd_99999999`,o=`txcd_00000000`,s=`txcd_92010001`;function c(e){return e?a:o}async function l(n,r,i,a,o){if(!r.length)return[];let s=[...new Set(r.map(e=>e.product_id))],{data:c,error:l}=await n.from(`products`).select(`id, is_taxable`).in(`id`,s);if(l)throw Error(l.message);let u=new Map((c||[]).map(e=>[e.id,e]));return r.reduce((n,r)=>{let s=u.get(r.product_id);if(!s)return n;let c=e.resolveEffectivePriceForCurrency({prices:r.prices,salePrices:r.sale_prices,fallbackPrice:r.price,fallbackSalePrice:r.sale_price,saleStartAt:r.sale_start_at,saleEndAt:r.sale_end_at,scheduledPrice:r.scheduled_price,scheduledPrices:r.scheduled_prices,scheduledPriceAt:r.scheduled_price_at,currencyCode:i,currencies:a});return n.push({product_id:s.id,quantity:r.quantity,unit_amount:c.sale_price??c.price,discount_amount:o?.get(t.getCartLineCouponKey(r))??0,is_taxable:s.is_taxable??!0}),n},[])}async function u(e,t){let a=await i.getEcommerceInventorySettings(e),o=t.items.reduce((e,t)=>t.is_taxable?e+Math.max(0,t.unit_amount*t.quantity-(t.discount_amount??0)):e,0);if(!a.enableTaxes||o<=0)return{enabled:!1,mode:a.taxCalculationMode,amount:0,taxableSubtotal:o,lines:[]};if(a.taxCalculationMode===`automatic`)return{enabled:!0,mode:`automatic`,amount:0,taxableSubtotal:o,lines:[],isPendingExternalCalculation:!0};let s=n.normalizeCountryCode(t.destination?.country_code),c=r.normalizeSubdivisionCode(s,t.destination?.state)||null;if(!s)return{enabled:!0,mode:`manual`,amount:0,taxableSubtotal:o,lines:[]};let l=e.from(`tax_rates`).select(`id, country_code, state_code, tax_name, tax_rate, created_at, updated_at`).eq(`country_code`,s);l=c?l.or(`state_code.is.null,state_code.eq.${c}`):l.is(`state_code`,null);let{data:u,error:d}=await l;if(d)throw Error(d.message);let f=(u||[]).map(e=>({id:e.id,name:e.tax_name,rate:Number(e.tax_rate),amount:Math.round(o*Number(e.tax_rate)/100),country_code:e.country_code,state_code:e.state_code??null}));return{enabled:!0,mode:`manual`,amount:f.reduce((e,t)=>e+t.amount,0),taxableSubtotal:o,lines:f}}exports.STRIPE_TAX_CODE_NONTAXABLE=o,exports.STRIPE_TAX_CODE_SHIPPING=s,exports.STRIPE_TAX_CODE_TAXABLE_GOODS=a,exports.buildCheckoutTaxableItemsFromCart=l,exports.calculateCheckoutTaxes=u,exports.getStripeTaxCodeForProduct=c;
@@ -1,101 +1,87 @@
1
- import { normalizeCountryCode as m } from "./countries.es.js";
2
- import { resolveEffectivePriceForCurrency as p } from "./currency.es.js";
3
- import { getEcommerceInventorySettings as f } from "./inventory-settings.es.js";
4
- import { normalizeSubdivisionCode as x } from "./states.es.js";
5
- import { getCartLineCouponKey as C } from "./coupons.es.js";
6
- const b = "txcd_99999999", y = "txcd_00000000", g = "txcd_92010001";
7
- function A(i) {
8
- return i ? b : y;
1
+ import { resolveEffectivePriceForCurrency as e } from "./currency.es.js";
2
+ import { getCartLineCouponKey as t } from "./coupons.es.js";
3
+ import { normalizeCountryCode as n } from "./countries.es.js";
4
+ import { normalizeSubdivisionCode as r } from "./states.es.js";
5
+ import { getEcommerceInventorySettings as i } from "./inventory-settings.es.js";
6
+ //#region src/lib/tax-calculation.ts
7
+ var a = "txcd_99999999", o = "txcd_00000000", s = "txcd_92010001";
8
+ function c(e) {
9
+ return e ? a : o;
9
10
  }
10
- async function w(i, r, s, n, c) {
11
- if (!r.length)
12
- return [];
13
- const u = [...new Set(r.map((o) => o.product_id))], { data: d, error: l } = await i.from("products").select("id, is_taxable").in("id", u);
14
- if (l)
15
- throw new Error(l.message);
16
- const _ = new Map(
17
- (d || []).map((o) => [o.id, o])
18
- );
19
- return r.reduce((o, e) => {
20
- const t = _.get(e.product_id);
21
- if (!t)
22
- return o;
23
- const a = p({
24
- prices: e.prices,
25
- salePrices: e.sale_prices,
26
- fallbackPrice: e.price,
27
- fallbackSalePrice: e.sale_price,
28
- saleStartAt: e.sale_start_at,
29
- saleEndAt: e.sale_end_at,
30
- scheduledPrice: e.scheduled_price,
31
- scheduledPrices: e.scheduled_prices,
32
- scheduledPriceAt: e.scheduled_price_at,
33
- currencyCode: s,
34
- currencies: n
35
- });
36
- return o.push({
37
- product_id: t.id,
38
- quantity: e.quantity,
39
- unit_amount: a.sale_price ?? a.price,
40
- discount_amount: c?.get(C(e)) ?? 0,
41
- is_taxable: t.is_taxable ?? !0
42
- }), o;
43
- }, []);
11
+ async function l(n, r, i, a, o) {
12
+ if (!r.length) return [];
13
+ let s = [...new Set(r.map((e) => e.product_id))], { data: c, error: l } = await n.from("products").select("id, is_taxable").in("id", s);
14
+ if (l) throw Error(l.message);
15
+ let u = new Map((c || []).map((e) => [e.id, e]));
16
+ return r.reduce((n, r) => {
17
+ let s = u.get(r.product_id);
18
+ if (!s) return n;
19
+ let c = e({
20
+ prices: r.prices,
21
+ salePrices: r.sale_prices,
22
+ fallbackPrice: r.price,
23
+ fallbackSalePrice: r.sale_price,
24
+ saleStartAt: r.sale_start_at,
25
+ saleEndAt: r.sale_end_at,
26
+ scheduledPrice: r.scheduled_price,
27
+ scheduledPrices: r.scheduled_prices,
28
+ scheduledPriceAt: r.scheduled_price_at,
29
+ currencyCode: i,
30
+ currencies: a
31
+ });
32
+ return n.push({
33
+ product_id: s.id,
34
+ quantity: r.quantity,
35
+ unit_amount: c.sale_price ?? c.price,
36
+ discount_amount: o?.get(t(r)) ?? 0,
37
+ is_taxable: s.is_taxable ?? !0
38
+ }), n;
39
+ }, []);
44
40
  }
45
- async function q(i, r) {
46
- const s = await f(i), n = r.items.reduce((t, a) => a.is_taxable ? t + Math.max(0, a.unit_amount * a.quantity - (a.discount_amount ?? 0)) : t, 0);
47
- if (!s.enableTaxes || n <= 0)
48
- return {
49
- enabled: !1,
50
- mode: s.taxCalculationMode,
51
- amount: 0,
52
- taxableSubtotal: n,
53
- lines: []
54
- };
55
- if (s.taxCalculationMode === "automatic")
56
- return {
57
- enabled: !0,
58
- mode: "automatic",
59
- amount: 0,
60
- taxableSubtotal: n,
61
- lines: [],
62
- isPendingExternalCalculation: !0
63
- };
64
- const c = m(r.destination?.country_code), u = x(c, r.destination?.state) || null;
65
- if (!c)
66
- return {
67
- enabled: !0,
68
- mode: "manual",
69
- amount: 0,
70
- taxableSubtotal: n,
71
- lines: []
72
- };
73
- let d = i.from("tax_rates").select("id, country_code, state_code, tax_name, tax_rate, created_at, updated_at").eq("country_code", c);
74
- d = u ? d.or(`state_code.is.null,state_code.eq.${u}`) : d.is("state_code", null);
75
- const { data: l, error: _ } = await d;
76
- if (_)
77
- throw new Error(_.message);
78
- const e = (l || []).map((t) => ({
79
- id: t.id,
80
- name: t.tax_name,
81
- rate: Number(t.tax_rate),
82
- amount: Math.round(n * Number(t.tax_rate) / 100),
83
- country_code: t.country_code,
84
- state_code: t.state_code ?? null
85
- }));
86
- return {
87
- enabled: !0,
88
- mode: "manual",
89
- amount: e.reduce((t, a) => t + a.amount, 0),
90
- taxableSubtotal: n,
91
- lines: e
92
- };
41
+ async function u(e, t) {
42
+ let a = await i(e), o = t.items.reduce((e, t) => t.is_taxable ? e + Math.max(0, t.unit_amount * t.quantity - (t.discount_amount ?? 0)) : e, 0);
43
+ if (!a.enableTaxes || o <= 0) return {
44
+ enabled: !1,
45
+ mode: a.taxCalculationMode,
46
+ amount: 0,
47
+ taxableSubtotal: o,
48
+ lines: []
49
+ };
50
+ if (a.taxCalculationMode === "automatic") return {
51
+ enabled: !0,
52
+ mode: "automatic",
53
+ amount: 0,
54
+ taxableSubtotal: o,
55
+ lines: [],
56
+ isPendingExternalCalculation: !0
57
+ };
58
+ let s = n(t.destination?.country_code), c = r(s, t.destination?.state) || null;
59
+ if (!s) return {
60
+ enabled: !0,
61
+ mode: "manual",
62
+ amount: 0,
63
+ taxableSubtotal: o,
64
+ lines: []
65
+ };
66
+ let l = e.from("tax_rates").select("id, country_code, state_code, tax_name, tax_rate, created_at, updated_at").eq("country_code", s);
67
+ l = c ? l.or(`state_code.is.null,state_code.eq.${c}`) : l.is("state_code", null);
68
+ let { data: u, error: d } = await l;
69
+ if (d) throw Error(d.message);
70
+ let f = (u || []).map((e) => ({
71
+ id: e.id,
72
+ name: e.tax_name,
73
+ rate: Number(e.tax_rate),
74
+ amount: Math.round(o * Number(e.tax_rate) / 100),
75
+ country_code: e.country_code,
76
+ state_code: e.state_code ?? null
77
+ }));
78
+ return {
79
+ enabled: !0,
80
+ mode: "manual",
81
+ amount: f.reduce((e, t) => e + t.amount, 0),
82
+ taxableSubtotal: o,
83
+ lines: f
84
+ };
93
85
  }
94
- export {
95
- y as STRIPE_TAX_CODE_NONTAXABLE,
96
- g as STRIPE_TAX_CODE_SHIPPING,
97
- b as STRIPE_TAX_CODE_TAXABLE_GOODS,
98
- w as buildCheckoutTaxableItemsFromCart,
99
- q as calculateCheckoutTaxes,
100
- A as getStripeTaxCodeForProduct
101
- };
86
+ //#endregion
87
+ export { o as STRIPE_TAX_CODE_NONTAXABLE, s as STRIPE_TAX_CODE_SHIPPING, a as STRIPE_TAX_CODE_TAXABLE_GOODS, l as buildCheckoutTaxableItemsFromCart, u as calculateCheckoutTaxes, c as getStripeTaxCodeForProduct };
package/lib/trials.cjs ADDED
@@ -0,0 +1 @@
1
+ function e(e){let t=Number(e?.trial_period_days??0);return!Number.isFinite(t)||t<=0?0:Math.round(t)}function t(t){return e(t)===0?null:t?.trial_requires_payment_method?`paid`:`free`}function n(e,t,n,r){if(!e)return n;let i=e(t,r);return i===t?n:i}function r(t,r){let i=e(typeof t==`number`?{trial_period_days:t}:t);return i>0?n(r,`ecommerce.trial_days`,`${i}-day free trial`,{count:i}):null}function i(e,t){return e?.trial_requires_payment_method?n(t,`ecommerce.trial_payment_required`,`Payment method required`):n(t,`ecommerce.trial_no_card`,`No credit card required`)}function a(e,n){let a=r(e,n);return a?{label:a,paymentRequirementLabel:i(e,n),checkoutMode:t(e)}:null}exports.getTrialCheckoutMode=t,exports.getTrialLabel=r,exports.getTrialPaymentRequirementLabel=i,exports.getTrialPeriodDays=e,exports.getTrialSummary=a;
package/lib/trials.es.js CHANGED
@@ -1,36 +1,30 @@
1
- function i(r) {
2
- const e = Number(r?.trial_period_days ?? 0);
3
- return !Number.isFinite(e) || e <= 0 ? 0 : Math.round(e);
1
+ //#region src/lib/trials.ts
2
+ function e(e) {
3
+ let t = Number(e?.trial_period_days ?? 0);
4
+ return !Number.isFinite(t) || t <= 0 ? 0 : Math.round(t);
4
5
  }
5
- function u(r) {
6
- return i(r) === 0 ? null : r?.trial_requires_payment_method ? "paid" : "free";
6
+ function t(t) {
7
+ return e(t) === 0 ? null : t?.trial_requires_payment_method ? "paid" : "free";
7
8
  }
8
- function n(r, e, t, o) {
9
- if (!r) return t;
10
- const a = r(e, o);
11
- return a === e ? t : a;
9
+ function n(e, t, n, r) {
10
+ if (!e) return n;
11
+ let i = e(t, r);
12
+ return i === t ? n : i;
12
13
  }
13
- function d(r, e) {
14
- const t = i(typeof r == "number" ? { trial_period_days: r } : r);
15
- return t > 0 ? n(e, "ecommerce.trial_days", `${t}-day free trial`, {
16
- count: t
17
- }) : null;
14
+ function r(t, r) {
15
+ let i = e(typeof t == "number" ? { trial_period_days: t } : t);
16
+ return i > 0 ? n(r, "ecommerce.trial_days", `${i}-day free trial`, { count: i }) : null;
18
17
  }
19
- function l(r, e) {
20
- return r?.trial_requires_payment_method ? n(e, "ecommerce.trial_payment_required", "Payment method required") : n(e, "ecommerce.trial_no_card", "No credit card required");
18
+ function i(e, t) {
19
+ return e?.trial_requires_payment_method ? n(t, "ecommerce.trial_payment_required", "Payment method required") : n(t, "ecommerce.trial_no_card", "No credit card required");
21
20
  }
22
- function c(r, e) {
23
- const t = d(r, e);
24
- return t ? {
25
- label: t,
26
- paymentRequirementLabel: l(r, e),
27
- checkoutMode: u(r)
28
- } : null;
21
+ function a(e, n) {
22
+ let a = r(e, n);
23
+ return a ? {
24
+ label: a,
25
+ paymentRequirementLabel: i(e, n),
26
+ checkoutMode: t(e)
27
+ } : null;
29
28
  }
30
- export {
31
- u as getTrialCheckoutMode,
32
- d as getTrialLabel,
33
- l as getTrialPaymentRequirementLabel,
34
- i as getTrialPeriodDays,
35
- c as getTrialSummary
36
- };
29
+ //#endregion
30
+ export { t as getTrialCheckoutMode, r as getTrialLabel, i as getTrialPaymentRequirementLabel, e as getTrialPeriodDays, a as getTrialSummary };
package/lib/types.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e={stripe:!1,freemius:!1};function t(t){if(!t||typeof t!=`object`||Array.isArray(t))return{...e};let n=t;return{stripe:n.stripe===!0,freemius:n.freemius===!0}}function n(e){return e===`digital`?`freemius`:`stripe`}function r(e){return e?`provider`in e&&e.provider?e.provider:e.payment_provider?e.payment_provider:e.product_type?n(e.product_type):`freemius_product_id`in e&&e.freemius_product_id?`freemius`:null:null}function i(e){return r(e)===`freemius`}function a(e){return i(e)}exports.DEFAULT_ENABLED_PAYMENT_PROVIDERS=e,exports.derivePaymentProviderFromProductType=n,exports.getProductPaymentProvider=r,exports.isDigitalItem=a,exports.isDigitalProduct=i,exports.normalizeEnabledPaymentProviders=t;
package/lib/types.es.js CHANGED
@@ -1,33 +1,27 @@
1
- const i = {
2
- stripe: !1,
3
- freemius: !1
1
+ //#region src/lib/types.ts
2
+ var e = {
3
+ stripe: !1,
4
+ freemius: !1
4
5
  };
5
- function u(r) {
6
- if (!r || typeof r != "object" || Array.isArray(r))
7
- return { ...i };
8
- const e = r;
9
- return {
10
- stripe: e.stripe === !0,
11
- freemius: e.freemius === !0
12
- };
6
+ function t(t) {
7
+ if (!t || typeof t != "object" || Array.isArray(t)) return { ...e };
8
+ let n = t;
9
+ return {
10
+ stripe: n.stripe === !0,
11
+ freemius: n.freemius === !0
12
+ };
13
13
  }
14
- function t(r) {
15
- return r === "digital" ? "freemius" : "stripe";
14
+ function n(e) {
15
+ return e === "digital" ? "freemius" : "stripe";
16
16
  }
17
- function n(r) {
18
- return r ? "provider" in r && r.provider ? r.provider : r.payment_provider ? r.payment_provider : r.product_type ? t(r.product_type) : "freemius_product_id" in r && r.freemius_product_id ? "freemius" : null : null;
17
+ function r(e) {
18
+ return e ? "provider" in e && e.provider ? e.provider : e.payment_provider ? e.payment_provider : e.product_type ? n(e.product_type) : "freemius_product_id" in e && e.freemius_product_id ? "freemius" : null : null;
19
19
  }
20
- function o(r) {
21
- return n(r) === "freemius";
20
+ function i(e) {
21
+ return r(e) === "freemius";
22
22
  }
23
- function d(r) {
24
- return o(r);
23
+ function a(e) {
24
+ return i(e);
25
25
  }
26
- export {
27
- i as DEFAULT_ENABLED_PAYMENT_PROVIDERS,
28
- t as derivePaymentProviderFromProductType,
29
- n as getProductPaymentProvider,
30
- d as isDigitalItem,
31
- o as isDigitalProduct,
32
- u as normalizeEnabledPaymentProviders
33
- };
26
+ //#endregion
27
+ export { e as DEFAULT_ENABLED_PAYMENT_PROVIDERS, n as derivePaymentProviderFromProductType, r as getProductPaymentProvider, a as isDigitalItem, i as isDigitalProduct, t as normalizeEnabledPaymentProviders };
@@ -0,0 +1 @@
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./cart-store.cjs");let t=require("react");var n=null;function r(){return e.useCartStore.persist}function i(){return r()?.hasHydrated?.()??!1}function a(){if(typeof window>`u`)return Promise.resolve();let e=r();return!e||e.hasHydrated()?Promise.resolve():(n||=Promise.resolve().then(()=>e.rehydrate()).finally(()=>{n=null}),n)}var o=n=>{let o=e.useCartStore(n),[s,c]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{let e=r();if(i()){c(!0);return}let t=e?.onFinishHydration(()=>c(!0));return a(),()=>{t?.()}},[]),s?o:void 0},s=()=>{let[e,n]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{let e=r()?.onFinishHydration(()=>n(!0));return n(i()),i()||a(),()=>{e?.()}},[]),e};exports.useCart=o,exports.useIsCartHydrated=s;
@@ -1,44 +1,42 @@
1
- 'use client';
2
- import { useState as u, useEffect as a } from "react";
3
- import { useCartStore as d } from "./cart-store.es.js";
4
- let s = null;
5
- function n() {
6
- return d.persist;
7
- }
1
+ "use client";
2
+ import { useCartStore as e } from "./cart-store.es.js";
3
+ import { useEffect as t, useState as n } from "react";
4
+ //#region src/lib/use-cart.ts
5
+ var r = null;
8
6
  function i() {
9
- return n()?.hasHydrated?.() ?? !1;
7
+ return e.persist;
10
8
  }
11
- function f() {
12
- if (typeof window > "u")
13
- return Promise.resolve();
14
- const t = n();
15
- return !t || t.hasHydrated() ? Promise.resolve() : (s || (s = Promise.resolve().then(() => t.rehydrate()).finally(() => {
16
- s = null;
17
- })), s);
9
+ function a() {
10
+ return i()?.hasHydrated?.() ?? !1;
18
11
  }
19
- const m = (t) => {
20
- const r = d(t), [o, e] = u(!1);
21
- return a(() => {
22
- const c = n();
23
- if (i()) {
24
- e(!0);
25
- return;
26
- }
27
- const l = c?.onFinishHydration(() => e(!0));
28
- return f(), () => {
29
- l?.();
30
- };
31
- }, []), o ? r : void 0;
32
- }, H = () => {
33
- const [t, r] = u(!1);
34
- return a(() => {
35
- const e = n()?.onFinishHydration(() => r(!0));
36
- return r(i()), i() || f(), () => {
37
- e?.();
38
- };
39
- }, []), t;
40
- };
41
- export {
42
- m as useCart,
43
- H as useIsCartHydrated
12
+ function o() {
13
+ if (typeof window > "u") return Promise.resolve();
14
+ let e = i();
15
+ return !e || e.hasHydrated() ? Promise.resolve() : (r ||= Promise.resolve().then(() => e.rehydrate()).finally(() => {
16
+ r = null;
17
+ }), r);
18
+ }
19
+ var s = (r) => {
20
+ let s = e(r), [c, l] = n(!1);
21
+ return t(() => {
22
+ let e = i();
23
+ if (a()) {
24
+ l(!0);
25
+ return;
26
+ }
27
+ let t = e?.onFinishHydration(() => l(!0));
28
+ return o(), () => {
29
+ t?.();
30
+ };
31
+ }, []), c ? s : void 0;
32
+ }, c = () => {
33
+ let [e, r] = n(!1);
34
+ return t(() => {
35
+ let e = i()?.onFinishHydration(() => r(!0));
36
+ return r(a()), a() || o(), () => {
37
+ e?.();
38
+ };
39
+ }, []), e;
44
40
  };
41
+ //#endregion
42
+ export { s as useCart, c as useIsCartHydrated };
@@ -0,0 +1 @@
1
+ "use client";let e=require("@nextblock-cms/utils");function t(e){return e?e===`fr`?`fr-CA`:e===`en`?`en-US`:e:`en-US`}function n(){let{lang:n}=(0,e.useTranslations)(),r=t(n);return(t,n)=>(0,e.formatPrice)(t,n,r)}exports.getPriceLocale=t,exports.usePriceFormatter=n;
@@ -1,13 +1,12 @@
1
- 'use client';
2
- import { useTranslations as o, formatPrice as i } from "@nextblock-cms/utils";
3
- function c(r) {
4
- return r ? r === "fr" ? "fr-CA" : r === "en" ? "en-US" : r : "en-US";
1
+ "use client";
2
+ import { formatPrice as e, useTranslations as t } from "@nextblock-cms/utils";
3
+ //#region src/lib/use-price-formatter.ts
4
+ function n(e) {
5
+ return e ? e === "fr" ? "fr-CA" : e === "en" ? "en-US" : e : "en-US";
5
6
  }
6
- function u() {
7
- const { lang: r } = o(), e = c(r);
8
- return (t, n) => i(t, n, e);
7
+ function r() {
8
+ let { lang: r } = t(), i = n(r);
9
+ return (t, n) => e(t, n, i);
9
10
  }
10
- export {
11
- c as getPriceLocale,
12
- u as usePriceFormatter
13
- };
11
+ //#endregion
12
+ export { n as getPriceLocale, r as usePriceFormatter };
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./currency.cjs");function t(e){return!e||typeof e!=`object`||Array.isArray(e)?null:Object.entries(e).reduce((e,[t,n])=>(typeof n==`string`&&n.trim()&&(e[t]=n.trim()),e),{})}function n(e,t,n){return!n||!t?e:t[n]?.trim()||e}function r(e,t){return n(e.name,e.name_translations,t)}function i(e,t){return n(e.value,e.value_translations,t)}function a(e){return e?e.startsWith(`http`)?e:process.env.NEXT_PUBLIC_R2_BASE_URL?`${process.env.NEXT_PUBLIC_R2_BASE_URL}/${e}`:process.env.NEXT_PUBLIC_SUPABASE_URL?`${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/public/media/${e}`:e:null}function o(e){return e.toLowerCase().trim().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``)}function s(e){return[...e].sort().join(`__`)}function c(e){return e.map(e=>e.term_value).join(` / `)}function l(e){return e.length===0?[]:e.reduce((e,t)=>e.flatMap(e=>t.map(t=>[...e,t])),[[]])}function u(t){let{baseSku:n,basePrice:r,basePrices:i={},baseSalePrice:a=null,baseSalePrices:u={},selectedAttributes:d,previousVariants:f=[]}=t;if(d.length===0||d.some(e=>e.terms.length===0))return[];let p=new Map(f.map(e=>[e.combination_key,e]));return l(d.map(e=>e.terms.map(t=>({attribute_id:e.attribute_id,attribute_name:e.attribute_name,term:t})))).map(t=>{let l=t.map(({attribute_id:e,attribute_name:t,term:n})=>({attribute_id:e,attribute_name:t,term_id:n.id,term_value:n.value,term_slug:n.slug})),d=l.map(e=>e.term_id),f=s(d),m=p.get(f),h=l.map(e=>(e.term_slug?e.term_slug:o(e.term_value)).toUpperCase()).filter(Boolean).join(`-`);return{id:m?.id,combination_key:f,sku:m?.sku||[n.trim(),h].filter(Boolean).join(`-`),upc:m?.upc??null,price:m?.price??r,prices:m?.prices??e.normalizePriceMap(i),sale_price:m?.sale_price??a,sale_prices:m?.sale_prices??e.normalizeSalePriceMap(u),sale_start_at:m?.sale_start_at??null,sale_end_at:m?.sale_end_at??null,stock_quantity:m?.stock_quantity??0,main_media_id:m?.main_media_id??null,main_image_url:m?.main_image_url??null,attribute_term_ids:d,selected_options:l,label:c(l)}})}function d(e){let t={};for(let n of e)for(let e of n.selected_options??[]){let n=new Set(t[e.attribute_id]??[]);n.add(e.term_id),t[e.attribute_id]=[...n]}return t}function f(e,t){let n=Object.values(t).filter(Boolean);return n.length===0?null:e.find(e=>e.attribute_term_ids.length===n.length&&n.every(t=>e.attribute_term_ids.includes(t)))??null}function p(e,t,n){let r=new Set;for(let i of e){if(!Object.entries(n).every(([e,n])=>!n||e===t||i.attribute_term_ids.includes(n)))continue;let e=i.selected_options.find(e=>e.attribute_id===t);e&&r.add(e.term_id)}return r}function m(e,t){let n=t.find(e=>e.stock_quantity>0)??t[0]??null;return n?n.selected_options.reduce((e,t)=>(e[t.attribute_id]=t.term_id,e),{}):e.reduce((e,t)=>{let n=t.terms[0];return n&&(e[t.id]=n.id),e},{})}function h(e,t,n,r,i){let a={[r]:i};for(let i of e){if(i.id===r)continue;let e=p(t,i.id,a),o=n[i.id];if(o&&e.has(o)){a[i.id]=o;continue}let s=i.terms.find(t=>e.has(t.id));s&&(a[i.id]=s.id)}return a}function g(e,t,n){let r={...n};for(let n of e){let e=p(t,n.id,r);if(e.size===0){delete r[n.id];continue}let i=r[n.id];if(i&&e.has(i))continue;let a=n.terms.find(t=>e.has(t.id));a&&(r[n.id]=a.id)}return r}function _(r=[],i){let o=new Map,l=r.map(r=>{let l=(r.variant_attribute_mapping||[]).map(e=>{let r=e.product_attribute_terms,a=r?.product_attributes;if(!r||!a)return null;let s=o.get(a.id)||{id:a.id,name:n(a.name,t(a.name_translations),i),slug:a.slug,name_translations:t(a.name_translations),terms:[],_termIds:new Set};return s._termIds.has(r.id)||(s.terms.push({id:r.id,attribute_id:r.attribute_id,value:n(r.value,t(r.value_translations),i),slug:r.slug,sort_order:r.sort_order??null,value_translations:t(r.value_translations)}),s._termIds.add(r.id)),o.set(a.id,s),{attribute_id:a.id,attribute_name:n(a.name,t(a.name_translations),i),term_id:r.id,term_value:n(r.value,t(r.value_translations),i),term_slug:r.slug}}).filter(e=>e!==null).sort((e,t)=>e.attribute_name.localeCompare(t.attribute_name)),u=l.map(e=>e.term_id);return{id:r.id,combination_key:s(u),sku:r.sku,upc:r.upc??null,price:r.price??0,prices:e.normalizePriceMap(r.prices),sale_price:r.sale_price??null,sale_prices:e.normalizeSalePriceMap(r.sale_prices),sale_start_at:r.sale_start_at??null,sale_end_at:r.sale_end_at??null,scheduled_price:r.scheduled_price??null,scheduled_prices:e.normalizePriceMap(r.scheduled_prices),scheduled_price_at:r.scheduled_price_at??null,stock_quantity:r.stock_quantity??0,main_media_id:r.main_media_id??null,image_url:a(r.media?.file_path??r.media?.object_key??null),attribute_term_ids:u,selected_options:l,label:c(l)}});return{attributes:[...o.values()].map(e=>({id:e.id,name:e.name,slug:e.slug,name_translations:e.name_translations,terms:[...e.terms].sort((e,t)=>{let n=e.sort_order??2**53-1,r=t.sort_order??2**53-1;return n===r?e.value.localeCompare(t.value):n-r})})).sort((e,t)=>e.name.localeCompare(t.name)),variants:l}}function v(t,n){if(!t.length)return null;let r=t.map(t=>e.isSaleWindowActive({saleStartAt:t.sale_start_at,saleEndAt:t.sale_end_at,now:n})&&typeof t.sale_price==`number`?t.sale_price:t.price);return{min:Math.min(...r),max:Math.max(...r)}}exports.applyVariantSelection=h,exports.buildCombinationKey=s,exports.buildVariantLabel=c,exports.chooseInitialVariantSelections=m,exports.extractSelectedTermsByAttribute=d,exports.findMatchingVariant=f,exports.generateVariantDrafts=u,exports.getAvailableTermIdsForAttribute=p,exports.getVariantEffectivePriceRange=v,exports.mapRawVariantRelations=_,exports.normalizeSelectionsToAvailableVariants=g,exports.resolveAttributeName=r,exports.resolveTermValue=i,exports.resolveTranslatedText=n;