UNPKG

@commercelayer/react-components

Version:
35 lines (34 loc) 1.84 kB
import { type JSX } from 'react'; import type { BaseSelectComponentProps } from '../../typings/index'; import { type AddressValuesKeys } from '../../context/BillingAddressFormContext'; import { type Country } from '../../utils/countryStateCity'; type TCountryFieldName = 'billing_address_country_code' | 'shipping_address_country_code' | 'customer_address_country_code'; interface Props extends Omit<BaseSelectComponentProps, 'options' | 'name'>, Pick<JSX.IntrinsicElements['select'], 'className' | 'id' | 'style'> { name: Extract<AddressValuesKeys, TCountryFieldName>; required?: boolean; disabled?: boolean; /** * Optional country list to override default ones. */ countries?: Country[]; } /** * The AddressInput component creates a form `select` related to the `country_code` attribute of the `address` object. * * It requires a `name` prop to define the field name associated with the select and accepts most of HTML `select` 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 `country_code` address attribute with a `_` separator. Eg.: `billing_address_country_code`. * </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 AddressCountrySelector(props: Props): JSX.Element; export default AddressCountrySelector;