@shopify/hydrogen 0.12.0 → 0.13.2
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/CHANGELOG.md +331 -27
- package/dist/esnext/client.d.ts +2 -0
- package/dist/esnext/client.js +2 -0
- package/dist/esnext/components/CartLineProvider/context.d.ts +10 -10
- package/dist/esnext/components/CartProvider/CartProvider.client.d.ts +1 -1
- package/dist/esnext/components/CartProvider/CartProvider.client.js +2 -1
- package/dist/esnext/components/CartProvider/cart-queries.d.ts +9 -0
- package/dist/esnext/components/CartProvider/cart-queries.js +876 -0
- package/dist/esnext/components/CartProvider/graphql/CartAttributesUpdateMutation.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartCreateMutation.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartFragment.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartLineAddMutation.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartLineRemoveMutation.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartLineUpdateMutation.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartNoteUpdateMutation.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartQuery.d.ts +1 -1
- package/dist/esnext/components/CartProvider/hooks.d.ts +1 -1
- package/dist/esnext/components/CartProvider/hooks.js +4 -1
- package/dist/esnext/components/CartProvider/types.d.ts +1 -1
- package/dist/esnext/components/ExternalVideo/ExternalVideo.d.ts +6 -5
- package/dist/esnext/components/ExternalVideo/ExternalVideo.js +5 -2
- package/dist/esnext/components/Image/Image.d.ts +14 -12
- package/dist/esnext/components/Image/Image.js +17 -14
- package/dist/esnext/components/Link/Link.client.d.ts +4 -5
- package/dist/esnext/components/Link/Link.client.js +5 -4
- package/dist/esnext/components/LocalizationProvider/LocalizationClientProvider.client.js +1 -3
- package/dist/esnext/components/LocalizationProvider/LocalizationContext.client.d.ts +0 -1
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.d.ts +2 -2
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +15 -4
- package/dist/esnext/components/LocalizationProvider/LocalizationQuery.d.ts +1 -8
- package/dist/esnext/components/LocalizationProvider/index.d.ts +0 -1
- package/dist/esnext/components/LocalizationProvider/index.js +0 -1
- package/dist/esnext/components/MediaFile/MediaFile.d.ts +4 -3
- package/dist/esnext/components/Metafield/Metafield.client.d.ts +2 -2
- package/dist/esnext/components/Metafield/Metafield.client.js +8 -5
- package/dist/esnext/components/Metafield/types.d.ts +1 -1
- package/dist/esnext/components/ModelViewer/ModelViewer.client.d.ts +57 -56
- package/dist/esnext/components/ModelViewer/ModelViewer.client.js +10 -4
- package/dist/esnext/components/Money/Money.client.d.ts +5 -4
- package/dist/esnext/components/Money/Money.client.js +1 -1
- package/dist/esnext/components/ProductDescription/ProductDescription.client.d.ts +9 -4
- package/dist/esnext/components/ProductDescription/ProductDescription.client.js +4 -3
- package/dist/esnext/components/ProductMetafield/ProductMetafield.client.js +3 -3
- package/dist/esnext/components/ProductPrice/ProductPrice.client.js +2 -2
- package/dist/esnext/components/ProductProvider/ProductProvider.client.d.ts +3 -2
- package/dist/esnext/components/ProductProvider/ProductProvider.client.js +1 -0
- package/dist/esnext/components/ProductProvider/context.d.ts +23 -14
- package/dist/esnext/components/Seo/CollectionSeo.client.d.ts +3 -2
- package/dist/esnext/components/Seo/CollectionSeo.client.js +2 -2
- package/dist/esnext/components/Seo/DefaultPageSeo.client.d.ts +3 -2
- package/dist/esnext/components/Seo/DescriptionSeo.client.d.ts +2 -2
- package/dist/esnext/components/Seo/HomePageSeo.client.d.ts +1 -1
- package/dist/esnext/components/Seo/ImageSeo.client.d.ts +3 -2
- package/dist/esnext/components/Seo/ImageSeo.client.js +1 -1
- package/dist/esnext/components/Seo/PageSeo.client.d.ts +3 -2
- package/dist/esnext/components/Seo/ProductSeo.client.d.ts +3 -3
- package/dist/esnext/components/Seo/ProductSeo.client.js +10 -5
- package/dist/esnext/components/Seo/Seo.client.d.ts +10 -7
- package/dist/esnext/components/Seo/TitleSeo.client.d.ts +3 -4
- package/dist/esnext/components/Seo/TwitterSeo.client.d.ts +1 -1
- package/dist/esnext/components/Seo/seo-types.d.ts +17 -0
- package/dist/esnext/components/{ExternalVideo/ExternalVideoFragment.js → Seo/seo-types.js} +0 -0
- package/dist/esnext/components/UnitPrice/UnitPrice.client.d.ts +7 -6
- package/dist/esnext/components/UnitPrice/UnitPrice.client.js +1 -1
- package/dist/esnext/components/Video/Video.d.ts +5 -4
- package/dist/esnext/components/Video/Video.js +10 -2
- package/dist/esnext/components/index.d.ts +0 -3
- package/dist/esnext/components/index.js +0 -3
- package/dist/esnext/entry-client.js +9 -4
- package/dist/esnext/entry-server.d.ts +1 -0
- package/dist/esnext/entry-server.js +101 -88
- package/dist/esnext/foundation/FileRoutes/FileRoutes.server.d.ts +22 -0
- package/dist/esnext/foundation/{Router/FileRoutes.js → FileRoutes/FileRoutes.server.js} +20 -10
- package/dist/esnext/foundation/Redirect/Redirect.client.d.ts +5 -0
- package/dist/esnext/foundation/Redirect/Redirect.client.js +14 -0
- package/dist/esnext/foundation/Route/Route.server.d.ts +12 -0
- package/dist/esnext/foundation/Route/Route.server.js +33 -0
- package/dist/esnext/foundation/Router/{Router.d.ts → BrowserRouter.client.d.ts} +3 -2
- package/dist/esnext/foundation/Router/{Router.js → BrowserRouter.client.js} +7 -5
- package/dist/esnext/foundation/Router/Router.server.d.ts +5 -3
- package/dist/esnext/foundation/Router/Router.server.js +7 -22
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +19 -24
- package/dist/esnext/foundation/ShopifyProvider/index.d.ts +0 -1
- package/dist/esnext/foundation/ShopifyProvider/index.js +0 -1
- package/dist/esnext/foundation/index.d.ts +0 -1
- package/dist/esnext/foundation/index.js +0 -1
- package/dist/esnext/{hooks → foundation}/useNavigate/useNavigate.d.ts +6 -3
- package/dist/esnext/{hooks → foundation}/useNavigate/useNavigate.js +4 -1
- package/dist/esnext/foundation/useQuery/hooks.d.ts +5 -4
- package/dist/esnext/foundation/useQuery/hooks.js +13 -4
- package/dist/esnext/foundation/useRouteParams/RouteParamsProvider.client.d.ts +9 -0
- package/dist/esnext/foundation/useRouteParams/RouteParamsProvider.client.js +7 -0
- package/dist/esnext/foundation/useRouteParams/useRouteParams.d.ts +4 -0
- package/dist/esnext/foundation/useRouteParams/useRouteParams.js +9 -0
- package/dist/esnext/foundation/useUrl/useUrl.js +1 -1
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.d.ts +13 -0
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.js +28 -7
- package/dist/esnext/framework/Hydration/ServerComponentResponse.server.d.ts +4 -1
- package/dist/esnext/framework/Hydration/ServerComponentResponse.server.js +5 -0
- package/dist/esnext/framework/cache/in-memory.d.ts +1 -0
- package/dist/esnext/framework/cache/in-memory.js +15 -5
- package/dist/esnext/framework/middleware.js +25 -3
- package/dist/esnext/framework/plugin.js +6 -1
- package/dist/esnext/framework/plugins/vite-plugin-css-modules-rsc.d.ts +2 -0
- package/dist/esnext/framework/plugins/vite-plugin-css-modules-rsc.js +28 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +61 -75
- package/dist/esnext/framework/plugins/vite-plugin-platform-entry.js +1 -1
- package/dist/esnext/hooks/index.d.ts +0 -1
- package/dist/esnext/hooks/index.js +0 -1
- package/dist/esnext/hooks/useCartLine/useCartLine.d.ts +10 -10
- package/dist/esnext/hooks/useCountry/useCountry.d.ts +4 -4
- package/dist/esnext/hooks/useMoney/hooks.d.ts +3 -3
- package/dist/esnext/hooks/useMoney/hooks.js +2 -2
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.d.ts +17 -2
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.js +7 -3
- package/dist/esnext/hooks/useProduct/useProduct.d.ts +34 -96
- package/dist/esnext/hooks/useProductOptions/helpers.d.ts +6 -4
- package/dist/esnext/hooks/useProductOptions/helpers.js +13 -6
- package/dist/esnext/hooks/useProductOptions/types.d.ts +15 -35
- package/dist/esnext/hooks/useProductOptions/useProductOptions.d.ts +6 -5
- package/dist/esnext/hooks/useProductOptions/useProductOptions.js +13 -3
- package/dist/esnext/hooks/useShopQuery/hooks.js +68 -15
- package/dist/esnext/index.d.ts +7 -5
- package/dist/esnext/index.js +7 -5
- package/dist/esnext/platforms/node.d.ts +2 -3
- package/dist/esnext/platforms/node.js +5 -3
- package/dist/esnext/platforms/worker-event.d.ts +0 -8
- package/dist/esnext/platforms/worker-event.js +2 -23
- package/dist/esnext/platforms/worker.d.ts +14 -0
- package/dist/esnext/platforms/worker.js +25 -0
- package/dist/esnext/{graphql/types/types.d.ts → storefront-api-types.d.ts} +389 -32
- package/dist/esnext/{graphql/types/types.js → storefront-api-types.js} +326 -30
- package/dist/esnext/streaming.server.d.ts +9 -5
- package/dist/esnext/streaming.server.js +2 -18
- package/dist/esnext/types.d.ts +1 -16
- package/dist/esnext/utilities/apiRoutes.d.ts +5 -1
- package/dist/esnext/utilities/apiRoutes.js +5 -4
- package/dist/esnext/utilities/devtools.d.ts +11 -0
- package/dist/esnext/utilities/devtools.js +11 -0
- package/dist/esnext/utilities/fetch.d.ts +7 -1
- package/dist/esnext/utilities/fetch.js +9 -10
- package/dist/esnext/utilities/flattenConnection/flattenConnection.d.ts +3 -2
- package/dist/esnext/utilities/flattenConnection/flattenConnection.js +6 -2
- package/dist/esnext/utilities/graphql-tracker.d.ts +17 -0
- package/dist/esnext/utilities/graphql-tracker.js +119 -0
- package/dist/esnext/utilities/image_size.d.ts +5 -4
- package/dist/esnext/utilities/log/log-query-timeline.d.ts +1 -1
- package/dist/esnext/utilities/log/log-query-timeline.js +1 -2
- package/dist/esnext/utilities/log/log.d.ts +1 -0
- package/dist/esnext/utilities/log/utils.js +3 -0
- package/dist/esnext/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +3 -2
- package/dist/esnext/version.d.ts +1 -1
- package/dist/esnext/version.js +1 -1
- package/dist/node/entry-server.d.ts +1 -0
- package/dist/node/entry-server.js +106 -89
- package/dist/node/foundation/Redirect/Redirect.client.d.ts +5 -0
- package/dist/node/foundation/Redirect/Redirect.client.js +17 -0
- package/dist/node/foundation/Router/BrowserRouter.client.d.ts +13 -0
- package/dist/node/foundation/Router/BrowserRouter.client.js +77 -0
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +24 -25
- package/dist/node/foundation/ServerRequestProvider/index.js +5 -1
- package/dist/node/foundation/ServerStateProvider/ServerStateProvider.js +5 -1
- package/dist/node/foundation/ssr-interop.d.ts +29 -0
- package/dist/node/foundation/ssr-interop.js +39 -0
- package/dist/node/foundation/useNavigate/useNavigate.d.ts +13 -0
- package/dist/node/foundation/useNavigate/useNavigate.js +18 -0
- package/dist/node/foundation/useServerState/index.d.ts +1 -0
- package/dist/node/foundation/useServerState/index.js +5 -0
- package/dist/node/foundation/useServerState/use-server-state.d.ts +16 -0
- package/dist/node/foundation/useServerState/use-server-state.js +24 -0
- package/dist/node/framework/Hydration/ServerComponentRequest.server.d.ts +13 -0
- package/dist/node/framework/Hydration/ServerComponentRequest.server.js +28 -7
- package/dist/node/framework/Hydration/ServerComponentResponse.server.d.ts +4 -1
- package/dist/node/framework/Hydration/ServerComponentResponse.server.js +8 -0
- package/dist/node/framework/cache/in-memory.d.ts +1 -0
- package/dist/node/framework/cache/in-memory.js +15 -5
- package/dist/node/framework/middleware.js +30 -4
- package/dist/node/framework/plugin.js +11 -2
- package/dist/node/framework/plugins/vite-plugin-css-modules-rsc.d.ts +2 -0
- package/dist/node/framework/plugins/vite-plugin-css-modules-rsc.js +31 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +61 -75
- package/dist/node/framework/plugins/vite-plugin-platform-entry.js +1 -1
- package/dist/node/{graphql/types/types.d.ts → storefront-api-types.d.ts} +389 -32
- package/dist/node/{graphql/types/types.js → storefront-api-types.js} +327 -31
- package/dist/node/streaming.server.d.ts +9 -5
- package/dist/node/streaming.server.js +2 -18
- package/dist/node/types.d.ts +1 -16
- package/dist/node/utilities/apiRoutes.d.ts +5 -1
- package/dist/node/utilities/apiRoutes.js +5 -4
- package/dist/node/utilities/fetch.d.ts +7 -1
- package/dist/node/utilities/fetch.js +9 -10
- package/dist/node/utilities/log/log-query-timeline.d.ts +1 -1
- package/dist/node/utilities/log/log-query-timeline.js +1 -2
- package/dist/node/utilities/log/log.d.ts +1 -0
- package/dist/node/utilities/log/utils.js +3 -0
- package/dist/node/utilities/web-api-polyfill.js +5 -1
- package/dist/node/version.d.ts +1 -1
- package/dist/node/version.js +1 -1
- package/package.json +9 -12
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +43 -104
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.development.server.js +1566 -848
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.production.min.server.js +36 -421
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.development.server.js +1523 -864
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.production.min.server.js +35 -437
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.development.js +507 -517
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.production.min.js +10 -246
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-client-proxy.js +16 -23
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +47 -108
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js +1033 -306
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.node.server.js +965 -293
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite.js +98 -108
- package/vendor/react-server-dom-vite/package.json +0 -2
- package/dist/esnext/components/ExternalVideo/ExternalVideoFragment.d.ts +0 -8
- package/dist/esnext/components/Image/ImageFragment.d.ts +0 -8
- package/dist/esnext/components/Image/ImageFragment.js +0 -1
- package/dist/esnext/components/MediaFile/MediaFileFragment.d.ts +0 -36
- package/dist/esnext/components/MediaFile/MediaFileFragment.js +0 -1
- package/dist/esnext/components/Metafield/MetafieldFragment.d.ts +0 -22
- package/dist/esnext/components/Metafield/MetafieldFragment.js +0 -1
- package/dist/esnext/components/ModelViewer/Model3DFragment.d.ts +0 -15
- package/dist/esnext/components/ModelViewer/Model3DFragment.js +0 -1
- package/dist/esnext/components/Money/MoneyFragment.d.ts +0 -8
- package/dist/esnext/components/Money/MoneyFragment.js +0 -1
- package/dist/esnext/components/ProductProvider/ProductProviderFragment.d.ts +0 -247
- package/dist/esnext/components/ProductProvider/ProductProviderFragment.js +0 -1
- package/dist/esnext/components/ProductProvider/types.d.ts +0 -19
- package/dist/esnext/components/ProductProvider/types.js +0 -1
- package/dist/esnext/components/RawHtml/RawHtml.d.ts +0 -17
- package/dist/esnext/components/RawHtml/RawHtml.js +0 -21
- package/dist/esnext/components/RawHtml/index.d.ts +0 -1
- package/dist/esnext/components/RawHtml/index.js +0 -1
- package/dist/esnext/components/Seo/SeoFragment.d.ts +0 -66
- package/dist/esnext/components/Seo/SeoFragment.js +0 -1
- package/dist/esnext/components/Seo/types.d.ts +0 -15
- package/dist/esnext/components/Seo/types.js +0 -1
- package/dist/esnext/components/UnitPrice/UnitPriceFragment.d.ts +0 -15
- package/dist/esnext/components/UnitPrice/UnitPriceFragment.js +0 -1
- package/dist/esnext/components/Video/VideoFragment.d.ts +0 -15
- package/dist/esnext/components/Video/VideoFragment.js +0 -1
- package/dist/esnext/foundation/Router/FileRoutes.d.ts +0 -18
- package/dist/esnext/foundation/Router/Route.server.d.ts +0 -9
- package/dist/esnext/foundation/Router/Route.server.js +0 -6
- package/dist/esnext/foundation/Router/useParams.d.ts +0 -1
- package/dist/esnext/foundation/Router/useParams.js +0 -5
- package/dist/esnext/fragments.d.ts +0 -20
- package/dist/esnext/fragments.js +0 -10
- package/dist/esnext/graphql/graphql-constants.d.ts +0 -1756
- package/dist/esnext/graphql/graphql-constants.js +0 -3447
- package/dist/esnext/hooks/useAvailableCountries/index.d.ts +0 -1
- package/dist/esnext/hooks/useAvailableCountries/index.js +0 -1
- package/dist/esnext/hooks/useAvailableCountries/useAvailableCountries.d.ts +0 -11
- package/dist/esnext/hooks/useAvailableCountries/useAvailableCountries.js +0 -17
- package/dist/esnext/hooks/useNavigate/index.d.ts +0 -1
- package/dist/esnext/hooks/useNavigate/index.js +0 -1
- package/dist/esnext/hooks/useProductOptions/SellingPlanFragment.d.ts +0 -31
- package/dist/esnext/hooks/useProductOptions/SellingPlanFragment.js +0 -1
- package/dist/esnext/hooks/useProductOptions/SellingPlanGroupsFragment.d.ts +0 -46
- package/dist/esnext/hooks/useProductOptions/SellingPlanGroupsFragment.js +0 -1
- package/dist/esnext/hooks/useProductOptions/VariantFragment.d.ts +0 -106
- package/dist/esnext/hooks/useProductOptions/VariantFragment.js +0 -1
- package/fragments.d.ts +0 -1
- package/fragments.js +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
|
|
3
3
|
* Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
|
|
4
4
|
*/
|
|
5
|
-
import * as Types from '../../../
|
|
5
|
+
import * as Types from '../../../storefront-api-types';
|
|
6
6
|
export declare type CartAttributesUpdateMutationVariables = Types.Exact<{
|
|
7
7
|
attributes: Array<Types.AttributeInput> | Types.AttributeInput;
|
|
8
8
|
cartId: Types.Scalars['ID'];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
|
|
3
3
|
* Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
|
|
4
4
|
*/
|
|
5
|
-
import * as Types from '../../../
|
|
5
|
+
import * as Types from '../../../storefront-api-types';
|
|
6
6
|
export declare type CartBuyerIdentityUpdateMutationVariables = Types.Exact<{
|
|
7
7
|
cartId: Types.Scalars['ID'];
|
|
8
8
|
buyerIdentity: Types.CartBuyerIdentityInput;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
|
|
3
3
|
* Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
|
|
4
4
|
*/
|
|
5
|
-
import * as Types from '../../../
|
|
5
|
+
import * as Types from '../../../storefront-api-types';
|
|
6
6
|
export declare type CartCreateMutationVariables = Types.Exact<{
|
|
7
7
|
input: Types.CartInput;
|
|
8
8
|
numCartLines?: Types.InputMaybe<Types.Scalars['Int']>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
|
|
3
3
|
* Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
|
|
4
4
|
*/
|
|
5
|
-
import * as Types from '../../../
|
|
5
|
+
import * as Types from '../../../storefront-api-types';
|
|
6
6
|
export declare type CartDiscountCodesUpdateMutationVariables = Types.Exact<{
|
|
7
7
|
cartId: Types.Scalars['ID'];
|
|
8
8
|
discountCodes?: Types.InputMaybe<Array<Types.Scalars['String']> | Types.Scalars['String']>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
|
|
3
3
|
* Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
|
|
4
4
|
*/
|
|
5
|
-
import * as Types from '../../../
|
|
5
|
+
import * as Types from '../../../storefront-api-types';
|
|
6
6
|
export declare type CartFragmentFragment = {
|
|
7
7
|
__typename?: 'Cart';
|
|
8
8
|
} & Pick<Types.Cart, 'id' | 'checkoutUrl' | 'note'> & {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
|
|
3
3
|
* Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
|
|
4
4
|
*/
|
|
5
|
-
import * as Types from '../../../
|
|
5
|
+
import * as Types from '../../../storefront-api-types';
|
|
6
6
|
export declare type CartLineAddMutationVariables = Types.Exact<{
|
|
7
7
|
cartId: Types.Scalars['ID'];
|
|
8
8
|
lines: Array<Types.CartLineInput> | Types.CartLineInput;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
|
|
3
3
|
* Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
|
|
4
4
|
*/
|
|
5
|
-
import * as Types from '../../../
|
|
5
|
+
import * as Types from '../../../storefront-api-types';
|
|
6
6
|
export declare type CartLineRemoveMutationVariables = Types.Exact<{
|
|
7
7
|
cartId: Types.Scalars['ID'];
|
|
8
8
|
lines: Array<Types.Scalars['ID']> | Types.Scalars['ID'];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
|
|
3
3
|
* Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
|
|
4
4
|
*/
|
|
5
|
-
import * as Types from '../../../
|
|
5
|
+
import * as Types from '../../../storefront-api-types';
|
|
6
6
|
export declare type CartLineUpdateMutationVariables = Types.Exact<{
|
|
7
7
|
cartId: Types.Scalars['ID'];
|
|
8
8
|
lines: Array<Types.CartLineUpdateInput> | Types.CartLineUpdateInput;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
|
|
3
3
|
* Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
|
|
4
4
|
*/
|
|
5
|
-
import * as Types from '../../../
|
|
5
|
+
import * as Types from '../../../storefront-api-types';
|
|
6
6
|
export declare type CartNoteUpdateMutationVariables = Types.Exact<{
|
|
7
7
|
cartId: Types.Scalars['ID'];
|
|
8
8
|
note?: Types.InputMaybe<Types.Scalars['String']>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
|
|
3
3
|
* Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
|
|
4
4
|
*/
|
|
5
|
-
import * as Types from '../../../
|
|
5
|
+
import * as Types from '../../../storefront-api-types';
|
|
6
6
|
export declare type CartQueryQueryVariables = Types.Exact<{
|
|
7
7
|
id: Types.Scalars['ID'];
|
|
8
8
|
numCartLines?: Types.InputMaybe<Types.Scalars['Int']>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { useShop } from '../../foundation';
|
|
3
3
|
import { flattenConnection } from '../../utilities';
|
|
4
|
-
import { CartCreate } from '
|
|
4
|
+
import { CartCreate } from './cart-queries';
|
|
5
5
|
export function useCartFetch() {
|
|
6
6
|
const { storeDomain, storefrontApiVersion, storefrontToken } = useShop();
|
|
7
7
|
return React.useCallback(({ query, variables, }) => {
|
|
@@ -9,6 +9,8 @@ export function useCartFetch() {
|
|
|
9
9
|
method: 'POST',
|
|
10
10
|
headers: {
|
|
11
11
|
'Content-Type': 'application/json',
|
|
12
|
+
'X-SDK-Variant': 'hydrogen',
|
|
13
|
+
'X-SDK-Version': storefrontApiVersion,
|
|
12
14
|
'X-Shopify-Storefront-Access-Token': storefrontToken,
|
|
13
15
|
},
|
|
14
16
|
body: JSON.stringify({
|
|
@@ -47,6 +49,7 @@ export function useInstantCheckout() {
|
|
|
47
49
|
const dataCart = data.cartCreate.cart;
|
|
48
50
|
updateCart({
|
|
49
51
|
...dataCart,
|
|
52
|
+
// @ts-expect-error While the cart still uses fragments, there will be a TS error here until we remove those fragments and get the type in-line
|
|
50
53
|
lines: flattenConnection(dataCart.lines),
|
|
51
54
|
note: (_b = dataCart.note) !== null && _b !== void 0 ? _b : undefined,
|
|
52
55
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CartInput, CartLineInput, CartLineUpdateInput, MutationCartNoteUpdateArgs, CartBuyerIdentityInput, MutationCartAttributesUpdateArgs } from '../../
|
|
1
|
+
import { CartInput, CartLineInput, CartLineUpdateInput, MutationCartNoteUpdateArgs, CartBuyerIdentityInput, MutationCartAttributesUpdateArgs } from '../../storefront-api-types';
|
|
2
2
|
import { CartFragmentFragment } from './graphql/CartFragment';
|
|
3
3
|
export declare type Status = State['status'];
|
|
4
4
|
export interface Cart {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { YouTube, Vimeo } from '../../utilities';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExternalVideo as ExternalVideoType } from '../../storefront-api-types';
|
|
3
|
+
import type { PartialDeep } from 'type-fest';
|
|
3
4
|
interface ExternalVideoProps {
|
|
4
|
-
/**
|
|
5
|
-
* [
|
|
5
|
+
/**
|
|
6
|
+
* An object with fields that correspond to the Storefront API's [ExternalVideo object](/api/storefront/reference/products/externalvideo).
|
|
6
7
|
*/
|
|
7
|
-
data:
|
|
8
|
+
data: PartialDeep<ExternalVideoType>;
|
|
8
9
|
/** An object containing the options available for either
|
|
9
10
|
* [YouTube](https://developers.google.com/youtube/player_parameters#Parameters) or
|
|
10
11
|
* [Vimeo](https://vimeo.zendesk.com/hc/en-us/articles/360001494447-Using-Player-Parameters).
|
|
@@ -14,7 +15,7 @@ interface ExternalVideoProps {
|
|
|
14
15
|
declare type PropsWeControl = 'src';
|
|
15
16
|
/**
|
|
16
17
|
* The `ExternalVideo` component renders an embedded video for the Storefront
|
|
17
|
-
* API's [
|
|
18
|
+
* API's [ExternalVideo object](/api/storefront/reference/products/externalvideo).
|
|
18
19
|
*/
|
|
19
20
|
export declare function ExternalVideo(props: Omit<JSX.IntrinsicElements['iframe'], PropsWeControl> & ExternalVideoProps): JSX.Element;
|
|
20
21
|
export {};
|
|
@@ -2,10 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import { useEmbeddedVideoUrl } from '../../utilities';
|
|
3
3
|
/**
|
|
4
4
|
* The `ExternalVideo` component renders an embedded video for the Storefront
|
|
5
|
-
* API's [
|
|
5
|
+
* API's [ExternalVideo object](/api/storefront/reference/products/externalvideo).
|
|
6
6
|
*/
|
|
7
7
|
export function ExternalVideo(props) {
|
|
8
8
|
const { data, options, id = data.id, frameBorder = '0', allow = 'accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture', allowFullScreen = true, ...passthroughProps } = props;
|
|
9
|
+
if (!data.embedUrl) {
|
|
10
|
+
throw new Error(`<ExternalVideo/> requires the 'embedUrl' property`);
|
|
11
|
+
}
|
|
9
12
|
const url = useEmbeddedVideoUrl(data.embedUrl, options);
|
|
10
|
-
return (React.createElement("iframe", { ...passthroughProps, id: id, frameBorder: frameBorder, allow: allow, allowFullScreen: allowFullScreen, src: url }));
|
|
13
|
+
return (React.createElement("iframe", { ...passthroughProps, id: id !== null && id !== void 0 ? id : data.embedUrl, frameBorder: frameBorder, allow: allow, allowFullScreen: allowFullScreen, src: url }));
|
|
11
14
|
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Props } from '../types';
|
|
3
2
|
import { ImageSizeOptions, ImageLoaderOptions } from '../../utilities';
|
|
4
|
-
import type {
|
|
3
|
+
import type { Image as ImageType } from '../../storefront-api-types';
|
|
4
|
+
import type { PartialDeep, Merge, MergeExclusive } from 'type-fest';
|
|
5
5
|
export interface BaseImageProps {
|
|
6
6
|
/** A custom function that generates the image URL. Parameters passed into this function includes
|
|
7
7
|
* `src` and an `options` object that contains the provided `width`, `height` and `loaderOptions` values.
|
|
8
8
|
*/
|
|
9
9
|
loader?(props: ImageLoaderOptions): string;
|
|
10
10
|
/** An object of `loader` function options. For example, if the `loader` function requires a `scale` option,
|
|
11
|
-
* then the value can be a property of the `loaderOptions` object (
|
|
11
|
+
* then the value can be a property of the `loaderOptions` object (for example, `{scale: 2}`).
|
|
12
12
|
*/
|
|
13
13
|
loaderOptions?: ImageLoaderOptions['options'];
|
|
14
14
|
}
|
|
15
|
-
interface
|
|
16
|
-
/** An object with
|
|
17
|
-
*
|
|
15
|
+
interface MediaImagePropsBase extends BaseImageProps {
|
|
16
|
+
/** An object with fields that correspond to the Storefront API's
|
|
17
|
+
* [Image object](/api/storefront/reference/common-objects/image).
|
|
18
18
|
*/
|
|
19
|
-
data:
|
|
19
|
+
data: PartialDeep<ImageType>;
|
|
20
20
|
/** An object of image size options for Shopify CDN images. */
|
|
21
21
|
options?: ImageSizeOptions;
|
|
22
22
|
}
|
|
23
|
-
interface
|
|
23
|
+
interface ExternalImagePropsBase extends BaseImageProps {
|
|
24
24
|
/** A URL string. This string can be an absolute path or a relative path depending on the `loader`. */
|
|
25
25
|
src: string;
|
|
26
26
|
/** The integer value for the width of the image. This is a required prop when `src` is present. */
|
|
@@ -28,11 +28,13 @@ interface ExternalImageProps extends BaseImageProps {
|
|
|
28
28
|
/** The integer value for the height of the image. This is a required prop when `src` is present. */
|
|
29
29
|
height: number;
|
|
30
30
|
}
|
|
31
|
-
declare type
|
|
32
|
-
declare type
|
|
31
|
+
declare type BaseElementProps = React.ImgHTMLAttributes<HTMLImageElement>;
|
|
32
|
+
declare type MediaImageProps = Merge<BaseElementProps, MediaImagePropsBase>;
|
|
33
|
+
declare type ExternalImageProps = Merge<BaseElementProps, ExternalImagePropsBase>;
|
|
34
|
+
declare type ImageProps = MergeExclusive<MediaImageProps, ExternalImageProps>;
|
|
33
35
|
/**
|
|
34
36
|
* The `Image` component renders an image for the Storefront API's
|
|
35
|
-
* [
|
|
37
|
+
* [Image object](/api/storefront/reference/common-objects/image).
|
|
36
38
|
*/
|
|
37
|
-
export declare function Image
|
|
39
|
+
export declare function Image(props: ImageProps): JSX.Element;
|
|
38
40
|
export {};
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { shopifyImageLoader, getShopifyImageDimensions, } from '../../utilities';
|
|
3
|
-
function convertShopifyImageData({ data, options, loader, loaderOptions, id: propId, alt, }) {
|
|
4
|
-
const { url: src, altText, id } = data;
|
|
5
|
-
const { width, height } = getShopifyImageDimensions(data, options);
|
|
6
|
-
return {
|
|
7
|
-
src,
|
|
8
|
-
id: propId ? propId : id,
|
|
9
|
-
alt: alt ? alt : altText,
|
|
10
|
-
width,
|
|
11
|
-
height,
|
|
12
|
-
loader: loader ? loader : shopifyImageLoader,
|
|
13
|
-
loaderOptions: { ...options, ...loaderOptions },
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
3
|
/**
|
|
17
4
|
* The `Image` component renders an image for the Storefront API's
|
|
18
|
-
* [
|
|
5
|
+
* [Image object](/api/storefront/reference/common-objects/image).
|
|
19
6
|
*/
|
|
20
7
|
export function Image(props) {
|
|
21
8
|
var _a, _b, _c, _d;
|
|
@@ -49,3 +36,19 @@ export function Image(props) {
|
|
|
49
36
|
: imgProps.src;
|
|
50
37
|
return (React.createElement("img", { id: (_a = imgProps.id) !== null && _a !== void 0 ? _a : '', loading: "lazy", alt: (_b = imgProps.alt) !== null && _b !== void 0 ? _b : '', ...passthroughProps, src: srcPath, width: (_c = imgProps.width) !== null && _c !== void 0 ? _c : undefined, height: (_d = imgProps.height) !== null && _d !== void 0 ? _d : undefined }));
|
|
51
38
|
}
|
|
39
|
+
function convertShopifyImageData({ data, options, loader, loaderOptions, id: propId, alt, }) {
|
|
40
|
+
const { url: src, altText, id } = data;
|
|
41
|
+
if (!src) {
|
|
42
|
+
throw new Error(`<Image/> requires 'data.url' when using the 'data' prop`);
|
|
43
|
+
}
|
|
44
|
+
const { width, height } = getShopifyImageDimensions(data, options);
|
|
45
|
+
return {
|
|
46
|
+
src,
|
|
47
|
+
id: propId ? propId : id,
|
|
48
|
+
alt: alt ? alt : altText,
|
|
49
|
+
width,
|
|
50
|
+
height,
|
|
51
|
+
loader: loader ? loader : shopifyImageLoader,
|
|
52
|
+
loaderOptions: { ...options, ...loaderOptions },
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export interface LinkProps
|
|
3
|
-
/** All properties available to an `<a>` element are available. See [anchor element documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes).*/
|
|
4
|
-
extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
|
|
2
|
+
export interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
|
|
5
3
|
/** The destination URL that the link points to. This is the `href` attribute of the underlying `<a>` element. */
|
|
6
4
|
to: string;
|
|
7
5
|
/** Whether to update the state object or URL of the current history entry. Refer to the [history.replaceState documentation](https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState). */
|
|
@@ -12,7 +10,8 @@ export interface LinkProps
|
|
|
12
10
|
reloadDocument?: boolean;
|
|
13
11
|
}
|
|
14
12
|
/**
|
|
15
|
-
* The `Link` component
|
|
16
|
-
*
|
|
13
|
+
* The `Link` component is used to navigate between routes. Because it renders an underlying `<a>` element, all
|
|
14
|
+
* properties available to the `<a>` element are also available to the `Link` component.
|
|
15
|
+
* For more information, refer to the [`<a>` element documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes).
|
|
17
16
|
*/
|
|
18
17
|
export declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
|
-
import { useRouter } from '../../foundation/Router/
|
|
2
|
+
import { useRouter } from '../../foundation/Router/BrowserRouter.client';
|
|
3
3
|
import { createPath } from 'history';
|
|
4
|
-
import { useNavigate } from '../../
|
|
4
|
+
import { useNavigate } from '../../foundation/useNavigate/useNavigate';
|
|
5
5
|
/**
|
|
6
|
-
* The `Link` component
|
|
7
|
-
*
|
|
6
|
+
* The `Link` component is used to navigate between routes. Because it renders an underlying `<a>` element, all
|
|
7
|
+
* properties available to the `<a>` element are also available to the `Link` component.
|
|
8
|
+
* For more information, refer to the [`<a>` element documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes).
|
|
8
9
|
*/
|
|
9
10
|
export const Link = React.forwardRef(function Link(props, ref) {
|
|
10
11
|
const navigate = useNavigate();
|
|
@@ -4,7 +4,6 @@ import { useServerState } from '../../foundation/useServerState';
|
|
|
4
4
|
export default function LocalizationClientProvider({ localization, children, }) {
|
|
5
5
|
const { setServerState } = useServerState();
|
|
6
6
|
const [country, setCountry] = useState(localization.country);
|
|
7
|
-
const [availableCountries] = useState(localization.availableCountries);
|
|
8
7
|
const setter = useCallback((country) => {
|
|
9
8
|
setCountry(country);
|
|
10
9
|
setServerState('country', country);
|
|
@@ -13,8 +12,7 @@ export default function LocalizationClientProvider({ localization, children, })
|
|
|
13
12
|
return {
|
|
14
13
|
country,
|
|
15
14
|
setCountry: setter,
|
|
16
|
-
availableCountries,
|
|
17
15
|
};
|
|
18
|
-
}, [country, setter
|
|
16
|
+
}, [country, setter]);
|
|
19
17
|
return (React.createElement(LocalizationContext.Provider, { value: contextValue }, children));
|
|
20
18
|
}
|
|
@@ -2,7 +2,6 @@ import { LocalizationQuery } from './LocalizationQuery';
|
|
|
2
2
|
export declare type Localization = LocalizationQuery['localization'];
|
|
3
3
|
export interface LocalizationContextValue {
|
|
4
4
|
country?: Localization['country'];
|
|
5
|
-
availableCountries: Localization['availableCountries'];
|
|
6
5
|
setCountry(country: Localization['country']): void;
|
|
7
6
|
}
|
|
8
7
|
export declare const LocalizationContext: import("react").Context<LocalizationContextValue | null>;
|
|
@@ -12,9 +12,9 @@ export interface LocalizationProviderProps {
|
|
|
12
12
|
/**
|
|
13
13
|
* The `LocalizationProvider` component automatically queries the Storefront API's
|
|
14
14
|
* [`localization`](/api/storefront/reference/common-objects/queryroot) field
|
|
15
|
-
* for the `isoCode` and `name` of the `country` and
|
|
15
|
+
* for the `isoCode` and `name` of the `country` and keeps this information in a context.
|
|
16
16
|
*
|
|
17
|
-
* Any descendents of this provider can use the `useCountry`
|
|
17
|
+
* Any descendents of this provider can use the `useCountry` hook.
|
|
18
18
|
* The `isoCode` of the `country` can be used in the Storefront API's
|
|
19
19
|
* `@inContext` directive as the `country` value.
|
|
20
20
|
*/
|
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import LocalizationClientProvider from './LocalizationClientProvider.client';
|
|
3
3
|
import { useShopQuery } from '../../hooks/useShopQuery';
|
|
4
|
-
import { Localization } from '../../graphql/graphql-constants';
|
|
5
4
|
import { CacheDays } from '../../framework/CachingStrategy';
|
|
6
5
|
/**
|
|
7
6
|
* The `LocalizationProvider` component automatically queries the Storefront API's
|
|
8
7
|
* [`localization`](/api/storefront/reference/common-objects/queryroot) field
|
|
9
|
-
* for the `isoCode` and `name` of the `country` and
|
|
8
|
+
* for the `isoCode` and `name` of the `country` and keeps this information in a context.
|
|
10
9
|
*
|
|
11
|
-
* Any descendents of this provider can use the `useCountry`
|
|
10
|
+
* Any descendents of this provider can use the `useCountry` hook.
|
|
12
11
|
* The `isoCode` of the `country` can be used in the Storefront API's
|
|
13
12
|
* `@inContext` directive as the `country` value.
|
|
14
13
|
*/
|
|
15
14
|
export function LocalizationProvider(props) {
|
|
16
15
|
const { data: { localization }, } = useShopQuery({
|
|
17
|
-
query:
|
|
16
|
+
query: query,
|
|
18
17
|
cache: CacheDays(),
|
|
19
18
|
preload: props.preload,
|
|
20
19
|
});
|
|
21
20
|
return (React.createElement(LocalizationClientProvider, { localization: localization }, props.children));
|
|
22
21
|
}
|
|
22
|
+
const query = `query Localization {
|
|
23
|
+
localization {
|
|
24
|
+
country {
|
|
25
|
+
isoCode
|
|
26
|
+
name
|
|
27
|
+
currency {
|
|
28
|
+
isoCode
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
|
|
3
3
|
* Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
|
|
4
4
|
*/
|
|
5
|
-
import * as Types from '../../
|
|
5
|
+
import * as Types from '../../storefront-api-types';
|
|
6
6
|
export declare type LocalizationQueryVariables = Types.Exact<{
|
|
7
7
|
[key: string]: never;
|
|
8
8
|
}>;
|
|
@@ -19,12 +19,5 @@ export declare type LocalizationQuery = {
|
|
|
19
19
|
__typename?: 'Currency';
|
|
20
20
|
} & Pick<Types.Currency, 'isoCode'>;
|
|
21
21
|
};
|
|
22
|
-
availableCountries: Array<{
|
|
23
|
-
__typename?: 'Country';
|
|
24
|
-
} & Pick<Types.Country, 'isoCode' | 'name'> & {
|
|
25
|
-
currency: {
|
|
26
|
-
__typename?: 'Currency';
|
|
27
|
-
} & Pick<Types.Currency, 'isoCode'>;
|
|
28
|
-
}>;
|
|
29
22
|
};
|
|
30
23
|
};
|
|
@@ -2,10 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import { Image } from '../Image';
|
|
3
3
|
import { Video } from '../Video';
|
|
4
4
|
import { ExternalVideo } from '../ExternalVideo';
|
|
5
|
-
import type {
|
|
5
|
+
import type { MediaEdge as MediaEdgeType } from '../../storefront-api-types';
|
|
6
|
+
import type { PartialDeep } from 'type-fest';
|
|
6
7
|
export interface MediaFileProps {
|
|
7
|
-
/**
|
|
8
|
-
data:
|
|
8
|
+
/** An object with fields that correspond to the Storefront API's [Media object](/api/storefront/reference/products/media). */
|
|
9
|
+
data: PartialDeep<MediaEdgeType['node']>;
|
|
9
10
|
/** The options for the `Image`, `Video`, or `ExternalVideo` components. */
|
|
10
11
|
options?: React.ComponentProps<typeof Image>['options'] | React.ComponentProps<typeof Video>['options'] | React.ComponentProps<typeof ExternalVideo>['options'];
|
|
11
12
|
}
|
|
@@ -2,7 +2,7 @@ import { ElementType } from 'react';
|
|
|
2
2
|
import { Props } from '../types';
|
|
3
3
|
import { ParsedMetafield } from '../../types';
|
|
4
4
|
export interface MetafieldProps<TTag> {
|
|
5
|
-
/**
|
|
5
|
+
/** An object with fields that correspond to the Storefront API's [Metafield object](/api/storefront/reference/common-objects/metafield). */
|
|
6
6
|
data: ParsedMetafield;
|
|
7
7
|
/** An HTML tag to be rendered as the base element wrapper. The default value varies depending on [metafield.type](/apps/metafields/types). */
|
|
8
8
|
as?: TTag;
|
|
@@ -12,6 +12,6 @@ export interface MetafieldProps<TTag> {
|
|
|
12
12
|
* API's [Metafield object](/api/storefront/reference/common-objects/metafield).
|
|
13
13
|
*
|
|
14
14
|
* Renders a smart default of the
|
|
15
|
-
* Metafield's `value`. For more information, refer to the [Default
|
|
15
|
+
* Metafield's `value`. For more information, refer to the [Default output](#default-output) section.
|
|
16
16
|
*/
|
|
17
17
|
export declare function Metafield<TTag extends ElementType>(props: Props<TTag> & MetafieldProps<TTag>): JSX.Element | null;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useShop } from '../../foundation';
|
|
3
3
|
import { getMeasurementAsString } from '../../utilities';
|
|
4
|
-
import { RawHtml } from '../RawHtml';
|
|
5
4
|
import { Image } from '../Image';
|
|
6
5
|
/**
|
|
7
6
|
* The `Metafield` component renders the value of a Storefront
|
|
8
7
|
* API's [Metafield object](/api/storefront/reference/common-objects/metafield).
|
|
9
8
|
*
|
|
10
9
|
* Renders a smart default of the
|
|
11
|
-
* Metafield's `value`. For more information, refer to the [Default
|
|
10
|
+
* Metafield's `value`. For more information, refer to the [Default output](#default-output) section.
|
|
12
11
|
*/
|
|
13
12
|
export function Metafield(props) {
|
|
14
13
|
var _a;
|
|
@@ -38,10 +37,14 @@ export function Metafield(props) {
|
|
|
38
37
|
return (React.createElement(Wrapper, { ...passthroughProps }, data.value.value));
|
|
39
38
|
}
|
|
40
39
|
case 'single_line_text_field': {
|
|
41
|
-
|
|
40
|
+
const Wrapper = as !== null && as !== void 0 ? as : 'span';
|
|
41
|
+
return (React.createElement(Wrapper, { ...passthroughProps, dangerouslySetInnerHTML: { __html: data.value } }));
|
|
42
42
|
}
|
|
43
43
|
case 'multi_line_text_field': {
|
|
44
|
-
|
|
44
|
+
const Wrapper = as !== null && as !== void 0 ? as : 'div';
|
|
45
|
+
return (React.createElement(Wrapper, { ...passthroughProps, dangerouslySetInnerHTML: {
|
|
46
|
+
__html: data.value.split('\n').join('<br/>'),
|
|
47
|
+
} }));
|
|
45
48
|
}
|
|
46
49
|
case 'url':
|
|
47
50
|
return (React.createElement("a", { href: data.value, ...passthroughProps }, data.value));
|
|
@@ -51,7 +54,7 @@ export function Metafield(props) {
|
|
|
51
54
|
case 'file_reference': {
|
|
52
55
|
if (((_a = data.reference) === null || _a === void 0 ? void 0 : _a.__typename) === 'MediaImage') {
|
|
53
56
|
const ref = data.reference;
|
|
54
|
-
return ref.
|
|
57
|
+
return ref.image ? (React.createElement(Image, { data: ref.image, ...passthroughProps })) : null;
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
default: {
|