UNPKG

@shopify/hydrogen-react

Version:

React components, hooks, and utilities for creating custom Shopify storefronts

30 lines (29 loc) 1.88 kB
import { type ReactNode } from 'react'; import type { MoneyV2, UnitPriceMeasurement } from './storefront-api-types.js'; import type { PartialDeep } from 'type-fest'; interface CustomProps<ComponentGeneric extends React.ElementType> { /** An HTML tag or React Component to be rendered as the base element wrapper. The default is `div`. */ as?: ComponentGeneric; /** An object with fields that correspond to the Storefront API's [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2). */ data: PartialDeep<MoneyV2, { recurseIntoArrays: true; }>; /** Whether to remove the currency symbol from the output. */ withoutCurrency?: boolean; /** Whether to remove trailing zeros (fractional money) from the output. */ withoutTrailingZeros?: boolean; /** A [UnitPriceMeasurement object](https://shopify.dev/api/storefront/latest/objects/unitpricemeasurement). */ measurement?: PartialDeep<UnitPriceMeasurement, { recurseIntoArrays: true; }>; /** Customizes the separator between the money output and the measurement output. Used with the `measurement` prop. Defaults to `'/'`. */ measurementSeparator?: ReactNode; } export declare type MoneyProps<ComponentGeneric extends React.ElementType> = CustomProps<ComponentGeneric> & Omit<React.ComponentPropsWithoutRef<ComponentGeneric>, keyof CustomProps<ComponentGeneric>>; /** * The `Money` component renders a string of the Storefront API's * [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) according to the * `locale` in the `ShopifyProvider` component. */ export declare function Money<ComponentGeneric extends React.ElementType>({ data, as, withoutCurrency, withoutTrailingZeros, measurement, measurementSeparator, ...passthroughProps }: MoneyProps<ComponentGeneric>): JSX.Element; export {};