@oxog/printkit 1.1.1 → 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/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkE7TXCY3N_cjs=require('./chunk-E7TXCY3N.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=chunkE7TXCY3N_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 chunkE7TXCY3N_cjs.t}});Object.defineProperty(exports,"BREAK_AFTER_CLASS",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.s}});Object.defineProperty(exports,"BREAK_BEFORE_CLASS",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.r}});Object.defineProperty(exports,"PAGE_SIZES",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.m}});Object.defineProperty(exports,"PRINT_HIDE_CLASS",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.J}});Object.defineProperty(exports,"PRINT_ONLY_CLASS",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.K}});Object.defineProperty(exports,"PrintError",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.d}});Object.defineProperty(exports,"avoidBreak",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.v}});Object.defineProperty(exports,"breakAfter",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.x}});Object.defineProperty(exports,"breakBefore",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.w}});Object.defineProperty(exports,"buildStyleTag",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.F}});Object.defineProperty(exports,"calculatePages",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.y}});Object.defineProperty(exports,"cloneElement",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.k}});Object.defineProperty(exports,"combineStyles",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.G}});Object.defineProperty(exports,"copyPageStyles",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.H}});Object.defineProperty(exports,"createPDFExporter",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.R}});Object.defineProperty(exports,"createPageInfo",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.z}});Object.defineProperty(exports,"createPrintError",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.e}});Object.defineProperty(exports,"createPrintPreview",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.S}});Object.defineProperty(exports,"createPrinter",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.P}});Object.defineProperty(exports,"getAllDefaultStyles",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.N}});Object.defineProperty(exports,"getBaseDocumentStyles",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.M}});Object.defineProperty(exports,"getComputedStylesCSS",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.I}});Object.defineProperty(exports,"getDefaultPrintStyles",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.L}});Object.defineProperty(exports,"getDefaultPrinter",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.Q}});Object.defineProperty(exports,"getMarginsInPixels",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.q}});Object.defineProperty(exports,"getPageDimensions",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.n}});Object.defineProperty(exports,"getPagePixelDimensions",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.o}});Object.defineProperty(exports,"injectPrintStyles",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.C}});Object.defineProperty(exports,"isBrowser",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.c}});Object.defineProperty(exports,"isPDFSupported",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.b}});Object.defineProperty(exports,"isPrintError",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.f}});Object.defineProperty(exports,"isPrintSupported",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.a}});Object.defineProperty(exports,"normalizeMargins",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.p}});Object.defineProperty(exports,"pageBreak",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.u}});Object.defineProperty(exports,"removeAllPrintStyles",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.E}});Object.defineProperty(exports,"removePrintStyles",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.D}});Object.defineProperty(exports,"renderHeaderFooter",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.B}});Object.defineProperty(exports,"replacePlaceholders",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.A}});Object.defineProperty(exports,"resolveElement",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.i}});Object.defineProperty(exports,"resolveElements",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.j}});Object.defineProperty(exports,"sanitizeHTML",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.h}});Object.defineProperty(exports,"waitForImages",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.l}});Object.defineProperty(exports,"wrapError",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.g}});exports.createPrintQueue=X;//# sourceMappingURL=index.cjs.map
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, a as Printer, b as PrintTarget, c as PreviewOptions, d as PrintPreview, e as PDFExporter, f as PrintQueue, g as PageSize, O as Orientation, D as Dimensions, h as PageSizeName, M as MarginOptions, H as HeaderFooterFn, i as PageInfo } from './errors-COjJm-gl.cjs';
2
- export { A as AVOID_BREAK_CLASS, t as BREAK_AFTER_CLASS, B as BREAK_BEFORE_CLASS, C as CustomSize, S as FormatOptions, J as JobPriority, G as JobStatus, y as ModalOptions, N as NewPrintJob, E as PDFMetadata, z as PDFOptions, r as PRINT_HIDE_CLASS, s as PRINT_ONLY_CLASS, U as PageOptions, X as PrintDocument, u as PrintError, V as PrintErrorCode, W as PrintErrorType, R as PrintJSONOptions, F as PrintJob, L as PrintTableOptions, Q as QueueEvent, I as QueueEventHandler, K as TableData, T as ToolbarOptions, n as avoidBreak, q as breakAfter, o as breakBefore, m as calculatePages, v as createPrintError, l as getAllDefaultStyles, k as getBaseDocumentStyles, j as getDefaultPrintStyles, w as isPrintError, p as pageBreak, x as wrapError } from './errors-COjJm-gl.cjs';
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
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PrintOptions, a as Printer, b as PrintTarget, c as PreviewOptions, d as PrintPreview, e as PDFExporter, f as PrintQueue, g as PageSize, O as Orientation, D as Dimensions, h as PageSizeName, M as MarginOptions, H as HeaderFooterFn, i as PageInfo } from './errors-COjJm-gl.js';
2
- export { A as AVOID_BREAK_CLASS, t as BREAK_AFTER_CLASS, B as BREAK_BEFORE_CLASS, C as CustomSize, S as FormatOptions, J as JobPriority, G as JobStatus, y as ModalOptions, N as NewPrintJob, E as PDFMetadata, z as PDFOptions, r as PRINT_HIDE_CLASS, s as PRINT_ONLY_CLASS, U as PageOptions, X as PrintDocument, u as PrintError, V as PrintErrorCode, W as PrintErrorType, R as PrintJSONOptions, F as PrintJob, L as PrintTableOptions, Q as QueueEvent, I as QueueEventHandler, K as TableData, T as ToolbarOptions, n as avoidBreak, q as breakAfter, o as breakBefore, m as calculatePages, v as createPrintError, l as getAllDefaultStyles, k as getBaseDocumentStyles, j as getDefaultPrintStyles, w as isPrintError, p as pageBreak, x as wrapError } from './errors-COjJm-gl.js';
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
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import {P}from'./chunk-N44HS34F.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-N44HS34F.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
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
@@ -57,8 +57,8 @@ interface Printer {
57
57
  print(target: PrintTarget, options?: PrintOptions): Promise<void>;
58
58
  printHTML(html: string, options?: PrintOptions): Promise<void>;
59
59
  printURL(url: string, options?: PrintOptions): Promise<void>;
60
- printImage(src: string | HTMLImageElement, options?: PrintOptions | undefined): Promise<void>;
61
- printImages(sources: (string | HTMLImageElement)[], options?: PrintOptions | undefined): Promise<void>;
60
+ printImage(src: string | HTMLImageElement, options?: PrintOptions): Promise<void>;
61
+ printImages(sources: (string | HTMLImageElement)[], options?: PrintOptions): Promise<void>;
62
62
  printJSON(data: unknown, options?: PrintJSONOptions): Promise<void>;
63
63
  printTable(data: TableData, options?: PrintTableOptions): Promise<void>;
64
64
  setDefaultOptions(options: PrintOptions): void;
@@ -123,8 +123,8 @@ interface PDFExporter {
123
123
  toBlob(target: PrintTarget, options?: PDFOptions): Promise<Blob>;
124
124
  toBase64(target: PrintTarget, options?: PDFOptions): Promise<string>;
125
125
  toDataURL(target: PrintTarget, options?: PDFOptions): Promise<string>;
126
- download(target: PrintTarget, filename: string, options?: PDFOptions | undefined): Promise<void>;
127
- downloadHTML(html: string, filename: string, options?: PDFOptions | undefined): Promise<void>;
126
+ download(target: PrintTarget, filename: string, options?: PDFOptions): Promise<void>;
127
+ downloadHTML(html: string, filename: string, options?: PDFOptions): Promise<void>;
128
128
  }
129
129
  type JobPriority = 'low' | 'normal' | 'high';
130
130
  type JobStatus = 'pending' | 'printing' | 'completed' | 'failed';
@@ -213,6 +213,27 @@ interface PrintDocument {
213
213
  title: string;
214
214
  }
215
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
+
216
237
  /**
217
238
  * CSS class to hide elements when printing
218
239
  */
@@ -267,25 +288,4 @@ declare function breakAfter(element: HTMLElement): void;
267
288
  */
268
289
  declare function calculatePages(contentHeight: number, pageHeight: number, marginTop?: number, marginBottom?: number): number;
269
290
 
270
- /**
271
- * Custom error class for print operations
272
- */
273
- declare class PrintError extends Error implements PrintError$1 {
274
- readonly code: PrintErrorCode;
275
- readonly target?: PrintTarget | undefined;
276
- constructor(code: PrintErrorCode, message: string, target?: PrintTarget | undefined);
277
- }
278
- /**
279
- * Creates a PrintError with the appropriate message
280
- */
281
- declare function createPrintError(code: PrintErrorCode, details?: string, target?: PrintTarget): PrintError;
282
- /**
283
- * Type guard to check if an error is a PrintError
284
- */
285
- declare function isPrintError(error: unknown): error is PrintError;
286
- /**
287
- * Wraps an unknown error as a PrintError
288
- */
289
- declare function wrapError(error: unknown, target?: PrintTarget): PrintError;
290
-
291
- 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 };
@@ -57,8 +57,8 @@ interface Printer {
57
57
  print(target: PrintTarget, options?: PrintOptions): Promise<void>;
58
58
  printHTML(html: string, options?: PrintOptions): Promise<void>;
59
59
  printURL(url: string, options?: PrintOptions): Promise<void>;
60
- printImage(src: string | HTMLImageElement, options?: PrintOptions | undefined): Promise<void>;
61
- printImages(sources: (string | HTMLImageElement)[], options?: PrintOptions | undefined): Promise<void>;
60
+ printImage(src: string | HTMLImageElement, options?: PrintOptions): Promise<void>;
61
+ printImages(sources: (string | HTMLImageElement)[], options?: PrintOptions): Promise<void>;
62
62
  printJSON(data: unknown, options?: PrintJSONOptions): Promise<void>;
63
63
  printTable(data: TableData, options?: PrintTableOptions): Promise<void>;
64
64
  setDefaultOptions(options: PrintOptions): void;
@@ -123,8 +123,8 @@ interface PDFExporter {
123
123
  toBlob(target: PrintTarget, options?: PDFOptions): Promise<Blob>;
124
124
  toBase64(target: PrintTarget, options?: PDFOptions): Promise<string>;
125
125
  toDataURL(target: PrintTarget, options?: PDFOptions): Promise<string>;
126
- download(target: PrintTarget, filename: string, options?: PDFOptions | undefined): Promise<void>;
127
- downloadHTML(html: string, filename: string, options?: PDFOptions | undefined): Promise<void>;
126
+ download(target: PrintTarget, filename: string, options?: PDFOptions): Promise<void>;
127
+ downloadHTML(html: string, filename: string, options?: PDFOptions): Promise<void>;
128
128
  }
129
129
  type JobPriority = 'low' | 'normal' | 'high';
130
130
  type JobStatus = 'pending' | 'printing' | 'completed' | 'failed';
@@ -213,6 +213,27 @@ interface PrintDocument {
213
213
  title: string;
214
214
  }
215
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
+
216
237
  /**
217
238
  * CSS class to hide elements when printing
218
239
  */
@@ -267,25 +288,4 @@ declare function breakAfter(element: HTMLElement): void;
267
288
  */
268
289
  declare function calculatePages(contentHeight: number, pageHeight: number, marginTop?: number, marginBottom?: number): number;
269
290
 
270
- /**
271
- * Custom error class for print operations
272
- */
273
- declare class PrintError extends Error implements PrintError$1 {
274
- readonly code: PrintErrorCode;
275
- readonly target?: PrintTarget | undefined;
276
- constructor(code: PrintErrorCode, message: string, target?: PrintTarget | undefined);
277
- }
278
- /**
279
- * Creates a PrintError with the appropriate message
280
- */
281
- declare function createPrintError(code: PrintErrorCode, details?: string, target?: PrintTarget): PrintError;
282
- /**
283
- * Type guard to check if an error is a PrintError
284
- */
285
- declare function isPrintError(error: unknown): error is PrintError;
286
- /**
287
- * Wraps an unknown error as a PrintError
288
- */
289
- declare function wrapError(error: unknown, target?: PrintTarget): PrintError;
290
-
291
- 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 chunkE7TXCY3N_cjs=require('./chunk-E7TXCY3N.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[P,e]=react.useState(r??{}),l=react.useCallback(o=>{e(s=>({...s,...o}));},[]),n=react.useMemo(()=>({defaultOptions:P,setDefaultOptions:l}),[P,l]);return jsxRuntime.jsx(b.Provider,{value:n,children:a})}function D(r){let a=T(),[P,e]=react.useState(false),[l,n]=react.useState(null),o=react.useRef(null),s=react.useRef({});s.current=chunkE7TXCY3N_cjs.O(a?.defaultOptions??{},r),react.useEffect(()=>(o.current=chunkE7TXCY3N_cjs.P(),()=>{o.current?.destroy(),o.current=null;}),[]);let m=react.useCallback(async(d,g)=>{if(!o.current){n(new chunkE7TXCY3N_cjs.d("PRINT_NOT_SUPPORTED","Printer not initialized"));return}e(true),n(null);try{await o.current.print(d,chunkE7TXCY3N_cjs.O(s.current,g));}catch(i){let c=i instanceof chunkE7TXCY3N_cjs.d?i:new chunkE7TXCY3N_cjs.d("UNKNOWN",i instanceof Error?i.message:"Unknown error");throw n(c),c}finally{e(false);}},[]),x=react.useCallback(async(d,g)=>{if(!o.current){n(new chunkE7TXCY3N_cjs.d("PRINT_NOT_SUPPORTED","Printer not initialized"));return}e(true),n(null);try{await o.current.printHTML(d,chunkE7TXCY3N_cjs.O(s.current,g));}catch(i){let c=i instanceof chunkE7TXCY3N_cjs.d?i:new chunkE7TXCY3N_cjs.d("UNKNOWN",i instanceof Error?i.message:"Unknown error");throw n(c),c}finally{e(false);}},[]),p=react.useCallback(async(d,g)=>{if(!o.current){n(new chunkE7TXCY3N_cjs.d("PRINT_NOT_SUPPORTED","Printer not initialized"));return}e(true),n(null);try{await o.current.printURL(d,chunkE7TXCY3N_cjs.O(s.current,g));}catch(i){let c=i instanceof chunkE7TXCY3N_cjs.d?i:new chunkE7TXCY3N_cjs.d("UNKNOWN",i instanceof Error?i.message:"Unknown error");throw n(c),c}finally{e(false);}},[]),t=react.useCallback(()=>{n(null);},[]);return {print:m,printHTML:x,printURL:p,isPrinting:P,error:l,clearError:t}}function k(r,a){let P=T(),[e,l]=react.useState(false),[n,o]=react.useState(1),[s,m]=react.useState(1),[x,p]=react.useState(100),t=react.useRef(null),d=react.useRef({});d.current={...P?.defaultOptions,...a};let g=react.useCallback(()=>{if(!r.current)return null;t.current&&t.current.destroy();let y=d.current,H=chunkE7TXCY3N_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]),c=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);},[]),v=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:c,isOpen:e,print:u,download:O,currentPage:n,totalPages:s,zoom:x,setZoom:v,zoomIn:E,zoomOut:S,resetZoom:R,nextPage:B,prevPage:Y,goToPage:q}}function ct(r){let a=T(),[P,e]=react.useState(false),[l,n]=react.useState(0),[o,s]=react.useState(null),m=react.useRef(null),x=react.useRef({});x.current={...a?.defaultOptions,...r},react.useEffect(()=>(m.current=chunkE7TXCY3N_cjs.R(),()=>{m.current=null;}),[]);let p=react.useCallback(async(u,O)=>{let v=m.current;if(!v){let R=new chunkE7TXCY3N_cjs.d("PDF_EXPORT_FAILED","PDF exporter not initialized");throw s(R),R}e(true),n(0),s(null);let E=x.current,S={...E,...O,onProgress:R=>{n(R),E.onProgress?.(R),O?.onProgress!==E.onProgress&&O?.onProgress?.(R);}};try{let R=await u(v,S);return n(100),R}catch(R){let B=R instanceof chunkE7TXCY3N_cjs.d?R:new chunkE7TXCY3N_cjs.d("PDF_EXPORT_FAILED",R instanceof Error?R.message:"Unknown error");throw s(B),B}finally{e(false);}},[]),t=react.useCallback((u,O,v)=>p((E,S)=>E.download(u,O,S),v),[p]),d=react.useCallback((u,O)=>p((v,E)=>v.toBlob(u,E),O),[p]),g=react.useCallback((u,O)=>p((v,E)=>v.toBase64(u,E),O),[p]),i=react.useCallback((u,O)=>p((v,E)=>v.toDataURL(u,E),O),[p]),c=react.useCallback(()=>{s(null);},[]);return {download:t,toBlob:d,toBase64:g,toDataURL:i,isExporting:P,progress:l,error:o,clearError:c}}var mt=react.forwardRef(function({children:a,className:P,style:e,id:l,...n},o){let s=react.useRef(null),{print:m}=D(n);return react.useImperativeHandle(o,()=>({print:async x=>{s.current&&await m(s.current,x);},getElement:()=>s.current}),[m]),jsxRuntime.jsx("div",{ref:s,id:l,className:P,style:e,children:a})});function gt({target:r,targetRef:a,options:P,children:e="Print",render:l,onPrintStart:n,onPrintComplete:o,onPrintError:s,disabled:m,onClick:x,...p}){let{print:t,isPrinting:d,error:g}=D(P),i=async c=>{x?.(c);let u=a?.current??r;if(!u){console.error("PrintButton: No target specified");return}try{n?.(),await t(u),o?.();}catch(O){O instanceof chunkE7TXCY3N_cjs.d&&s?.(O);}};return l?jsxRuntime.jsx(jsxRuntime.Fragment,{children:l({print:async()=>{let c=a?.current??r;c&&await t(c);},isPrinting:d,error:g})}):jsxRuntime.jsx("button",{...p,onClick:i,disabled:m??d,children:e})}function yt({target:r,targetRef:a,trigger:P,isOpen:e,onClose:l,onPrint:n,onDownload:o,...s}){let m=react.useRef(null),x=a??m,p={...s,...l?{onClose:l}:{},...n?{onPrint:n}:{},...o?{onDownload:o}:{}},{open:t,close:d,isOpen:g}=k(x,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 c=()=>{t();};return P?jsxRuntime.jsx("span",{onClick:c,style:{cursor:"pointer"},children:P}):null}function xt({className:r}){return jsxRuntime.jsx("div",{className:`${chunkE7TXCY3N_cjs.r} ${r??""}`.trim(),style:{height:0,pageBreakBefore:"always",breakBefore:"page"},"aria-hidden":"true"})}function wt({children:r,className:a,style:P,as:e="div"}){return jsxRuntime.jsx(e,{className:`${chunkE7TXCY3N_cjs.K} ${a??""}`.trim(),style:{display:"none",...P},children:r})}function Ct({children:r,className:a,style:P,as:e="div"}){return jsxRuntime.jsx(e,{className:`${chunkE7TXCY3N_cjs.J} ${a??""}`.trim(),style:P,children:r})}Object.defineProperty(exports,"AVOID_BREAK_CLASS",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.t}});Object.defineProperty(exports,"BREAK_AFTER_CLASS",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.s}});Object.defineProperty(exports,"BREAK_BEFORE_CLASS",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.r}});Object.defineProperty(exports,"PRINT_HIDE_CLASS",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.J}});Object.defineProperty(exports,"PRINT_ONLY_CLASS",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.K}});Object.defineProperty(exports,"PrintError",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.d}});Object.defineProperty(exports,"isPrintError",{enumerable:true,get:function(){return chunkE7TXCY3N_cjs.f}});exports.NoPrint=Ct;exports.PageBreak=xt;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
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
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/adapters/react/context.ts","../src/adapters/react/provider.tsx","../src/adapters/react/hooks/usePrint.ts","../src/adapters/react/hooks/usePrintPreview.ts","../src/adapters/react/hooks/usePDF.ts","../src/adapters/react/components/Printable.tsx","../src/adapters/react/components/PrintButton.tsx","../src/adapters/react/components/PrintPreview.tsx","../src/adapters/react/components/PageBreak.tsx","../src/adapters/react/components/PrintOnly.tsx","../src/adapters/react/components/NoPrint.tsx"],"names":["PrintContext","createContext","usePrintContext","context","useContext","usePrintContextOptional","PrintProvider","initialOptions","children","defaultOptions","setDefaultOptionsState","useState","setDefaultOptions","useCallback","options","prev","value","useMemo","jsx","usePrint","isPrinting","setIsPrinting","error","setError","printerRef","useRef","optionsRef","mergeOptions","useEffect","createPrinter","print","target","printOptions","PrintError","e","printError","printHTML","html","printURL","url","clearError","usePrintPreview","ref","isOpen","setIsOpen","currentPage","setCurrentPage","totalPages","setTotalPages","zoom","setZoomState","previewRef","createPreviewInstance","mergedOptions","preview","createPrintPreview","open","close","download","filename","setZoom","level","zoomIn","zoomOut","resetZoom","nextPage","prevPage","goToPage","page","usePDF","isExporting","setIsExporting","progress","setProgress","exporterRef","createPDFExporter","run","exportFn","callOptions","exporter","notReady","hookOptions","finalOptions","p","result","exportError","pdfOptions","opts","toBlob","toBase64","toDataURL","Printable","forwardRef","className","style","id","containerRef","useImperativeHandle","PrintButton","targetRef","render","onPrintStart","onPrintComplete","onPrintError","disabled","onClick","buttonProps","handleClick","printTarget","err","Fragment","PrintPreview","trigger","controlledIsOpen","onCloseProp","onPrintProp","onDownloadProp","previewOptions","internalRef","effectiveRef","previewHookOptions","internalIsOpen","element","isControlled","handleTriggerClick","PageBreak","BREAK_BEFORE_CLASS","PrintOnly","Component","PRINT_ONLY_CLASS","NoPrint","PRINT_HIDE_CLASS"],"mappings":"sIAcaA,CAAAA,CAAeC,mBAAAA,CAAwC,IAAI,EAKjE,SAASC,IAAqC,CACnD,IAAMC,EAAUC,gBAAAA,CAAWJ,CAAY,EACvC,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,qDAAqD,CAAA,CAEvE,OAAOA,CACT,CAKO,SAASE,CAAAA,EAAoD,CAClE,OAAOD,gBAAAA,CAAWJ,CAAY,CAChC,CCVO,SAASM,EAAAA,CAAc,CAC5B,cAAA,CAAgBC,CAAAA,CAChB,SAAAC,CACF,CAAA,CAA0C,CACxC,GAAM,CAACC,EAAgBC,CAAsB,CAAA,CAAIC,eAC/CJ,CAAAA,EAAkB,EACpB,CAAA,CAEMK,CAAAA,CAAoBC,kBAAaC,CAAAA,EAA0B,CAC/DJ,EAAwBK,CAAAA,GAAU,CAA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K,QAAS0G,CAAAA,CAAoB,KAAA,CAAO,CAAE,MAAA,CAAQ,SAAU,EAC3D,QAAA,CAAAZ,CAAAA,CACH,EAIG,IACT,CChGO,SAASa,EAAAA,CAAU,CAAE,UAAAhC,CAAU,CAAA,CAAsC,CAC1E,OACE3E,cAAAA,CAAC,KAAA,CAAA,CACC,UAAW,CAAA,EAAG4G,mBAAkB,IAAIjC,CAAAA,EAAa,EAAE,GAAG,IAAA,EAAK,CAC3D,MAAO,CACL,MAAA,CAAQ,EACR,eAAA,CAAiB,QAAA,CACjB,YAAa,MACf,CAAA,CACA,cAAY,MAAA,CACd,CAEJ,CCCO,SAASkC,EAAAA,CAAU,CACxB,QAAA,CAAAvH,CAAAA,CACA,UAAAqF,CAAAA,CACA,KAAA,CAAAC,EACA,EAAA,CAAIkC,CAAAA,CAAY,KAClB,CAAA,CAAsC,CACpC,OACE9G,cAAAA,CAAC8G,CAAAA,CAAA,CACC,SAAA,CAAW,CAAA,EAAGC,mBAAgB,CAAA,CAAA,EAAIpC,CAAAA,EAAa,EAAE,GAAG,IAAA,EAAK,CACzD,MAAO,CACL,OAAA,CAAS,OACT,GAAGC,CACL,EAEC,QAAA,CAAAtF,CAAAA,CACH,CAEJ,CCjBO,SAAS0H,GAAQ,CACtB,QAAA,CAAA1H,CAAAA,CACA,SAAA,CAAAqF,CAAAA,CACA,KAAA,CAAAC,EACA,EAAA,CAAIkC,CAAAA,CAAY,KAClB,CAAA,CAAoC,CAClC,OACE9G,cAAAA,CAAC8G,CAAAA,CAAA,CACC,SAAA,CAAW,CAAA,EAAGG,mBAAgB,CAAA,CAAA,EAAItC,CAAAA,EAAa,EAAE,CAAA,CAAA,CAAG,IAAA,GACpD,KAAA,CAAOC,CAAAA,CAEN,QAAA,CAAAtF,CAAAA,CACH,CAEJ","file":"react.cjs","sourcesContent":["import { createContext, useContext } from 'react'\nimport type { PrintOptions } from '../../types'\n\n/**\n * Print context value type\n */\nexport interface PrintContextValue {\n defaultOptions: PrintOptions\n setDefaultOptions: (options: PrintOptions) => void\n}\n\n/**\n * Print context\n */\nexport const PrintContext = createContext<PrintContextValue | null>(null)\n\n/**\n * Hook to access print context\n */\nexport function usePrintContext(): PrintContextValue {\n const context = useContext(PrintContext)\n if (!context) {\n throw new Error('usePrintContext must be used within a PrintProvider')\n }\n return context\n}\n\n/**\n * Hook to optionally access print context (returns null if not in provider)\n */\nexport function usePrintContextOptional(): PrintContextValue | null {\n return useContext(PrintContext)\n}\n","import React, { useState, useMemo, useCallback } from 'react'\nimport type { ReactNode } from 'react'\nimport type { PrintOptions } from '../../types'\nimport { PrintContext, type PrintContextValue } from './context'\n\n/**\n * PrintProvider props\n */\nexport interface PrintProviderProps {\n /**\n * Default print options for all print operations\n */\n defaultOptions?: PrintOptions\n /**\n * Child components\n */\n children: ReactNode\n}\n\n/**\n * Provider component for print functionality\n */\nexport function PrintProvider({\n defaultOptions: initialOptions,\n children,\n}: PrintProviderProps): React.JSX.Element {\n const [defaultOptions, setDefaultOptionsState] = useState<PrintOptions>(\n initialOptions ?? {}\n )\n\n const setDefaultOptions = useCallback((options: PrintOptions) => {\n setDefaultOptionsState((prev) => ({ ...prev, ...options }))\n }, [])\n\n const value = useMemo<PrintContextValue>(\n () => ({\n defaultOptions,\n setDefaultOptions,\n }),\n [defaultOptions, setDefaultOptions]\n )\n\n return (\n <PrintContext.Provider value={value}>\n {children}\n </PrintContext.Provider>\n )\n}\n","import { useState, useCallback, useRef, useEffect } from 'react'\nimport type { PrintOptions, PrintTarget, Printer } from '../../../types'\nimport { createPrinter } from '../../../core/printer'\nimport { mergeOptions } from '../../../core/config'\nimport { PrintError } from '../../../errors'\nimport { usePrintContextOptional } from '../context'\n\n/**\n * usePrint hook result\n */\nexport interface UsePrintResult {\n /**\n * Print function\n */\n print: (target: PrintTarget, options?: PrintOptions) => Promise<void>\n /**\n * Print HTML string\n */\n printHTML: (html: string, options?: PrintOptions) => Promise<void>\n /**\n * Print URL content\n */\n printURL: (url: string, options?: PrintOptions) => Promise<void>\n /**\n * Whether a print operation is in progress\n */\n isPrinting: boolean\n /**\n * Error from the last print operation\n */\n error: PrintError | null\n /**\n * Clear the error state\n */\n clearError: () => void\n}\n\n/**\n * Hook for printing\n */\nexport function usePrint(options?: PrintOptions): UsePrintResult {\n const context = usePrintContextOptional()\n const [isPrinting, setIsPrinting] = useState(false)\n const [error, setError] = useState<PrintError | null>(null)\n const printerRef = useRef<Printer | null>(null)\n\n // Latest context + hook options, read at call time. They are merged per call\n // instead of being pushed into the printer on every render (which appended\n // `styles`/`styleSheets` again on each render).\n const optionsRef = useRef<PrintOptions>({})\n optionsRef.current = mergeOptions(context?.defaultOptions ?? {}, options)\n\n // Initialize printer\n useEffect(() => {\n printerRef.current = createPrinter()\n return () => {\n printerRef.current?.destroy()\n printerRef.current = null\n }\n }, [])\n\n const print = useCallback(\n async (target: PrintTarget, printOptions?: PrintOptions) => {\n if (!printerRef.current) {\n setError(new PrintError('PRINT_NOT_SUPPORTED', 'Printer not initialized'))\n return\n }\n\n setIsPrinting(true)\n setError(null)\n\n try {\n await printerRef.current.print(target, mergeOptions(optionsRef.current, printOptions))\n } catch (e) {\n const printError =\n e instanceof PrintError\n ? e\n : new PrintError('UNKNOWN', e instanceof Error ? e.message : 'Unknown error')\n setError(printError)\n throw printError\n } finally {\n setIsPrinting(false)\n }\n },\n []\n )\n\n const printHTML = useCallback(\n async (html: string, printOptions?: PrintOptions) => {\n if (!printerRef.current) {\n setError(new PrintError('PRINT_NOT_SUPPORTED', 'Printer not initialized'))\n return\n }\n\n setIsPrinting(true)\n setError(null)\n\n try {\n await printerRef.current.printHTML(html, mergeOptions(optionsRef.current, printOptions))\n } catch (e) {\n const printError =\n e instanceof PrintError\n ? e\n : new PrintError('UNKNOWN', e instanceof Error ? e.message : 'Unknown error')\n setError(printError)\n throw printError\n } finally {\n setIsPrinting(false)\n }\n },\n []\n )\n\n const printURL = useCallback(\n async (url: string, printOptions?: PrintOptions) => {\n if (!printerRef.current) {\n setError(new PrintError('PRINT_NOT_SUPPORTED', 'Printer not initialized'))\n return\n }\n\n setIsPrinting(true)\n setError(null)\n\n try {\n await printerRef.current.printURL(url, mergeOptions(optionsRef.current, printOptions))\n } catch (e) {\n const printError =\n e instanceof PrintError\n ? e\n : new PrintError('UNKNOWN', e instanceof Error ? e.message : 'Unknown error')\n setError(printError)\n throw printError\n } finally {\n setIsPrinting(false)\n }\n },\n []\n )\n\n const clearError = useCallback(() => {\n setError(null)\n }, [])\n\n return {\n print,\n printHTML,\n printURL,\n isPrinting,\n error,\n clearError,\n }\n}\n","import { useState, useCallback, useRef, useEffect } from 'react'\nimport type { RefObject } from 'react'\nimport type { PreviewOptions, PrintPreview as IPrintPreview } from '../../../types'\nimport { createPrintPreview } from '../../../core/preview'\nimport { usePrintContextOptional } from '../context'\n\n/**\n * usePrintPreview hook result\n */\nexport interface UsePrintPreviewResult {\n /**\n * Open the preview modal\n */\n open: () => void\n /**\n * Close the preview modal\n */\n close: () => void\n /**\n * Whether the preview is open\n */\n isOpen: boolean\n /**\n * Print from the preview\n */\n print: () => Promise<void>\n /**\n * Download from the preview\n */\n download: (filename?: string) => Promise<void>\n /**\n * Current page number\n */\n currentPage: number\n /**\n * Total number of pages\n */\n totalPages: number\n /**\n * Current zoom level\n */\n zoom: number\n /**\n * Set the zoom level\n */\n setZoom: (level: number) => void\n /**\n * Zoom in\n */\n zoomIn: () => void\n /**\n * Zoom out\n */\n zoomOut: () => void\n /**\n * Reset zoom to 100%\n */\n resetZoom: () => void\n /**\n * Go to next page\n */\n nextPage: () => void\n /**\n * Go to previous page\n */\n prevPage: () => void\n /**\n * Go to a specific page\n */\n goToPage: (page: number) => void\n}\n\n/**\n * Hook for print preview functionality\n */\nexport function usePrintPreview(\n ref: RefObject<HTMLElement | null>,\n options?: PreviewOptions\n): UsePrintPreviewResult {\n const context = usePrintContextOptional()\n const [isOpen, setIsOpen] = useState(false)\n const [currentPage, setCurrentPage] = useState(1)\n const [totalPages, setTotalPages] = useState(1)\n const [zoom, setZoomState] = useState(100)\n const previewRef = useRef<IPrintPreview | null>(null)\n\n // Latest context + hook options, read when the preview is opened\n const optionsRef = useRef<PreviewOptions>({})\n optionsRef.current = { ...context?.defaultOptions, ...options }\n\n // Create preview when needed\n const createPreviewInstance = useCallback(() => {\n if (!ref.current) return null\n\n if (previewRef.current) {\n previewRef.current.destroy()\n }\n\n const mergedOptions = optionsRef.current\n const preview = createPrintPreview(ref.current, {\n ...mergedOptions,\n onClose: () => {\n setIsOpen(false)\n mergedOptions.onClose?.()\n },\n })\n\n previewRef.current = preview\n return preview\n }, [ref])\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n previewRef.current?.destroy()\n previewRef.current = null\n }\n }, [])\n\n const open = useCallback(() => {\n const preview = createPreviewInstance()\n if (preview) {\n preview.open()\n setIsOpen(true)\n setCurrentPage(preview.getCurrentPage())\n setTotalPages(preview.getTotalPages())\n setZoomState(preview.getZoom())\n }\n }, [createPreviewInstance])\n\n const close = useCallback(() => {\n previewRef.current?.close()\n setIsOpen(false)\n }, [])\n\n const print = useCallback(async () => {\n await previewRef.current?.print()\n }, [])\n\n const download = useCallback(async (filename?: string) => {\n await previewRef.current?.download(filename)\n }, [])\n\n const setZoom = useCallback((level: number) => {\n previewRef.current?.setZoom(level)\n setZoomState(level)\n }, [])\n\n const zoomIn = useCallback(() => {\n previewRef.current?.zoomIn()\n if (previewRef.current) {\n setZoomState(previewRef.current.getZoom())\n }\n }, [])\n\n const zoomOut = useCallback(() => {\n previewRef.current?.zoomOut()\n if (previewRef.current) {\n setZoomState(previewRef.current.getZoom())\n }\n }, [])\n\n const resetZoom = useCallback(() => {\n previewRef.current?.resetZoom()\n setZoomState(100)\n }, [])\n\n const nextPage = useCallback(() => {\n previewRef.current?.nextPage()\n if (previewRef.current) {\n setCurrentPage(previewRef.current.getCurrentPage())\n }\n }, [])\n\n const prevPage = useCallback(() => {\n previewRef.current?.prevPage()\n if (previewRef.current) {\n setCurrentPage(previewRef.current.getCurrentPage())\n }\n }, [])\n\n const goToPage = useCallback((page: number) => {\n previewRef.current?.goToPage(page)\n if (previewRef.current) {\n setCurrentPage(previewRef.current.getCurrentPage())\n }\n }, [])\n\n return {\n open,\n close,\n isOpen,\n print,\n download,\n currentPage,\n totalPages,\n zoom,\n setZoom,\n zoomIn,\n zoomOut,\n resetZoom,\n nextPage,\n prevPage,\n goToPage,\n }\n}\n","import { useState, useCallback, useRef, useEffect } from 'react'\nimport type { PDFOptions, PrintTarget, PDFExporter } from '../../../types'\nimport { createPDFExporter } from '../../../core/pdf-exporter'\nimport { PrintError } from '../../../errors'\nimport { usePrintContextOptional } from '../context'\n\n/**\n * usePDF hook result\n */\nexport interface UsePDFResult {\n /**\n * Download target as PDF\n */\n download: (target: PrintTarget, filename: string, options?: PDFOptions) => Promise<void>\n /**\n * Convert target to Blob\n */\n toBlob: (target: PrintTarget, options?: PDFOptions) => Promise<Blob>\n /**\n * Convert target to base64 string\n */\n toBase64: (target: PrintTarget, options?: PDFOptions) => Promise<string>\n /**\n * Convert target to data URL\n */\n toDataURL: (target: PrintTarget, options?: PDFOptions) => Promise<string>\n /**\n * Whether an export operation is in progress\n */\n isExporting: boolean\n /**\n * Progress percentage (0-100)\n */\n progress: number\n /**\n * Error from the last export operation\n */\n error: PrintError | null\n /**\n * Clear the error state\n */\n clearError: () => void\n}\n\n/**\n * Hook for PDF export functionality\n */\nexport function usePDF(options?: PDFOptions): UsePDFResult {\n const context = usePrintContextOptional()\n const [isExporting, setIsExporting] = useState(false)\n const [progress, setProgress] = useState(0)\n const [error, setError] = useState<PrintError | null>(null)\n const exporterRef = useRef<PDFExporter | null>(null)\n\n // Latest context + hook options, read when an export starts\n const optionsRef = useRef<PDFOptions>({})\n optionsRef.current = { ...context?.defaultOptions, ...options }\n\n // Initialize exporter\n useEffect(() => {\n exporterRef.current = createPDFExporter()\n return () => {\n exporterRef.current = null\n }\n }, [])\n\n const run = useCallback(\n async <T,>(\n exportFn: (exporter: PDFExporter, options: PDFOptions) => Promise<T>,\n callOptions?: PDFOptions\n ): Promise<T> => {\n const exporter = exporterRef.current\n if (!exporter) {\n const notReady = new PrintError('PDF_EXPORT_FAILED', 'PDF exporter not initialized')\n setError(notReady)\n throw notReady\n }\n\n setIsExporting(true)\n setProgress(0)\n setError(null)\n\n const hookOptions = optionsRef.current\n const finalOptions: PDFOptions = {\n ...hookOptions,\n ...callOptions,\n onProgress: (p) => {\n setProgress(p)\n hookOptions.onProgress?.(p)\n if (callOptions?.onProgress !== hookOptions.onProgress) {\n callOptions?.onProgress?.(p)\n }\n },\n }\n\n try {\n const result = await exportFn(exporter, finalOptions)\n setProgress(100)\n return result\n } catch (e) {\n const exportError =\n e instanceof PrintError\n ? e\n : new PrintError('PDF_EXPORT_FAILED', e instanceof Error ? e.message : 'Unknown error')\n setError(exportError)\n throw exportError\n } finally {\n setIsExporting(false)\n }\n },\n []\n )\n\n const download = useCallback(\n (target: PrintTarget, filename: string, pdfOptions?: PDFOptions) =>\n run((exporter, opts) => exporter.download(target, filename, opts), pdfOptions),\n [run]\n )\n\n const toBlob = useCallback(\n (target: PrintTarget, pdfOptions?: PDFOptions) =>\n run((exporter, opts) => exporter.toBlob(target, opts), pdfOptions),\n [run]\n )\n\n const toBase64 = useCallback(\n (target: PrintTarget, pdfOptions?: PDFOptions) =>\n run((exporter, opts) => exporter.toBase64(target, opts), pdfOptions),\n [run]\n )\n\n const toDataURL = useCallback(\n (target: PrintTarget, pdfOptions?: PDFOptions) =>\n run((exporter, opts) => exporter.toDataURL(target, opts), pdfOptions),\n [run]\n )\n\n const clearError = useCallback(() => {\n setError(null)\n }, [])\n\n return {\n download,\n toBlob,\n toBase64,\n toDataURL,\n isExporting,\n progress,\n error,\n clearError,\n }\n}\n","import React, { useRef, forwardRef, useImperativeHandle } from 'react'\nimport type { ReactNode, CSSProperties, Ref } from 'react'\nimport type { PrintOptions } from '../../../types'\nimport { usePrint } from '../hooks/usePrint'\n\n/**\n * Printable component props\n */\nexport interface PrintableProps extends PrintOptions {\n /**\n * Content to be printed\n */\n children: ReactNode\n /**\n * Additional class name\n */\n className?: string\n /**\n * Inline styles\n */\n style?: CSSProperties\n /**\n * ID for the printable container\n */\n id?: string\n}\n\n/**\n * Printable component ref methods\n */\nexport interface PrintableRef {\n /**\n * Print the content\n */\n print: (options?: PrintOptions) => Promise<void>\n /**\n * Get the container element\n */\n getElement: () => HTMLDivElement | null\n}\n\n/**\n * Component that wraps content and makes it printable\n */\nexport const Printable = forwardRef<PrintableRef, PrintableProps>(\n function Printable(\n {\n children,\n className,\n style,\n id,\n ...printOptions\n }: PrintableProps,\n ref: Ref<PrintableRef>\n ): React.JSX.Element {\n const containerRef = useRef<HTMLDivElement>(null)\n const { print } = usePrint(printOptions)\n\n useImperativeHandle(\n ref,\n () => ({\n print: async (options?: PrintOptions) => {\n if (containerRef.current) {\n await print(containerRef.current, options)\n }\n },\n getElement: () => containerRef.current,\n }),\n [print]\n )\n\n return (\n <div\n ref={containerRef}\n id={id}\n className={className}\n style={style}\n >\n {children}\n </div>\n )\n }\n)\n","import React from 'react'\nimport type { ReactNode, ButtonHTMLAttributes, RefObject } from 'react'\nimport type { PrintOptions, PrintTarget } from '../../../types'\nimport { usePrint } from '../hooks/usePrint'\nimport { PrintError } from '../../../errors'\n\n/**\n * Render prop for PrintButton\n */\nexport interface PrintButtonRenderProps {\n print: () => Promise<void>\n isPrinting: boolean\n error: PrintError | null\n}\n\n/**\n * PrintButton component props\n */\nexport interface PrintButtonProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {\n /**\n * Target element or selector to print\n */\n target?: PrintTarget\n /**\n * Reference to the target element\n */\n targetRef?: RefObject<HTMLElement | null>\n /**\n * Print options\n */\n options?: PrintOptions\n /**\n * Button content\n */\n children?: ReactNode\n /**\n * Render prop for custom rendering\n */\n render?: (props: PrintButtonRenderProps) => ReactNode\n /**\n * Callback when print starts\n */\n onPrintStart?: () => void\n /**\n * Callback when print completes\n */\n onPrintComplete?: () => void\n /**\n * Callback when print fails\n */\n onPrintError?: (error: PrintError) => void\n}\n\n/**\n * Button component that triggers print\n */\nexport function PrintButton({\n target,\n targetRef,\n options,\n children = 'Print',\n render,\n onPrintStart,\n onPrintComplete,\n onPrintError,\n disabled,\n onClick,\n ...buttonProps\n}: PrintButtonProps): React.JSX.Element {\n const { print, isPrinting, error } = usePrint(options)\n\n const handleClick = async (e: React.MouseEvent<HTMLButtonElement>) => {\n // Call original onClick if provided\n onClick?.(e)\n\n // Determine target\n const printTarget = targetRef?.current ?? target\n\n if (!printTarget) {\n console.error('PrintButton: No target specified')\n return\n }\n\n try {\n onPrintStart?.()\n await print(printTarget)\n onPrintComplete?.()\n } catch (err) {\n if (err instanceof PrintError) {\n onPrintError?.(err)\n }\n }\n }\n\n // Use render prop if provided\n if (render) {\n return (\n <>\n {render({\n print: async () => {\n const printTarget = targetRef?.current ?? target\n if (printTarget) {\n await print(printTarget)\n }\n },\n isPrinting,\n error,\n })}\n </>\n )\n }\n\n return (\n <button\n {...buttonProps}\n onClick={handleClick}\n disabled={disabled ?? isPrinting}\n >\n {children}\n </button>\n )\n}\n","import React, { useRef, useEffect } from 'react'\nimport type { ReactNode, RefObject } from 'react'\nimport type { PreviewOptions, PrintTarget } from '../../../types'\nimport { usePrintPreview } from '../hooks/usePrintPreview'\n\n/**\n * PrintPreview component props\n */\nexport interface PrintPreviewProps extends PreviewOptions {\n /**\n * Target element or selector to preview (`targetRef` takes precedence).\n * Arrays are not supported here; use `createPrintPreview` for several elements.\n */\n target?: PrintTarget\n /**\n * Reference to the target element\n */\n targetRef?: RefObject<HTMLElement | null>\n /**\n * Trigger element that opens the preview\n */\n trigger?: ReactNode\n /**\n * Whether the preview is controlled externally\n */\n isOpen?: boolean\n /**\n * Callback when preview closes\n */\n onClose?: () => void\n /**\n * Callback when print is triggered from preview\n */\n onPrint?: () => void\n /**\n * Callback when download is triggered from preview\n */\n onDownload?: () => void\n}\n\n/**\n * Component for print preview modal\n */\nexport function PrintPreview({\n target,\n targetRef,\n trigger,\n isOpen: controlledIsOpen,\n onClose: onCloseProp,\n onPrint: onPrintProp,\n onDownload: onDownloadProp,\n ...previewOptions\n}: PrintPreviewProps): React.JSX.Element | null {\n // Internal ref for a `target` element or selector\n const internalRef = useRef<HTMLElement | null>(null)\n \n // Use provided ref or internal ref\n const effectiveRef = targetRef ?? internalRef\n\n const previewHookOptions = {\n ...previewOptions,\n ...(onCloseProp ? { onClose: onCloseProp } : {}),\n ...(onPrintProp ? { onPrint: onPrintProp } : {}),\n ...(onDownloadProp ? { onDownload: onDownloadProp } : {}),\n }\n\n const {\n open,\n close,\n isOpen: internalIsOpen,\n } = usePrintPreview(effectiveRef, previewHookOptions)\n\n // Resolve the `target` element or selector (before the controlled-open\n // effect below, which may open the preview right away)\n useEffect(() => {\n if (targetRef) return\n if (typeof target === 'string') {\n const element = document.querySelector(target)\n internalRef.current = element instanceof HTMLElement ? element : null\n } else if (target instanceof HTMLElement) {\n internalRef.current = target\n }\n }, [target, targetRef])\n\n // Handle controlled mode\n const isControlled = controlledIsOpen !== undefined\n\n // Sync controlled state\n useEffect(() => {\n if (isControlled) {\n if (controlledIsOpen && !internalIsOpen) {\n open()\n } else if (!controlledIsOpen && internalIsOpen) {\n close()\n }\n }\n }, [controlledIsOpen, isControlled, internalIsOpen, open, close])\n\n const handleTriggerClick = () => {\n open()\n }\n\n // Render trigger only\n if (trigger) {\n return (\n <span onClick={handleTriggerClick} style={{ cursor: 'pointer' }}>\n {trigger}\n </span>\n )\n }\n\n return null\n}\n","import React from 'react'\nimport { BREAK_BEFORE_CLASS } from '../../../layout/page-break'\n\n/**\n * PageBreak component props\n */\nexport interface PageBreakProps {\n /**\n * Additional class name\n */\n className?: string\n}\n\n/**\n * Component that creates a page break\n */\nexport function PageBreak({ className }: PageBreakProps): React.JSX.Element {\n return (\n <div\n className={`${BREAK_BEFORE_CLASS} ${className ?? ''}`.trim()}\n style={{\n height: 0,\n pageBreakBefore: 'always',\n breakBefore: 'page',\n }}\n aria-hidden=\"true\"\n />\n )\n}\n","import React from 'react'\nimport type { ReactNode, CSSProperties } from 'react'\nimport { PRINT_ONLY_CLASS } from '../../../styles/default'\n\n/**\n * PrintOnly component props\n */\nexport interface PrintOnlyProps {\n /**\n * Content to show only when printing\n */\n children: ReactNode\n /**\n * Additional class name\n */\n className?: string\n /**\n * Inline styles (will be applied during print)\n */\n style?: CSSProperties\n /**\n * HTML tag to use\n */\n as?: keyof React.JSX.IntrinsicElements\n}\n\n/**\n * Component that shows content only when printing\n */\nexport function PrintOnly({\n children,\n className,\n style,\n as: Component = 'div',\n}: PrintOnlyProps): React.JSX.Element {\n return (\n <Component\n className={`${PRINT_ONLY_CLASS} ${className ?? ''}`.trim()}\n style={{\n display: 'none',\n ...style,\n }}\n >\n {children}\n </Component>\n )\n}\n","import React from 'react'\nimport type { ReactNode, CSSProperties } from 'react'\nimport { PRINT_HIDE_CLASS } from '../../../styles/default'\n\n/**\n * NoPrint component props\n */\nexport interface NoPrintProps {\n /**\n * Content to hide when printing\n */\n children: ReactNode\n /**\n * Additional class name\n */\n className?: string\n /**\n * Inline styles\n */\n style?: CSSProperties\n /**\n * HTML tag to use\n */\n as?: keyof React.JSX.IntrinsicElements\n}\n\n/**\n * Component that hides content when printing\n */\nexport function NoPrint({\n children,\n className,\n style,\n as: Component = 'div',\n}: NoPrintProps): React.JSX.Element {\n return (\n <Component\n className={`${PRINT_HIDE_CLASS} ${className ?? ''}`.trim()}\n style={style}\n >\n {children}\n </Component>\n )\n}\n"]}
1
+ {"version":3,"sources":["../src/adapters/react/context.ts","../src/adapters/react/provider.tsx","../src/adapters/react/hooks/usePrint.ts","../src/adapters/react/hooks/usePrintPreview.ts","../src/adapters/react/hooks/usePDF.ts","../src/adapters/react/components/Printable.tsx","../src/adapters/react/components/PrintButton.tsx","../src/adapters/react/components/PrintPreview.tsx","../src/adapters/react/components/PageBreak.tsx","../src/adapters/react/components/PrintOnly.tsx","../src/adapters/react/components/NoPrint.tsx"],"names":["PrintContext","createContext","usePrintContext","context","useContext","usePrintContextOptional","PrintProvider","initialOptions","children","defaultOptions","setDefaultOptionsState","useState","setDefaultOptions","useCallback","options","prev","value","useMemo","jsx","usePrint","isPrinting","setIsPrinting","error","setError","printerRef","useRef","optionsRef","mergeOptions","useEffect","createPrinter","print","target","printOptions","PrintError","e","printError","printHTML","html","printURL","url","clearError","usePrintPreview","ref","isOpen","setIsOpen","currentPage","setCurrentPage","totalPages","setTotalPages","zoom","setZoomState","previewRef","createPreviewInstance","mergedOptions","preview","createPrintPreview","open","close","download","filename","setZoom","level","zoomIn","zoomOut","resetZoom","nextPage","prevPage","goToPage","page","usePDF","isExporting","setIsExporting","progress","setProgress","exporterRef","createPDFExporter","run","exportFn","callOptions","exporter","notReady","hookOptions","finalOptions","p","result","exportError","pdfOptions","opts","toBlob","toBase64","toDataURL","Printable","forwardRef","className","style","id","containerRef","useImperativeHandle","PrintButton","targetRef","render","onPrintStart","onPrintComplete","onPrintError","disabled","onClick","buttonProps","handleClick","printTarget","err","Fragment","PrintPreview","trigger","controlledIsOpen","onCloseProp","onPrintProp","onDownloadProp","previewOptions","internalRef","effectiveRef","previewHookOptions","internalIsOpen","element","isControlled","handleTriggerClick","PageBreak","BREAK_BEFORE_CLASS","PrintOnly","Component","PRINT_ONLY_CLASS","NoPrint","PRINT_HIDE_CLASS"],"mappings":"sIAcaA,CAAAA,CAAeC,mBAAAA,CAAwC,IAAI,EAKjE,SAASC,IAAqC,CACnD,IAAMC,EAAUC,gBAAAA,CAAWJ,CAAY,EACvC,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,qDAAqD,CAAA,CAEvE,OAAOA,CACT,CAKO,SAASE,CAAAA,EAAoD,CAClE,OAAOD,gBAAAA,CAAWJ,CAAY,CAChC,CCTO,SAASM,EAAAA,CAAc,CAC5B,cAAA,CAAgBC,CAAAA,CAChB,SAAAC,CACF,CAAA,CAA0C,CACxC,GAAM,CAACC,EAAgBC,CAAsB,CAAA,CAAIC,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AAA,EAAGG,mBAAgB,CAAA,CAAA,EAAItC,CAAAA,EAAa,EAAE,CAAA,CAAA,CAAG,IAAA,GACpD,KAAA,CAAOC,CAAAA,CAEN,QAAA,CAAAtF,CAAAA,CACH,CAEJ","file":"react.cjs","sourcesContent":["import { createContext, useContext } from 'react'\nimport type { PrintOptions } from '../../types'\n\n/**\n * Print context value type\n */\nexport interface PrintContextValue {\n defaultOptions: PrintOptions\n setDefaultOptions: (options: PrintOptions) => void\n}\n\n/**\n * Print context\n */\nexport const PrintContext = createContext<PrintContextValue | null>(null)\n\n/**\n * Hook to access print context\n */\nexport function usePrintContext(): PrintContextValue {\n const context = useContext(PrintContext)\n if (!context) {\n throw new Error('usePrintContext must be used within a PrintProvider')\n }\n return context\n}\n\n/**\n * Hook to optionally access print context (returns null if not in provider)\n */\nexport function usePrintContextOptional(): PrintContextValue | null {\n return useContext(PrintContext)\n}\n","import type React from 'react'\nimport { useState, useMemo, useCallback } from 'react'\nimport type { ReactNode } from 'react'\nimport type { PrintOptions } from '../../types'\nimport { PrintContext, type PrintContextValue } from './context'\n\n/**\n * PrintProvider props\n */\nexport interface PrintProviderProps {\n /**\n * Default print options for all print operations\n */\n defaultOptions?: PrintOptions\n /**\n * Child components\n */\n children: ReactNode\n}\n\n/**\n * Provider component for print functionality\n */\nexport function PrintProvider({\n defaultOptions: initialOptions,\n children,\n}: PrintProviderProps): React.JSX.Element {\n const [defaultOptions, setDefaultOptionsState] = useState<PrintOptions>(\n initialOptions ?? {}\n )\n\n const setDefaultOptions = useCallback((options: PrintOptions) => {\n setDefaultOptionsState((prev) => ({ ...prev, ...options }))\n }, [])\n\n const value = useMemo<PrintContextValue>(\n () => ({\n defaultOptions,\n setDefaultOptions,\n }),\n [defaultOptions, setDefaultOptions]\n )\n\n return (\n <PrintContext.Provider value={value}>\n {children}\n </PrintContext.Provider>\n )\n}\n","import { useState, useCallback, useRef, useEffect } from 'react'\nimport type { PrintOptions, PrintTarget, Printer } from '../../../types'\nimport { createPrinter } from '../../../core/printer'\nimport { mergeOptions } from '../../../core/config'\nimport { PrintError } from '../../../errors'\nimport { usePrintContextOptional } from '../context'\n\n/**\n * usePrint hook result\n */\nexport interface UsePrintResult {\n /**\n * Print function\n */\n print: (target: PrintTarget, options?: PrintOptions) => Promise<void>\n /**\n * Print HTML string\n */\n printHTML: (html: string, options?: PrintOptions) => Promise<void>\n /**\n * Print URL content\n */\n printURL: (url: string, options?: PrintOptions) => Promise<void>\n /**\n * Whether a print operation is in progress\n */\n isPrinting: boolean\n /**\n * Error from the last print operation\n */\n error: PrintError | null\n /**\n * Clear the error state\n */\n clearError: () => void\n}\n\n/**\n * Hook for printing\n */\nexport function usePrint(options?: PrintOptions): UsePrintResult {\n const context = usePrintContextOptional()\n const [isPrinting, setIsPrinting] = useState(false)\n const [error, setError] = useState<PrintError | null>(null)\n const printerRef = useRef<Printer | null>(null)\n\n // Latest context + hook options, read at call time. They are merged per call\n // instead of being pushed into the printer on every render (which appended\n // `styles`/`styleSheets` again on each render).\n const optionsRef = useRef<PrintOptions>({})\n optionsRef.current = mergeOptions(context?.defaultOptions ?? {}, options)\n\n // Initialize printer\n useEffect(() => {\n printerRef.current = createPrinter()\n return () => {\n printerRef.current?.destroy()\n printerRef.current = null\n }\n }, [])\n\n const print = useCallback(\n async (target: PrintTarget, printOptions?: PrintOptions) => {\n if (!printerRef.current) {\n setError(new PrintError('PRINT_NOT_SUPPORTED', 'Printer not initialized'))\n return\n }\n\n setIsPrinting(true)\n setError(null)\n\n try {\n await printerRef.current.print(target, mergeOptions(optionsRef.current, printOptions))\n } catch (e) {\n const printError =\n e instanceof PrintError\n ? e\n : new PrintError('UNKNOWN', e instanceof Error ? e.message : 'Unknown error')\n setError(printError)\n throw printError\n } finally {\n setIsPrinting(false)\n }\n },\n []\n )\n\n const printHTML = useCallback(\n async (html: string, printOptions?: PrintOptions) => {\n if (!printerRef.current) {\n setError(new PrintError('PRINT_NOT_SUPPORTED', 'Printer not initialized'))\n return\n }\n\n setIsPrinting(true)\n setError(null)\n\n try {\n await printerRef.current.printHTML(html, mergeOptions(optionsRef.current, printOptions))\n } catch (e) {\n const printError =\n e instanceof PrintError\n ? e\n : new PrintError('UNKNOWN', e instanceof Error ? e.message : 'Unknown error')\n setError(printError)\n throw printError\n } finally {\n setIsPrinting(false)\n }\n },\n []\n )\n\n const printURL = useCallback(\n async (url: string, printOptions?: PrintOptions) => {\n if (!printerRef.current) {\n setError(new PrintError('PRINT_NOT_SUPPORTED', 'Printer not initialized'))\n return\n }\n\n setIsPrinting(true)\n setError(null)\n\n try {\n await printerRef.current.printURL(url, mergeOptions(optionsRef.current, printOptions))\n } catch (e) {\n const printError =\n e instanceof PrintError\n ? e\n : new PrintError('UNKNOWN', e instanceof Error ? e.message : 'Unknown error')\n setError(printError)\n throw printError\n } finally {\n setIsPrinting(false)\n }\n },\n []\n )\n\n const clearError = useCallback(() => {\n setError(null)\n }, [])\n\n return {\n print,\n printHTML,\n printURL,\n isPrinting,\n error,\n clearError,\n }\n}\n","import { useState, useCallback, useRef, useEffect } from 'react'\nimport type { RefObject } from 'react'\nimport type { PreviewOptions, PrintPreview as IPrintPreview } from '../../../types'\nimport { createPrintPreview } from '../../../core/preview'\nimport { usePrintContextOptional } from '../context'\n\n/**\n * usePrintPreview hook result\n */\nexport interface UsePrintPreviewResult {\n /**\n * Open the preview modal\n */\n open: () => void\n /**\n * Close the preview modal\n */\n close: () => void\n /**\n * Whether the preview is open\n */\n isOpen: boolean\n /**\n * Print from the preview\n */\n print: () => Promise<void>\n /**\n * Download from the preview\n */\n download: (filename?: string) => Promise<void>\n /**\n * Current page number\n */\n currentPage: number\n /**\n * Total number of pages\n */\n totalPages: number\n /**\n * Current zoom level\n */\n zoom: number\n /**\n * Set the zoom level\n */\n setZoom: (level: number) => void\n /**\n * Zoom in\n */\n zoomIn: () => void\n /**\n * Zoom out\n */\n zoomOut: () => void\n /**\n * Reset zoom to 100%\n */\n resetZoom: () => void\n /**\n * Go to next page\n */\n nextPage: () => void\n /**\n * Go to previous page\n */\n prevPage: () => void\n /**\n * Go to a specific page\n */\n goToPage: (page: number) => void\n}\n\n/**\n * Hook for print preview functionality\n */\nexport function usePrintPreview(\n ref: RefObject<HTMLElement | null>,\n options?: PreviewOptions\n): UsePrintPreviewResult {\n const context = usePrintContextOptional()\n const [isOpen, setIsOpen] = useState(false)\n const [currentPage, setCurrentPage] = useState(1)\n const [totalPages, setTotalPages] = useState(1)\n const [zoom, setZoomState] = useState(100)\n const previewRef = useRef<IPrintPreview | null>(null)\n\n // Latest context + hook options, read when the preview is opened\n const optionsRef = useRef<PreviewOptions>({})\n optionsRef.current = { ...context?.defaultOptions, ...options }\n\n // Create preview when needed\n const createPreviewInstance = useCallback(() => {\n if (!ref.current) return null\n\n if (previewRef.current) {\n previewRef.current.destroy()\n }\n\n const mergedOptions = optionsRef.current\n const preview = createPrintPreview(ref.current, {\n ...mergedOptions,\n onClose: () => {\n setIsOpen(false)\n mergedOptions.onClose?.()\n },\n })\n\n previewRef.current = preview\n return preview\n }, [ref])\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n previewRef.current?.destroy()\n previewRef.current = null\n }\n }, [])\n\n const open = useCallback(() => {\n const preview = createPreviewInstance()\n if (preview) {\n preview.open()\n setIsOpen(true)\n setCurrentPage(preview.getCurrentPage())\n setTotalPages(preview.getTotalPages())\n setZoomState(preview.getZoom())\n }\n }, [createPreviewInstance])\n\n const close = useCallback(() => {\n previewRef.current?.close()\n setIsOpen(false)\n }, [])\n\n const print = useCallback(async () => {\n await previewRef.current?.print()\n }, [])\n\n const download = useCallback(async (filename?: string) => {\n await previewRef.current?.download(filename)\n }, [])\n\n const setZoom = useCallback((level: number) => {\n previewRef.current?.setZoom(level)\n setZoomState(level)\n }, [])\n\n const zoomIn = useCallback(() => {\n previewRef.current?.zoomIn()\n if (previewRef.current) {\n setZoomState(previewRef.current.getZoom())\n }\n }, [])\n\n const zoomOut = useCallback(() => {\n previewRef.current?.zoomOut()\n if (previewRef.current) {\n setZoomState(previewRef.current.getZoom())\n }\n }, [])\n\n const resetZoom = useCallback(() => {\n previewRef.current?.resetZoom()\n setZoomState(100)\n }, [])\n\n const nextPage = useCallback(() => {\n previewRef.current?.nextPage()\n if (previewRef.current) {\n setCurrentPage(previewRef.current.getCurrentPage())\n }\n }, [])\n\n const prevPage = useCallback(() => {\n previewRef.current?.prevPage()\n if (previewRef.current) {\n setCurrentPage(previewRef.current.getCurrentPage())\n }\n }, [])\n\n const goToPage = useCallback((page: number) => {\n previewRef.current?.goToPage(page)\n if (previewRef.current) {\n setCurrentPage(previewRef.current.getCurrentPage())\n }\n }, [])\n\n return {\n open,\n close,\n isOpen,\n print,\n download,\n currentPage,\n totalPages,\n zoom,\n setZoom,\n zoomIn,\n zoomOut,\n resetZoom,\n nextPage,\n prevPage,\n goToPage,\n }\n}\n","import { useState, useCallback, useRef, useEffect } from 'react'\nimport type { PDFOptions, PrintTarget, PDFExporter } from '../../../types'\nimport { createPDFExporter } from '../../../core/pdf-exporter'\nimport { PrintError } from '../../../errors'\nimport { usePrintContextOptional } from '../context'\n\n/**\n * usePDF hook result\n */\nexport interface UsePDFResult {\n /**\n * Download target as PDF\n */\n download: (target: PrintTarget, filename: string, options?: PDFOptions) => Promise<void>\n /**\n * Convert target to Blob\n */\n toBlob: (target: PrintTarget, options?: PDFOptions) => Promise<Blob>\n /**\n * Convert target to base64 string\n */\n toBase64: (target: PrintTarget, options?: PDFOptions) => Promise<string>\n /**\n * Convert target to data URL\n */\n toDataURL: (target: PrintTarget, options?: PDFOptions) => Promise<string>\n /**\n * Whether an export operation is in progress\n */\n isExporting: boolean\n /**\n * Progress percentage (0-100)\n */\n progress: number\n /**\n * Error from the last export operation\n */\n error: PrintError | null\n /**\n * Clear the error state\n */\n clearError: () => void\n}\n\n/**\n * Hook for PDF export functionality\n */\nexport function usePDF(options?: PDFOptions): UsePDFResult {\n const context = usePrintContextOptional()\n const [isExporting, setIsExporting] = useState(false)\n const [progress, setProgress] = useState(0)\n const [error, setError] = useState<PrintError | null>(null)\n const exporterRef = useRef<PDFExporter | null>(null)\n\n // Latest context + hook options, read when an export starts\n const optionsRef = useRef<PDFOptions>({})\n optionsRef.current = { ...context?.defaultOptions, ...options }\n\n // Initialize exporter\n useEffect(() => {\n exporterRef.current = createPDFExporter()\n return () => {\n exporterRef.current = null\n }\n }, [])\n\n const run = useCallback(\n async <T,>(\n exportFn: (exporter: PDFExporter, options: PDFOptions) => Promise<T>,\n callOptions?: PDFOptions\n ): Promise<T> => {\n const exporter = exporterRef.current\n if (!exporter) {\n const notReady = new PrintError('PDF_EXPORT_FAILED', 'PDF exporter not initialized')\n setError(notReady)\n throw notReady\n }\n\n setIsExporting(true)\n setProgress(0)\n setError(null)\n\n const hookOptions = optionsRef.current\n const finalOptions: PDFOptions = {\n ...hookOptions,\n ...callOptions,\n onProgress: (p) => {\n setProgress(p)\n hookOptions.onProgress?.(p)\n if (callOptions?.onProgress !== hookOptions.onProgress) {\n callOptions?.onProgress?.(p)\n }\n },\n }\n\n try {\n const result = await exportFn(exporter, finalOptions)\n setProgress(100)\n return result\n } catch (e) {\n const exportError =\n e instanceof PrintError\n ? e\n : new PrintError('PDF_EXPORT_FAILED', e instanceof Error ? e.message : 'Unknown error')\n setError(exportError)\n throw exportError\n } finally {\n setIsExporting(false)\n }\n },\n []\n )\n\n const download = useCallback(\n (target: PrintTarget, filename: string, pdfOptions?: PDFOptions) =>\n run((exporter, opts) => exporter.download(target, filename, opts), pdfOptions),\n [run]\n )\n\n const toBlob = useCallback(\n (target: PrintTarget, pdfOptions?: PDFOptions) =>\n run((exporter, opts) => exporter.toBlob(target, opts), pdfOptions),\n [run]\n )\n\n const toBase64 = useCallback(\n (target: PrintTarget, pdfOptions?: PDFOptions) =>\n run((exporter, opts) => exporter.toBase64(target, opts), pdfOptions),\n [run]\n )\n\n const toDataURL = useCallback(\n (target: PrintTarget, pdfOptions?: PDFOptions) =>\n run((exporter, opts) => exporter.toDataURL(target, opts), pdfOptions),\n [run]\n )\n\n const clearError = useCallback(() => {\n setError(null)\n }, [])\n\n return {\n download,\n toBlob,\n toBase64,\n toDataURL,\n isExporting,\n progress,\n error,\n clearError,\n }\n}\n","import type React from 'react'\nimport { useRef, forwardRef, useImperativeHandle } from 'react'\nimport type { ReactNode, CSSProperties, Ref } from 'react'\nimport type { PrintOptions } from '../../../types'\nimport { usePrint } from '../hooks/usePrint'\n\n/**\n * Printable component props\n */\nexport interface PrintableProps extends PrintOptions {\n /**\n * Content to be printed\n */\n children: ReactNode\n /**\n * Additional class name\n */\n className?: string\n /**\n * Inline styles\n */\n style?: CSSProperties\n /**\n * ID for the printable container\n */\n id?: string\n}\n\n/**\n * Printable component ref methods\n */\nexport interface PrintableRef {\n /**\n * Print the content\n */\n print: (options?: PrintOptions) => Promise<void>\n /**\n * Get the container element\n */\n getElement: () => HTMLDivElement | null\n}\n\n/**\n * Component that wraps content and makes it printable\n */\nexport const Printable = forwardRef<PrintableRef, PrintableProps>(\n function Printable(\n {\n children,\n className,\n style,\n id,\n ...printOptions\n }: PrintableProps,\n ref: Ref<PrintableRef>\n ): React.JSX.Element {\n const containerRef = useRef<HTMLDivElement>(null)\n const { print } = usePrint(printOptions)\n\n useImperativeHandle(\n ref,\n () => ({\n print: async (options?: PrintOptions) => {\n if (containerRef.current) {\n await print(containerRef.current, options)\n }\n },\n getElement: () => containerRef.current,\n }),\n [print]\n )\n\n return (\n <div\n ref={containerRef}\n id={id}\n className={className}\n style={style}\n >\n {children}\n </div>\n )\n }\n)\n","import type React from 'react'\nimport type { ReactNode, ButtonHTMLAttributes, RefObject } from 'react'\nimport type { PrintOptions, PrintTarget } from '../../../types'\nimport { usePrint } from '../hooks/usePrint'\nimport { PrintError } from '../../../errors'\n\n/**\n * Render prop for PrintButton\n */\nexport interface PrintButtonRenderProps {\n print: () => Promise<void>\n isPrinting: boolean\n error: PrintError | null\n}\n\n/**\n * PrintButton component props\n */\nexport interface PrintButtonProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {\n /**\n * Target element or selector to print\n */\n target?: PrintTarget\n /**\n * Reference to the target element\n */\n targetRef?: RefObject<HTMLElement | null>\n /**\n * Print options\n */\n options?: PrintOptions\n /**\n * Button content\n */\n children?: ReactNode\n /**\n * Render prop for custom rendering\n */\n render?: (props: PrintButtonRenderProps) => ReactNode\n /**\n * Callback when print starts\n */\n onPrintStart?: () => void\n /**\n * Callback when print completes\n */\n onPrintComplete?: () => void\n /**\n * Callback when print fails\n */\n onPrintError?: (error: PrintError) => void\n}\n\n/**\n * Button component that triggers print\n */\nexport function PrintButton({\n target,\n targetRef,\n options,\n children = 'Print',\n render,\n onPrintStart,\n onPrintComplete,\n onPrintError,\n disabled,\n onClick,\n ...buttonProps\n}: PrintButtonProps): React.JSX.Element {\n const { print, isPrinting, error } = usePrint(options)\n\n const handleClick = async (e: React.MouseEvent<HTMLButtonElement>) => {\n // Call original onClick if provided\n onClick?.(e)\n\n // Determine target\n const printTarget = targetRef?.current ?? target\n\n if (!printTarget) {\n console.error('PrintButton: No target specified')\n return\n }\n\n try {\n onPrintStart?.()\n await print(printTarget)\n onPrintComplete?.()\n } catch (err) {\n if (err instanceof PrintError) {\n onPrintError?.(err)\n }\n }\n }\n\n // Use render prop if provided\n if (render) {\n return (\n <>\n {render({\n print: async () => {\n const printTarget = targetRef?.current ?? target\n if (printTarget) {\n await print(printTarget)\n }\n },\n isPrinting,\n error,\n })}\n </>\n )\n }\n\n return (\n <button\n {...buttonProps}\n onClick={(e) => {\n void handleClick(e)\n }}\n disabled={disabled ?? isPrinting}\n >\n {children}\n </button>\n )\n}\n","import type React from 'react'\nimport { useRef, useEffect } from 'react'\nimport type { ReactNode, RefObject } from 'react'\nimport type { PreviewOptions, PrintTarget } from '../../../types'\nimport { usePrintPreview } from '../hooks/usePrintPreview'\n\n/**\n * PrintPreview component props\n */\nexport interface PrintPreviewProps extends PreviewOptions {\n /**\n * Target element or selector to preview (`targetRef` takes precedence).\n * Arrays are not supported here; use `createPrintPreview` for several elements.\n */\n target?: PrintTarget\n /**\n * Reference to the target element\n */\n targetRef?: RefObject<HTMLElement | null>\n /**\n * Trigger element that opens the preview\n */\n trigger?: ReactNode\n /**\n * Whether the preview is controlled externally\n */\n isOpen?: boolean\n /**\n * Callback when preview closes\n */\n onClose?: () => void\n /**\n * Callback when print is triggered from preview\n */\n onPrint?: () => void\n /**\n * Callback when download is triggered from preview\n */\n onDownload?: () => void\n}\n\n/**\n * Component for print preview modal\n */\nexport function PrintPreview({\n target,\n targetRef,\n trigger,\n isOpen: controlledIsOpen,\n onClose: onCloseProp,\n onPrint: onPrintProp,\n onDownload: onDownloadProp,\n ...previewOptions\n}: PrintPreviewProps): React.JSX.Element | null {\n // Internal ref for a `target` element or selector\n const internalRef = useRef<HTMLElement | null>(null)\n \n // Use provided ref or internal ref\n const effectiveRef = targetRef ?? internalRef\n\n const previewHookOptions = {\n ...previewOptions,\n ...(onCloseProp ? { onClose: onCloseProp } : {}),\n ...(onPrintProp ? { onPrint: onPrintProp } : {}),\n ...(onDownloadProp ? { onDownload: onDownloadProp } : {}),\n }\n\n const {\n open,\n close,\n isOpen: internalIsOpen,\n } = usePrintPreview(effectiveRef, previewHookOptions)\n\n // Resolve the `target` element or selector (before the controlled-open\n // effect below, which may open the preview right away)\n useEffect(() => {\n if (targetRef) return\n if (typeof target === 'string') {\n const element = document.querySelector(target)\n internalRef.current = element instanceof HTMLElement ? element : null\n } else if (target instanceof HTMLElement) {\n internalRef.current = target\n }\n }, [target, targetRef])\n\n // Handle controlled mode\n const isControlled = controlledIsOpen !== undefined\n\n // Sync controlled state\n useEffect(() => {\n if (isControlled) {\n if (controlledIsOpen && !internalIsOpen) {\n open()\n } else if (!controlledIsOpen && internalIsOpen) {\n close()\n }\n }\n }, [controlledIsOpen, isControlled, internalIsOpen, open, close])\n\n const handleTriggerClick = () => {\n open()\n }\n\n // Render trigger only\n if (trigger) {\n return (\n <span onClick={handleTriggerClick} style={{ cursor: 'pointer' }}>\n {trigger}\n </span>\n )\n }\n\n return null\n}\n","import type React from 'react'\nimport { BREAK_BEFORE_CLASS } from '../../../layout/page-break'\n\n/**\n * PageBreak component props\n */\nexport interface PageBreakProps {\n /**\n * Additional class name\n */\n className?: string\n}\n\n/**\n * Component that creates a page break\n */\nexport function PageBreak({ className }: PageBreakProps): React.JSX.Element {\n return (\n <div\n className={`${BREAK_BEFORE_CLASS} ${className ?? ''}`.trim()}\n style={{\n height: 0,\n pageBreakBefore: 'always',\n breakBefore: 'page',\n }}\n aria-hidden=\"true\"\n />\n )\n}\n","import type React from 'react'\nimport type { ReactNode, CSSProperties } from 'react'\nimport { PRINT_ONLY_CLASS } from '../../../styles/default'\n\n/**\n * PrintOnly component props\n */\nexport interface PrintOnlyProps {\n /**\n * Content to show only when printing\n */\n children: ReactNode\n /**\n * Additional class name\n */\n className?: string\n /**\n * Inline styles (will be applied during print)\n */\n style?: CSSProperties\n /**\n * HTML tag to use\n */\n as?: keyof React.JSX.IntrinsicElements\n}\n\n/**\n * Component that shows content only when printing\n */\nexport function PrintOnly({\n children,\n className,\n style,\n as: Component = 'div',\n}: PrintOnlyProps): React.JSX.Element {\n return (\n <Component\n className={`${PRINT_ONLY_CLASS} ${className ?? ''}`.trim()}\n style={{\n display: 'none',\n ...style,\n }}\n >\n {children}\n </Component>\n )\n}\n","import type React from 'react'\nimport type { ReactNode, CSSProperties } from 'react'\nimport { PRINT_HIDE_CLASS } from '../../../styles/default'\n\n/**\n * NoPrint component props\n */\nexport interface NoPrintProps {\n /**\n * Content to hide when printing\n */\n children: ReactNode\n /**\n * Additional class name\n */\n className?: string\n /**\n * Inline styles\n */\n style?: CSSProperties\n /**\n * HTML tag to use\n */\n as?: keyof React.JSX.IntrinsicElements\n}\n\n/**\n * Component that hides content when printing\n */\nexport function NoPrint({\n children,\n className,\n style,\n as: Component = 'div',\n}: NoPrintProps): React.JSX.Element {\n return (\n <Component\n className={`${PRINT_HIDE_CLASS} ${className ?? ''}`.trim()}\n style={style}\n >\n {children}\n </Component>\n )\n}\n"]}
package/dist/react.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { ReactNode, RefObject, CSSProperties, ButtonHTMLAttributes } from 'react';
3
- import { P as PrintOptions, b as PrintTarget, u as PrintError, c as PreviewOptions, z as PDFOptions } from './errors-COjJm-gl.cjs';
4
- export { A as AVOID_BREAK_CLASS, t as BREAK_AFTER_CLASS, B as BREAK_BEFORE_CLASS, O as Orientation, r as PRINT_HIDE_CLASS, s as PRINT_ONLY_CLASS, g as PageSize, K as TableData, w as isPrintError } from './errors-COjJm-gl.cjs';
3
+ import { P as PrintOptions, a as PrintTarget, b as PrintError, c as PreviewOptions, d as PDFOptions } from './page-break-Dr7lwsIh.cjs';
4
+ export { A as AVOID_BREAK_CLASS, B as BREAK_AFTER_CLASS, e as BREAK_BEFORE_CLASS, O as Orientation, f as PRINT_HIDE_CLASS, g as PRINT_ONLY_CLASS, h as PageSize, T as TableData, i as isPrintError } from './page-break-Dr7lwsIh.cjs';
5
5
 
6
6
  /**
7
7
  * PrintProvider props
package/dist/react.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { ReactNode, RefObject, CSSProperties, ButtonHTMLAttributes } from 'react';
3
- import { P as PrintOptions, b as PrintTarget, u as PrintError, c as PreviewOptions, z as PDFOptions } from './errors-COjJm-gl.js';
4
- export { A as AVOID_BREAK_CLASS, t as BREAK_AFTER_CLASS, B as BREAK_BEFORE_CLASS, O as Orientation, r as PRINT_HIDE_CLASS, s as PRINT_ONLY_CLASS, g as PageSize, K as TableData, w as isPrintError } from './errors-COjJm-gl.js';
3
+ import { P as PrintOptions, a as PrintTarget, b as PrintError, c as PreviewOptions, d as PDFOptions } from './page-break-Dr7lwsIh.js';
4
+ export { A as AVOID_BREAK_CLASS, B as BREAK_AFTER_CLASS, e as BREAK_BEFORE_CLASS, O as Orientation, f as PRINT_HIDE_CLASS, g as PRINT_ONLY_CLASS, h as PageSize, T as TableData, i as isPrintError } from './page-break-Dr7lwsIh.js';
5
5
 
6
6
  /**
7
7
  * PrintProvider props
package/dist/react.js CHANGED
@@ -1,2 +1,2 @@
1
- import {O,P,d,S,R,r,K,J}from'./chunk-N44HS34F.js';export{t as AVOID_BREAK_CLASS,s as BREAK_AFTER_CLASS,r as BREAK_BEFORE_CLASS,J as PRINT_HIDE_CLASS,K as PRINT_ONLY_CLASS,d as PrintError,f as isPrintError}from'./chunk-N44HS34F.js';import {createContext,forwardRef,useRef,useImperativeHandle,useState,useEffect,useCallback,useContext,useMemo}from'react';import {jsx,Fragment}from'react/jsx-runtime';var b=createContext(null);function rt(){let r=useContext(b);if(!r)throw new Error("usePrintContext must be used within a PrintProvider");return r}function T(){return useContext(b)}function it({defaultOptions:r,children:a}){let[P,e]=useState(r??{}),l=useCallback(o=>{e(s=>({...s,...o}));},[]),n=useMemo(()=>({defaultOptions:P,setDefaultOptions:l}),[P,l]);return jsx(b.Provider,{value:n,children:a})}function D(r){let a=T(),[P$1,e]=useState(false),[l,n]=useState(null),o=useRef(null),s=useRef({});s.current=O(a?.defaultOptions??{},r),useEffect(()=>(o.current=P(),()=>{o.current?.destroy(),o.current=null;}),[]);let m=useCallback(async(d$1,g)=>{if(!o.current){n(new d("PRINT_NOT_SUPPORTED","Printer not initialized"));return}e(true),n(null);try{await o.current.print(d$1,O(s.current,g));}catch(i){let c=i instanceof d?i:new d("UNKNOWN",i instanceof Error?i.message:"Unknown error");throw n(c),c}finally{e(false);}},[]),x=useCallback(async(d$1,g)=>{if(!o.current){n(new d("PRINT_NOT_SUPPORTED","Printer not initialized"));return}e(true),n(null);try{await o.current.printHTML(d$1,O(s.current,g));}catch(i){let c=i instanceof d?i:new d("UNKNOWN",i instanceof Error?i.message:"Unknown error");throw n(c),c}finally{e(false);}},[]),p=useCallback(async(d$1,g)=>{if(!o.current){n(new d("PRINT_NOT_SUPPORTED","Printer not initialized"));return}e(true),n(null);try{await o.current.printURL(d$1,O(s.current,g));}catch(i){let c=i instanceof d?i:new d("UNKNOWN",i instanceof Error?i.message:"Unknown error");throw n(c),c}finally{e(false);}},[]),t=useCallback(()=>{n(null);},[]);return {print:m,printHTML:x,printURL:p,isPrinting:P$1,error:l,clearError:t}}function k(r,a){let P=T(),[e,l]=useState(false),[n,o]=useState(1),[s,m]=useState(1),[x,p]=useState(100),t=useRef(null),d=useRef({});d.current={...P?.defaultOptions,...a};let g=useCallback(()=>{if(!r.current)return null;t.current&&t.current.destroy();let y=d.current,H=S(r.current,{...y,onClose:()=>{l(false),y.onClose?.();}});return t.current=H,H},[r]);useEffect(()=>()=>{t.current?.destroy(),t.current=null;},[]);let i=useCallback(()=>{let y=g();y&&(y.open(),l(true),o(y.getCurrentPage()),m(y.getTotalPages()),p(y.getZoom()));},[g]),c=useCallback(()=>{t.current?.close(),l(false);},[]),u=useCallback(async()=>{await t.current?.print();},[]),O=useCallback(async y=>{await t.current?.download(y);},[]),v=useCallback(y=>{t.current?.setZoom(y),p(y);},[]),E=useCallback(()=>{t.current?.zoomIn(),t.current&&p(t.current.getZoom());},[]),S$1=useCallback(()=>{t.current?.zoomOut(),t.current&&p(t.current.getZoom());},[]),R=useCallback(()=>{t.current?.resetZoom(),p(100);},[]),B=useCallback(()=>{t.current?.nextPage(),t.current&&o(t.current.getCurrentPage());},[]),Y=useCallback(()=>{t.current?.prevPage(),t.current&&o(t.current.getCurrentPage());},[]),q=useCallback(y=>{t.current?.goToPage(y),t.current&&o(t.current.getCurrentPage());},[]);return {open:i,close:c,isOpen:e,print:u,download:O,currentPage:n,totalPages:s,zoom:x,setZoom:v,zoomIn:E,zoomOut:S$1,resetZoom:R,nextPage:B,prevPage:Y,goToPage:q}}function ct(r){let a=T(),[P,e]=useState(false),[l,n]=useState(0),[o,s]=useState(null),m=useRef(null),x=useRef({});x.current={...a?.defaultOptions,...r},useEffect(()=>(m.current=R(),()=>{m.current=null;}),[]);let p=useCallback(async(u,O)=>{let v=m.current;if(!v){let R=new d("PDF_EXPORT_FAILED","PDF exporter not initialized");throw s(R),R}e(true),n(0),s(null);let E=x.current,S={...E,...O,onProgress:R=>{n(R),E.onProgress?.(R),O?.onProgress!==E.onProgress&&O?.onProgress?.(R);}};try{let R=await u(v,S);return n(100),R}catch(R){let B=R instanceof d?R:new d("PDF_EXPORT_FAILED",R instanceof Error?R.message:"Unknown error");throw s(B),B}finally{e(false);}},[]),t=useCallback((u,O,v)=>p((E,S)=>E.download(u,O,S),v),[p]),d$1=useCallback((u,O)=>p((v,E)=>v.toBlob(u,E),O),[p]),g=useCallback((u,O)=>p((v,E)=>v.toBase64(u,E),O),[p]),i=useCallback((u,O)=>p((v,E)=>v.toDataURL(u,E),O),[p]),c=useCallback(()=>{s(null);},[]);return {download:t,toBlob:d$1,toBase64:g,toDataURL:i,isExporting:P,progress:l,error:o,clearError:c}}var mt=forwardRef(function({children:a,className:P,style:e,id:l,...n},o){let s=useRef(null),{print:m}=D(n);return useImperativeHandle(o,()=>({print:async x=>{s.current&&await m(s.current,x);},getElement:()=>s.current}),[m]),jsx("div",{ref:s,id:l,className:P,style:e,children:a})});function gt({target:r,targetRef:a,options:P,children:e="Print",render:l,onPrintStart:n,onPrintComplete:o,onPrintError:s,disabled:m,onClick:x,...p}){let{print:t,isPrinting:d$1,error:g}=D(P),i=async c=>{x?.(c);let u=a?.current??r;if(!u){console.error("PrintButton: No target specified");return}try{n?.(),await t(u),o?.();}catch(O){O instanceof d&&s?.(O);}};return l?jsx(Fragment,{children:l({print:async()=>{let c=a?.current??r;c&&await t(c);},isPrinting:d$1,error:g})}):jsx("button",{...p,onClick:i,disabled:m??d$1,children:e})}function yt({target:r,targetRef:a,trigger:P,isOpen:e,onClose:l,onPrint:n,onDownload:o,...s}){let m=useRef(null),x=a??m,p={...s,...l?{onClose:l}:{},...n?{onPrint:n}:{},...o?{onDownload:o}:{}},{open:t,close:d,isOpen:g}=k(x,p);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;useEffect(()=>{i&&(e&&!g?t():!e&&g&&d());},[e,i,g,t,d]);let c=()=>{t();};return P?jsx("span",{onClick:c,style:{cursor:"pointer"},children:P}):null}function xt({className:r$1}){return jsx("div",{className:`${r} ${r$1??""}`.trim(),style:{height:0,pageBreakBefore:"always",breakBefore:"page"},"aria-hidden":"true"})}function wt({children:r,className:a,style:P,as:e="div"}){return jsx(e,{className:`${K} ${a??""}`.trim(),style:{display:"none",...P},children:r})}function Ct({children:r,className:a,style:P,as:e="div"}){return jsx(e,{className:`${J} ${a??""}`.trim(),style:P,children:r})}export{Ct as NoPrint,xt as PageBreak,gt as PrintButton,b as PrintContext,wt as PrintOnly,yt as PrintPreview,it as PrintProvider,mt as Printable,ct as usePDF,D as usePrint,rt as usePrintContext,k as usePrintPreview};//# sourceMappingURL=react.js.map
1
+ import {O,P,d,S,R,r,K,J}from'./chunk-PSFVJVSZ.js';export{t as AVOID_BREAK_CLASS,s as BREAK_AFTER_CLASS,r as BREAK_BEFORE_CLASS,J as PRINT_HIDE_CLASS,K as PRINT_ONLY_CLASS,d as PrintError,f as isPrintError}from'./chunk-PSFVJVSZ.js';import {createContext,forwardRef,useRef,useImperativeHandle,useState,useEffect,useCallback,useContext,useMemo}from'react';import {jsx,Fragment}from'react/jsx-runtime';var b=createContext(null);function rt(){let r=useContext(b);if(!r)throw new Error("usePrintContext must be used within a PrintProvider");return r}function T(){return useContext(b)}function it({defaultOptions:r,children:a}){let[c,e]=useState(r??{}),l=useCallback(o=>{e(s=>({...s,...o}));},[]),n=useMemo(()=>({defaultOptions:c,setDefaultOptions:l}),[c,l]);return jsx(b.Provider,{value:n,children:a})}function D(r){let a=T(),[c,e]=useState(false),[l,n]=useState(null),o=useRef(null),s=useRef({});s.current=O(a?.defaultOptions??{},r),useEffect(()=>(o.current=P(),()=>{o.current?.destroy(),o.current=null;}),[]);let m=useCallback(async(d$1,g)=>{if(!o.current){n(new d("PRINT_NOT_SUPPORTED","Printer not initialized"));return}e(true),n(null);try{await o.current.print(d$1,O(s.current,g));}catch(i){let p=i instanceof d?i:new d("UNKNOWN",i instanceof Error?i.message:"Unknown error");throw n(p),p}finally{e(false);}},[]),v=useCallback(async(d$1,g)=>{if(!o.current){n(new d("PRINT_NOT_SUPPORTED","Printer not initialized"));return}e(true),n(null);try{await o.current.printHTML(d$1,O(s.current,g));}catch(i){let p=i instanceof d?i:new d("UNKNOWN",i instanceof Error?i.message:"Unknown error");throw n(p),p}finally{e(false);}},[]),P$1=useCallback(async(d$1,g)=>{if(!o.current){n(new d("PRINT_NOT_SUPPORTED","Printer not initialized"));return}e(true),n(null);try{await o.current.printURL(d$1,O(s.current,g));}catch(i){let p=i instanceof d?i:new d("UNKNOWN",i instanceof Error?i.message:"Unknown error");throw n(p),p}finally{e(false);}},[]),t=useCallback(()=>{n(null);},[]);return {print:m,printHTML:v,printURL:P$1,isPrinting:c,error:l,clearError:t}}function k(r,a){let c=T(),[e,l]=useState(false),[n,o]=useState(1),[s,m]=useState(1),[v,P]=useState(100),t=useRef(null),d=useRef({});d.current={...c?.defaultOptions,...a};let g=useCallback(()=>{if(!r.current)return null;t.current&&t.current.destroy();let y=d.current,H=S(r.current,{...y,onClose:()=>{l(false),y.onClose?.();}});return t.current=H,H},[r]);useEffect(()=>()=>{t.current?.destroy(),t.current=null;},[]);let i=useCallback(()=>{let y=g();y&&(y.open(),l(true),o(y.getCurrentPage()),m(y.getTotalPages()),P(y.getZoom()));},[g]),p=useCallback(()=>{t.current?.close(),l(false);},[]),u=useCallback(async()=>{await t.current?.print();},[]),O=useCallback(async y=>{await t.current?.download(y);},[]),x=useCallback(y=>{t.current?.setZoom(y),P(y);},[]),E=useCallback(()=>{t.current?.zoomIn(),t.current&&P(t.current.getZoom());},[]),S$1=useCallback(()=>{t.current?.zoomOut(),t.current&&P(t.current.getZoom());},[]),R=useCallback(()=>{t.current?.resetZoom(),P(100);},[]),B=useCallback(()=>{t.current?.nextPage(),t.current&&o(t.current.getCurrentPage());},[]),Y=useCallback(()=>{t.current?.prevPage(),t.current&&o(t.current.getCurrentPage());},[]),q=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$1,resetZoom:R,nextPage:B,prevPage:Y,goToPage:q}}function ct(r){let a=T(),[c,e]=useState(false),[l,n]=useState(0),[o,s]=useState(null),m=useRef(null),v=useRef({});v.current={...a?.defaultOptions,...r},useEffect(()=>(m.current=R(),()=>{m.current=null;}),[]);let P=useCallback(async(u,O)=>{let x=m.current;if(!x){let R=new 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 d?R:new d("PDF_EXPORT_FAILED",R instanceof Error?R.message:"Unknown error");throw s(B),B}finally{e(false);}},[]),t=useCallback((u,O,x)=>P((E,S)=>E.download(u,O,S),x),[P]),d$1=useCallback((u,O)=>P((x,E)=>x.toBlob(u,E),O),[P]),g=useCallback((u,O)=>P((x,E)=>x.toBase64(u,E),O),[P]),i=useCallback((u,O)=>P((x,E)=>x.toDataURL(u,E),O),[P]),p=useCallback(()=>{s(null);},[]);return {download:t,toBlob:d$1,toBase64:g,toDataURL:i,isExporting:c,progress:l,error:o,clearError:p}}var mt=forwardRef(function({children:a,className:c,style:e,id:l,...n},o){let s=useRef(null),{print:m}=D(n);return useImperativeHandle(o,()=>({print:async v=>{s.current&&await m(s.current,v);},getElement:()=>s.current}),[m]),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$1,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 d&&s?.(O);}};return l?jsx(Fragment,{children:l({print:async()=>{let p=a?.current??r;p&&await t(p);},isPrinting:d$1,error:g})}):jsx("button",{...P,onClick:p=>{i(p);},disabled:m??d$1,children:e})}function yt({target:r,targetRef:a,trigger:c,isOpen:e,onClose:l,onPrint:n,onDownload:o,...s}){let m=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);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;useEffect(()=>{i&&(e&&!g?t():!e&&g&&d());},[e,i,g,t,d]);let p=()=>{t();};return c?jsx("span",{onClick:p,style:{cursor:"pointer"},children:c}):null}function vt({className:r$1}){return jsx("div",{className:`${r} ${r$1??""}`.trim(),style:{height:0,pageBreakBefore:"always",breakBefore:"page"},"aria-hidden":"true"})}function wt({children:r,className:a,style:c,as:e="div"}){return jsx(e,{className:`${K} ${a??""}`.trim(),style:{display:"none",...c},children:r})}function Ct({children:r,className:a,style:c,as:e="div"}){return jsx(e,{className:`${J} ${a??""}`.trim(),style:c,children:r})}export{Ct as NoPrint,vt as PageBreak,gt as PrintButton,b as PrintContext,wt as PrintOnly,yt as PrintPreview,it as PrintProvider,mt as Printable,ct as usePDF,D as usePrint,rt as usePrintContext,k as usePrintPreview};//# sourceMappingURL=react.js.map
2
2
  //# sourceMappingURL=react.js.map