@shopify/hydrogen-react 2023.1.8 → 2023.4.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 (251) hide show
  1. package/dist/browser-dev/CartProvider.mjs.map +1 -1
  2. package/dist/browser-dev/Image.mjs +336 -90
  3. package/dist/browser-dev/Image.mjs.map +1 -1
  4. package/dist/browser-dev/MediaFile.mjs.map +1 -1
  5. package/dist/browser-dev/ModelViewer.mjs.map +1 -1
  6. package/dist/browser-dev/Money.mjs.map +1 -1
  7. package/dist/browser-dev/Video.mjs +2 -2
  8. package/dist/browser-dev/Video.mjs.map +1 -1
  9. package/dist/browser-dev/analytics-utils.mjs.map +1 -1
  10. package/dist/browser-dev/index.mjs +4 -3
  11. package/dist/browser-dev/node_modules/@xstate/react/es/useConstant.mjs +2 -2
  12. package/dist/browser-dev/node_modules/@xstate/react/es/useConstant.mjs.map +1 -1
  13. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +2 -2
  14. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +2 -2
  15. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
  16. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +2 -2
  17. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +2 -2
  18. package/dist/browser-dev/storefront-api-constants.mjs +1 -1
  19. package/dist/browser-dev/storefront-api-constants.mjs.map +1 -1
  20. package/dist/browser-dev/storefront-client.mjs.map +1 -1
  21. package/dist/browser-dev/useCartAPIStateMachine.mjs.map +1 -1
  22. package/dist/browser-dev/useCartActions.mjs.map +1 -1
  23. package/dist/browser-prod/CartProvider.mjs.map +1 -1
  24. package/dist/browser-prod/Image.mjs +302 -82
  25. package/dist/browser-prod/Image.mjs.map +1 -1
  26. package/dist/browser-prod/MediaFile.mjs.map +1 -1
  27. package/dist/browser-prod/ModelViewer.mjs.map +1 -1
  28. package/dist/browser-prod/Money.mjs.map +1 -1
  29. package/dist/browser-prod/Video.mjs +2 -2
  30. package/dist/browser-prod/Video.mjs.map +1 -1
  31. package/dist/browser-prod/analytics-utils.mjs.map +1 -1
  32. package/dist/browser-prod/index.mjs +4 -3
  33. package/dist/browser-prod/node_modules/@xstate/react/es/useConstant.mjs +2 -2
  34. package/dist/browser-prod/node_modules/@xstate/react/es/useConstant.mjs.map +1 -1
  35. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +2 -2
  36. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +2 -2
  37. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
  38. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +2 -2
  39. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +2 -2
  40. package/dist/browser-prod/storefront-api-constants.mjs +1 -1
  41. package/dist/browser-prod/storefront-api-constants.mjs.map +1 -1
  42. package/dist/browser-prod/storefront-client.mjs.map +1 -1
  43. package/dist/browser-prod/useCartAPIStateMachine.mjs.map +1 -1
  44. package/dist/browser-prod/useCartActions.mjs.map +1 -1
  45. package/dist/node-dev/AddToCartButton.js +4 -4
  46. package/dist/node-dev/AddToCartButton.js.map +1 -1
  47. package/dist/node-dev/BaseButton.js +2 -2
  48. package/dist/node-dev/BaseButton.js.map +1 -1
  49. package/dist/node-dev/BuyNowButton.js +4 -4
  50. package/dist/node-dev/BuyNowButton.js.map +1 -1
  51. package/dist/node-dev/CartCheckoutButton.js +3 -3
  52. package/dist/node-dev/CartCheckoutButton.js.map +1 -1
  53. package/dist/node-dev/CartLineProvider.js +3 -3
  54. package/dist/node-dev/CartLineProvider.js.map +1 -1
  55. package/dist/node-dev/CartLineQuantityAdjustButton.js +2 -2
  56. package/dist/node-dev/CartLineQuantityAdjustButton.js.map +1 -1
  57. package/dist/node-dev/CartProvider.js +20 -20
  58. package/dist/node-dev/CartProvider.js.map +1 -1
  59. package/dist/node-dev/CartProvider.mjs.map +1 -1
  60. package/dist/node-dev/Image.js +350 -87
  61. package/dist/node-dev/Image.js.map +1 -1
  62. package/dist/node-dev/Image.mjs +336 -90
  63. package/dist/node-dev/Image.mjs.map +1 -1
  64. package/dist/node-dev/MediaFile.js.map +1 -1
  65. package/dist/node-dev/MediaFile.mjs.map +1 -1
  66. package/dist/node-dev/ModelViewer.js +4 -4
  67. package/dist/node-dev/ModelViewer.js.map +1 -1
  68. package/dist/node-dev/ModelViewer.mjs.map +1 -1
  69. package/dist/node-dev/Money.js.map +1 -1
  70. package/dist/node-dev/Money.mjs.map +1 -1
  71. package/dist/node-dev/ProductProvider.js +14 -14
  72. package/dist/node-dev/ProductProvider.js.map +1 -1
  73. package/dist/node-dev/ShopifyProvider.js +4 -4
  74. package/dist/node-dev/ShopifyProvider.js.map +1 -1
  75. package/dist/node-dev/Video.js +4 -4
  76. package/dist/node-dev/Video.js.map +1 -1
  77. package/dist/node-dev/Video.mjs +2 -2
  78. package/dist/node-dev/Video.mjs.map +1 -1
  79. package/dist/node-dev/analytics-utils.js.map +1 -1
  80. package/dist/node-dev/analytics-utils.mjs.map +1 -1
  81. package/dist/node-dev/cart-hooks.js +2 -2
  82. package/dist/node-dev/cart-hooks.js.map +1 -1
  83. package/dist/node-dev/index.js +3 -2
  84. package/dist/node-dev/index.js.map +1 -1
  85. package/dist/node-dev/index.mjs +4 -3
  86. package/dist/node-dev/load-script.js +3 -3
  87. package/dist/node-dev/load-script.js.map +1 -1
  88. package/dist/node-dev/node_modules/@xstate/react/es/fsm.js +6 -6
  89. package/dist/node-dev/node_modules/@xstate/react/es/fsm.js.map +1 -1
  90. package/dist/node-dev/node_modules/@xstate/react/es/useConstant.js +3 -3
  91. package/dist/node-dev/node_modules/@xstate/react/es/useConstant.js.map +1 -1
  92. package/dist/node-dev/node_modules/@xstate/react/es/useConstant.mjs +2 -2
  93. package/dist/node-dev/node_modules/@xstate/react/es/useConstant.mjs.map +1 -1
  94. package/dist/node-dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js +2 -2
  95. package/dist/node-dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js.map +1 -1
  96. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +3 -3
  97. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
  98. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +2 -2
  99. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +2 -2
  100. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -1
  101. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +2 -2
  102. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
  103. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +6 -6
  104. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
  105. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +2 -2
  106. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +2 -2
  107. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
  108. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +2 -2
  109. package/dist/node-dev/storefront-api-constants.js +1 -1
  110. package/dist/node-dev/storefront-api-constants.js.map +1 -1
  111. package/dist/node-dev/storefront-api-constants.mjs +1 -1
  112. package/dist/node-dev/storefront-api-constants.mjs.map +1 -1
  113. package/dist/node-dev/storefront-client.js.map +1 -1
  114. package/dist/node-dev/storefront-client.mjs.map +1 -1
  115. package/dist/node-dev/useCartAPIStateMachine.js +3 -3
  116. package/dist/node-dev/useCartAPIStateMachine.js.map +1 -1
  117. package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -1
  118. package/dist/node-dev/useCartActions.js +11 -11
  119. package/dist/node-dev/useCartActions.js.map +1 -1
  120. package/dist/node-dev/useCartActions.mjs.map +1 -1
  121. package/dist/node-dev/useMoney.js +5 -5
  122. package/dist/node-dev/useMoney.js.map +1 -1
  123. package/dist/node-dev/useShopifyCookies.js +2 -2
  124. package/dist/node-dev/useShopifyCookies.js.map +1 -1
  125. package/dist/node-prod/AddToCartButton.js +4 -4
  126. package/dist/node-prod/AddToCartButton.js.map +1 -1
  127. package/dist/node-prod/BaseButton.js +2 -2
  128. package/dist/node-prod/BaseButton.js.map +1 -1
  129. package/dist/node-prod/BuyNowButton.js +4 -4
  130. package/dist/node-prod/BuyNowButton.js.map +1 -1
  131. package/dist/node-prod/CartCheckoutButton.js +3 -3
  132. package/dist/node-prod/CartCheckoutButton.js.map +1 -1
  133. package/dist/node-prod/CartLineProvider.js +3 -3
  134. package/dist/node-prod/CartLineProvider.js.map +1 -1
  135. package/dist/node-prod/CartLineQuantityAdjustButton.js +2 -2
  136. package/dist/node-prod/CartLineQuantityAdjustButton.js.map +1 -1
  137. package/dist/node-prod/CartProvider.js +20 -20
  138. package/dist/node-prod/CartProvider.js.map +1 -1
  139. package/dist/node-prod/CartProvider.mjs.map +1 -1
  140. package/dist/node-prod/Image.js +317 -80
  141. package/dist/node-prod/Image.js.map +1 -1
  142. package/dist/node-prod/Image.mjs +302 -82
  143. package/dist/node-prod/Image.mjs.map +1 -1
  144. package/dist/node-prod/MediaFile.js.map +1 -1
  145. package/dist/node-prod/MediaFile.mjs.map +1 -1
  146. package/dist/node-prod/ModelViewer.js +4 -4
  147. package/dist/node-prod/ModelViewer.js.map +1 -1
  148. package/dist/node-prod/ModelViewer.mjs.map +1 -1
  149. package/dist/node-prod/Money.js.map +1 -1
  150. package/dist/node-prod/Money.mjs.map +1 -1
  151. package/dist/node-prod/ProductProvider.js +14 -14
  152. package/dist/node-prod/ProductProvider.js.map +1 -1
  153. package/dist/node-prod/ShopifyProvider.js +4 -4
  154. package/dist/node-prod/ShopifyProvider.js.map +1 -1
  155. package/dist/node-prod/Video.js +4 -4
  156. package/dist/node-prod/Video.js.map +1 -1
  157. package/dist/node-prod/Video.mjs +2 -2
  158. package/dist/node-prod/Video.mjs.map +1 -1
  159. package/dist/node-prod/analytics-utils.js.map +1 -1
  160. package/dist/node-prod/analytics-utils.mjs.map +1 -1
  161. package/dist/node-prod/cart-hooks.js +2 -2
  162. package/dist/node-prod/cart-hooks.js.map +1 -1
  163. package/dist/node-prod/index.js +3 -2
  164. package/dist/node-prod/index.js.map +1 -1
  165. package/dist/node-prod/index.mjs +4 -3
  166. package/dist/node-prod/load-script.js +3 -3
  167. package/dist/node-prod/load-script.js.map +1 -1
  168. package/dist/node-prod/node_modules/@xstate/react/es/fsm.js +6 -6
  169. package/dist/node-prod/node_modules/@xstate/react/es/fsm.js.map +1 -1
  170. package/dist/node-prod/node_modules/@xstate/react/es/useConstant.js +3 -3
  171. package/dist/node-prod/node_modules/@xstate/react/es/useConstant.js.map +1 -1
  172. package/dist/node-prod/node_modules/@xstate/react/es/useConstant.mjs +2 -2
  173. package/dist/node-prod/node_modules/@xstate/react/es/useConstant.mjs.map +1 -1
  174. package/dist/node-prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js +2 -2
  175. package/dist/node-prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js.map +1 -1
  176. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +3 -3
  177. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
  178. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +2 -2
  179. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +2 -2
  180. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -1
  181. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +2 -2
  182. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
  183. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +6 -6
  184. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
  185. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +2 -2
  186. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +2 -2
  187. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
  188. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +2 -2
  189. package/dist/node-prod/storefront-api-constants.js +1 -1
  190. package/dist/node-prod/storefront-api-constants.js.map +1 -1
  191. package/dist/node-prod/storefront-api-constants.mjs +1 -1
  192. package/dist/node-prod/storefront-api-constants.mjs.map +1 -1
  193. package/dist/node-prod/storefront-client.js.map +1 -1
  194. package/dist/node-prod/storefront-client.mjs.map +1 -1
  195. package/dist/node-prod/useCartAPIStateMachine.js +3 -3
  196. package/dist/node-prod/useCartAPIStateMachine.js.map +1 -1
  197. package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -1
  198. package/dist/node-prod/useCartActions.js +11 -11
  199. package/dist/node-prod/useCartActions.js.map +1 -1
  200. package/dist/node-prod/useCartActions.mjs.map +1 -1
  201. package/dist/node-prod/useMoney.js +5 -5
  202. package/dist/node-prod/useMoney.js.map +1 -1
  203. package/dist/node-prod/useShopifyCookies.js +2 -2
  204. package/dist/node-prod/useShopifyCookies.js.map +1 -1
  205. package/dist/types/CartProvider.d.ts +2 -2
  206. package/dist/types/Image.d.ts +173 -38
  207. package/dist/types/MediaFile.d.ts +2 -2
  208. package/dist/types/ModelViewer.d.ts +1 -1
  209. package/dist/types/Money.d.ts +1 -1
  210. package/dist/types/Video.d.ts +3 -3
  211. package/dist/types/analytics-types.d.ts +1 -1
  212. package/dist/types/analytics-utils.d.ts +2 -2
  213. package/dist/types/index.d.cts +3 -2
  214. package/dist/types/index.d.ts +3 -2
  215. package/dist/types/storefront-api-constants.d.ts +1 -1
  216. package/dist/types/storefront-api-types.d.ts +862 -118
  217. package/dist/types/storefront-client.d.ts +1 -1
  218. package/dist/types/useCartAPIStateMachine.d.ts +2 -2
  219. package/dist/types/useCartActions.d.ts +2 -2
  220. package/dist/umd/hydrogen-react.dev.js +332 -179
  221. package/dist/umd/hydrogen-react.dev.js.map +1 -1
  222. package/dist/umd/hydrogen-react.prod.js +22 -15
  223. package/dist/umd/hydrogen-react.prod.js.map +1 -1
  224. package/package.json +1 -1
  225. package/storefront.schema.json +1 -1
  226. package/dist/browser-dev/CartLinePrice.mjs +0 -21
  227. package/dist/browser-dev/CartLinePrice.mjs.map +0 -1
  228. package/dist/browser-dev/image-size.mjs +0 -80
  229. package/dist/browser-dev/image-size.mjs.map +0 -1
  230. package/dist/browser-prod/CartLinePrice.mjs +0 -18
  231. package/dist/browser-prod/CartLinePrice.mjs.map +0 -1
  232. package/dist/browser-prod/image-size.mjs +0 -80
  233. package/dist/browser-prod/image-size.mjs.map +0 -1
  234. package/dist/node-dev/CartLinePrice.js +0 -21
  235. package/dist/node-dev/CartLinePrice.js.map +0 -1
  236. package/dist/node-dev/CartLinePrice.mjs +0 -21
  237. package/dist/node-dev/CartLinePrice.mjs.map +0 -1
  238. package/dist/node-dev/image-size.js +0 -80
  239. package/dist/node-dev/image-size.js.map +0 -1
  240. package/dist/node-dev/image-size.mjs +0 -80
  241. package/dist/node-dev/image-size.mjs.map +0 -1
  242. package/dist/node-prod/CartLinePrice.js +0 -18
  243. package/dist/node-prod/CartLinePrice.js.map +0 -1
  244. package/dist/node-prod/CartLinePrice.mjs +0 -18
  245. package/dist/node-prod/CartLinePrice.mjs.map +0 -1
  246. package/dist/node-prod/image-size.js +0 -80
  247. package/dist/node-prod/image-size.js.map +0 -1
  248. package/dist/node-prod/image-size.mjs +0 -80
  249. package/dist/node-prod/image-size.mjs.map +0 -1
  250. package/dist/types/CartLinePrice.d.ts +0 -31
  251. package/dist/types/image-size.d.ts +0 -36
@@ -1,106 +1,343 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
- const imageSize = require("./image-size.js");
5
- function Image({
6
- data,
7
- width,
8
- height,
9
- loading,
10
- loader = imageSize.shopifyImageLoader,
11
- loaderOptions,
12
- widths,
13
- decoding = "async",
14
- ...rest
15
- }) {
16
- if (!data.url) {
17
- const missingUrlError = `<Image/>: the 'data' prop requires the 'url' property. Image: ${data.id ?? "no ID provided"}`;
18
- {
19
- console.error(missingUrlError);
4
+ const React = require("react");
5
+ function _interopNamespaceDefault(e) {
6
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
7
+ if (e) {
8
+ for (const k in e) {
9
+ if (k !== "default") {
10
+ const d = Object.getOwnPropertyDescriptor(e, k);
11
+ Object.defineProperty(n, k, d.get ? d : {
12
+ enumerable: true,
13
+ get: () => e[k]
14
+ });
15
+ }
20
16
  }
21
- return null;
22
17
  }
23
- const { width: imgElementWidth, height: imgElementHeight } = imageSize.getShopifyImageDimensions({
18
+ n.default = e;
19
+ return Object.freeze(n);
20
+ }
21
+ const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
22
+ const IMAGE_FRAGMENT = `#graphql
23
+ fragment Image on Image {
24
+ altText
25
+ url
26
+ width
27
+ height
28
+ }
29
+ `;
30
+ const Image = React__namespace.forwardRef(
31
+ ({
32
+ alt,
33
+ aspectRatio,
34
+ crop = "center",
24
35
  data,
36
+ decoding = "async",
37
+ height = "auto",
38
+ loader = shopifyLoader,
25
39
  loaderOptions,
26
- elementProps: {
40
+ loading = "lazy",
41
+ sizes,
42
+ src,
43
+ srcSetOptions = {
44
+ intervals: 15,
45
+ startingWidth: 200,
46
+ incrementSize: 200,
47
+ placeholderWidth: 100
48
+ },
49
+ width = "100%",
50
+ widths,
51
+ ...passthroughProps
52
+ }, ref) => {
53
+ const normalizedData = React__namespace.useMemo(() => {
54
+ const dataWidth = (data == null ? void 0 : data.width) && (data == null ? void 0 : data.height) ? data == null ? void 0 : data.width : void 0;
55
+ const dataHeight = (data == null ? void 0 : data.width) && (data == null ? void 0 : data.height) ? data == null ? void 0 : data.height : void 0;
56
+ return {
57
+ width: dataWidth,
58
+ height: dataHeight,
59
+ unitsMatch: Boolean(unitsMatch(dataWidth, dataHeight))
60
+ };
61
+ }, [data]);
62
+ const normalizedProps = React__namespace.useMemo(() => {
63
+ const nWidthProp = width || "100%";
64
+ const widthParts = getUnitValueParts(nWidthProp.toString());
65
+ const nWidth = `${widthParts.number}${widthParts.unit}`;
66
+ const autoHeight = height === void 0 || height === null;
67
+ const heightParts = autoHeight ? null : getUnitValueParts(height.toString());
68
+ const fixedHeight = heightParts ? `${heightParts.number}${heightParts.unit}` : "";
69
+ const nHeight = autoHeight ? "auto" : fixedHeight;
70
+ const nSrc = src || (data == null ? void 0 : data.url);
71
+ const nAlt = (data == null ? void 0 : data.altText) && !alt ? data == null ? void 0 : data.altText : alt || "";
72
+ const nAspectRatio = aspectRatio ? aspectRatio : normalizedData.unitsMatch ? [
73
+ getNormalizedFixedUnit(normalizedData.width),
74
+ getNormalizedFixedUnit(normalizedData.height)
75
+ ].join("/") : void 0;
76
+ return {
77
+ width: nWidth,
78
+ height: nHeight,
79
+ src: nSrc,
80
+ alt: nAlt,
81
+ aspectRatio: nAspectRatio
82
+ };
83
+ }, [
27
84
  width,
28
- height
29
- }
30
- });
31
- let finalSrc = data.url;
32
- if (loader) {
33
- finalSrc = loader({
34
- ...loaderOptions,
35
- src: data.url,
36
- width: imgElementWidth,
37
- height: imgElementHeight
38
- });
39
- if (typeof finalSrc !== "string" || !finalSrc) {
40
- throw new Error(
41
- `<Image/>: 'loader' did not return a valid string. Image: ${data.id ?? data.url}`
85
+ height,
86
+ src,
87
+ data,
88
+ alt,
89
+ aspectRatio,
90
+ normalizedData,
91
+ passthroughProps == null ? void 0 : passthroughProps.key
92
+ ]);
93
+ const { intervals, startingWidth, incrementSize, placeholderWidth } = srcSetOptions;
94
+ const imageWidths = React__namespace.useMemo(() => {
95
+ return generateImageWidths(
96
+ width,
97
+ intervals,
98
+ startingWidth,
99
+ incrementSize
100
+ );
101
+ }, [width, intervals, startingWidth, incrementSize]);
102
+ const fixedWidth = isFixedWidth(normalizedProps.width);
103
+ if (fixedWidth) {
104
+ return /* @__PURE__ */ jsxRuntime.jsx(
105
+ FixedWidthImage,
106
+ {
107
+ aspectRatio,
108
+ crop,
109
+ decoding,
110
+ height,
111
+ imageWidths,
112
+ loader,
113
+ loading,
114
+ normalizedProps,
115
+ passthroughProps,
116
+ ref,
117
+ width
118
+ }
119
+ );
120
+ } else {
121
+ return /* @__PURE__ */ jsxRuntime.jsx(
122
+ FluidImage,
123
+ {
124
+ aspectRatio,
125
+ crop,
126
+ decoding,
127
+ imageWidths,
128
+ loader,
129
+ loading,
130
+ normalizedProps,
131
+ passthroughProps,
132
+ placeholderWidth,
133
+ ref,
134
+ sizes
135
+ }
42
136
  );
43
137
  }
44
138
  }
45
- const maxWidth = width && imgElementWidth && width < imgElementWidth ? width : imgElementWidth;
46
- const finalSrcset = rest.srcSet ?? internalImageSrcSet({
47
- ...loaderOptions,
48
- widths,
49
- src: data.url,
50
- width: maxWidth,
51
- height: imgElementHeight,
52
- loader
53
- });
139
+ );
140
+ function FixedWidthImage({
141
+ aspectRatio,
142
+ crop,
143
+ decoding,
144
+ height,
145
+ imageWidths,
146
+ loader = shopifyLoader,
147
+ loading,
148
+ normalizedProps,
149
+ passthroughProps,
150
+ ref,
151
+ width
152
+ }) {
153
+ const fixed = React__namespace.useMemo(() => {
154
+ const intWidth = getNormalizedFixedUnit(width);
155
+ const intHeight = getNormalizedFixedUnit(height);
156
+ const fixedAspectRatio = aspectRatio ? aspectRatio : unitsMatch(normalizedProps.width, normalizedProps.height) ? [intWidth, intHeight].join("/") : normalizedProps.aspectRatio ? normalizedProps.aspectRatio : void 0;
157
+ const sizesArray = imageWidths === void 0 ? void 0 : generateSizes(imageWidths, fixedAspectRatio, crop);
158
+ const fixedHeight = intHeight ? intHeight : fixedAspectRatio && intWidth ? intWidth * (parseAspectRatio(fixedAspectRatio) ?? 1) : void 0;
159
+ const srcSet = generateSrcSet(normalizedProps.src, sizesArray, loader);
160
+ const src = loader({
161
+ src: normalizedProps.src,
162
+ width: intWidth,
163
+ height: fixedHeight,
164
+ crop: normalizedProps.height === "auto" ? void 0 : crop
165
+ });
166
+ return {
167
+ width: intWidth,
168
+ aspectRatio: fixedAspectRatio,
169
+ height: fixedHeight,
170
+ srcSet,
171
+ src
172
+ };
173
+ }, [aspectRatio, crop, height, imageWidths, loader, normalizedProps, width]);
54
174
  return /* @__PURE__ */ jsxRuntime.jsx(
55
175
  "img",
56
176
  {
57
- id: data.id ?? "",
58
- alt: data.altText ?? rest.alt ?? "",
59
- loading: loading ?? "lazy",
60
- ...rest,
61
- src: finalSrc,
62
- width: imgElementWidth ?? void 0,
63
- height: imgElementHeight ?? void 0,
64
- srcSet: finalSrcset,
65
- decoding
177
+ ref,
178
+ alt: normalizedProps.alt,
179
+ decoding,
180
+ height: fixed.height,
181
+ loading,
182
+ src: fixed.src,
183
+ srcSet: fixed.srcSet,
184
+ width: fixed.width,
185
+ style: {
186
+ aspectRatio: fixed.aspectRatio,
187
+ ...passthroughProps.style
188
+ },
189
+ ...passthroughProps
66
190
  }
67
191
  );
68
192
  }
69
- function internalImageSrcSet({
70
- src,
71
- width,
193
+ function FluidImage({
72
194
  crop,
73
- scale,
74
- widths,
75
- loader,
76
- height
195
+ decoding,
196
+ imageWidths,
197
+ loader = shopifyLoader,
198
+ loading,
199
+ normalizedProps,
200
+ passthroughProps,
201
+ placeholderWidth,
202
+ ref,
203
+ sizes
77
204
  }) {
78
- const hasCustomWidths = widths && Array.isArray(widths);
79
- if (hasCustomWidths && widths.some((size) => isNaN(size))) {
80
- throw new Error(
81
- `<Image/>: the 'widths' must be an array of numbers. Image: ${src}`
82
- );
205
+ const fluid = React__namespace.useMemo(() => {
206
+ const sizesArray = imageWidths === void 0 ? void 0 : generateSizes(imageWidths, normalizedProps.aspectRatio, crop);
207
+ const placeholderHeight = normalizedProps.aspectRatio && placeholderWidth ? placeholderWidth * (parseAspectRatio(normalizedProps.aspectRatio) ?? 1) : void 0;
208
+ const srcSet = generateSrcSet(normalizedProps.src, sizesArray, loader);
209
+ const src = loader({
210
+ src: normalizedProps.src,
211
+ width: placeholderWidth,
212
+ height: placeholderHeight,
213
+ crop
214
+ });
215
+ return {
216
+ placeholderHeight,
217
+ srcSet,
218
+ src
219
+ };
220
+ }, [crop, imageWidths, loader, normalizedProps, placeholderWidth]);
221
+ return /* @__PURE__ */ jsxRuntime.jsx(
222
+ "img",
223
+ {
224
+ ref,
225
+ alt: normalizedProps.alt,
226
+ decoding,
227
+ height: fluid.placeholderHeight,
228
+ loading,
229
+ sizes,
230
+ src: fluid.src,
231
+ srcSet: fluid.srcSet,
232
+ width: placeholderWidth,
233
+ ...passthroughProps,
234
+ style: {
235
+ width: normalizedProps.width,
236
+ aspectRatio: normalizedProps.aspectRatio,
237
+ ...passthroughProps.style
238
+ }
239
+ }
240
+ );
241
+ }
242
+ function shopifyLoader({ src, width, height, crop }) {
243
+ if (!src) {
244
+ return "";
245
+ }
246
+ const url = new URL(src);
247
+ if (width) {
248
+ url.searchParams.append("width", Math.round(width).toString());
249
+ }
250
+ if (height) {
251
+ url.searchParams.append("height", Math.round(height).toString());
252
+ }
253
+ if (crop) {
254
+ url.searchParams.append("crop", crop);
255
+ }
256
+ return url.href;
257
+ }
258
+ function unitsMatch(width = "100%", height = "auto") {
259
+ return getUnitValueParts(width.toString()).unit === getUnitValueParts(height.toString()).unit;
260
+ }
261
+ function getUnitValueParts(value) {
262
+ const unit = value.replace(/[0-9.]/g, "");
263
+ const number = parseFloat(value.replace(unit, ""));
264
+ return {
265
+ unit: unit === "" ? number === void 0 ? "auto" : "px" : unit,
266
+ number
267
+ };
268
+ }
269
+ function getNormalizedFixedUnit(value) {
270
+ if (value === void 0) {
271
+ return;
272
+ }
273
+ const { unit, number } = getUnitValueParts(value.toString());
274
+ switch (unit) {
275
+ case "em":
276
+ return number * 16;
277
+ case "rem":
278
+ return number * 16;
279
+ case "px":
280
+ return number;
281
+ case "":
282
+ return number;
283
+ default:
284
+ return;
83
285
  }
84
- let aspectRatio = 1;
85
- if (width && height) {
86
- aspectRatio = Number(height) / Number(width);
286
+ }
287
+ function isFixedWidth(width) {
288
+ const fixedEndings = /\d(px|em|rem)$/;
289
+ return typeof width === "number" || typeof width === "string" && fixedEndings.test(width);
290
+ }
291
+ function generateSrcSet(src, sizesArray, loader = shopifyLoader) {
292
+ if (!src) {
293
+ return "";
87
294
  }
88
- let setSizes = hasCustomWidths ? widths : imageSize.IMG_SRC_SET_SIZES;
89
- if (!hasCustomWidths && width && width < imageSize.IMG_SRC_SET_SIZES[imageSize.IMG_SRC_SET_SIZES.length - 1]) {
90
- setSizes = imageSize.IMG_SRC_SET_SIZES.filter((size) => size <= width);
295
+ if ((sizesArray == null ? void 0 : sizesArray.length) === 0 || !sizesArray) {
296
+ return src;
91
297
  }
92
- const srcGenerator = loader ? loader : imageSize.addImageSizeParametersToUrl;
93
- return setSizes.map(
94
- (size) => `${srcGenerator({
298
+ return sizesArray.map(
299
+ (size, i) => `${loader({
95
300
  src,
96
- width: size,
97
- // height is not applied if there is no crop
98
- // if there is crop, then height is applied as a ratio of the original width + height aspect ratio * size
99
- height: crop ? Number(size) * aspectRatio : void 0,
100
- crop,
101
- scale
102
- })} ${size ?? ""}w`
103
- ).join(", ");
301
+ width: size.width,
302
+ height: size.height,
303
+ crop: size.crop
304
+ })} ${sizesArray.length === 3 ? `${i + 1}x` : `${size.width ?? 0}w`}`
305
+ ).join(`, `);
306
+ }
307
+ function generateImageWidths(width = "100%", intervals, startingWidth, incrementSize) {
308
+ const responsive = Array.from(
309
+ { length: intervals },
310
+ (_, i) => i * incrementSize + startingWidth
311
+ );
312
+ const fixed = Array.from(
313
+ { length: 3 },
314
+ (_, i) => (i + 1) * (getNormalizedFixedUnit(width) ?? 0)
315
+ );
316
+ return isFixedWidth(width) ? fixed : responsive;
317
+ }
318
+ function parseAspectRatio(aspectRatio) {
319
+ if (!aspectRatio)
320
+ return;
321
+ const [width, height] = aspectRatio.split("/");
322
+ return 1 / (Number(width) / Number(height));
323
+ }
324
+ function generateSizes(imageWidths, aspectRatio, crop = "center") {
325
+ if (!imageWidths)
326
+ return;
327
+ const sizes = imageWidths.map((width) => {
328
+ return {
329
+ width,
330
+ height: aspectRatio ? width * (parseAspectRatio(aspectRatio) ?? 1) : void 0,
331
+ crop
332
+ };
333
+ });
334
+ return sizes;
104
335
  }
336
+ exports.IMAGE_FRAGMENT = IMAGE_FRAGMENT;
105
337
  exports.Image = Image;
338
+ exports.generateImageWidths = generateImageWidths;
339
+ exports.generateSizes = generateSizes;
340
+ exports.generateSrcSet = generateSrcSet;
341
+ exports.parseAspectRatio = parseAspectRatio;
342
+ exports.shopifyLoader = shopifyLoader;
106
343
  //# sourceMappingURL=Image.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Image.js","sources":["../../src/Image.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getShopifyImageDimensions,\n shopifyImageLoader,\n addImageSizeParametersToUrl,\n IMG_SRC_SET_SIZES,\n} from './image-size.js';\nimport type {Image as ImageType} from './storefront-api-types.js';\nimport type {PartialDeep, Simplify} from 'type-fest';\n\ntype HtmlImageProps = React.ImgHTMLAttributes<HTMLImageElement>;\n\nexport type ShopifyLoaderOptions = {\n crop?: 'top' | 'bottom' | 'left' | 'right' | 'center';\n scale?: 2 | 3;\n width?: HtmlImageProps['width'] | ImageType['width'];\n height?: HtmlImageProps['height'] | ImageType['height'];\n};\nexport type ShopifyLoaderParams = Simplify<ShopifyLoaderOptions & ImageSrc>;\n\ntype ImageSrc = {\n src: ImageType['url'];\n};\n\nexport type ShopifyImageProps = Omit<HtmlImageProps, 'src'> &\n ShopifyImageBaseProps;\n\ntype ShopifyImageBaseProps = {\n /** An object with fields that correspond to the Storefront API's\n * [Image object](https://shopify.dev/api/storefront/reference/common-objects/image).\n * The `data` prop is required.\n */\n data: PartialDeep<ImageType, {recurseIntoArrays: true}>;\n /** A custom function that generates the image URL. Parameters passed in\n * are `ShopifyLoaderParams`\n */\n loader?: (params: ShopifyLoaderParams) => string;\n /** An object of `loader` function options. For example, if the `loader` function\n * requires a `scale` option, then the value can be a property of the\n * `loaderOptions` object (for example, `{scale: 2}`). The object shape is `ShopifyLoaderOptions`.\n */\n loaderOptions?: ShopifyLoaderOptions;\n /**\n * `src` isn't used, and should instead be passed as part of the `data` object\n */\n src?: never;\n /**\n * An array of pixel widths to overwrite the default generated srcset. For example, `[300, 600, 800]`.\n */\n widths?: (HtmlImageProps['width'] | ImageType['width'])[];\n};\n\n/**\n * The `Image` component renders an image for the Storefront API's\n * [Image object](https://shopify.dev/api/storefront/reference/common-objects/image) by using the `data` prop. You can [customize this component](https://shopify.dev/api/hydrogen/components#customizing-hydrogen-components) using passthrough props.\n *\n * An image's width and height are determined using the following priority list:\n * 1. The width and height values for the `loaderOptions` prop\n * 2. The width and height values for bare props\n * 3. The width and height values for the `data` prop\n *\n * If only one of `width` or `height` are defined, then the other will attempt to be calculated based on the image's aspect ratio,\n * provided that both `data.width` and `data.height` are available. If `data.width` and `data.height` aren't available, then the aspect ratio cannot be determined and the missing\n * value will remain as `null`\n */\nexport function Image({\n data,\n width,\n height,\n loading,\n loader = shopifyImageLoader,\n loaderOptions,\n widths,\n decoding = 'async',\n ...rest\n}: ShopifyImageProps): JSX.Element | null {\n if (!data.url) {\n const missingUrlError = `<Image/>: the 'data' prop requires the 'url' property. Image: ${\n data.id ?? 'no ID provided'\n }`;\n\n if (__HYDROGEN_DEV__) {\n throw new Error(missingUrlError);\n } else {\n console.error(missingUrlError);\n }\n\n return null;\n }\n\n if (__HYDROGEN_DEV__ && !data.altText && !rest.alt) {\n console.warn(\n `<Image/>: the 'data' prop should have the 'altText' property, or the 'alt' prop, and one of them should not be empty. Image: ${\n data.id ?? data.url\n }`,\n );\n }\n\n const {width: imgElementWidth, height: imgElementHeight} =\n getShopifyImageDimensions({\n data,\n loaderOptions,\n elementProps: {\n width,\n height,\n },\n });\n\n if (__HYDROGEN_DEV__ && (!imgElementWidth || !imgElementHeight)) {\n console.warn(\n `<Image/>: the 'data' prop requires either 'width' or 'data.width', and 'height' or 'data.height' properties. Image: ${\n data.id ?? data.url\n }`,\n );\n }\n\n let finalSrc = data.url;\n\n if (loader) {\n finalSrc = loader({\n ...loaderOptions,\n src: data.url,\n width: imgElementWidth,\n height: imgElementHeight,\n });\n if (typeof finalSrc !== 'string' || !finalSrc) {\n throw new Error(\n `<Image/>: 'loader' did not return a valid string. Image: ${\n data.id ?? data.url\n }`,\n );\n }\n }\n\n // determining what the intended width of the image is. For example, if the width is specified and lower than the image width, then that is the maximum image width\n // to prevent generating a srcset with widths bigger than needed or to generate images that would distort because of being larger than original\n const maxWidth =\n width && imgElementWidth && width < imgElementWidth\n ? width\n : imgElementWidth;\n const finalSrcset =\n rest.srcSet ??\n internalImageSrcSet({\n ...loaderOptions,\n widths,\n src: data.url,\n width: maxWidth,\n height: imgElementHeight,\n loader,\n });\n\n /* eslint-disable hydrogen/prefer-image-component */\n return (\n <img\n id={data.id ?? ''}\n alt={data.altText ?? rest.alt ?? ''}\n loading={loading ?? 'lazy'}\n {...rest}\n src={finalSrc}\n width={imgElementWidth ?? undefined}\n height={imgElementHeight ?? undefined}\n srcSet={finalSrcset}\n decoding={decoding}\n />\n );\n /* eslint-enable hydrogen/prefer-image-component */\n}\n\ntype InternalShopifySrcSetGeneratorsParams = Simplify<\n ShopifyLoaderOptions & {\n src: ImageType['url'];\n widths?: (HtmlImageProps['width'] | ImageType['width'])[];\n loader?: (params: ShopifyLoaderParams) => string;\n }\n>;\nfunction internalImageSrcSet({\n src,\n width,\n crop,\n scale,\n widths,\n loader,\n height,\n}: InternalShopifySrcSetGeneratorsParams): string {\n const hasCustomWidths = widths && Array.isArray(widths);\n if (hasCustomWidths && widths.some((size) => isNaN(size as number))) {\n throw new Error(\n `<Image/>: the 'widths' must be an array of numbers. Image: ${src}`,\n );\n }\n\n let aspectRatio = 1;\n if (width && height) {\n aspectRatio = Number(height) / Number(width);\n }\n\n let setSizes = hasCustomWidths ? widths : IMG_SRC_SET_SIZES;\n if (\n !hasCustomWidths &&\n width &&\n width < IMG_SRC_SET_SIZES[IMG_SRC_SET_SIZES.length - 1]\n ) {\n setSizes = IMG_SRC_SET_SIZES.filter((size) => size <= width);\n }\n const srcGenerator = loader ? loader : addImageSizeParametersToUrl;\n return setSizes\n .map(\n (size) =>\n `${srcGenerator({\n src,\n width: size,\n // height is not applied if there is no crop\n // if there is crop, then height is applied as a ratio of the original width + height aspect ratio * size\n height: crop ? Number(size) * aspectRatio : undefined,\n crop,\n scale,\n })} ${size ?? ''}w`,\n )\n .join(', ');\n}\n"],"names":["shopifyImageLoader","getShopifyImageDimensions","jsx","IMG_SRC_SET_SIZES","addImageSizeParametersToUrl"],"mappings":";;;;AAiEO,SAAS,MAAM;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAASA,UAAA;AA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;AACF,GAAkD;AAChD,QAAM,kBAAkB,UAAU,MAAM,QAAQ,MAAM;AAClD,MAAA,mBAAmB,OAAO,KAAK,CAAC,SAAS,MAAM,IAAc,CAAC,GAAG;AACnE,UAAM,IAAI;AAAA,MACR,8DAA8D;AAAA,IAAA;AAAA,EAElE;AAEA,MAAI,cAAc;AAClB,MAAI,SAAS,QAAQ;AACnB,kBAAc,OAAO,MAAM,IAAI,OAAO,KAAK;AAAA,EAC7C;AAEI,MAAA,WAAW,kBAAkB,SAASC;AAExC,MAAA,CAAC,mBACD,SACA,QAAQA,4BAAkBA,4BAAkB,SAAS,CAAC,GACtD;AACA,eAAWA,UAAkB,kBAAA,OAAO,CAAC,SAAS,QAAQ,KAAK;AAAA,EAC7D;AACM,QAAA,eAAe,SAAS,SAASC;AACvC,SAAO,SACJ;AAAA,IACC,CAAC,SACC,GAAG,aAAa;AAAA,MACd;AAAA,MACA,OAAO;AAAA;AAAA;AAAA,MAGP,QAAQ,OAAO,OAAO,IAAI,IAAI,cAAc;AAAA,MAC5C;AAAA,MACA;AAAA,IACD,CAAA,KAAK,QAAQ;AAAA,EAAA,EAEjB,KAAK,IAAI;AACd;;"}
1
+ {"version":3,"file":"Image.js","sources":["../../src/Image.tsx"],"sourcesContent":["/* eslint-disable eslint-comments/disable-enable-pair */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\n/* eslint-disable hydrogen/prefer-image-component */\nimport * as React from 'react';\nimport type {PartialDeep} from 'type-fest';\nimport type {Image as ImageType} from './storefront-api-types.js';\n\n/*\n * An optional prop you can use to change the\n * default srcSet generation behaviour\n */\ntype SrcSetOptions = {\n intervals: number;\n startingWidth: number;\n incrementSize: number;\n placeholderWidth: number;\n};\n\ntype HtmlImageProps = React.DetailedHTMLProps<\n React.ImgHTMLAttributes<HTMLImageElement>,\n HTMLImageElement\n>;\n\ntype NormalizedProps = {\n alt: string;\n aspectRatio: string | undefined;\n height: string;\n src: string | undefined;\n width: string;\n};\n\nexport type LoaderParams = {\n /** The base URL of the image */\n src?: ImageType['url'];\n /** The URL param that controls width */\n width?: number;\n /** The URL param that controls height */\n height?: number;\n /** The URL param that controls the cropping region */\n crop?: Crop;\n};\n\nexport type Loader = (params: LoaderParams) => string;\n\n/** Legacy type for backwards compatibility *\n * @deprecated Use `crop`, `width`, `height`, and `src` props, and/or `data` prop. Or pass a custom `loader` with `LoaderParams` */\nexport type ShopifyLoaderOptions = {\n /** The base URL of the image */\n src?: ImageType['url'];\n /** The URL param that controls width */\n width?: HtmlImageProps['width'] | ImageType['width'];\n /** The URL param that controls height */\n height?: HtmlImageProps['height'] | ImageType['height'];\n /** The URL param that controls the cropping region */\n crop?: Crop;\n};\n\n/*\n * @TODO: Expand to include focal point support; and/or switch this to be an SF API type\n */\ntype Crop = 'center' | 'top' | 'bottom' | 'left' | 'right';\n\nexport type HydrogenImageProps = React.ComponentPropsWithRef<'img'> &\n HydrogenImageBaseProps;\n\ntype HydrogenImageBaseProps = {\n /** The aspect ratio of the image, in the format of `width/height`.\n *\n * @example\n * ```\n * <Image data={productImage} aspectRatio=\"4/5\" />\n * ```\n */\n aspectRatio?: string;\n /** The crop position of the image.\n *\n * @remarks\n * In the event that AspectRatio is set, without specifying a crop,\n * the Shopify CDN won't return the expected image.\n *\n * @defaultValue `center`\n */\n crop?: Crop;\n /** Data mapping to the [Storefront API `Image`](https://shopify.dev/docs/api/storefront/2023-04/objects/Image) object. Must be an Image object.\n *\n * @example\n * ```\n * import {IMAGE_FRAGMENT, Image} from '@shopify/hydrogen';\n *\n * export const IMAGE_QUERY = `#graphql\n * ${IMAGE_FRAGMENT}\n * query {\n * product {\n * featuredImage {\n * ...Image\n * }\n * }\n * }`\n *\n * <Image\n * data={productImage}\n * sizes=\"(min-width: 45em) 50vw, 100vw\"\n * aspectRatio=\"4/5\"\n * />\n * ```\n *\n * Image: {@link https://shopify.dev/api/storefront/reference/common-objects/image}\n */\n data?: PartialDeep<ImageType, {recurseIntoArrays: true}>;\n /** A function that returns a URL string for an image.\n *\n * @remarks\n * By default, this uses Shopify’s CDN {@link https://cdn.shopify.com/} but you can provide\n * your own function to use a another provider, as long as they support URL based image transformations.\n */\n loader?: Loader;\n /** An optional prop you can use to change the default srcSet generation behaviour */\n srcSetOptions?: SrcSetOptions;\n /** @deprecated Use `crop`, `width`, `height`, and `src` props, and/or `data` prop */\n loaderOptions?: ShopifyLoaderOptions;\n /** @deprecated Autocalculated, use only `width` prop, or srcSetOptions */\n widths?: (HtmlImageProps['width'] | ImageType['width'])[];\n};\n\n/**\n * A Storefront API GraphQL fragment that can be used to query for an image.\n */\nexport const IMAGE_FRAGMENT = `#graphql\n fragment Image on Image {\n altText\n url\n width\n height\n }\n`;\n\n/**\n * Hydrgen’s Image component is a wrapper around the HTML image element.\n * It supports the same props as the HTML `img` element, but automatically\n * generates the srcSet and sizes attributes for you. For most use cases,\n * you’ll want to set the `aspectRatio` prop to ensure the image is sized\n * correctly.\n *\n * @remarks\n * - `decoding` is set to `async` by default.\n * - `loading` is set to `lazy` by default.\n * - `alt` will automatically be set to the `altText` from the Storefront API if passed in the `data` prop\n * - `src` will automatically be set to the `url` from the Storefront API if passed in the `data` prop\n *\n * @example\n * A responsive image with a 4:5 aspect ratio:\n * ```\n * <Image\n * data={product.featuredImage}\n * aspectRatio=\"4/5\"\n * sizes=\"(min-width: 45em) 40vw, 100vw\"\n * />\n * ```\n * @example\n * A fixed size image:\n * ```\n * <Image\n * data={product.featuredImage}\n * width={100}\n * height={100}\n * />\n * ```\n *\n * {@link https://shopify.dev/docs/api/hydrogen-react/components/image}\n */\nexport const Image = React.forwardRef<HTMLImageElement, HydrogenImageProps>(\n (\n {\n alt,\n aspectRatio,\n crop = 'center',\n data,\n decoding = 'async',\n height = 'auto',\n loader = shopifyLoader,\n loaderOptions,\n loading = 'lazy',\n sizes,\n src,\n srcSetOptions = {\n intervals: 15,\n startingWidth: 200,\n incrementSize: 200,\n placeholderWidth: 100,\n },\n width = '100%',\n widths,\n ...passthroughProps\n },\n ref,\n ) => {\n /*\n * Deprecated Props from original Image component\n */\n if (__HYDROGEN_DEV__) {\n if (loaderOptions) {\n console.warn(\n [\n `Deprecated property from original Image component in use:`,\n `Use the \\`crop\\`, \\`width\\`, \\`height\\`, and src props, or`,\n `the \\`data\\` prop to achieve the same result. Image used is ${\n src || data?.url || passthroughProps?.key || 'unknown'\n }`,\n ].join(' '),\n );\n }\n\n if (widths) {\n console.warn(\n [\n `Deprecated property from original Image component in use:`,\n `\\`widths\\` are now calculated automatically based on the`,\n `config and width props. Image used is ${\n src || data?.url || passthroughProps?.key || 'unknown'\n }`,\n ].join(' '),\n );\n }\n }\n\n /*\n * Gets normalized values for width, height from data prop\n */\n const normalizedData = React.useMemo(() => {\n /* Only use data width if height is also set */\n const dataWidth: number | undefined =\n data?.width && data?.height ? data?.width : undefined;\n\n const dataHeight: number | undefined =\n data?.width && data?.height ? data?.height : undefined;\n\n return {\n width: dataWidth,\n height: dataHeight,\n unitsMatch: Boolean(unitsMatch(dataWidth, dataHeight)),\n };\n }, [data]);\n\n /*\n * Gets normalized values for width, height, src, alt, and aspectRatio props\n * supporting the presence of `data` in addition to flat props.\n */\n const normalizedProps = React.useMemo(() => {\n const nWidthProp: string | number = width || '100%';\n const widthParts = getUnitValueParts(nWidthProp.toString());\n const nWidth = `${widthParts.number}${widthParts.unit}`;\n\n const autoHeight = height === undefined || height === null;\n const heightParts = autoHeight\n ? null\n : getUnitValueParts(height.toString());\n\n const fixedHeight = heightParts\n ? `${heightParts.number}${heightParts.unit}`\n : '';\n\n const nHeight = autoHeight ? 'auto' : fixedHeight;\n\n const nSrc: string | undefined = src || data?.url;\n\n if (__HYDROGEN_DEV__ && !nSrc) {\n console.warn(\n `No src or data.url provided to Image component.`,\n passthroughProps?.key || '',\n );\n }\n\n const nAlt: string = data?.altText && !alt ? data?.altText : alt || '';\n\n const nAspectRatio: string | undefined = aspectRatio\n ? aspectRatio\n : normalizedData.unitsMatch\n ? [\n getNormalizedFixedUnit(normalizedData.width),\n getNormalizedFixedUnit(normalizedData.height),\n ].join('/')\n : undefined;\n\n return {\n width: nWidth,\n height: nHeight,\n src: nSrc,\n alt: nAlt,\n aspectRatio: nAspectRatio,\n };\n }, [\n width,\n height,\n src,\n data,\n alt,\n aspectRatio,\n normalizedData,\n passthroughProps?.key,\n ]);\n\n const {intervals, startingWidth, incrementSize, placeholderWidth} =\n srcSetOptions;\n\n /*\n * This function creates an array of widths to be used in srcSet\n */\n const imageWidths = React.useMemo(() => {\n return generateImageWidths(\n width,\n intervals,\n startingWidth,\n incrementSize,\n );\n }, [width, intervals, startingWidth, incrementSize]);\n\n const fixedWidth = isFixedWidth(normalizedProps.width);\n\n if (__HYDROGEN_DEV__ && !sizes && !fixedWidth) {\n console.warn(\n [\n 'No sizes prop provided to Image component,',\n 'you may be loading unnecessarily large images.',\n `Image used is ${\n src || data?.url || passthroughProps?.key || 'unknown'\n }`,\n ].join(' '),\n );\n }\n\n /*\n * We check to see whether the image is fixed width or not,\n * if fixed, we still provide a srcSet, but only to account for\n * different pixel densities.\n */\n if (fixedWidth) {\n return (\n <FixedWidthImage\n aspectRatio={aspectRatio}\n crop={crop}\n decoding={decoding}\n height={height}\n imageWidths={imageWidths}\n loader={loader}\n loading={loading}\n normalizedProps={normalizedProps}\n passthroughProps={passthroughProps}\n ref={ref}\n width={width}\n />\n );\n } else {\n return (\n <FluidImage\n aspectRatio={aspectRatio}\n crop={crop}\n decoding={decoding}\n imageWidths={imageWidths}\n loader={loader}\n loading={loading}\n normalizedProps={normalizedProps}\n passthroughProps={passthroughProps}\n placeholderWidth={placeholderWidth}\n ref={ref}\n sizes={sizes}\n />\n );\n }\n },\n);\n\ntype FixedImageExludedProps =\n | 'data'\n | 'loader'\n | 'loaderOptions'\n | 'sizes'\n | 'srcSetOptions'\n | 'widths';\n\ntype FixedWidthImageProps = Omit<HydrogenImageProps, FixedImageExludedProps> & {\n loader: Loader;\n passthroughProps: React.ImgHTMLAttributes<HTMLImageElement>;\n normalizedProps: NormalizedProps;\n imageWidths: number[];\n ref: React.Ref<HTMLImageElement>;\n};\n\nfunction FixedWidthImage({\n aspectRatio,\n crop,\n decoding,\n height,\n imageWidths,\n loader = shopifyLoader,\n loading,\n normalizedProps,\n passthroughProps,\n ref,\n width,\n}: FixedWidthImageProps) {\n const fixed = React.useMemo(() => {\n const intWidth: number | undefined = getNormalizedFixedUnit(width);\n const intHeight: number | undefined = getNormalizedFixedUnit(height);\n\n /*\n * The aspect ratio for fixed width images is taken from the explicitly\n * set prop, but if that's not present, and both width and height are\n * set, we calculate the aspect ratio from the width and height—as\n * long as they share the same unit type (e.g. both are 'px').\n */\n const fixedAspectRatio = aspectRatio\n ? aspectRatio\n : unitsMatch(normalizedProps.width, normalizedProps.height)\n ? [intWidth, intHeight].join('/')\n : normalizedProps.aspectRatio\n ? normalizedProps.aspectRatio\n : undefined;\n\n /*\n * The Sizes Array generates an array of all of the parts\n * that make up the srcSet, including the width, height, and crop\n */\n const sizesArray =\n imageWidths === undefined\n ? undefined\n : generateSizes(imageWidths, fixedAspectRatio, crop);\n\n const fixedHeight = intHeight\n ? intHeight\n : fixedAspectRatio && intWidth\n ? intWidth * (parseAspectRatio(fixedAspectRatio) ?? 1)\n : undefined;\n\n const srcSet = generateSrcSet(normalizedProps.src, sizesArray, loader);\n const src = loader({\n src: normalizedProps.src,\n width: intWidth,\n height: fixedHeight,\n crop: normalizedProps.height === 'auto' ? undefined : crop,\n });\n\n return {\n width: intWidth,\n aspectRatio: fixedAspectRatio,\n height: fixedHeight,\n srcSet,\n src,\n };\n }, [aspectRatio, crop, height, imageWidths, loader, normalizedProps, width]);\n\n return (\n <img\n ref={ref}\n alt={normalizedProps.alt}\n decoding={decoding}\n height={fixed.height}\n loading={loading}\n src={fixed.src}\n srcSet={fixed.srcSet}\n width={fixed.width}\n style={{\n aspectRatio: fixed.aspectRatio,\n ...passthroughProps.style,\n }}\n {...passthroughProps}\n />\n );\n}\n\ntype FluidImageExcludedProps =\n | 'data'\n | 'width'\n | 'height'\n | 'loader'\n | 'loaderOptions'\n | 'srcSetOptions';\n\ntype FluidImageProps = Omit<HydrogenImageProps, FluidImageExcludedProps> & {\n imageWidths: number[];\n loader: Loader;\n normalizedProps: NormalizedProps;\n passthroughProps: React.ImgHTMLAttributes<HTMLImageElement>;\n placeholderWidth: number;\n ref: React.Ref<HTMLImageElement>;\n};\n\nfunction FluidImage({\n crop,\n decoding,\n imageWidths,\n loader = shopifyLoader,\n loading,\n normalizedProps,\n passthroughProps,\n placeholderWidth,\n ref,\n sizes,\n}: FluidImageProps) {\n const fluid = React.useMemo(() => {\n const sizesArray =\n imageWidths === undefined\n ? undefined\n : generateSizes(imageWidths, normalizedProps.aspectRatio, crop);\n\n const placeholderHeight =\n normalizedProps.aspectRatio && placeholderWidth\n ? placeholderWidth *\n (parseAspectRatio(normalizedProps.aspectRatio) ?? 1)\n : undefined;\n\n const srcSet = generateSrcSet(normalizedProps.src, sizesArray, loader);\n\n const src = loader({\n src: normalizedProps.src,\n width: placeholderWidth,\n height: placeholderHeight,\n crop,\n });\n\n return {\n placeholderHeight,\n srcSet,\n src,\n };\n }, [crop, imageWidths, loader, normalizedProps, placeholderWidth]);\n\n return (\n <img\n ref={ref}\n alt={normalizedProps.alt}\n decoding={decoding}\n height={fluid.placeholderHeight}\n loading={loading}\n sizes={sizes}\n src={fluid.src}\n srcSet={fluid.srcSet}\n width={placeholderWidth}\n {...passthroughProps}\n style={{\n width: normalizedProps.width,\n aspectRatio: normalizedProps.aspectRatio,\n ...passthroughProps.style,\n }}\n />\n );\n}\n\n/**\n * The shopifyLoader function is a simple utility function that takes a src, width,\n * height, and crop and returns a string that can be used as the src for an image.\n * It can be used with the Hydrogen Image component or with the next/image component.\n * (or any others that accept equivalent configuration)\n * @param src - The source URL of the image, e.g. `https://cdn.shopify.com/static/sample-images/garnished.jpeg`\n * @param width - The width of the image, e.g. `100`\n * @param height - The height of the image, e.g. `100`\n * @param crop - The crop of the image, e.g. `center`\n * @returns A Shopify image URL with the correct query parameters, e.g. `https://cdn.shopify.com/static/sample-images/garnished.jpeg?width=100&height=100&crop=center`\n *\n * @example\n * ```\n * shopifyLoader({\n * src: 'https://cdn.shopify.com/static/sample-images/garnished.jpeg',\n * width: 100,\n * height: 100,\n * crop: 'center',\n * })\n * ```\n */\nexport function shopifyLoader({src, width, height, crop}: LoaderParams) {\n if (!src) {\n return '';\n }\n\n const url = new URL(src);\n\n if (width) {\n url.searchParams.append('width', Math.round(width).toString());\n }\n\n if (height) {\n url.searchParams.append('height', Math.round(height).toString());\n }\n\n if (crop) {\n url.searchParams.append('crop', crop);\n }\n return url.href;\n}\n\n/**\n * Checks whether the width and height share the same unit type\n * @param width - The width of the image, e.g. 100% | 10px\n * @param height - The height of the image, e.g. auto | 100px\n * @returns Whether the width and height share the same unit type (boolean)\n */\nfunction unitsMatch(\n width: string | number = '100%',\n height: string | number = 'auto',\n): boolean {\n return (\n getUnitValueParts(width.toString()).unit ===\n getUnitValueParts(height.toString()).unit\n );\n}\n\n/**\n * Given a CSS size, returns the unit and number parts of the value\n * @param value - The CSS size, e.g. 100px\n * @returns The unit and number parts of the value, e.g. \\{unit: 'px', number: 100\\}\n */\nfunction getUnitValueParts(value: string): {unit: string; number: number} {\n const unit = value.replace(/[0-9.]/g, '');\n const number = parseFloat(value.replace(unit, ''));\n\n return {\n unit: unit === '' ? (number === undefined ? 'auto' : 'px') : unit,\n number,\n };\n}\n\n/**\n * Given a value, returns the width of the image as an integer in pixels\n * @param value - The width of the image, e.g. 16px | 1rem | 1em | 16\n * @returns The width of the image in pixels, e.g. 16, or undefined if the value is not a fixed unit\n */\nfunction getNormalizedFixedUnit(value?: string | number): number | undefined {\n if (value === undefined) {\n return;\n }\n\n const {unit, number} = getUnitValueParts(value.toString());\n\n switch (unit) {\n case 'em':\n return number * 16;\n case 'rem':\n return number * 16;\n case 'px':\n return number;\n case '':\n return number;\n default:\n return;\n }\n}\n\n/**\n * This function checks whether a width is fixed or not.\n * @param width - The width of the image, e.g. 100 | '100px' | '100em' | '100rem'\n * @returns Whether the width is fixed or not\n */\nfunction isFixedWidth(width: string | number): boolean {\n const fixedEndings = /\\d(px|em|rem)$/;\n return (\n typeof width === 'number' ||\n (typeof width === 'string' && fixedEndings.test(width))\n );\n}\n\n/**\n * This function generates a srcSet for Shopify images.\n * @param src - The source URL of the image, e.g. https://cdn.shopify.com/static/sample-images/garnished.jpeg\n * @param sizesArray - An array of objects containing the `width`, `height`, and `crop` of the image, e.g. [\\{width: 200, height: 200, crop: 'center'\\}, \\{width: 400, height: 400, crop: 'center'\\}]\n * @param loader - A function that takes a Shopify image URL and returns a Shopify image URL with the correct query parameters\n * @returns A srcSet for Shopify images, e.g. 'https://cdn.shopify.com/static/sample-images/garnished.jpeg?width=200&height=200&crop=center 200w, https://cdn.shopify.com/static/sample-images/garnished.jpeg?width=400&height=400&crop=center 400w'\n */\nexport function generateSrcSet(\n src?: string,\n sizesArray?: Array<{width?: number; height?: number; crop?: Crop}>,\n loader: Loader = shopifyLoader,\n): string {\n if (!src) {\n return '';\n }\n\n if (sizesArray?.length === 0 || !sizesArray) {\n return src;\n }\n\n return sizesArray\n .map(\n (size, i) =>\n `${loader({\n src,\n width: size.width,\n height: size.height,\n crop: size.crop,\n })} ${sizesArray.length === 3 ? `${i + 1}x` : `${size.width ?? 0}w`}`,\n )\n .join(`, `);\n}\n\n/**\n * This function generates an array of sizes for Shopify images, for both fixed and responsive images.\n * @param width - The CSS width of the image\n * @param intervals - The number of intervals to generate\n * @param startingWidth - The starting width of the image\n * @param incrementSize - The size of each interval\n * @returns An array of widths\n */\nexport function generateImageWidths(\n width: string | number = '100%',\n intervals: number,\n startingWidth: number,\n incrementSize: number,\n): number[] {\n const responsive = Array.from(\n {length: intervals},\n (_, i) => i * incrementSize + startingWidth,\n );\n\n const fixed = Array.from(\n {length: 3},\n (_, i) => (i + 1) * (getNormalizedFixedUnit(width) ?? 0),\n );\n\n return isFixedWidth(width) ? fixed : responsive;\n}\n\n/**\n * Simple utility function to convert an aspect ratio CSS string to a decimal, currently only supports values like `1/1`, not `0.5`, or `auto`\n * @param aspectRatio - The aspect ratio of the image, e.g. `1/1`\n * @returns The aspect ratio as a number, e.g. `0.5`\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio}\n */\nexport function parseAspectRatio(aspectRatio?: string): number | undefined {\n if (!aspectRatio) return;\n const [width, height] = aspectRatio.split('/');\n return 1 / (Number(width) / Number(height));\n}\n\n// Generate data needed for Imagery loader\nexport function generateSizes(\n imageWidths?: number[],\n aspectRatio?: string,\n crop: Crop = 'center',\n):\n | {\n width: number;\n height: number | undefined;\n crop: Crop;\n }[]\n | undefined {\n if (!imageWidths) return;\n const sizes = imageWidths.map((width: number) => {\n return {\n width,\n height: aspectRatio\n ? width * (parseAspectRatio(aspectRatio) ?? 1)\n : undefined,\n crop,\n };\n });\n return sizes;\n /*\n Given:\n ([100, 200], 1/1, 'center')\n Returns:\n [{width: 100, height: 100, crop: 'center'},\n {width: 200, height: 200, crop: 'center'}]\n */\n}\n"],"names":["React","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+HO,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2CvB,MAAM,QAAQA,iBAAM;AAAA,EACzB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA,WAAW;AAAA,IACX,SAAS;AAAA,IACT,SAAS;AAAA,IACT;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,MACd,WAAW;AAAA,MACX,eAAe;AAAA,MACf,eAAe;AAAA,MACf,kBAAkB;AAAA,IACpB;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA,GAAG;AAAA,KAEL,QACG;AAiCG,UAAA,iBAAiBA,iBAAM,QAAQ,MAAM;AAEzC,YAAM,aACJ,6BAAM,WAAS,6BAAM,UAAS,6BAAM,QAAQ;AAE9C,YAAM,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