@documenso/embed-preact 0.2.0 → 0.2.1-rc.1
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/create-document.d.ts +26 -0
- package/dist/create-template.d.ts +26 -0
- package/dist/direct-template.d.ts +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +128 -48
- package/dist/sign-document.d.ts +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { h } from 'preact';
|
|
2
|
+
import { CssVars } from './css-vars';
|
|
3
|
+
export type EmbedCreateDocumentProps = {
|
|
4
|
+
className?: string;
|
|
5
|
+
host?: string;
|
|
6
|
+
presignToken: string;
|
|
7
|
+
externalId?: string;
|
|
8
|
+
css?: string | undefined;
|
|
9
|
+
cssVars?: (CssVars & Record<string, string>) | undefined;
|
|
10
|
+
darkModeDisabled?: boolean | undefined;
|
|
11
|
+
features?: {
|
|
12
|
+
allowConfigureSignatureTypes?: boolean;
|
|
13
|
+
allowConfigureLanguage?: boolean;
|
|
14
|
+
allowConfigureDateFormat?: boolean;
|
|
15
|
+
allowConfigureTimezone?: boolean;
|
|
16
|
+
allowConfigureRedirectUrl?: boolean;
|
|
17
|
+
allowConfigureCommunication?: boolean;
|
|
18
|
+
};
|
|
19
|
+
additionalProps?: Record<string, string | number | boolean> | undefined;
|
|
20
|
+
onDocumentCreated?: (data: {
|
|
21
|
+
externalId: string;
|
|
22
|
+
documentId: number;
|
|
23
|
+
}) => void;
|
|
24
|
+
};
|
|
25
|
+
declare function EmbedCreateDocument(props: EmbedCreateDocumentProps): h.JSX.Element;
|
|
26
|
+
export default EmbedCreateDocument;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { h } from 'preact';
|
|
2
|
+
import { CssVars } from './css-vars';
|
|
3
|
+
export type EmbedCreateTemplateProps = {
|
|
4
|
+
className?: string;
|
|
5
|
+
host?: string;
|
|
6
|
+
presignToken: string;
|
|
7
|
+
externalId?: string;
|
|
8
|
+
css?: string | undefined;
|
|
9
|
+
cssVars?: (CssVars & Record<string, string>) | undefined;
|
|
10
|
+
darkModeDisabled?: boolean | undefined;
|
|
11
|
+
features?: {
|
|
12
|
+
allowConfigureSignatureTypes?: boolean;
|
|
13
|
+
allowConfigureLanguage?: boolean;
|
|
14
|
+
allowConfigureDateFormat?: boolean;
|
|
15
|
+
allowConfigureTimezone?: boolean;
|
|
16
|
+
allowConfigureRedirectUrl?: boolean;
|
|
17
|
+
allowConfigureCommunication?: boolean;
|
|
18
|
+
};
|
|
19
|
+
additionalProps?: Record<string, string | number | boolean> | undefined;
|
|
20
|
+
onTemplateCreated?: (data: {
|
|
21
|
+
externalId: string;
|
|
22
|
+
templateId: number;
|
|
23
|
+
}) => void;
|
|
24
|
+
};
|
|
25
|
+
declare function EmbedCreateTemplate(props: EmbedCreateTemplateProps): h.JSX.Element;
|
|
26
|
+
export default EmbedCreateTemplate;
|
|
@@ -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.d.mts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { default as EmbedDirectTemplate } from './direct-template';
|
|
2
2
|
export { default as EmbedSignDocument } from './sign-document';
|
|
3
|
+
export { default as unstable_EmbedCreateDocument } from './create-document';
|
|
4
|
+
export { default as unstable_EmbedCreateTemplate } from './create-template';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { default as EmbedDirectTemplate } from './direct-template';
|
|
2
2
|
export { default as EmbedSignDocument } from './sign-document';
|
|
3
|
+
export { default as unstable_EmbedCreateDocument } from './create-document';
|
|
4
|
+
export { default as unstable_EmbedCreateTemplate } from './create-template';
|
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 f=require("preact"),s=require("preact/hooks");var b=0;function l(e,c,m,d,t,n){c||(c={});var a,i,o=c;if("ref"in o)for(i in o={},c)i=="ref"?a=c[i]:o[i]=c[i];var u={type:e,props:o,key:m,ref:a,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--b,__i:-1,__u:0,__source:t,__self:n};return f.options.vnode&&f.options.vnode(u),u}function k(e){const c=s.useRef(null);function m(){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 d(t){var n,a,i,o,u,r;if(((n=c.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":(i=e.onDocumentCompleted)==null||i.call(e,t.data.data);break;case"document-error":(o=e.onDocumentError)==null||o.call(e,t.data.data);break;case"field-signed":(u=e.onFieldSigned)==null||u.call(e);break;case"field-unsigned":(r=e.onFieldUnsigned)==null||r.call(e);break}}return s.useEffect(()=>{window.addEventListener("message",d)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",d)},[]),l("iframe",{ref:c,className:e.className,src:m()})}function _(e){const c=s.useRef(null);function m(){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 d(t){var n,a,i,o,u;if(((n=c.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":(i=e.onDocumentCompleted)==null||i.call(e,t.data.data);break;case"document-error":(o=e.onDocumentError)==null||o.call(e,t.data.data);break;case"document-rejected":(u=e.onDocumentRejected)==null||u.call(e,t.data.data);break}}return s.useEffect(()=>{window.addEventListener("message",d)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",d)},[]),l("iframe",{ref:c,className:e.className,src:m()})}function w(e){const c=s.useRef(null);function m(){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})));return`${new URL("/embed/v1/authoring/document/create",t)}#${n}`}function d(t){var n,a;if(((n=c.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"document-completed":(a=e.onDocumentCreated)==null||a.call(e,{documentId:t.data.documentId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",d)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",d)},[]),l("iframe",{ref:c,className:e.className,src:m()})}function g(e){const c=s.useRef(null);function m(){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})));return`${new URL("/embed/v1/authoring/template/create",t)}#${n}`}function d(t){var n,a;if(((n=c.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"template-completed":(a=e.onTemplateCreated)==null||a.call(e,{templateId:t.data.templateId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",d)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",d)},[]),l("iframe",{ref:c,className:e.className,src:m()})}exports.EmbedDirectTemplate=k;exports.EmbedSignDocument=_;exports.unstable_EmbedCreateDocument=w;exports.unstable_EmbedCreateTemplate=g;
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { options as
|
|
2
|
-
import { useRef as
|
|
1
|
+
import { options as b } from "preact";
|
|
2
|
+
import { useRef as r, useEffect as l } from "preact/hooks";
|
|
3
3
|
var k = 0;
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
if ("ref" in
|
|
8
|
-
var
|
|
9
|
-
return
|
|
4
|
+
function u(e, c, m, d, a, n) {
|
|
5
|
+
c || (c = {});
|
|
6
|
+
var t, i, s = c;
|
|
7
|
+
if ("ref" in s) for (i in s = {}, c) i == "ref" ? t = c[i] : s[i] = c[i];
|
|
8
|
+
var o = { type: e, props: s, key: m, ref: t, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --k, __i: -1, __u: 0, __source: a, __self: n };
|
|
9
|
+
return b.vnode && b.vnode(o), o;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
const
|
|
13
|
-
function
|
|
14
|
-
const
|
|
11
|
+
function g(e) {
|
|
12
|
+
const c = r(null);
|
|
13
|
+
function m() {
|
|
14
|
+
const a = e.host || "https://app.documenso.com", n = btoa(
|
|
15
15
|
encodeURIComponent(
|
|
16
16
|
JSON.stringify({
|
|
17
17
|
name: e.name,
|
|
@@ -20,77 +20,157 @@ 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}`, a);
|
|
28
|
+
return e.externalId && t.searchParams.set("externalId", e.externalId), `${t}#${n}`;
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
-
var
|
|
31
|
-
if (((
|
|
32
|
-
switch (
|
|
30
|
+
function d(a) {
|
|
31
|
+
var n, t, i, s, o, f;
|
|
32
|
+
if (((n = c.current) == null ? void 0 : n.contentWindow) === a.source)
|
|
33
|
+
switch (a.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
|
+
(i = e.onDocumentCompleted) == null || i.call(e, a.data.data);
|
|
38
39
|
break;
|
|
39
40
|
case "document-error":
|
|
40
|
-
(
|
|
41
|
+
(s = e.onDocumentError) == null || s.call(e, a.data.data);
|
|
41
42
|
break;
|
|
42
43
|
case "field-signed":
|
|
43
|
-
(
|
|
44
|
+
(o = e.onFieldSigned) == null || o.call(e);
|
|
44
45
|
break;
|
|
45
46
|
case "field-unsigned":
|
|
46
|
-
(
|
|
47
|
+
(f = e.onFieldUnsigned) == null || f.call(e);
|
|
47
48
|
break;
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
|
-
return
|
|
51
|
-
window.addEventListener("message",
|
|
52
|
-
}, []),
|
|
53
|
-
window.removeEventListener("message",
|
|
54
|
-
}, []), /* @__PURE__ */
|
|
51
|
+
return l(() => {
|
|
52
|
+
window.addEventListener("message", d);
|
|
53
|
+
}, []), l(() => () => {
|
|
54
|
+
window.removeEventListener("message", d);
|
|
55
|
+
}, []), /* @__PURE__ */ u("iframe", { ref: c, className: e.className, src: m() });
|
|
55
56
|
}
|
|
56
57
|
function D(e) {
|
|
57
|
-
const
|
|
58
|
-
function
|
|
59
|
-
const
|
|
58
|
+
const c = r(null);
|
|
59
|
+
function m() {
|
|
60
|
+
const a = e.host || "https://app.documenso.com", n = 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}`,
|
|
73
|
+
return `${new URL(`/embed/sign/${e.token}`, a)}#${n}`;
|
|
71
74
|
}
|
|
72
|
-
function
|
|
73
|
-
var t,
|
|
74
|
-
if (((
|
|
75
|
-
switch (
|
|
75
|
+
function d(a) {
|
|
76
|
+
var n, t, i, s, o;
|
|
77
|
+
if (((n = c.current) == null ? void 0 : n.contentWindow) === a.source)
|
|
78
|
+
switch (a.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
|
+
(i = e.onDocumentCompleted) == null || i.call(e, a.data.data);
|
|
81
84
|
break;
|
|
82
85
|
case "document-error":
|
|
83
|
-
(
|
|
86
|
+
(s = e.onDocumentError) == null || s.call(e, a.data.data);
|
|
87
|
+
break;
|
|
88
|
+
case "document-rejected":
|
|
89
|
+
(o = e.onDocumentRejected) == null || o.call(e, a.data.data);
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return l(() => {
|
|
94
|
+
window.addEventListener("message", d);
|
|
95
|
+
}, []), l(() => () => {
|
|
96
|
+
window.removeEventListener("message", d);
|
|
97
|
+
}, []), /* @__PURE__ */ u("iframe", { ref: c, className: e.className, src: m() });
|
|
98
|
+
}
|
|
99
|
+
function h(e) {
|
|
100
|
+
const c = r(null);
|
|
101
|
+
function m() {
|
|
102
|
+
const a = e.host || "https://app.documenso.com", n = btoa(
|
|
103
|
+
encodeURIComponent(
|
|
104
|
+
JSON.stringify({
|
|
105
|
+
token: e.presignToken,
|
|
106
|
+
externalId: e.externalId,
|
|
107
|
+
features: e.features,
|
|
108
|
+
css: e.css,
|
|
109
|
+
cssVars: e.cssVars,
|
|
110
|
+
darkModeDisabled: e.darkModeDisabled,
|
|
111
|
+
...e.additionalProps
|
|
112
|
+
})
|
|
113
|
+
)
|
|
114
|
+
);
|
|
115
|
+
return `${new URL("/embed/v1/authoring/document/create", a)}#${n}`;
|
|
116
|
+
}
|
|
117
|
+
function d(a) {
|
|
118
|
+
var n, t;
|
|
119
|
+
if (((n = c.current) == null ? void 0 : n.contentWindow) === a.source)
|
|
120
|
+
switch (a.data.type) {
|
|
121
|
+
case "document-completed":
|
|
122
|
+
(t = e.onDocumentCreated) == null || t.call(e, {
|
|
123
|
+
documentId: a.data.documentId,
|
|
124
|
+
externalId: a.data.externalId
|
|
125
|
+
});
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return l(() => {
|
|
130
|
+
window.addEventListener("message", d);
|
|
131
|
+
}, []), l(() => () => {
|
|
132
|
+
window.removeEventListener("message", d);
|
|
133
|
+
}, []), /* @__PURE__ */ u("iframe", { ref: c, className: e.className, src: m() });
|
|
134
|
+
}
|
|
135
|
+
function E(e) {
|
|
136
|
+
const c = r(null);
|
|
137
|
+
function m() {
|
|
138
|
+
const a = e.host || "https://app.documenso.com", n = btoa(
|
|
139
|
+
encodeURIComponent(
|
|
140
|
+
JSON.stringify({
|
|
141
|
+
token: e.presignToken,
|
|
142
|
+
externalId: e.externalId,
|
|
143
|
+
features: e.features,
|
|
144
|
+
css: e.css,
|
|
145
|
+
cssVars: e.cssVars,
|
|
146
|
+
darkModeDisabled: e.darkModeDisabled,
|
|
147
|
+
...e.additionalProps
|
|
148
|
+
})
|
|
149
|
+
)
|
|
150
|
+
);
|
|
151
|
+
return `${new URL("/embed/v1/authoring/template/create", a)}#${n}`;
|
|
152
|
+
}
|
|
153
|
+
function d(a) {
|
|
154
|
+
var n, t;
|
|
155
|
+
if (((n = c.current) == null ? void 0 : n.contentWindow) === a.source)
|
|
156
|
+
switch (a.data.type) {
|
|
157
|
+
case "template-completed":
|
|
158
|
+
(t = e.onTemplateCreated) == null || t.call(e, {
|
|
159
|
+
templateId: a.data.templateId,
|
|
160
|
+
externalId: a.data.externalId
|
|
161
|
+
});
|
|
84
162
|
break;
|
|
85
163
|
}
|
|
86
164
|
}
|
|
87
|
-
return
|
|
88
|
-
window.addEventListener("message",
|
|
89
|
-
}, []),
|
|
90
|
-
window.removeEventListener("message",
|
|
91
|
-
}, []), /* @__PURE__ */
|
|
165
|
+
return l(() => {
|
|
166
|
+
window.addEventListener("message", d);
|
|
167
|
+
}, []), l(() => () => {
|
|
168
|
+
window.removeEventListener("message", d);
|
|
169
|
+
}, []), /* @__PURE__ */ u("iframe", { ref: c, className: e.className, src: m() });
|
|
92
170
|
}
|
|
93
171
|
export {
|
|
94
|
-
|
|
95
|
-
D as EmbedSignDocument
|
|
172
|
+
g as EmbedDirectTemplate,
|
|
173
|
+
D as EmbedSignDocument,
|
|
174
|
+
h as unstable_EmbedCreateDocument,
|
|
175
|
+
E as unstable_EmbedCreateTemplate
|
|
96
176
|
};
|
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;
|