sard-uniapp
Version:
sard-uniapp 是一套基于 Uniapp + Vue3 框架开发的兼容多端的 UI 组件库
74 lines (73 loc) • 2.34 kB
TypeScript
import { type CanvasFontWeight, type CanvasFontStyle, type CanvasTextAlign } from './canvas';
export declare const BarcodeFormatList: readonly ["CODE128", "EAN13", "UPC-A", "ITF14"];
export type BarcodeFormat = (typeof BarcodeFormatList)[number];
export declare const BarcodeTextPositionList: readonly ["top", "bottom"];
export type BarcodeTextPosition = (typeof BarcodeTextPositionList)[number];
export interface BarcodeOptions {
format?: BarcodeFormat;
width?: number;
height?: number;
color?: string;
background?: string;
displayValue?: boolean;
text?: string;
textPosition?: BarcodeTextPosition;
textAlign?: CanvasTextAlign;
textMargin?: number;
fontStyle?: CanvasFontStyle;
fontWeight?: CanvasFontWeight;
fontSize?: number;
fontFamily?: string;
margin?: number;
marginTop?: number;
marginBottom?: number;
marginLeft?: number;
marginRight?: number;
ean128?: boolean;
flat?: boolean;
lastChar?: string;
}
export interface BarcodeRenderOptions {
format: BarcodeFormat;
width: number;
height: number;
lineColor: string;
background: string;
displayValue: boolean;
text?: string;
textPosition: BarcodeTextPosition;
textAlign: CanvasTextAlign;
textMargin: number;
fontStyle: CanvasFontStyle;
fontWeight: CanvasFontWeight;
fontSize: number;
fontFamily: string;
margin: number;
marginTop: number;
marginBottom: number;
marginLeft: number;
marginRight: number;
ean128?: boolean;
flat?: boolean;
lastChar?: string;
}
export interface BarcodeEncoding {
data: string;
text: string;
options: BarcodeRenderOptions;
}
export interface BarcodeLayoutSegment extends BarcodeEncoding {
width: number;
height: number;
textWidth: number;
barcodeWidth: number;
barcodePadding: number;
}
export interface BarcodeLayout {
width: number;
height: number;
segments: BarcodeLayoutSegment[];
}
export declare function normalizeBarcodeOptions(options?: BarcodeOptions): BarcodeRenderOptions;
export declare function barcode(value: string, options?: BarcodeOptions): BarcodeEncoding[];
export declare function calculateBarcodeLayout(encodings: BarcodeEncoding[], measureText: (text: string, options: BarcodeRenderOptions) => number): BarcodeLayout;