@shopify/hydrogen-react 2023.1.7 → 2023.4.0
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.
- package/dist/browser-dev/CartProvider.mjs.map +1 -1
- package/dist/browser-dev/Image.mjs +336 -90
- package/dist/browser-dev/Image.mjs.map +1 -1
- package/dist/browser-dev/MediaFile.mjs.map +1 -1
- package/dist/browser-dev/ModelViewer.mjs.map +1 -1
- package/dist/browser-dev/Money.mjs.map +1 -1
- package/dist/browser-dev/ProductProvider.mjs +2 -2
- package/dist/browser-dev/ProductProvider.mjs.map +1 -1
- package/dist/browser-dev/Video.mjs +2 -2
- package/dist/browser-dev/Video.mjs.map +1 -1
- package/dist/browser-dev/analytics-utils.mjs +1 -1
- package/dist/browser-dev/analytics-utils.mjs.map +1 -1
- package/dist/browser-dev/index.mjs +2 -3
- package/dist/browser-dev/index.mjs.map +1 -1
- package/dist/browser-dev/node_modules/@xstate/react/es/useConstant.mjs +2 -2
- package/dist/browser-dev/node_modules/@xstate/react/es/useConstant.mjs.map +1 -1
- package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +2 -2
- package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +2 -2
- package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
- package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +2 -2
- package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +2 -2
- package/dist/browser-dev/storefront-api-constants.mjs +1 -1
- package/dist/browser-dev/storefront-api-constants.mjs.map +1 -1
- package/dist/browser-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-dev/useCartActions.mjs.map +1 -1
- package/dist/browser-prod/CartProvider.mjs.map +1 -1
- package/dist/browser-prod/Image.mjs +302 -82
- package/dist/browser-prod/Image.mjs.map +1 -1
- package/dist/browser-prod/MediaFile.mjs.map +1 -1
- package/dist/browser-prod/ModelViewer.mjs.map +1 -1
- package/dist/browser-prod/Money.mjs.map +1 -1
- package/dist/browser-prod/ProductProvider.mjs +2 -2
- package/dist/browser-prod/ProductProvider.mjs.map +1 -1
- package/dist/browser-prod/Video.mjs +2 -2
- package/dist/browser-prod/Video.mjs.map +1 -1
- package/dist/browser-prod/analytics-utils.mjs +1 -1
- package/dist/browser-prod/analytics-utils.mjs.map +1 -1
- package/dist/browser-prod/index.mjs +2 -3
- package/dist/browser-prod/index.mjs.map +1 -1
- package/dist/browser-prod/node_modules/@xstate/react/es/useConstant.mjs +2 -2
- package/dist/browser-prod/node_modules/@xstate/react/es/useConstant.mjs.map +1 -1
- package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +2 -2
- package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +2 -2
- package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
- package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +2 -2
- package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +2 -2
- package/dist/browser-prod/storefront-api-constants.mjs +1 -1
- package/dist/browser-prod/storefront-api-constants.mjs.map +1 -1
- package/dist/browser-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-prod/useCartActions.mjs.map +1 -1
- package/dist/node-dev/AddToCartButton.js +4 -4
- package/dist/node-dev/AddToCartButton.js.map +1 -1
- package/dist/node-dev/BaseButton.js +2 -2
- package/dist/node-dev/BaseButton.js.map +1 -1
- package/dist/node-dev/BuyNowButton.js +4 -4
- package/dist/node-dev/BuyNowButton.js.map +1 -1
- package/dist/node-dev/CartCheckoutButton.js +3 -3
- package/dist/node-dev/CartCheckoutButton.js.map +1 -1
- package/dist/node-dev/CartLineProvider.js +3 -3
- package/dist/node-dev/CartLineProvider.js.map +1 -1
- package/dist/node-dev/CartLineQuantityAdjustButton.js +2 -2
- package/dist/node-dev/CartLineQuantityAdjustButton.js.map +1 -1
- package/dist/node-dev/CartProvider.js +20 -20
- package/dist/node-dev/CartProvider.js.map +1 -1
- package/dist/node-dev/CartProvider.mjs.map +1 -1
- package/dist/node-dev/Image.js +350 -87
- package/dist/node-dev/Image.js.map +1 -1
- package/dist/node-dev/Image.mjs +336 -90
- package/dist/node-dev/Image.mjs.map +1 -1
- package/dist/node-dev/MediaFile.js.map +1 -1
- package/dist/node-dev/MediaFile.mjs.map +1 -1
- package/dist/node-dev/ModelViewer.js +4 -4
- package/dist/node-dev/ModelViewer.js.map +1 -1
- package/dist/node-dev/ModelViewer.mjs.map +1 -1
- package/dist/node-dev/Money.js.map +1 -1
- package/dist/node-dev/Money.mjs.map +1 -1
- package/dist/node-dev/ProductProvider.js +16 -16
- package/dist/node-dev/ProductProvider.js.map +1 -1
- package/dist/node-dev/ProductProvider.mjs +2 -2
- package/dist/node-dev/ProductProvider.mjs.map +1 -1
- package/dist/node-dev/ShopifyProvider.js +4 -4
- package/dist/node-dev/ShopifyProvider.js.map +1 -1
- package/dist/node-dev/Video.js +4 -4
- package/dist/node-dev/Video.js.map +1 -1
- package/dist/node-dev/Video.mjs +2 -2
- package/dist/node-dev/Video.mjs.map +1 -1
- package/dist/node-dev/analytics-utils.js +1 -1
- package/dist/node-dev/analytics-utils.js.map +1 -1
- package/dist/node-dev/analytics-utils.mjs +1 -1
- package/dist/node-dev/analytics-utils.mjs.map +1 -1
- package/dist/node-dev/cart-hooks.js +2 -2
- package/dist/node-dev/cart-hooks.js.map +1 -1
- package/dist/node-dev/index.js +1 -2
- package/dist/node-dev/index.js.map +1 -1
- package/dist/node-dev/index.mjs +2 -3
- package/dist/node-dev/index.mjs.map +1 -1
- package/dist/node-dev/load-script.js +3 -3
- package/dist/node-dev/load-script.js.map +1 -1
- package/dist/node-dev/node_modules/@xstate/react/es/fsm.js +6 -6
- package/dist/node-dev/node_modules/@xstate/react/es/fsm.js.map +1 -1
- package/dist/node-dev/node_modules/@xstate/react/es/useConstant.js +3 -3
- package/dist/node-dev/node_modules/@xstate/react/es/useConstant.js.map +1 -1
- package/dist/node-dev/node_modules/@xstate/react/es/useConstant.mjs +2 -2
- package/dist/node-dev/node_modules/@xstate/react/es/useConstant.mjs.map +1 -1
- package/dist/node-dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js +2 -2
- package/dist/node-dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +3 -3
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +2 -2
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +2 -2
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +2 -2
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +6 -6
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +2 -2
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +2 -2
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +2 -2
- package/dist/node-dev/storefront-api-constants.js +1 -1
- package/dist/node-dev/storefront-api-constants.js.map +1 -1
- package/dist/node-dev/storefront-api-constants.mjs +1 -1
- package/dist/node-dev/storefront-api-constants.mjs.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.js +3 -3
- package/dist/node-dev/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-dev/useCartActions.js +11 -11
- package/dist/node-dev/useCartActions.js.map +1 -1
- package/dist/node-dev/useCartActions.mjs.map +1 -1
- package/dist/node-dev/useMoney.js +5 -5
- package/dist/node-dev/useMoney.js.map +1 -1
- package/dist/node-dev/useShopifyCookies.js +2 -2
- package/dist/node-dev/useShopifyCookies.js.map +1 -1
- package/dist/node-prod/AddToCartButton.js +4 -4
- package/dist/node-prod/AddToCartButton.js.map +1 -1
- package/dist/node-prod/BaseButton.js +2 -2
- package/dist/node-prod/BaseButton.js.map +1 -1
- package/dist/node-prod/BuyNowButton.js +4 -4
- package/dist/node-prod/BuyNowButton.js.map +1 -1
- package/dist/node-prod/CartCheckoutButton.js +3 -3
- package/dist/node-prod/CartCheckoutButton.js.map +1 -1
- package/dist/node-prod/CartLineProvider.js +3 -3
- package/dist/node-prod/CartLineProvider.js.map +1 -1
- package/dist/node-prod/CartLineQuantityAdjustButton.js +2 -2
- package/dist/node-prod/CartLineQuantityAdjustButton.js.map +1 -1
- package/dist/node-prod/CartProvider.js +20 -20
- package/dist/node-prod/CartProvider.js.map +1 -1
- package/dist/node-prod/CartProvider.mjs.map +1 -1
- package/dist/node-prod/Image.js +317 -80
- package/dist/node-prod/Image.js.map +1 -1
- package/dist/node-prod/Image.mjs +302 -82
- package/dist/node-prod/Image.mjs.map +1 -1
- package/dist/node-prod/MediaFile.js.map +1 -1
- package/dist/node-prod/MediaFile.mjs.map +1 -1
- package/dist/node-prod/ModelViewer.js +4 -4
- package/dist/node-prod/ModelViewer.js.map +1 -1
- package/dist/node-prod/ModelViewer.mjs.map +1 -1
- package/dist/node-prod/Money.js.map +1 -1
- package/dist/node-prod/Money.mjs.map +1 -1
- package/dist/node-prod/ProductProvider.js +16 -16
- package/dist/node-prod/ProductProvider.js.map +1 -1
- package/dist/node-prod/ProductProvider.mjs +2 -2
- package/dist/node-prod/ProductProvider.mjs.map +1 -1
- package/dist/node-prod/ShopifyProvider.js +4 -4
- package/dist/node-prod/ShopifyProvider.js.map +1 -1
- package/dist/node-prod/Video.js +4 -4
- package/dist/node-prod/Video.js.map +1 -1
- package/dist/node-prod/Video.mjs +2 -2
- package/dist/node-prod/Video.mjs.map +1 -1
- package/dist/node-prod/analytics-utils.js +1 -1
- package/dist/node-prod/analytics-utils.js.map +1 -1
- package/dist/node-prod/analytics-utils.mjs +1 -1
- package/dist/node-prod/analytics-utils.mjs.map +1 -1
- package/dist/node-prod/cart-hooks.js +2 -2
- package/dist/node-prod/cart-hooks.js.map +1 -1
- package/dist/node-prod/index.js +1 -2
- package/dist/node-prod/index.js.map +1 -1
- package/dist/node-prod/index.mjs +2 -3
- package/dist/node-prod/index.mjs.map +1 -1
- package/dist/node-prod/load-script.js +3 -3
- package/dist/node-prod/load-script.js.map +1 -1
- package/dist/node-prod/node_modules/@xstate/react/es/fsm.js +6 -6
- package/dist/node-prod/node_modules/@xstate/react/es/fsm.js.map +1 -1
- package/dist/node-prod/node_modules/@xstate/react/es/useConstant.js +3 -3
- package/dist/node-prod/node_modules/@xstate/react/es/useConstant.js.map +1 -1
- package/dist/node-prod/node_modules/@xstate/react/es/useConstant.mjs +2 -2
- package/dist/node-prod/node_modules/@xstate/react/es/useConstant.mjs.map +1 -1
- package/dist/node-prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js +2 -2
- package/dist/node-prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +3 -3
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +2 -2
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +2 -2
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +2 -2
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +6 -6
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +2 -2
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +2 -2
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +2 -2
- package/dist/node-prod/storefront-api-constants.js +1 -1
- package/dist/node-prod/storefront-api-constants.js.map +1 -1
- package/dist/node-prod/storefront-api-constants.mjs +1 -1
- package/dist/node-prod/storefront-api-constants.mjs.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.js +3 -3
- package/dist/node-prod/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-prod/useCartActions.js +11 -11
- package/dist/node-prod/useCartActions.js.map +1 -1
- package/dist/node-prod/useCartActions.mjs.map +1 -1
- package/dist/node-prod/useMoney.js +5 -5
- package/dist/node-prod/useMoney.js.map +1 -1
- package/dist/node-prod/useShopifyCookies.js +2 -2
- package/dist/node-prod/useShopifyCookies.js.map +1 -1
- package/dist/types/CartProvider.d.ts +4 -2
- package/dist/types/Image.d.ts +235 -38
- package/dist/types/MediaFile.d.ts +2 -2
- package/dist/types/ModelViewer.d.ts +1 -1
- package/dist/types/Money.d.ts +1 -1
- package/dist/types/ProductProvider.d.ts +8 -4
- package/dist/types/Video.d.ts +3 -3
- package/dist/types/index.d.cts +1 -2
- package/dist/types/index.d.ts +1 -2
- package/dist/types/storefront-api-constants.d.ts +1 -1
- package/dist/types/storefront-api-types.d.ts +862 -118
- package/dist/types/useCartAPIStateMachine.d.ts +2 -2
- package/dist/types/useCartActions.d.ts +2 -2
- package/dist/umd/hydrogen-react.dev.js +334 -182
- package/dist/umd/hydrogen-react.dev.js.map +1 -1
- package/dist/umd/hydrogen-react.prod.js +22 -15
- package/dist/umd/hydrogen-react.prod.js.map +1 -1
- package/package.json +2 -2
- package/storefront.schema.json +1 -1
- package/dist/browser-dev/CartLinePrice.mjs +0 -21
- package/dist/browser-dev/CartLinePrice.mjs.map +0 -1
- package/dist/browser-dev/image-size.mjs +0 -80
- package/dist/browser-dev/image-size.mjs.map +0 -1
- package/dist/browser-prod/CartLinePrice.mjs +0 -18
- package/dist/browser-prod/CartLinePrice.mjs.map +0 -1
- package/dist/browser-prod/image-size.mjs +0 -80
- package/dist/browser-prod/image-size.mjs.map +0 -1
- package/dist/node-dev/CartLinePrice.js +0 -21
- package/dist/node-dev/CartLinePrice.js.map +0 -1
- package/dist/node-dev/CartLinePrice.mjs +0 -21
- package/dist/node-dev/CartLinePrice.mjs.map +0 -1
- package/dist/node-dev/image-size.js +0 -80
- package/dist/node-dev/image-size.js.map +0 -1
- package/dist/node-dev/image-size.mjs +0 -80
- package/dist/node-dev/image-size.mjs.map +0 -1
- package/dist/node-prod/CartLinePrice.js +0 -18
- package/dist/node-prod/CartLinePrice.js.map +0 -1
- package/dist/node-prod/CartLinePrice.mjs +0 -18
- package/dist/node-prod/CartLinePrice.mjs.map +0 -1
- package/dist/node-prod/image-size.js +0 -80
- package/dist/node-prod/image-size.js.map +0 -1
- package/dist/node-prod/image-size.mjs +0 -80
- package/dist/node-prod/image-size.mjs.map +0 -1
- package/dist/types/CartLinePrice.d.ts +0 -31
- package/dist/types/image-size.d.ts +0 -36
|
@@ -11,11 +11,11 @@ export declare function useCartAPIStateMachine({ numCartLines, onCartActionEntry
|
|
|
11
11
|
onCartActionOptimisticUI?: (context: CartMachineContext, event: CartMachineEvent) => Partial<CartMachineContext>;
|
|
12
12
|
/** A callback that is invoked after a Cart API completes. */
|
|
13
13
|
onCartActionComplete?: (context: CartMachineContext, event: CartMachineFetchResultEvent) => void;
|
|
14
|
-
/** An object with fields that correspond to the Storefront API's [Cart object](https://shopify.dev/api/storefront/
|
|
14
|
+
/** An object with fields that correspond to the Storefront API's [Cart object](https://shopify.dev/api/storefront/2023-04/objects/cart). */
|
|
15
15
|
data?: PartialDeep<CartType, {
|
|
16
16
|
recurseIntoArrays: true;
|
|
17
17
|
}>;
|
|
18
|
-
/** A fragment used to query the Storefront API's [Cart object](https://shopify.dev/api/storefront/
|
|
18
|
+
/** A fragment used to query the Storefront API's [Cart object](https://shopify.dev/api/storefront/2023-04/objects/cart) for all queries and mutations. A default value is used if no argument is provided. */
|
|
19
19
|
cartFragment: string;
|
|
20
20
|
/** The ISO country code for i18n. */
|
|
21
21
|
countryCode?: CountryCode;
|
|
@@ -6,12 +6,12 @@ type CartResponse = PartialDeep<CartType, {
|
|
|
6
6
|
/**
|
|
7
7
|
* The `useCartActions` hook returns helper graphql functions for Storefront Cart API
|
|
8
8
|
*
|
|
9
|
-
* See [cart API graphql mutations](https://shopify.dev/api/storefront/2023-
|
|
9
|
+
* See [cart API graphql mutations](https://shopify.dev/api/storefront/2023-04/objects/Cart)
|
|
10
10
|
*/
|
|
11
11
|
export declare function useCartActions({ numCartLines, cartFragment, countryCode, }: {
|
|
12
12
|
/** Maximum number of cart lines to fetch. Defaults to 250 cart lines. */
|
|
13
13
|
numCartLines?: number;
|
|
14
|
-
/** A fragment used to query the Storefront API's [Cart object](https://shopify.dev/api/storefront/
|
|
14
|
+
/** A fragment used to query the Storefront API's [Cart object](https://shopify.dev/api/storefront/2023-04/objects/cart) for all queries and mutations. A default value is used if no argument is provided. */
|
|
15
15
|
cartFragment: string;
|
|
16
16
|
/** The ISO country code for i18n. */
|
|
17
17
|
countryCode?: CountryCode;
|
|
@@ -804,7 +804,7 @@
|
|
|
804
804
|
}
|
|
805
805
|
`
|
|
806
806
|
);
|
|
807
|
-
const SFAPI_VERSION = "2023-
|
|
807
|
+
const SFAPI_VERSION = "2023-04";
|
|
808
808
|
function createStorefrontClient(props) {
|
|
809
809
|
const {
|
|
810
810
|
storeDomain,
|
|
@@ -2031,6 +2031,7 @@
|
|
|
2031
2031
|
}, [selectedVariant, selectedSellingPlan]);
|
|
2032
2032
|
const value = React.useMemo(
|
|
2033
2033
|
() => ({
|
|
2034
|
+
product,
|
|
2034
2035
|
variants,
|
|
2035
2036
|
variantsConnection: product.variants,
|
|
2036
2037
|
options,
|
|
@@ -2047,10 +2048,9 @@
|
|
|
2047
2048
|
sellingPlanGroupsConnection: product.sellingPlanGroups
|
|
2048
2049
|
}),
|
|
2049
2050
|
[
|
|
2051
|
+
product,
|
|
2050
2052
|
isOptionInStock,
|
|
2051
2053
|
options,
|
|
2052
|
-
product.sellingPlanGroups,
|
|
2053
|
-
product.variants,
|
|
2054
2054
|
selectedOptions,
|
|
2055
2055
|
selectedSellingPlan,
|
|
2056
2056
|
selectedSellingPlanAllocation,
|
|
@@ -2270,7 +2270,7 @@
|
|
|
2270
2270
|
if (typeof gid !== "string") {
|
|
2271
2271
|
return defaultReturn;
|
|
2272
2272
|
}
|
|
2273
|
-
const matches = gid.match(/^gid:\/\/shopify\/(\w+)\/([
|
|
2273
|
+
const matches = gid.match(/^gid:\/\/shopify\/(\w+)\/([^/]+)/);
|
|
2274
2274
|
if (!matches || matches.length === 1) {
|
|
2275
2275
|
return defaultReturn;
|
|
2276
2276
|
}
|
|
@@ -2834,21 +2834,6 @@
|
|
|
2834
2834
|
}
|
|
2835
2835
|
return /* @__PURE__ */ React.createElement(Money, { ...passthroughProps, data: amount }, children);
|
|
2836
2836
|
}
|
|
2837
|
-
function CartLinePrice(props) {
|
|
2838
|
-
var _a, _b;
|
|
2839
|
-
{
|
|
2840
|
-
console.warn(`<CartLinePrice/> is deprecated; use <Money/> instead.`);
|
|
2841
|
-
}
|
|
2842
|
-
const { data: cartLine, priceType = "regular", ...passthroughProps } = props;
|
|
2843
|
-
if (cartLine == null) {
|
|
2844
|
-
throw new Error(`<CartLinePrice/> requires a cart line as the 'data' prop`);
|
|
2845
|
-
}
|
|
2846
|
-
const moneyV2 = priceType === "regular" ? (_a = cartLine.cost) == null ? void 0 : _a.totalAmount : (_b = cartLine.cost) == null ? void 0 : _b.compareAtAmountPerQuantity;
|
|
2847
|
-
if (moneyV2 == null) {
|
|
2848
|
-
return null;
|
|
2849
|
-
}
|
|
2850
|
-
return /* @__PURE__ */ React.createElement(Money, { ...passthroughProps, data: moneyV2 });
|
|
2851
|
-
}
|
|
2852
2837
|
const CartLineContext = React.createContext(null);
|
|
2853
2838
|
function useCartLine() {
|
|
2854
2839
|
const context = React.useContext(CartLineContext);
|
|
@@ -2953,187 +2938,354 @@
|
|
|
2953
2938
|
}
|
|
2954
2939
|
);
|
|
2955
2940
|
}
|
|
2956
|
-
const
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
const LOCAL_CDN_HOSTNAMES = ["spin.dev"];
|
|
2963
|
-
const ALL_CDN_HOSTNAMES = [...PRODUCTION_CDN_HOSTNAMES, ...LOCAL_CDN_HOSTNAMES];
|
|
2964
|
-
const IMG_SRC_SET_SIZES = [352, 832, 1200, 1920, 2560];
|
|
2965
|
-
function addImageSizeParametersToUrl({
|
|
2966
|
-
src,
|
|
2967
|
-
width,
|
|
2968
|
-
height,
|
|
2969
|
-
crop,
|
|
2970
|
-
scale
|
|
2971
|
-
}) {
|
|
2972
|
-
const newUrl = new URL(src);
|
|
2973
|
-
const multipliedScale = scale ?? 1;
|
|
2974
|
-
if (width) {
|
|
2975
|
-
let finalWidth;
|
|
2976
|
-
if (typeof width === "string") {
|
|
2977
|
-
finalWidth = (IMG_SRC_SET_SIZES[0] * multipliedScale).toString();
|
|
2978
|
-
} else {
|
|
2979
|
-
finalWidth = (Number(width) * multipliedScale).toString();
|
|
2980
|
-
}
|
|
2981
|
-
newUrl.searchParams.append("width", finalWidth);
|
|
2982
|
-
}
|
|
2983
|
-
if (height && typeof height === "number") {
|
|
2984
|
-
newUrl.searchParams.append("height", (height * multipliedScale).toString());
|
|
2985
|
-
}
|
|
2986
|
-
crop && newUrl.searchParams.append("crop", crop);
|
|
2987
|
-
return newUrl.toString();
|
|
2988
|
-
}
|
|
2989
|
-
function shopifyImageLoader(params) {
|
|
2990
|
-
const newSrc = new URL(params.src);
|
|
2991
|
-
const isShopifyServedImage = ALL_CDN_HOSTNAMES.some(
|
|
2992
|
-
(allowedHostname) => newSrc.hostname.endsWith(allowedHostname)
|
|
2993
|
-
);
|
|
2994
|
-
if (!isShopifyServedImage || !params.width && !params.height && !params.crop && !params.scale) {
|
|
2995
|
-
return params.src;
|
|
2996
|
-
}
|
|
2997
|
-
return addImageSizeParametersToUrl(params);
|
|
2998
|
-
}
|
|
2999
|
-
function getShopifyImageDimensions({
|
|
3000
|
-
data: sfapiImage,
|
|
3001
|
-
loaderOptions,
|
|
3002
|
-
elementProps
|
|
3003
|
-
}) {
|
|
3004
|
-
let aspectRatio = null;
|
|
3005
|
-
if ((sfapiImage == null ? void 0 : sfapiImage.width) && (sfapiImage == null ? void 0 : sfapiImage.height)) {
|
|
3006
|
-
aspectRatio = (sfapiImage == null ? void 0 : sfapiImage.width) / (sfapiImage == null ? void 0 : sfapiImage.height);
|
|
3007
|
-
}
|
|
3008
|
-
if ((loaderOptions == null ? void 0 : loaderOptions.width) || (loaderOptions == null ? void 0 : loaderOptions.height)) {
|
|
3009
|
-
return {
|
|
3010
|
-
width: (loaderOptions == null ? void 0 : loaderOptions.width) ?? (aspectRatio && typeof loaderOptions.height === "number" ? Math.round(aspectRatio * loaderOptions.height) : null),
|
|
3011
|
-
height: (loaderOptions == null ? void 0 : loaderOptions.height) ?? (aspectRatio && typeof loaderOptions.width === "number" ? Math.round(aspectRatio * loaderOptions.width) : null)
|
|
3012
|
-
};
|
|
3013
|
-
}
|
|
3014
|
-
if ((elementProps == null ? void 0 : elementProps.width) || (elementProps == null ? void 0 : elementProps.height)) {
|
|
3015
|
-
return {
|
|
3016
|
-
width: (elementProps == null ? void 0 : elementProps.width) ?? (aspectRatio && typeof elementProps.height === "number" ? Math.round(aspectRatio * elementProps.height) : null),
|
|
3017
|
-
height: (elementProps == null ? void 0 : elementProps.height) ?? (aspectRatio && typeof elementProps.width === "number" ? Math.round(aspectRatio * elementProps.width) : null)
|
|
3018
|
-
};
|
|
3019
|
-
}
|
|
3020
|
-
if ((sfapiImage == null ? void 0 : sfapiImage.width) || (sfapiImage == null ? void 0 : sfapiImage.height)) {
|
|
3021
|
-
return {
|
|
3022
|
-
// can't calculate the aspect ratio here
|
|
3023
|
-
width: (sfapiImage == null ? void 0 : sfapiImage.width) ?? null,
|
|
3024
|
-
height: (sfapiImage == null ? void 0 : sfapiImage.height) ?? null
|
|
3025
|
-
};
|
|
3026
|
-
}
|
|
3027
|
-
return { width: null, height: null };
|
|
2941
|
+
const IMAGE_FRAGMENT = `#graphql
|
|
2942
|
+
fragment Image on Image {
|
|
2943
|
+
altText
|
|
2944
|
+
url
|
|
2945
|
+
width
|
|
2946
|
+
height
|
|
3028
2947
|
}
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
loaderOptions,
|
|
3036
|
-
widths,
|
|
3037
|
-
decoding = "async",
|
|
3038
|
-
...rest
|
|
3039
|
-
}) {
|
|
3040
|
-
if (!data.url) {
|
|
3041
|
-
const missingUrlError = `<Image/>: the 'data' prop requires the 'url' property. Image: ${data.id ?? "no ID provided"}`;
|
|
3042
|
-
{
|
|
3043
|
-
throw new Error(missingUrlError);
|
|
3044
|
-
}
|
|
3045
|
-
}
|
|
3046
|
-
if (!data.altText && !rest.alt) {
|
|
3047
|
-
console.warn(
|
|
3048
|
-
`<Image/>: the 'data' prop should have the 'altText' property, or the 'alt' prop, and one of them should not be empty. Image: ${data.id ?? data.url}`
|
|
3049
|
-
);
|
|
3050
|
-
}
|
|
3051
|
-
const { width: imgElementWidth, height: imgElementHeight } = getShopifyImageDimensions({
|
|
2948
|
+
`;
|
|
2949
|
+
const Image = React__namespace.forwardRef(
|
|
2950
|
+
({
|
|
2951
|
+
alt,
|
|
2952
|
+
aspectRatio,
|
|
2953
|
+
crop = "center",
|
|
3052
2954
|
data,
|
|
2955
|
+
decoding = "async",
|
|
2956
|
+
height = "auto",
|
|
2957
|
+
loader = shopifyLoader,
|
|
3053
2958
|
loaderOptions,
|
|
3054
|
-
|
|
2959
|
+
loading = "lazy",
|
|
2960
|
+
sizes,
|
|
2961
|
+
src,
|
|
2962
|
+
srcSetOptions = {
|
|
2963
|
+
intervals: 15,
|
|
2964
|
+
startingWidth: 200,
|
|
2965
|
+
incrementSize: 200,
|
|
2966
|
+
placeholderWidth: 100
|
|
2967
|
+
},
|
|
2968
|
+
width = "100%",
|
|
2969
|
+
widths,
|
|
2970
|
+
...passthroughProps
|
|
2971
|
+
}, ref) => {
|
|
2972
|
+
{
|
|
2973
|
+
if (loaderOptions) {
|
|
2974
|
+
console.warn(
|
|
2975
|
+
[
|
|
2976
|
+
`Deprecated property from original Image component in use:`,
|
|
2977
|
+
`Use the \`crop\`, \`width\`, \`height\`, and src props, or`,
|
|
2978
|
+
`the \`data\` prop to achieve the same result. Image used is ${src || (data == null ? void 0 : data.url) || (passthroughProps == null ? void 0 : passthroughProps.key) || "unknown"}`
|
|
2979
|
+
].join(" ")
|
|
2980
|
+
);
|
|
2981
|
+
}
|
|
2982
|
+
if (widths) {
|
|
2983
|
+
console.warn(
|
|
2984
|
+
[
|
|
2985
|
+
`Deprecated property from original Image component in use:`,
|
|
2986
|
+
`\`widths\` are now calculated automatically based on the`,
|
|
2987
|
+
`config and width props. Image used is ${src || (data == null ? void 0 : data.url) || (passthroughProps == null ? void 0 : passthroughProps.key) || "unknown"}`
|
|
2988
|
+
].join(" ")
|
|
2989
|
+
);
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
const normalizedData = React__namespace.useMemo(() => {
|
|
2993
|
+
const dataWidth = (data == null ? void 0 : data.width) && (data == null ? void 0 : data.height) ? data == null ? void 0 : data.width : void 0;
|
|
2994
|
+
const dataHeight = (data == null ? void 0 : data.width) && (data == null ? void 0 : data.height) ? data == null ? void 0 : data.height : void 0;
|
|
2995
|
+
return {
|
|
2996
|
+
width: dataWidth,
|
|
2997
|
+
height: dataHeight,
|
|
2998
|
+
unitsMatch: Boolean(unitsMatch(dataWidth, dataHeight))
|
|
2999
|
+
};
|
|
3000
|
+
}, [data]);
|
|
3001
|
+
const normalizedProps = React__namespace.useMemo(() => {
|
|
3002
|
+
const nWidthProp = width || "100%";
|
|
3003
|
+
const widthParts = getUnitValueParts(nWidthProp.toString());
|
|
3004
|
+
const nWidth = `${widthParts.number}${widthParts.unit}`;
|
|
3005
|
+
const autoHeight = height === void 0 || height === null;
|
|
3006
|
+
const heightParts = autoHeight ? null : getUnitValueParts(height.toString());
|
|
3007
|
+
const fixedHeight = heightParts ? `${heightParts.number}${heightParts.unit}` : "";
|
|
3008
|
+
const nHeight = autoHeight ? "auto" : fixedHeight;
|
|
3009
|
+
const nSrc = src || (data == null ? void 0 : data.url);
|
|
3010
|
+
if (!nSrc) {
|
|
3011
|
+
console.warn(
|
|
3012
|
+
`No src or data.url provided to Image component.`,
|
|
3013
|
+
(passthroughProps == null ? void 0 : passthroughProps.key) || ""
|
|
3014
|
+
);
|
|
3015
|
+
}
|
|
3016
|
+
const nAlt = (data == null ? void 0 : data.altText) && !alt ? data == null ? void 0 : data.altText : alt || "";
|
|
3017
|
+
const nAspectRatio = aspectRatio ? aspectRatio : normalizedData.unitsMatch ? [
|
|
3018
|
+
getNormalizedFixedUnit(normalizedData.width),
|
|
3019
|
+
getNormalizedFixedUnit(normalizedData.height)
|
|
3020
|
+
].join("/") : void 0;
|
|
3021
|
+
return {
|
|
3022
|
+
width: nWidth,
|
|
3023
|
+
height: nHeight,
|
|
3024
|
+
src: nSrc,
|
|
3025
|
+
alt: nAlt,
|
|
3026
|
+
aspectRatio: nAspectRatio
|
|
3027
|
+
};
|
|
3028
|
+
}, [
|
|
3055
3029
|
width,
|
|
3056
|
-
height
|
|
3030
|
+
height,
|
|
3031
|
+
src,
|
|
3032
|
+
data,
|
|
3033
|
+
alt,
|
|
3034
|
+
aspectRatio,
|
|
3035
|
+
normalizedData,
|
|
3036
|
+
passthroughProps == null ? void 0 : passthroughProps.key
|
|
3037
|
+
]);
|
|
3038
|
+
const { intervals, startingWidth, incrementSize, placeholderWidth } = srcSetOptions;
|
|
3039
|
+
const imageWidths = React__namespace.useMemo(() => {
|
|
3040
|
+
return generateImageWidths(
|
|
3041
|
+
width,
|
|
3042
|
+
intervals,
|
|
3043
|
+
startingWidth,
|
|
3044
|
+
incrementSize
|
|
3045
|
+
);
|
|
3046
|
+
}, [width, intervals, startingWidth, incrementSize]);
|
|
3047
|
+
const fixedWidth = isFixedWidth(normalizedProps.width);
|
|
3048
|
+
if (!sizes && !fixedWidth) {
|
|
3049
|
+
console.warn(
|
|
3050
|
+
[
|
|
3051
|
+
"No sizes prop provided to Image component,",
|
|
3052
|
+
"you may be loading unnecessarily large images.",
|
|
3053
|
+
`Image used is ${src || (data == null ? void 0 : data.url) || (passthroughProps == null ? void 0 : passthroughProps.key) || "unknown"}`
|
|
3054
|
+
].join(" ")
|
|
3055
|
+
);
|
|
3057
3056
|
}
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3057
|
+
if (fixedWidth) {
|
|
3058
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
3059
|
+
FixedWidthImage,
|
|
3060
|
+
{
|
|
3061
|
+
aspectRatio,
|
|
3062
|
+
crop,
|
|
3063
|
+
decoding,
|
|
3064
|
+
height,
|
|
3065
|
+
imageWidths,
|
|
3066
|
+
loader,
|
|
3067
|
+
loading,
|
|
3068
|
+
normalizedProps,
|
|
3069
|
+
passthroughProps,
|
|
3070
|
+
ref,
|
|
3071
|
+
width
|
|
3072
|
+
}
|
|
3073
|
+
);
|
|
3074
|
+
} else {
|
|
3075
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
3076
|
+
FluidImage,
|
|
3077
|
+
{
|
|
3078
|
+
aspectRatio,
|
|
3079
|
+
crop,
|
|
3080
|
+
decoding,
|
|
3081
|
+
imageWidths,
|
|
3082
|
+
loader,
|
|
3083
|
+
loading,
|
|
3084
|
+
normalizedProps,
|
|
3085
|
+
passthroughProps,
|
|
3086
|
+
placeholderWidth,
|
|
3087
|
+
ref,
|
|
3088
|
+
sizes
|
|
3089
|
+
}
|
|
3075
3090
|
);
|
|
3076
3091
|
}
|
|
3077
3092
|
}
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3093
|
+
);
|
|
3094
|
+
function FixedWidthImage({
|
|
3095
|
+
aspectRatio,
|
|
3096
|
+
crop,
|
|
3097
|
+
decoding,
|
|
3098
|
+
height,
|
|
3099
|
+
imageWidths,
|
|
3100
|
+
loader = shopifyLoader,
|
|
3101
|
+
loading,
|
|
3102
|
+
normalizedProps,
|
|
3103
|
+
passthroughProps,
|
|
3104
|
+
ref,
|
|
3105
|
+
width
|
|
3106
|
+
}) {
|
|
3107
|
+
const fixed = React__namespace.useMemo(() => {
|
|
3108
|
+
const intWidth = getNormalizedFixedUnit(width);
|
|
3109
|
+
const intHeight = getNormalizedFixedUnit(height);
|
|
3110
|
+
const fixedAspectRatio = aspectRatio ? aspectRatio : unitsMatch(normalizedProps.width, normalizedProps.height) ? [intWidth, intHeight].join("/") : normalizedProps.aspectRatio ? normalizedProps.aspectRatio : void 0;
|
|
3111
|
+
const sizesArray = imageWidths === void 0 ? void 0 : generateSizes(imageWidths, fixedAspectRatio, crop);
|
|
3112
|
+
const fixedHeight = intHeight ? intHeight : fixedAspectRatio && intWidth ? intWidth * (parseAspectRatio(fixedAspectRatio) ?? 1) : void 0;
|
|
3113
|
+
const srcSet = generateSrcSet(normalizedProps.src, sizesArray, loader);
|
|
3114
|
+
const src = loader({
|
|
3115
|
+
src: normalizedProps.src,
|
|
3116
|
+
width: intWidth,
|
|
3117
|
+
height: fixedHeight,
|
|
3118
|
+
crop: normalizedProps.height === "auto" ? void 0 : crop
|
|
3119
|
+
});
|
|
3120
|
+
return {
|
|
3121
|
+
width: intWidth,
|
|
3122
|
+
aspectRatio: fixedAspectRatio,
|
|
3123
|
+
height: fixedHeight,
|
|
3124
|
+
srcSet,
|
|
3125
|
+
src
|
|
3126
|
+
};
|
|
3127
|
+
}, [aspectRatio, crop, height, imageWidths, loader, normalizedProps, width]);
|
|
3087
3128
|
return /* @__PURE__ */ React__namespace.createElement(
|
|
3088
3129
|
"img",
|
|
3089
3130
|
{
|
|
3090
|
-
|
|
3091
|
-
alt:
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3131
|
+
ref,
|
|
3132
|
+
alt: normalizedProps.alt,
|
|
3133
|
+
decoding,
|
|
3134
|
+
height: fixed.height,
|
|
3135
|
+
loading,
|
|
3136
|
+
src: fixed.src,
|
|
3137
|
+
srcSet: fixed.srcSet,
|
|
3138
|
+
width: fixed.width,
|
|
3139
|
+
style: {
|
|
3140
|
+
aspectRatio: fixed.aspectRatio,
|
|
3141
|
+
...passthroughProps.style
|
|
3142
|
+
},
|
|
3143
|
+
...passthroughProps
|
|
3099
3144
|
}
|
|
3100
3145
|
);
|
|
3101
3146
|
}
|
|
3102
|
-
function
|
|
3103
|
-
src,
|
|
3104
|
-
width,
|
|
3147
|
+
function FluidImage({
|
|
3105
3148
|
crop,
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
loader,
|
|
3109
|
-
|
|
3149
|
+
decoding,
|
|
3150
|
+
imageWidths,
|
|
3151
|
+
loader = shopifyLoader,
|
|
3152
|
+
loading,
|
|
3153
|
+
normalizedProps,
|
|
3154
|
+
passthroughProps,
|
|
3155
|
+
placeholderWidth,
|
|
3156
|
+
ref,
|
|
3157
|
+
sizes
|
|
3110
3158
|
}) {
|
|
3111
|
-
const
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3159
|
+
const fluid = React__namespace.useMemo(() => {
|
|
3160
|
+
const sizesArray = imageWidths === void 0 ? void 0 : generateSizes(imageWidths, normalizedProps.aspectRatio, crop);
|
|
3161
|
+
const placeholderHeight = normalizedProps.aspectRatio && placeholderWidth ? placeholderWidth * (parseAspectRatio(normalizedProps.aspectRatio) ?? 1) : void 0;
|
|
3162
|
+
const srcSet = generateSrcSet(normalizedProps.src, sizesArray, loader);
|
|
3163
|
+
const src = loader({
|
|
3164
|
+
src: normalizedProps.src,
|
|
3165
|
+
width: placeholderWidth,
|
|
3166
|
+
height: placeholderHeight,
|
|
3167
|
+
crop
|
|
3168
|
+
});
|
|
3169
|
+
return {
|
|
3170
|
+
placeholderHeight,
|
|
3171
|
+
srcSet,
|
|
3172
|
+
src
|
|
3173
|
+
};
|
|
3174
|
+
}, [crop, imageWidths, loader, normalizedProps, placeholderWidth]);
|
|
3175
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
3176
|
+
"img",
|
|
3177
|
+
{
|
|
3178
|
+
ref,
|
|
3179
|
+
alt: normalizedProps.alt,
|
|
3180
|
+
decoding,
|
|
3181
|
+
height: fluid.placeholderHeight,
|
|
3182
|
+
loading,
|
|
3183
|
+
sizes,
|
|
3184
|
+
src: fluid.src,
|
|
3185
|
+
srcSet: fluid.srcSet,
|
|
3186
|
+
width: placeholderWidth,
|
|
3187
|
+
...passthroughProps,
|
|
3188
|
+
style: {
|
|
3189
|
+
width: normalizedProps.width,
|
|
3190
|
+
aspectRatio: normalizedProps.aspectRatio,
|
|
3191
|
+
...passthroughProps.style
|
|
3192
|
+
}
|
|
3193
|
+
}
|
|
3194
|
+
);
|
|
3195
|
+
}
|
|
3196
|
+
function shopifyLoader({ src, width, height, crop }) {
|
|
3197
|
+
if (!src) {
|
|
3198
|
+
return "";
|
|
3199
|
+
}
|
|
3200
|
+
const url = new URL(src);
|
|
3201
|
+
if (width) {
|
|
3202
|
+
url.searchParams.append("width", Math.round(width).toString());
|
|
3203
|
+
}
|
|
3204
|
+
if (height) {
|
|
3205
|
+
url.searchParams.append("height", Math.round(height).toString());
|
|
3206
|
+
}
|
|
3207
|
+
if (crop) {
|
|
3208
|
+
url.searchParams.append("crop", crop);
|
|
3209
|
+
}
|
|
3210
|
+
return url.href;
|
|
3211
|
+
}
|
|
3212
|
+
function unitsMatch(width = "100%", height = "auto") {
|
|
3213
|
+
return getUnitValueParts(width.toString()).unit === getUnitValueParts(height.toString()).unit;
|
|
3214
|
+
}
|
|
3215
|
+
function getUnitValueParts(value) {
|
|
3216
|
+
const unit = value.replace(/[0-9.]/g, "");
|
|
3217
|
+
const number = parseFloat(value.replace(unit, ""));
|
|
3218
|
+
return {
|
|
3219
|
+
unit: unit === "" ? number === void 0 ? "auto" : "px" : unit,
|
|
3220
|
+
number
|
|
3221
|
+
};
|
|
3222
|
+
}
|
|
3223
|
+
function getNormalizedFixedUnit(value) {
|
|
3224
|
+
if (value === void 0) {
|
|
3225
|
+
return;
|
|
3116
3226
|
}
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3227
|
+
const { unit, number } = getUnitValueParts(value.toString());
|
|
3228
|
+
switch (unit) {
|
|
3229
|
+
case "em":
|
|
3230
|
+
return number * 16;
|
|
3231
|
+
case "rem":
|
|
3232
|
+
return number * 16;
|
|
3233
|
+
case "px":
|
|
3234
|
+
return number;
|
|
3235
|
+
case "":
|
|
3236
|
+
return number;
|
|
3237
|
+
default:
|
|
3238
|
+
return;
|
|
3120
3239
|
}
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3240
|
+
}
|
|
3241
|
+
function isFixedWidth(width) {
|
|
3242
|
+
const fixedEndings = /\d(px|em|rem)$/;
|
|
3243
|
+
return typeof width === "number" || typeof width === "string" && fixedEndings.test(width);
|
|
3244
|
+
}
|
|
3245
|
+
function generateSrcSet(src, sizesArray, loader = shopifyLoader) {
|
|
3246
|
+
if (!src) {
|
|
3247
|
+
return "";
|
|
3248
|
+
}
|
|
3249
|
+
if ((sizesArray == null ? void 0 : sizesArray.length) === 0 || !sizesArray) {
|
|
3250
|
+
return src;
|
|
3124
3251
|
}
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
(size) => `${srcGenerator({
|
|
3252
|
+
return sizesArray.map(
|
|
3253
|
+
(size, i2) => `${loader({
|
|
3128
3254
|
src,
|
|
3129
|
-
width: size,
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3255
|
+
width: size.width,
|
|
3256
|
+
height: size.height,
|
|
3257
|
+
crop: size.crop
|
|
3258
|
+
})} ${sizesArray.length === 3 ? `${i2 + 1}x` : `${size.width ?? 0}w`}`
|
|
3259
|
+
).join(`, `);
|
|
3260
|
+
}
|
|
3261
|
+
function generateImageWidths(width = "100%", intervals, startingWidth, incrementSize) {
|
|
3262
|
+
const responsive = Array.from(
|
|
3263
|
+
{ length: intervals },
|
|
3264
|
+
(_, i2) => i2 * incrementSize + startingWidth
|
|
3265
|
+
);
|
|
3266
|
+
const fixed = Array.from(
|
|
3267
|
+
{ length: 3 },
|
|
3268
|
+
(_, i2) => (i2 + 1) * (getNormalizedFixedUnit(width) ?? 0)
|
|
3269
|
+
);
|
|
3270
|
+
return isFixedWidth(width) ? fixed : responsive;
|
|
3271
|
+
}
|
|
3272
|
+
function parseAspectRatio(aspectRatio) {
|
|
3273
|
+
if (!aspectRatio)
|
|
3274
|
+
return;
|
|
3275
|
+
const [width, height] = aspectRatio.split("/");
|
|
3276
|
+
return 1 / (Number(width) / Number(height));
|
|
3277
|
+
}
|
|
3278
|
+
function generateSizes(imageWidths, aspectRatio, crop = "center") {
|
|
3279
|
+
if (!imageWidths)
|
|
3280
|
+
return;
|
|
3281
|
+
const sizes = imageWidths.map((width) => {
|
|
3282
|
+
return {
|
|
3283
|
+
width,
|
|
3284
|
+
height: aspectRatio ? width * (parseAspectRatio(aspectRatio) ?? 1) : void 0,
|
|
3285
|
+
crop
|
|
3286
|
+
};
|
|
3287
|
+
});
|
|
3288
|
+
return sizes;
|
|
3137
3289
|
}
|
|
3138
3290
|
function Video(props) {
|
|
3139
3291
|
var _a;
|
|
@@ -3146,7 +3298,7 @@
|
|
|
3146
3298
|
sourceProps = {},
|
|
3147
3299
|
...passthroughProps
|
|
3148
3300
|
} = props;
|
|
3149
|
-
const posterUrl =
|
|
3301
|
+
const posterUrl = shopifyLoader({
|
|
3150
3302
|
src: ((_a = data.previewImage) == null ? void 0 : _a.url) ?? "",
|
|
3151
3303
|
...previewImageOptions
|
|
3152
3304
|
});
|
|
@@ -3730,12 +3882,12 @@
|
|
|
3730
3882
|
exports2.BuyNowButton = BuyNowButton;
|
|
3731
3883
|
exports2.CartCheckoutButton = CartCheckoutButton;
|
|
3732
3884
|
exports2.CartCost = CartCost;
|
|
3733
|
-
exports2.CartLinePrice = CartLinePrice;
|
|
3734
3885
|
exports2.CartLineProvider = CartLineProvider;
|
|
3735
3886
|
exports2.CartLineQuantity = CartLineQuantity;
|
|
3736
3887
|
exports2.CartLineQuantityAdjustButton = CartLineQuantityAdjustButton;
|
|
3737
3888
|
exports2.CartProvider = CartProvider;
|
|
3738
3889
|
exports2.ExternalVideo = ExternalVideo;
|
|
3890
|
+
exports2.IMAGE_FRAGMENT = IMAGE_FRAGMENT;
|
|
3739
3891
|
exports2.Image = Image;
|
|
3740
3892
|
exports2.MediaFile = MediaFile;
|
|
3741
3893
|
exports2.ModelViewer = ModelViewer;
|