@documenso/embed-react 0.2.1 → 0.2.3
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/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +86 -38
- package/dist/multisign-document.d.ts +38 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -4,3 +4,4 @@ export { default as unstable_EmbedCreateDocument } from './create-document';
|
|
|
4
4
|
export { default as unstable_EmbedCreateTemplate } from './create-template';
|
|
5
5
|
export { default as unstable_EmbedUpdateDocument } from './update-document';
|
|
6
6
|
export { default as unstable_EmbedUpdateTemplate } from './update-template';
|
|
7
|
+
export { default as unstable_EmbedMultiSignDocument } from './multisign-document';
|
package/dist/index.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export { default as unstable_EmbedCreateDocument } from './create-document';
|
|
|
4
4
|
export { default as unstable_EmbedCreateTemplate } from './create-template';
|
|
5
5
|
export { default as unstable_EmbedUpdateDocument } from './update-document';
|
|
6
6
|
export { default as unstable_EmbedUpdateTemplate } from './update-template';
|
|
7
|
+
export { default as unstable_EmbedMultiSignDocument } from './multisign-document';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),c=require("react");function f(e){const d=c.useRef(null);function m(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,email:e.email,lockEmail:e.lockEmail,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL(`/embed/direct/${e.token}`,t);return e.externalId&&a.searchParams.set("externalId",e.externalId),`${a}#${n}`}function s(t){var n,a,i,o,u,r;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.action){case"document-ready":(a=e.onDocumentReady)==null||a.call(e);break;case"document-completed":(i=e.onDocumentCompleted)==null||i.call(e,t.data.data);break;case"document-error":(o=e.onDocumentError)==null||o.call(e,t.data.data);break;case"field-signed":(u=e.onFieldSigned)==null||u.call(e);break;case"field-unsigned":(r=e.onFieldUnsigned)==null||r.call(e);break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:m()})}function b(e){const d=c.useRef(null);function m(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,allowDocumentRejection:e.allowDocumentRejection,...e.additionalProps})));return`${new URL(`/embed/sign/${e.token}`,t)}#${n}`}function s(t){var n,a,i,o,u;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.action){case"document-ready":(a=e.onDocumentReady)==null||a.call(e);break;case"document-completed":(i=e.onDocumentCompleted)==null||i.call(e,t.data.data);break;case"document-error":(o=e.onDocumentError)==null||o.call(e,t.data.data);break;case"document-rejected":(u=e.onDocumentRejected)==null||u.call(e,t.data.data);break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:m()})}function k(e){const d=c.useRef(null);function m(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL("/embed/v1/authoring/document/create",t);return a.searchParams.set("token",e.presignToken),a.hash=n,a.toString()}function s(t){var n,a;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"document-created":(a=e.onDocumentCreated)==null||a.call(e,{documentId:t.data.documentId,externalId:t.data.externalId});break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:m()})}function g(e){const d=c.useRef(null);function m(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL("/embed/v1/authoring/template/create",t);return a.searchParams.set("token",e.presignToken),a.hash=n,a.toString()}function s(t){var n,a;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"template-created":(a=e.onTemplateCreated)==null||a.call(e,{templateId:t.data.templateId,externalId:t.data.externalId});break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:m()})}function w(e){const d=c.useRef(null);function m(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({token:e.presignToken,externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL(`/embed/v1/authoring/document/edit/${e.documentId}`,t);return a.searchParams.set("token",e.presignToken),a.hash=n,a.toString()}function s(t){var n,a;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"document-updated":(a=e.onDocumentUpdated)==null||a.call(e,{documentId:t.data.documentId,externalId:t.data.externalId});break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:m()})}function E(e){const d=c.useRef(null);function m(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL(`/embed/v1/authoring/template/edit/${e.templateId}`,t);return a.searchParams.set("token",e.presignToken),a.hash=n,a.toString()}function s(t){var n,a;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"template-updated":(a=e.onTemplateUpdated)==null||a.call(e,{templateId:t.data.templateId,externalId:t.data.externalId});break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:m()})}function h(e){const d=c.useRef(null);function m(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,allowDocumentRejection:e.allowDocumentRejection,...e.additionalProps}))),a=new URL("/embed/v1/multisign",t);for(const i of e.tokens)a.searchParams.append("token",i);return`${a}#${n}`}function s(t){var n,a,i,o,u,r;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.action){case"document-ready":(a=e.onDocumentReady)==null||a.call(e);break;case"document-completed":(i=e.onDocumentCompleted)==null||i.call(e,t.data.data);break;case"document-error":(o=e.onDocumentError)==null||o.call(e,t.data.data);break;case"document-rejected":(u=e.onDocumentRejected)==null||u.call(e,t.data.data);break;case"all-documents-completed":(r=e.onAllDocumentsCompleted)==null||r.call(e,t.data.data);break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:m()})}exports.EmbedDirectTemplate=f;exports.EmbedSignDocument=b;exports.unstable_EmbedCreateDocument=k;exports.unstable_EmbedCreateTemplate=g;exports.unstable_EmbedMultiSignDocument=h;exports.unstable_EmbedUpdateDocument=w;exports.unstable_EmbedUpdateTemplate=E;
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
function
|
|
4
|
-
const d =
|
|
5
|
-
function
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as r, useEffect as s } from "react";
|
|
3
|
+
function w(e) {
|
|
4
|
+
const d = r(null);
|
|
5
|
+
function m() {
|
|
6
6
|
const a = e.host || "https://app.documenso.com", n = btoa(
|
|
7
7
|
encodeURIComponent(
|
|
8
8
|
JSON.stringify({
|
|
@@ -20,20 +20,20 @@ function g(e) {
|
|
|
20
20
|
return e.externalId && t.searchParams.set("externalId", e.externalId), `${t}#${n}`;
|
|
21
21
|
}
|
|
22
22
|
function c(a) {
|
|
23
|
-
var n, t,
|
|
23
|
+
var n, t, i, o, l, f;
|
|
24
24
|
if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
|
|
25
25
|
switch (a.data.action) {
|
|
26
26
|
case "document-ready":
|
|
27
27
|
(t = e.onDocumentReady) == null || t.call(e);
|
|
28
28
|
break;
|
|
29
29
|
case "document-completed":
|
|
30
|
-
(
|
|
30
|
+
(i = e.onDocumentCompleted) == null || i.call(e, a.data.data);
|
|
31
31
|
break;
|
|
32
32
|
case "document-error":
|
|
33
|
-
(
|
|
33
|
+
(o = e.onDocumentError) == null || o.call(e, a.data.data);
|
|
34
34
|
break;
|
|
35
35
|
case "field-signed":
|
|
36
|
-
(
|
|
36
|
+
(l = e.onFieldSigned) == null || l.call(e);
|
|
37
37
|
break;
|
|
38
38
|
case "field-unsigned":
|
|
39
39
|
(f = e.onFieldUnsigned) == null || f.call(e);
|
|
@@ -44,11 +44,11 @@ function g(e) {
|
|
|
44
44
|
window.addEventListener("message", c);
|
|
45
45
|
}, []), s(() => () => {
|
|
46
46
|
window.removeEventListener("message", c);
|
|
47
|
-
}, []), /* @__PURE__ */
|
|
47
|
+
}, []), /* @__PURE__ */ u("iframe", { ref: d, className: e.className, src: m() });
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
const d =
|
|
51
|
-
function
|
|
49
|
+
function g(e) {
|
|
50
|
+
const d = r(null);
|
|
51
|
+
function m() {
|
|
52
52
|
const a = e.host || "https://app.documenso.com", n = btoa(
|
|
53
53
|
encodeURIComponent(
|
|
54
54
|
JSON.stringify({
|
|
@@ -65,20 +65,20 @@ function k(e) {
|
|
|
65
65
|
return `${new URL(`/embed/sign/${e.token}`, a)}#${n}`;
|
|
66
66
|
}
|
|
67
67
|
function c(a) {
|
|
68
|
-
var n, t,
|
|
68
|
+
var n, t, i, o, l;
|
|
69
69
|
if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
|
|
70
70
|
switch (a.data.action) {
|
|
71
71
|
case "document-ready":
|
|
72
72
|
(t = e.onDocumentReady) == null || t.call(e);
|
|
73
73
|
break;
|
|
74
74
|
case "document-completed":
|
|
75
|
-
(
|
|
75
|
+
(i = e.onDocumentCompleted) == null || i.call(e, a.data.data);
|
|
76
76
|
break;
|
|
77
77
|
case "document-error":
|
|
78
|
-
(
|
|
78
|
+
(o = e.onDocumentError) == null || o.call(e, a.data.data);
|
|
79
79
|
break;
|
|
80
80
|
case "document-rejected":
|
|
81
|
-
(
|
|
81
|
+
(l = e.onDocumentRejected) == null || l.call(e, a.data.data);
|
|
82
82
|
break;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -86,11 +86,11 @@ function k(e) {
|
|
|
86
86
|
window.addEventListener("message", c);
|
|
87
87
|
}, []), s(() => () => {
|
|
88
88
|
window.removeEventListener("message", c);
|
|
89
|
-
}, []), /* @__PURE__ */
|
|
89
|
+
}, []), /* @__PURE__ */ u("iframe", { ref: d, className: e.className, src: m() });
|
|
90
90
|
}
|
|
91
91
|
function h(e) {
|
|
92
|
-
const d =
|
|
93
|
-
function
|
|
92
|
+
const d = r(null);
|
|
93
|
+
function m() {
|
|
94
94
|
const a = e.host || "https://app.documenso.com", n = btoa(
|
|
95
95
|
encodeURIComponent(
|
|
96
96
|
JSON.stringify({
|
|
@@ -121,11 +121,11 @@ function h(e) {
|
|
|
121
121
|
window.addEventListener("message", c);
|
|
122
122
|
}, []), s(() => () => {
|
|
123
123
|
window.removeEventListener("message", c);
|
|
124
|
-
}, []), /* @__PURE__ */
|
|
124
|
+
}, []), /* @__PURE__ */ u("iframe", { ref: d, className: e.className, src: m() });
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
const d =
|
|
128
|
-
function
|
|
126
|
+
function D(e) {
|
|
127
|
+
const d = r(null);
|
|
128
|
+
function m() {
|
|
129
129
|
const a = e.host || "https://app.documenso.com", n = btoa(
|
|
130
130
|
encodeURIComponent(
|
|
131
131
|
JSON.stringify({
|
|
@@ -156,11 +156,11 @@ function I(e) {
|
|
|
156
156
|
window.addEventListener("message", c);
|
|
157
157
|
}, []), s(() => () => {
|
|
158
158
|
window.removeEventListener("message", c);
|
|
159
|
-
}, []), /* @__PURE__ */
|
|
159
|
+
}, []), /* @__PURE__ */ u("iframe", { ref: d, className: e.className, src: m() });
|
|
160
160
|
}
|
|
161
|
-
function
|
|
162
|
-
const d =
|
|
163
|
-
function
|
|
161
|
+
function I(e) {
|
|
162
|
+
const d = r(null);
|
|
163
|
+
function m() {
|
|
164
164
|
const a = e.host || "https://app.documenso.com", n = btoa(
|
|
165
165
|
encodeURIComponent(
|
|
166
166
|
JSON.stringify({
|
|
@@ -174,7 +174,7 @@ function D(e) {
|
|
|
174
174
|
})
|
|
175
175
|
)
|
|
176
176
|
), t = new URL(
|
|
177
|
-
`/embed/v1/authoring/document/
|
|
177
|
+
`/embed/v1/authoring/document/edit/${e.documentId}`,
|
|
178
178
|
a
|
|
179
179
|
);
|
|
180
180
|
return t.searchParams.set("token", e.presignToken), t.hash = n, t.toString();
|
|
@@ -195,11 +195,11 @@ function D(e) {
|
|
|
195
195
|
window.addEventListener("message", c);
|
|
196
196
|
}, []), s(() => () => {
|
|
197
197
|
window.removeEventListener("message", c);
|
|
198
|
-
}, []), /* @__PURE__ */
|
|
198
|
+
}, []), /* @__PURE__ */ u("iframe", { ref: d, className: e.className, src: m() });
|
|
199
199
|
}
|
|
200
200
|
function E(e) {
|
|
201
|
-
const d =
|
|
202
|
-
function
|
|
201
|
+
const d = r(null);
|
|
202
|
+
function m() {
|
|
203
203
|
const a = e.host || "https://app.documenso.com", n = btoa(
|
|
204
204
|
encodeURIComponent(
|
|
205
205
|
JSON.stringify({
|
|
@@ -212,7 +212,7 @@ function E(e) {
|
|
|
212
212
|
})
|
|
213
213
|
)
|
|
214
214
|
), t = new URL(
|
|
215
|
-
`/embed/v1/authoring/template/
|
|
215
|
+
`/embed/v1/authoring/template/edit/${e.templateId}`,
|
|
216
216
|
a
|
|
217
217
|
);
|
|
218
218
|
return t.searchParams.set("token", e.presignToken), t.hash = n, t.toString();
|
|
@@ -233,13 +233,61 @@ function E(e) {
|
|
|
233
233
|
window.addEventListener("message", c);
|
|
234
234
|
}, []), s(() => () => {
|
|
235
235
|
window.removeEventListener("message", c);
|
|
236
|
-
}, []), /* @__PURE__ */
|
|
236
|
+
}, []), /* @__PURE__ */ u("iframe", { ref: d, className: e.className, src: m() });
|
|
237
|
+
}
|
|
238
|
+
function U(e) {
|
|
239
|
+
const d = r(null);
|
|
240
|
+
function m() {
|
|
241
|
+
const a = e.host || "https://app.documenso.com", n = btoa(
|
|
242
|
+
encodeURIComponent(
|
|
243
|
+
JSON.stringify({
|
|
244
|
+
name: e.name,
|
|
245
|
+
lockName: e.lockName,
|
|
246
|
+
css: e.css,
|
|
247
|
+
cssVars: e.cssVars,
|
|
248
|
+
darkModeDisabled: e.darkModeDisabled,
|
|
249
|
+
allowDocumentRejection: e.allowDocumentRejection,
|
|
250
|
+
...e.additionalProps
|
|
251
|
+
})
|
|
252
|
+
)
|
|
253
|
+
), t = new URL("/embed/v1/multisign", a);
|
|
254
|
+
for (const i of e.tokens)
|
|
255
|
+
t.searchParams.append("token", i);
|
|
256
|
+
return `${t}#${n}`;
|
|
257
|
+
}
|
|
258
|
+
function c(a) {
|
|
259
|
+
var n, t, i, o, l, f;
|
|
260
|
+
if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
|
|
261
|
+
switch (a.data.action) {
|
|
262
|
+
case "document-ready":
|
|
263
|
+
(t = e.onDocumentReady) == null || t.call(e);
|
|
264
|
+
break;
|
|
265
|
+
case "document-completed":
|
|
266
|
+
(i = e.onDocumentCompleted) == null || i.call(e, a.data.data);
|
|
267
|
+
break;
|
|
268
|
+
case "document-error":
|
|
269
|
+
(o = e.onDocumentError) == null || o.call(e, a.data.data);
|
|
270
|
+
break;
|
|
271
|
+
case "document-rejected":
|
|
272
|
+
(l = e.onDocumentRejected) == null || l.call(e, a.data.data);
|
|
273
|
+
break;
|
|
274
|
+
case "all-documents-completed":
|
|
275
|
+
(f = e.onAllDocumentsCompleted) == null || f.call(e, a.data.data);
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return s(() => {
|
|
280
|
+
window.addEventListener("message", c);
|
|
281
|
+
}, []), s(() => () => {
|
|
282
|
+
window.removeEventListener("message", c);
|
|
283
|
+
}, []), /* @__PURE__ */ u("iframe", { ref: d, className: e.className, src: m() });
|
|
237
284
|
}
|
|
238
285
|
export {
|
|
239
|
-
|
|
240
|
-
|
|
286
|
+
w as EmbedDirectTemplate,
|
|
287
|
+
g as EmbedSignDocument,
|
|
241
288
|
h as unstable_EmbedCreateDocument,
|
|
242
|
-
|
|
243
|
-
|
|
289
|
+
D as unstable_EmbedCreateTemplate,
|
|
290
|
+
U as unstable_EmbedMultiSignDocument,
|
|
291
|
+
I as unstable_EmbedUpdateDocument,
|
|
244
292
|
E as unstable_EmbedUpdateTemplate
|
|
245
293
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CssVars } from './css-vars';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export type EmbedMultiSignDocumentProps = {
|
|
4
|
+
className?: string;
|
|
5
|
+
host?: string;
|
|
6
|
+
tokens: string[];
|
|
7
|
+
css?: string | undefined;
|
|
8
|
+
cssVars?: (CssVars & Record<string, string>) | undefined;
|
|
9
|
+
darkModeDisabled?: boolean | undefined;
|
|
10
|
+
name?: string | undefined;
|
|
11
|
+
lockName?: boolean | undefined;
|
|
12
|
+
allowDocumentRejection?: boolean | undefined;
|
|
13
|
+
additionalProps?: Record<string, string | number | boolean> | undefined;
|
|
14
|
+
onDocumentReady?: () => void;
|
|
15
|
+
onDocumentCompleted?: (data: {
|
|
16
|
+
token: string;
|
|
17
|
+
documentId: number;
|
|
18
|
+
recipientId: number;
|
|
19
|
+
}) => void;
|
|
20
|
+
onDocumentError?: (error: string) => void;
|
|
21
|
+
onDocumentRejected?: (data: {
|
|
22
|
+
token: string;
|
|
23
|
+
documentId: number;
|
|
24
|
+
recipientId: number;
|
|
25
|
+
reason: string;
|
|
26
|
+
}) => void;
|
|
27
|
+
onAllDocumentsCompleted?: (data: {
|
|
28
|
+
documents: Array<{
|
|
29
|
+
token: string;
|
|
30
|
+
documentId: number;
|
|
31
|
+
recipientId: number;
|
|
32
|
+
action: "document-completed" | "document-rejected";
|
|
33
|
+
reason?: string;
|
|
34
|
+
}>;
|
|
35
|
+
}) => void;
|
|
36
|
+
};
|
|
37
|
+
declare function EmbedMultiSignDocument(props: EmbedMultiSignDocumentProps): React.JSX.Element;
|
|
38
|
+
export default EmbedMultiSignDocument;
|