ngx-print 3.1.0 → 20.0.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 CHANGED
@@ -12,9 +12,11 @@ This directive makes printing your HTML sections smooth and easy in your Angular
12
12
  | 1.5.x | 17.0.0 |
13
13
  | 2.x.x | 18.0.0 |
14
14
  | 3.x.x | 19.0.0 |
15
+ | 20.x.x | 20.0.0 |
16
+
17
+ ## Version Alignment Notice
18
+ Starting with version 20.0.0, this package aligns its major version with the Angular framework version for better clarity and compatibility tracking. Version 20 is intended for Angular 20 and so on.
15
19
 
16
- ### Note
17
- The versioning strategy has been updated from incrementing minor versions (1.5.x) to using major versions (2.x.x). This change ensures that npm update will no longer automatically upgrade to an unsupported Angular version. Previously, this was overlooked, leading to potential compatibility issues. Starting with version 2.x.x, we are addressing this oversight to ensure better version management going forward.
18
20
 
19
21
  ## Setup
20
22
 
@@ -202,6 +204,17 @@ Here some simple styles were added to every `h1` & `h2` tags within the `div` wh
202
204
  ngxPrint>print</button>
203
205
  ```
204
206
 
207
+ - To run a function after printing completes, subscribe to the `printCompleted` event. Please note it is impossible to differentiate between the Cancel or Print buttong being clicked on the print window. This event will fire regardless of which button was clicked:
208
+
209
+ ```html
210
+ <button
211
+ (printCompleted)="onPrintComplete()"
212
+ printSectionId="print-section"
213
+ ngxPrint>
214
+ print
215
+ </button>
216
+ ```
217
+
205
218
  ## Using NgxPrint as a service (v1.5+)
206
219
  Inject the NgxPrintService in the constructor of your component or service:
207
220
 
@@ -244,6 +257,13 @@ this.printService.printStyle = styleSheet;
244
257
  this.printService.styleSheetFile = fileLocation;
245
258
  ```
246
259
 
260
+ ### Subscribing to print event
261
+ ```typescript
262
+ this.printService.printComplete$.pipe(take(1)).subscribe(() => {
263
+ console.log('Print completed!');
264
+ });
265
+ ```
266
+
247
267
  ## Content-Security-Policy (CSP) Support
248
268
  If Angular is configured to use a [CSP Nonce](https://angular.io/api/core/CSP_NONCE), ngx-print will automatically inject the `[printStyle]` CSS rules with this Nonce authorization.
249
269
 
@@ -1,13 +1,12 @@
1
1
  import * as i0 from '@angular/core';
2
- import { CSP_NONCE, Inject, Optional, Injectable, HostListener, Input, Directive, NgModule } from '@angular/core';
2
+ import { inject, CSP_NONCE, Injectable, output, HostListener, Input, Directive, NgModule } from '@angular/core';
3
+ import { Subject, take } from 'rxjs';
3
4
 
4
5
  class PrintBase {
5
- nonce;
6
+ nonce = inject(CSP_NONCE, { optional: true });
6
7
  _printStyle = [];
7
8
  _styleSheetFile = '';
8
- constructor(nonce) {
9
- this.nonce = nonce;
10
- }
9
+ printComplete = new Subject();
11
10
  //#region Getters and Setters
12
11
  /**
13
12
  * Sets the print styles based on the provided values.
@@ -164,6 +163,9 @@ class PrintBase {
164
163
  return html.join('\r\n');
165
164
  }
166
165
  //#endregion
166
+ notifyPrintComplete() {
167
+ this.printComplete.next();
168
+ }
167
169
  /**
168
170
  * Prints the specified content using the provided print options.
169
171
  *
@@ -222,41 +224,53 @@ class PrintBase {
222
224
  // Add script
223
225
  const script = doc.createElement('script');
224
226
  script.defer = true;
227
+ if (this.nonce) {
228
+ script.setAttribute('nonce', this.nonce);
229
+ }
225
230
  script.textContent = `
226
- function triggerPrint(event) {
227
- window.removeEventListener('load', triggerPrint, false);
228
- ${printOptions.previewOnly
231
+ function triggerPrint(event) {
232
+ window.removeEventListener('load', triggerPrint, false);
233
+ ${printOptions.previewOnly
229
234
  ? ''
230
235
  : `setTimeout(function() {
231
- closeWindow(window.print());
232
- }, ${printOptions.printDelay});`}
233
- }
234
- function closeWindow(){
235
- ${printOptions.closeWindow ? 'window.close();' : ''}
236
- }
237
- window.addEventListener('load', triggerPrint, false);
238
- `;
236
+ closeWindow(window.print());
237
+ }, ${printOptions.printDelay});`}
238
+ }
239
+ function closeWindow(){
240
+ ${printOptions.closeWindow ? 'window.close();' : ''}
241
+ }
242
+ window.addEventListener('load', triggerPrint, false);
243
+ window.addEventListener('afterprint', function () {
244
+ if (window.opener) {
245
+ window.opener.postMessage({ type: 'print-complete' }, '*');
246
+ }
247
+ closeWindow();
248
+ }, { once: true });
249
+ `;
239
250
  body.appendChild(script);
240
251
  // Assemble the document
241
252
  html.appendChild(head);
242
253
  html.appendChild(body);
243
254
  doc.appendChild(html);
244
255
  popupWin.document.close();
256
+ const handleMessage = (event) => {
257
+ if (event.data?.type === 'print-complete') {
258
+ // Notify of print completion
259
+ this.notifyPrintComplete();
260
+ window.removeEventListener('message', handleMessage);
261
+ }
262
+ };
263
+ window.addEventListener('message', handleMessage);
245
264
  }
246
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: PrintBase, deps: [{ token: CSP_NONCE, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
247
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: PrintBase, providedIn: 'root' });
265
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: PrintBase, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
266
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: PrintBase, providedIn: 'root' });
248
267
  }
249
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: PrintBase, decorators: [{
268
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: PrintBase, decorators: [{
250
269
  type: Injectable,
251
270
  args: [{
252
271
  providedIn: 'root',
253
272
  }]
254
- }], ctorParameters: () => [{ type: undefined, decorators: [{
255
- type: Inject,
256
- args: [CSP_NONCE]
257
- }, {
258
- type: Optional
259
- }] }] });
273
+ }] });
260
274
 
261
275
  /**
262
276
  * Service for handling printing functionality in Angular applications.
@@ -267,6 +281,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
267
281
  * @extends {PrintBase}
268
282
  */
269
283
  class NgxPrintService extends PrintBase {
284
+ printComplete$ = this.printComplete.asObservable();
270
285
  /**
271
286
  * Initiates the printing process using the provided print options.
272
287
  *
@@ -298,10 +313,10 @@ class NgxPrintService extends PrintBase {
298
313
  set styleSheetFile(cssList) {
299
314
  super.setStyleSheetFile(cssList);
300
315
  }
301
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgxPrintService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
302
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgxPrintService, providedIn: 'root' });
316
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: NgxPrintService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
317
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: NgxPrintService, providedIn: 'root' });
303
318
  }
304
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgxPrintService, decorators: [{
319
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: NgxPrintService, decorators: [{
305
320
  type: Injectable,
306
321
  args: [{
307
322
  providedIn: 'root',
@@ -409,11 +424,15 @@ class NgxPrintDirective extends PrintBase {
409
424
  */
410
425
  print() {
411
426
  super.print(this.printOptions);
427
+ this.printComplete.pipe(take(1)).subscribe(() => {
428
+ this.printCompleted.emit(undefined);
429
+ });
412
430
  }
413
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgxPrintDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
414
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.14", type: NgxPrintDirective, isStandalone: true, selector: "[ngxPrint]", inputs: { previewOnly: "previewOnly", printSectionId: "printSectionId", printTitle: "printTitle", useExistingCss: "useExistingCss", printDelay: "printDelay", closeWindow: "closeWindow", bodyClass: "bodyClass", openNewTab: "openNewTab", printStyle: "printStyle", styleSheetFile: "styleSheetFile" }, host: { listeners: { "click": "print()" } }, usesInheritance: true, ngImport: i0 });
431
+ printCompleted = output();
432
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: NgxPrintDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
433
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.0", type: NgxPrintDirective, isStandalone: true, selector: "[ngxPrint]", inputs: { previewOnly: "previewOnly", printSectionId: "printSectionId", printTitle: "printTitle", useExistingCss: "useExistingCss", printDelay: "printDelay", closeWindow: "closeWindow", bodyClass: "bodyClass", openNewTab: "openNewTab", printStyle: "printStyle", styleSheetFile: "styleSheetFile" }, outputs: { printCompleted: "printCompleted" }, host: { listeners: { "click": "print()" } }, usesInheritance: true, ngImport: i0 });
415
434
  }
416
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgxPrintDirective, decorators: [{
435
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: NgxPrintDirective, decorators: [{
417
436
  type: Directive,
418
437
  args: [{
419
438
  selector: '[ngxPrint]',
@@ -445,11 +464,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
445
464
  }] } });
446
465
 
447
466
  class NgxPrintModule {
448
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgxPrintModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
449
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: NgxPrintModule, imports: [NgxPrintDirective], exports: [NgxPrintDirective] });
450
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgxPrintModule });
467
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: NgxPrintModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
468
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: NgxPrintModule, imports: [NgxPrintDirective], exports: [NgxPrintDirective] });
469
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: NgxPrintModule });
451
470
  }
452
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgxPrintModule, decorators: [{
471
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: NgxPrintModule, decorators: [{
453
472
  type: NgModule,
454
473
  args: [{
455
474
  imports: [NgxPrintDirective],
@@ -1 +1 @@
1
- {"version":3,"file":"ngx-print.mjs","sources":["../../../src/lib/ngx-print.base.ts","../../../src/lib/ngx-print.service.ts","../../../src/lib/print-options.ts","../../../src/lib/ngx-print.directive.ts","../../../src/lib/ngx-print.module.ts","../../../src/public_api.ts","../../../src/ngx-print.ts"],"sourcesContent":["import { CSP_NONCE, Inject, Injectable, Optional } from '@angular/core';\r\nimport { PrintOptions } from './print-options';\r\n\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class PrintBase {\r\n private _printStyle: string[] = [];\r\n private _styleSheetFile: string = '';\r\n\r\n constructor(@Inject(CSP_NONCE) @Optional() private nonce?: string | null) {}\r\n\r\n //#region Getters and Setters\r\n /**\r\n * Sets the print styles based on the provided values.\r\n *\r\n * @param {Object} values - Key-value pairs representing print styles.\r\n * @protected\r\n */\r\n protected setPrintStyle(values: { [key: string]: { [key: string]: string } }) {\r\n this._printStyle = [];\r\n for (const key in values) {\r\n if (Object.prototype.hasOwnProperty.call(values, key)) {\r\n this._printStyle.push((key + JSON.stringify(values[key])).replace(/['\"]+/g, ''));\r\n }\r\n }\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 public returnStyleValues() {\r\n const styleNonce = this.nonce ? ` nonce=\"${this.nonce}\"` : '';\r\n return `<style${styleNonce}> ${this._printStyle.join(' ').replace(/,/g, ';')} </style>`;\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\r\n /**\r\n * Sets the style sheet file based on the provided CSS list.\r\n *\r\n * @param {string} cssList - CSS file or list of CSS files.\r\n * @protected\r\n */\r\n protected setStyleSheetFile(cssList: string) {\r\n const linkTagFn = function (cssFileName: string) {\r\n return `<link rel=\"stylesheet\" type=\"text/css\" href=\"${cssFileName}\">`;\r\n };\r\n\r\n if (cssList.indexOf(',') !== -1) {\r\n const valueArr = cssList.split(',');\r\n this._styleSheetFile = valueArr.map(val => linkTagFn(val)).join('');\r\n } else {\r\n this._styleSheetFile = linkTagFn(cssList);\r\n }\r\n }\r\n\r\n //#endregion\r\n\r\n //#region Private methods used by PrintBase\r\n\r\n /**\r\n * Updates the default values for input elements.\r\n *\r\n * @param {HTMLCollectionOf<HTMLInputElement>} elements - Collection of input elements.\r\n * @private\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\r\n /**\r\n * Updates the default values for select elements.\r\n *\r\n * @param {HTMLCollectionOf<HTMLSelectElement>} elements - Collection of select elements.\r\n * @private\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\r\n /**\r\n * Updates the default values for textarea elements.\r\n *\r\n * @param {HTMLCollectionOf<HTMLTextAreaElement>} elements - Collection of textarea elements.\r\n * @private\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 * Converts a canvas element to an image and returns its HTML string.\r\n *\r\n * @param {HTMLCanvasElement} element - The canvas element to convert.\r\n * @returns {string} - HTML string of the image.\r\n * @private\r\n */\r\n private canvasToImageHtml(element: HTMLCanvasElement): string {\r\n const dataUrl = element.toDataURL();\r\n return `<img src=\"${dataUrl}\" style=\"max-width: 100%;\">`;\r\n }\r\n\r\n /**\r\n * Includes canvas contents in the print section via img tags.\r\n *\r\n * @param {HTMLCollectionOf<HTMLCanvasElement>} elements - Collection of canvas elements.\r\n * @private\r\n */\r\n private updateCanvasToImage(elements: HTMLCollectionOf<HTMLCanvasElement>): void {\r\n for (let i = 0; i < elements.length; i++) {\r\n const element = this.canvasToImageHtml(elements[i]);\r\n elements[i].insertAdjacentHTML('afterend', element);\r\n elements[i].remove();\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the HTML content of a specified printing section.\r\n *\r\n * @param {string} printSectionId - Id of the printing section.\r\n * @returns {string | null} - HTML content of the printing section, or null if not found.\r\n * @private\r\n */\r\n private getHtmlContents(printSectionId: string): string | null {\r\n const printContents = document.getElementById(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 const canvasEls = printContents.getElementsByTagName('canvas');\r\n\r\n this.updateInputDefaults(inputEls);\r\n this.updateSelectDefaults(selectEls);\r\n this.updateTextAreaDefaults(textAreaEls);\r\n this.updateCanvasToImage(canvasEls);\r\n\r\n return printContents.innerHTML;\r\n }\r\n\r\n /**\r\n * Retrieves the HTML content of elements with the specified tag.\r\n *\r\n * @param {keyof HTMLElementTagNameMap} tag - HTML tag name.\r\n * @returns {string} - Concatenated outerHTML of elements with the specified tag.\r\n * @private\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 //#endregion\r\n\r\n /**\r\n * Prints the specified content using the provided print options.\r\n *\r\n * @param {PrintOptions} printOptions - Options for printing.\r\n * @public\r\n */\r\n protected print(printOptions: PrintOptions): void {\r\n let styles = '',\r\n links = '',\r\n popOut = 'top=0,left=0,height=auto,width=auto';\r\n const baseTag = this.getElementTag('base');\r\n\r\n if (printOptions.useExistingCss) {\r\n styles = this.getElementTag('style');\r\n links = this.getElementTag('link');\r\n }\r\n\r\n // If the openNewTab option is set to true, then set the popOut option to an empty string.\r\n // This will cause the print dialog to open in a new tab.\r\n if (printOptions.openNewTab) {\r\n popOut = '';\r\n }\r\n\r\n const printContents = this.getHtmlContents(printOptions.printSectionId);\r\n if (!printContents) {\r\n // Handle the case where the specified print section is not found.\r\n console.error(`Print section with id ${printOptions.printSectionId} not found.`);\r\n return;\r\n }\r\n\r\n const popupWin = window.open('', '_blank', popOut);\r\n\r\n if (!popupWin) {\r\n // the popup window could not be opened.\r\n console.error('Could not open print window.');\r\n return;\r\n }\r\n\r\n popupWin.document.open();\r\n\r\n // Create the HTML structure\r\n const doc = popupWin.document;\r\n\r\n // Set up the basic HTML structure\r\n const html = doc.createElement('html');\r\n const head = doc.createElement('head');\r\n const body = doc.createElement('body');\r\n\r\n // Set title\r\n const title = doc.createElement('title');\r\n title.textContent = printOptions.printTitle || '';\r\n head.appendChild(title);\r\n\r\n // Add base tag, styles, and links\r\n if (baseTag) {\r\n head.innerHTML += baseTag;\r\n }\r\n head.innerHTML += this.returnStyleValues();\r\n head.innerHTML += this.returnStyleSheetLinkTags();\r\n head.innerHTML += styles;\r\n head.innerHTML += links;\r\n\r\n // Set body class if provided\r\n if (printOptions.bodyClass) {\r\n body.className = printOptions.bodyClass;\r\n }\r\n\r\n // Insert print contents\r\n body.innerHTML += printContents;\r\n\r\n // Add script\r\n const script = doc.createElement('script');\r\n script.defer = true;\r\n script.textContent = `\r\n function triggerPrint(event) {\r\n window.removeEventListener('load', triggerPrint, false);\r\n ${\r\n printOptions.previewOnly\r\n ? ''\r\n : `setTimeout(function() {\r\n closeWindow(window.print());\r\n }, ${printOptions.printDelay});`\r\n }\r\n }\r\n function closeWindow(){\r\n ${printOptions.closeWindow ? 'window.close();' : ''}\r\n }\r\n window.addEventListener('load', triggerPrint, false);\r\n`;\r\n body.appendChild(script);\r\n\r\n // Assemble the document\r\n html.appendChild(head);\r\n html.appendChild(body);\r\n doc.appendChild(html);\r\n\r\n popupWin.document.close();\r\n }\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { PrintBase } from './ngx-print.base';\r\nimport { PrintOptions } from './print-options';\r\n\r\n/**\r\n * Service for handling printing functionality in Angular applications.\r\n * Extends the base printing class (PrintBase).\r\n *\r\n * @export\r\n * @class NgxPrintService\r\n * @extends {PrintBase}\r\n */\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class NgxPrintService extends PrintBase {\r\n /**\r\n * Initiates the printing process using the provided print options.\r\n *\r\n * @param {PrintOptions} printOptions - Options for configuring the printing process.\r\n * @memberof NgxPrintService\r\n * @returns {void}\r\n */\r\n public print(printOptions: PrintOptions): void {\r\n // Call the print method in the parent class\r\n super.print(printOptions);\r\n }\r\n\r\n /**\r\n * Sets the print style for the printing process.\r\n *\r\n * @param {{ [key: string]: { [key: string]: string } }} values - A dictionary representing the print styles.\r\n * @memberof NgxPrintService\r\n * @setter\r\n */\r\n set printStyle(values: { [key: string]: { [key: string]: string } }) {\r\n super.setPrintStyle(values);\r\n }\r\n\r\n /**\r\n * Sets the stylesheet file for the printing process.\r\n *\r\n * @param {string} cssList - A string representing the path to the stylesheet file.\r\n * @memberof NgxPrintService\r\n * @setter\r\n */\r\n set styleSheetFile(cssList: string) {\r\n super.setStyleSheetFile(cssList);\r\n }\r\n}\r\n","export class PrintOptions {\r\n printSectionId: string = '';\r\n printTitle: string = '';\r\n useExistingCss: boolean = false;\r\n bodyClass: string = '';\r\n openNewTab: boolean = false;\r\n previewOnly: boolean = false;\r\n closeWindow: boolean = true;\r\n printDelay: number = 0;\r\n\r\n constructor(options?: Partial<PrintOptions>) {\r\n if (options) {\r\n Object.assign(this, options);\r\n }\r\n }\r\n}\r\n","import { Directive, HostListener, Input } from '@angular/core';\r\nimport { PrintBase } from './ngx-print.base';\r\nimport { PrintOptions } from './print-options';\r\n@Directive({\r\n selector: '[ngxPrint]',\r\n standalone: true,\r\n})\r\nexport class NgxPrintDirective extends PrintBase {\r\n private printOptions = new PrintOptions();\r\n /**\r\n * Prevents the print dialog from opening on the window\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set previewOnly(value: boolean) {\r\n this.printOptions = { ...this.printOptions, previewOnly: value };\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set printSectionId(value: string) {\r\n this.printOptions = { ...this.printOptions, printSectionId: value };\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set printTitle(value: string) {\r\n this.printOptions = { ...this.printOptions, printTitle: value };\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set useExistingCss(value: boolean) {\r\n this.printOptions = { ...this.printOptions, useExistingCss: value };\r\n }\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() set printDelay(value: number) {\r\n this.printOptions = { ...this.printOptions, printDelay: value };\r\n }\r\n\r\n /**\r\n * Whether to close the window after print() returns.\r\n *\r\n */\r\n @Input() set closeWindow(value: boolean) {\r\n this.printOptions = { ...this.printOptions, closeWindow: value };\r\n }\r\n\r\n /**\r\n * Class attribute to apply to the body element.\r\n *\r\n */\r\n @Input() set bodyClass(value: string) {\r\n this.printOptions = { ...this.printOptions, bodyClass: value };\r\n }\r\n\r\n /**\r\n * Whether to open a new window or default to new window.\r\n *\r\n */\r\n @Input() set openNewTab(value: boolean) {\r\n this.printOptions = { ...this.printOptions, openNewTab: value };\r\n }\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 super.setPrintStyle(values);\r\n }\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 super.setStyleSheetFile(cssList);\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 super.print(this.printOptions);\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\nexport { NgxPrintService } from './lib/ngx-print.service';\r\nexport { NgxPrintDirective } from './lib/ngx-print.directive';\r\nexport { NgxPrintModule } from './lib/ngx-print.module';\r\nexport { PrintOptions } from './lib/print-options';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\n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AC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,iBAAiB,CAAC;oBAC5B,OAAO,EAAE,CAAC,iBAAiB,CAAC;AAC7B,iBAAA;;;ACND;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"ngx-print.mjs","sources":["../../../src/lib/ngx-print.base.ts","../../../src/lib/ngx-print.service.ts","../../../src/lib/print-options.ts","../../../src/lib/ngx-print.directive.ts","../../../src/lib/ngx-print.module.ts","../../../src/public_api.ts","../../../src/ngx-print.ts"],"sourcesContent":["import { CSP_NONCE, Injectable, inject } from '@angular/core';\r\nimport { PrintOptions } from './print-options';\r\nimport { Subject } from 'rxjs';\r\n\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class PrintBase {\r\n private nonce = inject(CSP_NONCE, { optional: true });\r\n\r\n private _printStyle: string[] = [];\r\n private _styleSheetFile: string = '';\r\n protected printComplete = new Subject<void>();\r\n\r\n //#region Getters and Setters\r\n /**\r\n * Sets the print styles based on the provided values.\r\n *\r\n * @param {Object} values - Key-value pairs representing print styles.\r\n * @protected\r\n */\r\n protected setPrintStyle(values: { [key: string]: { [key: string]: string } }) {\r\n this._printStyle = [];\r\n for (const key in values) {\r\n if (Object.prototype.hasOwnProperty.call(values, key)) {\r\n this._printStyle.push((key + JSON.stringify(values[key])).replace(/['\"]+/g, ''));\r\n }\r\n }\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 public returnStyleValues() {\r\n const styleNonce = this.nonce ? ` nonce=\"${this.nonce}\"` : '';\r\n return `<style${styleNonce}> ${this._printStyle.join(' ').replace(/,/g, ';')} </style>`;\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\r\n /**\r\n * Sets the style sheet file based on the provided CSS list.\r\n *\r\n * @param {string} cssList - CSS file or list of CSS files.\r\n * @protected\r\n */\r\n protected setStyleSheetFile(cssList: string) {\r\n const linkTagFn = function (cssFileName: string) {\r\n return `<link rel=\"stylesheet\" type=\"text/css\" href=\"${cssFileName}\">`;\r\n };\r\n\r\n if (cssList.indexOf(',') !== -1) {\r\n const valueArr = cssList.split(',');\r\n this._styleSheetFile = valueArr.map(val => linkTagFn(val)).join('');\r\n } else {\r\n this._styleSheetFile = linkTagFn(cssList);\r\n }\r\n }\r\n\r\n //#endregion\r\n\r\n //#region Private methods used by PrintBase\r\n\r\n /**\r\n * Updates the default values for input elements.\r\n *\r\n * @param {HTMLCollectionOf<HTMLInputElement>} elements - Collection of input elements.\r\n * @private\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\r\n /**\r\n * Updates the default values for select elements.\r\n *\r\n * @param {HTMLCollectionOf<HTMLSelectElement>} elements - Collection of select elements.\r\n * @private\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\r\n /**\r\n * Updates the default values for textarea elements.\r\n *\r\n * @param {HTMLCollectionOf<HTMLTextAreaElement>} elements - Collection of textarea elements.\r\n * @private\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 * Converts a canvas element to an image and returns its HTML string.\r\n *\r\n * @param {HTMLCanvasElement} element - The canvas element to convert.\r\n * @returns {string} - HTML string of the image.\r\n * @private\r\n */\r\n private canvasToImageHtml(element: HTMLCanvasElement): string {\r\n const dataUrl = element.toDataURL();\r\n return `<img src=\"${dataUrl}\" style=\"max-width: 100%;\">`;\r\n }\r\n\r\n /**\r\n * Includes canvas contents in the print section via img tags.\r\n *\r\n * @param {HTMLCollectionOf<HTMLCanvasElement>} elements - Collection of canvas elements.\r\n * @private\r\n */\r\n private updateCanvasToImage(elements: HTMLCollectionOf<HTMLCanvasElement>): void {\r\n for (let i = 0; i < elements.length; i++) {\r\n const element = this.canvasToImageHtml(elements[i]);\r\n elements[i].insertAdjacentHTML('afterend', element);\r\n elements[i].remove();\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the HTML content of a specified printing section.\r\n *\r\n * @param {string} printSectionId - Id of the printing section.\r\n * @returns {string | null} - HTML content of the printing section, or null if not found.\r\n * @private\r\n */\r\n private getHtmlContents(printSectionId: string): string | null {\r\n const printContents = document.getElementById(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 const canvasEls = printContents.getElementsByTagName('canvas');\r\n\r\n this.updateInputDefaults(inputEls);\r\n this.updateSelectDefaults(selectEls);\r\n this.updateTextAreaDefaults(textAreaEls);\r\n this.updateCanvasToImage(canvasEls);\r\n\r\n return printContents.innerHTML;\r\n }\r\n\r\n /**\r\n * Retrieves the HTML content of elements with the specified tag.\r\n *\r\n * @param {keyof HTMLElementTagNameMap} tag - HTML tag name.\r\n * @returns {string} - Concatenated outerHTML of elements with the specified tag.\r\n * @private\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 //#endregion\r\n\r\n protected notifyPrintComplete() {\r\n this.printComplete.next();\r\n }\r\n\r\n /**\r\n * Prints the specified content using the provided print options.\r\n *\r\n * @param {PrintOptions} printOptions - Options for printing.\r\n * @public\r\n */\r\n protected print(printOptions: PrintOptions): void {\r\n let styles = '',\r\n links = '',\r\n popOut = 'top=0,left=0,height=auto,width=auto';\r\n const baseTag = this.getElementTag('base');\r\n\r\n if (printOptions.useExistingCss) {\r\n styles = this.getElementTag('style');\r\n links = this.getElementTag('link');\r\n }\r\n\r\n // If the openNewTab option is set to true, then set the popOut option to an empty string.\r\n // This will cause the print dialog to open in a new tab.\r\n if (printOptions.openNewTab) {\r\n popOut = '';\r\n }\r\n\r\n const printContents = this.getHtmlContents(printOptions.printSectionId);\r\n if (!printContents) {\r\n // Handle the case where the specified print section is not found.\r\n console.error(`Print section with id ${printOptions.printSectionId} not found.`);\r\n return;\r\n }\r\n\r\n const popupWin = window.open('', '_blank', popOut);\r\n\r\n if (!popupWin) {\r\n // the popup window could not be opened.\r\n console.error('Could not open print window.');\r\n return;\r\n }\r\n\r\n popupWin.document.open();\r\n\r\n // Create the HTML structure\r\n const doc = popupWin.document;\r\n\r\n // Set up the basic HTML structure\r\n const html = doc.createElement('html');\r\n const head = doc.createElement('head');\r\n const body = doc.createElement('body');\r\n\r\n // Set title\r\n const title = doc.createElement('title');\r\n title.textContent = printOptions.printTitle || '';\r\n head.appendChild(title);\r\n\r\n // Add base tag, styles, and links\r\n if (baseTag) {\r\n head.innerHTML += baseTag;\r\n }\r\n head.innerHTML += this.returnStyleValues();\r\n head.innerHTML += this.returnStyleSheetLinkTags();\r\n head.innerHTML += styles;\r\n head.innerHTML += links;\r\n\r\n // Set body class if provided\r\n if (printOptions.bodyClass) {\r\n body.className = printOptions.bodyClass;\r\n }\r\n\r\n // Insert print contents\r\n body.innerHTML += printContents;\r\n\r\n // Add script\r\n const script = doc.createElement('script');\r\n script.defer = true;\r\n\r\n if (this.nonce) {\r\n script.setAttribute('nonce', this.nonce);\r\n }\r\n\r\n script.textContent = `\r\n function triggerPrint(event) {\r\n window.removeEventListener('load', triggerPrint, false);\r\n ${\r\n printOptions.previewOnly\r\n ? ''\r\n : `setTimeout(function() {\r\n closeWindow(window.print());\r\n }, ${printOptions.printDelay});`\r\n }\r\n }\r\n function closeWindow(){\r\n ${printOptions.closeWindow ? 'window.close();' : ''}\r\n }\r\n window.addEventListener('load', triggerPrint, false);\r\n window.addEventListener('afterprint', function () {\r\n if (window.opener) {\r\n window.opener.postMessage({ type: 'print-complete' }, '*');\r\n }\r\n closeWindow();\r\n }, { once: true });\r\n `;\r\n body.appendChild(script);\r\n\r\n // Assemble the document\r\n html.appendChild(head);\r\n html.appendChild(body);\r\n doc.appendChild(html);\r\n\r\n popupWin.document.close();\r\n const handleMessage = (event: MessageEvent) => {\r\n if (event.data?.type === 'print-complete') {\r\n // Notify of print completion\r\n this.notifyPrintComplete();\r\n window.removeEventListener('message', handleMessage);\r\n }\r\n };\r\n\r\n window.addEventListener('message', handleMessage);\r\n }\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { PrintBase } from './ngx-print.base';\r\nimport { PrintOptions } from './print-options';\r\n\r\n/**\r\n * Service for handling printing functionality in Angular applications.\r\n * Extends the base printing class (PrintBase).\r\n *\r\n * @export\r\n * @class NgxPrintService\r\n * @extends {PrintBase}\r\n */\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class NgxPrintService extends PrintBase {\r\n printComplete$ = this.printComplete.asObservable();\r\n /**\r\n * Initiates the printing process using the provided print options.\r\n *\r\n * @param {PrintOptions} printOptions - Options for configuring the printing process.\r\n * @memberof NgxPrintService\r\n * @returns {void}\r\n */\r\n public print(printOptions: PrintOptions): void {\r\n // Call the print method in the parent class\r\n super.print(printOptions);\r\n }\r\n\r\n /**\r\n * Sets the print style for the printing process.\r\n *\r\n * @param {{ [key: string]: { [key: string]: string } }} values - A dictionary representing the print styles.\r\n * @memberof NgxPrintService\r\n * @setter\r\n */\r\n set printStyle(values: { [key: string]: { [key: string]: string } }) {\r\n super.setPrintStyle(values);\r\n }\r\n\r\n /**\r\n * Sets the stylesheet file for the printing process.\r\n *\r\n * @param {string} cssList - A string representing the path to the stylesheet file.\r\n * @memberof NgxPrintService\r\n * @setter\r\n */\r\n set styleSheetFile(cssList: string) {\r\n super.setStyleSheetFile(cssList);\r\n }\r\n}\r\n","export class PrintOptions {\r\n printSectionId: string = '';\r\n printTitle: string = '';\r\n useExistingCss: boolean = false;\r\n bodyClass: string = '';\r\n openNewTab: boolean = false;\r\n previewOnly: boolean = false;\r\n closeWindow: boolean = true;\r\n printDelay: number = 0;\r\n\r\n constructor(options?: Partial<PrintOptions>) {\r\n if (options) {\r\n Object.assign(this, options);\r\n }\r\n }\r\n}\r\n","import { Directive, HostListener, Input, output } from '@angular/core';\r\nimport { PrintBase } from './ngx-print.base';\r\nimport { PrintOptions } from './print-options';\r\nimport { take } from 'rxjs';\r\n@Directive({\r\n selector: '[ngxPrint]',\r\n standalone: true,\r\n})\r\nexport class NgxPrintDirective extends PrintBase {\r\n private printOptions = new PrintOptions();\r\n /**\r\n * Prevents the print dialog from opening on the window\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set previewOnly(value: boolean) {\r\n this.printOptions = { ...this.printOptions, previewOnly: value };\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set printSectionId(value: string) {\r\n this.printOptions = { ...this.printOptions, printSectionId: value };\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set printTitle(value: string) {\r\n this.printOptions = { ...this.printOptions, printTitle: value };\r\n }\r\n\r\n /**\r\n *\r\n *\r\n * @memberof NgxPrintDirective\r\n */\r\n @Input() set useExistingCss(value: boolean) {\r\n this.printOptions = { ...this.printOptions, useExistingCss: value };\r\n }\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() set printDelay(value: number) {\r\n this.printOptions = { ...this.printOptions, printDelay: value };\r\n }\r\n\r\n /**\r\n * Whether to close the window after print() returns.\r\n *\r\n */\r\n @Input() set closeWindow(value: boolean) {\r\n this.printOptions = { ...this.printOptions, closeWindow: value };\r\n }\r\n\r\n /**\r\n * Class attribute to apply to the body element.\r\n *\r\n */\r\n @Input() set bodyClass(value: string) {\r\n this.printOptions = { ...this.printOptions, bodyClass: value };\r\n }\r\n\r\n /**\r\n * Whether to open a new window or default to new window.\r\n *\r\n */\r\n @Input() set openNewTab(value: boolean) {\r\n this.printOptions = { ...this.printOptions, openNewTab: value };\r\n }\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 super.setPrintStyle(values);\r\n }\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 super.setStyleSheetFile(cssList);\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 super.print(this.printOptions);\r\n this.printComplete.pipe(take(1)).subscribe(() => {\r\n this.printCompleted.emit(undefined);\r\n });\r\n }\r\n\r\n readonly printCompleted = output<void>();\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\nexport { NgxPrintService } from './lib/ngx-print.service';\r\nexport { NgxPrintDirective } from './lib/ngx-print.directive';\r\nexport { NgxPrintModule } from './lib/ngx-print.module';\r\nexport { PrintOptions } from './lib/print-options';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"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EAAA,CAAA;sBAAtB;gBASY,cAAc,EAAA,CAAA;sBAA1B;gBASY,UAAU,EAAA,CAAA;sBAAtB;gBAQY,WAAW,EAAA,CAAA;sBAAvB;gBAQY,SAAS,EAAA,CAAA;sBAArB;gBAQY,UAAU,EAAA,CAAA;sBAAtB;gBAUG,UAAU,EAAA,CAAA;sBADb;gBAUG,cAAc,EAAA,CAAA;sBADjB;gBAWM,KAAK,EAAA,CAAA;sBADX,YAAY;uBAAC,OAAO;;;MChGV,cAAc,CAAA;uGAAd,cAAc,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;wGAAd,cAAc,EAAA,OAAA,EAAA,CAHf,iBAAiB,CAAA,EAAA,OAAA,EAAA,CACjB,iBAAiB,CAAA,EAAA,CAAA;wGAEhB,cAAc,EAAA,CAAA;;2FAAd,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;;;ACND;;AAEG;;ACFH;;AAEG;;;;"}
package/index.d.ts CHANGED
@@ -1,6 +1,241 @@
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
+
1
119
  /**
2
- * Generated bundle index. Do not edit.
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}
3
126
  */
4
- /// <amd-module name="ngx-print" />
5
- export * from './public_api';
6
- //# sourceMappingURL=ngx-print.d.ts.map
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 ADDED
@@ -0,0 +1 @@
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;;;AAgHD;;AC/SD;;;;;;;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;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-print",
3
- "version": "3.1.0",
3
+ "version": "20.0.0",
4
4
  "description": "Plug n' Play Angular (2++) directive to print your stuff",
5
5
  "author": "https://github.com/selemxmn/ngx-print/graphs/contributors",
6
6
  "repository": {
@@ -22,6 +22,9 @@
22
22
  "dependency",
23
23
  "angular-print"
24
24
  ],
25
+ "peerDependencies": {
26
+ "rxjs": "^7.4.0"
27
+ },
25
28
  "module": "fesm2022/ngx-print.mjs",
26
29
  "typings": "index.d.ts",
27
30
  "exports": {
@@ -1,103 +0,0 @@
1
- import { PrintOptions } from './print-options';
2
- import * as i0 from "@angular/core";
3
- export declare class PrintBase {
4
- private nonce?;
5
- private _printStyle;
6
- private _styleSheetFile;
7
- constructor(nonce?: string | null | undefined);
8
- /**
9
- * Sets the print styles based on the provided values.
10
- *
11
- * @param {Object} values - Key-value pairs representing print styles.
12
- * @protected
13
- */
14
- protected setPrintStyle(values: {
15
- [key: string]: {
16
- [key: string]: string;
17
- };
18
- }): void;
19
- /**
20
- *
21
- *
22
- * @returns the string that create the stylesheet which will be injected
23
- * later within <style></style> tag.
24
- *
25
- * -join/replace to transform an array objects to css-styled string
26
- */
27
- returnStyleValues(): string;
28
- /**
29
- * @returns string which contains the link tags containing the css which will
30
- * be injected later within <head></head> tag.
31
- *
32
- */
33
- private returnStyleSheetLinkTags;
34
- /**
35
- * Sets the style sheet file based on the provided CSS list.
36
- *
37
- * @param {string} cssList - CSS file or list of CSS files.
38
- * @protected
39
- */
40
- protected setStyleSheetFile(cssList: string): void;
41
- /**
42
- * Updates the default values for input elements.
43
- *
44
- * @param {HTMLCollectionOf<HTMLInputElement>} elements - Collection of input elements.
45
- * @private
46
- */
47
- private updateInputDefaults;
48
- /**
49
- * Updates the default values for select elements.
50
- *
51
- * @param {HTMLCollectionOf<HTMLSelectElement>} elements - Collection of select elements.
52
- * @private
53
- */
54
- private updateSelectDefaults;
55
- /**
56
- * Updates the default values for textarea elements.
57
- *
58
- * @param {HTMLCollectionOf<HTMLTextAreaElement>} elements - Collection of textarea elements.
59
- * @private
60
- */
61
- private updateTextAreaDefaults;
62
- /**
63
- * Converts a canvas element to an image and returns its HTML string.
64
- *
65
- * @param {HTMLCanvasElement} element - The canvas element to convert.
66
- * @returns {string} - HTML string of the image.
67
- * @private
68
- */
69
- private canvasToImageHtml;
70
- /**
71
- * Includes canvas contents in the print section via img tags.
72
- *
73
- * @param {HTMLCollectionOf<HTMLCanvasElement>} elements - Collection of canvas elements.
74
- * @private
75
- */
76
- private updateCanvasToImage;
77
- /**
78
- * Retrieves the HTML content of a specified printing section.
79
- *
80
- * @param {string} printSectionId - Id of the printing section.
81
- * @returns {string | null} - HTML content of the printing section, or null if not found.
82
- * @private
83
- */
84
- private getHtmlContents;
85
- /**
86
- * Retrieves the HTML content of elements with the specified tag.
87
- *
88
- * @param {keyof HTMLElementTagNameMap} tag - HTML tag name.
89
- * @returns {string} - Concatenated outerHTML of elements with the specified tag.
90
- * @private
91
- */
92
- private getElementTag;
93
- /**
94
- * Prints the specified content using the provided print options.
95
- *
96
- * @param {PrintOptions} printOptions - Options for printing.
97
- * @public
98
- */
99
- protected print(printOptions: PrintOptions): void;
100
- static ɵfac: i0.ɵɵFactoryDeclaration<PrintBase, [{ optional: true; }]>;
101
- static ɵprov: i0.ɵɵInjectableDeclaration<PrintBase>;
102
- }
103
- //# sourceMappingURL=ngx-print.base.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ngx-print.base.d.ts","sourceRoot":"","sources":["../../../src/lib/ngx-print.base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;;AAE/C,qBAGa,SAAS;IAIuB,OAAO,CAAC,KAAK,CAAC;IAHzD,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,eAAe,CAAc;gBAEc,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,YAAA;IAGxE;;;;;OAKG;IACH,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAA;KAAE;IAS5E;;;;;;;OAOG;IACI,iBAAiB;IAKxB;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAIhC;;;;;OAKG;IACH,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM;IAiB3C;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAQ3B;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;;;;OAKG;IACH,OAAO,CAAC,sBAAsB;IAO9B;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IAKzB;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAQ3B;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IAiBvB;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IAUrB;;;;;OAKG;IACH,SAAS,CAAC,KAAK,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;yCAvLtC,SAAS;6CAAT,SAAS;CAmRrB"}
@@ -1,74 +0,0 @@
1
- import { PrintBase } from './ngx-print.base';
2
- import * as i0 from "@angular/core";
3
- export declare class NgxPrintDirective extends PrintBase {
4
- private printOptions;
5
- /**
6
- * Prevents the print dialog from opening on the window
7
- *
8
- * @memberof NgxPrintDirective
9
- */
10
- set previewOnly(value: boolean);
11
- /**
12
- *
13
- *
14
- * @memberof NgxPrintDirective
15
- */
16
- set printSectionId(value: string);
17
- /**
18
- *
19
- *
20
- * @memberof NgxPrintDirective
21
- */
22
- set printTitle(value: string);
23
- /**
24
- *
25
- *
26
- * @memberof NgxPrintDirective
27
- */
28
- set useExistingCss(value: boolean);
29
- /**
30
- * A delay in milliseconds to force the print dialog to wait before opened. Default: 0
31
- *
32
- * @memberof NgxPrintDirective
33
- */
34
- set printDelay(value: number);
35
- /**
36
- * Whether to close the window after print() returns.
37
- *
38
- */
39
- set closeWindow(value: boolean);
40
- /**
41
- * Class attribute to apply to the body element.
42
- *
43
- */
44
- set bodyClass(value: string);
45
- /**
46
- * Whether to open a new window or default to new window.
47
- *
48
- */
49
- set openNewTab(value: boolean);
50
- /**
51
- *
52
- *
53
- * @memberof NgxPrintDirective
54
- */
55
- set printStyle(values: {
56
- [key: string]: {
57
- [key: string]: string;
58
- };
59
- });
60
- /**
61
- * @memberof NgxPrintDirective
62
- * @param cssList
63
- */
64
- set styleSheetFile(cssList: string);
65
- /**
66
- *
67
- *
68
- * @memberof NgxPrintDirective
69
- */
70
- print(): void;
71
- static ɵfac: i0.ɵɵFactoryDeclaration<NgxPrintDirective, never>;
72
- 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; }; }, {}, never, never, true, never>;
73
- }
74
- //# sourceMappingURL=ngx-print.directive.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ngx-print.directive.d.ts","sourceRoot":"","sources":["../../../src/lib/ngx-print.directive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;;AAE7C,qBAIa,iBAAkB,SAAQ,SAAS;IAC9C,OAAO,CAAC,YAAY,CAAsB;IAC1C;;;;OAIG;IACH,IAAa,WAAW,CAAC,KAAK,EAAE,OAAO,EAEtC;IAED;;;;OAIG;IACH,IAAa,cAAc,CAAC,KAAK,EAAE,MAAM,EAExC;IAED;;;;OAIG;IACH,IAAa,UAAU,CAAC,KAAK,EAAE,MAAM,EAEpC;IAED;;;;OAIG;IACH,IAAa,cAAc,CAAC,KAAK,EAAE,OAAO,EAEzC;IAED;;;;OAIG;IACH,IAAa,UAAU,CAAC,KAAK,EAAE,MAAM,EAEpC;IAED;;;OAGG;IACH,IAAa,WAAW,CAAC,KAAK,EAAE,OAAO,EAEtC;IAED;;;OAGG;IACH,IAAa,SAAS,CAAC,KAAK,EAAE,MAAM,EAEnC;IAED;;;OAGG;IACH,IAAa,UAAU,CAAC,KAAK,EAAE,OAAO,EAErC;IAED;;;;OAIG;IACH,IACI,UAAU,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAA;KAAE,EAElE;IAED;;;OAGG;IACH,IACI,cAAc,CAAC,OAAO,EAAE,MAAM,EAEjC;IAED;;;;OAIG;IAEI,KAAK,IAAI,IAAI;yCAhGT,iBAAiB;2CAAjB,iBAAiB;CAmG7B"}
@@ -1,8 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- import * as i1 from "./ngx-print.directive";
3
- export declare class NgxPrintModule {
4
- static ɵfac: i0.ɵɵFactoryDeclaration<NgxPrintModule, never>;
5
- static ɵmod: i0.ɵɵNgModuleDeclaration<NgxPrintModule, never, [typeof i1.NgxPrintDirective], [typeof i1.NgxPrintDirective]>;
6
- static ɵinj: i0.ɵɵInjectorDeclaration<NgxPrintModule>;
7
- }
8
- //# sourceMappingURL=ngx-print.module.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ngx-print.module.d.ts","sourceRoot":"","sources":["../../../src/lib/ngx-print.module.ts"],"names":[],"mappings":";;AAGA,qBAIa,cAAc;yCAAd,cAAc;0CAAd,cAAc;0CAAd,cAAc;CAAG"}
@@ -1,44 +0,0 @@
1
- import { PrintBase } from './ngx-print.base';
2
- import { PrintOptions } from './print-options';
3
- import * as i0 from "@angular/core";
4
- /**
5
- * Service for handling printing functionality in Angular applications.
6
- * Extends the base printing class (PrintBase).
7
- *
8
- * @export
9
- * @class NgxPrintService
10
- * @extends {PrintBase}
11
- */
12
- export declare class NgxPrintService extends PrintBase {
13
- /**
14
- * Initiates the printing process using the provided print options.
15
- *
16
- * @param {PrintOptions} printOptions - Options for configuring the printing process.
17
- * @memberof NgxPrintService
18
- * @returns {void}
19
- */
20
- print(printOptions: PrintOptions): void;
21
- /**
22
- * Sets the print style for the printing process.
23
- *
24
- * @param {{ [key: string]: { [key: string]: string } }} values - A dictionary representing the print styles.
25
- * @memberof NgxPrintService
26
- * @setter
27
- */
28
- set printStyle(values: {
29
- [key: string]: {
30
- [key: string]: string;
31
- };
32
- });
33
- /**
34
- * Sets the stylesheet file for the printing process.
35
- *
36
- * @param {string} cssList - A string representing the path to the stylesheet file.
37
- * @memberof NgxPrintService
38
- * @setter
39
- */
40
- set styleSheetFile(cssList: string);
41
- static ɵfac: i0.ɵɵFactoryDeclaration<NgxPrintService, never>;
42
- static ɵprov: i0.ɵɵInjectableDeclaration<NgxPrintService>;
43
- }
44
- //# sourceMappingURL=ngx-print.service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ngx-print.service.d.ts","sourceRoot":"","sources":["../../../src/lib/ngx-print.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;;AAE/C;;;;;;;GAOG;AACH,qBAGa,eAAgB,SAAQ,SAAS;IAC5C;;;;;;OAMG;IACI,KAAK,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IAK9C;;;;;;OAMG;IACH,IAAI,UAAU,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAA;KAAE,EAElE;IAED;;;;;;OAMG;IACH,IAAI,cAAc,CAAC,OAAO,EAAE,MAAM,EAEjC;yCAjCU,eAAe;6CAAf,eAAe;CAkC3B"}
@@ -1,12 +0,0 @@
1
- export declare class PrintOptions {
2
- printSectionId: string;
3
- printTitle: string;
4
- useExistingCss: boolean;
5
- bodyClass: string;
6
- openNewTab: boolean;
7
- previewOnly: boolean;
8
- closeWindow: boolean;
9
- printDelay: number;
10
- constructor(options?: Partial<PrintOptions>);
11
- }
12
- //# sourceMappingURL=print-options.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"print-options.d.ts","sourceRoot":"","sources":["../../../src/lib/print-options.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAY;IACvB,cAAc,EAAE,MAAM,CAAM;IAC5B,UAAU,EAAE,MAAM,CAAM;IACxB,cAAc,EAAE,OAAO,CAAS;IAChC,SAAS,EAAE,MAAM,CAAM;IACvB,UAAU,EAAE,OAAO,CAAS;IAC5B,WAAW,EAAE,OAAO,CAAS;IAC7B,WAAW,EAAE,OAAO,CAAQ;IAC5B,UAAU,EAAE,MAAM,CAAK;gBAEX,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC;CAK5C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ngx-print.d.ts","sourceRoot":"","sources":["../../src/ngx-print.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,cAAc,cAAc,CAAC"}
package/public_api.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export { NgxPrintService } from './lib/ngx-print.service';
2
- export { NgxPrintDirective } from './lib/ngx-print.directive';
3
- export { NgxPrintModule } from './lib/ngx-print.module';
4
- export { PrintOptions } from './lib/print-options';
5
- //# sourceMappingURL=public_api.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"public_api.d.ts","sourceRoot":"","sources":["../../src/public_api.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC"}