@shopify/hydrogen-react 2022.10.7 → 2023.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -45
- package/dist/browser-dev/AddToCartButton.mjs +43 -40
- package/dist/browser-dev/AddToCartButton.mjs.map +1 -1
- package/dist/browser-dev/BaseButton.mjs +13 -15
- package/dist/browser-dev/BaseButton.mjs.map +1 -1
- package/dist/browser-dev/BuyNowButton.mjs +19 -17
- package/dist/browser-dev/BuyNowButton.mjs.map +1 -1
- package/dist/browser-dev/CartCheckoutButton.mjs +12 -15
- package/dist/browser-dev/CartCheckoutButton.mjs.map +1 -1
- package/dist/browser-dev/CartCost.mjs +25 -0
- package/dist/browser-dev/CartCost.mjs.map +1 -0
- package/dist/browser-dev/CartLinePrice.mjs +18 -0
- package/dist/browser-dev/CartLinePrice.mjs.map +1 -0
- package/dist/browser-dev/CartLineProvider.mjs +19 -0
- package/dist/browser-dev/CartLineProvider.mjs.map +1 -0
- package/dist/browser-dev/CartProvider.mjs +73 -67
- package/dist/browser-dev/CartProvider.mjs.map +1 -1
- package/dist/browser-dev/ExternalVideo.mjs +13 -11
- package/dist/browser-dev/ExternalVideo.mjs.map +1 -1
- package/dist/browser-dev/Image.mjs +41 -30
- package/dist/browser-dev/Image.mjs.map +1 -1
- package/dist/browser-dev/MediaFile.mjs +29 -21
- package/dist/browser-dev/MediaFile.mjs.map +1 -1
- package/dist/browser-dev/ModelViewer.mjs +138 -76
- package/dist/browser-dev/ModelViewer.mjs.map +1 -1
- package/dist/browser-dev/Money.mjs +12 -9
- package/dist/browser-dev/Money.mjs.map +1 -1
- package/dist/browser-dev/ProductPrice.mjs +12 -17
- package/dist/browser-dev/ProductPrice.mjs.map +1 -1
- package/dist/browser-dev/ProductProvider.mjs +102 -73
- package/dist/browser-dev/ProductProvider.mjs.map +1 -1
- package/dist/browser-dev/ShopPayButton.mjs +14 -24
- package/dist/browser-dev/ShopPayButton.mjs.map +1 -1
- package/dist/browser-dev/ShopifyProvider.mjs +22 -38
- package/dist/browser-dev/ShopifyProvider.mjs.map +1 -1
- package/dist/browser-dev/Video.mjs +30 -21
- package/dist/browser-dev/Video.mjs.map +1 -1
- package/dist/browser-dev/_virtual/index.mjs +11 -2
- package/dist/browser-dev/_virtual/index.mjs.map +1 -1
- package/dist/browser-dev/_virtual/with-selector.mjs +11 -2
- package/dist/browser-dev/_virtual/with-selector.mjs.map +1 -1
- package/dist/browser-dev/analytics-constants.mjs +43 -0
- package/dist/browser-dev/analytics-constants.mjs.map +1 -0
- package/dist/browser-dev/analytics-schema-custom-storefront-customer-tracking.mjs +145 -0
- package/dist/browser-dev/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -0
- package/dist/browser-dev/analytics-schema-trekkie-storefront-page-view.mjs +58 -0
- package/dist/browser-dev/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -0
- package/dist/browser-dev/analytics-utils.mjs +49 -0
- package/dist/browser-dev/analytics-utils.mjs.map +1 -0
- package/dist/browser-dev/analytics.mjs +159 -0
- package/dist/browser-dev/analytics.mjs.map +1 -0
- package/dist/browser-dev/cart-hooks.mjs +29 -34
- package/dist/browser-dev/cart-hooks.mjs.map +1 -1
- package/dist/browser-dev/cart-queries.mjs +50 -28
- package/dist/browser-dev/cart-queries.mjs.map +1 -1
- package/dist/browser-dev/codegen.helpers.mjs +1 -0
- package/dist/browser-dev/codegen.helpers.mjs.map +1 -1
- package/dist/browser-dev/cookies-utils.mjs +50 -0
- package/dist/browser-dev/cookies-utils.mjs.map +1 -0
- package/dist/browser-dev/flatten-connection.mjs +7 -5
- package/dist/browser-dev/flatten-connection.mjs.map +1 -1
- package/dist/browser-dev/image-size.mjs +8 -8
- package/dist/browser-dev/image-size.mjs.map +1 -1
- package/dist/browser-dev/index.mjs +20 -6
- package/dist/browser-dev/index.mjs.map +1 -1
- package/dist/browser-dev/load-script.mjs.map +1 -1
- package/dist/browser-dev/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
- package/dist/browser-dev/node_modules/@xstate/react/es/fsm.mjs +2 -2
- package/dist/browser-dev/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
- package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -1
- 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.map +1 -1
- package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -1
- package/dist/browser-dev/node_modules/use-sync-external-store/shim/index.mjs +3 -3
- package/dist/browser-dev/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
- package/dist/browser-dev/{metafield-parser.mjs → parse-metafield.mjs} +20 -12
- package/dist/browser-dev/parse-metafield.mjs.map +1 -0
- 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/storefront-client.mjs +19 -20
- package/dist/browser-dev/storefront-client.mjs.map +1 -1
- package/dist/browser-dev/useCartAPIStateMachine.mjs +111 -80
- package/dist/browser-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-dev/useCartActions.mjs +150 -109
- package/dist/browser-dev/useCartActions.mjs.map +1 -1
- package/dist/browser-dev/useMoney.mjs +62 -36
- package/dist/browser-dev/useMoney.mjs.map +1 -1
- package/dist/browser-dev/useShopifyCookies.mjs +41 -0
- package/dist/browser-dev/useShopifyCookies.mjs.map +1 -0
- package/dist/browser-prod/AddToCartButton.mjs +43 -40
- package/dist/browser-prod/AddToCartButton.mjs.map +1 -1
- package/dist/browser-prod/BaseButton.mjs +13 -15
- package/dist/browser-prod/BaseButton.mjs.map +1 -1
- package/dist/browser-prod/BuyNowButton.mjs +19 -17
- package/dist/browser-prod/BuyNowButton.mjs.map +1 -1
- package/dist/browser-prod/CartCheckoutButton.mjs +12 -15
- package/dist/browser-prod/CartCheckoutButton.mjs.map +1 -1
- package/dist/browser-prod/CartCost.mjs +25 -0
- package/dist/browser-prod/CartCost.mjs.map +1 -0
- package/dist/browser-prod/CartLinePrice.mjs +18 -0
- package/dist/browser-prod/CartLinePrice.mjs.map +1 -0
- package/dist/browser-prod/CartLineProvider.mjs +19 -0
- package/dist/browser-prod/CartLineProvider.mjs.map +1 -0
- package/dist/browser-prod/CartProvider.mjs +73 -67
- package/dist/browser-prod/CartProvider.mjs.map +1 -1
- package/dist/browser-prod/ExternalVideo.mjs +13 -11
- package/dist/browser-prod/ExternalVideo.mjs.map +1 -1
- package/dist/browser-prod/Image.mjs +35 -28
- package/dist/browser-prod/Image.mjs.map +1 -1
- package/dist/browser-prod/MediaFile.mjs +29 -21
- package/dist/browser-prod/MediaFile.mjs.map +1 -1
- package/dist/browser-prod/ModelViewer.mjs +135 -75
- package/dist/browser-prod/ModelViewer.mjs.map +1 -1
- package/dist/browser-prod/Money.mjs +12 -9
- package/dist/browser-prod/Money.mjs.map +1 -1
- package/dist/browser-prod/ProductPrice.mjs +12 -17
- package/dist/browser-prod/ProductPrice.mjs.map +1 -1
- package/dist/browser-prod/ProductProvider.mjs +102 -73
- package/dist/browser-prod/ProductProvider.mjs.map +1 -1
- package/dist/browser-prod/ShopPayButton.mjs +14 -24
- package/dist/browser-prod/ShopPayButton.mjs.map +1 -1
- package/dist/browser-prod/ShopifyProvider.mjs +22 -32
- package/dist/browser-prod/ShopifyProvider.mjs.map +1 -1
- package/dist/browser-prod/Video.mjs +30 -21
- package/dist/browser-prod/Video.mjs.map +1 -1
- package/dist/browser-prod/_virtual/index.mjs +11 -2
- package/dist/browser-prod/_virtual/index.mjs.map +1 -1
- package/dist/browser-prod/_virtual/with-selector.mjs +11 -2
- package/dist/browser-prod/_virtual/with-selector.mjs.map +1 -1
- package/dist/browser-prod/analytics-constants.mjs +43 -0
- package/dist/browser-prod/analytics-constants.mjs.map +1 -0
- package/dist/browser-prod/analytics-schema-custom-storefront-customer-tracking.mjs +145 -0
- package/dist/browser-prod/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -0
- package/dist/browser-prod/analytics-schema-trekkie-storefront-page-view.mjs +58 -0
- package/dist/browser-prod/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -0
- package/dist/browser-prod/analytics-utils.mjs +49 -0
- package/dist/browser-prod/analytics-utils.mjs.map +1 -0
- package/dist/browser-prod/analytics.mjs +158 -0
- package/dist/browser-prod/analytics.mjs.map +1 -0
- package/dist/browser-prod/cart-hooks.mjs +29 -34
- package/dist/browser-prod/cart-hooks.mjs.map +1 -1
- package/dist/browser-prod/cart-queries.mjs +50 -28
- package/dist/browser-prod/cart-queries.mjs.map +1 -1
- package/dist/browser-prod/codegen.helpers.mjs +1 -0
- package/dist/browser-prod/codegen.helpers.mjs.map +1 -1
- package/dist/browser-prod/cookies-utils.mjs +50 -0
- package/dist/browser-prod/cookies-utils.mjs.map +1 -0
- package/dist/browser-prod/flatten-connection.mjs +7 -5
- package/dist/browser-prod/flatten-connection.mjs.map +1 -1
- package/dist/browser-prod/image-size.mjs +8 -8
- package/dist/browser-prod/image-size.mjs.map +1 -1
- package/dist/browser-prod/index.mjs +20 -6
- package/dist/browser-prod/index.mjs.map +1 -1
- package/dist/browser-prod/load-script.mjs.map +1 -1
- package/dist/browser-prod/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
- package/dist/browser-prod/node_modules/@xstate/react/es/fsm.mjs +2 -2
- package/dist/browser-prod/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
- package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -1
- 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.map +1 -1
- package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -1
- package/dist/browser-prod/node_modules/use-sync-external-store/shim/index.mjs +3 -3
- package/dist/browser-prod/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
- package/dist/browser-prod/{metafield-parser.mjs → parse-metafield.mjs} +20 -12
- package/dist/browser-prod/parse-metafield.mjs.map +1 -0
- 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/storefront-client.mjs +19 -20
- package/dist/browser-prod/storefront-client.mjs.map +1 -1
- package/dist/browser-prod/useCartAPIStateMachine.mjs +111 -80
- package/dist/browser-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-prod/useCartActions.mjs +150 -109
- package/dist/browser-prod/useCartActions.mjs.map +1 -1
- package/dist/browser-prod/useMoney.mjs +62 -36
- package/dist/browser-prod/useMoney.mjs.map +1 -1
- package/dist/browser-prod/useShopifyCookies.mjs +41 -0
- package/dist/browser-prod/useShopifyCookies.mjs.map +1 -0
- package/dist/node-dev/AddToCartButton.js +44 -41
- package/dist/node-dev/AddToCartButton.js.map +1 -1
- package/dist/node-dev/AddToCartButton.mjs +43 -40
- package/dist/node-dev/AddToCartButton.mjs.map +1 -1
- package/dist/node-dev/BaseButton.js +14 -16
- package/dist/node-dev/BaseButton.js.map +1 -1
- package/dist/node-dev/BaseButton.mjs +13 -15
- package/dist/node-dev/BaseButton.mjs.map +1 -1
- package/dist/node-dev/BuyNowButton.js +20 -18
- package/dist/node-dev/BuyNowButton.js.map +1 -1
- package/dist/node-dev/BuyNowButton.mjs +19 -17
- package/dist/node-dev/BuyNowButton.mjs.map +1 -1
- package/dist/node-dev/CartCheckoutButton.js +13 -16
- package/dist/node-dev/CartCheckoutButton.js.map +1 -1
- package/dist/node-dev/CartCheckoutButton.mjs +12 -15
- package/dist/node-dev/CartCheckoutButton.mjs.map +1 -1
- package/dist/node-dev/CartCost.js +25 -0
- package/dist/node-dev/CartCost.js.map +1 -0
- package/dist/node-dev/CartCost.mjs +25 -0
- package/dist/node-dev/CartCost.mjs.map +1 -0
- package/dist/node-dev/CartLinePrice.js +18 -0
- package/dist/node-dev/CartLinePrice.js.map +1 -0
- package/dist/node-dev/CartLinePrice.mjs +18 -0
- package/dist/node-dev/CartLinePrice.mjs.map +1 -0
- package/dist/node-dev/CartLineProvider.js +19 -0
- package/dist/node-dev/CartLineProvider.js.map +1 -0
- package/dist/node-dev/CartLineProvider.mjs +19 -0
- package/dist/node-dev/CartLineProvider.mjs.map +1 -0
- package/dist/node-dev/CartProvider.js +74 -68
- package/dist/node-dev/CartProvider.js.map +1 -1
- package/dist/node-dev/CartProvider.mjs +73 -67
- package/dist/node-dev/CartProvider.mjs.map +1 -1
- package/dist/node-dev/ExternalVideo.js +14 -12
- package/dist/node-dev/ExternalVideo.js.map +1 -1
- package/dist/node-dev/ExternalVideo.mjs +13 -11
- package/dist/node-dev/ExternalVideo.mjs.map +1 -1
- package/dist/node-dev/Image.js +42 -31
- package/dist/node-dev/Image.js.map +1 -1
- package/dist/node-dev/Image.mjs +41 -30
- package/dist/node-dev/Image.mjs.map +1 -1
- package/dist/node-dev/MediaFile.js +30 -22
- package/dist/node-dev/MediaFile.js.map +1 -1
- package/dist/node-dev/MediaFile.mjs +29 -21
- package/dist/node-dev/MediaFile.mjs.map +1 -1
- package/dist/node-dev/ModelViewer.js +139 -77
- package/dist/node-dev/ModelViewer.js.map +1 -1
- package/dist/node-dev/ModelViewer.mjs +138 -76
- package/dist/node-dev/ModelViewer.mjs.map +1 -1
- package/dist/node-dev/Money.js +13 -10
- package/dist/node-dev/Money.js.map +1 -1
- package/dist/node-dev/Money.mjs +12 -9
- package/dist/node-dev/Money.mjs.map +1 -1
- package/dist/node-dev/ProductPrice.js +13 -18
- package/dist/node-dev/ProductPrice.js.map +1 -1
- package/dist/node-dev/ProductPrice.mjs +12 -17
- package/dist/node-dev/ProductPrice.mjs.map +1 -1
- package/dist/node-dev/ProductProvider.js +103 -74
- package/dist/node-dev/ProductProvider.js.map +1 -1
- package/dist/node-dev/ProductProvider.mjs +102 -73
- package/dist/node-dev/ProductProvider.mjs.map +1 -1
- package/dist/node-dev/ShopPayButton.js +14 -24
- package/dist/node-dev/ShopPayButton.js.map +1 -1
- package/dist/node-dev/ShopPayButton.mjs +14 -24
- package/dist/node-dev/ShopPayButton.mjs.map +1 -1
- package/dist/node-dev/ShopifyProvider.js +23 -39
- package/dist/node-dev/ShopifyProvider.js.map +1 -1
- package/dist/node-dev/ShopifyProvider.mjs +22 -38
- package/dist/node-dev/ShopifyProvider.mjs.map +1 -1
- package/dist/node-dev/Video.js +31 -22
- package/dist/node-dev/Video.js.map +1 -1
- package/dist/node-dev/Video.mjs +30 -21
- package/dist/node-dev/Video.mjs.map +1 -1
- package/dist/node-dev/_virtual/index.js +11 -3
- package/dist/node-dev/_virtual/index.js.map +1 -1
- package/dist/node-dev/_virtual/index.mjs +11 -2
- package/dist/node-dev/_virtual/index.mjs.map +1 -1
- package/dist/node-dev/_virtual/use-sync-external-store-shim.development.js +1 -1
- package/dist/node-dev/_virtual/use-sync-external-store-shim.production.min.js +1 -1
- package/dist/node-dev/_virtual/with-selector.development.js +1 -1
- package/dist/node-dev/_virtual/with-selector.js +11 -3
- package/dist/node-dev/_virtual/with-selector.js.map +1 -1
- package/dist/node-dev/_virtual/with-selector.mjs +11 -2
- package/dist/node-dev/_virtual/with-selector.mjs.map +1 -1
- package/dist/node-dev/_virtual/with-selector.production.min.js +1 -1
- package/dist/node-dev/analytics-constants.js +43 -0
- package/dist/node-dev/analytics-constants.js.map +1 -0
- package/dist/node-dev/analytics-constants.mjs +43 -0
- package/dist/node-dev/analytics-constants.mjs.map +1 -0
- package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.js +145 -0
- package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.js.map +1 -0
- package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.mjs +145 -0
- package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -0
- package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.js +58 -0
- package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.js.map +1 -0
- package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.mjs +58 -0
- package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -0
- package/dist/node-dev/analytics-utils.js +49 -0
- package/dist/node-dev/analytics-utils.js.map +1 -0
- package/dist/node-dev/analytics-utils.mjs +49 -0
- package/dist/node-dev/analytics-utils.mjs.map +1 -0
- package/dist/node-dev/analytics.js +159 -0
- package/dist/node-dev/analytics.js.map +1 -0
- package/dist/node-dev/analytics.mjs +159 -0
- package/dist/node-dev/analytics.mjs.map +1 -0
- package/dist/node-dev/cart-constants.js +1 -1
- package/dist/node-dev/cart-hooks.js +29 -34
- package/dist/node-dev/cart-hooks.js.map +1 -1
- package/dist/node-dev/cart-hooks.mjs +29 -34
- package/dist/node-dev/cart-hooks.mjs.map +1 -1
- package/dist/node-dev/cart-queries.js +51 -29
- package/dist/node-dev/cart-queries.js.map +1 -1
- package/dist/node-dev/cart-queries.mjs +50 -28
- package/dist/node-dev/cart-queries.mjs.map +1 -1
- package/dist/node-dev/codegen.helpers.js +2 -1
- package/dist/node-dev/codegen.helpers.js.map +1 -1
- package/dist/node-dev/codegen.helpers.mjs +1 -0
- package/dist/node-dev/codegen.helpers.mjs.map +1 -1
- package/dist/node-dev/cookies-utils.js +50 -0
- package/dist/node-dev/cookies-utils.js.map +1 -0
- package/dist/node-dev/cookies-utils.mjs +50 -0
- package/dist/node-dev/cookies-utils.mjs.map +1 -0
- package/dist/node-dev/flatten-connection.js +8 -6
- package/dist/node-dev/flatten-connection.js.map +1 -1
- package/dist/node-dev/flatten-connection.mjs +7 -5
- package/dist/node-dev/flatten-connection.mjs.map +1 -1
- package/dist/node-dev/image-size.js +9 -9
- package/dist/node-dev/image-size.js.map +1 -1
- package/dist/node-dev/image-size.mjs +8 -8
- package/dist/node-dev/image-size.mjs.map +1 -1
- package/dist/node-dev/index.js +21 -7
- package/dist/node-dev/index.js.map +1 -1
- package/dist/node-dev/index.mjs +20 -6
- package/dist/node-dev/index.mjs.map +1 -1
- package/dist/node-dev/load-script.js +1 -1
- package/dist/node-dev/load-script.js.map +1 -1
- package/dist/node-dev/load-script.mjs.map +1 -1
- package/dist/node-dev/node_modules/@xstate/fsm/es/index.js +1 -1
- package/dist/node-dev/node_modules/@xstate/fsm/es/index.js.map +1 -1
- package/dist/node-dev/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
- package/dist/node-dev/node_modules/@xstate/react/es/fsm.js +2 -2
- package/dist/node-dev/node_modules/@xstate/react/es/fsm.js.map +1 -1
- package/dist/node-dev/node_modules/@xstate/react/es/fsm.mjs +2 -2
- package/dist/node-dev/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
- package/dist/node-dev/node_modules/@xstate/react/es/useConstant.js +2 -4
- package/dist/node-dev/node_modules/@xstate/react/es/useConstant.js.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +2 -4
- 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.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +2 -4
- 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.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +2 -4
- 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.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +2 -4
- 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.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/shim/index.js +4 -4
- package/dist/node-dev/node_modules/use-sync-external-store/shim/index.mjs +3 -3
- package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.js +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
- package/dist/node-dev/{metafield-parser.js → parse-metafield.js} +21 -13
- package/dist/node-dev/parse-metafield.js.map +1 -0
- package/dist/node-dev/{metafield-parser.mjs → parse-metafield.mjs} +20 -12
- package/dist/node-dev/parse-metafield.mjs.map +1 -0
- package/dist/node-dev/storefront-api-constants.js +2 -2
- 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/storefront-client.js +20 -21
- package/dist/node-dev/storefront-client.js.map +1 -1
- package/dist/node-dev/storefront-client.mjs +19 -20
- package/dist/node-dev/storefront-client.mjs.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.js +112 -81
- package/dist/node-dev/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.mjs +111 -80
- package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-dev/useCartActions.js +151 -110
- package/dist/node-dev/useCartActions.js.map +1 -1
- package/dist/node-dev/useCartActions.mjs +150 -109
- package/dist/node-dev/useCartActions.mjs.map +1 -1
- package/dist/node-dev/useMoney.js +63 -37
- package/dist/node-dev/useMoney.js.map +1 -1
- package/dist/node-dev/useMoney.mjs +62 -36
- package/dist/node-dev/useMoney.mjs.map +1 -1
- package/dist/node-dev/useShopifyCookies.js +41 -0
- package/dist/node-dev/useShopifyCookies.js.map +1 -0
- package/dist/node-dev/useShopifyCookies.mjs +41 -0
- package/dist/node-dev/useShopifyCookies.mjs.map +1 -0
- package/dist/node-prod/AddToCartButton.js +44 -41
- package/dist/node-prod/AddToCartButton.js.map +1 -1
- package/dist/node-prod/AddToCartButton.mjs +43 -40
- package/dist/node-prod/AddToCartButton.mjs.map +1 -1
- package/dist/node-prod/BaseButton.js +14 -16
- package/dist/node-prod/BaseButton.js.map +1 -1
- package/dist/node-prod/BaseButton.mjs +13 -15
- package/dist/node-prod/BaseButton.mjs.map +1 -1
- package/dist/node-prod/BuyNowButton.js +20 -18
- package/dist/node-prod/BuyNowButton.js.map +1 -1
- package/dist/node-prod/BuyNowButton.mjs +19 -17
- package/dist/node-prod/BuyNowButton.mjs.map +1 -1
- package/dist/node-prod/CartCheckoutButton.js +13 -16
- package/dist/node-prod/CartCheckoutButton.js.map +1 -1
- package/dist/node-prod/CartCheckoutButton.mjs +12 -15
- package/dist/node-prod/CartCheckoutButton.mjs.map +1 -1
- package/dist/node-prod/CartCost.js +25 -0
- package/dist/node-prod/CartCost.js.map +1 -0
- package/dist/node-prod/CartCost.mjs +25 -0
- package/dist/node-prod/CartCost.mjs.map +1 -0
- package/dist/node-prod/CartLinePrice.js +18 -0
- package/dist/node-prod/CartLinePrice.js.map +1 -0
- package/dist/node-prod/CartLinePrice.mjs +18 -0
- package/dist/node-prod/CartLinePrice.mjs.map +1 -0
- package/dist/node-prod/CartLineProvider.js +19 -0
- package/dist/node-prod/CartLineProvider.js.map +1 -0
- package/dist/node-prod/CartLineProvider.mjs +19 -0
- package/dist/node-prod/CartLineProvider.mjs.map +1 -0
- package/dist/node-prod/CartProvider.js +74 -68
- package/dist/node-prod/CartProvider.js.map +1 -1
- package/dist/node-prod/CartProvider.mjs +73 -67
- package/dist/node-prod/CartProvider.mjs.map +1 -1
- package/dist/node-prod/ExternalVideo.js +14 -12
- package/dist/node-prod/ExternalVideo.js.map +1 -1
- package/dist/node-prod/ExternalVideo.mjs +13 -11
- package/dist/node-prod/ExternalVideo.mjs.map +1 -1
- package/dist/node-prod/Image.js +36 -29
- package/dist/node-prod/Image.js.map +1 -1
- package/dist/node-prod/Image.mjs +35 -28
- package/dist/node-prod/Image.mjs.map +1 -1
- package/dist/node-prod/MediaFile.js +30 -22
- package/dist/node-prod/MediaFile.js.map +1 -1
- package/dist/node-prod/MediaFile.mjs +29 -21
- package/dist/node-prod/MediaFile.mjs.map +1 -1
- package/dist/node-prod/ModelViewer.js +136 -76
- package/dist/node-prod/ModelViewer.js.map +1 -1
- package/dist/node-prod/ModelViewer.mjs +135 -75
- package/dist/node-prod/ModelViewer.mjs.map +1 -1
- package/dist/node-prod/Money.js +13 -10
- package/dist/node-prod/Money.js.map +1 -1
- package/dist/node-prod/Money.mjs +12 -9
- package/dist/node-prod/Money.mjs.map +1 -1
- package/dist/node-prod/ProductPrice.js +13 -18
- package/dist/node-prod/ProductPrice.js.map +1 -1
- package/dist/node-prod/ProductPrice.mjs +12 -17
- package/dist/node-prod/ProductPrice.mjs.map +1 -1
- package/dist/node-prod/ProductProvider.js +103 -74
- package/dist/node-prod/ProductProvider.js.map +1 -1
- package/dist/node-prod/ProductProvider.mjs +102 -73
- package/dist/node-prod/ProductProvider.mjs.map +1 -1
- package/dist/node-prod/ShopPayButton.js +14 -24
- package/dist/node-prod/ShopPayButton.js.map +1 -1
- package/dist/node-prod/ShopPayButton.mjs +14 -24
- package/dist/node-prod/ShopPayButton.mjs.map +1 -1
- package/dist/node-prod/ShopifyProvider.js +23 -33
- package/dist/node-prod/ShopifyProvider.js.map +1 -1
- package/dist/node-prod/ShopifyProvider.mjs +22 -32
- package/dist/node-prod/ShopifyProvider.mjs.map +1 -1
- package/dist/node-prod/Video.js +31 -22
- package/dist/node-prod/Video.js.map +1 -1
- package/dist/node-prod/Video.mjs +30 -21
- package/dist/node-prod/Video.mjs.map +1 -1
- package/dist/node-prod/_virtual/index.js +11 -3
- package/dist/node-prod/_virtual/index.js.map +1 -1
- package/dist/node-prod/_virtual/index.mjs +11 -2
- package/dist/node-prod/_virtual/index.mjs.map +1 -1
- package/dist/node-prod/_virtual/use-sync-external-store-shim.development.js +1 -1
- package/dist/node-prod/_virtual/use-sync-external-store-shim.production.min.js +1 -1
- package/dist/node-prod/_virtual/with-selector.development.js +1 -1
- package/dist/node-prod/_virtual/with-selector.js +11 -3
- package/dist/node-prod/_virtual/with-selector.js.map +1 -1
- package/dist/node-prod/_virtual/with-selector.mjs +11 -2
- package/dist/node-prod/_virtual/with-selector.mjs.map +1 -1
- package/dist/node-prod/_virtual/with-selector.production.min.js +1 -1
- package/dist/node-prod/analytics-constants.js +43 -0
- package/dist/node-prod/analytics-constants.js.map +1 -0
- package/dist/node-prod/analytics-constants.mjs +43 -0
- package/dist/node-prod/analytics-constants.mjs.map +1 -0
- package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.js +145 -0
- package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.js.map +1 -0
- package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.mjs +145 -0
- package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -0
- package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.js +58 -0
- package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.js.map +1 -0
- package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.mjs +58 -0
- package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -0
- package/dist/node-prod/analytics-utils.js +49 -0
- package/dist/node-prod/analytics-utils.js.map +1 -0
- package/dist/node-prod/analytics-utils.mjs +49 -0
- package/dist/node-prod/analytics-utils.mjs.map +1 -0
- package/dist/node-prod/analytics.js +158 -0
- package/dist/node-prod/analytics.js.map +1 -0
- package/dist/node-prod/analytics.mjs +158 -0
- package/dist/node-prod/analytics.mjs.map +1 -0
- package/dist/node-prod/cart-constants.js +1 -1
- package/dist/node-prod/cart-hooks.js +29 -34
- package/dist/node-prod/cart-hooks.js.map +1 -1
- package/dist/node-prod/cart-hooks.mjs +29 -34
- package/dist/node-prod/cart-hooks.mjs.map +1 -1
- package/dist/node-prod/cart-queries.js +51 -29
- package/dist/node-prod/cart-queries.js.map +1 -1
- package/dist/node-prod/cart-queries.mjs +50 -28
- package/dist/node-prod/cart-queries.mjs.map +1 -1
- package/dist/node-prod/codegen.helpers.js +2 -1
- package/dist/node-prod/codegen.helpers.js.map +1 -1
- package/dist/node-prod/codegen.helpers.mjs +1 -0
- package/dist/node-prod/codegen.helpers.mjs.map +1 -1
- package/dist/node-prod/cookies-utils.js +50 -0
- package/dist/node-prod/cookies-utils.js.map +1 -0
- package/dist/node-prod/cookies-utils.mjs +50 -0
- package/dist/node-prod/cookies-utils.mjs.map +1 -0
- package/dist/node-prod/flatten-connection.js +8 -6
- package/dist/node-prod/flatten-connection.js.map +1 -1
- package/dist/node-prod/flatten-connection.mjs +7 -5
- package/dist/node-prod/flatten-connection.mjs.map +1 -1
- package/dist/node-prod/image-size.js +9 -9
- package/dist/node-prod/image-size.js.map +1 -1
- package/dist/node-prod/image-size.mjs +8 -8
- package/dist/node-prod/image-size.mjs.map +1 -1
- package/dist/node-prod/index.js +21 -7
- package/dist/node-prod/index.js.map +1 -1
- package/dist/node-prod/index.mjs +20 -6
- package/dist/node-prod/index.mjs.map +1 -1
- package/dist/node-prod/load-script.js +1 -1
- package/dist/node-prod/load-script.js.map +1 -1
- package/dist/node-prod/load-script.mjs.map +1 -1
- package/dist/node-prod/node_modules/@xstate/fsm/es/index.js +1 -1
- package/dist/node-prod/node_modules/@xstate/fsm/es/index.js.map +1 -1
- package/dist/node-prod/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
- package/dist/node-prod/node_modules/@xstate/react/es/fsm.js +2 -2
- package/dist/node-prod/node_modules/@xstate/react/es/fsm.js.map +1 -1
- package/dist/node-prod/node_modules/@xstate/react/es/fsm.mjs +2 -2
- package/dist/node-prod/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
- package/dist/node-prod/node_modules/@xstate/react/es/useConstant.js +2 -4
- package/dist/node-prod/node_modules/@xstate/react/es/useConstant.js.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +2 -4
- 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.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +2 -4
- 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.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +2 -4
- 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.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +2 -4
- 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.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/shim/index.js +4 -4
- package/dist/node-prod/node_modules/use-sync-external-store/shim/index.mjs +3 -3
- package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.js +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
- package/dist/node-prod/{metafield-parser.js → parse-metafield.js} +21 -13
- package/dist/node-prod/parse-metafield.js.map +1 -0
- package/dist/node-prod/{metafield-parser.mjs → parse-metafield.mjs} +20 -12
- package/dist/node-prod/parse-metafield.mjs.map +1 -0
- package/dist/node-prod/storefront-api-constants.js +2 -2
- 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/storefront-client.js +20 -21
- package/dist/node-prod/storefront-client.js.map +1 -1
- package/dist/node-prod/storefront-client.mjs +19 -20
- package/dist/node-prod/storefront-client.mjs.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.js +112 -81
- package/dist/node-prod/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.mjs +111 -80
- package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-prod/useCartActions.js +151 -110
- package/dist/node-prod/useCartActions.js.map +1 -1
- package/dist/node-prod/useCartActions.mjs +150 -109
- package/dist/node-prod/useCartActions.mjs.map +1 -1
- package/dist/node-prod/useMoney.js +63 -37
- package/dist/node-prod/useMoney.js.map +1 -1
- package/dist/node-prod/useMoney.mjs +62 -36
- package/dist/node-prod/useMoney.mjs.map +1 -1
- package/dist/node-prod/useShopifyCookies.js +41 -0
- package/dist/node-prod/useShopifyCookies.js.map +1 -0
- package/dist/node-prod/useShopifyCookies.mjs +41 -0
- package/dist/node-prod/useShopifyCookies.mjs.map +1 -0
- package/dist/types/AddToCartButton.d.ts +3 -2
- package/dist/types/BuyNowButton.d.ts +7 -3
- package/dist/types/CartCheckoutButton.d.ts +6 -5
- package/dist/types/CartCost.d.ts +7 -5
- package/dist/types/CartLinePrice.d.ts +4 -4
- package/dist/types/CartLineProvider.d.ts +8 -6
- package/dist/types/CartProvider.d.ts +12 -2
- package/dist/types/ExternalVideo.d.ts +1 -2
- package/dist/types/Image.d.ts +5 -3
- package/dist/types/MediaFile.d.ts +12 -11
- package/dist/types/ModelViewer.d.ts +2 -2
- package/dist/types/ProductPrice.d.ts +1 -1
- package/dist/types/ProductProvider.d.ts +1 -1
- package/dist/types/ShopPayButton.d.ts +10 -10
- package/dist/types/ShopifyProvider.d.ts +36 -40
- package/dist/types/analytics-constants.d.ts +48 -0
- package/dist/types/analytics-schema-custom-storefront-customer-tracking.d.ts +3 -0
- package/dist/types/analytics-schema-trekkie-storefront-page-view.d.ts +2 -0
- package/dist/types/analytics-types.d.ts +108 -0
- package/dist/types/analytics-utils.d.ts +36 -0
- package/dist/types/analytics.d.ts +9 -0
- package/dist/types/cart-queries.d.ts +1 -1
- package/dist/types/cookies-utils.d.ts +4 -0
- package/dist/types/flatten-connection.d.ts +29 -9
- package/dist/types/index.d.cts +11 -4
- package/dist/types/index.d.ts +11 -4
- package/dist/types/{metafield-parser.d.ts → parse-metafield.d.ts} +11 -9
- package/dist/types/storefront-api-constants.d.ts +1 -1
- package/dist/types/storefront-api-types.d.ts +121 -2
- package/dist/types/storefront-client.d.ts +14 -14
- package/dist/types/useCartActions.d.ts +1 -1
- package/dist/types/useShopifyCookies.d.ts +14 -0
- package/dist/umd/hydrogen-react.dev.js +1634 -1371
- package/dist/umd/hydrogen-react.dev.js.map +1 -1
- package/dist/umd/hydrogen-react.prod.js +18 -25
- package/dist/umd/hydrogen-react.prod.js.map +1 -1
- package/package.json +24 -19
- package/storefront.schema.json +1 -1
- package/dist/browser-dev/Metafield.mjs +0 -301
- package/dist/browser-dev/Metafield.mjs.map +0 -1
- package/dist/browser-dev/metafield-parser.mjs.map +0 -1
- package/dist/browser-prod/Metafield.mjs +0 -288
- package/dist/browser-prod/Metafield.mjs.map +0 -1
- package/dist/browser-prod/metafield-parser.mjs.map +0 -1
- package/dist/node-dev/Metafield.js +0 -301
- package/dist/node-dev/Metafield.js.map +0 -1
- package/dist/node-dev/Metafield.mjs +0 -301
- package/dist/node-dev/Metafield.mjs.map +0 -1
- package/dist/node-dev/metafield-parser.js.map +0 -1
- package/dist/node-dev/metafield-parser.mjs.map +0 -1
- package/dist/node-prod/Metafield.js +0 -288
- package/dist/node-prod/Metafield.js.map +0 -1
- package/dist/node-prod/Metafield.mjs +0 -288
- package/dist/node-prod/Metafield.mjs.map +0 -1
- package/dist/node-prod/metafield-parser.js.map +0 -1
- package/dist/node-prod/metafield-parser.mjs.map +0 -1
- package/dist/types/Metafield.d.ts +0 -61
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react")) : typeof define === "function" && define.amd ? define(["exports", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react")) : typeof define === "function" && define.amd ? define(["exports", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.storefrontkitreact = {}, global.React));
|
|
3
3
|
})(this, function(exports2, React) {
|
|
4
4
|
"use strict";
|
|
5
|
-
|
|
6
|
-
function _interopNamespace(e2) {
|
|
7
|
-
if (e2 && e2.__esModule)
|
|
8
|
-
return e2;
|
|
5
|
+
function _interopNamespaceDefault(e2) {
|
|
9
6
|
const n2 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
7
|
if (e2) {
|
|
11
8
|
for (const k in e2) {
|
|
@@ -21,8 +18,7 @@
|
|
|
21
18
|
n2.default = e2;
|
|
22
19
|
return Object.freeze(n2);
|
|
23
20
|
}
|
|
24
|
-
const
|
|
25
|
-
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
|
21
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
26
22
|
/*! *****************************************************************************
|
|
27
23
|
Copyright (c) Microsoft Corporation.
|
|
28
24
|
|
|
@@ -144,7 +140,7 @@
|
|
|
144
140
|
} };
|
|
145
141
|
return y;
|
|
146
142
|
}
|
|
147
|
-
var l = function(t2, n2) {
|
|
143
|
+
var l$1 = function(t2, n2) {
|
|
148
144
|
return t2.actions.forEach(function(e2) {
|
|
149
145
|
var r2 = e2.exec;
|
|
150
146
|
return r2 && r2(t2.context, n2);
|
|
@@ -152,7 +148,7 @@
|
|
|
152
148
|
};
|
|
153
149
|
function v(t2) {
|
|
154
150
|
var r2 = t2.initialState, i2 = n.NotStarted, o2 = /* @__PURE__ */ new Set(), c2 = { _machine: t2, send: function(e2) {
|
|
155
|
-
i2 === n.Running && (r2 = t2.transition(r2, e2), l(r2, u$1(e2)), o2.forEach(function(t3) {
|
|
151
|
+
i2 === n.Running && (r2 = t2.transition(r2, e2), l$1(r2, u$1(e2)), o2.forEach(function(t3) {
|
|
156
152
|
return t3(r2);
|
|
157
153
|
}));
|
|
158
154
|
}, subscribe: function(t3) {
|
|
@@ -165,7 +161,7 @@
|
|
|
165
161
|
r2 = { value: u2.value, actions: [], context: u2.context, matches: a(u2.value) };
|
|
166
162
|
} else
|
|
167
163
|
r2 = t2.initialState;
|
|
168
|
-
return i2 = n.Running, l(r2, e), c2;
|
|
164
|
+
return i2 = n.Running, l$1(r2, e), c2;
|
|
169
165
|
}, stop: function() {
|
|
170
166
|
return i2 = n.Stopped, o2.clear(), c2;
|
|
171
167
|
}, get state() {
|
|
@@ -176,9 +172,25 @@
|
|
|
176
172
|
return c2;
|
|
177
173
|
}
|
|
178
174
|
var index = React.useLayoutEffect;
|
|
179
|
-
var
|
|
175
|
+
var withSelectorExports = {};
|
|
176
|
+
var withSelector = {
|
|
177
|
+
get exports() {
|
|
178
|
+
return withSelectorExports;
|
|
179
|
+
},
|
|
180
|
+
set exports(v2) {
|
|
181
|
+
withSelectorExports = v2;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
180
184
|
var withSelector_production_min = {};
|
|
181
|
-
var
|
|
185
|
+
var shimExports = {};
|
|
186
|
+
var shim = {
|
|
187
|
+
get exports() {
|
|
188
|
+
return shimExports;
|
|
189
|
+
},
|
|
190
|
+
set exports(v2) {
|
|
191
|
+
shimExports = v2;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
182
194
|
var useSyncExternalStoreShim_production_min = {};
|
|
183
195
|
/**
|
|
184
196
|
* @license React
|
|
@@ -194,7 +206,7 @@
|
|
|
194
206
|
if (hasRequiredUseSyncExternalStoreShim_production_min)
|
|
195
207
|
return useSyncExternalStoreShim_production_min;
|
|
196
208
|
hasRequiredUseSyncExternalStoreShim_production_min = 1;
|
|
197
|
-
var e2 =
|
|
209
|
+
var e2 = React;
|
|
198
210
|
function h(a2, b) {
|
|
199
211
|
return a2 === b && (0 !== a2 || 1 / a2 === 1 / b) || a2 !== a2 && b !== b;
|
|
200
212
|
}
|
|
@@ -252,8 +264,8 @@
|
|
|
252
264
|
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
|
253
265
|
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
254
266
|
}
|
|
255
|
-
var
|
|
256
|
-
var ReactSharedInternals =
|
|
267
|
+
var React$1 = React;
|
|
268
|
+
var ReactSharedInternals = React$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
257
269
|
function error(format) {
|
|
258
270
|
{
|
|
259
271
|
{
|
|
@@ -283,13 +295,13 @@
|
|
|
283
295
|
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
|
|
284
296
|
}
|
|
285
297
|
var objectIs = typeof Object.is === "function" ? Object.is : is;
|
|
286
|
-
var useState =
|
|
298
|
+
var useState = React$1.useState, useEffect = React$1.useEffect, useLayoutEffect = React$1.useLayoutEffect, useDebugValue = React$1.useDebugValue;
|
|
287
299
|
var didWarnOld18Alpha = false;
|
|
288
300
|
var didWarnUncachedGetSnapshot = false;
|
|
289
301
|
function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
|
|
290
302
|
{
|
|
291
303
|
if (!didWarnOld18Alpha) {
|
|
292
|
-
if (
|
|
304
|
+
if (React$1.startTransition !== void 0) {
|
|
293
305
|
didWarnOld18Alpha = true;
|
|
294
306
|
error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release.");
|
|
295
307
|
}
|
|
@@ -354,7 +366,7 @@
|
|
|
354
366
|
var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
|
355
367
|
var isServerEnvironment = !canUseDOM;
|
|
356
368
|
var shim2 = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
|
|
357
|
-
var useSyncExternalStore$2 =
|
|
369
|
+
var useSyncExternalStore$2 = React$1.useSyncExternalStore !== void 0 ? React$1.useSyncExternalStore : shim2;
|
|
358
370
|
useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
|
|
359
371
|
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
|
|
360
372
|
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
@@ -366,7 +378,7 @@
|
|
|
366
378
|
var hasRequiredShim;
|
|
367
379
|
function requireShim() {
|
|
368
380
|
if (hasRequiredShim)
|
|
369
|
-
return
|
|
381
|
+
return shimExports;
|
|
370
382
|
hasRequiredShim = 1;
|
|
371
383
|
(function(module2) {
|
|
372
384
|
if (process.env.NODE_ENV === "production") {
|
|
@@ -375,7 +387,7 @@
|
|
|
375
387
|
module2.exports = requireUseSyncExternalStoreShim_development();
|
|
376
388
|
}
|
|
377
389
|
})(shim);
|
|
378
|
-
return
|
|
390
|
+
return shimExports;
|
|
379
391
|
}
|
|
380
392
|
/**
|
|
381
393
|
* @license React
|
|
@@ -391,7 +403,7 @@
|
|
|
391
403
|
if (hasRequiredWithSelector_production_min)
|
|
392
404
|
return withSelector_production_min;
|
|
393
405
|
hasRequiredWithSelector_production_min = 1;
|
|
394
|
-
var h =
|
|
406
|
+
var h = React, n2 = requireShim();
|
|
395
407
|
function p(a2, b) {
|
|
396
408
|
return a2 === b && (0 !== a2 || 1 / a2 === 1 / b) || a2 !== a2 && b !== b;
|
|
397
409
|
}
|
|
@@ -462,14 +474,14 @@
|
|
|
462
474
|
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
|
463
475
|
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
464
476
|
}
|
|
465
|
-
var
|
|
477
|
+
var React$1 = React;
|
|
466
478
|
var shim2 = requireShim();
|
|
467
479
|
function is(x, y) {
|
|
468
480
|
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
|
|
469
481
|
}
|
|
470
482
|
var objectIs = typeof Object.is === "function" ? Object.is : is;
|
|
471
483
|
var useSyncExternalStore = shim2.useSyncExternalStore;
|
|
472
|
-
var useRef =
|
|
484
|
+
var useRef = React$1.useRef, useEffect = React$1.useEffect, useMemo = React$1.useMemo, useDebugValue = React$1.useDebugValue;
|
|
473
485
|
function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual2) {
|
|
474
486
|
var instRef = useRef(null);
|
|
475
487
|
var inst;
|
|
@@ -635,35 +647,39 @@
|
|
|
635
647
|
var unsubscribe = service.subscribe(handleStoreChange).unsubscribe;
|
|
636
648
|
return unsubscribe;
|
|
637
649
|
}, [service]);
|
|
638
|
-
var storeSnapshot =
|
|
650
|
+
var storeSnapshot = withSelectorExports.useSyncExternalStoreWithSelector(subscribe, getSnapshot, getSnapshot, identity, isEqual);
|
|
639
651
|
return [storeSnapshot, service.send, service];
|
|
640
652
|
}
|
|
641
653
|
function flattenConnection(connection) {
|
|
642
654
|
if (!connection) {
|
|
643
|
-
const noConnectionErr = `flattenConnection(): needs a 'connection' to flatten, but received '${connection}' instead
|
|
655
|
+
const noConnectionErr = `flattenConnection(): needs a 'connection' to flatten, but received '${connection}' instead.`;
|
|
644
656
|
{
|
|
645
657
|
throw new Error(noConnectionErr);
|
|
646
658
|
}
|
|
647
659
|
}
|
|
648
|
-
if (connection
|
|
660
|
+
if ("nodes" in connection) {
|
|
649
661
|
return connection.nodes;
|
|
650
662
|
}
|
|
651
|
-
if (connection.edges) {
|
|
663
|
+
if ("edges" in connection && Array.isArray(connection.edges)) {
|
|
652
664
|
return connection.edges.map((edge) => {
|
|
653
665
|
if (!(edge == null ? void 0 : edge.node)) {
|
|
654
|
-
throw new Error(
|
|
666
|
+
throw new Error(
|
|
667
|
+
"flattenConnection(): Connection edges must contain nodes"
|
|
668
|
+
);
|
|
655
669
|
}
|
|
656
670
|
return edge.node;
|
|
657
671
|
});
|
|
658
672
|
}
|
|
659
673
|
{
|
|
660
674
|
console.warn(
|
|
661
|
-
`The connection did not contain either "nodes" or "edges.node".
|
|
675
|
+
`flattenConnection(): The connection did not contain either "nodes" or "edges.node". Returning an empty array.`
|
|
662
676
|
);
|
|
663
677
|
}
|
|
664
678
|
return [];
|
|
665
679
|
}
|
|
666
|
-
const CartLineAdd = (cartFragment) =>
|
|
680
|
+
const CartLineAdd = (cartFragment) => (
|
|
681
|
+
/* GraphQL */
|
|
682
|
+
`
|
|
667
683
|
mutation CartLineAdd(
|
|
668
684
|
$cartId: ID!
|
|
669
685
|
$lines: [CartLineInput!]!
|
|
@@ -678,8 +694,11 @@
|
|
|
678
694
|
}
|
|
679
695
|
|
|
680
696
|
${cartFragment}
|
|
681
|
-
|
|
682
|
-
|
|
697
|
+
`
|
|
698
|
+
);
|
|
699
|
+
const CartCreate = (cartFragment) => (
|
|
700
|
+
/* GraphQL */
|
|
701
|
+
`
|
|
683
702
|
mutation CartCreate(
|
|
684
703
|
$input: CartInput!
|
|
685
704
|
$numCartLines: Int = 250
|
|
@@ -693,8 +712,11 @@
|
|
|
693
712
|
}
|
|
694
713
|
|
|
695
714
|
${cartFragment}
|
|
696
|
-
|
|
697
|
-
|
|
715
|
+
`
|
|
716
|
+
);
|
|
717
|
+
const CartLineRemove = (cartFragment) => (
|
|
718
|
+
/* GraphQL */
|
|
719
|
+
`
|
|
698
720
|
mutation CartLineRemove(
|
|
699
721
|
$cartId: ID!
|
|
700
722
|
$lines: [ID!]!
|
|
@@ -709,8 +731,11 @@
|
|
|
709
731
|
}
|
|
710
732
|
|
|
711
733
|
${cartFragment}
|
|
712
|
-
|
|
713
|
-
|
|
734
|
+
`
|
|
735
|
+
);
|
|
736
|
+
const CartLineUpdate = (cartFragment) => (
|
|
737
|
+
/* GraphQL */
|
|
738
|
+
`
|
|
714
739
|
mutation CartLineUpdate(
|
|
715
740
|
$cartId: ID!
|
|
716
741
|
$lines: [CartLineUpdateInput!]!
|
|
@@ -725,8 +750,11 @@
|
|
|
725
750
|
}
|
|
726
751
|
|
|
727
752
|
${cartFragment}
|
|
728
|
-
|
|
729
|
-
|
|
753
|
+
`
|
|
754
|
+
);
|
|
755
|
+
const CartNoteUpdate = (cartFragment) => (
|
|
756
|
+
/* GraphQL */
|
|
757
|
+
`
|
|
730
758
|
mutation CartNoteUpdate(
|
|
731
759
|
$cartId: ID!
|
|
732
760
|
$note: String
|
|
@@ -741,8 +769,11 @@
|
|
|
741
769
|
}
|
|
742
770
|
|
|
743
771
|
${cartFragment}
|
|
744
|
-
|
|
745
|
-
|
|
772
|
+
`
|
|
773
|
+
);
|
|
774
|
+
const CartBuyerIdentityUpdate = (cartFragment) => (
|
|
775
|
+
/* GraphQL */
|
|
776
|
+
`
|
|
746
777
|
mutation CartBuyerIdentityUpdate(
|
|
747
778
|
$cartId: ID!
|
|
748
779
|
$buyerIdentity: CartBuyerIdentityInput!
|
|
@@ -757,8 +788,11 @@
|
|
|
757
788
|
}
|
|
758
789
|
|
|
759
790
|
${cartFragment}
|
|
760
|
-
|
|
761
|
-
|
|
791
|
+
`
|
|
792
|
+
);
|
|
793
|
+
const CartAttributesUpdate = (cartFragment) => (
|
|
794
|
+
/* GraphQL */
|
|
795
|
+
`
|
|
762
796
|
mutation CartAttributesUpdate(
|
|
763
797
|
$attributes: [AttributeInput!]!
|
|
764
798
|
$cartId: ID!
|
|
@@ -773,8 +807,11 @@
|
|
|
773
807
|
}
|
|
774
808
|
|
|
775
809
|
${cartFragment}
|
|
776
|
-
|
|
777
|
-
|
|
810
|
+
`
|
|
811
|
+
);
|
|
812
|
+
const CartDiscountCodesUpdate = (cartFragment) => (
|
|
813
|
+
/* GraphQL */
|
|
814
|
+
`
|
|
778
815
|
mutation CartDiscountCodesUpdate(
|
|
779
816
|
$cartId: ID!
|
|
780
817
|
$discountCodes: [String!]
|
|
@@ -789,8 +826,11 @@
|
|
|
789
826
|
}
|
|
790
827
|
|
|
791
828
|
${cartFragment}
|
|
792
|
-
|
|
793
|
-
|
|
829
|
+
`
|
|
830
|
+
);
|
|
831
|
+
const CartQuery = (cartFragment) => (
|
|
832
|
+
/* GraphQL */
|
|
833
|
+
`
|
|
794
834
|
query CartQuery(
|
|
795
835
|
$id: ID!
|
|
796
836
|
$numCartLines: Int = 250
|
|
@@ -802,8 +842,11 @@
|
|
|
802
842
|
}
|
|
803
843
|
|
|
804
844
|
${cartFragment}
|
|
805
|
-
|
|
806
|
-
|
|
845
|
+
`
|
|
846
|
+
);
|
|
847
|
+
const defaultCartFragment = (
|
|
848
|
+
/* GraphQL */
|
|
849
|
+
`
|
|
807
850
|
fragment CartFragment on Cart {
|
|
808
851
|
id
|
|
809
852
|
checkoutUrl
|
|
@@ -846,17 +889,9 @@
|
|
|
846
889
|
compareAtPrice {
|
|
847
890
|
...MoneyFragment
|
|
848
891
|
}
|
|
849
|
-
# @deprecated remove in next major
|
|
850
|
-
compareAtPriceV2 {
|
|
851
|
-
...MoneyFragment
|
|
852
|
-
}
|
|
853
892
|
price {
|
|
854
893
|
...MoneyFragment
|
|
855
894
|
}
|
|
856
|
-
# @deprecated remove in next major
|
|
857
|
-
priceV2 {
|
|
858
|
-
...MoneyFragment
|
|
859
|
-
}
|
|
860
895
|
requiresShipping
|
|
861
896
|
title
|
|
862
897
|
image {
|
|
@@ -911,15 +946,9 @@
|
|
|
911
946
|
width
|
|
912
947
|
height
|
|
913
948
|
}
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
const
|
|
917
|
-
const warnOnce = (string) => {
|
|
918
|
-
if (!warnings.has(string)) {
|
|
919
|
-
console.warn(string);
|
|
920
|
-
warnings.add(string);
|
|
921
|
-
}
|
|
922
|
-
};
|
|
949
|
+
`
|
|
950
|
+
);
|
|
951
|
+
const SFAPI_VERSION = "2023-01";
|
|
923
952
|
function createStorefrontClient({
|
|
924
953
|
storeDomain,
|
|
925
954
|
privateStorefrontToken,
|
|
@@ -929,7 +958,7 @@
|
|
|
929
958
|
}) {
|
|
930
959
|
if (storefrontApiVersion !== SFAPI_VERSION) {
|
|
931
960
|
warnOnce(
|
|
932
|
-
`StorefrontClient: The Storefront API version that you're using is different than the version this build of Hydrogen
|
|
961
|
+
`StorefrontClient: The Storefront API version that you're using is different than the version this build of Hydrogen React is targeting. You may run into unexpected errors if these versions don't match. Received verion: "${storefrontApiVersion}"; expected version "${SFAPI_VERSION}"`
|
|
933
962
|
);
|
|
934
963
|
}
|
|
935
964
|
if (!privateStorefrontToken && !globalThis.document) {
|
|
@@ -944,15 +973,13 @@
|
|
|
944
973
|
}
|
|
945
974
|
return {
|
|
946
975
|
getShopifyDomain(overrideProps) {
|
|
947
|
-
|
|
948
|
-
return `https://${(_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : storeDomain}.myshopify.com`;
|
|
976
|
+
return (overrideProps == null ? void 0 : overrideProps.storeDomain) ?? storeDomain;
|
|
949
977
|
},
|
|
950
978
|
getStorefrontApiUrl(overrideProps) {
|
|
951
|
-
|
|
952
|
-
return
|
|
979
|
+
const finalDomainUrl = (overrideProps == null ? void 0 : overrideProps.storeDomain) ?? storeDomain;
|
|
980
|
+
return `${finalDomainUrl}${finalDomainUrl.endsWith("/") ? "" : "/"}api/${(overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) ?? storefrontApiVersion}/graphql.json`;
|
|
953
981
|
},
|
|
954
982
|
getPrivateTokenHeaders(overrideProps) {
|
|
955
|
-
var _a, _b, _c;
|
|
956
983
|
if (!privateStorefrontToken && !(overrideProps == null ? void 0 : overrideProps.privateStorefrontToken)) {
|
|
957
984
|
throw new Error(
|
|
958
985
|
`StorefrontClient: You did not pass in a 'privateStorefrontToken' while using 'getPrivateTokenHeaders()'`
|
|
@@ -963,53 +990,55 @@
|
|
|
963
990
|
`StorefrontClient: it is recommended to pass in the 'buyerIp' property which improves analytics and data in the admin.`
|
|
964
991
|
);
|
|
965
992
|
}
|
|
966
|
-
const finalContentType = (
|
|
993
|
+
const finalContentType = (overrideProps == null ? void 0 : overrideProps.contentType) ?? contentType;
|
|
967
994
|
return {
|
|
995
|
+
// default to json
|
|
968
996
|
"content-type": finalContentType === "graphql" ? "application/graphql" : "application/json",
|
|
969
|
-
"X-SDK-Variant": "hydrogen-
|
|
997
|
+
"X-SDK-Variant": "hydrogen-react",
|
|
970
998
|
"X-SDK-Variant-Source": "react",
|
|
971
999
|
"X-SDK-Version": storefrontApiVersion,
|
|
972
|
-
"Shopify-Storefront-Private-Token": (
|
|
1000
|
+
"Shopify-Storefront-Private-Token": (overrideProps == null ? void 0 : overrideProps.privateStorefrontToken) ?? privateStorefrontToken ?? "",
|
|
973
1001
|
...(overrideProps == null ? void 0 : overrideProps.buyerIp) ? { "Shopify-Storefront-Buyer-IP": overrideProps.buyerIp } : {}
|
|
974
1002
|
};
|
|
975
1003
|
},
|
|
976
1004
|
getPublicTokenHeaders(overrideProps) {
|
|
977
|
-
var _a, _b, _c, _d;
|
|
978
1005
|
if (!publicStorefrontToken && !(overrideProps == null ? void 0 : overrideProps.publicStorefrontToken)) {
|
|
979
1006
|
throw new Error(
|
|
980
1007
|
`StorefrontClient: You did not pass in a 'publicStorefrontToken' while using 'getPublicTokenHeaders()'`
|
|
981
1008
|
);
|
|
982
1009
|
}
|
|
983
|
-
const finalContentType = (
|
|
1010
|
+
const finalContentType = (overrideProps == null ? void 0 : overrideProps.contentType) ?? contentType ?? "json";
|
|
984
1011
|
return getPublicTokenHeadersRaw(
|
|
985
1012
|
finalContentType,
|
|
986
1013
|
storefrontApiVersion,
|
|
987
|
-
(
|
|
1014
|
+
(overrideProps == null ? void 0 : overrideProps.publicStorefrontToken) ?? publicStorefrontToken ?? ""
|
|
988
1015
|
);
|
|
989
1016
|
}
|
|
990
1017
|
};
|
|
991
1018
|
}
|
|
992
1019
|
function getPublicTokenHeadersRaw(contentType, storefrontApiVersion, accessToken) {
|
|
993
1020
|
return {
|
|
1021
|
+
// default to json
|
|
994
1022
|
"content-type": contentType === "graphql" ? "application/graphql" : "application/json",
|
|
995
|
-
"X-SDK-Variant": "hydrogen-
|
|
1023
|
+
"X-SDK-Variant": "hydrogen-react",
|
|
996
1024
|
"X-SDK-Variant-Source": "react",
|
|
997
1025
|
"X-SDK-Version": storefrontApiVersion,
|
|
998
1026
|
"X-Shopify-Storefront-Access-Token": accessToken
|
|
999
1027
|
};
|
|
1000
1028
|
}
|
|
1001
|
-
|
|
1029
|
+
const warnings = /* @__PURE__ */ new Set();
|
|
1030
|
+
const warnOnce = (string) => {
|
|
1031
|
+
if (!warnings.has(string)) {
|
|
1032
|
+
console.warn(string);
|
|
1033
|
+
warnings.add(string);
|
|
1034
|
+
}
|
|
1035
|
+
};
|
|
1002
1036
|
const ShopifyContext = React.createContext({
|
|
1003
1037
|
storeDomain: "test",
|
|
1004
1038
|
storefrontToken: "abc123",
|
|
1005
1039
|
storefrontApiVersion: SFAPI_VERSION,
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
},
|
|
1009
|
-
language: {
|
|
1010
|
-
isoCode: "EN"
|
|
1011
|
-
},
|
|
1012
|
-
locale: "EN-US",
|
|
1040
|
+
countryIsoCode: "US",
|
|
1041
|
+
languageIsoCode: "EN",
|
|
1013
1042
|
getStorefrontApiUrl() {
|
|
1014
1043
|
return "";
|
|
1015
1044
|
},
|
|
@@ -1022,57 +1051,41 @@
|
|
|
1022
1051
|
});
|
|
1023
1052
|
function ShopifyProvider({
|
|
1024
1053
|
children,
|
|
1025
|
-
shopifyConfig
|
|
1054
|
+
...shopifyConfig
|
|
1026
1055
|
}) {
|
|
1027
|
-
if (!shopifyConfig) {
|
|
1028
|
-
throw new Error(
|
|
1056
|
+
if (!shopifyConfig.countryIsoCode || !shopifyConfig.languageIsoCode || !shopifyConfig.storeDomain || !shopifyConfig.storefrontToken || !shopifyConfig.storefrontApiVersion) {
|
|
1057
|
+
throw new Error(
|
|
1058
|
+
`Please provide the necessary props to '<ShopifyProvider/>'`
|
|
1059
|
+
);
|
|
1029
1060
|
}
|
|
1030
1061
|
if (shopifyConfig.storefrontApiVersion !== SFAPI_VERSION) {
|
|
1031
|
-
console.warn(
|
|
1062
|
+
console.warn(
|
|
1063
|
+
`<ShopifyProvider/>: This version of Hydrogen React is built for Shopify's Storefront API version ${SFAPI_VERSION}, but it looks like you're using version ${shopifyConfig.storefrontApiVersion}. There may be issues or bugs if you use a mismatched version of Hydrogen React and the Storefront API.`
|
|
1064
|
+
);
|
|
1032
1065
|
}
|
|
1033
1066
|
const finalConfig = React.useMemo(() => {
|
|
1034
|
-
const storeDomain = shopifyConfig.storeDomain.replace(/^https?:\/\//, "");
|
|
1035
|
-
if (storeDomain.includes(".myshopify.com")) {
|
|
1036
|
-
{
|
|
1037
|
-
console.warn(`<ShopifyProvider/>: passing a 'storeDomain' prop that includes '.myshopify.com' will be unsupported in the future. Passing only the subdomain (for example, if the URL is 'test.myshopify.com', passing in 'test') will be the supported way going forward.`);
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
1067
|
function getShopifyDomain(overrideProps) {
|
|
1041
|
-
|
|
1042
|
-
let subDomain = (_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : storeDomain;
|
|
1043
|
-
subDomain = subDomain.replace(".myshopify.com", "");
|
|
1044
|
-
return `https://${subDomain}.myshopify.com`;
|
|
1068
|
+
return (overrideProps == null ? void 0 : overrideProps.storeDomain) ?? shopifyConfig.storeDomain;
|
|
1045
1069
|
}
|
|
1046
1070
|
return {
|
|
1047
1071
|
...shopifyConfig,
|
|
1048
|
-
storeDomain,
|
|
1049
1072
|
getPublicTokenHeaders(overrideProps) {
|
|
1050
|
-
|
|
1051
|
-
|
|
1073
|
+
return getPublicTokenHeadersRaw(
|
|
1074
|
+
overrideProps.contentType,
|
|
1075
|
+
shopifyConfig.storefrontApiVersion,
|
|
1076
|
+
overrideProps.storefrontToken ?? shopifyConfig.storefrontToken
|
|
1077
|
+
);
|
|
1052
1078
|
},
|
|
1053
1079
|
getShopifyDomain,
|
|
1054
1080
|
getStorefrontApiUrl(overrideProps) {
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
return `${getShopifyDomain({
|
|
1062
|
-
storeDomain: (_b = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _b : storeDomain
|
|
1063
|
-
})}/api/${(_c = overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) != null ? _c : shopifyConfig.storefrontApiVersion}/graphql.json`;
|
|
1081
|
+
const finalDomainUrl = getShopifyDomain({
|
|
1082
|
+
storeDomain: (overrideProps == null ? void 0 : overrideProps.storeDomain) ?? shopifyConfig.storeDomain
|
|
1083
|
+
});
|
|
1084
|
+
return `${finalDomainUrl}${finalDomainUrl.endsWith("/") ? "" : "/"}api/${(overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) ?? shopifyConfig.storefrontApiVersion}/graphql.json`;
|
|
1064
1085
|
}
|
|
1065
1086
|
};
|
|
1066
1087
|
}, [shopifyConfig]);
|
|
1067
|
-
return /* @__PURE__ */
|
|
1068
|
-
value: finalConfig,
|
|
1069
|
-
__self: this,
|
|
1070
|
-
__source: {
|
|
1071
|
-
fileName: _jsxFileName$f,
|
|
1072
|
-
lineNumber: 99,
|
|
1073
|
-
columnNumber: 5
|
|
1074
|
-
}
|
|
1075
|
-
}, children);
|
|
1088
|
+
return /* @__PURE__ */ React.createElement(ShopifyContext.Provider, { value: finalConfig }, children);
|
|
1076
1089
|
}
|
|
1077
1090
|
function useShop() {
|
|
1078
1091
|
const shopContext = React.useContext(ShopifyContext);
|
|
@@ -1110,41 +1123,82 @@
|
|
|
1110
1123
|
(s2 = t2.trim().toLowerCase()) && (s2 === "httponly" || s2 === "secure") && (r2[s2] = true);
|
|
1111
1124
|
return r2;
|
|
1112
1125
|
}
|
|
1126
|
+
function l(a2, r2, e2 = {}) {
|
|
1127
|
+
let t2 = a2 + "=" + encodeURIComponent(r2);
|
|
1128
|
+
return e2.expires && (t2 += "; Expires=" + new Date(e2.expires).toUTCString()), e2.maxage != null && e2.maxage >= 0 && (t2 += "; Max-Age=" + (e2.maxage | 0)), e2.domain && (t2 += "; Domain=" + e2.domain), e2.path && (t2 += "; Path=" + e2.path), e2.samesite && (t2 += "; SameSite=" + e2.samesite), (e2.secure || e2.samesite === "None") && (t2 += "; Secure"), e2.httponly && (t2 += "; HttpOnly"), t2;
|
|
1129
|
+
}
|
|
1130
|
+
const tokenHash = "xxxx-4xxx-xxxx-xxxxxxxxxxxx";
|
|
1131
|
+
function buildUUID() {
|
|
1132
|
+
let hash = "";
|
|
1133
|
+
try {
|
|
1134
|
+
const crypto = window.crypto;
|
|
1135
|
+
const randomValuesArray = new Uint16Array(31);
|
|
1136
|
+
crypto.getRandomValues(randomValuesArray);
|
|
1137
|
+
let i2 = 0;
|
|
1138
|
+
hash = tokenHash.replace(/[x]/g, (c2) => {
|
|
1139
|
+
const r2 = randomValuesArray[i2] % 16;
|
|
1140
|
+
const v2 = c2 === "x" ? r2 : r2 & 3 | 8;
|
|
1141
|
+
i2++;
|
|
1142
|
+
return v2.toString(16);
|
|
1143
|
+
}).toUpperCase();
|
|
1144
|
+
} catch (err) {
|
|
1145
|
+
hash = tokenHash.replace(/[x]/g, (c2) => {
|
|
1146
|
+
const r2 = Math.random() * 16 | 0;
|
|
1147
|
+
const v2 = c2 === "x" ? r2 : r2 & 3 | 8;
|
|
1148
|
+
return v2.toString(16);
|
|
1149
|
+
}).toUpperCase();
|
|
1150
|
+
}
|
|
1151
|
+
return `${hexTime()}-${hash}`;
|
|
1152
|
+
}
|
|
1153
|
+
function hexTime() {
|
|
1154
|
+
let dateNumber = 0;
|
|
1155
|
+
let perfNumber = 0;
|
|
1156
|
+
dateNumber = new Date().getTime() >>> 0;
|
|
1157
|
+
try {
|
|
1158
|
+
perfNumber = performance.now() >>> 0;
|
|
1159
|
+
} catch (err) {
|
|
1160
|
+
perfNumber = 0;
|
|
1161
|
+
}
|
|
1162
|
+
const output = Math.abs(dateNumber + perfNumber).toString(16).toLowerCase();
|
|
1163
|
+
return output.padStart(8 - output.length, "0");
|
|
1164
|
+
}
|
|
1165
|
+
function getShopifyCookies(cookies) {
|
|
1166
|
+
const cookieData = u(cookies);
|
|
1167
|
+
return {
|
|
1168
|
+
[SHOPIFY_Y]: cookieData[SHOPIFY_Y] || "",
|
|
1169
|
+
[SHOPIFY_S]: cookieData[SHOPIFY_S] || ""
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1113
1172
|
function useCartFetch() {
|
|
1114
|
-
const {
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
});
|
|
1126
|
-
if (storefrontId) {
|
|
1127
|
-
headers[SHOPIFY_STOREFRONT_ID_HEADER] = storefrontId;
|
|
1128
|
-
}
|
|
1129
|
-
const cookieData = u(document.cookie);
|
|
1130
|
-
if (cookieData[SHOPIFY_Y] && cookieData[SHOPIFY_S]) {
|
|
1173
|
+
const { storefrontId, getPublicTokenHeaders, getStorefrontApiUrl } = useShop();
|
|
1174
|
+
return React.useCallback(
|
|
1175
|
+
({
|
|
1176
|
+
query,
|
|
1177
|
+
variables
|
|
1178
|
+
}) => {
|
|
1179
|
+
const headers = getPublicTokenHeaders({ contentType: "json" });
|
|
1180
|
+
if (storefrontId) {
|
|
1181
|
+
headers[SHOPIFY_STOREFRONT_ID_HEADER] = storefrontId;
|
|
1182
|
+
}
|
|
1183
|
+
const cookieData = getShopifyCookies(document.cookie);
|
|
1131
1184
|
headers[SHOPIFY_STOREFRONT_Y_HEADER] = cookieData[SHOPIFY_Y];
|
|
1132
1185
|
headers[SHOPIFY_STOREFRONT_S_HEADER] = cookieData[SHOPIFY_S];
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
})
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
};
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1186
|
+
return fetch(getStorefrontApiUrl(), {
|
|
1187
|
+
method: "POST",
|
|
1188
|
+
headers,
|
|
1189
|
+
body: JSON.stringify({
|
|
1190
|
+
query: query.toString(),
|
|
1191
|
+
variables
|
|
1192
|
+
})
|
|
1193
|
+
}).then((res) => res.json()).catch((error) => {
|
|
1194
|
+
return {
|
|
1195
|
+
data: void 0,
|
|
1196
|
+
errors: error.toString()
|
|
1197
|
+
};
|
|
1198
|
+
});
|
|
1199
|
+
},
|
|
1200
|
+
[getPublicTokenHeaders, storefrontId, getStorefrontApiUrl]
|
|
1201
|
+
);
|
|
1148
1202
|
}
|
|
1149
1203
|
function useCartActions({
|
|
1150
1204
|
numCartLines,
|
|
@@ -1152,155 +1206,212 @@
|
|
|
1152
1206
|
countryCode = "US"
|
|
1153
1207
|
}) {
|
|
1154
1208
|
const fetchCart = useCartFetch();
|
|
1155
|
-
const cartFetch = React.useCallback(
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1209
|
+
const cartFetch = React.useCallback(
|
|
1210
|
+
(cartId) => {
|
|
1211
|
+
return fetchCart({
|
|
1212
|
+
query: CartQuery(cartFragment),
|
|
1213
|
+
variables: {
|
|
1214
|
+
id: cartId,
|
|
1215
|
+
numCartLines,
|
|
1216
|
+
country: countryCode
|
|
1217
|
+
}
|
|
1218
|
+
});
|
|
1219
|
+
},
|
|
1220
|
+
[fetchCart, cartFragment, numCartLines, countryCode]
|
|
1221
|
+
);
|
|
1222
|
+
const cartCreate = React.useCallback(
|
|
1223
|
+
(cart) => {
|
|
1224
|
+
return fetchCart({
|
|
1225
|
+
query: CartCreate(cartFragment),
|
|
1226
|
+
variables: {
|
|
1227
|
+
input: cart,
|
|
1228
|
+
numCartLines,
|
|
1229
|
+
country: countryCode
|
|
1230
|
+
}
|
|
1231
|
+
});
|
|
1232
|
+
},
|
|
1233
|
+
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1234
|
+
);
|
|
1235
|
+
const cartLineAdd = React.useCallback(
|
|
1236
|
+
(cartId, lines) => {
|
|
1237
|
+
return fetchCart({
|
|
1238
|
+
query: CartLineAdd(cartFragment),
|
|
1239
|
+
variables: {
|
|
1240
|
+
cartId,
|
|
1241
|
+
lines,
|
|
1242
|
+
numCartLines,
|
|
1243
|
+
country: countryCode
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
},
|
|
1247
|
+
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1248
|
+
);
|
|
1249
|
+
const cartLineUpdate = React.useCallback(
|
|
1250
|
+
(cartId, lines) => {
|
|
1251
|
+
return fetchCart({
|
|
1252
|
+
query: CartLineUpdate(cartFragment),
|
|
1253
|
+
variables: {
|
|
1254
|
+
cartId,
|
|
1255
|
+
lines,
|
|
1256
|
+
numCartLines,
|
|
1257
|
+
country: countryCode
|
|
1258
|
+
}
|
|
1259
|
+
});
|
|
1260
|
+
},
|
|
1261
|
+
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1262
|
+
);
|
|
1263
|
+
const cartLineRemove = React.useCallback(
|
|
1264
|
+
(cartId, lines) => {
|
|
1265
|
+
return fetchCart({
|
|
1266
|
+
query: CartLineRemove(cartFragment),
|
|
1267
|
+
variables: {
|
|
1268
|
+
cartId,
|
|
1269
|
+
lines,
|
|
1270
|
+
numCartLines,
|
|
1271
|
+
country: countryCode
|
|
1272
|
+
}
|
|
1273
|
+
});
|
|
1274
|
+
},
|
|
1275
|
+
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1276
|
+
);
|
|
1277
|
+
const noteUpdate = React.useCallback(
|
|
1278
|
+
(cartId, note) => {
|
|
1279
|
+
return fetchCart({
|
|
1280
|
+
query: CartNoteUpdate(cartFragment),
|
|
1281
|
+
variables: {
|
|
1282
|
+
cartId,
|
|
1283
|
+
note,
|
|
1284
|
+
numCartLines,
|
|
1285
|
+
country: countryCode
|
|
1286
|
+
}
|
|
1287
|
+
});
|
|
1288
|
+
},
|
|
1289
|
+
[fetchCart, cartFragment, numCartLines, countryCode]
|
|
1290
|
+
);
|
|
1291
|
+
const buyerIdentityUpdate = React.useCallback(
|
|
1292
|
+
(cartId, buyerIdentity) => {
|
|
1293
|
+
return fetchCart({
|
|
1294
|
+
query: CartBuyerIdentityUpdate(cartFragment),
|
|
1295
|
+
variables: {
|
|
1296
|
+
cartId,
|
|
1297
|
+
buyerIdentity,
|
|
1298
|
+
numCartLines,
|
|
1299
|
+
country: countryCode
|
|
1300
|
+
}
|
|
1301
|
+
});
|
|
1302
|
+
},
|
|
1303
|
+
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1304
|
+
);
|
|
1305
|
+
const cartAttributesUpdate = React.useCallback(
|
|
1306
|
+
(cartId, attributes) => {
|
|
1307
|
+
return fetchCart({
|
|
1308
|
+
query: CartAttributesUpdate(cartFragment),
|
|
1309
|
+
variables: {
|
|
1310
|
+
cartId,
|
|
1311
|
+
attributes,
|
|
1312
|
+
numCartLines,
|
|
1313
|
+
country: countryCode
|
|
1314
|
+
}
|
|
1315
|
+
});
|
|
1316
|
+
},
|
|
1317
|
+
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1318
|
+
);
|
|
1319
|
+
const discountCodesUpdate = React.useCallback(
|
|
1320
|
+
(cartId, discountCodes) => {
|
|
1321
|
+
return fetchCart({
|
|
1322
|
+
query: CartDiscountCodesUpdate(cartFragment),
|
|
1323
|
+
variables: {
|
|
1324
|
+
cartId,
|
|
1325
|
+
discountCodes,
|
|
1326
|
+
numCartLines,
|
|
1327
|
+
country: countryCode
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1330
|
+
},
|
|
1331
|
+
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1332
|
+
);
|
|
1333
|
+
return React.useMemo(
|
|
1334
|
+
() => ({
|
|
1335
|
+
cartFetch,
|
|
1336
|
+
cartCreate,
|
|
1337
|
+
cartLineAdd,
|
|
1338
|
+
cartLineUpdate,
|
|
1339
|
+
cartLineRemove,
|
|
1340
|
+
noteUpdate,
|
|
1341
|
+
buyerIdentityUpdate,
|
|
1342
|
+
cartAttributesUpdate,
|
|
1343
|
+
discountCodesUpdate,
|
|
1344
|
+
cartFragment
|
|
1345
|
+
}),
|
|
1346
|
+
[
|
|
1347
|
+
cartFetch,
|
|
1348
|
+
cartCreate,
|
|
1349
|
+
cartLineAdd,
|
|
1350
|
+
cartLineUpdate,
|
|
1351
|
+
cartLineRemove,
|
|
1352
|
+
noteUpdate,
|
|
1353
|
+
buyerIdentityUpdate,
|
|
1354
|
+
cartAttributesUpdate,
|
|
1355
|
+
discountCodesUpdate,
|
|
1356
|
+
cartFragment
|
|
1357
|
+
]
|
|
1358
|
+
);
|
|
1264
1359
|
}
|
|
1265
1360
|
function invokeCart(action, options) {
|
|
1266
1361
|
return {
|
|
1267
|
-
entry: [
|
|
1268
|
-
|
|
1269
|
-
|
|
1362
|
+
entry: [
|
|
1363
|
+
...(options == null ? void 0 : options.entryActions) || [],
|
|
1364
|
+
i({
|
|
1365
|
+
lastValidCart: (context) => context == null ? void 0 : context.cart
|
|
1366
|
+
}),
|
|
1367
|
+
"onCartActionEntry",
|
|
1368
|
+
"onCartActionOptimisticUI",
|
|
1369
|
+
action
|
|
1370
|
+
],
|
|
1270
1371
|
on: {
|
|
1271
1372
|
RESOLVE: {
|
|
1272
1373
|
target: (options == null ? void 0 : options.resolveTarget) || "idle",
|
|
1273
|
-
actions: [
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1374
|
+
actions: [
|
|
1375
|
+
i({
|
|
1376
|
+
prevCart: (context) => context == null ? void 0 : context.lastValidCart,
|
|
1377
|
+
cart: (_, event) => {
|
|
1378
|
+
var _a;
|
|
1379
|
+
return (_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.cart;
|
|
1380
|
+
},
|
|
1381
|
+
rawCartResult: (_, event) => {
|
|
1382
|
+
var _a;
|
|
1383
|
+
return (_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.rawCartResult;
|
|
1384
|
+
},
|
|
1385
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1386
|
+
errors: (_) => void 0
|
|
1387
|
+
})
|
|
1388
|
+
]
|
|
1285
1389
|
},
|
|
1286
1390
|
ERROR: {
|
|
1287
1391
|
target: (options == null ? void 0 : options.errorTarget) || "error",
|
|
1288
|
-
actions: [
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1392
|
+
actions: [
|
|
1393
|
+
i({
|
|
1394
|
+
prevCart: (context) => context == null ? void 0 : context.lastValidCart,
|
|
1395
|
+
cart: (context) => context == null ? void 0 : context.lastValidCart,
|
|
1396
|
+
errors: (_, event) => {
|
|
1397
|
+
var _a;
|
|
1398
|
+
return (_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.errors;
|
|
1399
|
+
}
|
|
1400
|
+
})
|
|
1401
|
+
]
|
|
1296
1402
|
},
|
|
1297
1403
|
CART_COMPLETED: {
|
|
1298
1404
|
target: "cartCompleted",
|
|
1299
1405
|
actions: i({
|
|
1406
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1300
1407
|
prevCart: (_) => void 0,
|
|
1408
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1301
1409
|
cart: (_) => void 0,
|
|
1410
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1302
1411
|
lastValidCart: (_) => void 0,
|
|
1412
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1303
1413
|
rawCartResult: (_) => void 0,
|
|
1414
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1304
1415
|
errors: (_) => void 0
|
|
1305
1416
|
})
|
|
1306
1417
|
}
|
|
@@ -1317,10 +1428,12 @@
|
|
|
1317
1428
|
},
|
|
1318
1429
|
CART_SET: {
|
|
1319
1430
|
target: "idle",
|
|
1320
|
-
actions: [
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1431
|
+
actions: [
|
|
1432
|
+
i({
|
|
1433
|
+
rawCartResult: (_, event) => event.payload.cart,
|
|
1434
|
+
cart: (_, event) => cartFromGraphQL(event.payload.cart)
|
|
1435
|
+
})
|
|
1436
|
+
]
|
|
1324
1437
|
}
|
|
1325
1438
|
};
|
|
1326
1439
|
const UPDATING_CART_EVENTS = {
|
|
@@ -1364,16 +1477,10 @@
|
|
|
1364
1477
|
on: INITIALIZING_CART_EVENTS
|
|
1365
1478
|
},
|
|
1366
1479
|
idle: {
|
|
1367
|
-
on: {
|
|
1368
|
-
...INITIALIZING_CART_EVENTS,
|
|
1369
|
-
...UPDATING_CART_EVENTS
|
|
1370
|
-
}
|
|
1480
|
+
on: { ...INITIALIZING_CART_EVENTS, ...UPDATING_CART_EVENTS }
|
|
1371
1481
|
},
|
|
1372
1482
|
error: {
|
|
1373
|
-
on: {
|
|
1374
|
-
...INITIALIZING_CART_EVENTS,
|
|
1375
|
-
...UPDATING_CART_EVENTS
|
|
1376
|
-
}
|
|
1483
|
+
on: { ...INITIALIZING_CART_EVENTS, ...UPDATING_CART_EVENTS }
|
|
1377
1484
|
},
|
|
1378
1485
|
cartFetching: invokeCart("cartFetchAction", {
|
|
1379
1486
|
errorTarget: "initializationError"
|
|
@@ -1422,10 +1529,7 @@
|
|
|
1422
1529
|
var _a;
|
|
1423
1530
|
if (event.type !== "CART_FETCH")
|
|
1424
1531
|
return;
|
|
1425
|
-
const {
|
|
1426
|
-
data,
|
|
1427
|
-
errors
|
|
1428
|
-
} = await cartFetch((_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.cartId);
|
|
1532
|
+
const { data, errors } = await cartFetch((_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.cartId);
|
|
1429
1533
|
const resultEvent = eventFromFetchResult(event, data == null ? void 0 : data.cart, errors);
|
|
1430
1534
|
send(resultEvent);
|
|
1431
1535
|
},
|
|
@@ -1433,88 +1537,117 @@
|
|
|
1433
1537
|
var _a;
|
|
1434
1538
|
if (event.type !== "CART_CREATE")
|
|
1435
1539
|
return;
|
|
1436
|
-
const {
|
|
1437
|
-
|
|
1540
|
+
const { data, errors } = await cartCreate(event == null ? void 0 : event.payload);
|
|
1541
|
+
const resultEvent = eventFromFetchResult(
|
|
1542
|
+
event,
|
|
1543
|
+
(_a = data == null ? void 0 : data.cartCreate) == null ? void 0 : _a.cart,
|
|
1438
1544
|
errors
|
|
1439
|
-
|
|
1440
|
-
const resultEvent = eventFromFetchResult(event, (_a = data == null ? void 0 : data.cartCreate) == null ? void 0 : _a.cart, errors);
|
|
1545
|
+
);
|
|
1441
1546
|
send(resultEvent);
|
|
1442
1547
|
},
|
|
1443
1548
|
cartLineAddAction: async (context, event) => {
|
|
1444
1549
|
var _a, _b;
|
|
1445
1550
|
if (event.type !== "CARTLINE_ADD" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
1446
1551
|
return;
|
|
1447
|
-
const {
|
|
1448
|
-
|
|
1552
|
+
const { data, errors } = await cartLineAdd(
|
|
1553
|
+
context.cart.id,
|
|
1554
|
+
event.payload.lines
|
|
1555
|
+
);
|
|
1556
|
+
const resultEvent = eventFromFetchResult(
|
|
1557
|
+
event,
|
|
1558
|
+
(_b = data == null ? void 0 : data.cartLinesAdd) == null ? void 0 : _b.cart,
|
|
1449
1559
|
errors
|
|
1450
|
-
|
|
1451
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartLinesAdd) == null ? void 0 : _b.cart, errors);
|
|
1560
|
+
);
|
|
1452
1561
|
send(resultEvent);
|
|
1453
1562
|
},
|
|
1454
1563
|
cartLineUpdateAction: async (context, event) => {
|
|
1455
1564
|
var _a, _b;
|
|
1456
1565
|
if (event.type !== "CARTLINE_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
1457
1566
|
return;
|
|
1458
|
-
const {
|
|
1459
|
-
|
|
1567
|
+
const { data, errors } = await cartLineUpdate(
|
|
1568
|
+
context.cart.id,
|
|
1569
|
+
event.payload.lines
|
|
1570
|
+
);
|
|
1571
|
+
const resultEvent = eventFromFetchResult(
|
|
1572
|
+
event,
|
|
1573
|
+
(_b = data == null ? void 0 : data.cartLinesUpdate) == null ? void 0 : _b.cart,
|
|
1460
1574
|
errors
|
|
1461
|
-
|
|
1462
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartLinesUpdate) == null ? void 0 : _b.cart, errors);
|
|
1575
|
+
);
|
|
1463
1576
|
send(resultEvent);
|
|
1464
1577
|
},
|
|
1465
1578
|
cartLineRemoveAction: async (context, event) => {
|
|
1466
1579
|
var _a, _b;
|
|
1467
1580
|
if (event.type !== "CARTLINE_REMOVE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
1468
1581
|
return;
|
|
1469
|
-
const {
|
|
1470
|
-
|
|
1582
|
+
const { data, errors } = await cartLineRemove(
|
|
1583
|
+
context.cart.id,
|
|
1584
|
+
event.payload.lines
|
|
1585
|
+
);
|
|
1586
|
+
const resultEvent = eventFromFetchResult(
|
|
1587
|
+
event,
|
|
1588
|
+
(_b = data == null ? void 0 : data.cartLinesRemove) == null ? void 0 : _b.cart,
|
|
1471
1589
|
errors
|
|
1472
|
-
|
|
1473
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartLinesRemove) == null ? void 0 : _b.cart, errors);
|
|
1590
|
+
);
|
|
1474
1591
|
send(resultEvent);
|
|
1475
1592
|
},
|
|
1476
1593
|
noteUpdateAction: async (context, event) => {
|
|
1477
1594
|
var _a, _b;
|
|
1478
1595
|
if (event.type !== "NOTE_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
1479
1596
|
return;
|
|
1480
|
-
const {
|
|
1481
|
-
|
|
1597
|
+
const { data, errors } = await noteUpdate(
|
|
1598
|
+
context.cart.id,
|
|
1599
|
+
event.payload.note
|
|
1600
|
+
);
|
|
1601
|
+
const resultEvent = eventFromFetchResult(
|
|
1602
|
+
event,
|
|
1603
|
+
(_b = data == null ? void 0 : data.cartNoteUpdate) == null ? void 0 : _b.cart,
|
|
1482
1604
|
errors
|
|
1483
|
-
|
|
1484
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartNoteUpdate) == null ? void 0 : _b.cart, errors);
|
|
1605
|
+
);
|
|
1485
1606
|
send(resultEvent);
|
|
1486
1607
|
},
|
|
1487
1608
|
buyerIdentityUpdateAction: async (context, event) => {
|
|
1488
1609
|
var _a, _b;
|
|
1489
1610
|
if (event.type !== "BUYER_IDENTITY_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
1490
1611
|
return;
|
|
1491
|
-
const {
|
|
1492
|
-
|
|
1612
|
+
const { data, errors } = await buyerIdentityUpdate(
|
|
1613
|
+
context.cart.id,
|
|
1614
|
+
event.payload.buyerIdentity
|
|
1615
|
+
);
|
|
1616
|
+
const resultEvent = eventFromFetchResult(
|
|
1617
|
+
event,
|
|
1618
|
+
(_b = data == null ? void 0 : data.cartBuyerIdentityUpdate) == null ? void 0 : _b.cart,
|
|
1493
1619
|
errors
|
|
1494
|
-
|
|
1495
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartBuyerIdentityUpdate) == null ? void 0 : _b.cart, errors);
|
|
1620
|
+
);
|
|
1496
1621
|
send(resultEvent);
|
|
1497
1622
|
},
|
|
1498
1623
|
cartAttributesUpdateAction: async (context, event) => {
|
|
1499
1624
|
var _a, _b;
|
|
1500
1625
|
if (event.type !== "CART_ATTRIBUTES_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
1501
1626
|
return;
|
|
1502
|
-
const {
|
|
1503
|
-
|
|
1627
|
+
const { data, errors } = await cartAttributesUpdate(
|
|
1628
|
+
context.cart.id,
|
|
1629
|
+
event.payload.attributes
|
|
1630
|
+
);
|
|
1631
|
+
const resultEvent = eventFromFetchResult(
|
|
1632
|
+
event,
|
|
1633
|
+
(_b = data == null ? void 0 : data.cartAttributesUpdate) == null ? void 0 : _b.cart,
|
|
1504
1634
|
errors
|
|
1505
|
-
|
|
1506
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartAttributesUpdate) == null ? void 0 : _b.cart, errors);
|
|
1635
|
+
);
|
|
1507
1636
|
send(resultEvent);
|
|
1508
1637
|
},
|
|
1509
1638
|
discountCodesUpdateAction: async (context, event) => {
|
|
1510
1639
|
var _a, _b;
|
|
1511
1640
|
if (event.type !== "DISCOUNT_CODES_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
1512
1641
|
return;
|
|
1513
|
-
const {
|
|
1514
|
-
|
|
1642
|
+
const { data, errors } = await discountCodesUpdate(
|
|
1643
|
+
context.cart.id,
|
|
1644
|
+
event.payload.discountCodes
|
|
1645
|
+
);
|
|
1646
|
+
const resultEvent = eventFromFetchResult(
|
|
1647
|
+
event,
|
|
1648
|
+
(_b = data == null ? void 0 : data.cartDiscountCodesUpdate) == null ? void 0 : _b.cart,
|
|
1515
1649
|
errors
|
|
1516
|
-
|
|
1517
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartDiscountCodesUpdate) == null ? void 0 : _b.cart, errors);
|
|
1650
|
+
);
|
|
1518
1651
|
send(resultEvent);
|
|
1519
1652
|
},
|
|
1520
1653
|
...onCartActionEntry && {
|
|
@@ -1541,22 +1674,15 @@
|
|
|
1541
1674
|
return React.useMemo(() => [state, send, service], [state, send, service]);
|
|
1542
1675
|
}
|
|
1543
1676
|
function cartFromGraphQL(cart) {
|
|
1544
|
-
var _a;
|
|
1545
1677
|
return {
|
|
1546
1678
|
...cart,
|
|
1547
1679
|
lines: flattenConnection(cart == null ? void 0 : cart.lines),
|
|
1548
|
-
note:
|
|
1680
|
+
note: cart.note ?? void 0
|
|
1549
1681
|
};
|
|
1550
1682
|
}
|
|
1551
1683
|
function eventFromFetchResult(cartActionEvent, cart, errors) {
|
|
1552
1684
|
if (errors) {
|
|
1553
|
-
return {
|
|
1554
|
-
type: "ERROR",
|
|
1555
|
-
payload: {
|
|
1556
|
-
errors,
|
|
1557
|
-
cartActionEvent
|
|
1558
|
-
}
|
|
1559
|
-
};
|
|
1685
|
+
return { type: "ERROR", payload: { errors, cartActionEvent } };
|
|
1560
1686
|
}
|
|
1561
1687
|
if (!cart) {
|
|
1562
1688
|
return {
|
|
@@ -1581,7 +1707,6 @@
|
|
|
1581
1707
|
function isCartFetchResultEvent(event) {
|
|
1582
1708
|
return event.type === "RESOLVE" || event.type === "ERROR" || event.type === "CART_COMPLETED";
|
|
1583
1709
|
}
|
|
1584
|
-
var _jsxFileName$e = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/CartProvider.tsx";
|
|
1585
1710
|
const CartContext = React.createContext(null);
|
|
1586
1711
|
function useCart() {
|
|
1587
1712
|
const context = React.useContext(CartContext);
|
|
@@ -1657,16 +1782,16 @@
|
|
|
1657
1782
|
onCartActionOptimisticUI(context, event) {
|
|
1658
1783
|
var _a2, _b2, _c2, _d2;
|
|
1659
1784
|
if (!context.cart)
|
|
1660
|
-
return {
|
|
1661
|
-
...context
|
|
1662
|
-
};
|
|
1785
|
+
return { ...context };
|
|
1663
1786
|
switch (event.type) {
|
|
1664
1787
|
case "CARTLINE_REMOVE":
|
|
1665
1788
|
return {
|
|
1666
1789
|
...context,
|
|
1667
1790
|
cart: {
|
|
1668
1791
|
...context.cart,
|
|
1669
|
-
lines: (_b2 = (_a2 = context == null ? void 0 : context.cart) == null ? void 0 : _a2.lines) == null ? void 0 : _b2.filter(
|
|
1792
|
+
lines: (_b2 = (_a2 = context == null ? void 0 : context.cart) == null ? void 0 : _a2.lines) == null ? void 0 : _b2.filter(
|
|
1793
|
+
(line) => (line == null ? void 0 : line.id) && !event.payload.lines.includes(line == null ? void 0 : line.id)
|
|
1794
|
+
)
|
|
1670
1795
|
}
|
|
1671
1796
|
};
|
|
1672
1797
|
case "CARTLINE_UPDATE":
|
|
@@ -1675,9 +1800,9 @@
|
|
|
1675
1800
|
cart: {
|
|
1676
1801
|
...context.cart,
|
|
1677
1802
|
lines: (_d2 = (_c2 = context == null ? void 0 : context.cart) == null ? void 0 : _c2.lines) == null ? void 0 : _d2.map((line) => {
|
|
1678
|
-
const updatedLine = event.payload.lines.find(
|
|
1679
|
-
id
|
|
1680
|
-
|
|
1803
|
+
const updatedLine = event.payload.lines.find(
|
|
1804
|
+
({ id }) => id === (line == null ? void 0 : line.id)
|
|
1805
|
+
);
|
|
1681
1806
|
if (updatedLine && updatedLine.quantity) {
|
|
1682
1807
|
return {
|
|
1683
1808
|
...line,
|
|
@@ -1689,9 +1814,7 @@
|
|
|
1689
1814
|
}
|
|
1690
1815
|
};
|
|
1691
1816
|
}
|
|
1692
|
-
return {
|
|
1693
|
-
...context
|
|
1694
|
-
};
|
|
1817
|
+
return { ...context };
|
|
1695
1818
|
},
|
|
1696
1819
|
onCartActionComplete(context, event) {
|
|
1697
1820
|
const cartActionEvent = event.payload.cartActionEvent;
|
|
@@ -1736,12 +1859,7 @@
|
|
|
1736
1859
|
try {
|
|
1737
1860
|
const cartId = window.localStorage.getItem(CART_ID_STORAGE_KEY);
|
|
1738
1861
|
if (cartId) {
|
|
1739
|
-
cartSend({
|
|
1740
|
-
type: "CART_FETCH",
|
|
1741
|
-
payload: {
|
|
1742
|
-
cartId
|
|
1743
|
-
}
|
|
1744
|
-
});
|
|
1862
|
+
cartSend({ type: "CART_FETCH", payload: { cartId } });
|
|
1745
1863
|
}
|
|
1746
1864
|
} catch (error) {
|
|
1747
1865
|
console.warn("error fetching cartId");
|
|
@@ -1756,25 +1874,32 @@
|
|
|
1756
1874
|
return;
|
|
1757
1875
|
cartSend({
|
|
1758
1876
|
type: "BUYER_IDENTITY_UPDATE",
|
|
1759
|
-
payload: {
|
|
1760
|
-
buyerIdentity: {
|
|
1761
|
-
countryCode,
|
|
1762
|
-
customerAccessToken
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1877
|
+
payload: { buyerIdentity: { countryCode, customerAccessToken } }
|
|
1765
1878
|
});
|
|
1766
|
-
}, [
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
cartSend
|
|
1772
|
-
|
|
1879
|
+
}, [
|
|
1880
|
+
countryCode,
|
|
1881
|
+
customerAccessToken,
|
|
1882
|
+
countryChanged,
|
|
1883
|
+
customerOverridesCountryCode,
|
|
1884
|
+
cartSend
|
|
1885
|
+
]);
|
|
1886
|
+
const onCartReadySend = React.useCallback(
|
|
1887
|
+
(cartEvent) => {
|
|
1888
|
+
if (!cartReady.current) {
|
|
1889
|
+
return console.warn("Cart isn't ready yet");
|
|
1890
|
+
}
|
|
1891
|
+
cartSend(cartEvent);
|
|
1892
|
+
},
|
|
1893
|
+
[cartSend]
|
|
1894
|
+
);
|
|
1773
1895
|
React.useEffect(() => {
|
|
1774
1896
|
var _a2, _b2, _c2;
|
|
1775
1897
|
if (((_b2 = (_a2 = cartState == null ? void 0 : cartState.context) == null ? void 0 : _a2.cart) == null ? void 0 : _b2.id) && storageAvailable("localStorage")) {
|
|
1776
1898
|
try {
|
|
1777
|
-
window.localStorage.setItem(
|
|
1899
|
+
window.localStorage.setItem(
|
|
1900
|
+
CART_ID_STORAGE_KEY,
|
|
1901
|
+
(_c2 = cartState.context.cart) == null ? void 0 : _c2.id
|
|
1902
|
+
);
|
|
1778
1903
|
} catch (error) {
|
|
1779
1904
|
console.warn("Failed to save cartId to localStorage", error);
|
|
1780
1905
|
}
|
|
@@ -1789,50 +1914,46 @@
|
|
|
1789
1914
|
}
|
|
1790
1915
|
}
|
|
1791
1916
|
}, [cartCompleted]);
|
|
1792
|
-
const cartCreate = React.useCallback(
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
if (cartInput.buyerIdentity == null) {
|
|
1796
|
-
cartInput.buyerIdentity
|
|
1917
|
+
const cartCreate = React.useCallback(
|
|
1918
|
+
(cartInput) => {
|
|
1919
|
+
var _a2, _b2;
|
|
1920
|
+
if (countryCode && !((_a2 = cartInput.buyerIdentity) == null ? void 0 : _a2.countryCode)) {
|
|
1921
|
+
if (cartInput.buyerIdentity == null) {
|
|
1922
|
+
cartInput.buyerIdentity = {};
|
|
1923
|
+
}
|
|
1924
|
+
cartInput.buyerIdentity.countryCode = countryCode;
|
|
1797
1925
|
}
|
|
1798
|
-
cartInput.buyerIdentity.
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
cartInput.buyerIdentity =
|
|
1926
|
+
if (customerAccessToken && !((_b2 = cartInput.buyerIdentity) == null ? void 0 : _b2.customerAccessToken)) {
|
|
1927
|
+
if (cartInput.buyerIdentity == null) {
|
|
1928
|
+
cartInput.buyerIdentity = {};
|
|
1929
|
+
}
|
|
1930
|
+
cartInput.buyerIdentity.customerAccessToken = customerAccessToken;
|
|
1803
1931
|
}
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1932
|
+
onCartReadySend({
|
|
1933
|
+
type: "CART_CREATE",
|
|
1934
|
+
payload: cartInput
|
|
1935
|
+
});
|
|
1936
|
+
},
|
|
1937
|
+
[countryCode, customerAccessToken, onCartReadySend]
|
|
1938
|
+
);
|
|
1811
1939
|
const cartDisplayState = useDelayedStateUntilHydration(cartState);
|
|
1812
1940
|
const cartContextValue = React.useMemo(() => {
|
|
1813
|
-
var _a2, _b2, _c2, _d2
|
|
1941
|
+
var _a2, _b2, _c2, _d2;
|
|
1814
1942
|
return {
|
|
1815
|
-
...(
|
|
1816
|
-
lines: [],
|
|
1817
|
-
attributes: []
|
|
1818
|
-
},
|
|
1943
|
+
...((_a2 = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _a2.cart) ?? { lines: [], attributes: [] },
|
|
1819
1944
|
status: transposeStatus(cartDisplayState.value),
|
|
1820
|
-
error: (
|
|
1821
|
-
totalQuantity: (
|
|
1945
|
+
error: (_b2 = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _b2.errors,
|
|
1946
|
+
totalQuantity: ((_d2 = (_c2 = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _c2.cart) == null ? void 0 : _d2.totalQuantity) ?? 0,
|
|
1822
1947
|
cartCreate,
|
|
1823
1948
|
linesAdd(lines) {
|
|
1824
1949
|
var _a3, _b3;
|
|
1825
1950
|
if ((_b3 = (_a3 = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _a3.cart) == null ? void 0 : _b3.id) {
|
|
1826
1951
|
onCartReadySend({
|
|
1827
1952
|
type: "CARTLINE_ADD",
|
|
1828
|
-
payload: {
|
|
1829
|
-
lines
|
|
1830
|
-
}
|
|
1953
|
+
payload: { lines }
|
|
1831
1954
|
});
|
|
1832
1955
|
} else {
|
|
1833
|
-
cartCreate({
|
|
1834
|
-
lines
|
|
1835
|
-
});
|
|
1956
|
+
cartCreate({ lines });
|
|
1836
1957
|
}
|
|
1837
1958
|
},
|
|
1838
1959
|
linesRemove(lines) {
|
|
@@ -1885,16 +2006,15 @@
|
|
|
1885
2006
|
},
|
|
1886
2007
|
cartFragment
|
|
1887
2008
|
};
|
|
1888
|
-
}, [
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
}, children);
|
|
2009
|
+
}, [
|
|
2010
|
+
cartCreate,
|
|
2011
|
+
(_f = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _f.cart,
|
|
2012
|
+
(_g = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _g.errors,
|
|
2013
|
+
cartDisplayState.value,
|
|
2014
|
+
cartFragment,
|
|
2015
|
+
onCartReadySend
|
|
2016
|
+
]);
|
|
2017
|
+
return /* @__PURE__ */ React.createElement(CartContext.Provider, { value: cartContextValue }, children);
|
|
1898
2018
|
}
|
|
1899
2019
|
function transposeStatus(status) {
|
|
1900
2020
|
switch (status) {
|
|
@@ -1949,65 +2069,76 @@
|
|
|
1949
2069
|
storage.removeItem(x);
|
|
1950
2070
|
return true;
|
|
1951
2071
|
} catch (e2) {
|
|
1952
|
-
return e2 instanceof DOMException &&
|
|
2072
|
+
return e2 instanceof DOMException && // everything except Firefox
|
|
2073
|
+
(e2.code === 22 || // Firefox
|
|
2074
|
+
e2.code === 1014 || // test name field too, because code might not be present
|
|
2075
|
+
// everything except Firefox
|
|
2076
|
+
e2.name === "QuotaExceededError" || // Firefox
|
|
2077
|
+
e2.name === "NS_ERROR_DOM_QUOTA_REACHED") && // acknowledge QuotaExceededError only if there's something already stored
|
|
2078
|
+
storage && storage.length !== 0;
|
|
1953
2079
|
}
|
|
1954
2080
|
}
|
|
1955
2081
|
function countryCodeNotUpdated(context, event) {
|
|
1956
2082
|
var _a, _b;
|
|
1957
2083
|
return event.payload.buyerIdentity.countryCode && ((_b = (_a = context.cart) == null ? void 0 : _a.buyerIdentity) == null ? void 0 : _b.countryCode) !== event.payload.buyerIdentity.countryCode;
|
|
1958
2084
|
}
|
|
1959
|
-
var _jsxFileName$d = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductProvider.tsx";
|
|
1960
2085
|
const ProductOptionsContext = React.createContext(null);
|
|
1961
2086
|
function ProductProvider({
|
|
1962
2087
|
children,
|
|
1963
2088
|
data: product,
|
|
1964
2089
|
initialVariantId: explicitVariantId
|
|
1965
2090
|
}) {
|
|
1966
|
-
const variants = React.useMemo(
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
2091
|
+
const variants = React.useMemo(
|
|
2092
|
+
() => flattenConnection(product.variants ?? {}),
|
|
2093
|
+
[product.variants]
|
|
2094
|
+
);
|
|
1970
2095
|
if (!isProductVariantArray(variants)) {
|
|
1971
|
-
throw new Error(
|
|
2096
|
+
throw new Error(
|
|
2097
|
+
`<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'`
|
|
2098
|
+
);
|
|
1972
2099
|
}
|
|
1973
2100
|
const options = React.useMemo(() => getOptions(variants), [variants]);
|
|
1974
2101
|
const [selectedVariant, setSelectedVariant] = React.useState(() => getVariantBasedOnIdProp(explicitVariantId, variants));
|
|
1975
|
-
const [selectedOptions, setSelectedOptions] = React.useState(
|
|
2102
|
+
const [selectedOptions, setSelectedOptions] = React.useState(
|
|
2103
|
+
() => getSelectedOptions(selectedVariant)
|
|
2104
|
+
);
|
|
1976
2105
|
React.useEffect(() => {
|
|
1977
|
-
const newSelectedVariant = getVariantBasedOnIdProp(
|
|
2106
|
+
const newSelectedVariant = getVariantBasedOnIdProp(
|
|
2107
|
+
explicitVariantId,
|
|
2108
|
+
variants
|
|
2109
|
+
);
|
|
1978
2110
|
setSelectedVariant(newSelectedVariant);
|
|
1979
2111
|
setSelectedOptions(getSelectedOptions(newSelectedVariant));
|
|
1980
2112
|
}, [explicitVariantId, variants]);
|
|
1981
|
-
const setSelectedOption = React.useCallback(
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
...selectedOptions2,
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
const isOptionInStock = React.useCallback(
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
}
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
const sellingPlanGroups = React.useMemo(
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
var _a2;
|
|
2005
|
-
return {
|
|
2113
|
+
const setSelectedOption = React.useCallback(
|
|
2114
|
+
(name, value2) => {
|
|
2115
|
+
setSelectedOptions((selectedOptions2) => {
|
|
2116
|
+
const opts = { ...selectedOptions2, [name]: value2 };
|
|
2117
|
+
setSelectedVariant(getSelectedVariant(variants, opts));
|
|
2118
|
+
return opts;
|
|
2119
|
+
});
|
|
2120
|
+
},
|
|
2121
|
+
[setSelectedOptions, variants]
|
|
2122
|
+
);
|
|
2123
|
+
const isOptionInStock = React.useCallback(
|
|
2124
|
+
(option, value2) => {
|
|
2125
|
+
const proposedVariant = getSelectedVariant(variants, {
|
|
2126
|
+
...selectedOptions,
|
|
2127
|
+
...{ [option]: value2 }
|
|
2128
|
+
});
|
|
2129
|
+
return (proposedVariant == null ? void 0 : proposedVariant.availableForSale) ?? true;
|
|
2130
|
+
},
|
|
2131
|
+
[selectedOptions, variants]
|
|
2132
|
+
);
|
|
2133
|
+
const sellingPlanGroups = React.useMemo(
|
|
2134
|
+
() => flattenConnection(product.sellingPlanGroups ?? {}).map(
|
|
2135
|
+
(sellingPlanGroup) => ({
|
|
2006
2136
|
...sellingPlanGroup,
|
|
2007
|
-
sellingPlans: flattenConnection((
|
|
2008
|
-
}
|
|
2009
|
-
|
|
2010
|
-
|
|
2137
|
+
sellingPlans: flattenConnection((sellingPlanGroup == null ? void 0 : sellingPlanGroup.sellingPlans) ?? {})
|
|
2138
|
+
})
|
|
2139
|
+
),
|
|
2140
|
+
[product.sellingPlanGroups]
|
|
2141
|
+
);
|
|
2011
2142
|
const [selectedSellingPlan, setSelectedSellingPlan] = React.useState(void 0);
|
|
2012
2143
|
const selectedSellingPlanAllocation = React.useMemo(() => {
|
|
2013
2144
|
var _a, _b;
|
|
@@ -2015,38 +2146,49 @@
|
|
|
2015
2146
|
return;
|
|
2016
2147
|
}
|
|
2017
2148
|
if (!((_a = selectedVariant.sellingPlanAllocations) == null ? void 0 : _a.nodes) && !((_b = selectedVariant.sellingPlanAllocations) == null ? void 0 : _b.edges)) {
|
|
2018
|
-
throw new Error(
|
|
2149
|
+
throw new Error(
|
|
2150
|
+
`<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation`
|
|
2151
|
+
);
|
|
2019
2152
|
}
|
|
2020
|
-
return flattenConnection(selectedVariant.sellingPlanAllocations).find(
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2153
|
+
return flattenConnection(selectedVariant.sellingPlanAllocations).find(
|
|
2154
|
+
(allocation) => {
|
|
2155
|
+
var _a2;
|
|
2156
|
+
return ((_a2 = allocation == null ? void 0 : allocation.sellingPlan) == null ? void 0 : _a2.id) === selectedSellingPlan.id;
|
|
2157
|
+
}
|
|
2158
|
+
);
|
|
2024
2159
|
}, [selectedVariant, selectedSellingPlan]);
|
|
2025
|
-
const value = React.useMemo(
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2160
|
+
const value = React.useMemo(
|
|
2161
|
+
() => ({
|
|
2162
|
+
variants,
|
|
2163
|
+
variantsConnection: product.variants,
|
|
2164
|
+
options,
|
|
2165
|
+
selectedVariant,
|
|
2166
|
+
setSelectedVariant,
|
|
2167
|
+
selectedOptions,
|
|
2168
|
+
setSelectedOption,
|
|
2169
|
+
setSelectedOptions,
|
|
2170
|
+
isOptionInStock,
|
|
2171
|
+
selectedSellingPlan,
|
|
2172
|
+
setSelectedSellingPlan,
|
|
2173
|
+
selectedSellingPlanAllocation,
|
|
2174
|
+
sellingPlanGroups,
|
|
2175
|
+
sellingPlanGroupsConnection: product.sellingPlanGroups
|
|
2176
|
+
}),
|
|
2177
|
+
[
|
|
2178
|
+
isOptionInStock,
|
|
2179
|
+
options,
|
|
2180
|
+
product.sellingPlanGroups,
|
|
2181
|
+
product.variants,
|
|
2182
|
+
selectedOptions,
|
|
2183
|
+
selectedSellingPlan,
|
|
2184
|
+
selectedSellingPlanAllocation,
|
|
2185
|
+
selectedVariant,
|
|
2186
|
+
sellingPlanGroups,
|
|
2187
|
+
setSelectedOption,
|
|
2188
|
+
variants
|
|
2189
|
+
]
|
|
2190
|
+
);
|
|
2191
|
+
return /* @__PURE__ */ React.createElement(ProductOptionsContext.Provider, { value }, children);
|
|
2050
2192
|
}
|
|
2051
2193
|
function useProduct() {
|
|
2052
2194
|
const context = React.useContext(ProductOptionsContext);
|
|
@@ -2063,7 +2205,9 @@
|
|
|
2063
2205
|
return variants == null ? void 0 : variants.find((variant) => {
|
|
2064
2206
|
return Object.entries(choices).every(([name, value]) => {
|
|
2065
2207
|
var _a2;
|
|
2066
|
-
return (_a2 = variant == null ? void 0 : variant.selectedOptions) == null ? void 0 : _a2.some(
|
|
2208
|
+
return (_a2 = variant == null ? void 0 : variant.selectedOptions) == null ? void 0 : _a2.some(
|
|
2209
|
+
(option) => (option == null ? void 0 : option.name) === name && (option == null ? void 0 : option.value) === value
|
|
2210
|
+
);
|
|
2067
2211
|
});
|
|
2068
2212
|
});
|
|
2069
2213
|
}
|
|
@@ -2074,9 +2218,8 @@
|
|
|
2074
2218
|
throw new Error(`'getOptions' requires 'variant.selectedOptions'`);
|
|
2075
2219
|
}
|
|
2076
2220
|
(_a = variant == null ? void 0 : variant.selectedOptions) == null ? void 0 : _a.forEach((opt) => {
|
|
2077
|
-
|
|
2078
|
-
memo[(
|
|
2079
|
-
memo[(_c = opt == null ? void 0 : opt.name) != null ? _c : ""].add((_d = opt == null ? void 0 : opt.value) != null ? _d : "");
|
|
2221
|
+
memo[(opt == null ? void 0 : opt.name) ?? ""] = memo[(opt == null ? void 0 : opt.name) ?? ""] || /* @__PURE__ */ new Set();
|
|
2222
|
+
memo[(opt == null ? void 0 : opt.name) ?? ""].add((opt == null ? void 0 : opt.value) ?? "");
|
|
2080
2223
|
});
|
|
2081
2224
|
return memo;
|
|
2082
2225
|
}, {});
|
|
@@ -2089,9 +2232,13 @@
|
|
|
2089
2232
|
}
|
|
2090
2233
|
function getVariantBasedOnIdProp(explicitVariantId, variants) {
|
|
2091
2234
|
if (explicitVariantId) {
|
|
2092
|
-
const foundVariant = variants.find(
|
|
2235
|
+
const foundVariant = variants.find(
|
|
2236
|
+
(variant) => (variant == null ? void 0 : variant.id) === explicitVariantId
|
|
2237
|
+
);
|
|
2093
2238
|
if (!foundVariant) {
|
|
2094
|
-
console.warn(
|
|
2239
|
+
console.warn(
|
|
2240
|
+
`<ProductProvider/> received a 'initialVariantId' prop, but could not actually find a variant with that ID`
|
|
2241
|
+
);
|
|
2095
2242
|
}
|
|
2096
2243
|
return foundVariant;
|
|
2097
2244
|
}
|
|
@@ -2103,11 +2250,13 @@
|
|
|
2103
2250
|
}
|
|
2104
2251
|
}
|
|
2105
2252
|
function getSelectedOptions(selectedVariant) {
|
|
2106
|
-
return (selectedVariant == null ? void 0 : selectedVariant.selectedOptions) ? selectedVariant.selectedOptions.reduce(
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2253
|
+
return (selectedVariant == null ? void 0 : selectedVariant.selectedOptions) ? selectedVariant.selectedOptions.reduce(
|
|
2254
|
+
(memo, optionSet) => {
|
|
2255
|
+
memo[(optionSet == null ? void 0 : optionSet.name) ?? ""] = (optionSet == null ? void 0 : optionSet.value) ?? "";
|
|
2256
|
+
return memo;
|
|
2257
|
+
},
|
|
2258
|
+
{}
|
|
2259
|
+
) : {};
|
|
2111
2260
|
}
|
|
2112
2261
|
function isProductVariantArray(maybeVariantArray) {
|
|
2113
2262
|
if (!maybeVariantArray || !Array.isArray(maybeVariantArray)) {
|
|
@@ -2115,7 +2264,6 @@
|
|
|
2115
2264
|
}
|
|
2116
2265
|
return true;
|
|
2117
2266
|
}
|
|
2118
|
-
var _jsxFileName$c = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/BaseButton.tsx";
|
|
2119
2267
|
function BaseButton(props) {
|
|
2120
2268
|
const {
|
|
2121
2269
|
as,
|
|
@@ -2125,30 +2273,21 @@
|
|
|
2125
2273
|
buttonRef,
|
|
2126
2274
|
...passthroughProps
|
|
2127
2275
|
} = props;
|
|
2128
|
-
const handleOnClick = React.useCallback(
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2276
|
+
const handleOnClick = React.useCallback(
|
|
2277
|
+
(event) => {
|
|
2278
|
+
if (onClick) {
|
|
2279
|
+
const clickShouldContinue = onClick(event);
|
|
2280
|
+
if (typeof clickShouldContinue === "boolean" && clickShouldContinue === false || (event == null ? void 0 : event.defaultPrevented))
|
|
2281
|
+
return;
|
|
2282
|
+
}
|
|
2283
|
+
defaultOnClick == null ? void 0 : defaultOnClick(event);
|
|
2284
|
+
},
|
|
2285
|
+
[defaultOnClick, onClick]
|
|
2286
|
+
);
|
|
2136
2287
|
const Component = as || "button";
|
|
2137
|
-
return /* @__PURE__ */
|
|
2138
|
-
|
|
2139
|
-
onClick: handleOnClick,
|
|
2140
|
-
...passthroughProps,
|
|
2141
|
-
__self: this,
|
|
2142
|
-
__source: {
|
|
2143
|
-
fileName: _jsxFileName$c,
|
|
2144
|
-
lineNumber: 59,
|
|
2145
|
-
columnNumber: 5
|
|
2146
|
-
}
|
|
2147
|
-
}, children);
|
|
2148
|
-
}
|
|
2149
|
-
var _jsxFileName$b = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/AddToCartButton.tsx";
|
|
2288
|
+
return /* @__PURE__ */ React.createElement(Component, { ref: buttonRef, onClick: handleOnClick, ...passthroughProps }, children);
|
|
2289
|
+
}
|
|
2150
2290
|
function AddToCartButton(props) {
|
|
2151
|
-
var _a;
|
|
2152
2291
|
const [addingItem, setAddingItem] = React.useState(false);
|
|
2153
2292
|
const {
|
|
2154
2293
|
variantId: explicitVariantId,
|
|
@@ -2160,14 +2299,9 @@
|
|
|
2160
2299
|
accessibleAddingToCartLabel,
|
|
2161
2300
|
...passthroughProps
|
|
2162
2301
|
} = props;
|
|
2163
|
-
const {
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
} = useCart();
|
|
2167
|
-
const {
|
|
2168
|
-
selectedVariant
|
|
2169
|
-
} = useProduct();
|
|
2170
|
-
const variantId = (_a = explicitVariantId != null ? explicitVariantId : selectedVariant == null ? void 0 : selectedVariant.id) != null ? _a : "";
|
|
2302
|
+
const { status, linesAdd } = useCart();
|
|
2303
|
+
const { selectedVariant } = useProduct();
|
|
2304
|
+
const variantId = explicitVariantId ?? (selectedVariant == null ? void 0 : selectedVariant.id) ?? "";
|
|
2171
2305
|
const disabled = explicitVariantId === null || variantId === "" || selectedVariant === null || addingItem || passthroughProps.disabled;
|
|
2172
2306
|
React.useEffect(() => {
|
|
2173
2307
|
if (addingItem && status === "idle") {
|
|
@@ -2176,52 +2310,460 @@
|
|
|
2176
2310
|
}, [status, addingItem]);
|
|
2177
2311
|
const handleAddItem = React.useCallback(() => {
|
|
2178
2312
|
setAddingItem(true);
|
|
2179
|
-
linesAdd([
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2313
|
+
linesAdd([
|
|
2314
|
+
{
|
|
2315
|
+
quantity,
|
|
2316
|
+
merchandiseId: variantId || "",
|
|
2317
|
+
attributes,
|
|
2318
|
+
sellingPlanId
|
|
2319
|
+
}
|
|
2320
|
+
]);
|
|
2185
2321
|
}, [linesAdd, quantity, variantId, attributes, sellingPlanId]);
|
|
2186
|
-
return /* @__PURE__ */
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2322
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
2323
|
+
BaseButton,
|
|
2324
|
+
{
|
|
2325
|
+
...passthroughProps,
|
|
2326
|
+
disabled,
|
|
2327
|
+
onClick,
|
|
2328
|
+
defaultOnClick: handleAddItem
|
|
2329
|
+
},
|
|
2330
|
+
children
|
|
2331
|
+
), accessibleAddingToCartLabel ? /* @__PURE__ */ React.createElement(
|
|
2332
|
+
"p",
|
|
2333
|
+
{
|
|
2334
|
+
style: {
|
|
2335
|
+
position: "absolute",
|
|
2336
|
+
width: "1px",
|
|
2337
|
+
height: "1px",
|
|
2338
|
+
padding: "0",
|
|
2339
|
+
margin: "-1px",
|
|
2340
|
+
overflow: "hidden",
|
|
2341
|
+
clip: "rect(0, 0, 0, 0)",
|
|
2342
|
+
whiteSpace: "nowrap",
|
|
2343
|
+
borderWidth: "0"
|
|
2344
|
+
},
|
|
2345
|
+
role: "alert",
|
|
2346
|
+
"aria-live": "assertive"
|
|
2208
2347
|
},
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2348
|
+
addingItem ? accessibleAddingToCartLabel : null
|
|
2349
|
+
) : null);
|
|
2350
|
+
}
|
|
2351
|
+
const AnalyticsEventName = {
|
|
2352
|
+
PAGE_VIEW: "PAGE_VIEW",
|
|
2353
|
+
ADD_TO_CART: "ADD_TO_CART"
|
|
2354
|
+
};
|
|
2355
|
+
const AnalyticsPageType = {
|
|
2356
|
+
article: "article",
|
|
2357
|
+
blog: "blog",
|
|
2358
|
+
captcha: "captcha",
|
|
2359
|
+
cart: "cart",
|
|
2360
|
+
collection: "collection",
|
|
2361
|
+
customersAccount: "customers/account",
|
|
2362
|
+
customersActivateAccount: "customers/activate_account",
|
|
2363
|
+
customersAddresses: "customers/addresses",
|
|
2364
|
+
customersLogin: "customers/login",
|
|
2365
|
+
customersOrder: "customers/order",
|
|
2366
|
+
customersRegister: "customers/register",
|
|
2367
|
+
customersResetPassword: "customers/reset_password",
|
|
2368
|
+
giftCard: "gift_card",
|
|
2369
|
+
home: "index",
|
|
2370
|
+
listCollections: "list-collections",
|
|
2371
|
+
forbidden: "403",
|
|
2372
|
+
notFound: "404",
|
|
2373
|
+
page: "page",
|
|
2374
|
+
password: "password",
|
|
2375
|
+
product: "product",
|
|
2376
|
+
policy: "policy",
|
|
2377
|
+
search: "search"
|
|
2378
|
+
};
|
|
2379
|
+
const ShopifySalesChannel = {
|
|
2380
|
+
hydrogen: "hydrogen",
|
|
2381
|
+
headless: "headless"
|
|
2382
|
+
};
|
|
2383
|
+
const ShopifyAppId = {
|
|
2384
|
+
hydrogen: "6167201",
|
|
2385
|
+
headless: "12875497473"
|
|
2386
|
+
};
|
|
2387
|
+
function schemaWrapper(schemaId, payload) {
|
|
2388
|
+
return {
|
|
2389
|
+
schema_id: schemaId,
|
|
2390
|
+
payload,
|
|
2391
|
+
metadata: {
|
|
2392
|
+
event_created_at_ms: Date.now()
|
|
2216
2393
|
}
|
|
2217
|
-
}
|
|
2394
|
+
};
|
|
2218
2395
|
}
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2396
|
+
function parseGid(gid) {
|
|
2397
|
+
const defaultReturn = { id: "", resource: null };
|
|
2398
|
+
if (typeof gid !== "string") {
|
|
2399
|
+
return defaultReturn;
|
|
2400
|
+
}
|
|
2401
|
+
const matches = gid.match(/^gid:\/\/shopify\/(\w+)\/([a-z0-9]+)/);
|
|
2402
|
+
if (!matches || matches.length === 1) {
|
|
2403
|
+
return defaultReturn;
|
|
2404
|
+
}
|
|
2405
|
+
const id = matches[2] ?? null;
|
|
2406
|
+
const resource = matches[1] ?? null;
|
|
2407
|
+
return { id, resource };
|
|
2408
|
+
}
|
|
2409
|
+
function addDataIf(keyValuePairs, formattedData) {
|
|
2410
|
+
if (typeof keyValuePairs !== "object") {
|
|
2411
|
+
return {};
|
|
2412
|
+
}
|
|
2413
|
+
Object.entries(keyValuePairs).forEach(([key, value]) => {
|
|
2414
|
+
if (value) {
|
|
2415
|
+
formattedData[key] = value;
|
|
2416
|
+
}
|
|
2417
|
+
});
|
|
2418
|
+
return formattedData;
|
|
2419
|
+
}
|
|
2420
|
+
function errorIfServer(fnName) {
|
|
2421
|
+
if (typeof document === "undefined") {
|
|
2422
|
+
console.error(
|
|
2423
|
+
`${fnName} should only be used within the useEffect callback or event handlers`
|
|
2424
|
+
);
|
|
2425
|
+
return true;
|
|
2426
|
+
}
|
|
2427
|
+
return false;
|
|
2428
|
+
}
|
|
2429
|
+
const SCHEMA_ID$1 = "trekkie_storefront_page_view/1.4";
|
|
2430
|
+
const OXYGEN_DOMAIN = "myshopify.dev";
|
|
2431
|
+
function pageView$1(payload) {
|
|
2432
|
+
const pageViewPayload = payload;
|
|
2433
|
+
const { id, resource } = parseGid(pageViewPayload.resourceId);
|
|
2434
|
+
const resourceType = resource ? resource.toLowerCase() : void 0;
|
|
2435
|
+
return [
|
|
2436
|
+
schemaWrapper(
|
|
2437
|
+
SCHEMA_ID$1,
|
|
2438
|
+
addDataIf(
|
|
2439
|
+
{
|
|
2440
|
+
pageType: pageViewPayload.pageType,
|
|
2441
|
+
customerId: pageViewPayload.customerId,
|
|
2442
|
+
resourceType,
|
|
2443
|
+
resourceId: parseInt(id)
|
|
2444
|
+
},
|
|
2445
|
+
formatPayload$1(pageViewPayload)
|
|
2446
|
+
)
|
|
2447
|
+
)
|
|
2448
|
+
];
|
|
2449
|
+
}
|
|
2450
|
+
function formatPayload$1(payload) {
|
|
2451
|
+
return {
|
|
2452
|
+
appClientId: payload.shopifySalesChannel ? ShopifyAppId[payload.shopifySalesChannel] : ShopifyAppId.headless,
|
|
2453
|
+
isMerchantRequest: isMerchantRequest(payload.url),
|
|
2454
|
+
hydrogenSubchannelId: payload.storefrontId || "0",
|
|
2455
|
+
isPersistentCookie: payload.hasUserConsent,
|
|
2456
|
+
uniqToken: payload.uniqueToken,
|
|
2457
|
+
visitToken: payload.visitToken,
|
|
2458
|
+
microSessionId: buildUUID(),
|
|
2459
|
+
microSessionCount: 1,
|
|
2460
|
+
url: payload.url,
|
|
2461
|
+
path: payload.path,
|
|
2462
|
+
search: payload.search,
|
|
2463
|
+
referrer: payload.referrer,
|
|
2464
|
+
title: payload.title,
|
|
2465
|
+
shopId: parseInt(parseGid(payload.shopId).id),
|
|
2466
|
+
currency: payload.currency,
|
|
2467
|
+
contentLanguage: payload.acceptedLanguage || "en"
|
|
2468
|
+
};
|
|
2469
|
+
}
|
|
2470
|
+
function isMerchantRequest(url) {
|
|
2471
|
+
if (typeof url !== "string") {
|
|
2472
|
+
return false;
|
|
2473
|
+
}
|
|
2474
|
+
const hostname = new URL(url).hostname;
|
|
2475
|
+
if (hostname.indexOf(OXYGEN_DOMAIN) !== -1 || hostname === "localhost") {
|
|
2476
|
+
return true;
|
|
2477
|
+
}
|
|
2478
|
+
return false;
|
|
2479
|
+
}
|
|
2480
|
+
const SCHEMA_ID = "custom_storefront_customer_tracking/1.0";
|
|
2481
|
+
const PAGE_RENDERED_EVENT_NAME = "page_rendered";
|
|
2482
|
+
const COLLECTION_PAGE_RENDERED_EVENT_NAME = "collection_page_rendered";
|
|
2483
|
+
const PRODUCT_PAGE_RENDERED_EVENT_NAME = "product_page_rendered";
|
|
2484
|
+
const PRODUCT_ADDED_TO_CART_EVENT_NAME = "product_added_to_cart";
|
|
2485
|
+
const SEARCH_SUBMITTED_EVENT_NAME = "search_submitted";
|
|
2486
|
+
function pageView(payload) {
|
|
2487
|
+
const pageViewPayload = payload;
|
|
2488
|
+
const additionalPayload = {
|
|
2489
|
+
canonical_url: pageViewPayload.canonicalUrl || pageViewPayload.url,
|
|
2490
|
+
customer_id: pageViewPayload.customerId
|
|
2491
|
+
};
|
|
2492
|
+
const pageType = pageViewPayload.pageType;
|
|
2493
|
+
const pageViewEvents = [];
|
|
2494
|
+
pageViewEvents.push(
|
|
2495
|
+
schemaWrapper(
|
|
2496
|
+
SCHEMA_ID,
|
|
2497
|
+
addDataIf(
|
|
2498
|
+
{
|
|
2499
|
+
event_name: PAGE_RENDERED_EVENT_NAME,
|
|
2500
|
+
...additionalPayload
|
|
2501
|
+
},
|
|
2502
|
+
formatPayload(pageViewPayload)
|
|
2503
|
+
)
|
|
2504
|
+
)
|
|
2505
|
+
);
|
|
2506
|
+
switch (pageType) {
|
|
2507
|
+
case AnalyticsPageType.collection:
|
|
2508
|
+
pageViewEvents.push(
|
|
2509
|
+
schemaWrapper(
|
|
2510
|
+
SCHEMA_ID,
|
|
2511
|
+
addDataIf(
|
|
2512
|
+
{
|
|
2513
|
+
event_name: COLLECTION_PAGE_RENDERED_EVENT_NAME,
|
|
2514
|
+
...additionalPayload,
|
|
2515
|
+
collection_name: pageViewPayload.collectionHandle
|
|
2516
|
+
},
|
|
2517
|
+
formatPayload(pageViewPayload)
|
|
2518
|
+
)
|
|
2519
|
+
)
|
|
2520
|
+
);
|
|
2521
|
+
break;
|
|
2522
|
+
case AnalyticsPageType.product:
|
|
2523
|
+
pageViewEvents.push(
|
|
2524
|
+
schemaWrapper(
|
|
2525
|
+
SCHEMA_ID,
|
|
2526
|
+
addDataIf(
|
|
2527
|
+
{
|
|
2528
|
+
event_name: PRODUCT_PAGE_RENDERED_EVENT_NAME,
|
|
2529
|
+
...additionalPayload,
|
|
2530
|
+
products: formatProductPayload(pageViewPayload.products),
|
|
2531
|
+
total_value: pageViewPayload.totalValue
|
|
2532
|
+
},
|
|
2533
|
+
formatPayload(pageViewPayload)
|
|
2534
|
+
)
|
|
2535
|
+
)
|
|
2536
|
+
);
|
|
2537
|
+
break;
|
|
2538
|
+
case AnalyticsPageType.search:
|
|
2539
|
+
pageViewEvents.push(
|
|
2540
|
+
schemaWrapper(
|
|
2541
|
+
SCHEMA_ID,
|
|
2542
|
+
addDataIf(
|
|
2543
|
+
{
|
|
2544
|
+
event_name: SEARCH_SUBMITTED_EVENT_NAME,
|
|
2545
|
+
...additionalPayload,
|
|
2546
|
+
search_string: pageViewPayload.searchString
|
|
2547
|
+
},
|
|
2548
|
+
formatPayload(pageViewPayload)
|
|
2549
|
+
)
|
|
2550
|
+
)
|
|
2551
|
+
);
|
|
2552
|
+
break;
|
|
2553
|
+
}
|
|
2554
|
+
return pageViewEvents;
|
|
2555
|
+
}
|
|
2556
|
+
function addToCart(payload) {
|
|
2557
|
+
const addToCartPayload = payload;
|
|
2558
|
+
const cartToken = parseGid(addToCartPayload.cartId);
|
|
2559
|
+
const cart_token = (cartToken == null ? void 0 : cartToken.id) ? `${cartToken.id}` : null;
|
|
2560
|
+
return [
|
|
2561
|
+
schemaWrapper(
|
|
2562
|
+
SCHEMA_ID,
|
|
2563
|
+
addDataIf(
|
|
2564
|
+
{
|
|
2565
|
+
event_name: PRODUCT_ADDED_TO_CART_EVENT_NAME,
|
|
2566
|
+
customerId: addToCartPayload.customerId,
|
|
2567
|
+
cart_token,
|
|
2568
|
+
total_value: addToCartPayload.totalValue,
|
|
2569
|
+
products: formatProductPayload(addToCartPayload.products)
|
|
2570
|
+
},
|
|
2571
|
+
formatPayload(addToCartPayload)
|
|
2572
|
+
)
|
|
2573
|
+
)
|
|
2574
|
+
];
|
|
2575
|
+
}
|
|
2576
|
+
function formatPayload(payload) {
|
|
2577
|
+
return {
|
|
2578
|
+
source: payload.shopifySalesChannel || ShopifySalesChannel.headless,
|
|
2579
|
+
hydrogenSubchannelId: payload.storefrontId || "0",
|
|
2580
|
+
is_persistent_cookie: payload.hasUserConsent,
|
|
2581
|
+
ccpa_enforced: false,
|
|
2582
|
+
gdpr_enforced: false,
|
|
2583
|
+
unique_token: payload.uniqueToken,
|
|
2584
|
+
event_time: Date.now(),
|
|
2585
|
+
event_id: buildUUID(),
|
|
2586
|
+
event_source_url: payload.url,
|
|
2587
|
+
referrer: payload.referrer,
|
|
2588
|
+
user_agent: payload.userAgent,
|
|
2589
|
+
navigation_type: payload.navigationType,
|
|
2590
|
+
navigation_api: payload.navigationApi,
|
|
2591
|
+
shop_id: parseInt(parseGid(payload.shopId).id),
|
|
2592
|
+
currency: payload.currency
|
|
2593
|
+
};
|
|
2594
|
+
}
|
|
2595
|
+
function formatProductPayload(products) {
|
|
2596
|
+
return products ? products.map((p) => {
|
|
2597
|
+
const product = addDataIf(
|
|
2598
|
+
{
|
|
2599
|
+
variant_gid: p.variantGid,
|
|
2600
|
+
category: p.category,
|
|
2601
|
+
sku: p.sku,
|
|
2602
|
+
product_id: parseInt(parseGid(p.productGid).id),
|
|
2603
|
+
variant_id: parseInt(parseGid(p.variantGid).id)
|
|
2604
|
+
},
|
|
2605
|
+
{
|
|
2606
|
+
product_gid: p.productGid,
|
|
2607
|
+
name: p.name,
|
|
2608
|
+
variant: p.variantName || "",
|
|
2609
|
+
brand: p.brand,
|
|
2610
|
+
price: p.price,
|
|
2611
|
+
quantity: Number(p.quantity || 0)
|
|
2612
|
+
}
|
|
2613
|
+
);
|
|
2614
|
+
return JSON.stringify(product);
|
|
2615
|
+
}) : [];
|
|
2616
|
+
}
|
|
2617
|
+
function sendShopifyAnalytics(event, shopDomain) {
|
|
2618
|
+
const { eventName, payload } = event;
|
|
2619
|
+
if (!payload.hasUserConsent)
|
|
2620
|
+
return Promise.resolve();
|
|
2621
|
+
let events = [];
|
|
2622
|
+
if (eventName === AnalyticsEventName.PAGE_VIEW) {
|
|
2623
|
+
const pageViewPayload = payload;
|
|
2624
|
+
events = events.concat(
|
|
2625
|
+
pageView$1(pageViewPayload),
|
|
2626
|
+
pageView(pageViewPayload)
|
|
2627
|
+
);
|
|
2628
|
+
} else if (eventName === AnalyticsEventName.ADD_TO_CART) {
|
|
2629
|
+
events = events.concat(
|
|
2630
|
+
addToCart(payload)
|
|
2631
|
+
);
|
|
2632
|
+
}
|
|
2633
|
+
if (events.length) {
|
|
2634
|
+
return sendToShopify(events, shopDomain);
|
|
2635
|
+
} else {
|
|
2636
|
+
return Promise.resolve();
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
const ERROR_MESSAGE = "sendShopifyAnalytics request is unsuccessful";
|
|
2640
|
+
function sendToShopify(events, shopDomain) {
|
|
2641
|
+
const eventsToBeSent = {
|
|
2642
|
+
events,
|
|
2643
|
+
metadata: {
|
|
2644
|
+
event_sent_at_ms: Date.now()
|
|
2645
|
+
}
|
|
2646
|
+
};
|
|
2647
|
+
try {
|
|
2648
|
+
return fetch(
|
|
2649
|
+
shopDomain ? `https://${shopDomain}/.well-known/shopify/monorail/unstable/produce_batch` : "https://monorail-edge.shopifysvc.com/unstable/produce_batch",
|
|
2650
|
+
{
|
|
2651
|
+
method: "post",
|
|
2652
|
+
headers: {
|
|
2653
|
+
"content-type": "text/plain"
|
|
2654
|
+
},
|
|
2655
|
+
body: JSON.stringify(eventsToBeSent)
|
|
2656
|
+
}
|
|
2657
|
+
).then((response) => {
|
|
2658
|
+
if (!response.ok) {
|
|
2659
|
+
throw new Error("Response failed");
|
|
2660
|
+
}
|
|
2661
|
+
return response.text();
|
|
2662
|
+
}).then((data) => {
|
|
2663
|
+
if (data) {
|
|
2664
|
+
const jsonResponse = JSON.parse(data);
|
|
2665
|
+
jsonResponse.result.forEach((eventResponse) => {
|
|
2666
|
+
if (eventResponse.status !== 200) {
|
|
2667
|
+
console.error(ERROR_MESSAGE, "\n\n", eventResponse.message);
|
|
2668
|
+
}
|
|
2669
|
+
});
|
|
2670
|
+
}
|
|
2671
|
+
}).catch((err) => {
|
|
2672
|
+
console.error(ERROR_MESSAGE, err);
|
|
2673
|
+
if (true) {
|
|
2674
|
+
throw new Error(ERROR_MESSAGE);
|
|
2675
|
+
}
|
|
2676
|
+
});
|
|
2677
|
+
} catch (error) {
|
|
2678
|
+
return Promise.resolve();
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
function getClientBrowserParameters() {
|
|
2682
|
+
if (errorIfServer("getClientBrowserParameters")) {
|
|
2683
|
+
return {
|
|
2684
|
+
uniqueToken: "",
|
|
2685
|
+
visitToken: "",
|
|
2686
|
+
url: "",
|
|
2687
|
+
path: "",
|
|
2688
|
+
search: "",
|
|
2689
|
+
referrer: "",
|
|
2690
|
+
title: "",
|
|
2691
|
+
userAgent: "",
|
|
2692
|
+
navigationType: "",
|
|
2693
|
+
navigationApi: ""
|
|
2694
|
+
};
|
|
2695
|
+
}
|
|
2696
|
+
const [navigationType, navigationApi] = getNavigationType();
|
|
2697
|
+
const cookies = getShopifyCookies(document.cookie);
|
|
2698
|
+
return {
|
|
2699
|
+
uniqueToken: cookies[SHOPIFY_Y],
|
|
2700
|
+
visitToken: cookies[SHOPIFY_S],
|
|
2701
|
+
url: location.href,
|
|
2702
|
+
path: location.pathname,
|
|
2703
|
+
search: location.search,
|
|
2704
|
+
referrer: document.referrer,
|
|
2705
|
+
title: document.title,
|
|
2706
|
+
userAgent: navigator.userAgent,
|
|
2707
|
+
navigationType,
|
|
2708
|
+
navigationApi
|
|
2709
|
+
};
|
|
2710
|
+
}
|
|
2711
|
+
function getNavigationTypeExperimental() {
|
|
2712
|
+
try {
|
|
2713
|
+
const navigationEntries = (performance == null ? void 0 : performance.getEntriesByType) && (performance == null ? void 0 : performance.getEntriesByType("navigation"));
|
|
2714
|
+
if (navigationEntries && navigationEntries[0]) {
|
|
2715
|
+
const rawType = window.performance.getEntriesByType(
|
|
2716
|
+
"navigation"
|
|
2717
|
+
)[0]["type"];
|
|
2718
|
+
const navType = rawType && rawType.toString();
|
|
2719
|
+
return navType;
|
|
2720
|
+
}
|
|
2721
|
+
} catch (err) {
|
|
2722
|
+
}
|
|
2723
|
+
return void 0;
|
|
2724
|
+
}
|
|
2725
|
+
function getNavigationTypeLegacy() {
|
|
2726
|
+
var _a, _b;
|
|
2727
|
+
try {
|
|
2728
|
+
if (PerformanceNavigation && ((_a = performance == null ? void 0 : performance.navigation) == null ? void 0 : _a.type) !== null && ((_b = performance == null ? void 0 : performance.navigation) == null ? void 0 : _b.type) !== void 0) {
|
|
2729
|
+
const rawType = performance.navigation.type;
|
|
2730
|
+
switch (rawType) {
|
|
2731
|
+
case PerformanceNavigation.TYPE_NAVIGATE:
|
|
2732
|
+
return "navigate";
|
|
2733
|
+
break;
|
|
2734
|
+
case PerformanceNavigation.TYPE_RELOAD:
|
|
2735
|
+
return "reload";
|
|
2736
|
+
break;
|
|
2737
|
+
case PerformanceNavigation.TYPE_BACK_FORWARD:
|
|
2738
|
+
return "back_forward";
|
|
2739
|
+
break;
|
|
2740
|
+
default:
|
|
2741
|
+
return `unknown: ${rawType}`;
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
} catch (err) {
|
|
2745
|
+
}
|
|
2746
|
+
return void 0;
|
|
2747
|
+
}
|
|
2748
|
+
function getNavigationType() {
|
|
2749
|
+
try {
|
|
2750
|
+
let navApi = "PerformanceNavigationTiming";
|
|
2751
|
+
let navType = getNavigationTypeExperimental();
|
|
2752
|
+
if (!navType) {
|
|
2753
|
+
navType = getNavigationTypeLegacy();
|
|
2754
|
+
navApi = "performance.navigation";
|
|
2755
|
+
}
|
|
2756
|
+
if (navType) {
|
|
2757
|
+
return [navType, navApi];
|
|
2758
|
+
} else {
|
|
2759
|
+
return ["unknown", "unknown"];
|
|
2760
|
+
}
|
|
2761
|
+
} catch (err) {
|
|
2762
|
+
}
|
|
2763
|
+
return ["error", "error"];
|
|
2764
|
+
}
|
|
2765
|
+
function BuyNowButton(props) {
|
|
2766
|
+
const { cartCreate, checkoutUrl } = useCart();
|
|
2225
2767
|
const [loading, setLoading] = React.useState(false);
|
|
2226
2768
|
const {
|
|
2227
2769
|
quantity,
|
|
@@ -2239,55 +2781,211 @@
|
|
|
2239
2781
|
const handleBuyNow = React.useCallback(() => {
|
|
2240
2782
|
setLoading(true);
|
|
2241
2783
|
cartCreate({
|
|
2242
|
-
lines: [
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2784
|
+
lines: [
|
|
2785
|
+
{
|
|
2786
|
+
quantity: quantity ?? 1,
|
|
2787
|
+
merchandiseId: variantId,
|
|
2788
|
+
attributes
|
|
2789
|
+
}
|
|
2790
|
+
]
|
|
2247
2791
|
});
|
|
2248
2792
|
}, [cartCreate, quantity, variantId, attributes]);
|
|
2249
|
-
return /* @__PURE__ */
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
}
|
|
2260
|
-
}, children);
|
|
2793
|
+
return /* @__PURE__ */ React.createElement(
|
|
2794
|
+
BaseButton,
|
|
2795
|
+
{
|
|
2796
|
+
disabled: loading ?? passthroughProps.disabled,
|
|
2797
|
+
...passthroughProps,
|
|
2798
|
+
onClick,
|
|
2799
|
+
defaultOnClick: handleBuyNow
|
|
2800
|
+
},
|
|
2801
|
+
children
|
|
2802
|
+
);
|
|
2261
2803
|
}
|
|
2262
|
-
var _jsxFileName$9 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/CartCheckoutButton.tsx";
|
|
2263
2804
|
function CartCheckoutButton(props) {
|
|
2264
2805
|
const [requestedCheckout, setRequestedCheckout] = React.useState(false);
|
|
2265
|
-
const {
|
|
2266
|
-
|
|
2267
|
-
checkoutUrl
|
|
2268
|
-
} = useCart();
|
|
2269
|
-
const {
|
|
2270
|
-
children,
|
|
2271
|
-
...passthroughProps
|
|
2272
|
-
} = props;
|
|
2806
|
+
const { status, checkoutUrl } = useCart();
|
|
2807
|
+
const { children, ...passthroughProps } = props;
|
|
2273
2808
|
React.useEffect(() => {
|
|
2274
2809
|
if (requestedCheckout && checkoutUrl && status === "idle") {
|
|
2275
2810
|
window.location.href = checkoutUrl;
|
|
2276
2811
|
}
|
|
2277
2812
|
}, [requestedCheckout, status, checkoutUrl]);
|
|
2278
|
-
return /* @__PURE__ */
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2813
|
+
return /* @__PURE__ */ React.createElement(
|
|
2814
|
+
BaseButton,
|
|
2815
|
+
{
|
|
2816
|
+
...passthroughProps,
|
|
2817
|
+
disabled: requestedCheckout || passthroughProps.disabled,
|
|
2818
|
+
onClick: () => setRequestedCheckout(true)
|
|
2819
|
+
},
|
|
2820
|
+
children
|
|
2821
|
+
);
|
|
2822
|
+
}
|
|
2823
|
+
function useMoney(money) {
|
|
2824
|
+
const { countryIsoCode, languageIsoCode } = useShop();
|
|
2825
|
+
const locale = `${languageIsoCode}-${countryIsoCode}`;
|
|
2826
|
+
if (!locale) {
|
|
2827
|
+
throw new Error(
|
|
2828
|
+
`useMoney(): Unable to get 'locale' from 'useShop()', which means that 'locale' was not passed to '<ShopifyProvider/>'. 'locale' is required for 'useMoney()' to work`
|
|
2829
|
+
);
|
|
2830
|
+
}
|
|
2831
|
+
const amount = parseFloat(money.amount);
|
|
2832
|
+
const options = React.useMemo(
|
|
2833
|
+
() => ({
|
|
2834
|
+
style: "currency",
|
|
2835
|
+
currency: money.currencyCode
|
|
2836
|
+
}),
|
|
2837
|
+
[money.currencyCode]
|
|
2838
|
+
);
|
|
2839
|
+
const defaultFormatter = useLazyFormatter(locale, options);
|
|
2840
|
+
const nameFormatter = useLazyFormatter(locale, {
|
|
2841
|
+
...options,
|
|
2842
|
+
currencyDisplay: "name"
|
|
2843
|
+
});
|
|
2844
|
+
const narrowSymbolFormatter = useLazyFormatter(locale, {
|
|
2845
|
+
...options,
|
|
2846
|
+
currencyDisplay: "narrowSymbol"
|
|
2847
|
+
});
|
|
2848
|
+
const withoutTrailingZerosFormatter = useLazyFormatter(locale, {
|
|
2849
|
+
...options,
|
|
2850
|
+
minimumFractionDigits: 0,
|
|
2851
|
+
maximumFractionDigits: 0
|
|
2852
|
+
});
|
|
2853
|
+
const withoutCurrencyFormatter = useLazyFormatter(locale);
|
|
2854
|
+
const withoutTrailingZerosOrCurrencyFormatter = useLazyFormatter(locale, {
|
|
2855
|
+
minimumFractionDigits: 0,
|
|
2856
|
+
maximumFractionDigits: 0
|
|
2857
|
+
});
|
|
2858
|
+
const isPartCurrency = (part) => part.type === "currency";
|
|
2859
|
+
const lazyFormatters = React.useMemo(
|
|
2860
|
+
() => ({
|
|
2861
|
+
original: () => money,
|
|
2862
|
+
currencyCode: () => money.currencyCode,
|
|
2863
|
+
localizedString: () => defaultFormatter().format(amount),
|
|
2864
|
+
parts: () => defaultFormatter().formatToParts(amount),
|
|
2865
|
+
withoutTrailingZeros: () => amount % 1 === 0 ? withoutTrailingZerosFormatter().format(amount) : defaultFormatter().format(amount),
|
|
2866
|
+
withoutTrailingZerosAndCurrency: () => amount % 1 === 0 ? withoutTrailingZerosOrCurrencyFormatter().format(amount) : withoutCurrencyFormatter().format(amount),
|
|
2867
|
+
currencyName: () => {
|
|
2868
|
+
var _a;
|
|
2869
|
+
return ((_a = nameFormatter().formatToParts(amount).find(isPartCurrency)) == null ? void 0 : _a.value) ?? money.currencyCode;
|
|
2870
|
+
},
|
|
2871
|
+
// e.g. "US dollars"
|
|
2872
|
+
currencySymbol: () => {
|
|
2873
|
+
var _a;
|
|
2874
|
+
return ((_a = defaultFormatter().formatToParts(amount).find(isPartCurrency)) == null ? void 0 : _a.value) ?? money.currencyCode;
|
|
2875
|
+
},
|
|
2876
|
+
// e.g. "USD"
|
|
2877
|
+
currencyNarrowSymbol: () => {
|
|
2878
|
+
var _a;
|
|
2879
|
+
return ((_a = narrowSymbolFormatter().formatToParts(amount).find(isPartCurrency)) == null ? void 0 : _a.value) ?? "";
|
|
2880
|
+
},
|
|
2881
|
+
// e.g. "$"
|
|
2882
|
+
amount: () => defaultFormatter().formatToParts(amount).filter(
|
|
2883
|
+
(part) => ["decimal", "fraction", "group", "integer", "literal"].includes(
|
|
2884
|
+
part.type
|
|
2885
|
+
)
|
|
2886
|
+
).map((part) => part.value).join("")
|
|
2887
|
+
}),
|
|
2888
|
+
[
|
|
2889
|
+
money,
|
|
2890
|
+
amount,
|
|
2891
|
+
nameFormatter,
|
|
2892
|
+
defaultFormatter,
|
|
2893
|
+
narrowSymbolFormatter,
|
|
2894
|
+
withoutCurrencyFormatter,
|
|
2895
|
+
withoutTrailingZerosFormatter,
|
|
2896
|
+
withoutTrailingZerosOrCurrencyFormatter
|
|
2897
|
+
]
|
|
2898
|
+
);
|
|
2899
|
+
return React.useMemo(
|
|
2900
|
+
() => new Proxy(lazyFormatters, {
|
|
2901
|
+
get: (target, key) => {
|
|
2902
|
+
var _a;
|
|
2903
|
+
return (_a = Reflect.get(target, key)) == null ? void 0 : _a.call(null);
|
|
2904
|
+
}
|
|
2905
|
+
}),
|
|
2906
|
+
[lazyFormatters]
|
|
2907
|
+
);
|
|
2908
|
+
}
|
|
2909
|
+
function useLazyFormatter(locale, options) {
|
|
2910
|
+
return React.useMemo(() => {
|
|
2911
|
+
let memoized;
|
|
2912
|
+
return () => memoized ?? (memoized = new Intl.NumberFormat(locale, options));
|
|
2913
|
+
}, [locale, options]);
|
|
2914
|
+
}
|
|
2915
|
+
function Money({
|
|
2916
|
+
data,
|
|
2917
|
+
as,
|
|
2918
|
+
withoutCurrency,
|
|
2919
|
+
withoutTrailingZeros,
|
|
2920
|
+
measurement,
|
|
2921
|
+
measurementSeparator = "/",
|
|
2922
|
+
...passthroughProps
|
|
2923
|
+
}) {
|
|
2924
|
+
if (!isMoney(data)) {
|
|
2925
|
+
throw new Error(
|
|
2926
|
+
`<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'`
|
|
2927
|
+
);
|
|
2928
|
+
}
|
|
2929
|
+
const moneyObject = useMoney(data);
|
|
2930
|
+
const Wrapper = as ?? "div";
|
|
2931
|
+
let output = moneyObject.localizedString;
|
|
2932
|
+
if (withoutCurrency || withoutTrailingZeros) {
|
|
2933
|
+
if (withoutCurrency && !withoutTrailingZeros) {
|
|
2934
|
+
output = moneyObject.amount;
|
|
2935
|
+
} else if (!withoutCurrency && withoutTrailingZeros) {
|
|
2936
|
+
output = moneyObject.withoutTrailingZeros;
|
|
2937
|
+
} else {
|
|
2938
|
+
output = moneyObject.withoutTrailingZerosAndCurrency;
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
return /* @__PURE__ */ React.createElement(Wrapper, { ...passthroughProps }, output, measurement && measurement.referenceUnit && /* @__PURE__ */ React.createElement(React.Fragment, null, measurementSeparator, measurement.referenceUnit));
|
|
2942
|
+
}
|
|
2943
|
+
function isMoney(maybeMoney) {
|
|
2944
|
+
return typeof maybeMoney.amount === "string" && !!maybeMoney.amount && typeof maybeMoney.currencyCode === "string" && !!maybeMoney.currencyCode;
|
|
2945
|
+
}
|
|
2946
|
+
function CartCost(props) {
|
|
2947
|
+
const { cost } = useCart();
|
|
2948
|
+
const { amountType = "total", children, ...passthroughProps } = props;
|
|
2949
|
+
let amount;
|
|
2950
|
+
if (amountType == "total") {
|
|
2951
|
+
amount = cost == null ? void 0 : cost.totalAmount;
|
|
2952
|
+
} else if (amountType == "subtotal") {
|
|
2953
|
+
amount = cost == null ? void 0 : cost.subtotalAmount;
|
|
2954
|
+
} else if (amountType == "tax") {
|
|
2955
|
+
amount = cost == null ? void 0 : cost.totalTaxAmount;
|
|
2956
|
+
} else if (amountType == "duty") {
|
|
2957
|
+
amount = cost == null ? void 0 : cost.totalDutyAmount;
|
|
2958
|
+
}
|
|
2959
|
+
if (amount == null) {
|
|
2960
|
+
return null;
|
|
2961
|
+
}
|
|
2962
|
+
return /* @__PURE__ */ React.createElement(Money, { ...passthroughProps, data: amount }, children);
|
|
2963
|
+
}
|
|
2964
|
+
function CartLinePrice(props) {
|
|
2965
|
+
var _a, _b;
|
|
2966
|
+
const { data: cartLine, priceType = "regular", ...passthroughProps } = props;
|
|
2967
|
+
if (cartLine == null) {
|
|
2968
|
+
throw new Error(`<CartLinePrice/> requires a cart line as the 'data' prop`);
|
|
2969
|
+
}
|
|
2970
|
+
const moneyV2 = priceType === "regular" ? (_a = cartLine.cost) == null ? void 0 : _a.totalAmount : (_b = cartLine.cost) == null ? void 0 : _b.compareAtAmountPerQuantity;
|
|
2971
|
+
if (moneyV2 == null) {
|
|
2972
|
+
return null;
|
|
2973
|
+
}
|
|
2974
|
+
return /* @__PURE__ */ React.createElement(Money, { ...passthroughProps, data: moneyV2 });
|
|
2975
|
+
}
|
|
2976
|
+
const CartLineContext = React.createContext(null);
|
|
2977
|
+
function useCartLine() {
|
|
2978
|
+
const context = React.useContext(CartLineContext);
|
|
2979
|
+
if (context == null) {
|
|
2980
|
+
throw new Error("Expected a cart line context but none was found");
|
|
2981
|
+
}
|
|
2982
|
+
return context;
|
|
2983
|
+
}
|
|
2984
|
+
function CartLineProvider({ children, line }) {
|
|
2985
|
+
return /* @__PURE__ */ React.createElement(CartLineContext.Provider, { value: line }, children);
|
|
2289
2986
|
}
|
|
2290
2987
|
const storefrontApiCustomScalars = {
|
|
2988
|
+
// Keep in sync with the definitions in the app/nextjs/codegen.ts!
|
|
2291
2989
|
DateTime: "string",
|
|
2292
2990
|
Decimal: "string",
|
|
2293
2991
|
HTML: "string",
|
|
@@ -2295,9 +2993,7 @@
|
|
|
2295
2993
|
Color: "string",
|
|
2296
2994
|
UnsignedInt64: "string"
|
|
2297
2995
|
};
|
|
2298
|
-
var _jsxFileName$8 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ExternalVideo.tsx";
|
|
2299
2996
|
function ExternalVideo(props) {
|
|
2300
|
-
var _a, _b;
|
|
2301
2997
|
const {
|
|
2302
2998
|
data,
|
|
2303
2999
|
options,
|
|
@@ -2319,22 +3015,19 @@
|
|
|
2319
3015
|
}
|
|
2320
3016
|
finalUrl = urlObject.toString();
|
|
2321
3017
|
}
|
|
2322
|
-
return /* @__PURE__ */
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
fileName: _jsxFileName$8,
|
|
2334
|
-
lineNumber: 56,
|
|
2335
|
-
columnNumber: 5
|
|
3018
|
+
return /* @__PURE__ */ React.createElement(
|
|
3019
|
+
"iframe",
|
|
3020
|
+
{
|
|
3021
|
+
...passthroughProps,
|
|
3022
|
+
id: id ?? data.embedUrl,
|
|
3023
|
+
title: data.alt ?? data.id ?? "external video",
|
|
3024
|
+
frameBorder,
|
|
3025
|
+
allow,
|
|
3026
|
+
allowFullScreen,
|
|
3027
|
+
src: finalUrl,
|
|
3028
|
+
loading
|
|
2336
3029
|
}
|
|
2337
|
-
|
|
3030
|
+
);
|
|
2338
3031
|
}
|
|
2339
3032
|
const PRODUCTION_CDN_HOSTNAMES = [
|
|
2340
3033
|
"cdn.shopify.com",
|
|
@@ -2353,7 +3046,7 @@
|
|
|
2353
3046
|
scale
|
|
2354
3047
|
}) {
|
|
2355
3048
|
const newUrl = new URL(src);
|
|
2356
|
-
const multipliedScale = scale
|
|
3049
|
+
const multipliedScale = scale ?? 1;
|
|
2357
3050
|
if (width) {
|
|
2358
3051
|
let finalWidth;
|
|
2359
3052
|
if (typeof width === "string") {
|
|
@@ -2384,32 +3077,31 @@
|
|
|
2384
3077
|
loaderOptions,
|
|
2385
3078
|
elementProps
|
|
2386
3079
|
}) {
|
|
2387
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2388
3080
|
let aspectRatio = null;
|
|
2389
3081
|
if ((sfapiImage == null ? void 0 : sfapiImage.width) && (sfapiImage == null ? void 0 : sfapiImage.height)) {
|
|
2390
3082
|
aspectRatio = (sfapiImage == null ? void 0 : sfapiImage.width) / (sfapiImage == null ? void 0 : sfapiImage.height);
|
|
2391
3083
|
}
|
|
2392
3084
|
if ((loaderOptions == null ? void 0 : loaderOptions.width) || (loaderOptions == null ? void 0 : loaderOptions.height)) {
|
|
2393
3085
|
return {
|
|
2394
|
-
width: (
|
|
2395
|
-
height: (
|
|
3086
|
+
width: (loaderOptions == null ? void 0 : loaderOptions.width) ?? (aspectRatio && typeof loaderOptions.height === "number" ? Math.round(aspectRatio * loaderOptions.height) : null),
|
|
3087
|
+
height: (loaderOptions == null ? void 0 : loaderOptions.height) ?? (aspectRatio && typeof loaderOptions.width === "number" ? Math.round(aspectRatio * loaderOptions.width) : null)
|
|
2396
3088
|
};
|
|
2397
3089
|
}
|
|
2398
3090
|
if ((elementProps == null ? void 0 : elementProps.width) || (elementProps == null ? void 0 : elementProps.height)) {
|
|
2399
3091
|
return {
|
|
2400
|
-
width: (
|
|
2401
|
-
height: (
|
|
3092
|
+
width: (elementProps == null ? void 0 : elementProps.width) ?? (aspectRatio && typeof elementProps.height === "number" ? Math.round(aspectRatio * elementProps.height) : null),
|
|
3093
|
+
height: (elementProps == null ? void 0 : elementProps.height) ?? (aspectRatio && typeof elementProps.width === "number" ? Math.round(aspectRatio * elementProps.width) : null)
|
|
2402
3094
|
};
|
|
2403
3095
|
}
|
|
2404
3096
|
if ((sfapiImage == null ? void 0 : sfapiImage.width) || (sfapiImage == null ? void 0 : sfapiImage.height)) {
|
|
2405
3097
|
return {
|
|
2406
|
-
|
|
2407
|
-
|
|
3098
|
+
// can't calculate the aspect ratio here
|
|
3099
|
+
width: (sfapiImage == null ? void 0 : sfapiImage.width) ?? null,
|
|
3100
|
+
height: (sfapiImage == null ? void 0 : sfapiImage.height) ?? null
|
|
2408
3101
|
};
|
|
2409
3102
|
}
|
|
2410
3103
|
return { width: null, height: null };
|
|
2411
3104
|
}
|
|
2412
|
-
var _jsxFileName$7 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Image.tsx";
|
|
2413
3105
|
function Image({
|
|
2414
3106
|
data,
|
|
2415
3107
|
width,
|
|
@@ -2421,20 +3113,18 @@
|
|
|
2421
3113
|
decoding = "async",
|
|
2422
3114
|
...rest
|
|
2423
3115
|
}) {
|
|
2424
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2425
3116
|
if (!data.url) {
|
|
2426
|
-
const missingUrlError = `<Image/>: the 'data' prop requires the 'url' property. Image: ${
|
|
3117
|
+
const missingUrlError = `<Image/>: the 'data' prop requires the 'url' property. Image: ${data.id ?? "no ID provided"}`;
|
|
2427
3118
|
{
|
|
2428
3119
|
throw new Error(missingUrlError);
|
|
2429
3120
|
}
|
|
2430
3121
|
}
|
|
2431
3122
|
if (!data.altText && !rest.alt) {
|
|
2432
|
-
console.warn(
|
|
3123
|
+
console.warn(
|
|
3124
|
+
`<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}`
|
|
3125
|
+
);
|
|
2433
3126
|
}
|
|
2434
|
-
const {
|
|
2435
|
-
width: imgElementWidth,
|
|
2436
|
-
height: imgElementHeight
|
|
2437
|
-
} = getShopifyImageDimensions({
|
|
3127
|
+
const { width: imgElementWidth, height: imgElementHeight } = getShopifyImageDimensions({
|
|
2438
3128
|
data,
|
|
2439
3129
|
loaderOptions,
|
|
2440
3130
|
elementProps: {
|
|
@@ -2443,7 +3133,9 @@
|
|
|
2443
3133
|
}
|
|
2444
3134
|
});
|
|
2445
3135
|
if (!imgElementWidth || !imgElementHeight) {
|
|
2446
|
-
console.warn(
|
|
3136
|
+
console.warn(
|
|
3137
|
+
`<Image/>: the 'data' prop requires either 'width' or 'data.width', and 'height' or 'data.height' properties. Image: ${data.id ?? data.url}`
|
|
3138
|
+
);
|
|
2447
3139
|
}
|
|
2448
3140
|
let finalSrc = data.url;
|
|
2449
3141
|
if (loader) {
|
|
@@ -2454,11 +3146,13 @@
|
|
|
2454
3146
|
height: imgElementHeight
|
|
2455
3147
|
});
|
|
2456
3148
|
if (typeof finalSrc !== "string" || !finalSrc) {
|
|
2457
|
-
throw new Error(
|
|
3149
|
+
throw new Error(
|
|
3150
|
+
`<Image/>: 'loader' did not return a valid string. Image: ${data.id ?? data.url}`
|
|
3151
|
+
);
|
|
2458
3152
|
}
|
|
2459
3153
|
}
|
|
2460
3154
|
const maxWidth = width && imgElementWidth && width < imgElementWidth ? width : imgElementWidth;
|
|
2461
|
-
const finalSrcset =
|
|
3155
|
+
const finalSrcset = rest.srcSet ?? internalImageSrcSet({
|
|
2462
3156
|
...loaderOptions,
|
|
2463
3157
|
widths,
|
|
2464
3158
|
src: data.url,
|
|
@@ -2466,23 +3160,20 @@
|
|
|
2466
3160
|
height: imgElementHeight,
|
|
2467
3161
|
loader
|
|
2468
3162
|
});
|
|
2469
|
-
return /* @__PURE__ */ React__namespace.createElement(
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
fileName: _jsxFileName$7,
|
|
2482
|
-
lineNumber: 150,
|
|
2483
|
-
columnNumber: 5
|
|
3163
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
3164
|
+
"img",
|
|
3165
|
+
{
|
|
3166
|
+
id: data.id ?? "",
|
|
3167
|
+
alt: data.altText ?? rest.alt ?? "",
|
|
3168
|
+
loading: loading ?? "lazy",
|
|
3169
|
+
...rest,
|
|
3170
|
+
src: finalSrc,
|
|
3171
|
+
width: imgElementWidth ?? void 0,
|
|
3172
|
+
height: imgElementHeight ?? void 0,
|
|
3173
|
+
srcSet: finalSrcset,
|
|
3174
|
+
decoding
|
|
2484
3175
|
}
|
|
2485
|
-
|
|
3176
|
+
);
|
|
2486
3177
|
}
|
|
2487
3178
|
function internalImageSrcSet({
|
|
2488
3179
|
src,
|
|
@@ -2495,7 +3186,9 @@
|
|
|
2495
3186
|
}) {
|
|
2496
3187
|
const hasCustomWidths = widths && Array.isArray(widths);
|
|
2497
3188
|
if (hasCustomWidths && widths.some((size) => isNaN(size))) {
|
|
2498
|
-
throw new Error(
|
|
3189
|
+
throw new Error(
|
|
3190
|
+
`<Image/>: the 'widths' must be an array of numbers. Image: ${src}`
|
|
3191
|
+
);
|
|
2499
3192
|
}
|
|
2500
3193
|
let aspectRatio = 1;
|
|
2501
3194
|
if (width && height) {
|
|
@@ -2506,17 +3199,20 @@
|
|
|
2506
3199
|
setSizes = IMG_SRC_SET_SIZES.filter((size) => size <= width);
|
|
2507
3200
|
}
|
|
2508
3201
|
const srcGenerator = loader ? loader : addImageSizeParametersToUrl;
|
|
2509
|
-
return setSizes.map(
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
3202
|
+
return setSizes.map(
|
|
3203
|
+
(size) => `${srcGenerator({
|
|
3204
|
+
src,
|
|
3205
|
+
width: size,
|
|
3206
|
+
// height is not applied if there is no crop
|
|
3207
|
+
// if there is crop, then height is applied as a ratio of the original width + height aspect ratio * size
|
|
3208
|
+
height: crop ? Number(size) * aspectRatio : void 0,
|
|
3209
|
+
crop,
|
|
3210
|
+
scale
|
|
3211
|
+
})} ${size}w`
|
|
3212
|
+
).join(", ");
|
|
3213
|
+
}
|
|
2518
3214
|
function Video(props) {
|
|
2519
|
-
var _a
|
|
3215
|
+
var _a;
|
|
2520
3216
|
const {
|
|
2521
3217
|
data,
|
|
2522
3218
|
previewImageOptions,
|
|
@@ -2527,41 +3223,39 @@
|
|
|
2527
3223
|
...passthroughProps
|
|
2528
3224
|
} = props;
|
|
2529
3225
|
const posterUrl = shopifyImageLoader({
|
|
2530
|
-
src: (
|
|
3226
|
+
src: ((_a = data.previewImage) == null ? void 0 : _a.url) ?? "",
|
|
2531
3227
|
...previewImageOptions
|
|
2532
3228
|
});
|
|
2533
3229
|
if (!data.sources) {
|
|
2534
3230
|
throw new Error(`<Video/> requires a 'data.sources' array`);
|
|
2535
3231
|
}
|
|
2536
|
-
return
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
});
|
|
2564
|
-
}));
|
|
3232
|
+
return (
|
|
3233
|
+
// eslint-disable-next-line jsx-a11y/media-has-caption
|
|
3234
|
+
/* @__PURE__ */ React.createElement(
|
|
3235
|
+
"video",
|
|
3236
|
+
{
|
|
3237
|
+
...passthroughProps,
|
|
3238
|
+
id,
|
|
3239
|
+
playsInline,
|
|
3240
|
+
controls,
|
|
3241
|
+
poster: posterUrl
|
|
3242
|
+
},
|
|
3243
|
+
data.sources.map((source) => {
|
|
3244
|
+
if (!((source == null ? void 0 : source.url) && (source == null ? void 0 : source.mimeType))) {
|
|
3245
|
+
throw new Error(`<Video/> needs 'source.url' and 'source.mimeType'`);
|
|
3246
|
+
}
|
|
3247
|
+
return /* @__PURE__ */ React.createElement(
|
|
3248
|
+
"source",
|
|
3249
|
+
{
|
|
3250
|
+
...sourceProps,
|
|
3251
|
+
key: source.url,
|
|
3252
|
+
src: source.url,
|
|
3253
|
+
type: source.mimeType
|
|
3254
|
+
}
|
|
3255
|
+
);
|
|
3256
|
+
})
|
|
3257
|
+
)
|
|
3258
|
+
);
|
|
2565
3259
|
}
|
|
2566
3260
|
const SCRIPTS_LOADED = {};
|
|
2567
3261
|
function loadScript(src, options) {
|
|
@@ -2609,22 +3303,21 @@
|
|
|
2609
3303
|
}, [url, stringifiedOptions, options]);
|
|
2610
3304
|
return status;
|
|
2611
3305
|
}
|
|
2612
|
-
var _jsxFileName$5 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ModelViewer.tsx";
|
|
2613
3306
|
function ModelViewer(props) {
|
|
2614
|
-
var _a, _b, _c
|
|
2615
|
-
const [modelViewer, setModelViewer] = React.useState(
|
|
3307
|
+
var _a, _b, _c;
|
|
3308
|
+
const [modelViewer, setModelViewer] = React.useState(
|
|
3309
|
+
void 0
|
|
3310
|
+
);
|
|
2616
3311
|
const callbackRef = React.useCallback((node) => {
|
|
2617
3312
|
setModelViewer(node);
|
|
2618
3313
|
}, []);
|
|
2619
|
-
const {
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
module: true
|
|
2627
|
-
});
|
|
3314
|
+
const { data, children, className, ...passthroughProps } = props;
|
|
3315
|
+
const modelViewerLoadedStatus = useLoadScript(
|
|
3316
|
+
"https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js",
|
|
3317
|
+
{
|
|
3318
|
+
module: true
|
|
3319
|
+
}
|
|
3320
|
+
);
|
|
2628
3321
|
React.useEffect(() => {
|
|
2629
3322
|
if (!modelViewer) {
|
|
2630
3323
|
return;
|
|
@@ -2636,25 +3329,43 @@
|
|
|
2636
3329
|
if (passthroughProps.onPreload)
|
|
2637
3330
|
modelViewer.addEventListener("preload", passthroughProps.onPreload);
|
|
2638
3331
|
if (passthroughProps.onModelVisibility)
|
|
2639
|
-
modelViewer.addEventListener(
|
|
3332
|
+
modelViewer.addEventListener(
|
|
3333
|
+
"model-visibility",
|
|
3334
|
+
passthroughProps.onModelVisibility
|
|
3335
|
+
);
|
|
2640
3336
|
if (passthroughProps.onProgress)
|
|
2641
3337
|
modelViewer.addEventListener("progress", passthroughProps.onProgress);
|
|
2642
3338
|
if (passthroughProps.onArStatus)
|
|
2643
3339
|
modelViewer.addEventListener("ar-status", passthroughProps.onArStatus);
|
|
2644
3340
|
if (passthroughProps.onArTracking)
|
|
2645
|
-
modelViewer.addEventListener(
|
|
3341
|
+
modelViewer.addEventListener(
|
|
3342
|
+
"ar-tracking",
|
|
3343
|
+
passthroughProps.onArTracking
|
|
3344
|
+
);
|
|
2646
3345
|
if (passthroughProps.onQuickLookButtonTapped)
|
|
2647
|
-
modelViewer.addEventListener(
|
|
3346
|
+
modelViewer.addEventListener(
|
|
3347
|
+
"quick-look-button-tapped",
|
|
3348
|
+
passthroughProps.onQuickLookButtonTapped
|
|
3349
|
+
);
|
|
2648
3350
|
if (passthroughProps.onCameraChange)
|
|
2649
|
-
modelViewer.addEventListener(
|
|
3351
|
+
modelViewer.addEventListener(
|
|
3352
|
+
"camera-change",
|
|
3353
|
+
passthroughProps.onCameraChange
|
|
3354
|
+
);
|
|
2650
3355
|
if (passthroughProps.onEnvironmentChange)
|
|
2651
|
-
modelViewer.addEventListener(
|
|
3356
|
+
modelViewer.addEventListener(
|
|
3357
|
+
"environment-change",
|
|
3358
|
+
passthroughProps.onEnvironmentChange
|
|
3359
|
+
);
|
|
2652
3360
|
if (passthroughProps.onPlay)
|
|
2653
3361
|
modelViewer.addEventListener("play", passthroughProps.onPlay);
|
|
2654
3362
|
if (passthroughProps.onPause)
|
|
2655
3363
|
modelViewer.addEventListener("ar-status", passthroughProps.onPause);
|
|
2656
3364
|
if (passthroughProps.onSceneGraphReady)
|
|
2657
|
-
modelViewer.addEventListener(
|
|
3365
|
+
modelViewer.addEventListener(
|
|
3366
|
+
"scene-graph-ready",
|
|
3367
|
+
passthroughProps.onSceneGraphReady
|
|
3368
|
+
);
|
|
2658
3369
|
return () => {
|
|
2659
3370
|
if (modelViewer == null) {
|
|
2660
3371
|
return;
|
|
@@ -2666,27 +3377,66 @@
|
|
|
2666
3377
|
if (passthroughProps.onPreload)
|
|
2667
3378
|
modelViewer.removeEventListener("preload", passthroughProps.onPreload);
|
|
2668
3379
|
if (passthroughProps.onModelVisibility)
|
|
2669
|
-
modelViewer.removeEventListener(
|
|
3380
|
+
modelViewer.removeEventListener(
|
|
3381
|
+
"model-visibility",
|
|
3382
|
+
passthroughProps.onModelVisibility
|
|
3383
|
+
);
|
|
2670
3384
|
if (passthroughProps.onProgress)
|
|
2671
|
-
modelViewer.removeEventListener(
|
|
3385
|
+
modelViewer.removeEventListener(
|
|
3386
|
+
"progress",
|
|
3387
|
+
passthroughProps.onProgress
|
|
3388
|
+
);
|
|
2672
3389
|
if (passthroughProps.onArStatus)
|
|
2673
|
-
modelViewer.removeEventListener(
|
|
3390
|
+
modelViewer.removeEventListener(
|
|
3391
|
+
"ar-status",
|
|
3392
|
+
passthroughProps.onArStatus
|
|
3393
|
+
);
|
|
2674
3394
|
if (passthroughProps.onArTracking)
|
|
2675
|
-
modelViewer.removeEventListener(
|
|
3395
|
+
modelViewer.removeEventListener(
|
|
3396
|
+
"ar-tracking",
|
|
3397
|
+
passthroughProps.onArTracking
|
|
3398
|
+
);
|
|
2676
3399
|
if (passthroughProps.onQuickLookButtonTapped)
|
|
2677
|
-
modelViewer.removeEventListener(
|
|
3400
|
+
modelViewer.removeEventListener(
|
|
3401
|
+
"quick-look-button-tapped",
|
|
3402
|
+
passthroughProps.onQuickLookButtonTapped
|
|
3403
|
+
);
|
|
2678
3404
|
if (passthroughProps.onCameraChange)
|
|
2679
|
-
modelViewer.removeEventListener(
|
|
3405
|
+
modelViewer.removeEventListener(
|
|
3406
|
+
"camera-change",
|
|
3407
|
+
passthroughProps.onCameraChange
|
|
3408
|
+
);
|
|
2680
3409
|
if (passthroughProps.onEnvironmentChange)
|
|
2681
|
-
modelViewer.removeEventListener(
|
|
3410
|
+
modelViewer.removeEventListener(
|
|
3411
|
+
"environment-change",
|
|
3412
|
+
passthroughProps.onEnvironmentChange
|
|
3413
|
+
);
|
|
2682
3414
|
if (passthroughProps.onPlay)
|
|
2683
3415
|
modelViewer.removeEventListener("play", passthroughProps.onPlay);
|
|
2684
3416
|
if (passthroughProps.onPause)
|
|
2685
3417
|
modelViewer.removeEventListener("ar-status", passthroughProps.onPause);
|
|
2686
3418
|
if (passthroughProps.onSceneGraphReady)
|
|
2687
|
-
modelViewer.removeEventListener(
|
|
3419
|
+
modelViewer.removeEventListener(
|
|
3420
|
+
"scene-graph-ready",
|
|
3421
|
+
passthroughProps.onSceneGraphReady
|
|
3422
|
+
);
|
|
2688
3423
|
};
|
|
2689
|
-
}, [
|
|
3424
|
+
}, [
|
|
3425
|
+
modelViewer,
|
|
3426
|
+
passthroughProps.onArStatus,
|
|
3427
|
+
passthroughProps.onArTracking,
|
|
3428
|
+
passthroughProps.onCameraChange,
|
|
3429
|
+
passthroughProps.onEnvironmentChange,
|
|
3430
|
+
passthroughProps.onError,
|
|
3431
|
+
passthroughProps.onLoad,
|
|
3432
|
+
passthroughProps.onModelVisibility,
|
|
3433
|
+
passthroughProps.onPause,
|
|
3434
|
+
passthroughProps.onPlay,
|
|
3435
|
+
passthroughProps.onPreload,
|
|
3436
|
+
passthroughProps.onProgress,
|
|
3437
|
+
passthroughProps.onQuickLookButtonTapped,
|
|
3438
|
+
passthroughProps.onSceneGraphReady
|
|
3439
|
+
]);
|
|
2690
3440
|
if (modelViewerLoadedStatus !== "done") {
|
|
2691
3441
|
return null;
|
|
2692
3442
|
}
|
|
@@ -2697,63 +3447,62 @@
|
|
|
2697
3447
|
}
|
|
2698
3448
|
}
|
|
2699
3449
|
if (!data.alt) {
|
|
2700
|
-
console.warn(
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
}
|
|
2756
|
-
var _jsxFileName$4 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/MediaFile.tsx";
|
|
3450
|
+
console.warn(
|
|
3451
|
+
`<ModelViewer/> requires the 'data.alt' prop for accessibility`
|
|
3452
|
+
);
|
|
3453
|
+
}
|
|
3454
|
+
return /* @__PURE__ */ React.createElement(
|
|
3455
|
+
"model-viewer",
|
|
3456
|
+
{
|
|
3457
|
+
ref: callbackRef,
|
|
3458
|
+
...passthroughProps,
|
|
3459
|
+
className,
|
|
3460
|
+
id: passthroughProps.id ?? data.id,
|
|
3461
|
+
src: data.sources[0].url,
|
|
3462
|
+
alt: data.alt ?? null,
|
|
3463
|
+
"camera-controls": passthroughProps.cameraControls ?? true,
|
|
3464
|
+
poster: (passthroughProps.poster || ((_c = data.previewImage) == null ? void 0 : _c.url)) ?? null,
|
|
3465
|
+
autoplay: passthroughProps.autoplay ?? true,
|
|
3466
|
+
loading: passthroughProps.loading,
|
|
3467
|
+
reveal: passthroughProps.reveal,
|
|
3468
|
+
ar: passthroughProps.ar,
|
|
3469
|
+
"ar-modes": passthroughProps.arModes,
|
|
3470
|
+
"ar-scale": passthroughProps.arScale,
|
|
3471
|
+
"ar-placement": passthroughProps.arPlacement,
|
|
3472
|
+
"ios-src": passthroughProps.iosSrc,
|
|
3473
|
+
"touch-action": passthroughProps.touchAction,
|
|
3474
|
+
"disable-zoom": passthroughProps.disableZoom,
|
|
3475
|
+
"orbit-sensitivity": passthroughProps.orbitSensitivity,
|
|
3476
|
+
"auto-rotate": passthroughProps.autoRotate,
|
|
3477
|
+
"auto-rotate-delay": passthroughProps.autoRotateDelay,
|
|
3478
|
+
"rotation-per-second": passthroughProps.rotationPerSecond,
|
|
3479
|
+
"interaction-policy": passthroughProps.interactionPolicy,
|
|
3480
|
+
"interaction-prompt": passthroughProps.interactionPrompt,
|
|
3481
|
+
"interaction-prompt-style": passthroughProps.interactionPromptStyle,
|
|
3482
|
+
"interaction-prompt-threshold": passthroughProps.interactionPromptThreshold,
|
|
3483
|
+
"camera-orbit": passthroughProps.cameraOrbit,
|
|
3484
|
+
"camera-target": passthroughProps.cameraTarget,
|
|
3485
|
+
"field-of-view": passthroughProps.fieldOfView,
|
|
3486
|
+
"max-camera-orbit": passthroughProps.maxCameraOrbit,
|
|
3487
|
+
"min-camera-orbit": passthroughProps.minCameraOrbit,
|
|
3488
|
+
"max-field-of-view": passthroughProps.maxFieldOfView,
|
|
3489
|
+
"min-field-of-view": passthroughProps.minFieldOfView,
|
|
3490
|
+
bounds: passthroughProps.bounds,
|
|
3491
|
+
"interpolation-decay": passthroughProps.interpolationDecay ?? 100,
|
|
3492
|
+
"skybox-image": passthroughProps.skyboxImage,
|
|
3493
|
+
"environment-image": passthroughProps.environmentImage,
|
|
3494
|
+
exposure: passthroughProps.exposure,
|
|
3495
|
+
"shadow-intensity": passthroughProps.shadowIntensity ?? 0,
|
|
3496
|
+
"shadow-softness": passthroughProps.shadowSoftness ?? 0,
|
|
3497
|
+
"animation-name": passthroughProps.animationName,
|
|
3498
|
+
"animation-crossfade-duration": passthroughProps.animationCrossfadeDuration,
|
|
3499
|
+
"variant-name": passthroughProps.variantName,
|
|
3500
|
+
orientation: passthroughProps.orientation,
|
|
3501
|
+
scale: passthroughProps.scale
|
|
3502
|
+
},
|
|
3503
|
+
children
|
|
3504
|
+
);
|
|
3505
|
+
}
|
|
2757
3506
|
function MediaFile({
|
|
2758
3507
|
data,
|
|
2759
3508
|
mediaOptions,
|
|
@@ -2767,56 +3516,40 @@
|
|
|
2767
3516
|
throw new Error(noDataImage);
|
|
2768
3517
|
}
|
|
2769
3518
|
}
|
|
2770
|
-
return /* @__PURE__ */
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
fileName: _jsxFileName$4,
|
|
2777
|
-
lineNumber: 54,
|
|
2778
|
-
columnNumber: 9
|
|
3519
|
+
return /* @__PURE__ */ React.createElement(
|
|
3520
|
+
Image,
|
|
3521
|
+
{
|
|
3522
|
+
...passthroughProps,
|
|
3523
|
+
...mediaOptions == null ? void 0 : mediaOptions.image,
|
|
3524
|
+
data: data.image
|
|
2779
3525
|
}
|
|
2780
|
-
|
|
3526
|
+
);
|
|
2781
3527
|
}
|
|
2782
3528
|
case "Video": {
|
|
2783
|
-
return /* @__PURE__ */
|
|
2784
|
-
...passthroughProps,
|
|
2785
|
-
...mediaOptions == null ? void 0 : mediaOptions.video,
|
|
2786
|
-
data,
|
|
2787
|
-
__self: this,
|
|
2788
|
-
__source: {
|
|
2789
|
-
fileName: _jsxFileName$4,
|
|
2790
|
-
lineNumber: 63,
|
|
2791
|
-
columnNumber: 9
|
|
2792
|
-
}
|
|
2793
|
-
});
|
|
3529
|
+
return /* @__PURE__ */ React.createElement(Video, { ...passthroughProps, ...mediaOptions == null ? void 0 : mediaOptions.video, data });
|
|
2794
3530
|
}
|
|
2795
3531
|
case "ExternalVideo": {
|
|
2796
|
-
return /* @__PURE__ */
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
fileName: _jsxFileName$4,
|
|
2803
|
-
lineNumber: 68,
|
|
2804
|
-
columnNumber: 9
|
|
3532
|
+
return /* @__PURE__ */ React.createElement(
|
|
3533
|
+
ExternalVideo,
|
|
3534
|
+
{
|
|
3535
|
+
...passthroughProps,
|
|
3536
|
+
...mediaOptions == null ? void 0 : mediaOptions.externalVideo,
|
|
3537
|
+
data
|
|
2805
3538
|
}
|
|
2806
|
-
|
|
3539
|
+
);
|
|
2807
3540
|
}
|
|
2808
3541
|
case "Model3d": {
|
|
2809
|
-
return
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
3542
|
+
return (
|
|
3543
|
+
// @ts-expect-error There are issues with the inferred HTML attribute types here for ModelViewer (and contentEditable), but I think that's a little bit beyond me at the moment
|
|
3544
|
+
/* @__PURE__ */ React.createElement(
|
|
3545
|
+
ModelViewer,
|
|
3546
|
+
{
|
|
3547
|
+
...passthroughProps,
|
|
3548
|
+
...mediaOptions == null ? void 0 : mediaOptions.modelViewer,
|
|
3549
|
+
data
|
|
3550
|
+
}
|
|
3551
|
+
)
|
|
3552
|
+
);
|
|
2820
3553
|
}
|
|
2821
3554
|
default: {
|
|
2822
3555
|
const typenameMissingMessage = `<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to render the matching sub-component for this type of media.`;
|
|
@@ -2826,384 +3559,9 @@
|
|
|
2826
3559
|
}
|
|
2827
3560
|
}
|
|
2828
3561
|
}
|
|
2829
|
-
var _jsxFileName$3 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Metafield.tsx";
|
|
2830
|
-
function Metafield(props) {
|
|
2831
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2832
|
-
const {
|
|
2833
|
-
data,
|
|
2834
|
-
as,
|
|
2835
|
-
...passthroughProps
|
|
2836
|
-
} = props;
|
|
2837
|
-
const {
|
|
2838
|
-
locale
|
|
2839
|
-
} = useShop();
|
|
2840
|
-
const parsedMetafield = React.useMemo(() => parseMetafield(data), [data]);
|
|
2841
|
-
if (!parsedMetafield) {
|
|
2842
|
-
const noDataPropWarning = `<Metafield/>: nothing was passed to the data prop 'data'. Rendering 'null'`;
|
|
2843
|
-
{
|
|
2844
|
-
throw new Error(noDataPropWarning);
|
|
2845
|
-
}
|
|
2846
|
-
}
|
|
2847
|
-
if (parsedMetafield.value === null || parsedMetafield.value === void 0) {
|
|
2848
|
-
const noValueWarning = `<Metafield/>: No metafield value for metafield ${(_a = parsedMetafield.id) != null ? _a : parsedMetafield.key}. Rendering 'null'`;
|
|
2849
|
-
{
|
|
2850
|
-
throw new Error(noValueWarning);
|
|
2851
|
-
}
|
|
2852
|
-
}
|
|
2853
|
-
switch (parsedMetafield.type) {
|
|
2854
|
-
case "date": {
|
|
2855
|
-
const Wrapper2 = as != null ? as : "time";
|
|
2856
|
-
return /* @__PURE__ */ React__default.default.createElement(Wrapper2, {
|
|
2857
|
-
...passthroughProps,
|
|
2858
|
-
__self: this,
|
|
2859
|
-
__source: {
|
|
2860
|
-
fileName: _jsxFileName$3,
|
|
2861
|
-
lineNumber: 68,
|
|
2862
|
-
columnNumber: 9
|
|
2863
|
-
}
|
|
2864
|
-
}, parsedMetafield.value.toLocaleDateString(locale));
|
|
2865
|
-
}
|
|
2866
|
-
case "date_time": {
|
|
2867
|
-
const Wrapper2 = as != null ? as : "time";
|
|
2868
|
-
return /* @__PURE__ */ React__default.default.createElement(Wrapper2, {
|
|
2869
|
-
...passthroughProps,
|
|
2870
|
-
__self: this,
|
|
2871
|
-
__source: {
|
|
2872
|
-
fileName: _jsxFileName$3,
|
|
2873
|
-
lineNumber: 76,
|
|
2874
|
-
columnNumber: 9
|
|
2875
|
-
}
|
|
2876
|
-
}, parsedMetafield.value.toLocaleString(locale));
|
|
2877
|
-
}
|
|
2878
|
-
case "weight":
|
|
2879
|
-
case "dimension":
|
|
2880
|
-
case "volume": {
|
|
2881
|
-
const Wrapper2 = as != null ? as : "span";
|
|
2882
|
-
return /* @__PURE__ */ React__default.default.createElement(Wrapper2, {
|
|
2883
|
-
...passthroughProps,
|
|
2884
|
-
__self: this,
|
|
2885
|
-
__source: {
|
|
2886
|
-
fileName: _jsxFileName$3,
|
|
2887
|
-
lineNumber: 86,
|
|
2888
|
-
columnNumber: 9
|
|
2889
|
-
}
|
|
2890
|
-
}, getMeasurementAsString(parsedMetafield.value, locale));
|
|
2891
|
-
}
|
|
2892
|
-
case "rating": {
|
|
2893
|
-
const Wrapper2 = as != null ? as : "span";
|
|
2894
|
-
return /* @__PURE__ */ React__default.default.createElement(Wrapper2, {
|
|
2895
|
-
...passthroughProps,
|
|
2896
|
-
__self: this,
|
|
2897
|
-
__source: {
|
|
2898
|
-
fileName: _jsxFileName$3,
|
|
2899
|
-
lineNumber: 94,
|
|
2900
|
-
columnNumber: 9
|
|
2901
|
-
}
|
|
2902
|
-
}, parsedMetafield.value.value);
|
|
2903
|
-
}
|
|
2904
|
-
case "single_line_text_field": {
|
|
2905
|
-
const Wrapper2 = as != null ? as : "span";
|
|
2906
|
-
return /* @__PURE__ */ React__default.default.createElement(Wrapper2, {
|
|
2907
|
-
...passthroughProps,
|
|
2908
|
-
dangerouslySetInnerHTML: {
|
|
2909
|
-
__html: parsedMetafield.value
|
|
2910
|
-
},
|
|
2911
|
-
__self: this,
|
|
2912
|
-
__source: {
|
|
2913
|
-
fileName: _jsxFileName$3,
|
|
2914
|
-
lineNumber: 102,
|
|
2915
|
-
columnNumber: 9
|
|
2916
|
-
}
|
|
2917
|
-
});
|
|
2918
|
-
}
|
|
2919
|
-
case "multi_line_text_field": {
|
|
2920
|
-
const Wrapper2 = as != null ? as : "div";
|
|
2921
|
-
return /* @__PURE__ */ React__default.default.createElement(Wrapper2, {
|
|
2922
|
-
...passthroughProps,
|
|
2923
|
-
dangerouslySetInnerHTML: {
|
|
2924
|
-
__html: parsedMetafield.value.split("\n").join("<br/>")
|
|
2925
|
-
},
|
|
2926
|
-
__self: this,
|
|
2927
|
-
__source: {
|
|
2928
|
-
fileName: _jsxFileName$3,
|
|
2929
|
-
lineNumber: 111,
|
|
2930
|
-
columnNumber: 9
|
|
2931
|
-
}
|
|
2932
|
-
});
|
|
2933
|
-
}
|
|
2934
|
-
case "url": {
|
|
2935
|
-
const protocolLessUrl = new URL(parsedMetafield.value);
|
|
2936
|
-
return /* @__PURE__ */ React__default.default.createElement("a", {
|
|
2937
|
-
href: protocolLessUrl.href.replace(protocolLessUrl.protocol, ""),
|
|
2938
|
-
...passthroughProps,
|
|
2939
|
-
__self: this,
|
|
2940
|
-
__source: {
|
|
2941
|
-
fileName: _jsxFileName$3,
|
|
2942
|
-
lineNumber: 122,
|
|
2943
|
-
columnNumber: 9
|
|
2944
|
-
}
|
|
2945
|
-
}, parsedMetafield.value);
|
|
2946
|
-
}
|
|
2947
|
-
case "json": {
|
|
2948
|
-
const Wrapper2 = as != null ? as : "span";
|
|
2949
|
-
return /* @__PURE__ */ React__default.default.createElement(Wrapper2, {
|
|
2950
|
-
...passthroughProps,
|
|
2951
|
-
__self: this,
|
|
2952
|
-
__source: {
|
|
2953
|
-
fileName: _jsxFileName$3,
|
|
2954
|
-
lineNumber: 133,
|
|
2955
|
-
columnNumber: 9
|
|
2956
|
-
}
|
|
2957
|
-
}, JSON.stringify(parsedMetafield.value));
|
|
2958
|
-
}
|
|
2959
|
-
case "product_reference":
|
|
2960
|
-
case "variant_reference":
|
|
2961
|
-
case "page_reference": {
|
|
2962
|
-
const Wrapper2 = as != null ? as : "span";
|
|
2963
|
-
const ref = parsedMetafield.reference;
|
|
2964
|
-
return /* @__PURE__ */ React__default.default.createElement(Wrapper2, {
|
|
2965
|
-
...passthroughProps,
|
|
2966
|
-
__self: this,
|
|
2967
|
-
__source: {
|
|
2968
|
-
fileName: _jsxFileName$3,
|
|
2969
|
-
lineNumber: 144,
|
|
2970
|
-
columnNumber: 9
|
|
2971
|
-
}
|
|
2972
|
-
}, (_c = (_b = ref == null ? void 0 : ref.title) != null ? _b : ref == null ? void 0 : ref.id) != null ? _c : "");
|
|
2973
|
-
}
|
|
2974
|
-
case "list.single_line_text_field": {
|
|
2975
|
-
const Wrapper2 = as != null ? as : "ul";
|
|
2976
|
-
const refArray = parsedMetafield.references ? flattenConnection(parsedMetafield.references) : [];
|
|
2977
|
-
return /* @__PURE__ */ React__default.default.createElement(Wrapper2, {
|
|
2978
|
-
...passthroughProps,
|
|
2979
|
-
__self: this,
|
|
2980
|
-
__source: {
|
|
2981
|
-
fileName: _jsxFileName$3,
|
|
2982
|
-
lineNumber: 154,
|
|
2983
|
-
columnNumber: 9
|
|
2984
|
-
}
|
|
2985
|
-
}, refArray.map((ref, index2) => /* @__PURE__ */ React__default.default.createElement("li", {
|
|
2986
|
-
key: `${ref != null ? ref : ""}-${index2}`,
|
|
2987
|
-
__self: this,
|
|
2988
|
-
__source: {
|
|
2989
|
-
fileName: _jsxFileName$3,
|
|
2990
|
-
lineNumber: 158,
|
|
2991
|
-
columnNumber: 13
|
|
2992
|
-
}
|
|
2993
|
-
}, ref)));
|
|
2994
|
-
}
|
|
2995
|
-
case "file_reference": {
|
|
2996
|
-
if (((_d = parsedMetafield.reference) == null ? void 0 : _d.__typename) === "MediaImage") {
|
|
2997
|
-
const ref = parsedMetafield.reference;
|
|
2998
|
-
return ref.image ? /* @__PURE__ */ React__default.default.createElement(Image, {
|
|
2999
|
-
data: ref.image,
|
|
3000
|
-
...passthroughProps,
|
|
3001
|
-
__self: this,
|
|
3002
|
-
__source: {
|
|
3003
|
-
fileName: _jsxFileName$3,
|
|
3004
|
-
lineNumber: 167,
|
|
3005
|
-
columnNumber: 11
|
|
3006
|
-
}
|
|
3007
|
-
}) : null;
|
|
3008
|
-
} else if (((_e = parsedMetafield.reference) == null ? void 0 : _e.__typename) === "GenericFile") {
|
|
3009
|
-
const ref = parsedMetafield.reference;
|
|
3010
|
-
return ref.previewImage ? /* @__PURE__ */ React__default.default.createElement("a", {
|
|
3011
|
-
href: (_g = (_f = parsedMetafield.reference) == null ? void 0 : _f.url) != null ? _g : "",
|
|
3012
|
-
...passthroughProps,
|
|
3013
|
-
__self: this,
|
|
3014
|
-
__source: {
|
|
3015
|
-
fileName: _jsxFileName$3,
|
|
3016
|
-
lineNumber: 172,
|
|
3017
|
-
columnNumber: 11
|
|
3018
|
-
}
|
|
3019
|
-
}, /* @__PURE__ */ React__default.default.createElement(Image, {
|
|
3020
|
-
data: ref.previewImage,
|
|
3021
|
-
__self: this,
|
|
3022
|
-
__source: {
|
|
3023
|
-
fileName: _jsxFileName$3,
|
|
3024
|
-
lineNumber: 173,
|
|
3025
|
-
columnNumber: 13
|
|
3026
|
-
}
|
|
3027
|
-
})) : null;
|
|
3028
|
-
} else if (((_h = parsedMetafield.reference) == null ? void 0 : _h.__typename) === "Video") {
|
|
3029
|
-
const ref = parsedMetafield.reference;
|
|
3030
|
-
return /* @__PURE__ */ React__default.default.createElement(Video, {
|
|
3031
|
-
...passthroughProps,
|
|
3032
|
-
data: ref,
|
|
3033
|
-
__self: this,
|
|
3034
|
-
__source: {
|
|
3035
|
-
fileName: _jsxFileName$3,
|
|
3036
|
-
lineNumber: 178,
|
|
3037
|
-
columnNumber: 16
|
|
3038
|
-
}
|
|
3039
|
-
});
|
|
3040
|
-
}
|
|
3041
|
-
}
|
|
3042
|
-
}
|
|
3043
|
-
const Wrapper = as != null ? as : "span";
|
|
3044
|
-
return /* @__PURE__ */ React__default.default.createElement(Wrapper, {
|
|
3045
|
-
...passthroughProps,
|
|
3046
|
-
__self: this,
|
|
3047
|
-
__source: {
|
|
3048
|
-
fileName: _jsxFileName$3,
|
|
3049
|
-
lineNumber: 185,
|
|
3050
|
-
columnNumber: 5
|
|
3051
|
-
}
|
|
3052
|
-
}, (_i = parsedMetafield.value) == null ? void 0 : _i.toString());
|
|
3053
|
-
}
|
|
3054
3562
|
function parseMetafield(metafield) {
|
|
3055
|
-
{
|
|
3056
|
-
console.info(`'parseMetafield()' will have a breaking change in a future version; its behavior will match that of 'metafieldParser()'`);
|
|
3057
|
-
}
|
|
3058
|
-
if (!metafield) {
|
|
3059
|
-
{
|
|
3060
|
-
console.warn(`'parseMetafield' was not passed any value for the 'metafield' argument`);
|
|
3061
|
-
}
|
|
3062
|
-
return null;
|
|
3063
|
-
}
|
|
3064
|
-
if (metafield.value === null || metafield.value === void 0) {
|
|
3065
|
-
console.warn(`'parseMetafield()' was passed ${metafield.value} for 'metafield.value'`);
|
|
3066
|
-
}
|
|
3067
|
-
return {
|
|
3068
|
-
...metafield,
|
|
3069
|
-
value: parseMetafieldValue(metafield)
|
|
3070
|
-
};
|
|
3071
|
-
}
|
|
3072
|
-
function parseMetafieldValue(metafield) {
|
|
3073
|
-
{
|
|
3074
|
-
console.info(`'parseMetafieldValue()' will be removed in a future version`);
|
|
3075
|
-
}
|
|
3076
|
-
if (!metafield) {
|
|
3077
|
-
return null;
|
|
3078
|
-
}
|
|
3079
|
-
if (metafield.value === null || metafield.value === void 0) {
|
|
3080
|
-
{
|
|
3081
|
-
console.warn(`'parseMetafieldValue()' was passed ${metafield.value} for 'metafield.value'`);
|
|
3082
|
-
}
|
|
3083
|
-
return metafield.value;
|
|
3084
|
-
}
|
|
3085
|
-
switch (metafield.type) {
|
|
3086
|
-
case "boolean":
|
|
3087
|
-
return metafield.value === "true";
|
|
3088
|
-
case "number_integer":
|
|
3089
|
-
return parseInt(metafield.value);
|
|
3090
|
-
case "number_decimal":
|
|
3091
|
-
return parseFloat(metafield.value);
|
|
3092
|
-
case "date":
|
|
3093
|
-
case "date_time":
|
|
3094
|
-
return new Date(metafield.value);
|
|
3095
|
-
case "json":
|
|
3096
|
-
case "weight":
|
|
3097
|
-
case "dimension":
|
|
3098
|
-
case "volume":
|
|
3099
|
-
case "rating":
|
|
3100
|
-
return parseJSON(metafield.value);
|
|
3101
|
-
case "color":
|
|
3102
|
-
case "single_line_text_field":
|
|
3103
|
-
case "multi_line_text_field":
|
|
3104
|
-
case "product_reference":
|
|
3105
|
-
case "page_reference":
|
|
3106
|
-
case "variant_reference":
|
|
3107
|
-
case "file_reference":
|
|
3108
|
-
case "url":
|
|
3109
|
-
default:
|
|
3110
|
-
return metafield.value;
|
|
3111
|
-
}
|
|
3112
|
-
}
|
|
3113
|
-
function parseJSON(json) {
|
|
3114
|
-
if (String(json).includes("__proto__")) {
|
|
3115
|
-
return JSON.parse(json, (k, v2) => {
|
|
3116
|
-
if (k !== "__proto__")
|
|
3117
|
-
return v2;
|
|
3118
|
-
});
|
|
3119
|
-
}
|
|
3120
|
-
return JSON.parse(json);
|
|
3121
|
-
}
|
|
3122
|
-
const UNIT_MAPPING = {
|
|
3123
|
-
mm: "millimeter",
|
|
3124
|
-
cm: "centimeter",
|
|
3125
|
-
m: "meter",
|
|
3126
|
-
in: "inch",
|
|
3127
|
-
ft: "foot",
|
|
3128
|
-
yd: "yard",
|
|
3129
|
-
ml: "milliliter",
|
|
3130
|
-
l: "liter",
|
|
3131
|
-
us_fl_oz: "fluid-ounce",
|
|
3132
|
-
us_gal: "gallon",
|
|
3133
|
-
kg: "kilogram",
|
|
3134
|
-
g: "gram",
|
|
3135
|
-
lb: "pound",
|
|
3136
|
-
oz: "ounce"
|
|
3137
|
-
};
|
|
3138
|
-
function getMeasurementAsString(measurement, locale = "en-us", options = {}) {
|
|
3139
|
-
let measure = {
|
|
3140
|
-
value: measurement.value,
|
|
3141
|
-
unit: UNIT_MAPPING[measurement.unit]
|
|
3142
|
-
};
|
|
3143
|
-
if (measure.unit == null) {
|
|
3144
|
-
measure = convertToSupportedUnit(measurement.value, measurement.unit);
|
|
3145
|
-
}
|
|
3146
|
-
return new Intl.NumberFormat(locale, {
|
|
3147
|
-
...options,
|
|
3148
|
-
unit: measure.unit,
|
|
3149
|
-
style: "unit"
|
|
3150
|
-
}).format(measure.value);
|
|
3151
|
-
}
|
|
3152
|
-
function convertToSupportedUnit(value, unit) {
|
|
3153
|
-
switch (unit) {
|
|
3154
|
-
case "cl":
|
|
3155
|
-
return {
|
|
3156
|
-
value: value / 1e3,
|
|
3157
|
-
unit: "liter"
|
|
3158
|
-
};
|
|
3159
|
-
case "m3":
|
|
3160
|
-
return {
|
|
3161
|
-
value: value * 1e3,
|
|
3162
|
-
unit: "liter"
|
|
3163
|
-
};
|
|
3164
|
-
case "us_pt":
|
|
3165
|
-
return {
|
|
3166
|
-
value: value * 0.125,
|
|
3167
|
-
unit: "gallon"
|
|
3168
|
-
};
|
|
3169
|
-
case "us_qt":
|
|
3170
|
-
return {
|
|
3171
|
-
value: value * 0.5,
|
|
3172
|
-
unit: "gallon"
|
|
3173
|
-
};
|
|
3174
|
-
case "us_oz":
|
|
3175
|
-
return {
|
|
3176
|
-
value: value / 128,
|
|
3177
|
-
unit: "gallon"
|
|
3178
|
-
};
|
|
3179
|
-
case "imp_pt":
|
|
3180
|
-
return {
|
|
3181
|
-
value: value / 6.661,
|
|
3182
|
-
unit: "gallon"
|
|
3183
|
-
};
|
|
3184
|
-
case "imp_qt":
|
|
3185
|
-
return {
|
|
3186
|
-
value: value / 3.331,
|
|
3187
|
-
unit: "gallon"
|
|
3188
|
-
};
|
|
3189
|
-
case "imp_gal":
|
|
3190
|
-
return {
|
|
3191
|
-
value: value / 1.201,
|
|
3192
|
-
unit: "gallon"
|
|
3193
|
-
};
|
|
3194
|
-
case "imp_fl_oz":
|
|
3195
|
-
return {
|
|
3196
|
-
value: value * 0.96076,
|
|
3197
|
-
unit: "fluid-ounce"
|
|
3198
|
-
};
|
|
3199
|
-
default:
|
|
3200
|
-
throw new Error(`Unit not supported: ${unit}`);
|
|
3201
|
-
}
|
|
3202
|
-
}
|
|
3203
|
-
function metafieldParser(metafield) {
|
|
3204
|
-
var _a, _b, _c, _d;
|
|
3205
3563
|
if (!metafield.type) {
|
|
3206
|
-
const noTypeError = `
|
|
3564
|
+
const noTypeError = `parseMetafield(): The 'type' field is required in order to parse the Metafield.`;
|
|
3207
3565
|
{
|
|
3208
3566
|
throw new Error(noTypeError);
|
|
3209
3567
|
}
|
|
@@ -3248,9 +3606,9 @@
|
|
|
3248
3606
|
case "list.weight": {
|
|
3249
3607
|
let parsedValue = null;
|
|
3250
3608
|
try {
|
|
3251
|
-
parsedValue = parseJSON(
|
|
3609
|
+
parsedValue = parseJSON(metafield.value ?? "");
|
|
3252
3610
|
} catch (err) {
|
|
3253
|
-
const parseError = `
|
|
3611
|
+
const parseError = `parseMetafield(): attempted to JSON.parse the 'metafield.value' property, but failed.`;
|
|
3254
3612
|
{
|
|
3255
3613
|
throw new Error(parseError);
|
|
3256
3614
|
}
|
|
@@ -3264,11 +3622,11 @@
|
|
|
3264
3622
|
case "date_time":
|
|
3265
3623
|
return {
|
|
3266
3624
|
...metafield,
|
|
3267
|
-
parsedValue: new Date(
|
|
3625
|
+
parsedValue: new Date(metafield.value ?? "")
|
|
3268
3626
|
};
|
|
3269
3627
|
case "list.date":
|
|
3270
3628
|
case "list.date_time": {
|
|
3271
|
-
const jsonParseValue = parseJSON((
|
|
3629
|
+
const jsonParseValue = parseJSON((metafield == null ? void 0 : metafield.value) ?? "");
|
|
3272
3630
|
return {
|
|
3273
3631
|
...metafield,
|
|
3274
3632
|
parsedValue: jsonParseValue.map((dateString) => new Date(dateString))
|
|
@@ -3287,123 +3645,27 @@
|
|
|
3287
3645
|
case "list.variant_reference":
|
|
3288
3646
|
return {
|
|
3289
3647
|
...metafield,
|
|
3290
|
-
parsedValue: flattenConnection(
|
|
3648
|
+
parsedValue: flattenConnection(metafield.references ?? void 0)
|
|
3291
3649
|
};
|
|
3292
3650
|
default: {
|
|
3293
|
-
const typeNotFoundError = `
|
|
3651
|
+
const typeNotFoundError = `parseMetafield(): the 'metafield.type' you passed in is not supported. Your type: "${metafield.type}". If you believe this is an error, please open an issue on GitHub.`;
|
|
3294
3652
|
{
|
|
3295
3653
|
throw new Error(typeNotFoundError);
|
|
3296
3654
|
}
|
|
3297
3655
|
}
|
|
3298
3656
|
}
|
|
3299
3657
|
}
|
|
3300
|
-
function
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
}
|
|
3307
|
-
const amount = parseFloat(money.amount);
|
|
3308
|
-
const options = React.useMemo(() => ({
|
|
3309
|
-
style: "currency",
|
|
3310
|
-
currency: money.currencyCode
|
|
3311
|
-
}), [money.currencyCode]);
|
|
3312
|
-
const defaultFormatter = useLazyFormatter(locale, options);
|
|
3313
|
-
const nameFormatter = useLazyFormatter(locale, {
|
|
3314
|
-
...options,
|
|
3315
|
-
currencyDisplay: "name"
|
|
3316
|
-
});
|
|
3317
|
-
const narrowSymbolFormatter = useLazyFormatter(locale, {
|
|
3318
|
-
...options,
|
|
3319
|
-
currencyDisplay: "narrowSymbol"
|
|
3320
|
-
});
|
|
3321
|
-
const withoutTrailingZerosFormatter = useLazyFormatter(locale, {
|
|
3322
|
-
...options,
|
|
3323
|
-
minimumFractionDigits: 0,
|
|
3324
|
-
maximumFractionDigits: 0
|
|
3325
|
-
});
|
|
3326
|
-
const withoutCurrencyFormatter = useLazyFormatter(locale);
|
|
3327
|
-
const withoutTrailingZerosOrCurrencyFormatter = useLazyFormatter(locale, {
|
|
3328
|
-
minimumFractionDigits: 0,
|
|
3329
|
-
maximumFractionDigits: 0
|
|
3330
|
-
});
|
|
3331
|
-
const isPartCurrency = (part) => part.type === "currency";
|
|
3332
|
-
const lazyFormatters = React.useMemo(() => ({
|
|
3333
|
-
original: () => money,
|
|
3334
|
-
currencyCode: () => money.currencyCode,
|
|
3335
|
-
localizedString: () => defaultFormatter().format(amount),
|
|
3336
|
-
parts: () => defaultFormatter().formatToParts(amount),
|
|
3337
|
-
withoutTrailingZeros: () => amount % 1 === 0 ? withoutTrailingZerosFormatter().format(amount) : defaultFormatter().format(amount),
|
|
3338
|
-
withoutTrailingZerosAndCurrency: () => amount % 1 === 0 ? withoutTrailingZerosOrCurrencyFormatter().format(amount) : withoutCurrencyFormatter().format(amount),
|
|
3339
|
-
currencyName: () => {
|
|
3340
|
-
var _a, _b;
|
|
3341
|
-
return (_b = (_a = nameFormatter().formatToParts(amount).find(isPartCurrency)) == null ? void 0 : _a.value) != null ? _b : money.currencyCode;
|
|
3342
|
-
},
|
|
3343
|
-
currencySymbol: () => {
|
|
3344
|
-
var _a, _b;
|
|
3345
|
-
return (_b = (_a = defaultFormatter().formatToParts(amount).find(isPartCurrency)) == null ? void 0 : _a.value) != null ? _b : money.currencyCode;
|
|
3346
|
-
},
|
|
3347
|
-
currencyNarrowSymbol: () => {
|
|
3348
|
-
var _a, _b;
|
|
3349
|
-
return (_b = (_a = narrowSymbolFormatter().formatToParts(amount).find(isPartCurrency)) == null ? void 0 : _a.value) != null ? _b : "";
|
|
3350
|
-
},
|
|
3351
|
-
amount: () => defaultFormatter().formatToParts(amount).filter((part) => ["decimal", "fraction", "group", "integer", "literal"].includes(part.type)).map((part) => part.value).join("")
|
|
3352
|
-
}), [money, amount, nameFormatter, defaultFormatter, narrowSymbolFormatter, withoutCurrencyFormatter, withoutTrailingZerosFormatter, withoutTrailingZerosOrCurrencyFormatter]);
|
|
3353
|
-
return React.useMemo(() => new Proxy(lazyFormatters, {
|
|
3354
|
-
get: (target, key) => {
|
|
3355
|
-
var _a;
|
|
3356
|
-
return (_a = Reflect.get(target, key)) == null ? void 0 : _a.call(null);
|
|
3357
|
-
}
|
|
3358
|
-
}), [lazyFormatters]);
|
|
3359
|
-
}
|
|
3360
|
-
function useLazyFormatter(locale, options) {
|
|
3361
|
-
return React.useMemo(() => {
|
|
3362
|
-
let memoized;
|
|
3363
|
-
return () => memoized != null ? memoized : memoized = new Intl.NumberFormat(locale, options);
|
|
3364
|
-
}, [locale, options]);
|
|
3365
|
-
}
|
|
3366
|
-
var _jsxFileName$2 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Money.tsx";
|
|
3367
|
-
function Money({
|
|
3368
|
-
data,
|
|
3369
|
-
as,
|
|
3370
|
-
withoutCurrency,
|
|
3371
|
-
withoutTrailingZeros,
|
|
3372
|
-
measurement,
|
|
3373
|
-
measurementSeparator = "/",
|
|
3374
|
-
...passthroughProps
|
|
3375
|
-
}) {
|
|
3376
|
-
if (!isMoney(data)) {
|
|
3377
|
-
throw new Error(`<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'`);
|
|
3378
|
-
}
|
|
3379
|
-
const moneyObject = useMoney(data);
|
|
3380
|
-
const Wrapper = as != null ? as : "div";
|
|
3381
|
-
let output = moneyObject.localizedString;
|
|
3382
|
-
if (withoutCurrency || withoutTrailingZeros) {
|
|
3383
|
-
if (withoutCurrency && !withoutTrailingZeros) {
|
|
3384
|
-
output = moneyObject.amount;
|
|
3385
|
-
} else if (!withoutCurrency && withoutTrailingZeros) {
|
|
3386
|
-
output = moneyObject.withoutTrailingZeros;
|
|
3387
|
-
} else {
|
|
3388
|
-
output = moneyObject.withoutTrailingZerosAndCurrency;
|
|
3389
|
-
}
|
|
3658
|
+
function parseJSON(json) {
|
|
3659
|
+
if (String(json).includes("__proto__")) {
|
|
3660
|
+
return JSON.parse(json, (k, v2) => {
|
|
3661
|
+
if (k !== "__proto__")
|
|
3662
|
+
return v2;
|
|
3663
|
+
});
|
|
3390
3664
|
}
|
|
3391
|
-
return
|
|
3392
|
-
...passthroughProps,
|
|
3393
|
-
__self: this,
|
|
3394
|
-
__source: {
|
|
3395
|
-
fileName: _jsxFileName$2,
|
|
3396
|
-
lineNumber: 65,
|
|
3397
|
-
columnNumber: 5
|
|
3398
|
-
}
|
|
3399
|
-
}, output, measurement && measurement.referenceUnit && /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, measurementSeparator, measurement.referenceUnit));
|
|
3400
|
-
}
|
|
3401
|
-
function isMoney(maybeMoney) {
|
|
3402
|
-
return typeof maybeMoney.amount === "string" && !!maybeMoney.amount && typeof maybeMoney.currencyCode === "string" && !!maybeMoney.currencyCode;
|
|
3665
|
+
return JSON.parse(json);
|
|
3403
3666
|
}
|
|
3404
|
-
var _jsxFileName$1 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductPrice.tsx";
|
|
3405
3667
|
function ProductPrice(props) {
|
|
3406
|
-
var _a, _b, _c, _d, _e, _f
|
|
3668
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3407
3669
|
const {
|
|
3408
3670
|
priceType = "regular",
|
|
3409
3671
|
variantId,
|
|
@@ -3416,17 +3678,19 @@
|
|
|
3416
3678
|
}
|
|
3417
3679
|
let price;
|
|
3418
3680
|
let measurement;
|
|
3419
|
-
const variant = variantId ?
|
|
3681
|
+
const variant = variantId ? flattenConnection((product == null ? void 0 : product.variants) ?? {}).find(
|
|
3682
|
+
(variant2) => (variant2 == null ? void 0 : variant2.id) === variantId
|
|
3683
|
+
) ?? null : null;
|
|
3420
3684
|
if (priceType === "compareAt") {
|
|
3421
3685
|
if (variantId && variant) {
|
|
3422
|
-
if (((
|
|
3686
|
+
if (((_a = variant.compareAtPriceV2) == null ? void 0 : _a.amount) === ((_b = variant.priceV2) == null ? void 0 : _b.amount)) {
|
|
3423
3687
|
return null;
|
|
3424
3688
|
}
|
|
3425
3689
|
price = variant.compareAtPriceV2;
|
|
3426
3690
|
} else if (valueType === "max") {
|
|
3427
|
-
price = (
|
|
3691
|
+
price = (_c = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _c.maxVariantPrice;
|
|
3428
3692
|
} else {
|
|
3429
|
-
price = (
|
|
3693
|
+
price = (_d = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _d.minVariantPrice;
|
|
3430
3694
|
}
|
|
3431
3695
|
} else {
|
|
3432
3696
|
if (variantId && variant) {
|
|
@@ -3436,39 +3700,19 @@
|
|
|
3436
3700
|
measurement = variant.unitPriceMeasurement;
|
|
3437
3701
|
}
|
|
3438
3702
|
} else if (valueType === "max") {
|
|
3439
|
-
price = (
|
|
3703
|
+
price = (_e = product.priceRange) == null ? void 0 : _e.maxVariantPrice;
|
|
3440
3704
|
} else {
|
|
3441
|
-
price = (
|
|
3705
|
+
price = (_f = product.priceRange) == null ? void 0 : _f.minVariantPrice;
|
|
3442
3706
|
}
|
|
3443
3707
|
}
|
|
3444
3708
|
if (!price) {
|
|
3445
3709
|
return null;
|
|
3446
3710
|
}
|
|
3447
3711
|
if (measurement) {
|
|
3448
|
-
return /* @__PURE__ */
|
|
3449
|
-
...passthroughProps,
|
|
3450
|
-
data: price,
|
|
3451
|
-
measurement,
|
|
3452
|
-
__self: this,
|
|
3453
|
-
__source: {
|
|
3454
|
-
fileName: _jsxFileName$1,
|
|
3455
|
-
lineNumber: 81,
|
|
3456
|
-
columnNumber: 7
|
|
3457
|
-
}
|
|
3458
|
-
});
|
|
3712
|
+
return /* @__PURE__ */ React.createElement(Money, { ...passthroughProps, data: price, measurement });
|
|
3459
3713
|
}
|
|
3460
|
-
return /* @__PURE__ */
|
|
3461
|
-
...passthroughProps,
|
|
3462
|
-
data: price,
|
|
3463
|
-
__self: this,
|
|
3464
|
-
__source: {
|
|
3465
|
-
fileName: _jsxFileName$1,
|
|
3466
|
-
lineNumber: 85,
|
|
3467
|
-
columnNumber: 10
|
|
3468
|
-
}
|
|
3469
|
-
});
|
|
3714
|
+
return /* @__PURE__ */ React.createElement(Money, { ...passthroughProps, data: price });
|
|
3470
3715
|
}
|
|
3471
|
-
var _jsxFileName = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopPayButton.tsx";
|
|
3472
3716
|
const SHOPJS_URL = "https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js";
|
|
3473
3717
|
function ShopPayButton({
|
|
3474
3718
|
variantIds,
|
|
@@ -3476,17 +3720,15 @@
|
|
|
3476
3720
|
variantIdsAndQuantities,
|
|
3477
3721
|
width
|
|
3478
3722
|
}) {
|
|
3479
|
-
const {
|
|
3480
|
-
storeDomain
|
|
3481
|
-
} = useShop();
|
|
3723
|
+
const { storeDomain } = useShop();
|
|
3482
3724
|
const shopPayLoadedStatus = useLoadScript(SHOPJS_URL);
|
|
3483
|
-
let ids;
|
|
3725
|
+
let ids = [];
|
|
3484
3726
|
if (variantIds && variantIdsAndQuantities) {
|
|
3485
3727
|
throw new Error(DoublePropsErrorMessage);
|
|
3486
3728
|
}
|
|
3487
3729
|
if (variantIds) {
|
|
3488
3730
|
ids = variantIds.reduce((prev, curr) => {
|
|
3489
|
-
const bareId =
|
|
3731
|
+
const bareId = parseGid(curr).id;
|
|
3490
3732
|
if (bareId) {
|
|
3491
3733
|
prev.push(bareId);
|
|
3492
3734
|
}
|
|
@@ -3494,71 +3736,92 @@
|
|
|
3494
3736
|
}, []);
|
|
3495
3737
|
} else if (variantIdsAndQuantities) {
|
|
3496
3738
|
ids = variantIdsAndQuantities.reduce((prev, curr) => {
|
|
3497
|
-
|
|
3498
|
-
const bareId = getIdFromGid(curr == null ? void 0 : curr.id);
|
|
3739
|
+
const bareId = parseGid(curr == null ? void 0 : curr.id).id;
|
|
3499
3740
|
if (bareId) {
|
|
3500
|
-
prev.push(`${bareId}:${(
|
|
3741
|
+
prev.push(`${bareId}:${(curr == null ? void 0 : curr.quantity) ?? 1}`);
|
|
3501
3742
|
}
|
|
3502
3743
|
return prev;
|
|
3503
3744
|
}, []);
|
|
3504
3745
|
} else {
|
|
3505
3746
|
throw new Error(MissingPropsErrorMessage);
|
|
3506
3747
|
}
|
|
3748
|
+
if (ids.length === 0) {
|
|
3749
|
+
throw new Error(InvalidPropsErrorMessage);
|
|
3750
|
+
}
|
|
3507
3751
|
const style = width ? {
|
|
3508
3752
|
"--shop-pay-button-width": width
|
|
3509
3753
|
} : void 0;
|
|
3510
|
-
return /* @__PURE__ */
|
|
3511
|
-
className,
|
|
3512
|
-
style,
|
|
3513
|
-
__self: this,
|
|
3514
|
-
__source: {
|
|
3515
|
-
fileName: _jsxFileName,
|
|
3516
|
-
lineNumber: 90,
|
|
3517
|
-
columnNumber: 5
|
|
3518
|
-
}
|
|
3519
|
-
}, shopPayLoadedStatus === "done" && /* @__PURE__ */ React__default.default.createElement("shop-pay-button", {
|
|
3520
|
-
"store-url": `https://${storeDomain}`,
|
|
3521
|
-
variants: ids.join(","),
|
|
3522
|
-
__self: this,
|
|
3523
|
-
__source: {
|
|
3524
|
-
fileName: _jsxFileName,
|
|
3525
|
-
lineNumber: 92,
|
|
3526
|
-
columnNumber: 9
|
|
3527
|
-
}
|
|
3528
|
-
}));
|
|
3529
|
-
}
|
|
3530
|
-
function getIdFromGid(id) {
|
|
3531
|
-
if (!id)
|
|
3532
|
-
return;
|
|
3533
|
-
return id.split("/").pop();
|
|
3754
|
+
return /* @__PURE__ */ React.createElement("div", { className, style }, shopPayLoadedStatus === "done" && /* @__PURE__ */ React.createElement("shop-pay-button", { "store-url": storeDomain, variants: ids.join(",") }));
|
|
3534
3755
|
}
|
|
3756
|
+
const InvalidPropsErrorMessage = `You must pass in "variantIds" in the form of ["gid://shopify/ProductVariant/1"]`;
|
|
3535
3757
|
const MissingPropsErrorMessage = `You must pass in either "variantIds" or "variantIdsAndQuantities" to ShopPayButton`;
|
|
3536
3758
|
const DoublePropsErrorMessage = `You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component`;
|
|
3759
|
+
const longTermLength = 60 * 60 * 24 * 360 * 1;
|
|
3760
|
+
const shortTermLength = 60 * 30;
|
|
3761
|
+
function useShopifyCookies(options) {
|
|
3762
|
+
const { hasUserConsent = false, domain = "" } = options || {};
|
|
3763
|
+
React.useEffect(() => {
|
|
3764
|
+
const cookies = getShopifyCookies(document.cookie);
|
|
3765
|
+
if (hasUserConsent) {
|
|
3766
|
+
setCookie(
|
|
3767
|
+
SHOPIFY_Y,
|
|
3768
|
+
cookies[SHOPIFY_Y] || buildUUID(),
|
|
3769
|
+
longTermLength,
|
|
3770
|
+
domain
|
|
3771
|
+
);
|
|
3772
|
+
setCookie(
|
|
3773
|
+
SHOPIFY_S,
|
|
3774
|
+
cookies[SHOPIFY_S] || buildUUID(),
|
|
3775
|
+
shortTermLength,
|
|
3776
|
+
domain
|
|
3777
|
+
);
|
|
3778
|
+
} else {
|
|
3779
|
+
setCookie(SHOPIFY_Y, "", 0, domain);
|
|
3780
|
+
setCookie(SHOPIFY_S, "", 0, domain);
|
|
3781
|
+
}
|
|
3782
|
+
});
|
|
3783
|
+
}
|
|
3784
|
+
function setCookie(name, value, maxage, domain) {
|
|
3785
|
+
document.cookie = l(name, value, {
|
|
3786
|
+
maxage,
|
|
3787
|
+
domain,
|
|
3788
|
+
samesite: "Lax",
|
|
3789
|
+
path: "/"
|
|
3790
|
+
});
|
|
3791
|
+
}
|
|
3537
3792
|
exports2.AddToCartButton = AddToCartButton;
|
|
3793
|
+
exports2.AnalyticsEventName = AnalyticsEventName;
|
|
3794
|
+
exports2.AnalyticsPageType = AnalyticsPageType;
|
|
3538
3795
|
exports2.BuyNowButton = BuyNowButton;
|
|
3539
3796
|
exports2.CartCheckoutButton = CartCheckoutButton;
|
|
3797
|
+
exports2.CartCost = CartCost;
|
|
3798
|
+
exports2.CartLinePrice = CartLinePrice;
|
|
3799
|
+
exports2.CartLineProvider = CartLineProvider;
|
|
3540
3800
|
exports2.CartProvider = CartProvider;
|
|
3541
3801
|
exports2.ExternalVideo = ExternalVideo;
|
|
3542
3802
|
exports2.Image = Image;
|
|
3543
3803
|
exports2.MediaFile = MediaFile;
|
|
3544
|
-
exports2.Metafield = Metafield;
|
|
3545
3804
|
exports2.ModelViewer = ModelViewer;
|
|
3546
3805
|
exports2.Money = Money;
|
|
3547
3806
|
exports2.ProductPrice = ProductPrice;
|
|
3548
3807
|
exports2.ProductProvider = ProductProvider;
|
|
3549
3808
|
exports2.ShopPayButton = ShopPayButton;
|
|
3550
3809
|
exports2.ShopifyProvider = ShopifyProvider;
|
|
3810
|
+
exports2.ShopifySalesChannel = ShopifySalesChannel;
|
|
3551
3811
|
exports2.Video = Video;
|
|
3552
3812
|
exports2.createStorefrontClient = createStorefrontClient;
|
|
3553
3813
|
exports2.flattenConnection = flattenConnection;
|
|
3554
|
-
exports2.
|
|
3814
|
+
exports2.getClientBrowserParameters = getClientBrowserParameters;
|
|
3815
|
+
exports2.getShopifyCookies = getShopifyCookies;
|
|
3555
3816
|
exports2.parseMetafield = parseMetafield;
|
|
3556
|
-
exports2.
|
|
3817
|
+
exports2.sendShopifyAnalytics = sendShopifyAnalytics;
|
|
3557
3818
|
exports2.storefrontApiCustomScalars = storefrontApiCustomScalars;
|
|
3558
3819
|
exports2.useCart = useCart;
|
|
3820
|
+
exports2.useCartLine = useCartLine;
|
|
3559
3821
|
exports2.useMoney = useMoney;
|
|
3560
3822
|
exports2.useProduct = useProduct;
|
|
3561
3823
|
exports2.useShop = useShop;
|
|
3562
|
-
|
|
3824
|
+
exports2.useShopifyCookies = useShopifyCookies;
|
|
3825
|
+
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
3563
3826
|
});
|
|
3564
3827
|
//# sourceMappingURL=hydrogen-react.dev.js.map
|