UNPKG

react-credit-cards-library

Version:

A lightweight, customizable React component library for rendering credit card forms with dynamic card issuer detection, input formatting, and responsive design. Built with TypeScript for type safety and flexibility.

46 lines (40 loc) 1.65 kB
declare const ISSUERS: readonly ["visa", "mastercard", "amex", "diners", "elo", "discover", "jcb", "sodexo", "vr", "ticket_vr", "ticket_va", "alelo", "Unknown"]; type Issuer = (typeof ISSUERS)[number]; declare const FOCUSED_FIELDS: readonly ["number", "name", "expiry", "cvc", ""]; type Focused = (typeof FOCUSED_FIELDS)[number]; type Locale = "en" | "pt-BR" | "es"; interface CardSizes { width?: string; height?: string; maxWidth?: string; maxHeight?: string; } interface CreditCardProps { number: string; name: string; expiry: string; cvc: string; focus: Focused; locale?: Locale; richColors?: boolean; cardSizes?: CardSizes; } /** Memoized, typed as a plain function component for cross-version @types/react compat */ declare const _default: (props: CreditCardProps) => JSX.Element; /** * Formats a credit card number based on the issuer type. * * @param value - The raw credit card number input. * @param issuer - The type of the credit card issuer. * @returns The formatted credit card number with grouping and bullet placeholders. */ declare const formatCardNumber: (value: string, issuer: Issuer) => string; /** * Identifies the issuer of a credit, debit, or benefit card. * * @param cardNumber - The credit card number, which may contain spaces or hyphens. * @returns The name of the card issuer (e.g., "visa", "mastercard", etc.) * or "Unknown" if no issuer matches the card number. */ declare function getCardIssuer(cardNumber: string): Issuer; export { _default as CreditCard, FOCUSED_FIELDS, type Focused, ISSUERS, type Issuer, formatCardNumber, getCardIssuer };