ngx-kjua
Version:
Angular QR-Code generator component.
248 lines (241 loc) • 7.98 kB
TypeScript
import * as i0 from '@angular/core';
import { AfterViewInit, OnChanges, EventEmitter, ElementRef, SimpleChanges } from '@angular/core';
type KjuaRender = "image" | "svg" | "canvas";
type KjuaEcLevel = "L" | "M" | "Q" | "H";
type KjuaMode = "plain" | "label" | "image" | "imagelabel" | "clearimage" | "labelimage";
declare class NgxKjuaComponent implements AfterViewInit, OnChanges {
/**
* render method
*/
render: KjuaRender;
/**
* render pixel-perfect lines
*/
crisp: boolean;
/**
* minimum version= 1..40
*/
minVersion: number;
/**
* error correction level
*/
ecLevel: KjuaEcLevel;
/**
* size in pixel
*/
size: string | number;
/**
* pixel-ratio; undefined for devicePixelRatio
*/
ratio: number | null | undefined;
/**
* code color
*/
fill: string;
/**
* background color
*/
back: string;
/**
* content
*/
private _text;
set text(value: any);
/**
* rounded corners in pc= 0..100
*/
rounded: number;
/**
* quiet zone in modules
*/
quiet: number;
/**
* modes
*/
mode: KjuaMode;
/**
* label/image size and pos in pc= 0..100
*/
mSize: number | number[];
mPosX: number | number[];
mPosY: number | number[];
image: null | undefined | HTMLImageElement | string;
imageAsCode: boolean;
/**
* label
*/
label: string;
fontname: string;
fontcolor: string;
fontoutline: boolean;
/**
* If true, rendering is done inside "requestAnimationFrame"-call.
* Use this if you want to generate more than one code (e.g. batch)
*/
renderAsync: boolean;
/**
* If set, this css-class will be appended to the div-container that contains
* the qr-code (which is either an img or a canvas)
*/
cssClass: string | undefined;
/**
* an optional HTML-ID-attribute for the element (works only with render-mode SVG and image)
*/
elementId: string | undefined;
codeFinished: EventEmitter<any>;
div: ElementRef<HTMLElement>;
private viewInitialized;
constructor();
ngAfterViewInit(): void;
ngOnChanges(_changes: SimpleChanges): void;
get template(): Node;
renderCode(): void;
updateView(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxKjuaComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<NgxKjuaComponent, "ngx-kjua", never, { "render": { "alias": "render"; "required": false; }; "crisp": { "alias": "crisp"; "required": false; }; "minVersion": { "alias": "minVersion"; "required": false; }; "ecLevel": { "alias": "ecLevel"; "required": false; }; "size": { "alias": "size"; "required": false; }; "ratio": { "alias": "ratio"; "required": false; }; "fill": { "alias": "fill"; "required": false; }; "back": { "alias": "back"; "required": false; }; "text": { "alias": "text"; "required": false; }; "rounded": { "alias": "rounded"; "required": false; }; "quiet": { "alias": "quiet"; "required": false; }; "mode": { "alias": "mode"; "required": false; }; "mSize": { "alias": "mSize"; "required": false; }; "mPosX": { "alias": "mPosX"; "required": false; }; "mPosY": { "alias": "mPosY"; "required": false; }; "image": { "alias": "image"; "required": false; }; "imageAsCode": { "alias": "imageAsCode"; "required": false; }; "label": { "alias": "label"; "required": false; }; "fontname": { "alias": "fontname"; "required": false; }; "fontcolor": { "alias": "fontcolor"; "required": false; }; "fontoutline": { "alias": "fontoutline"; "required": false; }; "renderAsync": { "alias": "renderAsync"; "required": false; }; "cssClass": { "alias": "cssClass"; "required": false; }; "elementId": { "alias": "elementId"; "required": false; }; }, { "codeFinished": "codeFinished"; }, never, never, true, never>;
static ngAcceptInputType_imageAsCode: unknown;
static ngAcceptInputType_renderAsync: unknown;
}
declare class QrCodeHelper {
/**
* Make the code for creating an SMS.
* Number can be provided as number or string (useful for international format e.g. +1 for USA)
*
* @paramnumber
* @param text
*/
static makeSMS(number: number | string, text?: string): string;
/**
* Make the code for making a phone call
* Number can be provided as number or string (useful for international format e.g. +1 for USA)
*
* @param number
*/
static makeCall(number: number | string): string;
/**
* Make the code for encoding a location
*
* @param lat
* @param lon
* @param meters
*/
static makeGeo(lat: string, lon: string, meters?: number): string;
/**
* Make the code for encoding an event in iCal format
* You have to do the encoding for the begin and end by yourself (use moment.js!)
*
* @param description
* @param begin
* @param end
*/
static makeEvent(description: string, begin: string, end: string): string;
/**
* Make the code for an Email
*
* @param recipient
* @param subject
* @param text
*/
static makeEmail(recipient: string, subject?: string, text?: string): string;
/**
* Make the code that lets user login to a WiFi
* If no pass is provided, the WiFi is considered as not encrypted (no WPA)
*
* @param ssid
* @param pass
* @param hidden
*/
static makeWifi(ssid: string, pass?: string, hidden?: boolean): string;
/**
* Make the code that encodes contact information.
* Numbers can be provided as number or string (useful for international format e.g. +1 for USA)
* Encoding is done with MECARD-format and NOT VCard! VCard gives a longer string and therefore a
* bigger code which has a negative impact on readability for scanners. You can, of course, create
* a VCard string as well but the format is more complex.
*
* @param name
* @param telNumbers
* @param address, values separated with comma
* @param email
* @param url
*/
static makeContactMeCard(name: string, telNumbers?: string[] | number[], address?: string, email?: string, url?: string): string;
}
declare const kjua: (options: any) => any;
interface KjuaOptions {
/**
* Render the image as either SVG, canvas or PNG-image
*/
render?: "image" | "svg" | "canvas";
/**
* render pixel-perfect lines
*/
crisp?: boolean;
/**
* minimum version: 1..40
*/
minVersion?: number;
/**
* error correction level: 'L', 'M', 'Q' or 'H'
*/
ecLevel?: "L" | "M" | "Q" | "H";
/**
* size in pixel
*/
size?: number;
/**
* pixel-ratio, null for devicePixelRatio
*/
ratio?: number | null;
/**
* code color
*/
fill?: string;
/**
* background color
*/
back?: string;
/**
* content
*/
text?: string;
/**
* roundend corners in pc: 0..100
*/
rounded?: number;
/**
* quiet zone in modules
*/
quiet?: number;
/**
* modes: 'plain', 'label', 'image', 'imagelabel' or 'labelimage'
*/
mode?: "plain" | "label" | "image" | "imagelabel" | "labelimage" | "clearimage";
/**
* label/image size and pos in pc: 0..100
*/
mSize?: number | number[];
mPosX?: number | number[];
mPosY?: number | number[];
/**
* label
*/
label?: string;
fontname?: string;
fontcolor?: string;
fontoutline?: boolean;
/**
* image element
*/
image?: null | HTMLImageElement | string;
/**
* draw the image as part of the code
*/
imageAsCode?: boolean;
/**
* an optional HTML-ID-attribute for the element (works only with render-mode SVG and image)
*/
elementId?: string;
}
export { NgxKjuaComponent, QrCodeHelper, kjua };
export type { KjuaEcLevel, KjuaMode, KjuaOptions, KjuaRender };