@superdoc-dev/esign 2.2.0-next.4 → 2.2.0-next.40

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":"AAEA,OAAO,KAAK,KAAK,KAAK,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,aAAa,EAA4C,MAAM,YAAY,CAAC;AAErG,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;AAIzC,QAAA,MAAM,aAAa,gIA8fjB,CAAC;AAIH,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,KAAK,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,aAAa,EAA4C,MAAM,YAAY,CAAC;AAErG,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;AAIzC,QAAA,MAAM,aAAa,gIAigBjB,CAAC;AAIH,eAAe,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require(`react`),t=require(`react/jsx-runtime`);const n=e=>{let t=globalThis.document.createElement(`canvas`),n=t.getContext(`2d`);n.font=`italic 30px cursive`;let r=n.measureText(e).width;return t.width=Math.ceil(r+8)+20,t.height=51,n.font=`italic 30px cursive`,n.fillStyle=`black`,n.textAlign=`center`,n.textBaseline=`middle`,n.fillText(e,t.width/2,t.height/2),t.toDataURL(`image/png`)},r=({value:e,onChange:n,isDisabled:r,label:i})=>(0,t.jsxs)(`div`,{className:`superdoc-esign-signature-input`,style:{display:`flex`,flexDirection:`column`,gap:`8px`},children:[i&&(0,t.jsx)(`label`,{children:i}),(0,t.jsx)(`input`,{type:`text`,value:String(e||``),onChange:e=>n(e.target.value),disabled:r,placeholder:`Type your full name`,style:{fontFamily:`cursive`,fontSize:`18px`}})]}),i=({value:e,onChange:n,isDisabled:r,label:i})=>(0,t.jsxs)(`label`,{className:`superdoc-esign-checkbox-input`,style:{display:`flex`,gap:`8px`},children:[(0,t.jsx)(`input`,{type:`checkbox`,checked:!!e,onChange:e=>n(e.target.checked),disabled:r}),(0,t.jsx)(`span`,{children:i})]}),a=e=>({onClick:n,fileName:r,isDisabled:i,isDownloading:a})=>{let o=e?.label||`Download`,s=i||a;return(0,t.jsxs)(`button`,{onClick:n,disabled:s,className:`superdoc-esign-btn superdoc-esign-btn--download${a?` superdoc-esign-btn--loading`:``}`,style:{padding:`8px 16px`,borderRadius:`6px`,border:`1px solid #d0d5dd`,background:`#ffffff`,color:`#333`,cursor:s?`not-allowed`:`pointer`,opacity:s?.7:1,fontSize:`16px`,fontWeight:`bold`,display:`inline-flex`,alignItems:`center`,gap:`8px`,transition:`opacity 0.2s ease`},children:[a&&(0,t.jsx)(`span`,{className:`superdoc-esign-spinner`}),a?`Downloading...`:o,!a&&r&&` (${r})`]})},o=e=>({onClick:n,isValid:r,isDisabled:i,isSubmitting:a})=>{let o=e?.label||`Submit`,s=!r||i||a;return(0,t.jsxs)(`button`,{onClick:n,disabled:s,className:`superdoc-esign-btn superdoc-esign-btn--submit${a?` superdoc-esign-btn--loading`:``}`,style:{padding:`12px 24px`,borderRadius:`6px`,border:`none`,background:`#007bff`,color:`#fff`,cursor:s?`not-allowed`:`pointer`,opacity:s&&!a?.5:1,fontSize:`16px`,fontWeight:`bold`,display:`inline-flex`,alignItems:`center`,gap:`8px`,transition:`opacity 0.2s ease`},children:[a&&(0,t.jsx)(`span`,{className:`superdoc-esign-spinner superdoc-esign-spinner--light`}),a?`Submitting...`:o]})};var s=(0,e.forwardRef)((s,c)=>{let{eventId:l,document:u,fields:d={},download:f,submit:p,onSubmit:m,onDownload:h,onStateChange:g,onFieldChange:_,onFieldsDiscovered:v,onZoomChange:y,telemetry:b,licenseKey:x,isDisabled:S=!1,className:C,style:ee,documentHeight:w=`600px`,pdf:T}=s,[E,D]=(0,e.useState)(!u.validation?.scroll?.required),[O,k]=(0,e.useState)(new Map),[A,j]=(0,e.useState)(!1),[M,N]=(0,e.useState)(!1),[P,F]=(0,e.useState)(!1),[I,L]=(0,e.useState)([]),[R,z]=(0,e.useState)(!1),B=(0,e.useRef)(null),V=(0,e.useRef)(null),te=(0,e.useRef)(Date.now()),H=(0,e.useRef)(d),U=(0,e.useRef)([]),W=(0,e.useRef)(v),G=(0,e.useRef)(y);H.current=d,W.current=v,G.current=y,(0,e.useEffect)(()=>{U.current=I},[I]);let K=(0,e.useCallback)(e=>{if(!V.current?.activeEditor)return;let t=V.current.activeEditor,r=H.current.signer?.find(t=>t.id===e.id);if(e.type===`table`&&Array.isArray(e.value)){let n=(t.helpers?.structuredContentCommands)?.getStructuredContentTablesById?.(e.id,t.state)||[];if(n.length){let{node:r,pos:i}=n[0],a=r.childCount;if(a>1){let e=t.state.tr;for(let t=a-1;t>=1;t--){let n=1;for(let e=0;e<t;e++)n+=r.child(e).nodeSize;let a=r.child(t),o=i+n,s=o+a.nodeSize;e=e.delete(e.mapping.map(o),e.mapping.map(s))}t.view?.dispatch(e)}t.commands?.appendRowsToStructuredContentTable?.({id:e.id,rows:e.value,copyRowStyle:!0})}return}let i;i=r?.type===`signature`&&e.value?{json:{type:`image`,attrs:{src:typeof e.value==`string`&&e.value.startsWith(`data:image/`)?e.value:n(String(e.value)),alt:`Signature`}}}:{text:String(e.value??``)},e.id&&t.commands?.updateStructuredContentById?.(e.id,i)},[]),q=(0,e.useCallback)(e=>{if(!e)return;let t=e.helpers.structuredContentCommands.getStructuredContentTags(e.state),n=new Map;H.current.document?.forEach(e=>{e.id&&n.set(e.id,e.value)}),H.current.signer?.forEach(e=>{e.value!==void 0&&n.set(e.id,e.value)});let r=t.map(({node:e})=>({id:e.attrs.id,label:e.attrs.label,value:n.get(e.attrs.id)??e.textContent??``})).filter(e=>e.id);r.length>0&&(W.current?.(r),(H.current.document||[]).filter(e=>e.value!==void 0).forEach(e=>K({id:e.id,value:e.value,type:e.type})),(H.current.signer||[]).filter(e=>e.value!==void 0).forEach(e=>K({id:e.id,value:e.value})))},[K]),J=e=>{let t={...e,timestamp:new Date().toISOString()},n=globalThis?.__SUPERDOC_AUDIT_MOCK__;n&&n(t);let r=[...U.current,t];return U.current=r,L(r),r},Y=(0,e.useMemo)(()=>({enabled:b?.enabled??!0,metadata:{source:`esign`,...b?.metadata}}),[b?.enabled,JSON.stringify(b?.metadata)]);(0,e.useEffect)(()=>{if(!B.current)return;let e=!1,t=null;return(async()=>{let{SuperDoc:n}=await import(`superdoc`);e||(t=new n({selector:B.current,document:T&&typeof u.source==`string`?{url:u.source,type:`pdf`}:u.source,documentMode:`viewing`,modules:{comments:!1,...T?{pdf:T}:{}},viewOptions:{layout:u.viewOptions?.layout??(u.layoutMode===`responsive`?`web`:`print`)},telemetry:Y,...x&&{licenseKey:x},onReady:()=>{e||(t?.activeEditor&&q(t.activeEditor),J({type:`ready`}),z(!0))},onPdfDocumentReady:()=>{e||(J({type:`ready`}),z(!0))}}),V.current=t,t.on(`zoomChange`,e=>{G.current?.(e)}))})(),()=>{e=!0,t&&typeof t.destroy==`function`&&t.destroy(),V.current=null}},[u.source,u.mode,u.layoutMode,u.viewOptions?.layout,T,q,Y,x]),(0,e.useEffect)(()=>{if(!u.validation?.scroll?.required||!R)return;let e=B.current;if(!e)return;let t=()=>{let{scrollTop:t,scrollHeight:n,clientHeight:r}=e,i=t/(n-r);(i>=.95||n<=r)&&(D(!0),J({type:`scroll`,data:{percent:Math.round(i*100)}}))};return e.addEventListener(`scroll`,t),t(),()=>e.removeEventListener(`scroll`,t)},[u.validation?.scroll?.required,R]);let X=(0,e.useCallback)((e,t)=>{k(n=>{let r=n.get(e),i=new Map(n);return i.set(e,t),K({id:e,value:t}),J({type:`field_change`,data:{fieldId:e,value:t,previousValue:r}}),_?.({id:e,value:t,previousValue:r}),i})},[_,K]),Z=(0,e.useCallback)(()=>u.validation?.scroll?.required&&!E?!1:(d.signer||[]).every(e=>{if(!e.validation?.required)return!0;let t=O.get(e.id);return t&&(typeof t!=`string`||t.trim())}),[E,d.signer,O,u.validation?.scroll?.required]);(0,e.useEffect)(()=>{let e=Z();j(e),g?.({scrolled:E,fields:O,isValid:e,isSubmitting:M})},[E,O,M,Z,g]);let ne=(0,e.useCallback)(async()=>{if(S||P)return;F(!0);let e={eventId:l,documentSource:u.source,fields:{document:d.document||[],signer:(d.signer||[]).map(e=>({id:e.id,value:O.get(e.id)??null}))},fileName:f?.fileName||`document.pdf`};try{await h?.(e)}finally{F(!1)}},[S,P,l,u.source,d,O,f,h]),re=(0,e.useCallback)(async()=>{if(!A||S||M)return;N(!0),J({type:`submit`});let e=J({type:`submit`}),t={eventId:l,timestamp:new Date().toISOString(),duration:Math.floor((Date.now()-te.current)/1e3),auditTrail:e,documentFields:d.document||[],signerFields:(d.signer||[]).map(e=>({id:e.id,value:O.get(e.id)??null})),isFullyCompleted:A};try{await m(t)}finally{N(!1)}},[A,S,M,l,d,O,m]),Q=e=>(0,t.jsx)(e.component||ie(e.type),{value:O.get(e.id)??null,onChange:t=>X(e.id,t),isDisabled:S,label:e.label},e.id),ie=e=>{switch(e){case`signature`:case`text`:return r;case`checkbox`:return i}},ae=()=>{let e=f?.component||a(f);return e?(0,t.jsx)(e,{onClick:ne,fileName:f?.fileName,isDisabled:S,isDownloading:P}):null},oe=()=>u.mode===`download`?null:(0,t.jsx)(`div`,{className:`superdoc-esign-actions superdoc-esign-form-actions`,children:(0,t.jsx)(p?.component||o(p),{onClick:re,isValid:A,isDisabled:S,isSubmitting:M})}),$=ae(),se=oe();return(0,e.useImperativeHandle)(c,()=>({getState:()=>({scrolled:E,fields:O,isValid:A,isSubmitting:M}),getAuditTrail:()=>U.current,reset:()=>{D(!u.validation?.scroll?.required),k(new Map),j(!1),U.current=[],L([])},updateFieldInDocument:K,setZoom:e=>{V.current?.setZoom(e)},getZoom:()=>V.current?.getZoom()??100}),[E,O,A,M,u.validation?.scroll?.required,K]),(0,t.jsxs)(`div`,{className:`superdoc-esign-container ${C||``}`,style:ee,children:[(0,t.jsxs)(`div`,{className:`superdoc-esign-document`,"data-testid":`superdoc-esign-document`,children:[$&&(0,t.jsx)(`div`,{className:`superdoc-esign-document-toolbar`,children:(0,t.jsx)(`div`,{className:`superdoc-esign-document-controls`,children:$})}),(0,t.jsx)(`div`,{ref:B,className:`superdoc-esign-document-viewer`,"data-testid":`superdoc-scroll-container`,style:{height:w,overflow:`auto`}})]}),(0,t.jsxs)(`div`,{className:`superdoc-esign-controls`,"data-testid":`superdoc-esign-controls`,children:[d.signer&&d.signer.length>0&&(0,t.jsx)(`div`,{className:`superdoc-esign-fields`,"data-testid":`superdoc-esign-fields`,children:d.signer.map(Q)}),se]})]})});s.displayName=`SuperDocESign`;var c=s;exports.CheckboxInput=i,exports.SignatureInput=r,exports.default=c,exports.textToImageDataUrl=n;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require(`react`),t=require(`react/jsx-runtime`);const n=e=>{let t=globalThis.document.createElement(`canvas`),n=t.getContext(`2d`);n.font=`italic 30px cursive`;let r=n.measureText(e).width;return t.width=Math.ceil(r+8)+20,t.height=51,n.font=`italic 30px cursive`,n.fillStyle=`black`,n.textAlign=`center`,n.textBaseline=`middle`,n.fillText(e,t.width/2,t.height/2),t.toDataURL(`image/png`)},r=({value:e,onChange:n,isDisabled:r,label:i})=>(0,t.jsxs)(`div`,{className:`superdoc-esign-signature-input`,style:{display:`flex`,flexDirection:`column`,gap:`8px`},children:[i&&(0,t.jsx)(`label`,{children:i}),(0,t.jsx)(`input`,{type:`text`,value:String(e||``),onChange:e=>n(e.target.value),disabled:r,placeholder:`Type your full name`,style:{fontFamily:`cursive`,fontSize:`18px`}})]}),i=({value:e,onChange:n,isDisabled:r,label:i})=>(0,t.jsxs)(`label`,{className:`superdoc-esign-checkbox-input`,style:{display:`flex`,gap:`8px`},children:[(0,t.jsx)(`input`,{type:`checkbox`,checked:!!e,onChange:e=>n(e.target.checked),disabled:r}),(0,t.jsx)(`span`,{children:i})]}),a=e=>({onClick:n,fileName:r,isDisabled:i,isDownloading:a})=>{let o=e?.label||`Download`,s=i||a;return(0,t.jsxs)(`button`,{onClick:n,disabled:s,className:`superdoc-esign-btn superdoc-esign-btn--download${a?` superdoc-esign-btn--loading`:``}`,style:{padding:`8px 16px`,borderRadius:`6px`,border:`1px solid #d0d5dd`,background:`#ffffff`,color:`#333`,cursor:s?`not-allowed`:`pointer`,opacity:s?.7:1,fontSize:`16px`,fontWeight:`bold`,display:`inline-flex`,alignItems:`center`,gap:`8px`,transition:`opacity 0.2s ease`},children:[a&&(0,t.jsx)(`span`,{className:`superdoc-esign-spinner`}),a?`Downloading...`:o,!a&&r&&` (${r})`]})},o=e=>({onClick:n,isValid:r,isDisabled:i,isSubmitting:a})=>{let o=e?.label||`Submit`,s=!r||i||a;return(0,t.jsxs)(`button`,{onClick:n,disabled:s,className:`superdoc-esign-btn superdoc-esign-btn--submit${a?` superdoc-esign-btn--loading`:``}`,style:{padding:`12px 24px`,borderRadius:`6px`,border:`none`,background:`#007bff`,color:`#fff`,cursor:s?`not-allowed`:`pointer`,opacity:s&&!a?.5:1,fontSize:`16px`,fontWeight:`bold`,display:`inline-flex`,alignItems:`center`,gap:`8px`,transition:`opacity 0.2s ease`},children:[a&&(0,t.jsx)(`span`,{className:`superdoc-esign-spinner superdoc-esign-spinner--light`}),a?`Submitting...`:o]})};var s=(0,e.forwardRef)((s,c)=>{let{eventId:l,document:u,fields:d={},download:f,submit:p,onSubmit:m,onDownload:h,onStateChange:g,onFieldChange:_,onFieldsDiscovered:v,onZoomChange:y,telemetry:b,licenseKey:x,isDisabled:S=!1,className:C,style:ee,documentHeight:w=`600px`,pdf:T}=s,[E,D]=(0,e.useState)(!u.validation?.scroll?.required),[O,k]=(0,e.useState)(new Map),[A,j]=(0,e.useState)(!1),[M,N]=(0,e.useState)(!1),[P,F]=(0,e.useState)(!1),[I,L]=(0,e.useState)([]),[R,z]=(0,e.useState)(!1),B=(0,e.useRef)(null),V=(0,e.useRef)(null),te=(0,e.useRef)(Date.now()),H=(0,e.useRef)(d),U=(0,e.useRef)([]),W=(0,e.useRef)(v),G=(0,e.useRef)(y);H.current=d,W.current=v,G.current=y,(0,e.useEffect)(()=>{U.current=I},[I]);let K=(0,e.useCallback)(e=>{if(!V.current?.activeEditor)return;let t=V.current.activeEditor,r=H.current.signer?.find(t=>t.id===e.id);if(e.type===`table`&&Array.isArray(e.value)){let n=(t.helpers?.structuredContentCommands)?.getStructuredContentTablesById?.(e.id,t.state)||[];if(n.length){let{node:r,pos:i}=n[0],a=r.childCount;if(a>1){let e=t.state.tr;for(let t=a-1;t>=1;t--){let n=1;for(let e=0;e<t;e++)n+=r.child(e).nodeSize;let a=r.child(t),o=i+n,s=o+a.nodeSize;e=e.delete(e.mapping.map(o),e.mapping.map(s))}t.view?.dispatch(e)}t.commands?.appendRowsToStructuredContentTable?.({id:e.id,rows:e.value,copyRowStyle:!0})}return}let i;i=r?.type===`signature`&&e.value?{json:{type:`image`,attrs:{src:typeof e.value==`string`&&e.value.startsWith(`data:image/`)?e.value:n(String(e.value)),alt:`Signature`}}}:{text:String(e.value??``)},e.id&&t.commands?.updateStructuredContentById?.(e.id,i)},[]),q=(0,e.useCallback)(e=>{if(!e)return;let t=e.helpers?.structuredContentCommands;if(!t?.getStructuredContentTags)return;let n=t.getStructuredContentTags(e.state),r=new Map;H.current.document?.forEach(e=>{e.id&&r.set(e.id,e.value)}),H.current.signer?.forEach(e=>{e.value!==void 0&&r.set(e.id,e.value)});let i=n.map(({node:e})=>({id:e.attrs.id,label:e.attrs.label,value:r.get(e.attrs.id)??e.textContent??``})).filter(e=>e.id);i.length>0&&(W.current?.(i),(H.current.document||[]).filter(e=>e.value!==void 0).forEach(e=>K({id:e.id,value:e.value,type:e.type})),(H.current.signer||[]).filter(e=>e.value!==void 0).forEach(e=>K({id:e.id,value:e.value})))},[K]),J=e=>{let t={...e,timestamp:new Date().toISOString()},n=globalThis?.__SUPERDOC_AUDIT_MOCK__;n&&n(t);let r=[...U.current,t];return U.current=r,L(r),r},Y=(0,e.useMemo)(()=>({enabled:b?.enabled??!0,metadata:{source:`esign`,...b?.metadata}}),[b?.enabled,JSON.stringify(b?.metadata)]);(0,e.useEffect)(()=>{if(!B.current)return;let e=!1,t=null;return(async()=>{let{SuperDoc:n}=await import(`superdoc`);e||(t=new n({selector:B.current,document:T&&typeof u.source==`string`?{url:u.source,type:`pdf`}:u.source,documentMode:`viewing`,modules:{comments:!1,...T?{pdf:T}:{}},viewOptions:{layout:u.viewOptions?.layout??(u.layoutMode===`responsive`?`web`:`print`)},telemetry:Y,...x&&{licenseKey:x},onReady:()=>{e||(t?.activeEditor&&q(t.activeEditor),J({type:`ready`}),z(!0))},onPdfDocumentReady:()=>{e||(J({type:`ready`}),z(!0))}}),V.current=t,t.on(`zoomChange`,e=>{G.current?.(e)}))})(),()=>{e=!0,t&&typeof t.destroy==`function`&&t.destroy(),V.current=null}},[u.source,u.mode,u.layoutMode,u.viewOptions?.layout,T,q,Y,x]),(0,e.useEffect)(()=>{if(!u.validation?.scroll?.required||!R)return;let e=B.current;if(!e)return;let t=()=>{let{scrollTop:t,scrollHeight:n,clientHeight:r}=e,i=t/(n-r);(i>=.95||n<=r)&&(D(!0),J({type:`scroll`,data:{percent:Math.round(i*100)}}))};return e.addEventListener(`scroll`,t),t(),()=>e.removeEventListener(`scroll`,t)},[u.validation?.scroll?.required,R]);let X=(0,e.useCallback)((e,t)=>{k(n=>{let r=n.get(e),i=new Map(n);return i.set(e,t),K({id:e,value:t}),J({type:`field_change`,data:{fieldId:e,value:t,previousValue:r}}),_?.({id:e,value:t,previousValue:r}),i})},[_,K]),Z=(0,e.useCallback)(()=>u.validation?.scroll?.required&&!E?!1:(d.signer||[]).every(e=>{if(!e.validation?.required)return!0;let t=O.get(e.id);return t&&(typeof t!=`string`||t.trim())}),[E,d.signer,O,u.validation?.scroll?.required]);(0,e.useEffect)(()=>{let e=Z();j(e),g?.({scrolled:E,fields:O,isValid:e,isSubmitting:M})},[E,O,M,Z,g]);let ne=(0,e.useCallback)(async()=>{if(S||P)return;F(!0);let e={eventId:l,documentSource:u.source,fields:{document:d.document||[],signer:(d.signer||[]).map(e=>({id:e.id,value:O.get(e.id)??null}))},fileName:f?.fileName||`document.pdf`};try{await h?.(e)}finally{F(!1)}},[S,P,l,u.source,d,O,f,h]),re=(0,e.useCallback)(async()=>{if(!A||S||M)return;N(!0),J({type:`submit`});let e=J({type:`submit`}),t={eventId:l,timestamp:new Date().toISOString(),duration:Math.floor((Date.now()-te.current)/1e3),auditTrail:e,documentFields:d.document||[],signerFields:(d.signer||[]).map(e=>({id:e.id,value:O.get(e.id)??null})),isFullyCompleted:A};try{await m(t)}finally{N(!1)}},[A,S,M,l,d,O,m]),Q=e=>(0,t.jsx)(e.component||ie(e.type),{value:O.get(e.id)??null,onChange:t=>X(e.id,t),isDisabled:S,label:e.label},e.id),ie=e=>{switch(e){case`signature`:case`text`:return r;case`checkbox`:return i}},ae=()=>{let e=f?.component||a(f);return e?(0,t.jsx)(e,{onClick:ne,fileName:f?.fileName,isDisabled:S,isDownloading:P}):null},oe=()=>u.mode===`download`?null:(0,t.jsx)(`div`,{className:`superdoc-esign-actions superdoc-esign-form-actions`,children:(0,t.jsx)(p?.component||o(p),{onClick:re,isValid:A,isDisabled:S,isSubmitting:M})}),$=ae(),se=oe();return(0,e.useImperativeHandle)(c,()=>({getState:()=>({scrolled:E,fields:O,isValid:A,isSubmitting:M}),getAuditTrail:()=>U.current,reset:()=>{D(!u.validation?.scroll?.required),k(new Map),j(!1),U.current=[],L([])},updateFieldInDocument:K,setZoom:e=>{V.current?.setZoom(e)},getZoom:()=>V.current?.getZoom()??100}),[E,O,A,M,u.validation?.scroll?.required,K]),(0,t.jsxs)(`div`,{className:`superdoc-esign-container ${C||``}`,style:ee,children:[(0,t.jsxs)(`div`,{className:`superdoc-esign-document`,"data-testid":`superdoc-esign-document`,children:[$&&(0,t.jsx)(`div`,{className:`superdoc-esign-document-toolbar`,children:(0,t.jsx)(`div`,{className:`superdoc-esign-document-controls`,children:$})}),(0,t.jsx)(`div`,{ref:B,className:`superdoc-esign-document-viewer`,"data-testid":`superdoc-scroll-container`,style:{height:w,overflow:`auto`}})]}),(0,t.jsxs)(`div`,{className:`superdoc-esign-controls`,"data-testid":`superdoc-esign-controls`,children:[d.signer&&d.signer.length>0&&(0,t.jsx)(`div`,{className:`superdoc-esign-fields`,"data-testid":`superdoc-esign-fields`,children:d.signer.map(Q)}),se]})]})});s.displayName=`SuperDocESign`;var c=s;exports.CheckboxInput=i,exports.SignatureInput=r,exports.default=c,exports.textToImageDataUrl=n;
package/dist/index.mjs CHANGED
@@ -126,18 +126,20 @@ var SuperDocESign = forwardRef((e, s) => {
126
126
  } } : { text: String(e.value ?? "") }, e.id && t.commands?.updateStructuredContentById?.(e.id, r);
127
127
  }, []), J = useCallback((e) => {
128
128
  if (!e) return;
129
- let t = e.helpers.structuredContentCommands.getStructuredContentTags(e.state), n = /* @__PURE__ */ new Map();
129
+ let t = e.helpers?.structuredContentCommands;
130
+ if (!t?.getStructuredContentTags) return;
131
+ let n = t.getStructuredContentTags(e.state), r = /* @__PURE__ */ new Map();
130
132
  U.current.document?.forEach((e) => {
131
- e.id && n.set(e.id, e.value);
133
+ e.id && r.set(e.id, e.value);
132
134
  }), U.current.signer?.forEach((e) => {
133
- e.value !== void 0 && n.set(e.id, e.value);
135
+ e.value !== void 0 && r.set(e.id, e.value);
134
136
  });
135
- let r = t.map(({ node: e }) => ({
137
+ let i = n.map(({ node: e }) => ({
136
138
  id: e.attrs.id,
137
139
  label: e.attrs.label,
138
- value: n.get(e.attrs.id) ?? e.textContent ?? ""
140
+ value: r.get(e.attrs.id) ?? e.textContent ?? ""
139
141
  })).filter((e) => e.id);
140
- r.length > 0 && (G.current?.(r), (U.current.document || []).filter((e) => e.value !== void 0).forEach((e) => q({
142
+ i.length > 0 && (G.current?.(i), (U.current.document || []).filter((e) => e.value !== void 0).forEach((e) => q({
141
143
  id: e.id,
142
144
  value: e.value,
143
145
  type: e.type
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/esign",
3
- "version": "2.2.0-next.4",
3
+ "version": "2.2.0-next.40",
4
4
  "description": "React eSignature component for SuperDoc",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -53,7 +53,7 @@
53
53
  "peerDependencies": {
54
54
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
55
55
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
56
- "superdoc": "^1.19.0"
56
+ "superdoc": "^1.24.2"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@testing-library/jest-dom": "catalog:",