@shopify/hydrogen-react 2022.10.7 → 2023.1.4

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 (612) hide show
  1. package/README.md +41 -45
  2. package/dist/browser-dev/AddToCartButton.mjs +43 -40
  3. package/dist/browser-dev/AddToCartButton.mjs.map +1 -1
  4. package/dist/browser-dev/BaseButton.mjs +13 -15
  5. package/dist/browser-dev/BaseButton.mjs.map +1 -1
  6. package/dist/browser-dev/BuyNowButton.mjs +19 -17
  7. package/dist/browser-dev/BuyNowButton.mjs.map +1 -1
  8. package/dist/browser-dev/CartCheckoutButton.mjs +12 -15
  9. package/dist/browser-dev/CartCheckoutButton.mjs.map +1 -1
  10. package/dist/browser-dev/CartCost.mjs +25 -0
  11. package/dist/browser-dev/CartCost.mjs.map +1 -0
  12. package/dist/browser-dev/CartLinePrice.mjs +18 -0
  13. package/dist/browser-dev/CartLinePrice.mjs.map +1 -0
  14. package/dist/browser-dev/CartLineProvider.mjs +19 -0
  15. package/dist/browser-dev/CartLineProvider.mjs.map +1 -0
  16. package/dist/browser-dev/CartProvider.mjs +73 -67
  17. package/dist/browser-dev/CartProvider.mjs.map +1 -1
  18. package/dist/browser-dev/ExternalVideo.mjs +13 -11
  19. package/dist/browser-dev/ExternalVideo.mjs.map +1 -1
  20. package/dist/browser-dev/Image.mjs +41 -30
  21. package/dist/browser-dev/Image.mjs.map +1 -1
  22. package/dist/browser-dev/MediaFile.mjs +29 -21
  23. package/dist/browser-dev/MediaFile.mjs.map +1 -1
  24. package/dist/browser-dev/ModelViewer.mjs +138 -76
  25. package/dist/browser-dev/ModelViewer.mjs.map +1 -1
  26. package/dist/browser-dev/Money.mjs +12 -9
  27. package/dist/browser-dev/Money.mjs.map +1 -1
  28. package/dist/browser-dev/ProductPrice.mjs +12 -17
  29. package/dist/browser-dev/ProductPrice.mjs.map +1 -1
  30. package/dist/browser-dev/ProductProvider.mjs +102 -73
  31. package/dist/browser-dev/ProductProvider.mjs.map +1 -1
  32. package/dist/browser-dev/ShopPayButton.mjs +14 -24
  33. package/dist/browser-dev/ShopPayButton.mjs.map +1 -1
  34. package/dist/browser-dev/ShopifyProvider.mjs +22 -38
  35. package/dist/browser-dev/ShopifyProvider.mjs.map +1 -1
  36. package/dist/browser-dev/Video.mjs +30 -21
  37. package/dist/browser-dev/Video.mjs.map +1 -1
  38. package/dist/browser-dev/_virtual/index.mjs +11 -2
  39. package/dist/browser-dev/_virtual/index.mjs.map +1 -1
  40. package/dist/browser-dev/_virtual/with-selector.mjs +11 -2
  41. package/dist/browser-dev/_virtual/with-selector.mjs.map +1 -1
  42. package/dist/browser-dev/analytics-constants.mjs +43 -0
  43. package/dist/browser-dev/analytics-constants.mjs.map +1 -0
  44. package/dist/browser-dev/analytics-schema-custom-storefront-customer-tracking.mjs +145 -0
  45. package/dist/browser-dev/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -0
  46. package/dist/browser-dev/analytics-schema-trekkie-storefront-page-view.mjs +58 -0
  47. package/dist/browser-dev/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -0
  48. package/dist/browser-dev/analytics-utils.mjs +49 -0
  49. package/dist/browser-dev/analytics-utils.mjs.map +1 -0
  50. package/dist/browser-dev/analytics.mjs +159 -0
  51. package/dist/browser-dev/analytics.mjs.map +1 -0
  52. package/dist/browser-dev/cart-hooks.mjs +29 -34
  53. package/dist/browser-dev/cart-hooks.mjs.map +1 -1
  54. package/dist/browser-dev/cart-queries.mjs +50 -28
  55. package/dist/browser-dev/cart-queries.mjs.map +1 -1
  56. package/dist/browser-dev/codegen.helpers.mjs +1 -0
  57. package/dist/browser-dev/codegen.helpers.mjs.map +1 -1
  58. package/dist/browser-dev/cookies-utils.mjs +50 -0
  59. package/dist/browser-dev/cookies-utils.mjs.map +1 -0
  60. package/dist/browser-dev/flatten-connection.mjs +7 -5
  61. package/dist/browser-dev/flatten-connection.mjs.map +1 -1
  62. package/dist/browser-dev/image-size.mjs +8 -8
  63. package/dist/browser-dev/image-size.mjs.map +1 -1
  64. package/dist/browser-dev/index.mjs +20 -6
  65. package/dist/browser-dev/index.mjs.map +1 -1
  66. package/dist/browser-dev/load-script.mjs.map +1 -1
  67. package/dist/browser-dev/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
  68. package/dist/browser-dev/node_modules/@xstate/react/es/fsm.mjs +2 -2
  69. package/dist/browser-dev/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
  70. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -1
  71. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
  72. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +1 -1
  73. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -1
  74. package/dist/browser-dev/node_modules/use-sync-external-store/shim/index.mjs +3 -3
  75. package/dist/browser-dev/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
  76. package/dist/browser-dev/{metafield-parser.mjs → parse-metafield.mjs} +20 -12
  77. package/dist/browser-dev/parse-metafield.mjs.map +1 -0
  78. package/dist/browser-dev/storefront-api-constants.mjs +1 -1
  79. package/dist/browser-dev/storefront-api-constants.mjs.map +1 -1
  80. package/dist/browser-dev/storefront-client.mjs +19 -20
  81. package/dist/browser-dev/storefront-client.mjs.map +1 -1
  82. package/dist/browser-dev/useCartAPIStateMachine.mjs +111 -80
  83. package/dist/browser-dev/useCartAPIStateMachine.mjs.map +1 -1
  84. package/dist/browser-dev/useCartActions.mjs +150 -109
  85. package/dist/browser-dev/useCartActions.mjs.map +1 -1
  86. package/dist/browser-dev/useMoney.mjs +62 -36
  87. package/dist/browser-dev/useMoney.mjs.map +1 -1
  88. package/dist/browser-dev/useShopifyCookies.mjs +41 -0
  89. package/dist/browser-dev/useShopifyCookies.mjs.map +1 -0
  90. package/dist/browser-prod/AddToCartButton.mjs +43 -40
  91. package/dist/browser-prod/AddToCartButton.mjs.map +1 -1
  92. package/dist/browser-prod/BaseButton.mjs +13 -15
  93. package/dist/browser-prod/BaseButton.mjs.map +1 -1
  94. package/dist/browser-prod/BuyNowButton.mjs +19 -17
  95. package/dist/browser-prod/BuyNowButton.mjs.map +1 -1
  96. package/dist/browser-prod/CartCheckoutButton.mjs +12 -15
  97. package/dist/browser-prod/CartCheckoutButton.mjs.map +1 -1
  98. package/dist/browser-prod/CartCost.mjs +25 -0
  99. package/dist/browser-prod/CartCost.mjs.map +1 -0
  100. package/dist/browser-prod/CartLinePrice.mjs +18 -0
  101. package/dist/browser-prod/CartLinePrice.mjs.map +1 -0
  102. package/dist/browser-prod/CartLineProvider.mjs +19 -0
  103. package/dist/browser-prod/CartLineProvider.mjs.map +1 -0
  104. package/dist/browser-prod/CartProvider.mjs +73 -67
  105. package/dist/browser-prod/CartProvider.mjs.map +1 -1
  106. package/dist/browser-prod/ExternalVideo.mjs +13 -11
  107. package/dist/browser-prod/ExternalVideo.mjs.map +1 -1
  108. package/dist/browser-prod/Image.mjs +35 -28
  109. package/dist/browser-prod/Image.mjs.map +1 -1
  110. package/dist/browser-prod/MediaFile.mjs +29 -21
  111. package/dist/browser-prod/MediaFile.mjs.map +1 -1
  112. package/dist/browser-prod/ModelViewer.mjs +135 -75
  113. package/dist/browser-prod/ModelViewer.mjs.map +1 -1
  114. package/dist/browser-prod/Money.mjs +12 -9
  115. package/dist/browser-prod/Money.mjs.map +1 -1
  116. package/dist/browser-prod/ProductPrice.mjs +12 -17
  117. package/dist/browser-prod/ProductPrice.mjs.map +1 -1
  118. package/dist/browser-prod/ProductProvider.mjs +102 -73
  119. package/dist/browser-prod/ProductProvider.mjs.map +1 -1
  120. package/dist/browser-prod/ShopPayButton.mjs +14 -24
  121. package/dist/browser-prod/ShopPayButton.mjs.map +1 -1
  122. package/dist/browser-prod/ShopifyProvider.mjs +22 -32
  123. package/dist/browser-prod/ShopifyProvider.mjs.map +1 -1
  124. package/dist/browser-prod/Video.mjs +30 -21
  125. package/dist/browser-prod/Video.mjs.map +1 -1
  126. package/dist/browser-prod/_virtual/index.mjs +11 -2
  127. package/dist/browser-prod/_virtual/index.mjs.map +1 -1
  128. package/dist/browser-prod/_virtual/with-selector.mjs +11 -2
  129. package/dist/browser-prod/_virtual/with-selector.mjs.map +1 -1
  130. package/dist/browser-prod/analytics-constants.mjs +43 -0
  131. package/dist/browser-prod/analytics-constants.mjs.map +1 -0
  132. package/dist/browser-prod/analytics-schema-custom-storefront-customer-tracking.mjs +145 -0
  133. package/dist/browser-prod/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -0
  134. package/dist/browser-prod/analytics-schema-trekkie-storefront-page-view.mjs +58 -0
  135. package/dist/browser-prod/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -0
  136. package/dist/browser-prod/analytics-utils.mjs +49 -0
  137. package/dist/browser-prod/analytics-utils.mjs.map +1 -0
  138. package/dist/browser-prod/analytics.mjs +158 -0
  139. package/dist/browser-prod/analytics.mjs.map +1 -0
  140. package/dist/browser-prod/cart-hooks.mjs +29 -34
  141. package/dist/browser-prod/cart-hooks.mjs.map +1 -1
  142. package/dist/browser-prod/cart-queries.mjs +50 -28
  143. package/dist/browser-prod/cart-queries.mjs.map +1 -1
  144. package/dist/browser-prod/codegen.helpers.mjs +1 -0
  145. package/dist/browser-prod/codegen.helpers.mjs.map +1 -1
  146. package/dist/browser-prod/cookies-utils.mjs +50 -0
  147. package/dist/browser-prod/cookies-utils.mjs.map +1 -0
  148. package/dist/browser-prod/flatten-connection.mjs +7 -5
  149. package/dist/browser-prod/flatten-connection.mjs.map +1 -1
  150. package/dist/browser-prod/image-size.mjs +8 -8
  151. package/dist/browser-prod/image-size.mjs.map +1 -1
  152. package/dist/browser-prod/index.mjs +20 -6
  153. package/dist/browser-prod/index.mjs.map +1 -1
  154. package/dist/browser-prod/load-script.mjs.map +1 -1
  155. package/dist/browser-prod/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
  156. package/dist/browser-prod/node_modules/@xstate/react/es/fsm.mjs +2 -2
  157. package/dist/browser-prod/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
  158. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -1
  159. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
  160. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +1 -1
  161. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -1
  162. package/dist/browser-prod/node_modules/use-sync-external-store/shim/index.mjs +3 -3
  163. package/dist/browser-prod/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
  164. package/dist/browser-prod/{metafield-parser.mjs → parse-metafield.mjs} +20 -12
  165. package/dist/browser-prod/parse-metafield.mjs.map +1 -0
  166. package/dist/browser-prod/storefront-api-constants.mjs +1 -1
  167. package/dist/browser-prod/storefront-api-constants.mjs.map +1 -1
  168. package/dist/browser-prod/storefront-client.mjs +19 -20
  169. package/dist/browser-prod/storefront-client.mjs.map +1 -1
  170. package/dist/browser-prod/useCartAPIStateMachine.mjs +111 -80
  171. package/dist/browser-prod/useCartAPIStateMachine.mjs.map +1 -1
  172. package/dist/browser-prod/useCartActions.mjs +150 -109
  173. package/dist/browser-prod/useCartActions.mjs.map +1 -1
  174. package/dist/browser-prod/useMoney.mjs +62 -36
  175. package/dist/browser-prod/useMoney.mjs.map +1 -1
  176. package/dist/browser-prod/useShopifyCookies.mjs +41 -0
  177. package/dist/browser-prod/useShopifyCookies.mjs.map +1 -0
  178. package/dist/node-dev/AddToCartButton.js +44 -41
  179. package/dist/node-dev/AddToCartButton.js.map +1 -1
  180. package/dist/node-dev/AddToCartButton.mjs +43 -40
  181. package/dist/node-dev/AddToCartButton.mjs.map +1 -1
  182. package/dist/node-dev/BaseButton.js +14 -16
  183. package/dist/node-dev/BaseButton.js.map +1 -1
  184. package/dist/node-dev/BaseButton.mjs +13 -15
  185. package/dist/node-dev/BaseButton.mjs.map +1 -1
  186. package/dist/node-dev/BuyNowButton.js +20 -18
  187. package/dist/node-dev/BuyNowButton.js.map +1 -1
  188. package/dist/node-dev/BuyNowButton.mjs +19 -17
  189. package/dist/node-dev/BuyNowButton.mjs.map +1 -1
  190. package/dist/node-dev/CartCheckoutButton.js +13 -16
  191. package/dist/node-dev/CartCheckoutButton.js.map +1 -1
  192. package/dist/node-dev/CartCheckoutButton.mjs +12 -15
  193. package/dist/node-dev/CartCheckoutButton.mjs.map +1 -1
  194. package/dist/node-dev/CartCost.js +25 -0
  195. package/dist/node-dev/CartCost.js.map +1 -0
  196. package/dist/node-dev/CartCost.mjs +25 -0
  197. package/dist/node-dev/CartCost.mjs.map +1 -0
  198. package/dist/node-dev/CartLinePrice.js +18 -0
  199. package/dist/node-dev/CartLinePrice.js.map +1 -0
  200. package/dist/node-dev/CartLinePrice.mjs +18 -0
  201. package/dist/node-dev/CartLinePrice.mjs.map +1 -0
  202. package/dist/node-dev/CartLineProvider.js +19 -0
  203. package/dist/node-dev/CartLineProvider.js.map +1 -0
  204. package/dist/node-dev/CartLineProvider.mjs +19 -0
  205. package/dist/node-dev/CartLineProvider.mjs.map +1 -0
  206. package/dist/node-dev/CartProvider.js +74 -68
  207. package/dist/node-dev/CartProvider.js.map +1 -1
  208. package/dist/node-dev/CartProvider.mjs +73 -67
  209. package/dist/node-dev/CartProvider.mjs.map +1 -1
  210. package/dist/node-dev/ExternalVideo.js +14 -12
  211. package/dist/node-dev/ExternalVideo.js.map +1 -1
  212. package/dist/node-dev/ExternalVideo.mjs +13 -11
  213. package/dist/node-dev/ExternalVideo.mjs.map +1 -1
  214. package/dist/node-dev/Image.js +42 -31
  215. package/dist/node-dev/Image.js.map +1 -1
  216. package/dist/node-dev/Image.mjs +41 -30
  217. package/dist/node-dev/Image.mjs.map +1 -1
  218. package/dist/node-dev/MediaFile.js +30 -22
  219. package/dist/node-dev/MediaFile.js.map +1 -1
  220. package/dist/node-dev/MediaFile.mjs +29 -21
  221. package/dist/node-dev/MediaFile.mjs.map +1 -1
  222. package/dist/node-dev/ModelViewer.js +139 -77
  223. package/dist/node-dev/ModelViewer.js.map +1 -1
  224. package/dist/node-dev/ModelViewer.mjs +138 -76
  225. package/dist/node-dev/ModelViewer.mjs.map +1 -1
  226. package/dist/node-dev/Money.js +13 -10
  227. package/dist/node-dev/Money.js.map +1 -1
  228. package/dist/node-dev/Money.mjs +12 -9
  229. package/dist/node-dev/Money.mjs.map +1 -1
  230. package/dist/node-dev/ProductPrice.js +13 -18
  231. package/dist/node-dev/ProductPrice.js.map +1 -1
  232. package/dist/node-dev/ProductPrice.mjs +12 -17
  233. package/dist/node-dev/ProductPrice.mjs.map +1 -1
  234. package/dist/node-dev/ProductProvider.js +103 -74
  235. package/dist/node-dev/ProductProvider.js.map +1 -1
  236. package/dist/node-dev/ProductProvider.mjs +102 -73
  237. package/dist/node-dev/ProductProvider.mjs.map +1 -1
  238. package/dist/node-dev/ShopPayButton.js +14 -24
  239. package/dist/node-dev/ShopPayButton.js.map +1 -1
  240. package/dist/node-dev/ShopPayButton.mjs +14 -24
  241. package/dist/node-dev/ShopPayButton.mjs.map +1 -1
  242. package/dist/node-dev/ShopifyProvider.js +23 -39
  243. package/dist/node-dev/ShopifyProvider.js.map +1 -1
  244. package/dist/node-dev/ShopifyProvider.mjs +22 -38
  245. package/dist/node-dev/ShopifyProvider.mjs.map +1 -1
  246. package/dist/node-dev/Video.js +31 -22
  247. package/dist/node-dev/Video.js.map +1 -1
  248. package/dist/node-dev/Video.mjs +30 -21
  249. package/dist/node-dev/Video.mjs.map +1 -1
  250. package/dist/node-dev/_virtual/index.js +11 -3
  251. package/dist/node-dev/_virtual/index.js.map +1 -1
  252. package/dist/node-dev/_virtual/index.mjs +11 -2
  253. package/dist/node-dev/_virtual/index.mjs.map +1 -1
  254. package/dist/node-dev/_virtual/use-sync-external-store-shim.development.js +1 -1
  255. package/dist/node-dev/_virtual/use-sync-external-store-shim.production.min.js +1 -1
  256. package/dist/node-dev/_virtual/with-selector.development.js +1 -1
  257. package/dist/node-dev/_virtual/with-selector.js +11 -3
  258. package/dist/node-dev/_virtual/with-selector.js.map +1 -1
  259. package/dist/node-dev/_virtual/with-selector.mjs +11 -2
  260. package/dist/node-dev/_virtual/with-selector.mjs.map +1 -1
  261. package/dist/node-dev/_virtual/with-selector.production.min.js +1 -1
  262. package/dist/node-dev/analytics-constants.js +43 -0
  263. package/dist/node-dev/analytics-constants.js.map +1 -0
  264. package/dist/node-dev/analytics-constants.mjs +43 -0
  265. package/dist/node-dev/analytics-constants.mjs.map +1 -0
  266. package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.js +145 -0
  267. package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.js.map +1 -0
  268. package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.mjs +145 -0
  269. package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -0
  270. package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.js +58 -0
  271. package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.js.map +1 -0
  272. package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.mjs +58 -0
  273. package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -0
  274. package/dist/node-dev/analytics-utils.js +49 -0
  275. package/dist/node-dev/analytics-utils.js.map +1 -0
  276. package/dist/node-dev/analytics-utils.mjs +49 -0
  277. package/dist/node-dev/analytics-utils.mjs.map +1 -0
  278. package/dist/node-dev/analytics.js +159 -0
  279. package/dist/node-dev/analytics.js.map +1 -0
  280. package/dist/node-dev/analytics.mjs +159 -0
  281. package/dist/node-dev/analytics.mjs.map +1 -0
  282. package/dist/node-dev/cart-constants.js +1 -1
  283. package/dist/node-dev/cart-hooks.js +29 -34
  284. package/dist/node-dev/cart-hooks.js.map +1 -1
  285. package/dist/node-dev/cart-hooks.mjs +29 -34
  286. package/dist/node-dev/cart-hooks.mjs.map +1 -1
  287. package/dist/node-dev/cart-queries.js +51 -29
  288. package/dist/node-dev/cart-queries.js.map +1 -1
  289. package/dist/node-dev/cart-queries.mjs +50 -28
  290. package/dist/node-dev/cart-queries.mjs.map +1 -1
  291. package/dist/node-dev/codegen.helpers.js +2 -1
  292. package/dist/node-dev/codegen.helpers.js.map +1 -1
  293. package/dist/node-dev/codegen.helpers.mjs +1 -0
  294. package/dist/node-dev/codegen.helpers.mjs.map +1 -1
  295. package/dist/node-dev/cookies-utils.js +50 -0
  296. package/dist/node-dev/cookies-utils.js.map +1 -0
  297. package/dist/node-dev/cookies-utils.mjs +50 -0
  298. package/dist/node-dev/cookies-utils.mjs.map +1 -0
  299. package/dist/node-dev/flatten-connection.js +8 -6
  300. package/dist/node-dev/flatten-connection.js.map +1 -1
  301. package/dist/node-dev/flatten-connection.mjs +7 -5
  302. package/dist/node-dev/flatten-connection.mjs.map +1 -1
  303. package/dist/node-dev/image-size.js +9 -9
  304. package/dist/node-dev/image-size.js.map +1 -1
  305. package/dist/node-dev/image-size.mjs +8 -8
  306. package/dist/node-dev/image-size.mjs.map +1 -1
  307. package/dist/node-dev/index.js +21 -7
  308. package/dist/node-dev/index.js.map +1 -1
  309. package/dist/node-dev/index.mjs +20 -6
  310. package/dist/node-dev/index.mjs.map +1 -1
  311. package/dist/node-dev/load-script.js +1 -1
  312. package/dist/node-dev/load-script.js.map +1 -1
  313. package/dist/node-dev/load-script.mjs.map +1 -1
  314. package/dist/node-dev/node_modules/@xstate/fsm/es/index.js +1 -1
  315. package/dist/node-dev/node_modules/@xstate/fsm/es/index.js.map +1 -1
  316. package/dist/node-dev/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
  317. package/dist/node-dev/node_modules/@xstate/react/es/fsm.js +2 -2
  318. package/dist/node-dev/node_modules/@xstate/react/es/fsm.js.map +1 -1
  319. package/dist/node-dev/node_modules/@xstate/react/es/fsm.mjs +2 -2
  320. package/dist/node-dev/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
  321. package/dist/node-dev/node_modules/@xstate/react/es/useConstant.js +2 -4
  322. package/dist/node-dev/node_modules/@xstate/react/es/useConstant.js.map +1 -1
  323. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +2 -4
  324. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
  325. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -1
  326. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +2 -4
  327. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -1
  328. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
  329. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +2 -4
  330. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
  331. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +1 -1
  332. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +2 -4
  333. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
  334. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -1
  335. package/dist/node-dev/node_modules/use-sync-external-store/shim/index.js +4 -4
  336. package/dist/node-dev/node_modules/use-sync-external-store/shim/index.mjs +3 -3
  337. package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.js +1 -1
  338. package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
  339. package/dist/node-dev/{metafield-parser.js → parse-metafield.js} +21 -13
  340. package/dist/node-dev/parse-metafield.js.map +1 -0
  341. package/dist/node-dev/{metafield-parser.mjs → parse-metafield.mjs} +20 -12
  342. package/dist/node-dev/parse-metafield.mjs.map +1 -0
  343. package/dist/node-dev/storefront-api-constants.js +2 -2
  344. package/dist/node-dev/storefront-api-constants.js.map +1 -1
  345. package/dist/node-dev/storefront-api-constants.mjs +1 -1
  346. package/dist/node-dev/storefront-api-constants.mjs.map +1 -1
  347. package/dist/node-dev/storefront-client.js +20 -21
  348. package/dist/node-dev/storefront-client.js.map +1 -1
  349. package/dist/node-dev/storefront-client.mjs +19 -20
  350. package/dist/node-dev/storefront-client.mjs.map +1 -1
  351. package/dist/node-dev/useCartAPIStateMachine.js +112 -81
  352. package/dist/node-dev/useCartAPIStateMachine.js.map +1 -1
  353. package/dist/node-dev/useCartAPIStateMachine.mjs +111 -80
  354. package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -1
  355. package/dist/node-dev/useCartActions.js +151 -110
  356. package/dist/node-dev/useCartActions.js.map +1 -1
  357. package/dist/node-dev/useCartActions.mjs +150 -109
  358. package/dist/node-dev/useCartActions.mjs.map +1 -1
  359. package/dist/node-dev/useMoney.js +63 -37
  360. package/dist/node-dev/useMoney.js.map +1 -1
  361. package/dist/node-dev/useMoney.mjs +62 -36
  362. package/dist/node-dev/useMoney.mjs.map +1 -1
  363. package/dist/node-dev/useShopifyCookies.js +41 -0
  364. package/dist/node-dev/useShopifyCookies.js.map +1 -0
  365. package/dist/node-dev/useShopifyCookies.mjs +41 -0
  366. package/dist/node-dev/useShopifyCookies.mjs.map +1 -0
  367. package/dist/node-prod/AddToCartButton.js +44 -41
  368. package/dist/node-prod/AddToCartButton.js.map +1 -1
  369. package/dist/node-prod/AddToCartButton.mjs +43 -40
  370. package/dist/node-prod/AddToCartButton.mjs.map +1 -1
  371. package/dist/node-prod/BaseButton.js +14 -16
  372. package/dist/node-prod/BaseButton.js.map +1 -1
  373. package/dist/node-prod/BaseButton.mjs +13 -15
  374. package/dist/node-prod/BaseButton.mjs.map +1 -1
  375. package/dist/node-prod/BuyNowButton.js +20 -18
  376. package/dist/node-prod/BuyNowButton.js.map +1 -1
  377. package/dist/node-prod/BuyNowButton.mjs +19 -17
  378. package/dist/node-prod/BuyNowButton.mjs.map +1 -1
  379. package/dist/node-prod/CartCheckoutButton.js +13 -16
  380. package/dist/node-prod/CartCheckoutButton.js.map +1 -1
  381. package/dist/node-prod/CartCheckoutButton.mjs +12 -15
  382. package/dist/node-prod/CartCheckoutButton.mjs.map +1 -1
  383. package/dist/node-prod/CartCost.js +25 -0
  384. package/dist/node-prod/CartCost.js.map +1 -0
  385. package/dist/node-prod/CartCost.mjs +25 -0
  386. package/dist/node-prod/CartCost.mjs.map +1 -0
  387. package/dist/node-prod/CartLinePrice.js +18 -0
  388. package/dist/node-prod/CartLinePrice.js.map +1 -0
  389. package/dist/node-prod/CartLinePrice.mjs +18 -0
  390. package/dist/node-prod/CartLinePrice.mjs.map +1 -0
  391. package/dist/node-prod/CartLineProvider.js +19 -0
  392. package/dist/node-prod/CartLineProvider.js.map +1 -0
  393. package/dist/node-prod/CartLineProvider.mjs +19 -0
  394. package/dist/node-prod/CartLineProvider.mjs.map +1 -0
  395. package/dist/node-prod/CartProvider.js +74 -68
  396. package/dist/node-prod/CartProvider.js.map +1 -1
  397. package/dist/node-prod/CartProvider.mjs +73 -67
  398. package/dist/node-prod/CartProvider.mjs.map +1 -1
  399. package/dist/node-prod/ExternalVideo.js +14 -12
  400. package/dist/node-prod/ExternalVideo.js.map +1 -1
  401. package/dist/node-prod/ExternalVideo.mjs +13 -11
  402. package/dist/node-prod/ExternalVideo.mjs.map +1 -1
  403. package/dist/node-prod/Image.js +36 -29
  404. package/dist/node-prod/Image.js.map +1 -1
  405. package/dist/node-prod/Image.mjs +35 -28
  406. package/dist/node-prod/Image.mjs.map +1 -1
  407. package/dist/node-prod/MediaFile.js +30 -22
  408. package/dist/node-prod/MediaFile.js.map +1 -1
  409. package/dist/node-prod/MediaFile.mjs +29 -21
  410. package/dist/node-prod/MediaFile.mjs.map +1 -1
  411. package/dist/node-prod/ModelViewer.js +136 -76
  412. package/dist/node-prod/ModelViewer.js.map +1 -1
  413. package/dist/node-prod/ModelViewer.mjs +135 -75
  414. package/dist/node-prod/ModelViewer.mjs.map +1 -1
  415. package/dist/node-prod/Money.js +13 -10
  416. package/dist/node-prod/Money.js.map +1 -1
  417. package/dist/node-prod/Money.mjs +12 -9
  418. package/dist/node-prod/Money.mjs.map +1 -1
  419. package/dist/node-prod/ProductPrice.js +13 -18
  420. package/dist/node-prod/ProductPrice.js.map +1 -1
  421. package/dist/node-prod/ProductPrice.mjs +12 -17
  422. package/dist/node-prod/ProductPrice.mjs.map +1 -1
  423. package/dist/node-prod/ProductProvider.js +103 -74
  424. package/dist/node-prod/ProductProvider.js.map +1 -1
  425. package/dist/node-prod/ProductProvider.mjs +102 -73
  426. package/dist/node-prod/ProductProvider.mjs.map +1 -1
  427. package/dist/node-prod/ShopPayButton.js +14 -24
  428. package/dist/node-prod/ShopPayButton.js.map +1 -1
  429. package/dist/node-prod/ShopPayButton.mjs +14 -24
  430. package/dist/node-prod/ShopPayButton.mjs.map +1 -1
  431. package/dist/node-prod/ShopifyProvider.js +23 -33
  432. package/dist/node-prod/ShopifyProvider.js.map +1 -1
  433. package/dist/node-prod/ShopifyProvider.mjs +22 -32
  434. package/dist/node-prod/ShopifyProvider.mjs.map +1 -1
  435. package/dist/node-prod/Video.js +31 -22
  436. package/dist/node-prod/Video.js.map +1 -1
  437. package/dist/node-prod/Video.mjs +30 -21
  438. package/dist/node-prod/Video.mjs.map +1 -1
  439. package/dist/node-prod/_virtual/index.js +11 -3
  440. package/dist/node-prod/_virtual/index.js.map +1 -1
  441. package/dist/node-prod/_virtual/index.mjs +11 -2
  442. package/dist/node-prod/_virtual/index.mjs.map +1 -1
  443. package/dist/node-prod/_virtual/use-sync-external-store-shim.development.js +1 -1
  444. package/dist/node-prod/_virtual/use-sync-external-store-shim.production.min.js +1 -1
  445. package/dist/node-prod/_virtual/with-selector.development.js +1 -1
  446. package/dist/node-prod/_virtual/with-selector.js +11 -3
  447. package/dist/node-prod/_virtual/with-selector.js.map +1 -1
  448. package/dist/node-prod/_virtual/with-selector.mjs +11 -2
  449. package/dist/node-prod/_virtual/with-selector.mjs.map +1 -1
  450. package/dist/node-prod/_virtual/with-selector.production.min.js +1 -1
  451. package/dist/node-prod/analytics-constants.js +43 -0
  452. package/dist/node-prod/analytics-constants.js.map +1 -0
  453. package/dist/node-prod/analytics-constants.mjs +43 -0
  454. package/dist/node-prod/analytics-constants.mjs.map +1 -0
  455. package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.js +145 -0
  456. package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.js.map +1 -0
  457. package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.mjs +145 -0
  458. package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -0
  459. package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.js +58 -0
  460. package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.js.map +1 -0
  461. package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.mjs +58 -0
  462. package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -0
  463. package/dist/node-prod/analytics-utils.js +49 -0
  464. package/dist/node-prod/analytics-utils.js.map +1 -0
  465. package/dist/node-prod/analytics-utils.mjs +49 -0
  466. package/dist/node-prod/analytics-utils.mjs.map +1 -0
  467. package/dist/node-prod/analytics.js +158 -0
  468. package/dist/node-prod/analytics.js.map +1 -0
  469. package/dist/node-prod/analytics.mjs +158 -0
  470. package/dist/node-prod/analytics.mjs.map +1 -0
  471. package/dist/node-prod/cart-constants.js +1 -1
  472. package/dist/node-prod/cart-hooks.js +29 -34
  473. package/dist/node-prod/cart-hooks.js.map +1 -1
  474. package/dist/node-prod/cart-hooks.mjs +29 -34
  475. package/dist/node-prod/cart-hooks.mjs.map +1 -1
  476. package/dist/node-prod/cart-queries.js +51 -29
  477. package/dist/node-prod/cart-queries.js.map +1 -1
  478. package/dist/node-prod/cart-queries.mjs +50 -28
  479. package/dist/node-prod/cart-queries.mjs.map +1 -1
  480. package/dist/node-prod/codegen.helpers.js +2 -1
  481. package/dist/node-prod/codegen.helpers.js.map +1 -1
  482. package/dist/node-prod/codegen.helpers.mjs +1 -0
  483. package/dist/node-prod/codegen.helpers.mjs.map +1 -1
  484. package/dist/node-prod/cookies-utils.js +50 -0
  485. package/dist/node-prod/cookies-utils.js.map +1 -0
  486. package/dist/node-prod/cookies-utils.mjs +50 -0
  487. package/dist/node-prod/cookies-utils.mjs.map +1 -0
  488. package/dist/node-prod/flatten-connection.js +8 -6
  489. package/dist/node-prod/flatten-connection.js.map +1 -1
  490. package/dist/node-prod/flatten-connection.mjs +7 -5
  491. package/dist/node-prod/flatten-connection.mjs.map +1 -1
  492. package/dist/node-prod/image-size.js +9 -9
  493. package/dist/node-prod/image-size.js.map +1 -1
  494. package/dist/node-prod/image-size.mjs +8 -8
  495. package/dist/node-prod/image-size.mjs.map +1 -1
  496. package/dist/node-prod/index.js +21 -7
  497. package/dist/node-prod/index.js.map +1 -1
  498. package/dist/node-prod/index.mjs +20 -6
  499. package/dist/node-prod/index.mjs.map +1 -1
  500. package/dist/node-prod/load-script.js +1 -1
  501. package/dist/node-prod/load-script.js.map +1 -1
  502. package/dist/node-prod/load-script.mjs.map +1 -1
  503. package/dist/node-prod/node_modules/@xstate/fsm/es/index.js +1 -1
  504. package/dist/node-prod/node_modules/@xstate/fsm/es/index.js.map +1 -1
  505. package/dist/node-prod/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
  506. package/dist/node-prod/node_modules/@xstate/react/es/fsm.js +2 -2
  507. package/dist/node-prod/node_modules/@xstate/react/es/fsm.js.map +1 -1
  508. package/dist/node-prod/node_modules/@xstate/react/es/fsm.mjs +2 -2
  509. package/dist/node-prod/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
  510. package/dist/node-prod/node_modules/@xstate/react/es/useConstant.js +2 -4
  511. package/dist/node-prod/node_modules/@xstate/react/es/useConstant.js.map +1 -1
  512. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +2 -4
  513. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
  514. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -1
  515. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +2 -4
  516. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -1
  517. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
  518. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +2 -4
  519. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
  520. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +1 -1
  521. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +2 -4
  522. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
  523. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -1
  524. package/dist/node-prod/node_modules/use-sync-external-store/shim/index.js +4 -4
  525. package/dist/node-prod/node_modules/use-sync-external-store/shim/index.mjs +3 -3
  526. package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.js +1 -1
  527. package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
  528. package/dist/node-prod/{metafield-parser.js → parse-metafield.js} +21 -13
  529. package/dist/node-prod/parse-metafield.js.map +1 -0
  530. package/dist/node-prod/{metafield-parser.mjs → parse-metafield.mjs} +20 -12
  531. package/dist/node-prod/parse-metafield.mjs.map +1 -0
  532. package/dist/node-prod/storefront-api-constants.js +2 -2
  533. package/dist/node-prod/storefront-api-constants.js.map +1 -1
  534. package/dist/node-prod/storefront-api-constants.mjs +1 -1
  535. package/dist/node-prod/storefront-api-constants.mjs.map +1 -1
  536. package/dist/node-prod/storefront-client.js +20 -21
  537. package/dist/node-prod/storefront-client.js.map +1 -1
  538. package/dist/node-prod/storefront-client.mjs +19 -20
  539. package/dist/node-prod/storefront-client.mjs.map +1 -1
  540. package/dist/node-prod/useCartAPIStateMachine.js +112 -81
  541. package/dist/node-prod/useCartAPIStateMachine.js.map +1 -1
  542. package/dist/node-prod/useCartAPIStateMachine.mjs +111 -80
  543. package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -1
  544. package/dist/node-prod/useCartActions.js +151 -110
  545. package/dist/node-prod/useCartActions.js.map +1 -1
  546. package/dist/node-prod/useCartActions.mjs +150 -109
  547. package/dist/node-prod/useCartActions.mjs.map +1 -1
  548. package/dist/node-prod/useMoney.js +63 -37
  549. package/dist/node-prod/useMoney.js.map +1 -1
  550. package/dist/node-prod/useMoney.mjs +62 -36
  551. package/dist/node-prod/useMoney.mjs.map +1 -1
  552. package/dist/node-prod/useShopifyCookies.js +41 -0
  553. package/dist/node-prod/useShopifyCookies.js.map +1 -0
  554. package/dist/node-prod/useShopifyCookies.mjs +41 -0
  555. package/dist/node-prod/useShopifyCookies.mjs.map +1 -0
  556. package/dist/types/AddToCartButton.d.ts +3 -2
  557. package/dist/types/BuyNowButton.d.ts +7 -3
  558. package/dist/types/CartCheckoutButton.d.ts +6 -5
  559. package/dist/types/CartCost.d.ts +7 -5
  560. package/dist/types/CartLinePrice.d.ts +4 -4
  561. package/dist/types/CartLineProvider.d.ts +8 -6
  562. package/dist/types/CartProvider.d.ts +12 -2
  563. package/dist/types/ExternalVideo.d.ts +1 -2
  564. package/dist/types/Image.d.ts +5 -3
  565. package/dist/types/MediaFile.d.ts +12 -11
  566. package/dist/types/ModelViewer.d.ts +2 -2
  567. package/dist/types/ProductPrice.d.ts +1 -1
  568. package/dist/types/ProductProvider.d.ts +1 -1
  569. package/dist/types/ShopPayButton.d.ts +10 -10
  570. package/dist/types/ShopifyProvider.d.ts +36 -40
  571. package/dist/types/analytics-constants.d.ts +48 -0
  572. package/dist/types/analytics-schema-custom-storefront-customer-tracking.d.ts +3 -0
  573. package/dist/types/analytics-schema-trekkie-storefront-page-view.d.ts +2 -0
  574. package/dist/types/analytics-types.d.ts +108 -0
  575. package/dist/types/analytics-utils.d.ts +36 -0
  576. package/dist/types/analytics.d.ts +9 -0
  577. package/dist/types/cart-queries.d.ts +1 -1
  578. package/dist/types/cookies-utils.d.ts +4 -0
  579. package/dist/types/flatten-connection.d.ts +29 -9
  580. package/dist/types/index.d.cts +11 -4
  581. package/dist/types/index.d.ts +11 -4
  582. package/dist/types/{metafield-parser.d.ts → parse-metafield.d.ts} +11 -9
  583. package/dist/types/storefront-api-constants.d.ts +1 -1
  584. package/dist/types/storefront-api-types.d.ts +121 -2
  585. package/dist/types/storefront-client.d.ts +14 -14
  586. package/dist/types/useCartActions.d.ts +1 -1
  587. package/dist/types/useShopifyCookies.d.ts +14 -0
  588. package/dist/umd/hydrogen-react.dev.js +1634 -1371
  589. package/dist/umd/hydrogen-react.dev.js.map +1 -1
  590. package/dist/umd/hydrogen-react.prod.js +18 -25
  591. package/dist/umd/hydrogen-react.prod.js.map +1 -1
  592. package/package.json +24 -19
  593. package/storefront.schema.json +1 -1
  594. package/dist/browser-dev/Metafield.mjs +0 -301
  595. package/dist/browser-dev/Metafield.mjs.map +0 -1
  596. package/dist/browser-dev/metafield-parser.mjs.map +0 -1
  597. package/dist/browser-prod/Metafield.mjs +0 -288
  598. package/dist/browser-prod/Metafield.mjs.map +0 -1
  599. package/dist/browser-prod/metafield-parser.mjs.map +0 -1
  600. package/dist/node-dev/Metafield.js +0 -301
  601. package/dist/node-dev/Metafield.js.map +0 -1
  602. package/dist/node-dev/Metafield.mjs +0 -301
  603. package/dist/node-dev/Metafield.mjs.map +0 -1
  604. package/dist/node-dev/metafield-parser.js.map +0 -1
  605. package/dist/node-dev/metafield-parser.mjs.map +0 -1
  606. package/dist/node-prod/Metafield.js +0 -288
  607. package/dist/node-prod/Metafield.js.map +0 -1
  608. package/dist/node-prod/Metafield.mjs +0 -288
  609. package/dist/node-prod/Metafield.mjs.map +0 -1
  610. package/dist/node-prod/metafield-parser.js.map +0 -1
  611. package/dist/node-prod/metafield-parser.mjs.map +0 -1
  612. package/dist/types/Metafield.d.ts +0 -61
@@ -1 +1 @@
1
- {"version":3,"file":"ModelViewer.mjs","sources":["../../src/ModelViewer.tsx"],"sourcesContent":["import {useState, useEffect, useCallback} from 'react';\nimport {useLoadScript} from './load-script.js';\nimport type {Model3d} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\nimport type {ModelViewerElement} from '@google/model-viewer/lib/model-viewer.js';\n\ntype PropsWeControl = 'src';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'model-viewer': PartialDeep<\n ModelViewerElement,\n {recurseIntoArrays: true}\n >;\n }\n }\n}\n\ntype ModelViewerProps = Omit<\n PartialDeep<JSX.IntrinsicElements['model-viewer'], {recurseIntoArrays: true}>,\n PropsWeControl\n> & {\n /** An object with fields that correspond to the Storefront API's [Model3D object](https://shopify.dev/api/storefront/latest/objects/model3d). */\n data: PartialDeep<Model3d, {recurseIntoArrays: true}>;\n /** The callback to invoke when the 'error' event is triggered. Refer to [error in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-error). */\n onError?: (event: Event) => void;\n /** The callback to invoke when the `load` event is triggered. Refer to [load in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-load). */\n onLoad?: (event: Event) => void;\n /** The callback to invoke when the 'preload' event is triggered. Refer to [preload in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-preload). */\n onPreload?: (event: Event) => void;\n /** The callback to invoke when the 'model-visibility' event is triggered. Refer to [model-visibility in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-modelVisibility). */\n onModelVisibility?: (event: Event) => void;\n /** The callback to invoke when the 'progress' event is triggered. Refer to [progress in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-progress). */\n onProgress?: (event: Event) => void;\n /** The callback to invoke when the 'ar-status' event is triggered. Refer to [ar-status in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-events-arStatus). */\n onArStatus?: (event: Event) => void;\n /** The callback to invoke when the 'ar-tracking' event is triggered. Refer to [ar-tracking in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-events-arTracking). */\n onArTracking?: (event: Event) => void;\n /** The callback to invoke when the 'quick-look-button-tapped' event is triggered. Refer to [quick-look-button-tapped in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-events-quickLookButtonTapped). */\n onQuickLookButtonTapped?: (event: Event) => void;\n /** The callback to invoke when the 'camera-change' event is triggered. Refer to [camera-change in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-stagingandcameras-events-cameraChange). */\n onCameraChange?: (event: Event) => void;\n /** The callback to invoke when the 'environment-change' event is triggered. Refer to [environment-change in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-lightingandenv-events-environmentChange). */\n onEnvironmentChange?: (event: Event) => void;\n /** The callback to invoke when the 'play' event is triggered. Refer to [play in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-animation-events-play). */\n onPlay?: (event: Event) => void;\n /** The callback to invoke when the 'pause' event is triggered. Refer to [pause in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-animation-events-pause). */\n onPause?: (event: Event) => void;\n /** The callback to invoke when the 'scene-graph-ready' event is triggered. Refer to [scene-graph-ready in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-scenegraph-events-sceneGraphReady). */\n onSceneGraphReady?: (event: Event) => void;\n};\n\n/**\n * The `ModelViewer` component renders a 3D model (with the `model-viewer` custom element) for\n * the Storefront API's [Model3d object](https://shopify.dev/api/storefront/reference/products/model3d).\n *\n * The `model-viewer` custom element is lazily downloaded through a dynamically-injected `<script type=\"module\">` tag when the `<ModelViewer />` component is rendered\n *\n * ModelViewer is using version `1.21.1` of the `@google/model-viewer` library.\n */\nexport function ModelViewer(props: ModelViewerProps) {\n const [modelViewer, setModelViewer] = useState<undefined | HTMLElement>(\n undefined\n );\n const callbackRef = useCallback((node: HTMLElement) => {\n setModelViewer(node);\n }, []);\n const {data, children, className, ...passthroughProps} = props;\n\n const modelViewerLoadedStatus = useLoadScript(\n 'https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js',\n {\n module: true,\n }\n );\n\n useEffect(() => {\n if (!modelViewer) {\n return;\n }\n if (passthroughProps.onError)\n modelViewer.addEventListener('error', passthroughProps.onError);\n if (passthroughProps.onLoad)\n modelViewer.addEventListener('load', passthroughProps.onLoad);\n if (passthroughProps.onPreload)\n modelViewer.addEventListener('preload', passthroughProps.onPreload);\n if (passthroughProps.onModelVisibility)\n modelViewer.addEventListener(\n 'model-visibility',\n passthroughProps.onModelVisibility\n );\n if (passthroughProps.onProgress)\n modelViewer.addEventListener('progress', passthroughProps.onProgress);\n if (passthroughProps.onArStatus)\n modelViewer.addEventListener('ar-status', passthroughProps.onArStatus);\n if (passthroughProps.onArTracking)\n modelViewer.addEventListener(\n 'ar-tracking',\n passthroughProps.onArTracking\n );\n if (passthroughProps.onQuickLookButtonTapped)\n modelViewer.addEventListener(\n 'quick-look-button-tapped',\n passthroughProps.onQuickLookButtonTapped\n );\n if (passthroughProps.onCameraChange)\n modelViewer.addEventListener(\n 'camera-change',\n passthroughProps.onCameraChange\n );\n if (passthroughProps.onEnvironmentChange)\n modelViewer.addEventListener(\n 'environment-change',\n passthroughProps.onEnvironmentChange\n );\n if (passthroughProps.onPlay)\n modelViewer.addEventListener('play', passthroughProps.onPlay);\n if (passthroughProps.onPause)\n modelViewer.addEventListener('ar-status', passthroughProps.onPause);\n if (passthroughProps.onSceneGraphReady)\n modelViewer.addEventListener(\n 'scene-graph-ready',\n passthroughProps.onSceneGraphReady\n );\n\n return () => {\n if (modelViewer == null) {\n return;\n }\n if (passthroughProps.onError)\n modelViewer.removeEventListener('error', passthroughProps.onError);\n if (passthroughProps.onLoad)\n modelViewer.removeEventListener('load', passthroughProps.onLoad);\n if (passthroughProps.onPreload)\n modelViewer.removeEventListener('preload', passthroughProps.onPreload);\n if (passthroughProps.onModelVisibility)\n modelViewer.removeEventListener(\n 'model-visibility',\n passthroughProps.onModelVisibility\n );\n if (passthroughProps.onProgress)\n modelViewer.removeEventListener(\n 'progress',\n passthroughProps.onProgress\n );\n if (passthroughProps.onArStatus)\n modelViewer.removeEventListener(\n 'ar-status',\n passthroughProps.onArStatus\n );\n if (passthroughProps.onArTracking)\n modelViewer.removeEventListener(\n 'ar-tracking',\n passthroughProps.onArTracking\n );\n if (passthroughProps.onQuickLookButtonTapped)\n modelViewer.removeEventListener(\n 'quick-look-button-tapped',\n passthroughProps.onQuickLookButtonTapped\n );\n if (passthroughProps.onCameraChange)\n modelViewer.removeEventListener(\n 'camera-change',\n passthroughProps.onCameraChange\n );\n if (passthroughProps.onEnvironmentChange)\n modelViewer.removeEventListener(\n 'environment-change',\n passthroughProps.onEnvironmentChange\n );\n if (passthroughProps.onPlay)\n modelViewer.removeEventListener('play', passthroughProps.onPlay);\n if (passthroughProps.onPause)\n modelViewer.removeEventListener('ar-status', passthroughProps.onPause);\n if (passthroughProps.onSceneGraphReady)\n modelViewer.removeEventListener(\n 'scene-graph-ready',\n passthroughProps.onSceneGraphReady\n );\n };\n }, [\n modelViewer,\n passthroughProps.onArStatus,\n passthroughProps.onArTracking,\n passthroughProps.onCameraChange,\n passthroughProps.onEnvironmentChange,\n passthroughProps.onError,\n passthroughProps.onLoad,\n passthroughProps.onModelVisibility,\n passthroughProps.onPause,\n passthroughProps.onPlay,\n passthroughProps.onPreload,\n passthroughProps.onProgress,\n passthroughProps.onQuickLookButtonTapped,\n passthroughProps.onSceneGraphReady,\n ]);\n\n if (modelViewerLoadedStatus !== 'done') {\n // TODO: What do we want to display while the model-viewer library loads?\n return null;\n }\n\n if (!data.sources?.[0]?.url) {\n const sourcesUrlError = `<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'`;\n if (__HYDROGEN_DEV__) {\n throw new Error(sourcesUrlError);\n } else {\n console.error(sourcesUrlError);\n return null;\n }\n }\n\n if (__HYDROGEN_DEV__ && !data.alt) {\n console.warn(\n `<ModelViewer/> requires the 'data.alt' prop for accessibility`\n );\n }\n\n return (\n <model-viewer\n // @ts-expect-error ref should exist\n ref={callbackRef}\n {...passthroughProps}\n className={className}\n id={passthroughProps.id ?? data.id}\n src={data.sources[0].url}\n alt={data.alt ?? null}\n camera-controls={passthroughProps.cameraControls ?? true}\n poster={(passthroughProps.poster || data.previewImage?.url) ?? null}\n autoplay={passthroughProps.autoplay ?? true}\n loading={passthroughProps.loading}\n reveal={passthroughProps.reveal}\n ar={passthroughProps.ar}\n ar-modes={passthroughProps.arModes}\n ar-scale={passthroughProps.arScale}\n // @ts-expect-error arPlacement should exist as a type, not sure why it doesn't. https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-attributes-arPlacement\n ar-placement={passthroughProps.arPlacement}\n ios-src={passthroughProps.iosSrc}\n touch-action={passthroughProps.touchAction}\n disable-zoom={passthroughProps.disableZoom}\n orbit-sensitivity={passthroughProps.orbitSensitivity}\n auto-rotate={passthroughProps.autoRotate}\n auto-rotate-delay={passthroughProps.autoRotateDelay}\n // @ts-expect-error rotationPerSecond should exist as a type, not sure why it doesn't. https://modelviewer.dev/docs/index.html#entrydocs-stagingandcameras-attributes-rotationPerSecond\n rotation-per-second={passthroughProps.rotationPerSecond}\n interaction-policy={passthroughProps.interactionPolicy}\n interaction-prompt={passthroughProps.interactionPrompt}\n interaction-prompt-style={passthroughProps.interactionPromptStyle}\n interaction-prompt-threshold={passthroughProps.interactionPromptThreshold}\n camera-orbit={passthroughProps.cameraOrbit}\n camera-target={passthroughProps.cameraTarget}\n field-of-view={passthroughProps.fieldOfView}\n max-camera-orbit={passthroughProps.maxCameraOrbit}\n min-camera-orbit={passthroughProps.minCameraOrbit}\n max-field-of-view={passthroughProps.maxFieldOfView}\n min-field-of-view={passthroughProps.minFieldOfView}\n bounds={passthroughProps.bounds}\n interpolation-decay={passthroughProps.interpolationDecay ?? 100}\n skybox-image={passthroughProps.skyboxImage}\n environment-image={passthroughProps.environmentImage}\n exposure={passthroughProps.exposure}\n shadow-intensity={passthroughProps.shadowIntensity ?? 0}\n shadow-softness={passthroughProps.shadowSoftness ?? 0}\n animation-name={passthroughProps.animationName}\n animation-crossfade-duration={passthroughProps.animationCrossfadeDuration}\n variant-name={passthroughProps.variantName}\n orientation={passthroughProps.orientation}\n scale={passthroughProps.scale}\n >\n {children}\n </model-viewer>\n );\n}\n"],"names":["ModelViewer","props","modelViewer","setModelViewer","useState","undefined","callbackRef","useCallback","node","data","children","className","passthroughProps","modelViewerLoadedStatus","useLoadScript","module","useEffect","onError","addEventListener","onLoad","onPreload","onModelVisibility","onProgress","onArStatus","onArTracking","onQuickLookButtonTapped","onCameraChange","onEnvironmentChange","onPlay","onPause","onSceneGraphReady","removeEventListener","sources","url","sourcesUrlError","console","error","id","alt","cameraControls","poster","previewImage","autoplay","loading","reveal","ar","arModes","arScale","arPlacement","iosSrc","touchAction","disableZoom","orbitSensitivity","autoRotate","autoRotateDelay","rotationPerSecond","interactionPolicy","interactionPrompt","interactionPromptStyle","interactionPromptThreshold","cameraOrbit","cameraTarget","fieldOfView","maxCameraOrbit","minCameraOrbit","maxFieldOfView","minFieldOfView","bounds","interpolationDecay","skyboxImage","environmentImage","exposure","shadowIntensity","shadowSoftness","animationName","animationCrossfadeDuration","variantName","orientation","scale"],"mappings":";;;AA8DO,SAASA,YAAYC,OAAyB;;AACnD,QAAM,CAACC,aAAaC,cAAc,IAAIC,SACpCC,MAAS;AAELC,QAAAA,cAAcC,YAAY,CAACC,SAAsB;AACrDL,mBAAeK,IAAI;AAAA,EACrB,GAAG,CAAE,CAAA;AACC,QAAA;AAAA,IAACC;AAAAA,IAAMC;AAAAA,IAAUC;AAAAA,OAAcC;AAAAA,EAAoBX,IAAAA;AAEnDY,QAAAA,0BAA0BC,cAC9B,2EACA;AAAA,IACEC,QAAQ;AAAA,EAAA,CACT;AAGHC,YAAU,MAAM;AACd,QAAI,CAACd,aAAa;AAChB;AAAA,IACF;AACA,QAAIU,iBAAiBK;AACPC,kBAAAA,iBAAiB,SAASN,iBAAiBK,OAAO;AAChE,QAAIL,iBAAiBO;AACPD,kBAAAA,iBAAiB,QAAQN,iBAAiBO,MAAM;AAC9D,QAAIP,iBAAiBQ;AACPF,kBAAAA,iBAAiB,WAAWN,iBAAiBQ,SAAS;AACpE,QAAIR,iBAAiBS;AACPH,kBAAAA,iBACV,oBACAN,iBAAiBS,iBAAiB;AAEtC,QAAIT,iBAAiBU;AACPJ,kBAAAA,iBAAiB,YAAYN,iBAAiBU,UAAU;AACtE,QAAIV,iBAAiBW;AACPL,kBAAAA,iBAAiB,aAAaN,iBAAiBW,UAAU;AACvE,QAAIX,iBAAiBY;AACPN,kBAAAA,iBACV,eACAN,iBAAiBY,YAAY;AAEjC,QAAIZ,iBAAiBa;AACPP,kBAAAA,iBACV,4BACAN,iBAAiBa,uBAAuB;AAE5C,QAAIb,iBAAiBc;AACPR,kBAAAA,iBACV,iBACAN,iBAAiBc,cAAc;AAEnC,QAAId,iBAAiBe;AACPT,kBAAAA,iBACV,sBACAN,iBAAiBe,mBAAmB;AAExC,QAAIf,iBAAiBgB;AACPV,kBAAAA,iBAAiB,QAAQN,iBAAiBgB,MAA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AAoB3C,iBAAiB4C;AAAAA,IACrC,sBAAoB5C,iBAAiB6C;AAAAA,IACrC,4BAA0B7C,iBAAiB8C;AAAAA,IAC3C,gCAA8B9C,iBAAiB+C;AAAAA,IAC/C,gBAAc/C,iBAAiBgD;AAAAA,IAC/B,iBAAehD,iBAAiBiD;AAAAA,IAChC,iBAAejD,iBAAiBkD;AAAAA,IAChC,oBAAkBlD,iBAAiBmD;AAAAA,IACnC,oBAAkBnD,iBAAiBoD;AAAAA,IACnC,qBAAmBpD,iBAAiBqD;AAAAA,IACpC,qBAAmBrD,iBAAiBsD;AAAAA,IACpC,QAAQtD,iBAAiBuD;AAAAA,IACzB,wBAAqBvD,sBAAiBwD,uBAAjBxD,YAAuC;AAAA,IAC5D,gBAAcA,iBAAiByD;AAAAA,IAC/B,qBAAmBzD,iBAAiB0D;AAAAA,IACpC,UAAU1D,iBAAiB2D;AAAAA,IAC3B,qBAAkB3D,sBAAiB4D,oBAAjB5D,YAAoC;AAAA,IACtD,oBAAiBA,sBAAiB6D,mBAAjB7D,YAAmC;AAAA,IACpD,kBAAgBA,iBAAiB8D;AAAAA,IACjC,gCAA8B9D,iBAAiB+D;AAAAA,IAC/C,gBAAc/D,iBAAiBgE;AAAAA,IAC/B,aAAahE,iBAAiBiE;AAAAA,IAC9B,OAAOjE,iBAAiBkE;AAAAA,IAAM;AAAA,EAAA,CAGjB;AAEnB;"}
1
+ {"version":3,"file":"ModelViewer.mjs","sources":["../../src/ModelViewer.tsx"],"sourcesContent":["import {useState, useEffect, useCallback} from 'react';\nimport {useLoadScript} from './load-script.js';\nimport type {Model3d} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\nimport type {ModelViewerElement} from '@google/model-viewer/lib/model-viewer.js';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'model-viewer': PartialDeep<\n ModelViewerElement,\n {recurseIntoArrays: true}\n >;\n }\n }\n}\n\ntype ModelViewerProps = Omit<\n PartialDeep<JSX.IntrinsicElements['model-viewer'], {recurseIntoArrays: true}>,\n 'src'\n> &\n ModelViewerBaseProps;\n\ntype ModelViewerBaseProps = {\n /** An object with fields that correspond to the Storefront API's [Model3D object](https://shopify.dev/api/storefront/latest/objects/model3d). */\n data: PartialDeep<Model3d, {recurseIntoArrays: true}>;\n /** The callback to invoke when the 'error' event is triggered. Refer to [error in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-error). */\n onError?: (event: Event) => void;\n /** The callback to invoke when the `load` event is triggered. Refer to [load in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-load). */\n onLoad?: (event: Event) => void;\n /** The callback to invoke when the 'preload' event is triggered. Refer to [preload in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-preload). */\n onPreload?: (event: Event) => void;\n /** The callback to invoke when the 'model-visibility' event is triggered. Refer to [model-visibility in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-modelVisibility). */\n onModelVisibility?: (event: Event) => void;\n /** The callback to invoke when the 'progress' event is triggered. Refer to [progress in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-progress). */\n onProgress?: (event: Event) => void;\n /** The callback to invoke when the 'ar-status' event is triggered. Refer to [ar-status in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-events-arStatus). */\n onArStatus?: (event: Event) => void;\n /** The callback to invoke when the 'ar-tracking' event is triggered. Refer to [ar-tracking in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-events-arTracking). */\n onArTracking?: (event: Event) => void;\n /** The callback to invoke when the 'quick-look-button-tapped' event is triggered. Refer to [quick-look-button-tapped in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-events-quickLookButtonTapped). */\n onQuickLookButtonTapped?: (event: Event) => void;\n /** The callback to invoke when the 'camera-change' event is triggered. Refer to [camera-change in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-stagingandcameras-events-cameraChange). */\n onCameraChange?: (event: Event) => void;\n /** The callback to invoke when the 'environment-change' event is triggered. Refer to [environment-change in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-lightingandenv-events-environmentChange). */\n onEnvironmentChange?: (event: Event) => void;\n /** The callback to invoke when the 'play' event is triggered. Refer to [play in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-animation-events-play). */\n onPlay?: (event: Event) => void;\n /** The callback to invoke when the 'pause' event is triggered. Refer to [pause in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-animation-events-pause). */\n onPause?: (event: Event) => void;\n /** The callback to invoke when the 'scene-graph-ready' event is triggered. Refer to [scene-graph-ready in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-scenegraph-events-sceneGraphReady). */\n onSceneGraphReady?: (event: Event) => void;\n};\n\n/**\n * The `ModelViewer` component renders a 3D model (with the `model-viewer` custom element) for\n * the Storefront API's [Model3d object](https://shopify.dev/api/storefront/reference/products/model3d).\n *\n * The `model-viewer` custom element is lazily downloaded through a dynamically-injected `<script type=\"module\">` tag when the `<ModelViewer />` component is rendered\n *\n * ModelViewer is using version `1.21.1` of the `@google/model-viewer` library.\n */\nexport function ModelViewer(props: ModelViewerProps) {\n const [modelViewer, setModelViewer] = useState<undefined | HTMLElement>(\n undefined\n );\n const callbackRef = useCallback((node: HTMLElement) => {\n setModelViewer(node);\n }, []);\n const {data, children, className, ...passthroughProps} = props;\n\n const modelViewerLoadedStatus = useLoadScript(\n 'https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js',\n {\n module: true,\n }\n );\n\n useEffect(() => {\n if (!modelViewer) {\n return;\n }\n if (passthroughProps.onError)\n modelViewer.addEventListener('error', passthroughProps.onError);\n if (passthroughProps.onLoad)\n modelViewer.addEventListener('load', passthroughProps.onLoad);\n if (passthroughProps.onPreload)\n modelViewer.addEventListener('preload', passthroughProps.onPreload);\n if (passthroughProps.onModelVisibility)\n modelViewer.addEventListener(\n 'model-visibility',\n passthroughProps.onModelVisibility\n );\n if (passthroughProps.onProgress)\n modelViewer.addEventListener('progress', passthroughProps.onProgress);\n if (passthroughProps.onArStatus)\n modelViewer.addEventListener('ar-status', passthroughProps.onArStatus);\n if (passthroughProps.onArTracking)\n modelViewer.addEventListener(\n 'ar-tracking',\n passthroughProps.onArTracking\n );\n if (passthroughProps.onQuickLookButtonTapped)\n modelViewer.addEventListener(\n 'quick-look-button-tapped',\n passthroughProps.onQuickLookButtonTapped\n );\n if (passthroughProps.onCameraChange)\n modelViewer.addEventListener(\n 'camera-change',\n passthroughProps.onCameraChange\n );\n if (passthroughProps.onEnvironmentChange)\n modelViewer.addEventListener(\n 'environment-change',\n passthroughProps.onEnvironmentChange\n );\n if (passthroughProps.onPlay)\n modelViewer.addEventListener('play', passthroughProps.onPlay);\n if (passthroughProps.onPause)\n modelViewer.addEventListener('ar-status', passthroughProps.onPause);\n if (passthroughProps.onSceneGraphReady)\n modelViewer.addEventListener(\n 'scene-graph-ready',\n passthroughProps.onSceneGraphReady\n );\n\n return () => {\n if (modelViewer == null) {\n return;\n }\n if (passthroughProps.onError)\n modelViewer.removeEventListener('error', passthroughProps.onError);\n if (passthroughProps.onLoad)\n modelViewer.removeEventListener('load', passthroughProps.onLoad);\n if (passthroughProps.onPreload)\n modelViewer.removeEventListener('preload', passthroughProps.onPreload);\n if (passthroughProps.onModelVisibility)\n modelViewer.removeEventListener(\n 'model-visibility',\n passthroughProps.onModelVisibility\n );\n if (passthroughProps.onProgress)\n modelViewer.removeEventListener(\n 'progress',\n passthroughProps.onProgress\n );\n if (passthroughProps.onArStatus)\n modelViewer.removeEventListener(\n 'ar-status',\n passthroughProps.onArStatus\n );\n if (passthroughProps.onArTracking)\n modelViewer.removeEventListener(\n 'ar-tracking',\n passthroughProps.onArTracking\n );\n if (passthroughProps.onQuickLookButtonTapped)\n modelViewer.removeEventListener(\n 'quick-look-button-tapped',\n passthroughProps.onQuickLookButtonTapped\n );\n if (passthroughProps.onCameraChange)\n modelViewer.removeEventListener(\n 'camera-change',\n passthroughProps.onCameraChange\n );\n if (passthroughProps.onEnvironmentChange)\n modelViewer.removeEventListener(\n 'environment-change',\n passthroughProps.onEnvironmentChange\n );\n if (passthroughProps.onPlay)\n modelViewer.removeEventListener('play', passthroughProps.onPlay);\n if (passthroughProps.onPause)\n modelViewer.removeEventListener('ar-status', passthroughProps.onPause);\n if (passthroughProps.onSceneGraphReady)\n modelViewer.removeEventListener(\n 'scene-graph-ready',\n passthroughProps.onSceneGraphReady\n );\n };\n }, [\n modelViewer,\n passthroughProps.onArStatus,\n passthroughProps.onArTracking,\n passthroughProps.onCameraChange,\n passthroughProps.onEnvironmentChange,\n passthroughProps.onError,\n passthroughProps.onLoad,\n passthroughProps.onModelVisibility,\n passthroughProps.onPause,\n passthroughProps.onPlay,\n passthroughProps.onPreload,\n passthroughProps.onProgress,\n passthroughProps.onQuickLookButtonTapped,\n passthroughProps.onSceneGraphReady,\n ]);\n\n if (modelViewerLoadedStatus !== 'done') {\n // TODO: What do we want to display while the model-viewer library loads?\n return null;\n }\n\n if (!data.sources?.[0]?.url) {\n const sourcesUrlError = `<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'`;\n if (__HYDROGEN_DEV__) {\n throw new Error(sourcesUrlError);\n } else {\n console.error(sourcesUrlError);\n return null;\n }\n }\n\n if (__HYDROGEN_DEV__ && !data.alt) {\n console.warn(\n `<ModelViewer/> requires the 'data.alt' prop for accessibility`\n );\n }\n\n return (\n <model-viewer\n // @ts-expect-error ref should exist\n ref={callbackRef}\n {...passthroughProps}\n className={className}\n id={passthroughProps.id ?? data.id}\n src={data.sources[0].url}\n alt={data.alt ?? null}\n camera-controls={passthroughProps.cameraControls ?? true}\n poster={(passthroughProps.poster || data.previewImage?.url) ?? null}\n autoplay={passthroughProps.autoplay ?? true}\n loading={passthroughProps.loading}\n reveal={passthroughProps.reveal}\n ar={passthroughProps.ar}\n ar-modes={passthroughProps.arModes}\n ar-scale={passthroughProps.arScale}\n // @ts-expect-error arPlacement should exist as a type, not sure why it doesn't. https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-attributes-arPlacement\n ar-placement={passthroughProps.arPlacement}\n ios-src={passthroughProps.iosSrc}\n touch-action={passthroughProps.touchAction}\n disable-zoom={passthroughProps.disableZoom}\n orbit-sensitivity={passthroughProps.orbitSensitivity}\n auto-rotate={passthroughProps.autoRotate}\n auto-rotate-delay={passthroughProps.autoRotateDelay}\n // @ts-expect-error rotationPerSecond should exist as a type, not sure why it doesn't. https://modelviewer.dev/docs/index.html#entrydocs-stagingandcameras-attributes-rotationPerSecond\n rotation-per-second={passthroughProps.rotationPerSecond}\n interaction-policy={passthroughProps.interactionPolicy}\n interaction-prompt={passthroughProps.interactionPrompt}\n interaction-prompt-style={passthroughProps.interactionPromptStyle}\n interaction-prompt-threshold={passthroughProps.interactionPromptThreshold}\n camera-orbit={passthroughProps.cameraOrbit}\n camera-target={passthroughProps.cameraTarget}\n field-of-view={passthroughProps.fieldOfView}\n max-camera-orbit={passthroughProps.maxCameraOrbit}\n min-camera-orbit={passthroughProps.minCameraOrbit}\n max-field-of-view={passthroughProps.maxFieldOfView}\n min-field-of-view={passthroughProps.minFieldOfView}\n bounds={passthroughProps.bounds}\n interpolation-decay={passthroughProps.interpolationDecay ?? 100}\n skybox-image={passthroughProps.skyboxImage}\n environment-image={passthroughProps.environmentImage}\n exposure={passthroughProps.exposure}\n shadow-intensity={passthroughProps.shadowIntensity ?? 0}\n shadow-softness={passthroughProps.shadowSoftness ?? 0}\n animation-name={passthroughProps.animationName}\n animation-crossfade-duration={passthroughProps.animationCrossfadeDuration}\n variant-name={passthroughProps.variantName}\n orientation={passthroughProps.orientation}\n scale={passthroughProps.scale}\n >\n {children}\n </model-viewer>\n );\n}\n"],"names":[],"mappings":";;;AA+DO,SAAS,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B,iBAAiB;AAAA,MACpC,qBAAmB,iBAAiB;AAAA,MACpC,QAAQ,iBAAiB;AAAA,MACzB,uBAAqB,iBAAiB,sBAAsB;AAAA,MAC5D,gBAAc,iBAAiB;AAAA,MAC/B,qBAAmB,iBAAiB;AAAA,MACpC,UAAU,iBAAiB;AAAA,MAC3B,oBAAkB,iBAAiB,mBAAmB;AAAA,MACtD,mBAAiB,iBAAiB,kBAAkB;AAAA,MACpD,kBAAgB,iBAAiB;AAAA,MACjC,gCAA8B,iBAAiB;AAAA,MAC/C,gBAAc,iBAAiB;AAAA,MAC/B,aAAa,iBAAiB;AAAA,MAC9B,OAAO,iBAAiB;AAAA,MAEvB;AAAA,IAAA;AAAA,EAAA;AAGP;"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const useMoney = require("./useMoney.js");
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
3
  const jsxRuntime = require("react/jsx-runtime");
4
+ const useMoney = require("./useMoney.js");
5
5
  function Money({
6
6
  data,
7
7
  as,
@@ -12,10 +12,12 @@ function Money({
12
12
  ...passthroughProps
13
13
  }) {
14
14
  if (!isMoney(data)) {
15
- throw new Error(`<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'`);
15
+ throw new Error(
16
+ `<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'`
17
+ );
16
18
  }
17
19
  const moneyObject = useMoney.useMoney(data);
18
- const Wrapper = as != null ? as : "div";
20
+ const Wrapper = as ?? "div";
19
21
  let output = moneyObject.localizedString;
20
22
  if (withoutCurrency || withoutTrailingZeros) {
21
23
  if (withoutCurrency && !withoutTrailingZeros) {
@@ -26,12 +28,13 @@ function Money({
26
28
  output = moneyObject.withoutTrailingZerosAndCurrency;
27
29
  }
28
30
  }
29
- return /* @__PURE__ */ jsxRuntime.jsxs(Wrapper, {
30
- ...passthroughProps,
31
- children: [output, measurement && measurement.referenceUnit && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
32
- children: [measurementSeparator, measurement.referenceUnit]
33
- })]
34
- });
31
+ return /* @__PURE__ */ jsxRuntime.jsxs(Wrapper, { ...passthroughProps, children: [
32
+ output,
33
+ measurement && measurement.referenceUnit && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
34
+ measurementSeparator,
35
+ measurement.referenceUnit
36
+ ] })
37
+ ] });
35
38
  }
36
39
  function isMoney(maybeMoney) {
37
40
  return typeof maybeMoney.amount === "string" && !!maybeMoney.amount && typeof maybeMoney.currencyCode === "string" && !!maybeMoney.currencyCode;
@@ -1 +1 @@
1
- {"version":3,"file":"Money.js","sources":["../../src/Money.tsx"],"sourcesContent":["import {type ReactNode} from 'react';\nimport {useMoney} from './useMoney.js';\nimport type {MoneyV2, UnitPriceMeasurement} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\n\ninterface CustomProps<ComponentGeneric extends React.ElementType> {\n /** An HTML tag or React Component to be rendered as the base element wrapper. The default is `div`. */\n as?: ComponentGeneric;\n /** An object with fields that correspond to the Storefront API's [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2). */\n data: PartialDeep<MoneyV2, {recurseIntoArrays: true}>;\n /** Whether to remove the currency symbol from the output. */\n withoutCurrency?: boolean;\n /** Whether to remove trailing zeros (fractional money) from the output. */\n withoutTrailingZeros?: boolean;\n /** A [UnitPriceMeasurement object](https://shopify.dev/api/storefront/latest/objects/unitpricemeasurement). */\n measurement?: PartialDeep<UnitPriceMeasurement, {recurseIntoArrays: true}>;\n /** Customizes the separator between the money output and the measurement output. Used with the `measurement` prop. Defaults to `'/'`. */\n measurementSeparator?: ReactNode;\n}\n\n// This article helps understand the typing here https://www.benmvp.com/blog/polymorphic-react-components-typescript/ Ben is the best :)\nexport type MoneyProps<ComponentGeneric extends React.ElementType> =\n CustomProps<ComponentGeneric> &\n Omit<\n React.ComponentPropsWithoutRef<ComponentGeneric>,\n keyof CustomProps<ComponentGeneric>\n >;\n\n/**\n * The `Money` component renders a string of the Storefront API's\n * [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) according to the\n * `locale` in the `ShopifyProvider` component.\n */\nexport function Money<ComponentGeneric extends React.ElementType = 'div'>({\n data,\n as,\n withoutCurrency,\n withoutTrailingZeros,\n measurement,\n measurementSeparator = '/',\n ...passthroughProps\n}: MoneyProps<ComponentGeneric>) {\n if (!isMoney(data)) {\n throw new Error(\n `<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'`\n );\n }\n const moneyObject = useMoney(data);\n const Wrapper = as ?? 'div';\n\n let output = moneyObject.localizedString;\n\n if (withoutCurrency || withoutTrailingZeros) {\n if (withoutCurrency && !withoutTrailingZeros) {\n output = moneyObject.amount;\n } else if (!withoutCurrency && withoutTrailingZeros) {\n output = moneyObject.withoutTrailingZeros;\n } else {\n // both\n output = moneyObject.withoutTrailingZerosAndCurrency;\n }\n }\n\n return (\n <Wrapper {...passthroughProps}>\n {output}\n {measurement && measurement.referenceUnit && (\n <>\n {measurementSeparator}\n {measurement.referenceUnit}\n </>\n )}\n </Wrapper>\n );\n}\n\n// required in order to narrow the money object down and make TS happy\nfunction isMoney(\n maybeMoney: PartialDeep<MoneyV2, {recurseIntoArrays: true}>\n): maybeMoney is MoneyV2 {\n return (\n typeof maybeMoney.amount === 'string' &&\n !!maybeMoney.amount &&\n typeof maybeMoney.currencyCode === 'string' &&\n !!maybeMoney.currencyCode\n );\n}\n"],"names":["Money","data","as","withoutCurrency","withoutTrailingZeros","measurement","measurementSeparator","passthroughProps","isMoney","Error","moneyObject","useMoney","Wrapper","output","localizedString","amount","withoutTrailingZerosAndCurrency","referenceUnit","_Fragment","maybeMoney","currencyCode"],"mappings":";;;;AAiCO,SAASA,MAA0D;AAAA,EACxEC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,uBAAuB;AAAA,KACpBC;AACyB,GAAG;AAC3B,MAAA,CAACC,QAAQP,IAAI,GAAG;AACZ,UAAA,IAAIQ,MACP,yEAAwE;AAAA,EAE7E;AACMC,QAAAA,cAAcC,kBAASV,IAAI;AACjC,QAAMW,UAAUV,kBAAM;AAEtB,MAAIW,SAASH,YAAYI;AAEzB,MAAIX,mBAAmBC,sBAAsB;AACvCD,QAAAA,mBAAmB,CAACC,sBAAsB;AAC5CS,eAASH,YAAYK;AAAAA,IAAAA,WACZ,CAACZ,mBAAmBC,sBAAsB;AACnDS,eAASH,YAAYN;AAAAA,IAAAA,OAChB;AAELS,eAASH,YAAYM;AAAAA,IACvB;AAAA,EACF;AAEA,yCACG,SAAO;AAAA,IAAA,GAAKT;AAAAA,IAAgB,UAAA,CAC1BM,QACAR,eAAeA,YAAYY,iDAC1BC,qBAAA;AAAA,MAAA,UAAA,CACGZ,sBACAD,YAAYY,aAAa;AAAA,IAAA,CAE7B,CAAA;AAAA,EAAA,CACO;AAEd;AAGA,SAAST,QACPW,YACuB;AACvB,SACE,OAAOA,WAAWJ,WAAW,YAC7B,CAAC,CAACI,WAAWJ,UACb,OAAOI,WAAWC,iBAAiB,YACnC,CAAC,CAACD,WAAWC;AAEjB;;"}
1
+ {"version":3,"file":"Money.js","sources":["../../src/Money.tsx"],"sourcesContent":["import {type ReactNode} from 'react';\nimport {useMoney} from './useMoney.js';\nimport type {MoneyV2, UnitPriceMeasurement} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\n\ninterface CustomProps<ComponentGeneric extends React.ElementType> {\n /** An HTML tag or React Component to be rendered as the base element wrapper. The default is `div`. */\n as?: ComponentGeneric;\n /** An object with fields that correspond to the Storefront API's [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2). */\n data: PartialDeep<MoneyV2, {recurseIntoArrays: true}>;\n /** Whether to remove the currency symbol from the output. */\n withoutCurrency?: boolean;\n /** Whether to remove trailing zeros (fractional money) from the output. */\n withoutTrailingZeros?: boolean;\n /** A [UnitPriceMeasurement object](https://shopify.dev/api/storefront/latest/objects/unitpricemeasurement). */\n measurement?: PartialDeep<UnitPriceMeasurement, {recurseIntoArrays: true}>;\n /** Customizes the separator between the money output and the measurement output. Used with the `measurement` prop. Defaults to `'/'`. */\n measurementSeparator?: ReactNode;\n}\n\n// This article helps understand the typing here https://www.benmvp.com/blog/polymorphic-react-components-typescript/ Ben is the best :)\nexport type MoneyProps<ComponentGeneric extends React.ElementType> =\n CustomProps<ComponentGeneric> &\n Omit<\n React.ComponentPropsWithoutRef<ComponentGeneric>,\n keyof CustomProps<ComponentGeneric>\n >;\n\n/**\n * The `Money` component renders a string of the Storefront API's\n * [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) according to the\n * `locale` in the `ShopifyProvider` component.\n */\nexport function Money<ComponentGeneric extends React.ElementType = 'div'>({\n data,\n as,\n withoutCurrency,\n withoutTrailingZeros,\n measurement,\n measurementSeparator = '/',\n ...passthroughProps\n}: MoneyProps<ComponentGeneric>) {\n if (!isMoney(data)) {\n throw new Error(\n `<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'`\n );\n }\n const moneyObject = useMoney(data);\n const Wrapper = as ?? 'div';\n\n let output = moneyObject.localizedString;\n\n if (withoutCurrency || withoutTrailingZeros) {\n if (withoutCurrency && !withoutTrailingZeros) {\n output = moneyObject.amount;\n } else if (!withoutCurrency && withoutTrailingZeros) {\n output = moneyObject.withoutTrailingZeros;\n } else {\n // both\n output = moneyObject.withoutTrailingZerosAndCurrency;\n }\n }\n\n return (\n <Wrapper {...passthroughProps}>\n {output}\n {measurement && measurement.referenceUnit && (\n <>\n {measurementSeparator}\n {measurement.referenceUnit}\n </>\n )}\n </Wrapper>\n );\n}\n\n// required in order to narrow the money object down and make TS happy\nfunction isMoney(\n maybeMoney: PartialDeep<MoneyV2, {recurseIntoArrays: true}>\n): maybeMoney is MoneyV2 {\n return (\n typeof maybeMoney.amount === 'string' &&\n !!maybeMoney.amount &&\n typeof maybeMoney.currencyCode === 'string' &&\n !!maybeMoney.currencyCode\n );\n}\n"],"names":["useMoney","jsxs","Fragment"],"mappings":";;;;AAiCO,SAAS,MAA0D;AAAA,EACxE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,uBAAuB;AAAA,EACvB,GAAG;AACL,GAAiC;AAC3B,MAAA,CAAC,QAAQ,IAAI,GAAG;AAClB,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAAA,EAEJ;AACM,QAAA,cAAcA,kBAAS,IAAI;AACjC,QAAM,UAAU,MAAM;AAEtB,MAAI,SAAS,YAAY;AAEzB,MAAI,mBAAmB,sBAAsB;AACvC,QAAA,mBAAmB,CAAC,sBAAsB;AAC5C,eAAS,YAAY;AAAA,IAAA,WACZ,CAAC,mBAAmB,sBAAsB;AACnD,eAAS,YAAY;AAAA,IAAA,OAChB;AAEL,eAAS,YAAY;AAAA,IACvB;AAAA,EACF;AAGE,SAAAC,2BAAA,KAAC,SAAS,EAAA,GAAG,kBACV,UAAA;AAAA,IAAA;AAAA,IACA,eAAe,YAAY,iBAEvBA,2BAAA,KAAAC,WAAA,UAAA,EAAA,UAAA;AAAA,MAAA;AAAA,MACA,YAAY;AAAA,IAAA,GACf;AAAA,EAEJ,EAAA,CAAA;AAEJ;AAGA,SAAS,QACP,YACuB;AACvB,SACE,OAAO,WAAW,WAAW,YAC7B,CAAC,CAAC,WAAW,UACb,OAAO,WAAW,iBAAiB,YACnC,CAAC,CAAC,WAAW;AAEjB;;"}
@@ -1,5 +1,5 @@
1
- import { useMoney } from "./useMoney.mjs";
2
1
  import { jsxs, Fragment } from "react/jsx-runtime";
2
+ import { useMoney } from "./useMoney.mjs";
3
3
  function Money({
4
4
  data,
5
5
  as,
@@ -10,10 +10,12 @@ function Money({
10
10
  ...passthroughProps
11
11
  }) {
12
12
  if (!isMoney(data)) {
13
- throw new Error(`<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'`);
13
+ throw new Error(
14
+ `<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'`
15
+ );
14
16
  }
15
17
  const moneyObject = useMoney(data);
16
- const Wrapper = as != null ? as : "div";
18
+ const Wrapper = as ?? "div";
17
19
  let output = moneyObject.localizedString;
18
20
  if (withoutCurrency || withoutTrailingZeros) {
19
21
  if (withoutCurrency && !withoutTrailingZeros) {
@@ -24,12 +26,13 @@ function Money({
24
26
  output = moneyObject.withoutTrailingZerosAndCurrency;
25
27
  }
26
28
  }
27
- return /* @__PURE__ */ jsxs(Wrapper, {
28
- ...passthroughProps,
29
- children: [output, measurement && measurement.referenceUnit && /* @__PURE__ */ jsxs(Fragment, {
30
- children: [measurementSeparator, measurement.referenceUnit]
31
- })]
32
- });
29
+ return /* @__PURE__ */ jsxs(Wrapper, { ...passthroughProps, children: [
30
+ output,
31
+ measurement && measurement.referenceUnit && /* @__PURE__ */ jsxs(Fragment, { children: [
32
+ measurementSeparator,
33
+ measurement.referenceUnit
34
+ ] })
35
+ ] });
33
36
  }
34
37
  function isMoney(maybeMoney) {
35
38
  return typeof maybeMoney.amount === "string" && !!maybeMoney.amount && typeof maybeMoney.currencyCode === "string" && !!maybeMoney.currencyCode;
@@ -1 +1 @@
1
- {"version":3,"file":"Money.mjs","sources":["../../src/Money.tsx"],"sourcesContent":["import {type ReactNode} from 'react';\nimport {useMoney} from './useMoney.js';\nimport type {MoneyV2, UnitPriceMeasurement} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\n\ninterface CustomProps<ComponentGeneric extends React.ElementType> {\n /** An HTML tag or React Component to be rendered as the base element wrapper. The default is `div`. */\n as?: ComponentGeneric;\n /** An object with fields that correspond to the Storefront API's [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2). */\n data: PartialDeep<MoneyV2, {recurseIntoArrays: true}>;\n /** Whether to remove the currency symbol from the output. */\n withoutCurrency?: boolean;\n /** Whether to remove trailing zeros (fractional money) from the output. */\n withoutTrailingZeros?: boolean;\n /** A [UnitPriceMeasurement object](https://shopify.dev/api/storefront/latest/objects/unitpricemeasurement). */\n measurement?: PartialDeep<UnitPriceMeasurement, {recurseIntoArrays: true}>;\n /** Customizes the separator between the money output and the measurement output. Used with the `measurement` prop. Defaults to `'/'`. */\n measurementSeparator?: ReactNode;\n}\n\n// This article helps understand the typing here https://www.benmvp.com/blog/polymorphic-react-components-typescript/ Ben is the best :)\nexport type MoneyProps<ComponentGeneric extends React.ElementType> =\n CustomProps<ComponentGeneric> &\n Omit<\n React.ComponentPropsWithoutRef<ComponentGeneric>,\n keyof CustomProps<ComponentGeneric>\n >;\n\n/**\n * The `Money` component renders a string of the Storefront API's\n * [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) according to the\n * `locale` in the `ShopifyProvider` component.\n */\nexport function Money<ComponentGeneric extends React.ElementType = 'div'>({\n data,\n as,\n withoutCurrency,\n withoutTrailingZeros,\n measurement,\n measurementSeparator = '/',\n ...passthroughProps\n}: MoneyProps<ComponentGeneric>) {\n if (!isMoney(data)) {\n throw new Error(\n `<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'`\n );\n }\n const moneyObject = useMoney(data);\n const Wrapper = as ?? 'div';\n\n let output = moneyObject.localizedString;\n\n if (withoutCurrency || withoutTrailingZeros) {\n if (withoutCurrency && !withoutTrailingZeros) {\n output = moneyObject.amount;\n } else if (!withoutCurrency && withoutTrailingZeros) {\n output = moneyObject.withoutTrailingZeros;\n } else {\n // both\n output = moneyObject.withoutTrailingZerosAndCurrency;\n }\n }\n\n return (\n <Wrapper {...passthroughProps}>\n {output}\n {measurement && measurement.referenceUnit && (\n <>\n {measurementSeparator}\n {measurement.referenceUnit}\n </>\n )}\n </Wrapper>\n );\n}\n\n// required in order to narrow the money object down and make TS happy\nfunction isMoney(\n maybeMoney: PartialDeep<MoneyV2, {recurseIntoArrays: true}>\n): maybeMoney is MoneyV2 {\n return (\n typeof maybeMoney.amount === 'string' &&\n !!maybeMoney.amount &&\n typeof maybeMoney.currencyCode === 'string' &&\n !!maybeMoney.currencyCode\n );\n}\n"],"names":["Money","data","as","withoutCurrency","withoutTrailingZeros","measurement","measurementSeparator","passthroughProps","isMoney","Error","moneyObject","useMoney","Wrapper","output","localizedString","amount","withoutTrailingZerosAndCurrency","referenceUnit","_Fragment","maybeMoney","currencyCode"],"mappings":";;AAiCO,SAASA,MAA0D;AAAA,EACxEC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,uBAAuB;AAAA,KACpBC;AACyB,GAAG;AAC3B,MAAA,CAACC,QAAQP,IAAI,GAAG;AACZ,UAAA,IAAIQ,MACP,yEAAwE;AAAA,EAE7E;AACMC,QAAAA,cAAcC,SAASV,IAAI;AACjC,QAAMW,UAAUV,kBAAM;AAEtB,MAAIW,SAASH,YAAYI;AAEzB,MAAIX,mBAAmBC,sBAAsB;AACvCD,QAAAA,mBAAmB,CAACC,sBAAsB;AAC5CS,eAASH,YAAYK;AAAAA,IAAAA,WACZ,CAACZ,mBAAmBC,sBAAsB;AACnDS,eAASH,YAAYN;AAAAA,IAAAA,OAChB;AAELS,eAASH,YAAYM;AAAAA,IACvB;AAAA,EACF;AAEA,8BACG,SAAO;AAAA,IAAA,GAAKT;AAAAA,IAAgB,UAAA,CAC1BM,QACAR,eAAeA,YAAYY,sCAC1BC,UAAA;AAAA,MAAA,UAAA,CACGZ,sBACAD,YAAYY,aAAa;AAAA,IAAA,CAE7B,CAAA;AAAA,EAAA,CACO;AAEd;AAGA,SAAST,QACPW,YACuB;AACvB,SACE,OAAOA,WAAWJ,WAAW,YAC7B,CAAC,CAACI,WAAWJ,UACb,OAAOI,WAAWC,iBAAiB,YACnC,CAAC,CAACD,WAAWC;AAEjB;"}
1
+ {"version":3,"file":"Money.mjs","sources":["../../src/Money.tsx"],"sourcesContent":["import {type ReactNode} from 'react';\nimport {useMoney} from './useMoney.js';\nimport type {MoneyV2, UnitPriceMeasurement} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\n\ninterface CustomProps<ComponentGeneric extends React.ElementType> {\n /** An HTML tag or React Component to be rendered as the base element wrapper. The default is `div`. */\n as?: ComponentGeneric;\n /** An object with fields that correspond to the Storefront API's [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2). */\n data: PartialDeep<MoneyV2, {recurseIntoArrays: true}>;\n /** Whether to remove the currency symbol from the output. */\n withoutCurrency?: boolean;\n /** Whether to remove trailing zeros (fractional money) from the output. */\n withoutTrailingZeros?: boolean;\n /** A [UnitPriceMeasurement object](https://shopify.dev/api/storefront/latest/objects/unitpricemeasurement). */\n measurement?: PartialDeep<UnitPriceMeasurement, {recurseIntoArrays: true}>;\n /** Customizes the separator between the money output and the measurement output. Used with the `measurement` prop. Defaults to `'/'`. */\n measurementSeparator?: ReactNode;\n}\n\n// This article helps understand the typing here https://www.benmvp.com/blog/polymorphic-react-components-typescript/ Ben is the best :)\nexport type MoneyProps<ComponentGeneric extends React.ElementType> =\n CustomProps<ComponentGeneric> &\n Omit<\n React.ComponentPropsWithoutRef<ComponentGeneric>,\n keyof CustomProps<ComponentGeneric>\n >;\n\n/**\n * The `Money` component renders a string of the Storefront API's\n * [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) according to the\n * `locale` in the `ShopifyProvider` component.\n */\nexport function Money<ComponentGeneric extends React.ElementType = 'div'>({\n data,\n as,\n withoutCurrency,\n withoutTrailingZeros,\n measurement,\n measurementSeparator = '/',\n ...passthroughProps\n}: MoneyProps<ComponentGeneric>) {\n if (!isMoney(data)) {\n throw new Error(\n `<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'`\n );\n }\n const moneyObject = useMoney(data);\n const Wrapper = as ?? 'div';\n\n let output = moneyObject.localizedString;\n\n if (withoutCurrency || withoutTrailingZeros) {\n if (withoutCurrency && !withoutTrailingZeros) {\n output = moneyObject.amount;\n } else if (!withoutCurrency && withoutTrailingZeros) {\n output = moneyObject.withoutTrailingZeros;\n } else {\n // both\n output = moneyObject.withoutTrailingZerosAndCurrency;\n }\n }\n\n return (\n <Wrapper {...passthroughProps}>\n {output}\n {measurement && measurement.referenceUnit && (\n <>\n {measurementSeparator}\n {measurement.referenceUnit}\n </>\n )}\n </Wrapper>\n );\n}\n\n// required in order to narrow the money object down and make TS happy\nfunction isMoney(\n maybeMoney: PartialDeep<MoneyV2, {recurseIntoArrays: true}>\n): maybeMoney is MoneyV2 {\n return (\n typeof maybeMoney.amount === 'string' &&\n !!maybeMoney.amount &&\n typeof maybeMoney.currencyCode === 'string' &&\n !!maybeMoney.currencyCode\n );\n}\n"],"names":[],"mappings":";;AAiCO,SAAS,MAA0D;AAAA,EACxE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,uBAAuB;AAAA,EACvB,GAAG;AACL,GAAiC;AAC3B,MAAA,CAAC,QAAQ,IAAI,GAAG;AAClB,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAAA,EAEJ;AACM,QAAA,cAAc,SAAS,IAAI;AACjC,QAAM,UAAU,MAAM;AAEtB,MAAI,SAAS,YAAY;AAEzB,MAAI,mBAAmB,sBAAsB;AACvC,QAAA,mBAAmB,CAAC,sBAAsB;AAC5C,eAAS,YAAY;AAAA,IAAA,WACZ,CAAC,mBAAmB,sBAAsB;AACnD,eAAS,YAAY;AAAA,IAAA,OAChB;AAEL,eAAS,YAAY;AAAA,IACvB;AAAA,EACF;AAGE,SAAA,qBAAC,SAAS,EAAA,GAAG,kBACV,UAAA;AAAA,IAAA;AAAA,IACA,eAAe,YAAY,iBAEvB,qBAAA,UAAA,EAAA,UAAA;AAAA,MAAA;AAAA,MACA,YAAY;AAAA,IAAA,GACf;AAAA,EAEJ,EAAA,CAAA;AAEJ;AAGA,SAAS,QACP,YACuB;AACvB,SACE,OAAO,WAAW,WAAW,YAC7B,CAAC,CAAC,WAAW,UACb,OAAO,WAAW,iBAAiB,YACnC,CAAC,CAAC,WAAW;AAEjB;"}
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
3
4
  const Money = require("./Money.js");
4
5
  const flattenConnection = require("./flatten-connection.js");
5
- const jsxRuntime = require("react/jsx-runtime");
6
6
  function ProductPrice(props) {
7
- var _a, _b, _c, _d, _e, _f, _g, _h;
7
+ var _a, _b, _c, _d, _e, _f;
8
8
  const {
9
9
  priceType = "regular",
10
10
  variantId,
@@ -17,17 +17,19 @@ function ProductPrice(props) {
17
17
  }
18
18
  let price;
19
19
  let measurement;
20
- const variant = variantId ? (_b = flattenConnection.flattenConnection((_a = product == null ? void 0 : product.variants) != null ? _a : {}).find((variant2) => (variant2 == null ? void 0 : variant2.id) === variantId)) != null ? _b : null : null;
20
+ const variant = variantId ? flattenConnection.flattenConnection((product == null ? void 0 : product.variants) ?? {}).find(
21
+ (variant2) => (variant2 == null ? void 0 : variant2.id) === variantId
22
+ ) ?? null : null;
21
23
  if (priceType === "compareAt") {
22
24
  if (variantId && variant) {
23
- if (((_c = variant.compareAtPriceV2) == null ? void 0 : _c.amount) === ((_d = variant.priceV2) == null ? void 0 : _d.amount)) {
25
+ if (((_a = variant.compareAtPriceV2) == null ? void 0 : _a.amount) === ((_b = variant.priceV2) == null ? void 0 : _b.amount)) {
24
26
  return null;
25
27
  }
26
28
  price = variant.compareAtPriceV2;
27
29
  } else if (valueType === "max") {
28
- price = (_e = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _e.maxVariantPrice;
30
+ price = (_c = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _c.maxVariantPrice;
29
31
  } else {
30
- price = (_f = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _f.minVariantPrice;
32
+ price = (_d = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _d.minVariantPrice;
31
33
  }
32
34
  } else {
33
35
  if (variantId && variant) {
@@ -37,25 +39,18 @@ function ProductPrice(props) {
37
39
  measurement = variant.unitPriceMeasurement;
38
40
  }
39
41
  } else if (valueType === "max") {
40
- price = (_g = product.priceRange) == null ? void 0 : _g.maxVariantPrice;
42
+ price = (_e = product.priceRange) == null ? void 0 : _e.maxVariantPrice;
41
43
  } else {
42
- price = (_h = product.priceRange) == null ? void 0 : _h.minVariantPrice;
44
+ price = (_f = product.priceRange) == null ? void 0 : _f.minVariantPrice;
43
45
  }
44
46
  }
45
47
  if (!price) {
46
48
  return null;
47
49
  }
48
50
  if (measurement) {
49
- return /* @__PURE__ */ jsxRuntime.jsx(Money.Money, {
50
- ...passthroughProps,
51
- data: price,
52
- measurement
53
- });
51
+ return /* @__PURE__ */ jsxRuntime.jsx(Money.Money, { ...passthroughProps, data: price, measurement });
54
52
  }
55
- return /* @__PURE__ */ jsxRuntime.jsx(Money.Money, {
56
- ...passthroughProps,
57
- data: price
58
- });
53
+ return /* @__PURE__ */ jsxRuntime.jsx(Money.Money, { ...passthroughProps, data: price });
59
54
  }
60
55
  exports.ProductPrice = ProductPrice;
61
56
  //# sourceMappingURL=ProductPrice.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProductPrice.js","sources":["../../src/ProductPrice.tsx"],"sourcesContent":["import type {\n MoneyV2,\n UnitPriceMeasurement,\n Product,\n} from './storefront-api-types.js';\nimport {Money, type MoneyProps} from './Money.js';\nimport type {PartialDeep} from 'type-fest';\nimport {flattenConnection} from './flatten-connection.js';\n\nexport interface ProductPriceProps {\n /** A [Product object](https://shopify.dev/api/storefront/reference/products/product). */\n data: PartialDeep<Product, {recurseIntoArrays: true}>;\n /** The type of price. Valid values: `regular` (default) or `compareAt`. */\n priceType?: 'regular' | 'compareAt';\n /** The type of value. Valid values: `min` (default), `max` or `unit`. */\n valueType?: 'max' | 'min' | 'unit';\n /** The ID of the variant. */\n variantId?: string;\n}\n\n/**\n * The `ProductPrice` component renders a `Money` component with the product\n * [`priceRange`](https://shopify.dev/api/storefront/reference/products/productpricerange)'s `maxVariantPrice` or `minVariantPrice`, for either the regular price or compare at price range.\n */\nexport function ProductPrice<ComponentGeneric extends React.ElementType>(\n props: ProductPriceProps &\n Omit<MoneyProps<ComponentGeneric>, 'data' | 'measurement'>\n) {\n const {\n priceType = 'regular',\n variantId,\n valueType = 'min',\n data: product,\n ...passthroughProps\n } = props;\n\n if (product == null) {\n throw new Error(`<ProductPrice/> requires a product as the 'data' prop`);\n }\n\n let price: Partial<MoneyV2> | undefined | null;\n let measurement: Partial<UnitPriceMeasurement> | undefined | null;\n\n const variant = variantId\n ? flattenConnection(product?.variants ?? {}).find(\n (variant) => variant?.id === variantId\n ) ?? null\n : null;\n\n if (priceType === 'compareAt') {\n if (variantId && variant) {\n if (variant.compareAtPriceV2?.amount === variant.priceV2?.amount) {\n return null;\n }\n price = variant.compareAtPriceV2;\n } else if (valueType === 'max') {\n price = product?.compareAtPriceRange?.maxVariantPrice;\n } else {\n price = product?.compareAtPriceRange?.minVariantPrice;\n }\n } else {\n if (variantId && variant) {\n price = variant.priceV2;\n if (valueType === 'unit') {\n price = variant.unitPrice;\n measurement = variant.unitPriceMeasurement;\n }\n } else if (valueType === 'max') {\n price = product.priceRange?.maxVariantPrice;\n } else {\n price = product.priceRange?.minVariantPrice;\n }\n }\n\n if (!price) {\n return null;\n }\n\n if (measurement) {\n return (\n <Money {...passthroughProps} data={price} measurement={measurement} />\n );\n }\n\n return <Money {...passthroughProps} data={price} />;\n}\n"],"names":["ProductPrice","props","priceType","variantId","valueType","data","product","passthroughProps","Error","price","measurement","variant","flattenConnection","variants","find","id","compareAtPriceV2","amount","priceV2","compareAtPriceRange","maxVariantPrice","minVariantPrice","unitPrice","unitPriceMeasurement","priceRange","Money"],"mappings":";;;;;AAwBO,SAASA,aACdC,OAEA;;AACM,QAAA;AAAA,IACJC,YAAY;AAAA,IACZC;AAAAA,IACAC,YAAY;AAAA,IACZC,MAAMC;AAAAA,OACH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esContent":["import type {\n MoneyV2,\n UnitPriceMeasurement,\n Product,\n} from './storefront-api-types.js';\nimport {Money, type MoneyProps} from './Money.js';\nimport type {PartialDeep} from 'type-fest';\nimport {flattenConnection} from './flatten-connection.js';\n\nexport interface ProductPriceProps {\n /** A Storefront API [Product object](https://shopify.dev/api/storefront/reference/products/product). */\n data: PartialDeep<Product, {recurseIntoArrays: true}>;\n /** The type of price. Valid values: `regular` (default) or `compareAt`. */\n priceType?: 'regular' | 'compareAt';\n /** The type of value. Valid values: `min` (default), `max` or `unit`. */\n valueType?: 'max' | 'min' | 'unit';\n /** The ID of the variant. */\n variantId?: string;\n}\n\n/**\n * The `ProductPrice` component renders a `Money` component with the product\n * [`priceRange`](https://shopify.dev/api/storefront/reference/products/productpricerange)'s `maxVariantPrice` or `minVariantPrice`, for either the regular price or compare at price range.\n */\nexport function ProductPrice<ComponentGeneric extends React.ElementType>(\n props: ProductPriceProps &\n Omit<MoneyProps<ComponentGeneric>, 'data' | 'measurement'>\n) {\n const {\n priceType = 'regular',\n variantId,\n valueType = 'min',\n data: product,\n ...passthroughProps\n } = props;\n\n if (product == null) {\n throw new Error(`<ProductPrice/> requires a product as the 'data' prop`);\n }\n\n let price: Partial<MoneyV2> | undefined | null;\n let measurement: Partial<UnitPriceMeasurement> | undefined | null;\n\n const variant = variantId\n ? flattenConnection(product?.variants ?? {}).find(\n (variant) => variant?.id === variantId\n ) ?? null\n : null;\n\n if (priceType === 'compareAt') {\n if (variantId && variant) {\n if (variant.compareAtPriceV2?.amount === variant.priceV2?.amount) {\n return null;\n }\n price = variant.compareAtPriceV2;\n } else if (valueType === 'max') {\n price = product?.compareAtPriceRange?.maxVariantPrice;\n } else {\n price = product?.compareAtPriceRange?.minVariantPrice;\n }\n } else {\n if (variantId && variant) {\n price = variant.priceV2;\n if (valueType === 'unit') {\n price = variant.unitPrice;\n measurement = variant.unitPriceMeasurement;\n }\n } else if (valueType === 'max') {\n price = product.priceRange?.maxVariantPrice;\n } else {\n price = product.priceRange?.minVariantPrice;\n }\n }\n\n if (!price) {\n return null;\n }\n\n if (measurement) {\n return (\n <Money {...passthroughProps} data={price} measurement={measurement} />\n );\n }\n\n return <Money {...passthroughProps} data={price} />;\n}\n"],"names":["flattenConnection","variant","Money","jsx"],"mappings":";;;;;AAwBO,SAAS,aACd,OAEA;;AACM,QAAA;AAAA,IACJ,YAAY;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,IACZ,MAAM;AAAA,IACN,GAAG;AAAA,EACD,IAAA;AAEJ,MAAI,WAAW,MAAM;AACb,UAAA,IAAI,MAAM,uDAAuD;AAAA,EACzE;AAEI,MAAA;AACA,MAAA;AAEJ,QAAM,UAAU,YACZA,kBAAA,mBAAkB,mCAAS,aAAY,CAAE,CAAA,EAAE;AAAA,IACzC,CAACC,cAAYA,qCAAS,QAAO;AAAA,EAAA,KAC1B,OACL;AAEJ,MAAI,cAAc,aAAa;AAC7B,QAAI,aAAa,SAAS;AACxB,YAAI,aAAQ,qBAAR,mBAA0B,cAAW,aAAQ,YAAR,mBAAiB,SAAQ;AACzD,eAAA;AAAA,MACT;AACA,cAAQ,QAAQ;AAAA,IAAA,WACP,cAAc,OAAO;AAC9B,eAAQ,wCAAS,wBAAT,mBAA8B;AAAA,IAAA,OACjC;AACL,eAAQ,wCAAS,wBAAT,mBAA8B;AAAA,IACxC;AAAA,EAAA,OACK;AACL,QAAI,aAAa,SAAS;AACxB,cAAQ,QAAQ;AAChB,UAAI,cAAc,QAAQ;AACxB,gBAAQ,QAAQ;AAChB,sBAAc,QAAQ;AAAA,MACxB;AAAA,IAAA,WACS,cAAc,OAAO;AAC9B,eAAQ,aAAQ,eAAR,mBAAoB;AAAA,IAAA,OACvB;AACL,eAAQ,aAAQ,eAAR,mBAAoB;AAAA,IAC9B;AAAA,EACF;AAEA,MAAI,CAAC,OAAO;AACH,WAAA;AAAA,EACT;AAEA,MAAI,aAAa;AACf,0CACGC,MAAO,OAAA,EAAA,GAAG,kBAAkB,MAAM,OAAO,YAA0B,CAAA;AAAA,EAExE;AAEA,SAAQC,2BAAAA,IAAAD,MAAAA,OAAA,EAAO,GAAG,kBAAkB,MAAM,MAAO,CAAA;AACnD;;"}
@@ -1,8 +1,8 @@
1
+ import { jsx } from "react/jsx-runtime";
1
2
  import { Money } from "./Money.mjs";
2
3
  import { flattenConnection } from "./flatten-connection.mjs";
3
- import { jsx } from "react/jsx-runtime";
4
4
  function ProductPrice(props) {
5
- var _a, _b, _c, _d, _e, _f, _g, _h;
5
+ var _a, _b, _c, _d, _e, _f;
6
6
  const {
7
7
  priceType = "regular",
8
8
  variantId,
@@ -15,17 +15,19 @@ function ProductPrice(props) {
15
15
  }
16
16
  let price;
17
17
  let measurement;
18
- const variant = variantId ? (_b = flattenConnection((_a = product == null ? void 0 : product.variants) != null ? _a : {}).find((variant2) => (variant2 == null ? void 0 : variant2.id) === variantId)) != null ? _b : null : null;
18
+ const variant = variantId ? flattenConnection((product == null ? void 0 : product.variants) ?? {}).find(
19
+ (variant2) => (variant2 == null ? void 0 : variant2.id) === variantId
20
+ ) ?? null : null;
19
21
  if (priceType === "compareAt") {
20
22
  if (variantId && variant) {
21
- if (((_c = variant.compareAtPriceV2) == null ? void 0 : _c.amount) === ((_d = variant.priceV2) == null ? void 0 : _d.amount)) {
23
+ if (((_a = variant.compareAtPriceV2) == null ? void 0 : _a.amount) === ((_b = variant.priceV2) == null ? void 0 : _b.amount)) {
22
24
  return null;
23
25
  }
24
26
  price = variant.compareAtPriceV2;
25
27
  } else if (valueType === "max") {
26
- price = (_e = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _e.maxVariantPrice;
28
+ price = (_c = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _c.maxVariantPrice;
27
29
  } else {
28
- price = (_f = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _f.minVariantPrice;
30
+ price = (_d = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _d.minVariantPrice;
29
31
  }
30
32
  } else {
31
33
  if (variantId && variant) {
@@ -35,25 +37,18 @@ function ProductPrice(props) {
35
37
  measurement = variant.unitPriceMeasurement;
36
38
  }
37
39
  } else if (valueType === "max") {
38
- price = (_g = product.priceRange) == null ? void 0 : _g.maxVariantPrice;
40
+ price = (_e = product.priceRange) == null ? void 0 : _e.maxVariantPrice;
39
41
  } else {
40
- price = (_h = product.priceRange) == null ? void 0 : _h.minVariantPrice;
42
+ price = (_f = product.priceRange) == null ? void 0 : _f.minVariantPrice;
41
43
  }
42
44
  }
43
45
  if (!price) {
44
46
  return null;
45
47
  }
46
48
  if (measurement) {
47
- return /* @__PURE__ */ jsx(Money, {
48
- ...passthroughProps,
49
- data: price,
50
- measurement
51
- });
49
+ return /* @__PURE__ */ jsx(Money, { ...passthroughProps, data: price, measurement });
52
50
  }
53
- return /* @__PURE__ */ jsx(Money, {
54
- ...passthroughProps,
55
- data: price
56
- });
51
+ return /* @__PURE__ */ jsx(Money, { ...passthroughProps, data: price });
57
52
  }
58
53
  export {
59
54
  ProductPrice
@@ -1 +1 @@
1
- {"version":3,"file":"ProductPrice.mjs","sources":["../../src/ProductPrice.tsx"],"sourcesContent":["import type {\n MoneyV2,\n UnitPriceMeasurement,\n Product,\n} from './storefront-api-types.js';\nimport {Money, type MoneyProps} from './Money.js';\nimport type {PartialDeep} from 'type-fest';\nimport {flattenConnection} from './flatten-connection.js';\n\nexport interface ProductPriceProps {\n /** A [Product object](https://shopify.dev/api/storefront/reference/products/product). */\n data: PartialDeep<Product, {recurseIntoArrays: true}>;\n /** The type of price. Valid values: `regular` (default) or `compareAt`. */\n priceType?: 'regular' | 'compareAt';\n /** The type of value. Valid values: `min` (default), `max` or `unit`. */\n valueType?: 'max' | 'min' | 'unit';\n /** The ID of the variant. */\n variantId?: string;\n}\n\n/**\n * The `ProductPrice` component renders a `Money` component with the product\n * [`priceRange`](https://shopify.dev/api/storefront/reference/products/productpricerange)'s `maxVariantPrice` or `minVariantPrice`, for either the regular price or compare at price range.\n */\nexport function ProductPrice<ComponentGeneric extends React.ElementType>(\n props: ProductPriceProps &\n Omit<MoneyProps<ComponentGeneric>, 'data' | 'measurement'>\n) {\n const {\n priceType = 'regular',\n variantId,\n valueType = 'min',\n data: product,\n ...passthroughProps\n } = props;\n\n if (product == null) {\n throw new Error(`<ProductPrice/> requires a product as the 'data' prop`);\n }\n\n let price: Partial<MoneyV2> | undefined | null;\n let measurement: Partial<UnitPriceMeasurement> | undefined | null;\n\n const variant = variantId\n ? flattenConnection(product?.variants ?? {}).find(\n (variant) => variant?.id === variantId\n ) ?? null\n : null;\n\n if (priceType === 'compareAt') {\n if (variantId && variant) {\n if (variant.compareAtPriceV2?.amount === variant.priceV2?.amount) {\n return null;\n }\n price = variant.compareAtPriceV2;\n } else if (valueType === 'max') {\n price = product?.compareAtPriceRange?.maxVariantPrice;\n } else {\n price = product?.compareAtPriceRange?.minVariantPrice;\n }\n } else {\n if (variantId && variant) {\n price = variant.priceV2;\n if (valueType === 'unit') {\n price = variant.unitPrice;\n measurement = variant.unitPriceMeasurement;\n }\n } else if (valueType === 'max') {\n price = product.priceRange?.maxVariantPrice;\n } else {\n price = product.priceRange?.minVariantPrice;\n }\n }\n\n if (!price) {\n return null;\n }\n\n if (measurement) {\n return (\n <Money {...passthroughProps} data={price} measurement={measurement} />\n );\n }\n\n return <Money {...passthroughProps} data={price} />;\n}\n"],"names":["ProductPrice","props","priceType","variantId","valueType","data","product","passthroughProps","Error","price","measurement","variant","flattenConnection","variants","find","id","compareAtPriceV2","amount","priceV2","compareAtPriceRange","maxVariantPrice","minVariantPrice","unitPrice","unitPriceMeasurement","priceRange"],"mappings":";;;AAwBO,SAASA,aACdC,OAEA;;AACM,QAAA;AAAA,IACJC,YAAY;AAAA,IACZC;AAAAA,IACAC,YAAY;AAAA,IACZC,MAAMC;AAAAA,OACHC;AAAAA,EACDN,IAAAA;AAEJ,MAAIK,WAAW,MAAM;AACb,UAAA,IAAIE,MAAO,uDAAsD;AAAA,EACzE;AAEIC,MAAAA;AACAC,MAAAA;AAEJ,QAAMC,UAAUR,aACZS,wBAAkBN,wCAASO,aAATP,YAAqB,CAAA,CAAE,EAAEQ,KACxCH,CAAAA,cAAYA,qCAASI,QAAOZ,SAAS,MADxCS,YAEK,OACL;AAEJ,MAAIV,cAAc,aAAa;AAC7B,QAAIC,aAAaQ,SAAS;AACxB,YAAIA,aAAQK,qBAARL,mBAA0BM,cAAWN,aAAQO,YAARP,mBAAiBM,SAAQ;AACzD,eAAA;AAAA,MACT;AACAR,cAAQE,QAAQK;AAAAA,IAAAA,WACPZ,cAAc,OAAO;AAC9BK,eAAQH,wCAASa,wBAATb,mBAA8Bc;AAAAA,IAAAA,OACjC;AACLX,eAAQH,wCAASa,wBAATb,mBAA8Be;AAAAA,IACxC;AAAA,EAAA,OACK;AACL,QAAIlB,aAAaQ,SAAS;AACxBF,cAAQE,QAAQO;AAChB,UAAId,cAAc,QAAQ;AACxBK,gBAAQE,QAAQW;AAChBZ,sBAAcC,QAAQY;AAAAA,MACxB;AAAA,IAAA,WACSnB,cAAc,OAAO;AAC9BK,eAAQH,aAAQkB,eAARlB,mBAAoBc;AAAAA,IAAAA,OACvB;AACLX,eAAQH,aAAQkB,eAARlB,mBAAoBe;AAAAA,IAC9B;AAAA,EACF;AAEA,MAAI,CAACZ,OAAO;AACH,WAAA;AAAA,EACT;AAEA,MAAIC,aAAa;AACf,+BACG,OAAK;AAAA,MAAA,GAAKH;AAAAA,MAAkB,MAAME;AAAAA,MAAO;AAAA,IAAA,CAA4B;AAAA,EAE1E;AAEA,6BAAQ,OAAK;AAAA,IAAA,GAAKF;AAAAA,IAAkB,MAAME;AAAAA,EAAAA,CAAS;AACrD;"}
1
+ {"version":3,"file":"ProductPrice.mjs","sources":["../../src/ProductPrice.tsx"],"sourcesContent":["import type {\n MoneyV2,\n UnitPriceMeasurement,\n Product,\n} from './storefront-api-types.js';\nimport {Money, type MoneyProps} from './Money.js';\nimport type {PartialDeep} from 'type-fest';\nimport {flattenConnection} from './flatten-connection.js';\n\nexport interface ProductPriceProps {\n /** A Storefront API [Product object](https://shopify.dev/api/storefront/reference/products/product). */\n data: PartialDeep<Product, {recurseIntoArrays: true}>;\n /** The type of price. Valid values: `regular` (default) or `compareAt`. */\n priceType?: 'regular' | 'compareAt';\n /** The type of value. Valid values: `min` (default), `max` or `unit`. */\n valueType?: 'max' | 'min' | 'unit';\n /** The ID of the variant. */\n variantId?: string;\n}\n\n/**\n * The `ProductPrice` component renders a `Money` component with the product\n * [`priceRange`](https://shopify.dev/api/storefront/reference/products/productpricerange)'s `maxVariantPrice` or `minVariantPrice`, for either the regular price or compare at price range.\n */\nexport function ProductPrice<ComponentGeneric extends React.ElementType>(\n props: ProductPriceProps &\n Omit<MoneyProps<ComponentGeneric>, 'data' | 'measurement'>\n) {\n const {\n priceType = 'regular',\n variantId,\n valueType = 'min',\n data: product,\n ...passthroughProps\n } = props;\n\n if (product == null) {\n throw new Error(`<ProductPrice/> requires a product as the 'data' prop`);\n }\n\n let price: Partial<MoneyV2> | undefined | null;\n let measurement: Partial<UnitPriceMeasurement> | undefined | null;\n\n const variant = variantId\n ? flattenConnection(product?.variants ?? {}).find(\n (variant) => variant?.id === variantId\n ) ?? null\n : null;\n\n if (priceType === 'compareAt') {\n if (variantId && variant) {\n if (variant.compareAtPriceV2?.amount === variant.priceV2?.amount) {\n return null;\n }\n price = variant.compareAtPriceV2;\n } else if (valueType === 'max') {\n price = product?.compareAtPriceRange?.maxVariantPrice;\n } else {\n price = product?.compareAtPriceRange?.minVariantPrice;\n }\n } else {\n if (variantId && variant) {\n price = variant.priceV2;\n if (valueType === 'unit') {\n price = variant.unitPrice;\n measurement = variant.unitPriceMeasurement;\n }\n } else if (valueType === 'max') {\n price = product.priceRange?.maxVariantPrice;\n } else {\n price = product.priceRange?.minVariantPrice;\n }\n }\n\n if (!price) {\n return null;\n }\n\n if (measurement) {\n return (\n <Money {...passthroughProps} data={price} measurement={measurement} />\n );\n }\n\n return <Money {...passthroughProps} data={price} />;\n}\n"],"names":["variant"],"mappings":";;;AAwBO,SAAS,aACd,OAEA;;AACM,QAAA;AAAA,IACJ,YAAY;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,IACZ,MAAM;AAAA,IACN,GAAG;AAAA,EACD,IAAA;AAEJ,MAAI,WAAW,MAAM;AACb,UAAA,IAAI,MAAM,uDAAuD;AAAA,EACzE;AAEI,MAAA;AACA,MAAA;AAEJ,QAAM,UAAU,YACZ,mBAAkB,mCAAS,aAAY,CAAE,CAAA,EAAE;AAAA,IACzC,CAACA,cAAYA,qCAAS,QAAO;AAAA,EAAA,KAC1B,OACL;AAEJ,MAAI,cAAc,aAAa;AAC7B,QAAI,aAAa,SAAS;AACxB,YAAI,aAAQ,qBAAR,mBAA0B,cAAW,aAAQ,YAAR,mBAAiB,SAAQ;AACzD,eAAA;AAAA,MACT;AACA,cAAQ,QAAQ;AAAA,IAAA,WACP,cAAc,OAAO;AAC9B,eAAQ,wCAAS,wBAAT,mBAA8B;AAAA,IAAA,OACjC;AACL,eAAQ,wCAAS,wBAAT,mBAA8B;AAAA,IACxC;AAAA,EAAA,OACK;AACL,QAAI,aAAa,SAAS;AACxB,cAAQ,QAAQ;AAChB,UAAI,cAAc,QAAQ;AACxB,gBAAQ,QAAQ;AAChB,sBAAc,QAAQ;AAAA,MACxB;AAAA,IAAA,WACS,cAAc,OAAO;AAC9B,eAAQ,aAAQ,eAAR,mBAAoB;AAAA,IAAA,OACvB;AACL,eAAQ,aAAQ,eAAR,mBAAoB;AAAA,IAC9B;AAAA,EACF;AAEA,MAAI,CAAC,OAAO;AACH,WAAA;AAAA,EACT;AAEA,MAAI,aAAa;AACf,+BACG,OAAO,EAAA,GAAG,kBAAkB,MAAM,OAAO,YAA0B,CAAA;AAAA,EAExE;AAEA,SAAQ,oBAAA,OAAA,EAAO,GAAG,kBAAkB,MAAM,MAAO,CAAA;AACnD;"}