/** * Copyright Aquera Inc 2023 * * This source code is licensed under the BSD-3-Clause license found in the * LICENSE file in the root directory of this source tree. */ import { CSSResultArray, TemplateResult, PropertyValues } from 'lit'; import { ErrorCorrectionLevel } from './nile-qr-code-utils.js'; import NileElement from '../internal/nile-element.js'; /** * Nile QR Code component. * * @tag nile-qr-code * * @csspart base - The canvas element used to draw the QR code. * * @fires nile-qr-image-error - Emitted when the center image fails to load. * * @example * */ export declare class NileQrCode extends NileElement { /** * The styles for QR Code. * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]` */ static get styles(): CSSResultArray; /** * The QR code's value — the text or URL to encode. */ value: string; /** * The size of the QR code, in pixels. */ size: number; /** * The fill color. This can be any valid CSS color, but not a CSS custom property. */ fill: string; /** * The background color. This can be any valid CSS color or `'transparent'`. * It cannot be a CSS custom property. */ background: string; /** * The edge radius of each module. Must be between 0 and 0.5. * Use this to create a rounded effect. */ radius: number; /** * The level of error correction to use. * - `'L'` — Low (~7%) * - `'M'` — Medium (~15%) * - `'Q'` — Quartile (~25%) * - `'H'` — High (~30%) * * When using an image overlay, `'H'` is recommended so the QR remains scannable. */ errorCorrection: ErrorCorrectionLevel; /** * The label for assistive devices to announce. * If unspecified, the `value` will be used instead. */ label: string; /** * URL of an image to overlay in the center of the QR code (e.g. a logo). * The image is drawn on top of the QR modules, so use `error-correction="H"` * to ensure the code remains scannable. */ image: string; /** * Size of the center image as a fraction of the overall QR code size * (0.1 – 0.4). Defaults to 0.25 (25% of the QR code). */ imageSize: number; /** * Padding around the center image in pixels. Creates a clear area * between the image and the surrounding QR modules. */ imagePadding: number; /** * Optional border radius for the center image in pixels. * Set to a high value for a circular mask. */ imageRadius: number; /** * Apply a linear gradient to the QR modules instead of a flat color. * Format: `"direction, color1, color2[, ...]"` where direction is an * angle in degrees (e.g. `"135, #6366f1, #ec4899"`). * When set, this overrides the `fill` property for module rendering. */ fillGradient: string; private _loadedImage; private _imageLoadPromise; private canvas; protected updated(changedProperties: PropertyValues): void; render(): TemplateResult; /** * Downloads the QR code as a PNG image. * @param filename - The name of the downloaded file (defaults to `'qr-code.png'`). */ download(filename?: string): void; /** * Returns the QR code canvas content as a data URL. * @param type - MIME type (defaults to `'image/png'`). */ toDataURL(type?: string): string; private loadImage; private drawQrCode; /** * Returns the fill style for QR modules — either a gradient or the flat fill color. */ private resolveModuleFill; private drawCenterImage; private drawRoundedModule; private drawRoundedRect; private clipRoundedRect; } export default NileQrCode; declare global { interface HTMLElementTagNameMap { 'nile-qr-code': NileQrCode; } }