@documenso/embed-react 0.3.0 → 0.4.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
@@ -1,5 +1,9 @@
1
1
  export { default as EmbedDirectTemplate } from './direct-template';
2
2
  export { default as EmbedSignDocument } from './sign-document';
3
+ export { default as EmbedCreateDocumentV1 } from './create-document';
4
+ export { default as EmbedCreateTemplateV1 } from './create-template';
5
+ export { default as EmbedUpdateDocumentV1 } from './update-document';
6
+ export { default as EmbedUpdateTemplateV1 } from './update-template';
3
7
  export { default as unstable_EmbedCreateDocument } from './create-document';
4
8
  export { default as unstable_EmbedCreateTemplate } from './create-template';
5
9
  export { default as unstable_EmbedUpdateDocument } from './update-document';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  export { default as EmbedDirectTemplate } from './direct-template';
2
2
  export { default as EmbedSignDocument } from './sign-document';
3
+ export { default as EmbedCreateDocumentV1 } from './create-document';
4
+ export { default as EmbedCreateTemplateV1 } from './create-template';
5
+ export { default as EmbedUpdateDocumentV1 } from './update-document';
6
+ export { default as EmbedUpdateTemplateV1 } from './update-template';
3
7
  export { default as unstable_EmbedCreateDocument } from './create-document';
4
8
  export { default as unstable_EmbedCreateTemplate } from './create-template';
5
9
  export { default as unstable_EmbedUpdateDocument } from './update-document';
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 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;
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;
package/dist/index.mjs CHANGED
@@ -166,6 +166,7 @@ function g(e) {
166
166
  css: e.css,
167
167
  cssVars: e.cssVars,
168
168
  darkModeDisabled: e.darkModeDisabled,
169
+ onlyEditFields: e.onlyEditFields,
169
170
  ...e.additionalProps
170
171
  })
171
172
  )
@@ -203,6 +204,7 @@ function h(e) {
203
204
  css: e.css,
204
205
  cssVars: e.cssVars,
205
206
  darkModeDisabled: e.darkModeDisabled,
207
+ onlyEditFields: e.onlyEditFields,
206
208
  ...e.additionalProps
207
209
  })
208
210
  )
@@ -276,8 +278,12 @@ function D(e) {
276
278
  }, []), /* @__PURE__ */ r("iframe", { ref: n, className: e.className, src: c() });
277
279
  }
278
280
  export {
281
+ k as EmbedCreateDocumentV1,
282
+ w as EmbedCreateTemplateV1,
279
283
  f as EmbedDirectTemplate,
280
284
  b as EmbedSignDocument,
285
+ g as EmbedUpdateDocumentV1,
286
+ h as EmbedUpdateTemplateV1,
281
287
  k as unstable_EmbedCreateDocument,
282
288
  w as unstable_EmbedCreateTemplate,
283
289
  D as unstable_EmbedMultiSignDocument,
@@ -17,6 +17,7 @@ export type EmbedUpdateDocumentProps = {
17
17
  allowConfigureRedirectUrl?: boolean;
18
18
  allowConfigureCommunication?: boolean;
19
19
  };
20
+ onlyEditFields?: boolean | undefined;
20
21
  additionalProps?: Record<string, string | number | boolean> | undefined;
21
22
  onDocumentUpdated?: (data: {
22
23
  externalId: string;
@@ -17,6 +17,7 @@ export type EmbedUpdateTemplateProps = {
17
17
  allowConfigureRedirectUrl?: boolean;
18
18
  allowConfigureCommunication?: boolean;
19
19
  };
20
+ onlyEditFields?: boolean | undefined;
20
21
  additionalProps?: Record<string, string | number | boolean> | undefined;
21
22
  onTemplateUpdated?: (data: {
22
23
  externalId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@documenso/embed-react",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"