ngx-print 20.1.0-beta.3 → 20.1.0-beta.4

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/index.d.ts DELETED
@@ -1,241 +0,0 @@
1
- import * as rxjs from 'rxjs';
2
- import { Subject } from 'rxjs';
3
- import * as i0 from '@angular/core';
4
-
5
- declare class PrintOptions {
6
- printSectionId: string;
7
- printTitle: string;
8
- useExistingCss: boolean;
9
- bodyClass: string;
10
- openNewTab: boolean;
11
- previewOnly: boolean;
12
- closeWindow: boolean;
13
- printDelay: number;
14
- constructor(options?: Partial<PrintOptions>);
15
- }
16
-
17
- declare class PrintBase {
18
- private nonce;
19
- private _printStyle;
20
- private _styleSheetFile;
21
- protected printComplete: Subject<void>;
22
- /**
23
- * Sets the print styles based on the provided values.
24
- *
25
- * @param {Object} values - Key-value pairs representing print styles.
26
- * @protected
27
- */
28
- protected setPrintStyle(values: {
29
- [key: string]: {
30
- [key: string]: string;
31
- };
32
- }): void;
33
- /**
34
- *
35
- *
36
- * @returns the string that create the stylesheet which will be injected
37
- * later within <style></style> tag.
38
- *
39
- * -join/replace to transform an array objects to css-styled string
40
- */
41
- returnStyleValues(): string;
42
- /**
43
- * @returns string which contains the link tags containing the css which will
44
- * be injected later within <head></head> tag.
45
- *
46
- */
47
- private returnStyleSheetLinkTags;
48
- /**
49
- * Sets the style sheet file based on the provided CSS list.
50
- *
51
- * @param {string} cssList - CSS file or list of CSS files.
52
- * @protected
53
- */
54
- protected setStyleSheetFile(cssList: string): void;
55
- /**
56
- * Updates the default values for input elements.
57
- *
58
- * @param {HTMLCollectionOf<HTMLInputElement>} elements - Collection of input elements.
59
- * @private
60
- */
61
- private updateInputDefaults;
62
- /**
63
- * Updates the default values for select elements.
64
- *
65
- * @param {HTMLCollectionOf<HTMLSelectElement>} elements - Collection of select elements.
66
- * @private
67
- */
68
- private updateSelectDefaults;
69
- /**
70
- * Updates the default values for textarea elements.
71
- *
72
- * @param {HTMLCollectionOf<HTMLTextAreaElement>} elements - Collection of textarea elements.
73
- * @private
74
- */
75
- private updateTextAreaDefaults;
76
- /**
77
- * Converts a canvas element to an image and returns its HTML string.
78
- *
79
- * @param {HTMLCanvasElement} element - The canvas element to convert.
80
- * @returns {string} - HTML string of the image.
81
- * @private
82
- */
83
- private canvasToImageHtml;
84
- /**
85
- * Includes canvas contents in the print section via img tags.
86
- *
87
- * @param {HTMLCollectionOf<HTMLCanvasElement>} elements - Collection of canvas elements.
88
- * @private
89
- */
90
- private updateCanvasToImage;
91
- /**
92
- * Retrieves the HTML content of a specified printing section.
93
- *
94
- * @param {string} printSectionId - Id of the printing section.
95
- * @returns {string | null} - HTML content of the printing section, or null if not found.
96
- * @private
97
- */
98
- private getHtmlContents;
99
- /**
100
- * Retrieves the HTML content of elements with the specified tag.
101
- *
102
- * @param {keyof HTMLElementTagNameMap} tag - HTML tag name.
103
- * @returns {string} - Concatenated outerHTML of elements with the specified tag.
104
- * @private
105
- */
106
- private getElementTag;
107
- protected notifyPrintComplete(): void;
108
- /**
109
- * Prints the specified content using the provided print options.
110
- *
111
- * @param {PrintOptions} printOptions - Options for printing.
112
- * @public
113
- */
114
- protected print(printOptions: PrintOptions): void;
115
- static ɵfac: i0.ɵɵFactoryDeclaration<PrintBase, never>;
116
- static ɵprov: i0.ɵɵInjectableDeclaration<PrintBase>;
117
- }
118
-
119
- /**
120
- * Service for handling printing functionality in Angular applications.
121
- * Extends the base printing class (PrintBase).
122
- *
123
- * @export
124
- * @class NgxPrintService
125
- * @extends {PrintBase}
126
- */
127
- declare class NgxPrintService extends PrintBase {
128
- printComplete$: rxjs.Observable<void>;
129
- /**
130
- * Initiates the printing process using the provided print options.
131
- *
132
- * @param {PrintOptions} printOptions - Options for configuring the printing process.
133
- * @memberof NgxPrintService
134
- * @returns {void}
135
- */
136
- print(printOptions: PrintOptions): void;
137
- /**
138
- * Sets the print style for the printing process.
139
- *
140
- * @param {{ [key: string]: { [key: string]: string } }} values - A dictionary representing the print styles.
141
- * @memberof NgxPrintService
142
- * @setter
143
- */
144
- set printStyle(values: {
145
- [key: string]: {
146
- [key: string]: string;
147
- };
148
- });
149
- /**
150
- * Sets the stylesheet file for the printing process.
151
- *
152
- * @param {string} cssList - A string representing the path to the stylesheet file.
153
- * @memberof NgxPrintService
154
- * @setter
155
- */
156
- set styleSheetFile(cssList: string);
157
- static ɵfac: i0.ɵɵFactoryDeclaration<NgxPrintService, never>;
158
- static ɵprov: i0.ɵɵInjectableDeclaration<NgxPrintService>;
159
- }
160
-
161
- declare class NgxPrintDirective extends PrintBase {
162
- private printOptions;
163
- /**
164
- * Prevents the print dialog from opening on the window
165
- *
166
- * @memberof NgxPrintDirective
167
- */
168
- set previewOnly(value: boolean);
169
- /**
170
- *
171
- *
172
- * @memberof NgxPrintDirective
173
- */
174
- set printSectionId(value: string);
175
- /**
176
- *
177
- *
178
- * @memberof NgxPrintDirective
179
- */
180
- set printTitle(value: string);
181
- /**
182
- *
183
- *
184
- * @memberof NgxPrintDirective
185
- */
186
- set useExistingCss(value: boolean);
187
- /**
188
- * A delay in milliseconds to force the print dialog to wait before opened. Default: 0
189
- *
190
- * @memberof NgxPrintDirective
191
- */
192
- set printDelay(value: number);
193
- /**
194
- * Whether to close the window after print() returns.
195
- *
196
- */
197
- set closeWindow(value: boolean);
198
- /**
199
- * Class attribute to apply to the body element.
200
- *
201
- */
202
- set bodyClass(value: string);
203
- /**
204
- * Whether to open a new window or default to new window.
205
- *
206
- */
207
- set openNewTab(value: boolean);
208
- /**
209
- *
210
- *
211
- * @memberof NgxPrintDirective
212
- */
213
- set printStyle(values: {
214
- [key: string]: {
215
- [key: string]: string;
216
- };
217
- });
218
- /**
219
- * @memberof NgxPrintDirective
220
- * @param cssList
221
- */
222
- set styleSheetFile(cssList: string);
223
- /**
224
- *
225
- *
226
- * @memberof NgxPrintDirective
227
- */
228
- print(): void;
229
- readonly printCompleted: i0.OutputEmitterRef<void>;
230
- static ɵfac: i0.ɵɵFactoryDeclaration<NgxPrintDirective, never>;
231
- static ɵdir: i0.ɵɵDirectiveDeclaration<NgxPrintDirective, "[ngxPrint]", never, { "previewOnly": { "alias": "previewOnly"; "required": false; }; "printSectionId": { "alias": "printSectionId"; "required": false; }; "printTitle": { "alias": "printTitle"; "required": false; }; "useExistingCss": { "alias": "useExistingCss"; "required": false; }; "printDelay": { "alias": "printDelay"; "required": false; }; "closeWindow": { "alias": "closeWindow"; "required": false; }; "bodyClass": { "alias": "bodyClass"; "required": false; }; "openNewTab": { "alias": "openNewTab"; "required": false; }; "printStyle": { "alias": "printStyle"; "required": false; }; "styleSheetFile": { "alias": "styleSheetFile"; "required": false; }; }, { "printCompleted": "printCompleted"; }, never, never, true, never>;
232
- }
233
-
234
- declare class NgxPrintModule {
235
- static ɵfac: i0.ɵɵFactoryDeclaration<NgxPrintModule, never>;
236
- static ɵmod: i0.ɵɵNgModuleDeclaration<NgxPrintModule, never, [typeof NgxPrintDirective], [typeof NgxPrintDirective]>;
237
- static ɵinj: i0.ɵɵInjectorDeclaration<NgxPrintModule>;
238
- }
239
-
240
- export { NgxPrintDirective, NgxPrintModule, NgxPrintService, PrintOptions };
241
- //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sources":["../../src/lib/print-options.ts","../../src/lib/ngx-print.base.ts","../../src/lib/ngx-print.service.ts","../../src/lib/ngx-print.directive.ts","../../src/lib/ngx-print.module.ts"],"sourcesContent":[null,null,null,null,null],"names":["_angular_core"],"mappings":";;;;AAAA,cAAA,YAAA;;;;;;;;;AAUc,0BAAA,OAAA,CAAA,YAAA;AAKb;;ACXD,cAAA,SAAA;;;;;AAWE;;;;;AAKG;AACH;;AAAmD;;AAAyB;AAS5E;;;;;;;AAOG;;AAMH;;;;AAIG;AACH;AAIA;;;;;AAKG;AACH;AAiBA;;;;;AAKG;AACH;AAQA;;;;;AAKG;AACH;AAUA;;;;;AAKG;AACH;AAOA;;;;;;AAMG;AACH;AAKA;;;;;AAKG;AACH;AAQA;;;;;;AAMG;AACH;AAiBA;;;;;;AAMG;AACH;AAUA;AAIA;;;;;AAKG;AACH,kCAAA,YAAA;;;AAqFD;;ACpRD;;;;;;;AAOG;AACH,cAAA,eAAA,SAAA,SAAA;AAIE,oBAAc,IAAA,CAAA,UAAA;AACd;;;;;;AAMG;AACI,wBAAA,YAAA;AAKP;;;;;;AAMG;;;AACuC;;;AAI1C;;;;;;AAMG;AACH;;;AAGD;;AC9CD,cAAA,iBAAA,SAAA,SAAA;;AAME;;;;AAIG;AACH;AAIA;;;;AAIG;AACH;AAIA;;;;AAIG;AACH;AAIA;;;;AAIG;AACH;AAIA;;;;AAIG;AACH;AAIA;;;AAGG;AACH;AAIA;;;AAGG;AACH;AAIA;;;AAGG;AACH;AAIA;;;;AAIG;;;AAEuC;;;AAI1C;;;AAGG;AACH;AAKA;;;;AAIG;AAEI;6BAOgBA,EAAA,CAAA,gBAAA;;;AACxB;;AC7GD,cAAA,cAAA;;;;AAI8B;;;;"}
@@ -1,42 +0,0 @@
1
- (function () {
2
- function initPrint(printOptions) {
3
- function triggerPrint() {
4
- window.removeEventListener('load', triggerPrint, false);
5
- if (!printOptions.previewOnly) {
6
- setTimeout(() => {
7
- window.print();
8
- if (printOptions.closeWindow) window.close();
9
- }, printOptions.printDelay || 0);
10
- }
11
- }
12
-
13
- function afterPrint() {
14
- if (window.opener) {
15
- window.opener.postMessage({ type: 'print-complete' }, '*');
16
- }
17
- if (printOptions.closeWindow) window.close();
18
- }
19
-
20
- window.addEventListener('load', triggerPrint, false);
21
- window.addEventListener('afterprint', afterPrint, { once: true });
22
- }
23
-
24
- const scriptEl = document.currentScript;
25
- if (scriptEl) {
26
- const raw = scriptEl.getAttribute('data-print-options');
27
- if (raw) {
28
- try {
29
- const opts = JSON.parse(raw);
30
- initPrint(opts);
31
- } catch (e) {
32
- console.error('Failed to parse print options', e);
33
- }
34
- }
35
- }
36
-
37
- window.addEventListener('message', e => {
38
- if (e.data?.type === 'init-print') {
39
- initPrint(e.data.options || {});
40
- }
41
- });
42
- })();