@documenso/embed-preact 0.5.0 → 0.6.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.
@@ -0,0 +1,20 @@
1
+ import { h } from 'preact';
2
+ import { CssVars } from './css-vars';
3
+ import { DeepPartial, EnvelopeEditorSettings } from './features-type';
4
+ export type EmbedCreateEnvelopeProps = {
5
+ className?: string;
6
+ host?: string;
7
+ presignToken: string;
8
+ externalId?: string;
9
+ type: "DOCUMENT" | "TEMPLATE";
10
+ css?: string | undefined;
11
+ cssVars?: (CssVars & Record<string, string>) | undefined;
12
+ darkModeDisabled?: boolean | undefined;
13
+ features?: DeepPartial<EnvelopeEditorSettings> & Record<string, any>;
14
+ onEnvelopeCreated?: (data: {
15
+ externalId: string | null;
16
+ envelopeId: number;
17
+ }) => void;
18
+ };
19
+ declare function EmbedCreateEnvelope(props: EmbedCreateEnvelopeProps): h.JSX.Element;
20
+ export default EmbedCreateEnvelope;
@@ -0,0 +1,47 @@
1
+ export type DeepPartial<T> = T extends object ? {
2
+ [K in keyof T]?: DeepPartial<T[K]>;
3
+ } : T;
4
+ /**
5
+ * Envelope editor settings (features) for create/edit envelope embeds.
6
+ * Matches ZEnvelopeEditorSettingsSchema from the app.
7
+ */
8
+ export type EnvelopeEditorSettings = {
9
+ general: {
10
+ allowConfigureEnvelopeTitle: boolean;
11
+ allowUploadAndRecipientStep: boolean;
12
+ allowAddFieldsStep: boolean;
13
+ allowPreviewStep: boolean;
14
+ minimizeLeftSidebar: boolean;
15
+ };
16
+ /** If null, envelope settings will not be available to be seen/updated. */
17
+ settings: {
18
+ allowConfigureSignatureTypes: boolean;
19
+ allowConfigureLanguage: boolean;
20
+ allowConfigureDateFormat: boolean;
21
+ allowConfigureTimezone: boolean;
22
+ allowConfigureRedirectUrl: boolean;
23
+ allowConfigureDistribution: boolean;
24
+ allowConfigureExpirationPeriod: boolean;
25
+ allowConfigureEmailSender: boolean;
26
+ allowConfigureEmailReplyTo: boolean;
27
+ } | null;
28
+ actions: {
29
+ allowAttachments: boolean;
30
+ };
31
+ /** If null, no adjustments to envelope items will be allowed. */
32
+ envelopeItems: {
33
+ allowConfigureTitle: boolean;
34
+ allowConfigureOrder: boolean;
35
+ allowUpload: boolean;
36
+ allowDelete: boolean;
37
+ } | null;
38
+ /** If null, recipients will not be configurable at all. */
39
+ recipients: {
40
+ allowConfigureSigningOrder: boolean;
41
+ allowConfigureDictateNextSigner: boolean;
42
+ allowApproverRole: boolean;
43
+ allowViewerRole: boolean;
44
+ allowCCerRole: boolean;
45
+ allowAssistantRole: boolean;
46
+ } | null;
47
+ };
package/dist/index.d.mts CHANGED
@@ -4,8 +4,13 @@ export { default as EmbedCreateDocumentV1 } from './create-document';
4
4
  export { default as EmbedCreateTemplateV1 } from './create-template';
5
5
  export { default as EmbedUpdateDocumentV1 } from './update-document';
6
6
  export { default as EmbedUpdateTemplateV1 } from './update-template';
7
+ export { default as EmbedCreateEnvelopeV2 } from './create-envelope';
8
+ export { default as EmbedUpdateEnvelopeV2 } from './update-envelope';
9
+ export type { EnvelopeEditorSettings } from './features-type';
7
10
  export { default as unstable_EmbedCreateDocument } from './create-document';
8
11
  export { default as unstable_EmbedCreateTemplate } from './create-template';
9
12
  export { default as unstable_EmbedUpdateDocument } from './update-document';
10
13
  export { default as unstable_EmbedUpdateTemplate } from './update-template';
14
+ export { default as unstable_EmbedCreateEnvelope } from './create-envelope';
15
+ export { default as unstable_EmbedUpdateEnvelope } from './update-envelope';
11
16
  export { default as unstable_EmbedMultiSignDocument } from './multisign-document';
package/dist/index.d.ts CHANGED
@@ -4,8 +4,13 @@ export { default as EmbedCreateDocumentV1 } from './create-document';
4
4
  export { default as EmbedCreateTemplateV1 } from './create-template';
5
5
  export { default as EmbedUpdateDocumentV1 } from './update-document';
6
6
  export { default as EmbedUpdateTemplateV1 } from './update-template';
7
+ export { default as EmbedCreateEnvelopeV2 } from './create-envelope';
8
+ export { default as EmbedUpdateEnvelopeV2 } from './update-envelope';
9
+ export type { EnvelopeEditorSettings } from './features-type';
7
10
  export { default as unstable_EmbedCreateDocument } from './create-document';
8
11
  export { default as unstable_EmbedCreateTemplate } from './create-template';
9
12
  export { default as unstable_EmbedUpdateDocument } from './update-document';
10
13
  export { default as unstable_EmbedUpdateTemplate } from './update-template';
14
+ export { default as unstable_EmbedCreateEnvelope } from './create-envelope';
15
+ export { default as unstable_EmbedUpdateEnvelope } from './update-envelope';
11
16
  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 l=require("preact"),s=require("preact/hooks");var g=0;function i(e,a,d,c,t,o){a||(a={});var n,r,m=a;if("ref"in m)for(r in m={},a)r=="ref"?n=a[r]:m[r]=a[r];var u={type:e,props:m,key:d,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--g,__i:-1,__u:0,__source:t,__self:o};return l.options.vnode&&l.options.vnode(u),u}function w(e){const a=s.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}))),n=new URL(`/embed/direct/${e.token}`,t);return e.externalId&&n.searchParams.set("externalId",e.externalId),`${n}#${o}`}function c(t){if(a.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 s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function h(e){const a=s.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(a.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 s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function f(e){const a=s.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}))),n=new URL("/embed/v1/authoring/document/create",t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function c(t){a.current?.contentWindow===t.source&&t.data.type==="document-created"&&e.onDocumentCreated?.({documentId:t.data.documentId,externalId:t.data.externalId})}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function b(e){const a=s.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}))),n=new URL("/embed/v1/authoring/template/create",t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function c(t){a.current?.contentWindow===t.source&&t.data.type==="template-created"&&e.onTemplateCreated?.({templateId:t.data.templateId,externalId:t.data.externalId})}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function k(e){const a=s.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}))),n=new URL(`/embed/v1/authoring/document/edit/${e.documentId}`,t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function c(t){a.current?.contentWindow===t.source&&t.data.type==="document-updated"&&e.onDocumentUpdated?.({documentId:t.data.documentId,externalId:t.data.externalId})}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function E(e){const a=s.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}))),n=new URL(`/embed/v1/authoring/template/edit/${e.templateId}`,t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function c(t){a.current?.contentWindow===t.source&&t.data.type==="template-updated"&&e.onTemplateUpdated?.({templateId:t.data.templateId,externalId:t.data.externalId})}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function D(e){const a=s.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}))),n=new URL("/embed/v1/multisign",t);for(const r of e.tokens)n.searchParams.append("token",r);return`${n}#${o}`}function c(t){if(a.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 s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}exports.EmbedCreateDocumentV1=f;exports.EmbedCreateTemplateV1=b;exports.EmbedDirectTemplate=w;exports.EmbedSignDocument=h;exports.EmbedUpdateDocumentV1=k;exports.EmbedUpdateTemplateV1=E;exports.unstable_EmbedCreateDocument=f;exports.unstable_EmbedCreateTemplate=b;exports.unstable_EmbedMultiSignDocument=D;exports.unstable_EmbedUpdateDocument=k;exports.unstable_EmbedUpdateTemplate=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("preact"),d=require("preact/hooks");var h=0;function r(e,a,c,s,t,o){a||(a={});var n,i,m=a;if("ref"in m)for(i in m={},a)i=="ref"?n=a[i]:m[i]=a[i];var l={type:e,props:m,key:c,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--h,__i:-1,__u:0,__source:t,__self:o};return u.options.vnode&&u.options.vnode(l),l}function I(e){const a=d.useRef(null);function c(){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}))),n=new URL(`/embed/direct/${e.token}`,t);return e.externalId&&n.searchParams.set("externalId",e.externalId),`${n}#${o}`}function s(t){if(a.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 d.useEffect(()=>{window.addEventListener("message",s)},[]),d.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),r("iframe",{ref:a,className:e.className,src:c()})}function D(e){const a=d.useRef(null);function c(){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,allowDocumentRejection:e.allowDocumentRejection,...e.additionalProps})));return`${new URL(`/embed/sign/${e.token}`,t)}#${o}`}function s(t){if(a.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 d.useEffect(()=>{window.addEventListener("message",s)},[]),d.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),r("iframe",{ref:a,className:e.className,src:c()})}function f(e){const a=d.useRef(null);function c(){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}))),n=new URL("/embed/v1/authoring/document/create",t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function s(t){a.current?.contentWindow===t.source&&t.data.type==="document-created"&&e.onDocumentCreated?.({documentId:t.data.documentId,externalId:t.data.externalId})}return d.useEffect(()=>{window.addEventListener("message",s)},[]),d.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),r("iframe",{ref:a,className:e.className,src:c()})}function b(e){const a=d.useRef(null);function c(){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}))),n=new URL("/embed/v1/authoring/template/create",t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function s(t){a.current?.contentWindow===t.source&&t.data.type==="template-created"&&e.onTemplateCreated?.({templateId:t.data.templateId,externalId:t.data.externalId})}return d.useEffect(()=>{window.addEventListener("message",s)},[]),d.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),r("iframe",{ref:a,className:e.className,src:c()})}function E(e){const a=d.useRef(null);function c(){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}))),n=new URL(`/embed/v1/authoring/document/edit/${e.documentId}`,t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function s(t){a.current?.contentWindow===t.source&&t.data.type==="document-updated"&&e.onDocumentUpdated?.({documentId:t.data.documentId,externalId:t.data.externalId})}return d.useEffect(()=>{window.addEventListener("message",s)},[]),d.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),r("iframe",{ref:a,className:e.className,src:c()})}function k(e){const a=d.useRef(null);function c(){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}))),n=new URL(`/embed/v1/authoring/template/edit/${e.templateId}`,t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function s(t){a.current?.contentWindow===t.source&&t.data.type==="template-updated"&&e.onTemplateUpdated?.({templateId:t.data.templateId,externalId:t.data.externalId})}return d.useEffect(()=>{window.addEventListener("message",s)},[]),d.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),r("iframe",{ref:a,className:e.className,src:c()})}function g(e){const a=d.useRef(null);function c(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,type:e.type,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled}))),n=new URL("/embed/v2/authoring/envelope/create",t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function s(t){a.current?.contentWindow===t.source&&t.data.type==="envelope-created"&&e.onEnvelopeCreated?.({envelopeId:t.data.envelopeId,externalId:t.data.externalId})}return d.useEffect(()=>{window.addEventListener("message",s)},[]),d.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),r("iframe",{ref:a,className:e.className,src:c()})}function w(e){const a=d.useRef(null);function c(){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}))),n=new URL(`/embed/v2/authoring/envelope/edit/${e.envelopeId}`,t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function s(t){a.current?.contentWindow===t.source&&t.data.type==="envelope-updated"&&e.onEnvelopeUpdated?.({envelopeId:t.data.envelopeId,externalId:t.data.externalId})}return d.useEffect(()=>{window.addEventListener("message",s)},[]),d.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),r("iframe",{ref:a,className:e.className,src:c()})}function _(e){const a=d.useRef(null);function c(){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}))),n=new URL("/embed/v1/multisign",t);for(const i of e.tokens)n.searchParams.append("token",i);return`${n}#${o}`}function s(t){if(a.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 d.useEffect(()=>{window.addEventListener("message",s)},[]),d.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),r("iframe",{ref:a,className:e.className,src:c()})}exports.EmbedCreateDocumentV1=f;exports.EmbedCreateEnvelopeV2=g;exports.EmbedCreateTemplateV1=b;exports.EmbedDirectTemplate=I;exports.EmbedSignDocument=D;exports.EmbedUpdateDocumentV1=E;exports.EmbedUpdateEnvelopeV2=w;exports.EmbedUpdateTemplateV1=k;exports.unstable_EmbedCreateDocument=f;exports.unstable_EmbedCreateEnvelope=g;exports.unstable_EmbedCreateTemplate=b;exports.unstable_EmbedMultiSignDocument=_;exports.unstable_EmbedUpdateDocument=E;exports.unstable_EmbedUpdateEnvelope=w;exports.unstable_EmbedUpdateTemplate=k;
package/dist/index.mjs CHANGED
@@ -1,16 +1,16 @@
1
1
  import { options as f } from "preact";
2
- import { useRef as i, useEffect as o } from "preact/hooks";
2
+ import { useRef as r, useEffect as o } from "preact/hooks";
3
3
  var b = 0;
4
- function m(e, t, s, d, a, c) {
4
+ function i(e, t, d, s, a, c) {
5
5
  t || (t = {});
6
- var n, r, l = t;
7
- if ("ref" in l) for (r in l = {}, t) r == "ref" ? n = t[r] : l[r] = t[r];
8
- var u = { type: e, props: l, key: s, ref: n, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --b, __i: -1, __u: 0, __source: a, __self: c };
6
+ var n, m, l = t;
7
+ if ("ref" in l) for (m in l = {}, t) m == "ref" ? n = t[m] : l[m] = t[m];
8
+ var u = { type: e, props: l, key: d, ref: n, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --b, __i: -1, __u: 0, __source: a, __self: c };
9
9
  return f.vnode && f.vnode(u), u;
10
10
  }
11
11
  function g(e) {
12
- const t = i(null);
13
- function s() {
12
+ const t = r(null);
13
+ function d() {
14
14
  const a = e.host || "https://app.documenso.com", c = btoa(
15
15
  encodeURIComponent(
16
16
  JSON.stringify({
@@ -27,7 +27,7 @@ function g(e) {
27
27
  ), n = new URL(`/embed/direct/${e.token}`, a);
28
28
  return e.externalId && n.searchParams.set("externalId", e.externalId), `${n}#${c}`;
29
29
  }
30
- function d(a) {
30
+ function s(a) {
31
31
  if (t.current?.contentWindow === a.source)
32
32
  switch (a.data.action) {
33
33
  case "document-ready":
@@ -48,19 +48,21 @@ function g(e) {
48
48
  }
49
49
  }
50
50
  return o(() => {
51
- window.addEventListener("message", d);
51
+ window.addEventListener("message", s);
52
52
  }, []), o(() => () => {
53
- window.removeEventListener("message", d);
54
- }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
53
+ window.removeEventListener("message", s);
54
+ }, []), /* @__PURE__ */ i("iframe", { ref: t, className: e.className, src: d() });
55
55
  }
56
56
  function h(e) {
57
- const t = i(null);
58
- function s() {
57
+ const t = r(null);
58
+ function d() {
59
59
  const a = e.host || "https://app.documenso.com", c = btoa(
60
60
  encodeURIComponent(
61
61
  JSON.stringify({
62
62
  name: e.name,
63
63
  lockName: e.lockName,
64
+ email: e.email,
65
+ lockEmail: e.lockEmail,
64
66
  css: e.css,
65
67
  cssVars: e.cssVars,
66
68
  darkModeDisabled: e.darkModeDisabled,
@@ -71,7 +73,7 @@ function h(e) {
71
73
  );
72
74
  return `${new URL(`/embed/sign/${e.token}`, a)}#${c}`;
73
75
  }
74
- function d(a) {
76
+ function s(a) {
75
77
  if (t.current?.contentWindow === a.source)
76
78
  switch (a.data.action) {
77
79
  case "document-ready":
@@ -89,14 +91,14 @@ function h(e) {
89
91
  }
90
92
  }
91
93
  return o(() => {
92
- window.addEventListener("message", d);
94
+ window.addEventListener("message", s);
93
95
  }, []), o(() => () => {
94
- window.removeEventListener("message", d);
95
- }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
96
+ window.removeEventListener("message", s);
97
+ }, []), /* @__PURE__ */ i("iframe", { ref: t, className: e.className, src: d() });
96
98
  }
97
- function D(e) {
98
- const t = i(null);
99
- function s() {
99
+ function E(e) {
100
+ const t = r(null);
101
+ function d() {
100
102
  const a = e.host || "https://app.documenso.com", c = btoa(
101
103
  encodeURIComponent(
102
104
  JSON.stringify({
@@ -111,21 +113,21 @@ function D(e) {
111
113
  ), n = new URL("/embed/v1/authoring/document/create", a);
112
114
  return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
113
115
  }
114
- function d(a) {
116
+ function s(a) {
115
117
  t.current?.contentWindow === a.source && a.data.type === "document-created" && e.onDocumentCreated?.({
116
118
  documentId: a.data.documentId,
117
119
  externalId: a.data.externalId
118
120
  });
119
121
  }
120
122
  return o(() => {
121
- window.addEventListener("message", d);
123
+ window.addEventListener("message", s);
122
124
  }, []), o(() => () => {
123
- window.removeEventListener("message", d);
124
- }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
125
+ window.removeEventListener("message", s);
126
+ }, []), /* @__PURE__ */ i("iframe", { ref: t, className: e.className, src: d() });
125
127
  }
126
- function E(e) {
127
- const t = i(null);
128
- function s() {
128
+ function I(e) {
129
+ const t = r(null);
130
+ function d() {
129
131
  const a = e.host || "https://app.documenso.com", c = btoa(
130
132
  encodeURIComponent(
131
133
  JSON.stringify({
@@ -140,21 +142,21 @@ function E(e) {
140
142
  ), n = new URL("/embed/v1/authoring/template/create", a);
141
143
  return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
142
144
  }
143
- function d(a) {
145
+ function s(a) {
144
146
  t.current?.contentWindow === a.source && a.data.type === "template-created" && e.onTemplateCreated?.({
145
147
  templateId: a.data.templateId,
146
148
  externalId: a.data.externalId
147
149
  });
148
150
  }
149
151
  return o(() => {
150
- window.addEventListener("message", d);
152
+ window.addEventListener("message", s);
151
153
  }, []), o(() => () => {
152
- window.removeEventListener("message", d);
153
- }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
154
+ window.removeEventListener("message", s);
155
+ }, []), /* @__PURE__ */ i("iframe", { ref: t, className: e.className, src: d() });
154
156
  }
155
- function _(e) {
156
- const t = i(null);
157
- function s() {
157
+ function D(e) {
158
+ const t = r(null);
159
+ function d() {
158
160
  const a = e.host || "https://app.documenso.com", c = btoa(
159
161
  encodeURIComponent(
160
162
  JSON.stringify({
@@ -174,21 +176,21 @@ function _(e) {
174
176
  );
175
177
  return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
176
178
  }
177
- function d(a) {
179
+ function s(a) {
178
180
  t.current?.contentWindow === a.source && a.data.type === "document-updated" && e.onDocumentUpdated?.({
179
181
  documentId: a.data.documentId,
180
182
  externalId: a.data.externalId
181
183
  });
182
184
  }
183
185
  return o(() => {
184
- window.addEventListener("message", d);
186
+ window.addEventListener("message", s);
185
187
  }, []), o(() => () => {
186
- window.removeEventListener("message", d);
187
- }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
188
+ window.removeEventListener("message", s);
189
+ }, []), /* @__PURE__ */ i("iframe", { ref: t, className: e.className, src: d() });
188
190
  }
189
- function I(e) {
190
- const t = i(null);
191
- function s() {
191
+ function _(e) {
192
+ const t = r(null);
193
+ function d() {
192
194
  const a = e.host || "https://app.documenso.com", c = btoa(
193
195
  encodeURIComponent(
194
196
  JSON.stringify({
@@ -207,21 +209,81 @@ function I(e) {
207
209
  );
208
210
  return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
209
211
  }
210
- function d(a) {
212
+ function s(a) {
211
213
  t.current?.contentWindow === a.source && a.data.type === "template-updated" && e.onTemplateUpdated?.({
212
214
  templateId: a.data.templateId,
213
215
  externalId: a.data.externalId
214
216
  });
215
217
  }
216
218
  return o(() => {
217
- window.addEventListener("message", d);
219
+ window.addEventListener("message", s);
218
220
  }, []), o(() => () => {
219
- window.removeEventListener("message", d);
220
- }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
221
+ window.removeEventListener("message", s);
222
+ }, []), /* @__PURE__ */ i("iframe", { ref: t, className: e.className, src: d() });
221
223
  }
222
224
  function U(e) {
223
- const t = i(null);
224
- function s() {
225
+ const t = r(null);
226
+ function d() {
227
+ const a = e.host || "https://app.documenso.com", c = btoa(
228
+ encodeURIComponent(
229
+ JSON.stringify({
230
+ externalId: e.externalId,
231
+ type: e.type,
232
+ features: e.features,
233
+ css: e.css,
234
+ cssVars: e.cssVars,
235
+ darkModeDisabled: e.darkModeDisabled
236
+ })
237
+ )
238
+ ), n = new URL("/embed/v2/authoring/envelope/create", a);
239
+ return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
240
+ }
241
+ function s(a) {
242
+ t.current?.contentWindow === a.source && a.data.type === "envelope-created" && e.onEnvelopeCreated?.({
243
+ envelopeId: a.data.envelopeId,
244
+ externalId: a.data.externalId
245
+ });
246
+ }
247
+ return o(() => {
248
+ window.addEventListener("message", s);
249
+ }, []), o(() => () => {
250
+ window.removeEventListener("message", s);
251
+ }, []), /* @__PURE__ */ i("iframe", { ref: t, className: e.className, src: d() });
252
+ }
253
+ function N(e) {
254
+ const t = r(null);
255
+ function d() {
256
+ const a = e.host || "https://app.documenso.com", c = btoa(
257
+ encodeURIComponent(
258
+ JSON.stringify({
259
+ externalId: e.externalId,
260
+ features: e.features,
261
+ css: e.css,
262
+ cssVars: e.cssVars,
263
+ darkModeDisabled: e.darkModeDisabled
264
+ })
265
+ )
266
+ ), n = new URL(
267
+ `/embed/v2/authoring/envelope/edit/${e.envelopeId}`,
268
+ a
269
+ );
270
+ return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
271
+ }
272
+ function s(a) {
273
+ t.current?.contentWindow === a.source && a.data.type === "envelope-updated" && e.onEnvelopeUpdated?.({
274
+ envelopeId: a.data.envelopeId,
275
+ externalId: a.data.externalId
276
+ });
277
+ }
278
+ return o(() => {
279
+ window.addEventListener("message", s);
280
+ }, []), o(() => () => {
281
+ window.removeEventListener("message", s);
282
+ }, []), /* @__PURE__ */ i("iframe", { ref: t, className: e.className, src: d() });
283
+ }
284
+ function y(e) {
285
+ const t = r(null);
286
+ function d() {
225
287
  const a = e.host || "https://app.documenso.com", c = btoa(
226
288
  encodeURIComponent(
227
289
  JSON.stringify({
@@ -235,11 +297,11 @@ function U(e) {
235
297
  })
236
298
  )
237
299
  ), n = new URL("/embed/v1/multisign", a);
238
- for (const r of e.tokens)
239
- n.searchParams.append("token", r);
300
+ for (const m of e.tokens)
301
+ n.searchParams.append("token", m);
240
302
  return `${n}#${c}`;
241
303
  }
242
- function d(a) {
304
+ function s(a) {
243
305
  if (t.current?.contentWindow === a.source)
244
306
  switch (a.data.action) {
245
307
  case "document-ready":
@@ -260,21 +322,25 @@ function U(e) {
260
322
  }
261
323
  }
262
324
  return o(() => {
263
- window.addEventListener("message", d);
325
+ window.addEventListener("message", s);
264
326
  }, []), o(() => () => {
265
- window.removeEventListener("message", d);
266
- }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
327
+ window.removeEventListener("message", s);
328
+ }, []), /* @__PURE__ */ i("iframe", { ref: t, className: e.className, src: d() });
267
329
  }
268
330
  export {
269
- D as EmbedCreateDocumentV1,
270
- E as EmbedCreateTemplateV1,
331
+ E as EmbedCreateDocumentV1,
332
+ U as EmbedCreateEnvelopeV2,
333
+ I as EmbedCreateTemplateV1,
271
334
  g as EmbedDirectTemplate,
272
335
  h as EmbedSignDocument,
273
- _ as EmbedUpdateDocumentV1,
274
- I as EmbedUpdateTemplateV1,
275
- D as unstable_EmbedCreateDocument,
276
- E as unstable_EmbedCreateTemplate,
277
- U as unstable_EmbedMultiSignDocument,
278
- _ as unstable_EmbedUpdateDocument,
279
- I as unstable_EmbedUpdateTemplate
336
+ D as EmbedUpdateDocumentV1,
337
+ N as EmbedUpdateEnvelopeV2,
338
+ _ as EmbedUpdateTemplateV1,
339
+ E as unstable_EmbedCreateDocument,
340
+ U as unstable_EmbedCreateEnvelope,
341
+ I as unstable_EmbedCreateTemplate,
342
+ y as unstable_EmbedMultiSignDocument,
343
+ D as unstable_EmbedUpdateDocument,
344
+ N as unstable_EmbedUpdateEnvelope,
345
+ _ as unstable_EmbedUpdateTemplate
280
346
  };
@@ -9,6 +9,8 @@ export type EmbedSignDocumentProps = {
9
9
  darkModeDisabled?: boolean | undefined;
10
10
  name?: string | undefined;
11
11
  lockName?: boolean | undefined;
12
+ email?: string | undefined;
13
+ lockEmail?: boolean | undefined;
12
14
  allowDocumentRejection?: boolean | undefined;
13
15
  additionalProps?: Record<string, string | number | boolean> | undefined;
14
16
  onDocumentReady?: () => void;
@@ -0,0 +1,20 @@
1
+ import { h } from 'preact';
2
+ import { CssVars } from './css-vars';
3
+ import { DeepPartial, EnvelopeEditorSettings } from './features-type';
4
+ export type EmbedUpdateEnvelopeProps = {
5
+ className?: string;
6
+ host?: string;
7
+ presignToken: string;
8
+ externalId?: string;
9
+ envelopeId: string;
10
+ css?: string | undefined;
11
+ cssVars?: (CssVars & Record<string, string>) | undefined;
12
+ darkModeDisabled?: boolean | undefined;
13
+ features?: DeepPartial<EnvelopeEditorSettings> & Record<string, any>;
14
+ onEnvelopeUpdated?: (data: {
15
+ externalId: string | null;
16
+ envelopeId: string;
17
+ }) => void;
18
+ };
19
+ declare function EmbedUpdateEnvelope(props: EmbedUpdateEnvelopeProps): h.JSX.Element;
20
+ export default EmbedUpdateEnvelope;
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "@documenso/embed-preact",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/documenso/embeds",
8
+ "directory": "packages/preact"
9
+ },
5
10
  "files": [
6
11
  "dist"
7
12
  ],