@superdoc-dev/esign 1.3.1 → 1.4.1

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