UNPKG

solid-qr-code

Version:

Solid component to generate QR codes, based on qrcode.react

91 lines (88 loc) 3.05 kB
import { Component, ComponentProps } from 'solid-js'; type ImageSettings = { src: string; height: number; width: number; excavate: boolean; x?: number; y?: number; opacity?: number; }; declare const ErrorCorrectionLevel: { readonly LOW: "low"; readonly MEDIUM: "medium"; readonly QUARTILE: "quartile"; readonly HIGH: "high"; }; type ErrorCorrectionLevel = (typeof ErrorCorrectionLevel)[keyof typeof ErrorCorrectionLevel]; type ErrorCorrection = { ordinal: number; formatBits: number; }; declare const MaskType: { readonly ALTERNATING_TILES: 0; readonly ALTERNATING_HORIZONTAL_LINES: 1; readonly ALTERNATING_VERTICAL_LINES_TWO_GAP: 2; readonly DIAGONAL: 3; readonly FOUR_BY_TWO_RECTANGLE_ALTERNATING: 4; readonly FLOWER_IN_SQAURE: 5; readonly DIAGONAL_SQUARE: 6; readonly ALTERNATING_PUZZLE_PIECE: 7; }; type MaskType = (typeof MaskType)[keyof typeof MaskType]; type FrameOptions = { /** The value to be encoded. */ readonly value: string; /** The ECC level to be used. Default is L */ readonly level: ErrorCorrection | ErrorCorrectionLevel; /** The mask type. IF none is specified, one will be automatically chosen based on badness. */ readonly maskType?: MaskType; }; /** * Renders a QR code into an SVG html string. */ type QRSVGProps = FrameOptions & { readonly backgroundColor: string; readonly backgroundAlpha: number; readonly foregroundColor: string; readonly foregroundAlpha: number; readonly width: number; readonly height: number; readonly value: string; }; declare const QRCodeSVG: Component<QRSVGProps>; type QRCanvasProps = FrameOptions & { readonly backgroundColor: string; readonly backgroundAlpha: number; readonly foregroundColor: string; readonly foregroundAlpha: number; readonly width: number; readonly height: number; readonly x: number; readonly y: number; }; /** * Renders a QR code onto a canvas context */ declare const QRCodeCanvas: Component<QRCanvasProps>; type QRTextProps = FrameOptions & { /** The activated characters (black on a regular QR code.) */ readonly foregroundChar?: string | undefined; /** The non-activated characters (white on a regular QR code) */ readonly backgroundChar?: string | undefined; } & ComponentProps<"h1">; /** * Render a QR code in text format. */ declare const QRCodeText: Component<QRTextProps>; type QRTwoToneProps = FrameOptions & { readonly solidCharacter?: string | undefined; readonly solidTopCharacter?: string | undefined; readonly solidBottomCharacter?: string | undefined; readonly emptyCharacter?: string | undefined; } & ComponentProps<"h1">; /** * Renders a QR code with 4 different characters (to compact size) */ declare const QRCodeTwoTone: Component<QRTwoToneProps>; export { type ErrorCorrection, ErrorCorrectionLevel, type FrameOptions, type ImageSettings, MaskType, type QRCanvasProps, QRCodeCanvas, QRCodeSVG, QRCodeText, QRCodeTwoTone, type QRSVGProps };