Skip to content

Commit 2b0c3af

Browse files
fix js doc comments
1 parent 4e4f454 commit 2b0c3af

28 files changed

+517
-5048
lines changed

packages/hydrogen-react/src/CartLineProvider.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ type CartLinePartialDeep = PartialDeep<
1212

1313
export const CartLineContext = createContext<CartLinePartialDeep | null>(null);
1414

15-
/** @publicDocs */
15+
/**
16+
* The `useCartLine` hook provides access to the [CartLine object](https://shopify.dev/api/storefront/2026-01/objects/cartline) from the Storefront API. It must be a descendent of a `CartProvider` component.
17+
*/
1618
export function useCartLine(): CartLinePartialDeep {
1719
const context = useContext(CartLineContext);
1820

packages/hydrogen-react/src/MediaFile.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ import type {ModelViewerElement} from '@google/model-viewer/lib/model-viewer.js'
99
type BaseProps = React.HTMLAttributes<
1010
HTMLImageElement | HTMLVideoElement | HTMLIFrameElement | ModelViewerElement
1111
>;
12-
/**
13-
* MediaFile renders an `Image`, `Video`, `ExternalVideo`, or `ModelViewer` component. Use the `mediaOptions` prop to customize the props sent to each of these components.
14-
* @publicDocs
15-
*/
12+
/** @publicDocs */
1613
export interface MediaFileProps extends BaseProps {
1714
/** An object with fields that correspond to the Storefront API's [Media object](https://shopify.dev/api/storefront/reference/products/media). */
1815
data: PartialDeep<MediaEdgeType['node'], {recurseIntoArrays: true}>;
@@ -38,7 +35,6 @@ type MediaOptions = {
3835
* The `MediaFile` component renders the media for the Storefront API's
3936
* [Media object](https://shopify.dev/api/storefront/reference/products/media). It renders an `Image`, a
4037
* `Video`, an `ExternalVideo`, or a `ModelViewer` depending on the `__typename` of the `data` prop.
41-
* Use the `mediaOptions` prop to customize the props sent to each of these components.
4238
* @publicDocs
4339
*/
4440
export function MediaFile({

packages/hydrogen-react/src/ShopifyProvider.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ export function ShopifyProvider({
116116
);
117117
}
118118

119-
/** @publicDocs */
119+
/**
120+
* Provides access to the `shopifyConfig` prop of `<ShopifyProvider/>`. Must be a descendent of `<ShopifyProvider/>`.
121+
* @publicDocs
122+
*/
120123
export function useShop(): ShopifyContextValue {
121124
const shopContext = useContext(ShopifyContext);
122125
if (!shopContext) {
@@ -149,7 +152,10 @@ export interface ShopifyProviderBase {
149152
sameDomainForStorefrontApi?: boolean;
150153
}
151154

152-
/** @publicDocs */
155+
/**
156+
* Shopify-specific values that are used in various Hydrogen React components and hooks.
157+
* @publicDocs
158+
*/
153159
export interface ShopifyProviderProps extends ShopifyProviderBase {
154160
/** React children to render. */
155161
children?: ReactNode;

packages/hydrogen-react/src/analytics.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ import {
1919
} from './analytics-schema-custom-storefront-customer-tracking.js';
2020
import {getTrackingValues} from './tracking-utils.js';
2121

22-
/** @publicDocs */
22+
/**
23+
* Set user and session cookies and refresh the expiry time
24+
* @param event - The analytics event.
25+
* @param shopDomain - The Online Store domain to sent Shopify analytics under the same
26+
* top level domain.
27+
* @publicDocs
28+
*/
29+
2330
export function sendShopifyAnalytics(
2431
event: ShopifyAnalytics,
2532
shopDomain?: string,

packages/hydrogen-react/src/cookies-utils.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export function hexTime(): string {
5959
}
6060

6161
/**
62+
* Gets the values of _shopify_y and _shopify_s cookies from the provided cookie string.
6263
* @deprecated Use getTrackingValues instead.
6364
* @publicDocs
6465
*/

packages/hydrogen-react/src/flatten-connection.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,5 @@ type ConnectionNodes = {
9191
export interface ConnectionGenericForDoc {
9292
connection?: ConnectionEdges | ConnectionNodes;
9393
}
94-
/**
95-
* The return type of the `flattenConnection` utility: a flat array of nodes extracted from a Storefront API connection object.
96-
* @publicDocs
97-
*/
94+
/** @publicDocs */
9895
export type FlattenConnectionReturnForDoc = unknown[];

packages/hydrogen-react/src/optionValueDecoder.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ const V1_CONTROL_CHARS = {
2020
RANGE: '-',
2121
};
2222

23-
/**
24-
* A function type that determines whether a given option value combination is present in an encoded variant field from the Storefront API.
25-
* @publicDocs
26-
*/
23+
/** @publicDocs */
2724
export type IsOptionValueCombinationInEncodedVariant = (
2825
targetOptionValueCombination: number[],
2926
encodedVariantField: string,

packages/hydrogen-react/src/parse-metafield.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@ import type {PartialDeep, Simplify} from 'type-fest';
1313
import {flattenConnection} from './flatten-connection.js';
1414
import {RootASTNode as RichTextRootASTNode} from './RichText.types.js';
1515

16-
/** @publicDocs */
16+
/**
17+
* A function that uses `metafield.type` to parse the Metafield's `value` or `reference` or `references` (depending on the `metafield.type`) and places the result in `metafield.parsedValue`
18+
*
19+
* TypeScript developers can use the type `ParsedMetafields` from this package to get the returned object's type correct. For example:
20+
*
21+
* ```
22+
* parseMetafield<ParsedMetafields['boolean']>({type: 'boolean', value: 'false'}
23+
* ```
24+
* @publicDocs
25+
*/
1726
export function parseMetafield<ReturnGeneric>(
1827
metafield: PartialDeep<MetafieldBaseType, {recurseIntoArrays: true}>,
1928
): ReturnGeneric {

packages/hydrogen-react/src/tracking-utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export const cachedTrackingValues: {
1818
current: null | TrackingValues;
1919
} = {current: null};
2020

21-
/** @publicDocs */
21+
/**
22+
* Retrieves user session tracking values for analytics
23+
* and marketing from the browser environment.
24+
* @publicDocs
25+
*/
2226
export function getTrackingValues(): TrackingValues {
2327
// Overall behavior: Tracking values are returned in Server-Timing headers from
2428
// Storefront API responses, and we want to find and return these tracking values.

packages/hydrogen-react/src/useMoney.tsx

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,59 @@ export type UseMoneyValue = {
7272
withoutTrailingZerosAndCurrency: string;
7373
};
7474

75-
/** @publicDocs */
75+
/**
76+
* The `useMoney` hook takes a [MoneyV2 object from the Storefront API](https://shopify.dev/docs/api/storefront/2026-01/objects/MoneyV2)
77+
* or a [MoneyV2 object from the Customer Account API](https://shopify.dev/docs/api/customer/2026-01/objects/moneyv2) and returns a
78+
* default-formatted string of the amount with the correct currency indicator, along with some of the parts provided by
79+
* [Intl.NumberFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat).
80+
* Uses `locale` from `ShopifyProvider`
81+
* &nbsp;
82+
* @see {@link https://shopify.dev/api/hydrogen/hooks/usemoney}
83+
* @example initialize the money object
84+
* ```ts
85+
* const money = useMoney({
86+
* amount: '100.00',
87+
* currencyCode: 'USD'
88+
* })
89+
* ```
90+
* &nbsp;
91+
*
92+
* @example basic usage, outputs: $100.00
93+
* ```ts
94+
* money.localizedString
95+
* ```
96+
* &nbsp;
97+
*
98+
* @example without currency, outputs: 100.00
99+
* ```ts
100+
* money.amount
101+
* ```
102+
* &nbsp;
103+
*
104+
* @example without trailing zeros, outputs: $100
105+
* ```ts
106+
* money.withoutTrailingZeros
107+
* ```
108+
* &nbsp;
109+
*
110+
* @example currency name, outputs: US dollars
111+
* ```ts
112+
* money.currencyCode
113+
* ```
114+
* &nbsp;
115+
*
116+
* @example currency symbol, outputs: $
117+
* ```ts
118+
* money.currencySymbol
119+
* ```
120+
* &nbsp;
121+
*
122+
* @example without currency and without trailing zeros, outputs: 100
123+
* ```ts
124+
* money.withoutTrailingZerosAndCurrency
125+
* ```
126+
* @publicDocs
127+
*/
76128
export function useMoney(money: MoneyV2): UseMoneyValue {
77129
const {countryIsoCode, languageIsoCode} = useShop();
78130
const locale = languageIsoCode.includes('_')

0 commit comments

Comments
 (0)