@documenso/embed-react 0.2.3 → 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 l=require("react/jsx-runtime"),c=require("react");function f(e){const d=c.useRef(null);function m(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,email:e.email,lockEmail:e.lockEmail,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL(`/embed/direct/${e.token}`,t);return e.externalId&&a.searchParams.set("externalId",e.externalId),`${a}#${n}`}function s(t){var n,a,i,o,u,r;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.action){case"document-ready":(a=e.onDocumentReady)==null||a.call(e);break;case"document-completed":(i=e.onDocumentCompleted)==null||i.call(e,t.data.data);break;case"document-error":(o=e.onDocumentError)==null||o.call(e,t.data.data);break;case"field-signed":(u=e.onFieldSigned)==null||u.call(e);break;case"field-unsigned":(r=e.onFieldUnsigned)==null||r.call(e);break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:m()})}function b(e){const d=c.useRef(null);function m(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,allowDocumentRejection:e.allowDocumentRejection,...e.additionalProps})));return`${new URL(`/embed/sign/${e.token}`,t)}#${n}`}function s(t){var n,a,i,o,u;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.action){case"document-ready":(a=e.onDocumentReady)==null||a.call(e);break;case"document-completed":(i=e.onDocumentCompleted)==null||i.call(e,t.data.data);break;case"document-error":(o=e.onDocumentError)==null||o.call(e,t.data.data);break;case"document-rejected":(u=e.onDocumentRejected)==null||u.call(e,t.data.data);break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:m()})}function k(e){const d=c.useRef(null);function m(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL("/embed/v1/authoring/document/create",t);return a.searchParams.set("token",e.presignToken),a.hash=n,a.toString()}function s(t){var n,a;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"document-created":(a=e.onDocumentCreated)==null||a.call(e,{documentId:t.data.documentId,externalId:t.data.externalId});break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:m()})}function g(e){const d=c.useRef(null);function m(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL("/embed/v1/authoring/template/create",t);return a.searchParams.set("token",e.presignToken),a.hash=n,a.toString()}function s(t){var n,a;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"template-created":(a=e.onTemplateCreated)==null||a.call(e,{templateId:t.data.templateId,externalId:t.data.externalId});break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:m()})}function w(e){const d=c.useRef(null);function m(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({token:e.presignToken,externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL(`/embed/v1/authoring/document/edit/${e.documentId}`,t);return a.searchParams.set("token",e.presignToken),a.hash=n,a.toString()}function s(t){var n,a;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"document-updated":(a=e.onDocumentUpdated)==null||a.call(e,{documentId:t.data.documentId,externalId:t.data.externalId});break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:m()})}function E(e){const d=c.useRef(null);function m(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL(`/embed/v1/authoring/template/edit/${e.templateId}`,t);return a.searchParams.set("token",e.presignToken),a.hash=n,a.toString()}function s(t){var n,a;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"template-updated":(a=e.onTemplateUpdated)==null||a.call(e,{templateId:t.data.templateId,externalId:t.data.externalId});break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:m()})}function h(e){const d=c.useRef(null);function m(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,allowDocumentRejection:e.allowDocumentRejection,...e.additionalProps}))),a=new URL("/embed/v1/multisign",t);for(const i of e.tokens)a.searchParams.append("token",i);return`${a}#${n}`}function s(t){var n,a,i,o,u,r;if(((n=d.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.action){case"document-ready":(a=e.onDocumentReady)==null||a.call(e);break;case"document-completed":(i=e.onDocumentCompleted)==null||i.call(e,t.data.data);break;case"document-error":(o=e.onDocumentError)==null||o.call(e,t.data.data);break;case"document-rejected":(u=e.onDocumentRejected)==null||u.call(e,t.data.data);break;case"all-documents-completed":(r=e.onAllDocumentsCompleted)==null||r.call(e,t.data.data);break}}return c.useEffect(()=>{window.addEventListener("message",s)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",s)},[]),l.jsx("iframe",{ref:d,className:e.className,src:m()})}exports.EmbedDirectTemplate=f;exports.EmbedSignDocument=b;exports.unstable_EmbedCreateDocument=k;exports.unstable_EmbedCreateTemplate=g;exports.unstable_EmbedMultiSignDocument=h;exports.unstable_EmbedUpdateDocument=w;exports.unstable_EmbedUpdateTemplate=E;
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
@@ -1,9 +1,9 @@
1
- import { jsx as u } from "react/jsx-runtime";
2
- import { useRef as r, useEffect as s } from "react";
3
- function w(e) {
4
- const d = r(null);
5
- function m() {
6
- const a = e.host || "https://app.documenso.com", n = btoa(
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { useRef as m, useEffect as s } from "react";
3
+ function f(e) {
4
+ const n = m(null);
5
+ function c() {
6
+ const a = e.host || "https://app.documenso.com", o = btoa(
7
7
  encodeURIComponent(
8
8
  JSON.stringify({
9
9
  name: e.name,
@@ -17,39 +17,38 @@ function w(e) {
17
17
  })
18
18
  )
19
19
  ), t = new URL(`/embed/direct/${e.token}`, a);
20
- return e.externalId && t.searchParams.set("externalId", e.externalId), `${t}#${n}`;
20
+ return e.externalId && t.searchParams.set("externalId", e.externalId), `${t}#${o}`;
21
21
  }
22
- function c(a) {
23
- var n, t, i, o, l, f;
24
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
22
+ function d(a) {
23
+ if (n.current?.contentWindow === a.source)
25
24
  switch (a.data.action) {
26
25
  case "document-ready":
27
- (t = e.onDocumentReady) == null || t.call(e);
26
+ e.onDocumentReady?.();
28
27
  break;
29
28
  case "document-completed":
30
- (i = e.onDocumentCompleted) == null || i.call(e, a.data.data);
29
+ e.onDocumentCompleted?.(a.data.data);
31
30
  break;
32
31
  case "document-error":
33
- (o = e.onDocumentError) == null || o.call(e, a.data.data);
32
+ e.onDocumentError?.(a.data.data);
34
33
  break;
35
34
  case "field-signed":
36
- (l = e.onFieldSigned) == null || l.call(e);
35
+ e.onFieldSigned?.();
37
36
  break;
38
37
  case "field-unsigned":
39
- (f = e.onFieldUnsigned) == null || f.call(e);
38
+ e.onFieldUnsigned?.();
40
39
  break;
41
40
  }
42
41
  }
43
42
  return s(() => {
44
- window.addEventListener("message", c);
43
+ window.addEventListener("message", d);
45
44
  }, []), s(() => () => {
46
- window.removeEventListener("message", c);
47
- }, []), /* @__PURE__ */ u("iframe", { ref: d, className: e.className, src: m() });
45
+ window.removeEventListener("message", d);
46
+ }, []), /* @__PURE__ */ r("iframe", { ref: n, className: e.className, src: c() });
48
47
  }
49
- function g(e) {
50
- const d = r(null);
51
- function m() {
52
- const a = e.host || "https://app.documenso.com", n = btoa(
48
+ function b(e) {
49
+ const n = m(null);
50
+ function c() {
51
+ const a = e.host || "https://app.documenso.com", o = btoa(
53
52
  encodeURIComponent(
54
53
  JSON.stringify({
55
54
  name: e.name,
@@ -62,36 +61,35 @@ function g(e) {
62
61
  })
63
62
  )
64
63
  );
65
- return `${new URL(`/embed/sign/${e.token}`, a)}#${n}`;
64
+ return `${new URL(`/embed/sign/${e.token}`, a)}#${o}`;
66
65
  }
67
- function c(a) {
68
- var n, t, i, o, l;
69
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
66
+ function d(a) {
67
+ if (n.current?.contentWindow === a.source)
70
68
  switch (a.data.action) {
71
69
  case "document-ready":
72
- (t = e.onDocumentReady) == null || t.call(e);
70
+ e.onDocumentReady?.();
73
71
  break;
74
72
  case "document-completed":
75
- (i = e.onDocumentCompleted) == null || i.call(e, a.data.data);
73
+ e.onDocumentCompleted?.(a.data.data);
76
74
  break;
77
75
  case "document-error":
78
- (o = e.onDocumentError) == null || o.call(e, a.data.data);
76
+ e.onDocumentError?.(a.data.data);
79
77
  break;
80
78
  case "document-rejected":
81
- (l = e.onDocumentRejected) == null || l.call(e, a.data.data);
79
+ e.onDocumentRejected?.(a.data.data);
82
80
  break;
83
81
  }
84
82
  }
85
83
  return s(() => {
86
- window.addEventListener("message", c);
84
+ window.addEventListener("message", d);
87
85
  }, []), s(() => () => {
88
- window.removeEventListener("message", c);
89
- }, []), /* @__PURE__ */ u("iframe", { ref: d, className: e.className, src: m() });
86
+ window.removeEventListener("message", d);
87
+ }, []), /* @__PURE__ */ r("iframe", { ref: n, className: e.className, src: c() });
90
88
  }
91
- function h(e) {
92
- const d = r(null);
93
- function m() {
94
- const a = e.host || "https://app.documenso.com", n = btoa(
89
+ function k(e) {
90
+ const n = m(null);
91
+ function c() {
92
+ const a = e.host || "https://app.documenso.com", o = btoa(
95
93
  encodeURIComponent(
96
94
  JSON.stringify({
97
95
  externalId: e.externalId,
@@ -103,14 +101,13 @@ function h(e) {
103
101
  })
104
102
  )
105
103
  ), t = new URL("/embed/v1/authoring/document/create", a);
106
- return t.searchParams.set("token", e.presignToken), t.hash = n, t.toString();
104
+ return t.searchParams.set("token", e.presignToken), t.hash = o, t.toString();
107
105
  }
108
- function c(a) {
109
- var n, t;
110
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
106
+ function d(a) {
107
+ if (n.current?.contentWindow === a.source)
111
108
  switch (a.data.type) {
112
109
  case "document-created":
113
- (t = e.onDocumentCreated) == null || t.call(e, {
110
+ e.onDocumentCreated?.({
114
111
  documentId: a.data.documentId,
115
112
  externalId: a.data.externalId
116
113
  });
@@ -118,15 +115,15 @@ function h(e) {
118
115
  }
119
116
  }
120
117
  return s(() => {
121
- window.addEventListener("message", c);
118
+ window.addEventListener("message", d);
122
119
  }, []), s(() => () => {
123
- window.removeEventListener("message", c);
124
- }, []), /* @__PURE__ */ u("iframe", { ref: d, className: e.className, src: m() });
120
+ window.removeEventListener("message", d);
121
+ }, []), /* @__PURE__ */ r("iframe", { ref: n, className: e.className, src: c() });
125
122
  }
126
- function D(e) {
127
- const d = r(null);
128
- function m() {
129
- const a = e.host || "https://app.documenso.com", n = btoa(
123
+ function w(e) {
124
+ const n = m(null);
125
+ function c() {
126
+ const a = e.host || "https://app.documenso.com", o = btoa(
130
127
  encodeURIComponent(
131
128
  JSON.stringify({
132
129
  externalId: e.externalId,
@@ -138,14 +135,13 @@ function D(e) {
138
135
  })
139
136
  )
140
137
  ), t = new URL("/embed/v1/authoring/template/create", a);
141
- return t.searchParams.set("token", e.presignToken), t.hash = n, t.toString();
138
+ return t.searchParams.set("token", e.presignToken), t.hash = o, t.toString();
142
139
  }
143
- function c(a) {
144
- var n, t;
145
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
140
+ function d(a) {
141
+ if (n.current?.contentWindow === a.source)
146
142
  switch (a.data.type) {
147
143
  case "template-created":
148
- (t = e.onTemplateCreated) == null || t.call(e, {
144
+ e.onTemplateCreated?.({
149
145
  templateId: a.data.templateId,
150
146
  externalId: a.data.externalId
151
147
  });
@@ -153,15 +149,15 @@ function D(e) {
153
149
  }
154
150
  }
155
151
  return s(() => {
156
- window.addEventListener("message", c);
152
+ window.addEventListener("message", d);
157
153
  }, []), s(() => () => {
158
- window.removeEventListener("message", c);
159
- }, []), /* @__PURE__ */ u("iframe", { ref: d, className: e.className, src: m() });
154
+ window.removeEventListener("message", d);
155
+ }, []), /* @__PURE__ */ r("iframe", { ref: n, className: e.className, src: c() });
160
156
  }
161
- function I(e) {
162
- const d = r(null);
163
- function m() {
164
- const a = e.host || "https://app.documenso.com", n = btoa(
157
+ function g(e) {
158
+ const n = m(null);
159
+ function c() {
160
+ const a = e.host || "https://app.documenso.com", o = btoa(
165
161
  encodeURIComponent(
166
162
  JSON.stringify({
167
163
  token: e.presignToken,
@@ -170,6 +166,7 @@ function I(e) {
170
166
  css: e.css,
171
167
  cssVars: e.cssVars,
172
168
  darkModeDisabled: e.darkModeDisabled,
169
+ onlyEditFields: e.onlyEditFields,
173
170
  ...e.additionalProps
174
171
  })
175
172
  )
@@ -177,14 +174,13 @@ function I(e) {
177
174
  `/embed/v1/authoring/document/edit/${e.documentId}`,
178
175
  a
179
176
  );
180
- return t.searchParams.set("token", e.presignToken), t.hash = n, t.toString();
177
+ return t.searchParams.set("token", e.presignToken), t.hash = o, t.toString();
181
178
  }
182
- function c(a) {
183
- var n, t;
184
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
179
+ function d(a) {
180
+ if (n.current?.contentWindow === a.source)
185
181
  switch (a.data.type) {
186
182
  case "document-updated":
187
- (t = e.onDocumentUpdated) == null || t.call(e, {
183
+ e.onDocumentUpdated?.({
188
184
  documentId: a.data.documentId,
189
185
  externalId: a.data.externalId
190
186
  });
@@ -192,15 +188,15 @@ function I(e) {
192
188
  }
193
189
  }
194
190
  return s(() => {
195
- window.addEventListener("message", c);
191
+ window.addEventListener("message", d);
196
192
  }, []), s(() => () => {
197
- window.removeEventListener("message", c);
198
- }, []), /* @__PURE__ */ u("iframe", { ref: d, className: e.className, src: m() });
193
+ window.removeEventListener("message", d);
194
+ }, []), /* @__PURE__ */ r("iframe", { ref: n, className: e.className, src: c() });
199
195
  }
200
- function E(e) {
201
- const d = r(null);
202
- function m() {
203
- const a = e.host || "https://app.documenso.com", n = btoa(
196
+ function h(e) {
197
+ const n = m(null);
198
+ function c() {
199
+ const a = e.host || "https://app.documenso.com", o = btoa(
204
200
  encodeURIComponent(
205
201
  JSON.stringify({
206
202
  externalId: e.externalId,
@@ -208,6 +204,7 @@ function E(e) {
208
204
  css: e.css,
209
205
  cssVars: e.cssVars,
210
206
  darkModeDisabled: e.darkModeDisabled,
207
+ onlyEditFields: e.onlyEditFields,
211
208
  ...e.additionalProps
212
209
  })
213
210
  )
@@ -215,14 +212,13 @@ function E(e) {
215
212
  `/embed/v1/authoring/template/edit/${e.templateId}`,
216
213
  a
217
214
  );
218
- return t.searchParams.set("token", e.presignToken), t.hash = n, t.toString();
215
+ return t.searchParams.set("token", e.presignToken), t.hash = o, t.toString();
219
216
  }
220
- function c(a) {
221
- var n, t;
222
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
217
+ function d(a) {
218
+ if (n.current?.contentWindow === a.source)
223
219
  switch (a.data.type) {
224
220
  case "template-updated":
225
- (t = e.onTemplateUpdated) == null || t.call(e, {
221
+ e.onTemplateUpdated?.({
226
222
  templateId: a.data.templateId,
227
223
  externalId: a.data.externalId
228
224
  });
@@ -230,15 +226,15 @@ function E(e) {
230
226
  }
231
227
  }
232
228
  return s(() => {
233
- window.addEventListener("message", c);
229
+ window.addEventListener("message", d);
234
230
  }, []), s(() => () => {
235
- window.removeEventListener("message", c);
236
- }, []), /* @__PURE__ */ u("iframe", { ref: d, className: e.className, src: m() });
231
+ window.removeEventListener("message", d);
232
+ }, []), /* @__PURE__ */ r("iframe", { ref: n, className: e.className, src: c() });
237
233
  }
238
- function U(e) {
239
- const d = r(null);
240
- function m() {
241
- const a = e.host || "https://app.documenso.com", n = btoa(
234
+ function D(e) {
235
+ const n = m(null);
236
+ function c() {
237
+ const a = e.host || "https://app.documenso.com", o = btoa(
242
238
  encodeURIComponent(
243
239
  JSON.stringify({
244
240
  name: e.name,
@@ -253,41 +249,44 @@ function U(e) {
253
249
  ), t = new URL("/embed/v1/multisign", a);
254
250
  for (const i of e.tokens)
255
251
  t.searchParams.append("token", i);
256
- return `${t}#${n}`;
252
+ return `${t}#${o}`;
257
253
  }
258
- function c(a) {
259
- var n, t, i, o, l, f;
260
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
254
+ function d(a) {
255
+ if (n.current?.contentWindow === a.source)
261
256
  switch (a.data.action) {
262
257
  case "document-ready":
263
- (t = e.onDocumentReady) == null || t.call(e);
258
+ e.onDocumentReady?.();
264
259
  break;
265
260
  case "document-completed":
266
- (i = e.onDocumentCompleted) == null || i.call(e, a.data.data);
261
+ e.onDocumentCompleted?.(a.data.data);
267
262
  break;
268
263
  case "document-error":
269
- (o = e.onDocumentError) == null || o.call(e, a.data.data);
264
+ e.onDocumentError?.(a.data.data);
270
265
  break;
271
266
  case "document-rejected":
272
- (l = e.onDocumentRejected) == null || l.call(e, a.data.data);
267
+ e.onDocumentRejected?.(a.data.data);
273
268
  break;
274
269
  case "all-documents-completed":
275
- (f = e.onAllDocumentsCompleted) == null || f.call(e, a.data.data);
270
+ e.onAllDocumentsCompleted?.(a.data.data);
276
271
  break;
277
272
  }
278
273
  }
279
274
  return s(() => {
280
- window.addEventListener("message", c);
275
+ window.addEventListener("message", d);
281
276
  }, []), s(() => () => {
282
- window.removeEventListener("message", c);
283
- }, []), /* @__PURE__ */ u("iframe", { ref: d, className: e.className, src: m() });
277
+ window.removeEventListener("message", d);
278
+ }, []), /* @__PURE__ */ r("iframe", { ref: n, className: e.className, src: c() });
284
279
  }
285
280
  export {
286
- w as EmbedDirectTemplate,
287
- g as EmbedSignDocument,
288
- h as unstable_EmbedCreateDocument,
289
- D as unstable_EmbedCreateTemplate,
290
- U as unstable_EmbedMultiSignDocument,
291
- I as unstable_EmbedUpdateDocument,
292
- E as unstable_EmbedUpdateTemplate
281
+ k as EmbedCreateDocumentV1,
282
+ w as EmbedCreateTemplateV1,
283
+ f as EmbedDirectTemplate,
284
+ b as EmbedSignDocument,
285
+ g as EmbedUpdateDocumentV1,
286
+ h as EmbedUpdateTemplateV1,
287
+ k as unstable_EmbedCreateDocument,
288
+ w as unstable_EmbedCreateTemplate,
289
+ D as unstable_EmbedMultiSignDocument,
290
+ g as unstable_EmbedUpdateDocument,
291
+ h as unstable_EmbedUpdateTemplate
293
292
  };
@@ -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.2.3",
3
+ "version": "0.4.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"
@@ -32,14 +32,14 @@
32
32
  },
33
33
  "dependencies": {},
34
34
  "peerDependencies": {
35
- "react": "^18.0.0",
36
- "react-dom": "^18.0.0"
35
+ "react": "^18.0.0 || ^19.0.0",
36
+ "react-dom": "^18.0.0 || ^19.0.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@documenso/embed": "*",
40
- "@types/react": "^18.0.0",
41
- "@vitejs/plugin-react": "^4.3.1",
42
- "vite": "^5.4.2",
40
+ "@types/react": "^18.0.0 || ^19.0.0",
41
+ "@vitejs/plugin-react": "^5.0.0",
42
+ "vite": "^7.0.0",
43
43
  "vite-plugin-dts": "^4.1.0"
44
44
  }
45
45
  }