@shopify/hydrogen-react 2023.1.4 → 2023.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -201
- package/dist/browser-dev/AddToCartButton.mjs.map +1 -1
- package/dist/browser-dev/BaseButton.mjs.map +1 -1
- package/dist/browser-dev/BuyNowButton.mjs.map +1 -1
- package/dist/browser-dev/CartCheckoutButton.mjs.map +1 -1
- package/dist/browser-dev/CartCost.mjs.map +1 -1
- package/dist/browser-dev/CartLinePrice.mjs +3 -0
- package/dist/browser-dev/CartLinePrice.mjs.map +1 -1
- package/dist/browser-dev/CartLineProvider.mjs +4 -1
- package/dist/browser-dev/CartLineProvider.mjs.map +1 -1
- package/dist/browser-dev/CartLineQuantity.mjs +12 -0
- package/dist/browser-dev/CartLineQuantity.mjs.map +1 -0
- package/dist/browser-dev/CartLineQuantityAdjustButton.mjs +48 -0
- package/dist/browser-dev/CartLineQuantityAdjustButton.mjs.map +1 -0
- package/dist/browser-dev/CartProvider.mjs +3 -3
- package/dist/browser-dev/CartProvider.mjs.map +1 -1
- package/dist/browser-dev/ExternalVideo.mjs.map +1 -1
- package/dist/browser-dev/Image.mjs +1 -1
- package/dist/browser-dev/Image.mjs.map +1 -1
- package/dist/browser-dev/MediaFile.mjs.map +1 -1
- package/dist/browser-dev/ModelViewer.mjs.map +1 -1
- package/dist/browser-dev/Money.mjs.map +1 -1
- package/dist/browser-dev/ProductPrice.mjs.map +1 -1
- package/dist/browser-dev/ProductProvider.mjs.map +1 -1
- package/dist/browser-dev/ShopPayButton.mjs.map +1 -1
- package/dist/browser-dev/ShopifyProvider.mjs.map +1 -1
- package/dist/browser-dev/Video.mjs.map +1 -1
- package/dist/browser-dev/analytics.mjs.map +1 -1
- package/dist/browser-dev/cart-hooks.mjs +5 -2
- package/dist/browser-dev/cart-hooks.mjs.map +1 -1
- package/dist/browser-dev/cart-queries.mjs.map +1 -1
- package/dist/browser-dev/flatten-connection.mjs +1 -1
- package/dist/browser-dev/flatten-connection.mjs.map +1 -1
- package/dist/browser-dev/image-size.mjs.map +1 -1
- package/dist/browser-dev/index.mjs +4 -0
- package/dist/browser-dev/index.mjs.map +1 -1
- package/dist/browser-dev/load-script.mjs +3 -1
- package/dist/browser-dev/load-script.mjs.map +1 -1
- package/dist/browser-dev/parse-metafield.mjs.map +1 -1
- package/dist/browser-dev/storefront-client.mjs +9 -8
- package/dist/browser-dev/storefront-client.mjs.map +1 -1
- package/dist/browser-dev/useCartAPIStateMachine.mjs +9 -0
- package/dist/browser-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-dev/useCartActions.mjs.map +1 -1
- package/dist/browser-dev/useMoney.mjs +1 -0
- package/dist/browser-dev/useMoney.mjs.map +1 -1
- package/dist/browser-prod/AddToCartButton.mjs.map +1 -1
- package/dist/browser-prod/BaseButton.mjs.map +1 -1
- package/dist/browser-prod/BuyNowButton.mjs.map +1 -1
- package/dist/browser-prod/CartCheckoutButton.mjs.map +1 -1
- package/dist/browser-prod/CartCost.mjs.map +1 -1
- package/dist/browser-prod/CartLinePrice.mjs.map +1 -1
- package/dist/browser-prod/CartLineProvider.mjs +4 -1
- package/dist/browser-prod/CartLineProvider.mjs.map +1 -1
- package/dist/browser-prod/CartLineQuantity.mjs +12 -0
- package/dist/browser-prod/CartLineQuantity.mjs.map +1 -0
- package/dist/browser-prod/CartLineQuantityAdjustButton.mjs +48 -0
- package/dist/browser-prod/CartLineQuantityAdjustButton.mjs.map +1 -0
- package/dist/browser-prod/CartProvider.mjs +3 -3
- package/dist/browser-prod/CartProvider.mjs.map +1 -1
- package/dist/browser-prod/ExternalVideo.mjs.map +1 -1
- package/dist/browser-prod/Image.mjs +1 -1
- package/dist/browser-prod/Image.mjs.map +1 -1
- package/dist/browser-prod/MediaFile.mjs.map +1 -1
- package/dist/browser-prod/ModelViewer.mjs.map +1 -1
- package/dist/browser-prod/Money.mjs.map +1 -1
- package/dist/browser-prod/ProductPrice.mjs.map +1 -1
- package/dist/browser-prod/ProductProvider.mjs.map +1 -1
- package/dist/browser-prod/ShopPayButton.mjs.map +1 -1
- package/dist/browser-prod/ShopifyProvider.mjs.map +1 -1
- package/dist/browser-prod/Video.mjs.map +1 -1
- package/dist/browser-prod/analytics.mjs.map +1 -1
- package/dist/browser-prod/cart-hooks.mjs +5 -2
- package/dist/browser-prod/cart-hooks.mjs.map +1 -1
- package/dist/browser-prod/cart-queries.mjs.map +1 -1
- package/dist/browser-prod/flatten-connection.mjs +1 -1
- package/dist/browser-prod/flatten-connection.mjs.map +1 -1
- package/dist/browser-prod/image-size.mjs.map +1 -1
- package/dist/browser-prod/index.mjs +4 -0
- package/dist/browser-prod/index.mjs.map +1 -1
- package/dist/browser-prod/load-script.mjs +3 -1
- package/dist/browser-prod/load-script.mjs.map +1 -1
- package/dist/browser-prod/parse-metafield.mjs.map +1 -1
- package/dist/browser-prod/storefront-client.mjs +8 -7
- package/dist/browser-prod/storefront-client.mjs.map +1 -1
- package/dist/browser-prod/useCartAPIStateMachine.mjs +9 -0
- package/dist/browser-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-prod/useCartActions.mjs.map +1 -1
- package/dist/browser-prod/useMoney.mjs +1 -0
- package/dist/browser-prod/useMoney.mjs.map +1 -1
- package/dist/node-dev/AddToCartButton.js.map +1 -1
- package/dist/node-dev/AddToCartButton.mjs.map +1 -1
- package/dist/node-dev/BaseButton.js.map +1 -1
- package/dist/node-dev/BaseButton.mjs.map +1 -1
- package/dist/node-dev/BuyNowButton.js.map +1 -1
- package/dist/node-dev/BuyNowButton.mjs.map +1 -1
- package/dist/node-dev/CartCheckoutButton.js.map +1 -1
- package/dist/node-dev/CartCheckoutButton.mjs.map +1 -1
- package/dist/node-dev/CartCost.js.map +1 -1
- package/dist/node-dev/CartCost.mjs.map +1 -1
- package/dist/node-dev/CartLinePrice.js +3 -0
- package/dist/node-dev/CartLinePrice.js.map +1 -1
- package/dist/node-dev/CartLinePrice.mjs +3 -0
- package/dist/node-dev/CartLinePrice.mjs.map +1 -1
- package/dist/node-dev/CartLineProvider.js +4 -1
- package/dist/node-dev/CartLineProvider.js.map +1 -1
- package/dist/node-dev/CartLineProvider.mjs +4 -1
- package/dist/node-dev/CartLineProvider.mjs.map +1 -1
- package/dist/node-dev/CartLineQuantity.js +12 -0
- package/dist/node-dev/CartLineQuantity.js.map +1 -0
- package/dist/node-dev/CartLineQuantity.mjs +12 -0
- package/dist/node-dev/CartLineQuantity.mjs.map +1 -0
- package/dist/node-dev/CartLineQuantityAdjustButton.js +48 -0
- package/dist/node-dev/CartLineQuantityAdjustButton.js.map +1 -0
- package/dist/node-dev/CartLineQuantityAdjustButton.mjs +48 -0
- package/dist/node-dev/CartLineQuantityAdjustButton.mjs.map +1 -0
- package/dist/node-dev/CartProvider.js +3 -3
- package/dist/node-dev/CartProvider.js.map +1 -1
- package/dist/node-dev/CartProvider.mjs +3 -3
- package/dist/node-dev/CartProvider.mjs.map +1 -1
- package/dist/node-dev/ExternalVideo.js.map +1 -1
- package/dist/node-dev/ExternalVideo.mjs.map +1 -1
- package/dist/node-dev/Image.js +1 -1
- package/dist/node-dev/Image.js.map +1 -1
- package/dist/node-dev/Image.mjs +1 -1
- package/dist/node-dev/Image.mjs.map +1 -1
- package/dist/node-dev/MediaFile.js.map +1 -1
- package/dist/node-dev/MediaFile.mjs.map +1 -1
- package/dist/node-dev/ModelViewer.js.map +1 -1
- package/dist/node-dev/ModelViewer.mjs.map +1 -1
- package/dist/node-dev/Money.js.map +1 -1
- package/dist/node-dev/Money.mjs.map +1 -1
- package/dist/node-dev/ProductPrice.js.map +1 -1
- package/dist/node-dev/ProductPrice.mjs.map +1 -1
- package/dist/node-dev/ProductProvider.js.map +1 -1
- package/dist/node-dev/ProductProvider.mjs.map +1 -1
- package/dist/node-dev/ShopPayButton.js.map +1 -1
- package/dist/node-dev/ShopPayButton.mjs.map +1 -1
- package/dist/node-dev/ShopifyProvider.js.map +1 -1
- package/dist/node-dev/ShopifyProvider.mjs.map +1 -1
- package/dist/node-dev/Video.js.map +1 -1
- package/dist/node-dev/Video.mjs.map +1 -1
- package/dist/node-dev/analytics.js.map +1 -1
- package/dist/node-dev/analytics.mjs.map +1 -1
- package/dist/node-dev/cart-hooks.js +5 -2
- package/dist/node-dev/cart-hooks.js.map +1 -1
- package/dist/node-dev/cart-hooks.mjs +5 -2
- package/dist/node-dev/cart-hooks.mjs.map +1 -1
- package/dist/node-dev/cart-queries.js.map +1 -1
- package/dist/node-dev/cart-queries.mjs.map +1 -1
- package/dist/node-dev/flatten-connection.js +1 -1
- package/dist/node-dev/flatten-connection.js.map +1 -1
- package/dist/node-dev/flatten-connection.mjs +1 -1
- package/dist/node-dev/flatten-connection.mjs.map +1 -1
- package/dist/node-dev/image-size.js.map +1 -1
- package/dist/node-dev/image-size.mjs.map +1 -1
- package/dist/node-dev/index.js +4 -0
- package/dist/node-dev/index.js.map +1 -1
- package/dist/node-dev/index.mjs +4 -0
- package/dist/node-dev/index.mjs.map +1 -1
- package/dist/node-dev/load-script.js +3 -1
- package/dist/node-dev/load-script.js.map +1 -1
- package/dist/node-dev/load-script.mjs +3 -1
- package/dist/node-dev/load-script.mjs.map +1 -1
- package/dist/node-dev/parse-metafield.js.map +1 -1
- package/dist/node-dev/parse-metafield.mjs.map +1 -1
- package/dist/node-dev/storefront-client.js +9 -8
- package/dist/node-dev/storefront-client.js.map +1 -1
- package/dist/node-dev/storefront-client.mjs +9 -8
- package/dist/node-dev/storefront-client.mjs.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.js +9 -0
- package/dist/node-dev/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.mjs +9 -0
- package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-dev/useCartActions.js.map +1 -1
- package/dist/node-dev/useCartActions.mjs.map +1 -1
- package/dist/node-dev/useMoney.js +1 -0
- package/dist/node-dev/useMoney.js.map +1 -1
- package/dist/node-dev/useMoney.mjs +1 -0
- package/dist/node-dev/useMoney.mjs.map +1 -1
- package/dist/node-prod/AddToCartButton.js.map +1 -1
- package/dist/node-prod/AddToCartButton.mjs.map +1 -1
- package/dist/node-prod/BaseButton.js.map +1 -1
- package/dist/node-prod/BaseButton.mjs.map +1 -1
- package/dist/node-prod/BuyNowButton.js.map +1 -1
- package/dist/node-prod/BuyNowButton.mjs.map +1 -1
- package/dist/node-prod/CartCheckoutButton.js.map +1 -1
- package/dist/node-prod/CartCheckoutButton.mjs.map +1 -1
- package/dist/node-prod/CartCost.js.map +1 -1
- package/dist/node-prod/CartCost.mjs.map +1 -1
- package/dist/node-prod/CartLinePrice.js.map +1 -1
- package/dist/node-prod/CartLinePrice.mjs.map +1 -1
- package/dist/node-prod/CartLineProvider.js +4 -1
- package/dist/node-prod/CartLineProvider.js.map +1 -1
- package/dist/node-prod/CartLineProvider.mjs +4 -1
- package/dist/node-prod/CartLineProvider.mjs.map +1 -1
- package/dist/node-prod/CartLineQuantity.js +12 -0
- package/dist/node-prod/CartLineQuantity.js.map +1 -0
- package/dist/node-prod/CartLineQuantity.mjs +12 -0
- package/dist/node-prod/CartLineQuantity.mjs.map +1 -0
- package/dist/node-prod/CartLineQuantityAdjustButton.js +48 -0
- package/dist/node-prod/CartLineQuantityAdjustButton.js.map +1 -0
- package/dist/node-prod/CartLineQuantityAdjustButton.mjs +48 -0
- package/dist/node-prod/CartLineQuantityAdjustButton.mjs.map +1 -0
- package/dist/node-prod/CartProvider.js +3 -3
- package/dist/node-prod/CartProvider.js.map +1 -1
- package/dist/node-prod/CartProvider.mjs +3 -3
- package/dist/node-prod/CartProvider.mjs.map +1 -1
- package/dist/node-prod/ExternalVideo.js.map +1 -1
- package/dist/node-prod/ExternalVideo.mjs.map +1 -1
- package/dist/node-prod/Image.js +1 -1
- package/dist/node-prod/Image.js.map +1 -1
- package/dist/node-prod/Image.mjs +1 -1
- package/dist/node-prod/Image.mjs.map +1 -1
- package/dist/node-prod/MediaFile.js.map +1 -1
- package/dist/node-prod/MediaFile.mjs.map +1 -1
- package/dist/node-prod/ModelViewer.js.map +1 -1
- package/dist/node-prod/ModelViewer.mjs.map +1 -1
- package/dist/node-prod/Money.js.map +1 -1
- package/dist/node-prod/Money.mjs.map +1 -1
- package/dist/node-prod/ProductPrice.js.map +1 -1
- package/dist/node-prod/ProductPrice.mjs.map +1 -1
- package/dist/node-prod/ProductProvider.js.map +1 -1
- package/dist/node-prod/ProductProvider.mjs.map +1 -1
- package/dist/node-prod/ShopPayButton.js.map +1 -1
- package/dist/node-prod/ShopPayButton.mjs.map +1 -1
- package/dist/node-prod/ShopifyProvider.js.map +1 -1
- package/dist/node-prod/ShopifyProvider.mjs.map +1 -1
- package/dist/node-prod/Video.js.map +1 -1
- package/dist/node-prod/Video.mjs.map +1 -1
- package/dist/node-prod/analytics.js.map +1 -1
- package/dist/node-prod/analytics.mjs.map +1 -1
- package/dist/node-prod/cart-hooks.js +5 -2
- package/dist/node-prod/cart-hooks.js.map +1 -1
- package/dist/node-prod/cart-hooks.mjs +5 -2
- package/dist/node-prod/cart-hooks.mjs.map +1 -1
- package/dist/node-prod/cart-queries.js.map +1 -1
- package/dist/node-prod/cart-queries.mjs.map +1 -1
- package/dist/node-prod/flatten-connection.js +1 -1
- package/dist/node-prod/flatten-connection.js.map +1 -1
- package/dist/node-prod/flatten-connection.mjs +1 -1
- package/dist/node-prod/flatten-connection.mjs.map +1 -1
- package/dist/node-prod/image-size.js.map +1 -1
- package/dist/node-prod/image-size.mjs.map +1 -1
- package/dist/node-prod/index.js +4 -0
- package/dist/node-prod/index.js.map +1 -1
- package/dist/node-prod/index.mjs +4 -0
- package/dist/node-prod/index.mjs.map +1 -1
- package/dist/node-prod/load-script.js +3 -1
- package/dist/node-prod/load-script.js.map +1 -1
- package/dist/node-prod/load-script.mjs +3 -1
- package/dist/node-prod/load-script.mjs.map +1 -1
- package/dist/node-prod/parse-metafield.js.map +1 -1
- package/dist/node-prod/parse-metafield.mjs.map +1 -1
- package/dist/node-prod/storefront-client.js +8 -7
- package/dist/node-prod/storefront-client.js.map +1 -1
- package/dist/node-prod/storefront-client.mjs +8 -7
- package/dist/node-prod/storefront-client.mjs.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.js +9 -0
- package/dist/node-prod/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.mjs +9 -0
- package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-prod/useCartActions.js.map +1 -1
- package/dist/node-prod/useCartActions.mjs.map +1 -1
- package/dist/node-prod/useMoney.js +1 -0
- package/dist/node-prod/useMoney.js.map +1 -1
- package/dist/node-prod/useMoney.mjs +1 -0
- package/dist/node-prod/useMoney.mjs.map +1 -1
- package/dist/types/AddToCartButton.d.ts +4 -1
- package/dist/types/BaseButton.d.ts +2 -2
- package/dist/types/BuyNowButton.d.ts +3 -1
- package/dist/types/CartCheckoutButton.d.ts +3 -1
- package/dist/types/CartCost.d.ts +3 -1
- package/dist/types/CartLinePrice.d.ts +15 -1
- package/dist/types/CartLineProvider.d.ts +11 -5
- package/dist/types/CartLineQuantity.d.ts +13 -0
- package/dist/types/CartLineQuantityAdjustButton.d.ts +13 -0
- package/dist/types/CartProvider.d.ts +1 -1
- package/dist/types/ExternalVideo.d.ts +2 -2
- package/dist/types/Money.d.ts +2 -3
- package/dist/types/ProductPrice.d.ts +3 -1
- package/dist/types/ShopifyProvider.d.ts +9 -6
- package/dist/types/analytics-types.d.ts +60 -11
- package/dist/types/flatten-connection.d.ts +4 -0
- package/dist/types/image-size.d.ts +1 -1
- package/dist/types/index.d.cts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/parse-metafield.d.ts +1 -1
- package/dist/types/storefront-api-response.types.d.ts +1 -1
- package/dist/types/storefront-api-types.d.ts +2 -1
- package/dist/types/storefront-client.d.ts +1 -1
- package/dist/umd/hydrogen-react.dev.js +271 -346
- package/dist/umd/hydrogen-react.dev.js.map +1 -1
- package/dist/umd/hydrogen-react.prod.js +15 -31
- package/dist/umd/hydrogen-react.prod.js.map +1 -1
- package/package.json +32 -22
- package/storefront.schema.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Money } from './Money.js';
|
|
1
|
+
import { Money, type MoneyPropsBase } from './Money.js';
|
|
2
2
|
import { CartLine } from './storefront-api-types.js';
|
|
3
3
|
import { PartialDeep } from 'type-fest';
|
|
4
4
|
interface CartLinePricePropsBase {
|
|
@@ -11,7 +11,21 @@ interface CartLinePricePropsBase {
|
|
|
11
11
|
}
|
|
12
12
|
type CartLinePriceProps = Omit<React.ComponentProps<typeof Money>, 'data'> & CartLinePricePropsBase;
|
|
13
13
|
/**
|
|
14
|
+
* @deprecated Use `Money` instead. To migrate, use the `priceType` prop that matches the corresponding property on the `CartLine` object:
|
|
15
|
+
* - `regular`: `cartLine.cost.totalAmount`
|
|
16
|
+
* - `compareAt`: `cartLine.cost.compareAtAmountPerQuantity`
|
|
17
|
+
*
|
|
18
|
+
* For example:
|
|
19
|
+
* ```
|
|
20
|
+
* // before
|
|
21
|
+
* <CartLinePrice data={cartLine} priceType="regular" />
|
|
22
|
+
* // after
|
|
23
|
+
* <Money data={cartLine.cost.totalAmount} />
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
14
26
|
* The `CartLinePrice` component renders a `Money` component for the cart line merchandise's price or compare at price.
|
|
15
27
|
*/
|
|
16
28
|
export declare function CartLinePrice(props: CartLinePriceProps): JSX.Element | null;
|
|
29
|
+
export interface CartLinePricePropsForDocs<AsType extends React.ElementType = 'div'> extends Omit<MoneyPropsBase<AsType>, 'data'>, CartLinePricePropsBase {
|
|
30
|
+
}
|
|
17
31
|
export {};
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import type { CartLine } from './storefront-api-types.js';
|
|
3
|
-
|
|
3
|
+
import type { PartialDeep } from 'type-fest';
|
|
4
|
+
type CartLinePartialDeep = PartialDeep<CartLine, {
|
|
5
|
+
recurseIntoArrays: true;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const CartLineContext: import("react").Context<import("type-fest/source/partial-deep.js").PartialObjectDeep<CartLine, {
|
|
8
|
+
recurseIntoArrays: true;
|
|
9
|
+
}> | null>;
|
|
4
10
|
/**
|
|
5
|
-
* The `useCartLine` hook provides access to the
|
|
11
|
+
* The `useCartLine` hook provides access to the [CartLine object](https://shopify.dev/api/storefront/unstable/objects/cartline) from the Storefront API. It must be a descendent of a `CartProvider` component.
|
|
6
12
|
*/
|
|
7
|
-
export declare function useCartLine():
|
|
13
|
+
export declare function useCartLine(): CartLinePartialDeep;
|
|
8
14
|
type CartLineProviderProps = {
|
|
9
15
|
/** Any `ReactNode` elements. */
|
|
10
16
|
children: ReactNode;
|
|
11
17
|
/** A cart line object. */
|
|
12
|
-
line:
|
|
18
|
+
line: CartLinePartialDeep;
|
|
13
19
|
};
|
|
14
20
|
/**
|
|
15
21
|
* The `CartLineProvider` component creates a context for using a cart line.
|
|
16
22
|
*/
|
|
17
|
-
export declare function CartLineProvider({ children, line }: CartLineProviderProps): JSX.Element;
|
|
23
|
+
export declare function CartLineProvider({ children, line, }: CartLineProviderProps): JSX.Element;
|
|
18
24
|
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ElementType } from 'react';
|
|
2
|
+
interface CartLineQuantityBaseProps<ComponentGeneric extends ElementType = 'span'> {
|
|
3
|
+
/** An HTML tag or React Component to be rendered as the base element wrapper. The default is `span`. */
|
|
4
|
+
as?: ComponentGeneric;
|
|
5
|
+
}
|
|
6
|
+
export type CartLineQuantityProps<ComponentGeneric extends ElementType> = CartLineQuantityBaseProps<ComponentGeneric> & Omit<ComponentPropsWithoutRef<ComponentGeneric>, keyof CartLineQuantityBaseProps<ComponentGeneric>>;
|
|
7
|
+
/**
|
|
8
|
+
* The `<CartLineQuantity/>` component renders a `span` (or another element / component that can be customized by the `as` prop) with the cart line's quantity.
|
|
9
|
+
*
|
|
10
|
+
* It must be a descendent of a `<CartLineProvider/>` component, and uses the `useCartLine()` hook internally.
|
|
11
|
+
*/
|
|
12
|
+
export declare function CartLineQuantity<ComponentGeneric extends ElementType = 'span'>(props: CartLineQuantityProps<ComponentGeneric>): JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type BaseButtonProps } from './BaseButton.js';
|
|
2
|
+
interface CartLineQuantityAdjustButtonBaseProps {
|
|
3
|
+
/** The adjustment for a cart line's quantity. Valid values: `increase` (default), `decrease`, or `remove`. */
|
|
4
|
+
adjust?: 'increase' | 'decrease' | 'remove';
|
|
5
|
+
}
|
|
6
|
+
type CartLineQuantityAdjustButtonProps<AsType extends React.ElementType = 'button'> = BaseButtonProps<AsType> & CartLineQuantityAdjustButtonBaseProps;
|
|
7
|
+
/**
|
|
8
|
+
* The `<CartLineQuantityAdjustButton />` component renders a button that adjusts the cart line's quantity when pressed.
|
|
9
|
+
*
|
|
10
|
+
* It must be a descendent of `<CartLineProvider/>` and `<CartProvider/>`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function CartLineQuantityAdjustButton<AsType extends React.ElementType = 'button'>(props: CartLineQuantityAdjustButtonProps<AsType>): JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -66,5 +66,5 @@ export declare function CartProvider({ children, numCartLines, onCreate, onLineA
|
|
|
66
66
|
/** Check for storage availability funciton obtained from
|
|
67
67
|
* https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
|
|
68
68
|
*/
|
|
69
|
-
export declare function storageAvailable(type: 'localStorage' | 'sessionStorage'): boolean
|
|
69
|
+
export declare function storageAvailable(type: 'localStorage' | 'sessionStorage'): boolean;
|
|
70
70
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ExternalVideo as ExternalVideoType } from './storefront-api-types.js';
|
|
2
2
|
import type { PartialDeep } from 'type-fest';
|
|
3
|
-
interface
|
|
3
|
+
interface ExternalVideoBaseProps {
|
|
4
4
|
/**
|
|
5
5
|
* An object with fields that correspond to the Storefront API's [ExternalVideo object](https://shopify.dev/api/storefront/reference/products/externalvideo).
|
|
6
6
|
*/
|
|
@@ -13,7 +13,7 @@ interface BaseProps {
|
|
|
13
13
|
*/
|
|
14
14
|
options?: YouTube | Vimeo;
|
|
15
15
|
}
|
|
16
|
-
export type ExternalVideoProps = Omit<JSX.IntrinsicElements['iframe'], 'src'> &
|
|
16
|
+
export type ExternalVideoProps = Omit<JSX.IntrinsicElements['iframe'], 'src'> & ExternalVideoBaseProps;
|
|
17
17
|
/**
|
|
18
18
|
* The `ExternalVideo` component renders an embedded video for the Storefront
|
|
19
19
|
* API's [ExternalVideo object](https://shopify.dev/api/storefront/reference/products/externalvideo).
|
package/dist/types/Money.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import type { MoneyV2, UnitPriceMeasurement } from './storefront-api-types.js';
|
|
3
3
|
import type { PartialDeep } from 'type-fest';
|
|
4
|
-
interface
|
|
4
|
+
export interface MoneyPropsBase<ComponentGeneric extends React.ElementType> {
|
|
5
5
|
/** An HTML tag or React Component to be rendered as the base element wrapper. The default is `div`. */
|
|
6
6
|
as?: ComponentGeneric;
|
|
7
7
|
/** An object with fields that correspond to the Storefront API's [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2). */
|
|
@@ -19,11 +19,10 @@ interface CustomProps<ComponentGeneric extends React.ElementType> {
|
|
|
19
19
|
/** Customizes the separator between the money output and the measurement output. Used with the `measurement` prop. Defaults to `'/'`. */
|
|
20
20
|
measurementSeparator?: ReactNode;
|
|
21
21
|
}
|
|
22
|
-
export type MoneyProps<ComponentGeneric extends React.ElementType> =
|
|
22
|
+
export type MoneyProps<ComponentGeneric extends React.ElementType> = MoneyPropsBase<ComponentGeneric> & Omit<React.ComponentPropsWithoutRef<ComponentGeneric>, keyof MoneyPropsBase<ComponentGeneric>>;
|
|
23
23
|
/**
|
|
24
24
|
* The `Money` component renders a string of the Storefront API's
|
|
25
25
|
* [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) according to the
|
|
26
26
|
* `locale` in the `ShopifyProvider` component.
|
|
27
27
|
*/
|
|
28
28
|
export declare function Money<ComponentGeneric extends React.ElementType = 'div'>({ data, as, withoutCurrency, withoutTrailingZeros, measurement, measurementSeparator, ...passthroughProps }: MoneyProps<ComponentGeneric>): JSX.Element;
|
|
29
|
-
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Product } from './storefront-api-types.js';
|
|
2
|
-
import { type MoneyProps } from './Money.js';
|
|
2
|
+
import { type MoneyProps, type MoneyPropsBase } from './Money.js';
|
|
3
3
|
import type { PartialDeep } from 'type-fest';
|
|
4
4
|
export interface ProductPriceProps {
|
|
5
5
|
/** A Storefront API [Product object](https://shopify.dev/api/storefront/reference/products/product). */
|
|
@@ -18,3 +18,5 @@ export interface ProductPriceProps {
|
|
|
18
18
|
* [`priceRange`](https://shopify.dev/api/storefront/reference/products/productpricerange)'s `maxVariantPrice` or `minVariantPrice`, for either the regular price or compare at price range.
|
|
19
19
|
*/
|
|
20
20
|
export declare function ProductPrice<ComponentGeneric extends React.ElementType>(props: ProductPriceProps & Omit<MoneyProps<ComponentGeneric>, 'data' | 'measurement'>): JSX.Element | null;
|
|
21
|
+
export interface ProductPricePropsForDocs<AsType extends React.ElementType = 'div'> extends Omit<MoneyPropsBase<AsType>, 'data' | 'measurement'>, ProductPriceProps {
|
|
22
|
+
}
|
|
@@ -8,10 +8,7 @@ export declare function ShopifyProvider({ children, ...shopifyConfig }: ShopifyP
|
|
|
8
8
|
* Provides access to the `shopifyConfig` prop of `<ShopifyProvider/>`. Must be a descendent of `<ShopifyProvider/>`.
|
|
9
9
|
*/
|
|
10
10
|
export declare function useShop(): ShopifyContextValue;
|
|
11
|
-
|
|
12
|
-
* Shopify-specific values that are used in various Hydrogen React components and hooks.
|
|
13
|
-
*/
|
|
14
|
-
export type ShopifyProviderProps = {
|
|
11
|
+
export interface ShopifyProviderBase {
|
|
15
12
|
/** The globally-unique identifier for the Shop */
|
|
16
13
|
storefrontId?: string;
|
|
17
14
|
/** The full domain of your Shopify storefront URL (eg: the complete string of `{subdomain}.myshopify.com`). */
|
|
@@ -28,10 +25,16 @@ export type ShopifyProviderProps = {
|
|
|
28
25
|
* `ISO 369` language codes supported by Shopify.
|
|
29
26
|
*/
|
|
30
27
|
languageIsoCode: LanguageCode;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Shopify-specific values that are used in various Hydrogen React components and hooks.
|
|
31
|
+
*/
|
|
32
|
+
export interface ShopifyProviderProps extends ShopifyProviderBase {
|
|
31
33
|
/** React children to render. */
|
|
32
34
|
children?: ReactNode;
|
|
33
|
-
}
|
|
34
|
-
export
|
|
35
|
+
}
|
|
36
|
+
export interface ShopifyContextValue extends ShopifyProviderBase, ShopifyContextReturn {
|
|
37
|
+
}
|
|
35
38
|
type ShopifyContextReturn = {
|
|
36
39
|
/**
|
|
37
40
|
* Creates the fully-qualified URL to your store's GraphQL endpoint.
|
|
@@ -2,36 +2,85 @@ import type { CurrencyCode, LanguageCode, Product, ProductVariant } from './stor
|
|
|
2
2
|
import { AnalyticsEventName, ShopifySalesChannel } from './analytics-constants.js';
|
|
3
3
|
import { SHOPIFY_Y, SHOPIFY_S } from './cart-constants.js';
|
|
4
4
|
export type ClientBrowserParameters = {
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Shopify unique user token: Value of `_shopify_y` cookie.
|
|
7
|
+
*
|
|
8
|
+
* Use `getClientBrowserParameters()` to collect this value.
|
|
9
|
+
**/
|
|
6
10
|
uniqueToken: string;
|
|
7
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Shopify session token: Value of `_shopify_s` cookie.
|
|
13
|
+
*
|
|
14
|
+
* Use `getClientBrowserParameters()` to collect this value.
|
|
15
|
+
**/
|
|
8
16
|
visitToken: string;
|
|
9
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Value of `window.location.href`.
|
|
19
|
+
*
|
|
20
|
+
* Use `getClientBrowserParameters()` to collect this value.
|
|
21
|
+
**/
|
|
10
22
|
url: string;
|
|
11
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Value of `window.location.pathname`.
|
|
25
|
+
*
|
|
26
|
+
* Use `getClientBrowserParameters()` to collect this value.
|
|
27
|
+
**/
|
|
12
28
|
path: string;
|
|
13
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Value of `window.location.search`.
|
|
31
|
+
*
|
|
32
|
+
* Use `getClientBrowserParameters()` to collect this value.
|
|
33
|
+
**/
|
|
14
34
|
search: string;
|
|
15
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Value of `window.location.referrer`.
|
|
37
|
+
*
|
|
38
|
+
* Use `getClientBrowserParameters()` to collect this value.
|
|
39
|
+
**/
|
|
16
40
|
referrer: string;
|
|
17
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Value of `document.title`.
|
|
43
|
+
*
|
|
44
|
+
* Use `getClientBrowserParameters()` to collect this value.
|
|
45
|
+
**/
|
|
18
46
|
title: string;
|
|
19
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Value of `navigator.userAgent`.
|
|
49
|
+
*
|
|
50
|
+
* Use `getClientBrowserParameters()` to collect this value.
|
|
51
|
+
**/
|
|
20
52
|
userAgent: string;
|
|
21
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Navigation type: `'navigate' | 'reload' | 'back_forward' | 'prerender' | 'unknown'`.
|
|
55
|
+
*
|
|
56
|
+
* Use `getClientBrowserParameters()` to collect this value.
|
|
57
|
+
**/
|
|
22
58
|
navigationType: string;
|
|
23
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Navigation api: `'PerformanceNavigationTiming' | 'performance.navigation'`.
|
|
61
|
+
*
|
|
62
|
+
* Use `getClientBrowserParameters()` to collect this value.
|
|
63
|
+
**/
|
|
24
64
|
navigationApi: string;
|
|
25
65
|
};
|
|
26
66
|
export type ShopifyAnalyticsProduct = {
|
|
67
|
+
/** Product id in the form of `gid://shopify/Product/<id>`. */
|
|
27
68
|
productGid: Product['id'];
|
|
69
|
+
/** Variant id in the form of `gid://shopify/ProductVariant/<id>`. */
|
|
28
70
|
variantGid?: ProductVariant['id'];
|
|
71
|
+
/** Product name. */
|
|
29
72
|
name: Product['title'];
|
|
73
|
+
/** Variant name. */
|
|
30
74
|
variantName?: ProductVariant['title'];
|
|
75
|
+
/** Product brand or vendor. */
|
|
31
76
|
brand: Product['vendor'];
|
|
77
|
+
/** Product category or type. */
|
|
32
78
|
category?: Product['productType'];
|
|
79
|
+
/** Product price. */
|
|
33
80
|
price: ProductVariant['price']['amount'];
|
|
81
|
+
/** Product sku. */
|
|
34
82
|
sku?: ProductVariant['sku'];
|
|
83
|
+
/** Quantity of the product in this event. */
|
|
35
84
|
quantity?: number;
|
|
36
85
|
};
|
|
37
86
|
type ShopifyAnalyticsBase = {
|
|
@@ -51,7 +100,7 @@ type ShopifyAnalyticsBase = {
|
|
|
51
100
|
customerId?: string;
|
|
52
101
|
/** Total value of products. */
|
|
53
102
|
totalValue?: number;
|
|
54
|
-
/**
|
|
103
|
+
/** Product list. */
|
|
55
104
|
products?: ShopifyAnalyticsProduct[];
|
|
56
105
|
};
|
|
57
106
|
export type ShopifySalesChannels = keyof typeof ShopifySalesChannel;
|
|
@@ -36,4 +36,8 @@ type ConnectionEdges = {
|
|
|
36
36
|
type ConnectionNodes = {
|
|
37
37
|
nodes: Array<unknown>;
|
|
38
38
|
};
|
|
39
|
+
export interface ConnectionGenericForDoc {
|
|
40
|
+
connection?: ConnectionEdges | ConnectionNodes;
|
|
41
|
+
}
|
|
42
|
+
export type FlattenConnectionReturnForDoc = Array<unknown>;
|
|
39
43
|
export {};
|
|
@@ -6,7 +6,7 @@ export declare const IMG_SRC_SET_SIZES: number[];
|
|
|
6
6
|
* Adds image size parameters to an image URL hosted by Shopify's CDN
|
|
7
7
|
*/
|
|
8
8
|
export declare function addImageSizeParametersToUrl({ src, width, height, crop, scale, }: ShopifyLoaderParams): string;
|
|
9
|
-
export declare function shopifyImageLoader(params: ShopifyLoaderParams):
|
|
9
|
+
export declare function shopifyImageLoader(params: ShopifyLoaderParams): ReturnType<typeof addImageSizeParametersToUrl>;
|
|
10
10
|
type HtmlImageProps = React.ImgHTMLAttributes<HTMLImageElement>;
|
|
11
11
|
export type GetShopifyImageDimensionsProps = {
|
|
12
12
|
data: Pick<PartialDeep<ImageType, {
|
package/dist/types/index.d.cts
CHANGED
|
@@ -8,6 +8,8 @@ export { CartCheckoutButton } from './CartCheckoutButton.js';
|
|
|
8
8
|
export { CartCost } from './CartCost.js';
|
|
9
9
|
export { CartLinePrice } from './CartLinePrice.js';
|
|
10
10
|
export { CartLineProvider, useCartLine } from './CartLineProvider.js';
|
|
11
|
+
export { CartLineQuantity } from './CartLineQuantity.js';
|
|
12
|
+
export { CartLineQuantityAdjustButton } from './CartLineQuantityAdjustButton.js';
|
|
11
13
|
export { CartProvider, useCart } from './CartProvider.js';
|
|
12
14
|
export { storefrontApiCustomScalars } from './codegen.helpers.js';
|
|
13
15
|
export { getShopifyCookies } from './cookies-utils.js';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export { CartCheckoutButton } from './CartCheckoutButton.js';
|
|
|
8
8
|
export { CartCost } from './CartCost.js';
|
|
9
9
|
export { CartLinePrice } from './CartLinePrice.js';
|
|
10
10
|
export { CartLineProvider, useCartLine } from './CartLineProvider.js';
|
|
11
|
+
export { CartLineQuantity } from './CartLineQuantity.js';
|
|
12
|
+
export { CartLineQuantityAdjustButton } from './CartLineQuantityAdjustButton.js';
|
|
11
13
|
export { CartProvider, useCart } from './CartProvider.js';
|
|
12
14
|
export { storefrontApiCustomScalars } from './codegen.helpers.js';
|
|
13
15
|
export { getShopifyCookies } from './cookies-utils.js';
|
|
@@ -15,7 +15,7 @@ export declare function parseMetafield<ReturnGeneric>(metafield: PartialDeep<Met
|
|
|
15
15
|
/**
|
|
16
16
|
* Parses a JSON string while preventing prototype injection attacks.
|
|
17
17
|
*/
|
|
18
|
-
export declare function parseJSON(json: string):
|
|
18
|
+
export declare function parseJSON(json: string): unknown;
|
|
19
19
|
export declare const allMetafieldTypesArray: readonly ["boolean", "collection_reference", "color", "date", "date_time", "dimension", "file_reference", "json", "money", "multi_line_text_field", "number_decimal", "number_integer", "page_reference", "product_reference", "rating", "single_line_text_field", "url", "variant_reference", "volume", "weight", "list.collection_reference", "list.color", "list.date", "list.date_time", "list.dimension", "list.file_reference", "list.number_integer", "list.number_decimal", "list.page_reference", "list.product_reference", "list.rating", "list.single_line_text_field", "list.url", "list.variant_reference", "list.volume", "list.weight"];
|
|
20
20
|
/** A union of all the supported `metafield.type`s */
|
|
21
21
|
export type MetafieldTypeTypes = (typeof allMetafieldTypesArray)[number];
|
|
@@ -9,7 +9,7 @@ type StorefrontApiExtensions = {
|
|
|
9
9
|
* Shows error codes common to Shopify. Additional error codes may also be shown.
|
|
10
10
|
* https://shopify.dev/api/storefront#status_and_error_codes
|
|
11
11
|
*/
|
|
12
|
-
code?: 'THROTTLED' | 'ACCESS_DENIED' | 'SHOP_INACTIVE' | 'INTERNAL_SERVER_ERROR' | string;
|
|
12
|
+
code?: 'THROTTLED' | 'ACCESS_DENIED' | 'SHOP_INACTIVE' | 'INTERNAL_SERVER_ERROR' | (string & {});
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* The Storefront API can return a 200 OK response code when the query succeeds, and will populate the `data` property. The generic you pass in through type parameters will be the shape of the `data` object if successful. If you prefer a "deeply-partial" version of that generic object, consider using `StorefrontApiResponseOkPartial` instead.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE IS AUTO-GENERATED, DO NOT EDIT
|
|
3
3
|
* Based on Storefront API 2023-01
|
|
4
|
-
* If changes need to happen to the types defined in this file, then generally the Storefront API needs to update. After it's updated, you can run `
|
|
4
|
+
* If changes need to happen to the types defined in this file, then generally the Storefront API needs to update. After it's updated, you can run `npm run graphql-types`.
|
|
5
5
|
* Except custom Scalars, which are defined in the `codegen.ts` file
|
|
6
6
|
*/
|
|
7
7
|
/* eslint-disable */
|
|
@@ -5253,6 +5253,7 @@ export type PageEdge = {
|
|
|
5253
5253
|
/**
|
|
5254
5254
|
* Returns information about pagination in a connection, in accordance with the
|
|
5255
5255
|
* [Relay specification](https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo).
|
|
5256
|
+
* For more information, please read our [GraphQL Pagination Usage Guide](https://shopify.dev/api/usage/pagination-graphql).
|
|
5256
5257
|
*
|
|
5257
5258
|
*/
|
|
5258
5259
|
export type PageInfo = {
|
|
@@ -19,7 +19,7 @@ type StorefrontClientProps = {
|
|
|
19
19
|
*
|
|
20
20
|
* When used on the server, it is recommended to use the `privateStorefrontToken` prop. When used on the client, it is recommended to use the `publicStorefrontToken` prop.
|
|
21
21
|
*/
|
|
22
|
-
export declare function createStorefrontClient(
|
|
22
|
+
export declare function createStorefrontClient(props: StorefrontClientProps): StorefrontClientReturn;
|
|
23
23
|
export declare function getPublicTokenHeadersRaw(contentType: 'graphql' | 'json', storefrontApiVersion: string, accessToken: string): {
|
|
24
24
|
'content-type': string;
|
|
25
25
|
'X-SDK-Variant': string;
|