@documenso/embed-react 0.2.1 → 0.2.2

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.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/update/${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/update/${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 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;
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { useRef as o, useEffect as s } from "react";
3
3
  function g(e) {
4
4
  const d = o(null);
5
5
  function i() {
6
- const a = e.host || "https://app.documenso.com", n = btoa(
6
+ const t = e.host || "https://app.documenso.com", n = btoa(
7
7
  encodeURIComponent(
8
8
  JSON.stringify({
9
9
  name: e.name,
@@ -16,21 +16,21 @@ function g(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
+ ), a = new URL(`/embed/direct/${e.token}`, t);
20
+ return e.externalId && a.searchParams.set("externalId", e.externalId), `${a}#${n}`;
21
21
  }
22
- function c(a) {
23
- var n, t, r, l, u, f;
24
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
25
- switch (a.data.action) {
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) {
26
26
  case "document-ready":
27
- (t = e.onDocumentReady) == null || t.call(e);
27
+ (a = e.onDocumentReady) == null || a.call(e);
28
28
  break;
29
29
  case "document-completed":
30
- (r = e.onDocumentCompleted) == null || r.call(e, a.data.data);
30
+ (r = e.onDocumentCompleted) == null || r.call(e, t.data.data);
31
31
  break;
32
32
  case "document-error":
33
- (l = e.onDocumentError) == null || l.call(e, a.data.data);
33
+ (l = e.onDocumentError) == null || l.call(e, t.data.data);
34
34
  break;
35
35
  case "field-signed":
36
36
  (u = e.onFieldSigned) == null || u.call(e);
@@ -49,7 +49,7 @@ function g(e) {
49
49
  function k(e) {
50
50
  const d = o(null);
51
51
  function i() {
52
- const a = e.host || "https://app.documenso.com", n = btoa(
52
+ const t = e.host || "https://app.documenso.com", n = btoa(
53
53
  encodeURIComponent(
54
54
  JSON.stringify({
55
55
  name: e.name,
@@ -62,23 +62,23 @@ function k(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}`, t)}#${n}`;
66
66
  }
67
- function c(a) {
68
- var n, t, r, l, u;
69
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
70
- switch (a.data.action) {
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) {
71
71
  case "document-ready":
72
- (t = e.onDocumentReady) == null || t.call(e);
72
+ (a = e.onDocumentReady) == null || a.call(e);
73
73
  break;
74
74
  case "document-completed":
75
- (r = e.onDocumentCompleted) == null || r.call(e, a.data.data);
75
+ (r = e.onDocumentCompleted) == null || r.call(e, t.data.data);
76
76
  break;
77
77
  case "document-error":
78
- (l = e.onDocumentError) == null || l.call(e, a.data.data);
78
+ (l = e.onDocumentError) == null || l.call(e, t.data.data);
79
79
  break;
80
80
  case "document-rejected":
81
- (u = e.onDocumentRejected) == null || u.call(e, a.data.data);
81
+ (u = e.onDocumentRejected) == null || u.call(e, t.data.data);
82
82
  break;
83
83
  }
84
84
  }
@@ -91,7 +91,7 @@ function k(e) {
91
91
  function h(e) {
92
92
  const d = o(null);
93
93
  function i() {
94
- const a = e.host || "https://app.documenso.com", n = btoa(
94
+ const t = e.host || "https://app.documenso.com", n = btoa(
95
95
  encodeURIComponent(
96
96
  JSON.stringify({
97
97
  externalId: e.externalId,
@@ -102,17 +102,17 @@ function h(e) {
102
102
  ...e.additionalProps
103
103
  })
104
104
  )
105
- ), t = new URL("/embed/v1/authoring/document/create", a);
106
- return t.searchParams.set("token", e.presignToken), t.hash = n, t.toString();
105
+ ), a = new URL("/embed/v1/authoring/document/create", t);
106
+ return a.searchParams.set("token", e.presignToken), a.hash = n, a.toString();
107
107
  }
108
- function c(a) {
109
- var n, t;
110
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
111
- switch (a.data.type) {
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) {
112
112
  case "document-created":
113
- (t = e.onDocumentCreated) == null || t.call(e, {
114
- documentId: a.data.documentId,
115
- externalId: a.data.externalId
113
+ (a = e.onDocumentCreated) == null || a.call(e, {
114
+ documentId: t.data.documentId,
115
+ externalId: t.data.externalId
116
116
  });
117
117
  break;
118
118
  }
@@ -126,7 +126,7 @@ function h(e) {
126
126
  function I(e) {
127
127
  const d = o(null);
128
128
  function i() {
129
- const a = e.host || "https://app.documenso.com", n = btoa(
129
+ const t = e.host || "https://app.documenso.com", n = btoa(
130
130
  encodeURIComponent(
131
131
  JSON.stringify({
132
132
  externalId: e.externalId,
@@ -137,17 +137,17 @@ function I(e) {
137
137
  ...e.additionalProps
138
138
  })
139
139
  )
140
- ), t = new URL("/embed/v1/authoring/template/create", a);
141
- return t.searchParams.set("token", e.presignToken), t.hash = n, t.toString();
140
+ ), a = new URL("/embed/v1/authoring/template/create", t);
141
+ return a.searchParams.set("token", e.presignToken), a.hash = n, a.toString();
142
142
  }
143
- function c(a) {
144
- var n, t;
145
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
146
- switch (a.data.type) {
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) {
147
147
  case "template-created":
148
- (t = e.onTemplateCreated) == null || t.call(e, {
149
- templateId: a.data.templateId,
150
- externalId: a.data.externalId
148
+ (a = e.onTemplateCreated) == null || a.call(e, {
149
+ templateId: t.data.templateId,
150
+ externalId: t.data.externalId
151
151
  });
152
152
  break;
153
153
  }
@@ -161,7 +161,7 @@ function I(e) {
161
161
  function D(e) {
162
162
  const d = o(null);
163
163
  function i() {
164
- const a = e.host || "https://app.documenso.com", n = btoa(
164
+ const t = e.host || "https://app.documenso.com", n = btoa(
165
165
  encodeURIComponent(
166
166
  JSON.stringify({
167
167
  token: e.presignToken,
@@ -173,20 +173,20 @@ function D(e) {
173
173
  ...e.additionalProps
174
174
  })
175
175
  )
176
- ), t = new URL(
177
- `/embed/v1/authoring/document/update/${e.documentId}`,
178
- a
176
+ ), a = new URL(
177
+ `/embed/v1/authoring/document/edit/${e.documentId}`,
178
+ t
179
179
  );
180
- return t.searchParams.set("token", e.presignToken), t.hash = n, t.toString();
180
+ return a.searchParams.set("token", e.presignToken), a.hash = n, a.toString();
181
181
  }
182
- function c(a) {
183
- var n, t;
184
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
185
- switch (a.data.type) {
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) {
186
186
  case "document-updated":
187
- (t = e.onDocumentUpdated) == null || t.call(e, {
188
- documentId: a.data.documentId,
189
- externalId: a.data.externalId
187
+ (a = e.onDocumentUpdated) == null || a.call(e, {
188
+ documentId: t.data.documentId,
189
+ externalId: t.data.externalId
190
190
  });
191
191
  break;
192
192
  }
@@ -200,7 +200,7 @@ function D(e) {
200
200
  function E(e) {
201
201
  const d = o(null);
202
202
  function i() {
203
- const a = e.host || "https://app.documenso.com", n = btoa(
203
+ const t = e.host || "https://app.documenso.com", n = btoa(
204
204
  encodeURIComponent(
205
205
  JSON.stringify({
206
206
  externalId: e.externalId,
@@ -211,20 +211,20 @@ function E(e) {
211
211
  ...e.additionalProps
212
212
  })
213
213
  )
214
- ), t = new URL(
215
- `/embed/v1/authoring/template/update/${e.templateId}`,
216
- a
214
+ ), a = new URL(
215
+ `/embed/v1/authoring/template/edit/${e.templateId}`,
216
+ t
217
217
  );
218
- return t.searchParams.set("token", e.presignToken), t.hash = n, t.toString();
218
+ return a.searchParams.set("token", e.presignToken), a.hash = n, a.toString();
219
219
  }
220
- function c(a) {
221
- var n, t;
222
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
223
- switch (a.data.type) {
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) {
224
224
  case "template-updated":
225
- (t = e.onTemplateUpdated) == null || t.call(e, {
226
- templateId: a.data.templateId,
227
- externalId: a.data.externalId
225
+ (a = e.onTemplateUpdated) == null || a.call(e, {
226
+ templateId: t.data.templateId,
227
+ externalId: t.data.externalId
228
228
  });
229
229
  break;
230
230
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@documenso/embed-react",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"