@shopify/hydrogen-react 2026.4.1 → 2026.4.2

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 (595) hide show
  1. package/dist/browser-dev/AddToCartButton.mjs +60 -71
  2. package/dist/browser-dev/AddToCartButton.mjs.map +1 -1
  3. package/dist/browser-dev/BaseButton.mjs +20 -26
  4. package/dist/browser-dev/BaseButton.mjs.map +1 -1
  5. package/dist/browser-dev/BuyNowButton.mjs +40 -45
  6. package/dist/browser-dev/BuyNowButton.mjs.map +1 -1
  7. package/dist/browser-dev/CartCheckoutButton.mjs +28 -23
  8. package/dist/browser-dev/CartCheckoutButton.mjs.map +1 -1
  9. package/dist/browser-dev/CartCost.mjs +26 -22
  10. package/dist/browser-dev/CartCost.mjs.map +1 -1
  11. package/dist/browser-dev/CartLineProvider.mjs +23 -18
  12. package/dist/browser-dev/CartLineProvider.mjs.map +1 -1
  13. package/dist/browser-dev/CartLineQuantity.mjs +18 -9
  14. package/dist/browser-dev/CartLineQuantity.mjs.map +1 -1
  15. package/dist/browser-dev/CartLineQuantityAdjustButton.mjs +48 -45
  16. package/dist/browser-dev/CartLineQuantityAdjustButton.mjs.map +1 -1
  17. package/dist/browser-dev/CartProvider.mjs +315 -385
  18. package/dist/browser-dev/CartProvider.mjs.map +1 -1
  19. package/dist/browser-dev/ExternalVideo.mjs +35 -47
  20. package/dist/browser-dev/ExternalVideo.mjs.map +1 -1
  21. package/dist/browser-dev/Image.mjs +335 -340
  22. package/dist/browser-dev/Image.mjs.map +1 -1
  23. package/dist/browser-dev/MediaFile.mjs +39 -61
  24. package/dist/browser-dev/MediaFile.mjs.map +1 -1
  25. package/dist/browser-dev/ModelViewer.mjs +115 -139
  26. package/dist/browser-dev/ModelViewer.mjs.map +1 -1
  27. package/dist/browser-dev/Money.mjs +53 -39
  28. package/dist/browser-dev/Money.mjs.map +1 -1
  29. package/dist/browser-dev/ProductPrice.mjs +44 -61
  30. package/dist/browser-dev/ProductPrice.mjs.map +1 -1
  31. package/dist/browser-dev/ProductProvider.mjs +147 -179
  32. package/dist/browser-dev/ProductProvider.mjs.map +1 -1
  33. package/dist/browser-dev/RichText.components.mjs +36 -46
  34. package/dist/browser-dev/RichText.components.mjs.map +1 -1
  35. package/dist/browser-dev/RichText.mjs +111 -154
  36. package/dist/browser-dev/RichText.mjs.map +1 -1
  37. package/dist/browser-dev/ShopPayButton.mjs +53 -81
  38. package/dist/browser-dev/ShopPayButton.mjs.map +1 -1
  39. package/dist/browser-dev/ShopifyProvider.mjs +71 -84
  40. package/dist/browser-dev/ShopifyProvider.mjs.map +1 -1
  41. package/dist/browser-dev/Video.mjs +35 -52
  42. package/dist/browser-dev/Video.mjs.map +1 -1
  43. package/dist/browser-dev/analytics-constants.mjs +41 -43
  44. package/dist/browser-dev/analytics-constants.mjs.map +1 -1
  45. package/dist/browser-dev/analytics-schema-custom-storefront-customer-tracking.mjs +127 -214
  46. package/dist/browser-dev/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -1
  47. package/dist/browser-dev/analytics-schema-trekkie-storefront-page-view.mjs +39 -50
  48. package/dist/browser-dev/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -1
  49. package/dist/browser-dev/analytics-utils.mjs +78 -56
  50. package/dist/browser-dev/analytics-utils.mjs.map +1 -1
  51. package/dist/browser-dev/analytics.mjs +112 -155
  52. package/dist/browser-dev/analytics.mjs.map +1 -1
  53. package/dist/browser-dev/cart-constants.mjs +11 -15
  54. package/dist/browser-dev/cart-constants.mjs.map +1 -1
  55. package/dist/browser-dev/cart-hooks.mjs +42 -57
  56. package/dist/browser-dev/cart-hooks.mjs.map +1 -1
  57. package/dist/browser-dev/cart-queries.mjs +28 -66
  58. package/dist/browser-dev/cart-queries.mjs.map +1 -1
  59. package/dist/browser-dev/codegen.helpers.mjs +31 -20
  60. package/dist/browser-dev/codegen.helpers.mjs.map +1 -1
  61. package/dist/browser-dev/cookies-utils.mjs +44 -42
  62. package/dist/browser-dev/cookies-utils.mjs.map +1 -1
  63. package/dist/browser-dev/flatten-connection.mjs +23 -29
  64. package/dist/browser-dev/flatten-connection.mjs.map +1 -1
  65. package/dist/browser-dev/getProductOptions.mjs +248 -226
  66. package/dist/browser-dev/getProductOptions.mjs.map +1 -1
  67. package/dist/browser-dev/index.mjs +15 -70
  68. package/dist/browser-dev/load-script.mjs +38 -49
  69. package/dist/browser-dev/load-script.mjs.map +1 -1
  70. package/dist/browser-dev/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.mjs +175 -123
  71. package/dist/browser-dev/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
  72. package/dist/browser-dev/optionValueDecoder.mjs +104 -86
  73. package/dist/browser-dev/optionValueDecoder.mjs.map +1 -1
  74. package/dist/browser-dev/packages/hydrogen-react/package.mjs +6 -0
  75. package/dist/browser-dev/packages/hydrogen-react/package.mjs.map +1 -0
  76. package/dist/browser-dev/parse-metafield.mjs +122 -134
  77. package/dist/browser-dev/parse-metafield.mjs.map +1 -1
  78. package/dist/browser-dev/storefront-api-constants.mjs +6 -5
  79. package/dist/browser-dev/storefront-api-constants.mjs.map +1 -1
  80. package/dist/browser-dev/storefront-client.mjs +62 -102
  81. package/dist/browser-dev/storefront-client.mjs.map +1 -1
  82. package/dist/browser-dev/tracking-utils.mjs +68 -88
  83. package/dist/browser-dev/tracking-utils.mjs.map +1 -1
  84. package/dist/browser-dev/useCartAPIStateMachine.mjs +188 -346
  85. package/dist/browser-dev/useCartAPIStateMachine.mjs.map +1 -1
  86. package/dist/browser-dev/useCartActions.mjs +197 -172
  87. package/dist/browser-dev/useCartActions.mjs.map +1 -1
  88. package/dist/browser-dev/useMachine.mjs +50 -62
  89. package/dist/browser-dev/useMachine.mjs.map +1 -1
  90. package/dist/browser-dev/useMoney.mjs +176 -154
  91. package/dist/browser-dev/useMoney.mjs.map +1 -1
  92. package/dist/browser-dev/useSelectedOptionInUrlParam.mjs +17 -27
  93. package/dist/browser-dev/useSelectedOptionInUrlParam.mjs.map +1 -1
  94. package/dist/browser-dev/useShopifyCookies.mjs +123 -138
  95. package/dist/browser-dev/useShopifyCookies.mjs.map +1 -1
  96. package/dist/browser-prod/AddToCartButton.mjs +60 -71
  97. package/dist/browser-prod/AddToCartButton.mjs.map +1 -1
  98. package/dist/browser-prod/BaseButton.mjs +20 -26
  99. package/dist/browser-prod/BaseButton.mjs.map +1 -1
  100. package/dist/browser-prod/BuyNowButton.mjs +40 -45
  101. package/dist/browser-prod/BuyNowButton.mjs.map +1 -1
  102. package/dist/browser-prod/CartCheckoutButton.mjs +28 -23
  103. package/dist/browser-prod/CartCheckoutButton.mjs.map +1 -1
  104. package/dist/browser-prod/CartCost.mjs +26 -22
  105. package/dist/browser-prod/CartCost.mjs.map +1 -1
  106. package/dist/browser-prod/CartLineProvider.mjs +23 -18
  107. package/dist/browser-prod/CartLineProvider.mjs.map +1 -1
  108. package/dist/browser-prod/CartLineQuantity.mjs +18 -9
  109. package/dist/browser-prod/CartLineQuantity.mjs.map +1 -1
  110. package/dist/browser-prod/CartLineQuantityAdjustButton.mjs +48 -45
  111. package/dist/browser-prod/CartLineQuantityAdjustButton.mjs.map +1 -1
  112. package/dist/browser-prod/CartProvider.mjs +315 -385
  113. package/dist/browser-prod/CartProvider.mjs.map +1 -1
  114. package/dist/browser-prod/ExternalVideo.mjs +35 -47
  115. package/dist/browser-prod/ExternalVideo.mjs.map +1 -1
  116. package/dist/browser-prod/Image.mjs +326 -325
  117. package/dist/browser-prod/Image.mjs.map +1 -1
  118. package/dist/browser-prod/MediaFile.mjs +44 -63
  119. package/dist/browser-prod/MediaFile.mjs.map +1 -1
  120. package/dist/browser-prod/ModelViewer.mjs +117 -135
  121. package/dist/browser-prod/ModelViewer.mjs.map +1 -1
  122. package/dist/browser-prod/Money.mjs +53 -39
  123. package/dist/browser-prod/Money.mjs.map +1 -1
  124. package/dist/browser-prod/ProductPrice.mjs +44 -61
  125. package/dist/browser-prod/ProductPrice.mjs.map +1 -1
  126. package/dist/browser-prod/ProductProvider.mjs +147 -179
  127. package/dist/browser-prod/ProductProvider.mjs.map +1 -1
  128. package/dist/browser-prod/RichText.components.mjs +36 -46
  129. package/dist/browser-prod/RichText.components.mjs.map +1 -1
  130. package/dist/browser-prod/RichText.mjs +111 -154
  131. package/dist/browser-prod/RichText.mjs.map +1 -1
  132. package/dist/browser-prod/ShopPayButton.mjs +53 -81
  133. package/dist/browser-prod/ShopPayButton.mjs.map +1 -1
  134. package/dist/browser-prod/ShopifyProvider.mjs +71 -84
  135. package/dist/browser-prod/ShopifyProvider.mjs.map +1 -1
  136. package/dist/browser-prod/Video.mjs +35 -52
  137. package/dist/browser-prod/Video.mjs.map +1 -1
  138. package/dist/browser-prod/analytics-constants.mjs +41 -43
  139. package/dist/browser-prod/analytics-constants.mjs.map +1 -1
  140. package/dist/browser-prod/analytics-schema-custom-storefront-customer-tracking.mjs +127 -214
  141. package/dist/browser-prod/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -1
  142. package/dist/browser-prod/analytics-schema-trekkie-storefront-page-view.mjs +39 -50
  143. package/dist/browser-prod/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -1
  144. package/dist/browser-prod/analytics-utils.mjs +78 -56
  145. package/dist/browser-prod/analytics-utils.mjs.map +1 -1
  146. package/dist/browser-prod/analytics.mjs +111 -153
  147. package/dist/browser-prod/analytics.mjs.map +1 -1
  148. package/dist/browser-prod/cart-constants.mjs +11 -15
  149. package/dist/browser-prod/cart-constants.mjs.map +1 -1
  150. package/dist/browser-prod/cart-hooks.mjs +42 -57
  151. package/dist/browser-prod/cart-hooks.mjs.map +1 -1
  152. package/dist/browser-prod/cart-queries.mjs +28 -66
  153. package/dist/browser-prod/cart-queries.mjs.map +1 -1
  154. package/dist/browser-prod/codegen.helpers.mjs +31 -20
  155. package/dist/browser-prod/codegen.helpers.mjs.map +1 -1
  156. package/dist/browser-prod/cookies-utils.mjs +44 -42
  157. package/dist/browser-prod/cookies-utils.mjs.map +1 -1
  158. package/dist/browser-prod/flatten-connection.mjs +23 -25
  159. package/dist/browser-prod/flatten-connection.mjs.map +1 -1
  160. package/dist/browser-prod/getProductOptions.mjs +248 -226
  161. package/dist/browser-prod/getProductOptions.mjs.map +1 -1
  162. package/dist/browser-prod/index.mjs +15 -70
  163. package/dist/browser-prod/load-script.mjs +38 -49
  164. package/dist/browser-prod/load-script.mjs.map +1 -1
  165. package/dist/browser-prod/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.mjs +175 -123
  166. package/dist/browser-prod/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
  167. package/dist/browser-prod/optionValueDecoder.mjs +104 -86
  168. package/dist/browser-prod/optionValueDecoder.mjs.map +1 -1
  169. package/dist/browser-prod/packages/hydrogen-react/package.mjs +6 -0
  170. package/dist/browser-prod/packages/hydrogen-react/package.mjs.map +1 -0
  171. package/dist/browser-prod/parse-metafield.mjs +134 -146
  172. package/dist/browser-prod/parse-metafield.mjs.map +1 -1
  173. package/dist/browser-prod/storefront-api-constants.mjs +6 -5
  174. package/dist/browser-prod/storefront-api-constants.mjs.map +1 -1
  175. package/dist/browser-prod/storefront-client.mjs +56 -84
  176. package/dist/browser-prod/storefront-client.mjs.map +1 -1
  177. package/dist/browser-prod/tracking-utils.mjs +68 -88
  178. package/dist/browser-prod/tracking-utils.mjs.map +1 -1
  179. package/dist/browser-prod/useCartAPIStateMachine.mjs +188 -346
  180. package/dist/browser-prod/useCartAPIStateMachine.mjs.map +1 -1
  181. package/dist/browser-prod/useCartActions.mjs +197 -172
  182. package/dist/browser-prod/useCartActions.mjs.map +1 -1
  183. package/dist/browser-prod/useMachine.mjs +50 -62
  184. package/dist/browser-prod/useMachine.mjs.map +1 -1
  185. package/dist/browser-prod/useMoney.mjs +176 -154
  186. package/dist/browser-prod/useMoney.mjs.map +1 -1
  187. package/dist/browser-prod/useSelectedOptionInUrlParam.mjs +17 -27
  188. package/dist/browser-prod/useSelectedOptionInUrlParam.mjs.map +1 -1
  189. package/dist/browser-prod/useShopifyCookies.mjs +123 -138
  190. package/dist/browser-prod/useShopifyCookies.mjs.map +1 -1
  191. package/dist/node-dev/AddToCartButton.js +64 -73
  192. package/dist/node-dev/AddToCartButton.js.map +1 -1
  193. package/dist/node-dev/AddToCartButton.mjs +60 -71
  194. package/dist/node-dev/AddToCartButton.mjs.map +1 -1
  195. package/dist/node-dev/BaseButton.js +21 -26
  196. package/dist/node-dev/BaseButton.js.map +1 -1
  197. package/dist/node-dev/BaseButton.mjs +20 -26
  198. package/dist/node-dev/BaseButton.mjs.map +1 -1
  199. package/dist/node-dev/BuyNowButton.js +42 -46
  200. package/dist/node-dev/BuyNowButton.js.map +1 -1
  201. package/dist/node-dev/BuyNowButton.mjs +40 -45
  202. package/dist/node-dev/BuyNowButton.mjs.map +1 -1
  203. package/dist/node-dev/CartCheckoutButton.js +30 -24
  204. package/dist/node-dev/CartCheckoutButton.js.map +1 -1
  205. package/dist/node-dev/CartCheckoutButton.mjs +28 -23
  206. package/dist/node-dev/CartCheckoutButton.mjs.map +1 -1
  207. package/dist/node-dev/CartCost.js +27 -22
  208. package/dist/node-dev/CartCost.js.map +1 -1
  209. package/dist/node-dev/CartCost.mjs +26 -22
  210. package/dist/node-dev/CartCost.mjs.map +1 -1
  211. package/dist/node-dev/CartLineProvider.js +24 -17
  212. package/dist/node-dev/CartLineProvider.js.map +1 -1
  213. package/dist/node-dev/CartLineProvider.mjs +23 -18
  214. package/dist/node-dev/CartLineProvider.mjs.map +1 -1
  215. package/dist/node-dev/CartLineQuantity.js +19 -9
  216. package/dist/node-dev/CartLineQuantity.js.map +1 -1
  217. package/dist/node-dev/CartLineQuantity.mjs +18 -9
  218. package/dist/node-dev/CartLineQuantity.mjs.map +1 -1
  219. package/dist/node-dev/CartLineQuantityAdjustButton.js +50 -46
  220. package/dist/node-dev/CartLineQuantityAdjustButton.js.map +1 -1
  221. package/dist/node-dev/CartLineQuantityAdjustButton.mjs +48 -45
  222. package/dist/node-dev/CartLineQuantityAdjustButton.mjs.map +1 -1
  223. package/dist/node-dev/CartProvider.js +317 -385
  224. package/dist/node-dev/CartProvider.js.map +1 -1
  225. package/dist/node-dev/CartProvider.mjs +315 -385
  226. package/dist/node-dev/CartProvider.mjs.map +1 -1
  227. package/dist/node-dev/ExternalVideo.js +36 -47
  228. package/dist/node-dev/ExternalVideo.js.map +1 -1
  229. package/dist/node-dev/ExternalVideo.mjs +35 -47
  230. package/dist/node-dev/ExternalVideo.mjs.map +1 -1
  231. package/dist/node-dev/Image.js +337 -355
  232. package/dist/node-dev/Image.js.map +1 -1
  233. package/dist/node-dev/Image.mjs +335 -340
  234. package/dist/node-dev/Image.mjs.map +1 -1
  235. package/dist/node-dev/MediaFile.js +42 -63
  236. package/dist/node-dev/MediaFile.js.map +1 -1
  237. package/dist/node-dev/MediaFile.mjs +39 -61
  238. package/dist/node-dev/MediaFile.mjs.map +1 -1
  239. package/dist/node-dev/ModelViewer.js +116 -139
  240. package/dist/node-dev/ModelViewer.js.map +1 -1
  241. package/dist/node-dev/ModelViewer.mjs +115 -139
  242. package/dist/node-dev/ModelViewer.mjs.map +1 -1
  243. package/dist/node-dev/Money.js +54 -39
  244. package/dist/node-dev/Money.js.map +1 -1
  245. package/dist/node-dev/Money.mjs +53 -39
  246. package/dist/node-dev/Money.mjs.map +1 -1
  247. package/dist/node-dev/ProductPrice.js +45 -61
  248. package/dist/node-dev/ProductPrice.js.map +1 -1
  249. package/dist/node-dev/ProductPrice.mjs +44 -61
  250. package/dist/node-dev/ProductPrice.mjs.map +1 -1
  251. package/dist/node-dev/ProductProvider.js +148 -178
  252. package/dist/node-dev/ProductProvider.js.map +1 -1
  253. package/dist/node-dev/ProductProvider.mjs +147 -179
  254. package/dist/node-dev/ProductProvider.mjs.map +1 -1
  255. package/dist/node-dev/RichText.components.js +37 -46
  256. package/dist/node-dev/RichText.components.js.map +1 -1
  257. package/dist/node-dev/RichText.components.mjs +36 -46
  258. package/dist/node-dev/RichText.components.mjs.map +1 -1
  259. package/dist/node-dev/RichText.js +112 -154
  260. package/dist/node-dev/RichText.js.map +1 -1
  261. package/dist/node-dev/RichText.mjs +111 -154
  262. package/dist/node-dev/RichText.mjs.map +1 -1
  263. package/dist/node-dev/ShopPayButton.js +54 -81
  264. package/dist/node-dev/ShopPayButton.js.map +1 -1
  265. package/dist/node-dev/ShopPayButton.mjs +53 -81
  266. package/dist/node-dev/ShopPayButton.mjs.map +1 -1
  267. package/dist/node-dev/ShopifyProvider.js +73 -83
  268. package/dist/node-dev/ShopifyProvider.js.map +1 -1
  269. package/dist/node-dev/ShopifyProvider.mjs +71 -84
  270. package/dist/node-dev/ShopifyProvider.mjs.map +1 -1
  271. package/dist/node-dev/Video.js +36 -52
  272. package/dist/node-dev/Video.js.map +1 -1
  273. package/dist/node-dev/Video.mjs +35 -52
  274. package/dist/node-dev/Video.mjs.map +1 -1
  275. package/dist/node-dev/_virtual/_rolldown/runtime.js +23 -0
  276. package/dist/node-dev/analytics-constants.js +40 -39
  277. package/dist/node-dev/analytics-constants.js.map +1 -1
  278. package/dist/node-dev/analytics-constants.mjs +41 -43
  279. package/dist/node-dev/analytics-constants.mjs.map +1 -1
  280. package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.js +128 -210
  281. package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.js.map +1 -1
  282. package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.mjs +127 -214
  283. package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -1
  284. package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.js +40 -51
  285. package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.js.map +1 -1
  286. package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.mjs +39 -50
  287. package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -1
  288. package/dist/node-dev/analytics-utils.js +77 -52
  289. package/dist/node-dev/analytics-utils.js.map +1 -1
  290. package/dist/node-dev/analytics-utils.mjs +78 -56
  291. package/dist/node-dev/analytics-utils.mjs.map +1 -1
  292. package/dist/node-dev/analytics.js +114 -156
  293. package/dist/node-dev/analytics.js.map +1 -1
  294. package/dist/node-dev/analytics.mjs +112 -155
  295. package/dist/node-dev/analytics.mjs.map +1 -1
  296. package/dist/node-dev/cart-constants.js +10 -9
  297. package/dist/node-dev/cart-constants.js.map +1 -1
  298. package/dist/node-dev/cart-constants.mjs +11 -15
  299. package/dist/node-dev/cart-constants.mjs.map +1 -1
  300. package/dist/node-dev/cart-hooks.js +43 -57
  301. package/dist/node-dev/cart-hooks.js.map +1 -1
  302. package/dist/node-dev/cart-hooks.mjs +42 -57
  303. package/dist/node-dev/cart-hooks.mjs.map +1 -1
  304. package/dist/node-dev/cart-queries.js +27 -56
  305. package/dist/node-dev/cart-queries.js.map +1 -1
  306. package/dist/node-dev/cart-queries.mjs +28 -66
  307. package/dist/node-dev/cart-queries.mjs.map +1 -1
  308. package/dist/node-dev/codegen.helpers.js +30 -18
  309. package/dist/node-dev/codegen.helpers.js.map +1 -1
  310. package/dist/node-dev/codegen.helpers.mjs +31 -20
  311. package/dist/node-dev/codegen.helpers.mjs.map +1 -1
  312. package/dist/node-dev/cookies-utils.js +45 -42
  313. package/dist/node-dev/cookies-utils.js.map +1 -1
  314. package/dist/node-dev/cookies-utils.mjs +44 -42
  315. package/dist/node-dev/cookies-utils.mjs.map +1 -1
  316. package/dist/node-dev/flatten-connection.js +22 -28
  317. package/dist/node-dev/flatten-connection.js.map +1 -1
  318. package/dist/node-dev/flatten-connection.mjs +23 -29
  319. package/dist/node-dev/flatten-connection.mjs.map +1 -1
  320. package/dist/node-dev/getProductOptions.js +248 -224
  321. package/dist/node-dev/getProductOptions.js.map +1 -1
  322. package/dist/node-dev/getProductOptions.mjs +248 -226
  323. package/dist/node-dev/getProductOptions.mjs.map +1 -1
  324. package/dist/node-dev/index.js +88 -90
  325. package/dist/node-dev/index.mjs +15 -70
  326. package/dist/node-dev/load-script.js +38 -48
  327. package/dist/node-dev/load-script.js.map +1 -1
  328. package/dist/node-dev/load-script.mjs +38 -49
  329. package/dist/node-dev/load-script.mjs.map +1 -1
  330. package/dist/node-dev/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.js +185 -124
  331. package/dist/node-dev/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.js.map +1 -1
  332. package/dist/node-dev/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.mjs +175 -123
  333. package/dist/node-dev/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
  334. package/dist/node-dev/optionValueDecoder.js +103 -84
  335. package/dist/node-dev/optionValueDecoder.js.map +1 -1
  336. package/dist/node-dev/optionValueDecoder.mjs +104 -86
  337. package/dist/node-dev/optionValueDecoder.mjs.map +1 -1
  338. package/dist/node-dev/packages/hydrogen-react/package.js +6 -0
  339. package/dist/node-dev/packages/hydrogen-react/package.js.map +1 -0
  340. package/dist/node-dev/packages/hydrogen-react/package.mjs +6 -0
  341. package/dist/node-dev/packages/hydrogen-react/package.mjs.map +1 -0
  342. package/dist/node-dev/parse-metafield.js +122 -134
  343. package/dist/node-dev/parse-metafield.js.map +1 -1
  344. package/dist/node-dev/parse-metafield.mjs +122 -134
  345. package/dist/node-dev/parse-metafield.mjs.map +1 -1
  346. package/dist/node-dev/storefront-api-constants.js +5 -4
  347. package/dist/node-dev/storefront-api-constants.js.map +1 -1
  348. package/dist/node-dev/storefront-api-constants.mjs +6 -5
  349. package/dist/node-dev/storefront-api-constants.mjs.map +1 -1
  350. package/dist/node-dev/storefront-client.js +62 -101
  351. package/dist/node-dev/storefront-client.js.map +1 -1
  352. package/dist/node-dev/storefront-client.mjs +62 -102
  353. package/dist/node-dev/storefront-client.mjs.map +1 -1
  354. package/dist/node-dev/tracking-utils.js +67 -85
  355. package/dist/node-dev/tracking-utils.js.map +1 -1
  356. package/dist/node-dev/tracking-utils.mjs +68 -88
  357. package/dist/node-dev/tracking-utils.mjs.map +1 -1
  358. package/dist/node-dev/useCartAPIStateMachine.js +192 -349
  359. package/dist/node-dev/useCartAPIStateMachine.js.map +1 -1
  360. package/dist/node-dev/useCartAPIStateMachine.mjs +188 -346
  361. package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -1
  362. package/dist/node-dev/useCartActions.js +198 -172
  363. package/dist/node-dev/useCartActions.js.map +1 -1
  364. package/dist/node-dev/useCartActions.mjs +197 -172
  365. package/dist/node-dev/useCartActions.mjs.map +1 -1
  366. package/dist/node-dev/useMachine.js +50 -61
  367. package/dist/node-dev/useMachine.js.map +1 -1
  368. package/dist/node-dev/useMachine.mjs +50 -62
  369. package/dist/node-dev/useMachine.mjs.map +1 -1
  370. package/dist/node-dev/useMoney.js +177 -154
  371. package/dist/node-dev/useMoney.js.map +1 -1
  372. package/dist/node-dev/useMoney.mjs +176 -154
  373. package/dist/node-dev/useMoney.mjs.map +1 -1
  374. package/dist/node-dev/useSelectedOptionInUrlParam.js +18 -27
  375. package/dist/node-dev/useSelectedOptionInUrlParam.js.map +1 -1
  376. package/dist/node-dev/useSelectedOptionInUrlParam.mjs +17 -27
  377. package/dist/node-dev/useSelectedOptionInUrlParam.mjs.map +1 -1
  378. package/dist/node-dev/useShopifyCookies.js +124 -138
  379. package/dist/node-dev/useShopifyCookies.js.map +1 -1
  380. package/dist/node-dev/useShopifyCookies.mjs +123 -138
  381. package/dist/node-dev/useShopifyCookies.mjs.map +1 -1
  382. package/dist/node-prod/AddToCartButton.js +64 -73
  383. package/dist/node-prod/AddToCartButton.js.map +1 -1
  384. package/dist/node-prod/AddToCartButton.mjs +60 -71
  385. package/dist/node-prod/AddToCartButton.mjs.map +1 -1
  386. package/dist/node-prod/BaseButton.js +21 -26
  387. package/dist/node-prod/BaseButton.js.map +1 -1
  388. package/dist/node-prod/BaseButton.mjs +20 -26
  389. package/dist/node-prod/BaseButton.mjs.map +1 -1
  390. package/dist/node-prod/BuyNowButton.js +42 -46
  391. package/dist/node-prod/BuyNowButton.js.map +1 -1
  392. package/dist/node-prod/BuyNowButton.mjs +40 -45
  393. package/dist/node-prod/BuyNowButton.mjs.map +1 -1
  394. package/dist/node-prod/CartCheckoutButton.js +30 -24
  395. package/dist/node-prod/CartCheckoutButton.js.map +1 -1
  396. package/dist/node-prod/CartCheckoutButton.mjs +28 -23
  397. package/dist/node-prod/CartCheckoutButton.mjs.map +1 -1
  398. package/dist/node-prod/CartCost.js +27 -22
  399. package/dist/node-prod/CartCost.js.map +1 -1
  400. package/dist/node-prod/CartCost.mjs +26 -22
  401. package/dist/node-prod/CartCost.mjs.map +1 -1
  402. package/dist/node-prod/CartLineProvider.js +24 -17
  403. package/dist/node-prod/CartLineProvider.js.map +1 -1
  404. package/dist/node-prod/CartLineProvider.mjs +23 -18
  405. package/dist/node-prod/CartLineProvider.mjs.map +1 -1
  406. package/dist/node-prod/CartLineQuantity.js +19 -9
  407. package/dist/node-prod/CartLineQuantity.js.map +1 -1
  408. package/dist/node-prod/CartLineQuantity.mjs +18 -9
  409. package/dist/node-prod/CartLineQuantity.mjs.map +1 -1
  410. package/dist/node-prod/CartLineQuantityAdjustButton.js +50 -46
  411. package/dist/node-prod/CartLineQuantityAdjustButton.js.map +1 -1
  412. package/dist/node-prod/CartLineQuantityAdjustButton.mjs +48 -45
  413. package/dist/node-prod/CartLineQuantityAdjustButton.mjs.map +1 -1
  414. package/dist/node-prod/CartProvider.js +317 -385
  415. package/dist/node-prod/CartProvider.js.map +1 -1
  416. package/dist/node-prod/CartProvider.mjs +315 -385
  417. package/dist/node-prod/CartProvider.mjs.map +1 -1
  418. package/dist/node-prod/ExternalVideo.js +36 -47
  419. package/dist/node-prod/ExternalVideo.js.map +1 -1
  420. package/dist/node-prod/ExternalVideo.mjs +35 -47
  421. package/dist/node-prod/ExternalVideo.mjs.map +1 -1
  422. package/dist/node-prod/Image.js +328 -340
  423. package/dist/node-prod/Image.js.map +1 -1
  424. package/dist/node-prod/Image.mjs +326 -325
  425. package/dist/node-prod/Image.mjs.map +1 -1
  426. package/dist/node-prod/MediaFile.js +47 -65
  427. package/dist/node-prod/MediaFile.js.map +1 -1
  428. package/dist/node-prod/MediaFile.mjs +44 -63
  429. package/dist/node-prod/MediaFile.mjs.map +1 -1
  430. package/dist/node-prod/ModelViewer.js +118 -135
  431. package/dist/node-prod/ModelViewer.js.map +1 -1
  432. package/dist/node-prod/ModelViewer.mjs +117 -135
  433. package/dist/node-prod/ModelViewer.mjs.map +1 -1
  434. package/dist/node-prod/Money.js +54 -39
  435. package/dist/node-prod/Money.js.map +1 -1
  436. package/dist/node-prod/Money.mjs +53 -39
  437. package/dist/node-prod/Money.mjs.map +1 -1
  438. package/dist/node-prod/ProductPrice.js +45 -61
  439. package/dist/node-prod/ProductPrice.js.map +1 -1
  440. package/dist/node-prod/ProductPrice.mjs +44 -61
  441. package/dist/node-prod/ProductPrice.mjs.map +1 -1
  442. package/dist/node-prod/ProductProvider.js +148 -178
  443. package/dist/node-prod/ProductProvider.js.map +1 -1
  444. package/dist/node-prod/ProductProvider.mjs +147 -179
  445. package/dist/node-prod/ProductProvider.mjs.map +1 -1
  446. package/dist/node-prod/RichText.components.js +37 -46
  447. package/dist/node-prod/RichText.components.js.map +1 -1
  448. package/dist/node-prod/RichText.components.mjs +36 -46
  449. package/dist/node-prod/RichText.components.mjs.map +1 -1
  450. package/dist/node-prod/RichText.js +112 -154
  451. package/dist/node-prod/RichText.js.map +1 -1
  452. package/dist/node-prod/RichText.mjs +111 -154
  453. package/dist/node-prod/RichText.mjs.map +1 -1
  454. package/dist/node-prod/ShopPayButton.js +54 -81
  455. package/dist/node-prod/ShopPayButton.js.map +1 -1
  456. package/dist/node-prod/ShopPayButton.mjs +53 -81
  457. package/dist/node-prod/ShopPayButton.mjs.map +1 -1
  458. package/dist/node-prod/ShopifyProvider.js +73 -83
  459. package/dist/node-prod/ShopifyProvider.js.map +1 -1
  460. package/dist/node-prod/ShopifyProvider.mjs +71 -84
  461. package/dist/node-prod/ShopifyProvider.mjs.map +1 -1
  462. package/dist/node-prod/Video.js +36 -52
  463. package/dist/node-prod/Video.js.map +1 -1
  464. package/dist/node-prod/Video.mjs +35 -52
  465. package/dist/node-prod/Video.mjs.map +1 -1
  466. package/dist/node-prod/_virtual/_rolldown/runtime.js +23 -0
  467. package/dist/node-prod/analytics-constants.js +40 -39
  468. package/dist/node-prod/analytics-constants.js.map +1 -1
  469. package/dist/node-prod/analytics-constants.mjs +41 -43
  470. package/dist/node-prod/analytics-constants.mjs.map +1 -1
  471. package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.js +128 -210
  472. package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.js.map +1 -1
  473. package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.mjs +127 -214
  474. package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -1
  475. package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.js +40 -51
  476. package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.js.map +1 -1
  477. package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.mjs +39 -50
  478. package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -1
  479. package/dist/node-prod/analytics-utils.js +77 -52
  480. package/dist/node-prod/analytics-utils.js.map +1 -1
  481. package/dist/node-prod/analytics-utils.mjs +78 -56
  482. package/dist/node-prod/analytics-utils.mjs.map +1 -1
  483. package/dist/node-prod/analytics.js +113 -154
  484. package/dist/node-prod/analytics.js.map +1 -1
  485. package/dist/node-prod/analytics.mjs +111 -153
  486. package/dist/node-prod/analytics.mjs.map +1 -1
  487. package/dist/node-prod/cart-constants.js +10 -9
  488. package/dist/node-prod/cart-constants.js.map +1 -1
  489. package/dist/node-prod/cart-constants.mjs +11 -15
  490. package/dist/node-prod/cart-constants.mjs.map +1 -1
  491. package/dist/node-prod/cart-hooks.js +43 -57
  492. package/dist/node-prod/cart-hooks.js.map +1 -1
  493. package/dist/node-prod/cart-hooks.mjs +42 -57
  494. package/dist/node-prod/cart-hooks.mjs.map +1 -1
  495. package/dist/node-prod/cart-queries.js +27 -56
  496. package/dist/node-prod/cart-queries.js.map +1 -1
  497. package/dist/node-prod/cart-queries.mjs +28 -66
  498. package/dist/node-prod/cart-queries.mjs.map +1 -1
  499. package/dist/node-prod/codegen.helpers.js +30 -18
  500. package/dist/node-prod/codegen.helpers.js.map +1 -1
  501. package/dist/node-prod/codegen.helpers.mjs +31 -20
  502. package/dist/node-prod/codegen.helpers.mjs.map +1 -1
  503. package/dist/node-prod/cookies-utils.js +45 -42
  504. package/dist/node-prod/cookies-utils.js.map +1 -1
  505. package/dist/node-prod/cookies-utils.mjs +44 -42
  506. package/dist/node-prod/cookies-utils.mjs.map +1 -1
  507. package/dist/node-prod/flatten-connection.js +22 -24
  508. package/dist/node-prod/flatten-connection.js.map +1 -1
  509. package/dist/node-prod/flatten-connection.mjs +23 -25
  510. package/dist/node-prod/flatten-connection.mjs.map +1 -1
  511. package/dist/node-prod/getProductOptions.js +248 -224
  512. package/dist/node-prod/getProductOptions.js.map +1 -1
  513. package/dist/node-prod/getProductOptions.mjs +248 -226
  514. package/dist/node-prod/getProductOptions.mjs.map +1 -1
  515. package/dist/node-prod/index.js +88 -90
  516. package/dist/node-prod/index.mjs +15 -70
  517. package/dist/node-prod/load-script.js +38 -48
  518. package/dist/node-prod/load-script.js.map +1 -1
  519. package/dist/node-prod/load-script.mjs +38 -49
  520. package/dist/node-prod/load-script.mjs.map +1 -1
  521. package/dist/node-prod/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.js +185 -124
  522. package/dist/node-prod/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.js.map +1 -1
  523. package/dist/node-prod/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.mjs +175 -123
  524. package/dist/node-prod/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
  525. package/dist/node-prod/optionValueDecoder.js +103 -84
  526. package/dist/node-prod/optionValueDecoder.js.map +1 -1
  527. package/dist/node-prod/optionValueDecoder.mjs +104 -86
  528. package/dist/node-prod/optionValueDecoder.mjs.map +1 -1
  529. package/dist/node-prod/packages/hydrogen-react/package.js +6 -0
  530. package/dist/node-prod/packages/hydrogen-react/package.js.map +1 -0
  531. package/dist/node-prod/packages/hydrogen-react/package.mjs +6 -0
  532. package/dist/node-prod/packages/hydrogen-react/package.mjs.map +1 -0
  533. package/dist/node-prod/parse-metafield.js +134 -146
  534. package/dist/node-prod/parse-metafield.js.map +1 -1
  535. package/dist/node-prod/parse-metafield.mjs +134 -146
  536. package/dist/node-prod/parse-metafield.mjs.map +1 -1
  537. package/dist/node-prod/storefront-api-constants.js +5 -4
  538. package/dist/node-prod/storefront-api-constants.js.map +1 -1
  539. package/dist/node-prod/storefront-api-constants.mjs +6 -5
  540. package/dist/node-prod/storefront-api-constants.mjs.map +1 -1
  541. package/dist/node-prod/storefront-client.js +56 -83
  542. package/dist/node-prod/storefront-client.js.map +1 -1
  543. package/dist/node-prod/storefront-client.mjs +56 -84
  544. package/dist/node-prod/storefront-client.mjs.map +1 -1
  545. package/dist/node-prod/tracking-utils.js +67 -85
  546. package/dist/node-prod/tracking-utils.js.map +1 -1
  547. package/dist/node-prod/tracking-utils.mjs +68 -88
  548. package/dist/node-prod/tracking-utils.mjs.map +1 -1
  549. package/dist/node-prod/useCartAPIStateMachine.js +192 -349
  550. package/dist/node-prod/useCartAPIStateMachine.js.map +1 -1
  551. package/dist/node-prod/useCartAPIStateMachine.mjs +188 -346
  552. package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -1
  553. package/dist/node-prod/useCartActions.js +198 -172
  554. package/dist/node-prod/useCartActions.js.map +1 -1
  555. package/dist/node-prod/useCartActions.mjs +197 -172
  556. package/dist/node-prod/useCartActions.mjs.map +1 -1
  557. package/dist/node-prod/useMachine.js +50 -61
  558. package/dist/node-prod/useMachine.js.map +1 -1
  559. package/dist/node-prod/useMachine.mjs +50 -62
  560. package/dist/node-prod/useMachine.mjs.map +1 -1
  561. package/dist/node-prod/useMoney.js +177 -154
  562. package/dist/node-prod/useMoney.js.map +1 -1
  563. package/dist/node-prod/useMoney.mjs +176 -154
  564. package/dist/node-prod/useMoney.mjs.map +1 -1
  565. package/dist/node-prod/useSelectedOptionInUrlParam.js +18 -27
  566. package/dist/node-prod/useSelectedOptionInUrlParam.js.map +1 -1
  567. package/dist/node-prod/useSelectedOptionInUrlParam.mjs +17 -27
  568. package/dist/node-prod/useSelectedOptionInUrlParam.mjs.map +1 -1
  569. package/dist/node-prod/useShopifyCookies.js +124 -138
  570. package/dist/node-prod/useShopifyCookies.js.map +1 -1
  571. package/dist/node-prod/useShopifyCookies.mjs +123 -138
  572. package/dist/node-prod/useShopifyCookies.mjs.map +1 -1
  573. package/dist/umd/hydrogen-react.dev.js +3930 -4418
  574. package/dist/umd/hydrogen-react.dev.js.map +1 -1
  575. package/dist/umd/hydrogen-react.prod.js +35 -49
  576. package/dist/umd/hydrogen-react.prod.js.map +1 -1
  577. package/package.json +5 -5
  578. package/dist/browser-dev/index.mjs.map +0 -1
  579. package/dist/browser-dev/packages/hydrogen-react/package.json.mjs +0 -5
  580. package/dist/browser-dev/packages/hydrogen-react/package.json.mjs.map +0 -1
  581. package/dist/browser-prod/index.mjs.map +0 -1
  582. package/dist/browser-prod/packages/hydrogen-react/package.json.mjs +0 -5
  583. package/dist/browser-prod/packages/hydrogen-react/package.json.mjs.map +0 -1
  584. package/dist/node-dev/index.js.map +0 -1
  585. package/dist/node-dev/index.mjs.map +0 -1
  586. package/dist/node-dev/packages/hydrogen-react/package.json.js +0 -5
  587. package/dist/node-dev/packages/hydrogen-react/package.json.js.map +0 -1
  588. package/dist/node-dev/packages/hydrogen-react/package.json.mjs +0 -5
  589. package/dist/node-dev/packages/hydrogen-react/package.json.mjs.map +0 -1
  590. package/dist/node-prod/index.js.map +0 -1
  591. package/dist/node-prod/index.mjs.map +0 -1
  592. package/dist/node-prod/packages/hydrogen-react/package.json.js +0 -5
  593. package/dist/node-prod/packages/hydrogen-react/package.json.js.map +0 -1
  594. package/dist/node-prod/packages/hydrogen-react/package.json.mjs +0 -5
  595. package/dist/node-prod/packages/hydrogen-react/package.json.mjs.map +0 -1
@@ -1,49 +1,44 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useState, useEffect, useCallback } from "react";
3
1
  import { useCart } from "./CartProvider.mjs";
4
2
  import { BaseButton } from "./BaseButton.mjs";
3
+ import { useCallback, useEffect, useState } from "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ //#region src/BuyNowButton.tsx
6
+ /**
7
+ * The `BuyNowButton` component renders a button that adds an item to the cart and redirects the customer to checkout.
8
+ * Must be a child of a `CartProvider` component.
9
+ * @publicDocs
10
+ */
5
11
  function BuyNowButton(props) {
6
- const { cartCreate, checkoutUrl } = useCart();
7
- const [loading, setLoading] = useState(false);
8
- const {
9
- quantity,
10
- variantId,
11
- sellingPlanId,
12
- onClick,
13
- attributes,
14
- children,
15
- ...passthroughProps
16
- } = props;
17
- useEffect(() => {
18
- if (loading && checkoutUrl) {
19
- window.location.href = checkoutUrl;
20
- }
21
- }, [loading, checkoutUrl]);
22
- const handleBuyNow = useCallback(() => {
23
- setLoading(true);
24
- cartCreate({
25
- lines: [
26
- {
27
- quantity: quantity ?? 1,
28
- merchandiseId: variantId,
29
- attributes,
30
- sellingPlanId
31
- }
32
- ]
33
- });
34
- }, [cartCreate, quantity, variantId, attributes, sellingPlanId]);
35
- return /* @__PURE__ */ jsx(
36
- BaseButton,
37
- {
38
- disabled: loading ?? passthroughProps.disabled,
39
- ...passthroughProps,
40
- onClick,
41
- defaultOnClick: handleBuyNow,
42
- children
43
- }
44
- );
12
+ const { cartCreate, checkoutUrl } = useCart();
13
+ const [loading, setLoading] = useState(false);
14
+ const { quantity, variantId, sellingPlanId, onClick, attributes, children, ...passthroughProps } = props;
15
+ useEffect(() => {
16
+ if (loading && checkoutUrl) window.location.href = checkoutUrl;
17
+ }, [loading, checkoutUrl]);
18
+ const handleBuyNow = useCallback(() => {
19
+ setLoading(true);
20
+ cartCreate({ lines: [{
21
+ quantity: quantity ?? 1,
22
+ merchandiseId: variantId,
23
+ attributes,
24
+ sellingPlanId
25
+ }] });
26
+ }, [
27
+ cartCreate,
28
+ quantity,
29
+ variantId,
30
+ attributes,
31
+ sellingPlanId
32
+ ]);
33
+ return /* @__PURE__ */ jsx(BaseButton, {
34
+ disabled: loading ?? passthroughProps.disabled,
35
+ ...passthroughProps,
36
+ onClick,
37
+ defaultOnClick: handleBuyNow,
38
+ children
39
+ });
45
40
  }
46
- export {
47
- BuyNowButton
48
- };
49
- //# sourceMappingURL=BuyNowButton.mjs.map
41
+ //#endregion
42
+ export { BuyNowButton };
43
+
44
+ //# sourceMappingURL=BuyNowButton.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"BuyNowButton.mjs","sources":["../../src/BuyNowButton.tsx"],"sourcesContent":["import {useEffect, useState, useCallback} from 'react';\nimport {useCart} from './CartProvider.js';\nimport {\n BaseButton,\n type BaseButtonProps,\n type CustomBaseButtonProps,\n} from './BaseButton.js';\n\ninterface BuyNowButtonPropsBase {\n /** The item quantity. Defaults to 1. */\n quantity?: number;\n /** The ID of the variant. */\n variantId: string;\n /** The selling plan ID of the subscription variant */\n sellingPlanId?: string;\n /** An array of cart line attributes that belong to the item being added to the cart. */\n attributes?: {\n key: string;\n value: string;\n }[];\n}\n\ntype BuyNowButtonProps<AsType extends React.ElementType = 'button'> =\n BuyNowButtonPropsBase & BaseButtonProps<AsType>;\n\n/**\n * The `BuyNowButton` component renders a button that adds an item to the cart and redirects the customer to checkout.\n * Must be a child of a `CartProvider` component.\n * @publicDocs\n */\nexport function BuyNowButton<AsType extends React.ElementType = 'button'>(\n props: BuyNowButtonProps<AsType>,\n): JSX.Element {\n const {cartCreate, checkoutUrl} = useCart();\n const [loading, setLoading] = useState<boolean>(false);\n\n const {\n quantity,\n variantId,\n sellingPlanId,\n onClick,\n attributes,\n children,\n ...passthroughProps\n } = props;\n\n useEffect(() => {\n if (loading && checkoutUrl) {\n window.location.href = checkoutUrl;\n }\n }, [loading, checkoutUrl]);\n\n const handleBuyNow = useCallback(() => {\n setLoading(true);\n cartCreate({\n lines: [\n {\n quantity: quantity ?? 1,\n merchandiseId: variantId,\n attributes,\n sellingPlanId,\n },\n ],\n });\n }, [cartCreate, quantity, variantId, attributes, sellingPlanId]);\n\n return (\n <BaseButton\n // Only certain 'as' types such as 'button' contain `disabled`\n disabled={loading ?? (passthroughProps as {disabled?: boolean}).disabled}\n {...passthroughProps}\n onClick={onClick}\n defaultOnClick={handleBuyNow}\n >\n {children}\n </BaseButton>\n );\n}\n\n// This is only for documentation purposes, and it is not used in the code.\n/** @publicDocs */\nexport interface BuyNowButtonPropsForDocs<\n AsType extends React.ElementType = 'button',\n>\n extends BuyNowButtonPropsBase, CustomBaseButtonProps<AsType> {}\n"],"names":[],"mappings":";;;;AA8BO,SAAS,aACd,OACa;AACb,QAAM,EAAC,YAAY,YAAA,IAAe,QAAA;AAClC,QAAM,CAAC,SAAS,UAAU,IAAI,SAAkB,KAAK;AAErD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD;AAEJ,YAAU,MAAM;AACd,QAAI,WAAW,aAAa;AAC1B,aAAO,SAAS,OAAO;AAAA,IACzB;AAAA,EACF,GAAG,CAAC,SAAS,WAAW,CAAC;AAEzB,QAAM,eAAe,YAAY,MAAM;AACrC,eAAW,IAAI;AACf,eAAW;AAAA,MACT,OAAO;AAAA,QACL;AAAA,UACE,UAAU,YAAY;AAAA,UACtB,eAAe;AAAA,UACf;AAAA,UACA;AAAA,QAAA;AAAA,MACF;AAAA,IACF,CACD;AAAA,EACH,GAAG,CAAC,YAAY,UAAU,WAAW,YAAY,aAAa,CAAC;AAE/D,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MAEC,UAAU,WAAY,iBAA0C;AAAA,MAC/D,GAAG;AAAA,MACJ;AAAA,MACA,gBAAgB;AAAA,MAEf;AAAA,IAAA;AAAA,EAAA;AAGP;"}
1
+ {"version":3,"file":"BuyNowButton.mjs","names":[],"sources":["../../src/BuyNowButton.tsx"],"sourcesContent":["import {useEffect, useState, useCallback} from 'react';\nimport {useCart} from './CartProvider.js';\nimport {\n BaseButton,\n type BaseButtonProps,\n type CustomBaseButtonProps,\n} from './BaseButton.js';\n\ninterface BuyNowButtonPropsBase {\n /** The item quantity. Defaults to 1. */\n quantity?: number;\n /** The ID of the variant. */\n variantId: string;\n /** The selling plan ID of the subscription variant */\n sellingPlanId?: string;\n /** An array of cart line attributes that belong to the item being added to the cart. */\n attributes?: {\n key: string;\n value: string;\n }[];\n}\n\ntype BuyNowButtonProps<AsType extends React.ElementType = 'button'> =\n BuyNowButtonPropsBase & BaseButtonProps<AsType>;\n\n/**\n * The `BuyNowButton` component renders a button that adds an item to the cart and redirects the customer to checkout.\n * Must be a child of a `CartProvider` component.\n * @publicDocs\n */\nexport function BuyNowButton<AsType extends React.ElementType = 'button'>(\n props: BuyNowButtonProps<AsType>,\n): JSX.Element {\n const {cartCreate, checkoutUrl} = useCart();\n const [loading, setLoading] = useState<boolean>(false);\n\n const {\n quantity,\n variantId,\n sellingPlanId,\n onClick,\n attributes,\n children,\n ...passthroughProps\n } = props;\n\n useEffect(() => {\n if (loading && checkoutUrl) {\n window.location.href = checkoutUrl;\n }\n }, [loading, checkoutUrl]);\n\n const handleBuyNow = useCallback(() => {\n setLoading(true);\n cartCreate({\n lines: [\n {\n quantity: quantity ?? 1,\n merchandiseId: variantId,\n attributes,\n sellingPlanId,\n },\n ],\n });\n }, [cartCreate, quantity, variantId, attributes, sellingPlanId]);\n\n return (\n <BaseButton\n // Only certain 'as' types such as 'button' contain `disabled`\n disabled={loading ?? (passthroughProps as {disabled?: boolean}).disabled}\n {...passthroughProps}\n onClick={onClick}\n defaultOnClick={handleBuyNow}\n >\n {children}\n </BaseButton>\n );\n}\n\n// This is only for documentation purposes, and it is not used in the code.\n/** @publicDocs */\nexport interface BuyNowButtonPropsForDocs<\n AsType extends React.ElementType = 'button',\n>\n extends BuyNowButtonPropsBase, CustomBaseButtonProps<AsType> {}\n"],"mappings":";;;;;;;;;;AA8BA,SAAgB,aACd,OACa;CACb,MAAM,EAAC,YAAY,gBAAe,SAAS;CAC3C,MAAM,CAAC,SAAS,cAAc,SAAkB,MAAM;CAEtD,MAAM,EACJ,UACA,WACA,eACA,SACA,YACA,UACA,GAAG,qBACD;AAEJ,iBAAgB;AACd,MAAI,WAAW,YACb,QAAO,SAAS,OAAO;IAExB,CAAC,SAAS,YAAY,CAAC;CAE1B,MAAM,eAAe,kBAAkB;AACrC,aAAW,KAAK;AAChB,aAAW,EACT,OAAO,CACL;GACE,UAAU,YAAY;GACtB,eAAe;GACf;GACA;GACD,CACF,EACF,CAAC;IACD;EAAC;EAAY;EAAU;EAAW;EAAY;EAAc,CAAC;AAEhE,QACE,oBAAC,YAAD;EAEE,UAAU,WAAY,iBAA0C;EAChE,GAAI;EACK;EACT,gBAAgB;EAEf;EACU,CAAA"}
@@ -1,27 +1,32 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useState, useEffect } from "react";
3
1
  import { useCart } from "./CartProvider.mjs";
4
2
  import { BaseButton } from "./BaseButton.mjs";
3
+ import { useEffect, useState } from "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ //#region src/CartCheckoutButton.tsx
6
+ /**
7
+ * The `CartCheckoutButton` component renders a button that redirects to the checkout URL for the cart.
8
+ * It must be a descendent of a `CartProvider` component.
9
+ * @publicDocs
10
+ */
5
11
  function CartCheckoutButton(props) {
6
- const [requestedCheckout, setRequestedCheckout] = useState(false);
7
- const { status, checkoutUrl } = useCart();
8
- const { children, ...passthroughProps } = props;
9
- useEffect(() => {
10
- if (requestedCheckout && checkoutUrl && status === "idle") {
11
- window.location.href = checkoutUrl;
12
- }
13
- }, [requestedCheckout, status, checkoutUrl]);
14
- return /* @__PURE__ */ jsx(
15
- BaseButton,
16
- {
17
- ...passthroughProps,
18
- disabled: requestedCheckout || passthroughProps.disabled,
19
- onClick: () => setRequestedCheckout(true),
20
- children
21
- }
22
- );
12
+ const [requestedCheckout, setRequestedCheckout] = useState(false);
13
+ const { status, checkoutUrl } = useCart();
14
+ const { children, ...passthroughProps } = props;
15
+ useEffect(() => {
16
+ if (requestedCheckout && checkoutUrl && status === "idle") window.location.href = checkoutUrl;
17
+ }, [
18
+ requestedCheckout,
19
+ status,
20
+ checkoutUrl
21
+ ]);
22
+ return /* @__PURE__ */ jsx(BaseButton, {
23
+ ...passthroughProps,
24
+ disabled: requestedCheckout || passthroughProps.disabled,
25
+ onClick: () => setRequestedCheckout(true),
26
+ children
27
+ });
23
28
  }
24
- export {
25
- CartCheckoutButton
26
- };
27
- //# sourceMappingURL=CartCheckoutButton.mjs.map
29
+ //#endregion
30
+ export { CartCheckoutButton };
31
+
32
+ //# sourceMappingURL=CartCheckoutButton.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CartCheckoutButton.mjs","sources":["../../src/CartCheckoutButton.tsx"],"sourcesContent":["import {ReactNode, useEffect, useState} from 'react';\nimport {useCart} from './CartProvider.js';\nimport {\n BaseButton,\n type BaseButtonProps,\n type CustomBaseButtonProps,\n} from './BaseButton.js';\n\ntype ChildrenProps = {\n /** A `ReactNode` element. */\n children: ReactNode;\n};\ntype CartCheckoutButtonProps = Omit<BaseButtonProps<'button'>, 'onClick'> &\n ChildrenProps;\n\n/**\n * The `CartCheckoutButton` component renders a button that redirects to the checkout URL for the cart.\n * It must be a descendent of a `CartProvider` component.\n * @publicDocs\n */\nexport function CartCheckoutButton(\n props: CartCheckoutButtonProps,\n): JSX.Element {\n const [requestedCheckout, setRequestedCheckout] = useState(false);\n const {status, checkoutUrl} = useCart();\n const {children, ...passthroughProps} = props;\n\n useEffect(() => {\n if (requestedCheckout && checkoutUrl && status === 'idle') {\n window.location.href = checkoutUrl;\n }\n }, [requestedCheckout, status, checkoutUrl]);\n\n return (\n <BaseButton\n {...passthroughProps}\n disabled={requestedCheckout || passthroughProps.disabled}\n onClick={(): void => setRequestedCheckout(true)}\n >\n {children}\n </BaseButton>\n );\n}\n\n// This is only for documentation purposes, and it is not used in the code.\n// we ignore this issue because it makes the documentation look better than the equivalent `type` that it wants us to convert to\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\n/** @publicDocs */\nexport interface CartCheckoutButtonPropsForDocs<\n AsType extends React.ElementType = 'button',\n> extends Omit<CustomBaseButtonProps<AsType>, 'onClick'> {}\n"],"names":[],"mappings":";;;;AAoBO,SAAS,mBACd,OACa;AACb,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAS,KAAK;AAChE,QAAM,EAAC,QAAQ,YAAA,IAAe,QAAA;AAC9B,QAAM,EAAC,UAAU,GAAG,iBAAA,IAAoB;AAExC,YAAU,MAAM;AACd,QAAI,qBAAqB,eAAe,WAAW,QAAQ;AACzD,aAAO,SAAS,OAAO;AAAA,IACzB;AAAA,EACF,GAAG,CAAC,mBAAmB,QAAQ,WAAW,CAAC;AAE3C,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ,UAAU,qBAAqB,iBAAiB;AAAA,MAChD,SAAS,MAAY,qBAAqB,IAAI;AAAA,MAE7C;AAAA,IAAA;AAAA,EAAA;AAGP;"}
1
+ {"version":3,"file":"CartCheckoutButton.mjs","names":[],"sources":["../../src/CartCheckoutButton.tsx"],"sourcesContent":["import {ReactNode, useEffect, useState} from 'react';\nimport {useCart} from './CartProvider.js';\nimport {\n BaseButton,\n type BaseButtonProps,\n type CustomBaseButtonProps,\n} from './BaseButton.js';\n\ntype ChildrenProps = {\n /** A `ReactNode` element. */\n children: ReactNode;\n};\ntype CartCheckoutButtonProps = Omit<BaseButtonProps<'button'>, 'onClick'> &\n ChildrenProps;\n\n/**\n * The `CartCheckoutButton` component renders a button that redirects to the checkout URL for the cart.\n * It must be a descendent of a `CartProvider` component.\n * @publicDocs\n */\nexport function CartCheckoutButton(\n props: CartCheckoutButtonProps,\n): JSX.Element {\n const [requestedCheckout, setRequestedCheckout] = useState(false);\n const {status, checkoutUrl} = useCart();\n const {children, ...passthroughProps} = props;\n\n useEffect(() => {\n if (requestedCheckout && checkoutUrl && status === 'idle') {\n window.location.href = checkoutUrl;\n }\n }, [requestedCheckout, status, checkoutUrl]);\n\n return (\n <BaseButton\n {...passthroughProps}\n disabled={requestedCheckout || passthroughProps.disabled}\n onClick={(): void => setRequestedCheckout(true)}\n >\n {children}\n </BaseButton>\n );\n}\n\n// This is only for documentation purposes, and it is not used in the code.\n// we ignore this issue because it makes the documentation look better than the equivalent `type` that it wants us to convert to\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\n/** @publicDocs */\nexport interface CartCheckoutButtonPropsForDocs<\n AsType extends React.ElementType = 'button',\n> extends Omit<CustomBaseButtonProps<AsType>, 'onClick'> {}\n"],"mappings":";;;;;;;;;;AAoBA,SAAgB,mBACd,OACa;CACb,MAAM,CAAC,mBAAmB,wBAAwB,SAAS,MAAM;CACjE,MAAM,EAAC,QAAQ,gBAAe,SAAS;CACvC,MAAM,EAAC,UAAU,GAAG,qBAAoB;AAExC,iBAAgB;AACd,MAAI,qBAAqB,eAAe,WAAW,OACjD,QAAO,SAAS,OAAO;IAExB;EAAC;EAAmB;EAAQ;EAAY,CAAC;AAE5C,QACE,oBAAC,YAAD;EACE,GAAI;EACJ,UAAU,qBAAqB,iBAAiB;EAChD,eAAqB,qBAAqB,KAAK;EAE9C;EACU,CAAA"}
@@ -1,25 +1,29 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { Money } from "./Money.mjs";
3
1
  import { useCart } from "./CartProvider.mjs";
2
+ import { Money } from "./Money.mjs";
3
+ import { jsx } from "react/jsx-runtime";
4
+ //#region src/CartCost.tsx
5
+ /**
6
+ * The `CartCost` component renders a `Money` component with the cost associated with the `amountType` prop.
7
+ * If no `amountType` prop is specified, then it defaults to `totalAmount`.
8
+ * Depends on `useCart()` and must be a child of `<CartProvider/>`
9
+ * @publicDocs
10
+ */
4
11
  function CartCost(props) {
5
- const { cost } = useCart();
6
- const { amountType = "total", children, ...passthroughProps } = props;
7
- let amount;
8
- if (amountType == "total") {
9
- amount = cost == null ? void 0 : cost.totalAmount;
10
- } else if (amountType == "subtotal") {
11
- amount = cost == null ? void 0 : cost.subtotalAmount;
12
- } else if (amountType == "tax") {
13
- amount = cost == null ? void 0 : cost.totalTaxAmount;
14
- } else if (amountType == "duty") {
15
- amount = cost == null ? void 0 : cost.totalDutyAmount;
16
- }
17
- if (amount == null) {
18
- return null;
19
- }
20
- return /* @__PURE__ */ jsx(Money, { ...passthroughProps, data: amount, children });
12
+ const { cost } = useCart();
13
+ const { amountType = "total", children, ...passthroughProps } = props;
14
+ let amount;
15
+ if (amountType == "total") amount = cost?.totalAmount;
16
+ else if (amountType == "subtotal") amount = cost?.subtotalAmount;
17
+ else if (amountType == "tax") amount = cost?.totalTaxAmount;
18
+ else if (amountType == "duty") amount = cost?.totalDutyAmount;
19
+ if (amount == null) return null;
20
+ return /* @__PURE__ */ jsx(Money, {
21
+ ...passthroughProps,
22
+ data: amount,
23
+ children
24
+ });
21
25
  }
22
- export {
23
- CartCost
24
- };
25
- //# sourceMappingURL=CartCost.mjs.map
26
+ //#endregion
27
+ export { CartCost };
28
+
29
+ //# sourceMappingURL=CartCost.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CartCost.mjs","sources":["../../src/CartCost.tsx"],"sourcesContent":["import {Money, type MoneyPropsBase} from './Money.js';\nimport {useCart} from './CartProvider.js';\n\ninterface CartCostPropsBase {\n /** A string type that defines the type of cost needed. Valid values: `total`, `subtotal`, `tax`, or `duty`. */\n amountType?: 'total' | 'subtotal' | 'tax' | 'duty';\n /** Any `ReactNode` elements. */\n children?: React.ReactNode;\n}\n\ntype CartCostProps = Omit<React.ComponentProps<typeof Money>, 'data'> &\n CartCostPropsBase;\n\n/**\n * The `CartCost` component renders a `Money` component with the cost associated with the `amountType` prop.\n * If no `amountType` prop is specified, then it defaults to `totalAmount`.\n * Depends on `useCart()` and must be a child of `<CartProvider/>`\n * @publicDocs\n */\nexport function CartCost(props: CartCostProps): JSX.Element | null {\n const {cost} = useCart();\n const {amountType = 'total', children, ...passthroughProps} = props;\n let amount;\n\n if (amountType == 'total') {\n amount = cost?.totalAmount;\n } else if (amountType == 'subtotal') {\n amount = cost?.subtotalAmount;\n } else if (amountType == 'tax') {\n amount = cost?.totalTaxAmount;\n } else if (amountType == 'duty') {\n amount = cost?.totalDutyAmount;\n }\n\n if (amount == null) {\n return null;\n }\n\n return (\n <Money {...passthroughProps} data={amount}>\n {children}\n </Money>\n );\n}\n\n// This is only for documentation purposes, and it is not used in the code.\n/** @publicDocs */\nexport interface CartCostPropsForDocs<AsType extends React.ElementType = 'div'>\n extends Omit<MoneyPropsBase<AsType>, 'data'>, CartCostPropsBase {}\n"],"names":[],"mappings":";;;AAmBO,SAAS,SAAS,OAA0C;AACjE,QAAM,EAAC,KAAA,IAAQ,QAAA;AACf,QAAM,EAAC,aAAa,SAAS,UAAU,GAAG,qBAAoB;AAC9D,MAAI;AAEJ,MAAI,cAAc,SAAS;AACzB,aAAS,6BAAM;AAAA,EACjB,WAAW,cAAc,YAAY;AACnC,aAAS,6BAAM;AAAA,EACjB,WAAW,cAAc,OAAO;AAC9B,aAAS,6BAAM;AAAA,EACjB,WAAW,cAAc,QAAQ;AAC/B,aAAS,6BAAM;AAAA,EACjB;AAEA,MAAI,UAAU,MAAM;AAClB,WAAO;AAAA,EACT;AAEA,6BACG,OAAA,EAAO,GAAG,kBAAkB,MAAM,QAChC,UACH;AAEJ;"}
1
+ {"version":3,"file":"CartCost.mjs","names":[],"sources":["../../src/CartCost.tsx"],"sourcesContent":["import {Money, type MoneyPropsBase} from './Money.js';\nimport {useCart} from './CartProvider.js';\n\ninterface CartCostPropsBase {\n /** A string type that defines the type of cost needed. Valid values: `total`, `subtotal`, `tax`, or `duty`. */\n amountType?: 'total' | 'subtotal' | 'tax' | 'duty';\n /** Any `ReactNode` elements. */\n children?: React.ReactNode;\n}\n\ntype CartCostProps = Omit<React.ComponentProps<typeof Money>, 'data'> &\n CartCostPropsBase;\n\n/**\n * The `CartCost` component renders a `Money` component with the cost associated with the `amountType` prop.\n * If no `amountType` prop is specified, then it defaults to `totalAmount`.\n * Depends on `useCart()` and must be a child of `<CartProvider/>`\n * @publicDocs\n */\nexport function CartCost(props: CartCostProps): JSX.Element | null {\n const {cost} = useCart();\n const {amountType = 'total', children, ...passthroughProps} = props;\n let amount;\n\n if (amountType == 'total') {\n amount = cost?.totalAmount;\n } else if (amountType == 'subtotal') {\n amount = cost?.subtotalAmount;\n } else if (amountType == 'tax') {\n amount = cost?.totalTaxAmount;\n } else if (amountType == 'duty') {\n amount = cost?.totalDutyAmount;\n }\n\n if (amount == null) {\n return null;\n }\n\n return (\n <Money {...passthroughProps} data={amount}>\n {children}\n </Money>\n );\n}\n\n// This is only for documentation purposes, and it is not used in the code.\n/** @publicDocs */\nexport interface CartCostPropsForDocs<AsType extends React.ElementType = 'div'>\n extends Omit<MoneyPropsBase<AsType>, 'data'>, CartCostPropsBase {}\n"],"mappings":";;;;;;;;;;AAmBA,SAAgB,SAAS,OAA0C;CACjE,MAAM,EAAC,SAAQ,SAAS;CACxB,MAAM,EAAC,aAAa,SAAS,UAAU,GAAG,qBAAoB;CAC9D,IAAI;AAEJ,KAAI,cAAc,QAChB,UAAS,MAAM;UACN,cAAc,WACvB,UAAS,MAAM;UACN,cAAc,MACvB,UAAS,MAAM;UACN,cAAc,OACvB,UAAS,MAAM;AAGjB,KAAI,UAAU,KACZ,QAAO;AAGT,QACE,oBAAC,OAAD;EAAO,GAAI;EAAkB,MAAM;EAChC;EACK,CAAA"}
@@ -1,22 +1,27 @@
1
+ import { createContext, useContext } from "react";
1
2
  import { jsx } from "react/jsx-runtime";
2
- import { useContext, createContext } from "react";
3
- const CartLineContext = createContext(null);
3
+ //#region src/CartLineProvider.tsx
4
+ var CartLineContext = createContext(null);
5
+ /**
6
+ * The `useCartLine` hook provides access to the [CartLine object](https://shopify.dev/api/storefront/2026-04/objects/cartline) from the Storefront API. It must be a descendent of a `CartProvider` component.
7
+ * @publicDocs
8
+ */
4
9
  function useCartLine() {
5
- const context = useContext(CartLineContext);
6
- if (context == null) {
7
- throw new Error("Expected a cart line context but none was found");
8
- }
9
- return context;
10
+ const context = useContext(CartLineContext);
11
+ if (context == null) throw new Error("Expected a cart line context but none was found");
12
+ return context;
10
13
  }
11
- function CartLineProvider({
12
- children,
13
- line
14
- }) {
15
- return /* @__PURE__ */ jsx(CartLineContext.Provider, { value: line, children });
14
+ /**
15
+ * The `CartLineProvider` component creates a context for using a cart line.
16
+ * @publicDocs
17
+ */
18
+ function CartLineProvider({ children, line }) {
19
+ return /* @__PURE__ */ jsx(CartLineContext.Provider, {
20
+ value: line,
21
+ children
22
+ });
16
23
  }
17
- export {
18
- CartLineContext,
19
- CartLineProvider,
20
- useCartLine
21
- };
22
- //# sourceMappingURL=CartLineProvider.mjs.map
24
+ //#endregion
25
+ export { CartLineProvider, useCartLine };
26
+
27
+ //# sourceMappingURL=CartLineProvider.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CartLineProvider.mjs","sources":["../../src/CartLineProvider.tsx"],"sourcesContent":["import {useContext, createContext, type ReactNode} from 'react';\nimport {\n ComponentizableCartLine,\n type CartLine,\n} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\n\ntype CartLinePartialDeep = PartialDeep<\n CartLine | ComponentizableCartLine,\n {recurseIntoArrays: true}\n>;\n\nexport const CartLineContext = createContext<CartLinePartialDeep | null>(null);\n\n/**\n * The `useCartLine` hook provides access to the [CartLine object](https://shopify.dev/api/storefront/2026-04/objects/cartline) from the Storefront API. It must be a descendent of a `CartProvider` component.\n * @publicDocs\n */\nexport function useCartLine(): CartLinePartialDeep {\n const context = useContext(CartLineContext);\n\n if (context == null) {\n throw new Error('Expected a cart line context but none was found');\n }\n\n return context;\n}\n\ntype CartLineProviderProps = {\n /** Any `ReactNode` elements. */\n children: ReactNode;\n /** A cart line object. */\n line: CartLinePartialDeep;\n};\n\n/**\n * The `CartLineProvider` component creates a context for using a cart line.\n * @publicDocs\n */\nexport function CartLineProvider({\n children,\n line,\n}: CartLineProviderProps): JSX.Element {\n return (\n <CartLineContext.Provider value={line}>{children}</CartLineContext.Provider>\n );\n}\n"],"names":[],"mappings":";;AAYO,MAAM,kBAAkB,cAA0C,IAAI;AAMtE,SAAS,cAAmC;AACjD,QAAM,UAAU,WAAW,eAAe;AAE1C,MAAI,WAAW,MAAM;AACnB,UAAM,IAAI,MAAM,iDAAiD;AAAA,EACnE;AAEA,SAAO;AACT;AAaO,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AACF,GAAuC;AACrC,6BACG,gBAAgB,UAAhB,EAAyB,OAAO,MAAO,UAAS;AAErD;"}
1
+ {"version":3,"file":"CartLineProvider.mjs","names":[],"sources":["../../src/CartLineProvider.tsx"],"sourcesContent":["import {useContext, createContext, type ReactNode} from 'react';\nimport {\n ComponentizableCartLine,\n type CartLine,\n} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\n\ntype CartLinePartialDeep = PartialDeep<\n CartLine | ComponentizableCartLine,\n {recurseIntoArrays: true}\n>;\n\nexport const CartLineContext = createContext<CartLinePartialDeep | null>(null);\n\n/**\n * The `useCartLine` hook provides access to the [CartLine object](https://shopify.dev/api/storefront/2026-04/objects/cartline) from the Storefront API. It must be a descendent of a `CartProvider` component.\n * @publicDocs\n */\nexport function useCartLine(): CartLinePartialDeep {\n const context = useContext(CartLineContext);\n\n if (context == null) {\n throw new Error('Expected a cart line context but none was found');\n }\n\n return context;\n}\n\ntype CartLineProviderProps = {\n /** Any `ReactNode` elements. */\n children: ReactNode;\n /** A cart line object. */\n line: CartLinePartialDeep;\n};\n\n/**\n * The `CartLineProvider` component creates a context for using a cart line.\n * @publicDocs\n */\nexport function CartLineProvider({\n children,\n line,\n}: CartLineProviderProps): JSX.Element {\n return (\n <CartLineContext.Provider value={line}>{children}</CartLineContext.Provider>\n );\n}\n"],"mappings":";;;AAYA,IAAa,kBAAkB,cAA0C,KAAK;;;;;AAM9E,SAAgB,cAAmC;CACjD,MAAM,UAAU,WAAW,gBAAgB;AAE3C,KAAI,WAAW,KACb,OAAM,IAAI,MAAM,kDAAkD;AAGpE,QAAO;;;;;;AAcT,SAAgB,iBAAiB,EAC/B,UACA,QACqC;AACrC,QACE,oBAAC,gBAAgB,UAAjB;EAA0B,OAAO;EAAO;EAAoC,CAAA"}
@@ -1,12 +1,21 @@
1
- import { jsx } from "react/jsx-runtime";
2
1
  import { useCartLine } from "./CartLineProvider.mjs";
2
+ import { jsx } from "react/jsx-runtime";
3
+ //#region src/CartLineQuantity.tsx
4
+ /**
5
+ * The `<CartLineQuantity/>` component renders a `span` (or another element / component that can be customized by the `as` prop) with the cart line's quantity.
6
+ *
7
+ * It must be a descendent of a `<CartLineProvider/>` component, and uses the `useCartLine()` hook internally.
8
+ * @publicDocs
9
+ */
3
10
  function CartLineQuantity(props) {
4
- const cartLine = useCartLine();
5
- const { as, ...passthroughProps } = props;
6
- const Wrapper = as ? as : "span";
7
- return /* @__PURE__ */ jsx(Wrapper, { ...passthroughProps, children: cartLine.quantity });
11
+ const cartLine = useCartLine();
12
+ const { as, ...passthroughProps } = props;
13
+ return /* @__PURE__ */ jsx(as ? as : "span", {
14
+ ...passthroughProps,
15
+ children: cartLine.quantity
16
+ });
8
17
  }
9
- export {
10
- CartLineQuantity
11
- };
12
- //# sourceMappingURL=CartLineQuantity.mjs.map
18
+ //#endregion
19
+ export { CartLineQuantity };
20
+
21
+ //# sourceMappingURL=CartLineQuantity.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CartLineQuantity.mjs","sources":["../../src/CartLineQuantity.tsx"],"sourcesContent":["import type {ComponentPropsWithoutRef, ElementType} from 'react';\nimport {useCartLine} from './CartLineProvider.js';\n\n/** @publicDocs */\ninterface CartLineQuantityBaseProps<\n ComponentGeneric extends ElementType = 'span',\n> {\n /** An HTML tag or React Component to be rendered as the base element wrapper. The default is `span`. */\n as?: ComponentGeneric;\n}\n\nexport type CartLineQuantityProps<ComponentGeneric extends ElementType> =\n CartLineQuantityBaseProps<ComponentGeneric> &\n Omit<\n ComponentPropsWithoutRef<ComponentGeneric>,\n keyof CartLineQuantityBaseProps<ComponentGeneric>\n >;\n\n/**\n * The `<CartLineQuantity/>` component renders a `span` (or another element / component that can be customized by the `as` prop) with the cart line's quantity.\n *\n * It must be a descendent of a `<CartLineProvider/>` component, and uses the `useCartLine()` hook internally.\n * @publicDocs\n */\nexport function CartLineQuantity<ComponentGeneric extends ElementType = 'span'>(\n props: CartLineQuantityProps<ComponentGeneric>,\n): JSX.Element {\n const cartLine = useCartLine();\n const {as, ...passthroughProps} = props;\n\n const Wrapper = as ? as : 'span';\n\n return <Wrapper {...passthroughProps}>{cartLine.quantity}</Wrapper>;\n}\n"],"names":[],"mappings":";;AAwBO,SAAS,iBACd,OACa;AACb,QAAM,WAAW,YAAA;AACjB,QAAM,EAAC,IAAI,GAAG,iBAAA,IAAoB;AAElC,QAAM,UAAU,KAAK,KAAK;AAE1B,SAAO,oBAAC,SAAA,EAAS,GAAG,kBAAmB,mBAAS,UAAS;AAC3D;"}
1
+ {"version":3,"file":"CartLineQuantity.mjs","names":[],"sources":["../../src/CartLineQuantity.tsx"],"sourcesContent":["import type {ComponentPropsWithoutRef, ElementType} from 'react';\nimport {useCartLine} from './CartLineProvider.js';\n\n/** @publicDocs */\ninterface CartLineQuantityBaseProps<\n ComponentGeneric extends ElementType = 'span',\n> {\n /** An HTML tag or React Component to be rendered as the base element wrapper. The default is `span`. */\n as?: ComponentGeneric;\n}\n\nexport type CartLineQuantityProps<ComponentGeneric extends ElementType> =\n CartLineQuantityBaseProps<ComponentGeneric> &\n Omit<\n ComponentPropsWithoutRef<ComponentGeneric>,\n keyof CartLineQuantityBaseProps<ComponentGeneric>\n >;\n\n/**\n * The `<CartLineQuantity/>` component renders a `span` (or another element / component that can be customized by the `as` prop) with the cart line's quantity.\n *\n * It must be a descendent of a `<CartLineProvider/>` component, and uses the `useCartLine()` hook internally.\n * @publicDocs\n */\nexport function CartLineQuantity<ComponentGeneric extends ElementType = 'span'>(\n props: CartLineQuantityProps<ComponentGeneric>,\n): JSX.Element {\n const cartLine = useCartLine();\n const {as, ...passthroughProps} = props;\n\n const Wrapper = as ? as : 'span';\n\n return <Wrapper {...passthroughProps}>{cartLine.quantity}</Wrapper>;\n}\n"],"mappings":";;;;;;;;;AAwBA,SAAgB,iBACd,OACa;CACb,MAAM,WAAW,aAAa;CAC9B,MAAM,EAAC,IAAI,GAAG,qBAAoB;AAIlC,QAAO,oBAFS,KAAK,KAAK,QAEnB;EAAS,GAAI;YAAmB,SAAS;EAAmB,CAAA"}
@@ -1,49 +1,52 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useCallback } from "react";
3
1
  import { useCart } from "./CartProvider.mjs";
4
- import { useCartLine } from "./CartLineProvider.mjs";
5
2
  import { BaseButton } from "./BaseButton.mjs";
3
+ import { useCartLine } from "./CartLineProvider.mjs";
4
+ import { useCallback } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region src/CartLineQuantityAdjustButton.tsx
7
+ /**
8
+ * The `<CartLineQuantityAdjustButton />` component renders a button that adjusts the cart line's quantity when pressed.
9
+ *
10
+ * It must be a descendent of `<CartLineProvider/>` and `<CartProvider/>`.
11
+ * @publicDocs
12
+ */
6
13
  function CartLineQuantityAdjustButton(props) {
7
- const { status, linesRemove, linesUpdate } = useCart();
8
- const cartLine = useCartLine();
9
- const { children, adjust, onClick, ...passthroughProps } = props;
10
- const handleAdjust = useCallback(() => {
11
- if (adjust === "remove") {
12
- linesRemove([(cartLine == null ? void 0 : cartLine.id) ?? ""]);
13
- return;
14
- }
15
- const quantity = adjust === "decrease" ? ((cartLine == null ? void 0 : cartLine.quantity) ?? 0) - 1 : ((cartLine == null ? void 0 : cartLine.quantity) ?? 0) + 1;
16
- if (quantity <= 0) {
17
- linesRemove([(cartLine == null ? void 0 : cartLine.id) ?? ""]);
18
- return;
19
- }
20
- const lineUpdate = {
21
- id: (cartLine == null ? void 0 : cartLine.id) ?? "",
22
- quantity,
23
- attributes: (cartLine == null ? void 0 : cartLine.attributes) ?? []
24
- };
25
- linesUpdate([lineUpdate]);
26
- }, [
27
- adjust,
28
- cartLine == null ? void 0 : cartLine.attributes,
29
- cartLine == null ? void 0 : cartLine.id,
30
- cartLine == null ? void 0 : cartLine.quantity,
31
- linesRemove,
32
- linesUpdate
33
- ]);
34
- const disabledAttr = passthroughProps.disabled;
35
- return /* @__PURE__ */ jsx(
36
- BaseButton,
37
- {
38
- ...passthroughProps,
39
- onClick,
40
- defaultOnClick: handleAdjust,
41
- disabled: typeof disabledAttr !== "undefined" ? disabledAttr : status !== "idle",
42
- children
43
- }
44
- );
14
+ const { status, linesRemove, linesUpdate } = useCart();
15
+ const cartLine = useCartLine();
16
+ const { children, adjust, onClick, ...passthroughProps } = props;
17
+ const handleAdjust = useCallback(() => {
18
+ if (adjust === "remove") {
19
+ linesRemove([cartLine?.id ?? ""]);
20
+ return;
21
+ }
22
+ const quantity = adjust === "decrease" ? (cartLine?.quantity ?? 0) - 1 : (cartLine?.quantity ?? 0) + 1;
23
+ if (quantity <= 0) {
24
+ linesRemove([cartLine?.id ?? ""]);
25
+ return;
26
+ }
27
+ linesUpdate([{
28
+ id: cartLine?.id ?? "",
29
+ quantity,
30
+ attributes: cartLine?.attributes ?? []
31
+ }]);
32
+ }, [
33
+ adjust,
34
+ cartLine?.attributes,
35
+ cartLine?.id,
36
+ cartLine?.quantity,
37
+ linesRemove,
38
+ linesUpdate
39
+ ]);
40
+ const disabledAttr = passthroughProps.disabled;
41
+ return /* @__PURE__ */ jsx(BaseButton, {
42
+ ...passthroughProps,
43
+ onClick,
44
+ defaultOnClick: handleAdjust,
45
+ disabled: typeof disabledAttr !== "undefined" ? disabledAttr : status !== "idle",
46
+ children
47
+ });
45
48
  }
46
- export {
47
- CartLineQuantityAdjustButton
48
- };
49
- //# sourceMappingURL=CartLineQuantityAdjustButton.mjs.map
49
+ //#endregion
50
+ export { CartLineQuantityAdjustButton };
51
+
52
+ //# sourceMappingURL=CartLineQuantityAdjustButton.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CartLineQuantityAdjustButton.mjs","sources":["../../src/CartLineQuantityAdjustButton.tsx"],"sourcesContent":["import {useCallback} from 'react';\nimport {useCart} from './CartProvider.js';\nimport {useCartLine} from './CartLineProvider.js';\nimport {BaseButton, type BaseButtonProps} from './BaseButton.js';\nimport type {CartLineUpdateInput} from './storefront-api-types.js';\n\ninterface CartLineQuantityAdjustButtonBaseProps {\n /** The adjustment for a cart line's quantity. Valid values: `increase` (default), `decrease`, or `remove`. */\n adjust?: 'increase' | 'decrease' | 'remove';\n}\n\ntype CartLineQuantityAdjustButtonProps<\n AsType extends React.ElementType = 'button',\n> = BaseButtonProps<AsType> & CartLineQuantityAdjustButtonBaseProps;\n\n/**\n * The `<CartLineQuantityAdjustButton />` component renders a button that adjusts the cart line's quantity when pressed.\n *\n * It must be a descendent of `<CartLineProvider/>` and `<CartProvider/>`.\n * @publicDocs\n */\nexport function CartLineQuantityAdjustButton<\n AsType extends React.ElementType = 'button',\n>(props: CartLineQuantityAdjustButtonProps<AsType>): JSX.Element {\n const {status, linesRemove, linesUpdate} = useCart();\n const cartLine = useCartLine();\n const {children, adjust, onClick, ...passthroughProps} = props;\n\n const handleAdjust = useCallback(() => {\n if (adjust === 'remove') {\n linesRemove([cartLine?.id ?? '']);\n return;\n }\n\n const quantity =\n adjust === 'decrease'\n ? (cartLine?.quantity ?? 0) - 1\n : (cartLine?.quantity ?? 0) + 1;\n\n if (quantity <= 0) {\n linesRemove([cartLine?.id ?? '']);\n return;\n }\n\n const lineUpdate = {\n id: cartLine?.id ?? '',\n quantity,\n attributes: (cartLine?.attributes ??\n []) as CartLineUpdateInput['attributes'],\n } satisfies CartLineUpdateInput;\n\n linesUpdate([lineUpdate]);\n }, [\n adjust,\n cartLine?.attributes,\n cartLine?.id,\n cartLine?.quantity,\n linesRemove,\n linesUpdate,\n ]);\n\n // Only certain 'as' types such as 'button' contain `disabled`\n const disabledAttr = (passthroughProps as {disabled?: boolean}).disabled;\n\n return (\n <BaseButton\n {...passthroughProps}\n onClick={onClick}\n defaultOnClick={handleAdjust}\n disabled={\n typeof disabledAttr !== 'undefined' ? disabledAttr : status !== 'idle'\n }\n >\n {children}\n </BaseButton>\n );\n}\n"],"names":[],"mappings":";;;;;AAqBO,SAAS,6BAEd,OAA+D;AAC/D,QAAM,EAAC,QAAQ,aAAa,YAAA,IAAe,QAAA;AAC3C,QAAM,WAAW,YAAA;AACjB,QAAM,EAAC,UAAU,QAAQ,SAAS,GAAG,qBAAoB;AAEzD,QAAM,eAAe,YAAY,MAAM;AACrC,QAAI,WAAW,UAAU;AACvB,kBAAY,EAAC,qCAAU,OAAM,EAAE,CAAC;AAChC;AAAA,IACF;AAEA,UAAM,WACJ,WAAW,eACN,qCAAU,aAAY,KAAK,MAC3B,qCAAU,aAAY,KAAK;AAElC,QAAI,YAAY,GAAG;AACjB,kBAAY,EAAC,qCAAU,OAAM,EAAE,CAAC;AAChC;AAAA,IACF;AAEA,UAAM,aAAa;AAAA,MACjB,KAAI,qCAAU,OAAM;AAAA,MACpB;AAAA,MACA,aAAa,qCAAU,eACrB,CAAA;AAAA,IAAC;AAGL,gBAAY,CAAC,UAAU,CAAC;AAAA,EAC1B,GAAG;AAAA,IACD;AAAA,IACA,qCAAU;AAAA,IACV,qCAAU;AAAA,IACV,qCAAU;AAAA,IACV;AAAA,IACA;AAAA,EAAA,CACD;AAGD,QAAM,eAAgB,iBAA0C;AAEhE,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA,MACA,gBAAgB;AAAA,MAChB,UACE,OAAO,iBAAiB,cAAc,eAAe,WAAW;AAAA,MAGjE;AAAA,IAAA;AAAA,EAAA;AAGP;"}
1
+ {"version":3,"file":"CartLineQuantityAdjustButton.mjs","names":[],"sources":["../../src/CartLineQuantityAdjustButton.tsx"],"sourcesContent":["import {useCallback} from 'react';\nimport {useCart} from './CartProvider.js';\nimport {useCartLine} from './CartLineProvider.js';\nimport {BaseButton, type BaseButtonProps} from './BaseButton.js';\nimport type {CartLineUpdateInput} from './storefront-api-types.js';\n\ninterface CartLineQuantityAdjustButtonBaseProps {\n /** The adjustment for a cart line's quantity. Valid values: `increase` (default), `decrease`, or `remove`. */\n adjust?: 'increase' | 'decrease' | 'remove';\n}\n\ntype CartLineQuantityAdjustButtonProps<\n AsType extends React.ElementType = 'button',\n> = BaseButtonProps<AsType> & CartLineQuantityAdjustButtonBaseProps;\n\n/**\n * The `<CartLineQuantityAdjustButton />` component renders a button that adjusts the cart line's quantity when pressed.\n *\n * It must be a descendent of `<CartLineProvider/>` and `<CartProvider/>`.\n * @publicDocs\n */\nexport function CartLineQuantityAdjustButton<\n AsType extends React.ElementType = 'button',\n>(props: CartLineQuantityAdjustButtonProps<AsType>): JSX.Element {\n const {status, linesRemove, linesUpdate} = useCart();\n const cartLine = useCartLine();\n const {children, adjust, onClick, ...passthroughProps} = props;\n\n const handleAdjust = useCallback(() => {\n if (adjust === 'remove') {\n linesRemove([cartLine?.id ?? '']);\n return;\n }\n\n const quantity =\n adjust === 'decrease'\n ? (cartLine?.quantity ?? 0) - 1\n : (cartLine?.quantity ?? 0) + 1;\n\n if (quantity <= 0) {\n linesRemove([cartLine?.id ?? '']);\n return;\n }\n\n const lineUpdate = {\n id: cartLine?.id ?? '',\n quantity,\n attributes: (cartLine?.attributes ??\n []) as CartLineUpdateInput['attributes'],\n } satisfies CartLineUpdateInput;\n\n linesUpdate([lineUpdate]);\n }, [\n adjust,\n cartLine?.attributes,\n cartLine?.id,\n cartLine?.quantity,\n linesRemove,\n linesUpdate,\n ]);\n\n // Only certain 'as' types such as 'button' contain `disabled`\n const disabledAttr = (passthroughProps as {disabled?: boolean}).disabled;\n\n return (\n <BaseButton\n {...passthroughProps}\n onClick={onClick}\n defaultOnClick={handleAdjust}\n disabled={\n typeof disabledAttr !== 'undefined' ? disabledAttr : status !== 'idle'\n }\n >\n {children}\n </BaseButton>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,SAAgB,6BAEd,OAA+D;CAC/D,MAAM,EAAC,QAAQ,aAAa,gBAAe,SAAS;CACpD,MAAM,WAAW,aAAa;CAC9B,MAAM,EAAC,UAAU,QAAQ,SAAS,GAAG,qBAAoB;CAEzD,MAAM,eAAe,kBAAkB;AACrC,MAAI,WAAW,UAAU;AACvB,eAAY,CAAC,UAAU,MAAM,GAAG,CAAC;AACjC;;EAGF,MAAM,WACJ,WAAW,cACN,UAAU,YAAY,KAAK,KAC3B,UAAU,YAAY,KAAK;AAElC,MAAI,YAAY,GAAG;AACjB,eAAY,CAAC,UAAU,MAAM,GAAG,CAAC;AACjC;;AAUF,cAAY,CAPO;GACjB,IAAI,UAAU,MAAM;GACpB;GACA,YAAa,UAAU,cACrB,EAAE;GACL,CAEuB,CAAC;IACxB;EACD;EACA,UAAU;EACV,UAAU;EACV,UAAU;EACV;EACA;EACD,CAAC;CAGF,MAAM,eAAgB,iBAA0C;AAEhE,QACE,oBAAC,YAAD;EACE,GAAI;EACK;EACT,gBAAgB;EAChB,UACE,OAAO,iBAAiB,cAAc,eAAe,WAAW;EAGjE;EACU,CAAA"}