@superdoc-dev/esign 1.0.0-next.2 → 1.0.0
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 +104 -169
- package/dist/defaults/ConsentCheckbox.d.ts +4 -0
- package/dist/defaults/ConsentCheckbox.d.ts.map +1 -0
- package/dist/defaults/DownloadButton.d.ts +4 -0
- package/dist/defaults/DownloadButton.d.ts.map +1 -0
- package/dist/defaults/SignatureInput.d.ts +4 -0
- package/dist/defaults/SignatureInput.d.ts.map +1 -0
- package/dist/defaults/SubmitButton.d.ts +4 -0
- package/dist/defaults/SubmitButton.d.ts.map +1 -0
- package/dist/defaults/index.d.ts +5 -0
- package/dist/defaults/index.d.ts.map +1 -0
- package/dist/index.d.ts +5 -60
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +494 -363
- package/dist/types.d.ts +107 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @superdoc-dev/esign
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React component that wraps SuperDoc for document signing workflows with audit trails and compliance tracking.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -11,195 +11,130 @@ npm install @superdoc-dev/esign superdoc
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
13
|
```jsx
|
|
14
|
-
import React
|
|
14
|
+
import React from 'react';
|
|
15
15
|
import SuperDocESign from '@superdoc-dev/esign';
|
|
16
16
|
import 'superdoc/dist/style.css';
|
|
17
17
|
|
|
18
18
|
function App() {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
19
|
+
const handleSubmit = async (data) => {
|
|
20
|
+
// Send to your backend
|
|
21
|
+
await fetch('/api/sign', {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
headers: { 'Content-Type': 'application/json' },
|
|
24
|
+
body: JSON.stringify(data)
|
|
25
|
+
});
|
|
26
|
+
alert('Document signed!');
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
return (
|
|
31
|
-
<
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
{/* Accept button */}
|
|
64
|
-
<button
|
|
65
|
-
onClick={() => esignRef.current?.accept()}
|
|
66
|
-
disabled={!status.isValid}
|
|
67
|
-
>
|
|
68
|
-
Accept Agreement
|
|
69
|
-
</button>
|
|
70
|
-
</div>
|
|
30
|
+
<SuperDocESign
|
|
31
|
+
eventId={`session-${Date.now()}`}
|
|
32
|
+
|
|
33
|
+
document={{
|
|
34
|
+
source: "https://storage.googleapis.com/public_static_hosting/public_demo_docs/employment_agreement.docx",
|
|
35
|
+
validation: { scroll: { required: true } }
|
|
36
|
+
}}
|
|
37
|
+
|
|
38
|
+
fields={{
|
|
39
|
+
document: [
|
|
40
|
+
{ id: 'employee_name', value: 'Jane Smith' },
|
|
41
|
+
{ id: 'position', value: 'Senior Engineer' },
|
|
42
|
+
{ id: 'salary', value: '$120,000' }
|
|
43
|
+
],
|
|
44
|
+
signer: [
|
|
45
|
+
{
|
|
46
|
+
id: 'signature',
|
|
47
|
+
type: 'signature',
|
|
48
|
+
validation: { required: true },
|
|
49
|
+
label: 'Type your full name'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'accept_terms',
|
|
53
|
+
type: 'consent',
|
|
54
|
+
validation: { required: true },
|
|
55
|
+
label: 'I accept the terms'
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}}
|
|
59
|
+
|
|
60
|
+
onSubmit={handleSubmit}
|
|
61
|
+
/>
|
|
71
62
|
);
|
|
72
63
|
}
|
|
73
64
|
```
|
|
74
65
|
|
|
75
|
-
##
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
/>
|
|
66
|
+
## Backend - Create Signed PDF
|
|
67
|
+
|
|
68
|
+
Use the SuperDoc API to create the final signed document:
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
// Node.js/Express
|
|
72
|
+
app.post('/api/sign', async (req, res) => {
|
|
73
|
+
const { eventId, auditTrail, documentFields, signerFields } = req.body;
|
|
74
|
+
|
|
75
|
+
// 1. Fill document fields
|
|
76
|
+
const annotated = await fetch('https://api.superdoc.dev/v1/annotate', {
|
|
77
|
+
method: 'POST',
|
|
78
|
+
headers: {
|
|
79
|
+
'Authorization': `Bearer ${API_KEY}`,
|
|
80
|
+
'Content-Type': 'application/json'
|
|
81
|
+
},
|
|
82
|
+
body: JSON.stringify({
|
|
83
|
+
document: 'template.docx',
|
|
84
|
+
fields: [...documentFields, ...signerFields]
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// 2. Add digital signature
|
|
89
|
+
const signed = await fetch('https://api.superdoc.dev/v1/sign', {
|
|
90
|
+
method: 'POST',
|
|
91
|
+
headers: {
|
|
92
|
+
'Authorization': `Bearer ${API_KEY}`,
|
|
93
|
+
'Content-Type': 'application/json'
|
|
94
|
+
},
|
|
95
|
+
body: JSON.stringify({
|
|
96
|
+
document: await annotated.blob(),
|
|
97
|
+
auditTrail: auditTrail
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// 3. Save PDF
|
|
102
|
+
await saveToStorage(await signed.blob(), `signed_${eventId}.pdf`);
|
|
103
|
+
|
|
104
|
+
res.json({ success: true });
|
|
105
|
+
});
|
|
154
106
|
```
|
|
155
107
|
|
|
156
|
-
|
|
108
|
+
See [Python, Ruby, and more examples](https://docs.superdoc.dev/solutions/esign/backend).
|
|
157
109
|
|
|
158
|
-
|
|
110
|
+
## What You Receive
|
|
159
111
|
|
|
160
|
-
```
|
|
112
|
+
```javascript
|
|
161
113
|
{
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
114
|
+
eventId: "session-123",
|
|
115
|
+
timestamp: "2024-01-15T10:30:00Z",
|
|
116
|
+
duration: 45000,
|
|
117
|
+
documentFields: [
|
|
118
|
+
{ id: "employee_name", value: "Jane Smith" }
|
|
119
|
+
],
|
|
120
|
+
signerFields: [
|
|
121
|
+
{ id: "signature", value: "Jane Smith" },
|
|
122
|
+
{ id: "accept_terms", value: true }
|
|
166
123
|
],
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
124
|
+
auditTrail: [
|
|
125
|
+
{ type: "ready", timestamp: "..." },
|
|
126
|
+
{ type: "scroll", timestamp: "..." },
|
|
127
|
+
{ type: "field_change", timestamp: "..." },
|
|
128
|
+
{ type: "submit", timestamp: "..." }
|
|
129
|
+
],
|
|
130
|
+
isFullyCompleted: true
|
|
171
131
|
}
|
|
172
132
|
```
|
|
173
133
|
|
|
174
|
-
##
|
|
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
|
|
134
|
+
## Documentation
|
|
200
135
|
|
|
201
|
-
|
|
136
|
+
Full docs at [docs.superdoc.dev/solutions/esign](https://docs.superdoc.dev/solutions/esign)
|
|
202
137
|
|
|
203
138
|
## License
|
|
204
139
|
|
|
205
|
-
|
|
140
|
+
AGPLv3
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConsentCheckbox.d.ts","sourceRoot":"","sources":["../../src/defaults/ConsentCheckbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAoBzD,CAAC"}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignatureInput.d.ts","sourceRoot":"","sources":["../../src/defaults/SignatureInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAsBxD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubmitButton.d.ts","sourceRoot":"","sources":["../../src/defaults/SubmitButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEhE,eAAO,MAAM,kBAAkB,GAAI,SAAS,YAAY,gCAkCvD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/defaults/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,62 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
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>>;
|
|
1
|
+
import { SignatureInput, ConsentCheckbox } from './defaults';
|
|
2
|
+
import type * as Types from "./types";
|
|
3
|
+
export * from './types';
|
|
4
|
+
export { SignatureInput, ConsentCheckbox };
|
|
5
|
+
declare const SuperDocESign: import('react').ForwardRefExoticComponent<Types.SuperDocESignProps & import('react').RefAttributes<any>>;
|
|
61
6
|
export default SuperDocESign;
|
|
62
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"
|
|
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,eAAe,EAGhB,MAAM,YAAY,CAAC;AAEpB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC;AAI3C,QAAA,MAAM,aAAa,0GA2alB,CAAC;AAIF,eAAe,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var ue=Object.create;var ee=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty;var ge=(l,f,u,s)=>{if(f&&typeof f=="object"||typeof f=="function")for(let n of fe(f))!pe.call(l,n)&&n!==u&&ee(l,n,{get:()=>f[n],enumerable:!(s=de(f,n))||s.enumerable});return l};var ve=(l,f,u)=>(u=l!=null?ue(me(l)):{},ge(f||!l||!l.__esModule?ee(u,"default",{value:l,enumerable:!0}):u,l));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("react");var X={exports:{}},$={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var te;function be(){if(te)return $;te=1;var l=Symbol.for("react.transitional.element"),f=Symbol.for("react.fragment");function u(s,n,m){var b=null;if(m!==void 0&&(b=""+m),n.key!==void 0&&(b=""+n.key),"key"in n){m={};for(var _ in n)_!=="key"&&(m[_]=n[_])}else m=n;return n=m.ref,{$$typeof:l,type:s,key:b,ref:n!==void 0?n:null,props:m}}return $.Fragment=f,$.jsx=u,$.jsxs=u,$}var L={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var re;function he(){return re||(re=1,process.env.NODE_ENV!=="production"&&(function(){function l(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Q?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case y:return"Fragment";case E:return"Profiler";case W:return"StrictMode";case T:return"Suspense";case B: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 Z:return"Portal";case w:return e.displayName||"Context";case V:return(e._context.displayName||"Context")+".Consumer";case z:var a=e.render;return e=e.displayName,e||(e=a.displayName||a.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case I:return a=e.displayName||null,a!==null?a:l(e.type)||"Memo";case O:a=e._payload,e=e._init;try{return l(e(a))}catch{}}return null}function f(e){return""+e}function u(e){try{f(e);var a=!1}catch{a=!0}if(a){a=console;var i=a.error,p=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i.call(a,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",p),f(e)}}function s(e){if(e===y)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===O)return"<...>";try{var a=l(e);return a?"<"+a+">":"<...>"}catch{return"<...>"}}function n(){var e=k.A;return e===null?null:e.getOwner()}function m(){return Error("react-stack-top-frame")}function b(e){if(x.call(e,"key")){var a=Object.getOwnPropertyDescriptor(e,"key").get;if(a&&a.isReactWarning)return!1}return e.key!==void 0}function _(e,a){function i(){j||(j=!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)",a))}i.isReactWarning=!0,Object.defineProperty(e,"key",{get:i,configurable:!0})}function P(){var e=l(this.type);return H[e]||(H[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 U(e,a,i,p,N,Y){var t=i.ref;return e={$$typeof:q,type:e,key:a,props:i,_owner:p},(t!==void 0?t:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:P}):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:N}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Y}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function D(e,a,i,p,N,Y){var t=a.children;if(t!==void 0)if(p)if(K(t)){for(p=0;p<t.length;p++)F(t[p]);Object.freeze&&Object.freeze(t)}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 F(t);if(x.call(a,"key")){t=l(e);var r=Object.keys(a).filter(function(g){return g!=="key"});p=0<r.length?"{key: someKey, "+r.join(": ..., ")+": ...}":"{key: someKey}",G[t+p]||(r=0<r.length?"{"+r.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,
|
|
22
|
+
<%s key={someKey} {...props} />`,p,t,r,t),G[t+p]=!0)}if(t=null,i!==void 0&&(u(i),t=""+i),b(a)&&(u(a.key),t=""+a.key),"key"in a){i={};for(var o in a)o!=="key"&&(i[o]=a[o])}else i=a;return t&&_(i,typeof e=="function"?e.displayName||e.name||"Unknown":e),U(e,t,i,n(),N,Y)}function F(e){h(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===O&&(e._payload.status==="fulfilled"?h(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function h(e){return typeof e=="object"&&e!==null&&e.$$typeof===q}var A=d,q=Symbol.for("react.transitional.element"),Z=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),W=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),V=Symbol.for("react.consumer"),w=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),Q=Symbol.for("react.client.reference"),k=A.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,x=Object.prototype.hasOwnProperty,K=Array.isArray,R=console.createTask?console.createTask:function(){return null};A={react_stack_bottom_frame:function(e){return e()}};var j,H={},M=A.react_stack_bottom_frame.bind(A,m)(),C=R(s(m)),G={};L.Fragment=y,L.jsx=function(e,a,i){var p=1e4>k.recentlyCreatedOwnerStacks++;return D(e,a,i,!1,p?Error("react-stack-top-frame"):M,p?R(s(e)):C)},L.jsxs=function(e,a,i){var p=1e4>k.recentlyCreatedOwnerStacks++;return D(e,a,i,!0,p?Error("react-stack-top-frame"):M,p?R(s(e)):C)}})()),L}var ne;function Ee(){return ne||(ne=1,process.env.NODE_ENV==="production"?X.exports=be():X.exports=he()),X.exports}var v=Ee();const ae=({value:l,onChange:f,isDisabled:u,label:s})=>v.jsxs("div",{className:"superdoc-esign-signature-input",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[s&&v.jsx("label",{children:s}),v.jsx("input",{type:"text",value:String(l||""),onChange:n=>f(n.target.value),disabled:u,placeholder:"Type your full name",style:{fontFamily:"cursive",fontSize:"18px"}})]}),oe=({value:l,onChange:f,isDisabled:u,label:s})=>v.jsxs("label",{className:"superdoc-esign-consent-checkbox",style:{display:"flex",gap:"8px"},children:[v.jsx("input",{type:"checkbox",checked:!!l,onChange:n=>f(n.target.checked),disabled:u}),v.jsx("span",{children:s})]}),xe=l=>({onClick:u,fileName:s,isDisabled:n})=>{const m=l?.label||"Download";return v.jsxs("button",{onClick:u,disabled:n,className:"superdoc-esign-btn",style:{padding:"10px 20px",borderRadius:"6px",border:"none",background:"#fff",color:"#333",cursor:n?"not-allowed":"pointer",opacity:n?.5:1,fontSize:"16px",fontWeight:"bold"},children:[m," ",s&&`(${s})`]})},Re=l=>({onClick:u,isValid:s,isDisabled:n,isSubmitting:m})=>{const b=()=>l?.label||"Submit";return v.jsx("button",{onClick:u,disabled:!s||n||m,className:"superdoc-esign-btn",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:b()})},se=d.forwardRef((l,f)=>{const{eventId:u,document:s,fields:n={},download:m,submit:b,onSubmit:_,onDownload:P,onStateChange:U,onFieldChange:D,onFieldsDiscovered:F,isDisabled:h=!1,className:A,style:q,documentHeight:Z="600px"}=l,[y,W]=d.useState(!s.validation?.scroll?.required),[E,V]=d.useState(new Map),[w,z]=d.useState(!1),[T,B]=d.useState(!1),[I,O]=d.useState([]),[J,Q]=d.useState(!1),k=d.useRef(null),x=d.useRef(null),K=d.useRef(Date.now()),R=d.useRef(n);R.current=n;const j=d.useCallback(t=>{if(!x.current?.activeEditor)return;const r=x.current.activeEditor,o=R.current.signer?.find(c=>c.id===t.id);let g;o?.type==="signature"&&t.value?g={json:{type:"image",attrs:{src:typeof t.value=="string"&&t.value.startsWith("data:image/")?t.value:H(String(t.value)),alt:"Signature"}}}:g={text:String(t.value??"")},t.id&&r.commands.updateStructuredContentById(t.id,g)},[]);function H(t){const r=globalThis.document.createElement("canvas"),o=r.getContext("2d"),g=30;o.font=`italic ${g}px cursive`;const S=o.measureText(t).width,le=g*1.3,ce=4,ie=6;return r.width=Math.ceil(S+ce*2)+20,r.height=Math.ceil(le+ie*2),o.font=`italic ${g}px cursive`,o.fillStyle="black",o.textAlign="center",o.textBaseline="middle",o.fillText(t,r.width/2,r.height/2),r.toDataURL("image/png")}const M=d.useCallback(t=>{if(!t)return;const r=t.helpers.structuredContentCommands.getStructuredContentTags(t.state),o=new Map;R.current.document?.forEach(c=>{c.id&&o.set(c.id,c.value)}),R.current.signer?.forEach(c=>{c.value!==void 0&&o.set(c.id,c.value)});const g=r.map(({node:c})=>({id:c.attrs.id,label:c.attrs.label,value:o.get(c.attrs.id)??c.textContent??""})).filter(c=>c.id);g.length>0&&(F?.(g),[...R.current.document||[],...R.current.signer||[]].filter(S=>S.value!==void 0).forEach(S=>j({id:S.id,value:S.value})))},[F,j]),C=t=>{const r={...t,timestamp:new Date().toISOString()};O(o=>[...o,r])};d.useEffect(()=>k.current?((async()=>{const{SuperDoc:r}=await import("superdoc"),o=new r({selector:k.current,document:s.source,documentMode:"viewing",onReady:()=>{o.activeEditor&&M(o.activeEditor),C({type:"ready"}),Q(!0)}});x.current=o})(),()=>{x.current&&(x.current.destroy(),x.current=null)}):void 0,[s.source,s.mode,M]),d.useEffect(()=>{if(!s.validation?.scroll?.required||!J)return;const t=k.current;if(!t)return;const r=()=>{const{scrollTop:o,scrollHeight:g,clientHeight:c}=t,S=o/(g-c);(S>=.95||g<=c)&&(W(!0),C({type:"scroll",data:{percent:Math.round(S*100)}}))};return t.addEventListener("scroll",r),r(),()=>t.removeEventListener("scroll",r)},[s.validation?.scroll?.required,J]);const G=d.useCallback((t,r)=>{V(o=>{const g=o.get(t),c=new Map(o);return c.set(t,r),j({id:t,value:r}),C({type:"field_change",data:{fieldId:t,value:r,previousValue:g}}),D?.({id:t,value:r,previousValue:g}),c})},[D,j]),e=d.useCallback(()=>s.validation?.scroll?.required&&!y?!1:(n.signer||[]).every(t=>{if(!t.validation?.required)return!0;const r=E.get(t.id);return r&&(typeof r!="string"||r.trim())}),[y,n.signer,E,s.validation?.scroll?.required]);d.useEffect(()=>{const t=e();z(t),U?.({scrolled:y,fields:E,isValid:t,isSubmitting:T})},[y,E,T,e,U]);const a=d.useCallback(async()=>{if(h)return;const t=await x.current?.export({exportType:["pdf"],isFinalDoc:!0,triggerDownload:!1});if(t&&P)P(t,m?.fileName||"document.pdf");else if(t){const r=URL.createObjectURL(t),o=globalThis.document.createElement("a");o.href=r,o.download=m?.fileName||"document.pdf",o.click(),URL.revokeObjectURL(r)}},[h,m,P]),i=d.useCallback(async()=>{if(!w||h||T)return;B(!0),C({type:"submit"});const t={eventId:u,timestamp:new Date().toISOString(),duration:Math.floor((Date.now()-K.current)/1e3),auditTrail:I,documentFields:n.document||[],signerFields:(n.signer||[]).map(r=>({id:r.id,value:E.get(r.id)??null})),isFullyCompleted:w};try{await _(t)}finally{B(!1)}},[w,h,T,u,I,n,E,_]),p=t=>{const r=t.component||N(t.type);return v.jsx(r,{value:E.get(t.id)??null,onChange:o=>G(t.id,o),isDisabled:h,label:t.label},t.id)},N=t=>{switch(t){case"signature":case"text":return ae;case"consent":case"checkbox":return oe}},Y=()=>{const t=m?.component||xe(m),r=b?.component||Re(b);return v.jsxs("div",{className:"superdoc-esign-actions",style:{display:"flex",gap:"10px"},children:[s.mode!=="download"&&v.jsx(r,{onClick:i,isValid:w,isDisabled:h,isSubmitting:T}),v.jsx(t,{onClick:a,fileName:m?.fileName,isDisabled:h})]})};return d.useImperativeHandle(f,()=>({getState:()=>({scrolled:y,fields:E,isValid:w,isSubmitting:T}),getAuditTrail:()=>I,reset:()=>{W(!s.validation?.scroll?.required),V(new Map),z(!1),O([])}})),v.jsxs("div",{className:`superdoc-esign-container ${A||""}`,style:q,children:[v.jsx("div",{className:"superdoc-esign-document",children:v.jsx("div",{ref:k,style:{height:Z,overflow:"auto"}})}),v.jsxs("div",{className:"superdoc-esign-controls",style:{marginTop:"20px"},children:[n.signer&&n.signer.length>0&&v.jsx("div",{className:"superdoc-esign-fields",style:{marginBottom:"20px"},children:n.signer.map(p)}),Y()]})]})});se.displayName="SuperDocESign";exports.ConsentCheckbox=oe;exports.SignatureInput=ae;exports.default=se;
|