@documenso/embed-react 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 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){s.current?.contentWindow===t.source&&t.data.type==="document-created"&&e.onDocumentCreated?.({documentId:t.data.documentId,externalId:t.data.externalId})}return n.useEffect(()=>{window.addEventListener("message",c)},[]),n.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),r.jsx("iframe",{ref:s,className:e.className,src:d()})}function i(e){const s=n.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL("/embed/v1/authoring/template/create",t);return a.searchParams.set("token",e.presignToken),a.hash=o,a.toString()}function c(t){s.current?.contentWindow===t.source&&t.data.type==="template-created"&&e.onTemplateCreated?.({templateId:t.data.templateId,externalId:t.data.externalId})}return n.useEffect(()=>{window.addEventListener("message",c)},[]),n.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),r.jsx("iframe",{ref:s,className:e.className,src:d()})}function u(e){const s=n.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({token:e.presignToken,externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,onlyEditFields:e.onlyEditFields,...e.additionalProps}))),a=new URL(`/embed/v1/authoring/document/edit/${e.documentId}`,t);return a.searchParams.set("token",e.presignToken),a.hash=o,a.toString()}function c(t){s.current?.contentWindow===t.source&&t.data.type==="document-updated"&&e.onDocumentUpdated?.({documentId:t.data.documentId,externalId:t.data.externalId})}return n.useEffect(()=>{window.addEventListener("message",c)},[]),n.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),r.jsx("iframe",{ref:s,className:e.className,src:d()})}function l(e){const s=n.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,onlyEditFields:e.onlyEditFields,...e.additionalProps}))),a=new URL(`/embed/v1/authoring/template/edit/${e.templateId}`,t);return a.searchParams.set("token",e.presignToken),a.hash=o,a.toString()}function c(t){s.current?.contentWindow===t.source&&t.data.type==="template-updated"&&e.onTemplateUpdated?.({templateId:t.data.templateId,externalId:t.data.externalId})}return n.useEffect(()=>{window.addEventListener("message",c)},[]),n.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),r.jsx("iframe",{ref:s,className:e.className,src:d()})}function E(e){const s=n.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,allowDocumentRejection:e.allowDocumentRejection,...e.additionalProps}))),a=new URL("/embed/v1/multisign",t);for(const f of e.tokens)a.searchParams.append("token",f);return`${a}#${o}`}function c(t){if(s.current?.contentWindow===t.source)switch(t.data.action){case"document-ready":e.onDocumentReady?.();break;case"document-completed":e.onDocumentCompleted?.(t.data.data);break;case"document-error":e.onDocumentError?.(t.data.data);break;case"document-rejected":e.onDocumentRejected?.(t.data.data);break;case"all-documents-completed":e.onAllDocumentsCompleted?.(t.data.data);break}}return n.useEffect(()=>{window.addEventListener("message",c)},[]),n.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),r.jsx("iframe",{ref:s,className:e.className,src:d()})}exports.EmbedCreateDocumentV1=m;exports.EmbedCreateTemplateV1=i;exports.EmbedDirectTemplate=b;exports.EmbedSignDocument=k;exports.EmbedUpdateDocumentV1=u;exports.EmbedUpdateTemplateV1=l;exports.unstable_EmbedCreateDocument=m;exports.unstable_EmbedCreateTemplate=i;exports.unstable_EmbedMultiSignDocument=E;exports.unstable_EmbedUpdateDocument=u;exports.unstable_EmbedUpdateTemplate=l;
package/dist/index.mjs CHANGED
@@ -104,15 +104,10 @@ function k(e) {
104
104
  return t.searchParams.set("token", e.presignToken), t.hash = o, t.toString();
105
105
  }
106
106
  function d(a) {
107
- if (n.current?.contentWindow === a.source)
108
- switch (a.data.type) {
109
- case "document-created":
110
- e.onDocumentCreated?.({
111
- documentId: a.data.documentId,
112
- externalId: a.data.externalId
113
- });
114
- break;
115
- }
107
+ n.current?.contentWindow === a.source && a.data.type === "document-created" && e.onDocumentCreated?.({
108
+ documentId: a.data.documentId,
109
+ externalId: a.data.externalId
110
+ });
116
111
  }
117
112
  return s(() => {
118
113
  window.addEventListener("message", d);
@@ -138,15 +133,10 @@ function w(e) {
138
133
  return t.searchParams.set("token", e.presignToken), t.hash = o, t.toString();
139
134
  }
140
135
  function d(a) {
141
- if (n.current?.contentWindow === a.source)
142
- switch (a.data.type) {
143
- case "template-created":
144
- e.onTemplateCreated?.({
145
- templateId: a.data.templateId,
146
- externalId: a.data.externalId
147
- });
148
- break;
149
- }
136
+ n.current?.contentWindow === a.source && a.data.type === "template-created" && e.onTemplateCreated?.({
137
+ templateId: a.data.templateId,
138
+ externalId: a.data.externalId
139
+ });
150
140
  }
151
141
  return s(() => {
152
142
  window.addEventListener("message", d);
@@ -166,6 +156,7 @@ function g(e) {
166
156
  css: e.css,
167
157
  cssVars: e.cssVars,
168
158
  darkModeDisabled: e.darkModeDisabled,
159
+ onlyEditFields: e.onlyEditFields,
169
160
  ...e.additionalProps
170
161
  })
171
162
  )
@@ -176,15 +167,10 @@ function g(e) {
176
167
  return t.searchParams.set("token", e.presignToken), t.hash = o, t.toString();
177
168
  }
178
169
  function d(a) {
179
- if (n.current?.contentWindow === a.source)
180
- switch (a.data.type) {
181
- case "document-updated":
182
- e.onDocumentUpdated?.({
183
- documentId: a.data.documentId,
184
- externalId: a.data.externalId
185
- });
186
- break;
187
- }
170
+ n.current?.contentWindow === a.source && a.data.type === "document-updated" && e.onDocumentUpdated?.({
171
+ documentId: a.data.documentId,
172
+ externalId: a.data.externalId
173
+ });
188
174
  }
189
175
  return s(() => {
190
176
  window.addEventListener("message", d);
@@ -203,6 +189,7 @@ function h(e) {
203
189
  css: e.css,
204
190
  cssVars: e.cssVars,
205
191
  darkModeDisabled: e.darkModeDisabled,
192
+ onlyEditFields: e.onlyEditFields,
206
193
  ...e.additionalProps
207
194
  })
208
195
  )
@@ -213,15 +200,10 @@ function h(e) {
213
200
  return t.searchParams.set("token", e.presignToken), t.hash = o, t.toString();
214
201
  }
215
202
  function d(a) {
216
- if (n.current?.contentWindow === a.source)
217
- switch (a.data.type) {
218
- case "template-updated":
219
- e.onTemplateUpdated?.({
220
- templateId: a.data.templateId,
221
- externalId: a.data.externalId
222
- });
223
- break;
224
- }
203
+ n.current?.contentWindow === a.source && a.data.type === "template-updated" && e.onTemplateUpdated?.({
204
+ templateId: a.data.templateId,
205
+ externalId: a.data.externalId
206
+ });
225
207
  }
226
208
  return s(() => {
227
209
  window.addEventListener("message", d);
@@ -276,8 +258,12 @@ function D(e) {
276
258
  }, []), /* @__PURE__ */ r("iframe", { ref: n, className: e.className, src: c() });
277
259
  }
278
260
  export {
261
+ k as EmbedCreateDocumentV1,
262
+ w as EmbedCreateTemplateV1,
279
263
  f as EmbedDirectTemplate,
280
264
  b as EmbedSignDocument,
265
+ g as EmbedUpdateDocumentV1,
266
+ h as EmbedUpdateTemplateV1,
281
267
  k as unstable_EmbedCreateDocument,
282
268
  w as unstable_EmbedCreateTemplate,
283
269
  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.5.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"
@@ -40,6 +40,6 @@
40
40
  "@types/react": "^18.0.0 || ^19.0.0",
41
41
  "@vitejs/plugin-react": "^5.0.0",
42
42
  "vite": "^7.0.0",
43
- "vite-plugin-dts": "^4.1.0"
43
+ "vite-plugin-dts": "^4.0.0"
44
44
  }
45
45
  }