@documenso/embed-preact 0.3.0 → 0.4.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/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +44 -38
- package/dist/update-document.d.ts +1 -0
- package/dist/update-template.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export { default as EmbedDirectTemplate } from './direct-template';
|
|
2
2
|
export { default as EmbedSignDocument } from './sign-document';
|
|
3
|
+
export { default as EmbedCreateDocumentV1 } from './create-document';
|
|
4
|
+
export { default as EmbedCreateTemplateV1 } from './create-template';
|
|
5
|
+
export { default as EmbedUpdateDocumentV1 } from './update-document';
|
|
6
|
+
export { default as EmbedUpdateTemplateV1 } from './update-template';
|
|
3
7
|
export { default as unstable_EmbedCreateDocument } from './create-document';
|
|
4
8
|
export { default as unstable_EmbedCreateTemplate } from './create-template';
|
|
5
9
|
export { default as unstable_EmbedUpdateDocument } from './update-document';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export { default as EmbedDirectTemplate } from './direct-template';
|
|
2
2
|
export { default as EmbedSignDocument } from './sign-document';
|
|
3
|
+
export { default as EmbedCreateDocumentV1 } from './create-document';
|
|
4
|
+
export { default as EmbedCreateTemplateV1 } from './create-template';
|
|
5
|
+
export { default as EmbedUpdateDocumentV1 } from './update-document';
|
|
6
|
+
export { default as EmbedUpdateTemplateV1 } from './update-template';
|
|
3
7
|
export { default as unstable_EmbedCreateDocument } from './create-document';
|
|
4
8
|
export { default as unstable_EmbedCreateTemplate } from './create-template';
|
|
5
9
|
export { default as unstable_EmbedUpdateDocument } from './update-document';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("preact"),s=require("preact/hooks");var
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("preact"),s=require("preact/hooks");var g=0;function i(e,a,d,c,t,o){a||(a={});var n,r,m=a;if("ref"in m)for(r in m={},a)r=="ref"?n=a[r]:m[r]=a[r];var u={type:e,props:m,key:d,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--g,__i:-1,__u:0,__source:t,__self:o};return l.options.vnode&&l.options.vnode(u),u}function w(e){const a=s.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=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}))),n=new URL(`/embed/direct/${e.token}`,t);return e.externalId&&n.searchParams.set("externalId",e.externalId),`${n}#${o}`}function c(t){if(a.current?.contentWindow===t.source)switch(t.data.action){case"document-ready":e.onDocumentReady?.();break;case"document-completed":e.onDocumentCompleted?.(t.data.data);break;case"document-error":e.onDocumentError?.(t.data.data);break;case"field-signed":e.onFieldSigned?.();break;case"field-unsigned":e.onFieldUnsigned?.();break}}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function h(e){const a=s.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=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)}#${o}`}function c(t){if(a.current?.contentWindow===t.source)switch(t.data.action){case"document-ready":e.onDocumentReady?.();break;case"document-completed":e.onDocumentCompleted?.(t.data.data);break;case"document-error":e.onDocumentError?.(t.data.data);break;case"document-rejected":e.onDocumentRejected?.(t.data.data);break}}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function f(e){const a=s.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),n=new URL("/embed/v1/authoring/document/create",t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function c(t){if(a.current?.contentWindow===t.source)switch(t.data.type){case"document-created":e.onDocumentCreated?.({documentId:t.data.documentId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function b(e){const a=s.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),n=new URL("/embed/v1/authoring/template/create",t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function c(t){if(a.current?.contentWindow===t.source)switch(t.data.type){case"template-created":e.onTemplateCreated?.({templateId:t.data.templateId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function k(e){const a=s.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({token:e.presignToken,externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,onlyEditFields:e.onlyEditFields,...e.additionalProps}))),n=new URL(`/embed/v1/authoring/document/edit/${e.documentId}`,t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function c(t){if(a.current?.contentWindow===t.source)switch(t.data.type){case"document-updated":e.onDocumentUpdated?.({documentId:t.data.documentId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function E(e){const a=s.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,onlyEditFields:e.onlyEditFields,...e.additionalProps}))),n=new URL(`/embed/v1/authoring/template/edit/${e.templateId}`,t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function c(t){if(a.current?.contentWindow===t.source)switch(t.data.type){case"template-updated":e.onTemplateUpdated?.({templateId:t.data.templateId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function D(e){const a=s.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,allowDocumentRejection:e.allowDocumentRejection,...e.additionalProps}))),n=new URL("/embed/v1/multisign",t);for(const r of e.tokens)n.searchParams.append("token",r);return`${n}#${o}`}function c(t){if(a.current?.contentWindow===t.source)switch(t.data.action){case"document-ready":e.onDocumentReady?.();break;case"document-completed":e.onDocumentCompleted?.(t.data.data);break;case"document-error":e.onDocumentError?.(t.data.data);break;case"document-rejected":e.onDocumentRejected?.(t.data.data);break;case"all-documents-completed":e.onAllDocumentsCompleted?.(t.data.data);break}}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}exports.EmbedCreateDocumentV1=f;exports.EmbedCreateTemplateV1=b;exports.EmbedDirectTemplate=w;exports.EmbedSignDocument=h;exports.EmbedUpdateDocumentV1=k;exports.EmbedUpdateTemplateV1=E;exports.unstable_EmbedCreateDocument=f;exports.unstable_EmbedCreateTemplate=b;exports.unstable_EmbedMultiSignDocument=D;exports.unstable_EmbedUpdateDocument=k;exports.unstable_EmbedUpdateTemplate=E;
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { options as f } from "preact";
|
|
2
2
|
import { useRef as i, useEffect as o } from "preact/hooks";
|
|
3
3
|
var b = 0;
|
|
4
|
-
function m(e, t,
|
|
4
|
+
function m(e, t, s, d, a, c) {
|
|
5
5
|
t || (t = {});
|
|
6
6
|
var n, r, l = t;
|
|
7
7
|
if ("ref" in l) for (r in l = {}, t) r == "ref" ? n = t[r] : l[r] = t[r];
|
|
8
|
-
var u = { type: e, props: l, key:
|
|
8
|
+
var u = { type: e, props: l, key: s, ref: n, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --b, __i: -1, __u: 0, __source: a, __self: c };
|
|
9
9
|
return f.vnode && f.vnode(u), u;
|
|
10
10
|
}
|
|
11
11
|
function g(e) {
|
|
12
12
|
const t = i(null);
|
|
13
|
-
function
|
|
14
|
-
const a = e.host || "https://app.documenso.com",
|
|
13
|
+
function s() {
|
|
14
|
+
const a = e.host || "https://app.documenso.com", c = btoa(
|
|
15
15
|
encodeURIComponent(
|
|
16
16
|
JSON.stringify({
|
|
17
17
|
name: e.name,
|
|
@@ -25,7 +25,7 @@ function g(e) {
|
|
|
25
25
|
})
|
|
26
26
|
)
|
|
27
27
|
), n = new URL(`/embed/direct/${e.token}`, a);
|
|
28
|
-
return e.externalId && n.searchParams.set("externalId", e.externalId), `${n}#${
|
|
28
|
+
return e.externalId && n.searchParams.set("externalId", e.externalId), `${n}#${c}`;
|
|
29
29
|
}
|
|
30
30
|
function d(a) {
|
|
31
31
|
if (t.current?.contentWindow === a.source)
|
|
@@ -51,12 +51,12 @@ function g(e) {
|
|
|
51
51
|
window.addEventListener("message", d);
|
|
52
52
|
}, []), o(() => () => {
|
|
53
53
|
window.removeEventListener("message", d);
|
|
54
|
-
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src:
|
|
54
|
+
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
|
|
55
55
|
}
|
|
56
56
|
function h(e) {
|
|
57
57
|
const t = i(null);
|
|
58
|
-
function
|
|
59
|
-
const a = e.host || "https://app.documenso.com",
|
|
58
|
+
function s() {
|
|
59
|
+
const a = e.host || "https://app.documenso.com", c = btoa(
|
|
60
60
|
encodeURIComponent(
|
|
61
61
|
JSON.stringify({
|
|
62
62
|
name: e.name,
|
|
@@ -69,7 +69,7 @@ function h(e) {
|
|
|
69
69
|
})
|
|
70
70
|
)
|
|
71
71
|
);
|
|
72
|
-
return `${new URL(`/embed/sign/${e.token}`, a)}#${
|
|
72
|
+
return `${new URL(`/embed/sign/${e.token}`, a)}#${c}`;
|
|
73
73
|
}
|
|
74
74
|
function d(a) {
|
|
75
75
|
if (t.current?.contentWindow === a.source)
|
|
@@ -92,12 +92,12 @@ function h(e) {
|
|
|
92
92
|
window.addEventListener("message", d);
|
|
93
93
|
}, []), o(() => () => {
|
|
94
94
|
window.removeEventListener("message", d);
|
|
95
|
-
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src:
|
|
95
|
+
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function D(e) {
|
|
98
98
|
const t = i(null);
|
|
99
|
-
function
|
|
100
|
-
const a = e.host || "https://app.documenso.com",
|
|
99
|
+
function s() {
|
|
100
|
+
const a = e.host || "https://app.documenso.com", c = btoa(
|
|
101
101
|
encodeURIComponent(
|
|
102
102
|
JSON.stringify({
|
|
103
103
|
externalId: e.externalId,
|
|
@@ -109,7 +109,7 @@ function _(e) {
|
|
|
109
109
|
})
|
|
110
110
|
)
|
|
111
111
|
), n = new URL("/embed/v1/authoring/document/create", a);
|
|
112
|
-
return n.searchParams.set("token", e.presignToken), n.hash =
|
|
112
|
+
return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
|
|
113
113
|
}
|
|
114
114
|
function d(a) {
|
|
115
115
|
if (t.current?.contentWindow === a.source)
|
|
@@ -126,12 +126,12 @@ function _(e) {
|
|
|
126
126
|
window.addEventListener("message", d);
|
|
127
127
|
}, []), o(() => () => {
|
|
128
128
|
window.removeEventListener("message", d);
|
|
129
|
-
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src:
|
|
129
|
+
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function _(e) {
|
|
132
132
|
const t = i(null);
|
|
133
|
-
function
|
|
134
|
-
const a = e.host || "https://app.documenso.com",
|
|
133
|
+
function s() {
|
|
134
|
+
const a = e.host || "https://app.documenso.com", c = btoa(
|
|
135
135
|
encodeURIComponent(
|
|
136
136
|
JSON.stringify({
|
|
137
137
|
externalId: e.externalId,
|
|
@@ -143,7 +143,7 @@ function D(e) {
|
|
|
143
143
|
})
|
|
144
144
|
)
|
|
145
145
|
), n = new URL("/embed/v1/authoring/template/create", a);
|
|
146
|
-
return n.searchParams.set("token", e.presignToken), n.hash =
|
|
146
|
+
return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
|
|
147
147
|
}
|
|
148
148
|
function d(a) {
|
|
149
149
|
if (t.current?.contentWindow === a.source)
|
|
@@ -160,12 +160,12 @@ function D(e) {
|
|
|
160
160
|
window.addEventListener("message", d);
|
|
161
161
|
}, []), o(() => () => {
|
|
162
162
|
window.removeEventListener("message", d);
|
|
163
|
-
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src:
|
|
163
|
+
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function E(e) {
|
|
166
166
|
const t = i(null);
|
|
167
|
-
function
|
|
168
|
-
const a = e.host || "https://app.documenso.com",
|
|
167
|
+
function s() {
|
|
168
|
+
const a = e.host || "https://app.documenso.com", c = btoa(
|
|
169
169
|
encodeURIComponent(
|
|
170
170
|
JSON.stringify({
|
|
171
171
|
token: e.presignToken,
|
|
@@ -174,6 +174,7 @@ function I(e) {
|
|
|
174
174
|
css: e.css,
|
|
175
175
|
cssVars: e.cssVars,
|
|
176
176
|
darkModeDisabled: e.darkModeDisabled,
|
|
177
|
+
onlyEditFields: e.onlyEditFields,
|
|
177
178
|
...e.additionalProps
|
|
178
179
|
})
|
|
179
180
|
)
|
|
@@ -181,7 +182,7 @@ function I(e) {
|
|
|
181
182
|
`/embed/v1/authoring/document/edit/${e.documentId}`,
|
|
182
183
|
a
|
|
183
184
|
);
|
|
184
|
-
return n.searchParams.set("token", e.presignToken), n.hash =
|
|
185
|
+
return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
|
|
185
186
|
}
|
|
186
187
|
function d(a) {
|
|
187
188
|
if (t.current?.contentWindow === a.source)
|
|
@@ -198,12 +199,12 @@ function I(e) {
|
|
|
198
199
|
window.addEventListener("message", d);
|
|
199
200
|
}, []), o(() => () => {
|
|
200
201
|
window.removeEventListener("message", d);
|
|
201
|
-
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src:
|
|
202
|
+
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
|
|
202
203
|
}
|
|
203
|
-
function
|
|
204
|
+
function I(e) {
|
|
204
205
|
const t = i(null);
|
|
205
|
-
function
|
|
206
|
-
const a = e.host || "https://app.documenso.com",
|
|
206
|
+
function s() {
|
|
207
|
+
const a = e.host || "https://app.documenso.com", c = btoa(
|
|
207
208
|
encodeURIComponent(
|
|
208
209
|
JSON.stringify({
|
|
209
210
|
externalId: e.externalId,
|
|
@@ -211,6 +212,7 @@ function E(e) {
|
|
|
211
212
|
css: e.css,
|
|
212
213
|
cssVars: e.cssVars,
|
|
213
214
|
darkModeDisabled: e.darkModeDisabled,
|
|
215
|
+
onlyEditFields: e.onlyEditFields,
|
|
214
216
|
...e.additionalProps
|
|
215
217
|
})
|
|
216
218
|
)
|
|
@@ -218,7 +220,7 @@ function E(e) {
|
|
|
218
220
|
`/embed/v1/authoring/template/edit/${e.templateId}`,
|
|
219
221
|
a
|
|
220
222
|
);
|
|
221
|
-
return n.searchParams.set("token", e.presignToken), n.hash =
|
|
223
|
+
return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
|
|
222
224
|
}
|
|
223
225
|
function d(a) {
|
|
224
226
|
if (t.current?.contentWindow === a.source)
|
|
@@ -235,12 +237,12 @@ function E(e) {
|
|
|
235
237
|
window.addEventListener("message", d);
|
|
236
238
|
}, []), o(() => () => {
|
|
237
239
|
window.removeEventListener("message", d);
|
|
238
|
-
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src:
|
|
240
|
+
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
|
|
239
241
|
}
|
|
240
242
|
function U(e) {
|
|
241
243
|
const t = i(null);
|
|
242
|
-
function
|
|
243
|
-
const a = e.host || "https://app.documenso.com",
|
|
244
|
+
function s() {
|
|
245
|
+
const a = e.host || "https://app.documenso.com", c = btoa(
|
|
244
246
|
encodeURIComponent(
|
|
245
247
|
JSON.stringify({
|
|
246
248
|
name: e.name,
|
|
@@ -255,7 +257,7 @@ function U(e) {
|
|
|
255
257
|
), n = new URL("/embed/v1/multisign", a);
|
|
256
258
|
for (const r of e.tokens)
|
|
257
259
|
n.searchParams.append("token", r);
|
|
258
|
-
return `${n}#${
|
|
260
|
+
return `${n}#${c}`;
|
|
259
261
|
}
|
|
260
262
|
function d(a) {
|
|
261
263
|
if (t.current?.contentWindow === a.source)
|
|
@@ -281,14 +283,18 @@ function U(e) {
|
|
|
281
283
|
window.addEventListener("message", d);
|
|
282
284
|
}, []), o(() => () => {
|
|
283
285
|
window.removeEventListener("message", d);
|
|
284
|
-
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src:
|
|
286
|
+
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
|
|
285
287
|
}
|
|
286
288
|
export {
|
|
289
|
+
D as EmbedCreateDocumentV1,
|
|
290
|
+
_ as EmbedCreateTemplateV1,
|
|
287
291
|
g as EmbedDirectTemplate,
|
|
288
292
|
h as EmbedSignDocument,
|
|
289
|
-
|
|
290
|
-
|
|
293
|
+
E as EmbedUpdateDocumentV1,
|
|
294
|
+
I as EmbedUpdateTemplateV1,
|
|
295
|
+
D as unstable_EmbedCreateDocument,
|
|
296
|
+
_ as unstable_EmbedCreateTemplate,
|
|
291
297
|
U as unstable_EmbedMultiSignDocument,
|
|
292
|
-
|
|
293
|
-
|
|
298
|
+
E as unstable_EmbedUpdateDocument,
|
|
299
|
+
I as unstable_EmbedUpdateTemplate
|
|
294
300
|
};
|
|
@@ -17,6 +17,7 @@ export type EmbedUpdateDocumentProps = {
|
|
|
17
17
|
allowConfigureRedirectUrl?: boolean;
|
|
18
18
|
allowConfigureCommunication?: boolean;
|
|
19
19
|
};
|
|
20
|
+
onlyEditFields?: boolean | undefined;
|
|
20
21
|
additionalProps?: Record<string, string | number | boolean> | undefined;
|
|
21
22
|
onDocumentUpdated?: (data: {
|
|
22
23
|
externalId: string;
|
|
@@ -17,6 +17,7 @@ export type EmbedUpdateTemplateProps = {
|
|
|
17
17
|
allowConfigureRedirectUrl?: boolean;
|
|
18
18
|
allowConfigureCommunication?: boolean;
|
|
19
19
|
};
|
|
20
|
+
onlyEditFields?: boolean | undefined;
|
|
20
21
|
additionalProps?: Record<string, string | number | boolean> | undefined;
|
|
21
22
|
onTemplateUpdated?: (data: {
|
|
22
23
|
externalId: string;
|