@superdoc-dev/esign 1.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,205 @@
1
+ # @superdoc-dev/esign
2
+
3
+ A React eSignature component for SuperDoc that handles document acceptance workflows.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @superdoc-dev/esign superdoc
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```jsx
14
+ import React, { useRef, useState } from 'react';
15
+ import SuperDocESign from '@superdoc-dev/esign';
16
+ import 'superdoc/dist/style.css';
17
+
18
+ function App() {
19
+ const esignRef = useRef();
20
+ const [status, setStatus] = useState({});
21
+
22
+ const handleAccept = async () => {
23
+ const auditData = await esignRef.current?.accept();
24
+ if (auditData) {
25
+ // Send to your API
26
+ await api.saveSignature(auditData);
27
+ }
28
+ };
29
+
30
+ return (
31
+ <div>
32
+ {/* Document viewer */}
33
+ <SuperDocESign
34
+ ref={esignRef}
35
+ document="https://example.com/agreement.docx"
36
+ requirements={{
37
+ scroll: true,
38
+ signature: true,
39
+ consents: ['terms', 'privacy']
40
+ }}
41
+ onChange={setStatus}
42
+ onAccept={handleAccept}
43
+ />
44
+
45
+ {/* Your signature UI */}
46
+ <input
47
+ type="text"
48
+ data-esign-signature
49
+ placeholder="Type your full name"
50
+ disabled={!status.scroll}
51
+ />
52
+
53
+ {/* Your consent UI */}
54
+ <label>
55
+ <input
56
+ type="checkbox"
57
+ data-esign-consent="terms"
58
+ disabled={!status.scroll || !status.signature}
59
+ />
60
+ I accept the terms
61
+ </label>
62
+
63
+ {/* Accept button */}
64
+ <button
65
+ onClick={() => esignRef.current?.accept()}
66
+ disabled={!status.isValid}
67
+ >
68
+ Accept Agreement
69
+ </button>
70
+ </div>
71
+ );
72
+ }
73
+ ```
74
+
75
+ ## Props
76
+
77
+ | Prop | Type | Description |
78
+ |------|------|-------------|
79
+ | `document` | `string \| File \| Blob` | Document to display |
80
+ | `requirements` | `Object` | What users must complete |
81
+ | `fields` | `Array` | Initial field values |
82
+ | `signatureSelector` | `string` | CSS selector for signature element (default: `[data-esign-signature]`) |
83
+ | `consentSelector` | `string` | CSS selector for consent checkboxes (default: `[data-esign-consent]`) |
84
+ | `onChange` | `(status) => void` | Called when requirements change |
85
+ | `onAccept` | `(data) => void` | Called when document is accepted |
86
+ | `onReady` | `() => void` | Called when component is ready |
87
+ | `onFieldsDiscovered` | `(fields) => void` | Called when document fields are found |
88
+
89
+ ## Methods (via ref)
90
+
91
+ - `accept()` - Process acceptance and return audit data
92
+ - `reset()` - Clear all state
93
+ - `updateFields(fields)` - Update document field values
94
+ - `getStatus()` - Get current requirement status
95
+ - `getFields()` - Get all document fields
96
+
97
+ ## Requirements
98
+
99
+ Configure what users must complete before accepting:
100
+
101
+ ```jsx
102
+ <SuperDocESign
103
+ requirements={{
104
+ scroll: true, // Must scroll to bottom
105
+ signature: true, // Must provide signature
106
+ consents: ['terms', 'privacy'] // Must check these boxes
107
+ }}
108
+ />
109
+ ```
110
+
111
+ ## Signature Input
112
+
113
+ Use the `data-esign-signature` attribute on any input or canvas:
114
+
115
+ ```jsx
116
+ {/* Text input */}
117
+ <input type="text" data-esign-signature placeholder="Type your name" />
118
+
119
+ {/* Canvas signature pad */}
120
+ <canvas data-esign-signature width="400" height="200" />
121
+
122
+ {/* Custom component */}
123
+ <SignaturePad data-esign-signature data-signed={isSigned} />
124
+ ```
125
+
126
+ ## Consent Checkboxes
127
+
128
+ Use the `data-esign-consent` attribute with a unique name:
129
+
130
+ ```jsx
131
+ <label>
132
+ <input type="checkbox" data-esign-consent="terms" />
133
+ I accept the terms
134
+ </label>
135
+
136
+ <label>
137
+ <input type="checkbox" data-esign-consent="privacy" />
138
+ I acknowledge the privacy policy
139
+ </label>
140
+ ```
141
+
142
+ ## Field Population
143
+
144
+ Replace placeholders in your document with dynamic data:
145
+
146
+ ```jsx
147
+ <SuperDocESign
148
+ fields={[
149
+ { alias: 'userName', value: 'John Doe' },
150
+ { alias: 'date', value: new Date().toLocaleDateString() },
151
+ { alias: 'company', value: 'Acme Inc.' }
152
+ ]}
153
+ />
154
+ ```
155
+
156
+ ## Audit Data
157
+
158
+ When a user accepts, you receive comprehensive audit data:
159
+
160
+ ```typescript
161
+ {
162
+ timestamp: "2024-01-15T10:30:00.000Z",
163
+ duration: 45, // seconds spent on document
164
+ fields: [
165
+ { id: "field1", alias: "userName", value: "John Doe" }
166
+ ],
167
+ scrolled: true,
168
+ signed: true,
169
+ consents: ["terms", "privacy"],
170
+ signatureImage: "data:image/png;base64,..." // if canvas
171
+ }
172
+ ```
173
+
174
+ ## TypeScript
175
+
176
+ Full TypeScript support with exported types:
177
+
178
+ ```typescript
179
+ import SuperDocESign, {
180
+ SuperDocESignHandle,
181
+ Status,
182
+ AuditData,
183
+ FieldUpdate
184
+ } from '@superdoc-dev/esign';
185
+
186
+ const esignRef = useRef<SuperDocESignHandle>(null);
187
+ const [status, setStatus] = useState<Status>({
188
+ scroll: false,
189
+ signature: false,
190
+ consents: [],
191
+ isValid: false
192
+ });
193
+
194
+ const handleAccept = async (data: AuditData) => {
195
+ // Process acceptance
196
+ };
197
+ ```
198
+
199
+ ## Examples
200
+
201
+ See the [examples](./examples) directory for complete implementations.
202
+
203
+ ## License
204
+
205
+ MIT
@@ -0,0 +1,62 @@
1
+ import { default as React } from 'react';
2
+ import { SuperDoc } from 'superdoc';
3
+ export interface FieldUpdate {
4
+ id?: string;
5
+ alias?: string;
6
+ value: any;
7
+ }
8
+ export interface Status {
9
+ scroll: boolean;
10
+ signature: boolean;
11
+ consents: string[];
12
+ isValid: boolean;
13
+ }
14
+ export interface AuditData {
15
+ timestamp: string;
16
+ duration: number;
17
+ fields: FieldUpdate[];
18
+ scrolled: boolean;
19
+ signed: boolean;
20
+ consents: string[];
21
+ signatureImage?: string;
22
+ }
23
+ export interface FieldInfo {
24
+ id: string;
25
+ label?: string;
26
+ value?: any;
27
+ }
28
+ export interface DownloadRequestData {
29
+ blob: Blob;
30
+ fields: FieldInfo[];
31
+ }
32
+ export interface SuperDocESignProps {
33
+ document: string | File | Blob;
34
+ requirements?: {
35
+ scroll?: boolean;
36
+ signature?: boolean;
37
+ consents?: string[];
38
+ };
39
+ fields?: FieldUpdate[];
40
+ signatureSelector?: string;
41
+ consentSelector?: string;
42
+ downloadSelector?: string;
43
+ onReady?: () => void;
44
+ onChange?: (status: Status) => void;
45
+ onAccept?: (data: AuditData) => void | Promise<void>;
46
+ onFieldsDiscovered?: (fields: FieldInfo[]) => void;
47
+ onDownloadRequest?: (data: DownloadRequestData) => void | Promise<void>;
48
+ className?: string;
49
+ style?: React.CSSProperties;
50
+ }
51
+ export interface SuperDocESignHandle {
52
+ accept: () => Promise<AuditData | false>;
53
+ reset: () => void;
54
+ updateFields: (fields: FieldUpdate[]) => void;
55
+ getStatus: () => Status;
56
+ getFields: () => FieldInfo[];
57
+ requestDownload: () => Promise<DownloadRequestData | false>;
58
+ superdoc: SuperDoc | null;
59
+ }
60
+ declare const SuperDocESign: React.ForwardRefExoticComponent<SuperDocESignProps & React.RefAttributes<SuperDocESignHandle>>;
61
+ export default SuperDocESign;
62
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,MAAM,WAAW,WAAW;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,GAAG,CAAC;CACZ;AAED,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,GAAG,CAAC;CACb;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IAEjC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAG/B,YAAY,CAAC,EAAE;QACb,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;IAGF,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IAGvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAG1B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IACnD,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAGxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC;IACzC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,YAAY,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;IAC9C,SAAS,EAAE,MAAM,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,SAAS,EAAE,CAAC;IAC7B,eAAe,EAAE,MAAM,OAAO,CAAC,mBAAmB,GAAG,KAAK,CAAC,CAAC;IAC5D,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC3B;AAED,QAAA,MAAM,aAAa,gGAiclB,CAAC;AAIF,eAAe,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";var re=Object.create;var B=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var se=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var ce=(l,s,d,f)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of ae(s))!oe.call(l,o)&&o!==d&&B(l,o,{get:()=>s[o],enumerable:!(f=ne(s,o))||f.enumerable});return l};var le=(l,s,d)=>(d=l!=null?re(se(l)):{},ce(s||!l||!l.__esModule?B(d,"default",{value:l,enumerable:!0}):d,l));const c=require("react");var G={exports:{}},L={};/**
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 Z;function ue(){if(Z)return L;Z=1;var l=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function d(f,o,m){var S=null;if(m!==void 0&&(S=""+m),o.key!==void 0&&(S=""+o.key),"key"in o){m={};for(var h in o)h!=="key"&&(m[h]=o[h])}else m=o;return o=m.ref,{$$typeof:l,type:f,key:S,ref:o!==void 0?o:null,props:m}}return L.Fragment=s,L.jsx=d,L.jsxs=d,L}var F={};/**
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 Q;function ie(){return Q||(Q=1,process.env.NODE_ENV!=="production"&&(function(){function l(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===_?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case E:return"Fragment";case R:return"Profiler";case W:return"StrictMode";case k:return"Suspense";case q:return"SuspenseList";case J:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case $:return"Portal";case v:return e.displayName||"Context";case U:return(e._context.displayName||"Context")+".Consumer";case z:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case T:return t=e.displayName||null,t!==null?t:l(e.type)||"Memo";case g:t=e._payload,e=e._init;try{return l(e(t))}catch{}}return null}function s(e){return""+e}function d(e){try{s(e);var t=!1}catch{t=!0}if(t){t=console;var r=t.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),s(e)}}function f(e){if(e===E)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===g)return"<...>";try{var t=l(e);return t?"<"+t+">":"<...>"}catch{return"<...>"}}function o(){var e=x.A;return e===null?null:e.getOwner()}function m(){return Error("react-stack-top-frame")}function S(e){if(C.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function h(e,t){function r(){P||(P=!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)",t))}r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}function Y(){var e=l(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 H(e,t,r,n,u,i){var a=r.ref;return e={$$typeof:p,type:e,key:t,props:r,_owner:n},(a!==void 0?a:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:Y}):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:u}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function A(e,t,r,n,u,i){var a=t.children;if(a!==void 0)if(n)if(X(a)){for(n=0;n<a.length;n++)M(a[n]);Object.freeze&&Object.freeze(a)}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 M(a);if(C.call(t,"key")){a=l(e);var b=Object.keys(t).filter(function(te){return te!=="key"});n=0<b.length?"{key: someKey, "+b.join(": ..., ")+": ...}":"{key: someKey}",w[a+n]||(b=0<b.length?"{"+b.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} />`,n,a,b,a),w[a+n]=!0)}if(a=null,r!==void 0&&(d(r),a=""+r),S(t)&&(d(t.key),a=""+t.key),"key"in t){r={};for(var I in t)I!=="key"&&(r[I]=t[I])}else r=t;return a&&h(r,typeof e=="function"?e.displayName||e.name||"Unknown":e),H(e,a,r,o(),u,i)}function M(e){V(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===g&&(e._payload.status==="fulfilled"?V(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function V(e){return typeof e=="object"&&e!==null&&e.$$typeof===p}var y=c,p=Symbol.for("react.transitional.element"),$=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),W=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),U=Symbol.for("react.consumer"),v=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),q=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),_=Symbol.for("react.client.reference"),x=y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,C=Object.prototype.hasOwnProperty,X=Array.isArray,O=console.createTask?console.createTask:function(){return null};y={react_stack_bottom_frame:function(e){return e()}};var P,N={},j=y.react_stack_bottom_frame.bind(y,m)(),D=O(f(m)),w={};F.Fragment=E,F.jsx=function(e,t,r){var n=1e4>x.recentlyCreatedOwnerStacks++;return A(e,t,r,!1,n?Error("react-stack-top-frame"):j,n?O(f(e)):D)},F.jsxs=function(e,t,r){var n=1e4>x.recentlyCreatedOwnerStacks++;return A(e,t,r,!0,n?Error("react-stack-top-frame"):j,n?O(f(e)):D)}})()),F}var K;function fe(){return K||(K=1,process.env.NODE_ENV==="production"?G.exports=ue():G.exports=ie()),G.exports}var de=fe();const ee=c.forwardRef(({document:l,requirements:s={},fields:d=[],signatureSelector:f="[data-esign-signature]",consentSelector:o="[data-esign-consent]",downloadSelector:m="[data-esign-download]",onReady:S,onChange:h,onAccept:Y,onFieldsDiscovered:H,onDownloadRequest:A,className:M,style:V},y)=>{const[p,$]=c.useState(!1),[E,W]=c.useState(!1),[R,U]=c.useState(new Set),[v,z]=c.useState(new Map),[k,q]=c.useState(!1),T=c.useRef(null),g=c.useRef(null),J=c.useRef(Date.now()),_=c.useCallback(()=>{const t=(s.consents||[]).every(r=>R.has(r));return{scroll:!s.scroll||p,signature:!s.signature||E,consents:Array.from(R),isValid:(!s.scroll||p)&&(!s.signature||E)&&t}},[p,E,R,s]);c.useEffect(()=>T.current?((async()=>{const{SuperDoc:t}=await import("superdoc"),r=new t({selector:T.current,document:l,documentMode:"viewing",onReady:()=>{q(!0),x(r),S?.()},onException:({error:n})=>{console.error("SuperDoc error:",n)}});g.current=r})(),()=>{g.current?.destroy?.(),g.current=null}):void 0,[l]);const x=e=>{if(!e.activeEditor)return;const t=e.activeEditor,r=t.helpers.structuredContentCommands.getStructuredContentTags(t.state),n=new Map;d.forEach(i=>{const a=i.id||i.alias;a&&n.set(a,i.value)});const u=r.map(({node:i})=>{const a=i.attrs.id,b=i.attrs.alias,I=n.get(a)??n.get(b);return{id:a,label:b,value:I??i.textContent??""}});if(u.length>0){const i=new Map(u.map(a=>[a.id,a]));z(i),H?.(u),d.forEach(a=>{C(a)})}},C=e=>{if(!g.current?.activeEditor)return;const t=g.current.activeEditor,r=String(e.value);e.id?t.commands.updateStructuredContentById(e.id,{text:r}):e.alias&&t.commands.updateStructuredContentByAlias(e.alias,{text:r})};c.useEffect(()=>{if(!s.scroll||!k)return;const e=T.current;if(!e)return;const t=()=>{const{scrollTop:r,scrollHeight:n,clientHeight:u}=e;(r/(n-u)>=.95||n<=u)&&$(!0)};return e.addEventListener("scroll",t),t(),()=>e.removeEventListener("scroll",t)},[s.scroll,k]),c.useEffect(()=>{if(!s.signature)return;const e=()=>{const n=globalThis.document.querySelector(f);if(!n)return;const u=X(n);W(u)},t=new MutationObserver(e);t.observe(globalThis.document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value","data-signed"]});const r=n=>{n.target.matches(f)&&e()};return globalThis.document.addEventListener("input",r,!0),globalThis.document.addEventListener("change",r,!0),e(),()=>{t.disconnect(),globalThis.document.removeEventListener("input",r,!0),globalThis.document.removeEventListener("change",r,!0)}},[s.signature,f]),c.useEffect(()=>{if(!s.consents||s.consents.length===0)return;const e=()=>{const r=globalThis.document.querySelectorAll(o),n=new Set;r.forEach(u=>{const i=u.name||u.dataset.esignConsent||u.id;i&&u.checked&&n.add(i)}),U(n)},t=r=>{r.target.matches(o)&&e()};return globalThis.document.addEventListener("change",t,!0),e(),()=>{globalThis.document.removeEventListener("change",t,!0)}},[s.consents,o]);const X=e=>{if(!e)return!1;if(e.tagName==="CANVAS"){const t=e,r=t.getContext("2d");return r?r.getImageData(0,0,t.width,t.height).data.some(u=>u!==0&&u!==255):!1}return"value"in e?!!e.value?.trim():e.dataset.signed==="true"},O=()=>{const e=globalThis.document.querySelector(f);if(e?.dataset.signatureImage)return e.dataset.signatureImage;if(e?.tagName==="CANVAS")return e.toDataURL("image/png")};c.useEffect(()=>{const e=_();h?.(e)},[p,E,R,s,_,h]);const P=c.useCallback(async()=>{if(!_().isValid)return!1;const t=Array.from(v.values()).map(n=>({id:n.id,alias:n.label,value:n.value})),r={timestamp:new Date().toISOString(),duration:Math.round((Date.now()-J.current)/1e3),fields:t,scrolled:p,signed:E,consents:Array.from(R),signatureImage:O()};return await Y?.(r),r},[v,p,E,R,_,Y]),N=c.useCallback(()=>{$(!1),W(!1),U(new Set),J.current=Date.now(),T.current&&(T.current.scrollTop=0);const e=globalThis.document.querySelector(f);e&&(e.tagName==="CANVAS"?e.getContext("2d")?.clearRect(0,0,e.clientWidth,e.clientHeight):"value"in e&&(e.value=""),e.dataset.signed="false"),globalThis.document.querySelectorAll(o).forEach(r=>{r.checked=!1})},[f,o]),j=c.useCallback(e=>{e.forEach(t=>{C(t);const r=v.get(t.id||"");r&&(r.value=t.value,z(new Map(v)))})},[v]),D=c.useCallback(()=>Array.from(v.values()),[v]),w=c.useCallback(async()=>{if(!g.current)return!1;try{const e=await g.current.export({exportType:["docx"],isFinalDoc:!0,triggerDownload:!1});if(!e)return!1;const t={blob:e,fields:Array.from(v.values())};return await A?.(t),t}catch(e){return console.error("Download request failed:",e),!1}},[v,A]);return c.useEffect(()=>{if(!k)return;const e=r=>{r.preventDefault(),w()},t=globalThis.document.querySelectorAll(m);return t.forEach(r=>{r.addEventListener("click",e)}),()=>{t.forEach(r=>{r.removeEventListener("click",e)})}},[m,k,w]),c.useImperativeHandle(y,()=>({accept:P,reset:N,updateFields:j,getStatus:_,getFields:D,requestDownload:w,superdoc:g.current}),[P,N,j,_,D,w]),de.jsx("div",{ref:T,className:`superdoc-esign ${M||""}`,"data-superdoc":"esign",style:V})});ee.displayName="SuperDocESign";module.exports=ee;
package/dist/index.mjs ADDED
@@ -0,0 +1,523 @@
1
+ import ne, { forwardRef as ae, useState as F, useRef as Q, useCallback as A, useEffect as k, useImperativeHandle as oe } from "react";
2
+ var X = { exports: {} }, Y = {};
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 K;
13
+ function se() {
14
+ if (K) return Y;
15
+ K = 1;
16
+ var m = Symbol.for("react.transitional.element"), s = Symbol.for("react.fragment");
17
+ function p(i, c, u) {
18
+ var _ = null;
19
+ if (u !== void 0 && (_ = "" + u), c.key !== void 0 && (_ = "" + c.key), "key" in c) {
20
+ u = {};
21
+ for (var b in c)
22
+ b !== "key" && (u[b] = c[b]);
23
+ } else u = c;
24
+ return c = u.ref, {
25
+ $$typeof: m,
26
+ type: i,
27
+ key: _,
28
+ ref: c !== void 0 ? c : null,
29
+ props: u
30
+ };
31
+ }
32
+ return Y.Fragment = s, Y.jsx = p, Y.jsxs = p, Y;
33
+ }
34
+ var M = {};
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 ee;
45
+ function ce() {
46
+ return ee || (ee = 1, process.env.NODE_ENV !== "production" && (function() {
47
+ function m(e) {
48
+ if (e == null) return null;
49
+ if (typeof e == "function")
50
+ return e.$$typeof === T ? null : e.displayName || e.name || null;
51
+ if (typeof e == "string") return e;
52
+ switch (e) {
53
+ case g:
54
+ return "Fragment";
55
+ case h:
56
+ return "Profiler";
57
+ case z:
58
+ return "StrictMode";
59
+ case y:
60
+ return "Suspense";
61
+ case B:
62
+ return "SuspenseList";
63
+ case H:
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 U:
71
+ return "Portal";
72
+ case f:
73
+ return e.displayName || "Context";
74
+ case J:
75
+ return (e._context.displayName || "Context") + ".Consumer";
76
+ case G:
77
+ var t = e.render;
78
+ return e = e.displayName, e || (e = t.displayName || t.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
79
+ case R:
80
+ return t = e.displayName || null, t !== null ? t : m(e.type) || "Memo";
81
+ case d:
82
+ t = e._payload, e = e._init;
83
+ try {
84
+ return m(e(t));
85
+ } catch {
86
+ }
87
+ }
88
+ return null;
89
+ }
90
+ function s(e) {
91
+ return "" + e;
92
+ }
93
+ function p(e) {
94
+ try {
95
+ s(e);
96
+ var t = !1;
97
+ } catch {
98
+ t = !0;
99
+ }
100
+ if (t) {
101
+ t = console;
102
+ var r = t.error, n = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
103
+ return r.call(
104
+ t,
105
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
106
+ n
107
+ ), s(e);
108
+ }
109
+ }
110
+ function i(e) {
111
+ if (e === g) return "<>";
112
+ if (typeof e == "object" && e !== null && e.$$typeof === d)
113
+ return "<...>";
114
+ try {
115
+ var t = m(e);
116
+ return t ? "<" + t + ">" : "<...>";
117
+ } catch {
118
+ return "<...>";
119
+ }
120
+ }
121
+ function c() {
122
+ var e = C.A;
123
+ return e === null ? null : e.getOwner();
124
+ }
125
+ function u() {
126
+ return Error("react-stack-top-frame");
127
+ }
128
+ function _(e) {
129
+ if (O.call(e, "key")) {
130
+ var t = Object.getOwnPropertyDescriptor(e, "key").get;
131
+ if (t && t.isReactWarning) return !1;
132
+ }
133
+ return e.key !== void 0;
134
+ }
135
+ function b(e, t) {
136
+ function r() {
137
+ N || (N = !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
+ t
140
+ ));
141
+ }
142
+ r.isReactWarning = !0, Object.defineProperty(e, "key", {
143
+ get: r,
144
+ configurable: !0
145
+ });
146
+ }
147
+ function V() {
148
+ var e = m(this.type);
149
+ return j[e] || (j[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 q(e, t, r, n, o, l) {
154
+ var a = r.ref;
155
+ return e = {
156
+ $$typeof: v,
157
+ type: e,
158
+ key: t,
159
+ props: r,
160
+ _owner: n
161
+ }, (a !== void 0 ? a : null) !== null ? Object.defineProperty(e, "ref", {
162
+ enumerable: !1,
163
+ get: V
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: o
179
+ }), Object.defineProperty(e, "_debugTask", {
180
+ configurable: !1,
181
+ enumerable: !1,
182
+ writable: !0,
183
+ value: l
184
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
185
+ }
186
+ function x(e, t, r, n, o, l) {
187
+ var a = t.children;
188
+ if (a !== void 0)
189
+ if (n)
190
+ if (Z(a)) {
191
+ for (n = 0; n < a.length; n++)
192
+ $(a[n]);
193
+ Object.freeze && Object.freeze(a);
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 $(a);
199
+ if (O.call(t, "key")) {
200
+ a = m(e);
201
+ var E = Object.keys(t).filter(function(re) {
202
+ return re !== "key";
203
+ });
204
+ n = 0 < E.length ? "{key: someKey, " + E.join(": ..., ") + ": ...}" : "{key: someKey}", S[a + n] || (E = 0 < E.length ? "{" + E.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
+ n,
212
+ a,
213
+ E,
214
+ a
215
+ ), S[a + n] = !0);
216
+ }
217
+ if (a = null, r !== void 0 && (p(r), a = "" + r), _(t) && (p(t.key), a = "" + t.key), "key" in t) {
218
+ r = {};
219
+ for (var L in t)
220
+ L !== "key" && (r[L] = t[L]);
221
+ } else r = t;
222
+ return a && b(
223
+ r,
224
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
225
+ ), q(
226
+ e,
227
+ a,
228
+ r,
229
+ c(),
230
+ o,
231
+ l
232
+ );
233
+ }
234
+ function $(e) {
235
+ W(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === d && (e._payload.status === "fulfilled" ? W(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
236
+ }
237
+ function W(e) {
238
+ return typeof e == "object" && e !== null && e.$$typeof === v;
239
+ }
240
+ var w = ne, v = Symbol.for("react.transitional.element"), U = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), z = Symbol.for("react.strict_mode"), h = Symbol.for("react.profiler"), J = Symbol.for("react.consumer"), f = Symbol.for("react.context"), G = Symbol.for("react.forward_ref"), y = Symbol.for("react.suspense"), B = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), d = Symbol.for("react.lazy"), H = Symbol.for("react.activity"), T = Symbol.for("react.client.reference"), C = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, O = Object.prototype.hasOwnProperty, Z = Array.isArray, P = console.createTask ? console.createTask : function() {
241
+ return null;
242
+ };
243
+ w = {
244
+ react_stack_bottom_frame: function(e) {
245
+ return e();
246
+ }
247
+ };
248
+ var N, j = {}, D = w.react_stack_bottom_frame.bind(
249
+ w,
250
+ u
251
+ )(), I = P(i(u)), S = {};
252
+ M.Fragment = g, M.jsx = function(e, t, r) {
253
+ var n = 1e4 > C.recentlyCreatedOwnerStacks++;
254
+ return x(
255
+ e,
256
+ t,
257
+ r,
258
+ !1,
259
+ n ? Error("react-stack-top-frame") : D,
260
+ n ? P(i(e)) : I
261
+ );
262
+ }, M.jsxs = function(e, t, r) {
263
+ var n = 1e4 > C.recentlyCreatedOwnerStacks++;
264
+ return x(
265
+ e,
266
+ t,
267
+ r,
268
+ !0,
269
+ n ? Error("react-stack-top-frame") : D,
270
+ n ? P(i(e)) : I
271
+ );
272
+ };
273
+ })()), M;
274
+ }
275
+ var te;
276
+ function le() {
277
+ return te || (te = 1, process.env.NODE_ENV === "production" ? X.exports = se() : X.exports = ce()), X.exports;
278
+ }
279
+ var ue = le();
280
+ const ie = ae(
281
+ ({
282
+ document: m,
283
+ requirements: s = {},
284
+ fields: p = [],
285
+ signatureSelector: i = "[data-esign-signature]",
286
+ consentSelector: c = "[data-esign-consent]",
287
+ downloadSelector: u = "[data-esign-download]",
288
+ onReady: _,
289
+ onChange: b,
290
+ onAccept: V,
291
+ onFieldsDiscovered: q,
292
+ onDownloadRequest: x,
293
+ className: $,
294
+ style: W
295
+ }, w) => {
296
+ const [v, U] = F(!1), [g, z] = F(!1), [h, J] = F(/* @__PURE__ */ new Set()), [f, G] = F(/* @__PURE__ */ new Map()), [y, B] = F(!1), R = Q(null), d = Q(null), H = Q(Date.now()), T = A(() => {
297
+ const t = (s.consents || []).every(
298
+ (r) => h.has(r)
299
+ );
300
+ return {
301
+ scroll: !s.scroll || v,
302
+ signature: !s.signature || g,
303
+ consents: Array.from(h),
304
+ isValid: (!s.scroll || v) && (!s.signature || g) && t
305
+ };
306
+ }, [v, g, h, s]);
307
+ k(() => R.current ? ((async () => {
308
+ const { SuperDoc: t } = await import("superdoc"), r = new t({
309
+ selector: R.current,
310
+ document: m,
311
+ documentMode: "viewing",
312
+ onReady: () => {
313
+ B(!0), C(r), _?.();
314
+ },
315
+ onException: ({ error: n }) => {
316
+ console.error("SuperDoc error:", n);
317
+ }
318
+ });
319
+ d.current = r;
320
+ })(), () => {
321
+ d.current?.destroy?.(), d.current = null;
322
+ }) : void 0, [m]);
323
+ const C = (e) => {
324
+ if (!e.activeEditor) return;
325
+ const t = e.activeEditor, r = t.helpers.structuredContentCommands.getStructuredContentTags(
326
+ t.state
327
+ ), n = /* @__PURE__ */ new Map();
328
+ p.forEach((l) => {
329
+ const a = l.id || l.alias;
330
+ a && n.set(a, l.value);
331
+ });
332
+ const o = r.map(({ node: l }) => {
333
+ const a = l.attrs.id, E = l.attrs.alias, L = n.get(a) ?? n.get(E);
334
+ return {
335
+ id: a,
336
+ label: E,
337
+ value: L ?? l.textContent ?? ""
338
+ };
339
+ });
340
+ if (o.length > 0) {
341
+ const l = new Map(o.map((a) => [a.id, a]));
342
+ G(l), q?.(o), p.forEach((a) => {
343
+ O(a);
344
+ });
345
+ }
346
+ }, O = (e) => {
347
+ if (!d.current?.activeEditor) return;
348
+ const t = d.current.activeEditor, r = String(e.value);
349
+ e.id ? t.commands.updateStructuredContentById(e.id, {
350
+ text: r
351
+ }) : e.alias && t.commands.updateStructuredContentByAlias(e.alias, {
352
+ text: r
353
+ });
354
+ };
355
+ k(() => {
356
+ if (!s.scroll || !y) return;
357
+ const e = R.current;
358
+ if (!e) return;
359
+ const t = () => {
360
+ const { scrollTop: r, scrollHeight: n, clientHeight: o } = e;
361
+ (r / (n - o) >= 0.95 || n <= o) && U(!0);
362
+ };
363
+ return e.addEventListener("scroll", t), t(), () => e.removeEventListener("scroll", t);
364
+ }, [s.scroll, y]), k(() => {
365
+ if (!s.signature) return;
366
+ const e = () => {
367
+ const n = globalThis.document.querySelector(
368
+ i
369
+ );
370
+ if (!n) return;
371
+ const o = Z(n);
372
+ z(o);
373
+ }, t = new MutationObserver(e);
374
+ t.observe(globalThis.document.body, {
375
+ childList: !0,
376
+ subtree: !0,
377
+ attributes: !0,
378
+ attributeFilter: ["value", "data-signed"]
379
+ });
380
+ const r = (n) => {
381
+ n.target.matches(i) && e();
382
+ };
383
+ return globalThis.document.addEventListener("input", r, !0), globalThis.document.addEventListener("change", r, !0), e(), () => {
384
+ t.disconnect(), globalThis.document.removeEventListener("input", r, !0), globalThis.document.removeEventListener("change", r, !0);
385
+ };
386
+ }, [s.signature, i]), k(() => {
387
+ if (!s.consents || s.consents.length === 0) return;
388
+ const e = () => {
389
+ const r = globalThis.document.querySelectorAll(
390
+ c
391
+ ), n = /* @__PURE__ */ new Set();
392
+ r.forEach((o) => {
393
+ const l = o.name || o.dataset.esignConsent || o.id;
394
+ l && o.checked && n.add(l);
395
+ }), J(n);
396
+ }, t = (r) => {
397
+ r.target.matches(c) && e();
398
+ };
399
+ return globalThis.document.addEventListener("change", t, !0), e(), () => {
400
+ globalThis.document.removeEventListener("change", t, !0);
401
+ };
402
+ }, [s.consents, c]);
403
+ const Z = (e) => {
404
+ if (!e) return !1;
405
+ if (e.tagName === "CANVAS") {
406
+ const t = e, r = t.getContext("2d");
407
+ return r ? r.getImageData(0, 0, t.width, t.height).data.some(
408
+ (o) => o !== 0 && o !== 255
409
+ ) : !1;
410
+ }
411
+ return "value" in e ? !!e.value?.trim() : e.dataset.signed === "true";
412
+ }, P = () => {
413
+ const e = globalThis.document.querySelector(
414
+ i
415
+ );
416
+ if (e?.dataset.signatureImage)
417
+ return e.dataset.signatureImage;
418
+ if (e?.tagName === "CANVAS")
419
+ return e.toDataURL("image/png");
420
+ };
421
+ k(() => {
422
+ const e = T();
423
+ b?.(e);
424
+ }, [v, g, h, s, T, b]);
425
+ const N = A(async () => {
426
+ if (!T().isValid) return !1;
427
+ const t = Array.from(f.values()).map(
428
+ (n) => ({
429
+ id: n.id,
430
+ alias: n.label,
431
+ value: n.value
432
+ })
433
+ ), r = {
434
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
435
+ duration: Math.round((Date.now() - H.current) / 1e3),
436
+ fields: t,
437
+ scrolled: v,
438
+ signed: g,
439
+ consents: Array.from(h),
440
+ signatureImage: P()
441
+ };
442
+ return await V?.(r), r;
443
+ }, [f, v, g, h, T, V]), j = A(() => {
444
+ U(!1), z(!1), J(/* @__PURE__ */ new Set()), H.current = Date.now(), R.current && (R.current.scrollTop = 0);
445
+ const e = globalThis.document.querySelector(
446
+ i
447
+ );
448
+ e && (e.tagName === "CANVAS" ? e.getContext("2d")?.clearRect(
449
+ 0,
450
+ 0,
451
+ e.clientWidth,
452
+ e.clientHeight
453
+ ) : "value" in e && (e.value = ""), e.dataset.signed = "false"), globalThis.document.querySelectorAll(
454
+ c
455
+ ).forEach((r) => {
456
+ r.checked = !1;
457
+ });
458
+ }, [i, c]), D = A(
459
+ (e) => {
460
+ e.forEach((t) => {
461
+ O(t);
462
+ const r = f.get(t.id || "");
463
+ r && (r.value = t.value, G(new Map(f)));
464
+ });
465
+ },
466
+ [f]
467
+ ), I = A(() => Array.from(f.values()), [f]), S = A(async () => {
468
+ if (!d.current) return !1;
469
+ try {
470
+ const e = await d.current.export({
471
+ exportType: ["docx"],
472
+ isFinalDoc: !0,
473
+ triggerDownload: !1
474
+ });
475
+ if (!e) return !1;
476
+ const t = {
477
+ blob: e,
478
+ fields: Array.from(f.values())
479
+ };
480
+ return await x?.(t), t;
481
+ } catch (e) {
482
+ return console.error("Download request failed:", e), !1;
483
+ }
484
+ }, [f, x]);
485
+ return k(() => {
486
+ if (!y) return;
487
+ const e = (r) => {
488
+ r.preventDefault(), S();
489
+ }, t = globalThis.document.querySelectorAll(u);
490
+ return t.forEach((r) => {
491
+ r.addEventListener("click", e);
492
+ }), () => {
493
+ t.forEach((r) => {
494
+ r.removeEventListener("click", e);
495
+ });
496
+ };
497
+ }, [u, y, S]), oe(
498
+ w,
499
+ () => ({
500
+ accept: N,
501
+ reset: j,
502
+ updateFields: D,
503
+ getStatus: T,
504
+ getFields: I,
505
+ requestDownload: S,
506
+ superdoc: d.current
507
+ }),
508
+ [N, j, D, T, I, S]
509
+ ), /* @__PURE__ */ ue.jsx(
510
+ "div",
511
+ {
512
+ ref: R,
513
+ className: `superdoc-esign ${$ || ""}`,
514
+ "data-superdoc": "esign",
515
+ style: W
516
+ }
517
+ );
518
+ }
519
+ );
520
+ ie.displayName = "SuperDocESign";
521
+ export {
522
+ ie as default
523
+ };
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@superdoc-dev/esign",
3
+ "version": "1.0.0-next.1",
4
+ "description": "React eSignature component for SuperDoc",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "dev": "vite build --watch",
22
+ "build": "tsc && vite build",
23
+ "type-check": "tsc --noEmit",
24
+ "lint": "eslint src --ext .ts,.tsx",
25
+ "format": "prettier --write \"src/**/*.{ts,tsx}\"",
26
+ "prepare": "husky",
27
+ "release": "semantic-release",
28
+ "check:all": "pnpm run type-check && pnpm run lint && pnpm run format"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/superdoc-dev/esign.git"
33
+ },
34
+ "keywords": [
35
+ "superdoc",
36
+ "esign",
37
+ "esignature",
38
+ "clickwrap",
39
+ "agreement",
40
+ "document",
41
+ "signature",
42
+ "react"
43
+ ],
44
+ "author": "SuperDoc Team",
45
+ "license": "MIT",
46
+ "bugs": {
47
+ "url": "https://github.com/superdoc-dev/esign/issues"
48
+ },
49
+ "homepage": "https://github.com/superdoc-dev/esign#readme",
50
+ "peerDependencies": {
51
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
52
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
53
+ "superdoc": "^0.22.0"
54
+ },
55
+ "devDependencies": {
56
+ "@types/react": "^19.1.13",
57
+ "@types/react-dom": "^19.1.9",
58
+ "@eslint/js": "^9.36.0",
59
+ "@types/node": "^24.5.2",
60
+ "@vitejs/plugin-react": "^5.0.4",
61
+ "eslint": "^9.36.0",
62
+ "eslint-plugin-react": "^7.37.5",
63
+ "eslint-plugin-react-hooks": "^6.1.0",
64
+ "husky": "^9.1.7",
65
+ "prettier": "^3.6.2",
66
+ "react": "^19.2.0",
67
+ "react-dom": "^19.2.0",
68
+ "semantic-release": "^24.2.9",
69
+ "typescript": "^5.9.2",
70
+ "typescript-eslint": "^8.44.1",
71
+ "vite": "^7.1.7",
72
+ "vite-plugin-dts": "^4.5.4"
73
+ },
74
+ "publishConfig": {
75
+ "access": "public"
76
+ },
77
+ "engines": {
78
+ "node": ">=18"
79
+ }
80
+ }