import type * as React from 'react'; import type { PrimitivePropsWithRef } from '../utils/primitive.cjs'; import type { ErrorCorrectionLevel } from '../utils/qr-encoder.cjs'; /** Error-correction level, in ascending order of redundancy: `'L'` ≈ 7% recoverable, `'M'` ≈ 15%, `'Q'` ≈ 25%, `'H'` ≈ 30%. */ export type QrCodeErrorCorrection = ErrorCorrectionLevel; /** @internal Encoded matrix distributed from {@link QrCode} to its parts via context. */ export interface QrCodeContextValue { /** The encoded symbol, indexed `[row][column]`; `true` is a dark module. */ matrix: boolean[][]; /** Modules along one edge — `4 × version + 17`, and the `viewBox` extent. */ size: number; /** The encoded payload, so parts can label themselves without re-threading the prop. */ value: string; /** The level the symbol was encoded at, so the Overlay can warn when it is not `'H'`. */ errorCorrection: QrCodeErrorCorrection; } /** Props for the {@link QrCode} root. */ export interface QrCodeProps extends PrimitivePropsWithRef<'div'> { /** The payload to encode as UTF-8 bytes — a URL, phone number, or Wi-Fi credential string. */ value: string; /** * Error-correction level; higher levels survive more damage at the cost of a denser symbol. * @default 'M' */ errorCorrection?: QrCodeErrorCorrection | undefined; /** * Force a symbol version (1–40), fixing the module count at `4 × version + 17`. * @default undefined — the smallest version whose capacity fits `value`. * @min 1 * @max 40 */ version?: number | undefined; /** * Fires when `value` cannot be encoded at the chosen level or pinned `version`. * @default undefined — the failure is silent. */ onEncodeError?: ((error: Error) => void) | undefined; /** * Visually hidden text rendered inside the root: `true` renders `value`, a string renders that text instead, `false` renders none. * @default true */ hiddenLabel?: boolean | string | undefined; /** * Content centred over the pattern in a derived `QrCodeOverlay`, ignored when `children` is given. * @default undefined */ overlay?: React.ReactNode | undefined; } /** Props for {@link QrCodeFrame}, the `` host. */ export interface QrCodeFrameProps extends PrimitivePropsWithRef<'svg'> { } /** Props for {@link QrCodePattern}, the single `` carrying every dark module. */ export interface QrCodePatternProps extends React.ComponentPropsWithRef<'path'> { } /** Props for {@link QrCodeOverlay}, the centred slot for a logo. */ export interface QrCodeOverlayProps extends React.ComponentPropsWithRef<'g'> { /** * Edge length of the overlay box in module units. * @default 7 */ extent?: number | undefined; }