@documenso/embed-preact 0.2.0-rc.0 → 0.2.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.js +1 -1
- package/dist/index.mjs +34 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("preact"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("preact"),o=require("preact/hooks");var _=0;function f(e,a,u,m,n,c){a||(a={});var t,d,i=a;if("ref"in i)for(d in i={},a)d=="ref"?t=a[d]:i[d]=a[d];var l={type:e,props:i,key:u,ref:t,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--_,__i:-1,__u:0,__source:n,__self:c};return r.options.vnode&&r.options.vnode(l),l}function b(e){const a=o.useRef(null);function u(){const n=e.host||"https://app.documenso.com",c=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}))),t=new URL(`/embed/direct/${e.token}`,n);return e.externalId&&t.searchParams.set("externalId",e.externalId),`${t}#${c}`}function m(n){var c,t,d,i,l,s;if(((c=a.current)==null?void 0:c.contentWindow)===n.source)switch(n.data.action){case"document-ready":(t=e.onDocumentReady)==null||t.call(e);break;case"document-completed":(d=e.onDocumentCompleted)==null||d.call(e,n.data.data);break;case"document-error":(i=e.onDocumentError)==null||i.call(e,n.data.data);break;case"field-signed":(l=e.onFieldSigned)==null||l.call(e);break;case"field-unsigned":(s=e.onFieldUnsigned)==null||s.call(e);break}}return o.useEffect(()=>{window.addEventListener("message",m)},[]),o.useEffect(()=>()=>{window.removeEventListener("message",m)},[]),f("iframe",{ref:a,className:e.className,src:u()})}function k(e){const a=o.useRef(null);function u(){const n=e.host||"https://app.documenso.com",c=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled})));return`${new URL(`/embed/sign/${e.token}`,n)}#${c}`}function m(n){var c,t,d,i;if(((c=a.current)==null?void 0:c.contentWindow)===n.source)switch(n.data.action){case"document-ready":(t=e.onDocumentReady)==null||t.call(e);break;case"document-completed":(d=e.onDocumentCompleted)==null||d.call(e,n.data.data);break;case"document-error":(i=e.onDocumentError)==null||i.call(e,n.data.data);break}}return o.useEffect(()=>{window.addEventListener("message",m)},[]),o.useEffect(()=>()=>{window.removeEventListener("message",m)},[]),f("iframe",{ref:a,className:e.className,src:u()})}exports.EmbedDirectTemplate=b;exports.EmbedSignDocument=k;
|
package/dist/index.mjs
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import { options as r } from "preact";
|
|
2
|
-
import { useRef as f, useEffect as
|
|
2
|
+
import { useRef as f, useEffect as u } from "preact/hooks";
|
|
3
3
|
var k = 0;
|
|
4
|
-
function _(e, a,
|
|
4
|
+
function _(e, a, o, m, n, t) {
|
|
5
5
|
a || (a = {});
|
|
6
6
|
var c, d, i = a;
|
|
7
7
|
if ("ref" in i) for (d in i = {}, a) d == "ref" ? c = a[d] : i[d] = a[d];
|
|
8
|
-
var
|
|
9
|
-
return r.vnode && r.vnode(
|
|
8
|
+
var l = { type: e, props: i, key: o, ref: c, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --k, __i: -1, __u: 0, __source: n, __self: t };
|
|
9
|
+
return r.vnode && r.vnode(l), l;
|
|
10
10
|
}
|
|
11
11
|
function w(e) {
|
|
12
12
|
const a = f(null);
|
|
13
|
-
function
|
|
13
|
+
function o() {
|
|
14
14
|
const n = e.host || "https://app.documenso.com", t = btoa(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
encodeURIComponent(
|
|
16
|
+
JSON.stringify({
|
|
17
|
+
name: e.name,
|
|
18
|
+
lockName: e.lockName,
|
|
19
|
+
email: e.email,
|
|
20
|
+
lockEmail: e.lockEmail,
|
|
21
|
+
css: e.css,
|
|
22
|
+
cssVars: e.cssVars,
|
|
23
|
+
darkModeDisabled: e.darkModeDisabled
|
|
24
|
+
})
|
|
25
|
+
)
|
|
24
26
|
), c = new URL(`/embed/direct/${e.token}`, n);
|
|
25
27
|
return e.externalId && c.searchParams.set("externalId", e.externalId), `${c}#${t}`;
|
|
26
28
|
}
|
|
27
29
|
function m(n) {
|
|
28
|
-
var t, c, d, i,
|
|
30
|
+
var t, c, d, i, l, s;
|
|
29
31
|
if (((t = a.current) == null ? void 0 : t.contentWindow) === n.source)
|
|
30
32
|
switch (n.data.action) {
|
|
31
33
|
case "document-ready":
|
|
@@ -38,30 +40,32 @@ function w(e) {
|
|
|
38
40
|
(i = e.onDocumentError) == null || i.call(e, n.data.data);
|
|
39
41
|
break;
|
|
40
42
|
case "field-signed":
|
|
41
|
-
(
|
|
43
|
+
(l = e.onFieldSigned) == null || l.call(e);
|
|
42
44
|
break;
|
|
43
45
|
case "field-unsigned":
|
|
44
46
|
(s = e.onFieldUnsigned) == null || s.call(e);
|
|
45
47
|
break;
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
|
-
return
|
|
50
|
+
return u(() => {
|
|
49
51
|
window.addEventListener("message", m);
|
|
50
|
-
}, []),
|
|
52
|
+
}, []), u(() => () => {
|
|
51
53
|
window.removeEventListener("message", m);
|
|
52
|
-
}, []), /* @__PURE__ */ _("iframe", { ref: a, className: e.className, src:
|
|
54
|
+
}, []), /* @__PURE__ */ _("iframe", { ref: a, className: e.className, src: o() });
|
|
53
55
|
}
|
|
54
56
|
function D(e) {
|
|
55
57
|
const a = f(null);
|
|
56
|
-
function
|
|
58
|
+
function o() {
|
|
57
59
|
const n = e.host || "https://app.documenso.com", t = btoa(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
encodeURIComponent(
|
|
61
|
+
JSON.stringify({
|
|
62
|
+
name: e.name,
|
|
63
|
+
lockName: e.lockName,
|
|
64
|
+
css: e.css,
|
|
65
|
+
cssVars: e.cssVars,
|
|
66
|
+
darkModeDisabled: e.darkModeDisabled
|
|
67
|
+
})
|
|
68
|
+
)
|
|
65
69
|
);
|
|
66
70
|
return `${new URL(`/embed/sign/${e.token}`, n)}#${t}`;
|
|
67
71
|
}
|
|
@@ -80,11 +84,11 @@ function D(e) {
|
|
|
80
84
|
break;
|
|
81
85
|
}
|
|
82
86
|
}
|
|
83
|
-
return
|
|
87
|
+
return u(() => {
|
|
84
88
|
window.addEventListener("message", m);
|
|
85
|
-
}, []),
|
|
89
|
+
}, []), u(() => () => {
|
|
86
90
|
window.removeEventListener("message", m);
|
|
87
|
-
}, []), /* @__PURE__ */ _("iframe", { ref: a, className: e.className, src:
|
|
91
|
+
}, []), /* @__PURE__ */ _("iframe", { ref: a, className: e.className, src: o() });
|
|
88
92
|
}
|
|
89
93
|
export {
|
|
90
94
|
w as EmbedDirectTemplate,
|