@documenso/embed-preact 0.3.0 → 0.5.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 l=require("preact"),s=require("preact/hooks");var f=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,__d:void 0,__c:null,constructor:void 0,__v:--f,__i:-1,__u:0,__source:t,__self:o};return l.options.vnode&&l.options.vnode(u),u}function b(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 k(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 g(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){if(a.current?.contentWindow===t.source)switch(t.data.type){case"document-created":e.onDocumentCreated?.({documentId:t.data.documentId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function w(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){if(a.current?.contentWindow===t.source)switch(t.data.type){case"template-created":e.onTemplateCreated?.({templateId:t.data.templateId,externalId:t.data.externalId});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({token:e.presignToken,externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...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){if(a.current?.contentWindow===t.source)switch(t.data.type){case"document-updated":e.onDocumentUpdated?.({documentId:t.data.documentId,externalId:t.data.externalId});break}}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,...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){if(a.current?.contentWindow===t.source)switch(t.data.type){case"template-updated":e.onTemplateUpdated?.({templateId:t.data.templateId,externalId:t.data.externalId});break}}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.EmbedDirectTemplate=b;exports.EmbedSignDocument=k;exports.unstable_EmbedCreateDocument=g;exports.unstable_EmbedCreateTemplate=w;exports.unstable_EmbedMultiSignDocument=D;exports.unstable_EmbedUpdateDocument=h;exports.unstable_EmbedUpdateTemplate=E;
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;
package/dist/index.mjs CHANGED
@@ -1,17 +1,17 @@
1
1
  import { options as f } from "preact";
2
2
  import { useRef as i, useEffect as o } from "preact/hooks";
3
3
  var b = 0;
4
- function m(e, t, c, d, a, s) {
4
+ function m(e, t, s, d, a, c) {
5
5
  t || (t = {});
6
6
  var n, r, l = t;
7
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: c, ref: n, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --b, __i: -1, __u: 0, __source: a, __self: s };
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 };
9
9
  return f.vnode && f.vnode(u), u;
10
10
  }
11
11
  function g(e) {
12
12
  const t = i(null);
13
- function c() {
14
- const a = e.host || "https://app.documenso.com", s = btoa(
13
+ function s() {
14
+ const a = e.host || "https://app.documenso.com", c = btoa(
15
15
  encodeURIComponent(
16
16
  JSON.stringify({
17
17
  name: e.name,
@@ -25,7 +25,7 @@ function g(e) {
25
25
  })
26
26
  )
27
27
  ), n = new URL(`/embed/direct/${e.token}`, a);
28
- return e.externalId && n.searchParams.set("externalId", e.externalId), `${n}#${s}`;
28
+ return e.externalId && n.searchParams.set("externalId", e.externalId), `${n}#${c}`;
29
29
  }
30
30
  function d(a) {
31
31
  if (t.current?.contentWindow === a.source)
@@ -51,12 +51,12 @@ function g(e) {
51
51
  window.addEventListener("message", d);
52
52
  }, []), o(() => () => {
53
53
  window.removeEventListener("message", d);
54
- }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: c() });
54
+ }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
55
55
  }
56
56
  function h(e) {
57
57
  const t = i(null);
58
- function c() {
59
- const a = e.host || "https://app.documenso.com", s = btoa(
58
+ function s() {
59
+ const a = e.host || "https://app.documenso.com", c = btoa(
60
60
  encodeURIComponent(
61
61
  JSON.stringify({
62
62
  name: e.name,
@@ -69,7 +69,7 @@ function h(e) {
69
69
  })
70
70
  )
71
71
  );
72
- return `${new URL(`/embed/sign/${e.token}`, a)}#${s}`;
72
+ return `${new URL(`/embed/sign/${e.token}`, a)}#${c}`;
73
73
  }
74
74
  function d(a) {
75
75
  if (t.current?.contentWindow === a.source)
@@ -92,12 +92,12 @@ function h(e) {
92
92
  window.addEventListener("message", d);
93
93
  }, []), o(() => () => {
94
94
  window.removeEventListener("message", d);
95
- }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: c() });
95
+ }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
96
96
  }
97
- function _(e) {
97
+ function D(e) {
98
98
  const t = i(null);
99
- function c() {
100
- const a = e.host || "https://app.documenso.com", s = btoa(
99
+ function s() {
100
+ const a = e.host || "https://app.documenso.com", c = btoa(
101
101
  encodeURIComponent(
102
102
  JSON.stringify({
103
103
  externalId: e.externalId,
@@ -109,29 +109,24 @@ function _(e) {
109
109
  })
110
110
  )
111
111
  ), n = new URL("/embed/v1/authoring/document/create", a);
112
- return n.searchParams.set("token", e.presignToken), n.hash = s, n.toString();
112
+ return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
113
113
  }
114
114
  function d(a) {
115
- if (t.current?.contentWindow === a.source)
116
- switch (a.data.type) {
117
- case "document-created":
118
- e.onDocumentCreated?.({
119
- documentId: a.data.documentId,
120
- externalId: a.data.externalId
121
- });
122
- break;
123
- }
115
+ t.current?.contentWindow === a.source && a.data.type === "document-created" && e.onDocumentCreated?.({
116
+ documentId: a.data.documentId,
117
+ externalId: a.data.externalId
118
+ });
124
119
  }
125
120
  return o(() => {
126
121
  window.addEventListener("message", d);
127
122
  }, []), o(() => () => {
128
123
  window.removeEventListener("message", d);
129
- }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: c() });
124
+ }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
130
125
  }
131
- function D(e) {
126
+ function E(e) {
132
127
  const t = i(null);
133
- function c() {
134
- const a = e.host || "https://app.documenso.com", s = btoa(
128
+ function s() {
129
+ const a = e.host || "https://app.documenso.com", c = btoa(
135
130
  encodeURIComponent(
136
131
  JSON.stringify({
137
132
  externalId: e.externalId,
@@ -143,29 +138,24 @@ function D(e) {
143
138
  })
144
139
  )
145
140
  ), n = new URL("/embed/v1/authoring/template/create", a);
146
- return n.searchParams.set("token", e.presignToken), n.hash = s, n.toString();
141
+ return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
147
142
  }
148
143
  function d(a) {
149
- if (t.current?.contentWindow === a.source)
150
- switch (a.data.type) {
151
- case "template-created":
152
- e.onTemplateCreated?.({
153
- templateId: a.data.templateId,
154
- externalId: a.data.externalId
155
- });
156
- break;
157
- }
144
+ t.current?.contentWindow === a.source && a.data.type === "template-created" && e.onTemplateCreated?.({
145
+ templateId: a.data.templateId,
146
+ externalId: a.data.externalId
147
+ });
158
148
  }
159
149
  return o(() => {
160
150
  window.addEventListener("message", d);
161
151
  }, []), o(() => () => {
162
152
  window.removeEventListener("message", d);
163
- }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: c() });
153
+ }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
164
154
  }
165
- function I(e) {
155
+ function _(e) {
166
156
  const t = i(null);
167
- function c() {
168
- const a = e.host || "https://app.documenso.com", s = btoa(
157
+ function s() {
158
+ const a = e.host || "https://app.documenso.com", c = btoa(
169
159
  encodeURIComponent(
170
160
  JSON.stringify({
171
161
  token: e.presignToken,
@@ -174,6 +164,7 @@ function I(e) {
174
164
  css: e.css,
175
165
  cssVars: e.cssVars,
176
166
  darkModeDisabled: e.darkModeDisabled,
167
+ onlyEditFields: e.onlyEditFields,
177
168
  ...e.additionalProps
178
169
  })
179
170
  )
@@ -181,29 +172,24 @@ function I(e) {
181
172
  `/embed/v1/authoring/document/edit/${e.documentId}`,
182
173
  a
183
174
  );
184
- return n.searchParams.set("token", e.presignToken), n.hash = s, n.toString();
175
+ return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
185
176
  }
186
177
  function d(a) {
187
- if (t.current?.contentWindow === a.source)
188
- switch (a.data.type) {
189
- case "document-updated":
190
- e.onDocumentUpdated?.({
191
- documentId: a.data.documentId,
192
- externalId: a.data.externalId
193
- });
194
- break;
195
- }
178
+ t.current?.contentWindow === a.source && a.data.type === "document-updated" && e.onDocumentUpdated?.({
179
+ documentId: a.data.documentId,
180
+ externalId: a.data.externalId
181
+ });
196
182
  }
197
183
  return o(() => {
198
184
  window.addEventListener("message", d);
199
185
  }, []), o(() => () => {
200
186
  window.removeEventListener("message", d);
201
- }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: c() });
187
+ }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
202
188
  }
203
- function E(e) {
189
+ function I(e) {
204
190
  const t = i(null);
205
- function c() {
206
- const a = e.host || "https://app.documenso.com", s = btoa(
191
+ function s() {
192
+ const a = e.host || "https://app.documenso.com", c = btoa(
207
193
  encodeURIComponent(
208
194
  JSON.stringify({
209
195
  externalId: e.externalId,
@@ -211,6 +197,7 @@ function E(e) {
211
197
  css: e.css,
212
198
  cssVars: e.cssVars,
213
199
  darkModeDisabled: e.darkModeDisabled,
200
+ onlyEditFields: e.onlyEditFields,
214
201
  ...e.additionalProps
215
202
  })
216
203
  )
@@ -218,29 +205,24 @@ function E(e) {
218
205
  `/embed/v1/authoring/template/edit/${e.templateId}`,
219
206
  a
220
207
  );
221
- return n.searchParams.set("token", e.presignToken), n.hash = s, n.toString();
208
+ return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
222
209
  }
223
210
  function d(a) {
224
- if (t.current?.contentWindow === a.source)
225
- switch (a.data.type) {
226
- case "template-updated":
227
- e.onTemplateUpdated?.({
228
- templateId: a.data.templateId,
229
- externalId: a.data.externalId
230
- });
231
- break;
232
- }
211
+ t.current?.contentWindow === a.source && a.data.type === "template-updated" && e.onTemplateUpdated?.({
212
+ templateId: a.data.templateId,
213
+ externalId: a.data.externalId
214
+ });
233
215
  }
234
216
  return o(() => {
235
217
  window.addEventListener("message", d);
236
218
  }, []), o(() => () => {
237
219
  window.removeEventListener("message", d);
238
- }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: c() });
220
+ }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
239
221
  }
240
222
  function U(e) {
241
223
  const t = i(null);
242
- function c() {
243
- const a = e.host || "https://app.documenso.com", s = btoa(
224
+ function s() {
225
+ const a = e.host || "https://app.documenso.com", c = btoa(
244
226
  encodeURIComponent(
245
227
  JSON.stringify({
246
228
  name: e.name,
@@ -255,7 +237,7 @@ function U(e) {
255
237
  ), n = new URL("/embed/v1/multisign", a);
256
238
  for (const r of e.tokens)
257
239
  n.searchParams.append("token", r);
258
- return `${n}#${s}`;
240
+ return `${n}#${c}`;
259
241
  }
260
242
  function d(a) {
261
243
  if (t.current?.contentWindow === a.source)
@@ -281,14 +263,18 @@ function U(e) {
281
263
  window.addEventListener("message", d);
282
264
  }, []), o(() => () => {
283
265
  window.removeEventListener("message", d);
284
- }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: c() });
266
+ }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
285
267
  }
286
268
  export {
269
+ D as EmbedCreateDocumentV1,
270
+ E as EmbedCreateTemplateV1,
287
271
  g as EmbedDirectTemplate,
288
272
  h as EmbedSignDocument,
289
- _ as unstable_EmbedCreateDocument,
290
- D as unstable_EmbedCreateTemplate,
273
+ _ as EmbedUpdateDocumentV1,
274
+ I as EmbedUpdateTemplateV1,
275
+ D as unstable_EmbedCreateDocument,
276
+ E as unstable_EmbedCreateTemplate,
291
277
  U as unstable_EmbedMultiSignDocument,
292
- I as unstable_EmbedUpdateDocument,
293
- E as unstable_EmbedUpdateTemplate
278
+ _ as unstable_EmbedUpdateDocument,
279
+ I as unstable_EmbedUpdateTemplate
294
280
  };
@@ -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-preact",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"
@@ -36,8 +36,8 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "@documenso/embed": "*",
39
- "@preact/preset-vite": "^2.9.0",
39
+ "@preact/preset-vite": "^2.0.0",
40
40
  "vite": "^7.0.0",
41
- "vite-plugin-dts": "^4.1.0"
41
+ "vite-plugin-dts": "^4.0.0"
42
42
  }
43
43
  }