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