@shopify/hydrogen 0.10.0-experimental.4 → 0.11.0-experimental.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. package/README.md +1 -1
  2. package/dist/esnext/client.d.ts +1 -3
  3. package/dist/esnext/client.js +1 -3
  4. package/dist/esnext/components/AddToCartButton/AddToCartButton.client.js +4 -6
  5. package/dist/esnext/components/CartCheckoutButton/CartCheckoutButton.client.js +5 -6
  6. package/dist/esnext/components/CartLineAttributes/CartLineAttributes.client.d.ts +4 -0
  7. package/dist/esnext/components/CartLinePrice/CartLinePrice.client.d.ts +2 -1
  8. package/dist/esnext/components/CartLinePrice/CartLinePrice.client.js +1 -1
  9. package/dist/esnext/components/CartLineProductTitle/CartLineProductTitle.client.d.ts +4 -1
  10. package/dist/esnext/components/CartLineQuantity/CartLineQuantity.client.d.ts +4 -1
  11. package/dist/esnext/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.js +5 -7
  12. package/dist/esnext/components/CartLineSelectedOptions/CartLineSelectedOptions.client.d.ts +4 -0
  13. package/dist/esnext/components/CartLines/CartLines.d.ts +3 -4
  14. package/dist/esnext/components/CartLines/CartLines.js +3 -5
  15. package/dist/esnext/components/CartProvider/CartProvider.client.d.ts +8 -8
  16. package/dist/esnext/components/CartProvider/CartProvider.client.js +5 -0
  17. package/dist/esnext/components/CartProvider/hooks.js +3 -3
  18. package/dist/esnext/components/CartProvider/index.d.ts +0 -10
  19. package/dist/esnext/components/CartProvider/index.js +0 -10
  20. package/dist/esnext/components/CartProvider/types.d.ts +36 -6
  21. package/dist/esnext/components/CartShopPayButton/CartShopPayButton.client.js +6 -3
  22. package/dist/esnext/components/Link/Link.client.d.ts +18 -1
  23. package/dist/esnext/components/Link/Link.client.js +42 -4
  24. package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.d.ts +1 -1
  25. package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +1 -1
  26. package/dist/esnext/components/MediaFile/MediaFile.d.ts +5 -5
  27. package/dist/esnext/components/MediaFile/MediaFile.js +3 -3
  28. package/dist/esnext/components/MediaFile/MediaFileFragment.d.ts +1 -1
  29. package/dist/esnext/components/Metafield/Metafield.client.d.ts +4 -8
  30. package/dist/esnext/components/Metafield/Metafield.client.js +4 -11
  31. package/dist/esnext/components/Metafield/components/StarRating/StarRating.d.ts +2 -0
  32. package/dist/esnext/components/{Model3D → ModelViewer}/Model3DFragment.d.ts +0 -0
  33. package/dist/esnext/components/{Model3D → ModelViewer}/Model3DFragment.js +0 -0
  34. package/dist/esnext/components/{Model3D/Model3D.client.d.ts → ModelViewer/ModelViewer.client.d.ts} +5 -7
  35. package/dist/esnext/components/{Model3D/Model3D.client.js → ModelViewer/ModelViewer.client.js} +8 -21
  36. package/dist/esnext/components/ModelViewer/index.d.ts +1 -0
  37. package/dist/esnext/components/ModelViewer/index.js +1 -0
  38. package/dist/esnext/components/Money/Money.client.d.ts +3 -6
  39. package/dist/esnext/components/Money/Money.client.js +3 -6
  40. package/dist/esnext/components/ProductMetafield/ProductMetafield.client.d.ts +3 -4
  41. package/dist/esnext/components/ProductMetafield/ProductMetafield.client.js +5 -1
  42. package/dist/esnext/components/ProductPrice/ProductPrice.client.d.ts +2 -1
  43. package/dist/esnext/components/ProductPrice/ProductPrice.client.js +1 -1
  44. package/dist/esnext/components/ProductTitle/ProductTitle.client.d.ts +6 -5
  45. package/dist/esnext/components/ProductTitle/ProductTitle.client.js +1 -5
  46. package/dist/esnext/components/RawHtml/RawHtml.d.ts +2 -0
  47. package/dist/esnext/components/Router/index.d.ts +1 -0
  48. package/dist/esnext/components/Router/index.js +1 -0
  49. package/dist/esnext/components/SelectedVariantMetafield/SelectedVariantMetafield.client.d.ts +3 -4
  50. package/dist/esnext/components/SelectedVariantMetafield/SelectedVariantMetafield.client.js +5 -1
  51. package/dist/esnext/components/SelectedVariantPrice/SelectedVariantPrice.client.d.ts +2 -1
  52. package/dist/esnext/components/SelectedVariantPrice/SelectedVariantPrice.client.js +1 -1
  53. package/dist/esnext/components/Seo/CollectionSeo.client.d.ts +2 -0
  54. package/dist/esnext/components/Seo/CollectionSeo.client.js +15 -0
  55. package/dist/esnext/components/Seo/DefaultPageSeo.client.d.ts +2 -0
  56. package/dist/esnext/components/Seo/DefaultPageSeo.client.js +19 -0
  57. package/dist/esnext/components/Seo/DescriptionSeo.client.d.ts +4 -0
  58. package/dist/esnext/components/Seo/DescriptionSeo.client.js +10 -0
  59. package/dist/esnext/components/Seo/HomePageSeo.client.d.ts +2 -0
  60. package/dist/esnext/components/Seo/HomePageSeo.client.js +25 -0
  61. package/dist/esnext/components/Seo/ImageSeo.client.d.ts +2 -0
  62. package/dist/esnext/components/Seo/ImageSeo.client.js +10 -0
  63. package/dist/esnext/components/Seo/PageSeo.client.d.ts +2 -0
  64. package/dist/esnext/components/Seo/PageSeo.client.js +13 -0
  65. package/dist/esnext/components/Seo/ProductSeo.client.d.ts +2 -0
  66. package/dist/esnext/components/Seo/ProductSeo.client.js +56 -0
  67. package/dist/esnext/components/Seo/Seo.client.d.ts +22 -0
  68. package/dist/esnext/components/Seo/Seo.client.js +34 -0
  69. package/dist/esnext/components/Seo/TitleSeo.client.d.ts +4 -0
  70. package/dist/esnext/components/Seo/TitleSeo.client.js +10 -0
  71. package/dist/esnext/components/Seo/TwitterSeo.client.d.ts +2 -0
  72. package/dist/esnext/components/Seo/TwitterSeo.client.js +9 -0
  73. package/dist/esnext/components/Seo/index.d.ts +1 -0
  74. package/dist/esnext/components/Seo/index.js +1 -0
  75. package/dist/esnext/components/Seo/types.d.ts +67 -0
  76. package/dist/esnext/components/Seo/types.js +1 -0
  77. package/dist/esnext/components/ShopPayButton/ShopPayButton.client.d.ts +22 -5
  78. package/dist/esnext/components/ShopPayButton/ShopPayButton.client.js +47 -26
  79. package/dist/esnext/components/UnitPrice/UnitPrice.client.d.ts +3 -8
  80. package/dist/esnext/components/UnitPrice/UnitPrice.client.js +3 -12
  81. package/dist/esnext/components/index.d.ts +8 -5
  82. package/dist/esnext/components/index.js +7 -50
  83. package/dist/esnext/components/types.d.ts +3 -5
  84. package/dist/esnext/constants.d.ts +1 -0
  85. package/dist/esnext/constants.js +1 -0
  86. package/dist/esnext/entry-client.js +8 -10
  87. package/dist/esnext/entry-server.js +97 -86
  88. package/dist/esnext/foundation/Boomerang/Boomerang.client.d.ts +7 -0
  89. package/dist/esnext/foundation/Boomerang/Boomerang.client.js +50 -0
  90. package/dist/esnext/foundation/Boomerang/BoomerangPageTemplate.client.d.ts +3 -0
  91. package/dist/esnext/foundation/Boomerang/BoomerangPageTemplate.client.js +14 -0
  92. package/dist/esnext/foundation/Helmet/Helmet.client.d.ts +10 -0
  93. package/dist/esnext/foundation/Helmet/Helmet.client.js +10 -0
  94. package/dist/esnext/foundation/Helmet/index.d.ts +1 -0
  95. package/dist/esnext/foundation/Helmet/index.js +1 -0
  96. package/dist/esnext/foundation/Router/DefaultRoutes.d.ts +1 -1
  97. package/dist/esnext/foundation/Router/DefaultRoutes.js +14 -2
  98. package/dist/esnext/foundation/Router/Router.client.d.ts +12 -0
  99. package/dist/esnext/foundation/Router/Router.client.js +44 -0
  100. package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +7 -7
  101. package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.client.d.ts +7 -0
  102. package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.client.js +5 -0
  103. package/dist/esnext/foundation/ShopifyProvider/{ShopifyProvider.d.ts → ShopifyProvider.server.d.ts} +3 -2
  104. package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.js +26 -0
  105. package/dist/esnext/foundation/ShopifyProvider/index.d.ts +2 -1
  106. package/dist/esnext/foundation/ShopifyProvider/index.js +2 -1
  107. package/dist/esnext/foundation/ShopifyProvider/types.d.ts +4 -3
  108. package/dist/esnext/foundation/constants.d.ts +0 -1
  109. package/dist/esnext/foundation/constants.js +0 -1
  110. package/dist/esnext/foundation/index.d.ts +3 -2
  111. package/dist/esnext/foundation/index.js +3 -2
  112. package/dist/esnext/foundation/ssr-interop.d.ts +29 -0
  113. package/dist/esnext/foundation/ssr-interop.js +35 -0
  114. package/dist/esnext/foundation/useQuery/hooks.d.ts +1 -1
  115. package/dist/esnext/foundation/useQuery/hooks.js +1 -1
  116. package/dist/esnext/foundation/useServerState/use-server-state.d.ts +2 -1
  117. package/dist/esnext/foundation/useServerState/use-server-state.js +2 -2
  118. package/dist/esnext/foundation/useShop/index.d.ts +1 -1
  119. package/dist/esnext/foundation/useShop/index.js +1 -1
  120. package/dist/esnext/foundation/useShop/use-shop.d.ts +1 -4
  121. package/dist/esnext/foundation/useShop/use-shop.js +5 -16
  122. package/dist/esnext/foundation/useUrl/index.d.ts +1 -0
  123. package/dist/esnext/foundation/useUrl/index.js +1 -0
  124. package/dist/esnext/foundation/useUrl/useUrl.d.ts +4 -0
  125. package/dist/esnext/foundation/useUrl/useUrl.js +18 -0
  126. package/dist/esnext/framework/Hydration/Html.js +13 -1
  127. package/dist/esnext/framework/Hydration/ServerComponentRequest.server.d.ts +4 -0
  128. package/dist/esnext/framework/Hydration/ServerComponentRequest.server.js +5 -1
  129. package/dist/esnext/framework/Hydration/rsc.d.ts +1 -1
  130. package/dist/esnext/framework/Hydration/rsc.js +14 -4
  131. package/dist/esnext/framework/graphiql.d.ts +1 -1
  132. package/dist/esnext/framework/graphiql.js +1 -2
  133. package/dist/esnext/framework/middleware.js +3 -3
  134. package/dist/esnext/framework/plugin.js +2 -0
  135. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +1 -1
  136. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +1 -1
  137. package/dist/esnext/framework/plugins/vite-plugin-ssr-interop.d.ts +3 -0
  138. package/dist/esnext/framework/plugins/vite-plugin-ssr-interop.js +13 -0
  139. package/dist/esnext/handle-event.js +2 -1
  140. package/dist/esnext/hooks/index.d.ts +1 -0
  141. package/dist/esnext/hooks/index.js +1 -0
  142. package/dist/esnext/hooks/useLoadScript/index.d.ts +1 -0
  143. package/dist/esnext/hooks/useLoadScript/index.js +1 -0
  144. package/dist/esnext/hooks/useLoadScript/useLoadScript.d.ts +8 -0
  145. package/dist/esnext/hooks/useLoadScript/useLoadScript.js +22 -0
  146. package/dist/esnext/hooks/useNavigate/index.d.ts +1 -0
  147. package/dist/esnext/hooks/useNavigate/index.js +1 -0
  148. package/dist/esnext/hooks/useNavigate/useNavigate.d.ts +10 -0
  149. package/dist/esnext/hooks/useNavigate/useNavigate.js +11 -0
  150. package/dist/esnext/hooks/useShopQuery/hooks.js +3 -3
  151. package/dist/esnext/index.d.ts +0 -1
  152. package/dist/esnext/index.js +0 -1
  153. package/dist/esnext/streaming.server.d.ts +11 -0
  154. package/dist/esnext/streaming.server.js +14 -0
  155. package/dist/esnext/types.d.ts +1 -1
  156. package/dist/esnext/utilities/apiRoutes.d.ts +1 -1
  157. package/dist/esnext/utilities/apiRoutes.js +19 -5
  158. package/dist/esnext/utilities/error.js +3 -12
  159. package/dist/esnext/utilities/fetch.js +8 -0
  160. package/dist/esnext/utilities/index.d.ts +1 -1
  161. package/dist/esnext/utilities/index.js +1 -1
  162. package/dist/esnext/utilities/{script_loader.d.ts → load_script.d.ts} +0 -0
  163. package/dist/esnext/utilities/{script_loader.js → load_script.js} +0 -0
  164. package/dist/esnext/utilities/log/log.d.ts +4 -3
  165. package/dist/esnext/utilities/log/log.js +3 -2
  166. package/dist/esnext/utilities/video_parameters.js +4 -0
  167. package/dist/esnext/version.d.ts +1 -1
  168. package/dist/esnext/version.js +1 -1
  169. package/dist/node/constants.d.ts +1 -0
  170. package/dist/node/constants.js +4 -0
  171. package/dist/node/foundation/Helmet/Helmet.client.d.ts +10 -0
  172. package/dist/node/foundation/Helmet/Helmet.client.js +17 -0
  173. package/dist/node/foundation/Helmet/index.d.ts +1 -0
  174. package/dist/node/foundation/Helmet/index.js +5 -0
  175. package/dist/node/foundation/ShopifyProvider/types.d.ts +15 -0
  176. package/dist/node/foundation/ShopifyProvider/types.js +2 -0
  177. package/dist/node/foundation/ssr-interop.d.ts +29 -0
  178. package/dist/node/foundation/ssr-interop.js +39 -0
  179. package/dist/node/framework/Hydration/Html.js +13 -1
  180. package/dist/node/framework/Hydration/ServerComponentRequest.server.d.ts +4 -0
  181. package/dist/node/framework/Hydration/ServerComponentRequest.server.js +5 -1
  182. package/dist/node/framework/Hydration/rsc.d.ts +1 -1
  183. package/dist/node/framework/Hydration/rsc.js +14 -4
  184. package/dist/node/framework/graphiql.d.ts +1 -1
  185. package/dist/node/framework/graphiql.js +1 -2
  186. package/dist/node/framework/middleware.js +3 -3
  187. package/dist/node/framework/plugin.js +2 -0
  188. package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +1 -1
  189. package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +1 -1
  190. package/dist/node/framework/plugins/vite-plugin-ssr-interop.d.ts +3 -0
  191. package/dist/node/framework/plugins/vite-plugin-ssr-interop.js +15 -0
  192. package/dist/node/handle-event.js +2 -1
  193. package/dist/node/types.d.ts +1 -1
  194. package/dist/node/utilities/apiRoutes.d.ts +1 -1
  195. package/dist/node/utilities/apiRoutes.js +19 -5
  196. package/dist/node/utilities/log/log.d.ts +4 -3
  197. package/dist/node/utilities/log/log.js +3 -2
  198. package/dist/worker/constants.d.ts +1 -0
  199. package/dist/worker/constants.js +1 -0
  200. package/dist/worker/foundation/Helmet/Helmet.client.d.ts +10 -0
  201. package/dist/worker/foundation/Helmet/Helmet.client.js +10 -0
  202. package/dist/worker/foundation/Helmet/index.d.ts +1 -0
  203. package/dist/worker/foundation/Helmet/index.js +1 -0
  204. package/dist/worker/foundation/ShopifyProvider/types.d.ts +15 -0
  205. package/dist/worker/foundation/ShopifyProvider/types.js +1 -0
  206. package/dist/worker/foundation/ssr-interop.d.ts +29 -0
  207. package/dist/worker/foundation/ssr-interop.js +35 -0
  208. package/dist/worker/framework/Hydration/ServerComponentRequest.server.d.ts +4 -0
  209. package/dist/worker/framework/Hydration/ServerComponentRequest.server.js +5 -1
  210. package/dist/worker/handle-event.js +2 -1
  211. package/dist/worker/types.d.ts +1 -1
  212. package/dist/worker/utilities/apiRoutes.d.ts +1 -1
  213. package/dist/worker/utilities/apiRoutes.js +19 -5
  214. package/dist/worker/utilities/log/log.d.ts +4 -3
  215. package/dist/worker/utilities/log/log.js +3 -2
  216. package/package.json +6 -6
  217. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +84 -30
  218. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.development.server.js +2 -1
  219. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.production.min.server.js +2 -1
  220. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.development.server.js +2 -1
  221. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.production.min.server.js +2 -1
  222. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.development.js +5 -2
  223. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.production.min.js +5 -2
  224. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-client-proxy.js +41 -39
  225. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +83 -27
  226. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js +2 -1
  227. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.node.server.js +2 -1
  228. package/vendor/react-server-dom-vite/esm/react-server-dom-vite.js +5 -2
  229. package/dist/esnext/components/Model3D/index.d.ts +0 -1
  230. package/dist/esnext/components/Model3D/index.js +0 -1
  231. package/dist/esnext/foundation/Router/ServerStateRouter.client.d.ts +0 -6
  232. package/dist/esnext/foundation/Router/ServerStateRouter.client.js +0 -29
  233. package/dist/esnext/foundation/ShopifyProvider/ShopifyContext.d.ts +0 -4
  234. package/dist/esnext/foundation/ShopifyProvider/ShopifyContext.js +0 -13
  235. package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.js +0 -12
  236. package/dist/esnext/hooks/useCartAttributesUpdateCallback/index.d.ts +0 -1
  237. package/dist/esnext/hooks/useCartAttributesUpdateCallback/index.js +0 -1
  238. package/dist/esnext/hooks/useCartAttributesUpdateCallback/useCartAttributesUpdateCallback.d.ts +0 -4
  239. package/dist/esnext/hooks/useCartAttributesUpdateCallback/useCartAttributesUpdateCallback.js +0 -8
  240. package/dist/esnext/hooks/useCartBuyerIdentityUpdateCallback/index.d.ts +0 -1
  241. package/dist/esnext/hooks/useCartBuyerIdentityUpdateCallback/index.js +0 -1
  242. package/dist/esnext/hooks/useCartBuyerIdentityUpdateCallback/useCartBuyerIdentityUpdateCallback.d.ts +0 -4
  243. package/dist/esnext/hooks/useCartBuyerIdentityUpdateCallback/useCartBuyerIdentityUpdateCallback.js +0 -8
  244. package/dist/esnext/hooks/useCartCheckoutUrl/index.d.ts +0 -1
  245. package/dist/esnext/hooks/useCartCheckoutUrl/index.js +0 -1
  246. package/dist/esnext/hooks/useCartCheckoutUrl/useCartCheckoutUrl.d.ts +0 -4
  247. package/dist/esnext/hooks/useCartCheckoutUrl/useCartCheckoutUrl.js +0 -8
  248. package/dist/esnext/hooks/useCartCreateCallback/index.d.ts +0 -1
  249. package/dist/esnext/hooks/useCartCreateCallback/index.js +0 -1
  250. package/dist/esnext/hooks/useCartCreateCallback/useCartCreateCallback.d.ts +0 -4
  251. package/dist/esnext/hooks/useCartCreateCallback/useCartCreateCallback.js +0 -8
  252. package/dist/esnext/hooks/useCartDiscountCodesUpdateCallback/index.d.ts +0 -1
  253. package/dist/esnext/hooks/useCartDiscountCodesUpdateCallback/index.js +0 -1
  254. package/dist/esnext/hooks/useCartDiscountCodesUpdateCallback/useCartDiscountCodesUpdateCallback.d.ts +0 -4
  255. package/dist/esnext/hooks/useCartDiscountCodesUpdateCallback/useCartDiscountCodesUpdateCallback.js +0 -8
  256. package/dist/esnext/hooks/useCartLinesAddCallback/index.d.ts +0 -1
  257. package/dist/esnext/hooks/useCartLinesAddCallback/index.js +0 -1
  258. package/dist/esnext/hooks/useCartLinesAddCallback/useCartLinesAddCallback.d.ts +0 -5
  259. package/dist/esnext/hooks/useCartLinesAddCallback/useCartLinesAddCallback.js +0 -9
  260. package/dist/esnext/hooks/useCartLinesRemoveCallback/index.d.ts +0 -1
  261. package/dist/esnext/hooks/useCartLinesRemoveCallback/index.js +0 -1
  262. package/dist/esnext/hooks/useCartLinesRemoveCallback/useCartLinesRemoveCallback.d.ts +0 -4
  263. package/dist/esnext/hooks/useCartLinesRemoveCallback/useCartLinesRemoveCallback.js +0 -8
  264. package/dist/esnext/hooks/useCartLinesTotalQuantity/index.d.ts +0 -1
  265. package/dist/esnext/hooks/useCartLinesTotalQuantity/index.js +0 -1
  266. package/dist/esnext/hooks/useCartLinesTotalQuantity/useCartLinesTotalQuantity.d.ts +0 -4
  267. package/dist/esnext/hooks/useCartLinesTotalQuantity/useCartLinesTotalQuantity.js +0 -15
  268. package/dist/esnext/hooks/useCartLinesUpdateCallback/index.d.ts +0 -1
  269. package/dist/esnext/hooks/useCartLinesUpdateCallback/index.js +0 -1
  270. package/dist/esnext/hooks/useCartLinesUpdateCallback/useCartLinesUpdateCallback.d.ts +0 -4
  271. package/dist/esnext/hooks/useCartLinesUpdateCallback/useCartLinesUpdateCallback.js +0 -8
  272. package/dist/esnext/hooks/useCartNoteUpdateCallback/index.d.ts +0 -1
  273. package/dist/esnext/hooks/useCartNoteUpdateCallback/index.js +0 -1
  274. package/dist/esnext/hooks/useCartNoteUpdateCallback/useCartNoteUpdateCallback.d.ts +0 -4
  275. package/dist/esnext/hooks/useCartNoteUpdateCallback/useCartNoteUpdateCallback.js +0 -8
  276. package/dist/node/foundation/constants.d.ts +0 -2
  277. package/dist/node/foundation/constants.js +0 -7
package/README.md CHANGED
@@ -8,7 +8,7 @@ Hydrogen is a React framework and SDK that you can use to build fast and dynamic
8
8
 
9
9
  **Requirements:**
10
10
 
11
- - Node v14+
11
+ - Node.js version 16.5.0 or higher
12
12
  - Yarn
13
13
 
14
14
  ```bash
@@ -2,8 +2,6 @@ export * from './components';
2
2
  export * from './hooks';
3
3
  export * from './foundation/useServerState';
4
4
  export * from './foundation/useShop';
5
- export * from './foundation/ShopifyProvider';
6
5
  export * from './foundation/ServerStateProvider';
7
- export { ServerStateRouter } from './foundation/Router/ServerStateRouter.client';
8
- export { Helmet, HelmetProvider } from 'react-helmet-async';
6
+ export { Helmet } from './foundation/Helmet';
9
7
  export * from './utilities';
@@ -2,8 +2,6 @@ export * from './components';
2
2
  export * from './hooks';
3
3
  export * from './foundation/useServerState';
4
4
  export * from './foundation/useShop';
5
- export * from './foundation/ShopifyProvider';
6
5
  export * from './foundation/ServerStateProvider';
7
- export { ServerStateRouter } from './foundation/Router/ServerStateRouter.client';
8
- export { Helmet, HelmetProvider } from 'react-helmet-async';
6
+ export { Helmet } from './foundation/Helmet';
9
7
  export * from './utilities';
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { useCartLinesAddCallback, useCart, useCartCreateCallback, } from '../CartProvider';
2
+ import { useCart } from '../CartProvider';
3
3
  /**
4
4
  * The `AddToCartButton` component renders a button that adds an item to the cart when pressed.
5
5
  * It must be a descendent of the `CartProvider` component.
@@ -7,9 +7,7 @@ import { useCartLinesAddCallback, useCart, useCartCreateCallback, } from '../Car
7
7
  export function AddToCartButton(props) {
8
8
  const [addingItem, setAddingItem] = useState(false);
9
9
  const { variantId, quantity = 1, attributes, children, onAdd, accessibleAddingToCartLabel, ...passthroughProps } = props;
10
- const { status, id } = useCart();
11
- const createCart = useCartCreateCallback();
12
- const addLines = useCartLinesAddCallback();
10
+ const { status, id, cartCreate, linesAdd } = useCart();
13
11
  useEffect(() => {
14
12
  if (addingItem && status === 'idle') {
15
13
  setAddingItem(false);
@@ -19,7 +17,7 @@ export function AddToCartButton(props) {
19
17
  React.createElement("button", { ...passthroughProps, disabled: addingItem || passthroughProps.disabled, onClick: () => {
20
18
  setAddingItem(true);
21
19
  if (!id) {
22
- createCart({
20
+ cartCreate({
23
21
  lines: [
24
22
  {
25
23
  quantity: quantity,
@@ -30,7 +28,7 @@ export function AddToCartButton(props) {
30
28
  });
31
29
  }
32
30
  else {
33
- addLines([
31
+ linesAdd([
34
32
  {
35
33
  quantity: quantity,
36
34
  merchandiseId: variantId,
@@ -1,18 +1,17 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { useCart, useCartCheckoutUrl } from '../CartProvider';
2
+ import { useCart } from '../CartProvider';
3
3
  /**
4
4
  * The `CartCheckoutButton` component renders a button that redirects to the checkout URL for the cart.
5
5
  * It must be a descendent of a `CartProvider` component.
6
6
  */
7
7
  export function CartCheckoutButton(props) {
8
8
  const [requestedCheckout, setRequestedCheckout] = useState(false);
9
- const { status } = useCart();
10
- const url = useCartCheckoutUrl();
9
+ const { status, checkoutUrl } = useCart();
11
10
  const { children, ...passthroughProps } = props;
12
11
  useEffect(() => {
13
- if (requestedCheckout && url && status === 'idle') {
14
- window.location.href = url;
12
+ if (requestedCheckout && checkoutUrl && status === 'idle') {
13
+ window.location.href = checkoutUrl;
15
14
  }
16
- }, [requestedCheckout, status, url]);
15
+ }, [requestedCheckout, status, checkoutUrl]);
17
16
  return (React.createElement("button", { ...passthroughProps, disabled: requestedCheckout || passthroughProps.disabled, onClick: () => setRequestedCheckout(true) }, children));
18
17
  }
@@ -12,6 +12,10 @@ interface AttributesRenderProps {
12
12
  * cart line's attributes. It must be a descendent of a `CartLineProvider` component.
13
13
  */
14
14
  export declare function CartLineAttributes<TTag extends ElementType>(props: Props<TTag> & {
15
+ /** A `ReactNode` element. Valid values: `ul` or `undefined`. If `ul`, then each child will
16
+ * be wrapped with a `li` element.
17
+ */
18
+ as?: ElementType;
15
19
  /** A function that takes an object as an argument and returns a `ReactNode`. */
16
20
  children: (props: AttributesRenderProps) => ReactElement;
17
21
  }): JSX.Element;
@@ -1,6 +1,7 @@
1
1
  import { ElementType } from 'react';
2
+ import { MoneyProps } from '../Money';
2
3
  import { Props } from '../types';
3
- export interface CartLinePriceProps {
4
+ export interface CartLinePriceProps extends Omit<MoneyProps, 'money'> {
4
5
  /** The type of price. Valid values:`regular` (default) or `compareAt`. */
5
6
  priceType?: 'regular' | 'compareAt';
6
7
  }
@@ -17,5 +17,5 @@ export function CartLinePrice(props) {
17
17
  return (React.createElement(Money, { ...passthroughProps, money: {
18
18
  amount: price.amount * cartLine.quantity,
19
19
  currencyCode: price.currencyCode,
20
- } }, props.children));
20
+ } }));
21
21
  }
@@ -4,4 +4,7 @@ import { Props } from '../types';
4
4
  * The `CartLineProductTitle` component renders a `span` element (or the type of HTML element specified by
5
5
  * the `as` prop) with the cart line merchandise's title. It must be a descendent of a `CartLineProvider` component.
6
6
  */
7
- export declare function CartLineProductTitle<TTag extends ElementType>(props: Props<TTag>): JSX.Element;
7
+ export declare function CartLineProductTitle<TTag extends ElementType>(props: Props<TTag> & {
8
+ /** An HTML tag to be rendered as the base element wrapper. The default is `span`. */
9
+ as?: ElementType;
10
+ }): JSX.Element;
@@ -4,4 +4,7 @@ import { Props } from '../types';
4
4
  * The `CartLineQuantity` component renders a `span` element (or the type of HTML element
5
5
  * specified by the `as` prop) with the cart line's quantity. It must be a descendent of a `CartLineProvider` component.
6
6
  */
7
- export declare function CartLineQuantity<TTag extends ElementType>(props: Props<TTag>): JSX.Element;
7
+ export declare function CartLineQuantity<TTag extends ElementType>(props: Props<TTag> & {
8
+ /** An HTML tag to be rendered as the base element wrapper. The default is `div`. */
9
+ as?: ElementType;
10
+ }): JSX.Element;
@@ -1,26 +1,24 @@
1
1
  import React from 'react';
2
- import { useCart, useCartLinesRemoveCallback, useCartLinesUpdateCallback, } from '../CartProvider';
2
+ import { useCart } from '../CartProvider';
3
3
  import { useCartLine } from '../CartLineProvider';
4
4
  /**
5
5
  * The `CartLineQuantityAdjustButton` component renders a button that adjusts the cart line's quantity when pressed.
6
6
  * It must be a descendent of a `CartLineProvider` component.
7
7
  */
8
8
  export function CartLineQuantityAdjustButton(props) {
9
- const updateLines = useCartLinesUpdateCallback();
10
- const removeLines = useCartLinesRemoveCallback();
11
- const { status } = useCart();
9
+ const { status, linesRemove, linesUpdate } = useCart();
12
10
  const cartLine = useCartLine();
13
11
  const { children, adjust, ...passthroughProps } = props;
14
12
  return (React.createElement("button", { disabled: status !== 'idle', onClick: () => {
15
13
  if (adjust === 'remove') {
16
- removeLines([cartLine.id]);
14
+ linesRemove([cartLine.id]);
17
15
  return;
18
16
  }
19
17
  const quantity = adjust === 'decrease' ? cartLine.quantity - 1 : cartLine.quantity + 1;
20
18
  if (quantity <= 0) {
21
- removeLines([cartLine.id]);
19
+ linesRemove([cartLine.id]);
22
20
  return;
23
21
  }
24
- updateLines([{ id: cartLine.id, quantity }]);
22
+ linesUpdate([{ id: cartLine.id, quantity }]);
25
23
  }, ...passthroughProps }, children));
26
24
  }
@@ -11,6 +11,10 @@ interface SelectedOptionsRenderProps {
11
11
  * for each of the cart line merchandise's selected options. It must be a descendent of a `CartLineProvider` component.
12
12
  */
13
13
  export declare function CartLineSelectedOptions<TTag extends ElementType>(props: Props<TTag> & {
14
+ /** A `ReactNode` element. Valid values: `ul` or `undefined`. If `ul`, then each child will
15
+ * be wrapped with a `li` element.
16
+ */
17
+ as?: ElementType;
14
18
  /** A function that takes an object as an argument and returns a `ReactNode`. */
15
19
  children: (props: SelectedOptionsRenderProps) => ReactElement;
16
20
  }): JSX.Element;
@@ -1,16 +1,15 @@
1
1
  import { ReactNode, ElementType } from 'react';
2
- import { Cart } from '../CartProvider';
3
2
  import { Props } from '../types';
4
3
  export interface CartLinesProps {
5
4
  /** A `ReactNode` element. Valid values: `ul` or `undefined`. If `ul`, then each child will
6
5
  * be wrapped with a `li` element.
7
6
  */
8
7
  as?: 'ul';
9
- /** A `ReactNode` element or a function that takes a cart line as an argument and returns a `ReactNode`. */
10
- children: ReactNode | ((line: Cart['lines'][1]) => ReactNode);
8
+ /** A `ReactNode` element */
9
+ children: ReactNode;
11
10
  }
12
11
  /**
13
12
  * The `CartLines` component iterates over each cart line and renders its `children` within
14
- * a `CartLineProvider` for each cart line. It also provides render props in the case where `children` is a function.
13
+ * a `CartLineProvider` for each cart line.
15
14
  */
16
15
  export declare function CartLines<TTag extends ElementType>(props: Props<TTag> & CartLinesProps): JSX.Element;
@@ -1,9 +1,9 @@
1
- import React, { cloneElement, Fragment } from 'react';
1
+ import React, { Fragment } from 'react';
2
2
  import { useCart } from '../CartProvider';
3
3
  import { CartLineProvider } from '../CartLineProvider';
4
4
  /**
5
5
  * The `CartLines` component iterates over each cart line and renders its `children` within
6
- * a `CartLineProvider` for each cart line. It also provides render props in the case where `children` is a function.
6
+ * a `CartLineProvider` for each cart line.
7
7
  */
8
8
  export function CartLines(props) {
9
9
  const { lines } = useCart();
@@ -12,8 +12,6 @@ export function CartLines(props) {
12
12
  const ChildWrapper = Wrapper === 'ul' ? 'li' : Fragment;
13
13
  return (React.createElement(Wrapper, { ...passthroughProps }, lines.map((line) => {
14
14
  return (React.createElement(ChildWrapper, { key: line.id },
15
- React.createElement(CartLineProvider, { line: line }, typeof children === 'function'
16
- ? cloneElement(children(line))
17
- : children)));
15
+ React.createElement(CartLineProvider, { line: line }, children)));
18
16
  })));
19
17
  }
@@ -13,21 +13,21 @@ export declare function CartProvider({ children, numCartLines, onCreate, onLineA
13
13
  /** Any `ReactNode` elements. */
14
14
  children: React.ReactNode;
15
15
  numCartLines?: number;
16
- /** A callback that is run automatically when a cart is created. */
16
+ /** A callback that is invoked when the process to create a cart begins, but before the cart is created in the Storefront API. */
17
17
  onCreate?: () => void;
18
- /** A callback that is run automatically when a new cart line is added. */
18
+ /** A callback that is invoked when the process to add a line item to the cart begins, but before the line item is added to the Storefront API. */
19
19
  onLineAdd?: () => void;
20
- /** A callback that is run automatically when a cart line is removed. */
20
+ /** A callback that is invoked when the process to remove a line item to the cart begins, but before the line item is removed from the Storefront API. */
21
21
  onLineRemove?: () => void;
22
- /** A callback that is run automatically when a cart line is updated. */
22
+ /** A callback that is invoked when the process to update a line item in the cart begins, but before the line item is updated in the Storefront API. */
23
23
  onLineUpdate?: () => void;
24
- /** A callback that is run automatically when the cart note is updated. */
24
+ /** A callback that is invoked when the process to add or update a note in the cart begins, but before the note is added or updated in the Storefront API. */
25
25
  onNoteUpdate?: () => void;
26
- /** A callback that is run automatically when the cart's buyer identity is updated. */
26
+ /** A callback that is invoked when the process to update the buyer identity begins, but before the buyer identity is updated in the Storefront API. */
27
27
  onBuyerIdentityUpdate?: () => void;
28
- /** A callback that is run automatically when the cart's buyer identity is updated. */
28
+ /** A callback that is invoked when the process to update the cart attributes begins, but before the attributes are updated in the Storefront API. */
29
29
  onAttributesUpdate?: () => void;
30
- /** A callback that is run automatically when the cart's discount codes are updated. */
30
+ /** A callback that is invoked when the process to update the cart discount codes begins, but before the discount codes are updated in the Storefront API. */
31
31
  onDiscountCodesUpdate?: () => void;
32
32
  /**
33
33
  * A cart object from the Storefront API to populate the initial state of the provider.
@@ -429,6 +429,11 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
429
429
  }),
430
430
  status: state.status,
431
431
  error: 'error' in state ? state.error : undefined,
432
+ totalQuantity: 'cart' in state
433
+ ? state.cart.lines.reduce((previous, current) => {
434
+ return previous + current.quantity;
435
+ }, 0)
436
+ : 0,
432
437
  cartCreate,
433
438
  linesAdd(lines) {
434
439
  addLineItem(lines, state);
@@ -3,9 +3,9 @@ import { useShop } from '../../foundation';
3
3
  import { flattenConnection } from '../../utilities';
4
4
  import { CartCreate } from '../../graphql/graphql-constants';
5
5
  export function useCartFetch() {
6
- const { storeDomain, graphqlApiVersion, storefrontToken } = useShop();
6
+ const { storeDomain, storefrontApiVersion, storefrontToken } = useShop();
7
7
  return React.useCallback(({ query, variables, }) => {
8
- return fetch(`https://${storeDomain}/api/${graphqlApiVersion}/graphql.json`, {
8
+ return fetch(`https://${storeDomain}/api/${storefrontApiVersion}/graphql.json`, {
9
9
  method: 'POST',
10
10
  headers: {
11
11
  'Content-Type': 'application/json',
@@ -23,7 +23,7 @@ export function useCartFetch() {
23
23
  error: error.toString(),
24
24
  };
25
25
  });
26
- }, [storeDomain, graphqlApiVersion, storefrontToken]);
26
+ }, [storeDomain, storefrontApiVersion, storefrontToken]);
27
27
  }
28
28
  export function useInstantCheckout() {
29
29
  const [cart, updateCart] = useState();
@@ -1,14 +1,4 @@
1
1
  export { CartProvider } from './CartProvider.client';
2
2
  export { useCartFetch, useInstantCheckout } from './hooks';
3
3
  export { useCart } from '../../hooks/useCart';
4
- export { useCartAttributesUpdateCallback } from '../../hooks/useCartAttributesUpdateCallback';
5
- export { useCartBuyerIdentityUpdateCallback } from '../../hooks/useCartBuyerIdentityUpdateCallback';
6
- export { useCartNoteUpdateCallback } from '../../hooks/useCartNoteUpdateCallback';
7
- export { useCartCheckoutUrl } from '../../hooks/useCartCheckoutUrl';
8
- export { useCartCreateCallback } from '../../hooks/useCartCreateCallback';
9
- export { useCartDiscountCodesUpdateCallback } from '../../hooks/useCartDiscountCodesUpdateCallback';
10
- export { useCartLinesAddCallback } from '../../hooks/useCartLinesAddCallback';
11
- export { useCartLinesRemoveCallback } from '../../hooks/useCartLinesRemoveCallback';
12
- export { useCartLinesTotalQuantity } from '../../hooks/useCartLinesTotalQuantity';
13
- export { useCartLinesUpdateCallback } from '../../hooks/useCartLinesUpdateCallback';
14
4
  export type { State, Status, Cart, CartWithActions, CartAction } from './types';
@@ -1,13 +1,3 @@
1
1
  export { CartProvider } from './CartProvider.client';
2
2
  export { useCartFetch, useInstantCheckout } from './hooks';
3
3
  export { useCart } from '../../hooks/useCart';
4
- export { useCartAttributesUpdateCallback } from '../../hooks/useCartAttributesUpdateCallback';
5
- export { useCartBuyerIdentityUpdateCallback } from '../../hooks/useCartBuyerIdentityUpdateCallback';
6
- export { useCartNoteUpdateCallback } from '../../hooks/useCartNoteUpdateCallback';
7
- export { useCartCheckoutUrl } from '../../hooks/useCartCheckoutUrl';
8
- export { useCartCreateCallback } from '../../hooks/useCartCreateCallback';
9
- export { useCartDiscountCodesUpdateCallback } from '../../hooks/useCartDiscountCodesUpdateCallback';
10
- export { useCartLinesAddCallback } from '../../hooks/useCartLinesAddCallback';
11
- export { useCartLinesRemoveCallback } from '../../hooks/useCartLinesRemoveCallback';
12
- export { useCartLinesTotalQuantity } from '../../hooks/useCartLinesTotalQuantity';
13
- export { useCartLinesUpdateCallback } from '../../hooks/useCartLinesUpdateCallback';
@@ -1,40 +1,70 @@
1
1
  import { CartInput, CartLineInput, CartLineUpdateInput, MutationCartNoteUpdateArgs, CartBuyerIdentityInput, MutationCartAttributesUpdateArgs } from '../../graphql/types/types';
2
2
  import { CartFragmentFragment } from './graphql/CartFragment';
3
- export declare type Status = 'uninitialized' | 'fetching' | 'creating' | 'updating' | 'idle';
3
+ export declare type Status = State['status'];
4
4
  export interface Cart {
5
+ /** The cart's ID if it has been created through the Storefront API. */
5
6
  id?: string;
7
+ /** The cart lines. */
6
8
  lines: CartFragmentFragment['lines']['edges'][1]['node'][];
9
+ /** The checkout URL for the cart, if the cart has been created in the Storefront API. */
7
10
  checkoutUrl?: string;
11
+ /** The cart's note. */
8
12
  note?: string;
13
+ /** The cart's buyer identity. */
9
14
  buyerIdentity?: CartFragmentFragment['buyerIdentity'];
15
+ /** The cart's attributes. */
10
16
  attributes: CartFragmentFragment['attributes'];
17
+ /** The discount codes applied to the cart. */
11
18
  discountCodes?: CartFragmentFragment['discountCodes'];
19
+ /** The estimate cost for the cart, including the subtotal, total, taxes, and duties. */
12
20
  estimatedCost?: CartFragmentFragment['estimatedCost'];
13
21
  }
14
22
  export interface CartWithActions extends Cart {
23
+ /** The status of the cart. This returns 'uninitialized' when the cart is not yet created, `creating` when the cart is being created, `fetching` when an existing cart is being fetched, `updating` when the cart is updating, and `idle` when the cart isn't being created or updated. */
15
24
  status: Status;
25
+ /** If an error occurred on the previous cart action, then `error` will exist and `cart` will be put back into the last valid status it was in. */
16
26
  error?: string;
27
+ /** A callback that creates a cart. Expects the same input you would provide to the Storefront API's `cartCreate` mutation. */
17
28
  cartCreate: (cart: CartInput) => void;
29
+ /** A callback that adds lines to the cart. Expects the same `lines` input that you would provide to the Storefront API's `cartLinesAdd` mutation. If a cart doesn't already exist, then it will create the cart for you. */
18
30
  linesAdd: (lines: CartLineInput[]) => void;
31
+ /** A callback that removes lines from the cart. Expects the same `lines` input that you would provide to the Storefront API's `cartLinesRemove` mutation. Only lines that are included in the `lines` parameter will be in the cart afterwards. */
19
32
  linesRemove: (lines: string[]) => void;
33
+ /** A callback that updates lines in the cart. Expects the same `lines` input that you would provide to the Storefront API's `cartLinesUpdate` mutation. If a line item is not included in the `lines` parameter, it will still exist in the cart and will not be changed. */
20
34
  linesUpdate: (lines: CartLineUpdateInput[]) => void;
35
+ /** A callback that updates the note in the cart. Expects the same `note` input that you would provide to the Storefront API's `cartNoteUpdate` mutation. */
21
36
  noteUpdate: (note: MutationCartNoteUpdateArgs['note']) => void;
37
+ /** A callback that updates the buyer identity in the cart. Expects the same `buyerIdentity` input that you would provide to the Storefront API's `cartBuyerIdentityUpdate` mutation. */
22
38
  buyerIdentityUpdate: (buyerIdenity: CartBuyerIdentityInput) => void;
39
+ /** A callback that updates the cart attributes. Expects the same `attributes` input that you would provide to the Storefront API's `cartAttributesUpdate` mutation. */
23
40
  cartAttributesUpdate: (attributes: MutationCartAttributesUpdateArgs['attributes']) => void;
41
+ /** A callback that updates the cart's discount codes. Expects the same `codes` input that you would provide to the Storefront API's `cartDiscountCodesUpdate` mutation. */
24
42
  discountCodesUpdate: (discountCodes: string[]) => void;
43
+ /** The total number of items in the cart, across all lines. If there are no lines, then the value is 0. */
44
+ totalQuantity: number;
25
45
  }
26
- export declare type State = {
46
+ export declare type State =
47
+ /** A cart has not been created yet, or an error occurred when a cart was attempting to be created or fetched. */
48
+ {
27
49
  status: 'uninitialized';
28
50
  error?: string;
29
- } | {
51
+ }
52
+ /** An existing cart is being fetched from the Storefront API. */
53
+ | {
30
54
  status: 'fetching';
31
- } | {
55
+ }
56
+ /** A new cart is being created through the Storefront API. */
57
+ | {
32
58
  status: 'creating';
33
- } | {
59
+ }
60
+ /** The cart is in the process of being updated. */
61
+ | {
34
62
  status: 'updating';
35
63
  cart: Cart;
36
64
  lastValidCart: Cart;
37
- } | {
65
+ }
66
+ /** The cart has been created and no action is currently happening. */
67
+ | {
38
68
  status: 'idle';
39
69
  cart: Cart;
40
70
  error?: string;
@@ -9,8 +9,11 @@ export function CartShopPayButton({
9
9
  /** A string of classes to apply to the `div` that wraps the `shop-pay-button` web component. */
10
10
  className, }) {
11
11
  const { lines } = useCart();
12
- const ids = useMemo(() => {
13
- return lines.map((line) => line.merchandise.id);
12
+ const idsAndQuantities = useMemo(() => {
13
+ return lines.map((line) => ({
14
+ id: line.merchandise.id,
15
+ quantity: line.quantity,
16
+ }));
14
17
  }, [lines]);
15
- return React.createElement(ShopPayButton, { className: className, variantIds: ids });
18
+ return (React.createElement(ShopPayButton, { className: className, variantIdsAndQuantities: idsAndQuantities }));
16
19
  }
@@ -1 +1,18 @@
1
- export declare function Link(props: any): JSX.Element;
1
+ import React from 'react';
2
+ export interface LinkProps
3
+ /** All properties available to an `<a>` element are available. See [anchor element documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes).*/
4
+ extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
5
+ /** The destination URL that the link points to. This is the `href` attribute of the underlying `<a>` element. */
6
+ to: string;
7
+ /** Whether to update the state object or URL of the current history entry. Refer to the [history.replaceState documentation](https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState). */
8
+ replace?: boolean;
9
+ /** The custom client state with the navigation. */
10
+ clientState?: any;
11
+ /** Whether to reload the whole document on navigation. */
12
+ reloadDocument?: boolean;
13
+ }
14
+ /**
15
+ * The `Link` component lets users navigate from one page to another.
16
+ * It renders an accessible `<a>` element.
17
+ */
18
+ export declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
@@ -1,5 +1,43 @@
1
- import React from 'react';
2
- import { Link as RRLink } from 'react-router-dom';
3
- export function Link(props) {
4
- return import.meta.env.SSR ? (React.createElement("a", { href: props.to, ...props, to: null })) : (React.createElement(RRLink, { ...props }));
1
+ import React, { useCallback } from 'react';
2
+ import { useRouter } from '../Router';
3
+ import { createPath } from 'history';
4
+ import { useNavigate } from '../../hooks/useNavigate';
5
+ /**
6
+ * The `Link` component lets users navigate from one page to another.
7
+ * It renders an accessible `<a>` element.
8
+ */
9
+ export const Link = React.forwardRef(function Link(props, ref) {
10
+ const navigate = useNavigate();
11
+ const { location } = useRouter();
12
+ const { reloadDocument, target, replace: _replace, to, onClick, clientState, } = props;
13
+ const internalClick = useCallback((e) => {
14
+ if (onClick)
15
+ onClick(e);
16
+ if (!reloadDocument && // do regular browser stuff
17
+ e.button === 0 && // Ignore everything but left clicks
18
+ (!target || target === '_self') && // Let browser handle "target=_blank"
19
+ !isModifiedEvent(e) // Ignore modifier key clicks
20
+ ) {
21
+ e.preventDefault();
22
+ // If the URL hasn't changed, the regular <a> will do a replace
23
+ const replace = !!_replace || createPath(location) === createPath({ pathname: to });
24
+ navigate(props.to, {
25
+ replace,
26
+ clientState,
27
+ });
28
+ }
29
+ }, [reloadDocument, target, _replace, to, clientState, onClick, location]);
30
+ return (React.createElement("a", { ...without(props, ['to', 'replace', 'clientState', 'reloadDocument']), ref: ref, onClick: internalClick, href: props.to }, props.children));
31
+ });
32
+ function isModifiedEvent(event) {
33
+ return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
34
+ }
35
+ function without(obj, props) {
36
+ const newObj = {};
37
+ for (const key of Object.keys(obj)) {
38
+ if (!props.includes(key)) {
39
+ newObj[key] = obj[key];
40
+ }
41
+ }
42
+ return newObj;
5
43
  }
@@ -6,7 +6,7 @@ import { ReactNode } from 'react';
6
6
  *
7
7
  * Any descendents of this provider can use the `useCountry` and `useAvailableCountries` hooks.
8
8
  * The `isoCode` of the `country` can be used in the Storefront API's
9
- * [`@inContext`](/api/storefront/reference/directives/incontext) directive as the `country` value.
9
+ * `@inContext` directive as the `country` value.
10
10
  */
11
11
  export declare function LocalizationProvider({ children }: {
12
12
  children: ReactNode;
@@ -9,7 +9,7 @@ import { Localization } from '../../graphql/graphql-constants';
9
9
  *
10
10
  * Any descendents of this provider can use the `useCountry` and `useAvailableCountries` hooks.
11
11
  * The `isoCode` of the `country` can be used in the Storefront API's
12
- * [`@inContext`](/api/storefront/reference/directives/incontext) directive as the `country` value.
12
+ * `@inContext` directive as the `country` value.
13
13
  */
14
14
  export function LocalizationProvider({ children }) {
15
15
  const { data: { localization }, } = useShopQuery({
@@ -1,23 +1,23 @@
1
1
  import { MediaImageProps } from '../Image';
2
2
  import { VideoProps } from '../Video';
3
3
  import { ExternalVideoProps } from '../ExternalVideo';
4
- import { Model3DProps } from '../Model3D';
4
+ import { ModelViewerProps } from '../ModelViewer';
5
5
  import { Media as MediaType } from '../../graphql/types/types';
6
6
  export declare type Media = Pick<MediaType, 'mediaContentType'>;
7
7
  declare type MediaImageMedia = Media & MediaImageProps;
8
- declare type Model3DMedia = Media & Model3DProps['model'];
8
+ declare type ModelViewerMedia = Media & ModelViewerProps['model'];
9
9
  declare type ExternalVideoMedia = Media & ExternalVideoProps['video'];
10
10
  declare type VideoMedia = Media & VideoProps['video'];
11
11
  export interface MediaFileProps {
12
12
  /** A [Media object](/api/storefront/reference/products/media). */
13
- media: MediaImageMedia | Model3DMedia | ExternalVideoMedia | VideoMedia;
14
- /** The options for the `Image`, `Video`, `ExternalVideo`, or `Model3D` components. */
13
+ media: MediaImageMedia | ModelViewerMedia | ExternalVideoMedia | VideoMedia;
14
+ /** The options for the `Image`, `Video`, `ExternalVideo`, or `ModelViewer` components. */
15
15
  options?: VideoProps['options'] | ExternalVideoProps['options'];
16
16
  }
17
17
  /**
18
18
  * The `MediaFile` component renders the media for the Storefront API's
19
19
  * [Media object](/api/storefront/reference/products/media). It renders an `Image`, a
20
- * `Video`, an `ExternalVideo`, or a `Model3D` depending on the `mediaContentType` of the
20
+ * `Video`, an `ExternalVideo`, or a `ModelViewer` depending on the `mediaContentType` of the
21
21
  * `media` provided as a prop.
22
22
  */
23
23
  export declare function MediaFile({ media, options, ...passthroughProps }: MediaFileProps): JSX.Element | null;
@@ -2,12 +2,12 @@ import * as React from 'react';
2
2
  import { Image } from '../Image';
3
3
  import { Video } from '../Video';
4
4
  import { ExternalVideo } from '../ExternalVideo';
5
- import { Model3D } from '../Model3D';
5
+ import { ModelViewer } from '../ModelViewer';
6
6
  import { MediaFileFragment as Fragment } from '../../graphql/graphql-constants';
7
7
  /**
8
8
  * The `MediaFile` component renders the media for the Storefront API's
9
9
  * [Media object](/api/storefront/reference/products/media). It renders an `Image`, a
10
- * `Video`, an `ExternalVideo`, or a `Model3D` depending on the `mediaContentType` of the
10
+ * `Video`, an `ExternalVideo`, or a `ModelViewer` depending on the `mediaContentType` of the
11
11
  * `media` provided as a prop.
12
12
  */
13
13
  export function MediaFile({ media, options, ...passthroughProps }) {
@@ -20,7 +20,7 @@ export function MediaFile({ media, options, ...passthroughProps }) {
20
20
  case 'EXTERNAL_VIDEO':
21
21
  return (React.createElement(ExternalVideo, { ...passthroughProps, video: media, options: options }));
22
22
  case 'MODEL_3D':
23
- return React.createElement(Model3D, { ...passthroughProps, model: media });
23
+ return (React.createElement(ModelViewer, { ...passthroughProps, model: media }));
24
24
  default:
25
25
  return null;
26
26
  }
@@ -2,7 +2,7 @@ import * as Types from '../../graphql/types/types';
2
2
  import { ImageFragmentFragment } from '../Image/ImageFragment';
3
3
  import { VideoFragmentFragment } from '../Video/VideoFragment';
4
4
  import { ExternalVideoFragmentFragment } from '../ExternalVideo/ExternalVideoFragment';
5
- import { Model3DFragmentFragment } from '../Model3D/Model3DFragment';
5
+ import { Model3DFragmentFragment } from '../ModelViewer/Model3DFragment';
6
6
  export declare type MediaFileFragment_ExternalVideo_Fragment = {
7
7
  __typename?: 'ExternalVideo';
8
8
  } & Pick<Types.ExternalVideo, 'mediaContentType'> & ExternalVideoFragmentFragment;
@@ -1,21 +1,17 @@
1
- import { ElementType, ReactElement } from 'react';
1
+ import { ElementType } from 'react';
2
2
  import { Props } from '../types';
3
3
  import { ParsedMetafield } from '../../types';
4
4
  export interface MetafieldProps {
5
5
  /** A [Metafield object](/api/storefront/reference/common-objects/metafield) from the Storefront API. */
6
6
  metafield: ParsedMetafield;
7
- /** A render function that takes a `Metafield` object as an argument. Refer to [Render props](#render-props). */
8
- children?: (value: ParsedMetafield) => ReactElement;
7
+ /** An HTML tag to be rendered as the base element wrapper. The default value varies depending on [metafield.type](/apps/metafields/types). */
8
+ as?: ElementType;
9
9
  }
10
10
  /**
11
11
  * The `Metafield` component renders the value of a Storefront
12
12
  * API's [Metafield object](/api/storefront/reference/common-objects/metafield).
13
13
  *
14
- * When a render function is provided, it passes the Metafield object with a value
15
- * that was parsed according to the Metafield's `type` field. For more information,
16
- * refer to the [Render props](#render-props) section.
17
-
18
- * When no render function is provided, it renders a smart default of the
14
+ * Renders a smart default of the
19
15
  * Metafield's `value`. For more information, refer to the [Default Output](#default-output) section.
20
16
  */
21
17
  export declare function Metafield<TTag extends ElementType>(props: Props<TTag> & MetafieldProps): JSX.Element | null;