ngx-print 1.3.1 → 1.4.0
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/README.md +35 -0
- package/esm2022/lib/ngx-print.directive.mjs +236 -0
- package/esm2022/lib/ngx-print.module.mjs +16 -0
- package/{esm2020 → esm2022}/ngx-print.mjs +4 -4
- package/{esm2020 → esm2022}/public_api.mjs +5 -5
- package/{fesm2015 → fesm2022}/ngx-print.mjs +225 -177
- package/fesm2022/ngx-print.mjs.map +1 -0
- package/index.d.ts +5 -5
- package/lib/ngx-print.directive.d.ts +112 -94
- package/lib/ngx-print.directive.d.ts.map +1 -1
- package/lib/ngx-print.module.d.ts +7 -7
- package/lib/ngx-print.module.d.ts.map +1 -1
- package/package.json +5 -11
- package/public_api.d.ts +2 -2
- package/esm2020/lib/ngx-print.directive.mjs +0 -187
- package/esm2020/lib/ngx-print.module.mjs +0 -17
- package/fesm2015/ngx-print.mjs.map +0 -1
- package/fesm2020/ngx-print.mjs +0 -212
- package/fesm2020/ngx-print.mjs.map +0 -1
|
@@ -1,136 +1,180 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Directive, Input, HostListener, NgModule } from '@angular/core';
|
|
3
3
|
|
|
4
|
-
class NgxPrintDirective {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
*
|
|
62
|
-
* @
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
4
|
+
class NgxPrintDirective {
|
|
5
|
+
_printStyle = [];
|
|
6
|
+
/**
|
|
7
|
+
* Prevents the print dialog from opening on the window
|
|
8
|
+
*
|
|
9
|
+
* @memberof NgxPrintDirective
|
|
10
|
+
*/
|
|
11
|
+
previewOnly = false;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
*
|
|
15
|
+
* @memberof NgxPrintDirective
|
|
16
|
+
*/
|
|
17
|
+
printSectionId;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
*
|
|
21
|
+
* @memberof NgxPrintDirective
|
|
22
|
+
*/
|
|
23
|
+
printTitle;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
*
|
|
27
|
+
* @memberof NgxPrintDirective
|
|
28
|
+
*/
|
|
29
|
+
useExistingCss = false;
|
|
30
|
+
/**
|
|
31
|
+
* A delay in milliseconds to force the print dialog to wait before opened. Default: 0
|
|
32
|
+
*
|
|
33
|
+
* @memberof NgxPrintDirective
|
|
34
|
+
*/
|
|
35
|
+
printDelay = 0;
|
|
36
|
+
/**
|
|
37
|
+
* Whether to close the window after print() returns.
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
closeWindow = true;
|
|
41
|
+
/**
|
|
42
|
+
* Class attribute to apply to the body element.
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
bodyClass = '';
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
*
|
|
49
|
+
* @memberof NgxPrintDirective
|
|
50
|
+
*/
|
|
51
|
+
set printStyle(values) {
|
|
52
|
+
for (let key in values) {
|
|
53
|
+
if (values.hasOwnProperty(key)) {
|
|
54
|
+
this._printStyle.push((key + JSON.stringify(values[key])).replace(/['"]+/g, ''));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
this.returnStyleValues();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
*
|
|
62
|
+
* @returns the string that create the stylesheet which will be injected
|
|
63
|
+
* later within <style></style> tag.
|
|
64
|
+
*
|
|
65
|
+
* -join/replace to transform an array objects to css-styled string
|
|
66
|
+
*
|
|
67
|
+
* @memberof NgxPrintDirective
|
|
68
|
+
*/
|
|
69
|
+
returnStyleValues() {
|
|
70
|
+
return `<style> ${this._printStyle.join(' ').replace(/,/g, ';')} </style>`;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
*
|
|
74
|
+
*
|
|
75
|
+
* @returns html for the given tag
|
|
76
|
+
*
|
|
77
|
+
* @memberof NgxPrintDirective
|
|
78
|
+
*/
|
|
79
|
+
_styleSheetFile = '';
|
|
80
|
+
/**
|
|
81
|
+
* @memberof NgxPrintDirective
|
|
82
|
+
* @param cssList
|
|
83
|
+
*/
|
|
84
|
+
set styleSheetFile(cssList) {
|
|
85
|
+
let linkTagFn = function (cssFileName) {
|
|
86
|
+
return `<link rel="stylesheet" type="text/css" href="${cssFileName}">`;
|
|
87
|
+
};
|
|
88
|
+
if (cssList.indexOf(',') !== -1) {
|
|
89
|
+
const valueArr = cssList.split(',');
|
|
90
|
+
for (let val of valueArr) {
|
|
91
|
+
this._styleSheetFile = this._styleSheetFile + linkTagFn(val);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
this._styleSheetFile = linkTagFn(cssList);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* @returns string which contains the link tags containing the css which will
|
|
100
|
+
* be injected later within <head></head> tag.
|
|
101
|
+
*
|
|
102
|
+
*/
|
|
103
|
+
returnStyleSheetLinkTags() {
|
|
104
|
+
return this._styleSheetFile;
|
|
105
|
+
}
|
|
106
|
+
getElementTag(tag) {
|
|
107
|
+
const html = [];
|
|
108
|
+
const elements = document.getElementsByTagName(tag);
|
|
109
|
+
for (let index = 0; index < elements.length; index++) {
|
|
110
|
+
html.push(elements[index].outerHTML);
|
|
111
|
+
}
|
|
112
|
+
return html.join('\r\n');
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
*
|
|
116
|
+
* @description When printing, the default option of form elements are printed.
|
|
117
|
+
* Here we update what that default is to print the current values.
|
|
118
|
+
*
|
|
119
|
+
* @param elements the html element collection to save defaults to
|
|
120
|
+
*
|
|
121
|
+
*/
|
|
122
|
+
updateInputDefaults(elements) {
|
|
123
|
+
for (let i = 0; i < elements.length; i++) {
|
|
124
|
+
const element = elements[i];
|
|
125
|
+
element['defaultValue'] = element.value;
|
|
126
|
+
if (element['checked'])
|
|
127
|
+
element['defaultChecked'] = true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
updateSelectDefaults(elements) {
|
|
131
|
+
for (let i = 0; i < elements.length; i++) {
|
|
132
|
+
const element = elements[i];
|
|
133
|
+
const selectedIdx = element.selectedIndex;
|
|
134
|
+
const selectedOption = element.options[selectedIdx];
|
|
135
|
+
selectedOption.defaultSelected = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
updateTextAreaDefaults(elements) {
|
|
139
|
+
for (let i = 0; i < elements.length; i++) {
|
|
140
|
+
const element = elements[i];
|
|
141
|
+
element['defaultValue'] = element.value;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* @description Retrieves the html contents of the print section id.
|
|
146
|
+
* Updates the html elements to default their form values to the current form values
|
|
147
|
+
*
|
|
148
|
+
* @returns {string | null} html section to be printed
|
|
149
|
+
*
|
|
150
|
+
*/
|
|
151
|
+
getHtmlContents() {
|
|
152
|
+
const printContents = document.getElementById(this.printSectionId);
|
|
153
|
+
if (!printContents)
|
|
154
|
+
return null;
|
|
155
|
+
const inputEls = printContents.getElementsByTagName('input');
|
|
156
|
+
const selectEls = printContents.getElementsByTagName('select');
|
|
157
|
+
const textAreaEls = printContents.getElementsByTagName('textarea');
|
|
158
|
+
this.updateInputDefaults(inputEls);
|
|
159
|
+
this.updateSelectDefaults(selectEls);
|
|
160
|
+
this.updateTextAreaDefaults(textAreaEls);
|
|
161
|
+
return printContents.innerHTML;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
*
|
|
165
|
+
*
|
|
166
|
+
* @memberof NgxPrintDirective
|
|
167
|
+
*/
|
|
168
|
+
print() {
|
|
169
|
+
let printContents, popupWin, styles = '', links = '';
|
|
170
|
+
const baseTag = this.getElementTag('base');
|
|
171
|
+
if (this.useExistingCss) {
|
|
172
|
+
styles = this.getElementTag('style');
|
|
173
|
+
links = this.getElementTag('link');
|
|
174
|
+
}
|
|
175
|
+
printContents = this.getHtmlContents();
|
|
176
|
+
popupWin = window.open("", "_blank", "top=0,left=0,height=auto,width=auto");
|
|
177
|
+
popupWin.document.open();
|
|
134
178
|
popupWin.document.write(`
|
|
135
179
|
<html>
|
|
136
180
|
<head>
|
|
@@ -141,71 +185,75 @@ class NgxPrintDirective {
|
|
|
141
185
|
${styles}
|
|
142
186
|
${links}
|
|
143
187
|
</head>
|
|
144
|
-
<body>
|
|
188
|
+
<body ${this.bodyClass ? `class="${this.bodyClass}"` : ''}>
|
|
145
189
|
${printContents}
|
|
146
190
|
<script defer>
|
|
147
191
|
function triggerPrint(event) {
|
|
148
192
|
window.removeEventListener('load', triggerPrint, false);
|
|
149
|
-
${this.previewOnly ? '' : `setTimeout(function() {
|
|
193
|
+
${this.previewOnly || !this.closeWindow ? '' : `setTimeout(function() {
|
|
150
194
|
closeWindow(window.print());
|
|
151
195
|
}, ${this.printDelay});`}
|
|
152
196
|
}
|
|
153
197
|
function closeWindow(){
|
|
154
|
-
|
|
198
|
+
window.close();
|
|
155
199
|
}
|
|
156
200
|
window.addEventListener('load', triggerPrint, false);
|
|
157
201
|
</script>
|
|
158
202
|
</body>
|
|
159
|
-
</html>`);
|
|
160
|
-
popupWin.document.close();
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
166
|
-
type: Directive,
|
|
167
|
-
args: [{
|
|
168
|
-
selector: "button[ngxPrint]"
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
203
|
+
</html>`);
|
|
204
|
+
popupWin.document.close();
|
|
205
|
+
}
|
|
206
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxPrintDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
207
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: NgxPrintDirective, isStandalone: true, selector: "button[ngxPrint]", inputs: { previewOnly: "previewOnly", printSectionId: "printSectionId", printTitle: "printTitle", useExistingCss: "useExistingCss", printDelay: "printDelay", closeWindow: "closeWindow", bodyClass: "bodyClass", printStyle: "printStyle", styleSheetFile: "styleSheetFile" }, host: { listeners: { "click": "print()" } }, ngImport: i0 });
|
|
208
|
+
}
|
|
209
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxPrintDirective, decorators: [{
|
|
210
|
+
type: Directive,
|
|
211
|
+
args: [{
|
|
212
|
+
selector: "button[ngxPrint]",
|
|
213
|
+
standalone: true
|
|
214
|
+
}]
|
|
215
|
+
}], propDecorators: { previewOnly: [{
|
|
216
|
+
type: Input
|
|
217
|
+
}], printSectionId: [{
|
|
218
|
+
type: Input
|
|
219
|
+
}], printTitle: [{
|
|
220
|
+
type: Input
|
|
221
|
+
}], useExistingCss: [{
|
|
222
|
+
type: Input
|
|
223
|
+
}], printDelay: [{
|
|
224
|
+
type: Input
|
|
225
|
+
}], closeWindow: [{
|
|
226
|
+
type: Input
|
|
227
|
+
}], bodyClass: [{
|
|
228
|
+
type: Input
|
|
229
|
+
}], printStyle: [{
|
|
230
|
+
type: Input
|
|
231
|
+
}], styleSheetFile: [{
|
|
232
|
+
type: Input
|
|
233
|
+
}], print: [{
|
|
234
|
+
type: HostListener,
|
|
235
|
+
args: ['click']
|
|
187
236
|
}] } });
|
|
188
237
|
|
|
189
|
-
class NgxPrintModule {
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
195
|
-
type: NgModule,
|
|
196
|
-
args: [{
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}]
|
|
238
|
+
class NgxPrintModule {
|
|
239
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxPrintModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
240
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: NgxPrintModule, imports: [NgxPrintDirective], exports: [NgxPrintDirective] });
|
|
241
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxPrintModule });
|
|
242
|
+
}
|
|
243
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxPrintModule, decorators: [{
|
|
244
|
+
type: NgModule,
|
|
245
|
+
args: [{
|
|
246
|
+
imports: [NgxPrintDirective],
|
|
247
|
+
exports: [NgxPrintDirective]
|
|
248
|
+
}]
|
|
201
249
|
}] });
|
|
202
250
|
|
|
203
|
-
/*
|
|
204
|
-
* Public API Surface of ngx-print
|
|
251
|
+
/*
|
|
252
|
+
* Public API Surface of ngx-print
|
|
205
253
|
*/
|
|
206
254
|
|
|
207
|
-
/**
|
|
208
|
-
* Generated bundle index. Do not edit.
|
|
255
|
+
/**
|
|
256
|
+
* Generated bundle index. Do not edit.
|
|
209
257
|
*/
|
|
210
258
|
|
|
211
259
|
export { NgxPrintDirective, NgxPrintModule };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngx-print.mjs","sources":["../../../src/lib/ngx-print.directive.ts","../../../src/lib/ngx-print.module.ts","../../../src/public_api.ts","../../../src/ngx-print.ts"],"sourcesContent":["import { Directive, HostListener, Input } from '@angular/core';\r\n@Directive({\r\n selector: \"button[ngxPrint]\",\r\n standalone: true\r\n})\r\nexport class NgxPrintDirective {\r\n\r\n public _printStyle = [];\r\n\r\n /**\r\n * Prevents the print dialog from opening on the window\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() previewOnly: boolean = false;\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() printSectionId: string;\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() printTitle: string;\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() useExistingCss = false;\r\n\r\n /**\r\n * A delay in milliseconds to force the print dialog to wait before opened. Default: 0\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() printDelay: number = 0;\r\n\r\n /**\r\n * Whether to close the window after print() returns.\r\n *\r\n */\r\n @Input() closeWindow: boolean = true;\r\n\r\n /**\r\n * Class attribute to apply to the body element.\r\n *\r\n */\r\n @Input() bodyClass: string = '';\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input()\r\n set printStyle(values: { [key: string]: { [key: string]: string } }) {\r\n for (let key in values) {\r\n if (values.hasOwnProperty(key)) {\r\n this._printStyle.push((key + JSON.stringify(values[key])).replace(/['\"]+/g, ''));\r\n }\r\n }\r\n this.returnStyleValues();\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @returns the string that create the stylesheet which will be injected\r\n * later within <style></style> tag.\r\n *\r\n * -join/replace to transform an array objects to css-styled string\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n public returnStyleValues() {\r\n return `<style> ${this._printStyle.join(' ').replace(/,/g, ';')} </style>`;\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @returns html for the given tag\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n private _styleSheetFile = '';\r\n\r\n /**\r\n * @memberof NgxPrintDirective\r\n * @param cssList\r\n */\r\n @Input()\r\n set styleSheetFile(cssList: string) {\r\n let linkTagFn = function (cssFileName) {\r\n return `<link rel=\"stylesheet\" type=\"text/css\" href=\"${cssFileName}\">`;\r\n }\r\n if (cssList.indexOf(',') !== -1) {\r\n const valueArr = cssList.split(',');\r\n for (let val of valueArr) {\r\n this._styleSheetFile = this._styleSheetFile + linkTagFn(val);\r\n }\r\n } else {\r\n this._styleSheetFile = linkTagFn(cssList);\r\n }\r\n }\r\n\r\n /**\r\n * @returns string which contains the link tags containing the css which will\r\n * be injected later within <head></head> tag.\r\n *\r\n */\r\n private returnStyleSheetLinkTags() {\r\n return this._styleSheetFile;\r\n }\r\n private getElementTag(tag: keyof HTMLElementTagNameMap): string {\r\n const html: string[] = [];\r\n const elements = document.getElementsByTagName(tag);\r\n for (let index = 0; index < elements.length; index++) {\r\n html.push(elements[index].outerHTML);\r\n }\r\n return html.join('\\r\\n');\r\n }\r\n\r\n /**\r\n *\r\n * @description When printing, the default option of form elements are printed.\r\n * Here we update what that default is to print the current values.\r\n *\r\n * @param elements the html element collection to save defaults to\r\n *\r\n */\r\n private updateInputDefaults(elements: HTMLCollectionOf<HTMLInputElement>): void {\r\n for (let i = 0; i < elements.length; i++) {\r\n const element = elements[i];\r\n element['defaultValue'] = element.value;\r\n if (element['checked']) element['defaultChecked'] = true;\r\n }\r\n }\r\n private updateSelectDefaults(elements: HTMLCollectionOf<HTMLSelectElement>): void {\r\n for (let i = 0; i < elements.length; i++) {\r\n const element = elements[i];\r\n const selectedIdx = element.selectedIndex;\r\n const selectedOption: HTMLOptionElement = element.options[selectedIdx];\r\n\r\n selectedOption.defaultSelected = true;\r\n }\r\n }\r\n private updateTextAreaDefaults(elements: HTMLCollectionOf<HTMLTextAreaElement>): void {\r\n for (let i = 0; i < elements.length; i++) {\r\n const element = elements[i];\r\n element['defaultValue'] = element.value;\r\n }\r\n }\r\n\r\n /**\r\n * @description Retrieves the html contents of the print section id.\r\n * Updates the html elements to default their form values to the current form values\r\n *\r\n * @returns {string | null} html section to be printed\r\n *\r\n */\r\n private getHtmlContents(): string | null {\r\n const printContents = document.getElementById(this.printSectionId);\r\n if (!printContents) return null;\r\n\r\n const inputEls = printContents.getElementsByTagName('input');\r\n const selectEls = printContents.getElementsByTagName('select');\r\n const textAreaEls = printContents.getElementsByTagName('textarea');\r\n\r\n this.updateInputDefaults(inputEls);\r\n this.updateSelectDefaults(selectEls);\r\n this.updateTextAreaDefaults(textAreaEls);\r\n\r\n return printContents.innerHTML;\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @HostListener('click')\r\n public print(): void {\r\n let printContents, popupWin, styles = '', links = '';\r\n const baseTag = this.getElementTag('base');\r\n\r\n if (this.useExistingCss) {\r\n styles = this.getElementTag('style');\r\n links = this.getElementTag('link');\r\n }\r\n\r\n printContents = this.getHtmlContents();\r\n popupWin = window.open(\"\", \"_blank\", \"top=0,left=0,height=auto,width=auto\");\r\n popupWin.document.open();\r\n popupWin.document.write(`\r\n <html>\r\n <head>\r\n <title>${this.printTitle ? this.printTitle : \"\"}</title>\r\n ${baseTag}\r\n ${this.returnStyleValues()}\r\n ${this.returnStyleSheetLinkTags()}\r\n ${styles}\r\n ${links}\r\n </head>\r\n <body ${this.bodyClass ? `class=\"${this.bodyClass}\"` : ''}>\r\n ${printContents}\r\n <script defer>\r\n function triggerPrint(event) {\r\n window.removeEventListener('load', triggerPrint, false);\r\n ${this.previewOnly || !this.closeWindow ? '' : `setTimeout(function() {\r\n closeWindow(window.print());\r\n }, ${this.printDelay});`}\r\n }\r\n function closeWindow(){\r\n window.close();\r\n }\r\n window.addEventListener('load', triggerPrint, false);\r\n </script>\r\n </body>\r\n </html>`);\r\n popupWin.document.close();\r\n }\r\n}\r\n","import { NgModule } from '@angular/core';\r\nimport { NgxPrintDirective } from './ngx-print.directive';\r\n\r\n@NgModule({\r\n imports: [NgxPrintDirective],\r\n exports: [NgxPrintDirective]\r\n})\r\nexport class NgxPrintModule { }\r\n","/*\r\n * Public API Surface of ngx-print\r\n */\r\n\r\nexport * from './lib/ngx-print.directive';\r\nexport * from './lib/ngx-print.module';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;MAKa,iBAAiB,CAAA;IAErB,WAAW,GAAG,EAAE,CAAC;AAExB;;;;AAIG;IACM,WAAW,GAAY,KAAK,CAAC;AAEtC;;;;AAIG;AACM,IAAA,cAAc,CAAS;AAEhC;;;;AAIG;AACM,IAAA,UAAU,CAAS;AAE5B;;;;AAIG;IACM,cAAc,GAAG,KAAK,CAAC;AAEhC;;;;AAIG;IACM,UAAU,GAAW,CAAC,CAAC;AAEhC;;;AAGG;IACM,WAAW,GAAY,IAAI,CAAC;AAErC;;;AAGG;IACM,SAAS,GAAW,EAAE,CAAC;AAEhC;;;;AAIG;IACH,IACI,UAAU,CAAC,MAAoD,EAAA;AACjE,QAAA,KAAK,IAAI,GAAG,IAAI,MAAM,EAAE;AACtB,YAAA,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;gBAC9B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;AAClF,aAAA;AACF,SAAA;QACD,IAAI,CAAC,iBAAiB,EAAE,CAAC;KAC1B;AAED;;;;;;;;;AASG;IACI,iBAAiB,GAAA;AACtB,QAAA,OAAO,WAAW,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC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A;sBAAnB,KAAK;gBAMG,SAAS,EAAA,CAAA;sBAAjB,KAAK;gBAQF,UAAU,EAAA,CAAA;sBADb,KAAK;gBAsCF,cAAc,EAAA,CAAA;sBADjB,KAAK;gBA2FC,KAAK,EAAA,CAAA;sBADX,YAAY;uBAAC,OAAO,CAAA;;;MCrLV,cAAc,CAAA;wGAAd,cAAc,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;yGAAd,cAAc,EAAA,OAAA,EAAA,CAHf,iBAAiB,CAAA,EAAA,OAAA,EAAA,CACjB,iBAAiB,CAAA,EAAA,CAAA,CAAA;yGAEhB,cAAc,EAAA,CAAA,CAAA;;4FAAd,cAAc,EAAA,UAAA,EAAA,CAAA;kBAJ1B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,iBAAiB,CAAC;oBAC5B,OAAO,EAAE,CAAC,iBAAiB,CAAC;AAC7B,iBAAA,CAAA;;;ACND;;AAEG;;ACFH;;AAEG;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generated bundle index. Do not edit.
|
|
3
|
-
*/
|
|
4
|
-
/// <amd-module name="ngx-print" />
|
|
5
|
-
export * from './public_api';
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
/// <amd-module name="ngx-print" />
|
|
5
|
+
export * from './public_api';
|
|
6
6
|
//# sourceMappingURL=ngx-print.d.ts.map
|