@oxog/printkit 1.1.0 → 1.2.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 +21 -4
- package/dist/chunk-II3B3JRX.cjs +491 -0
- package/dist/chunk-II3B3JRX.cjs.map +1 -0
- package/dist/chunk-PSFVJVSZ.js +491 -0
- package/dist/chunk-PSFVJVSZ.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +1 -1
- package/dist/{errors-B6q-4bX_.d.cts → page-break-Dr7lwsIh.d.cts} +45 -26
- package/dist/{errors-B6q-4bX_.d.ts → page-break-Dr7lwsIh.d.ts} +45 -26
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +9 -8
- package/dist/react.d.ts +9 -8
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/package.json +19 -10
- package/dist/chunk-KWR7DOLQ.cjs +0 -482
- package/dist/chunk-KWR7DOLQ.cjs.map +0 -1
- package/dist/chunk-YHD5OSS6.js +0 -482
- package/dist/chunk-YHD5OSS6.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkII3B3JRX_cjs=require('./chunk-II3B3JRX.cjs');function W(){return `job-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}var a=class{constructor(){this.listeners=new Map;}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e)?.add(t),()=>this.off(e,t)}off(e,t){this.listeners.get(e)?.delete(t);}emit(e,...t){this.listeners.get(e)?.forEach(r=>{try{r(...t);}catch(i){console.error(`Error in event handler for ${e}:`,i);}});}clear(){this.listeners.clear();}},u=class{constructor(e){this.jobs=new Map;this.emitter=new a;this.isPaused=false;this.isProcessing=false;this.running=null;this.defaultOptions=e??{},this.printer=chunkII3B3JRX_cjs.P(this.defaultOptions);}add(e){let t=W(),r={...e,id:t,status:"pending",createdAt:new Date};return this.jobs.set(t,r),t}remove(e){return this.jobs.delete(e)}retry(e){let t=this.jobs.get(e);return !t||t.status!=="failed"?false:(t.status="pending",delete t.error,delete t.completedAt,true)}clear(){this.jobs.clear();}getJob(e){return this.jobs.get(e)}getJobs(){return Array.from(this.jobs.values())}getPendingJobs(){let e={high:0,normal:1,low:2};return Array.from(this.jobs.values()).filter(t=>t.status==="pending").sort((t,r)=>{let i=e[t.priority??"normal"],n=e[r.priority??"normal"];return i!==n?i-n:t.createdAt.getTime()-r.createdAt.getTime()})}async printNext(){if(this.isPaused||this.isProcessing)return;let t=this.getPendingJobs()[0];t&&await this.processJob(t);}printAll(){return this.isPaused?Promise.resolve():(this.running||(this.running=this.runAll().finally(()=>{this.running=null;})),this.running)}async runAll(){for(;!this.isPaused;){let t=this.getPendingJobs()[0];if(!t)break;await this.processJob(t);}this.isPaused||this.emitter.emit("queueComplete");}pause(){this.isPaused=true,this.emitter.emit("queuePause");}resume(){this.isPaused=false,this.emitter.emit("queueResume");}on(e,t){return this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t);}destroy(){this.clear(),this.emitter.clear(),this.printer.destroy();}async processJob(e){if(!this.isPaused){this.isProcessing=true,e.status="printing",this.emitter.emit("jobStart",e);try{let t=1+Math.max(0,Math.floor(e.retries??0)),r;for(let i=0;i<t;i++){e.attempts=(e.attempts??0)+1;try{await this.printer.print(e.content,e.options),e.status="completed",e.completedAt=new Date,this.emitter.emit("jobComplete",e);return}catch(n){if(r=n,!this.jobs.has(e.id))break}}e.status="failed",e.error=r instanceof Error?r:new Error(String(r)),e.completedAt=new Date,this.emitter.emit("jobError",e,e.error);}finally{this.isProcessing=false;}}}};function X(s){return new u(s)}Object.defineProperty(exports,"AVOID_BREAK_CLASS",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.t}});Object.defineProperty(exports,"BREAK_AFTER_CLASS",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.s}});Object.defineProperty(exports,"BREAK_BEFORE_CLASS",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.r}});Object.defineProperty(exports,"PAGE_SIZES",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.m}});Object.defineProperty(exports,"PRINT_HIDE_CLASS",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.J}});Object.defineProperty(exports,"PRINT_ONLY_CLASS",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.K}});Object.defineProperty(exports,"PrintError",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.d}});Object.defineProperty(exports,"avoidBreak",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.v}});Object.defineProperty(exports,"breakAfter",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.x}});Object.defineProperty(exports,"breakBefore",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.w}});Object.defineProperty(exports,"buildStyleTag",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.F}});Object.defineProperty(exports,"calculatePages",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.y}});Object.defineProperty(exports,"cloneElement",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.k}});Object.defineProperty(exports,"combineStyles",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.G}});Object.defineProperty(exports,"copyPageStyles",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.H}});Object.defineProperty(exports,"createPDFExporter",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.R}});Object.defineProperty(exports,"createPageInfo",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.z}});Object.defineProperty(exports,"createPrintError",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.e}});Object.defineProperty(exports,"createPrintPreview",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.S}});Object.defineProperty(exports,"createPrinter",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.P}});Object.defineProperty(exports,"getAllDefaultStyles",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.N}});Object.defineProperty(exports,"getBaseDocumentStyles",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.M}});Object.defineProperty(exports,"getComputedStylesCSS",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.I}});Object.defineProperty(exports,"getDefaultPrintStyles",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.L}});Object.defineProperty(exports,"getDefaultPrinter",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.Q}});Object.defineProperty(exports,"getMarginsInPixels",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.q}});Object.defineProperty(exports,"getPageDimensions",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.n}});Object.defineProperty(exports,"getPagePixelDimensions",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.o}});Object.defineProperty(exports,"injectPrintStyles",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.C}});Object.defineProperty(exports,"isBrowser",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.c}});Object.defineProperty(exports,"isPDFSupported",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.b}});Object.defineProperty(exports,"isPrintError",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.f}});Object.defineProperty(exports,"isPrintSupported",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.a}});Object.defineProperty(exports,"normalizeMargins",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.p}});Object.defineProperty(exports,"pageBreak",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.u}});Object.defineProperty(exports,"removeAllPrintStyles",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.E}});Object.defineProperty(exports,"removePrintStyles",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.D}});Object.defineProperty(exports,"renderHeaderFooter",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.B}});Object.defineProperty(exports,"replacePlaceholders",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.A}});Object.defineProperty(exports,"resolveElement",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.i}});Object.defineProperty(exports,"resolveElements",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.j}});Object.defineProperty(exports,"sanitizeHTML",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.h}});Object.defineProperty(exports,"waitForImages",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.l}});Object.defineProperty(exports,"wrapError",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.g}});exports.createPrintQueue=X;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PrintOptions,
|
|
2
|
-
export { A as AVOID_BREAK_CLASS,
|
|
1
|
+
import { P as PrintOptions, j as Printer, a as PrintTarget, c as PreviewOptions, k as PrintPreview, l as PDFExporter, m as PrintQueue, n as PageSizeName, D as Dimensions, h as PageSize, O as Orientation, M as MarginOptions, o as PageInfo, H as HeaderFooterFn } from './page-break-Dr7lwsIh.cjs';
|
|
2
|
+
export { A as AVOID_BREAK_CLASS, B as BREAK_AFTER_CLASS, e as BREAK_BEFORE_CLASS, C as CustomSize, F as FormatOptions, J as JobPriority, p as JobStatus, q as ModalOptions, N as NewPrintJob, r as PDFMetadata, d as PDFOptions, f as PRINT_HIDE_CLASS, g as PRINT_ONLY_CLASS, s as PageOptions, t as PrintDocument, b as PrintError, u as PrintErrorCode, v as PrintErrorType, w as PrintJSONOptions, x as PrintJob, y as PrintTableOptions, Q as QueueEvent, z as QueueEventHandler, T as TableData, E as ToolbarOptions, G as avoidBreak, I as breakAfter, K as breakBefore, L as calculatePages, R as createPrintError, S as getAllDefaultStyles, U as getBaseDocumentStyles, V as getDefaultPrintStyles, i as isPrintError, W as pageBreak, X as wrapError } from './page-break-Dr7lwsIh.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Creates a new Printer instance
|
|
@@ -41,11 +41,17 @@ declare function isBrowser(): boolean;
|
|
|
41
41
|
/**
|
|
42
42
|
* Sanitizes untrusted HTML so it can be written into a print document.
|
|
43
43
|
*
|
|
44
|
-
* The markup is parsed into an inert document and
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
44
|
+
* The markup is parsed into an inert document and walked with an allow-list:
|
|
45
|
+
* only known HTML and SVG formatting elements and attributes are kept.
|
|
46
|
+
* Scripts, frames, plugins, `<base>`, `<meta>`, `<template>`, MathML, SVG
|
|
47
|
+
* animation and `<foreignObject>`, `on*` handlers, `srcdoc`, `formaction` and
|
|
48
|
+
* every URL other than relative, `http(s):`, `mailto:`, `tel:` and `ftp:` (plus
|
|
49
|
+
* `data:image/...` and `blob:` for images) are removed. Unknown elements are
|
|
50
|
+
* replaced by their content, so text is kept.
|
|
51
|
+
*
|
|
52
|
+
* Markup can change meaning when it is serialized and parsed again (mutation
|
|
53
|
+
* XSS), so the result is parsed and sanitized again until it no longer
|
|
54
|
+
* changes; markup that never settles is reduced to its escaped text.
|
|
49
55
|
*
|
|
50
56
|
* Without a DOM (e.g. during server-side rendering) the whole string is
|
|
51
57
|
* HTML-escaped, so the result is always safe to insert.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PrintOptions,
|
|
2
|
-
export { A as AVOID_BREAK_CLASS,
|
|
1
|
+
import { P as PrintOptions, j as Printer, a as PrintTarget, c as PreviewOptions, k as PrintPreview, l as PDFExporter, m as PrintQueue, n as PageSizeName, D as Dimensions, h as PageSize, O as Orientation, M as MarginOptions, o as PageInfo, H as HeaderFooterFn } from './page-break-Dr7lwsIh.js';
|
|
2
|
+
export { A as AVOID_BREAK_CLASS, B as BREAK_AFTER_CLASS, e as BREAK_BEFORE_CLASS, C as CustomSize, F as FormatOptions, J as JobPriority, p as JobStatus, q as ModalOptions, N as NewPrintJob, r as PDFMetadata, d as PDFOptions, f as PRINT_HIDE_CLASS, g as PRINT_ONLY_CLASS, s as PageOptions, t as PrintDocument, b as PrintError, u as PrintErrorCode, v as PrintErrorType, w as PrintJSONOptions, x as PrintJob, y as PrintTableOptions, Q as QueueEvent, z as QueueEventHandler, T as TableData, E as ToolbarOptions, G as avoidBreak, I as breakAfter, K as breakBefore, L as calculatePages, R as createPrintError, S as getAllDefaultStyles, U as getBaseDocumentStyles, V as getDefaultPrintStyles, i as isPrintError, W as pageBreak, X as wrapError } from './page-break-Dr7lwsIh.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Creates a new Printer instance
|
|
@@ -41,11 +41,17 @@ declare function isBrowser(): boolean;
|
|
|
41
41
|
/**
|
|
42
42
|
* Sanitizes untrusted HTML so it can be written into a print document.
|
|
43
43
|
*
|
|
44
|
-
* The markup is parsed into an inert document and
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
44
|
+
* The markup is parsed into an inert document and walked with an allow-list:
|
|
45
|
+
* only known HTML and SVG formatting elements and attributes are kept.
|
|
46
|
+
* Scripts, frames, plugins, `<base>`, `<meta>`, `<template>`, MathML, SVG
|
|
47
|
+
* animation and `<foreignObject>`, `on*` handlers, `srcdoc`, `formaction` and
|
|
48
|
+
* every URL other than relative, `http(s):`, `mailto:`, `tel:` and `ftp:` (plus
|
|
49
|
+
* `data:image/...` and `blob:` for images) are removed. Unknown elements are
|
|
50
|
+
* replaced by their content, so text is kept.
|
|
51
|
+
*
|
|
52
|
+
* Markup can change meaning when it is serialized and parsed again (mutation
|
|
53
|
+
* XSS), so the result is parsed and sanitized again until it no longer
|
|
54
|
+
* changes; markup that never settles is reduced to its escaped text.
|
|
49
55
|
*
|
|
50
56
|
* Without a DOM (e.g. during server-side rendering) the whole string is
|
|
51
57
|
* HTML-escaped, so the result is always safe to insert.
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {P}from'./chunk-
|
|
1
|
+
import {P}from'./chunk-PSFVJVSZ.js';export{t as AVOID_BREAK_CLASS,s as BREAK_AFTER_CLASS,r as BREAK_BEFORE_CLASS,m as PAGE_SIZES,J as PRINT_HIDE_CLASS,K as PRINT_ONLY_CLASS,d as PrintError,v as avoidBreak,x as breakAfter,w as breakBefore,F as buildStyleTag,y as calculatePages,k as cloneElement,G as combineStyles,H as copyPageStyles,R as createPDFExporter,z as createPageInfo,e as createPrintError,S as createPrintPreview,P as createPrinter,N as getAllDefaultStyles,M as getBaseDocumentStyles,I as getComputedStylesCSS,L as getDefaultPrintStyles,Q as getDefaultPrinter,q as getMarginsInPixels,n as getPageDimensions,o as getPagePixelDimensions,C as injectPrintStyles,c as isBrowser,b as isPDFSupported,f as isPrintError,a as isPrintSupported,p as normalizeMargins,u as pageBreak,E as removeAllPrintStyles,D as removePrintStyles,B as renderHeaderFooter,A as replacePlaceholders,i as resolveElement,j as resolveElements,h as sanitizeHTML,l as waitForImages,g as wrapError}from'./chunk-PSFVJVSZ.js';function W(){return `job-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}var a=class{constructor(){this.listeners=new Map;}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e)?.add(t),()=>this.off(e,t)}off(e,t){this.listeners.get(e)?.delete(t);}emit(e,...t){this.listeners.get(e)?.forEach(r=>{try{r(...t);}catch(i){console.error(`Error in event handler for ${e}:`,i);}});}clear(){this.listeners.clear();}},u=class{constructor(e){this.jobs=new Map;this.emitter=new a;this.isPaused=false;this.isProcessing=false;this.running=null;this.defaultOptions=e??{},this.printer=P(this.defaultOptions);}add(e){let t=W(),r={...e,id:t,status:"pending",createdAt:new Date};return this.jobs.set(t,r),t}remove(e){return this.jobs.delete(e)}retry(e){let t=this.jobs.get(e);return !t||t.status!=="failed"?false:(t.status="pending",delete t.error,delete t.completedAt,true)}clear(){this.jobs.clear();}getJob(e){return this.jobs.get(e)}getJobs(){return Array.from(this.jobs.values())}getPendingJobs(){let e={high:0,normal:1,low:2};return Array.from(this.jobs.values()).filter(t=>t.status==="pending").sort((t,r)=>{let i=e[t.priority??"normal"],n=e[r.priority??"normal"];return i!==n?i-n:t.createdAt.getTime()-r.createdAt.getTime()})}async printNext(){if(this.isPaused||this.isProcessing)return;let t=this.getPendingJobs()[0];t&&await this.processJob(t);}printAll(){return this.isPaused?Promise.resolve():(this.running||(this.running=this.runAll().finally(()=>{this.running=null;})),this.running)}async runAll(){for(;!this.isPaused;){let t=this.getPendingJobs()[0];if(!t)break;await this.processJob(t);}this.isPaused||this.emitter.emit("queueComplete");}pause(){this.isPaused=true,this.emitter.emit("queuePause");}resume(){this.isPaused=false,this.emitter.emit("queueResume");}on(e,t){return this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t);}destroy(){this.clear(),this.emitter.clear(),this.printer.destroy();}async processJob(e){if(!this.isPaused){this.isProcessing=true,e.status="printing",this.emitter.emit("jobStart",e);try{let t=1+Math.max(0,Math.floor(e.retries??0)),r;for(let i=0;i<t;i++){e.attempts=(e.attempts??0)+1;try{await this.printer.print(e.content,e.options),e.status="completed",e.completedAt=new Date,this.emitter.emit("jobComplete",e);return}catch(n){if(r=n,!this.jobs.has(e.id))break}}e.status="failed",e.error=r instanceof Error?r:new Error(String(r)),e.completedAt=new Date,this.emitter.emit("jobError",e,e.error);}finally{this.isProcessing=false;}}}};function X(s){return new u(s)}export{X as createPrintQueue};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -23,7 +23,21 @@ interface PrintOptions {
|
|
|
23
23
|
pageSize?: PageSize | undefined;
|
|
24
24
|
orientation?: Orientation | undefined;
|
|
25
25
|
margin?: number | string | MarginOptions | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Header template (HTML string with `{title}`, `{date}`, `{time}`, `{page}`
|
|
28
|
+
* and `{pages}` placeholders) or a function returning HTML.
|
|
29
|
+
*
|
|
30
|
+
* When printing, a string with `{page}`/`{pages}` is shown on every page
|
|
31
|
+
* with the real numbers through CSS `@page` margin boxes (as text) in
|
|
32
|
+
* browsers that support them (Chromium 131+). In other browsers, and for
|
|
33
|
+
* templates without those placeholders or function templates, the header
|
|
34
|
+
* is printed once at the top of the document; `{page}`/`{pages}` are left
|
|
35
|
+
* empty and function templates receive page 1 of 1.
|
|
36
|
+
*
|
|
37
|
+
* PDF export draws it on every page with the real page number and count.
|
|
38
|
+
*/
|
|
26
39
|
header?: string | HeaderFooterFn | undefined;
|
|
40
|
+
/** Footer template, see `header`. */
|
|
27
41
|
footer?: string | HeaderFooterFn | undefined;
|
|
28
42
|
styles?: string | string[] | undefined;
|
|
29
43
|
styleSheets?: string[] | undefined;
|
|
@@ -32,6 +46,7 @@ interface PrintOptions {
|
|
|
32
46
|
pageBreakAfter?: string | undefined;
|
|
33
47
|
avoidBreakInside?: string | undefined;
|
|
34
48
|
removeAfterPrint?: boolean | undefined;
|
|
49
|
+
/** Print background colours and images (default true); false removes them from every element */
|
|
35
50
|
printBackground?: boolean | undefined;
|
|
36
51
|
onBeforePrint?: (() => void | Promise<void>) | undefined;
|
|
37
52
|
onAfterPrint?: (() => void) | undefined;
|
|
@@ -42,8 +57,8 @@ interface Printer {
|
|
|
42
57
|
print(target: PrintTarget, options?: PrintOptions): Promise<void>;
|
|
43
58
|
printHTML(html: string, options?: PrintOptions): Promise<void>;
|
|
44
59
|
printURL(url: string, options?: PrintOptions): Promise<void>;
|
|
45
|
-
printImage(src: string | HTMLImageElement, options?: PrintOptions
|
|
46
|
-
printImages(sources: (string | HTMLImageElement)[], options?: PrintOptions
|
|
60
|
+
printImage(src: string | HTMLImageElement, options?: PrintOptions): Promise<void>;
|
|
61
|
+
printImages(sources: (string | HTMLImageElement)[], options?: PrintOptions): Promise<void>;
|
|
47
62
|
printJSON(data: unknown, options?: PrintJSONOptions): Promise<void>;
|
|
48
63
|
printTable(data: TableData, options?: PrintTableOptions): Promise<void>;
|
|
49
64
|
setDefaultOptions(options: PrintOptions): void;
|
|
@@ -108,8 +123,8 @@ interface PDFExporter {
|
|
|
108
123
|
toBlob(target: PrintTarget, options?: PDFOptions): Promise<Blob>;
|
|
109
124
|
toBase64(target: PrintTarget, options?: PDFOptions): Promise<string>;
|
|
110
125
|
toDataURL(target: PrintTarget, options?: PDFOptions): Promise<string>;
|
|
111
|
-
download(target: PrintTarget, filename: string, options?: PDFOptions
|
|
112
|
-
downloadHTML(html: string, filename: string, options?: PDFOptions
|
|
126
|
+
download(target: PrintTarget, filename: string, options?: PDFOptions): Promise<void>;
|
|
127
|
+
downloadHTML(html: string, filename: string, options?: PDFOptions): Promise<void>;
|
|
113
128
|
}
|
|
114
129
|
type JobPriority = 'low' | 'normal' | 'high';
|
|
115
130
|
type JobStatus = 'pending' | 'printing' | 'completed' | 'failed';
|
|
@@ -162,6 +177,10 @@ interface PrintTableOptions extends PrintOptions {
|
|
|
162
177
|
interface PrintJSONOptions extends PrintOptions {
|
|
163
178
|
indent?: number | undefined;
|
|
164
179
|
syntaxHighlight?: boolean | undefined;
|
|
180
|
+
/**
|
|
181
|
+
* @deprecated Has no effect: printed output cannot be collapsed. Accepted
|
|
182
|
+
* for compatibility and will be removed in the next major version.
|
|
183
|
+
*/
|
|
165
184
|
collapsible?: boolean | undefined;
|
|
166
185
|
}
|
|
167
186
|
interface FormatOptions {
|
|
@@ -194,6 +213,27 @@ interface PrintDocument {
|
|
|
194
213
|
title: string;
|
|
195
214
|
}
|
|
196
215
|
|
|
216
|
+
/**
|
|
217
|
+
* Custom error class for print operations
|
|
218
|
+
*/
|
|
219
|
+
declare class PrintError extends Error implements PrintError$1 {
|
|
220
|
+
readonly code: PrintErrorCode;
|
|
221
|
+
readonly target?: PrintTarget | undefined;
|
|
222
|
+
constructor(code: PrintErrorCode, message: string, target?: PrintTarget);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Creates a PrintError with the appropriate message
|
|
226
|
+
*/
|
|
227
|
+
declare function createPrintError(code: PrintErrorCode, details?: string, target?: PrintTarget): PrintError;
|
|
228
|
+
/**
|
|
229
|
+
* Type guard to check if an error is a PrintError
|
|
230
|
+
*/
|
|
231
|
+
declare function isPrintError(error: unknown): error is PrintError;
|
|
232
|
+
/**
|
|
233
|
+
* Wraps an unknown error as a PrintError
|
|
234
|
+
*/
|
|
235
|
+
declare function wrapError(error: unknown, target?: PrintTarget): PrintError;
|
|
236
|
+
|
|
197
237
|
/**
|
|
198
238
|
* CSS class to hide elements when printing
|
|
199
239
|
*/
|
|
@@ -248,25 +288,4 @@ declare function breakAfter(element: HTMLElement): void;
|
|
|
248
288
|
*/
|
|
249
289
|
declare function calculatePages(contentHeight: number, pageHeight: number, marginTop?: number, marginBottom?: number): number;
|
|
250
290
|
|
|
251
|
-
|
|
252
|
-
* Custom error class for print operations
|
|
253
|
-
*/
|
|
254
|
-
declare class PrintError extends Error implements PrintError$1 {
|
|
255
|
-
readonly code: PrintErrorCode;
|
|
256
|
-
readonly target: PrintTarget | undefined;
|
|
257
|
-
constructor(code: PrintErrorCode, message: string, target?: PrintTarget | undefined);
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Creates a PrintError with the appropriate message
|
|
261
|
-
*/
|
|
262
|
-
declare function createPrintError(code: PrintErrorCode, details?: string, target?: PrintTarget): PrintError;
|
|
263
|
-
/**
|
|
264
|
-
* Type guard to check if an error is a PrintError
|
|
265
|
-
*/
|
|
266
|
-
declare function isPrintError(error: unknown): error is PrintError;
|
|
267
|
-
/**
|
|
268
|
-
* Wraps an unknown error as a PrintError
|
|
269
|
-
*/
|
|
270
|
-
declare function wrapError(error: unknown, target?: PrintTarget): PrintError;
|
|
271
|
-
|
|
272
|
-
export { AVOID_BREAK_CLASS as A, BREAK_BEFORE_CLASS as B, type CustomSize as C, type Dimensions as D, type PDFMetadata as E, type PrintJob as F, type JobStatus as G, type HeaderFooterFn as H, type QueueEventHandler as I, type JobPriority as J, type TableData as K, type PrintTableOptions as L, type MarginOptions as M, type NewPrintJob as N, type Orientation as O, type PrintOptions as P, type QueueEvent as Q, type PrintJSONOptions as R, type FormatOptions as S, type ToolbarOptions as T, type PageOptions as U, type PrintErrorCode as V, type PrintError$1 as W, type PrintDocument as X, type Printer as a, type PrintTarget as b, type PreviewOptions as c, type PrintPreview as d, type PDFExporter as e, type PrintQueue as f, type PageSize as g, type PageSizeName as h, type PageInfo as i, getDefaultPrintStyles as j, getBaseDocumentStyles as k, getAllDefaultStyles as l, calculatePages as m, avoidBreak as n, breakBefore as o, pageBreak as p, breakAfter as q, PRINT_HIDE_CLASS as r, PRINT_ONLY_CLASS as s, BREAK_AFTER_CLASS as t, PrintError as u, createPrintError as v, isPrintError as w, wrapError as x, type ModalOptions as y, type PDFOptions as z };
|
|
291
|
+
export { AVOID_BREAK_CLASS as A, BREAK_AFTER_CLASS as B, type CustomSize as C, type Dimensions as D, type ToolbarOptions as E, type FormatOptions as F, avoidBreak as G, type HeaderFooterFn as H, breakAfter as I, type JobPriority as J, breakBefore as K, calculatePages as L, type MarginOptions as M, type NewPrintJob as N, type Orientation as O, type PrintOptions as P, type QueueEvent as Q, createPrintError as R, getAllDefaultStyles as S, type TableData as T, getBaseDocumentStyles as U, getDefaultPrintStyles as V, pageBreak as W, wrapError as X, type PrintTarget as a, PrintError as b, type PreviewOptions as c, type PDFOptions as d, BREAK_BEFORE_CLASS as e, PRINT_HIDE_CLASS as f, PRINT_ONLY_CLASS as g, type PageSize as h, isPrintError as i, type Printer as j, type PrintPreview as k, type PDFExporter as l, type PrintQueue as m, type PageSizeName as n, type PageInfo as o, type JobStatus as p, type ModalOptions as q, type PDFMetadata as r, type PageOptions as s, type PrintDocument as t, type PrintErrorCode as u, type PrintError$1 as v, type PrintJSONOptions as w, type PrintJob as x, type PrintTableOptions as y, type QueueEventHandler as z };
|
|
@@ -23,7 +23,21 @@ interface PrintOptions {
|
|
|
23
23
|
pageSize?: PageSize | undefined;
|
|
24
24
|
orientation?: Orientation | undefined;
|
|
25
25
|
margin?: number | string | MarginOptions | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Header template (HTML string with `{title}`, `{date}`, `{time}`, `{page}`
|
|
28
|
+
* and `{pages}` placeholders) or a function returning HTML.
|
|
29
|
+
*
|
|
30
|
+
* When printing, a string with `{page}`/`{pages}` is shown on every page
|
|
31
|
+
* with the real numbers through CSS `@page` margin boxes (as text) in
|
|
32
|
+
* browsers that support them (Chromium 131+). In other browsers, and for
|
|
33
|
+
* templates without those placeholders or function templates, the header
|
|
34
|
+
* is printed once at the top of the document; `{page}`/`{pages}` are left
|
|
35
|
+
* empty and function templates receive page 1 of 1.
|
|
36
|
+
*
|
|
37
|
+
* PDF export draws it on every page with the real page number and count.
|
|
38
|
+
*/
|
|
26
39
|
header?: string | HeaderFooterFn | undefined;
|
|
40
|
+
/** Footer template, see `header`. */
|
|
27
41
|
footer?: string | HeaderFooterFn | undefined;
|
|
28
42
|
styles?: string | string[] | undefined;
|
|
29
43
|
styleSheets?: string[] | undefined;
|
|
@@ -32,6 +46,7 @@ interface PrintOptions {
|
|
|
32
46
|
pageBreakAfter?: string | undefined;
|
|
33
47
|
avoidBreakInside?: string | undefined;
|
|
34
48
|
removeAfterPrint?: boolean | undefined;
|
|
49
|
+
/** Print background colours and images (default true); false removes them from every element */
|
|
35
50
|
printBackground?: boolean | undefined;
|
|
36
51
|
onBeforePrint?: (() => void | Promise<void>) | undefined;
|
|
37
52
|
onAfterPrint?: (() => void) | undefined;
|
|
@@ -42,8 +57,8 @@ interface Printer {
|
|
|
42
57
|
print(target: PrintTarget, options?: PrintOptions): Promise<void>;
|
|
43
58
|
printHTML(html: string, options?: PrintOptions): Promise<void>;
|
|
44
59
|
printURL(url: string, options?: PrintOptions): Promise<void>;
|
|
45
|
-
printImage(src: string | HTMLImageElement, options?: PrintOptions
|
|
46
|
-
printImages(sources: (string | HTMLImageElement)[], options?: PrintOptions
|
|
60
|
+
printImage(src: string | HTMLImageElement, options?: PrintOptions): Promise<void>;
|
|
61
|
+
printImages(sources: (string | HTMLImageElement)[], options?: PrintOptions): Promise<void>;
|
|
47
62
|
printJSON(data: unknown, options?: PrintJSONOptions): Promise<void>;
|
|
48
63
|
printTable(data: TableData, options?: PrintTableOptions): Promise<void>;
|
|
49
64
|
setDefaultOptions(options: PrintOptions): void;
|
|
@@ -108,8 +123,8 @@ interface PDFExporter {
|
|
|
108
123
|
toBlob(target: PrintTarget, options?: PDFOptions): Promise<Blob>;
|
|
109
124
|
toBase64(target: PrintTarget, options?: PDFOptions): Promise<string>;
|
|
110
125
|
toDataURL(target: PrintTarget, options?: PDFOptions): Promise<string>;
|
|
111
|
-
download(target: PrintTarget, filename: string, options?: PDFOptions
|
|
112
|
-
downloadHTML(html: string, filename: string, options?: PDFOptions
|
|
126
|
+
download(target: PrintTarget, filename: string, options?: PDFOptions): Promise<void>;
|
|
127
|
+
downloadHTML(html: string, filename: string, options?: PDFOptions): Promise<void>;
|
|
113
128
|
}
|
|
114
129
|
type JobPriority = 'low' | 'normal' | 'high';
|
|
115
130
|
type JobStatus = 'pending' | 'printing' | 'completed' | 'failed';
|
|
@@ -162,6 +177,10 @@ interface PrintTableOptions extends PrintOptions {
|
|
|
162
177
|
interface PrintJSONOptions extends PrintOptions {
|
|
163
178
|
indent?: number | undefined;
|
|
164
179
|
syntaxHighlight?: boolean | undefined;
|
|
180
|
+
/**
|
|
181
|
+
* @deprecated Has no effect: printed output cannot be collapsed. Accepted
|
|
182
|
+
* for compatibility and will be removed in the next major version.
|
|
183
|
+
*/
|
|
165
184
|
collapsible?: boolean | undefined;
|
|
166
185
|
}
|
|
167
186
|
interface FormatOptions {
|
|
@@ -194,6 +213,27 @@ interface PrintDocument {
|
|
|
194
213
|
title: string;
|
|
195
214
|
}
|
|
196
215
|
|
|
216
|
+
/**
|
|
217
|
+
* Custom error class for print operations
|
|
218
|
+
*/
|
|
219
|
+
declare class PrintError extends Error implements PrintError$1 {
|
|
220
|
+
readonly code: PrintErrorCode;
|
|
221
|
+
readonly target?: PrintTarget | undefined;
|
|
222
|
+
constructor(code: PrintErrorCode, message: string, target?: PrintTarget);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Creates a PrintError with the appropriate message
|
|
226
|
+
*/
|
|
227
|
+
declare function createPrintError(code: PrintErrorCode, details?: string, target?: PrintTarget): PrintError;
|
|
228
|
+
/**
|
|
229
|
+
* Type guard to check if an error is a PrintError
|
|
230
|
+
*/
|
|
231
|
+
declare function isPrintError(error: unknown): error is PrintError;
|
|
232
|
+
/**
|
|
233
|
+
* Wraps an unknown error as a PrintError
|
|
234
|
+
*/
|
|
235
|
+
declare function wrapError(error: unknown, target?: PrintTarget): PrintError;
|
|
236
|
+
|
|
197
237
|
/**
|
|
198
238
|
* CSS class to hide elements when printing
|
|
199
239
|
*/
|
|
@@ -248,25 +288,4 @@ declare function breakAfter(element: HTMLElement): void;
|
|
|
248
288
|
*/
|
|
249
289
|
declare function calculatePages(contentHeight: number, pageHeight: number, marginTop?: number, marginBottom?: number): number;
|
|
250
290
|
|
|
251
|
-
|
|
252
|
-
* Custom error class for print operations
|
|
253
|
-
*/
|
|
254
|
-
declare class PrintError extends Error implements PrintError$1 {
|
|
255
|
-
readonly code: PrintErrorCode;
|
|
256
|
-
readonly target: PrintTarget | undefined;
|
|
257
|
-
constructor(code: PrintErrorCode, message: string, target?: PrintTarget | undefined);
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Creates a PrintError with the appropriate message
|
|
261
|
-
*/
|
|
262
|
-
declare function createPrintError(code: PrintErrorCode, details?: string, target?: PrintTarget): PrintError;
|
|
263
|
-
/**
|
|
264
|
-
* Type guard to check if an error is a PrintError
|
|
265
|
-
*/
|
|
266
|
-
declare function isPrintError(error: unknown): error is PrintError;
|
|
267
|
-
/**
|
|
268
|
-
* Wraps an unknown error as a PrintError
|
|
269
|
-
*/
|
|
270
|
-
declare function wrapError(error: unknown, target?: PrintTarget): PrintError;
|
|
271
|
-
|
|
272
|
-
export { AVOID_BREAK_CLASS as A, BREAK_BEFORE_CLASS as B, type CustomSize as C, type Dimensions as D, type PDFMetadata as E, type PrintJob as F, type JobStatus as G, type HeaderFooterFn as H, type QueueEventHandler as I, type JobPriority as J, type TableData as K, type PrintTableOptions as L, type MarginOptions as M, type NewPrintJob as N, type Orientation as O, type PrintOptions as P, type QueueEvent as Q, type PrintJSONOptions as R, type FormatOptions as S, type ToolbarOptions as T, type PageOptions as U, type PrintErrorCode as V, type PrintError$1 as W, type PrintDocument as X, type Printer as a, type PrintTarget as b, type PreviewOptions as c, type PrintPreview as d, type PDFExporter as e, type PrintQueue as f, type PageSize as g, type PageSizeName as h, type PageInfo as i, getDefaultPrintStyles as j, getBaseDocumentStyles as k, getAllDefaultStyles as l, calculatePages as m, avoidBreak as n, breakBefore as o, pageBreak as p, breakAfter as q, PRINT_HIDE_CLASS as r, PRINT_ONLY_CLASS as s, BREAK_AFTER_CLASS as t, PrintError as u, createPrintError as v, isPrintError as w, wrapError as x, type ModalOptions as y, type PDFOptions as z };
|
|
291
|
+
export { AVOID_BREAK_CLASS as A, BREAK_AFTER_CLASS as B, type CustomSize as C, type Dimensions as D, type ToolbarOptions as E, type FormatOptions as F, avoidBreak as G, type HeaderFooterFn as H, breakAfter as I, type JobPriority as J, breakBefore as K, calculatePages as L, type MarginOptions as M, type NewPrintJob as N, type Orientation as O, type PrintOptions as P, type QueueEvent as Q, createPrintError as R, getAllDefaultStyles as S, type TableData as T, getBaseDocumentStyles as U, getDefaultPrintStyles as V, pageBreak as W, wrapError as X, type PrintTarget as a, PrintError as b, type PreviewOptions as c, type PDFOptions as d, BREAK_BEFORE_CLASS as e, PRINT_HIDE_CLASS as f, PRINT_ONLY_CLASS as g, type PageSize as h, isPrintError as i, type Printer as j, type PrintPreview as k, type PDFExporter as l, type PrintQueue as m, type PageSizeName as n, type PageInfo as o, type JobStatus as p, type ModalOptions as q, type PDFMetadata as r, type PageOptions as s, type PrintDocument as t, type PrintErrorCode as u, type PrintError$1 as v, type PrintJSONOptions as w, type PrintJob as x, type PrintTableOptions as y, type QueueEventHandler as z };
|
package/dist/react.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkII3B3JRX_cjs=require('./chunk-II3B3JRX.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var b=react.createContext(null);function rt(){let r=react.useContext(b);if(!r)throw new Error("usePrintContext must be used within a PrintProvider");return r}function T(){return react.useContext(b)}function it({defaultOptions:r,children:a}){let[c,e]=react.useState(r??{}),l=react.useCallback(o=>{e(s=>({...s,...o}));},[]),n=react.useMemo(()=>({defaultOptions:c,setDefaultOptions:l}),[c,l]);return jsxRuntime.jsx(b.Provider,{value:n,children:a})}function D(r){let a=T(),[c,e]=react.useState(false),[l,n]=react.useState(null),o=react.useRef(null),s=react.useRef({});s.current=chunkII3B3JRX_cjs.O(a?.defaultOptions??{},r),react.useEffect(()=>(o.current=chunkII3B3JRX_cjs.P(),()=>{o.current?.destroy(),o.current=null;}),[]);let m=react.useCallback(async(d,g)=>{if(!o.current){n(new chunkII3B3JRX_cjs.d("PRINT_NOT_SUPPORTED","Printer not initialized"));return}e(true),n(null);try{await o.current.print(d,chunkII3B3JRX_cjs.O(s.current,g));}catch(i){let p=i instanceof chunkII3B3JRX_cjs.d?i:new chunkII3B3JRX_cjs.d("UNKNOWN",i instanceof Error?i.message:"Unknown error");throw n(p),p}finally{e(false);}},[]),v=react.useCallback(async(d,g)=>{if(!o.current){n(new chunkII3B3JRX_cjs.d("PRINT_NOT_SUPPORTED","Printer not initialized"));return}e(true),n(null);try{await o.current.printHTML(d,chunkII3B3JRX_cjs.O(s.current,g));}catch(i){let p=i instanceof chunkII3B3JRX_cjs.d?i:new chunkII3B3JRX_cjs.d("UNKNOWN",i instanceof Error?i.message:"Unknown error");throw n(p),p}finally{e(false);}},[]),P=react.useCallback(async(d,g)=>{if(!o.current){n(new chunkII3B3JRX_cjs.d("PRINT_NOT_SUPPORTED","Printer not initialized"));return}e(true),n(null);try{await o.current.printURL(d,chunkII3B3JRX_cjs.O(s.current,g));}catch(i){let p=i instanceof chunkII3B3JRX_cjs.d?i:new chunkII3B3JRX_cjs.d("UNKNOWN",i instanceof Error?i.message:"Unknown error");throw n(p),p}finally{e(false);}},[]),t=react.useCallback(()=>{n(null);},[]);return {print:m,printHTML:v,printURL:P,isPrinting:c,error:l,clearError:t}}function k(r,a){let c=T(),[e,l]=react.useState(false),[n,o]=react.useState(1),[s,m]=react.useState(1),[v,P]=react.useState(100),t=react.useRef(null),d=react.useRef({});d.current={...c?.defaultOptions,...a};let g=react.useCallback(()=>{if(!r.current)return null;t.current&&t.current.destroy();let y=d.current,H=chunkII3B3JRX_cjs.S(r.current,{...y,onClose:()=>{l(false),y.onClose?.();}});return t.current=H,H},[r]);react.useEffect(()=>()=>{t.current?.destroy(),t.current=null;},[]);let i=react.useCallback(()=>{let y=g();y&&(y.open(),l(true),o(y.getCurrentPage()),m(y.getTotalPages()),P(y.getZoom()));},[g]),p=react.useCallback(()=>{t.current?.close(),l(false);},[]),u=react.useCallback(async()=>{await t.current?.print();},[]),O=react.useCallback(async y=>{await t.current?.download(y);},[]),x=react.useCallback(y=>{t.current?.setZoom(y),P(y);},[]),E=react.useCallback(()=>{t.current?.zoomIn(),t.current&&P(t.current.getZoom());},[]),S=react.useCallback(()=>{t.current?.zoomOut(),t.current&&P(t.current.getZoom());},[]),R=react.useCallback(()=>{t.current?.resetZoom(),P(100);},[]),B=react.useCallback(()=>{t.current?.nextPage(),t.current&&o(t.current.getCurrentPage());},[]),Y=react.useCallback(()=>{t.current?.prevPage(),t.current&&o(t.current.getCurrentPage());},[]),q=react.useCallback(y=>{t.current?.goToPage(y),t.current&&o(t.current.getCurrentPage());},[]);return {open:i,close:p,isOpen:e,print:u,download:O,currentPage:n,totalPages:s,zoom:v,setZoom:x,zoomIn:E,zoomOut:S,resetZoom:R,nextPage:B,prevPage:Y,goToPage:q}}function ct(r){let a=T(),[c,e]=react.useState(false),[l,n]=react.useState(0),[o,s]=react.useState(null),m=react.useRef(null),v=react.useRef({});v.current={...a?.defaultOptions,...r},react.useEffect(()=>(m.current=chunkII3B3JRX_cjs.R(),()=>{m.current=null;}),[]);let P=react.useCallback(async(u,O)=>{let x=m.current;if(!x){let R=new chunkII3B3JRX_cjs.d("PDF_EXPORT_FAILED","PDF exporter not initialized");throw s(R),R}e(true),n(0),s(null);let E=v.current,S={...E,...O,onProgress:R=>{n(R),E.onProgress?.(R),O?.onProgress!==E.onProgress&&O?.onProgress?.(R);}};try{let R=await u(x,S);return n(100),R}catch(R){let B=R instanceof chunkII3B3JRX_cjs.d?R:new chunkII3B3JRX_cjs.d("PDF_EXPORT_FAILED",R instanceof Error?R.message:"Unknown error");throw s(B),B}finally{e(false);}},[]),t=react.useCallback((u,O,x)=>P((E,S)=>E.download(u,O,S),x),[P]),d=react.useCallback((u,O)=>P((x,E)=>x.toBlob(u,E),O),[P]),g=react.useCallback((u,O)=>P((x,E)=>x.toBase64(u,E),O),[P]),i=react.useCallback((u,O)=>P((x,E)=>x.toDataURL(u,E),O),[P]),p=react.useCallback(()=>{s(null);},[]);return {download:t,toBlob:d,toBase64:g,toDataURL:i,isExporting:c,progress:l,error:o,clearError:p}}var mt=react.forwardRef(function({children:a,className:c,style:e,id:l,...n},o){let s=react.useRef(null),{print:m}=D(n);return react.useImperativeHandle(o,()=>({print:async v=>{s.current&&await m(s.current,v);},getElement:()=>s.current}),[m]),jsxRuntime.jsx("div",{ref:s,id:l,className:c,style:e,children:a})});function gt({target:r,targetRef:a,options:c,children:e="Print",render:l,onPrintStart:n,onPrintComplete:o,onPrintError:s,disabled:m,onClick:v,...P}){let{print:t,isPrinting:d,error:g}=D(c),i=async p=>{v?.(p);let u=a?.current??r;if(!u){console.error("PrintButton: No target specified");return}try{n?.(),await t(u),o?.();}catch(O){O instanceof chunkII3B3JRX_cjs.d&&s?.(O);}};return l?jsxRuntime.jsx(jsxRuntime.Fragment,{children:l({print:async()=>{let p=a?.current??r;p&&await t(p);},isPrinting:d,error:g})}):jsxRuntime.jsx("button",{...P,onClick:p=>{i(p);},disabled:m??d,children:e})}function yt({target:r,targetRef:a,trigger:c,isOpen:e,onClose:l,onPrint:n,onDownload:o,...s}){let m=react.useRef(null),v=a??m,P={...s,...l?{onClose:l}:{},...n?{onPrint:n}:{},...o?{onDownload:o}:{}},{open:t,close:d,isOpen:g}=k(v,P);react.useEffect(()=>{if(!a)if(typeof r=="string"){let u=document.querySelector(r);m.current=u instanceof HTMLElement?u:null;}else r instanceof HTMLElement&&(m.current=r);},[r,a]);let i=e!==void 0;react.useEffect(()=>{i&&(e&&!g?t():!e&&g&&d());},[e,i,g,t,d]);let p=()=>{t();};return c?jsxRuntime.jsx("span",{onClick:p,style:{cursor:"pointer"},children:c}):null}function vt({className:r}){return jsxRuntime.jsx("div",{className:`${chunkII3B3JRX_cjs.r} ${r??""}`.trim(),style:{height:0,pageBreakBefore:"always",breakBefore:"page"},"aria-hidden":"true"})}function wt({children:r,className:a,style:c,as:e="div"}){return jsxRuntime.jsx(e,{className:`${chunkII3B3JRX_cjs.K} ${a??""}`.trim(),style:{display:"none",...c},children:r})}function Ct({children:r,className:a,style:c,as:e="div"}){return jsxRuntime.jsx(e,{className:`${chunkII3B3JRX_cjs.J} ${a??""}`.trim(),style:c,children:r})}Object.defineProperty(exports,"AVOID_BREAK_CLASS",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.t}});Object.defineProperty(exports,"BREAK_AFTER_CLASS",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.s}});Object.defineProperty(exports,"BREAK_BEFORE_CLASS",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.r}});Object.defineProperty(exports,"PRINT_HIDE_CLASS",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.J}});Object.defineProperty(exports,"PRINT_ONLY_CLASS",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.K}});Object.defineProperty(exports,"PrintError",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.d}});Object.defineProperty(exports,"isPrintError",{enumerable:true,get:function(){return chunkII3B3JRX_cjs.f}});exports.NoPrint=Ct;exports.PageBreak=vt;exports.PrintButton=gt;exports.PrintContext=b;exports.PrintOnly=wt;exports.PrintPreview=yt;exports.PrintProvider=it;exports.Printable=mt;exports.usePDF=ct;exports.usePrint=D;exports.usePrintContext=rt;exports.usePrintPreview=k;//# sourceMappingURL=react.cjs.map
|
|
2
2
|
//# sourceMappingURL=react.cjs.map
|