@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.
@@ -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 r=require("react/jsx-runtime"),c=require("react");function f(e){const d=c.useRef(null);function u(){const n=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}))),t=new URL(`/embed/direct/${e.token}`,n);return e.externalId&&t.searchParams.set("externalId",e.externalId),`${t}#${a}`}function i(n){var a,t,m,s,l,o;if(((a=d.current)==null?void 0:a.contentWindow)===n.source)switch(n.data.action){case"document-ready":(t=e.onDocumentReady)==null||t.call(e);break;case"document-completed":(m=e.onDocumentCompleted)==null||m.call(e,n.data.data);break;case"document-error":(s=e.onDocumentError)==null||s.call(e,n.data.data);break;case"field-signed":(l=e.onFieldSigned)==null||l.call(e);break;case"field-unsigned":(o=e.onFieldUnsigned)==null||o.call(e);break}}return c.useEffect(()=>{window.addEventListener("message",i)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",i)},[]),r.jsx("iframe",{ref:d,className:e.className,src:u()})}function b(e){const d=c.useRef(null);function u(){const n=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})));return`${new URL(`/embed/sign/${e.token}`,n)}#${a}`}function i(n){var a,t,m,s;if(((a=d.current)==null?void 0:a.contentWindow)===n.source)switch(n.data.action){case"document-ready":(t=e.onDocumentReady)==null||t.call(e);break;case"document-completed":(m=e.onDocumentCompleted)==null||m.call(e,n.data.data);break;case"document-error":(s=e.onDocumentError)==null||s.call(e,n.data.data);break}}return c.useEffect(()=>{window.addEventListener("message",i)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",i)},[]),r.jsx("iframe",{ref:d,className:e.className,src:u()})}exports.EmbedDirectTemplate=f;exports.EmbedSignDocument=b;
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 f, useEffect as l } from "react";
3
- function g(e) {
4
- const c = f(null);
5
- function s() {
6
- const a = e.host || "https://app.documenso.com", n = btoa(
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
- ), t = new URL(`/embed/direct/${e.token}`, a);
19
- return e.externalId && t.searchParams.set("externalId", e.externalId), `${t}#${n}`;
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 n, t, m, i, o, u;
23
- if (((n = c.current) == null ? void 0 : n.contentWindow) === a.source)
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
- (t = e.onDocumentReady) == null || t.call(e);
27
+ (n = e.onDocumentReady) == null || n.call(e);
27
28
  break;
28
29
  case "document-completed":
29
- (m = e.onDocumentCompleted) == null || m.call(e, a.data.data);
30
+ (s = e.onDocumentCompleted) == null || s.call(e, a.data.data);
30
31
  break;
31
32
  case "document-error":
32
- (i = e.onDocumentError) == null || i.call(e, a.data.data);
33
+ (o = e.onDocumentError) == null || o.call(e, a.data.data);
33
34
  break;
34
35
  case "field-signed":
35
- (o = e.onFieldSigned) == null || o.call(e);
36
+ (l = e.onFieldSigned) == null || l.call(e);
36
37
  break;
37
38
  case "field-unsigned":
38
- (u = e.onFieldUnsigned) == null || u.call(e);
39
+ (f = e.onFieldUnsigned) == null || f.call(e);
39
40
  break;
40
41
  }
41
42
  }
42
- return l(() => {
43
+ return m(() => {
43
44
  window.addEventListener("message", d);
44
- }, []), l(() => () => {
45
+ }, []), m(() => () => {
45
46
  window.removeEventListener("message", d);
46
- }, []), /* @__PURE__ */ r("iframe", { ref: c, className: e.className, src: s() });
47
+ }, []), /* @__PURE__ */ r("iframe", { ref: c, className: e.className, src: i() });
47
48
  }
48
- function w(e) {
49
- const c = f(null);
50
- function s() {
51
- const a = e.host || "https://app.documenso.com", n = btoa(
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)}#${n}`;
65
+ return `${new URL(`/embed/sign/${e.token}`, a)}#${t}`;
63
66
  }
64
67
  function d(a) {
65
- var n, t, m, i;
66
- if (((n = c.current) == null ? void 0 : n.contentWindow) === a.source)
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
- (t = e.onDocumentReady) == null || t.call(e);
72
+ (n = e.onDocumentReady) == null || n.call(e);
70
73
  break;
71
74
  case "document-completed":
72
- (m = e.onDocumentCompleted) == null || m.call(e, a.data.data);
75
+ (s = e.onDocumentCompleted) == null || s.call(e, a.data.data);
73
76
  break;
74
77
  case "document-error":
75
- (i = e.onDocumentError) == null || i.call(e, a.data.data);
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 l(() => {
157
+ return m(() => {
80
158
  window.addEventListener("message", d);
81
- }, []), l(() => () => {
159
+ }, []), m(() => () => {
82
160
  window.removeEventListener("message", d);
83
- }, []), /* @__PURE__ */ r("iframe", { ref: c, className: e.className, src: s() });
161
+ }, []), /* @__PURE__ */ r("iframe", { ref: c, className: e.className, src: i() });
84
162
  }
85
163
  export {
86
- g as EmbedDirectTemplate,
87
- w as EmbedSignDocument
164
+ w as EmbedDirectTemplate,
165
+ g as EmbedSignDocument,
166
+ D as unstable_EmbedCreateDocument,
167
+ h as unstable_EmbedCreateTemplate
88
168
  };
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@documenso/embed-react",
3
- "version": "0.2.0",
3
+ "version": "0.2.1-rc.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"