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