@documenso/embed-react 0.2.0 → 0.2.1-rc.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.
@@ -12,6 +12,7 @@ export type EmbedDirectTemplateProps = {
12
12
  lockEmail?: boolean | undefined;
13
13
  name?: string | undefined;
14
14
  lockName?: boolean | undefined;
15
+ additionalProps?: Record<string, string | number | boolean> | undefined;
15
16
  onDocumentReady?: () => void;
16
17
  onDocumentCompleted?: (data: {
17
18
  token: string;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),c=require("react");function f(e){const d=c.useRef(null);function u(){const n=e.host||"https://app.documenso.com",a=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}))),t=new URL(`/embed/direct/${e.token}`,n);return e.externalId&&t.searchParams.set("externalId",e.externalId),`${t}#${a}`}function i(n){var a,t,m,s,l,o;if(((a=d.current)==null?void 0:a.contentWindow)===n.source)switch(n.data.action){case"document-ready":(t=e.onDocumentReady)==null||t.call(e);break;case"document-completed":(m=e.onDocumentCompleted)==null||m.call(e,n.data.data);break;case"document-error":(s=e.onDocumentError)==null||s.call(e,n.data.data);break;case"field-signed":(l=e.onFieldSigned)==null||l.call(e);break;case"field-unsigned":(o=e.onFieldUnsigned)==null||o.call(e);break}}return c.useEffect(()=>{window.addEventListener("message",i)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",i)},[]),r.jsx("iframe",{ref:d,className:e.className,src:u()})}function b(e){const d=c.useRef(null);function u(){const n=e.host||"https://app.documenso.com",a=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled})));return`${new URL(`/embed/sign/${e.token}`,n)}#${a}`}function i(n){var a,t,m,s;if(((a=d.current)==null?void 0:a.contentWindow)===n.source)switch(n.data.action){case"document-ready":(t=e.onDocumentReady)==null||t.call(e);break;case"document-completed":(m=e.onDocumentCompleted)==null||m.call(e,n.data.data);break;case"document-error":(s=e.onDocumentError)==null||s.call(e,n.data.data);break}}return c.useEffect(()=>{window.addEventListener("message",i)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",i)},[]),r.jsx("iframe",{ref:d,className:e.className,src:u()})}exports.EmbedDirectTemplate=f;exports.EmbedSignDocument=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),c=require("react");function r(e){const d=c.useRef(null);function o(){const a=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}))),t=new URL(`/embed/direct/${e.token}`,a);return e.externalId&&t.searchParams.set("externalId",e.externalId),`${t}#${n}`}function i(a){var n,t,m,u,l,s;if(((n=d.current)==null?void 0:n.contentWindow)===a.source)switch(a.data.action){case"document-ready":(t=e.onDocumentReady)==null||t.call(e);break;case"document-completed":(m=e.onDocumentCompleted)==null||m.call(e,a.data.data);break;case"document-error":(u=e.onDocumentError)==null||u.call(e,a.data.data);break;case"field-signed":(l=e.onFieldSigned)==null||l.call(e);break;case"field-unsigned":(s=e.onFieldUnsigned)==null||s.call(e);break}}return c.useEffect(()=>{window.addEventListener("message",i)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",i)},[]),f.jsx("iframe",{ref:d,className:e.className,src:o()})}function b(e){const d=c.useRef(null);function o(){const a=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}`,a)}#${n}`}function i(a){var n,t,m,u,l;if(((n=d.current)==null?void 0:n.contentWindow)===a.source)switch(a.data.action){case"document-ready":(t=e.onDocumentReady)==null||t.call(e);break;case"document-completed":(m=e.onDocumentCompleted)==null||m.call(e,a.data.data);break;case"document-error":(u=e.onDocumentError)==null||u.call(e,a.data.data);break;case"document-rejected":(l=e.onDocumentRejected)==null||l.call(e,a.data.data);break}}return c.useEffect(()=>{window.addEventListener("message",i)},[]),c.useEffect(()=>()=>{window.removeEventListener("message",i)},[]),f.jsx("iframe",{ref:d,className:e.className,src:o()})}exports.EmbedDirectTemplate=r;exports.EmbedSignDocument=b;
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import { useRef as f, useEffect as l } from "react";
3
- function g(e) {
4
- const c = f(null);
5
- function s() {
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import { useRef as r, useEffect as o } from "react";
3
+ function w(e) {
4
+ const c = r(null);
5
+ function u() {
6
6
  const a = e.host || "https://app.documenso.com", n = btoa(
7
7
  encodeURIComponent(
8
8
  JSON.stringify({
@@ -12,14 +12,15 @@ function g(e) {
12
12
  lockEmail: e.lockEmail,
13
13
  css: e.css,
14
14
  cssVars: e.cssVars,
15
- darkModeDisabled: e.darkModeDisabled
15
+ darkModeDisabled: e.darkModeDisabled,
16
+ ...e.additionalProps
16
17
  })
17
18
  )
18
19
  ), t = new URL(`/embed/direct/${e.token}`, a);
19
20
  return e.externalId && t.searchParams.set("externalId", e.externalId), `${t}#${n}`;
20
21
  }
21
22
  function d(a) {
22
- var n, t, m, i, o, u;
23
+ var n, t, m, i, l, s;
23
24
  if (((n = c.current) == null ? void 0 : n.contentWindow) === a.source)
24
25
  switch (a.data.action) {
25
26
  case "document-ready":
@@ -32,22 +33,22 @@ function g(e) {
32
33
  (i = e.onDocumentError) == null || i.call(e, a.data.data);
33
34
  break;
34
35
  case "field-signed":
35
- (o = e.onFieldSigned) == null || o.call(e);
36
+ (l = e.onFieldSigned) == null || l.call(e);
36
37
  break;
37
38
  case "field-unsigned":
38
- (u = e.onFieldUnsigned) == null || u.call(e);
39
+ (s = e.onFieldUnsigned) == null || s.call(e);
39
40
  break;
40
41
  }
41
42
  }
42
- return l(() => {
43
+ return o(() => {
43
44
  window.addEventListener("message", d);
44
- }, []), l(() => () => {
45
+ }, []), o(() => () => {
45
46
  window.removeEventListener("message", d);
46
- }, []), /* @__PURE__ */ r("iframe", { ref: c, className: e.className, src: s() });
47
+ }, []), /* @__PURE__ */ f("iframe", { ref: c, className: e.className, src: u() });
47
48
  }
48
- function w(e) {
49
- const c = f(null);
50
- function s() {
49
+ function D(e) {
50
+ const c = r(null);
51
+ function u() {
51
52
  const a = e.host || "https://app.documenso.com", n = btoa(
52
53
  encodeURIComponent(
53
54
  JSON.stringify({
@@ -55,14 +56,16 @@ function w(e) {
55
56
  lockName: e.lockName,
56
57
  css: e.css,
57
58
  cssVars: e.cssVars,
58
- darkModeDisabled: e.darkModeDisabled
59
+ darkModeDisabled: e.darkModeDisabled,
60
+ allowDocumentRejection: e.allowDocumentRejection,
61
+ ...e.additionalProps
59
62
  })
60
63
  )
61
64
  );
62
65
  return `${new URL(`/embed/sign/${e.token}`, a)}#${n}`;
63
66
  }
64
67
  function d(a) {
65
- var n, t, m, i;
68
+ var n, t, m, i, l;
66
69
  if (((n = c.current) == null ? void 0 : n.contentWindow) === a.source)
67
70
  switch (a.data.action) {
68
71
  case "document-ready":
@@ -74,15 +77,18 @@ function w(e) {
74
77
  case "document-error":
75
78
  (i = e.onDocumentError) == null || i.call(e, a.data.data);
76
79
  break;
80
+ case "document-rejected":
81
+ (l = e.onDocumentRejected) == null || l.call(e, a.data.data);
82
+ break;
77
83
  }
78
84
  }
79
- return l(() => {
85
+ return o(() => {
80
86
  window.addEventListener("message", d);
81
- }, []), l(() => () => {
87
+ }, []), o(() => () => {
82
88
  window.removeEventListener("message", d);
83
- }, []), /* @__PURE__ */ r("iframe", { ref: c, className: e.className, src: s() });
89
+ }, []), /* @__PURE__ */ f("iframe", { ref: c, className: e.className, src: u() });
84
90
  }
85
91
  export {
86
- g as EmbedDirectTemplate,
87
- w as EmbedSignDocument
92
+ w as EmbedDirectTemplate,
93
+ D as EmbedSignDocument
88
94
  };
@@ -9,6 +9,8 @@ export type EmbedSignDocumentProps = {
9
9
  darkModeDisabled?: boolean | undefined;
10
10
  name?: string | undefined;
11
11
  lockName?: boolean | undefined;
12
+ allowDocumentRejection?: boolean | undefined;
13
+ additionalProps?: Record<string, string | number | boolean> | undefined;
12
14
  onDocumentReady?: () => void;
13
15
  onDocumentCompleted?: (data: {
14
16
  token: string;
@@ -16,6 +18,12 @@ export type EmbedSignDocumentProps = {
16
18
  recipientId: number;
17
19
  }) => void;
18
20
  onDocumentError?: (error: string) => void;
21
+ onDocumentRejected?: (data: {
22
+ token: string;
23
+ documentId: number;
24
+ recipientId: number;
25
+ reason: string;
26
+ }) => void;
19
27
  };
20
28
  declare function EmbedSignDocument(props: EmbedSignDocumentProps): React.JSX.Element;
21
29
  export default EmbedSignDocument;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@documenso/embed-react",
3
- "version": "0.2.0",
3
+ "version": "0.2.1-rc.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"