@shopify/hydrogen-react 2022.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +218 -0
- package/dist/dev/ExternalVideo.cjs +39 -0
- package/dist/dev/ExternalVideo.cjs.map +1 -0
- package/dist/dev/ExternalVideo.js +39 -0
- package/dist/dev/ExternalVideo.js.map +1 -0
- package/dist/dev/Image.cjs +104 -0
- package/dist/dev/Image.cjs.map +1 -0
- package/dist/dev/Image.js +104 -0
- package/dist/dev/Image.js.map +1 -0
- package/dist/dev/MediaFile.cjs +57 -0
- package/dist/dev/MediaFile.cjs.map +1 -0
- package/dist/dev/MediaFile.js +57 -0
- package/dist/dev/MediaFile.js.map +1 -0
- package/dist/dev/Metafield.cjs +295 -0
- package/dist/dev/Metafield.cjs.map +1 -0
- package/dist/dev/Metafield.js +295 -0
- package/dist/dev/Metafield.js.map +1 -0
- package/dist/dev/ModelViewer.cjs +145 -0
- package/dist/dev/ModelViewer.cjs.map +1 -0
- package/dist/dev/ModelViewer.js +145 -0
- package/dist/dev/ModelViewer.js.map +1 -0
- package/dist/dev/Money.cjs +40 -0
- package/dist/dev/Money.cjs.map +1 -0
- package/dist/dev/Money.js +40 -0
- package/dist/dev/Money.js.map +1 -0
- package/dist/dev/ProductPrice.cjs +61 -0
- package/dist/dev/ProductPrice.cjs.map +1 -0
- package/dist/dev/ProductPrice.js +61 -0
- package/dist/dev/ProductPrice.js.map +1 -0
- package/dist/dev/ProductProvider.cjs +161 -0
- package/dist/dev/ProductProvider.cjs.map +1 -0
- package/dist/dev/ProductProvider.js +161 -0
- package/dist/dev/ProductProvider.js.map +1 -0
- package/dist/dev/ShopPayButton.cjs +64 -0
- package/dist/dev/ShopPayButton.cjs.map +1 -0
- package/dist/dev/ShopPayButton.js +64 -0
- package/dist/dev/ShopPayButton.js.map +1 -0
- package/dist/dev/ShopifyProvider.cjs +46 -0
- package/dist/dev/ShopifyProvider.cjs.map +1 -0
- package/dist/dev/ShopifyProvider.js +46 -0
- package/dist/dev/ShopifyProvider.js.map +1 -0
- package/dist/dev/Video.cjs +44 -0
- package/dist/dev/Video.cjs.map +1 -0
- package/dist/dev/Video.js +44 -0
- package/dist/dev/Video.js.map +1 -0
- package/dist/dev/flatten-connection.cjs +23 -0
- package/dist/dev/flatten-connection.cjs.map +1 -0
- package/dist/dev/flatten-connection.js +23 -0
- package/dist/dev/flatten-connection.js.map +1 -0
- package/dist/dev/image-size.cjs +80 -0
- package/dist/dev/image-size.cjs.map +1 -0
- package/dist/dev/image-size.js +80 -0
- package/dist/dev/image-size.js.map +1 -0
- package/dist/dev/index.cjs +35 -0
- package/dist/dev/index.cjs.map +1 -0
- package/dist/dev/index.js +35 -0
- package/dist/dev/index.js.map +1 -0
- package/dist/dev/load-script.cjs +52 -0
- package/dist/dev/load-script.cjs.map +1 -0
- package/dist/dev/load-script.js +52 -0
- package/dist/dev/load-script.js.map +1 -0
- package/dist/dev/storefront-api-constants.cjs +5 -0
- package/dist/dev/storefront-api-constants.cjs.map +1 -0
- package/dist/dev/storefront-api-constants.js +5 -0
- package/dist/dev/storefront-api-constants.js.map +1 -0
- package/dist/dev/storefront-client.cjs +72 -0
- package/dist/dev/storefront-client.cjs.map +1 -0
- package/dist/dev/storefront-client.js +72 -0
- package/dist/dev/storefront-client.js.map +1 -0
- package/dist/dev/useMoney.cjs +72 -0
- package/dist/dev/useMoney.cjs.map +1 -0
- package/dist/dev/useMoney.js +72 -0
- package/dist/dev/useMoney.js.map +1 -0
- package/dist/prod/ExternalVideo.cjs +39 -0
- package/dist/prod/ExternalVideo.cjs.map +1 -0
- package/dist/prod/ExternalVideo.js +39 -0
- package/dist/prod/ExternalVideo.js.map +1 -0
- package/dist/prod/Image.cjs +99 -0
- package/dist/prod/Image.cjs.map +1 -0
- package/dist/prod/Image.js +99 -0
- package/dist/prod/Image.js.map +1 -0
- package/dist/prod/MediaFile.cjs +59 -0
- package/dist/prod/MediaFile.cjs.map +1 -0
- package/dist/prod/MediaFile.js +59 -0
- package/dist/prod/MediaFile.js.map +1 -0
- package/dist/prod/Metafield.cjs +288 -0
- package/dist/prod/Metafield.cjs.map +1 -0
- package/dist/prod/Metafield.js +288 -0
- package/dist/prod/Metafield.js.map +1 -0
- package/dist/prod/ModelViewer.cjs +143 -0
- package/dist/prod/ModelViewer.cjs.map +1 -0
- package/dist/prod/ModelViewer.js +143 -0
- package/dist/prod/ModelViewer.js.map +1 -0
- package/dist/prod/Money.cjs +40 -0
- package/dist/prod/Money.cjs.map +1 -0
- package/dist/prod/Money.js +40 -0
- package/dist/prod/Money.js.map +1 -0
- package/dist/prod/ProductPrice.cjs +61 -0
- package/dist/prod/ProductPrice.cjs.map +1 -0
- package/dist/prod/ProductPrice.js +61 -0
- package/dist/prod/ProductPrice.js.map +1 -0
- package/dist/prod/ProductProvider.cjs +161 -0
- package/dist/prod/ProductProvider.cjs.map +1 -0
- package/dist/prod/ProductProvider.js +161 -0
- package/dist/prod/ProductProvider.js.map +1 -0
- package/dist/prod/ShopPayButton.cjs +64 -0
- package/dist/prod/ShopPayButton.cjs.map +1 -0
- package/dist/prod/ShopPayButton.js +64 -0
- package/dist/prod/ShopPayButton.js.map +1 -0
- package/dist/prod/ShopifyProvider.cjs +46 -0
- package/dist/prod/ShopifyProvider.cjs.map +1 -0
- package/dist/prod/ShopifyProvider.js +46 -0
- package/dist/prod/ShopifyProvider.js.map +1 -0
- package/dist/prod/Video.cjs +44 -0
- package/dist/prod/Video.cjs.map +1 -0
- package/dist/prod/Video.js +44 -0
- package/dist/prod/Video.js.map +1 -0
- package/dist/prod/flatten-connection.cjs +18 -0
- package/dist/prod/flatten-connection.cjs.map +1 -0
- package/dist/prod/flatten-connection.js +18 -0
- package/dist/prod/flatten-connection.js.map +1 -0
- package/dist/prod/image-size.cjs +80 -0
- package/dist/prod/image-size.cjs.map +1 -0
- package/dist/prod/image-size.js +80 -0
- package/dist/prod/image-size.js.map +1 -0
- package/dist/prod/index.cjs +35 -0
- package/dist/prod/index.cjs.map +1 -0
- package/dist/prod/index.js +35 -0
- package/dist/prod/index.js.map +1 -0
- package/dist/prod/load-script.cjs +52 -0
- package/dist/prod/load-script.cjs.map +1 -0
- package/dist/prod/load-script.js +52 -0
- package/dist/prod/load-script.js.map +1 -0
- package/dist/prod/storefront-api-constants.cjs +5 -0
- package/dist/prod/storefront-api-constants.cjs.map +1 -0
- package/dist/prod/storefront-api-constants.js +5 -0
- package/dist/prod/storefront-api-constants.js.map +1 -0
- package/dist/prod/storefront-client.cjs +57 -0
- package/dist/prod/storefront-client.cjs.map +1 -0
- package/dist/prod/storefront-client.js +57 -0
- package/dist/prod/storefront-client.js.map +1 -0
- package/dist/prod/useMoney.cjs +72 -0
- package/dist/prod/useMoney.cjs.map +1 -0
- package/dist/prod/useMoney.js +72 -0
- package/dist/prod/useMoney.js.map +1 -0
- package/dist/types/ExternalVideo.d.ts +67 -0
- package/dist/types/Image.d.ts +54 -0
- package/dist/types/MediaFile.d.ts +31 -0
- package/dist/types/Metafield.d.ts +58 -0
- package/dist/types/ModelViewer.d.ts +57 -0
- package/dist/types/Money.d.ts +29 -0
- package/dist/types/ProductPrice.d.ts +22 -0
- package/dist/types/ProductProvider.d.ts +74 -0
- package/dist/types/ShopPayButton.d.ts +42 -0
- package/dist/types/ShopifyProvider.d.ts +42 -0
- package/dist/types/Video.d.ts +20 -0
- package/dist/types/flatten-connection.d.ts +17 -0
- package/dist/types/image-size.d.ts +36 -0
- package/dist/types/index.d.cts +15 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/load-script.d.ts +11 -0
- package/dist/types/storefront-api-constants.d.ts +1 -0
- package/dist/types/storefront-api-response.types.d.ts +68 -0
- package/dist/types/storefront-api-types.d.ts +6537 -0
- package/dist/types/storefront-client.d.ts +63 -0
- package/dist/types/useMoney.d.ts +55 -0
- package/dist/umd/hydrogen-react.dev.js +1472 -0
- package/dist/umd/hydrogen-react.dev.js.map +1 -0
- package/dist/umd/hydrogen-react.prod.js +3 -0
- package/dist/umd/hydrogen-react.prod.js.map +1 -0
- package/package.json +106 -0
- package/storefront.schema.json +1 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `createStorefrontClient()` function creates helpers that enable you to quickly query the Shopify Storefront API.
|
|
3
|
+
*
|
|
4
|
+
* 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.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createStorefrontClient({ storeDomain, privateStorefrontToken, publicStorefrontToken, storefrontApiVersion, contentType, }: StorefrontClientProps): StorefrontClientReturn;
|
|
7
|
+
declare type StorefrontClientProps = {
|
|
8
|
+
/** The host name of the domain (eg: `{shop}.myshopify.com`). */
|
|
9
|
+
storeDomain: string;
|
|
10
|
+
/** The Storefront API delegate access token. Refer to the [authentication](https://shopify.dev/api/storefront#authentication) and [delegate access token](https://shopify.dev/apps/auth/oauth/delegate-access-tokens) documentation for more details. */
|
|
11
|
+
privateStorefrontToken?: string;
|
|
12
|
+
/** The Storefront API access token. Refer to the [authentication](https://shopify.dev/api/storefront#authentication) documentation for more details. */
|
|
13
|
+
publicStorefrontToken?: string;
|
|
14
|
+
/** The Storefront API version. This should almost always be the same as the version Hydrogen-UI was built for. Learn more about Shopify [API versioning](https://shopify.dev/api/usage/versioning) for more details. */
|
|
15
|
+
storefrontApiVersion: string;
|
|
16
|
+
/**
|
|
17
|
+
* Customizes which `"content-type"` header is added when using `getPrivateTokenHeaders()` and `getPublicTokenHeaders()`. When fetching with a `JSON.stringify()`-ed `body`, use `"json"`. When fetching with a `body` that is a plain string, use `"graphql"`. Defaults to `"json"`
|
|
18
|
+
*
|
|
19
|
+
* Can also be customized on a call-by-call basis by passing in `'contentType'` to both `getPrivateTokenHeaders({...})` and `getPublicTokenHeaders({...})`, for example: `getPublicTokenHeaders({contentType: 'graphql'})`
|
|
20
|
+
*/
|
|
21
|
+
contentType?: 'json' | 'graphql';
|
|
22
|
+
};
|
|
23
|
+
declare type OverrideTokenHeaderProps = Partial<Pick<StorefrontClientProps, 'contentType'>>;
|
|
24
|
+
declare type StorefrontClientReturn = {
|
|
25
|
+
/**
|
|
26
|
+
* Creates the fully-qualified URL to your store's GraphQL endpoint.
|
|
27
|
+
*
|
|
28
|
+
* By default, it will use the config you passed in when calling `createStorefrontClient()`. However, you can override the following settings on each invocation of `getStorefrontApiUrl({...})`:
|
|
29
|
+
*
|
|
30
|
+
* - `storeDomain`
|
|
31
|
+
* - `storefrontApiVersion`
|
|
32
|
+
*/
|
|
33
|
+
getStorefrontApiUrl: (props?: Partial<Pick<StorefrontClientProps, 'storeDomain' | 'storefrontApiVersion'>>) => string;
|
|
34
|
+
/**
|
|
35
|
+
* Returns an object that contains headers that are needed for each query to Storefront API GraphQL endpoint. This method uses the private Server-to-Server token which reduces the chance of throttling but must not be exposed to clients. Server-side calls should prefer using this over `getPublicTokenHeaders()`.
|
|
36
|
+
*
|
|
37
|
+
* By default, it will use the config you passed in when calling `createStorefrontClient()`. However, you can override the following settings on each invocation of `getPrivateTokenHeaders({...})`:
|
|
38
|
+
*
|
|
39
|
+
* - `contentType`
|
|
40
|
+
* - `privateStorefrontToken`
|
|
41
|
+
* - `buyerIp`
|
|
42
|
+
*
|
|
43
|
+
* Note that `contentType` defaults to what you configured in `createStorefrontClient({...})` and defaults to `'json'`, but a specific call may require using `graphql`. When using `JSON.stringify()` on the `body`, use `'json'`; otherwise, use `'graphql'`.
|
|
44
|
+
*/
|
|
45
|
+
getPrivateTokenHeaders: (props?: OverrideTokenHeaderProps & Pick<StorefrontClientProps, 'privateStorefrontToken'> & {
|
|
46
|
+
/**
|
|
47
|
+
* The client's IP address. Passing this to the Storefront API when using a server-to-server token will help improve your store's analytics data.
|
|
48
|
+
*/
|
|
49
|
+
buyerIp?: string;
|
|
50
|
+
}) => Record<string, string>;
|
|
51
|
+
/**
|
|
52
|
+
* Returns an object that contains headers that are needed for each query to Storefront API GraphQL endpoint. This method uses the private Server-to-Server token which reduces the chance of throttling but must not be exposed to clients. Server-side calls should prefer using this over `getPublicTokenHeaders()`.
|
|
53
|
+
*
|
|
54
|
+
* By default, it will use the config you passed in when calling `createStorefrontClient()`. However, you can override the following settings on each invocation of `getPrivateTokenHeaders({...})`:
|
|
55
|
+
*
|
|
56
|
+
* - `contentType`
|
|
57
|
+
* - `publicStorefrontToken`
|
|
58
|
+
*
|
|
59
|
+
* Note that `contentType` defaults to what you configured in `createStorefrontClient({...})` and defaults to `'json'`, but a specific call may require using `graphql`. When using `JSON.stringify()` on the `body`, use `'json'`; otherwise, use `'graphql'`.
|
|
60
|
+
*/
|
|
61
|
+
getPublicTokenHeaders: (props?: OverrideTokenHeaderProps & Pick<StorefrontClientProps, 'publicStorefrontToken'>) => Record<string, string>;
|
|
62
|
+
};
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { CurrencyCode, MoneyV2 } from './storefront-api-types.js';
|
|
2
|
+
export declare type UseMoneyValue = {
|
|
3
|
+
/**
|
|
4
|
+
* The currency code from the `MoneyV2` object.
|
|
5
|
+
*/
|
|
6
|
+
currencyCode: CurrencyCode;
|
|
7
|
+
/**
|
|
8
|
+
* The name for the currency code, returned by `Intl.NumberFormat`.
|
|
9
|
+
*/
|
|
10
|
+
currencyName?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The currency symbol returned by `Intl.NumberFormat`.
|
|
13
|
+
*/
|
|
14
|
+
currencySymbol?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The currency narrow symbol returned by `Intl.NumberFormat`.
|
|
17
|
+
*/
|
|
18
|
+
currencyNarrowSymbol?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The localized amount, without any currency symbols or non-number types from the `Intl.NumberFormat.formatToParts` parts.
|
|
21
|
+
*/
|
|
22
|
+
amount: string;
|
|
23
|
+
/**
|
|
24
|
+
* All parts returned by `Intl.NumberFormat.formatToParts`.
|
|
25
|
+
*/
|
|
26
|
+
parts: Intl.NumberFormatPart[];
|
|
27
|
+
/**
|
|
28
|
+
* A string returned by `new Intl.NumberFormat` for the amount and currency code,
|
|
29
|
+
* using the `locale` value in the [`LocalizationProvider` component](https://shopify.dev/api/hydrogen/components/localization/localizationprovider).
|
|
30
|
+
*/
|
|
31
|
+
localizedString: string;
|
|
32
|
+
/**
|
|
33
|
+
* The `MoneyV2` object provided as an argument to the hook.
|
|
34
|
+
*/
|
|
35
|
+
original: MoneyV2;
|
|
36
|
+
/**
|
|
37
|
+
* A string with trailing zeros removed from the fractional part, if any exist. If there are no trailing zeros, then the fractional part remains.
|
|
38
|
+
* For example, `$640.00` turns into `$640`.
|
|
39
|
+
* `$640.42` remains `$640.42`.
|
|
40
|
+
*/
|
|
41
|
+
withoutTrailingZeros: string;
|
|
42
|
+
/**
|
|
43
|
+
* A string without currency and without trailing zeros removed from the fractional part, if any exist. If there are no trailing zeros, then the fractional part remains.
|
|
44
|
+
* For example, `$640.00` turns into `640`.
|
|
45
|
+
* `$640.42` turns into `640.42`.
|
|
46
|
+
*/
|
|
47
|
+
withoutTrailingZerosAndCurrency: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The `useMoney` hook takes a [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) and returns a
|
|
51
|
+
* default-formatted string of the amount with the correct currency indicator, along with some of the parts provided by
|
|
52
|
+
* [Intl.NumberFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat).
|
|
53
|
+
* Uses `locale` from `ShopifyProvider`
|
|
54
|
+
*/
|
|
55
|
+
export declare function useMoney(money: MoneyV2): UseMoneyValue;
|