@documenso/embed-react 0.2.2 → 0.3.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/index.d.mts CHANGED
@@ -4,3 +4,4 @@ export { default as unstable_EmbedCreateDocument } from './create-document';
4
4
  export { default as unstable_EmbedCreateTemplate } from './create-template';
5
5
  export { default as unstable_EmbedUpdateDocument } from './update-document';
6
6
  export { default as unstable_EmbedUpdateTemplate } from './update-template';
7
+ export { default as unstable_EmbedMultiSignDocument } from './multisign-document';
package/dist/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export { default as unstable_EmbedCreateDocument } from './create-document';
4
4
  export { default as unstable_EmbedCreateTemplate } from './create-template';
5
5
  export { default as unstable_EmbedUpdateDocument } from './update-document';
6
6
  export { default as unstable_EmbedUpdateTemplate } from './update-template';
7
+ export { default as unstable_EmbedMultiSignDocument } from './multisign-document';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=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",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 s(t){var n,a,o,u,r,l;if(((n=d.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":(o=e.onDocumentCompleted)==null||o.call(e,t.data.data);break;case"document-error":(u=e.onDocumentError)==null||u.call(e,t.data.data);break;case"field-signed":(r=e.onFieldSigned)==null||r.call(e);break;case"field-unsigned":(l=e.onFieldUnsigned)==null||l.call(e);break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),m.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",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 s(t){var n,a,o,u,r;if(((n=d.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":(o=e.onDocumentCompleted)==null||o.call(e,t.data.data);break;case"document-error":(u=e.onDocumentError)==null||u.call(e,t.data.data);break;case"document-rejected":(r=e.onDocumentRejected)==null||r.call(e,t.data.data);break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),m.jsx("iframe",{ref:d,className:e.className,src:i()})}function g(e){const d=c.useRef(null);function i(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL("/embed/v1/authoring/document/create",t);return a.searchParams.set("token",e.presignToken),a.hash=n,a.toString()}function s(t){var n,a;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"document-created":(a=e.onDocumentCreated)==null||a.call(e,{documentId:t.data.documentId,externalId:t.data.externalId});break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),m.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",n=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL("/embed/v1/authoring/template/create",t);return a.searchParams.set("token",e.presignToken),a.hash=n,a.toString()}function s(t){var n,a;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"template-created":(a=e.onTemplateCreated)==null||a.call(e,{templateId:t.data.templateId,externalId:t.data.externalId});break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),m.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",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}))),a=new URL(`/embed/v1/authoring/document/edit/${e.documentId}`,t);return a.searchParams.set("token",e.presignToken),a.hash=n,a.toString()}function s(t){var n,a;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"document-updated":(a=e.onDocumentUpdated)==null||a.call(e,{documentId:t.data.documentId,externalId:t.data.externalId});break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),m.jsx("iframe",{ref:d,className:e.className,src:i()})}function h(e){const d=c.useRef(null);function i(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL(`/embed/v1/authoring/template/edit/${e.templateId}`,t);return a.searchParams.set("token",e.presignToken),a.hash=n,a.toString()}function s(t){var n,a;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"template-updated":(a=e.onTemplateUpdated)==null||a.call(e,{templateId:t.data.templateId,externalId:t.data.externalId});break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),m.jsx("iframe",{ref:d,className:e.className,src:i()})}exports.EmbedDirectTemplate=f;exports.EmbedSignDocument=b;exports.unstable_EmbedCreateDocument=g;exports.unstable_EmbedCreateTemplate=w;exports.unstable_EmbedUpdateDocument=k;exports.unstable_EmbedUpdateTemplate=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),n=require("react");function i(e){const s=n.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=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}#${o}`}function c(t){if(s.current?.contentWindow===t.source)switch(t.data.action){case"document-ready":e.onDocumentReady?.();break;case"document-completed":e.onDocumentCompleted?.(t.data.data);break;case"document-error":e.onDocumentError?.(t.data.data);break;case"field-signed":e.onFieldSigned?.();break;case"field-unsigned":e.onFieldUnsigned?.();break}}return n.useEffect(()=>{window.addEventListener("message",c)},[]),n.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),r.jsx("iframe",{ref:s,className:e.className,src:d()})}function u(e){const s=n.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=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)}#${o}`}function c(t){if(s.current?.contentWindow===t.source)switch(t.data.action){case"document-ready":e.onDocumentReady?.();break;case"document-completed":e.onDocumentCompleted?.(t.data.data);break;case"document-error":e.onDocumentError?.(t.data.data);break;case"document-rejected":e.onDocumentRejected?.(t.data.data);break}}return n.useEffect(()=>{window.addEventListener("message",c)},[]),n.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),r.jsx("iframe",{ref:s,className:e.className,src:d()})}function l(e){const s=n.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL("/embed/v1/authoring/document/create",t);return a.searchParams.set("token",e.presignToken),a.hash=o,a.toString()}function c(t){if(s.current?.contentWindow===t.source)switch(t.data.type){case"document-created":e.onDocumentCreated?.({documentId:t.data.documentId,externalId:t.data.externalId});break}}return n.useEffect(()=>{window.addEventListener("message",c)},[]),n.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),r.jsx("iframe",{ref:s,className:e.className,src:d()})}function f(e){const s=n.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL("/embed/v1/authoring/template/create",t);return a.searchParams.set("token",e.presignToken),a.hash=o,a.toString()}function c(t){if(s.current?.contentWindow===t.source)switch(t.data.type){case"template-created":e.onTemplateCreated?.({templateId:t.data.templateId,externalId:t.data.externalId});break}}return n.useEffect(()=>{window.addEventListener("message",c)},[]),n.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),r.jsx("iframe",{ref:s,className:e.className,src:d()})}function b(e){const s=n.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({token:e.presignToken,externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL(`/embed/v1/authoring/document/edit/${e.documentId}`,t);return a.searchParams.set("token",e.presignToken),a.hash=o,a.toString()}function c(t){if(s.current?.contentWindow===t.source)switch(t.data.type){case"document-updated":e.onDocumentUpdated?.({documentId:t.data.documentId,externalId:t.data.externalId});break}}return n.useEffect(()=>{window.addEventListener("message",c)},[]),n.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),r.jsx("iframe",{ref:s,className:e.className,src:d()})}function k(e){const s=n.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL(`/embed/v1/authoring/template/edit/${e.templateId}`,t);return a.searchParams.set("token",e.presignToken),a.hash=o,a.toString()}function c(t){if(s.current?.contentWindow===t.source)switch(t.data.type){case"template-updated":e.onTemplateUpdated?.({templateId:t.data.templateId,externalId:t.data.externalId});break}}return n.useEffect(()=>{window.addEventListener("message",c)},[]),n.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),r.jsx("iframe",{ref:s,className:e.className,src:d()})}function g(e){const s=n.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,allowDocumentRejection:e.allowDocumentRejection,...e.additionalProps}))),a=new URL("/embed/v1/multisign",t);for(const m of e.tokens)a.searchParams.append("token",m);return`${a}#${o}`}function c(t){if(s.current?.contentWindow===t.source)switch(t.data.action){case"document-ready":e.onDocumentReady?.();break;case"document-completed":e.onDocumentCompleted?.(t.data.data);break;case"document-error":e.onDocumentError?.(t.data.data);break;case"document-rejected":e.onDocumentRejected?.(t.data.data);break;case"all-documents-completed":e.onAllDocumentsCompleted?.(t.data.data);break}}return n.useEffect(()=>{window.addEventListener("message",c)},[]),n.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),r.jsx("iframe",{ref:s,className:e.className,src:d()})}exports.EmbedDirectTemplate=i;exports.EmbedSignDocument=u;exports.unstable_EmbedCreateDocument=l;exports.unstable_EmbedCreateTemplate=f;exports.unstable_EmbedMultiSignDocument=g;exports.unstable_EmbedUpdateDocument=b;exports.unstable_EmbedUpdateTemplate=k;
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { jsx as m } from "react/jsx-runtime";
2
- import { useRef as o, useEffect as s } from "react";
3
- function g(e) {
4
- const d = o(null);
5
- function i() {
6
- const t = e.host || "https://app.documenso.com", n = btoa(
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { useRef as m, useEffect as s } from "react";
3
+ function f(e) {
4
+ const n = m(null);
5
+ function c() {
6
+ const a = e.host || "https://app.documenso.com", o = btoa(
7
7
  encodeURIComponent(
8
8
  JSON.stringify({
9
9
  name: e.name,
@@ -16,40 +16,39 @@ function g(e) {
16
16
  ...e.additionalProps
17
17
  })
18
18
  )
19
- ), a = new URL(`/embed/direct/${e.token}`, t);
20
- return e.externalId && a.searchParams.set("externalId", e.externalId), `${a}#${n}`;
19
+ ), t = new URL(`/embed/direct/${e.token}`, a);
20
+ return e.externalId && t.searchParams.set("externalId", e.externalId), `${t}#${o}`;
21
21
  }
22
- function c(t) {
23
- var n, a, r, l, u, f;
24
- if (((n = d.current) == null ? void 0 : n.contentWindow) === t.source)
25
- switch (t.data.action) {
22
+ function d(a) {
23
+ if (n.current?.contentWindow === a.source)
24
+ switch (a.data.action) {
26
25
  case "document-ready":
27
- (a = e.onDocumentReady) == null || a.call(e);
26
+ e.onDocumentReady?.();
28
27
  break;
29
28
  case "document-completed":
30
- (r = e.onDocumentCompleted) == null || r.call(e, t.data.data);
29
+ e.onDocumentCompleted?.(a.data.data);
31
30
  break;
32
31
  case "document-error":
33
- (l = e.onDocumentError) == null || l.call(e, t.data.data);
32
+ e.onDocumentError?.(a.data.data);
34
33
  break;
35
34
  case "field-signed":
36
- (u = e.onFieldSigned) == null || u.call(e);
35
+ e.onFieldSigned?.();
37
36
  break;
38
37
  case "field-unsigned":
39
- (f = e.onFieldUnsigned) == null || f.call(e);
38
+ e.onFieldUnsigned?.();
40
39
  break;
41
40
  }
42
41
  }
43
42
  return s(() => {
44
- window.addEventListener("message", c);
43
+ window.addEventListener("message", d);
45
44
  }, []), s(() => () => {
46
- window.removeEventListener("message", c);
47
- }, []), /* @__PURE__ */ m("iframe", { ref: d, className: e.className, src: i() });
45
+ window.removeEventListener("message", d);
46
+ }, []), /* @__PURE__ */ r("iframe", { ref: n, className: e.className, src: c() });
48
47
  }
49
- function k(e) {
50
- const d = o(null);
51
- function i() {
52
- const t = e.host || "https://app.documenso.com", n = btoa(
48
+ function b(e) {
49
+ const n = m(null);
50
+ function c() {
51
+ const a = e.host || "https://app.documenso.com", o = btoa(
53
52
  encodeURIComponent(
54
53
  JSON.stringify({
55
54
  name: e.name,
@@ -62,36 +61,35 @@ function k(e) {
62
61
  })
63
62
  )
64
63
  );
65
- return `${new URL(`/embed/sign/${e.token}`, t)}#${n}`;
64
+ return `${new URL(`/embed/sign/${e.token}`, a)}#${o}`;
66
65
  }
67
- function c(t) {
68
- var n, a, r, l, u;
69
- if (((n = d.current) == null ? void 0 : n.contentWindow) === t.source)
70
- switch (t.data.action) {
66
+ function d(a) {
67
+ if (n.current?.contentWindow === a.source)
68
+ switch (a.data.action) {
71
69
  case "document-ready":
72
- (a = e.onDocumentReady) == null || a.call(e);
70
+ e.onDocumentReady?.();
73
71
  break;
74
72
  case "document-completed":
75
- (r = e.onDocumentCompleted) == null || r.call(e, t.data.data);
73
+ e.onDocumentCompleted?.(a.data.data);
76
74
  break;
77
75
  case "document-error":
78
- (l = e.onDocumentError) == null || l.call(e, t.data.data);
76
+ e.onDocumentError?.(a.data.data);
79
77
  break;
80
78
  case "document-rejected":
81
- (u = e.onDocumentRejected) == null || u.call(e, t.data.data);
79
+ e.onDocumentRejected?.(a.data.data);
82
80
  break;
83
81
  }
84
82
  }
85
83
  return s(() => {
86
- window.addEventListener("message", c);
84
+ window.addEventListener("message", d);
87
85
  }, []), s(() => () => {
88
- window.removeEventListener("message", c);
89
- }, []), /* @__PURE__ */ m("iframe", { ref: d, className: e.className, src: i() });
86
+ window.removeEventListener("message", d);
87
+ }, []), /* @__PURE__ */ r("iframe", { ref: n, className: e.className, src: c() });
90
88
  }
91
- function h(e) {
92
- const d = o(null);
93
- function i() {
94
- const t = e.host || "https://app.documenso.com", n = btoa(
89
+ function k(e) {
90
+ const n = m(null);
91
+ function c() {
92
+ const a = e.host || "https://app.documenso.com", o = btoa(
95
93
  encodeURIComponent(
96
94
  JSON.stringify({
97
95
  externalId: e.externalId,
@@ -102,31 +100,30 @@ function h(e) {
102
100
  ...e.additionalProps
103
101
  })
104
102
  )
105
- ), a = new URL("/embed/v1/authoring/document/create", t);
106
- return a.searchParams.set("token", e.presignToken), a.hash = n, a.toString();
103
+ ), t = new URL("/embed/v1/authoring/document/create", a);
104
+ return t.searchParams.set("token", e.presignToken), t.hash = o, t.toString();
107
105
  }
108
- function c(t) {
109
- var n, a;
110
- if (((n = d.current) == null ? void 0 : n.contentWindow) === t.source)
111
- switch (t.data.type) {
106
+ function d(a) {
107
+ if (n.current?.contentWindow === a.source)
108
+ switch (a.data.type) {
112
109
  case "document-created":
113
- (a = e.onDocumentCreated) == null || a.call(e, {
114
- documentId: t.data.documentId,
115
- externalId: t.data.externalId
110
+ e.onDocumentCreated?.({
111
+ documentId: a.data.documentId,
112
+ externalId: a.data.externalId
116
113
  });
117
114
  break;
118
115
  }
119
116
  }
120
117
  return s(() => {
121
- window.addEventListener("message", c);
118
+ window.addEventListener("message", d);
122
119
  }, []), s(() => () => {
123
- window.removeEventListener("message", c);
124
- }, []), /* @__PURE__ */ m("iframe", { ref: d, className: e.className, src: i() });
120
+ window.removeEventListener("message", d);
121
+ }, []), /* @__PURE__ */ r("iframe", { ref: n, className: e.className, src: c() });
125
122
  }
126
- function I(e) {
127
- const d = o(null);
128
- function i() {
129
- const t = e.host || "https://app.documenso.com", n = btoa(
123
+ function w(e) {
124
+ const n = m(null);
125
+ function c() {
126
+ const a = e.host || "https://app.documenso.com", o = btoa(
130
127
  encodeURIComponent(
131
128
  JSON.stringify({
132
129
  externalId: e.externalId,
@@ -137,31 +134,30 @@ function I(e) {
137
134
  ...e.additionalProps
138
135
  })
139
136
  )
140
- ), a = new URL("/embed/v1/authoring/template/create", t);
141
- return a.searchParams.set("token", e.presignToken), a.hash = n, a.toString();
137
+ ), t = new URL("/embed/v1/authoring/template/create", a);
138
+ return t.searchParams.set("token", e.presignToken), t.hash = o, t.toString();
142
139
  }
143
- function c(t) {
144
- var n, a;
145
- if (((n = d.current) == null ? void 0 : n.contentWindow) === t.source)
146
- switch (t.data.type) {
140
+ function d(a) {
141
+ if (n.current?.contentWindow === a.source)
142
+ switch (a.data.type) {
147
143
  case "template-created":
148
- (a = e.onTemplateCreated) == null || a.call(e, {
149
- templateId: t.data.templateId,
150
- externalId: t.data.externalId
144
+ e.onTemplateCreated?.({
145
+ templateId: a.data.templateId,
146
+ externalId: a.data.externalId
151
147
  });
152
148
  break;
153
149
  }
154
150
  }
155
151
  return s(() => {
156
- window.addEventListener("message", c);
152
+ window.addEventListener("message", d);
157
153
  }, []), s(() => () => {
158
- window.removeEventListener("message", c);
159
- }, []), /* @__PURE__ */ m("iframe", { ref: d, className: e.className, src: i() });
154
+ window.removeEventListener("message", d);
155
+ }, []), /* @__PURE__ */ r("iframe", { ref: n, className: e.className, src: c() });
160
156
  }
161
- function D(e) {
162
- const d = o(null);
163
- function i() {
164
- const t = e.host || "https://app.documenso.com", n = btoa(
157
+ function g(e) {
158
+ const n = m(null);
159
+ function c() {
160
+ const a = e.host || "https://app.documenso.com", o = btoa(
165
161
  encodeURIComponent(
166
162
  JSON.stringify({
167
163
  token: e.presignToken,
@@ -173,34 +169,33 @@ function D(e) {
173
169
  ...e.additionalProps
174
170
  })
175
171
  )
176
- ), a = new URL(
172
+ ), t = new URL(
177
173
  `/embed/v1/authoring/document/edit/${e.documentId}`,
178
- t
174
+ a
179
175
  );
180
- return a.searchParams.set("token", e.presignToken), a.hash = n, a.toString();
176
+ return t.searchParams.set("token", e.presignToken), t.hash = o, t.toString();
181
177
  }
182
- function c(t) {
183
- var n, a;
184
- if (((n = d.current) == null ? void 0 : n.contentWindow) === t.source)
185
- switch (t.data.type) {
178
+ function d(a) {
179
+ if (n.current?.contentWindow === a.source)
180
+ switch (a.data.type) {
186
181
  case "document-updated":
187
- (a = e.onDocumentUpdated) == null || a.call(e, {
188
- documentId: t.data.documentId,
189
- externalId: t.data.externalId
182
+ e.onDocumentUpdated?.({
183
+ documentId: a.data.documentId,
184
+ externalId: a.data.externalId
190
185
  });
191
186
  break;
192
187
  }
193
188
  }
194
189
  return s(() => {
195
- window.addEventListener("message", c);
190
+ window.addEventListener("message", d);
196
191
  }, []), s(() => () => {
197
- window.removeEventListener("message", c);
198
- }, []), /* @__PURE__ */ m("iframe", { ref: d, className: e.className, src: i() });
192
+ window.removeEventListener("message", d);
193
+ }, []), /* @__PURE__ */ r("iframe", { ref: n, className: e.className, src: c() });
199
194
  }
200
- function E(e) {
201
- const d = o(null);
202
- function i() {
203
- const t = e.host || "https://app.documenso.com", n = btoa(
195
+ function h(e) {
196
+ const n = m(null);
197
+ function c() {
198
+ const a = e.host || "https://app.documenso.com", o = btoa(
204
199
  encodeURIComponent(
205
200
  JSON.stringify({
206
201
  externalId: e.externalId,
@@ -211,35 +206,81 @@ function E(e) {
211
206
  ...e.additionalProps
212
207
  })
213
208
  )
214
- ), a = new URL(
209
+ ), t = new URL(
215
210
  `/embed/v1/authoring/template/edit/${e.templateId}`,
216
- t
211
+ a
217
212
  );
218
- return a.searchParams.set("token", e.presignToken), a.hash = n, a.toString();
213
+ return t.searchParams.set("token", e.presignToken), t.hash = o, t.toString();
219
214
  }
220
- function c(t) {
221
- var n, a;
222
- if (((n = d.current) == null ? void 0 : n.contentWindow) === t.source)
223
- switch (t.data.type) {
215
+ function d(a) {
216
+ if (n.current?.contentWindow === a.source)
217
+ switch (a.data.type) {
224
218
  case "template-updated":
225
- (a = e.onTemplateUpdated) == null || a.call(e, {
226
- templateId: t.data.templateId,
227
- externalId: t.data.externalId
219
+ e.onTemplateUpdated?.({
220
+ templateId: a.data.templateId,
221
+ externalId: a.data.externalId
228
222
  });
229
223
  break;
230
224
  }
231
225
  }
232
226
  return s(() => {
233
- window.addEventListener("message", c);
227
+ window.addEventListener("message", d);
228
+ }, []), s(() => () => {
229
+ window.removeEventListener("message", d);
230
+ }, []), /* @__PURE__ */ r("iframe", { ref: n, className: e.className, src: c() });
231
+ }
232
+ function D(e) {
233
+ const n = m(null);
234
+ function c() {
235
+ const a = e.host || "https://app.documenso.com", o = btoa(
236
+ encodeURIComponent(
237
+ JSON.stringify({
238
+ name: e.name,
239
+ lockName: e.lockName,
240
+ css: e.css,
241
+ cssVars: e.cssVars,
242
+ darkModeDisabled: e.darkModeDisabled,
243
+ allowDocumentRejection: e.allowDocumentRejection,
244
+ ...e.additionalProps
245
+ })
246
+ )
247
+ ), t = new URL("/embed/v1/multisign", a);
248
+ for (const i of e.tokens)
249
+ t.searchParams.append("token", i);
250
+ return `${t}#${o}`;
251
+ }
252
+ function d(a) {
253
+ if (n.current?.contentWindow === a.source)
254
+ switch (a.data.action) {
255
+ case "document-ready":
256
+ e.onDocumentReady?.();
257
+ break;
258
+ case "document-completed":
259
+ e.onDocumentCompleted?.(a.data.data);
260
+ break;
261
+ case "document-error":
262
+ e.onDocumentError?.(a.data.data);
263
+ break;
264
+ case "document-rejected":
265
+ e.onDocumentRejected?.(a.data.data);
266
+ break;
267
+ case "all-documents-completed":
268
+ e.onAllDocumentsCompleted?.(a.data.data);
269
+ break;
270
+ }
271
+ }
272
+ return s(() => {
273
+ window.addEventListener("message", d);
234
274
  }, []), s(() => () => {
235
- window.removeEventListener("message", c);
236
- }, []), /* @__PURE__ */ m("iframe", { ref: d, className: e.className, src: i() });
275
+ window.removeEventListener("message", d);
276
+ }, []), /* @__PURE__ */ r("iframe", { ref: n, className: e.className, src: c() });
237
277
  }
238
278
  export {
239
- g as EmbedDirectTemplate,
240
- k as EmbedSignDocument,
241
- h as unstable_EmbedCreateDocument,
242
- I as unstable_EmbedCreateTemplate,
243
- D as unstable_EmbedUpdateDocument,
244
- E as unstable_EmbedUpdateTemplate
279
+ f as EmbedDirectTemplate,
280
+ b as EmbedSignDocument,
281
+ k as unstable_EmbedCreateDocument,
282
+ w as unstable_EmbedCreateTemplate,
283
+ D as unstable_EmbedMultiSignDocument,
284
+ g as unstable_EmbedUpdateDocument,
285
+ h as unstable_EmbedUpdateTemplate
245
286
  };
@@ -0,0 +1,38 @@
1
+ import { CssVars } from './css-vars';
2
+ import * as React from "react";
3
+ export type EmbedMultiSignDocumentProps = {
4
+ className?: string;
5
+ host?: string;
6
+ tokens: string[];
7
+ css?: string | undefined;
8
+ cssVars?: (CssVars & Record<string, string>) | undefined;
9
+ darkModeDisabled?: boolean | undefined;
10
+ name?: string | undefined;
11
+ lockName?: boolean | undefined;
12
+ allowDocumentRejection?: boolean | undefined;
13
+ additionalProps?: Record<string, string | number | boolean> | undefined;
14
+ onDocumentReady?: () => void;
15
+ onDocumentCompleted?: (data: {
16
+ token: string;
17
+ documentId: number;
18
+ recipientId: number;
19
+ }) => void;
20
+ onDocumentError?: (error: string) => void;
21
+ onDocumentRejected?: (data: {
22
+ token: string;
23
+ documentId: number;
24
+ recipientId: number;
25
+ reason: string;
26
+ }) => void;
27
+ onAllDocumentsCompleted?: (data: {
28
+ documents: Array<{
29
+ token: string;
30
+ documentId: number;
31
+ recipientId: number;
32
+ action: "document-completed" | "document-rejected";
33
+ reason?: string;
34
+ }>;
35
+ }) => void;
36
+ };
37
+ declare function EmbedMultiSignDocument(props: EmbedMultiSignDocumentProps): React.JSX.Element;
38
+ export default EmbedMultiSignDocument;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@documenso/embed-react",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"
@@ -32,14 +32,14 @@
32
32
  },
33
33
  "dependencies": {},
34
34
  "peerDependencies": {
35
- "react": "^18.0.0",
36
- "react-dom": "^18.0.0"
35
+ "react": "^18.0.0 || ^19.0.0",
36
+ "react-dom": "^18.0.0 || ^19.0.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@documenso/embed": "*",
40
- "@types/react": "^18.0.0",
41
- "@vitejs/plugin-react": "^4.3.1",
42
- "vite": "^5.4.2",
40
+ "@types/react": "^18.0.0 || ^19.0.0",
41
+ "@vitejs/plugin-react": "^5.0.0",
42
+ "vite": "^7.0.0",
43
43
  "vite-plugin-dts": "^4.1.0"
44
44
  }
45
45
  }