@documenso/embed-react 0.4.0 → 0.5.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/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),n=require("react");function b(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 k(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 m(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 i(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 u(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,onlyEditFields:e.onlyEditFields,...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 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,onlyEditFields:e.onlyEditFields,...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 E(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 f of e.tokens)a.searchParams.append("token",f);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.EmbedCreateDocumentV1=m;exports.EmbedCreateTemplateV1=i;exports.EmbedDirectTemplate=b;exports.EmbedSignDocument=k;exports.EmbedUpdateDocumentV1=u;exports.EmbedUpdateTemplateV1=l;exports.unstable_EmbedCreateDocument=m;exports.unstable_EmbedCreateTemplate=i;exports.unstable_EmbedMultiSignDocument=E;exports.unstable_EmbedUpdateDocument=u;exports.unstable_EmbedUpdateTemplate=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),n=require("react");function b(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 k(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 m(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){s.current?.contentWindow===t.source&&t.data.type==="document-created"&&e.onDocumentCreated?.({documentId:t.data.documentId,externalId:t.data.externalId})}return n.useEffect(()=>{window.addEventListener("message",c)},[]),n.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),r.jsx("iframe",{ref:s,className:e.className,src:d()})}function i(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){s.current?.contentWindow===t.source&&t.data.type==="template-created"&&e.onTemplateCreated?.({templateId:t.data.templateId,externalId:t.data.externalId})}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({token:e.presignToken,externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,onlyEditFields:e.onlyEditFields,...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){s.current?.contentWindow===t.source&&t.data.type==="document-updated"&&e.onDocumentUpdated?.({documentId:t.data.documentId,externalId:t.data.externalId})}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,onlyEditFields:e.onlyEditFields,...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){s.current?.contentWindow===t.source&&t.data.type==="template-updated"&&e.onTemplateUpdated?.({templateId:t.data.templateId,externalId:t.data.externalId})}return n.useEffect(()=>{window.addEventListener("message",c)},[]),n.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),r.jsx("iframe",{ref:s,className:e.className,src:d()})}function E(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 f of e.tokens)a.searchParams.append("token",f);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.EmbedCreateDocumentV1=m;exports.EmbedCreateTemplateV1=i;exports.EmbedDirectTemplate=b;exports.EmbedSignDocument=k;exports.EmbedUpdateDocumentV1=u;exports.EmbedUpdateTemplateV1=l;exports.unstable_EmbedCreateDocument=m;exports.unstable_EmbedCreateTemplate=i;exports.unstable_EmbedMultiSignDocument=E;exports.unstable_EmbedUpdateDocument=u;exports.unstable_EmbedUpdateTemplate=l;
package/dist/index.mjs CHANGED
@@ -104,15 +104,10 @@ function k(e) {
104
104
  return t.searchParams.set("token", e.presignToken), t.hash = o, t.toString();
105
105
  }
106
106
  function d(a) {
107
- if (n.current?.contentWindow === a.source)
108
- switch (a.data.type) {
109
- case "document-created":
110
- e.onDocumentCreated?.({
111
- documentId: a.data.documentId,
112
- externalId: a.data.externalId
113
- });
114
- break;
115
- }
107
+ n.current?.contentWindow === a.source && a.data.type === "document-created" && e.onDocumentCreated?.({
108
+ documentId: a.data.documentId,
109
+ externalId: a.data.externalId
110
+ });
116
111
  }
117
112
  return s(() => {
118
113
  window.addEventListener("message", d);
@@ -138,15 +133,10 @@ function w(e) {
138
133
  return t.searchParams.set("token", e.presignToken), t.hash = o, t.toString();
139
134
  }
140
135
  function d(a) {
141
- if (n.current?.contentWindow === a.source)
142
- switch (a.data.type) {
143
- case "template-created":
144
- e.onTemplateCreated?.({
145
- templateId: a.data.templateId,
146
- externalId: a.data.externalId
147
- });
148
- break;
149
- }
136
+ n.current?.contentWindow === a.source && a.data.type === "template-created" && e.onTemplateCreated?.({
137
+ templateId: a.data.templateId,
138
+ externalId: a.data.externalId
139
+ });
150
140
  }
151
141
  return s(() => {
152
142
  window.addEventListener("message", d);
@@ -177,15 +167,10 @@ function g(e) {
177
167
  return t.searchParams.set("token", e.presignToken), t.hash = o, t.toString();
178
168
  }
179
169
  function d(a) {
180
- if (n.current?.contentWindow === a.source)
181
- switch (a.data.type) {
182
- case "document-updated":
183
- e.onDocumentUpdated?.({
184
- documentId: a.data.documentId,
185
- externalId: a.data.externalId
186
- });
187
- break;
188
- }
170
+ n.current?.contentWindow === a.source && a.data.type === "document-updated" && e.onDocumentUpdated?.({
171
+ documentId: a.data.documentId,
172
+ externalId: a.data.externalId
173
+ });
189
174
  }
190
175
  return s(() => {
191
176
  window.addEventListener("message", d);
@@ -215,15 +200,10 @@ function h(e) {
215
200
  return t.searchParams.set("token", e.presignToken), t.hash = o, t.toString();
216
201
  }
217
202
  function d(a) {
218
- if (n.current?.contentWindow === a.source)
219
- switch (a.data.type) {
220
- case "template-updated":
221
- e.onTemplateUpdated?.({
222
- templateId: a.data.templateId,
223
- externalId: a.data.externalId
224
- });
225
- break;
226
- }
203
+ n.current?.contentWindow === a.source && a.data.type === "template-updated" && e.onTemplateUpdated?.({
204
+ templateId: a.data.templateId,
205
+ externalId: a.data.externalId
206
+ });
227
207
  }
228
208
  return s(() => {
229
209
  window.addEventListener("message", d);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@documenso/embed-react",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"
@@ -40,6 +40,6 @@
40
40
  "@types/react": "^18.0.0 || ^19.0.0",
41
41
  "@vitejs/plugin-react": "^5.0.0",
42
42
  "vite": "^7.0.0",
43
- "vite-plugin-dts": "^4.1.0"
43
+ "vite-plugin-dts": "^4.0.0"
44
44
  }
45
45
  }