@commercelayer/react-components
Version:
The Official Commerce Layer React Components
35 lines (34 loc) • 1.68 kB
TypeScript
import { type JSX } from "react";
import { type AddressValuesKeys } from "../../context/BillingAddressFormContext";
import type { AddressInputName, BaseInputComponentProps } from "../../typings/index";
type Props = {
/**
* The name of the input.
*/
name: Extract<AddressValuesKeys, AddressInputName>;
/**
* @deprecated
* Used to add a custom validation rule. Accept a regex as param.
*/
pattern?: RegExp;
} & Omit<BaseInputComponentProps, "name"> & Omit<JSX.IntrinsicElements["input"], "pattern"> & Omit<JSX.IntrinsicElements["textarea"], "children" | "pattern">;
/**
* The AddressInput component creates a form `input` related to a particular address attribute.
*
* It requires a `name` prop to define the field name associated with the input and accepts most of HTML `input` tag standard props.
*
* <span title="Name prop" type="info">
* The `name` prop must respect the convention of mentioning one of the available addresses forms (`billing_address` or `shipping_address` or `customer_address`) concatenated to the address attribute name with a `_` separator. Eg.: `billing_address_first_name`.
* </span>
*
* <span title="Requirement" type="warning">
* It must to be used inside either the `<BillingAddressForm>` or the `<ShippingAddressForm>` component.
* </span>
*
* <span title="Fields" type="info">
* Check the `addresses` resource from our [Core API documentation](https://docs.commercelayer.io/core/v/api-reference/addresses/object)
* for more details about the available attributes to render.
* </span>
*/
export declare function AddressInput(props: Props): JSX.Element | null;
export default AddressInput;