@shopify/hydrogen 0.15.0 → 0.17.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/CHANGELOG.md +113 -1
- package/dist/esnext/FileSessionStorage.d.ts +1 -0
- package/dist/esnext/FileSessionStorage.js +1 -0
- package/dist/esnext/client.d.ts +3 -2
- package/dist/esnext/client.js +3 -2
- package/dist/esnext/components/CartProvider/CartProvider.client.d.ts +1 -1
- package/dist/esnext/components/CartProvider/CartProvider.client.js +3 -3
- package/dist/esnext/components/ExternalVideo/ExternalVideo.d.ts +2 -2
- package/dist/esnext/components/ExternalVideo/ExternalVideo.js +1 -1
- package/dist/esnext/components/Image/Image.d.ts +2 -2
- package/dist/esnext/components/Image/Image.js +1 -1
- package/dist/esnext/components/Link/Link.client.d.ts +1 -1
- package/dist/esnext/components/Link/Link.client.js +3 -3
- package/dist/esnext/components/LocalizationProvider/LocalizationClientProvider.client.js +4 -4
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.d.ts +2 -2
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +2 -2
- package/dist/esnext/components/MediaFile/MediaFile.d.ts +2 -2
- package/dist/esnext/components/MediaFile/MediaFile.js +1 -1
- package/dist/esnext/components/Metafield/Metafield.client.d.ts +8 -4
- package/dist/esnext/components/Metafield/Metafield.client.js +6 -2
- package/dist/esnext/components/ModelViewer/ModelViewer.client.d.ts +3 -3
- package/dist/esnext/components/ModelViewer/ModelViewer.client.js +1 -1
- package/dist/esnext/components/Money/Money.client.d.ts +2 -2
- package/dist/esnext/components/Money/Money.client.js +1 -1
- package/dist/esnext/components/ProductDescription/ProductDescription.client.d.ts +1 -1
- package/dist/esnext/components/ProductDescription/ProductDescription.client.js +1 -1
- package/dist/esnext/components/ProductMetafield/ProductMetafield.client.d.ts +3 -3
- package/dist/esnext/components/ProductMetafield/ProductMetafield.client.js +1 -1
- package/dist/esnext/components/ProductPrice/ProductPrice.client.d.ts +1 -1
- package/dist/esnext/components/ProductPrice/ProductPrice.client.js +1 -1
- package/dist/esnext/components/ProductProvider/ProductProvider.client.d.ts +1 -1
- package/dist/esnext/components/ProductTitle/ProductTitle.client.d.ts +1 -1
- package/dist/esnext/components/ProductTitle/ProductTitle.client.js +1 -1
- package/dist/esnext/components/UnitPrice/UnitPrice.client.d.ts +4 -4
- package/dist/esnext/components/UnitPrice/UnitPrice.client.js +2 -2
- package/dist/esnext/components/Video/Video.d.ts +2 -2
- package/dist/esnext/components/Video/Video.js +1 -1
- package/dist/esnext/constants.d.ts +4 -0
- package/dist/esnext/constants.js +4 -0
- package/dist/esnext/entry-client.js +4 -4
- package/dist/esnext/entry-server.d.ts +1 -1
- package/dist/esnext/entry-server.js +12 -5
- package/dist/esnext/foundation/Analytics/Analytics.server.js +4 -2
- package/dist/esnext/foundation/AnalyticsErrorBoundary.client.d.ts +4 -0
- package/dist/esnext/foundation/AnalyticsErrorBoundary.client.js +8 -0
- package/dist/esnext/foundation/Cookie/Cookie.d.ts +48 -0
- package/dist/esnext/foundation/Cookie/Cookie.js +66 -0
- package/dist/esnext/foundation/CookieSessionStorage/CookieSessionStorage.d.ts +5 -0
- package/dist/esnext/foundation/CookieSessionStorage/CookieSessionStorage.js +31 -0
- package/dist/esnext/foundation/FileSessionStorage/FileSessionStorage.d.ts +6 -0
- package/dist/esnext/foundation/FileSessionStorage/FileSessionStorage.js +148 -0
- package/dist/esnext/foundation/MemorySessionStorage/MemorySessionStorage.d.ts +5 -0
- package/dist/esnext/foundation/MemorySessionStorage/MemorySessionStorage.js +53 -0
- package/dist/esnext/foundation/Router/BrowserRouter.client.js +8 -8
- package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +40 -0
- package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.js +76 -0
- package/dist/esnext/foundation/ServerPropsProvider/index.d.ts +2 -0
- package/dist/esnext/foundation/ServerPropsProvider/index.js +1 -0
- package/dist/esnext/foundation/index.d.ts +1 -1
- package/dist/esnext/foundation/index.js +1 -1
- package/dist/esnext/foundation/session/session.d.ts +27 -0
- package/dist/esnext/foundation/session/session.js +37 -0
- package/dist/esnext/foundation/useQuery/hooks.d.ts +3 -3
- package/dist/esnext/foundation/useQuery/hooks.js +1 -1
- package/dist/esnext/foundation/useServerProps/index.d.ts +1 -0
- package/dist/esnext/foundation/useServerProps/index.js +1 -0
- package/dist/esnext/foundation/useServerProps/use-server-props.d.ts +21 -0
- package/dist/esnext/foundation/useServerProps/use-server-props.js +35 -0
- package/dist/esnext/foundation/useSession/useSession.d.ts +2 -0
- package/dist/esnext/foundation/useSession/useSession.js +8 -0
- package/dist/esnext/foundation/useUrl/useUrl.js +8 -1
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.d.ts +2 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +27 -12
- package/dist/esnext/hooks/useMoney/hooks.d.ts +1 -1
- package/dist/esnext/hooks/useMoney/hooks.js +1 -1
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.d.ts +2 -2
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.js +2 -2
- package/dist/esnext/hooks/useShopQuery/hooks.d.ts +2 -2
- package/dist/esnext/hooks/useShopQuery/hooks.js +5 -17
- package/dist/esnext/index.d.ts +4 -0
- package/dist/esnext/index.js +4 -0
- package/dist/esnext/storefront-api-types.d.ts +31 -13
- package/dist/esnext/storefront-api-types.js +14 -2
- package/dist/esnext/types.d.ts +2 -0
- package/dist/esnext/utilities/apiRoutes.d.ts +4 -3
- package/dist/esnext/utilities/apiRoutes.js +35 -8
- package/dist/esnext/utilities/flattenConnection/flattenConnection.d.ts +1 -1
- package/dist/esnext/utilities/flattenConnection/flattenConnection.js +1 -1
- package/dist/esnext/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +1 -1
- package/dist/esnext/utilities/parseMetafieldValue/parseMetafieldValue.js +1 -1
- package/dist/esnext/utilities/storefrontApi.d.ts +4 -0
- package/dist/esnext/utilities/storefrontApi.js +21 -0
- package/dist/esnext/version.d.ts +1 -1
- package/dist/esnext/version.js +1 -1
- package/dist/node/constants.d.ts +4 -0
- package/dist/node/constants.js +5 -1
- package/dist/node/entry-server.d.ts +1 -1
- package/dist/node/entry-server.js +12 -5
- package/dist/node/foundation/Analytics/Analytics.server.js +27 -2
- package/dist/node/foundation/AnalyticsErrorBoundary.client.d.ts +4 -0
- package/dist/node/foundation/AnalyticsErrorBoundary.client.js +14 -0
- package/dist/node/foundation/Router/BrowserRouter.client.js +8 -8
- package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +40 -0
- package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.js +101 -0
- package/dist/node/foundation/ServerPropsProvider/index.d.ts +2 -0
- package/dist/node/foundation/ServerPropsProvider/index.js +6 -0
- package/dist/node/foundation/session/session.d.ts +27 -0
- package/dist/node/foundation/session/session.js +43 -0
- package/dist/node/foundation/useServerProps/use-server-props.d.ts +21 -0
- package/dist/node/foundation/useServerProps/use-server-props.js +40 -0
- package/dist/node/framework/Hydration/ServerComponentRequest.server.d.ts +2 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +27 -12
- package/dist/node/storefront-api-types.d.ts +31 -13
- package/dist/node/storefront-api-types.js +14 -2
- package/dist/node/types.d.ts +2 -0
- package/dist/node/utilities/apiRoutes.d.ts +4 -3
- package/dist/node/utilities/apiRoutes.js +35 -8
- package/dist/node/utilities/flattenConnection/flattenConnection.d.ts +1 -1
- package/dist/node/utilities/flattenConnection/flattenConnection.js +1 -1
- package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +1 -1
- package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.js +1 -1
- package/dist/node/utilities/storefrontApi.d.ts +4 -0
- package/dist/node/utilities/storefrontApi.js +25 -0
- package/dist/node/version.d.ts +1 -1
- package/dist/node/version.js +1 -1
- package/package.json +4 -1
- package/dist/esnext/foundation/ServerStateProvider/index.d.ts +0 -2
- package/dist/esnext/foundation/ServerStateProvider/index.js +0 -1
- package/dist/esnext/foundation/useServerState/index.d.ts +0 -1
- package/dist/esnext/foundation/useServerState/index.js +0 -1
- package/dist/esnext/foundation/useServerState/use-server-state.d.ts +0 -16
- package/dist/esnext/foundation/useServerState/use-server-state.js +0 -20
- package/dist/node/foundation/ServerStateProvider/ServerStateProvider.d.ts +0 -30
- package/dist/node/foundation/ServerStateProvider/ServerStateProvider.js +0 -77
- package/dist/node/foundation/ServerStateProvider/index.d.ts +0 -2
- package/dist/node/foundation/ServerStateProvider/index.js +0 -6
- package/dist/node/foundation/useServerState/index.d.ts +0 -1
- package/dist/node/foundation/useServerState/index.js +0 -5
- package/dist/node/foundation/useServerState/use-server-state.d.ts +0 -16
- package/dist/node/foundation/useServerState/use-server-state.js +0 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,124 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.17.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1044](https://github.com/Shopify/hydrogen/pull/1044) [`c8f5934d`](https://github.com/Shopify/hydrogen/commit/c8f5934d85db63162a13256cfcf21098b390887b) Thanks [@blittle](https://github.com/blittle)! - Hydrogen now has a built in session and cookie implementation. Read more about [how sessions work in Hydrogen](https://shopify.dev/custom-storefronts/hydrogen/framework/sessions). The starter template also includes a cookie session storage implementation. To use the new session implementation within an existing Hydrogen app:
|
|
8
|
+
|
|
9
|
+
```diff
|
|
10
|
+
import renderHydrogen from '@shopify/hydrogen/entry-server';
|
|
11
|
+
import {
|
|
12
|
+
Router,
|
|
13
|
+
Route,
|
|
14
|
+
FileRoutes,
|
|
15
|
+
ShopifyProvider,
|
|
16
|
+
+ CookieSessionStorage,
|
|
17
|
+
} from '@shopify/hydrogen';
|
|
18
|
+
import {Suspense} from 'react';
|
|
19
|
+
import shopifyConfig from '../shopify.config';
|
|
20
|
+
import DefaultSeo from './components/DefaultSeo.server';
|
|
21
|
+
import NotFound from './components/NotFound.server';
|
|
22
|
+
import LoadingFallback from './components/LoadingFallback';
|
|
23
|
+
import CartProvider from './components/CartProvider.client';
|
|
24
|
+
|
|
25
|
+
function App({routes}) {
|
|
26
|
+
return (
|
|
27
|
+
<Suspense fallback={<LoadingFallback />}>
|
|
28
|
+
<ShopifyProvider shopifyConfig={shopifyConfig}>
|
|
29
|
+
<CartProvider>
|
|
30
|
+
<DefaultSeo />
|
|
31
|
+
<Router>
|
|
32
|
+
<FileRoutes routes={routes} />
|
|
33
|
+
<Route path="*" page={<NotFound />} />
|
|
34
|
+
</Router>
|
|
35
|
+
</CartProvider>
|
|
36
|
+
</ShopifyProvider>
|
|
37
|
+
</Suspense>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const routes = import.meta.globEager('./routes/**/*.server.[jt](s|sx)');
|
|
42
|
+
|
|
43
|
+
export default renderHydrogen(App, {
|
|
44
|
+
routes,
|
|
45
|
+
shopifyConfig,
|
|
46
|
+
+ session: CookieSessionStorage('__session', {
|
|
47
|
+
+ path: '/',
|
|
48
|
+
+ httpOnly: true,
|
|
49
|
+
+ secure: process.env.NODE_ENV === 'production',
|
|
50
|
+
+ sameSite: 'strict',
|
|
51
|
+
+ maxAge: 60 * 60 * 24 * 30,
|
|
52
|
+
+ }),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
* [#881](https://github.com/Shopify/hydrogen/pull/881) [`a31babfb`](https://github.com/Shopify/hydrogen/commit/a31babfb9bf73b732a18487582cec129acbb8b5e) Thanks [@jplhomer](https://github.com/jplhomer)! - ## Change from serverState to serverProps
|
|
58
|
+
|
|
59
|
+
**Breaking changes:**
|
|
60
|
+
|
|
61
|
+
1. `useServerState()` is gone. Use `useServerProps()` instead
|
|
62
|
+
2. `useServerProps()` is reset on each page navigation. Previously `useServerState()` was not.
|
|
63
|
+
3. `useServerProps()` does not contain `pathname` and `search`. Use the [useNavigate](https://shopify.dev/api/hydrogen/hooks/framework/usenavigate) hook to programmatically navigate instead.
|
|
64
|
+
|
|
65
|
+
**Explanation:**
|
|
66
|
+
|
|
67
|
+
The current behavior of server state is to **persist indefinitely** (until a hard page reload). This works great for things like the CountrySelector, where the updated state is meant to persist across navigations. This breaks down for many other use cases. Consider a collection paginator: if you paginate through to the second page of a collection using server state, visit a product page, and then go to a different collection page, the new collection page will use that same pagination variable in server state. This will result in a wonky or errored experience.
|
|
68
|
+
|
|
69
|
+
Additionally, we have found that the term for `serverState` is confusing. The hook is used within client components, yet the state is passed as a prop to server components.
|
|
70
|
+
|
|
71
|
+
As a result, `serverState` is now gone. Instead communicating between client and server components is through `serverProps`. If a client component wants to re-render server content, it just calls `setServerProps('some', 'data')`. Those props will be serialized to the server, and the server component will re-render. Additionally, the server props are reset on page navigation. So that they will not bleed between pages (fixes #331).
|
|
72
|
+
|
|
73
|
+
If you previously relied on `serverState` for global state in your app, you shouldn't use `serverProps` anymore. Instead we'll introduce a new session based mechanism for global state (in the meantime you could manually manage a cookie).
|
|
74
|
+
|
|
75
|
+
Lastly, `serverProps` no longer include the `pathname` and `search` parameters. Programmatically navigate in hydrogen instead with the [useNavigate](https://shopify.dev/api/hydrogen/hooks/framework/usenavigate) hook.
|
|
76
|
+
|
|
77
|
+
- [#1098](https://github.com/Shopify/hydrogen/pull/1098) [`f3dafec4`](https://github.com/Shopify/hydrogen/commit/f3dafec4b3113c85e33a15ee70b3f91c741e74f9) Thanks [@wizardlyhel](https://github.com/wizardlyhel)! - Obfuscate chunk filename on production build
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- [#1131](https://github.com/Shopify/hydrogen/pull/1131) [`8199023b`](https://github.com/Shopify/hydrogen/commit/8199023b88924db156e2a687dd6dfce2665ab638) Thanks [@blittle](https://github.com/blittle)! - Fix hydration issue where strings with $ would get converted to a single $
|
|
82
|
+
|
|
83
|
+
* [#1105](https://github.com/Shopify/hydrogen/pull/1105) [`57ececf8`](https://github.com/Shopify/hydrogen/commit/57ececf82ee0c264abc256df8b02555772cc2419) Thanks [@frehner](https://github.com/frehner)! - Regenerate the graphql.schema.json which should fix the sudden end-of-line termination, and makes the schema valid again.
|
|
84
|
+
|
|
85
|
+
- [#1099](https://github.com/Shopify/hydrogen/pull/1099) [`6b50d371`](https://github.com/Shopify/hydrogen/commit/6b50d37158aab1a4a82626e09865d27e14adfbfb) Thanks [@blittle](https://github.com/blittle)! - Fix Hydrogen to not hard fail when client analytics doesn't load. Analytics might fail to load due to client-side adblockers.
|
|
86
|
+
|
|
87
|
+
## 0.16.1
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- [#1102](https://github.com/Shopify/hydrogen/pull/1102) [`59ee791a`](https://github.com/Shopify/hydrogen/commit/59ee791ac81f41764b4ab3e5dd667c0c72b672d3) Thanks [@frandiox](https://github.com/frandiox)! - Do not call client exported functions during RSC.
|
|
92
|
+
|
|
93
|
+
## 0.16.0
|
|
94
|
+
|
|
95
|
+
### Patch Changes
|
|
96
|
+
|
|
97
|
+
- [#1082](https://github.com/Shopify/hydrogen/pull/1082) [`bd14340c`](https://github.com/Shopify/hydrogen/commit/bd14340c3099a0bf375a5879410cdf0697ed22f6) Thanks [@jplhomer](https://github.com/jplhomer)! - Update `useUrl()` to allow a developer to subscribe to a reactive version of the current router location.
|
|
98
|
+
|
|
99
|
+
Example:
|
|
100
|
+
|
|
101
|
+
```jsx
|
|
102
|
+
import {useUrl} from '@shopify/hydrogen/client';
|
|
103
|
+
|
|
104
|
+
function MyClientComponent() {
|
|
105
|
+
const url = useUrl();
|
|
106
|
+
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
// Record navigation, analytics, etc
|
|
109
|
+
}, [url]);
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
* [#1075](https://github.com/Shopify/hydrogen/pull/1075) [`05dea552`](https://github.com/Shopify/hydrogen/commit/05dea552c90862a125b5111993003355a019b556) Thanks [@jplhomer](https://github.com/jplhomer)! - Properly set buyer IP and secret token for API Route queryShop helper
|
|
114
|
+
|
|
3
115
|
## 0.15.0
|
|
4
116
|
|
|
5
117
|
### Minor Changes
|
|
6
118
|
|
|
7
119
|
- [#983](https://github.com/Shopify/hydrogen/pull/983) [`52af261b`](https://github.com/Shopify/hydrogen/commit/52af261ba2bf6ed08e232b9fb2d75e69905f4cc6) Thanks [@jplhomer](https://github.com/jplhomer)! - Introduce Suspense-friendly `fetchSync` API for server and client components.
|
|
8
120
|
|
|
9
|
-
When using `fetchSync` in server components, you provide options for caching and preloading. This is similar to the [`useQuery` hook](
|
|
121
|
+
When using `fetchSync` in server components, you provide options for caching and preloading. This is similar to the [`useQuery` hook](https://shopify.dev/api/hydrogen/hooks/global/usequery):
|
|
10
122
|
|
|
11
123
|
```jsx
|
|
12
124
|
import {fetchSync, CacheMinutes} from '@shopify/hydrogen';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FileSessionStorage } from './foundation/FileSessionStorage/FileSessionStorage';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FileSessionStorage } from './foundation/FileSessionStorage/FileSessionStorage';
|
package/dist/esnext/client.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export * from './components';
|
|
2
2
|
export * from './hooks';
|
|
3
|
-
export * from './foundation/
|
|
3
|
+
export * from './foundation/useServerProps';
|
|
4
4
|
export * from './foundation/useShop';
|
|
5
|
-
export * from './foundation/
|
|
5
|
+
export * from './foundation/ServerPropsProvider';
|
|
6
|
+
export * from './foundation/useUrl';
|
|
6
7
|
export { Head } from './foundation/Head';
|
|
7
8
|
export * from './utilities';
|
|
8
9
|
export { ClientAnalytics } from './foundation/Analytics';
|
package/dist/esnext/client.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export * from './components';
|
|
2
2
|
export * from './hooks';
|
|
3
|
-
export * from './foundation/
|
|
3
|
+
export * from './foundation/useServerProps';
|
|
4
4
|
export * from './foundation/useShop';
|
|
5
|
-
export * from './foundation/
|
|
5
|
+
export * from './foundation/ServerPropsProvider';
|
|
6
|
+
export * from './foundation/useUrl';
|
|
6
7
|
export { Head } from './foundation/Head';
|
|
7
8
|
export * from './utilities';
|
|
8
9
|
export { ClientAnalytics } from './foundation/Analytics';
|
|
@@ -30,7 +30,7 @@ export declare function CartProvider({ children, numCartLines, onCreate, onLineA
|
|
|
30
30
|
/** A callback that is invoked when the process to update the cart discount codes begins, but before the discount codes are updated in the Storefront API. */
|
|
31
31
|
onDiscountCodesUpdate?: () => void;
|
|
32
32
|
/**
|
|
33
|
-
* An object with fields that correspond to the Storefront API's [Cart object](/api/storefront/latest/objects/cart).
|
|
33
|
+
* An object with fields that correspond to the Storefront API's [Cart object](https://shopify.dev/api/storefront/latest/objects/cart).
|
|
34
34
|
*/
|
|
35
35
|
data?: CartFragmentFragment;
|
|
36
36
|
}): JSX.Element;
|
|
@@ -4,7 +4,7 @@ import { CartLineAdd, CartCreate, CartLineRemove, CartLineUpdate, CartNoteUpdate
|
|
|
4
4
|
import { useCartFetch } from './hooks';
|
|
5
5
|
import { CartContext } from './context';
|
|
6
6
|
import { CART_ID_STORAGE_KEY } from './constants';
|
|
7
|
-
import {
|
|
7
|
+
import { useServerProps } from '../../foundation/useServerProps';
|
|
8
8
|
import { ClientAnalytics } from '../../foundation/Analytics';
|
|
9
9
|
function cartReducer(state, action) {
|
|
10
10
|
switch (action.type) {
|
|
@@ -152,8 +152,8 @@ function cartReducer(state, action) {
|
|
|
152
152
|
*/
|
|
153
153
|
export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, data: cart, }) {
|
|
154
154
|
var _a;
|
|
155
|
-
const {
|
|
156
|
-
const countryCode = (_a =
|
|
155
|
+
const { serverProps } = useServerProps();
|
|
156
|
+
const countryCode = (_a = serverProps === null || serverProps === void 0 ? void 0 : serverProps.country) === null || _a === void 0 ? void 0 : _a.isoCode;
|
|
157
157
|
const initialStatus = cart
|
|
158
158
|
? { status: 'idle', cart: cartFromGraphQL(cart) }
|
|
159
159
|
: { status: 'uninitialized' };
|
|
@@ -3,7 +3,7 @@ import type { ExternalVideo as ExternalVideoType } from '../../storefront-api-ty
|
|
|
3
3
|
import type { PartialDeep } from 'type-fest';
|
|
4
4
|
interface ExternalVideoProps {
|
|
5
5
|
/**
|
|
6
|
-
* An object with fields that correspond to the Storefront API's [ExternalVideo object](/api/storefront/reference/products/externalvideo).
|
|
6
|
+
* An object with fields that correspond to the Storefront API's [ExternalVideo object](https://shopify.dev/api/storefront/reference/products/externalvideo).
|
|
7
7
|
*/
|
|
8
8
|
data: PartialDeep<ExternalVideoType>;
|
|
9
9
|
/** An object containing the options available for either
|
|
@@ -15,7 +15,7 @@ interface ExternalVideoProps {
|
|
|
15
15
|
declare type PropsWeControl = 'src';
|
|
16
16
|
/**
|
|
17
17
|
* The `ExternalVideo` component renders an embedded video for the Storefront
|
|
18
|
-
* API's [ExternalVideo object](/api/storefront/reference/products/externalvideo).
|
|
18
|
+
* API's [ExternalVideo object](https://shopify.dev/api/storefront/reference/products/externalvideo).
|
|
19
19
|
*/
|
|
20
20
|
export declare function ExternalVideo(props: Omit<JSX.IntrinsicElements['iframe'], PropsWeControl> & ExternalVideoProps): JSX.Element;
|
|
21
21
|
export {};
|
|
@@ -2,7 +2,7 @@ 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 [ExternalVideo object](/api/storefront/reference/products/externalvideo).
|
|
5
|
+
* API's [ExternalVideo object](https://shopify.dev/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;
|
|
@@ -14,7 +14,7 @@ export interface BaseImageProps {
|
|
|
14
14
|
}
|
|
15
15
|
interface MediaImagePropsBase extends BaseImageProps {
|
|
16
16
|
/** An object with fields that correspond to the Storefront API's
|
|
17
|
-
* [Image object](/api/storefront/reference/common-objects/image).
|
|
17
|
+
* [Image object](https://shopify.dev/api/storefront/reference/common-objects/image).
|
|
18
18
|
*/
|
|
19
19
|
data: PartialDeep<ImageType>;
|
|
20
20
|
/** An object of image size options for Shopify CDN images. */
|
|
@@ -34,7 +34,7 @@ declare type ExternalImageProps = Merge<BaseElementProps, ExternalImagePropsBase
|
|
|
34
34
|
declare type ImageProps = MergeExclusive<MediaImageProps, ExternalImageProps>;
|
|
35
35
|
/**
|
|
36
36
|
* The `Image` component renders an image for the Storefront API's
|
|
37
|
-
* [Image object](/api/storefront/reference/common-objects/image).
|
|
37
|
+
* [Image object](https://shopify.dev/api/storefront/reference/common-objects/image).
|
|
38
38
|
*/
|
|
39
39
|
export declare function Image(props: ImageProps): JSX.Element;
|
|
40
40
|
export {};
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { shopifyImageLoader, getShopifyImageDimensions, } from '../../utilities';
|
|
3
3
|
/**
|
|
4
4
|
* The `Image` component renders an image for the Storefront API's
|
|
5
|
-
* [Image object](/api/storefront/reference/common-objects/image).
|
|
5
|
+
* [Image object](https://shopify.dev/api/storefront/reference/common-objects/image).
|
|
6
6
|
*/
|
|
7
7
|
export function Image(props) {
|
|
8
8
|
var _a, _b, _c, _d;
|
|
@@ -8,7 +8,7 @@ export interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorEle
|
|
|
8
8
|
clientState?: any;
|
|
9
9
|
/** Whether to reload the whole document on navigation. */
|
|
10
10
|
reloadDocument?: boolean;
|
|
11
|
-
/** Whether to prefetch the link source when the user signals intent. Defaults to `true`. For more information, refer to [Prefetching a link source](/custom-storefronts/hydrogen/framework/routes#prefetching-a-link-source). */
|
|
11
|
+
/** Whether to prefetch the link source when the user signals intent. Defaults to `true`. For more information, refer to [Prefetching a link source](https://shopify.dev/custom-storefronts/hydrogen/framework/routes#prefetching-a-link-source). */
|
|
12
12
|
prefetch?: boolean;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
@@ -2,8 +2,8 @@ import React, { useCallback, useEffect, useState } from 'react';
|
|
|
2
2
|
import { useRouter } from '../../foundation/Router/BrowserRouter.client';
|
|
3
3
|
import { createPath } from 'history';
|
|
4
4
|
import { useNavigate } from '../../foundation/useNavigate/useNavigate';
|
|
5
|
-
import { useServerState } from '../../foundation/useServerState';
|
|
6
5
|
import { RSC_PATHNAME } from '../../constants';
|
|
6
|
+
import { useInternalServerProps } from '../../foundation/useServerProps/use-server-props';
|
|
7
7
|
/**
|
|
8
8
|
* The `Link` component is used to navigate between routes. Because it renders an underlying `<a>` element, all
|
|
9
9
|
* properties available to the `<a>` element are also available to the `Link` component.
|
|
@@ -86,14 +86,14 @@ export const Link = React.forwardRef(function Link(props, ref) {
|
|
|
86
86
|
shouldPrefetch && React.createElement(Prefetch, { pathname: to })));
|
|
87
87
|
});
|
|
88
88
|
function Prefetch({ pathname }) {
|
|
89
|
-
const {
|
|
89
|
+
const { getProposedLocationServerProps } = useInternalServerProps();
|
|
90
90
|
const { location } = useRouter();
|
|
91
91
|
const newPath = createPath({ pathname });
|
|
92
92
|
if (pathname.startsWith('http') || newPath === createPath(location)) {
|
|
93
93
|
return null;
|
|
94
94
|
}
|
|
95
95
|
const newLocation = new URL(newPath, window.location.href);
|
|
96
|
-
const proposedServerState =
|
|
96
|
+
const proposedServerState = getProposedLocationServerProps({
|
|
97
97
|
pathname: newLocation.pathname,
|
|
98
98
|
search: newLocation.search,
|
|
99
99
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React, { useMemo, useState, useCallback } from 'react';
|
|
2
2
|
import { LocalizationContext } from './LocalizationContext.client';
|
|
3
|
-
import {
|
|
3
|
+
import { useServerProps } from '../../foundation/useServerProps';
|
|
4
4
|
export default function LocalizationClientProvider({ localization, children, }) {
|
|
5
|
-
const {
|
|
5
|
+
const { setServerProps } = useServerProps();
|
|
6
6
|
const [country, setCountry] = useState(localization.country);
|
|
7
7
|
const setter = useCallback((country) => {
|
|
8
8
|
setCountry(country);
|
|
9
|
-
|
|
10
|
-
}, [
|
|
9
|
+
setServerProps('country', country);
|
|
10
|
+
}, [setServerProps]);
|
|
11
11
|
const contextValue = useMemo(() => {
|
|
12
12
|
return {
|
|
13
13
|
country,
|
|
@@ -5,14 +5,14 @@ export interface LocalizationProviderProps {
|
|
|
5
5
|
/** A `ReactNode` element. */
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
/** Whether to preload the query. Defaults to `false`. Specify `true` to
|
|
8
|
-
* [preload the query](/custom-storefronts/hydrogen/framework/preloaded-queries) for the URL
|
|
8
|
+
* [preload the query](https://shopify.dev/custom-storefronts/hydrogen/framework/preloaded-queries) for the URL
|
|
9
9
|
* or `'*'` to preload the query for all requests.
|
|
10
10
|
*/
|
|
11
11
|
preload: PreloadOptions;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* The `LocalizationProvider` component automatically queries the Storefront API's
|
|
15
|
-
* [`localization`](/api/storefront/reference/common-objects/queryroot) field
|
|
15
|
+
* [`localization`](https://shopify.dev/api/storefront/reference/common-objects/queryroot) field
|
|
16
16
|
* for the `isoCode` and `name` of the `country` and keeps this information in a context.
|
|
17
17
|
*
|
|
18
18
|
* Any descendents of this provider can use the `useCountry` hook.
|
|
@@ -5,7 +5,7 @@ import { useShopQuery } from '../../hooks/useShopQuery';
|
|
|
5
5
|
import { CacheDays } from '../../framework/CachingStrategy';
|
|
6
6
|
/**
|
|
7
7
|
* The `LocalizationProvider` component automatically queries the Storefront API's
|
|
8
|
-
* [`localization`](/api/storefront/reference/common-objects/queryroot) field
|
|
8
|
+
* [`localization`](https://shopify.dev/api/storefront/reference/common-objects/queryroot) field
|
|
9
9
|
* for the `isoCode` and `name` of the `country` and keeps this information in a context.
|
|
10
10
|
*
|
|
11
11
|
* Any descendents of this provider can use the `useCountry` hook.
|
|
@@ -23,7 +23,7 @@ export function LocalizationProvider(props) {
|
|
|
23
23
|
return (React.createElement(LocalizationClientProvider, { localization: localization }, props.children));
|
|
24
24
|
}
|
|
25
25
|
const query = `
|
|
26
|
-
query Localization($language: LanguageCode)
|
|
26
|
+
query Localization($language: LanguageCode)
|
|
27
27
|
@inContext(language: $language) {
|
|
28
28
|
localization {
|
|
29
29
|
country {
|
|
@@ -5,14 +5,14 @@ import { ExternalVideo } from '../ExternalVideo';
|
|
|
5
5
|
import type { MediaEdge as MediaEdgeType } from '../../storefront-api-types';
|
|
6
6
|
import type { PartialDeep } from 'type-fest';
|
|
7
7
|
export interface MediaFileProps {
|
|
8
|
-
/** An object with fields that correspond to the Storefront API's [Media object](/api/storefront/reference/products/media). */
|
|
8
|
+
/** An object with fields that correspond to the Storefront API's [Media object](https://shopify.dev/api/storefront/reference/products/media). */
|
|
9
9
|
data: PartialDeep<MediaEdgeType['node']>;
|
|
10
10
|
/** The options for the `Image`, `Video`, or `ExternalVideo` components. */
|
|
11
11
|
options?: React.ComponentProps<typeof Image>['options'] | React.ComponentProps<typeof Video>['options'] | React.ComponentProps<typeof ExternalVideo>['options'];
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* The `MediaFile` component renders the media for the Storefront API's
|
|
15
|
-
* [Media object](/api/storefront/reference/products/media). It renders an `Image`, a
|
|
15
|
+
* [Media object](https://shopify.dev/api/storefront/reference/products/media). It renders an `Image`, a
|
|
16
16
|
* `Video`, an `ExternalVideo`, or a `ModelViewer` depending on the `mediaContentType` of the
|
|
17
17
|
* `media` provided as a prop.
|
|
18
18
|
*/
|
|
@@ -5,7 +5,7 @@ import { ExternalVideo } from '../ExternalVideo';
|
|
|
5
5
|
import { ModelViewer } from '../ModelViewer';
|
|
6
6
|
/**
|
|
7
7
|
* The `MediaFile` component renders the media for the Storefront API's
|
|
8
|
-
* [Media object](/api/storefront/reference/products/media). It renders an `Image`, a
|
|
8
|
+
* [Media object](https://shopify.dev/api/storefront/reference/products/media). It renders an `Image`, a
|
|
9
9
|
* `Video`, an `ExternalVideo`, or a `ModelViewer` depending on the `mediaContentType` of the
|
|
10
10
|
* `media` provided as a prop.
|
|
11
11
|
*/
|
|
@@ -2,16 +2,20 @@ import { ElementType } from 'react';
|
|
|
2
2
|
import { Props } from '../types';
|
|
3
3
|
import { ParsedMetafield } from '../../types';
|
|
4
4
|
export interface MetafieldProps<TTag> {
|
|
5
|
-
/** An object with fields that correspond to the Storefront API's [Metafield object](/api/storefront/reference/common-objects/metafield). */
|
|
5
|
+
/** An object with fields that correspond to the Storefront API's [Metafield object](https://shopify.dev/api/storefront/reference/common-objects/metafield). */
|
|
6
6
|
data: ParsedMetafield;
|
|
7
|
-
/** An HTML tag to be rendered as the base element wrapper. The default value varies depending on [metafield.type](/apps/metafields/types). */
|
|
7
|
+
/** An HTML tag to be rendered as the base element wrapper. The default value varies depending on [metafield.type](https://shopify.dev/apps/metafields/types). */
|
|
8
8
|
as?: TTag;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* The `Metafield` component renders the value of a Storefront
|
|
12
|
-
* API's [Metafield object](/api/storefront/reference/common-objects/metafield).
|
|
12
|
+
* API's [Metafield object](https://shopify.dev/api/storefront/reference/common-objects/metafield).
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* When a render function is provided, it passes the Metafield object with a value
|
|
15
|
+
* that was parsed according to the Metafield's `type` field. For more information,
|
|
16
|
+
* refer to the [Render props](#render-props) section.
|
|
17
|
+
*
|
|
18
|
+
* When no render function is provided, it renders a smart default of the
|
|
15
19
|
* Metafield's `value`. For more information, refer to the [Default output](#default-output) section.
|
|
16
20
|
*/
|
|
17
21
|
export declare function Metafield<TTag extends ElementType>(props: Props<TTag> & MetafieldProps<TTag>): JSX.Element | null;
|
|
@@ -4,9 +4,13 @@ import { getMeasurementAsString } from '../../utilities';
|
|
|
4
4
|
import { Image } from '../Image';
|
|
5
5
|
/**
|
|
6
6
|
* The `Metafield` component renders the value of a Storefront
|
|
7
|
-
* API's [Metafield object](/api/storefront/reference/common-objects/metafield).
|
|
7
|
+
* API's [Metafield object](https://shopify.dev/api/storefront/reference/common-objects/metafield).
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* When a render function is provided, it passes the Metafield object with a value
|
|
10
|
+
* that was parsed according to the Metafield's `type` field. For more information,
|
|
11
|
+
* refer to the [Render props](#render-props) section.
|
|
12
|
+
*
|
|
13
|
+
* When no render function is provided, it renders a smart default of the
|
|
10
14
|
* Metafield's `value`. For more information, refer to the [Default output](#default-output) section.
|
|
11
15
|
*/
|
|
12
16
|
export function Metafield(props) {
|
|
@@ -5,11 +5,11 @@ import type { PartialDeep } from 'type-fest';
|
|
|
5
5
|
interface ModelViewerProps {
|
|
6
6
|
/** Any ReactNode elements. */
|
|
7
7
|
children?: ReactNode;
|
|
8
|
-
/** An object with fields that correspond to the Storefront API's [Model3D object](/api/storefront/latest/objects/model3d). */
|
|
8
|
+
/** An object with fields that correspond to the Storefront API's [Model3D object](https://shopify.dev/api/storefront/latest/objects/model3d). */
|
|
9
9
|
data: PartialDeep<Model3d>;
|
|
10
10
|
/** A string of either `auto`, `lazy`, or `eager` to indicate the conditions for preloading. Refer to [loading in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-attributes-loading). */
|
|
11
11
|
loading?: 'auto' | 'lazy' | 'eager';
|
|
12
|
-
/** A URL to display an image instead of the model. This is useful for showing the user something before a model is loaded and ready to render. If no URL is provided, then [Model3d.previewImage](/api/storefront/latest/objects/model3d) is used. Refer to [poster in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-attributes-poster). */
|
|
12
|
+
/** A URL to display an image instead of the model. This is useful for showing the user something before a model is loaded and ready to render. If no URL is provided, then [Model3d.previewImage](https://shopify.dev/api/storefront/latest/objects/model3d) is used. Refer to [poster in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-attributes-poster). */
|
|
13
13
|
poster?: string;
|
|
14
14
|
/** A string of either `auto`, `interaction`, or `manual` to indicate when the model should be revealed. Refer to [reveal in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-attributes-reveal). */
|
|
15
15
|
reveal?: 'auto' | 'interaction' | 'manual';
|
|
@@ -122,7 +122,7 @@ declare global {
|
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
124
|
* The `ModelViewer` component renders a 3D model (with the `model-viewer` tag) for
|
|
125
|
-
* the Storefront API's [Model3d object](/api/storefront/reference/products/model3d).
|
|
125
|
+
* the Storefront API's [Model3d object](https://shopify.dev/api/storefront/reference/products/model3d).
|
|
126
126
|
*/
|
|
127
127
|
export declare function ModelViewer<TTag extends ElementType>(props: Props<TTag, PropsWeControl> & ModelViewerProps): JSX.Element | null;
|
|
128
128
|
export {};
|
|
@@ -2,7 +2,7 @@ import React, { useState, useEffect, useCallback, } from 'react';
|
|
|
2
2
|
import { useLoadScript } from '../../hooks/useLoadScript/useLoadScript';
|
|
3
3
|
/**
|
|
4
4
|
* The `ModelViewer` component renders a 3D model (with the `model-viewer` tag) for
|
|
5
|
-
* the Storefront API's [Model3d object](/api/storefront/reference/products/model3d).
|
|
5
|
+
* the Storefront API's [Model3d object](https://shopify.dev/api/storefront/reference/products/model3d).
|
|
6
6
|
*/
|
|
7
7
|
export function ModelViewer(props) {
|
|
8
8
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -3,12 +3,12 @@ import type { PartialDeep } from 'type-fest';
|
|
|
3
3
|
interface MoneyProps<TTag> {
|
|
4
4
|
/** An HTML tag to be rendered as the base element wrapper. The default is `div`. */
|
|
5
5
|
as?: TTag;
|
|
6
|
-
/** An object with fields that correspond to the Storefront API's [MoneyV2 object](/api/storefront/reference/common-objects/moneyv2). */
|
|
6
|
+
/** An object with fields that correspond to the Storefront API's [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2). */
|
|
7
7
|
data: PartialDeep<MoneyV2>;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* The `Money` component renders a string of the Storefront API's
|
|
11
|
-
* [MoneyV2 object](/api/storefront/reference/common-objects/moneyv2) according to the
|
|
11
|
+
* [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) according to the
|
|
12
12
|
* `defaultLocale` in the `shopify.config.js` file.
|
|
13
13
|
*/
|
|
14
14
|
export declare function Money<TTag extends keyof JSX.IntrinsicElements = 'div'>(props: JSX.IntrinsicElements[TTag] & MoneyProps<TTag>): JSX.Element;
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { useMoney } from '../../hooks';
|
|
3
3
|
/**
|
|
4
4
|
* The `Money` component renders a string of the Storefront API's
|
|
5
|
-
* [MoneyV2 object](/api/storefront/reference/common-objects/moneyv2) according to the
|
|
5
|
+
* [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) according to the
|
|
6
6
|
* `defaultLocale` in the `shopify.config.js` file.
|
|
7
7
|
*/
|
|
8
8
|
export function Money(props) {
|
|
@@ -2,7 +2,7 @@ import { ElementType } from 'react';
|
|
|
2
2
|
import { Props } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* The `ProductDescription` component renders a `div` with
|
|
5
|
-
* the product's [`descriptionHtml`](/api/storefront/reference/products/product).
|
|
5
|
+
* the product's [`descriptionHtml`](https://shopify.dev/api/storefront/reference/products/product).
|
|
6
6
|
* It must be a descendent of the `ProductProvider` component.
|
|
7
7
|
*/
|
|
8
8
|
export declare function ProductDescription<TTag extends ElementType = 'div'>(props: Props<TTag> & {
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { useProduct } from '../ProductProvider';
|
|
3
3
|
/**
|
|
4
4
|
* The `ProductDescription` component renders a `div` with
|
|
5
|
-
* the product's [`descriptionHtml`](/api/storefront/reference/products/product).
|
|
5
|
+
* the product's [`descriptionHtml`](https://shopify.dev/api/storefront/reference/products/product).
|
|
6
6
|
* It must be a descendent of the `ProductProvider` component.
|
|
7
7
|
*/
|
|
8
8
|
export function ProductDescription(props) {
|
|
@@ -2,11 +2,11 @@ import { ElementType } from 'react';
|
|
|
2
2
|
import { Props } from '../types';
|
|
3
3
|
import { MetafieldProps } from '../Metafield/Metafield.client';
|
|
4
4
|
export interface ProductMetafieldProps<TTag> extends Omit<MetafieldProps<TTag>, 'metafield'> {
|
|
5
|
-
/** A string corresponding to the [key](/api/storefront/reference/common-objects/metafield) of the product's
|
|
5
|
+
/** A string corresponding to the [key](https://shopify.dev/api/storefront/reference/common-objects/metafield) of the product's
|
|
6
6
|
* metafield.
|
|
7
7
|
*/
|
|
8
8
|
keyName: string;
|
|
9
|
-
/** A string corresponding to the [namespace](/api/storefront/reference/common-objects/metafield) of the
|
|
9
|
+
/** A string corresponding to the [namespace](https://shopify.dev/api/storefront/reference/common-objects/metafield) of the
|
|
10
10
|
* product's metafield.
|
|
11
11
|
*/
|
|
12
12
|
namespace: string;
|
|
@@ -15,7 +15,7 @@ export interface ProductMetafieldProps<TTag> extends Omit<MetafieldProps<TTag>,
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* The `ProductMetafield` component renders a
|
|
18
|
-
* [`Metafield`](/api/hydrogen/components/primitive/metafield) component with the product metafield.
|
|
18
|
+
* [`Metafield`](https://shopify.dev/api/hydrogen/components/primitive/metafield) component with the product metafield.
|
|
19
19
|
* It must be a descendent of a `ProductProvider` component.
|
|
20
20
|
*/
|
|
21
21
|
export declare function ProductMetafield<TTag extends ElementType>(props: Props<TTag> & Omit<ProductMetafieldProps<TTag>, 'data'>): JSX.Element | null;
|
|
@@ -4,7 +4,7 @@ import { useProduct } from '../../hooks/useProduct/useProduct';
|
|
|
4
4
|
import { flattenConnection } from '../../utilities';
|
|
5
5
|
/**
|
|
6
6
|
* The `ProductMetafield` component renders a
|
|
7
|
-
* [`Metafield`](/api/hydrogen/components/primitive/metafield) component with the product metafield.
|
|
7
|
+
* [`Metafield`](https://shopify.dev/api/hydrogen/components/primitive/metafield) component with the product metafield.
|
|
8
8
|
* It must be a descendent of a `ProductProvider` component.
|
|
9
9
|
*/
|
|
10
10
|
export function ProductMetafield(props) {
|
|
@@ -11,6 +11,6 @@ export interface ProductPriceProps {
|
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* The `ProductPrice` component renders a `Money` component with the product
|
|
14
|
-
* [`priceRange`](/api/storefront/reference/products/productpricerange)'s `maxVariantPrice` or `minVariantPrice`, for either the regular price or compare at price range. It must be a descendent of the `ProductProvider` component.
|
|
14
|
+
* [`priceRange`](https://shopify.dev/api/storefront/reference/products/productpricerange)'s `maxVariantPrice` or `minVariantPrice`, for either the regular price or compare at price range. It must be a descendent of the `ProductProvider` component.
|
|
15
15
|
*/
|
|
16
16
|
export declare function ProductPrice<TTag extends keyof JSX.IntrinsicElements>(props: (Omit<React.ComponentProps<typeof UnitPrice>, 'data' | 'measurement'> | Omit<React.ComponentProps<typeof Money>, 'data'>) & ProductPriceProps): JSX.Element | null;
|
|
@@ -4,7 +4,7 @@ import { useProduct } from '../ProductProvider';
|
|
|
4
4
|
import { UnitPrice } from '../UnitPrice';
|
|
5
5
|
/**
|
|
6
6
|
* The `ProductPrice` component renders a `Money` component with the product
|
|
7
|
-
* [`priceRange`](/api/storefront/reference/products/productpricerange)'s `maxVariantPrice` or `minVariantPrice`, for either the regular price or compare at price range. It must be a descendent of the `ProductProvider` component.
|
|
7
|
+
* [`priceRange`](https://shopify.dev/api/storefront/reference/products/productpricerange)'s `maxVariantPrice` or `minVariantPrice`, for either the regular price or compare at price range. It must be a descendent of the `ProductProvider` component.
|
|
8
8
|
*/
|
|
9
9
|
export function ProductPrice(props) {
|
|
10
10
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -5,7 +5,7 @@ import type { PartialDeep } from 'type-fest';
|
|
|
5
5
|
export interface ProductProviderProps {
|
|
6
6
|
/** A `ReactNode` element. */
|
|
7
7
|
children: ReactNode;
|
|
8
|
-
/** A [Product object](/api/storefront/reference/products/product). */
|
|
8
|
+
/** A [Product object](https://shopify.dev/api/storefront/reference/products/product). */
|
|
9
9
|
data: PartialDeep<ProductType>;
|
|
10
10
|
/** The initially selected variant. If this is missing, then `selectedVariantId`
|
|
11
11
|
* in the returned `object` from the `useProduct` hook uses the first available variant
|
|
@@ -2,7 +2,7 @@ import { ElementType } from 'react';
|
|
|
2
2
|
import { Props } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* The `ProductTitle` component renders a `span` element (or the type of
|
|
5
|
-
* HTML element specified by the `as` prop) with the product's [`title`](/api/storefront/reference/products/product).
|
|
5
|
+
* HTML element specified by the `as` prop) with the product's [`title`](https://shopify.dev/api/storefront/reference/products/product).
|
|
6
6
|
* It must be a descendent of the `ProductProvider` component.
|
|
7
7
|
*/
|
|
8
8
|
export declare function ProductTitle<TTag extends ElementType = 'span'>(props: Props<TTag> & {
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { useProduct } from '../ProductProvider';
|
|
3
3
|
/**
|
|
4
4
|
* The `ProductTitle` component renders a `span` element (or the type of
|
|
5
|
-
* HTML element specified by the `as` prop) with the product's [`title`](/api/storefront/reference/products/product).
|
|
5
|
+
* HTML element specified by the `as` prop) with the product's [`title`](https://shopify.dev/api/storefront/reference/products/product).
|
|
6
6
|
* It must be a descendent of the `ProductProvider` component.
|
|
7
7
|
*/
|
|
8
8
|
export function ProductTitle(props) {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { UnitPriceMeasurement, MoneyV2 } from '../../storefront-api-types';
|
|
2
2
|
import type { PartialDeep } from 'type-fest';
|
|
3
3
|
export interface UnitPriceProps<TTag> {
|
|
4
|
-
/** An object with fields that correspond to the Storefront API's [MoneyV2 object](/api/storefront/reference/common-objects/moneyv2). */
|
|
4
|
+
/** An object with fields that correspond to the Storefront API's [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2). */
|
|
5
5
|
data: PartialDeep<MoneyV2>;
|
|
6
|
-
/** A [UnitPriceMeasurement object](/api/storefront/reference/products/unitpricemeasurement). */
|
|
6
|
+
/** A [UnitPriceMeasurement object](https://shopify.dev/api/storefront/reference/products/unitpricemeasurement). */
|
|
7
7
|
measurement: PartialDeep<UnitPriceMeasurement>;
|
|
8
8
|
/** An HTML tag to be rendered as the base element wrapper. The default is `div`. */
|
|
9
9
|
as?: TTag;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* The `UnitPrice` component renders a string with a [UnitPrice](/themes/pricing-payments/unit-pricing) as the
|
|
13
|
-
* Storefront API's [MoneyV2 object](/api/storefront/reference/common-objects/moneyv2) with a reference unit from the Storefront API's [UnitPriceMeasurement object](/api/storefront/reference/products/unitpricemeasurement).
|
|
12
|
+
* The `UnitPrice` component renders a string with a [UnitPrice](https://shopify.dev/themes/pricing-payments/unit-pricing) as the
|
|
13
|
+
* Storefront API's [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) with a reference unit from the Storefront API's [UnitPriceMeasurement object](/api/storefront/reference/products/unitpricemeasurement).
|
|
14
14
|
*/
|
|
15
15
|
export declare function UnitPrice<TTag extends keyof JSX.IntrinsicElements = 'div'>(props: JSX.IntrinsicElements[TTag] & UnitPriceProps<TTag>): JSX.Element | null;
|