@documenso/embed-react 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 +114 -34
- package/dist/sign-document.d.ts +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CssVars } from './css-vars';
|
|
2
|
+
import * as React from "react";
|
|
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): React.JSX.Element;
|
|
26
|
+
export default EmbedCreateDocument;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CssVars } from './css-vars';
|
|
2
|
+
import * as React from "react";
|
|
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): React.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 l=require("react/jsx-runtime"),c=require("react");function f(e){const d=c.useRef(null);function i(){const t=e.host||"https://app.documenso.com",a=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}#${a}`}function s(t){var a,n,m,o,u,r;if(((a=d.current)==null?void 0:a.contentWindow)===t.source)switch(t.data.action){case"document-ready":(n=e.onDocumentReady)==null||n.call(e);break;case"document-completed":(m=e.onDocumentCompleted)==null||m.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 c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:i()})}function b(e){const d=c.useRef(null);function i(){const t=e.host||"https://app.documenso.com",a=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)}#${a}`}function s(t){var a,n,m,o,u;if(((a=d.current)==null?void 0:a.contentWindow)===t.source)switch(t.data.action){case"document-ready":(n=e.onDocumentReady)==null||n.call(e);break;case"document-completed":(m=e.onDocumentCompleted)==null||m.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 c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:i()})}function k(e){const d=c.useRef(null);function i(){const t=e.host||"https://app.documenso.com",a=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)}#${a}`}function s(t){var a,n;if(((a=d.current)==null?void 0:a.contentWindow)===t.source)switch(t.data.type){case"document-completed":(n=e.onDocumentCreated)==null||n.call(e,{documentId:t.data.documentId,externalId:t.data.externalId});break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:i()})}function w(e){const d=c.useRef(null);function i(){const t=e.host||"https://app.documenso.com",a=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)}#${a}`}function s(t){var a,n;if(((a=d.current)==null?void 0:a.contentWindow)===t.source)switch(t.data.type){case"template-completed":(n=e.onTemplateCreated)==null||n.call(e,{templateId:t.data.templateId,externalId:t.data.externalId});break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:i()})}exports.EmbedDirectTemplate=f;exports.EmbedSignDocument=b;exports.unstable_EmbedCreateDocument=k;exports.unstable_EmbedCreateTemplate=w;
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as
|
|
3
|
-
function
|
|
4
|
-
const c =
|
|
5
|
-
function
|
|
6
|
-
const a = e.host || "https://app.documenso.com",
|
|
2
|
+
import { useRef as u, useEffect as m } from "react";
|
|
3
|
+
function w(e) {
|
|
4
|
+
const c = u(null);
|
|
5
|
+
function i() {
|
|
6
|
+
const a = e.host || "https://app.documenso.com", t = btoa(
|
|
7
7
|
encodeURIComponent(
|
|
8
8
|
JSON.stringify({
|
|
9
9
|
name: e.name,
|
|
@@ -12,77 +12,157 @@ function g(e) {
|
|
|
12
12
|
lockEmail: e.lockEmail,
|
|
13
13
|
css: e.css,
|
|
14
14
|
cssVars: e.cssVars,
|
|
15
|
-
darkModeDisabled: e.darkModeDisabled
|
|
15
|
+
darkModeDisabled: e.darkModeDisabled,
|
|
16
|
+
...e.additionalProps
|
|
16
17
|
})
|
|
17
18
|
)
|
|
18
|
-
),
|
|
19
|
-
return e.externalId &&
|
|
19
|
+
), n = new URL(`/embed/direct/${e.token}`, a);
|
|
20
|
+
return e.externalId && n.searchParams.set("externalId", e.externalId), `${n}#${t}`;
|
|
20
21
|
}
|
|
21
22
|
function d(a) {
|
|
22
|
-
var
|
|
23
|
-
if (((
|
|
23
|
+
var t, n, s, o, l, f;
|
|
24
|
+
if (((t = c.current) == null ? void 0 : t.contentWindow) === a.source)
|
|
24
25
|
switch (a.data.action) {
|
|
25
26
|
case "document-ready":
|
|
26
|
-
(
|
|
27
|
+
(n = e.onDocumentReady) == null || n.call(e);
|
|
27
28
|
break;
|
|
28
29
|
case "document-completed":
|
|
29
|
-
(
|
|
30
|
+
(s = e.onDocumentCompleted) == null || s.call(e, a.data.data);
|
|
30
31
|
break;
|
|
31
32
|
case "document-error":
|
|
32
|
-
(
|
|
33
|
+
(o = e.onDocumentError) == null || o.call(e, a.data.data);
|
|
33
34
|
break;
|
|
34
35
|
case "field-signed":
|
|
35
|
-
(
|
|
36
|
+
(l = e.onFieldSigned) == null || l.call(e);
|
|
36
37
|
break;
|
|
37
38
|
case "field-unsigned":
|
|
38
|
-
(
|
|
39
|
+
(f = e.onFieldUnsigned) == null || f.call(e);
|
|
39
40
|
break;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
|
-
return
|
|
43
|
+
return m(() => {
|
|
43
44
|
window.addEventListener("message", d);
|
|
44
|
-
}, []),
|
|
45
|
+
}, []), m(() => () => {
|
|
45
46
|
window.removeEventListener("message", d);
|
|
46
|
-
}, []), /* @__PURE__ */ r("iframe", { ref: c, className: e.className, src:
|
|
47
|
+
}, []), /* @__PURE__ */ r("iframe", { ref: c, className: e.className, src: i() });
|
|
47
48
|
}
|
|
48
|
-
function
|
|
49
|
-
const c =
|
|
50
|
-
function
|
|
51
|
-
const a = e.host || "https://app.documenso.com",
|
|
49
|
+
function g(e) {
|
|
50
|
+
const c = u(null);
|
|
51
|
+
function i() {
|
|
52
|
+
const a = e.host || "https://app.documenso.com", t = btoa(
|
|
52
53
|
encodeURIComponent(
|
|
53
54
|
JSON.stringify({
|
|
54
55
|
name: e.name,
|
|
55
56
|
lockName: e.lockName,
|
|
56
57
|
css: e.css,
|
|
57
58
|
cssVars: e.cssVars,
|
|
58
|
-
darkModeDisabled: e.darkModeDisabled
|
|
59
|
+
darkModeDisabled: e.darkModeDisabled,
|
|
60
|
+
allowDocumentRejection: e.allowDocumentRejection,
|
|
61
|
+
...e.additionalProps
|
|
59
62
|
})
|
|
60
63
|
)
|
|
61
64
|
);
|
|
62
|
-
return `${new URL(`/embed/sign/${e.token}`, a)}#${
|
|
65
|
+
return `${new URL(`/embed/sign/${e.token}`, a)}#${t}`;
|
|
63
66
|
}
|
|
64
67
|
function d(a) {
|
|
65
|
-
var n,
|
|
66
|
-
if (((
|
|
68
|
+
var t, n, s, o, l;
|
|
69
|
+
if (((t = c.current) == null ? void 0 : t.contentWindow) === a.source)
|
|
67
70
|
switch (a.data.action) {
|
|
68
71
|
case "document-ready":
|
|
69
|
-
(
|
|
72
|
+
(n = e.onDocumentReady) == null || n.call(e);
|
|
70
73
|
break;
|
|
71
74
|
case "document-completed":
|
|
72
|
-
(
|
|
75
|
+
(s = e.onDocumentCompleted) == null || s.call(e, a.data.data);
|
|
73
76
|
break;
|
|
74
77
|
case "document-error":
|
|
75
|
-
(
|
|
78
|
+
(o = e.onDocumentError) == null || o.call(e, a.data.data);
|
|
79
|
+
break;
|
|
80
|
+
case "document-rejected":
|
|
81
|
+
(l = e.onDocumentRejected) == null || l.call(e, a.data.data);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return m(() => {
|
|
86
|
+
window.addEventListener("message", d);
|
|
87
|
+
}, []), m(() => () => {
|
|
88
|
+
window.removeEventListener("message", d);
|
|
89
|
+
}, []), /* @__PURE__ */ r("iframe", { ref: c, className: e.className, src: i() });
|
|
90
|
+
}
|
|
91
|
+
function D(e) {
|
|
92
|
+
const c = u(null);
|
|
93
|
+
function i() {
|
|
94
|
+
const a = e.host || "https://app.documenso.com", t = btoa(
|
|
95
|
+
encodeURIComponent(
|
|
96
|
+
JSON.stringify({
|
|
97
|
+
token: e.presignToken,
|
|
98
|
+
externalId: e.externalId,
|
|
99
|
+
features: e.features,
|
|
100
|
+
css: e.css,
|
|
101
|
+
cssVars: e.cssVars,
|
|
102
|
+
darkModeDisabled: e.darkModeDisabled,
|
|
103
|
+
...e.additionalProps
|
|
104
|
+
})
|
|
105
|
+
)
|
|
106
|
+
);
|
|
107
|
+
return `${new URL("/embed/v1/authoring/document/create", a)}#${t}`;
|
|
108
|
+
}
|
|
109
|
+
function d(a) {
|
|
110
|
+
var t, n;
|
|
111
|
+
if (((t = c.current) == null ? void 0 : t.contentWindow) === a.source)
|
|
112
|
+
switch (a.data.type) {
|
|
113
|
+
case "document-completed":
|
|
114
|
+
(n = e.onDocumentCreated) == null || n.call(e, {
|
|
115
|
+
documentId: a.data.documentId,
|
|
116
|
+
externalId: a.data.externalId
|
|
117
|
+
});
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return m(() => {
|
|
122
|
+
window.addEventListener("message", d);
|
|
123
|
+
}, []), m(() => () => {
|
|
124
|
+
window.removeEventListener("message", d);
|
|
125
|
+
}, []), /* @__PURE__ */ r("iframe", { ref: c, className: e.className, src: i() });
|
|
126
|
+
}
|
|
127
|
+
function h(e) {
|
|
128
|
+
const c = u(null);
|
|
129
|
+
function i() {
|
|
130
|
+
const a = e.host || "https://app.documenso.com", t = btoa(
|
|
131
|
+
encodeURIComponent(
|
|
132
|
+
JSON.stringify({
|
|
133
|
+
token: e.presignToken,
|
|
134
|
+
externalId: e.externalId,
|
|
135
|
+
features: e.features,
|
|
136
|
+
css: e.css,
|
|
137
|
+
cssVars: e.cssVars,
|
|
138
|
+
darkModeDisabled: e.darkModeDisabled,
|
|
139
|
+
...e.additionalProps
|
|
140
|
+
})
|
|
141
|
+
)
|
|
142
|
+
);
|
|
143
|
+
return `${new URL("/embed/v1/authoring/template/create", a)}#${t}`;
|
|
144
|
+
}
|
|
145
|
+
function d(a) {
|
|
146
|
+
var t, n;
|
|
147
|
+
if (((t = c.current) == null ? void 0 : t.contentWindow) === a.source)
|
|
148
|
+
switch (a.data.type) {
|
|
149
|
+
case "template-completed":
|
|
150
|
+
(n = e.onTemplateCreated) == null || n.call(e, {
|
|
151
|
+
templateId: a.data.templateId,
|
|
152
|
+
externalId: a.data.externalId
|
|
153
|
+
});
|
|
76
154
|
break;
|
|
77
155
|
}
|
|
78
156
|
}
|
|
79
|
-
return
|
|
157
|
+
return m(() => {
|
|
80
158
|
window.addEventListener("message", d);
|
|
81
|
-
}, []),
|
|
159
|
+
}, []), m(() => () => {
|
|
82
160
|
window.removeEventListener("message", d);
|
|
83
|
-
}, []), /* @__PURE__ */ r("iframe", { ref: c, className: e.className, src:
|
|
161
|
+
}, []), /* @__PURE__ */ r("iframe", { ref: c, className: e.className, src: i() });
|
|
84
162
|
}
|
|
85
163
|
export {
|
|
86
|
-
|
|
87
|
-
|
|
164
|
+
w as EmbedDirectTemplate,
|
|
165
|
+
g as EmbedSignDocument,
|
|
166
|
+
D as unstable_EmbedCreateDocument,
|
|
167
|
+
h as unstable_EmbedCreateTemplate
|
|
88
168
|
};
|
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): React.JSX.Element;
|
|
21
29
|
export default EmbedSignDocument;
|