@documenso/embed-preact 0.2.0 → 0.2.1-rc.1

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,26 @@
1
+ import { h } from 'preact';
2
+ import { CssVars } from './css-vars';
3
+ export type EmbedCreateDocumentProps = {
4
+ className?: string;
5
+ host?: string;
6
+ presignToken: string;
7
+ externalId?: string;
8
+ css?: string | undefined;
9
+ cssVars?: (CssVars & Record<string, string>) | undefined;
10
+ darkModeDisabled?: boolean | undefined;
11
+ features?: {
12
+ allowConfigureSignatureTypes?: boolean;
13
+ allowConfigureLanguage?: boolean;
14
+ allowConfigureDateFormat?: boolean;
15
+ allowConfigureTimezone?: boolean;
16
+ allowConfigureRedirectUrl?: boolean;
17
+ allowConfigureCommunication?: boolean;
18
+ };
19
+ additionalProps?: Record<string, string | number | boolean> | undefined;
20
+ onDocumentCreated?: (data: {
21
+ externalId: string;
22
+ documentId: number;
23
+ }) => void;
24
+ };
25
+ declare function EmbedCreateDocument(props: EmbedCreateDocumentProps): h.JSX.Element;
26
+ export default EmbedCreateDocument;
@@ -0,0 +1,26 @@
1
+ import { h } from 'preact';
2
+ import { CssVars } from './css-vars';
3
+ export type EmbedCreateTemplateProps = {
4
+ className?: string;
5
+ host?: string;
6
+ presignToken: string;
7
+ externalId?: string;
8
+ css?: string | undefined;
9
+ cssVars?: (CssVars & Record<string, string>) | undefined;
10
+ darkModeDisabled?: boolean | undefined;
11
+ features?: {
12
+ allowConfigureSignatureTypes?: boolean;
13
+ allowConfigureLanguage?: boolean;
14
+ allowConfigureDateFormat?: boolean;
15
+ allowConfigureTimezone?: boolean;
16
+ allowConfigureRedirectUrl?: boolean;
17
+ allowConfigureCommunication?: boolean;
18
+ };
19
+ additionalProps?: Record<string, string | number | boolean> | undefined;
20
+ onTemplateCreated?: (data: {
21
+ externalId: string;
22
+ templateId: number;
23
+ }) => void;
24
+ };
25
+ declare function EmbedCreateTemplate(props: EmbedCreateTemplateProps): h.JSX.Element;
26
+ export default EmbedCreateTemplate;
@@ -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.d.mts CHANGED
@@ -1,2 +1,4 @@
1
1
  export { default as EmbedDirectTemplate } from './direct-template';
2
2
  export { default as EmbedSignDocument } from './sign-document';
3
+ export { default as unstable_EmbedCreateDocument } from './create-document';
4
+ export { default as unstable_EmbedCreateTemplate } from './create-template';
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export { default as EmbedDirectTemplate } from './direct-template';
2
2
  export { default as EmbedSignDocument } from './sign-document';
3
+ export { default as unstable_EmbedCreateDocument } from './create-document';
4
+ export { default as unstable_EmbedCreateTemplate } from './create-template';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("preact"),o=require("preact/hooks");var _=0;function f(e,a,u,m,n,c){a||(a={});var t,d,i=a;if("ref"in i)for(d in i={},a)d=="ref"?t=a[d]:i[d]=a[d];var l={type:e,props:i,key:u,ref:t,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--_,__i:-1,__u:0,__source:n,__self:c};return r.options.vnode&&r.options.vnode(l),l}function b(e){const a=o.useRef(null);function u(){const n=e.host||"https://app.documenso.com",c=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}#${c}`}function m(n){var c,t,d,i,l,s;if(((c=a.current)==null?void 0:c.contentWindow)===n.source)switch(n.data.action){case"document-ready":(t=e.onDocumentReady)==null||t.call(e);break;case"document-completed":(d=e.onDocumentCompleted)==null||d.call(e,n.data.data);break;case"document-error":(i=e.onDocumentError)==null||i.call(e,n.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 o.useEffect(()=>{window.addEventListener("message",m)},[]),o.useEffect(()=>()=>{window.removeEventListener("message",m)},[]),f("iframe",{ref:a,className:e.className,src:u()})}function k(e){const a=o.useRef(null);function u(){const n=e.host||"https://app.documenso.com",c=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)}#${c}`}function m(n){var c,t,d,i;if(((c=a.current)==null?void 0:c.contentWindow)===n.source)switch(n.data.action){case"document-ready":(t=e.onDocumentReady)==null||t.call(e);break;case"document-completed":(d=e.onDocumentCompleted)==null||d.call(e,n.data.data);break;case"document-error":(i=e.onDocumentError)==null||i.call(e,n.data.data);break}}return o.useEffect(()=>{window.addEventListener("message",m)},[]),o.useEffect(()=>()=>{window.removeEventListener("message",m)},[]),f("iframe",{ref:a,className:e.className,src:u()})}exports.EmbedDirectTemplate=b;exports.EmbedSignDocument=k;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("preact"),s=require("preact/hooks");var b=0;function l(e,c,m,d,t,n){c||(c={});var a,i,o=c;if("ref"in o)for(i in o={},c)i=="ref"?a=c[i]:o[i]=c[i];var u={type:e,props:o,key:m,ref:a,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--b,__i:-1,__u:0,__source:t,__self:n};return f.options.vnode&&f.options.vnode(u),u}function k(e){const c=s.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 d(t){var n,a,i,o,u,r;if(((n=c.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 s.useEffect(()=>{window.addEventListener("message",d)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",d)},[]),l("iframe",{ref:c,className:e.className,src:m()})}function _(e){const c=s.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 d(t){var n,a,i,o,u;if(((n=c.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 s.useEffect(()=>{window.addEventListener("message",d)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",d)},[]),l("iframe",{ref:c,className:e.className,src:m()})}function w(e){const c=s.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})));return`${new URL("/embed/v1/authoring/document/create",t)}#${n}`}function d(t){var n,a;if(((n=c.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"document-completed":(a=e.onDocumentCreated)==null||a.call(e,{documentId:t.data.documentId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",d)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",d)},[]),l("iframe",{ref:c,className:e.className,src:m()})}function g(e){const c=s.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})));return`${new URL("/embed/v1/authoring/template/create",t)}#${n}`}function d(t){var n,a;if(((n=c.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"template-completed":(a=e.onTemplateCreated)==null||a.call(e,{templateId:t.data.templateId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",d)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",d)},[]),l("iframe",{ref:c,className:e.className,src:m()})}exports.EmbedDirectTemplate=k;exports.EmbedSignDocument=_;exports.unstable_EmbedCreateDocument=w;exports.unstable_EmbedCreateTemplate=g;
package/dist/index.mjs CHANGED
@@ -1,17 +1,17 @@
1
- import { options as r } from "preact";
2
- import { useRef as f, useEffect as u } from "preact/hooks";
1
+ import { options as b } from "preact";
2
+ import { useRef as r, useEffect as l } from "preact/hooks";
3
3
  var k = 0;
4
- function _(e, a, o, m, n, t) {
5
- a || (a = {});
6
- var c, d, i = a;
7
- if ("ref" in i) for (d in i = {}, a) d == "ref" ? c = a[d] : i[d] = a[d];
8
- var l = { type: e, props: i, key: o, ref: c, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --k, __i: -1, __u: 0, __source: n, __self: t };
9
- return r.vnode && r.vnode(l), l;
4
+ function u(e, c, m, d, a, n) {
5
+ c || (c = {});
6
+ var t, i, s = c;
7
+ if ("ref" in s) for (i in s = {}, c) i == "ref" ? t = c[i] : s[i] = c[i];
8
+ var o = { type: e, props: s, key: m, ref: t, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --k, __i: -1, __u: 0, __source: a, __self: n };
9
+ return b.vnode && b.vnode(o), o;
10
10
  }
11
- function w(e) {
12
- const a = f(null);
13
- function o() {
14
- const n = e.host || "https://app.documenso.com", t = btoa(
11
+ function g(e) {
12
+ const c = r(null);
13
+ function m() {
14
+ const a = e.host || "https://app.documenso.com", n = btoa(
15
15
  encodeURIComponent(
16
16
  JSON.stringify({
17
17
  name: e.name,
@@ -20,77 +20,157 @@ function w(e) {
20
20
  lockEmail: e.lockEmail,
21
21
  css: e.css,
22
22
  cssVars: e.cssVars,
23
- darkModeDisabled: e.darkModeDisabled
23
+ darkModeDisabled: e.darkModeDisabled,
24
+ ...e.additionalProps
24
25
  })
25
26
  )
26
- ), c = new URL(`/embed/direct/${e.token}`, n);
27
- return e.externalId && c.searchParams.set("externalId", e.externalId), `${c}#${t}`;
27
+ ), t = new URL(`/embed/direct/${e.token}`, a);
28
+ return e.externalId && t.searchParams.set("externalId", e.externalId), `${t}#${n}`;
28
29
  }
29
- function m(n) {
30
- var t, c, d, i, l, s;
31
- if (((t = a.current) == null ? void 0 : t.contentWindow) === n.source)
32
- switch (n.data.action) {
30
+ function d(a) {
31
+ var n, t, i, s, o, f;
32
+ if (((n = c.current) == null ? void 0 : n.contentWindow) === a.source)
33
+ switch (a.data.action) {
33
34
  case "document-ready":
34
- (c = e.onDocumentReady) == null || c.call(e);
35
+ (t = e.onDocumentReady) == null || t.call(e);
35
36
  break;
36
37
  case "document-completed":
37
- (d = e.onDocumentCompleted) == null || d.call(e, n.data.data);
38
+ (i = e.onDocumentCompleted) == null || i.call(e, a.data.data);
38
39
  break;
39
40
  case "document-error":
40
- (i = e.onDocumentError) == null || i.call(e, n.data.data);
41
+ (s = e.onDocumentError) == null || s.call(e, a.data.data);
41
42
  break;
42
43
  case "field-signed":
43
- (l = e.onFieldSigned) == null || l.call(e);
44
+ (o = e.onFieldSigned) == null || o.call(e);
44
45
  break;
45
46
  case "field-unsigned":
46
- (s = e.onFieldUnsigned) == null || s.call(e);
47
+ (f = e.onFieldUnsigned) == null || f.call(e);
47
48
  break;
48
49
  }
49
50
  }
50
- return u(() => {
51
- window.addEventListener("message", m);
52
- }, []), u(() => () => {
53
- window.removeEventListener("message", m);
54
- }, []), /* @__PURE__ */ _("iframe", { ref: a, className: e.className, src: o() });
51
+ return l(() => {
52
+ window.addEventListener("message", d);
53
+ }, []), l(() => () => {
54
+ window.removeEventListener("message", d);
55
+ }, []), /* @__PURE__ */ u("iframe", { ref: c, className: e.className, src: m() });
55
56
  }
56
57
  function D(e) {
57
- const a = f(null);
58
- function o() {
59
- const n = e.host || "https://app.documenso.com", t = btoa(
58
+ const c = r(null);
59
+ function m() {
60
+ const a = e.host || "https://app.documenso.com", n = btoa(
60
61
  encodeURIComponent(
61
62
  JSON.stringify({
62
63
  name: e.name,
63
64
  lockName: e.lockName,
64
65
  css: e.css,
65
66
  cssVars: e.cssVars,
66
- darkModeDisabled: e.darkModeDisabled
67
+ darkModeDisabled: e.darkModeDisabled,
68
+ allowDocumentRejection: e.allowDocumentRejection,
69
+ ...e.additionalProps
67
70
  })
68
71
  )
69
72
  );
70
- return `${new URL(`/embed/sign/${e.token}`, n)}#${t}`;
73
+ return `${new URL(`/embed/sign/${e.token}`, a)}#${n}`;
71
74
  }
72
- function m(n) {
73
- var t, c, d, i;
74
- if (((t = a.current) == null ? void 0 : t.contentWindow) === n.source)
75
- switch (n.data.action) {
75
+ function d(a) {
76
+ var n, t, i, s, o;
77
+ if (((n = c.current) == null ? void 0 : n.contentWindow) === a.source)
78
+ switch (a.data.action) {
76
79
  case "document-ready":
77
- (c = e.onDocumentReady) == null || c.call(e);
80
+ (t = e.onDocumentReady) == null || t.call(e);
78
81
  break;
79
82
  case "document-completed":
80
- (d = e.onDocumentCompleted) == null || d.call(e, n.data.data);
83
+ (i = e.onDocumentCompleted) == null || i.call(e, a.data.data);
81
84
  break;
82
85
  case "document-error":
83
- (i = e.onDocumentError) == null || i.call(e, n.data.data);
86
+ (s = e.onDocumentError) == null || s.call(e, a.data.data);
87
+ break;
88
+ case "document-rejected":
89
+ (o = e.onDocumentRejected) == null || o.call(e, a.data.data);
90
+ break;
91
+ }
92
+ }
93
+ return l(() => {
94
+ window.addEventListener("message", d);
95
+ }, []), l(() => () => {
96
+ window.removeEventListener("message", d);
97
+ }, []), /* @__PURE__ */ u("iframe", { ref: c, className: e.className, src: m() });
98
+ }
99
+ function h(e) {
100
+ const c = r(null);
101
+ function m() {
102
+ const a = e.host || "https://app.documenso.com", n = btoa(
103
+ encodeURIComponent(
104
+ JSON.stringify({
105
+ token: e.presignToken,
106
+ externalId: e.externalId,
107
+ features: e.features,
108
+ css: e.css,
109
+ cssVars: e.cssVars,
110
+ darkModeDisabled: e.darkModeDisabled,
111
+ ...e.additionalProps
112
+ })
113
+ )
114
+ );
115
+ return `${new URL("/embed/v1/authoring/document/create", a)}#${n}`;
116
+ }
117
+ function d(a) {
118
+ var n, t;
119
+ if (((n = c.current) == null ? void 0 : n.contentWindow) === a.source)
120
+ switch (a.data.type) {
121
+ case "document-completed":
122
+ (t = e.onDocumentCreated) == null || t.call(e, {
123
+ documentId: a.data.documentId,
124
+ externalId: a.data.externalId
125
+ });
126
+ break;
127
+ }
128
+ }
129
+ return l(() => {
130
+ window.addEventListener("message", d);
131
+ }, []), l(() => () => {
132
+ window.removeEventListener("message", d);
133
+ }, []), /* @__PURE__ */ u("iframe", { ref: c, className: e.className, src: m() });
134
+ }
135
+ function E(e) {
136
+ const c = r(null);
137
+ function m() {
138
+ const a = e.host || "https://app.documenso.com", n = btoa(
139
+ encodeURIComponent(
140
+ JSON.stringify({
141
+ token: e.presignToken,
142
+ externalId: e.externalId,
143
+ features: e.features,
144
+ css: e.css,
145
+ cssVars: e.cssVars,
146
+ darkModeDisabled: e.darkModeDisabled,
147
+ ...e.additionalProps
148
+ })
149
+ )
150
+ );
151
+ return `${new URL("/embed/v1/authoring/template/create", a)}#${n}`;
152
+ }
153
+ function d(a) {
154
+ var n, t;
155
+ if (((n = c.current) == null ? void 0 : n.contentWindow) === a.source)
156
+ switch (a.data.type) {
157
+ case "template-completed":
158
+ (t = e.onTemplateCreated) == null || t.call(e, {
159
+ templateId: a.data.templateId,
160
+ externalId: a.data.externalId
161
+ });
84
162
  break;
85
163
  }
86
164
  }
87
- return u(() => {
88
- window.addEventListener("message", m);
89
- }, []), u(() => () => {
90
- window.removeEventListener("message", m);
91
- }, []), /* @__PURE__ */ _("iframe", { ref: a, className: e.className, src: o() });
165
+ return l(() => {
166
+ window.addEventListener("message", d);
167
+ }, []), l(() => () => {
168
+ window.removeEventListener("message", d);
169
+ }, []), /* @__PURE__ */ u("iframe", { ref: c, className: e.className, src: m() });
92
170
  }
93
171
  export {
94
- w as EmbedDirectTemplate,
95
- D as EmbedSignDocument
172
+ g as EmbedDirectTemplate,
173
+ D as EmbedSignDocument,
174
+ h as unstable_EmbedCreateDocument,
175
+ E as unstable_EmbedCreateTemplate
96
176
  };
@@ -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): h.JSX.Element;
21
29
  export default EmbedSignDocument;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@documenso/embed-preact",
3
- "version": "0.2.0",
3
+ "version": "0.2.1-rc.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"