@documenso/embed-react 0.2.1 → 0.2.2
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.js +1 -1
- package/dist/index.mjs +64 -64
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),c=require("react");function f(e){const d=c.useRef(null);function i(){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,o,u,r,l;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":(o=e.onDocumentCompleted)==null||o.call(e,t.data.data);break;case"document-error":(u=e.onDocumentError)==null||u.call(e,t.data.data);break;case"field-signed":(r=e.onFieldSigned)==null||r.call(e);break;case"field-unsigned":(l=e.onFieldUnsigned)==null||l.call(e);break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),m.jsx("iframe",{ref:d,className:e.className,src:i()})}function b(e){const d=c.useRef(null);function i(){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,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":(o=e.onDocumentCompleted)==null||o.call(e,t.data.data);break;case"document-error":(u=e.onDocumentError)==null||u.call(e,t.data.data);break;case"document-rejected":(r=e.onDocumentRejected)==null||r.call(e,t.data.data);break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),m.jsx("iframe",{ref:d,className:e.className,src:i()})}function g(e){const d=c.useRef(null);function i(){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)},[]),m.jsx("iframe",{ref:d,className:e.className,src:i()})}function w(e){const d=c.useRef(null);function i(){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)},[]),m.jsx("iframe",{ref:d,className:e.className,src:i()})}function k(e){const d=c.useRef(null);function i(){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/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),c=require("react");function f(e){const d=c.useRef(null);function i(){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,o,u,r,l;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":(o=e.onDocumentCompleted)==null||o.call(e,t.data.data);break;case"document-error":(u=e.onDocumentError)==null||u.call(e,t.data.data);break;case"field-signed":(r=e.onFieldSigned)==null||r.call(e);break;case"field-unsigned":(l=e.onFieldUnsigned)==null||l.call(e);break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),m.jsx("iframe",{ref:d,className:e.className,src:i()})}function b(e){const d=c.useRef(null);function i(){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,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":(o=e.onDocumentCompleted)==null||o.call(e,t.data.data);break;case"document-error":(u=e.onDocumentError)==null||u.call(e,t.data.data);break;case"document-rejected":(r=e.onDocumentRejected)==null||r.call(e,t.data.data);break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),m.jsx("iframe",{ref:d,className:e.className,src:i()})}function g(e){const d=c.useRef(null);function i(){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)},[]),m.jsx("iframe",{ref:d,className:e.className,src:i()})}function w(e){const d=c.useRef(null);function i(){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)},[]),m.jsx("iframe",{ref:d,className:e.className,src:i()})}function k(e){const d=c.useRef(null);function i(){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)},[]),m.jsx("iframe",{ref:d,className:e.className,src:i()})}function h(e){const d=c.useRef(null);function i(){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)},[]),m.jsx("iframe",{ref:d,className:e.className,src:i()})}exports.EmbedDirectTemplate=f;exports.EmbedSignDocument=b;exports.unstable_EmbedCreateDocument=g;exports.unstable_EmbedCreateTemplate=w;exports.unstable_EmbedUpdateDocument=k;exports.unstable_EmbedUpdateTemplate=h;
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { useRef as o, useEffect as s } from "react";
|
|
|
3
3
|
function g(e) {
|
|
4
4
|
const d = o(null);
|
|
5
5
|
function i() {
|
|
6
|
-
const
|
|
6
|
+
const t = e.host || "https://app.documenso.com", n = btoa(
|
|
7
7
|
encodeURIComponent(
|
|
8
8
|
JSON.stringify({
|
|
9
9
|
name: e.name,
|
|
@@ -16,21 +16,21 @@ function g(e) {
|
|
|
16
16
|
...e.additionalProps
|
|
17
17
|
})
|
|
18
18
|
)
|
|
19
|
-
),
|
|
20
|
-
return e.externalId &&
|
|
19
|
+
), a = new URL(`/embed/direct/${e.token}`, t);
|
|
20
|
+
return e.externalId && a.searchParams.set("externalId", e.externalId), `${a}#${n}`;
|
|
21
21
|
}
|
|
22
|
-
function c(
|
|
23
|
-
var n,
|
|
24
|
-
if (((n = d.current) == null ? void 0 : n.contentWindow) ===
|
|
25
|
-
switch (
|
|
22
|
+
function c(t) {
|
|
23
|
+
var n, a, r, l, u, f;
|
|
24
|
+
if (((n = d.current) == null ? void 0 : n.contentWindow) === t.source)
|
|
25
|
+
switch (t.data.action) {
|
|
26
26
|
case "document-ready":
|
|
27
|
-
(
|
|
27
|
+
(a = e.onDocumentReady) == null || a.call(e);
|
|
28
28
|
break;
|
|
29
29
|
case "document-completed":
|
|
30
|
-
(r = e.onDocumentCompleted) == null || r.call(e,
|
|
30
|
+
(r = e.onDocumentCompleted) == null || r.call(e, t.data.data);
|
|
31
31
|
break;
|
|
32
32
|
case "document-error":
|
|
33
|
-
(l = e.onDocumentError) == null || l.call(e,
|
|
33
|
+
(l = e.onDocumentError) == null || l.call(e, t.data.data);
|
|
34
34
|
break;
|
|
35
35
|
case "field-signed":
|
|
36
36
|
(u = e.onFieldSigned) == null || u.call(e);
|
|
@@ -49,7 +49,7 @@ function g(e) {
|
|
|
49
49
|
function k(e) {
|
|
50
50
|
const d = o(null);
|
|
51
51
|
function i() {
|
|
52
|
-
const
|
|
52
|
+
const t = e.host || "https://app.documenso.com", n = btoa(
|
|
53
53
|
encodeURIComponent(
|
|
54
54
|
JSON.stringify({
|
|
55
55
|
name: e.name,
|
|
@@ -62,23 +62,23 @@ function k(e) {
|
|
|
62
62
|
})
|
|
63
63
|
)
|
|
64
64
|
);
|
|
65
|
-
return `${new URL(`/embed/sign/${e.token}`,
|
|
65
|
+
return `${new URL(`/embed/sign/${e.token}`, t)}#${n}`;
|
|
66
66
|
}
|
|
67
|
-
function c(
|
|
68
|
-
var n,
|
|
69
|
-
if (((n = d.current) == null ? void 0 : n.contentWindow) ===
|
|
70
|
-
switch (
|
|
67
|
+
function c(t) {
|
|
68
|
+
var n, a, r, l, u;
|
|
69
|
+
if (((n = d.current) == null ? void 0 : n.contentWindow) === t.source)
|
|
70
|
+
switch (t.data.action) {
|
|
71
71
|
case "document-ready":
|
|
72
|
-
(
|
|
72
|
+
(a = e.onDocumentReady) == null || a.call(e);
|
|
73
73
|
break;
|
|
74
74
|
case "document-completed":
|
|
75
|
-
(r = e.onDocumentCompleted) == null || r.call(e,
|
|
75
|
+
(r = e.onDocumentCompleted) == null || r.call(e, t.data.data);
|
|
76
76
|
break;
|
|
77
77
|
case "document-error":
|
|
78
|
-
(l = e.onDocumentError) == null || l.call(e,
|
|
78
|
+
(l = e.onDocumentError) == null || l.call(e, t.data.data);
|
|
79
79
|
break;
|
|
80
80
|
case "document-rejected":
|
|
81
|
-
(u = e.onDocumentRejected) == null || u.call(e,
|
|
81
|
+
(u = e.onDocumentRejected) == null || u.call(e, t.data.data);
|
|
82
82
|
break;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -91,7 +91,7 @@ function k(e) {
|
|
|
91
91
|
function h(e) {
|
|
92
92
|
const d = o(null);
|
|
93
93
|
function i() {
|
|
94
|
-
const
|
|
94
|
+
const t = e.host || "https://app.documenso.com", n = btoa(
|
|
95
95
|
encodeURIComponent(
|
|
96
96
|
JSON.stringify({
|
|
97
97
|
externalId: e.externalId,
|
|
@@ -102,17 +102,17 @@ function h(e) {
|
|
|
102
102
|
...e.additionalProps
|
|
103
103
|
})
|
|
104
104
|
)
|
|
105
|
-
),
|
|
106
|
-
return
|
|
105
|
+
), a = new URL("/embed/v1/authoring/document/create", t);
|
|
106
|
+
return a.searchParams.set("token", e.presignToken), a.hash = n, a.toString();
|
|
107
107
|
}
|
|
108
|
-
function c(
|
|
109
|
-
var n,
|
|
110
|
-
if (((n = d.current) == null ? void 0 : n.contentWindow) ===
|
|
111
|
-
switch (
|
|
108
|
+
function c(t) {
|
|
109
|
+
var n, a;
|
|
110
|
+
if (((n = d.current) == null ? void 0 : n.contentWindow) === t.source)
|
|
111
|
+
switch (t.data.type) {
|
|
112
112
|
case "document-created":
|
|
113
|
-
(
|
|
114
|
-
documentId:
|
|
115
|
-
externalId:
|
|
113
|
+
(a = e.onDocumentCreated) == null || a.call(e, {
|
|
114
|
+
documentId: t.data.documentId,
|
|
115
|
+
externalId: t.data.externalId
|
|
116
116
|
});
|
|
117
117
|
break;
|
|
118
118
|
}
|
|
@@ -126,7 +126,7 @@ function h(e) {
|
|
|
126
126
|
function I(e) {
|
|
127
127
|
const d = o(null);
|
|
128
128
|
function i() {
|
|
129
|
-
const
|
|
129
|
+
const t = e.host || "https://app.documenso.com", n = btoa(
|
|
130
130
|
encodeURIComponent(
|
|
131
131
|
JSON.stringify({
|
|
132
132
|
externalId: e.externalId,
|
|
@@ -137,17 +137,17 @@ function I(e) {
|
|
|
137
137
|
...e.additionalProps
|
|
138
138
|
})
|
|
139
139
|
)
|
|
140
|
-
),
|
|
141
|
-
return
|
|
140
|
+
), a = new URL("/embed/v1/authoring/template/create", t);
|
|
141
|
+
return a.searchParams.set("token", e.presignToken), a.hash = n, a.toString();
|
|
142
142
|
}
|
|
143
|
-
function c(
|
|
144
|
-
var n,
|
|
145
|
-
if (((n = d.current) == null ? void 0 : n.contentWindow) ===
|
|
146
|
-
switch (
|
|
143
|
+
function c(t) {
|
|
144
|
+
var n, a;
|
|
145
|
+
if (((n = d.current) == null ? void 0 : n.contentWindow) === t.source)
|
|
146
|
+
switch (t.data.type) {
|
|
147
147
|
case "template-created":
|
|
148
|
-
(
|
|
149
|
-
templateId:
|
|
150
|
-
externalId:
|
|
148
|
+
(a = e.onTemplateCreated) == null || a.call(e, {
|
|
149
|
+
templateId: t.data.templateId,
|
|
150
|
+
externalId: t.data.externalId
|
|
151
151
|
});
|
|
152
152
|
break;
|
|
153
153
|
}
|
|
@@ -161,7 +161,7 @@ function I(e) {
|
|
|
161
161
|
function D(e) {
|
|
162
162
|
const d = o(null);
|
|
163
163
|
function i() {
|
|
164
|
-
const
|
|
164
|
+
const t = e.host || "https://app.documenso.com", n = btoa(
|
|
165
165
|
encodeURIComponent(
|
|
166
166
|
JSON.stringify({
|
|
167
167
|
token: e.presignToken,
|
|
@@ -173,20 +173,20 @@ function D(e) {
|
|
|
173
173
|
...e.additionalProps
|
|
174
174
|
})
|
|
175
175
|
)
|
|
176
|
-
),
|
|
177
|
-
`/embed/v1/authoring/document/
|
|
178
|
-
|
|
176
|
+
), a = new URL(
|
|
177
|
+
`/embed/v1/authoring/document/edit/${e.documentId}`,
|
|
178
|
+
t
|
|
179
179
|
);
|
|
180
|
-
return
|
|
180
|
+
return a.searchParams.set("token", e.presignToken), a.hash = n, a.toString();
|
|
181
181
|
}
|
|
182
|
-
function c(
|
|
183
|
-
var n,
|
|
184
|
-
if (((n = d.current) == null ? void 0 : n.contentWindow) ===
|
|
185
|
-
switch (
|
|
182
|
+
function c(t) {
|
|
183
|
+
var n, a;
|
|
184
|
+
if (((n = d.current) == null ? void 0 : n.contentWindow) === t.source)
|
|
185
|
+
switch (t.data.type) {
|
|
186
186
|
case "document-updated":
|
|
187
|
-
(
|
|
188
|
-
documentId:
|
|
189
|
-
externalId:
|
|
187
|
+
(a = e.onDocumentUpdated) == null || a.call(e, {
|
|
188
|
+
documentId: t.data.documentId,
|
|
189
|
+
externalId: t.data.externalId
|
|
190
190
|
});
|
|
191
191
|
break;
|
|
192
192
|
}
|
|
@@ -200,7 +200,7 @@ function D(e) {
|
|
|
200
200
|
function E(e) {
|
|
201
201
|
const d = o(null);
|
|
202
202
|
function i() {
|
|
203
|
-
const
|
|
203
|
+
const t = e.host || "https://app.documenso.com", n = btoa(
|
|
204
204
|
encodeURIComponent(
|
|
205
205
|
JSON.stringify({
|
|
206
206
|
externalId: e.externalId,
|
|
@@ -211,20 +211,20 @@ function E(e) {
|
|
|
211
211
|
...e.additionalProps
|
|
212
212
|
})
|
|
213
213
|
)
|
|
214
|
-
),
|
|
215
|
-
`/embed/v1/authoring/template/
|
|
216
|
-
|
|
214
|
+
), a = new URL(
|
|
215
|
+
`/embed/v1/authoring/template/edit/${e.templateId}`,
|
|
216
|
+
t
|
|
217
217
|
);
|
|
218
|
-
return
|
|
218
|
+
return a.searchParams.set("token", e.presignToken), a.hash = n, a.toString();
|
|
219
219
|
}
|
|
220
|
-
function c(
|
|
221
|
-
var n,
|
|
222
|
-
if (((n = d.current) == null ? void 0 : n.contentWindow) ===
|
|
223
|
-
switch (
|
|
220
|
+
function c(t) {
|
|
221
|
+
var n, a;
|
|
222
|
+
if (((n = d.current) == null ? void 0 : n.contentWindow) === t.source)
|
|
223
|
+
switch (t.data.type) {
|
|
224
224
|
case "template-updated":
|
|
225
|
-
(
|
|
226
|
-
templateId:
|
|
227
|
-
externalId:
|
|
225
|
+
(a = e.onTemplateUpdated) == null || a.call(e, {
|
|
226
|
+
templateId: t.data.templateId,
|
|
227
|
+
externalId: t.data.externalId
|
|
228
228
|
});
|
|
229
229
|
break;
|
|
230
230
|
}
|