@superdoc-dev/esign 1.4.0-next.2 → 1.4.0-next.4

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=signature.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signature.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/signature.test.ts"],"names":[],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
+ import { textToImageDataUrl } from './utils/signature';
1
2
  import { SignatureInput, CheckboxInput } from './defaults';
2
3
  import type * as Types from './types';
3
4
  export * from './types';
5
+ export { textToImageDataUrl };
4
6
  export { SignatureInput, CheckboxInput };
5
7
  declare const SuperDocESign: import('react').ForwardRefExoticComponent<Types.SuperDocESignProps & import('react').RefAttributes<Types.SuperDocESignHandle>>;
6
8
  export default SuperDocESign;
@@ -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,EACL,cAAc,EACd,aAAa,EAGd,MAAM,YAAY,CAAC;AAEpB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;AAIzC,QAAA,MAAM,aAAa,gIAqdlB,CAAC;AAIF,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,EACL,cAAc,EACd,aAAa,EAGd,MAAM,YAAY,CAAC;AAEpB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;AAIzC,QAAA,MAAM,aAAa,gIAuclB,CAAC;AAIF,eAAe,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var de=Object.create;var P=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var he=(l,p,u,r)=>{if(p&&typeof p=="object"||typeof p=="function")for(let n of ge(p))!fe.call(l,n)&&n!==u&&P(l,n,{get:()=>p[n],enumerable:!(r=pe(p,n))||r.enumerable});return l};var ve=(l,p,u)=>(u=l!=null?de(me(l)):{},he(p||!l||!l.__esModule?P(u,"default",{value:l,enumerable:!0}):u,l));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("react/jsx-runtime"),a=require("react"),W=({value:l,onChange:p,isDisabled:u,label:r})=>c.jsxs("div",{className:"superdoc-esign-signature-input",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[r&&c.jsx("label",{children:r}),c.jsx("input",{type:"text",value:String(l||""),onChange:n=>p(n.target.value),disabled:u,placeholder:"Type your full name",style:{fontFamily:"cursive",fontSize:"18px"}})]}),L=({value:l,onChange:p,isDisabled:u,label:r})=>c.jsxs("label",{className:"superdoc-esign-checkbox-input",style:{display:"flex",gap:"8px"},children:[c.jsx("input",{type:"checkbox",checked:!!l,onChange:n=>p(n.target.checked),disabled:u}),c.jsx("span",{children:r})]}),xe=l=>({onClick:u,fileName:r,isDisabled:n,isDownloading:d})=>{const x=l?.label||"Download",m=n||d;return c.jsxs("button",{onClick:u,disabled:m,className:`superdoc-esign-btn superdoc-esign-btn--download${d?" superdoc-esign-btn--loading":""}`,style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid #d0d5dd",background:"#ffffff",color:"#333",cursor:m?"not-allowed":"pointer",opacity:m?.7:1,fontSize:"16px",fontWeight:"bold",display:"inline-flex",alignItems:"center",gap:"8px",transition:"opacity 0.2s ease"},children:[d&&c.jsx("span",{className:"superdoc-esign-spinner"}),d?"Downloading...":x,!d&&r&&` (${r})`]})},be=l=>({onClick:u,isValid:r,isDisabled:n,isSubmitting:d})=>{const x=l?.label||"Submit",m=!r||n||d;return c.jsxs("button",{onClick:u,disabled:m,className:`superdoc-esign-btn superdoc-esign-btn--submit${d?" superdoc-esign-btn--loading":""}`,style:{padding:"12px 24px",borderRadius:"6px",border:"none",background:"#007bff",color:"#fff",cursor:m?"not-allowed":"pointer",opacity:m&&!d?.5:1,fontSize:"16px",fontWeight:"bold",display:"inline-flex",alignItems:"center",gap:"8px",transition:"opacity 0.2s ease"},children:[d&&c.jsx("span",{className:"superdoc-esign-spinner superdoc-esign-spinner--light"}),d?"Submitting...":x]})},K=a.forwardRef((l,p)=>{const{eventId:u,document:r,fields:n={},download:d,submit:x,onSubmit:m,onDownload:E,onStateChange:N,onFieldChange:T,onFieldsDiscovered:F,isDisabled:h=!1,className:X,style:Y,documentHeight:G="600px"}=l,[b,I]=a.useState(!r.validation?.scroll?.required),[g,M]=a.useState(new Map),[y,q]=a.useState(!1),[v,A]=a.useState(!1),[k,_]=a.useState(!1),[V,B]=a.useState([]),[U,J]=a.useState(!1),j=a.useRef(null),R=a.useRef(null),Q=a.useRef(Date.now()),S=a.useRef(n),w=a.useRef([]),$=a.useRef(F);S.current=n,$.current=F,a.useEffect(()=>{w.current=V},[V]);const C=a.useCallback(e=>{if(!R.current?.activeEditor)return;const t=R.current.activeEditor,s=S.current.signer?.find(o=>o.id===e.id);let i;s?.type==="signature"&&e.value?i={json:{type:"image",attrs:{src:typeof e.value=="string"&&e.value.startsWith("data:image/")?e.value:Z(String(e.value)),alt:"Signature"}}}:i={text:String(e.value??"")},e.id&&t.commands.updateStructuredContentById(e.id,i)},[]);function Z(e){const t=globalThis.document.createElement("canvas"),s=t.getContext("2d"),i=30;s.font=`italic ${i}px cursive`;const f=s.measureText(e).width,ce=i*1.3,le=4,ue=6;return t.width=Math.ceil(f+le*2)+20,t.height=Math.ceil(ce+ue*2),s.font=`italic ${i}px cursive`,s.fillStyle="black",s.textAlign="center",s.textBaseline="middle",s.fillText(e,t.width/2,t.height/2),t.toDataURL("image/png")}const H=a.useCallback(e=>{if(!e)return;const t=e.helpers.structuredContentCommands.getStructuredContentTags(e.state),s=new Map;S.current.document?.forEach(o=>{o.id&&s.set(o.id,o.value)}),S.current.signer?.forEach(o=>{o.value!==void 0&&s.set(o.id,o.value)});const i=t.map(({node:o})=>({id:o.attrs.id,label:o.attrs.label,value:s.get(o.attrs.id)??o.textContent??""})).filter(o=>o.id);i.length>0&&($.current?.(i),[...S.current.document||[],...S.current.signer||[]].filter(f=>f.value!==void 0).forEach(f=>C({id:f.id,value:f.value})))},[C]),D=e=>{const t={...e,timestamp:new Date().toISOString()},s=globalThis?.__SUPERDOC_AUDIT_MOCK__;s&&s(t);const i=[...w.current,t];return w.current=i,B(i),i};a.useEffect(()=>{if(!j.current)return;let e=!1,t=null;return(async()=>{const{SuperDoc:i}=await import("superdoc");e||(t=new i({selector:j.current,document:r.source,documentMode:"viewing",modules:{comments:!1},onReady:()=>{e||(t?.activeEditor&&H(t.activeEditor),D({type:"ready"}),J(!0))}}),R.current=t)})(),()=>{e=!0,t&&typeof t.destroy=="function"&&t.destroy(),R.current=null}},[r.source,r.mode,H]),a.useEffect(()=>{if(!r.validation?.scroll?.required||!U)return;const e=j.current;if(!e)return;const t=()=>{const{scrollTop:s,scrollHeight:i,clientHeight:o}=e,f=s/(i-o);(f>=.95||i<=o)&&(I(!0),D({type:"scroll",data:{percent:Math.round(f*100)}}))};return e.addEventListener("scroll",t),t(),()=>e.removeEventListener("scroll",t)},[r.validation?.scroll?.required,U]);const ee=a.useCallback((e,t)=>{M(s=>{const i=s.get(e),o=new Map(s);return o.set(e,t),C({id:e,value:t}),D({type:"field_change",data:{fieldId:e,value:t,previousValue:i}}),T?.({id:e,value:t,previousValue:i}),o})},[T,C]),O=a.useCallback(()=>r.validation?.scroll?.required&&!b?!1:(n.signer||[]).every(e=>{if(!e.validation?.required)return!0;const t=g.get(e.id);return t&&(typeof t!="string"||t.trim())}),[b,n.signer,g,r.validation?.scroll?.required]);a.useEffect(()=>{const e=O();q(e),N?.({scrolled:b,fields:g,isValid:e,isSubmitting:v})},[b,g,v,O,N]);const te=a.useCallback(async()=>{if(h||k)return;_(!0);const e={eventId:u,documentSource:r.source,fields:{document:n.document||[],signer:(n.signer||[]).map(t=>({id:t.id,value:g.get(t.id)??null}))},fileName:d?.fileName||"document.pdf"};try{await E?.(e)}finally{_(!1)}},[h,k,u,r.source,n,g,d,E]),ne=a.useCallback(async()=>{if(!y||h||v)return;A(!0),D({type:"submit"});const e=D({type:"submit"}),t={eventId:u,timestamp:new Date().toISOString(),duration:Math.floor((Date.now()-Q.current)/1e3),auditTrail:e,documentFields:n.document||[],signerFields:(n.signer||[]).map(s=>({id:s.id,value:g.get(s.id)??null})),isFullyCompleted:y};try{await m(t)}finally{A(!1)}},[y,h,v,u,n,g,m]),se=e=>{const t=e.component||re(e.type);return c.jsx(t,{value:g.get(e.id)??null,onChange:s=>ee(e.id,s),isDisabled:h,label:e.label},e.id)},re=e=>{switch(e){case"signature":case"text":return W;case"checkbox":return L}},oe=()=>{const e=d?.component||xe(d);return e?c.jsx(e,{onClick:te,fileName:d?.fileName,isDisabled:h,isDownloading:k}):null},ae=()=>{if(r.mode==="download")return null;const e=x?.component||be(x);return c.jsx("div",{className:"superdoc-esign-actions superdoc-esign-form-actions",children:c.jsx(e,{onClick:ne,isValid:y,isDisabled:h,isSubmitting:v})})},z=oe(),ie=ae();return a.useImperativeHandle(p,()=>({getState:()=>({scrolled:b,fields:g,isValid:y,isSubmitting:v}),getAuditTrail:()=>w.current,reset:()=>{I(!r.validation?.scroll?.required),M(new Map),q(!1),w.current=[],B([])},updateFieldInDocument:C}),[b,g,y,v,r.validation?.scroll?.required,C]),c.jsxs("div",{className:`superdoc-esign-container ${X||""}`,style:Y,children:[c.jsxs("div",{className:"superdoc-esign-document","data-testid":"superdoc-esign-document",children:[z&&c.jsx("div",{className:"superdoc-esign-document-toolbar",children:c.jsx("div",{className:"superdoc-esign-document-controls",children:z})}),c.jsx("div",{ref:j,className:"superdoc-esign-document-viewer","data-testid":"superdoc-scroll-container",style:{height:G,overflow:"auto"}})]}),c.jsxs("div",{className:"superdoc-esign-controls","data-testid":"superdoc-esign-controls",children:[n.signer&&n.signer.length>0&&c.jsx("div",{className:"superdoc-esign-fields","data-testid":"superdoc-esign-fields",children:n.signer.map(se)}),ie]})]})});K.displayName="SuperDocESign";exports.CheckboxInput=L;exports.SignatureInput=W;exports.default=K;
1
+ "use strict";var ce=Object.create;var P=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var de=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty;var ge=(i,c,o,t)=>{if(c&&typeof c=="object"||typeof c=="function")for(let s of ue(c))!pe.call(i,s)&&s!==o&&P(i,s,{get:()=>c[s],enumerable:!(t=le(c,s))||t.enumerable});return i};var me=(i,c,o)=>(o=i!=null?ce(de(i)):{},ge(c||!i||!i.__esModule?P(o,"default",{value:i,enumerable:!0}):o,i));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),r=require("react"),W=i=>{const c=globalThis.document.createElement("canvas"),o=c.getContext("2d"),t=30;o.font=`italic ${t}px cursive`;const u=o.measureText(i).width,f=t*1.3,g=4,j=6;return c.width=Math.ceil(u+g*2)+20,c.height=Math.ceil(f+j*2),o.font=`italic ${t}px cursive`,o.fillStyle="black",o.textAlign="center",o.textBaseline="middle",o.fillText(i,c.width/2,c.height/2),c.toDataURL("image/png")},L=({value:i,onChange:c,isDisabled:o,label:t})=>l.jsxs("div",{className:"superdoc-esign-signature-input",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t&&l.jsx("label",{children:t}),l.jsx("input",{type:"text",value:String(i||""),onChange:s=>c(s.target.value),disabled:o,placeholder:"Type your full name",style:{fontFamily:"cursive",fontSize:"18px"}})]}),K=({value:i,onChange:c,isDisabled:o,label:t})=>l.jsxs("label",{className:"superdoc-esign-checkbox-input",style:{display:"flex",gap:"8px"},children:[l.jsx("input",{type:"checkbox",checked:!!i,onChange:s=>c(s.target.checked),disabled:o}),l.jsx("span",{children:t})]}),fe=i=>({onClick:o,fileName:t,isDisabled:s,isDownloading:u})=>{const f=i?.label||"Download",g=s||u;return l.jsxs("button",{onClick:o,disabled:g,className:`superdoc-esign-btn superdoc-esign-btn--download${u?" superdoc-esign-btn--loading":""}`,style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid #d0d5dd",background:"#ffffff",color:"#333",cursor:g?"not-allowed":"pointer",opacity:g?.7:1,fontSize:"16px",fontWeight:"bold",display:"inline-flex",alignItems:"center",gap:"8px",transition:"opacity 0.2s ease"},children:[u&&l.jsx("span",{className:"superdoc-esign-spinner"}),u?"Downloading...":f,!u&&t&&` (${t})`]})},he=i=>({onClick:o,isValid:t,isDisabled:s,isSubmitting:u})=>{const f=i?.label||"Submit",g=!t||s||u;return l.jsxs("button",{onClick:o,disabled:g,className:`superdoc-esign-btn superdoc-esign-btn--submit${u?" superdoc-esign-btn--loading":""}`,style:{padding:"12px 24px",borderRadius:"6px",border:"none",background:"#007bff",color:"#fff",cursor:g?"not-allowed":"pointer",opacity:g&&!u?.5:1,fontSize:"16px",fontWeight:"bold",display:"inline-flex",alignItems:"center",gap:"8px",transition:"opacity 0.2s ease"},children:[u&&l.jsx("span",{className:"superdoc-esign-spinner superdoc-esign-spinner--light"}),u?"Submitting...":f]})},X=r.forwardRef((i,c)=>{const{eventId:o,document:t,fields:s={},download:u,submit:f,onSubmit:g,onDownload:j,onStateChange:E,onFieldChange:N,onFieldsDiscovered:T,isDisabled:h=!1,className:Y,style:G,documentHeight:J="600px"}=i,[y,F]=r.useState(!t.validation?.scroll?.required),[m,I]=r.useState(new Map),[b,q]=r.useState(!1),[x,A]=r.useState(!1),[k,_]=r.useState(!1),[V,B]=r.useState([]),[U,Q]=r.useState(!1),M=r.useRef(null),R=r.useRef(null),Z=r.useRef(Date.now()),S=r.useRef(s),w=r.useRef([]),$=r.useRef(T);S.current=s,$.current=T,r.useEffect(()=>{w.current=V},[V]);const C=r.useCallback(e=>{if(!R.current?.activeEditor)return;const n=R.current.activeEditor,d=S.current.signer?.find(a=>a.id===e.id);let p;d?.type==="signature"&&e.value?p={json:{type:"image",attrs:{src:typeof e.value=="string"&&e.value.startsWith("data:image/")?e.value:W(String(e.value)),alt:"Signature"}}}:p={text:String(e.value??"")},e.id&&n.commands.updateStructuredContentById(e.id,p)},[]),H=r.useCallback(e=>{if(!e)return;const n=e.helpers.structuredContentCommands.getStructuredContentTags(e.state),d=new Map;S.current.document?.forEach(a=>{a.id&&d.set(a.id,a.value)}),S.current.signer?.forEach(a=>{a.value!==void 0&&d.set(a.id,a.value)});const p=n.map(({node:a})=>({id:a.attrs.id,label:a.attrs.label,value:d.get(a.attrs.id)??a.textContent??""})).filter(a=>a.id);p.length>0&&($.current?.(p),[...S.current.document||[],...S.current.signer||[]].filter(v=>v.value!==void 0).forEach(v=>C({id:v.id,value:v.value})))},[C]),D=e=>{const n={...e,timestamp:new Date().toISOString()},d=globalThis?.__SUPERDOC_AUDIT_MOCK__;d&&d(n);const p=[...w.current,n];return w.current=p,B(p),p};r.useEffect(()=>{if(!M.current)return;let e=!1,n=null;return(async()=>{const{SuperDoc:p}=await import("superdoc");e||(n=new p({selector:M.current,document:t.source,documentMode:"viewing",modules:{comments:!1},layoutMode:t.layoutMode,layoutMargins:t.layoutMargins,onReady:()=>{e||(n?.activeEditor&&H(n.activeEditor),D({type:"ready"}),Q(!0))}}),R.current=n)})(),()=>{e=!0,n&&typeof n.destroy=="function"&&n.destroy(),R.current=null}},[t.source,t.mode,t.layoutMode,t.layoutMargins?.top,t.layoutMargins?.bottom,t.layoutMargins?.left,t.layoutMargins?.right,H]),r.useEffect(()=>{if(!t.validation?.scroll?.required||!U)return;const e=M.current;if(!e)return;const n=()=>{const{scrollTop:d,scrollHeight:p,clientHeight:a}=e,v=d/(p-a);(v>=.95||p<=a)&&(F(!0),D({type:"scroll",data:{percent:Math.round(v*100)}}))};return e.addEventListener("scroll",n),n(),()=>e.removeEventListener("scroll",n)},[t.validation?.scroll?.required,U]);const ee=r.useCallback((e,n)=>{I(d=>{const p=d.get(e),a=new Map(d);return a.set(e,n),C({id:e,value:n}),D({type:"field_change",data:{fieldId:e,value:n,previousValue:p}}),N?.({id:e,value:n,previousValue:p}),a})},[N,C]),O=r.useCallback(()=>t.validation?.scroll?.required&&!y?!1:(s.signer||[]).every(e=>{if(!e.validation?.required)return!0;const n=m.get(e.id);return n&&(typeof n!="string"||n.trim())}),[y,s.signer,m,t.validation?.scroll?.required]);r.useEffect(()=>{const e=O();q(e),E?.({scrolled:y,fields:m,isValid:e,isSubmitting:x})},[y,m,x,O,E]);const te=r.useCallback(async()=>{if(h||k)return;_(!0);const e={eventId:o,documentSource:t.source,fields:{document:s.document||[],signer:(s.signer||[]).map(n=>({id:n.id,value:m.get(n.id)??null}))},fileName:u?.fileName||"document.pdf"};try{await j?.(e)}finally{_(!1)}},[h,k,o,t.source,s,m,u,j]),ne=r.useCallback(async()=>{if(!b||h||x)return;A(!0),D({type:"submit"});const e=D({type:"submit"}),n={eventId:o,timestamp:new Date().toISOString(),duration:Math.floor((Date.now()-Z.current)/1e3),auditTrail:e,documentFields:s.document||[],signerFields:(s.signer||[]).map(d=>({id:d.id,value:m.get(d.id)??null})),isFullyCompleted:b};try{await g(n)}finally{A(!1)}},[b,h,x,o,s,m,g]),se=e=>{const n=e.component||oe(e.type);return l.jsx(n,{value:m.get(e.id)??null,onChange:d=>ee(e.id,d),isDisabled:h,label:e.label},e.id)},oe=e=>{switch(e){case"signature":case"text":return L;case"checkbox":return K}},re=()=>{const e=u?.component||fe(u);return e?l.jsx(e,{onClick:te,fileName:u?.fileName,isDisabled:h,isDownloading:k}):null},ae=()=>{if(t.mode==="download")return null;const e=f?.component||he(f);return l.jsx("div",{className:"superdoc-esign-actions superdoc-esign-form-actions",children:l.jsx(e,{onClick:ne,isValid:b,isDisabled:h,isSubmitting:x})})},z=re(),ie=ae();return r.useImperativeHandle(c,()=>({getState:()=>({scrolled:y,fields:m,isValid:b,isSubmitting:x}),getAuditTrail:()=>w.current,reset:()=>{F(!t.validation?.scroll?.required),I(new Map),q(!1),w.current=[],B([])},updateFieldInDocument:C}),[y,m,b,x,t.validation?.scroll?.required,C]),l.jsxs("div",{className:`superdoc-esign-container ${Y||""}`,style:G,children:[l.jsxs("div",{className:"superdoc-esign-document","data-testid":"superdoc-esign-document",children:[z&&l.jsx("div",{className:"superdoc-esign-document-toolbar",children:l.jsx("div",{className:"superdoc-esign-document-controls",children:z})}),l.jsx("div",{ref:M,className:"superdoc-esign-document-viewer","data-testid":"superdoc-scroll-container",style:{height:J,overflow:"auto"}})]}),l.jsxs("div",{className:"superdoc-esign-controls","data-testid":"superdoc-esign-controls",children:[s.signer&&s.signer.length>0&&l.jsx("div",{className:"superdoc-esign-fields","data-testid":"superdoc-esign-fields",children:s.signer.map(se)}),ie]})]})});X.displayName="SuperDocESign";exports.CheckboxInput=K;exports.SignatureInput=L;exports.default=X;exports.textToImageDataUrl=W;
package/dist/index.mjs CHANGED
@@ -1,24 +1,29 @@
1
- import { jsxs as y, jsx as c } from "react/jsx-runtime";
2
- import { forwardRef as ue, useState as v, useRef as D, useEffect as k, useCallback as N, useImperativeHandle as pe } from "react";
3
- const ge = ({
4
- value: p,
5
- onChange: m,
6
- isDisabled: l,
7
- label: r
8
- }) => /* @__PURE__ */ y(
1
+ import { jsxs as b, jsx as d } from "react/jsx-runtime";
2
+ import { forwardRef as ae, useState as y, useRef as D, useEffect as k, useCallback as M, useImperativeHandle as ce } from "react";
3
+ const le = (u) => {
4
+ const l = globalThis.document.createElement("canvas"), r = l.getContext("2d"), n = 30;
5
+ r.font = `italic ${n}px cursive`;
6
+ const i = r.measureText(u).width, m = n * 1.3, p = 4, E = 6;
7
+ return l.width = Math.ceil(i + p * 2) + 20, l.height = Math.ceil(m + E * 2), r.font = `italic ${n}px cursive`, r.fillStyle = "black", r.textAlign = "center", r.textBaseline = "middle", r.fillText(u, l.width / 2, l.height / 2), l.toDataURL("image/png");
8
+ }, de = ({
9
+ value: u,
10
+ onChange: l,
11
+ isDisabled: r,
12
+ label: n
13
+ }) => /* @__PURE__ */ b(
9
14
  "div",
10
15
  {
11
16
  className: "superdoc-esign-signature-input",
12
17
  style: { display: "flex", flexDirection: "column", gap: "8px" },
13
18
  children: [
14
- r && /* @__PURE__ */ c("label", { children: r }),
15
- /* @__PURE__ */ c(
19
+ n && /* @__PURE__ */ d("label", { children: n }),
20
+ /* @__PURE__ */ d(
16
21
  "input",
17
22
  {
18
23
  type: "text",
19
- value: String(p || ""),
20
- onChange: (i) => m(i.target.value),
21
- disabled: l,
24
+ value: String(u || ""),
25
+ onChange: (o) => l(o.target.value),
26
+ disabled: r,
22
27
  placeholder: "Type your full name",
23
28
  style: {
24
29
  fontFamily: "cursive",
@@ -28,43 +33,43 @@ const ge = ({
28
33
  )
29
34
  ]
30
35
  }
31
- ), me = ({
32
- value: p,
33
- onChange: m,
34
- isDisabled: l,
35
- label: r
36
- }) => /* @__PURE__ */ y("label", { className: "superdoc-esign-checkbox-input", style: { display: "flex", gap: "8px" }, children: [
37
- /* @__PURE__ */ c(
36
+ ), ue = ({
37
+ value: u,
38
+ onChange: l,
39
+ isDisabled: r,
40
+ label: n
41
+ }) => /* @__PURE__ */ b("label", { className: "superdoc-esign-checkbox-input", style: { display: "flex", gap: "8px" }, children: [
42
+ /* @__PURE__ */ d(
38
43
  "input",
39
44
  {
40
45
  type: "checkbox",
41
- checked: !!p,
42
- onChange: (i) => m(i.target.checked),
43
- disabled: l
46
+ checked: !!u,
47
+ onChange: (o) => l(o.target.checked),
48
+ disabled: r
44
49
  }
45
50
  ),
46
- /* @__PURE__ */ c("span", { children: r })
47
- ] }), fe = (p) => ({
48
- onClick: l,
49
- fileName: r,
50
- isDisabled: i,
51
- isDownloading: a
51
+ /* @__PURE__ */ d("span", { children: n })
52
+ ] }), pe = (u) => ({
53
+ onClick: r,
54
+ fileName: n,
55
+ isDisabled: o,
56
+ isDownloading: i
52
57
  }) => {
53
- const b = p?.label || "Download", u = i || a;
54
- return /* @__PURE__ */ y(
58
+ const m = u?.label || "Download", p = o || i;
59
+ return /* @__PURE__ */ b(
55
60
  "button",
56
61
  {
57
- onClick: l,
58
- disabled: u,
59
- className: `superdoc-esign-btn superdoc-esign-btn--download${a ? " superdoc-esign-btn--loading" : ""}`,
62
+ onClick: r,
63
+ disabled: p,
64
+ className: `superdoc-esign-btn superdoc-esign-btn--download${i ? " superdoc-esign-btn--loading" : ""}`,
60
65
  style: {
61
66
  padding: "8px 16px",
62
67
  borderRadius: "6px",
63
68
  border: "1px solid #d0d5dd",
64
69
  background: "#ffffff",
65
70
  color: "#333",
66
- cursor: u ? "not-allowed" : "pointer",
67
- opacity: u ? 0.7 : 1,
71
+ cursor: p ? "not-allowed" : "pointer",
72
+ opacity: p ? 0.7 : 1,
68
73
  fontSize: "16px",
69
74
  fontWeight: "bold",
70
75
  display: "inline-flex",
@@ -73,33 +78,33 @@ const ge = ({
73
78
  transition: "opacity 0.2s ease"
74
79
  },
75
80
  children: [
76
- a && /* @__PURE__ */ c("span", { className: "superdoc-esign-spinner" }),
77
- a ? "Downloading..." : b,
78
- !a && r && ` (${r})`
81
+ i && /* @__PURE__ */ d("span", { className: "superdoc-esign-spinner" }),
82
+ i ? "Downloading..." : m,
83
+ !i && n && ` (${n})`
79
84
  ]
80
85
  }
81
86
  );
82
- }, he = (p) => ({
83
- onClick: l,
84
- isValid: r,
85
- isDisabled: i,
86
- isSubmitting: a
87
+ }, ge = (u) => ({
88
+ onClick: r,
89
+ isValid: n,
90
+ isDisabled: o,
91
+ isSubmitting: i
87
92
  }) => {
88
- const b = p?.label || "Submit", u = !r || i || a;
89
- return /* @__PURE__ */ y(
93
+ const m = u?.label || "Submit", p = !n || o || i;
94
+ return /* @__PURE__ */ b(
90
95
  "button",
91
96
  {
92
- onClick: l,
93
- disabled: u,
94
- className: `superdoc-esign-btn superdoc-esign-btn--submit${a ? " superdoc-esign-btn--loading" : ""}`,
97
+ onClick: r,
98
+ disabled: p,
99
+ className: `superdoc-esign-btn superdoc-esign-btn--submit${i ? " superdoc-esign-btn--loading" : ""}`,
95
100
  style: {
96
101
  padding: "12px 24px",
97
102
  borderRadius: "6px",
98
103
  border: "none",
99
104
  background: "#007bff",
100
105
  color: "#fff",
101
- cursor: u ? "not-allowed" : "pointer",
102
- opacity: u && !a ? 0.5 : 1,
106
+ cursor: p ? "not-allowed" : "pointer",
107
+ opacity: p && !i ? 0.5 : 1,
103
108
  fontSize: "16px",
104
109
  fontWeight: "bold",
105
110
  display: "inline-flex",
@@ -108,21 +113,21 @@ const ge = ({
108
113
  transition: "opacity 0.2s ease"
109
114
  },
110
115
  children: [
111
- a && /* @__PURE__ */ c("span", { className: "superdoc-esign-spinner superdoc-esign-spinner--light" }),
112
- a ? "Submitting..." : b
116
+ i && /* @__PURE__ */ d("span", { className: "superdoc-esign-spinner superdoc-esign-spinner--light" }),
117
+ i ? "Submitting..." : m
113
118
  ]
114
119
  }
115
120
  );
116
- }, ve = ue(
117
- (p, m) => {
121
+ }, me = ae(
122
+ (u, l) => {
118
123
  const {
119
- eventId: l,
120
- document: r,
121
- fields: i = {},
122
- download: a,
123
- submit: b,
124
- onSubmit: u,
125
- onDownload: M,
124
+ eventId: r,
125
+ document: n,
126
+ fields: o = {},
127
+ download: i,
128
+ submit: m,
129
+ onSubmit: p,
130
+ onDownload: E,
126
131
  onStateChange: A,
127
132
  onFieldChange: q,
128
133
  onFieldsDiscovered: V,
@@ -130,248 +135,253 @@ const ge = ({
130
135
  className: X,
131
136
  style: Y,
132
137
  documentHeight: G = "600px"
133
- } = p, [x, B] = v(!r.validation?.scroll?.required), [d, _] = v(/* @__PURE__ */ new Map()), [S, U] = v(!1), [h, $] = v(!1), [I, H] = v(!1), [z, O] = v([]), [W, J] = v(!1), F = D(null), R = D(null), Q = D(Date.now()), w = D(i), T = D([]), j = D(V);
134
- w.current = i, j.current = V, k(() => {
135
- T.current = z;
138
+ } = u, [x, B] = y(!n.validation?.scroll?.required), [g, _] = y(/* @__PURE__ */ new Map()), [S, U] = y(!1), [h, $] = y(!1), [I, H] = y(!1), [z, O] = y([]), [W, J] = y(!1), F = D(null), R = D(null), Q = D(Date.now()), w = D(o), N = D([]), j = D(V);
139
+ w.current = o, j.current = V, k(() => {
140
+ N.current = z;
136
141
  }, [z]);
137
- const C = N((e) => {
142
+ const C = M((e) => {
138
143
  if (!R.current?.activeEditor) return;
139
- const t = R.current.activeEditor, n = w.current.signer?.find((s) => s.id === e.id);
140
- let o;
141
- n?.type === "signature" && e.value ? o = {
144
+ const t = R.current.activeEditor, a = w.current.signer?.find((s) => s.id === e.id);
145
+ let c;
146
+ a?.type === "signature" && e.value ? c = {
142
147
  json: {
143
148
  type: "image",
144
- attrs: { src: typeof e.value == "string" && e.value.startsWith("data:image/") ? e.value : Z(String(e.value)), alt: "Signature" }
149
+ attrs: { src: typeof e.value == "string" && e.value.startsWith("data:image/") ? e.value : le(String(e.value)), alt: "Signature" }
145
150
  }
146
- } : o = { text: String(e.value ?? "") }, e.id && t.commands.updateStructuredContentById(e.id, o);
147
- }, []);
148
- function Z(e) {
149
- const t = globalThis.document.createElement("canvas"), n = t.getContext("2d"), o = 30;
150
- n.font = `italic ${o}px cursive`;
151
- const g = n.measureText(e).width, ce = o * 1.3, le = 4, de = 6;
152
- return t.width = Math.ceil(g + le * 2) + 20, t.height = Math.ceil(ce + de * 2), n.font = `italic ${o}px cursive`, n.fillStyle = "black", n.textAlign = "center", n.textBaseline = "middle", n.fillText(e, t.width / 2, t.height / 2), t.toDataURL("image/png");
153
- }
154
- const L = N(
151
+ } : c = { text: String(e.value ?? "") }, e.id && t.commands.updateStructuredContentById(e.id, c);
152
+ }, []), L = M(
155
153
  (e) => {
156
154
  if (!e) return;
157
155
  const t = e.helpers.structuredContentCommands.getStructuredContentTags(
158
156
  e.state
159
- ), n = /* @__PURE__ */ new Map();
157
+ ), a = /* @__PURE__ */ new Map();
160
158
  w.current.document?.forEach((s) => {
161
- s.id && n.set(s.id, s.value);
159
+ s.id && a.set(s.id, s.value);
162
160
  }), w.current.signer?.forEach((s) => {
163
- s.value !== void 0 && n.set(s.id, s.value);
161
+ s.value !== void 0 && a.set(s.id, s.value);
164
162
  });
165
- const o = t.map(({ node: s }) => ({
163
+ const c = t.map(({ node: s }) => ({
166
164
  id: s.attrs.id,
167
165
  label: s.attrs.label,
168
- value: n.get(s.attrs.id) ?? s.textContent ?? ""
166
+ value: a.get(s.attrs.id) ?? s.textContent ?? ""
169
167
  })).filter((s) => s.id);
170
- o.length > 0 && (j.current?.(o), [
168
+ c.length > 0 && (j.current?.(c), [
171
169
  ...w.current.document || [],
172
170
  ...w.current.signer || []
173
- ].filter((g) => g.value !== void 0).forEach(
174
- (g) => C({
175
- id: g.id,
176
- value: g.value
171
+ ].filter((v) => v.value !== void 0).forEach(
172
+ (v) => C({
173
+ id: v.id,
174
+ value: v.value
177
175
  })
178
176
  ));
179
177
  },
180
178
  [C]
181
- ), E = (e) => {
179
+ ), T = (e) => {
182
180
  const t = {
183
181
  ...e,
184
182
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
185
- }, n = globalThis?.__SUPERDOC_AUDIT_MOCK__;
186
- n && n(t);
187
- const o = [...T.current, t];
188
- return T.current = o, O(o), o;
183
+ }, a = globalThis?.__SUPERDOC_AUDIT_MOCK__;
184
+ a && a(t);
185
+ const c = [...N.current, t];
186
+ return N.current = c, O(c), c;
189
187
  };
190
188
  k(() => {
191
189
  if (!F.current) return;
192
190
  let e = !1, t = null;
193
191
  return (async () => {
194
- const { SuperDoc: o } = await import("superdoc");
195
- e || (t = new o({
192
+ const { SuperDoc: c } = await import("superdoc");
193
+ e || (t = new c({
196
194
  selector: F.current,
197
- document: r.source,
195
+ document: n.source,
198
196
  documentMode: "viewing",
199
197
  modules: {
200
198
  comments: !1
201
199
  },
200
+ // @ts-expect-error - layoutMode is not supported in SuperDoc v1.1.0 yet
201
+ layoutMode: n.layoutMode,
202
+ layoutMargins: n.layoutMargins,
202
203
  onReady: () => {
203
- e || (t?.activeEditor && L(t.activeEditor), E({ type: "ready" }), J(!0));
204
+ e || (t?.activeEditor && L(t.activeEditor), T({ type: "ready" }), J(!0));
204
205
  }
205
206
  }), R.current = t);
206
207
  })(), () => {
207
208
  e = !0, t && typeof t.destroy == "function" && t.destroy(), R.current = null;
208
209
  };
209
- }, [r.source, r.mode, L]), k(() => {
210
- if (!r.validation?.scroll?.required || !W) return;
210
+ }, [
211
+ n.source,
212
+ n.mode,
213
+ n.layoutMode,
214
+ n.layoutMargins?.top,
215
+ n.layoutMargins?.bottom,
216
+ n.layoutMargins?.left,
217
+ n.layoutMargins?.right,
218
+ L
219
+ ]), k(() => {
220
+ if (!n.validation?.scroll?.required || !W) return;
211
221
  const e = F.current;
212
222
  if (!e) return;
213
223
  const t = () => {
214
- const { scrollTop: n, scrollHeight: o, clientHeight: s } = e, g = n / (o - s);
215
- (g >= 0.95 || o <= s) && (B(!0), E({
224
+ const { scrollTop: a, scrollHeight: c, clientHeight: s } = e, v = a / (c - s);
225
+ (v >= 0.95 || c <= s) && (B(!0), T({
216
226
  type: "scroll",
217
- data: { percent: Math.round(g * 100) }
227
+ data: { percent: Math.round(v * 100) }
218
228
  }));
219
229
  };
220
230
  return e.addEventListener("scroll", t), t(), () => e.removeEventListener("scroll", t);
221
- }, [r.validation?.scroll?.required, W]);
222
- const ee = N(
231
+ }, [n.validation?.scroll?.required, W]);
232
+ const Z = M(
223
233
  (e, t) => {
224
- _((n) => {
225
- const o = n.get(e), s = new Map(n);
234
+ _((a) => {
235
+ const c = a.get(e), s = new Map(a);
226
236
  return s.set(e, t), C({
227
237
  id: e,
228
238
  value: t
229
- }), E({
239
+ }), T({
230
240
  type: "field_change",
231
- data: { fieldId: e, value: t, previousValue: o }
241
+ data: { fieldId: e, value: t, previousValue: c }
232
242
  }), q?.({
233
243
  id: e,
234
244
  value: t,
235
- previousValue: o
245
+ previousValue: c
236
246
  }), s;
237
247
  });
238
248
  },
239
249
  [q, C]
240
- ), P = N(() => r.validation?.scroll?.required && !x ? !1 : (i.signer || []).every((e) => {
250
+ ), P = M(() => n.validation?.scroll?.required && !x ? !1 : (o.signer || []).every((e) => {
241
251
  if (!e.validation?.required) return !0;
242
- const t = d.get(e.id);
252
+ const t = g.get(e.id);
243
253
  return t && (typeof t != "string" || t.trim());
244
- }), [x, i.signer, d, r.validation?.scroll?.required]);
254
+ }), [x, o.signer, g, n.validation?.scroll?.required]);
245
255
  k(() => {
246
256
  const e = P();
247
257
  U(e), A?.({
248
258
  scrolled: x,
249
- fields: d,
259
+ fields: g,
250
260
  isValid: e,
251
261
  isSubmitting: h
252
262
  });
253
- }, [x, d, h, P, A]);
254
- const te = N(async () => {
263
+ }, [x, g, h, P, A]);
264
+ const ee = M(async () => {
255
265
  if (f || I) return;
256
266
  H(!0);
257
267
  const e = {
258
- eventId: l,
259
- documentSource: r.source,
268
+ eventId: r,
269
+ documentSource: n.source,
260
270
  fields: {
261
- document: i.document || [],
262
- signer: (i.signer || []).map((t) => ({
271
+ document: o.document || [],
272
+ signer: (o.signer || []).map((t) => ({
263
273
  id: t.id,
264
- value: d.get(t.id) ?? null
274
+ value: g.get(t.id) ?? null
265
275
  }))
266
276
  },
267
- fileName: a?.fileName || "document.pdf"
277
+ fileName: i?.fileName || "document.pdf"
268
278
  };
269
279
  try {
270
- await M?.(e);
280
+ await E?.(e);
271
281
  } finally {
272
282
  H(!1);
273
283
  }
274
284
  }, [
275
285
  f,
276
286
  I,
277
- l,
278
- r.source,
287
+ r,
288
+ n.source,
289
+ o,
290
+ g,
279
291
  i,
280
- d,
281
- a,
282
- M
283
- ]), ne = N(async () => {
292
+ E
293
+ ]), te = M(async () => {
284
294
  if (!S || f || h) return;
285
- $(!0), E({ type: "submit" });
286
- const e = E({ type: "submit" }), t = {
287
- eventId: l,
295
+ $(!0), T({ type: "submit" });
296
+ const e = T({ type: "submit" }), t = {
297
+ eventId: r,
288
298
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
289
299
  duration: Math.floor((Date.now() - Q.current) / 1e3),
290
300
  auditTrail: e,
291
- documentFields: i.document || [],
292
- signerFields: (i.signer || []).map((n) => ({
293
- id: n.id,
294
- value: d.get(n.id) ?? null
301
+ documentFields: o.document || [],
302
+ signerFields: (o.signer || []).map((a) => ({
303
+ id: a.id,
304
+ value: g.get(a.id) ?? null
295
305
  })),
296
306
  isFullyCompleted: S
297
307
  };
298
308
  try {
299
- await u(t);
309
+ await p(t);
300
310
  } finally {
301
311
  $(!1);
302
312
  }
303
- }, [S, f, h, l, i, d, u]), se = (e) => {
304
- const t = e.component || re(e.type);
305
- return /* @__PURE__ */ c(
313
+ }, [S, f, h, r, o, g, p]), ne = (e) => {
314
+ const t = e.component || se(e.type);
315
+ return /* @__PURE__ */ d(
306
316
  t,
307
317
  {
308
- value: d.get(e.id) ?? null,
309
- onChange: (n) => ee(e.id, n),
318
+ value: g.get(e.id) ?? null,
319
+ onChange: (a) => Z(e.id, a),
310
320
  isDisabled: f,
311
321
  label: e.label
312
322
  },
313
323
  e.id
314
324
  );
315
- }, re = (e) => {
325
+ }, se = (e) => {
316
326
  switch (e) {
317
327
  case "signature":
318
328
  case "text":
319
- return ge;
329
+ return de;
320
330
  case "checkbox":
321
- return me;
331
+ return ue;
322
332
  }
323
333
  }, oe = () => {
324
- const e = a?.component || fe(a);
325
- return e ? /* @__PURE__ */ c(
334
+ const e = i?.component || pe(i);
335
+ return e ? /* @__PURE__ */ d(
326
336
  e,
327
337
  {
328
- onClick: te,
329
- fileName: a?.fileName,
338
+ onClick: ee,
339
+ fileName: i?.fileName,
330
340
  isDisabled: f,
331
341
  isDownloading: I
332
342
  }
333
343
  ) : null;
334
- }, ie = () => {
335
- if (r.mode === "download")
344
+ }, re = () => {
345
+ if (n.mode === "download")
336
346
  return null;
337
- const e = b?.component || he(b);
338
- return /* @__PURE__ */ c("div", { className: "superdoc-esign-actions superdoc-esign-form-actions", children: /* @__PURE__ */ c(
347
+ const e = m?.component || ge(m);
348
+ return /* @__PURE__ */ d("div", { className: "superdoc-esign-actions superdoc-esign-form-actions", children: /* @__PURE__ */ d(
339
349
  e,
340
350
  {
341
- onClick: ne,
351
+ onClick: te,
342
352
  isValid: S,
343
353
  isDisabled: f,
344
354
  isSubmitting: h
345
355
  }
346
356
  ) });
347
- }, K = oe(), ae = ie();
348
- return pe(
349
- m,
357
+ }, K = oe(), ie = re();
358
+ return ce(
359
+ l,
350
360
  () => ({
351
361
  getState: () => ({
352
362
  scrolled: x,
353
- fields: d,
363
+ fields: g,
354
364
  isValid: S,
355
365
  isSubmitting: h
356
366
  }),
357
- getAuditTrail: () => T.current,
367
+ getAuditTrail: () => N.current,
358
368
  reset: () => {
359
- B(!r.validation?.scroll?.required), _(/* @__PURE__ */ new Map()), U(!1), T.current = [], O([]);
369
+ B(!n.validation?.scroll?.required), _(/* @__PURE__ */ new Map()), U(!1), N.current = [], O([]);
360
370
  },
361
371
  updateFieldInDocument: C
362
372
  }),
363
373
  [
364
374
  x,
365
- d,
375
+ g,
366
376
  S,
367
377
  h,
368
- r.validation?.scroll?.required,
378
+ n.validation?.scroll?.required,
369
379
  C
370
380
  ]
371
- ), /* @__PURE__ */ y("div", { className: `superdoc-esign-container ${X || ""}`, style: Y, children: [
372
- /* @__PURE__ */ y("div", { className: "superdoc-esign-document", "data-testid": "superdoc-esign-document", children: [
373
- K && /* @__PURE__ */ c("div", { className: "superdoc-esign-document-toolbar", children: /* @__PURE__ */ c("div", { className: "superdoc-esign-document-controls", children: K }) }),
374
- /* @__PURE__ */ c(
381
+ ), /* @__PURE__ */ b("div", { className: `superdoc-esign-container ${X || ""}`, style: Y, children: [
382
+ /* @__PURE__ */ b("div", { className: "superdoc-esign-document", "data-testid": "superdoc-esign-document", children: [
383
+ K && /* @__PURE__ */ d("div", { className: "superdoc-esign-document-toolbar", children: /* @__PURE__ */ d("div", { className: "superdoc-esign-document-controls", children: K }) }),
384
+ /* @__PURE__ */ d(
375
385
  "div",
376
386
  {
377
387
  ref: F,
@@ -381,16 +391,17 @@ const ge = ({
381
391
  }
382
392
  )
383
393
  ] }),
384
- /* @__PURE__ */ y("div", { className: "superdoc-esign-controls", "data-testid": "superdoc-esign-controls", children: [
385
- i.signer && i.signer.length > 0 && /* @__PURE__ */ c("div", { className: "superdoc-esign-fields", "data-testid": "superdoc-esign-fields", children: i.signer.map(se) }),
386
- ae
394
+ /* @__PURE__ */ b("div", { className: "superdoc-esign-controls", "data-testid": "superdoc-esign-controls", children: [
395
+ o.signer && o.signer.length > 0 && /* @__PURE__ */ d("div", { className: "superdoc-esign-fields", "data-testid": "superdoc-esign-fields", children: o.signer.map(ne) }),
396
+ ie
387
397
  ] })
388
398
  ] });
389
399
  }
390
400
  );
391
- ve.displayName = "SuperDocESign";
401
+ me.displayName = "SuperDocESign";
392
402
  export {
393
- me as CheckboxInput,
394
- ge as SignatureInput,
395
- ve as default
403
+ ue as CheckboxInput,
404
+ de as SignatureInput,
405
+ me as default,
406
+ le as textToImageDataUrl
396
407
  };
package/dist/types.d.ts CHANGED
@@ -43,6 +43,12 @@ export interface SubmitConfig {
43
43
  label?: string;
44
44
  component?: React.ComponentType<SubmitButtonProps>;
45
45
  }
46
+ export interface LayoutMargins {
47
+ top?: number;
48
+ bottom?: number;
49
+ left?: number;
50
+ right?: number;
51
+ }
46
52
  export interface DocumentConfig {
47
53
  source: string | File | Blob;
48
54
  mode?: 'full' | 'download';
@@ -51,6 +57,18 @@ export interface DocumentConfig {
51
57
  required?: boolean;
52
58
  };
53
59
  };
60
+ /**
61
+ * Document layout mode:
62
+ * - 'paginated' (default): Fixed page width, shows page breaks
63
+ * - 'responsive': 100% width, text reflows to fit container (useful for mobile/accessibility)
64
+ * Note: 'responsive' takes precedence over pagination - pagination is ignored when layoutMode is 'responsive'
65
+ */
66
+ layoutMode?: 'responsive' | 'paginated';
67
+ /**
68
+ * Custom margins in pixels for responsive layout mode.
69
+ * Only applies when layoutMode is 'responsive'.
70
+ */
71
+ layoutMargins?: LayoutMargins;
54
72
  }
55
73
  export interface SuperDocESignProps {
56
74
  eventId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAEtE,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,aAAc,SAAQ,cAAc;IACnD,KAAK,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,UAAU,CAAC,EAAE;QACX,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;IACF,SAAS,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC;CACtD;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;CACxB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+1 @@
1
+ {"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/utils/signature.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,KAAG,MAyBjD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/esign",
3
- "version": "1.4.0-next.2",
3
+ "version": "1.4.0-next.4",
4
4
  "description": "React eSignature component for SuperDoc",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -56,7 +56,7 @@
56
56
  "peerDependencies": {
57
57
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
58
58
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
59
- "superdoc": "^0.29.0"
59
+ "superdoc": "^1.1.0"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@commitlint/cli": "^20.1.0",
@@ -81,7 +81,7 @@
81
81
  "react": "^19.2.0",
82
82
  "react-dom": "^19.2.0",
83
83
  "semantic-release": "^24.2.9",
84
- "superdoc": "^0.35.3",
84
+ "superdoc": "1.1.0",
85
85
  "typescript": "^5.9.2",
86
86
  "typescript-eslint": "^8.44.1",
87
87
  "vite": "^7.1.7",