@documenso/embed-preact 0.2.3 → 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 +128 -129
- package/dist/update-document.d.ts +1 -0
- package/dist/update-template.d.ts +1 -0
- package/package.json +2 -2
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
|
|
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
|
-
import { options as
|
|
2
|
-
import { useRef as
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
if ("ref" in
|
|
8
|
-
var
|
|
9
|
-
return
|
|
1
|
+
import { options as f } from "preact";
|
|
2
|
+
import { useRef as i, useEffect as o } from "preact/hooks";
|
|
3
|
+
var b = 0;
|
|
4
|
+
function m(e, t, s, d, a, c) {
|
|
5
|
+
t || (t = {});
|
|
6
|
+
var n, r, l = t;
|
|
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: 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
|
+
return f.vnode && f.vnode(u), u;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
const
|
|
13
|
-
function
|
|
14
|
-
const a = e.host || "https://app.documenso.com",
|
|
11
|
+
function g(e) {
|
|
12
|
+
const t = i(null);
|
|
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,
|
|
@@ -24,40 +24,39 @@ function h(e) {
|
|
|
24
24
|
...e.additionalProps
|
|
25
25
|
})
|
|
26
26
|
)
|
|
27
|
-
),
|
|
28
|
-
return e.externalId &&
|
|
27
|
+
), n = new URL(`/embed/direct/${e.token}`, a);
|
|
28
|
+
return e.externalId && n.searchParams.set("externalId", e.externalId), `${n}#${c}`;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
|
|
30
|
+
function d(a) {
|
|
31
|
+
if (t.current?.contentWindow === a.source)
|
|
33
32
|
switch (a.data.action) {
|
|
34
33
|
case "document-ready":
|
|
35
|
-
|
|
34
|
+
e.onDocumentReady?.();
|
|
36
35
|
break;
|
|
37
36
|
case "document-completed":
|
|
38
|
-
|
|
37
|
+
e.onDocumentCompleted?.(a.data.data);
|
|
39
38
|
break;
|
|
40
39
|
case "document-error":
|
|
41
|
-
|
|
40
|
+
e.onDocumentError?.(a.data.data);
|
|
42
41
|
break;
|
|
43
42
|
case "field-signed":
|
|
44
|
-
|
|
43
|
+
e.onFieldSigned?.();
|
|
45
44
|
break;
|
|
46
45
|
case "field-unsigned":
|
|
47
|
-
|
|
46
|
+
e.onFieldUnsigned?.();
|
|
48
47
|
break;
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
|
-
return
|
|
52
|
-
window.addEventListener("message",
|
|
53
|
-
}, []),
|
|
54
|
-
window.removeEventListener("message",
|
|
55
|
-
}, []), /* @__PURE__ */
|
|
50
|
+
return o(() => {
|
|
51
|
+
window.addEventListener("message", d);
|
|
52
|
+
}, []), o(() => () => {
|
|
53
|
+
window.removeEventListener("message", d);
|
|
54
|
+
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
|
|
56
55
|
}
|
|
57
|
-
function
|
|
58
|
-
const
|
|
59
|
-
function
|
|
60
|
-
const a = e.host || "https://app.documenso.com",
|
|
56
|
+
function h(e) {
|
|
57
|
+
const t = i(null);
|
|
58
|
+
function s() {
|
|
59
|
+
const a = e.host || "https://app.documenso.com", c = btoa(
|
|
61
60
|
encodeURIComponent(
|
|
62
61
|
JSON.stringify({
|
|
63
62
|
name: e.name,
|
|
@@ -70,36 +69,35 @@ function _(e) {
|
|
|
70
69
|
})
|
|
71
70
|
)
|
|
72
71
|
);
|
|
73
|
-
return `${new URL(`/embed/sign/${e.token}`, a)}#${
|
|
72
|
+
return `${new URL(`/embed/sign/${e.token}`, a)}#${c}`;
|
|
74
73
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
|
|
74
|
+
function d(a) {
|
|
75
|
+
if (t.current?.contentWindow === a.source)
|
|
78
76
|
switch (a.data.action) {
|
|
79
77
|
case "document-ready":
|
|
80
|
-
|
|
78
|
+
e.onDocumentReady?.();
|
|
81
79
|
break;
|
|
82
80
|
case "document-completed":
|
|
83
|
-
|
|
81
|
+
e.onDocumentCompleted?.(a.data.data);
|
|
84
82
|
break;
|
|
85
83
|
case "document-error":
|
|
86
|
-
|
|
84
|
+
e.onDocumentError?.(a.data.data);
|
|
87
85
|
break;
|
|
88
86
|
case "document-rejected":
|
|
89
|
-
|
|
87
|
+
e.onDocumentRejected?.(a.data.data);
|
|
90
88
|
break;
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
|
-
return
|
|
94
|
-
window.addEventListener("message",
|
|
95
|
-
}, []),
|
|
96
|
-
window.removeEventListener("message",
|
|
97
|
-
}, []), /* @__PURE__ */
|
|
91
|
+
return o(() => {
|
|
92
|
+
window.addEventListener("message", d);
|
|
93
|
+
}, []), o(() => () => {
|
|
94
|
+
window.removeEventListener("message", d);
|
|
95
|
+
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
|
|
98
96
|
}
|
|
99
97
|
function D(e) {
|
|
100
|
-
const
|
|
101
|
-
function
|
|
102
|
-
const a = e.host || "https://app.documenso.com",
|
|
98
|
+
const t = i(null);
|
|
99
|
+
function s() {
|
|
100
|
+
const a = e.host || "https://app.documenso.com", c = btoa(
|
|
103
101
|
encodeURIComponent(
|
|
104
102
|
JSON.stringify({
|
|
105
103
|
externalId: e.externalId,
|
|
@@ -110,31 +108,30 @@ function D(e) {
|
|
|
110
108
|
...e.additionalProps
|
|
111
109
|
})
|
|
112
110
|
)
|
|
113
|
-
),
|
|
114
|
-
return
|
|
111
|
+
), n = new URL("/embed/v1/authoring/document/create", a);
|
|
112
|
+
return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
|
|
115
113
|
}
|
|
116
|
-
function
|
|
117
|
-
|
|
118
|
-
if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
|
|
114
|
+
function d(a) {
|
|
115
|
+
if (t.current?.contentWindow === a.source)
|
|
119
116
|
switch (a.data.type) {
|
|
120
117
|
case "document-created":
|
|
121
|
-
|
|
118
|
+
e.onDocumentCreated?.({
|
|
122
119
|
documentId: a.data.documentId,
|
|
123
120
|
externalId: a.data.externalId
|
|
124
121
|
});
|
|
125
122
|
break;
|
|
126
123
|
}
|
|
127
124
|
}
|
|
128
|
-
return
|
|
129
|
-
window.addEventListener("message",
|
|
130
|
-
}, []),
|
|
131
|
-
window.removeEventListener("message",
|
|
132
|
-
}, []), /* @__PURE__ */
|
|
125
|
+
return o(() => {
|
|
126
|
+
window.addEventListener("message", d);
|
|
127
|
+
}, []), o(() => () => {
|
|
128
|
+
window.removeEventListener("message", d);
|
|
129
|
+
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
|
|
133
130
|
}
|
|
134
|
-
function
|
|
135
|
-
const
|
|
136
|
-
function
|
|
137
|
-
const a = e.host || "https://app.documenso.com",
|
|
131
|
+
function _(e) {
|
|
132
|
+
const t = i(null);
|
|
133
|
+
function s() {
|
|
134
|
+
const a = e.host || "https://app.documenso.com", c = btoa(
|
|
138
135
|
encodeURIComponent(
|
|
139
136
|
JSON.stringify({
|
|
140
137
|
externalId: e.externalId,
|
|
@@ -145,31 +142,30 @@ function I(e) {
|
|
|
145
142
|
...e.additionalProps
|
|
146
143
|
})
|
|
147
144
|
)
|
|
148
|
-
),
|
|
149
|
-
return
|
|
145
|
+
), n = new URL("/embed/v1/authoring/template/create", a);
|
|
146
|
+
return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
|
|
150
147
|
}
|
|
151
|
-
function
|
|
152
|
-
|
|
153
|
-
if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
|
|
148
|
+
function d(a) {
|
|
149
|
+
if (t.current?.contentWindow === a.source)
|
|
154
150
|
switch (a.data.type) {
|
|
155
151
|
case "template-created":
|
|
156
|
-
|
|
152
|
+
e.onTemplateCreated?.({
|
|
157
153
|
templateId: a.data.templateId,
|
|
158
154
|
externalId: a.data.externalId
|
|
159
155
|
});
|
|
160
156
|
break;
|
|
161
157
|
}
|
|
162
158
|
}
|
|
163
|
-
return
|
|
164
|
-
window.addEventListener("message",
|
|
165
|
-
}, []),
|
|
166
|
-
window.removeEventListener("message",
|
|
167
|
-
}, []), /* @__PURE__ */
|
|
159
|
+
return o(() => {
|
|
160
|
+
window.addEventListener("message", d);
|
|
161
|
+
}, []), o(() => () => {
|
|
162
|
+
window.removeEventListener("message", d);
|
|
163
|
+
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
|
|
168
164
|
}
|
|
169
165
|
function E(e) {
|
|
170
|
-
const
|
|
171
|
-
function
|
|
172
|
-
const a = e.host || "https://app.documenso.com",
|
|
166
|
+
const t = i(null);
|
|
167
|
+
function s() {
|
|
168
|
+
const a = e.host || "https://app.documenso.com", c = btoa(
|
|
173
169
|
encodeURIComponent(
|
|
174
170
|
JSON.stringify({
|
|
175
171
|
token: e.presignToken,
|
|
@@ -178,37 +174,37 @@ function E(e) {
|
|
|
178
174
|
css: e.css,
|
|
179
175
|
cssVars: e.cssVars,
|
|
180
176
|
darkModeDisabled: e.darkModeDisabled,
|
|
177
|
+
onlyEditFields: e.onlyEditFields,
|
|
181
178
|
...e.additionalProps
|
|
182
179
|
})
|
|
183
180
|
)
|
|
184
|
-
),
|
|
181
|
+
), n = new URL(
|
|
185
182
|
`/embed/v1/authoring/document/edit/${e.documentId}`,
|
|
186
183
|
a
|
|
187
184
|
);
|
|
188
|
-
return
|
|
185
|
+
return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
|
|
189
186
|
}
|
|
190
|
-
function
|
|
191
|
-
|
|
192
|
-
if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
|
|
187
|
+
function d(a) {
|
|
188
|
+
if (t.current?.contentWindow === a.source)
|
|
193
189
|
switch (a.data.type) {
|
|
194
190
|
case "document-updated":
|
|
195
|
-
|
|
191
|
+
e.onDocumentUpdated?.({
|
|
196
192
|
documentId: a.data.documentId,
|
|
197
193
|
externalId: a.data.externalId
|
|
198
194
|
});
|
|
199
195
|
break;
|
|
200
196
|
}
|
|
201
197
|
}
|
|
202
|
-
return
|
|
203
|
-
window.addEventListener("message",
|
|
204
|
-
}, []),
|
|
205
|
-
window.removeEventListener("message",
|
|
206
|
-
}, []), /* @__PURE__ */
|
|
198
|
+
return o(() => {
|
|
199
|
+
window.addEventListener("message", d);
|
|
200
|
+
}, []), o(() => () => {
|
|
201
|
+
window.removeEventListener("message", d);
|
|
202
|
+
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
|
|
207
203
|
}
|
|
208
|
-
function
|
|
209
|
-
const
|
|
210
|
-
function
|
|
211
|
-
const a = e.host || "https://app.documenso.com",
|
|
204
|
+
function I(e) {
|
|
205
|
+
const t = i(null);
|
|
206
|
+
function s() {
|
|
207
|
+
const a = e.host || "https://app.documenso.com", c = btoa(
|
|
212
208
|
encodeURIComponent(
|
|
213
209
|
JSON.stringify({
|
|
214
210
|
externalId: e.externalId,
|
|
@@ -216,37 +212,37 @@ function U(e) {
|
|
|
216
212
|
css: e.css,
|
|
217
213
|
cssVars: e.cssVars,
|
|
218
214
|
darkModeDisabled: e.darkModeDisabled,
|
|
215
|
+
onlyEditFields: e.onlyEditFields,
|
|
219
216
|
...e.additionalProps
|
|
220
217
|
})
|
|
221
218
|
)
|
|
222
|
-
),
|
|
219
|
+
), n = new URL(
|
|
223
220
|
`/embed/v1/authoring/template/edit/${e.templateId}`,
|
|
224
221
|
a
|
|
225
222
|
);
|
|
226
|
-
return
|
|
223
|
+
return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
|
|
227
224
|
}
|
|
228
|
-
function
|
|
229
|
-
|
|
230
|
-
if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
|
|
225
|
+
function d(a) {
|
|
226
|
+
if (t.current?.contentWindow === a.source)
|
|
231
227
|
switch (a.data.type) {
|
|
232
228
|
case "template-updated":
|
|
233
|
-
|
|
229
|
+
e.onTemplateUpdated?.({
|
|
234
230
|
templateId: a.data.templateId,
|
|
235
231
|
externalId: a.data.externalId
|
|
236
232
|
});
|
|
237
233
|
break;
|
|
238
234
|
}
|
|
239
235
|
}
|
|
240
|
-
return
|
|
241
|
-
window.addEventListener("message",
|
|
242
|
-
}, []),
|
|
243
|
-
window.removeEventListener("message",
|
|
244
|
-
}, []), /* @__PURE__ */
|
|
236
|
+
return o(() => {
|
|
237
|
+
window.addEventListener("message", d);
|
|
238
|
+
}, []), o(() => () => {
|
|
239
|
+
window.removeEventListener("message", d);
|
|
240
|
+
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
|
|
245
241
|
}
|
|
246
|
-
function
|
|
247
|
-
const
|
|
248
|
-
function
|
|
249
|
-
const a = e.host || "https://app.documenso.com",
|
|
242
|
+
function U(e) {
|
|
243
|
+
const t = i(null);
|
|
244
|
+
function s() {
|
|
245
|
+
const a = e.host || "https://app.documenso.com", c = btoa(
|
|
250
246
|
encodeURIComponent(
|
|
251
247
|
JSON.stringify({
|
|
252
248
|
name: e.name,
|
|
@@ -258,44 +254,47 @@ function N(e) {
|
|
|
258
254
|
...e.additionalProps
|
|
259
255
|
})
|
|
260
256
|
)
|
|
261
|
-
),
|
|
262
|
-
for (const
|
|
263
|
-
|
|
264
|
-
return `${
|
|
257
|
+
), n = new URL("/embed/v1/multisign", a);
|
|
258
|
+
for (const r of e.tokens)
|
|
259
|
+
n.searchParams.append("token", r);
|
|
260
|
+
return `${n}#${c}`;
|
|
265
261
|
}
|
|
266
|
-
function
|
|
267
|
-
|
|
268
|
-
if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
|
|
262
|
+
function d(a) {
|
|
263
|
+
if (t.current?.contentWindow === a.source)
|
|
269
264
|
switch (a.data.action) {
|
|
270
265
|
case "document-ready":
|
|
271
|
-
|
|
266
|
+
e.onDocumentReady?.();
|
|
272
267
|
break;
|
|
273
268
|
case "document-completed":
|
|
274
|
-
|
|
269
|
+
e.onDocumentCompleted?.(a.data.data);
|
|
275
270
|
break;
|
|
276
271
|
case "document-error":
|
|
277
|
-
|
|
272
|
+
e.onDocumentError?.(a.data.data);
|
|
278
273
|
break;
|
|
279
274
|
case "document-rejected":
|
|
280
|
-
|
|
275
|
+
e.onDocumentRejected?.(a.data.data);
|
|
281
276
|
break;
|
|
282
277
|
case "all-documents-completed":
|
|
283
|
-
|
|
278
|
+
e.onAllDocumentsCompleted?.(a.data.data);
|
|
284
279
|
break;
|
|
285
280
|
}
|
|
286
281
|
}
|
|
287
|
-
return
|
|
288
|
-
window.addEventListener("message",
|
|
289
|
-
}, []),
|
|
290
|
-
window.removeEventListener("message",
|
|
291
|
-
}, []), /* @__PURE__ */
|
|
282
|
+
return o(() => {
|
|
283
|
+
window.addEventListener("message", d);
|
|
284
|
+
}, []), o(() => () => {
|
|
285
|
+
window.removeEventListener("message", d);
|
|
286
|
+
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
|
|
292
287
|
}
|
|
293
288
|
export {
|
|
294
|
-
|
|
295
|
-
_ as
|
|
289
|
+
D as EmbedCreateDocumentV1,
|
|
290
|
+
_ as EmbedCreateTemplateV1,
|
|
291
|
+
g as EmbedDirectTemplate,
|
|
292
|
+
h as EmbedSignDocument,
|
|
293
|
+
E as EmbedUpdateDocumentV1,
|
|
294
|
+
I as EmbedUpdateTemplateV1,
|
|
296
295
|
D as unstable_EmbedCreateDocument,
|
|
297
|
-
|
|
298
|
-
|
|
296
|
+
_ as unstable_EmbedCreateTemplate,
|
|
297
|
+
U as unstable_EmbedMultiSignDocument,
|
|
299
298
|
E as unstable_EmbedUpdateDocument,
|
|
300
|
-
|
|
299
|
+
I as unstable_EmbedUpdateTemplate
|
|
301
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@documenso/embed-preact",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@documenso/embed": "*",
|
|
39
39
|
"@preact/preset-vite": "^2.9.0",
|
|
40
|
-
"vite": "^
|
|
40
|
+
"vite": "^7.0.0",
|
|
41
41
|
"vite-plugin-dts": "^4.1.0"
|
|
42
42
|
}
|
|
43
43
|
}
|