@sv-print/hiprint 0.2.22 → 0.2.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,31 +1,186 @@
1
1
  export declare function autoConnect(callback?: (status?: boolean, msg?: any) => void);
2
2
 
3
+ export declare interface ConfigOptions extends Record<string, any> {
4
+ optionItems?: any[];
5
+ movingDistance?: number; //鼠标拖动一次移动的距离,默认1.5pt
6
+ paperHeightTrim?: number; //纸张html 的高度等于真实高度-1
7
+ showPosition?: boolean; //显示坐标位置
8
+ positionLineMode?: boolean; //坐标显示在线上的
9
+ positionUnit?: boolean; //显示坐标单位
10
+ showSizeBox?: boolean; //显示宽高box
11
+ adsorbMin?: number; //吸附最小距离pt
12
+ showAdsorbLine?: boolean; //显示吸附线
13
+ adsorbLineMin?: number; //吸附线显示最小距离pt
14
+ paperNumberContinue?: boolean; //页码续排
15
+ disableNoDraggableSize?: boolean; //锁定元素不可修改宽高大小
16
+ }
17
+
3
18
  export declare class defaultElementTypeProvider {
4
19
  constructor();
5
20
  }
6
21
 
7
22
  export declare function disAutoConnect();
8
23
 
24
+ export declare interface FieldJson {
25
+ field: string;
26
+ text: string;
27
+ }
28
+
29
+ export declare interface FontJson {
30
+ title: string;
31
+ value: string;
32
+ }
33
+
34
+ export declare type Hiprint = hiprint;
35
+
9
36
  export declare class hiprint {
10
- static init: (...args: any) => void;
11
- static register: (...args: any) => string;
12
- static setConfig: (...args: any) => void;
13
- static updateElementType: (...args: any) => void;
14
- static hiwebSocket: any;
15
- static refreshPrinterList: (...args: any) => void;
16
- static getAddress: (...args: any) => void;
37
+ static init: (options: InitOptions) => void;
38
+ static register: (options: RegisterOptions) => string;
39
+ static setConfig: (options: ConfigOptions) => void;
40
+ static getOptionItems: Record<string, any>;
41
+ static updateElementType: <T>(tid: string, callback: (type: T) => T) => void;
42
+ static hiwebSocket: HiWebSocket;
43
+ static refreshPrinterList: (callback: (printerList: PrinterInfo[]) => void) => void;
44
+ static getAddress: (type: string, callback: (addr: Record<string, any>, e: any) => void) => void;
17
45
  static ippPrint: (...args: any) => void;
18
46
  static ippRequest: (...args: any) => void;
19
- static PrintElementTypeManager: any;
20
- static PrintElementTypeGroup: any;
21
- static PrintTemplate: PrintTemplate;
22
- static print: (...args: any) => any;
23
- static print2: (...args: any) => any;
24
- static getHtml: (...args: any) => any;
47
+ static PrintElementTypeManager: PrintElementTypeManager;
48
+ static PrintElementTypeGroup: PrintElementTypeGroup;
49
+ static PrintTemplate: typeof PrintTemplate;
50
+ static print: (data: Templates) => void;
51
+ static print2: (data: Templates, printSuccess: (e: any) => void, printError: (e: any) => void) => void;
52
+ static getHtml: (data: Templates) => any;
53
+ }
54
+
55
+ export declare interface HiWebSocket {
56
+ opened: boolean;
57
+ host: string;
58
+ setHost: (host: string, token: string, callback: (connect: boolean, e: any) => void) => void;
59
+ start: (callback: (connect: boolean, e: any) => void) => void;
60
+ stop: () => void;
61
+ }
62
+
63
+ export declare interface InitOptions extends Record<string, any> {
64
+ providers?: any[];
65
+ token?: string;
66
+ }
67
+
68
+ export declare interface PanelJson {
69
+ index?: number;
70
+ name?: string;
71
+ paperType?: string;
72
+ height?: number;
73
+ width?: number;
74
+ paperHeader?: number;
75
+ paperFooter?: number;
76
+ printElements?: any[];
77
+ paperNumberLeft?: number;
78
+ paperNumberTop?: number;
79
+ paperNumberDisabled?: boolean;
80
+ paperNumberContinue?: boolean;
81
+ paperNumberFormat?: string;
82
+ panelPageRule?: string;
83
+ orient?: 1 | 2;
84
+ overPrintOptions?: {
85
+ content?: string;
86
+ opacity?: 0.7;
87
+ type?: 1 | 2;
88
+ };
89
+ watermarkOptions?: {
90
+ content?: string;
91
+ fillStyle?: string;
92
+ fontSize?: string;
93
+ rotate?: boolean;
94
+ width?: number;
95
+ height?: number;
96
+ timestamp?: boolean;
97
+ format?: string;
98
+ };
99
+ panelLayoutOptions?: {
100
+ layoutType?: "column" | "row";
101
+ layoutRowGap?: number;
102
+ layoutColumnGap?: number;
103
+ };
104
+ }
105
+
106
+ export declare interface PaperJson {
107
+ type: string;
108
+ width: number;
109
+ height: number;
110
+ }
111
+
112
+ export declare interface Print2Options extends Record<string, any> {
113
+ styleHandler?: () => string;
114
+ printer?: string;
115
+ silent?: boolean;
116
+ printBackground?: boolean;
117
+ color?: boolean;
118
+ copies?: number;
119
+ landscape?: boolean;
120
+ pageSize?:
121
+ | string
122
+ | {
123
+ height: number;
124
+ width: number;
125
+ };
126
+ scaleFactor?: number;
127
+ pagesPerSheet?: number;
128
+ collate?: boolean;
129
+ pageRanges?: {
130
+ from: number;
131
+ to: number;
132
+ }[];
133
+ duplexMode?: "simplex" | "shortEdge" | "longEdge";
134
+ dpi?: Record<string, number>;
135
+ margins?: {
136
+ /**
137
+ * Can be `default`, `none`, `printableArea`, or `custom`. If `custom` is chosen,
138
+ * you will also need to specify `top`, `bottom`, `left`, and `right`.
139
+ */
140
+ marginType?: "default" | "none" | "printableArea" | "custom";
141
+ /**
142
+ * The top margin of the printed web page, in pixels.
143
+ */
144
+ top?: number;
145
+ bottom?: number;
146
+ left?: number;
147
+ right?: number;
148
+ };
149
+ header?: string;
150
+ footer?: string;
151
+ }
152
+
153
+ export declare type PrintData = Record<string, any> | Record<string, any>[];
154
+
155
+ export declare interface PrintElementType extends Record<string, any> {
156
+ tid: string;
157
+ type: string;
158
+ title: string;
159
+ data?: any;
160
+ field?: any;
161
+ options?: Record<string, any>;
162
+ }
163
+
164
+ export declare interface PrintElementTypeGroup {
165
+ constructor(name: string, list: PrintElementType[]);
166
+ }
167
+
168
+ export declare interface PrintElementTypeManager {
169
+ buildByHtml(el: any): void;
170
+ build(el: any, type: string, render: (list: any) => any): void;
25
171
  }
26
172
 
27
- export declare interface PrintTemplate {
28
- constructor(options?: any);
173
+ export declare interface PrinterInfo {
174
+ name: string; // 打印机名称
175
+ displayName: string; // 显示名称
176
+ description: string; // 描述
177
+ isDefault: boolean; // 是否为默认打印机
178
+ status: number; // 状态码
179
+ options: Record<string, any>; // 打印机选项
180
+ }
181
+
182
+ export declare class PrintTemplate {
183
+ constructor(options: PrintTemplateOptions);
29
184
  id: string;
30
185
  history: boolean;
31
186
  historyPos: number;
@@ -33,40 +188,114 @@ export declare interface PrintTemplate {
33
188
  container: any;
34
189
  editingPanel: Array<any>;
35
190
  printPanels: Array<any>;
36
- design: (...args: any) => any;
191
+ design: (container: string, { grid: boolean }) => any;
37
192
  buildPagination: (container: string) => void;
38
- update: (...args: any) => any;
39
- print: (...args: any) => any;
40
- print2: (...args: any) => any;
41
- getHtml: (...args: any) => any;
42
- clear: () => any;
43
- rotatePaper: () => any;
44
- setPaper: () => any;
45
- getOrient: () => any;
46
- zoom: (...args: any) => any;
193
+ update: (json: PrintTemplateJson, panelIndex: number, history: boolean) => any;
194
+ print: (
195
+ data: PrintData,
196
+ options?: { leftOffset?: number; topOffset?: number },
197
+ ext?: {
198
+ callback?: () => void;
199
+ styleHandler?: () => string;
200
+ }
201
+ ) => void;
202
+ print2: (data: PrintData, options?: Print2Options) => void;
203
+ getHtml: (data: PrintData) => any;
204
+ toPdf: (data: PrintData, optoins?: ToPdfOptions) => any;
205
+ toImage: (data: PrintData, optoins?: ToImageOptions) => any;
206
+ clear: () => void;
207
+ rotatePaper: () => void;
208
+ setPaper: (width: number, height: number) => void;
209
+ getOrient: () => number;
210
+ zoom: (scale: number) => void;
47
211
  undo: () => any;
48
212
  redo: () => any;
49
- getPrintStyle: () => any;
50
- getPaperType: () => any;
51
- copyJson: () => any;
52
- cutJson: () => any;
213
+ getPrintStyle: () => string;
214
+ getPaperType: () => string;
215
+ copyJson: () => void;
216
+ cutJson: () => void;
53
217
  canPaste: () => boolean;
54
- getSelectEls: (...args: any) => any;
55
- updateOption: (...args: any) => any;
56
- setElsAlign: (align: string, toPaper?: boolean) => any;
57
- setElsSpace: (...args: any) => any;
218
+ getSelectEls: () => any[];
219
+ updateOption: (key: string, val: any) => void;
220
+ setElsAlign: (align: string, toPaper?: boolean) => void;
221
+ setElsSpace: (dis: number, isHor: boolean) => void;
58
222
  selectAllEls: (reverse?: boolean) => any;
59
223
  addPrintElementToPaperByTid: (tid: string, left?: number, top?: number) => any;
60
- getJson: (...args: any) => any;
61
- getJsonTid: (...args: any) => any;
62
- getPrinterList: (...args: any) => any;
224
+ getJson: () => PrintTemplateJson;
225
+ getJsonTid: () => PrintTemplateJson;
226
+ getPrinterList: () => PrinterInfo[];
227
+ getFieldsInPanel: () => any[];
228
+ getTestData: () => PrintData;
63
229
  on: (...args: any) => any;
64
- setFields: (...args: any) => any;
65
- setFontList: (...args: any) => any;
66
- setPaperList: (...args: any) => any;
67
- setOnImageChooseClick: (...args: any) => any;
68
- onDataChanged: (...args: any) => any;
230
+ setFields: (fields: FieldJson[]) => void;
231
+ setFontList: (fontList: FontJson[]) => void;
232
+ setPaperList: (paperList: PaperJson[]) => void;
233
+ setOnImageChooseClick: (callback: (target: HTMLElement) => void) => void;
234
+ setCustomDataFun: (fun: (data: any, field: string, printData: PrintData) => any) => void;
235
+ onDataChanged: (type: string, json: PrintTemplateJson) => void;
69
236
  onZoomChange: (zoom: number) => void;
70
237
  }
71
238
 
239
+ export declare interface PrintTemplateJson {
240
+ panels?: PanelJson[];
241
+ }
242
+
243
+ export declare interface PrintTemplateOptions extends Record<string, any> {
244
+ template?: PrintTemplateJson | Record<string, any>;
245
+ settingContainer?: string;
246
+ paginationContainer?: string;
247
+ fields?: FieldJson[];
248
+ fontList?: FontJson[];
249
+ paperList?: PaperJson[];
250
+ history?: boolean;
251
+ dataMode?: 1 | 2;
252
+ onDataChanged?: (type: string, data: PrintData) => void;
253
+ onUpdateError?: (e: any) => void;
254
+ onImageChooseClick?: (target: HTMLElement) => void;
255
+ onPanelAddClick?: (panel: any, createPanel: any) => void;
256
+ onFunctionClick?: (option: any, printElement: any, event: any) => void;
257
+ onZoomChange?: (scale: number) => void;
258
+ customDataFun?: (ele: any, data: any, field: string, printData: PrintData) => any;
259
+ beforeDragIn?: (printTemplate: any, panel: any, ele: any) => boolean;
260
+ }
261
+
262
+ export declare interface RegisterOptions extends Record<string, any> {
263
+ authKey?: String;
264
+ plugins?: any[];
265
+ }
266
+
267
+ export declare interface Templates {
268
+ templates: {
269
+ templates: PrintTemplate;
270
+ data: PrintData;
271
+ options?: Record<string, any>;
272
+ }[];
273
+ options?: Print2Options;
274
+ }
275
+
276
+ export declare interface ToImageOptions {
277
+ isDownload?: boolean;
278
+ name?: string;
279
+ leftOffset?: number;
280
+ topOffset?: number;
281
+ onProgress?: (cur: number, total: number) => void;
282
+ limit?: number;
283
+ quality?: number;
284
+ pixelRatio?: number;
285
+ type?: string;
286
+ toType?: "url" | "blob" | string;
287
+ }
288
+
289
+ export declare interface ToPdfOptions {
290
+ isDownload?: boolean;
291
+ name?: string;
292
+ leftOffset?: number;
293
+ topOffset?: number;
294
+ onProgress?: (cur: number, total: number) => void;
295
+ limit?: number;
296
+ quality?: number;
297
+ pixelRatio?: number;
298
+ type?: string;
299
+ }
300
+
72
301
  export { }