@superdoc-dev/esign 1.2.0-next.2 → 1.2.0-next.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,KAAK,KAAK,MAAM,SAAS,CAAC;AACtC,OAAO,EACL,cAAc,EACd,aAAa,EAGd,MAAM,YAAY,CAAC;AAEpB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;AAIzC,QAAA,MAAM,aAAa,gIAucjB,CAAC;AAIH,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,KAAK,KAAK,MAAM,SAAS,CAAC;AACtC,OAAO,EACL,cAAc,EACd,aAAa,EAGd,MAAM,YAAY,CAAC;AAEpB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;AAIzC,QAAA,MAAM,aAAa,gIAyelB,CAAC;AAIF,eAAe,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react");var Z={exports:{}},$={};/**
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react");var K={exports:{}},U={};/**
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 te;function ue(){if(te)return $;te=1;var g=Symbol.for("react.transitional.element"),b=Symbol.for("react.fragment");function m(s,a,p){var E=null;if(p!==void 0&&(E=""+p),a.key!==void 0&&(E=""+a.key),"key"in a){p={};for(var T in a)T!=="key"&&(p[T]=a[T])}else p=a;return a=p.ref,{$$typeof:g,type:s,key:E,ref:a!==void 0?a:null,props:p}}return $.Fragment=b,$.jsx=m,$.jsxs=m,$}var q={};/**
9
+ */var oe;function pe(){if(oe)return U;oe=1;var v=Symbol.for("react.transitional.element"),b=Symbol.for("react.fragment");function g(a,n,p){var h=null;if(p!==void 0&&(h=""+p),n.key!==void 0&&(h=""+n.key),"key"in n){p={};for(var T in n)T!=="key"&&(p[T]=n[T])}else p=n;return n=p.ref,{$$typeof:v,type:a,key:h,ref:n!==void 0?n:null,props:p}}return U.Fragment=b,U.jsx=g,U.jsxs=g,U}var L={};/**
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 re;function de(){return re||(re=1,process.env.NODE_ENV!=="production"&&(function(){function g(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===K?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case R:return"Fragment";case h:return"Profiler";case V:return"StrictMode";case k:return"Suspense";case J:return"SuspenseList";case G: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 Q:return"Portal";case A:return e.displayName||"Context";case z:return(e._context.displayName||"Context")+".Consumer";case B:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case H:return n=e.displayName||null,n!==null?n:g(e.type)||"Memo";case P:n=e._payload,e=e._init;try{return g(e(n))}catch{}}return null}function b(e){return""+e}function m(e){try{b(e);var n=!1}catch{n=!0}if(n){n=console;var c=n.error,d=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return c.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",d),b(e)}}function s(e){if(e===R)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===P)return"<...>";try{var n=g(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function a(){var e=w.A;return e===null?null:e.getOwner()}function p(){return Error("react-stack-top-frame")}function E(e){if(y.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function T(e,n){function c(){C||(C=!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))}c.isReactWarning=!0,Object.defineProperty(e,"key",{get:c,configurable:!0})}function U(){var e=g(this.type);return O[e]||(O[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,c,d,D,Y){var f=c.ref;return e={$$typeof:W,type:e,key:n,props:c,_owner:d},(f!==void 0?f:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:U}):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:D}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Y}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function F(e,n,c,d,D,Y){var f=n.children;if(f!==void 0)if(d)if(ee(f)){for(d=0;d<f.length;d++)I(f[d]);Object.freeze&&Object.freeze(f)}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 I(f);if(y.call(n,"key")){f=g(e);var t=Object.keys(n).filter(function(o){return o!=="key"});d=0<t.length?"{key: someKey, "+t.join(": ..., ")+": ...}":"{key: someKey}",j[f+d]||(t=0<t.length?"{"+t.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var ae;function me(){return ae||(ae=1,process.env.NODE_ENV!=="production"&&(function(){function v(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===te?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case R:return"Fragment";case x:return"Profiler";case B:return"StrictMode";case w:return"Suspense";case G:return"SuspenseList";case Z: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 ee:return"Portal";case O:return e.displayName||"Context";case J:return(e._context.displayName||"Context")+".Consumer";case H:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case X:return r=e.displayName||null,r!==null?r:v(e.type)||"Memo";case D:r=e._payload,e=e._init;try{return v(e(r))}catch{}}return null}function b(e){return""+e}function g(e){try{b(e);var r=!1}catch{r=!0}if(r){r=console;var c=r.error,d=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return c.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",d),b(e)}}function a(e){if(e===R)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===D)return"<...>";try{var r=v(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function n(){var e=k.A;return e===null?null:e.getOwner()}function p(){return Error("react-stack-top-frame")}function h(e){if(y.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function T(e,r){function c(){C||(C=!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)",r))}c.isReactWarning=!0,Object.defineProperty(e,"key",{get:c,configurable:!0})}function W(){var e=v(this.type);return N[e]||(N[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 V(e,r,c,d,F,q){var f=c.ref;return e={$$typeof:z,type:e,key:r,props:c,_owner:d},(f!==void 0?f:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:W}):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:F}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:q}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function M(e,r,c,d,F,q){var f=r.children;if(f!==void 0)if(d)if(re(f)){for(d=0;d<f.length;d++)Y(f[d]);Object.freeze&&Object.freeze(f)}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 Y(f);if(y.call(r,"key")){f=v(e);var A=Object.keys(r).filter(function(ne){return ne!=="key"});d=0<A.length?"{key: someKey, "+A.join(": ..., ")+": ...}":"{key: someKey}",j[f+d]||(A=0<A.length?"{"+A.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} />`,d,f,t,f),j[f+d]=!0)}if(f=null,c!==void 0&&(m(c),f=""+c),E(n)&&(m(n.key),f=""+n.key),"key"in n){c={};for(var r in n)r!=="key"&&(c[r]=n[r])}else c=n;return f&&T(c,typeof e=="function"?e.displayName||e.name||"Unknown":e),L(e,f,c,a(),D,Y)}function I(e){x(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===P&&(e._payload.status==="fulfilled"?x(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function x(e){return typeof e=="object"&&e!==null&&e.$$typeof===W}var N=l,W=Symbol.for("react.transitional.element"),Q=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),z=Symbol.for("react.consumer"),A=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),J=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),G=Symbol.for("react.activity"),K=Symbol.for("react.client.reference"),w=N.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,y=Object.prototype.hasOwnProperty,ee=Array.isArray,_=console.createTask?console.createTask:function(){return null};N={react_stack_bottom_frame:function(e){return e()}};var C,O={},X=N.react_stack_bottom_frame.bind(N,p)(),M=_(s(p)),j={};q.Fragment=R,q.jsx=function(e,n,c){var d=1e4>w.recentlyCreatedOwnerStacks++;return F(e,n,c,!1,d?Error("react-stack-top-frame"):X,d?_(s(e)):M)},q.jsxs=function(e,n,c){var d=1e4>w.recentlyCreatedOwnerStacks++;return F(e,n,c,!0,d?Error("react-stack-top-frame"):X,d?_(s(e)):M)}})()),q}var ne;function fe(){return ne||(ne=1,process.env.NODE_ENV==="production"?Z.exports=ue():Z.exports=de()),Z.exports}var v=fe();const ae=({value:g,onChange:b,isDisabled:m,label:s})=>v.jsxs("div",{className:"superdoc-esign-signature-input",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[s&&v.jsx("label",{children:s}),v.jsx("input",{type:"text",value:String(g||""),onChange:a=>b(a.target.value),disabled:m,placeholder:"Type your full name",style:{fontFamily:"cursive",fontSize:"18px"}})]}),oe=({value:g,onChange:b,isDisabled:m,label:s})=>v.jsxs("label",{className:"superdoc-esign-checkbox-input",style:{display:"flex",gap:"8px"},children:[v.jsx("input",{type:"checkbox",checked:!!g,onChange:a=>b(a.target.checked),disabled:m}),v.jsx("span",{children:s})]}),pe=g=>({onClick:m,fileName:s,isDisabled:a})=>{const p=g?.label||"Download";return v.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:[p," ",s&&`(${s})`]})},me=g=>({onClick:m,isValid:s,isDisabled:a,isSubmitting:p})=>{const E=()=>g?.label||"Submit";return v.jsx("button",{onClick:m,disabled:!s||a||p,className:"superdoc-esign-btn",style:{padding:"12px 24px",borderRadius:"6px",border:"none",background:"#007bff",color:"#fff",cursor:!s||a?"not-allowed":"pointer",opacity:!s||a?.5:1,fontSize:"16px",fontWeight:"bold"},children:E()})},se=l.forwardRef((g,b)=>{const{eventId:m,document:s,fields:a={},download:p,submit:E,onSubmit:T,onDownload:U,onStateChange:L,onFieldChange:F,onFieldsDiscovered:I,isDisabled:x=!1,className:N,style:W,documentHeight:Q="600px"}=g,[R,V]=l.useState(!s.validation?.scroll?.required),[h,z]=l.useState(new Map),[A,B]=l.useState(!1),[k,J]=l.useState(!1),[H,P]=l.useState([]),[G,K]=l.useState(!1),w=l.useRef(null),y=l.useRef(null),ee=l.useRef(Date.now()),_=l.useRef(a),C=l.useRef([]);_.current=a,l.useEffect(()=>{C.current=H},[H]);const O=l.useCallback(t=>{if(!y.current?.activeEditor)return;const r=y.current.activeEditor,o=_.current.signer?.find(i=>i.id===t.id);let u;o?.type==="signature"&&t.value?u={json:{type:"image",attrs:{src:typeof t.value=="string"&&t.value.startsWith("data:image/")?t.value:X(String(t.value)),alt:"Signature"}}}:u={text:String(t.value??"")},t.id&&r.commands.updateStructuredContentById(t.id,u)},[]);function X(t){const r=globalThis.document.createElement("canvas"),o=r.getContext("2d"),u=30;o.font=`italic ${u}px cursive`;const S=o.measureText(t).width,ie=u*1.3,ce=4,le=6;return r.width=Math.ceil(S+ce*2)+20,r.height=Math.ceil(ie+le*2),o.font=`italic ${u}px cursive`,o.fillStyle="black",o.textAlign="center",o.textBaseline="middle",o.fillText(t,r.width/2,r.height/2),r.toDataURL("image/png")}const M=l.useCallback(t=>{if(!t)return;const r=t.helpers.structuredContentCommands.getStructuredContentTags(t.state),o=new Map;_.current.document?.forEach(i=>{i.id&&o.set(i.id,i.value)}),_.current.signer?.forEach(i=>{i.value!==void 0&&o.set(i.id,i.value)});const u=r.map(({node:i})=>({id:i.attrs.id,label:i.attrs.label,value:o.get(i.attrs.id)??i.textContent??""})).filter(i=>i.id);u.length>0&&(I?.(u),[..._.current.document||[],..._.current.signer||[]].filter(S=>S.value!==void 0).forEach(S=>O({id:S.id,value:S.value})))},[I,O]),j=t=>{const r={...t,timestamp:new Date().toISOString()},o=globalThis?.__SUPERDOC_AUDIT_MOCK__;o&&o(r);const u=[...C.current,r];return C.current=u,P(u),u};l.useEffect(()=>w.current?((async()=>{const{SuperDoc:r}=await Promise.resolve().then(()=>require("./superdoc.es-DfpwGgyj.cjs")).then(u=>u.superdoc_es),o=new r({selector:w.current,document:s.source,documentMode:"viewing",onReady:()=>{o.activeEditor&&M(o.activeEditor),j({type:"ready"}),K(!0)}});y.current=o})(),()=>{y.current&&(typeof y.current.destroy=="function"&&y.current.destroy(),y.current=null)}):void 0,[s.source,s.mode,M]),l.useEffect(()=>{if(!s.validation?.scroll?.required||!G)return;const t=w.current;if(!t)return;const r=()=>{const{scrollTop:o,scrollHeight:u,clientHeight:i}=t,S=o/(u-i);(S>=.95||u<=i)&&(V(!0),j({type:"scroll",data:{percent:Math.round(S*100)}}))};return t.addEventListener("scroll",r),r(),()=>t.removeEventListener("scroll",r)},[s.validation?.scroll?.required,G]);const e=l.useCallback((t,r)=>{z(o=>{const u=o.get(t),i=new Map(o);return i.set(t,r),O({id:t,value:r}),j({type:"field_change",data:{fieldId:t,value:r,previousValue:u}}),F?.({id:t,value:r,previousValue:u}),i})},[F,O]),n=l.useCallback(()=>s.validation?.scroll?.required&&!R?!1:(a.signer||[]).every(t=>{if(!t.validation?.required)return!0;const r=h.get(t.id);return r&&(typeof r!="string"||r.trim())}),[R,a.signer,h,s.validation?.scroll?.required]);l.useEffect(()=>{const t=n();B(t),L?.({scrolled:R,fields:h,isValid:t,isSubmitting:k})},[R,h,k,n,L]);const c=l.useCallback(async()=>{if(x)return;const t={eventId:m,documentSource:s.source,fields:{document:a.document||[],signer:(a.signer||[]).map(r=>({id:r.id,value:h.get(r.id)??null}))},fileName:p?.fileName||"document.pdf"};await U?.(t)},[x,m,s.source,a,h,p,U]),d=l.useCallback(async()=>{if(!A||x||k)return;J(!0),j({type:"submit"});const t=j({type:"submit"}),r={eventId:m,timestamp:new Date().toISOString(),duration:Math.floor((Date.now()-ee.current)/1e3),auditTrail:t,documentFields:a.document||[],signerFields:(a.signer||[]).map(o=>({id:o.id,value:h.get(o.id)??null})),isFullyCompleted:A};try{await T(r)}finally{J(!1)}},[A,x,k,m,a,h,T]),D=t=>{const r=t.component||Y(t.type);return v.jsx(r,{value:h.get(t.id)??null,onChange:o=>e(t.id,o),isDisabled:x,label:t.label},t.id)},Y=t=>{switch(t){case"signature":case"text":return ae;case"checkbox":return oe}},f=()=>{const t=p?.component||pe(p),r=E?.component||me(E);return v.jsxs("div",{className:"superdoc-esign-actions",style:{display:"flex",gap:"10px"},children:[s.mode!=="download"&&v.jsx(r,{onClick:d,isValid:A,isDisabled:x,isSubmitting:k}),v.jsx(t,{onClick:c,fileName:p?.fileName,isDisabled:x})]})};return l.useImperativeHandle(b,()=>({getState:()=>({scrolled:R,fields:h,isValid:A,isSubmitting:k}),getAuditTrail:()=>C.current,reset:()=>{V(!s.validation?.scroll?.required),z(new Map),B(!1),C.current=[],P([])}})),v.jsxs("div",{className:`superdoc-esign-container ${N||""}`,style:W,children:[v.jsx("div",{className:"superdoc-esign-document","data-testid":"superdoc-esign-document",children:v.jsx("div",{ref:w,"data-testid":"superdoc-scroll-container",style:{height:Q,overflow:"auto"}})}),v.jsxs("div",{className:"superdoc-esign-controls",style:{marginTop:"20px"},"data-testid":"superdoc-esign-controls",children:[a.signer&&a.signer.length>0&&v.jsx("div",{className:"superdoc-esign-fields",style:{marginBottom:"20px"},"data-testid":"superdoc-esign-fields",children:a.signer.map(D)}),f()]})]})});se.displayName="SuperDocESign";exports.CheckboxInput=oe;exports.SignatureInput=ae;exports.default=se;
22
+ <%s key={someKey} {...props} />`,d,f,A,f),j[f+d]=!0)}if(f=null,c!==void 0&&(g(c),f=""+c),h(r)&&(g(r.key),f=""+r.key),"key"in r){c={};for(var I in r)I!=="key"&&(c[I]=r[I])}else c=r;return f&&T(c,typeof e=="function"?e.displayName||e.name||"Unknown":e),V(e,f,c,n(),F,q)}function Y(e){E(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===D&&(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===z}var P=l,z=Symbol.for("react.transitional.element"),ee=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),J=Symbol.for("react.consumer"),O=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),G=Symbol.for("react.suspense_list"),X=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),Z=Symbol.for("react.activity"),te=Symbol.for("react.client.reference"),k=P.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,y=Object.prototype.hasOwnProperty,re=Array.isArray,_=console.createTask?console.createTask:function(){return null};P={react_stack_bottom_frame:function(e){return e()}};var C,N={},Q=P.react_stack_bottom_frame.bind(P,p)(),$=_(a(p)),j={};L.Fragment=R,L.jsx=function(e,r,c){var d=1e4>k.recentlyCreatedOwnerStacks++;return M(e,r,c,!1,d?Error("react-stack-top-frame"):Q,d?_(a(e)):$)},L.jsxs=function(e,r,c){var d=1e4>k.recentlyCreatedOwnerStacks++;return M(e,r,c,!0,d?Error("react-stack-top-frame"):Q,d?_(a(e)):$)}})()),L}var se;function ge(){return se||(se=1,process.env.NODE_ENV==="production"?K.exports=pe():K.exports=me()),K.exports}var m=ge();const ie=({value:v,onChange:b,isDisabled:g,label:a})=>m.jsxs("div",{className:"superdoc-esign-signature-input",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[a&&m.jsx("label",{children:a}),m.jsx("input",{type:"text",value:String(v||""),onChange:n=>b(n.target.value),disabled:g,placeholder:"Type your full name",style:{fontFamily:"cursive",fontSize:"18px"}})]}),ce=({value:v,onChange:b,isDisabled:g,label:a})=>m.jsxs("label",{className:"superdoc-esign-checkbox-input",style:{display:"flex",gap:"8px"},children:[m.jsx("input",{type:"checkbox",checked:!!v,onChange:n=>b(n.target.checked),disabled:g}),m.jsx("span",{children:a})]}),ve=v=>({onClick:g,fileName:a,isDisabled:n})=>{const p=v?.label||"Download";return m.jsxs("button",{onClick:g,disabled:n,className:"superdoc-esign-btn superdoc-esign-btn--download",style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid #d0d5dd",background:"#ffffff",color:"#333",cursor:n?"not-allowed":"pointer",opacity:n?.5:1,fontSize:"16px",fontWeight:"bold"},children:[p," ",a&&`(${a})`]})},be=v=>({onClick:g,isValid:a,isDisabled:n,isSubmitting:p})=>{const h=()=>v?.label||"Submit";return m.jsx("button",{onClick:g,disabled:!a||n||p,className:"superdoc-esign-btn superdoc-esign-btn--submit",style:{padding:"12px 24px",borderRadius:"6px",border:"none",background:"#007bff",color:"#fff",cursor:!a||n?"not-allowed":"pointer",opacity:!a||n?.5:1,fontSize:"16px",fontWeight:"bold"},children:h()})},le=l.forwardRef((v,b)=>{const{eventId:g,document:a,fields:n={},download:p,submit:h,onSubmit:T,onDownload:W,onStateChange:V,onFieldChange:M,onFieldsDiscovered:Y,isDisabled:E=!1,className:P,style:z,documentHeight:ee="600px"}=v,[R,B]=l.useState(!a.validation?.scroll?.required),[x,J]=l.useState(new Map),[O,H]=l.useState(!1),[w,G]=l.useState(!1),[X,D]=l.useState([]),[Z,te]=l.useState(!1),k=l.useRef(null),y=l.useRef(null),re=l.useRef(Date.now()),_=l.useRef(n),C=l.useRef([]);_.current=n,l.useEffect(()=>{C.current=X},[X]);const N=l.useCallback(t=>{if(!y.current?.activeEditor)return;const o=y.current.activeEditor,s=_.current.signer?.find(i=>i.id===t.id);let u;s?.type==="signature"&&t.value?u={json:{type:"image",attrs:{src:typeof t.value=="string"&&t.value.startsWith("data:image/")?t.value:Q(String(t.value)),alt:"Signature"}}}:u={text:String(t.value??"")},t.id&&o.commands.updateStructuredContentById(t.id,u)},[]);function Q(t){const o=globalThis.document.createElement("canvas"),s=o.getContext("2d"),u=30;s.font=`italic ${u}px cursive`;const S=s.measureText(t).width,ue=u*1.3,de=4,fe=6;return o.width=Math.ceil(S+de*2)+20,o.height=Math.ceil(ue+fe*2),s.font=`italic ${u}px cursive`,s.fillStyle="black",s.textAlign="center",s.textBaseline="middle",s.fillText(t,o.width/2,o.height/2),o.toDataURL("image/png")}const $=l.useCallback(t=>{if(!t)return;const o=t.helpers.structuredContentCommands.getStructuredContentTags(t.state),s=new Map;_.current.document?.forEach(i=>{i.id&&s.set(i.id,i.value)}),_.current.signer?.forEach(i=>{i.value!==void 0&&s.set(i.id,i.value)});const u=o.map(({node:i})=>({id:i.attrs.id,label:i.attrs.label,value:s.get(i.attrs.id)??i.textContent??""})).filter(i=>i.id);u.length>0&&(Y?.(u),[..._.current.document||[],..._.current.signer||[]].filter(S=>S.value!==void 0).forEach(S=>N({id:S.id,value:S.value})))},[Y,N]),j=t=>{const o={...t,timestamp:new Date().toISOString()},s=globalThis?.__SUPERDOC_AUDIT_MOCK__;s&&s(o);const u=[...C.current,o];return C.current=u,D(u),u};l.useEffect(()=>k.current?((async()=>{const{SuperDoc:o}=await Promise.resolve().then(()=>require("./superdoc.es-DfpwGgyj.cjs")).then(u=>u.superdoc_es),s=new o({selector:k.current,document:a.source,documentMode:"viewing",onReady:()=>{s.activeEditor&&$(s.activeEditor),j({type:"ready"}),te(!0)}});y.current=s})(),()=>{y.current&&(typeof y.current.destroy=="function"&&y.current.destroy(),y.current=null)}):void 0,[a.source,a.mode,$]),l.useEffect(()=>{if(!a.validation?.scroll?.required||!Z)return;const t=k.current;if(!t)return;const o=()=>{const{scrollTop:s,scrollHeight:u,clientHeight:i}=t,S=s/(u-i);(S>=.95||u<=i)&&(B(!0),j({type:"scroll",data:{percent:Math.round(S*100)}}))};return t.addEventListener("scroll",o),o(),()=>t.removeEventListener("scroll",o)},[a.validation?.scroll?.required,Z]);const e=l.useCallback((t,o)=>{J(s=>{const u=s.get(t),i=new Map(s);return i.set(t,o),N({id:t,value:o}),j({type:"field_change",data:{fieldId:t,value:o,previousValue:u}}),M?.({id:t,value:o,previousValue:u}),i})},[M,N]),r=l.useCallback(()=>a.validation?.scroll?.required&&!R?!1:(n.signer||[]).every(t=>{if(!t.validation?.required)return!0;const o=x.get(t.id);return o&&(typeof o!="string"||o.trim())}),[R,n.signer,x,a.validation?.scroll?.required]);l.useEffect(()=>{const t=r();H(t),V?.({scrolled:R,fields:x,isValid:t,isSubmitting:w})},[R,x,w,r,V]);const c=l.useCallback(async()=>{if(E)return;const t={eventId:g,documentSource:a.source,fields:{document:n.document||[],signer:(n.signer||[]).map(o=>({id:o.id,value:x.get(o.id)??null}))},fileName:p?.fileName||"document.pdf"};await W?.(t)},[E,g,a.source,n,x,p,W]),d=l.useCallback(async()=>{if(!O||E||w)return;G(!0),j({type:"submit"});const t=j({type:"submit"}),o={eventId:g,timestamp:new Date().toISOString(),duration:Math.floor((Date.now()-re.current)/1e3),auditTrail:t,documentFields:n.document||[],signerFields:(n.signer||[]).map(s=>({id:s.id,value:x.get(s.id)??null})),isFullyCompleted:O};try{await T(o)}finally{G(!1)}},[O,E,w,g,n,x,T]),F=t=>{const o=t.component||q(t.type);return m.jsx(o,{value:x.get(t.id)??null,onChange:s=>e(t.id,s),isDisabled:E,label:t.label},t.id)},q=t=>{switch(t){case"signature":case"text":return ie;case"checkbox":return ce}},f=()=>{const t=p?.component||ve(p);return t?m.jsx(t,{onClick:c,fileName:p?.fileName,isDisabled:E}):null},A=()=>{if(a.mode==="download")return null;const t=h?.component||be(h);return m.jsx("div",{className:"superdoc-esign-actions superdoc-esign-form-actions",style:{display:"flex",gap:"10px"},children:m.jsx(t,{onClick:d,isValid:O,isDisabled:E,isSubmitting:w})})},I=f(),ne=A();return l.useImperativeHandle(b,()=>({getState:()=>({scrolled:R,fields:x,isValid:O,isSubmitting:w}),getAuditTrail:()=>C.current,reset:()=>{B(!a.validation?.scroll?.required),J(new Map),H(!1),C.current=[],D([])}})),m.jsxs("div",{className:`superdoc-esign-container ${P||""}`,style:z,children:[m.jsxs("div",{className:"superdoc-esign-document","data-testid":"superdoc-esign-document",style:{display:"flex",flexDirection:"column"},children:[I&&m.jsx("div",{className:"superdoc-esign-document-toolbar",style:{display:"flex",justifyContent:"flex-end",alignItems:"center",padding:"8px 12px"},children:m.jsx("div",{className:"superdoc-esign-document-controls",style:{display:"flex",gap:"8px"},children:I})}),m.jsx("div",{ref:k,className:"superdoc-esign-document-viewer","data-testid":"superdoc-scroll-container",style:{height:ee,overflow:"auto"}})]}),m.jsxs("div",{className:"superdoc-esign-controls",style:{marginTop:"20px"},"data-testid":"superdoc-esign-controls",children:[n.signer&&n.signer.length>0&&m.jsx("div",{className:"superdoc-esign-fields",style:{marginBottom:"20px"},"data-testid":"superdoc-esign-fields",children:n.signer.map(F)}),ne]})]})});le.displayName="SuperDocESign";exports.CheckboxInput=ce;exports.SignatureInput=ie;exports.default=le;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import ue, { forwardRef as de, useState as D, useRef as U, useEffect as K, useCallback as F, useImperativeHandle as fe } from "react";
2
- var ee = { exports: {} }, q = {};
1
+ import pe, { forwardRef as me, useState as I, useRef as L, useEffect as te, useCallback as M, useImperativeHandle as ge } from "react";
2
+ var re = { exports: {} }, W = {};
3
3
  /**
4
4
  * @license React
5
5
  * react-jsx-runtime.production.js
@@ -9,29 +9,29 @@ var ee = { exports: {} }, q = {};
9
9
  * This source code is licensed under the MIT license found in the
10
10
  * LICENSE file in the root directory of this source tree.
11
11
  */
12
- var oe;
13
- function me() {
14
- if (oe) return q;
15
- oe = 1;
16
- var p = Symbol.for("react.transitional.element"), v = Symbol.for("react.fragment");
17
- function m(s, o, f) {
18
- var h = null;
19
- if (f !== void 0 && (h = "" + f), o.key !== void 0 && (h = "" + o.key), "key" in o) {
12
+ var ie;
13
+ function ve() {
14
+ if (ie) return W;
15
+ ie = 1;
16
+ var g = Symbol.for("react.transitional.element"), v = Symbol.for("react.fragment");
17
+ function m(a, n, f) {
18
+ var x = null;
19
+ if (f !== void 0 && (x = "" + f), n.key !== void 0 && (x = "" + n.key), "key" in n) {
20
20
  f = {};
21
- for (var S in o)
22
- S !== "key" && (f[S] = o[S]);
23
- } else f = o;
24
- return o = f.ref, {
25
- $$typeof: p,
26
- type: s,
27
- key: h,
28
- ref: o !== void 0 ? o : null,
21
+ for (var S in n)
22
+ S !== "key" && (f[S] = n[S]);
23
+ } else f = n;
24
+ return n = f.ref, {
25
+ $$typeof: g,
26
+ type: a,
27
+ key: x,
28
+ ref: n !== void 0 ? n : null,
29
29
  props: f
30
30
  };
31
31
  }
32
- return q.Fragment = v, q.jsx = m, q.jsxs = m, q;
32
+ return W.Fragment = v, W.jsx = m, W.jsxs = m, W;
33
33
  }
34
- var L = {};
34
+ var V = {};
35
35
  /**
36
36
  * @license React
37
37
  * react-jsx-runtime.development.js
@@ -41,47 +41,47 @@ var L = {};
41
41
  * This source code is licensed under the MIT license found in the
42
42
  * LICENSE file in the root directory of this source tree.
43
43
  */
44
- var ae;
45
- function pe() {
46
- return ae || (ae = 1, process.env.NODE_ENV !== "production" && (function() {
47
- function p(e) {
44
+ var ce;
45
+ function be() {
46
+ return ce || (ce = 1, process.env.NODE_ENV !== "production" && (function() {
47
+ function g(e) {
48
48
  if (e == null) return null;
49
49
  if (typeof e == "function")
50
- return e.$$typeof === re ? null : e.displayName || e.name || null;
50
+ return e.$$typeof === oe ? null : e.displayName || e.name || null;
51
51
  if (typeof e == "string") return e;
52
52
  switch (e) {
53
53
  case _:
54
54
  return "Fragment";
55
55
  case b:
56
56
  return "Profiler";
57
- case B:
57
+ case H:
58
58
  return "StrictMode";
59
59
  case T:
60
60
  return "Suspense";
61
- case G:
62
- return "SuspenseList";
63
61
  case Z:
62
+ return "SuspenseList";
63
+ case K:
64
64
  return "Activity";
65
65
  }
66
66
  if (typeof e == "object")
67
67
  switch (typeof e.tag == "number" && console.error(
68
68
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
69
69
  ), e.$$typeof) {
70
- case te:
70
+ case ne:
71
71
  return "Portal";
72
72
  case A:
73
73
  return e.displayName || "Context";
74
- case J:
74
+ case G:
75
75
  return (e._context.displayName || "Context") + ".Consumer";
76
- case H:
77
- var n = e.render;
78
- return e = e.displayName, e || (e = n.displayName || n.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
79
76
  case X:
80
- return n = e.displayName || null, n !== null ? n : p(e.type) || "Memo";
81
- case N:
82
- n = e._payload, e = e._init;
77
+ var r = e.render;
78
+ return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
79
+ case Q:
80
+ return r = e.displayName || null, r !== null ? r : g(e.type) || "Memo";
81
+ case P:
82
+ r = e._payload, e = e._init;
83
83
  try {
84
- return p(e(n));
84
+ return g(e(r));
85
85
  } catch {
86
86
  }
87
87
  }
@@ -93,50 +93,50 @@ function pe() {
93
93
  function m(e) {
94
94
  try {
95
95
  v(e);
96
- var n = !1;
96
+ var r = !1;
97
97
  } catch {
98
- n = !0;
98
+ r = !0;
99
99
  }
100
- if (n) {
101
- n = console;
102
- var c = n.error, u = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
100
+ if (r) {
101
+ r = console;
102
+ var c = r.error, u = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
103
103
  return c.call(
104
- n,
104
+ r,
105
105
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
106
106
  u
107
107
  ), v(e);
108
108
  }
109
109
  }
110
- function s(e) {
110
+ function a(e) {
111
111
  if (e === _) return "<>";
112
- if (typeof e == "object" && e !== null && e.$$typeof === N)
112
+ if (typeof e == "object" && e !== null && e.$$typeof === P)
113
113
  return "<...>";
114
114
  try {
115
- var n = p(e);
116
- return n ? "<" + n + ">" : "<...>";
115
+ var r = g(e);
116
+ return r ? "<" + r + ">" : "<...>";
117
117
  } catch {
118
118
  return "<...>";
119
119
  }
120
120
  }
121
- function o() {
121
+ function n() {
122
122
  var e = w.A;
123
123
  return e === null ? null : e.getOwner();
124
124
  }
125
125
  function f() {
126
126
  return Error("react-stack-top-frame");
127
127
  }
128
- function h(e) {
129
- if (x.call(e, "key")) {
130
- var n = Object.getOwnPropertyDescriptor(e, "key").get;
131
- if (n && n.isReactWarning) return !1;
128
+ function x(e) {
129
+ if (y.call(e, "key")) {
130
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
131
+ if (r && r.isReactWarning) return !1;
132
132
  }
133
133
  return e.key !== void 0;
134
134
  }
135
- function S(e, n) {
135
+ function S(e, r) {
136
136
  function c() {
137
137
  k || (k = !0, console.error(
138
138
  "%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)",
139
- n
139
+ r
140
140
  ));
141
141
  }
142
142
  c.isReactWarning = !0, Object.defineProperty(e, "key", {
@@ -144,23 +144,23 @@ function pe() {
144
144
  configurable: !0
145
145
  });
146
146
  }
147
- function W() {
148
- var e = p(this.type);
149
- return C[e] || (C[e] = !0, console.error(
147
+ function z() {
148
+ var e = g(this.type);
149
+ return N[e] || (N[e] = !0, console.error(
150
150
  "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."
151
151
  )), e = this.props.ref, e !== void 0 ? e : null;
152
152
  }
153
- function V(e, n, c, u, P, $) {
153
+ function B(e, r, c, u, D, q) {
154
154
  var d = c.ref;
155
155
  return e = {
156
- $$typeof: z,
156
+ $$typeof: J,
157
157
  type: e,
158
- key: n,
158
+ key: r,
159
159
  props: c,
160
160
  _owner: u
161
161
  }, (d !== void 0 ? d : null) !== null ? Object.defineProperty(e, "ref", {
162
162
  enumerable: !1,
163
- get: W
163
+ get: z
164
164
  }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
165
165
  configurable: !1,
166
166
  enumerable: !1,
@@ -175,33 +175,33 @@ function pe() {
175
175
  configurable: !1,
176
176
  enumerable: !1,
177
177
  writable: !0,
178
- value: P
178
+ value: D
179
179
  }), Object.defineProperty(e, "_debugTask", {
180
180
  configurable: !1,
181
181
  enumerable: !1,
182
182
  writable: !0,
183
- value: $
183
+ value: q
184
184
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
185
185
  }
186
- function I(e, n, c, u, P, $) {
187
- var d = n.children;
186
+ function Y(e, r, c, u, D, q) {
187
+ var d = r.children;
188
188
  if (d !== void 0)
189
189
  if (u)
190
- if (ne(d)) {
190
+ if (ae(d)) {
191
191
  for (u = 0; u < d.length; u++)
192
- M(d[u]);
192
+ $(d[u]);
193
193
  Object.freeze && Object.freeze(d);
194
194
  } else
195
195
  console.error(
196
196
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
197
197
  );
198
- else M(d);
199
- if (x.call(n, "key")) {
200
- d = p(e);
201
- var t = Object.keys(n).filter(function(a) {
202
- return a !== "key";
198
+ else $(d);
199
+ if (y.call(r, "key")) {
200
+ d = g(e);
201
+ var C = Object.keys(r).filter(function(se) {
202
+ return se !== "key";
203
203
  });
204
- u = 0 < t.length ? "{key: someKey, " + t.join(": ..., ") + ": ...}" : "{key: someKey}", j[d + u] || (t = 0 < t.length ? "{" + t.join(": ..., ") + ": ...}" : "{}", console.error(
204
+ u = 0 < C.length ? "{key: someKey, " + C.join(": ..., ") + ": ...}" : "{key: someKey}", j[d + u] || (C = 0 < C.length ? "{" + C.join(": ..., ") + ": ...}" : "{}", console.error(
205
205
  `A props object containing a "key" prop is being spread into JSX:
206
206
  let props = %s;
207
207
  <%s {...props} />
@@ -210,34 +210,34 @@ React keys must be passed directly to JSX without using spread:
210
210
  <%s key={someKey} {...props} />`,
211
211
  u,
212
212
  d,
213
- t,
213
+ C,
214
214
  d
215
215
  ), j[d + u] = !0);
216
216
  }
217
- if (d = null, c !== void 0 && (m(c), d = "" + c), h(n) && (m(n.key), d = "" + n.key), "key" in n) {
217
+ if (d = null, c !== void 0 && (m(c), d = "" + c), x(r) && (m(r.key), d = "" + r.key), "key" in r) {
218
218
  c = {};
219
- for (var r in n)
220
- r !== "key" && (c[r] = n[r]);
221
- } else c = n;
219
+ for (var F in r)
220
+ F !== "key" && (c[F] = r[F]);
221
+ } else c = r;
222
222
  return d && S(
223
223
  c,
224
224
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
225
- ), V(
225
+ ), B(
226
226
  e,
227
227
  d,
228
228
  c,
229
- o(),
230
- P,
231
- $
229
+ n(),
230
+ D,
231
+ q
232
232
  );
233
233
  }
234
- function M(e) {
235
- E(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === N && (e._payload.status === "fulfilled" ? E(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
234
+ function $(e) {
235
+ h(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === P && (e._payload.status === "fulfilled" ? h(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
236
236
  }
237
- function E(e) {
238
- return typeof e == "object" && e !== null && e.$$typeof === z;
237
+ function h(e) {
238
+ return typeof e == "object" && e !== null && e.$$typeof === J;
239
239
  }
240
- var O = ue, z = Symbol.for("react.transitional.element"), te = Symbol.for("react.portal"), _ = Symbol.for("react.fragment"), B = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), J = Symbol.for("react.consumer"), A = Symbol.for("react.context"), H = Symbol.for("react.forward_ref"), T = Symbol.for("react.suspense"), G = Symbol.for("react.suspense_list"), X = Symbol.for("react.memo"), N = Symbol.for("react.lazy"), Z = Symbol.for("react.activity"), re = Symbol.for("react.client.reference"), w = O.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, x = Object.prototype.hasOwnProperty, ne = Array.isArray, y = console.createTask ? console.createTask : function() {
240
+ var O = pe, J = Symbol.for("react.transitional.element"), ne = Symbol.for("react.portal"), _ = Symbol.for("react.fragment"), H = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), G = Symbol.for("react.consumer"), A = Symbol.for("react.context"), X = Symbol.for("react.forward_ref"), T = Symbol.for("react.suspense"), Z = Symbol.for("react.suspense_list"), Q = Symbol.for("react.memo"), P = Symbol.for("react.lazy"), K = Symbol.for("react.activity"), oe = Symbol.for("react.client.reference"), w = O.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, y = Object.prototype.hasOwnProperty, ae = Array.isArray, E = console.createTask ? console.createTask : function() {
241
241
  return null;
242
242
  };
243
243
  O = {
@@ -245,56 +245,56 @@ React keys must be passed directly to JSX without using spread:
245
245
  return e();
246
246
  }
247
247
  };
248
- var k, C = {}, Q = O.react_stack_bottom_frame.bind(
248
+ var k, N = {}, ee = O.react_stack_bottom_frame.bind(
249
249
  O,
250
250
  f
251
- )(), Y = y(s(f)), j = {};
252
- L.Fragment = _, L.jsx = function(e, n, c) {
251
+ )(), U = E(a(f)), j = {};
252
+ V.Fragment = _, V.jsx = function(e, r, c) {
253
253
  var u = 1e4 > w.recentlyCreatedOwnerStacks++;
254
- return I(
254
+ return Y(
255
255
  e,
256
- n,
256
+ r,
257
257
  c,
258
258
  !1,
259
- u ? Error("react-stack-top-frame") : Q,
260
- u ? y(s(e)) : Y
259
+ u ? Error("react-stack-top-frame") : ee,
260
+ u ? E(a(e)) : U
261
261
  );
262
- }, L.jsxs = function(e, n, c) {
262
+ }, V.jsxs = function(e, r, c) {
263
263
  var u = 1e4 > w.recentlyCreatedOwnerStacks++;
264
- return I(
264
+ return Y(
265
265
  e,
266
- n,
266
+ r,
267
267
  c,
268
268
  !0,
269
- u ? Error("react-stack-top-frame") : Q,
270
- u ? y(s(e)) : Y
269
+ u ? Error("react-stack-top-frame") : ee,
270
+ u ? E(a(e)) : U
271
271
  );
272
272
  };
273
- })()), L;
273
+ })()), V;
274
274
  }
275
- var se;
276
- function ge() {
277
- return se || (se = 1, process.env.NODE_ENV === "production" ? ee.exports = me() : ee.exports = pe()), ee.exports;
275
+ var le;
276
+ function xe() {
277
+ return le || (le = 1, process.env.NODE_ENV === "production" ? re.exports = ve() : re.exports = be()), re.exports;
278
278
  }
279
- var g = ge();
280
- const ve = ({
281
- value: p,
279
+ var p = xe();
280
+ const he = ({
281
+ value: g,
282
282
  onChange: v,
283
283
  isDisabled: m,
284
- label: s
285
- }) => /* @__PURE__ */ g.jsxs(
284
+ label: a
285
+ }) => /* @__PURE__ */ p.jsxs(
286
286
  "div",
287
287
  {
288
288
  className: "superdoc-esign-signature-input",
289
289
  style: { display: "flex", flexDirection: "column", gap: "8px" },
290
290
  children: [
291
- s && /* @__PURE__ */ g.jsx("label", { children: s }),
292
- /* @__PURE__ */ g.jsx(
291
+ a && /* @__PURE__ */ p.jsx("label", { children: a }),
292
+ /* @__PURE__ */ p.jsx(
293
293
  "input",
294
294
  {
295
295
  type: "text",
296
- value: String(p || ""),
297
- onChange: (o) => v(o.target.value),
296
+ value: String(g || ""),
297
+ onChange: (n) => v(n.target.value),
298
298
  disabled: m,
299
299
  placeholder: "Type your full name",
300
300
  style: {
@@ -305,386 +305,414 @@ const ve = ({
305
305
  )
306
306
  ]
307
307
  }
308
- ), be = ({
309
- value: p,
308
+ ), ye = ({
309
+ value: g,
310
310
  onChange: v,
311
311
  isDisabled: m,
312
- label: s
313
- }) => /* @__PURE__ */ g.jsxs(
312
+ label: a
313
+ }) => /* @__PURE__ */ p.jsxs(
314
314
  "label",
315
315
  {
316
316
  className: "superdoc-esign-checkbox-input",
317
317
  style: { display: "flex", gap: "8px" },
318
318
  children: [
319
- /* @__PURE__ */ g.jsx(
319
+ /* @__PURE__ */ p.jsx(
320
320
  "input",
321
321
  {
322
322
  type: "checkbox",
323
- checked: !!p,
324
- onChange: (o) => v(o.target.checked),
323
+ checked: !!g,
324
+ onChange: (n) => v(n.target.checked),
325
325
  disabled: m
326
326
  }
327
327
  ),
328
- /* @__PURE__ */ g.jsx("span", { children: s })
328
+ /* @__PURE__ */ p.jsx("span", { children: a })
329
329
  ]
330
330
  }
331
- ), he = (p) => ({
331
+ ), Ee = (g) => ({
332
332
  onClick: m,
333
- fileName: s,
334
- isDisabled: o
333
+ fileName: a,
334
+ isDisabled: n
335
335
  }) => {
336
- const f = p?.label || "Download";
337
- return /* @__PURE__ */ g.jsxs(
336
+ const f = g?.label || "Download";
337
+ return /* @__PURE__ */ p.jsxs(
338
338
  "button",
339
339
  {
340
340
  onClick: m,
341
- disabled: o,
342
- className: "superdoc-esign-btn",
341
+ disabled: n,
342
+ className: "superdoc-esign-btn superdoc-esign-btn--download",
343
343
  style: {
344
- padding: "10px 20px",
344
+ padding: "8px 16px",
345
345
  borderRadius: "6px",
346
- border: "none",
347
- background: "#fff",
346
+ border: "1px solid #d0d5dd",
347
+ background: "#ffffff",
348
348
  color: "#333",
349
- cursor: o ? "not-allowed" : "pointer",
350
- opacity: o ? 0.5 : 1,
349
+ cursor: n ? "not-allowed" : "pointer",
350
+ opacity: n ? 0.5 : 1,
351
351
  fontSize: "16px",
352
352
  fontWeight: "bold"
353
353
  },
354
354
  children: [
355
355
  f,
356
356
  " ",
357
- s && `(${s})`
357
+ a && `(${a})`
358
358
  ]
359
359
  }
360
360
  );
361
- }, Ee = (p) => ({
361
+ }, _e = (g) => ({
362
362
  onClick: m,
363
- isValid: s,
364
- isDisabled: o,
363
+ isValid: a,
364
+ isDisabled: n,
365
365
  isSubmitting: f
366
366
  }) => {
367
- const h = () => p?.label || "Submit";
368
- return /* @__PURE__ */ g.jsx(
367
+ const x = () => g?.label || "Submit";
368
+ return /* @__PURE__ */ p.jsx(
369
369
  "button",
370
370
  {
371
371
  onClick: m,
372
- disabled: !s || o || f,
373
- className: "superdoc-esign-btn",
372
+ disabled: !a || n || f,
373
+ className: "superdoc-esign-btn superdoc-esign-btn--submit",
374
374
  style: {
375
375
  padding: "12px 24px",
376
376
  borderRadius: "6px",
377
377
  border: "none",
378
378
  background: "#007bff",
379
379
  color: "#fff",
380
- cursor: !s || o ? "not-allowed" : "pointer",
381
- opacity: !s || o ? 0.5 : 1,
380
+ cursor: !a || n ? "not-allowed" : "pointer",
381
+ opacity: !a || n ? 0.5 : 1,
382
382
  fontSize: "16px",
383
383
  fontWeight: "bold"
384
384
  },
385
- children: h()
385
+ children: x()
386
386
  }
387
387
  );
388
- }, xe = de((p, v) => {
389
- const {
390
- eventId: m,
391
- document: s,
392
- fields: o = {},
393
- download: f,
394
- submit: h,
395
- onSubmit: S,
396
- onDownload: W,
397
- onStateChange: V,
398
- onFieldChange: I,
399
- onFieldsDiscovered: M,
400
- isDisabled: E = !1,
401
- className: O,
402
- style: z,
403
- documentHeight: te = "600px"
404
- } = p, [_, B] = D(
405
- !s.validation?.scroll?.required
406
- ), [b, J] = D(
407
- /* @__PURE__ */ new Map()
408
- ), [A, H] = D(!1), [T, G] = D(!1), [X, N] = D([]), [Z, re] = D(!1), w = U(null), x = U(null), ne = U(Date.now()), y = U(o), k = U([]);
409
- y.current = o, K(() => {
410
- k.current = X;
411
- }, [X]);
412
- const C = F((t) => {
413
- if (!x.current?.activeEditor) return;
414
- const r = x.current.activeEditor, a = y.current.signer?.find(
415
- (i) => i.id === t.id
416
- );
417
- let l;
418
- a?.type === "signature" && t.value ? l = {
419
- json: {
420
- type: "image",
421
- attrs: { src: typeof t.value == "string" && t.value.startsWith("data:image/") ? t.value : Q(String(t.value)), alt: "Signature" }
422
- }
423
- } : l = { text: String(t.value ?? "") }, t.id && r.commands.updateStructuredContentById(t.id, l);
424
- }, []);
425
- function Q(t) {
426
- const r = globalThis.document.createElement("canvas"), a = r.getContext("2d"), l = 30;
427
- a.font = `italic ${l}px cursive`;
428
- const R = a.measureText(t).width, ie = l * 1.3, ce = 4, le = 6;
429
- return r.width = Math.ceil(R + ce * 2) + 20, r.height = Math.ceil(ie + le * 2), a.font = `italic ${l}px cursive`, a.fillStyle = "black", a.textAlign = "center", a.textBaseline = "middle", a.fillText(t, r.width / 2, r.height / 2), r.toDataURL("image/png");
430
- }
431
- const Y = F(
432
- (t) => {
433
- if (!t) return;
434
- const r = t.helpers.structuredContentCommands.getStructuredContentTags(
435
- t.state
436
- ), a = /* @__PURE__ */ new Map();
437
- y.current.document?.forEach((i) => {
438
- i.id && a.set(i.id, i.value);
439
- }), y.current.signer?.forEach((i) => {
440
- i.value !== void 0 && a.set(i.id, i.value);
441
- });
442
- const l = r.map(({ node: i }) => ({
443
- id: i.attrs.id,
444
- label: i.attrs.label,
445
- value: a.get(i.attrs.id) ?? i.textContent ?? ""
446
- })).filter((i) => i.id);
447
- l.length > 0 && (M?.(l), [
448
- ...y.current.document || [],
449
- ...y.current.signer || []
450
- ].filter((R) => R.value !== void 0).forEach(
451
- (R) => C({
452
- id: R.id,
453
- value: R.value
454
- })
455
- ));
456
- },
457
- [M, C]
458
- ), j = (t) => {
459
- const r = {
460
- ...t,
461
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
462
- }, a = globalThis?.__SUPERDOC_AUDIT_MOCK__;
463
- a && a(r);
464
- const l = [...k.current, r];
465
- return k.current = l, N(l), l;
466
- };
467
- K(() => w.current ? ((async () => {
468
- const { SuperDoc: r } = await import("./superdoc.es-CqejOF1J.js").then((l) => l.D), a = new r({
469
- selector: w.current,
470
- document: s.source,
471
- documentMode: "viewing",
472
- onReady: () => {
473
- a.activeEditor && Y(a.activeEditor), j({ type: "ready" }), re(!0);
474
- }
475
- });
476
- x.current = a;
477
- })(), () => {
478
- x.current && (typeof x.current.destroy == "function" && x.current.destroy(), x.current = null);
479
- }) : void 0, [s.source, s.mode, Y]), K(() => {
480
- if (!s.validation?.scroll?.required || !Z) return;
481
- const t = w.current;
482
- if (!t) return;
483
- const r = () => {
484
- const { scrollTop: a, scrollHeight: l, clientHeight: i } = t, R = a / (l - i);
485
- (R >= 0.95 || l <= i) && (B(!0), j({
486
- type: "scroll",
487
- data: { percent: Math.round(R * 100) }
488
- }));
489
- };
490
- return t.addEventListener("scroll", r), r(), () => t.removeEventListener("scroll", r);
491
- }, [s.validation?.scroll?.required, Z]);
492
- const e = F(
493
- (t, r) => {
494
- J((a) => {
495
- const l = a.get(t), i = new Map(a);
496
- return i.set(t, r), C({
497
- id: t,
498
- value: r
499
- }), j({
500
- type: "field_change",
501
- data: { fieldId: t, value: r, previousValue: l }
502
- }), I?.({
503
- id: t,
504
- value: r,
505
- previousValue: l
506
- }), i;
507
- });
508
- },
509
- [I, C]
510
- ), n = F(() => s.validation?.scroll?.required && !_ ? !1 : (o.signer || []).every((t) => {
511
- if (!t.validation?.required) return !0;
512
- const r = b.get(t.id);
513
- return r && (typeof r != "string" || r.trim());
514
- }), [
515
- _,
516
- o.signer,
517
- b,
518
- s.validation?.scroll?.required
519
- ]);
520
- K(() => {
521
- const t = n();
522
- H(t), V?.({
523
- scrolled: _,
524
- fields: b,
525
- isValid: t,
526
- isSubmitting: T
527
- });
528
- }, [_, b, T, n, V]);
529
- const c = F(async () => {
530
- if (E) return;
531
- const t = {
388
+ }, Re = me(
389
+ (g, v) => {
390
+ const {
532
391
  eventId: m,
533
- documentSource: s.source,
534
- fields: {
535
- document: o.document || [],
536
- signer: (o.signer || []).map((r) => ({
537
- id: r.id,
538
- value: b.get(r.id) ?? null
539
- }))
392
+ document: a,
393
+ fields: n = {},
394
+ download: f,
395
+ submit: x,
396
+ onSubmit: S,
397
+ onDownload: z,
398
+ onStateChange: B,
399
+ onFieldChange: Y,
400
+ onFieldsDiscovered: $,
401
+ isDisabled: h = !1,
402
+ className: O,
403
+ style: J,
404
+ documentHeight: ne = "600px"
405
+ } = g, [_, H] = I(
406
+ !a.validation?.scroll?.required
407
+ ), [b, G] = I(
408
+ /* @__PURE__ */ new Map()
409
+ ), [A, X] = I(!1), [T, Z] = I(!1), [Q, P] = I([]), [K, oe] = I(!1), w = L(null), y = L(null), ae = L(Date.now()), E = L(n), k = L([]);
410
+ E.current = n, te(() => {
411
+ k.current = Q;
412
+ }, [Q]);
413
+ const N = M((t) => {
414
+ if (!y.current?.activeEditor) return;
415
+ const o = y.current.activeEditor, s = E.current.signer?.find(
416
+ (i) => i.id === t.id
417
+ );
418
+ let l;
419
+ s?.type === "signature" && t.value ? l = {
420
+ json: {
421
+ type: "image",
422
+ attrs: { src: typeof t.value == "string" && t.value.startsWith("data:image/") ? t.value : ee(String(t.value)), alt: "Signature" }
423
+ }
424
+ } : l = { text: String(t.value ?? "") }, t.id && o.commands.updateStructuredContentById(t.id, l);
425
+ }, []);
426
+ function ee(t) {
427
+ const o = globalThis.document.createElement("canvas"), s = o.getContext("2d"), l = 30;
428
+ s.font = `italic ${l}px cursive`;
429
+ const R = s.measureText(t).width, ue = l * 1.3, de = 4, fe = 6;
430
+ return o.width = Math.ceil(R + de * 2) + 20, o.height = Math.ceil(ue + fe * 2), s.font = `italic ${l}px cursive`, s.fillStyle = "black", s.textAlign = "center", s.textBaseline = "middle", s.fillText(t, o.width / 2, o.height / 2), o.toDataURL("image/png");
431
+ }
432
+ const U = M(
433
+ (t) => {
434
+ if (!t) return;
435
+ const o = t.helpers.structuredContentCommands.getStructuredContentTags(
436
+ t.state
437
+ ), s = /* @__PURE__ */ new Map();
438
+ E.current.document?.forEach((i) => {
439
+ i.id && s.set(i.id, i.value);
440
+ }), E.current.signer?.forEach((i) => {
441
+ i.value !== void 0 && s.set(i.id, i.value);
442
+ });
443
+ const l = o.map(({ node: i }) => ({
444
+ id: i.attrs.id,
445
+ label: i.attrs.label,
446
+ value: s.get(i.attrs.id) ?? i.textContent ?? ""
447
+ })).filter((i) => i.id);
448
+ l.length > 0 && ($?.(l), [
449
+ ...E.current.document || [],
450
+ ...E.current.signer || []
451
+ ].filter((R) => R.value !== void 0).forEach(
452
+ (R) => N({
453
+ id: R.id,
454
+ value: R.value
455
+ })
456
+ ));
540
457
  },
541
- fileName: f?.fileName || "document.pdf"
542
- };
543
- await W?.(t);
544
- }, [
545
- E,
546
- m,
547
- s.source,
548
- o,
549
- b,
550
- f,
551
- W
552
- ]), u = F(async () => {
553
- if (!A || E || T) return;
554
- G(!0), j({ type: "submit" });
555
- const t = j({ type: "submit" }), r = {
556
- eventId: m,
557
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
558
- duration: Math.floor((Date.now() - ne.current) / 1e3),
559
- auditTrail: t,
560
- documentFields: o.document || [],
561
- signerFields: (o.signer || []).map((a) => ({
562
- id: a.id,
563
- value: b.get(a.id) ?? null
564
- })),
565
- isFullyCompleted: A
458
+ [$, N]
459
+ ), j = (t) => {
460
+ const o = {
461
+ ...t,
462
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
463
+ }, s = globalThis?.__SUPERDOC_AUDIT_MOCK__;
464
+ s && s(o);
465
+ const l = [...k.current, o];
466
+ return k.current = l, P(l), l;
566
467
  };
567
- try {
568
- await S(r);
569
- } finally {
570
- G(!1);
571
- }
572
- }, [
573
- A,
574
- E,
575
- T,
576
- m,
577
- o,
578
- b,
579
- S
580
- ]), P = (t) => {
581
- const r = t.component || $(t.type);
582
- return /* @__PURE__ */ g.jsx(
583
- r,
584
- {
585
- value: b.get(t.id) ?? null,
586
- onChange: (a) => e(t.id, a),
587
- isDisabled: E,
588
- label: t.label
468
+ te(() => w.current ? ((async () => {
469
+ const { SuperDoc: o } = await import("./superdoc.es-CqejOF1J.js").then((l) => l.D), s = new o({
470
+ selector: w.current,
471
+ document: a.source,
472
+ documentMode: "viewing",
473
+ onReady: () => {
474
+ s.activeEditor && U(s.activeEditor), j({ type: "ready" }), oe(!0);
475
+ }
476
+ });
477
+ y.current = s;
478
+ })(), () => {
479
+ y.current && (typeof y.current.destroy == "function" && y.current.destroy(), y.current = null);
480
+ }) : void 0, [a.source, a.mode, U]), te(() => {
481
+ if (!a.validation?.scroll?.required || !K) return;
482
+ const t = w.current;
483
+ if (!t) return;
484
+ const o = () => {
485
+ const { scrollTop: s, scrollHeight: l, clientHeight: i } = t, R = s / (l - i);
486
+ (R >= 0.95 || l <= i) && (H(!0), j({
487
+ type: "scroll",
488
+ data: { percent: Math.round(R * 100) }
489
+ }));
490
+ };
491
+ return t.addEventListener("scroll", o), o(), () => t.removeEventListener("scroll", o);
492
+ }, [a.validation?.scroll?.required, K]);
493
+ const e = M(
494
+ (t, o) => {
495
+ G((s) => {
496
+ const l = s.get(t), i = new Map(s);
497
+ return i.set(t, o), N({
498
+ id: t,
499
+ value: o
500
+ }), j({
501
+ type: "field_change",
502
+ data: { fieldId: t, value: o, previousValue: l }
503
+ }), Y?.({
504
+ id: t,
505
+ value: o,
506
+ previousValue: l
507
+ }), i;
508
+ });
589
509
  },
590
- t.id
591
- );
592
- }, $ = (t) => {
593
- switch (t) {
594
- case "signature":
595
- case "text":
596
- return ve;
597
- case "checkbox":
598
- return be;
599
- }
600
- }, d = () => {
601
- const t = f?.component || he(f), r = h?.component || Ee(h);
602
- return /* @__PURE__ */ g.jsxs(
603
- "div",
604
- {
605
- className: "superdoc-esign-actions",
606
- style: { display: "flex", gap: "10px" },
607
- children: [
608
- s.mode !== "download" && /* @__PURE__ */ g.jsx(
609
- r,
510
+ [Y, N]
511
+ ), r = M(() => a.validation?.scroll?.required && !_ ? !1 : (n.signer || []).every((t) => {
512
+ if (!t.validation?.required) return !0;
513
+ const o = b.get(t.id);
514
+ return o && (typeof o != "string" || o.trim());
515
+ }), [
516
+ _,
517
+ n.signer,
518
+ b,
519
+ a.validation?.scroll?.required
520
+ ]);
521
+ te(() => {
522
+ const t = r();
523
+ X(t), B?.({
524
+ scrolled: _,
525
+ fields: b,
526
+ isValid: t,
527
+ isSubmitting: T
528
+ });
529
+ }, [_, b, T, r, B]);
530
+ const c = M(async () => {
531
+ if (h) return;
532
+ const t = {
533
+ eventId: m,
534
+ documentSource: a.source,
535
+ fields: {
536
+ document: n.document || [],
537
+ signer: (n.signer || []).map((o) => ({
538
+ id: o.id,
539
+ value: b.get(o.id) ?? null
540
+ }))
541
+ },
542
+ fileName: f?.fileName || "document.pdf"
543
+ };
544
+ await z?.(t);
545
+ }, [
546
+ h,
547
+ m,
548
+ a.source,
549
+ n,
550
+ b,
551
+ f,
552
+ z
553
+ ]), u = M(async () => {
554
+ if (!A || h || T) return;
555
+ Z(!0), j({ type: "submit" });
556
+ const t = j({ type: "submit" }), o = {
557
+ eventId: m,
558
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
559
+ duration: Math.floor((Date.now() - ae.current) / 1e3),
560
+ auditTrail: t,
561
+ documentFields: n.document || [],
562
+ signerFields: (n.signer || []).map((s) => ({
563
+ id: s.id,
564
+ value: b.get(s.id) ?? null
565
+ })),
566
+ isFullyCompleted: A
567
+ };
568
+ try {
569
+ await S(o);
570
+ } finally {
571
+ Z(!1);
572
+ }
573
+ }, [
574
+ A,
575
+ h,
576
+ T,
577
+ m,
578
+ n,
579
+ b,
580
+ S
581
+ ]), D = (t) => {
582
+ const o = t.component || q(t.type);
583
+ return /* @__PURE__ */ p.jsx(
584
+ o,
585
+ {
586
+ value: b.get(t.id) ?? null,
587
+ onChange: (s) => e(t.id, s),
588
+ isDisabled: h,
589
+ label: t.label
590
+ },
591
+ t.id
592
+ );
593
+ }, q = (t) => {
594
+ switch (t) {
595
+ case "signature":
596
+ case "text":
597
+ return he;
598
+ case "checkbox":
599
+ return ye;
600
+ }
601
+ }, d = () => {
602
+ const t = f?.component || Ee(f);
603
+ return t ? /* @__PURE__ */ p.jsx(
604
+ t,
605
+ {
606
+ onClick: c,
607
+ fileName: f?.fileName,
608
+ isDisabled: h
609
+ }
610
+ ) : null;
611
+ }, C = () => {
612
+ if (a.mode === "download")
613
+ return null;
614
+ const t = x?.component || _e(x);
615
+ return /* @__PURE__ */ p.jsx(
616
+ "div",
617
+ {
618
+ className: "superdoc-esign-actions superdoc-esign-form-actions",
619
+ style: { display: "flex", gap: "10px" },
620
+ children: /* @__PURE__ */ p.jsx(
621
+ t,
610
622
  {
611
623
  onClick: u,
612
624
  isValid: A,
613
- isDisabled: E,
625
+ isDisabled: h,
614
626
  isSubmitting: T
615
627
  }
628
+ )
629
+ }
630
+ );
631
+ }, F = d(), se = C();
632
+ return ge(v, () => ({
633
+ getState: () => ({
634
+ scrolled: _,
635
+ fields: b,
636
+ isValid: A,
637
+ isSubmitting: T
638
+ }),
639
+ getAuditTrail: () => k.current,
640
+ reset: () => {
641
+ H(!a.validation?.scroll?.required), G(/* @__PURE__ */ new Map()), X(!1), k.current = [], P([]);
642
+ }
643
+ })), /* @__PURE__ */ p.jsxs(
644
+ "div",
645
+ {
646
+ className: `superdoc-esign-container ${O || ""}`,
647
+ style: J,
648
+ children: [
649
+ /* @__PURE__ */ p.jsxs(
650
+ "div",
651
+ {
652
+ className: "superdoc-esign-document",
653
+ "data-testid": "superdoc-esign-document",
654
+ style: { display: "flex", flexDirection: "column" },
655
+ children: [
656
+ F && /* @__PURE__ */ p.jsx(
657
+ "div",
658
+ {
659
+ className: "superdoc-esign-document-toolbar",
660
+ style: {
661
+ display: "flex",
662
+ justifyContent: "flex-end",
663
+ alignItems: "center",
664
+ padding: "8px 12px"
665
+ },
666
+ children: /* @__PURE__ */ p.jsx(
667
+ "div",
668
+ {
669
+ className: "superdoc-esign-document-controls",
670
+ style: { display: "flex", gap: "8px" },
671
+ children: F
672
+ }
673
+ )
674
+ }
675
+ ),
676
+ /* @__PURE__ */ p.jsx(
677
+ "div",
678
+ {
679
+ ref: w,
680
+ className: "superdoc-esign-document-viewer",
681
+ "data-testid": "superdoc-scroll-container",
682
+ style: { height: ne, overflow: "auto" }
683
+ }
684
+ )
685
+ ]
686
+ }
616
687
  ),
617
- /* @__PURE__ */ g.jsx(
618
- t,
688
+ /* @__PURE__ */ p.jsxs(
689
+ "div",
619
690
  {
620
- onClick: c,
621
- fileName: f?.fileName,
622
- isDisabled: E
691
+ className: "superdoc-esign-controls",
692
+ style: { marginTop: "20px" },
693
+ "data-testid": "superdoc-esign-controls",
694
+ children: [
695
+ n.signer && n.signer.length > 0 && /* @__PURE__ */ p.jsx(
696
+ "div",
697
+ {
698
+ className: "superdoc-esign-fields",
699
+ style: { marginBottom: "20px" },
700
+ "data-testid": "superdoc-esign-fields",
701
+ children: n.signer.map(D)
702
+ }
703
+ ),
704
+ se
705
+ ]
623
706
  }
624
707
  )
625
708
  ]
626
709
  }
627
710
  );
628
- };
629
- return fe(v, () => ({
630
- getState: () => ({
631
- scrolled: _,
632
- fields: b,
633
- isValid: A,
634
- isSubmitting: T
635
- }),
636
- getAuditTrail: () => k.current,
637
- reset: () => {
638
- B(!s.validation?.scroll?.required), J(/* @__PURE__ */ new Map()), H(!1), k.current = [], N([]);
639
- }
640
- })), /* @__PURE__ */ g.jsxs(
641
- "div",
642
- {
643
- className: `superdoc-esign-container ${O || ""}`,
644
- style: z,
645
- children: [
646
- /* @__PURE__ */ g.jsx(
647
- "div",
648
- {
649
- className: "superdoc-esign-document",
650
- "data-testid": "superdoc-esign-document",
651
- children: /* @__PURE__ */ g.jsx(
652
- "div",
653
- {
654
- ref: w,
655
- "data-testid": "superdoc-scroll-container",
656
- style: { height: te, overflow: "auto" }
657
- }
658
- )
659
- }
660
- ),
661
- /* @__PURE__ */ g.jsxs(
662
- "div",
663
- {
664
- className: "superdoc-esign-controls",
665
- style: { marginTop: "20px" },
666
- "data-testid": "superdoc-esign-controls",
667
- children: [
668
- o.signer && o.signer.length > 0 && /* @__PURE__ */ g.jsx(
669
- "div",
670
- {
671
- className: "superdoc-esign-fields",
672
- style: { marginBottom: "20px" },
673
- "data-testid": "superdoc-esign-fields",
674
- children: o.signer.map(P)
675
- }
676
- ),
677
- d()
678
- ]
679
- }
680
- )
681
- ]
682
- }
683
- );
684
- });
685
- xe.displayName = "SuperDocESign";
711
+ }
712
+ );
713
+ Re.displayName = "SuperDocESign";
686
714
  export {
687
- be as CheckboxInput,
688
- ve as SignatureInput,
689
- xe as default
715
+ ye as CheckboxInput,
716
+ he as SignatureInput,
717
+ Re as default
690
718
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/esign",
3
- "version": "1.2.0-next.2",
3
+ "version": "1.2.0-next.3",
4
4
  "description": "React eSignature component for SuperDoc",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",