@shopify/hydrogen-react 0.0.0-next-5c16c78 → 0.0.0-next-ea3959b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-dev/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/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 +4 -14
- package/dist/browser-dev/ShopPayButton.mjs.map +1 -1
- package/dist/browser-dev/ShopifyProvider.mjs +20 -15
- 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/cart-hooks.mjs +31 -34
- package/dist/browser-dev/cart-hooks.mjs.map +1 -1
- package/dist/browser-dev/cart-queries.mjs +50 -20
- 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/image-size.mjs +8 -8
- package/dist/browser-dev/image-size.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/parse-metafield.mjs +4 -5
- package/dist/browser-dev/parse-metafield.mjs.map +1 -1
- package/dist/browser-dev/storefront-client.mjs +8 -10
- 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 +61 -36
- package/dist/browser-dev/useMoney.mjs.map +1 -1
- 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/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 +4 -14
- package/dist/browser-prod/ShopPayButton.mjs.map +1 -1
- package/dist/browser-prod/ShopifyProvider.mjs +17 -14
- 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/cart-hooks.mjs +31 -34
- package/dist/browser-prod/cart-hooks.mjs.map +1 -1
- package/dist/browser-prod/cart-queries.mjs +50 -20
- 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/image-size.mjs +8 -8
- package/dist/browser-prod/image-size.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/parse-metafield.mjs +4 -5
- package/dist/browser-prod/parse-metafield.mjs.map +1 -1
- package/dist/browser-prod/storefront-client.mjs +8 -10
- 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 +61 -36
- package/dist/browser-prod/useMoney.mjs.map +1 -1
- 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/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 +5 -15
- package/dist/node-dev/ShopPayButton.js.map +1 -1
- package/dist/node-dev/ShopPayButton.mjs +4 -14
- package/dist/node-dev/ShopPayButton.mjs.map +1 -1
- package/dist/node-dev/ShopifyProvider.js +21 -16
- package/dist/node-dev/ShopifyProvider.js.map +1 -1
- package/dist/node-dev/ShopifyProvider.mjs +20 -15
- 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/cart-constants.js +1 -1
- package/dist/node-dev/cart-hooks.js +32 -35
- package/dist/node-dev/cart-hooks.js.map +1 -1
- package/dist/node-dev/cart-hooks.mjs +31 -34
- package/dist/node-dev/cart-hooks.mjs.map +1 -1
- package/dist/node-dev/cart-queries.js +51 -21
- package/dist/node-dev/cart-queries.js.map +1 -1
- package/dist/node-dev/cart-queries.mjs +50 -20
- 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/flatten-connection.js +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 +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/parse-metafield.js +5 -6
- package/dist/node-dev/parse-metafield.js.map +1 -1
- package/dist/node-dev/parse-metafield.mjs +4 -5
- package/dist/node-dev/parse-metafield.mjs.map +1 -1
- package/dist/node-dev/storefront-api-constants.js +1 -1
- package/dist/node-dev/storefront-client.js +9 -11
- package/dist/node-dev/storefront-client.js.map +1 -1
- package/dist/node-dev/storefront-client.mjs +8 -10
- 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 +62 -37
- package/dist/node-dev/useMoney.js.map +1 -1
- package/dist/node-dev/useMoney.mjs +61 -36
- package/dist/node-dev/useMoney.mjs.map +1 -1
- 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/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 +5 -15
- package/dist/node-prod/ShopPayButton.js.map +1 -1
- package/dist/node-prod/ShopPayButton.mjs +4 -14
- package/dist/node-prod/ShopPayButton.mjs.map +1 -1
- package/dist/node-prod/ShopifyProvider.js +18 -15
- package/dist/node-prod/ShopifyProvider.js.map +1 -1
- package/dist/node-prod/ShopifyProvider.mjs +17 -14
- 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/cart-constants.js +1 -1
- package/dist/node-prod/cart-hooks.js +32 -35
- package/dist/node-prod/cart-hooks.js.map +1 -1
- package/dist/node-prod/cart-hooks.mjs +31 -34
- package/dist/node-prod/cart-hooks.mjs.map +1 -1
- package/dist/node-prod/cart-queries.js +51 -21
- package/dist/node-prod/cart-queries.js.map +1 -1
- package/dist/node-prod/cart-queries.mjs +50 -20
- 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/flatten-connection.js +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 +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/parse-metafield.js +5 -6
- package/dist/node-prod/parse-metafield.js.map +1 -1
- package/dist/node-prod/parse-metafield.mjs +4 -5
- package/dist/node-prod/parse-metafield.mjs.map +1 -1
- package/dist/node-prod/storefront-api-constants.js +1 -1
- package/dist/node-prod/storefront-client.js +9 -11
- package/dist/node-prod/storefront-client.js.map +1 -1
- package/dist/node-prod/storefront-client.mjs +8 -10
- 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 +62 -37
- package/dist/node-prod/useMoney.js.map +1 -1
- package/dist/node-prod/useMoney.mjs +61 -36
- package/dist/node-prod/useMoney.mjs.map +1 -1
- package/dist/types/parse-metafield.d.ts +1 -1
- package/dist/umd/hydrogen-react.dev.js +994 -880
- package/dist/umd/hydrogen-react.dev.js.map +1 -1
- package/dist/umd/hydrogen-react.prod.js +16 -16
- package/dist/umd/hydrogen-react.prod.js.map +1 -1
- package/package.json +13 -13
|
@@ -2,10 +2,7 @@
|
|
|
2
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.hydrogenreact = {}, 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
|
|
|
@@ -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,7 +647,7 @@
|
|
|
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) {
|
|
@@ -665,7 +677,9 @@
|
|
|
665
677
|
}
|
|
666
678
|
return [];
|
|
667
679
|
}
|
|
668
|
-
const CartLineAdd = (cartFragment) =>
|
|
680
|
+
const CartLineAdd = (cartFragment) => (
|
|
681
|
+
/* GraphQL */
|
|
682
|
+
`
|
|
669
683
|
mutation CartLineAdd(
|
|
670
684
|
$cartId: ID!
|
|
671
685
|
$lines: [CartLineInput!]!
|
|
@@ -680,8 +694,11 @@
|
|
|
680
694
|
}
|
|
681
695
|
|
|
682
696
|
${cartFragment}
|
|
683
|
-
|
|
684
|
-
|
|
697
|
+
`
|
|
698
|
+
);
|
|
699
|
+
const CartCreate = (cartFragment) => (
|
|
700
|
+
/* GraphQL */
|
|
701
|
+
`
|
|
685
702
|
mutation CartCreate(
|
|
686
703
|
$input: CartInput!
|
|
687
704
|
$numCartLines: Int = 250
|
|
@@ -695,8 +712,11 @@
|
|
|
695
712
|
}
|
|
696
713
|
|
|
697
714
|
${cartFragment}
|
|
698
|
-
|
|
699
|
-
|
|
715
|
+
`
|
|
716
|
+
);
|
|
717
|
+
const CartLineRemove = (cartFragment) => (
|
|
718
|
+
/* GraphQL */
|
|
719
|
+
`
|
|
700
720
|
mutation CartLineRemove(
|
|
701
721
|
$cartId: ID!
|
|
702
722
|
$lines: [ID!]!
|
|
@@ -711,8 +731,11 @@
|
|
|
711
731
|
}
|
|
712
732
|
|
|
713
733
|
${cartFragment}
|
|
714
|
-
|
|
715
|
-
|
|
734
|
+
`
|
|
735
|
+
);
|
|
736
|
+
const CartLineUpdate = (cartFragment) => (
|
|
737
|
+
/* GraphQL */
|
|
738
|
+
`
|
|
716
739
|
mutation CartLineUpdate(
|
|
717
740
|
$cartId: ID!
|
|
718
741
|
$lines: [CartLineUpdateInput!]!
|
|
@@ -727,8 +750,11 @@
|
|
|
727
750
|
}
|
|
728
751
|
|
|
729
752
|
${cartFragment}
|
|
730
|
-
|
|
731
|
-
|
|
753
|
+
`
|
|
754
|
+
);
|
|
755
|
+
const CartNoteUpdate = (cartFragment) => (
|
|
756
|
+
/* GraphQL */
|
|
757
|
+
`
|
|
732
758
|
mutation CartNoteUpdate(
|
|
733
759
|
$cartId: ID!
|
|
734
760
|
$note: String
|
|
@@ -743,8 +769,11 @@
|
|
|
743
769
|
}
|
|
744
770
|
|
|
745
771
|
${cartFragment}
|
|
746
|
-
|
|
747
|
-
|
|
772
|
+
`
|
|
773
|
+
);
|
|
774
|
+
const CartBuyerIdentityUpdate = (cartFragment) => (
|
|
775
|
+
/* GraphQL */
|
|
776
|
+
`
|
|
748
777
|
mutation CartBuyerIdentityUpdate(
|
|
749
778
|
$cartId: ID!
|
|
750
779
|
$buyerIdentity: CartBuyerIdentityInput!
|
|
@@ -759,8 +788,11 @@
|
|
|
759
788
|
}
|
|
760
789
|
|
|
761
790
|
${cartFragment}
|
|
762
|
-
|
|
763
|
-
|
|
791
|
+
`
|
|
792
|
+
);
|
|
793
|
+
const CartAttributesUpdate = (cartFragment) => (
|
|
794
|
+
/* GraphQL */
|
|
795
|
+
`
|
|
764
796
|
mutation CartAttributesUpdate(
|
|
765
797
|
$attributes: [AttributeInput!]!
|
|
766
798
|
$cartId: ID!
|
|
@@ -775,8 +807,11 @@
|
|
|
775
807
|
}
|
|
776
808
|
|
|
777
809
|
${cartFragment}
|
|
778
|
-
|
|
779
|
-
|
|
810
|
+
`
|
|
811
|
+
);
|
|
812
|
+
const CartDiscountCodesUpdate = (cartFragment) => (
|
|
813
|
+
/* GraphQL */
|
|
814
|
+
`
|
|
780
815
|
mutation CartDiscountCodesUpdate(
|
|
781
816
|
$cartId: ID!
|
|
782
817
|
$discountCodes: [String!]
|
|
@@ -791,8 +826,11 @@
|
|
|
791
826
|
}
|
|
792
827
|
|
|
793
828
|
${cartFragment}
|
|
794
|
-
|
|
795
|
-
|
|
829
|
+
`
|
|
830
|
+
);
|
|
831
|
+
const CartQuery = (cartFragment) => (
|
|
832
|
+
/* GraphQL */
|
|
833
|
+
`
|
|
796
834
|
query CartQuery(
|
|
797
835
|
$id: ID!
|
|
798
836
|
$numCartLines: Int = 250
|
|
@@ -804,8 +842,11 @@
|
|
|
804
842
|
}
|
|
805
843
|
|
|
806
844
|
${cartFragment}
|
|
807
|
-
|
|
808
|
-
|
|
845
|
+
`
|
|
846
|
+
);
|
|
847
|
+
const defaultCartFragment = (
|
|
848
|
+
/* GraphQL */
|
|
849
|
+
`
|
|
809
850
|
fragment CartFragment on Cart {
|
|
810
851
|
id
|
|
811
852
|
checkoutUrl
|
|
@@ -905,7 +946,8 @@
|
|
|
905
946
|
width
|
|
906
947
|
height
|
|
907
948
|
}
|
|
908
|
-
|
|
949
|
+
`
|
|
950
|
+
);
|
|
909
951
|
const SFAPI_VERSION = "2023-01";
|
|
910
952
|
const warnings = /* @__PURE__ */ new Set();
|
|
911
953
|
const warnOnce = (string) => {
|
|
@@ -938,15 +980,12 @@
|
|
|
938
980
|
}
|
|
939
981
|
return {
|
|
940
982
|
getShopifyDomain(overrideProps) {
|
|
941
|
-
|
|
942
|
-
return `https://${(_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : storeDomain}.myshopify.com`;
|
|
983
|
+
return `https://${(overrideProps == null ? void 0 : overrideProps.storeDomain) ?? storeDomain}.myshopify.com`;
|
|
943
984
|
},
|
|
944
985
|
getStorefrontApiUrl(overrideProps) {
|
|
945
|
-
|
|
946
|
-
return `https://${(_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : storeDomain}.myshopify.com/api/${(_b = overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) != null ? _b : storefrontApiVersion}/graphql.json`;
|
|
986
|
+
return `https://${(overrideProps == null ? void 0 : overrideProps.storeDomain) ?? storeDomain}.myshopify.com/api/${(overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) ?? storefrontApiVersion}/graphql.json`;
|
|
947
987
|
},
|
|
948
988
|
getPrivateTokenHeaders(overrideProps) {
|
|
949
|
-
var _a, _b, _c;
|
|
950
989
|
if (!privateStorefrontToken && !(overrideProps == null ? void 0 : overrideProps.privateStorefrontToken)) {
|
|
951
990
|
throw new Error(
|
|
952
991
|
`StorefrontClient: You did not pass in a 'privateStorefrontToken' while using 'getPrivateTokenHeaders()'`
|
|
@@ -957,34 +996,35 @@
|
|
|
957
996
|
`StorefrontClient: it is recommended to pass in the 'buyerIp' property which improves analytics and data in the admin.`
|
|
958
997
|
);
|
|
959
998
|
}
|
|
960
|
-
const finalContentType = (
|
|
999
|
+
const finalContentType = (overrideProps == null ? void 0 : overrideProps.contentType) ?? contentType;
|
|
961
1000
|
return {
|
|
1001
|
+
// default to json
|
|
962
1002
|
"content-type": finalContentType === "graphql" ? "application/graphql" : "application/json",
|
|
963
1003
|
"X-SDK-Variant": "hydrogen-ui",
|
|
964
1004
|
"X-SDK-Variant-Source": "react",
|
|
965
1005
|
"X-SDK-Version": storefrontApiVersion,
|
|
966
|
-
"Shopify-Storefront-Private-Token": (
|
|
1006
|
+
"Shopify-Storefront-Private-Token": (overrideProps == null ? void 0 : overrideProps.privateStorefrontToken) ?? privateStorefrontToken ?? "",
|
|
967
1007
|
...(overrideProps == null ? void 0 : overrideProps.buyerIp) ? { "Shopify-Storefront-Buyer-IP": overrideProps.buyerIp } : {}
|
|
968
1008
|
};
|
|
969
1009
|
},
|
|
970
1010
|
getPublicTokenHeaders(overrideProps) {
|
|
971
|
-
var _a, _b, _c, _d;
|
|
972
1011
|
if (!publicStorefrontToken && !(overrideProps == null ? void 0 : overrideProps.publicStorefrontToken)) {
|
|
973
1012
|
throw new Error(
|
|
974
1013
|
`StorefrontClient: You did not pass in a 'publicStorefrontToken' while using 'getPublicTokenHeaders()'`
|
|
975
1014
|
);
|
|
976
1015
|
}
|
|
977
|
-
const finalContentType = (
|
|
1016
|
+
const finalContentType = (overrideProps == null ? void 0 : overrideProps.contentType) ?? contentType ?? "json";
|
|
978
1017
|
return getPublicTokenHeadersRaw(
|
|
979
1018
|
finalContentType,
|
|
980
1019
|
storefrontApiVersion,
|
|
981
|
-
(
|
|
1020
|
+
(overrideProps == null ? void 0 : overrideProps.publicStorefrontToken) ?? publicStorefrontToken ?? ""
|
|
982
1021
|
);
|
|
983
1022
|
}
|
|
984
1023
|
};
|
|
985
1024
|
}
|
|
986
1025
|
function getPublicTokenHeadersRaw(contentType, storefrontApiVersion, accessToken) {
|
|
987
1026
|
return {
|
|
1027
|
+
// default to json
|
|
988
1028
|
"content-type": contentType === "graphql" ? "application/graphql" : "application/json",
|
|
989
1029
|
"X-SDK-Variant": "hydrogen-ui",
|
|
990
1030
|
"X-SDK-Variant-Source": "react",
|
|
@@ -992,7 +1032,6 @@
|
|
|
992
1032
|
"X-Shopify-Storefront-Access-Token": accessToken
|
|
993
1033
|
};
|
|
994
1034
|
}
|
|
995
|
-
var _jsxFileName$e = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopifyProvider.tsx";
|
|
996
1035
|
const ShopifyContext = React.createContext({
|
|
997
1036
|
storeDomain: "test",
|
|
998
1037
|
storefrontToken: "abc123",
|
|
@@ -1019,45 +1058,45 @@
|
|
|
1019
1058
|
shopifyConfig
|
|
1020
1059
|
}) {
|
|
1021
1060
|
if (!shopifyConfig) {
|
|
1022
|
-
throw new Error(
|
|
1061
|
+
throw new Error(
|
|
1062
|
+
`The 'shopifyConfig' prop must be passed to '<ShopifyProvider/>'`
|
|
1063
|
+
);
|
|
1023
1064
|
}
|
|
1024
1065
|
if (shopifyConfig.storefrontApiVersion !== SFAPI_VERSION) {
|
|
1025
|
-
console.warn(
|
|
1066
|
+
console.warn(
|
|
1067
|
+
`<ShopifyProvider/>: This version of Hydrogen-UI 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-UI and the Storefront API.`
|
|
1068
|
+
);
|
|
1026
1069
|
}
|
|
1027
1070
|
const finalConfig = React.useMemo(() => {
|
|
1028
1071
|
function getShopifyDomain(overrideProps) {
|
|
1029
|
-
|
|
1030
|
-
return (_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : shopifyConfig.storeDomain;
|
|
1072
|
+
return (overrideProps == null ? void 0 : overrideProps.storeDomain) ?? shopifyConfig.storeDomain;
|
|
1031
1073
|
}
|
|
1032
1074
|
return {
|
|
1033
1075
|
...shopifyConfig,
|
|
1034
1076
|
getPublicTokenHeaders(overrideProps) {
|
|
1035
|
-
|
|
1036
|
-
|
|
1077
|
+
return getPublicTokenHeadersRaw(
|
|
1078
|
+
overrideProps.contentType,
|
|
1079
|
+
shopifyConfig.storefrontApiVersion,
|
|
1080
|
+
overrideProps.storefrontToken ?? shopifyConfig.storefrontToken
|
|
1081
|
+
);
|
|
1037
1082
|
},
|
|
1038
1083
|
getShopifyDomain,
|
|
1039
1084
|
getStorefrontApiUrl(overrideProps) {
|
|
1040
|
-
var _a
|
|
1085
|
+
var _a;
|
|
1041
1086
|
if ((_a = overrideProps == null ? void 0 : overrideProps.storeDomain) == null ? void 0 : _a.includes(".myshopify.com")) {
|
|
1042
1087
|
{
|
|
1043
|
-
console.warn(
|
|
1088
|
+
console.warn(
|
|
1089
|
+
`<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.`
|
|
1090
|
+
);
|
|
1044
1091
|
}
|
|
1045
1092
|
}
|
|
1046
1093
|
return `${getShopifyDomain({
|
|
1047
|
-
storeDomain: (
|
|
1048
|
-
})}/api/${(
|
|
1094
|
+
storeDomain: (overrideProps == null ? void 0 : overrideProps.storeDomain) ?? shopifyConfig.storeDomain
|
|
1095
|
+
})}/api/${(overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) ?? shopifyConfig.storefrontApiVersion}/graphql.json`;
|
|
1049
1096
|
}
|
|
1050
1097
|
};
|
|
1051
1098
|
}, [shopifyConfig]);
|
|
1052
|
-
return /* @__PURE__ */
|
|
1053
|
-
value: finalConfig,
|
|
1054
|
-
__self: this,
|
|
1055
|
-
__source: {
|
|
1056
|
-
fileName: _jsxFileName$e,
|
|
1057
|
-
lineNumber: 84,
|
|
1058
|
-
columnNumber: 5
|
|
1059
|
-
}
|
|
1060
|
-
}, children);
|
|
1099
|
+
return /* @__PURE__ */ React.createElement(ShopifyContext.Provider, { value: finalConfig }, children);
|
|
1061
1100
|
}
|
|
1062
1101
|
function useShop() {
|
|
1063
1102
|
const shopContext = React.useContext(ShopifyContext);
|
|
@@ -1096,40 +1135,37 @@
|
|
|
1096
1135
|
return r2;
|
|
1097
1136
|
}
|
|
1098
1137
|
function useCartFetch() {
|
|
1099
|
-
const {
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
};
|
|
1131
|
-
});
|
|
1132
|
-
}, [getPublicTokenHeaders, storefrontId, getStorefrontApiUrl]);
|
|
1138
|
+
const { storefrontId, getPublicTokenHeaders, getStorefrontApiUrl } = useShop();
|
|
1139
|
+
return React.useCallback(
|
|
1140
|
+
({
|
|
1141
|
+
query,
|
|
1142
|
+
variables
|
|
1143
|
+
}) => {
|
|
1144
|
+
const headers = getPublicTokenHeaders({ contentType: "json" });
|
|
1145
|
+
if (storefrontId) {
|
|
1146
|
+
headers[SHOPIFY_STOREFRONT_ID_HEADER] = storefrontId;
|
|
1147
|
+
}
|
|
1148
|
+
const cookieData = u(document.cookie);
|
|
1149
|
+
if (cookieData[SHOPIFY_Y] && cookieData[SHOPIFY_S]) {
|
|
1150
|
+
headers[SHOPIFY_STOREFRONT_Y_HEADER] = cookieData[SHOPIFY_Y];
|
|
1151
|
+
headers[SHOPIFY_STOREFRONT_S_HEADER] = cookieData[SHOPIFY_S];
|
|
1152
|
+
}
|
|
1153
|
+
return fetch(getStorefrontApiUrl(), {
|
|
1154
|
+
method: "POST",
|
|
1155
|
+
headers,
|
|
1156
|
+
body: JSON.stringify({
|
|
1157
|
+
query: query.toString(),
|
|
1158
|
+
variables
|
|
1159
|
+
})
|
|
1160
|
+
}).then((res) => res.json()).catch((error) => {
|
|
1161
|
+
return {
|
|
1162
|
+
data: void 0,
|
|
1163
|
+
errors: error.toString()
|
|
1164
|
+
};
|
|
1165
|
+
});
|
|
1166
|
+
},
|
|
1167
|
+
[getPublicTokenHeaders, storefrontId, getStorefrontApiUrl]
|
|
1168
|
+
);
|
|
1133
1169
|
}
|
|
1134
1170
|
function useCartActions({
|
|
1135
1171
|
numCartLines,
|
|
@@ -1137,155 +1173,212 @@
|
|
|
1137
1173
|
countryCode = "US"
|
|
1138
1174
|
}) {
|
|
1139
1175
|
const fetchCart = useCartFetch();
|
|
1140
|
-
const cartFetch = React.useCallback(
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
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
|
-
|
|
1176
|
+
const cartFetch = React.useCallback(
|
|
1177
|
+
(cartId) => {
|
|
1178
|
+
return fetchCart({
|
|
1179
|
+
query: CartQuery(cartFragment),
|
|
1180
|
+
variables: {
|
|
1181
|
+
id: cartId,
|
|
1182
|
+
numCartLines,
|
|
1183
|
+
country: countryCode
|
|
1184
|
+
}
|
|
1185
|
+
});
|
|
1186
|
+
},
|
|
1187
|
+
[fetchCart, cartFragment, numCartLines, countryCode]
|
|
1188
|
+
);
|
|
1189
|
+
const cartCreate = React.useCallback(
|
|
1190
|
+
(cart) => {
|
|
1191
|
+
return fetchCart({
|
|
1192
|
+
query: CartCreate(cartFragment),
|
|
1193
|
+
variables: {
|
|
1194
|
+
input: cart,
|
|
1195
|
+
numCartLines,
|
|
1196
|
+
country: countryCode
|
|
1197
|
+
}
|
|
1198
|
+
});
|
|
1199
|
+
},
|
|
1200
|
+
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1201
|
+
);
|
|
1202
|
+
const cartLineAdd = React.useCallback(
|
|
1203
|
+
(cartId, lines) => {
|
|
1204
|
+
return fetchCart({
|
|
1205
|
+
query: CartLineAdd(cartFragment),
|
|
1206
|
+
variables: {
|
|
1207
|
+
cartId,
|
|
1208
|
+
lines,
|
|
1209
|
+
numCartLines,
|
|
1210
|
+
country: countryCode
|
|
1211
|
+
}
|
|
1212
|
+
});
|
|
1213
|
+
},
|
|
1214
|
+
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1215
|
+
);
|
|
1216
|
+
const cartLineUpdate = React.useCallback(
|
|
1217
|
+
(cartId, lines) => {
|
|
1218
|
+
return fetchCart({
|
|
1219
|
+
query: CartLineUpdate(cartFragment),
|
|
1220
|
+
variables: {
|
|
1221
|
+
cartId,
|
|
1222
|
+
lines,
|
|
1223
|
+
numCartLines,
|
|
1224
|
+
country: countryCode
|
|
1225
|
+
}
|
|
1226
|
+
});
|
|
1227
|
+
},
|
|
1228
|
+
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1229
|
+
);
|
|
1230
|
+
const cartLineRemove = React.useCallback(
|
|
1231
|
+
(cartId, lines) => {
|
|
1232
|
+
return fetchCart({
|
|
1233
|
+
query: CartLineRemove(cartFragment),
|
|
1234
|
+
variables: {
|
|
1235
|
+
cartId,
|
|
1236
|
+
lines,
|
|
1237
|
+
numCartLines,
|
|
1238
|
+
country: countryCode
|
|
1239
|
+
}
|
|
1240
|
+
});
|
|
1241
|
+
},
|
|
1242
|
+
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1243
|
+
);
|
|
1244
|
+
const noteUpdate = React.useCallback(
|
|
1245
|
+
(cartId, note) => {
|
|
1246
|
+
return fetchCart({
|
|
1247
|
+
query: CartNoteUpdate(cartFragment),
|
|
1248
|
+
variables: {
|
|
1249
|
+
cartId,
|
|
1250
|
+
note,
|
|
1251
|
+
numCartLines,
|
|
1252
|
+
country: countryCode
|
|
1253
|
+
}
|
|
1254
|
+
});
|
|
1255
|
+
},
|
|
1256
|
+
[fetchCart, cartFragment, numCartLines, countryCode]
|
|
1257
|
+
);
|
|
1258
|
+
const buyerIdentityUpdate = React.useCallback(
|
|
1259
|
+
(cartId, buyerIdentity) => {
|
|
1260
|
+
return fetchCart({
|
|
1261
|
+
query: CartBuyerIdentityUpdate(cartFragment),
|
|
1262
|
+
variables: {
|
|
1263
|
+
cartId,
|
|
1264
|
+
buyerIdentity,
|
|
1265
|
+
numCartLines,
|
|
1266
|
+
country: countryCode
|
|
1267
|
+
}
|
|
1268
|
+
});
|
|
1269
|
+
},
|
|
1270
|
+
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1271
|
+
);
|
|
1272
|
+
const cartAttributesUpdate = React.useCallback(
|
|
1273
|
+
(cartId, attributes) => {
|
|
1274
|
+
return fetchCart({
|
|
1275
|
+
query: CartAttributesUpdate(cartFragment),
|
|
1276
|
+
variables: {
|
|
1277
|
+
cartId,
|
|
1278
|
+
attributes,
|
|
1279
|
+
numCartLines,
|
|
1280
|
+
country: countryCode
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1283
|
+
},
|
|
1284
|
+
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1285
|
+
);
|
|
1286
|
+
const discountCodesUpdate = React.useCallback(
|
|
1287
|
+
(cartId, discountCodes) => {
|
|
1288
|
+
return fetchCart({
|
|
1289
|
+
query: CartDiscountCodesUpdate(cartFragment),
|
|
1290
|
+
variables: {
|
|
1291
|
+
cartId,
|
|
1292
|
+
discountCodes,
|
|
1293
|
+
numCartLines,
|
|
1294
|
+
country: countryCode
|
|
1295
|
+
}
|
|
1296
|
+
});
|
|
1297
|
+
},
|
|
1298
|
+
[cartFragment, countryCode, fetchCart, numCartLines]
|
|
1299
|
+
);
|
|
1300
|
+
return React.useMemo(
|
|
1301
|
+
() => ({
|
|
1302
|
+
cartFetch,
|
|
1303
|
+
cartCreate,
|
|
1304
|
+
cartLineAdd,
|
|
1305
|
+
cartLineUpdate,
|
|
1306
|
+
cartLineRemove,
|
|
1307
|
+
noteUpdate,
|
|
1308
|
+
buyerIdentityUpdate,
|
|
1309
|
+
cartAttributesUpdate,
|
|
1310
|
+
discountCodesUpdate,
|
|
1311
|
+
cartFragment
|
|
1312
|
+
}),
|
|
1313
|
+
[
|
|
1314
|
+
cartFetch,
|
|
1315
|
+
cartCreate,
|
|
1316
|
+
cartLineAdd,
|
|
1317
|
+
cartLineUpdate,
|
|
1318
|
+
cartLineRemove,
|
|
1319
|
+
noteUpdate,
|
|
1320
|
+
buyerIdentityUpdate,
|
|
1321
|
+
cartAttributesUpdate,
|
|
1322
|
+
discountCodesUpdate,
|
|
1323
|
+
cartFragment
|
|
1324
|
+
]
|
|
1325
|
+
);
|
|
1249
1326
|
}
|
|
1250
1327
|
function invokeCart(action, options) {
|
|
1251
1328
|
return {
|
|
1252
|
-
entry: [
|
|
1253
|
-
|
|
1254
|
-
|
|
1329
|
+
entry: [
|
|
1330
|
+
...(options == null ? void 0 : options.entryActions) || [],
|
|
1331
|
+
i({
|
|
1332
|
+
lastValidCart: (context) => context == null ? void 0 : context.cart
|
|
1333
|
+
}),
|
|
1334
|
+
"onCartActionEntry",
|
|
1335
|
+
"onCartActionOptimisticUI",
|
|
1336
|
+
action
|
|
1337
|
+
],
|
|
1255
1338
|
on: {
|
|
1256
1339
|
RESOLVE: {
|
|
1257
1340
|
target: (options == null ? void 0 : options.resolveTarget) || "idle",
|
|
1258
|
-
actions: [
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1341
|
+
actions: [
|
|
1342
|
+
i({
|
|
1343
|
+
prevCart: (context) => context == null ? void 0 : context.lastValidCart,
|
|
1344
|
+
cart: (_, event) => {
|
|
1345
|
+
var _a;
|
|
1346
|
+
return (_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.cart;
|
|
1347
|
+
},
|
|
1348
|
+
rawCartResult: (_, event) => {
|
|
1349
|
+
var _a;
|
|
1350
|
+
return (_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.rawCartResult;
|
|
1351
|
+
},
|
|
1352
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1353
|
+
errors: (_) => void 0
|
|
1354
|
+
})
|
|
1355
|
+
]
|
|
1270
1356
|
},
|
|
1271
1357
|
ERROR: {
|
|
1272
1358
|
target: (options == null ? void 0 : options.errorTarget) || "error",
|
|
1273
|
-
actions: [
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1359
|
+
actions: [
|
|
1360
|
+
i({
|
|
1361
|
+
prevCart: (context) => context == null ? void 0 : context.lastValidCart,
|
|
1362
|
+
cart: (context) => context == null ? void 0 : context.lastValidCart,
|
|
1363
|
+
errors: (_, event) => {
|
|
1364
|
+
var _a;
|
|
1365
|
+
return (_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.errors;
|
|
1366
|
+
}
|
|
1367
|
+
})
|
|
1368
|
+
]
|
|
1281
1369
|
},
|
|
1282
1370
|
CART_COMPLETED: {
|
|
1283
1371
|
target: "cartCompleted",
|
|
1284
1372
|
actions: i({
|
|
1373
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1285
1374
|
prevCart: (_) => void 0,
|
|
1375
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1286
1376
|
cart: (_) => void 0,
|
|
1377
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1287
1378
|
lastValidCart: (_) => void 0,
|
|
1379
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1288
1380
|
rawCartResult: (_) => void 0,
|
|
1381
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1289
1382
|
errors: (_) => void 0
|
|
1290
1383
|
})
|
|
1291
1384
|
}
|
|
@@ -1302,10 +1395,12 @@
|
|
|
1302
1395
|
},
|
|
1303
1396
|
CART_SET: {
|
|
1304
1397
|
target: "idle",
|
|
1305
|
-
actions: [
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1398
|
+
actions: [
|
|
1399
|
+
i({
|
|
1400
|
+
rawCartResult: (_, event) => event.payload.cart,
|
|
1401
|
+
cart: (_, event) => cartFromGraphQL(event.payload.cart)
|
|
1402
|
+
})
|
|
1403
|
+
]
|
|
1309
1404
|
}
|
|
1310
1405
|
};
|
|
1311
1406
|
const UPDATING_CART_EVENTS = {
|
|
@@ -1349,16 +1444,10 @@
|
|
|
1349
1444
|
on: INITIALIZING_CART_EVENTS
|
|
1350
1445
|
},
|
|
1351
1446
|
idle: {
|
|
1352
|
-
on: {
|
|
1353
|
-
...INITIALIZING_CART_EVENTS,
|
|
1354
|
-
...UPDATING_CART_EVENTS
|
|
1355
|
-
}
|
|
1447
|
+
on: { ...INITIALIZING_CART_EVENTS, ...UPDATING_CART_EVENTS }
|
|
1356
1448
|
},
|
|
1357
1449
|
error: {
|
|
1358
|
-
on: {
|
|
1359
|
-
...INITIALIZING_CART_EVENTS,
|
|
1360
|
-
...UPDATING_CART_EVENTS
|
|
1361
|
-
}
|
|
1450
|
+
on: { ...INITIALIZING_CART_EVENTS, ...UPDATING_CART_EVENTS }
|
|
1362
1451
|
},
|
|
1363
1452
|
cartFetching: invokeCart("cartFetchAction", {
|
|
1364
1453
|
errorTarget: "initializationError"
|
|
@@ -1407,10 +1496,7 @@
|
|
|
1407
1496
|
var _a;
|
|
1408
1497
|
if (event.type !== "CART_FETCH")
|
|
1409
1498
|
return;
|
|
1410
|
-
const {
|
|
1411
|
-
data,
|
|
1412
|
-
errors
|
|
1413
|
-
} = await cartFetch((_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.cartId);
|
|
1499
|
+
const { data, errors } = await cartFetch((_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.cartId);
|
|
1414
1500
|
const resultEvent = eventFromFetchResult(event, data == null ? void 0 : data.cart, errors);
|
|
1415
1501
|
send(resultEvent);
|
|
1416
1502
|
},
|
|
@@ -1418,88 +1504,117 @@
|
|
|
1418
1504
|
var _a;
|
|
1419
1505
|
if (event.type !== "CART_CREATE")
|
|
1420
1506
|
return;
|
|
1421
|
-
const {
|
|
1422
|
-
|
|
1507
|
+
const { data, errors } = await cartCreate(event == null ? void 0 : event.payload);
|
|
1508
|
+
const resultEvent = eventFromFetchResult(
|
|
1509
|
+
event,
|
|
1510
|
+
(_a = data == null ? void 0 : data.cartCreate) == null ? void 0 : _a.cart,
|
|
1423
1511
|
errors
|
|
1424
|
-
|
|
1425
|
-
const resultEvent = eventFromFetchResult(event, (_a = data == null ? void 0 : data.cartCreate) == null ? void 0 : _a.cart, errors);
|
|
1512
|
+
);
|
|
1426
1513
|
send(resultEvent);
|
|
1427
1514
|
},
|
|
1428
1515
|
cartLineAddAction: async (context, event) => {
|
|
1429
1516
|
var _a, _b;
|
|
1430
1517
|
if (event.type !== "CARTLINE_ADD" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
1431
1518
|
return;
|
|
1432
|
-
const {
|
|
1433
|
-
|
|
1519
|
+
const { data, errors } = await cartLineAdd(
|
|
1520
|
+
context.cart.id,
|
|
1521
|
+
event.payload.lines
|
|
1522
|
+
);
|
|
1523
|
+
const resultEvent = eventFromFetchResult(
|
|
1524
|
+
event,
|
|
1525
|
+
(_b = data == null ? void 0 : data.cartLinesAdd) == null ? void 0 : _b.cart,
|
|
1434
1526
|
errors
|
|
1435
|
-
|
|
1436
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartLinesAdd) == null ? void 0 : _b.cart, errors);
|
|
1527
|
+
);
|
|
1437
1528
|
send(resultEvent);
|
|
1438
1529
|
},
|
|
1439
1530
|
cartLineUpdateAction: async (context, event) => {
|
|
1440
1531
|
var _a, _b;
|
|
1441
1532
|
if (event.type !== "CARTLINE_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
1442
1533
|
return;
|
|
1443
|
-
const {
|
|
1444
|
-
|
|
1534
|
+
const { data, errors } = await cartLineUpdate(
|
|
1535
|
+
context.cart.id,
|
|
1536
|
+
event.payload.lines
|
|
1537
|
+
);
|
|
1538
|
+
const resultEvent = eventFromFetchResult(
|
|
1539
|
+
event,
|
|
1540
|
+
(_b = data == null ? void 0 : data.cartLinesUpdate) == null ? void 0 : _b.cart,
|
|
1445
1541
|
errors
|
|
1446
|
-
|
|
1447
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartLinesUpdate) == null ? void 0 : _b.cart, errors);
|
|
1542
|
+
);
|
|
1448
1543
|
send(resultEvent);
|
|
1449
1544
|
},
|
|
1450
1545
|
cartLineRemoveAction: async (context, event) => {
|
|
1451
1546
|
var _a, _b;
|
|
1452
1547
|
if (event.type !== "CARTLINE_REMOVE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
1453
1548
|
return;
|
|
1454
|
-
const {
|
|
1455
|
-
|
|
1549
|
+
const { data, errors } = await cartLineRemove(
|
|
1550
|
+
context.cart.id,
|
|
1551
|
+
event.payload.lines
|
|
1552
|
+
);
|
|
1553
|
+
const resultEvent = eventFromFetchResult(
|
|
1554
|
+
event,
|
|
1555
|
+
(_b = data == null ? void 0 : data.cartLinesRemove) == null ? void 0 : _b.cart,
|
|
1456
1556
|
errors
|
|
1457
|
-
|
|
1458
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartLinesRemove) == null ? void 0 : _b.cart, errors);
|
|
1557
|
+
);
|
|
1459
1558
|
send(resultEvent);
|
|
1460
1559
|
},
|
|
1461
1560
|
noteUpdateAction: async (context, event) => {
|
|
1462
1561
|
var _a, _b;
|
|
1463
1562
|
if (event.type !== "NOTE_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
1464
1563
|
return;
|
|
1465
|
-
const {
|
|
1466
|
-
|
|
1564
|
+
const { data, errors } = await noteUpdate(
|
|
1565
|
+
context.cart.id,
|
|
1566
|
+
event.payload.note
|
|
1567
|
+
);
|
|
1568
|
+
const resultEvent = eventFromFetchResult(
|
|
1569
|
+
event,
|
|
1570
|
+
(_b = data == null ? void 0 : data.cartNoteUpdate) == null ? void 0 : _b.cart,
|
|
1467
1571
|
errors
|
|
1468
|
-
|
|
1469
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartNoteUpdate) == null ? void 0 : _b.cart, errors);
|
|
1572
|
+
);
|
|
1470
1573
|
send(resultEvent);
|
|
1471
1574
|
},
|
|
1472
1575
|
buyerIdentityUpdateAction: async (context, event) => {
|
|
1473
1576
|
var _a, _b;
|
|
1474
1577
|
if (event.type !== "BUYER_IDENTITY_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
1475
1578
|
return;
|
|
1476
|
-
const {
|
|
1477
|
-
|
|
1579
|
+
const { data, errors } = await buyerIdentityUpdate(
|
|
1580
|
+
context.cart.id,
|
|
1581
|
+
event.payload.buyerIdentity
|
|
1582
|
+
);
|
|
1583
|
+
const resultEvent = eventFromFetchResult(
|
|
1584
|
+
event,
|
|
1585
|
+
(_b = data == null ? void 0 : data.cartBuyerIdentityUpdate) == null ? void 0 : _b.cart,
|
|
1478
1586
|
errors
|
|
1479
|
-
|
|
1480
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartBuyerIdentityUpdate) == null ? void 0 : _b.cart, errors);
|
|
1587
|
+
);
|
|
1481
1588
|
send(resultEvent);
|
|
1482
1589
|
},
|
|
1483
1590
|
cartAttributesUpdateAction: async (context, event) => {
|
|
1484
1591
|
var _a, _b;
|
|
1485
1592
|
if (event.type !== "CART_ATTRIBUTES_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
1486
1593
|
return;
|
|
1487
|
-
const {
|
|
1488
|
-
|
|
1594
|
+
const { data, errors } = await cartAttributesUpdate(
|
|
1595
|
+
context.cart.id,
|
|
1596
|
+
event.payload.attributes
|
|
1597
|
+
);
|
|
1598
|
+
const resultEvent = eventFromFetchResult(
|
|
1599
|
+
event,
|
|
1600
|
+
(_b = data == null ? void 0 : data.cartAttributesUpdate) == null ? void 0 : _b.cart,
|
|
1489
1601
|
errors
|
|
1490
|
-
|
|
1491
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartAttributesUpdate) == null ? void 0 : _b.cart, errors);
|
|
1602
|
+
);
|
|
1492
1603
|
send(resultEvent);
|
|
1493
1604
|
},
|
|
1494
1605
|
discountCodesUpdateAction: async (context, event) => {
|
|
1495
1606
|
var _a, _b;
|
|
1496
1607
|
if (event.type !== "DISCOUNT_CODES_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
1497
1608
|
return;
|
|
1498
|
-
const {
|
|
1499
|
-
|
|
1609
|
+
const { data, errors } = await discountCodesUpdate(
|
|
1610
|
+
context.cart.id,
|
|
1611
|
+
event.payload.discountCodes
|
|
1612
|
+
);
|
|
1613
|
+
const resultEvent = eventFromFetchResult(
|
|
1614
|
+
event,
|
|
1615
|
+
(_b = data == null ? void 0 : data.cartDiscountCodesUpdate) == null ? void 0 : _b.cart,
|
|
1500
1616
|
errors
|
|
1501
|
-
|
|
1502
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartDiscountCodesUpdate) == null ? void 0 : _b.cart, errors);
|
|
1617
|
+
);
|
|
1503
1618
|
send(resultEvent);
|
|
1504
1619
|
},
|
|
1505
1620
|
...onCartActionEntry && {
|
|
@@ -1526,22 +1641,15 @@
|
|
|
1526
1641
|
return React.useMemo(() => [state, send, service], [state, send, service]);
|
|
1527
1642
|
}
|
|
1528
1643
|
function cartFromGraphQL(cart) {
|
|
1529
|
-
var _a;
|
|
1530
1644
|
return {
|
|
1531
1645
|
...cart,
|
|
1532
1646
|
lines: flattenConnection(cart == null ? void 0 : cart.lines),
|
|
1533
|
-
note:
|
|
1647
|
+
note: cart.note ?? void 0
|
|
1534
1648
|
};
|
|
1535
1649
|
}
|
|
1536
1650
|
function eventFromFetchResult(cartActionEvent, cart, errors) {
|
|
1537
1651
|
if (errors) {
|
|
1538
|
-
return {
|
|
1539
|
-
type: "ERROR",
|
|
1540
|
-
payload: {
|
|
1541
|
-
errors,
|
|
1542
|
-
cartActionEvent
|
|
1543
|
-
}
|
|
1544
|
-
};
|
|
1652
|
+
return { type: "ERROR", payload: { errors, cartActionEvent } };
|
|
1545
1653
|
}
|
|
1546
1654
|
if (!cart) {
|
|
1547
1655
|
return {
|
|
@@ -1566,7 +1674,6 @@
|
|
|
1566
1674
|
function isCartFetchResultEvent(event) {
|
|
1567
1675
|
return event.type === "RESOLVE" || event.type === "ERROR" || event.type === "CART_COMPLETED";
|
|
1568
1676
|
}
|
|
1569
|
-
var _jsxFileName$d = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/CartProvider.tsx";
|
|
1570
1677
|
const CartContext = React.createContext(null);
|
|
1571
1678
|
function useCart() {
|
|
1572
1679
|
const context = React.useContext(CartContext);
|
|
@@ -1642,16 +1749,16 @@
|
|
|
1642
1749
|
onCartActionOptimisticUI(context, event) {
|
|
1643
1750
|
var _a2, _b2, _c2, _d2;
|
|
1644
1751
|
if (!context.cart)
|
|
1645
|
-
return {
|
|
1646
|
-
...context
|
|
1647
|
-
};
|
|
1752
|
+
return { ...context };
|
|
1648
1753
|
switch (event.type) {
|
|
1649
1754
|
case "CARTLINE_REMOVE":
|
|
1650
1755
|
return {
|
|
1651
1756
|
...context,
|
|
1652
1757
|
cart: {
|
|
1653
1758
|
...context.cart,
|
|
1654
|
-
lines: (_b2 = (_a2 = context == null ? void 0 : context.cart) == null ? void 0 : _a2.lines) == null ? void 0 : _b2.filter(
|
|
1759
|
+
lines: (_b2 = (_a2 = context == null ? void 0 : context.cart) == null ? void 0 : _a2.lines) == null ? void 0 : _b2.filter(
|
|
1760
|
+
(line) => (line == null ? void 0 : line.id) && !event.payload.lines.includes(line == null ? void 0 : line.id)
|
|
1761
|
+
)
|
|
1655
1762
|
}
|
|
1656
1763
|
};
|
|
1657
1764
|
case "CARTLINE_UPDATE":
|
|
@@ -1660,9 +1767,9 @@
|
|
|
1660
1767
|
cart: {
|
|
1661
1768
|
...context.cart,
|
|
1662
1769
|
lines: (_d2 = (_c2 = context == null ? void 0 : context.cart) == null ? void 0 : _c2.lines) == null ? void 0 : _d2.map((line) => {
|
|
1663
|
-
const updatedLine = event.payload.lines.find(
|
|
1664
|
-
id
|
|
1665
|
-
|
|
1770
|
+
const updatedLine = event.payload.lines.find(
|
|
1771
|
+
({ id }) => id === (line == null ? void 0 : line.id)
|
|
1772
|
+
);
|
|
1666
1773
|
if (updatedLine && updatedLine.quantity) {
|
|
1667
1774
|
return {
|
|
1668
1775
|
...line,
|
|
@@ -1674,9 +1781,7 @@
|
|
|
1674
1781
|
}
|
|
1675
1782
|
};
|
|
1676
1783
|
}
|
|
1677
|
-
return {
|
|
1678
|
-
...context
|
|
1679
|
-
};
|
|
1784
|
+
return { ...context };
|
|
1680
1785
|
},
|
|
1681
1786
|
onCartActionComplete(context, event) {
|
|
1682
1787
|
const cartActionEvent = event.payload.cartActionEvent;
|
|
@@ -1721,12 +1826,7 @@
|
|
|
1721
1826
|
try {
|
|
1722
1827
|
const cartId = window.localStorage.getItem(CART_ID_STORAGE_KEY);
|
|
1723
1828
|
if (cartId) {
|
|
1724
|
-
cartSend({
|
|
1725
|
-
type: "CART_FETCH",
|
|
1726
|
-
payload: {
|
|
1727
|
-
cartId
|
|
1728
|
-
}
|
|
1729
|
-
});
|
|
1829
|
+
cartSend({ type: "CART_FETCH", payload: { cartId } });
|
|
1730
1830
|
}
|
|
1731
1831
|
} catch (error) {
|
|
1732
1832
|
console.warn("error fetching cartId");
|
|
@@ -1741,25 +1841,32 @@
|
|
|
1741
1841
|
return;
|
|
1742
1842
|
cartSend({
|
|
1743
1843
|
type: "BUYER_IDENTITY_UPDATE",
|
|
1744
|
-
payload: {
|
|
1745
|
-
buyerIdentity: {
|
|
1746
|
-
countryCode,
|
|
1747
|
-
customerAccessToken
|
|
1748
|
-
}
|
|
1749
|
-
}
|
|
1844
|
+
payload: { buyerIdentity: { countryCode, customerAccessToken } }
|
|
1750
1845
|
});
|
|
1751
|
-
}, [
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
cartSend
|
|
1757
|
-
|
|
1846
|
+
}, [
|
|
1847
|
+
countryCode,
|
|
1848
|
+
customerAccessToken,
|
|
1849
|
+
countryChanged,
|
|
1850
|
+
customerOverridesCountryCode,
|
|
1851
|
+
cartSend
|
|
1852
|
+
]);
|
|
1853
|
+
const onCartReadySend = React.useCallback(
|
|
1854
|
+
(cartEvent) => {
|
|
1855
|
+
if (!cartReady.current) {
|
|
1856
|
+
return console.warn("Cart isn't ready yet");
|
|
1857
|
+
}
|
|
1858
|
+
cartSend(cartEvent);
|
|
1859
|
+
},
|
|
1860
|
+
[cartSend]
|
|
1861
|
+
);
|
|
1758
1862
|
React.useEffect(() => {
|
|
1759
1863
|
var _a2, _b2, _c2;
|
|
1760
1864
|
if (((_b2 = (_a2 = cartState == null ? void 0 : cartState.context) == null ? void 0 : _a2.cart) == null ? void 0 : _b2.id) && storageAvailable("localStorage")) {
|
|
1761
1865
|
try {
|
|
1762
|
-
window.localStorage.setItem(
|
|
1866
|
+
window.localStorage.setItem(
|
|
1867
|
+
CART_ID_STORAGE_KEY,
|
|
1868
|
+
(_c2 = cartState.context.cart) == null ? void 0 : _c2.id
|
|
1869
|
+
);
|
|
1763
1870
|
} catch (error) {
|
|
1764
1871
|
console.warn("Failed to save cartId to localStorage", error);
|
|
1765
1872
|
}
|
|
@@ -1774,50 +1881,46 @@
|
|
|
1774
1881
|
}
|
|
1775
1882
|
}
|
|
1776
1883
|
}, [cartCompleted]);
|
|
1777
|
-
const cartCreate = React.useCallback(
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
if (cartInput.buyerIdentity == null) {
|
|
1781
|
-
cartInput.buyerIdentity
|
|
1884
|
+
const cartCreate = React.useCallback(
|
|
1885
|
+
(cartInput) => {
|
|
1886
|
+
var _a2, _b2;
|
|
1887
|
+
if (countryCode && !((_a2 = cartInput.buyerIdentity) == null ? void 0 : _a2.countryCode)) {
|
|
1888
|
+
if (cartInput.buyerIdentity == null) {
|
|
1889
|
+
cartInput.buyerIdentity = {};
|
|
1890
|
+
}
|
|
1891
|
+
cartInput.buyerIdentity.countryCode = countryCode;
|
|
1782
1892
|
}
|
|
1783
|
-
cartInput.buyerIdentity.
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
cartInput.buyerIdentity =
|
|
1893
|
+
if (customerAccessToken && !((_b2 = cartInput.buyerIdentity) == null ? void 0 : _b2.customerAccessToken)) {
|
|
1894
|
+
if (cartInput.buyerIdentity == null) {
|
|
1895
|
+
cartInput.buyerIdentity = {};
|
|
1896
|
+
}
|
|
1897
|
+
cartInput.buyerIdentity.customerAccessToken = customerAccessToken;
|
|
1788
1898
|
}
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1899
|
+
onCartReadySend({
|
|
1900
|
+
type: "CART_CREATE",
|
|
1901
|
+
payload: cartInput
|
|
1902
|
+
});
|
|
1903
|
+
},
|
|
1904
|
+
[countryCode, customerAccessToken, onCartReadySend]
|
|
1905
|
+
);
|
|
1796
1906
|
const cartDisplayState = useDelayedStateUntilHydration(cartState);
|
|
1797
1907
|
const cartContextValue = React.useMemo(() => {
|
|
1798
|
-
var _a2, _b2, _c2, _d2
|
|
1908
|
+
var _a2, _b2, _c2, _d2;
|
|
1799
1909
|
return {
|
|
1800
|
-
...(
|
|
1801
|
-
lines: [],
|
|
1802
|
-
attributes: []
|
|
1803
|
-
},
|
|
1910
|
+
...((_a2 = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _a2.cart) ?? { lines: [], attributes: [] },
|
|
1804
1911
|
status: transposeStatus(cartDisplayState.value),
|
|
1805
|
-
error: (
|
|
1806
|
-
totalQuantity: (
|
|
1912
|
+
error: (_b2 = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _b2.errors,
|
|
1913
|
+
totalQuantity: ((_d2 = (_c2 = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _c2.cart) == null ? void 0 : _d2.totalQuantity) ?? 0,
|
|
1807
1914
|
cartCreate,
|
|
1808
1915
|
linesAdd(lines) {
|
|
1809
1916
|
var _a3, _b3;
|
|
1810
1917
|
if ((_b3 = (_a3 = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _a3.cart) == null ? void 0 : _b3.id) {
|
|
1811
1918
|
onCartReadySend({
|
|
1812
1919
|
type: "CARTLINE_ADD",
|
|
1813
|
-
payload: {
|
|
1814
|
-
lines
|
|
1815
|
-
}
|
|
1920
|
+
payload: { lines }
|
|
1816
1921
|
});
|
|
1817
1922
|
} else {
|
|
1818
|
-
cartCreate({
|
|
1819
|
-
lines
|
|
1820
|
-
});
|
|
1923
|
+
cartCreate({ lines });
|
|
1821
1924
|
}
|
|
1822
1925
|
},
|
|
1823
1926
|
linesRemove(lines) {
|
|
@@ -1870,16 +1973,15 @@
|
|
|
1870
1973
|
},
|
|
1871
1974
|
cartFragment
|
|
1872
1975
|
};
|
|
1873
|
-
}, [
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
}, children);
|
|
1976
|
+
}, [
|
|
1977
|
+
cartCreate,
|
|
1978
|
+
(_f = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _f.cart,
|
|
1979
|
+
(_g = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _g.errors,
|
|
1980
|
+
cartDisplayState.value,
|
|
1981
|
+
cartFragment,
|
|
1982
|
+
onCartReadySend
|
|
1983
|
+
]);
|
|
1984
|
+
return /* @__PURE__ */ React.createElement(CartContext.Provider, { value: cartContextValue }, children);
|
|
1883
1985
|
}
|
|
1884
1986
|
function transposeStatus(status) {
|
|
1885
1987
|
switch (status) {
|
|
@@ -1934,65 +2036,76 @@
|
|
|
1934
2036
|
storage.removeItem(x);
|
|
1935
2037
|
return true;
|
|
1936
2038
|
} catch (e2) {
|
|
1937
|
-
return e2 instanceof DOMException &&
|
|
2039
|
+
return e2 instanceof DOMException && // everything except Firefox
|
|
2040
|
+
(e2.code === 22 || // Firefox
|
|
2041
|
+
e2.code === 1014 || // test name field too, because code might not be present
|
|
2042
|
+
// everything except Firefox
|
|
2043
|
+
e2.name === "QuotaExceededError" || // Firefox
|
|
2044
|
+
e2.name === "NS_ERROR_DOM_QUOTA_REACHED") && // acknowledge QuotaExceededError only if there's something already stored
|
|
2045
|
+
storage && storage.length !== 0;
|
|
1938
2046
|
}
|
|
1939
2047
|
}
|
|
1940
2048
|
function countryCodeNotUpdated(context, event) {
|
|
1941
2049
|
var _a, _b;
|
|
1942
2050
|
return event.payload.buyerIdentity.countryCode && ((_b = (_a = context.cart) == null ? void 0 : _a.buyerIdentity) == null ? void 0 : _b.countryCode) !== event.payload.buyerIdentity.countryCode;
|
|
1943
2051
|
}
|
|
1944
|
-
var _jsxFileName$c = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductProvider.tsx";
|
|
1945
2052
|
const ProductOptionsContext = React.createContext(null);
|
|
1946
2053
|
function ProductProvider({
|
|
1947
2054
|
children,
|
|
1948
2055
|
data: product,
|
|
1949
2056
|
initialVariantId: explicitVariantId
|
|
1950
2057
|
}) {
|
|
1951
|
-
const variants = React.useMemo(
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
2058
|
+
const variants = React.useMemo(
|
|
2059
|
+
() => flattenConnection(product.variants ?? {}),
|
|
2060
|
+
[product.variants]
|
|
2061
|
+
);
|
|
1955
2062
|
if (!isProductVariantArray(variants)) {
|
|
1956
|
-
throw new Error(
|
|
2063
|
+
throw new Error(
|
|
2064
|
+
`<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'`
|
|
2065
|
+
);
|
|
1957
2066
|
}
|
|
1958
2067
|
const options = React.useMemo(() => getOptions(variants), [variants]);
|
|
1959
2068
|
const [selectedVariant, setSelectedVariant] = React.useState(() => getVariantBasedOnIdProp(explicitVariantId, variants));
|
|
1960
|
-
const [selectedOptions, setSelectedOptions] = React.useState(
|
|
2069
|
+
const [selectedOptions, setSelectedOptions] = React.useState(
|
|
2070
|
+
() => getSelectedOptions(selectedVariant)
|
|
2071
|
+
);
|
|
1961
2072
|
React.useEffect(() => {
|
|
1962
|
-
const newSelectedVariant = getVariantBasedOnIdProp(
|
|
2073
|
+
const newSelectedVariant = getVariantBasedOnIdProp(
|
|
2074
|
+
explicitVariantId,
|
|
2075
|
+
variants
|
|
2076
|
+
);
|
|
1963
2077
|
setSelectedVariant(newSelectedVariant);
|
|
1964
2078
|
setSelectedOptions(getSelectedOptions(newSelectedVariant));
|
|
1965
2079
|
}, [explicitVariantId, variants]);
|
|
1966
|
-
const setSelectedOption = React.useCallback(
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
...selectedOptions2,
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
const isOptionInStock = React.useCallback(
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
}
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
const sellingPlanGroups = React.useMemo(
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
var _a2;
|
|
1990
|
-
return {
|
|
2080
|
+
const setSelectedOption = React.useCallback(
|
|
2081
|
+
(name, value2) => {
|
|
2082
|
+
setSelectedOptions((selectedOptions2) => {
|
|
2083
|
+
const opts = { ...selectedOptions2, [name]: value2 };
|
|
2084
|
+
setSelectedVariant(getSelectedVariant(variants, opts));
|
|
2085
|
+
return opts;
|
|
2086
|
+
});
|
|
2087
|
+
},
|
|
2088
|
+
[setSelectedOptions, variants]
|
|
2089
|
+
);
|
|
2090
|
+
const isOptionInStock = React.useCallback(
|
|
2091
|
+
(option, value2) => {
|
|
2092
|
+
const proposedVariant = getSelectedVariant(variants, {
|
|
2093
|
+
...selectedOptions,
|
|
2094
|
+
...{ [option]: value2 }
|
|
2095
|
+
});
|
|
2096
|
+
return (proposedVariant == null ? void 0 : proposedVariant.availableForSale) ?? true;
|
|
2097
|
+
},
|
|
2098
|
+
[selectedOptions, variants]
|
|
2099
|
+
);
|
|
2100
|
+
const sellingPlanGroups = React.useMemo(
|
|
2101
|
+
() => flattenConnection(product.sellingPlanGroups ?? {}).map(
|
|
2102
|
+
(sellingPlanGroup) => ({
|
|
1991
2103
|
...sellingPlanGroup,
|
|
1992
|
-
sellingPlans: flattenConnection((
|
|
1993
|
-
}
|
|
1994
|
-
|
|
1995
|
-
|
|
2104
|
+
sellingPlans: flattenConnection((sellingPlanGroup == null ? void 0 : sellingPlanGroup.sellingPlans) ?? {})
|
|
2105
|
+
})
|
|
2106
|
+
),
|
|
2107
|
+
[product.sellingPlanGroups]
|
|
2108
|
+
);
|
|
1996
2109
|
const [selectedSellingPlan, setSelectedSellingPlan] = React.useState(void 0);
|
|
1997
2110
|
const selectedSellingPlanAllocation = React.useMemo(() => {
|
|
1998
2111
|
var _a, _b;
|
|
@@ -2000,38 +2113,49 @@
|
|
|
2000
2113
|
return;
|
|
2001
2114
|
}
|
|
2002
2115
|
if (!((_a = selectedVariant.sellingPlanAllocations) == null ? void 0 : _a.nodes) && !((_b = selectedVariant.sellingPlanAllocations) == null ? void 0 : _b.edges)) {
|
|
2003
|
-
throw new Error(
|
|
2116
|
+
throw new Error(
|
|
2117
|
+
`<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation`
|
|
2118
|
+
);
|
|
2004
2119
|
}
|
|
2005
|
-
return flattenConnection(selectedVariant.sellingPlanAllocations).find(
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2120
|
+
return flattenConnection(selectedVariant.sellingPlanAllocations).find(
|
|
2121
|
+
(allocation) => {
|
|
2122
|
+
var _a2;
|
|
2123
|
+
return ((_a2 = allocation == null ? void 0 : allocation.sellingPlan) == null ? void 0 : _a2.id) === selectedSellingPlan.id;
|
|
2124
|
+
}
|
|
2125
|
+
);
|
|
2009
2126
|
}, [selectedVariant, selectedSellingPlan]);
|
|
2010
|
-
const value = React.useMemo(
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2127
|
+
const value = React.useMemo(
|
|
2128
|
+
() => ({
|
|
2129
|
+
variants,
|
|
2130
|
+
variantsConnection: product.variants,
|
|
2131
|
+
options,
|
|
2132
|
+
selectedVariant,
|
|
2133
|
+
setSelectedVariant,
|
|
2134
|
+
selectedOptions,
|
|
2135
|
+
setSelectedOption,
|
|
2136
|
+
setSelectedOptions,
|
|
2137
|
+
isOptionInStock,
|
|
2138
|
+
selectedSellingPlan,
|
|
2139
|
+
setSelectedSellingPlan,
|
|
2140
|
+
selectedSellingPlanAllocation,
|
|
2141
|
+
sellingPlanGroups,
|
|
2142
|
+
sellingPlanGroupsConnection: product.sellingPlanGroups
|
|
2143
|
+
}),
|
|
2144
|
+
[
|
|
2145
|
+
isOptionInStock,
|
|
2146
|
+
options,
|
|
2147
|
+
product.sellingPlanGroups,
|
|
2148
|
+
product.variants,
|
|
2149
|
+
selectedOptions,
|
|
2150
|
+
selectedSellingPlan,
|
|
2151
|
+
selectedSellingPlanAllocation,
|
|
2152
|
+
selectedVariant,
|
|
2153
|
+
sellingPlanGroups,
|
|
2154
|
+
setSelectedOption,
|
|
2155
|
+
variants
|
|
2156
|
+
]
|
|
2157
|
+
);
|
|
2158
|
+
return /* @__PURE__ */ React.createElement(ProductOptionsContext.Provider, { value }, children);
|
|
2035
2159
|
}
|
|
2036
2160
|
function useProduct() {
|
|
2037
2161
|
const context = React.useContext(ProductOptionsContext);
|
|
@@ -2048,7 +2172,9 @@
|
|
|
2048
2172
|
return variants == null ? void 0 : variants.find((variant) => {
|
|
2049
2173
|
return Object.entries(choices).every(([name, value]) => {
|
|
2050
2174
|
var _a2;
|
|
2051
|
-
return (_a2 = variant == null ? void 0 : variant.selectedOptions) == null ? void 0 : _a2.some(
|
|
2175
|
+
return (_a2 = variant == null ? void 0 : variant.selectedOptions) == null ? void 0 : _a2.some(
|
|
2176
|
+
(option) => (option == null ? void 0 : option.name) === name && (option == null ? void 0 : option.value) === value
|
|
2177
|
+
);
|
|
2052
2178
|
});
|
|
2053
2179
|
});
|
|
2054
2180
|
}
|
|
@@ -2059,9 +2185,8 @@
|
|
|
2059
2185
|
throw new Error(`'getOptions' requires 'variant.selectedOptions'`);
|
|
2060
2186
|
}
|
|
2061
2187
|
(_a = variant == null ? void 0 : variant.selectedOptions) == null ? void 0 : _a.forEach((opt) => {
|
|
2062
|
-
|
|
2063
|
-
memo[(
|
|
2064
|
-
memo[(_c = opt == null ? void 0 : opt.name) != null ? _c : ""].add((_d = opt == null ? void 0 : opt.value) != null ? _d : "");
|
|
2188
|
+
memo[(opt == null ? void 0 : opt.name) ?? ""] = memo[(opt == null ? void 0 : opt.name) ?? ""] || /* @__PURE__ */ new Set();
|
|
2189
|
+
memo[(opt == null ? void 0 : opt.name) ?? ""].add((opt == null ? void 0 : opt.value) ?? "");
|
|
2065
2190
|
});
|
|
2066
2191
|
return memo;
|
|
2067
2192
|
}, {});
|
|
@@ -2074,9 +2199,13 @@
|
|
|
2074
2199
|
}
|
|
2075
2200
|
function getVariantBasedOnIdProp(explicitVariantId, variants) {
|
|
2076
2201
|
if (explicitVariantId) {
|
|
2077
|
-
const foundVariant = variants.find(
|
|
2202
|
+
const foundVariant = variants.find(
|
|
2203
|
+
(variant) => (variant == null ? void 0 : variant.id) === explicitVariantId
|
|
2204
|
+
);
|
|
2078
2205
|
if (!foundVariant) {
|
|
2079
|
-
console.warn(
|
|
2206
|
+
console.warn(
|
|
2207
|
+
`<ProductProvider/> received a 'initialVariantId' prop, but could not actually find a variant with that ID`
|
|
2208
|
+
);
|
|
2080
2209
|
}
|
|
2081
2210
|
return foundVariant;
|
|
2082
2211
|
}
|
|
@@ -2088,11 +2217,13 @@
|
|
|
2088
2217
|
}
|
|
2089
2218
|
}
|
|
2090
2219
|
function getSelectedOptions(selectedVariant) {
|
|
2091
|
-
return (selectedVariant == null ? void 0 : selectedVariant.selectedOptions) ? selectedVariant.selectedOptions.reduce(
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2220
|
+
return (selectedVariant == null ? void 0 : selectedVariant.selectedOptions) ? selectedVariant.selectedOptions.reduce(
|
|
2221
|
+
(memo, optionSet) => {
|
|
2222
|
+
memo[(optionSet == null ? void 0 : optionSet.name) ?? ""] = (optionSet == null ? void 0 : optionSet.value) ?? "";
|
|
2223
|
+
return memo;
|
|
2224
|
+
},
|
|
2225
|
+
{}
|
|
2226
|
+
) : {};
|
|
2096
2227
|
}
|
|
2097
2228
|
function isProductVariantArray(maybeVariantArray) {
|
|
2098
2229
|
if (!maybeVariantArray || !Array.isArray(maybeVariantArray)) {
|
|
@@ -2100,7 +2231,6 @@
|
|
|
2100
2231
|
}
|
|
2101
2232
|
return true;
|
|
2102
2233
|
}
|
|
2103
|
-
var _jsxFileName$b = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/BaseButton.tsx";
|
|
2104
2234
|
function BaseButton(props) {
|
|
2105
2235
|
const {
|
|
2106
2236
|
as,
|
|
@@ -2110,30 +2240,21 @@
|
|
|
2110
2240
|
buttonRef,
|
|
2111
2241
|
...passthroughProps
|
|
2112
2242
|
} = props;
|
|
2113
|
-
const handleOnClick = React.useCallback(
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2243
|
+
const handleOnClick = React.useCallback(
|
|
2244
|
+
(event) => {
|
|
2245
|
+
if (onClick) {
|
|
2246
|
+
const clickShouldContinue = onClick(event);
|
|
2247
|
+
if (typeof clickShouldContinue === "boolean" && clickShouldContinue === false || (event == null ? void 0 : event.defaultPrevented))
|
|
2248
|
+
return;
|
|
2249
|
+
}
|
|
2250
|
+
defaultOnClick == null ? void 0 : defaultOnClick(event);
|
|
2251
|
+
},
|
|
2252
|
+
[defaultOnClick, onClick]
|
|
2253
|
+
);
|
|
2121
2254
|
const Component = as || "button";
|
|
2122
|
-
return /* @__PURE__ */
|
|
2123
|
-
|
|
2124
|
-
onClick: handleOnClick,
|
|
2125
|
-
...passthroughProps,
|
|
2126
|
-
__self: this,
|
|
2127
|
-
__source: {
|
|
2128
|
-
fileName: _jsxFileName$b,
|
|
2129
|
-
lineNumber: 59,
|
|
2130
|
-
columnNumber: 5
|
|
2131
|
-
}
|
|
2132
|
-
}, children);
|
|
2133
|
-
}
|
|
2134
|
-
var _jsxFileName$a = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/AddToCartButton.tsx";
|
|
2255
|
+
return /* @__PURE__ */ React.createElement(Component, { ref: buttonRef, onClick: handleOnClick, ...passthroughProps }, children);
|
|
2256
|
+
}
|
|
2135
2257
|
function AddToCartButton(props) {
|
|
2136
|
-
var _a;
|
|
2137
2258
|
const [addingItem, setAddingItem] = React.useState(false);
|
|
2138
2259
|
const {
|
|
2139
2260
|
variantId: explicitVariantId,
|
|
@@ -2145,14 +2266,9 @@
|
|
|
2145
2266
|
accessibleAddingToCartLabel,
|
|
2146
2267
|
...passthroughProps
|
|
2147
2268
|
} = props;
|
|
2148
|
-
const {
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
} = useCart();
|
|
2152
|
-
const {
|
|
2153
|
-
selectedVariant
|
|
2154
|
-
} = useProduct();
|
|
2155
|
-
const variantId = (_a = explicitVariantId != null ? explicitVariantId : selectedVariant == null ? void 0 : selectedVariant.id) != null ? _a : "";
|
|
2269
|
+
const { status, linesAdd } = useCart();
|
|
2270
|
+
const { selectedVariant } = useProduct();
|
|
2271
|
+
const variantId = explicitVariantId ?? (selectedVariant == null ? void 0 : selectedVariant.id) ?? "";
|
|
2156
2272
|
const disabled = explicitVariantId === null || variantId === "" || selectedVariant === null || addingItem || passthroughProps.disabled;
|
|
2157
2273
|
React.useEffect(() => {
|
|
2158
2274
|
if (addingItem && status === "idle") {
|
|
@@ -2161,52 +2277,46 @@
|
|
|
2161
2277
|
}, [status, addingItem]);
|
|
2162
2278
|
const handleAddItem = React.useCallback(() => {
|
|
2163
2279
|
setAddingItem(true);
|
|
2164
|
-
linesAdd([
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2280
|
+
linesAdd([
|
|
2281
|
+
{
|
|
2282
|
+
quantity,
|
|
2283
|
+
merchandiseId: variantId || "",
|
|
2284
|
+
attributes,
|
|
2285
|
+
sellingPlanId
|
|
2286
|
+
}
|
|
2287
|
+
]);
|
|
2170
2288
|
}, [linesAdd, quantity, variantId, attributes, sellingPlanId]);
|
|
2171
|
-
return /* @__PURE__ */
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
fileName: _jsxFileName$a,
|
|
2179
|
-
lineNumber: 71,
|
|
2180
|
-
columnNumber: 7
|
|
2181
|
-
}
|
|
2182
|
-
}, children), accessibleAddingToCartLabel ? /* @__PURE__ */ React__default.default.createElement("p", {
|
|
2183
|
-
style: {
|
|
2184
|
-
position: "absolute",
|
|
2185
|
-
width: "1px",
|
|
2186
|
-
height: "1px",
|
|
2187
|
-
padding: "0",
|
|
2188
|
-
margin: "-1px",
|
|
2189
|
-
overflow: "hidden",
|
|
2190
|
-
clip: "rect(0, 0, 0, 0)",
|
|
2191
|
-
whiteSpace: "nowrap",
|
|
2192
|
-
borderWidth: "0"
|
|
2289
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
2290
|
+
BaseButton,
|
|
2291
|
+
{
|
|
2292
|
+
...passthroughProps,
|
|
2293
|
+
disabled,
|
|
2294
|
+
onClick,
|
|
2295
|
+
defaultOnClick: handleAddItem
|
|
2193
2296
|
},
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2297
|
+
children
|
|
2298
|
+
), accessibleAddingToCartLabel ? /* @__PURE__ */ React.createElement(
|
|
2299
|
+
"p",
|
|
2300
|
+
{
|
|
2301
|
+
style: {
|
|
2302
|
+
position: "absolute",
|
|
2303
|
+
width: "1px",
|
|
2304
|
+
height: "1px",
|
|
2305
|
+
padding: "0",
|
|
2306
|
+
margin: "-1px",
|
|
2307
|
+
overflow: "hidden",
|
|
2308
|
+
clip: "rect(0, 0, 0, 0)",
|
|
2309
|
+
whiteSpace: "nowrap",
|
|
2310
|
+
borderWidth: "0"
|
|
2311
|
+
},
|
|
2312
|
+
role: "alert",
|
|
2313
|
+
"aria-live": "assertive"
|
|
2314
|
+
},
|
|
2315
|
+
addingItem ? accessibleAddingToCartLabel : null
|
|
2316
|
+
) : null);
|
|
2203
2317
|
}
|
|
2204
|
-
var _jsxFileName$9 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/BuyNowButton.tsx";
|
|
2205
2318
|
function BuyNowButton(props) {
|
|
2206
|
-
const {
|
|
2207
|
-
cartCreate,
|
|
2208
|
-
checkoutUrl
|
|
2209
|
-
} = useCart();
|
|
2319
|
+
const { cartCreate, checkoutUrl } = useCart();
|
|
2210
2320
|
const [loading, setLoading] = React.useState(false);
|
|
2211
2321
|
const {
|
|
2212
2322
|
quantity,
|
|
@@ -2224,55 +2334,47 @@
|
|
|
2224
2334
|
const handleBuyNow = React.useCallback(() => {
|
|
2225
2335
|
setLoading(true);
|
|
2226
2336
|
cartCreate({
|
|
2227
|
-
lines: [
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2337
|
+
lines: [
|
|
2338
|
+
{
|
|
2339
|
+
quantity: quantity ?? 1,
|
|
2340
|
+
merchandiseId: variantId,
|
|
2341
|
+
attributes
|
|
2342
|
+
}
|
|
2343
|
+
]
|
|
2232
2344
|
});
|
|
2233
2345
|
}, [cartCreate, quantity, variantId, attributes]);
|
|
2234
|
-
return /* @__PURE__ */
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
}
|
|
2245
|
-
}, children);
|
|
2346
|
+
return /* @__PURE__ */ React.createElement(
|
|
2347
|
+
BaseButton,
|
|
2348
|
+
{
|
|
2349
|
+
disabled: loading ?? passthroughProps.disabled,
|
|
2350
|
+
...passthroughProps,
|
|
2351
|
+
onClick,
|
|
2352
|
+
defaultOnClick: handleBuyNow
|
|
2353
|
+
},
|
|
2354
|
+
children
|
|
2355
|
+
);
|
|
2246
2356
|
}
|
|
2247
|
-
var _jsxFileName$8 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/CartCheckoutButton.tsx";
|
|
2248
2357
|
function CartCheckoutButton(props) {
|
|
2249
2358
|
const [requestedCheckout, setRequestedCheckout] = React.useState(false);
|
|
2250
|
-
const {
|
|
2251
|
-
|
|
2252
|
-
checkoutUrl
|
|
2253
|
-
} = useCart();
|
|
2254
|
-
const {
|
|
2255
|
-
children,
|
|
2256
|
-
...passthroughProps
|
|
2257
|
-
} = props;
|
|
2359
|
+
const { status, checkoutUrl } = useCart();
|
|
2360
|
+
const { children, ...passthroughProps } = props;
|
|
2258
2361
|
React.useEffect(() => {
|
|
2259
2362
|
if (requestedCheckout && checkoutUrl && status === "idle") {
|
|
2260
2363
|
window.location.href = checkoutUrl;
|
|
2261
2364
|
}
|
|
2262
2365
|
}, [requestedCheckout, status, checkoutUrl]);
|
|
2263
|
-
return /* @__PURE__ */
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
}
|
|
2273
|
-
}, children);
|
|
2366
|
+
return /* @__PURE__ */ React.createElement(
|
|
2367
|
+
BaseButton,
|
|
2368
|
+
{
|
|
2369
|
+
...passthroughProps,
|
|
2370
|
+
disabled: requestedCheckout || passthroughProps.disabled,
|
|
2371
|
+
onClick: () => setRequestedCheckout(true)
|
|
2372
|
+
},
|
|
2373
|
+
children
|
|
2374
|
+
);
|
|
2274
2375
|
}
|
|
2275
2376
|
const storefrontApiCustomScalars = {
|
|
2377
|
+
// Keep in sync with the definitions in the app/nextjs/codegen.ts!
|
|
2276
2378
|
DateTime: "string",
|
|
2277
2379
|
Decimal: "string",
|
|
2278
2380
|
HTML: "string",
|
|
@@ -2280,9 +2382,7 @@
|
|
|
2280
2382
|
Color: "string",
|
|
2281
2383
|
UnsignedInt64: "string"
|
|
2282
2384
|
};
|
|
2283
|
-
var _jsxFileName$7 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ExternalVideo.tsx";
|
|
2284
2385
|
function ExternalVideo(props) {
|
|
2285
|
-
var _a, _b;
|
|
2286
2386
|
const {
|
|
2287
2387
|
data,
|
|
2288
2388
|
options,
|
|
@@ -2304,22 +2404,19 @@
|
|
|
2304
2404
|
}
|
|
2305
2405
|
finalUrl = urlObject.toString();
|
|
2306
2406
|
}
|
|
2307
|
-
return /* @__PURE__ */
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
fileName: _jsxFileName$7,
|
|
2319
|
-
lineNumber: 56,
|
|
2320
|
-
columnNumber: 5
|
|
2407
|
+
return /* @__PURE__ */ React.createElement(
|
|
2408
|
+
"iframe",
|
|
2409
|
+
{
|
|
2410
|
+
...passthroughProps,
|
|
2411
|
+
id: id ?? data.embedUrl,
|
|
2412
|
+
title: data.alt ?? data.id ?? "external video",
|
|
2413
|
+
frameBorder,
|
|
2414
|
+
allow,
|
|
2415
|
+
allowFullScreen,
|
|
2416
|
+
src: finalUrl,
|
|
2417
|
+
loading
|
|
2321
2418
|
}
|
|
2322
|
-
|
|
2419
|
+
);
|
|
2323
2420
|
}
|
|
2324
2421
|
const PRODUCTION_CDN_HOSTNAMES = [
|
|
2325
2422
|
"cdn.shopify.com",
|
|
@@ -2338,7 +2435,7 @@
|
|
|
2338
2435
|
scale
|
|
2339
2436
|
}) {
|
|
2340
2437
|
const newUrl = new URL(src);
|
|
2341
|
-
const multipliedScale = scale
|
|
2438
|
+
const multipliedScale = scale ?? 1;
|
|
2342
2439
|
if (width) {
|
|
2343
2440
|
let finalWidth;
|
|
2344
2441
|
if (typeof width === "string") {
|
|
@@ -2369,32 +2466,31 @@
|
|
|
2369
2466
|
loaderOptions,
|
|
2370
2467
|
elementProps
|
|
2371
2468
|
}) {
|
|
2372
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2373
2469
|
let aspectRatio = null;
|
|
2374
2470
|
if ((sfapiImage == null ? void 0 : sfapiImage.width) && (sfapiImage == null ? void 0 : sfapiImage.height)) {
|
|
2375
2471
|
aspectRatio = (sfapiImage == null ? void 0 : sfapiImage.width) / (sfapiImage == null ? void 0 : sfapiImage.height);
|
|
2376
2472
|
}
|
|
2377
2473
|
if ((loaderOptions == null ? void 0 : loaderOptions.width) || (loaderOptions == null ? void 0 : loaderOptions.height)) {
|
|
2378
2474
|
return {
|
|
2379
|
-
width: (
|
|
2380
|
-
height: (
|
|
2475
|
+
width: (loaderOptions == null ? void 0 : loaderOptions.width) ?? (aspectRatio && typeof loaderOptions.height === "number" ? Math.round(aspectRatio * loaderOptions.height) : null),
|
|
2476
|
+
height: (loaderOptions == null ? void 0 : loaderOptions.height) ?? (aspectRatio && typeof loaderOptions.width === "number" ? Math.round(aspectRatio * loaderOptions.width) : null)
|
|
2381
2477
|
};
|
|
2382
2478
|
}
|
|
2383
2479
|
if ((elementProps == null ? void 0 : elementProps.width) || (elementProps == null ? void 0 : elementProps.height)) {
|
|
2384
2480
|
return {
|
|
2385
|
-
width: (
|
|
2386
|
-
height: (
|
|
2481
|
+
width: (elementProps == null ? void 0 : elementProps.width) ?? (aspectRatio && typeof elementProps.height === "number" ? Math.round(aspectRatio * elementProps.height) : null),
|
|
2482
|
+
height: (elementProps == null ? void 0 : elementProps.height) ?? (aspectRatio && typeof elementProps.width === "number" ? Math.round(aspectRatio * elementProps.width) : null)
|
|
2387
2483
|
};
|
|
2388
2484
|
}
|
|
2389
2485
|
if ((sfapiImage == null ? void 0 : sfapiImage.width) || (sfapiImage == null ? void 0 : sfapiImage.height)) {
|
|
2390
2486
|
return {
|
|
2391
|
-
|
|
2392
|
-
|
|
2487
|
+
// can't calculate the aspect ratio here
|
|
2488
|
+
width: (sfapiImage == null ? void 0 : sfapiImage.width) ?? null,
|
|
2489
|
+
height: (sfapiImage == null ? void 0 : sfapiImage.height) ?? null
|
|
2393
2490
|
};
|
|
2394
2491
|
}
|
|
2395
2492
|
return { width: null, height: null };
|
|
2396
2493
|
}
|
|
2397
|
-
var _jsxFileName$6 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Image.tsx";
|
|
2398
2494
|
function Image({
|
|
2399
2495
|
data,
|
|
2400
2496
|
width,
|
|
@@ -2406,20 +2502,18 @@
|
|
|
2406
2502
|
decoding = "async",
|
|
2407
2503
|
...rest
|
|
2408
2504
|
}) {
|
|
2409
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2410
2505
|
if (!data.url) {
|
|
2411
|
-
const missingUrlError = `<Image/>: the 'data' prop requires the 'url' property. Image: ${
|
|
2506
|
+
const missingUrlError = `<Image/>: the 'data' prop requires the 'url' property. Image: ${data.id ?? "no ID provided"}`;
|
|
2412
2507
|
{
|
|
2413
2508
|
throw new Error(missingUrlError);
|
|
2414
2509
|
}
|
|
2415
2510
|
}
|
|
2416
2511
|
if (!data.altText && !rest.alt) {
|
|
2417
|
-
console.warn(
|
|
2512
|
+
console.warn(
|
|
2513
|
+
`<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}`
|
|
2514
|
+
);
|
|
2418
2515
|
}
|
|
2419
|
-
const {
|
|
2420
|
-
width: imgElementWidth,
|
|
2421
|
-
height: imgElementHeight
|
|
2422
|
-
} = getShopifyImageDimensions({
|
|
2516
|
+
const { width: imgElementWidth, height: imgElementHeight } = getShopifyImageDimensions({
|
|
2423
2517
|
data,
|
|
2424
2518
|
loaderOptions,
|
|
2425
2519
|
elementProps: {
|
|
@@ -2428,7 +2522,9 @@
|
|
|
2428
2522
|
}
|
|
2429
2523
|
});
|
|
2430
2524
|
if (!imgElementWidth || !imgElementHeight) {
|
|
2431
|
-
console.warn(
|
|
2525
|
+
console.warn(
|
|
2526
|
+
`<Image/>: the 'data' prop requires either 'width' or 'data.width', and 'height' or 'data.height' properties. Image: ${data.id ?? data.url}`
|
|
2527
|
+
);
|
|
2432
2528
|
}
|
|
2433
2529
|
let finalSrc = data.url;
|
|
2434
2530
|
if (loader) {
|
|
@@ -2439,11 +2535,13 @@
|
|
|
2439
2535
|
height: imgElementHeight
|
|
2440
2536
|
});
|
|
2441
2537
|
if (typeof finalSrc !== "string" || !finalSrc) {
|
|
2442
|
-
throw new Error(
|
|
2538
|
+
throw new Error(
|
|
2539
|
+
`<Image/>: 'loader' did not return a valid string. Image: ${data.id ?? data.url}`
|
|
2540
|
+
);
|
|
2443
2541
|
}
|
|
2444
2542
|
}
|
|
2445
2543
|
const maxWidth = width && imgElementWidth && width < imgElementWidth ? width : imgElementWidth;
|
|
2446
|
-
const finalSrcset =
|
|
2544
|
+
const finalSrcset = rest.srcSet ?? internalImageSrcSet({
|
|
2447
2545
|
...loaderOptions,
|
|
2448
2546
|
widths,
|
|
2449
2547
|
src: data.url,
|
|
@@ -2451,23 +2549,20 @@
|
|
|
2451
2549
|
height: imgElementHeight,
|
|
2452
2550
|
loader
|
|
2453
2551
|
});
|
|
2454
|
-
return /* @__PURE__ */ React__namespace.createElement(
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
fileName: _jsxFileName$6,
|
|
2467
|
-
lineNumber: 150,
|
|
2468
|
-
columnNumber: 5
|
|
2552
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
2553
|
+
"img",
|
|
2554
|
+
{
|
|
2555
|
+
id: data.id ?? "",
|
|
2556
|
+
alt: data.altText ?? rest.alt ?? "",
|
|
2557
|
+
loading: loading ?? "lazy",
|
|
2558
|
+
...rest,
|
|
2559
|
+
src: finalSrc,
|
|
2560
|
+
width: imgElementWidth ?? void 0,
|
|
2561
|
+
height: imgElementHeight ?? void 0,
|
|
2562
|
+
srcSet: finalSrcset,
|
|
2563
|
+
decoding
|
|
2469
2564
|
}
|
|
2470
|
-
|
|
2565
|
+
);
|
|
2471
2566
|
}
|
|
2472
2567
|
function internalImageSrcSet({
|
|
2473
2568
|
src,
|
|
@@ -2480,7 +2575,9 @@
|
|
|
2480
2575
|
}) {
|
|
2481
2576
|
const hasCustomWidths = widths && Array.isArray(widths);
|
|
2482
2577
|
if (hasCustomWidths && widths.some((size) => isNaN(size))) {
|
|
2483
|
-
throw new Error(
|
|
2578
|
+
throw new Error(
|
|
2579
|
+
`<Image/>: the 'widths' must be an array of numbers. Image: ${src}`
|
|
2580
|
+
);
|
|
2484
2581
|
}
|
|
2485
2582
|
let aspectRatio = 1;
|
|
2486
2583
|
if (width && height) {
|
|
@@ -2491,17 +2588,20 @@
|
|
|
2491
2588
|
setSizes = IMG_SRC_SET_SIZES.filter((size) => size <= width);
|
|
2492
2589
|
}
|
|
2493
2590
|
const srcGenerator = loader ? loader : addImageSizeParametersToUrl;
|
|
2494
|
-
return setSizes.map(
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2591
|
+
return setSizes.map(
|
|
2592
|
+
(size) => `${srcGenerator({
|
|
2593
|
+
src,
|
|
2594
|
+
width: size,
|
|
2595
|
+
// height is not applied if there is no crop
|
|
2596
|
+
// if there is crop, then height is applied as a ratio of the original width + height aspect ratio * size
|
|
2597
|
+
height: crop ? Number(size) * aspectRatio : void 0,
|
|
2598
|
+
crop,
|
|
2599
|
+
scale
|
|
2600
|
+
})} ${size}w`
|
|
2601
|
+
).join(", ");
|
|
2602
|
+
}
|
|
2503
2603
|
function Video(props) {
|
|
2504
|
-
var _a
|
|
2604
|
+
var _a;
|
|
2505
2605
|
const {
|
|
2506
2606
|
data,
|
|
2507
2607
|
previewImageOptions,
|
|
@@ -2512,41 +2612,39 @@
|
|
|
2512
2612
|
...passthroughProps
|
|
2513
2613
|
} = props;
|
|
2514
2614
|
const posterUrl = shopifyImageLoader({
|
|
2515
|
-
src: (
|
|
2615
|
+
src: ((_a = data.previewImage) == null ? void 0 : _a.url) ?? "",
|
|
2516
2616
|
...previewImageOptions
|
|
2517
2617
|
});
|
|
2518
2618
|
if (!data.sources) {
|
|
2519
2619
|
throw new Error(`<Video/> requires a 'data.sources' array`);
|
|
2520
2620
|
}
|
|
2521
|
-
return
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
});
|
|
2549
|
-
}));
|
|
2621
|
+
return (
|
|
2622
|
+
// eslint-disable-next-line jsx-a11y/media-has-caption
|
|
2623
|
+
/* @__PURE__ */ React.createElement(
|
|
2624
|
+
"video",
|
|
2625
|
+
{
|
|
2626
|
+
...passthroughProps,
|
|
2627
|
+
id,
|
|
2628
|
+
playsInline,
|
|
2629
|
+
controls,
|
|
2630
|
+
poster: posterUrl
|
|
2631
|
+
},
|
|
2632
|
+
data.sources.map((source) => {
|
|
2633
|
+
if (!((source == null ? void 0 : source.url) && (source == null ? void 0 : source.mimeType))) {
|
|
2634
|
+
throw new Error(`<Video/> needs 'source.url' and 'source.mimeType'`);
|
|
2635
|
+
}
|
|
2636
|
+
return /* @__PURE__ */ React.createElement(
|
|
2637
|
+
"source",
|
|
2638
|
+
{
|
|
2639
|
+
...sourceProps,
|
|
2640
|
+
key: source.url,
|
|
2641
|
+
src: source.url,
|
|
2642
|
+
type: source.mimeType
|
|
2643
|
+
}
|
|
2644
|
+
);
|
|
2645
|
+
})
|
|
2646
|
+
)
|
|
2647
|
+
);
|
|
2550
2648
|
}
|
|
2551
2649
|
const SCRIPTS_LOADED = {};
|
|
2552
2650
|
function loadScript(src, options) {
|
|
@@ -2594,22 +2692,21 @@
|
|
|
2594
2692
|
}, [url, stringifiedOptions, options]);
|
|
2595
2693
|
return status;
|
|
2596
2694
|
}
|
|
2597
|
-
var _jsxFileName$4 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ModelViewer.tsx";
|
|
2598
2695
|
function ModelViewer(props) {
|
|
2599
|
-
var _a, _b, _c
|
|
2600
|
-
const [modelViewer, setModelViewer] = React.useState(
|
|
2696
|
+
var _a, _b, _c;
|
|
2697
|
+
const [modelViewer, setModelViewer] = React.useState(
|
|
2698
|
+
void 0
|
|
2699
|
+
);
|
|
2601
2700
|
const callbackRef = React.useCallback((node) => {
|
|
2602
2701
|
setModelViewer(node);
|
|
2603
2702
|
}, []);
|
|
2604
|
-
const {
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
module: true
|
|
2612
|
-
});
|
|
2703
|
+
const { data, children, className, ...passthroughProps } = props;
|
|
2704
|
+
const modelViewerLoadedStatus = useLoadScript(
|
|
2705
|
+
"https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js",
|
|
2706
|
+
{
|
|
2707
|
+
module: true
|
|
2708
|
+
}
|
|
2709
|
+
);
|
|
2613
2710
|
React.useEffect(() => {
|
|
2614
2711
|
if (!modelViewer) {
|
|
2615
2712
|
return;
|
|
@@ -2621,25 +2718,43 @@
|
|
|
2621
2718
|
if (passthroughProps.onPreload)
|
|
2622
2719
|
modelViewer.addEventListener("preload", passthroughProps.onPreload);
|
|
2623
2720
|
if (passthroughProps.onModelVisibility)
|
|
2624
|
-
modelViewer.addEventListener(
|
|
2721
|
+
modelViewer.addEventListener(
|
|
2722
|
+
"model-visibility",
|
|
2723
|
+
passthroughProps.onModelVisibility
|
|
2724
|
+
);
|
|
2625
2725
|
if (passthroughProps.onProgress)
|
|
2626
2726
|
modelViewer.addEventListener("progress", passthroughProps.onProgress);
|
|
2627
2727
|
if (passthroughProps.onArStatus)
|
|
2628
2728
|
modelViewer.addEventListener("ar-status", passthroughProps.onArStatus);
|
|
2629
2729
|
if (passthroughProps.onArTracking)
|
|
2630
|
-
modelViewer.addEventListener(
|
|
2730
|
+
modelViewer.addEventListener(
|
|
2731
|
+
"ar-tracking",
|
|
2732
|
+
passthroughProps.onArTracking
|
|
2733
|
+
);
|
|
2631
2734
|
if (passthroughProps.onQuickLookButtonTapped)
|
|
2632
|
-
modelViewer.addEventListener(
|
|
2735
|
+
modelViewer.addEventListener(
|
|
2736
|
+
"quick-look-button-tapped",
|
|
2737
|
+
passthroughProps.onQuickLookButtonTapped
|
|
2738
|
+
);
|
|
2633
2739
|
if (passthroughProps.onCameraChange)
|
|
2634
|
-
modelViewer.addEventListener(
|
|
2740
|
+
modelViewer.addEventListener(
|
|
2741
|
+
"camera-change",
|
|
2742
|
+
passthroughProps.onCameraChange
|
|
2743
|
+
);
|
|
2635
2744
|
if (passthroughProps.onEnvironmentChange)
|
|
2636
|
-
modelViewer.addEventListener(
|
|
2745
|
+
modelViewer.addEventListener(
|
|
2746
|
+
"environment-change",
|
|
2747
|
+
passthroughProps.onEnvironmentChange
|
|
2748
|
+
);
|
|
2637
2749
|
if (passthroughProps.onPlay)
|
|
2638
2750
|
modelViewer.addEventListener("play", passthroughProps.onPlay);
|
|
2639
2751
|
if (passthroughProps.onPause)
|
|
2640
2752
|
modelViewer.addEventListener("ar-status", passthroughProps.onPause);
|
|
2641
2753
|
if (passthroughProps.onSceneGraphReady)
|
|
2642
|
-
modelViewer.addEventListener(
|
|
2754
|
+
modelViewer.addEventListener(
|
|
2755
|
+
"scene-graph-ready",
|
|
2756
|
+
passthroughProps.onSceneGraphReady
|
|
2757
|
+
);
|
|
2643
2758
|
return () => {
|
|
2644
2759
|
if (modelViewer == null) {
|
|
2645
2760
|
return;
|
|
@@ -2651,27 +2766,66 @@
|
|
|
2651
2766
|
if (passthroughProps.onPreload)
|
|
2652
2767
|
modelViewer.removeEventListener("preload", passthroughProps.onPreload);
|
|
2653
2768
|
if (passthroughProps.onModelVisibility)
|
|
2654
|
-
modelViewer.removeEventListener(
|
|
2769
|
+
modelViewer.removeEventListener(
|
|
2770
|
+
"model-visibility",
|
|
2771
|
+
passthroughProps.onModelVisibility
|
|
2772
|
+
);
|
|
2655
2773
|
if (passthroughProps.onProgress)
|
|
2656
|
-
modelViewer.removeEventListener(
|
|
2774
|
+
modelViewer.removeEventListener(
|
|
2775
|
+
"progress",
|
|
2776
|
+
passthroughProps.onProgress
|
|
2777
|
+
);
|
|
2657
2778
|
if (passthroughProps.onArStatus)
|
|
2658
|
-
modelViewer.removeEventListener(
|
|
2779
|
+
modelViewer.removeEventListener(
|
|
2780
|
+
"ar-status",
|
|
2781
|
+
passthroughProps.onArStatus
|
|
2782
|
+
);
|
|
2659
2783
|
if (passthroughProps.onArTracking)
|
|
2660
|
-
modelViewer.removeEventListener(
|
|
2784
|
+
modelViewer.removeEventListener(
|
|
2785
|
+
"ar-tracking",
|
|
2786
|
+
passthroughProps.onArTracking
|
|
2787
|
+
);
|
|
2661
2788
|
if (passthroughProps.onQuickLookButtonTapped)
|
|
2662
|
-
modelViewer.removeEventListener(
|
|
2789
|
+
modelViewer.removeEventListener(
|
|
2790
|
+
"quick-look-button-tapped",
|
|
2791
|
+
passthroughProps.onQuickLookButtonTapped
|
|
2792
|
+
);
|
|
2663
2793
|
if (passthroughProps.onCameraChange)
|
|
2664
|
-
modelViewer.removeEventListener(
|
|
2794
|
+
modelViewer.removeEventListener(
|
|
2795
|
+
"camera-change",
|
|
2796
|
+
passthroughProps.onCameraChange
|
|
2797
|
+
);
|
|
2665
2798
|
if (passthroughProps.onEnvironmentChange)
|
|
2666
|
-
modelViewer.removeEventListener(
|
|
2799
|
+
modelViewer.removeEventListener(
|
|
2800
|
+
"environment-change",
|
|
2801
|
+
passthroughProps.onEnvironmentChange
|
|
2802
|
+
);
|
|
2667
2803
|
if (passthroughProps.onPlay)
|
|
2668
2804
|
modelViewer.removeEventListener("play", passthroughProps.onPlay);
|
|
2669
2805
|
if (passthroughProps.onPause)
|
|
2670
2806
|
modelViewer.removeEventListener("ar-status", passthroughProps.onPause);
|
|
2671
2807
|
if (passthroughProps.onSceneGraphReady)
|
|
2672
|
-
modelViewer.removeEventListener(
|
|
2808
|
+
modelViewer.removeEventListener(
|
|
2809
|
+
"scene-graph-ready",
|
|
2810
|
+
passthroughProps.onSceneGraphReady
|
|
2811
|
+
);
|
|
2673
2812
|
};
|
|
2674
|
-
}, [
|
|
2813
|
+
}, [
|
|
2814
|
+
modelViewer,
|
|
2815
|
+
passthroughProps.onArStatus,
|
|
2816
|
+
passthroughProps.onArTracking,
|
|
2817
|
+
passthroughProps.onCameraChange,
|
|
2818
|
+
passthroughProps.onEnvironmentChange,
|
|
2819
|
+
passthroughProps.onError,
|
|
2820
|
+
passthroughProps.onLoad,
|
|
2821
|
+
passthroughProps.onModelVisibility,
|
|
2822
|
+
passthroughProps.onPause,
|
|
2823
|
+
passthroughProps.onPlay,
|
|
2824
|
+
passthroughProps.onPreload,
|
|
2825
|
+
passthroughProps.onProgress,
|
|
2826
|
+
passthroughProps.onQuickLookButtonTapped,
|
|
2827
|
+
passthroughProps.onSceneGraphReady
|
|
2828
|
+
]);
|
|
2675
2829
|
if (modelViewerLoadedStatus !== "done") {
|
|
2676
2830
|
return null;
|
|
2677
2831
|
}
|
|
@@ -2682,63 +2836,62 @@
|
|
|
2682
2836
|
}
|
|
2683
2837
|
}
|
|
2684
2838
|
if (!data.alt) {
|
|
2685
|
-
console.warn(
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
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
|
-
var _jsxFileName$3 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/MediaFile.tsx";
|
|
2839
|
+
console.warn(
|
|
2840
|
+
`<ModelViewer/> requires the 'data.alt' prop for accessibility`
|
|
2841
|
+
);
|
|
2842
|
+
}
|
|
2843
|
+
return /* @__PURE__ */ React.createElement(
|
|
2844
|
+
"model-viewer",
|
|
2845
|
+
{
|
|
2846
|
+
ref: callbackRef,
|
|
2847
|
+
...passthroughProps,
|
|
2848
|
+
className,
|
|
2849
|
+
id: passthroughProps.id ?? data.id,
|
|
2850
|
+
src: data.sources[0].url,
|
|
2851
|
+
alt: data.alt ?? null,
|
|
2852
|
+
"camera-controls": passthroughProps.cameraControls ?? true,
|
|
2853
|
+
poster: (passthroughProps.poster || ((_c = data.previewImage) == null ? void 0 : _c.url)) ?? null,
|
|
2854
|
+
autoplay: passthroughProps.autoplay ?? true,
|
|
2855
|
+
loading: passthroughProps.loading,
|
|
2856
|
+
reveal: passthroughProps.reveal,
|
|
2857
|
+
ar: passthroughProps.ar,
|
|
2858
|
+
"ar-modes": passthroughProps.arModes,
|
|
2859
|
+
"ar-scale": passthroughProps.arScale,
|
|
2860
|
+
"ar-placement": passthroughProps.arPlacement,
|
|
2861
|
+
"ios-src": passthroughProps.iosSrc,
|
|
2862
|
+
"touch-action": passthroughProps.touchAction,
|
|
2863
|
+
"disable-zoom": passthroughProps.disableZoom,
|
|
2864
|
+
"orbit-sensitivity": passthroughProps.orbitSensitivity,
|
|
2865
|
+
"auto-rotate": passthroughProps.autoRotate,
|
|
2866
|
+
"auto-rotate-delay": passthroughProps.autoRotateDelay,
|
|
2867
|
+
"rotation-per-second": passthroughProps.rotationPerSecond,
|
|
2868
|
+
"interaction-policy": passthroughProps.interactionPolicy,
|
|
2869
|
+
"interaction-prompt": passthroughProps.interactionPrompt,
|
|
2870
|
+
"interaction-prompt-style": passthroughProps.interactionPromptStyle,
|
|
2871
|
+
"interaction-prompt-threshold": passthroughProps.interactionPromptThreshold,
|
|
2872
|
+
"camera-orbit": passthroughProps.cameraOrbit,
|
|
2873
|
+
"camera-target": passthroughProps.cameraTarget,
|
|
2874
|
+
"field-of-view": passthroughProps.fieldOfView,
|
|
2875
|
+
"max-camera-orbit": passthroughProps.maxCameraOrbit,
|
|
2876
|
+
"min-camera-orbit": passthroughProps.minCameraOrbit,
|
|
2877
|
+
"max-field-of-view": passthroughProps.maxFieldOfView,
|
|
2878
|
+
"min-field-of-view": passthroughProps.minFieldOfView,
|
|
2879
|
+
bounds: passthroughProps.bounds,
|
|
2880
|
+
"interpolation-decay": passthroughProps.interpolationDecay ?? 100,
|
|
2881
|
+
"skybox-image": passthroughProps.skyboxImage,
|
|
2882
|
+
"environment-image": passthroughProps.environmentImage,
|
|
2883
|
+
exposure: passthroughProps.exposure,
|
|
2884
|
+
"shadow-intensity": passthroughProps.shadowIntensity ?? 0,
|
|
2885
|
+
"shadow-softness": passthroughProps.shadowSoftness ?? 0,
|
|
2886
|
+
"animation-name": passthroughProps.animationName,
|
|
2887
|
+
"animation-crossfade-duration": passthroughProps.animationCrossfadeDuration,
|
|
2888
|
+
"variant-name": passthroughProps.variantName,
|
|
2889
|
+
orientation: passthroughProps.orientation,
|
|
2890
|
+
scale: passthroughProps.scale
|
|
2891
|
+
},
|
|
2892
|
+
children
|
|
2893
|
+
);
|
|
2894
|
+
}
|
|
2742
2895
|
function MediaFile({
|
|
2743
2896
|
data,
|
|
2744
2897
|
mediaOptions,
|
|
@@ -2752,56 +2905,40 @@
|
|
|
2752
2905
|
throw new Error(noDataImage);
|
|
2753
2906
|
}
|
|
2754
2907
|
}
|
|
2755
|
-
return /* @__PURE__ */
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
fileName: _jsxFileName$3,
|
|
2762
|
-
lineNumber: 54,
|
|
2763
|
-
columnNumber: 9
|
|
2908
|
+
return /* @__PURE__ */ React.createElement(
|
|
2909
|
+
Image,
|
|
2910
|
+
{
|
|
2911
|
+
...passthroughProps,
|
|
2912
|
+
...mediaOptions == null ? void 0 : mediaOptions.image,
|
|
2913
|
+
data: data.image
|
|
2764
2914
|
}
|
|
2765
|
-
|
|
2915
|
+
);
|
|
2766
2916
|
}
|
|
2767
2917
|
case "Video": {
|
|
2768
|
-
return /* @__PURE__ */
|
|
2769
|
-
...passthroughProps,
|
|
2770
|
-
...mediaOptions == null ? void 0 : mediaOptions.video,
|
|
2771
|
-
data,
|
|
2772
|
-
__self: this,
|
|
2773
|
-
__source: {
|
|
2774
|
-
fileName: _jsxFileName$3,
|
|
2775
|
-
lineNumber: 63,
|
|
2776
|
-
columnNumber: 9
|
|
2777
|
-
}
|
|
2778
|
-
});
|
|
2918
|
+
return /* @__PURE__ */ React.createElement(Video, { ...passthroughProps, ...mediaOptions == null ? void 0 : mediaOptions.video, data });
|
|
2779
2919
|
}
|
|
2780
2920
|
case "ExternalVideo": {
|
|
2781
|
-
return /* @__PURE__ */
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
fileName: _jsxFileName$3,
|
|
2788
|
-
lineNumber: 68,
|
|
2789
|
-
columnNumber: 9
|
|
2921
|
+
return /* @__PURE__ */ React.createElement(
|
|
2922
|
+
ExternalVideo,
|
|
2923
|
+
{
|
|
2924
|
+
...passthroughProps,
|
|
2925
|
+
...mediaOptions == null ? void 0 : mediaOptions.externalVideo,
|
|
2926
|
+
data
|
|
2790
2927
|
}
|
|
2791
|
-
|
|
2928
|
+
);
|
|
2792
2929
|
}
|
|
2793
2930
|
case "Model3d": {
|
|
2794
|
-
return
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2931
|
+
return (
|
|
2932
|
+
// @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
|
|
2933
|
+
/* @__PURE__ */ React.createElement(
|
|
2934
|
+
ModelViewer,
|
|
2935
|
+
{
|
|
2936
|
+
...passthroughProps,
|
|
2937
|
+
...mediaOptions == null ? void 0 : mediaOptions.modelViewer,
|
|
2938
|
+
data
|
|
2939
|
+
}
|
|
2940
|
+
)
|
|
2941
|
+
);
|
|
2805
2942
|
}
|
|
2806
2943
|
default: {
|
|
2807
2944
|
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.`;
|
|
@@ -2812,7 +2949,6 @@
|
|
|
2812
2949
|
}
|
|
2813
2950
|
}
|
|
2814
2951
|
function parseMetafield(metafield) {
|
|
2815
|
-
var _a, _b, _c, _d;
|
|
2816
2952
|
if (!metafield.type) {
|
|
2817
2953
|
const noTypeError = `parseMetafield(): The 'type' field is required in order to parse the Metafield.`;
|
|
2818
2954
|
{
|
|
@@ -2859,7 +2995,7 @@
|
|
|
2859
2995
|
case "list.weight": {
|
|
2860
2996
|
let parsedValue = null;
|
|
2861
2997
|
try {
|
|
2862
|
-
parsedValue = parseJSON(
|
|
2998
|
+
parsedValue = parseJSON(metafield.value ?? "");
|
|
2863
2999
|
} catch (err) {
|
|
2864
3000
|
const parseError = `parseMetafield(): attempted to JSON.parse the 'metafield.value' property, but failed.`;
|
|
2865
3001
|
{
|
|
@@ -2875,11 +3011,11 @@
|
|
|
2875
3011
|
case "date_time":
|
|
2876
3012
|
return {
|
|
2877
3013
|
...metafield,
|
|
2878
|
-
parsedValue: new Date(
|
|
3014
|
+
parsedValue: new Date(metafield.value ?? "")
|
|
2879
3015
|
};
|
|
2880
3016
|
case "list.date":
|
|
2881
3017
|
case "list.date_time": {
|
|
2882
|
-
const jsonParseValue = parseJSON((
|
|
3018
|
+
const jsonParseValue = parseJSON((metafield == null ? void 0 : metafield.value) ?? "");
|
|
2883
3019
|
return {
|
|
2884
3020
|
...metafield,
|
|
2885
3021
|
parsedValue: jsonParseValue.map((dateString) => new Date(dateString))
|
|
@@ -2898,7 +3034,7 @@
|
|
|
2898
3034
|
case "list.variant_reference":
|
|
2899
3035
|
return {
|
|
2900
3036
|
...metafield,
|
|
2901
|
-
parsedValue: flattenConnection(
|
|
3037
|
+
parsedValue: flattenConnection(metafield.references ?? void 0)
|
|
2902
3038
|
};
|
|
2903
3039
|
default: {
|
|
2904
3040
|
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.`;
|
|
@@ -2918,17 +3054,20 @@
|
|
|
2918
3054
|
return JSON.parse(json);
|
|
2919
3055
|
}
|
|
2920
3056
|
function useMoney(money) {
|
|
2921
|
-
const {
|
|
2922
|
-
locale
|
|
2923
|
-
} = useShop();
|
|
3057
|
+
const { locale } = useShop();
|
|
2924
3058
|
if (!locale) {
|
|
2925
|
-
throw new Error(
|
|
3059
|
+
throw new Error(
|
|
3060
|
+
`useMoney(): Unable to get 'locale' from 'useShop()', which means that 'locale' was not passed to '<ShopifyProvider/>'. 'locale' is required for 'useMoney()' to work`
|
|
3061
|
+
);
|
|
2926
3062
|
}
|
|
2927
3063
|
const amount = parseFloat(money.amount);
|
|
2928
|
-
const options = React.useMemo(
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
3064
|
+
const options = React.useMemo(
|
|
3065
|
+
() => ({
|
|
3066
|
+
style: "currency",
|
|
3067
|
+
currency: money.currencyCode
|
|
3068
|
+
}),
|
|
3069
|
+
[money.currencyCode]
|
|
3070
|
+
);
|
|
2932
3071
|
const defaultFormatter = useLazyFormatter(locale, options);
|
|
2933
3072
|
const nameFormatter = useLazyFormatter(locale, {
|
|
2934
3073
|
...options,
|
|
@@ -2949,41 +3088,62 @@
|
|
|
2949
3088
|
maximumFractionDigits: 0
|
|
2950
3089
|
});
|
|
2951
3090
|
const isPartCurrency = (part) => part.type === "currency";
|
|
2952
|
-
const lazyFormatters = React.useMemo(
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
3091
|
+
const lazyFormatters = React.useMemo(
|
|
3092
|
+
() => ({
|
|
3093
|
+
original: () => money,
|
|
3094
|
+
currencyCode: () => money.currencyCode,
|
|
3095
|
+
localizedString: () => defaultFormatter().format(amount),
|
|
3096
|
+
parts: () => defaultFormatter().formatToParts(amount),
|
|
3097
|
+
withoutTrailingZeros: () => amount % 1 === 0 ? withoutTrailingZerosFormatter().format(amount) : defaultFormatter().format(amount),
|
|
3098
|
+
withoutTrailingZerosAndCurrency: () => amount % 1 === 0 ? withoutTrailingZerosOrCurrencyFormatter().format(amount) : withoutCurrencyFormatter().format(amount),
|
|
3099
|
+
currencyName: () => {
|
|
3100
|
+
var _a;
|
|
3101
|
+
return ((_a = nameFormatter().formatToParts(amount).find(isPartCurrency)) == null ? void 0 : _a.value) ?? money.currencyCode;
|
|
3102
|
+
},
|
|
3103
|
+
// e.g. "US dollars"
|
|
3104
|
+
currencySymbol: () => {
|
|
3105
|
+
var _a;
|
|
3106
|
+
return ((_a = defaultFormatter().formatToParts(amount).find(isPartCurrency)) == null ? void 0 : _a.value) ?? money.currencyCode;
|
|
3107
|
+
},
|
|
3108
|
+
// e.g. "USD"
|
|
3109
|
+
currencyNarrowSymbol: () => {
|
|
3110
|
+
var _a;
|
|
3111
|
+
return ((_a = narrowSymbolFormatter().formatToParts(amount).find(isPartCurrency)) == null ? void 0 : _a.value) ?? "";
|
|
3112
|
+
},
|
|
3113
|
+
// e.g. "$"
|
|
3114
|
+
amount: () => defaultFormatter().formatToParts(amount).filter(
|
|
3115
|
+
(part) => ["decimal", "fraction", "group", "integer", "literal"].includes(
|
|
3116
|
+
part.type
|
|
3117
|
+
)
|
|
3118
|
+
).map((part) => part.value).join("")
|
|
3119
|
+
}),
|
|
3120
|
+
[
|
|
3121
|
+
money,
|
|
3122
|
+
amount,
|
|
3123
|
+
nameFormatter,
|
|
3124
|
+
defaultFormatter,
|
|
3125
|
+
narrowSymbolFormatter,
|
|
3126
|
+
withoutCurrencyFormatter,
|
|
3127
|
+
withoutTrailingZerosFormatter,
|
|
3128
|
+
withoutTrailingZerosOrCurrencyFormatter
|
|
3129
|
+
]
|
|
3130
|
+
);
|
|
3131
|
+
return React.useMemo(
|
|
3132
|
+
() => new Proxy(lazyFormatters, {
|
|
3133
|
+
get: (target, key) => {
|
|
3134
|
+
var _a;
|
|
3135
|
+
return (_a = Reflect.get(target, key)) == null ? void 0 : _a.call(null);
|
|
3136
|
+
}
|
|
3137
|
+
}),
|
|
3138
|
+
[lazyFormatters]
|
|
3139
|
+
);
|
|
2979
3140
|
}
|
|
2980
3141
|
function useLazyFormatter(locale, options) {
|
|
2981
3142
|
return React.useMemo(() => {
|
|
2982
3143
|
let memoized;
|
|
2983
|
-
return () => memoized
|
|
3144
|
+
return () => memoized ?? (memoized = new Intl.NumberFormat(locale, options));
|
|
2984
3145
|
}, [locale, options]);
|
|
2985
3146
|
}
|
|
2986
|
-
var _jsxFileName$2 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Money.tsx";
|
|
2987
3147
|
function Money({
|
|
2988
3148
|
data,
|
|
2989
3149
|
as,
|
|
@@ -2994,10 +3154,12 @@
|
|
|
2994
3154
|
...passthroughProps
|
|
2995
3155
|
}) {
|
|
2996
3156
|
if (!isMoney(data)) {
|
|
2997
|
-
throw new Error(
|
|
3157
|
+
throw new Error(
|
|
3158
|
+
`<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'`
|
|
3159
|
+
);
|
|
2998
3160
|
}
|
|
2999
3161
|
const moneyObject = useMoney(data);
|
|
3000
|
-
const Wrapper = as
|
|
3162
|
+
const Wrapper = as ?? "div";
|
|
3001
3163
|
let output = moneyObject.localizedString;
|
|
3002
3164
|
if (withoutCurrency || withoutTrailingZeros) {
|
|
3003
3165
|
if (withoutCurrency && !withoutTrailingZeros) {
|
|
@@ -3008,22 +3170,13 @@
|
|
|
3008
3170
|
output = moneyObject.withoutTrailingZerosAndCurrency;
|
|
3009
3171
|
}
|
|
3010
3172
|
}
|
|
3011
|
-
return /* @__PURE__ */
|
|
3012
|
-
...passthroughProps,
|
|
3013
|
-
__self: this,
|
|
3014
|
-
__source: {
|
|
3015
|
-
fileName: _jsxFileName$2,
|
|
3016
|
-
lineNumber: 65,
|
|
3017
|
-
columnNumber: 5
|
|
3018
|
-
}
|
|
3019
|
-
}, output, measurement && measurement.referenceUnit && /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, measurementSeparator, measurement.referenceUnit));
|
|
3173
|
+
return /* @__PURE__ */ React.createElement(Wrapper, { ...passthroughProps }, output, measurement && measurement.referenceUnit && /* @__PURE__ */ React.createElement(React.Fragment, null, measurementSeparator, measurement.referenceUnit));
|
|
3020
3174
|
}
|
|
3021
3175
|
function isMoney(maybeMoney) {
|
|
3022
3176
|
return typeof maybeMoney.amount === "string" && !!maybeMoney.amount && typeof maybeMoney.currencyCode === "string" && !!maybeMoney.currencyCode;
|
|
3023
3177
|
}
|
|
3024
|
-
var _jsxFileName$1 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductPrice.tsx";
|
|
3025
3178
|
function ProductPrice(props) {
|
|
3026
|
-
var _a, _b, _c, _d, _e, _f
|
|
3179
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3027
3180
|
const {
|
|
3028
3181
|
priceType = "regular",
|
|
3029
3182
|
variantId,
|
|
@@ -3036,17 +3189,19 @@
|
|
|
3036
3189
|
}
|
|
3037
3190
|
let price;
|
|
3038
3191
|
let measurement;
|
|
3039
|
-
const variant = variantId ?
|
|
3192
|
+
const variant = variantId ? flattenConnection((product == null ? void 0 : product.variants) ?? {}).find(
|
|
3193
|
+
(variant2) => (variant2 == null ? void 0 : variant2.id) === variantId
|
|
3194
|
+
) ?? null : null;
|
|
3040
3195
|
if (priceType === "compareAt") {
|
|
3041
3196
|
if (variantId && variant) {
|
|
3042
|
-
if (((
|
|
3197
|
+
if (((_a = variant.compareAtPriceV2) == null ? void 0 : _a.amount) === ((_b = variant.priceV2) == null ? void 0 : _b.amount)) {
|
|
3043
3198
|
return null;
|
|
3044
3199
|
}
|
|
3045
3200
|
price = variant.compareAtPriceV2;
|
|
3046
3201
|
} else if (valueType === "max") {
|
|
3047
|
-
price = (
|
|
3202
|
+
price = (_c = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _c.maxVariantPrice;
|
|
3048
3203
|
} else {
|
|
3049
|
-
price = (
|
|
3204
|
+
price = (_d = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _d.minVariantPrice;
|
|
3050
3205
|
}
|
|
3051
3206
|
} else {
|
|
3052
3207
|
if (variantId && variant) {
|
|
@@ -3056,39 +3211,19 @@
|
|
|
3056
3211
|
measurement = variant.unitPriceMeasurement;
|
|
3057
3212
|
}
|
|
3058
3213
|
} else if (valueType === "max") {
|
|
3059
|
-
price = (
|
|
3214
|
+
price = (_e = product.priceRange) == null ? void 0 : _e.maxVariantPrice;
|
|
3060
3215
|
} else {
|
|
3061
|
-
price = (
|
|
3216
|
+
price = (_f = product.priceRange) == null ? void 0 : _f.minVariantPrice;
|
|
3062
3217
|
}
|
|
3063
3218
|
}
|
|
3064
3219
|
if (!price) {
|
|
3065
3220
|
return null;
|
|
3066
3221
|
}
|
|
3067
3222
|
if (measurement) {
|
|
3068
|
-
return /* @__PURE__ */
|
|
3069
|
-
...passthroughProps,
|
|
3070
|
-
data: price,
|
|
3071
|
-
measurement,
|
|
3072
|
-
__self: this,
|
|
3073
|
-
__source: {
|
|
3074
|
-
fileName: _jsxFileName$1,
|
|
3075
|
-
lineNumber: 81,
|
|
3076
|
-
columnNumber: 7
|
|
3077
|
-
}
|
|
3078
|
-
});
|
|
3223
|
+
return /* @__PURE__ */ React.createElement(Money, { ...passthroughProps, data: price, measurement });
|
|
3079
3224
|
}
|
|
3080
|
-
return /* @__PURE__ */
|
|
3081
|
-
...passthroughProps,
|
|
3082
|
-
data: price,
|
|
3083
|
-
__self: this,
|
|
3084
|
-
__source: {
|
|
3085
|
-
fileName: _jsxFileName$1,
|
|
3086
|
-
lineNumber: 85,
|
|
3087
|
-
columnNumber: 10
|
|
3088
|
-
}
|
|
3089
|
-
});
|
|
3225
|
+
return /* @__PURE__ */ React.createElement(Money, { ...passthroughProps, data: price });
|
|
3090
3226
|
}
|
|
3091
|
-
var _jsxFileName = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopPayButton.tsx";
|
|
3092
3227
|
const SHOPJS_URL = "https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js";
|
|
3093
3228
|
function ShopPayButton({
|
|
3094
3229
|
variantIds,
|
|
@@ -3096,9 +3231,7 @@
|
|
|
3096
3231
|
variantIdsAndQuantities,
|
|
3097
3232
|
width
|
|
3098
3233
|
}) {
|
|
3099
|
-
const {
|
|
3100
|
-
storeDomain
|
|
3101
|
-
} = useShop();
|
|
3234
|
+
const { storeDomain } = useShop();
|
|
3102
3235
|
const shopPayLoadedStatus = useLoadScript(SHOPJS_URL);
|
|
3103
3236
|
let ids;
|
|
3104
3237
|
if (variantIds && variantIdsAndQuantities) {
|
|
@@ -3114,10 +3247,9 @@
|
|
|
3114
3247
|
}, []);
|
|
3115
3248
|
} else if (variantIdsAndQuantities) {
|
|
3116
3249
|
ids = variantIdsAndQuantities.reduce((prev, curr) => {
|
|
3117
|
-
var _a;
|
|
3118
3250
|
const bareId = getIdFromGid(curr == null ? void 0 : curr.id);
|
|
3119
3251
|
if (bareId) {
|
|
3120
|
-
prev.push(`${bareId}:${(
|
|
3252
|
+
prev.push(`${bareId}:${(curr == null ? void 0 : curr.quantity) ?? 1}`);
|
|
3121
3253
|
}
|
|
3122
3254
|
return prev;
|
|
3123
3255
|
}, []);
|
|
@@ -3127,25 +3259,7 @@
|
|
|
3127
3259
|
const style = width ? {
|
|
3128
3260
|
"--shop-pay-button-width": width
|
|
3129
3261
|
} : void 0;
|
|
3130
|
-
return /* @__PURE__ */
|
|
3131
|
-
className,
|
|
3132
|
-
style,
|
|
3133
|
-
__self: this,
|
|
3134
|
-
__source: {
|
|
3135
|
-
fileName: _jsxFileName,
|
|
3136
|
-
lineNumber: 90,
|
|
3137
|
-
columnNumber: 5
|
|
3138
|
-
}
|
|
3139
|
-
}, shopPayLoadedStatus === "done" && /* @__PURE__ */ React__default.default.createElement("shop-pay-button", {
|
|
3140
|
-
"store-url": storeDomain,
|
|
3141
|
-
variants: ids.join(","),
|
|
3142
|
-
__self: this,
|
|
3143
|
-
__source: {
|
|
3144
|
-
fileName: _jsxFileName,
|
|
3145
|
-
lineNumber: 92,
|
|
3146
|
-
columnNumber: 9
|
|
3147
|
-
}
|
|
3148
|
-
}));
|
|
3262
|
+
return /* @__PURE__ */ React.createElement("div", { className, style }, shopPayLoadedStatus === "done" && /* @__PURE__ */ React.createElement("shop-pay-button", { "store-url": storeDomain, variants: ids.join(",") }));
|
|
3149
3263
|
}
|
|
3150
3264
|
function getIdFromGid(id) {
|
|
3151
3265
|
if (!id)
|
|
@@ -3176,6 +3290,6 @@
|
|
|
3176
3290
|
exports2.useMoney = useMoney;
|
|
3177
3291
|
exports2.useProduct = useProduct;
|
|
3178
3292
|
exports2.useShop = useShop;
|
|
3179
|
-
Object.
|
|
3293
|
+
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
3180
3294
|
});
|
|
3181
3295
|
//# sourceMappingURL=hydrogen-react.dev.js.map
|