@superdoc-dev/esign 1.1.1 → 1.2.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -7
- package/dist/PdfViewer-BLHsHKWf.es-DVVY0V9L.cjs +43 -0
- package/dist/PdfViewer-BLHsHKWf.es-JoVU99JQ.js +400 -0
- package/dist/index.js +4 -4
- package/dist/index.mjs +199 -197
- package/dist/superdoc.es-CqejOF1J.js +90963 -0
- package/dist/superdoc.es-DfpwGgyj.cjs +1180 -0
- package/dist/types.d.ts +10 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,15 +31,18 @@ function App() {
|
|
|
31
31
|
eventId={`session-${Date.now()}`}
|
|
32
32
|
|
|
33
33
|
document={{
|
|
34
|
-
source: "https://storage.googleapis.com/public_static_hosting/public_demo_docs/
|
|
34
|
+
source: "https://storage.googleapis.com/public_static_hosting/public_demo_docs/service_agreement.docx",
|
|
35
35
|
validation: { scroll: { required: true } }
|
|
36
36
|
}}
|
|
37
37
|
|
|
38
38
|
fields={{
|
|
39
39
|
document: [
|
|
40
|
-
{ id: '
|
|
41
|
-
{ id: '
|
|
42
|
-
{ id: '
|
|
40
|
+
{ id: 'user_name', value: 'John Doe' },
|
|
41
|
+
{ id: 'agreement_date', value: new Date().toLocaleDateString() },
|
|
42
|
+
{ id: 'company_name', value: 'SuperDoc' },
|
|
43
|
+
{ id: 'service_type', value: 'Premium' },
|
|
44
|
+
{ id: 'agreement_jurisdiction', value: 'CA' },
|
|
45
|
+
{ id: 'company_address', value: '123 Main St, Anytown, USA' }
|
|
43
46
|
],
|
|
44
47
|
signer: [
|
|
45
48
|
{
|
|
@@ -105,7 +108,7 @@ app.post('/api/sign', async (req, res) => {
|
|
|
105
108
|
});
|
|
106
109
|
```
|
|
107
110
|
|
|
108
|
-
See [Python,
|
|
111
|
+
See [Python, Node.js, and more examples](https://docs.superdoc.dev/solutions/esign/backend).
|
|
109
112
|
|
|
110
113
|
## What You Receive
|
|
111
114
|
|
|
@@ -115,10 +118,10 @@ See [Python, Ruby, and more examples](https://docs.superdoc.dev/solutions/esign/
|
|
|
115
118
|
timestamp: "2024-01-15T10:30:00Z",
|
|
116
119
|
duration: 45000,
|
|
117
120
|
documentFields: [
|
|
118
|
-
{ id: "
|
|
121
|
+
{ id: "user_name", value: "John Doe" }
|
|
119
122
|
],
|
|
120
123
|
signerFields: [
|
|
121
|
-
{ id: "signature", value: "
|
|
124
|
+
{ id: "signature", value: "John Doe" },
|
|
122
125
|
{ id: "accept_terms", value: true }
|
|
123
126
|
],
|
|
124
127
|
auditTrail: [
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./superdoc.es-DfpwGgyj.cjs");function B(s){const{opacityDisabled:t,heightTiny:o,heightSmall:n,heightMedium:i,heightLarge:a,heightHuge:u,primaryColor:l,fontSize:r}=s;return{fontSize:r,textColor:l,sizeTiny:o,sizeSmall:n,sizeMedium:i,sizeLarge:a,sizeHuge:u,color:l,opacitySpinning:t}}const V={common:e.derived,self:B},L=e.c$1([e.c$1("@keyframes spin-rotate",`
|
|
2
|
+
from {
|
|
3
|
+
transform: rotate(0);
|
|
4
|
+
}
|
|
5
|
+
to {
|
|
6
|
+
transform: rotate(360deg);
|
|
7
|
+
}
|
|
8
|
+
`),e.cB("spin-container",`
|
|
9
|
+
position: relative;
|
|
10
|
+
`,[e.cB("spin-body",`
|
|
11
|
+
position: absolute;
|
|
12
|
+
top: 50%;
|
|
13
|
+
left: 50%;
|
|
14
|
+
transform: translateX(-50%) translateY(-50%);
|
|
15
|
+
`,[e.fadeInTransition()])]),e.cB("spin-body",`
|
|
16
|
+
display: inline-flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
`),e.cB("spin",`
|
|
21
|
+
display: inline-flex;
|
|
22
|
+
height: var(--n-size);
|
|
23
|
+
width: var(--n-size);
|
|
24
|
+
font-size: var(--n-size);
|
|
25
|
+
color: var(--n-color);
|
|
26
|
+
`,[e.cM("rotate",`
|
|
27
|
+
animation: spin-rotate 2s linear infinite;
|
|
28
|
+
`)]),e.cB("spin-description",`
|
|
29
|
+
display: inline-block;
|
|
30
|
+
font-size: var(--n-font-size);
|
|
31
|
+
color: var(--n-text-color);
|
|
32
|
+
transition: color .3s var(--n-bezier);
|
|
33
|
+
margin-top: 8px;
|
|
34
|
+
`),e.cB("spin-content",`
|
|
35
|
+
opacity: 1;
|
|
36
|
+
transition: opacity .3s var(--n-bezier);
|
|
37
|
+
pointer-events: all;
|
|
38
|
+
`,[e.cM("spinning",`
|
|
39
|
+
user-select: none;
|
|
40
|
+
-webkit-user-select: none;
|
|
41
|
+
pointer-events: none;
|
|
42
|
+
opacity: var(--n-opacity-spinning);
|
|
43
|
+
`)])]),_={small:20,medium:18,large:16},R=Object.assign(Object.assign({},e.useTheme.props),{contentClass:String,contentStyle:[Object,String],description:String,stroke:String,size:{type:[String,Number],default:"medium"},show:{type:Boolean,default:!0},strokeWidth:Number,rotate:{type:Boolean,default:!0},spinning:{type:Boolean,validator:()=>!0,default:void 0},delay:Number}),D=e.defineComponent({name:"Spin",props:R,slots:Object,setup(s){e.process$1.env.NODE_ENV!=="production"&&e.watchEffect(()=>{s.spinning!==void 0&&e.warnOnce("spin","`spinning` is deprecated, please use `show` instead.")});const{mergedClsPrefixRef:t,inlineThemeDisabled:o}=e.useConfig(s),n=e.useTheme("Spin","-spin",L,V,s,t),i=e.computed(()=>{const{size:r}=s,{common:{cubicBezierEaseInOut:p},self:h}=n.value,{opacitySpinning:f,color:y,textColor:b}=h,m=typeof r=="number"?e.pxfy(r):h[e.createKey("size",r)];return{"--n-bezier":p,"--n-opacity-spinning":f,"--n-size":m,"--n-color":y,"--n-text-color":b}}),a=o?e.useThemeClass("spin",e.computed(()=>{const{size:r}=s;return typeof r=="number"?String(r):r[0]}),i,s):void 0,u=e.useCompitable(s,["spinning","show"]),l=e.ref(!1);return e.watchEffect(r=>{let p;if(u.value){const{delay:h}=s;if(h){p=window.setTimeout(()=>{l.value=!0},h),r(()=>{clearTimeout(p)});return}}l.value=u.value}),{mergedClsPrefix:t,active:l,mergedStrokeWidth:e.computed(()=>{const{strokeWidth:r}=s;if(r!==void 0)return r;const{size:p}=s;return _[typeof p=="number"?"medium":p]}),cssVars:o?void 0:i,themeClass:a?.themeClass,onRender:a?.onRender}},render(){var s,t;const{$slots:o,mergedClsPrefix:n,description:i}=this,a=o.icon&&this.rotate,u=(i||o.description)&&e.h("div",{class:`${n}-spin-description`},i||((s=o.description)===null||s===void 0?void 0:s.call(o))),l=o.icon?e.h("div",{class:[`${n}-spin-body`,this.themeClass]},e.h("div",{class:[`${n}-spin`,a&&`${n}-spin--rotate`],style:o.default?"":this.cssVars},o.icon()),u):e.h("div",{class:[`${n}-spin-body`,this.themeClass]},e.h(e.NBaseLoading,{clsPrefix:n,style:o.default?"":this.cssVars,stroke:this.stroke,"stroke-width":this.mergedStrokeWidth,class:`${n}-spin`}),u);return(t=this.onRender)===null||t===void 0||t.call(this),o.default?e.h("div",{class:[`${n}-spin-container`,this.themeClass],style:this.cssVars},e.h("div",{class:[`${n}-spin-content`,this.active&&`${n}-spin-content--spinning`,this.contentClass],style:this.contentStyle},o),e.h(e.Transition,{name:"fade-in-transition"},{default:()=>this.active?l:null})):l}}),M=(s,t)=>{const o=t-s;return Array.from({length:o},(n,i)=>s+i)};class z{constructor(){if(Object.getPrototypeOf(this).constructor===z)throw new Error("Abstract class should not be instanciated")}}class T extends z{constructor(t){super(),this.pdfLib=t.pdfLib,this.pdfViewer=t.pdfViewer,this.workerSrc=t.workerSrc,this.textLayerMode=t.textLayerMode??0,t.setWorker&&(this.workerSrc?this.pdfLib.GlobalWorkerOptions.workerSrc=t.workerSrc:this.pdfLib.GlobalWorkerOptions.workerSrc=N(this.pdfLib.version)),this.pdfPageViews=[]}async getDocument(t){return await this.pdfLib.getDocument(t).promise}async renderPages({documentId:t,pdfDocument:o,viewerContainer:n,emit:i=()=>{}}){try{this.pdfPageViews=[];const a=o.numPages,l=await $(o,1,a),r=[];for(const[p,h]of l.entries()){const f=document.createElement("div");f.classList.add("pdf-page"),f.dataset.pageNumber=(p+1).toString(),f.id=`${t}-page-${p+1}`,r.push(f);const{width:y,height:b}=this.getOriginalPageSize(h),m=1,C=new this.pdfViewer.EventBus,d=new this.pdfViewer.PDFPageView({container:f,id:p+1,scale:m,defaultViewport:h.getViewport({scale:m}),eventBus:C,textLayerMode:this.textLayerMode});this.pdfPageViews.push(d);const g=f.getBoundingClientRect();g.originalWidth=y,g.originalHeight=b,d.setPdfPage(h),await d.draw(),i("page-loaded",t,p,g)}n.append(...r),i("ready",t,n)}catch(a){console.error("Error loading PDF:",a)}}getOriginalPageSize(t){const o=t.getViewport({scale:1}),n=o.width,i=o.height;return{width:n,height:i}}destroy(){this.pdfPageViews.forEach(t=>t.destroy()),this.pdfPageViews=[]}}class j{static create(t){const o={pdfjs:()=>new T(t),default:()=>{throw new Error("Unsupported adapter")}};return(o[t.adapter]??o.default)()}}const O=s=>({...{adapter:"pdfjs"},...s});async function $(s,t,o){const n=M(t,o+1).map(i=>s.getPage(i));return await Promise.all(n)}function N(s){return`https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${s}/pdf.worker.min.mjs`}const E=s=>new Promise((t,o)=>{const n=new FileReader;n.onload=i=>t(i.target.result),n.onerror=o,n.readAsDataURL(s)}),W={key:0,class:"superdoc-pdf-viewer__loader"},A={__name:"PdfViewer",props:{documentData:{type:Object,required:!0},config:{type:Object,required:!0}},emits:["page-loaded","ready","selection-change","bypass-selection"],setup(s,{emit:t}){const o=t,n=s,i=e.useSuperdocStore(),{activeZoom:a}=e.storeToRefs(i),u=e.ref(null),l=e.ref(!1),r=n.documentData.id,p=n.documentData.data,h=O({pdfLib:n.config.pdfLib,pdfViewer:n.config.pdfViewer,workerSrc:n.config.workerSrc,setWorker:n.config.setWorker,textLayerMode:n.config.textLayerMode}),f=j.create(h),y=async d=>{try{const g=await E(d),S=await f.getDocument(g);await f.renderPages({documentId:r,pdfDocument:S,viewerContainer:u.value,emit:o}),l.value=!0}catch{}};function b(d){const g=window.getSelection();if(g.rangeCount===0)return null;const w=g.getRangeAt(0).getClientRects();if(w.length===0)return null;const P=w[0];let c={top:P.top,left:P.left,bottom:P.bottom,right:P.right};for(let x=1;x<w.length;x++){const v=w[x];v.width===0||v.height===0||(c.top=Math.min(c.top,v.top),c.left=Math.min(c.left,v.left),c.bottom=Math.max(c.bottom,v.bottom),c.right=Math.max(c.right,v.right))}const k=d.getBoundingClientRect();return u.value.getBoundingClientRect(),c.top=(c.top-k.top)/(a.value/100)+d.scrollTop,c.left=(c.left-k.left)/(a.value/100)+d.scrollLeft,c.bottom=(c.bottom-k.top)/(a.value/100)+d.scrollTop,c.right=(c.right-k.left)/(a.value/100)+d.scrollLeft,c}const m=d=>{const{target:g}=d;g.tagName!=="SPAN"&&o("bypass-selection",d)},C=d=>{if(window.getSelection().toString().length>0){const S=b(u.value),w=e.useSelection({selectionBounds:S,documentId:r});o("selection-change",w)}};return e.onMounted(async()=>{await y(p)}),e.onUnmounted(()=>{f.destroy()}),(d,g)=>(e.openBlock(),e.createElementBlock("div",{class:"superdoc-pdf-viewer-container",onMousedown:m,onMouseup:C},[e.createBaseVNode("div",{class:"superdoc-pdf-viewer",ref_key:"viewer",ref:u,id:"viewerId"},null,512),l.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",W,[e.createVNode(e.unref(D),{class:"superdoc-pdf-viewer__spin",size:"large"})]))],32))}},F=e._export_sfc(A,[["__scopeId","data-v-84719682"]]);exports.default=F;
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { _ as N, u as O, s as $, r as L, o as E, a as W, c as B, b as R, d as A, e as F, f as I, g as H, h as U, i as h, N as q, T as G, p as K, w as D, j as J, k as X, l as M, m as Y, n as T, q as V, t as Z, v as Q, x as ee, y as te, z as se, A as y, B as ne, C as j } from "./superdoc.es-CqejOF1J.js";
|
|
2
|
+
function oe(n) {
|
|
3
|
+
const {
|
|
4
|
+
opacityDisabled: e,
|
|
5
|
+
heightTiny: s,
|
|
6
|
+
heightSmall: t,
|
|
7
|
+
heightMedium: o,
|
|
8
|
+
heightLarge: r,
|
|
9
|
+
heightHuge: p,
|
|
10
|
+
primaryColor: d,
|
|
11
|
+
fontSize: i
|
|
12
|
+
} = n;
|
|
13
|
+
return {
|
|
14
|
+
fontSize: i,
|
|
15
|
+
textColor: d,
|
|
16
|
+
sizeTiny: s,
|
|
17
|
+
sizeSmall: t,
|
|
18
|
+
sizeMedium: o,
|
|
19
|
+
sizeLarge: r,
|
|
20
|
+
sizeHuge: p,
|
|
21
|
+
color: d,
|
|
22
|
+
opacitySpinning: e
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const ie = {
|
|
26
|
+
common: Y,
|
|
27
|
+
self: oe
|
|
28
|
+
}, re = T([T("@keyframes spin-rotate", `
|
|
29
|
+
from {
|
|
30
|
+
transform: rotate(0);
|
|
31
|
+
}
|
|
32
|
+
to {
|
|
33
|
+
transform: rotate(360deg);
|
|
34
|
+
}
|
|
35
|
+
`), y("spin-container", `
|
|
36
|
+
position: relative;
|
|
37
|
+
`, [y("spin-body", `
|
|
38
|
+
position: absolute;
|
|
39
|
+
top: 50%;
|
|
40
|
+
left: 50%;
|
|
41
|
+
transform: translateX(-50%) translateY(-50%);
|
|
42
|
+
`, [ne()])]), y("spin-body", `
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
flex-direction: column;
|
|
47
|
+
`), y("spin", `
|
|
48
|
+
display: inline-flex;
|
|
49
|
+
height: var(--n-size);
|
|
50
|
+
width: var(--n-size);
|
|
51
|
+
font-size: var(--n-size);
|
|
52
|
+
color: var(--n-color);
|
|
53
|
+
`, [j("rotate", `
|
|
54
|
+
animation: spin-rotate 2s linear infinite;
|
|
55
|
+
`)]), y("spin-description", `
|
|
56
|
+
display: inline-block;
|
|
57
|
+
font-size: var(--n-font-size);
|
|
58
|
+
color: var(--n-text-color);
|
|
59
|
+
transition: color .3s var(--n-bezier);
|
|
60
|
+
margin-top: 8px;
|
|
61
|
+
`), y("spin-content", `
|
|
62
|
+
opacity: 1;
|
|
63
|
+
transition: opacity .3s var(--n-bezier);
|
|
64
|
+
pointer-events: all;
|
|
65
|
+
`, [j("spinning", `
|
|
66
|
+
user-select: none;
|
|
67
|
+
-webkit-user-select: none;
|
|
68
|
+
pointer-events: none;
|
|
69
|
+
opacity: var(--n-opacity-spinning);
|
|
70
|
+
`)])]), ae = {
|
|
71
|
+
small: 20,
|
|
72
|
+
medium: 18,
|
|
73
|
+
large: 16
|
|
74
|
+
}, ce = Object.assign(Object.assign({}, M.props), {
|
|
75
|
+
contentClass: String,
|
|
76
|
+
contentStyle: [Object, String],
|
|
77
|
+
description: String,
|
|
78
|
+
stroke: String,
|
|
79
|
+
size: {
|
|
80
|
+
type: [String, Number],
|
|
81
|
+
default: "medium"
|
|
82
|
+
},
|
|
83
|
+
show: {
|
|
84
|
+
type: Boolean,
|
|
85
|
+
default: !0
|
|
86
|
+
},
|
|
87
|
+
strokeWidth: Number,
|
|
88
|
+
rotate: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
default: !0
|
|
91
|
+
},
|
|
92
|
+
spinning: {
|
|
93
|
+
type: Boolean,
|
|
94
|
+
validator: () => !0,
|
|
95
|
+
default: void 0
|
|
96
|
+
},
|
|
97
|
+
delay: Number
|
|
98
|
+
}), de = U({
|
|
99
|
+
name: "Spin",
|
|
100
|
+
props: ce,
|
|
101
|
+
slots: Object,
|
|
102
|
+
setup(n) {
|
|
103
|
+
K.env.NODE_ENV !== "production" && D(() => {
|
|
104
|
+
n.spinning !== void 0 && J("spin", "`spinning` is deprecated, please use `show` instead.");
|
|
105
|
+
});
|
|
106
|
+
const {
|
|
107
|
+
mergedClsPrefixRef: e,
|
|
108
|
+
inlineThemeDisabled: s
|
|
109
|
+
} = X(n), t = M("Spin", "-spin", re, ie, n, e), o = V(() => {
|
|
110
|
+
const {
|
|
111
|
+
size: i
|
|
112
|
+
} = n, {
|
|
113
|
+
common: {
|
|
114
|
+
cubicBezierEaseInOut: l
|
|
115
|
+
},
|
|
116
|
+
self: g
|
|
117
|
+
} = t.value, {
|
|
118
|
+
opacitySpinning: u,
|
|
119
|
+
color: b,
|
|
120
|
+
textColor: S
|
|
121
|
+
} = g, m = typeof i == "number" ? Z(i) : g[Q("size", i)];
|
|
122
|
+
return {
|
|
123
|
+
"--n-bezier": l,
|
|
124
|
+
"--n-opacity-spinning": u,
|
|
125
|
+
"--n-size": m,
|
|
126
|
+
"--n-color": b,
|
|
127
|
+
"--n-text-color": S
|
|
128
|
+
};
|
|
129
|
+
}), r = s ? ee("spin", V(() => {
|
|
130
|
+
const {
|
|
131
|
+
size: i
|
|
132
|
+
} = n;
|
|
133
|
+
return typeof i == "number" ? String(i) : i[0];
|
|
134
|
+
}), o, n) : void 0, p = te(n, ["spinning", "show"]), d = L(!1);
|
|
135
|
+
return D((i) => {
|
|
136
|
+
let l;
|
|
137
|
+
if (p.value) {
|
|
138
|
+
const {
|
|
139
|
+
delay: g
|
|
140
|
+
} = n;
|
|
141
|
+
if (g) {
|
|
142
|
+
l = window.setTimeout(() => {
|
|
143
|
+
d.value = !0;
|
|
144
|
+
}, g), i(() => {
|
|
145
|
+
clearTimeout(l);
|
|
146
|
+
});
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
d.value = p.value;
|
|
151
|
+
}), {
|
|
152
|
+
mergedClsPrefix: e,
|
|
153
|
+
active: d,
|
|
154
|
+
mergedStrokeWidth: V(() => {
|
|
155
|
+
const {
|
|
156
|
+
strokeWidth: i
|
|
157
|
+
} = n;
|
|
158
|
+
if (i !== void 0) return i;
|
|
159
|
+
const {
|
|
160
|
+
size: l
|
|
161
|
+
} = n;
|
|
162
|
+
return ae[typeof l == "number" ? "medium" : l];
|
|
163
|
+
}),
|
|
164
|
+
cssVars: s ? void 0 : o,
|
|
165
|
+
themeClass: r?.themeClass,
|
|
166
|
+
onRender: r?.onRender
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
render() {
|
|
170
|
+
var n, e;
|
|
171
|
+
const {
|
|
172
|
+
$slots: s,
|
|
173
|
+
mergedClsPrefix: t,
|
|
174
|
+
description: o
|
|
175
|
+
} = this, r = s.icon && this.rotate, p = (o || s.description) && h("div", {
|
|
176
|
+
class: `${t}-spin-description`
|
|
177
|
+
}, o || ((n = s.description) === null || n === void 0 ? void 0 : n.call(s))), d = s.icon ? h("div", {
|
|
178
|
+
class: [`${t}-spin-body`, this.themeClass]
|
|
179
|
+
}, h("div", {
|
|
180
|
+
class: [`${t}-spin`, r && `${t}-spin--rotate`],
|
|
181
|
+
style: s.default ? "" : this.cssVars
|
|
182
|
+
}, s.icon()), p) : h("div", {
|
|
183
|
+
class: [`${t}-spin-body`, this.themeClass]
|
|
184
|
+
}, h(q, {
|
|
185
|
+
clsPrefix: t,
|
|
186
|
+
style: s.default ? "" : this.cssVars,
|
|
187
|
+
stroke: this.stroke,
|
|
188
|
+
"stroke-width": this.mergedStrokeWidth,
|
|
189
|
+
class: `${t}-spin`
|
|
190
|
+
}), p);
|
|
191
|
+
return (e = this.onRender) === null || e === void 0 || e.call(this), s.default ? h("div", {
|
|
192
|
+
class: [`${t}-spin-container`, this.themeClass],
|
|
193
|
+
style: this.cssVars
|
|
194
|
+
}, h("div", {
|
|
195
|
+
class: [`${t}-spin-content`, this.active && `${t}-spin-content--spinning`, this.contentClass],
|
|
196
|
+
style: this.contentStyle
|
|
197
|
+
}, s), h(G, {
|
|
198
|
+
name: "fade-in-transition"
|
|
199
|
+
}, {
|
|
200
|
+
default: () => this.active ? d : null
|
|
201
|
+
})) : d;
|
|
202
|
+
}
|
|
203
|
+
}), le = (n, e) => {
|
|
204
|
+
const s = e - n;
|
|
205
|
+
return Array.from({ length: s }, (t, o) => n + o);
|
|
206
|
+
};
|
|
207
|
+
class _ {
|
|
208
|
+
/**
|
|
209
|
+
* @throws {Error}
|
|
210
|
+
*/
|
|
211
|
+
constructor() {
|
|
212
|
+
if (Object.getPrototypeOf(this).constructor === _)
|
|
213
|
+
throw new Error("Abstract class should not be instanciated");
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
class pe extends _ {
|
|
217
|
+
/**
|
|
218
|
+
* @param {PDFJSConfig} config
|
|
219
|
+
*/
|
|
220
|
+
constructor(e) {
|
|
221
|
+
super(), this.pdfLib = e.pdfLib, this.pdfViewer = e.pdfViewer, this.workerSrc = e.workerSrc, this.textLayerMode = e.textLayerMode ?? 0, e.setWorker && (this.workerSrc ? this.pdfLib.GlobalWorkerOptions.workerSrc = e.workerSrc : this.pdfLib.GlobalWorkerOptions.workerSrc = he(this.pdfLib.version)), this.pdfPageViews = [];
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* @param {string | ArrayBuffer | Uint8Array} file
|
|
225
|
+
* @returns {Promise<PDFDocumentProxy>}
|
|
226
|
+
*/
|
|
227
|
+
async getDocument(e) {
|
|
228
|
+
return await this.pdfLib.getDocument(e).promise;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* @param {RenderPagesOptions} options
|
|
232
|
+
* @returns {Promise<void>}
|
|
233
|
+
*/
|
|
234
|
+
async renderPages({ documentId: e, pdfDocument: s, viewerContainer: t, emit: o = () => {
|
|
235
|
+
} }) {
|
|
236
|
+
try {
|
|
237
|
+
this.pdfPageViews = [];
|
|
238
|
+
const r = s.numPages, d = await ge(s, 1, r), i = [];
|
|
239
|
+
for (const [l, g] of d.entries()) {
|
|
240
|
+
const u = document.createElement("div");
|
|
241
|
+
u.classList.add("pdf-page"), u.dataset.pageNumber = (l + 1).toString(), u.id = `${e}-page-${l + 1}`, i.push(u);
|
|
242
|
+
const { width: b, height: S } = this.getOriginalPageSize(g), m = 1, x = new this.pdfViewer.EventBus(), c = new this.pdfViewer.PDFPageView({
|
|
243
|
+
container: u,
|
|
244
|
+
id: l + 1,
|
|
245
|
+
scale: m,
|
|
246
|
+
defaultViewport: g.getViewport({ scale: m }),
|
|
247
|
+
eventBus: x,
|
|
248
|
+
textLayerMode: this.textLayerMode
|
|
249
|
+
});
|
|
250
|
+
this.pdfPageViews.push(c);
|
|
251
|
+
const f = u.getBoundingClientRect();
|
|
252
|
+
f.originalWidth = b, f.originalHeight = S, c.setPdfPage(g), await c.draw(), o("page-loaded", e, l, f);
|
|
253
|
+
}
|
|
254
|
+
t.append(...i), o("ready", e, t);
|
|
255
|
+
} catch (r) {
|
|
256
|
+
console.error("Error loading PDF:", r);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* @param {PDFPageProxy} page
|
|
261
|
+
* @returns {object}
|
|
262
|
+
*/
|
|
263
|
+
getOriginalPageSize(e) {
|
|
264
|
+
const s = e.getViewport({ scale: 1 }), t = s.width, o = s.height;
|
|
265
|
+
return { width: t, height: o };
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* @return {void}
|
|
269
|
+
*/
|
|
270
|
+
destroy() {
|
|
271
|
+
this.pdfPageViews.forEach((e) => e.destroy()), this.pdfPageViews = [];
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
class ue {
|
|
275
|
+
/**
|
|
276
|
+
* @param {PDFJSConfig & {adapter: AdapterType}} config
|
|
277
|
+
* @returns {PDFAdapter}
|
|
278
|
+
* @throws {Error}
|
|
279
|
+
*/
|
|
280
|
+
static create(e) {
|
|
281
|
+
const s = {
|
|
282
|
+
pdfjs: () => new pe(e),
|
|
283
|
+
default: () => {
|
|
284
|
+
throw new Error("Unsupported adapter");
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
return (s[e.adapter] ?? s.default)();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
const fe = (n) => ({
|
|
291
|
+
...{
|
|
292
|
+
adapter: "pdfjs"
|
|
293
|
+
},
|
|
294
|
+
...n
|
|
295
|
+
});
|
|
296
|
+
async function ge(n, e, s) {
|
|
297
|
+
const t = le(e, s + 1).map((o) => n.getPage(o));
|
|
298
|
+
return await Promise.all(t);
|
|
299
|
+
}
|
|
300
|
+
function he(n) {
|
|
301
|
+
return `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${n}/pdf.worker.min.mjs`;
|
|
302
|
+
}
|
|
303
|
+
const me = (n) => new Promise((e, s) => {
|
|
304
|
+
const t = new FileReader();
|
|
305
|
+
t.onload = (o) => e(o.target.result), t.onerror = s, t.readAsDataURL(n);
|
|
306
|
+
}), we = {
|
|
307
|
+
key: 0,
|
|
308
|
+
class: "superdoc-pdf-viewer__loader"
|
|
309
|
+
}, ve = {
|
|
310
|
+
__name: "PdfViewer",
|
|
311
|
+
props: {
|
|
312
|
+
documentData: {
|
|
313
|
+
type: Object,
|
|
314
|
+
required: !0
|
|
315
|
+
},
|
|
316
|
+
config: {
|
|
317
|
+
type: Object,
|
|
318
|
+
required: !0
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
emits: ["page-loaded", "ready", "selection-change", "bypass-selection"],
|
|
322
|
+
setup(n, { emit: e }) {
|
|
323
|
+
const s = e, t = n, o = O(), { activeZoom: r } = $(o), p = L(null), d = L(!1), i = t.documentData.id, l = t.documentData.data, g = fe({
|
|
324
|
+
pdfLib: t.config.pdfLib,
|
|
325
|
+
pdfViewer: t.config.pdfViewer,
|
|
326
|
+
workerSrc: t.config.workerSrc,
|
|
327
|
+
setWorker: t.config.setWorker,
|
|
328
|
+
textLayerMode: t.config.textLayerMode
|
|
329
|
+
}), u = ue.create(g), b = async (c) => {
|
|
330
|
+
try {
|
|
331
|
+
const f = await me(c), P = await u.getDocument(f);
|
|
332
|
+
await u.renderPages({
|
|
333
|
+
documentId: i,
|
|
334
|
+
pdfDocument: P,
|
|
335
|
+
viewerContainer: p.value,
|
|
336
|
+
emit: s
|
|
337
|
+
}), d.value = !0;
|
|
338
|
+
} catch {
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
function S(c) {
|
|
342
|
+
const f = window.getSelection();
|
|
343
|
+
if (f.rangeCount === 0)
|
|
344
|
+
return null;
|
|
345
|
+
const w = f.getRangeAt(0).getClientRects();
|
|
346
|
+
if (w.length === 0)
|
|
347
|
+
return null;
|
|
348
|
+
const k = w[0];
|
|
349
|
+
let a = {
|
|
350
|
+
top: k.top,
|
|
351
|
+
left: k.left,
|
|
352
|
+
bottom: k.bottom,
|
|
353
|
+
right: k.right
|
|
354
|
+
};
|
|
355
|
+
for (let z = 1; z < w.length; z++) {
|
|
356
|
+
const v = w[z];
|
|
357
|
+
v.width === 0 || v.height === 0 || (a.top = Math.min(a.top, v.top), a.left = Math.min(a.left, v.left), a.bottom = Math.max(a.bottom, v.bottom), a.right = Math.max(a.right, v.right));
|
|
358
|
+
}
|
|
359
|
+
const C = c.getBoundingClientRect();
|
|
360
|
+
return p.value.getBoundingClientRect(), a.top = (a.top - C.top) / (r.value / 100) + c.scrollTop, a.left = (a.left - C.left) / (r.value / 100) + c.scrollLeft, a.bottom = (a.bottom - C.top) / (r.value / 100) + c.scrollTop, a.right = (a.right - C.left) / (r.value / 100) + c.scrollLeft, a;
|
|
361
|
+
}
|
|
362
|
+
const m = (c) => {
|
|
363
|
+
const { target: f } = c;
|
|
364
|
+
f.tagName !== "SPAN" && s("bypass-selection", c);
|
|
365
|
+
}, x = (c) => {
|
|
366
|
+
if (window.getSelection().toString().length > 0) {
|
|
367
|
+
const P = S(p.value), w = se({
|
|
368
|
+
selectionBounds: P,
|
|
369
|
+
documentId: i
|
|
370
|
+
});
|
|
371
|
+
s("selection-change", w);
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
return E(async () => {
|
|
375
|
+
await b(l);
|
|
376
|
+
}), W(() => {
|
|
377
|
+
u.destroy();
|
|
378
|
+
}), (c, f) => (R(), B("div", {
|
|
379
|
+
class: "superdoc-pdf-viewer-container",
|
|
380
|
+
onMousedown: m,
|
|
381
|
+
onMouseup: x
|
|
382
|
+
}, [
|
|
383
|
+
A("div", {
|
|
384
|
+
class: "superdoc-pdf-viewer",
|
|
385
|
+
ref_key: "viewer",
|
|
386
|
+
ref: p,
|
|
387
|
+
id: "viewerId"
|
|
388
|
+
}, null, 512),
|
|
389
|
+
d.value ? F("", !0) : (R(), B("div", we, [
|
|
390
|
+
I(H(de), {
|
|
391
|
+
class: "superdoc-pdf-viewer__spin",
|
|
392
|
+
size: "large"
|
|
393
|
+
})
|
|
394
|
+
]))
|
|
395
|
+
], 32));
|
|
396
|
+
}
|
|
397
|
+
}, be = /* @__PURE__ */ N(ve, [["__scopeId", "data-v-84719682"]]);
|
|
398
|
+
export {
|
|
399
|
+
be as default
|
|
400
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("react");var X={exports:{}},Y={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var ee;function ce(){if(ee)return Y;ee=1;var p=Symbol.for("react.transitional.element"),v=Symbol.for("react.fragment");function m(o,a,d){var h=null;if(d!==void 0&&(h=""+d),a.key!==void 0&&(h=""+a.key),"key"in a){d={};for(var _ in a)_!=="key"&&(d[_]=a[_])}else d=a;return a=d.ref,{$$typeof:p,type:o,key:h,ref:a!==void 0?a:null,props:d}}return Y.Fragment=v,Y.jsx=m,Y.jsxs=m,Y}var $={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var te;function ue(){return te||(te=1,process.env.NODE_ENV!=="production"&&(function(){function p(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Q?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case y:return"Fragment";case b:return"Profiler";case U:return"StrictMode";case T:return"Suspense";case B:return"SuspenseList";case J:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case Z:return"Portal";case k:return e.displayName||"Context";case V:return(e._context.displayName||"Context")+".Consumer";case z:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case F:return n=e.displayName||null,n!==null?n:p(e.type)||"Memo";case O:n=e._payload,e=e._init;try{return p(e(n))}catch{}}return null}function v(e){return""+e}function m(e){try{v(e);var n=!1}catch{n=!0}if(n){n=console;var i=n.error,u=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",u),v(e)}}function o(e){if(e===y)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===O)return"<...>";try{var n=p(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function a(){var e=w.A;return e===null?null:e.getOwner()}function d(){return Error("react-stack-top-frame")}function h(e){if(S.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function _(e,n){function i(){j||(j=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",n))}i.isReactWarning=!0,Object.defineProperty(e,"key",{get:i,configurable:!0})}function q(){var e=p(this.type);return H[e]||(H[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function L(e,n,i,u,N,M){var t=i.ref;return e={$$typeof:W,type:e,key:n,props:i,_owner:u},(t!==void 0?t:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:q}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:N}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function P(e,n,i,u,N,M){var t=n.children;if(t!==void 0)if(u)if(K(t)){for(u=0;u<t.length;u++)D(t[u]);Object.freeze&&Object.freeze(t)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else D(t);if(S.call(n,"key")){t=p(e);var r=Object.keys(n).filter(function(f){return f!=="key"});u=0<r.length?"{key: someKey, "+r.join(": ..., ")+": ...}":"{key: someKey}",G[t+u]||(r=0<r.length?"{"+r.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,
|
|
22
|
+
<%s key={someKey} {...props} />`,u,t,r,t),G[t+u]=!0)}if(t=null,i!==void 0&&(m(i),t=""+i),h(n)&&(m(n.key),t=""+n.key),"key"in n){i={};for(var s in n)s!=="key"&&(i[s]=n[s])}else i=n;return t&&_(i,typeof e=="function"?e.displayName||e.name||"Unknown":e),L(e,t,i,a(),N,M)}function D(e){E(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===O&&(e._payload.status==="fulfilled"?E(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function E(e){return typeof e=="object"&&e!==null&&e.$$typeof===W}var A=c,W=Symbol.for("react.transitional.element"),Z=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),U=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),V=Symbol.for("react.consumer"),k=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),Q=Symbol.for("react.client.reference"),w=A.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,S=Object.prototype.hasOwnProperty,K=Array.isArray,x=console.createTask?console.createTask:function(){return null};A={react_stack_bottom_frame:function(e){return e()}};var j,H={},I=A.react_stack_bottom_frame.bind(A,d)(),C=x(o(d)),G={};$.Fragment=y,$.jsx=function(e,n,i){var u=1e4>w.recentlyCreatedOwnerStacks++;return P(e,n,i,!1,u?Error("react-stack-top-frame"):I,u?x(o(e)):C)},$.jsxs=function(e,n,i){var u=1e4>w.recentlyCreatedOwnerStacks++;return P(e,n,i,!0,u?Error("react-stack-top-frame"):I,u?x(o(e)):C)}})()),$}var re;function de(){return re||(re=1,process.env.NODE_ENV==="production"?X.exports=ce():X.exports=ue()),X.exports}var g=de();const ne=({value:p,onChange:v,isDisabled:m,label:o})=>g.jsxs("div",{className:"superdoc-esign-signature-input",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[o&&g.jsx("label",{children:o}),g.jsx("input",{type:"text",value:String(p||""),onChange:a=>v(a.target.value),disabled:m,placeholder:"Type your full name",style:{fontFamily:"cursive",fontSize:"18px"}})]}),ae=({value:p,onChange:v,isDisabled:m,label:o})=>g.jsxs("label",{className:"superdoc-esign-checkbox-input",style:{display:"flex",gap:"8px"},children:[g.jsx("input",{type:"checkbox",checked:!!p,onChange:a=>v(a.target.checked),disabled:m}),g.jsx("span",{children:o})]}),fe=p=>({onClick:m,fileName:o,isDisabled:a})=>{const d=p?.label||"Download";return g.jsxs("button",{onClick:m,disabled:a,className:"superdoc-esign-btn",style:{padding:"10px 20px",borderRadius:"6px",border:"none",background:"#fff",color:"#333",cursor:a?"not-allowed":"pointer",opacity:a?.5:1,fontSize:"16px",fontWeight:"bold"},children:[d," ",o&&`(${o})`]})},me=p=>({onClick:m,isValid:o,isDisabled:a,isSubmitting:d})=>{const h=()=>p?.label||"Submit";return g.jsx("button",{onClick:m,disabled:!o||a||d,className:"superdoc-esign-btn",style:{padding:"12px 24px",borderRadius:"6px",border:"none",background:"#007bff",color:"#fff",cursor:!o||a?"not-allowed":"pointer",opacity:!o||a?.5:1,fontSize:"16px",fontWeight:"bold"},children:h()})},oe=c.forwardRef((p,v)=>{const{eventId:m,document:o,fields:a={},download:d,submit:h,onSubmit:_,onDownload:q,onStateChange:L,onFieldChange:P,onFieldsDiscovered:D,isDisabled:E=!1,className:A,style:W,documentHeight:Z="600px"}=p,[y,U]=c.useState(!o.validation?.scroll?.required),[b,V]=c.useState(new Map),[k,z]=c.useState(!1),[T,B]=c.useState(!1),[F,O]=c.useState([]),[J,Q]=c.useState(!1),w=c.useRef(null),S=c.useRef(null),K=c.useRef(Date.now()),x=c.useRef(a);x.current=a;const j=c.useCallback(t=>{if(!S.current?.activeEditor)return;const r=S.current.activeEditor,s=x.current.signer?.find(l=>l.id===t.id);let f;s?.type==="signature"&&t.value?f={json:{type:"image",attrs:{src:typeof t.value=="string"&&t.value.startsWith("data:image/")?t.value:H(String(t.value)),alt:"Signature"}}}:f={text:String(t.value??"")},t.id&&r.commands.updateStructuredContentById(t.id,f)},[]);function H(t){const r=globalThis.document.createElement("canvas"),s=r.getContext("2d"),f=30;s.font=`italic ${f}px cursive`;const R=s.measureText(t).width,se=f*1.3,le=4,ie=6;return r.width=Math.ceil(R+le*2)+20,r.height=Math.ceil(se+ie*2),s.font=`italic ${f}px cursive`,s.fillStyle="black",s.textAlign="center",s.textBaseline="middle",s.fillText(t,r.width/2,r.height/2),r.toDataURL("image/png")}const I=c.useCallback(t=>{if(!t)return;const r=t.helpers.structuredContentCommands.getStructuredContentTags(t.state),s=new Map;x.current.document?.forEach(l=>{l.id&&s.set(l.id,l.value)}),x.current.signer?.forEach(l=>{l.value!==void 0&&s.set(l.id,l.value)});const f=r.map(({node:l})=>({id:l.attrs.id,label:l.attrs.label,value:s.get(l.attrs.id)??l.textContent??""})).filter(l=>l.id);f.length>0&&(D?.(f),[...x.current.document||[],...x.current.signer||[]].filter(R=>R.value!==void 0).forEach(R=>j({id:R.id,value:R.value})))},[D,j]),C=t=>{const r={...t,timestamp:new Date().toISOString()};O(s=>[...s,r])};c.useEffect(()=>w.current?((async()=>{const{SuperDoc:r}=await Promise.resolve().then(()=>require("./superdoc.es-DfpwGgyj.cjs")).then(f=>f.superdoc_es),s=new r({selector:w.current,document:o.source,documentMode:"viewing",onReady:()=>{s.activeEditor&&I(s.activeEditor),C({type:"ready"}),Q(!0)}});S.current=s})(),()=>{S.current&&(S.current.destroy(),S.current=null)}):void 0,[o.source,o.mode,I]),c.useEffect(()=>{if(!o.validation?.scroll?.required||!J)return;const t=w.current;if(!t)return;const r=()=>{const{scrollTop:s,scrollHeight:f,clientHeight:l}=t,R=s/(f-l);(R>=.95||f<=l)&&(U(!0),C({type:"scroll",data:{percent:Math.round(R*100)}}))};return t.addEventListener("scroll",r),r(),()=>t.removeEventListener("scroll",r)},[o.validation?.scroll?.required,J]);const G=c.useCallback((t,r)=>{V(s=>{const f=s.get(t),l=new Map(s);return l.set(t,r),j({id:t,value:r}),C({type:"field_change",data:{fieldId:t,value:r,previousValue:f}}),P?.({id:t,value:r,previousValue:f}),l})},[P,j]),e=c.useCallback(()=>o.validation?.scroll?.required&&!y?!1:(a.signer||[]).every(t=>{if(!t.validation?.required)return!0;const r=b.get(t.id);return r&&(typeof r!="string"||r.trim())}),[y,a.signer,b,o.validation?.scroll?.required]);c.useEffect(()=>{const t=e();z(t),L?.({scrolled:y,fields:b,isValid:t,isSubmitting:T})},[y,b,T,e,L]);const n=c.useCallback(async()=>{if(E)return;const t={eventId:m,documentSource:o.source,fields:{document:a.document||[],signer:(a.signer||[]).map(r=>({id:r.id,value:b.get(r.id)??null}))},fileName:d?.fileName||"document.pdf"};await q?.(t)},[E,m,o.source,a,b,d,q]),i=c.useCallback(async()=>{if(!k||E||T)return;B(!0),C({type:"submit"});const t={eventId:m,timestamp:new Date().toISOString(),duration:Math.floor((Date.now()-K.current)/1e3),auditTrail:F,documentFields:a.document||[],signerFields:(a.signer||[]).map(r=>({id:r.id,value:b.get(r.id)??null})),isFullyCompleted:k};try{await _(t)}finally{B(!1)}},[k,E,T,m,F,a,b,_]),u=t=>{const r=t.component||N(t.type);return g.jsx(r,{value:b.get(t.id)??null,onChange:s=>G(t.id,s),isDisabled:E,label:t.label},t.id)},N=t=>{switch(t){case"signature":case"text":return ne;case"checkbox":return ae}},M=()=>{const t=d?.component||fe(d),r=h?.component||me(h);return g.jsxs("div",{className:"superdoc-esign-actions",style:{display:"flex",gap:"10px"},children:[o.mode!=="download"&&g.jsx(r,{onClick:i,isValid:k,isDisabled:E,isSubmitting:T}),g.jsx(t,{onClick:n,fileName:d?.fileName,isDisabled:E})]})};return c.useImperativeHandle(v,()=>({getState:()=>({scrolled:y,fields:b,isValid:k,isSubmitting:T}),getAuditTrail:()=>F,reset:()=>{U(!o.validation?.scroll?.required),V(new Map),z(!1),O([])}})),g.jsxs("div",{className:`superdoc-esign-container ${A||""}`,style:W,children:[g.jsx("div",{className:"superdoc-esign-document",children:g.jsx("div",{ref:w,style:{height:Z,overflow:"auto"}})}),g.jsxs("div",{className:"superdoc-esign-controls",style:{marginTop:"20px"},children:[a.signer&&a.signer.length>0&&g.jsx("div",{className:"superdoc-esign-fields",style:{marginBottom:"20px"},children:a.signer.map(u)}),M()]})]})});oe.displayName="SuperDocESign";exports.CheckboxInput=ae;exports.SignatureInput=ne;exports.default=oe;
|